Salome HOME
Merge branch 'master' of newgeom:newgeom.git
authorsbh <sergey.belash@opencascade.com>
Wed, 9 Jul 2014 13:29:08 +0000 (17:29 +0400)
committersbh <sergey.belash@opencascade.com>
Wed, 9 Jul 2014 13:29:08 +0000 (17:29 +0400)
64 files changed:
CMakeLists.txt
src/Config/plugins.xml
src/ConstructionPlugin/CMakeLists.txt
src/ConstructionPlugin/ConstructionPlugin_Extrusion.cpp [deleted file]
src/ConstructionPlugin/ConstructionPlugin_Extrusion.h [deleted file]
src/ConstructionPlugin/ConstructionPlugin_Plugin.cpp
src/ConstructionPlugin/extrusion_widget.xml [deleted file]
src/ConstructionPlugin/plugin-Construction.xml
src/FeaturesPlugin/CMakeLists.txt [new file with mode: 0644]
src/FeaturesPlugin/FeaturesPlugin.h [new file with mode: 0644]
src/FeaturesPlugin/FeaturesPlugin_Extrusion.cpp [new file with mode: 0644]
src/FeaturesPlugin/FeaturesPlugin_Extrusion.h [new file with mode: 0644]
src/FeaturesPlugin/FeaturesPlugin_Plugin.cpp [new file with mode: 0644]
src/FeaturesPlugin/FeaturesPlugin_Plugin.h [new file with mode: 0644]
src/FeaturesPlugin/extrusion_widget.xml [new file with mode: 0644]
src/FeaturesPlugin/plugin-Features.xml [new file with mode: 0644]
src/Model/Model_Validator.cpp
src/Model/Model_Validator.h
src/ModelAPI/CMakeLists.txt
src/ModelAPI/ModelAPI_FeatureValidator.h [new file with mode: 0644]
src/ModelAPI/ModelAPI_Validator.h
src/ModuleBase/CMakeLists.txt
src/ModuleBase/ModuleBase_IModule.h
src/ModuleBase/ModuleBase_ISelection.h [new file with mode: 0644]
src/ModuleBase/ModuleBase_IWorkshop.h
src/ModuleBase/ModuleBase_SelectionValidator.h [new file with mode: 0644]
src/ModuleBase/ModuleBase_ViewerPrs.h [new file with mode: 0644]
src/ModuleBase/ModuleBase_WidgetFactory.cpp
src/PartSet/CMakeLists.txt
src/PartSet/PartSet_Module.cpp
src/PartSet/PartSet_Module.h
src/PartSet/PartSet_OperationFeatureCreate.cpp
src/PartSet/PartSet_OperationFeatureCreate.h
src/PartSet/PartSet_OperationFeatureEdit.cpp
src/PartSet/PartSet_OperationFeatureEdit.h
src/PartSet/PartSet_OperationFeatureEditMulti.cpp
src/PartSet/PartSet_OperationFeatureEditMulti.h
src/PartSet/PartSet_OperationSketch.cpp
src/PartSet/PartSet_OperationSketch.h
src/PartSet/PartSet_OperationSketchBase.cpp
src/PartSet/PartSet_OperationSketchBase.h
src/PartSet/PartSet_TestOCC.cpp
src/PartSet/PartSet_Tools.cpp
src/PartSet/PartSet_Tools.h
src/PartSet/PartSet_Validators.cpp [new file with mode: 0644]
src/PartSet/PartSet_Validators.h [new file with mode: 0644]
src/PartSet/PartSet_WidgetSketchLabel.cpp [new file with mode: 0644]
src/PartSet/PartSet_WidgetSketchLabel.h [new file with mode: 0644]
src/SketchPlugin/CMakeLists.txt
src/SketchPlugin/plugin-Sketch.xml
src/XGUI/CMakeLists.txt
src/XGUI/XGUI_ContextMenuMgr.cpp
src/XGUI/XGUI_Displayer.cpp
src/XGUI/XGUI_Displayer.h
src/XGUI/XGUI_ModuleConnector.cpp
src/XGUI/XGUI_ModuleConnector.h
src/XGUI/XGUI_Selection.cpp [new file with mode: 0644]
src/XGUI/XGUI_Selection.h [new file with mode: 0644]
src/XGUI/XGUI_SelectionMgr.cpp
src/XGUI/XGUI_SelectionMgr.h
src/XGUI/XGUI_ViewerPrs.cpp [deleted file]
src/XGUI/XGUI_ViewerPrs.h [deleted file]
src/XGUI/XGUI_Workshop.cpp
src/XGUI/XGUI_Workshop.h

index 4f70d821c7df0d7b6820462f9f0bcc72fad7611a..7a276cea134134a10a953b34b7f81d8f2f53736d 100644 (file)
@@ -33,6 +33,7 @@ ADD_SUBDIRECTORY (src/GeomData)
 ADD_SUBDIRECTORY (src/GeomDataAPI)
 ADD_SUBDIRECTORY (src/PartSetPlugin)
 ADD_SUBDIRECTORY (src/ConstructionPlugin)
+ADD_SUBDIRECTORY (src/FeaturesPlugin)
 ADD_SUBDIRECTORY (src/SketchPlugin)
 ADD_SUBDIRECTORY (src/SketchSolver)
 ADD_SUBDIRECTORY (src/ModuleBase)
index e54794df6bcae5207337f07b5d70121752445c48..a4d1dbdae5e3f237a7e3f8088c232a7f9909908a 100644 (file)
@@ -2,6 +2,7 @@
   <plugin library="PartSetPlugin" configuration="plugin-PartSet.xml"/>
   <plugin library="SketchPlugin" configuration="plugin-Sketch.xml"/>
   <plugin library="ConstructionPlugin" configuration="plugin-Construction.xml"/>
+  <plugin library="FeaturesPlugin" configuration="plugin-Features.xml"/>
   <plugin library="SketchSolver"/>
   <plugin library="DFBrowser"/>
 </plugins>
index dc32be9876c22203738ac932552f1a2d68671448..1c81b62aaad584e2481476434ae9f4d9665d084f 100644 (file)
@@ -4,13 +4,11 @@ SET(PROJECT_HEADERS
     ConstructionPlugin.h
     ConstructionPlugin_Plugin.h
     ConstructionPlugin_Point.h
-    ConstructionPlugin_Extrusion.h
 )
 
 SET(PROJECT_SOURCES
     ConstructionPlugin_Plugin.cpp
     ConstructionPlugin_Point.cpp
-    ConstructionPlugin_Extrusion.cpp
 )
 
 ADD_DEFINITIONS(-DCONSTRUCTIONPLUGIN_EXPORTS ${BOOST_DEFINITIONS})
@@ -26,7 +24,6 @@ INCLUDE_DIRECTORIES(
 SET(XML_RESOURCES
   plugin-Construction.xml
   point_widget.xml
-  extrusion_widget.xml
 )
 
 INSTALL(TARGETS ConstructionPlugin DESTINATION plugins)
diff --git a/src/ConstructionPlugin/ConstructionPlugin_Extrusion.cpp b/src/ConstructionPlugin/ConstructionPlugin_Extrusion.cpp
deleted file mode 100644 (file)
index 0af9cad..0000000
+++ /dev/null
@@ -1,45 +0,0 @@
-// File:        ConstructionPlugin_Extrusion.cpp
-// Created:     30 May 2014
-// Author:      Vitaly SMETANNIKOV
-
-#include "ConstructionPlugin_Extrusion.h"
-#include <ModelAPI_PluginManager.h>
-#include <ModelAPI_Document.h>
-#include <ModelAPI_Data.h>
-#include <ModelAPI_AttributeDouble.h>
-#include <ModelAPI_AttributeReference.h>
-#include <ModelAPI_AttributeBoolean.h>
-
-#include <GeomAlgoAPI_Extrusion.h>
-
-using namespace std;
-
-ConstructionPlugin_Extrusion::ConstructionPlugin_Extrusion()
-{
-}
-
-void ConstructionPlugin_Extrusion::initAttributes()
-{
-  data()->addAttribute(EXTRUSION_FACE, ModelAPI_AttributeReference::type());
-  data()->addAttribute(EXTRUSION_SIZE, ModelAPI_AttributeDouble::type());
-  data()->addAttribute(EXTRUSION_REVERSE, ModelAPI_AttributeBoolean::type());
-}
-
-void ConstructionPlugin_Extrusion::execute()
-{
-  boost::shared_ptr<ModelAPI_AttributeReference> aFaceRef = 
-    boost::dynamic_pointer_cast<ModelAPI_AttributeReference>(data()->attribute(EXTRUSION_FACE));
-  if (!aFaceRef)
-    return;
-  FeaturePtr aFaceFeature = aFaceRef->value();
-  if (!aFaceFeature)
-    return;
-  boost::shared_ptr<GeomAPI_Shape> aFace = aFaceFeature->data()->shape();
-  if (!aFace)
-    return;
-
-  double aSize = data()->real(EXTRUSION_SIZE)->value();
-  if (data()->boolean(EXTRUSION_REVERSE)->value())
-    aSize = -aSize;
-  data()->store(GeomAlgoAPI_Extrusion::makeExtrusion(aFace, aSize));
-}
diff --git a/src/ConstructionPlugin/ConstructionPlugin_Extrusion.h b/src/ConstructionPlugin/ConstructionPlugin_Extrusion.h
deleted file mode 100644 (file)
index 5933929..0000000
+++ /dev/null
@@ -1,45 +0,0 @@
-// File:        ConstructionPlugin_Extrusion.h
-// Created:     30 May 2014
-// Author:      Vitaly SMETANNIKOV
-
-#ifndef ConstructionPlugin_Extrusion_HeaderFile
-#define ConstructionPlugin_Extrusion_HeaderFile
-
-#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_face";
-
-/// attribute name of extrusion size
-const std::string EXTRUSION_SIZE = "extrusion_size";
-
-/// attribute name of reverce direction
-const std::string EXTRUSION_REVERSE = "extrusion_reverse";
-
-
-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 = CONSTRUCTION_EXTRUSION_KIND; return MY_KIND; }
-
-  /// Returns to which group in the document must be added feature
-  CONSTRUCTIONPLUGIN_EXPORT virtual const std::string& getGroup() 
-  { static std::string MY_GROUP = "Construction";  return MY_GROUP; }
-
-  /// Creates a new part document if needed
-  CONSTRUCTIONPLUGIN_EXPORT virtual void execute();
-
-  /// Request for initialization of data model of the feature: adding all attributes
-  CONSTRUCTIONPLUGIN_EXPORT virtual void initAttributes();
-
-  /// Use plugin manager for features creation
-  ConstructionPlugin_Extrusion();
-};
-
-#endif
index d420b21104827a33f6e25cf279d0ba2cb77db4c5..6b0d729a44c68919eb1cdfe1fe29276cf9de4037 100644 (file)
@@ -1,6 +1,5 @@
 #include "ConstructionPlugin_Plugin.h"
 #include "ConstructionPlugin_Point.h"
-#include "ConstructionPlugin_Extrusion.h"
 
 #include <ModelAPI_PluginManager.h>
 #include <ModelAPI_Document.h>
