]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
Plugin for the folowing task: 3.4 Construction of vertices, edges and faces from...
authornds <nds@opencascade.com>
Thu, 26 Nov 2015 08:05:01 +0000 (11:05 +0300)
committerdbv <dbv@opencascade.com>
Tue, 8 Dec 2015 08:44:56 +0000 (11:44 +0300)
21 files changed:
CMakeLists.txt
src/Config/plugins.xml
src/ModuleBase/CMakeLists.txt
src/ModuleBase/ModuleBase_IWidgetCreator.cpp [new file with mode: 0755]
src/ModuleBase/ModuleBase_IWidgetCreator.h [new file with mode: 0755]
src/PartSet/PartSet_icons.qrc
src/PartSet/icons/sketch_shape.png [new file with mode: 0755]
src/SketchShapePlugin/CMakeLists.txt [new file with mode: 0755]
src/SketchShapePlugin/SketchShapePlugin.h [new file with mode: 0755]
src/SketchShapePlugin/SketchShapePlugin_Feature.cpp [new file with mode: 0755]
src/SketchShapePlugin/SketchShapePlugin_Feature.h [new file with mode: 0755]
src/SketchShapePlugin/SketchShapePlugin_PageGroupBox.cpp [new file with mode: 0755]
src/SketchShapePlugin/SketchShapePlugin_PageGroupBox.h [new file with mode: 0755]
src/SketchShapePlugin/SketchShapePlugin_Plugin.cpp [new file with mode: 0755]
src/SketchShapePlugin/SketchShapePlugin_Plugin.h [new file with mode: 0755]
src/SketchShapePlugin/SketchShapePlugin_Tools.cpp [new file with mode: 0755]
src/SketchShapePlugin/SketchShapePlugin_Tools.h [new file with mode: 0755]
src/SketchShapePlugin/SketchShapePlugin_Validators.cpp [new file with mode: 0755]
src/SketchShapePlugin/SketchShapePlugin_Validators.h [new file with mode: 0755]
src/SketchShapePlugin/Test/TestSketchShape.py [new file with mode: 0755]
src/SketchShapePlugin/plugin-SketchShape.xml [new file with mode: 0755]

index bd81e21070f532b951358e76c76aa29cdee37776..6f7f7a8f61c89112c814c11344037250dc317c14 100644 (file)
@@ -55,6 +55,7 @@ ADD_SUBDIRECTORY (src/ConstructionPlugin)
 ADD_SUBDIRECTORY (src/FeaturesPlugin)
 ADD_SUBDIRECTORY (src/SketcherPrs)
 ADD_SUBDIRECTORY (src/SketchPlugin)
+ADD_SUBDIRECTORY (src/SketchShapePlugin)
 ADD_SUBDIRECTORY (src/SketchSolver)
 ADD_SUBDIRECTORY (src/ModuleBase)
 ADD_SUBDIRECTORY (src/PartSet)
index 70c0311a6a46b89bbf444a70d78f7b4ca95d5407..a8b4b231557d5d2eb66c78a90d58e77ba0de63c9 100644 (file)
@@ -5,6 +5,7 @@
   <plugin library="InitializationPlugin"/>
   <plugin library="PartSetPlugin" configuration="plugin-PartSet.xml"/>
   <plugin library="SketchPlugin" configuration="plugin-Sketch.xml"/>
+  <plugin library="SketchShapePlugin" configuration="plugin-SketchShape.xml"/>
   <plugin library="ConstructionPlugin" configuration="plugin-Construction.xml"/>
   <plugin library="FeaturesPlugin" configuration="plugin-Features.xml"/>
   <plugin library="ExchangePlugin" configuration="plugin-Exchange.xml"/>
