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)
<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"/>
ModuleBase_ISelection.h
ModuleBase_IViewWindow.h
ModuleBase_IViewer.h
+ ModuleBase_IWidgetCreator.h
ModuleBase_IWorkshop.h
ModuleBase_ModelWidget.h
ModuleBase_Operation.h
ModuleBase_ISelection.cpp
ModuleBase_IViewWindow.cpp
ModuleBase_IViewer.cpp
+ ModuleBase_IWidgetCreator.cpp
ModuleBase_IWorkshop.cpp
ModuleBase_ModelWidget.cpp
ModuleBase_Operation.cpp
--- /dev/null
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
+#include "ModuleBase_IWidgetCreator.h"
+
+ModuleBase_IWidgetCreator::ModuleBase_IWidgetCreator()
+{
+
+}
+
+ModuleBase_IWidgetCreator::~ModuleBase_IWidgetCreator()
+{
+
+}
--- /dev/null
+// 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
<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>
--- /dev/null
+## 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)
--- /dev/null
+// 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
--- /dev/null
+// 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)
+{
+}
+
--- /dev/null
+// 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
--- /dev/null
+// 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");
+}*/
+
--- /dev/null
+// 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_ */
--- /dev/null
+// 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;
+}*/
+
--- /dev/null
+// 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
--- /dev/null
+// 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
--- /dev/null
+// 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_
--- /dev/null
+// 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;
+}
--- /dev/null
+// 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
--- /dev/null
+"""
+ 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
+#=========================================================================
--- /dev/null
+<!-- 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>