@@ -20,8 +19,6 @@ FeaturePtr ConstructionPlugin_Plugin::createFeature(string theFeatureID)
 {
   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 FeaturePtr();
diff --git a/src/ConstructionPlugin/extrusion_widget.xml b/src/ConstructionPlugin/extrusion_widget.xml
deleted file mode 100644 (file)
index c0069ca..0000000
+++ /dev/null
@@ -1,11 +0,0 @@
-<source>
-  <selector id="extrusion_face" 
-    label="Select a face" 
-    icon=":icons/sketch.png" 
-    tooltip="Select a face for extrusion"
-    activate="true"
-    shape_types="face"
-  />
-  <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"/>
-</source>
index 4736d36cfa54344fbd11db2b318b8c8306917f41..b3fdc4608c6ae1054cff9a91c7201cdf2412605b 100644 (file)
@@ -6,9 +6,6 @@
       </feature>
       <feature id="Axis" title="Axis" tooltip="Create a new axis" icon=":icons/axis.png" keysequence="" internal="true"/>
       <feature id="Plane" title="Plane" tooltip="Create a new plane" icon=":icons/plane.png" keysequence="" internal="true"/>
-      <feature id="Extrusion" title="Extrusion" tooltip="Create a shape by extrusion of a contour" icon=":icons/extrusion.png">
-          <source path="extrusion_widget.xml"/>
-      </feature>
     </group>
 </workbench>  
 </plugin>
diff --git a/src/FeaturesPlugin/CMakeLists.txt b/src/FeaturesPlugin/CMakeLists.txt
new file mode 100644 (file)
index 0000000..29e0878
--- /dev/null
@@ -0,0 +1,30 @@
+INCLUDE(Common)
+
+SET(PROJECT_HEADERS
+    FeaturesPlugin.h
+    FeaturesPlugin_Plugin.h
+    FeaturesPlugin_Extrusion.h
+)
+
+SET(PROJECT_SOURCES
+    FeaturesPlugin_Plugin.cpp
+    FeaturesPlugin_Extrusion.cpp
+)
+
+ADD_DEFINITIONS(-DFEATURESPLUGIN_EXPORTS ${BOOST_DEFINITIONS})
+ADD_LIBRARY(FeaturesPlugin SHARED ${PROJECT_SOURCES} ${PROJECT_HEADERS})
+TARGET_LINK_LIBRARIES(FeaturesPlugin ${PROJECT_LIBRARIES} ModelAPI GeomAPI GeomAlgoAPI)
+
+INCLUDE_DIRECTORIES(
+  ../ModelAPI
+  ../GeomAPI
+  ../GeomAlgoAPI
+)
+
+SET(XML_RESOURCES
+  plugin-Features.xml
+  extrusion_widget.xml
+)
+
+INSTALL(TARGETS FeaturesPlugin DESTINATION plugins)
+INSTALL(FILES ${XML_RESOURCES} DESTINATION plugins)
diff --git a/src/FeaturesPlugin/FeaturesPlugin.h b/src/FeaturesPlugin/FeaturesPlugin.h
new file mode 100644 (file)
index 0000000..2e931e2
--- /dev/null
@@ -0,0 +1,18 @@
+#ifndef FEATURESPLUGIN_H
+#define FEATURESPLUGIN_H
+
+#if defined FEATURESPLUGIN_EXPORTS
+#if defined WIN32
+#define FEATURESPLUGIN_EXPORT              __declspec( dllexport )
+#else
+#define FEATURESPLUGIN_EXPORT
+#endif
+#else
+#if defined WIN32
+#define FEATURESPLUGIN_EXPORT              __declspec( dllimport )
+#else
+#define FEATURESPLUGIN_EXPORT
+#endif
+#endif
+
+#endif
diff --git a/src/FeaturesPlugin/FeaturesPlugin_Extrusion.cpp b/src/FeaturesPlugin/FeaturesPlugin_Extrusion.cpp
new file mode 100644 (file)
index 0000000..328dde5
--- /dev/null
@@ -0,0 +1,45 @@
+// File:        FeaturesPlugin_Extrusion.cpp
+// Created:     30 May 2014
+// Author:      Vitaly SMETANNIKOV
+
+#include "FeaturesPlugin_Extrusion.h"
+#include <ModelAPI_PluginManager.h>
+#include <ModelAPI_Document.h>
+#include <ModelAPI_Data.h>
+#include <ModelAPI_AttributeDouble.h>
+#include <ModelAPI_AttributeReference.h>
+#include <ModelAPI_AttributeBoolean.h>
+
+#include <GeomAlgoAPI_Extrusion.h>
+
+using namespace std;
+
+FeaturesPlugin_Extrusion::FeaturesPlugin_Extrusion()
+{
+}
+
+void FeaturesPlugin_Extrusion::initAttributes()
+{
+  data()->addAttribute(EXTRUSION_FACE, ModelAPI_AttributeReference::type());
+  data()->addAttribute(EXTRUSION_SIZE, ModelAPI_AttributeDouble::type());
+  data()->addAttribute(EXTRUSION_REVERSE, ModelAPI_AttributeBoolean::type());
+}
+
+void FeaturesPlugin_Extrusion::execute()
+{
+  boost::shared_ptr<ModelAPI_AttributeReference> aFaceRef = 
+    boost::dynamic_pointer_cast<ModelAPI_AttributeReference>(data()->attribute(EXTRUSION_FACE));
+  if (!aFaceRef)
+    return;
+  FeaturePtr aFaceFeature = aFaceRef->value();
+  if (!aFaceFeature)
+    return;
+  boost::shared_ptr<GeomAPI_Shape> aFace = aFaceFeature->data()->shape();
+  if (!aFace)
+    return;
+
+  double aSize = data()->real(EXTRUSION_SIZE)->value();
+  if (data()->boolean(EXTRUSION_REVERSE)->value())
+    aSize = -aSize;
+  data()->store(GeomAlgoAPI_Extrusion::makeExtrusion(aFace, aSize));
+}
diff --git a/src/FeaturesPlugin/FeaturesPlugin_Extrusion.h b/src/FeaturesPlugin/FeaturesPlugin_Extrusion.h
new file mode 100644 (file)
index 0000000..95c8f98
--- /dev/null
@@ -0,0 +1,45 @@
+// File:        FeaturesPlugin_Extrusion.h
+// Created:     30 May 2014
+// Author:      Vitaly SMETANNIKOV
+
+#ifndef FeaturesPlugin_Extrusion_HeaderFile
+#define FeaturesPlugin_Extrusion_HeaderFile
+
+#include "FeaturesPlugin.h"
+#include <ModelAPI_Feature.h>
+
+/// Extrusion kind
+const std::string FEATURES_EXTRUSION_KIND("Extrusion");
+
+/// attribute name of referenced face
+const std::string EXTRUSION_FACE = "extrusion_face";
+
+/// attribute name of extrusion size
+const std::string EXTRUSION_SIZE = "extrusion_size";
+
+/// attribute name of reverse direction
+const std::string EXTRUSION_REVERSE = "extrusion_reverse";
+
+
+class FeaturesPlugin_Extrusion: public ModelAPI_Feature
+{
+public:
+  /// Returns the kind of a feature
+  FEATURESPLUGIN_EXPORT virtual const std::string& getKind() 
+  { static std::string MY_KIND = FEATURES_EXTRUSION_KIND; return MY_KIND; }
+
+  /// Returns to which group in the document must be added feature
+  FEATURESPLUGIN_EXPORT virtual const std::string& getGroup() 
+  { static std::string MY_GROUP = "Construction";  return MY_GROUP; }
+
+  /// Creates a new part document if needed
+  FEATURESPLUGIN_EXPORT virtual void execute();
+
+  /// Request for initialization of data model of the feature: adding all attributes
+  FEATURESPLUGIN_EXPORT virtual void initAttributes();
+
+  /// Use plugin manager for features creation
+  FeaturesPlugin_Extrusion();
+};
+
+#endif
diff --git a/src/FeaturesPlugin/FeaturesPlugin_Plugin.cpp b/src/FeaturesPlugin/FeaturesPlugin_Plugin.cpp
new file mode 100644 (file)
index 0000000..1c9273d
--- /dev/null
@@ -0,0 +1,25 @@
+#include "FeaturesPlugin_Plugin.h"
+#include "FeaturesPlugin_Extrusion.h"
+
+#include <ModelAPI_PluginManager.h>
+#include <ModelAPI_Document.h>
+
+using namespace std;
+
+// the only created instance of this plugin
+static FeaturesPlugin_Plugin* MY_INSTANCE = new FeaturesPlugin_Plugin();
+
+FeaturesPlugin_Plugin::FeaturesPlugin_Plugin() 
+{
+  // register this plugin
+  ModelAPI_PluginManager::get()->registerPlugin(this);
+}
+
+FeaturePtr FeaturesPlugin_Plugin::createFeature(string theFeatureID)
+{
+  if (theFeatureID == FEATURES_EXTRUSION_KIND) {
+    return FeaturePtr(new FeaturesPlugin_Extrusion);
+  }
+  // feature of such kind is not found
+  return FeaturePtr();
+}
diff --git a/src/FeaturesPlugin/FeaturesPlugin_Plugin.h b/src/FeaturesPlugin/FeaturesPlugin_Plugin.h
new file mode 100644 (file)
index 0000000..3ec8c12
--- /dev/null
@@ -0,0 +1,24 @@
+// File:        FeaturesPlugin_Plugin.hxx
+// Created:     07 July 2014
+// Author:      Vitaly SMETANNIKOV
+
+#ifndef FeaturesPlugin_Plugin_HeaderFile
+#define FeaturesPlugin_Plugin_HeaderFile
+
+
+#include "FeaturesPlugin.h"
+#include <ModelAPI_Plugin.h>
+#include <ModelAPI_Feature.h>
+
+class FEATURESPLUGIN_EXPORT FeaturesPlugin_Plugin: public ModelAPI_Plugin
+{
+public:
+  /// Creates the feature object of this plugin by the feature string ID
+  virtual FeaturePtr createFeature(std::string theFeatureID);
+
+public:
+  /// Is needed for python wrapping by swig
+  FeaturesPlugin_Plugin();
+};
+
+#endif
diff --git a/src/FeaturesPlugin/extrusion_widget.xml b/src/FeaturesPlugin/extrusion_widget.xml
new file mode 100644 (file)
index 0000000..c0069ca
--- /dev/null
@@ -0,0 +1,11 @@
+<source>
+  <selector id="extrusion_face" 
+    label="Select a face" 
+    icon=":icons/sketch.png" 
+    tooltip="Select a face for extrusion"
+    activate="true"
+    shape_types="face"
+  />
+  <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"/>
+</source>
diff --git a/src/FeaturesPlugin/plugin-Features.xml b/src/FeaturesPlugin/plugin-Features.xml
new file mode 100644 (file)
index 0000000..783d373
--- /dev/null
@@ -0,0 +1,9 @@
+<plugin>
+  <workbench id="Features">
+    <group id="Basic">
+      <feature id="Extrusion" title="Extrusion" tooltip="Create a shape by extrusion of a contour" icon=":icons/extrusion.png">
+          <source path="extrusion_widget.xml"/>
+      </feature>
+    </group>
+</workbench>  
+</plugin>
index fe7110924634b04434eedb72f2e73e0f4de07ddb..3f6e1c6caabbeb90b5bccd67bcdaedba39b7ea1d 100644 (file)
@@ -77,7 +77,7 @@ const ModelAPI_Validator* Model_ValidatorsFactory::validator(const string& theFe
   return NULL; // not found
 }
 
-bool Model_ValidatorsFactory::validate(
+/*bool Model_ValidatorsFactory::validate(
   const boost::shared_ptr<ModelAPI_Feature>& theFeature, const string& theAttrID ) const
 {
   map<string, map<string, pair<ModelAPI_Validator*, list<string> > > >::const_iterator
@@ -87,7 +87,7 @@ bool Model_ValidatorsFactory::validate(
     anAttr = aFeature->second.find(theAttrID);
   if (anAttr == aFeature->second.cend()) return true; // attribute is not found
   return anAttr->second.first->validate(theFeature, theAttrID, anAttr->second.second);
-}
+}*/
 
 Model_ValidatorsFactory::Model_ValidatorsFactory() : ModelAPI_ValidatorsFactory()
 {
index 9d04e290167ff128c9134a8cb9122f1f966d55c9..a917911d91c5dce5218c927a4167a21b6ebd0041 100644 (file)
@@ -46,8 +46,8 @@ public:
 
   /// Returns the result of "validate" method for attribute of validator.
   /// If validator is not exists, returns true: everything is valid by default.
-  MODEL_EXPORT virtual bool validate(
-    const boost::shared_ptr<ModelAPI_Feature>& theFeature, const std::string& theAttrID) const;
+  //MODEL_EXPORT virtual bool validate(
+  //  const boost::shared_ptr<ModelAPI_Feature>& theFeature, const std::string& theAttrID) const;
 
 protected:
   /// Get instance from PluginManager
index 5a13d37a656f9463992df4272f652b15d046ad69..8b834dd72561b7790f3bde8fa3a7048c8c786983 100644 (file)
@@ -19,6 +19,7 @@ SET(PROJECT_HEADERS
     ModelAPI_AttributeBoolean.h
     ModelAPI_Events.h
     ModelAPI_Validator.h
+    ModelAPI_FeatureValidator.h
 )
 
 SET(PROJECT_SOURCES
diff --git a/src/ModelAPI/ModelAPI_FeatureValidator.h b/src/ModelAPI/ModelAPI_FeatureValidator.h
new file mode 100644 (file)
index 0000000..2023a66
--- /dev/null
@@ -0,0 +1,22 @@
+// File:        ModelAPI_FeatureValidator.h
+// Created:     8 Jul 2014
+// Author:      Vitaly SMETANNIKOV
+
+#ifndef ModelAPI_FeatureValidator_H
+#define ModelAPI_FeatureValidator_H
+
+#include "ModelAPI.h"
+#include "ModelAPI_Validator.h"
+
+class MODELAPI_EXPORT ModelAPI_FeatureValidator: public ModelAPI_Validator
+{
+public:
+  /// Returns true if feature and/or attributes are valid
+  /// \param theFeature the validated feature
+  /// \param theAttr the validated attribute ID, empty string of feature is validated
+  /// \param theArguments list of string, feature attribute names: dependent attributes
+  virtual bool validate(const boost::shared_ptr<ModelAPI_Feature>& theFeature,
+    const std::string theAttr, std::list<std::string> theArguments) const = 0;
+};
+
+#endif
index 4a0243cd009627cb30dce073b43d3a3e47bd0403..4c807763ac2f2cd104415b062846b1fc8e23444f 100644 (file)
@@ -25,12 +25,15 @@ class ModelAPI_Feature;
 class MODELAPI_EXPORT ModelAPI_Validator
 {
 public:
+  // Make virtual destructor in order to make the class polymorphic
+  virtual ~ModelAPI_Validator() {};
+
   /// Returns true if feature and/or attributes are valid
   /// \param theFeature the validated feature
   /// \param theAttr the validated attribute ID, empty string of feature is validated
   /// \param theArguments list of string, feature attribute names: dependent attributes
-  virtual bool validate(const boost::shared_ptr<ModelAPI_Feature>& theFeature,
-    const std::string theAttr, std::list<std::string> theArguments) const = 0;
+  //virtual bool validate(const boost::shared_ptr<ModelAPI_Feature>& theFeature,
+  //  const std::string theAttr, std::list<std::string> theArguments) const = 0;
 };
 
 typedef boost::shared_ptr<ModelAPI_Validator> ValidatorPtr;
@@ -66,8 +69,8 @@ public:
 
   /// Returns the result of "validate" method for attribute of validator.
   /// If validator is not exists, returns true: everything is valid by default.
-  virtual bool validate(
-    const boost::shared_ptr<ModelAPI_Feature>& theFeature, const std::string& theAttrID) const = 0;
+  //virtual bool validate(
+  //  const boost::shared_ptr<ModelAPI_Feature>& theFeature, const std::string& theAttrID) const = 0;
 
 protected:
   /// Get instance from PluginManager
index 6b3847b293b466d43282a28cd566ba386c616a31..b21756a5c39ff3dc9c72c13d5cbfd6696a9308cc 100644 (file)
@@ -22,6 +22,9 @@ SET(PROJECT_HEADERS
        ModuleBase_WidgetValue.h
        ModuleBase_WidgetValueFeature.h
        ModuleBase_Definitions.h
+       ModuleBase_SelectionValidator.h
+       ModuleBase_ISelection.h
+       ModuleBase_ViewerPrs.h
 )
 
 SET(PROJECT_SOURCES
index 6a4401f765e27efa2f7c1b83576ce313564595f9..ae652617e9f8a4f5ae7d39576d6fc0bd3f37f1ea 100644 (file)
@@ -6,6 +6,8 @@
 
 class QAction;
 class XGUI_Workshop;
+class Config_WidgetAPI;
+class ModuleBase_ModelWidget;
 
 /**
 * Interface to a module
@@ -24,7 +26,14 @@ public:
   virtual void launchOperation(const QString& theCmdId) = 0;
 
   /// Called when it is necessary to update a command state (enable or disable it)
-  virtual bool isFeatureEnabled(const QString& theCmdId) const = 0;
+  //virtual bool isFeatureEnabled(const QString& theCmdId) const = 0;
+
+  /// Creates custom widgets for property panel
+  virtual QWidget* createWidgetByType(const std::string& theType, QWidget* theParent, 
+    Config_WidgetAPI* theWidgetApi, QList<ModuleBase_ModelWidget*>& theModelWidgets)
+  {
+    return 0;
+  }
 
   virtual ~ModuleBase_IModule() {};
 };
diff --git a/src/ModuleBase/ModuleBase_ISelection.h b/src/ModuleBase/ModuleBase_ISelection.h
new file mode 100644 (file)
index 0000000..0519985
--- /dev/null
@@ -0,0 +1,49 @@
+// File:        ModuleBase_ISelection.h
+// Created:     2 June 2014
+// Author:      Vitaly Smetannikov
+
+#ifndef ModuleBase_ISelection_H
+#define ModuleBase_ISelection_H
+
+#include "ModuleBase.h"
+#include "ModuleBase_Definitions.h"
+#include "ModuleBase_ViewerPrs.h"
+
+#include <QModelIndexList>
+#include <AIS_ListOfInteractive.hxx>
+#include <NCollection_List.hxx>
+#include <TopoDS_Shape.hxx>
+
+#include <list>
+
+class ModuleBase_ISelection
+{
+public:
+
+  /// 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
+  virtual std::list<ModuleBase_ViewerPrs> getSelected(int theShapeTypeToSkip = -1) const = 0;
+
+  /// 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
+  virtual std::list<ModuleBase_ViewerPrs> getHighlighted(int theShapeTypeToSkip = -1) const = 0;
+
+  /**
+  * Returns list of features currently selected in 3d viewer
+  */
+  virtual QFeatureList selectedFeatures() const = 0;
+  
+  //! Returns list of currently selected QModelIndexes
+  virtual QModelIndexList selectedIndexes() const = 0;
+
+  //! Returns list of currently selected AIS objects
+  virtual void selectedAISObjects(AIS_ListOfInteractive& theList) const = 0;
+
+  //! Returns list of currently selected shapes
+  virtual void selectedShapes(NCollection_List<TopoDS_Shape>& theList) const = 0;
+
+};
+
+#endif
\ No newline at end of file
index d9dcf5405fb4d8968a5f9259566a96080c2ff3b9..4d6e920b0a504c442fd6a5ffe99f6267c0a93794 100644 (file)
@@ -13,6 +13,8 @@
 
 #include <QObject>
 
+class ModuleBase_IModule;
+
 /**
 * Class which provides access to Workshop object serveces
 */
@@ -30,6 +32,9 @@ public:
   //! Returns list of currently selected data objects
   virtual QList<FeaturePtr> selectedFeatures() const = 0; 
 
+  //! Returns instance of loaded module
+  virtual ModuleBase_IModule* module() const = 0;
+
 signals:
   void selectionChanged();
 };
diff --git a/src/ModuleBase/ModuleBase_SelectionValidator.h b/src/ModuleBase/ModuleBase_SelectionValidator.h
new file mode 100644 (file)
index 0000000..1dd3801
--- /dev/null
@@ -0,0 +1,20 @@
+// File:        ModuleBase_SelectionValidator.h
+// Created:     8 Jul 2014
+// Author:      Vitaly SMETANNIKOV
+
+#ifndef ModuleBase_SelectionValidator_H
+#define ModuleBase_SelectionValidator_H
+
+#include "ModuleBase.h"
+#include "ModuleBase_ISelection.h"
+
+#include <ModelAPI_Validator.h>
+
+
+class ModuleBase_SelectionValidator: public ModelAPI_Validator
+{
+public:
+  virtual bool isValid(const ModuleBase_ISelection* theSelection) const = 0;
+};
+
+#endif
diff --git a/src/ModuleBase/ModuleBase_ViewerPrs.h b/src/ModuleBase/ModuleBase_ViewerPrs.h
new file mode 100644 (file)
index 0000000..b595ac1
--- /dev/null
@@ -0,0 +1,76 @@
+// File:        ModuleBase_ViewerPrs.h
+// Created:     20 Apr 2014
+// Author:      Natalia ERMOLAEVA
+
+#ifndef ModuleBase_ViewerPrs_H
+#define ModuleBase_ViewerPrs_H
+
+#include "ModuleBase.h"
+
+#include <boost/shared_ptr.hpp>
+#include <TopoDS_Shape.hxx>
+#include <SelectMgr_EntityOwner.hxx>
+
+#include <ModelAPI_Feature.h>
+
+/**\class ModuleBase_ViewerPrs
+ * \ingroup Module base
+ * \brief Presentation. Provides container to have feature, shape and/or selection owner.
+ */
+class ModuleBase_ViewerPrs
+{
+public:
+  /// Constructor
+  ModuleBase_ViewerPrs() {}
+  
+  /// Constructor
+  /// \param theFeature a model feature
+  /// \param theShape a viewer shape
+  /// \param theOwner a selection owner
+  ModuleBase_ViewerPrs(FeaturePtr theFeature,
+                 const TopoDS_Shape& theShape,
+                 Handle_SelectMgr_EntityOwner theOwner)
+  : myFeature(theFeature), myShape(theShape), myOwner(theOwner) {}
+  
+  /// Destructor
+  virtual ~ModuleBase_ViewerPrs() {}
+
+  /// Sets the feature.
+  /// \param theFeature a feature instance
+  void setFeature(FeaturePtr theFeature) { myFeature = theFeature; }
+
+  /// Returns the feature.
+  /// \return a feature instance
+  FeaturePtr feature() const { return myFeature; }
+
+  /// Returns the presentation owner
+  /// \param the owner
+  void setOwner(Handle_SelectMgr_EntityOwner theOwner) { myOwner = theOwner; }
+
+  /// Returns the presentation owner
+  /// \return an owner
+  Handle_SelectMgr_EntityOwner owner() const { return myOwner; }
+
+  /// Sets the shape
+  /// \param theShape a shape instance
+  void setShape(const TopoDS_Shape& theShape) { myShape = theShape; }
+
+  /// Returns the shape
+  /// \return a shape instance
+  const TopoDS_Shape& shape() const { return myShape; }
+
+  bool operator==(const ModuleBase_ViewerPrs& thePrs)
+  {
+    bool aFeature = (myFeature.get() == thePrs.feature().get());
+    bool aOwner = (myOwner.Access() == thePrs.owner().Access());
+    bool aShape = myShape.IsEqual(thePrs.shape());
+    return aFeature && aOwner && aShape;
+  }
+
+private:
+  FeaturePtr myFeature; /// the feature
+  Handle(SelectMgr_EntityOwner) myOwner; /// the selection owner
+  TopoDS_Shape myShape; /// the shape
+};
+
+#endif
index edb98aee88c9646ff232cb2632d4247518205d9c..0c62cf36106de4730782099a10e05de8203e15be 100644 (file)
@@ -18,6 +18,8 @@
 #include <ModuleBase_WidgetDoubleValue.h>
 #include <ModuleBase_WidgetBoolValue.h>
 #include <ModuleBase_WidgetPoint2dDistance.h>
+#include <ModuleBase_IWorkshop.h>
+#include <ModuleBase_IModule.h>
 
 #include <Config_Keywords.h>
 #include <Config_WidgetAPI.h>
@@ -144,10 +146,12 @@ QWidget* ModuleBase_WidgetFactory::createWidgetByType(const std::string& theType
   }
   else if (myWidgetApi->isContainerWidget() || myWidgetApi->isPagedWidget()) {
     result = createContainer(theType, theParent);
-  }
+  } else {
+    result = myWorkshop->module()->createWidgetByType(theType, theParent, myWidgetApi, myModelWidgets);
 #ifdef _DEBUG
-  else { qDebug() << "ModuleBase_WidgetFactory::fillWidget: find bad widget type"; }
+    if (!result) { qDebug("ModuleBase_WidgetFactory::fillWidget: find bad widget type"); }
 #endif
+  }
   return result;
 }
 
index 9a90b72f761bd7930f650a46349fd34121c871dc..235acf63ac113e40ac5da2bab6414208b597f8f9 100644 (file)
@@ -15,6 +15,7 @@ SET(PROJECT_HEADERS
        PartSet_OperationSketch.h
        PartSet_TestOCC.h
        PartSet_Tools.h
+       PartSet_WidgetSketchLabel.h
 )
 
 SET(PROJECT_SOURCES
@@ -28,6 +29,7 @@ SET(PROJECT_SOURCES
        PartSet_OperationSketch.cpp
        PartSet_TestOCC.cpp
        PartSet_Tools.cpp
+       PartSet_WidgetSketchLabel.cpp
 )
 
 SET(PROJECT_RESOURCES 
index 990c9e44bceeb1625de372a8ebb795fc0eaec4d2..2824363e1d4d8b3a9c3f7039774e30b880546eb3 100644 (file)
@@ -8,10 +8,13 @@
 #include <ModuleBase_WidgetFactory.h>
 #include <PartSet_Listener.h>
 #include <PartSet_TestOCC.h>
+#include <PartSet_WidgetSketchLabel.h>
+#include <PartSet_Validators.h>
 
 #include <ModuleBase_Operation.h>
 #include <ModelAPI_Object.h>
 #include <ModelAPI_Events.h>
+#include <ModelAPI_Validator.h>
 
 #include <ModelAPI_Data.h>
 #include <GeomDataAPI_Point2D.h>
@@ -23,6 +26,7 @@
 #include <XGUI_Workshop.h>
 #include <XGUI_OperationMgr.h>
 #include <XGUI_SelectionMgr.h>
+#include <XGUI_Selection.h>
 #include <XGUI_ViewPort.h>
 #include <XGUI_ActionsMgr.h>
 #include <XGUI_ViewerProxy.h>
@@ -100,6 +104,16 @@ void PartSet_Module::createFeatures()
   Config_ModuleReader aXMLReader = Config_ModuleReader();
   aXMLReader.readAll();
   myFeaturesInFiles = aXMLReader.featuresInFiles();
+
+  //!! Test registering of validators
+  PluginManagerPtr aMgr = ModelAPI_PluginManager::get();
+  ModelAPI_ValidatorsFactory* aFactory = aMgr->validators();
+  
+  aFactory->registerValidator("PartSet_DistanceValidator", new PartSet_DistanceValidator);
+  aFactory->assignValidator("PartSet_DistanceValidator", "SketchConstraintDistance");
+
+  aFactory->registerValidator("PartSet_LengthValidator", new PartSet_LengthValidator);
+  aFactory->assignValidator("PartSet_LengthValidator", "SketchConstraintLength");
 }
 
 void PartSet_Module::featureCreated(QAction* theFeature)
@@ -139,10 +153,10 @@ void PartSet_Module::launchOperation(const QString& theCmdId)
   ModuleBase_Operation* anOperation = createOperation(theCmdId.toStdString());
   PartSet_OperationSketchBase* aPreviewOp = dynamic_cast<PartSet_OperationSketchBase*>(anOperation);
   if (aPreviewOp) {
-    XGUI_Displayer* aDisplayer = myWorkshop->displayer();
+    XGUI_Selection* aSelection = myWorkshop->selector()->selection();
     // Initialise operation with preliminary selection
-    std::list<XGUI_ViewerPrs> aSelected = aDisplayer->getSelected();
-    std::list<XGUI_ViewerPrs> aHighlighted = aDisplayer->getHighlighted();
+    std::list<ModuleBase_ViewerPrs> aSelected = aSelection->getSelected();
+    std::list<ModuleBase_ViewerPrs> aHighlighted = aSelection->getHighlighted();
     aPreviewOp->initSelection(aSelected, aHighlighted);
   } 
   sendOperation(anOperation);
@@ -173,7 +187,7 @@ void PartSet_Module::onOperationStopped(ModuleBase_Operation* theOperation)
 
 void PartSet_Module::onContextMenuCommand(const QString& theId, bool isChecked)
 {
-  QFeatureList aFeatures = myWorkshop->selector()->selectedFeatures();
+  QFeatureList aFeatures = myWorkshop->selector()->selection()->selectedFeatures();
   if (theId == "EDIT_CMD" && (aFeatures.size() > 0)) {
     editFeature(aFeatures.first());
   }
@@ -184,9 +198,10 @@ void PartSet_Module::onMousePressed(QMouseEvent* theEvent)
   PartSet_OperationSketchBase* aPreviewOp = dynamic_cast<PartSet_OperationSketchBase*>(
                                        myWorkshop->operationMgr()->currentOperation());
   if (aPreviewOp) {
-    XGUI_Displayer* aDisplayer = myWorkshop->displayer();
-    std::list<XGUI_ViewerPrs> aSelected = aDisplayer->getSelected();
-    std::list<XGUI_ViewerPrs> aHighlighted = aDisplayer->getHighlighted();
+    XGUI_Selection* aSelection = myWorkshop->selector()->selection();
+    // Initialise operation with preliminary selection
+    std::list<ModuleBase_ViewerPrs> aSelected = aSelection->getSelected();
+    std::list<ModuleBase_ViewerPrs> aHighlighted = aSelection->getHighlighted();
 
     aPreviewOp->mousePressed(theEvent, myWorkshop->viewer()->activeView(), aSelected, aHighlighted);
   }
@@ -198,9 +213,10 @@ void PartSet_Module::onMouseReleased(QMouseEvent* theEvent)
                                        myWorkshop->operationMgr()->currentOperation());
   if (aPreviewOp)
   {
-    XGUI_Displayer* aDisplayer = myWorkshop->displayer();
-    std::list<XGUI_ViewerPrs> aSelected = aDisplayer->getSelected();
-    std::list<XGUI_ViewerPrs> aHighlighted = aDisplayer->getHighlighted();
+    XGUI_Selection* aSelection = myWorkshop->selector()->selection();
+    // Initialise operation with preliminary selection
+    std::list<ModuleBase_ViewerPrs> aSelected = aSelection->getSelected();
+    std::list<ModuleBase_ViewerPrs> aHighlighted = aSelection->getHighlighted();
 
     aPreviewOp->mouseReleased(theEvent, myWorkshop->viewer()->activeView(), aSelected, aHighlighted);
   }
@@ -229,9 +245,10 @@ void PartSet_Module::onMouseDoubleClick(QMouseEvent* theEvent)
                                        myWorkshop->operationMgr()->currentOperation());
   if (aPreviewOp)
   {
-    XGUI_Displayer* aDisplayer = myWorkshop->displayer();
-    std::list<XGUI_ViewerPrs> aSelected = aDisplayer->getSelected();
-    std::list<XGUI_ViewerPrs> aHighlighted = aDisplayer->getHighlighted();
+    XGUI_Selection* aSelection = myWorkshop->selector()->selection();
+    // Initialise operation with preliminary selection
+    std::list<ModuleBase_ViewerPrs> aSelected = aSelection->getSelected();
+    std::list<ModuleBase_ViewerPrs> aHighlighted = aSelection->getHighlighted();
     aPreviewOp->mouseDoubleClick(theEvent, myWorkshop->viewer()->activeView(), aSelected,
                                  aHighlighted);
   }
@@ -257,10 +274,10 @@ void PartSet_Module::onLaunchOperation(std::string theName, FeaturePtr theFeatur
   PartSet_OperationSketchBase* aPreviewOp = dynamic_cast<PartSet_OperationSketchBase*>(anOperation);
   if (aPreviewOp)
   {
-    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();
-    std::list<XGUI_ViewerPrs> aHighlighted = aDisplayer->getHighlighted();
+    XGUI_Selection* aSelection = myWorkshop->selector()->selection();
+    // Initialise operation with preliminary selection
+    std::list<ModuleBase_ViewerPrs> aSelected = aSelection->getSelected();
+    std::list<ModuleBase_ViewerPrs> aHighlighted = aSelection->getHighlighted();
     aPreviewOp->initFeature(theFeature);
     aPreviewOp->initSelection(aSelected, aHighlighted);
   } else {
@@ -521,7 +538,7 @@ void PartSet_Module::onStorePoint2D(FeaturePtr theFeature, const std::string& th
                                 aPoint->x(), aPoint->y());
 }
 
-bool PartSet_Module::isFeatureEnabled(const QString& theCmdId) const
+/*bool PartSet_Module::isFeatureEnabled(const QString& theCmdId) const
 {
   XGUI_OperationMgr* aOpMgr = myWorkshop->operationMgr();
   XGUI_ActionsMgr* aActMgr = myWorkshop->actionsMgr();
@@ -539,4 +556,16 @@ bool PartSet_Module::isFeatureEnabled(const QString& theCmdId) const
   }
   QStringList aList = aActMgr->nestedCommands(aOperation->id());
   return aList.contains(theCmdId);
+}*/
+
+QWidget* PartSet_Module::createWidgetByType(const std::string& theType, QWidget* theParent, 
+                         Config_WidgetAPI* theWidgetApi, QList<ModuleBase_ModelWidget*>& theModelWidgets)
+{
+  if (theType == "sketch-start-label") {
+    PartSet_WidgetSketchLabel* aWgt = new PartSet_WidgetSketchLabel(theParent, theWidgetApi);
+    aWgt->setOperationsMgr(myWorkshop->operationMgr());
+    theModelWidgets.append(aWgt);
+    return aWgt->getControl();
+  } else
+    return 0;
 }
index 261427642304dff1cf6afc7cae2e37ab20790962..627d088b15bf30c63627d5b317449d3a1191d41b 100644 (file)
@@ -49,7 +49,7 @@ public:
   virtual void launchOperation(const QString& theCmdId);
 
   /// Called when it is necessary to update a command state (enable or disable it)
-  virtual bool isFeatureEnabled(const QString& theCmdId) const;
+  //virtual bool isFeatureEnabled(const QString& theCmdId) const;
 
   /// Displays or erase the current operation preview, if it has it.
   /// \param theFeature the feature instance to be displayed
@@ -68,6 +68,11 @@ public:
   /// \param theCmdId the operation name
   void updateCurrentPreview(const std::string& theCmdId);
 
+  /// Creates custom widgets for property panel
+  virtual QWidget* createWidgetByType(const std::string& theType, QWidget* theParent, 
+    Config_WidgetAPI* theWidgetApi, QList<ModuleBase_ModelWidget*>& theModelWidgets);
+
+
 public slots:
   void onFeatureTriggered();
   /// SLOT, that is called after the operation is started. Connect on the focus activated signal
index b2f445505d96762b2a7b2e9e214c46bc433ab823..d1d5d409b42d33d6fef7bc2c638862227450ed61 100644 (file)
@@ -24,8 +24,8 @@
 #include <ModuleBase_OperationDescription.h>
 #include <ModuleBase_WidgetPoint2D.h>
 #include <ModuleBase_WidgetValueFeature.h>
+#include <ModuleBase_ViewerPrs.h>
 
-#include <XGUI_ViewerPrs.h>
 #include <XGUI_Constants.h>
 
 #include <V3d_View.hxx>
@@ -83,8 +83,8 @@ std::list<int> PartSet_OperationFeatureCreate::getSelectionModes(FeaturePtr theF
   return aModes;
 }
 
-void PartSet_OperationFeatureCreate::initSelection(const std::list<XGUI_ViewerPrs>& theSelected,
-                                                   const std::list<XGUI_ViewerPrs>& /*theHighlighted*/)
+void PartSet_OperationFeatureCreate::initSelection(const std::list<ModuleBase_ViewerPrs>& theSelected,
+                                                   const std::list<ModuleBase_ViewerPrs>& /*theHighlighted*/)
 {
   myPreSelection = theSelected;
 }
@@ -101,8 +101,8 @@ FeaturePtr PartSet_OperationFeatureCreate::sketch() const
 }
 
 void PartSet_OperationFeatureCreate::mouseReleased(QMouseEvent* theEvent, Handle(V3d_View) theView,
-                                                const std::list<XGUI_ViewerPrs>& theSelected,
-                                                const std::list<XGUI_ViewerPrs>& /*theHighlighted*/)
+                                                const std::list<ModuleBase_ViewerPrs>& theSelected,
+                                                const std::list<ModuleBase_ViewerPrs>& /*theHighlighted*/)
 {
   if (canBeCommitted())
   {
@@ -120,7 +120,7 @@ void PartSet_OperationFeatureCreate::mouseReleased(QMouseEvent* theEvent, Handle
     PartSet_Tools::convertTo2D(aPoint, sketch(), theView, aX, anY);
   }
   else {
-    XGUI_ViewerPrs aPrs = theSelected.front();
+    ModuleBase_ViewerPrs aPrs = theSelected.front();
     const TopoDS_Shape& aShape = aPrs.shape();
     if (!aShape.IsNull()) // the point is selected
     {
@@ -147,7 +147,7 @@ void PartSet_OperationFeatureCreate::mouseReleased(QMouseEvent* theEvent, Handle
   }
   FeaturePtr aFeature;
   if (!theSelected.empty()) {
-    XGUI_ViewerPrs aPrs = theSelected.front();
+    ModuleBase_ViewerPrs aPrs = theSelected.front();
     aFeature = aPrs.feature();
   }
   else
@@ -190,7 +190,7 @@ void PartSet_OperationFeatureCreate::onWidgetActivated(ModuleBase_ModelWidget* t
 {
   myActiveWidget = theWidget;
   if ((myPreSelection.size() > 0) && myActiveWidget) {
-    const XGUI_ViewerPrs& aPrs = myPreSelection.front();
+    const ModuleBase_ViewerPrs& aPrs = myPreSelection.front();
     ModuleBase_WidgetValueFeature aValue;
     aValue.setFeature(aPrs.feature());
     if (myActiveWidget->setValue(&aValue)) {
index ee711b1bc02fb3818f7cc4d3242413a0fa3add0f..f5823d6c1de244d119f8b23a423cd7f192509719 100644 (file)
@@ -60,8 +60,8 @@ public:
   /// Initialisation of operation with preliminary selection
   /// \param theSelected the list of selected presentations
   /// \param theHighlighted the list of highlighted presentations
-  virtual void initSelection(const std::list<XGUI_ViewerPrs>& theSelected,
-    const std::list<XGUI_ViewerPrs>& theHighlighted);
+  virtual void initSelection(const std::list<ModuleBase_ViewerPrs>& theSelected,
+    const std::list<ModuleBase_ViewerPrs>& theHighlighted);
 
   /// Returns the operation sketch feature
   /// \returns the sketch instance
@@ -73,8 +73,8 @@ public:
   /// \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);
+                            const std::list<ModuleBase_ViewerPrs>& theSelected,
+                            const std::list<ModuleBase_ViewerPrs>& theHighlighted);
   /// Gives the current mouse point in the viewer
   /// \param thePoint a point clicked in the viewer
   /// \param theEvent the mouse event
@@ -128,7 +128,7 @@ private:
 
   ModuleBase_ModelWidget* myActiveWidget; ///< the active widget
 
-  std::list<XGUI_ViewerPrs> myPreSelection;
+  std::list<ModuleBase_ViewerPrs> myPreSelection;
 };
 
 #endif
index 07f077d2bf04e76cf9a7a33b8ab8ce9319c4a5a4..c6ad6130ecb2902f917ec9247192110e79d12a93 100644 (file)
@@ -10,9 +10,9 @@
 
 #include <ModuleBase_OperationDescription.h>
 #include <ModuleBase_WidgetEditor.h>
-#include <ModelAPI_Events.h>
+#include <ModuleBase_ViewerPrs.h>
 
-#include <XGUI_ViewerPrs.h>
+#include <ModelAPI_Events.h>
 
 #include <SketchPlugin_Feature.h>
 #include <GeomDataAPI_Point2D.h>
@@ -70,8 +70,8 @@ FeaturePtr PartSet_OperationFeatureEdit::sketch() const
 }
 
 void PartSet_OperationFeatureEdit::mousePressed(QMouseEvent* theEvent, Handle(V3d_View) theView,
-                                             const std::list<XGUI_ViewerPrs>& theSelected,
-                                             const std::list<XGUI_ViewerPrs>& theHighlighted)
+                                             const std::list<ModuleBase_ViewerPrs>& theSelected,
+                                             const std::list<ModuleBase_ViewerPrs>& theHighlighted)
 {
   FeaturePtr aFeature;
   if (!theHighlighted.empty())
@@ -125,19 +125,19 @@ void PartSet_OperationFeatureEdit::mouseMoved(QMouseEvent* theEvent, Handle(V3d_
 }
 
 void PartSet_OperationFeatureEdit::mouseReleased(QMouseEvent* theEvent, Handle(V3d_View) theView,
-                                              const std::list<XGUI_ViewerPrs>& /*theSelected*/,
-                                              const std::list<XGUI_ViewerPrs>& /*theHighlighted*/)
+                                              const std::list<ModuleBase_ViewerPrs>& /*theSelected*/,
+                                              const std::list<ModuleBase_ViewerPrs>& /*theHighlighted*/)
 {
   blockSelection(false);
 }
 
 void PartSet_OperationFeatureEdit::mouseDoubleClick(QMouseEvent* theEvent, Handle_V3d_View theView,
-                                                    const std::list<XGUI_ViewerPrs>& theSelected,
-                                                    const std::list<XGUI_ViewerPrs>& theHighlighted)
+                                                    const std::list<ModuleBase_ViewerPrs>& theSelected,
+                                                    const std::list<ModuleBase_ViewerPrs>& theHighlighted)
 {
   // TODO the functionality is important only for constraint feature. Should be moved in another place
   if (!theSelected.empty()) {
-    XGUI_ViewerPrs aFeaturePrs = theSelected.front();
+    ModuleBase_ViewerPrs aFeaturePrs = theSelected.front();
     if (!aFeaturePrs.owner().IsNull()) {
       Handle(AIS_DimensionOwner) anOwner = Handle(AIS_DimensionOwner)::DownCast(aFeaturePrs.owner());
       if (!anOwner.IsNull() && anOwner->SelectionMode() == AIS_DSM_Text) {
index a750cf9f77e9124b4a3fde5e4f9d7b94baa21491..f64e25ab11c1b213b0e8431e8e3ed334d378b009 100644 (file)
@@ -83,8 +83,8 @@ public:
   /// \param theSelected the list of selected presentations
   /// \param theHighlighted the list of highlighted presentations
   virtual void mousePressed(QMouseEvent* theEvent, Handle_V3d_View theView,
-                            const std::list<XGUI_ViewerPrs>& theSelected,
-                            const std::list<XGUI_ViewerPrs>& theHighlighted);
+                            const std::list<ModuleBase_ViewerPrs>& theSelected,
+                            const std::list<ModuleBase_ViewerPrs>& theHighlighted);
   /// Gives the current mouse point in the viewer
   /// \param theEvent the mouse event
   /// \param theView a viewer to have the viewer the eye position
@@ -95,8 +95,8 @@ public:
   /// \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);
+                            const std::list<ModuleBase_ViewerPrs>& theSelected,
+                            const std::list<ModuleBase_ViewerPrs>& theHighlighted);
 
   /// Processes the mouse double click in the point
   /// \param theEvent the mouse event
@@ -104,8 +104,8 @@ public:
   /// \param theSelected the list of selected presentations
   /// \param theHighlighted the list of highlighted presentations
   virtual void mouseDoubleClick(QMouseEvent* theEvent, Handle_V3d_View theView,
-                                const std::list<XGUI_ViewerPrs>& theSelected,
-                                const std::list<XGUI_ViewerPrs>& theHighlighted);
+                                const std::list<ModuleBase_ViewerPrs>& theSelected,
+                                const std::list<ModuleBase_ViewerPrs>& theHighlighted);
 protected:
   /// \brief Virtual method called when operation is started
   /// Virtual method called when operation started (see start() method for more description)
index e5feef62d5a40f3a02fa2435625a4311793d7078..ac2cd698268690709d071e4cea9565324222ddf2 100644 (file)
@@ -7,9 +7,9 @@
 #include <PartSet_OperationSketch.h>
 
 #include <ModuleBase_OperationDescription.h>
-#include <ModelAPI_Events.h>
+#include <ModuleBase_ViewerPrs.h>
 
-#include <XGUI_ViewerPrs.h>
+#include <ModelAPI_Events.h>
 
 #include <SketchPlugin_Feature.h>
 #include <GeomDataAPI_Point2D.h>
@@ -48,8 +48,8 @@ bool PartSet_OperationFeatureEditMulti::isGranted(ModuleBase_IOperation* theOper
   return theOperation->getDescription()->operationId().toStdString() == PartSet_OperationSketch::Type();
 }
 
-void PartSet_OperationFeatureEditMulti::initSelection(const std::list<XGUI_ViewerPrs>& theSelected,
-                                                      const std::list<XGUI_ViewerPrs>& theHighlighted)
+void PartSet_OperationFeatureEditMulti::initSelection(const std::list<ModuleBase_ViewerPrs>& theSelected,
+                                                      const std::list<ModuleBase_ViewerPrs>& theHighlighted)
 {
   if (!theHighlighted.empty()) {
     // if there is highlighted object, we check whether it is in the list of selected objects
@@ -57,7 +57,7 @@ void PartSet_OperationFeatureEditMulti::initSelection(const std::list<XGUI_Viewe
     // the hightlighted object should moved and the selection is skipped. The skipped selection will be
     // deselected in the viewer by blockSelection signal in the startOperation method.
     bool isSelected = false;
-    std::list<XGUI_ViewerPrs>::const_iterator anIt = theSelected.begin(), aLast = theSelected.end();
+    std::list<ModuleBase_ViewerPrs>::const_iterator anIt = theSelected.begin(), aLast = theSelected.end();
     for (; anIt != aLast && !isSelected; anIt++) {
       isSelected = (*anIt).feature() == feature();
     }
@@ -81,8 +81,8 @@ FeaturePtr PartSet_OperationFeatureEditMulti::sketch() const
 }
 
 void PartSet_OperationFeatureEditMulti::mousePressed(QMouseEvent* theEvent, Handle(V3d_View) theView,
-                                             const std::list<XGUI_ViewerPrs>& /*theSelected*/,
-                                             const std::list<XGUI_ViewerPrs>& theHighlighted)
+                                             const std::list<ModuleBase_ViewerPrs>& /*theSelected*/,
+                                             const std::list<ModuleBase_ViewerPrs>& theHighlighted)
 {
 }
 
@@ -108,7 +108,7 @@ void PartSet_OperationFeatureEditMulti::mouseMoved(QMouseEvent* theEvent, Handle
                            boost::dynamic_pointer_cast<SketchPlugin_Feature>(feature());
     aSketchFeature->move(aDeltaX, aDeltaY);
 
-    std::list<XGUI_ViewerPrs>::const_iterator anIt = myFeatures.begin(), aLast = myFeatures.end();
+    std::list<ModuleBase_ViewerPrs>::const_iterator anIt = myFeatures.begin(), aLast = myFeatures.end();
     for (; anIt != aLast; anIt++) {
       FeaturePtr aFeature = (*anIt).feature();
       if (!aFeature || aFeature == feature())
@@ -123,12 +123,12 @@ void PartSet_OperationFeatureEditMulti::mouseMoved(QMouseEvent* theEvent, Handle
 }
 
 void PartSet_OperationFeatureEditMulti::mouseReleased(QMouseEvent* theEvent, Handle(V3d_View) theView,
-                                              const std::list<XGUI_ViewerPrs>& /*theSelected*/,
-                                              const std::list<XGUI_ViewerPrs>& /*theHighlighted*/)
+                                              const std::list<ModuleBase_ViewerPrs>& /*theSelected*/,
+                                              const std::list<ModuleBase_ViewerPrs>& /*theHighlighted*/)
 {
-  std::list<XGUI_ViewerPrs> aFeatures = myFeatures;
+  std::list<ModuleBase_ViewerPrs> aFeatures = myFeatures;
   commit();
-  std::list<XGUI_ViewerPrs>::const_iterator anIt = aFeatures.begin(), aLast = aFeatures.end();
+  std::list<ModuleBase_ViewerPrs>::const_iterator anIt = aFeatures.begin(), aLast = aFeatures.end();
   for (; anIt != aLast; anIt++) {
     FeaturePtr aFeature = (*anIt).feature();
     if (aFeature) {
@@ -163,7 +163,7 @@ void PartSet_OperationFeatureEditMulti::blockSelection(bool isBlocked, const boo
 
   myIsBlockedSelection = isBlocked;
   QFeatureList aFeatureList;
-  std::list<XGUI_ViewerPrs>::const_iterator anIt = myFeatures.begin(),
+  std::list<ModuleBase_ViewerPrs>::const_iterator anIt = myFeatures.begin(),
                                             aLast = myFeatures.end();
   for(; anIt != aLast; anIt++)
     aFeatureList.append((*anIt).feature());
@@ -184,7 +184,7 @@ void PartSet_OperationFeatureEditMulti::sendFeatures()
   static Events_ID anEvent = Events_Loop::eventByName(EVENT_FEATURE_MOVED);
 
   std::list<FeaturePtr > aFeatures;
-  std::list<XGUI_ViewerPrs>::const_iterator anIt = myFeatures.begin(), aLast = myFeatures.end();
+  std::list<ModuleBase_ViewerPrs>::const_iterator anIt = myFeatures.begin(), aLast = myFeatures.end();
   for (; anIt != aLast; anIt++) {
     FeaturePtr aFeature = (*anIt).feature();
     if (!aFeature)
index a431a1d85f7b3176a0b5d66ad6c446c09419850b..7f018618b215499bb6280d266212cfdb985133f8 100644 (file)
@@ -71,8 +71,8 @@ public:
   /// Initialisation of operation with preliminary selection
   /// \param theSelected the list of selected presentations
   /// \param theHighlighted the list of highlighted presentations
-  virtual void initSelection(const std::list<XGUI_ViewerPrs>& theSelected,
-    const std::list<XGUI_ViewerPrs>& theHighlighted);
+  virtual void initSelection(const std::list<ModuleBase_ViewerPrs>& theSelected,
+    const std::list<ModuleBase_ViewerPrs>& theHighlighted);
 
   /// Returns the operation sketch feature
   /// \returns the sketch instance
@@ -84,8 +84,8 @@ public:
   /// \param theSelected the list of selected presentations
   /// \param theHighlighted the list of highlighted presentations
   virtual void mousePressed(QMouseEvent* theEvent, Handle_V3d_View theView,
-                            const std::list<XGUI_ViewerPrs>& theSelected,
-                            const std::list<XGUI_ViewerPrs>& theHighlighted);
+                            const std::list<ModuleBase_ViewerPrs>& theSelected,
+                            const std::list<ModuleBase_ViewerPrs>& theHighlighted);
   /// Gives the current mouse point in the viewer
   /// \param theEvent the mouse event
   /// \param theView a viewer to have the viewer the eye position
@@ -96,8 +96,8 @@ public:
   /// \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);
+                            const std::list<ModuleBase_ViewerPrs>& theSelected,
+                            const std::list<ModuleBase_ViewerPrs>& theHighlighted);
 protected:
   /// \brief Virtual method called when operation is started
   /// Virtual method called when operation started (see start() method for more description)
@@ -121,7 +121,7 @@ protected:
 
 private:
   FeaturePtr mySketch; ///< the sketch feature
-  std::list<XGUI_ViewerPrs> myFeatures; ///< the features to apply the edit operation
+  std::list<ModuleBase_ViewerPrs> myFeatures; ///< the features to apply the edit operation
   Point myCurPoint; ///< the current 3D point clicked or moved
   bool myIsBlockedSelection; ///< the state of the last state of selection blocked signal
 };
index eff5a65ee5c3ef40a63277311a59cf5652958fc2..563caf21ca286697d7714ca8ac94f12cfcc2e13e 100644 (file)
@@ -20,7 +20,7 @@
 #include <GeomDataAPI_Dir.h>
 #include <GeomAPI_XYZ.h>
 
-#include <XGUI_ViewerPrs.h>
+#include <ModuleBase_ViewerPrs.h>
 
 #include <AIS_Shape.hxx>
 #include <AIS_ListOfInteractive.hxx>
@@ -72,12 +72,12 @@ FeaturePtr PartSet_OperationSketch::sketch() const
 }
 
 void PartSet_OperationSketch::mousePressed(QMouseEvent* theEvent, Handle_V3d_View theView,
-                                           const std::list<XGUI_ViewerPrs>& theSelected,
-                                           const std::list<XGUI_ViewerPrs>& theHighlighted)
+                                           const std::list<ModuleBase_ViewerPrs>& theSelected,
+                                           const std::list<ModuleBase_ViewerPrs>& theHighlighted)
 {
   if (!hasSketchPlane()) {
     if (!theHighlighted.empty()) {
-      XGUI_ViewerPrs aPrs = theHighlighted.front();
+      ModuleBase_ViewerPrs aPrs = theHighlighted.front();
       const TopoDS_Shape& aShape = aPrs.shape();
       if (!aShape.IsNull())
         setSketchPlane(aShape);
@@ -106,8 +106,8 @@ void PartSet_OperationSketch::mousePressed(QMouseEvent* theEvent, Handle_V3d_Vie
 }
 
 void PartSet_OperationSketch::mouseReleased(QMouseEvent* theEvent, Handle_V3d_View theView,
-                                            const std::list<XGUI_ViewerPrs>& theSelected,
-                                            const std::list<XGUI_ViewerPrs>& theHighlighted)
+                                            const std::list<ModuleBase_ViewerPrs>& theSelected,
+                                            const std::list<ModuleBase_ViewerPrs>& theHighlighted)
 {
   if (!hasSketchPlane()) {
   }
index df7243a49fa6a4978e438de4fdb7b77e82a56227..eb0c8477542a5aaeb8e295da6ed4d3f8ced79c9a 100644 (file)
@@ -52,16 +52,16 @@ public:
   /// \param theSelected the list of selected presentations
   /// \param theHighlighted the list of highlighted presentations
   virtual void mousePressed(QMouseEvent* theEvent, Handle_V3d_View theView,
-                            const std::list<XGUI_ViewerPrs>& theSelected,
-                            const std::list<XGUI_ViewerPrs>& theHighlighted);
+                            const std::list<ModuleBase_ViewerPrs>& theSelected,
+                            const std::list<ModuleBase_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);
+                             const std::list<ModuleBase_ViewerPrs>& theSelected,
+                             const std::list<ModuleBase_ViewerPrs>& theHighlighted);
 
   /// Gives the current mouse point in the viewer
   /// \param thePoint a point clicked in the viewer
@@ -82,6 +82,10 @@ public:
   /// \return enabled state
   virtual bool isNestedOperationsEnabled() const;
 
+  /// Returns whether the sketch plane is set
+  /// \return the boolean value whether the sketch is set
+  bool hasSketchPlane() const;
+
 signals:
   /// signal about the sketch plane is selected
   /// \param theX the value in the X direction of the plane
@@ -96,16 +100,12 @@ protected:
   /// Default impl calls corresponding slot and commits immediately.
   virtual void startOperation();
 
-  /// Returns whether the sketch plane is set
-  /// \return the boolean value whether the sketch is set
-  bool hasSketchPlane() const;
-
   /// Set the plane to the current sketch
   /// \param theShape the shape
   void setSketchPlane(const TopoDS_Shape& theShape);
 
 private:
-  std::list<XGUI_ViewerPrs> myFeatures; ///< the features to apply the edit operation
+  std::list<ModuleBase_ViewerPrs> myFeatures; ///< the features to apply the edit operation
 };
 
 #endif
index dd66393219a8f95dafba59a4bb06944551b843fb..bef1dfde5cde9d2d426d81de989e99b2c5cb228c 100644 (file)
@@ -69,21 +69,21 @@ FeaturePtr PartSet_OperationSketchBase::createFeature(const bool theFlushMessage
 
 
 void PartSet_OperationSketchBase::mousePressed(QMouseEvent* theEvent, Handle_V3d_View theView,
-                                               const std::list<XGUI_ViewerPrs>& theSelected,
-                                               const std::list<XGUI_ViewerPrs>& theHighlighted)
+                                               const std::list<ModuleBase_ViewerPrs>& theSelected,
+                                               const std::list<ModuleBase_ViewerPrs>& theHighlighted)
 {
 }
 void PartSet_OperationSketchBase::mouseReleased(QMouseEvent* theEvent, Handle_V3d_View theView,
-                                                const std::list<XGUI_ViewerPrs>& theSelected,
-                                                const std::list<XGUI_ViewerPrs>& theHighlighted)
+                                                const std::list<ModuleBase_ViewerPrs>& theSelected,
+                                                const std::list<ModuleBase_ViewerPrs>& theHighlighted)
 {
 }
 void PartSet_OperationSketchBase::mouseMoved(QMouseEvent* theEvent, Handle(V3d_View) theView)
 {
 }
 void PartSet_OperationSketchBase::mouseDoubleClick(QMouseEvent* theEvent, Handle_V3d_View theView,
-                                                   const std::list<XGUI_ViewerPrs>& theSelected,
-                                                   const std::list<XGUI_ViewerPrs>& theHighlighted)
+                                                   const std::list<ModuleBase_ViewerPrs>& theSelected,
+                                                   const std::list<ModuleBase_ViewerPrs>& theHighlighted)
 {
 }
 
index 8fa6439d7ff636505e4aa484783f1eaaf3848717..449d65834959d8753fec95e39627694f9d30261f 100644 (file)
@@ -26,7 +26,7 @@
 class Handle_V3d_View;
 class QMouseEvent;
 class GeomAPI_Shape;
-class XGUI_ViewerPrs;
+class ModuleBase_ViewerPrs;
 
 /*!
   \class PartSet_OperationSketchBase
@@ -66,8 +66,8 @@ public:
   /// Initialisation of operation with preliminary selection
   /// \param theSelected the list of selected presentations
   /// \param theHighlighted the list of highlighted presentations
-  virtual void initSelection(const std::list<XGUI_ViewerPrs>& theSelected,
-    const std::list<XGUI_ViewerPrs>& theHighlighted) {}
+  virtual void initSelection(const std::list<ModuleBase_ViewerPrs>& theSelected,
+    const std::list<ModuleBase_ViewerPrs>& theHighlighted) {}
 
   /// Returns the operation sketch feature
   /// \returns the sketch instance
@@ -79,8 +79,8 @@ public:
   /// \param theSelected the list of selected presentations
   /// \param theHighlighted the list of highlighted presentations
   virtual void mousePressed(QMouseEvent* theEvent, Handle_V3d_View theView,
-                            const std::list<XGUI_ViewerPrs>& theSelected,
-                            const std::list<XGUI_ViewerPrs>& theHighlighted);
+                            const std::list<ModuleBase_ViewerPrs>& theSelected,
+                            const std::list<ModuleBase_ViewerPrs>& theHighlighted);
 
   /// Processes the mouse release in the point
   /// \param theEvent the mouse event
@@ -88,8 +88,8 @@ public:
   /// \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);
+                             const std::list<ModuleBase_ViewerPrs>& theSelected,
+                             const std::list<ModuleBase_ViewerPrs>& theHighlighted);
 
   /// Processes the mouse move in the point
   /// \param theEvent the mouse event
@@ -102,8 +102,8 @@ public:
   /// \param theSelected the list of selected presentations
   /// \param theHighlighted the list of highlighted presentations
   virtual void mouseDoubleClick(QMouseEvent* theEvent, Handle_V3d_View theView,
-                            const std::list<XGUI_ViewerPrs>& theSelected,
-                            const std::list<XGUI_ViewerPrs>& theHighlighted);
+                            const std::list<ModuleBase_ViewerPrs>& theSelected,
+                            const std::list<ModuleBase_ViewerPrs>& theHighlighted);
 
   /// Processes the key pressed in the view
   /// \param theKey a key value
@@ -130,7 +130,7 @@ signals:
                           int theMode);
   /// Signal about the features should be selected
   /// \param theSelected the list of selected presentations
-  void featureSelected(const std::list<XGUI_ViewerPrs>& theSelected);
+  void featureSelected(const std::list<ModuleBase_ViewerPrs>& theSelected);
   /// signal to enable/disable multi selection in the viewer
   /// \param theEnabled the boolean state
   void multiSelectionEnabled(bool theEnabled);
index 00ff7cef268779659b4f9f56ba623a9837172229..f447f59660f3a1bd4894326893b3271874e5d482 100644 (file)
@@ -7,11 +7,11 @@
 #include <XGUI_Workshop.h>
 #include <XGUI_OperationMgr.h>
 #include <XGUI_Displayer.h>
-#include <XGUI_ViewerPrs.h>
 #include <XGUI_ViewerProxy.h>
 #include <PartSet_Tools.h>
 #include <PartSet_OperationSketchBase.h>
 
+#include <ModuleBase_ViewerPrs.h>
 #include <ModelAPI_Feature.h>
 
 #include <SketchPlugin_Line.h>
index ca6b10adbdb8d105719c93f9674978e34d4c982c..aa3ac235adbfa32483ccfc0b404d306195136c0b 100644 (file)
@@ -27,7 +27,7 @@
 #include <SketchPlugin_ConstraintRadius.h>
 #include <SketchPlugin_Constraint.h>
 
-#include <XGUI_ViewerPrs.h>
+#include <ModuleBase_ViewerPrs.h>
 
 #include <V3d_View.hxx>
 #include <gp_Pln.hxx>
@@ -138,18 +138,18 @@ void PartSet_Tools::convertTo3D(const double theX, const double theY,
 
 FeaturePtr PartSet_Tools::nearestFeature(QPoint thePoint, Handle_V3d_View theView,
                                          FeaturePtr theSketch,
-                                         const std::list<XGUI_ViewerPrs>& theFeatures)
+                                         const std::list<ModuleBase_ViewerPrs>& theFeatures)
 {
   double aX, anY;
   gp_Pnt aPoint = PartSet_Tools::convertClickToPoint(thePoint, theView);
   PartSet_Tools::convertTo2D(aPoint, theSketch, theView, aX, anY);
 
   FeaturePtr aFeature;
-  std::list<XGUI_ViewerPrs>::const_iterator anIt = theFeatures.begin(), aLast = theFeatures.end();
+  std::list<ModuleBase_ViewerPrs>::const_iterator anIt = theFeatures.begin(), aLast = theFeatures.end();
 
   FeaturePtr aDeltaFeature;   
   double aMinDelta = -1;
-  XGUI_ViewerPrs aPrs;
+  ModuleBase_ViewerPrs aPrs;
   for (; anIt != aLast; anIt++) {
     aPrs = *anIt;
     if (!aPrs.feature())
index fa1f31f9d765b53dedc062dfef20dbe641592787..1cd763ca0e9af86623bf246e7b675d7dfd61afc1 100644 (file)
@@ -18,7 +18,7 @@
 #include <list>
 
 class Handle_V3d_View;
-class XGUI_ViewerPrs;
+class ModuleBase_ViewerPrs;
 class GeomDataAPI_Point2D;
 class GeomAPI_Pln;
 class GeomAPI_Pnt2d;
@@ -58,7 +58,7 @@ public:
   /// \param theSketch the sketch feature
   /// \param theFeatures the list of selected presentations
   static FeaturePtr nearestFeature(QPoint thePoint, Handle_V3d_View theView, FeaturePtr theSketch,
-                                   const std::list<XGUI_ViewerPrs>& theFeatures);
+                                   const std::list<ModuleBase_ViewerPrs>& theFeatures);
 
   /// Returns pointer to the root document.
   static boost::shared_ptr<ModelAPI_Document> document();
diff --git a/src/PartSet/PartSet_Validators.cpp b/src/PartSet/PartSet_Validators.cpp
new file mode 100644 (file)
index 0000000..296f8da
--- /dev/null
@@ -0,0 +1,37 @@
+// File:        PartSet_Validators.cpp
+// Created:     09 July 2014
+// Author:      Vitaly SMETANNIKOV
+
+#include "PartSet_Validators.h"
+
+#include <list>
+
+
+int shapesNb(const ModuleBase_ISelection* theSelection, TopAbs_ShapeEnum theType)
+{
+  std::list<ModuleBase_ViewerPrs> aList = theSelection->getSelected();
+  std::list<ModuleBase_ViewerPrs>::iterator it;
+  ModuleBase_ViewerPrs aPrs;
+  int aCount = 0;
+  for (it = aList.begin(); it != aList.end(); ++it) {
+    aPrs = *it;
+    const TopoDS_Shape& aShape = aPrs.shape();
+    if (!aShape.IsNull()) {
+      if (aShape.ShapeType() == theType)
+        aCount++;
+    }
+  }
+  return aCount;
+}
+
+bool PartSet_DistanceValidator::isValid(const ModuleBase_ISelection* theSelection) const
+{
+  int aCount = shapesNb(theSelection, TopAbs_VERTEX);
+  return (aCount > 0) && (aCount < 3);
+}
+
+bool PartSet_LengthValidator::isValid(const ModuleBase_ISelection* theSelection) const
+{
+  int aCount = shapesNb(theSelection, TopAbs_EDGE);
+  return (aCount == 1);
+}
\ No newline at end of file
diff --git a/src/PartSet/PartSet_Validators.h b/src/PartSet/PartSet_Validators.h
new file mode 100644 (file)
index 0000000..10cdcf2
--- /dev/null
@@ -0,0 +1,25 @@
+// File:        PartSet_Validators.h
+// Created:     09 July 2014
+// Author:      Vitaly SMETANNIKOV
+
+#ifndef PartSet_Validators_H
+#define PartSet_Validators_H
+
+#include "PartSet.h"
+
+#include <ModuleBase_SelectionValidator.h>
+#include <ModuleBase_ISelection.h>
+
+class PartSet_DistanceValidator: public ModuleBase_SelectionValidator
+{
+public:
+  PARTSET_EXPORT virtual bool isValid(const ModuleBase_ISelection* theSelection) const;
+};
+
+class PartSet_LengthValidator: public ModuleBase_SelectionValidator
+{
+public:
+  PARTSET_EXPORT virtual bool isValid(const ModuleBase_ISelection* theSelection) const;
+};
+
+#endif
diff --git a/src/PartSet/PartSet_WidgetSketchLabel.cpp b/src/PartSet/PartSet_WidgetSketchLabel.cpp
new file mode 100644 (file)
index 0000000..4b39dc6
--- /dev/null
@@ -0,0 +1,66 @@
+// File:        PartSet_WidgetSketchLabel.cpp
+// Created:     07 July 2014
+// Author:      Vitaly SMETANNIKOV
+
+#include "PartSet_WidgetSketchLabel.h"
+#include "PartSet_OperationSketch.h"
+
+#include <ModuleBase_Operation.h>
+#include <XGUI_OperationMgr.h>
+
+#include <Config_WidgetAPI.h>
+
+#include <QLabel>
+
+PartSet_WidgetSketchLabel::PartSet_WidgetSketchLabel(QWidget* theParent, 
+                                                     const Config_WidgetAPI* theData)
+: ModuleBase_ModelWidget(theParent, theData)
+{
+  myText = QString::fromStdString(theData->getProperty("title"));
+  myLabel = new QLabel(myText, theParent);
+  myLabel->setWordWrap(true);
+  myTooltip = QString::fromStdString(theData->getProperty("tooltip"));
+  myLabel->setToolTip(myTooltip);
+}
+
+QList<QWidget*> PartSet_WidgetSketchLabel::getControls() const
+{
+  QList<QWidget*> aLst;
+  aLst<<myLabel;
+  return aLst;
+}
+
+QWidget* PartSet_WidgetSketchLabel::getControl() const
+{
+  return myLabel;
+}
+
+
+
+void PartSet_WidgetSketchLabel::setOperationsMgr(XGUI_OperationMgr* theMgr)
+{
+  ModuleBase_Operation* aOperation = theMgr->currentOperation();
+  if (aOperation->inherits("PartSet_OperationSketch")) {
+    PartSet_OperationSketch* aSketchOpe = static_cast<PartSet_OperationSketch*>(aOperation);
+    updateLabel(aSketchOpe);
+    connect(aSketchOpe, SIGNAL(planeSelected(double, double, double)), 
+            this, SLOT(onPlaneSelected()));
+  }
+}
+
+void PartSet_WidgetSketchLabel::onPlaneSelected()
+{
+  PartSet_OperationSketch* aSketchOpe = static_cast<PartSet_OperationSketch*>(sender());
+  updateLabel(aSketchOpe);
+}
+
+void PartSet_WidgetSketchLabel::updateLabel(PartSet_OperationSketch* theSketchOpe)
+{
+  if (theSketchOpe->hasSketchPlane()) {
+    myLabel->setText("");
+    myLabel->setToolTip("");
+  } else {
+    myLabel->setText(myText);
+    myLabel->setToolTip(myTooltip);
+  }
+}
\ No newline at end of file
diff --git a/src/PartSet/PartSet_WidgetSketchLabel.h b/src/PartSet/PartSet_WidgetSketchLabel.h
new file mode 100644 (file)
index 0000000..30cdaac
--- /dev/null
@@ -0,0 +1,49 @@
+// File:        PartSet_WidgetSketchLabel.h
+// Created:     07 July 2014
+// Author:      Vitaly SMETANNIKOV
+
+#ifndef PartSet_WidgetSketchLabel_H
+#define PartSet_WidgetSketchLabel_H
+
+#include "PartSet.h"
+
+#include <ModuleBase_ModelWidget.h>
+
+class QLabel;
+class XGUI_OperationMgr; 
+class PartSet_OperationSketch;
+
+class PARTSET_EXPORT PartSet_WidgetSketchLabel : public ModuleBase_ModelWidget
+{
+  Q_OBJECT
+public:
+  PartSet_WidgetSketchLabel(QWidget* theParent, const Config_WidgetAPI* theData);
+
+  virtual ~PartSet_WidgetSketchLabel() {};
+
+  /// Saves the internal parameters to the given feature
+  /// \param theFeature a model feature to be changed
+  virtual bool storeValue(FeaturePtr theFeature) const { return true;}
+
+  virtual bool restoreValue(FeaturePtr theFeature) { return true;}
+
+  /// Returns list of widget controls
+  /// \return a control list
+  virtual QList<QWidget*> getControls() const;
+
+  QWidget* getControl() const;
+
+  void setOperationsMgr(XGUI_OperationMgr* theMgr);
+
+private slots:
+  void onPlaneSelected();
+
+private:
+  void updateLabel(PartSet_OperationSketch* theSketchOpe);
+
+  QLabel* myLabel;
+  QString myText;
+  QString myTooltip;
+};
+
+#endif
\ No newline at end of file
index 2bbac462f940c751ece8b64baf53f40b23b029ba..1f5228ffd5211df9269fb9271963cfbf7d8f605e 100644 (file)
@@ -54,6 +54,7 @@ INCLUDE_DIRECTORIES(
   ../GeomAPI
   ../GeomAlgoAPI
   ../GeomDataAPI
+  ../ModuleBase
 )
 
 INSTALL(TARGETS SketchPlugin DESTINATION plugins)
index 365fb02c3f79fb49eb97e78eacb2efc1f773cc1f..3b5801e77067d33e723241a99add6bbbce914219 100644 (file)
@@ -2,7 +2,7 @@
   <workbench id="Sketch">
     <group id="Basic">
       <feature id="Sketch" nested="SketchPoint SketchLine SketchCircle SketchArc SketchConstraintLength SketchConstraintRadius SketchConstraintDistance SketchConstraintParallel SketchConstraintPerpendicular" 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"/> 
+        <sketch-start-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>
       <feature id="SketchPoint" title="Point" tooltip="Create a new point" icon=":icons/point.png">
index 450954322a3bb50d4a0cc8dd99a85a1745dd210d..4380786974b39ccc470174b26c01fd4a8e9236d7 100644 (file)
@@ -28,10 +28,10 @@ SET(PROJECT_HEADERS
     XGUI_ErrorDialog.h
     XGUI_SalomeViewer.h
     XGUI_ViewerProxy.h
-    XGUI_ViewerPrs.h
     XGUI_PropertyPanel.h
     XGUI_ContextMenuMgr.h
     XGUI_ModuleConnector.h
+       XGUI_Selection.h
 )
 
 SET(PROJECT_AUTOMOC 
@@ -60,10 +60,10 @@ SET(PROJECT_SOURCES
     XGUI_ActionsMgr.cpp
     XGUI_ErrorDialog.cpp
     XGUI_ViewerProxy.cpp
-    XGUI_ViewerPrs.cpp
     XGUI_PropertyPanel.cpp
     XGUI_ContextMenuMgr.cpp
     XGUI_ModuleConnector.cpp
+       XGUI_Selection.cpp
 )
 
 SET(PROJECT_RESOURCES 
index efe3c9c127763939cb292274e67a4ae5d6b45ac6..8ecb179b3d1b77a46503126208ead9d91469b882 100644 (file)
@@ -6,6 +6,7 @@
 #include "XGUI_Displayer.h"
 #include "XGUI_MainWindow.h"
 #include "XGUI_ViewerProxy.h"
+#include "XGUI_Selection.h"
 
 #include "PartSetPlugin_Part.h"
 
@@ -98,7 +99,7 @@ QMenu* XGUI_ContextMenuMgr::objectBrowserMenu() const
 {
   QMenu* aMenu = new QMenu();
   XGUI_SelectionMgr* aSelMgr = myWorkshop->selector();
-  QFeatureList aFeatures = aSelMgr->selectedFeatures();
+  QFeatureList aFeatures = aSelMgr->selection()->selectedFeatures();
   if (aFeatures.size() == 1) {
     PluginManagerPtr aMgr = ModelAPI_PluginManager::get();
     FeaturePtr aFeature = aFeatures.first();
@@ -152,7 +153,7 @@ QMenu* XGUI_ContextMenuMgr::viewerMenu() const
 void XGUI_ContextMenuMgr::addViewerItems(QMenu* theMenu) const
 {
   XGUI_SelectionMgr* aSelMgr = myWorkshop->selector();
-  QFeatureList aFeatures = aSelMgr->selectedFeatures();
+  QFeatureList aFeatures = aSelMgr->selection()->selectedFeatures();
   if (aFeatures.size() > 0) {
     if (aFeatures.size() == 1)
       theMenu->addAction(action("EDIT_CMD"));
index fc9159a91a8f417dbbefa65184d37493ebae7660..83f70bf14547149dfb23246cc61dce5aef25c2f1 100644 (file)
@@ -69,65 +69,6 @@ bool XGUI_Displayer::display(FeaturePtr theFeature,
 }
 
 
-std::list<XGUI_ViewerPrs> XGUI_Displayer::getSelected(const int theShapeTypeToSkip)
-{
-  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;
-
-    FeaturePtr aFeature = getFeature(anIO);
-    if (aPrsFeatures.find(aFeature) != aPrsFeatures.end())
-      continue;
-    Handle(SelectMgr_EntityOwner) anOwner = aContext->SelectedOwner();
-    aPresentations.push_back(XGUI_ViewerPrs(aFeature, aShape, anOwner));
-    aPrsFeatures.insert(aFeature);
-  }
-  return aPresentations;
-}
-
-QFeatureList XGUI_Displayer::selectedFeatures() const
-{
-  QFeatureList aSelectedList;
-
-  Handle(AIS_InteractiveContext) aContext = AISContext();
-  for (aContext->InitSelected(); aContext->MoreSelected(); aContext->NextSelected()) {
-    Handle(AIS_InteractiveObject) anIO = aContext->SelectedInteractive();
-    FeaturePtr aFeature = getFeature(anIO);
-    if (aFeature)
-      aSelectedList.append(aFeature);
-  }
-  return aSelectedList;
-}
-
-
-std::list<XGUI_ViewerPrs> XGUI_Displayer::getHighlighted(const int theShapeTypeToSkip)
-{
-  std::set<FeaturePtr > aPrsFeatures;
-  std::list<XGUI_ViewerPrs> aPresentations;
-
-  Handle(AIS_InteractiveContext) aContext = AISContext();
-  for (aContext->InitDetected(); aContext->MoreDetected(); aContext->NextDetected()) {
-    Handle(AIS_InteractiveObject) anIO = aContext->DetectedInteractive();
-    TopoDS_Shape aShape = aContext->DetectedShape();
-    if (theShapeTypeToSkip >= 0 && !aShape.IsNull() && aShape.ShapeType() == theShapeTypeToSkip)
-      continue;
-
-    FeaturePtr aFeature = getFeature(anIO);
-    if (aPrsFeatures.find(aFeature) != aPrsFeatures.end())
-      continue;
-    aPresentations.push_back(XGUI_ViewerPrs(aFeature, aShape, NULL));
-    aPrsFeatures.insert(aFeature);
-  }
-
-  return aPresentations;
-}
 
 void XGUI_Displayer::erase(FeaturePtr theFeature,
                            const bool isUpdateViewer)
index a9a7fb36f744b652492889f93a20d015be5ca38d..2c730c9e8b01ee60ef8b9a119512dd912bcc69e0 100644 (file)
@@ -6,7 +6,6 @@
 #define XGUI_Displayer_H
 
 #include "XGUI.h"
-#include <ModuleBase_Definitions.h>
 
 #include <QString>
 #include <boost/shared_ptr.hpp>
@@ -20,7 +19,8 @@
 
 #include <ModelAPI_Feature.h>
 
-#include <XGUI_ViewerPrs.h>
+#include <ModuleBase_Definitions.h>
+#include <ModuleBase_ViewerPrs.h>
 
 #include <map>
 #include <vector>
@@ -64,21 +64,6 @@ public:
   /// Returns true if the Feature succesfully displayed
   bool display(FeaturePtr theFeature, boost::shared_ptr<GeomAPI_AISObject> theAIS, 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);
-
-  /**
-  * Returns list of features currently selected in 3d viewer
-  */
-  QFeatureList selectedFeatures() const;
-
-  /// 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);
-
   /// Display the shape and activate selection of sub-shapes
   /// \param theFeature a feature instance
   /// \param theAIS an AIS object
@@ -146,11 +131,12 @@ public:
   /// \return theIO an interactive object
   boost::shared_ptr<GeomAPI_AISObject> 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
   FeaturePtr getFeature(Handle(AIS_InteractiveObject) theIO) const;
+
+protected:
   /// Deactivate local selection
   /// \param isUpdateViewer the state wether the viewer should be updated immediatelly
   void closeAllContexts(const bool isUpdateViewer);
index a491a89ee3367e7f0010b81b426287d1839b5148..9cb80fa224e46d212bd1fd4524d198df0f976934 100644 (file)
@@ -7,6 +7,7 @@
 #include "XGUI_Workshop.h"
 #include "XGUI_ViewerProxy.h"
 #include "XGUI_SelectionMgr.h"
+#include "XGUI_Selection.h"
 
 
 
@@ -29,6 +30,10 @@ Handle(AIS_InteractiveContext) XGUI_ModuleConnector::AISContext() const
 
 QFeatureList XGUI_ModuleConnector::selectedFeatures() const
 {
-  return myWorkshop->selector()->selectedFeatures();
+  return myWorkshop->selector()->selection()->selectedFeatures();
 }
 
+ModuleBase_IModule* XGUI_ModuleConnector::module() const
+{
+  return myWorkshop->module();
+}
\ No newline at end of file
index 8efd97e210f0697814417da53b11a91115a48986..8ef06b3217cd9abced8e794b33bb1324701c53e3 100644 (file)
@@ -31,6 +31,9 @@ public:
   //! Returns list of currently selected data objects
   virtual QFeatureList selectedFeatures() const; 
 
+  //! Returns instance of loaded module
+  virtual ModuleBase_IModule* module() const;
+
 private:
   XGUI_Workshop* myWorkshop;
 };
diff --git a/src/XGUI/XGUI_Selection.cpp b/src/XGUI/XGUI_Selection.cpp
new file mode 100644 (file)
index 0000000..5900aef
--- /dev/null
@@ -0,0 +1,109 @@
+// File:        XGUI_Selection.cpp
+// Created:     8 July 2014
+// Author:      Vitaly SMETANNIKOV
+
+#include "XGUI_Selection.h"
+#include "XGUI_Workshop.h"
+#include "XGUI_Displayer.h"
+#include "XGUI_ViewerProxy.h"
+#include "XGUI_ObjectsBrowser.h"
+
+#include <ModelAPI_Feature.h>
+
+#include <AIS_InteractiveContext.hxx>
+
+#include <set>
+
+
+XGUI_Selection::XGUI_Selection(XGUI_Workshop* theWorkshop)
+: myWorkshop(theWorkshop)
+{
+}
+
+std::list<ModuleBase_ViewerPrs> XGUI_Selection::getSelected(int theShapeTypeToSkip) const
+{
+  std::set<FeaturePtr> aPrsFeatures;
+  std::list<ModuleBase_ViewerPrs> aPresentations;
+
+  Handle(AIS_InteractiveContext) aContext = myWorkshop->viewer()->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;
+
+    FeaturePtr aFeature = myWorkshop->displayer()->getFeature(anIO);
+    if (aPrsFeatures.find(aFeature) != aPrsFeatures.end())
+      continue;
+    Handle(SelectMgr_EntityOwner) anOwner = aContext->SelectedOwner();
+    aPresentations.push_back(ModuleBase_ViewerPrs(aFeature, aShape, anOwner));
+    aPrsFeatures.insert(aFeature);
+  }
+  return aPresentations;
+}
+
+std::list<ModuleBase_ViewerPrs> XGUI_Selection::getHighlighted(int theShapeTypeToSkip) const
+{
+  std::set<FeaturePtr > aPrsFeatures;
+  std::list<ModuleBase_ViewerPrs> aPresentations;
+
+  Handle(AIS_InteractiveContext) aContext = myWorkshop->viewer()->AISContext();
+  for (aContext->InitDetected(); aContext->MoreDetected(); aContext->NextDetected()) {
+    Handle(AIS_InteractiveObject) anIO = aContext->DetectedInteractive();
+    TopoDS_Shape aShape = aContext->DetectedShape();
+    if (theShapeTypeToSkip >= 0 && !aShape.IsNull() && aShape.ShapeType() == theShapeTypeToSkip)
+      continue;
+
+    FeaturePtr aFeature = myWorkshop->displayer()->getFeature(anIO);
+    if (aPrsFeatures.find(aFeature) != aPrsFeatures.end())
+      continue;
+    aPresentations.push_back(ModuleBase_ViewerPrs(aFeature, aShape, NULL));
+    aPrsFeatures.insert(aFeature);
+  }
+
+  return aPresentations;
+}
+
+QFeatureList XGUI_Selection::selectedFeatures() const
+{
+  return myWorkshop->objectBrowser()->selectedFeatures();
+  //QFeatureList aSelectedList;
+
+  //Handle(AIS_InteractiveContext) aContext = myWorkshop->viewer()->AISContext();
+  //for (aContext->InitSelected(); aContext->MoreSelected(); aContext->NextSelected()) {
+  //  Handle(AIS_InteractiveObject) anIO = aContext->SelectedInteractive();
+  //  FeaturePtr aFeature = myWorkshop->displayer()->getFeature(anIO);
+  //  if (aFeature)
+  //    aSelectedList.append(aFeature);
+  //}
+  //return aSelectedList;
+}
+
+
+//**************************************************************
+QModelIndexList XGUI_Selection::selectedIndexes() const 
+{ 
+  return myWorkshop->objectBrowser()->selectedIndexes();
+}
+
+//**************************************************************
+void XGUI_Selection::selectedAISObjects(AIS_ListOfInteractive& theList) const
+{
+  Handle(AIS_InteractiveContext) aContext = myWorkshop->viewer()->AISContext();
+  theList.Clear();
+  for (aContext->InitSelected(); aContext->MoreSelected(); aContext->NextSelected())
+    theList.Append(aContext->SelectedInteractive());
+}
+
+//**************************************************************
+void XGUI_Selection::selectedShapes(NCollection_List<TopoDS_Shape>& theList) const
+{
+  theList.Clear();
+  Handle(AIS_InteractiveContext) aContext = myWorkshop->viewer()->AISContext();
+  for (aContext->InitSelected(); aContext->MoreSelected(); aContext->NextSelected()) {
+    TopoDS_Shape aShape = aContext->SelectedShape();
+    if (!aShape.IsNull())
+      theList.Append(aShape);
+  }
+}
diff --git a/src/XGUI/XGUI_Selection.h b/src/XGUI/XGUI_Selection.h
new file mode 100644 (file)
index 0000000..c6f92f5
--- /dev/null
@@ -0,0 +1,56 @@
+// File:        XGUI_Selection.h
+// Created:     8 July 2014
+// Author:      Vitaly SMETANNIKOV
+
+#ifndef XGUI_Selection_H
+#define XGUI_Selection_H
+
+#include "XGUI.h"
+
+#include <ModuleBase_ViewerPrs.h>
+#include <ModuleBase_Definitions.h>
+#include <ModuleBase_ISelection.h>
+
+#include <QModelIndexList>
+#include <AIS_ListOfInteractive.hxx>
+#include <NCollection_List.hxx>
+#include <TopoDS_Shape.hxx>
+
+#include <list>
+
+class XGUI_Workshop;
+
+class XGUI_EXPORT XGUI_Selection: public ModuleBase_ISelection
+{
+public:
+  XGUI_Selection(XGUI_Workshop* theWorkshop);
+
+  /// 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<ModuleBase_ViewerPrs> getSelected(int theShapeTypeToSkip = -1) const;
+
+  /// 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<ModuleBase_ViewerPrs> getHighlighted(int theShapeTypeToSkip = -1) const;
+
+  /**
+  * Returns list of features currently selected in 3d viewer
+  */
+  QFeatureList selectedFeatures() const;
+  
+  //! Returns list of currently selected QModelIndexes
+  QModelIndexList selectedIndexes() const;
+
+  //! Returns list of currently selected AIS objects
+  void selectedAISObjects(AIS_ListOfInteractive& theList) const;
+
+  //! Returns list of currently selected shapes
+  void selectedShapes(NCollection_List<TopoDS_Shape>& theList) const;
+
+private:
+  XGUI_Workshop* myWorkshop;
+};
+
+#endif
\ No newline at end of file
index 9f830a74ec5757257915168ab59afcb277ad6e58..d1d9f83a0a008f3c01f825b84c7dcd43ca1c84c1 100644 (file)
@@ -6,6 +6,7 @@
 #include "XGUI_SalomeConnector.h"
 #include "XGUI_ViewerProxy.h"
 #include "XGUI_Displayer.h"
+#include "XGUI_Selection.h"
 
 #include <ModelAPI_Feature.h>
 #include <ModelAPI_PluginManager.h>
 XGUI_SelectionMgr::XGUI_SelectionMgr(XGUI_Workshop* theParent) :
   QObject(theParent), myWorkshop(theParent)
 {
+  mySelection = new XGUI_Selection(myWorkshop);
 }
 
 XGUI_SelectionMgr::~XGUI_SelectionMgr()
 {
+  delete mySelection;
 }
 
 //**************************************************************
@@ -37,24 +40,29 @@ void XGUI_SelectionMgr::connectViewers()
 //**************************************************************
 void XGUI_SelectionMgr::onObjectBrowserSelection()
 {
-  QFeatureList aFeatures = selectedFeatures();
+  QFeatureList aFeatures = myWorkshop->objectBrowser()->selectedFeatures();
   XGUI_Displayer* aDisplayer = myWorkshop->displayer();
   aDisplayer->setSelected(aFeatures);
-
   emit selectionChanged();
 }
 
 //**************************************************************
 void XGUI_SelectionMgr::onViewerSelection()
 {
-  XGUI_Displayer* aDisplayer = myWorkshop->displayer();
-  QFeatureList aFeatures = aDisplayer->selectedFeatures();
+  QFeatureList aFeatures;
+  Handle(AIS_InteractiveContext) aContext = myWorkshop->viewer()->AISContext();
+  for (aContext->InitSelected(); aContext->MoreSelected(); aContext->NextSelected()) {
+    Handle(AIS_InteractiveObject) anIO = aContext->SelectedInteractive();
+    FeaturePtr aFeature = myWorkshop->displayer()->getFeature(anIO);
+    if (aFeature)
+      aFeatures.append(aFeature);
+  }
   myWorkshop->objectBrowser()->setFeaturesSelected(aFeatures);
   emit selectionChanged();
 }
 
 //**************************************************************
-QFeatureList XGUI_SelectionMgr::selectedFeatures() const 
+/*QFeatureList XGUI_SelectionMgr::selectedFeatures() const 
 { 
   return myWorkshop->objectBrowser()->selectedFeatures(); 
 }
@@ -84,4 +92,4 @@ void XGUI_SelectionMgr::selectedShapes(NCollection_List<TopoDS_Shape>& theList)
     if (!aShape.IsNull())
       theList.Append(aShape);
   }
-}
+}*/
index e98b52841fb76fb321e910d51a52e1ebdbfb7b76..93f19284c72f34fdfe66899494b2933a578c6c86 100644 (file)
@@ -12,6 +12,7 @@
 
 class XGUI_Workshop;
 class XGUI_ObjectsBrowser;
+class XGUI_Selection;
 
 /**\class XGUI_SelectionMgr
  * \ingroup GUI
@@ -25,17 +26,19 @@ public:
   XGUI_SelectionMgr(XGUI_Workshop* theParent);
   virtual ~XGUI_SelectionMgr();
 
+  XGUI_Selection* selection() const { return mySelection; }
+
   //! Returns list of currently selected data objects
-  QFeatureList selectedFeatures() const; 
+  //QFeatureList selectedFeatures() const; 
   
   //! Returns list of currently selected QModelIndexes
-  QModelIndexList selectedIndexes() const;
+  //QModelIndexList selectedIndexes() const;
 
   //! Returns list of currently selected AIS objects
-  void selectedAISObjects(AIS_ListOfInteractive& theList) const;
+  //void selectedAISObjects(AIS_ListOfInteractive& theList) const;
 
   //! Returns list of currently selected shapes
-  void selectedShapes(NCollection_List<TopoDS_Shape>& theList) const;
+  //void selectedShapes(NCollection_List<TopoDS_Shape>& theList) const;
 
   //! Connects the manager to all viewers accessible by Workshop
   void connectViewers();
@@ -49,8 +52,8 @@ private slots:
   void onViewerSelection();
 
 private:
-
   XGUI_Workshop* myWorkshop;
+  XGUI_Selection* mySelection;
 };
 
 #endif
diff --git a/src/XGUI/XGUI_ViewerPrs.cpp b/src/XGUI/XGUI_ViewerPrs.cpp
deleted file mode 100644 (file)
index f280905..0000000
+++ /dev/null
@@ -1,60 +0,0 @@
-// File:        XGUI_ViewerPrs.cpp
-// Created:     20 Apr 2014
-// Author:      Natalia ERMOLAEVA
-
-#include "XGUI_ViewerPrs.h"
-
-#include "SelectMgr_EntityOwner.hxx"
-
-XGUI_ViewerPrs::XGUI_ViewerPrs()
-{
-}
-
-XGUI_ViewerPrs::XGUI_ViewerPrs(FeaturePtr theFeature,
-                               const TopoDS_Shape& theShape,
-                               Handle(SelectMgr_EntityOwner) theOwner)
-: myFeature(theFeature), myShape(theShape), myOwner(theOwner)
-{
-}
-
-XGUI_ViewerPrs::~XGUI_ViewerPrs()
-{
-}
-
-void XGUI_ViewerPrs::setFeature(FeaturePtr theFeature)
-{
-  myFeature = theFeature;
-}
-
-FeaturePtr XGUI_ViewerPrs::feature() const
-{
-  return myFeature;
-}
-
-void XGUI_ViewerPrs::setOwner(Handle(SelectMgr_EntityOwner) theOwner)
-{
-  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
-{
-  return myShape;
-}
-
-bool XGUI_ViewerPrs::operator==(const XGUI_ViewerPrs& thePrs)
-{
-  bool aFeature = (myFeature.get() == thePrs.feature().get());
-  bool aOwner = (myOwner.Access() == thePrs.owner().Access());
-  bool aShape = myShape.IsEqual(thePrs.shape());
-  return aFeature && aOwner && aShape;
-}
diff --git a/src/XGUI/XGUI_ViewerPrs.h b/src/XGUI/XGUI_ViewerPrs.h
deleted file mode 100644 (file)
index 808640c..0000000
+++ /dev/null
@@ -1,67 +0,0 @@
-// File:        XGUI_ViewerPrs.h
-// Created:     20 Apr 2014
-// Author:      Natalia ERMOLAEVA
-
-#ifndef XGUI_ViewerPrs_H
-#define XGUI_ViewerPrs_H
-
-#include "XGUI.h"
-
-#include <boost/shared_ptr.hpp>
-#include <TopoDS_Shape.hxx>
-#include <SelectMgr_EntityOwner.hxx>
-
-#include <ModelAPI_Feature.h>
-
-/**\class XGUI_ViewerPrs
- * \ingroup GUI
- * \brief Presentation. Provides container to have feature, shape and/or selection owner.
- */
-class XGUI_EXPORT XGUI_ViewerPrs
-{
-public:
-  /// Constructor
-  XGUI_ViewerPrs();
-  /// Constructor
-  /// \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(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 shape
-  /// \return a shape instance
-  const TopoDS_Shape& shape() const;
-
-  bool operator==(const XGUI_ViewerPrs&);
-
-private:
-  FeaturePtr myFeature; /// the feature
-  Handle(SelectMgr_EntityOwner) myOwner; /// the selection owner
-  TopoDS_Shape myShape; /// the shape
-};
-
-#endif
index 0b13ba5144359dd18a585d9fcc08e14530b1a273..b5b0b5f6baeeb50b95d9cd621859c12dd4d9cfdf 100644 (file)
@@ -10,6 +10,7 @@
 #include "XGUI_Viewer.h"
 #include "ModuleBase_WidgetFactory.h"
 #include "XGUI_SelectionMgr.h"
+#include "XGUI_Selection.h"
 #include "XGUI_ObjectsBrowser.h"
 #include "XGUI_Displayer.h"
 #include "XGUI_OperationMgr.h"
 #include <ModelAPI_Data.h>
 #include <ModelAPI_AttributeDocRef.h>
 #include <ModelAPI_Object.h>
+#include <ModelAPI_Validator.h>
 
 #include <PartSetPlugin_Part.h>
 
 #include <Events_Loop.h>
 #include <Events_Error.h>
+
 #include <ModuleBase_Operation.h>
 #include <ModuleBase_Operation.h>
 #include <ModuleBase_OperationDescription.h>
+#include <ModuleBase_SelectionValidator.h>
+
 #include <Config_Common.h>
 #include <Config_FeatureMessage.h>
 #include <Config_PointerMessage.h>
@@ -74,7 +79,7 @@ QString XGUI_Workshop::featureIcon(const std::string& theId)
 XGUI_Workshop::XGUI_Workshop(XGUI_SalomeConnector* theConnector)
   : QObject(),
   myCurrentDir(QString()),
-  myPartSetModule(NULL),
+  myModule(NULL),
   mySalomeConnector(theConnector),
   myPropertyPanel(0),
   myObjectBrowser(0),
@@ -85,7 +90,7 @@ XGUI_Workshop::XGUI_Workshop(XGUI_SalomeConnector* theConnector)
   myDisplayer = new XGUI_Displayer(this);
 
   mySelector = new XGUI_SelectionMgr(this);
-  connect(mySelector, SIGNAL(selectionChanged()), this, SLOT(updateModuleCommands()));
+  //connect(mySelector, SIGNAL(selectionChanged()), this, SLOT(updateModuleCommands()));
 
   myOperationMgr = new XGUI_OperationMgr(this);
   myActionsMgr = new XGUI_ActionsMgr(this);
@@ -95,6 +100,7 @@ XGUI_Workshop::XGUI_Workshop(XGUI_SalomeConnector* theConnector)
           this, SLOT(onContextMenuCommand(const QString&, bool)));
 
   myViewerProxy = new XGUI_ViewerProxy(this);
+  connect(myViewerProxy, SIGNAL(selectionChanged()), this, SLOT(updateCommandsOnViewSelection()));
   
   myModuleConnector = new XGUI_ModuleConnector(this);
 
@@ -396,7 +402,7 @@ void XGUI_Workshop::addFeature(const Config_FeatureMessage* theMessage)
                               QKeySequence(), isUsePropPanel);
     salomeConnector()->setNestedActions(aId, aNestedFeatures.split(" "));
     myActionsMgr->addCommand(aAction);
-    myPartSetModule->featureCreated(aAction);
+    myModule->featureCreated(aAction);
   } else {
 
     XGUI_MainMenu* aMenuBar = myMainWindow->menuObject();
@@ -418,7 +424,7 @@ void XGUI_Workshop::addFeature(const Config_FeatureMessage* theMessage)
                                                 QKeySequence(), isUsePropPanel);
     aCommand->setNestedCommands(aNestedFeatures.split(" ", QString::SkipEmptyParts));
     myActionsMgr->addCommand(aCommand);