index aa6a72b630e70fedd230db19cec96c0f50e12539..ea029d5bd10aca574a98ece6176dd9cd94d03773 100644 (file)
@@ -19,6 +19,7 @@ SET(PROJECT_HEADERS
   ModuleBase_ISelection.h
   ModuleBase_IViewWindow.h
   ModuleBase_IViewer.h
+  ModuleBase_IWidgetCreator.h
   ModuleBase_IWorkshop.h
   ModuleBase_ModelWidget.h
   ModuleBase_Operation.h
@@ -71,6 +72,7 @@ SET(PROJECT_SOURCES
   ModuleBase_ISelection.cpp
   ModuleBase_IViewWindow.cpp
   ModuleBase_IViewer.cpp
+  ModuleBase_IWidgetCreator.cpp
   ModuleBase_IWorkshop.cpp
   ModuleBase_ModelWidget.cpp
   ModuleBase_Operation.cpp
diff --git a/src/ModuleBase/ModuleBase_IWidgetCreator.cpp b/src/ModuleBase/ModuleBase_IWidgetCreator.cpp
new file mode 100755 (executable)
index 0000000..e0f86d6
--- /dev/null
@@ -0,0 +1,13 @@
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
+#include "ModuleBase_IWidgetCreator.h"
+
+ModuleBase_IWidgetCreator::ModuleBase_IWidgetCreator()
+{
+
+}
+
+ModuleBase_IWidgetCreator::~ModuleBase_IWidgetCreator()
+{
+
+}
diff --git a/src/ModuleBase/ModuleBase_IWidgetCreator.h b/src/ModuleBase/ModuleBase_IWidgetCreator.h
new file mode 100755 (executable)
index 0000000..4f1e040
--- /dev/null
@@ -0,0 +1,40 @@
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
+#ifndef ModuleBase_IWidgetCreator_H
+#define ModuleBase_IWidgetCreator_H
+
+#include "ModuleBase.h"
+
+#include <list>
+#include <string>
+
+class ModuleBase_ModelWidget;
+
+class QWidget;
+
+/** 
+* \ingroup GUI
+* Interface to WidgetCreator which can create specific widgets by type
+*/
+class MODULEBASE_EXPORT ModuleBase_IWidgetCreator
+{
+public:
+  /// Default constructor
+  ModuleBase_IWidgetCreator();
+
+  /// Virtual destructor
+  ~ModuleBase_IWidgetCreator();
+
+  /// Returns a list of possible widget types, which this creator can process
+  /// \param theTypes
+  virtual void widgetTypes(std::list<std::string>& theTypes) = 0;
+
+   /// Create widget by its type
+   /// \param theType a type
+   /// \param theParent a parent widget
+  virtual ModuleBase_ModelWidget* createWidgetByType(const std::string& theType,
+                                                     QWidget* theParent = NULL) = 0;
+};
+
+
+#endif
\ No newline at end of file
index 13a0a428f642010af71cabe5ad3d5f44370fd615..7fac03ac44250b64bd566247e6d1a7e88bf386ce 100644 (file)
@@ -29,6 +29,7 @@
      <file>icons/export.png</file>
      <file>icons/line.png</file>
      <file>icons/sketch.png</file>
+     <file>icons/sketch_shape.png</file>
      <file>icons/hand_point.png</file>
      <file>icons/dimension_up.png</file>
      <file>icons/dimension_up_32x32.png</file>
diff --git a/src/PartSet/icons/sketch_shape.png b/src/PartSet/icons/sketch_shape.png
new file mode 100755 (executable)
index 0000000..d55e89c
Binary files /dev/null and b/src/PartSet/icons/sketch_shape.png differ
diff --git a/src/SketchShapePlugin/CMakeLists.txt b/src/SketchShapePlugin/CMakeLists.txt
new file mode 100755 (executable)
index 0000000..97cb8ab
--- /dev/null
@@ -0,0 +1,56 @@
+## Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
+INCLUDE(Common)
+INCLUDE(UnitTest)
+
+SET(PROJECT_HEADERS
+    SketchShapePlugin.h
+    SketchShapePlugin_Feature.h
+    SketchShapePlugin_PageGroupBox.h
+    SketchShapePlugin_Plugin.h
+    SketchShapePlugin_Validators.h
+    SketchShapePlugin_Tools.h
+)
+
+SET(PROJECT_SOURCES
+    SketchShapePlugin_Feature.cpp
+    SketchShapePlugin_PageGroupBox.cpp
+    SketchShapePlugin_Plugin.cpp
+    SketchShapePlugin_Validators.cpp
+    SketchShapePlugin_Tools.cpp
+)
+
+SET(PROJECT_LIBRARIES
+    Config
+    GeomAPI
+    GeomAlgoAPI
+    ModelAPI
+    GeomDataAPI
+    ModuleBase
+    ${QT_LIBRARIES}
+)
+
+SET(XML_RESOURCES
+  plugin-SketchShape.xml
+)
+
+ADD_DEFINITIONS(-DSKETCHSHAPEPLUGIN_EXPORTS)
+ADD_LIBRARY(SketchShapePlugin MODULE ${PROJECT_SOURCES} ${PROJECT_HEADERS} ${XML_RESOURCES})
+TARGET_LINK_LIBRARIES(SketchShapePlugin ${PROJECT_LIBRARIES})
+
+INCLUDE_DIRECTORIES(
+  ../Config
+  ../Events
+  ../ModelAPI
+  ../GeomAPI
+  ../GeomAlgoAPI
+  ../GeomDataAPI
+  ../ModuleBase
+  ${SUIT_INCLUDE}
+  ${CAS_INCLUDE_DIRS}
+)
+
+INSTALL(TARGETS SketchShapePlugin DESTINATION plugins)
+INSTALL(FILES ${XML_RESOURCES} DESTINATION plugins)
+
+ADD_UNIT_TESTS(TestSketchShape.py)
diff --git a/src/SketchShapePlugin/SketchShapePlugin.h b/src/SketchShapePlugin/SketchShapePlugin.h
new file mode 100755 (executable)
index 0000000..e5afe35
--- /dev/null
@@ -0,0 +1,20 @@
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D -->
+
+#ifndef SKETCHSHAPEPLUGIN_H
+#define SKETCHSHAPEPLUGIN_H
+
+#if defined SKETCHSHAPEPLUGIN_EXPORTS
+#if defined WIN32
+#define SKETCHSHAPEPLUGIN_EXPORT              __declspec( dllexport )
+#else
+#define SKETCHSHAPEPLUGIN_EXPORT
+#endif
+#else
+#if defined WIN32
+#define SKETCHSHAPEPLUGIN_EXPORT              __declspec( dllimport )
+#else
+#define SKETCHSHAPEPLUGIN_EXPORT
+#endif
+#endif
+
+#endif
diff --git a/src/SketchShapePlugin/SketchShapePlugin_Feature.cpp b/src/SketchShapePlugin/SketchShapePlugin_Feature.cpp
new file mode 100755 (executable)
index 0000000..0b45548
--- /dev/null
@@ -0,0 +1,30 @@
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D -->
+
+// File:        SketchShapePlugin_Feature.cpp
+// Created:     25 Nov 2015
+// Author:      Natalia ERMOLAEVA
+
+#include "SketchShapePlugin_Feature.h"
+
+#include <ModelAPI_AttributeSelectionList.h>
+#include <ModelAPI_AttributeBoolean.h>
+
+SketchShapePlugin_Feature::SketchShapePlugin_Feature()
+: ModelAPI_Feature()
+{
+}
+
+void SketchShapePlugin_Feature::initAttributes()
+{
+  data()->addAttribute(VERTEX_LIST_ID(), ModelAPI_AttributeSelectionList::typeId());
+  data()->addAttribute(VERTEX_CHOICE_ID(), ModelAPI_AttributeBoolean::typeId());
+}
+
+void SketchShapePlugin_Feature::execute()
+{
+}
+
+void SketchShapePlugin_Feature::attributeChanged(const std::string& theID)
+{
+}
+
diff --git a/src/SketchShapePlugin/SketchShapePlugin_Feature.h b/src/SketchShapePlugin/SketchShapePlugin_Feature.h
new file mode 100755 (executable)
index 0000000..6e38662
--- /dev/null
@@ -0,0 +1,67 @@
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D -->
+
+// File:        SketchShapePlugin_Feature.h
+// Created:     25 Nov 2015
+// Author:      Natalia ERMOLAEVA
+
+#ifndef SKETCHSHAPEPLUGIN_FEATURE_H_
+#define SKETCHSHAPEPLUGIN_FEATURE_H_
+
+#include "SketchShapePlugin.h"
+
+#include <ModelAPI_Feature.h>
+
+/**\class SketchShapePlugin_Feature
+ * \ingroup Plugins
+ * \brief Feature for extraction shapes from the sketch.
+ * The visualization of this object is a result and
+ * it is calculated if all attributes are initialized.
+ * It is possible to extract simultaneously vertices, edges and faces.
+ * 
+ */
+class SketchShapePlugin_Feature : public ModelAPI_Feature
+{
+ public:
+  /// SketchShape feature kind
+  inline static const std::string& ID()
+  {
+    static const std::string MY_SKETCH_SHAPE_ID("SketchShape");
+    return MY_SKETCH_SHAPE_ID;
+  }
+
+  /// List of vertices to be extracted
+  inline static const std::string& VERTEX_LIST_ID()
+  {
+    static const std::string MY_VERTEX_LIST_ID("VertexList");
+    return MY_VERTEX_LIST_ID;
+  }
+
+  /// State whether the vertices are selectable
+  inline static const std::string& VERTEX_CHOICE_ID()
+  {
+    static const std::string MY_VERTEX_CHOICE_ID("VertexChoice");
+    return MY_VERTEX_CHOICE_ID;
+  }
+
+  /// Returns the kind of a feature
+  SKETCHSHAPEPLUGIN_EXPORT virtual const std::string& getKind()
+  {
+    static std::string MY_KIND = SketchShapePlugin_Feature::ID();
+    return MY_KIND;
+  }
+
+  /// Creates an arc-shape
+  SKETCHSHAPEPLUGIN_EXPORT virtual void execute();
+
+  /// Request for initialization of data model of the feature: adding all attributes
+  SKETCHSHAPEPLUGIN_EXPORT virtual void initAttributes();
+
+  /// Called on change of any argument-attribute of this object
+  /// \param theID identifier of changed attribute
+  SKETCHSHAPEPLUGIN_EXPORT virtual void attributeChanged(const std::string& theID);
+
+  /// Use plugin manager for features creation
+  SketchShapePlugin_Feature();
+};
+
+#endif
diff --git a/src/SketchShapePlugin/SketchShapePlugin_PageGroupBox.cpp b/src/SketchShapePlugin/SketchShapePlugin_PageGroupBox.cpp
new file mode 100755 (executable)
index 0000000..e8f9334
--- /dev/null
@@ -0,0 +1,16 @@
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D -->
+
+// File:        SketchShapePlugin_PageGroupBox.h
+// Created:     25 Nov 2015
+// Author:      Natalia ERMOLAEVA
+
+//#include <SketchShapePlugin_PageGroupBox.h>
+
+//#include <QGridLayout>
+
+/*SketchShapePlugin_PageGroupBox::SketchShapePlugin_PageGroupBox(QWidget* theParent)
+: ModuleBase_PageGroupBox(theParent)
+{
+  setTitle("SketchShapePlugin_PageGroupBox");
+}*/
+
diff --git a/src/SketchShapePlugin/SketchShapePlugin_PageGroupBox.h b/src/SketchShapePlugin/SketchShapePlugin_PageGroupBox.h
new file mode 100755 (executable)
index 0000000..4a3666c
--- /dev/null
@@ -0,0 +1,28 @@
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D -->
+
+// File:        SketchShapePlugin_PageGroupBox.h
+// Created:     25 Nov 2015
+// Author:      Natalia ERMOLAEVA
+
+#ifndef SKETCHSHAPEPLUGIN_PAGEGROUPBOX_H_
+#define SKETCHSHAPEPLUGIN_PAGEGROUPBOX_H_
+
+#include <ModuleBase_PageGroupBox.h>
+
+class QWidget;
+
+/*!
+ * \ingroup GUI
+ * Represent a property panel's list of ModuleBase_ModelWidgets.
+ */
+class SketchShapePlugin_PageGroupBox// : public ModuleBase_PageGroupBox
+{
+  //Q_OBJECT
+ public:
+  /// Constructs a page that looks like a QGroupBox
+  SketchShapePlugin_PageGroupBox(QWidget* theParent = 0) {};
+  /// Destructs the page
+  virtual ~SketchShapePlugin_PageGroupBox() {};
+};
+
+#endif /* SKETCHSHAPEPLUGIN_PAGEGROUPBOX_H_ */
diff --git a/src/SketchShapePlugin/SketchShapePlugin_Plugin.cpp b/src/SketchShapePlugin/SketchShapePlugin_Plugin.cpp
new file mode 100755 (executable)
index 0000000..00c5a36
--- /dev/null
@@ -0,0 +1,56 @@
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D -->
+
+// File:        SketchShapePlugin_Plugin.cpp
+// Created:     25 Nov 2015
+// Author:      Natalia ERMOLAEVA
+
+#include <SketchShapePlugin_Plugin.h>
+#include <SketchShapePlugin_Validators.h>
+#include <SketchShapePlugin_Feature.h>
+/*
+#include <SketchShapePlugin_PageGroupBox.h>
+
+#include <Events_Loop.h>
+*/
+#include <ModelAPI_Session.h>
+#include <ModelAPI_Document.h>
+#include <ModelAPI_Validator.h>
+/*#include <ModelAPI_Data.h>
+
+#include <ModuleBase_ModelWidget.h>
+#include <qwidget.h>
+
+#include <memory>*/
+
+// the only created instance of this plugin
+//static SketchShapePlugin_Plugin* MY_SKETCH_SHAPE_INSTANCE = new SketchShapePlugin_Plugin();
+
+SketchShapePlugin_Plugin::SketchShapePlugin_Plugin()
+{
+  SessionPtr aMgr = ModelAPI_Session::get();
+  ModelAPI_ValidatorsFactory* aFactory = aMgr->validators();
+  aFactory->registerValidator("SketchShapePlugin_FeatureValidator",
+                              new SketchShapePlugin_FeatureValidator);
+
+  // register this plugin
+  ModelAPI_Session::get()->registerPlugin(this);
+}
+
+FeaturePtr SketchShapePlugin_Plugin::createFeature(std::string theFeatureID)
+{
+  if (theFeatureID == SketchShapePlugin_Feature::ID()) {
+    return FeaturePtr(new SketchShapePlugin_Feature);
+  }
+  // feature of such kind is not found
+  return FeaturePtr();
+}
+
+/*ModuleBase_ModelWidget* SketchShapePlugin_Plugin::createWidgetByType(const std::string& theType,
+                                                                     QWidget* theParent)
+{
+  ModuleBase_ModelWidget* aWidget = 0;
+  if (theType == "sketchshape_groupbox")
+    aWidget = new SketchShapePlugin_PageGroupBox(theParent);
+  return aWidget;
+}*/
+
diff --git a/src/SketchShapePlugin/SketchShapePlugin_Plugin.h b/src/SketchShapePlugin/SketchShapePlugin_Plugin.h
new file mode 100755 (executable)
index 0000000..3c037c9
--- /dev/null
@@ -0,0 +1,40 @@
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D -->
+
+// File:        SketchShapePlugin_Plugin.hxx
+// Created:     25 Nov 2015
+// Author:      Natalia ERMOLAEVA
+
+#ifndef SKETCHSHAPEPLUGIN_PLUGIN_H_
+#define SKETCHSHAPEPLUGIN_PLUGIN_H_
+
+#include <SketchShapePlugin.h>
+#include <ModelAPI_Plugin.h>
+//#include <ModuleBase_IWidgetCreator.h>
+
+#include <ModelAPI_Feature.h>
+#include <ModelAPI_Events.h>
+
+class ModuleBase_ModelWidget;
+class QWidget;
+
+/**\class SketchShapePlugin_Plugin
+ * \ingroup Plugins
+ * \brief Interface common for any plugin: allows to use plugin by the plugins manager.
+ */
+//, public ModuleBase_IWidgetCreator
+class SketchShapePlugin_Plugin : public ModelAPI_Plugin
+{
+public:
+  /// Creates the feature object of this plugin by the feature string ID
+  virtual FeaturePtr createFeature(std::string theFeatureID);
+
+  /// Create widget by its type
+  /// \param theType a type
+  /// \param theParent a parent widget
+  //virtual ModuleBase_ModelWidget* createWidgetByType(const std::string& theType,
+  //                                                   QWidget* theParent = NULL);
+ public:
+   SketchShapePlugin_Plugin();
+};
+
+#endif
diff --git a/src/SketchShapePlugin/SketchShapePlugin_Tools.cpp b/src/SketchShapePlugin/SketchShapePlugin_Tools.cpp
new file mode 100755 (executable)
index 0000000..dc2fecd
--- /dev/null
@@ -0,0 +1,11 @@
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D -->
+
+// File:        SketchShapePlugin_Tools.cpp
+// Created:     25 Nov 2015
+// Author:      Natalia ERMOLAEVA
+
+#include "SketchShapePlugin_Tools.h"
+
+namespace SketchShapePlugin_Tools {
+
+} // namespace SketchShapePlugin_Tools
diff --git a/src/SketchShapePlugin/SketchShapePlugin_Tools.h b/src/SketchShapePlugin/SketchShapePlugin_Tools.h
new file mode 100755 (executable)
index 0000000..412cf9c
--- /dev/null
@@ -0,0 +1,15 @@
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D -->
+
+// File:        SketchPlugin_Tools.h
+// Created:     25 Nov 2015
+// Author:      Natalia ERMOLAEVA
+
+#ifndef SKETCHSHAPEPLUGIN_TOOLS_H_
+#define SKETCHSHAPEPLUGIN_TOOLS_H_
+
+namespace SketchShapePlugin_Tools {
+
+
+}; // namespace SketchPlugin_Tools
+
+#endif // SKETCHSHAPEPLUGIN_TOOLS_H_
diff --git a/src/SketchShapePlugin/SketchShapePlugin_Validators.cpp b/src/SketchShapePlugin/SketchShapePlugin_Validators.cpp
new file mode 100755 (executable)
index 0000000..0609e53
--- /dev/null
@@ -0,0 +1,21 @@
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D -->
+
+// File:        SketchShapePlugin_Validators.cpp
+// Created:     25 Nov 2015
+// Author:      Natalia ERMOLAEVA
+
+#include "SketchShapePlugin_Validators.h"
+
+//#include "SketchShapePlugin_Feature.h"
+
+bool SketchShapePlugin_FeatureValidator::isValid(const AttributePtr& theAttribute, 
+                                                 const std::list<std::string>& theArguments,
+                                                 std::string& theError) const
+{
+  /*if (theAttribute->attributeType() != ModelAPI_AttributeRefAttr::typeId()) {
+    theError = "The attribute with the " + theAttribute->attributeType() + " type is not processed";
+    return false;
+  }*/
+
+  return true;
+}
diff --git a/src/SketchShapePlugin/SketchShapePlugin_Validators.h b/src/SketchShapePlugin/SketchShapePlugin_Validators.h
new file mode 100755 (executable)
index 0000000..b883fc7
--- /dev/null
@@ -0,0 +1,31 @@
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D -->
+
+// File:        SketchShapePlugin_Validators.h
+// Created:     25 Nov 2015
+// Author:      Natalia ERMOLAEVA
+
+#ifndef SKETCHSHAPEPLUGIN_VALIDATORS_H
+#define SKETCHSHAPEPLUGIN_VALIDATORS_H
+
+#include "SketchShapePlugin.h"
+#include <ModelAPI_AttributeValidator.h>
+
+/**\class SketchShapePlugin_FeatureValidator
+ * \ingroup Validators
+ * \brief Validator for an attribute of sketch shape feature.
+ *
+ * It is empty.
+ */
+class SketchShapePlugin_FeatureValidator : public ModelAPI_AttributeValidator
+{
+ public:
+  //! returns true if attribute is valid
+  //! \param theAttribute the checked attribute
+  //! \param theArguments arguments of the attribute
+  //! \param theError error message
+  virtual bool isValid(const AttributePtr& theAttribute,
+                       const std::list<std::string>& theArguments,
+                       std::string& theError) const;
+};
+
+#endif
diff --git a/src/SketchShapePlugin/Test/TestSketchShape.py b/src/SketchShapePlugin/Test/TestSketchShape.py
new file mode 100755 (executable)
index 0000000..43b8ff0
--- /dev/null
@@ -0,0 +1,129 @@
+"""
+    TestConstraintAngle.py
+    Unit test of SketchPlugin_ConstraintAngle class
+        
+    SketchPlugin_ConstraintAngle
+        static const std::string MY_CONSTRAINT_ANGLE_ID("SketchConstraintAngle");
+        data()->addAttribute(SketchPlugin_Constraint::VALUE(),    ModelAPI_AttributeDouble::typeId());
+        data()->addAttribute(SketchPlugin_Constraint::ENTITY_A(), ModelAPI_AttributeRefAttr::typeId());
+        data()->addAttribute(SketchPlugin_Constraint::ENTITY_B(), ModelAPI_AttributeRefAttr::typeId());
+        data()->addAttribute(SketchPlugin_Constraint::FLYOUT_VALUE_PNT(), GeomDataAPI_Point2D::typeId());
+        
+    
+"""
+from GeomDataAPI import *
+from ModelAPI import *
+import os
+import math
+
+#=========================================================================
+# Auxiliary functions
+#=========================================================================
+
+def angle(theLine1, theLine2):
+    # subroutine to angle between two lines
+    aStartPoint1 = geomDataAPI_Point2D(theLine1.attribute("StartPoint"))
+    aEndPoint1   = geomDataAPI_Point2D(theLine1.attribute("EndPoint"))
+    aStartPoint2 = geomDataAPI_Point2D(theLine2.attribute("StartPoint"))
+    aEndPoint2   = geomDataAPI_Point2D(theLine2.attribute("EndPoint"))
+    
+    aDirX1 = aEndPoint1.x() - aStartPoint1.x()
+    aDirY1 = aEndPoint1.y() - aStartPoint1.y()
+    aLen1 = math.hypot(aDirX1, aDirY1)
+    aDirX2 = aEndPoint2.x() - aStartPoint2.x()
+    aDirY2 = aEndPoint2.y() - aStartPoint2.y()
+    aLen2 = math.hypot(aDirX2, aDirY2)
+    
+    aDot = aDirX1 * aDirX2 + aDirY1 * aDirY2
+    
+    anAngle = math.acos(aDot / aLen1 / aLen2)
+    return round(anAngle * 180. / math.pi, 6)
+
+
+#=========================================================================
+# Initialization of the test
+#=========================================================================
+
+__updated__ = "2015-09-18"
+
+aSession = ModelAPI_Session.get()
+aDocument = aSession.moduleDocument()
+#=========================================================================
+# Creation of a sketch
+#=========================================================================
+aSession.startOperation()
+aSketchCommonFeature = aDocument.addFeature("Sketch")
+aSketchFeature = featureToCompositeFeature(aSketchCommonFeature)
+origin = geomDataAPI_Point(aSketchFeature.attribute("Origin"))
+origin.setValue(0, 0, 0)
+dirx = geomDataAPI_Dir(aSketchFeature.attribute("DirX"))
+dirx.setValue(1, 0, 0)
+norm = geomDataAPI_Dir(aSketchFeature.attribute("Norm"))
+norm.setValue(0, 0, 1)
+aSession.finishOperation()
+#=========================================================================
+# Create two lines
+#=========================================================================
+aSession.startOperation()
+aSketchLineA = aSketchFeature.addFeature("SketchLine")
+aStartPoint = geomDataAPI_Point2D(aSketchLineA.attribute("StartPoint"))
+aEndPoint = geomDataAPI_Point2D(aSketchLineA.attribute("EndPoint"))
+aStartPoint.setValue(-10., 25.)
+aEndPoint.setValue(100., 25.)
+
+aSketchLineB = aSketchFeature.addFeature("SketchLine")
+aStartPoint = geomDataAPI_Point2D(aSketchLineB.attribute("StartPoint"))
+aEndPoint = geomDataAPI_Point2D(aSketchLineB.attribute("EndPoint"))
+aStartPoint.setValue(-20., 15.)
+aEndPoint.setValue(80., 50.)
+aSession.finishOperation()
+#=========================================================================
+# Make a constraint to keep the angle
+#=========================================================================
+ANGLE_DEGREE = 30.
+aSession.startOperation()
+aConstraint = aSketchFeature.addFeature("SketchConstraintAngle")
+anAngleVal = aConstraint.real("ConstraintValue")
+refattrA = aConstraint.refattr("ConstraintEntityA")
+refattrB = aConstraint.refattr("ConstraintEntityB")
+assert (not anAngleVal.isInitialized())
+assert (not refattrA.isInitialized())
+assert (not refattrB.isInitialized())
+anAngleVal.setValue(ANGLE_DEGREE)
+refattrA.setObject(aSketchLineA.firstResult())
+refattrB.setObject(aSketchLineB.firstResult())
+aConstraint.execute()
+aSession.finishOperation()
+assert (anAngleVal.isInitialized())
+assert (refattrA.isInitialized())
+assert (refattrB.isInitialized())
+assert (angle(aSketchLineA, aSketchLineB) == ANGLE_DEGREE)
+#=========================================================================
+# Move line, check that angle is constant
+#=========================================================================
+aSession.startOperation()
+aStartPoint = geomDataAPI_Point2D(aSketchLineA.attribute("StartPoint"))
+aStartPoint.setValue(0., 30.)
+aConstraint.execute()
+aSession.finishOperation()
+assert (angle(aSketchLineA, aSketchLineB) == ANGLE_DEGREE)
+#=========================================================================
+# Change angle value and check the lines are moved
+#=========================================================================
+NEW_ANGLE_DEGREE = 60.
+aSession.startOperation()
+anAngleVal.setValue(NEW_ANGLE_DEGREE)
+aConstraint.execute()
+aSession.finishOperation()
+assert (angle(aSketchLineA, aSketchLineB) == NEW_ANGLE_DEGREE)
+#=========================================================================
+# TODO: improve test
+# 1. remove constraint, move line's start point to
+#    check that constraint are not applied
+# 2. check constrained distance between:
+#    * point and line
+#    * two lines
+#=========================================================================
+#=========================================================================
+# End of test
+#=========================================================================
diff --git a/src/SketchShapePlugin/plugin-SketchShape.xml b/src/SketchShapePlugin/plugin-SketchShape.xml
new file mode 100755 (executable)
index 0000000..4dca705
--- /dev/null
@@ -0,0 +1,22 @@
+<!-- Copyright (C) 2014-20xx CEA/DEN, EDF R&D -->
+
+<plugin>
+  <workbench id="Sketch">
+    <group id="Exchange">
+      <feature id="SketchShape" title="Sketch vertices, edges and faces" tooltip="Construct vertices, edges and faces by sketch" icon=":icons/sketchshape.png">
+        <sketchshape_groupbox title="Direction">
+          <boolvalue id="VertexChoice" label="VERTICES" default="true" tooltip="Vertices selection on sketch"/>
+
+        <sketch_multi_selector id="VertexList"
+            label=""
+            tooltip="Select list of mirroring objects"
+            type_choice="Vertices"
+            use_external="false"
+            use_choice="false">
+          <validator id="SketchShapePlugin_FeatureValidator" />
+        </sketch_multi_selector>
+        </sketchshape_groupbox>
+      </feature>
+    </group>
+  </workbench>
+</plugin>