Salome HOME
Merge remote-tracking branch 'remotes/origin/master' into SketchSolver
authorazv <azv@opencascade.com>
Thu, 5 Jun 2014 11:09:28 +0000 (15:09 +0400)
committerazv <azv@opencascade.com>
Thu, 5 Jun 2014 11:09:28 +0000 (15:09 +0400)
Conflicts:
src/GeomAlgoAPI/CMakeLists.txt

134 files changed:
CMakeLists.txt
src/Config/CMakeLists.txt
src/Config/Config.h [deleted file]
src/Config/Config_Common.h
src/Config/Config_FeatureMessage.h
src/Config/Config_FeatureReader.h
src/Config/Config_ModuleReader.h
src/Config/Config_PointerMessage.h
src/Config/Config_WidgetAPI.cpp
src/Config/Config_WidgetAPI.h
src/Config/Config_WidgetReader.h
src/Config/Config_XMLReader.h
src/Config/Config_def.h [new file with mode: 0644]
src/ConstructionPlugin/CMakeLists.txt
src/ConstructionPlugin/ConstructionPlugin_Extrusion.h
src/ConstructionPlugin/ConstructionPlugin_Plugin.cpp
src/ConstructionPlugin/ConstructionPlugin_Plugin.h
src/ConstructionPlugin/ConstructionPlugin_Point.cpp
src/ConstructionPlugin/ConstructionPlugin_Point.h
src/ConstructionPlugin/extrusion_widget.xml
src/GeomAPI/CMakeLists.txt
src/GeomAlgoAPI/CMakeLists.txt
src/GeomAlgoAPI/GeomAlgoAPI.i
src/GeomAlgoAPI/GeomAlgoAPI_PointBuilder.cpp [new file with mode: 0644]
src/GeomAlgoAPI/GeomAlgoAPI_PointBuilder.h [new file with mode: 0644]
src/GeomData/CMakeLists.txt
src/Model/CMakeLists.txt
src/Model/Model_AttributeBoolean.cpp
src/Model/Model_AttributeRefAttr.cpp
src/Model/Model_AttributeRefAttr.h
src/Model/Model_AttributeRefList.cpp
src/Model/Model_AttributeRefList.h
src/Model/Model_AttributeReference.cpp
src/Model/Model_AttributeReference.h
src/Model/Model_Data.cpp
src/Model/Model_Data.h
src/Model/Model_Document.cpp
src/Model/Model_Document.h
src/Model/Model_Events.h
src/Model/Model_Object.cpp
src/Model/Model_Object.h
src/Model/Model_PluginManager.cpp
src/Model/Model_PluginManager.h
src/ModelAPI/ModelAPI_AttributeRefAttr.h
src/ModelAPI/ModelAPI_AttributeRefList.h
src/ModelAPI/ModelAPI_AttributeReference.h
src/ModelAPI/ModelAPI_Data.h
src/ModelAPI/ModelAPI_Feature.h
src/ModelAPI/ModelAPI_Object.h
src/ModuleBase/CMakeLists.txt
src/ModuleBase/ModuleBase_IWorkshop.h [new file with mode: 0644]
src/ModuleBase/ModuleBase_MetaWidget.cpp
src/ModuleBase/ModuleBase_MetaWidget.h
src/ModuleBase/ModuleBase_ModelWidget.h
src/ModuleBase/ModuleBase_Operation.cpp
src/ModuleBase/ModuleBase_Operation.h
src/ModuleBase/ModuleBase_SelectorWidget.cpp [new file with mode: 0644]
src/ModuleBase/ModuleBase_SelectorWidget.h [new file with mode: 0644]
src/ModuleBase/ModuleBase_WidgetFactory.cpp
src/ModuleBase/ModuleBase_WidgetFactory.h
src/ModuleBase/ModuleBase_WidgetPoint2D.cpp
src/ModuleBase/ModuleBase_WidgetPoint2D.h
src/ModuleBase/ModuleBase_Widgets.cpp [new file with mode: 0644]
src/ModuleBase/ModuleBase_Widgets.h [new file with mode: 0644]
src/NewGeom/CMakeLists.txt
src/PartSet/CMakeLists.txt
src/PartSet/PartSet_Constants.h [new file with mode: 0644]
src/PartSet/PartSet_FeaturePrs.cpp [new file with mode: 0644]
src/PartSet/PartSet_FeaturePrs.h [new file with mode: 0644]
src/PartSet/PartSet_Listener.cpp
src/PartSet/PartSet_Module.cpp
src/PartSet/PartSet_Module.h
src/PartSet/PartSet_OperationConstraint.cpp [new file with mode: 0644]
src/PartSet/PartSet_OperationConstraint.h [new file with mode: 0644]
src/PartSet/PartSet_OperationCreateFeature.cpp [new file with mode: 0644]
src/PartSet/PartSet_OperationCreateFeature.h [new file with mode: 0644]
src/PartSet/PartSet_OperationEditLine.cpp
src/PartSet/PartSet_OperationEditLine.h
src/PartSet/PartSet_OperationSketch.cpp
src/PartSet/PartSet_OperationSketch.h
src/PartSet/PartSet_OperationSketchBase.cpp
src/PartSet/PartSet_OperationSketchBase.h
src/PartSet/PartSet_OperationSketchLine.cpp [deleted file]
src/PartSet/PartSet_OperationSketchLine.h [deleted file]
src/PartSet/PartSet_Presentation.cpp [new file with mode: 0644]
src/PartSet/PartSet_Presentation.h [new file with mode: 0644]
src/PartSet/PartSet_TestOCC.cpp
src/PartSet/PartSet_Tools.cpp
src/PartSet/PartSet_Tools.h
src/PartSetPlugin/PartSetPlugin_Part.h
src/PartSetPlugin/PartSetPlugin_Plugin.cpp
src/PartSetPlugin/PartSetPlugin_Plugin.h
src/PartSetPlugin/PartSetPlugin_Remove.cpp
src/PartSetPlugin/PartSetPlugin_Remove.h
src/SketchPlugin/CMakeLists.txt
src/SketchPlugin/SketchPlugin_Arc.h
src/SketchPlugin/SketchPlugin_Circle.h
src/SketchPlugin/SketchPlugin_Constraint.h
src/SketchPlugin/SketchPlugin_ConstraintCoincidence.h
src/SketchPlugin/SketchPlugin_ConstraintDistance.h
src/SketchPlugin/SketchPlugin_ConstraintLength.h
src/SketchPlugin/SketchPlugin_ConstraintParallel.h
src/SketchPlugin/SketchPlugin_ConstraintPerpendicular.h
src/SketchPlugin/SketchPlugin_ConstraintRadius.h
src/SketchPlugin/SketchPlugin_Feature.cpp
src/SketchPlugin/SketchPlugin_Feature.h
src/SketchPlugin/SketchPlugin_Line.h
src/SketchPlugin/SketchPlugin_Plugin.cpp
src/SketchPlugin/SketchPlugin_Plugin.h
src/SketchPlugin/SketchPlugin_Point.h
src/SketchPlugin/SketchPlugin_Sketch.cpp
src/SketchPlugin/SketchPlugin_Sketch.h
src/SketchPlugin/plugin-Sketch.xml
src/SketchSolver/SketchSolver_Constraint.cpp
src/SketchSolver/SketchSolver_ConstraintGroup.cpp
src/SketchSolver/SketchSolver_ConstraintGroup.h
src/SketchSolver/SketchSolver_ConstraintManager.cpp
src/XGUI/CMakeLists.txt
src/XGUI/XGUI_ContextMenuMgr.cpp
src/XGUI/XGUI_Displayer.cpp
src/XGUI/XGUI_Displayer.h
src/XGUI/XGUI_ModuleConnector.cpp [new file with mode: 0644]
src/XGUI/XGUI_ModuleConnector.h [new file with mode: 0644]
src/XGUI/XGUI_ObjectsBrowser.cpp
src/XGUI/XGUI_ObjectsBrowser.h
src/XGUI/XGUI_PropertyPanel.cpp
src/XGUI/XGUI_PropertyPanel.h
src/XGUI/XGUI_Tools.cpp
src/XGUI/XGUI_Tools.h
src/XGUI/XGUI_ViewerProxy.h
src/XGUI/XGUI_ViewerPrs.cpp
src/XGUI/XGUI_ViewerPrs.h
src/XGUI/XGUI_Workshop.cpp
src/XGUI/XGUI_Workshop.h

index bef4cdee832db553cbc8fc76202f5bfcf6f52b3b..4f70d821c7df0d7b6820462f9f0bcc72fad7611a 100644 (file)
@@ -10,6 +10,7 @@ INCLUDE(FindBoost)
 INCLUDE(FindPython)
 INCLUDE(FindSalome)
 INCLUDE(FindSolveSpace)
+INCLUDE(FindCAS)
 
 IF(UNIX)
     IF(CMAKE_COMPILER_IS_GNUCC)
index 2e954c8a844614d3ec2cf3c5b288c6a9a874876e..ebb5efb695ee3c638bf152f765af59f9ee65c266 100644 (file)
@@ -4,7 +4,7 @@ INCLUDE(XMLProcessing)
 INCLUDE_DIRECTORIES (${PROJECT_SOURCE_DIR}/src/Events) 
 
 SET(PROJECT_HEADERS
-  Config.h
+  Config_def.h
   Config_FeatureMessage.h
   Config_XMLReader.h
   Config_ModuleReader.h
diff --git a/src/Config/Config.h b/src/Config/Config.h
deleted file mode 100644 (file)
index 587ac53..0000000
+++ /dev/null
@@ -1,18 +0,0 @@
-#ifndef CONFIG_H
-#define CONFIG_H
-
-#if defined CONFIG_EXPORTS
-#if defined WIN32
-#define CONFIG_EXPORT              __declspec( dllexport )
-#else
-#define CONFIG_EXPORT
-#endif
-#else
-#if defined WIN32
-#define CONFIG_EXPORT              __declspec( dllimport )
-#else
-#define CONFIG_EXPORT
-#endif
-#endif
-
-#endif //CONFIG_H
index 40051dc2ac209f5d0389d4fe5f712cc5eb8017de..2a579b91e126403d14d7f74cc698988be479a285 100644 (file)
@@ -8,7 +8,7 @@
 #ifndef Config_Common_H_
 #define Config_Common_H_
 
-#include "Config.h"
+#include "Config_def.h"
 
 #include <string>
 #include <stdarg.h>
index 9328e0690775df4e1fb7bdc44ba625477bb3a846..2613c992636fef61ddaeade5dafdb19730a76638 100644 (file)
@@ -1,7 +1,7 @@
 #ifndef CONFIG_MESSAGE_H\r
 #define CONFIG_MESSAGE_H\r
 \r
-#include <Config.h>\r
+#include <Config_def.h>\r
 #include <Events_Message.h>\r
 \r
 #include <string>\r
index 1add8438d464da227b792435783df3907af2ce2c..468cb9911165f8c09faa902d6d0b55c23f317b53 100644 (file)
@@ -8,7 +8,7 @@
 #ifndef CONFIG_FEATUREREADER_H_
 #define CONFIG_FEATUREREADER_H_
 
-#include <Config.h>
+#include <Config_def.h>
 #include <Config_XMLReader.h>
 
 #include <string>
index a4afba3c242dd20be7eeb39a99f3b7325253f79f..3bd5d39f3f75c8289f5566e5fc44ec8bfc1e553f 100644 (file)
@@ -8,7 +8,7 @@
 #ifndef CONFIG_MODULEREADER_H_
 #define CONFIG_MODULEREADER_H_
 
-#include <Config.h>
+#include <Config_def.h>
 #include <Config_XMLReader.h>
 
 #include <map>
index f108d3edeaa50bc7ad81f1071026fd6f5825484f..0e3c726caa094e05e0392032a357952e35b2fafb 100644 (file)
@@ -8,7 +8,7 @@
 #ifndef PARTSET_MESSAGE_H_
 #define PARTSET_MESSAGE_H_
 
-#include <Config.h>
+#include <Config_def.h>
 #include <Events_Message.h>
 
 /*
index 9a77d778ac0825da41131e6ffc65a2ef0ea3c88c..2fdad673519fcd7f1be6fc49cdbadad3062ffb67 100644 (file)
@@ -61,7 +61,7 @@ bool Config_WidgetAPI::toParentWidget()
   return myCurrentNode != NULL;
 }
 
-std::string Config_WidgetAPI::widgetType()
+std::string Config_WidgetAPI::widgetType() const
 {
   std::string result = "";
   if(myCurrentNode) {
@@ -70,19 +70,19 @@ std::string Config_WidgetAPI::widgetType()
   return result;
 }
 
-bool Config_WidgetAPI::isContainerWidget()
+bool Config_WidgetAPI::isContainerWidget() const
 {
   return isNode(myCurrentNode, WDG_GROUP, WDG_CHECK_GROUP,
                                NULL);
 }
 
-bool Config_WidgetAPI::isPagedWidget()
+bool Config_WidgetAPI::isPagedWidget() const
 {
   return isNode(myCurrentNode, WDG_TOOLBOX, WDG_SWITCH,
                                NULL);
 }
 
-std::string Config_WidgetAPI::getProperty(const char* thePropName)
+std::string Config_WidgetAPI::getProperty(const char* thePropName) const
 {
   std::string result = "";
   char* aPropChars = (char*) xmlGetProp(myCurrentNode, BAD_CAST thePropName);
@@ -92,22 +92,22 @@ std::string Config_WidgetAPI::getProperty(const char* thePropName)
   return result;
 }
 
-std::string Config_WidgetAPI::widgetId()
+std::string Config_WidgetAPI::widgetId() const
 {
   return getProperty("id");
 }
 
-std::string Config_WidgetAPI::widgetTooltip()
+std::string Config_WidgetAPI::widgetTooltip() const
 {
   return getProperty("tooltip");
 }
 
-std::string Config_WidgetAPI::widgetIcon()
+std::string Config_WidgetAPI::widgetIcon() const
 {
   return getProperty("icon");
 }
 
-std::string Config_WidgetAPI::widgetLabel()
+std::string Config_WidgetAPI::widgetLabel() const
 {
   return getProperty("label");
 }
index 4030ff257a204b12e70af6d7c14cdbd6f4677f10..190ccfc7fafd450dcd7ea1ea931414cf43b35455 100644 (file)
@@ -8,7 +8,7 @@
 #ifndef CONFIG_WIDGETAPI_H_
 #define CONFIG_WIDGETAPI_H_
 
-#include <Config.h>
+#include <Config_def.h>
 
 #include <cstdarg>
 #include <string>
@@ -36,16 +36,16 @@ public:
   bool toChildWidget();
   bool toParentWidget();
 
-  std::string widgetType();
-  bool isContainerWidget();
-  bool isPagedWidget();
+  std::string widgetType() const;
+  bool isContainerWidget() const;
+  bool isPagedWidget() const;
 
-  std::string widgetId();
-  std::string widgetIcon();
-  std::string widgetLabel();
-  std::string widgetTooltip();
+  std::string widgetId() const;
+  std::string widgetIcon() const;
+  std::string widgetLabel() const;
+  std::string widgetTooltip() const;
 
-  std::string getProperty(const char* thePropName);
+  std::string getProperty(const char* thePropName) const;
 
 private:
   xmlDocPtr myDoc;
index cfc1519a56b62fcc46eafeaeb39e489d3fba599d..96f35ac19a062a46a70075bab2150b115c9a2b1f 100644 (file)
@@ -8,7 +8,7 @@
 #ifndef CONFIG_WIDGETREADER_H_
 #define CONFIG_WIDGETREADER_H_
 
-#include <Config.h>
+#include <Config_def.h>
 #include <Config_XMLReader.h>
 
 #include <map>
index bcd8ddfdf4bfe5d27bdd6305060a40298cb714eb..8915147e9eb5c8b88a550d642e38ec2d6728bd65 100644 (file)
@@ -8,7 +8,7 @@
 #ifndef CONFIG_XMLREADER_H_
 #define CONFIG_XMLREADER_H_
 
-#include <Config.h>
+#include <Config_def.h>
 
 #include <cstdarg>
 #include <string>
diff --git a/src/Config/Config_def.h b/src/Config/Config_def.h
new file mode 100644 (file)
index 0000000..587ac53
--- /dev/null
@@ -0,0 +1,18 @@
+#ifndef CONFIG_H
+#define CONFIG_H
+
+#if defined CONFIG_EXPORTS
+#if defined WIN32
+#define CONFIG_EXPORT              __declspec( dllexport )
+#else
+#define CONFIG_EXPORT
+#endif
+#else
+#if defined WIN32
+#define CONFIG_EXPORT              __declspec( dllimport )
+#else
+#define CONFIG_EXPORT
+#endif
+#endif
+
+#endif //CONFIG_H
index ab34919147ff1251a53a238fd62bec0a005e75ec..dc32be9876c22203738ac932552f1a2d68671448 100644 (file)
@@ -15,10 +15,12 @@ SET(PROJECT_SOURCES
 
 ADD_DEFINITIONS(-DCONSTRUCTIONPLUGIN_EXPORTS ${BOOST_DEFINITIONS})
 ADD_LIBRARY(ConstructionPlugin SHARED ${PROJECT_SOURCES} ${PROJECT_HEADERS})
-TARGET_LINK_LIBRARIES(ConstructionPlugin ${PROJECT_LIBRARIES} ModelAPI)
+TARGET_LINK_LIBRARIES(ConstructionPlugin ${PROJECT_LIBRARIES} ModelAPI GeomAPI GeomAlgoAPI)
 
 INCLUDE_DIRECTORIES(
   ../ModelAPI
+  ../GeomAPI
+  ../GeomAlgoAPI
 )
 
 SET(XML_RESOURCES
index 6d557a3abfb27a8aa8b5e9fb5df0c1dc27c3f436..5270d2d892c6a756d489202e8e1fd5c8e718b83b 100644 (file)
@@ -8,8 +8,11 @@
 #include "ConstructionPlugin.h"
 #include <ModelAPI_Feature.h>
 
+/// Extrusion kind
+const std::string CONSTRUCTION_EXTRUSION_KIND("Extrusion");
+
 /// attribute name of referenced face
-const std::string EXTRUSION_FACE = "extrusion_select_face";
+const std::string EXTRUSION_FACE = "extrusion_face";
 
 /// attribute name of extrusion size
 const std::string EXTRUSION_SIZE = "extrusion_size";
@@ -23,7 +26,7 @@ class ConstructionPlugin_Extrusion: public ModelAPI_Feature
 public:
   /// Returns the kind of a feature
   CONSTRUCTIONPLUGIN_EXPORT virtual const std::string& getKind() 
-  { static std::string MY_KIND = "Extrusion"; return MY_KIND; }
+  { static std::string MY_KIND = CONSTRUCTION_EXTRUSION_KIND; return MY_KIND; }
 
   /// Returns to which group in the document must be added feature
   CONSTRUCTIONPLUGIN_EXPORT virtual const std::string& getGroup() 
index a825c5608e0a96cc95a2a453623bc65088706c6e..d420b21104827a33f6e25cf279d0ba2cb77db4c5 100644 (file)
@@ -16,13 +16,13 @@ ConstructionPlugin_Plugin::ConstructionPlugin_Plugin()
   ModelAPI_PluginManager::get()->registerPlugin(this);
 }
 
-boost::shared_ptr<ModelAPI_Feature> ConstructionPlugin_Plugin::createFeature(string theFeatureID)
+FeaturePtr ConstructionPlugin_Plugin::createFeature(string theFeatureID)
 {
-  if (theFeatureID == "Point") {
-    return boost::shared_ptr<ModelAPI_Feature>(new ConstructionPlugin_Point);
-  } else if (theFeatureID == "Extrusion") {
-    return boost::shared_ptr<ModelAPI_Feature>(new ConstructionPlugin_Extrusion);
+  if (theFeatureID == CONSTRUCTION_POINT_KIND) {
+    return FeaturePtr(new ConstructionPlugin_Point);
+  } else if (theFeatureID == CONSTRUCTION_EXTRUSION_KIND) {
+    return FeaturePtr(new ConstructionPlugin_Extrusion);
   }
   // feature of such kind is not found
-  return boost::shared_ptr<ModelAPI_Feature>();
+  return FeaturePtr();
 }
index 0201b40a36715f6cc468e03bc2eaed4e7706c1d4..1c772033befb7f89b1ce13ce01aacbc701919f82 100644 (file)
@@ -8,12 +8,13 @@
 
 #include "ConstructionPlugin.h"
 #include "ModelAPI_Plugin.h"
+#include "ModelAPI_Feature.h"
 
 class CONSTRUCTIONPLUGIN_EXPORT ConstructionPlugin_Plugin: public ModelAPI_Plugin
 {
 public:
   /// Creates the feature object of this plugin by the feature string ID
-  virtual boost::shared_ptr<ModelAPI_Feature> createFeature(std::string theFeatureID);
+  virtual FeaturePtr createFeature(std::string theFeatureID);
 
 public:
   /// Is needed for python wrapping by swig
index ea613603b9d3a3417b05e78da8bdeb6841ad5db6..aaa697dd5684f8c58d26b222f5e798a932ce3357 100644 (file)
@@ -7,6 +7,8 @@
 #include "ModelAPI_Document.h"
 #include "ModelAPI_Data.h"
 #include "ModelAPI_AttributeDouble.h"
+#include <GeomAlgoAPI_PointBuilder.h>
+#include <GeomAPI_Pnt.h>
 
 using namespace std;
 
@@ -21,11 +23,10 @@ void ConstructionPlugin_Point::initAttributes()
   data()->addAttribute(POINT_ATTR_Z, ModelAPI_AttributeDouble::type());
 }
 
-// this is for debug only
-#include <iostream>
 void ConstructionPlugin_Point::execute() 
 {
-  // TODO: create a real shape for the point using OCC layer
-  cout<<"X="<<data()->real(POINT_ATTR_X)->value()<<" Y="<<data()->real(POINT_ATTR_Y)->value()
-      <<" Z="<<data()->real(POINT_ATTR_Z)->value()<<endl;
+  boost::shared_ptr<GeomAPI_Pnt> aPnt(new GeomAPI_Pnt(
+    data()->real(POINT_ATTR_X)->value(), data()->real(POINT_ATTR_Y)->value(), data()->real(POINT_ATTR_Z)->value()));
+
+  data()->store(GeomAlgoAPI_PointBuilder::point(aPnt));
 }
index 2b71b50fea6e88763edfaf2d7325341d12e2ee30..a0dda28dd782103e9e37f42c4a77b0b3f6d47979 100644 (file)
@@ -8,6 +8,9 @@
 #include "ConstructionPlugin.h"
 #include <ModelAPI_Feature.h>
 
+/// Point kind
+const std::string CONSTRUCTION_POINT_KIND("Point");
+
 /// attribute name for X coordinate
 const std::string POINT_ATTR_X = "x";
 /// attribute name for Y coordinate
@@ -24,7 +27,7 @@ class ConstructionPlugin_Point: public ModelAPI_Feature
 public:
   /// Returns the kind of a feature
   CONSTRUCTIONPLUGIN_EXPORT virtual const std::string& getKind() 
-  {static std::string MY_KIND = "Point"; return MY_KIND;}
+  {static std::string MY_KIND = CONSTRUCTION_POINT_KIND; return MY_KIND;}
 
   /// Returns to which group in the document must be added feature
   CONSTRUCTIONPLUGIN_EXPORT virtual const std::string& getGroup() 
index 52cf8622f8c4081aa7491443e8f4b6ca79f586ed..f368a68cd06329b06e35370e617e47a284b3781f 100644 (file)
@@ -1,8 +1,9 @@
 <source>
-  <selector id="extrusion_select_face" 
+  <selector id="extrusion_face" 
     label="Select a face" 
     icon=":icons/sketch.png" 
     tooltip="Select a face for extrusion"
+       activate="true"
   />
   <doublevalue id="extrusion_size" label="Size" min="0" step="1.0" default="10" icon=":icons/dimension_v.png" tooltip="Set size of extrusion"/>
   <boolvalue id="extrusion_reverse" label="Reverse" default="false" tooltip="Reverse default direction"/>
index ad741d302d83c67fe65adae20fc93ff949e96e45..2a2f3ed40e5ffe4ac1b7ef99880054a9a1a4e1a2 100644 (file)
@@ -1,5 +1,4 @@
 FIND_PACKAGE(SWIG REQUIRED)
-INCLUDE(FindCAS)
 
 INCLUDE(${SWIG_USE_FILE})
 INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR})
index 548f7002f059005ef606fec6c162634eac72afb6..5822d61fb15faafa03f551fd693e723608ea1b04 100644 (file)
@@ -1,5 +1,4 @@
 FIND_PACKAGE(SWIG REQUIRED)
-INCLUDE(FindCAS)
 
 INCLUDE(${SWIG_USE_FILE})
 INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR})
@@ -9,6 +8,7 @@ SET(PROJECT_HEADERS
     GeomAlgoAPI_CompoundBuilder.h
     GeomAlgoAPI_FaceBuilder.h
     GeomAlgoAPI_EdgeBuilder.h
+    GeomAlgoAPI_PointBuilder.h
     GeomAlgoAPI_SketchBuilder.h
 )
 
@@ -16,6 +16,7 @@ SET(PROJECT_SOURCES
     GeomAlgoAPI_CompoundBuilder.cpp
     GeomAlgoAPI_FaceBuilder.cpp
     GeomAlgoAPI_EdgeBuilder.cpp
+    GeomAlgoAPI_PointBuilder.cpp
     GeomAlgoAPI_SketchBuilder.cpp
 )
 
index 99a815f744a870d1b0d90f71dd916ad3b3d7f167..c43f350dc4bdb9e9d3471ae71ea82d293bd9cdb4 100644 (file)
@@ -4,6 +4,8 @@
   #include "memory"
   #include "GeomAlgoAPI.h"
   #include "GeomAlgoAPI_FaceBuilder.h"
+  #include "GeomAlgoAPI_EdgeBuilder.h"
+  #include "GeomAlgoAPI_PointBuilder.h"
 %}
 
 // to avoid error on this
@@ -17,3 +19,5 @@
 
 // all supported interfaces
 %include "GeomAlgoAPI_FaceBuilder.h"
+%include "GeomAlgoAPI_EdgeBuilder.h"
+%include "GeomAlgoAPI_PointBuilder.h"
diff --git a/src/GeomAlgoAPI/GeomAlgoAPI_PointBuilder.cpp b/src/GeomAlgoAPI/GeomAlgoAPI_PointBuilder.cpp
new file mode 100644 (file)
index 0000000..d12bd6a
--- /dev/null
@@ -0,0 +1,22 @@
+// File:        GeomAlgoAPI_PointBuilder.cpp
+// Created:     02 Jun 2014
+// Author:      Mikhail PONIKAROV
+
+
+
+#include <GeomAlgoAPI_PointBuilder.h>
+#include <GeomAPI_Pnt.h>
+#include <GeomAPI_Shape.h>
+#include <BRepBuilderAPI_MakeVertex.hxx>
+#include <TopoDS_Vertex.hxx>
+
+boost::shared_ptr<GeomAPI_Shape> GeomAlgoAPI_PointBuilder::point(
+    boost::shared_ptr<GeomAPI_Pnt> thePoint)
+{
+  const gp_Pnt& aPnt = thePoint->impl<gp_Pnt>();
+  BRepBuilderAPI_MakeVertex aMaker(aPnt);
+  TopoDS_Vertex aVertex = aMaker.Vertex();
+  boost::shared_ptr<GeomAPI_Shape> aRes(new GeomAPI_Shape);
+  aRes->setImpl(new TopoDS_Shape(aVertex));
+  return aRes;
+}
diff --git a/src/GeomAlgoAPI/GeomAlgoAPI_PointBuilder.h b/src/GeomAlgoAPI/GeomAlgoAPI_PointBuilder.h
new file mode 100644 (file)
index 0000000..2715062
--- /dev/null
@@ -0,0 +1,27 @@
+// File:        GeomAlgoAPI_PointBuilder.h
+// Created:     02 Jun 2014
+// Author:      Mikhail PONIKAROV
+
+#ifndef GeomAlgoAPI_PointBuilder_HeaderFile
+#define GeomAlgoAPI_PointBuilder_HeaderFile
+
+#include <GeomAlgoAPI.h>
+#include <boost/shared_ptr.hpp>
+
+class GeomAPI_Shape;
+class GeomAPI_Pnt;
+
+/**\class GeomAlgoAPI_PointBuilder
+ * \ingroup DataAlgo
+ * \brief Allows to create face-shapes by different parameters
+ */
+
+class GEOMALGOAPI_EXPORT GeomAlgoAPI_PointBuilder
+{
+public:
+  /// Creates linear edge by two points
+  static boost::shared_ptr<GeomAPI_Shape> point(
+    boost::shared_ptr<GeomAPI_Pnt> thePoint);
+};
+
+#endif
index b69c280d060d7ae678882a7c9307b80589227e8b..a1e450c6ecdf9034de10fcc4910fb24cfebf88ae 100644 (file)
@@ -1,5 +1,4 @@
 INCLUDE(Common)
-INCLUDE(FindCAS)
 
 SET(PROJECT_HEADERS
     GeomData.h
index 9da38b914c666e7dcd6563552f3372e5647f91d3..bb12daaadbd2e87fb940b2bef2dc57f9049816b3 100644 (file)
@@ -1,5 +1,4 @@
 INCLUDE(Common)
-INCLUDE(FindCAS)
 
 SET(PROJECT_HEADERS
     Model.h
@@ -36,7 +35,9 @@ SET(PROJECT_LIBRARIES
     Events 
     Config 
     GeomData
+    GeomAPI
     ${CAS_OCAF}
+    ${CAS_TKCAF}
 )
 
 
@@ -51,6 +52,7 @@ INCLUDE_DIRECTORIES(
   ../Config
   ../GeomData
   ../GeomDataAPI
+  ../GeomAPI
   ${CAS_INCLUDE_DIRS}
 )
 
index d3c0d6bc5aa9f5950f229b09bbc9d5a06549d53b..5472dadf255f13feac8b09704726979751f0d191 100644 (file)
@@ -10,8 +10,9 @@ using namespace std;
 
 void Model_AttributeBoolean::setValue(bool theValue)
 {
-  if (myBool->Get() != theValue) {
-    myBool->Set(theValue? 1 : 0);
+  Standard_Boolean aValue = theValue ? Standard_True : Standard_False;
+  if (myBool->Get() != aValue) {
+    myBool->Set(aValue);
     static Events_ID anEvent = Events_Loop::eventByName(EVENT_FEATURE_UPDATED);
     Model_FeatureUpdatedMessage aMsg(owner(), anEvent);
     Events_Loop::loop()->send(aMsg);
@@ -20,7 +21,7 @@ void Model_AttributeBoolean::setValue(bool theValue)
 
 bool Model_AttributeBoolean::value()
 {
-  return (myBool->Get() == 1)? true : false;
+  return myBool->Get() == Standard_True;
 }
 
 Model_AttributeBoolean::Model_AttributeBoolean(TDF_Label& theLabel)
index 16a86b194f412b4f8e83f927aae7dcbdf3b77afe..39797722609130ae4fc3d7cf42ee4bcb5dcce231 100644 (file)
@@ -34,7 +34,7 @@ void Model_AttributeRefAttr::setAttr(boost::shared_ptr<ModelAPI_Attribute> theAt
 
 boost::shared_ptr<ModelAPI_Attribute> Model_AttributeRefAttr::attr()
 {
-  boost::shared_ptr<ModelAPI_Feature> aFeature = feature();
+  FeaturePtr aFeature = feature();
   if (aFeature) {
     boost::shared_ptr<Model_Data> aData = 
       boost::dynamic_pointer_cast<Model_Data>(aFeature->data());
@@ -44,7 +44,7 @@ boost::shared_ptr<ModelAPI_Attribute> Model_AttributeRefAttr::attr()
   return boost::shared_ptr<ModelAPI_Attribute>();
 }
 
-void Model_AttributeRefAttr::setFeature(boost::shared_ptr<ModelAPI_Feature> theFeature)
+void Model_AttributeRefAttr::setFeature(FeaturePtr theFeature)
 {
   if (myID->Get().Length() != 0 || feature() != theFeature) {
     boost::shared_ptr<Model_Data> aData = 
@@ -58,7 +58,7 @@ void Model_AttributeRefAttr::setFeature(boost::shared_ptr<ModelAPI_Feature> theF
   }
 }
 
-boost::shared_ptr<ModelAPI_Feature> Model_AttributeRefAttr::feature()
+FeaturePtr Model_AttributeRefAttr::feature()
 {
   if (myRef->Get() != myRef->Label()) { // initialized
     boost::shared_ptr<Model_Document> aDoc = 
@@ -70,7 +70,7 @@ boost::shared_ptr<ModelAPI_Feature> Model_AttributeRefAttr::feature()
     }
   }
   // not initialized
-  return boost::shared_ptr<ModelAPI_Feature>();
+  return FeaturePtr();
 }
 
 Model_AttributeRefAttr::Model_AttributeRefAttr(TDF_Label& theLabel)
index f9d2bc42e2ff34f001030855f18c4767ee3ccc6b..69fda0163632dd7a0d858fd7c04c706d73ef4e0d 100644 (file)
@@ -33,10 +33,10 @@ public:
   MODEL_EXPORT virtual boost::shared_ptr<ModelAPI_Attribute> attr();
 
   /// Defines the reference to the feature
-  MODEL_EXPORT virtual void setFeature(boost::shared_ptr<ModelAPI_Feature> theFeature);
+  MODEL_EXPORT virtual void setFeature(FeaturePtr theFeature);
 
   /// Returns feature referenced from this attribute
-  MODEL_EXPORT virtual boost::shared_ptr<ModelAPI_Feature> feature();
+  MODEL_EXPORT virtual FeaturePtr feature();
 
 protected:
   /// Objects are created for features automatically
index f6520fce869300ecaacfa0ee092dd0fece340583..af4cbd3ea6246983a910f4bc3f177540ebe8d1e5 100644 (file)
@@ -12,7 +12,7 @@
 
 using namespace std;
 
-void Model_AttributeRefList::append(boost::shared_ptr<ModelAPI_Feature> theFeature)
+void Model_AttributeRefList::append(FeaturePtr theFeature)
 {
   boost::shared_ptr<Model_Data> aData = 
     boost::dynamic_pointer_cast<Model_Data>(theFeature->data());
@@ -23,7 +23,7 @@ void Model_AttributeRefList::append(boost::shared_ptr<ModelAPI_Feature> theFeatu
   Events_Loop::loop()->send(aMsg);
 }
 
-void Model_AttributeRefList::remove(boost::shared_ptr<ModelAPI_Feature> theFeature)
+void Model_AttributeRefList::remove(FeaturePtr theFeature)
 {
   boost::shared_ptr<Model_Data> aData = 
     boost::dynamic_pointer_cast<Model_Data>(theFeature->data());
@@ -36,9 +36,9 @@ int Model_AttributeRefList::size()
   return myRef->Extent();
 }
 
-list<boost::shared_ptr<ModelAPI_Feature> > Model_AttributeRefList::list()
+list<FeaturePtr > Model_AttributeRefList::list()
 {
-  std::list< boost::shared_ptr<ModelAPI_Feature> > aResult;
+  std::list< FeaturePtr > aResult;
   boost::shared_ptr<Model_Document> aDoc = 
     boost::dynamic_pointer_cast<Model_Document>(owner()->document());
   if (aDoc) {
index bf6290c07ddf7bc64573b2e0e982b6bbc8df49d2..340f5cdf011ad037338248b3a19731b25a8bf46c 100644 (file)
@@ -7,6 +7,8 @@
 
 #include "Model.h"
 #include "ModelAPI_AttributeRefList.h"
+#include "ModelAPI_Feature.h"
+
 #include <TDataStd_ReferenceList.hxx>
 
 /**\class Model_AttributeRefList
@@ -19,16 +21,16 @@ class Model_AttributeRefList : public ModelAPI_AttributeRefList
   Handle_TDataStd_ReferenceList myRef; ///< references to the features labels
 public:
   /// Appends the feature to the end of a list
-  MODEL_EXPORT virtual void append(boost::shared_ptr<ModelAPI_Feature> theFeature);
+  MODEL_EXPORT virtual void append(FeaturePtr theFeature);
 
   /// Erases the first meet of the feature in the list
-  MODEL_EXPORT virtual void remove(boost::shared_ptr<ModelAPI_Feature> theFeature);
+  MODEL_EXPORT virtual void remove(FeaturePtr theFeature);
 
   /// Returns number of features in the list
   MODEL_EXPORT virtual int size();
 
   /// Returns the list of features
-  MODEL_EXPORT virtual std::list<boost::shared_ptr<ModelAPI_Feature> > list();
+  MODEL_EXPORT virtual std::list<FeaturePtr > list();
 
 protected:
   /// Objects are created for features automatically
index 105639b742fdda4b3b8b17887361e436875b2ff3..adcfe4ab46e0b1d62d038f8408dd7568a029afe7 100644 (file)
@@ -11,7 +11,7 @@
 
 using namespace std;
 
-void Model_AttributeReference::setValue(boost::shared_ptr<ModelAPI_Feature> theFeature)
+void Model_AttributeReference::setValue(FeaturePtr theFeature)
 {
   if (value() != theFeature) {
     boost::shared_ptr<Model_Data> aData = 
@@ -19,7 +19,7 @@ void Model_AttributeReference::setValue(boost::shared_ptr<ModelAPI_Feature> theF
     if (myRef.IsNull()) {
       boost::shared_ptr<Model_Data> aMyData = 
         boost::dynamic_pointer_cast<Model_Data>(owner()->data());
-      TDF_Reference::Set(aMyData->label(), aData->label());
+      myRef = TDF_Reference::Set(aMyData->label(), aData->label());
     } else {
       myRef->Set(aData->label());
     }
@@ -30,7 +30,7 @@ void Model_AttributeReference::setValue(boost::shared_ptr<ModelAPI_Feature> theF
   }
 }
 
-boost::shared_ptr<ModelAPI_Feature> Model_AttributeReference::value()
+FeaturePtr Model_AttributeReference::value()
 {
   if (!myRef.IsNull()) {
     boost::shared_ptr<Model_Document> aDoc = 
@@ -41,7 +41,7 @@ boost::shared_ptr<ModelAPI_Feature> Model_AttributeReference::value()
     }
   }
   // not initialized
-  return boost::shared_ptr<ModelAPI_Feature>();
+  return FeaturePtr();
 }
 
 Model_AttributeReference::Model_AttributeReference(TDF_Label& theLabel)
index e17855e48419ee63c2ae242fc0a15ad376c6c9ab..6406d0bfbfbf0fd8b828ab4fc0dca034c39423ec 100644 (file)
@@ -7,6 +7,7 @@
 
 #include "Model.h"
 #include "ModelAPI_AttributeReference.h"
+#include <ModelAPI_Feature.h>
 #include <TDF_Label.hxx>
 #include <TDF_Reference.hxx>
 
@@ -20,10 +21,10 @@ class Model_AttributeReference : public ModelAPI_AttributeReference
   Handle_TDF_Reference myRef; ///< references to the feature label
 public:
   /// Defines the feature referenced from this attribute
-  MODEL_EXPORT virtual void setValue(boost::shared_ptr<ModelAPI_Feature> theFeature);
+  MODEL_EXPORT virtual void setValue(FeaturePtr theFeature);
 
   /// Returns feature referenced from this attribute
-  MODEL_EXPORT virtual boost::shared_ptr<ModelAPI_Feature> value();
+  MODEL_EXPORT virtual FeaturePtr value();
 
 protected:
   /// Objects are created for features automatically
index f794bda07c143f0936ff573d656542285969b459..31f9f36a03eab9542a8410a4e753c2d83248fda6 100644 (file)
@@ -8,6 +8,7 @@
 #include <Model_AttributeReference.h>
 #include <Model_AttributeRefAttr.h>
 #include <Model_AttributeRefList.h>
+#include <Model_AttributeBoolean.h>
 #include <GeomData_Point.h>
 #include <GeomData_Point2D.h>
 #include <GeomData_Dir.h>
@@ -73,6 +74,8 @@ void Model_Data::addAttribute(string theID, string theAttrType)
     anAttr = new GeomData_Dir(anAttrLab);
   else if (theAttrType == GeomData_Point2D::type())
     anAttr = new GeomData_Point2D(anAttrLab);
+  else if (theAttrType == Model_AttributeBoolean::type())
+    anAttr = new Model_AttributeBoolean(anAttrLab);
 
   if (anAttr) {
     myAttrs[theID] = boost::shared_ptr<ModelAPI_Attribute>(anAttr);
@@ -112,6 +115,21 @@ boost::shared_ptr<ModelAPI_AttributeDouble> Model_Data::real(const string theID)
   return aRes;
 }
 
+boost::shared_ptr<ModelAPI_AttributeBoolean> Model_Data::boolean(const std::string theID)
+{
+  map<string, boost::shared_ptr<ModelAPI_Attribute> >::iterator aFound = myAttrs.find(theID);
+  if (aFound == myAttrs.end()) {
+    // TODO: generate error on unknown attribute request and/or add mechanism for customization
+    return boost::shared_ptr<ModelAPI_AttributeBoolean>();
+  }
+  boost::shared_ptr<ModelAPI_AttributeBoolean> aRes = 
+    boost::dynamic_pointer_cast<ModelAPI_AttributeBoolean>(aFound->second);
+  if (!aRes) {
+    // TODO: generate error on invalid attribute type request
+  }
+  return aRes;
+}
+
 boost::shared_ptr<ModelAPI_AttributeReference> Model_Data::reference(const string theID)
 {
   map<string, boost::shared_ptr<ModelAPI_Attribute> >::iterator aFound = myAttrs.find(theID);
@@ -188,3 +206,34 @@ bool Model_Data::isValid()
 {
   return !myLab.IsNull() && myLab.HasAttribute();
 }
+
+#include <TNaming_Builder.hxx>
+#include <TNaming_NamedShape.hxx>
+#include <TopoDS_Shape.hxx>
+#include <GeomAPI_Shape.h>
+
+void Model_Data::store(const boost::shared_ptr<GeomAPI_Shape>& theShape)
+{
+  // the simplest way is to keep this attribute here, on Data
+  // TODO: add naming structure in separated document for shape storage
+  TNaming_Builder aBuilder(myLab);
+  if (!theShape) return; // bad shape
+  TopoDS_Shape aShape = theShape->impl<TopoDS_Shape>();
+  if (aShape.IsNull()) return; // null shape inside
+
+  aBuilder.Generated(aShape);
+}
+
+boost::shared_ptr<GeomAPI_Shape> Model_Data::shape()
+{
+  Handle(TNaming_NamedShape) aName;
+  if (myLab.FindAttribute(TNaming_NamedShape::GetID(), aName)) {
+    TopoDS_Shape aShape = aName->Get();
+    if (!aShape.IsNull()) {
+      boost::shared_ptr<GeomAPI_Shape> aRes(new GeomAPI_Shape);
+      aRes->setImpl(new TopoDS_Shape(aShape));
+      return aRes;
+    }
+  }
+  return boost::shared_ptr<GeomAPI_Shape>();
+}
index 03ff0c54eddc44dd8fec9cf433b9cfa307edb9b5..36f5f361463d7372cef018a00f687bebf9c23d65 100644 (file)
@@ -7,12 +7,12 @@
 
 #include "Model.h"
 #include <ModelAPI_Data.h>
+#include <ModelAPI_Feature.h>
 #include <TDF_Label.hxx>
 
 #include <map>
 
 class ModelAPI_Attribute;
-class ModelAPI_Feature;
 
 /**\class Model_Data
  * \ingroup DataModel
@@ -27,7 +27,7 @@ class Model_Data: public ModelAPI_Data
   std::map<std::string, boost::shared_ptr<ModelAPI_Attribute> > myAttrs;
 
   /// needed here to emit signal that feature changed on change of the attribute
-  boost::shared_ptr<ModelAPI_Feature> myFeature;
+  FeaturePtr myFeature;
 
   Model_Data();
 
@@ -57,6 +57,9 @@ public:
   /// Returns the attribute that contains list of references to features
   MODEL_EXPORT virtual boost::shared_ptr<ModelAPI_AttributeRefList> 
     reflist(const std::string theID);
+  /// Returns the attribute that contains boolean value
+  MODEL_EXPORT virtual boost::shared_ptr<ModelAPI_AttributeBoolean> 
+    boolean(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);
@@ -68,6 +71,11 @@ public:
   /// Returns true if it is correctly connected t othe data model
   MODEL_EXPORT virtual bool isValid();
 
+  /// Stores the shape (called by the execution method).
+  MODEL_EXPORT virtual void store(const boost::shared_ptr<GeomAPI_Shape>& theShape);
+  /// Returns the shape-result produced by this feature
+  MODEL_EXPORT virtual boost::shared_ptr<GeomAPI_Shape> shape();
+
   /// 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
@@ -78,7 +86,7 @@ public:
   MODEL_EXPORT void setLabel(TDF_Label& theLab);
 
   /// Sets the feature of this data
-  MODEL_EXPORT virtual void setFeature(boost::shared_ptr<ModelAPI_Feature> theFeature)
+  MODEL_EXPORT virtual void setFeature(FeaturePtr theFeature)
     {myFeature = theFeature;}
 };
 
index 76b72fe0c12b3bcd0e4a5ea26890c25911fff28e..e17a14af55719000c54b58eb0747eb7cb040b5eb 100644 (file)
@@ -319,9 +319,9 @@ void Model_Document::redo()
     subDocument(*aSubIter)->redo();
 }
 
-boost::shared_ptr<ModelAPI_Feature> Model_Document::addFeature(string theID)
+FeaturePtr Model_Document::addFeature(string theID)
 {
-  boost::shared_ptr<ModelAPI_Feature> aFeature = 
+  FeaturePtr aFeature = 
     ModelAPI_PluginManager::get()->createFeature(theID);
   if (aFeature) {
     boost::dynamic_pointer_cast<Model_Document>(aFeature->documentToAdd())->addFeature(aFeature);
@@ -348,7 +348,7 @@ static void AddToRefArray(TDF_Label& theArrayLab, TDF_Label& theReferenced) {
   }
 }
 
-void Model_Document::addFeature(const boost::shared_ptr<ModelAPI_Feature> theFeature)
+void Model_Document::addFeature(const FeaturePtr theFeature)
 {
   if (theFeature->isAction()) return; // do not add action to the data model
 
@@ -421,7 +421,7 @@ static int RemoveFromRefArray(
   return aResult;
 }
 
-void Model_Document::removeFeature(boost::shared_ptr<ModelAPI_Feature> theFeature)
+void Model_Document::removeFeature(FeaturePtr theFeature)
 {
   boost::shared_ptr<Model_Data> aData = boost::static_pointer_cast<Model_Data>(theFeature->data());
   TDF_Label aFeatureLabel = aData->label();
@@ -430,7 +430,7 @@ void Model_Document::removeFeature(boost::shared_ptr<ModelAPI_Feature> theFeatur
   int aRemovedIndex = RemoveFromRefArray(aGroupLabel, aFeatureLabel);
   RemoveFromRefArray(aGroupLabel.FindChild(1), TDF_Label(), aRemovedIndex);
   // remove feature from the myFeatures list
-  std::vector<boost::shared_ptr<ModelAPI_Feature> >::iterator aFIter = myFeatures.begin();
+  std::vector<FeaturePtr >::iterator aFIter = myFeatures.begin();
   while(aFIter != myFeatures.end()) {
     if (*aFIter == theFeature) {
       aFIter = myFeatures.erase(aFIter);
@@ -448,17 +448,17 @@ void Model_Document::removeFeature(boost::shared_ptr<ModelAPI_Feature> theFeatur
   Events_Loop::loop()->send(aMsg);
 }
 
-boost::shared_ptr<ModelAPI_Feature> Model_Document::feature(TDF_Label& theLabel)
+FeaturePtr Model_Document::feature(TDF_Label& theLabel)
 {
   // iterate all features, may be optimized later by keeping labels-map
-  vector<boost::shared_ptr<ModelAPI_Feature> >::iterator aFIter = myFeatures.begin();
+  vector<FeaturePtr >::iterator aFIter = myFeatures.begin();
   for(; aFIter != myFeatures.end(); aFIter++) {
     boost::shared_ptr<Model_Data> aData = 
       boost::dynamic_pointer_cast<Model_Data>((*aFIter)->data());
     if (aData->label().IsEqual(theLabel))
       return *aFIter;
   }
-  return boost::shared_ptr<ModelAPI_Feature>(); // not found
+  return FeaturePtr(); // not found
 }
 
 boost::shared_ptr<ModelAPI_Document> Model_Document::subDocument(string theDocID)
@@ -469,7 +469,7 @@ boost::shared_ptr<ModelAPI_Document> Model_Document::subDocument(string theDocID
   return Model_Application::getApplication()->getDocument(theDocID);
 }
 
-boost::shared_ptr<ModelAPI_Feature> Model_Document::feature(
+FeaturePtr Model_Document::feature(
   const string& theGroupID, const int theIndex, const bool isOperation)
 {
   TDF_Label aGroupLab = groupLabel(theGroupID);
@@ -477,7 +477,7 @@ boost::shared_ptr<ModelAPI_Feature> Model_Document::feature(
   if (aGroupLab.FindAttribute(TDataStd_ReferenceArray::GetID(), aRefs)) {
     if (aRefs->Lower() <= theIndex && aRefs->Upper() >= theIndex) {
       TDF_Label aFeatureLab = aRefs->Value(theIndex);
-      boost::shared_ptr<ModelAPI_Feature> aFeature = feature(aFeatureLab);
+      FeaturePtr aFeature = feature(aFeatureLab);
 
       if (theGroupID == FEATURES_GROUP || isOperation) { // just returns the feature from the history
         return aFeature;
@@ -492,7 +492,7 @@ boost::shared_ptr<ModelAPI_Feature> Model_Document::feature(
   }
 
   // not found
-  return boost::shared_ptr<ModelAPI_Feature>();
+  return FeaturePtr();
 }
 
 int Model_Document::size(const string& theGroupID) 
@@ -534,7 +534,7 @@ TDF_Label Model_Document::groupLabel(const string theGroup)
   return aNew;
 }
 
-void Model_Document::setUniqueName(boost::shared_ptr<ModelAPI_Feature> theFeature)
+void Model_Document::setUniqueName(FeaturePtr theFeature)
 {
   string aName; // result
   // iterate all features but also iterate group of this feature if object is not in history
@@ -571,8 +571,8 @@ void Model_Document::setUniqueName(boost::shared_ptr<ModelAPI_Feature> theFeatur
 }
 
 //! Returns the object by the feature
-boost::shared_ptr<ModelAPI_Feature> Model_Document::objectByFeature(
-  const boost::shared_ptr<ModelAPI_Feature> theFeature)
+FeaturePtr Model_Document::objectByFeature(
+  const FeaturePtr theFeature)
 {
   for(int a = 0; a < size(theFeature->getGroup()); a++) {
     boost::shared_ptr<Model_Object> anObj = 
@@ -581,14 +581,14 @@ boost::shared_ptr<ModelAPI_Feature> Model_Document::objectByFeature(
       return anObj;
     }
   }
-  return boost::shared_ptr<ModelAPI_Feature>(); // not found
+  return FeaturePtr(); // not found
 }
 
 void Model_Document::synchronizeFeatures(const bool theMarkUpdated)
 {
   boost::shared_ptr<ModelAPI_Document> aThis = Model_Application::getApplication()->getDocument(myID);
   // update features
-  vector<boost::shared_ptr<ModelAPI_Feature> >::iterator aFIter = myFeatures.begin();
+  vector<FeaturePtr >::iterator aFIter = myFeatures.begin();
   // and in parallel iterate labels of features
   TDF_ChildIDIterator aFLabIter(groupLabel(FEATURES_GROUP), TDataStd_Comment::GetID());
   while(aFIter != myFeatures.end() || aFLabIter.More()) {
@@ -614,7 +614,7 @@ void Model_Document::synchronizeFeatures(const bool theMarkUpdated)
       Events_Loop::loop()->send(aMsg2);
     } else if (aDSTag < aFeatureTag) { // a new feature is inserted
       // create a feature
-      boost::shared_ptr<ModelAPI_Feature> aFeature = ModelAPI_PluginManager::get()->createFeature(
+      FeaturePtr aFeature = ModelAPI_PluginManager::get()->createFeature(
         TCollection_AsciiString(Handle(TDataStd_Comment)::DownCast(
         aFLabIter.Value())->Get()).ToCString());
 
@@ -637,7 +637,7 @@ void Model_Document::synchronizeFeatures(const bool theMarkUpdated)
       static Events_ID anEvent = Events_Loop::eventByName(EVENT_FEATURE_CREATED);
       Model_FeatureUpdatedMessage aMsg1(aFeature, anEvent);
       Events_Loop::loop()->send(aMsg1);
-      boost::shared_ptr<ModelAPI_Feature> anObj = objectByFeature(aFeature);
+      FeaturePtr anObj = objectByFeature(aFeature);
       if (anObj) {
         Model_FeatureUpdatedMessage aMsg2(anObj, anEvent);
         Events_Loop::loop()->send(aMsg2);
index 41f7d51f6a54bbdd828176d9d49d3a0e3b3902dd..adc4846eccd0520a6eeb8bfe69aea132557342c8 100644 (file)
@@ -7,6 +7,7 @@
 
 #include <Model.h>
 #include <ModelAPI_Document.h>
+#include <ModelAPI_Feature.h>
 
 #include <TDocStd_Document.hxx>
 #include <map>
@@ -61,14 +62,14 @@ public:
 
   //! Adds to the document the new feature of the given feature id
   //! \param creates feature and puts it in the document
-  MODEL_EXPORT virtual boost::shared_ptr<ModelAPI_Feature> addFeature(std::string theID);
+  MODEL_EXPORT virtual FeaturePtr addFeature(std::string theID);
 
   //! Removes the feature from the document
-  MODEL_EXPORT virtual void removeFeature(boost::shared_ptr<ModelAPI_Feature> theFeature);
+  MODEL_EXPORT virtual void removeFeature(FeaturePtr theFeature);
 
   //! Returns the existing feature by the label
   //! \param theLabel base label of the feature
-  MODEL_EXPORT virtual boost::shared_ptr<ModelAPI_Feature> feature(TDF_Label& theLabel);
+  MODEL_EXPORT virtual FeaturePtr feature(TDF_Label& theLabel);
 
   //! Adds a new sub-document by the identifier, or returns existing one if it is already exist
   MODEL_EXPORT virtual boost::shared_ptr<ModelAPI_Document> subDocument(std::string theDocID);
@@ -80,7 +81,7 @@ public:
   //! \param theGroupID group that contains a feature
   //! \param theIndex zero-based index of feature in the group
   //! \param isOperation if it is true, returns feature (not Object)
-  MODEL_EXPORT virtual boost::shared_ptr<ModelAPI_Feature> 
+  MODEL_EXPORT virtual FeaturePtr 
     feature(const std::string& theGroupID, const int theIndex, const bool isOperation = false);
 
   //! Returns the number of features in the group
@@ -93,14 +94,14 @@ protected:
 
   //! Initializes feature with a unique name in this group (unique name is generated as 
   //! feature type + "_" + index
-  void setUniqueName(boost::shared_ptr<ModelAPI_Feature> theFeature);
+  void setUniqueName(FeaturePtr theFeature);
 
   //! Adds to the document the new feature
-  void addFeature(const boost::shared_ptr<ModelAPI_Feature> theFeature);
+  void addFeature(const FeaturePtr theFeature);
 
   //! Returns the object by the feature
-  boost::shared_ptr<ModelAPI_Feature> objectByFeature(
-    const boost::shared_ptr<ModelAPI_Feature> theFeature);
+  FeaturePtr objectByFeature(
+    const FeaturePtr theFeature);
 
   //! Synchronizes myFeatures list with the updated document
   void synchronizeFeatures(const bool theMarkUpdated = false);
@@ -124,7 +125,7 @@ private:
   /// number of nested transactions performed (or -1 if not nested)
   int myNestedNum;
   /// All features managed by this document (not only in history of OB)
-  std::vector<boost::shared_ptr<ModelAPI_Feature> > myFeatures;
+  std::vector<FeaturePtr > myFeatures;
 
   ///< set of identifiers of sub-documents of this document
   std::set<std::string> mySubs;
index 0bce1c980bc508eed36659bb9a3504a12d50e8c0..1fbf1980e1481b40ab2c1ef50340bf6131fc09f7 100644 (file)
@@ -12,7 +12,8 @@
 #include <string>
 #include <set>
 
-class ModelAPI_Feature;
+#include "ModelAPI_Feature.h"
+
 class ModelAPI_Document;
 
 /// Event ID that feature is created (comes with Model_FeatureUpdatedMessage)
@@ -26,27 +27,27 @@ static const char * EVENT_FEATURE_MOVED = "FeaturesMoved";
 
 /// Message that feature was changed (used for Object Browser update): moved, updated and deleted
 class Model_FeatureUpdatedMessage : public Events_MessageGroup {
-  std::set<boost::shared_ptr<ModelAPI_Feature> > myFeatures; ///< which feature is changed
+  std::set<FeaturePtr > myFeatures; ///< which feature is changed
 public:
   /// sender is not important, all information is located in the feature
   Model_FeatureUpdatedMessage(
-    const boost::shared_ptr<ModelAPI_Feature>& theFeature,
+    const FeaturePtr& theFeature,
     const Events_ID& theEvent) : Events_MessageGroup(theEvent, 0)
   {if (theFeature) myFeatures.insert(theFeature);}
 
   /// Returns the feature that has been updated
-  std::set<boost::shared_ptr<ModelAPI_Feature> > features() const {return myFeatures;}
+  std::set<FeaturePtr > features() const {return myFeatures;}
 
   //! Creates a new empty group (to store it in the loop before flush)
   virtual Events_MessageGroup* newEmpty() {
-    boost::shared_ptr<ModelAPI_Feature> anEmptyFeature;
+    FeaturePtr anEmptyFeature;
     return new Model_FeatureUpdatedMessage(anEmptyFeature, eventID());
   }
 
   //! Allows to join the given message with the current one
   virtual void Join(Events_MessageGroup& theJoined) {
     Model_FeatureUpdatedMessage* aJoined = dynamic_cast<Model_FeatureUpdatedMessage*>(&theJoined);
-    std::set<boost::shared_ptr<ModelAPI_Feature> >::iterator aFIter = aJoined->myFeatures.begin();
+    std::set<FeaturePtr >::iterator aFIter = aJoined->myFeatures.begin();
     for(; aFIter != aJoined->myFeatures.end(); aFIter++) {
       myFeatures.insert(*aFIter);
     }
index 269c547cf90b641ceeaa1ee7c912ac69d460520a..e0c5b30280e87cb671145536861239432747328c 100644 (file)
@@ -7,7 +7,7 @@
 #include "Model_Events.h"
 #include <Events_Loop.h>
 
-boost::shared_ptr<ModelAPI_Feature> Model_Object::featureRef()
+FeaturePtr Model_Object::featureRef()
 {
   return myRef;
 }
@@ -29,7 +29,7 @@ void Model_Object::setName(std::string theName)
   }
 }
 
-Model_Object::Model_Object(boost::shared_ptr<ModelAPI_Feature> theRef,
+Model_Object::Model_Object(FeaturePtr theRef,
                            Handle_TDataStd_Name theName)
                            : myRef(theRef), myName(theName)
 {
index 811edf709171f691d7f0340747d471d1011bea10..73975bc28e24dc91130eca9172c0bd5ad0ee707d 100644 (file)
  */
 class Model_Object : public ModelAPI_Object
 {
-  boost::shared_ptr<ModelAPI_Feature> myRef; ///< the referenced feature
+  FeaturePtr myRef; ///< the referenced feature
   Handle_TDataStd_Name myName; ///< the name of this object that may be changed
 public:
   /// Reference to the feature-operation that produces this object
-  MODEL_EXPORT virtual boost::shared_ptr<ModelAPI_Feature> featureRef();
+  MODEL_EXPORT virtual FeaturePtr featureRef();
 
   /// Returns the name of this object (by default equal to the name of feature)
   MODEL_EXPORT virtual std::string getName();
@@ -42,7 +42,7 @@ public:
   {return myRef->document();}
 
   /// Returns true if feature refers to the same model data instance
-  MODEL_EXPORT virtual bool isSame(const boost::shared_ptr<ModelAPI_Feature>& theFeature)
+  MODEL_EXPORT virtual bool isSame(const FeaturePtr& theFeature)
   {
     boost::shared_ptr<Model_Object> anObj = boost::dynamic_pointer_cast<Model_Object>(theFeature);
     return anObj && myRef == anObj->myRef;
@@ -57,7 +57,7 @@ public:
 private:
 
   /// Constructor fully defines this object
-  Model_Object(boost::shared_ptr<ModelAPI_Feature> theRef, Handle_TDataStd_Name theName);
+  Model_Object(FeaturePtr theRef, Handle_TDataStd_Name theName);
 
   friend class Model_Document;  
 };
index 1a6cef9d82964e297c036547464e3240ac0bdeec..c95ab12426ef7dd5c06e1ffb1399d2a12c54d027 100644 (file)
@@ -24,7 +24,7 @@ using namespace std;
 
 static Model_PluginManager* myImpl = new Model_PluginManager();
 
-boost::shared_ptr<ModelAPI_Feature> Model_PluginManager::createFeature(string theFeatureID)
+FeaturePtr Model_PluginManager::createFeature(string theFeatureID)
 {
   if (this != myImpl) return myImpl->createFeature(theFeatureID);
 
@@ -36,7 +36,7 @@ boost::shared_ptr<ModelAPI_Feature> Model_PluginManager::createFeature(string th
       Config_ModuleReader::loadLibrary(myCurrentPluginName);
     }
     if (myPluginObjs.find(myCurrentPluginName) != myPluginObjs.end()) {
-      boost::shared_ptr<ModelAPI_Feature> aCreated = 
+      FeaturePtr aCreated = 
         myPluginObjs[myCurrentPluginName]->createFeature(theFeatureID);
       if (!aCreated) {
         Events_Error::send(string("Can not initialize feature '") + theFeatureID +
@@ -48,7 +48,7 @@ boost::shared_ptr<ModelAPI_Feature> Model_PluginManager::createFeature(string th
     }
   }
 
-  return boost::shared_ptr<ModelAPI_Feature>(); // return nothing
+  return FeaturePtr(); // return nothing
 }
 
 boost::shared_ptr<ModelAPI_Document> Model_PluginManager::rootDocument()
index 4efef6a4cd5034c79e8ff69a405cc49b852ceb33..bed54c08b496dc4629c46cdbffe2544a69a60d6c 100644 (file)
@@ -7,6 +7,8 @@
 
 #include "Model.h"
 #include <ModelAPI_PluginManager.h>
+#include <ModelAPI_Feature.h>
+
 #include <Events_Listener.h>
 #include <map>
 
@@ -62,7 +64,7 @@ protected:
   void LoadPluginsInfo();
 
   /// Creates the feature object using plugins functionality
-  virtual boost::shared_ptr<ModelAPI_Feature> createFeature(std::string theFeatureID);
+  virtual FeaturePtr createFeature(std::string theFeatureID);
 };
 
 #endif
index 4fd8834669118d033d802c416da5250ec6152965..a16813609520877f62af3b2e996f96486cff5b65 100644 (file)
@@ -6,6 +6,7 @@
 #define ModelAPI_AttributeRefAttr_HeaderFile
 
 #include "ModelAPI_Attribute.h"
+#include "ModelAPI_Feature.h"
 
 /**\class ModelAPI_AttributeRefAttr
  * \ingroup DataModel
@@ -26,10 +27,10 @@ public:
   MODELAPI_EXPORT virtual boost::shared_ptr<ModelAPI_Attribute> attr() = 0;
 
   /// Defines the reference to the feature
-  MODELAPI_EXPORT virtual void setFeature(boost::shared_ptr<ModelAPI_Feature> theFeature) = 0;
+  MODELAPI_EXPORT virtual void setFeature(FeaturePtr theFeature) = 0;
 
   /// Returns feature referenced from this attribute
-  MODELAPI_EXPORT virtual boost::shared_ptr<ModelAPI_Feature> feature() = 0;
+  MODELAPI_EXPORT virtual FeaturePtr feature() = 0;
 
   /// Returns the type of this class of attributes
   MODELAPI_EXPORT static std::string type() {return "RefAttr";}
index 973fbc46deb88e83cf5af51ce18585c499e5b36d..87800fb3660d0ab102944894dc0093aaf5295138 100644 (file)
@@ -6,6 +6,7 @@
 #define ModelAPI_AttributeRefList_HeaderFile
 
 #include "ModelAPI_Attribute.h"
+#include "ModelAPI_Feature.h"
 #include <list>
 
 /**\class ModelAPI_AttributeRefList
@@ -23,16 +24,16 @@ public:
   MODELAPI_EXPORT virtual std::string attributeType() {return type();}
 
   /// Appends the feature to the end of a list
-  MODELAPI_EXPORT virtual void append(boost::shared_ptr<ModelAPI_Feature> theFeature) = 0;
+  MODELAPI_EXPORT virtual void append(FeaturePtr theFeature) = 0;
 
   /// Erases the first meet of the feature in the list
-  MODELAPI_EXPORT virtual void remove(boost::shared_ptr<ModelAPI_Feature> theFeature) = 0;
+  MODELAPI_EXPORT virtual void remove(FeaturePtr theFeature) = 0;
 
   /// Returns number of features in the list
   MODELAPI_EXPORT virtual int size() = 0;
 
   /// Returns the list of features
-  MODELAPI_EXPORT virtual std::list<boost::shared_ptr<ModelAPI_Feature> > list() = 0;
+  MODELAPI_EXPORT virtual std::list<FeaturePtr > list() = 0;
 
 protected:
   /// Objects are created for features automatically
index 37b22560cc520562ecf9e28134834d41f5ea2a28..0af5898ff69c29fb97b555fc619e81e17b754929 100644 (file)
@@ -6,6 +6,7 @@
 #define ModelAPI_AttributeReference_HeaderFile
 
 #include "ModelAPI_Attribute.h"
+#include <ModelAPI_Feature.h>
 
 /**\class ModelAPI_AttributeReference
  * \ingroup DataModel
@@ -16,10 +17,10 @@ class ModelAPI_AttributeReference : public ModelAPI_Attribute
 {
 public:
   /// Defines the feature referenced from this attribute
-  MODELAPI_EXPORT virtual void setValue(boost::shared_ptr<ModelAPI_Feature> theFeature) = 0;
+  MODELAPI_EXPORT virtual void setValue(FeaturePtr theFeature) = 0;
 
   /// Returns feature referenced from this attribute
-  MODELAPI_EXPORT virtual boost::shared_ptr<ModelAPI_Feature> value() = 0;
+  MODELAPI_EXPORT virtual FeaturePtr value() = 0;
 
   /// Returns the type of this class of attributes
   MODELAPI_EXPORT static std::string type() {return "Reference";}
index f8dd2289673e932f53d9d01a26df8e5acee9c17b..76967d18143f6e50c00374755a0ad13fa5f6f110 100644 (file)
@@ -14,8 +14,10 @@ class ModelAPI_AttributeDouble;
 class ModelAPI_AttributeReference;
 class ModelAPI_AttributeRefAttr;
 class ModelAPI_AttributeRefList;
+class ModelAPI_AttributeBoolean;
 class ModelAPI_Document;
 class ModelAPI_Attribute;
+class GeomAPI_Shape;
 
 /**\class ModelAPI_Data
  * \ingroup DataModel
@@ -43,6 +45,8 @@ public:
   virtual boost::shared_ptr<ModelAPI_AttributeRefAttr> refattr(const std::string theID) = 0;
   /// Returns the attribute that contains list of references to features
   virtual boost::shared_ptr<ModelAPI_AttributeRefList> reflist(const std::string theID) = 0;
+  /// Returns the attribute that contains boolean value
+  virtual boost::shared_ptr<ModelAPI_AttributeBoolean> boolean(const std::string theID) = 0;
 
   /// Returns the generic attribute by identifier
   /// \param theID identifier of the attribute
@@ -55,6 +59,11 @@ public:
   /// Returns true if it is correctly connected t othe data model
   virtual bool isValid() = 0;
 
+  /// Stores the shape (called by the execution method).
+  virtual void store(const boost::shared_ptr<GeomAPI_Shape>& theShape) = 0;
+  /// Returns the shape-result produced by this feature
+  virtual boost::shared_ptr<GeomAPI_Shape> shape() = 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 bd726461ff4194ecec2da0f35d4c5d65e63e80aa..6d7955f4b1dee713b9149faa581656770c1f5155 100644 (file)
@@ -58,7 +58,7 @@ public:
 
   /// Returns true if feature refers to the same model data instance
   MODELAPI_EXPORT virtual bool isSame(const boost::shared_ptr<ModelAPI_Feature>& theFeature)
-  {return true;}
+  {return theFeature.get() == this;}
 
   /// To virtually destroy the fields of successors
   virtual ~ModelAPI_Feature() {}
index 55ee0952733f50dbe8943d7c11f347b41e46414b..581f045884c0e45f2bf4efc43271fbfa47634611 100644 (file)
@@ -23,7 +23,7 @@ public:
   MODELAPI_EXPORT virtual bool isInHistory() {return false;}
 
   /// Reference to the feature-operation that produces this object
-  MODELAPI_EXPORT virtual boost::shared_ptr<ModelAPI_Feature> featureRef() = 0;
+  MODELAPI_EXPORT virtual FeaturePtr featureRef() = 0;
 
   /// Returns the name of this object (by default equal to the name of feature)
   MODELAPI_EXPORT virtual std::string getName() = 0;
index 82f7214d88e005c820d1fda431e71c81f9b8eb81..8679b5724cfd008ff0d8246e63ac62ce35651ca1 100644 (file)
@@ -11,6 +11,9 @@ SET(PROJECT_HEADERS
        ModuleBase_WidgetPoint2D.h
        ModuleBase_WidgetSwitch.h
        ModuleBase_MetaWidget.h
+    ModuleBase_SelectorWidget.h
+    ModuleBase_IWorkshop.h
+    ModuleBase_Widgets.h
 )
 
 SET(PROJECT_SOURCES
@@ -21,12 +24,16 @@ SET(PROJECT_SOURCES
        ModuleBase_WidgetPoint2D.cpp
        ModuleBase_WidgetSwitch.cpp
        ModuleBase_MetaWidget.cpp
+    ModuleBase_SelectorWidget.cpp
+    ModuleBase_Widgets.cpp
 )
 
 SET(PROJECT_LIBRARIES
     Config
     ModelAPI
     ${QT_LIBRARIES}
+       ${CAS_VIEWER}
+       ${CAS_KERNEL}
 )
 
 SET(PROJECT_AUTOMOC 
@@ -40,14 +47,15 @@ SOURCE_GROUP ("Generated Files" FILES ${PROJECT_AUTOMOC} ${PROJECT_COMPILED_RESO
 #SOURCE_GROUP ("Resource Files" FILES ${TEXT_RESOURCES} ${PROJECT_RESOURCES})
 
 INCLUDE_DIRECTORIES(
-    ${PROJECT_SOURCE_DIR}/src/Config
+    ${CAS_INCLUDE_DIRS}
+    ${CMAKE_SOURCE_DIR}/src/Config
     ${CMAKE_SOURCE_DIR}/src/Events
     ${CMAKE_SOURCE_DIR}/src/Model
     ${CMAKE_SOURCE_DIR}/src/ModelAPI
     ${CMAKE_SOURCE_DIR}/src/GeomDataAPI
 )
 
-ADD_DEFINITIONS(-DMODULEBASE_EXPORTS)
+ADD_DEFINITIONS(-DMODULEBASE_EXPORTS ${CAS_DEFINITIONS})
 ADD_LIBRARY(ModuleBase SHARED ${PROJECT_SOURCES} ${PROJECT_HEADERS})
 TARGET_LINK_LIBRARIES(ModuleBase ${PROJECT_LIBRARIES})
 
diff --git a/src/ModuleBase/ModuleBase_IWorkshop.h b/src/ModuleBase/ModuleBase_IWorkshop.h
new file mode 100644 (file)
index 0000000..d9dcf54
--- /dev/null
@@ -0,0 +1,37 @@
+// File:        ModuleBase_IWorkshop.h
+// Created:     2 June 2014
+// Author:      Vitaly Smetannikov
+
+#ifndef ModuleBase_IWorkshop_H
+#define ModuleBase_IWorkshop_H
+
+#include "ModuleBase.h"
+
+#include <ModelAPI_Feature.h>
+
+#include <AIS_InteractiveContext.hxx>
+
+#include <QObject>
+
+/**
+* Class which provides access to Workshop object serveces
+*/
+class MODULEBASE_EXPORT ModuleBase_IWorkshop: public QObject
+{
+Q_OBJECT
+public:
+  ModuleBase_IWorkshop(QObject* theParent):QObject(theParent) {}
+
+  virtual ~ModuleBase_IWorkshop() {};
+
+  //! Returns AIS_InteractiveContext from current OCCViewer
+  virtual Handle(AIS_InteractiveContext) AISContext() const = 0;
+
+  //! Returns list of currently selected data objects
+  virtual QList<FeaturePtr> selectedFeatures() const = 0; 
+
+signals:
+  void selectionChanged();
+};
+
+#endif
\ No newline at end of file
index a8a65232b423e09cff1312ac37c23d400a3a0408..ba8eb260d6857ab0208650d5b0d22e489f170080 100644 (file)
@@ -21,7 +21,7 @@ ModuleBase_MetaWidget::~ModuleBase_MetaWidget()
 
 }
 
-bool ModuleBase_MetaWidget::storeValue(boost::shared_ptr<ModelAPI_Feature> theFeature)
+bool ModuleBase_MetaWidget::storeValue(FeaturePtr theFeature)
 {
   #ifdef _DEBUG
   std::cout << "ModuleBase_MetaWidget::storeValue"
@@ -30,7 +30,7 @@ bool ModuleBase_MetaWidget::storeValue(boost::shared_ptr<ModelAPI_Feature> theFe
   return true;
 }
 
-bool ModuleBase_MetaWidget::restoreValue(boost::shared_ptr<ModelAPI_Feature> theFeature)
+bool ModuleBase_MetaWidget::restoreValue(FeaturePtr theFeature)
 {
   #ifdef _DEBUG
   std::cout << "ModuleBase_MetaWidget::restoreValue"
index 0bbc6fbcdfdc945964273092697e5acb451eb596..42504e0f0a98203a44d1b34501f40c93b2575c64 100644 (file)
@@ -23,9 +23,9 @@ public:
   MODULEBASE_EXPORT ModuleBase_MetaWidget(QWidget* theWrapped);
   virtual ~ModuleBase_MetaWidget();
   //! Interface for saving widget's data into the data model
-  MODULEBASE_EXPORT virtual bool storeValue(boost::shared_ptr<ModelAPI_Feature> theFeature);
+  MODULEBASE_EXPORT virtual bool storeValue(FeaturePtr theFeature);
   //! Interface for loading widget's data from the data model
-  MODULEBASE_EXPORT virtual bool restoreValue(boost::shared_ptr<ModelAPI_Feature> theFeature);
+  MODULEBASE_EXPORT virtual bool restoreValue(FeaturePtr theFeature);
 
   /// Set focus to the current widget if it corresponds to the given attribute
   /// \param theAttribute name
index afdc1f2cafccbf317b6faa7d3e3fe28696d3da64..c203579420b29a78e13f0c0d7e907d9678e348ab 100644 (file)
@@ -7,6 +7,8 @@
 
 #include <ModuleBase.h>
 
+#include <ModelAPI_Feature.h>
+
 #include <QObject>
 
 #include <boost/shared_ptr.hpp>
@@ -34,16 +36,16 @@ public:
 
   /// Saves the internal parameters to the given feature
   /// \param theFeature a model feature to be changed
-  virtual bool storeValue(boost::shared_ptr<ModelAPI_Feature> theFeature) = 0;
+  virtual bool storeValue(FeaturePtr theFeature) const = 0;
 
-  virtual bool restoreValue(boost::shared_ptr<ModelAPI_Feature> theFeature) = 0;
+  virtual bool restoreValue(FeaturePtr theFeature) = 0;
 
   /// Returns whether the widget can accept focus, or if it corresponds to the given attribute
   /// \param theAttribute name
-  virtual bool canFocusTo(const std::string& theAttributeName) = 0;
+  virtual bool canFocusTo(const std::string& theAttributeName) const { return false; }
 
   /// Set focus to the current widget if it corresponds to the given attribute
-  virtual void focusTo() = 0;
+  virtual void focusTo() {}
 
   /// Returns list of widget controls
   /// \return a control list
index 8bf69185cea2baa2bb0260b6742d5d46aa98ab23..52b23a92c7a7e337adeae683e38a4260e768b3db 100644 (file)
@@ -24,7 +24,7 @@
 #endif
 
 ModuleBase_Operation::ModuleBase_Operation(const QString& theId, QObject* theParent)
-: ModuleBase_IOperation(theId, theParent)
+: ModuleBase_IOperation(theId, theParent), myIsEditing(false)
 {
 }
 
@@ -37,7 +37,7 @@ QString ModuleBase_Operation::id() const
   return getDescription()->operationId();
 }
 
-boost::shared_ptr<ModelAPI_Feature> ModuleBase_Operation::feature() const
+FeaturePtr ModuleBase_Operation::feature() const
 {
   return myFeature;
 }
@@ -80,7 +80,8 @@ void ModuleBase_Operation::storeCustomValue()
 
 void ModuleBase_Operation::startOperation()
 {
-  setFeature(createFeature());
+  if (!myIsEditing)
+    setFeature(createFeature());
   //emit callSlot();
   //commit();
 }
@@ -112,10 +113,10 @@ void ModuleBase_Operation::flushCreated()
   Events_Loop::loop()->flush(Events_Loop::eventByName(EVENT_FEATURE_CREATED));
 }
 
-boost::shared_ptr<ModelAPI_Feature> ModuleBase_Operation::createFeature(const bool theFlushMessage)
+FeaturePtr ModuleBase_Operation::createFeature(const bool theFlushMessage)
 {
   boost::shared_ptr<ModelAPI_Document> aDoc = document();
-  boost::shared_ptr<ModelAPI_Feature> aFeature = aDoc->addFeature(
+  FeaturePtr aFeature = aDoc->addFeature(
                                            getDescription()->operationId().toStdString());
   if (aFeature) // TODO: generate an error if feature was not created
     aFeature->execute();
@@ -125,7 +126,13 @@ boost::shared_ptr<ModelAPI_Feature> ModuleBase_Operation::createFeature(const bo
   return aFeature;
 }
 
-void ModuleBase_Operation::setFeature(boost::shared_ptr<ModelAPI_Feature> theFeature)
+void ModuleBase_Operation::setFeature(FeaturePtr theFeature)
 {
   myFeature = theFeature;
 }
+
+void ModuleBase_Operation::setEditingFeature(FeaturePtr theFeature)
+{
+  myFeature = theFeature;
+  myIsEditing = true;
+}
index 833dbf57c80872c4234aafdf4a3191b3da4d0c68..a526655a2ab787d574a4706caedd7f5f06bdd188 100644 (file)
 #include <ModuleBase.h>
 #include <ModuleBase_IOperation.h>
 
+#include "ModelAPI_Feature.h"
+
 #include <QObject>
 #include <QString>
 
 #include <boost/shared_ptr.hpp>
 
-class ModelAPI_Feature;
 class ModelAPI_Document;
 
 class QKeyEvent;
@@ -54,7 +55,7 @@ public:
   QString id() const;
   /// Returns the operation feature
   /// \return the feature
-  boost::shared_ptr<ModelAPI_Feature> feature() const;
+  FeaturePtr feature() const;
 
   /// Returns whether the nested operations are enabled.
   /// The state can depend on the operation current state.
@@ -70,6 +71,11 @@ public:
 
   virtual void keyReleased(std::string theName, QKeyEvent* theEvent) {};
 
+  /// Sets the operation feature
+  void setEditingFeature(FeaturePtr theFeature);
+
+  bool isEditOperation() const { return myIsEditing; }
+
 protected:
   /// Virtual method called when operation started (see start() method for more description)
   /// Default impl calls corresponding slot and commits immediately.
@@ -91,14 +97,15 @@ protected:
   /// Creates an operation new feature
   /// \param theFlushMessage the flag whether the create message should be flushed
   /// \returns the created feature
-  virtual boost::shared_ptr<ModelAPI_Feature> createFeature(const bool theFlushMessage = true);
+  virtual FeaturePtr createFeature(const bool theFlushMessage = true);
 
-  /// Returns the operation feature
-  /// \return the feature
-  void setFeature(boost::shared_ptr<ModelAPI_Feature> theFeature);
+  /// Sets the operation feature
+  void setFeature(FeaturePtr theFeature);
 
 private:
-  boost::shared_ptr<ModelAPI_Feature> myFeature; /// the operation feature to be handled
+  FeaturePtr myFeature; /// the operation feature to be handled
+
+  bool myIsEditing;
 };
 
 #endif
diff --git a/src/ModuleBase/ModuleBase_SelectorWidget.cpp b/src/ModuleBase/ModuleBase_SelectorWidget.cpp
new file mode 100644 (file)
index 0000000..f694523
--- /dev/null
@@ -0,0 +1,205 @@
+// File:        ModuleBase_SelectorWidget.h
+// Created:     2 June 2014
+// Author:      Vitaly Smetannikov
+
+
+#include "ModuleBase_SelectorWidget.h"
+#include "ModuleBase_IWorkshop.h"
+
+#include <Events_Loop.h>
+#include <Model_Events.h>
+
+#include <ModelAPI_Data.h>
+#include <ModelAPI_Object.h>
+#include <ModelAPI_AttributeReference.h>
+#include <Config_WidgetAPI.h>
+
+#include <QWidget>
+#include <QLayout>
+#include <QLabel>
+#include <QLineEdit>
+#include <QToolButton>
+#include <QString>
+#include <QEvent>
+#include <QDockWidget>
+
+
+ModuleBase_SelectorWidget::ModuleBase_SelectorWidget(QWidget* theParent, 
+                                                     ModuleBase_IWorkshop* theWorkshop, 
+                                                     const Config_WidgetAPI* theData)
+: ModuleBase_ModelWidget(theParent), myWorkshop(theWorkshop), myActivateOnStart(false)
+{
+  myFeatureAttributeID = theData->widgetId();
+
+  myContainer = new QWidget(theParent);
+  QHBoxLayout* aLayout = new QHBoxLayout(myContainer);
+
+  aLayout->setContentsMargins(0, 0, 0, 0);
+  QString aLabelText = QString::fromStdString(theData->widgetLabel());
+  QString aLabelIcon = QString::fromStdString(theData->widgetIcon());
+  myLabel = new QLabel(aLabelText, myContainer);
+  myLabel->setPixmap(QPixmap(aLabelIcon));
+
+  aLayout->addWidget(myLabel);
+
+  QString aToolTip = QString::fromStdString(theData->widgetTooltip());
+  myTextLine = new QLineEdit(myContainer);
+  myTextLine->setReadOnly(true);
+  myTextLine->setToolTip(aToolTip);
+  myTextLine->installEventFilter(this);
+
+  aLayout->addWidget(myTextLine);
+
+  myActivateBtn = new QToolButton(myContainer);
+  myActivateBtn->setIcon(QIcon(":icons/hand_point.png"));
+  myActivateBtn->setCheckable(true);
+  myActivateBtn->setToolTip(tr("Activate/Deactivate selection"));
+  connect(myActivateBtn, SIGNAL(toggled(bool)), this, SLOT(activateSelection(bool)));
+
+  aLayout->addWidget(myActivateBtn);
+
+  QString aActivateTxt = QString::fromStdString(theData->getProperty("activate"));
+  if (!aActivateTxt.isNull()) {
+    myActivateOnStart = (aActivateTxt == "true");
+  }
+}
+
+//********************************************************************
+ModuleBase_SelectorWidget::~ModuleBase_SelectorWidget()
+{
+}
+
+//********************************************************************
+bool ModuleBase_SelectorWidget::storeValue(FeaturePtr theFeature) const
+{
+  DataPtr aData = theFeature->data();
+  boost::shared_ptr<ModelAPI_AttributeReference> aRef = 
+    boost::dynamic_pointer_cast<ModelAPI_AttributeReference>(aData->attribute(myFeatureAttributeID));
+
+  FeaturePtr aFeature = aRef->value();
+  if (!(aFeature && aFeature->isSame(mySelectedFeature))) {
+    aRef->setValue(mySelectedFeature);
+    Events_Loop::loop()->flush(Events_Loop::eventByName(EVENT_FEATURE_UPDATED));
+  }
+  return true;
+}
+
+//********************************************************************
+bool ModuleBase_SelectorWidget::restoreValue(FeaturePtr theFeature)
+{
+  DataPtr aData = theFeature->data();
+  boost::shared_ptr<ModelAPI_AttributeReference> aRef = aData->reference(myFeatureAttributeID);
+
+  bool isBlocked = this->blockSignals(true);
+  mySelectedFeature = aRef->value();
+  updateSelectionName(); 
+
+  this->blockSignals(isBlocked);
+  return true;
+}
+
+//********************************************************************
+QList<QWidget*> ModuleBase_SelectorWidget::getControls() const
+{
+  QList<QWidget*> aControls;
+  aControls.append(myLabel);
+  aControls.append(myTextLine);
+  aControls.append(myActivateBtn);
+  return aControls;
+}
+
+//********************************************************************
+void ModuleBase_SelectorWidget::onSelectionChanged()
+{
+  QList<FeaturePtr> aFeatures = myWorkshop->selectedFeatures();
+  if (aFeatures.size() > 0) {
+    FeaturePtr aFeature = aFeatures.first();
+    if ((!mySelectedFeature) && (!aFeature))
+      return;
+    if (mySelectedFeature && aFeature && mySelectedFeature->isSame(aFeature))
+      return;
+
+    // TODO: Check that the selection corresponds to selection type
+    // TODO: Use the feature kind definition like SKETCH_KIND instead of the direct text
+    if (aFeature->getKind().compare("Sketch") != 0)
+      return;
+
+    mySelectedFeature = aFeature;
+    if (mySelectedFeature) {
+      updateSelectionName();
+      activateSelection(false);
+      raisePanel();
+    } else {
+      myTextLine->setText("");
+    }
+    emit valuesChanged();
+  }
+}
+
+//********************************************************************
+void ModuleBase_SelectorWidget::updateSelectionName()
+{
+  if (mySelectedFeature) {
+    std::string aName;
+    if (mySelectedFeature->data())
+      aName = mySelectedFeature->data()->getName();
+    else 
+      aName = boost::dynamic_pointer_cast<ModelAPI_Object>(mySelectedFeature)->getName();
+    myTextLine->setText(QString::fromStdString(aName));
+  } else 
+    myTextLine->setText("");
+}
+
+//********************************************************************
+bool ModuleBase_SelectorWidget::eventFilter(QObject* theObj, QEvent* theEvent)
+{
+  if (theObj == myTextLine) {
+    if (theEvent->type() == QEvent::Polish) {
+      activateSelection(myActivateOnStart);
+      onSelectionChanged();
+    }
+  }
+  return ModuleBase_ModelWidget::eventFilter(theObj, theEvent);
+}
+
+//********************************************************************
+void ModuleBase_SelectorWidget::enableOthersControls(bool toEnable) const
+{
+  QWidget* aParent = myContainer->parentWidget();
+  QList<QWidget*> aChldList = aParent->findChildren<QWidget*>();
+  foreach(QWidget* aWgt, aChldList) {
+    if ((aWgt != myLabel) && (aWgt != myActivateBtn) && (aWgt != myTextLine) && (aWgt != myContainer))
+      aWgt->setEnabled(toEnable);
+  }
+}
+
+//********************************************************************
+void ModuleBase_SelectorWidget::activateSelection(bool toActivate)
+{
+  enableOthersControls(!toActivate);
+  myTextLine->setEnabled(toActivate);
+
+  if (toActivate)
+    connect(myWorkshop, SIGNAL(selectionChanged()), this, SLOT(onSelectionChanged()));
+  else
+    disconnect(myWorkshop, SIGNAL(selectionChanged()), this, SLOT(onSelectionChanged()));
+
+  myActivateBtn->setDown(toActivate);
+}
+
+//********************************************************************
+void ModuleBase_SelectorWidget::raisePanel() const
+{
+  QWidget* aParent = myContainer->parentWidget();
+  QWidget* aLastPanel = 0;
+  while (!aParent->inherits("QDockWidget")) {
+    aLastPanel = aParent;
+    aParent = aParent->parentWidget();
+    if (!aParent) return;
+  }
+  if (aParent->inherits("QDockWidget")) {
+    QDockWidget* aTabWgt = (QDockWidget*) aParent;
+    aTabWgt->raise();
+  }
+}
\ No newline at end of file
diff --git a/src/ModuleBase/ModuleBase_SelectorWidget.h b/src/ModuleBase/ModuleBase_SelectorWidget.h
new file mode 100644 (file)
index 0000000..45ef3d6
--- /dev/null
@@ -0,0 +1,80 @@
+// File:        ModuleBase_SelectorWidget.h
+// Created:     2 June 2014
+// Author:      Vitaly Smetannikov
+
+#ifndef ModuleBase_SelectorWidget_H
+#define ModuleBase_SelectorWidget_H
+
+#include "ModuleBase.h"
+#include "ModuleBase_ModelWidget.h"
+
+#include <ModelAPI_Feature.h>
+
+
+class Config_WidgetAPI;
+class QWidget;
+class QLabel;
+class QLineEdit;
+class QToolButton;
+class ModuleBase_IWorkshop;
+
+class MODULEBASE_EXPORT ModuleBase_SelectorWidget: public ModuleBase_ModelWidget
+{
+  Q_OBJECT
+public:
+  ModuleBase_SelectorWidget(QWidget* theParent, 
+                            ModuleBase_IWorkshop* theWorkshop, 
+                            const Config_WidgetAPI* theData);
+
+  virtual ~ModuleBase_SelectorWidget();
+
+  /// Saves the internal parameters to the given feature
+  /// \param theFeature a model feature to be changed
+  virtual bool storeValue(FeaturePtr theFeature) const;
+
+  virtual bool restoreValue(FeaturePtr theFeature);
+
+  /// Returns the internal parent wiget control, that can be shown anywhere
+  /// \returns the widget
+  QWidget* getControl() const { return myContainer; }
+
+  /// Returns list of widget controls
+  /// \return a control list
+  virtual QList<QWidget*> getControls() const;
+
+  void setActivationOnStart(bool toActivate) { myActivateOnStart = toActivate; }
+  bool activateOnStart() const { return myActivateOnStart; }
+
+  FeaturePtr selectedFeature() const { return mySelectedFeature; }
+
+public slots:
+
+  /// Activate or deactivate selection
+  void activateSelection(bool toActivate);
+
+protected:
+  bool eventFilter(QObject* theObj, QEvent* theEvent);
+
+private slots:
+  void onSelectionChanged();
+
+private:
+  void enableOthersControls(bool toEnable) const;
+  void updateSelectionName();
+  void raisePanel() const;
+
+  std::string myFeatureAttributeID;
+
+  QWidget*     myContainer;
+  QLabel*      myLabel;
+  QLineEdit*   myTextLine;
+  QToolButton* myActivateBtn;
+
+  ModuleBase_IWorkshop* myWorkshop;
+
+  bool myActivateOnStart;
+
+  FeaturePtr mySelectedFeature;
+};
+
+#endif
\ No newline at end of file
index 1ef8c83d8bedc66cea3b12e801dd69b0ee4d303c..63646b9565474d81917db69ca089bd0cf30155bb 100644 (file)
@@ -7,11 +7,12 @@
 
 #include <ModuleBase_WidgetFactory.h>
 
-#include <ModuleBase_MetaWidget.h>
 #include <ModuleBase_Operation.h>
 #include <ModuleBase_OperationDescription.h>
 #include <ModuleBase_WidgetPoint2D.h>
 #include <ModuleBase_WidgetSwitch.h>
+#include <ModuleBase_SelectorWidget.h>
+#include <ModuleBase_Widgets.h>
 
 #include <Config_Keywords.h>
 #include <Config_WidgetAPI.h>
@@ -25,9 +26,6 @@
 #include <QPixmap>
 #include <QGroupBox>
 #include <QToolBox>
-#include <QLineEdit>
-#include <QToolButton>
-#include <QCheckBox>
 
 #ifdef _DEBUG
 #include <QDebug>
@@ -36,8 +34,8 @@
 #include <cfloat>
 #include <climits>
 
-ModuleBase_WidgetFactory::ModuleBase_WidgetFactory(ModuleBase_Operation* theOperation)
- : myOperation(theOperation)
+ModuleBase_WidgetFactory::ModuleBase_WidgetFactory(ModuleBase_Operation* theOperation, ModuleBase_IWorkshop* theWorkshop)
+ : myOperation(theOperation), myWorkshop(theWorkshop)
 {
   QString aXml = myOperation->getDescription()->xmlRepresentation();
   myWidgetApi = new Config_WidgetAPI(aXml.toStdString());
@@ -106,7 +104,7 @@ QWidget* ModuleBase_WidgetFactory::createWidgetByType(const std::string& theType
 {
   QWidget* result = NULL;
   if (theType == WDG_DOUBLEVALUE) {
-    result = doubleSpinBoxControl();
+    result = doubleSpinBoxControl(theParent);
 
   } else if (theType == WDG_INFO) {
     result = labelControl(theParent);
@@ -149,52 +147,17 @@ QWidget* ModuleBase_WidgetFactory::createContainer(const std::string& theType, Q
   return result;
 }
 
-QWidget* ModuleBase_WidgetFactory::doubleSpinBoxControl()
+QWidget* ModuleBase_WidgetFactory::doubleSpinBoxControl(QWidget* theParent)
 {
-  QWidget* result = new QWidget();
-  QHBoxLayout* aControlLay = new QHBoxLayout(result);
-  aControlLay->setContentsMargins(0, 0, 0, 0);
-  QString aLabelText = qs(myWidgetApi->widgetLabel());
-  QString aLabelIcon = qs(myWidgetApi->widgetIcon());
-  QLabel* aLabel = new QLabel(aLabelText);
-  aLabel->setPixmap(QPixmap(aLabelIcon));
+  ModuleBase_DoubleValueWidget* aDblWgt = new ModuleBase_DoubleValueWidget(theParent, myWidgetApi);
+  QObject::connect(aDblWgt, SIGNAL(valuesChanged()),  myOperation, SLOT(storeCustomValue()));
 
-  aControlLay->addWidget(aLabel);
-  QDoubleSpinBox* aBox = new QDoubleSpinBox(result);
-  QString anObjName = QString::fromStdString(myWidgetApi->widgetId());
-  aBox->setObjectName(anObjName);
-  bool isOk = false;
-  std::string aProp = myWidgetApi->getProperty(DOUBLE_WDG_MIN);
-  double aMinVal = qs(aProp).toDouble(&isOk);
-  if (isOk) {
-    aBox->setMinimum(aMinVal);
-  } else {
-    aBox->setMinimum(-DBL_MAX);
-  }
-  aProp = myWidgetApi->getProperty(DOUBLE_WDG_MAX);
-  double aMaxVal = qs(aProp).toDouble(&isOk);
-  if (isOk) {
-    aBox->setMaximum(aMaxVal);
-  } else {
-    aBox->setMaximum(DBL_MAX);
-  }
-  aProp = myWidgetApi->getProperty(DOUBLE_WDG_STEP);
-  double aStepVal = qs(aProp).toDouble(&isOk);
-  if (isOk) {
-    aBox->setSingleStep(aStepVal);
-  }
-  aProp = myWidgetApi->getProperty(DOUBLE_WDG_DFLT);
-  double aDefVal = qs(aProp).toDouble(&isOk);
-  if (isOk) {
-    aBox->setValue(aDefVal);
-  }
-  QString aTTip = qs(myWidgetApi->widgetTooltip());
-  aBox->setToolTip(aTTip);
-  aControlLay->addWidget(aBox);
-  aControlLay->setStretch(1, 1);
-  result->setLayout(aControlLay);
-  connectWidget(aBox, WDG_DOUBLEVALUE);
-  return result;
+  myModelWidgets.append(aDblWgt);
+
+  // Init default values
+  if (!myOperation->isEditOperation())
+    aDblWgt->storeValue(myOperation->feature());
+  return aDblWgt->getControl();
 }
 
 QWidget* ModuleBase_WidgetFactory::pointSelectorControl(QWidget* theParent)
@@ -229,40 +192,24 @@ QString ModuleBase_WidgetFactory::qs(const std::string& theStdString) const
 
 QWidget* ModuleBase_WidgetFactory::selectorControl(QWidget* theParent)
 {
-  QWidget* aRes = new QWidget();
-  QHBoxLayout* aLayout = new QHBoxLayout(aRes);
-
-  aLayout->setContentsMargins(0, 0, 0, 0);
-  QString aLabelText = qs(myWidgetApi->widgetLabel());
-  QString aLabelIcon = qs(myWidgetApi->widgetIcon());
-  QLabel* aLabel = new QLabel(aLabelText, aRes);
-  aLabel->setPixmap(QPixmap(aLabelIcon));
+  ModuleBase_SelectorWidget* aSelector = new ModuleBase_SelectorWidget(theParent, myWorkshop, myWidgetApi);
+  
+  QObject::connect(aSelector, SIGNAL(valuesChanged()),  myOperation, SLOT(storeCustomValue()));
 
-  aLayout->addWidget(aLabel);
-
-  QLineEdit* aTextLine = new QLineEdit(aRes);
-  aTextLine->setReadOnly(true);
-
-  aLayout->addWidget(aTextLine);
-
-  QToolButton* aActivateBtn = new QToolButton(aRes);
-  aActivateBtn->setIcon(QIcon(":icons/hand_point.png"));
-  aActivateBtn->setCheckable(true);
-
-  aLayout->addWidget(aActivateBtn);
-
-  return aRes;
+  myModelWidgets.append(aSelector);
+  return aSelector->getControl();
 }
 
 
 QWidget* ModuleBase_WidgetFactory::booleanControl(QWidget* theParent)
 {
-  QString aText = qs(myWidgetApi->widgetLabel());
-  QString aToolTip = qs(myWidgetApi->widgetTooltip());
-  QString aDefault = qs(myWidgetApi->getProperty("default"));
+  ModuleBase_BoolValueWidget* aBoolWgt = new ModuleBase_BoolValueWidget(theParent, myWidgetApi);
+  QObject::connect(aBoolWgt, SIGNAL(valuesChanged()),  myOperation, SLOT(storeCustomValue()));
+
+  myModelWidgets.append(aBoolWgt);
 
-  QCheckBox* aRes = new QCheckBox(aText, theParent);
-  aRes->setToolTip(aToolTip);
-  aRes->setChecked(aDefault == "true");
-  return aRes;
+  // Init default values
+  if (!myOperation->isEditOperation())
+    aBoolWgt->storeValue(myOperation->feature());
+  return aBoolWgt->getControl();
 }
\ No newline at end of file
index f0303cdae36e66a47d336cb935514118650a8054..e20fd2d9cf7191ddfa151b9cdfb6d97fe0aefb89 100644 (file)
@@ -8,8 +8,8 @@
 #ifndef ModuleBase_WidgetFactory_H_
 #define ModuleBase_WidgetFactory_H_
 
-#include <ModuleBase.h>
-#include <ModuleBase_ModelWidget.h>
+#include "ModuleBase.h"
+#include "ModuleBase_ModelWidget.h"
 
 #include <QString>
 #include <QList>
@@ -18,11 +18,12 @@ class QObject;
 class QWidget;
 class Config_WidgetAPI;
 class ModuleBase_Operation;
+class ModuleBase_IWorkshop;
 
 class MODULEBASE_EXPORT ModuleBase_WidgetFactory
 {
 public:
-  ModuleBase_WidgetFactory(ModuleBase_Operation*);
+  ModuleBase_WidgetFactory(ModuleBase_Operation* theOperation, ModuleBase_IWorkshop* theWorkshop);
   virtual ~ModuleBase_WidgetFactory();
 
   void createWidget(QWidget* theParent);
@@ -36,7 +37,7 @@ protected:
   //Widgets
   QWidget* createWidgetByType(const std::string& theType, QWidget* theParent = NULL);
   QWidget* labelControl(QWidget* theParent);
-  QWidget* doubleSpinBoxControl();
+  QWidget* doubleSpinBoxControl(QWidget* theParent);
   QWidget* pointSelectorControl(QWidget* theParent);
   QWidget* createContainer(const std::string& theType, QWidget* theParent = NULL);
   QWidget* selectorControl(QWidget* theParent);
@@ -48,6 +49,7 @@ protected:
 private:
   Config_WidgetAPI* myWidgetApi;
   ModuleBase_Operation*   myOperation;
+  ModuleBase_IWorkshop*   myWorkshop;
 
   QList<ModuleBase_ModelWidget*> myModelWidgets;
 };
index cbc61430a743a286c9278a46b33573c28364ed7c..2d8c814798d423fb16cbbe8a1f1dee2bc1865ae9 100644 (file)
@@ -68,21 +68,22 @@ ModuleBase_WidgetPoint2D::~ModuleBase_WidgetPoint2D()
 {
 }
 
-bool ModuleBase_WidgetPoint2D::storeValue(boost::shared_ptr<ModelAPI_Feature> theFeature)
+bool ModuleBase_WidgetPoint2D::storeValue(FeaturePtr theFeature) const
 {
   boost::shared_ptr<ModelAPI_Data> aData = theFeature->data();
   boost::shared_ptr<GeomDataAPI_Point2D> aPoint =
     boost::dynamic_pointer_cast<GeomDataAPI_Point2D>(aData->attribute(myFeatureAttributeID));
 
-  bool isBlocked = this->blockSignals(true);
+  ModuleBase_WidgetPoint2D* that = (ModuleBase_WidgetPoint2D*) this;
+  bool isBlocked = that->blockSignals(true);
   aPoint->setValue(myXSpin->value(), myYSpin->value());
   Events_Loop::loop()->flush(Events_Loop::eventByName(EVENT_FEATURE_UPDATED));
+  that->blockSignals(isBlocked);
 
-  this->blockSignals(isBlocked);
   return true;
 }
 
-bool ModuleBase_WidgetPoint2D::restoreValue(boost::shared_ptr<ModelAPI_Feature> theFeature)
+bool ModuleBase_WidgetPoint2D::restoreValue(FeaturePtr theFeature)
 {
   boost::shared_ptr<ModelAPI_Data> aData = theFeature->data();
   boost::shared_ptr<GeomDataAPI_Point2D> aPoint =
index 1a09516b00c30e50635cca03db926459f5233120..85c4c938d5aa0e6dfd69a2b768debcfd44f74bff 100644 (file)
@@ -34,9 +34,9 @@ public:
 
   /// Saves the internal parameters to the given feature
   /// \param theFeature a model feature to be changed
-  virtual bool storeValue(boost::shared_ptr<ModelAPI_Feature> theFeature);
+  virtual bool storeValue(FeaturePtr theFeature) const;
 
-  virtual bool restoreValue(boost::shared_ptr<ModelAPI_Feature> theFeature);
+  virtual bool restoreValue(FeaturePtr theFeature);
 
   /// Returns whether the widget can accept focus, or if it corresponds to the given attribute
   /// \param theAttribute name
diff --git a/src/ModuleBase/ModuleBase_Widgets.cpp b/src/ModuleBase/ModuleBase_Widgets.cpp
new file mode 100644 (file)
index 0000000..0d810ec
--- /dev/null
@@ -0,0 +1,170 @@
+// File:        ModuleBase_Widgets.h
+// Created:     04 June 2014
+// Author:      Vitaly Smetannikov
+
+#include "ModuleBase_Widgets.h"
+
+#include <ModelAPI_AttributeDouble.h>
+#include <ModelAPI_AttributeBoolean.h>
+#include <ModelAPI_Data.h>
+
+#include <Config_Keywords.h>
+#include <Config_WidgetAPI.h>
+
+#include <Events_Loop.h>
+#include <Model_Events.h>
+
+#include <QWidget>
+#include <QLayout>
+#include <QLabel>
+#include <QDoubleSpinBox>
+#include <QCheckBox>
+
+
+ModuleBase_DoubleValueWidget::ModuleBase_DoubleValueWidget(QWidget* theParent, const Config_WidgetAPI* theData)
+  : ModuleBase_ModelWidget(theParent)
+{
+  myContainer = new QWidget(theParent);
+  QHBoxLayout* aControlLay = new QHBoxLayout(myContainer);
+  aControlLay->setContentsMargins(0, 0, 0, 0);
+
+  QString aLabelText = QString::fromStdString(theData->widgetLabel());
+  QString aLabelIcon = QString::fromStdString(theData->widgetIcon());
+  myLabel = new QLabel(aLabelText, myContainer);
+  myLabel->setPixmap(QPixmap(aLabelIcon));
+  aControlLay->addWidget(myLabel);
+
+  myAttributeID = theData->widgetId();
+  mySpinBox = new QDoubleSpinBox(myContainer);
+  QString anObjName = QString::fromStdString(myAttributeID);
+  mySpinBox->setObjectName(anObjName);
+
+  bool isOk = false;
+  std::string aProp = theData->getProperty(DOUBLE_WDG_MIN);
+  double aMinVal = QString::fromStdString(aProp).toDouble(&isOk);
+  if (isOk) {
+    mySpinBox->setMinimum(aMinVal);
+  } else {
+    mySpinBox->setMinimum(-DBL_MAX);
+  }
+
+  aProp = theData->getProperty(DOUBLE_WDG_MAX);
+  double aMaxVal = QString::fromStdString(aProp).toDouble(&isOk);
+  if (isOk) {
+    mySpinBox->setMaximum(aMaxVal);
+  } else {
+    mySpinBox->setMaximum(DBL_MAX);
+  }
+
+  aProp = theData->getProperty(DOUBLE_WDG_STEP);
+  double aStepVal = QString::fromStdString(aProp).toDouble(&isOk);
+  if (isOk) {
+    mySpinBox->setSingleStep(aStepVal);
+  }
+
+  aProp = theData->getProperty(DOUBLE_WDG_DFLT);
+  double aDefVal = QString::fromStdString(aProp).toDouble(&isOk);
+  if (isOk) {
+    mySpinBox->setValue(aDefVal);
+  }
+
+  QString aTTip = QString::fromStdString(theData->widgetTooltip());
+  mySpinBox->setToolTip(aTTip);
+
+  aControlLay->addWidget(mySpinBox);
+  aControlLay->setStretch(1, 1);
+
+  connect(mySpinBox, SIGNAL(valueChanged(double)), this, SIGNAL(valuesChanged()));
+}
+
+ModuleBase_DoubleValueWidget::~ModuleBase_DoubleValueWidget()
+{
+}
+
+bool ModuleBase_DoubleValueWidget::storeValue(FeaturePtr theFeature) const
+{
+  DataPtr aData = theFeature->data();
+  boost::shared_ptr<ModelAPI_AttributeDouble> aReal = aData->real(myAttributeID);
+  if (aReal->value() != mySpinBox->value()) {
+    aReal->setValue(mySpinBox->value());
+    Events_Loop::loop()->flush(Events_Loop::eventByName(EVENT_FEATURE_UPDATED));
+  }
+  return true;
+}
+
+bool ModuleBase_DoubleValueWidget::restoreValue(FeaturePtr theFeature)
+{
+  DataPtr aData = theFeature->data();
+  boost::shared_ptr<ModelAPI_AttributeDouble> aRef = aData->real(myAttributeID);
+
+  bool isBlocked = mySpinBox->blockSignals(true);
+  mySpinBox->setValue(aRef->value());
+  mySpinBox->blockSignals(isBlocked);
+
+  return true;
+}
+
+QList<QWidget*> ModuleBase_DoubleValueWidget::getControls() const
+{
+  QList<QWidget*> aList;
+  aList.append(myLabel);
+  aList.append(mySpinBox);
+  return aList;
+}
+
+
+//////////////////////////////////////////////////////////////////////////////////
+ModuleBase_BoolValueWidget::ModuleBase_BoolValueWidget(QWidget* theParent, const Config_WidgetAPI* theData)
+  : ModuleBase_ModelWidget(theParent)
+{
+  myAttributeID = theData->widgetId();
+  QString aText = QString::fromStdString(theData->widgetLabel());
+  QString aToolTip = QString::fromStdString(theData->widgetTooltip());
+  QString aDefault = QString::fromStdString(theData->getProperty("default"));
+
+  myCheckBox = new QCheckBox(aText, theParent);
+  myCheckBox->setToolTip(aToolTip);
+  myCheckBox->setChecked(aDefault == "true");
+
+  connect(myCheckBox, SIGNAL(toggled(bool)), this, SIGNAL(valuesChanged()));
+}
+
+ModuleBase_BoolValueWidget::~ModuleBase_BoolValueWidget()
+{
+}
+
+QWidget* ModuleBase_BoolValueWidget::getControl() const 
+{ 
+  return myCheckBox; 
+}
+
+bool ModuleBase_BoolValueWidget::storeValue(FeaturePtr theFeature) const
+{
+  DataPtr aData = theFeature->data();
+  boost::shared_ptr<ModelAPI_AttributeBoolean> aBool = aData->boolean(myAttributeID);
+
+  if (aBool->value() != myCheckBox->isChecked()) {
+    aBool->setValue(myCheckBox->isChecked());
+    Events_Loop::loop()->flush(Events_Loop::eventByName(EVENT_FEATURE_UPDATED));
+  }
+  return true;
+}
+
+bool ModuleBase_BoolValueWidget::restoreValue(FeaturePtr theFeature)
+{
+  DataPtr aData = theFeature->data();
+  boost::shared_ptr<ModelAPI_AttributeBoolean> aRef = aData->boolean(myAttributeID);
+
+  bool isBlocked = myCheckBox->blockSignals(true);
+  myCheckBox->setChecked(aRef->value());
+  myCheckBox->blockSignals(isBlocked);
+
+  return true;
+}
+
+QList<QWidget*> ModuleBase_BoolValueWidget::getControls() const
+{
+  QList<QWidget*> aList;
+  aList.append(myCheckBox);
+  return aList;
+}
diff --git a/src/ModuleBase/ModuleBase_Widgets.h b/src/ModuleBase/ModuleBase_Widgets.h
new file mode 100644 (file)
index 0000000..d8030f9
--- /dev/null
@@ -0,0 +1,78 @@
+// File:        ModuleBase_Widgets.h
+// Created:     04 June 2014
+// Author:      Vitaly Smetannikov
+
+#ifndef ModuleBase_Widgets_H
+#define ModuleBase_Widgets_H
+
+#include "ModuleBase.h"
+#include "ModuleBase_ModelWidget.h"
+
+class Config_WidgetAPI;
+class QWidget;
+class QLabel;
+class QDoubleSpinBox;
+class QCheckBox;
+
+class MODULEBASE_EXPORT ModuleBase_DoubleValueWidget: public ModuleBase_ModelWidget
+{
+  Q_OBJECT
+public:
+  ModuleBase_DoubleValueWidget(QWidget* theParent, const Config_WidgetAPI* theData);
+
+  virtual ~ModuleBase_DoubleValueWidget();
+
+  /// Saves the internal parameters to the given feature
+  /// \param theFeature a model feature to be changed
+  virtual bool storeValue(FeaturePtr theFeature) const;
+
+  virtual bool restoreValue(FeaturePtr theFeature);
+
+  /// Returns list of widget controls
+  /// \return a control list
+  virtual QList<QWidget*> getControls() const;
+
+  /// Returns the internal parent wiget control, that can be shown anywhere
+  /// \returns the widget
+  QWidget* getControl() const { return myContainer; }
+
+private:
+  std::string myAttributeID;
+  
+  QWidget*     myContainer;
+  QLabel*      myLabel;
+  QDoubleSpinBox* mySpinBox;
+};
+
+
+//////////////////////////////////////////////////////////////////////////////////
+
+class MODULEBASE_EXPORT ModuleBase_BoolValueWidget: public ModuleBase_ModelWidget
+{
+  Q_OBJECT
+public:
+  ModuleBase_BoolValueWidget(QWidget* theParent, const Config_WidgetAPI* theData);
+
+  virtual ~ModuleBase_BoolValueWidget();
+
+  /// Saves the internal parameters to the given feature
+  /// \param theFeature a model feature to be changed
+  virtual bool storeValue(FeaturePtr theFeature) const;
+
+  virtual bool restoreValue(FeaturePtr theFeature);
+
+  /// Returns list of widget controls
+  /// \return a control list
+  virtual QList<QWidget*> getControls() const;
+
+  /// Returns the internal parent wiget control, that can be shown anywhere
+  /// \returns the widget
+  QWidget* getControl() const;
+
+private:
+  std::string myAttributeID;
+  
+  QCheckBox* myCheckBox;
+};
+
+#endif
\ No newline at end of file
index 4eee4a29489646d15093f9cb1d10080fd7d9b488..27b7c58f481c9ea961947fc3c0af63b6386d2290 100644 (file)
@@ -1,6 +1,4 @@
 
-INCLUDE(FindCAS)
-
 SET(CMAKE_AUTOMOC ON)
 
 SET(PROJECT_HEADERS
index 9ccf4e46b3b6ab0eb2153da3030e748e95045b95..fe69c3399ad643009c59053c863665e4c553f630 100644 (file)
@@ -1,27 +1,33 @@
 INCLUDE(Common)
-INCLUDE(FindCAS)
 
 SET(CMAKE_AUTOMOC ON)
 
 SET(PROJECT_HEADERS
        PartSet.h
+       PartSet_Constants.h
+       PartSet_FeaturePrs.h
        PartSet_Listener.h
        PartSet_Module.h
+       PartSet_OperationConstraint.h
+       PartSet_OperationCreateFeature.h
        PartSet_OperationEditLine.h
        PartSet_OperationSketchBase.h
        PartSet_OperationSketch.h
-       PartSet_OperationSketchLine.h
+       PartSet_Presentation.h
        PartSet_TestOCC.h
        PartSet_Tools.h
 )
 
 SET(PROJECT_SOURCES
+       PartSet_FeaturePrs.cpp
        PartSet_Listener.cpp
        PartSet_Module.cpp
+       PartSet_OperationConstraint.cpp
+       PartSet_OperationCreateFeature.cpp
        PartSet_OperationEditLine.cpp
        PartSet_OperationSketchBase.cpp
        PartSet_OperationSketch.cpp
-       PartSet_OperationSketchLine.cpp
+       PartSet_Presentation.cpp
        PartSet_TestOCC.cpp
        PartSet_Tools.cpp
 )
diff --git a/src/PartSet/PartSet_Constants.h b/src/PartSet/PartSet_Constants.h
new file mode 100644 (file)
index 0000000..95b28bd
--- /dev/null
@@ -0,0 +1,21 @@
+// File:        PartSet_Tools.h
+// Created:     04 Jun 2014
+// Author:      Natalia ERMOLAEVA
+
+#ifndef PartSet_Constants_H
+#define PartSet_Constants_H
+
+#include <ModelAPI_Feature.h>
+
+/// This file contains various constants used in the PartSet module
+
+/// Types of viewer selection in an operation
+enum PartSet_SelectionMode
+{
+  SM_FirstPoint,
+  SM_SecondPoint,
+  SM_DonePoint
+};
+
+
+#endif
diff --git a/src/PartSet/PartSet_FeaturePrs.cpp b/src/PartSet/PartSet_FeaturePrs.cpp
new file mode 100644 (file)
index 0000000..434dd94
--- /dev/null
@@ -0,0 +1,224 @@
+// File:        PartSet_FeaturePrs.h
+// Created:     04 Jun 2014
+// Author:      Natalia ERMOLAEVA
+
+#include <PartSet_FeaturePrs.h>
+
+#include <SketchPlugin_Feature.h>
+#include <SketchPlugin_Sketch.h>
+#include <SketchPlugin_ConstraintCoincidence.h>
+#include <SketchPlugin_Line.h>
+#include <SketchPlugin_Constraint.h>
+
+#include <GeomDataAPI_Point2D.h>
+
+#include <ModelAPI_Data.h>
+#include <ModelAPI_Document.h>
+#include <ModelAPI_AttributeRefAttr.h>
+#include <ModelAPI_AttributeRefList.h>
+
+#include <Precision.hxx>
+
+using namespace std;
+
+PartSet_FeaturePrs::PartSet_FeaturePrs(FeaturePtr theFeature)
+: mySketch(theFeature)
+{
+}
+
+PartSet_FeaturePrs::~PartSet_FeaturePrs()
+{
+}
+
+void PartSet_FeaturePrs::init(FeaturePtr theFeature, FeaturePtr theSourceFeature)
+{
+  myFeature = theFeature;
+  if (theSourceFeature)
+  {
+    // use the last point of the previous feature as the first of the new one
+    boost::shared_ptr<ModelAPI_Data> aData = theSourceFeature->data();
+    boost::shared_ptr<GeomDataAPI_Point2D> anInitPoint = boost::dynamic_pointer_cast<GeomDataAPI_Point2D>
+                                                                  (aData->attribute(LINE_ATTR_END));
+    setLinePoint(theFeature, anInitPoint->x(), anInitPoint->y(), LINE_ATTR_START);
+    setLinePoint(theFeature, anInitPoint->x(), anInitPoint->y(), LINE_ATTR_END);
+
+    aData = theFeature->data();
+    boost::shared_ptr<GeomDataAPI_Point2D> aPoint = boost::dynamic_pointer_cast<GeomDataAPI_Point2D>
+                                                                 (aData->attribute(LINE_ATTR_START));
+    createConstraint(anInitPoint, aPoint);
+  }
+}
+
+boost::shared_ptr<ModelAPI_Document> PartSet_FeaturePrs::document() const
+{
+  return ModelAPI_PluginManager::get()->rootDocument();
+}
+
+FeaturePtr PartSet_FeaturePrs::sketch() const
+{
+  return mySketch;
+}
+
+PartSet_SelectionMode PartSet_FeaturePrs::setPoint(double theX, double theY,
+                                                   const PartSet_SelectionMode& theMode)
+{
+  PartSet_SelectionMode aMode = theMode;
+  switch (theMode)
+  {
+    case SM_FirstPoint: {
+      setLinePoint(feature(), theX, theY, LINE_ATTR_START);
+      setLinePoint(feature(), theX, theY, LINE_ATTR_END);
+      aMode = SM_SecondPoint;
+    }
+    break;
+    case SM_SecondPoint: {
+      setLinePoint(feature(), theX, theY, LINE_ATTR_END);
+      aMode = SM_DonePoint;
+   }
+    break;
+    default:
+      break;
+  }
+  return aMode;
+}
+
+FeaturePtr PartSet_FeaturePrs::feature() const
+{
+  return myFeature;
+}
+
+void PartSet_FeaturePrs::createConstraint(boost::shared_ptr<GeomDataAPI_Point2D> thePoint1,
+                                          boost::shared_ptr<GeomDataAPI_Point2D> thePoint2)
+{
+  boost::shared_ptr<ModelAPI_Document> aDoc = document();
+  FeaturePtr aFeature = aDoc->addFeature(SKETCH_CONSTRAINT_COINCIDENCE_KIND);
+
+  if (sketch()) {
+    boost::shared_ptr<SketchPlugin_Feature> aSketch = 
+                           boost::dynamic_pointer_cast<SketchPlugin_Feature>(sketch());
+    aSketch->addSub(aFeature);
+  }
+
+  boost::shared_ptr<ModelAPI_Data> aData = aFeature->data();
+
+  boost::shared_ptr<ModelAPI_AttributeRefAttr> aRef1 =
+        boost::dynamic_pointer_cast<ModelAPI_AttributeRefAttr>(aData->attribute(CONSTRAINT_ATTR_ENTITY_A));
+  aRef1->setAttr(thePoint1);
+
+  boost::shared_ptr<ModelAPI_AttributeRefAttr> aRef2 =
+        boost::dynamic_pointer_cast<ModelAPI_AttributeRefAttr>(aData->attribute(CONSTRAINT_ATTR_ENTITY_B));
+  aRef2->setAttr(thePoint2);
+
+  if (aFeature) // TODO: generate an error if feature was not created
+    aFeature->execute();
+}
+
+void PartSet_FeaturePrs::setConstraints(double theX, double theY,
+                                        const PartSet_SelectionMode& theMode)
+{
+  std::string aPointArg;
+  switch (theMode)
+  {
+    case SM_FirstPoint:
+      aPointArg = LINE_ATTR_START;
+      break;
+    case SM_SecondPoint:
+      aPointArg = LINE_ATTR_END;
+      break;
+    default:
+      break;
+  }
+
+  FeaturePtr aSkFeature = feature();
+
+  boost::shared_ptr<ModelAPI_Data> aData = feature()->data();
+  boost::shared_ptr<GeomDataAPI_Point2D> aPoint = boost::dynamic_pointer_cast<GeomDataAPI_Point2D>
+                                                              (aData->attribute(aPointArg));
+  aData = sketch()->data();
+  boost::shared_ptr<ModelAPI_AttributeRefList> aRefList =
+        boost::dynamic_pointer_cast<ModelAPI_AttributeRefList>(aData->attribute(SKETCH_ATTR_FEATURES));
+
+  std::list<FeaturePtr > aFeatures = aRefList->list();
+  std::list<FeaturePtr >::const_iterator anIt = aFeatures.begin(),
+                                                                  aLast = aFeatures.end();
+  for (; anIt != aLast; anIt++) {
+    FeaturePtr aFeature = *anIt;
+    boost::shared_ptr<GeomDataAPI_Point2D> aFPoint = findLinePoint(aFeature, theX, theY);
+    if (aFPoint)
+      createConstraint(aFPoint, aPoint);
+  }
+}
+
+std::string PartSet_FeaturePrs::getAttribute(const PartSet_SelectionMode& theMode) const
+{
+  std::string aAttribute;
+  switch (theMode)
+  {
+    case SM_FirstPoint:
+      aAttribute = LINE_ATTR_START;
+    break;
+    case SM_SecondPoint:
+      aAttribute = LINE_ATTR_END;
+    break;
+    default:
+    break;
+  }
+  return aAttribute;
+}
+
+PartSet_SelectionMode PartSet_FeaturePrs::getNextMode(const std::string& theAttribute) const
+{
+  PartSet_SelectionMode aMode;
+
+  if (theAttribute == LINE_ATTR_START)
+    aMode = SM_SecondPoint;
+  else if (theAttribute == LINE_ATTR_END)
+    aMode = SM_DonePoint;
+  return aMode;
+}
+
+void PartSet_FeaturePrs::getLinePoint(FeaturePtr theFeature,
+                                               const std::string& theAttribute,
+                                               double& theX, double& theY)
+{
+  if (!theFeature || theFeature->getKind() != SKETCH_LINE_KIND)
+    return;
+  boost::shared_ptr<ModelAPI_Data> aData = theFeature->data();
+  boost::shared_ptr<GeomDataAPI_Point2D> aPoint =
+        boost::dynamic_pointer_cast<GeomDataAPI_Point2D>(aData->attribute(theAttribute));
+  theX = aPoint->x();
+  theY = aPoint->y();
+}
+
+boost::shared_ptr<GeomDataAPI_Point2D> PartSet_FeaturePrs::findLinePoint(
+                                               FeaturePtr theFeature,
+                                               double theX, double theY)
+{
+  boost::shared_ptr<GeomDataAPI_Point2D> aPoint2D;
+  if (!theFeature || theFeature->getKind() != SKETCH_LINE_KIND)
+    return aPoint2D;
+  boost::shared_ptr<ModelAPI_Data> aData = theFeature->data();
+  
+  boost::shared_ptr<GeomDataAPI_Point2D> aPoint =
+        boost::dynamic_pointer_cast<GeomDataAPI_Point2D>(aData->attribute(LINE_ATTR_START));
+  if (fabs(aPoint->x() - theX) < Precision::Confusion() && fabs(aPoint->y() - theY) < Precision::Confusion() )
+    aPoint2D = aPoint;
+  else {
+    aPoint = boost::dynamic_pointer_cast<GeomDataAPI_Point2D>(aData->attribute(LINE_ATTR_END));
+    if (fabs(aPoint->x() - theX) < Precision::Confusion() && fabs(aPoint->y() - theY) < Precision::Confusion() )
+      aPoint2D = aPoint;
+  }
+  return aPoint2D;
+}
+
+void PartSet_FeaturePrs::setLinePoint(FeaturePtr theFeature,
+                                               double theX, double theY,
+                                               const std::string& theAttribute)
+{
+  if (!theFeature)
+    return;
+  boost::shared_ptr<ModelAPI_Data> aData = theFeature->data();
+  boost::shared_ptr<GeomDataAPI_Point2D> aPoint =
+        boost::dynamic_pointer_cast<GeomDataAPI_Point2D>(aData->attribute(theAttribute));
+  aPoint->setValue(theX, theY);
+}
diff --git a/src/PartSet/PartSet_FeaturePrs.h b/src/PartSet/PartSet_FeaturePrs.h
new file mode 100644 (file)
index 0000000..0a285f5
--- /dev/null
@@ -0,0 +1,102 @@
+// File:        PartSet_FeaturePrs.h
+// Created:     04 Jun 2014
+// Author:      Natalia ERMOLAEVA
+
+#ifndef PartSet_FeaturePrs_H
+#define PartSet_FeaturePrs_H
+
+#include "PartSet.h"
+
+#include "PartSet_Constants.h"
+
+class GeomDataAPI_Point2D;
+
+/*!
+ \class PartSet_FeaturePrs
+ * \brief The abstract class to define the specific feature manipulation. It is created for
+ * the feature create operation to move out the feature properties set and use one operation
+ * for any type of features.
+*/
+class PARTSET_EXPORT PartSet_FeaturePrs
+{
+public:
+  /// Constructor
+  /// \param theSketch the sketch feature
+  PartSet_FeaturePrs(FeaturePtr theSketch);
+  /// Destructor
+  virtual ~PartSet_FeaturePrs();
+
+  /// Initializes some fields of feature accorging to the source feature
+  /// Saves the fiature as the presentation internal feature
+  /// \param theFeature the presentation feature
+  /// \param theSourceFeature the feature, which attributes are used to initialize the feature
+  virtual void init(FeaturePtr theFeature, FeaturePtr theSourceFeature);
+
+  /// Returns the operation sketch feature
+  /// \returns the sketch instance
+  FeaturePtr sketch() const;
+
+  /// Sets the point to the feature in an attribute depending on the selection mode
+  /// \param theX the 2D point horizontal coordinate
+  /// \param theY the 2D point vertical coordinate
+  /// \param theMode the selection mode
+  /// \return the new selection mode
+  PartSet_SelectionMode setPoint(double theX, double theY, const PartSet_SelectionMode& theMode);
+
+  /// Creates constrains of the current 
+  /// \param theX the horizontal coordnate of the point
+  /// \param theY the vertical coordnate of the point
+  /// \param theMode the current operation selection mode. The feature attribute depends on the mode
+  void setConstraints(double theX, double theY, const PartSet_SelectionMode& theMode);
+
+  /// Returns the feature attribute name for the selection mode
+  /// \param theMode the current operation selection mode. The feature attribute depends on the mode
+  std::string getAttribute(const PartSet_SelectionMode& theMode) const;
+
+  /// Returns the next selection mode after the attribute
+  /// \param theAttribute the feature attribute name
+  /// \return next attribute selection mode
+  PartSet_SelectionMode getNextMode(const std::string& theAttribute) const;
+
+  /// \brief Save the point to the line.
+  /// \param theFeature the line feature
+  /// \param theX the horizontal coordinate
+  /// \param theY the vertical coordinate
+  /// \param theAttribute the start or end attribute of the line
+  static void setLinePoint(FeaturePtr, double theX, double theY,
+                           const std::string& theAttribute);
+
+protected:
+  /// Returns pointer to the root document.
+  boost::shared_ptr<ModelAPI_Document> document() const;
+
+    /// Returns the operation feature
+  /// \return the feature
+  FeaturePtr feature() const;
+
+  /// Creates a constraint on two points
+  /// \param thePoint1 the first point
+  /// \param thePoint1 the second point
+  void createConstraint(boost::shared_ptr<GeomDataAPI_Point2D> thePoint1,
+                        boost::shared_ptr<GeomDataAPI_Point2D> thePoint2);
+
+  /// \brief Get the line point 2d coordinates.
+  /// \param theFeature the line feature
+  /// \param theAttribute the start or end attribute of the line
+  /// \param theX the horizontal coordinate
+  /// \param theY the vertical coordinate
+  void getLinePoint(FeaturePtr theFeature, const std::string& theAttribute,
+                    double& theX, double& theY);
+  /// Find a point in the line with given coordinates
+  /// \param theFeature the line feature
+  /// \param theX the horizontal point coordinate
+  /// \param theY the vertical point coordinate
+  boost::shared_ptr<GeomDataAPI_Point2D> findLinePoint(FeaturePtr theFeature,
+                                                       double theX, double theY);
+
+private:
+  FeaturePtr mySketch; ///< the sketch of the feature
+  FeaturePtr myFeature; ///< the feature
+};
+
+#endif
index fbe2485324858d246d998b2db7a6a749967377cb..1f3505ee771821645ce24f312f47364718f4e481 100644 (file)
@@ -11,6 +11,8 @@
 #include <Events_Loop.h>
 #include <Model_Events.h>
 
+#include <SketchPlugin_Sketch.h>
+
 #ifdef _DEBUG
 #include <QDebug>
 #endif
@@ -39,19 +41,18 @@ void PartSet_Listener::processEvent(const Events_Message* theMessage)
   {
     const Model_FeatureUpdatedMessage* aUpdMsg = dynamic_cast<const Model_FeatureUpdatedMessage*>
                                                                                     (theMessage);
-    std::set<boost::shared_ptr<ModelAPI_Feature> > aFeatures = aUpdMsg->features();
-    std::set<boost::shared_ptr<ModelAPI_Feature> >::const_iterator anIt = aFeatures.begin(),
-                                                                   aLast = aFeatures.end();
+    std::set<FeaturePtr > aFeatures = aUpdMsg->features();
+    std::set<FeaturePtr >::const_iterator anIt = aFeatures.begin(), aLast = aFeatures.end();
     for (; anIt != aLast; anIt++) {
-      boost::shared_ptr<ModelAPI_Feature> aFeature = *anIt;
-      if (myModule->workshop()->displayer()->IsVisible(aFeature) ||
+      FeaturePtr aFeature = *anIt;
+      if (myModule->workshop()->displayer()->isVisible(aFeature) ||
           aType == EVENT_FEATURE_CREATED) {
         myModule->visualizePreview(aFeature, true, false);
         //if (aType == EVENT_FEATURE_CREATED)
           myModule->activateFeature(aFeature, true);
       }
     }
-    myModule->workshop()->displayer()->UpdateViewer();
+    myModule->workshop()->displayer()->updateViewer();
   }
   if (aType == EVENT_FEATURE_DELETED)
   {
@@ -62,8 +63,8 @@ void PartSet_Listener::processEvent(const Events_Message* theMessage)
     std::set<std::string>::const_iterator anIt = aGroups.begin(), aLast = aGroups.end();
     for (; anIt != aLast; anIt++) {
       std::string aGroup = *anIt;
-      if (aGroup.compare("Sketch") == 0) { // Update only Sketch group
-        myModule->workshop()->displayer()->EraseDeletedFeatures();
+      if (aGroup.compare(SKETCH_KIND) == 0) { // Update only Sketch group
+        myModule->workshop()->displayer()->eraseDeletedFeatures();
         myModule->updateCurrentPreview(aGroup);
       }
     }
index 99cab29e5c2a2be1f1c3660db3f475f92ec16c61..83b8fbe74ab40321632a651a6168b242d1f559c5 100644 (file)
@@ -1,11 +1,13 @@
 #include <PartSet_Module.h>
 #include <PartSet_OperationSketch.h>
-#include <PartSet_OperationSketchLine.h>
+#include <PartSet_OperationCreateFeature.h>
 #include <PartSet_OperationEditLine.h>
+#include <PartSet_OperationConstraint.h>
 #include <ModuleBase_Operation.h>
 #include <ModuleBase_OperationDescription.h>
 #include <PartSet_Listener.h>
 #include <PartSet_TestOCC.h>
+#include <PartSet_Presentation.h>
 
 #include <ModuleBase_Operation.h>
 #include <ModelAPI_Object.h>
@@ -33,6 +35,7 @@
 #include <GeomAPI_Shape.h>
 
 #include <AIS_ListOfInteractive.hxx>
+#include <AIS_DimensionSelectionMode.hxx>
 
 #include <QObject>
 #include <QMouseEvent>
@@ -167,8 +170,8 @@ void PartSet_Module::onMousePressed(QMouseEvent* theEvent)
   if (aPreviewOp)
   {
     XGUI_Displayer* aDisplayer = myWorkshop->displayer();
-    std::list<XGUI_ViewerPrs> aSelected = aDisplayer->GetSelected();
-    std::list<XGUI_ViewerPrs> aHighlighted = aDisplayer->GetHighlighted();
+    std::list<XGUI_ViewerPrs> aSelected = aDisplayer->getSelected();
+    std::list<XGUI_ViewerPrs> aHighlighted = aDisplayer->getHighlighted();
 
     aPreviewOp->mousePressed(theEvent, myWorkshop->viewer()->activeView(), aSelected, aHighlighted);
   }
@@ -181,8 +184,8 @@ void PartSet_Module::onMouseReleased(QMouseEvent* theEvent)
   if (aPreviewOp)
   {
     XGUI_Displayer* aDisplayer = myWorkshop->displayer();
-    std::list<XGUI_ViewerPrs> aSelected = aDisplayer->GetSelected();
-    std::list<XGUI_ViewerPrs> aHighlighted = aDisplayer->GetHighlighted();
+    std::list<XGUI_ViewerPrs> aSelected = aDisplayer->getSelected();
+    std::list<XGUI_ViewerPrs> aHighlighted = aDisplayer->getHighlighted();
 
     aPreviewOp->mouseReleased(theEvent, myWorkshop->viewer()->activeView(), aSelected, aHighlighted);
   }
@@ -218,7 +221,7 @@ void PartSet_Module::onFitAllView()
   myWorkshop->viewer()->fitAll();
 }
 
-void PartSet_Module::onLaunchOperation(std::string theName, boost::shared_ptr<ModelAPI_Feature> theFeature)
+void PartSet_Module::onLaunchOperation(std::string theName, FeaturePtr theFeature)
 {
   ModuleBase_Operation* anOperation = createOperation(theName.c_str());
   PartSet_OperationSketchBase* aPreviewOp = dynamic_cast<PartSet_OperationSketchBase*>(anOperation);
@@ -226,9 +229,11 @@ void PartSet_Module::onLaunchOperation(std::string theName, boost::shared_ptr<Mo
   {
     XGUI_Displayer* aDisplayer = myWorkshop->displayer();
       // refill the features list with avoiding of the features, obtained only by vertex shape (TODO)
-    std::list<XGUI_ViewerPrs> aSelected = aDisplayer->GetSelected(TopAbs_VERTEX);
-    std::list<XGUI_ViewerPrs> aHighlighted = aDisplayer->GetHighlighted(TopAbs_VERTEX);
+    std::list<XGUI_ViewerPrs> aSelected = aDisplayer->getSelected(TopAbs_VERTEX);
+    std::list<XGUI_ViewerPrs> aHighlighted = aDisplayer->getHighlighted(TopAbs_VERTEX);
     aPreviewOp->init(theFeature, aSelected, aHighlighted);
+  } else {
+    anOperation->setEditingFeature(theFeature);
   }
   sendOperation(anOperation);
   myWorkshop->actionsMgr()->updateCheckState();
@@ -245,54 +250,52 @@ void PartSet_Module::onStopSelection(const std::list<XGUI_ViewerPrs>& theFeature
   XGUI_Displayer* aDisplayer = myWorkshop->displayer();
   if (!isStop) {
     std::list<XGUI_ViewerPrs>::const_iterator anIt = theFeatures.begin(), aLast = theFeatures.end();
-    boost::shared_ptr<ModelAPI_Feature> aFeature;
+    FeaturePtr aFeature;
     for (; anIt != aLast; anIt++) {
       activateFeature((*anIt).feature(), false);
     }
   }
-  aDisplayer->StopSelection(theFeatures, isStop, false);
+  aDisplayer->stopSelection(theFeatures, isStop, false);
 
   XGUI_ViewerProxy* aViewer = myWorkshop->viewer();
   aViewer->enableSelection(!isStop);
 
-  aDisplayer->UpdateViewer();
+  aDisplayer->updateViewer();
 }
 
 void PartSet_Module::onSetSelection(const std::list<XGUI_ViewerPrs>& theFeatures)
 {
   XGUI_Displayer* aDisplayer = myWorkshop->displayer();
-  aDisplayer->SetSelected(theFeatures, false);
-  aDisplayer->UpdateViewer();
+  aDisplayer->setSelected(theFeatures, false);
+  aDisplayer->updateViewer();
 }
 
 void PartSet_Module::onCloseLocalContext()
 {
   XGUI_Displayer* aDisplayer = myWorkshop->displayer();
-  aDisplayer->CloseLocalContexts();
+  aDisplayer->closeLocalContexts();
 }
 
-void PartSet_Module::onFeatureConstructed(boost::shared_ptr<ModelAPI_Feature> theFeature,
-                                          int theMode)
+void PartSet_Module::onFeatureConstructed(FeaturePtr theFeature, int theMode)
 {
   bool isDisplay = theMode != PartSet_OperationSketchBase::FM_Hide;
   visualizePreview(theFeature, isDisplay, false);
   if (!isDisplay) {
     ModuleBase_Operation* aCurOperation = myWorkshop->operationMgr()->currentOperation();
-    boost::shared_ptr<ModelAPI_Feature> aSketch;
+    FeaturePtr aSketch;
     PartSet_OperationSketchBase* aPrevOp = dynamic_cast<PartSet_OperationSketchBase*>(aCurOperation);
     if (aPrevOp) {
-      std::map<boost::shared_ptr<ModelAPI_Feature>, boost::shared_ptr<GeomAPI_Shape> >
-                                                                         aList = aPrevOp->subPreview();
+      std::map<FeaturePtr, boost::shared_ptr<GeomAPI_Shape> > aList = aPrevOp->subPreview();
       XGUI_Displayer* aDisplayer = myWorkshop->displayer();
       std::list<int> aModes = aPrevOp->getSelectionModes(aPrevOp->feature());
 
-      std::map<boost::shared_ptr<ModelAPI_Feature>, boost::shared_ptr<GeomAPI_Shape> >::const_iterator
+      std::map<FeaturePtr, boost::shared_ptr<GeomAPI_Shape> >::const_iterator
                                                              anIt = aList.begin(), aLast = aList.end();
       for (; anIt != aLast; anIt++) {
-        boost::shared_ptr<ModelAPI_Feature> aFeature = (*anIt).first;
+        FeaturePtr aFeature = (*anIt).first;
         visualizePreview(aFeature, false, false);
       }
-      aDisplayer->UpdateViewer();
+      aDisplayer->updateViewer();
     }
   }
 
@@ -306,7 +309,7 @@ ModuleBase_Operation* PartSet_Module::createOperation(const std::string& theCmdI
   // get operation xml description
   std::string aStdCmdId = theCmdId;
   if (aStdCmdId == PartSet_OperationEditLine::Type())
-    aStdCmdId = PartSet_OperationSketchLine::Type();
+    aStdCmdId = SKETCH_LINE_KIND;
   std::string aPluginFileName = featureFile(aStdCmdId);
   Config_WidgetReader aWdgReader = Config_WidgetReader(aPluginFileName);
   aWdgReader.readAll();
@@ -314,23 +317,25 @@ ModuleBase_Operation* PartSet_Module::createOperation(const std::string& theCmdI
   std::string aDescription = aWdgReader.featureDescription(aStdCmdId);
 
   // create the operation
-  ModuleBase_Operation* anOperation;
+  ModuleBase_Operation* anOperation = 0;
   if (theCmdId == PartSet_OperationSketch::Type()) {
     anOperation = new PartSet_OperationSketch(theCmdId.c_str(), this);
   }
-  else if(theCmdId == PartSet_OperationSketchLine::Type() ||
-          theCmdId == PartSet_OperationEditLine::Type()) {
+  else {
     ModuleBase_Operation* aCurOperation = myWorkshop->operationMgr()->currentOperation();
-    boost::shared_ptr<ModelAPI_Feature> aSketch;
+    FeaturePtr aSketch;
     PartSet_OperationSketchBase* aPrevOp = dynamic_cast<PartSet_OperationSketchBase*>(aCurOperation);
     if (aPrevOp)
       aSketch = aPrevOp->sketch();
-    if (theCmdId == PartSet_OperationSketchLine::Type())
-      anOperation = new PartSet_OperationSketchLine(theCmdId.c_str(), this, aSketch);
-    else
+    if (theCmdId == SKETCH_LINE_KIND)
+      anOperation = new PartSet_OperationCreateFeature(theCmdId.c_str(), this, aSketch);
+    else if (theCmdId == PartSet_OperationEditLine::Type())
       anOperation = new PartSet_OperationEditLine(theCmdId.c_str(), this, aSketch);
+    else if (theCmdId == PartSet_OperationConstraint::Type())
+      anOperation = new PartSet_OperationConstraint(theCmdId.c_str(), this, aSketch);
   }
-  else {
+
+  if (!anOperation) {
     anOperation = new ModuleBase_Operation(theCmdId.c_str(), this);
   }
   anOperation->getDescription()->setXmlRepresentation(QString::fromStdString(aXmlCfg));
@@ -339,10 +344,10 @@ ModuleBase_Operation* PartSet_Module::createOperation(const std::string& theCmdI
   // connect the operation
   PartSet_OperationSketchBase* aPreviewOp = dynamic_cast<PartSet_OperationSketchBase*>(anOperation);
   if (aPreviewOp) {
-    connect(aPreviewOp, SIGNAL(featureConstructed(boost::shared_ptr<ModelAPI_Feature>, int)),
-            this, SLOT(onFeatureConstructed(boost::shared_ptr<ModelAPI_Feature>, int)));
-    connect(aPreviewOp, SIGNAL(launchOperation(std::string, boost::shared_ptr<ModelAPI_Feature>)),
-            this, SLOT(onLaunchOperation(std::string, boost::shared_ptr<ModelAPI_Feature>)));
+    connect(aPreviewOp, SIGNAL(featureConstructed(FeaturePtr, int)),
+            this, SLOT(onFeatureConstructed(FeaturePtr, int)));
+    connect(aPreviewOp, SIGNAL(launchOperation(std::string, FeaturePtr)),
+            this, SLOT(onLaunchOperation(std::string, FeaturePtr)));
     connect(aPreviewOp, SIGNAL(multiSelectionEnabled(bool)),
             this, SLOT(onMultiSelectionEnabled(bool)));
 
@@ -377,7 +382,7 @@ void PartSet_Module::sendOperation(ModuleBase_Operation* theOperation)
   Events_Loop::loop()->send(aMessage);
 }
 
-void PartSet_Module::visualizePreview(boost::shared_ptr<ModelAPI_Feature> theFeature, bool isDisplay,
+void PartSet_Module::visualizePreview(FeaturePtr theFeature, bool isDisplay,
                                       const bool isUpdateViewer)
 {
   ModuleBase_Operation* anOperation = myWorkshop->operationMgr()->currentOperation();
@@ -391,24 +396,31 @@ void PartSet_Module::visualizePreview(boost::shared_ptr<ModelAPI_Feature> theFea
   XGUI_Displayer* aDisplayer = myWorkshop->displayer();
   if (isDisplay) {
     boost::shared_ptr<GeomAPI_Shape> aPreview = aPreviewOp->preview(theFeature);
-    aDisplayer->Redisplay(theFeature,
-                          aPreview ? aPreview->impl<TopoDS_Shape>() : TopoDS_Shape(), false);
+    Handle(AIS_InteractiveObject) anAIS = PartSet_Presentation::createPresentation(
+                           theFeature, aPreviewOp->sketch(),
+                           aPreview ? aPreview->impl<TopoDS_Shape>() : TopoDS_Shape(),
+                           aDisplayer->getAISObject(theFeature));
+
+    int aSelectionMode = -1;
+    if (theFeature->getKind() == SKETCH_CONSTRAINT_LENGTH_KIND) {
+      aSelectionMode = AIS_DSM_Text;
+    }
+    aDisplayer->redisplay(theFeature, anAIS, aSelectionMode, false);
   }
   else
-    aDisplayer->Erase(theFeature, false);
+    aDisplayer->erase(theFeature, false);
 
   if (isUpdateViewer)
-    aDisplayer->UpdateViewer();
+    aDisplayer->updateViewer();
 }
 
-void PartSet_Module::activateFeature(boost::shared_ptr<ModelAPI_Feature> theFeature,
-                                     const bool isUpdateViewer)
+void PartSet_Module::activateFeature(FeaturePtr theFeature, const bool isUpdateViewer)
 {
   ModuleBase_Operation* anOperation = myWorkshop->operationMgr()->currentOperation();
   PartSet_OperationSketchBase* aPreviewOp = dynamic_cast<PartSet_OperationSketchBase*>(anOperation);
   if (aPreviewOp) {
     XGUI_Displayer* aDisplayer = myWorkshop->displayer();
-    aDisplayer->ActivateInLocalContext(theFeature, aPreviewOp->getSelectionModes(theFeature),
+    aDisplayer->activateInLocalContext(theFeature, aPreviewOp->getSelectionModes(theFeature),
                                        isUpdateViewer);
   }
 }
@@ -423,25 +435,28 @@ void PartSet_Module::updateCurrentPreview(const std::string& theCmdId)
   if (!aPreviewOp)
     return;
 
-  boost::shared_ptr<ModelAPI_Feature> aFeature = aPreviewOp->feature();
+  FeaturePtr aFeature = aPreviewOp->feature();
   if (!aFeature || aFeature->getKind() != theCmdId)
     return;
 
-  std::map<boost::shared_ptr<ModelAPI_Feature>, boost::shared_ptr<GeomAPI_Shape> >
-                                                                     aList = aPreviewOp->subPreview();
+  std::map<FeaturePtr, boost::shared_ptr<GeomAPI_Shape> > aList = aPreviewOp->subPreview();
   XGUI_Displayer* aDisplayer = myWorkshop->displayer();
   std::list<int> aModes = aPreviewOp->getSelectionModes(aPreviewOp->feature());
 
-  std::map<boost::shared_ptr<ModelAPI_Feature>, boost::shared_ptr<GeomAPI_Shape> >::const_iterator
+  std::map<FeaturePtr, boost::shared_ptr<GeomAPI_Shape> >::const_iterator
                                                          anIt = aList.begin(), aLast = aList.end();
   for (; anIt != aLast; anIt++) {
-    boost::shared_ptr<ModelAPI_Feature> aFeature = (*anIt).first;
+    FeaturePtr aFeature = (*anIt).first;
     boost::shared_ptr<GeomAPI_Shape> aPreview = (*anIt).second;
-    aDisplayer->Redisplay(aFeature,
-                          aPreview ? aPreview->impl<TopoDS_Shape>() : TopoDS_Shape(), false);
-    aDisplayer->ActivateInLocalContext(aFeature, aModes, false);
+    Handle(AIS_InteractiveObject) anAIS = PartSet_Presentation::createPresentation(
+                           aFeature, aPreviewOp->sketch(),
+                           aPreview ? aPreview->impl<TopoDS_Shape>() : TopoDS_Shape(),
+                           aDisplayer->getAISObject(aFeature));
+    if (!anAIS.IsNull())
+      aDisplayer->redisplay(aFeature, anAIS, -1, false);
+    aDisplayer->activateInLocalContext(aFeature, aModes, false);
   }
-  aDisplayer->UpdateViewer();
+  aDisplayer->updateViewer();
 }
 
 void PartSet_Module::editFeature(FeaturePtr theFeature)
@@ -449,7 +464,7 @@ void PartSet_Module::editFeature(FeaturePtr theFeature)
   if (!theFeature)
     return;
 
-  if (theFeature->getKind() == "Sketch") {
+//  if (theFeature->getKind() == SKETCH_KIND) {
     FeaturePtr aFeature = theFeature;
     if (XGUI_Tools::isModelObject(aFeature)) {
       ObjectPtr aObject = boost::dynamic_pointer_cast<ModelAPI_Object>(aFeature);
@@ -460,5 +475,5 @@ void PartSet_Module::editFeature(FeaturePtr theFeature)
       onLaunchOperation(aFeature->getKind(), aFeature);
       updateCurrentPreview(aFeature->getKind());
     }
-  }
+//  }
 }
index d92604bbb89410135ec12244364edb5464ac4779..f906f939ae34615add931df859534cde4850b74d 100644 (file)
@@ -44,13 +44,13 @@ public:
   /// \param theFeature the feature instance to be displayed
   /// \param isDisplay the state whether the presentation should be displayed or erased
   /// \param isUpdateViewer the flag whether the viewer should be updated
-  void visualizePreview(boost::shared_ptr<ModelAPI_Feature> theFeature, bool isDisplay,
+  void visualizePreview(FeaturePtr theFeature, bool isDisplay,
                         const bool isUpdateViewer = true);
 
   /// Activates the feature in the displayer
   /// \param theFeature the feature instance to be displayed
   /// \param isUpdateViewer the flag whether the viewer should be updated
-  void activateFeature(boost::shared_ptr<ModelAPI_Feature> theFeature,
+  void activateFeature(FeaturePtr theFeature,
                        const bool isUpdateViewer);
 
   /// Updates current operation preview, if it has it.
@@ -92,7 +92,7 @@ public slots:
   /// SLOT, to fit all current viewer
   void onFitAllView();
 
-  void onLaunchOperation(std::string theName, boost::shared_ptr<ModelAPI_Feature> theFeature);
+  void onLaunchOperation(std::string theName, FeaturePtr theFeature);
 
   /// SLOT, to switch on/off the multi selection in the viewer
   /// \param theEnabled the enabled state
@@ -113,7 +113,7 @@ public slots:
   /// SLOT, to visualize the feature in another local context mode
   /// \param theFeature the feature to be put in another local context mode
   /// \param theMode the mode appeared on the feature
-  void onFeatureConstructed(boost::shared_ptr<ModelAPI_Feature> theFeature,
+  void onFeatureConstructed(FeaturePtr theFeature,
                             int theMode);
 protected:
   /// Creates a new operation
diff --git a/src/PartSet/PartSet_OperationConstraint.cpp b/src/PartSet/PartSet_OperationConstraint.cpp
new file mode 100644 (file)
index 0000000..6c65c0e
--- /dev/null
@@ -0,0 +1,274 @@
+// File:        PartSet_OperationConstraint.h
+// Created:     20 Apr 2014
+// Author:      Natalia ERMOLAEVA
+
+#include <PartSet_OperationConstraint.h>
+
+#include <PartSet_Tools.h>
+#include <PartSet_OperationSketch.h>
+
+#include <SketchPlugin_Feature.h>
+#include <SketchPlugin_Sketch.h>
+
+#include <GeomDataAPI_Point2D.h>
+
+#include <ModuleBase_OperationDescription.h>
+
+#include <ModelAPI_Data.h>
+#include <ModelAPI_Document.h>
+#include <ModelAPI_AttributeRefAttr.h>
+#include <ModelAPI_AttributeRefList.h>
+#include <ModelAPI_AttributeDouble.h>
+
+#include <SketchPlugin_Constraint.h>
+
+#include <Geom_Line.hxx>
+#include <gp_Lin.hxx>
+
+#include <XGUI_ViewerPrs.h>
+#include <XGUI_Constants.h>
+
+#include <SketchPlugin_Line.h>
+
+#include <V3d_View.hxx>
+#include <TopoDS_Vertex.hxx>
+#include <TopoDS.hxx>
+#include <BRep_Tool.hxx>
+
+#ifdef _DEBUG
+#include <QDebug>
+#endif
+
+#include <QMouseEvent>
+
+using namespace std;
+
+PartSet_OperationConstraint::PartSet_OperationConstraint(const QString& theId,
+                                                 QObject* theParent,
+                                              FeaturePtr theFeature)
+: PartSet_OperationSketchBase(theId, theParent), mySketch(theFeature)
+{
+}
+
+PartSet_OperationConstraint::~PartSet_OperationConstraint()
+{
+}
+
+bool PartSet_OperationConstraint::isGranted(ModuleBase_IOperation* theOperation) const
+{
+  return theOperation->getDescription()->operationId().toStdString() == PartSet_OperationSketch::Type();
+}
+
+void PartSet_OperationConstraint::init(FeaturePtr theFeature,
+                                       const std::list<XGUI_ViewerPrs>& /*theSelected*/,
+                                       const std::list<XGUI_ViewerPrs>& /*theHighlighted*/)
+{
+  //if (!theFeature || theFeature->getKind() != SKETCH_LINE_KIND)
+  //  return;
+  // use the last point of the previous feature as the first of the new one
+  //boost::shared_ptr<ModelAPI_Data> aData = theFeature->data();
+  //myInitPoint = boost::dynamic_pointer_cast<GeomDataAPI_Point2D>(aData->attribute(LINE_ATTR_END));
+}
+
+FeaturePtr PartSet_OperationConstraint::sketch() const
+{
+  return mySketch;
+}
+
+void PartSet_OperationConstraint::mouseReleased(QMouseEvent* theEvent, Handle(V3d_View) theView,
+                                                const std::list<XGUI_ViewerPrs>& theSelected,
+                                                const std::list<XGUI_ViewerPrs>& /*theHighlighted*/)
+{
+  /*if (myPointSelectionMode == SM_DonePoint)
+  {
+    // if the point creation is finished, the next mouse release should commit the modification
+    // the next release can happens by double click in the viewer
+    commit();
+    restartOperation(PartSet_OperationConstraint::Type(), feature());
+    return;
+  }
+
+  double aX, anY;
+
+  bool isFoundPoint = false;
+  gp_Pnt aPoint = PartSet_Tools::convertClickToPoint(theEvent->pos(), theView);
+*/
+  if (theSelected.empty()) {
+    //PartSet_Tools::convertTo2D(aPoint, sketch(), theView, aX, anY);
+    //isFoundPoint = true;
+  }
+  else {
+    XGUI_ViewerPrs aPrs = theSelected.front();
+    FeaturePtr aFeature = aPrs.feature();
+
+    setFeature(aFeature);
+    setValue(120);
+    flushUpdated();
+
+    /*const TopoDS_Shape& aShape = aPrs.shape();
+    if (!aShape.IsNull()) // the point is selected
+    {
+      if (aShape.ShapeType() == TopAbs_VERTEX) {
+        const TopoDS_Vertex& aVertex = TopoDS::Vertex(aShape);
+        if (!aVertex.IsNull()) {
+          aPoint = BRep_Tool::Pnt(aVertex);
+          PartSet_Tools::convertTo2D(aPoint, sketch(), theView, aX, anY);
+          isFoundPoint = true;
+
+          setConstraints(aX, anY);
+        }
+      }
+      else if (aShape.ShapeType() == TopAbs_EDGE) // the line is selected
+      {
+        FeaturePtr aFeature = aPrs.feature();
+        if (aFeature) {
+          double X0, X1, X2, X3;
+          double Y0, Y1, Y2, Y3;
+          getLinePoint(aFeature, LINE_ATTR_START, X2, Y2);
+          getLinePoint(aFeature, LINE_ATTR_END, X3, Y3);
+          PartSet_Tools::convertTo2D(aPoint, sketch(), theView, X1, Y1);
+
+          switch (myPointSelectionMode) {
+            case SM_FirstPoint:
+              PartSet_Tools::projectPointOnLine(X2, Y2, X3, Y3, X1, Y1, aX, anY);
+            break;
+            case SM_SecondPoint: {
+              getLinePoint(feature(), LINE_ATTR_START, X0, Y0);
+              PartSet_Tools::intersectLines(X0, Y0, X1, Y1, X2, Y2, X3, Y3, aX, anY);
+            }
+            break;
+            default:
+            break;
+          }
+          isFoundPoint = true;
+        }
+      }
+    }*/
+  }
+
+  /*switch (myPointSelectionMode)
+  {
+    case SM_FirstPoint: {
+      setLinePoint(feature(), aX, anY, LINE_ATTR_START);
+      setLinePoint(feature(), aX, anY, LINE_ATTR_END);
+      flushUpdated();
+
+      //setPointSelectionMode(SM_SecondPoint);
+    }
+    break;
+    case SM_SecondPoint: {
+      setLinePoint(feature(), aX, anY, LINE_ATTR_END);
+      flushUpdated();
+
+      //setPointSelectionMode(SM_DonePoint);
+   }
+    break;
+    default:
+      break;
+  }*/
+}
+
+void PartSet_OperationConstraint::mouseMoved(QMouseEvent* theEvent, Handle(V3d_View) theView)
+{
+/*  switch (myPointSelectionMode)
+  {
+    case SM_FirstPoint: {
+      double aX, anY;
+      gp_Pnt aPoint = PartSet_Tools::convertClickToPoint(theEvent->pos(), theView);
+      PartSet_Tools::convertTo2D(aPoint, sketch(), theView, aX, anY);
+      setLinePoint(feature(), aX, anY, LINE_ATTR_START);
+      setLinePoint(feature(), aX, anY, LINE_ATTR_END);
+      flushUpdated();
+      emit focusActivated(LINE_ATTR_START);
+    }
+    break;
+    case SM_SecondPoint:
+    {
+      gp_Pnt aPoint = PartSet_Tools::convertClickToPoint(theEvent->pos(), theView);
+      setLinePoint(aPoint, theView, LINE_ATTR_END);
+      flushUpdated();
+      emit focusActivated(LINE_ATTR_END);
+    }
+    break;
+    case SM_DonePoint:
+    {
+      commit();
+      restartOperation(PartSet_OperationConstraint::Type(), feature());
+    }
+    default:
+      break;
+  }*/
+}
+
+void PartSet_OperationConstraint::startOperation()
+{
+  PartSet_OperationSketchBase::startOperation();
+  //setPointSelectionMode(!myInitPoint ? SM_FirstPoint : SM_SecondPoint);
+
+  emit multiSelectionEnabled(false);
+}
+
+void PartSet_OperationConstraint::abortOperation()
+{
+  emit featureConstructed(feature(), FM_Hide);
+  PartSet_OperationSketchBase::abortOperation();
+}
+
+void PartSet_OperationConstraint::stopOperation()
+{
+  PartSet_OperationSketchBase::stopOperation();
+  emit multiSelectionEnabled(true);
+}
+
+void PartSet_OperationConstraint::afterCommitOperation()
+{
+  PartSet_OperationSketchBase::afterCommitOperation();  
+  emit featureConstructed(feature(), FM_Deactivation);
+}
+
+FeaturePtr PartSet_OperationConstraint::createFeature(const bool theFlushMessage)
+{
+  FeaturePtr aNewFeature = ModuleBase_Operation::createFeature(false);
+  if (sketch()) {
+    boost::shared_ptr<SketchPlugin_Feature> aFeature = 
+                           boost::dynamic_pointer_cast<SketchPlugin_Feature>(sketch());
+
+    aFeature->addSub(aNewFeature);
+  }
+  /*if (myInitPoint) {
+    setLinePoint(aNewFeature, myInitPoint->x(), myInitPoint->y(), LINE_ATTR_START);
+    setLinePoint(aNewFeature, myInitPoint->x(), myInitPoint->y(), LINE_ATTR_END);
+
+    boost::shared_ptr<ModelAPI_Data> aData = aNewFeature->data();
+    boost::shared_ptr<GeomDataAPI_Point2D> aPoint = boost::dynamic_pointer_cast<GeomDataAPI_Point2D>
+                                                                (aData->attribute(LINE_ATTR_START));
+    createConstraint(myInitPoint, aPoint);
+  }*/
+
+  emit featureConstructed(aNewFeature, FM_Activation);
+  if (theFlushMessage)
+    flushCreated();
+  return aNewFeature;
+}
+
+void PartSet_OperationConstraint::setFeature(FeaturePtr theFeature)
+{
+  if (!theFeature || theFeature->getKind() != SKETCH_LINE_KIND)
+    return;
+
+  boost::shared_ptr<ModelAPI_Data> aData = feature()->data();
+
+  boost::shared_ptr<ModelAPI_AttributeRefAttr> anAttr = 
+          boost::dynamic_pointer_cast<ModelAPI_AttributeRefAttr>(aData->attribute(CONSTRAINT_ATTR_ENTITY_A));
+  anAttr->setFeature(theFeature);
+}
+
+void PartSet_OperationConstraint::setValue(const double theValue)
+{
+  boost::shared_ptr<ModelAPI_Data> aData = feature()->data();
+
+  boost::shared_ptr<ModelAPI_AttributeDouble> anAttr = 
+          boost::dynamic_pointer_cast<ModelAPI_AttributeDouble>(aData->attribute(CONSTRAINT_ATTR_VALUE));
+  anAttr->setValue(theValue);
+
+}
diff --git a/src/PartSet/PartSet_OperationConstraint.h b/src/PartSet/PartSet_OperationConstraint.h
new file mode 100644 (file)
index 0000000..678964a
--- /dev/null
@@ -0,0 +1,103 @@
+// File:        PartSet_OperationConstraint.h
+// Created:     20 Apr 2014
+// Author:      Natalia ERMOLAEVA
+
+#ifndef PartSet_OperationConstraint_H
+#define PartSet_OperationConstraint_H
+
+#include "PartSet.h"
+
+#include <PartSet_OperationSketchBase.h>
+
+#include <SketchPlugin_ConstraintLength.h>
+
+#include <QObject>
+
+/*!
+ \class PartSet_OperationConstraint
+ * \brief The operation for the sketch constraint feature creation
+*/
+class PARTSET_EXPORT PartSet_OperationConstraint : public PartSet_OperationSketchBase
+{
+  Q_OBJECT
+
+public:
+  /// Returns the operation type key
+  static std::string Type() { return SKETCH_CONSTRAINT_LENGTH_KIND; }
+
+public:
+  /// Constructor
+  /// \param theId the feature identifier
+  /// \param theParent the operation parent
+  /// \param theFeature the parent feature
+  PartSet_OperationConstraint(const QString& theId, QObject* theParent,
+                              FeaturePtr theSketchFeature);
+  /// Destructor
+  virtual ~PartSet_OperationConstraint();
+
+  /// Returns that this operator can be started above already running one.
+   /// The runned operation should be the sketch feature modified operation
+  /// \param theOperation the previous running operation
+  virtual bool isGranted(ModuleBase_IOperation* theOperation) const;
+
+  /// Initializes some fields accorging to the feature
+  /// \param theSelected the list of selected presentations
+  /// \param theHighlighted the list of highlighted presentations
+  virtual void init(FeaturePtr theFeature,
+                    const std::list<XGUI_ViewerPrs>& theSelected,
+                    const std::list<XGUI_ViewerPrs>& theHighlighted);
+
+  /// Returns the operation sketch feature
+  /// \returns the sketch instance
+  virtual FeaturePtr sketch() const;
+
+  /// Gives the current selected objects to be processed by the operation
+  /// \param theEvent the mouse event
+  /// \param theView a viewer to have the viewer the eye position
+  /// \param theSelected the list of selected presentations
+  /// \param theHighlighted the list of highlighted presentations
+ virtual void mouseReleased(QMouseEvent* theEvent, Handle_V3d_View theView,
+                            const std::list<XGUI_ViewerPrs>& theSelected,
+                            const std::list<XGUI_ViewerPrs>& theHighlighted);
+  /// Gives the current mouse point in the viewer
+  /// \param thePoint a point clicked in the viewer
+  /// \param theEvent the mouse event
+  virtual void mouseMoved(QMouseEvent* theEvent, Handle_V3d_View theView);
+
+protected:
+  /// \brief Virtual method called when operation is started
+  /// Virtual method called when operation started (see start() method for more description)
+  /// After the parent operation body perform, set sketch feature to the created line feature
+  virtual void startOperation();
+
+  /// Virtual method called when operation aborted (see abort() method for more description)
+  /// Before the feature is aborted, it should be hidden from the viewer
+  virtual void abortOperation();
+
+  /// Virtual method called when operation stopped - committed or aborted.
+  /// Restore the multi selection state
+  virtual void stopOperation();
+
+  /// Virtual method called after operation committed (see commit() method for more description)
+  virtual void afterCommitOperation();
+
+  /// Creates an operation new feature
+  /// In addition to the default realization it appends the created line feature to
+  /// the sketch feature
+  /// \param theFlushMessage the flag whether the create message should be flushed
+  /// \returns the created feature
+  virtual FeaturePtr createFeature(const bool theFlushMessage = true);
+
+  /// Set the feature for the constraint
+  /// \param theFeature the line feature
+  void setFeature(FeaturePtr theFeature);
+
+  /// Set the value for the constraint
+  /// \param theValue the constraint value
+  void setValue(const double theValue);
+
+private:
+  FeaturePtr mySketch; ///< the sketch feature
+};
+
+#endif
diff --git a/src/PartSet/PartSet_OperationCreateFeature.cpp b/src/PartSet/PartSet_OperationCreateFeature.cpp
new file mode 100644 (file)
index 0000000..1d90445
--- /dev/null
@@ -0,0 +1,276 @@
+// File:        PartSet_OperationCreateFeature.h
+// Created:     20 Apr 2014
+// Author:      Natalia ERMOLAEVA
+
+#include <PartSet_OperationCreateFeature.h>
+
+#include <PartSet_Tools.h>
+#include <PartSet_OperationSketch.h>
+#include <PartSet_FeaturePrs.h>
+
+#include <SketchPlugin_Feature.h>
+
+#include <ModuleBase_OperationDescription.h>
+
+#include <XGUI_ViewerPrs.h>
+#include <XGUI_Constants.h>
+
+#include <V3d_View.hxx>
+#include <TopoDS_Vertex.hxx>
+#include <TopoDS.hxx>
+#include <BRep_Tool.hxx>
+
+#ifdef _DEBUG
+#include <QDebug>
+#endif
+
+#include <QMouseEvent>
+
+using namespace std;
+
+PartSet_OperationCreateFeature::PartSet_OperationCreateFeature(const QString& theId,
+                                                 QObject* theParent,
+                                              FeaturePtr theFeature)
+: PartSet_OperationSketchBase(theId, theParent),
+  myPointSelectionMode(SM_FirstPoint)
+{
+  myFeaturePrs = new PartSet_FeaturePrs(theFeature);
+}
+
+PartSet_OperationCreateFeature::~PartSet_OperationCreateFeature()
+{
+  delete myFeaturePrs;
+}
+
+bool PartSet_OperationCreateFeature::canBeCommitted() const
+{
+  return myPointSelectionMode == SM_DonePoint;
+}
+
+bool PartSet_OperationCreateFeature::isGranted(ModuleBase_IOperation* theOperation) const
+{
+  return theOperation->getDescription()->operationId().toStdString() == PartSet_OperationSketch::Type();
+}
+
+std::list<int> PartSet_OperationCreateFeature::getSelectionModes(FeaturePtr theFeature) const
+{
+  std::list<int> aModes;
+  if (theFeature != feature())
+    aModes = PartSet_OperationSketchBase::getSelectionModes(theFeature);
+  return aModes;
+}
+
+void PartSet_OperationCreateFeature::init(FeaturePtr theFeature,
+                                       const std::list<XGUI_ViewerPrs>& /*theSelected*/,
+                                       const std::list<XGUI_ViewerPrs>& /*theHighlighted*/)
+{
+  if (!theFeature || theFeature->getKind() != SKETCH_LINE_KIND)
+    return;
+  myInitFeature = theFeature;
+}
+
+FeaturePtr PartSet_OperationCreateFeature::sketch() const
+{
+  return myFeaturePrs->sketch();
+}
+
+void PartSet_OperationCreateFeature::mouseReleased(QMouseEvent* theEvent, Handle(V3d_View) theView,
+                                                const std::list<XGUI_ViewerPrs>& theSelected,
+                                                const std::list<XGUI_ViewerPrs>& /*theHighlighted*/)
+{
+  if (myPointSelectionMode == SM_DonePoint)
+  {
+    // if the point creation is finished, the next mouse release should commit the modification
+    // the next release can happens by double click in the viewer
+    commit();
+    restartOperation(feature()->getKind(), feature());
+    return;
+  }
+
+  double aX, anY;
+
+  bool isFoundPoint = false;
+  gp_Pnt aPoint = PartSet_Tools::convertClickToPoint(theEvent->pos(), theView);
+  if (theSelected.empty()) {
+    PartSet_Tools::convertTo2D(aPoint, sketch(), theView, aX, anY);
+    isFoundPoint = true;
+  }
+  else {
+    XGUI_ViewerPrs aPrs = theSelected.front();
+    const TopoDS_Shape& aShape = aPrs.shape();
+    if (!aShape.IsNull()) // the point is selected
+    {
+      if (aShape.ShapeType() == TopAbs_VERTEX) {
+        const TopoDS_Vertex& aVertex = TopoDS::Vertex(aShape);
+        if (!aVertex.IsNull()) {
+          aPoint = BRep_Tool::Pnt(aVertex);
+          PartSet_Tools::convertTo2D(aPoint, sketch(), theView, aX, anY);
+          isFoundPoint = true;
+
+          myFeaturePrs->setConstraints(aX, anY, myPointSelectionMode);
+        }
+      }
+      /*else if (aShape.ShapeType() == TopAbs_EDGE) // the line is selected
+      {
+        FeaturePtr aFeature = aPrs.feature();
+        if (aFeature) {
+          double X0, X1, X2, X3;
+          double Y0, Y1, Y2, Y3;
+          getLinePoint(aFeature, LINE_ATTR_START, X2, Y2);
+          getLinePoint(aFeature, LINE_ATTR_END, X3, Y3);
+          PartSet_Tools::convertTo2D(aPoint, sketch(), theView, X1, Y1);
+
+          switch (myPointSelectionMode) {
+            case SM_FirstPoint:
+              PartSet_Tools::projectPointOnLine(X2, Y2, X3, Y3, X1, Y1, aX, anY);
+            break;
+            case SM_SecondPoint: {
+              getLinePoint(feature(), LINE_ATTR_START, X0, Y0);
+              PartSet_Tools::intersectLines(X0, Y0, X1, Y1, X2, Y2, X3, Y3, aX, anY);
+            }
+            break;
+            default:
+            break;
+          }
+          isFoundPoint = true;
+        }
+      }*/
+    }
+  }
+
+  switch (myPointSelectionMode)
+  {
+    case SM_FirstPoint:
+    case SM_SecondPoint: {
+      PartSet_SelectionMode aMode = myFeaturePrs->setPoint(aX, anY, myPointSelectionMode);
+      flushUpdated();
+      setPointSelectionMode(aMode);
+    }
+    break;
+    default:
+      break;
+  }
+}
+
+void PartSet_OperationCreateFeature::mouseMoved(QMouseEvent* theEvent, Handle(V3d_View) theView)
+{
+  switch (myPointSelectionMode)
+  {
+    case SM_FirstPoint:
+    case SM_SecondPoint:
+    {
+      double aX, anY;
+      gp_Pnt aPoint = PartSet_Tools::convertClickToPoint(theEvent->pos(), theView);
+      PartSet_Tools::convertTo2D(aPoint, sketch(), theView, aX, anY);
+      myFeaturePrs->setPoint(aX, anY, myPointSelectionMode);
+
+      flushUpdated();
+      emit focusActivated(myFeaturePrs->getAttribute(myPointSelectionMode));
+    }
+    break;
+    case SM_DonePoint:
+    {
+      commit();
+      restartOperation(feature()->getKind(), feature());
+    }
+    default:
+      break;
+  }
+}
+
+void PartSet_OperationCreateFeature::keyReleased(std::string theName, QKeyEvent* theEvent)
+{
+  int aKeyType = theEvent->key();
+  // the second point should be activated by any modification in the property panel
+  if (!theName.empty() /*&& aKeyType == Qt::Key_Return*/)
+  {
+    setPointSelectionMode(myFeaturePrs->getNextMode(theName), false);
+  }
+  keyReleased(theEvent->key());
+}
+
+void PartSet_OperationCreateFeature::keyReleased(const int theKey)
+{
+  switch (theKey) {
+    case Qt::Key_Return: {
+      if (myPointSelectionMode == SM_DonePoint)
+      {
+        commit();
+        // it start a new line creation at a free point
+        restartOperation(feature()->getKind(), FeaturePtr()/*feature()*/);
+      }
+      //else
+      //  abort();
+      //restartOperation(feature()->getKind(), FeaturePtr());
+    }
+    break;
+    case Qt::Key_Escape: {
+      if (myPointSelectionMode == SM_DonePoint)
+      {
+        commit();
+      }
+      else
+      {
+        abort();
+      }
+    }
+    default:
+    break;
+  }
+}
+
+void PartSet_OperationCreateFeature::startOperation()
+{
+  PartSet_OperationSketchBase::startOperation();
+  setPointSelectionMode(!myInitFeature ? SM_FirstPoint : SM_SecondPoint);
+
+  emit multiSelectionEnabled(false);
+}
+
+void PartSet_OperationCreateFeature::abortOperation()
+{
+  emit featureConstructed(feature(), FM_Hide);
+  PartSet_OperationSketchBase::abortOperation();
+}
+
+void PartSet_OperationCreateFeature::stopOperation()
+{
+  PartSet_OperationSketchBase::stopOperation();
+  emit multiSelectionEnabled(true);
+}
+
+void PartSet_OperationCreateFeature::afterCommitOperation()
+{
+  PartSet_OperationSketchBase::afterCommitOperation();  
+  emit featureConstructed(feature(), FM_Deactivation);
+}
+
+FeaturePtr PartSet_OperationCreateFeature::createFeature(const bool theFlushMessage)
+{
+  FeaturePtr aNewFeature = ModuleBase_Operation::createFeature(false);
+  if (sketch()) {
+    boost::shared_ptr<SketchPlugin_Feature> aFeature = 
+                           boost::dynamic_pointer_cast<SketchPlugin_Feature>(sketch());
+
+    aFeature->addSub(aNewFeature);
+  }
+  myFeaturePrs->init(aNewFeature, myInitFeature);
+
+  emit featureConstructed(aNewFeature, FM_Activation);
+  if (theFlushMessage)
+    flushCreated();
+  return aNewFeature;
+}
+
+void PartSet_OperationCreateFeature::setPointSelectionMode(const PartSet_SelectionMode& theMode,
+                                                           const bool isToEmitSignal)
+{
+  myPointSelectionMode = theMode;
+  if (isToEmitSignal) {
+    std::string aName = myFeaturePrs->getAttribute(theMode);
+    if (aName.empty() && theMode == SM_DonePoint) {
+      aName = XGUI::PROP_PANEL_OK;
+    }
+    emit focusActivated(aName);
+  }
+}
diff --git a/src/PartSet/PartSet_OperationCreateFeature.h b/src/PartSet/PartSet_OperationCreateFeature.h
new file mode 100644 (file)
index 0000000..e53bf9b
--- /dev/null
@@ -0,0 +1,122 @@
+// File:        PartSet_OperationCreateFeature.h
+// Created:     20 Apr 2014
+// Author:      Natalia ERMOLAEVA
+
+#ifndef PartSet_OperationCreateFeature_H
+#define PartSet_OperationCreateFeature_H
+
+#include "PartSet.h"
+
+#include <PartSet_OperationSketchBase.h>
+#include <PartSet_Constants.h>
+
+#include <SketchPlugin_Line.h>
+
+#include <QObject>
+
+class PartSet_FeaturePrs;
+class GeomDataAPI_Point2D;
+class QMouseEvent;
+class QKeyEvent;
+
+/*!
+ \class PartSet_OperationCreateFeature
+ * \brief The operation for the sketch feature creation
+*/
+class PARTSET_EXPORT PartSet_OperationCreateFeature : public PartSet_OperationSketchBase
+{
+  Q_OBJECT
+
+public:
+
+public:
+  /// Constructor
+  /// \param theId the feature identifier
+  /// \param theParent the operation parent
+  /// \param theSketch the parent feature
+  PartSet_OperationCreateFeature(const QString& theId, QObject* theParent,
+                                 FeaturePtr theSketch);
+  /// Destructor
+  virtual ~PartSet_OperationCreateFeature();
+
+  /// Verifies whether this operator can be commited.
+  /// \return Returns TRUE if current operation can be committed, e.g. all parameters are filled
+  virtual bool canBeCommitted() const;
+
+  /// Returns that this operator can be started above already running one.
+   /// The runned operation should be the sketch feature modified operation
+  /// \param theOperation the previous running operation
+  virtual bool isGranted(ModuleBase_IOperation* theOperation) const;
+
+  /// Returns the operation local selection mode
+  /// \param theFeature the feature object to get the selection mode
+  /// \return the selection mode
+  virtual std::list<int> getSelectionModes(FeaturePtr theFeature) const;
+
+  /// Initializes some fields accorging to the feature
+  /// \param theSelected the list of selected presentations
+  /// \param theHighlighted the list of highlighted presentations
+  virtual void init(FeaturePtr theFeature,
+                    const std::list<XGUI_ViewerPrs>& theSelected,
+                    const std::list<XGUI_ViewerPrs>& theHighlighted);
+
+  /// Returns the operation sketch feature
+  /// \returns the sketch instance
+  virtual FeaturePtr sketch() const;
+
+  /// Gives the current selected objects to be processed by the operation
+  /// \param theEvent the mouse event
+  /// \param theView a viewer to have the viewer the eye position
+  /// \param theSelected the list of selected presentations
+  /// \param theHighlighted the list of highlighted presentations
+ virtual void mouseReleased(QMouseEvent* theEvent, Handle_V3d_View theView,
+                            const std::list<XGUI_ViewerPrs>& theSelected,
+                            const std::list<XGUI_ViewerPrs>& theHighlighted);
+  /// Gives the current mouse point in the viewer
+  /// \param thePoint a point clicked in the viewer
+  /// \param theEvent the mouse event
+  virtual void mouseMoved(QMouseEvent* theEvent, Handle_V3d_View theView);
+  /// Processes the key pressed in the view
+  /// \param theKey a key value
+  virtual void keyReleased(const int theKey);
+
+  virtual void keyReleased(std::string theName, QKeyEvent* theEvent);
+
+protected:
+  /// \brief Virtual method called when operation is started
+  /// Virtual method called when operation started (see start() method for more description)
+  /// After the parent operation body perform, set sketch feature to the created line feature
+  virtual void startOperation();
+
+  /// Virtual method called when operation aborted (see abort() method for more description)
+  /// Before the feature is aborted, it should be hidden from the viewer
+  virtual void abortOperation();
+
+  /// Virtual method called when operation stopped - committed or aborted.
+  /// Restore the multi selection state
+  virtual void stopOperation();
+
+  /// Virtual method called after operation committed (see commit() method for more description)
+  virtual void afterCommitOperation();
+
+  /// Creates an operation new feature
+  /// In addition to the default realization it appends the created line feature to
+  /// the sketch feature
+  /// \param theFlushMessage the flag whether the create message should be flushed
+  /// \returns the created feature
+  virtual FeaturePtr createFeature(const bool theFlushMessage = true);
+
+protected:
+  ///< Set the point selection mode. Emit signal about focus change if necessary.
+  /// \param theMode a new selection mode
+  /// \param isToEmitSignal the neccessity to emit signal
+  void setPointSelectionMode(const PartSet_SelectionMode& theMode,
+                             const bool isToEmitSignal = true);
+
+private:
+  PartSet_FeaturePrs* myFeaturePrs; ///< the feature presentation
+  FeaturePtr myInitFeature; ///< the initial feature
+  PartSet_SelectionMode myPointSelectionMode; ///< point selection mode
+};
+
+#endif
index 2edee70af2cfbcde14f496eaccc9b242869fbe6d..af46da90da3ba3b0a94e8e9d256cb6594f9ed6a0 100644 (file)
@@ -34,7 +34,7 @@ using namespace std;
 
 PartSet_OperationEditLine::PartSet_OperationEditLine(const QString& theId,
                                                  QObject* theParent,
-                                              boost::shared_ptr<ModelAPI_Feature> theFeature)
+                                              FeaturePtr theFeature)
 : PartSet_OperationSketchBase(theId, theParent), mySketch(theFeature), myIsBlockedSelection(false)
 {
 }
@@ -48,12 +48,12 @@ bool PartSet_OperationEditLine::isGranted(ModuleBase_IOperation* theOperation) c
   return theOperation->getDescription()->operationId().toStdString() == PartSet_OperationSketch::Type();
 }
 
-std::list<int> PartSet_OperationEditLine::getSelectionModes(boost::shared_ptr<ModelAPI_Feature> theFeature) const
+std::list<int> PartSet_OperationEditLine::getSelectionModes(FeaturePtr theFeature) const
 {
   return PartSet_OperationSketchBase::getSelectionModes(theFeature);
 }
 
-void PartSet_OperationEditLine::init(boost::shared_ptr<ModelAPI_Feature> theFeature,
+void PartSet_OperationEditLine::init(FeaturePtr theFeature,
                                      const std::list<XGUI_ViewerPrs>& theSelected,
                                      const std::list<XGUI_ViewerPrs>& theHighlighted)
 {
@@ -78,7 +78,7 @@ void PartSet_OperationEditLine::init(boost::shared_ptr<ModelAPI_Feature> theFeat
     myFeatures = theSelected;
 }
 
-boost::shared_ptr<ModelAPI_Feature> PartSet_OperationEditLine::sketch() const
+FeaturePtr PartSet_OperationEditLine::sketch() const
 {
   return mySketch;
 }
@@ -89,7 +89,7 @@ void PartSet_OperationEditLine::mousePressed(QMouseEvent* theEvent, Handle(V3d_V
 {
   if (myFeatures.size() == 1)
   {
-    boost::shared_ptr<ModelAPI_Feature> aFeature;
+    FeaturePtr aFeature;
     if (!theHighlighted.empty())
       aFeature = theHighlighted.front().feature();
 
@@ -119,15 +119,15 @@ void PartSet_OperationEditLine::mouseMoved(QMouseEvent* theEvent, Handle(V3d_Vie
   if (!(theEvent->buttons() &  Qt::LeftButton))
     return;
 
-  gp_Pnt aPoint = PartSet_Tools::ConvertClickToPoint(theEvent->pos(), theView);
+  gp_Pnt aPoint = PartSet_Tools::convertClickToPoint(theEvent->pos(), theView);
 
   blockSelection(true);
   if (myCurPoint.myIsInitialized) {
     double aCurX, aCurY;
-    PartSet_Tools::ConvertTo2D(myCurPoint.myPoint, sketch(), theView, aCurX, aCurY);
+    PartSet_Tools::convertTo2D(myCurPoint.myPoint, sketch(), theView, aCurX, aCurY);
 
     double aX, anY;
-    PartSet_Tools::ConvertTo2D(aPoint, sketch(), theView, aX, anY);
+    PartSet_Tools::convertTo2D(aPoint, sketch(), theView, aX, anY);
 
     double aDeltaX = aX - aCurX;
     double aDeltaY = anY - aCurY;
@@ -137,7 +137,7 @@ void PartSet_OperationEditLine::mouseMoved(QMouseEvent* theEvent, Handle(V3d_Vie
 
     std::list<XGUI_ViewerPrs>::const_iterator anIt = myFeatures.begin(), aLast = myFeatures.end();
     for (; anIt != aLast; anIt++) {
-      boost::shared_ptr<ModelAPI_Feature> aFeature = (*anIt).feature();
+      FeaturePtr aFeature = (*anIt).feature();
       if (!aFeature || aFeature == feature())
         continue;
       moveLinePoint(aFeature, aDeltaX, aDeltaY, LINE_ATTR_START);
@@ -161,7 +161,7 @@ void PartSet_OperationEditLine::mouseReleased(QMouseEvent* theEvent, Handle(V3d_
     commit();
     std::list<XGUI_ViewerPrs>::const_iterator anIt = aFeatures.begin(), aLast = aFeatures.end();
     for (; anIt != aLast; anIt++) {
-      boost::shared_ptr<ModelAPI_Feature> aFeature = (*anIt).feature();
+      FeaturePtr aFeature = (*anIt).feature();
       if (aFeature)
         emit featureConstructed(aFeature, FM_Deactivation);
     }
@@ -205,17 +205,17 @@ void PartSet_OperationEditLine::blockSelection(bool isBlocked, const bool isRest
   }
 }
 
-boost::shared_ptr<ModelAPI_Feature> PartSet_OperationEditLine::createFeature(const bool /*theFlushMessage*/)
+FeaturePtr PartSet_OperationEditLine::createFeature(const bool /*theFlushMessage*/)
 {
   // do nothing in order to do not create a new feature
-  return boost::shared_ptr<ModelAPI_Feature>();
+  return FeaturePtr();
 }
 
-void PartSet_OperationEditLine::moveLinePoint(boost::shared_ptr<ModelAPI_Feature> theFeature,
+void PartSet_OperationEditLine::moveLinePoint(FeaturePtr theFeature,
                                                double theDeltaX, double theDeltaY,
                                                const std::string& theAttribute)
 {
-  if (!theFeature || theFeature->getKind() != "SketchLine")
+  if (!theFeature || theFeature->getKind() != SKETCH_LINE_KIND)
     return;
 
   boost::shared_ptr<ModelAPI_Data> aData = theFeature->data();
@@ -231,10 +231,10 @@ void PartSet_OperationEditLine::sendFeatures()
 {
   static Events_ID anEvent = Events_Loop::eventByName(EVENT_FEATURE_MOVED);
 
-  std::list<boost::shared_ptr<ModelAPI_Feature> > aFeatures;
+  std::list<FeaturePtr > aFeatures;
   std::list<XGUI_ViewerPrs>::const_iterator anIt = myFeatures.begin(), aLast = myFeatures.end();
   for (; anIt != aLast; anIt++) {
-    boost::shared_ptr<ModelAPI_Feature> aFeature = (*anIt).feature();
+    FeaturePtr aFeature = (*anIt).feature();
     if (!aFeature)
       continue;
 
index d42d0e545fb38022f6f716bd69b77935b83425bc..1e18c1511669eda17d636085e0bb3b60540a6fd5 100644 (file)
@@ -56,7 +56,7 @@ public:
   /// \param theParent the operation parent
   /// \param theFeature the parent feature
   PartSet_OperationEditLine(const QString& theId, QObject* theParent,
-                            boost::shared_ptr<ModelAPI_Feature> theFeature);
+                            FeaturePtr theFeature);
   /// Destructor
   virtual ~PartSet_OperationEditLine();
 
@@ -68,19 +68,19 @@ public:
   /// Returns the operation local selection mode
   /// \param theFeature the feature object to get the selection mode
   /// \return the selection mode
-  virtual std::list<int> getSelectionModes(boost::shared_ptr<ModelAPI_Feature> theFeature) const;
+  virtual std::list<int> getSelectionModes(FeaturePtr theFeature) const;
 
   /// Initializes some fields accorging to the feature
   /// \param theFeature the feature
   /// \param theSelected the list of selected presentations
   /// \param theHighlighted the list of highlighted presentations
-  virtual void init(boost::shared_ptr<ModelAPI_Feature> theFeature,
+  virtual void init(FeaturePtr theFeature,
                     const std::list<XGUI_ViewerPrs>& theSelected,
                     const std::list<XGUI_ViewerPrs>& theHighlighted);
 
   /// Returns the operation sketch feature
   /// \returns the sketch instance
-  virtual boost::shared_ptr<ModelAPI_Feature> sketch() const;
+  virtual FeaturePtr sketch() const;
 
   /// Processes the mouse pressed in the point
   /// \param theEvent the mouse event
@@ -116,7 +116,7 @@ protected:
   /// Returns NULL feature. This is an operation of edition, not creation.
   /// \param theFlushMessage the flag whether the create message should be flushed
   /// \returns the created feature
-  virtual boost::shared_ptr<ModelAPI_Feature> createFeature(const bool theFlushMessage = true);
+  virtual FeaturePtr createFeature(const bool theFlushMessage = true);
 
 protected:
   /// Emits a signal about the selection blocking. Emits a signal to change the selection.
@@ -131,17 +131,16 @@ protected:
   /// \param theDeltaX the delta for X coordinate is moved
   /// \param theDeltaY the delta for Y coordinate is moved
   /// \param theAttribute the start or end attribute of the line
-  void  moveLinePoint(boost::shared_ptr<ModelAPI_Feature> theFeature,
+  void  moveLinePoint(FeaturePtr theFeature,
                       double theDeltaX, double theDeltaY,
                       const std::string& theAttribute);
   /// Sends the features
   void sendFeatures();
 
 private:
-  boost::shared_ptr<ModelAPI_Feature> mySketch; ///< the sketch feature
+  FeaturePtr mySketch; ///< the sketch feature
   std::list<XGUI_ViewerPrs> myFeatures; ///< the features to apply the edit operation
   Point myCurPoint; ///< the current 3D point clicked or moved
-  gp_Pnt myCurPressed; ///< the current 3D point clicked or moved
   bool myIsBlockedSelection; ///< the state of the last state of selection blocked signal
 };
 
index af60900da7dbe00f5dc8c342497a413198dad102..039d293b39600b053b4d4cfca45565be6a40e561 100644 (file)
@@ -22,6 +22,9 @@
 
 #include <AIS_Shape.hxx>
 #include <AIS_ListOfInteractive.hxx>
+#include <AIS_InteractiveObject.hxx>
+#include <AIS_DimensionOwner.hxx>
+#include <AIS_LengthDimension.hxx>
 #include <V3d_View.hxx>
 
 #ifdef _DEBUG
@@ -42,24 +45,25 @@ PartSet_OperationSketch::~PartSet_OperationSketch()
 {
 }
 
-std::list<int> PartSet_OperationSketch::getSelectionModes(boost::shared_ptr<ModelAPI_Feature> theFeature) const
+std::list<int> PartSet_OperationSketch::getSelectionModes(FeaturePtr theFeature) const
 {
   std::list<int> aModes;
   if (!hasSketchPlane())
     aModes.push_back(TopAbs_FACE);
   else
     aModes = PartSet_OperationSketchBase::getSelectionModes(theFeature);
+
   return aModes;
 }
 
-void PartSet_OperationSketch::init(boost::shared_ptr<ModelAPI_Feature> theFeature,
+void PartSet_OperationSketch::init(FeaturePtr theFeature,
                                    const std::list<XGUI_ViewerPrs>& /*theSelected*/,
                                    const std::list<XGUI_ViewerPrs>& /*theHighlighted*/)
 {
   setFeature(theFeature);
 }
 
-boost::shared_ptr<ModelAPI_Feature> PartSet_OperationSketch::sketch() const
+FeaturePtr PartSet_OperationSketch::sketch() const
 {
   return feature();
 }
@@ -84,7 +88,7 @@ void PartSet_OperationSketch::mousePressed(QMouseEvent* theEvent, Handle_V3d_Vie
       return;
 
     if (theHighlighted.size() == 1) {
-      boost::shared_ptr<ModelAPI_Feature> aFeature = theHighlighted.front().feature();
+      FeaturePtr aFeature = theHighlighted.front().feature();
       if (aFeature)
         restartOperation(PartSet_OperationEditLine::Type(), aFeature);
     }
@@ -93,23 +97,56 @@ void PartSet_OperationSketch::mousePressed(QMouseEvent* theEvent, Handle_V3d_Vie
   }
 }
 
+#include <QLineEdit>
+void PartSet_OperationSketch::mouseReleased(QMouseEvent* theEvent, Handle_V3d_View theView,
+                                            const std::list<XGUI_ViewerPrs>& theSelected,
+                                            const std::list<XGUI_ViewerPrs>& theHighlighted)
+{
+  if (!hasSketchPlane()) {
+  }
+  else {
+    if (!theSelected.empty()) {
+      XGUI_ViewerPrs aPrs = theSelected.front();
+      if (!aPrs.owner().IsNull()) {
+        Handle(AIS_DimensionOwner) anOwner = Handle(AIS_DimensionOwner)::DownCast(aPrs.owner());
+        if (!anOwner.IsNull() && anOwner->SelectionMode() == AIS_DSM_Text) {
+          Handle(SelectMgr_SelectableObject) anObject = anOwner->Selectable();
+          double aValue = 0;
+          if (!anObject.IsNull()) {
+            Handle(AIS_LengthDimension) aLenDim = Handle(AIS_LengthDimension)::DownCast(anObject);
+            if (!aLenDim.IsNull())
+              aValue = aLenDim->GetValue();
+          }
+
+          QLineEdit* aLine = new QLineEdit();
+          QPoint aViewPos = theEvent->globalPos();
+          QPoint aLinePos(aViewPos.x(), aViewPos.y());
+          aLine->move(aLinePos);
+          aLine->setText(QString::number(aValue));
+          aLine->show();
+        }
+      }
+    }
+  }
+}
+
 void PartSet_OperationSketch::mouseMoved(QMouseEvent* theEvent, Handle(V3d_View) theView)
 {
   if (!hasSketchPlane() || !(theEvent->buttons() &  Qt::LeftButton) || myFeatures.empty())
     return;
 
   if (myFeatures.size() != 1) {
-    boost::shared_ptr<ModelAPI_Feature> aFeature = PartSet_Tools::NearestFeature(theEvent->pos(),
+    FeaturePtr aFeature = PartSet_Tools::nearestFeature(theEvent->pos(),
                                                                 theView, feature(), myFeatures);
     if (aFeature)
       restartOperation(PartSet_OperationEditLine::Type(), aFeature);
   }
 }
 
-std::map<boost::shared_ptr<ModelAPI_Feature>, boost::shared_ptr<GeomAPI_Shape> >
+std::map<FeaturePtr, boost::shared_ptr<GeomAPI_Shape> >
                                                         PartSet_OperationSketch::subPreview() const
 {
-  std::map<boost::shared_ptr<ModelAPI_Feature>, boost::shared_ptr<GeomAPI_Shape> > aPreviewMap;
+  std::map<FeaturePtr, boost::shared_ptr<GeomAPI_Shape> > aPreviewMap;
 
   boost::shared_ptr<SketchPlugin_Feature> aFeature;
 
@@ -119,8 +156,8 @@ std::map<boost::shared_ptr<ModelAPI_Feature>, boost::shared_ptr<GeomAPI_Shape> >
   boost::shared_ptr<ModelAPI_AttributeRefList> aRefList =
         boost::dynamic_pointer_cast<ModelAPI_AttributeRefList>(aData->attribute(SKETCH_ATTR_FEATURES));
 
-  std::list<boost::shared_ptr<ModelAPI_Feature> > aFeatures = aRefList->list();
-  std::list<boost::shared_ptr<ModelAPI_Feature> >::const_iterator anIt = aFeatures.begin(),
+  std::list<FeaturePtr > aFeatures = aRefList->list();
+  std::list<FeaturePtr >::const_iterator anIt = aFeatures.begin(),
                                                                   aLast = aFeatures.end();
   for (; anIt != aLast; anIt++) {
     aFeature = boost::dynamic_pointer_cast<SketchPlugin_Feature>(*anIt);
@@ -189,7 +226,7 @@ void PartSet_OperationSketch::setSketchPlane(const TopoDS_Shape& theShape)
   aCoords = aCoords->multiplied(-aD * aCoords->distance(aZero));
   boost::shared_ptr<GeomAPI_Pnt> anOrigPnt(new GeomAPI_Pnt(aCoords));
   // X axis is preferable to be dirX on the sketch
-  const double tol = 1e-7;
+  const double tol = Precision::Confusion();
   bool isX = fabs(anA - 1.0) < tol && fabs(aB) < tol && fabs(aC) < tol;
   boost::shared_ptr<GeomAPI_Dir> aTempDir(isX ? new GeomAPI_Dir(0, 1, 0) : new GeomAPI_Dir(1, 0, 0));
   boost::shared_ptr<GeomAPI_Dir> aYDir(new GeomAPI_Dir(aNormDir->cross(aTempDir)));
index 9c76414e9f7b5ce2b9cce0c008afe8d3b12cbeac..27c0d8641db489ef85cde4dce263e84cc9f3386b 100644 (file)
@@ -8,8 +8,13 @@
 #include "PartSet.h"
 
 #include <PartSet_OperationSketchBase.h>
+
+#include <SketchPlugin_Sketch.h>
+
 #include <QObject>
 
+class Handle_AIS_InteractiveObject;
+
 /*!
  \class PartSet_OperationSketch
  * \brief The operation for the sketch feature creation
@@ -19,7 +24,7 @@ class PARTSET_EXPORT PartSet_OperationSketch : public PartSet_OperationSketchBas
   Q_OBJECT
 public:
   /// Returns the operation type key
-  static std::string Type() { return "Sketch"; }
+  static std::string Type() { return SKETCH_KIND; }
 
 public:
   /// Constructor
@@ -32,18 +37,18 @@ public:
   /// Returns the operation local selection mode
   /// \param theFeature the feature object to get the selection mode
   /// \return the selection mode
-  virtual std::list<int> getSelectionModes(boost::shared_ptr<ModelAPI_Feature> theFeature) const;
+  virtual std::list<int> getSelectionModes(FeaturePtr theFeature) const;
 
   /// Initializes some fields accorging to the feature
   /// \param theSelected the list of selected presentations
   /// \param theHighlighted the list of highlighted presentations
-  virtual void init(boost::shared_ptr<ModelAPI_Feature> theFeature,
+  virtual void init(FeaturePtr theFeature,
                     const std::list<XGUI_ViewerPrs>& theSelected,
                     const std::list<XGUI_ViewerPrs>& theHighlighted);
 
   /// Returns the operation sketch feature
   /// \returns the sketch instance
-  virtual boost::shared_ptr<ModelAPI_Feature> sketch() const;
+  virtual FeaturePtr sketch() const;
 
   /// Processes the mouse pressed in the point
   /// \param theEvent the mouse event
@@ -53,6 +58,15 @@ public:
   virtual void mousePressed(QMouseEvent* theEvent, Handle_V3d_View theView,
                             const std::list<XGUI_ViewerPrs>& theSelected,
                             const std::list<XGUI_ViewerPrs>& theHighlighted);
+  /// Processes the mouse release in the point
+  /// \param theEvent the mouse event
+  /// \param theView a viewer to have the viewer the eye position
+  /// \param theSelected the list of selected presentations
+  /// \param theHighlighted the list of highlighted presentations
+  virtual void mouseReleased(QMouseEvent* theEvent, Handle_V3d_View theView,
+                             const std::list<XGUI_ViewerPrs>& theSelected,
+                             const std::list<XGUI_ViewerPrs>& theHighlighted);
+
   /// Gives the current mouse point in the viewer
   /// \param thePoint a point clicked in the viewer
   /// \param theEvent the mouse event
@@ -60,7 +74,7 @@ public:
 
   /// Returns the map of the operation previews including the nested feature previews
   /// \return the map of feature to the feature preview
-  virtual std::map<boost::shared_ptr<ModelAPI_Feature>, boost::shared_ptr<GeomAPI_Shape> >
+  virtual std::map<FeaturePtr, boost::shared_ptr<GeomAPI_Shape> >
                                                                            subPreview() const;
 
   /// Virtual method called when operation stopped - committed or aborted.
index ae751b269ec8f14ce686d059e24a9f4c5f6128c0..8bb9e3be213209ebb45a420f67f4304c7aae31be 100644 (file)
@@ -27,7 +27,7 @@ PartSet_OperationSketchBase::~PartSet_OperationSketchBase()
 }
 
 boost::shared_ptr<GeomAPI_Shape> PartSet_OperationSketchBase::preview(
-                                      boost::shared_ptr<ModelAPI_Feature> theFeature)
+                                      FeaturePtr theFeature)
 {
   boost::shared_ptr<SketchPlugin_Feature> aFeature = 
                               boost::dynamic_pointer_cast<SketchPlugin_Feature>(theFeature);
@@ -36,22 +36,22 @@ boost::shared_ptr<GeomAPI_Shape> PartSet_OperationSketchBase::preview(
   return aFeature->preview();
 }
 
-std::map<boost::shared_ptr<ModelAPI_Feature>, boost::shared_ptr<GeomAPI_Shape> >
+std::map<FeaturePtr, boost::shared_ptr<GeomAPI_Shape> >
                                                      PartSet_OperationSketchBase::subPreview() const
 {
-  return std::map<boost::shared_ptr<ModelAPI_Feature>, boost::shared_ptr<GeomAPI_Shape> >();
+  return std::map<FeaturePtr, boost::shared_ptr<GeomAPI_Shape> >();
 }
 
-std::list<int> PartSet_OperationSketchBase::getSelectionModes(boost::shared_ptr<ModelAPI_Feature> theFeature) const
+std::list<int> PartSet_OperationSketchBase::getSelectionModes(FeaturePtr theFeature) const
 {
   std::list<int> aModes;
   aModes.push_back(TopAbs_VERTEX);
   aModes.push_back(TopAbs_EDGE);
   return aModes;
 }
-boost::shared_ptr<ModelAPI_Feature> PartSet_OperationSketchBase::createFeature(const bool theFlushMessage)
+FeaturePtr PartSet_OperationSketchBase::createFeature(const bool theFlushMessage)
 {
-  boost::shared_ptr<ModelAPI_Feature> aFeature = ModuleBase_Operation::createFeature(theFlushMessage);
+  FeaturePtr aFeature = ModuleBase_Operation::createFeature(theFlushMessage);
   if (aFeature)
     emit featureConstructed(aFeature, FM_Activation);
   return aFeature;
@@ -90,7 +90,7 @@ void PartSet_OperationSketchBase::keyReleased(std::string theName, QKeyEvent* th
 }
 
 void PartSet_OperationSketchBase::restartOperation(const std::string& theType,
-                                                   boost::shared_ptr<ModelAPI_Feature> theFeature)
+                                                   FeaturePtr theFeature)
 {
   emit launchOperation(theType, theFeature);
 }
index 0c10c6c1a9fb3b4074138b9b43f62e72f5d168fa..ff6f06847b568dbada696596b3a86a656b94d2da 100644 (file)
@@ -43,27 +43,27 @@ public:
 
   /// Returns the feature preview shape
   /// \param theFeature the feature object to obtain the preview
-  static boost::shared_ptr<GeomAPI_Shape> preview(boost::shared_ptr<ModelAPI_Feature> theFeature);
+  static boost::shared_ptr<GeomAPI_Shape> preview(FeaturePtr theFeature);
 
   /// Returns the map of the operation previews including the nested feature previews
   /// \return the map of feature to the feature preview
-  virtual std::map<boost::shared_ptr<ModelAPI_Feature>, boost::shared_ptr<GeomAPI_Shape> > subPreview() const;
+  virtual std::map<FeaturePtr, boost::shared_ptr<GeomAPI_Shape> > subPreview() const;
 
   /// Returns the operation local selection mode
   /// \param theFeature the feature object to get the selection mode
   /// \return the selection mode
-  virtual std::list<int> getSelectionModes(boost::shared_ptr<ModelAPI_Feature> theFeature) const = 0;
+  virtual std::list<int> getSelectionModes(FeaturePtr theFeature) const;
 
   /// Initializes some fields accorging to the feature
   /// \param theSelected the list of selected presentations
   /// \param theHighlighted the list of highlighted presentations
-  virtual void init(boost::shared_ptr<ModelAPI_Feature> theFeature,
+  virtual void init(FeaturePtr theFeature,
                     const std::list<XGUI_ViewerPrs>& theSelected,
                     const std::list<XGUI_ViewerPrs>& theHighlighted) {}
 
   /// Returns the operation sketch feature
   /// \returns the sketch instance
-  virtual boost::shared_ptr<ModelAPI_Feature> sketch() const = 0;
+  virtual FeaturePtr sketch() const = 0;
 
   /// Processes the mouse pressed in the point
   /// \param theEvent the mouse event
@@ -99,13 +99,13 @@ public:
   /// \param theType a type of an operation started
   /// theFeature the operation argument
   void restartOperation(const std::string& theType,
-         boost::shared_ptr<ModelAPI_Feature> theFeature = boost::shared_ptr<ModelAPI_Feature>());
+         FeaturePtr theFeature = FeaturePtr());
 
 signals:
   /// signal about the request to launch operation
   /// theName the operation name
   /// theFeature the operation argument
-  void launchOperation(std::string theName, boost::shared_ptr<ModelAPI_Feature> theFeature);
+  void launchOperation(std::string theName, FeaturePtr theFeature);
   /// signal about the focus activated
   /// theName the attribute name
   void focusActivated(const std::string& theAttibuteName);
@@ -113,7 +113,7 @@ signals:
   /// Signal about the feature construing is finished
   /// \param theFeature the result feature
   /// \param theMode the mode of the feature modification
-  void featureConstructed(boost::shared_ptr<ModelAPI_Feature> theFeature,
+  void featureConstructed(FeaturePtr theFeature,
                           int theMode);
   /// Signal about the features should be selected
   /// \param theSelected the list of selected presentations
@@ -139,7 +139,7 @@ protected:
   /// the sketch feature
   /// \param theFlushMessage the flag whether the create message should be flushed
   /// \returns the created feature
-  virtual boost::shared_ptr<ModelAPI_Feature> createFeature(const bool theFlushMessage = true);
+  virtual FeaturePtr createFeature(const bool theFlushMessage = true);
 };
 
 #endif
diff --git a/src/PartSet/PartSet_OperationSketchLine.cpp b/src/PartSet/PartSet_OperationSketchLine.cpp
deleted file mode 100644 (file)
index 1a1cdbc..0000000
+++ /dev/null
@@ -1,442 +0,0 @@
-// File:        PartSet_OperationSketchLine.h
-// Created:     20 Apr 2014
-// Author:      Natalia ERMOLAEVA
-
-#include <PartSet_OperationSketchLine.h>
-
-#include <PartSet_Tools.h>
-#include <PartSet_OperationSketch.h>
-
-#include <SketchPlugin_Feature.h>
-#include <SketchPlugin_Sketch.h>
-
-#include <GeomDataAPI_Point2D.h>
-
-#include <ModuleBase_OperationDescription.h>
-
-#include <ModelAPI_Data.h>
-#include <ModelAPI_Document.h>
-#include <ModelAPI_AttributeRefAttr.h>
-#include <ModelAPI_AttributeRefList.h>
-
-#include <SketchPlugin_Constraint.h>
-
-#include <Geom_Line.hxx>
-#include <gp_Lin.hxx>
-
-#include <XGUI_ViewerPrs.h>
-#include <XGUI_Constants.h>
-
-#include <SketchPlugin_Line.h>
-
-#include <V3d_View.hxx>
-#include <TopoDS_Vertex.hxx>
-#include <TopoDS.hxx>
-#include <BRep_Tool.hxx>
-
-#ifdef _DEBUG
-#include <QDebug>
-#endif
-
-#include <QMouseEvent>
-
-using namespace std;
-
-PartSet_OperationSketchLine::PartSet_OperationSketchLine(const QString& theId,
-                                                 QObject* theParent,
-                                              boost::shared_ptr<ModelAPI_Feature> theFeature)
-: PartSet_OperationSketchBase(theId, theParent), mySketch(theFeature),
-  myPointSelectionMode(SM_FirstPoint)
-{
-}
-
-PartSet_OperationSketchLine::~PartSet_OperationSketchLine()
-{
-}
-
-bool PartSet_OperationSketchLine::canBeCommitted() const
-{
-  return myPointSelectionMode == SM_DonePoint;
-}
-
-bool PartSet_OperationSketchLine::isGranted(ModuleBase_IOperation* theOperation) const
-{
-  return theOperation->getDescription()->operationId().toStdString() == PartSet_OperationSketch::Type();
-}
-
-std::list<int> PartSet_OperationSketchLine::getSelectionModes(boost::shared_ptr<ModelAPI_Feature> theFeature) const
-{
-  std::list<int> aModes;
-  if (theFeature != feature())
-    aModes = PartSet_OperationSketchBase::getSelectionModes(theFeature);
-  return aModes;
-}
-
-void PartSet_OperationSketchLine::init(boost::shared_ptr<ModelAPI_Feature> theFeature,
-                                       const std::list<XGUI_ViewerPrs>& /*theSelected*/,
-                                       const std::list<XGUI_ViewerPrs>& /*theHighlighted*/)
-{
-  if (!theFeature || theFeature->getKind() != "SketchLine")
-    return;
-  // use the last point of the previous feature as the first of the new one
-  boost::shared_ptr<ModelAPI_Data> aData = theFeature->data();
-  myInitPoint = boost::dynamic_pointer_cast<GeomDataAPI_Point2D>(aData->attribute(LINE_ATTR_END));
-}
-
-boost::shared_ptr<ModelAPI_Feature> PartSet_OperationSketchLine::sketch() const
-{
-  return mySketch;
-}
-
-void PartSet_OperationSketchLine::mouseReleased(QMouseEvent* theEvent, Handle(V3d_View) theView,
-                                                const std::list<XGUI_ViewerPrs>& theSelected,
-                                                const std::list<XGUI_ViewerPrs>& /*theHighlighted*/)
-{
-  if (myPointSelectionMode == SM_DonePoint)
-  {
-    // if the point creation is finished, the next mouse release should commit the modification
-    // the next release can happens by double click in the viewer
-    commit();
-    restartOperation(PartSet_OperationSketchLine::Type(), feature());
-    return;
-  }
-
-  double aX, anY;
-
-  bool isFoundPoint = false;
-  gp_Pnt aPoint = PartSet_Tools::ConvertClickToPoint(theEvent->pos(), theView);
-  if (theSelected.empty()) {
-    PartSet_Tools::ConvertTo2D(aPoint, sketch(), theView, aX, anY);
-    isFoundPoint = true;
-  }
-  else {
-    XGUI_ViewerPrs aPrs = theSelected.front();
-    const TopoDS_Shape& aShape = aPrs.shape();
-    if (!aShape.IsNull()) // the point is selected
-    {
-      if (aShape.ShapeType() == TopAbs_VERTEX) {
-        const TopoDS_Vertex& aVertex = TopoDS::Vertex(aShape);
-        if (!aVertex.IsNull()) {
-          aPoint = BRep_Tool::Pnt(aVertex);
-          PartSet_Tools::ConvertTo2D(aPoint, sketch(), theView, aX, anY);
-          isFoundPoint = true;
-
-          setConstraints(aX, anY);
-        }
-      }
-      else if (aShape.ShapeType() == TopAbs_EDGE) // the line is selected
-      {
-        boost::shared_ptr<ModelAPI_Feature> aFeature = aPrs.feature();
-        if (aFeature) {
-          double X0, X1, X2, X3;
-          double Y0, Y1, Y2, Y3;
-          getLinePoint(aFeature, LINE_ATTR_START, X2, Y2);
-          getLinePoint(aFeature, LINE_ATTR_END, X3, Y3);
-          PartSet_Tools::ConvertTo2D(aPoint, sketch(), theView, X1, Y1);
-
-          switch (myPointSelectionMode) {
-            case SM_FirstPoint:
-              PartSet_Tools::ProjectPointOnLine(X2, Y2, X3, Y3, X1, Y1, aX, anY);
-            break;
-            case SM_SecondPoint: {
-              getLinePoint(feature(), LINE_ATTR_START, X0, Y0);
-              PartSet_Tools::IntersectLines(X0, Y0, X1, Y1, X2, Y2, X3, Y3, aX, anY);
-            }
-            break;
-            default:
-            break;
-          }
-          isFoundPoint = true;
-        }
-      }
-    }
-  }
-
-  switch (myPointSelectionMode)
-  {
-    case SM_FirstPoint: {
-      setLinePoint(feature(), aX, anY, LINE_ATTR_START);
-      setLinePoint(feature(), aX, anY, LINE_ATTR_END);
-      flushUpdated();
-
-      setPointSelectionMode(SM_SecondPoint);
-    }
-    break;
-    case SM_SecondPoint: {
-      setLinePoint(feature(), aX, anY, LINE_ATTR_END);
-      flushUpdated();
-
-      setPointSelectionMode(SM_DonePoint);
-   }
-    break;
-    default:
-      break;
-  }
-}
-
-void PartSet_OperationSketchLine::mouseMoved(QMouseEvent* theEvent, Handle(V3d_View) theView)
-{
-  switch (myPointSelectionMode)
-  {
-    case SM_FirstPoint: {
-      double aX, anY;
-      gp_Pnt aPoint = PartSet_Tools::ConvertClickToPoint(theEvent->pos(), theView);
-      PartSet_Tools::ConvertTo2D(aPoint, sketch(), theView, aX, anY);
-      setLinePoint(feature(), aX, anY, LINE_ATTR_START);
-      setLinePoint(feature(), aX, anY, LINE_ATTR_END);
-      flushUpdated();
-      emit focusActivated(LINE_ATTR_START);
-    }
-    break;
-    case SM_SecondPoint:
-    {
-      gp_Pnt aPoint = PartSet_Tools::ConvertClickToPoint(theEvent->pos(), theView);
-      setLinePoint(aPoint, theView, LINE_ATTR_END);
-      flushUpdated();
-      emit focusActivated(LINE_ATTR_END);
-    }
-    break;
-    case SM_DonePoint:
-    {
-      commit();
-      restartOperation(PartSet_OperationSketchLine::Type(), feature());
-    }
-    default:
-      break;
-  }
-}
-
-void PartSet_OperationSketchLine::keyReleased(std::string theName, QKeyEvent* theEvent)
-{
-  int aKeyType = theEvent->key();
-  // the second point should be activated by any modification in the property panel
-  if (!theName.empty() /*&& aKeyType == Qt::Key_Return*/) {
-    if (theName == LINE_ATTR_START) {
-      setPointSelectionMode(SM_SecondPoint, false);
-    }
-    else if (theName == LINE_ATTR_END) {
-      setPointSelectionMode(SM_DonePoint, false);
-    }
-  }
-  keyReleased(theEvent->key());
-}
-
-void PartSet_OperationSketchLine::keyReleased(const int theKey)
-{
-  switch (theKey) {
-    case Qt::Key_Return: {
-      if (myPointSelectionMode == SM_DonePoint)
-      {
-        commit();
-        restartOperation(PartSet_OperationSketchLine::Type(), feature());
-      }
-      //else
-      //  abort();
-      //emit launchOperation(PartSet_OperationSketchLine::Type(), boost::shared_ptr<ModelAPI_Feature>());
-    }
-    break;
-    case Qt::Key_Escape: {
-      if (myPointSelectionMode == SM_DonePoint)
-      {
-        commit();
-      }
-      else
-        abort();
-    }
-    default:
-    break;
-  }
-}
-
-void PartSet_OperationSketchLine::startOperation()
-{
-  PartSet_OperationSketchBase::startOperation();
-  setPointSelectionMode(!myInitPoint ? SM_FirstPoint : SM_SecondPoint);
-
-  emit multiSelectionEnabled(false);
-}
-
-void PartSet_OperationSketchLine::abortOperation()
-{
-  emit featureConstructed(feature(), FM_Hide);
-  PartSet_OperationSketchBase::abortOperation();
-}
-
-void PartSet_OperationSketchLine::stopOperation()
-{
-  PartSet_OperationSketchBase::stopOperation();
-  emit multiSelectionEnabled(true);
-}
-
-void PartSet_OperationSketchLine::afterCommitOperation()
-{
-  PartSet_OperationSketchBase::afterCommitOperation();  
-  emit featureConstructed(feature(), FM_Deactivation);
-}
-
-boost::shared_ptr<ModelAPI_Feature> PartSet_OperationSketchLine::createFeature(const bool theFlushMessage)
-{
-  boost::shared_ptr<ModelAPI_Feature> aNewFeature = ModuleBase_Operation::createFeature(false);
-  if (sketch()) {
-    boost::shared_ptr<SketchPlugin_Feature> aFeature = 
-                           boost::dynamic_pointer_cast<SketchPlugin_Feature>(sketch());
-
-    aFeature->addSub(aNewFeature);
-  }
-  if (myInitPoint) {
-    setLinePoint(aNewFeature, myInitPoint->x(), myInitPoint->y(), LINE_ATTR_START);
-    setLinePoint(aNewFeature, myInitPoint->x(), myInitPoint->y(), LINE_ATTR_END);
-
-    boost::shared_ptr<ModelAPI_Data> aData = aNewFeature->data();
-    boost::shared_ptr<GeomDataAPI_Point2D> aPoint = boost::dynamic_pointer_cast<GeomDataAPI_Point2D>
-                                                                (aData->attribute(LINE_ATTR_START));
-    createConstraint(myInitPoint, aPoint);
-  }
-
-  emit featureConstructed(aNewFeature, FM_Activation);
-  if (theFlushMessage)
-    flushCreated();
-  return aNewFeature;
-}
-
-void PartSet_OperationSketchLine::createConstraint(boost::shared_ptr<GeomDataAPI_Point2D> thePoint1,
-                                                   boost::shared_ptr<GeomDataAPI_Point2D> thePoint2)
-{
-  boost::shared_ptr<ModelAPI_Document> aDoc = document();
-  boost::shared_ptr<ModelAPI_Feature> aFeature = aDoc->addFeature("SketchConstraintCoincidence");
-
-  if (sketch()) {
-    boost::shared_ptr<SketchPlugin_Feature> aSketch = 
-                           boost::dynamic_pointer_cast<SketchPlugin_Feature>(sketch());
-    aSketch->addSub(aFeature);
-  }
-
-  boost::shared_ptr<ModelAPI_Data> aData = aFeature->data();
-
-  boost::shared_ptr<ModelAPI_AttributeRefAttr> aRef1 =
-        boost::dynamic_pointer_cast<ModelAPI_AttributeRefAttr>(aData->attribute(CONSTRAINT_ATTR_ENTITY_A));
-  aRef1->setAttr(thePoint1);
-
-  boost::shared_ptr<ModelAPI_AttributeRefAttr> aRef2 =
-        boost::dynamic_pointer_cast<ModelAPI_AttributeRefAttr>(aData->attribute(CONSTRAINT_ATTR_ENTITY_B));
-  aRef2->setAttr(thePoint2);
-
-  if (aFeature) // TODO: generate an error if feature was not created
-    aFeature->execute();
-}
-
-void PartSet_OperationSketchLine::setConstraints(double theX, double theY)
-{
-  std::string aPointArg;
-  switch (myPointSelectionMode)
-  {
-    case SM_FirstPoint:
-      aPointArg = LINE_ATTR_START;
-      break;
-    case SM_SecondPoint:
-      aPointArg = LINE_ATTR_END;
-      break;
-    default:
-      break;
-  }
-
-  boost::shared_ptr<ModelAPI_Feature> aSkFeature = feature();
-
-  boost::shared_ptr<ModelAPI_Data> aData = feature()->data();
-  boost::shared_ptr<GeomDataAPI_Point2D> aPoint = boost::dynamic_pointer_cast<GeomDataAPI_Point2D>
-                                                              (aData->attribute(aPointArg));
-  aData = sketch()->data();
-  boost::shared_ptr<ModelAPI_AttributeRefList> aRefList =
-        boost::dynamic_pointer_cast<ModelAPI_AttributeRefList>(aData->attribute(SKETCH_ATTR_FEATURES));
-
-  std::list<boost::shared_ptr<ModelAPI_Feature> > aFeatures = aRefList->list();
-  std::list<boost::shared_ptr<ModelAPI_Feature> >::const_iterator anIt = aFeatures.begin(),
-                                                                  aLast = aFeatures.end();
-  for (; anIt != aLast; anIt++) {
-    boost::shared_ptr<ModelAPI_Feature> aFeature = *anIt;
-    boost::shared_ptr<GeomDataAPI_Point2D> aFPoint = findLinePoint(aFeature, theX, theY);
-    if (aFPoint)
-      createConstraint(aFPoint, aPoint);
-  }
-}
-
-void PartSet_OperationSketchLine::getLinePoint(boost::shared_ptr<ModelAPI_Feature> theFeature,
-                                               const std::string& theAttribute,
-                                               double& theX, double& theY)
-{
-  if (!theFeature || theFeature->getKind() != "SketchLine")
-    return;
-  boost::shared_ptr<ModelAPI_Data> aData = theFeature->data();
-  boost::shared_ptr<GeomDataAPI_Point2D> aPoint =
-        boost::dynamic_pointer_cast<GeomDataAPI_Point2D>(aData->attribute(theAttribute));
-  theX = aPoint->x();
-  theY = aPoint->y();
-}
-
-boost::shared_ptr<GeomDataAPI_Point2D> PartSet_OperationSketchLine::findLinePoint(
-                                               boost::shared_ptr<ModelAPI_Feature> theFeature,
-                                               double theX, double theY)
-{
-  boost::shared_ptr<GeomDataAPI_Point2D> aPoint2D;
-  if (!theFeature || theFeature->getKind() != "SketchLine")
-    return aPoint2D;
-  boost::shared_ptr<ModelAPI_Data> aData = theFeature->data();
-  
-  boost::shared_ptr<GeomDataAPI_Point2D> aPoint =
-        boost::dynamic_pointer_cast<GeomDataAPI_Point2D>(aData->attribute(LINE_ATTR_START));
-  if (fabs(aPoint->x() - theX) < Precision::Confusion() && fabs(aPoint->y() - theY) < Precision::Confusion() )
-    aPoint2D = aPoint;
-  else {
-    aPoint = boost::dynamic_pointer_cast<GeomDataAPI_Point2D>(aData->attribute(LINE_ATTR_END));
-    if (fabs(aPoint->x() - theX) < Precision::Confusion() && fabs(aPoint->y() - theY) < Precision::Confusion() )
-      aPoint2D = aPoint;
-  }
-  return aPoint2D;
-}
-
-void PartSet_OperationSketchLine::setLinePoint(boost::shared_ptr<ModelAPI_Feature> theFeature,
-                                               double theX, double theY,
-                                               const std::string& theAttribute)
-{
-  if (!theFeature)
-    return;
-  boost::shared_ptr<ModelAPI_Data> aData = theFeature->data();
-  boost::shared_ptr<GeomDataAPI_Point2D> aPoint =
-        boost::dynamic_pointer_cast<GeomDataAPI_Point2D>(aData->attribute(theAttribute));
-  aPoint->setValue(theX, theY);
-}
-
-void PartSet_OperationSketchLine::setLinePoint(const gp_Pnt& thePoint,
-                                               Handle(V3d_View) theView,
-                                               const std::string& theAttribute)
-{
-  double aX, anY;
-  PartSet_Tools::ConvertTo2D(thePoint, sketch(), theView, aX, anY);
-  boost::shared_ptr<ModelAPI_Data> aData = feature()->data();
-  boost::shared_ptr<GeomDataAPI_Point2D> aPoint =
-        boost::dynamic_pointer_cast<GeomDataAPI_Point2D>(aData->attribute(theAttribute));
-  aPoint->setValue(aX, anY);
-}
-
-void PartSet_OperationSketchLine::setPointSelectionMode(const PointSelectionMode& theMode,
-                                                        const bool isToEmitSignal)
-{
-  myPointSelectionMode = theMode;
-  if (isToEmitSignal) {
-    std::string aName;
-    switch (theMode) {
-      case SM_FirstPoint:
-        aName = LINE_ATTR_START;
-        break;
-      case SM_SecondPoint:
-        aName = LINE_ATTR_END;
-        break;
-      case SM_DonePoint:
-        aName = XGUI::PROP_PANEL_OK;
-        break;
-      default:
-        break;
-    }
-    emit focusActivated(aName);
-  }
-}
diff --git a/src/PartSet/PartSet_OperationSketchLine.h b/src/PartSet/PartSet_OperationSketchLine.h
deleted file mode 100644 (file)
index cda1781..0000000
+++ /dev/null
@@ -1,160 +0,0 @@
-// File:        PartSet_OperationSketchLine.h
-// Created:     20 Apr 2014
-// Author:      Natalia ERMOLAEVA
-
-#ifndef PartSet_OperationSketchLine_H
-#define PartSet_OperationSketchLine_H
-
-#include "PartSet.h"
-
-#include <PartSet_OperationSketchBase.h>
-#include <QObject>
-
-class GeomDataAPI_Point2D;
-class QMouseEvent;
-class QKeyEvent;
-
-/*!
- \class PartSet_OperationSketchLine
- * \brief The operation for the sketch feature creation
-*/
-class PARTSET_EXPORT PartSet_OperationSketchLine : public PartSet_OperationSketchBase
-{
-  Q_OBJECT
-
-public:
-  /// Returns the operation type key
-  static std::string Type() { return "SketchLine"; }
-
-public:
-  /// Constructor
-  /// \param theId the feature identifier
-  /// \param theParent the operation parent
-  /// \param theFeature the parent feature
-  PartSet_OperationSketchLine(const QString& theId, QObject* theParent,
-                              boost::shared_ptr<ModelAPI_Feature> theSketchFeature);
-  /// Destructor
-  virtual ~PartSet_OperationSketchLine();
-
-  /// Verifies whether this operator can be commited.
-  /// \return Returns TRUE if current operation can be committed, e.g. all parameters are filled
-  virtual bool canBeCommitted() const;
-
-  /// Returns that this operator can be started above already running one.
-   /// The runned operation should be the sketch feature modified operation
-  /// \param theOperation the previous running operation
-  virtual bool isGranted(ModuleBase_IOperation* theOperation) const;
-
-  /// Returns the operation local selection mode
-  /// \param theFeature the feature object to get the selection mode
-  /// \return the selection mode
-  virtual std::list<int> getSelectionModes(boost::shared_ptr<ModelAPI_Feature> theFeature) const;
-
-  /// Initializes some fields accorging to the feature
-  /// \param theSelected the list of selected presentations
-  /// \param theHighlighted the list of highlighted presentations
-  virtual void init(boost::shared_ptr<ModelAPI_Feature> theFeature,
-                    const std::list<XGUI_ViewerPrs>& theSelected,
-                    const std::list<XGUI_ViewerPrs>& theHighlighted);
-
-  /// Returns the operation sketch feature
-  /// \returns the sketch instance
-  virtual boost::shared_ptr<ModelAPI_Feature> sketch() const;
-
-  /// Gives the current selected objects to be processed by the operation
-  /// \param theEvent the mouse event
-  /// \param theView a viewer to have the viewer the eye position
-  /// \param theSelected the list of selected presentations
-  /// \param theHighlighted the list of highlighted presentations
- virtual void mouseReleased(QMouseEvent* theEvent, Handle_V3d_View theView,
-                            const std::list<XGUI_ViewerPrs>& theSelected,
-                            const std::list<XGUI_ViewerPrs>& theHighlighted);
-  /// Gives the current mouse point in the viewer
-  /// \param thePoint a point clicked in the viewer
-  /// \param theEvent the mouse event
-  virtual void mouseMoved(QMouseEvent* theEvent, Handle_V3d_View theView);
-  /// Processes the key pressed in the view
-  /// \param theKey a key value
-  virtual void keyReleased(const int theKey);
-
-  virtual void keyReleased(std::string theName, QKeyEvent* theEvent);
-
-  /// \brief Save the point to the line.
-  /// \param theFeature the line feature
-  /// \param theX the horizontal coordinate
-  /// \param theY the vertical coordinate
-  /// \param theAttribute the start or end attribute of the line
-  static void setLinePoint(boost::shared_ptr<ModelAPI_Feature>, double theX, double theY,
-                           const std::string& theAttribute);
-
-protected:
-  /// \brief Virtual method called when operation is started
-  /// Virtual method called when operation started (see start() method for more description)
-  /// After the parent operation body perform, set sketch feature to the created line feature
-  virtual void startOperation();
-
-  /// Virtual method called when operation aborted (see abort() method for more description)
-  /// Before the feature is aborted, it should be hidden from the viewer
-  virtual void abortOperation();
-
-  /// Virtual method called when operation stopped - committed or aborted.
-  /// Restore the multi selection state
-  virtual void stopOperation();
-
-  /// Virtual method called after operation committed (see commit() method for more description)
-  virtual void afterCommitOperation();
-
-  /// Creates an operation new feature
-  /// In addition to the default realization it appends the created line feature to
-  /// the sketch feature
-  /// \param theFlushMessage the flag whether the create message should be flushed
-  /// \returns the created feature
-  virtual boost::shared_ptr<ModelAPI_Feature> createFeature(const bool theFlushMessage = true);
-
-  /// Creates a constraint on two points
-  /// \param thePoint1 the first point
-  /// \param thePoint1 the second point
-  void createConstraint(boost::shared_ptr<GeomDataAPI_Point2D> thePoint1,
-                        boost::shared_ptr<GeomDataAPI_Point2D> thePoint2);
-
-  /// Creates constrains of the current 
-  /// \param theX the horizontal coordnate of the point
-  /// \param theY the vertical coordnate of the point
-  void setConstraints(double theX, double theY);
-
-protected:
-  /// \brief Get the line point 2d coordinates.
-  /// \param theFeature the line feature
-  /// \param theAttribute the start or end attribute of the line
-  /// \param theX the horizontal coordinate
-  /// \param theY the vertical coordinate
-  void getLinePoint(boost::shared_ptr<ModelAPI_Feature> theFeature, const std::string& theAttribute,
-                    double& theX, double& theY);
-  /// Find a point in the line with given coordinates
-  /// \param theFeature the line feature
-  /// \param theX the horizontal point coordinate
-  /// \param theY the vertical point coordinate
-  boost::shared_ptr<GeomDataAPI_Point2D> findLinePoint(boost::shared_ptr<ModelAPI_Feature> theFeature,
-                                                       double theX, double theY);
-
-  /// \brief Save the point to the line.
-  /// \param thePoint the 3D point in the viewer
-  /// \param theAttribute the start or end attribute of the line
-  void setLinePoint(const gp_Pnt& thePoint, Handle(V3d_View) theView, const std::string& theAttribute);
-
-protected:
-  ///< Structure to lists the possible types of point selection modes
-  enum PointSelectionMode {SM_FirstPoint, SM_SecondPoint, SM_DonePoint};
-
-  ///< Set the point selection mode. Emit signal about focus change if necessary.
-  /// \param theMode a new selection mode
-  /// \param isToEmitSignal the neccessity to emit signal
-  void setPointSelectionMode(const PointSelectionMode& theMode, const bool isToEmitSignal = true);
-
-private:
-  boost::shared_ptr<ModelAPI_Feature> mySketch; ///< the sketch feature
-  boost::shared_ptr<GeomDataAPI_Point2D> myInitPoint; ///< the first line point
-  PointSelectionMode myPointSelectionMode; ///< point selection mode
-};
-
-#endif
diff --git a/src/PartSet/PartSet_Presentation.cpp b/src/PartSet/PartSet_Presentation.cpp
new file mode 100644 (file)
index 0000000..28d9ce3
--- /dev/null
@@ -0,0 +1,150 @@
+// File:        PartSet_Presentation.h
+// Created:     02 June 2014
+// Author:      Natalia ERMOLAEVA
+
+#include <PartSet_Presentation.h>
+#include <PartSet_Tools.h>
+
+#include <ModelAPI_Feature.h>
+#include <ModelAPI_Data.h>
+
+#include <GeomDataAPI_Point.h>
+#include <GeomDataAPI_Point2D.h>
+#include <GeomDataAPI_Dir.h>
+
+#include <SketchPlugin_Sketch.h>
+#include <SketchPlugin_Line.h>
+#include <SketchPlugin_Constraint.h>
+#include <SketchPlugin_ConstraintLength.h>
+
+#include <AIS_InteractiveObject.hxx>
+#include <AIS_LengthDimension.hxx>
+#include <AIS_Shape.hxx>
+
+#include <gp_Pln.hxx>
+#include <gp_Pnt.hxx>
+
+const Quantity_NameOfColor SKETCH_PLANE_COLOR = Quantity_NOC_CHOCOLATE; /// the plane edge color
+const int SKETCH_WIDTH = 4; /// the plane edge width
+
+Handle(AIS_InteractiveObject) PartSet_Presentation::createPresentation(
+                                         FeaturePtr theFeature,
+                                         FeaturePtr theSketch,
+                                         const TopoDS_Shape& theShape,
+                                         Handle_AIS_InteractiveObject thePrevPrs)
+{
+  Handle(AIS_InteractiveObject) anAIS;
+
+  if (theFeature->getKind() == SKETCH_CONSTRAINT_LENGTH_KIND)
+    anAIS = createSketchConstraintLength(theFeature, theSketch, thePrevPrs);
+  else {
+    anAIS = createFeature(theFeature, theShape, thePrevPrs);
+    if (theFeature->getKind() == SKETCH_KIND)
+    {
+      Handle(AIS_Shape) aShapeAIS = Handle(AIS_Shape)::DownCast(anAIS);
+      aShapeAIS->SetColor(Quantity_Color(SKETCH_PLANE_COLOR));
+      aShapeAIS->SetWidth(SKETCH_WIDTH);
+      aShapeAIS->Redisplay();
+    }
+  }
+
+  return anAIS;
+}
+
+Handle(AIS_InteractiveObject) PartSet_Presentation::createFeature(
+                                              FeaturePtr theFeature,
+                                              const TopoDS_Shape& theShape,
+                                              Handle_AIS_InteractiveObject thePrevPrs)
+{
+  Handle(AIS_InteractiveObject) anAIS = thePrevPrs;
+  if (!anAIS.IsNull())
+  {
+    Handle(AIS_Shape) aShapeAIS = Handle(AIS_Shape)::DownCast(anAIS);
+    if (!aShapeAIS.IsNull()) {
+      // if the AIS object is displayed in the opened local context in some mode, additional
+      // AIS sub objects are created there. They should be rebuild for correct selecting.
+      // It is possible to correct it by closing local context before the shape set and opening
+      // after. Another workaround to thrown down the selection and reselecting the AIS.
+      // If there was a problem here, try the first solution with close/open local context.
+      aShapeAIS->Set(theShape);
+      aShapeAIS->Redisplay(Standard_True);
+    }
+  }
+  else
+  {
+    anAIS = new AIS_Shape(theShape);
+  }
+  return anAIS;
+}
+
+Handle(AIS_InteractiveObject) PartSet_Presentation::createSketchConstraintLength(
+                                         FeaturePtr theFeature,
+                                         FeaturePtr theSketch,
+                                         Handle(AIS_InteractiveObject) thePrevPrs)
+{
+  if (!theFeature || !theSketch)
+    return thePrevPrs;
+
+  boost::shared_ptr<ModelAPI_Data> aData = theSketch->data();
+  boost::shared_ptr<GeomDataAPI_Point> anOrigin = 
+    boost::dynamic_pointer_cast<GeomDataAPI_Point>(aData->attribute(SKETCH_ATTR_ORIGIN));
+  boost::shared_ptr<GeomDataAPI_Dir> aNormal = 
+    boost::dynamic_pointer_cast<GeomDataAPI_Dir>(aData->attribute(SKETCH_ATTR_NORM));
+  gp_Pln aPlane(aNormal->x(), aNormal->y(), aNormal->z(), 0/*D*/);
+
+  aData = theFeature->data();
+  boost::shared_ptr<ModelAPI_AttributeRefAttr> anAttr = 
+          boost::dynamic_pointer_cast<ModelAPI_AttributeRefAttr>(aData->attribute(CONSTRAINT_ATTR_ENTITY_A));
+  if (!anAttr)
+    return thePrevPrs;
+  FeaturePtr aFeature = anAttr->feature();
+  if (!aFeature || aFeature->getKind() != SKETCH_LINE_KIND)
+    return thePrevPrs;
+
+  aData = aFeature->data();
+  if (!aData->isValid())
+    return thePrevPrs;
+
+  boost::shared_ptr<GeomDataAPI_Point2D> aPointStart =
+        boost::dynamic_pointer_cast<GeomDataAPI_Point2D>(aData->attribute(LINE_ATTR_START));
+  boost::shared_ptr<GeomDataAPI_Point2D> aPointEnd =
+        boost::dynamic_pointer_cast<GeomDataAPI_Point2D>(aData->attribute(LINE_ATTR_END));
+
+  gp_Pnt aPoint1, aPoint2;
+  PartSet_Tools::convertTo3D(aPointStart->x(), aPointStart->y(), theSketch, aPoint1);
+  PartSet_Tools::convertTo3D(aPointEnd->x(), aPointEnd->y(), theSketch, aPoint2);
+
+  //Build dimension here
+  gp_Pnt aP1 = aPoint1;
+  gp_Pnt aP2 = aPoint2;
+
+  Handle(AIS_InteractiveObject) anAIS = thePrevPrs;
+  if (anAIS.IsNull())
+  {
+    Handle(AIS_LengthDimension) aLenDim = new AIS_LengthDimension (aP1, aP2, aPlane);
+
+    Handle(Prs3d_DimensionAspect) anAspect = new Prs3d_DimensionAspect();
+    anAspect->MakeArrows3d (Standard_False);
+    anAspect->MakeText3d(false/*is text 3d*/);
+    anAspect->TextAspect()->SetHeight(28);
+    anAspect->MakeTextShaded(false/*is test shaded*/);
+    aLenDim->DimensionAspect()->MakeUnitsDisplayed(false/*is units displayed*/);
+    /*if (isUnitsDisplayed)
+    {
+      aLenDim->SetDisplayUnits (aDimDlg->GetUnits ());
+    }*/
+    aLenDim->SetDimensionAspect (anAspect);
+    aLenDim->SetFlyout(12);
+
+    anAIS = aLenDim;
+  }
+  else {
+    // update presentation
+    Handle(AIS_LengthDimension) aDimAIS = Handle(AIS_LengthDimension)::DownCast(anAIS);
+    if (!aDimAIS.IsNull()) {
+      aDimAIS->SetMeasuredGeometry(aPoint1, aPoint2, aPlane);
+      aDimAIS->Redisplay(Standard_True);
+    }
+  }
+  return anAIS;
+}
diff --git a/src/PartSet/PartSet_Presentation.h b/src/PartSet/PartSet_Presentation.h
new file mode 100644 (file)
index 0000000..8e4b2ae
--- /dev/null
@@ -0,0 +1,45 @@
+// File:        PartSet_Presentation.h
+// Created:     02 Jun 2014
+// Author:      Natalia ERMOLAEVA
+
+#ifndef PartSet_Presentation_H
+#define PartSet_Presentation_H
+
+#include "PartSet.h"
+
+#include <TopoDS_Shape.hxx>
+
+#include <ModelAPI_Feature.h>
+
+#include <boost/shared_ptr.hpp>
+
+class Handle_AIS_InteractiveObject;
+
+/*!
+ \class PartSet_Presentation
+ * \brief The operation for the sketch feature creation
+*/
+class PARTSET_EXPORT PartSet_Presentation
+{
+public:
+  /// Creates AIS presentation for the given feature
+  /// \param theFeature a feature
+  /// \return the presentation
+  static Handle_AIS_InteractiveObject createPresentation(
+                                              FeaturePtr theFeature,
+                                              FeaturePtr theSketch,
+                                              const TopoDS_Shape& theShape,
+                                              Handle_AIS_InteractiveObject thePrevPrs);
+protected:
+  static Handle_AIS_InteractiveObject createFeature(
+                                              FeaturePtr theFeature,
+                                              const TopoDS_Shape& theShape,
+                                              Handle_AIS_InteractiveObject thePrevPrs);
+
+  static Handle_AIS_InteractiveObject createSketchConstraintLength(
+                                              FeaturePtr theFeature,
+                                              FeaturePtr theSketch,
+                                              Handle_AIS_InteractiveObject thePrevPrs);
+};
+
+#endif
index 60798a78beae046b0a02c73e2740e7672321e81b..ef0ea9a751c6a52df8850d1fd16c5a85c08cd61a 100644 (file)
@@ -9,7 +9,9 @@
 #include <XGUI_Displayer.h>
 #include <XGUI_ViewerPrs.h>
 #include <XGUI_ViewerProxy.h>
-#include <PartSet_OperationSketchLine.h>
+#include <PartSet_FeaturePrs.h>
+#include <PartSet_Presentation.h>
+#include <PartSet_OperationSketchBase.h>
 
 #include <ModelAPI_Feature.h>
 
@@ -17,7 +19,7 @@
 #include <ModelAPI_Document.h>
 
 static double myTestDelta;
-static boost::shared_ptr<ModelAPI_Feature> myTestFeature;
+static FeaturePtr myTestFeature;
 
 #include <AIS_InteractiveContext.hxx>
 #include <AIS_Shape.hxx>
@@ -36,7 +38,7 @@ void PartSet_TestOCC::testSelection(XGUI_Workshop* theWorkshop)
                                theWorkshop->viewer()->activeView());
     PartSet_TestOCC::changeTestLine(theWorkshop);
   }
-  Handle(AIS_InteractiveObject) anIO = theWorkshop->displayer()->GetAISObject(myTestFeature);
+  Handle(AIS_InteractiveObject) anIO = theWorkshop->displayer()->getAISObject(myTestFeature);
   if (!anIO.IsNull()) {
     theWorkshop->viewer()->AISContext()->MoveTo(0, 0, theWorkshop->viewer()->activeView());
     theWorkshop->viewer()->AISContext()->Select(0, 0, 2500, 2500, theWorkshop->viewer()->activeView());
@@ -126,13 +128,12 @@ void PartSet_TestOCC::createTestLine(XGUI_Workshop* theWorkshop)
 
   ModuleBase_Operation* anOperation = theWorkshop->operationMgr()->currentOperation();
   PartSet_OperationSketchBase* aPreviewOp = dynamic_cast<PartSet_OperationSketchBase*>(anOperation);
-    boost::shared_ptr<ModelAPI_Feature> aSketch;
+    FeaturePtr aSketch;
 
   if (aPreviewOp) {
     // create a line
     boost::shared_ptr<ModelAPI_Document> aDoc = ModelAPI_PluginManager::get()->rootDocument();
-    boost::shared_ptr<ModelAPI_Feature> aFeature = aDoc->addFeature(
-                                                   PartSet_OperationSketchLine::Type().c_str());
+    FeaturePtr aFeature = aDoc->addFeature(SKETCH_LINE_KIND);
     if (aFeature) // TODO: generate an error if feature was not created
       aFeature->execute();
 
@@ -140,27 +141,37 @@ void PartSet_TestOCC::createTestLine(XGUI_Workshop* theWorkshop)
                         boost::dynamic_pointer_cast<SketchPlugin_Feature>(aPreviewOp->sketch());
     aSketch->addSub(aFeature);
 
-    PartSet_OperationSketchLine::setLinePoint(aFeature, 100, 100, LINE_ATTR_START);
-    PartSet_OperationSketchLine::setLinePoint(aFeature, 150, 300, LINE_ATTR_END);
+    PartSet_FeaturePrs::setLinePoint(aFeature, 100, 100, LINE_ATTR_START);
+    PartSet_FeaturePrs::setLinePoint(aFeature, 150, 300, LINE_ATTR_END);
 
-    boost::shared_ptr<GeomAPI_Shape> aPreview = PartSet_OperationSketchLine::preview(aFeature);
+    boost::shared_ptr<GeomAPI_Shape> aPreview = PartSet_OperationSketchBase::preview(aFeature);
 
     XGUI_Displayer* aDisplayer = theWorkshop->displayer();
-    aDisplayer->Redisplay(aFeature, aPreview ? aPreview->impl<TopoDS_Shape>() : TopoDS_Shape(), false);
+
+    Handle(AIS_InteractiveObject) anAIS = PartSet_Presentation::createPresentation(
+                           aFeature, aSketch,
+                           aPreview ? aPreview->impl<TopoDS_Shape>() : TopoDS_Shape(), NULL);
+    if (!anAIS.IsNull())
+      aDisplayer->redisplay(aFeature, anAIS, -1, false);
+
     std::list<int> aModes;
     aModes.push_back(TopAbs_VERTEX);
     aModes.push_back(TopAbs_EDGE);
-    aDisplayer->ActivateInLocalContext(aFeature, aModes, true);
+    aDisplayer->activateInLocalContext(aFeature, aModes, true);
 
     // change the line
     /*double aDelta = -200;
     for (int i = 0; i < 20; i++) {
       aDelta = aDelta - i*2;
-      PartSet_OperationSketchLine::setLinePoint(aFeature, 100+aDelta, 200+aDelta, LINE_ATTR_START);
-      PartSet_OperationSketchLine::setLinePoint(aFeature, 300+aDelta, 500+aDelta, LINE_ATTR_END);
-      boost::shared_ptr<GeomAPI_Shape> aPreview = PartSet_OperationSketchLine::preview(aFeature);
+      PartSet_FeaturePrs::setLinePoint(aFeature, 100+aDelta, 200+aDelta, LINE_ATTR_START);
+      PartSet_FeaturePrs::setLinePoint(aFeature, 300+aDelta, 500+aDelta, LINE_ATTR_END);
 
-      theWorkshop->displayer()->Redisplay(aFeature, aPreview ? aPreview->impl<TopoDS_Shape>() : TopoDS_Shape(), true);
+      boost::shared_ptr<GeomAPI_Shape> aPreview = PartSet_OperationSketchBase::preview(aFeature);
+      Handle(AIS_InteractiveObject) anAIS = PartSet_Presentation::createPresentation(
+                             aFeature, aSketch,
+                             aPreview ? aPreview->impl<TopoDS_Shape>() : TopoDS_Shape(), NULL);
+      if (!anAIS.IsNull())
+        aDisplayer->redisplay(aFeature, anAIS, -1, true);
 
       int aVal = 90;
       for (int j = 0; j < 10000000; j++)
@@ -170,12 +181,12 @@ void PartSet_TestOCC::createTestLine(XGUI_Workshop* theWorkshop)
     //aModes.clear();
     //aModes.push_back(TopAbs_VERTEX);
     //aModes.push_back(TopAbs_EDGE);
-    //aDisplayer->ActivateInLocalContext(aFeature, aModes, true);
+    //aDisplayer->activateInLocalContext(aFeature, aModes, true);
     myTestFeature = aFeature;
 
     std::list<XGUI_ViewerPrs> aPrs;
-    aPrs.push_back(XGUI_ViewerPrs(myTestFeature, TopoDS_Shape()));
-    aDisplayer->SetSelected(aPrs, true);
+    aPrs.push_back(XGUI_ViewerPrs(myTestFeature, TopoDS_Shape(), NULL));
+    aDisplayer->setSelected(aPrs, true);
   }
 }
 
@@ -184,26 +195,33 @@ void PartSet_TestOCC::changeTestLine(XGUI_Workshop* theWorkshop)
   // change the line
   if (!myTestFeature)
     return;
-  boost::shared_ptr<ModelAPI_Feature> aFeature = myTestFeature;
+  FeaturePtr aFeature = myTestFeature;
 
   myTestDelta = myTestDelta - 50;
   double aDelta = myTestDelta;
-  PartSet_OperationSketchLine::setLinePoint(aFeature, -100/*aDelta*/, -100/*aDelta*/, LINE_ATTR_START);
-  PartSet_OperationSketchLine::setLinePoint(aFeature, 200/*aDelta*2*/, 200/*aDelta*2*/, LINE_ATTR_END);
-  boost::shared_ptr<GeomAPI_Shape> aPreview = PartSet_OperationSketchLine::preview(aFeature);
-
-  theWorkshop->displayer()->Redisplay(aFeature, aPreview ? aPreview->impl<TopoDS_Shape>() : TopoDS_Shape(), true);
+  PartSet_FeaturePrs::setLinePoint(aFeature, -100/*aDelta*/, -100/*aDelta*/, LINE_ATTR_START);
+  PartSet_FeaturePrs::setLinePoint(aFeature, 200/*aDelta*2*/, 200/*aDelta*2*/, LINE_ATTR_END);
+  boost::shared_ptr<GeomAPI_Shape> aPreview = PartSet_OperationSketchBase::preview(aFeature);
+
+  Handle(AIS_InteractiveObject) aPrevAIS;
+  FeaturePtr aSketch;//NULL
+  Handle(AIS_InteractiveObject) anAIS = PartSet_Presentation::createPresentation(
+                          aFeature, aSketch,
+                          aPreview ? aPreview->impl<TopoDS_Shape>() : TopoDS_Shape(),
+                          aPrevAIS);
+  if (!anAIS.IsNull())
+    theWorkshop->displayer()->redisplay(aFeature, anAIS, -1, true);
   //std::list<int> aModes;
   //aModes.clear();
   //aModes.push_back(TopAbs_VERTEX);
   //aModes.push_back(TopAbs_EDGE);
-  //aDisplayer->ActivateInLocalContext(aFeature, aModes, true);
+  //aDisplayer->activateInLocalContext(aFeature, aModes, true);
 
   /*std::list<XGUI_ViewerPrs> aPrs;
   aPrs.push_back(XGUI_ViewerPrs(myTestFeature, TopoDS_Shape()));
-  theWorkshop->displayer()->SetSelected(aPrs, true);*/
+  theWorkshop->displayer()->setSelected(aPrs, true);*/
 
-  theWorkshop->displayer()->UpdateViewer();
+  theWorkshop->displayer()->updateViewer();
 }
 
 void PartSet_TestOCC::moveMouse(Handle(AIS_InteractiveContext) theContext, Handle(V3d_View) theView)
index 2c7a93b069bab6d65eaaab70c0fd1612d4444d42..ae51d7b20a6d788ba94f9861169852ba8fe787e1 100644 (file)
@@ -32,7 +32,7 @@
 
 const double PRECISION_TOLERANCE = 0.000001;
 
-gp_Pnt PartSet_Tools::ConvertClickToPoint(QPoint thePoint, Handle(V3d_View) theView)
+gp_Pnt PartSet_Tools::convertClickToPoint(QPoint thePoint, Handle(V3d_View) theView)
 {
   if (theView.IsNull())
     return gp_Pnt();
@@ -57,7 +57,7 @@ gp_Pnt PartSet_Tools::ConvertClickToPoint(QPoint thePoint, Handle(V3d_View) theV
   return ResultPoint;
 }
 
-void PartSet_Tools::ConvertTo2D(const gp_Pnt& thePoint, boost::shared_ptr<ModelAPI_Feature> theSketch,
+void PartSet_Tools::convertTo2D(const gp_Pnt& thePoint, FeaturePtr theSketch,
                                 Handle(V3d_View) theView, double& theX, double& theY)
 {
   if (!theSketch)
@@ -103,7 +103,30 @@ void PartSet_Tools::ConvertTo2D(const gp_Pnt& thePoint, boost::shared_ptr<ModelA
   theY = aVec.X() * anY->x() + aVec.Y() * anY->y() + aVec.Z() * anY->z();
 }
 
-void PartSet_Tools::IntersectLines(double theX0, double theY0, double theX1, double theY1,
+void PartSet_Tools::convertTo3D(const double theX, const double theY,
+                                FeaturePtr theSketch,
+                                gp_Pnt& thePoint)
+{
+  if (!theSketch)
+    return;
+
+  boost::shared_ptr<ModelAPI_Data> aData = theSketch->data();
+
+  boost::shared_ptr<GeomDataAPI_Point> aC = 
+    boost::dynamic_pointer_cast<GeomDataAPI_Point>(aData->attribute(SKETCH_ATTR_ORIGIN));
+  boost::shared_ptr<GeomDataAPI_Dir> aX = 
+    boost::dynamic_pointer_cast<GeomDataAPI_Dir>(aData->attribute(SKETCH_ATTR_DIRX));
+  boost::shared_ptr<GeomDataAPI_Dir> aY = 
+    boost::dynamic_pointer_cast<GeomDataAPI_Dir>(aData->attribute(SKETCH_ATTR_DIRY));
+
+  boost::shared_ptr<GeomAPI_XYZ> aSum = aC->pnt()->xyz()->added(
+    aX->dir()->xyz()->multiplied(theX))->added(aY->dir()->xyz()->multiplied(theY));
+
+  boost::shared_ptr<GeomAPI_Pnt> aPoint = boost::shared_ptr<GeomAPI_Pnt>(new GeomAPI_Pnt(aSum));
+  thePoint = gp_Pnt(aPoint->x(), aPoint->y(), aPoint->z());
+}
+
+void PartSet_Tools::intersectLines(double theX0, double theY0, double theX1, double theY1,
                                    double theX2, double theY2, double theX3, double theY3,
                                    double& theX, double& theY)
 {
@@ -123,11 +146,11 @@ void PartSet_Tools::IntersectLines(double theX0, double theY0, double theX1, dou
   //It is not possible to use Precision::Confusion(), because it is e-0.8, but V is sometimes e-6
   Standard_Real aPrec = PRECISION_TOLERANCE;
   if (fabs(theX - theX0) < aPrec && fabs(theY - theY0) < aPrec) {
-    ProjectPointOnLine(theX2, theY2, theX3, theY3, theX1, theY1, theX, theY);    
+    projectPointOnLine(theX2, theY2, theX3, theY3, theX1, theY1, theX, theY);    
   }
 }
 
-void PartSet_Tools::ProjectPointOnLine(double theX1, double theY1, double theX2, double theY2,
+void PartSet_Tools::projectPointOnLine(double theX1, double theY1, double theX2, double theY2,
                                        double thePointX, double thePointY, double& theX, double& theY)
 {
   theX = theY = 0;
@@ -144,26 +167,26 @@ void PartSet_Tools::ProjectPointOnLine(double theX1, double theY1, double theX2,
   }
 }
 
-boost::shared_ptr<ModelAPI_Feature> PartSet_Tools::NearestFeature(QPoint thePoint,
+FeaturePtr PartSet_Tools::nearestFeature(QPoint thePoint,
                                                    Handle_V3d_View theView,
-                                                   boost::shared_ptr<ModelAPI_Feature> theSketch,
+                                                   FeaturePtr theSketch,
                                                    const std::list<XGUI_ViewerPrs>& theFeatures)
 {
   double aX, anY;
-  gp_Pnt aPoint = PartSet_Tools::ConvertClickToPoint(thePoint, theView);
-  PartSet_Tools::ConvertTo2D(aPoint, theSketch, theView, aX, anY);
+  gp_Pnt aPoint = PartSet_Tools::convertClickToPoint(thePoint, theView);
+  PartSet_Tools::convertTo2D(aPoint, theSketch, theView, aX, anY);
 
-  boost::shared_ptr<ModelAPI_Feature> aFeature;
+  FeaturePtr aFeature;
   std::list<XGUI_ViewerPrs>::const_iterator anIt = theFeatures.begin(), aLast = theFeatures.end();
 
-  boost::shared_ptr<ModelAPI_Feature> aDeltaFeature;   
+  FeaturePtr aDeltaFeature;   
   double aMinDelta = -1;
   XGUI_ViewerPrs aPrs;
   for (; anIt != aLast; anIt++) {
     aPrs = *anIt;
     if (!aPrs.feature())
       continue;
-    double aDelta = DistanceToPoint(aPrs.feature(), aX, anY);
+    double aDelta = distanceToPoint(aPrs.feature(), aX, anY);
     if (aMinDelta < 0 || aMinDelta > aDelta) {
       aMinDelta = aDelta;
       aDeltaFeature = aPrs.feature();
@@ -172,11 +195,11 @@ boost::shared_ptr<ModelAPI_Feature> PartSet_Tools::NearestFeature(QPoint thePoin
   return aDeltaFeature;
 }
 
-double PartSet_Tools::DistanceToPoint(boost::shared_ptr<ModelAPI_Feature> theFeature,
+double PartSet_Tools::distanceToPoint(FeaturePtr theFeature,
                                       double theX, double theY)
 {
   double aDelta = 0;
-  if (theFeature->getKind() != "SketchLine")
+  if (theFeature->getKind() != SKETCH_LINE_KIND)
     return aDelta;
 
   boost::shared_ptr<ModelAPI_Data> aData = theFeature->data();
@@ -187,7 +210,7 @@ double PartSet_Tools::DistanceToPoint(boost::shared_ptr<ModelAPI_Feature> theFea
         boost::dynamic_pointer_cast<GeomDataAPI_Point2D>(aData->attribute(LINE_ATTR_END));
 
   double aX, anY;
-  PartSet_Tools::ProjectPointOnLine(aPoint1->x(), aPoint1->y(), aPoint2->x(), aPoint2->y(), theX, theY, aX, anY);
+  PartSet_Tools::projectPointOnLine(aPoint1->x(), aPoint1->y(), aPoint2->x(), aPoint2->y(), theX, theY, aX, anY);
 
   aDelta = gp_Pnt(theX, theY, 0).Distance(gp_Pnt(aX, anY, 0));
 
index 957585b2666dca460af873a780ded28db3174d94..c8fa3066094b9a748b11716dfd5b6e9251ad1a88 100644 (file)
 
 #include <QPoint>
 
+#include <ModelAPI_Feature.h>
+
 #include <boost/shared_ptr.hpp>
 
 #include <list>
 
 class Handle_V3d_View;
-class ModelAPI_Feature;
 class XGUI_ViewerPrs;
 
 /*!
@@ -29,16 +30,25 @@ public:
   /// Converts the 2D screen point to the 3D point on the view according to the point of view
   /// \param thePoint a screen point
   /// \param theView a 3D view
-  static gp_Pnt ConvertClickToPoint(QPoint thePoint, Handle_V3d_View theView);
+  static gp_Pnt convertClickToPoint(QPoint thePoint, Handle_V3d_View theView);
 
   /// \brief Converts the 3D point to the projected coodinates on the sketch plane.
   /// \param thePoint the 3D point in the viewer
   /// \param theSketch the sketch feature
   /// \param theX the X coordinate
   /// \param theY the Y coordinate
-  static void ConvertTo2D(const gp_Pnt& thePoint, boost::shared_ptr<ModelAPI_Feature> theSketch,
+  static void convertTo2D(const gp_Pnt& thePoint, FeaturePtr theSketch,
                           Handle(V3d_View) theView, double& theX, double& theY);
 
+  /// \brief Converts the 2D projected coodinates on the sketch plane to the 3D point.
+  /// \param theX the X coordinate
+  /// \param theY the Y coordinate
+  /// \param theSketch the sketch feature
+  /// \param thePoint the 3D point in the viewer
+  static void convertTo3D(const double theX, const double theY,
+                          FeaturePtr theSketch,
+                          gp_Pnt& thePoint);
+
   /// Returns the point of intersection of the two lines, the first is (v0, v1), the second is (v2, v3),
   /// where vi - {xi,yi}. If the v0 is on the second line, the result is a projection of the v1 to this line
   /// \param theX0 the horizontal coordinate of 0 point
@@ -51,7 +61,7 @@ public:
   /// \param theY3 the vertical coordinate of 3 point
   /// \param theX the output horizontal coordinate of the intersection point
   /// \param theY the outpup vertical coordinate of the intersection point
-  static void IntersectLines(double theX0, double theY0, double theX1, double theY1,
+  static void intersectLines(double theX0, double theY0, double theX1, double theY1,
                              double theX2, double theY2, double theX3, double theY3,
                              double& theX, double& theY);
 
@@ -62,7 +72,7 @@ public:
   /// \param theY1 the vertical coordinate of the first line point
   /// \param theX2 the horizontal coordinate of the second line point
   /// \param theY2 the vertical coordinate of the second line point
-  static void ProjectPointOnLine(double theX1, double theY1, double theX2, double theY2,
+  static void projectPointOnLine(double theX1, double theY1, double theX2, double theY2,
                                  double thePointX, double thePointY, double& theX, double& theY);
 
   /// Returns a feature that is under the mouse point
@@ -70,15 +80,15 @@ public:
   /// \param theView a 3D view
   /// \param theSketch the sketch feature
   /// \param theFeatures the list of selected presentations
-  static boost::shared_ptr<ModelAPI_Feature> NearestFeature(QPoint thePoint, Handle_V3d_View theView,
-                                                     boost::shared_ptr<ModelAPI_Feature> theSketch,
+  static FeaturePtr nearestFeature(QPoint thePoint, Handle_V3d_View theView,
+                                                     FeaturePtr theSketch,
                                                      const std::list<XGUI_ViewerPrs>& theFeatures);
 private:
   /// Return the distance between the feature and the point
   /// \param theFeature feature object
   /// \param theX the horizontal coordinate of the point
   /// \param theX the vertical coordinate of the point
-  static double DistanceToPoint(boost::shared_ptr<ModelAPI_Feature> theFeature,
+  static double distanceToPoint(FeaturePtr theFeature,
                                 double theX, double theY);
 };
 
index eaae463ad2831260dc75a595e9c8a761f645e09c..0f921727129f03036314e6d9531f8d53df209728 100644 (file)
@@ -8,6 +8,9 @@
 #include "PartSetPlugin.h"
 #include <ModelAPI_Feature.h>
 
+/// Part kind
+const std::string PARTSET_PART_KIND("Part");
+
 /// part reference attribute
 const std::string PART_ATTR_DOC_REF = "PartDocument";
 
@@ -20,7 +23,7 @@ class PartSetPlugin_Part: public ModelAPI_Feature
 public:
   /// Returns the kind of a feature
   PARTSETPLUGIN_EXPORT virtual const std::string& getKind() 
-  {static std::string MY_KIND = "Part"; return MY_KIND;}
+  {static std::string MY_KIND = PARTSET_PART_KIND; return MY_KIND;}
 
   /// Returns to which group in the document must be added feature
   PARTSETPLUGIN_EXPORT virtual const std::string& getGroup() 
index 76ea7b441c0f6ae5375b48bdb1ed5c4bc498ddcc..4ba7fa5cac1e2e1b8193232b6f06d39cd4107486 100644 (file)
@@ -16,17 +16,17 @@ PartSetPlugin_Plugin::PartSetPlugin_Plugin()
   ModelAPI_PluginManager::get()->registerPlugin(this);
 }
 
-boost::shared_ptr<ModelAPI_Feature> PartSetPlugin_Plugin::createFeature(string theFeatureID)
+FeaturePtr PartSetPlugin_Plugin::createFeature(string theFeatureID)
 {
-  if (theFeatureID == "Part") {
-    return boost::shared_ptr<ModelAPI_Feature>(new PartSetPlugin_Part);
+  if (theFeatureID == PARTSET_PART_KIND) {
+    return FeaturePtr(new PartSetPlugin_Part);
   }
   if (theFeatureID == "duplicate") {
-    return boost::shared_ptr<ModelAPI_Feature>(new PartSetPlugin_Duplicate);
+    return FeaturePtr(new PartSetPlugin_Duplicate);
   }
   if (theFeatureID == "remove") {
-    return boost::shared_ptr<ModelAPI_Feature>(new PartSetPlugin_Remove);
+    return FeaturePtr(new PartSetPlugin_Remove);
   }
     // feature of such kind is not found
-  return boost::shared_ptr<ModelAPI_Feature>();
+  return FeaturePtr();
 }
index ff577f79a3adec8e2003a43ece502a805e536255..d1ccd314b37f5f138a97b6b5122b469f50d1fad1 100644 (file)
@@ -8,12 +8,13 @@
 
 #include "PartSetPlugin.h"
 #include "ModelAPI_Plugin.h"
+#include "ModelAPI_Feature.h"
 
 class PARTSETPLUGIN_EXPORT PartSetPlugin_Plugin: public ModelAPI_Plugin
 {
 public:
   /// Creates the feature object of this plugin by the feature string ID
-  virtual boost::shared_ptr<ModelAPI_Feature> createFeature(std::string theFeatureID);
+  virtual FeaturePtr createFeature(std::string theFeatureID);
 
 public:
   /// Is needed for python wrapping by swig
index 5e99cb1f9a8734f5c318133546e6f65e740f5e46..0e09f3a607b7e440cbfe3a49fbfffd25cdbf440a 100644 (file)
@@ -15,8 +15,8 @@ void PartSetPlugin_Remove::execute()
   boost::shared_ptr<ModelAPI_Document> aCurrent;
   boost::shared_ptr<PartSetPlugin_Part> a;
   for(int a = aRoot->size(getGroup()) - 1; a >= 0; a--) {
-    boost::shared_ptr<ModelAPI_Feature> aFeature = aRoot->feature(getGroup(), a, true);
-    if (aFeature->getKind() == "Part") {
+    FeaturePtr aFeature = aRoot->feature(getGroup(), a, true);
+    if (aFeature->getKind() == PARTSET_PART_KIND) {
       boost::shared_ptr<PartSetPlugin_Part> aPart = 
         boost::static_pointer_cast<PartSetPlugin_Part>(aFeature);
       if (aPart->data()->docRef(PART_ATTR_DOC_REF)->value() == aPManager->currentDocument()) {
index f12066c3e24a6de8ba8ac71d5e816344de68f9ac..87b7e258ce768a0524cdddb9cd9caa1e50e7dcd9 100644 (file)
@@ -8,6 +8,9 @@
 #include "PartSetPlugin.h"
 #include <ModelAPI_Feature.h>
 
+/// Extrusion kind
+const std::string PARTSET_REMOVE_KIND("Remove");
+
 /**\class PartSetPlugin_Remove
  * \ingroup DataModel
  * \brief Feature for creation of the new part in PartSet.
@@ -17,7 +20,7 @@ class PartSetPlugin_Remove: public ModelAPI_Feature
 public:
   /// Returns the kind of a feature
   PARTSETPLUGIN_EXPORT virtual const std::string& getKind() 
-  {static std::string MY_KIND = "Remove"; return MY_KIND;}
+  {static std::string MY_KIND = PARTSET_REMOVE_KIND; return MY_KIND;}
 
   /// Returns to which group in the document must be added feature
   PARTSETPLUGIN_EXPORT virtual const std::string& getGroup() 
index 9a4d7cf766d9adef77756ab45bf4048da12d68cd..5c0f982e96249ddbc0e79d328200924c9656b1c2 100644 (file)
@@ -40,8 +40,12 @@ SET(PROJECT_LIBRARIES
     ModelAPI
 )
 
+SET(XML_RESOURCES
+  plugin-Sketch.xml
+)
+
 ADD_DEFINITIONS(-DSKETCHPLUGIN_EXPORTS ${BOOST_DEFINITIONS})
-ADD_LIBRARY(SketchPlugin MODULE ${PROJECT_SOURCES} ${PROJECT_HEADERS})
+ADD_LIBRARY(SketchPlugin MODULE ${PROJECT_SOURCES} ${PROJECT_HEADERS} ${XML_RESOURCES})
 TARGET_LINK_LIBRARIES(SketchPlugin ${PROJECT_LIBRARIES})
 
 INCLUDE_DIRECTORIES(
@@ -51,9 +55,5 @@ INCLUDE_DIRECTORIES(
   ../GeomDataAPI
 )
 
-SET(XML_RESOURCES
-  plugin-Sketch.xml
-)
-
 INSTALL(TARGETS SketchPlugin DESTINATION plugins)
 INSTALL(FILES ${XML_RESOURCES} DESTINATION plugins)
index f22e92b4cd82222fcd87a9872af74f5b63f0c33a..928a7608347f7af73e96125bfc43c30965e559e4 100644 (file)
@@ -7,6 +7,10 @@
 
 #include "SketchPlugin.h"
 #include <SketchPlugin_Feature.h>
+#include <SketchPlugin_Sketch.h>
+
+/// Arc feature kind
+const std::string SKETCH_ARC_KIND("SketchArc");
 
 /// Central 2D point of the circle which contains the arc
 const std::string ARC_ATTR_CENTER("ArcCenter");
@@ -24,11 +28,11 @@ class SketchPlugin_Arc: public SketchPlugin_Feature
 public:
   /// Returns the kind of a feature
   SKETCHPLUGIN_EXPORT virtual const std::string& getKind()
-  {static std::string MY_KIND = "SketchArc"; return MY_KIND;}
+  {static std::string MY_KIND = SKETCH_ARC_KIND; 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;}
+  {static std::string MY_GROUP = SKETCH_KIND; return MY_GROUP;}
 
   /// Creates a new part document if needed
   SKETCHPLUGIN_EXPORT virtual void execute();
@@ -42,7 +46,7 @@ public:
   /// 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) {};
+    const FeaturePtr& theFeature) {};
 
   /// Use plugin manager for features creation
   SketchPlugin_Arc();
index 18fa1e71f94ce1db6a85076d2e68ef1fbfcd7faf..10fee4f7bba9f27b1c453d745528138dcced52d9 100644 (file)
@@ -7,6 +7,10 @@
 
 #include "SketchPlugin.h"
 #include <SketchPlugin_Feature.h>
+#include <SketchPlugin_Sketch.h>
+
+/// Circle feature kind
+const std::string SKETCH_CIRCLE_KIND("SketchCircle");
 
 /// 2D point - center of the circle
 const std::string CIRCLE_ATTR_CENTER("CircleCenter");
@@ -22,11 +26,11 @@ class SketchPlugin_Circle: public SketchPlugin_Feature
 public:
   /// Returns the kind of a feature
   SKETCHPLUGIN_EXPORT virtual const std::string& getKind() 
-  {static std::string MY_KIND = "SketchCircle"; return MY_KIND;}
+  {static std::string MY_KIND = SKETCH_CIRCLE_KIND; 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;}
+  {static std::string MY_GROUP = SKETCH_KIND; return MY_GROUP;}
 
   /// Creates a new part document if needed
   SKETCHPLUGIN_EXPORT virtual void execute();
@@ -40,7 +44,7 @@ public:
   /// 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) {};
+    const FeaturePtr& theFeature) {};
 
   /// Use plugin manager for features creation
   SketchPlugin_Circle();
index 98680830ae87b92b2152e7d2cb45b0ad72d4fd29..b4e8bcca6aac2b5496e6e547cbd8e37651ed7654 100644 (file)
@@ -7,6 +7,7 @@
 
 #include "SketchPlugin.h"
 #include "SketchPlugin_Feature.h"
+#include <SketchPlugin_Sketch.h>
 #include <ModelAPI_AttributeReference.h>
 #include <ModelAPI_AttributeRefAttr.h>
 #include <list>
@@ -48,19 +49,15 @@ const std::string CONSTRAINT_ATTRIBUTES[CONSTRAINT_ATTR_SIZE] =
 class SketchPlugin_Constraint: public SketchPlugin_Feature
 {
 public:
-  /// \brief Returns the kind of a feature
-  SKETCHPLUGIN_EXPORT virtual const std::string& getKind()
-  {static std::string MY_KIND = "SketchConstraint"; return MY_KIND;}
-
   /// \brief 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;}
+  {static std::string MY_GROUP = SKETCH_KIND; return MY_GROUP;}
 
   /** \brief 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) {}
+    const FeaturePtr& theFeature) {}
 
 protected:
   /// \brief Use plugin manager for features creation
index 1c5f2adf37c7f437c787c343f7826df9b416adbd..5da46cf8801ae0f1e8f1b3b9d0b32a5e957bd57c 100644 (file)
@@ -7,8 +7,11 @@
 
 #include "SketchPlugin.h"
 #include "SketchPlugin_Constraint.h"
+#include <SketchPlugin_Sketch.h>
 #include <list>
 
+/// Coincidence constraint kind
+const std::string SKETCH_CONSTRAINT_COINCIDENCE_KIND("SketchConstraintCoincidence");
 
 /** \class SketchPlugin_ConstraintCoincidence
  *  \ingroup DataModel
@@ -22,11 +25,11 @@ class SketchPlugin_ConstraintCoincidence: public SketchPlugin_Constraint
 public:
   /// \brief Returns the kind of a feature
   SKETCHPLUGIN_EXPORT virtual const std::string& getKind() 
-  {static std::string MY_KIND = "SketchConstraintCoincidence"; return MY_KIND;}
+  {static std::string MY_KIND = SKETCH_CONSTRAINT_COINCIDENCE_KIND; return MY_KIND;}
 
   /// \brief 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;}
+  {static std::string MY_GROUP = SKETCH_KIND; return MY_GROUP;}
 
   /// \brief Creates a new part document if needed
   SKETCHPLUGIN_EXPORT virtual void execute();
index 4295e8c2dee1d9dba731c92d9d00c33a5276d342..1a90e2dd3c5516c3cb585036c0b284d3d074c2cb 100644 (file)
@@ -7,8 +7,11 @@
 
 #include "SketchPlugin.h"
 #include "SketchPlugin_Constraint.h"
+#include <SketchPlugin_Sketch.h>
 #include <list>
 
+/// Distance constraint kind
+const std::string SKETCH_CONSTRAINT_DISTANCE_KIND("SketchConstraintDistance");
 
 /** \class SketchPlugin_ConstraintDistance
  *  \ingroup DataModel
@@ -23,11 +26,11 @@ class SketchPlugin_ConstraintDistance: public SketchPlugin_Constraint
 public:
   /// \brief Returns the kind of a feature
   SKETCHPLUGIN_EXPORT virtual const std::string& getKind() 
-  {static std::string MY_KIND = "SketchConstraintDistance"; return MY_KIND;}
+  {static std::string MY_KIND = SKETCH_CONSTRAINT_DISTANCE_KIND; return MY_KIND;}
 
   /// \brief 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;}
+  {static std::string MY_GROUP = SKETCH_KIND; return MY_GROUP;}
 
   /// \brief Creates a new part document if needed
   SKETCHPLUGIN_EXPORT virtual void execute();
index 3e4cde4a0ad980e395bcb843592daf4a8aef9d21..bc614e137ad3bf22c24931359d5763635e762cf4 100644 (file)
@@ -7,8 +7,11 @@
 
 #include "SketchPlugin.h"
 #include "SketchPlugin_Constraint.h"
+#include <SketchPlugin_Sketch.h>
 #include <list>
 
+/// Length constraint kind
+const std::string SKETCH_CONSTRAINT_LENGTH_KIND("SketchConstraintLength");
 
 /** \class SketchPlugin_ConstraintLength
  *  \ingroup DataModel
@@ -22,11 +25,11 @@ class SketchPlugin_ConstraintLength: public SketchPlugin_Constraint
 public:
   /// \brief Returns the kind of a feature
   SKETCHPLUGIN_EXPORT virtual const std::string& getKind() 
-  {static std::string MY_KIND = "SketchConstraintLength"; return MY_KIND;}
+  {static std::string MY_KIND = SKETCH_CONSTRAINT_LENGTH_KIND; return MY_KIND;}
 
   /// \brief 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;}
+  {static std::string MY_GROUP = SKETCH_KIND; return MY_GROUP;}
 
   /// \brief Creates a new part document if needed
   SKETCHPLUGIN_EXPORT virtual void execute();
index dfc894d364a6e6f92f96d80643c4857d231d96f8..ac209b68fd75988661bfdccae9418d0e18234a30 100644 (file)
@@ -6,8 +6,11 @@
 #define SketchPlugin_ConstraintParallel_HeaderFile
 
 #include "SketchPlugin.h"
+#include <SketchPlugin_Sketch.h>
 #include "SketchPlugin_Constraint.h"
 
+/// Parallel constraint kind
+const std::string SKETCH_CONSTRAINT_PARALLEL_KIND("SketchConstraintParallel");
 
 /** \class SketchPlugin_ConstraintParallel
  *  \ingroup DataModel
@@ -21,11 +24,11 @@ class SketchPlugin_ConstraintParallel: public SketchPlugin_Constraint
 public:
   /// \brief Returns the kind of a feature
   SKETCHPLUGIN_EXPORT virtual const std::string& getKind() 
-  {static std::string MY_KIND = "SketchConstraintParallel"; return MY_KIND;}
+  {static std::string MY_KIND = SKETCH_CONSTRAINT_PARALLEL_KIND; return MY_KIND;}
 
   /// \brief 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;}
+  {static std::string MY_GROUP = SKETCH_KIND; return MY_GROUP;}
 
   /// \brief Creates a new part document if needed
   SKETCHPLUGIN_EXPORT virtual void execute();
index 6c5074a90cd62c1ec2b4205011d03af5cf1aba62..475c330849c3c35095878230876cc22493e2cd16 100644 (file)
@@ -6,8 +6,11 @@
 #define SketchPlugin_ConstraintPerpendicular_HeaderFile
 
 #include "SketchPlugin.h"
+#include <SketchPlugin_Sketch.h>
 #include "SketchPlugin_Constraint.h"
 
+/// Perpendicular constraint kind
+const std::string SKETCH_CONSTRAINT_PERPENDICULAR_KIND("SketchConstraintPerpendicular");
 
 /** \class SketchPlugin_ConstraintPerpendicular
  *  \ingroup DataModel
@@ -21,11 +24,11 @@ class SketchPlugin_ConstraintPerpendicular: public SketchPlugin_Constraint
 public:
   /// \brief Returns the kind of a feature
   SKETCHPLUGIN_EXPORT virtual const std::string& getKind() 
-  {static std::string MY_KIND = "SketchConstraintPerpendicular"; return MY_KIND;}
+  {static std::string MY_KIND = SKETCH_CONSTRAINT_PERPENDICULAR_KIND; return MY_KIND;}
 
   /// \brief 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;}
+  {static std::string MY_GROUP = SKETCH_KIND; return MY_GROUP;}
 
   /// \brief Creates a new part document if needed
   SKETCHPLUGIN_EXPORT virtual void execute();
index 26a0ecbdc0dfebb7842851bdfde34c8022563c48..bdfaa42974ee3885a7d44b6890c4e3f74b2eea99 100644 (file)
@@ -6,8 +6,12 @@
 #define SketchPlugin_ConstraintRadius_HeaderFile
 
 #include "SketchPlugin.h"
+#include <SketchPlugin_Sketch.h>
 #include "SketchPlugin_Constraint.h"
 
+/// Radius constraint kind
+const std::string SKETCH_CONSTRAINT_RADIUS_KIND("SketchConstraintRadius");
+
 
 /** \class SketchPlugin_ConstraintRadius
  *  \ingroup DataModel
@@ -22,11 +26,11 @@ class SketchPlugin_ConstraintRadius: public SketchPlugin_Constraint
 public:
   /// \brief Returns the kind of a feature
   SKETCHPLUGIN_EXPORT virtual const std::string& getKind() 
-  {static std::string MY_KIND = "SketchConstraintRadius"; return MY_KIND;}
+  {static std::string MY_KIND = SKETCH_CONSTRAINT_RADIUS_KIND; return MY_KIND;}
 
   /// \brief 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;}
+  {static std::string MY_GROUP = SKETCH_KIND; return MY_GROUP;}
 
   /// \brief Creates a new part document if needed
   SKETCHPLUGIN_EXPORT virtual void execute();
index ae771b5567b1dff3cc71ac5f52d9c4b15ff95969..7bda5720bb0e1fc8bdb0e28705d1a420bd965c88 100644 (file)
@@ -29,9 +29,9 @@ SketchPlugin_Sketch* SketchPlugin_Feature::sketch()
       boost::shared_ptr<SketchPlugin_Sketch> aSketch = boost::
         dynamic_pointer_cast<SketchPlugin_Sketch>(document()->feature("Construction", a, true));
       if (aSketch) {
-        std::list<boost::shared_ptr<ModelAPI_Feature> > aList = 
+        std::list<FeaturePtr > aList = 
           aSketch->data()->reflist(SKETCH_ATTR_FEATURES)->list();
-        std::list<boost::shared_ptr<ModelAPI_Feature> >::iterator aSub = aList.begin();
+        std::list<FeaturePtr >::iterator aSub = aList.begin();
         for(; aSub != aList.end(); aSub++) {
           if ((*aSub)->data()->isEqual(data())) {
             mySketch = aSketch.get();
index db6a6d6607aff088a251a6e4f6e43fb30d71b82e..8e59b54892d5c8935f587563554b8338ec546032 100644 (file)
@@ -27,7 +27,7 @@ public:
   /// 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;
+    const FeaturePtr& theFeature) = 0;
 
   /// Returns true if this feature must be displayed in the history (top level of Part tree)
   SKETCHPLUGIN_EXPORT virtual bool isInHistory() {return false;}
index 62dc6cfa971182255e968814247646764a89cb74..6acefd2943f36e69a885cd34769e7b36b6e10913 100644 (file)
@@ -7,8 +7,12 @@
 
 #include "SketchPlugin.h"
 #include <SketchPlugin_Feature.h>
+#include <SketchPlugin_Sketch.h>
 #include <list>
 
+/// Line feature kind
+const std::string SKETCH_LINE_KIND("SketchLine");
+
 /// Start 2D point of the line
 const std::string LINE_ATTR_START("StartPoint");
 /// End 2D point of the line
@@ -23,11 +27,11 @@ 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;}
+  {static std::string MY_KIND = SKETCH_LINE_KIND; 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;}
+  {static std::string MY_GROUP = SKETCH_KIND; return MY_GROUP;}
 
   /// Creates a new part document if needed
   SKETCHPLUGIN_EXPORT virtual void execute();
@@ -41,7 +45,7 @@ public:
   /// 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) {};
+    const FeaturePtr& theFeature) {};
 
   /// Use plugin manager for features creation
   SketchPlugin_Line();
index 23a6cf05a17cc3fb364a10d7f616943df9d71c6b..14e61b2362c7806c27657e8017b92cb77c2f95c8 100644 (file)
@@ -24,38 +24,38 @@ SketchPlugin_Plugin::SketchPlugin_Plugin()
   ModelAPI_PluginManager::get()->registerPlugin(this);
 }
 
-boost::shared_ptr<ModelAPI_Feature> SketchPlugin_Plugin::createFeature(string theFeatureID)
+FeaturePtr SketchPlugin_Plugin::createFeature(string theFeatureID)
 {
-  if (theFeatureID == "Sketch") {
-    return boost::shared_ptr<ModelAPI_Feature>(new SketchPlugin_Sketch);
+  if (theFeatureID == SKETCH_KIND) {
+    return FeaturePtr(new SketchPlugin_Sketch);
   }
-  else if (theFeatureID == "SketchPoint") {
-    return boost::shared_ptr<ModelAPI_Feature>(new SketchPlugin_Point);
+  else if (theFeatureID == SKETCH_POINT_KIND) {
+    return FeaturePtr(new SketchPlugin_Point);
   }
-  else if (theFeatureID == "SketchLine") {
-    return boost::shared_ptr<ModelAPI_Feature>(new SketchPlugin_Line);
+  else if (theFeatureID == SKETCH_LINE_KIND) {
+    return FeaturePtr(new SketchPlugin_Line);
   }
-  else if (theFeatureID == "SketchCircle") {
-    return boost::shared_ptr<ModelAPI_Feature>(new SketchPlugin_Circle);
+  else if (theFeatureID == SKETCH_CIRCLE_KIND) {
+    return FeaturePtr(new SketchPlugin_Circle);
   }
-  else if (theFeatureID == "SketchConstraintCoincidence") {
-    return boost::shared_ptr<ModelAPI_Feature>(new SketchPlugin_ConstraintCoincidence);
+  else if (theFeatureID == SKETCH_CONSTRAINT_COINCIDENCE_KIND) {
+    return FeaturePtr(new SketchPlugin_ConstraintCoincidence);
   }
-  else if (theFeatureID == "SketchConstraintDistance") {
-    return boost::shared_ptr<ModelAPI_Feature>(new SketchPlugin_ConstraintDistance);
+  else if (theFeatureID == SKETCH_CONSTRAINT_DISTANCE_KIND) {
+    return FeaturePtr(new SketchPlugin_ConstraintDistance);
   }
-  else if (theFeatureID == "SketchConstraintLength") {
-    return boost::shared_ptr<ModelAPI_Feature>(new SketchPlugin_ConstraintLength);
+  else if (theFeatureID == SKETCH_CONSTRAINT_LENGTH_KIND) {
+    return FeaturePtr(new SketchPlugin_ConstraintLength);
   }
-  else if (theFeatureID == "SketchConstraintParallel") {
-    return boost::shared_ptr<ModelAPI_Feature>(new SketchPlugin_ConstraintParallel);
+  else if (theFeatureID == SKETCH_CONSTRAINT_PARALLEL_KIND) {
+    return FeaturePtr(new SketchPlugin_ConstraintParallel);
   }
-  else if (theFeatureID == "SketchConstraintPerpendicular") {
-    return boost::shared_ptr<ModelAPI_Feature>(new SketchPlugin_ConstraintPerpendicular);
+  else if (theFeatureID == SKETCH_CONSTRAINT_PERPENDICULAR_KIND) {
+    return FeaturePtr(new SketchPlugin_ConstraintPerpendicular);
   }
-  else if (theFeatureID == "SketchConstraintRadius") {
-    return boost::shared_ptr<ModelAPI_Feature>(new SketchPlugin_ConstraintRadius);
+  else if (theFeatureID == SKETCH_CONSTRAINT_RADIUS_KIND) {
+    return FeaturePtr(new SketchPlugin_ConstraintRadius);
   }
   // feature of such kind is not found
-  return boost::shared_ptr<ModelAPI_Feature>();
+  return FeaturePtr();
 }
index f232b68fac26fdfdd6d38e824cae6f624aa520fb..408ae73cc2be30eacbf5e0211ed6c6aef3fcdae2 100644 (file)
@@ -8,12 +8,13 @@
 
 #include "SketchPlugin.h"
 #include "ModelAPI_Plugin.h"
+#include "ModelAPI_Feature.h"
 
 class SKETCHPLUGIN_EXPORT SketchPlugin_Plugin: public ModelAPI_Plugin
 {
 public:
   /// Creates the feature object of this plugin by the feature string ID
-  virtual boost::shared_ptr<ModelAPI_Feature> createFeature(std::string theFeatureID);
+  virtual FeaturePtr createFeature(std::string theFeatureID);
 
 public:
   /// Is needed for python wrapping by swig
index b18bffb08646be9264dbec3f9f26fe01bd22664f..8d37e19e13eaea2520b4163670251c9d6ad6bae7 100644 (file)
@@ -6,9 +6,13 @@
 #define SketchPlugin_Point_HeaderFile
 
 #include "SketchPlugin.h"
+#include <SketchPlugin_Sketch.h>
 #include "SketchPlugin_Feature.h"
 #include <list>
 
+/// Point feature kind
+const std::string SKETCH_POINT_KIND("SketchPoint");
+
 /// Coordinates of the point
 const std::string POINT_ATTR_COORD("PointCoordindates");
 
@@ -21,11 +25,11 @@ class SketchPlugin_Point: public SketchPlugin_Feature
 public:
   /// Returns the kind of a feature
   SKETCHPLUGIN_EXPORT virtual const std::string& getKind() 
-  {static std::string MY_KIND = "SketchPoint"; return MY_KIND;}
+  {static std::string MY_KIND = SKETCH_POINT_KIND; 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;}
+  {static std::string MY_GROUP = SKETCH_KIND; return MY_GROUP;}
 
   /// Creates a new part document if needed
   SKETCHPLUGIN_EXPORT virtual void execute();
@@ -39,7 +43,7 @@ public:
   /// 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) {};
+    const FeaturePtr& theFeature) {};
 
   /// Use plugin manager for features creation
   SketchPlugin_Point();
index a0adedd05eebb6a97b46f789ec3624a41713aaac..bc9d72735210f7e0e9647aa93afa68a1cb16f5a7 100644 (file)
@@ -83,7 +83,7 @@ const boost::shared_ptr<GeomAPI_Shape>& SketchPlugin_Sketch::preview()
   return getPreview();
 }
 
-const void SketchPlugin_Sketch::addSub(const boost::shared_ptr<ModelAPI_Feature>& theFeature)
+const void SketchPlugin_Sketch::addSub(const FeaturePtr& theFeature)
 {
   boost::dynamic_pointer_cast<SketchPlugin_Feature>(theFeature)->setSketch(this);
   data()->reflist(SKETCH_ATTR_FEATURES)->append(theFeature);
index 7c0894995afb358733a1aaf8b90be271f04b398c..8337c8d2478d18a9c13fc1524373753eb4cdf405 100644 (file)
@@ -10,6 +10,9 @@
 #include <GeomAPI_Pnt.h>
 #include <list>
 
+/// Sketch feature kind
+const std::string SKETCH_KIND("Sketch");
+
 /// Origin point of the sketcher in 3D space
 const std::string SKETCH_ATTR_ORIGIN("Origin");
 /// Vector X inside of the sketch plane
@@ -30,7 +33,7 @@ class SketchPlugin_Sketch: public SketchPlugin_Feature
 public:
   /// Returns the kind of a feature
   SKETCHPLUGIN_EXPORT virtual const std::string& getKind() 
-  {static std::string MY_KIND = "Sketch"; return MY_KIND;}
+  {static std::string MY_KIND = SKETCH_KIND; return MY_KIND;}
 
   /// Returns to which group in the document must be added feature
   SKETCHPLUGIN_EXPORT virtual const std::string& getGroup() 
@@ -48,7 +51,7 @@ public:
   /// 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);
+    const FeaturePtr& theFeature);
 
   /// Converts a 2D sketch space point into point in 3D space
   SKETCHPLUGIN_EXPORT boost::shared_ptr<GeomAPI_Pnt> to3D(
index d91e6066c9fd86126cf4a318f0d94d8f649a628e..be4bb9e41e9cbf1addcf90f3259d3ad00e647871 100644 (file)
@@ -1,7 +1,7 @@
 <plugin>
   <workbench id="Sketch">
     <group id="Basic">
-      <feature id="Sketch" nested="SketchLine" title="Sketch" tooltip="Create a new sketch or edit an existing sketch" icon=":icons/sketch.png">
+      <feature id="Sketch" nested="SketchLine SketchConstraintLength" title="Sketch" tooltip="Create a new sketch or edit an existing sketch" icon=":icons/sketch.png">
         <label title="Select a plane on which to create a sketch" tooltip="Select a plane on which to create a sketch"/> 
       <!--icon=":pictures/x_point.png"-->
       </feature>
@@ -20,7 +20,9 @@
       </feature>
       <feature id="SketchConstraintCoincidence" title="Points coincidence" tooltip="Create constraint for the coincidence of two points" internal="1"/>
       <feature id="SketchConstraintDistance" title="Distance between objects" tooltip="Create constraint for the distance from a point to an object" internal="1"/>
-      <feature id="SketchConstraintLength" title="Length of a line" tooltip="Create constraint for the given length of a line segment" internal="1"/>
+      <feature id="SketchConstraintLength" title="Length of a line" tooltip="Create constraint for the given length of a line segment">
+        <label title="Select a line entity on which to calculate lenght" tooltip="Select a line entity on which to calculate lenght"/>
+      </feature>
       <feature id="SketchConstraintRadius" title="Radius of a circle or an arc" tooltip="Create constraint for the given radius of a circle or an arc" internal="1"/>
       <feature id="SketchConstraintParallel" title="Parallelism of a lines" tooltip="Create constraint defining two parallel lines" internal="1"/>
       <feature id="SketchConstraintPerpendicular" title="Orthgonality of a lines" tooltip="Create constraint defining two perpendicular lines" internal="1"/>
index 2e8a1fae82df22d5e3ba133b0d157b112ea4971e..d4f55e00d1ac4db93bdfe0c516ae0b49316849e0 100644 (file)
@@ -5,6 +5,16 @@
 #include "SketchSolver_Constraint.h"
 #include <SketchSolver_Solver.h>
 
+#include <SketchPlugin_Line.h>
+#include <SketchPlugin_Point.h>
+#include <SketchPlugin_Circle.h>
+#include <SketchPlugin_Arc.h>
+#include <SketchPlugin_ConstraintDistance.h>
+#include <SketchPlugin_ConstraintLength.h>
+#include <SketchPlugin_ConstraintParallel.h>
+#include <SketchPlugin_ConstraintPerpendicular.h>
+#include <SketchPlugin_ConstraintRadius.h>
+
 #include <ModelAPI_AttributeRefAttr.h>
 #include <ModelAPI_Data.h>
 
@@ -83,7 +93,7 @@ const int& SketchSolver_Constraint::getType(boost::shared_ptr<SketchPlugin_Const
   }
 
   // Constraint for distance between point and another entity
-  if (aConstraintKind.compare("SketchConstraintDistance") == 0)
+  if (aConstraintKind.compare(SKETCH_CONSTRAINT_DISTANCE_KIND) == 0)
   {
     int aNbPoints = 0;
     int aNbEntities = 0;
@@ -94,15 +104,15 @@ const int& SketchSolver_Constraint::getType(boost::shared_ptr<SketchPlugin_Const
           theConstraint->data()->attribute(CONSTRAINT_ATTRIBUTES[indAttr])
         );
       if (!anAttr) continue;
-      if (anAttr->isFeature())
+      if (anAttr->isFeature() && anAttr->feature())
       { // verify posiible entities
         const std::string& aKind = anAttr->feature()->getKind();
-        if (aKind.compare("SketchPoint") == 0)
+        if (aKind.compare(SKETCH_POINT_KIND) == 0)
         {
           myAttributesList[aNbPoints++] = CONSTRAINT_ATTRIBUTES[indAttr];
           continue;
         }
-        else if(aKind.compare("SketchLine") == 0)
+        else if(aKind.compare(SKETCH_LINE_KIND) == 0)
         {
           // entities are placed starting from CONSTRAINT_ATTR_ENTITY_C attribute
           myAttributesList[2 + aNbEntities++] = CONSTRAINT_ATTRIBUTES[indAttr];
@@ -139,7 +149,7 @@ const int& SketchSolver_Constraint::getType(boost::shared_ptr<SketchPlugin_Const
   }
 
   // Constraint for the given length of a line
-  if (aConstraintKind.compare("SketchConstraintLength") == 0)
+  if (aConstraintKind.compare(SKETCH_CONSTRAINT_LENGTH_KIND) == 0)
   {
     int aNbLines = 0;
     for (unsigned int indAttr = 0; indAttr < CONSTRAINT_ATTR_SIZE; indAttr++)
@@ -149,7 +159,8 @@ const int& SketchSolver_Constraint::getType(boost::shared_ptr<SketchPlugin_Const
           theConstraint->data()->attribute(CONSTRAINT_ATTRIBUTES[indAttr])
         );
       if (!anAttr) continue;
-      if (anAttr->isFeature() && anAttr->feature()->getKind().compare("SketchLine") == 0)
+      if (anAttr->isFeature() && anAttr->feature() &&
+          anAttr->feature()->getKind().compare(SKETCH_LINE_KIND) == 0)
       {
         myAttributesList[aNbLines++] = CONSTRAINT_ATTRIBUTES[indAttr];
         break;
@@ -161,8 +172,8 @@ const int& SketchSolver_Constraint::getType(boost::shared_ptr<SketchPlugin_Const
   }
 
   // Constraint for two parallel/perpendicular lines
-  bool isParallel = (aConstraintKind.compare("SketchConstraintParallel") == 0);
-  bool isPerpendicular = (aConstraintKind.compare("SketchConstraintPerpendicular") == 0);
+  bool isParallel = (aConstraintKind.compare(SKETCH_CONSTRAINT_PARALLEL_KIND) == 0);
+  bool isPerpendicular = (aConstraintKind.compare(SKETCH_CONSTRAINT_PERPENDICULAR_KIND) == 0);
   if (isParallel || isPerpendicular)
   {
     int aNbEntities = 2; // lines in SolveSpace constraints should started from CONSTRAINT_ATTR_ENTITY_C attribute
@@ -174,7 +185,7 @@ const int& SketchSolver_Constraint::getType(boost::shared_ptr<SketchPlugin_Const
         );
       if (!anAttr || !anAttr->isFeature()) continue;
       const std::string& aKind = anAttr->feature()->getKind();
-      if (aKind.compare("SketchLine") == 0)
+      if (aKind.compare(SKETCH_LINE_KIND) == 0)
       {
         myAttributesList[aNbEntities++] = CONSTRAINT_ATTRIBUTES[indAttr];
         continue;
@@ -186,7 +197,7 @@ const int& SketchSolver_Constraint::getType(boost::shared_ptr<SketchPlugin_Const
   }
 
   // Constraint for radius of a circle or an arc of circle
-  if (aConstraintKind.compare("SketchConstraintRadius") == 0)
+  if (aConstraintKind.compare(SKETCH_CONSTRAINT_RADIUS_KIND) == 0)
   {
     int aNbEntities = 2; // lines in SolveSpace constraints should started from CONSTRAINT_ATTR_ENTITY_C attribute
     for (unsigned int indAttr = 0; indAttr < CONSTRAINT_ATTR_SIZE; indAttr++)
@@ -197,7 +208,7 @@ const int& SketchSolver_Constraint::getType(boost::shared_ptr<SketchPlugin_Const
         );
       if (!anAttr || !anAttr->isFeature()) continue;
       const std::string& aKind = anAttr->feature()->getKind();
-      if (aKind.compare("SketchCircle") == 0 || aKind.compare("SketchArc") == 0)
+      if (aKind.compare(SKETCH_CIRCLE_KIND) == 0 || aKind.compare(SKETCH_ARC_KIND) == 0)
       {
         myAttributesList[aNbEntities++] = CONSTRAINT_ATTRIBUTES[indAttr];
         continue;
index 7c0bd37845879ea5df3015d550a1645a013eefdb..186e80505628cc859a2da9867c6558333338a0b2 100644 (file)
@@ -15,6 +15,8 @@
 #include <Model_Events.h>
 
 #include <SketchPlugin_Constraint.h>
+#include <SketchPlugin_ConstraintLength.h>
+#include <SketchPlugin_ConstraintCoincidence.h>
 
 #include <SketchPlugin_Arc.h>
 #include <SketchPlugin_Circle.h>
@@ -186,7 +188,7 @@ bool SketchSolver_ConstraintGroup::changeConstraint(
     if (!aConstrAttr) continue;
 
     // For the length constraint the start and end points of the line should be added to the entities list instead of line
-    if (aConstrType == SLVS_C_PT_PT_DISTANCE && theConstraint->getKind().compare("SketchConstraintLength") == 0)
+    if (aConstrType == SLVS_C_PT_PT_DISTANCE && theConstraint->getKind().compare(SKETCH_CONSTRAINT_LENGTH_KIND) == 0)
     {
       boost::shared_ptr<ModelAPI_Data> aData = aConstrAttr->feature()->data();
       aConstrEnt[indAttr]   = changeEntity(aData->attribute(LINE_ATTR_START));
@@ -315,10 +317,10 @@ Slvs_hEntity SketchSolver_ConstraintGroup::changeEntity(
 //  Purpose:  create/update the element defined by the feature affected by any constraint
 // ============================================================================
 Slvs_hEntity SketchSolver_ConstraintGroup::changeEntity(
-                boost::shared_ptr<ModelAPI_Feature> theEntity)
+                FeaturePtr theEntity)
 {
   // If the entity is already in the group, try to find it
-  std::map<boost::shared_ptr<ModelAPI_Feature>, Slvs_hEntity>::const_iterator
+  std::map<FeaturePtr, Slvs_hEntity>::const_iterator
     aEntIter = myEntityFeatMap.find(theEntity);
   // defines that the entity already exists
   const bool isEntExists = (myEntityFeatMap.find(theEntity) != myEntityFeatMap.end());
@@ -331,7 +333,7 @@ Slvs_hEntity SketchSolver_ConstraintGroup::changeEntity(
     const std::string& aFeatureKind = aFeature->getKind();
 
     // Line
-    if (aFeatureKind.compare("SketchLine") == 0)
+    if (aFeatureKind.compare(SKETCH_LINE_KIND) == 0)
     {
       Slvs_hEntity aStart = changeEntity(aFeature->data()->attribute(LINE_ATTR_START));
       Slvs_hEntity aEnd   = changeEntity(aFeature->data()->attribute(LINE_ATTR_END));
@@ -346,7 +348,7 @@ Slvs_hEntity SketchSolver_ConstraintGroup::changeEntity(
       return aLineEntity.h;
     }
     // Circle
-    else if (aFeatureKind.compare("SketchCircle") == 0)
+    else if (aFeatureKind.compare(SKETCH_CIRCLE_KIND) == 0)
     {
       Slvs_hEntity aCenter = changeEntity(aFeature->data()->attribute(CIRCLE_ATTR_CENTER));
       Slvs_hEntity aRadius = changeEntity(aFeature->data()->attribute(CIRCLE_ATTR_RADIUS));
@@ -362,7 +364,7 @@ Slvs_hEntity SketchSolver_ConstraintGroup::changeEntity(
       return aCircleEntity.h;
     }
     // Arc
-    else if (aFeatureKind.compare("SketchArc") == 0)
+    else if (aFeatureKind.compare(SKETCH_ARC_KIND) == 0)
     {
       Slvs_hEntity aCenter = changeEntity(aFeature->data()->attribute(ARC_ATTR_CENTER));
       Slvs_hEntity aStart  = changeEntity(aFeature->data()->attribute(ARC_ATTR_START));
@@ -378,7 +380,7 @@ Slvs_hEntity SketchSolver_ConstraintGroup::changeEntity(
       return anArcEntity.h;
     }
     // Point (it has low probability to be an attribute of constraint, so it is checked at the end)
-    else if (aFeatureKind.compare("SketchPoint") == 0)
+    else if (aFeatureKind.compare(SKETCH_POINT_KIND) == 0)
     {
       Slvs_hEntity aPoint = changeEntity(aFeature->data()->attribute(POINT_ATTR_COORD));
 
@@ -461,7 +463,7 @@ Slvs_hEntity SketchSolver_ConstraintGroup::changeNormal(
 bool SketchSolver_ConstraintGroup::addWorkplane(
                 boost::shared_ptr<SketchPlugin_Feature> theSketch)
 {
-  if (myWorkplane.h || theSketch->getKind().compare("Sketch") != 0)
+  if (myWorkplane.h || theSketch->getKind().compare(SKETCH_KIND) != 0)
     return false; // the workplane already exists or the function parameter is not Sketch
 
   mySketch = theSketch;
@@ -744,7 +746,7 @@ bool SketchSolver_ConstraintGroup::updateGroup()
   {
     if (!aConstrIter->first->data()->isValid())
     {
-      if (aConstrIter->first->getKind().compare("SketchConstraintCoincidence") == 0)
+      if (aConstrIter->first->getKind().compare(SKETCH_CONSTRAINT_COINCIDENCE_KIND) == 0)
         isCCRemoved = true;
       std::map<boost::shared_ptr<SketchPlugin_Constraint>, Slvs_hConstraint>::reverse_iterator
         aCopyIter = aConstrIter++;
@@ -994,13 +996,13 @@ void SketchSolver_ConstraintGroup::removeConstraint(boost::shared_ptr<SketchPlug
     }
     else anEntAttrIter++;
   }
-  std::map<boost::shared_ptr<ModelAPI_Feature>, Slvs_hEntity>::iterator
+  std::map<FeaturePtr, Slvs_hEntity>::iterator
     anEntFeatIter = myEntityFeatMap.begin();
   while (anEntFeatIter != myEntityFeatMap.end())
   {
     if (anEntToRemove.find(anEntFeatIter->second) != anEntToRemove.end())
     {
-      std::map<boost::shared_ptr<ModelAPI_Feature>, Slvs_hEntity>::iterator
+      std::map<FeaturePtr, Slvs_hEntity>::iterator
         aRemovedIter = anEntFeatIter;
       anEntFeatIter++;
       myEntityFeatMap.erase(aRemovedIter);
index 7baeac158450944060cc9d49ea54f98aa62afcc0..69c1a7c04584e6894796a4ab1fcc4f85a1da8e8b 100644 (file)
@@ -104,7 +104,7 @@ protected:
    *  \return identifier of changed entity or 0 if entity could not be changed
    */
   Slvs_hEntity changeEntity(boost::shared_ptr<ModelAPI_Attribute> theEntity);
-  Slvs_hEntity changeEntity(boost::shared_ptr<ModelAPI_Feature>   theEntity);
+  Slvs_hEntity changeEntity(FeaturePtr   theEntity);
 
   /** \brief Adds or updates a normal in the group
    *
@@ -192,7 +192,7 @@ private:
                                myConstraintMap; ///< The map between SketchPlugin and SolveSpace constraints
   std::map<boost::shared_ptr<ModelAPI_Attribute>, Slvs_hEntity>
                                myEntityAttrMap;     ///< The map between "attribute" parameters of constraints and their equivalent SolveSpace entities
-  std::map<boost::shared_ptr<ModelAPI_Feature>, Slvs_hEntity>
+  std::map<FeaturePtr, Slvs_hEntity>
                                myEntityFeatMap;     ///< The map between "feature" parameters of constraints and their equivalent SolveSpace entities
 
   // Conincident items
index dd502982ba736bf0ef4ac9892ccb323957fe15ea..e91d65a16bc5491c0473d65a62b2f1fcc3283b15 100644 (file)
@@ -64,17 +64,17 @@ void SketchSolver_ConstraintManager::processEvent(const Events_Message* theMessa
       theMessage->eventID() == Events_Loop::loop()->eventByName(EVENT_FEATURE_MOVED))
   {
     const Model_FeatureUpdatedMessage* anUpdateMsg = dynamic_cast<const Model_FeatureUpdatedMessage*>(theMessage);
-    std::set< boost::shared_ptr<ModelAPI_Feature> > aFeatures = anUpdateMsg->features();
+    std::set< FeaturePtr > aFeatures = anUpdateMsg->features();
 
     bool isModifiedEvt = theMessage->eventID() == Events_Loop::loop()->eventByName(EVENT_FEATURE_MOVED);
     if (!isModifiedEvt)
     {
-      std::set< boost::shared_ptr<ModelAPI_Feature> >::iterator aFeatIter;
+      std::set< FeaturePtr >::iterator aFeatIter;
       for (aFeatIter = aFeatures.begin(); aFeatIter != aFeatures.end(); aFeatIter++)
       {
         // Only sketches and constraints can be added by Create event
         const std::string& aFeatureKind = (*aFeatIter)->getKind();
-        if (aFeatureKind.compare("Sketch") == 0)
+        if (aFeatureKind.compare(SKETCH_KIND) == 0)
         {
           boost::shared_ptr<SketchPlugin_Feature> aSketch =
             boost::dynamic_pointer_cast<SketchPlugin_Feature>(*aFeatIter);
@@ -105,10 +105,10 @@ void SketchSolver_ConstraintManager::processEvent(const Events_Message* theMessa
     const Model_FeatureDeletedMessage* aDeleteMsg = dynamic_cast<const Model_FeatureDeletedMessage*>(theMessage);
     const std::set<std::string>& aFeatureGroups = aDeleteMsg->groups();
 
-    // Find "Sketch" in groups. The constraint groups should be updated when an object removed from Sketch
+    // Find SKETCH_KIND in groups. The constraint groups should be updated when an object removed from Sketch
     std::set<std::string>::const_iterator aFGrIter;
     for (aFGrIter = aFeatureGroups.begin(); aFGrIter != aFeatureGroups.end(); aFGrIter++)
-      if (aFGrIter->compare("Sketch") == 0)
+      if (aFGrIter->compare(SKETCH_KIND) == 0)
         break;
     
     if (aFGrIter != aFeatureGroups.end())
@@ -256,22 +256,22 @@ void SketchSolver_ConstraintManager::updateEntity(boost::shared_ptr<SketchPlugin
   std::vector<std::string> anAttrList;
   const std::string& aFeatureKind = theFeature->getKind();
   // Point
-  if (aFeatureKind.compare("SketchPoint") == 0)
+  if (aFeatureKind.compare(SKETCH_POINT_KIND) == 0)
     anAttrList.push_back(POINT_ATTR_COORD);
   // Line
-  else if (aFeatureKind.compare("SketchLine") == 0)
+  else if (aFeatureKind.compare(SKETCH_LINE_KIND) == 0)
   {
     anAttrList.push_back(LINE_ATTR_START);
     anAttrList.push_back(LINE_ATTR_END);
   }
   // Circle
-  else if (aFeatureKind.compare("SketchCircle") == 0)
+  else if (aFeatureKind.compare(SKETCH_CIRCLE_KIND) == 0)
   {
     anAttrList.push_back(CIRCLE_ATTR_CENTER);
     anAttrList.push_back(CIRCLE_ATTR_RADIUS);
   }
   // Arc
-  else if (aFeatureKind.compare("SketchArc") == 0)
+  else if (aFeatureKind.compare(SKETCH_ARC_KIND) == 0)
   {
     anAttrList.push_back(ARC_ATTR_CENTER);
     anAttrList.push_back(ARC_ATTR_START);
@@ -343,8 +343,8 @@ boost::shared_ptr<SketchPlugin_Feature> SketchSolver_ConstraintManager::findWork
 
     boost::shared_ptr<ModelAPI_AttributeRefList> aWPFeatures =
       boost::dynamic_pointer_cast<ModelAPI_AttributeRefList>(aWP->data()->attribute(SKETCH_ATTR_FEATURES));
-    std::list< boost::shared_ptr<ModelAPI_Feature> > aFeaturesList = aWPFeatures->list();
-    std::list< boost::shared_ptr<ModelAPI_Feature> >::const_iterator anIter;
+    std::list< FeaturePtr > aFeaturesList = aWPFeatures->list();
+    std::list< FeaturePtr >::const_iterator anIter;
     for (anIter = aFeaturesList.begin(); anIter != aFeaturesList.end(); anIter++)
       if (*anIter == theConstraint)
         return aWP; // workplane is found
index ea9af50b6bfd6138eea9e3575a077cf30d68ead6..1775cb1259fa8bdb1aaa53860868341af26aa758 100644 (file)
@@ -1,4 +1,3 @@
-INCLUDE(FindCAS)
 
 SET(CMAKE_AUTOMOC ON)
 
@@ -33,6 +32,7 @@ SET(PROJECT_HEADERS
     XGUI_ViewerPrs.h
     XGUI_PropertyPanel.h
     XGUI_ContextMenuMgr.h
+    XGUI_ModuleConnector.h
 )
 
 SET(PROJECT_AUTOMOC 
@@ -64,6 +64,7 @@ SET(PROJECT_SOURCES
     XGUI_ViewerPrs.cpp
     XGUI_PropertyPanel.cpp
     XGUI_ContextMenuMgr.cpp
+    XGUI_ModuleConnector.cpp
 )
 
 SET(PROJECT_RESOURCES 
@@ -116,6 +117,7 @@ INCLUDE_DIRECTORIES (${PROJECT_SOURCE_DIR}/src/Events
                                         ${PROJECT_SOURCE_DIR}/src/ModelAPI
                                         ${PROJECT_SOURCE_DIR}/src/Model
                                         ${PROJECT_SOURCE_DIR}/src/ModuleBase
+                                        ${PROJECT_SOURCE_DIR}/src/PartSetPlugin
                                         ${CAS_INCLUDE_DIRS})
 
 LINK_DIRECTORIES($ENV{PYTHON_LIB_DIR})
index 0abbb09ffe7bb8cbdd84e86c214622fb76dd8094..b114aa3157d40f89b315244fa07720e1a7da10b5 100644 (file)
@@ -5,6 +5,8 @@
 #include "XGUI_SelectionMgr.h"
 #include "XGUI_Displayer.h"
 
+#include "PartSetPlugin_Part.h"
+
 #include <ModelAPI_Data.h>
 #include <ModelAPI_AttributeDocRef.h>
 #include <ModelAPI_Object.h>
@@ -96,7 +98,7 @@ QMenu* XGUI_ContextMenuMgr::objectBrowserMenu() const
     FeaturePtr aFeature = aFeatures.first();
     //Process Feature
     if (aFeature) {
-      if (aFeature->getKind() == "Part") {
+      if (aFeature->getKind() == PARTSET_PART_KIND) {
         ObjectPtr aObject = boost::dynamic_pointer_cast<ModelAPI_Object>(aFeature);
         DocumentPtr aFeaDoc = aObject->featureRef()->data()->docRef("PartDocument")->value();
         if (aMgr->currentDocument() == aFeaDoc)
@@ -107,7 +109,7 @@ QMenu* XGUI_ContextMenuMgr::objectBrowserMenu() const
         aMenu->addAction(action("EDIT_CMD"));
 
         XGUI_Displayer* aDisplayer = myWorkshop->displayer();
-        if (aDisplayer->IsVisible(aFeature))
+        if (aDisplayer->isVisible(aFeature))
           aMenu->addAction(action("HIDE_CMD"));
         else
           aMenu->addAction(action("SHOW_CMD"));
index d81b6e59fd9a7129ba18ca76e80406769247ed01..54f3728edb3e01d4f92a4fbe406efe06987d53de 100644 (file)
@@ -15,6 +15,7 @@
 #include <AIS_LocalContext.hxx>
 #include <AIS_ListOfInteractive.hxx>
 #include <AIS_ListIteratorOfListOfInteractive.hxx>
+#include <AIS_DimensionSelectionMode.hxx>
 
 #include <AIS_Shape.hxx>
 
@@ -31,17 +32,17 @@ XGUI_Displayer::~XGUI_Displayer()
 {
 }
 
-bool XGUI_Displayer::IsVisible(boost::shared_ptr<ModelAPI_Feature> theFeature)
+bool XGUI_Displayer::isVisible(FeaturePtr theFeature)
 {
   return myFeature2AISObjectMap.find(theFeature) != myFeature2AISObjectMap.end();
 }
 
-void XGUI_Displayer::Display(boost::shared_ptr<ModelAPI_Feature> theFeature,
-                             const bool isUpdateViewer)
-{
-}
+//void XGUI_Displayer::Display(FeaturePtr theFeature,
+//                             const bool isUpdateViewer)
+//{
+//}
 
-/*void XGUI_Displayer::Display(boost::shared_ptr<ModelAPI_Feature> theFeature,
+/*void XGUI_Displayer::Display(FeaturePtr theFeature,
                              const TopoDS_Shape& theShape, const bool isUpdateViewer)
 {
   Handle(AIS_InteractiveContext) aContext = AISContext();
@@ -51,34 +52,36 @@ void XGUI_Displayer::Display(boost::shared_ptr<ModelAPI_Feature> theFeature,
 
   aContext->Display(anAIS, Standard_False);
   if (isUpdateViewer)
-    UpdateViewer();
+    updateViewer();
 }*/
 
 
-std::list<XGUI_ViewerPrs> XGUI_Displayer::GetSelected(const int theShapeTypeToSkip)
+std::list<XGUI_ViewerPrs> XGUI_Displayer::getSelected(const int theShapeTypeToSkip)
 {
-  std::set<boost::shared_ptr<ModelAPI_Feature> > aPrsFeatures;
+  std::set<FeaturePtr > aPrsFeatures;
   std::list<XGUI_ViewerPrs> aPresentations;
 
   Handle(AIS_InteractiveContext) aContext = AISContext();
   for (aContext->InitSelected(); aContext->MoreSelected(); aContext->NextSelected()) {
     Handle(AIS_InteractiveObject) anIO = aContext->SelectedInteractive();
     TopoDS_Shape aShape = aContext->SelectedShape();
+
     if (theShapeTypeToSkip >= 0 && !aShape.IsNull() && aShape.ShapeType() == theShapeTypeToSkip)
       continue;
 
-    boost::shared_ptr<ModelAPI_Feature> aFeature = GetFeature(anIO);
+    FeaturePtr aFeature = getFeature(anIO);
     if (aPrsFeatures.find(aFeature) != aPrsFeatures.end())
       continue;
-    aPresentations.push_back(XGUI_ViewerPrs(aFeature, aShape));
+    Handle(SelectMgr_EntityOwner) anOwner = aContext->SelectedOwner();
+    aPresentations.push_back(XGUI_ViewerPrs(aFeature, aShape, anOwner));
     aPrsFeatures.insert(aFeature);
   }
   return aPresentations;
 }
 
-std::list<XGUI_ViewerPrs> XGUI_Displayer::GetHighlighted(const int theShapeTypeToSkip)
+std::list<XGUI_ViewerPrs> XGUI_Displayer::getHighlighted(const int theShapeTypeToSkip)
 {
-  std::set<boost::shared_ptr<ModelAPI_Feature> > aPrsFeatures;
+  std::set<FeaturePtr > aPrsFeatures;
   std::list<XGUI_ViewerPrs> aPresentations;
 
   Handle(AIS_InteractiveContext) aContext = AISContext();
@@ -88,17 +91,17 @@ std::list<XGUI_ViewerPrs> XGUI_Displayer::GetHighlighted(const int theShapeTypeT
     if (theShapeTypeToSkip >= 0 && !aShape.IsNull() && aShape.ShapeType() == theShapeTypeToSkip)
       continue;
 
-    boost::shared_ptr<ModelAPI_Feature> aFeature = GetFeature(anIO);
+    FeaturePtr aFeature = getFeature(anIO);
     if (aPrsFeatures.find(aFeature) != aPrsFeatures.end())
       continue;
-    aPresentations.push_back(XGUI_ViewerPrs(aFeature, aShape));
+    aPresentations.push_back(XGUI_ViewerPrs(aFeature, aShape, NULL));
     aPrsFeatures.insert(aFeature);
   }
 
   return aPresentations;
 }
 
-void XGUI_Displayer::Erase(boost::shared_ptr<ModelAPI_Feature> theFeature,
+void XGUI_Displayer::erase(FeaturePtr theFeature,
                            const bool isUpdateViewer)
 {
   if (myFeature2AISObjectMap.find(theFeature) == myFeature2AISObjectMap.end())
@@ -114,12 +117,15 @@ void XGUI_Displayer::Erase(boost::shared_ptr<ModelAPI_Feature> theFeature,
   myFeature2AISObjectMap.erase(theFeature);
 
   if (isUpdateViewer)
-    UpdateViewer();
+    updateViewer();
 }
 
-void XGUI_Displayer::Redisplay(boost::shared_ptr<ModelAPI_Feature> theFeature,
-                               const TopoDS_Shape& theShape, const bool isUpdateViewer)
+bool XGUI_Displayer::redisplay(FeaturePtr theFeature,
+                               Handle(AIS_InteractiveObject) theAIS,
+                               const int theSelectionMode,
+                               const bool isUpdateViewer)
 {
+  bool isCreated = false;
   Handle(AIS_InteractiveContext) aContext = AISContext();
   // Open local context if there is no one
   if (!aContext->HasOpenedContext()) {
@@ -130,30 +136,28 @@ void XGUI_Displayer::Redisplay(boost::shared_ptr<ModelAPI_Feature> theFeature,
     //aContext->SetPixelTolerance(MOUSE_SENSITIVITY_IN_PIXEL);
   }
   // display or redisplay presentation
-  Handle(AIS_Shape) anAIS;
-  if (IsVisible(theFeature)) {
-    anAIS = Handle(AIS_Shape)::DownCast(myFeature2AISObjectMap[theFeature]);
-    if (!anAIS.IsNull()) {
-      // if the AIS object is displayed in the opened local context in some mode, additional
-      // AIS sub objects are created there. They should be rebuild for correct selecting.
-      // It is possible to correct it by closing local context before the shape set and opening
-      // after. Another workaround to thrown down the selection and reselecting the AIS.
-      // If there was a problem here, try the first solution with close/open local context.
-      anAIS->Set(theShape);
-      anAIS->Redisplay(Standard_True);
-      aContext->RecomputeSelectionOnly(anAIS);
-    }
+  if (isVisible(theFeature) && !myFeature2AISObjectMap[theFeature].IsNull()) {
+      aContext->RecomputeSelectionOnly(theAIS);
   }
   else {
-    anAIS = new AIS_Shape(theShape);
-    myFeature2AISObjectMap[theFeature] = anAIS;
-    aContext->Display(anAIS, false);
+    myFeature2AISObjectMap[theFeature] = theAIS;
+    if (theSelectionMode < 0)
+    {
+      aContext->Display(theAIS, false);
+    }
+    else
+    {
+      aContext->Display(theAIS, 0, theSelectionMode, false);
+    }
+    isCreated = true;
   }
   if (isUpdateViewer)
-    UpdateViewer();
+    updateViewer();
+
+  return isCreated;
 }
 
-void XGUI_Displayer::ActivateInLocalContext(boost::shared_ptr<ModelAPI_Feature> theFeature,
+void XGUI_Displayer::activateInLocalContext(FeaturePtr theFeature,
                                          const std::list<int>& theModes, const bool isUpdateViewer)
 {
   Handle(AIS_InteractiveContext) aContext = AISContext();
@@ -164,7 +168,7 @@ void XGUI_Displayer::ActivateInLocalContext(boost::shared_ptr<ModelAPI_Feature>
   }
   // display or redisplay presentation
   Handle(AIS_Shape) anAIS;
-  if (IsVisible(theFeature))
+  if (isVisible(theFeature))
     anAIS = Handle(AIS_Shape)::DownCast(myFeature2AISObjectMap[theFeature]);
 
   // Activate selection of objects from prs
@@ -180,20 +184,20 @@ void XGUI_Displayer::ActivateInLocalContext(boost::shared_ptr<ModelAPI_Feature>
   }
 
   if (isUpdateViewer)
-    UpdateViewer();
+    updateViewer();
 }
 
-void XGUI_Displayer::StopSelection(const std::list<XGUI_ViewerPrs>& theFeatures, const bool isStop,
+void XGUI_Displayer::stopSelection(const std::list<XGUI_ViewerPrs>& theFeatures, const bool isStop,
                                    const bool isUpdateViewer)
 {
   Handle(AIS_InteractiveContext) aContext = AISContext();
 
   Handle(AIS_Shape) anAIS;
   std::list<XGUI_ViewerPrs>::const_iterator anIt = theFeatures.begin(), aLast = theFeatures.end();
-  boost::shared_ptr<ModelAPI_Feature> aFeature;
+  FeaturePtr aFeature;
   for (; anIt != aLast; anIt++) {
     aFeature = (*anIt).feature();
-    if (IsVisible(aFeature))
+    if (isVisible(aFeature))
       anAIS = Handle(AIS_Shape)::DownCast(myFeature2AISObjectMap[aFeature]);
     if (anAIS.IsNull())
       continue;
@@ -210,15 +214,15 @@ void XGUI_Displayer::StopSelection(const std::list<XGUI_ViewerPrs>& theFeatures,
     }
   }
   if (isUpdateViewer)
-    UpdateViewer();
+    updateViewer();
 }
 
-void XGUI_Displayer::SetSelected(const std::list<XGUI_ViewerPrs>& theFeatures, const bool isUpdateViewer)
+void XGUI_Displayer::setSelected(const std::list<XGUI_ViewerPrs>& theFeatures, const bool isUpdateViewer)
 {
   Handle(AIS_InteractiveContext) aContext = AISContext();
 
   std::list<XGUI_ViewerPrs>::const_iterator anIt = theFeatures.begin(), aLast = theFeatures.end();
-  boost::shared_ptr<ModelAPI_Feature> aFeature;
+  FeaturePtr aFeature;
 
   Handle(AIS_Shape) anAIS;
   // we need to unhighligth objects manually in the current local context
@@ -230,7 +234,7 @@ void XGUI_Displayer::SetSelected(const std::list<XGUI_ViewerPrs>& theFeatures, c
 
   for (; anIt != aLast; anIt++) {
     aFeature = (*anIt).feature();
-    if (IsVisible(aFeature))
+    if (isVisible(aFeature))
       anAIS = Handle(AIS_Shape)::DownCast(myFeature2AISObjectMap[aFeature]);
     if (anAIS.IsNull())
       continue;
@@ -238,10 +242,10 @@ void XGUI_Displayer::SetSelected(const std::list<XGUI_ViewerPrs>& theFeatures, c
   }
  
   if (isUpdateViewer)
-    UpdateViewer();
+    updateViewer();
 }
 
-void XGUI_Displayer::EraseAll(const bool isUpdateViewer)
+/*void XGUI_Displayer::EraseAll(const bool isUpdateViewer)
 {
   Handle(AIS_InteractiveContext) ic = AISContext();
 
@@ -258,19 +262,19 @@ void XGUI_Displayer::EraseAll(const bool isUpdateViewer)
   }
   myFeature2AISObjectMap.clear();
   if (isUpdateViewer)
-    UpdateViewer();
-}
+    updateViewer();
+}*/
 
-void XGUI_Displayer::EraseDeletedFeatures(const bool isUpdateViewer)
+void XGUI_Displayer::eraseDeletedFeatures(const bool isUpdateViewer)
 {
   Handle(AIS_InteractiveContext) aContext = AISContext();
 
   FeatureToAISMap::const_iterator aFIt = myFeature2AISObjectMap.begin(),
                                   aFLast = myFeature2AISObjectMap.end();
-  std::list<boost::shared_ptr<ModelAPI_Feature>> aRemoved;
+  std::list<FeaturePtr> aRemoved;
   for (; aFIt != aFLast; aFIt++)
   {
-    boost::shared_ptr<ModelAPI_Feature> aFeature = (*aFIt).first;
+    FeaturePtr aFeature = (*aFIt).first;
     if (!aFeature || !aFeature->data() || !aFeature->data()->isValid()) {
       Handle(AIS_InteractiveObject) anAIS = (*aFIt).second;
       if (!anAIS.IsNull()) {
@@ -279,23 +283,23 @@ void XGUI_Displayer::EraseDeletedFeatures(const bool isUpdateViewer)
       }
     }
   }
-  std::list<boost::shared_ptr<ModelAPI_Feature>>::const_iterator anIt = aRemoved.begin(),
+  std::list<FeaturePtr>::const_iterator anIt = aRemoved.begin(),
                                                                  aLast = aRemoved.end();
   for (; anIt != aLast; anIt++) {
     myFeature2AISObjectMap.erase(myFeature2AISObjectMap.find(*anIt));
   }
 
   if (isUpdateViewer)
-    UpdateViewer();
+    updateViewer();
 }
 
-void XGUI_Displayer::CloseLocalContexts(const bool isUpdateViewer)
+void XGUI_Displayer::closeLocalContexts(const bool isUpdateViewer)
 {
-  CloseAllContexts(true);
+  closeAllContexts(true);
 }
 
-Handle(AIS_InteractiveObject) XGUI_Displayer::GetAISObject(
-                                              boost::shared_ptr<ModelAPI_Feature> theFeature) const
+Handle(AIS_InteractiveObject) XGUI_Displayer::getAISObject(
+                                              FeaturePtr theFeature) const
 {
   Handle(AIS_InteractiveObject) anIO;
   if (myFeature2AISObjectMap.find(theFeature) != myFeature2AISObjectMap.end())
@@ -303,9 +307,9 @@ Handle(AIS_InteractiveObject) XGUI_Displayer::GetAISObject(
   return anIO;
 }
 
-boost::shared_ptr<ModelAPI_Feature> XGUI_Displayer::GetFeature(Handle(AIS_InteractiveObject) theIO) const
+FeaturePtr XGUI_Displayer::getFeature(Handle(AIS_InteractiveObject) theIO) const
 {
-  boost::shared_ptr<ModelAPI_Feature> aFeature;
+  FeaturePtr aFeature;
   FeatureToAISMap::const_iterator aFIt = myFeature2AISObjectMap.begin(),
                                   aFLast = myFeature2AISObjectMap.end();
   for (; aFIt != aFLast && !aFeature; aFIt++) {
@@ -317,17 +321,17 @@ boost::shared_ptr<ModelAPI_Feature> XGUI_Displayer::GetFeature(Handle(AIS_Intera
   return aFeature;
 }
 
-void XGUI_Displayer::CloseAllContexts(const bool isUpdateViewer)
+void XGUI_Displayer::closeAllContexts(const bool isUpdateViewer)
 {
   Handle(AIS_InteractiveContext) ic = AISContext();
   if (!ic.IsNull()) {
     ic->CloseAllContexts(false);
     if (isUpdateViewer)
-      UpdateViewer();
+      updateViewer();
   }
 }
 
-void XGUI_Displayer::UpdateViewer()
+void XGUI_Displayer::updateViewer()
 {
   Handle(AIS_InteractiveContext) ic = AISContext();
   if (!ic.IsNull())
index 6606ebf06fcd0b91d3cd353299a3ed6709f51b4e..b8389af5d52539dab819b34850fbd125663f17ed 100644 (file)
@@ -15,6 +15,8 @@
 #include <AIS_InteractiveContext.hxx>
 #include <NCollection_List.hxx>
 
+#include <ModelAPI_Feature.h>
+
 #include <XGUI_ViewerPrs.h>
 
 #include <map>
@@ -44,91 +46,97 @@ public:
 
   /// Returns the feature visibility state.
   /// \param theFeature a feature instance
-  bool IsVisible(boost::shared_ptr<ModelAPI_Feature> theFeature);
+  bool isVisible(FeaturePtr theFeature);
 
   /// Display the feature. Obtain the visualized object from the feature.
   /// \param theFeature a feature instance
   /// \param isUpdateViewer the parameter whether the viewer should be update immediatelly
-  void Display(boost::shared_ptr<ModelAPI_Feature> theFeature, const bool isUpdateViewer = true);
+  //void Display(FeaturePtr theFeature, const bool isUpdateViewer = true);
 
   /// Display the feature and a shape. This shape would be associated to the given feature
   /// \param theFeature a feature instance
   /// \param theShape a shape
   /// \param isUpdateViewer the parameter whether the viewer should be update immediatelly
-  //void Display(boost::shared_ptr<ModelAPI_Feature> theFeature, const TopoDS_Shape& theShape,
+  //void Display(FeaturePtr theFeature, const TopoDS_Shape& theShape,
   //             const bool isUpdateViewer = true);
   
   /// Returns a list of viewer selected presentations
   /// \param theShapeTypeToSkip the shapes with this type will be skipped during the result list build
   /// \return list of presentations
-  std::list<XGUI_ViewerPrs> GetSelected(const int theShapeTypeToSkip = -1);
+  std::list<XGUI_ViewerPrs> getSelected(const int theShapeTypeToSkip = -1);
 
   /// Returns a list of viewer highlited presentations
   /// \param theShapeTypeToSkip the shapes with this type will be skipped during the result list build
   /// \return list of presentations
-  std::list<XGUI_ViewerPrs> GetHighlighted(const int theShapeTypeToSkip = -1);
+  std::list<XGUI_ViewerPrs> getHighlighted(const int theShapeTypeToSkip = -1);
 
   /// Display the shape and activate selection of sub-shapes
   /// \param theFeature a feature instance
-  /// \param theShape a shape
-  /// \param theMode a local selection mode
+  /// \param theAIS an AIS object
+  /// \param isUpdateViewer the parameter whether the viewer should be update immediatelly
+  /// \returns true if the presentation is created
+  bool redisplay(FeaturePtr theFeature,
+                 Handle(AIS_InteractiveObject) theAIS,
+                 const int theSelectionMode, const bool isUpdateViewer = true);
+
+  /// Redisplay the shape and activate selection of sub-shapes
+  /// \param theFeature a feature instance
   /// \param isUpdateViewer the parameter whether the viewer should be update immediatelly
-  void Redisplay(boost::shared_ptr<ModelAPI_Feature> theFeature,
-                             const TopoDS_Shape& theShape, const bool isUpdateViewer = true);
+  //void redisplay(Handle(AIS_InteractiveObject) theAIS, const bool isUpdateViewer = true);
 
   /// Display the shape and activate selection of sub-shapes
   /// \param theFeature a feature instance
   /// \param theShape a shape
   /// \param theMode a list of local selection modes
   /// \param isUpdateViewer the parameter whether the viewer should be update immediatelly
-  void ActivateInLocalContext(boost::shared_ptr<ModelAPI_Feature> theFeature,
+  void activateInLocalContext(FeaturePtr theFeature,
                               const std::list<int>& theModes, const bool isUpdateViewer = true);
 
   /// Stop the current selection and color the given features to the selection color
   /// \param theFeatures a list of features to be disabled
   /// \param theToStop the boolean state whether it it stopped or non stopped
   /// \param isUpdateViewer the parameter whether the viewer should be update immediatelly
-  void StopSelection(const std::list<XGUI_ViewerPrs>& theFeatures, const bool isStop,
+  void stopSelection(const std::list<XGUI_ViewerPrs>& theFeatures, const bool isStop,
                      const bool isUpdateViewer);
 
   /// Set the features are selected
   /// \param theFeatures a list of features to be selected
   /// \param isUpdateViewer the parameter whether the viewer should be update immediatelly
-  void SetSelected(const std::list<XGUI_ViewerPrs>& theFeatures, const bool isUpdateViewer);
+  void setSelected(const std::list<XGUI_ViewerPrs>& theFeatures, const bool isUpdateViewer);
 
   /// Erase the feature and a shape.
   /// \param theFeature a feature instance
   /// \param isUpdateViewer the parameter whether the viewer should be update immediatelly
-  void Erase(boost::shared_ptr<ModelAPI_Feature> theFeature, const bool isUpdateViewer = true);
+  void erase(FeaturePtr theFeature, const bool isUpdateViewer = true);
 
   /// Erase all presentations
   /// \param isUpdateViewer the parameter whether the viewer should be update immediatelly
-  void EraseAll(const bool isUpdateViewer = true);
+  //void EraseAll(const bool isUpdateViewer = true);
 
   /// Erase AIS interactive objects, which has an empty feature in the internal map
   /// \param isUpdateViewer the parameter whether the viewer should be update immediatelly
-  void EraseDeletedFeatures(const bool isUpdateViewer = true);
+  void eraseDeletedFeatures(const bool isUpdateViewer = true);
 
   /// Deactivates selection of sub-shapes
   /// \param isUpdateViewer the parameter whether the viewer should be update immediatelly
-  void CloseLocalContexts(const bool isUpdateViewer = true);
+  void closeLocalContexts(const bool isUpdateViewer = true);
 
   /// Updates the viewer
-  void UpdateViewer();
+  void updateViewer();
 
   /// Searches the interactive object by feature
-  /// \param feature the feature or NULL if it not visualized
+  /// \param theFeature the feature or NULL if it not visualized
   /// \return theIO an interactive object
-   Handle(AIS_InteractiveObject) GetAISObject(boost::shared_ptr<ModelAPI_Feature>) const;
+  Handle(AIS_InteractiveObject) getAISObject(FeaturePtr theFeature) const;
 
 protected:
   /// Searches the feature by interactive object
   /// \param theIO an interactive object
   /// \return feature the feature or NULL if it not visualized
-  boost::shared_ptr<ModelAPI_Feature> GetFeature(Handle(AIS_InteractiveObject) theIO) const;
+  FeaturePtr getFeature(Handle(AIS_InteractiveObject) theIO) const;
   /// Deactivate local selection
   /// \param isUpdateViewer the state wether the viewer should be updated immediatelly
-  void CloseAllContexts(const bool isUpdateViewer);
+  void closeAllContexts(const bool isUpdateViewer);
 
   /// Returns currently installed AIS_InteractiveContext
   Handle(AIS_InteractiveContext) AISContext() const;
@@ -136,7 +144,7 @@ protected:
 protected:
   XGUI_Workshop* myWorkshop;
 
-  typedef std::map<boost::shared_ptr<ModelAPI_Feature>, Handle(AIS_InteractiveObject) > FeatureToAISMap;
+  typedef std::map<FeaturePtr, Handle(AIS_InteractiveObject) > FeatureToAISMap;
   FeatureToAISMap myFeature2AISObjectMap;
 };
 
diff --git a/src/XGUI/XGUI_ModuleConnector.cpp b/src/XGUI/XGUI_ModuleConnector.cpp
new file mode 100644 (file)
index 0000000..542eca0
--- /dev/null
@@ -0,0 +1,33 @@
+// File:        XGUI_ModuleConnector.cpp
+// Created:     3 June 2014
+// Author:      Vitaly Smetannikov
+
+
+#include "XGUI_ModuleConnector.h"
+#include "XGUI_Workshop.h"
+#include "XGUI_ViewerProxy.h"
+#include "XGUI_SelectionMgr.h"
+
+
+
+XGUI_ModuleConnector::XGUI_ModuleConnector(XGUI_Workshop* theWorkshop) 
+: ModuleBase_IWorkshop(theWorkshop), myWorkshop(theWorkshop)
+{
+  XGUI_SelectionMgr* aSelector = myWorkshop->selector();
+  connect(aSelector, SIGNAL(selectionChanged()), this, SIGNAL(selectionChanged()));
+}
+
+XGUI_ModuleConnector::~XGUI_ModuleConnector()
+{
+}
+
+Handle(AIS_InteractiveContext) XGUI_ModuleConnector::AISContext() const
+{
+  return myWorkshop->viewer()->AISContext();
+}
+
+
+QFeatureList XGUI_ModuleConnector::selectedFeatures() const
+{
+  return myWorkshop->selector()->selectedFeatures();
+}
\ No newline at end of file
diff --git a/src/XGUI/XGUI_ModuleConnector.h b/src/XGUI/XGUI_ModuleConnector.h
new file mode 100644 (file)
index 0000000..04d7b3e
--- /dev/null
@@ -0,0 +1,38 @@
+// File:        XGUI_ModuleConnector.h
+// Created:     3 June 2014
+// Author:      Vitaly Smetannikov
+
+#ifndef XGUI_ModuleConnector_H
+#define XGUI_ModuleConnector_H
+
+
+#include "XGUI.h"
+#include "XGUI_Constants.h"
+
+#include <ModuleBase_IWorkshop.h>
+
+class Handle_AIS_InteractiveContext;
+class XGUI_Workshop;
+
+/**
+* Implementation of IWorkshop interface which provides access to Workshop sevices at module level
+*/
+class XGUI_EXPORT XGUI_ModuleConnector: public ModuleBase_IWorkshop
+{
+  Q_OBJECT
+public:
+  XGUI_ModuleConnector(XGUI_Workshop* theWorkshop);
+
+  virtual ~XGUI_ModuleConnector();
+
+  //! Returns AIS_InteractiveContext from current OCCViewer
+  virtual Handle(AIS_InteractiveContext) AISContext() const;
+
+  //! Returns list of currently selected data objects
+  QFeatureList selectedFeatures() const; 
+
+private:
+  XGUI_Workshop* myWorkshop;
+};
+
+#endif
\ No newline at end of file
index 125e1aaf4bc17cd6d52adda9f90296f88e671bb0..818e72210722732ae689684011070b0aa99dd668 100644 (file)
@@ -146,7 +146,7 @@ XGUI_ObjectsBrowser::XGUI_ObjectsBrowser(QWidget* theParent)
   aLabelWgt->setFrameShape(myTreeView->frameShape());
   aLabelWgt->setFrameShadow(myTreeView->frameShadow());
 
-  connect(myTreeView, SIGNAL(selectionChanged()), this, SIGNAL(selectionChanged()));
+  connect(myTreeView, SIGNAL(selectionChanged()), this, SLOT(onSelectionChanged()));
   connect(myTreeView, SIGNAL(activePartChanged(FeaturePtr)), this, SLOT(onActivePartChanged(FeaturePtr)));
   connect(myTreeView, SIGNAL(activePartChanged(FeaturePtr)), this, SIGNAL(activePartChanged(FeaturePtr)));
 
@@ -315,4 +315,11 @@ void XGUI_ObjectsBrowser::onEditItem()
       myActiveDocLbl->setProperty("OldText", myActiveDocLbl->text());
     }
   }
+}
+
+//***************************************************
+void XGUI_ObjectsBrowser::onSelectionChanged()
+{
+  myFeaturesList = myTreeView->selectedFeatures();
+  emit selectionChanged();
 }
\ No newline at end of file
index b8e275ae688e3d6f7478bc832ef244377a4eea38..8e4842df549e707f5bc29bc81f0bef552d023925 100644 (file)
@@ -96,6 +96,8 @@ private slots:
   //! Called on Edit command request
   void onEditItem();
 
+  void onSelectionChanged();
+
 private:
   void closeDocNameEditing(bool toSave);
 
index f511a5750a38d3b40f86638087076ae0b16b645d..ce30a89c1e61c31fc11f76982403f8acbddd69a8 100644 (file)
@@ -119,7 +119,7 @@ QWidget* XGUI_PropertyPanel::contentWidget()
   return myCustomWidget;
 }
 
-void XGUI_PropertyPanel::updateContentWidget(boost::shared_ptr<ModelAPI_Feature> theFeature)
+void XGUI_PropertyPanel::updateContentWidget(FeaturePtr theFeature)
 {
   foreach(ModuleBase_ModelWidget* eachWidget, myWidgets) {
     eachWidget->restoreValue(theFeature);
index d034d728903641885564db7737e56e2748e61d74..67c9857c305f004482025fec025d18ec239abb86 100644 (file)
@@ -30,7 +30,7 @@ public:
   virtual bool eventFilter(QObject *theObject, QEvent *theEvent);
 
 public slots:
-  void updateContentWidget(boost::shared_ptr<ModelAPI_Feature> theFeature);
+  void updateContentWidget(FeaturePtr theFeature);
   /// slot to set the focus to the widget visualized an attribute with the given name
   /// \param theAttributteName
   void onFocusActivated(const std::string& theAttributeName);
index 339d08369551b6128bcff4b93083563a4150848e..3148bc274b06024ee92ff0c92168b7826726455b 100644 (file)
@@ -56,13 +56,13 @@ QRect makeRect(const int x1, const int y1, const int x2, const int y2)
 }
 
 //******************************************************************
-bool isModelObject(boost::shared_ptr<ModelAPI_Feature> theFeature)
+bool isModelObject(FeaturePtr theFeature)
 {
   return theFeature && !theFeature->data();
 }
 
 //******************************************************************
-std::string featureInfo(boost::shared_ptr<ModelAPI_Feature> theFeature)
+std::string featureInfo(FeaturePtr theFeature)
 {
   std::ostringstream aStream; 
   if (theFeature)
index d20260f8e3046847cc6d0b53c51f0f1e021e2190..f2f2b9d88c5b98a2abc2a9c89d47b7c7f8fe9645 100644 (file)
@@ -5,10 +5,11 @@
 #include <QString>
 #include <QRect>
 
+#include <ModelAPI_Feature.h>
+
 #include <boost/shared_ptr.hpp>
 
 class TopoDS_Shape;
-class ModelAPI_Feature;
 /*!
  \brief Return directory part of the file path.
 
@@ -64,13 +65,13 @@ namespace XGUI_Tools
    Returns true if the feature is a model object
    \param theFeature a feature
   */
-  bool XGUI_EXPORT isModelObject(boost::shared_ptr<ModelAPI_Feature> theFeature);
+  bool XGUI_EXPORT isModelObject(FeaturePtr theFeature);
 
   /*!
    Returns the string presentation of the given feature
    \param theFeature a feature
   */
-  std::string XGUI_EXPORT featureInfo(boost::shared_ptr<ModelAPI_Feature> theFeature);
+  std::string XGUI_EXPORT featureInfo(FeaturePtr theFeature);
 }
 
 #endif
index 1f7f63344662da2dfef8de75ebc948c303a4e4fc..dfd632bdab9699a1497f78fcdca15e941d36f6c7 100644 (file)
@@ -64,4 +64,4 @@ private:
   XGUI_Workshop* myWorkshop;
 };
 
-#endif
\ No newline at end of file
+#endif
index 4ab8801aa1f124151bff9b5aa9edbc13267e57af..e0958f76fc6417fd2cbf50bbb543b8b4000882c2 100644 (file)
@@ -4,13 +4,16 @@
 
 #include "XGUI_ViewerPrs.h"
 
+#include "SelectMgr_EntityOwner.hxx"
+
 XGUI_ViewerPrs::XGUI_ViewerPrs()
 {
 }
 
-XGUI_ViewerPrs::XGUI_ViewerPrs(boost::shared_ptr<ModelAPI_Feature> theFeature,
-                               const TopoDS_Shape& theShape)
-: myFeature(theFeature), myShape(theShape)
+XGUI_ViewerPrs::XGUI_ViewerPrs(FeaturePtr theFeature,
+                               const TopoDS_Shape& theShape,
+                               Handle(SelectMgr_EntityOwner) theOwner)
+: myFeature(theFeature), myShape(theShape), myOwner(theOwner)
 {
 }
 
@@ -18,19 +21,29 @@ XGUI_ViewerPrs::~XGUI_ViewerPrs()
 {
 }
 
-void XGUI_ViewerPrs::setFeature(boost::shared_ptr<ModelAPI_Feature> theFeature)
+void XGUI_ViewerPrs::setFeature(FeaturePtr theFeature)
 {
   myFeature = theFeature;
 }
 
-void XGUI_ViewerPrs::setShape(const TopoDS_Shape& theShape)
+FeaturePtr XGUI_ViewerPrs::feature() const
 {
-  myShape = theShape;
+  return myFeature;
 }
 
-boost::shared_ptr<ModelAPI_Feature> XGUI_ViewerPrs::feature() const
+void XGUI_ViewerPrs::setOwner(Handle(SelectMgr_EntityOwner) theOwner)
 {
-  return myFeature;
+  myOwner = theOwner;
+}
+
+Handle(SelectMgr_EntityOwner) XGUI_ViewerPrs::owner() const
+{
+  return myOwner;
+}
+
+void XGUI_ViewerPrs::setShape(const TopoDS_Shape& theShape)
+{
+  myShape = theShape;
 }
 
 const TopoDS_Shape& XGUI_ViewerPrs::shape() const
index 957e4dc7c0a535c0af2c8f1c4fc6ff412fae35de..585b65cc37a8dffd705a1e6f21271c488cc1dac9 100644 (file)
@@ -9,12 +9,13 @@
 
 #include <boost/shared_ptr.hpp>
 #include <TopoDS_Shape.hxx>
+#include <SelectMgr_EntityOwner.hxx>
 
-class ModelAPI_Feature;
+#include <ModelAPI_Feature.h>
 
 /**\class XGUI_ViewerPrs
  * \ingroup GUI
- * \brief Presentation. Provides container to have feature and the shape
+ * \brief Presentation. Provides container to have feature, shape and/or selection owner.
  */
 class XGUI_EXPORT XGUI_ViewerPrs
 {
@@ -22,29 +23,42 @@ public:
   /// Constructor
   XGUI_ViewerPrs();
   /// Constructor
-  XGUI_ViewerPrs(boost::shared_ptr<ModelAPI_Feature> theFeature,
-                 const TopoDS_Shape& theShape);
+  /// \param theFeature a model feature
+  /// \param theShape a viewer shape
+  /// \param theOwner a selection owner
+  XGUI_ViewerPrs(FeaturePtr theFeature,
+                 const TopoDS_Shape& theShape,
+                 Handle_SelectMgr_EntityOwner theOwner);
   /// Destructor
   virtual ~XGUI_ViewerPrs();
 
   /// Sets the feature.
   /// \param theFeature a feature instance
-  void setFeature(boost::shared_ptr<ModelAPI_Feature> theFeature);
+  void setFeature(FeaturePtr theFeature);
+
+  /// Returns the feature.
+  /// \return a feature instance
+  FeaturePtr feature() const;
+
+  /// Returns the presentation owner
+  /// \param the owner
+  void setOwner(Handle_SelectMgr_EntityOwner theOwner);
+
+  /// Returns the presentation owner
+  /// \return an owner
+  Handle_SelectMgr_EntityOwner owner() const;
 
   /// Sets the shape
   /// \param theShape a shape instance
   void setShape(const TopoDS_Shape& theShape);
 
-  /// Returns the feature.
-  /// \return a feature instance
-  boost::shared_ptr<ModelAPI_Feature> feature() const;
-
   /// Returns the shape
   /// \return a shape instance
   const TopoDS_Shape& shape() const;
 
 private:
-  boost::shared_ptr<ModelAPI_Feature> myFeature; /// the feature
+  FeaturePtr myFeature; /// the feature
+  Handle(SelectMgr_EntityOwner) myOwner; /// the selection owner
   TopoDS_Shape myShape; /// the shape
 };
 
index 980b8c8e0f28243771c285ceab2c4f9e74a423d9..25f3b5317528e8e98678770a61d32f44ed91989c 100644 (file)
@@ -20,6 +20,7 @@
 #include "XGUI_ViewerProxy.h"
 #include "XGUI_PropertyPanel.h"
 #include "XGUI_ContextMenuMgr.h"
+#include "XGUI_ModuleConnector.h"
 
 #include <Model_Events.h>
 #include <ModelAPI_PluginManager.h>
@@ -28,6 +29,8 @@
 #include <ModelAPI_AttributeDocRef.h>
 #include <ModelAPI_Object.h>
 
+#include <PartSetPlugin_Part.h>
+
 #include <Events_Loop.h>
 #include <Events_Error.h>
 #include <ModuleBase_Operation.h>
@@ -91,6 +94,8 @@ XGUI_Workshop::XGUI_Workshop(XGUI_SalomeConnector* theConnector)
           this, SLOT(onContextMenuCommand(const QString&, bool)));
 
   myViewerProxy = new XGUI_ViewerProxy(this);
+  
+  myModuleConnector = new XGUI_ModuleConnector(this);
 
   connect(myOperationMgr, SIGNAL(operationStarted()), SLOT(onOperationStarted()));
   connect(myOperationMgr, SIGNAL(operationResumed()), SLOT(onOperationStarted()));
@@ -225,7 +230,7 @@ void XGUI_Workshop::processEvent(const Events_Message* theMessage)
     bool aHasPart = false;
     for (aIt = aFeatures.begin(); aIt != aFeatures.end(); ++aIt) {
       FeaturePtr aFeature = (*aIt);
-      if (aFeature->getKind() == "Part") {
+      if (aFeature->getKind() == PARTSET_PART_KIND) {
         aHasPart = true;
         break;
       }
@@ -289,7 +294,7 @@ void XGUI_Workshop::onOperationStarted()
 
     showPropertyPanel();
 
-    ModuleBase_WidgetFactory aFactory = ModuleBase_WidgetFactory(aOperation);
+    ModuleBase_WidgetFactory aFactory = ModuleBase_WidgetFactory(aOperation, myModuleConnector);
     QWidget* aContent = myPropertyPanel->contentWidget();
     qDeleteAll(aContent->children());
     aFactory.createWidget(aContent);
@@ -806,7 +811,7 @@ void XGUI_Workshop::deleteFeatures(QFeatureList theList)
     PluginManagerPtr aMgr = ModelAPI_PluginManager::get();
     aMgr->rootDocument()->startOperation();
     foreach (FeaturePtr aFeature, theList) {
-      if (aFeature->getKind() == "Part") {
+      if (aFeature->getKind() == PARTSET_PART_KIND) {
         DocumentPtr aDoc;
         if (!XGUI_Tools::isModelObject(aFeature)) {
           aDoc = aFeature->data()->docRef("PartDocument")->value();
index d7ace358b60068eb67234ed7c51be05957cf4d79..dad0857074b93a92e6e91d51226012ecf5e5e4ea 100644 (file)
@@ -25,6 +25,7 @@ class XGUI_SalomeViewer;
 class XGUI_ViewerProxy;
 class XGUI_PropertyPanel;
 class XGUI_ContextMenuMgr;
+class XGUI_ModuleConnector;
 
 class ModuleBase_Operation;
 
@@ -174,6 +175,7 @@ private:
   XGUI_ErrorDialog* myErrorDlg;
   XGUI_ViewerProxy* myViewerProxy;
   XGUI_ContextMenuMgr* myContextMenuMgr;
+  XGUI_ModuleConnector* myModuleConnector;
 
   QString myCurrentDir;
   static QMap<QString, QString> myIcons;