-    myPartSetModule->featureCreated(aCommand);
+    myModule->featureCreated(aCommand);
   }
 }
 
@@ -662,10 +668,10 @@ bool XGUI_Workshop::activateModule()
 {
   Config_ModuleReader aModuleReader;
   QString moduleName = QString::fromStdString(aModuleReader.getModuleName());
-  myPartSetModule = loadModule(moduleName);
-  if (!myPartSetModule)
+  myModule = loadModule(moduleName);
+  if (!myModule)
     return false;
-  myPartSetModule->createFeatures();
+  myModule->createFeatures();
   myActionsMgr->update();
   return true;
 }
@@ -712,7 +718,7 @@ void XGUI_Workshop::updateCommandStatus()
 }
 
 //******************************************************
-void XGUI_Workshop::updateModuleCommands()
+QList<QAction*> XGUI_Workshop::getModuleCommands() const
 {
   QList<QAction*> aCommands;
   if (isSalomeMode()) { // update commands in SALOME mode
@@ -726,9 +732,7 @@ void XGUI_Workshop::updateModuleCommands()
       }
     }
   }
-  foreach(QAction* aCmd, aCommands) {
-    aCmd->setEnabled(myPartSetModule->isFeatureEnabled(aCmd->data().toString()));
-  }
+  return aCommands;
 }
 
 //******************************************************
@@ -815,7 +819,7 @@ void XGUI_Workshop::onFeatureTriggered()
   if (aCmd) {
     QString aId = salomeConnector()->commandId(aCmd);
     if (!aId.isNull())
-      myPartSetModule->launchOperation(aId);
+      myModule->launchOperation(aId);
   }
 }
 
@@ -854,7 +858,7 @@ XGUI_SalomeViewer* XGUI_Workshop::salomeViewer() const
 //**************************************************************
 void XGUI_Workshop::onContextMenuCommand(const QString& theId, bool isChecked)
 {
-  QFeatureList aFeatures = mySelector->selectedFeatures();
+  QFeatureList aFeatures = mySelector->selection()->selectedFeatures();
   if ((theId == "ACTIVATE_PART_CMD") && (aFeatures.size() > 0))
     activatePart(aFeatures.first());
   else if (theId == "DEACTIVATE_PART_CMD") 
@@ -955,3 +959,24 @@ void XGUI_Workshop::showFeatures(QFeatureList theList, bool isVisible)
   }
   myDisplayer->updateViewer();
 }
+
+//**************************************************************
+void XGUI_Workshop::updateCommandsOnViewSelection()
+{
+  PluginManagerPtr aMgr = ModelAPI_PluginManager::get();
+  ModelAPI_ValidatorsFactory* aFactory = aMgr->validators();
+  XGUI_Selection* aSelection = mySelector->selection();
+
+  QList<QAction*> aActions = getModuleCommands();
+  foreach(QAction* aAction, aActions) {
+    QString aId = aAction->data().toString();
+    const ModelAPI_Validator* aValidator = aFactory->validator(aId.toStdString());
+    if (aValidator) {
+      const ModuleBase_SelectionValidator* aSelValidator = 
+        dynamic_cast<const ModuleBase_SelectionValidator*>(aValidator);
+      if (aSelValidator) {
+        aAction->setEnabled(aSelValidator->isValid(aSelection));
+      }
+    }
+  }
+}
index 32a761f82c8945049791e8aaae73f907f9d35359..960c4dd89e5b5e4ab191c7c8f41c18897f510efc 100644 (file)
@@ -38,6 +38,7 @@ class QWidget;
 class QDockWidget;
 
 class Model_FeatureUpdatedMessage;
+class QAction;
 
 /**\class XGUI_Workshop
  * \ingroup GUI
@@ -117,13 +118,15 @@ public:
   //! Show the given features in 3d Viewer
   void showFeatures(QFeatureList theList, bool isVisible);
 
+  ModuleBase_IModule* module() const { return myModule; }
+
 signals:
   void salomeViewerSelection();
   void errorOccurred(const QString&);
 
 public slots:
   void updateCommandStatus();
-  void updateModuleCommands();
+  void updateCommandsOnViewSelection();
 
   void onNew();
   void onOpen();
@@ -153,6 +156,8 @@ protected:
   void onFeatureCreatedMsg(const Model_FeatureUpdatedMessage* theMsg);
   void onFeatureRedisplayMsg(const Model_FeatureUpdatedMessage* theMsg);
 
+  QList<QAction*> getModuleCommands() const;
+
 protected slots:
   /// SLOT, that is called after the operation is started. Update workshop state according to
   /// the started operation, e.g. visualizes the property panel and connect to it.
@@ -179,7 +184,7 @@ private:
   void createDockWidgets();
 
   XGUI_MainWindow* myMainWindow;
-  ModuleBase_IModule* myPartSetModule;
+  ModuleBase_IModule* myModule;
   XGUI_ObjectsBrowser* myObjectBrowser;
   XGUI_PropertyPanel* myPropertyPanel;
   XGUI_SelectionMgr* mySelector;