]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
Merge branch 'BR_PYTHON_PLUGIN' of newgeom:newgeom.git into Dev_0.6.1
authorsbh <sergey.belash@opencascade.com>
Mon, 22 Dec 2014 07:21:50 +0000 (10:21 +0300)
committersbh <sergey.belash@opencascade.com>
Mon, 22 Dec 2014 07:21:50 +0000 (10:21 +0300)
Conflicts:
src/Events/Events_Loop.cpp:
<<<<<<< HEAD
    if (!aWasFlushed)
      myFlushed.erase(myFlushed.find(theID.myID));
=======
    std::set<char*>::iterator anIt = myFlushed.find(theID.myID);
    if (anIt != myFlushed.end()) {
      myFlushed.erase(anIt);
    }
>>>>>>> origin/BR_PYTHON_PLUGIN
src/ModelAPI/ModelAPI.i
src/ModelAPI/ModelAPI_Plugin.h
src/PartSetPlugin/PartSetPlugin_Plugin.h

568 files changed:
CMakeCommon/CodeCoverage.cmake
CMakeCommon/Common.cmake
CMakeCommon/FindCAS.cmake
CMakeCommon/FindEclipse.cmake
CMakeCommon/FindPython.cmake
CMakeCommon/FindQt.cmake
CMakeCommon/FindSUIT.cmake
CMakeCommon/FindSalome.cmake
CMakeCommon/FindSolveSpace.cmake
CMakeCommon/Logger.cmake
CMakeCommon/UnitTest.cmake
CMakeCommon/XMLProcessing.cmake
CMakeLists.txt
build_Salome740_deb.bat [deleted file]
build_Salome740_rel.bat [deleted file]
build_Salome_deb.bat [new file with mode: 0644]
build_Salome_rel.bat [new file with mode: 0644]
msvc10_env.bat
src/Config/CMakeLists.txt
src/Config/Config_AttributeMessage.cpp
src/Config/Config_AttributeMessage.h
src/Config/Config_Common.cpp
src/Config/Config_Common.h
src/Config/Config_FeatureMessage.cpp
src/Config/Config_FeatureMessage.h
src/Config/Config_FeatureReader.cpp
src/Config/Config_FeatureReader.h
src/Config/Config_Keywords.h
src/Config/Config_ModuleReader.cpp
src/Config/Config_ModuleReader.h
src/Config/Config_PointerMessage.cpp
src/Config/Config_PointerMessage.h
src/Config/Config_Prop.cpp
src/Config/Config_Prop.h
src/Config/Config_PropManager.cpp
src/Config/Config_PropManager.h
src/Config/Config_SelectionFilterMessage.cpp [new file with mode: 0644]
src/Config/Config_SelectionFilterMessage.h [new file with mode: 0644]
src/Config/Config_ValidatorMessage.cpp
src/Config/Config_ValidatorMessage.h
src/Config/Config_WidgetAPI.cpp
src/Config/Config_WidgetAPI.h
src/Config/Config_WidgetReader.cpp
src/Config/Config_WidgetReader.h
src/Config/Config_XMLReader.cpp
src/Config/Config_XMLReader.h
src/Config/Config_def.h
src/Config/plugins.xml
src/ConstructionPlugin/CMakeLists.txt
src/ConstructionPlugin/ConstructionPlugin.h
src/ConstructionPlugin/ConstructionPlugin_Axis.cpp [new file with mode: 0644]
src/ConstructionPlugin/ConstructionPlugin_Axis.h [new file with mode: 0644]
src/ConstructionPlugin/ConstructionPlugin_Plane.cpp [new file with mode: 0644]
src/ConstructionPlugin/ConstructionPlugin_Plane.h [new file with mode: 0644]
src/ConstructionPlugin/ConstructionPlugin_Plugin.cpp
src/ConstructionPlugin/ConstructionPlugin_Plugin.h
src/ConstructionPlugin/ConstructionPlugin_Point.cpp
src/ConstructionPlugin/ConstructionPlugin_Point.h
src/ConstructionPlugin/axis_widget.xml [new file with mode: 0644]
src/ConstructionPlugin/plane_widget.xml [new file with mode: 0644]
src/ConstructionPlugin/plugin-Construction.xml
src/ConstructionPlugin/point_widget.xml
src/Events/CMakeLists.txt
src/Events/Events.h
src/Events/Events_Error.cpp
src/Events/Events_Error.h
src/Events/Events_Listener.cpp
src/Events/Events_Listener.h
src/Events/Events_LongOp.cpp
src/Events/Events_LongOp.h
src/Events/Events_Loop.cpp
src/Events/Events_Loop.h
src/Events/Events_Message.cpp
src/Events/Events_Message.h
src/Events/Events_MessageGroup.cpp
src/Events/Events_MessageGroup.h
src/ExchangePlugin/CMakeLists.txt
src/ExchangePlugin/ExchangePlugin.h
src/ExchangePlugin/ExchangePlugin_ImportFeature.cpp
src/ExchangePlugin/ExchangePlugin_ImportFeature.h
src/ExchangePlugin/ExchangePlugin_Plugin.cpp
src/ExchangePlugin/ExchangePlugin_Plugin.h
src/ExchangePlugin/ExchangePlugin_Validators.cpp
src/ExchangePlugin/ExchangePlugin_Validators.h
src/ExchangePlugin/plugin-Exchange.xml
src/FeaturesPlugin/CMakeLists.txt
src/FeaturesPlugin/FeaturesPlugin.h
src/FeaturesPlugin/FeaturesPlugin_Boolean.cpp
src/FeaturesPlugin/FeaturesPlugin_Boolean.h
src/FeaturesPlugin/FeaturesPlugin_Extrusion.cpp
src/FeaturesPlugin/FeaturesPlugin_Extrusion.h
src/FeaturesPlugin/FeaturesPlugin_Group.cpp
src/FeaturesPlugin/FeaturesPlugin_Group.h
src/FeaturesPlugin/FeaturesPlugin_Placement.cpp [new file with mode: 0644]
src/FeaturesPlugin/FeaturesPlugin_Placement.h [new file with mode: 0644]
src/FeaturesPlugin/FeaturesPlugin_Plugin.cpp
src/FeaturesPlugin/FeaturesPlugin_Plugin.h
src/FeaturesPlugin/Test/TestBoolean.py
src/FeaturesPlugin/Test/TestExtrusion.py
src/FeaturesPlugin/Test/TestGroup.py [new file with mode: 0644]
src/FeaturesPlugin/boolean_widget.xml
src/FeaturesPlugin/extrusion_widget.xml
src/FeaturesPlugin/group_widget.xml
src/FeaturesPlugin/placement_widget.xml [new file with mode: 0644]
src/FeaturesPlugin/plugin-Features.xml
src/GeomAPI/CMakeLists.txt
src/GeomAPI/GeomAPI.h
src/GeomAPI/GeomAPI_AISObject.cpp
src/GeomAPI/GeomAPI_AISObject.h
src/GeomAPI/GeomAPI_Circ.cpp
src/GeomAPI/GeomAPI_Circ.h
src/GeomAPI/GeomAPI_Circ2d.cpp
src/GeomAPI/GeomAPI_Circ2d.h
src/GeomAPI/GeomAPI_Curve.cpp
src/GeomAPI/GeomAPI_Curve.h
src/GeomAPI/GeomAPI_DataMapOfShapeShape.cpp
src/GeomAPI/GeomAPI_DataMapOfShapeShape.h
src/GeomAPI/GeomAPI_Dir.cpp
src/GeomAPI/GeomAPI_Dir.h
src/GeomAPI/GeomAPI_Dir2d.cpp
src/GeomAPI/GeomAPI_Dir2d.h
src/GeomAPI/GeomAPI_Edge.cpp
src/GeomAPI/GeomAPI_Edge.h
src/GeomAPI/GeomAPI_Face.cpp [new file with mode: 0644]
src/GeomAPI/GeomAPI_Face.h [new file with mode: 0644]
src/GeomAPI/GeomAPI_ICustomPrs.h [new file with mode: 0644]
src/GeomAPI/GeomAPI_IPresentable.h
src/GeomAPI/GeomAPI_Interface.cpp
src/GeomAPI/GeomAPI_Interface.h
src/GeomAPI/GeomAPI_Lin.cpp
src/GeomAPI/GeomAPI_Lin.h
src/GeomAPI/GeomAPI_Lin2d.cpp
src/GeomAPI/GeomAPI_Lin2d.h
src/GeomAPI/GeomAPI_PlanarEdges.cpp
src/GeomAPI/GeomAPI_PlanarEdges.h
src/GeomAPI/GeomAPI_Pln.cpp
src/GeomAPI/GeomAPI_Pln.h
src/GeomAPI/GeomAPI_Pnt.cpp
src/GeomAPI/GeomAPI_Pnt.h
src/GeomAPI/GeomAPI_Pnt2d.cpp
src/GeomAPI/GeomAPI_Pnt2d.h
src/GeomAPI/GeomAPI_Shape.cpp
src/GeomAPI/GeomAPI_Shape.h
src/GeomAPI/GeomAPI_Vertex.cpp [new file with mode: 0644]
src/GeomAPI/GeomAPI_Vertex.h [new file with mode: 0644]
src/GeomAPI/GeomAPI_XY.cpp
src/GeomAPI/GeomAPI_XY.h
src/GeomAPI/GeomAPI_XYZ.cpp
src/GeomAPI/GeomAPI_XYZ.h
src/GeomAlgoAPI/CMakeLists.txt
src/GeomAlgoAPI/GeomAlgoAPI.h
src/GeomAlgoAPI/GeomAlgoAPI_Boolean.cpp
src/GeomAlgoAPI/GeomAlgoAPI_Boolean.h
src/GeomAlgoAPI/GeomAlgoAPI_CompoundBuilder.cpp
src/GeomAlgoAPI/GeomAlgoAPI_CompoundBuilder.h
src/GeomAlgoAPI/GeomAlgoAPI_DFLoader.cpp
src/GeomAlgoAPI/GeomAlgoAPI_DFLoader.h
src/GeomAlgoAPI/GeomAlgoAPI_EdgeBuilder.cpp
src/GeomAlgoAPI/GeomAlgoAPI_EdgeBuilder.h
src/GeomAlgoAPI/GeomAlgoAPI_Extrusion.cpp
src/GeomAlgoAPI/GeomAlgoAPI_Extrusion.h
src/GeomAlgoAPI/GeomAlgoAPI_FaceBuilder.cpp
src/GeomAlgoAPI/GeomAlgoAPI_FaceBuilder.h
src/GeomAlgoAPI/GeomAlgoAPI_MakeShape.cpp
src/GeomAlgoAPI/GeomAlgoAPI_MakeShape.h
src/GeomAlgoAPI/GeomAlgoAPI_Placement.cpp [new file with mode: 0644]
src/GeomAlgoAPI/GeomAlgoAPI_Placement.h [new file with mode: 0644]
src/GeomAlgoAPI/GeomAlgoAPI_PointBuilder.cpp
src/GeomAlgoAPI/GeomAlgoAPI_PointBuilder.h
src/GeomAlgoAPI/GeomAlgoAPI_SketchBuilder.cpp
src/GeomAlgoAPI/GeomAlgoAPI_SketchBuilder.h
src/GeomData/CMakeLists.txt
src/GeomData/GeomData.h
src/GeomData/GeomData_Dir.cpp
src/GeomData/GeomData_Dir.h
src/GeomData/GeomData_Point.cpp
src/GeomData/GeomData_Point.h
src/GeomData/GeomData_Point2D.cpp
src/GeomData/GeomData_Point2D.h
src/GeomDataAPI/CMakeLists.txt
src/GeomDataAPI/GeomDataAPI.h
src/GeomDataAPI/GeomDataAPI_Dir.h
src/GeomDataAPI/GeomDataAPI_Point.h
src/GeomDataAPI/GeomDataAPI_Point2D.h
src/GeomValidators/CMakeLists.txt
src/GeomValidators/GeomValidators.h
src/GeomValidators/GeomValidators_Positive.cpp
src/GeomValidators/GeomValidators_Positive.h
src/Model/CMakeLists.txt
src/Model/Model.h
src/Model/Model_Application.cpp
src/Model/Model_Application.h
src/Model/Model_AttributeBoolean.cpp
src/Model/Model_AttributeBoolean.h
src/Model/Model_AttributeDocRef.cpp
src/Model/Model_AttributeDocRef.h
src/Model/Model_AttributeDouble.cpp
src/Model/Model_AttributeDouble.h
src/Model/Model_AttributeInteger.cpp
src/Model/Model_AttributeInteger.h
src/Model/Model_AttributeRefAttr.cpp
src/Model/Model_AttributeRefAttr.h
src/Model/Model_AttributeRefList.cpp
src/Model/Model_AttributeRefList.h
src/Model/Model_AttributeReference.cpp
src/Model/Model_AttributeReference.h
src/Model/Model_AttributeSelection.cpp
src/Model/Model_AttributeSelection.h
src/Model/Model_AttributeSelectionList.cpp
src/Model/Model_AttributeSelectionList.h
src/Model/Model_AttributeString.cpp
src/Model/Model_AttributeString.h
src/Model/Model_Data.cpp
src/Model/Model_Data.h
src/Model/Model_Document.cpp
src/Model/Model_Document.h
src/Model/Model_Events.cpp
src/Model/Model_Events.h
src/Model/Model_FeatureValidator.cpp
src/Model/Model_FeatureValidator.h
src/Model/Model_ResultBody.cpp
src/Model/Model_ResultBody.h
src/Model/Model_ResultConstruction.cpp
src/Model/Model_ResultConstruction.h
src/Model/Model_ResultGroup.cpp
src/Model/Model_ResultGroup.h
src/Model/Model_ResultPart.cpp
src/Model/Model_ResultPart.h
src/Model/Model_Session.cpp
src/Model/Model_Session.h
src/Model/Model_Update.cpp
src/Model/Model_Update.h
src/Model/Model_Validator.cpp
src/Model/Model_Validator.h
src/ModelAPI/CMakeLists.txt
src/ModelAPI/ModelAPI.h
src/ModelAPI/ModelAPI.i
src/ModelAPI/ModelAPI_Attribute.h
src/ModelAPI/ModelAPI_AttributeBoolean.h
src/ModelAPI/ModelAPI_AttributeDocRef.h
src/ModelAPI/ModelAPI_AttributeDouble.h
src/ModelAPI/ModelAPI_AttributeInteger.h
src/ModelAPI/ModelAPI_AttributeRefAttr.h
src/ModelAPI/ModelAPI_AttributeRefList.h
src/ModelAPI/ModelAPI_AttributeReference.h
src/ModelAPI/ModelAPI_AttributeSelection.h
src/ModelAPI/ModelAPI_AttributeSelectionList.h
src/ModelAPI/ModelAPI_AttributeString.h
src/ModelAPI/ModelAPI_AttributeValidator.h
src/ModelAPI/ModelAPI_CompositeFeature.h
src/ModelAPI/ModelAPI_Data.h
src/ModelAPI/ModelAPI_Document.h
src/ModelAPI/ModelAPI_Events.cpp [new file with mode: 0644]
src/ModelAPI/ModelAPI_Events.h
src/ModelAPI/ModelAPI_Feature.cpp
src/ModelAPI/ModelAPI_Feature.h
src/ModelAPI/ModelAPI_FeatureValidator.h
src/ModelAPI/ModelAPI_Object.cpp
src/ModelAPI/ModelAPI_Object.h
src/ModelAPI/ModelAPI_Plugin.h
src/ModelAPI/ModelAPI_RefAttrValidator.h
src/ModelAPI/ModelAPI_Result.cpp
src/ModelAPI/ModelAPI_Result.h
src/ModelAPI/ModelAPI_ResultBody.h
src/ModelAPI/ModelAPI_ResultConstruction.h
src/ModelAPI/ModelAPI_ResultGroup.h
src/ModelAPI/ModelAPI_ResultParameters.h
src/ModelAPI/ModelAPI_ResultPart.h
src/ModelAPI/ModelAPI_ResultValidator.h
src/ModelAPI/ModelAPI_Session.cpp
src/ModelAPI/ModelAPI_Session.h
src/ModelAPI/ModelAPI_Tools.cpp
src/ModelAPI/ModelAPI_Tools.h
src/ModelAPI/ModelAPI_Validator.h
src/ModelAPI/Test/TestDocument.py [new file with mode: 0644]
src/ModuleBase/CMakeLists.txt
src/ModuleBase/ModuleBase.h
src/ModuleBase/ModuleBase_Definitions.h
src/ModuleBase/ModuleBase_DoubleSpinBox.cpp
src/ModuleBase/ModuleBase_DoubleSpinBox.h
src/ModuleBase/ModuleBase_Filter.cpp [new file with mode: 0644]
src/ModuleBase/ModuleBase_Filter.h [new file with mode: 0644]
src/ModuleBase/ModuleBase_FilterFace.cpp [new file with mode: 0644]
src/ModuleBase/ModuleBase_FilterFace.h [new file with mode: 0644]
src/ModuleBase/ModuleBase_FilterFactory.cpp [new file with mode: 0644]
src/ModuleBase/ModuleBase_FilterFactory.h [new file with mode: 0644]
src/ModuleBase/ModuleBase_FilterLinearEdge.cpp [new file with mode: 0644]
src/ModuleBase/ModuleBase_FilterLinearEdge.h [new file with mode: 0644]
src/ModuleBase/ModuleBase_IModule.cpp
src/ModuleBase/ModuleBase_IModule.h
src/ModuleBase/ModuleBase_IPrefMgr.h [new file with mode: 0644]
src/ModuleBase/ModuleBase_IPropertyPanel.h
src/ModuleBase/ModuleBase_ISelection.h
src/ModuleBase/ModuleBase_IViewWindow.h [new file with mode: 0644]
src/ModuleBase/ModuleBase_IViewer.h
src/ModuleBase/ModuleBase_IWorkshop.cpp [new file with mode: 0644]
src/ModuleBase/ModuleBase_IWorkshop.h
src/ModuleBase/ModuleBase_ModelWidget.cpp
src/ModuleBase/ModuleBase_ModelWidget.h
src/ModuleBase/ModuleBase_Operation.cpp
src/ModuleBase/ModuleBase_Operation.h
src/ModuleBase/ModuleBase_OperationDescription.cpp
src/ModuleBase/ModuleBase_OperationDescription.h
src/ModuleBase/ModuleBase_Preferences.cpp [new file with mode: 0644]
src/ModuleBase/ModuleBase_Preferences.h [new file with mode: 0644]
src/ModuleBase/ModuleBase_ResultPrs.cpp
src/ModuleBase/ModuleBase_ResultPrs.h
src/ModuleBase/ModuleBase_SelectionValidator.h
src/ModuleBase/ModuleBase_Tools.cpp
src/ModuleBase/ModuleBase_Tools.h
src/ModuleBase/ModuleBase_ViewerFilters.cpp
src/ModuleBase/ModuleBase_ViewerFilters.h
src/ModuleBase/ModuleBase_ViewerPrs.h
src/ModuleBase/ModuleBase_WidgetBoolValue.cpp
src/ModuleBase/ModuleBase_WidgetBoolValue.h
src/ModuleBase/ModuleBase_WidgetChoice.cpp
src/ModuleBase/ModuleBase_WidgetChoice.h
src/ModuleBase/ModuleBase_WidgetDoubleValue.cpp
src/ModuleBase/ModuleBase_WidgetDoubleValue.h
src/ModuleBase/ModuleBase_WidgetEditor.cpp
src/ModuleBase/ModuleBase_WidgetEditor.h
src/ModuleBase/ModuleBase_WidgetFactory.cpp
src/ModuleBase/ModuleBase_WidgetFactory.h
src/ModuleBase/ModuleBase_WidgetFeature.cpp [deleted file]
src/ModuleBase/ModuleBase_WidgetFeature.h [deleted file]
src/ModuleBase/ModuleBase_WidgetFeatureOrAttribute.cpp [deleted file]
src/ModuleBase/ModuleBase_WidgetFeatureOrAttribute.h [deleted file]
src/ModuleBase/ModuleBase_WidgetFileSelector.cpp
src/ModuleBase/ModuleBase_WidgetFileSelector.h
src/ModuleBase/ModuleBase_WidgetLabel.cpp [new file with mode: 0644]
src/ModuleBase/ModuleBase_WidgetLabel.h [new file with mode: 0644]
src/ModuleBase/ModuleBase_WidgetLineEdit.cpp
src/ModuleBase/ModuleBase_WidgetLineEdit.h
src/ModuleBase/ModuleBase_WidgetMultiSelector.cpp
src/ModuleBase/ModuleBase_WidgetMultiSelector.h
src/ModuleBase/ModuleBase_WidgetPoint2D.cpp [deleted file]
src/ModuleBase/ModuleBase_WidgetPoint2D.h [deleted file]
src/ModuleBase/ModuleBase_WidgetPoint2dDistance.cpp [deleted file]
src/ModuleBase/ModuleBase_WidgetPoint2dDistance.h [deleted file]
src/ModuleBase/ModuleBase_WidgetShapeSelector.cpp
src/ModuleBase/ModuleBase_WidgetShapeSelector.h
src/ModuleBase/ModuleBase_WidgetSwitch.cpp
src/ModuleBase/ModuleBase_WidgetSwitch.h
src/ModuleBase/ModuleBase_WidgetValue.cpp [deleted file]
src/ModuleBase/ModuleBase_WidgetValue.h [deleted file]
src/ModuleBase/ModuleBase_WidgetValueFeature.cpp [deleted file]
src/ModuleBase/ModuleBase_WidgetValueFeature.h [deleted file]
src/NewGeom/CMakeLists.txt
src/NewGeom/NewGeom.h
src/NewGeom/NewGeom_DataModel.cpp
src/NewGeom/NewGeom_DataModel.h
src/NewGeom/NewGeom_Module.cpp
src/NewGeom/NewGeom_Module.h
src/NewGeom/NewGeom_OCCSelector.cpp
src/NewGeom/NewGeom_OCCSelector.h
src/NewGeom/NewGeom_SalomeViewer.cpp
src/NewGeom/NewGeom_SalomeViewer.h
src/NewGeom/resources/LightApp.xml
src/NewGeom/resources/SalomeApp.xml
src/PartSet/CMakeLists.txt
src/PartSet/PartSet.h
src/PartSet/PartSet_Constants.h
src/PartSet/PartSet_EditLine.cpp
src/PartSet/PartSet_EditLine.h
src/PartSet/PartSet_Filters.cpp [new file with mode: 0644]
src/PartSet/PartSet_Filters.h [new file with mode: 0644]
src/PartSet/PartSet_Listener.cpp [deleted file]
src/PartSet/PartSet_Listener.h [deleted file]
src/PartSet/PartSet_Module.cpp
src/PartSet/PartSet_Module.h
src/PartSet/PartSet_Operation.cpp [new file with mode: 0644]
src/PartSet/PartSet_Operation.h [new file with mode: 0644]
src/PartSet/PartSet_OperationFeatureBase.cpp [deleted file]
src/PartSet/PartSet_OperationFeatureBase.h [deleted file]
src/PartSet/PartSet_OperationFeatureCreate.cpp [deleted file]
src/PartSet/PartSet_OperationFeatureCreate.h [deleted file]
src/PartSet/PartSet_OperationFeatureEdit.cpp [deleted file]
src/PartSet/PartSet_OperationFeatureEdit.h [deleted file]
src/PartSet/PartSet_OperationSketch.cpp [deleted file]
src/PartSet/PartSet_OperationSketch.h [deleted file]
src/PartSet/PartSet_OperationSketchBase.cpp [deleted file]
src/PartSet/PartSet_OperationSketchBase.h [deleted file]
src/PartSet/PartSet_TestOCC.cpp
src/PartSet/PartSet_TestOCC.h
src/PartSet/PartSet_Tools.cpp
src/PartSet/PartSet_Tools.h
src/PartSet/PartSet_Validators.cpp
src/PartSet/PartSet_Validators.h
src/PartSet/PartSet_WidgetPoint2d.cpp [new file with mode: 0644]
src/PartSet/PartSet_WidgetPoint2d.h [new file with mode: 0644]
src/PartSet/PartSet_WidgetPoint2dDistance.cpp [new file with mode: 0644]
src/PartSet/PartSet_WidgetPoint2dDistance.h [new file with mode: 0644]
src/PartSet/PartSet_WidgetShapeSelector.cpp [new file with mode: 0644]
src/PartSet/PartSet_WidgetShapeSelector.h [new file with mode: 0644]
src/PartSet/PartSet_WidgetSketchLabel.cpp
src/PartSet/PartSet_WidgetSketchLabel.h
src/PartSet/PartSet_icons.qrc
src/PartSet/icons/arc.png
src/PartSet/icons/axis.png
src/PartSet/icons/circle.png
src/PartSet/icons/common.png
src/PartSet/icons/extrusion.png
src/PartSet/icons/import.png
src/PartSet/icons/line.png
src/PartSet/icons/placement.png [new file with mode: 0644]
src/PartSet/icons/plane.png
src/PartSet/icons/point.png
src/PartSet/icons/revol.png
src/PartSet/icons/sketch.png
src/PartSetPlugin/CMakeLists.txt
src/PartSetPlugin/PartSetPlugin.h
src/PartSetPlugin/PartSetPlugin_Duplicate.cpp
src/PartSetPlugin/PartSetPlugin_Duplicate.h
src/PartSetPlugin/PartSetPlugin_Part.cpp
src/PartSetPlugin/PartSetPlugin_Part.h
src/PartSetPlugin/PartSetPlugin_Plugin.cpp
src/PartSetPlugin/PartSetPlugin_Plugin.h
src/PartSetPlugin/PartSetPlugin_Remove.cpp
src/PartSetPlugin/PartSetPlugin_Remove.h
src/PartSetPlugin/plugin-PartSet.xml
src/SketchPlugin/CMakeLists.txt
src/SketchPlugin/SketchPlugin.h
src/SketchPlugin/SketchPlugin_Arc.cpp
src/SketchPlugin/SketchPlugin_Arc.h
src/SketchPlugin/SketchPlugin_Circle.cpp
src/SketchPlugin/SketchPlugin_Circle.h
src/SketchPlugin/SketchPlugin_Constraint.h
src/SketchPlugin/SketchPlugin_ConstraintBase.cpp
src/SketchPlugin/SketchPlugin_ConstraintBase.h
src/SketchPlugin/SketchPlugin_ConstraintCoincidence.cpp
src/SketchPlugin/SketchPlugin_ConstraintCoincidence.h
src/SketchPlugin/SketchPlugin_ConstraintDistance.cpp
src/SketchPlugin/SketchPlugin_ConstraintDistance.h
src/SketchPlugin/SketchPlugin_ConstraintLength.cpp
src/SketchPlugin/SketchPlugin_ConstraintLength.h
src/SketchPlugin/SketchPlugin_ConstraintParallel.cpp
src/SketchPlugin/SketchPlugin_ConstraintParallel.h
src/SketchPlugin/SketchPlugin_ConstraintPerpendicular.cpp
src/SketchPlugin/SketchPlugin_ConstraintPerpendicular.h
src/SketchPlugin/SketchPlugin_ConstraintRadius.cpp
src/SketchPlugin/SketchPlugin_ConstraintRadius.h
src/SketchPlugin/SketchPlugin_ConstraintRigid.cpp
src/SketchPlugin/SketchPlugin_ConstraintRigid.h
src/SketchPlugin/SketchPlugin_Feature.cpp
src/SketchPlugin/SketchPlugin_Feature.h
src/SketchPlugin/SketchPlugin_Line.cpp
src/SketchPlugin/SketchPlugin_Line.h
src/SketchPlugin/SketchPlugin_Plugin.cpp
src/SketchPlugin/SketchPlugin_Plugin.h
src/SketchPlugin/SketchPlugin_Point.cpp
src/SketchPlugin/SketchPlugin_Point.h
src/SketchPlugin/SketchPlugin_ResultValidators.cpp
src/SketchPlugin/SketchPlugin_ResultValidators.h
src/SketchPlugin/SketchPlugin_Sketch.cpp
src/SketchPlugin/SketchPlugin_Sketch.h
src/SketchPlugin/SketchPlugin_Validators.cpp
src/SketchPlugin/SketchPlugin_Validators.h
src/SketchPlugin/Test/TestConstraintRadius.py
src/SketchPlugin/Test/TestHighload.py
src/SketchPlugin/Test/TestSketchArcCircle.py
src/SketchPlugin/Test/TestSnowflake.py [new file with mode: 0644]
src/SketchPlugin/plugin-Sketch.xml
src/SketchSolver/CMakeLists.txt
src/SketchSolver/SketchSolver.h
src/SketchSolver/SketchSolver_Constraint.cpp
src/SketchSolver/SketchSolver_Constraint.h
src/SketchSolver/SketchSolver_ConstraintGroup.cpp
src/SketchSolver/SketchSolver_ConstraintGroup.h
src/SketchSolver/SketchSolver_ConstraintManager.cpp
src/SketchSolver/SketchSolver_ConstraintManager.h
src/SketchSolver/SketchSolver_Solver.cpp
src/SketchSolver/SketchSolver_Solver.h
src/XGUI/CMakeLists.txt
src/XGUI/NewGeom.xml
src/XGUI/XGUI.h
src/XGUI/XGUI_ActionsMgr.cpp
src/XGUI/XGUI_ActionsMgr.h
src/XGUI/XGUI_Command.cpp [deleted file]
src/XGUI/XGUI_Command.h [deleted file]
src/XGUI/XGUI_Constants.h [deleted file]
src/XGUI/XGUI_ContextMenuMgr.cpp
src/XGUI/XGUI_ContextMenuMgr.h
src/XGUI/XGUI_DataTreeModel.h
src/XGUI/XGUI_Displayer.cpp
src/XGUI/XGUI_Displayer.h
src/XGUI/XGUI_DocumentDataModel.cpp
src/XGUI/XGUI_DocumentDataModel.h
src/XGUI/XGUI_ErrorDialog.cpp
src/XGUI/XGUI_ErrorDialog.h
src/XGUI/XGUI_IPrefMgr.h [deleted file]
src/XGUI/XGUI_MainMenu.cpp [deleted file]
src/XGUI/XGUI_MainMenu.h [deleted file]
src/XGUI/XGUI_MainWindow.cpp [deleted file]
src/XGUI/XGUI_MainWindow.h [deleted file]
src/XGUI/XGUI_MenuGroupPanel.cpp [deleted file]
src/XGUI/XGUI_MenuGroupPanel.h [deleted file]
src/XGUI/XGUI_ModuleConnector.cpp
src/XGUI/XGUI_ModuleConnector.h
src/XGUI/XGUI_ObjectsBrowser.cpp
src/XGUI/XGUI_ObjectsBrowser.h
src/XGUI/XGUI_OperationMgr.cpp
src/XGUI/XGUI_OperationMgr.h
src/XGUI/XGUI_PartDataModel.cpp
src/XGUI/XGUI_PartDataModel.h
src/XGUI/XGUI_Preferences.cpp [deleted file]
src/XGUI/XGUI_Preferences.h [deleted file]
src/XGUI/XGUI_PropertyPanel.cpp
src/XGUI/XGUI_PropertyPanel.h
src/XGUI/XGUI_QtEvents.cpp
src/XGUI/XGUI_QtEvents.h
src/XGUI/XGUI_RubberBand.cpp [deleted file]
src/XGUI/XGUI_RubberBand.h [deleted file]
src/XGUI/XGUI_SalomeConnector.h
src/XGUI/XGUI_Selection.cpp
src/XGUI/XGUI_Selection.h
src/XGUI/XGUI_SelectionMgr.cpp
src/XGUI/XGUI_SelectionMgr.h
src/XGUI/XGUI_Tools.cpp
src/XGUI/XGUI_Tools.h
src/XGUI/XGUI_ViewBackground.cpp [deleted file]
src/XGUI/XGUI_ViewBackground.h [deleted file]
src/XGUI/XGUI_ViewPort.cpp [deleted file]
src/XGUI/XGUI_ViewPort.h [deleted file]
src/XGUI/XGUI_ViewWindow.cpp [deleted file]
src/XGUI/XGUI_ViewWindow.h [deleted file]
src/XGUI/XGUI_Viewer.cpp [deleted file]
src/XGUI/XGUI_Viewer.h [deleted file]
src/XGUI/XGUI_ViewerProxy.cpp
src/XGUI/XGUI_ViewerProxy.h
src/XGUI/XGUI_Workbench.cpp [deleted file]
src/XGUI/XGUI_Workbench.h [deleted file]
src/XGUI/XGUI_Workshop.cpp
src/XGUI/XGUI_Workshop.h
src/XGUI/XGUI_pictures.qrc
src/XGUI/pictures/box.png
src/XGUI/pictures/cascade_views.png [deleted file]
src/XGUI/pictures/exec_state_failed.png [new file with mode: 0644]
src/XGUI/pictures/exec_state_invalid_parameters.png [new file with mode: 0644]
src/XGUI/pictures/new_view.png [deleted file]
src/XGUI/pictures/occ_view_back.png [deleted file]
src/XGUI/pictures/occ_view_bottom.png [deleted file]
src/XGUI/pictures/occ_view_camera_dump.png [deleted file]
src/XGUI/pictures/occ_view_clone.png [deleted file]
src/XGUI/pictures/occ_view_fitall.png [deleted file]
src/XGUI/pictures/occ_view_fitarea.png [deleted file]
src/XGUI/pictures/occ_view_front.png [deleted file]
src/XGUI/pictures/occ_view_glpan.png [deleted file]
src/XGUI/pictures/occ_view_left.png [deleted file]
src/XGUI/pictures/occ_view_pan.png [deleted file]
src/XGUI/pictures/occ_view_reset.png [deleted file]
src/XGUI/pictures/occ_view_right.png [deleted file]
src/XGUI/pictures/occ_view_rotate.png [deleted file]
src/XGUI/pictures/occ_view_top.png [deleted file]
src/XGUI/pictures/occ_view_zoom.png [deleted file]
src/XGUI/pictures/shading.png
src/XGUI/pictures/tile_views.png [deleted file]
src/XGUI/pictures/wireframe.png
src/XGUI/pictures/wnd_close.png [deleted file]
src/XGUI/pictures/wnd_grip.png [deleted file]
src/XGUI/pictures/wnd_maximize.png [deleted file]
src/XGUI/pictures/wnd_minimize.png [deleted file]
src/XGUI/pictures/wnd_restore.png [deleted file]
src/XGUI/pictures/x_point.png
src/XGUI/pictures/x_size.png
src/XGUI/pictures/y_point.png
src/XGUI/pictures/y_size.png
src/XGUI/pictures/z_point.png
src/XGUI/pictures/z_size.png

index b8f5ce043fb9a4c96f644aee6c09bb6a9f73acd1..0299026159012bc9237c34ef934d5856f3eb8be7 100644 (file)
@@ -1,3 +1,5 @@
+## Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
 #
 # 2012-01-31, Lars Bilke
 # - Enable Code Coverage
index b9cf4596f7fd174c6965f05d709b5ca387f04e22..009277a68ead31ae6cbc7ccfa3ff64f051d87f52 100644 (file)
@@ -1,3 +1,5 @@
+## Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
 cmake_minimum_required (VERSION 2.6)
 cmake_policy(SET CMP0011 NEW)
 
index 7b19e28b8958798d72c64129af7ea0eb7bc38f65..1d066b168ff38cfe7a915975b5a9428d09a79553 100644 (file)
@@ -1,3 +1,5 @@
+## Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
 # Copyright (C) 2007-2013  CEA/DEN, EDF R&D, OPEN CASCADE
 #
 # This library is free software; you can redistribute it and/or
index 772b7160ea70c053ff3fd73ef098476fc50ab853..5171af29f4d8d5519da8157cd8b47b5445d936cf 100644 (file)
@@ -1,3 +1,5 @@
+## Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
 IF (CMAKE_GENERATOR MATCHES "NMake Makefiles")
   IF(CMAKE_BUILD_TYPE STREQUAL "Debug")
     ADD_DEFINITIONS(-D_DEBUG)
index 97f5f26440128c1312e07a4ce0968546b4ebd130..c5352896e0d9e5e832066302ec65e80cb588b372 100644 (file)
@@ -1,3 +1,5 @@
+## Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
 
 IF(WIN32)
     IF(CMAKE_BUILD_TYPE STREQUAL "Debug")
index 77376576553c712a1ebec373436938388e82abd3..389f01f5c1192467e7090180f951e35e5699f3e0 100644 (file)
@@ -1,3 +1,5 @@
+## Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
 CMAKE_MINIMUM_REQUIRED(VERSION 2.8.10)
 IF(WIN32)
     SET(QT_USE_QTMAIN ON)
index 260e4cedae08d92f5077e35a169fe5c3143c606a..30cd6e9702f93f59b38867a990c6e6a08eac87f1 100644 (file)
@@ -1,3 +1,5 @@
+## Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
 
 IF(HAVE_SALOME)
   SET(SUIT_INCLUDE ${SALOME_GUI_INCLUDE})
index 114b1e745b711bb943f25d9ed3a7c6f5e60fac17..fb714959c87ffbfaaed40af8bc6aac8f50c4da9c 100644 (file)
@@ -1,3 +1,5 @@
+## Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
 
 
 SET(KERNEL_ROOT_DIR $ENV{KERNEL_ROOT_DIR} CACHE PATH "Path to the Salome KERNEL directory")
index d3c0811e0d30278be45bebf4a42eb4b028160174..40acbbe8ce25d0645fc83f3d40551c735d17fe11 100644 (file)
@@ -1,3 +1,5 @@
+## Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
 SET(SLVS_ROOT_DIR $ENV{SOLVESPACE_ROOT_DIR})
 
 INCLUDE_DIRECTORIES(${SLVS_ROOT_DIR}/include)
index 1807183a09d6dd4c97ca969deaf9dfa1360f8df0..fa90460de2d822731b029e3e90198b771e9dbd37 100644 (file)
@@ -1,3 +1,5 @@
+## Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
 # /*   C++ comment style not allowed   */
 
 
index b401edece28460699a8b3686ea145580d0a9e15b..db5686dfe58baaff172a31b7e02744022a385e18 100644 (file)
@@ -1,3 +1,5 @@
+## Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
 #
 # NewGeom unit test system
 # How to use:
index 04860f1b268922735592c971499a04d39de8ea5c..16a3f11bac9fcd54ddb5ef95a2a38c37a3220f39 100644 (file)
@@ -1,3 +1,5 @@
+## Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
 
 IF(WIN32)
     FILE(TO_CMAKE_PATH $ENV{LIBXML2_ROOT_DIR}/lib/libxml2.lib LIBXML2_LIBRARIES)
index 02ee3ea2c23557f0e36b913840b01e3aa671ea88..5b4167eafc8b88577c29eb468accbed0d8e7e934 100644 (file)
@@ -56,6 +56,7 @@ ADD_SUBDIRECTORY (src/SketchPlugin)
 ADD_SUBDIRECTORY (src/SketchSolver)
 ADD_SUBDIRECTORY (src/ModuleBase)
 ADD_SUBDIRECTORY (src/PartSet)
+ADD_SUBDIRECTORY (src/AppElements)
 ADD_SUBDIRECTORY (src/XGUI)
 ADD_SUBDIRECTORY (src/GeomApp)
 ADD_SUBDIRECTORY (src/ExchangePlugin)
diff --git a/build_Salome740_deb.bat b/build_Salome740_deb.bat
deleted file mode 100644 (file)
index 77a58f1..0000000
+++ /dev/null
@@ -1,19 +0,0 @@
-@ECHO OFF
-
-REM Find absolute path to ROOT_DIR 
-@SET PARENT_DIR=%~dp0..
-@SET ROOT_DIR=
-pushd %PARENT_DIR%
-@SET ROOT_DIR=%CD%
-popd
-
-@SET SRC_DIR=%ROOT_DIR%\sources
-@SET OCC_LIB_PREFIX=d
-
-call %SRC_DIR%\env_Salome.bat d
-mkdir %ROOT_DIR%\build
-cd %ROOT_DIR%\build
-
-cmake %SRC_DIR% -G "Visual Studio 10" -DPYTHON_EXECUTABLE=%PYTHONHOME%\python_d.exe -DCMAKE_BUILD_TYPE=Debug -DCMAKE_INSTALL_PREFIX:PATH=%ROOT_DIR%\install
-
-start "" %MSVC_EXE% NewGEOM.sln
diff --git a/build_Salome740_rel.bat b/build_Salome740_rel.bat
deleted file mode 100644 (file)
index 26fbe15..0000000
+++ /dev/null
@@ -1,18 +0,0 @@
-@ECHO OFF
-
-REM Find absolute path to ROOT_DIR 
-@SET PARENT_DIR=%~dp0..
-@SET ROOT_DIR=
-pushd %PARENT_DIR%
-@SET ROOT_DIR=%CD%
-popd
-
-@SET SRC_DIR=%ROOT_DIR%\sources
-
-call %SRC_DIR%\env_Salome.bat
-mkdir %ROOT_DIR%\build
-cd %ROOT_DIR%\build
-
-cmake %SRC_DIR% -G "Visual Studio 10" -DCMAKE_BUILD_TYPE=Debug -DCMAKE_INSTALL_PREFIX:PATH=%ROOT_DIR%\install
-
-start "" %MSVC_EXE% NewGEOM.sln
diff --git a/build_Salome_deb.bat b/build_Salome_deb.bat
new file mode 100644 (file)
index 0000000..77a58f1
--- /dev/null
@@ -0,0 +1,19 @@
+@ECHO OFF
+
+REM Find absolute path to ROOT_DIR 
+@SET PARENT_DIR=%~dp0..
+@SET ROOT_DIR=
+pushd %PARENT_DIR%
+@SET ROOT_DIR=%CD%
+popd
+
+@SET SRC_DIR=%ROOT_DIR%\sources
+@SET OCC_LIB_PREFIX=d
+
+call %SRC_DIR%\env_Salome.bat d
+mkdir %ROOT_DIR%\build
+cd %ROOT_DIR%\build
+
+cmake %SRC_DIR% -G "Visual Studio 10" -DPYTHON_EXECUTABLE=%PYTHONHOME%\python_d.exe -DCMAKE_BUILD_TYPE=Debug -DCMAKE_INSTALL_PREFIX:PATH=%ROOT_DIR%\install
+
+start "" %MSVC_EXE% NewGEOM.sln
diff --git a/build_Salome_rel.bat b/build_Salome_rel.bat
new file mode 100644 (file)
index 0000000..4f3a061
--- /dev/null
@@ -0,0 +1,18 @@
+@ECHO OFF
+
+REM Find absolute path to ROOT_DIR 
+@SET PARENT_DIR=%~dp0..
+@SET ROOT_DIR=
+pushd %PARENT_DIR%
+@SET ROOT_DIR=%CD%
+popd
+
+@SET SRC_DIR=%ROOT_DIR%\sources
+
+call %SRC_DIR%\env_Salome.bat
+mkdir %ROOT_DIR%\build
+cd %ROOT_DIR%\build
+
+cmake %SRC_DIR% -G "Visual Studio 10" -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX:PATH=%ROOT_DIR%\install
+
+start "" %MSVC_EXE% NewGEOM.sln
index 9f018b720ee1c0ace401c0ae0eabfa54438d5d53..af025a994176940fb1f8cb967675c043393e3c23 100644 (file)
@@ -26,7 +26,7 @@ set PATH=%CMAKEDIR%\bin;%PATH%
 
 @REM -------------------------
 @REM CASCADE
-@SET CAS_ROOT_DIR=%PDIR%\OCCT-6.7.1
+@SET CAS_ROOT_DIR=%PDIR%\OCCT-6.8.0
 @SET CASROOT=%CAS_ROOT_DIR%
 @REM -------------------------
 
index ecf41b60b7d200a699fc1faaffc412366003b178..c5ee88f7817fc6702c22500e4096b4b5c1a0e977 100644 (file)
@@ -1,3 +1,5 @@
+## Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
 INCLUDE(Common)
 INCLUDE(XMLProcessing)
 
@@ -19,6 +21,7 @@ SET(PROJECT_HEADERS
   Config_Prop.h
   Config_PropManager.h
   Config_AttributeMessage.h
+  Config_SelectionFilterMessage.h
  )
  
 SET(PROJECT_SOURCES
@@ -34,6 +37,7 @@ SET(PROJECT_SOURCES
   Config_Prop.cpp
   Config_PropManager.cpp
   Config_AttributeMessage.cpp
+  Config_SelectionFilterMessage.cpp
 )
 
 SET(XML_RESOURCES
index f0a638a107939b90f18c93f1b90c3412b1c8e03c..cea94547e49461fd9c6d1e363902698be512fe8e 100644 (file)
@@ -1,3 +1,5 @@
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
 /*
  *
  */
index f8ac8e3d5d325b83e347051f4cf1adda163e1034..c93565758847f1aac94c36f198f036b5ac829074 100644 (file)
@@ -1,3 +1,5 @@
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
 #ifndef ATTRIBUTE_MESSAGE_H
 #define ATTRIBUTE_MESSAGE_H
 
index b3a93acd1963a5fd52eaf6a78e9294803172cd55..e0837036eb71d200a1a40581e3a98ad3854dfcba 100644 (file)
@@ -1,3 +1,5 @@
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D\r
+\r
 /*\r
  * Config_Common.cpp\r
  *\r
@@ -14,7 +16,8 @@
 #include <sstream> // for stringstream\r
 \r
 #include <string>\r
-#include <algorithm> // for std::transform\r\r
+#include <algorithm> // for std::transform\r
+\r
 bool isElementNode(xmlNodePtr theNode)\r
 {\r
   return theNode->type == XML_ELEMENT_NODE;\r
@@ -55,7 +58,7 @@ bool isWidgetNode(xmlNodePtr theNode)
     return false;\r
 \r
   //it should not be a "source" or a "validator" node\r
-  return !isNode(theNode, NODE_SOURCE, NODE_VALIDATOR, NULL);\r
+  return !isNode(theNode, NODE_SOURCE, NODE_VALIDATOR, NODE_SELFILTER, NULL);\r
 }\r
 \r
 bool hasChild(xmlNodePtr theNode)\r
@@ -69,25 +72,25 @@ bool hasChild(xmlNodePtr theNode)
   return false;\r
 }\r
 \r
-bool getValidatorInfo(xmlNodePtr theNode, std::string& outValidatorId,\r
+bool getParametersInfo(xmlNodePtr theNode, std::string& outPropertyId,\r
                       std::list<std::string>& outValidatorParameters)\r
 {\r
-  //Validator id:\r
+  //Property id:\r
   char* anIdProp = (char*) xmlGetProp(theNode, BAD_CAST _ID);\r
   if (!anIdProp || anIdProp[0] == 0) {\r
     return false;\r
   }\r
-  outValidatorId = std::string(anIdProp);\r
+  outPropertyId = std::string(anIdProp);\r
 \r
-  //Validator parameters:\r
-  char* aParamProp = (char*) xmlGetProp(theNode, BAD_CAST VALIDATOR_PARAMETERS);\r
+  //Property parameters:\r
+  char* aParamProp = (char*) xmlGetProp(theNode, BAD_CAST _PARAMETERS);\r
   if (aParamProp && aParamProp[0] != 0) {\r
     std::string aPropString = std::string(aParamProp);\r
     std::stringstream aPropStringStream(aPropString);\r
     char COMMA_DELIM = ',';\r
-    std::string aValidatorParameter;\r
-    while (std::getline(aPropStringStream, aValidatorParameter, ',')) {\r
-      outValidatorParameters.push_back(aValidatorParameter);\r
+    std::string aParameter;\r
+    while (std::getline(aPropStringStream, aParameter, ',')) {\r
+      outValidatorParameters.push_back(aParameter);\r
     }\r
   }\r
   return true;\r
@@ -95,6 +98,8 @@ bool getValidatorInfo(xmlNodePtr theNode, std::string& outValidatorId,
 \r
 std::string library(const std::string& theLibName)\r
 {\r
+  if(theLibName.empty())\r
+    return std::string();\r
   std::string aLibName = theLibName;\r
 #ifndef WIN32\r
   static std::string aLibExt( ".so" );\r
index 0c2689757cc3958a3cc3e6a7b605931f34a86320..05e2024fd2d049eee678883a1fd34b9d6da8c4dd 100644 (file)
@@ -1,3 +1,5 @@
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
 /*
  * Config_Common.h
  *
@@ -56,10 +58,10 @@ CONFIG_EXPORT bool isWidgetNode(xmlNodePtr theNode);
 CONFIG_EXPORT bool hasChild(xmlNodePtr theNode);
 
 /*
- *
+ * Returns named property for an id node as std::string and the parameters of the node.
  */
-CONFIG_EXPORT bool getValidatorInfo(xmlNodePtr theNode, std::string& outValidatorId,
-                                    std::list<std::string>& outValidatorParameters);
+CONFIG_EXPORT bool getParametersInfo(xmlNodePtr theNode, std::string& outPropertyId,
+                                     std::list<std::string>& outValidatorParameters);
 
 /*!
  \brief Convert the given parameter to the platform-specific library name.
index de0966349dc6615022182f88b6aec68963ef0a7c..f5c77fb40ead4a08b94b9c4b5e6c7061f1899371 100644 (file)
@@ -1,3 +1,5 @@
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
 /*
  *
  */
index 04afbad199f0cbc5a5f1ca0436498c9341862a98..68bd94378fc5c54ca4f29a91c4faa11e10cef399 100644 (file)
@@ -1,3 +1,5 @@
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D\r
+\r
 #ifndef CONFIG_MESSAGE_H\r
 #define CONFIG_MESSAGE_H\r
 \r
index 9ebc93f78f821c399ec5106c85bb5844db09e5d5..94274a40ab08361e14807d2e3c6fdbb335023ffb 100644 (file)
@@ -1,3 +1,5 @@
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
 /*
  * Config_FeatureReader.cpp
  *
@@ -65,8 +67,8 @@ void Config_FeatureReader::processNode(xmlNodePtr theNode)
     std::string anAttributeID = getProperty(theNode, _ID);
     if (!anAttributeID.empty()) {
       aMessage->setAttributeId(anAttributeID);
-      aMessage->setObligatory(getBooleanAttribute(theNode, ATTRIBUTE_OBLIGATORY, true));
-      aMessage->setConcealment(getBooleanAttribute(theNode, ATTRIBUTE_CONCEALMENT, false));
+      aMessage->setObligatory(getBooleanAttribute(theNode, ATTR_OBLIGATORY, true));
+      aMessage->setConcealment(getBooleanAttribute(theNode, ATTR_CONCEALMENT, false));
       Events_Loop::loop()->send(aMessage);
     }
   }
@@ -83,26 +85,31 @@ bool Config_FeatureReader::processChildren(xmlNodePtr theNode)
   return result;
 }
 
-void Config_FeatureReader::fillFeature(xmlNodePtr theNode, 
+void Config_FeatureReader::fillFeature(xmlNodePtr theFeatureNode,
   const std::shared_ptr<Config_FeatureMessage>& outFeatureMessage)
 {
-  outFeatureMessage->setId(getProperty(theNode, _ID));
+  outFeatureMessage->setId(getProperty(theFeatureNode, _ID));
   outFeatureMessage->setPluginLibrary(myLibraryName);
-  outFeatureMessage->setNestedFeatures(getProperty(theNode, FEATURE_NESTED));
+  outFeatureMessage->setNestedFeatures(getProperty(theFeatureNode, FEATURE_NESTED));
 
-  bool isInternal = getBooleanAttribute(theNode, ATTRIBUTE_INTERNAL, false);
+  bool isInternal = getBooleanAttribute(theFeatureNode, ATTR_INTERNAL, false);
   outFeatureMessage->setInternal(isInternal);
   if (isInternal) {
     //Internal feature has no visual representation.
     return;
   }
-  outFeatureMessage->setText(getProperty(theNode, FEATURE_TEXT));
-  outFeatureMessage->setTooltip(getProperty(theNode, FEATURE_TOOLTIP));
-  outFeatureMessage->setIcon(getProperty(theNode, FEATURE_ICON));
-  outFeatureMessage->setKeysequence(getProperty(theNode, FEATURE_KEYSEQUENCE));
+  outFeatureMessage->setText(getProperty(theFeatureNode, FEATURE_TEXT));
+  outFeatureMessage->setTooltip(getProperty(theFeatureNode, FEATURE_TOOLTIP));
+  outFeatureMessage->setIcon(getProperty(theFeatureNode, FEATURE_ICON));
+  outFeatureMessage->setKeysequence(getProperty(theFeatureNode, FEATURE_KEYSEQUENCE));
   outFeatureMessage->setGroupId(restoreAttribute(NODE_GROUP, _ID));
   outFeatureMessage->setWorkbenchId(restoreAttribute(NODE_WORKBENCH, _ID));
-  outFeatureMessage->setDocumentKind(restoreAttribute(NODE_WORKBENCH, WORKBENCH_DOC));
+  // Get document kind of a feature, if empty set workbench's kind (might be empty too)
+  std::string aDocKind = getProperty(theFeatureNode, FEATURE_DOC);
+  if(aDocKind.empty()) {
+    aDocKind = restoreAttribute(NODE_WORKBENCH, WORKBENCH_DOC);
+  }
+  outFeatureMessage->setDocumentKind(aDocKind);
 }
 
 void Config_FeatureReader::storeAttribute(xmlNodePtr theNode,
index 005c9d7f2594fb791005a8cbfbbd3009d89b848a..eec7889b01df91ee00b815a8373929d4956f8b9a 100644 (file)
@@ -1,3 +1,5 @@
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
 /*
  * Config_FeatureReader.h
  *
index 62c5f59af88d6e1518de8a496badc71d3636faea..bc9f4e419bae005781f5767e4311b8ba6526534d 100644 (file)
@@ -1,3 +1,5 @@
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
 /*
  * Config_Keywords.h
  *
@@ -16,8 +18,9 @@ const static char* NODE_GROUP = "group";
 const static char* NODE_FEATURE = "feature";
 const static char* NODE_SOURCE = "source";
 const static char* NODE_VALIDATOR = "validator";
+const static char* NODE_SELFILTER = "selection_filter";
 
-//Widgets
+// Widgets
 const static char* WDG_INFO = "label";
 const static char* WDG_DOUBLEVALUE = "doublevalue";
 const static char* WDG_BOOLVALUE = "boolvalue";
@@ -25,53 +28,48 @@ const static char* WDG_STRINGVALUE = "stringvalue";
 const static char* WDG_MULTISELECTOR = "multi_selector";
 const static char* WDG_SHAPE_SELECTOR = "shape_selector";
 const static char* WDG_CHOICE = "choice";
-//Specific widgets
-const static char* WDG_POINT_SELECTOR = "point_selector";
-const static char* WDG_POINT2D_DISTANCE = "point2ddistance";
-const static char* WDG_FEATURE_SELECTOR = "feature_selector";
-const static char* WDG_FEATURE_OR_ATTRIBUTE_SELECTOR = "feature_or_attribute_selector";
 const static char* WDG_DOUBLEVALUE_EDITOR = "doublevalue_editor";
 const static char* WDG_FILE_SELECTOR= "file_selector";
-
-//Widget containers
+// Containers
 const static char* WDG_GROUP = "groupbox";
 const static char* WDG_CHECK_GROUP = "check_groupbox";
 const static char* WDG_TOOLBOX = "toolbox";
 const static char* WDG_TOOLBOX_BOX = "box";
 const static char* WDG_SWITCH = "switch";
 const static char* WDG_SWITCH_CASE = "case";
-
-const static char* WORKBENCH_DOC = "document";
-//Common Widget's or Feature's Properties
+// Common properties (xml attributes of nodes)
 const static char* _ID = "id";
+// NODE_WORKBENCH properties
+const static char* WORKBENCH_DOC = "document";
+// NODE_SOURCE properties
+const static char* SOURCE_FILE = "path";
+// NODE_FEATURE properties
 const static char* FEATURE_TOOLTIP = "tooltip";
 const static char* FEATURE_ICON = "icon";
 const static char* FEATURE_TEXT = "title";
 const static char* FEATURE_KEYSEQUENCE = "keysequence";
 const static char* FEATURE_NESTED = "nested";
+const static char* FEATURE_DOC = WORKBENCH_DOC;
+// NODE_VALIDATOR properties, NODE_SELFILTER properties
+const static char* _PARAMETERS = "parameters";
 
-const static char* ATTRIBUTE_INTERNAL = "internal";
-const static char* ATTRIBUTE_OBLIGATORY = "obligatory";
-const static char* ATTRIBUTE_CONCEALMENT = "concealment";
-// TODO: Rename
-const static char* PREVIOUS_FEATURE_PARAM = "previous_feature_param";
-const static char* ANY_WDG_TOOLTIP = FEATURE_TOOLTIP;
-const static char* ANY_WDG_ICON = FEATURE_ICON;
-const static char* ANY_WDG_LABEL = "label";
-const static char* ANY_WDG_DEFAULT = "default";
-
-const static char* SOURCE_FILE = "path";
-const static char* VALIDATOR_PARAMETERS = "parameters";
-
-// doublevalue properties:
+// Widget (attribute) properties
+const static char* ATTR_TOOLTIP = FEATURE_TOOLTIP;
+const static char* ATTR_ICON = FEATURE_ICON;
+const static char* ATTR_LABEL = "label";
+const static char* ATTR_DEFAULT = "default";
+const static char* ATTR_INTERNAL = "internal";
+const static char* ATTR_OBLIGATORY = "obligatory";
+const static char* ATTR_CONCEALMENT = "concealment";
+// WDG_INFO properties
 const static char* INFO_WDG_TEXT = FEATURE_TEXT;
 const static char* INFO_WDG_TOOLTIP = FEATURE_TOOLTIP;
+// WDG_DOUBLEVALUE properties:
 const static char* DOUBLE_WDG_MIN = "min";
 const static char* DOUBLE_WDG_MAX = "max";
 const static char* DOUBLE_WDG_STEP = "step";
 const static char* DOUBLE_WDG_DEFAULT_COMPUTED = "computed";
-
-//toolbox/switch properties
+// WDG_TOOLBOX/WDG_SWITCH properties
 const static char* CONTAINER_PAGE_NAME = "title";
 
 /*
index 0cfe432467368dcaa718c57bd889eaea81eccbab..21925af599b1b91fca64131371d931ed98ad6443 100644 (file)
@@ -1,3 +1,5 @@
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
 /*
  * Config_ModuleReader.cpp
  *
index 137afbeaeaa67f03d1667ebd8e9762613e156226..2281eb5cd33910e46bd16949e25b8b8b7afe6f7e 100644 (file)
@@ -1,3 +1,5 @@
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
 /*
  * Config_XMLModuleReader.h
  *
index 60f27398f3ad3d7e0df993f7b9c843ebe4359529..68b37a872cbb203f48a65932ca4ab741f5691c4c 100644 (file)
@@ -1,3 +1,5 @@
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
 /*
  * Config_PointerMessage.cpp
  *
index 87aee317179fc98fc8599e5fcdd6461feb6d2229..e745beb0e48dc3abc0eb83794edb8d4f86ac683c 100644 (file)
@@ -1,3 +1,5 @@
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
 /*
  * Config_PointerMessage.h
  *
index f2854009b70494c8995e9a9ba053ce9a691d0758..91b9686700a5fff66ce0fb5b44db621294a62f6a 100644 (file)
@@ -1,3 +1,5 @@
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
 // File:        Config_Prop.cpp
 // Created:     18 Sep 2014
 // Author:      Mikhail PONIKAROV
index 4430bade8b68c4c6f655c2201a37c23f640e57b0..b9252a8c0b3bd8138aaa0806942e807c3cea5a6d 100644 (file)
@@ -1,3 +1,5 @@
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
 // File:        Config_Prop.h
 // Created:     12 Aug 2014
 // Author:      Vitaly SMETANNIKOV
@@ -37,7 +39,8 @@ class Config_Prop
     Shortcut,
     ShortcutTree,
     BiColor,
-    Background
+    Background,
+    Directory
   };
 
   /** 
index e6f800c27f649ba7c91b23f5c4ac701ff5a79e59..82ec43f5871c82fba052e124ee830189943d53ef 100644 (file)
@@ -1,3 +1,5 @@
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
 // File:        Config_PropManager.cpp
 // Created:     13 Aug 2014
 // Author:      Vitaly SMETANNIKOV
index 444312ebd501fb9cbb77f60785007803c6d34a9c..4df2e55635c63d168dfb2156a92802ea6ccf94c2 100644 (file)
@@ -1,3 +1,5 @@
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
 // File:        Config_PropManager.h
 // Created:     13 Aug 2014
 // Author:      Vitaly SMETANNIKOV
diff --git a/src/Config/Config_SelectionFilterMessage.cpp b/src/Config/Config_SelectionFilterMessage.cpp
new file mode 100644 (file)
index 0000000..cb958cd
--- /dev/null
@@ -0,0 +1,64 @@
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
+/*
+ * Config_SelectionFilterMessage.cpp
+ *
+ *  Created on: 08 Jul 2014
+ *      Author: sbh
+ */
+
+#include <Config_SelectionFilterMessage.h>
+
+Config_SelectionFilterMessage::Config_SelectionFilterMessage(const Events_ID theId,
+                                                             const void* theParent)
+    : Events_Message(theId, theParent)
+{
+  mySelectionFilterId = "";
+  myFeatureId = "";
+  myAttributeId = "";
+}
+
+Config_SelectionFilterMessage::~Config_SelectionFilterMessage()
+{
+}
+
+const std::string& Config_SelectionFilterMessage::selectionFilterId() const
+{
+  return mySelectionFilterId;
+}
+
+const std::string& Config_SelectionFilterMessage::featureId() const
+{
+  return myFeatureId;
+}
+
+void Config_SelectionFilterMessage::setSelectionFilterId(const std::string& theId)
+{
+  mySelectionFilterId = theId;
+}
+
+const std::string& Config_SelectionFilterMessage::attributeId() const
+{
+  return myAttributeId;
+}
+
+const std::list<std::string>& Config_SelectionFilterMessage::parameters() const
+{
+  return myFilterParameters;
+}
+
+void Config_SelectionFilterMessage::setFeatureId(const std::string& theId)
+{
+  myFeatureId = theId;
+}
+
+void Config_SelectionFilterMessage::setAttributeId(const std::string& theId)
+{
+  myAttributeId = theId;
+}
+
+void Config_SelectionFilterMessage::setFilterParameters(const std::list<std::string>& parameters)
+{
+  myFilterParameters = parameters;
+}
+
diff --git a/src/Config/Config_SelectionFilterMessage.h b/src/Config/Config_SelectionFilterMessage.h
new file mode 100644 (file)
index 0000000..d43b413
--- /dev/null
@@ -0,0 +1,44 @@
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
+/*
+ * Config_SelectionFilterMessage.h
+ *
+ *  Created on: 08 Jul 2014
+ *      Author: sbh
+ */
+
+#ifndef CONFIG_SELECTIONFILTERMESSAGE_H_
+#define CONFIG_SELECTIONFILTERMESSAGE_H_
+
+#include <Events_Message.h>
+#include <Config_def.h>
+
+#include <list>
+#include <string>
+
+/// Event ID that Selection Filter is loaded (comes with Config_SelectionFilterMessage)
+static const char * EVENT_SELFILTER_LOADED = "SelectionFilterLoaded";
+
+class Config_SelectionFilterMessage : public Events_Message
+{
+  std::string mySelectionFilterId;
+  std::string myFeatureId;
+  std::string myAttributeId;
+  std::list<std::string> myFilterParameters;
+
+ public:
+  CONFIG_EXPORT Config_SelectionFilterMessage(const Events_ID theId, const void* theParent = 0);
+  CONFIG_EXPORT virtual ~Config_SelectionFilterMessage();
+
+  CONFIG_EXPORT const std::string& selectionFilterId() const;
+  CONFIG_EXPORT const std::string& featureId() const;
+  CONFIG_EXPORT const std::string& attributeId() const;
+  CONFIG_EXPORT const std::list<std::string>& parameters() const;
+
+  CONFIG_EXPORT void setSelectionFilterId(const std::string& theId);
+  CONFIG_EXPORT void setFeatureId(const std::string& theId);
+  CONFIG_EXPORT void setAttributeId(const std::string& theId);
+  CONFIG_EXPORT void setFilterParameters(const std::list<std::string>& parameters);
+};
+
+#endif /* CONFIG_SELECTIONFILTERMESSAGE_H_ */
index 61ee376c00d87c6b7f9ba2a1bffa3676137b1ccf..7bc98763979c81ced029e4cbfa856b3888628dde 100644 (file)
@@ -1,7 +1,9 @@
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
 /*
  * Config_ValidatorMessage.cpp
  *
- *  Created on: 08 Jul 2014 ã.
+ *  Created on: 08 Jul 2014 .
  *      Author: sbh
  */
 
@@ -19,11 +21,6 @@ Config_ValidatorMessage::~Config_ValidatorMessage()
 {
 }
 
-//static const const char* Config_ValidatorMessage::UID() const
-//{
-//  return "ValidatorMessage";
-//}
-
 const std::string& Config_ValidatorMessage::validatorId() const
 {
   return myValidatorId;
index 16ec279222b136d3d9c06fbe46ee7132e36b0c51..1863891933a23b4476b6a0c46cc942a6a7ed7cef 100644 (file)
@@ -1,7 +1,9 @@
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
 /*
  * Config_ValidatorMessage.h
  *
- *  Created on: 08 Jul 2014 ã.
+ *  Created on: 08 Jul 2014 .
  *      Author: sbh
  */
 
@@ -14,7 +16,7 @@
 #include <list>
 #include <string>
 
-/// Event ID that feature is loaded (comes with Config_FeatureMessage)
+/// Event ID that Validator is loaded (comes with Config_ValidatorMessage)
 static const char * EVENT_VALIDATOR_LOADED = "ValidatorLoaded";
 
 class Config_ValidatorMessage : public Events_Message
index 085648e9708b5f6d6f1d96bd5bbd6146aba02608..994a46f99c9a300205331c5c5d1c85389e964535 100644 (file)
@@ -1,3 +1,5 @@
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
 /*
  * Config_WidgetAPI.cpp
  *
@@ -99,15 +101,15 @@ std::string Config_WidgetAPI::widgetId() const
 
 std::string Config_WidgetAPI::widgetIcon() const
 {
-  return getProperty(ANY_WDG_ICON);
+  return getProperty(ATTR_ICON);
 }
 
 std::string Config_WidgetAPI::widgetLabel() const
 {
-  return getProperty(ANY_WDG_LABEL);
+  return getProperty(ATTR_LABEL);
 }
 
 std::string Config_WidgetAPI::widgetTooltip() const
 {
-  return getProperty(ANY_WDG_TOOLTIP);
+  return getProperty(ATTR_TOOLTIP);
 }
index 44349fc418ec38d2d352966856b635f841e6f174..ed58bb4f50b6ff05a0d8df052359280d4e979634 100644 (file)
@@ -1,3 +1,5 @@
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
 /*
  * Config_WidgetAPI.h
  *
index e4125b3e688049f15812d0e01188d0c4cb74def5..4899fe190ecfc05b38e33a07e3838fa12ea46f33 100644 (file)
@@ -1,3 +1,5 @@
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
 /*
  * Config_WidgetReader.cpp
  *
@@ -54,7 +56,9 @@ void Config_WidgetReader::processNode(xmlNodePtr theNode)
 bool Config_WidgetReader::processChildren(xmlNodePtr theNode)
 {
   //Read all nodes recursively, source and validator nodes have no children
-  return !isNode(theNode, NODE_VALIDATOR, NODE_SOURCE, NULL);
+  return !isNode(theNode, NODE_VALIDATOR,
+                          NODE_SELFILTER,
+                          NODE_SOURCE, NULL);
 }
 
 void Config_WidgetReader::resolveSourceNodes(xmlNodePtr theNode)
index 55ce4e932b06183b0c8aa35ebc7bacb53af05539..ab60f4278d7dd63fe6163c9d4a2903445f8ab82a 100644 (file)
@@ -1,3 +1,5 @@
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
 /*
  * Config_WidgetReader.h
  *
index 44c806ce919faebbb6e70e7121e6ee6eecf0cd4c..856e663becd7511c6a01bd1fa9a6a4685a6ff5c0 100644 (file)
@@ -1,3 +1,5 @@
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
 /*
  * Config_XMLReader.cpp
  *
 #include <Config_Keywords.h>
 #include <Config_Common.h>
 #include <Config_ValidatorMessage.h>
+#include <Config_SelectionFilterMessage.h>
+#include <Config_PropManager.h>
 
 #include <Events_Loop.h>
+#include <Events_Error.h>
 #include <libxml/parser.h>
 #include <libxml/tree.h>
 
+#include <fstream>
+
 #ifdef WIN32
 #pragma warning(disable : 4996) // for getenv
 #endif
 Config_XMLReader::Config_XMLReader(const std::string& theXmlFileName)
     : myXmlDoc(NULL)
 {
-  std::string prefix = "";
+  std::string prefix = ""; 
+  Config_Prop* aProp = Config_PropManager::findProp("Plugins", "default_path");
+  if (aProp)
+    prefix = aProp->value();
   /*
    * Get path to *.xml files (typically ./bin/../plugins/)
 
    * the problem: application may be launched using python executable,
    * to use environment variable (at least for the current moment)
    */
-  char* anEnv = getenv("NEW_GEOM_CONFIG_FILE");
-  if (anEnv) {
-    prefix = std::string(anEnv) + "/";
+  if (prefix.empty()) {
+    char* anEnv = getenv("NEW_GEOM_CONFIG_FILE");
+    if (anEnv) {
+      prefix = std::string(anEnv);
+    }
   }
-
+#ifdef WIN32
+    prefix += "\\";
+#else
+    prefix += "/";
+#endif
   myDocumentPath = prefix + theXmlFileName;
+  std::ifstream aTestFile(myDocumentPath);
+  if (!aTestFile) Events_Error::send("Unable to open " + myDocumentPath);
+  aTestFile.close();
 }
 
 Config_XMLReader::~Config_XMLReader()
@@ -72,6 +91,8 @@ void Config_XMLReader::processNode(xmlNodePtr theNode)
 #endif
   } else if (isNode(theNode, NODE_VALIDATOR, NULL)) {
     processValidator(theNode);
+  } else if (isNode(theNode, NODE_SELFILTER, NULL)) {
+    processSelectionFilter(theNode);
   }
 }
 
@@ -155,10 +176,32 @@ void Config_XMLReader::processValidator(xmlNodePtr theNode)
   std::shared_ptr<Config_ValidatorMessage> 
     aMessage(new Config_ValidatorMessage(aValidatoEvent, this));
   std::string aValidatorId;
-  std::list<std::string> aValidatorParameters;
-  getValidatorInfo(theNode, aValidatorId, aValidatorParameters);
+  std::list<std::string> aParameters;
+  getParametersInfo(theNode, aValidatorId, aParameters);
   aMessage->setValidatorId(aValidatorId);
-  aMessage->setValidatorParameters(aValidatorParameters);
+  aMessage->setValidatorParameters(aParameters);
+  xmlNodePtr aFeatureOrWdgNode = theNode->parent;
+  if (isNode(aFeatureOrWdgNode, NODE_FEATURE, NULL)) {
+    aMessage->setFeatureId(getProperty(aFeatureOrWdgNode, _ID));
+  } else {
+    aMessage->setAttributeId(getProperty(aFeatureOrWdgNode, _ID));
+    aMessage->setFeatureId(myCurrentFeature);
+  }
+  aEvLoop->send(aMessage);
+}
+
+void Config_XMLReader::processSelectionFilter(xmlNodePtr theNode)
+{
+  Events_ID aFilterEvent = Events_Loop::eventByName(EVENT_SELFILTER_LOADED);
+  Events_Loop* aEvLoop = Events_Loop::loop();
+  std::shared_ptr<Config_SelectionFilterMessage> aMessage =
+      std::make_shared<Config_SelectionFilterMessage>(aFilterEvent, this);
+  std::string aSelectionFilterId;
+  std::list<std::string> aParameters;
+  getParametersInfo(theNode, aSelectionFilterId, aParameters);
+  aMessage->setSelectionFilterId(aSelectionFilterId);
+  aMessage->setFilterParameters(aParameters);
+
   xmlNodePtr aFeatureOrWdgNode = theNode->parent;
   if (isNode(aFeatureOrWdgNode, NODE_FEATURE, NULL)) {
     aMessage->setFeatureId(getProperty(aFeatureOrWdgNode, _ID));
index 9ca7ca8e59f2d81e344d2eeaaf6eb228008cdca8..119bd71c132542d662f3fb5b9f152207d4955fb1 100644 (file)
@@ -1,3 +1,5 @@
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
 /*
  * Config_XMLReader.h
  *
@@ -49,6 +51,7 @@ class Config_XMLReader
   xmlNodePtr node(void* theNode);
   std::string getNodeName(xmlNodePtr theNode);
   void processValidator(xmlNodePtr theNode);
+  void processSelectionFilter(xmlNodePtr theNode);
 
  protected:
   std::string myCurrentFeature;
index 1edcc6c10227d85502136482bddee2de5d22a448..6d0f73d9507075f949d040e48566675179804619 100644 (file)
@@ -1,3 +1,5 @@
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D\r
+\r
 #ifndef CONFIG_H\r
 #define CONFIG_H\r
 \r
index 474b0ba07def5ac985f424b14efbaefc4d0094ec..78a9549260f07c5c76f1137a35eca1211e0b2722 100644 (file)
@@ -1,3 +1,5 @@
+<!-- Copyright (C) 2014-20xx CEA/DEN, EDF R&D -->
+
 <plugins module="PartSet">
   <plugin library="PartSetPlugin" configuration="plugin-PartSet.xml"/>
   <plugin library="SketchPlugin" configuration="plugin-Sketch.xml"/>
index 53489c8fdf55cab13a5a154a46b1e42571c4dc1b..0a1847283a9633002b259e4444b6920be189c3c9 100644 (file)
@@ -1,3 +1,5 @@
+## Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
 INCLUDE(Common)
 INCLUDE(UnitTest)
 
@@ -5,16 +7,22 @@ SET(PROJECT_HEADERS
     ConstructionPlugin.h
     ConstructionPlugin_Plugin.h
     ConstructionPlugin_Point.h
+       ConstructionPlugin_Axis.h
+       ConstructionPlugin_Plane.h
 )
 
 SET(PROJECT_SOURCES
     ConstructionPlugin_Plugin.cpp
     ConstructionPlugin_Point.cpp
+       ConstructionPlugin_Axis.cpp
+       ConstructionPlugin_Plane.cpp
 )
 
 SET(XML_RESOURCES
   plugin-Construction.xml
   point_widget.xml
+  axis_widget.xml
+  plane_widget.xml
 )
 
 SET(PROJECT_LIBRARIES
index 99bbf1fda668ac917d97d5779a41e1823d25d0f1..ec32ff740e8f04a6cf1b0852461d0149674725dc 100644 (file)
@@ -1,3 +1,5 @@
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
 #ifndef CONSTRUCTIONPLUGIN_H
 #define CONSTRUCTIONPLUGIN_H
 
diff --git a/src/ConstructionPlugin/ConstructionPlugin_Axis.cpp b/src/ConstructionPlugin/ConstructionPlugin_Axis.cpp
new file mode 100644 (file)
index 0000000..7315289
--- /dev/null
@@ -0,0 +1,55 @@
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
+// File:        ConstructionPlugin_Axis.cpp
+// Created:     12 Dec 2014
+// Author:      Vitaly Smetannikov
+
+#include "ConstructionPlugin_Axis.h"
+
+#include <ModelAPI_AttributeSelection.h>
+#include <ModelAPI_ResultConstruction.h>
+
+#include <GeomAPI_Edge.h>
+#include <GeomAlgoAPI_EdgeBuilder.h>
+#include <GeomAlgoAPI_PointBuilder.h>
+
+using namespace std;
+
+static const double MINIMAL_LENGTH = 1.e-5;
+
+ConstructionPlugin_Axis::ConstructionPlugin_Axis()
+{
+}
+
+void ConstructionPlugin_Axis::initAttributes()
+{
+  data()->addAttribute(POINT_ATTR_FIRST,  ModelAPI_AttributeSelection::type());
+  data()->addAttribute(POINT_ATTR_SECOND, ModelAPI_AttributeSelection::type());
+}
+
+void ConstructionPlugin_Axis::execute()
+{
+  AttributeSelectionPtr aRef1 = data()->selection(POINT_ATTR_FIRST);
+  AttributeSelectionPtr aRef2 = data()->selection(POINT_ATTR_SECOND);
+  if ((aRef1.get() != NULL) && (aRef2.get() != NULL)) {
+    GeomShapePtr aShape1 = aRef1->value();
+    GeomShapePtr aShape2 = aRef2->value();
+    if (aShape1->isVertex() && aShape2->isVertex() && (!aShape1->isEqual(aShape2))) {
+      std::shared_ptr<GeomAPI_Pnt> aStart = GeomAlgoAPI_PointBuilder::point(aShape1);
+      std::shared_ptr<GeomAPI_Pnt> anEnd = GeomAlgoAPI_PointBuilder::point(aShape2);
+      if (aStart->distance(anEnd) > MINIMAL_LENGTH) {
+        std::shared_ptr<GeomAPI_Edge> anEdge = GeomAlgoAPI_EdgeBuilder::line(aStart, anEnd);
+
+        ResultConstructionPtr aConstr = document()->createConstruction(data());
+        aConstr->setShape(anEdge);
+        setResult(aConstr);
+      }
+    }
+  }
+}
+
+void ConstructionPlugin_Axis::customisePresentation(AISObjectPtr thePrs)
+{
+  thePrs->setColor(0, 0, 0);
+  thePrs->setLineStyle(3);
+}
\ No newline at end of file
diff --git a/src/ConstructionPlugin/ConstructionPlugin_Axis.h b/src/ConstructionPlugin/ConstructionPlugin_Axis.h
new file mode 100644 (file)
index 0000000..099d547
--- /dev/null
@@ -0,0 +1,55 @@
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
+// File:        ConstructionPlugin_Axis.h
+// Created:     12 Dec 2014
+// Author:      Vitaly Smetannikov
+
+#ifndef ConstructionPlugin_Axis_H
+#define ConstructionPlugin_Axis_H
+
+#include "ConstructionPlugin.h"
+#include <ModelAPI_Feature.h>
+#include <GeomAPI_ICustomPrs.h>
+
+
+/// Point kind
+const std::string CONSTRUCTION_AXIS_KIND("Axis");
+
+/// attribute name for first point
+const std::string POINT_ATTR_FIRST = "firstPoint";
+
+/// attribute name for second point
+const std::string POINT_ATTR_SECOND = "secondPoint";
+
+/**\class ConstructionPlugin_Axis
+ * \ingroup DataModel
+ * \brief Feature for creation of the new axis in PartSet.
+ */
+class ConstructionPlugin_Axis : public ModelAPI_Feature, public GeomAPI_ICustomPrs
+{
+ public:
+  /// Returns the kind of a feature
+  CONSTRUCTIONPLUGIN_EXPORT virtual const std::string& getKind()
+  {
+    static std::string MY_KIND = CONSTRUCTION_AXIS_KIND;
+    return MY_KIND;
+  }
+
+  /// 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();
+
+  /// Construction result is allways recomuted on the fly
+  CONSTRUCTIONPLUGIN_EXPORT virtual bool isPersistentResult() {return false;}
+
+  /// Use plugin manager for features creation
+  ConstructionPlugin_Axis();
+
+  /// Customize presentation of the feature
+  virtual void customisePresentation(AISObjectPtr thePrs);
+};
+
+
+#endif
\ No newline at end of file
diff --git a/src/ConstructionPlugin/ConstructionPlugin_Plane.cpp b/src/ConstructionPlugin/ConstructionPlugin_Plane.cpp
new file mode 100644 (file)
index 0000000..5475402
--- /dev/null
@@ -0,0 +1,78 @@
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
+// File:        ConstructionPlugin_Plane.cpp
+// Created:     12 Dec 2014
+// Author:      Vitaly Smetannikov
+
+#include "ConstructionPlugin_Plane.h"
+
+#include <ModelAPI_AttributeSelection.h>
+#include <ModelAPI_AttributeDouble.h>
+#include <ModelAPI_ResultConstruction.h>
+#include <GeomAlgoAPI_FaceBuilder.h>
+
+#include <GeomAPI_Pnt2d.h>
+
+
+#define PLANE_SIZE 300
+
+ConstructionPlugin_Plane::ConstructionPlugin_Plane()
+{
+}
+
+void ConstructionPlugin_Plane::initAttributes()
+{
+  data()->addAttribute(FACE_ATTR,  ModelAPI_AttributeSelection::type());
+  data()->addAttribute(DISTANCE_ATTR, ModelAPI_AttributeDouble::type());
+}
+
+void ConstructionPlugin_Plane::execute()
+{
+  AttributeSelectionPtr aFaceAttr = data()->selection(FACE_ATTR);
+  AttributeDoublePtr aDistAttr = data()->real(DISTANCE_ATTR);
+  if ((aFaceAttr.get() != NULL) && (aDistAttr.get() != NULL) && 
+    aFaceAttr->isInitialized() && aDistAttr->isInitialized()) {
+
+    double aDist = aDistAttr->value();
+    GeomShapePtr aShape = aFaceAttr->value();
+    if (aShape.get() != NULL) {
+      std::shared_ptr<GeomAPI_Pln> aPln = GeomAlgoAPI_FaceBuilder::plane(aShape);
+      std::shared_ptr<GeomAPI_Pnt> aOrig = aPln->location();
+      std::shared_ptr<GeomAPI_Dir> aDir = aPln->direction();
+
+      aOrig->translate(aDir, aDist);
+      std::shared_ptr<GeomAPI_Pln> aNewPln = 
+        std::shared_ptr<GeomAPI_Pln>(new GeomAPI_Pln(aOrig, aDir));
+
+      // Create rectangular face close to the selected
+      double aXmin, aYmin, Zmin, aXmax, aYmax, Zmax;
+      aShape->computeSize(aXmin, aYmin, Zmin, aXmax, aYmax, Zmax);
+
+      std::shared_ptr<GeomAPI_Pnt> aPnt1 = 
+        std::shared_ptr<GeomAPI_Pnt>(new GeomAPI_Pnt(aXmin, aYmin, Zmin));
+      std::shared_ptr<GeomAPI_Pnt> aPnt2 = 
+        std::shared_ptr<GeomAPI_Pnt>(new GeomAPI_Pnt(aXmax, aYmax, Zmax));
+
+      std::shared_ptr<GeomAPI_Pnt2d> aPnt2d1 = aPnt1->to2D(aNewPln);
+      std::shared_ptr<GeomAPI_Pnt2d> aPnt2d2 = aPnt2->to2D(aNewPln);
+
+      double aWidth = aPnt2d2->x() - aPnt2d1->x();
+      double aHeight = aPnt2d2->y() - aPnt2d1->y();
+      double aWgap = aWidth * 0.1;
+      double aHgap = aHeight * 0.1;
+
+      std::shared_ptr<GeomAPI_Shape> aPlane = 
+        GeomAlgoAPI_FaceBuilder::planarFace(aNewPln, aPnt2d1->x() - aWgap, aPnt2d1->y() - aHgap, 
+                                            aWidth + 2 * aWgap, aHeight + 2 * aHgap);
+      ResultConstructionPtr aConstr = document()->createConstruction(data());
+      aConstr->setShape(aPlane);
+      setResult(aConstr);
+    }
+  }
+}
+
+void ConstructionPlugin_Plane::customisePresentation(AISObjectPtr thePrs)
+{
+  thePrs->setColor(50, 255, 50);
+  thePrs->setTransparensy(0.6);
+}
\ No newline at end of file
diff --git a/src/ConstructionPlugin/ConstructionPlugin_Plane.h b/src/ConstructionPlugin/ConstructionPlugin_Plane.h
new file mode 100644 (file)
index 0000000..e58dd2e
--- /dev/null
@@ -0,0 +1,53 @@
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
+// File:        ConstructionPlugin_Plane.h
+// Created:     12 Dec 2014
+// Author:      Vitaly Smetannikov
+
+#ifndef ConstructionPlugin_Plane_H
+#define ConstructionPlugin_Plane_H
+
+#include "ConstructionPlugin.h"
+#include <ModelAPI_Feature.h>
+#include <GeomAPI_ICustomPrs.h>
+
+/// Point kind
+const std::string CONSTRUCTION_PLANE_KIND("Plane");
+
+/// attribute name for base face
+const std::string FACE_ATTR = "planeFace";
+
+/// attribute name for distance
+const std::string DISTANCE_ATTR = "distance";
+
+/**\class ConstructionPlugin_Axis
+ * \ingroup DataModel
+ * \brief Feature for creation of the new axis in PartSet.
+ */
+class ConstructionPlugin_Plane : public ModelAPI_Feature, public GeomAPI_ICustomPrs
+{
+ public:
+  /// Returns the kind of a feature
+  CONSTRUCTIONPLUGIN_EXPORT virtual const std::string& getKind()
+  {
+    static std::string MY_KIND = CONSTRUCTION_PLANE_KIND;
+    return MY_KIND;
+  }
+
+  /// 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();
+
+  /// Construction result is allways recomuted on the fly
+  CONSTRUCTIONPLUGIN_EXPORT virtual bool isPersistentResult() {return false;}
+
+  /// Use plugin manager for features creation
+  ConstructionPlugin_Plane();
+
+  /// Customize presentation of the feature
+  virtual void customisePresentation(AISObjectPtr thePrs);
+};
+
+#endif
\ No newline at end of file
index 2d853ebd0ce1defd27172297efc257dad371eba0..4ce70ae037c789ce3e0e7aa0cf788c3589355543 100644 (file)
@@ -1,5 +1,9 @@
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
 #include "ConstructionPlugin_Plugin.h"
 #include "ConstructionPlugin_Point.h"
+#include "ConstructionPlugin_Axis.h"
+#include "ConstructionPlugin_Plane.h"
 
 #include <ModelAPI_Session.h>
 #include <ModelAPI_Document.h>
@@ -20,6 +24,12 @@ FeaturePtr ConstructionPlugin_Plugin::createFeature(string theFeatureID)
   if (theFeatureID == CONSTRUCTION_POINT_KIND) {
     return FeaturePtr(new ConstructionPlugin_Point);
   }
+  else if (theFeatureID == CONSTRUCTION_AXIS_KIND) {
+    return FeaturePtr(new ConstructionPlugin_Axis);
+  }
+  else if (theFeatureID == CONSTRUCTION_PLANE_KIND) {
+    return FeaturePtr(new ConstructionPlugin_Plane);
+  }
   // feature of such kind is not found
   return FeaturePtr();
 }
index 79f48abe5cd6e375891d1b573ed9565d1c9c5e6d..39f2449fc5fad4e942953f8015801b66bc39d42c 100644 (file)
@@ -1,3 +1,5 @@
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
 // File:        ConstructionPlugin_Plugin.hxx
 // Created:     31 Mar 2014
 // Author:      Mikhail PONIKAROV
index f98ac1b85b449d164887efe527fc02602d739c20..9539004b7645ed5ff075cfa952fb4f46fc82753c 100644 (file)
@@ -1,3 +1,5 @@
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
 // File:        ConstructionPlugin_Point.cxx
 // Created:     27 Mar 2014
 // Author:      Mikhail PONIKAROV
index 4e62d79ae32ba190e60128af6c0012975173c48e..637b96193d5d0f205d926920c550171cccb00cc0 100644 (file)
@@ -1,3 +1,5 @@
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
 // File:        ConstructionPlugin_Point.h
 // Created:     3 Apr 2014
 // Author:      Mikhail PONIKAROV
@@ -32,13 +34,6 @@ class ConstructionPlugin_Point : public ModelAPI_Feature
     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();
 
diff --git a/src/ConstructionPlugin/axis_widget.xml b/src/ConstructionPlugin/axis_widget.xml
new file mode 100644 (file)
index 0000000..2b0659c
--- /dev/null
@@ -0,0 +1,18 @@
+<!-- Copyright (C) 2014-20xx CEA/DEN, EDF R&D -->
+
+<source>
+  <shape_selector id="firstPoint" 
+    label="First point" 
+    icon=":icons/point.png" 
+    tooltip="Select a first point for the axis"
+    shape_types="vertex"
+       use_subshapes="true"
+  />
+  <shape_selector id="secondPoint"
+    label="Second point"
+    icon=":icons/point.png"
+    tooltip="Select a second point for the axis"
+    shape_types="vertex"
+       use_subshapes="true">
+  </shape_selector>
+</source>
diff --git a/src/ConstructionPlugin/plane_widget.xml b/src/ConstructionPlugin/plane_widget.xml
new file mode 100644 (file)
index 0000000..8697dcc
--- /dev/null
@@ -0,0 +1,15 @@
+<!-- Copyright (C) 2014-20xx CEA/DEN, EDF R&D -->
+
+<source>
+  <shape_selector id="planeFace" 
+                  label="Plane face" 
+                  tooltip="Select a planar face for plane definition"
+                  shape_types="face"
+                  use_subshapes="true">
+                 <selection_filter id="FaceFilter" parameters="plane"/>
+  </shape_selector>
+  <doublevalue id="distance" 
+               label="Distance" 
+               tooltip="Distance from selected face to plane" 
+               default="0" />
+</source>
index 217afb33e3865245144c31679a79a535bf2b32cb..68a3e4e7c9f484690594266c2dfae4a519db8899 100644 (file)
@@ -1,3 +1,5 @@
+<!-- Copyright (C) 2014-20xx CEA/DEN, EDF R&D -->
+
 <plugin>
   <workbench id="Construction">
     <group id="Basic">
         id="Axis"
         title="Axis"
         tooltip="Create a new axis"
-        icon=":icons/axis.png"
-        keysequence=""
-        internal="true" />
+        icon=":icons/axis.png">
+        <source path="axis_widget.xml" />
+      </feature>
       <feature
         id="Plane"
         title="Plane"
         tooltip="Create a new plane"
-        icon=":icons/plane.png"
-        keysequence=""
-        internal="true" />
+        icon=":icons/plane.png">
+        <source path="plane_widget.xml" />
+      </feature>
     </group>
   </workbench>
-</plugin>
\ No newline at end of file
+</plugin>
index 669df071de5fed7bdec4ec930391f607ad8bb662..506f48f56ab6a0c9703d1c9940605b8e017f2d89 100644 (file)
@@ -1,3 +1,5 @@
+<!-- Copyright (C) 2014-20xx CEA/DEN, EDF R&D -->
+
 <source>
   <doublevalue id="x" label="X:" icon=":pictures/x_point.png" tooltip="Set X"/>
   <doublevalue id="y" label="Y:" icon=":pictures/y_point.png" tooltip="Set Y"/>
index 52369991ce4cf15a11cd77ccc8b05c559cc25731..492f4374a6ade95f772222d4e2dce6cc3e471c49 100644 (file)
@@ -1,3 +1,5 @@
+## Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
 INCLUDE(Common)
 
 SET(PROJECT_HEADERS
index 928056c8e78aca657e5963f528df61aae027f97d..2eed7a691d2d260b58a77b31f320d7c0cafc16f7 100644 (file)
@@ -1,3 +1,5 @@
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
 #ifndef EVENTS_H
 #define EVENTS_H
 
index 712478c894c2e049a16b264b14723304805a6652..2f606b7f91d7f02cb21dcdff83cc8ab79f1c2cc3 100644 (file)
@@ -1,3 +1,5 @@
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
 /*
  * Events_Error.cpp
  *
index f3c7f8024f84707aa9f0b7fa502414112fad3b1a..d3222a28e1ffb5566d4d1a72761c86b283ba3108 100644 (file)
@@ -1,3 +1,5 @@
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
 /*
  * Events_Error.h
  *
index 8a7720c72af788edfb5a3ca4093c69e29ab8d078..1d55bb95562afb7675792cbe9597d928d0cf6362 100644 (file)
@@ -1,3 +1,5 @@
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
 // File:       Events_Listener.cxx
 // Created:    Thu Mar 13 2014
 // Author:     Mikhail PONIKAROV
index 8d2df430ba75a28ce59fe4aeb74f2c48119bfd6c..90dedcdfd14e9b0654c12545a755a0a3228c62f3 100644 (file)
@@ -1,3 +1,5 @@
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
 // File:       Events_Listener.hxx
 // Created:    Thu Mar 13 2014
 // Author:     Mikhail PONIKAROV
index 17c373c651ff99e0f0770d6ac507e4391883141a..35558de6a5b75deba4f6e81586905b23e9ccc0c0 100644 (file)
@@ -1,3 +1,5 @@
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
 // File:        Events_LongOp.cpp
 // Created:     29 Jul 2014
 // Author:      Mikhail PONIKAROV
index 32240f7c13a23ddb0c66299281184dafc9c10125..f8e5dd8f2b2ee22794a2a618a7ad61ad0dc815ff 100644 (file)
@@ -1,3 +1,5 @@
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
 // File:        Events_LongOp.h
 // Created:     29 Jul 2014
 // Author:      Mikhail PONIKAROV
index d70b9764f1b05603e600cba3d751953e0df5afec..139e862340007e89ce5dec7723768cb401df18cd 100644 (file)
@@ -1,3 +1,5 @@
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
 // File:       Events_Loop.hxx
 // Created:    Thu Mar 13 2014
 // Author:     Mikhail PONIKAROV
@@ -115,17 +117,19 @@ void Events_Loop::flush(const Events_ID& theID)
 {
   if (!myFlushActive)
     return;
-  std::map<char*, std::shared_ptr<Events_Message>>::iterator aMyGroup =
-    myGroups.find(theID.eventText());
-  if (aMyGroup != myGroups.end()) {  // really sends
-    myFlushed.insert(theID.myID);
+  std::map<char*, std::shared_ptr<Events_Message> >::iterator aMyGroup;
+  for(aMyGroup = myGroups.find(theID.eventText());
+    aMyGroup != myGroups.end(); aMyGroup = myGroups.find(theID.eventText()))
+  {  // really sends
+    bool aWasFlushed = myFlushed.find(theID.myID) != myFlushed.end();
+    if (!aWasFlushed)
+      myFlushed.insert(theID.myID);
     std::shared_ptr<Events_Message> aGroup = aMyGroup->second;
     myGroups.erase(aMyGroup);
     send(aGroup, false);
-    std::set<char*>::iterator anIt = myFlushed.find(theID.myID);
-    if (anIt != myFlushed.end()) {
-      myFlushed.erase(anIt);
-    }
+
+    if (!aWasFlushed)
+      myFlushed.erase(myFlushed.find(theID.myID));
   }
 }
 
@@ -150,3 +154,16 @@ void Events_Loop::autoFlush(const Events_ID& theID, const bool theAuto)
   else
     myFlushed.erase(myFlushed.find(theID.myID));
 }
+
+bool Events_Loop::isFlushed(const Events_ID& theID)
+{
+  return myFlushed.find(theID.myID) != myFlushed.end();
+}
+
+void Events_Loop::setFlushed(const Events_ID& theID, const bool theValue)
+{
+  if (theValue)
+    myFlushed.insert(theID.myID);
+  else
+    myFlushed.erase(myFlushed.find(theID.myID));
+}
index c8b7798c0e06944cdc3348fdbe6e60126a662ee1..669c56febbc72e3acf676608a38acb6643112ad5 100644 (file)
@@ -1,3 +1,5 @@
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
 // File:       Events_Loop.hxx
 // Created:    Thu Mar 13 2014
 // Author:     Mikhail PONIKAROV
@@ -72,6 +74,11 @@ class Events_Loop
 
   //! Enables flush without grouping for the given message
   EVENTS_EXPORT void autoFlush(const Events_ID& theID, const bool theAuto = true);
+
+  //! Returns true if the evement is flushed right now
+  EVENTS_EXPORT bool isFlushed(const Events_ID& theID);
+  //! Sets the flag that the event is flished right now
+  EVENTS_EXPORT void setFlushed(const Events_ID& theID, const bool theValue);
 };
 
 #endif
index 6de3839123ec045d064c855759ce9de1536a4060..aad25a7d93d7655f15677737bad89c74a04ef40a 100644 (file)
@@ -1,3 +1,5 @@
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
 // File:       Events_Message.cxx
 // Created:    Thu Mar 13 2014
 // Author:     Mikhail PONIKAROV
index ef8837c93f51d929f7c85896c584a0390bac811d..40027344a7231cef442347b7cbfbb69c940f04b1 100644 (file)
@@ -1,3 +1,5 @@
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
 // File:       Events_Message.hxx
 // Created:    Thu Mar 13 2014
 // Author:     Mikhail PONIKAROV
index 799f71e69b04a086d3ac4b493537be3f2bf60727..2c9769434890a55e58bac5cc14f7d3122f61622c 100644 (file)
@@ -1,3 +1,5 @@
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
 // File:       Events_MessageGroup.cpp
 // Created:    Thu Mar 13 2014
 // Author:     Mikhail PONIKAROV
index 8f6561f0b6a287bfa6fbbe82b59b3b608776583f..146f5d3bca199d0353af601d964f68ef7b0d27c3 100644 (file)
@@ -1,3 +1,5 @@
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
 // File:       Events_MessageGroup.hxx
 // Created:    Thu Mar 13 2014
 // Author:     Mikhail PONIKAROV
index 8200a6d93799cf1ffb92664fd0ce207de1224fce..ef96dbd6cb778633c06ab3072791713882e1309f 100644 (file)
@@ -1,3 +1,5 @@
+## Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
 INCLUDE(Common)
 
 INCLUDE_DIRECTORIES(${PROJECT_SOURCE_DIR}/src/Events
index 183563e34d7e15d0df78267d713c208579a9747b..0c8f80b9577120adceb9f21eef3e24848be5f4a9 100644 (file)
@@ -1,3 +1,5 @@
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
 #ifndef EXCHANGEPLUGIN_H
 #define EXCHANGEPLUGIN_H
 
index 6493870df6ea6a6260f552f10576471c83837246..11abbb3904ae5cd475c3100ca87601e61dfb1297 100644 (file)
@@ -1,3 +1,5 @@
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
 /*
  * ExchangePlugin_ImportFeature.cpp
  *
@@ -9,7 +11,6 @@
 
 #include <GeomAPI_Shape.h>
 #include <Config_Common.h>
-#include <Events_Error.h>
 #include <ModelAPI_AttributeString.h>
 #include <ModelAPI_Data.h>
 #include <ModelAPI_Document.h>
@@ -100,12 +101,9 @@ bool ExchangePlugin_ImportFeature::importFile(const std::string& theFileName)
                             anUnknownLabel);
    // Check if shape is valid
    if ( aShape.IsNull() ) {
-     std::string aShapeError = "An error occurred while importing " + theFileName + ": ";
-     aShapeError = aShapeError + std::string(anError.ToCString());
-     Events_Error::send(aShapeError, this);
- #ifdef _DEBUG
-     std::cerr << aShapeError << std::endl;
- #endif
+     const static std::string aShapeError = 
+       "An error occurred while importing " + theFileName + ": " + anError.ToCString();
+     setError(aShapeError);
      return false;
    }
   //
@@ -154,20 +152,15 @@ LibHandle ExchangePlugin_ImportFeature::loadImportPlugin(const std::string& theF
 #else
     anImportError = anImportError + std::string(dlerror());
 #endif
-    Events_Error::send(anImportError, this);
-#ifdef _DEBUG
-    std::cerr << anImportError << std::endl;
-#endif
+    setError(anImportError);
     return false;
   }
   // Test loaded plugin for existence of valid "Import" function:
   importFunctionPointer fp = (importFunctionPointer) GetProc(anImportLib, "Import");
   if (!fp) {
-    std::string aFunctionError = "No valid \"Import\" function was found in the " + aLibName;
-    Events_Error::send(aFunctionError, this);
-#ifdef _DEBUG
-    std::cerr << aFunctionError << std::endl;
-#endif
+    const static std::string aFunctionError = 
+      "No valid \"Import\" function was found in the " + aLibName;
+    setError(aFunctionError);
     UnLoadLib(anImportLib)
     return NULL;
   }
index c4c254e0026a7cabb491588e29c9a375e4d93295..be327ecd592a9d514365dd352f6029db208c9252 100644 (file)
@@ -1,3 +1,5 @@
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
 /*
  * ExchangePlugin_ImportFeature.h
  *
index 5168e91f77c6916251f7bcd69e07d905014a68e9..6386d8a2a98b9562032cfcfb9bb60e1af6587e3b 100644 (file)
@@ -1,3 +1,5 @@
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
 /*
  *
  */
index d614028f1296f5b8ea3eca822af3fea11dbcc8a1..89531bd8a225a3dccf26d764875132f95f592a3d 100644 (file)
@@ -1,3 +1,5 @@
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
 // File:        ExchangePlugin_Plugin.hxx
 // Created:     07 July 2014
 // Author:      Vitaly SMETANNIKOV
index 2582ca76e115063bcb941e10ab4d0e586e9e69b4..e708041a8f7e034bc342fa8ddb0706b56ec85e91 100644 (file)
@@ -1,3 +1,5 @@
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
 // File:        SketchPlugin_Validators.cpp
 // Created:     01 Aug 2014
 // Author:      Vitaly SMETANNIKOV
index f390f57586309cfdf9353bd2d041688ec3956479..1e93f95accb8c8d164b6882b3bedbcbeb4e42961 100644 (file)
@@ -1,3 +1,5 @@
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
 // File:        SketchPlugin_Validators.h
 // Created:     01 Aug 2014
 // Author:      Vitaly SMETANNIKOV
index 7e1c7f1178f8e667e6037b9cf8f06c2a4ca03075..dd477f46749d5013b4aa3b278fe517a96d791600 100644 (file)
@@ -1,3 +1,5 @@
+<!-- Copyright (C) 2014-20xx CEA/DEN, EDF R&D -->
+
 <plugin>
   <workbench id="Features" document="Part">
     <group id="Exchange">
index 4b4ce8e1152d74069b12a395d11073e9dfd074b2..1d10d183c22cf2b3db37c288987293cb79649d2f 100644 (file)
@@ -1,3 +1,5 @@
+## Copyright (C) 2014-20xx CEA/DEN, EDF R&D -->
+
 INCLUDE(Common)
 INCLUDE(UnitTest)
 
@@ -5,8 +7,9 @@ SET(PROJECT_HEADERS
     FeaturesPlugin.h
     FeaturesPlugin_Plugin.h
     FeaturesPlugin_Extrusion.h
-       FeaturesPlugin_Boolean.h
-       FeaturesPlugin_Group.h
+    FeaturesPlugin_Boolean.h
+    FeaturesPlugin_Group.h
+    FeaturesPlugin_Placement.h
 )
 
 SET(PROJECT_SOURCES
@@ -14,6 +17,7 @@ SET(PROJECT_SOURCES
     FeaturesPlugin_Extrusion.cpp
     FeaturesPlugin_Boolean.cpp
     FeaturesPlugin_Group.cpp
+    FeaturesPlugin_Placement.cpp
 )
 
 SET(XML_RESOURCES
@@ -21,6 +25,7 @@ SET(XML_RESOURCES
   extrusion_widget.xml
   boolean_widget.xml
   group_widget.xml
+  placement_widget.xml
 )
 
 INCLUDE_DIRECTORIES(
@@ -45,4 +50,5 @@ INSTALL(TARGETS FeaturesPlugin DESTINATION plugins)
 INSTALL(FILES ${XML_RESOURCES} DESTINATION plugins)
 
 ADD_UNIT_TESTS(TestExtrusion.py
-               TestBoolean.py)
+               TestBoolean.py
+               TestGroup.py)
index 2e931e293066f9629434828690831b1d17b609ab..e666ab6aa365fc760a88422b6da05675729b2c5e 100644 (file)
@@ -1,3 +1,5 @@
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D -->
+
 #ifndef FEATURESPLUGIN_H
 #define FEATURESPLUGIN_H
 
index d8b8198ed1219c4ec710785d678a2f5722c0c242..e71b379baaa0dacddc7be125e259d92a9c410cb4 100644 (file)
@@ -1,3 +1,5 @@
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D -->
+
 // File:        FeaturesPlugin_Boolean.cpp
 // Created:     02 Sept 2014
 // Author:      Vitaly SMETANNIKOV
 #include <ModelAPI_AttributeInteger.h>
 #include <ModelAPI_ResultBody.h>
 #include <GeomAlgoAPI_Boolean.h>
-#include <Events_Error.h>
 using namespace std;
-#ifdef _DEBUG
-#include <iostream>
-#include <ostream>
-#endif
 
 #define FACE 4
 #define _MODIFY_TAG 1
@@ -65,29 +62,26 @@ void FeaturesPlugin_Boolean::execute()
 
   GeomAlgoAPI_Boolean* aFeature = new GeomAlgoAPI_Boolean(anObject, aTool, aType);
   if(aFeature && !aFeature->isDone()) {
-    std::string aFeatureError = "Boolean feature: algorithm failed";  
-    Events_Error::send(aFeatureError, this);
+    static const std::string aFeatureError = "Boolean feature: algorithm failed";  
+    setError(aFeatureError);
     return;
   }
    // Check if shape is valid
   if (aFeature->shape()->isNull()) {
-    std::string aShapeError = "Boolean feature: resulting shape is Null";     
-    Events_Error::send(aShapeError, this);
-#ifdef _DEBUG
-    std::cerr << aShapeError << std::endl;
-#endif
+    static const std::string aShapeError = "Boolean feature: resulting shape is Null";     
+    setError(aShapeError);
     return;
   }
   if(!aFeature->isValid()) {
-    std::string aFeatureError = "Boolean feature: resulting shape is not valid";  
-    Events_Error::send(aFeatureError, this);
+    static const std::string aFeatureError = "Boolean feature: resulting shape is not valid";  
+    setError(aFeatureError);
     return;
   }  
   // if result of Boolean operation is same as was before it means that Boolean operation has no sence
   // and naming provides no result, so, generate an error in this case
   if (anObject->isEqual(aFeature->shape())) {
-    std::string aFeatureError = "Boolean feature: operation was not performed";  
-    Events_Error::send(aFeatureError, this);
+    static const std::string aFeatureError = "Boolean feature: operation was not performed";  
+    setError(aFeatureError);
     return;
   }
   //LoadNamingDS
index e9f28ae1dd60580b4844c2a7724dd663ba48cbcd..824dcd0dbb5dd787032974c50c93f6c0b95dde69 100644 (file)
@@ -1,3 +1,5 @@
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D -->
+
 // File:        FeaturesPlugin_Boolean.h
 // Created:     02 Sept 2014
 // Author:      Vitaly SMETANNIKOV
index 55bc605c16f4c9f2ecdf67f510bf30268cd022a8..f8235f691a43aa1b48b3d69db3af4ac6716fa293 100644 (file)
@@ -1,3 +1,5 @@
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D -->
+
 // File:        FeaturesPlugin_Extrusion.cpp
 // Created:     30 May 2014
 // Author:      Vitaly SMETANNIKOV
@@ -11,7 +13,6 @@
 #include <ModelAPI_AttributeDouble.h>
 #include <ModelAPI_AttributeSelection.h>
 #include <ModelAPI_AttributeBoolean.h>
-#include <Events_Error.h>
 #include <GeomAlgoAPI_Extrusion.h>
 
 using namespace std;
@@ -19,10 +20,6 @@ using namespace std;
 #define _FIRST_TAG 2
 #define _LAST_TAG 3
 #define EDGE 6
-#ifdef _DEBUG
-#include <iostream>
-#include <ostream>
-#endif
 
 FeaturesPlugin_Extrusion::FeaturesPlugin_Extrusion()
 {
@@ -56,8 +53,8 @@ void FeaturesPlugin_Extrusion::execute()
       aContext = std::dynamic_pointer_cast<ModelAPI_ResultConstruction>(aContextRes)->shape();
   }
   if (!aContext) {
-    std::string aContextError = "The selection context is bad";
-    Events_Error::send(aContextError, this);
+    static const std::string aContextError = "The selection context is bad";
+    setError(aContextError);
     return;
   }
 
@@ -68,23 +65,20 @@ void FeaturesPlugin_Extrusion::execute()
   std::shared_ptr<ModelAPI_ResultBody> aResultBody = document()->createBody(data());
   GeomAlgoAPI_Extrusion aFeature(aFace, aSize);
   if(!aFeature.isDone()) {
-    std::string aFeatureError = "Extrusion algorithm failed";  
-    Events_Error::send(aFeatureError, this);
+    static const std::string aFeatureError = "Extrusion algorithm failed";  
+    setError(aFeatureError);
     return;
   }
 
   // Check if shape is valid
   if (aFeature.shape()->isNull()) {
-    std::string aShapeError = "Resulting shape is Null";     
-    Events_Error::send(aShapeError, this);
-#ifdef _DEBUG
-    std::cerr << aShapeError << std::endl;
-#endif
+    static const std::string aShapeError = "Resulting shape is Null";     
+    setError(aShapeError);
     return;
   }
   if(!aFeature.isValid()) {
     std::string aFeatureError = "Warning: resulting shape is not valid";  
-    Events_Error::send(aFeatureError, this);
+    setError(aFeatureError);
     return;
   }  
   //LoadNamingDS
index 1519682995b3e343058d0a1c86dc64a1d72461ee..8199fcb2e131bdb039f368f6eba5d55bab2a14a6 100644 (file)
@@ -1,3 +1,5 @@
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D -->
+
 // File:        FeaturesPlugin_Extrusion.h
 // Created:     30 May 2014
 // Author:      Vitaly SMETANNIKOV
index c5761b11e359722e64dc2757ca2ccc7528df4dc9..4708c6fc0f6250ac69e73772326676ae865043b9 100644 (file)
@@ -1,3 +1,5 @@
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D -->
+
 // File:        FeaturesPlugin_Group.cpp
 // Created:     08 Oct 2014
 // Author:      Sergey BELASH
index 7138c1241ca0a298c6199878f6e2b658a4ea5e4c..e859d5e89b562a99f87cce07d3dbe053a22143ef 100644 (file)
@@ -1,3 +1,5 @@
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D -->
+
 // File:        FeaturesPlugin_Group.h
 // Created:     08 Oct 2014
 // Author:      Sergey BELASH
@@ -45,7 +47,7 @@ class FeaturesPlugin_Group : public ModelAPI_Feature
   FEATURESPLUGIN_EXPORT virtual void initAttributes();
 
   /// Result of groups is created on the fly and don't stored to the document
-  FEATURESPLUGIN_EXPORT virtual bool isPersistentResult() {return false;}
+  FEATURESPLUGIN_EXPORT virtual bool isPersistentResult() {return true;}
 
   /// Use plugin manager for features creation
   FeaturesPlugin_Group();
diff --git a/src/FeaturesPlugin/FeaturesPlugin_Placement.cpp b/src/FeaturesPlugin/FeaturesPlugin_Placement.cpp
new file mode 100644 (file)
index 0000000..d9fe0ca
--- /dev/null
@@ -0,0 +1,133 @@
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D -->
+
+// File:        FeaturesPlugin_Placement.cpp
+// Created:     2 Dec 2014
+// Author:      Artem ZHIDKOV
+
+#include "FeaturesPlugin_Placement.h"
+
+#include <ModelAPI_ResultConstruction.h>
+#include <ModelAPI_ResultBody.h>
+#include <ModelAPI_AttributeSelection.h>
+
+#include <GeomAPI_Face.h>
+#include <GeomAPI_Pln.h>
+#include <GeomAlgoAPI_Placement.h>
+
+#define _MODIFIEDF_TAG 1
+#define _MODIFIEDE_TAG 2
+#define _MODIFIEDV_TAG 3
+#define _FACE 4
+FeaturesPlugin_Placement::FeaturesPlugin_Placement()
+{
+}
+
+void FeaturesPlugin_Placement::initAttributes()
+{
+  data()->addAttribute(FeaturesPlugin_Placement::BASE_FACE_ID(), ModelAPI_AttributeSelection::type());
+  data()->addAttribute(FeaturesPlugin_Placement::ATTRACT_FACE_ID(), ModelAPI_AttributeSelection::type());
+}
+
+void FeaturesPlugin_Placement::execute()
+{
+  // Verify the base face
+  std::shared_ptr<ModelAPI_AttributeSelection> aFaceRef = std::dynamic_pointer_cast<
+    ModelAPI_AttributeSelection>(data()->attribute(FeaturesPlugin_Placement::BASE_FACE_ID()));
+  if (!aFaceRef)
+    return;
+
+  std::shared_ptr<GeomAPI_Shape> aBaseFace = 
+    std::dynamic_pointer_cast<GeomAPI_Shape>(aFaceRef->value());
+  if (!aBaseFace)
+    return;
+
+  std::shared_ptr<GeomAPI_Shape> aBaseFaceContext;
+  ResultPtr aContextRes = aFaceRef->context();
+  if (aContextRes) {
+    if (aContextRes->groupName() == ModelAPI_ResultBody::group())
+      aBaseFaceContext = std::dynamic_pointer_cast<ModelAPI_ResultBody>(aContextRes)->shape();
+    else if (aContextRes->groupName() == ModelAPI_ResultConstruction::group())
+      aBaseFaceContext = std::dynamic_pointer_cast<ModelAPI_ResultConstruction>(aContextRes)->shape();
+  }
+  if (!aBaseFaceContext) {
+    static const std::string aContextError = "The selection context is bad";
+    setError(aContextError);
+    return;
+  }
+
+  // Verify the attractive face
+  aFaceRef = std::dynamic_pointer_cast<ModelAPI_AttributeSelection>(
+      data()->attribute(FeaturesPlugin_Placement::ATTRACT_FACE_ID()));
+
+  std::shared_ptr<GeomAPI_Shape> aSlaveObjectFace = 
+    std::dynamic_pointer_cast<GeomAPI_Shape>(aFaceRef->value());
+  if (!aSlaveObjectFace)
+    return;
+
+  std::shared_ptr<GeomAPI_Shape> aSlaveObject;
+  aContextRes = aFaceRef->context();
+  if (aContextRes) {
+    if (aContextRes->groupName() == ModelAPI_ResultBody::group())
+      aSlaveObject = std::dynamic_pointer_cast<ModelAPI_ResultBody>(aContextRes)->shape();
+    else if (aContextRes->groupName() == ModelAPI_ResultConstruction::group())
+      aSlaveObject = std::dynamic_pointer_cast<ModelAPI_ResultConstruction>(aContextRes)->shape();
+  }
+  if (!aSlaveObject) {
+    static const std::string aContextError = "The selection context is bad";
+    setError(aContextError);
+    return;
+  }
+
+  // Verify faces planarity
+  std::shared_ptr<GeomAPI_Face> aBaseFace1(new GeomAPI_Face(aBaseFace));
+  std::shared_ptr<GeomAPI_Face> aSlaveFace1(new GeomAPI_Face(aSlaveObjectFace));
+  if (!aBaseFace1->isPlanar() || !aSlaveFace1->isPlanar()) {
+    static const std::string aPlanarityError = "One of selected face is not planar";
+    setError(aPlanarityError);
+    return;
+  }
+
+  std::shared_ptr<GeomAPI_Pln> aBasePlane = aBaseFace1->getPlane();
+  std::shared_ptr<GeomAPI_Pln> aSlavePlane = aSlaveFace1->getPlane();
+
+  std::shared_ptr<ModelAPI_ResultBody> aResultBody = document()->createBody(data());
+  GeomAlgoAPI_Placement aFeature(aSlaveObject, aSlavePlane, aBasePlane);
+  if(!aFeature.isDone()) {
+    static const std::string aFeatureError = "Placement algorithm failed";
+    setError(aFeatureError);
+    return;
+  }
+
+  // Check if shape is valid
+  if (aFeature.shape()->isNull()) {
+    static const std::string aShapeError = "Resulting shape is Null";
+    setError(aShapeError);
+    return;
+  }
+  if(!aFeature.isValid()) {
+    std::string aFeatureError = "Warning: resulting shape is not valid";
+    setError(aFeatureError);
+    return;
+  }  
+  //LoadNamingDS
+  LoadNamingDS(aFeature, aResultBody, aSlaveObject);
+
+  setResult(aResultBody);
+}
+
+//============================================================================
+void FeaturesPlugin_Placement::LoadNamingDS(
+    GeomAlgoAPI_Placement& theFeature,
+    std::shared_ptr<ModelAPI_ResultBody> theResultBody,
+    std::shared_ptr<GeomAPI_Shape> theSlaveObject)
+{
+  //load result
+  theResultBody->storeModified(theSlaveObject, theFeature.shape()); // the initial Slave, the resulting Slave
+
+  GeomAPI_DataMapOfShapeShape* aSubShapes = new GeomAPI_DataMapOfShapeShape();
+  theFeature.mapOfShapes(*aSubShapes);
+
+    // put modifed faces in DF
+  theResultBody->loadAndOrientModifiedShapes(theFeature.makeShape(), theSlaveObject, _FACE, _MODIFIEDF_TAG, *aSubShapes); 
+
+}
diff --git a/src/FeaturesPlugin/FeaturesPlugin_Placement.h b/src/FeaturesPlugin/FeaturesPlugin_Placement.h
new file mode 100644 (file)
index 0000000..3cfd358
--- /dev/null
@@ -0,0 +1,61 @@
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D -->
+
+// File:        FeaturesPlugin_Placement.h
+// Created:     2 Dec 2014
+// Author:      Artem ZHIDKOV
+
+#ifndef FeaturesPlugin_Placement_H_
+#define FeaturesPlugin_Placement_H_
+
+#include "FeaturesPlugin.h"
+#include <ModelAPI_Feature.h>
+#include <GeomAlgoAPI_Placement.h>
+
+class ModelAPI_ResultBody;
+class GeomAPI_Shape;
+
+class FeaturesPlugin_Placement : public ModelAPI_Feature
+{
+ public:
+  /// Placement kind
+  inline static const std::string& ID()
+  {
+    static const std::string MY_PLACEMENT_ID("Placement");
+    return MY_PLACEMENT_ID;
+  }
+  /// attribute name of referenced face
+  inline static const std::string& BASE_FACE_ID()
+  {
+    static const std::string MY_BASE_FACE_ID("placement_base_face");
+    return MY_BASE_FACE_ID;
+  }
+  /// attribute name of attractable face
+  inline static const std::string& ATTRACT_FACE_ID()
+  {
+    static const std::string MY_ATTRACT_FACE_ID("placement_attractable_face");
+    return MY_ATTRACT_FACE_ID;
+  }
+
+  /// Returns the kind of a feature
+  FEATURESPLUGIN_EXPORT virtual const std::string& getKind()
+  {
+    static std::string MY_KIND = FeaturesPlugin_Placement::ID();
+    return MY_KIND;
+  }
+
+  /// 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_Placement();
+private:
+  /// Load Naming data structure of the feature to the document
+  void LoadNamingDS(GeomAlgoAPI_Placement& theFeature,
+                    std::shared_ptr<ModelAPI_ResultBody> theResultBody,
+                    std::shared_ptr<GeomAPI_Shape> theSlaveObject);
+};
+
+#endif
index 681479032f7c5359fec4cbd5bc425d4e9e59bb36..7dd5081f47508f8292823cdbe610a001b27d7694 100644 (file)
@@ -1,8 +1,11 @@
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D -->
+
 #include <FeaturesPlugin_Plugin.h>
 
 #include <FeaturesPlugin_Boolean.h>
 #include <FeaturesPlugin_Extrusion.h>
 #include <FeaturesPlugin_Group.h>
+#include <FeaturesPlugin_Placement.h>
 
 #include <ModelAPI_Session.h>
 
@@ -29,6 +32,8 @@ FeaturePtr FeaturesPlugin_Plugin::createFeature(string theFeatureID)
     return FeaturePtr(new FeaturesPlugin_Boolean);
   } else if (theFeatureID == FeaturesPlugin_Group::ID()) {
     return FeaturePtr(new FeaturesPlugin_Group);
+  } else if (theFeatureID == FeaturesPlugin_Placement::ID()) {
+    return FeaturePtr(new FeaturesPlugin_Placement);
   }
   // feature of such kind is not found
   return FeaturePtr();
index e56ac83ea77c79afc93639bfa4a2af8c994c871b..651de9badeffa4e5ee1b4fc61f873d9b7fa248f1 100644 (file)
@@ -1,3 +1,5 @@
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D -->
+
 // File:        FeaturesPlugin_Plugin.hxx
 // Created:     07 July 2014
 // Author:      Vitaly SMETANNIKOV
index 63f1891723a7f695fa749e31afe31ca01ec004bf..94aa22e8e5158a83d93ef1484d27b742dd054908 100644 (file)
@@ -18,8 +18,9 @@
 from ModelAPI import *
 from GeomDataAPI import *
 from GeomAlgoAPI import *
+from GeomAPI import *
 
-__updated__ = "2014-11-21"
+__updated__ = "2014-12-16"
 
 aSession = ModelAPI_Session.get()
 # Create a part for extrusions & boolean
index 1f60c4ed941e8c5381ec1fb0aa6261761e56a899..2d6cc6a5e8f76db48900825116c0bae6bce69605 100644 (file)
@@ -18,8 +18,9 @@
 from ModelAPI import *
 from GeomDataAPI import *
 from GeomAlgoAPI import *
+from GeomAPI import *
 
-__updated__ = "2014-11-21"
+__updated__ = "2014-12-16"
 
 aSession = ModelAPI_Session.get()
 aDocument = aSession.moduleDocument()
diff --git a/src/FeaturesPlugin/Test/TestGroup.py b/src/FeaturesPlugin/Test/TestGroup.py
new file mode 100644 (file)
index 0000000..62b98d4
--- /dev/null
@@ -0,0 +1,101 @@
+"""
+      TestBoolean.py
+      Unit test of FeaturesPlugin_Group class
+      
+      class FeaturesPlugin_Group
+        static const std::string MY_GROUP_ID("Group");
+        static const std::string MY_GROUP_LIST_ID("group_list");
+        
+        data()->addAttribute(FeaturesPlugin_Group::LIST_ID(), ModelAPI_AttributeSelectionList::type());
+"""
+#=========================================================================
+# Initialization of the test
+#=========================================================================
+from ModelAPI import *
+from GeomDataAPI import *
+from GeomAlgoAPI import *
+from GeomAPI import *
+
+__updated__ = "2014-12-16"
+
+aSession = ModelAPI_Session.get()
+# Create a part for extrusions & boolean
+aSession.startOperation()
+aPartFeature = aSession.moduleDocument().addFeature("Part")
+aPart = aSession.activeDocument()
+aSession.finishOperation()
+#=========================================================================
+# Create a sketch with triangle and extrude it
+#=========================================================================
+aSession.startOperation()
+aTriangleSketchFeature = modelAPI_CompositeFeature(aPart.addFeature("Sketch"))
+origin = geomDataAPI_Point(aTriangleSketchFeature.attribute("Origin"))
+origin.setValue(0, 0, 0)
+dirx = geomDataAPI_Dir(aTriangleSketchFeature.attribute("DirX"))
+dirx.setValue(1, 0, 0)
+diry = geomDataAPI_Dir(aTriangleSketchFeature.attribute("DirY"))
+diry.setValue(0, 1, 0)
+norm = geomDataAPI_Dir(aTriangleSketchFeature.attribute("Norm"))
+norm.setValue(0, 0, 1)
+aSketchLineA = aTriangleSketchFeature.addFeature("SketchLine")
+aSketchLineB = aTriangleSketchFeature.addFeature("SketchLine")
+aSketchLineC = aTriangleSketchFeature.addFeature("SketchLine")
+aLineAStartPoint = geomDataAPI_Point2D(aSketchLineA.attribute("StartPoint"))
+aLineAEndPoint = geomDataAPI_Point2D(aSketchLineA.attribute("EndPoint"))
+aLineBStartPoint = geomDataAPI_Point2D(aSketchLineB.attribute("StartPoint"))
+aLineBEndPoint = geomDataAPI_Point2D(aSketchLineB.attribute("EndPoint"))
+aLineCStartPoint = geomDataAPI_Point2D(aSketchLineC.attribute("StartPoint"))
+aLineCEndPoint = geomDataAPI_Point2D(aSketchLineC.attribute("EndPoint"))
+aLineAStartPoint.setValue(25., 25.)
+aLineAEndPoint.setValue(100., 25.)
+aLineBStartPoint.setValue(100., 25.)
+aLineBEndPoint.setValue(60., 75.)
+aLineCStartPoint.setValue(60., 75.)
+aLineCEndPoint.setValue(25., 25.)
+aSession.finishOperation()
+# Build sketch faces
+aSession.startOperation()
+aSketchResult = aTriangleSketchFeature.firstResult()
+aSketchEdges = modelAPI_ResultConstruction(aSketchResult).shape()
+origin = geomDataAPI_Point(aTriangleSketchFeature.attribute("Origin")).pnt()
+dirX = geomDataAPI_Dir(aTriangleSketchFeature.attribute("DirX")).dir()
+dirY = geomDataAPI_Dir(aTriangleSketchFeature.attribute("DirY")).dir()
+norm = geomDataAPI_Dir(aTriangleSketchFeature.attribute("Norm")).dir()
+aSketchFaces = ShapeList()
+GeomAlgoAPI_SketchBuilder.createFaces(
+    origin, dirX, dirY, norm, aSketchEdges, aSketchFaces)
+# Create extrusion on them
+anExtrusionFt = aPart.addFeature("Extrusion")
+anExtrusionFt.selection("extrusion_face").setValue(
+    aSketchResult, aSketchFaces[0])
+anExtrusionFt.real("extrusion_size").setValue(50)
+anExtrusionFt.boolean("extrusion_reverse").setValue(False)
+anExtrusionFt.execute()
+aSession.finishOperation()
+anExtrusionBody = modelAPI_ResultBody(anExtrusionFt.firstResult())
+#=========================================================================
+# Create group of edges
+# TODO: After implementation of selection from batch script
+# update this test to have proper reslts in the group feature
+#=========================================================================
+aSession.startOperation()
+aGroupFeature = aSession.activeDocument().addFeature("Group")
+aSelectionListAttr = aGroupFeature.selectionList("group_list")
+aSelectionListAttr.clear()
+topAbs_EdgeType = 6
+aSelectionListAttr.setSelectionType(topAbs_EdgeType)
+
+for anEdge in [aSketchLineA, aSketchLineB, aSketchLineC]:
+    anEdgeResult = anEdge.firstResult()
+    assert(anEdgeResult)
+    assert(anEdgeResult.shape())
+    aSelectionListAttr.append(anEdgeResult, anEdgeResult.shape())
+aSession.finishOperation()
+#=========================================================================
+# Check results
+#=========================================================================
+aGroupResult = aGroupFeature.firstResult()
+# assert(aGroupResult)
+#=========================================================================
+# End of test
+#=========================================================================
index af4822c2c848784f950bbf54d3726034ccd4ccda..4b1cf3c72b9991b927ed261c0eaa9e4d56fb3b31 100644 (file)
@@ -1,3 +1,5 @@
+<!-- Copyright (C) 2014-20xx CEA/DEN, EDF R&D -->
+
 <source>
   <shape_selector id="main_object" 
     label="Main object" 
@@ -11,8 +13,9 @@
     icon=":icons/cut_tool.png" 
     tooltip="Select a tool"
     shape_types="solid"
-    concealment="true"
-  />
+    concealment="true" >
+       <validator id="PartSet_DifferentObjects"/>
+  </shape_selector>
   <choice id="bool_type" 
     label="Type" 
     tooltip="Type of boolean operation"
index da2d99d2dbed4c7f7856c7db807b3d1bb7515bbb..52808c76ec2770d0af893a922786fd2f2a0fd9d6 100644 (file)
@@ -1,3 +1,5 @@
+<!-- Copyright (C) 2014-20xx CEA/DEN, EDF R&D -->
+
 <source>
   <shape_selector id="extrusion_face" 
     label="Select a face" 
index d4288b638b250c23bb6e971c411cd1aec1112c02..0a5409354245858f9bfc8ac9fef2330c31dbbdb7 100644 (file)
@@ -1,3 +1,5 @@
+<!-- Copyright (C) 2014-20xx CEA/DEN, EDF R&D -->
+
 <source>
   <multi_selector id="group_list" 
     tooltip="List of selected objects" 
diff --git a/src/FeaturesPlugin/placement_widget.xml b/src/FeaturesPlugin/placement_widget.xml
new file mode 100644 (file)
index 0000000..a43e156
--- /dev/null
@@ -0,0 +1,20 @@
+<!-- Copyright (C) 2014-20xx CEA/DEN, EDF R&D -->
+
+<source>
+  <shape_selector id="placement_base_face" 
+    label="Select a face" 
+    icon=":icons/cut_shape.png" 
+    tooltip="Select a face a one object"
+    shape_types="face"
+    use_subshapes="true"
+  />
+  <shape_selector id="placement_attractable_face" 
+               label="Select a face" 
+               icon=":icons/cut_shape.png" 
+               tooltip="Select a face of another object" 
+               shape_types="face" 
+               use_subshapes="true"    
+               concealment="true" >
+       <validator id="PartSet_DifferentObjects"/>
+  </shape_selector>
+</source>
index 749941fcab783ebcd4276b2d6a8bbaf92716d729..7257ac2cf98e4a525adda8a50629d035f6cf53fe 100644 (file)
@@ -1,3 +1,5 @@
+<!-- Copyright (C) 2014-20xx CEA/DEN, EDF R&D -->
+
 <plugin>
   <workbench id="Features" document="Part">
     <group id="Basic">
@@ -7,6 +9,9 @@
       <feature id="Boolean" title="Boolean" tooltip="Perform boolean operations with shapes" icon=":icons/cut.png">
           <source path="boolean_widget.xml"/>
       </feature>
+      <feature id="Placement" title="Placement" tooltip="Perform moving an object to specified position" icon=":icons/placement.png">
+          <source path="placement_widget.xml"/>
+      </feature>
     </group>
     <group id="Collections">
       <feature id="Group"
index 9ee8694c8cac79d3c34eeac641b6c7a16f4d98c2..0de88e1edf91ef91631f56abee2b149da1e21ac6 100644 (file)
@@ -1,3 +1,5 @@
+## Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
 FIND_PACKAGE(SWIG REQUIRED)
 
 INCLUDE(${SWIG_USE_FILE})
@@ -19,11 +21,14 @@ SET(PROJECT_HEADERS
     GeomAPI_Pln.h
     GeomAPI_Shape.h
     GeomAPI_Edge.h
+    GeomAPI_Face.h
     GeomAPI_PlanarEdges.h
     GeomAPI_AISObject.h
     GeomAPI_IPresentable.h
     GeomAPI_Curve.h 
     GeomAPI_DataMapOfShapeShape.h
+    GeomAPI_ICustomPrs.h
+    GeomAPI_Vertex.h
 )
 
 SET(PROJECT_SOURCES
@@ -41,10 +46,12 @@ SET(PROJECT_SOURCES
     GeomAPI_Pln.cpp
     GeomAPI_Shape.cpp
     GeomAPI_Edge.cpp
+    GeomAPI_Face.cpp
     GeomAPI_PlanarEdges.cpp
     GeomAPI_AISObject.cpp
     GeomAPI_Curve.cpp
     GeomAPI_DataMapOfShapeShape.cpp
+    GeomAPI_Vertex.cpp
 )
 
 SET(PROJECT_LIBRARIES
index f27fc481ad8f7f67c142ca28681e1d16de44457d..fa6e4ceb17529b8b6632529519c7670a81620a5b 100644 (file)
@@ -1,3 +1,5 @@
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
 #ifndef GEOMAPI_H
 #define GEOMAPI_H
 
index 46e67f998650942a785d65f08ba3522a737d3f76..a2b39e45217fcb1ae3427531db1eb20ffab599a0 100644 (file)
@@ -1,3 +1,5 @@
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
 // File:        GeomAPI_AISObject.cpp
 // Created:     25 Jun 2014
 // Author:      Artem ZHIDKOV
 #include <BRepBndLib.hxx>
 
 #include <AIS_InteractiveObject.hxx>
+#include <AIS_InteractiveContext.hxx>
 #include <AIS_LengthDimension.hxx>
 #include <AIS_ParallelRelation.hxx>
 #include <AIS_PerpendicularRelation.hxx>
 #include <AIS_RadiusDimension.hxx>
 #include <AIS_Shape.hxx>
 #include <AIS_FixRelation.hxx>
+#include <Prs3d_PointAspect.hxx>
 
 const double tolerance = 1e-7;
 
@@ -294,3 +298,55 @@ bool GeomAPI_AISObject::empty() const
   return false;
 }
 
+int GeomAPI_AISObject::getShapeType() const
+{
+  Handle(AIS_InteractiveObject) anAIS = const_cast<GeomAPI_AISObject*>(this)
+      ->impl<Handle(AIS_InteractiveObject)>();
+  if (!anAIS.IsNull()) {
+    Handle(AIS_Shape) aAISShape = Handle(AIS_Shape)::DownCast(anAIS);
+    if (!aAISShape.IsNull()) {
+      return aAISShape->Shape().ShapeType();
+    }
+  }
+  return -1;
+}
+
+void GeomAPI_AISObject::setPointMarker(int theType, double theScale)
+{
+  Handle(AIS_InteractiveObject) anAIS = impl<Handle(AIS_InteractiveObject)>();
+  if (!anAIS.IsNull()) {
+    Handle(AIS_Drawer) aDrawer = anAIS->Attributes();
+    if (aDrawer->HasPointAspect()) {
+      Handle(Prs3d_PointAspect) aPA = aDrawer->PointAspect();
+      aPA->SetTypeOfMarker((Aspect_TypeOfMarker)theType);
+      aPA->SetScale(theScale);
+    } else {
+      Quantity_NameOfColor aCol = Quantity_NOC_YELLOW;
+      aDrawer->SetPointAspect(new Prs3d_PointAspect((Aspect_TypeOfMarker)theType, aCol, theScale));
+    }
+  }
+}
+
+
+void GeomAPI_AISObject::setLineStyle(int theStyle)
+{
+  Handle(AIS_InteractiveObject) anAIS = impl<Handle(AIS_InteractiveObject)>();
+  if (!anAIS.IsNull()) {
+    Handle(AIS_Drawer) aDrawer = anAIS->Attributes();
+    if (aDrawer->HasLineAspect())
+      aDrawer->LineAspect()->SetTypeOfLine((Aspect_TypeOfLine)theStyle);
+    if (aDrawer->HasWireAspect())
+      aDrawer->WireAspect()->SetTypeOfLine((Aspect_TypeOfLine)theStyle);
+  }
+}
+
+
+void GeomAPI_AISObject::setTransparensy(double theVal)
+{
+  Handle(AIS_InteractiveObject) anAIS = impl<Handle(AIS_InteractiveObject)>();
+  if (!anAIS.IsNull()) {
+    Handle(AIS_InteractiveContext) aContext = anAIS->GetContext();
+    if (!aContext.IsNull())
+      aContext->SetTransparency(anAIS, theVal, false);
+  }
+}
index 03785b4ec08ce7aea5d1b1cacb75144f0f9f5731..a76016bd6d738989f04238cb02037f5b291f17bb 100644 (file)
@@ -1,3 +1,5 @@
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
 // File:        GeomAPI_AISObject.hxx
 // Created:     25 Jun 2014
 // Author:      Artem ZHIDKOV
@@ -93,6 +95,21 @@ class GEOMAPI_EXPORT GeomAPI_AISObject : public GeomAPI_Interface
 
   /// \brief Checks if the object is empty
   bool empty() const;
+
+  /// Return shape type according to TopAbs_ShapeEnum if the AIS is AIS_Shape
+  /// Otherwise returns -1
+  int getShapeType() const;
+
+  /// Sets marker type for vertex.
+  /// The type has to be defined according to Acpect_TypeOfMarker
+  void setPointMarker(int theType, double theScale);
+
+  /// Set line type of edges
+  /// Has to be defined according to Aspect_TypeOfLine
+  void setLineStyle(int theStyle);
+
+  /// Set transparency of the presentation (theVal = 0 ... 1)
+  void setTransparensy(double theVal);
 };
 
 //! Pointer on attribute object
index e2b46853b956a189e76321897a07231733351736..807390364369856c4603231a1c8cb01d0d3690c3 100644 (file)
@@ -1,3 +1,5 @@
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
 // File:        GeomAPI_Circ2cpp
 // Created:     24 Jun 2014
 // Author:      Artem ZHIDKOV
index 8036faf5600cd408b1c555b017142fc315456ecd..2532ef2edd3bc7c95f5cd99a72821757fec285b1 100644 (file)
@@ -1,3 +1,5 @@
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
 // File:        GeomAPI_Circ.h
 // Created:     24 Jun 2014
 // Author:      Artem ZHIDKOV
index 0a7a9a01bd77c3848d9582b0e2e06f502e2af92e..9871e60fb0387d510778839af5823d79d59a9234 100644 (file)
@@ -1,3 +1,5 @@
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
 // File:        GeomAPI_Circ2d.cpp
 // Created:     29 May 2014
 // Author:      Artem ZHIDKOV
index 6a2627baf59465085ce25ed7bdfa95d99734053b..9761c882900d10b1a3b2f576c529571d5008ae65 100644 (file)
@@ -1,3 +1,5 @@
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
 // File:        GeomAPI_Circ2d.h
 // Created:     29 May 2014
 // Author:      Artem ZHIDKOV
index d6a7280c644b74eaf3aac23f0303925558300cfb..9b4f4e26d8e8869945df7aa7a5b24ef34bb93ff5 100644 (file)
@@ -1,3 +1,5 @@
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
 // File:        GeomAPI_Curve.cpp
 // Created:     04 Sep 2014
 // Author:      Mikhail PONIKAROV
index f09f1d375e22af89b48a0d4c43dfda11b9002126..f09654a8c941328b2f0554a6ccf9035589ec09d4 100644 (file)
@@ -1,3 +1,5 @@
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
 // File:        GeomAPI_Curve.hxx
 // Created:     04 Sep 2014
 // Author:      Mikhail PONIKAROV
index c20e9fd89161620b560adca7347eb54eecfa5259..c42ef1562edac8a5ea29487a597c983ba77c68ba 100644 (file)
@@ -1,3 +1,5 @@
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
 // File:        GeomAPI_DataMapOfShapeShape.cpp
 // Created:     28 Oct 2014
 // Author:      Sergey Zaritchny
@@ -18,6 +20,12 @@ void GeomAPI_DataMapOfShapeShape::clear()
   implPtr<TopTools_DataMapOfShapeShape>()->Clear();
 }
 
+/// Size 
+int GeomAPI_DataMapOfShapeShape::size()
+{
+  return implPtr<TopTools_DataMapOfShapeShape>()->Extent();
+}
+
 /// Adds the Key <K> to  the Map <me>  with  the  Item. Returns True  if the Key  was not already in the map
 bool GeomAPI_DataMapOfShapeShape::bind (std::shared_ptr<GeomAPI_Shape> theKey, std::shared_ptr<GeomAPI_Shape> theItem)
 {
index 94a35b780ea9c087acf1ac4b39a07d3da7681a84..40c447baed4d31ff5d5c083391ca584a90b4d50e 100644 (file)
@@ -1,3 +1,5 @@
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
 // File:        GeomAPI_DataMapOfShapeShape.h
 // Created:     28 Oct 2014
 // Author:      Sergey Zaritchny
@@ -25,6 +27,9 @@ class GEOMAPI_EXPORT GeomAPI_DataMapOfShapeShape : public GeomAPI_Interface
   /// Clear 
   void clear();
 
+  /// Size of the map
+  int size();
+
   /// Adds the Key <K> to  the Map <me>  with  the  Item. Returns True  if the Key  was not already in the map
   bool bind (std::shared_ptr<GeomAPI_Shape> theKey, std::shared_ptr<GeomAPI_Shape> theItem);
 
index c81efd26e98b61f382454d744fe0171bf63d5e1d..858d8f877bca48b78b968e536a4eaa214a746e48 100644 (file)
@@ -1,3 +1,5 @@
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
 // File:        GeomAPI_Dir.cpp
 // Created:     23 Apr 2014
 // Author:      Mikhail PONIKAROV
index 12f3b0b3fbb45c16900009dab8e5ca15be119533..c713019f92267f6d7a9f46fce67fa605b98b5e1d 100644 (file)
@@ -1,3 +1,5 @@
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
 // File:        GeomAPI_Dir.hxx
 // Created:     23 Apr 2014
 // Author:      Mikhail PONIKAROV
index b7dcfc96089ac2301a5ab745bd226d81534c0c43..e9131f992d6b2782d32d73d895eabcd6b83ab92e 100644 (file)
@@ -1,3 +1,5 @@
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
 // File:        GeomAPI_Dir2d.cpp
 // Created:     23 Apr 2014
 // Author:      Mikhail PONIKAROV
index 3453f1247cefd065c1d13f876f53cc0e8b8d5aa3..ec558769392d7b1f91a370edaa9ea172a8526d1d 100644 (file)
@@ -1,3 +1,5 @@
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
 // File:        GeomAPI_Dir2d.hxx
 // Created:     23 Apr 2014
 // Author:      Mikhail PONIKAROV
index 5e455f9f3dd3f3bd426fa0f85999859c4bac463f..d2d0248f29a880bccb33505b4145ed5cabc1c25d 100644 (file)
@@ -1,3 +1,5 @@
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
 // File:        GeomAPI_Edge.cpp
 // Created:     24 Jul 2014
 // Author:      Artem ZHIDKOV
@@ -129,4 +131,4 @@ bool GeomAPI_Edge::isEqual(std::shared_ptr<GeomAPI_Shape> theEdge)
     return false;
 
   return true;
-}
\ No newline at end of file
+}
index 1ecf750786be277173b77f93477964ba441a80dd..53552262983695efa0144176558bc02e86ceb647 100644 (file)
@@ -1,3 +1,5 @@
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
 // File:        GeomAPI_Edge.hxx
 // Created:     24 Jul 2014
 // Author:      Artem ZHIDKOV
diff --git a/src/GeomAPI/GeomAPI_Face.cpp b/src/GeomAPI/GeomAPI_Face.cpp
new file mode 100644 (file)
index 0000000..2055bdc
--- /dev/null
@@ -0,0 +1,101 @@
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
+// File:        GeomAPI_Face.cpp
+// Created:     2 Dec 2014
+// Author:      Artem ZHIDKOV
+
+#include <GeomAPI_Face.h>
+#include <GeomAPI_Dir.h>
+#include <GeomAPI_Pln.h>
+#include <GeomAPI_Pnt.h>
+
+#include <TopoDS_Shape.hxx>
+#include <TopoDS_Face.hxx>
+#include <TopoDS.hxx>
+#include <BRep_Tool.hxx>
+#include <BRepAdaptor_Surface.hxx>
+#include <Geom_Surface.hxx>
+#include <Geom_Plane.hxx>
+
+GeomAPI_Face::GeomAPI_Face()
+  : GeomAPI_Shape()
+{
+}
+
+GeomAPI_Face::GeomAPI_Face(const std::shared_ptr<GeomAPI_Shape>& theShape)
+{
+  if (!theShape->isNull() && theShape->isFace()) {
+    setImpl(new TopoDS_Shape(theShape->impl<TopoDS_Shape>()));
+  }
+}
+
+bool GeomAPI_Face::isEqual(std::shared_ptr<GeomAPI_Shape> theFace) const
+{
+  if (!theFace->isFace())
+    return false;
+
+  const TopoDS_Shape& aMyShape = const_cast<GeomAPI_Face*>(this)->impl<TopoDS_Shape>();
+  const TopoDS_Shape& aInShape = theFace->impl<TopoDS_Shape>();
+
+  Handle(Geom_Surface) aMySurf = BRep_Tool::Surface(TopoDS::Face(aMyShape));
+  Handle(Geom_Surface) aInSurf = BRep_Tool::Surface(TopoDS::Face(aInShape));
+
+  // Check that surfaces a the same type
+  if (aMySurf->DynamicType() != aInSurf->DynamicType())
+    return false;
+
+  // Get parameters of surfaces
+  double aMyUMin, aMyUMax, aMyVMin, aMyVMax;
+  aMySurf->Bounds(aMyUMin, aMyUMax, aMyVMin, aMyVMax);
+  double aInUMin, aInUMax, aInVMin, aInVMax;
+  aInSurf->Bounds(aInUMin, aInUMax, aInVMin, aInVMax);
+
+  // Check that parameters are the same
+  if (fabs(aMyUMin - aInUMin) > Precision::PConfusion() ||
+      fabs(aMyUMax - aInUMax) > Precision::PConfusion() ||
+      fabs(aMyVMin - aInVMin) > Precision::PConfusion() ||
+      fabs(aMyVMax - aInVMax) > Precision::PConfusion())
+    return false;
+
+  return true;
+}
+
+bool GeomAPI_Face::isPlanar() const
+{
+  const TopoDS_Shape& aShape = const_cast<GeomAPI_Face*>(this)->impl<TopoDS_Shape>();
+  Handle(Geom_Surface) aSurf = BRep_Tool::Surface(TopoDS::Face(aShape));
+  if (aSurf->IsKind(STANDARD_TYPE(Geom_Plane)))
+    return true;
+  return false;
+}
+
+std::shared_ptr<GeomAPI_Pln> GeomAPI_Face::getPlane() const
+{
+  const TopoDS_Shape& aShape = const_cast<GeomAPI_Face*>(this)->impl<TopoDS_Shape>();
+  BRepAdaptor_Surface aSurfAdapt(TopoDS::Face(aShape));
+
+  if (aSurfAdapt.GetType() != GeomAbs_Plane)
+    return std::shared_ptr<GeomAPI_Pln>();
+
+  // Obtain central point
+  double aUMin, aUMax, aVMin, aVMax;
+  aUMin = aSurfAdapt.FirstUParameter();
+  aUMax = aSurfAdapt.LastUParameter();
+  aVMin = aSurfAdapt.FirstVParameter();
+  aVMax = aSurfAdapt.LastVParameter();
+  gp_Pnt aCentralPnt;
+  gp_Vec aDU, aDV;
+  aSurfAdapt.D1((aUMin+aUMax)*0.5, (aVMin+aVMax)*0.5, aCentralPnt, aDU, aDV);
+  std::shared_ptr<GeomAPI_Pnt> aCenter(
+      new GeomAPI_Pnt(aCentralPnt.X(), aCentralPnt.Y(), aCentralPnt.Z()));
+
+  // Obtain plane direction
+  gp_XYZ aNormalVec = aDU.XYZ().Crossed(aDV.XYZ());
+  if (aNormalVec.SquareModulus() < Precision::Confusion() * Precision::Confusion())
+    return std::shared_ptr<GeomAPI_Pln>();
+  std::shared_ptr<GeomAPI_Dir> aNormal(
+      new GeomAPI_Dir(aNormalVec.X(), aNormalVec.Y(), aNormalVec.Z()));
+
+  std::shared_ptr<GeomAPI_Pln> aResult(new GeomAPI_Pln(aCenter, aNormal));
+  return aResult;
+}
diff --git a/src/GeomAPI/GeomAPI_Face.h b/src/GeomAPI/GeomAPI_Face.h
new file mode 100644 (file)
index 0000000..96d637f
--- /dev/null
@@ -0,0 +1,38 @@
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
+// File:        GeomAPI_Face.h
+// Created:     2 Dec 2014
+// Author:      Artem ZHIDKOV
+
+#ifndef GeomAPI_Face_H_
+#define GeomAPI_Face_H_
+
+#include <GeomAPI_Shape.h>
+
+class GeomAPI_Pln;
+
+/**\class GeomAPI_Face
+* \ingroup DataModel
+ * \brief Interface to the face object
+ */
+class GEOMAPI_EXPORT GeomAPI_Face : public GeomAPI_Shape
+{
+public:
+  /// Creation of empty (null) shape
+  GeomAPI_Face();
+
+  /// Creation of face by the face-shape
+  GeomAPI_Face(const std::shared_ptr<GeomAPI_Shape>& theShape);
+
+  /// Returns true if the current face is geometrically equal to the given face
+  virtual bool isEqual(const std::shared_ptr<GeomAPI_Shape> theFace) const;
+
+  /// Returns true if the face is a planar face
+  bool isPlanar() const;
+
+  /// Returns the base plane of the face (if it is planar) with location in the center of the face
+  std::shared_ptr<GeomAPI_Pln> getPlane() const;
+};
+
+#endif
+
diff --git a/src/GeomAPI/GeomAPI_ICustomPrs.h b/src/GeomAPI/GeomAPI_ICustomPrs.h
new file mode 100644 (file)
index 0000000..c398a33
--- /dev/null
@@ -0,0 +1,24 @@
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
+// File:        GeomAPI_ICustomPrs.hxx
+// Created:     11 Dec 2014
+// Author:      Vitaly SMETANNIKOV
+
+#ifndef GeomAPI_ICustomPrs_H
+#define GeomAPI_ICustomPrs_H
+
+#include "GeomAPI_AISObject.h"
+
+/**
+* Interface of a class which can provide specific customization of
+* object presentation
+*/ 
+class GeomAPI_ICustomPrs
+{
+public:
+  virtual void customisePresentation(AISObjectPtr thePrs) = 0;
+};
+
+typedef std::shared_ptr<GeomAPI_ICustomPrs> GeomCustomPrsPtr;
+
+#endif
\ No newline at end of file
index 8f9a6d8d34d994cc6a3e6911f9100d109f0837b6..94021ab80f87495362f3754d51781eb459a9400b 100644 (file)
@@ -1,3 +1,5 @@
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
 // File:        GeomAPI_IPresentable.hxx
 // Created:     17 July 2014
 // Author:      Vitaly SMETANNIKOV
index a583aa564cb499f9022c84ad94de9169f3d5da48..1ee1a621303a50828488368e10cd906e1d25b67a 100644 (file)
@@ -1,3 +1,5 @@
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
 // File:        GeomAPI_Interface.cpp
 // Created:     23 Apr 2014
 // Author:      Mikhail PONIKAROV
index 3dca3485462d9ef988da49d0b28945e7f450f567..0e79a10f6c124f27db5cac305f21e49a3b8f6dbb 100644 (file)
@@ -1,3 +1,5 @@
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
 // File:        GeomAPI_Interface.hxx
 // Created:     23 Apr 2014
 // Author:      Mikhail PONIKAROV
index 770d7175f0230fc7ea6e8576836db182bb212749..27bd3e0e297fdee97d63db8ed18e4d9ed2661d41 100644 (file)
@@ -1,3 +1,5 @@
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
 // File:        GeomAPI_Lin.cpp
 // Created:     29 May 2014
 // Author:      Artem ZHIDKOV
index b6b3cca5af8a47c9e5b245a3c55b3fd5e6a9bf1a..feefca2383551ba3ac06ece65fd4e772456d1b90 100644 (file)
@@ -1,3 +1,5 @@
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
 // File:        GeomAPI_Lin.h
 // Created:     29 May 2014
 // Author:      Artem ZHIDKOV
index a59c5b4ea0fa801faa8ba7eb54ff97e3fb6afecf..0a65590fa789f6f1a22ded9f7b1688563170cdb7 100644 (file)
@@ -1,3 +1,5 @@
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
 // File:        GeomAPI_Lin2d.cpp
 // Created:     29 May 2014
 // Author:      Artem ZHIDKOV
index 50a8fbfb1f23c6e88ca2d7895f9fb3726ce4d650..5f6a02244d33033e2552701ae1c16600984cdd9a 100644 (file)
@@ -1,3 +1,5 @@
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
 // File:        GeomAPI_Lin2d.h
 // Created:     29 May 2014
 // Author:      Artem ZHIDKOV
index 3b17174c066a19033849328c6dd65a03a1baf2e5..53470fb5e55d09aa3c21ee1fc2baa012a0f3b625 100644 (file)
@@ -1,3 +1,5 @@
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
 // File:        GeomAPI_PlanarEdges.cpp
 // Created:     06 Oct 2014
 // Author:      Sergey BELASH
index 1cb638530404779baacb5d608c3601277282af7c..a9cd54a31679cd0453b185caa936f52235f6b06d 100644 (file)
@@ -1,3 +1,5 @@
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
 // File:        GeomAPI_PlanarEdges.hxx
 // Created:     24 Jul 2014
 // Author:      Artem ZHIDKOV
index cee05500816e80885f7f4e5fd7cf6a02fe4be594..81c5bbc2e18726f8f4fdb501ba669c556fb59eeb 100644 (file)
@@ -1,3 +1,5 @@
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
 // File:        GeomAPI_Pln.cpp
 // Created:     23 Apr 2014
 // Author:      Mikhail PONIKAROV
index c1a99f6ef6bae4640b6cb25079f25952973ae12e..8bd9668e7dc407e0020f27bfa8943f4bc106f187 100644 (file)
@@ -1,3 +1,5 @@
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
 // File:        GeomAPI_Pln.hxx
 // Created:     23 Apr 2014
 // Author:      Mikhail PONIKAROV
index ef7b5800135fdcd92d182a123c3b0fbbfbd23d42..29fe933a668f87ddfab4985fbf3ff1b910e12c6a 100644 (file)
@@ -1,3 +1,5 @@
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
 // File:        GeomAPI_Pnt.cpp
 // Created:     23 Apr 2014
 // Author:      Mikhail PONIKAROV
@@ -6,8 +8,11 @@
 #include<GeomAPI_XYZ.h>
 #include<GeomAPI_Pnt2d.h>
 #include<GeomAPI_Dir.h>
+#include<GeomAPI_Pln.h>
 
 #include<gp_Pnt.hxx>
+#include<gp_Pln.hxx>
+#include<ProjLib.hxx>
 
 #define MY_PNT static_cast<gp_Pnt*>(myImpl)
 
@@ -71,3 +76,22 @@ std::shared_ptr<GeomAPI_Pnt2d> GeomAPI_Pnt::to2D(const std::shared_ptr<GeomAPI_P
   double aY = aVec.X() * theDirY->x() + aVec.Y() * theDirY->y() + aVec.Z() * theDirY->z();
   return std::shared_ptr<GeomAPI_Pnt2d>(new GeomAPI_Pnt2d(aX, aY));
 }
+
+
+void GeomAPI_Pnt::translate(const std::shared_ptr<GeomAPI_Dir>& theDir, double theDist)
+{
+  gp_Vec aVec(theDir->impl<gp_Dir>());
+  aVec.Normalize();
+  aVec.Multiply(theDist);
+  MY_PNT->Translate(aVec);
+}
+
+std::shared_ptr<GeomAPI_Pnt2d> GeomAPI_Pnt::to2D(const std::shared_ptr<GeomAPI_Pln>& thePln) const
+{
+  double aA, aB, aC, aD;
+  thePln->coefficients(aA, aB, aC, aD);
+  gp_Pln aPln(aA, aB, aC, aD);
+
+  gp_Pnt2d aRes = ProjLib::Project(aPln, *MY_PNT);
+  return std::shared_ptr<GeomAPI_Pnt2d>(new GeomAPI_Pnt2d(aRes.X(), aRes.Y()));
+}
index e01c80647d8cbc57bc92dbc612e90fcd330f47bf..44f203a7735232d5b8691da10a3b3f2b3b62f44e 100644 (file)
@@ -1,3 +1,5 @@
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
 // File:        GeomAPI_Pnt.hxx
 // Created:     23 Apr 2014
 // Author:      Mikhail PONIKAROV
@@ -11,6 +13,7 @@
 class GeomAPI_XYZ;
 class GeomAPI_Pnt2d;
 class GeomAPI_Dir;
+class GeomAPI_Pln;
 
 /**\class GeomAPI_Pnt
  * \ingroup DataModel
@@ -49,6 +52,12 @@ class GEOMAPI_EXPORT GeomAPI_Pnt : public GeomAPI_Interface
   std::shared_ptr<GeomAPI_Pnt2d> to2D(const std::shared_ptr<GeomAPI_Pnt>& theOrigin,
                                         const std::shared_ptr<GeomAPI_Dir>& theDirX,
                                         const std::shared_ptr<GeomAPI_Dir>& theDirY);
+
+  /// Projects a point to the plane defined by the origin and 2 axes vectors in this plane
+  std::shared_ptr<GeomAPI_Pnt2d> to2D(const std::shared_ptr<GeomAPI_Pln>& thePln) const;
+
+  /// Translates the point along direction theDir on distance theDist
+  void translate(const std::shared_ptr<GeomAPI_Dir>& theDir, double theDist);
 };
 
 #endif
index 5ef9df175c3eb9f6f18e3386d20b8df1d7acf97c..2bd8e3937982f62d42bc0f6c734cc4712ab2cd3d 100644 (file)
@@ -1,3 +1,5 @@
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
 // File:        GeomAPI_Pnt2d.cpp
 // Created:     29 May 2014
 // Author:      Artem ZHIDKOV
index 7d1716cb000551f4253128e41e2252540ee51e29..bd0000fdb867d2e0bc919862bf41f599db18cf8b 100644 (file)
@@ -1,3 +1,5 @@
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
 // File:        GeomAPI_Pnt2d.h
 // Created:     29 May 2014
 // Author:      Artem ZHIDKOV
index 5b9694ccce509b77e915aa2724636c138045c8c0..5a84a3d98680abc7ba2753556332fe53b31bffb1 100644 (file)
@@ -1,3 +1,5 @@
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
 // File:        GeomAPI_Shape.cpp
 // Created:     23 Apr 2014
 // Author:      Mikhail PONIKAROV
@@ -5,6 +7,11 @@
 #include<GeomAPI_Shape.h>
 
 #include <TopoDS_Shape.hxx>
+#include <BRepBndLib.hxx>
+#include <Bnd_Box.hxx>
+#include <BRepTools.hxx>
+
+#include <sstream>
 
 #define MY_SHAPE static_cast<TopoDS_Shape*>(myImpl)
 
@@ -39,3 +46,29 @@ bool GeomAPI_Shape::isEdge() const
   const TopoDS_Shape& aShape = const_cast<GeomAPI_Shape*>(this)->impl<TopoDS_Shape>();
   return aShape.ShapeType() == TopAbs_EDGE;
 }
+
+bool GeomAPI_Shape::isFace() const
+{
+  const TopoDS_Shape& aShape = const_cast<GeomAPI_Shape*>(this)->impl<TopoDS_Shape>();
+  return aShape.ShapeType() == TopAbs_FACE;
+}
+
+bool GeomAPI_Shape::computeSize(double& theXmin, double& theYmin, double& theZmin,
+                                double& theXmax, double& theYmax, double& theZmax) const
+{
+  const TopoDS_Shape& aShape = const_cast<GeomAPI_Shape*>(this)->impl<TopoDS_Shape>();
+  if (aShape.IsNull())
+    return false;
+  Bnd_Box aBndBox;
+  BRepBndLib::Add(aShape, aBndBox);
+  aBndBox.Get(theXmin, theYmin, theZmin, theXmax, theYmax, theZmax);
+  return true;
+}
+
+std::string GeomAPI_Shape::getShapeStream() const
+{
+  std::ostringstream aStream;
+  const TopoDS_Shape& aShape = const_cast<GeomAPI_Shape*>(this)->impl<TopoDS_Shape>();
+  BRepTools::Write(aShape, aStream);
+  return aStream.str();
+}
index c55d9ab314d3b5cff5e5ce8a9228de60c652eb7b..8ff96d9815ca5e00c3e93ed1d2dc5e2b201a6100 100644 (file)
@@ -1,3 +1,5 @@
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
 // File:        GeomAPI_Shape.hxx
 // Created:     23 Apr 2014
 // Author:      Mikhail PONIKAROV
@@ -30,6 +32,15 @@ class GEOMAPI_EXPORT GeomAPI_Shape : public GeomAPI_Interface
   /// Returns whether the shape is an edge
   virtual bool isEdge() const;
 
+  /// Returns whether the shape is a face
+  virtual bool isFace() const;
+
+  /// Computes boundary dimensions of the shape
+  /// Returns False if it is not possible
+  bool computeSize(double& theXmin, double& theYmin, double& theZmin,
+                   double& theXmax, double& theYmax, double& theZmax) const;
+
+  std::string getShapeStream() const;
 };
 
 //! Pointer on list of shapes
diff --git a/src/GeomAPI/GeomAPI_Vertex.cpp b/src/GeomAPI/GeomAPI_Vertex.cpp
new file mode 100644 (file)
index 0000000..4c51908
--- /dev/null
@@ -0,0 +1,50 @@
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
+// File:        GeomAPI_Vertex.cpp
+// Created:     24 Jul 2014
+// Author:      Artem ZHIDKOV
+
+#include<GeomAPI_Vertex.h>
+#include<GeomAPI_Pnt.h>
+
+#include <TopoDS_Shape.hxx>
+#include <TopoDS_Edge.hxx>
+#include <TopoDS.hxx>
+#include <TopoDS_Vertex.hxx>
+#include <BRep_Tool.hxx>
+#include <gp_Pnt.hxx>
+#include <Precision.hxx>
+
+GeomAPI_Vertex::GeomAPI_Vertex()
+  : GeomAPI_Shape()
+{
+}
+
+GeomAPI_Vertex::GeomAPI_Vertex(const std::shared_ptr<GeomAPI_Shape>& theShape)
+{
+  if (!theShape->isNull() && theShape->isVertex()) {
+    setImpl(new TopoDS_Shape(theShape->impl<TopoDS_Shape>()));
+  }
+}
+
+std::shared_ptr<GeomAPI_Pnt> GeomAPI_Vertex::point()
+{
+  const TopoDS_Shape& aShape = const_cast<GeomAPI_Vertex*>(this)->impl<TopoDS_Shape>();
+  TopoDS_Vertex aVertex = TopoDS::Vertex(aShape);
+  gp_Pnt aPoint = BRep_Tool::Pnt(aVertex);
+  return std::shared_ptr<GeomAPI_Pnt>(new GeomAPI_Pnt(aPoint.X(), aPoint.Y(), aPoint.Z()));
+}
+
+bool GeomAPI_Vertex::isEqual(std::shared_ptr<GeomAPI_Shape> theVert)
+{
+  const TopoDS_Shape& aMyShape = const_cast<GeomAPI_Vertex*>(this)->impl<TopoDS_Shape>();
+  const TopoDS_Shape& aInShape = theVert->impl<TopoDS_Shape>();
+
+  TopoDS_Vertex aVertex1 = TopoDS::Vertex(aMyShape);
+  gp_Pnt aPoint1 = BRep_Tool::Pnt(aVertex1);
+
+  TopoDS_Vertex aVertex2 = TopoDS::Vertex(aInShape);
+  gp_Pnt aPoint2 = BRep_Tool::Pnt(aVertex2);
+
+  return aPoint1.IsEqual(aPoint2, Precision::Confusion()) == Standard_True;
+}
diff --git a/src/GeomAPI/GeomAPI_Vertex.h b/src/GeomAPI/GeomAPI_Vertex.h
new file mode 100644 (file)
index 0000000..fab2840
--- /dev/null
@@ -0,0 +1,36 @@
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
+// File:        GeomAPI_Vertex.hxx
+// Created:     16 Dec 2014
+// Author:      Vitaly Smetannikov
+
+#ifndef GeomAPI_Vertex_H_
+#define GeomAPI_Vertex_H_
+
+#include <GeomAPI_Shape.h>
+
+class GeomAPI_Pnt;
+
+/**\class GeomAPI_Vertex
+* \ingroup DataModel
+ * \brief Interface to the vertex object
+ */
+
+class GEOMAPI_EXPORT GeomAPI_Vertex : public GeomAPI_Shape
+{
+public:
+   /// Creation of empty (null) shape
+   GeomAPI_Vertex();
+
+   /// Creation of edge by the edge-shape
+   GeomAPI_Vertex(const std::shared_ptr<GeomAPI_Shape>& theShape);
+
+  /// Returns the first vertex coordinates of the edge 
+  std::shared_ptr<GeomAPI_Pnt> point();
+
+  /// Returns true if the current edge is geometrically equal to the given edge
+  bool isEqual(std::shared_ptr<GeomAPI_Shape> theVert);
+};
+
+#endif
+
index beff35c27fadb9f10b5cab6efaddb22cd98181e8..ebe52e065e53b893c0787b242e136e0389ebc8ba 100644 (file)
@@ -1,3 +1,5 @@
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
 // File:        GeomAPI_XY.cpp
 // Created:     30 May 2014
 // Author:      Artem ZHIDKOV
index b4439b93d49d25bbf7d21e2ace21edee71924e66..3649db87d9166f8517658b3ff3dff86129b86978 100644 (file)
@@ -1,3 +1,5 @@
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
 // File:        GeomAPI_XY.hxx
 // Created:     30 May 2014
 // Author:      Artem ZHIDKOV
index 6d4b97c2fc9f6139ee2048291d5f07c45798c752..1b8e0e457f068914f6b433274b42025d7e06844e 100644 (file)
@@ -1,3 +1,5 @@
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
 // File:        GeomAPI_XYZ.cpp
 // Created:     23 Apr 2014
 // Author:      Mikhail PONIKAROV
index 2ff628824929bc6943fc506846b4b92afc83adca..12cf7d04a678902b7e1b62d380f2e54a557787fe 100644 (file)
@@ -1,3 +1,5 @@
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
 // File:        GeomAPI_XYZ.hxx
 // Created:     23 Apr 2014
 // Author:      Mikhail PONIKAROV
index ef36a838e3b4c70ff2ab0ab5ad9f4f7962132227..5ae5c8e50fee6e2f4f5e3037c29cb1066342d4df 100644 (file)
@@ -1,3 +1,5 @@
+## Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
 FIND_PACKAGE(SWIG REQUIRED)
 
 INCLUDE(${SWIG_USE_FILE})
@@ -14,6 +16,7 @@ SET(PROJECT_HEADERS
     GeomAlgoAPI_Boolean.h
     GeomAlgoAPI_MakeShape.h
     GeomAlgoAPI_DFLoader.h
+    GeomAlgoAPI_Placement.h
 )
 
 SET(PROJECT_SOURCES
@@ -26,6 +29,7 @@ SET(PROJECT_SOURCES
     GeomAlgoAPI_Boolean.cpp
     GeomAlgoAPI_MakeShape.cpp
     GeomAlgoAPI_DFLoader.cpp
+    GeomAlgoAPI_Placement.cpp
 )
 
 SET(PROJECT_LIBRARIES
index fc7d33bbe95e3429effcfe2a7cac6aff42bb7a82..5ce3930df8580878b8556563b496e7b7a22ad33d 100644 (file)
@@ -1,3 +1,5 @@
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
 #ifndef GEOMALGOAPI_H
 #define GEOMALGOAPI_H
 
index 24598c5416c2047d83f10af67ce6e5a5dd3ac2d8..9d3a05873507cc28a76d59a47d59f0ace60616cc 100644 (file)
@@ -1,3 +1,5 @@
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
 // File:        GeomAlgoAPI_Boolean.cpp
 // Created:     02 Sept 2014
 // Author:      Vitaly Smetannikov
index 7c315d9a65705800be55bd4eb45d35a32e816bac..ac7b267d0eb4f4c0aba8c772c45b7b5c63d32799 100644 (file)
@@ -1,3 +1,5 @@
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
 // File:        GeomAlgoAPI_Boolean.h
 // Created:     02 Sept 2014
 // Author:      Vitaly Smetannikov
index 8ce54d347adf98d35701495bd93121c587cab445..a988d3bb2a8dfd798efdc027e0619347032b34e6 100644 (file)
@@ -1,3 +1,5 @@
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
 // File:        GeomAlgoAPI_CompoundBuilder.cpp
 // Created:     24 Apr 2014
 // Author:      Natalia ERMOLAEVA
index dac10ee8cdc7d156550d71b0afe8223f25c958e2..5e863f34c92b1a1646ae70df2fc09c0292bfac93 100644 (file)
@@ -1,3 +1,5 @@
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
 // File:        GeomAlgoAPI_CompoundBuilder.h
 // Created:     24 Apr 2014
 // Author:      Natalia ERMOLAEVA
index 89fb0237b90da2e6df870adce9476e08f2572154..86c7b0a228059201fde6a5a2530aa90933fd8aab 100644 (file)
@@ -1,3 +1,5 @@
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
 // File:        GeomAlgoAPI_DFLoader.cpp
 // Created:     23 October 2014
 // Author:      Sergey Zaritchny
index 766e0c734a18b71df50df0b864bbdc2588453c54..e5ac0f25468ea3293f44e1aa83d9dc4cf1dd3022 100644 (file)
@@ -1,3 +1,5 @@
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
 // File:        GeomAlgoAPI_DFLoader.h
 // Created:     23 October 2014
 // Author:      Sergey Zaritchny
index 5d314dd8e1583a12c727a8a343a2bd8c25f7fb3b..f1ecb2b34fca5e14775253030ec483e616639460 100644 (file)
@@ -1,3 +1,5 @@
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
 // File:        GeomAlgoAPI_EdgeBuilder.cpp
 // Created:     23 Apr 2014
 // Author:      Mikhail PONIKAROV
index bc29d923c4ba19ef14bbb48862e4a02c2e6f1586..ef0f82df49d04931d80d748a35c2667dcc4232e6 100644 (file)
@@ -1,3 +1,5 @@
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
 // File:        GeomAlgoAPI_EdgeBuilder.h
 // Created:     23 Apr 2014
 // Author:      Mikhail PONIKAROV
index 7d76979b2e22003881e6c1d1c5c9988eb80aad6a..29c4aec277baa4167af118b36f05d4f343f9e261 100644 (file)
@@ -1,3 +1,5 @@
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
 // File:        GeomAlgoAPI_Extrusion.cpp
 // Created:     06 Jun 2014
 // Author:      Artem ZHIDKOV
index 26a22bf5d85d58ce87d0cd47f55080a585461cd7..9db662fa25036522f0641c4af76f4c363dbb291c 100644 (file)
@@ -1,3 +1,5 @@
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
 // File:        GeomAlgoAPI_Extrusion.h
 // Created:     22 October 2014
 // Author:      Sergey Zaritchny
index b1a7d5e924bb2feee9aa5c614fafa333344d1fe4..2dc527d9d5462e97016396853b31144b6e9f754a 100644 (file)
@@ -1,3 +1,5 @@
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
 // File:        GeomAlgoAPI_FaceBuilder.cpp
 // Created:     23 Apr 2014
 // Author:      Mikhail PONIKAROV
@@ -50,3 +52,21 @@ std::shared_ptr<GeomAPI_Pln> GeomAlgoAPI_FaceBuilder::plane(
   aResult = std::shared_ptr<GeomAPI_Pln>(new GeomAPI_Pln(aA, aB, aC, aD));
   return aResult;
 }
+
+
+std::shared_ptr<GeomAPI_Shape> GeomAlgoAPI_FaceBuilder::
+  planarFace(std::shared_ptr<GeomAPI_Pln> thePlane,
+             double theX, double theY,
+             double theWidth, double theHeight)
+{
+  double aA, aB, aC, aD;
+  thePlane->coefficients(aA, aB, aC, aD);
+  gp_Pln aPlane(aA, aB, aC, aD);
+
+  // half of the size in each direction from the center
+  BRepBuilderAPI_MakeFace aFaceBuilder(aPlane, theX, theX + theWidth, 
+                                       theY, theY + theHeight);
+  std::shared_ptr<GeomAPI_Shape> aRes(new GeomAPI_Shape);
+  aRes->setImpl(new TopoDS_Shape(aFaceBuilder.Face()));
+  return aRes;
+}
\ No newline at end of file
index 4880566dffebb912667ae29fc477dd1b3bae0e4c..7db03a41b72cd57084eef25a5c4182e68756ff0f 100644 (file)
@@ -1,3 +1,5 @@
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
 // File:        GeomAlgoAPI_FaceBuilder.h
 // Created:     23 Apr 2014
 // Author:      Mikhail PONIKAROV
@@ -28,6 +30,11 @@ class GEOMALGOAPI_EXPORT GeomAlgoAPI_FaceBuilder
 
   /// Returns the plane of the planar face. If it is not planar, returns empty ptr.
   static std::shared_ptr<GeomAPI_Pln> plane(std::shared_ptr<GeomAPI_Shape> theFace);
+
+  /// Creates a planar face by given plane, left lower point and size.
+  static std::shared_ptr<GeomAPI_Shape> planarFace(std::shared_ptr<GeomAPI_Pln> thePlane,
+                                                   double theX, double theY,
+                                                   double theWidth, double theHeight);
 };
 
 #endif
index 402457c954219dc5ef543e768c7eb580f380ad96..f28779de5f60f244d5c41124d2541b00fdeefcbf 100644 (file)
@@ -1,3 +1,5 @@
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
 // File:        GeomAlgoAPI_MakeShape.cpp
 // Created:     20 Oct 2014
 // Author:      Sergey ZARITCHNY
index 6848898b6c9615ab7784692dca7e0327696a6a19..6159b11c6949a0851b7c934eaa0ecaec6bc191f2 100644 (file)
@@ -1,3 +1,5 @@
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
 // File:        GeomAlgoAPI_MakeShape.h
 // Created:     17 Oct 2014
 // Author:      Sergey ZARITCHNY
diff --git a/src/GeomAlgoAPI/GeomAlgoAPI_Placement.cpp b/src/GeomAlgoAPI/GeomAlgoAPI_Placement.cpp
new file mode 100644 (file)
index 0000000..3cc4f85
--- /dev/null
@@ -0,0 +1,124 @@
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
+// File:        GeomAlgoAPI_Placement.cpp
+// Created:     2 Dec 2014
+// Author:      Artem ZHIDKOV
+
+#include <GeomAlgoAPI_Placement.h>
+#include <GeomAlgoAPI_DFLoader.h>
+
+#include <GeomAPI_Pnt.h>
+
+#include <BRepBuilderAPI_Transform.hxx>
+#include <gp_Trsf.hxx>
+#include <gp_Quaternion.hxx>
+#include <TopExp_Explorer.hxx>
+#include <BRepCheck_Analyzer.hxx>
+#include <GProp_GProps.hxx>
+#include <BRepGProp.hxx>
+#include <Precision.hxx>
+#define DEB_PLACEMENT 1
+GeomAlgoAPI_Placement::GeomAlgoAPI_Placement(
+    std::shared_ptr<GeomAPI_Shape> theAttractiveFace,
+    std::shared_ptr<GeomAPI_Pln> theSourcePlane,
+    std::shared_ptr<GeomAPI_Pln> theDestPlane)
+  : myDone(false),
+    myShape(new GeomAPI_Shape())
+{
+  build(theAttractiveFace, theSourcePlane, theDestPlane);
+}
+
+void GeomAlgoAPI_Placement::build(
+    const std::shared_ptr<GeomAPI_Shape>& theAttractiveShape,
+    const std::shared_ptr<GeomAPI_Pln>& theSourcePlane,
+    const std::shared_ptr<GeomAPI_Pln>& theDestPlane)
+{
+  std::shared_ptr<GeomAPI_Dir> aSourceDir = theSourcePlane->direction();
+  std::shared_ptr<GeomAPI_Pnt> aSourceLoc = theSourcePlane->location();
+  std::shared_ptr<GeomAPI_Dir> aDestDir = theDestPlane->direction();
+  std::shared_ptr<GeomAPI_Pnt> aDestLoc = theDestPlane->location();
+
+  // Calculate transformation
+  gp_Trsf aTrsf;
+  gp_Vec aSrcDir(aSourceDir->x(), aSourceDir->y(), aSourceDir->z());
+  gp_Vec aDstDir(aDestDir->x(), aDestDir->y(), aDestDir->z());
+  gp_Quaternion aRot(aSrcDir, aDstDir);
+  aTrsf.SetRotation(aRot);
+  gp_Vec aSrcCenter(aSourceLoc->x(), aSourceLoc->y(), aSourceLoc->z());
+  aSrcCenter.Transform(aTrsf);
+  gp_Vec aTrans(aDestLoc->x() - aSrcCenter.X(),
+                aDestLoc->y() - aSrcCenter.Y(),
+                aDestLoc->z() - aSrcCenter.Z());
+  aTrsf.SetTransformation(aRot, aTrans);
+
+  // Transform the shape with copying it
+  const TopoDS_Shape& aShape = theAttractiveShape->impl<TopoDS_Shape>();
+  BRepBuilderAPI_Transform* aBuilder = new BRepBuilderAPI_Transform(aShape, aTrsf, true);
+  if(aBuilder) {
+    setImpl(aBuilder);
+    myDone = aBuilder->IsDone() == Standard_True;
+    if (myDone) {
+      TopoDS_Shape aResult = aBuilder->Shape();
+      // fill data map to keep correct orientation of sub-shapes 
+      for (TopExp_Explorer Exp(aResult,TopAbs_FACE); Exp.More(); Exp.Next()) {
+        std::shared_ptr<GeomAPI_Shape> aCurrentShape(new GeomAPI_Shape());
+        aCurrentShape->setImpl(new TopoDS_Shape(Exp.Current()));
+        myMap.bind(aCurrentShape, aCurrentShape);
+      }
+#ifdef DEB_PLACEMENT
+         int aNum = myMap.size();
+         cout << "MAP of Oriented shapes =" << aNum <<endl;
+
+#endif
+
+      myShape->setImpl(new TopoDS_Shape(aResult));
+      myMkShape = new GeomAlgoAPI_MakeShape (aBuilder);
+    }
+  }
+}
+
+//============================================================================
+const bool GeomAlgoAPI_Placement::isValid() const
+{
+  BRepCheck_Analyzer aChecker(myShape->impl<TopoDS_Shape>());
+  return (aChecker.IsValid() == Standard_True);
+}
+
+//============================================================================
+const bool GeomAlgoAPI_Placement::hasVolume() const
+{
+  bool hasVolume(false);
+  if(isValid()) {
+    const TopoDS_Shape& aRShape = myShape->impl<TopoDS_Shape>();
+    GProp_GProps aGProp;
+    BRepGProp::VolumeProperties(aRShape, aGProp);
+    if(aGProp.Mass() > Precision::Confusion()) 
+      hasVolume = true;        
+  }
+  return hasVolume;
+}
+
+//============================================================================
+const std::shared_ptr<GeomAPI_Shape>& GeomAlgoAPI_Placement::shape () const 
+{
+  return myShape;
+}
+
+//============================================================================
+void GeomAlgoAPI_Placement::mapOfShapes (GeomAPI_DataMapOfShapeShape& theMap) const
+{
+  theMap = myMap;
+}
+
+//============================================================================
+GeomAlgoAPI_MakeShape * GeomAlgoAPI_Placement::makeShape() const
+{
+  return myMkShape;
+}
+
+//============================================================================
+GeomAlgoAPI_Placement::~GeomAlgoAPI_Placement()
+{
+  if (myImpl)
+    myMap.clear();
+}
\ No newline at end of file
diff --git a/src/GeomAlgoAPI/GeomAlgoAPI_Placement.h b/src/GeomAlgoAPI/GeomAlgoAPI_Placement.h
new file mode 100644 (file)
index 0000000..7bebf97
--- /dev/null
@@ -0,0 +1,70 @@
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
+// File:        GeomAlgoAPI_Placement.h
+// Created:     2 Dec 2014
+// Author:      Artem ZHIDKOV
+
+#ifndef GeomAlgoAPI_Placement_H_
+#define GeomAlgoAPI_Placement_H_
+
+#include <GeomAlgoAPI.h>
+#include <GeomAPI_Shape.h>
+#include <GeomAPI_Dir.h>
+#include <GeomAPI_Pln.h>
+#include <GeomAlgoAPI_MakeShape.h>
+#include <GeomAPI_DataMapOfShapeShape.h>
+#include <memory>
+
+/**\class GeomAlgoAPI_Placement
+ * \ingroup DataAlgo
+ * \brief Creates the copied object which face is placed on the given plane
+ */
+class GeomAlgoAPI_Placement : public GeomAPI_Interface
+{
+public:
+  /** \brief Creates an object which is obtained from current object by transformation calculated
+   *         as a movement of the source plane to be coincident with the destination plane
+   *  \param[in] theAttractiveShape shape to be moved
+   *  \param[in] theSourcePlane     plane on the shape to be made coincident with destination plane
+   *  \param[in] theDestPlane       destination plane
+   */
+  GEOMALGOAPI_EXPORT GeomAlgoAPI_Placement(std::shared_ptr<GeomAPI_Shape> theAttractiveShape,
+                                           std::shared_ptr<GeomAPI_Pln> theSourcePlane,
+                                           std::shared_ptr<GeomAPI_Pln> theDestPlane);
+
+  /// Returns True if algorithm succeed
+  GEOMALGOAPI_EXPORT const bool isDone() const
+  { return myDone; }
+
+  ///  Returns True if resulting shape is valid
+  GEOMALGOAPI_EXPORT const bool isValid() const;
+
+  /// Returns True if resulting shape has volume
+  GEOMALGOAPI_EXPORT const bool hasVolume() const;
+
+  /// Returns result of the Placement algorithm which may be a Solid or a Face
+  GEOMALGOAPI_EXPORT const std::shared_ptr<GeomAPI_Shape>& shape () const;
+
+  /// Returns map of sub-shapes of the result. To be used for History keeping
+  GEOMALGOAPI_EXPORT void  mapOfShapes (GeomAPI_DataMapOfShapeShape& theMap) const;
+
+  /// Return interface for for History processing
+  GEOMALGOAPI_EXPORT GeomAlgoAPI_MakeShape* makeShape () const;
+
+  /// Destructor
+  GEOMALGOAPI_EXPORT virtual ~GeomAlgoAPI_Placement();
+
+private:
+  /// builds resulting shape
+  void build(const std::shared_ptr<GeomAPI_Shape>& theAttractiveShape,
+             const std::shared_ptr<GeomAPI_Pln>& theSourcePlane,
+             const std::shared_ptr<GeomAPI_Pln>& theDestPlane);
+
+  /// fields
+  bool myDone;
+  std::shared_ptr<GeomAPI_Shape> myShape;
+  GeomAPI_DataMapOfShapeShape myMap;
+  GeomAlgoAPI_MakeShape * myMkShape;
+};
+
+#endif
index 086cc419b429c43205fea01aba229792954b2955..f57605c8c4fe2ee37f078ab46f0ea545f8d7d5e5 100644 (file)
@@ -1,3 +1,5 @@
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
 // File:        GeomAlgoAPI_PointBuilder.cpp
 // Created:     02 Jun 2014
 // Author:      Mikhail PONIKAROV
@@ -6,7 +8,10 @@
 #include <GeomAPI_Pnt.h>
 #include <GeomAPI_Shape.h>
 #include <BRepBuilderAPI_MakeVertex.hxx>
+#include <BRep_Tool.hxx>
 #include <TopoDS_Vertex.hxx>
+#include <TopoDS.hxx>
+#include <gp_Pnt.hxx>
 
 std::shared_ptr<GeomAPI_Shape> GeomAlgoAPI_PointBuilder::point(
     std::shared_ptr<GeomAPI_Pnt> thePoint)
@@ -18,3 +23,16 @@ std::shared_ptr<GeomAPI_Shape> GeomAlgoAPI_PointBuilder::point(
   aRes->setImpl(new TopoDS_Shape(aVertex));
   return aRes;
 }
+
+
+std::shared_ptr<GeomAPI_Pnt> GeomAlgoAPI_PointBuilder::point(std::shared_ptr<GeomAPI_Shape> theVertex)
+{
+  TopoDS_Shape aShape = theVertex->impl<TopoDS_Shape>();
+  if ((!aShape.IsNull()) && (aShape.ShapeType() == TopAbs_VERTEX)) {
+    TopoDS_Vertex aVertex = TopoDS::Vertex(aShape);
+    gp_Pnt aPoint = BRep_Tool::Pnt(aVertex);
+    std::shared_ptr<GeomAPI_Pnt> aPnt(new GeomAPI_Pnt(aPoint.X(), aPoint.Y(), aPoint.Z()));
+    return aPnt;
+  }
+  return std::shared_ptr<GeomAPI_Pnt>();
+}
index 78639d7fdd4f7ce273b30fe0e00fc71b6aa1f202..893c70c977fa77c999d15b11215584169ccf3f72 100644 (file)
@@ -1,3 +1,5 @@
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
 // File:        GeomAlgoAPI_PointBuilder.h
 // Created:     02 Jun 2014
 // Author:      Mikhail PONIKAROV
@@ -19,8 +21,11 @@ class GeomAPI_Pnt;
 class GEOMALGOAPI_EXPORT GeomAlgoAPI_PointBuilder
 {
  public:
-  /// Creates linear edge by two points
+  /// Creates a shape by point
   static std::shared_ptr<GeomAPI_Shape> point(std::shared_ptr<GeomAPI_Pnt> thePoint);
+
+  /// Return point by shape vertex
+  static std::shared_ptr<GeomAPI_Pnt> point(std::shared_ptr<GeomAPI_Shape> theVertex);
 };
 
 #endif
index 4e894827d7f63d037da9748132f9784a6107f721..065b27257f2922c77953e4bbd2ac8817b7ec7e40 100644 (file)
@@ -1,3 +1,5 @@
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
 // File:        GeomAlgoAPI_SketchBuilder.cpp
 // Created:     02 Jun 2014
 // Author:      Artem ZHIDKOV
index a2ed358490d0344a93b7a1b45f58d3b7ac8d6e3a..0d471dd0f3591bbdea4b70c4bb1d6294f2017d63 100644 (file)
@@ -1,3 +1,5 @@
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
 // File:        GeomAlgoAPI_SketchBuilder.h
 // Created:     02 Jun 2014
 // Author:      Artem ZHIDKOV
index c63c256c78fd2b9de84583b5d4cc01ab5f52482a..0469a36ea768c12b201f73fdca3a005f11a7d5e3 100644 (file)
@@ -1,3 +1,5 @@
+## Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
 INCLUDE(Common)
 
 SET(PROJECT_HEADERS
index c17c76cf5b635b17aecef61608a80d68b54078cd..4e54e64d22498dd159a7288802d90fefd570ef6a 100644 (file)
@@ -1,3 +1,5 @@
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
 #ifndef GEOMDATA_H
 #define GEOMDATA_H
 
index 837c94073dad6d2af33c8b060a7f1461de72ec1e..d36e8a8f5c84685b7b3d6fbc879ee6aa03ca2fa2 100644 (file)
@@ -1,3 +1,5 @@
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
 // File:        GeomData_Dir.cxx
 // Created:     2 Apr 2014
 // Author:      Mikhail PONIKAROV
index a11316a4be9a46731e2d99fc5acff7bd026b61c5..0080ffbc6df16c357a0c95ff11475b592b34b861 100644 (file)
@@ -1,3 +1,5 @@
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
 // File:        GeomData_Dir.h
 // Created:     24 Apr 2014
 // Author:      Mikhail PONIKAROV
index ca9f960dfbcf1490514ea1cc78ee9b032c45b3de..2a2f52d80ea3e2b93de5f66eb0dd9cb6b9e19be6 100644 (file)
@@ -1,3 +1,5 @@
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
 // File:        GeomData_Point.cxx
 // Created:     24 Apr 2014
 // Author:      Mikhail PONIKAROV
index 507227f1b6970da0bdf6f75424d365e2885a8df5..d4b715ac43a86418b9f94b746b1a1efe52ff8d61 100644 (file)
@@ -1,3 +1,5 @@
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
 // File:        GeomData_Point.h
 // Created:     24 Apr 2014
 // Author:      Mikhail PONIKAROV
index eee50b4e7a01ab48cdfa3d55834362a03dfbd097..5061f8193ec6c8eb495116a788fb2395fb5239bb 100644 (file)
@@ -1,3 +1,5 @@
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
 // File:        GeomData_Point2D.cxx
 // Created:     24 Apr 2014
 // Author:      Mikhail PONIKAROV
index f5989898e78c5da66e1f77356df0485925f7def2..8363f99670fdb47bdd70b829dfd690b277785f7c 100644 (file)
@@ -1,3 +1,5 @@
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
 // File:        GeomData_Point2D.h
 // Created:     24 Apr 2014
 // Author:      Mikhail PONIKAROV
index b9e1488b7ffda88869b9855292b5276310b8fbe6..1f8880b751c479b752b6b736ba1eb38b3b90869f 100644 (file)
@@ -1,3 +1,5 @@
+## Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
 FIND_PACKAGE(SWIG REQUIRED)
 INCLUDE(${SWIG_USE_FILE})
 INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR})
index 1449986df2fd6c1854d86b17b5e4bf9f5bfbd071..eab53ec1f49f25ac71a84ade4ac672bfccdd6e96 100644 (file)
@@ -1,3 +1,5 @@
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
 #ifndef GEOMDATAAPI_H
 #define GEOMDATAAPI_H
 
index c4bdb19ed0dae9fb2e12c6b2ccd5d9eae62328b2..968edb2325670112dc8e008c5afb2bb9c383ea1e 100644 (file)
@@ -1,3 +1,5 @@
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
 // File:        GeomDataAPI_Dir.h
 // Created:     24 Apr 2014
 // Author:      Mikhail PONIKAROV
index cc5f4f6f09a4e892fc6175df6c7cbfc24fe3a91d..9209e521013a827e33aabaea45fd13b8639f722a 100644 (file)
@@ -1,3 +1,5 @@
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
 // File:        GeomDataAPI_Point.h
 // Created:     24 Apr 2014
 // Author:      Mikhail PONIKAROV
index 73df286246a46ea3eae15b38f14ffb3927338984..83acc0b57e05bb510735a3dd5991ce272d07b2bc 100644 (file)
@@ -1,3 +1,5 @@
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
 // File:        GeomDataAPI_Point2D.h
 // Created:     24 Apr 2014
 // Author:      Mikhail PONIKAROV
index 9a1b97c1371a51886ac7ad3e4dd193f8ae1ee288..51263163459b727449b3e67f666bd782e0b76c3a 100644 (file)
@@ -1,3 +1,5 @@
+## Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
 INCLUDE(Common)
 
 SET(PROJECT_HEADERS
index 0966a483d4b5571c2a5dd3bf6e9ca2ab457f260f..c161250c0d5a3fa7ecae88543983725712db27ae 100644 (file)
@@ -1,3 +1,5 @@
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
 #ifndef GEOMVALIDATORS_H
 #define GEOMVALIDATORS_H
 
index 3362a47d3c33310193fb1301cfba2535d424da12..58964c04f985a1ce4f9afc8bedd3c83f8ebc6926 100644 (file)
@@ -1,3 +1,5 @@
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
 // File:        GeomValidators_ValidatorPositive.cpp
 // Created:     16 Sep 2014
 // Author:      Mikhail PONIKAROV
index fcc741e3b30a18ab3d620107aa6992b54bf74c76..abfbe948bc519bd8bcbe0cbd390a46d947cf368d 100644 (file)
@@ -1,3 +1,5 @@
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
 // File:        GeomValidators_ValidatorPositive.h
 // Created:     16 Sep 2014
 // Author:      Mikhail PONIKAROV
index c5cf96007803720c5cccf9fd8b732cb6eda87fe8..379fc69afe1c6f9f664f729f6b77b5fb352b33e3 100644 (file)
@@ -1,3 +1,5 @@
+## Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
 INCLUDE(Common)
 
 SET(PROJECT_HEADERS
index b7bf7f20668d96c4d98d60ee97a18d4a674b1de5..b2112e0bc0f01be8361effb9fa930fd1dd861f16 100644 (file)
@@ -1,3 +1,5 @@
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
 #ifndef MODEL_H
 #define MODEL_H
 
index 6f315ee0ebd58b3ade943dba1e30af618981d7c7..147bb4ac29e2c4450b28c73bafa042215c8c8c18 100644 (file)
@@ -1,3 +1,5 @@
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
 // File:       Model_Application.cxx
 // Created:    Fri Sep 2 2011
 // Author:     Mikhail PONIKAROV
@@ -65,6 +67,12 @@ void Model_Application::setLoadPath(std::string thePath)
   myPath = thePath;
 }
 
+//=======================================================================
+const std::string& Model_Application::loadPath() const
+{
+  return myPath;
+}
+
 //=======================================================================
 void Model_Application::setLoadByDemand(std::string theID)
 {
index 3d905dc41e35994026e0f9def396184112a65f7b..aa25bcb4e161c9b6bfa1a389a12dff6942618463 100644 (file)
@@ -1,3 +1,5 @@
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
 // File:        Model_Application.hxx
 // Created:     28 Dec 2011
 // Author:      Mikhail PONIKAROV
@@ -41,6 +43,8 @@ class Model_Application : public TDocStd_Application
 
   //! Set path for the loaded by demand documents
   void setLoadPath(std::string thePath);
+  //! Returns the path for the loaded by demand documents
+  const std::string& loadPath() const;
   //! Defines that specified document must be loaded by demand
   void setLoadByDemand(std::string theID);
   //! Returns true if specified document must be loaded by demand
index 74901271ef27ba3dd9ddedc362bcf23e28f9a327..3ebcaf953db0f6a17d9460084274f5cf116628dd 100644 (file)
@@ -1,3 +1,5 @@
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
 // File:        Model_AttributeBoolean.cpp
 // Created:     2 june 2014
 // Author:      Vitaly Smetannikov
index f52d52691a7217392fa965bbe7031d0ed167cc24..c3217b6ca7f6112b099aa2334a92beb1bd9b90a4 100644 (file)
@@ -1,3 +1,5 @@
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
 // File:        Model_AttributeBoolean.h
 // Created:     2 june 2014
 // Author:      Vitaly Smetannikov
index 566533aaf1f17309ab02bb5b4dd2635a11255451..2284226c262cb09819572a5c52e370623f5a7950 100644 (file)
@@ -1,3 +1,5 @@
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
 // File:        ModelAPI_AttributeDocRef.cxx
 // Created:     2 Apr 2014
 // Author:      Mikhail PONIKAROV
index 28fc60fd20e141959f153f01d5aa9cdcc2c9922e..3a4638a69c69588cbd0013cd73821c4f06e90eff 100644 (file)
@@ -1,3 +1,5 @@
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
 // File:        Model_AttributeDocRef.h
 // Created:     2 Apr 2014
 // Author:      Mikhail PONIKAROV
index 13b976c2e1e57e74e19cd51a0168e4ddb6dbd611..4764420f7c515a0184b7471f416ae4a328e5bdaa 100644 (file)
@@ -1,3 +1,5 @@
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
 // File:        ModelAPI_AttributeDouble.cxx
 // Created:     2 Apr 2014
 // Author:      Mikhail PONIKAROV
index c9b54b863b3ef344b5fa680dc94fc92ca283d847..f04db7f88e9cdba0b4aef6b0fbd619e8cbfe08aa 100644 (file)
@@ -1,3 +1,5 @@
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
 // File:        Model_AttributeDouble.h
 // Created:     2 Apr 2014
 // Author:      Mikhail PONIKAROV
index 1d72baa40b37afe5d52534d5a237087d0755b103..b93bfa855cec04391064137e5dea7d054ee32f13 100644 (file)
@@ -1,3 +1,5 @@
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
 // File:        Model_AttributeInteger.cpp
 // Created:     03 sep 2014
 // Author:      sbh
index c4be993be0be78f3ffc4d3e6085d6534b1804bbf..a723227bc550c7efc77309ff766e984650801491 100644 (file)
@@ -1,3 +1,5 @@
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
 // File:        Model_AttributeInteger.h
 // Created:     03 sep 2014
 // Author:      sbh
index 0410e657bf6a6d07a5df025b6ba9eb0f2746dc29..14e6eb4a18d394929af5d30dc2d89d11f10ac4c6 100644 (file)
@@ -1,3 +1,5 @@
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
 // File:        ModelAPI_AttributeRefAttr.cxx
 // Created:     2 Apr 2014
 // Author:      Mikhail PONIKAROV
index 1833d3eb9f255c165b533f4966a01b1c16b0c298..94609a8f5f37e5e9390638844764f3d177d5b775 100644 (file)
@@ -1,3 +1,5 @@
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
 // File:        Model_AttributeRefAttr.h
 // Created:     8 May 2014
 // Author:      Mikhail PONIKAROV
index 8c304cb3bca6b5cd95799bc3d3afcda5a1acf6c4..9287cf0415079707b7ecfb17c91b01c51742deb4 100644 (file)
@@ -1,3 +1,5 @@
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
 // File:        ModelAPI_AttributeRefList.cxx
 // Created:     8 May 2014
 // Author:      Mikhail PONIKAROV
index 2b0edac1fc99c7a2f4ab30f1109f29e2c140b668..2a4550a80bfd376c3437b5c5aaadfc2e82967863 100644 (file)
@@ -1,3 +1,5 @@
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
 // File:        Model_AttributeRefList.h
 // Created:     8 May 2014
 // Author:      Mikhail PONIKAROV
index e209eb0e12ef43ac33786ce9bbf025e7e8cb3554..2b0e15756ff84c9766ac0226447aab13a9ad63c5 100644 (file)
@@ -1,3 +1,5 @@
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
 // File:        ModelAPI_AttributeReference.cxx
 // Created:     2 Apr 2014
 // Author:      Mikhail PONIKAROV
@@ -7,6 +9,11 @@
 #include "Model_Events.h"
 #include "Model_Data.h"
 #include <ModelAPI_Feature.h>
+#include <ModelAPI_Session.h>
+
+#include <TDataStd_Comment.hxx>
+#include <TDataStd_AsciiString.hxx>
+#include <TDF_Tool.hxx>
 
 using namespace std;
 
@@ -15,12 +22,25 @@ void Model_AttributeReference::setValue(ObjectPtr theObject)
   if(!theObject)
     return;
   if (!myIsInitialized || value() != theObject) {
-    std::shared_ptr<Model_Data> aData = std::dynamic_pointer_cast<Model_Data>(
-        theObject->data());
+      std::shared_ptr<Model_Data> aData = std::dynamic_pointer_cast<Model_Data>(
+          theObject->data());
+      TDF_Label anObjLab = aData->label().Father(); // object label
 
-    std::shared_ptr<Model_Document> aDoc =
-      std::dynamic_pointer_cast<Model_Document>(owner()->document());
-    myRef->Set(aData->label().Father());  // references to the feature label
+    if (owner()->document() == theObject->document()) { // same document, use reference attribute
+
+      std::shared_ptr<Model_Document> aDoc =
+        std::dynamic_pointer_cast<Model_Document>(owner()->document());
+      myRef->Set(anObjLab);  // references to the object label
+       // remove external link attributes (if any)
+      myRef->Label().ForgetAttribute(TDataStd_Comment::GetID());
+      myRef->Label().ForgetAttribute(TDataStd_AsciiString::GetID());
+    } else { // different document: store the document name (comment) and entry (string): external
+      // if these attributes exist, the link is external: keep reference to access the label
+      TDataStd_Comment::Set(myRef->Label(), theObject->document()->id().c_str());
+      TCollection_AsciiString anEntry;
+      TDF_Tool::Entry(anObjLab, anEntry);
+      TDataStd_AsciiString::Set(myRef->Label(), anEntry);
+    }
 
     owner()->data()->sendAttributeUpdated(this);
   }
@@ -29,11 +49,28 @@ void Model_AttributeReference::setValue(ObjectPtr theObject)
 ObjectPtr Model_AttributeReference::value()
 {
   if (myIsInitialized) {
-    std::shared_ptr<Model_Document> aDoc = std::dynamic_pointer_cast<Model_Document>(
-        owner()->document());
-    if (aDoc) {
-      TDF_Label aRefLab = myRef->Get();
-      return aDoc->object(aRefLab);
+    Handle(TDataStd_Comment) aDocID;
+    if (myRef->Label().FindAttribute(TDataStd_Comment::GetID(), aDocID)) { // external ref
+      DocumentPtr aRefDoc =
+        ModelAPI_Session::get()->document(TCollection_AsciiString(aDocID->Get()).ToCString());
+      if (aRefDoc) {
+        Handle(TDataStd_AsciiString) anEntry;
+        if (myRef->Label().FindAttribute(TDataStd_AsciiString::GetID(), anEntry)) {
+          std::shared_ptr<Model_Document> aDR = std::dynamic_pointer_cast<Model_Document>(aRefDoc);
+          TDF_Label aRefLab;
+          TDF_Tool::Label(aDR->featuresLabel().Data(), anEntry->Get().ToCString(), aRefLab);
+          if (!aRefLab.IsNull()) {
+            return aDR->object(aRefLab);
+          }
+        }
+      }
+    } else { // internal ref
+      std::shared_ptr<Model_Document> aDoc = std::dynamic_pointer_cast<Model_Document>(
+          owner()->document());
+      if (aDoc) {
+        TDF_Label aRefLab = myRef->Get();
+        return aDoc->object(aRefLab);
+      }
     }
   }
   // not initialized
index eceb208cb8ca3278e40e3dbddf60efbc2e1b8f95..991f4e725544ae90283cad4ecd618c58bbeba063 100644 (file)
@@ -1,3 +1,5 @@
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
 // File:        Model_AttributeReference.h
 // Created:     8 May 2014
 // Author:      Mikhail PONIKAROV
index 0ae4bf6a844fe2a337497a37b429684e3de6546c..f76344f552f6d0e976e26a7910c6dccb6b6c1666 100644 (file)
@@ -1,3 +1,5 @@
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
 // File:        Model_AttributeSelection.h
 // Created:     2 Oct 2014
 // Author:      Mikhail PONIKAROV
@@ -31,6 +33,8 @@
 #include <TColStd_MapOfTransient.hxx>
 #include <gp_Pnt.hxx>
 #include <Precision.hxx>
+#include <TDF_ChildIterator.hxx>
+#include <TDF_ChildIDIterator.hxx>
 
 using namespace std;
 /// adeed to the index in the packed map to signalize that the vertex of edge is seleted
@@ -74,6 +78,12 @@ std::shared_ptr<GeomAPI_Shape> Model_AttributeSelection::value()
       TopoDS_Shape aSelShape = aSelection->Get();
       aResult = std::shared_ptr<GeomAPI_Shape>(new GeomAPI_Shape);
       aResult->setImpl(new TopoDS_Shape(aSelShape));
+    } else { // for simple construction element: just shape of this construction element
+      ResultConstructionPtr aConstr = 
+        std::dynamic_pointer_cast<ModelAPI_ResultConstruction>(context());
+      if (aConstr) {
+        return aConstr->shape();
+      }
     }
   }
   return aResult;
@@ -96,6 +106,29 @@ void Model_AttributeSelection::setObject(const std::shared_ptr<ModelAPI_Object>&
   myRef.setObject(theObject);
 }
 
+TDF_LabelMap& Model_AttributeSelection::scope()
+{
+  if (myScope.IsEmpty()) { // create a new scope if not yet done
+    // gets all labels with named shapes that are bofore this feature label (before in history)
+    TDF_Label aFeatureLab = std::dynamic_pointer_cast<Model_Data>(
+      owner()->data())->label().Father();
+    int aFeatureID = aFeatureLab.Tag();
+    TDF_ChildIterator aFeaturesIter(aFeatureLab.Father());
+    for(; aFeaturesIter.More(); aFeaturesIter.Next()) {
+      if (aFeaturesIter.Value().Tag() >= aFeatureID) // the left labels are created later
+        break;
+      TDF_ChildIDIterator aNSIter(aFeaturesIter.Value(), TNaming_NamedShape::GetID(), 1);
+      for(; aNSIter.More(); aNSIter.Next()) {
+        Handle(TNaming_NamedShape) aNS = Handle(TNaming_NamedShape)::DownCast(aNSIter.Value());
+        if (!aNS.IsNull() && aNS->Evolution() != TNaming_SELECTED) {
+          myScope.Add(aNS->Label());
+        }
+      }
+    }
+  }
+  return myScope;
+}
+
 bool Model_AttributeSelection::update()
 {
   ResultPtr aContext = context();
@@ -103,8 +136,7 @@ bool Model_AttributeSelection::update()
   if (aContext->groupName() == ModelAPI_ResultBody::group()) {
     // body: just a named shape, use selection mechanism from OCCT
     TNaming_Selector aSelector(selectionLabel());
-    TDF_LabelMap aScope; // empty means the whole document
-    bool aResult = aSelector.Solve(aScope) == Standard_True;
+    bool aResult = aSelector.Solve(scope()) == Standard_True;
     owner()->data()->sendAttributeUpdated(this);
     return aResult;
   } else if (aContext->groupName() == ModelAPI_ResultConstruction::group()) {
@@ -113,7 +145,7 @@ bool Model_AttributeSelection::update()
     std::shared_ptr<GeomAPI_PlanarEdges> aWirePtr = 
       std::dynamic_pointer_cast<GeomAPI_PlanarEdges>(
       std::dynamic_pointer_cast<ModelAPI_ResultConstruction>(aContext)->shape());
-    if (aWirePtr && aWirePtr->hasPlane()) {
+    if (aWirePtr && aWirePtr->hasPlane()) { // sketch sub-element
       TDF_Label aLab = myRef.myRef->Label();
       // getting a type of selected shape
       Handle(TDataStd_Integer) aTypeAttr;
@@ -127,7 +159,7 @@ bool Model_AttributeSelection::update()
       bool aNoIndexes = 
         !aLab.FindAttribute(TDataStd_IntPackedMap::GetID(), aSubIds) || aSubIds->Extent() == 0;
       // for now working only with composite features
-      FeaturePtr aContextFeature = owner()->document()->feature(aContext);
+      FeaturePtr aContextFeature = aContext->document()->feature(aContext);
       CompositeFeaturePtr aComposite = 
         std::dynamic_pointer_cast<ModelAPI_CompositeFeature>(aContextFeature);
       if (!aComposite || aComposite->numberOfSubs() == 0) {
@@ -232,7 +264,7 @@ bool Model_AttributeSelection::update()
             // searching for deltas
             int aVertexNum = 0;
             if (aSubIds->Contains(aFeatureID + kSTART_VERTEX_DELTA)) aVertexNum = 1;
-            else if (aSubIds->Contains(aFeatureID + kSTART_VERTEX_DELTA)) aVertexNum = 2;
+            else if (aSubIds->Contains(aFeatureID + kSTART_VERTEX_DELTA * 2)) aVertexNum = 2;
             // found the feature with appropriate edge
             FeaturePtr aFeature = aComposite->subFeature(a);
             std::list<std::shared_ptr<ModelAPI_Result> >::const_iterator aResIter =
@@ -264,6 +296,9 @@ bool Model_AttributeSelection::update()
           }
         }
       }
+    } else { // simple construction element: the selected is that needed
+      owner()->data()->sendAttributeUpdated(this);
+      return true;
     }
   }
   return false; // unknown case
@@ -296,7 +331,7 @@ void Model_AttributeSelection::selectBody(
 void Model_AttributeSelection::selectConstruction(
     const ResultPtr& theContext, const std::shared_ptr<GeomAPI_Shape>& theSubShape)
 {
-  FeaturePtr aContextFeature = owner()->document()->feature(theContext);
+  FeaturePtr aContextFeature = theContext->document()->feature(theContext);
   CompositeFeaturePtr aComposite = 
     std::dynamic_pointer_cast<ModelAPI_CompositeFeature>(aContextFeature);
   if (!aComposite || aComposite->numberOfSubs() == 0) {
index f2d8106eae9862eadc26154814fa5c5ba99015f8..bc6933d39a3bdfc092d091db8568a1931def4b54 100644 (file)
@@ -1,3 +1,5 @@
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
 // File:        Model_AttributeSelection.h
 // Created:     8 May 2014
 // Author:      Mikhail PONIKAROV
@@ -8,6 +10,7 @@
 #include "Model.h"
 #include "Model_AttributeReference.h"
 #include <ModelAPI_AttributeSelection.h>
+#include <TDF_LabelMap.hxx>
 
 /**\class Model_AttributeSelection
  * \ingroup DataModel
@@ -17,6 +20,7 @@
 class Model_AttributeSelection : public ModelAPI_AttributeSelection
 {
   Model_AttributeReference myRef;  ///< The reference functionality reusage
+  TDF_LabelMap myScope; ///< the map of valid labels for naming selection solving
 public:
   /// Defines the result and its selected sub-shape
   MODEL_EXPORT virtual void setValue(
@@ -51,6 +55,9 @@ protected:
   /// Note: there must be no attributes stored at the same label because Selector clears this lab
   TDF_Label selectionLabel();
 
+  /// Returns the prepared map of valid labels for naming selection solving (creates if not exists)
+  TDF_LabelMap& scope();
+
   friend class Model_Data;
   friend class Model_AttributeSelectionList;
 };
index 96a2ccb32c1f70ed4c1a266e8f2b60bc4e4b445c..14a684a96657ff7f13443ac8dc4ef9bff83ccc9a 100644 (file)
@@ -1,3 +1,5 @@
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
 // File:        Model_AttributeSelectionList.h
 // Created:     22 Oct 2014
 // Author:      Mikhail PONIKAROV
index 602e5b2382f53f4153e00209f8b371048a133b21..dcfc8b85dae803f39ec4c4022b844b31871a4d06 100644 (file)
@@ -1,3 +1,5 @@
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
 // File:        Model_AttributeSelectionList.h
 // Created:     22 Oct 2014
 // Author:      Mikhail PONIKAROV
index 8a9d6f0ebcea225222a1361f5842200645c65647..53650b1202b3cfa9eb279c5165d9f3d95acfbb35 100644 (file)
@@ -1,3 +1,5 @@
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
 // File:        Model_AttributeString.cpp
 // Created:     25 august 2014
 // Author:      sbh
index a75ddae6a6e3313b5177b18677e0c1b05944311c..e99f21763a4c658d53439b469c2665d28f55e070 100644 (file)
@@ -1,3 +1,5 @@
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
 // File:        Model_AttributeString.h
 // Created:     25 august 2014
 // Author:      sbh
index 77b834ada84f458a48bf33d6259c9659d57b1a19..1bd4dc1b96c3e861f0936e9d65badc93f4886fee 100644 (file)
@@ -1,3 +1,5 @@
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
 // File:        Model_Data.hxx
 // Created:     21 Mar 2014
 // Author:      Mikhail PONIKAROV
 #include <Events_Error.h>
 
 #include <TDataStd_Name.hxx>
-#include <TDataStd_UAttribute.hxx>
 
 #include <string>
 
+// myLab contains:
+// TDataStd_Name - name of the object
+// TDataStd_Integer - state of the object execution
+
 Model_Data::Model_Data()
 {
 }
@@ -85,7 +90,9 @@ void Model_Data::addAttribute(const std::string& theID, const std::string theAtt
     anAttr = new Model_AttributeRefAttr(anAttrLab);
   } else if (theAttrType == ModelAPI_AttributeRefList::type()) {
     anAttr = new Model_AttributeRefList(anAttrLab);
-  } else if (theAttrType == GeomData_Point::type()) {
+  } 
+  // create also GeomData attributes here because only here the OCAF strucure is known
+  else if (theAttrType == GeomData_Point::type()) {
     anAttr = new GeomData_Point(anAttrLab);
   } else if (theAttrType == GeomData_Dir::type()) {
     anAttr = new GeomData_Dir(anAttrLab);
@@ -95,172 +102,34 @@ void Model_Data::addAttribute(const std::string& theID, const std::string theAtt
   if (anAttr) {
     myAttrs[theID] = std::shared_ptr<ModelAPI_Attribute>(anAttr);
     anAttr->setObject(myObject);
+    anAttr->setID(theID);
   } else {
     Events_Error::send("Can not create unknown type of attribute " + theAttrType);
   }
 }
 
-std::shared_ptr<ModelAPI_AttributeDocRef> Model_Data::document(const std::string& theID)
-{
-  std::map<std::string, std::shared_ptr<ModelAPI_Attribute> >::iterator aFound = 
-    myAttrs.find(theID);
-  if (aFound == myAttrs.end()) {
-    // TODO: generate error on unknown attribute request and/or add mechanism for customization
-    return std::shared_ptr<ModelAPI_AttributeDocRef>();
-  }
-  std::shared_ptr<ModelAPI_AttributeDocRef> aRes = std::dynamic_pointer_cast<
-      ModelAPI_AttributeDocRef>(aFound->second);
-  if (!aRes) {
-    // TODO: generate error on invalid attribute type request
-  }
-  return aRes;
-}
-
-std::shared_ptr<ModelAPI_AttributeDouble> Model_Data::real(const std::string& theID)
-{
-  std::map<std::string, std::shared_ptr<ModelAPI_Attribute> >::iterator aFound = 
-    myAttrs.find(theID);
-  if (aFound == myAttrs.end()) {
-    // TODO: generate error on unknown attribute request and/or add mechanism for customization
-    return std::shared_ptr<ModelAPI_AttributeDouble>();
-  }
-  std::shared_ptr<ModelAPI_AttributeDouble> aRes = std::dynamic_pointer_cast<
-      ModelAPI_AttributeDouble>(aFound->second);
-  if (!aRes) {
-    // TODO: generate error on invalid attribute type request
-  }
-  return aRes;
-}
-
-std::shared_ptr<ModelAPI_AttributeInteger> Model_Data::integer(const std::string& theID)
-{
-  std::map<std::string, std::shared_ptr<ModelAPI_Attribute> >::iterator aFound = 
-    myAttrs.find(theID);
-  if (aFound == myAttrs.end()) {
-    // TODO: generate error on unknown attribute request and/or add mechanism for customization
-    return std::shared_ptr<ModelAPI_AttributeInteger>();
-  }
-  std::shared_ptr<ModelAPI_AttributeInteger> aRes = std::dynamic_pointer_cast<
-      ModelAPI_AttributeInteger>(aFound->second);
-  if (!aRes) {
-    // TODO: generate error on invalid attribute type request
-  }
-  return aRes;
-}
-
-std::shared_ptr<ModelAPI_AttributeBoolean> Model_Data::boolean(const std::string& theID)
-{
-  std::map<std::string, std::shared_ptr<ModelAPI_Attribute> >::iterator aFound = 
-    myAttrs.find(theID);
-  if (aFound == myAttrs.end()) {
-    // TODO: generate error on unknown attribute request and/or add mechanism for customization
-    return std::shared_ptr<ModelAPI_AttributeBoolean>();
-  }
-  std::shared_ptr<ModelAPI_AttributeBoolean> aRes = std::dynamic_pointer_cast<
-      ModelAPI_AttributeBoolean>(aFound->second);
-  if (!aRes) {
-    // TODO: generate error on invalid attribute type request
-  }
-  return aRes;
-}
-
-std::shared_ptr<ModelAPI_AttributeString> Model_Data::string(const std::string& theID)
-{
-  std::map<std::string, std::shared_ptr<ModelAPI_Attribute> >::iterator aFound = 
-    myAttrs.find(theID);
-  if (aFound == myAttrs.end()) {
-    // TODO: generate error on unknown attribute request and/or add mechanism for customization
-    return std::shared_ptr<ModelAPI_AttributeString>();
+// macro for gthe generic returning of the attribute by the ID
+#define GET_ATTRIBUTE_BY_ID(ATTR_TYPE, METHOD_NAME) \
+  std::shared_ptr<ATTR_TYPE> Model_Data::METHOD_NAME(const std::string& theID) { \
+    std::shared_ptr<ATTR_TYPE> aRes; \
+    std::map<std::string, AttributePtr >::iterator aFound = \
+      myAttrs.find(theID); \
+    if (aFound != myAttrs.end()) { \
+      aRes = std::dynamic_pointer_cast<ATTR_TYPE>(aFound->second); \
+    } \
+    return aRes; \
   }
-  std::shared_ptr<ModelAPI_AttributeString> aRes =
-      std::dynamic_pointer_cast<ModelAPI_AttributeString>(aFound->second);
-  if (!aRes) {
-    // TODO: generate error on invalid attribute type request
-  }
-  return aRes;
-
-}
-
-std::shared_ptr<ModelAPI_AttributeReference> Model_Data::reference(const std::string& theID)
-{
-  std::map<std::string, std::shared_ptr<ModelAPI_Attribute> >::iterator aFound = 
-    myAttrs.find(theID);
-  if (aFound == myAttrs.end()) {
-    // TODO: generate error on unknown attribute request and/or add mechanism for customization
-    return std::shared_ptr<ModelAPI_AttributeReference>();
-  }
-  std::shared_ptr<ModelAPI_AttributeReference> aRes = std::dynamic_pointer_cast<
-      ModelAPI_AttributeReference>(aFound->second);
-  if (!aRes) {
-    // TODO: generate error on invalid attribute type request
-  }
-  return aRes;
-}
-
-std::shared_ptr<ModelAPI_AttributeSelection> Model_Data::selection(const std::string& theID)
-{
-  std::map<std::string, std::shared_ptr<ModelAPI_Attribute> >::iterator aFound = 
-    myAttrs.find(theID);
-  if (aFound == myAttrs.end()) {
-    // TODO: generate error on unknown attribute request and/or add mechanism for customization
-    return std::shared_ptr<ModelAPI_AttributeSelection>();
-  }
-  std::shared_ptr<ModelAPI_AttributeSelection> aRes = 
-    std::dynamic_pointer_cast<ModelAPI_AttributeSelection>(aFound->second);
-  if (!aRes) {
-    // TODO: generate error on invalid attribute type request
-  }
-  return aRes;
-}
-
-std::shared_ptr<ModelAPI_AttributeSelectionList> 
-  Model_Data::selectionList(const std::string& theID)
-{
-  std::map<std::string, std::shared_ptr<ModelAPI_Attribute> >::iterator aFound = 
-    myAttrs.find(theID);
-  if (aFound == myAttrs.end()) {
-    // TODO: generate error on unknown attribute request and/or add mechanism for customization
-    return std::shared_ptr<ModelAPI_AttributeSelectionList>();
-  }
-  std::shared_ptr<ModelAPI_AttributeSelectionList> aRes = 
-    std::dynamic_pointer_cast<ModelAPI_AttributeSelectionList>(aFound->second);
-  if (!aRes) {
-    // TODO: generate error on invalid attribute type request
-  }
-  return aRes;
-}
-
-std::shared_ptr<ModelAPI_AttributeRefAttr> Model_Data::refattr(const std::string& theID)
-{
-  std::map<std::string, std::shared_ptr<ModelAPI_Attribute> >::iterator aFound = 
-    myAttrs.find(theID);
-  if (aFound == myAttrs.end()) {
-    // TODO: generate error on unknown attribute request and/or add mechanism for customization
-    return std::shared_ptr<ModelAPI_AttributeRefAttr>();
-  }
-  std::shared_ptr<ModelAPI_AttributeRefAttr> aRes = std::dynamic_pointer_cast<
-      ModelAPI_AttributeRefAttr>(aFound->second);
-  if (!aRes) {
-    // TODO: generate error on invalid attribute type request
-  }
-  return aRes;
-}
-
-std::shared_ptr<ModelAPI_AttributeRefList> Model_Data::reflist(const std::string& theID)
-{
-  std::map<std::string, std::shared_ptr<ModelAPI_Attribute> >::iterator aFound = 
-    myAttrs.find(theID);
-  if (aFound == myAttrs.end()) {
-    // TODO: generate error on unknown attribute request and/or add mechanism for customization
-    return std::shared_ptr<ModelAPI_AttributeRefList>();
-  }
-  std::shared_ptr<ModelAPI_AttributeRefList> aRes = std::dynamic_pointer_cast<
-      ModelAPI_AttributeRefList>(aFound->second);
-  if (!aRes) {
-    // TODO: generate error on invalid attribute type request
-  }
-  return aRes;
-}
+// implement nice getting methods for all ModelAPI attributes
+GET_ATTRIBUTE_BY_ID(ModelAPI_AttributeDocRef, document);
+GET_ATTRIBUTE_BY_ID(ModelAPI_AttributeDouble, real);
+GET_ATTRIBUTE_BY_ID(ModelAPI_AttributeInteger, integer);
+GET_ATTRIBUTE_BY_ID(ModelAPI_AttributeBoolean, boolean);
+GET_ATTRIBUTE_BY_ID(ModelAPI_AttributeString, string);
+GET_ATTRIBUTE_BY_ID(ModelAPI_AttributeReference, reference);
+GET_ATTRIBUTE_BY_ID(ModelAPI_AttributeSelection, selection);
+GET_ATTRIBUTE_BY_ID(ModelAPI_AttributeSelectionList, selectionList);
+GET_ATTRIBUTE_BY_ID(ModelAPI_AttributeRefAttr, refattr);
+GET_ATTRIBUTE_BY_ID(ModelAPI_AttributeRefList, reflist);
 
 std::shared_ptr<ModelAPI_Attribute> Model_Data::attribute(const std::string& theID)
 {
@@ -329,7 +198,7 @@ void Model_Data::sendAttributeUpdated(ModelAPI_Attribute* theAttr)
     static const Events_ID anEvent = Events_Loop::eventByName(EVENT_OBJECT_UPDATED);
     ModelAPI_EventCreator::get()->sendUpdated(myObject, anEvent);
     if (myObject) {
-      myObject->attributeChanged();
+      myObject->attributeChanged(theAttr->id());
     }
   }
 }
@@ -340,20 +209,25 @@ void Model_Data::erase()
     myLab.ForgetAllAttributes();
 }
 
-/// identifeir of the "must be updated" flag in the data tree
-Standard_GUID kMustBeUpdatedGUID("baede74c-31a6-4416-9c4d-e48ce65f2005");
+void Model_Data::execState(const ModelAPI_ExecState theState)
+{
+  if (theState != ModelAPI_StateNothing)
+    TDataStd_Integer::Set(myLab, (int)theState);
+}
 
-void Model_Data::mustBeUpdated(const bool theFlag)
+ModelAPI_ExecState Model_Data::execState()
 {
-  if (theFlag)
-    TDataStd_UAttribute::Set(myLab, kMustBeUpdatedGUID);
-  else
-    myLab.ForgetAttribute(kMustBeUpdatedGUID);
+  Handle(TDataStd_Integer) aStateAttr;
+  if (myLab.FindAttribute(TDataStd_Integer::GetID(), aStateAttr)) {
+    return ModelAPI_ExecState(aStateAttr->Get());
+  }
+  return ModelAPI_StateMustBeUpdated; // default value
 }
 
-bool Model_Data::mustBeUpdated()
+void Model_Data::setError(const std::string& theError)
 {
-  return myLab.IsAttribute(kMustBeUpdatedGUID) == Standard_True;
+  execState(ModelAPI_StateExecFailed);
+  Events_Error::send(theError);
 }
 
 int Model_Data::featureId() const
@@ -393,7 +267,6 @@ void Model_Data::referencesToObjects(
       std::shared_ptr<ModelAPI_AttributeReference> aRef = std::dynamic_pointer_cast<
           ModelAPI_AttributeReference>(anAttr->second);
       aReferenced.push_back(aRef->value());
-      theRefs.push_back(std::pair<std::string, std::list<ObjectPtr> >(anAttr->first, aReferenced));
     } else if (aType == ModelAPI_AttributeRefAttr::type()) { // reference to attribute or object
       std::shared_ptr<ModelAPI_AttributeRefAttr> aRef = std::dynamic_pointer_cast<
           ModelAPI_AttributeRefAttr>(anAttr->second);
index 1d82ad14be9a89ccb4619adf152f3f955142b01e..01b66978090198dfd92624ff87ca61e941e795de 100644 (file)
@@ -1,3 +1,5 @@
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
 // File:        Model_Data.hxx
 // Created:     21 Mar 2014
 // Author:      Mikhail PONIKAROV
@@ -140,14 +142,17 @@ class Model_Data : public ModelAPI_Data
     myObject = theObject;
   }
 
+  /// Erases all the data from the data model
   MODEL_EXPORT virtual void erase();
 
-  /// Makes feature must be updated later (on rebuild). Normally the Updater must call it
-  /// in case of not-automatic update to true
-  MODEL_EXPORT virtual void mustBeUpdated(const bool theFlag);
+  /// Stores the state of the object to execute it later accordingly
+  MODEL_EXPORT virtual void execState(const ModelAPI_ExecState theState);
+
+  /// Returns the state of the latest execution of the feature
+  MODEL_EXPORT virtual ModelAPI_ExecState execState();
 
-  /// Returns true if feature must be updated (re-executed) on rebuild
-  MODEL_EXPORT virtual bool mustBeUpdated();
+  /// Registers error during the execution, causes the ExecutionFailed state
+  MODEL_EXPORT virtual void setError(const std::string& theError);
 
   /// Returns the identifier of feature-owner, unique in this document
   MODEL_EXPORT virtual int featureId() const;
index 0fa26c8d45537daeeb879d4594a6207b18942ea6..c4fb2e7aaa8c1003d46b2782231fad0ed83f5ae3 100644 (file)
@@ -1,3 +1,5 @@
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
 // File:        Model_Document.cxx
 // Created:     28 Feb 2014
 // Author:      Mikhail PONIKAROV
@@ -24,6 +26,8 @@
 #include <TDF_Reference.hxx>
 #include <TDF_ChildIDIterator.hxx>
 #include <TDF_LabelMapHasher.hxx>
+#include <OSD_File.hxx>
+#include <OSD_Path.hxx>
 
 #include <climits>
 #ifndef WIN32
@@ -46,12 +50,18 @@ static const int TAG_HISTORY = 3;  // tag of the history sub-tree (python dump)
 static const int TAG_FEATURE_ARGUMENTS = 1;  ///< where the arguments are located
 static const int TAG_FEATURE_RESULTS = 2;  ///< where the results are located
 
+///
+/// 0:1:2 - where features are located
+/// 0:1:2:N:1 - data of the feature N
+/// 0:1:2:N:2:K:1 - data of the K result of the feature N
+
 Model_Document::Model_Document(const std::string theID, const std::string theKind)
     : myID(theID), myKind(theKind),
       myDoc(new TDocStd_Document("BinOcaf"))  // binary OCAF format
 {
   myDoc->SetUndoLimit(UNDO_LIMIT);  
-  myTransactionsAfterSave = 0;
+  myTransactionsCounter = 0;
+  myTransactionSave = 0;
   myNestedNum = -1;
   myExecuteFeatures = true;
   // to have something in the document and avoid empty doc open/save problem
@@ -158,6 +168,7 @@ bool Model_Document::load(const char* theFileName)
 bool Model_Document::save(const char* theFileName, std::list<std::string>& theResults)
 {
   // create a directory in the root document if it is not yet exist
+  Handle(Model_Application) anApp = Model_Application::getApplication();
   if (this == Model_Session::get()->moduleDocument().get()) {
 #ifdef WIN32
     CreateDirectory(theFileName, NULL);
@@ -169,7 +180,7 @@ bool Model_Document::save(const char* theFileName, std::list<std::string>& theRe
   TCollection_ExtendedString aPath(DocFileName(theFileName, myID));
   PCDM_StoreStatus aStatus;
   try {
-    aStatus = Model_Application::getApplication()->SaveAs(myDoc, aPath);
+    aStatus = anApp->SaveAs(myDoc, aPath);
   } catch (Standard_Failure) {
     Handle(Standard_Failure) aFail = Standard_Failure::Caught();
     Events_Error::send(
@@ -191,13 +202,39 @@ bool Model_Document::save(const char* theFileName, std::list<std::string>& theRe
         break;
     }
   }
-  myTransactionsAfterSave = 0;
+  myTransactionSave = myTransactionsCounter;
   if (isDone) {  // save also sub-documents if any
     theResults.push_back(TCollection_AsciiString(aPath).ToCString());
     std::set<std::string>::iterator aSubIter = mySubs.begin();
     for (; aSubIter != mySubs.end() && isDone; aSubIter++) {
       isDone = subDoc(*aSubIter)->save(theFileName, theResults);
     }
+    if (isDone) { // also try to copy the not-activated sub-documents
+      // they are not in mySubs but as ResultParts
+      int aPartsNum = size(ModelAPI_ResultPart::group());
+      for(int aPart = 0; aPart < aPartsNum; aPart++) {
+        ResultPartPtr aPartRes = std::dynamic_pointer_cast<ModelAPI_ResultPart>
+          (object(ModelAPI_ResultPart::group(), aPart));
+        if (aPartRes) {
+          std::string aDocName = aPartRes->data()->name();
+          if (!aDocName.empty() && mySubs.find(aDocName) == mySubs.end()) {
+            // just copy file
+            TCollection_AsciiString aSubPath(DocFileName(anApp->loadPath().c_str(), aDocName));
+            OSD_Path aPath(aSubPath);
+            OSD_File aFile(aPath);
+            if (aFile.Exists()) {
+              TCollection_AsciiString aDestinationDir(DocFileName(theFileName, aDocName));
+              OSD_Path aDestination(aDestinationDir);
+              aFile.Copy(aDestination);
+              theResults.push_back(aDestinationDir.ToCString());
+            } else {
+              Events_Error::send(
+                std::string("Can not open file ") + aSubPath.ToCString() + " for saving");
+            }
+          }
+        }
+      }
+    }
   }
   return isDone;
 }
@@ -250,8 +287,8 @@ void Model_Document::startOperation()
       myNestedNum = 0;
       myDoc->InitDeltaCompaction();
     }
-    myIsEmptyTr[myTransactionsAfterSave] = !myDoc->CommitCommand();
-    myTransactionsAfterSave++;
+    myIsEmptyTr[myTransactionsCounter] = !myDoc->CommitCommand();
+    myTransactionsCounter++;
     myDoc->OpenCommand();
   } else {  // start the simple command
     myDoc->NewCommand();
@@ -266,15 +303,15 @@ bool Model_Document::compactNested()
 {
   bool allWasEmpty = true;
   while (myNestedNum != -1) {
-    myTransactionsAfterSave--;
-    if (!myIsEmptyTr[myTransactionsAfterSave]) {
+    myTransactionsCounter--;
+    if (!myIsEmptyTr[myTransactionsCounter]) {
       allWasEmpty = false;
     }
-    myIsEmptyTr.erase(myTransactionsAfterSave);
+    myIsEmptyTr.erase(myTransactionsCounter);
     myNestedNum--;
   }
-  myIsEmptyTr[myTransactionsAfterSave] = allWasEmpty;
-  myTransactionsAfterSave++;
+  myIsEmptyTr[myTransactionsCounter] = allWasEmpty;
+  myTransactionsCounter++;
   if (allWasEmpty) {
     // Issue 151: if everything is empty, it is a problem for OCCT to work with it, 
     // just commit the empty that returns nothing
@@ -329,8 +366,8 @@ void Model_Document::finishOperation()
     }
   } else {
     // returns false if delta is empty and no transaction was made
-    myIsEmptyTr[myTransactionsAfterSave] = !myDoc->CommitCommand();  // && (myNestedNum == -1);
-    myTransactionsAfterSave++;
+    myIsEmptyTr[myTransactionsCounter] = !myDoc->CommitCommand();  // && (myNestedNum == -1);
+    myTransactionsCounter++;
   }
 }
 
@@ -338,11 +375,12 @@ void Model_Document::abortOperation()
 {
   if (myNestedNum > 0 && !myDoc->HasOpenCommand()) {  // abort all what was done in nested
       // first compact all nested
-    compactNested();
-    myDoc->Undo();
+    if (compactNested()) {
+      myDoc->Undo(); // undo only compacted, if not: do not undo the empty transaction
+    }
     myDoc->ClearRedos();
-    myTransactionsAfterSave--;
-    myIsEmptyTr.erase(myTransactionsAfterSave);
+    myTransactionsCounter--;
+    myIsEmptyTr.erase(myTransactionsCounter);
   } else {
     if (myNestedNum == 0)  // abort only high-level
       myNestedNum = -1;
@@ -364,13 +402,13 @@ bool Model_Document::isOperation()
 bool Model_Document::isModified()
 {
   // is modified if at least one operation was commited and not undoed
-  return myTransactionsAfterSave > 0 || isOperation();
+  return myTransactionsCounter != myTransactionSave || isOperation();
 }
 
 bool Model_Document::canUndo()
 {
   if (myDoc->GetAvailableUndos() > 0 && myNestedNum != 0
-      && myTransactionsAfterSave != 0 /* for omitting the first useless transaction */)
+      && myTransactionsCounter != 0 /* for omitting the first useless transaction */)
     return true;
   // check other subs contains operation that can be undoed
   std::set<std::string>::iterator aSubIter = mySubs.begin();
@@ -382,10 +420,10 @@ bool Model_Document::canUndo()
 
 void Model_Document::undo()
 {
-  myTransactionsAfterSave--;
+  myTransactionsCounter--;
   if (myNestedNum > 0)
     myNestedNum--;
-  if (!myIsEmptyTr[myTransactionsAfterSave])
+  if (!myIsEmptyTr[myTransactionsCounter])
     myDoc->Undo();
   synchronizeFeatures(true, true);
   // undo for all subs
@@ -410,9 +448,9 @@ void Model_Document::redo()
 {
   if (myNestedNum != -1)
     myNestedNum++;
-  if (!myIsEmptyTr[myTransactionsAfterSave])
+  if (!myIsEmptyTr[myTransactionsCounter])
     myDoc->Redo();
-  myTransactionsAfterSave++;
+  myTransactionsCounter++;
   synchronizeFeatures(true, true);
   // redo for all subs
   std::set<std::string>::iterator aSubIter = mySubs.begin();
@@ -885,6 +923,10 @@ void Model_Document::synchronizeBackRefs()
         ModelAPI_EventCreator::get()->sendUpdated(aCIter->first, anEvent);
       } else { // was not concealed become concealed => delete event
         ModelAPI_EventCreator::get()->sendDeleted(aThis, aCIter->first->groupName());
+        // redisplay for the viewer (it must be disappeared also)
+        static Events_ID EVENT_DISP = 
+          Events_Loop::loop()->eventByName(EVENT_OBJECT_TO_REDISPLAY);
+        ModelAPI_EventCreator::get()->sendUpdated(aCIter->first, EVENT_DISP);
       }
     }
   }
@@ -1009,6 +1051,9 @@ void Model_Document::updateResults(FeaturePtr theFeature)
     }
     aResIter++;
   }
+  // it may be on undo
+  if (!theFeature->data() || !theFeature->data()->isValid())
+    return;
   // check that results are presented on all labels
   int aResSize = theFeature->results().size();
   TDF_ChildIterator aLabIter(resultLabel(theFeature->data(), 0).Father());
@@ -1050,3 +1095,16 @@ Standard_Boolean IsEqual(const TDF_Label& theLab1, const TDF_Label& theLab2)
 {
   return TDF_LabelMapHasher::IsEqual(theLab1, theLab2);
 }
+
+void Model_Document::addNamingName(const TDF_Label theLabel, std::string theName)
+{
+  myNamingNames[theName] = theLabel;
+}
+
+TDF_Label Model_Document::findNamingName(std::string theName)
+{
+  std::map<std::string, TDF_Label>::iterator aFind = myNamingNames.find(theName);
+  if (aFind == myNamingNames.end())
+    return TDF_Label(); // not found
+  return aFind->second;
+}
index 519c57a19cb09a159de9f942672a7038e85b0307..75825586474b1dd93bef02be0455018c9a034273 100644 (file)
@@ -1,3 +1,5 @@
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
 // File:        Model_Document.h
 // Created:     28 Feb 2014
 // Author:      Mikhail PONIKAROV
@@ -134,6 +136,11 @@ class Model_Document : public ModelAPI_Document
   ///! On abort, undo or redo it is not necessary: results in document are updated automatically
   bool executeFeatures() {return myExecuteFeatures;}
 
+  //! Registers the name of the shape for the topological naming needs
+  void addNamingName(const TDF_Label theLabel, std::string theName);
+  //! Returns the label, keeper of the name  for the topological naming needs
+  TDF_Label findNamingName(std::string theName);
+
  protected:
 
   //! Returns (creates if needed) the features label
@@ -181,6 +188,7 @@ class Model_Document : public ModelAPI_Document
 
   friend class Model_Application;
   friend class Model_Session;
+  friend class Model_Update;
   friend class Model_AttributeReference;
   friend class DFBrowser;
 
@@ -188,13 +196,17 @@ class Model_Document : public ModelAPI_Document
   std::string myID;  ///< identifier of the document in the application
   std::string myKind;  ///< kind of the document in the application
   Handle_TDocStd_Document myDoc;  ///< OCAF document
-  /// number of transactions after the last "save" call, used for "IsModified" method
-  int myTransactionsAfterSave;
+  /// counter of transactions
+  int myTransactionsCounter;
+  /// counter value of transaction on the last "save" call, used for "IsModified" method
+  int myTransactionSave;
   /// number of nested transactions performed (or -1 if not nested)
   int myNestedNum;
   /// All features managed by this document (not only in history of OB)
   /// For optimization mapped by labels
   NCollection_DataMap<TDF_Label, FeaturePtr> myObjs;
+  /// Optimization for finding the shape-label by topological naming names
+  std::map<std::string, TDF_Label> myNamingNames;
 
   ///< set of identifiers of sub-documents of this document
   std::set<std::string> mySubs;
index a87fc9fb8a320d05b9569d0953b20fd624a22997..13c4d256873c97719cc6a525c49006d26432cf13 100644 (file)
@@ -1,3 +1,5 @@
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
 // File:        Model_Events.cxx
 // Created:     10 Apr 2014
 // Author:      Mikhail PONIKAROV
index 163c84581f7234059987c424dbb26be4968c0b7e..6c492c1ca3a3f1eff6ac8d4fe5e3862e7bfcea38 100644 (file)
@@ -1,3 +1,5 @@
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
 // File:        Model_Events.h
 // Created:     10 Apr 2014
 // Author:      Mikhail PONIKAROV
@@ -8,6 +10,8 @@
 #include <Model.h>
 #include <ModelAPI_Events.h>
 
+#include <memory>
+
 /// Allovs to create ModelAPI messages
 class Model_EventCreator : public ModelAPI_EventCreator
 {
index 6e609dd5d706cfcb0a6c76729b8a9126f646ae76..b3b1b821687f13ebdadaed93bc9ed4772fde4f02 100644 (file)
@@ -1,3 +1,5 @@
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
 // File:        Model_FeatureValidator.cpp
 // Created:     8 Jul 2014
 // Author:      Vitaly SMETANNIKOV
@@ -15,8 +17,10 @@ bool Model_FeatureValidator::isValid(const std::shared_ptr<ModelAPI_Feature>& th
   const std::list<std::string>& theArguments) const
 {
   std::shared_ptr<ModelAPI_Data> aData = theFeature->data();
-  if (!aData)
-    return false;
+  // "Action" features has no data, but still valid. e.g "Remove Part"  
+  if (!aData) {
+    return theFeature->isAction();
+  }
   if (!aData->isValid())
     return false;
   const std::string kAllTypes = "";
@@ -24,10 +28,10 @@ bool Model_FeatureValidator::isValid(const std::shared_ptr<ModelAPI_Feature>& th
   std::list<std::string>::iterator it = aLtAttributes.begin();
   for (; it != aLtAttributes.end(); it++) {
     AttributePtr anAttr = aData->attribute(*it);
-    if (!anAttr->isInitialized()) {
+    if (!anAttr->isInitialized()) { // attribute is not initialized
       std::map<std::string, std::set<std::string> >::const_iterator aFeatureFind = 
         myNotObligatory.find(theFeature->getKind());
-      if (aFeatureFind == myNotObligatory.end() ||
+      if (aFeatureFind == myNotObligatory.end() || // and it is obligatory for filling
           aFeatureFind->second.find(*it) == aFeatureFind->second.end()) {
         return false;
       }
@@ -41,3 +45,9 @@ void Model_FeatureValidator::registerNotObligatory(std::string theFeature, std::
   std::set<std::string>& anAttrs = myNotObligatory[theFeature];
   anAttrs.insert(theAttribute);
 }
+
+bool Model_FeatureValidator::isNotObligatory(std::string theFeature, std::string theAttribute)
+{
+  std::set<std::string>& anAttrs = myNotObligatory[theFeature];
+  return anAttrs.find(theAttribute) != anAttrs.end();
+}
index b262ff0ea552b0fee6cbb9d1ba2fc063fdbf4af5..86f287c99460cf08dfe963efb05b60f8fad6cd69 100644 (file)
@@ -1,3 +1,5 @@
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
 // File:        ModelAPI_FeatureValidator.h
 // Created:     8 Jul 2014
 // Author:      Vitaly SMETANNIKOV
@@ -24,7 +26,10 @@ class Model_FeatureValidator : public ModelAPI_FeatureValidator
     const std::list<std::string>& theArguments) const;
 
   // sets not obligatory attributes, not checked for initialization
-  void registerNotObligatory(std::string theFeature, std::string theAttribute);
+  virtual void registerNotObligatory(std::string theFeature, std::string theAttribute);
+
+  /// Returns true if the attribute in feature is not obligatory for the feature execution
+  virtual bool isNotObligatory(std::string theFeature, std::string theAttribute);
 };
 
 #endif
index 59c65ac9e470b92a2f184ee0258e8921952c62da..49cfa0fe543f5b4e085d6d8ae53cb2657f405c75 100644 (file)
@@ -1,3 +1,5 @@
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
 // File:        Model_ResultBody.cpp
 // Created:     08 Jul 2014
 // Author:      Mikhail PONIKAROV
@@ -92,7 +94,7 @@ void Model_ResultBody::storeModified(const std::shared_ptr<GeomAPI_Shape>& theOl
     TopoDS_Shape aShapeNew = theNewShape->impl<TopoDS_Shape>();
     if (aShapeNew.IsNull())
       return;  // null shape inside
-    aBuilder.Generated(aShapeOld, aShapeNew);
+       aBuilder.Modify(aShapeOld, aShapeNew);
   }
 }
 
index 28f268d83d1204d0da7f4d90d9b0e206cf91822a..31f9744cf7273f4304183d381cd17d658a8eceb7 100644 (file)
@@ -1,3 +1,5 @@
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
 // File:        Model_ResultBody.h
 // Created:     08 Jul 2014
 // Author:      Mikhail PONIKAROV
index 750d0e27d370443ddff3abd629cdf2e96570a482..aaade70ff23d3364b2fb930b5c1bc61081d5eac2 100644 (file)
@@ -1,3 +1,5 @@
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
 // File:        ModelAPI_ResultConstruction.cpp
 // Created:     07 Jul 2014
 // Author:      Mikhail PONIKAROV
index a1e395c5ed13919c8ae3cbc23f4074f43ae7819b..fa7e3f1aad99e3faa3e173584e6a1851ef5c57b5 100644 (file)
@@ -1,3 +1,5 @@
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
 // File:        ModelAPI_ResultConstruction.hxx
 // Created:     07 Jul 2014
 // Author:      Mikhail PONIKAROV
index e9c6e8c8b9cbb185ea348d8c36221173c142e163..ebcdb9b437ff4915e0bfe66b11856f4efb0b16f3 100644 (file)
@@ -1,3 +1,5 @@
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
 // File:        Model_ResultGroup.cpp
 // Created:     08 Jul 2014
 // Author:      Mikhail PONIKAROV
index 0dc35bdcfb25cf1bb685daa339fc326f543a9501..46a453de348b2f92fe2d495eabc5eb4dec269235 100644 (file)
@@ -1,3 +1,5 @@
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
 // File:        Model_ResultGroup.h
 // Created:     08 Jul 2014
 // Author:      Mikhail PONIKAROV
index 3032d6f9de0ae1d7aabcfc39046d8636ebcfc545..cc1666e5b3a43976ba1d61d718bebbcc69565d1d 100644 (file)
@@ -1,3 +1,5 @@
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
 // File:        ModelAPI_ResultPart.cpp
 // Created:     07 Jul 2014
 // Author:      Mikhail PONIKAROV
index 2df33884e46b12f74e898415f8ff648c5fbf3b19..e88d22aa28caa47d10dc550521524220bd9b4e12 100644 (file)
@@ -1,3 +1,5 @@
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
 // File:        ModelAPI_ResultPart.hxx
 // Created:     07 Jul 2014
 // Author:      Mikhail PONIKAROV
index d742dd9306451cebd46893011453e1b451f2e3f3..9430c7a16fce92d46ae8ac72f9cd2c08504e160d 100644 (file)
@@ -1,3 +1,5 @@
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
 // File:        Model_Session.cxx
 // Created:     20 Mar 2014
 // Author:      Mikhail PONIKAROV
@@ -61,9 +63,15 @@ void Model_Session::finishOperation()
 void Model_Session::abortOperation()
 {
   ROOT_DOC->abortOperation();
+  // here the update mechanism may work after abort, so, supress the warnings about
+  // modifications outside of the transactions
+  bool aWasCheck = myCheckTransactions;
+  myCheckTransactions = false;
   static std::shared_ptr<Events_Message> anAbortMsg
     (new Events_Message(Events_Loop::eventByName("AbortOperation")));
   Events_Loop::loop()->send(anAbortMsg);
+  myCheckTransactions = true;
+  myCheckTransactions = aWasCheck;
 }
 
 bool Model_Session::isOperation()
@@ -142,6 +150,12 @@ std::shared_ptr<ModelAPI_Document> Model_Session::moduleDocument()
       Model_Application::getApplication()->getDocument("root"));
 }
 
+std::shared_ptr<ModelAPI_Document> Model_Session::document(std::string theDocID)
+{
+  return std::shared_ptr<ModelAPI_Document>(
+      Model_Application::getApplication()->getDocument(theDocID));
+}
+
 bool Model_Session::hasModuleDocument()
 {
   return Model_Application::getApplication()->hasDocument("root");
@@ -284,6 +298,14 @@ void Model_Session::registerPlugin(ModelAPI_Plugin* thePlugin)
   static Events_ID EVENT_LOAD = Events_Loop::loop()->eventByName(EVENT_PLUGIN_LOADED);
   ModelAPI_EventCreator::get()->sendUpdated(ObjectPtr(), EVENT_LOAD);
   Events_Loop::loop()->flush(EVENT_LOAD);
+  // If the plugin has an ability to process GUI events, register it
+  Events_Listener* aListener = dynamic_cast<Events_Listener*>(thePlugin);
+  if (aListener) {
+    Events_Loop* aLoop = Events_Loop::loop();
+    static Events_ID aStateRequestEventId =
+        Events_Loop::loop()->eventByName(EVENT_FEATURE_STATE_REQUEST);
+    aLoop->registerListener(aListener, aStateRequestEventId);
+  }
 }
 
 ModelAPI_ValidatorsFactory* Model_Session::validators()
index 72977752ad95671df6004834cc35e92f1007b8ea..19172f3877389cb708f750595acd544f1d353b6e 100644 (file)
@@ -1,3 +1,5 @@
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
 // File:        Model_Session.hxx
 // Created:     20 Mar 2014
 // Author:      Mikhail PONIKAROV
@@ -69,6 +71,9 @@ class Model_Session : public ModelAPI_Session, public Events_Listener
   /// Returns the root document of the application (that may contains sub-documents)
   MODEL_EXPORT virtual std::shared_ptr<ModelAPI_Document> moduleDocument();
 
+  /// Returns the document by ID, loads if not loaded yet. Returns null if no such document.
+  MODEL_EXPORT virtual std::shared_ptr<ModelAPI_Document> document(std::string theDocID);
+
   /// Return true if root document has been already created
   MODEL_EXPORT virtual bool hasModuleDocument();
 
index e7116df59d3cbadb34bbab0f54739b53d98ec188..b27e6cc1740a80754de4edbf3d0a7c7606b3a812 100644 (file)
@@ -1,3 +1,5 @@
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
 // File:        Model_Update.cxx
 // Created:     25 Jun 2014
 // Author:      Mikhail PONIKAROV
@@ -116,37 +118,15 @@ void Model_Update::processEvent(const std::shared_ptr<Events_Message>& theMessag
 
   //Events_LongOp::start(this);
   isExecuted = true;
-  std::list<std::shared_ptr<ModelAPI_Document> > aDocs;
   std::shared_ptr<ModelAPI_ObjectUpdatedMessage> aMsg =
       std::dynamic_pointer_cast<ModelAPI_ObjectUpdatedMessage>(theMessage);
   if (aMsg) myInitial = aMsg->objects();
   else {
     myInitial.clear();
-    // on change flag all documents must be updated
-    if (isAutomatic) {
-      aDocs = ModelAPI_Session::get()->allOpenedDocuments();
-    }
-  }
-  // collect all documents involved into the update process
-  set<std::shared_ptr<ModelAPI_Object> >::iterator aFIter = myInitial.begin();
-  for (; aFIter != myInitial.end(); aFIter++) {
-    aDocs.push_back((*aFIter)->document());
-  }
-  // iterate all features of features-documents to update them (including hidden)
-  std::set<std::shared_ptr<ModelAPI_Document> > alreadyUsed;
-  list<std::shared_ptr<ModelAPI_Document> >::iterator aDIter = aDocs.begin();
-  for (; aDIter != aDocs.end(); aDIter++) {
-    if (alreadyUsed.find(*aDIter) != alreadyUsed.end())
-      continue;
-    alreadyUsed.insert(*aDIter);
-    int aNbFeatures = (*aDIter)->size(ModelAPI_Feature::group(), true);
-    for (int aFIndex = 0; aFIndex < aNbFeatures; aFIndex++) {
-      FeaturePtr aFeature = std::dynamic_pointer_cast<ModelAPI_Feature>(
-          (*aDIter)->object(ModelAPI_Feature::group(), aFIndex, true));
-      if (aFeature)
-        updateFeature(aFeature);
-    }
   }
+  // iterate all documents: features in Root first, then - subs
+  updateInDoc(ModelAPI_Session::get()->moduleDocument());
+
   myUpdated.clear();
   // flush to update display
   static Events_ID EVENT_DISP = aLoop->eventByName(EVENT_OBJECT_TO_REDISPLAY);
@@ -161,20 +141,58 @@ void Model_Update::processEvent(const std::shared_ptr<Events_Message>& theMessag
   isExecuted = false;
 }
 
-void Model_Update::redisplayWithResults(FeaturePtr theFeature) {
-  // maske updated and redisplay all results
+void Model_Update::updateInDoc(std::shared_ptr<ModelAPI_Document> theDoc)
+{
+  // all features one by one
+  int aNbFeatures = theDoc->size(ModelAPI_Feature::group(), true);
+  for (int aFIndex = 0; aFIndex < aNbFeatures; aFIndex++) {
+    FeaturePtr aFeature = std::dynamic_pointer_cast<ModelAPI_Feature>(
+        theDoc->object(ModelAPI_Feature::group(), aFIndex, true));
+    if (aFeature)
+      updateFeature(aFeature);
+  }
+  // all sub-documents one by one
+  std::shared_ptr<Model_Document> aDoc = std::dynamic_pointer_cast<Model_Document>(theDoc);
+  if (aDoc) {
+    const std::set<std::string>& aSubs = aDoc->subDocuments();
+    for(std::set<std::string>::iterator aSub = aSubs.begin(); aSub != aSubs.end(); aSub++) {
+      DocumentPtr aSubDoc = theDoc->subDocument(*aSub);
+      if (aSubDoc) {
+        updateInDoc(aSubDoc);
+      }
+    }
+  }
+}
+
+void Model_Update::redisplayWithResults(FeaturePtr theFeature, const ModelAPI_ExecState theState) 
+{
+  // make updated and redisplay all results
   static Events_ID EVENT_DISP = Events_Loop::loop()->eventByName(EVENT_OBJECT_TO_REDISPLAY);
   const std::list<std::shared_ptr<ModelAPI_Result> >& aResults = theFeature->results();
   std::list<std::shared_ptr<ModelAPI_Result> >::const_iterator aRIter = aResults.begin();
   for (; aRIter != aResults.cend(); aRIter++) {
     std::shared_ptr<ModelAPI_Result> aRes = *aRIter;
-    aRes->data()->mustBeUpdated(false);
+    aRes->data()->execState(theState);
     myUpdated[aRes] = true;
     ModelAPI_EventCreator::get()->sendUpdated(aRes, EVENT_DISP);
   }
   // to redisplay "presentable" feature (for ex. distance constraint)
   ModelAPI_EventCreator::get()->sendUpdated(theFeature, EVENT_DISP);
-  theFeature->data()->mustBeUpdated(false);
+  theFeature->data()->execState(theState);
+}
+
+/// Updates the state by the referenced object: if something bad with it, set state for this one
+ModelAPI_ExecState stateByReference(ObjectPtr theTarget, const ModelAPI_ExecState theCurrent)
+{
+  if (theTarget) {
+    ModelAPI_ExecState aRefState = theTarget->data()->execState();
+    if (aRefState == ModelAPI_StateMustBeUpdated) {
+      return ModelAPI_StateMustBeUpdated;
+    } else if (aRefState != ModelAPI_StateDone) {
+      return ModelAPI_StateInvalidArgument;
+    }
+  }
+  return theCurrent;
 }
 
 bool Model_Update::updateFeature(FeaturePtr theFeature)
@@ -186,7 +204,8 @@ bool Model_Update::updateFeature(FeaturePtr theFeature)
   ModelAPI_ValidatorsFactory* aFactory = ModelAPI_Session::get()->validators();
   bool aMustbeUpdated = myInitial.find(theFeature) != myInitial.end();
   if (theFeature) {  // only real feature contains references to other objects
-    if (theFeature->data()->mustBeUpdated()) aMustbeUpdated = true;
+    if (theFeature->data()->execState() != ModelAPI_StateDone)
+      aMustbeUpdated = true;
 
     // composite feature must be executed after sub-features execution
     CompositeFeaturePtr aComposite = 
@@ -198,7 +217,9 @@ bool Model_Update::updateFeature(FeaturePtr theFeature)
           aMustbeUpdated = true;
       }
     }
+    ModelAPI_ExecState aState = ModelAPI_StateDone;
     // check all references: if referenced objects are updated, this object also must be updated
+    // also check state of referenced objects: if they are not ready, inherit corresponding state
     std::list<std::pair<std::string, std::list<ObjectPtr> > > aRefs;
     std::shared_ptr<Model_Data> aData = 
       std::dynamic_pointer_cast<Model_Data>(theFeature->data());
@@ -210,6 +231,7 @@ bool Model_Update::updateFeature(FeaturePtr theFeature)
         if (updateObject(*aRefObj)) {
           aMustbeUpdated = true;
         }
+        aState = stateByReference(*aRefObj, aState);
       }
     }
 
@@ -219,71 +241,94 @@ bool Model_Update::updateFeature(FeaturePtr theFeature)
       if (std::dynamic_pointer_cast<Model_Document>(theFeature->document())->executeFeatures() ||
           !theFeature->isPersistentResult()) {
         if (aFactory->validate(theFeature)) {
-          if (isAutomatic || (myJustCreatedOrUpdated.find(theFeature) != myJustCreatedOrUpdated.end()) ||
-            !theFeature->isPersistentResult() /* execute quick, not persistent results */) 
+          if (isAutomatic || 
+              (myJustCreatedOrUpdated.find(theFeature) != myJustCreatedOrUpdated.end()) ||
+              !theFeature->isPersistentResult() /* execute quick, not persistent results */) 
           {
-            //std::cout<<"Execute feature "<<theFeature->getKind()<<std::endl;
-            // before execution update the selection attributes if any
-            list<AttributePtr> aRefs = 
-              theFeature->data()->attributes(ModelAPI_AttributeSelection::type());
-            list<AttributePtr>::iterator aRefsIter = aRefs.begin();
-            for (; aRefsIter != aRefs.end(); aRefsIter++) {
-              std::shared_ptr<ModelAPI_AttributeSelection> aSel =
-                std::dynamic_pointer_cast<ModelAPI_AttributeSelection>(*aRefsIter);
-              aSel->update(); // this must be done on execution since it may be long operation
-            }
-            aRefs = theFeature->data()->attributes(ModelAPI_AttributeSelectionList::type());
-            for (aRefsIter = aRefs.begin(); aRefsIter != aRefs.end(); aRefsIter++) {
-              std::shared_ptr<ModelAPI_AttributeSelectionList> aSel =
-                std::dynamic_pointer_cast<ModelAPI_AttributeSelectionList>(*aRefsIter);
-              for(int a = aSel->size() - 1; a >= 0; a--) {
-                  aSel->value(a)->update();
+            if (aState == ModelAPI_StateDone) {// all referenced objects are ready to be used
+              //std::cout<<"Execute feature "<<theFeature->getKind()<<std::endl;
+              // before execution update the selection attributes if any
+              list<AttributePtr> aRefs = 
+                theFeature->data()->attributes(ModelAPI_AttributeSelection::type());
+              list<AttributePtr>::iterator aRefsIter = aRefs.begin();
+              for (; aRefsIter != aRefs.end(); aRefsIter++) {
+                std::shared_ptr<ModelAPI_AttributeSelection> aSel =
+                  std::dynamic_pointer_cast<ModelAPI_AttributeSelection>(*aRefsIter);
+                if (!aSel->update()) { // this must be done on execution since it may be long operation
+                  if (!aFactory->isNotObligatory(theFeature->getKind(), theFeature->data()->id(aSel)))
+                    aState = ModelAPI_StateInvalidArgument;
+                }
               }
-            }
-            // for sketch after update of plane (by update of selection attribute)
-            // but before execute, all sub-elements also must be updated (due to the plane changes)
-            if (aComposite) {
-              int aSubsNum = aComposite->numberOfSubs();
-              for(int a = 0; a < aSubsNum; a++) {
-                FeaturePtr aSub = aComposite->subFeature(a);
-                bool aWasModified = myUpdated[aSub];
-                myUpdated.erase(myUpdated.find(aSub)); // erase to update for sure (plane may be changed)
-                myInitial.insert(aSub);
-                updateFeature(aSub);
-                myUpdated[aSub] = aWasModified; // restore value
+              aRefs = theFeature->data()->attributes(ModelAPI_AttributeSelectionList::type());
+              for (aRefsIter = aRefs.begin(); aRefsIter != aRefs.end(); aRefsIter++) {
+                std::shared_ptr<ModelAPI_AttributeSelectionList> aSel =
+                  std::dynamic_pointer_cast<ModelAPI_AttributeSelectionList>(*aRefsIter);
+                for(int a = aSel->size() - 1; a >= 0; a--) {
+                  std::shared_ptr<ModelAPI_AttributeSelection> aSelAttr =
+                    std::dynamic_pointer_cast<ModelAPI_AttributeSelection>(aSel->value(a));
+                  if (aSelAttr) {
+                    if (!aSelAttr->update()) {
+                      if (!aFactory->isNotObligatory(
+                          theFeature->getKind(), theFeature->data()->id(aSel)))
+                        aState = ModelAPI_StateInvalidArgument;
+                    }
+                  }
+                }
               }
-              // re-execute after update: solver may update the previous values, so, shapes must be
-              // updated
-              for(int a = 0; a < aSubsNum; a++) {
-                if (aComposite->subFeature(a) && aFactory->validate(aComposite->subFeature(a)))
-                  aComposite->subFeature(a)->execute();
+              // for sketch after update of plane (by update of selection attribute)
+              // but before execute, all sub-elements also must be updated (due to the plane changes)
+              if (aComposite) {
+                int aSubsNum = aComposite->numberOfSubs();
+                for(int a = 0; a < aSubsNum; a++) {
+                  FeaturePtr aSub = aComposite->subFeature(a);
+                  bool aWasModified = myUpdated[aSub];
+                  myUpdated.erase(myUpdated.find(aSub)); // erase to update for sure (plane may be changed)
+                  myInitial.insert(aSub);
+                  updateFeature(aSub);
+                  myUpdated[aSub] = aWasModified; // restore value
+                }
+                // re-execute after update: solver may update the previous values, so, shapes must be
+                // updated
+                for(int a = 0; a < aSubsNum; a++) {
+                  if (aComposite->subFeature(a) && aFactory->validate(aComposite->subFeature(a)))
+                    aComposite->subFeature(a)->execute();
+                }
               }
             }
 
             // execute in try-catch to avoid internal problems of the feature
-            try {
-              theFeature->execute();
-            } catch(...) {
-              Events_Error::send(
-                "Feature " + theFeature->getKind() + " has failed during the execution");
+            if (aState == ModelAPI_StateDone) {
+              theFeature->data()->execState(ModelAPI_StateDone);
+              try {
+                theFeature->execute();
+                if (theFeature->data()->execState() != ModelAPI_StateDone) {
+                  aState = ModelAPI_StateExecFailed;
+                }
+              } catch(...) {
+                aState = ModelAPI_StateExecFailed;
+                Events_Error::send(
+                  "Feature " + theFeature->getKind() + " has failed during the execution");
+              }
+            }
+            if (aState != ModelAPI_StateDone) {
               theFeature->eraseResults();
             }
-            redisplayWithResults(theFeature);
+            redisplayWithResults(theFeature, aState);
           } else { // must be updatet, but not updated yet
-            theFeature->data()->mustBeUpdated(true);
+            theFeature->data()->execState(ModelAPI_StateMustBeUpdated);
             const std::list<std::shared_ptr<ModelAPI_Result> >& aResults = theFeature->results();
             std::list<std::shared_ptr<ModelAPI_Result> >::const_iterator aRIter = aResults.begin();
             for (; aRIter != aResults.cend(); aRIter++) {
               std::shared_ptr<ModelAPI_Result> aRes = *aRIter;
-              aRes->data()->mustBeUpdated(true);
+              aRes->data()->execState(ModelAPI_StateMustBeUpdated);
             }
           }
         } else {
           theFeature->eraseResults();
-          redisplayWithResults(theFeature); // result also must be updated
+          redisplayWithResults(theFeature, ModelAPI_StateInvalidArgument); // result also must be updated
         }
       } else { // for automatically updated features (on abort, etc) it is necessary to redisplay anyway
-        redisplayWithResults(theFeature);
+        redisplayWithResults(theFeature, ModelAPI_StateNothing);
       }
     } else {
       // returns also true is results were updated: for sketch that 
index 31d532da516fe38bd0ece5048025097635ed8b4b..a9a7bfee82e50711e447953cac2d8df2e063a309 100644 (file)
@@ -1,3 +1,5 @@
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
 // File:        Model_Update.hxx
 // Created:     25 Jun 2014
 // Author:      Mikhail PONIKAROV
@@ -6,6 +8,7 @@
 #define Model_Update_H_
 
 #include "Model.h"
+#include <ModelAPI_Data.h>
 #include "Events_Listener.h"
 #include <memory>
 #include <set>
@@ -39,7 +42,9 @@ class Model_Update : public Events_Listener
   /// Processes the feature argument update: executes the results
   MODEL_EXPORT virtual void processEvent(const std::shared_ptr<Events_Message>& theMessage);
 
- protected:
+protected:
+  /// updates all features in the document and then - in sub-documents
+  void updateInDoc(std::shared_ptr<ModelAPI_Document> theDoc);
   /// Recoursively checks and updates the feature if needed (calls the execute method)
   /// Returns true if feature was updated.
   bool updateFeature(std::shared_ptr<ModelAPI_Feature> theFeature);
@@ -48,7 +53,8 @@ class Model_Update : public Events_Listener
   /// Returns true if object was updated.
   bool updateObject(std::shared_ptr<ModelAPI_Object> theObject, const bool theCyclic = true);
   /// Sends the redisplay events for feature and results, updates the updated status
-  void redisplayWithResults(std::shared_ptr<ModelAPI_Feature> theFeature);
+  void redisplayWithResults(std::shared_ptr<ModelAPI_Feature> theFeature, 
+    const ModelAPI_ExecState theState);
 };
 
 #endif
index cc3a612a50d19752eae437181a03df9d3122bf75..c2c994da9cd65dc1b194115c8250aa524760ae1c 100644 (file)
@@ -1,3 +1,5 @@
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
 // File:        Model_Validator.cpp
 // Created:     2 Jul 2014
 // Author:      Mikhail PONIKAROV
@@ -88,7 +90,7 @@ void Model_ValidatorsFactory::validators(const std::string& theFeatureID,
       }
     }
   }
-  addDefaultValidators(theResult);
+  addDefaultValidators(theResult, theArguments);
 }
 
 void Model_ValidatorsFactory::validators(const std::string& theFeatureID,
@@ -132,13 +134,15 @@ const ModelAPI_Validator* Model_ValidatorsFactory::validator(const std::string&
   return NULL;
 }
 
-void Model_ValidatorsFactory::addDefaultValidators(std::list<ModelAPI_Validator*>& theValidators) const
+void Model_ValidatorsFactory::addDefaultValidators(std::list<ModelAPI_Validator*>& theValidators,
+  std::list<std::list<std::string> >& theArguments) const
 {
   const static std::string kDefaultId = "Model_FeatureValidator";
   std::map<std::string, ModelAPI_Validator*>::const_iterator it = myIDs.find(kDefaultId);
   if(it == myIDs.end())
     return;
   theValidators.push_back(it->second);
+  theArguments.push_back(std::list<std::string>());
 }
 
 bool Model_ValidatorsFactory::validate(const std::shared_ptr<ModelAPI_Feature>& theFeature) const
@@ -175,10 +179,12 @@ bool Model_ValidatorsFactory::validate(const std::shared_ptr<ModelAPI_Feature>&
         return false;
     }
   }
+  
   // check all attributes for validity
   std::shared_ptr<ModelAPI_Data> aData = theFeature->data();
-  if (!aData || !aData->isValid())
-    return false;
+  // Validity of data is checked by "Model_FeatureValidator" (kDefaultId)
+  // if (!aData || !aData->isValid())
+  //   return false;
   static const std::string kAllTypes = "";
   std::map<std::string, std::map<std::string, AttrValidators> >::const_iterator aFeatureIter = 
     myAttrs.find(theFeature->getKind());
@@ -224,6 +230,19 @@ void Model_ValidatorsFactory::registerNotObligatory(std::string theFeature, std:
   }
 }
 
+bool Model_ValidatorsFactory::isNotObligatory(std::string theFeature, std::string theAttribute)
+{
+  const static std::string kDefaultId = "Model_FeatureValidator";
+  std::map<std::string, ModelAPI_Validator*>::const_iterator it = myIDs.find(kDefaultId);
+  if (it != myIDs.end()) {
+    Model_FeatureValidator* aValidator = dynamic_cast<Model_FeatureValidator*>(it->second);
+    if (aValidator) {
+      return aValidator->isNotObligatory(theFeature, theAttribute);
+    }
+  }
+  return false; // default
+}
+
 void Model_ValidatorsFactory::registerConcealment(std::string theFeature, std::string theAttribute)
 {
   std::map<std::string, std::set<std::string> >::iterator aFind = myConcealed.find(theFeature);
index a6d36996360610ee46f5b983752d6eda01ce79f2..e2f67b617dde97fb7a9024be9d37217d8a2fd95b 100644 (file)
@@ -1,3 +1,5 @@
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
 // File:        Model_Validator.hxx
 // Created:     2 Jul 2014
 // Author:      Mikhail PONIKAROV
@@ -76,6 +78,9 @@ class Model_ValidatorsFactory : public ModelAPI_ValidatorsFactory
   /// so, it is not needed for the standard validation mechanism
   virtual void registerNotObligatory(std::string theFeature, std::string theAttribute);
 
+  /// Returns true if the attribute in feature is not obligatory for the feature execution
+  virtual bool isNotObligatory(std::string theFeature, std::string theAttribute);
+
   /// register that this attribute conceals in the object browser
   /// all referenced features after execution
   virtual void registerConcealment(std::string theFeature, std::string theAttribute);
@@ -84,7 +89,8 @@ class Model_ValidatorsFactory : public ModelAPI_ValidatorsFactory
   virtual bool isConcealed(std::string theFeature, std::string theAttribute);
 
 protected:
-  void addDefaultValidators(std::list<ModelAPI_Validator*>& theValidators) const;
+  void addDefaultValidators(std::list<ModelAPI_Validator*>& theValidators,
+                            std::list<std::list<std::string> >& theArguments) const;
   /// Get instance from Session
   Model_ValidatorsFactory();
 
index 20d4ec1071f692400ca807392f7ccf2452990f4b..e30ddf142f04d85ffa7d5271d29ac62228068689 100644 (file)
@@ -1,3 +1,5 @@
+## Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
 FIND_PACKAGE(SWIG REQUIRED)
 INCLUDE(${SWIG_USE_FILE})
 INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR})
@@ -39,6 +41,7 @@ SET(PROJECT_HEADERS
 )
 
 SET(PROJECT_SOURCES
+    ModelAPI_Events.cpp
     ModelAPI_Feature.cpp
     ModelAPI_Session.cpp
     ModelAPI_Tools.cpp
@@ -90,4 +93,5 @@ INSTALL(TARGETS ModelAPI DESTINATION bin)
 INSTALL(FILES ${SWIG_SCRIPTS} DESTINATION swig)
 
 ADD_UNIT_TESTS(TestConstants.py
-               TestUndoRedo.py)
+               TestUndoRedo.py
+               TestDocument.py)
index b9e811215c59bf142f5338ac8cdd8fa865246cf1..d97d7666c95ec9350f24946233f002f0278ed50f 100644 (file)
@@ -1,3 +1,5 @@
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
 #ifndef MODELAPI_H
 #define MODELAPI_H
 
index 5c97aeb4cbab2f1931fa902a411d4eba68f7b1b6..bdf6c28e52b440c0161f3fd7a0010419d974c8d9 100644 (file)
 %include "ModelAPI_ResultParameters.h"
 %include "ModelAPI_Tools.h"
 
+// std::list -> [] 
 %template(ObjectList) std::list<std::shared_ptr<ModelAPI_Object> >;
 %template(ResultList) std::list<std::shared_ptr<ModelAPI_Result> >;
+%template(DocumentList) std::list<std::shared_ptr<ModelAPI_Document> >;
 
+// std::dynamic_pointer_cast
 template<class T1, class T2> std::shared_ptr<T1> shared_ptr_cast(std::shared_ptr<T2> theObject);
 %template(modelAPI_CompositeFeature) shared_ptr_cast<ModelAPI_CompositeFeature, ModelAPI_Feature>;
 %template(modelAPI_Feature) shared_ptr_cast<ModelAPI_Feature, ModelAPI_Object>;
-// Result casts
+
 %template(modelAPI_Result) shared_ptr_cast<ModelAPI_Result, ModelAPI_Object>;
 %template(modelAPI_ResultConstruction) shared_ptr_cast<ModelAPI_ResultConstruction, ModelAPI_Result>;
 %template(modelAPI_ResultBody) shared_ptr_cast<ModelAPI_ResultBody, ModelAPI_Result>;
 %template(modelAPI_ResultPart) shared_ptr_cast<ModelAPI_ResultPart, ModelAPI_Result>;
+%template(modelAPI_ResultGroup) shared_ptr_cast<ModelAPI_ResultPart, ModelAPI_ResultGroup>;
 
 // Attribute casts
 %template(modelAPI_AttributeDocRef)        shared_ptr_cast<ModelAPI_AttributeDocRef, ModelAPI_Attribute>;
index 27d65eb9b69eb8bc96b6ac5da4b680a5fb55acad..a8abce8b855e18ecdabcb40ac9d68bfce8c3d71f 100644 (file)
@@ -1,3 +1,5 @@
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
 // File:        ModelAPI_Attribute.h
 // Created:     2 Apr 2014
 // Author:      Mikhail PONIKAROV
@@ -19,11 +21,12 @@ class ModelAPI_Attribute
 {
   ///< needed here to emit signal that feature changed on change of the attribute
   std::shared_ptr<ModelAPI_Object> myObject;
+  std::string myID; ///< identifier of this attribute in Data class
  protected:
   // accessible from the attributes
-  bool myIsInitialized;
-  bool myIsArgument;
-  bool myIsImmutable;
+  bool myIsInitialized; ///< is some value assigned to this attribute
+  bool myIsArgument;    ///< is this attribute used as an argument for execution
+  bool myIsImmutable;   ///< is this attribute can be changed programmatically (e.g. by constraint)
 
  public:
 
@@ -88,6 +91,12 @@ class ModelAPI_Attribute
     return myIsImmutable;
   }
 
+  /// ID of the attribute in Data
+  MODELAPI_EXPORT const std::string& id() const
+  {
+    return myID;
+  }
+
  protected:
   /// Objects are created for features automatically
   ModelAPI_Attribute()
@@ -97,6 +106,13 @@ class ModelAPI_Attribute
     myIsImmutable = false;
   }
 
+  /// Sets the ID of the attribute in Data (called from Data)
+  MODELAPI_EXPORT void setID(const std::string theID)
+  {
+    myID = theID;
+  }
+
+  friend class Model_Data;
 };
 
 //! Pointer on attribute object
index 23c8f2403aab2cbd87330e40b42f99f6824842c9..d7b9bac82db182c08b7b17aa23012445f6fd193d 100644 (file)
@@ -1,3 +1,5 @@
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
 // File:        ModelAPI_AttributeBoolean.h
 // Created:     2 june 2014
 // Author:      Vitaly Smetannikov
index b7c4bbcdfc42a20d0875000532a232912bfb50a5..61c0c7b7f61a5f34c565b46b9dc2c19ca868810b 100644 (file)
@@ -1,3 +1,5 @@
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
 // File:        ModelAPI_AttributeDocRef.h
 // Created:     2 Apr 2014
 // Author:      Mikhail PONIKAROV
index 670c7f0892d24b756409625c4f09d9eebb7d2d70..121af02a5c083985ebcf3bf46bb1c5f604b456d8 100644 (file)
@@ -1,3 +1,5 @@
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
 // File:        ModelAPI_AttributeDouble.h
 // Created:     2 Apr 2014
 // Author:      Mikhail PONIKAROV
index 16e70ee663d4647cb51646501b15dacebe8fbd93..676352b1977fa5a87bee53f2fcdb8f4928d748d3 100644 (file)
@@ -1,3 +1,5 @@
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
 // File:        ModelAPI_AttributeInteger.h
 // Created:     2 Apr 2014
 // Author:      Mikhail PONIKAROV
index b1e9ad2332337c43954d59ca752b4b13423c5e91..bfbd03ff6f0c89a8f8a7380244a292fceda5f14f 100644 (file)
@@ -1,3 +1,5 @@
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
 // File:        ModelAPI_AttributeRefAttr.h
 // Created:     8 May 2014
 // Author:      Mikhail PONIKAROV
index 3036cc9704b629c4202960f34c963c16981e65d8..513404266b2a48278cd4b1dc306e1ccac4914564 100644 (file)
@@ -1,3 +1,5 @@
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
 // File:        ModelAPI_AttributeRefList.h
 // Created:     8 May 2014
 // Author:      Mikhail PONIKAROV
index 25508af859c37eef477b1d7b243baef8a4b9a595..3f02aa9170823e66201ace4a2ae3fb6b156a5002 100644 (file)
@@ -1,3 +1,5 @@
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
 // File:        ModelAPI_AttributeReference.h
 // Created:     8 May 2014
 // Author:      Mikhail PONIKAROV
index 80335f2179da458b55c2d71ccc0e915641991187..600a9820448d4dc79ec1079ad1cb12a7ec83cc4a 100644 (file)
@@ -1,3 +1,5 @@
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
 // File:        ModelAPI_AttributeSelection.h
 // Created:     2 Oct 2014
 // Author:      Mikhail PONIKAROV
index 37647df68f790e22247b873a49d8dbd6f6b43872..fec280f37ece835150537c58ec98a6e44d01ffd7 100644 (file)
@@ -1,3 +1,5 @@
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
 // File:        ModelAPI_AttributeSelectionList.h
 // Created:     22 Oct 2014
 // Author:      Mikhail PONIKAROV
@@ -18,8 +20,8 @@ class ModelAPI_AttributeSelectionList : public ModelAPI_Attribute
 {
  public:
   /// Adds the new reference to the end of the list
-  virtual void append(
-    const ResultPtr& theContext, const std::shared_ptr<GeomAPI_Shape>& theSubShape) = 0;
+  virtual void append(const ResultPtr& theContext,
+                      const GeomShapePtr& theSubShape) = 0;
 
   /// Returns the number ofselection attributes in the list
   virtual int size() = 0;
index a111ba388fd1cb2de419e2cbdde796fd6008e17e..26f740113b5b4b055c10ac7bd12f4152e9a34f06 100644 (file)
@@ -1,3 +1,5 @@
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
 // File:        ModelAPI_AttributeString.h
 // Created:     2 Apr 2014
 // Author:      Mikhail PONIKAROV
index aa0680cbb5311c5939590d570595af06697c7765..f059b9c659d4571ff5f03ed0b061bdd81c1a87a4 100644 (file)
@@ -1,3 +1,5 @@
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
 // File:        ModelAPI_AttributeValidator.h
 // Created:     4 Sep 2014
 // Author:      Mikhail PONIKAROV
index e21a6aa090c128042a492607b5af0691e769111d..3498b8fb1c0d714c2cde47218c9bcf12e915ca0e 100644 (file)
@@ -1,3 +1,5 @@
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
 // File:        ModelAPI_CompositeFeature.hxx
 // Created:     20 Oct 2014
 // Author:      Mikhail PONIKAROV
index 8cc137477029665743eee48b877600859cb118bc..14d191b08bb4556e9cca2264e68dc34ff07f6829 100644 (file)
@@ -1,3 +1,5 @@
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
 // File:        ModelAPI_Data.hxx
 // Created:     21 Mar 2014
 // Author:      Mikhail PONIKAROV
@@ -26,6 +28,15 @@ class ModelAPI_AttributeSelection;
 class ModelAPI_AttributeSelectionList;
 class GeomAPI_Shape;
 
+/// Enumeration that contains the execution status of the Object
+enum ModelAPI_ExecState {
+  ModelAPI_StateDone, ///< execution was performed and result is up to date
+  ModelAPI_StateMustBeUpdated, ///< execution must be performed to obtain the up to date result
+  ModelAPI_StateExecFailed, ///< execution was failed (results are deleted in this case)
+  ModelAPI_StateInvalidArgument, ///< execution was not performed (results are deleted in this case)
+  ModelAPI_StateNothing ///< internal state that actually means that nothing must be changed
+};
+
 /**\class ModelAPI_Data
  * \ingroup DataModel
  * \brief General object of the application that allows
@@ -100,12 +111,14 @@ class MODELAPI_EXPORT ModelAPI_Data
   {
   }
 
-  /// Makes feature must be updated later (on rebuild). Normally the Updater must call it
-  /// in case of not-automatic update to true
-  virtual void mustBeUpdated(const bool theFlag) = 0;
+  /// Stores the state of the object to execute it later accordingly
+  virtual void execState(const ModelAPI_ExecState theState) = 0;
+
+  /// Returns the state of the latest execution of the feature
+  virtual ModelAPI_ExecState execState() = 0;
 
-  /// Returns true if feature must be updated (re-executed) on rebuild
-  virtual bool mustBeUpdated() = 0;
+  /// Registers error during the execution, causes the ExecutionFailed state
+  virtual void setError(const std::string& theError) = 0;
 
   /// Returns the identifier of feature-owner, unique in this document
   virtual int featureId() const = 0;
index 84439e6863d466b7b27a6ba3e816c43b031e3c66..99311a6281a3cada2df4f015d19d6d6a3d7debf4 100644 (file)
@@ -1,3 +1,5 @@
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
 // File:        ModelAPI_Document.cxx
 // Created:     28 Feb 2014
 // Author:      Mikhail PONIKAROV
diff --git a/src/ModelAPI/ModelAPI_Events.cpp b/src/ModelAPI/ModelAPI_Events.cpp
new file mode 100644 (file)
index 0000000..447019a
--- /dev/null
@@ -0,0 +1,86 @@
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
+/*
+ * ModelAPI_Events.cpp
+ *
+ *  Created on: Dec 8, 2014
+ *      Author: sbh
+ */
+
+#include <ModelAPI.h>
+#include <ModelAPI_Events.h>
+
+ModelAPI_ObjectUpdatedMessage::ModelAPI_ObjectUpdatedMessage(const Events_ID theID,
+                                                             const void* theSender)
+    : Events_MessageGroup(theID, theSender)
+{
+
+}
+
+ModelAPI_ObjectUpdatedMessage::~ModelAPI_ObjectUpdatedMessage()
+{
+
+}
+
+ModelAPI_ObjectDeletedMessage::ModelAPI_ObjectDeletedMessage(const Events_ID theID,
+                                                             const void* theSender)
+    : Events_MessageGroup(theID, theSender)
+{
+
+}
+
+ModelAPI_ObjectDeletedMessage::~ModelAPI_ObjectDeletedMessage()
+{
+
+}
+
+ModelAPI_FeatureStateMessage::ModelAPI_FeatureStateMessage(const Events_ID theID,
+                                                           const void* theSender)
+ : Events_Message(theID, theSender)
+{
+  myCurrentFeature = std::shared_ptr<ModelAPI_Feature>();
+}
+
+ModelAPI_FeatureStateMessage::~ModelAPI_FeatureStateMessage()
+{
+
+}
+
+std::shared_ptr<ModelAPI_Feature> ModelAPI_FeatureStateMessage::feature() const
+{
+  return myCurrentFeature;
+}
+
+void ModelAPI_FeatureStateMessage::setFeature(std::shared_ptr<ModelAPI_Feature>& theFeature)
+{
+  myCurrentFeature = theFeature;
+}
+
+bool ModelAPI_FeatureStateMessage::hasState(const std::string& theKey) const
+{
+  return myFeatureState.find(theKey) != myFeatureState.end();
+}
+
+bool ModelAPI_FeatureStateMessage::state(const  std::string& theFeatureId, bool theDefault) const
+{
+  if(hasState(theFeatureId)) {
+    return myFeatureState.at(theFeatureId);
+  }
+  return theDefault;
+}
+
+void ModelAPI_FeatureStateMessage::setState(const std::string& theFeatureId, bool theValue)
+{
+  myFeatureState[theFeatureId] = theValue;
+}
+
+std::list<std::string> ModelAPI_FeatureStateMessage::features() const
+{
+  std::list<std::string> result;
+  std::map<std::string, bool>::const_iterator it = myFeatureState.begin();
+  for( ; it != myFeatureState.end(); ++it) {
+    result.push_back(it->first);
+  }
+  return result;
+}
+
index 9141c146c77797186cedd851dbacfeed9095a83f..26441f25336f9115398f9ea8bc68a88f1475e75c 100644 (file)
@@ -1,17 +1,22 @@
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
 // File:        ModelAPI_Events.h
 // Created:     10 Apr 2014
 // Author:      Mikhail PONIKAROV
 
-#ifndef ModelAPI_Events_H_
-#define ModelAPI_Events_H_
+#ifndef MODELAPI_EVENTS_H_
+#define MODELAPI_EVENTS_H_
 
 #include <ModelAPI.h>
+#include <ModelAPI_Object.h>
+#include <ModelAPI_Feature.h>
 #include <Events_MessageGroup.h>
+
 #include <memory>
 #include <string>
 #include <set>
+#include <map>
 
-#include "ModelAPI_Object.h"
 
 class ModelAPI_Document;
 
@@ -34,14 +39,15 @@ static const char * EVENT_OBJECT_TOSHOW = "ObjectShow";
 /// Event ID that data of feature has to be shown (comes with ModelAPI_ObjectUpdatedMessage)
 static const char * EVENT_OBJECT_TOHIDE = "ObjectHide";
 
+static const char * EVENT_FEATURE_STATE_REQUEST = "FeatureStateRequest";
+static const char * EVENT_FEATURE_STATE_RESPONSE = "FeatureStateResponse";
+
 /// Message that feature was changed (used for Object Browser update): moved, updated and deleted
-class ModelAPI_ObjectUpdatedMessage : public Events_MessageGroup
+class MODELAPI_EXPORT ModelAPI_ObjectUpdatedMessage : public Events_MessageGroup
 {
  protected:
-  ModelAPI_ObjectUpdatedMessage(const Events_ID theID, const void* theSender = 0)
-      : Events_MessageGroup(theID, theSender)
-  {
-  }
+  ModelAPI_ObjectUpdatedMessage(const Events_ID theID, const void* theSender = 0);
+  virtual ~ModelAPI_ObjectUpdatedMessage();
 
  public:
   /// Returns the feature that has been updated
@@ -55,13 +61,11 @@ class ModelAPI_ObjectUpdatedMessage : public Events_MessageGroup
 };
 
 /// Message that feature was deleted (used for Object Browser update)
-class ModelAPI_ObjectDeletedMessage : public Events_MessageGroup
+class MODELAPI_EXPORT ModelAPI_ObjectDeletedMessage : public Events_MessageGroup
 {
  protected:
-  ModelAPI_ObjectDeletedMessage(const Events_ID theID, const void* theSender = 0)
-      : Events_MessageGroup(theID, theSender)
-  {
-  }
+  ModelAPI_ObjectDeletedMessage(const Events_ID theID, const void* theSender = 0);
+  virtual ~ModelAPI_ObjectDeletedMessage();
 
  public:
   /// Returns the feature that has been updated
@@ -95,4 +99,27 @@ class MODELAPI_EXPORT ModelAPI_EventCreator
   static void set(const ModelAPI_EventCreator* theCreator);
 };
 
+// TODO(sbh): Move this message into a separate package, like "GuiAPI"
+class ModelAPI_FeatureStateMessage : public Events_Message
+{
+ public:
+  MODELAPI_EXPORT ModelAPI_FeatureStateMessage(const Events_ID theID, const void* theSender = 0);
+  MODELAPI_EXPORT virtual ~ModelAPI_FeatureStateMessage();
+
+  // For request
+  MODELAPI_EXPORT std::shared_ptr<ModelAPI_Feature> feature() const;
+  MODELAPI_EXPORT void setFeature(std::shared_ptr<ModelAPI_Feature>& theFeature);
+  // For response
+  MODELAPI_EXPORT bool hasState(const std::string& theFeatureId) const;
+  MODELAPI_EXPORT bool state(const  std::string& theFeatureId, bool theDefault = false) const;
+  MODELAPI_EXPORT void setState(const std::string& theFeatureId, bool theValue);
+  MODELAPI_EXPORT std::list<std::string> features() const;
+
+ private:
+  // For Request
+  std::shared_ptr<ModelAPI_Feature> myCurrentFeature;
+  // For response
+  std::map<std::string, bool> myFeatureState;
+};
+
 #endif
index 5be82475ee0c95045f61916a32f3d25bdf32dc45..65cfa361ed3e8645cbf3812d45a90d83f5e31f68 100644 (file)
@@ -1,3 +1,5 @@
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
 // File:        ModelAPI_Feature.cpp
 // Created:     17 Jul 2014
 // Author:      Mikhail PONIKAROV
index 431b065b77f2d76d26d696ba16bbd75b6f9191da..452686cdb20906749a9c312f2a720c0a32121adc 100644 (file)
@@ -1,3 +1,5 @@
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
 // File:        ModelAPI_Feature.hxx
 // Created:     21 Mar 2014
 // Author:      Mikhail PONIKAROV
@@ -53,6 +55,11 @@ class ModelAPI_Feature : public ModelAPI_Object
   /// Computes or recomputes the results
   virtual void execute() = 0;
 
+  /// Registers error during the execution, causes the ExecutionFailed state
+  virtual void setError(const std::string& theError) {
+    data()->setError(theError);
+  }
+
   /// returns the current results of the feature
   MODELAPI_EXPORT const std::list<std::shared_ptr<ModelAPI_Result> >& results();
   /// returns the first result in the list or NULL reference
index 6d44a735a14f1dceb09c2223c76079a1f642322c..85e06609c6f3facdd654fee13edd8cf82b406cbd 100644 (file)
@@ -1,3 +1,5 @@
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
 // File:        ModelAPI_FeatureValidator.h
 // Created:     8 Jul 2014
 // Author:      Vitaly SMETANNIKOV
@@ -17,6 +19,9 @@ class ModelAPI_FeatureValidator : public ModelAPI_Validator
   /// \param theArguments list of string, feature attribute names: dependent attributes
   virtual bool isValid(const std::shared_ptr<ModelAPI_Feature>& theFeature,
     const std::list<std::string>& theArguments) const = 0;
+
+  /// Returns true if the attribute in feature is not obligatory for the feature execution
+  virtual bool isNotObligatory(std::string theFeature, std::string theAttribute) = 0;
 };
 
 #endif
index 40f1b236ce11d4f836525cc88ab70f079b7cca90..26bc4681946fdd4665ee4432f3d35146148746b5 100644 (file)
@@ -1,3 +1,5 @@
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
 // File:        ModelAPI_Object.cpp
 // Created:     19 May 2014
 // Author:      Mikhail PONIKAROV
index be488054077184cc2dc006ff80bd358387f635ce..6d8aeaec8f82869cf259908aacb9bbb8cdcdf779 100644 (file)
@@ -1,3 +1,5 @@
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
 // File:        ModelAPI_Object.hxx
 // Created:     19 May 2014
 // Author:      Mikhail PONIKAROV
@@ -55,7 +57,8 @@ class ModelAPI_Object
   virtual std::string groupName() = 0;
 
   /// Called on change of any argument-attribute of this object
-  MODELAPI_EXPORT virtual void attributeChanged() 
+  /// \param theID identifier of changed attribute
+  MODELAPI_EXPORT virtual void attributeChanged(const std::string& theID) 
   {}
 
   /// To use virtuality for destructors
index 5b107d5a4730287c40d55d5c004a75887baa06da..b23bf3f1244d42e7def9a94af7afd743a97e4d9c 100644 (file)
@@ -1,3 +1,5 @@
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
 // File:        ModelAPI_Plugin.hxx
 // Created:     31 Mar 2014
 // Author:      Mikhail PONIKAROV
index 1f690ca47445e1597ca3584946a7fa14a6eda265..1e4d7bdddad8a029542f0a4fb04b14b9003ef880 100644 (file)
@@ -1,3 +1,5 @@
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
 // File:        ModelAPI_RefAttrValidator.h
 // Created:     5 Aug 2014
 // Author:      Vitaly SMETANNIKOV
index 0968507029e8fd55ad477471aa6006306fa73477..743c0367b43b3ea5e7dd7e4202768752f96d0e2d 100644 (file)
@@ -1,3 +1,5 @@
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
 // File:        ModelAPI_Result.cpp
 // Created:     07 Jul 2014
 // Author:      Mikhail PONIKAROV
index 91304744e457755086d2b4a93fb78722b0a24b76..c354ed3a3c2d821c4db457e006d6cbdd0d40122d 100644 (file)
@@ -1,3 +1,5 @@
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
 // File:        ModelAPI_Result.hxx
 // Created:     07 Jul 2014
 // Author:      Mikhail PONIKAROV
@@ -6,7 +8,7 @@
 #define ModelAPI_Result_H_
 
 #include "ModelAPI_Object.h"
-#include "GeomAPI_Shape.h"
+#include <GeomAPI_Shape.h>
 
 class ModelAPI_Feature;
 
index 98350ce37d57e9335c1272ed5eb41b06eb68c2b3..9a2053abcdce276371be600ada2a74511ea48a56 100644 (file)
@@ -1,3 +1,5 @@
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
 // File:        ModelAPI_ResultBody.hxx
 // Created:     07 Jul 2014
 // Author:      Mikhail PONIKAROV
index a431c8472370683f6482e11ef7f265469a4ac11b..1092c4a9c1f20124ae9a2471dd40bf72e2bb0a65 100644 (file)
@@ -1,3 +1,5 @@
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
 // File:        ModelAPI_ResultConstruction.h
 // Created:     07 Jul 2014
 // Author:      Mikhail PONIKAROV
index 063421599c301ac4e08462437e7d01f41d650d87..8e55134ef7feb0e34f7ea9612d7fe495d2938624 100644 (file)
@@ -1,3 +1,5 @@
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
 // File:        ModelAPI_ResultGroup.hxx
 // Created:     07 Jul 2014
 // Author:      Mikhail PONIKAROV
index 2023a7da207649626164a656856abe32219bed2f..f9ed62ecb62c8be72018bc9cb91ed137bd83d580 100644 (file)
@@ -1,3 +1,5 @@
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
 // File:        ModelAPI_ResultParameters.h
 // Created:     07 Jul 2014
 // Author:      Vitaly SMETANNIKOV
index f0db94ee31b44cc9a6fd52207d1c5016020e68a2..64be92e3cea9428496ff22a7eeaa11c185c5c0e4 100644 (file)
@@ -1,3 +1,5 @@
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
 // File:        ModelAPI_ResultPart.h
 // Created:     07 Jul 2014
 // Author:      Mikhail PONIKAROV
index b18709a144a7a5e0e7195c586e43c8cf2269fad3..f106d96dd0909fef860e8971fd8eac042df04fde 100644 (file)
@@ -1,3 +1,5 @@
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
 // File:        ModelAPI_ResultValidators.h
 // Created:     23 July 2014
 // Author:      Vitaly SMETANNIKOV
index 29c251031c4d43bf25fa7663dbd09b277b849b83..946096f28cd658795b5a0f204c3f3924e07247d5 100644 (file)
@@ -1,3 +1,5 @@
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
 // File:        ModelAPI_Session.hxx
 // Created:     20 Mar 2014
 // Author:      Mikhail PONIKAROV
index 02449b6ce8c60b3eb412087dcea9a6516ce051e0..f3ebb3d00aa4c5bdd4bf419c1b411f64e8b5c2fb 100644 (file)
@@ -1,3 +1,5 @@
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
 // File:        ModelAPI_Session.hxx
 // Created:     20 Mar 2014
 // Author:      Mikhail PONIKAROV
@@ -71,6 +73,9 @@ class MODELAPI_EXPORT ModelAPI_Session
   /// Returns the root document of the application (that may contains sub-documents)
   virtual std::shared_ptr<ModelAPI_Document> moduleDocument() = 0;
 
+  /// Returns the document by ID, loads if not loaded yet. Returns null if no such document.
+  virtual std::shared_ptr<ModelAPI_Document> document(std::string theDocID) = 0;
+
   /// Return true if root document has been already created
   virtual bool hasModuleDocument() = 0;
 
index 8f91a914a817017d52e46bd453eba7a8627e1d47..27a5fdde28540730509b7955d790908bbdfc4342 100644 (file)
@@ -1,3 +1,5 @@
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
 // File:        ModelAPI_Tools.cpp
 // Created:     06 Aug 2014
 // Author:      Vitaly Smetannikov
index 5fce98955aed466bc43e23bcaf695532cad9a82d..3804c3c0673f05c12e4ed3c8150f32c90877b1be 100644 (file)
@@ -1,3 +1,5 @@
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
 // File:        ModelAPI_Tools.h
 // Created:     06 Aug 2014
 // Author:      Vitaly Smetannikov
index a4eb79416c7f802910eb6f49b9232af7a75502bf..06068e011c591797773219931d176935bd3811cd 100644 (file)
@@ -1,3 +1,5 @@
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
 // File:        ModelAPI_Validator.hxx
 // Created:     2 Jul 2014
 // Author:      Mikhail PONIKAROV
@@ -83,6 +85,9 @@ class MODELAPI_EXPORT ModelAPI_ValidatorsFactory
   /// so, it is not needed for the standard validation mechanism
   virtual void registerNotObligatory(std::string theFeature, std::string theAttribute) = 0;
 
+  /// Returns true if the attribute in feature is not obligatory for the feature execution
+  virtual bool isNotObligatory(std::string theFeature, std::string theAttribute) = 0;
+
   /// register that this attribute conceals in the object browser
   /// all referenced features after execution
   virtual void registerConcealment(std::string theFeature, std::string theAttribute) = 0;
diff --git a/src/ModelAPI/Test/TestDocument.py b/src/ModelAPI/Test/TestDocument.py
new file mode 100644 (file)
index 0000000..fd94154
--- /dev/null
@@ -0,0 +1,105 @@
+"""
+      TestDocument.py
+      Unit test for Model_Document/ModelAPI_Document class
+      
+"""
+#=========================================================================
+# Initialization of the test
+#=========================================================================
+from ModelAPI import *
+# from GeomDataAPI import *
+# from GeomAlgoAPI import *
+
+__updated__ = "2014-12-16"
+
+#=========================================================================
+# Creation and activation of documents
+#=========================================================================
+aSession = ModelAPI_Session.get()
+# TODO: enable this assertion:
+assert(aSession.moduleDocument())
+assert(aSession.moduleDocument().id() == "root")
+assert(aSession.moduleDocument().kind() == "PartSet")
+assert(aSession.hasModuleDocument())
+# Create a new document
+aSession.startOperation()
+aSession.moduleDocument().addFeature("Part")
+aSession.finishOperation()
+
+assert(aSession.activeDocument())
+assert(aSession.activeDocument().id() == "Part_1")
+assert(aSession.activeDocument().kind() == "Part")
+# Activate root doc
+aRootDoc = aSession.document("root")
+assert(aRootDoc)
+aSession.startOperation()
+aSession.setActiveDocument(aRootDoc, False)
+aSession.finishOperation()
+assert(aSession.activeDocument())
+assert(aSession.activeDocument().id() == "root")
+# check all opened docs
+for aDoc in aSession.allOpenedDocuments():
+    assert(aDoc)
+# Activate Part_1 doc back for further testing
+aSession.startOperation()
+aSession.setActiveDocument(aSession.document("Part_1"), False)
+aSession.finishOperation()
+#=========================================================================
+# Duplication of a document
+#=========================================================================
+aPart = aSession.activeDocument()
+assert(aPart.size("Features") == 0)
+# Create a point in the current document to check if it is duplicated
+aSession.startOperation()
+aFeature = aPart.addFeature("Point")
+aFeatureData = aFeature.data()
+assert(aFeatureData is not None)
+aFeatureData.real("x").setValue(15.)
+aFeatureData.real("y").setValue(10.)
+aFeatureData.real("z").setValue(20.)
+aSession.finishOperation()
+assert(aPart.size("Features") == 1)
+# Duplicate the document
+assert(aSession.moduleDocument().size("Parts") == 1)
+aSession.startOperation()
+aSession.moduleDocument().addFeature("Duplicate")
+aSession.finishOperation()
+assert(aSession.moduleDocument().size("Parts") == 2)
+aCopyOfPart = aSession.activeDocument()
+assert(aCopyOfPart.id() == "Part_2")
+assert(aCopyOfPart.kind() == "Part")
+assert(aCopyOfPart.size("Features") == 1)
+assert(aCopyOfPart != aPart)
+#=========================================================================
+# Remove document
+#=========================================================================
+assert(aSession.moduleDocument().size("Parts") == 2)
+aSession.startOperation()
+aSession.moduleDocument().addFeature("Remove")
+aSession.finishOperation()
+assert(aSession.moduleDocument().size("Parts") == 1)
+assert(aSession.activeDocument().id() == aSession.moduleDocument().id())
+# Remove another one document
+aSession.startOperation()
+aDoc1 = aSession.document("Part_1")
+aSession.setActiveDocument(aDoc1, False)
+aSession.moduleDocument().addFeature("Remove")
+aSession.finishOperation()
+assert(aSession.moduleDocument().size("Parts") == 0)
+assert(aSession.activeDocument())
+#=========================================================================
+# Trying to duplicate/remove the root
+#=========================================================================
+aSession.startOperation()
+aSession.moduleDocument().addFeature("Duplicate")
+aSession.finishOperation()
+assert(aSession.activeDocument().id() == aSession.moduleDocument().id())
+assert(aSession.moduleDocument().size("Parts") == 0)
+aSession.startOperation()
+aSession.moduleDocument().addFeature("Remove")
+aSession.finishOperation()
+assert(aSession.activeDocument().id() == aSession.moduleDocument().id())
+assert(aSession.moduleDocument().size("Parts") == 0)
+#=========================================================================
+# End of test
+#=========================================================================
index ddf454e2c6a816cf620a27716dd3c64492265ca2..a7d3cc5007cc72490c14671c837df19b9d793ec2 100644 (file)
@@ -1,8 +1,14 @@
+## Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
 INCLUDE(Common)
 SET(CMAKE_AUTOMOC ON)
 
 SET(PROJECT_HEADERS
        ModuleBase.h
+       ModuleBase_Filter.h
+       ModuleBase_FilterFace.h
+       ModuleBase_FilterFactory.h
+       ModuleBase_FilterLinearEdge.h
        ModuleBase_Tools.h
        ModuleBase_IModule.h
        ModuleBase_Operation.h
@@ -12,15 +18,9 @@ SET(PROJECT_HEADERS
        ModuleBase_WidgetDoubleValue.h
        ModuleBase_WidgetEditor.h
        ModuleBase_WidgetFactory.h
-       ModuleBase_WidgetFeature.h
-       ModuleBase_WidgetFeatureOrAttribute.h
-       ModuleBase_WidgetPoint2D.h
        ModuleBase_WidgetSwitch.h
        ModuleBase_WidgetShapeSelector.h
        ModuleBase_IWorkshop.h
-       ModuleBase_WidgetPoint2dDistance.h
-       ModuleBase_WidgetValue.h
-       ModuleBase_WidgetValueFeature.h
        ModuleBase_Definitions.h
        ModuleBase_SelectionValidator.h
        ModuleBase_ISelection.h
@@ -34,11 +34,20 @@ SET(PROJECT_HEADERS
        ModuleBase_WidgetMultiSelector.h
        ModuleBase_ViewerFilters.h
        ModuleBase_ResultPrs.h
+       ModuleBase_IViewWindow.h
+       ModuleBase_WidgetLabel.h
+       ModuleBase_IPrefMgr.h
+       ModuleBase_Preferences.h
 )
 
 SET(PROJECT_SOURCES
+       ModuleBase_Filter.cpp
+       ModuleBase_FilterFace.cpp
+       ModuleBase_FilterFactory.cpp
+       ModuleBase_FilterLinearEdge.cpp
        ModuleBase_Tools.cpp
        ModuleBase_IModule.cpp
+       ModuleBase_IWorkshop.cpp
        ModuleBase_Operation.cpp
        ModuleBase_OperationDescription.cpp
        ModuleBase_ModelWidget.cpp
@@ -46,21 +55,17 @@ SET(PROJECT_SOURCES
        ModuleBase_WidgetDoubleValue.cpp
        ModuleBase_WidgetEditor.cpp
        ModuleBase_WidgetFactory.cpp
-       ModuleBase_WidgetFeature.cpp
-       ModuleBase_WidgetFeatureOrAttribute.cpp
-       ModuleBase_WidgetPoint2D.cpp
        ModuleBase_WidgetSwitch.cpp
        ModuleBase_WidgetShapeSelector.cpp
-       ModuleBase_WidgetPoint2dDistance.cpp
-       ModuleBase_WidgetValue.cpp
-       ModuleBase_WidgetValueFeature.cpp       
        ModuleBase_WidgetChoice.cpp
        ModuleBase_WidgetFileSelector.cpp
        ModuleBase_DoubleSpinBox.cpp
-    ModuleBase_WidgetLineEdit.cpp
+       ModuleBase_WidgetLineEdit.cpp
        ModuleBase_WidgetMultiSelector.cpp
        ModuleBase_ViewerFilters.cpp
        ModuleBase_ResultPrs.cpp
+       ModuleBase_WidgetLabel.cpp
+       ModuleBase_Preferences.cpp
 )
 
 SET(PROJECT_LIBRARIES
@@ -72,6 +77,8 @@ SET(PROJECT_LIBRARIES
        ${CAS_VIEWER}
        ${CAS_KERNEL}
        ${CAS_SHAPE}
+       ${suit}
+       ${qtx}
 )
 
 SET(PROJECT_AUTOMOC 
@@ -93,6 +100,7 @@ INCLUDE_DIRECTORIES(
     ${CMAKE_SOURCE_DIR}/src/GeomDataAPI
     ${CMAKE_SOURCE_DIR}/src/GeomAPI
     ${CMAKE_SOURCE_DIR}/src/GeomAlgoAPI
+    ${SUIT_INCLUDE}
 )
 
 ADD_DEFINITIONS(-DMODULEBASE_EXPORTS ${CAS_DEFINITIONS})
index 54ee504270c93a9df3a8195b617b4dfb5c10ac94..6152b63ec36517f13dbcacef993d583383912be2 100644 (file)
@@ -1,3 +1,5 @@
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D\r
+\r
 #ifndef MODULEBASE_H\r
 #define MODULEBASE_H\r
 \r
index 8cfed34b4fb03ff03b6368febb536a29dad7aad2..eddfff2e0782a237a821523b1caa1ff17500052f 100644 (file)
@@ -1,11 +1,13 @@
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
 #ifndef ModuleBase_Definitions_H
 #define ModuleBase_Definitions_H
 
 #include <QList>
-#include <ModelAPI_Feature.h>
+#include <ModelAPI_Object.h>
 
 typedef QList<int> QIntList;       //!< list of int values
 typedef QList<short> QShortList;     //!< list of short int values
 typedef QList<double> QDoubleList;    //!< list of double values
-typedef QList<FeaturePtr> QFeatureList;  //!< List of features
+typedef QList<ObjectPtr> QObjectPtrList;  //!< List of ModelAPI_Objects
 #endif
index d85ad9897385d7a1d21529881b9a0180782247d7..683d215784bcc3c130cad428f52b80677fed506b 100644 (file)
@@ -1,3 +1,5 @@
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
 // File:      ModuleBase_DoubleSpinBox.cxx
 // Author:    Sergey TELKOV
 //
index a247fb8b782d5fde34efb0acb4ab629c47c88438..b8d8c2bea304f7122e3f6ed2b2f3fca9a4d69ec1 100644 (file)
@@ -1,3 +1,5 @@
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
 // File:      ModuleBase_DoubleSpinBox.h
 // Author:    Sergey TELKOV
 //
diff --git a/src/ModuleBase/ModuleBase_Filter.cpp b/src/ModuleBase/ModuleBase_Filter.cpp
new file mode 100644 (file)
index 0000000..c799ed4
--- /dev/null
@@ -0,0 +1,15 @@
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
+// File:        ModuleBase_Filter.cpp
+// Created:     10 Dec 2014
+// Author:      Natalia ERMOLAEVA
+
+#include "ModuleBase_Filter.h"
+
+Handle(SelectMgr_Filter) ModuleBase_Filter::getFilter()
+{
+  if (myFilter.IsNull())
+    createFilter();
+
+  return myFilter;
+}
diff --git a/src/ModuleBase/ModuleBase_Filter.h b/src/ModuleBase/ModuleBase_Filter.h
new file mode 100644 (file)
index 0000000..7b1f63d
--- /dev/null
@@ -0,0 +1,51 @@
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
+// File:        ModuleBase_Filter.h
+// Created:     10 Dec 2014
+// Author:      Natalia ERMOLAEVA
+
+#ifndef ModuleBase_Filter_H
+#define ModuleBase_Filter_H
+
+#include "ModuleBase.h"
+
+#include <SelectMgr_Filter.hxx>
+
+#include <list>
+
+/**
+ * This object is assigned by the name
+ * in the XML file to the specific attribute or to the whole feature.
+ * If isOK method of the filter returns "false", it is signalized in user interface
+ * that the processed entity should not be selected.
+ * Filterss must be registered in the filters factory to be
+ * correctly identified by the XML string-ID.
+ */
+class ModuleBase_Filter
+{
+public:
+  MODULEBASE_EXPORT ModuleBase_Filter() {}
+
+  /**
+   * Returns an OCC selection filter. It can be appended into the context of a viewer
+   * It creates a filter if it has not be created yet.
+   * \return the selection filter
+   */
+  MODULEBASE_EXPORT Handle(SelectMgr_Filter) getFilter();
+
+  /**
+   * Sets the arguments to the filter.
+   * \param theArguments a list of arguments
+   */
+  MODULEBASE_EXPORT virtual void setArguments(const std::list<std::string>& theArguments) = 0;
+protected:
+  /**
+   * It creates an internal instance of the OCC filter
+   */
+  virtual void createFilter() = 0;
+
+protected:
+  Handle(SelectMgr_Filter) myFilter; // current instance of the OCC selection filter
+};
+
+#endif //ModuleBase_Filter
diff --git a/src/ModuleBase/ModuleBase_FilterFace.cpp b/src/ModuleBase/ModuleBase_FilterFace.cpp
new file mode 100644 (file)
index 0000000..8391e17
--- /dev/null
@@ -0,0 +1,47 @@
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
+// File:        ModuleBase_FilterFace.cpp
+// Created:     10 Dec 2014
+// Author:      Natalia ERMOLAEVA
+
+
+#include "ModuleBase_FilterFace.h"
+
+#include <StdSelect_FaceFilter.hxx>
+#include <StdSelect_TypeOfFace.hxx>
+
+#include <Events_Error.h>
+
+#include <QString>
+#include <QMap>
+
+typedef QMap<QString, StdSelect_TypeOfFace> FaceTypes;
+static FaceTypes MyFaceTypes;
+
+StdSelect_TypeOfFace ModuleBase_FilterFace::faceType(const std::string& theType)
+{
+  if (MyFaceTypes.count() == 0) {
+    MyFaceTypes["plane"] = StdSelect_Plane;
+  }
+  QString aType = QString(theType.c_str()).toLower();
+  if (MyFaceTypes.contains(aType))
+    return MyFaceTypes[aType];
+  Events_Error::send("Face type defined in XML is not implemented!");
+  return StdSelect_AnyFace;
+}
+
+void ModuleBase_FilterFace::createFilter()
+{
+  myFilter = new StdSelect_FaceFilter(StdSelect_AnyFace);
+}
+
+void ModuleBase_FilterFace::setArguments(const std::list<std::string>& theArguments)
+{
+  if (theArguments.size()!= 1)
+    return;
+
+  std::string anArgument = theArguments.front();
+  Handle(StdSelect_FaceFilter) aFilter = Handle(StdSelect_FaceFilter)::DownCast(getFilter());
+  if (!aFilter.IsNull())
+    aFilter->SetType(faceType(anArgument));
+}
diff --git a/src/ModuleBase/ModuleBase_FilterFace.h b/src/ModuleBase/ModuleBase_FilterFace.h
new file mode 100644 (file)
index 0000000..4e6919a
--- /dev/null
@@ -0,0 +1,38 @@
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
+// File:        ModuleBase_FilterFace.h
+// Created:     10 Dec 2014
+// Author:      Natalia ERMOLAEVA
+
+#ifndef ModuleBase_FilterFace_H
+#define ModuleBase_FilterFace_H
+
+#include "ModuleBase.h"
+
+#include "ModuleBase_Filter.h"
+
+#include <StdSelect_TypeOfFace.hxx>
+
+class ModuleBase_FilterFace: public ModuleBase_Filter
+{
+public:
+  static MODULEBASE_EXPORT StdSelect_TypeOfFace faceType(const std::string& theType);
+
+  MODULEBASE_EXPORT ModuleBase_FilterFace(): 
+      ModuleBase_Filter() {}
+
+  /**
+   * Sets the arguments to the filter.
+   * \param theArguments a list of arguments
+   */
+  MODULEBASE_EXPORT virtual void setArguments(const std::list<std::string>& theArguments);
+
+protected:
+  /**
+   * It creates an OCC face filter
+   */
+  virtual void createFilter();
+
+};
+
+#endif //ModuleBase_FilterFace
diff --git a/src/ModuleBase/ModuleBase_FilterFactory.cpp b/src/ModuleBase/ModuleBase_FilterFactory.cpp
new file mode 100644 (file)
index 0000000..f89d6e7
--- /dev/null
@@ -0,0 +1,94 @@
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
+// File:        ModuleBase_FilterFactory.h
+// Created:     10 Dec 2014
+// Author:      Natalia ERMOLAEVA
+
+#include "ModuleBase_FilterFactory.h"
+#include <ModuleBase_Filter.h>
+
+//#include <Model_FeatureValidator.h>
+#include <ModelAPI_Feature.h>
+#include <ModelAPI_Attribute.h>
+#include <ModelAPI_Data.h>
+//#include <ModelAPI_AttributeValidator.h>
+#include <Events_Error.h>
+
+
+void ModuleBase_FilterFactory::registerFilter(const std::string& theID,
+                                              ModuleBase_Filter* theFilter)
+{
+  if (myIDs.find(theID) != myIDs.end()) {
+    Events_Error::send(std::string("Filter ") + theID + " is already registered");
+  } else {
+    myIDs[theID] = theFilter;
+  }
+}
+
+void ModuleBase_FilterFactory::assignFilter(const std::string& theID,
+                                            const std::string& theFeatureID,
+                                            const std::string& theAttrID,
+                                            const std::list<std::string>& theArguments)
+{
+  // create feature-structures if not exist
+  std::map<std::string, std::map<std::string, AttrFilters> >::iterator aFeature = myAttrs.find(
+    theFeatureID);
+  if (aFeature == myAttrs.end()) {
+    myAttrs[theFeatureID] = std::map<std::string, AttrFilters>();
+    aFeature = myAttrs.find(theFeatureID);
+  }
+  // add attr-structure if not exist, or generate error if already exist
+  std::map<std::string, AttrFilters>::iterator anAttr = aFeature->second.find(theAttrID);
+  if (anAttr == aFeature->second.end()) {
+    aFeature->second[theAttrID] = AttrFilters();
+  }
+  aFeature->second[theAttrID][theID] = theArguments;
+}
+
+void ModuleBase_FilterFactory::filters(const std::string& theFeatureID,
+                                       const std::string& theAttrID,
+                                       SelectMgr_ListOfFilter& theFilters/*,
+                                        std::list<ModuleBase_Filter*>& theFilters/*,
+                                        std::list<std::list<std::string> >& theArguments*/) const
+{
+  SelectMgr_ListOfFilter aFilters;
+
+  std::map<std::string, std::map<std::string, AttrFilters> >::const_iterator aFeature = 
+    myAttrs.find(theFeatureID);
+  if (aFeature != myAttrs.cend()) {
+    std::map<std::string, AttrFilters>::const_iterator anAttr = aFeature->second.find(theAttrID);
+    if (anAttr != aFeature->second.end()) {
+      AttrFilters::const_iterator aValIter = anAttr->second.cbegin();
+      for (; aValIter != anAttr->second.cend(); aValIter++) {
+        std::map<std::string, ModuleBase_Filter*>::const_iterator aFound = myIDs.find(
+          aValIter->first);
+        if (aFound == myIDs.end()) {
+          Events_Error::send(std::string("Filter ") + aValIter->first + " was not registered");
+        } else {
+          ModuleBase_Filter* aFilter = aFound->second;
+          aFilter->setArguments(aValIter->second);
+          //if (aFilter.IsNull())
+          //  continue;
+
+          theFilters.Append(aFilter->getFilter());//aFound->second);
+          //theArguments.push_back(aValIter->second);
+        }
+      }
+    }
+  }
+}
+
+ModuleBase_FilterFactory::ModuleBase_FilterFactory()
+{
+  //const static std::string kDefaultId = "Model_FeatureFilter";
+  //registerFilter(kDefaultId, new Model_FeatureFilter);
+}
+
+const ModuleBase_Filter* ModuleBase_FilterFactory::filter(const std::string& theID) const
+{
+  std::map<std::string, ModuleBase_Filter*>::const_iterator aIt = myIDs.find(theID);
+  if (aIt != myIDs.end()) {
+    return aIt->second;
+  }
+  return NULL;
+}
diff --git a/src/ModuleBase/ModuleBase_FilterFactory.h b/src/ModuleBase/ModuleBase_FilterFactory.h
new file mode 100644 (file)
index 0000000..043bd64
--- /dev/null
@@ -0,0 +1,67 @@
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
+// File:        ModuleBase_FilterFactory.h
+// Created:     10 Dec 2014
+// Author:      Natalia ERMOLAEVA
+
+#ifndef ModuleBase_FilterFactory_H
+#define ModeleBase_SelectionFilterFactory_H
+
+#include "ModuleBase.h"
+#include "ModuleBase_IWorkshop.h"
+#include "ModuleBase_Filter.h"
+
+#include <SelectMgr_ListOfFilter.hxx>
+
+#include <map>
+#include <set>
+
+/**
+ * Allows to get a selection filter by the feature identifier and 
+ * the attribute identifier (if attribute is validated).
+ * All accessible filters must be registered by the ID string first.
+ * The instance of this factory can be get in the Workshop interface.
+ * Keeps the filter objects alive and just returns one of it by request.
+ * All the needed information is provided to the filter as an argument,
+ * this allows to work with them independently from the feature specific object.
+ */
+class ModuleBase_FilterFactory : public QObject
+{
+ private:
+  std::map<std::string, ModuleBase_Filter*> myIDs;  ///< map from ID to registered filter
+  /// filters IDs to list of arguments
+  typedef std::map<std::string, std::list<std::string> > AttrFilters;
+  /// filters IDs by feature ID
+  std::map<std::string, AttrFilters> myFeatures;
+  /// filters IDs and arguments by feature and attribute IDs
+  std::map<std::string, std::map<std::string, AttrFilters> > myAttrs;
+
+ public:
+  /// Registers the instance of the filter by the ID
+  MODULEBASE_EXPORT virtual void registerFilter(const std::string& theID,
+                                                ModuleBase_Filter* theFilter);
+
+  /// Assigns filter to the attribute of the feature
+  MODULEBASE_EXPORT virtual void assignFilter(const std::string& theID,
+                                              const std::string& theFeatureID,
+                                              const std::string& theAttrID,
+                                              const std::list<std::string>& theArguments);
+
+  /// Provides a filter for the attribute, returns NULL if no filter
+  MODULEBASE_EXPORT void filters(const std::string& theFeatureID,
+                                 const std::string& theAttrID,
+                                 SelectMgr_ListOfFilter& theFilters) const;
+
+  /// Returns registered filter by its Id
+  MODULEBASE_EXPORT virtual const ModuleBase_Filter* filter(const std::string& theID) const;
+
+protected:
+  ModuleBase_FilterFactory();
+
+  ~ModuleBase_FilterFactory() {}
+
+  friend class ModuleBase_IWorkshop;
+
+};
+
+#endif //ModuleBase_FilterFactory
diff --git a/src/ModuleBase/ModuleBase_FilterLinearEdge.cpp b/src/ModuleBase/ModuleBase_FilterLinearEdge.cpp
new file mode 100644 (file)
index 0000000..a5634cb
--- /dev/null
@@ -0,0 +1,48 @@
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
+// File:        ModuleBase_FilterLinearEdge.cpp
+// Created:     10 Dec 2014
+// Author:      Natalia ERMOLAEVA
+
+
+#include "ModuleBase_FilterLinearEdge.h"
+
+#include <StdSelect_EdgeFilter.hxx>
+#include <StdSelect_TypeOfEdge.hxx>
+
+#include <Events_Error.h>
+
+#include <QString>
+#include <QMap>
+
+typedef QMap<QString, StdSelect_TypeOfEdge> EdgeTypes;
+static EdgeTypes MyEdgeTypes;
+
+StdSelect_TypeOfEdge ModuleBase_FilterLinearEdge::edgeType(const std::string& theType)
+{
+  if (MyEdgeTypes.count() == 0) {
+    MyEdgeTypes["line"] = StdSelect_Line;
+    MyEdgeTypes["circle"] = StdSelect_Circle;
+  }
+  QString aType = QString(theType.c_str()).toLower();
+  if (MyEdgeTypes.contains(aType))
+    return MyEdgeTypes[aType];
+  Events_Error::send("Edge type defined in XML is not implemented!");
+  return StdSelect_AnyEdge;
+}
+
+void ModuleBase_FilterLinearEdge::createFilter()
+{
+  myFilter = new StdSelect_EdgeFilter(StdSelect_AnyEdge);
+}
+
+void ModuleBase_FilterLinearEdge::setArguments(const std::list<std::string>& theArguments)
+{
+  if (theArguments.size()!= 1)
+    return;
+
+  std::string anArgument = theArguments.front();
+  Handle(StdSelect_EdgeFilter) aFilter = Handle(StdSelect_EdgeFilter)::DownCast(getFilter());
+  if (!aFilter.IsNull())
+    aFilter->SetType(edgeType(anArgument));
+}
diff --git a/src/ModuleBase/ModuleBase_FilterLinearEdge.h b/src/ModuleBase/ModuleBase_FilterLinearEdge.h
new file mode 100644 (file)
index 0000000..cdfa8e4
--- /dev/null
@@ -0,0 +1,38 @@
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
+// File:        ModuleBase_FilterLinearEdge.h
+// Created:     10 Dec 2014
+// Author:      Natalia ERMOLAEVA
+
+#ifndef ModuleBase_FilterLinearEdge_H
+#define ModuleBase_FilterLinearEdge_H
+
+#include "ModuleBase.h"
+
+#include "ModuleBase_Filter.h"
+
+#include <StdSelect_TypeOfEdge.hxx>
+
+class ModuleBase_FilterLinearEdge: public ModuleBase_Filter
+{
+public:
+  static MODULEBASE_EXPORT StdSelect_TypeOfEdge edgeType(const std::string& theType);
+
+  MODULEBASE_EXPORT ModuleBase_FilterLinearEdge(): 
+      ModuleBase_Filter() {}
+
+  /**
+   * Sets the arguments to the filter.
+   * \param theArguments a list of arguments
+   */
+  MODULEBASE_EXPORT virtual void setArguments(const std::list<std::string>& theArguments);
+
+protected:
+  /**
+   * It creates an OCC edge filter
+   */
+  virtual void createFilter();
+
+};
+
+#endif //ModuleBase_FilterLinearEdge
index daece8b0d1fcc4c1e778a6343888d221a535b04b..0e2ce8d7f6bc7545a1c204fd6d6f2e670bdd8bcb 100644 (file)
@@ -1,36 +1,48 @@
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
 
 #include "ModuleBase_IModule.h"
 #include "ModuleBase_IViewer.h"
 #include "ModuleBase_ViewerPrs.h"
 #include "ModuleBase_Operation.h"
 #include "ModuleBase_ISelection.h"
+#include "ModuleBase_OperationDescription.h"
 
 #include <Events_Loop.h>
 
 #include <ModelAPI_Events.h>
+#include <ModelAPI_CompositeFeature.h>
 
 #include <Config_PointerMessage.h>
+#include <Config_WidgetReader.h>
+#include <Config_ModuleReader.h>
 
+#include <QAction>
 
 ModuleBase_IModule::ModuleBase_IModule(ModuleBase_IWorkshop* theParent)
   : QObject(theParent), myWorkshop(theParent) 
 {
   connect(myWorkshop, SIGNAL(selectionChanged()), this, SLOT(onSelectionChanged()));
-  connect(myWorkshop->viewer(), SIGNAL(mousePress(QMouseEvent*)), this,
-          SLOT(onMousePressed(QMouseEvent*)));
-  connect(myWorkshop->viewer(), SIGNAL(mouseRelease(QMouseEvent*)), this,
-          SLOT(onMouseReleased(QMouseEvent*)));
-  connect(myWorkshop->viewer(), SIGNAL(mouseMove(QMouseEvent*)), this,
-          SLOT(onMouseMoved(QMouseEvent*)));
-  connect(myWorkshop->viewer(), SIGNAL(keyRelease(QKeyEvent*)), this,
-          SLOT(onKeyRelease(QKeyEvent*)));
-  connect(myWorkshop->viewer(), SIGNAL(mouseDoubleClick(QMouseEvent*)), this,
-          SLOT(onMouseDoubleClick(QMouseEvent*)));
+
+
+  //connect(myWorkshop->viewer(), SIGNAL(mousePress(QMouseEvent*)), this,
+  //        SLOT(onMousePressed(QMouseEvent*)));
+  //connect(myWorkshop->viewer(), SIGNAL(mouseRelease(QMouseEvent*)), this,
+  //        SLOT(onMouseReleased(QMouseEvent*)));
+  //connect(myWorkshop->viewer(), SIGNAL(mouseMove(QMouseEvent*)), this,
+  //        SLOT(onMouseMoved(QMouseEvent*)));
+  //connect(myWorkshop->viewer(), SIGNAL(keyRelease(QKeyEvent*)), this,
+  //        SLOT(onKeyRelease(QKeyEvent*)));
+  //connect(myWorkshop->viewer(), SIGNAL(mouseDoubleClick(QMouseEvent*)), this,
+  //        SLOT(onMouseDoubleClick(QMouseEvent*)));
 }
 
 
 void ModuleBase_IModule::launchOperation(const QString& theCmdId)
 {
+  if (!myWorkshop->canStartOperation(theCmdId))
+    return;
+
   ModuleBase_Operation* anOperation = createOperation(theCmdId.toStdString());
   ModuleBase_ISelection* aSelection = myWorkshop->selection();
   // Initialise operation with preliminary selection
@@ -47,3 +59,72 @@ void ModuleBase_IModule::sendOperation(ModuleBase_Operation* theOperation)
   aMessage->setPointer(theOperation);
   Events_Loop::loop()->send(aMessage);
 }
+
+ModuleBase_Operation* ModuleBase_IModule::getNewOperation(const std::string& theFeatureId)
+{
+  return new ModuleBase_Operation(theFeatureId.c_str(), this);
+}
+
+ModuleBase_Operation* ModuleBase_IModule::createOperation(const std::string& theFeatureId)
+{
+  ModuleBase_Operation* anOperation = getNewOperation(theFeatureId);
+
+  // If the operation is launched as sub-operation of another then we have to initialise
+  // parent feature
+  ModuleBase_Operation* aCurOperation = myWorkshop->currentOperation();
+  if (aCurOperation) {
+    FeaturePtr aFeature = aCurOperation->feature();
+    CompositeFeaturePtr aCompFea = std::dynamic_pointer_cast<ModelAPI_CompositeFeature>(aFeature);
+    if (aCompFea)
+      anOperation->setParentFeature(aCompFea);
+  }
+
+  std::string aPluginFileName = myFeaturesInFiles[theFeatureId];
+  Config_WidgetReader aWdgReader = Config_WidgetReader(aPluginFileName);
+  aWdgReader.readAll();
+  std::string aXmlCfg = aWdgReader.featureWidgetCfg(theFeatureId);
+  std::string aDescription = aWdgReader.featureDescription(theFeatureId);
+
+  anOperation->getDescription()->setDescription(QString::fromStdString(aDescription));
+  anOperation->getDescription()->setXmlRepresentation(QString::fromStdString(aXmlCfg));
+
+  return anOperation;
+}
+
+void ModuleBase_IModule::createFeatures()
+{
+  registerValidators();
+  registerFilters();
+
+  Config_ModuleReader aXMLReader = Config_ModuleReader();
+  aXMLReader.readAll();
+  myFeaturesInFiles = aXMLReader.featuresInFiles();
+}
+
+
+void ModuleBase_IModule::actionCreated(QAction* theFeature)
+{
+  connect(theFeature, SIGNAL(triggered(bool)), this, SLOT(onFeatureTriggered()));
+}
+
+
+void ModuleBase_IModule::onFeatureTriggered()
+{
+  QAction* aCmd = dynamic_cast<QAction*>(sender());
+  //Do nothing on uncheck
+  if (aCmd->isCheckable() && !aCmd->isChecked())
+    return;
+  launchOperation(aCmd->data().toString());
+}
+
+
+void ModuleBase_IModule::editFeature(FeaturePtr theFeature)
+{
+  std::string aFeatureId = theFeature->getKind();
+  if (!myWorkshop->canStartOperation(aFeatureId.c_str()))
+    return;
+
+  ModuleBase_Operation* anOperation = createOperation(aFeatureId);
+  anOperation->setFeature(theFeature);
+  sendOperation(anOperation);
+}
\ No newline at end of file
index 5787ccfb09989d5aa62afee6753a0117fc91b384..5703bb3c068b09a228f3475cf0ca058a1e6fc380 100644 (file)
-#ifndef ModuleBase_IModule_H
-#define ModuleBase_IModule_H
-
-#include "ModuleBase.h"
-#include "ModuleBase_IWorkshop.h"
-
-#include <QString>
-#include <QObject>
-
-
-class QAction;
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D\r
+\r
+#ifndef ModuleBase_IModule_H\r
+#define ModuleBase_IModule_H\r
+\r
+#include "ModuleBase.h"\r
+#include "ModuleBase_IWorkshop.h"\r
+\r
+#include <ModelAPI_Feature.h>\r
+\r
+#include <QString>\r
+#include <QObject>\r
+\r
+#include <string>\r
+#include <map>\r
+\r
+class QAction;\r
 class QMouseEvent;\r
 class QKeyEvent;\r
-class Config_WidgetAPI;
-class ModuleBase_ModelWidget;
-class ModuleBase_Operation;
-class ModuleBase_IWorkshop;
-
-/**
- * Interface to a module
- */
-class MODULEBASE_EXPORT ModuleBase_IModule : public QObject
-{
-  Q_OBJECT
- public:
-
-   ModuleBase_IModule(ModuleBase_IWorkshop* theParent);
-
-  virtual ~ModuleBase_IModule() {}
-
-  /// Reads description of features from XML file 
-  virtual void createFeatures() = 0;
-
-  /// Called on creation of menu item in desktop
-  virtual void featureCreated(QAction*) = 0;
-
-  /// Creates an operation and send it to loop
-  /// \param theCmdId the operation name
-  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 = 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;
-  }
-
-  ModuleBase_IWorkshop* workshop() const { return myWorkshop; }
-
-protected slots:
-
-  /// Called on selection changed event
-  virtual void onSelectionChanged() {}
-
+class Config_WidgetAPI;\r
+class ModuleBase_ModelWidget;\r
+class ModuleBase_Operation;\r
+class ModuleBase_IWorkshop;\r
+\r
+/**\r
+ * Interface to a module\r
+ */\r
+class MODULEBASE_EXPORT ModuleBase_IModule : public QObject\r
+{\r
+  Q_OBJECT\r
+ public:\r
+\r
+   ModuleBase_IModule(ModuleBase_IWorkshop* theParent);\r
+\r
+  virtual ~ModuleBase_IModule() {}\r
+\r
+  /// Reads description of features from XML file \r
+  virtual void createFeatures();\r
+\r
+  /// Called on creation of menu item in desktop\r
+  virtual void actionCreated(QAction*);\r
+\r
+  /// Called when user selects feature for editing\r
+  virtual void editFeature(FeaturePtr theFeature);\r
+\r
+  /// Creates an operation and send it to loop\r
+  /// \param theCmdId the operation name\r
+  virtual void launchOperation(const QString& theCmdId);\r
+\r
+  /// Realizes some functionality by an operation start\r
+  /// \param theOperation a started operation\r
+  virtual void operationStarted(ModuleBase_Operation* theOperation) {}\r
+\r
+  /// Realizes some functionality by an operation resume\r
+  /// \param theOperation a resumed operation\r
+  virtual void operationResumed(ModuleBase_Operation* theOperation) {}\r
+\r
+  /// Realizes some functionality by an operation stop\r
+  virtual void operationStopped(ModuleBase_Operation* theOperation) {}\r
+\r
+  /// Realizes some functionality by an operation commit\r
+  virtual void operationCommitted(ModuleBase_Operation* theOperation) {}\r
+\r
+  /// Realizes some functionality by an operation abort\r
+  virtual void operationAborted(ModuleBase_Operation* theOperation) {}\r
+\r
+  /// Called when it is necessary to update a command state (enable or disable it)\r
+  //virtual bool isFeatureEnabled(const QString& theCmdId) const = 0;\r
+\r
+  /// Creates custom widgets for property panel\r
+  virtual QWidget* createWidgetByType(const std::string& theType, QWidget* theParent,\r
+                                      Config_WidgetAPI* theWidgetApi, std::string theParentId,\r
+                                      QList<ModuleBase_ModelWidget*>& theModelWidgets)\r
+  {\r
+    return 0;\r
+  }\r
+\r
+  ModuleBase_IWorkshop* workshop() const { return myWorkshop; }\r
+\r
+  /// Call back forlast tuning of property panel before operation performance\r
+  /// It is called as on clearing of property panel as on filling with new widgets\r
+  virtual void propertyPanelDefined(ModuleBase_Operation* theOperation) {}\r
+\r
+public slots:\r
+  void onFeatureTriggered();\r
+\r
+protected slots:\r
+  /// Called on selection changed event\r
+  virtual void onSelectionChanged() {}\r
+\r
   /// SLOT, that is called by mouse press in the viewer.\r
   /// The mouse released point is sent to the current operation to be processed.\r
   /// \param theEvent the mouse event\r
-  virtual void onMousePressed(QMouseEvent* theEvent) {}\r
+  //virtual void onMousePressed(QMouseEvent* theEvent) {}\r
 \r
   /// SLOT, that is called by mouse release in the viewer.\r
   /// The mouse released point is sent to the current operation to be processed.\r
   /// \param theEvent the mouse event\r
-  virtual void onMouseReleased(QMouseEvent* theEvent) {}\r
+  //virtual void onMouseReleased(QMouseEvent* theEvent) {}\r
   \r
   /// SLOT, that is called by mouse move in the viewer.\r
   /// The mouse moved point is sent to the current operation to be processed.\r
   /// \param theEvent the mouse event\r
-  virtual void onMouseMoved(QMouseEvent* theEvent) {}\r
+  //virtual void onMouseMoved(QMouseEvent* theEvent) {}\r
 \r
   /// SLOT, that is called by the mouse double click in the viewer.\r
   /// \param theEvent the mouse event\r
-  virtual void onMouseDoubleClick(QMouseEvent* theEvent) {}\r
+  //virtual void onMouseDoubleClick(QMouseEvent* theEvent) {}\r
 \r
   /// SLOT, that is called by the key in the viewer is clicked.\r
   /// \param theEvent the mouse event\r
-  virtual void onKeyRelease(QKeyEvent* theEvent) {}\r
-
- protected:
-  /// Sends the operation for launching
-  /// \param theOperation the operation
-  void sendOperation(ModuleBase_Operation* theOperation);
-
-  /// Creates a new operation
-  /// \param theCmdId the operation name
-  /// \param theFeatureKind a kind of feature to get the feature xml description
-  virtual ModuleBase_Operation* createOperation(const std::string& theCmdId,
-                                        const std::string& theFeatureKind = "") = 0;
-
-
-protected:
-
-  ModuleBase_IWorkshop* myWorkshop;
-
-};
-
-//! This function must return a new module instance.
-extern "C" {
-typedef ModuleBase_IModule* (*CREATE_FUNC)(ModuleBase_IWorkshop*);
-}
-
-#define CREATE_MODULE "createModule"
-
-#endif //ModuleBase_IModule
+  //virtual void onKeyRelease(QKeyEvent* theEvent) {}\r
+\r
+ protected:\r
+  /// Sends the operation for launching\r
+  /// \param theOperation the operation\r
+  void sendOperation(ModuleBase_Operation* theOperation);\r
+\r
+  /// Creates a new operation\r
+  /// \param theCmdId the operation name\r
+  /// \param theFeatureKind a kind of feature to get the feature xml description\r
+  virtual ModuleBase_Operation* createOperation(const std::string& theFeatureId);\r
+\r
+  /// Register validators for this module\r
+  virtual void registerValidators() {}\r
+\r
+  /// Register selection filters for this module\r
+  virtual void registerFilters() {}\r
+\r
+  /// Returns new instance of operation object (used in createOperation for customization)\r
+  virtual ModuleBase_Operation* getNewOperation(const std::string& theFeatureId);\r
+\r
+protected:\r
+\r
+  ModuleBase_IWorkshop* myWorkshop;\r
+  std::map<std::string, std::string> myFeaturesInFiles;\r
+};\r
+\r
+\r
+\r
+//! This function must return a new module instance.\r
+extern "C" {\r
+typedef ModuleBase_IModule* (*CREATE_FUNC)(ModuleBase_IWorkshop*);\r
+}\r
+\r
+#define CREATE_MODULE "createModule"\r
+\r
+#endif //ModuleBase_IModule\r
diff --git a/src/ModuleBase/ModuleBase_IPrefMgr.h b/src/ModuleBase/ModuleBase_IPrefMgr.h
new file mode 100644 (file)
index 0000000..584659d
--- /dev/null
@@ -0,0 +1,44 @@
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
+// File:        ModuleBase_IPrefMgr.h
+// Created:     10 Sept 2014
+// Author:      Vitaly SMETANNIKOV
+
+
+#ifndef ModuleBase_IPrefMgr_H
+#define ModuleBase_IPrefMgr_H
+
+#include <QString>
+#include <SUIT_PreferenceMgr.h>
+
+/** 
+* An interface class which provides incapsulation of SUIT_PreferenceMgr class instance 
+* It is used in order to make common interface to Preference manager in Salome 
+* and this application
+*/
+class ModuleBase_IPrefMgr
+{
+public:
+
+  /** 
+  * Add preference item into preference dialog box
+  * \param theLbl - label of the item
+  * \param pId - id of container item
+  * \param theType - type of the item
+  * \param theSection - resouce section name
+  * \param theName - name of the resource
+  * Returns Id of the ctreated item
+  */
+  virtual int addPreference(const QString& theLbl, int pId, 
+                            SUIT_PreferenceMgr::PrefItemType theType,
+                            const QString& theSection, const QString& theName ) = 0;
+
+  virtual void setItemProperty(const QString& thePropName,
+                               const QVariant& theValue,
+                               const int theId = -1) = 0;
+
+  /// Returns incapsulated preference manager
+  virtual SUIT_PreferenceMgr* prefMgr() const = 0;
+};
+
+#endif
index 7f8d9d32d3c06e0a915adce51a348ed52db54e42..fdac20d135efb252e1fbd54b82a3ac17938d5fc5 100644 (file)
@@ -1,3 +1,5 @@
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
 /*
  * ModuleBase_IPropertyPanel.h
  *
@@ -19,7 +21,7 @@ class MODULEBASE_EXPORT ModuleBase_IPropertyPanel : public QDockWidget
 {
 Q_OBJECT
 public:
-  ModuleBase_IPropertyPanel(QWidget* theParent) : QDockWidget(theParent) {}
+  ModuleBase_IPropertyPanel(QWidget* theParent) : QDockWidget(theParent), myIsEditing(false) {}
 
   /// Returns currently active widget
   virtual ModuleBase_ModelWidget* activeWidget() const = 0;
@@ -27,14 +29,34 @@ public:
   /// Returns all property panel's widget created by WidgetFactory
   virtual const QList<ModuleBase_ModelWidget*>& modelWidgets() const = 0;
 
+  /// Editing mode depends on mode of current operation. This value is defined by it.
+  void setEditingMode(bool isEditing) { myIsEditing = isEditing; }
+  bool isEditingMode() const { return myIsEditing; }
+
+  /// Set Enable/Disable state of Ok button
+  virtual void setOkEnabled(bool theEnabled) = 0;
+
+  /// Returns state of Ok button
+  virtual bool isOkEnabled() const = 0;
+
+  /// Set Enable/Disable state of Ok button
+  virtual void setCancelEnabled(bool theEnabled) = 0;
+
+  /// Returns state of Ok button
+  virtual bool isCancelEnabled() const = 0;
+
 signals:
   /// The signal about key release on the control, that corresponds to the attribute
   /// \param theEvent key release event
   void keyReleased(QKeyEvent* theEvent);
+
   /// The signal about the widget activation
   /// \param theWidget the activated widget
   void widgetActivated(ModuleBase_ModelWidget* theWidget);
 
+  /// Emited when there is no next widget
+  void noMoreWidgets();
+
 public slots:
   /// Activate the next widget in the property panel
   /// \param theWidget a widget. The next widget should be activated
@@ -42,6 +64,14 @@ public slots:
 
   /// Activate the next from current widget in the property panel
   virtual void activateNextWidget() = 0;
+
+  // Makes the given widget active, highlights it and removes
+  // highlighting from the previous active widget
+  // emits widgetActivated(theWidget) signal
+  virtual void activateWidget(ModuleBase_ModelWidget* theWidget) = 0;
+
+protected:
+  bool myIsEditing;
 };
 
 #endif
\ No newline at end of file
index c1b06ca1b71fae47724684d7c339f41e2fdcd158..b6983d25ac82419d52cc10c2b7bd239c5b8c1314 100644 (file)
@@ -1,3 +1,5 @@
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
 // File:        ModuleBase_ISelection.h
 // Created:     2 June 2014
 // Author:      Vitaly Smetannikov
@@ -31,14 +33,14 @@ class ModuleBase_ISelection
   virtual QList<ModuleBase_ViewerPrs> getHighlighted(int theShapeTypeToSkip = -1) const = 0;
 
   /**
-   * Returns list of features currently selected in 3d viewer
+   * Returns list of features currently selected in object browser
    */
-  virtual QList<ObjectPtr> selectedObjects() const = 0;
+  virtual QObjectPtrList selectedObjects() const = 0;
 
   /**
    * Returns list of currently selected results
    */
-  virtual QList<ObjectPtr> selectedPresentations() const = 0;
+  virtual QObjectPtrList selectedPresentations() const = 0;
 
   //! Returns list of currently selected QModelIndexes
   virtual QModelIndexList selectedIndexes() const = 0;
diff --git a/src/ModuleBase/ModuleBase_IViewWindow.h b/src/ModuleBase/ModuleBase_IViewWindow.h
new file mode 100644 (file)
index 0000000..abf938d
--- /dev/null
@@ -0,0 +1,22 @@
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
+
+
+#ifndef ModuleBase_IViewWindow_H
+#define ModuleBase_IViewWindow_H
+
+#include <V3d_View.hxx>
+
+
+/** 
+* Interface to ViewWindow object which contains 3d scene
+*/
+class ModuleBase_IViewWindow
+{
+public:
+  /// Returns OCCT object which contains 3d view object
+  virtual Handle(V3d_View) v3dView() const = 0;
+};
+
+
+#endif
\ No newline at end of file
index 3e573d22379843ca8c1c6cd5c46f9030dc1b3f10..d3028d42d4f0a5c60e6aa32dcf46d87d88692b05 100644 (file)
@@ -1,3 +1,5 @@
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
 #ifndef ModuleBase_IViewer_H
 #define ModuleBase_IViewer_H
 
@@ -9,6 +11,7 @@
 class QMouseEvent;
 class QKeyEvent;
 class QContextMenuEvent;
+class ModuleBase_IViewWindow;
 
 /**
  * A Base object for definition of connector object to
@@ -64,16 +67,18 @@ Q_OBJECT
 
 signals:
   void lastViewClosed();
-  void tryCloseView();
-  void deleteView();
-  void viewCreated();
-  void mousePress(QMouseEvent* theEvent);
-  void mouseRelease(QMouseEvent* theEvent);
-  void mouseDoubleClick(QMouseEvent* theEvent);
-  void mouseMove(QMouseEvent* theEvent);
-  void keyPress(QKeyEvent* theEvent);
-  void keyRelease(QKeyEvent* theEvent);
-  void activated();
+  void tryCloseView(ModuleBase_IViewWindow* theWnd);
+  void deleteView(ModuleBase_IViewWindow* theWnd);
+  void viewCreated(ModuleBase_IViewWindow* theWnd);
+  void activated(ModuleBase_IViewWindow* theWnd);
+
+  void mousePress(ModuleBase_IViewWindow* theWnd, QMouseEvent* theEvent);
+  void mouseRelease(ModuleBase_IViewWindow* theWnd, QMouseEvent* theEvent);
+  void mouseDoubleClick(ModuleBase_IViewWindow* theWnd, QMouseEvent* theEvent);
+  void mouseMove(ModuleBase_IViewWindow* theWnd, QMouseEvent* theEvent);
+
+  void keyPress(ModuleBase_IViewWindow* theWnd, QKeyEvent* theEvent);
+  void keyRelease(ModuleBase_IViewWindow* theWnd, QKeyEvent* theEvent);
 
   void selectionChanged();
   void contextMenuRequested(QContextMenuEvent*);
diff --git a/src/ModuleBase/ModuleBase_IWorkshop.cpp b/src/ModuleBase/ModuleBase_IWorkshop.cpp
new file mode 100644 (file)
index 0000000..4531933
--- /dev/null
@@ -0,0 +1,14 @@
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
+// File:        ModuleBase_ModelWidget.h
+// Created:     25 Apr 2014
+// Author:      Natalia ERMOLAEVA
+
+#include "ModuleBase_IWorkshop.h"
+#include "ModuleBase_FilterFactory.h"
+
+ModuleBase_FilterFactory* ModuleBase_IWorkshop::selectionFilters() const
+{
+  static ModuleBase_FilterFactory* aFactory = new ModuleBase_FilterFactory;
+  return aFactory;
+}
index 12e9aef22040c91a4a762d8028dcb794291c48b7..84af1145fa2e82359ccd8fd2ded285cd29432ccc 100644 (file)
@@ -1,3 +1,5 @@
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
 // File:        ModuleBase_IWorkshop.h
 // Created:     2 June 2014
 // Author:      Vitaly Smetannikov
@@ -17,6 +19,7 @@ class ModuleBase_IModule;
 class ModuleBase_ISelection;
 class ModuleBase_IViewer;
 class ModuleBase_Operation;
+class ModuleBase_FilterFactory;
 
 /**
  * Class which provides access to Workshop object serveces
@@ -47,9 +50,15 @@ Q_OBJECT
   //! Returns current viewer
   virtual ModuleBase_IViewer* viewer() const = 0;
 
+  //! Returns the factory of selection filters : the only one instance per application
+  ModuleBase_FilterFactory* selectionFilters() const;
+  
   //! Returns currently active operation
   virtual ModuleBase_Operation* currentOperation() const = 0;
 
+  //! Returns true if the operation with id theId can be started
+  virtual bool canStartOperation(QString theId) = 0;
+
   //! Returns AIS opbject by data object
   virtual AISObjectPtr findPresentation(const ObjectPtr& theObject) const = 0;
 
@@ -58,13 +67,14 @@ Q_OBJECT
 
   //! Select features clearing previous selection. 
   //! If the list is empty then selection will be cleared
-  virtual void setSelected(const QList<ObjectPtr>& theFeatures) = 0;
+  virtual void setSelected(const QObjectPtrList& theFeatures) = 0;
 
 signals:
   void selectionChanged();
 
-  void operationStarted(ModuleBase_Operation*);
-  void operationStopped(ModuleBase_Operation*);
+  /// Signal which is emited after activation of property panel
+  void propertyPanelActivated();
+
 };
 
 #endif
index 5a6ba6e1eb5b8032feef6a283c3cc5e09b16c8c1..79b00dfe2071fb892d6c3d3799377ad17f3ac438 100644 (file)
@@ -1,3 +1,5 @@
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
 // File:        ModuleBase_ModelWidget.h
 // Created:     25 Apr 2014
 // Author:      Natalia ERMOLAEVA
@@ -82,7 +84,6 @@ bool ModuleBase_ModelWidget::focusTo()
   return true;
 }
 
-
 void ModuleBase_ModelWidget::updateObject(ObjectPtr theObj) const
 {
   Events_Loop::loop()->flush(Events_Loop::eventByName(EVENT_OBJECT_UPDATED));
@@ -90,6 +91,13 @@ void ModuleBase_ModelWidget::updateObject(ObjectPtr theObj) const
   ModelAPI_EventCreator::get()->sendUpdated(theObj, anEvent);
 }
 
+void ModuleBase_ModelWidget::moveObject(ObjectPtr theObj) const
+{
+  static Events_ID anEvent = Events_Loop::eventByName(EVENT_OBJECT_MOVED);
+  ModelAPI_EventCreator::get()->sendUpdated(theObj, anEvent);
+  Events_Loop::loop()->flush(anEvent);
+}
+
 bool ModuleBase_ModelWidget::eventFilter(QObject* theObject, QEvent *theEvent)
 {
   QWidget* aWidget = qobject_cast<QWidget*>(theObject);
index 7e77804ac36a440d483d726af92e7b29b97d0fac..e2f23438474bb32d0d1e91f814f507a7eac47633 100644 (file)
@@ -1,3 +1,5 @@
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
 // File:        ModuleBase_ModelWidget.h
 // Created:     25 Apr 2014
 // Author:      Natalia ERMOLAEVA
@@ -6,6 +8,7 @@
 #define MODULEBASE_MODELWIDGET_H
 
 #include <ModuleBase.h>
+#include <ModuleBase_ViewerPrs.h>
 
 #include <ModelAPI_Feature.h>
 
@@ -14,7 +17,6 @@
 #include <memory>
 
 class Config_WidgetAPI;
-class ModuleBase_WidgetValue;
 class QKeyEvent;
 
 /**\class ModuleBase_ModelWidget
@@ -51,10 +53,14 @@ Q_OBJECT
   /// Defines if it is supposed that the widget should interact with the viewer.
   virtual bool isViewerSelector() { return false; }
 
+  /// Defines if it is supported to set the value in this widget
+  /// By default it returns true
+  virtual bool canSetValue() const { return true; };
+
   /// Set the given wrapped value to the current widget
   /// This value should be processed in the widget according to the needs
   /// \param theValue the wrapped widget value
-  virtual bool setValue(ModuleBase_WidgetValue* theValue)
+  virtual bool setSelection(ModuleBase_ViewerPrs theValue)
   {
     return false;
   }
@@ -70,6 +76,12 @@ Q_OBJECT
   /// \return the state whether the widget can accept the focus
   virtual bool focusTo();
 
+  /// The methiod called when widget is activated
+  virtual void activate() {}
+
+  /// The methiod called when widget is deactivated
+  virtual void deactivate() {}
+
   /// Returns the internal parent wiget control, that can be shown anywhere
   /// \returns the widget
   virtual QWidget* getControl() const = 0;
@@ -134,6 +146,7 @@ signals:
   }
 
   void updateObject(ObjectPtr theObj) const;
+  void moveObject(ObjectPtr theObj) const;
 
  protected:
   std::string myAttributeID; /// the attribute name of the model feature
index c7525d7427571a1879f004c7c79b13c3231e2d72..00e90732e4cf4efeeaab495ead46ba72c097aa1f 100644 (file)
@@ -1,3 +1,5 @@
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
 /*
  * ModuleBase_Operation.cpp
  *
@@ -9,7 +11,6 @@
 
 #include "ModuleBase_OperationDescription.h"
 #include "ModuleBase_ModelWidget.h"
-#include "ModuleBase_WidgetValueFeature.h"
 #include "ModuleBase_ViewerPrs.h"
 #include "ModuleBase_IPropertyPanel.h"
 #include "ModuleBase_ISelection.h"
@@ -30,6 +31,8 @@
 
 #include <Events_Loop.h>
 
+#include <QTimer>
+
 #ifdef _DEBUG
 #include <QDebug>
 #endif
@@ -69,47 +72,21 @@ bool ModuleBase_Operation::isValid() const
   return aFactory->validate(myFeature);
 }
 
-bool ModuleBase_Operation::isNestedOperationsEnabled() const
-{
-  return true;
-}
-
-void ModuleBase_Operation::storeCustomValue()
-{
-  if (!myFeature) {
-#ifdef _DEBUG
-    qDebug() << "ModuleBase_Operation::storeCustom: " <<
-    "trying to store value without opening a transaction.";
-#endif
-    return;
-  }
-
-  ModuleBase_ModelWidget* aCustom = dynamic_cast<ModuleBase_ModelWidget*>(sender());
-  if (aCustom)
-    aCustom->storeValue();
-}
+//void ModuleBase_Operation::storeCustomValue()
+//{
+//  if (!myFeature) {
+//#ifdef _DEBUG
+//    qDebug() << "ModuleBase_Operation::storeCustom: " <<
+//    "trying to store value without opening a transaction.";
+//#endif
+//    return;
+//  }
+//
+//  ModuleBase_ModelWidget* aCustom = dynamic_cast<ModuleBase_ModelWidget*>(sender());
+//  if (aCustom)
+//    aCustom->storeValue();
+//}
 
-void ModuleBase_Operation::startOperation()
-{
-  if (!myIsEditing)
-    createFeature();
-}
-
-void ModuleBase_Operation::stopOperation()
-{
-}
-
-void ModuleBase_Operation::abortOperation()
-{
-}
-
-void ModuleBase_Operation::commitOperation()
-{
-}
-
-void ModuleBase_Operation::afterCommitOperation()
-{
-}
 
 bool ModuleBase_Operation::canBeCommitted() const
 {
@@ -126,11 +103,10 @@ void ModuleBase_Operation::flushCreated()
   Events_Loop::loop()->flush(Events_Loop::eventByName(EVENT_OBJECT_CREATED));
 }
 
-FeaturePtr ModuleBase_Operation::createFeature(
-  const bool theFlushMessage, CompositeFeaturePtr theCompositeFeature)
+FeaturePtr ModuleBase_Operation::createFeature(const bool theFlushMessage)
 {
-  if (theCompositeFeature) {
-    myFeature = theCompositeFeature->addFeature(getDescription()->operationId().toStdString());
+  if (myParentFeature) {
+    myFeature = myParentFeature->addFeature(getDescription()->operationId().toStdString());
   } else {
     std::shared_ptr<ModelAPI_Document> aDoc = document();
     myFeature = aDoc->addFeature(getDescription()->operationId().toStdString());
@@ -167,7 +143,7 @@ bool ModuleBase_Operation::hasObject(ObjectPtr theObj) const
     std::list<ResultPtr> aResults = aFeature->results();
     std::list<ResultPtr>::const_iterator aIt;
     for (aIt = aResults.cbegin(); aIt != aResults.cend(); ++aIt) {
-      if ((*aIt) == theObj)
+      if (theObj == (*aIt))
         return true;
     }
   }
@@ -185,15 +161,25 @@ void ModuleBase_Operation::start()
 {
   ModelAPI_Session::get()->startOperation();
 
+  if (!myIsEditing)
+    createFeature();
+
   startOperation();
   emit started();
+
 }
 
-void ModuleBase_Operation::resume()
+void ModuleBase_Operation::postpone()
 {
   if (myPropertyPanel)
-    connect(myPropertyPanel, SIGNAL(widgetActivated(ModuleBase_ModelWidget*)),
-            this,            SLOT(onWidgetActivated(ModuleBase_ModelWidget*)));
+    disconnect(myPropertyPanel, 0, this, 0);
+  emit postponed();
+}
+
+void ModuleBase_Operation::resume()
+{
+  //  connect(myPropertyPanel, SIGNAL(widgetActivated(ModuleBase_ModelWidget*)),
+  //          this,            SLOT(onWidgetActivated(ModuleBase_ModelWidget*)));
   emit resumed();
 }
 
@@ -213,13 +199,10 @@ void ModuleBase_Operation::abort()
 bool ModuleBase_Operation::commit()
 {
   if (canBeCommitted()) {
-    commitOperation();
-    emit committed();
+    if (myPropertyPanel)
+      disconnect(myPropertyPanel, 0, this, 0);
 
-  if (myPropertyPanel)
-    disconnect(myPropertyPanel, 0, this, 0);
-
-    stopOperation();
+    commitOperation();
     // check whether there are modifications performed during the current operation
     // in the model
     // in case if there are no modifications, do not increase the undo/redo stack
@@ -228,7 +211,9 @@ bool ModuleBase_Operation::commit()
     else
       ModelAPI_Session::get()->abortOperation();
 
+    stopOperation();
     emit stopped();
+    emit committed();
 
     afterCommitOperation();
     return true;
@@ -243,26 +228,32 @@ void ModuleBase_Operation::setRunning(bool theState)
   }
 }
 
-bool ModuleBase_Operation::activateByPreselection()
+void ModuleBase_Operation::activateByPreselection()
 {
-  if (!myPropertyPanel)
-    return false;
-  if (myPreSelection.empty())
-    return false;
+  if (!myPropertyPanel || myPreSelection.empty()) {
+    myPropertyPanel->activateNextWidget(NULL);
+    return;
+  }
   const QList<ModuleBase_ModelWidget*>& aWidgets = myPropertyPanel->modelWidgets();
-  if (aWidgets.empty())
-    return false;
+  if (aWidgets.empty()) {
+    myPropertyPanel->activateNextWidget(NULL);
+    return;
+  }
   
   ModuleBase_ModelWidget* aWgt, *aFilledWgt = 0;
   QList<ModuleBase_ModelWidget*>::const_iterator aWIt;
-  QList<ModuleBase_WidgetValueFeature*>::const_iterator aPIt;
+  QList<ModuleBase_ViewerPrs>::const_iterator aPIt;
   bool isSet = false;
   for (aWIt = aWidgets.constBegin(), aPIt = myPreSelection.constBegin();
        (aWIt != aWidgets.constEnd()) && (aPIt != myPreSelection.constEnd());
-       ++aWIt, ++aPIt) {
+       ++aWIt) {
     aWgt = (*aWIt);
-    ModuleBase_WidgetValueFeature* aValue = (*aPIt);
-    if (!aWgt->setValue(aValue)) {
+    ModuleBase_ViewerPrs aValue = (*aPIt);
+    if (!aWgt->canSetValue())
+      continue;
+
+    ++aPIt;
+    if (!aWgt->setSelection(aValue)) {
       isSet = false;
       break;
     } else {
@@ -270,31 +261,11 @@ bool ModuleBase_Operation::activateByPreselection()
       aFilledWgt = aWgt;
     }
   }
-  if (isSet && canBeCommitted()) {
-    // if all widgets are filled with selection
-    commit();
-    return true;
-  }
-  else {
-    //activate next widget
-    if (aFilledWgt) {
-      myPropertyPanel->activateNextWidget(aFilledWgt);
-      return true;
-    }
-  }
 
-  //ModuleBase_ModelWidget* aActiveWgt = myPropertyPanel->activeWidget();
-  //if ((myPreSelection.size() > 0) && aActiveWgt) {
-  //  const ModuleBase_ViewerPrs& aPrs = myPreSelection.first();
-  //  ModuleBase_WidgetValueFeature aValue;
-  //  aValue.setObject(aPrs.object());
-  //  if (aActiveWgt->setValue(&aValue)) {
-  //    myPreSelection.removeOne(aPrs);
-  //    myPropertyPanel->activateNextWidget();
-  //  }
-  //  // If preselection is enough to make a valid feature - apply it immediately
-  //}
-  return false;
+  myPropertyPanel->activateNextWidget(aFilledWgt);
+  if (aFilledWgt)
+    emit activatedByPreselection();
+
 }
 
 void ModuleBase_Operation::initSelection(ModuleBase_ISelection* theSelection,
@@ -309,7 +280,7 @@ void ModuleBase_Operation::initSelection(ModuleBase_ISelection* theSelection,
     QList<ModuleBase_ViewerPrs> aSelected = theSelection->getSelected();
 
     std::list<ResultPtr> aResults = aFeature->results();
-    QList<ObjectPtr> aResList;
+    QObjectPtrList aResList;
     std::list<ResultPtr>::const_iterator aIt;
     for (aIt = aResults.begin(); aIt != aResults.end(); ++aIt)
       aResList.append(*aIt);
@@ -323,41 +294,42 @@ void ModuleBase_Operation::initSelection(ModuleBase_ISelection* theSelection,
 
   // convert the selection values to the values, which are set to the operation widgets
 
-  Handle(V3d_View) aView = theViewer->activeView();
-  foreach (ModuleBase_ViewerPrs aPrs, aPreSelected) {
-    ModuleBase_WidgetValueFeature* aValue = new ModuleBase_WidgetValueFeature();
-    aValue->setObject(aPrs.object());
+  //Handle(V3d_View) aView = theViewer->activeView();
+  //foreach (ModuleBase_ViewerPrs aPrs, aPreSelected) {
+  //  ModuleBase_WidgetValueFeature* aValue = new ModuleBase_WidgetValueFeature();
+  //  aValue->setObject(aPrs.object());
 
-    double aX, anY;
-    if (getViewerPoint(aPrs, theViewer, aX, anY))
-      aValue->setPoint(std::shared_ptr<GeomAPI_Pnt2d>(new GeomAPI_Pnt2d(aX, anY)));
-    myPreSelection.append(aValue);
-  }
-}
-
-void ModuleBase_Operation::onWidgetActivated(ModuleBase_ModelWidget* theWidget)
-{
-  //activateByPreselection();
-  //if (theWidget && myPropertyPanel) {
-  //  myPropertyPanel->activateNextWidget();
-  ////  //emit activateNextWidget(myActiveWidget);
+  //  double aX, anY;
+  //  if (getViewerPoint(aPrs, theViewer, aX, anY))
+  //    aValue->setPoint(std::shared_ptr<GeomAPI_Pnt2d>(new GeomAPI_Pnt2d(aX, anY)));
+  //  myPreSelection.append(aValue);
   //}
+  myPreSelection = aPreSelected;
 }
 
-bool ModuleBase_Operation::setWidgetValue(ObjectPtr theFeature, double theX, double theY)
-{
-  ModuleBase_ModelWidget* aActiveWgt = myPropertyPanel->activeWidget();
-  if (!aActiveWgt)
-    return false;
-  ModuleBase_WidgetValueFeature* aValue = new ModuleBase_WidgetValueFeature();
-  aValue->setObject(theFeature);
-  aValue->setPoint(std::shared_ptr<GeomAPI_Pnt2d>(new GeomAPI_Pnt2d(theX, theY)));
-  bool isApplyed = aActiveWgt->setValue(aValue);
-
-  delete aValue;
-  myIsModified = (myIsModified || isApplyed);
-  return isApplyed;
-}
+//void ModuleBase_Operation::onWidgetActivated(ModuleBase_ModelWidget* theWidget)
+//{
+//  //activateByPreselection();
+//  //if (theWidget && myPropertyPanel) {
+//  //  myPropertyPanel->activateNextWidget();
+//  ////  //emit activateNextWidget(myActiveWidget);
+//  //}
+//}
+
+//bool ModuleBase_Operation::setWidgetValue(ObjectPtr theFeature, double theX, double theY)
+//{
+//  ModuleBase_ModelWidget* aActiveWgt = myPropertyPanel->activeWidget();
+//  if (!aActiveWgt)
+//    return false;
+//  ModuleBase_WidgetValueFeature* aValue = new ModuleBase_WidgetValueFeature();
+//  aValue->setObject(theFeature);
+//  aValue->setPoint(std::shared_ptr<GeomAPI_Pnt2d>(new GeomAPI_Pnt2d(theX, theY)));
+//  bool isApplyed = aActiveWgt->setValue(aValue);
+//
+//  delete aValue;
+//  myIsModified = (myIsModified || isApplyed);
+//  return isApplyed;
+//}
 
 bool ModuleBase_Operation::getViewerPoint(ModuleBase_ViewerPrs thePrs,
                                                ModuleBase_IViewer* theViewer,
@@ -368,14 +340,23 @@ bool ModuleBase_Operation::getViewerPoint(ModuleBase_ViewerPrs thePrs,
 
 void ModuleBase_Operation::clearPreselection()
 {
-  while (!myPreSelection.isEmpty()) {
-    delete myPreSelection.takeFirst();
-  }
+  myPreSelection.clear();
 }
 
 void ModuleBase_Operation::setPropertyPanel(ModuleBase_IPropertyPanel* theProp) 
 { 
   myPropertyPanel = theProp; 
-  connect(myPropertyPanel, SIGNAL(widgetActivated(ModuleBase_ModelWidget*)), this,
-          SLOT(onWidgetActivated(ModuleBase_ModelWidget*)));
+  myPropertyPanel->setEditingMode(isEditOperation());
+  //connect(myPropertyPanel, SIGNAL(widgetActivated(ModuleBase_ModelWidget*)), this,
+  //        SLOT(onWidgetActivated(ModuleBase_ModelWidget*)));
+
+  // Do not activate widgets by default if the current operation is editing operation
+  // Because we don't know which widget is going to be edited. 
+  if (!isEditOperation())
+    activateByPreselection();
+}
+
+bool ModuleBase_Operation::isGranted(QString theId) const
+{
+  return myNestedFeatures.contains(theId);
 }
index f1b0ae2180b7963563f06ba4fd977d80833195a2..a9333a7e8cf6796062e689e01f6cc068be5ebfcd 100644 (file)
@@ -1,3 +1,5 @@
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
 /*
  * ModuleBase_Operation.h
  *
@@ -23,7 +25,6 @@ class ModuleBase_OperationDescription;
 class ModuleBase_IPropertyPanel;
 class ModuleBase_ISelection;
 class ModuleBase_IViewer;
-class ModuleBase_WidgetValueFeature;
 
 class QKeyEvent;
 
@@ -65,7 +66,7 @@ Q_OBJECT
   * the operation is not granted.
   * The method has to be redefined for granted operations.
   */
-  virtual bool isGranted(ModuleBase_Operation* theOperation) const  { return false; }
+  virtual bool isGranted(QString theId) const;
 
   /// Sets a list of model widgets, according to the operation feature xml definition
   /// \param theXmlRepresentation an xml feature definition
@@ -99,22 +100,17 @@ Q_OBJECT
   */
   virtual bool isValid() const;
 
-  /// Returns whether the nested operations are enabled.
-  /// The state can depend on the operation current state.
-  /// \return enabled state
-  virtual bool isNestedOperationsEnabled() const;
-
   /// Sets the operation feature
   void setFeature(FeaturePtr theFeature);
 
   /// Returns True if the current operation works with the given object (feature or result)
   virtual bool hasObject(ObjectPtr theObj) const;
 
-  virtual void keyReleased(const int theKey) {};
+  //virtual void keyReleased(const int theKey) {};
 
   /// If operation needs to redisplay its result during operation
   /// then this method has to return True
-  virtual bool hasPreview() const { return false; }
+  //virtual bool hasPreview() const { return false; }
 
   /// Initialisation of operation with preliminary selection
   /// \param theSelected the list of selected presentations
@@ -127,8 +123,14 @@ Q_OBJECT
 
   ModuleBase_IPropertyPanel* propertyPanel() const { return myPropertyPanel; }
 
-  /// Activates widgets by preselection if it is accepted
-  virtual bool activateByPreselection();
+  /// Activates widgets by preselection if it is accepted. Emits signal if the activation is correct
+  virtual void activateByPreselection();
+
+  /// If the operation works with feature which is sub-feature of another one
+  /// then this variable has to be initialised by parent feature 
+  /// before operation feature creating
+  void setParentFeature(CompositeFeaturePtr theParent) { myParentFeature = theParent; }
+  CompositeFeaturePtr parentFeature() const { return myParentFeature; }
 
 signals:
   void started();  /// the operation is started
@@ -136,6 +138,8 @@ signals:
   void committed();  /// the operation is committed
   void stopped();  /// the operation is aborted or committed
   void resumed();  /// the operation is resumed
+  void postponed();  /// the operation is postponed
+  void activatedByPreselection(); /// the operation is filled with existing preselection
 
  public slots:
   /// Starts operation
@@ -145,6 +149,10 @@ signals:
   /// be better to inherit own operator from base one and redefine startOperation method
   /// instead.
   void start();
+
+  /// Deactivates current operation which can be resumed later.
+  void postpone();
+
   /// Resumes operation
   /// Public slot. Verifies whether operation can be started and starts operation.
   /// This slot is not virtual and cannot be redefined. Redefine startOperation method
@@ -152,10 +160,12 @@ signals:
   /// be better to inherit own operator from base one and redefine startOperation method
   /// instead.
   void resume();
+
   /// Aborts operation
   /// Public slot. Aborts operation. This slot is not virtual and cannot be redefined.
   /// Redefine abortOperation method to change behavior of operation instead
   void abort();
+
   /// Commits operation
   /// Public slot. Commits operation. This slot is not virtual and cannot be redefined.
   /// Redefine commitOperation method to change behavior of operation instead
@@ -169,31 +179,35 @@ signals:
 
   // Data model methods.
   /// Stores a custom value in model.
-  virtual void storeCustomValue();
+  //virtual void storeCustomValue();
 
   /// Slots which listen the mode widget activation
   /// \param theWidget the model widget
-  virtual void onWidgetActivated(ModuleBase_ModelWidget* theWidget);
+  //virtual void onWidgetActivated(ModuleBase_ModelWidget* theWidget);
 
  protected:
   /// Virtual method called when operation started (see start() method for more description)
   /// Default impl calls corresponding slot and commits immediately.
-  virtual void startOperation();
+   virtual void startOperation() {}
+
+  /// Implementation of specific steps on postpone operation
+  virtual void postponeOperation() {}
 
   /// Virtual method called when operation stopped - committed or aborted.
-  virtual void stopOperation();
+  virtual void stopOperation() {}
 
   /// Virtual method called when operation aborted (see abort() method for more description)
-  virtual void abortOperation();
+  virtual void abortOperation() {}
 
   /// Virtual method called when operation committed (see commit() method for more description)
-  virtual void commitOperation();
+  virtual void commitOperation() {}
 
   /// Virtual method called after operation committed (see commit() method for more description)
-  virtual void afterCommitOperation();
+  virtual void afterCommitOperation() {}
 
   /// Send update message by loop
   void flushUpdated();
+
   /// Send created message by loop
   void flushCreated();
 
@@ -201,8 +215,7 @@ signals:
   /// \param theFlushMessage the flag whether the create message should be flushed
   /// \param theCompositeFeature the feature that must be used for adding the created object or null
   /// \returns the created 
-  virtual FeaturePtr createFeature(const bool theFlushMessage = true, 
-    CompositeFeaturePtr theCompositeFeature = CompositeFeaturePtr());
+  virtual FeaturePtr createFeature(const bool theFlushMessage = true);
 
   /// Verifies whether this operator can be commited.
   /// \return Returns TRUE if current operation can be committed, e.g. all parameters are filled
@@ -216,7 +229,7 @@ signals:
   /// \param theX the horizontal coordinate
   /// \param theY the vertical coordinate
   /// \return true if the point is set
-  virtual bool setWidgetValue(ObjectPtr theFeature, double theX, double theY);
+  //virtual bool setWidgetValue(ObjectPtr theFeature, double theX, double theY);
 
   /// Return a widget value point by the selection and the viewer position
   /// The default realization returns false
@@ -248,10 +261,16 @@ signals:
   QStringList myNestedFeatures;
 
   /// List of pre-selected object 
-  QList<ModuleBase_WidgetValueFeature*> myPreSelection;
+  QList<ModuleBase_ViewerPrs> myPreSelection;
 
   /// Access to property panel
   ModuleBase_IPropertyPanel* myPropertyPanel;
+
+  /// If the operation works with feature which is sub-feature of another one
+  /// then this variable has to be initialised by parent feature 
+  /// before operation feature creating
+  CompositeFeaturePtr myParentFeature;  
+
 };
 
 #endif
index e69e39218ca6646321f7341752ada5fae9912778..04d5cc4a01f0371787b3c14da7cff60f06d1a2f5 100644 (file)
@@ -1,3 +1,5 @@
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
 /*
  * ModuleBase_OperationDescription.cpp
  *
index fdcd0b3fb57c239d65348f7a54542408ac20452a..bd9f525517ca61e06d5e8bf73076fc33058f7018 100644 (file)
@@ -1,3 +1,5 @@
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D\r
+\r
 /*\r
  * ModuleBase_OperationDescription.h\r
  *\r
diff --git a/src/ModuleBase/ModuleBase_Preferences.cpp b/src/ModuleBase/ModuleBase_Preferences.cpp
new file mode 100644 (file)
index 0000000..c550b23
--- /dev/null
@@ -0,0 +1,317 @@
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
+// File:        ModuleBase_Preferences.cpp
+// Created:     07 Aug 2014
+// Author:      Vitaly SMETANNIKOV
+
+#include "ModuleBase_Preferences.h"
+//#include "ModuleBase_Constants.h"
+
+#include <Config_PropManager.h>
+
+#include <SUIT_ResourceMgr.h>
+#include <SUIT_PreferenceMgr.h>
+#include <Qtx.h>
+
+#include <QLayout>
+#include <QApplication>
+#include <QDialogButtonBox>
+#include <QPushButton>
+
+const QString ModuleBase_Preferences::VIEWER_SECTION = "Viewer";
+const QString ModuleBase_Preferences::MENU_SECTION = "Menu";
+
+SUIT_ResourceMgr* ModuleBase_Preferences::myResourceMgr = 0;
+
+SUIT_ResourceMgr* ModuleBase_Preferences::resourceMgr()
+{
+  if (!myResourceMgr) {
+    myResourceMgr = new SUIT_ResourceMgr("NewGeom");
+    myResourceMgr->setCurrentFormat("xml");
+  }
+  return myResourceMgr;
+}
+
+bool ModuleBase_Preferences::editPreferences(ModuleBase_Prefs& theModified)
+{
+  ModuleBase_PreferencesDlg aDlg(resourceMgr(), QApplication::activeWindow());
+  aDlg.exec();
+  if (aDlg.isChanged()) {
+    aDlg.modified(theModified);
+    resourceMgr()->save();
+    return true;
+  }
+  return false;
+}
+
+void ModuleBase_Preferences::updateConfigByResources()
+{
+  Config_Properties aProps = Config_PropManager::getProperties();
+  Config_Properties::iterator aIt;
+  for (aIt = aProps.begin(); aIt != aProps.end(); ++aIt) {
+    Config_Prop* aProp = (*aIt);
+    QString aVal = myResourceMgr->stringValue(QString(aProp->section().c_str()),
+                                              QString(aProp->name().c_str()));
+    if (!aVal.isEmpty()) {
+      aProp->setValue(aVal.toStdString());
+    }
+  }
+}
+
+void ModuleBase_Preferences::updateResourcesByConfig()
+{
+  Config_Properties aProps = Config_PropManager::getProperties();
+  Config_Properties::iterator aIt;
+  for (aIt = aProps.begin(); aIt != aProps.end(); ++aIt) {
+    Config_Prop* aProp = (*aIt);
+    myResourceMgr->setValue(QString(aProp->section().c_str()), QString(aProp->name().c_str()),
+                            QString(aProp->value().c_str()));
+  }
+}
+
+void ModuleBase_Preferences::resetConfig()
+{
+  Config_Properties aProps = Config_PropManager::getProperties();
+  Config_Properties::iterator aIt;
+  for (aIt = aProps.begin(); aIt != aProps.end(); ++aIt) {
+    Config_Prop* aProp = (*aIt);
+    aProp->setValue(aProp->defaultValue());
+  }
+}
+
+void ModuleBase_Preferences::loadCustomProps()
+{
+  if(!myResourceMgr)
+    return;
+  QStringList aSections = myResourceMgr->sections();
+  foreach (QString aSection, aSections)
+  {
+    QStringList aParams = myResourceMgr->parameters(aSection);
+    foreach (QString aParam, aParams)
+    {
+      Config_Prop* aProp = Config_PropManager::registerProp(aSection.toStdString(),
+                                       aParam.toStdString(), "", Config_Prop::Disabled);
+      aProp->setValue(myResourceMgr->stringValue(aSection, aParam).toStdString());
+    }
+  }
+}
+
+
+void ModuleBase_Preferences::createEditContent(ModuleBase_IPrefMgr* thePref, int thePage)
+{
+  thePref->prefMgr()->setItemIcon(thePage, QIcon(":pictures/module.png"));
+  createCustomPage(thePref, thePage);
+}
+
+
+void ModuleBase_Preferences::createCustomPage(ModuleBase_IPrefMgr* thePref, int thePageId)
+{
+  SUIT_ResourceMgr* aResMgr = ModuleBase_Preferences::resourceMgr();
+  bool isResModified = false;
+
+  // Make a Tab from each section
+  std::list<std::string> aSections = Config_PropManager::getSections();
+  std::list<std::string>::const_iterator it;
+  for (it = aSections.cbegin(); it != aSections.cend(); ++it) {
+    Config_Properties aProps = Config_PropManager::getProperties(*it);
+    int aTab = thePref->prefMgr()->addItem(QString((*it).c_str()), thePageId);
+    thePref->prefMgr()->setItemProperty("columns", 2, aTab);
+
+    Config_Properties::const_iterator aIt;
+    for (aIt = aProps.cbegin(); aIt != aProps.cend(); ++aIt) {
+      Config_Prop* aProp = (*aIt);
+      // check that the property is defined
+      QString aSection(aProp->section().c_str());
+      QString aName(aProp->name().c_str());
+      if (!aResMgr->hasValue(aSection, aName)) {
+        aResMgr->setValue(aSection, aName, QString(aProp->value().c_str()));
+        isResModified = true;
+      }
+      // Add item
+      if (aProp->type() != Config_Prop::Disabled) {
+        SUIT_PreferenceMgr::PrefItemType aPrefType = SUIT_PreferenceMgr::Auto;
+        if (aProp->type() == Config_Prop::Directory) {
+          aPrefType = SUIT_PreferenceMgr::File;
+        } else {
+          aPrefType = (SUIT_PreferenceMgr::PrefItemType) aProp->type();
+        }
+        int anId = thePref->addPreference(QObject::tr(aProp->title().c_str()), aTab, aPrefType,
+                                          QString::fromStdString(aProp->section()),
+                                          QString::fromStdString(aProp->name()));
+        if(aProp->type() == Config_Prop::Directory) {
+          thePref->setItemProperty("path_type", Qtx::PT_Directory, anId);
+        }
+      }
+    }
+  }
+}
+
+//**********************************************************
+//**********************************************************
+//**********************************************************
+class ModuleBase_PrefMgr: public ModuleBase_IPrefMgr
+{
+public:
+  ModuleBase_PrefMgr(ModuleBase_PreferencesMgr* theMgr):myMgr(theMgr) {}
+
+  virtual int addPreference(const QString& theLbl, int pId, 
+                            SUIT_PreferenceMgr::PrefItemType theType,
+                            const QString& theSection, const QString& theName )
+  {
+    return myMgr->addItem(theLbl, pId, theType, theSection, theName);
+  }
+
+  virtual void setItemProperty( const QString& thePropName, const QVariant& theValue,
+                               const int theId = -1) {
+    myMgr->setItemProperty(thePropName, theValue, theId);
+  }
+
+  virtual SUIT_PreferenceMgr* prefMgr() const { return myMgr; }
+
+private:
+  ModuleBase_PreferencesMgr* myMgr;
+};
+
+//**********************************************************
+//**********************************************************
+//**********************************************************
+ModuleBase_PreferencesDlg::ModuleBase_PreferencesDlg(SUIT_ResourceMgr* theResurces, QWidget* theParent)
+    : QDialog(theParent),
+      myIsChanged(false)
+{
+  setWindowTitle(tr("Edit preferences"));
+
+  QVBoxLayout* main = new QVBoxLayout(this);
+  main->setMargin(5);
+  main->setSpacing(5);
+
+  myPreferences = new ModuleBase_PreferencesMgr(theResurces, this);
+  main->addWidget(myPreferences);
+
+  setFocusProxy(myPreferences);
+  myPreferences->setFrameStyle(QFrame::Box | QFrame::Sunken);
+
+  QDialogButtonBox* aBtnBox = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel |
+                                                   QDialogButtonBox::Reset,
+                                                   Qt::Horizontal, this);
+  QPushButton* aDefaultButton = aBtnBox->button(QDialogButtonBox::Reset);
+  aDefaultButton->setText(tr("Default"));
+  connect(aDefaultButton, SIGNAL(clicked()), this, SLOT(onDefault()));
+
+  main->addWidget(aBtnBox);
+  connect(aBtnBox, SIGNAL(accepted()), this, SLOT(accept()));
+  connect(aBtnBox, SIGNAL(rejected()), this, SLOT(reject()));
+  createEditors();
+
+  myPreferences->retrieve();
+  setMinimumSize(800, 200);
+}
+
+ModuleBase_PreferencesDlg::~ModuleBase_PreferencesDlg()
+{
+}
+
+void ModuleBase_PreferencesDlg::createEditors()
+{
+  int aPage = myPreferences->addItem(tr("Desktop"));
+  myPreferences->setItemIcon(aPage, QIcon(":pictures/view_prefs.png"));
+
+  createMenuPage(aPage);
+  createViewerPage(aPage);
+
+  aPage = myPreferences->addItem(tr("Module"));
+  myPreferences->setItemIcon(aPage, QIcon(":pictures/module.png"));
+
+  ModuleBase_PrefMgr aMgr(myPreferences);
+  ModuleBase_Preferences::createEditContent(&aMgr, aPage);
+}
+
+void ModuleBase_PreferencesDlg::createViewerPage(int thePageId)
+{
+  int viewTab = myPreferences->addItem(tr("Viewer"), thePageId);
+
+  QStringList gradList;
+  gradList << tr("Horizontal gradient") << tr("Vertical gradient") << tr("First diagonal gradient")
+           << tr("Second diagonal gradient") << tr("First corner gradient")
+           << tr("Second corner gradient") << tr("Third corner gradient")
+           << tr("Fourth corner gradient");
+
+  QList<QVariant> idList;
+  for (int i = 0; i < gradList.size(); i++)
+    idList << i;
+
+  int bgGroup = myPreferences->addItem(tr("Background"), viewTab);
+
+  QString aImgFiles("Image files (*.bmp *.gif *.pix *.xwd *.rgb *.rs)");
+
+  int bgId = myPreferences->addItem(tr("Viewer 3d"), bgGroup, SUIT_PreferenceMgr::Background,
+                                    ModuleBase_Preferences::VIEWER_SECTION, "background");
+  myPreferences->setItemProperty("gradient_names", gradList, bgId);
+  myPreferences->setItemProperty("gradient_ids", idList, bgId);
+  myPreferences->setItemProperty("texture_enabled", true, bgId);
+  myPreferences->setItemProperty("texture_center_enabled", true, bgId);
+  myPreferences->setItemProperty("texture_tile_enabled", true, bgId);
+  myPreferences->setItemProperty("texture_stretch_enabled", true, bgId);
+  myPreferences->setItemProperty("custom_enabled", false, bgId);
+  myPreferences->setItemProperty("image_formats", aImgFiles, bgId);
+}
+
+void ModuleBase_PreferencesDlg::createMenuPage(int thePageId)
+{
+  int aMenuTab = myPreferences->addItem(tr("Main menu"), thePageId);
+
+  int aSizeGroup = myPreferences->addItem(tr("Size"), aMenuTab);
+  myPreferences->setItemProperty("columns", 1, aSizeGroup);
+
+  int aRowsNb = myPreferences->addItem(tr("Number of rows"), aSizeGroup,
+                                       SUIT_PreferenceMgr::IntSpin, ModuleBase_Preferences::MENU_SECTION,
+                                       "rows_number");
+  myPreferences->setItemProperty("min", 1, aRowsNb);
+  myPreferences->setItemProperty("max", 6, aRowsNb);
+}
+
+void ModuleBase_PreferencesDlg::accept()
+{
+  myPreferences->store();
+  myIsChanged = true;
+
+  // Save custom properties
+  ModuleBase_Preferences::updateConfigByResources();
+  QDialog::accept();
+}
+
+void ModuleBase_PreferencesDlg::modified(ModuleBase_Prefs& theModified) const
+{
+  theModified = myPreferences->modified();
+}
+
+void ModuleBase_PreferencesDlg::onDefault()
+{
+  // reset main resources
+#ifdef SALOME_750 // until SALOME 7.5.0 is released
+  QtxResourceMgr::WorkingMode aPrev =
+      myPreferences->resourceMgr()->setWorkingMode(QtxResourceMgr::IgnoreUserValues);
+  myPreferences->retrieve();
+  myPreferences->resourceMgr()->setWorkingMode(aPrev);
+#endif
+  // reset plugin's resources
+  ModuleBase_Preferences::resetConfig();
+  ModuleBase_Preferences::updateResourcesByConfig();
+
+  myPreferences->retrieve();
+}
+
+//**********************************************************
+//**********************************************************
+//**********************************************************
+void ModuleBase_PreferencesMgr::changedResources(const ResourceMap& theMap)
+{
+  myModified.clear();
+  ResourceMap::ConstIterator it;
+  QString sec, param;
+  for (it = theMap.begin(); it != theMap.end(); ++it) {
+    ModuleBase_Pref aPref;
+    it.key()->resource(aPref.first, aPref.second);
+    myModified.append(aPref);
+  }
+}
diff --git a/src/ModuleBase/ModuleBase_Preferences.h b/src/ModuleBase/ModuleBase_Preferences.h
new file mode 100644 (file)
index 0000000..e04c63b
--- /dev/null
@@ -0,0 +1,126 @@
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
+// File:        ModuleBase_Preferences.h
+// Created:     07 Aug 2014
+// Author:      Vitaly SMETANNIKOV
+
+#ifndef ModuleBase_Preferences_H
+#define ModuleBase_Preferences_H
+
+#include "ModuleBase.h"
+#include "ModuleBase_IPrefMgr.h"
+
+#include <SUIT_PreferenceMgr.h>
+#include <QDialog>
+
+class SUIT_ResourceMgr;
+class QWidget;
+
+// Pair of values: section name, value name
+typedef QPair<QString, QString> ModuleBase_Pref;
+typedef QList<ModuleBase_Pref> ModuleBase_Prefs;
+
+//***********************************************************************
+/// Class for manipulation  with preferences in the application
+class MODULEBASE_EXPORT ModuleBase_Preferences
+{
+ public:
+  static const QString VIEWER_SECTION;
+  static const QString MENU_SECTION;
+
+  static bool editPreferences(ModuleBase_Prefs& theModified);
+
+  /// Returns currently installed resource manager
+  static SUIT_ResourceMgr* resourceMgr();
+
+  /// Sets a resource manager
+  /// It is used in case of necessity to define external resource manager (not NewGeom)
+  static void setResourceMgr(SUIT_ResourceMgr* theMgr) { myResourceMgr = theMgr; }
+
+  /// Updates Config_PropManager properties by module from SUIT_ResourceMgr
+  static void updateConfigByResources();
+
+  /// Updates SUIT_ResourceMgr values by Config_PropManager properties
+  /// \param theUpdateOnlyInvalid flag to update only invalid values, if it is false, all are updated
+  static void updateResourcesByConfig();
+
+  /// Set default values to the Config_PropManager properties
+  static void resetConfig();
+
+  /// Loads properties defined by module to Config_PropManager
+  static void loadCustomProps();
+
+  /// 
+  static void createEditContent(ModuleBase_IPrefMgr* thePref, int thePage);
+
+private:
+  /// Creates content of preferences editing widget
+  static void createCustomPage(ModuleBase_IPrefMgr* thePref, int thePageId);
+
+  static SUIT_ResourceMgr* myResourceMgr;
+};
+
+//***********************************************************************
+/// Manager of preferences
+class MODULEBASE_EXPORT ModuleBase_PreferencesMgr : public SUIT_PreferenceMgr
+{
+Q_OBJECT
+ public:
+  ModuleBase_PreferencesMgr(QtxResourceMgr* theResource, QWidget* theParent)
+      : SUIT_PreferenceMgr(theResource, theParent)
+  {
+  }
+
+  virtual ~ModuleBase_PreferencesMgr()
+  {
+  }
+
+  ModuleBase_Prefs modified() const
+  {
+    return myModified;
+  }
+
+ protected:
+  virtual void changedResources(const ResourceMap& theMap);
+
+ private:
+  ModuleBase_Prefs myModified;
+};
+
+//***********************************************************************
+/// Dialog box for preferences editing
+class MODULEBASE_EXPORT ModuleBase_PreferencesDlg : public QDialog
+{
+Q_OBJECT
+ public:
+  ModuleBase_PreferencesDlg(SUIT_ResourceMgr* theResurces, QWidget* theParent = 0);
+  virtual ~ModuleBase_PreferencesDlg();
+
+  bool isChanged() const
+  {
+    return myIsChanged;
+  }
+
+  void modified(ModuleBase_Prefs& theModified) const;
+
+ public slots:
+  virtual void accept();
+
+protected slots:
+  void onDefault();
+
+ private:
+   /// Create editors for aplication properties
+   void createEditors();
+
+   /// Create a viewer page in dialog box
+   void createViewerPage(int thePageId);
+   
+   /// Create menu properties page in the dialog box
+   void createMenuPage(int thePageId);
+
+  ModuleBase_PreferencesMgr* myPreferences;
+  bool myIsChanged;
+};
+
+#endif
index 73f066fc32ea4f4b08d90708cc347f8224ce3a02..5031dac249edaa366522b15c03060c7eac8b0ffa 100644 (file)
@@ -1,3 +1,5 @@
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
 // File:        ModuleBase_ResultPrs.cpp
 // Created:     21 October 2014
 // Author:      Vitaly SMETANNIKOV
index 62b82389c6febed609181ae4ed5a5a53d15750a7..941ef15c4cb85591138c391e83f87198fa09679b 100644 (file)
@@ -1,3 +1,5 @@
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
 // File:        ModuleBase_ResultPrs.h
 // Created:     21 October 2014
 // Author:      Vitaly SMETANNIKOV
index f4bf04e7ec07da20de980180e3a984ac35da718b..180d59936a37308129a606c3f15429a1d883ec5e 100644 (file)
@@ -1,3 +1,5 @@
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
 // File:        ModuleBase_SelectionValidator.h
 // Created:     8 Jul 2014
 // Author:      Vitaly SMETANNIKOV
 
 #include <ModelAPI_Validator.h>
 
+#include <list>
+#include <string>
+
 class ModuleBase_SelectionValidator : public ModelAPI_Validator
 {
  public:
   virtual bool isValid(const ModuleBase_ISelection* theSelection) const = 0;
+  virtual bool isValid(const ModuleBase_ISelection* theSelection,
+                       const std::list<std::string>& theArguments) const
+  {
+    return isValid(theSelection);
+  }
 };
 
 #endif
index 8df14bdc35b74bfb93fce4cdb053f9ac5c302114..21fa0db1f29eb7d676bf0b2aab3a964a6272268b 100644 (file)
@@ -1,11 +1,14 @@
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
 // File:        ModuleBase_Tools.cpp
 // Created:     11 July 2014
 // Author:      Vitaly Smetannikov
 
 #include "ModuleBase_Tools.h"
-#include <ModelAPI_ResultBody.h>
-#include <ModelAPI_ResultConstruction.h>
-#include <ModelAPI_Document.h>
+#include <QWidget>
+#include <QLayout>
+#include <QPainter>
+#include <QBitmap>
 
 namespace ModuleBase_Tools {
 
@@ -43,4 +46,57 @@ void zeroMargins(QLayout* theLayout)
   theLayout->setSpacing(5);
 }
 
+QPixmap composite(const QString& theAdditionalIcon, const QString& theIcon)
+{
+  QImage anIcon(theIcon);
+  QImage anAditional(theAdditionalIcon);
+
+  if (anIcon.isNull())
+    return QPixmap();
+
+  int anAddWidth = anAditional.width();
+  int anAddHeight = anAditional.height();
+
+  int aWidth = anIcon.width();
+  int aHeight = anIcon.height();
+
+  int aStartWidthPos = aWidth - anAddWidth - 1;
+  int aStartHeightPos = aHeight - anAddHeight - 1;
+
+  for (int i = 0; i < anAddWidth && i + aStartWidthPos < aWidth; i++)
+  {
+    for (int j = 0; j < anAddHeight && j + aStartHeightPos < aHeight; j++)
+    {
+      if (qAlpha(anAditional.pixel(i, j)) > 0)
+        anIcon.setPixel(i + aStartWidthPos, j + aStartHeightPos, anAditional.pixel(i, j));
+    }
+  }
+  return QPixmap::fromImage(anIcon);
+}
+
+QPixmap lighter(const QString& theIcon, const int theLighterValue)
+{
+  QImage anIcon(theIcon);
+  if (anIcon.isNull())
+    return QPixmap();
+
+  QImage aResult(theIcon);
+  for ( int i = 0; i < anIcon.width(); i++ )
+  {
+    for ( int j = 0; j < anIcon.height(); j++ )
+    {
+      QRgb anRgb = anIcon.pixel( i, j );
+      QColor aPixelColor(qRed(anRgb), qGreen(anRgb), qBlue(anRgb),
+                         qAlpha( aResult.pixel( i, j ) ));
+
+      QColor aLighterColor = aPixelColor.lighter(theLighterValue);
+      aResult.setPixel(i, j, qRgba( aLighterColor.red(), aLighterColor.green(),
+                                    aLighterColor.blue(), aLighterColor.alpha() ) );
+    }
+  }
+  return QPixmap::fromImage(aResult);
+}
+
 }
+
+
index 6c903d3fbd7b41d7aeba8ff97694fa2aef27cd87..a0e250914ed12f73bbd4180292a26379d2abb18c 100644 (file)
@@ -1,3 +1,5 @@
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
 // File:        ModuleBase_Tools.h
 // Created:     11 July 2014
 // Author:      Vitaly Smetannikov
@@ -7,10 +9,10 @@
 
 #include "ModuleBase.h"
 
-#include <QWidget>
-#include <QLayout>
+#include <QPixmap>
 
-class GeomAPI_Shape;
+class QWidget;
+class QLayout;
 
 namespace ModuleBase_Tools {
 
@@ -23,6 +25,29 @@ MODULEBASE_EXPORT void adjustMargins(QLayout* theLayout);
 MODULEBASE_EXPORT void zeroMargins(QWidget* theWidget);
 MODULEBASE_EXPORT void zeroMargins(QLayout* theLayout);
 
+
+/**
+ * Methods to modify a resource pixmap
+ */
+//! Create composite pixmap. 
+//! Pixmap \a theAdditionalIcon is drawn over pixmap \a dest with coordinates
+//! specified relatively to the upper left corner of \a theIcon.
+
+//! \param theAdditionalIcon resource text of the additional pixmap
+//! \param theIcon resource text of the background pixmap
+//! \return resulting pixmap
+MODULEBASE_EXPORT QPixmap composite(const QString& theAdditionalIcon, const QString& theIcon);
+
+//! Generates the pixmap lighter than the resources pixmap. 
+//! Pixmap \a theIcon is lighted according to the given value.
+//! If the lighter value is greater than 100, this functions returns a lighter pixmap.
+//! Setting lighter value to 150 returns a color that is 50% brighter. If the factor is less than 100,
+//! the return pixmap is darker. If the factor is 0 or negative, the return pixmap is unspecified.
+
+//! \param resource text of the pixmap
+//! \param theLighterValue a lighter factor
+//! \return resulting pixmap
+MODULEBASE_EXPORT QPixmap lighter(const QString& theIcon, const int theLighterValue = 200);
 }
 
 #endif
index a7e2cd3f7b383a80988a86f2f1d8ab396fb37274..1e56112a7ebf23a03a1c47737af88e9a23831ca2 100644 (file)
@@ -1,3 +1,5 @@
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
 // File:        ModuleBase_ViewerFilters.cpp
 // Created:     07 Okt 2014
 // Author:      Vitaly SMETANNIKOV
@@ -37,7 +39,11 @@ Standard_Boolean ModuleBase_ShapeDocumentFilter::IsOk(const Handle(SelectMgr_Ent
       if (aObj) {
         DocumentPtr aDoc = aObj->document();
         SessionPtr aMgr = ModelAPI_Session::get();
-        return (aDoc == aMgr->activeDocument() /* MPV: for the current moment selection in other document is not possible || (aDoc == aMgr->moduleDocument()*/);
+        return (aDoc == aMgr->activeDocument() || aDoc == aMgr->moduleDocument());
+      }
+      else {
+        // This is not object controlled by the filter
+        return Standard_True;
       }
     }
   }
@@ -74,6 +80,10 @@ Standard_Boolean ModuleBase_ShapeInPlaneFilter::IsOk(const Handle(SelectMgr_Enti
           bool aD3 = myPlane.Distance(aLastPnt) < Precision::Confusion();
           return aD1 && aD2 && aD3;
         }
+      default:
+        // This is not object controlled by the filter
+        return Standard_True;
+      break;
       }
     } else {
       // This is not object controlled by the filter
index e4aa93ae29b299bc3713a20f0424f7d5f6f1f712..708eb9e03b15b55a0cca152c893da0ecdf2e70a1 100644 (file)
@@ -1,3 +1,5 @@
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
 // File:        ModuleBase_ViewerFilters.h
 // Created:     07 Okt 2014
 // Author:      Vitaly SMETANNIKOV
@@ -44,8 +46,10 @@ DEFINE_STANDARD_HANDLE(ModuleBase_ShapeInPlaneFilter, SelectMgr_Filter);
 class ModuleBase_ShapeInPlaneFilter: public SelectMgr_Filter
 {
 public:
-  Standard_EXPORT ModuleBase_ShapeInPlaneFilter(const gp_Pln& thePane): 
-      SelectMgr_Filter(), myPlane(thePane) {}
+  Standard_EXPORT ModuleBase_ShapeInPlaneFilter(): SelectMgr_Filter() {}
+
+  void setPlane(const gp_Pln& thePane) { myPlane = thePane; }
+  gp_Pln plane() const { return myPlane; }
 
   Standard_EXPORT virtual Standard_Boolean IsOk(const Handle(SelectMgr_EntityOwner)& theOwner) const;
 
index b9bcb2b9d5c18c4a2f61a00dd822e5f70d36ccba..6dec54b93b605eb2aa7442bd3f89a5f38f0bcfec 100644 (file)
@@ -1,3 +1,5 @@
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
 // File:        ModuleBase_ViewerPrs.h
 // Created:     20 Apr 2014
 // Author:      Natalia ERMOLAEVA
index 4e0ceee4c1dfb7e405798432d9882c7b3b5ebcd3..87e26a78f5c4b03a9a61ad35adc3e99e95929f08 100644 (file)
@@ -1,3 +1,5 @@
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
 // File:        ModuleBase_Widgets.h
 // Created:     04 June 2014
 // Author:      Vitaly Smetannikov
@@ -24,7 +26,7 @@ ModuleBase_WidgetBoolValue::ModuleBase_WidgetBoolValue(QWidget* theParent,
 {
   QString aText = QString::fromStdString(theData->widgetLabel());
   QString aToolTip = QString::fromStdString(theData->widgetTooltip());
-  bool isChecked = theData->getBooleanAttribute(ANY_WDG_DEFAULT, false);
+  bool isChecked = theData->getBooleanAttribute(ATTR_DEFAULT, false);
 
   myCheckBox = new QCheckBox(aText, theParent);
   myCheckBox->setToolTip(aToolTip);
index 9d0246c1156fa3b3043c85001e6706ca6b9d8ad2..cf41b6b89cb01d46e6947f83d4ed4bed12c86658 100644 (file)
@@ -1,3 +1,5 @@
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
 // File:        ModuleBase_WidgetBoolValue.h
 // Created:     04 June 2014
 // Author:      Vitaly Smetannikov
index b2d017db6b5aa0d39c3879270a2d0854e242e28e..7156a0f453e1e1e32911853ff0f82bc1a1117aa5 100644 (file)
@@ -1,3 +1,5 @@
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
 // File:        ModuleBase_WidgetChoice.cpp
 // Created:     03 Sept 2014
 // Author:      Vitaly Smetannikov
@@ -81,5 +83,6 @@ QList<QWidget*> ModuleBase_WidgetChoice::getControls() const
 void ModuleBase_WidgetChoice::onCurrentIndexChanged(int theIndex)
 {
   emit valuesChanged();
-  emit focusOutWidget(this);
+  // Don't transfer focus
+  // emit focusOutWidget(this);
 }
index 15a95054eb8662cc2ef192c7a2b3ee867ab99a31..99bd281f9505ac5e8a1ee1e4663841551f6832f3 100644 (file)
@@ -1,3 +1,5 @@
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
 // File:        ModuleBase_WidgetChoice.h
 // Created:     03 Sept 2014
 // Author:      Vitaly Smetannikov
index 7400d7f7d48db95bc329456d6a75aa6c7a567282..6b1f52ed35d161e778ccf891a49872adacddc8fb 100644 (file)
@@ -1,3 +1,5 @@
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
 // File:        ModuleBase_Widgets.h
 // Created:     04 June 2014
 // Author:      Vitaly Smetannikov
@@ -77,7 +79,7 @@ ModuleBase_WidgetDoubleValue::ModuleBase_WidgetDoubleValue(QWidget* theParent,
     mySpinBox->setSingleStep(aStepVal);
   }
 
-  aProp = theData->getProperty(ANY_WDG_DEFAULT);
+  aProp = theData->getProperty(ATTR_DEFAULT);
   double aDefVal = QString::fromStdString(aProp).toDouble(&isOk);
   if (isOk) {
     mySpinBox->setValue(aDefVal);
index 20afafbe18f9862e7a43b15c0287660334f79ed7..a4f0a1b8b8b5fcc1abea08c9b2e7745f584de2a9 100644 (file)
@@ -1,3 +1,5 @@
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
 // File:        ModuleBase_WidgetDoubleValue.h
 // Created:     04 June 2014
 // Author:      Vitaly Smetannikov
index ee5bc67f476ba024490da025fc8dbea9f5f87b10..7f77acd5a97ac1064fdfd533699a7e85dd71b4ad 100644 (file)
@@ -1,3 +1,5 @@
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
 // File:        ModuleBase_WidgetEditor.cpp
 // Created:     25 Apr 2014
 // Author:      Natalia ERMOLAEVA
@@ -24,6 +26,7 @@
 #include <QTimer>
 #include <QDialog>
 #include <QLayout>
+#include <QApplication>
 
 ModuleBase_WidgetEditor::ModuleBase_WidgetEditor(QWidget* theParent,
                                                  const Config_WidgetAPI* theData,
@@ -60,6 +63,16 @@ double editedValue(double theValue, bool& isDone)
 
 bool ModuleBase_WidgetEditor::focusTo()
 {
+  // We can not launch here modal process for value editing because 
+  // it can be called on other focusOutWidget event and will block it
+  QTimer::singleShot(1, this, SLOT(showPopupEditor()));
+  return true;
+}
+
+void ModuleBase_WidgetEditor::showPopupEditor()
+{
+  // White while all events will be processed
+  QApplication::processEvents();
   double aValue = mySpinBox->value();
   bool isDone;
   aValue = editedValue(aValue, isDone);
@@ -71,8 +84,6 @@ bool ModuleBase_WidgetEditor::focusTo()
   }
   emit valuesChanged();
   emit focusOutWidget(this);
-
-  return false;
 }
 
 void ModuleBase_WidgetEditor::editFeatureValue(FeaturePtr theFeature,
index 508e5ee53871ca5d9b1144deffe3dbd73e62c779..9f9358fae049cc2dae451cc1d2ef849ac2f55989 100644 (file)
@@ -1,3 +1,5 @@
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
 // File:        ModuleBase_WidgetEditor.h
 // Created:     25 Apr 2014
 // Author:      Natalia ERMOLAEVA
@@ -47,6 +49,10 @@ Q_OBJECT
   /// \param theAttribute the feature attribute
   static void editFeatureValue(FeaturePtr theFeature, const std::string theAttribute);
 
+ private slots:
+   /// Shous popup window under cursor for data editing
+   void showPopupEditor();
+
  private:
   FeaturePtr myFeature;  ///< the current widget feature
   QStringList myFeatureKinds;  ///< the kinds of possible features
index cc66a69b818d77acedb3b9a69ebcecf8c7e2230c..a726704137c781af1afd750d78fec6a7796d5f64 100644 (file)
@@ -1,3 +1,5 @@
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
 /*
  * ModuleBase_WidgetFactory.cpp
  *
 
 #include <ModuleBase_Operation.h>
 #include <ModuleBase_OperationDescription.h>
-#include <ModuleBase_WidgetPoint2D.h>
-#include <ModuleBase_WidgetFeatureOrAttribute.h>
-#include <ModuleBase_WidgetFeature.h>
+//#include <ModuleBase_WidgetFeatureOrAttribute.h>
+//#include <ModuleBase_WidgetFeature.h>
 #include <ModuleBase_WidgetEditor.h>
 #include <ModuleBase_WidgetSwitch.h>
 #include <ModuleBase_WidgetShapeSelector.h>
 #include <ModuleBase_WidgetDoubleValue.h>
 #include <ModuleBase_WidgetBoolValue.h>
-#include <ModuleBase_WidgetPoint2dDistance.h>
+//#include <ModuleBase_WidgetPoint2dDistance.h>
 #include <ModuleBase_WidgetFileSelector.h>
 #include <ModuleBase_WidgetChoice.h>
 #include <ModuleBase_IWorkshop.h>
@@ -25,6 +26,7 @@
 #include <ModuleBase_Tools.h>
 #include <ModuleBase_WidgetLineEdit.h>
 #include <ModuleBase_WidgetMultiSelector.h>
+#include <ModuleBase_WidgetLabel.h>
 
 #include <ModelAPI_Validator.h>
 #include <ModelAPI_Session.h>
@@ -73,7 +75,7 @@ void ModuleBase_WidgetFactory::createWidget(QWidget* theParent)
     //Create a widget (doublevalue, groupbox, toolbox, etc.
     QWidget* aWidget = createWidgetByType(aWdgType, theParent);
     if (aWidget) {
-      if (!myWidgetApi->getBooleanAttribute(ATTRIBUTE_INTERNAL, false)) {
+      if (!myWidgetApi->getBooleanAttribute(ATTR_INTERNAL, false)) {
         aWidgetLay->addWidget(aWidget);
       } else {
         aWidget->setVisible(false);
@@ -109,20 +111,16 @@ void ModuleBase_WidgetFactory::createWidget(QWidget* theParent)
   theParent->setLayout(aWidgetLay);
 }
 
+
 QWidget* ModuleBase_WidgetFactory::labelControl(QWidget* theParent)
 {
-  QWidget* result = new QWidget(theParent);
-  QVBoxLayout* aLabelLay = new QVBoxLayout(result);
-  QLabel* aLabel = new QLabel(result);
-  aLabel->setWordWrap(true);
-  aLabel->setText(qs(myWidgetApi->getProperty(INFO_WDG_TEXT)));
-  aLabel->setToolTip(qs(myWidgetApi->getProperty(INFO_WDG_TOOLTIP)));
-  aLabelLay->addWidget(aLabel);
-  aLabelLay->addStretch(1);
-  result->setLayout(aLabelLay);
-  return result;
+  ModuleBase_WidgetLabel* aWgt =
+      new ModuleBase_WidgetLabel(theParent, myWidgetApi, myParentId);
+  myModelWidgets.append(aWgt);
+  return aWgt->getControl();
 }
 
+
 QWidget* ModuleBase_WidgetFactory::createWidgetByType(const std::string& theType,
                                                       QWidget* theParent)
 {
@@ -139,21 +137,15 @@ QWidget* ModuleBase_WidgetFactory::createWidgetByType(const std::string& theType
   } else if (theType == WDG_BOOLVALUE) {
     result = booleanControl(theParent);
 
-  } else if (theType == WDG_POINT_SELECTOR) {
-    result = pointSelectorControl(theParent);
+  //} else if (theType == WDG_FEATURE_SELECTOR) {
+  //  result = featureSelectorControl(theParent);
 
-  } else if (theType == WDG_FEATURE_SELECTOR) {
-    result = featureSelectorControl(theParent);
-
-  } else if (theType == WDG_FEATURE_OR_ATTRIBUTE_SELECTOR) {
-    result = featureOrAttributeSelectorControl(theParent);
+  //} else if (theType == WDG_FEATURE_OR_ATTRIBUTE_SELECTOR) {
+  //  result = featureOrAttributeSelectorControl(theParent);
 
   } else if (theType == WDG_DOUBLEVALUE_EDITOR) {
     result = doubleValueEditor(theParent);
 
-  } else if (theType == WDG_POINT2D_DISTANCE) {
-    result = point2dDistanceControl(theParent);
-
   } else if (theType == WDG_FILE_SELECTOR) {
     result = fileSelectorControl(theParent);
 
@@ -170,7 +162,7 @@ QWidget* ModuleBase_WidgetFactory::createWidgetByType(const std::string& theType
     result = createContainer(theType, theParent);
   } else {
     result = myWorkshop->module()->createWidgetByType(theType, theParent, myWidgetApi,
-                                                      myModelWidgets);
+                                                      myParentId, myModelWidgets);
 #ifdef _DEBUG
     if (!result) {qDebug("ModuleBase_WidgetFactory::fillWidget: find bad widget type");}
 #endif
@@ -206,30 +198,6 @@ QWidget* ModuleBase_WidgetFactory::doubleSpinBoxControl(QWidget* theParent)
   return aDblWgt->getControl();
 }
 
-QWidget* ModuleBase_WidgetFactory::pointSelectorControl(QWidget* theParent)
-{
-  ModuleBase_WidgetPoint2D* aWidget =
-      new ModuleBase_WidgetPoint2D(theParent, myWidgetApi,myParentId);
-  myModelWidgets.append(aWidget);
-  return aWidget->getControl();
-}
-
-QWidget* ModuleBase_WidgetFactory::featureSelectorControl(QWidget* theParent)
-{
-  ModuleBase_WidgetFeature* aWidget =
-      new ModuleBase_WidgetFeature(theParent, myWidgetApi,myParentId);
-  myModelWidgets.append(aWidget);
-  return aWidget->getControl();
-}
-
-QWidget* ModuleBase_WidgetFactory::featureOrAttributeSelectorControl(QWidget* theParent)
-{
-  ModuleBase_WidgetFeatureOrAttribute* aWidget =
-      new ModuleBase_WidgetFeatureOrAttribute(theParent, myWidgetApi, myParentId);
-  myModelWidgets.append(aWidget);
-  return aWidget->getControl();
-}
-
 QWidget* ModuleBase_WidgetFactory::doubleValueEditor(QWidget* theParent)
 {
   ModuleBase_WidgetEditor* aWidget =
@@ -254,14 +222,6 @@ QWidget* ModuleBase_WidgetFactory::booleanControl(QWidget* theParent)
   return aBoolWgt->getControl();
 }
 
-QWidget* ModuleBase_WidgetFactory::point2dDistanceControl(QWidget* theParent)
-{
-  ModuleBase_WidgetPoint2dDistance* aDistWgt =
-      new ModuleBase_WidgetPoint2dDistance(theParent, myWidgetApi, myParentId);
-  myModelWidgets.append(aDistWgt);
-  return aDistWgt->getControl();
-}
-
 QWidget* ModuleBase_WidgetFactory::fileSelectorControl(QWidget* theParent)
 {
   ModuleBase_WidgetFileSelector* aFileSelectorWgt =
@@ -298,3 +258,4 @@ QString ModuleBase_WidgetFactory::qs(const std::string& theStdString) const
 {
   return QString::fromStdString(theStdString);
 }
+
index fd267d41801bd144d92aa5841b20f71ece86af69..f81ee61c982ff850b9747c050a3a4394e8764d04 100644 (file)
@@ -1,3 +1,5 @@
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
 /*
  * ModuleBase_WidgetFactory.h
  *
@@ -39,13 +41,9 @@ class MODULEBASE_EXPORT ModuleBase_WidgetFactory
   QWidget* createContainer(const std::string& theType, QWidget* theParent = NULL);
   QWidget* labelControl(QWidget* theParent);
   QWidget* doubleSpinBoxControl(QWidget* theParent);
-  QWidget* pointSelectorControl(QWidget* theParent);
-  QWidget* featureSelectorControl(QWidget* theParent);
-  QWidget* featureOrAttributeSelectorControl(QWidget* theParent);
   QWidget* doubleValueEditor(QWidget* theParent);
   QWidget* shapeSelectorControl(QWidget* theParent);
   QWidget* booleanControl(QWidget* theParent);
-  QWidget* point2dDistanceControl(QWidget* theParent);
   QWidget* fileSelectorControl(QWidget* theParent);
   QWidget* choiceControl(QWidget* theParent);
   QWidget* lineEditControl(QWidget* theParent);
diff --git a/src/ModuleBase/ModuleBase_WidgetFeature.cpp b/src/ModuleBase/ModuleBase_WidgetFeature.cpp
deleted file mode 100644 (file)
index 3b28aeb..0000000
+++ /dev/null
@@ -1,160 +0,0 @@
-// File:        ModuleBase_WidgetFeature.cpp
-// Created:     25 Apr 2014
-// Author:      Natalia ERMOLAEVA
-
-#include <ModuleBase_WidgetFeature.h>
-
-#include <ModuleBase_WidgetValueFeature.h>
-#include <ModuleBase_WidgetValue.h>
-#include <ModuleBase_Tools.h>
-
-#include <Config_Keywords.h>
-#include <Config_WidgetAPI.h>
-
-#include <Events_Loop.h>
-
-#include <ModelAPI_Events.h>
-#include <ModelAPI_Feature.h>
-#include <ModelAPI_Data.h>
-#include <ModelAPI_Object.h>
-#include <ModelAPI_AttributeRefAttr.h>
-#include <ModelAPI_Validator.h>
-#include <ModelAPI_ResultValidator.h>
-#include <ModelAPI_RefAttrValidator.h>
-#include <ModelAPI_Session.h>
-
-#include <QWidget>
-#include <QLineEdit>
-#include <QHBoxLayout>
-#include <QLabel>
-
-ModuleBase_WidgetFeature::ModuleBase_WidgetFeature(QWidget* theParent,
-                                                   const Config_WidgetAPI* theData,
-                                                   const std::string& theParentId)
-    : ModuleBase_ModelWidget(theParent, theData, theParentId)
-{
-  myContainer = new QWidget(theParent);
-  QHBoxLayout* aControlLay = new QHBoxLayout(myContainer);
-  ModuleBase_Tools::adjustMargins(aControlLay);
-
-  QString aLabelText = QString::fromStdString(theData->widgetLabel());
-  myLabel = new QLabel(aLabelText, myContainer);
-  aControlLay->addWidget(myLabel);
-
-  myEditor = new QLineEdit(myContainer);
-  QString anObjName = QString::fromStdString(attributeID());
-  myEditor->setObjectName(anObjName);
-  myEditor->setReadOnly(true);
-  aControlLay->addWidget(myEditor);
-
-  QString aTTip = QString::fromStdString(theData->widgetTooltip());
-  myEditor->setToolTip(aTTip);
-  aControlLay->addWidget(myEditor);
-  aControlLay->setStretch(1, 1);
-}
-
-ModuleBase_WidgetFeature::~ModuleBase_WidgetFeature()
-{
-}
-
-bool ModuleBase_WidgetFeature::setValue(ModuleBase_WidgetValue* theValue)
-{
-  bool isDone = false;
-
-  if (theValue) {
-    ModuleBase_WidgetValueFeature* aFeatureValue =
-        dynamic_cast<ModuleBase_WidgetValueFeature*>(theValue);
-    if (aFeatureValue)
-      isDone = setObject(aFeatureValue->object());
-  }
-  return isDone;
-}
-
-bool ModuleBase_WidgetFeature::setObject(const ObjectPtr& theObject, bool theSendEvent)
-{
-  SessionPtr aMgr = ModelAPI_Session::get();
-  ModelAPI_ValidatorsFactory* aFactory = aMgr->validators();
-  std::list<ModelAPI_Validator*> aValidators;
-  std::list<std::list<std::string> > anArguments;
-  aFactory->validators(parentID(), attributeID(), aValidators, anArguments);
-
-  // Check the type of selected object
-  std::list<ModelAPI_Validator*>::iterator aValidator = aValidators.begin();
-  bool isValid = true;
-  for (; aValidator != aValidators.end(); aValidator++) {
-    const ModelAPI_ResultValidator* aResValidator =
-        dynamic_cast<const ModelAPI_ResultValidator*>(*aValidator);
-    if (aResValidator) {
-      isValid = false;
-      if (aResValidator->isValid(theObject)) {
-        isValid = true;
-        break;
-      }
-    }
-  }
-  if (!isValid)
-    return false;
-
-  // Check the acceptability of the object as attribute
-  aValidator = aValidators.begin();
-  std::list<std::list<std::string> >::iterator aArgs = anArguments.begin();
-  for (; aValidator != aValidators.end(); aValidator++, aArgs++) {
-    const ModelAPI_RefAttrValidator* aAttrValidator =
-        dynamic_cast<const ModelAPI_RefAttrValidator*>(*aValidator);
-    if (aAttrValidator) {
-      if (!aAttrValidator->isValid(myFeature, *aArgs, theObject)) {
-        return false;
-      }
-    }
-  }
-
-  myObject = theObject;
-  myEditor->setText(theObject ? theObject->data()->name().c_str() : "");
-  if (theSendEvent)
-    emit valuesChanged();
-  return true;
-}
-
-bool ModuleBase_WidgetFeature::storeValue() const
-{
-  //FeaturePtr aFeature = std::dynamic_pointer_cast<ModelAPI_Feature>(theObject);
-  if (!myObject)
-    return false;
-
-  std::shared_ptr<ModelAPI_Data> aData = myFeature->data();
-  std::shared_ptr<ModelAPI_AttributeRefAttr> aRef = std::dynamic_pointer_cast<
-      ModelAPI_AttributeRefAttr>(aData->attribute(attributeID()));
-
-  ModuleBase_WidgetFeature* that = (ModuleBase_WidgetFeature*) this;
-  aRef->setObject(myObject);
-  myFeature->execute();
-  updateObject(myFeature);
-  return true;
-}
-
-bool ModuleBase_WidgetFeature::restoreValue()
-{
-  std::shared_ptr<ModelAPI_Data> aData = myFeature->data();
-  std::shared_ptr<ModelAPI_AttributeRefAttr> aRef = std::dynamic_pointer_cast<
-      ModelAPI_AttributeRefAttr>(aData->attribute(attributeID()));
-
-  ObjectPtr anObjPtr = aRef->object();
-  if (anObjPtr) {
-    myObject = anObjPtr;
-    myEditor->setText(myObject ? myObject->data()->name().c_str() : "");
-    return true;
-  }
-  return false;
-}
-
-QWidget* ModuleBase_WidgetFeature::getControl() const
-{
-  return myContainer;
-}
-
-QList<QWidget*> ModuleBase_WidgetFeature::getControls() const
-{
-  QList<QWidget*> aList;
-  aList.append(myEditor);
-  return aList;
-}
diff --git a/src/ModuleBase/ModuleBase_WidgetFeature.h b/src/ModuleBase/ModuleBase_WidgetFeature.h
deleted file mode 100644 (file)
index ec74136..0000000
+++ /dev/null
@@ -1,96 +0,0 @@
-// File:        ModuleBase_WidgetFeature.h
-// Created:     25 Apr 2014
-// Author:      Natalia ERMOLAEVA
-
-#ifndef ModuleBase_WidgetFeature_H
-#define ModuleBase_WidgetFeature_H
-
-#include <ModuleBase.h>
-#include "ModuleBase_ModelWidget.h"
-
-#include <QObject>
-#include <QStringList>
-
-class ModuleBase_WidgetValue;
-class ModelAPI_Feature;
-class QWidget;
-class QLabel;
-class QLineEdit;
-class QToolButton;
-
-/**\class ModuleBase_WidgetFeature
- * \ingroup GUI
- * \brief Custom widget. An abstract class to be redefined to fill with some GUI controls
- */
-class MODULEBASE_EXPORT ModuleBase_WidgetFeature : public ModuleBase_ModelWidget
-{
-Q_OBJECT
- public:
-  /// Constructor
-  /// \theParent the parent object
-  /// \theParent the parent object
-  /// \theData the widget configuation. The attribute of the model widget is obtained from
-  ModuleBase_WidgetFeature(QWidget* theParent, const Config_WidgetAPI* theData,
-                           const std::string& theParentId);
-  /// Destructor
-  virtual ~ModuleBase_WidgetFeature();
-
-  /// Set the given wrapped value to the current widget
-  /// This value should be processed in the widget according to the needs
-  /// \param theValue the wrapped widget value
-  virtual bool setValue(ModuleBase_WidgetValue* theValue);
-
-  /// Saves the internal parameters to the given feature
-  /// \param theFeature a model feature to be changed
-  virtual bool storeValue() const;
-
-  virtual bool restoreValue();
-
-  /// Returns the internal parent wiget control, that can be shown anywhere
-  /// \returns the widget
-  QWidget* getControl() const;
-
-  /// Returns list of widget controls
-  /// \return a control list
-  virtual QList<QWidget*> getControls() const;
-  /// Defines if it is supposed that the widget should interact with the viewer.
-  virtual bool isViewerSelector() { return true; }
-
- protected:
-  /// Fill the widget values by given point
-  /// \param thePoint the point
-  /// \return the boolean result of the feature set
-  bool setObject(const ObjectPtr& theObject, bool theSendEvent = true);
-
-  /// Returns current widget feature
-  /// \return the feature
-  const ObjectPtr object() const
-  {
-    return myObject;
-  }
-
-  /// Returns the widget editor
-  /// \return the editor
-  QLineEdit* editor() const
-  {
-    return myEditor;
-  }
-
-  /// Returns the possible feature kinds
-  /// \return the list of kinds
-  const QStringList& featureKinds() const
-  {
-    return myObjectKinds;
-  }
-
- protected:
-  ObjectPtr myObject;  ///< the current widget feature
-  QStringList myObjectKinds;  ///< the kinds of possible features
-
- private:
-  QWidget* myContainer;  /// the parent top control
-  QLabel* myLabel;  /// the editor information label
-  QLineEdit* myEditor;  ///< the feature editor to visualize the feature name
-};
-
-#endif
diff --git a/src/ModuleBase/ModuleBase_WidgetFeatureOrAttribute.cpp b/src/ModuleBase/ModuleBase_WidgetFeatureOrAttribute.cpp
deleted file mode 100644 (file)
index 9c05258..0000000
+++ /dev/null
@@ -1,179 +0,0 @@
-// File:        ModuleBase_WidgetFeatureOrAttribute.cpp
-// Created:     25 Apr 2014
-// Author:      Natalia ERMOLAEVA
-
-#include <ModuleBase_WidgetFeatureOrAttribute.h>
-
-#include <ModuleBase_WidgetValueFeature.h>
-#include <ModuleBase_WidgetValue.h>
-
-#include <ModelAPI_RefAttrValidator.h>
-#include <ModelAPI_Session.h>
-
-#include <Config_Keywords.h>
-#include <Config_WidgetAPI.h>
-
-#include <Events_Loop.h>
-#include <ModelAPI_Events.h>
-
-#include <ModelAPI_Feature.h>
-#include <ModelAPI_Data.h>
-#include <ModelAPI_Object.h>
-#include <ModelAPI_AttributeRefAttr.h>
-#include <ModelAPI_Validator.h>
-
-#include <GeomAPI_Pnt2d.h>
-
-#include <GeomDataAPI_Point2D.h>
-
-#include <Precision.hxx>
-
-#include <QWidget>
-#include <QLineEdit>
-#include <QHBoxLayout>
-#include <QLabel>
-
-ModuleBase_WidgetFeatureOrAttribute::ModuleBase_WidgetFeatureOrAttribute(QWidget* theParent, 
-                                                                         const Config_WidgetAPI* theData, 
-                                                                         const std::string& theParentId)
-    : ModuleBase_WidgetFeature(theParent, theData, theParentId)
-{
-}
-
-ModuleBase_WidgetFeatureOrAttribute::~ModuleBase_WidgetFeatureOrAttribute()
-{
-}
-
-bool ModuleBase_WidgetFeatureOrAttribute::setValue(ModuleBase_WidgetValue* theValue)
-{
-  bool isDone = false;
-
-  if (theValue) {
-    ModuleBase_WidgetValueFeature* aFeatureValue =
-        dynamic_cast<ModuleBase_WidgetValueFeature*>(theValue);
-    if (aFeatureValue) {
-      ObjectPtr aObject = aFeatureValue->object();
-
-      std::shared_ptr<ModelAPI_Attribute> anAttribute = findAttribute(aFeatureValue);
-      if (anAttribute) {
-        isDone = setAttribute(anAttribute, false);
-      }
-      else if (aObject) {
-        isDone = setObject(aObject, false);
-      }
-
-      if (isDone)
-        emit valuesChanged();
-    }
-  }
-  return isDone;
-}
-
-bool ModuleBase_WidgetFeatureOrAttribute::storeValue() const
-{
-  //FeaturePtr aFeature = std::dynamic_pointer_cast<ModelAPI_Feature>(theFeature);
-  //if (!aFeature)
-  //  return false;
-
-  std::shared_ptr<ModelAPI_Data> aData = myFeature->data();
-  std::shared_ptr<ModelAPI_AttributeRefAttr> aRef = std::dynamic_pointer_cast<
-      ModelAPI_AttributeRefAttr>(aData->attribute(attributeID()));
-
-  if (myObject)
-    aRef->setObject(myObject);
-  if (myAttribute)
-    aRef->setAttr(myAttribute);
-
-  myFeature->execute();
-  updateObject(myFeature);
-
-  return true;
-}
-
-bool ModuleBase_WidgetFeatureOrAttribute::restoreValue()
-{
-  std::shared_ptr<ModelAPI_Data> aData = myFeature->data();
-  std::shared_ptr<ModelAPI_AttributeRefAttr> aRef = std::dynamic_pointer_cast<
-      ModelAPI_AttributeRefAttr>(aData->attribute(attributeID()));
-
-  ObjectPtr aObj = aRef->object();
-  FeaturePtr aFeature = ModelAPI_Feature::feature(aRef->object());
-  if (aFeature) {
-    myObject = aFeature;
-    myAttribute = aRef->attr();
-
-    std::string aText = "";
-    if (aFeature)
-      aText = aFeature->data()->name().c_str();
-    if (myAttribute)
-      aText = myAttribute->attributeType().c_str();
-
-    editor()->setText(aText.c_str());
-    return true;
-  }
-  return false;
-}
-
-std::shared_ptr<ModelAPI_Attribute> ModuleBase_WidgetFeatureOrAttribute::findAttribute(
-                                                        ModuleBase_WidgetValue* theValue)
-{
-  std::shared_ptr<ModelAPI_Attribute> anAttribute;
-  ModuleBase_WidgetValueFeature* aFeatureValue =
-                                  dynamic_cast<ModuleBase_WidgetValueFeature*>(theValue);
-  if (!aFeatureValue)
-    return anAttribute;
-
-  std::shared_ptr<GeomAPI_Pnt2d> aValuePoint = aFeatureValue->point();
-  if (aValuePoint) {
-    ObjectPtr aObject = aFeatureValue->object();
-    FeaturePtr aFeature = ModelAPI_Feature::feature(aObject);
-    if (aFeature) {
-      // find the given point in the feature attributes
-      std::list<std::shared_ptr<ModelAPI_Attribute> > anAttiributes = aFeature->data()
-          ->attributes(GeomDataAPI_Point2D::type());
-      std::list<std::shared_ptr<ModelAPI_Attribute> >::const_iterator anIt = anAttiributes
-          .begin(), aLast = anAttiributes.end();
-      for (; anIt != aLast && !anAttribute; anIt++) {
-        std::shared_ptr<GeomDataAPI_Point2D> aCurPoint = std::dynamic_pointer_cast<
-            GeomDataAPI_Point2D>(*anIt);
-        if (aCurPoint && aCurPoint->pnt()->distance(aValuePoint) < Precision::Confusion())
-          anAttribute = aCurPoint;
-      }
-    }
-  }
-  return anAttribute;
-}
-
-bool ModuleBase_WidgetFeatureOrAttribute::setAttribute(
-    const std::shared_ptr<ModelAPI_Attribute>& theAttribute, bool theSendEvent)
-{
-  if (!theAttribute)  // || !featureKinds().contains(theAttribute->attributeType().c_str()))
-    return false;
-
-  SessionPtr aMgr = ModelAPI_Session::get();
-  ModelAPI_ValidatorsFactory* aFactory = aMgr->validators();
-  std::list<ModelAPI_Validator*> aValidators;
-  std::list<std::list<std::string> > anArguments;
-  aFactory->validators(parentID(), attributeID(), aValidators, anArguments);
-
-  // Check the acceptability of the attribute
-  std::list<ModelAPI_Validator*>::iterator aValidator = aValidators.begin();
-  int aSize = aValidators.size();
-  std::list<std::list<std::string> >::iterator aArgs = anArguments.begin();
-  for (; aValidator != aValidators.end(); aValidator++, aArgs++) {
-    const ModelAPI_RefAttrValidator* aAttrValidator =
-        dynamic_cast<const ModelAPI_RefAttrValidator*>(*aValidator);
-    if (aAttrValidator) {
-      if (!aAttrValidator->isValid(myFeature, *aArgs, theAttribute)) {
-        return false;
-      }
-    }
-  }
-
-  myAttribute = theAttribute;
-  editor()->setText(theAttribute ? theAttribute->attributeType().c_str() : "");
-  if (theSendEvent)
-    emit valuesChanged();
-  return true;
-}
-
diff --git a/src/ModuleBase/ModuleBase_WidgetFeatureOrAttribute.h b/src/ModuleBase/ModuleBase_WidgetFeatureOrAttribute.h
deleted file mode 100644 (file)
index 5fac251..0000000
+++ /dev/null
@@ -1,62 +0,0 @@
-// File:        ModuleBase_WidgetFeatureOrAttribute.h
-// Created:     25 Apr 2014
-// Author:      Natalia ERMOLAEVA
-
-#ifndef ModuleBase_WidgetFeatureOrAttribute_H
-#define ModuleBase_WidgetFeatureOrAttribute_H
-
-#include <ModuleBase.h>
-#include "ModuleBase_WidgetFeature.h"
-
-#include <QObject>
-
-class ModuleBase_WidgetValue;
-class ModelAPI_Attribute;
-
-/**\class ModuleBase_WidgetFeatureOrAttribute
- * \ingroup GUI
- * \brief Custom widget. An abstract class to be redefined to fill with some GUI controls
- */
-class MODULEBASE_EXPORT ModuleBase_WidgetFeatureOrAttribute : public ModuleBase_WidgetFeature
-{
-Q_OBJECT
- public:
-  /// Constructor
-  /// \theParent the parent object
-  /// \theParent the parent object
-  /// \theData the widget configuation. The attribute of the model widget is obtained from
-  ModuleBase_WidgetFeatureOrAttribute(QWidget* theParent, const Config_WidgetAPI* theData,
-                                      const std::string& theParentId);
-  /// Destructor
-  virtual ~ModuleBase_WidgetFeatureOrAttribute();
-
-  /// Set the given wrapped value to the current widget
-  /// This value should be processed in the widget according to the needs
-  /// \param theValue the wrapped widget value
-  virtual bool setValue(ModuleBase_WidgetValue* theValue);
-
-  /// Saves the internal parameters to the given feature
-  /// \param theFeature a model feature to be changed
-  virtual bool storeValue() const;
-
-  virtual bool restoreValue();
-  /// Defines if it is supposed that the widget should interact with the viewer.
-  virtual bool isViewerSelector() { return true; }
-
- protected:
-   /// Returns the feature attribute if it can be found by the given value
-   /// \param theValue the widget value
-   /// \return an attribute or null
-   std::shared_ptr<ModelAPI_Attribute> findAttribute(ModuleBase_WidgetValue* theValue);
-
-  /// Set the attribute
-  /// \param theAttribute value
-  /// \return the boolean result of the attribute set
-  bool setAttribute(const std::shared_ptr<ModelAPI_Attribute>& theAttribute, bool theSendEvent =
-                        true);
-
- protected:
-  std::shared_ptr<ModelAPI_Attribute> myAttribute;  /// < the attribute
-};
-
-#endif
index 2fb71922adff9c26e199d59d27b48aef2502a067..b82971d1f627d32ff56045a1ba8af4de34f7b551 100644 (file)
@@ -1,3 +1,5 @@
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
 /*
  * ModuleBase_WidgetFileSelector.cpp
  *
index 4e78830aa2b8b7fe8fed6dad7b857472f34b42bb..2133fe786aebda828553e6972886b9be34879b1d 100644 (file)
@@ -1,3 +1,5 @@
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
 /*
  * ModuleBase_WidgetFileSelector.h
  *
diff --git a/src/ModuleBase/ModuleBase_WidgetLabel.cpp b/src/ModuleBase/ModuleBase_WidgetLabel.cpp
new file mode 100644 (file)
index 0000000..d5ffd01
--- /dev/null
@@ -0,0 +1,37 @@
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
+// File:        ModuleBase_WidgetLabel.cpp
+// Created:     03 Dec 2014
+// Author:      Vitaly SMETANNIKOV
+
+#include "ModuleBase_WidgetLabel.h"
+
+#include <Config_WidgetAPI.h>
+
+#include <QLabel>
+
+
+ModuleBase_WidgetLabel::ModuleBase_WidgetLabel(QWidget* theParent,
+                                                     const Config_WidgetAPI* theData,
+                                                     const std::string& theParentId)
+    : ModuleBase_ModelWidget(theParent, theData, theParentId)
+{
+  QString aText = QString::fromStdString(theData->getProperty("title"));
+  myLabel = new QLabel(aText, theParent);
+  myLabel->setWordWrap(true);
+  myLabel->setIndent(5);
+}
+
+ModuleBase_WidgetLabel::~ModuleBase_WidgetLabel()
+{
+}
+
+QList<QWidget*> ModuleBase_WidgetLabel::getControls() const
+{
+  return QList<QWidget*>();
+}
+
+QWidget* ModuleBase_WidgetLabel::getControl() const
+{
+  return myLabel;
+}
diff --git a/src/ModuleBase/ModuleBase_WidgetLabel.h b/src/ModuleBase/ModuleBase_WidgetLabel.h
new file mode 100644 (file)
index 0000000..3fbf7e8
--- /dev/null
@@ -0,0 +1,49 @@
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
+// File:        ModuleBase_WidgetLabel.h
+// Created:     03 Dec 2014
+// Author:      Vitaly SMETANNIKOV
+
+#ifndef ModuleBase_WidgetLabel_H
+#define ModuleBase_WidgetLabel_H
+
+#include "ModuleBase.h"
+#include "ModuleBase_ModelWidget.h"
+
+class QLabel;
+
+class MODULEBASE_EXPORT ModuleBase_WidgetLabel : public ModuleBase_ModelWidget
+{
+Q_OBJECT
+ public:
+  ModuleBase_WidgetLabel(QWidget* theParent, const Config_WidgetAPI* theData,
+                            const std::string& theParentId);
+
+  virtual ~ModuleBase_WidgetLabel();
+
+  /// Defines if it is supported to set the value in this widget
+  /// It returns false because this is an info widget
+  virtual bool canSetValue() const { return false; };
+
+  virtual bool storeValue() const
+  {
+    return true;
+  }
+
+  virtual bool restoreValue()
+  {
+    return true;
+  }
+
+  virtual QList<QWidget*> getControls() const;
+
+  QWidget* getControl() const;
+
+  /// This control doesn't accept focus
+  virtual bool focusTo() { return false; }
+
+private:
+  QLabel* myLabel;
+};
+
+#endif
\ No newline at end of file
index 19771a66fd10deb7b3fb7e3c22d546d1725582f1..91af0aa943e439ddcaa37006ed11809bfbf31ec1 100644 (file)
@@ -1,3 +1,5 @@
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
 /*
  * ModuleBase_WidgetLineEdit.cpp
  *
index 92eff345980ebcd3fa98e57d3e4600e9c597d7ea..09d02fae3dda726b77069c7d06698577806b09a3 100644 (file)
@@ -1,3 +1,5 @@
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
 /*
  * ModuleBase_WidgetLineEdit.h
  *
index ea21968a10618d8e6ee9a29161d873644473f118..5c50ce38e318088dcc86d4182a45c35fae5901de 100644 (file)
@@ -1,3 +1,5 @@
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
 /*
  * ModuleBase_WidgetMultiSelector.cpp
  *
@@ -54,9 +56,10 @@ ModuleBase_WidgetMultiSelector::ModuleBase_WidgetMultiSelector(QWidget* theParen
 
   myListControl = new QListWidget(myMainWidget);
   aMainLay->addWidget(myListControl, 2, 0, 2, -1);
-  aMainLay->setColumnStretch(1, 1);
+  aMainLay->setRowStretch(2, 1);
+  aMainLay->addWidget(new QLabel(myMainWidget));
+  aMainLay->setRowMinimumHeight(3, 20);
   myMainWidget->setLayout(aMainLay);
-
   //TODO: Move into the base class
   myUseSubShapes = theData->getBooleanAttribute("use_subshapes", false);
   //TODO_END
@@ -163,7 +166,7 @@ void ModuleBase_WidgetMultiSelector::activateSelection(bool toActivate)
 void ModuleBase_WidgetMultiSelector::onSelectionTypeChanged()
 {
   activateShapeSelection();
-  QList<ObjectPtr> anEmptyList;
+  QObjectPtrList anEmptyList;
   myWorkshop->setSelected(anEmptyList);
   // Clear mySelection, myListControl and storeValue()
   onSelectionChanged();
index f94a19e2fab4dee39ccf373b9f34c9295f14c542..c38f72d072e1075be0c5c635abf627d9696d0570 100644 (file)
@@ -1,3 +1,5 @@
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
 /*
  * ModuleBase_WidgetMultiSelector.h
  *
diff --git a/src/ModuleBase/ModuleBase_WidgetPoint2D.cpp b/src/ModuleBase/ModuleBase_WidgetPoint2D.cpp
deleted file mode 100644 (file)
index 1308702..0000000
+++ /dev/null
@@ -1,177 +0,0 @@
-// File:        ModuleBase_WidgetPoint2D.cpp
-// Created:     25 Apr 2014
-// Author:      Natalia ERMOLAEVA
-
-#include <ModuleBase_WidgetPoint2D.h>
-#include <ModuleBase_WidgetValueFeature.h>
-#include <ModuleBase_DoubleSpinBox.h>
-#include <ModuleBase_Tools.h>
-
-#include <Config_Keywords.h>
-#include <Config_WidgetAPI.h>
-
-#include <Events_Loop.h>
-#include <ModelAPI_Events.h>
-
-#include <ModelAPI_Feature.h>
-#include <ModelAPI_Data.h>
-#include <ModelAPI_Object.h>
-#include <GeomDataAPI_Point2D.h>
-#include <GeomAPI_Pnt2d.h>
-
-#include <QGroupBox>
-#include <QGridLayout>
-#include <QLabel>
-#include <QEvent>
-
-#include <cfloat>
-#include <climits>
-
-ModuleBase_WidgetPoint2D::ModuleBase_WidgetPoint2D(QWidget* theParent,
-                                                   const Config_WidgetAPI* theData,
-                                                   const std::string& theParentId)
-    : ModuleBase_ModelWidget(theParent, theData, theParentId)
-{
-  myOptionParam = theData->getProperty(PREVIOUS_FEATURE_PARAM);
-  QString aPageName = QString::fromStdString(theData->getProperty(CONTAINER_PAGE_NAME));
-  myGroupBox = new QGroupBox(aPageName, theParent);
-  myGroupBox->setFlat(false);
-
-  QGridLayout* aGroupLay = new QGridLayout(myGroupBox);
-  ModuleBase_Tools::adjustMargins(aGroupLay);
-  aGroupLay->setColumnStretch(1, 1);
-  {
-    QLabel* aLabel = new QLabel(myGroupBox);
-    aLabel->setText("X");
-    aLabel->setPixmap(QPixmap(":pictures/x_point.png"));
-    aGroupLay->addWidget(aLabel, 0, 0);
-
-    myXSpin = new ModuleBase_DoubleSpinBox(myGroupBox);
-    myXSpin->setMinimum(-DBL_MAX);
-    myXSpin->setMaximum(DBL_MAX);
-    myXSpin->setToolTip("X");
-    aGroupLay->addWidget(myXSpin, 0, 1);
-
-    connect(myXSpin, SIGNAL(valueChanged(double)), this, SIGNAL(valuesChanged()));
-  }
-  {
-    QLabel* aLabel = new QLabel(myGroupBox);
-    aLabel->setText("Y");
-    aLabel->setPixmap(QPixmap(":pictures/y_point.png"));
-    aGroupLay->addWidget(aLabel, 1, 0);
-
-    myYSpin = new ModuleBase_DoubleSpinBox(myGroupBox);
-    myYSpin->setMinimum(-DBL_MAX);
-    myYSpin->setMaximum(DBL_MAX);
-    myYSpin->setToolTip("X");
-    aGroupLay->addWidget(myYSpin, 1, 1);
-
-    connect(myYSpin, SIGNAL(valueChanged(double)), this, SIGNAL(valuesChanged()));
-  }
-}
-
-ModuleBase_WidgetPoint2D::~ModuleBase_WidgetPoint2D()
-{
-}
-
-bool ModuleBase_WidgetPoint2D::setValue(ModuleBase_WidgetValue* theValue)
-{
-  bool isDone = false;
-  if (theValue) {
-    ModuleBase_WidgetValueFeature* aFeatureValue =
-        dynamic_cast<ModuleBase_WidgetValueFeature*>(theValue);
-    if (aFeatureValue) {
-      std::shared_ptr<GeomAPI_Pnt2d> aPoint = aFeatureValue->point();
-      if (aPoint) {
-        setPoint(aPoint);
-        isDone = true;
-      }
-    }
-  }
-  return isDone;
-}
-
-void ModuleBase_WidgetPoint2D::setPoint(const std::shared_ptr<GeomAPI_Pnt2d>& thePoint)
-{
-
-  bool isBlocked = this->blockSignals(true);
-  myXSpin->setValue(thePoint->x());
-  myYSpin->setValue(thePoint->y());
-  this->blockSignals(isBlocked);
-
-  emit valuesChanged();
-}
-
-bool ModuleBase_WidgetPoint2D::storeValue() const
-{
-  std::shared_ptr<ModelAPI_Data> aData = myFeature->data();
-  std::shared_ptr<GeomDataAPI_Point2D> aPoint = std::dynamic_pointer_cast<GeomDataAPI_Point2D>(
-      aData->attribute(attributeID()));
-  
-  ModuleBase_WidgetPoint2D* that = (ModuleBase_WidgetPoint2D*) this;
-  bool isBlocked = that->blockSignals(true);
-  bool isImmutable = aPoint->setImmutable(true);
-#ifdef _DEBUG
-  std::string _attr_name = myAttributeID;
-  double _X = myXSpin->value();
-  double _Y = myYSpin->value();
-#endif
-  aPoint->setValue(myXSpin->value(), myYSpin->value());
-  updateObject(myFeature);
-  aPoint->setImmutable(isImmutable);
-  that->blockSignals(isBlocked);
-
-  return true;
-}
-
-bool ModuleBase_WidgetPoint2D::restoreValue()
-{
-  std::shared_ptr<ModelAPI_Data> aData = myFeature->data();
-  std::shared_ptr<GeomDataAPI_Point2D> aPoint = std::dynamic_pointer_cast<GeomDataAPI_Point2D>(
-      aData->attribute(attributeID()));
-
-#ifdef _DEBUG
-  std::string _attr_name = myAttributeID;
-  double _X = aPoint->x();
-  double _Y = aPoint->y();
-#endif
-  bool isBlocked = this->blockSignals(true);
-  myXSpin->setValue(aPoint->x());
-  myYSpin->setValue(aPoint->y());
-  this->blockSignals(isBlocked);
-  return true;
-}
-
-QWidget* ModuleBase_WidgetPoint2D::getControl() const
-{
-  return myGroupBox;
-}
-
-QList<QWidget*> ModuleBase_WidgetPoint2D::getControls() const
-{
-  QList<QWidget*> aControls;
-  aControls.push_back(myXSpin);
-  aControls.push_back(myYSpin);
-
-  return aControls;
-}
-
-bool ModuleBase_WidgetPoint2D::initFromPrevious(ObjectPtr theObject)
-{
-  if (myOptionParam.length() == 0)
-    return false;
-  std::shared_ptr<ModelAPI_Data> aData = theObject->data();
-  std::shared_ptr<GeomDataAPI_Point2D> aPoint = std::dynamic_pointer_cast<GeomDataAPI_Point2D>(
-      aData->attribute(myOptionParam));
-  if (aPoint) {
-    bool isBlocked = this->blockSignals(true);
-    myXSpin->setValue(aPoint->x());
-    myYSpin->setValue(aPoint->y());
-    this->blockSignals(isBlocked);
-
-    emit valuesChanged();
-    emit storedPoint2D(theObject, myOptionParam);
-    return true;
-  }
-  return false;
-}
diff --git a/src/ModuleBase/ModuleBase_WidgetPoint2D.h b/src/ModuleBase/ModuleBase_WidgetPoint2D.h
deleted file mode 100644 (file)
index 3942119..0000000
+++ /dev/null
@@ -1,77 +0,0 @@
-// File:        ModuleBase_WidgetPoint2D.h
-// Created:     25 Apr 2014
-// Author:      Natalia ERMOLAEVA
-
-#ifndef ModuleBase_WidgetPoint2D_H
-#define ModuleBase_WidgetPoint2D_H
-
-#include <ModuleBase.h>
-#include "ModuleBase_ModelWidget.h"
-
-#include <QObject>
-
-class ModelAPI_Feature;
-class ModuleBase_WidgetValue;
-class GeomAPI_Pnt2d;
-
-class QGroupBox;
-class ModuleBase_DoubleSpinBox;
-
-/**\class ModuleBase_WidgetPoint2D
- * \ingroup GUI
- * \brief Custom widget. An abstract class to be redefined to fill with some GUI controls
- */
-class MODULEBASE_EXPORT ModuleBase_WidgetPoint2D : public ModuleBase_ModelWidget
-{
-Q_OBJECT
- public:
-  /// Constructor
-  /// \theParent the parent object
-  /// \theParent the parent object
-  /// \theData the widget configuation. The attribute of the model widget is obtained from
-  ModuleBase_WidgetPoint2D(QWidget* theParent, const Config_WidgetAPI* theData,
-                           const std::string& theParentId);
-  /// Destructor
-  virtual ~ModuleBase_WidgetPoint2D();
-
-  /// Set the given wrapped value to the current widget
-  /// This value should be processed in the widget according to the needs
-  /// \param theValue the wrapped widget value
-  virtual bool setValue(ModuleBase_WidgetValue* theValue);
-
-  /// Saves the internal parameters to the given feature
-  /// \param theObject a model feature to be changed
-  virtual bool storeValue() const;
-
-  virtual bool restoreValue();
-
-  /// Returns the internal parent wiget control, that can be shown anywhere
-  /// \returns the widget
-  QWidget* getControl() const;
-
-  /// Returns list of widget controls
-  /// \return a control list
-  virtual QList<QWidget*> getControls() const;
-
-  bool initFromPrevious(ObjectPtr theObject);
-
-signals:
-  /// Signal about the point 2d set to the feature
-  /// \param the feature
-  /// \param the attribute of the feature
-  void storedPoint2D(ObjectPtr theObject, const std::string& theAttribute);
-
- protected:
-  /// Fill the widget values by given point
-  /// \param thePoint the point
-  void setPoint(const std::shared_ptr<GeomAPI_Pnt2d>& thePoint);
-
- private:
-  QGroupBox* myGroupBox;  ///< the parent group box for all intenal widgets
-  ModuleBase_DoubleSpinBox* myXSpin;  ///< the spin box for the X coordinate
-  ModuleBase_DoubleSpinBox* myYSpin;  ///< the spin box for the Y coordinate
-
-  std::string myOptionParam;  /// Parameter name which has to be taken from previous feature
-};
-
-#endif
diff --git a/src/ModuleBase/ModuleBase_WidgetPoint2dDistance.cpp b/src/ModuleBase/ModuleBase_WidgetPoint2dDistance.cpp
deleted file mode 100644 (file)
index 210f4bc..0000000
+++ /dev/null
@@ -1,63 +0,0 @@
-// File:        ModuleBase_WidgetPoint2dDistance.h
-// Created:     23 June 2014
-// Author:      Vitaly Smetannikov
-
-#include <ModuleBase_WidgetPoint2dDistance.h>
-#include <ModuleBase_WidgetValueFeature.h>
-#include <ModuleBase_DoubleSpinBox.h>
-
-#include <GeomAPI_Pnt2d.h>
-#include <Config_WidgetAPI.h>
-#include <GeomDataAPI_Point2D.h>
-
-#include <ModelAPI_Data.h>
-#include <ModelAPI_AttributeDouble.h>
-
-ModuleBase_WidgetPoint2dDistance::ModuleBase_WidgetPoint2dDistance(QWidget* theParent,
-                                                                   const Config_WidgetAPI* theData,
-                                                                   const std::string& theParentId)
-    : ModuleBase_WidgetDoubleValue(theParent, theData, theParentId)
-{
-  myFirstPntName = theData->getProperty("first_point");
-}
-
-ModuleBase_WidgetPoint2dDistance::~ModuleBase_WidgetPoint2dDistance()
-{
-}
-
-bool ModuleBase_WidgetPoint2dDistance::setValue(ModuleBase_WidgetValue* theValue)
-{
-  bool isDone = false;
-
-  if (theValue) {
-    ModuleBase_WidgetValueFeature* aFeatureValue =
-        dynamic_cast<ModuleBase_WidgetValueFeature*>(theValue);
-    if (aFeatureValue) {
-      std::shared_ptr<GeomAPI_Pnt2d> aPnt = aFeatureValue->point();
-      ObjectPtr aObject = aFeatureValue->object();
-      FeaturePtr aFeature = std::dynamic_pointer_cast<ModelAPI_Feature>(aObject);
-      if (aFeature && aPnt) {
-        setPoint(aFeature, aPnt);
-        isDone = true;
-      }
-    }
-  }
-  return isDone;
-}
-
-void ModuleBase_WidgetPoint2dDistance::setPoint(FeaturePtr theFeature,
-                                                const std::shared_ptr<GeomAPI_Pnt2d>& thePnt)
-{
-  std::shared_ptr<ModelAPI_Data> aData = theFeature->data();
-  std::shared_ptr<GeomDataAPI_Point2D> aPoint = std::dynamic_pointer_cast<GeomDataAPI_Point2D>(
-      aData->attribute(myFirstPntName));
-  if (!aPoint)
-    return;
-
-  double aRadius = thePnt->distance(aPoint->pnt());
-  AttributeDoublePtr aReal = aData->real(attributeID());
-  if (aReal && (aReal->value() != aRadius)) {
-    aReal->setValue(aRadius);
-    mySpinBox->setValue(aRadius);
-  }
-}
diff --git a/src/ModuleBase/ModuleBase_WidgetPoint2dDistance.h b/src/ModuleBase/ModuleBase_WidgetPoint2dDistance.h
deleted file mode 100644 (file)
index e80aa39..0000000
+++ /dev/null
@@ -1,39 +0,0 @@
-// File:        ModuleBase_WidgetPoint2dDistance.h
-// Created:     23 June 2014
-// Author:      Vitaly Smetannikov
-
-#ifndef ModuleBase_WidgetPoint2dDistance_H
-#define ModuleBase_WidgetPoint2dDistance_H
-
-#include "ModuleBase.h"
-#include "ModuleBase_WidgetDoubleValue.h"
-
-class ModuleBase_WidgetValue;
-class GeomAPI_Pnt2d;
-
-class MODULEBASE_EXPORT ModuleBase_WidgetPoint2dDistance : public ModuleBase_WidgetDoubleValue
-{
-Q_OBJECT
- public:
-  /// Constructor
-  /// \theParent the parent object
-  /// \theData the widget configuation. The attribute of the model widget is obtained from
-  ModuleBase_WidgetPoint2dDistance(QWidget* theParent, const Config_WidgetAPI* theData,
-                                   const std::string& theParentId);
-
-  virtual ~ModuleBase_WidgetPoint2dDistance();
-
-  /// Set the given wrapped value to the current widget
-  /// This value should be processed in the widget according to the needs
-  /// \param theValue the wrapped widget value
-  virtual bool setValue(ModuleBase_WidgetValue* theValue);
-
- protected:
-  /// Set the second point which defines a value in the widget as a distance with a first point defined by feature
-  void setPoint(FeaturePtr theFeature, const std::shared_ptr<GeomAPI_Pnt2d>& thePnt);
-
- private:
-  std::string myFirstPntName;
-};
-
-#endif
index 91cc255e8c7af1d3d5416549a88853f95d00a6ca..1ef62f92a0788a56d77ea8959fb891a321d48963 100644 (file)
@@ -1,3 +1,5 @@
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
 // File:        ModuleBase_WidgetShapeSelector.h
 // Created:     2 June 2014
 // Author:      Vitaly Smetannikov
 #include <ModuleBase_IWorkshop.h>
 #include <ModuleBase_IViewer.h>
 #include <ModuleBase_Tools.h>
-#include <ModuleBase_WidgetValueFeature.h>
+#include <ModuleBase_FilterFactory.h>
+#include <ModuleBase_Filter.h>
 
 #include <Config_WidgetAPI.h>
 #include <Events_Loop.h>
 #include <Events_Message.h>
 #include <GeomAPI_Interface.h>
 #include <GeomAPI_Shape.h>
+
 #include <ModelAPI_AttributeReference.h>
 #include <ModelAPI_Data.h>
 #include <ModelAPI_Document.h>
 #include <ModelAPI_Session.h>
 #include <ModelAPI_Tools.h>
 #include <ModelAPI_ResultBody.h>
+#include <ModelAPI_AttributeRefAttr.h>
+#include <ModelAPI_Validator.h>
+#include <ModelAPI_ResultValidator.h>
+#include <ModelAPI_RefAttrValidator.h>
+
 #include <Config_WidgetAPI.h>
 #include <Events_Error.h>
 
 #include <GeomAPI_Shape.h>
 
+#include <SelectMgr_ListIteratorOfListOfFilter.hxx>
 #include <TopoDS_Shape.hxx>
 #include <TopExp_Explorer.hxx>
 
@@ -43,6 +53,7 @@
 #include <QString>
 #include <QEvent>
 #include <QDockWidget>
+#include <QApplication>
 
 #include <TopExp_Explorer.hxx>
 #include <TopoDS_Shape.hxx>
@@ -127,43 +138,95 @@ bool ModuleBase_WidgetShapeSelector::storeValue() const
 
   DataPtr aData = myFeature->data();
   if (myUseSubShapes) {
-    std::shared_ptr<ModelAPI_AttributeSelection> aSelect = 
-      std::dynamic_pointer_cast<ModelAPI_AttributeSelection>(aData->attribute(attributeID()));
-
     ResultPtr aBody = std::dynamic_pointer_cast<ModelAPI_Result>(mySelectedObject);
     if (aBody) {
-      aSelect->setValue(aBody, myShape);
-      updateObject(myFeature);
-      return true;
+      AttributePtr aAttr = aData->attribute(attributeID());
+
+      // We have to check several attributes types
+      AttributeSelectionPtr aSelectAttr = 
+        std::dynamic_pointer_cast<ModelAPI_AttributeSelection>(aAttr);
+      if (aSelectAttr) {
+        aSelectAttr->setValue(aBody, myShape);
+        updateObject(myFeature);
+        return true;
+      } else {
+        AttributeRefAttrPtr aRefAttr = aData->refattr(attributeID());
+        if (aRefAttr) {
+          aRefAttr->setObject(mySelectedObject);
+          updateObject(myFeature);
+          return true;
+        }
+      }
     }
   } else {
-    std::shared_ptr<ModelAPI_AttributeReference> aRef = 
-      std::dynamic_pointer_cast<ModelAPI_AttributeReference>(aData->attribute(attributeID()));
-
-    ObjectPtr aObject = aRef->value();
-    if (!(aObject && aObject->isSame(mySelectedObject))) {
-      aRef->setValue(mySelectedObject);
-      updateObject(myFeature);
-      return true;
+    AttributeReferencePtr aRef = aData->reference(attributeID());
+    if (aRef) {
+      ObjectPtr aObject = aRef->value();
+      if (!(aObject && aObject->isSame(mySelectedObject))) {
+        aRef->setValue(mySelectedObject);
+        updateObject(myFeature);
+        return true;
+      }
+    } else {
+      AttributeRefAttrPtr aRefAttr = aData->refattr(attributeID());
+      if (aRefAttr) {
+        ObjectPtr aObject = aRefAttr->object();
+        if (!(aObject && aObject->isSame(mySelectedObject))) {
+          aRefAttr->setObject(mySelectedObject);
+          updateObject(myFeature);
+          return true;
+        }
+      }
     }
   }
   return false;
 }
 
+//********************************************************************
+void ModuleBase_WidgetShapeSelector::clearAttribute()
+{
+  DataPtr aData = myFeature->data();
+  AttributeSelectionPtr aSelect = aData->selection(attributeID());
+  if (aSelect) {
+    aSelect->setValue(ResultPtr(), std::shared_ptr<GeomAPI_Shape>(new GeomAPI_Shape()));
+    return;
+  }
+  AttributeRefAttrPtr aRefAttr = aData->refattr(attributeID());
+  if (aRefAttr) {
+    aRefAttr->setObject(ObjectPtr());
+    return;
+  }
+  AttributeReferencePtr aRef = aData->reference(attributeID());
+  if (aRef) {
+    aRef->setObject(ObjectPtr());
+  }
+}
+
 //********************************************************************
 bool ModuleBase_WidgetShapeSelector::restoreValue()
 {
   DataPtr aData = myFeature->data();
   bool isBlocked = this->blockSignals(true);
   if (myUseSubShapes) {
-    std::shared_ptr<ModelAPI_AttributeSelection> aSelect = aData->selection(attributeID());
+    AttributeSelectionPtr aSelect = aData->selection(attributeID());
     if (aSelect) {
       mySelectedObject = aSelect->context();
       myShape = aSelect->value();
+    } else {
+      AttributeRefAttrPtr aRefAttr = aData->refattr(attributeID());
+      if (aRefAttr) {
+        mySelectedObject = aRefAttr->object();
+      }
     }
   } else {
-    std::shared_ptr<ModelAPI_AttributeReference> aRef = aData->reference(attributeID());
-    mySelectedObject = aRef->value();
+    AttributeReferencePtr aRef = aData->reference(attributeID());
+    if (aRef)
+      mySelectedObject = aRef->value();
+    else {
+      AttributeRefAttrPtr aRefAttr = aData->refattr(attributeID());
+      if (aRefAttr)
+        mySelectedObject = aRefAttr->object();
+    }
   }
   updateSelectionName();
 
@@ -182,64 +245,74 @@ QList<QWidget*> ModuleBase_WidgetShapeSelector::getControls() const
 //********************************************************************
 void ModuleBase_WidgetShapeSelector::onSelectionChanged()
 {
-  QList<ObjectPtr> aObjects = myWorkshop->selection()->selectedObjects();
-  if (aObjects.size() > 0) {
-    ObjectPtr aObject = aObjects.first();
-    if ((!mySelectedObject) && (!aObject))
-      return;
+  // In order to make reselection possible
+  // TODO: check with MPV clearAttribute();
+
+  //QObjectPtrList aObjects = myWorkshop->selection()->selectedPresentations();
+  QList<ModuleBase_ViewerPrs> aSelected = myWorkshop->selection()->getSelected();
+  if (aSelected.size() > 0) {
+    if (setSelection(aSelected.first()))
+      emit focusOutWidget(this);
+  }
+}
 
-    // Check that the selected object is result (others can not be accepted)
-    ResultPtr aRes = std::dynamic_pointer_cast<ModelAPI_Result>(aObject);
-    if (!aRes)
-      return;
+//********************************************************************
+bool ModuleBase_WidgetShapeSelector::setSelection(ModuleBase_ViewerPrs theValue)
+{
+  ObjectPtr aObject = theValue.object();
+  if ((!mySelectedObject) && (!aObject))
+    return false;
 
-    if (myFeature) {
-      // We can not select a result of our feature
-      const std::list<std::shared_ptr<ModelAPI_Result>>& aResList = myFeature->results();
-      std::list<std::shared_ptr<ModelAPI_Result> >::const_iterator aIt;
-      for (aIt = aResList.cbegin(); aIt != aResList.cend(); ++aIt) {
-        if ((*aIt) == aRes)
-          return;
-      }
+  // Check that the selected object is result (others can not be accepted)
+  ResultPtr aRes = std::dynamic_pointer_cast<ModelAPI_Result>(aObject);
+  if (!aRes)
+    return false;
+
+  if (myFeature) {
+    // We can not select a result of our feature
+    const std::list<std::shared_ptr<ModelAPI_Result>>& aResList = myFeature->results();
+    std::list<std::shared_ptr<ModelAPI_Result> >::const_iterator aIt;
+    for (aIt = aResList.cbegin(); aIt != aResList.cend(); ++aIt) {
+      if ((*aIt) == aRes)
+        return false;
     }
-    // Check that object belongs to active document or PartSet
-    DocumentPtr aDoc = aRes->document();
-    SessionPtr aMgr = ModelAPI_Session::get();
-    if (!(aDoc == aMgr->activeDocument()) || (aDoc == aMgr->moduleDocument()))
-      return;
+  }
+  // Check that object belongs to active document or PartSet
+  DocumentPtr aDoc = aRes->document();
+  SessionPtr aMgr = ModelAPI_Session::get();
+  if (!(aDoc == aMgr->activeDocument()) && !(aDoc == aMgr->moduleDocument()))
+    return false;
 
-    // Check that the result has a shape
-    GeomShapePtr aShape = ModelAPI_Tools::shape(aRes);
-    if (!aShape)
-      return;
+  // Check that the result has a shape
+  GeomShapePtr aShape = ModelAPI_Tools::shape(aRes);
+  if (!aShape)
+    return false;
 
-    /// Check that object has acceptable type
-    if (!acceptObjectType(aObject)) 
-      return;
+  /// Check that object has acceptable type
+  if (!acceptObjectType(aObject)) 
+    return false;
 
-    // Get sub-shapes from local selection
-    if (myUseSubShapes) {
-      NCollection_List<TopoDS_Shape> aShapeList;
-      std::list<ObjectPtr> aOwners;
-      myWorkshop->selection()->selectedShapes(aShapeList, aOwners);
-      if (aShapeList.Extent() > 0) {
-        aShape = std::shared_ptr<GeomAPI_Shape>(new GeomAPI_Shape());
-        aShape->setImpl(new TopoDS_Shape(aShapeList.First()));
-      }
+  // Get sub-shapes from local selection
+  if (myUseSubShapes) {
+    if (!theValue.shape().IsNull()) {
+      aShape = std::shared_ptr<GeomAPI_Shape>(new GeomAPI_Shape());
+      aShape->setImpl(new TopoDS_Shape(theValue.shape()));
     }
+  }
 
-    // Check that the selection corresponds to selection type
-    if (myUseSubShapes) {
-      if (!acceptSubShape(aShape))
-        return;
-    } else {
-      if (!acceptObjectShape(aObject))
-        return;
-    }
+  // Check that the selection corresponds to selection type
+  if (myUseSubShapes) {
+    if (!acceptSubShape(aShape))
+      return false;
+  } else {
+    if (!acceptObjectShape(aObject))
+      return false;
+  }
+  if (isValid(aObject, aShape)) {
     setObject(aObject, aShape);
-    //activateSelection(false);
-    emit focusOutWidget(this);
+    return true;
   }
+  return false;
 }
 
 //********************************************************************
@@ -249,13 +322,8 @@ void ModuleBase_WidgetShapeSelector::setObject(ObjectPtr theObj, std::shared_ptr
   myShape = theShape;
   if (mySelectedObject) {
     raisePanel();
-    if (!myUseSubShapes) {
-      static Events_ID anEvent = Events_Loop::eventByName(EVENT_OBJECT_TOHIDE);
-      ModelAPI_EventCreator::get()->sendUpdated(mySelectedObject, anEvent);
-    }
   } 
   updateSelectionName();
-  activateSelection(false);
   emit valuesChanged();
 }
 
@@ -336,8 +404,11 @@ void ModuleBase_WidgetShapeSelector::updateSelectionName()
 //********************************************************************
 void ModuleBase_WidgetShapeSelector::activateSelection(bool toActivate)
 {
+  if (myIsActive == toActivate)
+    return;
   myIsActive = toActivate;
   updateSelectionName();
+  ModuleBase_IViewer* aViewer = myWorkshop->viewer();
 
   if (myIsActive) {
     connect(myWorkshop, SIGNAL(selectionChanged()), this, SLOT(onSelectionChanged()));
@@ -349,20 +420,38 @@ void ModuleBase_WidgetShapeSelector::activateSelection(bool toActivate)
       myWorkshop->activateSubShapesSelection(aList);
       if (!myObjectTypes.isEmpty()) {
         myObjTypeFilter = new ModuleBase_ObjectTypesFilter(myWorkshop, myObjectTypes);
-        myWorkshop->viewer()->clearSelectionFilters();
-        myWorkshop->viewer()->addSelectionFilter(myObjTypeFilter);
+        aViewer->clearSelectionFilters();
+        aViewer->addSelectionFilter(myObjTypeFilter);
       }
     }
   } else {
     disconnect(myWorkshop, SIGNAL(selectionChanged()), this, SLOT(onSelectionChanged()));
     if (myUseSubShapes) {
       if (!myObjTypeFilter.IsNull()) {
-        myWorkshop->viewer()->removeSelectionFilter(myObjTypeFilter);
+        aViewer->removeSelectionFilter(myObjTypeFilter);
         myObjTypeFilter.Nullify();
       }
       myWorkshop->deactivateSubShapesSelection();
     }
   }
+  // apply filters loaded from the XML definition of the widget
+  ModuleBase_FilterFactory* aFactory = myWorkshop->selectionFilters();
+  SelectMgr_ListOfFilter aFilters;
+  aFactory->filters(parentID(), attributeID(), aFilters);
+  SelectMgr_ListIteratorOfListOfFilter aIt(aFilters);
+  for (; aIt.More(); aIt.Next()) {
+    Handle(SelectMgr_Filter) aSelFilter = aIt.Value();
+    if (aSelFilter.IsNull())
+      continue;
+
+    //Handle(ModuleBase_Filter) aFilter = Handle(ModuleBase_Filter)::DownCast(aIt.Value());
+    //if (aFilter.IsNull())
+    //  continue;
+    if (myIsActive)
+      aViewer->addSelectionFilter(aSelFilter);
+    else
+      aViewer->removeSelectionFilter(aSelFilter);
+  }
 }
 
 //********************************************************************
@@ -383,36 +472,67 @@ void ModuleBase_WidgetShapeSelector::raisePanel() const
 }
 
 //********************************************************************
-bool ModuleBase_WidgetShapeSelector::focusTo()
+//bool ModuleBase_WidgetShapeSelector::setSelection(ModuleBase_ViewerPrs theValue)
+//{
+//  if (theValue.object()) {
+//    ObjectPtr aObject = theValue.object();
+//    if (acceptObjectShape(aObject)) {
+//      setObject(aObject);
+//      return true;
+//    }
+//  }
+//  return false;
+//}
+
+//********************************************************************
+void ModuleBase_WidgetShapeSelector::activate()
 {
   activateSelection(true);
-  return ModuleBase_ModelWidget::focusTo();
 }
 
 //********************************************************************
-bool ModuleBase_WidgetShapeSelector::eventFilter(QObject* theObj, QEvent* theEvent)
+void ModuleBase_WidgetShapeSelector::deactivate()
 {
-  if (theObj == myTextLine) {
-    if (theEvent->type() == QEvent::FocusIn)
-      activateSelection(true);
-  }
-  return ModuleBase_ModelWidget::eventFilter(theObj, theEvent);
+  activateSelection(false);
 }
 
 //********************************************************************
-bool ModuleBase_WidgetShapeSelector::setValue(ModuleBase_WidgetValue* theValue)
+bool ModuleBase_WidgetShapeSelector::isValid(ObjectPtr theObj, std::shared_ptr<GeomAPI_Shape> theShape)
 {
-  if (theValue) {
-    ModuleBase_WidgetValueFeature* aFeatureValue =
-        dynamic_cast<ModuleBase_WidgetValueFeature*>(theValue);
-    if (aFeatureValue && aFeatureValue->object()) {
-      ObjectPtr aObject = aFeatureValue->object();
-      if (acceptObjectShape(aObject)) {
-        setObject(aObject);
-        return true;
+  SessionPtr aMgr = ModelAPI_Session::get();
+  ModelAPI_ValidatorsFactory* aFactory = aMgr->validators();
+  std::list<ModelAPI_Validator*> aValidators;
+  std::list<std::list<std::string> > anArguments;
+  aFactory->validators(parentID(), attributeID(), aValidators, anArguments);
+
+  // Check the type of selected object
+  std::list<ModelAPI_Validator*>::iterator aValidator = aValidators.begin();
+  bool isValid = true;
+  for (; aValidator != aValidators.end(); aValidator++) {
+    const ModelAPI_ResultValidator* aResValidator =
+        dynamic_cast<const ModelAPI_ResultValidator*>(*aValidator);
+    if (aResValidator) {
+      isValid = false;
+      if (aResValidator->isValid(theObj)) {
+        isValid = true;
+        break;
       }
     }
   }
-  return false;
-}
+  if (!isValid)
+    return false;
 
+  // Check the acceptability of the object as attribute
+  aValidator = aValidators.begin();
+  std::list<std::list<std::string> >::iterator aArgs = anArguments.begin();
+  for (; aValidator != aValidators.end(); aValidator++, aArgs++) {
+    const ModelAPI_RefAttrValidator* aAttrValidator =
+        dynamic_cast<const ModelAPI_RefAttrValidator*>(*aValidator);
+    if (aAttrValidator) {
+      if (!aAttrValidator->isValid(myFeature, *aArgs, theObj)) {
+        return false;
+      }
+    }
+  }
+  return true;
+}
\ No newline at end of file
index 7284d8ae59ec8c7e305457122850d1a75f53c1b3..a64932a247c8056265864b62b45ae6f7a1329019 100644 (file)
@@ -1,3 +1,5 @@
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
 // File:        ModuleBase_WidgetShapeSelector.h
 // Created:     2 June 2014
 // Author:      Vitaly Smetannikov
@@ -35,13 +37,10 @@ Q_OBJECT
   virtual ~ModuleBase_WidgetShapeSelector();
 
   /// Saves the internal parameters to the given feature
-  /// \param theObject a model feature to be changed
   virtual bool storeValue() const;
 
   virtual bool restoreValue();
 
-  virtual bool focusTo();
-
   /// Returns the internal parent wiget control, that can be shown anywhere
   /// \returns the widget
   QWidget* getControl() const
@@ -61,7 +60,15 @@ Q_OBJECT
   /// Set the given wrapped value to the current widget
   /// This value should be processed in the widget according to the needs
   /// \param theValue the wrapped widget value
-  virtual bool setValue(ModuleBase_WidgetValue* theValue);
+  virtual bool setSelection(ModuleBase_ViewerPrs theValue);
+
+
+  /// The methiod called when widget is activated
+  virtual void activate();
+
+  /// The methiod called when widget is deactivated
+  virtual void deactivate();
+
 
  public slots:
 
@@ -72,8 +79,6 @@ Q_OBJECT
   void onSelectionChanged();
 
  protected:
-  bool eventFilter(QObject* theObj, QEvent* theEvent);
-
   void updateSelectionName();
   void raisePanel() const;
 
@@ -93,8 +98,14 @@ Q_OBJECT
   // Set the given object as a value of the widget
   void setObject(ObjectPtr theObj, std::shared_ptr<GeomAPI_Shape> theShape = std::shared_ptr<GeomAPI_Shape>());
 
+  /// Check the selected with validators if installed
+  virtual bool isValid(ObjectPtr theObj, std::shared_ptr<GeomAPI_Shape> theShape);
+
+  /// Clear attribute
+  void clearAttribute();
+
   //----------- Class members -------------
- private:
+ protected:
   QWidget* myContainer;
   QLabel* myLabel;
   QLineEdit* myTextLine;
index a6e20a8cfffc2f8a253c53c9cf8d6f6aede60278..e1571cab161848fa45b510b48aa75cbc410ca996 100644 (file)
@@ -1,3 +1,5 @@
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
 /*
  * ModuleBase_WidgetSwitch.cpp
  *
index f7a442e41ad12b9cf8528b3dd80909b14f204a3f..e6e6eec91d3d658eedda831ae7eb0a71ba05c8c5 100644 (file)
@@ -1,3 +1,5 @@
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
 /*
  * ModuleBase_WidgetSwitch.h
  *
diff --git a/src/ModuleBase/ModuleBase_WidgetValue.cpp b/src/ModuleBase/ModuleBase_WidgetValue.cpp
deleted file mode 100644 (file)
index 83a9d27..0000000
+++ /dev/null
@@ -1,13 +0,0 @@
-// File:        ModuleBase_WidgetValue.cpp
-// Created:     25 Apr 2014
-// Author:      Natalia ERMOLAEVA
-
-#include <ModuleBase_WidgetValue.h>
-
-ModuleBase_WidgetValue::ModuleBase_WidgetValue()
-{
-}
-
-ModuleBase_WidgetValue::~ModuleBase_WidgetValue()
-{
-}
diff --git a/src/ModuleBase/ModuleBase_WidgetValue.h b/src/ModuleBase/ModuleBase_WidgetValue.h
deleted file mode 100644 (file)
index 38b8e51..0000000
+++ /dev/null
@@ -1,23 +0,0 @@
-// File:        ModuleBase_WidgetValue.h
-// Created:     25 Apr 2014
-// Author:      Natalia ERMOLAEVA
-
-#ifndef ModuleBase_WidgetValue_H
-#define ModuleBase_WidgetValue_H
-
-#include <ModuleBase.h>
-
-/**\class ModuleBase_WidgetValue
- * \ingroup GUI
- * \brief Custom widget value. An abstract class to be redefined and to be set in the model widget
- */
-class MODULEBASE_EXPORT ModuleBase_WidgetValue
-{
- public:
-  /// Constructor
-  ModuleBase_WidgetValue();
-  /// Destructor
-  virtual ~ModuleBase_WidgetValue();
-};
-
-#endif
diff --git a/src/ModuleBase/ModuleBase_WidgetValueFeature.cpp b/src/ModuleBase/ModuleBase_WidgetValueFeature.cpp
deleted file mode 100644 (file)
index 43d3a7c..0000000
+++ /dev/null
@@ -1,35 +0,0 @@
-// File:        ModuleBase_WidgetValueFeature.cpp
-// Created:     25 Apr 2014
-// Author:      Natalia ERMOLAEVA
-
-#include <ModuleBase_WidgetValueFeature.h>
-
-#include <GeomAPI_Pnt2d.h>
-
-ModuleBase_WidgetValueFeature::ModuleBase_WidgetValueFeature()
-{
-}
-
-ModuleBase_WidgetValueFeature::~ModuleBase_WidgetValueFeature()
-{
-}
-
-void ModuleBase_WidgetValueFeature::setObject(const ObjectPtr& theFeature)
-{
-  myResult = theFeature;
-}
-
-const ObjectPtr& ModuleBase_WidgetValueFeature::object() const
-{
-  return myResult;
-}
-
-void ModuleBase_WidgetValueFeature::setPoint(const std::shared_ptr<GeomAPI_Pnt2d>& thePoint)
-{
-  myPoint = thePoint;
-}
-
-const std::shared_ptr<GeomAPI_Pnt2d>& ModuleBase_WidgetValueFeature::point() const
-{
-  return myPoint;
-}
diff --git a/src/ModuleBase/ModuleBase_WidgetValueFeature.h b/src/ModuleBase/ModuleBase_WidgetValueFeature.h
deleted file mode 100644 (file)
index d11a6bf..0000000
+++ /dev/null
@@ -1,50 +0,0 @@
-// File:        ModuleBase_WidgetValueFeature.h
-// Created:     25 Apr 2014
-// Author:      Natalia ERMOLAEVA
-
-#ifndef ModuleBase_WidgetValueFeature_H
-#define ModuleBase_WidgetValueFeature_H
-
-#include <ModuleBase.h>
-#include <ModuleBase_WidgetValue.h>
-
-#include <ModelAPI_Result.h>
-
-#include <memory>
-
-class GeomAPI_Pnt2d;
-
-/**\class ModuleBase_WidgetValueFeature
- * \ingroup GUI
- * \brief Custom widget value. The widget contains a feature and 2D point.
- */
-class ModuleBase_WidgetValueFeature : public ModuleBase_WidgetValue
-{
- public:
-  /// Constructor
-  MODULEBASE_EXPORT ModuleBase_WidgetValueFeature();
-  /// Destructor
-  MODULEBASE_EXPORT virtual ~ModuleBase_WidgetValueFeature();
-
-  /// Fill the widget values by given point
-  /// \param thePoint the point
-  MODULEBASE_EXPORT void setObject(const ObjectPtr& theFeature);
-
-  /// Returns the widget values by given point
-  /// \return theFeature the current feature
-  MODULEBASE_EXPORT const ObjectPtr& object() const;
-
-  /// Fill the widget values by given point
-  /// \param thePoint the point
-  MODULEBASE_EXPORT void setPoint(const std::shared_ptr<GeomAPI_Pnt2d>& thePoint);
-
-  /// Returns the widget point
-  /// \return the current point
-  MODULEBASE_EXPORT const std::shared_ptr<GeomAPI_Pnt2d>& point() const;
-
- private:
-  ObjectPtr myResult;
-  std::shared_ptr<GeomAPI_Pnt2d> myPoint;
-};
-
-#endif
index cf0f687418de3c8782315c823730c23db65e7faa..979269418dfebfbf1c72e1cc791532872c0a6425 100644 (file)
@@ -1,3 +1,5 @@
+## Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
 
 SET(CMAKE_AUTOMOC ON)
 
index 4490c442b461961206ff1266f2160e0c5bd70a87..a8c6978f4f4ece7154be5ffc58843b7b80168b04 100644 (file)
@@ -1,3 +1,5 @@
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
 #ifndef NewGeom_H
 #define NewGeom_H
 
index 8593ab6323e07099cf5e6d28a38c913b9f84776d..88e7db728e938d5396200949082ac24b0b026ab3 100644 (file)
@@ -1,3 +1,5 @@
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
 #include "NewGeom_DataModel.h"
 #include "NewGeom_Module.h"
 
 #include <LightApp_Study.h>
 #include <CAM_Application.h>
 #include <SUIT_Tools.h>
+#include <SUIT_ResourceMgr.h>
 
 #include <QFile>
-
+#include <QDir>
 
 NewGeom_DataModel::NewGeom_DataModel(NewGeom_Module* theModule)
-    : LightApp_DataModel(theModule), myModule(theModule)
+    : LightApp_DataModel(theModule), myStudyPath(""), myModule(theModule)
 {
 }
 
@@ -27,12 +30,42 @@ bool NewGeom_DataModel::open(const QString& thePath, CAM_Study* theStudy, QStrin
   if (theFiles.size() == 0)
     return false;
 
-  QString aFile = theFiles.first();
+  myStudyPath = thePath;
+
+  // If the file is Multi(contain all module files inside), the open SALOME functionality creates
+  // these files in a temporary directory. After the open functionality is finished, it removes
+  // these files (in the full SALOME mode).
+  // The postponed loading of the files is realized in the NewGEOM module. So, it is important do
+  // not remove the opened files.
+  // The following code creates a new tmp directory with a copy of files.
+  QString aTmpDir = theFiles.first();
+
+  LightApp_Study* aStudy = dynamic_cast<LightApp_Study*>( myModule->application()->activeStudy() );
+  QString aNewTmpDir = aStudy->GetTmpDir("", false).c_str();
+
+  bool isDone = true;
+  QDir aDir(aTmpDir);
+  QStringList aFiles = aDir.entryList(QDir::Files);
+  QStringList::const_iterator anIt = aFiles.begin(), aLast = aFiles.end();
+  for (; anIt != aLast; anIt++) {
+    QString aFileName = *anIt;
+
+    QString aCurrentFile = SUIT_Tools::addSlash(aTmpDir) + aFileName;
+    QString aNewFile = SUIT_Tools::addSlash(aNewTmpDir) + aFileName;
+    if (!QFile::copy(aCurrentFile, aNewFile))
+      isDone = false;
+  }
+  if (isDone) {
+    myTmpDirectory = aNewTmpDir;
+  }
+  else {
+    removeDirectory(aNewTmpDir);
+    myTmpDirectory = "";
+  }
 
   SessionPtr aMgr = ModelAPI_Session::get();
-  aMgr->load(qPrintable(aFile));
+  aMgr->load(qPrintable(aNewTmpDir));
   myModule->setIsOpened(true);
-  myStudyPath = aFile;
   return true;
 }
 
@@ -42,8 +75,17 @@ bool NewGeom_DataModel::save(QStringList& theFiles)
   XGUI_Workshop* aWorkShop = myModule->workshop();
   std::list<std::string> aFileNames;
 
-  LightApp_Study* aStudy = dynamic_cast<LightApp_Study*>( myModule->application()->activeStudy() );
-  std::string aTmpDir = aStudy->GetTmpDir(qPrintable(myStudyPath), true );
+  CAM_Application* anApp = myModule->application();
+  LightApp_Study* aStudy = dynamic_cast<LightApp_Study*>(anApp->activeStudy());
+  SUIT_ResourceMgr* aResMgr = anApp->resourceMgr();
+
+  // it is important to check whether the file is saved in the multi-files mode in order to save
+  // files in temporary directories, which are removed in the full SALOME mode after copiying
+  // the files content in a result file.
+  bool isMultiFile = aResMgr ? aResMgr->booleanValue("Study", "multi_file", false) : false;
+
+  std::string aTmpDir = aStudy->GetTmpDir(qPrintable(myStudyPath), isMultiFile);
+  //std::string aTmpDir = aStudy->GetTmpDir("", false);//true );
   theFiles.append(QString(aTmpDir.c_str()));
 
   aWorkShop->saveDocument(QString(aTmpDir.c_str()), aFileNames);
@@ -66,6 +108,8 @@ bool NewGeom_DataModel::saveAs(const QString& thePath, CAM_Study* theStudy, QStr
 bool NewGeom_DataModel::close()
 {
   myModule->workshop()->closeDocument();
+  removeDirectory(myTmpDirectory);
+  myTmpDirectory = "";
   return LightApp_DataModel::close();
 }
 
@@ -88,3 +132,9 @@ bool NewGeom_DataModel::isSaved() const
 void NewGeom_DataModel::update(LightApp_DataObject* theObj, LightApp_Study* theStudy)
 {
 }
+
+void NewGeom_DataModel::removeDirectory(const QString& theDirectoryName)
+{
+  Qtx::rmDir(theDirectoryName);
+}
+
index fbd90dd44353a32f5585f7b434e4295114b42486..1024f275d6526488dff58f37acee2f9a42fcec8c 100644 (file)
@@ -1,3 +1,5 @@
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
 
 #ifndef NEWGEOM_DATAMODEL_H
 #define NEWGEOM_DATAMODEL_H
@@ -25,8 +27,18 @@ class NewGeom_EXPORT NewGeom_DataModel : public LightApp_DataModel
 
   virtual void update(LightApp_DataObject* theObj = 0, LightApp_Study* theStudy = 0);
 
+protected:
+  /**
+   * Removes the directory with content if it exists
+   * \param theDirectoryName a directory name
+   */
+  static void removeDirectory(const QString& theDirectoryName);
+
  private:
   QString myStudyPath;
+  QString myTmpDirectory; /// a path to the temporary directory, created by opening a document file
+  /// it should be created because the files reading is postponed in the module. The directory
+  // should be removed after the model document is closed.
   NewGeom_Module* myModule;
 };
 
index 9f8bc4543a6ee76012b5b0515195bd9c35e7f6ff..c9d875f1373ed6781255f440c61e6cfbdc2e6a38 100644 (file)
@@ -1,3 +1,5 @@
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
 
 #include "NewGeom_Module.h"
 #include "NewGeom_DataModel.h"
@@ -6,15 +8,16 @@
 #include <XGUI_Workshop.h>
 #include <XGUI_PropertyPanel.h>
 #include <XGUI_ContextMenuMgr.h>
-#include <XGUI_Preferences.h>
 #include <XGUI_ObjectsBrowser.h>
 #include <XGUI_OperationMgr.h>
 
 #include <ModuleBase_Operation.h>
+#include <ModuleBase_Preferences.h>
 
 #include <LightApp_Application.h>
 #include <LightApp_SelectionMgr.h>
 #include <LightApp_OCCSelector.h>
+#include <LightApp_Study.h>
 #include <OCCViewer_ViewModel.h>
 
 #include <SUIT_Selector.h>
@@ -45,7 +48,7 @@ NewGeom_EXPORT char* getModuleVersion()
 }
 }
 
-class NewGeom_PrefMgr: public XGUI_IPrefMgr
+class NewGeom_PrefMgr: public ModuleBase_IPrefMgr
 {
 public:
   NewGeom_PrefMgr(LightApp_Preferences* theMgr, const QString& theModName):myMgr(theMgr), myModName(theModName) {}
@@ -57,6 +60,14 @@ public:
     return myMgr->addPreference(myModName, theLbl, pId, theType, theSection, theName);
   }
 
+  virtual void setItemProperty(const QString& thePropName,
+                               const QVariant& theValue,
+                               const int theId = -1)
+  {
+    myMgr->setItemProperty(thePropName, theValue, theId);
+  }
+
+
   virtual SUIT_PreferenceMgr* prefMgr() const { return myMgr; }
 
 private:
@@ -73,10 +84,13 @@ NewGeom_Module::NewGeom_Module()
       mySelector(0), myIsOpened(0), myPopupMgr(0)
 {
   myWorkshop = new XGUI_Workshop(this);
+  connect(myWorkshop, SIGNAL(commandStatusUpdated()),
+          this, SLOT(onUpdateCommandStatus()));
+
   myProxyViewer = new NewGeom_SalomeViewer(this);
 
-  XGUI_Preferences::setResourceMgr(application()->resourceMgr());
-  XGUI_Preferences::loadCustomProps();
+  ModuleBase_Preferences::setResourceMgr(application()->resourceMgr());
+  ModuleBase_Preferences::loadCustomProps();
 }
 
 //******************************************************
@@ -139,9 +153,13 @@ bool NewGeom_Module::activateModule(SUIT_Study* theStudy)
       myIsOpened = false;
       QTimer::singleShot(1000, myWorkshop, SLOT(displayAllResults()));
     }
+    else
+      myWorkshop->updateCommandStatus();
   }
   SUIT_ResourceMgr* aResMgr = application()->resourceMgr();
   myIsStorePositions = aResMgr->booleanValue("Study", "store_positions", true);
+  myIsEditEnabled = getApp()->isEditEnabled();
+  getApp()->setEditEnabled(false);
 
   // this following row is caused by #187 bug.
   // SALOME saves the dock widget positions before deactivateModule() and
@@ -189,6 +207,7 @@ bool NewGeom_Module::deactivateModule(SUIT_Study* theStudy)
 
   SUIT_ResourceMgr* aResMgr = application()->resourceMgr();
   aResMgr->setValue("Study", "store_positions", myIsStorePositions);
+  getApp()->setEditEnabled(myIsEditEnabled);
 
   return LightApp_Module::deactivateModule(theStudy);
 }
@@ -212,14 +231,20 @@ QtxPopupMgr* NewGeom_Module::popupMgr()
 //******************************************************
 void NewGeom_Module::onDefaultPreferences()
 {
-  XGUI_Preferences::resetConfig();
-  XGUI_Preferences::updateResourcesByConfig();
+  ModuleBase_Preferences::resetConfig();
+  ModuleBase_Preferences::updateResourcesByConfig();
 
   LightApp_Preferences* pref = preferences();
   if (pref)
     pref->retrieve();
 }
 
+//******************************************************
+void NewGeom_Module::onUpdateCommandStatus()
+{
+  getApp()->updateActions();
+}
+
 //******************************************************
 NewGeom_OCCSelector* NewGeom_Module::createSelector(SUIT_ViewManager* theMgr)
 {
@@ -242,7 +267,13 @@ NewGeom_OCCSelector* NewGeom_Module::createSelector(SUIT_ViewManager* theMgr)
 //******************************************************
 CAM_DataModel* NewGeom_Module::createDataModel()
 {
-  return new NewGeom_DataModel(this);
+  NewGeom_DataModel* aDataModel = new NewGeom_DataModel(this);
+
+  // Calling addComponent() for persistent functionality work in the SalomeApp_Study
+  LightApp_Study* aStudy = dynamic_cast<LightApp_Study*>(application()->activeStudy() );
+  aStudy->addComponent(aDataModel);
+
+  return aDataModel;
 }
 
 //******************************************************
@@ -386,7 +417,7 @@ void NewGeom_Module::createPreferences()
   LightApp_Preferences* pref = preferences();
   if (!pref)
     return;
-  XGUI_Preferences::updateConfigByResources();
+  ModuleBase_Preferences::updateConfigByResources();
   QString aModName = moduleName();
 
   QtxPreferenceItem* item = pref->findItem(aModName, true );
@@ -399,7 +430,7 @@ void NewGeom_Module::createPreferences()
   if ( catId == -1 )
     return;
   NewGeom_PrefMgr aMgr(pref, aModName);
-  XGUI_Preferences::createEditContent(&aMgr, catId);
+  ModuleBase_Preferences::createEditContent(&aMgr, catId);
   pref->retrieve();
 }
 
index f8fdfb8f960d3e5ace4eb18f349d3932eb1e0bac..800d6b168957f26eaf83e805436f6a82598d469d 100644 (file)
@@ -1,3 +1,5 @@
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
 
 #ifndef NewGeom_Module_H
 #define NewGeom_Module_H
@@ -97,6 +99,8 @@ Q_OBJECT
  protected slots:
   virtual void onViewManagerAdded(SUIT_ViewManager* theMgr);
   void onDefaultPreferences();
+  // Obtains the current application and updates its actions
+  void onUpdateCommandStatus();
 
  protected:
   CAM_DataModel* createDataModel();
@@ -117,7 +121,9 @@ Q_OBJECT
   QMap<QString, QString> myDocumentType;
 
   bool myIsOpened;
-  bool myIsStorePositions;
+  // the next parameters should be restored after this module deactivation
+  bool myIsStorePositions; // the application value of the preferences parameter
+  bool myIsEditEnabled;    // the application value
 
   QtxPopupMgr* myPopupMgr;
 };
index a5c39b12bba14dc112158d967b1601afb5544587..2331662bf97a3bcfa267859495d68f5b9922a26c 100644 (file)
@@ -1,3 +1,5 @@
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
 #include "NewGeom_OCCSelector.h"
 
 NewGeom_OCCSelector::NewGeom_OCCSelector(OCCViewer_Viewer* theViewer, SUIT_SelectionMgr* theMgr)
index ce9a84615ed7868e85b1fed9b83bbd7721930852..e086444f00aaae86b1f79ca567a6b3f096bff860 100644 (file)
@@ -1,3 +1,5 @@
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
 #ifndef NewGeom_OCCSelector_H
 #define NewGeom_OCCSelector_H
 
index 419c5d0b88e14593970b5f97fdc27ffac25ba026..a1a640e5e6d0958f1f1547f0d4ab40e4933a1e32 100644 (file)
@@ -1,3 +1,5 @@
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
 #include "NewGeom_SalomeViewer.h"
 #include "NewGeom_OCCSelector.h"
 
 #include <QMouseEvent>
 #include <QContextMenuEvent>
 
+
+Handle(V3d_View) NewGeom_SalomeView::v3dView() const
+{
+  SUIT_ViewManager* aMgr = myViewer->getViewManager();
+  OCCViewer_ViewWindow* aWnd = static_cast<OCCViewer_ViewWindow*>(aMgr->getActiveView());
+  Handle(V3d_View) aView = aWnd->getViewPort()->getView();
+  return aView;
+}
+
+//**********************************************
+//**********************************************
+//**********************************************
+
+
+
 NewGeom_SalomeViewer::NewGeom_SalomeViewer(QObject* theParent)
     : ModuleBase_IViewer(theParent),
-      mySelector(0)
+      mySelector(0), myView(0), myIsSelectionChanged(false)
+{
+}
+
+NewGeom_SalomeViewer::~NewGeom_SalomeViewer()
 {
+  if (myView)
+    delete myView;
 }
 
+
 //**********************************************
 Handle(AIS_InteractiveContext) NewGeom_SalomeViewer::AISContext() const
 {
@@ -59,11 +83,19 @@ void NewGeom_SalomeViewer::setSelector(NewGeom_OCCSelector* theSel)
   OCCViewer_Viewer* aViewer = mySelector->viewer();
   SUIT_ViewManager* aMgr = aViewer->getViewManager();
 
+  myView = new NewGeom_SalomeView(mySelector->viewer());
+
+  // TODO: Provide ModuleBase_IViewWindow interface
   connect(aMgr, SIGNAL(lastViewClosed(SUIT_ViewManager*)), this, SIGNAL(lastViewClosed()));
-  connect(aMgr, SIGNAL(tryCloseView(SUIT_ViewManager*)), this, SIGNAL(tryCloseView()));
-  connect(aMgr, SIGNAL(deleteView(SUIT_ViewManager*)), this, SIGNAL(deleteView()));
-  connect(aMgr, SIGNAL(viewCreated(SUIT_ViewManager*)), this, SIGNAL(viewCreated()));
-  connect(aMgr, SIGNAL(activated(SUIT_ViewManager*)), this, SIGNAL(activated()));
+
+  connect(aMgr, SIGNAL(tryCloseView(SUIT_ViewWindow*)), 
+          this, SLOT(onTryCloseView(SUIT_ViewWindow*)));
+  connect(aMgr, SIGNAL(deleteView(SUIT_ViewWindow*)), 
+          this, SLOT(onDeleteView(SUIT_ViewWindow*)));
+  connect(aMgr, SIGNAL(viewCreated(SUIT_ViewWindow*)), 
+          this, SLOT(onViewCreated(SUIT_ViewWindow*)));
+  connect(aMgr, SIGNAL(activated(SUIT_ViewWindow*)), 
+          this, SLOT(onActivated(SUIT_ViewWindow*)));
 
   connect(aMgr, SIGNAL(mousePress(SUIT_ViewWindow*, QMouseEvent*)), this,
           SLOT(onMousePress(SUIT_ViewWindow*, QMouseEvent*)));
@@ -73,53 +105,84 @@ void NewGeom_SalomeViewer::setSelector(NewGeom_OCCSelector* theSel)
           SLOT(onMouseDoubleClick(SUIT_ViewWindow*, QMouseEvent*)));
   connect(aMgr, SIGNAL(mouseMove(SUIT_ViewWindow*, QMouseEvent*)), this,
           SLOT(onMouseMove(SUIT_ViewWindow*, QMouseEvent*)));
+
   connect(aMgr, SIGNAL(keyPress(SUIT_ViewWindow*, QKeyEvent*)), this,
           SLOT(onKeyPress(SUIT_ViewWindow*, QKeyEvent*)));
   connect(aMgr, SIGNAL(keyRelease(SUIT_ViewWindow*, QKeyEvent*)), this,
           SLOT(onKeyRelease(SUIT_ViewWindow*, QKeyEvent*)));
 
-  connect(aViewer, SIGNAL(selectionChanged()), this, SIGNAL(selectionChanged()));
+  connect(aViewer, SIGNAL(selectionChanged()), this, SLOT(onSelectionChanged()));
+}
+
+//**********************************************
+void NewGeom_SalomeViewer::onSelectionChanged()
+{
+  // Selection event must be sent only after mouse release
+  myIsSelectionChanged = true;
 }
 
 //**********************************************
 void NewGeom_SalomeViewer::onMousePress(SUIT_ViewWindow*, QMouseEvent* theEvent)
 {
-  emit mousePress(theEvent);
+  emit mousePress(myView, theEvent);
 }
 
 //**********************************************
 void NewGeom_SalomeViewer::onMouseRelease(SUIT_ViewWindow*, QMouseEvent* theEvent)
 {
-  emit mouseRelease(theEvent);
-  //if ((theEvent->button() == Qt::RightButton) && 
-  //  (theEvent->modifiers() == Qt::NoModifier)) {
-  //  QContextMenuEvent aEvent(QContextMenuEvent::Mouse, theEvent->pos(), theEvent->globalPos());
-  //  emit contextMenuRequested(&aEvent);
-  //}
+  emit mouseRelease(myView, theEvent);
+  if (myIsSelectionChanged) {
+    emit selectionChanged();
+    myIsSelectionChanged = false;
+  }
 }
 
 //**********************************************
 void NewGeom_SalomeViewer::onMouseDoubleClick(SUIT_ViewWindow*, QMouseEvent* theEvent)
 {
-  emit mouseDoubleClick(theEvent);
+  emit mouseDoubleClick(myView, theEvent);
 }
 
 //**********************************************
 void NewGeom_SalomeViewer::onMouseMove(SUIT_ViewWindow*, QMouseEvent* theEvent)
 {
-  emit mouseMove(theEvent);
+  emit mouseMove(myView, theEvent);
 }
 
 //**********************************************
 void NewGeom_SalomeViewer::onKeyPress(SUIT_ViewWindow*, QKeyEvent* theEvent)
 {
-  emit keyPress(theEvent);
+  emit keyPress(myView, theEvent);
 }
 
 //**********************************************
 void NewGeom_SalomeViewer::onKeyRelease(SUIT_ViewWindow*, QKeyEvent* theEvent)
 {
-  emit keyRelease(theEvent);
+  emit keyRelease(myView, theEvent);
+}
+
+//**********************************************
+void NewGeom_SalomeViewer::onTryCloseView(SUIT_ViewWindow*)
+{
+  emit tryCloseView(myView);
+}
+
+//**********************************************
+void NewGeom_SalomeViewer::onDeleteView(SUIT_ViewWindow*)
+{
+  emit deleteView(myView);
+}
+
+//**********************************************
+void NewGeom_SalomeViewer::onViewCreated(SUIT_ViewWindow*)
+{
+  emit viewCreated(myView);
+}
+
+//**********************************************
+void NewGeom_SalomeViewer::onActivated(SUIT_ViewWindow*)
+{
+  emit activated(myView);
 }
 
 //**********************************************
@@ -170,7 +233,7 @@ void NewGeom_SalomeViewer::setViewProjection(double theX, double theY, double th
     Handle(V3d_View) aView3d = aVFrame->getViewPort()->getView();
     if (!aView3d.IsNull()) {
       aView3d->SetProj(theX, theY, theZ);
-      aView3d->FitAll(0.01, true, true);
+      aView3d->FitAll(0.01, true);
       aView3d->SetZSize(0.);
     }
   }
index 5148dcc6db73730209b1a5454d3488182656eaa3..f3b6243f8887dcf0b76d2c7ef08e74937551823e 100644 (file)
@@ -1,3 +1,5 @@
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
 
 #ifndef NewGeom_SalomeViewer_H
 #define NewGeom_SalomeViewer_H
@@ -5,12 +7,33 @@
 #include "NewGeom.h"
 
 #include <ModuleBase_IViewer.h>
+#include <ModuleBase_IViewWindow.h>
+
+#include <V3d_View.hxx>
 
 class SUIT_ViewWindow;
 class QMouseEvent;
 class QKeyEvent;
 
 class NewGeom_OCCSelector;
+class OCCViewer_Viewer;
+class SUIT_ViewManager;
+
+
+class NewGeom_SalomeView: public ModuleBase_IViewWindow
+{
+public:
+  NewGeom_SalomeView(OCCViewer_Viewer* theViewer) { myViewer = theViewer; }
+
+  virtual Handle(V3d_View) v3dView() const;
+
+  void setViewer(OCCViewer_Viewer* theViewer) { myViewer = theViewer; }
+  OCCViewer_Viewer* viewer() const { return myViewer; }
+
+private:
+  OCCViewer_Viewer* myViewer;
+};
+
 
 class NewGeom_SalomeViewer : public ModuleBase_IViewer
 {
@@ -18,6 +41,8 @@ Q_OBJECT
  public:
   NewGeom_SalomeViewer(QObject* theParent);
 
+  ~NewGeom_SalomeViewer();
+
   //! Returns AIS_InteractiveContext from current OCCViewer
   virtual Handle(AIS_InteractiveContext) AISContext() const;
 
@@ -72,9 +97,18 @@ Q_OBJECT
   void onKeyPress(SUIT_ViewWindow*, QKeyEvent*);
   void onKeyRelease(SUIT_ViewWindow*, QKeyEvent*);
 
+  void onTryCloseView(SUIT_ViewWindow*);
+  void onDeleteView(SUIT_ViewWindow*);
+  void onViewCreated(SUIT_ViewWindow*);
+  void onActivated(SUIT_ViewWindow*);
+
+  void onSelectionChanged();
+
  private:
   NewGeom_OCCSelector* mySelector;
-
+  NewGeom_SalomeView* myView;
+  bool myIsSelectionChanged;
 };
 
+
 #endif
index db530bde71af993674e9c8ff23767701905132f2..0a0aff47b011494893147c228675d53851c9ed65 100644 (file)
@@ -23,6 +23,7 @@
     <!-- Major module parameters -->
     <parameter name="name" value="NewGeom"/>
     <parameter name="icon" value="newgeom.png"/>
+    <parameter name="version" value="0.6.1"/>
   </section>
   <section name="resources">
     <!-- Module resources -->
index 20536e2a69ab65127248129aacbc4885b5681fda..d4302060c09f0b3e2e7cc5119aab88141cca94ca 100644 (file)
@@ -27,6 +27,7 @@
     <!-- Major module parameters -->
     <parameter name="name" value="NewGeom"/>
     <parameter name="icon" value="newgeom.png"/>
+    <parameter name="version" value="0.6.1"/>
   </section>
   <section name="resources">
     <!-- Module resources -->
index dae5c3b4f127b9a7d3a0ca5839adeca0efbb49f6..fc2f4b0b82d2502af48722a81be8346f5f73ce25 100644 (file)
@@ -1,3 +1,5 @@
+## Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
 INCLUDE(Common)
 
 SET(CMAKE_AUTOMOC ON)
@@ -6,30 +8,26 @@ SET(PROJECT_HEADERS
        PartSet.h
        PartSet_Constants.h
        PartSet_EditLine.h
-       PartSet_Listener.h
        PartSet_Module.h
-       PartSet_OperationFeatureCreate.h
-       PartSet_OperationFeatureEdit.h
-       PartSet_OperationSketchBase.h
-       PartSet_OperationSketch.h
-       PartSet_OperationFeatureBase.h
        PartSet_Tools.h
        PartSet_WidgetSketchLabel.h
        PartSet_Validators.h
+       PartSet_WidgetPoint2d.h
+       PartSet_WidgetPoint2dDistance.h
+       PartSet_WidgetShapeSelector.h
+       PartSet_Filters.h
 )
 
 SET(PROJECT_SOURCES
        PartSet_EditLine.cpp
-       PartSet_Listener.cpp
        PartSet_Module.cpp
-       PartSet_OperationFeatureCreate.cpp
-       PartSet_OperationFeatureEdit.cpp
-       PartSet_OperationSketchBase.cpp
-       PartSet_OperationSketch.cpp
-       PartSet_OperationFeatureBase.cpp
        PartSet_Tools.cpp
        PartSet_WidgetSketchLabel.cpp
        PartSet_Validators.cpp
+       PartSet_WidgetPoint2d.cpp
+       PartSet_WidgetPoint2dDistance.cpp
+       PartSet_WidgetShapeSelector.cpp
+       PartSet_Filters.cpp
 )
 
 SET(PROJECT_RESOURCES 
@@ -74,6 +72,7 @@ INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/src/XGUI
                     ${CMAKE_SOURCE_DIR}/src/GeomDataAPI
                     ${CMAKE_SOURCE_DIR}/src/GeomAlgoAPI
                     ${CMAKE_SOURCE_DIR}/src/SketchPlugin
+                    ${CMAKE_SOURCE_DIR}/src/FeaturesPlugin
                     ${CMAKE_SOURCE_DIR}/src/GeomAPI
                     ${CAS_INCLUDE_DIRS}
                                        ${SUIT_INCLUDE}
index 4e9f59f46fcbc09b825cfe6576b5f69a767a8810..e39f0e728555904a966bc7b5d78a48769878783c 100644 (file)
@@ -1,3 +1,5 @@
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D\r
+\r
 #ifndef PARTSET_H\r
 #define PARTSET_H\r
 \r
index 17c0f5e5f63aaa88f320cb931b7ae998fde1dc6c..4d37dfb2b69ce86c6d274fc86abf157369eb6fb0 100644 (file)
@@ -1,3 +1,5 @@
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
 // File:        PartSet_Tools.h
 // Created:     04 Jun 2014
 // Author:      Natalia ERMOLAEVA
index a7b2ecccb9b1ebfc5f5cf5cff91604c4c3068d5d..c063172b2a8e3f2f331a8d1cb2a3b9c6692ab310 100644 (file)
@@ -1,3 +1,5 @@
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
 // File:        PartSet_EditLine.h
 // Created:     02 June 2014
 // Author:      Natalia ERMOLAEVA
index c043dc08a5008567c4ef67fba2f2f5b3b344a60c..cf85b78d3150c68f0d311c8ded4550050a49204e 100644 (file)
@@ -1,3 +1,5 @@
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
 // File:        PartSet_EditLine.h
 // Created:     02 Jun 2014
 // Author:      Natalia ERMOLAEVA
diff --git a/src/PartSet/PartSet_Filters.cpp b/src/PartSet/PartSet_Filters.cpp
new file mode 100644 (file)
index 0000000..d5df887
--- /dev/null
@@ -0,0 +1,44 @@
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
+// File:        PartSet_Filters.cpp
+// Created:     08 Nov 2014
+// Author:      Vitaly SMETANNIKOV
+
+#include "PartSet_Filters.h"
+
+#include <ModuleBase_IWorkshop.h>
+
+#include <ModelAPI_Feature.h>
+#include <FeaturesPlugin_Group.h>
+
+#include <AIS_InteractiveObject.hxx>
+#include <AIS_Shape.hxx>
+
+
+IMPLEMENT_STANDARD_HANDLE(PartSet_GlobalFilter, ModuleBase_ShapeDocumentFilter);
+IMPLEMENT_STANDARD_RTTIEXT(PartSet_GlobalFilter, ModuleBase_ShapeDocumentFilter);
+
+Standard_Boolean PartSet_GlobalFilter::IsOk(const Handle(SelectMgr_EntityOwner)& theOwner) const
+{
+  if (ModuleBase_ShapeDocumentFilter::IsOk(theOwner)) {
+    if (theOwner->HasSelectable()) {
+      Handle(AIS_InteractiveObject) aAisObj = 
+        Handle(AIS_InteractiveObject)::DownCast(theOwner->Selectable());
+      if (!aAisObj.IsNull()) {
+        std::shared_ptr<GeomAPI_AISObject> aAISObj = AISObjectPtr(new GeomAPI_AISObject());
+        aAISObj->setImpl(new Handle(AIS_InteractiveObject)(aAisObj));
+        ObjectPtr aObj = myWorkshop->findPresentedObject(aAISObj);
+        if (aObj) {
+          FeaturePtr aFeature = ModelAPI_Feature::feature(aObj);
+          if (aFeature) {
+            return aFeature->getKind() != FeaturesPlugin_Group::ID();
+          } else 
+            return Standard_True;
+        } else
+          // This is not object controlled by the filter
+          return Standard_True;
+      }
+    }
+  }
+  return Standard_False;
+}
diff --git a/src/PartSet/PartSet_Filters.h b/src/PartSet/PartSet_Filters.h
new file mode 100644 (file)
index 0000000..56a34e5
--- /dev/null
@@ -0,0 +1,28 @@
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
+// File:        PartSet_Filters.h
+// Created:     08 Nov 2014
+// Author:      Vitaly SMETANNIKOV
+
+#ifndef PartSet_Filters_H
+#define PartSet_Filters_H
+
+#include <ModuleBase_ViewerFilters.h>
+
+
+/**
+* A class which filters groups object in addition to documents (see issue #310)
+*/
+DEFINE_STANDARD_HANDLE(PartSet_GlobalFilter, ModuleBase_ShapeDocumentFilter);
+class PartSet_GlobalFilter: public ModuleBase_ShapeDocumentFilter
+{
+public:
+  PartSet_GlobalFilter(ModuleBase_IWorkshop* theWorkshop)
+    : ModuleBase_ShapeDocumentFilter(theWorkshop) {}
+
+  Standard_EXPORT virtual Standard_Boolean IsOk(const Handle(SelectMgr_EntityOwner)& theOwner) const;
+
+  DEFINE_STANDARD_RTTI(PartSet_GlobalFilter)
+};
+
+#endif
\ No newline at end of file
diff --git a/src/PartSet/PartSet_Listener.cpp b/src/PartSet/PartSet_Listener.cpp
deleted file mode 100644 (file)
index d12987e..0000000
+++ /dev/null
@@ -1,107 +0,0 @@
-// File:        PartSet_Listener.h
-// Created:     28 Apr 2014
-// Author:      Natalia ERMOLAEVA
-
-#include <PartSet_Listener.h>
-
-#include <PartSet_Module.h>
-#include <PartSet_OperationSketchBase.h>
-#include <PartSet_OperationSketch.h>
-#include <PartSet_OperationFeatureCreate.h>
-
-#include <XGUI_Displayer.h>
-#include <XGUI_Workshop.h>
-#include <XGUI_OperationMgr.h>
-
-#include <ModuleBase_Operation.h>
-
-#include <Events_Loop.h>
-#include <ModelAPI_Events.h>
-#include <ModelAPI_Feature.h>
-
-#ifdef _DEBUG
-#include <QDebug>
-#endif
-
-using namespace std;
-
-PartSet_Listener::PartSet_Listener(PartSet_Module* theModule)
-    : myModule(theModule)
-{
-  Events_Loop* aLoop = Events_Loop::loop();
-  aLoop->registerListener(this, aLoop->eventByName(EVENT_OBJECT_TO_REDISPLAY));
-  aLoop->registerListener(this, Events_Loop::eventByName(EVENT_OBJECT_CREATED));
-  aLoop->registerListener(this, Events_Loop::eventByName(EVENT_OBJECT_DELETED));
-}
-
-PartSet_Listener::~PartSet_Listener()
-{
-}
-
-//******************************************************
-void PartSet_Listener::processEvent(const std::shared_ptr<Events_Message>& theMessage)
-{
-  ModuleBase_Operation* anOperation = myModule->xWorkshop()->operationMgr()->currentOperation();
-  PartSet_OperationSketchBase* aSketchOp = dynamic_cast<PartSet_OperationSketchBase*>(anOperation);
-  if (!aSketchOp)
-    return;
-
-  XGUI_Displayer* aDisplayer = myModule->xWorkshop()->displayer();
-  QString aType = QString(theMessage->eventID().eventText());
-  if (aType == EVENT_OBJECT_CREATED) {
-    std::shared_ptr<ModelAPI_ObjectUpdatedMessage> aUpdMsg =
-        std::dynamic_pointer_cast<ModelAPI_ObjectUpdatedMessage>(theMessage);
-    std::set<ObjectPtr> aFeatures = aUpdMsg->objects();
-
-    PartSet_OperationSketch* aSketchOp = 
-      dynamic_cast<PartSet_OperationSketch*>(myModule->xWorkshop()->operationMgr()->currentOperation());
-
-    std::set<ObjectPtr>::const_iterator anIt = aFeatures.begin(), aLast = aFeatures.end();
-    for (; anIt != aLast; anIt++) {
-      ObjectPtr aObj = (*anIt);
-      // If current operation is Sketch then there is no active sketching operation
-      // and possible the object was created by Redo operation
-      if (aSketchOp) {
-          XGUI_Displayer* aDisplayer = myModule->xWorkshop()->displayer();
-          // Very possible it is not displayed
-          aDisplayer->display(aObj, false);
-      }
-    }
-  } else if (aType == EVENT_OBJECT_TO_REDISPLAY) {
-    PartSet_OperationFeatureCreate* aCreationOp = 
-      dynamic_cast<PartSet_OperationFeatureCreate*>
-      (myModule->xWorkshop()->operationMgr()->currentOperation());
-    if (aCreationOp) {
-      // Deactivate currently creating objects for selection
-      XGUI_Displayer* aDisplayer = myModule->xWorkshop()->displayer();
-      FeaturePtr aFeature = aCreationOp->feature();
-      const std::list<ResultPtr>& aResults = aFeature->results();
-      std::shared_ptr<ModelAPI_ObjectUpdatedMessage> aUpdMsg =
-        std::dynamic_pointer_cast<ModelAPI_ObjectUpdatedMessage>(theMessage);
-
-      std::set<ObjectPtr> aFeatures = aUpdMsg->objects();
-      std::set<ObjectPtr>::const_iterator aObjIt, aNoObj = aFeatures.cend();
-      std::list<ResultPtr>::const_iterator anIt = aResults.begin(), aLast = aResults.end();
-      for (; anIt != aLast; anIt++) {
-        aObjIt = aFeatures.find(*anIt);
-        if (aObjIt != aNoObj) {
-          aDisplayer->deactivate(*aObjIt);
-        }
-      }
-    }
-  } else if (aType == EVENT_OBJECT_DELETED) {
-    std::shared_ptr<ModelAPI_ObjectDeletedMessage> aDelMsg =
-        std::dynamic_pointer_cast<ModelAPI_ObjectDeletedMessage>(theMessage);
-    std::shared_ptr<ModelAPI_Document> aDoc = aDelMsg->document();
-
-    std::set<std::string> aGroups = aDelMsg->groups();
-    std::set<std::string>::const_iterator anIt = aGroups.begin(), aLast = aGroups.end();
-    for (; anIt != aLast; anIt++) {
-      std::string aGroup = *anIt;
-      if (aGroup.compare(SketchPlugin_Sketch::ID()) == 0) {  // Update only Sketch group
-        myModule->xWorkshop()->displayer()->eraseDeletedResults();
-        myModule->updateCurrentPreview(aGroup);
-      }
-    }
-  }
-}
diff --git a/src/PartSet/PartSet_Listener.h b/src/PartSet/PartSet_Listener.h
deleted file mode 100644 (file)
index 8950d2f..0000000
+++ /dev/null
@@ -1,35 +0,0 @@
-// File:        PartSet_Listener.h
-// Created:     28 Apr 2014
-// Author:      Natalia ERMOLAEVA
-
-#ifndef PartSet_Listener_H
-#define PartSet_Listener_H
-
-#include "PartSet.h"
-
-#include <Events_Listener.h>
-
-class PartSet_Module;
-
-/*!
- \class PartSet_Listener
- * \brief The operation for the sketch feature creation
- */
-class PARTSET_EXPORT PartSet_Listener : public Events_Listener
-{
- public:
-  /// Constructor
-  /// \param theId the feature identifier
-  /// \param theParent the operation parent
-  PartSet_Listener(PartSet_Module* theModule);
-  /// Destructor
-  virtual ~PartSet_Listener();
-
-  /// This method is called by loop when the event is started to process.
-  virtual void processEvent(const std::shared_ptr<Events_Message>& theMessage);
-
- private:
-  PartSet_Module* myModule;  ///< the current module
-};
-
-#endif
index 092b0769f36c6d06f01939d757caac942a59086a..4d84d816834264352a3cb0d1f20b934df7133ec6 100644 (file)
@@ -1,17 +1,22 @@
-#include <PartSet_Module.h>
-#include <PartSet_OperationSketch.h>
-#include <PartSet_OperationFeatureCreate.h>
-#include <PartSet_OperationFeatureEdit.h>
-#include <PartSet_Listener.h>
-#include <PartSet_TestOCC.h>
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
+#include "PartSet_Module.h"
 #include <PartSet_WidgetSketchLabel.h>
 #include <PartSet_Validators.h>
 #include <PartSet_Tools.h>
+#include <PartSet_WidgetPoint2d.h>
+#include <PartSet_WidgetPoint2dDistance.h>
+#include <PartSet_WidgetShapeSelector.h>
 
 #include <ModuleBase_Operation.h>
-#include <ModuleBase_OperationDescription.h>
-#include <ModuleBase_WidgetFactory.h>
-#include <ModuleBase_Operation.h>
+#include <ModuleBase_IViewer.h>
+#include <ModuleBase_IViewWindow.h>
+#include <ModuleBase_IPropertyPanel.h>
+#include <ModuleBase_WidgetEditor.h>
+#include <ModuleBase_FilterFactory.h>
+#include <ModuleBase_FilterLinearEdge.h>
+#include <ModuleBase_FilterFace.h>
+
 
 #include <ModelAPI_Object.h>
 #include <ModelAPI_Events.h>
 #include <GeomDataAPI_Point.h>
 #include <GeomDataAPI_Dir.h>
 
-#include <XGUI_MainWindow.h>
 #include <XGUI_Displayer.h>
-#include <XGUI_Viewer.h>
 #include <XGUI_Workshop.h>
 #include <XGUI_OperationMgr.h>
-#include <XGUI_ViewPort.h>
-#include <XGUI_ActionsMgr.h>
-#include <XGUI_ViewerProxy.h>
-#include <XGUI_ContextMenuMgr.h>
 #include <XGUI_PropertyPanel.h>
 #include <XGUI_ModuleConnector.h>
 #include <XGUI_Tools.h>
 
 #include <SketchPlugin_Line.h>
 #include <SketchPlugin_Sketch.h>
+#include <SketchPlugin_Point.h>
+#include <SketchPlugin_Arc.h>
+#include <SketchPlugin_Circle.h>
+#include <SketchPlugin_ConstraintLength.h>
+#include <SketchPlugin_ConstraintDistance.h>
+#include <SketchPlugin_ConstraintParallel.h>
+#include <SketchPlugin_ConstraintPerpendicular.h>
+#include <SketchPlugin_ConstraintRadius.h>
+#include <SketchPlugin_ConstraintRigid.h>
 
-#include <Config_PointerMessage.h>
-#include <Config_ModuleReader.h>
-#include <Config_WidgetReader.h>
 #include <Events_Loop.h>
-//#include <Events_Message.h>
-//#include <Events_Error.h>
-
-#include <GeomAPI_Shape.h>
-#include <GeomAPI_AISObject.h>
-#include <AIS_Shape.hxx>
-#include <AIS_DimensionSelectionMode.hxx>
 
 #include <StdSelect_TypeOfFace.hxx>
+#include <TopoDS_Vertex.hxx>
+#include <TopoDS.hxx>
+#include <TopoDS_Shape.hxx>
+#include <BRep_Tool.hxx>
 
 #include <QObject>
 #include <QMouseEvent>
 #include <QString>
+#include <QTimer>
+#include <QApplication>
 
 #include <GeomAlgoAPI_FaceBuilder.h>
 #include <GeomDataAPI_Dir.h>
 #include <QDebug>
 #endif
 
+
+/// Returns list of unique objects by sum of objects from List1 and List2
+QList<ObjectPtr> getSumList(const QList<ModuleBase_ViewerPrs>& theList1,
+                                       const QList<ModuleBase_ViewerPrs>& theList2)
+{
+  QList<ObjectPtr> aRes;
+  foreach (ModuleBase_ViewerPrs aPrs, theList1) {
+    if (!aRes.contains(aPrs.object()))
+      aRes.append(aPrs.object());
+  }
+  foreach (ModuleBase_ViewerPrs aPrs, theList2) {
+    if (!aRes.contains(aPrs.object()))
+      aRes.append(aPrs.object());
+  }
+  return aRes;
+}
+
 /*!Create and return new instance of XGUI_Module*/
 extern "C" PARTSET_EXPORT ModuleBase_IModule* createModule(ModuleBase_IWorkshop* theWshop)
 {
@@ -71,29 +92,44 @@ extern "C" PARTSET_EXPORT ModuleBase_IModule* createModule(ModuleBase_IWorkshop*
 }
 
 PartSet_Module::PartSet_Module(ModuleBase_IWorkshop* theWshop)
-  : ModuleBase_IModule(theWshop)
+  : ModuleBase_IModule(theWshop), 
+  myIsDragging(false), myRestartingMode(RM_None), myDragDone(false)
 {
-  //myWorkshop = theWshop;
-  myListener = new PartSet_Listener(this);
+  //myWorkshop = dynamic_cast<XGUI_Workshop*>(theWshop);
+  ModuleBase_IViewer* aViewer = aViewer = theWshop->viewer();
+  connect(aViewer, SIGNAL(mousePress(ModuleBase_IViewWindow*, QMouseEvent*)),
+          this, SLOT(onMousePressed(ModuleBase_IViewWindow*, QMouseEvent*)));
 
-  connect(myWorkshop, SIGNAL(operationStarted(ModuleBase_Operation*)), 
-    this, SLOT(onOperationStarted(ModuleBase_Operation*)));
+  connect(aViewer, SIGNAL(mouseRelease(ModuleBase_IViewWindow*, QMouseEvent*)),
+          this, SLOT(onMouseReleased(ModuleBase_IViewWindow*, QMouseEvent*)));
 
-  connect(myWorkshop, SIGNAL(operationStopped(ModuleBase_Operation*)), this,
-          SLOT(onOperationStopped(ModuleBase_Operation*)));
+  connect(aViewer, SIGNAL(mouseMove(ModuleBase_IViewWindow*, QMouseEvent*)),
+          this, SLOT(onMouseMoved(ModuleBase_IViewWindow*, QMouseEvent*)));
 
-  XGUI_Workshop* aXWshop = xWorkshop();
-  XGUI_ContextMenuMgr* aContextMenuMgr = aXWshop->contextMenuMgr();
-  connect(aContextMenuMgr, SIGNAL(actionTriggered(const QString&, bool)), this,
-          SLOT(onContextMenuCommand(const QString&, bool)));
+  connect(aViewer, SIGNAL(mouseDoubleClick(ModuleBase_IViewWindow*, QMouseEvent*)),
+          this, SLOT(onMouseDoubleClick(ModuleBase_IViewWindow*, QMouseEvent*)));
 
+  XGUI_ModuleConnector* aConnector = dynamic_cast<XGUI_ModuleConnector*>(theWshop);
+  XGUI_Workshop* aWorkshop = aConnector->workshop();
+
+  XGUI_OperationMgr* anOpMgr = aWorkshop->operationMgr();
+  connect(anOpMgr, SIGNAL(keyEnterReleased()), this, SLOT(onEnterReleased()));
+  connect(anOpMgr, SIGNAL(operationActivatedByPreselection()),
+          this, SLOT(onOperationActivatedByPreselection()));
+
+  connect(aViewer, SIGNAL(keyRelease(ModuleBase_IViewWindow*, QKeyEvent*)),
+          this, SLOT(onKeyRelease(ModuleBase_IViewWindow*, QKeyEvent*)));
 }
 
 PartSet_Module::~PartSet_Module()
 {
+  if (!myDocumentShapeFilter.IsNull())
+    myDocumentShapeFilter.Nullify();
+  if (!myPlaneFilter.IsNull())
+    myPlaneFilter.Nullify();
 }
 
-void PartSet_Module::createFeatures()
+void PartSet_Module::registerValidators()
 {
   //Registering of validators
   SessionPtr aMgr = ModelAPI_Session::get();
@@ -103,510 +139,546 @@ void PartSet_Module::createFeatures()
   aFactory->registerValidator("PartSet_PerpendicularValidator", new PartSet_PerpendicularValidator);
   aFactory->registerValidator("PartSet_ParallelValidator", new PartSet_ParallelValidator);
   aFactory->registerValidator("PartSet_RadiusValidator", new PartSet_RadiusValidator);
-
-  Config_ModuleReader aXMLReader = Config_ModuleReader();
-  aXMLReader.readAll();
-  myFeaturesInFiles = aXMLReader.featuresInFiles();
+  aFactory->registerValidator("PartSet_RigidValidator", new PartSet_RigidValidator);
+  aFactory->registerValidator("PartSet_DifferentObjects", new PartSet_DifferentObjectsValidator);
 }
 
-void PartSet_Module::featureCreated(QAction* theFeature)
+void PartSet_Module::registerFilters()
 {
-  connect(theFeature, SIGNAL(triggered(bool)), this, SLOT(onFeatureTriggered()));
+  //Registering of selection filters
+  XGUI_ModuleConnector* aConnector = dynamic_cast<XGUI_ModuleConnector*>(workshop());
+  ModuleBase_FilterFactory* aFactory = aConnector->selectionFilters();
+
+  aFactory->registerFilter("EdgeFilter", new ModuleBase_FilterLinearEdge);
+  aFactory->registerFilter("FaceFilter", new ModuleBase_FilterFace);
 }
 
-std::string PartSet_Module::featureFile(const std::string& theFeatureId)
+void PartSet_Module::operationCommitted(ModuleBase_Operation* theOperation) 
 {
-  return myFeaturesInFiles[theFeatureId];
+  if (theOperation->isEditOperation())
+    return;
+  /// Restart sketcher operations automatically
+  FeaturePtr aFeature = theOperation->feature();
+  std::shared_ptr<SketchPlugin_Feature> aSPFeature = 
+            std::dynamic_pointer_cast<SketchPlugin_Feature>(aFeature);
+  if (aSPFeature && (myRestartingMode == RM_LastFeatureUsed ||
+                     myRestartingMode == RM_EmptyFeatureUsed)) {
+    myLastOperationId = theOperation->id();
+    myLastFeature = myRestartingMode == RM_LastFeatureUsed ? theOperation->feature() : FeaturePtr();
+    launchOperation(myLastOperationId);
+  }
+  breakOperationSequence();
 }
 
-/*
- *
- */
-void PartSet_Module::onFeatureTriggered()
+void PartSet_Module::breakOperationSequence()
 {
-  QAction* aCmd = dynamic_cast<QAction*>(sender());
-  //Do nothing on uncheck
-  if (aCmd->isCheckable() && !aCmd->isChecked())
-    return;
-  launchOperation(aCmd->data().toString());
+  myLastOperationId = "";
+  myLastFeature = FeaturePtr();
+  myRestartingMode = RM_None;
 }
 
+void PartSet_Module::operationAborted(ModuleBase_Operation* theOperation)
+{
+  breakOperationSequence();
+}
 
-void PartSet_Module::onOperationStarted(ModuleBase_Operation* theOperation)
+void PartSet_Module::operationStarted(ModuleBase_Operation* theOperation)
 {
-  XGUI_Workshop* aXWshp = xWorkshop();
-  XGUI_Displayer* aDisplayer = aXWshp->displayer();
-  PartSet_OperationSketchBase* aPreviewOp = dynamic_cast<PartSet_OperationSketchBase*>(theOperation);
-  if (aPreviewOp) {
-    XGUI_PropertyPanel* aPropPanel = aXWshp->propertyPanel();
-    connect(aPropPanel, SIGNAL(storedPoint2D(ObjectPtr, const std::string&)), this,
-            SLOT(onStorePoint2D(ObjectPtr, const std::string&)), Qt::UniqueConnection);
-
-    //aDisplayer->deactivateObjectsOutOfContext();
-    PartSet_OperationSketch* aSketchOp = dynamic_cast<PartSet_OperationSketch*>(aPreviewOp);
-    if (aSketchOp) {
-      if (aSketchOp->isEditOperation()) {
-        setSketchingMode(getSketchPlane(aSketchOp->feature()));
-      } else {
-        aDisplayer->openLocalContext();
-        aDisplayer->activateObjectsOutOfContext(QIntList());
-        myPlaneFilter = new StdSelect_FaceFilter(StdSelect_Plane);
-        aDisplayer->addSelectionFilter(myPlaneFilter);
-        QIntList aModes = sketchSelectionModes(aPreviewOp->feature());
-        aDisplayer->setSelectionModes(aModes);
-      } 
+  if (theOperation->id().toStdString() == SketchPlugin_Sketch::ID()) {
+    // Display all sketcher sub-Objects
+    myCurrentSketch = std::dynamic_pointer_cast<ModelAPI_CompositeFeature>(theOperation->feature());
+    XGUI_ModuleConnector* aConnector = dynamic_cast<XGUI_ModuleConnector*>(workshop());
+    XGUI_Displayer* aDisplayer = aConnector->workshop()->displayer();
+
+    for (int i = 0; i < myCurrentSketch->numberOfSubs(); i++) {
+      FeaturePtr aFeature = myCurrentSketch->subFeature(i);
+      std::list<ResultPtr> aResults = aFeature->results();
+      std::list<ResultPtr>::const_iterator aIt;
+      for (aIt = aResults.begin(); aIt != aResults.end(); ++aIt) {
+        aDisplayer->display((*aIt), false);
+      }
+      aDisplayer->display(aFeature);
+    }
+    // Hide sketcher result
+    std::list<ResultPtr> aResults = myCurrentSketch->results();
+    std::list<ResultPtr>::const_iterator aIt;
+    for (aIt = aResults.begin(); aIt != aResults.end(); ++aIt) {
+      aDisplayer->erase((*aIt), false);
+    }
+    aDisplayer->erase(myCurrentSketch);
+
+
+    if (myPlaneFilter.IsNull()) 
+      myPlaneFilter = new ModuleBase_ShapeInPlaneFilter();
+    myWorkshop->viewer()->addSelectionFilter(myPlaneFilter);
+    if (theOperation->isEditOperation()) {
+      // If it is editing of sketch then it means that plane is already defined
+      std::shared_ptr<GeomAPI_Pln> aPln = PartSet_Tools::sketchPlane(myCurrentSketch);
+      myPlaneFilter->setPlane(aPln->impl<gp_Pln>());
     }
   }
+  if (myDocumentShapeFilter.IsNull())
+    myDocumentShapeFilter = new PartSet_GlobalFilter(myWorkshop);
+  myWorkshop->viewer()->addSelectionFilter(myDocumentShapeFilter);
 }
 
-void PartSet_Module::onOperationStopped(ModuleBase_Operation* theOperation)
+void PartSet_Module::operationStopped(ModuleBase_Operation* theOperation)
 {
-  if (!theOperation)
-    return;
-  XGUI_Workshop* aXWshp = xWorkshop();
-  XGUI_Displayer* aDisplayer = aXWshp->displayer();
-  PartSet_OperationSketchBase* aPreviewOp = dynamic_cast<PartSet_OperationSketchBase*>(theOperation);
-  if (aPreviewOp) {
-    XGUI_PropertyPanel* aPropPanel = aXWshp->propertyPanel();
-
-    PartSet_OperationSketch* aSketchOp = dynamic_cast<PartSet_OperationSketch*>(aPreviewOp);
-    if (aSketchOp) {
-      aDisplayer->closeLocalContexts();
-    } else {
-      PartSet_OperationFeatureCreate* aCreationOp = 
-        dynamic_cast<PartSet_OperationFeatureCreate*>(aPreviewOp);
-      if (aCreationOp) {
-        // Activate just created object for selection
-        FeaturePtr aFeature = aCreationOp->feature();
-        QIntList aModes = sketchSelectionModes(aFeature);
-        const std::list<ResultPtr>& aResults = aFeature->results();
-        std::list<ResultPtr>::const_iterator anIt, aLast = aResults.end();
-        for (anIt = aResults.begin(); anIt != aLast; anIt++) {
-          aDisplayer->activate(*anIt, aModes);
-        }
-        aDisplayer->activate(aFeature, aModes);
-        aDisplayer->clearSelected();
+  if (theOperation->id().toStdString() == SketchPlugin_Sketch::ID()) {
+    DataPtr aData = myCurrentSketch->data();
+    if ((!aData) || (!aData->isValid())) {
+      // The sketch was aborted
+      myCurrentSketch = CompositeFeaturePtr();
+      return; 
+    }
+    // Hide all sketcher sub-Objects
+    XGUI_ModuleConnector* aConnector = dynamic_cast<XGUI_ModuleConnector*>(workshop());
+    XGUI_Displayer* aDisplayer = aConnector->workshop()->displayer();
+    for (int i = 0; i < myCurrentSketch->numberOfSubs(); i++) {
+      FeaturePtr aFeature = myCurrentSketch->subFeature(i);
+      std::list<ResultPtr> aResults = aFeature->results();
+      std::list<ResultPtr>::const_iterator aIt;
+      for (aIt = aResults.begin(); aIt != aResults.end(); ++aIt) {
+        aDisplayer->erase((*aIt), false);
       }
+      aDisplayer->erase(aFeature, false);
     }
-  }// else {
-    // Activate results of current feature for selection
-    //FeaturePtr aFeature = theOperation->feature();
-    //XGUI_Displayer* aDisplayer = aXWshp->displayer();
-    //std::list<ResultPtr> aResults = aFeature->results();
-    //std::list<ResultPtr>::const_iterator aIt;
-    //for (aIt = aResults.cbegin(); aIt != aResults.cend(); ++aIt) {
-    //  aDisplayer->activate(*aIt);
-    //}    
-  //}
+    // Display sketcher result
+    std::list<ResultPtr> aResults = myCurrentSketch->results();
+    std::list<ResultPtr>::const_iterator aIt;
+    for (aIt = aResults.begin(); aIt != aResults.end(); ++aIt) {
+      aDisplayer->display((*aIt), false);
+    }
+    aDisplayer->display(myCurrentSketch);
+    
+    myCurrentSketch = CompositeFeaturePtr();
+    myWorkshop->viewer()->removeSelectionFilter(myPlaneFilter);
+  }
+  myWorkshop->viewer()->removeSelectionFilter(myDocumentShapeFilter);
 }
 
-void PartSet_Module::onContextMenuCommand(const QString& theId, bool isChecked)
+void PartSet_Module::onPlaneSelected(const std::shared_ptr<GeomAPI_Pln>& thePln)
 {
-  QList<ObjectPtr> aFeatures = workshop()->selection()->selectedObjects();
-  if (theId == "EDIT_CMD" && (aFeatures.size() > 0)) {
-    FeaturePtr aFeature = std::dynamic_pointer_cast<ModelAPI_Feature>(aFeatures.first());
-    if (aFeature)
-      editFeature(aFeature);
-  }
+  myPlaneFilter->setPlane(thePln->impl<gp_Pln>());
 }
 
-void PartSet_Module::onMousePressed(QMouseEvent* theEvent)
+
+void PartSet_Module::propertyPanelDefined(ModuleBase_Operation* theOperation)
 {
-  XGUI_Workshop* aXWshp = xWorkshop();
-  PartSet_OperationSketchBase* aPreviewOp = 
-    dynamic_cast<PartSet_OperationSketchBase*>(workshop()->currentOperation());
-  if (aPreviewOp) {
-    ModuleBase_ISelection* aSelection = workshop()->selection();
-    aPreviewOp->mousePressed(theEvent, myWorkshop->viewer(), aSelection);
+  ModuleBase_IPropertyPanel* aPanel = theOperation->propertyPanel();
+  if ((theOperation->id().toStdString() == SketchPlugin_Sketch::ID()) && 
+    (theOperation->isEditOperation())) {
+    // we have to manually activate the sketch label in edit mode
+      aPanel->activateWidget(aPanel->modelWidgets().first());
+      return;
   }
-}
 
-void PartSet_Module::onMouseReleased(QMouseEvent* theEvent)
-{
-  PartSet_OperationSketchBase* aPreviewOp = 
-    dynamic_cast<PartSet_OperationSketchBase*>(myWorkshop->currentOperation());
-  if (aPreviewOp) {
-    ModuleBase_ISelection* aSelection = workshop()->selection();
-    // Initialise operation with preliminary selection
-    aPreviewOp->mouseReleased(theEvent, myWorkshop->viewer(), aSelection);
+  // Restart last operation type 
+  if ((theOperation->id() == myLastOperationId) && myLastFeature) {
+    ModuleBase_ModelWidget* aWgt = aPanel->activeWidget();
+    if (theOperation->id().toStdString() == SketchPlugin_Line::ID()) {
+      // Initialise new line with first point equal to end of previous
+      PartSet_WidgetPoint2D* aPnt2dWgt = dynamic_cast<PartSet_WidgetPoint2D*>(aWgt);
+      if (aPnt2dWgt) {
+        std::shared_ptr<ModelAPI_Data> aData = myLastFeature->data();
+        std::shared_ptr<GeomDataAPI_Point2D> aPoint = 
+          std::dynamic_pointer_cast<GeomDataAPI_Point2D>(aData->attribute(SketchPlugin_Line::END_ID()));
+        if (aPoint) {
+          aPnt2dWgt->setPoint(aPoint->x(), aPoint->y());
+          PartSet_Tools::setConstraints(myCurrentSketch, theOperation->feature(), 
+            aWgt->attributeID(), aPoint->x(), aPoint->y());
+          theOperation->propertyPanel()->activateNextWidget(aPnt2dWgt);
+        }
+      }
+    }
+  } else {
+    // Start editing constraint
+    if (theOperation->isEditOperation()) {
+      std::string aId = theOperation->id().toStdString();
+      if (sketchOperationIdList().contains(QString(aId.c_str()))) {
+        if ((aId == SketchPlugin_ConstraintRadius::ID()) ||
+            (aId == SketchPlugin_ConstraintLength::ID()) || 
+            (aId == SketchPlugin_ConstraintDistance::ID())) {
+          // Find and activate widget for management of point for dimension line position
+          QList<ModuleBase_ModelWidget*> aWidgets = aPanel->modelWidgets();
+          foreach (ModuleBase_ModelWidget* aWgt, aWidgets) {
+            PartSet_WidgetPoint2D* aPntWgt = dynamic_cast<PartSet_WidgetPoint2D*>(aWgt);
+            if (aPntWgt) {
+              aPanel->activateWidget(aPntWgt);
+              return;
+            }
+          }
+        } 
+      }
+    }
   }
 }
 
-void PartSet_Module::onMouseMoved(QMouseEvent* theEvent)
-{
-  PartSet_OperationSketchBase* aPreviewOp = 
-    dynamic_cast<PartSet_OperationSketchBase*>(myWorkshop->currentOperation());
-  if (aPreviewOp)
-    aPreviewOp->mouseMoved(theEvent, myWorkshop->viewer());
-}
 
-void PartSet_Module::onKeyRelease(QKeyEvent* theEvent)
+void PartSet_Module::onSelectionChanged()
 {
-  ModuleBase_Operation* anOperation = myWorkshop->currentOperation();
-  PartSet_OperationSketchBase* aPreviewOp = dynamic_cast<PartSet_OperationSketchBase*>(anOperation);
-  if (aPreviewOp) {
-    aPreviewOp->keyReleased(theEvent->key());
+  ModuleBase_Operation* aOperation = myWorkshop->currentOperation();
+  bool isSketcherOp = false;
+  // An edit operation is enable only if the current opeation is the sketch operation
+  if (aOperation && myCurrentSketch) {
+    if (PartSet_Tools::sketchPlane(myCurrentSketch))
+      isSketcherOp = (aOperation->id().toStdString() == SketchPlugin_Sketch::ID());
   }
-}
+  if (!isSketcherOp)
+    return;
 
-void PartSet_Module::onMouseDoubleClick(QMouseEvent* theEvent)
-{
-  PartSet_OperationSketchBase* aPreviewOp = 
-    dynamic_cast<PartSet_OperationSketchBase*>(myWorkshop->currentOperation());
-  Handle(V3d_View) aView = myWorkshop->viewer()->activeView();
-  if (aPreviewOp && (!aView.IsNull())) {
-    ModuleBase_ISelection* aSelection = workshop()->selection();
-    // Initialise operation with preliminary selection
-    aPreviewOp->mouseDoubleClick(theEvent, aView, aSelection);
+  // Editing of constraints can be done on selection
+  ModuleBase_ISelection* aSelect = myWorkshop->selection();
+  QList<ModuleBase_ViewerPrs> aSelected = aSelect->getSelected();
+  if (aSelected.size() == 1) {
+    ModuleBase_ViewerPrs aPrs = aSelected.first();
+    ObjectPtr aObject = aPrs.object();
+    FeaturePtr aFeature = ModelAPI_Feature::feature(aObject);
+    if (aFeature) {
+      std::string aId = aFeature->getKind();
+      if ((aId == SketchPlugin_ConstraintRadius::ID()) ||
+          (aId == SketchPlugin_ConstraintLength::ID()) || 
+          (aId == SketchPlugin_ConstraintDistance::ID())) {
+        editFeature(aFeature);
+      }
+    }
   }
 }
 
-void PartSet_Module::onPlaneSelected(double theX, double theY, double theZ)
+void PartSet_Module::onMousePressed(ModuleBase_IViewWindow* theWnd, QMouseEvent* theEvent) 
 {
-  myWorkshop->viewer()->setViewProjection(theX, theY, theZ);
-}
+  if (!(theEvent->buttons() & Qt::LeftButton))
+    return;
 
-void PartSet_Module::onSketchLaunched()
-{
-  xWorkshop()->actionsMgr()->update();
-  // Set working plane
-  ModuleBase_Operation* anOperation = myWorkshop->currentOperation();
-  FeaturePtr aSketch = anOperation->feature();
-  setSketchingMode(getSketchPlane(aSketch));
-}
+  ModuleBase_Operation* aOperation = myWorkshop->currentOperation();
+  // Use only for sketch operations
+  if (aOperation && myCurrentSketch) {
+    if (!PartSet_Tools::sketchPlane(myCurrentSketch))
+      return;
 
-void PartSet_Module::onFitAllView()
-{
-  myWorkshop->viewer()->fitAll();
-}
+    bool isSketcher = (aOperation->id().toStdString() == SketchPlugin_Sketch::ID());
+    bool isSketchOpe = sketchOperationIdList().contains(aOperation->id());
 
-void PartSet_Module::onRestartOperation(std::string theName, ObjectPtr theObject)
-{
-  FeaturePtr aFeature = ModelAPI_Feature::feature(theObject);
-
-  std::string aKind = aFeature ? aFeature->getKind() : "";
-  ModuleBase_Operation* anOperation = createOperation(theName, aKind);
-
-  PartSet_OperationSketchBase* aSketchOp = dynamic_cast<PartSet_OperationSketchBase*>(anOperation);
-  if (aSketchOp) {
-    PartSet_OperationFeatureCreate* aCreateOp = dynamic_cast<PartSet_OperationFeatureCreate*>(anOperation);
-    if (aCreateOp)
-      aCreateOp->initFeature(aFeature);
-    else {
-      anOperation->setFeature(aFeature);
+    // Avoid non-sketch operations
+    if ((!isSketchOpe) && (!isSketcher))
+      return;
+
+    bool isEditing = aOperation->isEditOperation();
+
+    // Ignore creation sketch operation
+    if ((!isSketcher) && (!isEditing))
+      return;
+
+    if (theEvent->modifiers()) {
+      // If user performs multiselection
+      if (isSketchOpe && (!isSketcher))
+        if (!aOperation->commit())
+          aOperation->abort();
+      return;
     }
-    ModuleBase_ISelection* aSelection = workshop()->selection();
-    // Initialise operation with preliminary selection
-    aSketchOp->initSelection(aSelection, myWorkshop->viewer());
-  } else if (aFeature) { // In case of edit operation: set the previously created feature to the operation
-    anOperation->setFeature(aFeature);
-    ////Deactivate result of current feature in order to avoid its selection
-    XGUI_Displayer* aDisplayer = xWorkshop()->displayer();
-    std::list<ResultPtr> aResults = aFeature->results();
-    std::list<ResultPtr>::const_iterator aIt;
-    for (aIt = aResults.cbegin(); aIt != aResults.cend(); ++aIt) {
-      aDisplayer->deactivate(*aIt);
+    // Remember highlighted objects for editing
+    ModuleBase_ISelection* aSelect = myWorkshop->selection();
+    QList<ModuleBase_ViewerPrs> aHighlighted = aSelect->getHighlighted();
+    QList<ModuleBase_ViewerPrs> aSelected = aSelect->getSelected();
+    myEditingFeatures.clear();
+    myEditingAttr.clear();
+    if ((aHighlighted.size() == 0) && (aSelected.size() == 0)) {
+      if (isSketchOpe && (!isSketcher))
+        // commit previous operation
+        if (!aOperation->commit())
+          aOperation->abort();
+      return;
+    }
+
+    QObjectPtrList aSelObjects = getSumList(aHighlighted, aSelected);
+    if ((aHighlighted.size() == 1) && (aSelected.size() == 0)) {
+      // Move by selected shape (vertex). Can be used only for single selection
+      foreach(ModuleBase_ViewerPrs aPrs, aHighlighted) {
+        FeaturePtr aFeature = ModelAPI_Feature::feature(aHighlighted.first().object());
+        if (aFeature) {
+          myEditingFeatures.append(aFeature);
+          TopoDS_Shape aShape = aPrs.shape();
+          if (!aShape.IsNull()) {
+            if (aShape.ShapeType() == TopAbs_VERTEX) {
+              AttributePtr aAttr = PartSet_Tools::findAttributeBy2dPoint(myEditingFeatures.first(), 
+                                                                         aShape, myCurrentSketch);
+              if (aAttr)
+                myEditingAttr.append(aAttr);
+            }
+          }
+        }
+      }
+    } else {
+      // Provide multi-selection. Can be used only for features
+      foreach (ObjectPtr aObj, aSelObjects) {
+        FeaturePtr aFeature = ModelAPI_Feature::feature(aObj);
+        if (aFeature && (!myEditingFeatures.contains(aFeature)))
+          myEditingFeatures.append(aFeature);
+      }
+
+    }
+    // If nothing highlighted - return
+    if (myEditingFeatures.size() == 0)
+      return;
+
+    if (isSketcher) {
+      myIsDragging = true;
+      get2dPoint(theWnd, theEvent, myCurX, myCurY);
+      myDragDone = false;
+      myWorkshop->viewer()->enableSelection(false);
+      launchEditing();
+
+    } else if (isSketchOpe && isEditing) {
+      // If selected another object
+      aOperation->abort();
+
+      myIsDragging = true;
+      get2dPoint(theWnd, theEvent, myCurX, myCurY);
+      myDragDone = false;
+      myWorkshop->viewer()->enableSelection(false);
+
+      // This is necessary in order to finalize previous operation
+      QApplication::processEvents();
+      launchEditing();
     }
   }
-  sendOperation(anOperation);
-  xWorkshop()->actionsMgr()->updateCheckState();
 }
 
-void PartSet_Module::onMultiSelectionEnabled(bool theEnabled)
-{
-  ModuleBase_IViewer* aViewer = myWorkshop->viewer();
-  aViewer->enableMultiselection(theEnabled);
-}
 
-void PartSet_Module::onStopSelection(const QList<ObjectPtr>& theFeatures, const bool isStop)
+void PartSet_Module::get2dPoint(ModuleBase_IViewWindow* theWnd, QMouseEvent* theEvent, 
+                                double& theX, double& theY)
 {
-  XGUI_Displayer* aDisplayer = xWorkshop()->displayer();
-  //if (!isStop) {
-  //  foreach(ObjectPtr aObject, theFeatures) {
-  //    activateFeature(aObject);
-  //  }
-  //}
-  aDisplayer->stopSelection(theFeatures, isStop, false);
-
-  ModuleBase_IViewer* aViewer = myWorkshop->viewer();
-  aViewer->enableSelection(!isStop);
-
-  aDisplayer->updateViewer();
+  Handle(V3d_View) aView = theWnd->v3dView();
+  gp_Pnt aPoint = PartSet_Tools::convertClickToPoint(theEvent->pos(), aView);
+  PartSet_Tools::convertTo2D(aPoint, myCurrentSketch, aView, theX, theY);
 }
 
-void PartSet_Module::onSetSelection(const QList<ObjectPtr>& theFeatures)
-{
-  XGUI_Displayer* aDisplayer = xWorkshop()->displayer();
-  aDisplayer->setSelected(theFeatures, false);
-  aDisplayer->updateViewer();
-}
 
-void PartSet_Module::setSketchingMode(const gp_Pln& thePln)
+void PartSet_Module::launchEditing()
 {
-  XGUI_Displayer* aDisplayer = xWorkshop()->displayer();
-  if (!myPlaneFilter.IsNull()) {
-    aDisplayer->removeSelectionFilter(myPlaneFilter);
-    myPlaneFilter.Nullify();
+  if (myEditingFeatures.size() > 0) {
+    FeaturePtr aFeature = myEditingFeatures.first();
+    std::shared_ptr<SketchPlugin_Feature> aSPFeature = 
+              std::dynamic_pointer_cast<SketchPlugin_Feature>(aFeature);
+    if (aSPFeature) {
+      editFeature(aSPFeature);
+    }
   }
-  QIntList aModes;
-  // Clear standard selection modes
-  aDisplayer->setSelectionModes(aModes);
-  aDisplayer->openLocalContext();
-
-  // Set filter
-  mySketchFilter = new ModuleBase_ShapeInPlaneFilter(thePln);
-  aDisplayer->addSelectionFilter(mySketchFilter);
-
-  // Get default selection modes
-  aModes = sketchSelectionModes(ObjectPtr());
-  aDisplayer->activateObjectsOutOfContext(aModes);
 }
 
-void PartSet_Module::onFeatureConstructed(ObjectPtr theFeature, int theMode)
+void PartSet_Module::onMouseReleased(ModuleBase_IViewWindow* theWnd, QMouseEvent* theEvent)
 {
-  bool isDisplay = theMode != PartSet_OperationSketchBase::FM_Hide;
-  ModuleBase_Operation* aCurOperation = myWorkshop->currentOperation();
-  PartSet_OperationSketchBase* aPrevOp = dynamic_cast<PartSet_OperationSketchBase*>(aCurOperation);
-  if (aPrevOp) {
-    std::list<FeaturePtr> aList = aPrevOp->subFeatures();
-    XGUI_Displayer* aDisplayer = xWorkshop()->displayer();
-    QIntList aModes = sketchSelectionModes(aPrevOp->feature());
-    std::list<FeaturePtr>::iterator aSFIt;
-    for (aSFIt = aList.begin(); aSFIt != aList.end(); ++aSFIt) {
-      std::list<ResultPtr> aResults = (*aSFIt)->results();
-      std::list<ResultPtr>::iterator aIt;
-      for (aIt = aResults.begin(); aIt != aResults.end(); ++aIt) {
-        if (!isDisplay)
-          aDisplayer->erase((*aIt), false);
-      }
-      if (!isDisplay)
-        aDisplayer->erase((*aSFIt), false);
+  myWorkshop->viewer()->enableSelection(true);
+  if (myIsDragging) {
+    myIsDragging = false;
+    if (myDragDone) {
+      myWorkshop->currentOperation()->commit();
+      myEditingFeatures.clear();
+      myEditingAttr.clear();
     }
-    //aDisplayer->deactivateObjectsOutOfContext();
   }
-  if (isDisplay)
-    ModelAPI_EventCreator::get()->sendUpdated(
-        theFeature, Events_Loop::loop()->eventByName(EVENT_OBJECT_TO_REDISPLAY));
 }
 
-ModuleBase_Operation* PartSet_Module::createOperation(const std::string& theCmdId,
-                                                      const std::string& theFeatureKind)
-{
-  // create the operation
-  ModuleBase_Operation* anOperation = 0;
-  if (theCmdId == PartSet_OperationSketch::Type()) {
-    anOperation = new PartSet_OperationSketch(theCmdId.c_str(), this);
-  } else {
-    ModuleBase_Operation* aCurOperation = myWorkshop->currentOperation();
-    CompositeFeaturePtr aSketch;
-    PartSet_OperationSketchBase* aPrevOp = dynamic_cast<PartSet_OperationSketchBase*>(aCurOperation);
-    if (aPrevOp) {
-      aSketch = aPrevOp->sketch();
-    }
-    if (PartSet_OperationFeatureCreate::canProcessKind(theCmdId)) {
-      anOperation = new PartSet_OperationFeatureCreate(theCmdId.c_str(), this, aSketch);
-    } else if (theCmdId == PartSet_OperationFeatureEdit::Type()) {
-      anOperation = new PartSet_OperationFeatureEdit(theCmdId.c_str(), this, aSketch);
-    }
-  }
 
-  if (!anOperation) {
-    anOperation = new ModuleBase_Operation(theCmdId.c_str(), this);
+void PartSet_Module::onMouseMoved(ModuleBase_IViewWindow* theWnd, QMouseEvent* theEvent)
+{
+  if (myIsDragging) {
+    ModuleBase_Operation* aOperation = myWorkshop->currentOperation();
+    if (aOperation->id().toStdString() == SketchPlugin_Sketch::ID())
+      return; // No edit operation activated
+
+    static Events_ID anEvent = Events_Loop::eventByName(EVENT_OBJECT_MOVED);
+    Handle(V3d_View) aView = theWnd->v3dView();
+    gp_Pnt aPoint = PartSet_Tools::convertClickToPoint(theEvent->pos(), aView);
+    double aX, aY;
+    PartSet_Tools::convertTo2D(aPoint, myCurrentSketch, aView, aX, aY);
+    double dX =  aX - myCurX;
+    double dY =  aY - myCurY;
+
+    if ((aOperation->id().toStdString() == SketchPlugin_Line::ID()) &&
+        (myEditingAttr.size() == 1) && 
+        myEditingAttr.first()) {
+      // probably we have prehighlighted point
+      AttributePtr aAttr = myEditingAttr.first();
+      std::string aAttrId = aAttr->id();
+      ModuleBase_IPropertyPanel* aPanel = aOperation->propertyPanel();
+      QList<ModuleBase_ModelWidget*> aWidgets = aPanel->modelWidgets();
+      // Find corresponded widget to provide dragging
+      foreach (ModuleBase_ModelWidget* aWgt, aWidgets) {
+        if (aWgt->attributeID() == aAttrId) {
+          PartSet_WidgetPoint2D* aWgt2d = dynamic_cast<PartSet_WidgetPoint2D*>(aWgt);
+          if (aWgt2d) {
+            aWgt2d->setPoint(aWgt2d->x() + dX, aWgt2d->y() + dY);
+            break;
+          }
+        }
+      }
+    } else {
+      foreach(FeaturePtr aFeature, myEditingFeatures) {
+        std::shared_ptr<SketchPlugin_Feature> aSketchFeature =
+          std::dynamic_pointer_cast<SketchPlugin_Feature>(aFeature);
+        if (aSketchFeature) { 
+          aSketchFeature->move(dX, dY);
+          ModelAPI_EventCreator::get()->sendUpdated(aSketchFeature, anEvent);
+        }
+      }
+      // after movement the solver will call the update event: optimization
+      Events_Loop::loop()->flush(Events_Loop::eventByName(EVENT_OBJECT_MOVED));
+    }
+    myDragDone = true;
+    myCurX = aX;
+    myCurY = aY;
   }
+}
 
-  // set operation description and list of widgets corresponding to the feature xml definition
-  std::string aFeatureKind = theFeatureKind.empty() ? theCmdId : theFeatureKind;
-
-  std::string aPluginFileName = featureFile(aFeatureKind);
-  Config_WidgetReader aWdgReader = Config_WidgetReader(aPluginFileName);
-  aWdgReader.readAll();
-  std::string aXmlCfg = aWdgReader.featureWidgetCfg(aFeatureKind);
-  std::string aDescription = aWdgReader.featureDescription(aFeatureKind);
-
-  anOperation->getDescription()->setDescription(QString::fromStdString(aDescription));
-  anOperation->getDescription()->setXmlRepresentation(QString::fromStdString(aXmlCfg));
-
-  // connect the operation
-  PartSet_OperationSketchBase* aPreviewOp = dynamic_cast<PartSet_OperationSketchBase*>(anOperation);
-  if (aPreviewOp) {
-    connect(aPreviewOp, SIGNAL(featureConstructed(ObjectPtr, int)), this,
-            SLOT(onFeatureConstructed(ObjectPtr, int)));
-    connect(aPreviewOp, SIGNAL(restartRequired(std::string, ObjectPtr)), this,
-            SLOT(onRestartOperation(std::string, ObjectPtr)));
-    // If manage multi selection the it will be impossible to select more then one
-    // object under operation Edit
-//    connect(aPreviewOp, SIGNAL(multiSelectionEnabled(bool)), this,
-//            SLOT(onMultiSelectionEnabled(bool)));
-
-    connect(aPreviewOp, SIGNAL(stopSelection(const QList<ObjectPtr>&, const bool)), this,
-            SLOT(onStopSelection(const QList<ObjectPtr>&, const bool)));
-    connect(aPreviewOp, SIGNAL(setSelection(const QList<ObjectPtr>&)), this,
-            SLOT(onSetSelection(const QList<ObjectPtr>&)));
-
-    PartSet_OperationSketch* aSketchOp = dynamic_cast<PartSet_OperationSketch*>(aPreviewOp);
-    if (aSketchOp) {
-      connect(aSketchOp, SIGNAL(planeSelected(double, double, double)), this,
-              SLOT(onPlaneSelected(double, double, double)));
-      connect(aSketchOp, SIGNAL(fitAllView()), this, SLOT(onFitAllView()));
-      connect(aSketchOp, SIGNAL(launchSketch()), this, SLOT(onSketchLaunched()));
+void PartSet_Module::onMouseDoubleClick(ModuleBase_IViewWindow* theWnd, QMouseEvent* theEvent)
+{
+  ModuleBase_Operation* aOperation = myWorkshop->currentOperation();
+  if (aOperation && aOperation->isEditOperation()) {
+    std::string aId = aOperation->id().toStdString();
+    if ((aId == SketchPlugin_ConstraintLength::ID()) ||
+      (aId == SketchPlugin_ConstraintDistance::ID()) ||
+      (aId == SketchPlugin_ConstraintRadius::ID())) 
+    {
+      // Activate dimension value editing on double click
+      ModuleBase_IPropertyPanel* aPanel = aOperation->propertyPanel();
+      QList<ModuleBase_ModelWidget*> aWidgets = aPanel->modelWidgets();
+      // Find corresponded widget to activate value editing
+      foreach (ModuleBase_ModelWidget* aWgt, aWidgets) {
+        if (aWgt->attributeID() == "ConstraintValue") {
+          aWgt->focusTo();
+          return;
+        }
+      }
     }
   }
+}
 
-  return anOperation;
+void PartSet_Module::onKeyRelease(ModuleBase_IViewWindow* theWnd, QKeyEvent* theEvent)
+{
+  XGUI_ModuleConnector* aConnector = dynamic_cast<XGUI_ModuleConnector*>(workshop());
+  XGUI_OperationMgr* anOpMgr = aConnector->workshop()->operationMgr();
+  anOpMgr->onKeyReleased(theEvent);
 }
 
+void PartSet_Module::onEnterReleased()
+{
+  myRestartingMode = RM_EmptyFeatureUsed;
+}
 
-void PartSet_Module::updateCurrentPreview(const std::string& theCmdId)
+void PartSet_Module::onOperationActivatedByPreselection()
 {
-  ModuleBase_Operation* anOperation = myWorkshop->currentOperation();
-  if (!anOperation)
+  ModuleBase_Operation* aOperation = myWorkshop->currentOperation();
+  if (!aOperation)
     return;
 
-  PartSet_OperationSketchBase* aPreviewOp = dynamic_cast<PartSet_OperationSketchBase*>(anOperation);
-  if (!aPreviewOp)
-    return;
+  // Set final definitions if they are necessary
+  //propertyPanelDefined(aOperation);
 
-  FeaturePtr aFeature = aPreviewOp->feature();
-  if (!aFeature || aFeature->getKind() != theCmdId)
-    return;
+  /// Commit sketcher operations automatically
+  FeaturePtr aFeature = aOperation->feature();
+  std::shared_ptr<SketchPlugin_Feature> aSPFeature = 
+            std::dynamic_pointer_cast<SketchPlugin_Feature>(aFeature);
+  if (aSPFeature) {
+    aOperation->commit();
+  }
+}
 
-  XGUI_Displayer* aDisplayer = xWorkshop()->displayer();
-  // Hide result of sketch
-  std::list<ResultPtr> aResults = aFeature->results();
-  std::list<ResultPtr>::const_iterator aIt;
-  for (aIt = aResults.cbegin(); aIt != aResults.cend(); ++aIt)
-    aDisplayer->erase(*aIt, false);
-
-  std::list<FeaturePtr> aList = aPreviewOp->subFeatures();
-
-  std::list<FeaturePtr>::const_iterator anIt = aList.begin(), aLast = aList.end();
-  for (; anIt != aLast; anIt++) {
-    std::shared_ptr<SketchPlugin_Feature> aSPFeature = std::dynamic_pointer_cast<
-        SketchPlugin_Feature>(*anIt);
-    if (!aSPFeature)
-      continue;
-    std::list<ResultPtr> aResults = aSPFeature->results();
-    std::list<ResultPtr>::const_iterator aRIt;
-    for (aRIt = aResults.cbegin(); aRIt != aResults.cend(); ++aRIt) {
-      aDisplayer->display((*aRIt), false);
-      aDisplayer->activate((*aRIt), sketchSelectionModes((*aRIt)));
+void PartSet_Module::onNoMoreWidgets()
+{
+  ModuleBase_Operation* aOperation = myWorkshop->currentOperation();
+  if (aOperation) {
+    /// Restart sketcher operations automatically
+    FeaturePtr aFeature = aOperation->feature();
+    std::shared_ptr<SketchPlugin_Feature> aSPFeature = 
+              std::dynamic_pointer_cast<SketchPlugin_Feature>(aFeature);
+    if (aSPFeature) {
+      if (myRestartingMode != RM_Forbided)
+        myRestartingMode = RM_LastFeatureUsed;
+      aOperation->commit();
     }
-    aDisplayer->display(aSPFeature, false);
-    aDisplayer->activate(aSPFeature, sketchSelectionModes(aSPFeature));
   }
-  aDisplayer->updateViewer();
 }
 
-void PartSet_Module::editFeature(FeaturePtr theFeature)
+QStringList PartSet_Module::sketchOperationIdList() const
 {
-  if (!theFeature)
-    return;
-
-//  if (theFeature->getKind() == SKETCH_KIND) {
-  //FeaturePtr aFeature = theFeature;
-  //if (XGUI_Tools::isModelObject(aFeature)) {
-  //  ObjectPtr aObject = std::dynamic_pointer_cast<ModelAPI_Object>(aFeature);
-  //  aFeature = aObject->featureRef();
-  //}
-
-  //if (aFeature) {
-  onRestartOperation(theFeature->getKind(), theFeature);
-  updateCurrentPreview(theFeature->getKind());
-  //}
-//  }
+  QStringList aIds;
+  aIds << SketchPlugin_Line::ID().c_str();
+  aIds << SketchPlugin_Point::ID().c_str();
+  aIds << SketchPlugin_Arc::ID().c_str();
+  aIds << SketchPlugin_Circle::ID().c_str();
+  aIds << SketchPlugin_ConstraintLength::ID().c_str();
+  aIds << SketchPlugin_ConstraintDistance::ID().c_str();
+  aIds << SketchPlugin_ConstraintRigid::ID().c_str();
+  aIds << SketchPlugin_ConstraintRadius::ID().c_str();
+  aIds << SketchPlugin_ConstraintPerpendicular::ID().c_str();
+  aIds << SketchPlugin_ConstraintParallel::ID().c_str();
+  return aIds;
 }
 
-void PartSet_Module::onStorePoint2D(ObjectPtr theFeature, const std::string& theAttribute)
+void PartSet_Module::onVertexSelected(ObjectPtr theObject, const TopoDS_Shape& theShape)
 {
-  FeaturePtr aFeature = std::dynamic_pointer_cast<ModelAPI_Feature>(theFeature);
-
-  PartSet_OperationSketchBase* aPreviewOp = 
-    dynamic_cast<PartSet_OperationSketchBase*>(myWorkshop->currentOperation());
-  if (!aPreviewOp)
-    return;
-
-  std::shared_ptr<GeomDataAPI_Point2D> aPoint = std::dynamic_pointer_cast<GeomDataAPI_Point2D>(
-      aFeature->data()->attribute(theAttribute));
-
-  PartSet_Tools::setConstraints(aPreviewOp->sketch(), aFeature, theAttribute, aPoint->x(),
-                                aPoint->y());
+  ModuleBase_Operation* aOperation = myWorkshop->currentOperation();
+  if (aOperation->id().toStdString() == SketchPlugin_Line::ID()) {
+    /// If last line finished on vertex the lines creation sequence has to be break
+    ModuleBase_IPropertyPanel* aPanel = aOperation->propertyPanel();
+    const QList<ModuleBase_ModelWidget*>& aWidgets = aPanel->modelWidgets();
+    if (aWidgets.last() == aPanel->activeWidget()) {
+      myRestartingMode = RM_Forbided;
+    }
+  }
 }
 
 QWidget* PartSet_Module::createWidgetByType(const std::string& theType, QWidget* theParent,
-                                            Config_WidgetAPI* theWidgetApi,
+                                            Config_WidgetAPI* theWidgetApi, std::string theParentId,
                                             QList<ModuleBase_ModelWidget*>& theModelWidgets)
 {
+  XGUI_ModuleConnector* aConnector = dynamic_cast<XGUI_ModuleConnector*>(workshop());
+  XGUI_Workshop* aWorkshop = aConnector->workshop();
   if (theType == "sketch-start-label") {
-    PartSet_WidgetSketchLabel* aWgt = new PartSet_WidgetSketchLabel(theParent, theWidgetApi, "");
-    aWgt->setOperationsMgr(xWorkshop()->operationMgr());
+    PartSet_WidgetSketchLabel* aWgt = new PartSet_WidgetSketchLabel(theParent, theWidgetApi, theParentId);
+    aWgt->setWorkshop(aWorkshop);
+    connect(aWgt, SIGNAL(planeSelected(const std::shared_ptr<GeomAPI_Pln>&)), 
+      this, SLOT(onPlaneSelected(const std::shared_ptr<GeomAPI_Pln>&)));
     theModelWidgets.append(aWgt);
     return aWgt->getControl();
-  } else
-    return 0;
-}
 
+  } else if (theType == "sketch-2dpoint_selector") {
+    PartSet_WidgetPoint2D* aWgt = new PartSet_WidgetPoint2D(theParent, theWidgetApi, theParentId);
+    aWgt->setWorkshop(aWorkshop);
+    aWgt->setSketch(myCurrentSketch);
 
-XGUI_Workshop* PartSet_Module::xWorkshop() const
-{
-  XGUI_ModuleConnector* aConnector = dynamic_cast<XGUI_ModuleConnector*>(workshop());
-  if (aConnector) {
-    return aConnector->workshop();
-  }
-  return 0;
-}
+    connect(aWgt, SIGNAL(vertexSelected(ObjectPtr, const TopoDS_Shape&)), 
+      this, SLOT(onVertexSelected(ObjectPtr, const TopoDS_Shape&)));
 
+    theModelWidgets.append(aWgt);
+    return aWgt->getControl();
 
-QIntList PartSet_Module::sketchSelectionModes(ObjectPtr theFeature)
-{
-  QIntList aModes;
-  FeaturePtr aFeature = std::dynamic_pointer_cast<ModelAPI_Feature>(theFeature);
-  if (aFeature) {
-    if (aFeature->getKind() == SketchPlugin_Sketch::ID()) {
-      aModes.append(TopAbs_FACE);
-      return aModes;
-    } else if (PartSet_Tools::isConstraintFeature(aFeature->getKind())) {
-      aModes.append(AIS_DSM_Text);
-      aModes.append(AIS_DSM_Line);
-      return aModes;
-    }
-  } 
-  aModes.append(AIS_Shape::SelectionMode((TopAbs_ShapeEnum) TopAbs_VERTEX));
-  aModes.append(AIS_Shape::SelectionMode((TopAbs_ShapeEnum) TopAbs_EDGE));
-  return aModes;
-}
+  } if (theType == "point2ddistance") {
+    PartSet_WidgetPoint2dDistance* aWgt = new PartSet_WidgetPoint2dDistance(theParent, theWidgetApi, theParentId);
+    aWgt->setWorkshop(aWorkshop);
+    aWgt->setSketch(myCurrentSketch);
 
+    theModelWidgets.append(aWgt);
+    return aWgt->getControl();
 
-gp_Pln PartSet_Module::getSketchPlane(FeaturePtr theSketch) const
-{
-  DataPtr aData = theSketch->data();
-  std::shared_ptr<GeomDataAPI_Point> anOrigin = std::dynamic_pointer_cast<GeomDataAPI_Point>(
-      aData->attribute(SketchPlugin_Sketch::ORIGIN_ID()));
-  std::shared_ptr<GeomDataAPI_Dir> aNorm = std::dynamic_pointer_cast<GeomDataAPI_Dir>(
-      aData->attribute(SketchPlugin_Sketch::NORM_ID()));
-  gp_Pnt aOrig(anOrigin->x(), anOrigin->y(), anOrigin->z());
-  gp_Dir aDir(aNorm->x(), aNorm->y(), aNorm->z());
-  return gp_Pln(aOrig, aDir);
-}
+  } if (theType == "sketch_shape_selector") {
+    PartSet_WidgetShapeSelector* aWgt = 
+      new PartSet_WidgetShapeSelector(theParent, workshop(), theWidgetApi, theParentId);
+    aWgt->setSketcher(myCurrentSketch);
 
+    theModelWidgets.append(aWgt);
+    return aWgt->getControl();
 
-void PartSet_Module::onSelectionChanged()
-{
-  ModuleBase_ISelection* aSelect = myWorkshop->selection();
-  QList<ModuleBase_ViewerPrs> aSelected = aSelect->getSelected();
-  // We need to stop edit operation if selection is cleared
-  if (aSelected.size() == 0) {
-    // do not perform commit of the current edit operation here, because
-    // this functionality is realized inside this operation
-    /*PartSet_OperationFeatureEdit* anEditOp = 
-      dynamic_cast<PartSet_OperationFeatureEdit*>(myWorkshop->currentOperation());
-    if (!anEditOp)
-      return;
-    anEditOp->commit();*/
-  } else {
-    PartSet_OperationSketchBase* aSketchOp = 
-      dynamic_cast<PartSet_OperationSketchBase*>(myWorkshop->currentOperation());
-    if (aSketchOp) {
-      aSketchOp->selectionChanged(aSelect);
-    }
-  }
+  } if (theType == "sketch_constraint_shape_selector") {
+    PartSet_WidgetConstraintShapeSelector* aWgt = 
+      new PartSet_WidgetConstraintShapeSelector(theParent, workshop(), theWidgetApi, theParentId);
+    aWgt->setSketcher(myCurrentSketch);
+
+    theModelWidgets.append(aWgt);
+    return aWgt->getControl();
+
+  }else
+    return 0;
 }
+
index b42c1a93da6d9ccf3ee8213360f6d6b0a9a083b5..e04148a1db65620069090f9feeca5d8017c9c656 100644 (file)
@@ -1,14 +1,19 @@
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
 #ifndef PartSet_Module_H
 #define PartSet_Module_H
 
 #include "PartSet.h"
+#include <PartSet_Filters.h>
 
 #include <ModuleBase_IModule.h>
 #include <ModuleBase_Definitions.h>
-#include <ModuleBase_ViewerFilters.h>
-#include <XGUI_Command.h>
 #include <ModelAPI_Feature.h>
+#include <ModelAPI_Attribute.h>
+#include <ModelAPI_CompositeFeature.h>
+
 #include <StdSelect_FaceFilter.hxx>
+#include <TopoDS_Shape.hxx>
 
 #include <QMap>
 #include <QObject>
 
 #include <memory>
 
-class PartSet_Listener;
-class ModelAPI_Feature;
-class XGUI_ViewerPrs;
-class XGUI_Workshop;
 class ModuleBase_Operation;
-class GeomAPI_AISObject;
+class ModuleBase_IViewWindow;
 
 class PARTSET_EXPORT PartSet_Module : public ModuleBase_IModule
 {
 Q_OBJECT
 
- public:
+/// Enumeration to specify the restart operation properties.
+enum RestartingMode {
+  RM_None, /// the operation should not be restarted
+  RM_Forbided, /// the operation should not be restarted after there is no active widget
+  RM_LastFeatureUsed, /// the operation is restarted and use the previous feature for own initialization
+  RM_EmptyFeatureUsed /// the operation is restarted and does not use the previous feature
+};
+
+public:
   PartSet_Module(ModuleBase_IWorkshop* theWshop);
   virtual ~PartSet_Module();
 
-  /// Reads description of features from XML file 
-  virtual void createFeatures();
-
-  /// Called on creation of menu item in desktop
-  virtual void featureCreated(QAction* theFeature);
-
-  std::string featureFile(const std::string&);
-
-  /// Creates an operation and send it to loop
-  /// \param theCmdId the operation name
-  //virtual void launchOperation(const QString& theCmdId);
-
-  /// Updates current operation preview, if it has it.
-  /// \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,
+                                      Config_WidgetAPI* theWidgetApi, std::string theParentId,
                                       QList<ModuleBase_ModelWidget*>& theModelWidgets);
 
-  XGUI_Workshop* xWorkshop() const;
-
-
-  /// Returns list of selection modes for the given object for sketch operation
-  static QIntList sketchSelectionModes(ObjectPtr theFeature);
-
- public slots:
-  void onFeatureTriggered();
-  /// SLOT, that is called after the operation is started. Connect on the focus activated signal
-  void onOperationStarted(ModuleBase_Operation* theOperation);
-  /// SLOT, that is called after the operation is stopped. Switched off the modfications performed
-  /// by the operation start
-  void onOperationStopped(ModuleBase_Operation* theOperation);
-  /// SLOT, that is called afetr the popup menu action clicked.
-  void onContextMenuCommand(const QString& theId, bool isChecked);
-
-  /// SLOT, to apply to the current viewer the operation
-  /// \param theX the X projection value
-  /// \param theY the Y projection value
-  /// \param theZ the Z projection value
-  void onPlaneSelected(double theX, double theY, double theZ);
-
-  /// SLOT, to fit all current viewer
-  void onFitAllView();
+  /// Call back forlast tuning of property panel before operation performance
+  virtual void propertyPanelDefined(ModuleBase_Operation* theOperation);
 
-  void onRestartOperation(std::string theName, ObjectPtr theFeature);
+  QStringList sketchOperationIdList() const;
 
-  /// SLOT, to switch on/off the multi selection in the viewer
-  /// \param theEnabled the enabled state
-  void onMultiSelectionEnabled(bool theEnabled);
+  /// Realizes some functionality by an operation start
+  /// Displays all sketcher sub-Objects, hides sketcher result, appends selection filters
+  /// \param theOperation a started operation
+  virtual void operationStarted(ModuleBase_Operation* theOperation);
 
-  /// SLOT, to stop or start selection mode for the features
-  /// \param theFeatures a list of features to be disabled
-  /// \param theToStop the boolean state whether it it stopped or non stopped
-  void onStopSelection(const QList<ObjectPtr>& theFeatures, const bool isStop);
+  /// Realizes some functionality by an operation commit
+  /// Restarts sketcher operation automatically of it is necessary
+  /// \param theOperation a committed operation
+  virtual void operationCommitted(ModuleBase_Operation* theOperation);
 
-  /// SLOT, to set selection
-  /// \param theFeatures a list of features to be selected
-  void onSetSelection(const QList<ObjectPtr>& theFeatures);
+  /// Realizes some functionality by an operation abort
+  /// Hides all sketcher sub-Objects, displays sketcher result and removes selection filters
+  /// \param theOperation an aborted operation
+  virtual void operationAborted(ModuleBase_Operation* theOperation);
 
-  /// SLOT, Defines Sketch editing mode
-  /// \param thePln - plane of current sketch
-  void setSketchingMode(const gp_Pln& thePln);
+  /// Realizes some functionality by an operation stop
+  /// Hides all sketcher sub-Objects, displays sketcher result and removes selection filters
+  /// \param theOperation a stopped operation
+  virtual void operationStopped(ModuleBase_Operation* theOperation);
 
-  /// SLOT, to visualize the feature in another local context mode
-  /// \param theFeature the feature to be put in another local context mode
-  /// \param theMode the mode appeared on the feature
-  void onFeatureConstructed(ObjectPtr theFeature, int theMode);
-
-  /// Slot which reacts to the point 2d set to the feature. Creates a constraint
-  /// \param the feature
-  /// \param the attribute of the feature
-  void onStorePoint2D(ObjectPtr theFeature, const std::string& theAttribute);
-
-  /// Called when sketch is launched
-  void onSketchLaunched();
+public slots:
+  /// SLOT, that is called by no more widget signal emitted by property panel
+  /// Set a specific flag to restart the sketcher operation
+  void onNoMoreWidgets();
 
 protected slots:
-  /// Called on selection changed event
+  /// Called when previous operation is finished
   virtual void onSelectionChanged();
 
   /// SLOT, that is called by mouse press in the viewer.
-  /// The mouse released point is sent to the current operation to be processed.
+  /// \param theWnd - the window where the event happens
   /// \param theEvent the mouse event
-  virtual void onMousePressed(QMouseEvent* theEvent);
+  void onMousePressed(ModuleBase_IViewWindow* theWnd, QMouseEvent* theEvent);
 
   /// SLOT, that is called by mouse release in the viewer.
-  /// The mouse released point is sent to the current operation to be processed.
+  /// \param theWnd - the window where the event happens
   /// \param theEvent the mouse event
-  virtual void onMouseReleased(QMouseEvent* theEvent);
+  void onMouseReleased(ModuleBase_IViewWindow* theWnd, QMouseEvent* theEvent);
   
   /// SLOT, that is called by mouse move in the viewer.
-  /// The mouse moved point is sent to the current operation to be processed.
+  /// \param theWnd - the window where the event happens
   /// \param theEvent the mouse event
-  virtual void onMouseMoved(QMouseEvent* theEvent);
+  void onMouseMoved(ModuleBase_IViewWindow* theWnd, QMouseEvent* theEvent);
 
-  /// SLOT, that is called by the mouse double click in the viewer.
+  /// SLOT, that is called by mouse double click in the viewer.
+  /// \param theWnd - the window where the event happens
   /// \param theEvent the mouse event
-  virtual void onMouseDoubleClick(QMouseEvent* theEvent);
+  void onMouseDoubleClick(ModuleBase_IViewWindow* theWnd, QMouseEvent* theEvent);
 
-  /// SLOT, that is called by the key in the viewer is clicked.
-  /// \param theEvent the mouse event
-  virtual void onKeyRelease(QKeyEvent* theEvent);
+  /// SLOT, that is called by key release in the viewer.
+  /// The mouse moved point is sent to the current operation to be processed.
+  /// \param theEvent the key event
+  void onKeyRelease(ModuleBase_IViewWindow* theWnd, QKeyEvent* theEvent);
 
- protected:
-  /// Creates a new operation
-  /// \param theCmdId the operation name
-  /// \param theFeatureKind a kind of feature to get the feature xml description
-  ModuleBase_Operation* createOperation(const std::string& theCmdId,
-                                        const std::string& theFeatureKind = "");
+  /// SLOT, that is called by enter key released
+  /// Set a specific type of restarting the current operation
+  void onEnterReleased();
+
+  /// SLOT, that is called by the current operation filling with the preselection.
+  /// It commits the operation of it is can be committed
+  void onOperationActivatedByPreselection();
 
+  /// Launches the operation from current highlighting
+  void launchEditing();
 
  protected:
-  //! Edits the feature
-  void editFeature(FeaturePtr theFeature);
+  /// Register validators for this module
+  virtual void registerValidators();
 
-  gp_Pln getSketchPlane(FeaturePtr theSketch) const;
+  /// Register selection filters for this module
+  virtual void registerFilters();
+
+ private slots:
+   void onVertexSelected(ObjectPtr theObject, const TopoDS_Shape& theShape);
+
+   void onPlaneSelected(const std::shared_ptr<GeomAPI_Pln>& thePln);
 
  private:
-  //XGUI_Workshop* myWorkshop;
-  PartSet_Listener* myListener;
+   /// Converts mouse position to 2d coordinates. 
+   /// Member myCurrentSketch has to be correctly defined
+  void get2dPoint(ModuleBase_IViewWindow* theWnd, QMouseEvent* theEvent, 
+                  double& theX, double& theY);
+
+  /// Breaks sequense of automatically resterted operations
+  void breakOperationSequence();
+
+ private:
+   QString myLastOperationId;
+   FeaturePtr myLastFeature;
+
+   bool myIsDragging;
+   bool myDragDone;
+
+   // Automatical restarting mode flag
+   RestartingMode myRestartingMode;
 
-  std::map<std::string, std::string> myFeaturesInFiles;
+   double myCurX, myCurY;
+   CompositeFeaturePtr myCurrentSketch;
+   QList<FeaturePtr> myEditingFeatures;
+   QList<AttributePtr> myEditingAttr;
 
-  Handle(StdSelect_FaceFilter) myPlaneFilter;
-  Handle(ModuleBase_ShapeInPlaneFilter) mySketchFilter;
+   Handle(ModuleBase_ShapeInPlaneFilter) myPlaneFilter;
+  /// A filter which provides selection within a current document or whole PartSet
+  Handle(PartSet_GlobalFilter) myDocumentShapeFilter;
 };
 
 #endif
diff --git a/src/PartSet/PartSet_Operation.cpp b/src/PartSet/PartSet_Operation.cpp
new file mode 100644 (file)
index 0000000..1335289
--- /dev/null
@@ -0,0 +1,19 @@
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
+// File:        PartSet_Operation.cpp
+// Created:     24 Nov 2014
+// Author:      Vitaly SMETANNIKOV
+
+#include "PartSet_Operation.h"
+
+#include <ModuleBase_IWorkshop.h>
+#include <ModuleBase_ISelection.h>
+
+void PartSet_Operation::onSelectionChanged()
+{
+  if (isEditOperation()) {
+    ModuleBase_ISelection* aSelection = myWorkshop->selection();
+    QList<ModuleBase_ViewerPrs> aHighlighted = aSelection->getHighlighted();
+    QList<ModuleBase_ViewerPrs> aSelected = aSelection->getSelected();
+  }
+}
\ No newline at end of file
diff --git a/src/PartSet/PartSet_Operation.h b/src/PartSet/PartSet_Operation.h
new file mode 100644 (file)
index 0000000..83fce7e
--- /dev/null
@@ -0,0 +1,32 @@
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
+// File:        PartSet_Operation.h
+// Created:     24 Nov 2014
+// Author:      Vitaly SMETANNIKOV
+
+#ifndef PartSet_Operation_H
+#define PartSet_Operation_H
+
+#include "PartSet.h"
+
+#include <ModuleBase_Operation.h>
+
+class ModuleBase_IWorkshop;
+
+class PARTSET_EXPORT PartSet_Operation : public ModuleBase_Operation
+{
+Q_OBJECT
+ public:
+   PartSet_Operation(const QString& theId = "", QObject* theParent = 0)
+     :ModuleBase_Operation(theId, theParent) {}
+
+   void setWorkshop(ModuleBase_IWorkshop* theWorkshop) { myWorkshop = theWorkshop; } 
+
+public slots:
+  void onSelectionChanged();
+
+private:
+  ModuleBase_IWorkshop* myWorkshop;
+};
+
+#endif
\ No newline at end of file
diff --git a/src/PartSet/PartSet_OperationFeatureBase.cpp b/src/PartSet/PartSet_OperationFeatureBase.cpp
deleted file mode 100644 (file)
index 65689f2..0000000
+++ /dev/null
@@ -1,126 +0,0 @@
-// File:        PartSet_OperationFeatureBase.h
-// Created:     20 Apr 2014
-// Author:      Natalia ERMOLAEVA
-
-#include <PartSet_OperationFeatureBase.h>
-
-#include <PartSet_Tools.h>
-#include <PartSet_OperationSketch.h>
-
-#include <SketchPlugin_Feature.h>
-#include <SketchPlugin_Point.h>
-#include <SketchPlugin_Line.h>
-#include <SketchPlugin_Circle.h>
-#include <SketchPlugin_Arc.h>
-#include <SketchPlugin_ConstraintDistance.h>
-#include <SketchPlugin_ConstraintLength.h>
-#include <SketchPlugin_ConstraintRadius.h>
-#include <SketchPlugin_ConstraintParallel.h>
-#include <SketchPlugin_ConstraintPerpendicular.h>
-#include <SketchPlugin_ConstraintCoincidence.h>
-
-#include <GeomAPI_Pnt2d.h>
-
-#include <ModuleBase_OperationDescription.h>
-#include <ModuleBase_WidgetPoint2D.h>
-#include <ModuleBase_WidgetValueFeature.h>
-#include "ModuleBase_IPropertyPanel.h"
-#include "ModuleBase_ISelection.h"
-#include "ModuleBase_IViewer.h"
-
-#include <XGUI_Constants.h>
-
-#include <V3d_View.hxx>
-#include <BRep_Tool.hxx>
-
-#ifdef _DEBUG
-#include <QDebug>
-#include <iostream>
-#endif
-
-#include <QMouseEvent>
-
-using namespace std;
-
-PartSet_OperationFeatureBase::PartSet_OperationFeatureBase(const QString& theId,
-                                                               QObject* theParent,
-                                                               CompositeFeaturePtr theFeature)
-    : PartSet_OperationSketchBase(theId, theParent),
-      mySketch(theFeature)
-{
-}
-
-PartSet_OperationFeatureBase::~PartSet_OperationFeatureBase()
-{
-}
-
-CompositeFeaturePtr PartSet_OperationFeatureBase::sketch() const
-{
-  return mySketch;
-}
-
-void PartSet_OperationFeatureBase::mouseReleased(QMouseEvent* theEvent, ModuleBase_IViewer* theViewer,
-                                                 ModuleBase_ISelection* theSelection)
-{
-  Handle(V3d_View) aView = theViewer->activeView();
-  gp_Pnt aPoint = PartSet_Tools::convertClickToPoint(theEvent->pos(), aView);
-  double aX = aPoint.X(), anY = aPoint.Y();
-  QList<ModuleBase_ViewerPrs> aSelected = theSelection->getSelected();
-
-  if (aSelected.empty()) {
-    PartSet_Tools::convertTo2D(aPoint, sketch(), aView, aX, anY);
-  } else {
-    ModuleBase_ViewerPrs aPrs = aSelected.first();
-    if (getViewerPoint(aPrs, theViewer, aX, anY)) {
-      ModuleBase_ModelWidget* aActiveWgt = myPropertyPanel->activeWidget();
-      PartSet_Tools::setConstraints(sketch(), feature(), aActiveWgt->attributeID(), aX, anY);
-    }
-    const TopoDS_Shape& aShape = aPrs.shape();
-    if (!aShape.IsNull() && aShape.ShapeType() == TopAbs_EDGE) { // a line is selected
-      PartSet_Tools::convertTo2D(aPoint, sketch(), aView, aX, anY);
-    }
-  }
-  ObjectPtr aFeature;
-  if (!aSelected.empty()) {
-    ModuleBase_ViewerPrs aPrs = aSelected.first();
-    aFeature = aPrs.object();
-  } else {
-    aFeature = feature();  // for the widget distance only
-  }
-
-  bool isApplyed = setWidgetValue(aFeature, aX, anY);
-  if (isApplyed) {
-    flushUpdated();
-    myPropertyPanel->activateNextWidget();
-  }
-  // the operation can be committed only when there is no an active widget anymore
-  // if this check is absent, the edit operation for constraint perpendicular is stopped
-  // after the first object selection in the viewer(there are two objects to be selected)
-  // the second case is the constraint distance, the edit is stopped after any mouse click
-  // in the viewer whenever it is applyed or not to the selection control
-  if (!myPropertyPanel->activeWidget())
-    commit();
-}
-
-bool PartSet_OperationFeatureBase::getViewerPoint(ModuleBase_ViewerPrs thePrs,
-                                                       ModuleBase_IViewer* theViewer,
-                                                       double& theX, double& theY)
-{
-  return PartSet_Tools::hasVertexShape(thePrs, sketch(), theViewer->activeView(),
-                                       theX, theY);
-}
-
-/*bool PartSet_OperationFeatureBase::setWidgetValue(ObjectPtr theFeature, double theX, double theY)
-{
-  ModuleBase_ModelWidget* aActiveWgt = myPropertyPanel->activeWidget();
-  if (!aActiveWgt)
-    return false;
-  ModuleBase_WidgetValueFeature* aValue = new ModuleBase_WidgetValueFeature();
-  aValue->setObject(theFeature);
-  aValue->setPoint(std::shared_ptr<GeomAPI_Pnt2d>(new GeomAPI_Pnt2d(theX, theY)));
-  bool isApplyed = aActiveWgt->setValue(aValue);
-
-  delete aValue;
-  myIsModified = (myIsModified || isApplyed);
-  return isApplyed;
-}*/
diff --git a/src/PartSet/PartSet_OperationFeatureBase.h b/src/PartSet/PartSet_OperationFeatureBase.h
deleted file mode 100644 (file)
index ee290dd..0000000
+++ /dev/null
@@ -1,63 +0,0 @@
-// File:        PartSet_OperationFeatureBase.h
-// Created:     20 Apr 2014
-// Author:      Natalia ERMOLAEVA
-
-#ifndef PARTSET_OPERATIONFEATUREBASE_H
-#define PARTSET_OPERATIONFEATUREBASE_H
-
-#include "PartSet.h"
-
-#include <PartSet_OperationSketchBase.h>
-#include <PartSet_Constants.h>
-
-#include <QObject>
-
-class GeomDataAPI_Point2D;
-class QMouseEvent;
-class QKeyEvent;
-
-/*!
- \class PartSet_OperationFeatureBase
- * \brief The operation for the sketch feature creation
- */
-class PARTSET_EXPORT PartSet_OperationFeatureBase : public PartSet_OperationSketchBase
-{
-Q_OBJECT
-
- public:
-  /// Constructor
-  /// \param theId the feature identifier
-  /// \param theParent the operation parent
-  /// \param theSketch the parent feature
-  PartSet_OperationFeatureBase(const QString& theId, QObject* theParent, CompositeFeaturePtr theSketch);
-  /// Destructor
-  virtual ~PartSet_OperationFeatureBase();
-
-  /// Returns the operation sketch feature
-  /// \returns the sketch instance
-  virtual CompositeFeaturePtr sketch() const;
-
-  /// Gives the current selected objects to be processed by the operation
-  /// \param theEvent the mouse event
-  /// \param theView a viewer to have the viewer the eye position
-  /// \param theSelected the list of selected presentations
-  /// \param theHighlighted the list of highlighted presentations
-  virtual void mouseReleased(QMouseEvent* theEvent, ModuleBase_IViewer* theViewer,
-                             ModuleBase_ISelection* theSelection);
-
- protected:
-  /// Return a widget value point by the selection and the viewer position
-  /// \param thePrs the presentation
-  /// \param theViewer a viewer to have the viewer the eye position
-  /// \param theX the horizontal coordinate
-  /// \param theY the vertical coordinate
-  /// \return true if the point exits in the selection
-  virtual bool getViewerPoint(ModuleBase_ViewerPrs thePrs,
-                                   ModuleBase_IViewer* theViewer,
-                                   double& theX, double& theY);
-
- protected:
-  CompositeFeaturePtr mySketch;  ///< the sketch of the feature
-};
-
-#endif
diff --git a/src/PartSet/PartSet_OperationFeatureCreate.cpp b/src/PartSet/PartSet_OperationFeatureCreate.cpp
deleted file mode 100644 (file)
index 8e18b67..0000000
+++ /dev/null
@@ -1,195 +0,0 @@
-// File:        PartSet_OperationFeatureCreate.h
-// Created:     20 Apr 2014
-// Author:      Natalia ERMOLAEVA
-
-#include <PartSet_OperationFeatureCreate.h>
-
-#include <PartSet_Tools.h>
-#include <PartSet_OperationSketch.h>
-
-#include <SketchPlugin_Feature.h>
-#include <SketchPlugin_Point.h>
-#include <SketchPlugin_Line.h>
-#include <SketchPlugin_Circle.h>
-#include <SketchPlugin_Arc.h>
-#include <SketchPlugin_ConstraintDistance.h>
-#include <SketchPlugin_ConstraintLength.h>
-#include <SketchPlugin_ConstraintRadius.h>
-#include <SketchPlugin_ConstraintParallel.h>
-#include <SketchPlugin_ConstraintPerpendicular.h>
-#include <SketchPlugin_ConstraintCoincidence.h>
-#include <SketchPlugin_ConstraintRigid.h>
-
-#include <GeomAPI_Pnt2d.h>
-
-#include <ModuleBase_OperationDescription.h>
-#include <ModuleBase_WidgetPoint2D.h>
-#include <ModuleBase_WidgetValueFeature.h>
-#include <ModuleBase_ViewerPrs.h>
-#include <ModuleBase_IPropertyPanel.h>
-#include <ModuleBase_ISelection.h>
-#include <ModuleBase_IViewer.h>
-
-#include <XGUI_Constants.h>
-
-#include <V3d_View.hxx>
-
-#ifdef _DEBUG
-#include <QDebug>
-#include <iostream>
-#endif
-
-#include <QMouseEvent>
-
-using namespace std;
-
-PartSet_OperationFeatureCreate::PartSet_OperationFeatureCreate(const QString& theId,
-                                                               QObject* theParent,
-                                                               CompositeFeaturePtr theFeature)
-    : PartSet_OperationFeatureBase(theId, theParent, theFeature)
-{
-}
-
-PartSet_OperationFeatureCreate::~PartSet_OperationFeatureCreate()
-{
-}
-
-bool PartSet_OperationFeatureCreate::canProcessKind(const std::string& theId)
-{
-  return theId == SketchPlugin_Line::ID() || theId == SketchPlugin_Point::ID()
-      || theId == SketchPlugin_Circle::ID() || theId == SketchPlugin_Arc::ID()
-      || theId == SketchPlugin_ConstraintDistance::ID()
-      || theId == SketchPlugin_ConstraintLength::ID()
-      || theId == SketchPlugin_ConstraintRadius::ID()
-      || theId == SketchPlugin_ConstraintParallel::ID()
-      || theId == SketchPlugin_ConstraintPerpendicular::ID()
-      || theId == SketchPlugin_ConstraintCoincidence::ID()
-      || theId == SketchPlugin_ConstraintRigid::ID();
-}
-
-void PartSet_OperationFeatureCreate::mouseMoved(QMouseEvent* theEvent, ModuleBase_IViewer* theViewer)
-{
-    double aX, anY;
-    Handle(V3d_View) aView = theViewer->activeView();
-    gp_Pnt aPoint = PartSet_Tools::convertClickToPoint(theEvent->pos(), aView);
-    PartSet_Tools::convertTo2D(aPoint, sketch(), aView, aX, anY);
-    setWidgetValue(feature(), aX, anY);
-    flushUpdated();
-}
-
-void PartSet_OperationFeatureCreate::keyReleased(const int theKey)
-{
-  switch (theKey) {
-    case Qt::Key_Return:
-    case Qt::Key_Enter: {
-        // it start a new line creation at a free point
-      if(isValid())
-        restartOperation(feature()->getKind());
-    }
-      break;
-    default:
-      break;
-  }
-}
-
-void PartSet_OperationFeatureCreate::mouseReleased(QMouseEvent* theEvent, ModuleBase_IViewer* theViewer,
-                                                   ModuleBase_ISelection* theSelection)
-{
-  Handle(V3d_View) aView = theViewer->activeView();
-  gp_Pnt aPoint = PartSet_Tools::convertClickToPoint(theEvent->pos(), aView);
-  double aX = aPoint.X(), anY = aPoint.Y();
-  bool isClosedContour = false;
-
-  QList<ModuleBase_ViewerPrs> aSelected = theSelection->getSelected();
-
-  if (aSelected.empty()) {
-    PartSet_Tools::convertTo2D(aPoint, sketch(), aView, aX, anY);
-  } else {
-    ModuleBase_ViewerPrs aPrs = aSelected.first();
-    if (getViewerPoint(aPrs, theViewer, aX, anY)) {
-      ModuleBase_ModelWidget* aActiveWgt = myPropertyPanel->activeWidget();
-      PartSet_Tools::setConstraints(sketch(), feature(), aActiveWgt->attributeID(), aX, anY);
-      isClosedContour = true;
-    }
-    const TopoDS_Shape& aShape = aPrs.shape();
-    if (!aShape.IsNull() && aShape.ShapeType() == TopAbs_EDGE) { // a line is selected
-      ObjectPtr aObject = aPrs.object();
-      if (sketch()->isSub(aObject))
-        PartSet_Tools::convertTo2D(aPoint, sketch(), aView, aX, anY);
-      else {
-        // we have to create the selected edge for the current sketch
-        ResultPtr aRes = PartSet_Tools::createFixedObjectByEdge(aPrs, sketch());
-        aSelected.first().setFeature(aRes);
-      }
-    }
-  }
-  ObjectPtr aFeature;
-  if (!aSelected.empty()) {
-    ModuleBase_ViewerPrs aPrs = aSelected.first();
-    aFeature = aPrs.object();
-  } else {
-    aFeature = feature();  // for the widget distance only
-  }
-
-  bool isApplyed = setWidgetValue(aFeature, aX, anY);
-  if (isApplyed) {
-    flushUpdated();
-    myPropertyPanel->activateNextWidget();
-  }
-
-  if (!myPropertyPanel->activeWidget()) {
-    if(commit() && !isClosedContour) {
-      // if the point creation is finished, the next mouse release should commit the modification
-      // the next release can happens by double click in the viewer
-      restartOperation(feature()->getKind(), feature());
-    }
-  }
-}
-
-void PartSet_OperationFeatureCreate::startOperation()
-{
-  PartSet_OperationSketchBase::startOperation();
-  //emit multiSelectionEnabled(false);
-}
-
-void PartSet_OperationFeatureCreate::abortOperation()
-{
-  emit featureConstructed(feature(), FM_Hide);
-  PartSet_OperationSketchBase::abortOperation();
-}
-
-void PartSet_OperationFeatureCreate::stopOperation()
-{
-  PartSet_OperationSketchBase::stopOperation();
-  //emit multiSelectionEnabled(true);
-}
-
-void PartSet_OperationFeatureCreate::afterCommitOperation()
-{
-  PartSet_OperationSketchBase::afterCommitOperation();
-  emit featureConstructed(feature(), FM_Deactivation);
-}
-
-FeaturePtr PartSet_OperationFeatureCreate::createFeature(const bool theFlushMessage,
-  CompositeFeaturePtr theCompositeFeature)
-{
-  FeaturePtr aNewFeature = ModuleBase_Operation::createFeature(false, sketch());
-
-  if (theFlushMessage)
-    flushCreated();
-  return aNewFeature;
-}
-
-
-void PartSet_OperationFeatureCreate::onWidgetActivated(ModuleBase_ModelWidget* theWidget)
-{
-  PartSet_OperationFeatureBase::onWidgetActivated(theWidget);
-  if (myInitFeature && theWidget) {
-    ModuleBase_WidgetPoint2D* aWgt = dynamic_cast<ModuleBase_WidgetPoint2D*>(theWidget);
-    if (aWgt && aWgt->initFromPrevious(myInitFeature)) {
-      myInitFeature = FeaturePtr();
-      if (myPropertyPanel)
-        myPropertyPanel->activateNextWidget();
-    }
-  }
-}
diff --git a/src/PartSet/PartSet_OperationFeatureCreate.h b/src/PartSet/PartSet_OperationFeatureCreate.h
deleted file mode 100644 (file)
index 45e2950..0000000
+++ /dev/null
@@ -1,96 +0,0 @@
-// File:        PartSet_OperationFeatureCreate.h
-// Created:     20 Apr 2014
-// Author:      Natalia ERMOLAEVA
-
-#ifndef PartSet_OperationFeatureCreate_H
-#define PartSet_OperationFeatureCreate_H
-
-#include "PartSet.h"
-
-#include <PartSet_OperationFeatureBase.h>
-#include <PartSet_Constants.h>
-
-#include <QObject>
-
-class GeomDataAPI_Point2D;
-class QMouseEvent;
-class QKeyEvent;
-
-/*!
- \class PartSet_OperationFeatureCreate
- * \brief The operation for the sketch feature creation
- */
-class PARTSET_EXPORT PartSet_OperationFeatureCreate : public PartSet_OperationFeatureBase
-{
-Q_OBJECT
-
- public:
-  /// Returns true if the feature with the given kind can be created by this operation
-  /// \param theId the feature kind
-  /// \return the boolean result
-  static bool canProcessKind(const std::string& theId);
-
-  /// Constructor
-  /// \param theId the feature identifier
-  /// \param theParent the operation parent
-  /// \param theSketch the parent feature
-  PartSet_OperationFeatureCreate(
-    const QString& theId, QObject* theParent, CompositeFeaturePtr theSketch);
-  /// Destructor
-  virtual ~PartSet_OperationFeatureCreate();
-
-  /// Gives the current mouse point in the viewer
-  /// \param thePoint a point clicked in the viewer
-  /// \param theEvent the mouse event
-  virtual void mouseMoved(QMouseEvent* theEvent, ModuleBase_IViewer* theViewer);
-
-  /// Gives the current selected objects to be processed by the operation
-  /// \param theEvent the mouse event
-  /// \param theView a viewer to have the viewer the eye position
-  /// \param theSelected the list of selected presentations
-  /// \param theHighlighted the list of highlighted presentations
-  virtual void mouseReleased(QMouseEvent* theEvent, ModuleBase_IViewer* theViewer,
-                             ModuleBase_ISelection* theSelection);
-  /// Processes the key pressed in the view
-  /// \param theKey a key value
-  virtual void keyReleased(const int theKey);
-
-  /// Initializes the operation with previously created feature. It is used in sequental operations
-  void initFeature(FeaturePtr theFeature) { myInitFeature = theFeature; }
-
- public slots:
-  /// Slots which listen the mode widget activation
-  /// \param theWidget the model widget
-  virtual void onWidgetActivated(ModuleBase_ModelWidget* theWidget);
-
- protected:
-  /// \brief Virtual method called when operation is started
-  /// Virtual method called when operation started (see start() method for more description)
-  /// After the parent operation body perform, set sketch feature to the created line feature
-  virtual void startOperation();
-
-  /// Virtual method called when operation aborted (see abort() method for more description)
-  /// Before the feature is aborted, it should be hidden from the viewer
-  virtual void abortOperation();
-
-  /// Virtual method called when operation stopped - committed or aborted.
-  /// Restore the multi selection state
-  virtual void stopOperation();
-
-  /// Virtual method called after operation committed (see commit() method for more description)
-  virtual void afterCommitOperation();
-
-  /// Creates an operation new feature
-  /// In addition to the default realization it appends the created line feature to
-  /// the sketch feature
-  /// \param theFlushMessage the flag whether the create message should be flushed
-  /// \returns the created feature
-  virtual FeaturePtr createFeature(const bool theFlushMessage = true,
-    CompositeFeaturePtr theCompositeFeature = CompositeFeaturePtr());
-
-protected:
-  /// Feature of previous operation (for sequintal operations)
-  FeaturePtr myInitFeature;
-};
-
-#endif
diff --git a/src/PartSet/PartSet_OperationFeatureEdit.cpp b/src/PartSet/PartSet_OperationFeatureEdit.cpp
deleted file mode 100644 (file)
index d44dfa3..0000000
+++ /dev/null
@@ -1,521 +0,0 @@
-// File:        PartSet_OperationFeatureEdit.h
-// Created:     05 May 2014
-// Author:      Natalia ERMOLAEVA
-
-#include <PartSet_OperationFeatureEdit.h>
-#include <PartSet_Tools.h>
-#include <PartSet_OperationSketch.h>
-#include <SketchPlugin_Constraint.h>
-
-#include <ModuleBase_OperationDescription.h>
-#include <ModuleBase_WidgetEditor.h>
-#include <ModuleBase_ViewerPrs.h>
-#include <ModuleBase_IPropertyPanel.h>
-#include <ModuleBase_ISelection.h>
-#include <ModuleBase_IViewer.h>
-
-#include <ModelAPI_Events.h>
-
-#include <SketchPlugin_Feature.h>
-#include <GeomDataAPI_Point2D.h>
-
-#include <ModelAPI_Data.h>
-#include <ModelAPI_Document.h>
-#include <ModelAPI_Events.h>
-
-#include <Events_Loop.h>
-
-#include <SketchPlugin_Line.h>
-
-#include <V3d_View.hxx>
-#include <AIS_DimensionOwner.hxx>
-#include <AIS_DimensionSelectionMode.hxx>
-
-#ifdef _DEBUG
-#include <QDebug>
-#endif
-
-#include <QMouseEvent>
-
-using namespace std;
-
-PartSet_OperationFeatureEdit::PartSet_OperationFeatureEdit(const QString& theId,
-                                                           QObject* theParent,
-                                                           CompositeFeaturePtr theFeature)
-    : PartSet_OperationFeatureBase(theId, theParent, theFeature),
-      myIsBlockedSelection(false), myIsBlockedByDoubleClick(false)
-{
-  myIsEditing = true;
-}
-
-PartSet_OperationFeatureEdit::~PartSet_OperationFeatureEdit()
-{
-}
-
-void PartSet_OperationFeatureEdit::initSelection(ModuleBase_ISelection* theSelection,
-                                                 ModuleBase_IViewer* theViewer)
-{
-  // the method of the parent should is useless here because it processes the given
-  // selection in different way
-  //PartSet_OperationFeatureBase::initSelection(theSelection, theViewer);
-
-  QList<ModuleBase_ViewerPrs> aSelected = theSelection->getSelected();
-  QList<ModuleBase_ViewerPrs> aHighlighted = theSelection->getHighlighted();
-
-  // there is a bug in OCC, where the highlighted objects are repeated and should be
-  // filtered on the unique state here
-  QList<ModuleBase_ViewerPrs> anUniqueHighlighted;
-  foreach (ModuleBase_ViewerPrs aPrs, aHighlighted) {
-    if (!PartSet_Tools::isContainPresentation(anUniqueHighlighted, aPrs))
-      anUniqueHighlighted.append(aPrs);
-  }
-  fillFeature2Attribute(anUniqueHighlighted, theViewer, myHighlightedFeature2Attribute);
-
-  foreach (ModuleBase_ViewerPrs aPrs, anUniqueHighlighted) {
-    if (!PartSet_Tools::isContainPresentation(aSelected, aPrs))
-      aSelected.append(aPrs);
-  }
-  fillFeature2Attribute(aSelected, theViewer, myAllFeature2Attribute);
-}
-
-void PartSet_OperationFeatureEdit::fillFeature2Attribute(
-                                    const QList<ModuleBase_ViewerPrs>& thePresentations,
-                                    ModuleBase_IViewer* theViewer,
-                                    std::map<FeaturePtr, std::list<std::string> >& theFeature2Attribute)
-{
-  // 1. find all features with skipping features with selected vertex shapes
-  theFeature2Attribute.clear();
-  // firstly, collect the features without local selection
-  double aX, anY;
-  foreach (ModuleBase_ViewerPrs aPrs, thePresentations) {
-    if (getViewerPoint(aPrs, theViewer, aX, anY))
-      continue;
-    else {
-      ObjectPtr aObject = aPrs.object();
-      if (!aObject)
-        continue;
-      FeaturePtr aFeature = ModelAPI_Feature::feature(aObject);
-      if (aFeature && theFeature2Attribute.find(aFeature) == theFeature2Attribute.end()) {
-        std::list<std::string> aList;
-        // using an empty list as a sign, that this feature should be moved itself
-        theFeature2Attribute[aFeature] = aList;
-      }
-    }
-  }
-  // 2. collect the features with a local selection on them.
-  // if the list already has this feature, the local selection is skipped
-  // that means that if the selection contains a feature and a feature with local selected point,
-  // the edit is performed for a full feature
-  foreach (ModuleBase_ViewerPrs aPrs, thePresentations) {
-    if (getViewerPoint(aPrs, theViewer, aX, anY)) {
-      ObjectPtr aObject = aPrs.object();
-      if (!aObject)
-        continue;
-      FeaturePtr aFeature = ModelAPI_Feature::feature(aObject);
-      if (!aFeature)
-        continue;
-
-      // append the attribute of the vertex if it is found on the current feature
-      std::shared_ptr<GeomDataAPI_Point2D> aPoint2D = PartSet_Tools::getFeaturePoint(
-                                                                    aFeature, aX, anY);
-      std::string anAttribute = aFeature->data()->id(aPoint2D);
-      std::list<std::string> aList;
-      if (theFeature2Attribute.find(aFeature) != theFeature2Attribute.end())
-        aList = theFeature2Attribute[aFeature];
-
-      aList.push_back(anAttribute);
-      theFeature2Attribute[aFeature] = aList;
-    }
-  }
-}
-
-void PartSet_OperationFeatureEdit::mousePressed(QMouseEvent* theEvent, ModuleBase_IViewer* theViewer, ModuleBase_ISelection* theSelection)
-{
-  ModuleBase_ModelWidget* aActiveWgt = myPropertyPanel->activeWidget();
-  if(aActiveWgt && aActiveWgt->isViewerSelector()) {
-    // Almost do nothing, all stuff in on PartSet_OperationFeatureBase::mouseReleased
-    PartSet_OperationFeatureBase::mousePressed(theEvent, theViewer, theSelection);
-    // the current point should be cleared because it is saved from the previous move and 
-    // should be reinitialized after the start moving. It is important for example for the lenght
-    // constraint where the first widget is a viewer selector.
-    myCurPoint.clear();
-  }
-  else {
-    // commit always until the selection restore is realized (for feature and local selection)
-    // TODO: check whether the selection is changed and restart the operation only if it is modified
-    commit();
-    emitFeaturesDeactivation();
-    // find nearest feature and restart the operation for it
-    Handle(V3d_View) aView = theViewer->activeView();
-    QList<ModuleBase_ViewerPrs> aSelected = theSelection->getSelected();
-    QList<ModuleBase_ViewerPrs> aHighlighted = theSelection->getHighlighted();
-
-    ObjectPtr aFeature = PartSet_Tools::nearestFeature(theEvent->pos(), aView, sketch(),
-                                                       aSelected, aHighlighted);
-    if (aFeature) {
-      restartOperation(PartSet_OperationFeatureEdit::Type(), aFeature);
-    }
-  }
-  // the next code is commented because the new attempt to commit/restart operation implementation:
-  //QList<ModuleBase_ViewerPrs> aSelected = theSelection->getSelected();
-  //QList<ModuleBase_ViewerPrs> aHighlighted = theSelection->getHighlighted();
-  //bool aHasShift = (theEvent->modifiers() & Qt::ShiftModifier);
-  //if (aHasShift && !aHighlighted.empty()) {
-  //  foreach (ModuleBase_ViewerPrs aPrs, aHighlighted) {
-  //    aSelected.append(aPrs);
-  //  }
-  //}
-  //ObjectPtr aObject;
-  ///*if (!aSelected.empty()) {
-  //  aObject = aSelected.first().object();
-  //} else {   
-  //  if (!aHighlighted.empty())
-  //    aObject = aHighlighted.first().object();
-  //}*/
-  //// the priority to a highlighted object in order to edit it, even if the selected object is
-  //// the feature of this operation. Otherwise, the highlighting is ignored and the selected
-  //// object is moved
-  //if (!aHighlighted.empty()) {
-  //  aObject = aHighlighted.front().object();
-  //}
-  //if (!aObject && !aSelected.empty())  // changed for a constrain
-  //  aObject = aSelected.front().object();
-
-  //FeaturePtr aFeature = ModelAPI_Feature::feature(aObject);
-  //if (!aFeature || aFeature != feature() || (aSelected.size() > 1)) {
-  //  if (commit()) {
-  //    theViewer->enableSelection(true);
-  //    emit featureConstructed(feature(), FM_Deactivation);
-
-  //    // If we have selection and prehilighting with shift pressed 
-  //    // Then we have to select all these objects and restart as multi edit operfation
-  //    //bool aHasShift = (theEvent->modifiers() & Qt::ShiftModifier);
-  //    //if (aHasShift && !theHighlighted.empty()) {
-  //    //  QList<ObjectPtr> aSelected;
-  //    //  std::list<ModuleBase_ViewerPrs>::const_iterator aIt;
-  //    //  for (aIt = theSelected.cbegin(); aIt != theSelected.cend(); ++aIt)
-  //    //    aSelected.append((*aIt).object());
-
-  //    //  for (aIt = theHighlighted.cbegin(); aIt != theHighlighted.cend(); ++aIt) {
-  //    //    if (!aSelected.contains((*aIt).object()))
-  //    //      aSelected.append((*aIt).object());
-  //    //  }
-  //    //  emit setSelection(aSelected);
-  //    //} else 
-  //    if (aFeature) {
-  //      std::string anOperationType = PartSet_OperationFeatureEdit::Type();
-  //      restartOperation(anOperationType, aFeature);
-  //    }
-  //    //}
-  //  }
-  //}
-}
-
-void PartSet_OperationFeatureEdit::mouseMoved(QMouseEvent* theEvent, ModuleBase_IViewer* theViewer)
-{
-  if (!(theEvent->buttons() & Qt::LeftButton))
-    return;
-  Handle(V3d_View) aView = theViewer->activeView();
-  gp_Pnt aPoint = PartSet_Tools::convertClickToPoint(theEvent->pos(), aView);
-
-  theViewer->enableSelection(false);
-
-  //blockSelection(true);
-  if (myCurPoint.myIsInitialized) {
-    double aCurX, aCurY;
-    PartSet_Tools::convertTo2D(myCurPoint.myPoint, sketch(), aView, aCurX, aCurY);
-
-    double aX, anY;
-    PartSet_Tools::convertTo2D(aPoint, sketch(), aView, aX, anY);
-
-    double aDeltaX = aX - aCurX;
-    double aDeltaY = anY - aCurY;
-
-    // the next code is commented because it is obsolete by the multi edit operation realization here
-    //if (myIsMultiOperation) {
-    //  std::map<FeaturePtr, std::list<std::string>>::iterator aFeatIter = myFeature2Attribute.begin();
-    //  while (aFeatIter != myFeature2Attribute.end()) {
-    //    FeaturePtr aFeature = aFeatIter->first;
-    //    std::list<std::string> anAttributes = aFeatIter->second;
-    //    // perform edit for the feature
-    //    if (anAttributes.empty()) {
-    //      std::shared_ptr<SketchPlugin_Feature> aSketchFeature =
-    //                                     std::dynamic_pointer_cast<SketchPlugin_Feature>(aFeature);
-    //      if (aSketchFeature) {
-    //        aSketchFeature->move(aDeltaX, aDeltaY);
-    //      }
-    //    }
-    //    // perform edit for the feature's attribute
-    //    else {
-    //      std::list<std::string>::const_iterator anAttrIter = anAttributes.begin(),
-    //                                             anAttrEnd = anAttributes.end();
-    //      for (; anAttrIter != anAttrEnd; anAttrIter++) {
-    //        std::shared_ptr<GeomDataAPI_Point2D> aPointAttr = std::dynamic_pointer_cast<
-    //                         GeomDataAPI_Point2D>(aFeature->data()->attribute(*anAttrIter));
-    //        if (aPointAttr) {
-    //          aPointAttr->move(aDeltaX, aDeltaY);
-    //        }
-    //      }      
-    //    }
-    //    aFeatIter++;
-    //  }
-    //}
-    //else { // multieditoperation
-
-    //std::shared_ptr<SketchPlugin_Feature> aSketchFeature = std::dynamic_pointer_cast<
-    //    SketchPlugin_Feature>(feature());
-
-    bool isMoved = false;
-    bool aHasShift = (theEvent->modifiers() & Qt::ShiftModifier);
-
-    // the functionality to move the feature attribute if it exists in the internal map
-    std::map<FeaturePtr, std::list<std::string>>::iterator aFeatIter, aFeatLast;
-    if (aHasShift || myHighlightedFeature2Attribute.empty()) {
-      aFeatIter = myAllFeature2Attribute.begin();
-      aFeatLast = myAllFeature2Attribute.end();
-    }
-    else {
-      aFeatIter = myHighlightedFeature2Attribute.begin();
-      aFeatLast = myHighlightedFeature2Attribute.end();
-    }
-
-    while (aFeatIter != aFeatLast) {
-      FeaturePtr aFeature = aFeatIter->first;
-      // MPV: added condition because it could be external edge of some object, not sketch
-      if (aFeature && !sketch()->isSub(aFeature)) {
-        aFeatIter++;
-        continue;
-      }
-
-      std::list<std::string> anAttributes = aFeatIter->second;
-      // perform edit for the feature
-      if (anAttributes.empty()) {
-        std::shared_ptr<SketchPlugin_Feature> aSketchFeature =
-                                       std::dynamic_pointer_cast<SketchPlugin_Feature>(aFeature);
-        if (aSketchFeature) {
-          aSketchFeature->move(aDeltaX, aDeltaY);
-          isMoved = true;
-        }
-      }
-      // perform edit for the feature's attribute
-      else {
-        std::list<std::string>::const_iterator anAttrIter = anAttributes.begin(),
-                                               anAttrEnd = anAttributes.end();
-        for (; anAttrIter != anAttrEnd; anAttrIter++) {
-          std::shared_ptr<GeomDataAPI_Point2D> aPointAttr = std::dynamic_pointer_cast<
-                           GeomDataAPI_Point2D>(aFeature->data()->attribute(*anAttrIter));
-          if (aPointAttr) {
-            aPointAttr->move(aDeltaX, aDeltaY);
-            isMoved = true;
-          }
-        }      
-      }
-      aFeatIter++;
-    }
-    // the next code is commented because it is obsolete by the multi edit operation realization here
-    // the feature is moved only if there is no a local selection on this feature
-    //if (!isMoved) {
-    //  // MPV: added condition because it could be external edge of some object, not sketch
-    //  if (aSketchFeature && sketch()->isSub(aSketchFeature)) {
-    //   aSketchFeature->move(aDeltaX, aDeltaY);
-    //    static Events_ID anEvent = Events_Loop::eventByName(EVENT_OBJECT_TO_REDISPLAY);
-    //   ModelAPI_EventCreator::get()->sendUpdated(feature(), anEvent);
-    //  }
-    // }
-    //} // multieditoperation
-    sendFeatures(aHasShift);
-  }
-
-  myCurPoint.setPoint(aPoint);
-}
-
-void PartSet_OperationFeatureEdit::mouseReleased(
-    QMouseEvent* theEvent, ModuleBase_IViewer* theViewer,
-    ModuleBase_ISelection* theSelection)
-{
-  // the block is processed in order to do not commit the transaction until the started
-  // double click functionality is performed. It is reproduced on Linux only
-  if (myIsBlockedByDoubleClick)
-    return;
-
-  theViewer->enableSelection(true);
-  // the next code is commented because it is obsolete by the multi edit operation realization here
-  //if (myIsMultiOperation) {
-  //  if (commit()) {
-  //    std::map<FeaturePtr, std::list<std::string>>::iterator aFeatIter = myFeature2Attribute.begin();
-  //    while (aFeatIter != myFeature2Attribute.end()) {
-  //      FeaturePtr aFeature = aFeatIter->first;
-  //      if (aFeature) {
-  //        emit featureConstructed(aFeature, FM_Deactivation);
-  //      }
-  //      aFeatIter++;
-  //    }
-  //  }
-  //}
-  //else { // multieditoperation
-  ModuleBase_ModelWidget* aActiveWgt = 0;
-  if (myPropertyPanel)
-    aActiveWgt = myPropertyPanel->activeWidget();
-  if(aActiveWgt && aActiveWgt->isViewerSelector()) {
-    // Almost do nothing, all stuff in on PartSet_OperationFeatureBase::mouseReleased
-    PartSet_OperationFeatureBase::mouseReleased(theEvent, theViewer, theSelection);
-  //}// else {
-  ////blockSelection(false);
-  ////}
-  //} // multieditoperation
-  }
-  else {
-    theViewer->enableSelection(true);
-
-    // commit operation if there is no selected an highlighted objects anymore
-    Handle(V3d_View) aView = theViewer->activeView();
-    QList<ModuleBase_ViewerPrs> aSelected = theSelection->getSelected();
-    QList<ModuleBase_ViewerPrs> aHighlighted = theSelection->getHighlighted();
-
-    if (aSelected.empty() && aHighlighted.empty()) {
-      commit();
-      emitFeaturesDeactivation();
-    }
-    else if (aSelected.size() == 1) {
-     /// TODO: OCC bug: 25034 - the highlighted list should be filled not only for AIS_Shape
-     /// but for other IO, for example constraint dimensions.
-     /// It is empty and we have to use the process mouse release to start edition operation
-     /// for these objects
-      ObjectPtr anObject = aSelected.first().object();
-      FeaturePtr aFeature = ModelAPI_Feature::feature(anObject);
-      if (aFeature && PartSet_Tools::isConstraintFeature(aFeature->getKind()) &&
-          aFeature != feature()) {
-        restartOperation(PartSet_OperationFeatureEdit::Type(), aFeature);
-      }
-    }
-  }
-}
-
-void PartSet_OperationFeatureEdit::mouseDoubleClick(
-    QMouseEvent* theEvent, Handle_V3d_View theView,
-    ModuleBase_ISelection* theSelection)
-{
-  // TODO the functionality is important only for constraint feature. Should be moved in another place
-  QList<ModuleBase_ViewerPrs> aSelected = theSelection->getSelected();
-  // in case when the double click happens on another constraint feature when selection control is active
-  // we should not perform the double click functionality
-  // if there is no the viewer selector widget active, the operation is restarted with a correct feature
-  ModuleBase_ModelWidget* aActiveWgt = myPropertyPanel->activeWidget();
-  if(aActiveWgt && aActiveWgt->isViewerSelector()) {
-    if (!aSelected.empty()) {
-      if (aSelected.size() == 1) {
-       /// TODO: OCC bug: 25034 - the highlighted list should be filled not only for AIS_Shape
-       /// but for other IO, for example constraint dimensions.
-       /// It is empty and we have to use the process mouse release to start edition operation
-       /// for these objects
-        ObjectPtr anObject = aSelected.first().object();
-        FeaturePtr aFeature = ModelAPI_Feature::feature(anObject);
-        if (aFeature && PartSet_Tools::isConstraintFeature(aFeature->getKind()) &&
-            aFeature != feature()) {
-          return;
-        }
-      }
-    }
-  }
-
-  myIsBlockedByDoubleClick = true;
-  if (!aSelected.empty()) {
-    ModuleBase_ViewerPrs aFeaturePrs = aSelected.first();
-    if (!aFeaturePrs.owner().IsNull()) {
-      Handle(AIS_DimensionOwner) anOwner = Handle(AIS_DimensionOwner)::DownCast(
-          aFeaturePrs.owner());
-      if (!anOwner.IsNull() && anOwner->SelectionMode() == AIS_DSM_Text) {
-        bool isValid;
-        double aValue = PartSet_Tools::featureValue(feature(), SketchPlugin_Constraint::VALUE(),
-                                                    isValid);
-        if (isValid) {
-          ModuleBase_WidgetEditor::editFeatureValue(feature(), SketchPlugin_Constraint::VALUE());
-          flushUpdated();
-        }
-      }
-    }
-  }
-  myIsBlockedByDoubleClick  = false;
-}
-
-void PartSet_OperationFeatureEdit::startOperation()
-{
-  PartSet_OperationSketchBase::startOperation();
-  //emit multiSelectionEnabled(false);
-
-  myCurPoint.clear();
-}
-
-void PartSet_OperationFeatureEdit::stopOperation()
-{
-  //emit multiSelectionEnabled(true);
-
-  //blockSelection(false, false);
-
-  myHighlightedFeature2Attribute.clear();
-  myAllFeature2Attribute.clear();
-}
-
-//void PartSet_OperationFeatureEdit::blockSelection(bool isBlocked, const bool isRestoreSelection)
-//{
-//  if (myIsBlockedSelection == isBlocked)
-//    return;
-//
-//  myIsBlockedSelection = isBlocked;
-//  QList<ObjectPtr> aFeatureList;
-//  aFeatureList.append(feature());
-//
-//  //if (isBlocked) {
-//  //  emit setSelection(QList<ObjectPtr>());
-//  //  emit stopSelection(aFeatureList, true);
-//  //} else {
-//  //  emit stopSelection(aFeatureList, false);
-//  //  if (isRestoreSelection)
-//  //    emit setSelection(aFeatureList);
-//  //}
-//}
-
-FeaturePtr PartSet_OperationFeatureEdit::createFeature(const bool theFlushMessage,
-  CompositeFeaturePtr theCompositeFeature)
-{
-  // do nothing in order to do not create a new feature
-  return FeaturePtr();
-}
-
-void PartSet_OperationFeatureEdit::sendFeatures(const bool theIsAllFeatures)
-{
-  static Events_ID anEvent = Events_Loop::eventByName(EVENT_OBJECT_MOVED);
-
-  std::map<FeaturePtr, std::list<std::string>>::iterator aFeatIter, aFeatLast;
-  if (theIsAllFeatures || myHighlightedFeature2Attribute.empty()) {
-    aFeatIter = myAllFeature2Attribute.begin();
-    aFeatLast = myAllFeature2Attribute.end();
-  }
-  else {
-    aFeatIter = myHighlightedFeature2Attribute.begin();
-    aFeatLast = myHighlightedFeature2Attribute.end();
-  }
-  while (aFeatIter != aFeatLast) {
-    FeaturePtr aFeature = aFeatIter->first;
-    if (aFeature) {
-      ModelAPI_EventCreator::get()->sendUpdated(aFeature, anEvent);
-    }
-    aFeatIter++;
-  }
-
-  Events_Loop::loop()->flush(anEvent);
-  flushUpdated();
-}
-
-void PartSet_OperationFeatureEdit::emitFeaturesDeactivation()
-{
-  std::map<FeaturePtr, std::list<std::string>>::iterator aFeatIter = myAllFeature2Attribute.begin();
-  while (aFeatIter != myAllFeature2Attribute.end()) {
-    FeaturePtr aFeature = aFeatIter->first;
-    if (aFeature) {
-      emit featureConstructed(aFeature, FM_Deactivation);
-    }
-    aFeatIter++;
-  }
-}
-
diff --git a/src/PartSet/PartSet_OperationFeatureEdit.h b/src/PartSet/PartSet_OperationFeatureEdit.h
deleted file mode 100644 (file)
index 267b494..0000000
+++ /dev/null
@@ -1,156 +0,0 @@
-// File:        PartSet_OperationFeatureEdit.h
-// Created:     05 May 2014
-// Author:      Natalia ERMOLAEVA
-
-#ifndef PartSet_OperationFeatureEdit_H
-#define PartSet_OperationFeatureEdit_H
-
-#include "PartSet.h"
-
-#include <PartSet_OperationFeatureBase.h>
-#include <QObject>
-
-class QMouseEvent;
-class ModuleBase_ISelection;
-
-/*!
- \class PartSet_OperationFeatureEdit
- * \brief The operation for the sketch feature creation
- */
-class PARTSET_EXPORT PartSet_OperationFeatureEdit : public PartSet_OperationFeatureBase
-{
-Q_OBJECT
-  /// Struct to define gp point, with the state is the point is initialized
-  struct Point
-  {
-    /// Constructor
-    Point()
-    {
-      myIsInitialized = false;
-    }
-    /// Constructor
-    /// \param thePoint the point
-    Point(gp_Pnt thePoint)
-    {
-      setPoint(thePoint);
-    }
-    ~Point()
-    {
-    }
-
-    /// clear the initialized flag.
-    void clear()
-    {
-      myIsInitialized = false;
-    }
-    /// set the point and switch on the initialized flag
-    /// \param thePoint the point
-    void setPoint(const gp_Pnt& thePoint)
-    {
-      myIsInitialized = true;
-      myPoint = thePoint;
-    }
-
-    bool myIsInitialized;  /// the state whether the point is set
-    gp_Pnt myPoint;  /// the point
-  };
-
- public:
-  /// Returns the operation type key
-  static std::string Type()
-  {
-    return "EditLine";
-  }
-
- public:
-  /// Constructor
-  /// \param theId the feature identifier
-  /// \param theParent the operation parent
-  /// \param theFeature the parent feature
-  PartSet_OperationFeatureEdit(const QString& theId, QObject* theParent, CompositeFeaturePtr theFeature);
-  /// Destructor
-  virtual ~PartSet_OperationFeatureEdit();
-
-
-  /// Initialisation of operation with preliminary selection
-  /// \param theSelected the list of selected presentations
-  /// \param theHighlighted the list of highlighted presentations
-  /// \param theViewer a viewer to have the viewer the eye position
-  virtual void initSelection(ModuleBase_ISelection* theSelection,
-                             ModuleBase_IViewer* theViewer);
-
-  /// Processes the mouse pressed 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 mousePressed(QMouseEvent* theEvent, ModuleBase_IViewer* theViewer, ModuleBase_ISelection* theSelection);
-
-  /// Gives the current mouse point in the viewer
-  /// \param theEvent the mouse event
-  /// \param theView a viewer to have the viewer the eye position
-  virtual void mouseMoved(QMouseEvent* theEvent, ModuleBase_IViewer* theViewer);
-  /// Gives the current selected objects to be processed by the operation
-  /// \param thePoint a point clicked in the viewer
-  /// \param theEvent the mouse event
-  /// \param theSelected the list of selected presentations
-  /// \param theHighlighted the list of highlighted presentations
-  virtual void mouseReleased(QMouseEvent* theEvent, ModuleBase_IViewer* theViewer,
-                             ModuleBase_ISelection* theSelection);
-
-  /// Processes the mouse double click 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 mouseDoubleClick(QMouseEvent* theEvent, Handle_V3d_View theView,
-                                ModuleBase_ISelection* theSelection);
-
- protected:
-  /// \brief Virtual method called when operation is started
-  /// Virtual method called when operation started (see start() method for more description)
-  /// Switch off the multi selection state
-  virtual void startOperation();
-
-  /// Virtual method called when operation stopped - committed or aborted.
-  /// Restore the multi selection state
-  virtual void stopOperation();
-
-  /// Creates an operation new feature
-  /// Returns NULL feature. This is an operation of edition, not creation.
-  /// \param theFlushMessage the flag whether the create message should be flushed
-  /// \returns the created feature
-  virtual FeaturePtr createFeature(const bool theFlushMessage = true, 
-    CompositeFeaturePtr theCompositeFeature = CompositeFeaturePtr());
-
- protected:
-   void fillFeature2Attribute(const QList<ModuleBase_ViewerPrs>& thePresentations,
-                              ModuleBase_IViewer* theViewer,
-                              std::map<FeaturePtr, std::list<std::string> >& theFeature2Attribute);
-
-  /// Emits a signal about the selection blocking. Emits a signal to change the selection.
-  /// If the block is true, the signal clear selection, otherwise if restore selection flag allows,
-  /// the internal operation features are to be selected
-  /// \param isBlocked the state whether the operation is blocked or unblocked
-  /// \param isRestoreSelection the state whether the selected objects should be reselected
-  //void blockSelection(bool isBlocked, const bool isRestoreSelection = true);
-
-  /// Sends the features
-  /// \param theIsAllFeatures a boolean value whether all features should be send or only the highlighted ones
-  void sendFeatures(const bool theIsAllFeatures);
-
-  /// Sends signal about the current features are to be deactivated
-  void emitFeaturesDeactivation();
-
- private:
-  // the next map should be removed when selection is processed in the move function
-  std::map<FeaturePtr, std::list<std::string> > myHighlightedFeature2Attribute; /// a map of a feature to attributes
-  std::map<FeaturePtr, std::list<std::string> > myAllFeature2Attribute; /// a map of a feature to attributes
-
-  Point myCurPoint;  ///< the current 3D point clicked or moved
-  bool myIsBlockedSelection;  ///< the state of the last state of selection blocked signal
-  bool myIsBlockedByDoubleClick;  ///< the block value by double click is processed to avoid
-  ///< the mouse button release processing before the double click is finished
-};
-
-#endif
diff --git a/src/PartSet/PartSet_OperationSketch.cpp b/src/PartSet/PartSet_OperationSketch.cpp
deleted file mode 100644 (file)
index 5d9454d..0000000
+++ /dev/null
@@ -1,292 +0,0 @@
-// File:        PartSet_OperationSketch.h
-// Created:     20 Apr 2014
-// Author:      Natalia ERMOLAEVA
-
-#include <PartSet_OperationSketch.h>
-
-#include <PartSet_OperationFeatureEdit.h>
-#include <PartSet_Tools.h>
-
-#include <SketchPlugin_Sketch.h>
-#include <SketchPlugin_ConstraintLength.h>
-
-#include <ModelAPI_Data.h>
-#include <ModelAPI_AttributeDouble.h>
-#include <ModelAPI_AttributeRefList.h>
-#include <ModelAPI_Events.h>
-
-#include <GeomAlgoAPI_FaceBuilder.h>
-#include <GeomDataAPI_Point.h>
-#include <GeomDataAPI_Dir.h>
-#include <GeomAPI_XYZ.h>
-
-#include <ModuleBase_ViewerPrs.h>
-#include <ModuleBase_ISelection.h>
-#include <ModuleBase_IViewer.h>
-#include <Events_Loop.h>
-
-#include <AIS_Shape.hxx>
-#include <AIS_ListOfInteractive.hxx>
-#include <AIS_InteractiveObject.hxx>
-#include <AIS_DimensionOwner.hxx>
-#include <AIS_LengthDimension.hxx>
-#include <V3d_View.hxx>
-
-#ifdef _DEBUG
-#include <QDebug>
-#endif
-
-#include <QMouseEvent>
-
-using namespace std;
-
-PartSet_OperationSketch::PartSet_OperationSketch(const QString& theId, QObject* theParent)
-    : PartSet_OperationSketchBase(theId, theParent)
-{
-}
-
-PartSet_OperationSketch::~PartSet_OperationSketch()
-{
-}
-
-CompositeFeaturePtr PartSet_OperationSketch::sketch() const
-{
-  return std::dynamic_pointer_cast<ModelAPI_CompositeFeature>(feature());
-}
-
-void PartSet_OperationSketch::mousePressed(QMouseEvent* theEvent, ModuleBase_IViewer* theViewer, ModuleBase_ISelection* theSelection)
-{
-  if (hasSketchPlane()) {
-    // if shift button is pressed and there are some already selected objects, the operation should
-    // not be started. We just want to combine some selected objects.
-    bool aHasShift = (theEvent->modifiers() & Qt::ShiftModifier);
-    QList<ModuleBase_ViewerPrs> aSelected = theSelection->getSelected();
-    QList<ModuleBase_ViewerPrs> aHighlighted = theSelection->getHighlighted();
-    // commented: the next code is commented because the nearestFeature check the highlighting
-    // and selection inside
-    //if (aHasShift && (aSelected.size() > 0)) {
-    //  foreach(ModuleBase_ViewerPrs aPrs, aHighlighted)
-    //    aSelected.append(aPrs);
-    //}
-    //if (aHasShift && aSelected.size() > 0)
-    //  return;
-
-    // there should be a start of operation, which uses the pre-highlighted objects,
-    // the selected ones are collected here and are processed by a mouse move
-    //if (aHighlighted.size() == 1) {
-    //if (aSelected.size() > 0) {
-    //  ObjectPtr aFeature = aSelected.first().object();
-    //  if (aFeature) {
-    // commented: end
-        Handle(V3d_View) aView = theViewer->activeView();
-        ObjectPtr aFeature = PartSet_Tools::nearestFeature(theEvent->pos(), aView, feature(),
-                                                           aSelected, aHighlighted);
-        if (aFeature)
-          restartOperation(PartSet_OperationFeatureEdit::Type(), aFeature);
-      //}
-    //}
-    //else
-    //  myFeatures = aHighlighted;
-    //else
-    //myFeatures = aSelected;
-  } 
-}
-
-
-void PartSet_OperationSketch::selectionChanged(ModuleBase_ISelection* theSelection)
-{
-  if (hasSketchPlane()) 
-    return;
-
-  QList<ModuleBase_ViewerPrs> aSelected = theSelection->getSelected();
-  if (!aSelected.empty()) {
-    ModuleBase_ViewerPrs aPrs = aSelected.first();
-    // We have to select a plane before any operation
-    TopoDS_Shape aShape = aPrs.shape();
-    if (!aShape.IsNull()) {
-      std::shared_ptr<GeomAPI_Dir> aDir = setSketchPlane(aShape);
-      flushUpdated();
-      emit featureConstructed(feature(), FM_Hide);
-      // If selection is not a sketcher presentation then it has to be stored as 
-      // External shape
-      if (feature() != aPrs.object()) {
-        //std::shared_ptr<SketchPlugin_Sketch> aSketch = 
-        //  std::dynamic_pointer_cast<SketchPlugin_Sketch>(feature());
-        DataPtr aData = feature()->data();
-        AttributeSelectionPtr aSelAttr = 
-          std::dynamic_pointer_cast<ModelAPI_AttributeSelection>
-          (aData->attribute(SketchPlugin_Feature::EXTERNAL_ID()));
-        if (aSelAttr) {
-          ResultPtr aRes = std::dynamic_pointer_cast<ModelAPI_Result>(aPrs.object());
-          if (aRes) {
-            GeomShapePtr aShapePtr(new GeomAPI_Shape());
-            aShapePtr->setImpl(new TopoDS_Shape(aShape));
-            aSelAttr->setValue(aRes, aShapePtr);
-          }
-        }
-      } else {
-        // Turn viewer to the plane
-        emit planeSelected(aDir->x(), aDir->y(), aDir->z());
-      }
-      emit updatePropPanel();
-      emit launchSketch();
-    }
-  }
-}
-
-
-void PartSet_OperationSketch::mouseReleased(QMouseEvent* theEvent, ModuleBase_IViewer* theViewer,
-                                            ModuleBase_ISelection* theSelection)
-{
-  QList<ModuleBase_ViewerPrs> aSelected = theSelection->getSelected();
-  if (hasSketchPlane()) {
-    /// TODO: OCC bug: 25034 - the highlighted list should be filled not only for AIS_Shape
-    /// but for other IO, for example constraint dimensions.
-    /// It is empty and we have to use the process mouse release to start edition operation
-    /// for these objects
-    if (aSelected.size() == 1) {
-      ObjectPtr aObject = aSelected.first().object();
-      if (aObject) {
-        restartOperation(PartSet_OperationFeatureEdit::Type(), aObject);
-      }
-    }
-  }
-}
-
-void PartSet_OperationSketch::mouseMoved(QMouseEvent* theEvent, ModuleBase_IViewer* theViewer)
-{
-  if (!hasSketchPlane() || !(theEvent->buttons() & Qt::LeftButton) || myFeatures.empty())
-    return;
-
-  // myFeatures are not filled in the previous realization, so, this code is just commented
-  // because has no effect
-  /*if (myFeatures.size() != 1) {
-    Handle(V3d_View) aView = theViewer->activeView();
-    ObjectPtr aFeature = PartSet_Tools::nearestFeature(theEvent->pos(), aView, feature(),
-                                                       myFeatures);
-    if (aFeature)
-      restartOperation(PartSet_OperationFeatureEdit::Type(), aFeature);
-  }*/
-}
-
-std::list<FeaturePtr> PartSet_OperationSketch::subFeatures() const
-{
-  std::list<FeaturePtr> aFeaList;
-  FeaturePtr aFeature = feature();
-  if (!aFeature)
-    return aFeaList;
-
-  std::shared_ptr<ModelAPI_Data> aData = aFeature->data();
-  if (!aData->isValid())
-    return std::list<FeaturePtr>();
-  std::shared_ptr<ModelAPI_AttributeRefList> aRefList = std::dynamic_pointer_cast<
-      ModelAPI_AttributeRefList>(aData->attribute(SketchPlugin_Sketch::FEATURES_ID()));
-
-  std::list<ObjectPtr> aList = aRefList->list();
-  std::list<ObjectPtr>::iterator aIt;
-  for (aIt = aList.begin(); aIt != aList.end(); ++aIt) {
-    FeaturePtr aFeature = std::dynamic_pointer_cast<ModelAPI_Feature>(*aIt);
-    if (aFeature)
-      aFeaList.push_back(aFeature);
-  }
-  return aFeaList;
-}
-
-void PartSet_OperationSketch::stopOperation()
-{
-  PartSet_OperationSketchBase::stopOperation();
-  emit featureConstructed(feature(), FM_Hide);
-}
-
-void PartSet_OperationSketch::afterCommitOperation()
-{
-  FeaturePtr aFeature = feature();
-  std::list<ResultPtr> aResults = aFeature->results();
-  std::list<ResultPtr>::const_iterator aIt;
-  Events_ID anEvent = Events_Loop::loop()->eventByName(EVENT_OBJECT_TOSHOW);
-  for (aIt = aResults.cbegin(); aIt != aResults.cend(); ++aIt) {
-    ModelAPI_EventCreator::get()->sendUpdated(*aIt, anEvent);
-  }
-  Events_Loop::loop()->flush(anEvent);
-}
-
-bool PartSet_OperationSketch::isNestedOperationsEnabled() const
-{
-  return hasSketchPlane();
-}
-
-void PartSet_OperationSketch::startOperation()
-{
-  PartSet_OperationSketchBase::startOperation();
-  if (!isEditOperation())
-    emit fitAllView();
-}
-
-bool PartSet_OperationSketch::hasSketchPlane() const
-{
-  bool aHasPlane = false;
-
-  if (feature()) {
-    std::shared_ptr<ModelAPI_Data> aData = feature()->data();
-    AttributeDoublePtr anAttr;
-    std::shared_ptr<GeomDataAPI_Dir> aNormal = std::dynamic_pointer_cast<GeomDataAPI_Dir>(
-        aData->attribute(SketchPlugin_Sketch::NORM_ID()));
-    aHasPlane = aNormal && !(aNormal->x() == 0 && aNormal->y() == 0 && aNormal->z() == 0);
-  }
-  return aHasPlane;
-}
-
-std::shared_ptr<GeomAPI_Dir> PartSet_OperationSketch::setSketchPlane(const TopoDS_Shape& theShape)
-{
-  if (theShape.IsNull())
-    return std::shared_ptr<GeomAPI_Dir>();
-
-  // get selected shape
-  std::shared_ptr<GeomAPI_Shape> aGShape(new GeomAPI_Shape);
-  aGShape->setImpl(new TopoDS_Shape(theShape));
-
-  // get plane parameters
-  std::shared_ptr<GeomAPI_Pln> aPlane = GeomAlgoAPI_FaceBuilder::plane(aGShape);
-
-  // set plane parameters to feature
-  std::shared_ptr<ModelAPI_Data> aData = feature()->data();
-  double anA, aB, aC, aD;
-  aPlane->coefficients(anA, aB, aC, aD);
-
-  // calculate attributes of the sketch
-  std::shared_ptr<GeomAPI_Dir> aNormDir(new GeomAPI_Dir(anA, aB, aC));
-  std::shared_ptr<GeomAPI_XYZ> aCoords = aNormDir->xyz();
-  std::shared_ptr<GeomAPI_XYZ> aZero(new GeomAPI_XYZ(0, 0, 0));
-  aCoords = aCoords->multiplied(-aD * aCoords->distance(aZero));
-  std::shared_ptr<GeomAPI_Pnt> anOrigPnt(new GeomAPI_Pnt(aCoords));
-  // X axis is preferable to be dirX on the sketch
-  const double tol = Precision::Confusion();
-  bool isX = fabs(anA - 1.0) < tol && fabs(aB) < tol && fabs(aC) < tol;
-  std::shared_ptr<GeomAPI_Dir> aTempDir(
-      isX ? new GeomAPI_Dir(0, 1, 0) : new GeomAPI_Dir(1, 0, 0));
-  std::shared_ptr<GeomAPI_Dir> aYDir(new GeomAPI_Dir(aNormDir->cross(aTempDir)));
-  std::shared_ptr<GeomAPI_Dir> aXDir(new GeomAPI_Dir(aYDir->cross(aNormDir)));
-
-  std::shared_ptr<GeomDataAPI_Point> anOrigin = std::dynamic_pointer_cast<GeomDataAPI_Point>(
-      aData->attribute(SketchPlugin_Sketch::ORIGIN_ID()));
-  anOrigin->setValue(anOrigPnt);
-  std::shared_ptr<GeomDataAPI_Dir> aNormal = std::dynamic_pointer_cast<GeomDataAPI_Dir>(
-      aData->attribute(SketchPlugin_Sketch::NORM_ID()));
-  aNormal->setValue(aNormDir);
-  std::shared_ptr<GeomDataAPI_Dir> aDirX = std::dynamic_pointer_cast<GeomDataAPI_Dir>(
-      aData->attribute(SketchPlugin_Sketch::DIRX_ID()));
-  aDirX->setValue(aXDir);
-  std::shared_ptr<GeomDataAPI_Dir> aDirY = std::dynamic_pointer_cast<GeomDataAPI_Dir>(
-      aData->attribute(SketchPlugin_Sketch::DIRY_ID()));
-  aDirY->setValue(aYDir);
-  std::shared_ptr<GeomAPI_Dir> aDir = aPlane->direction();
-  return aDir;
-}
-
-
-bool PartSet_OperationSketch::isGranted(ModuleBase_Operation* theOperation) const
-{
-  PartSet_OperationSketchBase* aPreviewOp = dynamic_cast<PartSet_OperationSketchBase*>(theOperation);
-  return aPreviewOp != NULL;
-}
-
diff --git a/src/PartSet/PartSet_OperationSketch.h b/src/PartSet/PartSet_OperationSketch.h
deleted file mode 100644 (file)
index 1a770e1..0000000
+++ /dev/null
@@ -1,126 +0,0 @@
-// File:        PartSet_OperationSketch.h
-// Created:     20 Apr 2014
-// Author:      Natalia ERMOLAEVA
-
-#ifndef PartSet_OperationSketch_H
-#define PartSet_OperationSketch_H
-
-#include "PartSet.h"
-
-#include <PartSet_OperationSketchBase.h>
-
-#include <SketchPlugin_Sketch.h>
-
-#include <QObject>
-#include <QList>
-
-class Handle_AIS_InteractiveObject;
-
-/*!
- \class PartSet_OperationSketch
- * \brief The operation for the sketch feature creation
- */
-class PARTSET_EXPORT PartSet_OperationSketch : public PartSet_OperationSketchBase
-{
-Q_OBJECT
- public:
-  /// Returns the operation type key
-  static std::string Type()
-  {
-    return SketchPlugin_Sketch::ID();
-  }
-
- public:
-  /// Constructor
-  /// \param theId the feature identifier
-  /// \param theParent the operation parent
-  PartSet_OperationSketch(const QString& theId, QObject* theParent);
-  /// Destructor
-  virtual ~PartSet_OperationSketch();
-
-  /// Returns True if the given operation is a Sketcher operation
-  virtual bool isGranted(ModuleBase_Operation* theOperation) const;
-
-
-  /// Returns the operation sketch feature
-  /// \returns the sketch instance
-  virtual CompositeFeaturePtr sketch() const;
-
-  /// Processes the mouse pressed 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 mousePressed(QMouseEvent* theEvent, ModuleBase_IViewer* theViewer, ModuleBase_ISelection* theSelection);
-
-  /// 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, ModuleBase_IViewer* theViewer,
-                             ModuleBase_ISelection* theSelection);
-
-  /// Gives the current mouse point in the viewer
-  /// \param thePoint a point clicked in the viewer
-  /// \param theEvent the mouse event
-  virtual void mouseMoved(QMouseEvent* theEvent, ModuleBase_IViewer* theViewer);
-
-  /// Returns the list of the nested features
-  /// \return the list of subfeatures
-  virtual std::list<FeaturePtr> subFeatures() const;
-
-  /// Virtual method called when operation stopped - committed or aborted.
-  /// Emits a signal to hide the preview of the operation
-  virtual void stopOperation();
-
-  /// Returns whether the nested operations are enabled.
-  /// The state can depend on the operation current state.
-  /// It returns true after the sketch plane is choosen.
-  /// \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;
-
-  /// Set the plane to the current sketch
-  /// \param theShape the shape
-  /// \return selected direction
-  std::shared_ptr<GeomAPI_Dir> setSketchPlane(const TopoDS_Shape& theShape);
-  
-  /// Called on selection changed when the operation is active
-  virtual void selectionChanged(ModuleBase_ISelection* theSelection);
-
-  /// If operation needs to redisplay its result during operation
-  /// then this method has to return True
-  virtual bool hasPreview() const { return false; }
-
-signals:
-  /// signal about the sketch plane is selected
-  /// \param theX the value in the X direction of the plane
-  /// \param theX the value in the Y direction value of the plane
-  /// \param theX the value in the Z direction of the plane
-  void planeSelected(double theX, double theY, double theZ);
-  // signal about the viewer fit all perform
-  void fitAllView();
-
-  /// Signal to define sketch mode
-  void launchSketch();
-
-  /// Signal to update property panel
-  void updatePropPanel();
-
- protected:
-  /// Virtual method called when operation started (see start() method for more description)
-  /// Default impl calls corresponding slot and commits immediately.
-  virtual void startOperation();
-
-  /// Virtual method called after operation committed (see commit() method for more description)
-  virtual void afterCommitOperation();
-
- private:
-  QList<ModuleBase_ViewerPrs> myFeatures;  ///< the features to apply the edit operation
-};
-
-#endif
diff --git a/src/PartSet/PartSet_OperationSketchBase.cpp b/src/PartSet/PartSet_OperationSketchBase.cpp
deleted file mode 100644 (file)
index 310658e..0000000
+++ /dev/null
@@ -1,98 +0,0 @@
-// File:        PartSet_OperationSketchBase.cpp
-// Created:     20 Apr 2014
-// Author:      Natalia ERMOLAEVA
-
-#include <PartSet_OperationSketchBase.h>
-#include <PartSet_Tools.h>
-#include <ModelAPI_ResultBody.h>
-
-#include <ModuleBase_IPropertyPanel.h>
-#include <ModuleBase_IViewer.h>
-#include <ModuleBase_ModelWidget.h>
-#include <ModuleBase_WidgetValueFeature.h>
-
-#include <SketchPlugin_Feature.h>
-#include <V3d_View.hxx>
-#include <AIS_Shape.hxx>
-#include <AIS_DimensionSelectionMode.hxx>
-
-#include <QKeyEvent>
-#include <QMessageBox>
-#include <QApplication>
-
-#ifdef _DEBUG
-#include <QDebug>
-#endif
-
-using namespace std;
-
-PartSet_OperationSketchBase::PartSet_OperationSketchBase(const QString& theId, QObject* theParent)
-    : ModuleBase_Operation(theId, theParent)
-{
-}
-
-PartSet_OperationSketchBase::~PartSet_OperationSketchBase()
-{
-}
-
-std::shared_ptr<GeomAPI_Shape> PartSet_OperationSketchBase::preview(FeaturePtr theFeature)
-{
-  std::shared_ptr<SketchPlugin_Feature> aFeature = std::dynamic_pointer_cast<
-      SketchPlugin_Feature>(theFeature);
-  if (aFeature) {
-    ResultPtr aRes = aFeature->firstResult();
-    ResultBodyPtr aBody = std::dynamic_pointer_cast<ModelAPI_ResultBody>(aRes);
-    if (aBody)
-      return aBody->shape();
-  }
-  return std::shared_ptr<GeomAPI_Shape>();
-}
-
-std::list<FeaturePtr> PartSet_OperationSketchBase::subFeatures() const
-{
-  return std::list<FeaturePtr>();
-}
-
-FeaturePtr PartSet_OperationSketchBase::createFeature(const bool theFlushMessage)
-{
-  ModuleBase_Operation::createFeature(theFlushMessage);
-  if (myFeature)
-    emit featureConstructed(myFeature, FM_Activation);
-  return myFeature;
-}
-
-void PartSet_OperationSketchBase::mousePressed(QMouseEvent* theEvent, ModuleBase_IViewer* theViewer, ModuleBase_ISelection* theSelection)
-{
-}
-void PartSet_OperationSketchBase::mouseReleased(
-    QMouseEvent* theEvent, ModuleBase_IViewer* theViewer,
-    ModuleBase_ISelection* theSelection)
-{
-}
-void PartSet_OperationSketchBase::mouseMoved(QMouseEvent* theEvent, ModuleBase_IViewer* theViewer)
-{
-}
-void PartSet_OperationSketchBase::mouseDoubleClick(
-    QMouseEvent* theEvent, Handle_V3d_View theView,
-    ModuleBase_ISelection* theSelection)
-{
-}
-
-void PartSet_OperationSketchBase::selectionChanged(ModuleBase_ISelection* theSelection)
-{
-}
-
-void PartSet_OperationSketchBase::restartOperation(const std::string& theType, ObjectPtr theFeature)
-{
-  FeaturePtr aFeature = ModelAPI_Feature::feature(theFeature);
-  if (aFeature) {
-    QStringList aNested = this->nestedFeatures();
-    if (!aNested.isEmpty()) {
-      if (!aNested.contains(QString(aFeature->getKind().c_str())))
-        return;
-    }
-  }
-  emit restartRequired(theType, theFeature);
-}
-
-
diff --git a/src/PartSet/PartSet_OperationSketchBase.h b/src/PartSet/PartSet_OperationSketchBase.h
deleted file mode 100644 (file)
index dacfb8f..0000000
+++ /dev/null
@@ -1,148 +0,0 @@
-// File:        PartSet_OperationSketchBase.h
-// Created:     20 Apr 2014
-// Author:      Natalia ERMOLAEVA
-
-#ifndef PartSet_OperationSketchBase_H
-#define PartSet_OperationSketchBase_H
-
-#include "PartSet.h"
-
-#include <TopoDS_Shape.hxx>
-#include <gp_Pnt.hxx>
-#include <NCollection_List.hxx>
-
-#include <ModuleBase_Operation.h>
-#include <ModuleBase_Operation.h>
-
-#include <XGUI_Constants.h>
-#include <XGUI_Displayer.h>
-
-#include <QObject>
-
-#include <AIS_InteractiveObject.hxx>
-
-#include <map>
-
-class Handle_V3d_View;
-class QMouseEvent;
-class GeomAPI_Shape;
-class ModuleBase_ViewerPrs;
-class ModuleBase_ISelection;
-class ModuleBase_IViewer;
-
-/*!
- \class PartSet_OperationSketchBase
- * \brief The base operation for the sketch features.
- *  Base class for all sketch operations. It provides an access to the feature preview
- */
-class PARTSET_EXPORT PartSet_OperationSketchBase : public ModuleBase_Operation
-{
-Q_OBJECT
- public:
-  enum FeatureActionMode
-  {
-    FM_Activation,
-    FM_Deactivation,
-    FM_Hide
-  };
-
- public:
-  /// Constructor
-  /// \param theId an feature index
-  /// \param theParent the object parent
-  PartSet_OperationSketchBase(const QString& theId, QObject* theParent);
-  /// Destructor
-  virtual ~PartSet_OperationSketchBase();
-
-  /// Returns the feature preview shape
-  /// \param theFeature the feature object to obtain the preview
-  static std::shared_ptr<GeomAPI_Shape> preview(FeaturePtr theFeature);
-
-  /// Returns the list of the nested features
-  /// \return the list of subfeatures
-  virtual std::list<FeaturePtr> subFeatures() const;
-
-  /// Returns the operation sketch feature
-  /// \returns the sketch instance
-  virtual CompositeFeaturePtr sketch() const = 0;
-
-  /// Processes the mouse pressed 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 mousePressed(QMouseEvent* theEvent, ModuleBase_IViewer* theViewer, ModuleBase_ISelection* theSelection);
-
-  /// 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, ModuleBase_IViewer* theViewer,
-                             ModuleBase_ISelection* theSelection);
-
-  /// Processes the mouse move in the point
-  /// \param theEvent the mouse event
-  /// \param theView a viewer to have the viewer the eye position
-  virtual void mouseMoved(QMouseEvent* theEvent, ModuleBase_IViewer* theViewer);
-
-  /// Processes the mouse double click 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 mouseDoubleClick(QMouseEvent* theEvent, Handle_V3d_View theView,
-                                ModuleBase_ISelection* theSelection);
-
-  
-  /// Called on selection changed when the operation is active
-  virtual void selectionChanged(ModuleBase_ISelection* theSelection);
-
-  /// Emits a signal about the operation start. This signal has an information about the feature.
-  /// If the provided feature is empty, the current operation feature is used.
-  /// \param theType a type of an operation started
-  /// theFeature the operation argument
-  void restartOperation(const std::string& theType, ObjectPtr theFeature = ObjectPtr());
-
-  /// If operation needs to redisplay its result during operation
-  /// then this method has to return True
-  virtual bool hasPreview() const { return true; }
-
-signals:
-  /// signal about the request to launch operation
-  /// theName the operation name
-  /// theFeature the operation argument
-  void restartRequired(std::string theName, ObjectPtr theFeature);
-
-  /// Signal about the feature construing is finished
-  /// \param theFeature the result feature
-  /// \param theMode the mode of the feature modification
-  void featureConstructed(ObjectPtr theFeature, int theMode);
-
-  /// Signal about the features should be selected
-  /// \param theSelected the list of selected presentations
-  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);
-
-  /// signal to enable/disable selection in the viewer
-  /// \param theFeatures a list of features to be disabled
-  /// \param theToStop the boolean state whether it it stopped or non stopped
-  void stopSelection(const QList<ObjectPtr>& theFeatures, const bool theToStop);
-
-  /// signal to set selection in the viewer
-  /// \param theFeatures a list of features to be disabled
-  void setSelection(const QList<ObjectPtr>& theFeatures);
-
- protected:
-  /// Creates an operation new feature
-  /// In addition to the default realization it appends the created line feature to
-  /// the sketch feature
-  /// \param theFlushMessage the flag whether the create message should be flushed
-  /// \returns the created feature
-  virtual FeaturePtr createFeature(const bool theFlushMessage = true);
-};
-
-#endif
index 29c5829a037ff570a181571710499251ddc27286..57a1529a6f96f1184930840fe7d2bcb666a6b560 100644 (file)
@@ -1,3 +1,5 @@
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
 // File:        PartSet_TestOCC.h
 // Created:     28 Apr 2014
 // Author:      Natalia ERMOLAEVA
@@ -9,7 +11,6 @@
 #include <XGUI_Displayer.h>
 #include <XGUI_ViewerProxy.h>
 #include <PartSet_Tools.h>
-#include <PartSet_OperationSketchBase.h>
 
 #include <ModuleBase_ViewerPrs.h>
 #include <ModelAPI_Feature.h>
index 757b344cd39435a25b33965569ffd913dfa7e13a..0b656eacaa9e14eb844b7651a36450d64b7f9bf4 100644 (file)
@@ -1,3 +1,5 @@
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
 // File:        PartSet_TestOCC.h
 // Created:     28 Apr 2014
 // Author:      Natalia ERMOLAEVA
index c97b6c68f2b55fd192de55fdc44544f80539c36f..78df67edb61f3a0f9a98e7400a2e967329eb67e8 100644 (file)
@@ -1,3 +1,5 @@
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
 // File:        PartSet_Tools.h
 // Created:     28 Apr 2014
 // Author:      Natalia ERMOLAEVA
@@ -18,6 +20,7 @@
 #include <GeomAPI_Pnt2d.h>
 #include <GeomAPI_Pnt.h>
 #include <GeomAPI_Edge.h>
+#include <GeomAPI_Vertex.h>
 
 #include <GeomAPI_Dir.h>
 #include <GeomAPI_XYZ.h>
@@ -33,6 +36,7 @@
 #include <SketchPlugin_Circle.h>
 #include <SketchPlugin_Arc.h>
 #include <SketchPlugin_Line.h>
+#include <SketchPlugin_Point.h>
 
 #include <ModuleBase_ViewerPrs.h>
 
@@ -126,12 +130,8 @@ Handle(V3d_View) theView,
   theY = aVec.X() * anY->x() + aVec.Y() * anY->y() + aVec.Z() * anY->z();
 }
 
-void PartSet_Tools::convertTo3D(const double theX, const double theY, FeaturePtr theSketch,
-                                gp_Pnt& thePoint)
+std::shared_ptr<GeomAPI_Pnt> PartSet_Tools::convertTo3D(const double theX, const double theY, FeaturePtr theSketch)
 {
-  if (!theSketch)
-    return;
-
   std::shared_ptr<ModelAPI_Data> aData = theSketch->data();
 
   std::shared_ptr<GeomDataAPI_Point> aC = std::dynamic_pointer_cast<GeomDataAPI_Point>(
@@ -141,11 +141,10 @@ void PartSet_Tools::convertTo3D(const double theX, const double theY, FeaturePtr
   std::shared_ptr<GeomDataAPI_Dir> aY = std::dynamic_pointer_cast<GeomDataAPI_Dir>(
       aData->attribute(SketchPlugin_Sketch::DIRY_ID()));
 
-  std::shared_ptr<GeomAPI_XYZ> aSum = aC->pnt()->xyz()->added(aX->dir()->xyz()->multiplied(theX))
-      ->added(aY->dir()->xyz()->multiplied(theY));
+  std::shared_ptr<GeomAPI_Pnt2d> aPnt2d = 
+    std::shared_ptr<GeomAPI_Pnt2d>(new GeomAPI_Pnt2d(theX, theY));
 
-  std::shared_ptr<GeomAPI_Pnt> aPoint = std::shared_ptr<GeomAPI_Pnt>(new GeomAPI_Pnt(aSum));
-  thePoint = gp_Pnt(aPoint->x(), aPoint->y(), aPoint->z());
+  return aPnt2d->to3D(aC->pnt(), aX->dir(), aY->dir());
 }
 
 ObjectPtr PartSet_Tools::nearestFeature(QPoint thePoint, Handle_V3d_View theView,
@@ -352,19 +351,27 @@ void PartSet_Tools::setConstraints(CompositeFeaturePtr theSketch, FeaturePtr the
 std::shared_ptr<GeomAPI_Pln> PartSet_Tools::sketchPlane(CompositeFeaturePtr theSketch)
 {
   std::shared_ptr<GeomAPI_Pln> aPlane;
-  double aA, aB, aC, aD;
 
   std::shared_ptr<ModelAPI_Data> aData = theSketch->data();
   std::shared_ptr<GeomDataAPI_Point> anOrigin = std::dynamic_pointer_cast<GeomDataAPI_Point>(
       aData->attribute(SketchPlugin_Sketch::ORIGIN_ID()));
   std::shared_ptr<GeomDataAPI_Dir> aNormal = std::dynamic_pointer_cast<GeomDataAPI_Dir>(
       aData->attribute(SketchPlugin_Sketch::NORM_ID()));
-  aA = aNormal->x();
-  aB = aNormal->y();
-  aC = aNormal->z();
-  aD = 0;
-
-  aPlane = std::shared_ptr<GeomAPI_Pln>(new GeomAPI_Pln(aA, aB, aC, aD));
+  if (aNormal && anOrigin) {
+    double adX = aNormal->x();
+    double adY = aNormal->y();
+    double adZ = aNormal->z();
+
+    if ( (adX != 0) || (adY != 0) || (adZ != 0) ) { // Plane is valid
+      double aX = anOrigin->x();
+      double aY = anOrigin->y();
+      double aZ = anOrigin->z();
+      gp_Pln aPln(gp_Pnt(aX, aY, aZ), gp_Dir(adX, adY, adZ));
+      double aA, aB, aC, aD;
+      aPln.Coefficients(aA, aB, aC, aD);
+      aPlane = std::shared_ptr<GeomAPI_Pln>(new GeomAPI_Pln(aA, aB, aC, aD));
+    }
+  }
   return aPlane;
 }
 
@@ -393,79 +400,91 @@ bool PartSet_Tools::isConstraintFeature(const std::string& theKind)
       || theKind == SketchPlugin_ConstraintRigid::ID();
 }
 
-ResultPtr PartSet_Tools::createFixedObjectByEdge(const ModuleBase_ViewerPrs& thePrs, CompositeFeaturePtr theSketch)
+ResultPtr PartSet_Tools::createFixedObjectByEdge(const TopoDS_Shape& theShape, 
+                                                 const ObjectPtr& theObject, 
+                                                 CompositeFeaturePtr theSketch)
 {
-  TopoDS_Shape aShape = thePrs.shape();
-  if (aShape.ShapeType() != TopAbs_EDGE)
-    return ResultPtr();
-
-  // Check that we already have such external edge
-  std::shared_ptr<GeomAPI_Edge> aInEdge = std::shared_ptr<GeomAPI_Edge>(new GeomAPI_Edge());
-  aInEdge->setImpl(new TopoDS_Shape(aShape));
-  ResultPtr aResult = findExternalEdge(theSketch, aInEdge);
-  if (aResult)
-    return aResult;
-
-  // If not found then we have to create new
-  Standard_Real aStart, aEnd;
-  Handle(V3d_View) aNullView;
-  FeaturePtr aMyFeature;
-
-  Handle(Geom_Curve) aCurve = BRep_Tool::Curve(TopoDS::Edge(aShape), aStart, aEnd);
-  GeomAdaptor_Curve aAdaptor(aCurve);
-  if (aAdaptor.GetType() == GeomAbs_Line) {
-    // Create line
-    aMyFeature = theSketch->addFeature(SketchPlugin_Line::ID());
-
-    //DataPtr aData = myFeature->data();
-    //std::shared_ptr<GeomDataAPI_Point2D> anEndAttr = 
-    //  std::dynamic_pointer_cast<GeomDataAPI_Point2D>(aData->attribute(SketchPlugin_Line::END_ID()));
-
-    //double aX, aY;
-    //gp_Pnt Pnt1 = aAdaptor.Value(aStart);
-    //convertTo2D(Pnt1, theSketch, aNullView, aX, aY);
-    //setFeaturePoint(myFeature, aX, aY, SketchPlugin_Line::START_ID());
-
-    //gp_Pnt Pnt2 = aAdaptor.Value(aEnd);
-    //convertTo2D(Pnt2, theSketch, aNullView, aX, aY);
-    //setFeaturePoint(myFeature, aX, aY, SketchPlugin_Line::END_ID());
-  } else if (aAdaptor.GetType() == GeomAbs_Circle) {
-    if (aAdaptor.IsClosed()) {
-      // Create circle
-      aMyFeature = theSketch->addFeature(SketchPlugin_Circle::ID());
-      //gp_Circ aCirc = aAdaptor.Circle();
-      //gp_Pnt aCenter = aCirc.Location();
-
-      //double aX, aY;
-      //convertTo2D(aCenter, theSketch, aNullView, aX, aY);
-      //setFeaturePoint(myFeature, aX, aY, SketchPlugin_Circle::CENTER_ID());
-      //setFeatureValue(myFeature, aCirc.Radius(), SketchPlugin_Circle::RADIUS_ID());
-    } else {
-      // Create arc
-      aMyFeature = theSketch->addFeature(SketchPlugin_Arc::ID());
+  if (theShape.ShapeType() == TopAbs_EDGE) {
+    // Check that we already have such external edge
+    std::shared_ptr<GeomAPI_Edge> aInEdge = std::shared_ptr<GeomAPI_Edge>(new GeomAPI_Edge());
+    aInEdge->setImpl(new TopoDS_Shape(theShape));
+    ResultPtr aResult = findExternalEdge(theSketch, aInEdge);
+    if (aResult)
+      return aResult;
+
+    // If not found then we have to create new
+    Standard_Real aStart, aEnd;
+    Handle(V3d_View) aNullView;
+    FeaturePtr aMyFeature;
+
+    Handle(Geom_Curve) aCurve = BRep_Tool::Curve(TopoDS::Edge(theShape), aStart, aEnd);
+    GeomAdaptor_Curve aAdaptor(aCurve);
+    if (aAdaptor.GetType() == GeomAbs_Line) {
+      // Create line
+      aMyFeature = theSketch->addFeature(SketchPlugin_Line::ID());
+    } else if (aAdaptor.GetType() == GeomAbs_Circle) {
+      if (aAdaptor.IsClosed()) {
+        // Create circle
+        aMyFeature = theSketch->addFeature(SketchPlugin_Circle::ID());
+      } else {
+        // Create arc
+        aMyFeature = theSketch->addFeature(SketchPlugin_Arc::ID());
+      }
     }
-  }
-  if (aMyFeature) {
-    DataPtr aData = aMyFeature->data();
-    AttributeSelectionPtr anAttr = 
-      std::dynamic_pointer_cast<ModelAPI_AttributeSelection>
-      (aData->attribute(SketchPlugin_Feature::EXTERNAL_ID()));
+    if (aMyFeature) {
+      DataPtr aData = aMyFeature->data();
+      AttributeSelectionPtr anAttr = 
+        std::dynamic_pointer_cast<ModelAPI_AttributeSelection>
+        (aData->attribute(SketchPlugin_Feature::EXTERNAL_ID()));
 
-    ResultPtr aRes = std::dynamic_pointer_cast<ModelAPI_Result>(thePrs.object());
-    if (anAttr && aRes) {
-      std::shared_ptr<GeomAPI_Shape> anEdge(new GeomAPI_Shape);
-      anEdge->setImpl(new TopoDS_Shape(aShape));
+      ResultPtr aRes = std::dynamic_pointer_cast<ModelAPI_Result>(theObject);
+      if (anAttr && aRes) {
+        std::shared_ptr<GeomAPI_Shape> anEdge(new GeomAPI_Shape);
+        anEdge->setImpl(new TopoDS_Shape(theShape));
 
-      anAttr->setValue(aRes, anEdge);
+        anAttr->setValue(aRes, anEdge);
 
-      aMyFeature->execute();
+        aMyFeature->execute();
 
-      // fix this edge
-      FeaturePtr aFix = theSketch->addFeature(SketchPlugin_ConstraintRigid::ID());
-      aFix->data()->refattr(SketchPlugin_Constraint::ENTITY_A())->
-        setObject(aMyFeature->lastResult());
+        // fix this edge
+        FeaturePtr aFix = theSketch->addFeature(SketchPlugin_ConstraintRigid::ID());
+        aFix->data()->refattr(SketchPlugin_Constraint::ENTITY_A())->
+          setObject(aMyFeature->lastResult());
 
-      return aMyFeature->lastResult();
+        return aMyFeature->lastResult();
+      }
+    }
+  }
+  if (theShape.ShapeType() == TopAbs_VERTEX) {
+    std::shared_ptr<GeomAPI_Vertex> aInVert = std::shared_ptr<GeomAPI_Vertex>(new GeomAPI_Vertex());
+    aInVert->setImpl(new TopoDS_Shape(theShape));
+    ResultPtr aResult = findExternalVertex(theSketch, aInVert);
+    if (aResult)
+      return aResult;
+
+    FeaturePtr aMyFeature = theSketch->addFeature(SketchPlugin_Point::ID());
+
+    if (aMyFeature) {
+      DataPtr aData = aMyFeature->data();
+      AttributeSelectionPtr anAttr = 
+        std::dynamic_pointer_cast<ModelAPI_AttributeSelection>
+        (aData->attribute(SketchPlugin_Feature::EXTERNAL_ID()));
+
+      ResultPtr aRes = std::dynamic_pointer_cast<ModelAPI_Result>(theObject);
+      if (anAttr && aRes) {
+        std::shared_ptr<GeomAPI_Shape> aVert(new GeomAPI_Shape);
+        aVert->setImpl(new TopoDS_Shape(theShape));
+
+        anAttr->setValue(aRes, aVert);
+        aMyFeature->execute();
+
+        // fix this edge
+        FeaturePtr aFix = theSketch->addFeature(SketchPlugin_ConstraintRigid::ID());
+        aFix->data()->refattr(SketchPlugin_Constraint::ENTITY_A())->
+          setObject(aMyFeature->lastResult());
+
+        return aMyFeature->lastResult();
+      }
     }
   }
   return ResultPtr();
@@ -508,6 +527,35 @@ ResultPtr PartSet_Tools::findExternalEdge(CompositeFeaturePtr theSketch, std::sh
   return ResultPtr();
 }
 
+
+ResultPtr PartSet_Tools::findExternalVertex(CompositeFeaturePtr theSketch, std::shared_ptr<GeomAPI_Vertex> theVert)
+{
+  for (int i = 0; i < theSketch->numberOfSubs(); i++) {
+    FeaturePtr aFeature = theSketch->subFeature(i);
+    std::shared_ptr<SketchPlugin_Feature> aSketchFea = 
+      std::dynamic_pointer_cast<SketchPlugin_Feature>(aFeature);
+    if (aSketchFea) {
+      if (aSketchFea->isExternal()) {
+        std::list<ResultPtr> aResults = aSketchFea->results();
+        std::list<ResultPtr>::const_iterator aIt;
+        for (aIt = aResults.cbegin(); aIt != aResults.cend(); ++aIt) {
+          ResultConstructionPtr aRes = 
+            std::dynamic_pointer_cast<ModelAPI_ResultConstruction>(*aIt);
+          if (aRes) {
+            std::shared_ptr<GeomAPI_Shape> aShape = aRes->shape();
+            if (aShape) {
+              if (theVert->isEqual(aShape))
+                return aRes;
+            }
+          }
+        }
+      }
+    }
+  }
+  return ResultPtr();
+}
+
+
 bool PartSet_Tools::hasVertexShape(const ModuleBase_ViewerPrs& thePrs, FeaturePtr theSketch,
                                    Handle_V3d_View theView, double& theX, double& theY)
 {
@@ -527,3 +575,39 @@ bool PartSet_Tools::hasVertexShape(const ModuleBase_ViewerPrs& thePrs, FeaturePt
 
   return aHasVertex;
 }
+
+AttributePtr PartSet_Tools::findAttributeBy2dPoint(ObjectPtr theObj, 
+                                                   const TopoDS_Shape theShape, 
+                                                   FeaturePtr theSketch)
+{
+
+  AttributePtr anAttribute;
+  FeaturePtr aFeature = ModelAPI_Feature::feature(theObj);
+  if (aFeature) {
+    if (theShape.ShapeType() == TopAbs_VERTEX) {
+      const TopoDS_Vertex& aVertex = TopoDS::Vertex(theShape);
+      if (!aVertex.IsNull())  {
+        gp_Pnt aPoint = BRep_Tool::Pnt(aVertex);
+        std::shared_ptr<GeomAPI_Pnt> aValue = std::shared_ptr<GeomAPI_Pnt>(
+            new GeomAPI_Pnt(aPoint.X(), aPoint.Y(), aPoint.Z()));
+
+        // find the given point in the feature attributes
+        std::list<AttributePtr> anAttiributes = 
+          aFeature->data()->attributes(GeomDataAPI_Point2D::type());
+        std::list<AttributePtr>::const_iterator anIt = anAttiributes.begin(), 
+                                                aLast = anAttiributes.end();
+        for (; anIt != aLast && !anAttribute; anIt++) {
+          std::shared_ptr<GeomDataAPI_Point2D> aCurPoint = 
+            std::dynamic_pointer_cast<GeomDataAPI_Point2D>(*anIt);
+
+          std::shared_ptr<GeomAPI_Pnt> aPnt = convertTo3D(aCurPoint->x(), aCurPoint->y(), theSketch);
+          if (aPnt && (aPnt->distance(aValue) < Precision::Confusion())) {
+            anAttribute = aCurPoint;
+            break;
+          }
+        }
+      }
+    }
+  }
+  return anAttribute;
+}
index 5dda6eafb17e47f370de749ddbdbdd20cf98aed4..e3579c9f56b5958559ce8d88e132381a1d696284 100644 (file)
@@ -1,3 +1,5 @@
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
 // File:        PartSet_Tools.h
 // Created:     28 Apr 2014
 // Author:      Natalia ERMOLAEVA
 #include <QList>
 
 #include <ModelAPI_CompositeFeature.h>
+#include <ModelAPI_Object.h>
+#include <ModelAPI_Attribute.h>
+
+#include <TopoDS_Shape.hxx>
 
 #include <memory>
 
@@ -24,6 +30,7 @@ class GeomAPI_Pln;
 class GeomAPI_Pnt2d;
 class GeomAPI_Pnt;
 class GeomAPI_Edge;
+class GeomAPI_Vertex;
 
 /*!
  \class PartSet_Tools
@@ -35,6 +42,7 @@ class PARTSET_EXPORT PartSet_Tools
   /// Converts the 2D screen point to the 3D point on the view according to the point of view
   /// \param thePoint a screen point
   /// \param theView a 3D view
+  // Transferred to ModuleBase
   static gp_Pnt convertClickToPoint(QPoint thePoint, Handle_V3d_View theView);
 
   /// \brief Converts the 3D point to the projected coodinates on the sketch plane.
@@ -43,7 +51,7 @@ class PARTSET_EXPORT PartSet_Tools
   /// \param theX the X coordinate
   /// \param theY the Y coordinate
   static void convertTo2D(const gp_Pnt& thePoint, FeaturePtr theSketch,
-  Handle(V3d_View) theView,
+                          Handle(V3d_View) theView,
                           double& theX, double& theY);
 
   /// \brief Converts the 2D projected coodinates on the sketch plane to the 3D point.
@@ -51,8 +59,7 @@ class PARTSET_EXPORT PartSet_Tools
   /// \param theY the Y coordinate
   /// \param theSketch the sketch feature
   /// \param thePoint the 3D point in the viewer
-  static void convertTo3D(const double theX, const double theY, FeaturePtr theSketch,
-                          gp_Pnt& thePoint);
+  static std::shared_ptr<GeomAPI_Pnt> convertTo3D(const double theX, const double theY, FeaturePtr theSketch);
 
   /// Returns an object that is under the mouse point. Firstly it checks the highlighting,
   /// if it exists, the first object is returned. Secondly, there is an iteration on
@@ -137,7 +144,9 @@ class PARTSET_EXPORT PartSet_Tools
   /// Created line will have fixed constraint
   /// \param theEdge - an edge
   /// \return - result of created feature
-  static ResultPtr createFixedObjectByEdge(const ModuleBase_ViewerPrs& thePrs, CompositeFeaturePtr theSketch);
+  static ResultPtr createFixedObjectByEdge(const TopoDS_Shape& theShape, 
+                                           const ObjectPtr& theObject, 
+                                           CompositeFeaturePtr theSketch);
 
   /// Checks whether the list of selected presentations contains the given one
   /// \param theSelected a list of presentations
@@ -152,6 +161,12 @@ class PARTSET_EXPORT PartSet_Tools
   /// \return result object with external edge if it is found
   static ResultPtr findExternalEdge(CompositeFeaturePtr theSketch, std::shared_ptr<GeomAPI_Edge> theEdge);
 
+  /// Returns Result object if the given sketch contains external vertex equal to the given
+  /// \param theSketch - the sketch feature
+  /// \param theVert - the vertex
+  /// \return result object with external vertex if it is found
+  static ResultPtr findExternalVertex(CompositeFeaturePtr theSketch, std::shared_ptr<GeomAPI_Vertex> theVert);
+
   /// Returns whether the selected presentation has a shape with the vertex type
   /// \param thePrs a selected presentation
   /// \param theSketch the sketch feature
@@ -160,6 +175,16 @@ class PARTSET_EXPORT PartSet_Tools
   /// \param theY the output vertical coordinate of the point
   static bool hasVertexShape(const ModuleBase_ViewerPrs& thePrs, FeaturePtr theSketch,
                              Handle_V3d_View theView, double& theX, double& theY);
+
+
+  /**
+  * Find attribute of object which corresponds to the given shape
+  * \param theObj - an object
+  * \param theShape - a Shape
+  * \param theSketch - a Sketch to get a plane of converting to 2d
+  */
+  static AttributePtr findAttributeBy2dPoint(ObjectPtr theObj, const TopoDS_Shape theShape, FeaturePtr theSketch);
+
 protected:
   /// Returns an object that is under the mouse point. Firstly it checks the highlighting,
   /// if it exists, the first object is returned. Secondly, there is an iteration on
index 7a976bda33749c371cf392ef0478f5217e0edfc6..fa7ac518f60a1696c8a4b04f5b88cc7392107735 100644 (file)
@@ -1,3 +1,5 @@
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
 // File:        PartSet_Validators.cpp
 // Created:     09 July 2014
 // Author:      Vitaly SMETANNIKOV
 #include <GeomAbs_CurveType.hxx>
 #include <ModuleBase_ISelection.h>
 
+#include <ModelAPI_AttributeRefAttr.h>
+#include <ModelAPI_AttributeSelection.h>
+#include <ModelAPI_AttributeReference.h>
+
 #include <list>
+#ifdef _DEBUG
+#include <iostream>
+#endif
 
 int shapesNbPoints(const ModuleBase_ISelection* theSelection)
 {
@@ -49,7 +58,7 @@ int shapesNbLines(const ModuleBase_ISelection* theSelection)
 
 bool PartSet_DistanceValidator::isValid(const ModuleBase_ISelection* theSelection) const
 {
-  int aCount = shapesNbPoints(theSelection);
+  int aCount = shapesNbPoints(theSelection) + shapesNbLines(theSelection);
   return (aCount > 0) && (aCount < 3);
 }
 
@@ -92,3 +101,73 @@ bool PartSet_RadiusValidator::isValid(const ModuleBase_ISelection* theSelection)
   return (aCount > 0) && (aCount < 2);
 }
 
+bool PartSet_RigidValidator::isValid(const ModuleBase_ISelection* theSelection) const
+{
+  int aCount = shapesNbLines(theSelection);
+  return (aCount > 0) && (aCount < 2);
+}
+
+bool PartSet_DifferentObjectsValidator::isValid(const FeaturePtr& theFeature, 
+                                                const std::list<std::string>& theArguments,
+                                                const ObjectPtr& theObject) const
+{
+  // Check RefAttr attributes
+  std::list<std::shared_ptr<ModelAPI_Attribute> > anAttrs = 
+    theFeature->data()->attributes(ModelAPI_AttributeRefAttr::type());
+  if (anAttrs.size() > 0) {
+    std::list<std::shared_ptr<ModelAPI_Attribute> >::iterator anAttr = anAttrs.begin();
+    for(; anAttr != anAttrs.end(); anAttr++) {
+      if (*anAttr) {
+        std::shared_ptr<ModelAPI_AttributeRefAttr> aRef = 
+          std::dynamic_pointer_cast<ModelAPI_AttributeRefAttr>(*anAttr);
+        // check the object is already presented
+        if (aRef->isObject() && aRef->object() == theObject)
+          return false;
+      }
+    }
+  }
+  // Check selection attributes
+  anAttrs = theFeature->data()->attributes(ModelAPI_AttributeSelection::type());
+  if (anAttrs.size() > 0) {
+    std::list<std::shared_ptr<ModelAPI_Attribute> >::iterator anAttr = anAttrs.begin();
+    for(; anAttr != anAttrs.end(); anAttr++) {
+      if (*anAttr) {
+        std::shared_ptr<ModelAPI_AttributeSelection> aRef = 
+          std::dynamic_pointer_cast<ModelAPI_AttributeSelection>(*anAttr);
+        // check the object is already presented
+        if (aRef->isInitialized() && aRef->context() == theObject)
+          return false;
+      }
+    }
+  }
+  // Check selection attributes
+  anAttrs = theFeature->data()->attributes(ModelAPI_AttributeReference::type());
+  if (anAttrs.size() > 0) {
+    std::list<std::shared_ptr<ModelAPI_Attribute> >::iterator anAttr = anAttrs.begin();
+    for(; anAttr != anAttrs.end(); anAttr++) {
+      if (*anAttr) {
+        std::shared_ptr<ModelAPI_AttributeReference> aRef = 
+          std::dynamic_pointer_cast<ModelAPI_AttributeReference>(*anAttr);
+        // check the object is already presented
+        if (aRef->isInitialized() && aRef->value() == theObject)
+          return false;
+      }
+    }
+  }
+  return true;
+}
+
+bool PartSet_DifferentObjectsValidator::isValid(const FeaturePtr& theFeature, 
+                                                const std::list<std::string>& theArguments,
+                                                const AttributePtr& theAttribute) const
+{
+  // not implemented
+  return true;
+}
+
+bool PartSet_DifferentObjectsValidator::isValid(const AttributePtr& theAttribute, 
+                                                const std::list<std::string>& theArguments) const
+{
+  // not implemented
+  return true;
+}
index 02f7d21e6c53b1f8c7e8cd88385dc044a62c63dd..d0829b58692fe405a404b8df7874b119a9c12060 100644 (file)
@@ -1,3 +1,5 @@
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
 // File:        PartSet_Validators.h
 // Created:     09 July 2014
 // Author:      Vitaly SMETANNIKOV
@@ -9,6 +11,7 @@
 
 #include <ModuleBase_SelectionValidator.h>
 #include <ModuleBase_ISelection.h>
+#include <ModelAPI_RefAttrValidator.h>
 
 /*
  * Selector validators
@@ -49,4 +52,25 @@ class PartSet_RadiusValidator : public ModuleBase_SelectionValidator
   PARTSET_EXPORT virtual bool isValid(const ModuleBase_ISelection* theSelection) const;
 };
 
+//! A class to validate a selection for Perpendicular constraint operation
+class PartSet_RigidValidator : public ModuleBase_SelectionValidator
+{
+ public:
+  PARTSET_EXPORT virtual bool isValid(const ModuleBase_ISelection* theSelection) const;
+};
+
+class PartSet_DifferentObjectsValidator : public ModelAPI_RefAttrValidator
+{
+ public:
+  virtual bool isValid(const FeaturePtr& theFeature, const std::list<std::string>& theArguments,
+                       const ObjectPtr& theObject) const;
+  //! Returns true if the attribute is good for the feature attribute
+  virtual bool isValid(const FeaturePtr& theFeature, const std::list<std::string>& theArguments,
+                       const AttributePtr& theAttribute) const;
+
+  virtual bool isValid(const AttributePtr& theAttribute,
+                       const std::list<std::string>& theArguments) const;
+};
+
+
 #endif
diff --git a/src/PartSet/PartSet_WidgetPoint2d.cpp b/src/PartSet/PartSet_WidgetPoint2d.cpp
new file mode 100644 (file)
index 0000000..8079d48
--- /dev/null
@@ -0,0 +1,283 @@
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
+// File:        PartSet_WidgetPoint2D.cpp
+// Created:     25 Apr 2014
+// Author:      Natalia ERMOLAEVA
+
+#include "PartSet_WidgetPoint2d.h"
+#include <PartSet_Tools.h>
+
+#include <XGUI_Workshop.h>
+#include <XGUI_ViewerProxy.h>
+#include <XGUI_ModuleConnector.h>
+#include <XGUI_SelectionMgr.h>
+#include <XGUI_Selection.h>
+#include <XGUI_PropertyPanel.h>
+#include <XGUI_OperationMgr.h>
+
+#include <ModuleBase_DoubleSpinBox.h>
+#include <ModuleBase_Tools.h>
+#include <ModuleBase_IViewWindow.h>
+
+#include <Config_Keywords.h>
+#include <Config_WidgetAPI.h>
+
+#include <Events_Loop.h>
+#include <ModelAPI_Events.h>
+
+#include <ModelAPI_Feature.h>
+#include <ModelAPI_Data.h>
+#include <ModelAPI_Object.h>
+#include <GeomDataAPI_Point2D.h>
+#include <GeomAPI_Pnt2d.h>
+
+#include <QGroupBox>
+#include <QGridLayout>
+#include <QLabel>
+#include <QEvent>
+#include <QMouseEvent>
+#include <QApplication>
+
+#include <TopoDS.hxx>
+#include <TopoDS_Vertex.hxx>
+#include <BRep_Tool.hxx>
+
+#include <cfloat>
+#include <climits>
+
+PartSet_WidgetPoint2D::PartSet_WidgetPoint2D(QWidget* theParent, 
+                                              const Config_WidgetAPI* theData,
+                                              const std::string& theParentId)
+    : ModuleBase_ModelWidget(theParent, theData, theParentId)
+{
+  //myOptionParam = theData->getProperty(PREVIOUS_FEATURE_PARAM);
+  QString aPageName = QString::fromStdString(theData->getProperty(CONTAINER_PAGE_NAME));
+  myGroupBox = new QGroupBox(aPageName, theParent);
+  myGroupBox->setFlat(false);
+
+  QGridLayout* aGroupLay = new QGridLayout(myGroupBox);
+  ModuleBase_Tools::adjustMargins(aGroupLay);
+  aGroupLay->setColumnStretch(1, 1);
+  {
+    QLabel* aLabel = new QLabel(myGroupBox);
+    aLabel->setText("X");
+    aLabel->setPixmap(QPixmap(":pictures/x_point.png"));
+    aGroupLay->addWidget(aLabel, 0, 0);
+
+    myXSpin = new ModuleBase_DoubleSpinBox(myGroupBox);
+    myXSpin->setMinimum(-DBL_MAX);
+    myXSpin->setMaximum(DBL_MAX);
+    myXSpin->setToolTip("X");
+    aGroupLay->addWidget(myXSpin, 0, 1);
+
+    connect(myXSpin, SIGNAL(valueChanged(double)), this, SLOT(onValuesChanged()));
+  }
+  {
+    QLabel* aLabel = new QLabel(myGroupBox);
+    aLabel->setText("Y");
+    aLabel->setPixmap(QPixmap(":pictures/y_point.png"));
+    aGroupLay->addWidget(aLabel, 1, 0);
+
+    myYSpin = new ModuleBase_DoubleSpinBox(myGroupBox);
+    myYSpin->setMinimum(-DBL_MAX);
+    myYSpin->setMaximum(DBL_MAX);
+    myYSpin->setToolTip("X");
+    aGroupLay->addWidget(myYSpin, 1, 1);
+
+    connect(myYSpin, SIGNAL(valueChanged(double)), this, SLOT(onValuesChanged()));
+  }
+}
+
+PartSet_WidgetPoint2D::~PartSet_WidgetPoint2D()
+{
+}
+
+bool PartSet_WidgetPoint2D::setSelection(ModuleBase_ViewerPrs theValue)
+{
+  Handle(V3d_View) aView = myWorkshop->viewer()->activeView();
+  bool isDone = false;
+  TopoDS_Shape aShape = theValue.shape();
+  double aX, aY;
+  if (getPoint2d(aView, aShape, aX, aY)) {
+    setPoint(aX, aY);
+    isDone = true;
+  }
+  return isDone;
+}
+
+void PartSet_WidgetPoint2D::setPoint(double theX, double theY)
+{
+
+  bool isBlocked = this->blockSignals(true);
+  myXSpin->blockSignals(true);
+  myXSpin->setValue(theX);
+  myXSpin->blockSignals(false);
+
+  myYSpin->blockSignals(true);
+  myYSpin->setValue(theY);
+  myYSpin->blockSignals(false);
+  this->blockSignals(isBlocked);
+
+  emit valuesChanged();
+}
+
+bool PartSet_WidgetPoint2D::storeValue() const
+{
+  std::shared_ptr<ModelAPI_Data> aData = myFeature->data();
+  if (!aData) // can be on abort of sketcher element
+    return false;
+  std::shared_ptr<GeomDataAPI_Point2D> aPoint = std::dynamic_pointer_cast<GeomDataAPI_Point2D>(
+      aData->attribute(attributeID()));
+  
+  PartSet_WidgetPoint2D* that = (PartSet_WidgetPoint2D*) this;
+  bool isBlocked = that->blockSignals(true);
+  bool isImmutable = aPoint->setImmutable(true);
+#ifdef _DEBUG
+  std::string _attr_name = myAttributeID;
+  double _X = myXSpin->value();
+  double _Y = myYSpin->value();
+#endif
+  aPoint->setValue(myXSpin->value(), myYSpin->value());
+  // after movement the solver will call the update event: optimization
+  moveObject(myFeature);
+  aPoint->setImmutable(isImmutable);
+  that->blockSignals(isBlocked);
+
+  return true;
+}
+
+bool PartSet_WidgetPoint2D::restoreValue()
+{
+  std::shared_ptr<ModelAPI_Data> aData = myFeature->data();
+  std::shared_ptr<GeomDataAPI_Point2D> aPoint = std::dynamic_pointer_cast<GeomDataAPI_Point2D>(
+      aData->attribute(attributeID()));
+
+#ifdef _DEBUG
+  std::string _attr_name = myAttributeID;
+  double _X = aPoint->x();
+  double _Y = aPoint->y();
+#endif
+  bool isBlocked = this->blockSignals(true);
+  myXSpin->blockSignals(true);
+  myXSpin->setValue(aPoint->x());
+  myXSpin->blockSignals(false);
+
+  myYSpin->blockSignals(true);
+  myYSpin->setValue(aPoint->y());
+  myYSpin->blockSignals(false);
+  this->blockSignals(isBlocked);
+  return true;
+}
+
+QWidget* PartSet_WidgetPoint2D::getControl() const
+{
+  return myGroupBox;
+}
+
+QList<QWidget*> PartSet_WidgetPoint2D::getControls() const
+{
+  QList<QWidget*> aControls;
+  aControls.append(myXSpin);
+  aControls.append(myYSpin);
+  return aControls;
+}
+
+
+void PartSet_WidgetPoint2D::activate()
+{
+  XGUI_ViewerProxy* aViewer = myWorkshop->viewer();
+  connect(aViewer, SIGNAL(mouseMove(ModuleBase_IViewWindow*, QMouseEvent*)), 
+          this, SLOT(onMouseMove(ModuleBase_IViewWindow*, QMouseEvent*)));
+  connect(aViewer, SIGNAL(mouseRelease(ModuleBase_IViewWindow*, QMouseEvent*)), 
+          this, SLOT(onMouseRelease(ModuleBase_IViewWindow*, QMouseEvent*)));
+
+  QIntList aModes;
+  aModes << TopAbs_VERTEX;
+  myWorkshop->moduleConnector()->activateSubShapesSelection(aModes);
+}
+
+void PartSet_WidgetPoint2D::deactivate()
+{
+  ModuleBase_IViewer* aViewer = myWorkshop->viewer();
+  disconnect(aViewer, SIGNAL(mouseMove(ModuleBase_IViewWindow*, QMouseEvent*)), 
+             this, SLOT(onMouseMove(ModuleBase_IViewWindow*, QMouseEvent*)));
+  disconnect(aViewer, SIGNAL(mouseRelease(ModuleBase_IViewWindow*, QMouseEvent*)), 
+             this, SLOT(onMouseRelease(ModuleBase_IViewWindow*, QMouseEvent*)));
+  myWorkshop->moduleConnector()->deactivateSubShapesSelection();
+  myWorkshop->operationMgr()->setLockValidating(false);
+}
+
+bool PartSet_WidgetPoint2D::getPoint2d(const Handle(V3d_View)& theView, 
+                                       const TopoDS_Shape& theShape, 
+                                       double& theX, double& theY) const
+{
+  if (!theShape.IsNull()) {
+    if (theShape.ShapeType() == TopAbs_VERTEX) {
+      const TopoDS_Vertex& aVertex = TopoDS::Vertex(theShape);
+      if (!aVertex.IsNull()) {
+        // A case when point is taken from existing vertex
+        gp_Pnt aPoint = BRep_Tool::Pnt(aVertex);
+        PartSet_Tools::convertTo2D(aPoint, mySketch, theView, theX, theY);
+        return true;
+      }
+    }
+  }
+  return false;
+}
+
+
+void PartSet_WidgetPoint2D::onMouseRelease(ModuleBase_IViewWindow* theWnd, QMouseEvent* theEvent)
+{
+  XGUI_Selection* aSelection = myWorkshop->selector()->selection();
+  NCollection_List<TopoDS_Shape> aShapes;
+  std::list<ObjectPtr> aObjects;
+  aSelection->selectedShapes(aShapes, aObjects);
+  if (aShapes.Extent() > 0) {
+    TopoDS_Shape aShape = aShapes.First();
+    double aX, aY;
+    if (getPoint2d(theWnd->v3dView(), aShape, aX, aY)) {
+      setPoint(aX, aY);
+
+      PartSet_Tools::setConstraints(mySketch, feature(), attributeID(),aX, aY);
+      emit vertexSelected(aObjects.front(), aShape);
+      emit focusOutWidget(this);
+      return;
+    }
+  }
+  // A case when point is taken from mouse event
+  gp_Pnt aPoint = PartSet_Tools::convertClickToPoint(theEvent->pos(), theWnd->v3dView());
+  double aX, anY;
+  PartSet_Tools::convertTo2D(aPoint, mySketch, theWnd->v3dView(), aX, anY);
+  setPoint(aX, anY);
+
+  emit focusOutWidget(this);
+}
+
+
+void PartSet_WidgetPoint2D::onMouseMove(ModuleBase_IViewWindow* theWnd, QMouseEvent* theEvent)
+{
+  myWorkshop->operationMgr()->setLockValidating(true);
+  myWorkshop->propertyPanel()->setOkEnabled(false);
+
+  gp_Pnt aPoint = PartSet_Tools::convertClickToPoint(theEvent->pos(), theWnd->v3dView());
+
+  double aX, anY;
+  PartSet_Tools::convertTo2D(aPoint, mySketch, theWnd->v3dView(), aX, anY);
+  setPoint(aX, anY);
+}
+
+double PartSet_WidgetPoint2D::x() const
+{
+  return myXSpin->value();
+}
+
+double PartSet_WidgetPoint2D::y() const
+{
+  return myYSpin->value();
+}
+
+void PartSet_WidgetPoint2D::onValuesChanged()
+{
+  myWorkshop->operationMgr()->setLockValidating(false);
+  emit valuesChanged();
+}
diff --git a/src/PartSet/PartSet_WidgetPoint2d.h b/src/PartSet/PartSet_WidgetPoint2d.h
new file mode 100644 (file)
index 0000000..69e6461
--- /dev/null
@@ -0,0 +1,119 @@
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
+// File:        PartSet_WidgetPoint2d.h
+// Created:     25 Apr 2014
+// Author:      Natalia ERMOLAEVA
+
+#ifndef PartSet_WidgetPoint2D_H
+#define PartSet_WidgetPoint2D_H
+
+#include "PartSet.h"
+#include <ModelAPI_CompositeFeature.h>
+#include <ModuleBase_ModelWidget.h>
+
+#include <QObject>
+
+#include <TopoDS_Shape.hxx>
+#include <V3d_View.hxx>
+
+class ModelAPI_Feature;
+class ModuleBase_IWorkshop;
+class ModuleBase_DoubleSpinBox;
+class ModuleBase_IViewWindow;
+class GeomAPI_Pnt2d;
+class XGUI_Workshop;
+
+class QGroupBox;
+class QMouseEvent;
+
+/**\class PartSet_WidgetPoint2D
+ * \ingroup GUI
+ * \brief Custom widget. An abstract class to be redefined to fill with some GUI controls
+ */
+class PARTSET_EXPORT PartSet_WidgetPoint2D : public ModuleBase_ModelWidget
+{
+Q_OBJECT
+ public:
+  /// Constructor
+  /// \theParent the parent object
+  /// \theParent the parent object
+  /// \theData the widget configuation. The attribute of the model widget is obtained from
+  PartSet_WidgetPoint2D(QWidget* theParent, const Config_WidgetAPI* theData, 
+                        const std::string& theParentId);
+  /// Destructor
+  virtual ~PartSet_WidgetPoint2D();
+
+  /// Set the given wrapped value to the current widget
+  /// This value should be processed in the widget according to the needs
+  /// \param theValue the wrapped widget value
+  virtual bool setSelection(ModuleBase_ViewerPrs theValue);
+
+  /// Saves the internal parameters to the given feature
+  /// \param theObject a model feature to be changed
+  virtual bool storeValue() const;
+
+  virtual bool restoreValue();
+
+  /// Returns the internal parent wiget control, that can be shown anywhere
+  /// \returns the widget
+  QWidget* getControl() const;
+
+  /// Returns list of widget controls
+  /// \return a control list
+  virtual QList<QWidget*> getControls() const;
+
+  //bool initFromPrevious(ObjectPtr theObject);
+
+  /// The methiod called when widget is activated
+  virtual void activate();
+
+  /// The methiod called when widget is deactivated
+  virtual void deactivate();
+
+  XGUI_Workshop* workshop() const { return myWorkshop; }
+
+  void setWorkshop(XGUI_Workshop* theWork) { myWorkshop = theWork; }
+
+  /// \returns the sketch instance
+  CompositeFeaturePtr sketch() const { return mySketch; }
+  void setSketch(CompositeFeaturePtr theSketch) { mySketch = theSketch; }
+
+  /// Fill the widget values by given point
+  /// \param thePoint the point
+  void setPoint(double theX, double theY);
+
+  /// Returns coordinate X currently defined in the control
+  double x() const;
+
+  /// Returns coordinate Y currently defined in the control
+  double y() const;
+
+signals:
+  /// Signal about selection of an existing vertex from an object
+  /// \param theObject - the selected object
+  /// \param theShape - the selected shape
+  void vertexSelected(ObjectPtr theObject, const TopoDS_Shape& theShape);
+
+protected slots:
+  void onMouseRelease(ModuleBase_IViewWindow* theWnd, QMouseEvent* theEvent);
+  void onMouseMove(ModuleBase_IViewWindow* theWnd, QMouseEvent* theEvent);
+
+private slots:
+  void onValuesChanged();
+
+ private:
+   bool getPoint2d(const Handle(V3d_View)& theView, const TopoDS_Shape& theShape, 
+                   double& theX, double& theY) const;
+
+  XGUI_Workshop* myWorkshop;
+
+  QGroupBox* myGroupBox;  ///< the parent group box for all intenal widgets
+  ModuleBase_DoubleSpinBox* myXSpin;  ///< the spin box for the X coordinate
+  ModuleBase_DoubleSpinBox* myYSpin;  ///< the spin box for the Y coordinate
+
+  //std::string myOptionParam;  /// Parameter name which has to be taken from previous feature
+
+  CompositeFeaturePtr mySketch;
+};
+
+#endif
diff --git a/src/PartSet/PartSet_WidgetPoint2dDistance.cpp b/src/PartSet/PartSet_WidgetPoint2dDistance.cpp
new file mode 100644 (file)
index 0000000..b67ca14
--- /dev/null
@@ -0,0 +1,113 @@
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
+// File:        PartSet_WidgetPoint2dDistance.h
+// Created:     23 June 2014
+// Author:      Vitaly Smetannikov
+
+#include "PartSet_WidgetPoint2dDistance.h"
+#include "PartSet_Tools.h"
+
+#include <ModuleBase_DoubleSpinBox.h>
+#include <ModuleBase_IViewWindow.h>
+
+#include <XGUI_ViewerProxy.h>
+#include <XGUI_Workshop.h>
+#include <XGUI_PropertyPanel.h>
+#include <XGUI_OperationMgr.h>
+
+#include <GeomAPI_Pnt2d.h>
+#include <Config_WidgetAPI.h>
+#include <GeomDataAPI_Point2D.h>
+
+#include <ModelAPI_Data.h>
+#include <ModelAPI_AttributeDouble.h>
+
+#include <QMouseEvent>
+
+PartSet_WidgetPoint2dDistance::PartSet_WidgetPoint2dDistance(QWidget* theParent,
+                                                                   const Config_WidgetAPI* theData,
+                                                                   const std::string& theParentId)
+    : ModuleBase_WidgetDoubleValue(theParent, theData, theParentId)
+{
+  myFirstPntName = theData->getProperty("first_point");
+
+  // Reconnect to local slot
+  disconnect(mySpinBox, SIGNAL(valueChanged(double)), this, SIGNAL(valuesChanged()));
+  connect(mySpinBox, SIGNAL(valueChanged(double)), this, SLOT(onValuesChanged()));
+}
+
+PartSet_WidgetPoint2dDistance::~PartSet_WidgetPoint2dDistance()
+{
+}
+
+void PartSet_WidgetPoint2dDistance::setPoint(FeaturePtr theFeature,
+                                             const std::shared_ptr<GeomAPI_Pnt2d>& thePnt)
+{
+  std::shared_ptr<ModelAPI_Data> aData = theFeature->data();
+  std::shared_ptr<GeomDataAPI_Point2D> aPoint = std::dynamic_pointer_cast<GeomDataAPI_Point2D>(
+      aData->attribute(myFirstPntName));
+  if (!aPoint)
+    return;
+
+  double aRadius = thePnt->distance(aPoint->pnt());
+  AttributeDoublePtr aReal = aData->real(attributeID());
+  if (aReal && (aReal->value() != aRadius)) {
+    aReal->setValue(aRadius);
+    mySpinBox->blockSignals(true);
+    mySpinBox->setValue(aRadius);
+    mySpinBox->blockSignals(false);
+    emit valuesChanged();
+  }
+}
+
+void PartSet_WidgetPoint2dDistance::activate()
+{
+  XGUI_ViewerProxy* aViewer = myWorkshop->viewer();
+  connect(aViewer, SIGNAL(mouseMove(ModuleBase_IViewWindow*, QMouseEvent*)), 
+          this, SLOT(onMouseMove(ModuleBase_IViewWindow*, QMouseEvent*)));
+  connect(aViewer, SIGNAL(mouseRelease(ModuleBase_IViewWindow*, QMouseEvent*)), 
+          this, SLOT(onMouseRelease(ModuleBase_IViewWindow*, QMouseEvent*)));
+}
+
+void PartSet_WidgetPoint2dDistance::deactivate()
+{
+  ModuleBase_IViewer* aViewer = myWorkshop->viewer();
+  disconnect(aViewer, SIGNAL(mouseMove(ModuleBase_IViewWindow*, QMouseEvent*)), 
+             this, SLOT(onMouseMove(ModuleBase_IViewWindow*, QMouseEvent*)));
+  disconnect(aViewer, SIGNAL(mouseRelease(ModuleBase_IViewWindow*, QMouseEvent*)), 
+             this, SLOT(onMouseRelease(ModuleBase_IViewWindow*, QMouseEvent*)));
+  myWorkshop->operationMgr()->setLockValidating(false);
+}
+
+void PartSet_WidgetPoint2dDistance::onMouseRelease(ModuleBase_IViewWindow* theWnd, QMouseEvent* theEvent)
+{
+  gp_Pnt aPoint = PartSet_Tools::convertClickToPoint(theEvent->pos(), theWnd->v3dView());
+
+  double aX, aY;
+  PartSet_Tools::convertTo2D(aPoint, mySketch, theWnd->v3dView(), aX, aY);
+
+  std::shared_ptr<GeomAPI_Pnt2d> aPnt = std::shared_ptr<GeomAPI_Pnt2d>(new GeomAPI_Pnt2d(aX, aY));
+  setPoint(feature(), aPnt);
+  emit focusOutWidget(this);
+}
+
+void PartSet_WidgetPoint2dDistance::onMouseMove(ModuleBase_IViewWindow* theWnd, QMouseEvent* theEvent)
+{
+  myWorkshop->operationMgr()->setLockValidating(true);
+  myWorkshop->propertyPanel()->setOkEnabled(false);
+
+  gp_Pnt aPoint = PartSet_Tools::convertClickToPoint(theEvent->pos(), theWnd->v3dView());
+
+  double aX, aY;
+  PartSet_Tools::convertTo2D(aPoint, mySketch, theWnd->v3dView(), aX, aY);
+
+  std::shared_ptr<GeomAPI_Pnt2d> aPnt = std::shared_ptr<GeomAPI_Pnt2d>(new GeomAPI_Pnt2d(aX, aY));
+  setPoint(feature(), aPnt);
+}
+
+void PartSet_WidgetPoint2dDistance::onValuesChanged()
+{
+  myWorkshop->operationMgr()->setLockValidating(false);
+  emit valuesChanged();
+}
+
diff --git a/src/PartSet/PartSet_WidgetPoint2dDistance.h b/src/PartSet/PartSet_WidgetPoint2dDistance.h
new file mode 100644 (file)
index 0000000..ca95b75
--- /dev/null
@@ -0,0 +1,69 @@
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
+// File:        PartSet_WidgetPoint2dDistance.h
+// Created:     23 June 2014
+// Author:      Vitaly Smetannikov
+
+#ifndef PartSet_WidgetPoint2dDistance_H
+#define PartSet_WidgetPoint2dDistance_H
+
+#include "PartSet.h"
+#include <ModuleBase_WidgetDoubleValue.h>
+
+#include <ModelAPI_CompositeFeature.h>
+
+class GeomAPI_Pnt2d;
+class XGUI_Workshop;
+class ModuleBase_IViewWindow;
+class QMouseEvent;
+
+class PARTSET_EXPORT PartSet_WidgetPoint2dDistance : public ModuleBase_WidgetDoubleValue
+{
+Q_OBJECT
+ public:
+  /// Constructor
+  /// \theParent the parent object
+  /// \theData the widget configuation. The attribute of the model widget is obtained from
+  PartSet_WidgetPoint2dDistance(QWidget* theParent, const Config_WidgetAPI* theData,
+                                   const std::string& theParentId);
+
+  virtual ~PartSet_WidgetPoint2dDistance();
+
+  /// The methiod called when widget is activated
+  virtual void activate();
+
+  /// The methiod called when widget is deactivated
+  virtual void deactivate();
+
+  /// Set the given wrapped value to the current widget
+  /// This value should be processed in the widget according to the needs
+  /// \param theValue the wrapped widget value
+  //virtual bool setValue(ModuleBase_WidgetValue* theValue);
+
+  XGUI_Workshop* workshop() const { return myWorkshop; }
+
+  void setWorkshop(XGUI_Workshop* theWork) { myWorkshop = theWork; }
+
+  /// \returns the sketch instance
+  CompositeFeaturePtr sketch() const { return mySketch; }
+  void setSketch(CompositeFeaturePtr theSketch) { mySketch = theSketch; }
+
+ protected slots:
+  void onMouseRelease(ModuleBase_IViewWindow* theWnd, QMouseEvent* theEvent);
+  void onMouseMove(ModuleBase_IViewWindow* theWnd, QMouseEvent* theEvent);
+
+protected:
+  /// Set the second point which defines a value in the widget as a distance with a first point defined by feature
+  void setPoint(FeaturePtr theFeature, const std::shared_ptr<GeomAPI_Pnt2d>& thePnt);
+
+private slots:
+  void onValuesChanged();
+
+ private:
+  XGUI_Workshop* myWorkshop;
+  std::string myFirstPntName;
+
+  CompositeFeaturePtr mySketch;
+};
+
+#endif
diff --git a/src/PartSet/PartSet_WidgetShapeSelector.cpp b/src/PartSet/PartSet_WidgetShapeSelector.cpp
new file mode 100644 (file)
index 0000000..04f0261
--- /dev/null
@@ -0,0 +1,75 @@
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
+// File:        PartSet_WidgetShapeSelector.cpp
+// Created:     27 Nov 2014
+// Author:      Vitaly Smetannikov
+
+#include "PartSet_WidgetShapeSelector.h"
+
+#include <ModelAPI_AttributeRefAttr.h>
+#include <PartSet_Tools.h>
+#include <SketchPlugin_Feature.h>
+
+
+bool PartSet_WidgetShapeSelector::storeValue() const
+{
+  if (!mySelectedObject)
+    return false;
+
+  FeaturePtr aSelectedFeature = ModelAPI_Feature::feature(mySelectedObject);
+  if (aSelectedFeature == myFeature)  // In order to avoid selection of the same object
+    return false;
+  std::shared_ptr<SketchPlugin_Feature> aSPFeature = 
+          std::dynamic_pointer_cast<SketchPlugin_Feature>(aSelectedFeature);
+  if ((!aSPFeature) && (!myShape->isNull())) {
+    // Processing of external (non-sketch) object
+    ObjectPtr aObj = PartSet_Tools::createFixedObjectByEdge(myShape->impl<TopoDS_Shape>(),
+                                                            mySelectedObject, mySketch);
+    if (aObj) {
+      PartSet_WidgetShapeSelector* that = (PartSet_WidgetShapeSelector*) this;
+      that->mySelectedObject = aObj;
+    } else 
+      return false;
+  } else {
+    // Processing of sketch object
+    DataPtr aData = myFeature->data();
+    if (myUseSubShapes && myShape) {
+      AttributePtr aAttr = aData->attribute(attributeID());
+      AttributeRefAttrPtr aRefAttr = 
+        std::dynamic_pointer_cast<ModelAPI_AttributeRefAttr>(aAttr);
+      if (aRefAttr) {
+        TopoDS_Shape aShape = myShape->impl<TopoDS_Shape>();
+        AttributePtr aPntAttr = PartSet_Tools::findAttributeBy2dPoint(mySelectedObject, aShape, mySketch);
+        if (mySelectedObject)
+          aRefAttr->setObject(mySelectedObject);
+        if (aPntAttr)
+          aRefAttr->setAttr(aPntAttr);
+
+        updateObject(myFeature);
+        return true;
+      }
+    }
+  }
+  return ModuleBase_WidgetShapeSelector::storeValue();
+}
+
+//*********************************************
+bool PartSet_WidgetConstraintShapeSelector::storeValue() const
+{
+  FeaturePtr aFeature = ModelAPI_Feature::feature(mySelectedObject);
+  if (aFeature) {
+    std::shared_ptr<SketchPlugin_Feature> aSPFeature = 
+            std::dynamic_pointer_cast<SketchPlugin_Feature>(aFeature);
+    if ((!aSPFeature) && (!myShape->isNull())) {
+      ObjectPtr aObj = PartSet_Tools::createFixedObjectByEdge(myShape->impl<TopoDS_Shape>(),
+                                                              mySelectedObject, mySketch);
+      if (aObj) {
+        PartSet_WidgetConstraintShapeSelector* that = (PartSet_WidgetConstraintShapeSelector*) this;
+        that->mySelectedObject = aObj;
+      } else 
+        return false;
+    }
+  }
+  return ModuleBase_WidgetShapeSelector::storeValue();
+}
+
diff --git a/src/PartSet/PartSet_WidgetShapeSelector.h b/src/PartSet/PartSet_WidgetShapeSelector.h
new file mode 100644 (file)
index 0000000..d4cf72a
--- /dev/null
@@ -0,0 +1,58 @@
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
+// File:        PartSet_WidgetShapeSelector.h
+// Created:     27 Nov 2014
+// Author:      Vitaly Smetannikov
+
+
+#ifndef PartSet_WidgetShapeSelector_H
+#define PartSet_WidgetShapeSelector_H
+
+#include "PartSet.h"
+
+#include <ModuleBase_WidgetShapeSelector.h>
+
+#include <ModelAPI_CompositeFeature.h>
+
+class PARTSET_EXPORT PartSet_WidgetShapeSelector: public ModuleBase_WidgetShapeSelector
+{
+Q_OBJECT
+ public:
+  PartSet_WidgetShapeSelector(QWidget* theParent, ModuleBase_IWorkshop* theWorkshop,
+    const Config_WidgetAPI* theData, const std::string& theParentId)
+    : ModuleBase_WidgetShapeSelector(theParent, theWorkshop, theData, theParentId) {}
+
+  virtual ~PartSet_WidgetShapeSelector() {}
+
+  /// Saves the internal parameters to the given feature
+  virtual bool storeValue() const;
+
+  void setSketcher(CompositeFeaturePtr theSketch) { mySketch = theSketch; }
+  CompositeFeaturePtr sketch() const { return mySketch; }
+
+private:
+  CompositeFeaturePtr mySketch;
+};
+
+
+class PARTSET_EXPORT PartSet_WidgetConstraintShapeSelector: public ModuleBase_WidgetShapeSelector
+{
+Q_OBJECT
+ public:
+  PartSet_WidgetConstraintShapeSelector(QWidget* theParent, ModuleBase_IWorkshop* theWorkshop,
+    const Config_WidgetAPI* theData, const std::string& theParentId)
+    : ModuleBase_WidgetShapeSelector(theParent, theWorkshop, theData, theParentId) {}
+
+  virtual ~PartSet_WidgetConstraintShapeSelector() {}
+
+  /// Saves the internal parameters to the given feature
+  virtual bool storeValue() const;
+
+  void setSketcher(CompositeFeaturePtr theSketch) { mySketch = theSketch; }
+  CompositeFeaturePtr sketch() const { return mySketch; }
+
+private:
+  CompositeFeaturePtr mySketch;
+};
+
+#endif
\ No newline at end of file
index b6f18fb7f365b654ec02be44ad573d818f7f9d93..d5aa73b6bde91d841f5e823131761af5955e28b4 100644 (file)
@@ -1,21 +1,49 @@
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
 // File:        PartSet_WidgetSketchLabel.cpp
 // Created:     07 July 2014
 // Author:      Vitaly SMETANNIKOV
 
 #include "PartSet_WidgetSketchLabel.h"
-#include "PartSet_OperationSketch.h"
+#include "PartSet_Tools.h"
+
+#include <XGUI_Workshop.h>
+#include <XGUI_Displayer.h>
+#include <XGUI_SelectionMgr.h>
+#include <XGUI_Selection.h>
+#include <XGUI_ViewerProxy.h>
+#include <XGUI_ActionsMgr.h>
 
 #include <ModuleBase_Operation.h>
-#include <XGUI_OperationMgr.h>
+#include <ModuleBase_ViewerPrs.h>
+
+#include <GeomAlgoAPI_FaceBuilder.h>
+#include <GeomDataAPI_Point.h>
+#include <GeomDataAPI_Dir.h>
+#include <GeomAPI_XYZ.h>
+
+#include <SketchPlugin_Sketch.h>
+
+#include <Precision.hxx>
+#include <gp_Pln.hxx>
+#include <gp_Pnt.hxx>
+#include <gp_Dir.hxx>
+#include <AIS_Shape.hxx>
+#include <AIS_DimensionSelectionMode.hxx>
 
 #include <Config_WidgetAPI.h>
+#include <Config_PropManager.h>
 
 #include <QLabel>
 
+#define PLANE_SIZE          "200"     
+#define SKETCH_WIDTH        "4"
+
+
 PartSet_WidgetSketchLabel::PartSet_WidgetSketchLabel(QWidget* theParent,
                                                      const Config_WidgetAPI* theData,
                                                      const std::string& theParentId)
-    : ModuleBase_ModelWidget(theParent, theData, theParentId)
+    : ModuleBase_ModelWidget(theParent, theData, theParentId), myPreviewDisplayed(false)
 {
   myText = QString::fromStdString(theData->getProperty("title"));
   myLabel = new QLabel("", theParent);
@@ -25,6 +53,11 @@ PartSet_WidgetSketchLabel::PartSet_WidgetSketchLabel(QWidget* theParent,
   myLabel->setIndent(5);
 }
 
+PartSet_WidgetSketchLabel::~PartSet_WidgetSketchLabel()
+{
+  erasePreviewPlanes();
+}
+
 QList<QWidget*> PartSet_WidgetSketchLabel::getControls() const
 {
   return QList<QWidget*>();
@@ -35,30 +68,222 @@ QWidget* PartSet_WidgetSketchLabel::getControl() const
   return myLabel;
 }
 
-void PartSet_WidgetSketchLabel::setOperationsMgr(XGUI_OperationMgr* theMgr)
+void PartSet_WidgetSketchLabel::onPlaneSelected()
 {
-  ModuleBase_Operation* aOperation = theMgr->currentOperation();
-  if (aOperation->inherits("PartSet_OperationSketch")) {
-    PartSet_OperationSketch* aSketchOpe = static_cast<PartSet_OperationSketch*>(aOperation);
-    updateLabel(aSketchOpe);
-    connect(aSketchOpe, SIGNAL(updatePropPanel()), this,
-            SLOT(onPlaneSelected()));
+  XGUI_Selection* aSelection = myWorkshop->selector()->selection();
+  QList<ModuleBase_ViewerPrs> aSelected = aSelection->getSelected();
+  if (!aSelected.empty()) {
+    ModuleBase_ViewerPrs aPrs = aSelected.first();
+    TopoDS_Shape aShape = aPrs.shape();
+    if (!aShape.IsNull()) {
+      std::shared_ptr<GeomAPI_Dir> aDir = setSketchPlane(aShape);
+      if (aDir) {
+        erasePreviewPlanes();
+
+        if (aPrs.object() && (feature() != aPrs.object())) {
+          DataPtr aData = feature()->data();
+          AttributeSelectionPtr aSelAttr = 
+            std::dynamic_pointer_cast<ModelAPI_AttributeSelection>
+            (aData->attribute(SketchPlugin_Feature::EXTERNAL_ID()));
+          if (aSelAttr) {
+            ResultPtr aRes = std::dynamic_pointer_cast<ModelAPI_Result>(aPrs.object());
+            if (aRes) {
+              GeomShapePtr aShapePtr(new GeomAPI_Shape());
+              aShapePtr->setImpl(new TopoDS_Shape(aShape));
+              aSelAttr->setValue(aRes, aShapePtr);
+            }
+          }
+        } else
+          myWorkshop->viewer()->setViewProjection(aDir->x(), aDir->y(), aDir->z());
+
+        // Clear text in the label
+        myLabel->setText("");
+        myLabel->setToolTip("");
+        disconnect(myWorkshop->selector(), SIGNAL(selectionChanged()), 
+                   this, SLOT(onPlaneSelected()));
+
+        // Clear selection mode and define sketching mode
+        XGUI_Displayer* aDisp = myWorkshop->displayer();
+        aDisp->removeSelectionFilter(myFaceFilter);
+        aDisp->closeLocalContexts();
+        emit planeSelected(plane());
+        setSketchingMode();
+
+        // Update sketcher actions
+        XGUI_ActionsMgr* anActMgr = myWorkshop->actionsMgr();
+        anActMgr->update();
+      }
+    }
   }
 }
 
-void PartSet_WidgetSketchLabel::onPlaneSelected()
+std::shared_ptr<GeomAPI_Pln> PartSet_WidgetSketchLabel::plane() const
 {
-  PartSet_OperationSketch* aSketchOpe = static_cast<PartSet_OperationSketch*>(sender());
-  updateLabel(aSketchOpe);
+  CompositeFeaturePtr aSketch = std::dynamic_pointer_cast<ModelAPI_CompositeFeature>(myFeature);
+  return PartSet_Tools::sketchPlane(aSketch);
+
 }
 
-void PartSet_WidgetSketchLabel::updateLabel(PartSet_OperationSketch* theSketchOpe)
+void PartSet_WidgetSketchLabel::activate()
 {
-  if (theSketchOpe->hasSketchPlane()) {
-    myLabel->setText("");
-    myLabel->setToolTip("");
+  std::shared_ptr<GeomAPI_Pln> aPlane = plane();
+  if (aPlane) {
+    setSketchingMode();
   } else {
+    // We have to select a plane before any operation
+    showPreviewPlanes();
+
+    XGUI_Displayer* aDisp = myWorkshop->displayer();
+    aDisp->openLocalContext();
+    aDisp->activateObjects(QIntList());
+    if (myFaceFilter.IsNull())
+      myFaceFilter = new StdSelect_FaceFilter(StdSelect_Plane);
+    aDisp->addSelectionFilter(myFaceFilter);
+    QIntList aModes;
+    aModes << TopAbs_FACE;
+    aDisp->activateObjects(aModes);
+
     myLabel->setText(myText);
     myLabel->setToolTip(myTooltip);
+
+    connect(myWorkshop->selector(), SIGNAL(selectionChanged()), this, SLOT(onPlaneSelected()));
+    aDisp->updateViewer();
+  }
+}
+
+void PartSet_WidgetSketchLabel::deactivate()
+{
+
+  XGUI_Displayer* aDisp = myWorkshop->displayer();
+  aDisp->removeSelectionFilter(myFaceFilter);
+  //aDisp->removeSelectionFilter(mySketchFilter);
+  aDisp->closeLocalContexts();
+  erasePreviewPlanes();
+}
+
+void PartSet_WidgetSketchLabel::erasePreviewPlanes()
+{
+  if (myPreviewDisplayed) {
+    XGUI_Displayer* aDisp = myWorkshop->displayer();
+    aDisp->eraseAIS(myYZPlane, false);
+    aDisp->eraseAIS(myXZPlane, false);
+    aDisp->eraseAIS(myXYPlane, false);
+    myPreviewDisplayed = false;
   }
 }
+
+void PartSet_WidgetSketchLabel::showPreviewPlanes()
+{
+  if (myPreviewDisplayed)
+    return;
+
+  if (!myYZPlane) { // If planes are not created
+    // Create Preview
+    std::shared_ptr<GeomAPI_Pnt> anOrigin(new GeomAPI_Pnt(0, 0, 0));
+    std::shared_ptr<GeomAPI_Dir> aYZDir(new GeomAPI_Dir(1, 0, 0));
+    std::shared_ptr<GeomAPI_Dir> aXZDir(new GeomAPI_Dir(0, 1, 0));
+    std::shared_ptr<GeomAPI_Dir> aXYDir(new GeomAPI_Dir(0, 0, 1));
+
+    int aR[] = {255, 0, 0};
+    int aG[] = {0, 255, 0};
+    int aB[] = {0, 0, 255};
+
+    myYZPlane = createPreviewPlane(anOrigin, aYZDir, aR);
+    myXZPlane = createPreviewPlane(anOrigin, aXZDir, aG);
+    myXYPlane = createPreviewPlane(anOrigin, aXYDir, aB);
+  }
+  XGUI_Displayer* aDisp = myWorkshop->displayer();
+  aDisp->displayAIS(myYZPlane, false);
+  aDisp->displayAIS(myXZPlane, false);
+  aDisp->displayAIS(myXYPlane, false);
+  myPreviewDisplayed = true;
+}
+
+
+AISObjectPtr PartSet_WidgetSketchLabel::createPreviewPlane(std::shared_ptr<GeomAPI_Pnt> theOrigin, 
+                                                           std::shared_ptr<GeomAPI_Dir> theNorm, 
+                                                           const int theRGB[3])
+{
+  double aSize = Config_PropManager::integer("Sketch planes", "Size of planes", PLANE_SIZE);
+  std::shared_ptr<GeomAPI_Shape> aFace = GeomAlgoAPI_FaceBuilder::square(theOrigin, theNorm, aSize);
+  AISObjectPtr aAIS = AISObjectPtr(new GeomAPI_AISObject());
+  aAIS->createShape(aFace);
+  aAIS->setWidth(Config_PropManager::integer("Sketch planes", "planes_thickness", SKETCH_WIDTH));
+  aAIS->setColor(theRGB[0], theRGB[1], theRGB[2]);
+  return aAIS;
+}
+
+
+std::shared_ptr<GeomAPI_Dir> PartSet_WidgetSketchLabel::setSketchPlane(const TopoDS_Shape& theShape)
+{
+  if (theShape.IsNull())
+    return std::shared_ptr<GeomAPI_Dir>();
+
+  // get selected shape
+  std::shared_ptr<GeomAPI_Shape> aGShape(new GeomAPI_Shape);
+  aGShape->setImpl(new TopoDS_Shape(theShape));
+
+  // get plane parameters
+  std::shared_ptr<GeomAPI_Pln> aPlane = GeomAlgoAPI_FaceBuilder::plane(aGShape);
+
+  // set plane parameters to feature
+  std::shared_ptr<ModelAPI_Data> aData = feature()->data();
+  double anA, aB, aC, aD;
+  aPlane->coefficients(anA, aB, aC, aD);
+
+  // calculate attributes of the sketch
+  std::shared_ptr<GeomAPI_Dir> aNormDir(new GeomAPI_Dir(anA, aB, aC));
+  std::shared_ptr<GeomAPI_XYZ> aCoords = aNormDir->xyz();
+  std::shared_ptr<GeomAPI_XYZ> aZero(new GeomAPI_XYZ(0, 0, 0));
+  aCoords = aCoords->multiplied(-aD * aCoords->distance(aZero));
+  std::shared_ptr<GeomAPI_Pnt> anOrigPnt(new GeomAPI_Pnt(aCoords));
+  // X axis is preferable to be dirX on the sketch
+  const double tol = Precision::Confusion();
+  bool isX = fabs(anA - 1.0) < tol && fabs(aB) < tol && fabs(aC) < tol;
+  std::shared_ptr<GeomAPI_Dir> aTempDir(
+      isX ? new GeomAPI_Dir(0, 1, 0) : new GeomAPI_Dir(1, 0, 0));
+  std::shared_ptr<GeomAPI_Dir> aYDir(new GeomAPI_Dir(aNormDir->cross(aTempDir)));
+  std::shared_ptr<GeomAPI_Dir> aXDir(new GeomAPI_Dir(aYDir->cross(aNormDir)));
+
+  std::shared_ptr<GeomDataAPI_Point> anOrigin = std::dynamic_pointer_cast<GeomDataAPI_Point>(
+      aData->attribute(SketchPlugin_Sketch::ORIGIN_ID()));
+  anOrigin->setValue(anOrigPnt);
+  std::shared_ptr<GeomDataAPI_Dir> aNormal = std::dynamic_pointer_cast<GeomDataAPI_Dir>(
+      aData->attribute(SketchPlugin_Sketch::NORM_ID()));
+  aNormal->setValue(aNormDir);
+  std::shared_ptr<GeomDataAPI_Dir> aDirX = std::dynamic_pointer_cast<GeomDataAPI_Dir>(
+      aData->attribute(SketchPlugin_Sketch::DIRX_ID()));
+  aDirX->setValue(aXDir);
+  std::shared_ptr<GeomDataAPI_Dir> aDirY = std::dynamic_pointer_cast<GeomDataAPI_Dir>(
+      aData->attribute(SketchPlugin_Sketch::DIRY_ID()));
+  aDirY->setValue(aYDir);
+  std::shared_ptr<GeomAPI_Dir> aDir = aPlane->direction();
+  return aDir;
+}
+
+
+void PartSet_WidgetSketchLabel::setSketchingMode()
+{
+  XGUI_Displayer* aDisp = myWorkshop->displayer();
+  QIntList aModes;
+  // Clear standard selection modes if they are defined
+  aDisp->activateObjects(aModes);
+  aDisp->openLocalContext();
+
+  // Set filter
+  std::shared_ptr<GeomAPI_Pln> aPlane = plane();
+  double aA, aB, aC, aD;
+  aPlane->coefficients(aA, aB, aC, aD);
+  gp_Pln aPln(aA, aB, aC, aD);
+  // No selection of external objects
+  //mySketchFilter = new ModuleBase_ShapeInPlaneFilter(aPln);
+  //aDisp->addSelectionFilter(mySketchFilter);
+
+  // Get default selection modes
+  aModes.append(AIS_DSM_Text);
+  aModes.append(AIS_DSM_Line);
+  aModes.append(AIS_Shape::SelectionMode((TopAbs_ShapeEnum) TopAbs_VERTEX));
+  aModes.append(AIS_Shape::SelectionMode((TopAbs_ShapeEnum) TopAbs_EDGE));
+
+  aDisp->activateObjects(aModes);
+}
index 5ad06d65d615ccac1f197b7cba1ded407f22b026..58816ee4c7cfde676b82b90e230835db9caf7410 100644 (file)
@@ -1,3 +1,5 @@
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
 // File:        PartSet_WidgetSketchLabel.h
 // Created:     07 July 2014
 // Author:      Vitaly SMETANNIKOV
 #include "PartSet.h"
 
 #include <ModuleBase_ModelWidget.h>
+#include <ModuleBase_ViewerFilters.h>
+
+#include <GeomAPI_Pnt.h>
+#include <GeomAPI_Dir.h>
+#include <GeomAPI_AISObject.h>
+
+#include <StdSelect_FaceFilter.hxx>
+#include <TopoDS_Shape.hxx>
 
 class QLabel;
 class XGUI_OperationMgr;
-class PartSet_OperationSketch;
+class XGUI_Workshop;
+//class PartSet_OperationSketch;
 
 class PARTSET_EXPORT PartSet_WidgetSketchLabel : public ModuleBase_ModelWidget
 {
@@ -20,9 +31,7 @@ Q_OBJECT
   PartSet_WidgetSketchLabel(QWidget* theParent, const Config_WidgetAPI* theData,
                             const std::string& theParentId);
 
-  virtual ~PartSet_WidgetSketchLabel()
-  {
-  }
+  virtual ~PartSet_WidgetSketchLabel();
 
   /// Saves the internal parameters to the given feature
   /// \param theFeature a model feature to be changed
@@ -42,17 +51,49 @@ Q_OBJECT
 
   QWidget* getControl() const;
 
-  void setOperationsMgr(XGUI_OperationMgr* theMgr);
+  /// The methiod called when widget is activated
+  virtual void activate();
+
+  /// The methiod called when widget is deactivated
+  virtual void deactivate();
+
+  XGUI_Workshop* workshop() const { return myWorkshop; }
+
+  void setWorkshop(XGUI_Workshop* theWork) { myWorkshop = theWork; }
+
+  std::shared_ptr<GeomAPI_Pln> plane() const;
+
+signals:
+  void planeSelected(const std::shared_ptr<GeomAPI_Pln>& thePln);
 
  private slots:
   void onPlaneSelected();
 
  private:
-  void updateLabel(PartSet_OperationSketch* theSketchOpe);
+  AISObjectPtr createPreviewPlane(std::shared_ptr<GeomAPI_Pnt> theOrigin, 
+                                  std::shared_ptr<GeomAPI_Dir> theNorm, 
+                                  const int theRGB[3]);
+
+  std::shared_ptr<GeomAPI_Dir> setSketchPlane(const TopoDS_Shape& theShape);
+
+  void erasePreviewPlanes();
+  void showPreviewPlanes();
+
+  void setSketchingMode();
 
   QLabel* myLabel;
   QString myText;
   QString myTooltip;
+
+  XGUI_Workshop* myWorkshop;
+
+  AISObjectPtr myYZPlane;
+  AISObjectPtr myXZPlane;
+  AISObjectPtr myXYPlane;
+  bool myPreviewDisplayed;
+
+  Handle(StdSelect_FaceFilter) myFaceFilter;
+  //Handle(ModuleBase_ShapeInPlaneFilter) mySketchFilter;
 };
 
 #endif
index d0985d40c5d7573a235bb9a03823ae65bdd2bda7..b0bffcc5ae59cd015c706a1ed2578748543181fb 100644 (file)
@@ -27,5 +27,6 @@
      <file>icons/radius_constr.png</file>
      <file>icons/shape_group.png</file>
      <file>icons/fixed.png</file>
+     <file>icons/placement.png</file>
  </qresource>
  </RCC>
index 074c67dea0a71899291df86473acc5ff17550356..e2c53777f8a78dfa84532d9bcaf2b29344d9990a 100644 (file)
Binary files a/src/PartSet/icons/arc.png and b/src/PartSet/icons/arc.png differ
index 5f5bfffd87ca0369d07c9559318ebeb05057b39e..4857985acd5575d6852efe5e8e7b66126a69adfe 100644 (file)
Binary files a/src/PartSet/icons/axis.png and b/src/PartSet/icons/axis.png differ
index 35f20804e63c150e81b78be80e32474caa2c1c46..0c2ee1b09b3a1485e3b1b7475c9a47ef4e7cb354 100644 (file)
Binary files a/src/PartSet/icons/circle.png and b/src/PartSet/icons/circle.png differ
index 7deab358a033d23669225bdb6e5904430dac6479..6c2602bfef0de5c9dc93c44ff7084838ed416dc0 100644 (file)
Binary files a/src/PartSet/icons/common.png and b/src/PartSet/icons/common.png differ
index 12bbe4530abf1b5b0e8a64528c9fc6c1ee093df1..be530811a9188c9e993cd6f08c1f9f54dd4a80ee 100644 (file)
Binary files a/src/PartSet/icons/extrusion.png and b/src/PartSet/icons/extrusion.png differ
index 7786e85d73edc65e3aa8352278aad8f0f756727d..30ac8421fc291d35278ed5dadab639c55cf2817f 100644 (file)
Binary files a/src/PartSet/icons/import.png and b/src/PartSet/icons/import.png differ
index 6176fb62db49ec8daebfdb8e60c6cee2eb1f75e7..ba50033c113e08146c2dd5e824a780d901d447e2 100644 (file)
Binary files a/src/PartSet/icons/line.png and b/src/PartSet/icons/line.png differ
diff --git a/src/PartSet/icons/placement.png b/src/PartSet/icons/placement.png
new file mode 100644 (file)
index 0000000..22c41da
Binary files /dev/null and b/src/PartSet/icons/placement.png differ
index 3075a34aab64f7d69b4e5bd89b900a554cfa436f..8194bc92c9126b8c68703240386e6262bb8441ce 100644 (file)
Binary files a/src/PartSet/icons/plane.png and b/src/PartSet/icons/plane.png differ
index de84d9652ed8697df71d5ab5fae610b2f8a826d0..e140db67293b2d454a632156376ba4e97856a922 100644 (file)
Binary files a/src/PartSet/icons/point.png and b/src/PartSet/icons/point.png differ
index 3400b6200e3a902c870fcbf4ffbcdac9a33d629c..22ebbf37b401b1721192176a54f0fb3e39f797cc 100644 (file)
Binary files a/src/PartSet/icons/revol.png and b/src/PartSet/icons/revol.png differ
index f2964c744f94c68e79bfac572cfc1f6d974d018d..10374e2ece806ddb209f273228de0d44cee4cb47 100644 (file)
Binary files a/src/PartSet/icons/sketch.png and b/src/PartSet/icons/sketch.png differ
index e115ab9db5433d23f261f48b55a0d7a0b81badbe..cd3dcad9478402b5244761c09e2cf7d8ccd4ab26 100644 (file)
@@ -1,3 +1,5 @@
+## Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
 INCLUDE(Common)
 
 SET(PROJECT_HEADERS
@@ -15,18 +17,19 @@ SET(PROJECT_SOURCES
     PartSetPlugin_Remove.cpp
 )
 
+SET(XML_RESOURCES
+  plugin-PartSet.xml
+)
+
 ADD_DEFINITIONS(-DPARTSETPLUGIN_EXPORTS)
-ADD_LIBRARY(PartSetPlugin MODULE ${PROJECT_SOURCES} ${PROJECT_HEADERS})
+ADD_LIBRARY(PartSetPlugin MODULE ${PROJECT_SOURCES} ${PROJECT_HEADERS} ${XML_RESOURCES})
 TARGET_LINK_LIBRARIES(PartSetPlugin ${PROJECT_LIBRARIES} ModelAPI)
 
 INCLUDE_DIRECTORIES(
+  ../Events
   ../ModelAPI
   ../GeomAPI
 )
 
-SET(XML_RESOURCES
-  plugin-PartSet.xml
-)
-
 INSTALL(TARGETS PartSetPlugin DESTINATION plugins)
 INSTALL(FILES ${XML_RESOURCES} DESTINATION plugins)
index 50b7e8ef0b8c0c0600768d72e62a8ec083522dd3..786c6e82daeb42893c231d2ecd04886b4d8812a1 100644 (file)
@@ -1,3 +1,5 @@
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
 #ifndef PARTSETPLUGIN_H
 #define PARTSETPLUGIN_H
 
index f92c0e912a895a79b195896df95811709a704f39..37ff14adda0865bf2aeae1e5087d5044c27ae6b7 100644 (file)
@@ -1,3 +1,5 @@
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
 // File:        PartSetPlugin_Duplicate.cxx
 // Created:     20 May 2014
 // Author:      Mikhail PONIKAROV
index f327aa7f2ed382c0598aa1e162910ca42a334fa1..9ace34a5c8270f11cb4dad6b42a5b40e5c418858 100644 (file)
@@ -1,3 +1,5 @@
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
 // File:        PartSetPlugin_Duplicate.h
 // Created:     20 May 2014
 // Author:      Mikhail PONIKAROV
index 47fa360a9ee84a6163d0d966c1e26a72d5cf8574..58c2d85fd3384c6ca14a7a3506ce77c5a0306ecf 100644 (file)
@@ -1,3 +1,5 @@
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
 // File:        PartSetPlugin_Part.cxx
 // Created:     27 Mar 2014
 // Author:      Mikhail PONIKAROV
index 5a9b4202ceebd37a2f5328f3dd022fc02ce674f9..590d69562d70b8d2de6fdad673609a520cf4082f 100644 (file)
@@ -1,3 +1,5 @@
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
 // File:        PartSetPlugin_Part.h
 // Created:     27 Mar 2014
 // Author:      Mikhail PONIKAROV
index 31c80e4953a769853494e17e785805c59b6b3a7e..c4d50434636509f50168f7a0aef153dd3e96e73b 100644 (file)
@@ -1,10 +1,19 @@
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
 #include "PartSetPlugin_Plugin.h"
 #include "PartSetPlugin_Part.h"
 #include "PartSetPlugin_Duplicate.h"
 #include "PartSetPlugin_Remove.h"
+
+#include <Events_Loop.h>
+
 #include <ModelAPI_Session.h>
 #include <ModelAPI_Document.h>
 
+#ifdef _DEBUG
+#include <iostream>
+#endif
+
 using namespace std;
 
 // the only created instance of this plugin
@@ -30,3 +39,31 @@ FeaturePtr PartSetPlugin_Plugin::createFeature(string theFeatureID)
   // feature of such kind is not found
   return FeaturePtr();
 }
+
+void PartSetPlugin_Plugin::processEvent(const std::shared_ptr<Events_Message>& theMessage)
+{
+  const Events_ID kRequestEvent =
+      Events_Loop::loop()->eventByName(EVENT_FEATURE_STATE_REQUEST);
+  if (theMessage->eventID() == kRequestEvent) {
+    Events_Loop::loop()->send(getFeaturesState(), false);
+  } else if (theMessage.get()) {
+    #ifdef _DEBUG
+    std::cout << "PartSetPlugin_Plugin::processEvent: unhandled message caught: " << std::endl
+              << theMessage->eventID().eventText() << std::endl;
+    #endif
+  }
+}
+
+std::shared_ptr<ModelAPI_FeatureStateMessage> PartSetPlugin_Plugin::getFeaturesState()
+{
+  const Events_ID kResponseEvent =
+        Events_Loop::loop()->eventByName(EVENT_FEATURE_STATE_RESPONSE);
+  std::shared_ptr<ModelAPI_FeatureStateMessage> aMsg =
+      std::make_shared<ModelAPI_FeatureStateMessage>(kResponseEvent, this);
+  std::string aStdDocKind = ModelAPI_Session::get()->activeDocument()->kind();
+  bool aDocIsPart = (aStdDocKind == PartSetPlugin_Part::ID());
+  aMsg->setState(PartSetPlugin_Part::ID(), true);
+  aMsg->setState(PartSetPlugin_Duplicate::ID(), aDocIsPart);
+  aMsg->setState(PartSetPlugin_Remove::ID(), aDocIsPart);
+  return aMsg;
+}
index 5d91f7d46fb0b44cbcf183ed501ba6950d6b44ab..364ebb48dfbf4f12e2fbd571930136890e3c3b0b 100644 (file)
@@ -1,3 +1,5 @@
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
 // File:        PartSetPlugin_Plugin.hxx
 // Created:     31 Mar 2014
 // Author:      Mikhail PONIKAROV
@@ -5,18 +7,28 @@
 #ifndef PartSetPlugin_Plugin_H_
 #define PartSetPlugin_Plugin_H_
 
-#include "PartSetPlugin.h"
-#include "ModelAPI_Plugin.h"
-#include "ModelAPI_Feature.h"
+#include <PartSetPlugin.h>
+#include <ModelAPI_Plugin.h>
+#include <ModelAPI_Feature.h>
+#include <ModelAPI_Events.h>
+
+#include <Events_Listener.h>
+
+#include <memory>
 
-class PARTSETPLUGIN_EXPORT PartSetPlugin_Plugin : public ModelAPI_Plugin
+class PARTSETPLUGIN_EXPORT PartSetPlugin_Plugin : public ModelAPI_Plugin,
+                                                  public Events_Listener
 {
  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
   PartSetPlugin_Plugin();
+
+  //! Redefinition of Events_Listener method
+  virtual void processEvent(const std::shared_ptr<Events_Message>& theMessage);
+  std::shared_ptr<ModelAPI_FeatureStateMessage> getFeaturesState();
 };
 
 #endif
index 3f2cd80fe609d6724d1c41f30247cae83bbba9db..d77712bb34a01cd5c025da5b44165a95fc525dc8 100644 (file)
@@ -1,3 +1,5 @@
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
 // File:        PartSetPlugin_Remove.cxx
 // Created:     20 May 2014
 // Author:      Mikhail PONIKAROV
index bbb23be03f0779399a4493648af12c9a1c0bbdbe..c29028d39fbc0865695dc485d27ddb4b107cad73 100644 (file)
@@ -1,3 +1,5 @@
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
 // File:        PartSetPlugin_Remove.h
 // Created:     20 May 2014
 // Author:      Mikhail PONIKAROV
index 4a846cc42a98088901b5d05ae21d98a8f31b1b77..248ac5426d4ec3d6264b4b172376a96bff675ff6 100644 (file)
@@ -1,9 +1,18 @@
+<!-- Copyright (C) 2014-20xx CEA/DEN, EDF R&D -->
+
 <plugin>
   <workbench id="Part">
     <group id="Operations">
       <feature id="Part" title="New part" tooltip="Create a new part" icon=":pictures/part_ico.png"/>
-      <feature id="Duplicate" title="Duplicate" tooltip="Duplicate selected part" icon=":icons/duplicate.png"/>
-      <feature id="Remove" title="Remove part"  tooltip="Remove active part" icon=":icons/remove.png"/>
+      <feature id="Duplicate" title="Duplicate"
+               tooltip="Duplicate selected part"
+               icon=":icons/duplicate.png"
+               document="Part"/>
+      <feature id="Remove"
+               title="Remove part"
+               tooltip="Remove active part"
+               icon=":icons/remove.png"
+               document="Part"/>
     </group>
   </workbench>
 </plugin>
index 593f10bd87f17c22f2255b5da3be2d2336a14de4..d801aabacb294e48c188df5d896674172be61454 100644 (file)
@@ -1,3 +1,5 @@
+## Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
 INCLUDE(Common)
 INCLUDE(UnitTest)
 
@@ -62,6 +64,7 @@ TARGET_LINK_LIBRARIES(SketchPlugin ${PROJECT_LIBRARIES})
 
 INCLUDE_DIRECTORIES(
   ../Config
+  ../Events
   ../ModelAPI
   ../GeomAPI
   ../GeomAlgoAPI
@@ -79,4 +82,6 @@ ADD_UNIT_TESTS(TestSketchPointLine.py
                TestConstraintParallel.py
                TestConstraintPerpendicular.py
                TestConstraintRadius.py
-               TestConstraintRigid.py)
+               TestConstraintRigid.py
+               TestHighload.py
+               TestSnowflake.py)
index b7a5fcf1136c85d877475167672311e79e41c426..a8a7b8b7ec5d144e89b58fb4dbcbf98269b1db1c 100644 (file)
@@ -1,3 +1,5 @@
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D -->
+
 #ifndef SKETCHPLUGIN_H
 #define SKETCHPLUGIN_H
 
index 9f717bd702ff3279625c7fc1717d464c347d3aaa..d6a6facfae37ceaa3eeaef964b49e10d53eedbaf 100644 (file)
@@ -1,3 +1,5 @@
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D -->
+
 // File:        SketchPlugin_Arc.cpp
 // Created:     26 Apr 2014
 // Author:      Artem ZHIDKOV
@@ -23,6 +25,8 @@ const double tolerance = 1e-7;
 SketchPlugin_Arc::SketchPlugin_Arc()
     : SketchPlugin_Feature()
 {
+  myStartUpdate = false;
+  myEndUpdate = false;
 }
 
 void SketchPlugin_Arc::initAttributes()
@@ -42,10 +46,10 @@ void SketchPlugin_Arc::execute()
   if (aSketch && isFeatureValid()) {
     // compute a circle point in 3D view
     std::shared_ptr<GeomDataAPI_Point2D> aCenterAttr = std::dynamic_pointer_cast<
-        GeomDataAPI_Point2D>(data()->attribute(SketchPlugin_Arc::CENTER_ID()));
+        GeomDataAPI_Point2D>(data()->attribute(CENTER_ID()));
     // compute the arc start point
     std::shared_ptr<GeomDataAPI_Point2D> aStartAttr = std::dynamic_pointer_cast<
-        GeomDataAPI_Point2D>(data()->attribute(SketchPlugin_Arc::START_ID()));
+        GeomDataAPI_Point2D>(data()->attribute(START_ID()));
 
     std::shared_ptr<GeomAPI_Pnt> aCenter(aSketch->to3D(aCenterAttr->x(), aCenterAttr->y()));
     // make a visible point
@@ -59,30 +63,29 @@ void SketchPlugin_Arc::execute()
     // make a visible circle
     std::shared_ptr<GeomDataAPI_Dir> aNDir = std::dynamic_pointer_cast<GeomDataAPI_Dir>(
         aSketch->data()->attribute(SketchPlugin_Sketch::NORM_ID()));
-    bool aHasPlane = aNDir && !(aNDir->x() == 0 && aNDir->y() == 0 && aNDir->z() == 0);
-    if (aHasPlane) {
-      std::shared_ptr<GeomAPI_Dir> aNormal = aNDir->dir();
-      std::shared_ptr<GeomAPI_Pnt> aStartPoint(aSketch->to3D(aStartAttr->x(), aStartAttr->y()));
-
-      // compute and change the arc end point
-      std::shared_ptr<GeomDataAPI_Point2D> anEndAttr = std::dynamic_pointer_cast<
-          GeomDataAPI_Point2D>(data()->attribute(SketchPlugin_Arc::END_ID()));
-      std::shared_ptr<GeomAPI_Circ2d> aCircleForArc(
-          new GeomAPI_Circ2d(aCenterAttr->pnt(), aStartAttr->pnt()));
-      std::shared_ptr<GeomAPI_Pnt2d> aProjection = aCircleForArc->project(anEndAttr->pnt());
-      if (aProjection && anEndAttr->pnt()->distance(aProjection) > tolerance)
-        anEndAttr->setValue(aProjection);
-      std::shared_ptr<GeomAPI_Pnt> aEndPoint(aSketch->to3D(anEndAttr->x(), anEndAttr->y()));
-
-      std::shared_ptr<GeomAPI_Shape> aCircleShape = GeomAlgoAPI_EdgeBuilder::lineCircleArc(
-          aCenter, aStartPoint, aEndPoint, aNormal);
-      if (aCircleShape) {
-        std::shared_ptr<ModelAPI_ResultConstruction> aConstr2 = document()->createConstruction(
-            data(), 1);
-        aConstr2->setShape(aCircleShape);
-        aConstr2->setIsInHistory(false);
-        setResult(aConstr2, 1);
-      }
+    std::shared_ptr<GeomAPI_Dir> aNormal = aNDir->dir();
+    std::shared_ptr<GeomAPI_Pnt> aStartPoint(aSketch->to3D(aStartAttr->x(), aStartAttr->y()));
+
+    // compute and change the arc end point
+    std::shared_ptr<GeomDataAPI_Point2D> anEndAttr = std::dynamic_pointer_cast<
+        GeomDataAPI_Point2D>(data()->attribute(END_ID()));
+    /* must be automatically done in attributeChanged
+    std::shared_ptr<GeomAPI_Circ2d> aCircleForArc(
+        new GeomAPI_Circ2d(aCenterAttr->pnt(), aStartAttr->pnt()));
+    std::shared_ptr<GeomAPI_Pnt2d> aProjection = aCircleForArc->project(anEndAttr->pnt());
+    if (aProjection && anEndAttr->pnt()->distance(aProjection) > tolerance)
+      anEndAttr->setValue(aProjection);
+    */
+    std::shared_ptr<GeomAPI_Pnt> aEndPoint(aSketch->to3D(anEndAttr->x(), anEndAttr->y()));
+
+    std::shared_ptr<GeomAPI_Shape> aCircleShape = GeomAlgoAPI_EdgeBuilder::lineCircleArc(
+        aCenter, aStartPoint, aEndPoint, aNormal);
+    if (aCircleShape) {
+      std::shared_ptr<ModelAPI_ResultConstruction> aConstr2 = document()->createConstruction(
+          data(), 1);
+      aConstr2->setShape(aCircleShape);
+      aConstr2->setIsInHistory(false);
+      setResult(aConstr2, 1);
     }
   }
 }
@@ -95,7 +98,7 @@ AISObjectPtr SketchPlugin_Arc::getAISObject(AISObjectPtr thePrevious)
     if (!isFeatureValid()) {
       // compute a circle point in 3D view
       std::shared_ptr<GeomDataAPI_Point2D> aCenterAttr = std::dynamic_pointer_cast<
-          GeomDataAPI_Point2D>(data()->attribute(SketchPlugin_Arc::CENTER_ID()));
+          GeomDataAPI_Point2D>(data()->attribute(CENTER_ID()));
       if (aCenterAttr->isInitialized()) {
         std::shared_ptr<GeomAPI_Pnt> aCenter(aSketch->to3D(aCenterAttr->x(), aCenterAttr->y()));
 
@@ -125,6 +128,7 @@ AISObjectPtr SketchPlugin_Arc::getAISObject(AISObjectPtr thePrevious)
                 if (!anAIS)
                   anAIS = AISObjectPtr(new GeomAPI_AISObject);
                 anAIS->createShape(aCompound);
+                anAIS->setWidth(3);
                 return anAIS;
               }
             }
@@ -146,6 +150,8 @@ void SketchPlugin_Arc::move(double theDeltaX, double theDeltaY)
       aData->attribute(SketchPlugin_Arc::CENTER_ID()));
   aPoint1->move(theDeltaX, theDeltaY);
 
+  myStartUpdate = true;
+  myEndUpdate = true;
   std::shared_ptr<GeomDataAPI_Point2D> aPoint2 = std::dynamic_pointer_cast<GeomDataAPI_Point2D>(
       aData->attribute(SketchPlugin_Arc::START_ID()));
   aPoint2->move(theDeltaX, theDeltaY);
@@ -153,6 +159,8 @@ void SketchPlugin_Arc::move(double theDeltaX, double theDeltaY)
   std::shared_ptr<GeomDataAPI_Point2D> aPoint3 = std::dynamic_pointer_cast<GeomDataAPI_Point2D>(
       aData->attribute(SketchPlugin_Arc::END_ID()));
   aPoint3->move(theDeltaX, theDeltaY);
+  myStartUpdate = false;
+  myEndUpdate = false;
 }
 
 double SketchPlugin_Arc::distanceToPoint(const std::shared_ptr<GeomAPI_Pnt2d>& thePoint)
@@ -194,3 +202,40 @@ bool SketchPlugin_Arc::isFeatureValid()
 
   return aCenterAttr->isInitialized() && aStartAttr->isInitialized() && anEndAttr->isInitialized();
 }
+
+void SketchPlugin_Arc::attributeChanged(const std::string& theID)
+{
+  std::shared_ptr<GeomDataAPI_Point2D> aCenterAttr = std::dynamic_pointer_cast<
+      GeomDataAPI_Point2D>(data()->attribute(CENTER_ID()));
+  if (!aCenterAttr->isInitialized())
+    return;
+  std::shared_ptr<GeomDataAPI_Point2D> aStartAttr = std::dynamic_pointer_cast<
+      GeomDataAPI_Point2D>(data()->attribute(START_ID()));
+  if (!aStartAttr->isInitialized())
+    return;
+  std::shared_ptr<GeomDataAPI_Point2D> anEndAttr = std::dynamic_pointer_cast<
+      GeomDataAPI_Point2D>(data()->attribute(END_ID()));
+  if (!anEndAttr->isInitialized())
+    return;
+
+  // update the points in accordance to the changed point changes
+  if (theID == END_ID() && !myEndUpdate) {
+    myEndUpdate = true;
+    // compute and change the arc end point
+    std::shared_ptr<GeomAPI_Circ2d> aCircleForArc(
+        new GeomAPI_Circ2d(aCenterAttr->pnt(), aStartAttr->pnt()));
+    std::shared_ptr<GeomAPI_Pnt2d> aProjection = aCircleForArc->project(anEndAttr->pnt());
+    if (aProjection && anEndAttr->pnt()->distance(aProjection) > tolerance)
+      anEndAttr->setValue(aProjection);
+    myEndUpdate = false;
+  } else if (theID == START_ID() && !myStartUpdate) {
+    myStartUpdate = true;
+    // compute and change the arc end point
+    std::shared_ptr<GeomAPI_Circ2d> aCircleForArc(
+        new GeomAPI_Circ2d(aCenterAttr->pnt(), anEndAttr->pnt()));
+    std::shared_ptr<GeomAPI_Pnt2d> aProjection = aCircleForArc->project(aStartAttr->pnt());
+    if (aProjection && aStartAttr->pnt()->distance(aProjection) > tolerance)
+      aStartAttr->setValue(aProjection);
+    myStartUpdate = false;
+  }
+}
index 3958adbd743a464b3614b0e8df0b25e967e63a5d..f24af300f5e0cad2a6dbb81830b6b6e2fe2684b4 100644 (file)
@@ -1,3 +1,5 @@
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D -->
+
 // File:        SketchPlugin_Arc.h
 // Created:     26 May 2014
 // Author:      Artem ZHIDKOV
  */
 class SketchPlugin_Arc : public SketchPlugin_Feature, public GeomAPI_IPresentable
 {
+  /// to avoid cyclic dependencies in automatic updates: they mean that 
+  /// update is performed right now and automatic updates are not needed
+  bool myStartUpdate, myEndUpdate;
+
  public:
   /// Arc feature kind
   inline static const std::string& ID()
@@ -62,6 +68,10 @@ class SketchPlugin_Arc : public SketchPlugin_Feature, public GeomAPI_IPresentabl
   /// Request for initialization of data model of the feature: adding all attributes
   SKETCHPLUGIN_EXPORT virtual void initAttributes();
 
+  /// Called on change of any argument-attribute of this object
+  /// \param theID identifier of changed attribute
+  SKETCHPLUGIN_EXPORT virtual void attributeChanged(const std::string& theID);
+
   /// Returns the AIS preview
   virtual AISObjectPtr getAISObject(AISObjectPtr thePrevious);
 
index 209f9744a7310e9483a080a96033975dd4f91599..5fde3dfbe18e4b4cde24868d3243e14786e7a934 100644 (file)
@@ -1,3 +1,5 @@
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D -->
+
 // File:        SketchPlugin_Circle.cpp
 // Created:     26 May 2014
 // Author:      Artem ZHIDKOV
@@ -100,18 +102,17 @@ bool SketchPlugin_Circle::isFixed() {
   return data()->selection(EXTERNAL_ID())->context();
 }
 
-void SketchPlugin_Circle::attributeChanged() {
-  static bool myIsUpdated = false; // to avoid infinitive cycle on attrubtes change
-  std::shared_ptr<GeomAPI_Shape> aSelection = data()->selection(EXTERNAL_ID())->value();
-  // update arguments due to the selection value
-  if (aSelection && !aSelection->isNull() && aSelection->isEdge() && !myIsUpdated) {
-    myIsUpdated = true;
-    std::shared_ptr<GeomAPI_Edge> anEdge( new GeomAPI_Edge(aSelection));
-    std::shared_ptr<GeomAPI_Circ> aCirc = anEdge->circle();
-    std::shared_ptr<GeomDataAPI_Point2D> aCenterAttr = 
-      std::dynamic_pointer_cast<GeomDataAPI_Point2D>(attribute(CENTER_ID()));
-    aCenterAttr->setValue(sketch()->to2D(aCirc->center()));
-    real(RADIUS_ID())->setValue(aCirc->radius());
-    myIsUpdated = false;
+void SketchPlugin_Circle::attributeChanged(const std::string& theID) {
+  if (theID == EXTERNAL_ID()) {
+    std::shared_ptr<GeomAPI_Shape> aSelection = data()->selection(EXTERNAL_ID())->value();
+    // update arguments due to the selection value
+    if (aSelection && !aSelection->isNull() && aSelection->isEdge()) {
+      std::shared_ptr<GeomAPI_Edge> anEdge( new GeomAPI_Edge(aSelection));
+      std::shared_ptr<GeomAPI_Circ> aCirc = anEdge->circle();
+      std::shared_ptr<GeomDataAPI_Point2D> aCenterAttr = 
+        std::dynamic_pointer_cast<GeomDataAPI_Point2D>(attribute(CENTER_ID()));
+      aCenterAttr->setValue(sketch()->to2D(aCirc->center()));
+      real(RADIUS_ID())->setValue(aCirc->radius());
+    }
   }
 }
index 8ceef34ebce1a521f54428ffa9a8a9e1b0c68965..76bac7887bf111ab1f23b7b131714f4bc344820d 100644 (file)
@@ -1,3 +1,5 @@
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D -->
+
 // File:        SketchPlugin_Circle.h
 // Created:     26 May 2014
 // Author:      Artem ZHIDKOV
@@ -14,7 +16,7 @@
  * \ingroup DataModel
  * \brief Feature for creation of the new circle in PartSet.
  */
-class SketchPlugin_Circle : public SketchPlugin_Feature  //, public GeomAPI_IPresentable
+class SketchPlugin_Circle : public SketchPlugin_Feature 
 {
  public:
   /// Circle feature kind
@@ -54,12 +56,6 @@ class SketchPlugin_Circle : public SketchPlugin_Feature  //, public GeomAPI_IPre
   /// Request for initialization of data model of the feature: adding all attributes
   SKETCHPLUGIN_EXPORT virtual void initAttributes();
 
-  /// Returns the AIS preview
-  virtual AISObjectPtr getAISObject(AISObjectPtr thePrevious)
-  {
-    return simpleAISObject(firstResult(), thePrevious);
-  }
-
   /// Adds sub-feature of the higher level feature (sub-element of the sketch)
   /// \param theFeature sub-feature
   SKETCHPLUGIN_EXPORT virtual const void addSub(const FeaturePtr& theFeature)
@@ -77,7 +73,7 @@ class SketchPlugin_Circle : public SketchPlugin_Feature  //, public GeomAPI_IPre
   virtual double distanceToPoint(const std::shared_ptr<GeomAPI_Pnt2d>& thePoint);
 
   /// Called on change of any argument-attribute of this object
-  SKETCHPLUGIN_EXPORT virtual void attributeChanged();
+  SKETCHPLUGIN_EXPORT virtual void attributeChanged(const std::string& theID);
 
   /// Use plugin manager for features creation
   SketchPlugin_Circle();
index c621c58f562539c7bf06f93233ec821e3ea4330d..62abd9eef9f3dd643fa9de391f78bea3c6c92f03 100644 (file)
@@ -1,3 +1,5 @@
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D -->
+
 // File:    SketchPlugin_Constraint.h
 // Created: 08 May 2014
 // Author:  Artem ZHIDKOV
index 3dd0b92242df83e7874aa4a449b89c84891bee33..63b7b8dd860eb582ff3aa24f33eb6d66266736f6 100644 (file)
@@ -1,3 +1,5 @@
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D -->
+
 // File:    SketchPlugin_ConstraintBase.cpp
 // Created: 08 May 2014
 // Author:  Artem ZHIDKOV
index 7299aabe0fe3e19d216c3b05a5fe2c2363fe24d8..721d310292f415a4d799d32eba6b2be84b212054 100644 (file)
@@ -1,3 +1,5 @@
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D -->
+
 // File:    SketchPlugin_ConstraintBase.h
 // Created: 08 May 2014
 // Author:  Artem ZHIDKOV
index fe63928257371a02f9b8f2f6ec4a1257438ff1c7..15f6d1cccfc0844d7e55f573fa3994e588d47781 100644 (file)
@@ -1,3 +1,5 @@
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D -->
+
 // File:    SketchPlugin_ConstraintCoincidence.cpp
 // Created: 08 May 2014
 // Author:  Artem ZHIDKOV
index d14a4b6de371cc9b0c2e8b19926611f04b748828..7abe570f2f3575e1e2b7f5b1709193e39e30cdda 100644 (file)
@@ -1,3 +1,5 @@
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D -->
+
 // File:    SketchPlugin_ConstraintCoincidence.h
 // Created: 08 May 2014
 // Author:  Artem ZHIDKOV
index 611d85a0fba3c238f4605bf9d0ca953736a02906..bdd410ec06de64bf7fb35e2f163e16f8c3de869b 100644 (file)
@@ -1,3 +1,5 @@
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D -->
+
 // File:    SketchPlugin_ConstraintDistance.cpp
 // Created: 23 May 2014
 // Author:  Artem ZHIDKOV
@@ -101,12 +103,12 @@ AISObjectPtr SketchPlugin_ConstraintDistance::getAISObject(AISObjectPtr thePrevi
   // value calculation
   std::shared_ptr<ModelAPI_AttributeDouble> aValueAttr = std::dynamic_pointer_cast<
       ModelAPI_AttributeDouble>(aData->attribute(SketchPlugin_Constraint::VALUE()));
-  double aValue = aValueAttr->value();
+  double aValue = 0;
   // Issue #196: checking the positivity of the distance constraint
   // there is a validator for a distance constraint, that the value should be positive
   // in case if an invalid value is set, the current distance value is shown
-  if (aValue <= 0)
-    aValue = calculateCurrentDistance();
+  if (aValueAttr->isInitialized())
+    aValue = aValueAttr->value();
 
   AISObjectPtr anAIS = thePrevious;
   if (!anAIS)
@@ -162,6 +164,20 @@ double SketchPlugin_ConstraintDistance::calculateCurrentDistance() const
   return aDistance;
 }
 
+void SketchPlugin_ConstraintDistance::attributeChanged(const std::string& theID) {
+  if (theID == SketchPlugin_Constraint::ENTITY_A() || 
+      theID == SketchPlugin_Constraint::ENTITY_B()) 
+  {
+    std::shared_ptr<ModelAPI_AttributeDouble> aValueAttr = std::dynamic_pointer_cast<
+        ModelAPI_AttributeDouble>(data()->attribute(SketchPlugin_Constraint::VALUE()));
+    if (!aValueAttr->isInitialized()) { // only if it is not initialized, try to compute the current value
+      double aDistance = calculateCurrentDistance();
+      if (aDistance > 0) { // set as value the length of updated references
+        aValueAttr->setValue(aDistance);
+      }
+    }
+  }
+}
 
 //*************************************************************************************
 std::shared_ptr<GeomDataAPI_Point2D> getFeaturePoint(DataPtr theData,
index 8ac80c3139df4e41830ff70033cc6095d987cb24..53dfe43e7c010e85184cf73dd4360ec427ac0340 100644 (file)
@@ -1,3 +1,5 @@
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D -->
+
 // File:    SketchPlugin_ConstraintDistance.h
 // Created: 23 May 2014
 // Author:  Artem ZHIDKOV
@@ -56,6 +58,10 @@ class SketchPlugin_ConstraintDistance : public SketchPlugin_ConstraintBase
   /// \param theDeltaY the delta for Y coordinate is moved
   SKETCHPLUGIN_EXPORT virtual void move(const double theDeltaX, const double theDeltaY);
 
+  /// Called on change of any argument-attribute of this object
+  /// \param theID identifier of changed attribute
+  SKETCHPLUGIN_EXPORT virtual void attributeChanged(const std::string& theID);
+
   /// Returns the current distance between the feature attributes
   double calculateCurrentDistance() const;
 
index 5b3d0f05fc5e737bdef61df55ff483b47c597e7c..224ea32b5239cb53b2c8bc06a945a1f17b2aaca6 100644 (file)
@@ -1,3 +1,5 @@
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D -->
+
 // File:    SketchPlugin_ConstraintLength.cpp
 // Created: 30 May 2014
 // Author:  Artem ZHIDKOV
@@ -43,40 +45,49 @@ void SketchPlugin_ConstraintLength::execute()
 
     double aLenght = aPoint1->pnt()->distance(aPoint2->pnt());
 
-    std::shared_ptr<ModelAPI_AttributeDouble> aValueAttr = std::dynamic_pointer_cast<
-        ModelAPI_AttributeDouble>(data()->attribute(SketchPlugin_Constraint::VALUE()));
-    if(!aValueAttr->isInitialized()) {
-      aValueAttr->setValue(aLenght);
-    }
+    //std::shared_ptr<ModelAPI_AttributeDouble> aValueAttr = std::dynamic_pointer_cast<
+    //    ModelAPI_AttributeDouble>(data()->attribute(SketchPlugin_Constraint::VALUE()));
+    //if(!aValueAttr->isInitialized()) {
+    //  aValueAttr->setValue(aLenght);
+    //}
   }
 }
 
-AISObjectPtr SketchPlugin_ConstraintLength::getAISObject(AISObjectPtr thePrevious)
+bool SketchPlugin_ConstraintLength::getPoints(
+  std::shared_ptr<GeomAPI_Pnt>& thePoint1, std::shared_ptr<GeomAPI_Pnt>& thePoint2,
+  std::shared_ptr<GeomDataAPI_Point2D>& theStartPoint,
+  std::shared_ptr<GeomDataAPI_Point2D>& theEndPoint)
 {
   if (!sketch())
-    return thePrevious;
-
+    return false;
   std::shared_ptr<GeomAPI_Pln> aPlane = sketch()->plane();
-
   std::shared_ptr<ModelAPI_AttributeRefAttr> anAttr = std::dynamic_pointer_cast<
       ModelAPI_AttributeRefAttr>(data()->attribute(SketchPlugin_Constraint::ENTITY_A()));
   if (!anAttr)
-    return thePrevious;
+    return false;
   FeaturePtr aFeature = ModelAPI_Feature::feature(anAttr->object());
   if (!aFeature || aFeature->getKind() != SketchPlugin_Line::ID())
-    return thePrevious;
-
-  std::shared_ptr<GeomDataAPI_Point2D> aFlyOutAttr = std::dynamic_pointer_cast<
-      GeomDataAPI_Point2D>(data()->attribute(SketchPlugin_Constraint::FLYOUT_VALUE_PNT()));
-
+    return false;
   DataPtr aData = aFeature->data();
-  std::shared_ptr<GeomDataAPI_Point2D> aStartPoint = std::dynamic_pointer_cast<
+  theStartPoint = std::dynamic_pointer_cast<
       GeomDataAPI_Point2D>(aData->attribute(SketchPlugin_Line::START_ID()));
-  std::shared_ptr<GeomDataAPI_Point2D> anEndPoint = std::dynamic_pointer_cast<
+  theEndPoint = std::dynamic_pointer_cast<
       GeomDataAPI_Point2D>(aData->attribute(SketchPlugin_Line::END_ID()));
+  thePoint1 = sketch()->to3D(theStartPoint->x(), theStartPoint->y());
+  thePoint2 = sketch()->to3D(theEndPoint->x(), theEndPoint->y());
+  return true;
+}
 
-  std::shared_ptr<GeomAPI_Pnt> aPoint1 = sketch()->to3D(aStartPoint->x(), aStartPoint->y());
-  std::shared_ptr<GeomAPI_Pnt> aPoint2 = sketch()->to3D(anEndPoint->x(), anEndPoint->y());
+AISObjectPtr SketchPlugin_ConstraintLength::getAISObject(AISObjectPtr thePrevious)
+{
+  std::shared_ptr<GeomAPI_Pnt> aPoint1, aPoint2;
+  std::shared_ptr<GeomDataAPI_Point2D> aStartPoint, anEndPoint;
+  if (!getPoints(aPoint1, aPoint2, aStartPoint, anEndPoint))
+    return thePrevious; // not possible to show length because points are not defined
+
+  std::shared_ptr<GeomAPI_Pln> aPlane = sketch()->plane();
+  std::shared_ptr<GeomDataAPI_Point2D> aFlyOutAttr = std::dynamic_pointer_cast<
+      GeomDataAPI_Point2D>(data()->attribute(SketchPlugin_Constraint::FLYOUT_VALUE_PNT()));
   std::shared_ptr<GeomAPI_Pnt> aFlyoutPnt = std::shared_ptr<GeomAPI_Pnt>();
   if (aFlyOutAttr->isInitialized()) {
     aFlyoutPnt = sketch()->to3D(aFlyOutAttr->x(), aFlyOutAttr->y());
@@ -89,9 +100,16 @@ AISObjectPtr SketchPlugin_ConstraintLength::getAISObject(AISObjectPtr thePreviou
     aFlyoutPnt = sketch()->to3D(aFPnt->x(), aFPnt->y());
   }
   // value calculation
+  // TODO: has to be calculated on definition of reference object
+  double aDistance = aPoint1->distance(aPoint2);
   std::shared_ptr<ModelAPI_AttributeDouble> aValueAttr = std::dynamic_pointer_cast<
       ModelAPI_AttributeDouble>(data()->attribute(SketchPlugin_Constraint::VALUE()));
-  double aValue = aValueAttr->value();
+  double aValue = aDistance;
+  if (aValueAttr->isInitialized())
+    aValue = aValueAttr->value();
+  else 
+    aValueAttr->setValue(aValue);
+  // End TODO
 
   AISObjectPtr anAIS = thePrevious;
   if (!anAIS)
@@ -99,7 +117,8 @@ AISObjectPtr SketchPlugin_ConstraintLength::getAISObject(AISObjectPtr thePreviou
   anAIS->createDistance(aPoint1, aPoint2, aFlyoutPnt, aPlane, aValue);
 
   // Set color from preferences
-  std::vector<int> aRGB = Config_PropManager::color("Visualization", "length_color", LENGTH_COLOR);
+  std::vector<int> aRGB = 
+    Config_PropManager::color("Visualization", "length_color", LENGTH_COLOR);
   anAIS->setColor(aRGB[0], aRGB[1], aRGB[2]);
   return anAIS;
 }
@@ -115,3 +134,18 @@ void SketchPlugin_ConstraintLength::move(double theDeltaX, double theDeltaY)
   aPoint->move(theDeltaX, theDeltaY);
 }
 
+void SketchPlugin_ConstraintLength::attributeChanged(const std::string& theID) {
+  if (theID == SketchPlugin_Constraint::ENTITY_A()) 
+  {
+    std::shared_ptr<ModelAPI_AttributeDouble> aValueAttr = std::dynamic_pointer_cast<
+      ModelAPI_AttributeDouble>(data()->attribute(SketchPlugin_Constraint::VALUE()));
+    if (!aValueAttr->isInitialized()) { // only if it is not initialized, try to compute the current value
+      std::shared_ptr<GeomAPI_Pnt> aPoint1, aPoint2;
+      std::shared_ptr<GeomDataAPI_Point2D> aStartPoint, anEndPoint;
+      if (getPoints(aPoint1, aPoint2, aStartPoint, anEndPoint)) {
+        double aLength = aPoint1->distance(aPoint2);
+        aValueAttr->setValue(aLength);
+      }
+    }
+  }
+}
index 5f3ae9aae121173e9897dbf8268c5bd2f178c845..68141efa3d76e57a8ed72631673f16d39ae631b7 100644 (file)
@@ -1,3 +1,5 @@
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D -->
+
 // File:    SketchPlugin_ConstraintLength.h
 // Created: 30 May 2014
 // Author:  Artem ZHIDKOV
@@ -10,6 +12,8 @@
 #include <SketchPlugin_Sketch.h>
 #include <list>
 
+class GeomDataAPI_Point2D;
+
 #define LENGTH_COLOR "#ff00ff"
 
 /** \class SketchPlugin_ConstraintLength
@@ -50,8 +54,19 @@ class SketchPlugin_ConstraintLength : public SketchPlugin_ConstraintBase
   /// \param theDeltaY the delta for Y coordinate is moved
   SKETCHPLUGIN_EXPORT virtual void move(const double theDeltaX, const double theDeltaY);
 
+  /// Called on change of any argument-attribute of this object
+  /// \param theID identifier of changed attribute
+  SKETCHPLUGIN_EXPORT virtual void attributeChanged(const std::string& theID);
+
   /// \brief Use plugin manager for features creation
   SketchPlugin_ConstraintLength();
+
+private:
+  // retrns the points-base of length, returns false if it is not possible
+  bool getPoints(
+    std::shared_ptr<GeomAPI_Pnt>& thePoint1, std::shared_ptr<GeomAPI_Pnt>& thePoint2,
+    std::shared_ptr<GeomDataAPI_Point2D>& theStartPoint,
+    std::shared_ptr<GeomDataAPI_Point2D>& theEndPoint);
 };
 
 #endif
index a2f50adf7941a03923ebded51601b6a1f15fd92c..6997f4f0a36fbb8b30a8caa4edabe8573e0a49d0 100644 (file)
@@ -1,3 +1,5 @@
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D -->
+
 // File:    SketchPlugin_ConstraintParallel.cpp
 // Created: 26 May 2014
 // Author:  Artem ZHIDKOV
index 370ff6336997667535bae337433045080bb0af13..6e81c66d367428fe1edc1242cd269d78024002ec 100644 (file)
@@ -1,3 +1,5 @@
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D -->
+
 // File:    SketchPlugin_ConstraintParallel.h
 // Created: 26 May 2014
 // Author:  Artem ZHIDKOV
index e4f396ab747e2a4c43b32e0b04975fdfdd49a865..c63555da559034615fbe754dc73a63acd7cc3e17 100644 (file)
@@ -1,3 +1,5 @@
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D -->
+
 // File:    SketchPlugin_ConstraintPerpendicular.cpp
 // Created: 26 May 2014
 // Author:  Artem ZHIDKOV
index 7847bf4d64856fa284cab7d2b6faa48194476154..1e1953eee9b57a6d096774bc8a0bd8fd41483a0e 100644 (file)
@@ -1,3 +1,5 @@
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D -->
+
 // File:    SketchPlugin_ConstraintPerpendicular.h
 // Created: 26 May 2014
 // Author:  Artem ZHIDKOV
index 8da7b3606dff6ab3091151729d82614c455d7ded..135b6bbdb285d2b66a5671251c11866f814a2869 100644 (file)
@@ -1,3 +1,5 @@
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D -->
+
 // File:    SketchPlugin_ConstraintRadius.cpp
 // Created: 26 May 2014
 // Author:  Artem ZHIDKOV
@@ -53,47 +55,66 @@ void SketchPlugin_ConstraintRadius::execute()
       if (aCenterAttr && aStartAttr)
         aRadius = aCenterAttr->pnt()->distance(aStartAttr->pnt());
     }
-    std::shared_ptr<ModelAPI_AttributeDouble> aValueAttr = std::dynamic_pointer_cast<
-        ModelAPI_AttributeDouble>(data()->attribute(SketchPlugin_Constraint::VALUE()));
-    if(!aValueAttr->isInitialized()) {
-      aValueAttr->setValue(aRadius);
-    }
+    //std::shared_ptr<ModelAPI_AttributeDouble> aValueAttr = std::dynamic_pointer_cast<
+    //    ModelAPI_AttributeDouble>(data()->attribute(SketchPlugin_Constraint::VALUE()));
+    //if(!aValueAttr->isInitialized()) {
+    //  aValueAttr->setValue(aRadius);
+    //}
   }
 }
 
-AISObjectPtr SketchPlugin_ConstraintRadius::getAISObject(AISObjectPtr thePrevious)
+double SketchPlugin_ConstraintRadius::circleRadius(std::shared_ptr<ModelAPI_Feature>& theCirc)
 {
+  static const double kErrorResult = -1.;
   if (!sketch())
-    return thePrevious;
+    return kErrorResult;
 
   std::shared_ptr<ModelAPI_Data> aData = data();
   std::shared_ptr<ModelAPI_AttributeRefAttr> anAttr = std::dynamic_pointer_cast<
       ModelAPI_AttributeRefAttr>(aData->attribute(SketchPlugin_Constraint::ENTITY_A()));
   if (!anAttr)
-    return thePrevious;
-  FeaturePtr aFeature = ModelAPI_Feature::feature(anAttr->object());
-  std::string aKind = aFeature ? aFeature->getKind() : "";
+    return kErrorResult;
+  theCirc = ModelAPI_Feature::feature(anAttr->object());
+  std::string aKind = theCirc ? theCirc->getKind() : "";
   if (aKind != SketchPlugin_Circle::ID() && aKind != SketchPlugin_Arc::ID())
-    return thePrevious;
+    return kErrorResult;
+
+  DataPtr aCircData = theCirc->data();
+  std::shared_ptr<GeomDataAPI_Point2D> aCenterAttr;
+  if (aKind == SketchPlugin_Circle::ID()) {
+    AttributeDoublePtr aCircRadius = std::dynamic_pointer_cast<ModelAPI_AttributeDouble>(
+        aCircData->attribute(SketchPlugin_Circle::RADIUS_ID()));
+    return aCircRadius->value();
+  } else {
+    aCenterAttr = std::dynamic_pointer_cast<GeomDataAPI_Point2D>(
+        aCircData->attribute(SketchPlugin_Arc::CENTER_ID()));
+    std::shared_ptr<GeomDataAPI_Point2D> aStartAttr = std::dynamic_pointer_cast<
+        GeomDataAPI_Point2D>(aCircData->attribute(SketchPlugin_Arc::START_ID()));
+    return aCenterAttr->pnt()->distance(aStartAttr->pnt());
+  }
+  return kErrorResult;
+}
+
+AISObjectPtr SketchPlugin_ConstraintRadius::getAISObject(AISObjectPtr thePrevious)
+{
+  std::shared_ptr<ModelAPI_Feature> aCyrcFeature;
+  double aRadius = circleRadius(aCyrcFeature);
+  if (aRadius < 0)
+    return thePrevious; // can not create a good presentation
 
   // Flyout point
   std::shared_ptr<GeomDataAPI_Point2D> aFlyoutAttr = std::dynamic_pointer_cast<
-      GeomDataAPI_Point2D>(aData->attribute(SketchPlugin_Constraint::FLYOUT_VALUE_PNT()));
+      GeomDataAPI_Point2D>(data()->attribute(SketchPlugin_Constraint::FLYOUT_VALUE_PNT()));
   std::shared_ptr<GeomAPI_Pnt> aFlyoutPnt;
   if (aFlyoutAttr->isInitialized()) {
     aFlyoutPnt = sketch()->to3D(aFlyoutAttr->x(), aFlyoutAttr->y());
   } 
 
   // Prepare a circle
-  aData = aFeature->data();
   std::shared_ptr<GeomDataAPI_Point2D> aCenterAttr;
-  double aRadius;
-  if (aKind == SketchPlugin_Circle::ID()) {
+  if (aCyrcFeature->getKind() == SketchPlugin_Circle::ID()) { // circle
     aCenterAttr = std::dynamic_pointer_cast<GeomDataAPI_Point2D>(
-        aData->attribute(SketchPlugin_Circle::CENTER_ID()));
-    AttributeDoublePtr aCircRadius = std::dynamic_pointer_cast<ModelAPI_AttributeDouble>(
-        aData->attribute(SketchPlugin_Circle::RADIUS_ID()));
-    aRadius = aCircRadius->value();
+        aCyrcFeature->data()->attribute(SketchPlugin_Circle::CENTER_ID()));
     if (!aFlyoutPnt) {
       double aShift = aRadius * 1.1;
       std::shared_ptr<GeomAPI_Pnt2d> aPnt = aCenterAttr->pnt();
@@ -102,15 +123,12 @@ AISObjectPtr SketchPlugin_ConstraintRadius::getAISObject(AISObjectPtr thePreviou
       aFlyoutAttr->setValue(aFPnt);
       aFlyoutPnt = sketch()->to3D(aFPnt->x(), aFPnt->y());
     }
-  } else if (aKind == SketchPlugin_Arc::ID()) {
+  } else { // arc
     aCenterAttr = std::dynamic_pointer_cast<GeomDataAPI_Point2D>(
-        aData->attribute(SketchPlugin_Arc::CENTER_ID()));
-    std::shared_ptr<GeomDataAPI_Point2D> aStartAttr = std::dynamic_pointer_cast<
-        GeomDataAPI_Point2D>(aData->attribute(SketchPlugin_Arc::START_ID()));
-    aRadius = aCenterAttr->pnt()->distance(aStartAttr->pnt());
+        aCyrcFeature->data()->attribute(SketchPlugin_Arc::CENTER_ID()));
     if (!aFlyoutPnt) {
       std::shared_ptr<GeomDataAPI_Point2D> aStartAttr = std::dynamic_pointer_cast<
-        GeomDataAPI_Point2D>(aData->attribute(SketchPlugin_Arc::START_ID()));      
+        GeomDataAPI_Point2D>(aCyrcFeature->data()->attribute(SketchPlugin_Arc::START_ID()));      
       aFlyoutAttr->setValue(aStartAttr->pnt());
       aFlyoutPnt = sketch()->to3D(aStartAttr->pnt()->x(), aStartAttr->pnt()->y());
     }
@@ -124,15 +142,13 @@ AISObjectPtr SketchPlugin_ConstraintRadius::getAISObject(AISObjectPtr thePreviou
 
   // Value
   std::shared_ptr<ModelAPI_AttributeDouble> aValueAttr = std::dynamic_pointer_cast<
-      ModelAPI_AttributeDouble>(aData->attribute(SketchPlugin_Constraint::VALUE()));
-  double aValue = aRadius;
-  if (aValueAttr && aValueAttr->isInitialized())
-    aValue = aValueAttr->value();
-
+      ModelAPI_AttributeDouble>(data()->attribute(SketchPlugin_Constraint::VALUE()));
+  if (aValueAttr->isInitialized())
+    aRadius = aValueAttr->value();
   AISObjectPtr anAIS = thePrevious;
   if (!anAIS)
     anAIS = AISObjectPtr(new GeomAPI_AISObject);
-  anAIS->createRadius(aCircle, aFlyoutPnt, aValue);
+  anAIS->createRadius(aCircle, aFlyoutPnt, aRadius);
 
   // Set color from preferences
   std::vector<int> aRGB = Config_PropManager::color("Visualization", "radius_color", RADIUS_COLOR);
@@ -177,3 +193,17 @@ void SketchPlugin_ConstraintRadius::move(double theDeltaX, double theDeltaY)
 
   aFlyoutAttr->setValue(aFlyout->x(), aFlyout->y());
 }
+
+void SketchPlugin_ConstraintRadius::attributeChanged(const std::string& theID) {
+  if (theID == SketchPlugin_Constraint::ENTITY_A()) {
+    std::shared_ptr<ModelAPI_AttributeDouble> aValueAttr = std::dynamic_pointer_cast<
+        ModelAPI_AttributeDouble>(data()->attribute(SketchPlugin_Constraint::VALUE()));
+    if (!aValueAttr->isInitialized()) { // only if it is not initialized, try to compute the current value
+      std::shared_ptr<ModelAPI_Feature> aCyrcFeature;
+      double aRadius = circleRadius(aCyrcFeature);
+      if (aRadius > 0) { // set as value the radius of updated reference to another circle
+        aValueAttr->setValue(aRadius);
+      }
+    }
+  }
+}
index 96e295e1b50f0227b3e4764061ff29d8fc441d29..bbdef20553af371c7a07e91a1a50995902884dd1 100644 (file)
@@ -1,3 +1,5 @@
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D -->
+
 // File:    SketchPlugin_ConstraintRadius.h
 // Created: 26 May 2014
 // Author:  Artem ZHIDKOV
@@ -49,8 +51,17 @@ class SketchPlugin_ConstraintRadius : public SketchPlugin_ConstraintBase
   /// \param theDeltaY the delta for Y coordinate is moved
   SKETCHPLUGIN_EXPORT virtual void move(const double theDeltaX, const double theDeltaY);
 
+  /// Called on change of any argument-attribute of this object
+  /// \param theID identifier of changed attribute
+  SKETCHPLUGIN_EXPORT virtual void attributeChanged(const std::string& theID);
+
   /// \brief Use plugin manager for features creation
   SketchPlugin_ConstraintRadius();
+
+private:
+  /// Checks and gets the radius of referenced circle (or arc) otherwise returns -1.
+  /// \param theCircData the found referenced circle returned by this method
+  double circleRadius(std::shared_ptr<ModelAPI_Feature>& theCirc);
 };
 
 #endif
index 7653eb59ba4575ff1c2ebd1edd754a5f724ae22a..5a7b9d5f9781283302182a23c2e8ad6a6013be56 100644 (file)
@@ -1,3 +1,5 @@
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D -->
+
 // File:    SketchPlugin_ConstraintRigid.cpp
 // Created: 13 Oct 2014
 // Author:  Artem ZHIDKOV
index 7dc6ef8e9771ed44ca74e2959e066c0b9053a798..4646ac7fda00cb6b6270635096f41ceda2ad1a64 100644 (file)
@@ -1,3 +1,5 @@
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D -->
+
 // File:    SketchPlugin_ConstraintRigid.h
 // Created: 13 Oct 2014
 // Author:  Artem ZHIDKOV
index 42c5956b85da8181c408d3b2659c72a7bf5b2830..6e0f7111d1c29125622aae6885db76c5e1003b5e 100644 (file)
@@ -1,3 +1,5 @@
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D -->
+
 #include "SketchPlugin_Feature.h"
 #include "SketchPlugin_Sketch.h"
 #include <ModelAPI_Document.h>
@@ -29,19 +31,3 @@ SketchPlugin_Sketch* SketchPlugin_Feature::sketch()
   return mySketch;
 }
 
-AISObjectPtr SketchPlugin_Feature::simpleAISObject(std::shared_ptr<ModelAPI_Result> theRes,
-                                                   AISObjectPtr thePrevious)
-{
-  std::shared_ptr<ModelAPI_ResultConstruction> aConstr = std::dynamic_pointer_cast<
-      ModelAPI_ResultConstruction>(theRes);
-
-  std::shared_ptr<GeomAPI_Shape> aPreview;
-  if (aConstr)
-    aPreview = aConstr->shape();
-
-  AISObjectPtr aResult = thePrevious;
-  if (!aResult)
-    aResult = AISObjectPtr(new GeomAPI_AISObject());
-  aResult->createShape(aPreview);
-  return aResult;
-}
index 7f31bbbe401441a70e844f923a7b85de269e1c21..ca61e4b97b789bd8bc13bca99e758d574ed0a45c 100644 (file)
@@ -1,3 +1,5 @@
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D -->
+
 // File:        SketchPlugin_Feature.h
 // Created:     27 Mar 2014
 // Author:      Mikhail PONIKAROV
@@ -11,6 +13,7 @@
 #include <GeomAPI_AISObject.h>
 #include <ModelAPI_Document.h>
 #include <ModelAPI_AttributeSelection.h>
+#include <GeomAPI_ICustomPrs.h>
 
 class SketchPlugin_Sketch;
 class GeomAPI_Pnt2d;
@@ -21,13 +24,9 @@ class Handle_AIS_InteractiveObject;
  * \brief Feature for creation of the new feature in PartSet. This is an abstract class to give
  * an interface to create the sketch feature preview.
  */
-class SketchPlugin_Feature : public ModelAPI_Feature
+class SketchPlugin_Feature : public ModelAPI_Feature, public GeomAPI_ICustomPrs
 {
  public:
-  /// Simple creation of interactive object by the result of the object
-  static AISObjectPtr simpleAISObject(std::shared_ptr<ModelAPI_Result> theRes,
-                                      AISObjectPtr thePrevious);
-
   /// Reference to the external edge or vertex as a AttributeSelection
   inline static const std::string& EXTERNAL_ID()
   {
@@ -64,6 +63,17 @@ class SketchPlugin_Feature : public ModelAPI_Feature
     return false;
   }
 
+  /// Customize presentation of the feature
+  virtual void customisePresentation(AISObjectPtr thePrs)
+  {
+    // if this is an edge
+    if (thePrs->getShapeType() == 6)
+      thePrs->setWidth(3);
+    // if this is a vertex
+    //else if (thePrs->getShapeType() == 7)
+    //  thePrs->setPointMarker(6, 2.);
+  }
+
   /// Returns the sketch of this feature
   SketchPlugin_Sketch* sketch();
 protected:
index 2cba979ce710164a078d324ea93bf8139ee9fe8f..50d8f438f5072358de6535d2d05472f8f110e230 100644 (file)
@@ -1,3 +1,5 @@
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D -->
+
 // File:        SketchPlugin_Line.cxx
 // Created:     27 Mar 2014
 // Author:      Mikhail PONIKAROV
@@ -99,19 +101,19 @@ bool SketchPlugin_Line::isFixed() {
   return data()->selection(EXTERNAL_ID())->context();
 }
 
-void SketchPlugin_Line::attributeChanged() {
-  static bool myIsUpdated = false; // to avoid infinitive cycle on attrubtes change
-  std::shared_ptr<GeomAPI_Shape> aSelection = data()->selection(EXTERNAL_ID())->value();
-   // update arguments due to the selection value
-  if (aSelection && !aSelection->isNull() && aSelection->isEdge() && !myIsUpdated) {
-    myIsUpdated = true;
-    std::shared_ptr<GeomAPI_Edge> anEdge( new GeomAPI_Edge(aSelection));
-    std::shared_ptr<GeomDataAPI_Point2D> aStartAttr = 
-      std::dynamic_pointer_cast<GeomDataAPI_Point2D>(attribute(START_ID()));
-    aStartAttr->setValue(sketch()->to2D(anEdge->firstPoint()));
-    std::shared_ptr<GeomDataAPI_Point2D> anEndAttr = 
-      std::dynamic_pointer_cast<GeomDataAPI_Point2D>(attribute(END_ID()));
-    anEndAttr->setValue(sketch()->to2D(anEdge->lastPoint()));
-    myIsUpdated = false;
+void SketchPlugin_Line::attributeChanged(const std::string& theID) {
+  if (theID == EXTERNAL_ID()) {
+    std::shared_ptr<GeomAPI_Shape> aSelection = data()->selection(EXTERNAL_ID())->value();
+     // update arguments due to the selection value
+    if (aSelection && !aSelection->isNull() && aSelection->isEdge()) {
+      std::shared_ptr<GeomAPI_Edge> anEdge( new GeomAPI_Edge(aSelection));
+      std::shared_ptr<GeomDataAPI_Point2D> aStartAttr = 
+        std::dynamic_pointer_cast<GeomDataAPI_Point2D>(attribute(START_ID()));
+      aStartAttr->setValue(sketch()->to2D(anEdge->firstPoint()));
+      std::shared_ptr<GeomDataAPI_Point2D> anEndAttr = 
+        std::dynamic_pointer_cast<GeomDataAPI_Point2D>(attribute(END_ID()));
+      anEndAttr->setValue(sketch()->to2D(anEdge->lastPoint()));
+    }
   }
 }
+
index a9e3e606cc6b931e6b9f097603dabaf873886d57..be5fadaad66033f31cbf06f746750f9cfc69f55c 100644 (file)
@@ -1,3 +1,5 @@
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D -->
+
 // File:        SketchPlugin_Line.h
 // Created:     24 Apr 2014
 // Author:      Mikhail PONIKAROV
@@ -52,12 +54,6 @@ class SketchPlugin_Line : public SketchPlugin_Feature
   /// Request for initialization of data model of the feature: adding all attributes
   SKETCHPLUGIN_EXPORT virtual void initAttributes();
 
-  /// Returns the AIS preview
-  SKETCHPLUGIN_EXPORT virtual AISObjectPtr getAISObject(AISObjectPtr thePrevious)
-  {
-    return simpleAISObject(firstResult(), thePrevious);
-  }
-
   /// Moves the feature
   /// \param theDeltaX the delta for X coordinate is moved
   /// \param theDeltaY the delta for Y coordinate is moved
@@ -68,7 +64,7 @@ class SketchPlugin_Line : public SketchPlugin_Feature
   virtual double distanceToPoint(const std::shared_ptr<GeomAPI_Pnt2d>& thePoint);
 
   /// Called on change of any argument-attribute of this object
-  SKETCHPLUGIN_EXPORT virtual void attributeChanged();
+  SKETCHPLUGIN_EXPORT virtual void attributeChanged(const std::string& theID);
 
   /// Use plugin manager for features creation
   SketchPlugin_Line();
index 07768577649ec2cd8d3a8c974c111350f987817e..6680aef33008ad4a073d0ed3e3e6b7eebdc207f5 100644 (file)
@@ -1,24 +1,37 @@
-#include "SketchPlugin_Plugin.h"
-#include "SketchPlugin_Sketch.h"
-#include "SketchPlugin_Line.h"
-#include "SketchPlugin_Point.h"
-#include "SketchPlugin_Circle.h"
-#include "SketchPlugin_Arc.h"
-#include "SketchPlugin_ConstraintCoincidence.h"
-#include "SketchPlugin_ConstraintDistance.h"
-#include "SketchPlugin_ConstraintLength.h"
-#include "SketchPlugin_ConstraintParallel.h"
-#include "SketchPlugin_ConstraintPerpendicular.h"
-#include "SketchPlugin_ConstraintRadius.h"
-#include "SketchPlugin_ConstraintRigid.h"
-#include "SketchPlugin_Validators.h"
-#include "SketchPlugin_ResultValidators.h"
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D -->
+
+#include <SketchPlugin_Plugin.h>
+#include <SketchPlugin_Sketch.h>
+#include <SketchPlugin_Line.h>
+#include <SketchPlugin_Point.h>
+#include <SketchPlugin_Circle.h>
+#include <SketchPlugin_Arc.h>
+#include <SketchPlugin_ConstraintCoincidence.h>
+#include <SketchPlugin_ConstraintDistance.h>
+#include <SketchPlugin_ConstraintLength.h>
+#include <SketchPlugin_ConstraintParallel.h>
+#include <SketchPlugin_ConstraintPerpendicular.h>
+#include <SketchPlugin_ConstraintRadius.h>
+#include <SketchPlugin_ConstraintRigid.h>
+#include <SketchPlugin_Validators.h>
+#include <SketchPlugin_ResultValidators.h>
+
+#include <Events_Loop.h>
+#include <GeomDataAPI_Dir.h>
+
 #include <ModelAPI_Session.h>
 #include <ModelAPI_Document.h>
 #include <ModelAPI_Validator.h>
+#include <ModelAPI_Data.h>
 
 #include <Config_PropManager.h>
 
+#include <memory>
+
+#ifdef _DEBUG
+#include <iostream>
+#endif
+
 using namespace std;
 
 // the only created instance of this plugin
@@ -92,3 +105,45 @@ FeaturePtr SketchPlugin_Plugin::createFeature(string theFeatureID)
   // feature of such kind is not found
   return FeaturePtr();
 }
+
+void SketchPlugin_Plugin::processEvent(const std::shared_ptr<Events_Message>& theMessage)
+{
+  const Events_ID kRequestEvent =
+      Events_Loop::loop()->eventByName(EVENT_FEATURE_STATE_REQUEST);
+  if (theMessage->eventID() == kRequestEvent) {
+    std::shared_ptr<ModelAPI_FeatureStateMessage> aStateMessage =
+        std::dynamic_pointer_cast<ModelAPI_FeatureStateMessage>(theMessage);
+    Events_Loop::loop()->send(getFeaturesState(aStateMessage->feature()), false);
+  }
+}
+
+std::shared_ptr<ModelAPI_FeatureStateMessage> SketchPlugin_Plugin
+::getFeaturesState(const std::shared_ptr<ModelAPI_Feature>& theFeature) const
+{
+  const Events_ID kResponseEvent = Events_Loop::loop()->eventByName(EVENT_FEATURE_STATE_RESPONSE);
+  std::shared_ptr<ModelAPI_FeatureStateMessage> aMsg =
+      std::make_shared<ModelAPI_FeatureStateMessage>(kResponseEvent, this);
+
+  bool aHasSketchPlane = false;
+  std::shared_ptr<SketchPlugin_Sketch> aSketchFeature =
+      std::dynamic_pointer_cast<SketchPlugin_Sketch>(theFeature);
+  if (aSketchFeature.get()) {
+    std::shared_ptr<ModelAPI_Data> aData = aSketchFeature->data();
+    std::shared_ptr<GeomDataAPI_Dir> aNormal =
+      std::dynamic_pointer_cast<GeomDataAPI_Dir>(aData->attribute(SketchPlugin_Sketch::NORM_ID()));
+    aHasSketchPlane = aNormal && !(aNormal->x() == 0 && aNormal->y() == 0 && aNormal->z() == 0);
+
+    aMsg->setState(SketchPlugin_Point::ID(), aHasSketchPlane);
+    aMsg->setState(SketchPlugin_Line::ID(), aHasSketchPlane);
+    aMsg->setState(SketchPlugin_Circle::ID(), aHasSketchPlane);
+    aMsg->setState(SketchPlugin_Arc::ID(), aHasSketchPlane);
+    aMsg->setState(SketchPlugin_ConstraintCoincidence::ID(), aHasSketchPlane);
+    aMsg->setState(SketchPlugin_ConstraintDistance::ID(), aHasSketchPlane);
+    aMsg->setState(SketchPlugin_ConstraintLength::ID(), aHasSketchPlane);
+    aMsg->setState(SketchPlugin_ConstraintParallel::ID(), aHasSketchPlane);
+    aMsg->setState(SketchPlugin_ConstraintPerpendicular::ID(), aHasSketchPlane);
+    aMsg->setState(SketchPlugin_ConstraintRadius::ID(), aHasSketchPlane);
+    aMsg->setState(SketchPlugin_ConstraintRigid::ID(), aHasSketchPlane);
+  }
+  return aMsg;
+}
index 3b480410b8b169b23ccdbddfb98faf7455e59dc6..a02ef822c85e1bbdc88de7c458dc031c84aa2ca6 100644 (file)
@@ -1,15 +1,19 @@
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D -->
+
 // File:        SketchPlugin_Plugin.hxx
 // Created:     31 Mar 2014
 // Author:      Mikhail PONIKAROV
 
-#ifndef SketchPlugin_Plugin_H_
-#define SketchPlugin_Plugin_H_
+#ifndef SKETCHPLUGIN_PLUGIN_H_
+#define SKETCHPLUGIN_PLUGIN_H_
 
-#include "SketchPlugin.h"
-#include "ModelAPI_Plugin.h"
-#include "ModelAPI_Feature.h"
+#include <SketchPlugin.h>
+#include <Events_Listener.h>
+#include <ModelAPI_Plugin.h>
+#include <ModelAPI_Feature.h>
+#include <ModelAPI_Events.h>
 
-class SKETCHPLUGIN_EXPORT SketchPlugin_Plugin : public ModelAPI_Plugin
+class SKETCHPLUGIN_EXPORT SketchPlugin_Plugin : public ModelAPI_Plugin, public Events_Listener
 {
  public:
   /// Creates the feature object of this plugin by the feature string ID
@@ -17,6 +21,11 @@ class SKETCHPLUGIN_EXPORT SketchPlugin_Plugin : public ModelAPI_Plugin
 
  public:
   SketchPlugin_Plugin();
+  //! Redefinition of Events_Listener method
+  virtual void processEvent(const std::shared_ptr<Events_Message>& theMessage);
+ protected:
+  std::shared_ptr<ModelAPI_FeatureStateMessage> getFeaturesState(
+      const std::shared_ptr<ModelAPI_Feature>& theFeature) const;
 };
 
 #endif
index cd862a6adbd46ccac051ffca6eea0b5b02500994..97c74f4760dbfc4f52e4e3bab14563effcd24c5f 100644 (file)
@@ -1,3 +1,5 @@
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D -->
+
 // File:    SketchPlugin_Point.cpp
 // Created: 07 May 2014
 // Author:  Artem ZHIDKOV
@@ -12,7 +14,7 @@
 #include <ModelAPI_Session.h>
 
 #include <GeomAPI_Pnt2d.h>
-
+#include <GeomAPI_Vertex.h>
 #include <GeomDataAPI_Point2D.h>
 #include <GeomAlgoAPI_PointBuilder.h>
 
@@ -70,3 +72,16 @@ double SketchPlugin_Point::distanceToPoint(const std::shared_ptr<GeomAPI_Pnt2d>&
 bool SketchPlugin_Point::isFixed() {
   return data()->selection(EXTERNAL_ID())->context();
 }
+
+void SketchPlugin_Point::attributeChanged(const std::string& theID) {
+  if (theID == EXTERNAL_ID()) {
+    std::shared_ptr<GeomAPI_Shape> aSelection = data()->selection(EXTERNAL_ID())->value();
+     // update arguments due to the selection value
+    if (aSelection && !aSelection->isNull() && aSelection->isVertex()) {
+      std::shared_ptr<GeomAPI_Vertex> aVertex(new GeomAPI_Vertex(aSelection));
+      std::shared_ptr<GeomDataAPI_Point2D> aCoordAttr = 
+        std::dynamic_pointer_cast<GeomDataAPI_Point2D>(attribute(COORD_ID()));
+      aCoordAttr->setValue(sketch()->to2D(aVertex->point()));
+    }
+  }
+}
index 50eb4591db845e1524e7e03cfec4c638a9a9416c..c855dd32a95284c1d72cbbfa92213b7f2436d4d6 100644 (file)
@@ -1,3 +1,5 @@
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D -->
+
 // File:    SketchPlugin_Point.h
 // Created: 07 May 2014
 // Author:  Artem ZHIDKOV
@@ -45,12 +47,6 @@ class SketchPlugin_Point : public SketchPlugin_Feature
   /// Request for initialization of data model of the feature: adding all attributes
   SKETCHPLUGIN_EXPORT virtual void initAttributes();
 
-  /// Returns the AIS preview
-  virtual AISObjectPtr getAISObject(AISObjectPtr thePrevious)
-  {
-    return simpleAISObject(firstResult(), thePrevious);
-  }
-
   /// Moves the feature
   /// \param theDeltaX the delta for X coordinate is moved
   /// \param theDeltaY the delta for Y coordinate is moved
@@ -60,6 +56,9 @@ class SketchPlugin_Point : public SketchPlugin_Feature
   /// \param thePoint the point
   virtual double distanceToPoint(const std::shared_ptr<GeomAPI_Pnt2d>& thePoint);
 
+  /// Called on change of any argument-attribute of this object: for external point
+  SKETCHPLUGIN_EXPORT virtual void attributeChanged(const std::string& theID);
+
   /// Use plugin manager for features creation
   SketchPlugin_Point();
 };
index 043f45a0dac3c02f5d6085358c97e8f2c42ac97f..15f8554a2f9f25012a8ebb6cb7707c7815ede8ec 100644 (file)
@@ -1,3 +1,5 @@
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D -->
+
 // File:        Model_ResultValidators.cpp
 // Created:     23 July 2014
 // Author:      Vitaly SMETANNIKOV
index 0a6f7a692382020538b8f6bb85a32d8cd1a4017b..d5100d8fcbd040ab1033a8ae2f60d2df3cc298a2 100644 (file)
@@ -1,3 +1,5 @@
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D -->
+
 // File:        Model_ResultValidators.h
 // Created:     23 July 2014
 // Author:      Vitaly SMETANNIKOV
index 4902305a8b34bb67ee8a530db671d0106ca67a9c..8e9644e459fac19d312d3fd04a9281abf99902df 100644 (file)
@@ -1,3 +1,5 @@
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D -->
+
 // File:        SketchPlugin_Sketch.cxx
 // Created:     27 Mar 2014
 // Author:      Mikhail PONIKAROV
@@ -215,45 +217,45 @@ std::shared_ptr<GeomAPI_Pln> SketchPlugin_Sketch::plane()
   return std::shared_ptr<GeomAPI_Pln>(new GeomAPI_Pln(anOrigin->pnt(), aNorm->dir()));
 }
 
-void addPlane(double theX, double theY, double theZ,
-              std::list<std::shared_ptr<GeomAPI_Shape> >& theShapes)
-{
-  std::shared_ptr<GeomAPI_Pnt> anOrigin(new GeomAPI_Pnt(0, 0, 0));
-  std::shared_ptr<GeomAPI_Dir> aNormal(new GeomAPI_Dir(theX, theY, theZ));
-  double aSize = Config_PropManager::integer("Sketch planes", "Size of planes", PLANE_SIZE);
-  std::shared_ptr<GeomAPI_Shape> aFace = GeomAlgoAPI_FaceBuilder::square(anOrigin, aNormal,
-                                                                           aSize);
-  theShapes.push_back(aFace);
-}
-
-AISObjectPtr SketchPlugin_Sketch::getAISObject(AISObjectPtr thePrevious)
-{
-  std::shared_ptr<GeomDataAPI_Dir> aNorm = std::dynamic_pointer_cast<GeomDataAPI_Dir>(
-      data()->attribute(SketchPlugin_Sketch::NORM_ID()));
-
-  if (!aNorm || (aNorm->x() == 0 && aNorm->y() == 0 && aNorm->z() == 0)) {
-    AISObjectPtr aAIS = thePrevious;
-    if (!aAIS) {
-      std::list<std::shared_ptr<GeomAPI_Shape> > aFaces;
-
-      addPlane(1, 0, 0, aFaces);  // YZ plane
-      addPlane(0, 1, 0, aFaces);  // XZ plane
-      addPlane(0, 0, 1, aFaces);  // XY plane
-      std::shared_ptr<GeomAPI_Shape> aCompound = GeomAlgoAPI_CompoundBuilder::compound(aFaces);
-      aAIS = AISObjectPtr(new GeomAPI_AISObject());
-      aAIS->createShape(aCompound);
-
-      std::vector<int> aRGB = Config_PropManager::color("Sketch planes", "planes_color",
-      SKETCH_PLANE_COLOR);
-      aAIS->setColor(aRGB[0], aRGB[1], aRGB[2]);
-
-      aAIS->setWidth(Config_PropManager::integer("Sketch planes", "planes_thickness",
-      SKETCH_WIDTH));
-    }
-    return aAIS;
-  }
-  return AISObjectPtr();
-}
+//void addPlane(double theX, double theY, double theZ,
+//              std::list<std::shared_ptr<GeomAPI_Shape> >& theShapes)
+//{
+//  std::shared_ptr<GeomAPI_Pnt> anOrigin(new GeomAPI_Pnt(0, 0, 0));
+//  std::shared_ptr<GeomAPI_Dir> aNormal(new GeomAPI_Dir(theX, theY, theZ));
+//  double aSize = Config_PropManager::integer("Sketch planes", "Size of planes", PLANE_SIZE);
+//  std::shared_ptr<GeomAPI_Shape> aFace = GeomAlgoAPI_FaceBuilder::square(anOrigin, aNormal,
+//                                                                           aSize);
+//  theShapes.push_back(aFace);
+//}
+
+//AISObjectPtr SketchPlugin_Sketch::getAISObject(AISObjectPtr thePrevious)
+//{
+//  std::shared_ptr<GeomDataAPI_Dir> aNorm = std::dynamic_pointer_cast<GeomDataAPI_Dir>(
+//      data()->attribute(SketchPlugin_Sketch::NORM_ID()));
+//
+//  if (!aNorm || (aNorm->x() == 0 && aNorm->y() == 0 && aNorm->z() == 0)) {
+//    AISObjectPtr aAIS = thePrevious;
+//    if (!aAIS) {
+//      std::list<std::shared_ptr<GeomAPI_Shape> > aFaces;
+//
+//      addPlane(1, 0, 0, aFaces);  // YZ plane
+//      addPlane(0, 1, 0, aFaces);  // XZ plane
+//      addPlane(0, 0, 1, aFaces);  // XY plane
+//      std::shared_ptr<GeomAPI_Shape> aCompound = GeomAlgoAPI_CompoundBuilder::compound(aFaces);
+//      aAIS = AISObjectPtr(new GeomAPI_AISObject());
+//      aAIS->createShape(aCompound);
+//
+//      std::vector<int> aRGB = Config_PropManager::color("Sketch planes", "planes_color",
+//      SKETCH_PLANE_COLOR);
+//      aAIS->setColor(aRGB[0], aRGB[1], aRGB[2]);
+//
+//      aAIS->setWidth(Config_PropManager::integer("Sketch planes", "planes_thickness",
+//      SKETCH_WIDTH));
+//    }
+//    return aAIS;
+//  }
+//  return AISObjectPtr();
+//}
 
 void SketchPlugin_Sketch::erase()
 {
@@ -271,66 +273,46 @@ void SketchPlugin_Sketch::erase()
   ModelAPI_CompositeFeature::erase();
 }
 
-void SketchPlugin_Sketch::attributeChanged() {
-  static bool kIsUpdated = false; // to avoid infinitive cycle on attrubtes change
-  static bool kIsAttrChanged = false;
-  std::shared_ptr<GeomAPI_Shape> aSelection = 
-    data()->selection(SketchPlugin_Feature::EXTERNAL_ID())->value();
-  if (aSelection && !kIsUpdated) { // update arguments due to the selection value
-    kIsUpdated = true;
-    // update the sketch plane
-    std::shared_ptr<GeomAPI_Pln> aPlane = GeomAlgoAPI_FaceBuilder::plane(aSelection);
-    if (aPlane) {
-      double anA, aB, aC, aD;
-      aPlane->coefficients(anA, aB, aC, aD);
-
-      // calculate attributes of the sketch
-      std::shared_ptr<GeomAPI_Dir> aNormDir(new GeomAPI_Dir(anA, aB, aC));
-      std::shared_ptr<GeomAPI_XYZ> aCoords = aNormDir->xyz();
-      std::shared_ptr<GeomAPI_XYZ> aZero(new GeomAPI_XYZ(0, 0, 0));
-      aCoords = aCoords->multiplied(-aD * aCoords->distance(aZero));
-      std::shared_ptr<GeomAPI_Pnt> anOrigPnt(new GeomAPI_Pnt(aCoords));
-      // X axis is preferable to be dirX on the sketch
-      static const double tol = 1.e-7;
-      bool isX = fabs(anA - 1.0) < tol && fabs(aB) < tol && fabs(aC) < tol;
-      std::shared_ptr<GeomAPI_Dir> aTempDir(
-        isX ? new GeomAPI_Dir(0, 1, 0) : new GeomAPI_Dir(1, 0, 0));
-      std::shared_ptr<GeomAPI_Dir> aYDir(new GeomAPI_Dir(aNormDir->cross(aTempDir)));
-      std::shared_ptr<GeomAPI_Dir> aXDir(new GeomAPI_Dir(aYDir->cross(aNormDir)));
-
-      kIsAttrChanged = false; // track the attributes were really changed during the plane update
-      std::shared_ptr<GeomDataAPI_Point> anOrigin = std::dynamic_pointer_cast
-        <GeomDataAPI_Point>(data()->attribute(SketchPlugin_Sketch::ORIGIN_ID()));
-      anOrigin->setValue(anOrigPnt);
-      std::shared_ptr<GeomDataAPI_Dir> aNormal = std::dynamic_pointer_cast<GeomDataAPI_Dir>(
-        data()->attribute(SketchPlugin_Sketch::NORM_ID()));
-      aNormal->setValue(aNormDir);
-      std::shared_ptr<GeomDataAPI_Dir> aDirX = std::dynamic_pointer_cast<GeomDataAPI_Dir>(
-        data()->attribute(SketchPlugin_Sketch::DIRX_ID()));
-      aDirX->setValue(aXDir);
-      std::shared_ptr<GeomDataAPI_Dir> aDirY = std::dynamic_pointer_cast<GeomDataAPI_Dir>(
-        data()->attribute(SketchPlugin_Sketch::DIRY_ID()));
-      aDirY->setValue(aYDir);
-      std::shared_ptr<GeomAPI_Dir> aDir = aPlane->direction();
-
-      if (kIsAttrChanged) {
-        /* now it is in updater
-        // the plane was changed, so reexecute sub-elements to update shapes (located in new plane)
-        ModelAPI_ValidatorsFactory* aFactory = ModelAPI_Session::get()->validators();
-        list<ObjectPtr> aSubs = data()->reflist(SketchPlugin_Sketch::FEATURES_ID())->list();
-        for(list<ObjectPtr>::iterator aSubIt = aSubs.begin(); aSubIt != aSubs.end(); aSubIt++) {
-          std::shared_ptr<SketchPlugin_Feature> aFeature = 
-            std::dynamic_pointer_cast<SketchPlugin_Feature>(*aSubIt);
-          if (aFeature && aFactory->validate(aFeature)) {
-            aFeature->execute();
-          }
-        }
-        */
-        kIsAttrChanged = false;
+void SketchPlugin_Sketch::attributeChanged(const std::string& theID) {
+  if (theID == SketchPlugin_Feature::EXTERNAL_ID()) {
+    std::shared_ptr<GeomAPI_Shape> aSelection = 
+      data()->selection(SketchPlugin_Feature::EXTERNAL_ID())->value();
+    if (aSelection) { // update arguments due to the selection value
+      // update the sketch plane
+      std::shared_ptr<GeomAPI_Pln> aPlane = GeomAlgoAPI_FaceBuilder::plane(aSelection);
+      if (aPlane) {
+        double anA, aB, aC, aD;
+        aPlane->coefficients(anA, aB, aC, aD);
+
+        // calculate attributes of the sketch
+        std::shared_ptr<GeomAPI_Dir> aNormDir(new GeomAPI_Dir(anA, aB, aC));
+        std::shared_ptr<GeomAPI_XYZ> aCoords = aNormDir->xyz();
+        std::shared_ptr<GeomAPI_XYZ> aZero(new GeomAPI_XYZ(0, 0, 0));
+        aCoords = aCoords->multiplied(-aD * aCoords->distance(aZero));
+        std::shared_ptr<GeomAPI_Pnt> anOrigPnt(new GeomAPI_Pnt(aCoords));
+        // X axis is preferable to be dirX on the sketch
+        static const double tol = 1.e-7;
+        bool isX = fabs(anA - 1.0) < tol && fabs(aB) < tol && fabs(aC) < tol;
+        std::shared_ptr<GeomAPI_Dir> aTempDir(
+          isX ? new GeomAPI_Dir(0, 1, 0) : new GeomAPI_Dir(1, 0, 0));
+        std::shared_ptr<GeomAPI_Dir> aYDir(new GeomAPI_Dir(aNormDir->cross(aTempDir)));
+        std::shared_ptr<GeomAPI_Dir> aXDir(new GeomAPI_Dir(aYDir->cross(aNormDir)));
+
+        // update position of the sketch
+        std::shared_ptr<GeomDataAPI_Point> anOrigin = std::dynamic_pointer_cast
+          <GeomDataAPI_Point>(data()->attribute(SketchPlugin_Sketch::ORIGIN_ID()));
+        anOrigin->setValue(anOrigPnt);
+        std::shared_ptr<GeomDataAPI_Dir> aNormal = std::dynamic_pointer_cast<GeomDataAPI_Dir>(
+          data()->attribute(SketchPlugin_Sketch::NORM_ID()));
+        aNormal->setValue(aNormDir);
+        std::shared_ptr<GeomDataAPI_Dir> aDirX = std::dynamic_pointer_cast<GeomDataAPI_Dir>(
+          data()->attribute(SketchPlugin_Sketch::DIRX_ID()));
+        aDirX->setValue(aXDir);
+        std::shared_ptr<GeomDataAPI_Dir> aDirY = std::dynamic_pointer_cast<GeomDataAPI_Dir>(
+          data()->attribute(SketchPlugin_Sketch::DIRY_ID()));
+        aDirY->setValue(aYDir);
+        std::shared_ptr<GeomAPI_Dir> aDir = aPlane->direction();
       }
     }
-    kIsUpdated = false;
-  } else if (kIsUpdated) { // other attributes are updated during the selection comupation
-    kIsAttrChanged = true;
   }
 }
index c4802d48324df9f3962893c047eee3eb4122ca0c..a65fbb197acfc781006b9a927c2d1db539104c8f 100644 (file)
@@ -1,3 +1,5 @@
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D -->
+
 // File:        SketchPlugin_Sketch.h
 // Created:     27 Mar 2014
 // Author:      Mikhail PONIKAROV
@@ -25,7 +27,7 @@
  * \ingroup DataModel
  * \brief Feature for creation of the new part in PartSet.
  */
-class SketchPlugin_Sketch : public ModelAPI_CompositeFeature, public GeomAPI_IPresentable
+class SketchPlugin_Sketch : public ModelAPI_CompositeFeature//, public GeomAPI_IPresentable
 {
  public:
   /// Sketch feature kind
@@ -109,7 +111,7 @@ class SketchPlugin_Sketch : public ModelAPI_CompositeFeature, public GeomAPI_IPr
   /// Returns the basis plane for the sketch
   std::shared_ptr<GeomAPI_Pln> plane();
 
-  virtual AISObjectPtr getAISObject(AISObjectPtr thePrevious);
+  //virtual AISObjectPtr getAISObject(AISObjectPtr thePrevious);
 
   /// removes also all sub-sketch elements
   SKETCHPLUGIN_EXPORT virtual void erase();
@@ -135,7 +137,7 @@ class SketchPlugin_Sketch : public ModelAPI_CompositeFeature, public GeomAPI_IPr
   /// Returns the point projected into the sketch plane
   std::shared_ptr<GeomAPI_Pnt2d> to2D(const std::shared_ptr<GeomAPI_Pnt>& thePnt);
 
-  SKETCHPLUGIN_EXPORT virtual void attributeChanged();
+  SKETCHPLUGIN_EXPORT virtual void attributeChanged(const std::string& theID);
 protected:
   /// Creates a plane and append it to the list
   /// \param theX the X normal value
index ce58a0b3b54f6350815dfd7f825fc60ab935096a..c7117d4a8b7cc6f7dc079b5784f8963f0fca00aa 100644 (file)
@@ -1,3 +1,5 @@
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D -->
+
 // File:        SketchPlugin_Validators.cpp
 // Created:     01 Aug 2014
 // Author:      Vitaly SMETANNIKOV
index 14647fa71b35f372f84e8844b3996cb067950b0d..2f675c4f4fcc46150eb1cfc8b70463fb49a1ff20 100644 (file)
@@ -1,3 +1,5 @@
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D -->
+
 // File:        SketchPlugin_Validators.h
 // Created:     01 Aug 2014
 // Author:      Vitaly SMETANNIKOV
index afe60ba4f4971bb09d57c0ea3e9d08f63e28533e..cc71a412ff7b5cc2904f46584ffebbc896614d14 100644 (file)
@@ -107,12 +107,13 @@ assert (anArcPrevEndPointX == 50.)
 assert (anArcPrevEndPointY == 0.)
 # Move one point of the arc
 aSession.startOperation()
-anArcStartPoint.setValue(0., 60)
+anArcStartPoint.setValue(0, 60)
 aSession.finishOperation()
 assert (anArcCentr.x() == 10.)
 assert (anArcCentr.y() == 10.)
-assert (anArcEndPoint.x() != anArcPrevEndPointX)
-assert (anArcEndPoint.y() != anArcPrevEndPointY)
+# MPV: it just projects back to the circle the moved start point
+#assert (anArcEndPoint.x() != anArcPrevEndPointX)
+#assert (anArcEndPoint.y() != anArcPrevEndPointY)
 #=========================================================================
 # 4. Move the centr or the point of the arc
 # 5. Check radius is the same
index e2ca33704f282c6ca91de481213e40c869112a6a..f8fed6087f82e0ddf6147a1696b4aecdb97ab8b7 100644 (file)
@@ -1,14 +1,87 @@
 """
     TestHighload.py
 """
+from GeomAPI import *
 from GeomDataAPI import *
 from ModelAPI import *
-from GeomAPI import *
+import math
+
+
+#=========================================================================
+# Useful subroutines
+#=========================================================================
+def distance(pointA, pointB):
+    """
+    subroutine to calculate distance between two points
+    result of calculated distance is has 10**-5 precision
+    """
+    xdiff = math.pow((pointA.x() - pointB.x()), 2)
+    ydiff = math.pow((pointA.y() - pointB.y()), 2)
+    return round(math.sqrt(xdiff + ydiff), 5)
+
+
+def createNAngle(theSketch, theN, theRadius, theEdgeLength=0):
+    # Create an N-Angle at (0,0)
+    rad = 2. * math.pi / theN
+    points = []
+    for a in xrange(theN):
+        x = round(math.cos(rad * a), 10) * theRadius
+        y = round(math.sin(rad * a), 10) * theRadius
+        points.append((x, y))
+    # Close the contour
+    points.append(points[0])
+
+    # Create lines iterating over (A,B), (B,C), ... (N,A)
+    allStartPoints = []
+    allEndPoints = []
+    allLines = []
+    for begin, end in zip(points[:-1], points[1:]):
+        aSketchLine = theSketch.addFeature("SketchLine")
+        aStartPoint = geomDataAPI_Point2D(aSketchLine.attribute("StartPoint"))
+        anEndPoint = geomDataAPI_Point2D(aSketchLine.attribute("EndPoint"))
+        aStartPoint.setValue(begin[0], begin[1])
+        anEndPoint.setValue(end[0], end[1])
+        allStartPoints.append(aStartPoint)
+        allEndPoints.append(anEndPoint)
+        allLines.append(aSketchLine)
+    theSketch.execute()
+    # Shift a start point to the end of list:
+    # (Bb, Cb, Ab) zip (Ae, Be, Ce) --> ((Ae, Bb), (Cb, Be), (Ab, Ce))
+    allStartPoints.append(allStartPoints.pop(0))
+    # Make lines coincident:
+    for pointA, pointB in zip(allStartPoints, allEndPoints):
+        aCoincidence = theSketch.addFeature("SketchConstraintCoincidence")
+        aCoincidence.refattr("ConstraintEntityA").setAttr(pointA)
+        aCoincidence.refattr("ConstraintEntityB").setAttr(pointB)
+    return allLines
+
+
+def fixLineLength(theSketch, theLines, theEdgeLength=0):
+    aFirstLineLength = theEdgeLength
+    # Make give lines fixed length:
+    for aLine in theLines:
+        aLengthConstraint = aSketchFeature.addFeature("SketchConstraintLength")
+        refattrA = aLengthConstraint.refattr("ConstraintEntityA")
+        refattrA.setObject(modelAPI_ResultConstruction(aLine.firstResult()))
+        if aFirstLineLength == 0:
+            pointA = geomDataAPI_Point2D(aLine.attribute("StartPoint"))
+            pointB = geomDataAPI_Point2D(aLine.attribute("EndPoint"))
+            aFirstLineLength = distance(pointA, pointB)
+        aLengthConstraint.real("ConstraintValue").setValue(aFirstLineLength)
+
+
+def moveTo(theLines, theDeltaX, theDeltaY):
+    for aLine in theLines:
+        aStart = geomDataAPI_Point2D(aLine.attribute("StartPoint"))
+        anEnd = geomDataAPI_Point2D(aLine.attribute("EndPoint"))
+        aStart.setValue(aStart.x() + theDeltaX, aStart.y() + theDeltaY)
+        anEnd.setValue(anEnd.x() + theDeltaX, anEnd.y() + theDeltaY)
+
 #=========================================================================
 # Initialization of the test
 #=========================================================================
 
-__updated__ = "2014-11-21"
+__updated__ = "2014-11-27"
 
 aSession = ModelAPI_Session.get()
 aDocument = aSession.moduleDocument()
@@ -28,9 +101,23 @@ norm = geomDataAPI_Dir(aSketchFeature.attribute("Norm"))
 norm.setValue(0, 0, 1)
 aSession.finishOperation()
 #=========================================================================
-# TODO: implement test
+# Create 4x4 polygons N = {5, 21}
 #=========================================================================
-assert (False)
+deltaX = deltaY = 50.
+n = 5
+aSession.startOperation()
+for i in xrange(4):
+    for j in xrange(4):
+        allNangleLines = createNAngle(aSketchFeature, n, 50)
+        fixLineLength(aSketchFeature, allNangleLines)
+        moveTo(allNangleLines, deltaX, deltaY)
+        n += 1
+        deltaX += 110.
+    deltaY += 110.
+    deltaX = 50.
+aSession.finishOperation()
+
+
 #=========================================================================
 # End of test
 #=========================================================================
index 8ce7a3186b3bef32c439dceab06b871ab1098e45..c59725e218a969c2fe77015a48e7cc1edd79edba 100644 (file)
@@ -86,31 +86,33 @@ assert (anArcEndPoint.y() == 0.0)
 # 1. Move whole arc
 # 2. Change the start point
 #=========================================================================
-aSession.startOperation()
-deltaX, deltaY = 5., 10.
-anArcCentr.setValue(anArcCentr.x() + deltaX, anArcCentr.y() + deltaY)
-anArcStartPoint.setValue(
-    anArcStartPoint.x() + deltaX, anArcStartPoint.y() + deltaY)
-anArcEndPoint.setValue(anArcEndPoint.x() + deltaX, anArcEndPoint.y() + deltaY)
-aSession.finishOperation()
-assert (anArcCentr.x() == 15)
-assert (anArcCentr.y() == 20)
-assert (anArcStartPoint.x() == 5)
-assert (anArcStartPoint.y() == 60)
-assert (anArcEndPoint.x() == 55)
-assert (anArcEndPoint.y() == 10)
-# Change the start point
-aSession.startOperation()
-anArcStartPoint.setValue(anArcStartPoint.x() + deltaX, anArcStartPoint.y())
-aPrevEndPointX = anArcEndPoint.x()
-aPrevEndPointY = anArcEndPoint.y()
-aSession.finishOperation()
-assert (anArcCentr.x() == 15)
-assert (anArcCentr.y() == 20)
-assert (anArcStartPoint.x() == 10)
-assert (anArcStartPoint.y() == 60)
-assert (anArcEndPoint.x() != aPrevEndPointX)
-assert (anArcEndPoint.y() != aPrevEndPointY)
+
+# MPV: movement now is done little bit in different way, just move points causes changing them
+#  back t okeep the radius unchanged (projection back to the initial circle)
+#aSession.startOperation()
+#deltaX, deltaY = 5., 10.
+#anArcCentr.setValue(anArcCentr.x() + deltaX, anArcCentr.y() + deltaY)
+#anArcStartPoint.setValue(
+#    anArcStartPoint.x() + deltaX, anArcStartPoint.y() + deltaY)
+#anArcEndPoint.setValue(anArcEndPoint.x() + deltaX, anArcEndPoint.y() + deltaY)
+#aSession.finishOperation()
+#assert (anArcCentr.y() == 20)
+#assert (anArcStartPoint.x() == 5)
+#assert (anArcStartPoint.y() == 60)
+#assert (anArcEndPoint.x() == 55)
+#assert (anArcEndPoint.y() == 10)
+## Change the start point
+#aSession.startOperation()
+#anArcStartPoint.setValue(anArcStartPoint.x() + deltaX, anArcStartPoint.y())
+#aPrevEndPointX = anArcEndPoint.x()
+#aPrevEndPointY = anArcEndPoint.y()
+#aSession.finishOperation()
+#assert (anArcCentr.x() == 15)
+#assert (anArcCentr.y() == 20)
+#assert (anArcStartPoint.x() == 10)
+#assert (anArcStartPoint.y() == 60)
+#assert (anArcEndPoint.x() != aPrevEndPointX)
+#assert (anArcEndPoint.y() != aPrevEndPointY)
 #=========================================================================
 # Check results of the Arc
 #=========================================================================
diff --git a/src/SketchPlugin/Test/TestSnowflake.py b/src/SketchPlugin/Test/TestSnowflake.py
new file mode 100644 (file)
index 0000000..65b4213
--- /dev/null
@@ -0,0 +1,159 @@
+"""
+    TestSnowflake.py
+"""
+from GeomAPI import *
+from GeomDataAPI import *
+from ModelAPI import *
+import collections
+import math
+import random
+
+
+#=========================================================================
+# Useful subroutines
+#=========================================================================
+def mirrorDiagonal(theSketch, allLines):
+    result = []
+    for aLine in allLines:
+        aStartPoint = geomDataAPI_Point2D(aLine.attribute("StartPoint"))
+        anEndPoint = geomDataAPI_Point2D(aLine.attribute("EndPoint"))
+
+        aNewLine = aSketchFeature.addFeature("SketchLine")
+        aNewStartPoint = geomDataAPI_Point2D(aNewLine.attribute("StartPoint"))
+        aNewEndPoint = geomDataAPI_Point2D(aNewLine.attribute("EndPoint"))
+        aNewStartPoint.setValue(aStartPoint.y(), aStartPoint.x())
+        aNewEndPoint.setValue(anEndPoint.y(), anEndPoint.x())
+        result.append(aNewLine)
+    allLines.extend(result)
+
+
+def mirrorX(theSketch, allLines):
+    result = []
+    for aLine in allLines:
+        aStartPoint = geomDataAPI_Point2D(aLine.attribute("StartPoint"))
+        anEndPoint = geomDataAPI_Point2D(aLine.attribute("EndPoint"))
+
+        aNewLine = aSketchFeature.addFeature("SketchLine")
+        aNewStartPoint = geomDataAPI_Point2D(aNewLine.attribute("StartPoint"))
+        aNewEndPoint = geomDataAPI_Point2D(aNewLine.attribute("EndPoint"))
+        aNewStartPoint.setValue(aStartPoint.x() * -1., aStartPoint.y())
+        aNewEndPoint.setValue(anEndPoint.x() * -1., anEndPoint.y())
+        result.append(aNewLine)
+    allLines.extend(result)
+
+
+def mirrorY(theSketch, allLines):
+    result = []
+    for aLine in allLines:
+        aStartPoint = geomDataAPI_Point2D(aLine.attribute("StartPoint"))
+        anEndPoint = geomDataAPI_Point2D(aLine.attribute("EndPoint"))
+
+        aNewLine = aSketchFeature.addFeature("SketchLine")
+        aNewStartPoint = geomDataAPI_Point2D(aNewLine.attribute("StartPoint"))
+        aNewEndPoint = geomDataAPI_Point2D(aNewLine.attribute("EndPoint"))
+        aNewStartPoint.setValue(aStartPoint.x(), aStartPoint.y() * -1.)
+        aNewEndPoint.setValue(anEndPoint.x(), anEndPoint.y() * -1.)
+        result.append(aNewLine)
+    allLines.extend(result)
+
+
+def initContour(theNumLines):
+    prevPoint = (35, 0)
+    result = []
+    deltaY = random.uniform(20, 25)
+    for i in xrange(1, theNumLines):
+        rangeXMax = (prevPoint[1] + deltaY) * (30. / i if i % 2 != 0 else 2)
+        newX = random.uniform(prevPoint[1] + deltaY,
+                              max(rangeXMax, prevPoint[1] + deltaY + 25.))
+        newPoint = (round(newX, 4), round(prevPoint[1] + deltaY, 4))
+        result.append((prevPoint, newPoint))
+        prevPoint = newPoint
+    # Close the contour
+    result.append((prevPoint, (prevPoint[1], prevPoint[1])))
+    return result
+
+
+def makeLinesCoincident(theSketch, allLines):
+    allPoints = collections.defaultdict(list)
+    for aLine in allLines:
+        aStartPoint = geomDataAPI_Point2D(aLine.attribute("StartPoint"))
+        anEndPoint = geomDataAPI_Point2D(aLine.attribute("EndPoint"))
+        aStartPointValue = (aStartPoint.x(), aStartPoint.y())
+        anEndPointValue = (anEndPoint.x(), anEndPoint.y())
+        allPoints[aStartPointValue].append(aStartPoint)
+        allPoints[anEndPointValue].append(anEndPoint)
+    for keyPoint, valuePoints in allPoints.iteritems():
+        if len(valuePoints) != 2:
+            print "Strange point: ", keyPoint, "has in coincidence: ", len(valuePoints)
+            continue
+        aConstraint = theSketch.addFeature("SketchConstraintCoincidence")
+        aConstraint.refattr("ConstraintEntityA").setAttr(valuePoints[0])
+        aConstraint.refattr("ConstraintEntityB").setAttr(valuePoints[1])
+
+
+#=========================================================================
+# Initialization of the test
+#=========================================================================
+
+__updated__ = "2014-11-27"
+
+aSession = ModelAPI_Session.get()
+aDocument = aSession.moduleDocument()
+#=========================================================================
+# Creation of a sketch
+#=========================================================================
+aSession.startOperation()
+aSketchCommonFeature = aDocument.addFeature("Sketch")
+aSketchFeature = modelAPI_CompositeFeature(aSketchCommonFeature)
+origin = geomDataAPI_Point(aSketchFeature.attribute("Origin"))
+origin.setValue(0, 0, 0)
+dirx = geomDataAPI_Dir(aSketchFeature.attribute("DirX"))
+dirx.setValue(1, 0, 0)
+diry = geomDataAPI_Dir(aSketchFeature.attribute("DirY"))
+diry.setValue(0, 1, 0)
+norm = geomDataAPI_Dir(aSketchFeature.attribute("Norm"))
+norm.setValue(0, 0, 1)
+#=========================================================================
+# 1 With the predefined contour or a new random generated in X0Y
+# 2 Make complete contour using the diagonal, X and Y mirror symmetry
+# 3 Link all lines in contour with coincidence
+#=========================================================================
+initialContour = [((35, 0), (134.8224, 22.0494)), ((134.8224, 22.0494), (71.987, 44.0988)),
+                  ((71.987, 44.0988), (205.1448, 66.1482)), ((205.1448, 66.1482), (127.862, 88.1976)),
+                  ((127.862, 88.1976), (416.861, 110.247)), ((416.861, 110.247), (233.0475, 132.2964)),
+                  ((233.0475, 132.2964), (251.1518, 154.3458)), ((251.1518, 154.3458), (351.0993, 176.3952)),
+                  ((351.0993, 176.3952), (432.3397, 198.4446)), ((432.3397, 198.4446), (223.3246, 220.494)),
+                  ((223.3246, 220.494), (617.4069, 242.5434)), ((617.4069, 242.5434), (479.6524, 264.5928)),
+                  ((479.6524, 264.5928), (453.5778, 286.6422)), ((453.5778, 286.6422), (541.3463, 308.6916)),
+                  ((541.3463, 308.6916), (564.5509, 330.741)), ((564.5509, 330.741), (636.9284, 352.7904)),
+                  ((636.9284, 352.7904), (383.5946, 374.8398)), ((383.5946, 374.8398), (403.3764, 396.8892)),
+                  ((403.3764, 396.8892), (463.9447, 418.9386)), ((463.9447, 418.9386), (669.1751, 440.988)),
+                  ((669.1751, 440.988), (602.2044, 463.0374)), ((602.2044, 463.0374), (942.0456, 485.0868)),
+                  ((942.0456, 485.0868), (526.574, 507.1362)), ((526.574, 507.1362), (826.3619, 529.1856)),
+                  ((826.3619, 529.1856), (576.9488, 551.235)), ((576.9488, 551.235), (624.5595, 573.2844)),
+                  ((624.5595, 573.2844), (648.7146, 595.3338)), ((648.7146, 595.3338), (1194.6944, 617.3832)),
+                  ((1194.6944, 617.3832), (646.6597, 639.4326)), ((646.6597, 639.4326), (839.8201, 661.482)),
+                  ((839.8201, 661.482), (690.7487, 683.5314)), ((690.7487, 683.5314), (1350.2538, 705.5808)),
+                  ((1350.2538, 705.5808), (731.0722, 727.6302)), ((731.0722, 727.6302), (1324.0992, 749.6796)),
+                  ((1324.0992, 749.6796), (790.4873, 771.729)), ((790.4873, 771.729), (813.9883, 793.7784)),
+                  ((813.9883, 793.7784), (828.9997, 815.8278)), ((828.9997, 815.8278), (1321.9798, 837.8772)),
+                  ((1321.9798, 837.8772), (872.1503, 859.9266)), ((872.1503, 859.9266), (859.9266, 859.9266))]
+
+# Regenerate contour
+# initialContour = initContour(40)
+allLines = []
+for begin, end in initialContour:
+    aNewLine = aSketchFeature.addFeature("SketchLine")
+    aStartPoint = geomDataAPI_Point2D(aNewLine.attribute("StartPoint"))
+    anEndPoint = geomDataAPI_Point2D(aNewLine.attribute("EndPoint"))
+    aStartPoint.setValue(begin[0], begin[1])
+    anEndPoint.setValue(end[0], end[1])
+    allLines.append(aNewLine)
+mirrorDiagonal(aSketchFeature, allLines)
+mirrorX(aSketchFeature, allLines)
+mirrorY(aSketchFeature, allLines)
+makeLinesCoincident(aSketchFeature, allLines)
+aSession.finishOperation()
+#=========================================================================
+# End of test
+#=========================================================================
index 82ba507be416c1da2d605d16569da7d85cbd66d6..501a656c3a29bd61aad7c2e8faa75b9fd4a643db 100644 (file)
@@ -1,3 +1,5 @@
+<!-- Copyright (C) 2014-20xx CEA/DEN, EDF R&D -->
+
 <plugin>
   <workbench id="Sketch">
     <group id="Basic">
       <!--icon=":pictures/x_point.png"-->
       </feature>
       <feature id="SketchPoint" title="Point" tooltip="Create a new point" icon=":icons/point.png">
-        <point_selector id="PointCoordindates" title="Point" tooltip="Point"/>
+        <sketch-2dpoint_selector id="PointCoordindates" title="Point" tooltip="Point"/>
       </feature>
       <feature id="SketchLine" title="Line" tooltip="Create a new line" icon=":icons/line.png">
-        <point_selector id="StartPoint" title="Start point" tooltip="Start point of the line" previous_feature_param="EndPoint"/>
-        <point_selector id="EndPoint" title="End point" tooltip="End point of the line"/>
+        <sketch-2dpoint_selector id="StartPoint" title="Start point" tooltip="Start point of the line" previous_feature_param="EndPoint"/>
+        <sketch-2dpoint_selector id="EndPoint" title="End point" tooltip="End point of the line"/>
       </feature>
       <feature id="SketchCircle" title="Circle" tooltip="Create a new circle" icon=":icons/circle.png">
-        <point_selector id="CircleCenter" title="Center" tooltip="Center of the circle"/>
+        <sketch-2dpoint_selector id="CircleCenter" title="Center" tooltip="Center of the circle"/>
         <point2ddistance id="CircleRadius" first_point="CircleCenter" label="Radius:" min="0" step="1.0" default="0" icon=":icons/radius.png" tooltip="Set Radius">
           <validator id="GeomValidators_Positive"/>
         </point2ddistance>
       </feature>
       <feature id="SketchArc" title="Arc" tooltip="Create a new arc of a circle" icon=":icons/arc.png">
-        <point_selector id="ArcCenter" title="Center" tooltip="Center of the arc"/>
-        <point_selector id="ArcStartPoint" title="Start point" tooltip="Start point of the arc"/>
-        <point_selector id="ArcEndPoint" title="End point" tooltip="End point of the arc"/>
+        <sketch-2dpoint_selector id="ArcCenter" title="Center" tooltip="Center of the arc"/>
+        <sketch-2dpoint_selector id="ArcStartPoint" title="Start point" tooltip="Start point of the arc"/>
+        <sketch-2dpoint_selector id="ArcEndPoint" title="End point" tooltip="End point of the arc"/>
       </feature>
     </group>
          
     <group id="Constraints">
       <feature id="SketchConstraintCoincidence" title="Coincident" tooltip="Create constraint for the coincidence of two points" internal="1"/>
-
+       <!--  SketchConstraintDistance  -->
       <feature id="SketchConstraintDistance" title="Distance" tooltip="Create constraint for the distance from a point to an object" icon=":icons/distance.png">
         <label title="Select objects for distance definition. Following objects can be accepted: point, line or arc end point, center of circle or arc."/>
-        <feature_or_attribute_selector id="ConstraintEntityA" label="First object" tooltip="Select point, line end point, line, center of circle or arc.">
-          <validator id="SketchPlugin_ResultPoint"/>
-          <validator id="SketchPlugin_ResultLine"/>
-          <validator id="SketchPlugin_DifferentObjects"/>
-        </feature_or_attribute_selector>
-        <feature_or_attribute_selector id="ConstraintEntityB" label="Last object" tooltip="Select point, line end point, line, center of circle or arc.">
-          <validator id="SketchPlugin_ResultPoint"/>
-          <validator id="SketchPlugin_ResultLine"/>
-          <validator id="SketchPlugin_DistanceAttr" parameters="ConstraintEntityA"/>
-          <validator id="SketchPlugin_DifferentObjects"/>
-        </feature_or_attribute_selector>
-        <point_selector id="ConstraintFlyoutValuePnt" internal="1" obligatory="0"/>
-        <doublevalue_editor label="Value" tooltip="Constraint value" id="ConstraintValue" default="computed" min="0">
+               
+               <sketch_shape_selector id="ConstraintEntityA" label="First object" tooltip="Select point, line end point, line, center of circle or arc." 
+                       shape_types="edge vertex"  use_subshapes="true"/>
+               
+               <sketch_shape_selector id="ConstraintEntityB" label="Last object" tooltip="Select point, line end point, line, center of circle or arc." 
+                       shape_types="edge vertex"  use_subshapes="true">
+                       <validator id="SketchPlugin_DifferentObjects"/>
+               </sketch_shape_selector>
+               
+        <sketch-2dpoint_selector id="ConstraintFlyoutValuePnt" internal="1" obligatory="0"/>
+        
+               <doublevalue_editor label="Value" tooltip="Constraint value" id="ConstraintValue" default="computed" min="0">
           <validator id="GeomValidators_Positive"/>
         </doublevalue_editor>
-        <validator id="PartSet_DistanceValidator"/>
+        
+               <validator id="PartSet_DistanceValidator"/>
       </feature>
-      
+       <!--  SketchConstraintLength  -->      
       <feature id="SketchConstraintLength" title="Length" tooltip="Create constraint for the given length of a line segment" icon=":icons/length.png">
         <label title="Select a line on which to calculate length" tooltip="Select a line on which to calculate length"/>
-        <feature_selector id="ConstraintEntityA" label="Line" tooltip="Select an line in the viewer">
-          <validator id="SketchPlugin_ResultLine"/>
-        </feature_selector>
-        <point_selector id="ConstraintFlyoutValuePnt" internal="1" obligatory="0"/>
+               <shape_selector id="ConstraintEntityA" label="Line" tooltip="Select an line in the viewer" 
+                       shape_types="edge" >
+                       <validator id="SketchPlugin_ResultLine"/>
+      <selection_filter id="EdgeFilter" parameters="line"/>
+    </shape_selector>
+        <sketch-2dpoint_selector id="ConstraintFlyoutValuePnt" internal="1" obligatory="0"/>
         <doublevalue_editor label="Value" tooltip="Constraint value" id="ConstraintValue" default="computed">
           <validator id="GeomValidators_Positive"/>
         </doublevalue_editor>
         <validator id="PartSet_LengthValidator"/>
       </feature>
-      
+       <!--  SketchConstraintRadius  -->
       <feature id="SketchConstraintRadius" title="Radius" tooltip="Create constraint for the given radius of a circle or an arc" icon=":icons/radius_constr.png">
         <label title="Select a circle or an arc on which to calculate radius" tooltip="Select a circle or an arc on which to calculate radius"/>
-        <feature_selector id="ConstraintEntityA" label="Circle or Arc" tooltip="Select a circle or an arc in the viewer">
-          <validator id="SketchPlugin_ResultArc"/>
-        </feature_selector>
-        <point_selector id="ConstraintFlyoutValuePnt" internal="1" obligatory="0"/>
+               <shape_selector id="ConstraintEntityA" label="Circle or Arc" tooltip="Select a circle or an arc in the viewer" 
+                       shape_types="edge">
+                       <validator id="SketchPlugin_ResultArc"/>
+                       <selection_filter id="EdgeFilter" parameters="circle"/>
+               </shape_selector>
+        <sketch-2dpoint_selector id="ConstraintFlyoutValuePnt" internal="1" obligatory="0"/>
         <doublevalue_editor label="Value" tooltip="Constraint value" id="ConstraintValue" default="computed"/>
         <validator id="PartSet_RadiusValidator"/>
       </feature>
-      
+       <!--  SketchConstraintParallel  -->
       <feature id="SketchConstraintParallel" title="Parallel" tooltip="Create constraint defining two parallel lines" icon=":icons/parallel.png">
-        <feature_selector id="ConstraintEntityA" label="First line" tooltip="Select an line in the viewer">
-          <validator id="SketchPlugin_ResultLine"/>
-          <validator id="SketchPlugin_DifferentObjects"/>
-        </feature_selector>
-        <feature_selector id="ConstraintEntityB" label="Last line" tooltip="Select an line in the viewer">
-          <validator id="SketchPlugin_ResultLine"/>
-          <validator id="SketchPlugin_DifferentObjects"/>
-        </feature_selector>
-        <point_selector id="ConstraintFlyoutValuePnt" internal="1" obligatory="0"/>
+               <sketch_constraint_shape_selector id="ConstraintEntityA" 
+                       label="First line" tooltip="Select an line in the viewer" 
+                       shape_types="edge" use_subshapes="true">
+                       <selection_filter id="EdgeFilter" parameters="line"/>
+               </sketch_constraint_shape_selector>
+               
+               <sketch_constraint_shape_selector id="ConstraintEntityB" label="Last line" tooltip="Select an line in the viewer" 
+                       shape_types="edge" use_subshapes="true">
+                       <selection_filter id="EdgeFilter" parameters="line"/>
+                       <validator id="SketchPlugin_DifferentObjects"/>
+               </sketch_constraint_shape_selector>
+               
+        <sketch-2dpoint_selector id="ConstraintFlyoutValuePnt" internal="1" obligatory="0"/>
         <validator id="PartSet_ParallelValidator"/>
       </feature>
-      
+       <!--  SketchConstraintPerpendicular  -->
       <feature id="SketchConstraintPerpendicular" title="Perpendicular" tooltip="Create constraint defining two perpendicular lines" icon=":icons/perpendicular.png">
-        <feature_selector id="ConstraintEntityA" label="First line" tooltip="Select an line in the viewer">
-          <validator id="SketchPlugin_ResultLine"/>
-          <validator id="SketchPlugin_DifferentObjects"/>
-        </feature_selector>
-        <feature_selector id="ConstraintEntityB" label="Last line" tooltip="Select an line in the viewer">
-          <validator id="SketchPlugin_ResultLine"/>
-          <validator id="SketchPlugin_DifferentObjects"/>
-        </feature_selector>
+               <sketch_constraint_shape_selector id="ConstraintEntityA" 
+                       label="First line" tooltip="Select an line in the viewer" 
+                       shape_types="edge" use_subshapes="true">
+      <selection_filter id="EdgeFilter" parameters="line"/>
+    </sketch_constraint_shape_selector>
+               
+               <sketch_constraint_shape_selector id="ConstraintEntityB" 
+                       label="Last line" tooltip="Select an line in the viewer" 
+                       shape_types="edge" use_subshapes="true">
+                       <validator id="SketchPlugin_DifferentObjects"/>
+      <selection_filter id="EdgeFilter" parameters="line"/>
+    </sketch_constraint_shape_selector>
         <validator id="PartSet_PerpendicularValidator"/>
       </feature>
-
+       <!--  SketchConstraintRigid  -->
       <feature id="SketchConstraintRigid" title="Fixed" tooltip="Create constraint defining fixed object" icon=":icons/fixed.png">
-        <feature_or_attribute_selector id="ConstraintEntityA" label="Object" tooltip="Select any object in the viewer">
-          <validator id="SketchPlugin_ResultPoint"/>
-          <validator id="SketchPlugin_ResultLine"/>
-          <validator id="SketchPlugin_ResultArc"/>
-        </feature_or_attribute_selector>
+        <shape_selector id="ConstraintEntityA" label="Object" tooltip="Select any object in the viewer" 
+                       shape_types="edge vertex">
+                   <validator id="SketchPlugin_ResultPoint"/>
+                       <validator id="SketchPlugin_ResultLine"/>
+                       <validator id="SketchPlugin_ResultArc"/>
+               </shape_selector>
+           <validator id="PartSet_RigidValidator"/>
       </feature>
     </group>
   </workbench>
index 6a57baa74886c9f76954b620a722ea652d3b6ef3..cd1ca4297d6a27317a1040fb48077cf30f0ebfe9 100644 (file)
@@ -1,3 +1,5 @@
+## Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
 INCLUDE(Common)
 INCLUDE(FindSolveSpace)
 
index 2f98bf53eb8f9ee60ed9e259ccb4d01c357877f7..f31b7e49f65076ca43234ad50f1a5f5c1b50b258 100644 (file)
@@ -1,3 +1,5 @@
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
 #ifndef SKETCHSOLVER_H
 #define SKETCHSOLVER_H
 
index caccc5223b1303460ed3fd6dd265e4cd728c4c9c..88f4572a17c05d7e8b20e352b0524cf32045a075 100644 (file)
@@ -1,3 +1,5 @@
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
 // File:    SketchSolver_Constraint.cpp
 // Created: 27 May 2014
 // Author:  Artem ZHIDKOV
index 4caa73b49bcc9ec0598383d34513ab35780f40e6..4520bf3a585e0c31a6cb0fad0e618715f519b76d 100644 (file)
@@ -1,3 +1,5 @@
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
 // File:    SketchSolver_Constraint.h
 // Created: 27 May 2014
 // Author:  Artem ZHIDKOV
index 46caaa45dbdbe98414fb6001a00a526c453e0b1f..f311546396df5e0c87daf3ab05c3ab0fad49e324 100644 (file)
@@ -1,3 +1,5 @@
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
 // File:    SketchSolver_ConstraintGroup.cpp
 // Created: 27 May 2014
 // Author:  Artem ZHIDKOV
index 4d9a2d7698bb0d28b52aabbd6ec4adefd0a9b2bd..00e8d4e7b54a8533c068476a92a6a356d53785c9 100644 (file)
@@ -1,3 +1,5 @@
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
 // File:    SketchSolver_ConstraintGroup.h
 // Created: 27 May 2014
 // Author:  Artem ZHIDKOV
index 24c6572c42d2893c500d9032cc371c66ffbd3913..71f062c392a6a3de9537a2c31ed20066c6a36929 100644 (file)
@@ -1,3 +1,5 @@
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
 // File:    SketchSolver_ConstraintManager.cpp
 // Created: 08 May 2014
 // Author:  Artem ZHIDKOV
@@ -107,12 +109,12 @@ void SketchSolver_ConstraintManager::processEvent(
           std::dynamic_pointer_cast<SketchPlugin_Feature>(*aFeatIter);
         if (!aFeature)
           continue;
-          changeConstraintOrEntity(aFeature);
+        changeConstraintOrEntity(aFeature);
       }
     }
 
     // Solve the set of constraints
-    resolveConstraints();
+    resolveConstraints(isMovedEvt); // send update for movement in any case
   } else if (theMessage->eventID() == Events_Loop::loop()->eventByName(EVENT_OBJECT_DELETED)) {
     std::shared_ptr<ModelAPI_ObjectDeletedMessage> aDeleteMsg =
         std::dynamic_pointer_cast<ModelAPI_ObjectDeletedMessage>(theMessage);
@@ -169,7 +171,7 @@ bool SketchSolver_ConstraintManager::changeWorkplane(
   if (!isUpdated) {
     SketchSolver_ConstraintGroup* aNewGroup = new SketchSolver_ConstraintGroup(theSketch);
     // Verify that the group is created successfully
-    if (!aNewGroup->isBaseWorkplane(theSketch)) {
+    if (!aNewGroup->isBaseWorkplane(theSketch) || !aNewGroup->isWorkplaneValid()) {
       delete aNewGroup;
       return false;
     }
@@ -370,18 +372,31 @@ std::shared_ptr<ModelAPI_CompositeFeature> SketchSolver_ConstraintManager
 //  Class:    SketchSolver_Session
 //  Purpose:  change entities according to available constraints
 // ============================================================================
-void SketchSolver_ConstraintManager::resolveConstraints()
+void SketchSolver_ConstraintManager::resolveConstraints(const bool theForceUpdate)
 {
   myIsComputed = true;
   bool needToUpdate = false;
+  static Events_ID anUpdateEvent = Events_Loop::eventByName(EVENT_OBJECT_UPDATED);
+  // to avoid redisplay of each segment on update by solver one by one in the viewer
+  bool isUpdateFlushed = Events_Loop::loop()->isFlushed(anUpdateEvent);
+  if (isUpdateFlushed) {
+    Events_Loop::loop()->setFlushed(anUpdateEvent, false);
+  }
+
   std::vector<SketchSolver_ConstraintGroup*>::iterator aGroupIter;
   for (aGroupIter = myGroups.begin(); aGroupIter != myGroups.end(); aGroupIter++)
     if ((*aGroupIter)->resolveConstraints())
       needToUpdate = true;
 
-  // Features may be updated => send events
-  if (needToUpdate)
-    Events_Loop::loop()->flush(Events_Loop::eventByName(EVENT_OBJECT_UPDATED));
+  // Features may be updated => now send events, but for all changed at once
+  if (isUpdateFlushed) {
+    Events_Loop::loop()->setFlushed(anUpdateEvent, true);
+  }
+  // Must be before flush because on "Updated" flush the results may be produced
+  // and the creation event is appeared with many new objects. If myIsComputed these
+  // events are missed in processEvents and some elements are not added.
   myIsComputed = false;
+  if (needToUpdate || theForceUpdate)
+    Events_Loop::loop()->flush(anUpdateEvent);
 }
 
index c37637a3968fba3568ce5d8abbbd810218e2aa85..4604a52b11d7dc233a53e86ae2b12f6753ae6ad2 100644 (file)
@@ -1,3 +1,5 @@
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
 // File:    SketchSolver_ConstraintManager.h
 // Created: 08 May 2014
 // Author:  Artem ZHIDKOV
@@ -80,8 +82,9 @@ class SketchSolver_ConstraintManager : public Events_Listener
   void updateEntity(std::shared_ptr<SketchPlugin_Feature> theFeature);
 
   /** \brief Goes through the list of groups and solve the constraints
+   *  \param theForceUpdate flushes the update event in any case: something changed or not
    */
-  void resolveConstraints();
+  void resolveConstraints(const bool theForceUpdate);
 
  private:
   /** \brief Searches list of groups which interact with specified feature
index 975588bbb18084947a2bbcdeb457c1f68864f614..7e3a33de2891d609d769b2505179b7a2f46f91b4 100644 (file)
@@ -1,3 +1,5 @@
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
 // File:    SketchSolver_Solver.cpp
 // Created: 07 May 2014
 // Author:  Artem ZHIDKOV
index 8bdc566f0c733691d69e24d1ee3b30ae22961ffc..fd2e5213256f245e86d72ee6d8e6c9aa798eefd8 100644 (file)
@@ -1,3 +1,5 @@
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
 // File:    SketchSolver_Solver.h
 // Created: 07 May 2014
 // Author:  Artem ZHIDKOV
index 5ceda79603cc6772b9892f5b90e4443776859be6..26879a5e3e478af7648742a0ed7cc1e13734b073 100644 (file)
@@ -1,38 +1,28 @@
+## Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
 
 SET(CMAKE_AUTOMOC ON)
 
 SET(PROJECT_HEADERS
        XGUI.h
-       XGUI_Command.h
+       XGUI_ActionsMgr.h
+       XGUI_ContextMenuMgr.h
+       XGUI_DataTreeModel.h
        XGUI_Displayer.h
-       XGUI_MainMenu.h
-       XGUI_MainWindow.h
-       XGUI_MenuGroupPanel.h
-       XGUI_Tools.h
-       XGUI_Workbench.h
-       XGUI_Workshop.h
-    XGUI_ViewWindow.h
-    XGUI_ViewPort.h
-    XGUI_Viewer.h
-       XGUI_RubberBand.h
-       XGUI_Constants.h
        XGUI_DocumentDataModel.h
-       XGUI_PartDataModel.h
+       XGUI_ErrorDialog.h
+       XGUI_ModuleConnector.h
        XGUI_ObjectsBrowser.h
        XGUI_OperationMgr.h
-    XGUI_DataTreeModel.h
-    XGUI_SelectionMgr.h
-    XGUI_SalomeConnector.h
-    XGUI_ActionsMgr.h
-    XGUI_ErrorDialog.h
-    XGUI_ViewerProxy.h
-    XGUI_PropertyPanel.h
-    XGUI_ContextMenuMgr.h
-    XGUI_ModuleConnector.h
-       XGUI_Selection.h
-       XGUI_Preferences.h
-       XGUI_IPrefMgr.h
+       XGUI_PartDataModel.h
+       XGUI_PropertyPanel.h
        XGUI_QtEvents.h
+       XGUI_SalomeConnector.h
+       XGUI_Selection.h
+       XGUI_SelectionMgr.h
+       XGUI_Tools.h
+       XGUI_ViewerProxy.h
+       XGUI_Workshop.h
 )
 
 SET(PROJECT_AUTOMOC 
@@ -40,32 +30,22 @@ SET(PROJECT_AUTOMOC
 )
 
 SET(PROJECT_SOURCES
-       XGUI_Command.cpp
+       XGUI_ActionsMgr.cpp
+       XGUI_ContextMenuMgr.cpp
        XGUI_Displayer.cpp
-       XGUI_MainMenu.cpp
-       XGUI_MainWindow.cpp
-       XGUI_MenuGroupPanel.cpp
-       XGUI_Tools.cpp
-       XGUI_Workbench.cpp
-       XGUI_Workshop.cpp
-    XGUI_ViewWindow.cpp
-    XGUI_ViewPort.cpp
-    XGUI_Viewer.cpp
-       XGUI_RubberBand.cpp
        XGUI_DocumentDataModel.cpp
-       XGUI_PartDataModel.cpp
+       XGUI_ErrorDialog.cpp
+       XGUI_ModuleConnector.cpp
        XGUI_ObjectsBrowser.cpp
        XGUI_OperationMgr.cpp
-    XGUI_SelectionMgr.cpp
-    XGUI_ActionsMgr.cpp
-    XGUI_ErrorDialog.cpp
-    XGUI_ViewerProxy.cpp
-    XGUI_PropertyPanel.cpp
-    XGUI_ContextMenuMgr.cpp
-    XGUI_ModuleConnector.cpp
-       XGUI_Selection.cpp
-       XGUI_Preferences.cpp
+       XGUI_PartDataModel.cpp
+       XGUI_PropertyPanel.cpp
        XGUI_QtEvents.cpp
+       XGUI_Selection.cpp
+       XGUI_SelectionMgr.cpp
+       XGUI_Tools.cpp
+       XGUI_ViewerProxy.cpp
+       XGUI_Workshop.cpp
 )
 
 SET(PROJECT_RESOURCES 
@@ -85,6 +65,7 @@ SET(PROJECT_LIBRARIES
     Config
        ModelAPI
        ModuleBase
+       AppElements
        ${QT_LIBRARIES}
        ${CAS_VIEWER}
        ${CAS_KERNEL}
@@ -123,8 +104,9 @@ INCLUDE_DIRECTORIES (${PROJECT_SOURCE_DIR}/src/Events
                                         ${PROJECT_SOURCE_DIR}/src/ModelAPI
                                         ${PROJECT_SOURCE_DIR}/src/GeomAPI
                                         ${PROJECT_SOURCE_DIR}/src/ModuleBase
-                                        ${PROJECT_SOURCE_DIR}/src/PartSetPlugin
+#                                       ${PROJECT_SOURCE_DIR}/src/PartSetPlugin
                                         ${PROJECT_SOURCE_DIR}/src/GeomAlgoAPI
+                                        ${PROJECT_SOURCE_DIR}/src/AppElements
                                         ${CAS_INCLUDE_DIRS}
                                         ${SUIT_INCLUDE})
 
index 1b1bd2a0bbc129665136b8ad95e8ba64b494bc1c..02062241886dd7c06c4cf9c561254281209de761 100644 (file)
@@ -1,3 +1,5 @@
+<!-- Copyright (C) 2014-20xx CEA/DEN, EDF R&D -->
+
 <!--
 -->
 <document>
@@ -10,4 +12,9 @@
     <parameter name="item_size" value="25" />
     <parameter name="rows_number" value="3" />
   </section>
+  <section name="Plugins" >
+    <!-- Plugins preferences -->
+    <parameter name="default_path" value="" />
+  </section>
+
 </document>
index 713348a089ddc68e0f807a9b6f8dc6325aa53d3d..a0e77cd64bdc2d5f86d5faac9c4abe948a9c6447 100644 (file)
@@ -1,3 +1,5 @@
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D -->
+
 #ifndef XGUI_H
 #define XGUI_H
 
index 0468a39f75bc4ba8c5da482cdb115eefa28d89b1..851e3fef0adff9e5feb81c9e2eb35d4f5c9b7f49 100644 (file)
@@ -1,18 +1,28 @@
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D -->
+
 /*
  * XGUI_ActionsMgr.cpp
  */
 
-#include "XGUI_ActionsMgr.h"
-#include "XGUI_Command.h"
-#include "XGUI_Workshop.h"
-#include "XGUI_OperationMgr.h"
-#include "XGUI_SalomeConnector.h"
+#include <AppElements_Command.h>
 
-#include <ModelAPI_Session.h>
+#include <XGUI_ActionsMgr.h>
+#include <XGUI_Workshop.h>
+#include <XGUI_OperationMgr.h>
+#include <XGUI_SalomeConnector.h>
+#include <XGUI_Selection.h>
+#include <XGUI_SelectionMgr.h>
 
-#include <ModuleBase_Operation.h>
+#include <Events_Loop.h>
 #include <Events_Error.h>
 
+#include <ModelAPI_Session.h>
+#include <ModelAPI_Events.h>
+#include <ModelAPI_Validator.h>
+#include <ModuleBase_Operation.h>
+#include <ModuleBase_SelectionValidator.h>
+
+
 #include <QAction>
 
 #ifdef _DEBUG
@@ -31,6 +41,12 @@ XGUI_ActionsMgr::XGUI_ActionsMgr(XGUI_Workshop* theParent)
   myShortcuts << QKeySequence::Redo;
   myShortcuts << QKeySequence::Open;
   myShortcuts << QKeySequence::Close;
+
+  //Initialize event listening
+  Events_Loop* aLoop = Events_Loop::loop();
+  static Events_ID aStateResponseEventId =
+      Events_Loop::loop()->eventByName(EVENT_FEATURE_STATE_RESPONSE);
+  aLoop->registerListener(this, aStateResponseEventId, NULL, true);
 }
 
 XGUI_ActionsMgr::~XGUI_ActionsMgr()
@@ -44,7 +60,7 @@ void XGUI_ActionsMgr::addCommand(QAction* theCmd)
     return;
   }
   myActions.insert(aId, theCmd);
-  XGUI_Command* aXCmd = dynamic_cast<XGUI_Command*>(theCmd);
+  AppElements_Command* aXCmd = dynamic_cast<AppElements_Command*>(theCmd);
   if (aXCmd) {
     myNestedActions[aId] = aXCmd->nestedCommands();
   } else {
@@ -58,45 +74,144 @@ void XGUI_ActionsMgr::addNestedCommands(const QString& theId, const QStringList&
   myNestedActions[theId] = theCommands;
 }
 
+QStringList XGUI_ActionsMgr::nestedCommands(const QString& theId) const
+{
+  if (myNestedActions.contains(theId))
+    return myNestedActions[theId];
+  return QStringList();
+}
+
+bool XGUI_ActionsMgr::isNested(const QString& theId) const
+{
+  foreach(QString aId, myNestedActions.keys())
+  {
+    QStringList aList = myNestedActions[aId];
+    if (aList.contains(theId))
+      return true;
+  }
+  return false;
+}
+
 void XGUI_ActionsMgr::update()
 {
+  FeaturePtr anActiveFeature = FeaturePtr();
   if (myOperationMgr->hasOperation()) {
     ModuleBase_Operation* anOperation = myOperationMgr->currentOperation();
-    FeaturePtr aFeature = anOperation->feature();
-    if(aFeature) {
+    anActiveFeature = anOperation->feature();
+    if(anActiveFeature.get()) {
       setAllEnabled(false);
-      QString aFeatureId = QString::fromStdString(aFeature->getKind());
+      QString aFeatureId = QString::fromStdString(anActiveFeature->getKind());
       setActionEnabled(aFeatureId, true);
-      setNestedStackEnabled(anOperation);
     }
+    setNestedStackEnabled(anOperation);
   } else {
     setAllEnabled(true);
     setNestedCommandsEnabled(false);
   }
+  // TODO(SBH): Get defaults state of actions from XML and remove the following method
   updateByDocumentKind();
   updateCheckState();
+  updateByPlugins(anActiveFeature);
 }
 
-void XGUI_ActionsMgr::setAllEnabled(bool isEnabled)
+void XGUI_ActionsMgr::updateCheckState()
 {
-  foreach(QString eachAction, myActions.keys())
-  {
-    setActionEnabled(eachAction, isEnabled);
+  QString eachCommand = QString();
+  foreach(eachCommand, myActions.keys()) {
+    setActionChecked(eachCommand, false);
+  }
+  QStringList ltActiveCommands = myOperationMgr->operationList();
+  foreach(eachCommand, ltActiveCommands) {
+    setActionChecked(eachCommand, true);
   }
 }
 
-void XGUI_ActionsMgr::setNestedStackEnabled(ModuleBase_Operation* theOperation)
+void XGUI_ActionsMgr::updateOnViewSelection()
 {
-  if(!theOperation || !theOperation->feature())
+  XGUI_Selection* aSelection = myWorkshop->selector()->selection();
+  if (aSelection->getSelected().size() == 0 || !myOperationMgr->hasOperation())
     return;
-  FeaturePtr aFeature = theOperation->feature();
-  QString aFeatureId = QString::fromStdString(aFeature->getKind());
-  bool isNestedEnabled = theOperation->isNestedOperationsEnabled();
-  setNestedCommandsEnabled(isNestedEnabled, aFeatureId);
+  ModuleBase_Operation* anOperation = myOperationMgr->currentOperation();
+  FeaturePtr anActiveFeature = anOperation->feature();
+  if(!anActiveFeature.get())
+    return;
+  QString aFeatureId = QString::fromStdString(anActiveFeature->getKind());
 
-  setNestedStackEnabled(myOperationMgr->previousOperation(theOperation));
+  SessionPtr aMgr = ModelAPI_Session::get();
+  ModelAPI_ValidatorsFactory* aFactory = aMgr->validators();
+  foreach(QString aId, nestedCommands(aFeatureId)) {
+    std::list<ModelAPI_Validator*> aValidators;
+    std::list<std::list<std::string> > anArguments;
+    if (!anArguments.empty()) {
+      std::list<std::string> firstArg = anArguments.front();
+    }
+    aFactory->validators(aId.toStdString(), aValidators, anArguments);
+    std::list<ModelAPI_Validator*>::iterator aValidator = aValidators.begin();
+    std::list<std::list<std::string> >::iterator aValidatorArgs = anArguments.begin();
+    for (; aValidator != aValidators.end(); aValidator++, aValidatorArgs++) {
+      if (!(*aValidator))
+        continue;
+      const ModuleBase_SelectionValidator* aSelValidator =
+          dynamic_cast<const ModuleBase_SelectionValidator*>(*aValidator);
+      if (!aSelValidator)
+        continue;
+      setActionEnabled(aId, aSelValidator->isValid(aSelection, *aValidatorArgs));
+
+    }
+  }
+}
+
+QKeySequence XGUI_ActionsMgr::registerShortcut(const QString& theKeySequence)
+{
+  if (theKeySequence.isEmpty()) {
+    return QKeySequence();
+  }
+  QKeySequence aResult(theKeySequence);
+  if (myShortcuts.contains(aResult)) {
+    QString aMessage = tr("Shortcut %1 is already defined. Ignore.").arg(theKeySequence);
+    Events_Error::send(aMessage.toStdString());
+    return QKeySequence();
+  }
+  myShortcuts.append(aResult);
+  return aResult;
+}
+
+void XGUI_ActionsMgr::processEvent(const std::shared_ptr<Events_Message>& theMessage)
+{
+  const Events_ID kResponseEvent =
+      Events_Loop::loop()->eventByName(EVENT_FEATURE_STATE_RESPONSE);
+  if (theMessage->eventID() == kResponseEvent) {
+    std::shared_ptr<ModelAPI_FeatureStateMessage> aStateMessage =
+        std::dynamic_pointer_cast<ModelAPI_FeatureStateMessage>(theMessage);
+    if (!aStateMessage.get())
+      return;
+    std::list<std::string> aFeaturesList = aStateMessage->features();
+    std::list<std::string>::iterator it = aFeaturesList.begin();
+    for( ; it != aFeaturesList.end(); ++it) {
+      QString anActionId = QString::fromStdString(*it);
+      bool theDefaultState = false;
+      if (myActions.contains(anActionId)) {
+        theDefaultState = myActions[anActionId]->isEnabled();
+      }
+      setActionEnabled(anActionId, aStateMessage->state(*it, theDefaultState));
+    }
+  } else if (theMessage.get()) {
+    #ifdef _DEBUG
+    std::cout << "XGUI_ActionsMgr::processEvent: unhandled message caught: " << std::endl
+              << theMessage->eventID().eventText() << std::endl;
+    #endif
+  }
+}
+
+void XGUI_ActionsMgr::setAllEnabled(bool isEnabled)
+{
+  foreach(QString eachAction, myActions.keys())
+  {
+    setActionEnabled(eachAction, isEnabled);
+  }
 }
 
+
 //!
 void XGUI_ActionsMgr::setNestedCommandsEnabled(bool theEnabled, const QString& theParent)
 {
@@ -113,6 +228,17 @@ void XGUI_ActionsMgr::setNestedCommandsEnabled(bool theEnabled, const QString& t
   }
 }
 
+void XGUI_ActionsMgr::setNestedStackEnabled(ModuleBase_Operation* theOperation)
+{
+  if(!theOperation || !theOperation->feature())
+    return;
+  FeaturePtr aFeature = theOperation->feature();
+  QString aFeatureId = QString::fromStdString(aFeature->getKind());
+  setNestedCommandsEnabled(true, aFeatureId);
+
+  setNestedStackEnabled(myOperationMgr->previousOperation(theOperation));
+}
+
 void XGUI_ActionsMgr::setActionChecked(const QString& theId, const bool theChecked)
 {
   if (myActions.contains(theId)) {
@@ -123,6 +249,13 @@ void XGUI_ActionsMgr::setActionChecked(const QString& theId, const bool theCheck
   }
 }
 
+void XGUI_ActionsMgr::setActionEnabled(const QString& theId, const bool theEnabled)
+{
+  if (myActions.contains(theId)) {
+    myActions[theId]->setEnabled(theEnabled);
+  }
+}
+
 /*
  * Disables all actions which have the Document Kind different to
  * the current document's kind
@@ -133,7 +266,7 @@ void XGUI_ActionsMgr::updateByDocumentKind()
   QString aDocKind = QString::fromStdString(aStdDocKind);
   XGUI_Workshop* aWorkshop = static_cast<XGUI_Workshop*>(parent());
   foreach(QAction* eachAction, myActions.values()) {
-    XGUI_Command* aCmd = dynamic_cast<XGUI_Command*>(eachAction);
+    AppElements_Command* aCmd = dynamic_cast<AppElements_Command*>(eachAction);
     QString aCmdDocKind;
     if(aCmd) {
       aCmdDocKind = aCmd->documentKind();
@@ -149,54 +282,12 @@ void XGUI_ActionsMgr::updateByDocumentKind()
   }
 }
 
-void XGUI_ActionsMgr::setActionEnabled(const QString& theId, const bool theEnabled)
-{
-  if (myActions.contains(theId)) {
-    myActions[theId]->setEnabled(theEnabled);
-  }
-}
-
-void XGUI_ActionsMgr::updateCheckState()
-{
-  QString eachCommand = QString();
-  foreach(eachCommand, myActions.keys()) {
-    setActionChecked(eachCommand, false);
-  }
-  QStringList ltActiveCommands = myOperationMgr->operationList();
-  foreach(eachCommand, ltActiveCommands) {
-    setActionChecked(eachCommand, true);
-  }
-}
-
-QStringList XGUI_ActionsMgr::nestedCommands(const QString& theId) const
-{
-  if (myNestedActions.contains(theId))
-    return myNestedActions[theId];
-  return QStringList();
-}
-
-bool XGUI_ActionsMgr::isNested(const QString& theId) const
-{
-  foreach(QString aId, myNestedActions.keys())
-  {
-    QStringList aList = myNestedActions[aId];
-    if (aList.contains(theId))
-      return true;
-  }
-  return false;
-}
-
-QKeySequence XGUI_ActionsMgr::registerShortcut(const QString& theKeySequence)
+void XGUI_ActionsMgr::updateByPlugins(FeaturePtr anActiveFeature)
 {
-  if (theKeySequence.isEmpty()) {
-    return QKeySequence();
-  }
-  QKeySequence aResult(theKeySequence);
-  if (myShortcuts.contains(aResult)) {
-    QString aMessage = tr("Shortcut %1 is already defined. Ignore.").arg(theKeySequence);
-    Events_Error::send(aMessage.toStdString());
-    return QKeySequence();
-  }
-  myShortcuts.append(aResult);
-  return aResult;
+  static Events_ID aStateRequestEventId = Events_Loop::loop()->eventByName(
+      EVENT_FEATURE_STATE_REQUEST);
+  std::shared_ptr<ModelAPI_FeatureStateMessage> aMsg =
+      std::make_shared<ModelAPI_FeatureStateMessage>(aStateRequestEventId, this);
+  aMsg->setFeature(anActiveFeature);
+  Events_Loop::loop()->send(aMsg, false);
 }
index 8df73304db8b4a2f1a8031d62ddb664277219b08..3101cb0bd0acfd606493d24b5beea70c9bbac00e 100644 (file)
@@ -1,3 +1,5 @@
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D -->
+
 /*
  * XGUI_ActionsMgr.h
  */
@@ -7,19 +9,21 @@
 
 #include "XGUI.h"
 
+#include <Events_Listener.h>
+#include <ModelAPI_Feature.h>
+
 #include <QObject>
 #include <QMap>
 #include <QList>
 #include <QStringList>
 #include <QKeySequence>
 
-class XGUI_Command;
 class XGUI_Workshop;
 class XGUI_OperationMgr;
 class ModuleBase_Operation;
 class QAction;
 
-class XGUI_EXPORT XGUI_ActionsMgr : public QObject
+class XGUI_EXPORT XGUI_ActionsMgr : public QObject, public Events_Listener
 {
 Q_OBJECT
 
@@ -28,7 +32,7 @@ Q_OBJECT
   virtual ~XGUI_ActionsMgr();
 
   //! Add a command in the manager.
-  //! Please note that nested commands in the Salome mode (No XGUI_Command, pure QActions)
+  //! Please note that nested commands in the Salome mode (No AppElements_Command, pure QActions)
   //! won't be extracted and should be added manually using the addNestedCommands method.
   void addCommand(QAction* theCmd);
   //! Sets relation between the command (with given Id) and it's nested actions.
@@ -40,7 +44,8 @@ Q_OBJECT
 
   QKeySequence registerShortcut(const QString& theKeySequence);
 
-  void updateByDocumentKind();
+  //! Redefinition of Events_Listener method
+  virtual void processEvent(const std::shared_ptr<Events_Message>& theMessage);
 
  public slots:
   //! Update workbench actions according to OperationMgr state:
@@ -50,19 +55,25 @@ Q_OBJECT
   void update();
   //! Sets all commands checked if it's operation is active.
   void updateCheckState();
+  //! Updates actions according to current selection in the viewer
+  void updateOnViewSelection();
 
  protected:
   //! Sets all actions to isEnabled state.
   void setAllEnabled(bool isEnabled);
-  //! Sets to isEnabled state all siblings of the given operation and it's parents recursively
-  void setNestedStackEnabled(ModuleBase_Operation* theOperation);
   //! Sets all nested actions to isEnabled state for the command with given ID.
   //! If ID is empty - all nested actions will be affected.
   void setNestedCommandsEnabled(bool isEnabled, const QString& theParent = QString());
+  //! Sets to enabled state all siblings of the given operation and it's parents recursively
+  void setNestedStackEnabled(ModuleBase_Operation* theOperation);
   //! Sets the action with theId to theChecked state.
   void setActionChecked(const QString& theId, const bool theChecked);
   //! Sets the action with theId to theEnabled state.
   void setActionEnabled(const QString& theId, const bool theEnabled);
+  //! Updates actions according to their "document" tag
+  void updateByDocumentKind();
+  //! Asks plugins about their features state, using the Events system
+  void updateByPlugins(FeaturePtr theActiveFeature);
 
  private:
   QMap<QString, QAction*> myActions;
diff --git a/src/XGUI/XGUI_Command.cpp b/src/XGUI/XGUI_Command.cpp
deleted file mode 100644 (file)
index 1194dc4..0000000
+++ /dev/null
@@ -1,85 +0,0 @@
-#include "XGUI_Command.h"
-#include <QEvent>
-#include <QToolButton>
-#include <QVariant>
-#include <QDebug>
-
-XGUI_Command::XGUI_Command(const QString& theId,
-                           const QString& theDocumentKind,
-                           QObject * parent,
-                           bool isCheckable)
-    : QWidgetAction(parent),
-      myCheckable(isCheckable),
-      myDocumentKind(theDocumentKind)
-{
-  setData(theId);
-}
-
-XGUI_Command::XGUI_Command(const QString& theId,
-                           const QString& theDocumentKind,
-                           const QIcon& icon,
-                           const QString& text,
-                           QObject* parent,
-                           bool isCheckable)
-    : QWidgetAction(parent),
-      myCheckable(isCheckable),
-      myDocumentKind(theDocumentKind)
-{
-  setIcon(icon);
-  setText(text);
-  setData(theId);
-}
-
-XGUI_Command::~XGUI_Command()
-{
-}
-
-const QString& XGUI_Command::documentKind() const
-{
-  return myDocumentKind;
-}
-
-QWidget* XGUI_Command::createWidget(QWidget* theParent)
-{
-  if (theParent->inherits("XGUI_MenuGroupPanel")) {
-    QToolButton* aButton = new QToolButton(theParent);
-    aButton->setIcon(icon());
-    aButton->setText(text());
-    QKeySequence aKeys = shortcut();
-    QString aToolTip = toolTip();
-    if (!aKeys.isEmpty()) {
-      aToolTip = QString("%1 (%2)").arg(aToolTip).arg(aKeys.toString());
-      aButton->setShortcut(aKeys);
-    }
-    if (!aToolTip.isEmpty()) {
-      aButton->setToolTip(aToolTip);
-    }
-    aButton->setCheckable(myCheckable);
-    aButton->setAutoRaise(true);
-    aButton->setToolButtonStyle(Qt::ToolButtonTextBesideIcon);
-    aButton->setMinimumSize(MIN_BUTTON_WIDTH, MIN_BUTTON_HEIGHT);
-    aButton->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Fixed);
-
-    connect(aButton, SIGNAL(clicked()), this, SLOT(trigger()));
-    connect(this, SIGNAL(toggled(bool)), aButton, SLOT(setChecked(bool)));
-    this->setCheckable(myCheckable);
-
-    return aButton;
-  }
-  return QWidgetAction::createWidget(theParent);
-}
-
-void XGUI_Command::connectTo(const QObject* theResiver, const char* theSlot)
-{
-  connect(this, SIGNAL(triggered(bool)), theResiver, theSlot);
-}
-
-const QStringList& XGUI_Command::nestedCommands() const
-{
-  return myNestedCommands;
-}
-
-void XGUI_Command::setNestedCommands(const QStringList& myUnblockableCommands)
-{
-  this->myNestedCommands = myUnblockableCommands;
-}
diff --git a/src/XGUI/XGUI_Command.h b/src/XGUI/XGUI_Command.h
deleted file mode 100644 (file)
index 0f5aa62..0000000
+++ /dev/null
@@ -1,44 +0,0 @@
-#ifndef XGUI_Command_H
-#define XGUI_Command_H
-
-#include "XGUI.h"
-#include <QWidgetAction>
-
-#define MIN_BUTTON_HEIGHT 25
-#define MIN_BUTTON_WIDTH 60
-
-/**\class XGUI_Command
- * \ingroup GUI
- * \brief Represents a command item in the application menu (Workbench)
- */
-class XGUI_EXPORT XGUI_Command : public QWidgetAction
-{
-Q_OBJECT
- public:
-  XGUI_Command(const QString& theId, const QString& theDocumentKind,
-               QObject * parent, bool isCheckable = false);
-  XGUI_Command(const QString& theId, const QString& theDocumentKind,
-               const QIcon& icon, const QString& text, QObject* parent,
-               bool isCheckable = false);
-  ~XGUI_Command();
-
-  const QString& documentKind() const;
-  const QStringList& nestedCommands() const;
-  void setNestedCommands(const QStringList& myUnblockableCommands);
-
-  //! Connect the command to a slot
-  virtual void connectTo(const QObject* theResiver, const char* theSlot);
-
- protected:
-  //! Creates a command representation widget dependently on parent widget type
-  virtual QWidget* createWidget(QWidget* theParent);
-
- private:
-  bool myCheckable;
-
-  QString myDocumentKind;
-  //! List of Ids of commands which WILL NOT be blocked when the command is on.
-  QStringList myNestedCommands;
-};
-
-#endif
diff --git a/src/XGUI/XGUI_Constants.h b/src/XGUI/XGUI_Constants.h
deleted file mode 100644 (file)
index 5abd457..0000000
+++ /dev/null
@@ -1,85 +0,0 @@
-#ifndef XGUI_Constants_H
-#define XGUI_Constants_H
-
-namespace XGUI {
-
-//! Types of gradient type used in background of Viewer 3d
-enum GradientType
-{
-  NoGradient = -1,
-  HorizontalGradient,
-  VerticalGradient,
-  Diagonal1Gradient,
-  Diagonal2Gradient,
-  Corner1Gradient,
-  Corner2Gradient,
-  Corner3Gradient,
-  Corner4Gradient,
-  LastGradient = Corner4Gradient
-};
-
-//! Type of rotation point in viewer 3d
-enum RotationPointType
-{
-  GRAVITY,
-  SELECTED
-};
-
-//! Type of ribbon rect in Viewer 3d
-enum SketchingType
-{
-  NoSketching,
-  Rect,
-  Polygon
-};
-
-//! View window operations accessible by hot keys
-enum HotOperation
-{
-  PAN,
-  ZOOM,
-  ROTATE,
-  FIT_AREA
-};
-
-//! Types of view window interactions
-enum InteractionStyle
-{
-  STANDARD,
-  KEY_FREE
-};
-
-//! Types of 2d mode in viewer 3d
-enum Mode2dType
-{
-  No2dMode,
-  XYPlane,
-  XZPlane,
-  YZPlane
-};
-
-//! Types of background in view window
-//enum BackgroundMode
-//{
-//  NoBackground,              // no (invalid) background data
-//  ColorBackground,           // single color
-//  SimpleGradientBackground,  // simple two-color gradient
-//  CustomGradientBackground   // custom (complex) gradient
-//};
-
-//! Texture mode
-enum TextureMode
-{
-  CenterTexture,             // center texture
-  TileTexture,               // tile texture
-  StretchTexture,            // stretch texture
-};
-
-const static char* PROP_PANEL = "property_panel_dock";
-const static char* PROP_PANEL_OK = "property_panel_ok";
-const static char* PROP_PANEL_CANCEL = "property_panel_cancel";
-
-}
-;
-
-#endif
index 73808b9af3530d9c62112014c008dc16a77ac57a..8f4a49175b051d78f46dfee7224e8db3e184691e 100644 (file)
@@ -1,13 +1,16 @@
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D -->
+
 #include "XGUI_ContextMenuMgr.h"
 #include "XGUI_Workshop.h"
 #include "XGUI_ObjectsBrowser.h"
 #include "XGUI_SelectionMgr.h"
 #include "XGUI_Displayer.h"
-#include "XGUI_MainWindow.h"
 #include "XGUI_ViewerProxy.h"
 #include "XGUI_Selection.h"
 
-#include "PartSetPlugin_Part.h"
+#include <AppElements_MainWindow.h>
+
+//#include "PartSetPlugin_Part.h"
 
 #include <ModelAPI_Data.h>
 #include <ModelAPI_AttributeDocRef.h>
@@ -114,7 +117,7 @@ QMenu* XGUI_ContextMenuMgr::objectBrowserMenu() const
 {
   QMenu* aMenu = new QMenu();
   XGUI_SelectionMgr* aSelMgr = myWorkshop->selector();
-  QList<ObjectPtr> aObjects = aSelMgr->selection()->selectedObjects();
+  QObjectPtrList aObjects = aSelMgr->selection()->selectedObjects();
   int aSelected = aObjects.size();
   if (aSelected > 0) {
     SessionPtr aMgr = ModelAPI_Session::get();
@@ -197,7 +200,7 @@ QMenu* XGUI_ContextMenuMgr::viewerMenu() const
 void XGUI_ContextMenuMgr::addViewerItems(QMenu* theMenu) const
 {
   XGUI_SelectionMgr* aSelMgr = myWorkshop->selector();
-  QList<ObjectPtr> aObjects = aSelMgr->selection()->selectedObjects();
+  QObjectPtrList aObjects = aSelMgr->selection()->selectedObjects();
   if (aObjects.size() > 0) {
     //if (aObjects.size() == 1)
     //  theMenu->addAction(action("EDIT_CMD"));
index 64c846b18e2bd1aababd9f6da27b7438b613d69a..c7af183f4e104de9ded8fb8a1d6fce0cf1e5a3ae 100644 (file)
@@ -1,3 +1,5 @@
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D -->
+
 #ifndef XGUI_ContextMenuMgr_H
 #define XGUI_ContextMenuMgr_H
 
index 075c1e1621ea41928eb8873e23ec8177e6d2d60d..72a3d93f5f4019787a1d1753a1acccb09d4d85f9 100644 (file)
@@ -1,8 +1,9 @@
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D -->
+
 #ifndef XGUI_DataTreeModel_H
 #define XGUI_DataTreeModel_H
 
 #include "XGUI.h"
-#include "XGUI_Constants.h"
 
 #include <ModelAPI_Document.h>
 #include <ModelAPI_Feature.h>
index 0d0f6e384e3c6e21197237272ab2152bef0a4273..17f52eb5f9d01d15f23be14a58cd1c1862a1cb74 100644 (file)
@@ -1,12 +1,15 @@
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D -->
+
 // File:        XGUI_Displayer.cpp
 // Created:     20 Apr 2014
 // Author:      Natalia ERMOLAEVA
 
 #include "XGUI_Displayer.h"
-#include "XGUI_Viewer.h"
 #include "XGUI_Workshop.h"
 #include "XGUI_ViewerProxy.h"
 
+#include <AppElements_Viewer.h>
+
 #include <ModelAPI_Document.h>
 #include <ModelAPI_Data.h>
 #include <ModelAPI_Object.h>
@@ -16,6 +19,7 @@
 
 #include <GeomAPI_Shape.h>
 #include <GeomAPI_IPresentable.h>
+#include <GeomAPI_ICustomPrs.h>
 
 #include <AIS_InteractiveContext.hxx>
 #include <AIS_LocalContext.hxx>
@@ -43,7 +47,7 @@ XGUI_Displayer::~XGUI_Displayer()
 
 bool XGUI_Displayer::isVisible(ObjectPtr theObject) const
 {
-  return myResult2AISObjectMap.find(theObject) != myResult2AISObjectMap.end();
+  return myResult2AISObjectMap.contains(theObject);
 }
 
 void XGUI_Displayer::display(ObjectPtr theObject, bool isUpdateViewer)
@@ -55,13 +59,13 @@ void XGUI_Displayer::display(ObjectPtr theObject, bool isUpdateViewer)
 
     GeomPresentablePtr aPrs = std::dynamic_pointer_cast<GeomAPI_IPresentable>(theObject);
     bool isShading = false;
-    if (aPrs) {
+    if (aPrs.get() != NULL) {
       anAIS = aPrs->getAISObject(AISObjectPtr());
     } else {
       ResultPtr aResult = std::dynamic_pointer_cast<ModelAPI_Result>(theObject);
-      if (aResult) {
+      if (aResult.get() != NULL) {
         std::shared_ptr<GeomAPI_Shape> aShapePtr = ModelAPI_Tools::shape(aResult);
-        if (aShapePtr) {
+        if (aShapePtr.get() != NULL) {
           anAIS = AISObjectPtr(new GeomAPI_AISObject());
           anAIS->setImpl(new Handle(AIS_InteractiveObject)(new ModuleBase_ResultPrs(aResult)));
           //anAIS->createShape(aShapePtr);
@@ -85,7 +89,14 @@ void XGUI_Displayer::display(ObjectPtr theObject, AISObjectPtr theAIS,
   if (!anAISIO.IsNull()) {
     myResult2AISObjectMap[theObject] = theAIS;
     aContext->Display(anAISIO, false);
-    aContext->SetDisplayMode(anAISIO, isShading? Shading : Wireframe, isUpdateViewer);
+    aContext->SetDisplayMode(anAISIO, isShading? Shading : Wireframe, false);
+
+    FeaturePtr aFeature = ModelAPI_Feature::feature(theObject);
+    if (aFeature.get() != NULL) {
+      GeomCustomPrsPtr aCustPrs = std::dynamic_pointer_cast<GeomAPI_ICustomPrs>(aFeature);
+      if (aCustPrs.get() != NULL)
+        aCustPrs->customisePresentation(theAIS);
+    }
     if (aContext->HasOpenedContext()) {
       if (myUseExternalObjects) {
         if (myActiveSelectionModes.size() == 0)
@@ -98,6 +109,8 @@ void XGUI_Displayer::display(ObjectPtr theObject, AISObjectPtr theAIS,
       }
     }
   }
+  if (isUpdateViewer)
+    updateViewer();
 }
 
 void XGUI_Displayer::erase(ObjectPtr theObject, const bool isUpdateViewer)
@@ -115,7 +128,7 @@ void XGUI_Displayer::erase(ObjectPtr theObject, const bool isUpdateViewer)
       aContext->Remove(anAIS, isUpdateViewer);
     }
   }
-  myResult2AISObjectMap.erase(theObject);
+  myResult2AISObjectMap.remove(theObject);
 }
 
 void XGUI_Displayer::redisplay(ObjectPtr theObject, bool isUpdateViewer)
@@ -160,6 +173,12 @@ void XGUI_Displayer::deactivate(ObjectPtr theObject)
   }
 }
 
+void XGUI_Displayer::activate(ObjectPtr theFeature)
+{
+  QIntList aModes;
+  activate(theFeature, aModes);
+}
+
 void XGUI_Displayer::activate(ObjectPtr theObject, const QIntList& theModes)
 {
   if (isVisible(theObject)) {
@@ -189,7 +208,7 @@ bool XGUI_Displayer::isActive(ObjectPtr theObject) const
   if (!isVisible(theObject))
     return false;
     
-  AISObjectPtr anObj = myResult2AISObjectMap.at(theObject);
+  AISObjectPtr anObj = myResult2AISObjectMap[theObject];
   Handle(AIS_InteractiveObject) anAIS = anObj->impl<Handle(AIS_InteractiveObject)>();
 
   TColStd_ListOfInteger aModes;
@@ -197,7 +216,7 @@ bool XGUI_Displayer::isActive(ObjectPtr theObject) const
   return aModes.Extent() > 0;
 }
 
-void XGUI_Displayer::stopSelection(const QList<ObjectPtr>& theResults, const bool isStop,
+void XGUI_Displayer::stopSelection(const QObjectPtrList& theResults, const bool isStop,
                                    const bool isUpdateViewer)
 {
   Handle(AIS_InteractiveContext) aContext = AISContext();
@@ -205,7 +224,7 @@ void XGUI_Displayer::stopSelection(const QList<ObjectPtr>& theResults, const boo
     return;
 
   Handle(AIS_Shape) anAIS;
-  QList<ObjectPtr>::const_iterator anIt = theResults.begin(), aLast = theResults.end();
+  QObjectPtrList::const_iterator anIt = theResults.begin(), aLast = theResults.end();
   ObjectPtr aFeature;
   for (; anIt != aLast; anIt++) {
     aFeature = *anIt;
@@ -233,23 +252,32 @@ void XGUI_Displayer::stopSelection(const QList<ObjectPtr>& theResults, const boo
     updateViewer();
 }
 
-void XGUI_Displayer::setSelected(const QList<ObjectPtr>& theResults, const bool isUpdateViewer)
+void XGUI_Displayer::setSelected(const QObjectPtrList& theResults, const bool isUpdateViewer)
 {
   Handle(AIS_InteractiveContext) aContext = AISContext();
-  // we need to unhighligth objects manually in the current local context
-  // in couple with the selection clear (TODO)
-  Handle(AIS_LocalContext) aLocalContext = aContext->LocalContext();
-  if (!aLocalContext.IsNull())
-    aLocalContext->UnhilightLastDetected(myWorkshop->viewer()->activeView());
-
-  aContext->ClearSelected();
-  foreach(ObjectPtr aResult, theResults)
-  {
-    if (isVisible(aResult)) {
-      AISObjectPtr anObj = myResult2AISObjectMap[aResult];
-      Handle(AIS_InteractiveObject) anAIS = anObj->impl<Handle(AIS_InteractiveObject)>();
-      if (!anAIS.IsNull())
-        aContext->SetSelected(anAIS, false);
+  if (aContext.IsNull())
+    return;
+  if (aContext->HasOpenedContext()) {
+    aContext->UnhilightSelected();
+    aContext->ClearSelected();
+    foreach(ObjectPtr aResult, theResults) {
+      if (isVisible(aResult)) {
+        AISObjectPtr anObj = myResult2AISObjectMap[aResult];
+        Handle(AIS_InteractiveObject) anAIS = anObj->impl<Handle(AIS_InteractiveObject)>();
+        if (!anAIS.IsNull())
+          aContext->SetSelected(anAIS, false);
+      }
+    }
+  } else {
+    aContext->UnhilightCurrents();
+    aContext->ClearCurrents();
+    foreach(ObjectPtr aResult, theResults) {
+      if (isVisible(aResult)) {
+        AISObjectPtr anObj = myResult2AISObjectMap[aResult];
+        Handle(AIS_InteractiveObject) anAIS = anObj->impl<Handle(AIS_InteractiveObject)>();
+        if (!anAIS.IsNull())
+          aContext->SetCurrentObject(anAIS, false);
+      }
     }
   }
   if (isUpdateViewer)
@@ -268,17 +296,15 @@ void XGUI_Displayer::clearSelected()
 
 void XGUI_Displayer::eraseAll(const bool isUpdateViewer)
 {
-  Handle(AIS_InteractiveContext) ic = AISContext();
-  if (ic.IsNull())
+  Handle(AIS_InteractiveContext) aContext = AISContext();
+  if (aContext.IsNull())
     return;
 
-   ResultToAISMap::iterator aIt;
-   for (aIt = myResult2AISObjectMap.begin(); aIt != myResult2AISObjectMap.end(); aIt++) {
+   foreach (AISObjectPtr aAISObj, myResult2AISObjectMap) {
      // erase an object
-     AISObjectPtr aAISObj = (*aIt).second;
      Handle(AIS_InteractiveObject) anIO = aAISObj->impl<Handle(AIS_InteractiveObject)>();
      if (!anIO.IsNull())
-      ic->Remove(anIO, false);
+       aContext->Remove(anIO, false);
    }
    myResult2AISObjectMap.clear();
    if (isUpdateViewer)
@@ -291,25 +317,21 @@ void XGUI_Displayer::eraseDeletedResults(const bool isUpdateViewer)
   if (aContext.IsNull())
     return;
 
-  ResultToAISMap::const_iterator aFIt = myResult2AISObjectMap.begin(), aFLast =
-      myResult2AISObjectMap.end();
-  std::list<ObjectPtr> aRemoved;
-  for (; aFIt != aFLast; aFIt++) {
-    ObjectPtr aFeature = (*aFIt).first;
+  QObjectPtrList aRemoved;
+  foreach (ObjectPtr aFeature, myResult2AISObjectMap.keys()) {
     if (!aFeature || !aFeature->data() || !aFeature->data()->isValid()) {
-      AISObjectPtr anObj = (*aFIt).second;
+      AISObjectPtr anObj = myResult2AISObjectMap[aFeature];
       if (!anObj)
         continue;
       Handle(AIS_InteractiveObject) anAIS = anObj->impl<Handle(AIS_InteractiveObject)>();
       if (!anAIS.IsNull()) {
         aContext->Remove(anAIS, false);
-        aRemoved.push_back(aFeature);
+        aRemoved.append(aFeature);
       }
     }
   }
-  std::list<ObjectPtr>::const_iterator anIt = aRemoved.begin(), aLast = aRemoved.end();
-  for (; anIt != aLast; anIt++) {
-    myResult2AISObjectMap.erase(myResult2AISObjectMap.find(*anIt));
+  foreach(ObjectPtr aObj, aRemoved) {
+    myResult2AISObjectMap.remove(aObj);
   }
 
   if (isUpdateViewer)
@@ -323,27 +345,91 @@ void XGUI_Displayer::openLocalContext()
     return;
   // Open local context if there is no one
   if (!aContext->HasOpenedContext()) {
-    aContext->ClearCurrents(false);
-    //aContext->OpenLocalContext(false/*use displayed objects*/, true/*allow shape decomposition*/);
+    // Preserve selected objects
+    //AIS_ListOfInteractive aAisList;
+    //for (aContext->InitCurrent(); aContext->MoreCurrent(); aContext->NextCurrent())
+    //  aAisList.Append(aContext->Current());
+
+    // get the filters from the global context and append them to the local context
+    // a list of filters in the global context is not cleared and should be cleared here
+    SelectMgr_ListOfFilter aFilters;
+    aFilters.Assign(aContext->Filters());
+    // it is important to remove the filters in the global context, because there is a code
+    // in the closeLocalContex, which restore the global context filters
+    aContext->RemoveFilters();
+
+    aContext->ClearCurrents();
     aContext->OpenLocalContext();
     aContext->NotUseDisplayedObjects();
 
     myUseExternalObjects = false;
     myActiveSelectionModes.clear();
+
+    SelectMgr_ListIteratorOfListOfFilter aIt(aFilters);
+    for (;aIt.More(); aIt.Next()) {
+      aContext->AddFilter(aIt.Value());
+    }
+    // Restore selection
+    //AIS_ListIteratorOfListOfInteractive aIt2(aAisList);
+    //for(; aIt2.More(); aIt2.Next()) {
+    //  aContext->SetSelected(aIt2.Value(), false);
+    //}
   }
 }
 
 void XGUI_Displayer::closeLocalContexts(const bool isUpdateViewer)
 {
-  AISContext()->ClearSelected(false);
-  closeAllContexts(true);
+  Handle(AIS_InteractiveContext) aContext = AISContext();
+  if ( (!aContext.IsNull()) && (aContext->HasOpenedContext()) ) {
+    // Preserve selected objects
+    //AIS_ListOfInteractive aAisList;
+    //for (aContext->InitSelected(); aContext->MoreSelected(); aContext->NextSelected())
+    //  aAisList.Append(aContext->SelectedInteractive());
+
+    // get the filters from the local context and append them to the global context
+    // a list of filters in the local context is cleared
+    SelectMgr_ListOfFilter aFilters;
+    aFilters.Assign(aContext->Filters());
+
+    aContext->ClearSelected();
+    aContext->CloseAllContexts(false);
+
+    // Redisplay all object if they were displayed in localContext
+    Handle(AIS_InteractiveObject) aAISIO;
+    foreach (AISObjectPtr aAIS, myResult2AISObjectMap) {
+      aAISIO = aAIS->impl<Handle(AIS_InteractiveObject)>();
+      if (aContext->DisplayStatus(aAISIO) != AIS_DS_Displayed) {
+        aContext->Display(aAISIO, false);
+        aContext->SetDisplayMode(aAISIO, Shading, false);
+      }
+    }
+
+    // Append the filters from the local selection in the global selection context
+    SelectMgr_ListIteratorOfListOfFilter aIt(aFilters);
+    for (;aIt.More(); aIt.Next()) {
+      Handle(SelectMgr_Filter) aFilter = aIt.Value();
+      aContext->AddFilter(aFilter);
+    }
+
+    if (isUpdateViewer)
+      updateViewer();
+    myUseExternalObjects = false;
+    myActiveSelectionModes.clear();
+
+    // Restore selection
+    //AIS_ListIteratorOfListOfInteractive aIt2(aAisList);
+    //for(; aIt2.More(); aIt2.Next()) {
+    //  if (aContext->IsDisplayed(aIt2.Value()))
+    //    aContext->SetCurrentObject(aIt2.Value(), false);
+    //}
+  }
 }
 
 AISObjectPtr XGUI_Displayer::getAISObject(ObjectPtr theObject) const
 {
   AISObjectPtr anIO;
-  if (myResult2AISObjectMap.find(theObject) != myResult2AISObjectMap.end())
-    anIO = (myResult2AISObjectMap.find(theObject))->second;
+  if (myResult2AISObjectMap.contains(theObject))
+    anIO = myResult2AISObjectMap[theObject];
   return anIO;
 }
 
@@ -356,37 +442,20 @@ ObjectPtr XGUI_Displayer::getObject(const AISObjectPtr& theIO) const
 ObjectPtr XGUI_Displayer::getObject(const Handle(AIS_InteractiveObject)& theIO) const
 {
   ObjectPtr aFeature;
-  ResultToAISMap::const_iterator aFIt = myResult2AISObjectMap.begin(), aFLast =
-      myResult2AISObjectMap.end();
-  for (; aFIt != aFLast && !aFeature; aFIt++) {
-    AISObjectPtr anObj = (*aFIt).second;
-    if (!anObj)
-      continue;
-    Handle(AIS_InteractiveObject) anAIS = anObj->impl<Handle(AIS_InteractiveObject)>();
-    if (anAIS != theIO)
-      continue;
-    aFeature = (*aFIt).first;
+  foreach (ObjectPtr anObj, myResult2AISObjectMap.keys()) {
+    AISObjectPtr aAIS = myResult2AISObjectMap[anObj];
+    Handle(AIS_InteractiveObject) anAIS = aAIS->impl<Handle(AIS_InteractiveObject)>();
+    if (anAIS == theIO)
+      return anObj;
   }
   return aFeature;
 }
 
-void XGUI_Displayer::closeAllContexts(const bool isUpdateViewer)
-{
-  Handle(AIS_InteractiveContext) ic = AISContext();
-  if (!ic.IsNull()) {
-    ic->CloseAllContexts(false);
-    if (isUpdateViewer)
-      updateViewer();
-    myUseExternalObjects = false;
-    myActiveSelectionModes.clear();
-  }
-}
-
 void XGUI_Displayer::updateViewer()
 {
-  Handle(AIS_InteractiveContext) ic = AISContext();
-  if (!ic.IsNull())
-    ic->UpdateCurrentViewer();
+  Handle(AIS_InteractiveContext) aContext = AISContext();
+  if (!aContext.IsNull())
+    aContext->UpdateCurrentViewer();
 }
 
 Handle(AIS_InteractiveContext) XGUI_Displayer::AISContext() const
@@ -394,6 +463,16 @@ Handle(AIS_InteractiveContext) XGUI_Displayer::AISContext() const
   return myWorkshop->viewer()->AISContext();
 }
 
+Handle(SelectMgr_AndFilter) XGUI_Displayer::GetFilter()
+{
+  Handle(AIS_InteractiveContext) aContext = AISContext();
+  if (myAndFilter.IsNull() && !aContext.IsNull()) {
+    myAndFilter = new SelectMgr_AndFilter();
+    aContext->AddFilter(myAndFilter);
+  }
+  return myAndFilter;
+}
+
 void XGUI_Displayer::displayAIS(AISObjectPtr theAIS, bool isUpdate)
 {
   Handle(AIS_InteractiveContext) aContext = AISContext();
@@ -423,7 +502,7 @@ void XGUI_Displayer::eraseAIS(AISObjectPtr theAIS, const bool isUpdate)
   }
 }
 
-void XGUI_Displayer::activateObjectsOutOfContext(const QIntList& theModes)
+void XGUI_Displayer::activateObjects(const QIntList& theModes)
 {
   Handle(AIS_InteractiveContext) aContext = AISContext();
   // Open local context if there is no one
@@ -448,10 +527,18 @@ void XGUI_Displayer::activateObjectsOutOfContext(const QIntList& theModes)
     }
   }
 
-  ResultToAISMap::iterator aIt;
+  //Activate all displayed objects with the module modes
+  //AIS_ListOfInteractive aPrsList;
+  //aContext->DisplayedObjects(aPrsList, true);
+
+  //AIS_ListIteratorOfListOfInteractive aLIt(aPrsList);
   Handle(AIS_InteractiveObject) anAISIO;
-  for (aIt = myResult2AISObjectMap.begin(); aIt != myResult2AISObjectMap.end(); aIt++) {
-  anAISIO = (*aIt).second->impl<Handle(AIS_InteractiveObject)>();
+  for(aLIt.Initialize(aPrsList); aLIt.More(); aLIt.Next()){
+    anAISIO = aLIt.Value();
+    aTrihedron = Handle(AIS_Trihedron)::DownCast(anAISIO);
+    if (!aTrihedron.IsNull())
+      continue;
+
     aContext->Load(anAISIO, -1, true);
     if (theModes.size() == 0)
       aContext->Activate(anAISIO);
@@ -464,7 +551,7 @@ void XGUI_Displayer::activateObjectsOutOfContext(const QIntList& theModes)
 }
 
 
-void XGUI_Displayer::deactivateObjectsOutOfContext()
+void XGUI_Displayer::deactivateObjects()
 {
   Handle(AIS_InteractiveContext) aContext = AISContext();
   // Open local context if there is no one
@@ -492,28 +579,6 @@ void XGUI_Displayer::setDisplayMode(ObjectPtr theObject, DisplayMode theMode, bo
   aContext->SetDisplayMode(aAISIO, theMode, toUpdate);
 }
 
-void XGUI_Displayer::setSelectionModes(const QIntList& theModes)
-{
-  Handle(AIS_InteractiveContext) aContext = AISContext();
-  if (aContext.IsNull())
-    return;
-  if (!aContext->HasOpenedContext())
-    return;
-  // Clear previous mode
-  const TColStd_ListOfInteger& aModes = aContext->ActivatedStandardModes();
-  if (!aModes.IsEmpty()) {
-    TColStd_ListOfInteger aMModes;
-    aMModes.Assign(aModes);
-    TColStd_ListIteratorOfListOfInteger it(aMModes);
-    for(; it.More(); it.Next()) {
-      aContext->DeactivateStandardMode((TopAbs_ShapeEnum)it.Value());
-    }
-  }
-  foreach(int aMode, theModes) {
-    aContext->ActivateStandardMode((TopAbs_ShapeEnum)aMode);
-  }
-}
-
 XGUI_Displayer::DisplayMode XGUI_Displayer::displayMode(ObjectPtr theObject) const
 {
   Handle(AIS_InteractiveContext) aContext = AISContext();
@@ -539,7 +604,7 @@ void XGUI_Displayer::addSelectionFilter(const Handle(SelectMgr_Filter)& theFilte
     if (theFilter.Access() == aIt.Value().Access())
       return;
   }
-  aContext->AddFilter(theFilter);
+  GetFilter()->Add(theFilter);
 }
 
 void XGUI_Displayer::removeSelectionFilter(const Handle(SelectMgr_Filter)& theFilter)
@@ -547,5 +612,27 @@ void XGUI_Displayer::removeSelectionFilter(const Handle(SelectMgr_Filter)& theFi
   Handle(AIS_InteractiveContext) aContext = AISContext();
   if (aContext.IsNull())
     return;
-  aContext->RemoveFilter(theFilter);
+  GetFilter()->Remove(theFilter);
+}
+
+void XGUI_Displayer::removeFilters()
+{
+  Handle(AIS_InteractiveContext) aContext = AISContext();
+  if (aContext.IsNull())
+    return;
+  GetFilter()->Clear();
+}
+
+void XGUI_Displayer::showOnly(const QObjectPtrList& theList)
+{
+  QObjectPtrList aDispList = myResult2AISObjectMap.keys();
+  foreach(ObjectPtr aObj, aDispList) {
+    if (!theList.contains(aObj))
+      erase(aObj, false);
+  }
+  foreach(ObjectPtr aObj, theList) {
+    if (!isVisible(aObj))
+      display(aObj, false);
+  }
+  updateViewer();
 }
index 5d770e85ee5b2dd9ae95072d492f4ed6c3911e71..7fbbd814d07e758e733545588f25d6b9d2407f9e 100644 (file)
@@ -1,3 +1,5 @@
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D -->
+
 // File:        XGUI_Displayer.h
 // Created:     20 Apr 2014
 // Author:      Natalia ERMOLAEVA
@@ -7,11 +9,7 @@
 
 #include "XGUI.h"
 
-#include <QString>
-#include <memory>
-
 #include <GeomAPI_AISObject.h>
-
 #include <TopoDS_Shape.hxx>
 #include <AIS_InteractiveObject.hxx>
 #include <AIS_InteractiveContext.hxx>
 #include <ModuleBase_Definitions.h>
 #include <ModuleBase_ViewerPrs.h>
 
-#include <map>
-#include <vector>
-#include <list>
+#include <SelectMgr_AndFilter.hxx>
+
+#include <QString>
+#include <QMap>
 
-class XGUI_Viewer;
 class ModelAPI_Feature;
 class XGUI_Workshop;
 
@@ -62,7 +60,7 @@ class XGUI_EXPORT XGUI_Displayer
   /// \param theFeatures a list of features to be disabled
   /// \param theToStop the boolean state whether it it stopped or non stopped
   /// \param isUpdateViewer the parameter whether the viewer should be update immediatelly
-  void stopSelection(const QList<ObjectPtr>& theFeatures, const bool isStop,
+  void stopSelection(const QObjectPtrList& theFeatures, const bool isStop,
                      const bool isUpdateViewer);
 
   /**
@@ -70,7 +68,7 @@ class XGUI_EXPORT XGUI_Displayer
    * \param theFeatures a list of features to be selected
    * isUpdateViewer the parameter whether the viewer should be update immediatelly
    */
-  void setSelected(const QList<ObjectPtr>& theFeatures, bool isUpdateViewer = true);
+  void setSelected(const QObjectPtrList& theFeatures, bool isUpdateViewer = true);
 
 
   /// Un select all objects
@@ -99,17 +97,12 @@ class XGUI_EXPORT XGUI_Displayer
   /// \param isUpdateViewer the parameter whether the viewer should be update immediatelly
   void closeLocalContexts(const bool isUpdateViewer = true);
 
-  /*
-  * Set modes of selections. Selection mode has to be defined by TopAbs_ShapeEnum.
-  * It doesn't manages a local context
-  * \param theModes - list of selection modes. If the list is empty then all selectoin modes will be cleared.
-  */
-  void setSelectionModes(const QIntList& theModes);
-
   void addSelectionFilter(const Handle(SelectMgr_Filter)& theFilter);
 
   void removeSelectionFilter(const Handle(SelectMgr_Filter)& theFilter);
 
+  void removeFilters();
+
   /// Updates the viewer
   void updateViewer();
 
@@ -131,34 +124,41 @@ class XGUI_EXPORT XGUI_Displayer
   /// \param theModes - modes on which it has to be activated (can be empty)
   void activate(ObjectPtr theFeature, const QIntList& theModes);
 
+  /// Activates the given object with default modes
+  void activate(ObjectPtr theFeature);
+
   /// Returns true if the given object can be selected
   bool isActive(ObjectPtr theObject) const;
 
   /// Activates in local context displayed outside of the context.
   /// \param theModes - modes on which it has to be activated (can be empty)
-  void activateObjectsOutOfContext(const QIntList& theModes);
+  void activateObjects(const QIntList& theModes);
 
   /// Activates in local context displayed outside of the context.
-  void deactivateObjectsOutOfContext();
+  void deactivateObjects();
 
   /// Sets display mode for the given object if this object is displayed
   void setDisplayMode(ObjectPtr theObject, DisplayMode theMode, bool toUpdate = true);
 
   /// Returns current display mode for the given object.
-  /// If object is not displayed then returns NoMode.
+  /// If object is not dis played then returns NoMode.
   DisplayMode displayMode(ObjectPtr theObject) const;
 
 
+  /// Displays only objects listed in the list
+  void showOnly(const QObjectPtrList& theList);
+
+  /// Returns number of displayed objects
   int objectsCount() const { return myResult2AISObjectMap.size(); }
 
  protected:
-  /// Deactivate local selection
-  /// \param isUpdateViewer the state wether the viewer should be updated immediatelly
-  void closeAllContexts(const bool isUpdateViewer);
-
   /// Returns currently installed AIS_InteractiveContext
   Handle(AIS_InteractiveContext) AISContext() const;
 
+  /// Returns the viewer context top filter. If there is no a filter, it is created and set into
+  /// The context should have only this filter inside. Other filters should be add to the filter
+  Handle(SelectMgr_AndFilter) GetFilter();
+
   /// Display the feature and a shape. This shape would be associated to the given feature
   /// \param theFeature a feature instance
   /// \param theAIS AIS presentation
@@ -185,7 +185,9 @@ class XGUI_EXPORT XGUI_Displayer
  protected:
   XGUI_Workshop* myWorkshop;
 
-  typedef std::map<ObjectPtr, AISObjectPtr> ResultToAISMap;
+  Handle(SelectMgr_AndFilter) myAndFilter;
+
+  typedef QMap<ObjectPtr, AISObjectPtr> ResultToAISMap;
   ResultToAISMap myResult2AISObjectMap;
 
   // A flag of initialization of external objects selection
index 1ed348e1c3d0d3c2347661c529b9582b96de8122..c6e5e523e84c87b25bf49450ae2382c3018b3afc 100644 (file)
@@ -1,3 +1,5 @@
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D -->
+
 #include "XGUI_DocumentDataModel.h"
 #include "XGUI_PartDataModel.h"
 #include "XGUI_Workshop.h"
@@ -214,7 +216,7 @@ QVariant XGUI_DocumentDataModel::data(const QModelIndex& theIndex, int theRole)
               else
               return QVariant();
               case Qt::DecorationRole:
-              return QIcon(XGUI_Workshop::featureIcon(aFeature->getKind()));
+              return XGUI_Workshop::featureIcon(aFeature);
               case Qt::ToolTipRole:
               return tr("Feature object");
               case Qt::ForegroundRole:
index ac1466134bc21163ba2e3500e66c2894bae75a5f..0b3f35fd1797b3b09b47ac25a1f612fd3ffdcbf2 100644 (file)
@@ -1,3 +1,5 @@
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D -->
+
 #ifndef XGUI_DocumentDataModel_H
 #define XGUI_DocumentDataModel_H
 
index c6d2e90d6cce61add21db7e2263fe80c9fa1d2ed..ee076f1c4796c30840d58e5b5de55f207efdb139 100644 (file)
@@ -1,3 +1,5 @@
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D -->
+
 /*
  * XGUI_ErrorDialog.cpp
  *
index 20af808bb66a937466c26318dd7ae53daab89e0e..9a5ca5803d07987aef505fba7933dc10178eb8eb 100644 (file)
@@ -1,3 +1,5 @@
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D -->
+
 /*
  * XGUI_ErrorDialog.h
  *
diff --git a/src/XGUI/XGUI_IPrefMgr.h b/src/XGUI/XGUI_IPrefMgr.h
deleted file mode 100644 (file)
index af0752d..0000000
+++ /dev/null
@@ -1,37 +0,0 @@
-// File:        XGUI_IPrefMgr.h
-// Created:     10 Sept 2014
-// Author:      Vitaly SMETANNIKOV
-
-
-#ifndef XGUI_IPrefMgr_H
-#define XGUI_IPrefMgr_H
-
-#include <QString>
-#include <SUIT_PreferenceMgr.h>
-
-/** 
-* An interface class which provides incapsulation of SUIT_PreferenceMgr class instance 
-* It is used in order to make common interface to Preference manager in Salome 
-* and this application
-*/
-class XGUI_IPrefMgr
-{
-public:
-  /** 
-  * Add preference item into preference dialog box
-  * \param theLbl - label of the item
-  * \param pId - id of container item
-  * \param theType - type of the item
-  * \param theSection - resouce section name
-  * \param theName - name of the resource
-  * Returns Id of the ctreated item
-  */
-  virtual int addPreference(const QString& theLbl, int pId, 
-                            SUIT_PreferenceMgr::PrefItemType theType,
-                            const QString& theSection, const QString& theName ) = 0;
-
-  /// Returns incapsulated preference manager
-  virtual SUIT_PreferenceMgr* prefMgr() const = 0;
-};
-
-#endif
\ No newline at end of file
diff --git a/src/XGUI/XGUI_MainMenu.cpp b/src/XGUI/XGUI_MainMenu.cpp
deleted file mode 100644 (file)
index d874cc9..0000000
+++ /dev/null
@@ -1,148 +0,0 @@
-#include <XGUI_MainMenu.h>
-#include <XGUI_Workbench.h>
-#include <XGUI_MenuGroupPanel.h>
-#include <XGUI_MainWindow.h>
-#include <XGUI_Command.h>
-#include <XGUI_Preferences.h>
-
-#include <SUIT_ResourceMgr.h>
-
-#include <QLayout>
-#include <QTabWidget>
-#include <QLabel>
-#include <QDockWidget>
-#include <QEvent>
-#include <QPushButton>
-#include <QTabBar>
-
-XGUI_MainMenu::XGUI_MainMenu(XGUI_MainWindow *parent)
-    : QWidget(parent),
-      myDesktop(parent)
-{
-  myGeneralPage = new XGUI_MenuGroupPanel(this);
-  myGeneralPage->setObjectName("Default");
-  myGeneralPage->parentWidget()->setMaximumWidth(200);
-  myGeneralPage->installEventFilter(this);
-  myGeneralPage->setFrameStyle(QFrame::StyledPanel);
-
-  myMenuTabs = new QTabWidget(this);
-  myMenuTabs->setStyleSheet("QTabBar::tab {height: 24px;} QTabWidget:pane {border: 0px;}");
-  QHBoxLayout* aMainLayout = new QHBoxLayout(this);
-  aMainLayout->addWidget(myGeneralPage);
-  aMainLayout->addWidget(myMenuTabs);
-  aMainLayout->setContentsMargins(0, 2, 2, 0);
-  aMainLayout->setSpacing(2);
-  setLayout(aMainLayout);
-  updateFromResources();
-}
-
-XGUI_MainMenu::~XGUI_MainMenu(void)
-{
-}
-
-XGUI_Workbench* XGUI_MainMenu::addWorkbench(const QString& theId, const QString& theTitle)
-{
-  QString aTitle = theTitle;
-  if (aTitle.isEmpty()) {
-    aTitle = tr(theId.toLatin1().constData());
-  }
-  XGUI_Workbench* aPage = new XGUI_Workbench(myMenuTabs);
-  aPage->setObjectName(theId);
-  myMenuTabs->addTab(aPage, aTitle);
-  myWorkbenches.append(aPage);
-  return aPage;
-}
-
-/*
- * Searches for already created workbench with given name.
- */
-XGUI_Workbench* XGUI_MainMenu::findWorkbench(const QString& theObjName) const
-{
-  return myDesktop->findChild<XGUI_Workbench*>(theObjName);
-}
-
-bool XGUI_MainMenu::eventFilter(QObject *theWatched, QEvent *theEvent)
-{
-  if (theWatched == myGeneralPage) {
-    if (theEvent->type() == QEvent::Show) {
-      myGeneralPage->parentWidget()->setMaximumWidth(16777215);
-      myGeneralPage->removeEventFilter(this);
-    }
-  }
-  return QObject::eventFilter(theWatched, theEvent);
-}
-
-void XGUI_MainMenu::insertConsole(QWidget* theConsole)
-{
-  int aConsoleTabId = myMenuTabs->addTab(theConsole, "Console");
-
-  QTabBar* aTabBar = myMenuTabs->findChild<QTabBar*>();
-  QPushButton* aCloseTabButton = new QPushButton();
-  aCloseTabButton->setFixedSize(16, 16);
-  aCloseTabButton->setIcon(QIcon(":pictures/wnd_close.png"));
-  aCloseTabButton->setFlat(true);
-  aTabBar->setTabButton(aConsoleTabId, QTabBar::RightSide, aCloseTabButton);
-
-  connect(aCloseTabButton, SIGNAL(clicked()), myDesktop, SLOT(dockPythonConsole()));
-}
-
-void XGUI_MainMenu::removeConsole()
-{
-  const int kLastTab = myMenuTabs->count() - 1;
-  myMenuTabs->removeTab(kLastTab);
-}
-
-XGUI_Command* XGUI_MainMenu::feature(const QString& theId) const
-{
-  XGUI_Command* result;
-  result = myGeneralPage->feature(theId);
-  if (!result) {
-    XGUI_Workbench* aWbn;
-    foreach (aWbn, myWorkbenches)
-    {
-      result = aWbn->feature(theId);
-      if (result)
-        break;
-    }
-  }
-  return result;
-}
-
-QList<XGUI_Command*> XGUI_MainMenu::features() const
-{
-  QList<XGUI_Command*> aList = myGeneralPage->features();
-  XGUI_Workbench* aWbn;
-  foreach (aWbn, myWorkbenches)
-  {
-    aList.append(aWbn->features());
-  }
-  return aList;
-}
-
-int XGUI_MainMenu::menuItemSize() const
-{
-  const int kDefaultItemSize = 25;
-  return kDefaultItemSize;
-}
-
-int XGUI_MainMenu::menuHeight() const
-{
-  // Default group has no tabs above --> one extra row
-  int rows = menuItemRowsCount() + 1;
-  const int kMarginsSpacings = 5;
-  return rows * menuItemSize() + kMarginsSpacings;
-}
-
-int XGUI_MainMenu::menuItemRowsCount() const
-{
-  static const int kDefaultRowsCount = 3;
-  int aRowsCount = XGUI_Preferences::resourceMgr()->integerValue(XGUI_Preferences::MENU_SECTION,
-                                                                 "rows_number", kDefaultRowsCount);
-  return aRowsCount;
-}
-
-void XGUI_MainMenu::updateFromResources()
-{
-  setFixedHeight(menuHeight());
-  repaint();
-}
diff --git a/src/XGUI/XGUI_MainMenu.h b/src/XGUI/XGUI_MainMenu.h
deleted file mode 100644 (file)
index 50c19c8..0000000
+++ /dev/null
@@ -1,81 +0,0 @@
-#ifndef XGUI_MainMenu_H
-#define XGUI_MainMenu_H
-
-#include "XGUI.h"
-#include <QObject>
-#include <QList>
-#include <QMap>
-#include <QWidget>
-
-class XGUI_Command;
-class XGUI_MainWindow;
-class XGUI_Workbench;
-class XGUI_MenuGroupPanel;
-
-class QTabWidget;
-class QLabel;
-class QAction;
-class QDockWidget;
-class QEvent;
-
-/**\class XGUI_MainMenu
- * \ingroup GUI
- * \brief Class for creation of main menu (set of workbenches)
- */
-class XGUI_EXPORT XGUI_MainMenu : public QWidget
-{
-Q_OBJECT
-
- public:
-  XGUI_MainMenu(XGUI_MainWindow *parent);
-  virtual ~XGUI_MainMenu();
-
-  //! Creates and adds a new workbench (menu group) with the given name and returns it.
-  XGUI_Workbench* addWorkbench(const QString& theId, const QString& theText = "");
-
-  //! Returns workbench (menu group) by the given name.
-  XGUI_Workbench* findWorkbench(const QString& theId) const;
-
-  //! Returns General page (predefined workbench)
-  XGUI_MenuGroupPanel* generalPage() const
-  {
-    return myGeneralPage;
-  }
-
-  //! Rerturns last created workbench in dock widget container
-  //QDockWidget* getLastDockWindow() const;
-
-  //! Returns already created command by its ID
-  XGUI_Command* feature(const QString& theId) const;
-
-  //! Returns list of created commands
-  QList<XGUI_Command*> features() const;
-
-  virtual bool eventFilter(QObject *theWatched, QEvent *theEvent);
-
-  //! Displays given console as a tab in the workbench
-  void insertConsole(QWidget*);
-  //! Removes already created tab with python console
-  void removeConsole();
-
-  //! Defines size of menu item.
-  //! In the future this value should be extracted from the preferences.
-  int menuItemSize() const;
-  //! Defines number of menu item rows.
-  //! In the future this value should be extracted from the preferences.
-  int menuItemRowsCount() const;
-  //! Defines height of the main menu. (Number of rows * row height)
-  int menuHeight() const;
-
-  void updateFromResources();
-
- private:
-  XGUI_MainWindow* myDesktop;
-  QTabWidget* myMenuTabs;
-  XGUI_MenuGroupPanel* myGeneralPage;
-  QList<XGUI_Workbench*> myWorkbenches;
-
-  QMap<XGUI_Command*, bool> myCommandState;
-};
-
-#endif
diff --git a/src/XGUI/XGUI_MainWindow.cpp b/src/XGUI/XGUI_MainWindow.cpp
deleted file mode 100644 (file)
index 7fc26f0..0000000
+++ /dev/null
@@ -1,296 +0,0 @@
-#include "XGUI_MainWindow.h"
-#include "XGUI_Constants.h"
-#include "XGUI_MainMenu.h"
-#include "XGUI_ViewWindow.h"
-#include "XGUI_Viewer.h"
-#include "XGUI_ObjectsBrowser.h"
-
-#include <PyConsole_Console.h>
-#include <PyConsole_EnhInterp.h>
-
-#include <QMdiArea>
-#include <QMdiSubWindow>
-#include <QAction>
-#include <QDockWidget>
-#include <QApplication>
-#include <QTimer>
-#include <QCloseEvent>
-
-
-XGUI_MainWindow::XGUI_MainWindow(QWidget* parent)
-    : QMainWindow(parent),
-      myPythonConsole(0), myIsModified(false)
-{
-  myTitle = tr("New Geom");
-  updateTitle();
-  createMainMenu();
-  QMdiArea* aMdiArea = new QMdiArea(this);
-  aMdiArea->setContextMenuPolicy(Qt::ActionsContextMenu);
-  setCentralWidget(aMdiArea);
-  connect(aMdiArea, SIGNAL(subWindowActivated(QMdiSubWindow*)), this,
-          SLOT(onViewActivated(QMdiSubWindow*)));
-
-  // Create actions of MDI area
-  QAction* aAction = new QAction(QIcon(":pictures/new_view.png"), tr("Create Window"), aMdiArea);
-  aMdiArea->addAction(aAction);
-  connect(aAction, SIGNAL(triggered(bool)), this, SLOT(createSubWindow()));
-
-  aAction = new QAction(QIcon(":pictures/tile_views.png"), tr("Tile"), aMdiArea);
-  aMdiArea->addAction(aAction);
-  connect(aAction, SIGNAL(triggered(bool)), aMdiArea, SLOT(tileSubWindows()));
-
-  aAction = new QAction(QIcon(":pictures/cascade_views.png"), tr("Cascade"), aMdiArea);
-  aMdiArea->addAction(aAction);
-  connect(aAction, SIGNAL(triggered(bool)), this, SLOT(cascadeWindows()));
-
-  aAction = new QAction(aMdiArea);
-  aAction->setSeparator(true);
-  aMdiArea->addAction(aAction);
-
-  myViewer = new XGUI_Viewer(this);
-  connect(myViewer, SIGNAL(viewCreated(XGUI_ViewWindow*)), this,
-          SLOT(onViewCreated(XGUI_ViewWindow*)));
-  connect(myViewer, SIGNAL(deleteView(XGUI_ViewWindow*)), this,
-          SLOT(onDeleteView(XGUI_ViewWindow*)));
-}
-
-XGUI_MainWindow::~XGUI_MainWindow(void)
-{
-}
-
-//******************************************************
-QMdiArea* XGUI_MainWindow::mdiArea() const
-{
-  return static_cast<QMdiArea*>(centralWidget());
-}
-
-//******************************************************
-void XGUI_MainWindow::showPythonConsole()
-{
-  // TODO: Check why PyConsole can not be created
-  if (!myPythonConsole) {
-    myPythonConsole = new PyConsole_EnhConsole(this, new PyConsole_EnhInterp());
-    myPythonConsole->setObjectName("PythonConsole");
-    undockPythonConsole();
-  }
-  myPythonConsole->parentWidget()->show();
-}
-
-//******************************************************
-void XGUI_MainWindow::hidePythonConsole()
-{
-  if (myPythonConsole)
-    myPythonConsole->parentWidget()->hide();
-}
-
-//******************************************************
-void XGUI_MainWindow::dockPythonConsole()
-{
-  if (!myPythonConsole)
-    return;
-  myMenuBar->removeConsole();
-  QDockWidget* aDock = new QDockWidget(this);
-  aDock->setFeatures(QDockWidget::AllDockWidgetFeatures | QDockWidget::DockWidgetVerticalTitleBar);
-  aDock->setAllowedAreas(
-      Qt::LeftDockWidgetArea | Qt::RightDockWidgetArea | Qt::BottomDockWidgetArea);
-  aDock->setMinimumHeight(0);
-  aDock->setWindowTitle("Console");
-  aDock->setWidget(myPythonConsole);
-  addDockWidget(Qt::BottomDockWidgetArea, aDock);
-  // Undock python console if widget is closed...
-  CloseEventWatcher* aWatcher = new CloseEventWatcher(aDock);
-  connect(aWatcher, SIGNAL(widgetClosed()), this, SLOT(undockPythonConsole()));
-  aDock->installEventFilter(aWatcher);
-}
-
-void XGUI_MainWindow::undockPythonConsole()
-{
-  if (!myPythonConsole)
-    return;
-  QDockWidget* aDock = qobject_cast<QDockWidget*>(myPythonConsole->parentWidget());
-  //When the application starts console will be displayed as
-  //a wokbench tab, so there is no dock yet
-  if (aDock) {
-    aDock->hide();
-    aDock->setWidget(NULL);
-    aDock->deleteLater();
-  }
-  myMenuBar->insertConsole(myPythonConsole);
-}
-
-//******************************************************
-void XGUI_MainWindow::createSubWindow()
-{
-  viewer()->createView();
-}
-
-//******************************************************
-void XGUI_MainWindow::cascadeWindows()
-{
-  QMdiArea* aMdiArea = static_cast<QMdiArea*>(centralWidget());
-  QList<QMdiSubWindow*> aWindows = aMdiArea->subWindowList();
-
-  QSize aSize = aMdiArea->size();
-  QRect aRect = aMdiArea->geometry();
-  const int aOffset = 30;
-  int i = 0, j = 0;
-  int x, y;
-  int w = aSize.width() / 2;
-  int h = aSize.height() / 2;
-  QMdiSubWindow* aLastWnd;
-  foreach(QMdiSubWindow* aWnd, aWindows)
-  {
-    aWnd->showNormal();
-    aWnd->raise();
-    x = aOffset * i;
-    if ((x + w) > aSize.width()) {
-      x = 0;
-      i = 0;
-    }
-    y = aOffset * j;
-    if ((y + h) > aSize.height()) {
-      y = 0;
-      j = 0;
-    }
-    aWnd->setGeometry(QStyle::visualRect(aWnd->layoutDirection(), aRect, QRect(x, y, w, h)));
-    i++;
-    j++;
-    viewer()->onWindowActivated(aWnd);
-    aLastWnd = aWnd;
-    QApplication::processEvents();
-  }
-  aLastWnd->setFocus();
-}
-
-void XGUI_MainWindow::onViewCreated(XGUI_ViewWindow* theWindow)
-{
-  QWidget* aSubWindow = theWindow->parentWidget();
-  QWidget* aMDIWidget = centralWidget();
-
-  QAction* aAction = new QAction(aSubWindow->windowTitle(), aMDIWidget);
-  aAction->setCheckable(true);
-  connect(aAction, SIGNAL(triggered(bool)), this, SLOT(activateView()));
-  aMDIWidget->addAction(aAction);
-
-  QList<QAction*> aActions = aMDIWidget->actions();
-  foreach(QAction* aAct, aActions)
-  {
-    if (aAct->isCheckable())
-      aAct->setChecked(false);
-  }
-  aAction->setChecked(true);
-}
-
-void XGUI_MainWindow::onDeleteView(XGUI_ViewWindow* theWindow)
-{
-  QWidget* aSubWindow = theWindow->parentWidget();
-  QString aTitle = aSubWindow->windowTitle();
-  QWidget* aMDIWidget = centralWidget();
-  QList<QAction*> aActions = aMDIWidget->actions();
-
-  QAction* aDelAct = 0;
-  foreach(QAction* aAct, aActions)
-  {
-    if (aAct->text() == aTitle) {
-      aDelAct = aAct;
-      break;
-    }
-  }
-  aMDIWidget->removeAction(aDelAct);
-}
-
-void XGUI_MainWindow::activateView()
-{
-  QAction* aAction = static_cast<QAction*>(sender());
-  QString aWndTitle = aAction->text();
-  QMdiArea* aMdiArea = static_cast<QMdiArea*>(centralWidget());
-
-  QList<QMdiSubWindow*> aWndList = aMdiArea->subWindowList();
-  QMdiSubWindow* aTargetView = 0;
-  foreach(QMdiSubWindow* aWnd, aWndList)
-  {
-    if (aWnd->windowTitle() == aWndTitle) {
-      aWnd->raise();
-      aWnd->activateWindow();
-      aTargetView = aWnd;
-      break;
-    }
-  }
-  QApplication::processEvents();
-  if (aTargetView)
-    QTimer::singleShot(20, aTargetView, SLOT(setFocus()));
-}
-
-void XGUI_MainWindow::onViewActivated(QMdiSubWindow* theSubWnd)
-{
-  if (!theSubWnd)
-    return;
-  QMdiArea* aMdiArea = static_cast<QMdiArea*>(centralWidget());
-  QString aWndTitle = theSubWnd->windowTitle();
-  QList<QAction*> aActionList = aMdiArea->actions();
-  foreach(QAction* aAct, aActionList)
-  {
-    if (aAct->isCheckable())
-      aAct->setChecked(aAct->text() == aWndTitle);
-  }
-}
-
-void XGUI_MainWindow::closeEvent(QCloseEvent * event)
-{
-  emit exitKeySequence();
-  event->ignore();
-}
-
-void XGUI_MainWindow::createMainMenu()
-{
-  myMenuBar = new XGUI_MainMenu(this);
-  QDockWidget* aMenuDock = new QDockWidget(this);
-  aMenuDock->setWidget(myMenuBar);
-  aMenuDock->setAllowedAreas(Qt::TopDockWidgetArea);
-  aMenuDock->setFeatures(QDockWidget::DockWidgetVerticalTitleBar);
-  aMenuDock->setWindowTitle(tr("General"));
-  addDockWidget(Qt::TopDockWidgetArea, aMenuDock);
-}
-
-
-void XGUI_MainWindow::updateTitle()
-{
-  QString aTitle = myTitle;
-  if (!myCurrentDir.isNull())
-    aTitle += " - " + myCurrentDir;
-  if (myIsModified)
-    aTitle += "*";
-  setWindowTitle(aTitle);
-}
-
-void XGUI_MainWindow::setCurrentDir(const QString& theDir, bool toUpdate)
-{
-  myCurrentDir = theDir;
-  if (toUpdate)
-    updateTitle();
-}
-
-void XGUI_MainWindow::setModifiedState(bool isModified, bool toUpdate)
-{
-  myIsModified = isModified;
-  if (toUpdate)
-    updateTitle();
-}
-
-CloseEventWatcher::CloseEventWatcher(QObject* theParent)
-    : QObject(theParent)
-{
-}
-
-bool CloseEventWatcher::eventFilter(QObject *obj, QEvent *event)
-{
-  if (event->type() == QEvent::Close) {
-    emit widgetClosed();
-    event->ignore();
-    return true;
-  } else {
-    // standard event processing
-    return QObject::eventFilter(obj, event);
-  }
-}
-
diff --git a/src/XGUI/XGUI_MainWindow.h b/src/XGUI/XGUI_MainWindow.h
deleted file mode 100644 (file)
index 3294f58..0000000
+++ /dev/null
@@ -1,105 +0,0 @@
-#ifndef XGUI_MAINWINDOW_H
-#define XGUI_MAINWINDOW_H
-
-#include "XGUI.h"
-#include <QMainWindow>
-
-class XGUI_MainMenu;
-class XGUI_Viewer;
-class XGUI_ActionsMgr;
-class XGUI_ViewWindow;
-class QMdiArea;
-class QMdiSubWindow;
-class PyConsole_EnhConsole;
-class QCloseEvent;
-
-/**\class XGUI_MainWindow
- * \ingroup GUI
- * \brief Main window of the application (Desktop).
- * It contains: Object Browser, 3d Viewer, Python console, property panel, main menu
- */
-class XGUI_EXPORT XGUI_MainWindow : public QMainWindow
-{
-Q_OBJECT
-
- public:
-  XGUI_MainWindow(QWidget* parent = 0);
-  virtual ~XGUI_MainWindow();
-
-  //! Returns main menu object
-  XGUI_MainMenu* menuObject() const
-  {
-    return myMenuBar;
-  }
-
-  //! Returns MDI area
-  QMdiArea* mdiArea() const;
-
-  //! Returns 3d viewer
-  XGUI_Viewer* viewer() const
-  {
-    return myViewer;
-  }
-
- public slots:
-  void showPythonConsole();
-  void hidePythonConsole();
-  //! Python console can be a dock widget 
-  void dockPythonConsole();
-  //! or can be a tab in the main menu.
-  void undockPythonConsole();
-
-  void createSubWindow();
-
-  /// Add name of current directory into title of desktop window
-  void setCurrentDir(const QString& theDir, bool toUpdate = true);
-
-  /// Add asterisk to a title of the window
-  void setModifiedState(bool isModified, bool toUpdate = true);
-
-  /// Returns current state of modification
-  bool isModifiedState() const { return myIsModified; }
-
-  void updateTitle();
-
- private slots:
-  void cascadeWindows();
-  void onViewCreated(XGUI_ViewWindow* theWindow);
-  void onDeleteView(XGUI_ViewWindow* theWindow);
-  void activateView();
-  void onViewActivated(QMdiSubWindow* theSubWnd);
-
-signals:
-  void exitKeySequence();
-
- protected:
-  void closeEvent(QCloseEvent* event);
-  void createMainMenu();
-
- private:
-  XGUI_MainMenu* myMenuBar;
-  XGUI_Viewer* myViewer;
-
-  QString myTitle;
-  QString myCurrentDir;
-  bool myIsModified;
-
-  PyConsole_EnhConsole* myPythonConsole;
-};
-
-class XGUI_EXPORT CloseEventWatcher : public QObject
-{
-Q_OBJECT
-
- public:
-  CloseEventWatcher(QObject* theParent);
-
-signals:
-  void widgetClosed();
-
- protected:
-  bool eventFilter(QObject *obj, QEvent *);
-
-};
-
-#endif
diff --git a/src/XGUI/XGUI_MenuGroupPanel.cpp b/src/XGUI/XGUI_MenuGroupPanel.cpp
deleted file mode 100644 (file)
index a1883f2..0000000
+++ /dev/null
@@ -1,105 +0,0 @@
-#include "XGUI_MenuGroupPanel.h"
-#include "XGUI_Command.h"
-
-#include <QLayout>
-#include <QPushButton>
-#include <QAction>
-#include <QResizeEvent>
-
-#include <math.h>
-#include <iostream>
-
-XGUI_MenuGroupPanel::XGUI_MenuGroupPanel(QWidget *parent)
-    : QFrame(parent),
-      myNewRow(0),
-      myNewCol(0),
-      myMaxRow(1)
-{
-  myLayout = new QGridLayout(this);
-  myLayout->setSpacing(0);
-  myLayout->setMargin(0);
-  myLayout->setContentsMargins(0, 0, 0, 0);
-  setFrameShape(QFrame::NoFrame);
-}
-
-void XGUI_MenuGroupPanel::addCommand(XGUI_Command* theAction)
-{
-  myActions.append(theAction);
-  QWidget* aWdg = theAction->requestWidget(this);
-  myActionWidget.append(aWdg);
-  addWidget(aWdg);
-}
-
-void XGUI_MenuGroupPanel::placeWidget(QWidget* theWgt)
-{
-  if (myMaxRow == myNewRow) {
-    myNewRow = 0;
-    myNewCol++;
-  }
-  myLayout->addWidget(theWgt, myNewRow, myNewCol);
-  myLayout->setRowStretch(myNewRow, 0);
-  myNewRow++;
-}
-
-void XGUI_MenuGroupPanel::addWidget(QWidget* theWgt)
-{
-  placeWidget(theWgt);
-}
-
-void XGUI_MenuGroupPanel::resizeEvent(QResizeEvent* theEvent)
-{
-  QWidget::resizeEvent(theEvent);
-  if (myActions.size() == 0)
-    return;
-
-  int aH = theEvent->size().height();
-  int aMaxRow = (int) floor(double(aH / MIN_BUTTON_HEIGHT));
-  if (aMaxRow == myMaxRow)
-    return;
-
-  myMaxRow = aMaxRow;
-  myNewRow = 0;
-  myNewCol = 0;
-  foreach(QWidget* eachWidget, myActionWidget)
-  {
-    placeWidget(eachWidget);
-  }
-  myLayout->setRowStretch(myMaxRow + 1, 1);
-}
-
-XGUI_Command* XGUI_MenuGroupPanel::addFeature(const QString& theId,
-                                              const QString& theTip,
-                                              const QString& theTitle,
-                                              const QIcon& theIcon,
-                                              const QKeySequence& theKeys)
-{
-  return addFeature(theId, theTip, theTitle, theIcon, QString(), theKeys, false);
-}
-
-XGUI_Command* XGUI_MenuGroupPanel::addFeature(const QString& theId,
-                                              const QString& theTitle,
-                                              const QString& theTip,
-                                              const QIcon& theIcon,
-                                              const QString& theDocumentKind,
-                                              const QKeySequence& theKeys,
-                                              bool isCheckable)
-{
-  XGUI_Command* aCommand = new XGUI_Command(theId, theDocumentKind, theIcon,
-                                            theTitle, this, isCheckable);
-  aCommand->setToolTip(theTip);
-  if (!theKeys.isEmpty()) {
-    aCommand->setShortcut(theKeys);
-  }
-  addCommand(aCommand);
-  return aCommand;
-}
-
-XGUI_Command* XGUI_MenuGroupPanel::feature(const QString& theId) const
-{
-  foreach (XGUI_Command* aCmd, myActions)
-  {
-    if (aCmd->data().toString() == theId)
-      return aCmd;
-  }
-  return 0;
-}
diff --git a/src/XGUI/XGUI_MenuGroupPanel.h b/src/XGUI/XGUI_MenuGroupPanel.h
deleted file mode 100644 (file)
index 76de103..0000000
+++ /dev/null
@@ -1,63 +0,0 @@
-#ifndef XGUI_MenuGroupPanel_H
-#define XGUI_MenuGroupPanel_H
-
-#include "XGUI.h"
-#include <QFrame>
-#include <QMap>
-
-class XGUI_Command;
-class QGridLayout;
-
-/**\class XGUI_MenuGroupPanel
- * \ingroup GUI
- * \brief Represents a one group in a page of main menu (workbench)
- */
-class XGUI_EXPORT XGUI_MenuGroupPanel : public QFrame
-{
-Q_OBJECT
-
- public:
-  explicit XGUI_MenuGroupPanel(QWidget *parent = 0);
-
-  //! Adding a new feature (Command) in the group
-  XGUI_Command* addFeature(const QString& theId,
-                           const QString& theTip,
-                           const QString& theTitle,
-                           const QIcon& theIcon,
-                           const QKeySequence& theKeys = QKeySequence());
-
-  XGUI_Command* addFeature(const QString& theId,
-                           const QString& theTip,
-                           const QString& theTitle,
-                           const QIcon& theIcon,
-                           const QString& theDocumentKind = QString(),
-                           const QKeySequence& theKeys = QKeySequence(),
-                           bool isCheckable = false);
-
-  //! Returns already created command by its ID
-  XGUI_Command* feature(const QString& theId) const;
-
-  //! Returns list of created commands
-  QList<XGUI_Command*> features() const
-  {
-    return myActions;
-  }
-
- protected:
-  virtual void resizeEvent(QResizeEvent *theEvent);
-
- private:
-  void addWidget(QWidget* theWgt);
-  void placeWidget(QWidget* theWgt);
-  void addCommand(XGUI_Command* theAction);
-
-  QList<XGUI_Command*> myActions;
-  QWidgetList myActionWidget;
-
-  QGridLayout* myLayout;
-  int myNewRow;
-  int myNewCol;
-  int myMaxRow;
-};
-
-#endif
index 45f2d0ed7e9690fce5c5fc64232b01567c0a8149..d1b2d8d2b4cb8f227565fd6db591807f39d600d2 100644 (file)
@@ -1,3 +1,5 @@
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D -->
+
 // File:        XGUI_ModuleConnector.cpp
 // Created:     3 June 2014
 // Author:      Vitaly Smetannikov
@@ -22,17 +24,12 @@ XGUI_ModuleConnector::XGUI_ModuleConnector(XGUI_Workshop* theWorkshop)
   
   XGUI_OperationMgr* anOperationMgr = myWorkshop->operationMgr();
 
-  connect(anOperationMgr, SIGNAL(operationStarted(ModuleBase_Operation*)), 
-    this, SIGNAL(operationStarted(ModuleBase_Operation*)));
-  connect(anOperationMgr, SIGNAL(operationStopped(ModuleBase_Operation*)), 
-    this, SIGNAL(operationStopped(ModuleBase_Operation*)));
-
-  myDocumentShapeFilter = new ModuleBase_ShapeDocumentFilter(this);
+  //myDocumentShapeFilter = new ModuleBase_ShapeDocumentFilter(this);
 }
 
 XGUI_ModuleConnector::~XGUI_ModuleConnector()
 {
-  myDocumentShapeFilter.Nullify();
+  //myDocumentShapeFilter.Nullify();
 }
 
 ModuleBase_ISelection* XGUI_ModuleConnector::selection() const
@@ -67,16 +64,16 @@ void XGUI_ModuleConnector::activateSubShapesSelection(const QIntList& theTypes)
   foreach(int aType, theTypes) {
     aModes.append(AIS_Shape::SelectionMode((TopAbs_ShapeEnum)aType));
   }
-  aDisp->activateObjectsOutOfContext(aModes);
+  aDisp->activateObjects(aModes);
   //TODO: We have to open Local context because at neutral point filters don't work (bug 25340)
-  aDisp->addSelectionFilter(myDocumentShapeFilter);
+  //aDisp->addSelectionFilter(myDocumentShapeFilter);
 }
 
 void XGUI_ModuleConnector::deactivateSubShapesSelection()
 {
   XGUI_Displayer* aDisp = myWorkshop->displayer();
   // The document limitation selection has to be only during operation
-  aDisp->removeSelectionFilter(myDocumentShapeFilter);
+  //aDisp->removeSelectionFilter(myDocumentShapeFilter);
   aDisp->closeLocalContexts(false);
 }
 
@@ -92,8 +89,13 @@ ObjectPtr XGUI_ModuleConnector::findPresentedObject(const AISObjectPtr& theAIS)
   return aDisp->getObject(theAIS);
 }
 
-void XGUI_ModuleConnector::setSelected(const QList<ObjectPtr>& theFeatures)
+void XGUI_ModuleConnector::setSelected(const QObjectPtrList& theFeatures)
 {
   XGUI_Displayer* aDisp = myWorkshop->displayer();
   aDisp->setSelected(theFeatures);
-}
\ No newline at end of file
+}
+
+bool XGUI_ModuleConnector::canStartOperation(QString theId)
+{
+  return myWorkshop->operationMgr()->canStartOperation(theId);
+}
index 8a869f1d0db026bc03fafe78162c78df67dad92e..ab3b09a17231ae22e6cb01d5e5cd19600f6e52b8 100644 (file)
@@ -1,3 +1,5 @@
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D -->
+
 // File:        XGUI_ModuleConnector.h
 // Created:     3 June 2014
 // Author:      Vitaly Smetannikov
@@ -44,6 +46,9 @@ Q_OBJECT
   //! Returns currently active operation
   virtual ModuleBase_Operation* currentOperation() const;
 
+  //! Returns true if the operation with id theId can be started
+  virtual bool canStartOperation(QString theId);
+
   //! Returns AIS opbject by data object
   virtual AISObjectPtr findPresentation(const ObjectPtr& theObject) const;
 
@@ -52,7 +57,7 @@ Q_OBJECT
 
   //! Select features clearing previous selection. 
   //! If the list is empty then selection will be cleared
-  virtual void setSelected(const QList<ObjectPtr>& theFeatures);
+  virtual void setSelected(const QObjectPtrList& theFeatures);
 
   XGUI_Workshop* workshop() const { return myWorkshop; }
 
index 0f82445343ffe3cb6309731bd2b29cddb6efe98a..69cc9c616c58b32feda738a6194f444cfacd5a26 100644 (file)
@@ -1,3 +1,5 @@
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D -->
+
 #include "XGUI_ObjectsBrowser.h"
 #include "XGUI_DocumentDataModel.h"
 #include "XGUI_Tools.h"
@@ -336,7 +338,7 @@ void XGUI_ObjectsBrowser::rebuildDataTree()
 }
 
 //***************************************************
-void XGUI_ObjectsBrowser::setObjectsSelected(const QList<ObjectPtr>& theObjects)
+void XGUI_ObjectsBrowser::setObjectsSelected(const QObjectPtrList& theObjects)
 {
   QList<QModelIndex> theIndexes;
   QItemSelectionModel* aSelectModel = myTreeView->selectionModel();
index 15e5e3690673febfaddd22c21991b03667d8204c..a52c844545999bd6e91a17fa4e8663517c937d01 100644 (file)
@@ -1,3 +1,5 @@
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D -->
+
 #ifndef XGUI_ObjectsBrowser_H
 #define XGUI_ObjectsBrowser_H
 
@@ -21,7 +23,7 @@ Q_OBJECT
   virtual ~XGUI_DataTree();
 
   //! Returns list of currently selected objects
-  QList<ObjectPtr> selectedObjects() const
+  QObjectPtrList selectedObjects() const
   {
     return mySelectedData;
   }
@@ -52,7 +54,7 @@ public slots:
 
  private:
   //! List of currently selected data
-  QList<ObjectPtr> mySelectedData;
+  QObjectPtrList mySelectedData;
 };
 
 /**\class XGUI_ObjectsBrowser
@@ -73,12 +75,12 @@ Q_OBJECT
   }
 
   //! Returns list of currently selected objects
-  QList<ObjectPtr> selectedObjects() const
+  QObjectPtrList selectedObjects() const
   {
     return myObjectsList;
   }
 
-  void setObjectsSelected(const QList<ObjectPtr>& theObjects);
+  void setObjectsSelected(const QObjectPtrList& theObjects);
 
   //! Returns currently selected indexes
   QModelIndexList selectedIndexes() const
@@ -134,7 +136,7 @@ signals:
   QLineEdit* myActiveDocLbl;
   XGUI_DataTree* myTreeView;
 
-  QList<ObjectPtr> myObjectsList;
+  QObjectPtrList myObjectsList;
 };
 
 #endif
index f93cb6b6a22a0b2f74a10be0d71596484de0ac36..a8f68277b5aa2266d32b6cb4f4d6c4b33730a9d8 100644 (file)
@@ -1,3 +1,5 @@
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D -->
+
 // File:        XGUI_OperationMgr.h
 // Created:     20 Apr 2014
 // Author:      Natalia ERMOLAEVA
@@ -11,7 +13,7 @@
 #include <QKeyEvent>
 
 XGUI_OperationMgr::XGUI_OperationMgr(QObject* theParent)
-    : QObject(theParent)
+    : QObject(theParent), myIsValidationLock(false)
 {
 }
 
@@ -36,6 +38,25 @@ bool XGUI_OperationMgr::hasOperation() const
   return !myOperations.isEmpty() && (myOperations.last() != NULL);
 }
 
+bool XGUI_OperationMgr::hasOperation(const QString& theId) const
+{
+  foreach(ModuleBase_Operation* aOp, myOperations) {
+    if (aOp->id() == theId)
+      return true;
+  }
+  return false;
+}
+
+ModuleBase_Operation* XGUI_OperationMgr::findOperation(const QString& theId) const
+{
+  foreach(ModuleBase_Operation* aOp, myOperations) {
+    if (aOp->id() == theId)
+      return aOp;
+  }
+  return 0;
+}
+
+
 int XGUI_OperationMgr::operationsCount() const
 {
   return myOperations.count();
@@ -75,14 +96,17 @@ bool XGUI_OperationMgr::eventFilter(QObject *theObject, QEvent *theEvent)
 
 bool XGUI_OperationMgr::startOperation(ModuleBase_Operation* theOperation)
 {
-  if (!canStartOperation(theOperation))
-    return false;
-
+  if (hasOperation())
+    currentOperation()->postpone();
   myOperations.append(theOperation);
 
-  connect(theOperation, SIGNAL(stopped()), this, SLOT(onOperationStopped()));
-  connect(theOperation, SIGNAL(started()), this, SLOT(onOperationStarted()));
-  connect(theOperation, SIGNAL(resumed()), this, SIGNAL(operationResumed()));
+  connect(theOperation, SIGNAL(started()), SLOT(onOperationStarted()));
+  connect(theOperation, SIGNAL(aborted()), SLOT(onOperationAborted()));
+  connect(theOperation, SIGNAL(committed()), SLOT(onOperationCommitted()));
+  connect(theOperation, SIGNAL(stopped()), SLOT(onOperationStopped()));
+  connect(theOperation, SIGNAL(resumed()), SLOT(onOperationResumed()));
+  connect(theOperation, SIGNAL(activatedByPreselection()),
+          SIGNAL(operationActivatedByPreselection()));
 
   theOperation->start();
   onValidateOperation();
@@ -115,7 +139,7 @@ void XGUI_OperationMgr::onValidateOperation()
   if (!hasOperation())
     return;
   ModuleBase_Operation* anOperation = currentOperation();
-  if(anOperation) {
+  if(anOperation && (!myIsValidationLock)) {
     bool isValid = anOperation->isValid();
     emit operationValidated(isValid);
   }
@@ -135,12 +159,12 @@ void XGUI_OperationMgr::resumeOperation(ModuleBase_Operation* theOperation)
   theOperation->resume();
 }
 
-bool XGUI_OperationMgr::canStartOperation(ModuleBase_Operation* theOperation)
+bool XGUI_OperationMgr::canStartOperation(QString theId)
 {
   bool aCanStart = true;
   ModuleBase_Operation* aCurrentOp = currentOperation();
   if (aCurrentOp) {
-    if (!aCurrentOp->isGranted(theOperation)) {
+    if (!aCurrentOp->isGranted(theId)) {
       if (canAbortOperation()) {
         aCurrentOp->abort();
       } else {
@@ -189,6 +213,24 @@ void XGUI_OperationMgr::onOperationStarted()
   emit operationStarted(aSenderOperation);
 }
 
+void XGUI_OperationMgr::onOperationAborted()
+{
+  ModuleBase_Operation* aSenderOperation = dynamic_cast<ModuleBase_Operation*>(sender());
+  emit operationAborted(aSenderOperation);
+}
+
+void XGUI_OperationMgr::onOperationCommitted()
+{
+  ModuleBase_Operation* aSenderOperation = dynamic_cast<ModuleBase_Operation*>(sender());
+  emit operationCommitted(aSenderOperation);
+}
+
+void XGUI_OperationMgr::onOperationResumed()
+{
+  ModuleBase_Operation* aSenderOperation = dynamic_cast<ModuleBase_Operation*>(sender());
+  emit operationResumed(aSenderOperation);
+}
+
 void XGUI_OperationMgr::onOperationStopped()
 {
   ModuleBase_Operation* aSenderOperation = dynamic_cast<ModuleBase_Operation*>(sender());
@@ -226,6 +268,7 @@ bool XGUI_OperationMgr::onKeyReleased(QKeyEvent* theEvent)
   switch (theEvent->key()) {
     case Qt::Key_Return:
     case Qt::Key_Enter: {
+      emit keyEnterReleased();
       commitOperation();
     }
       break;
@@ -233,9 +276,9 @@ bool XGUI_OperationMgr::onKeyReleased(QKeyEvent* theEvent)
       isAccepted = false;
       break;
   }
-  if(anOperation) {
-    anOperation->keyReleased(theEvent->key());
-  }
+  //if(anOperation) {
+  //  anOperation->keyReleased(theEvent->key());
+  //}
   return isAccepted;
 }
 
index 25a155617e1558996221e6e5c00facc2a590b954..1cf7dcefcbbd5fcbb6a5cc6588f24f313d39a979 100644 (file)
@@ -1,3 +1,5 @@
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D -->
+
 // File:        XGUI_OperationMgr.h
 // Created:     20 Apr 2014
 // Author:      Natalia ERMOLAEVA
@@ -37,13 +39,23 @@ Q_OBJECT
   /// Returns the current operation or NULL
   /// \return the current operation
   ModuleBase_Operation* currentOperation() const;
+
   /// Check if the given operation is active operation.
   /// Also, returns false is ther is no active operation.
   bool isCurrentOperation(ModuleBase_Operation* theOperation);
+
   /// Returns true is operation manager has at least one non-null operation.
   bool hasOperation() const;
+
+  /// Returns true is operation manager has an operation with given Id.
+  bool hasOperation(const QString& theId) const;
+
+  /// Find and return operation by its Id.
+  ModuleBase_Operation* findOperation(const QString& theId) const;
+
   /// Returns number of operations in the stack
   int operationsCount() const;
+
   /// Returns list of all operations IDs
   QStringList operationList() const;
 
@@ -60,6 +72,23 @@ Q_OBJECT
 
   bool abortAllOperations();
 
+  /// Returns whether the operation can be started. Check if there is already started operation and
+  /// the granted parameter of the launched operation
+  /// \param theId id of the operation which is going to start
+  bool canStartOperation(QString theId);
+
+  bool canStopOperation();
+
+  /// Returns true if the operation can be aborted
+  bool canAbortOperation();
+
+  /// Blocking/unblocking enabling of Ok button in property panel.
+  /// It is used when operation can not be validated even all attributes are valid
+  void setLockValidating(bool toLock) { myIsValidationLock = toLock; }
+
+  /// Returns state of validation locking
+  bool isValidationLocked() const { return myIsValidationLock; }
+
  public slots:
   /// Slot that commits the current operation.
   void onCommitOperation();
@@ -71,14 +100,30 @@ Q_OBJECT
 signals:
   /// Signal about an operation is started. It is emitted after the start() of operation is done.
   void operationStarted(ModuleBase_Operation* theOperation);
+
   /// Signal about an operation is stopped. It is emitted after the stop() of operation is done.
   /// \param theOperation a stopped operation
   void operationStopped(ModuleBase_Operation* theOperation);
+
   /// Signal about an operation is resumed. It is emitted after the resume() of operation is done.
-  void operationResumed();
+  void operationResumed(ModuleBase_Operation* theOperation);
+
+  /// Emitted when current operation is Committed
+  void operationCommitted(ModuleBase_Operation* theOperation);
+
+  /// Emitted when current operation is aborted
+  void operationAborted(ModuleBase_Operation* theOperation);
+
   /// Signal is emitted after the validate methods calls.
   void operationValidated(bool);
 
+  /// Signal is emitted after the current operation is filled with existing preselection.
+  void operationActivatedByPreselection();
+
+  /// Signal is emitted after the key released click.
+  void keyEnterReleased();
+
+
  protected:
 
   /// Commits the current operatin if it is valid
@@ -89,16 +134,6 @@ signals:
   /// \return the state whether the operation is resumed
   void resumeOperation(ModuleBase_Operation* theOperation);
 
-  /// Returns whether the operation can be started. Check if there is already started operation and
-  /// the granted parameter of the launched operation
-  /// \param theOperation an operation to check
-  bool canStartOperation(ModuleBase_Operation* theOperation);
-
-  bool canStopOperation();
-
-  /// Returns true if the operation can be aborted
-  bool canAbortOperation();
-
  public slots:
   /// SLOT, that is called by the key in the property panel is clicked.
   /// \param theName the attribute name
@@ -110,11 +145,17 @@ signals:
   /// If there is a suspended operation, restart it.
   void onOperationStopped();
   void onOperationStarted();
+  void onOperationAborted();
+  void onOperationCommitted();
+  void onOperationResumed();
 
  private:
   typedef QList<ModuleBase_Operation*> Operations;  ///< definition for a list of operations
   Operations myOperations;  ///< a stack of started operations. The active operation is on top,
                             // others are suspended and started by the active is finished
+
+  /// Lock/Unlock access to Ok button in property panel
+  bool myIsValidationLock;
 };
 
 #endif
index c7f1b81a2e26fc70fc5a2a001ef5b915295b6e98..567ad5677e050e0d4923001afdbc3a23f2a75709 100644 (file)
@@ -1,3 +1,5 @@
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D -->
+
 #include "XGUI_PartDataModel.h"
 #include "XGUI_Workshop.h"
 
@@ -295,7 +297,7 @@ QVariant XGUI_PartDataModel::data(const QModelIndex& theIndex, int theRole) cons
             return aObject->data()->name().c_str();
         }
         case HistoryObject: {
-          ObjectPtr aObject = partDocument()->object(ModelAPI_Feature::group(), theIndex.row() - 4);
+          ObjectPtr aObject = partDocument()->object(ModelAPI_Feature::group(), theIndex.row() - getRowsNumber());
           if (aObject)
             return aObject->data()->name().c_str();
         }
@@ -319,16 +321,17 @@ QVariant XGUI_PartDataModel::data(const QModelIndex& theIndex, int theRole) cons
           std::string aGroup = theIndex.internalId() == ConstructObject ?
             ModelAPI_ResultConstruction::group() : ModelAPI_ResultBody::group();
           ObjectPtr anObject = partDocument()->object(aGroup, theIndex.row());
-          if (anObject && anObject->data() && anObject->data()->mustBeUpdated()) {
+          if (anObject && anObject->data() && 
+              anObject->data()->execState() == ModelAPI_StateMustBeUpdated) {
             return QIcon(":pictures/constr_object_modified.png");
           }
           return QIcon(":pictures/constr_object.png");
         }
         case HistoryObject: {
-          ObjectPtr aObject = partDocument()->object(ModelAPI_Feature::group(), theIndex.row() - 4);
+          ObjectPtr aObject = partDocument()->object(ModelAPI_Feature::group(), theIndex.row() - getRowsNumber());
           FeaturePtr aFeature = std::dynamic_pointer_cast<ModelAPI_Feature>(aObject);
           if (aFeature)
-            return QIcon(XGUI_Workshop::featureIcon(aFeature->getKind()));
+            return XGUI_Workshop::featureIcon(aFeature);
         }
       }
       break;
@@ -360,9 +363,9 @@ int XGUI_PartDataModel::rowCount(const QModelIndex& parent) const
     case MyRoot:
       {
         DocumentPtr aDoc = partDocument();
-        if (aDoc)
-          return 4 + aDoc->size(ModelAPI_Feature::group());
-        else 
+        if (aDoc) {
+          return getRowsNumber() + aDoc->size(ModelAPI_Feature::group());
+        else 
           return 0;
       }
     case ParamsFolder:
@@ -398,7 +401,13 @@ QModelIndex XGUI_PartDataModel::index(int theRow, int theColumn, const QModelInd
         case 2:
           return createIndex(theRow, 0, (qint32) BodiesFolder);
         case 3:
-          return createIndex(theRow, 0, (qint32) GroupsFolder);
+          {
+          int aSize = partDocument()->size(ModelAPI_ResultGroup::group());
+          if (aSize > 0)
+            return createIndex(theRow, 0, (qint32) GroupsFolder);
+          else
+            return createIndex(theRow, theColumn, (qint32) HistoryObject);
+          }
         default:
           return createIndex(theRow, theColumn, (qint32) HistoryObject);
       }
@@ -475,7 +484,7 @@ ObjectPtr XGUI_PartDataModel::object(const QModelIndex& theIndex) const
     case GroupObject:
       return partDocument()->object(ModelAPI_ResultGroup::group(), theIndex.row());
     case HistoryObject:
-      return partDocument()->object(ModelAPI_Feature::group(), theIndex.row() - 4);
+      return partDocument()->object(ModelAPI_Feature::group(), theIndex.row() - getRowsNumber());
   }
   return ObjectPtr();
 }
@@ -492,13 +501,13 @@ QModelIndex XGUI_PartDataModel::findParent(const ObjectPtr& theObject) const
 
 QModelIndex XGUI_PartDataModel::findGroup(const std::string& theGroup) const
 {
-  if (theGroup.compare(ModelAPI_ResultParameters::group()) == 0)
+  if (theGroup == ModelAPI_ResultParameters::group())
     return createIndex(0, 0, (qint32) ParamsFolder);
-  if (theGroup.compare(ModelAPI_ResultConstruction::group()) == 0)
+  if (theGroup == ModelAPI_ResultConstruction::group())
     return createIndex(1, 0, (qint32) ConstructFolder);
-  if (theGroup.compare(ModelAPI_ResultBody::group()) == 0)
+  if (theGroup == ModelAPI_ResultBody::group())
     return createIndex(2, 0, (qint32) BodiesFolder);
-  if (theGroup.compare(ModelAPI_ResultGroup::group()) == 0)
+  if (theGroup == ModelAPI_ResultGroup::group())
     return createIndex(3, 0, (qint32) GroupsFolder);
   return QModelIndex();
 }
@@ -538,7 +547,16 @@ QModelIndex XGUI_PartDataModel::objectIndex(const ObjectPtr& theObject) const
     else if (aGroup == ModelAPI_ResultGroup::group())
       return createIndex(aRow, 0, (qint32) GroupObject);
     else
-      return createIndex(aRow + 4, 0, (qint32) HistoryObject);
+      return createIndex(aRow + getRowsNumber(), 0, (qint32) HistoryObject);
   }
   return aIndex;
 }
+
+
+int XGUI_PartDataModel::getRowsNumber() const
+{
+  int aSize = partDocument()->size(ModelAPI_ResultGroup::group());
+  if (aSize == 0) // If there are no groups then do not show group folder
+    return 3;
+  return 4;
+}
\ No newline at end of file
index 8aec45dabe8475ed6968c7d1a65f953ee63c2348..4ef9cd58fe5e77611c73fb0f32d3fd04994183b1 100644 (file)
@@ -1,3 +1,5 @@
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D -->
+
 #ifndef XGUI_PartDataModel_H
 #define XGUI_PartDataModel_H
 
@@ -111,6 +113,8 @@ Q_OBJECT
   //! Returns document of the current part
   DocumentPtr partDocument() const;
 
+  int getRowsNumber() const;
+
   //! Types of QModelIndexes
   enum DataIds
   {
diff --git a/src/XGUI/XGUI_Preferences.cpp b/src/XGUI/XGUI_Preferences.cpp
deleted file mode 100644 (file)
index 635462d..0000000
+++ /dev/null
@@ -1,299 +0,0 @@
-// File:        XGUI_Preferences.cpp
-// Created:     07 Aug 2014
-// Author:      Vitaly SMETANNIKOV
-
-#include "XGUI_Preferences.h"
-#include "XGUI_Constants.h"
-
-#include <Config_PropManager.h>
-
-#include <SUIT_ResourceMgr.h>
-#include <SUIT_PreferenceMgr.h>
-
-#include <QLayout>
-#include <QApplication>
-#include <QDialogButtonBox>
-#include <QPushButton>
-
-const QString XGUI_Preferences::VIEWER_SECTION = "Viewer";
-const QString XGUI_Preferences::MENU_SECTION = "Menu";
-
-SUIT_ResourceMgr* XGUI_Preferences::myResourceMgr = 0;
-
-SUIT_ResourceMgr* XGUI_Preferences::resourceMgr()
-{
-  if (!myResourceMgr) {
-    myResourceMgr = new SUIT_ResourceMgr("NewGeom");
-    myResourceMgr->setCurrentFormat("xml");
-  }
-  return myResourceMgr;
-}
-
-bool XGUI_Preferences::editPreferences(XGUI_Prefs& theModified)
-{
-  XGUI_PreferencesDlg aDlg(resourceMgr(), QApplication::activeWindow());
-  aDlg.exec();
-  if (aDlg.isChanged()) {
-    aDlg.modified(theModified);
-    resourceMgr()->save();
-    return true;
-  }
-  return false;
-}
-
-void XGUI_Preferences::updateConfigByResources()
-{
-  Config_Properties aProps = Config_PropManager::getProperties();
-  Config_Properties::iterator aIt;
-  for (aIt = aProps.begin(); aIt != aProps.end(); ++aIt) {
-    Config_Prop* aProp = (*aIt);
-    QString aVal = myResourceMgr->stringValue(QString(aProp->section().c_str()),
-                                              QString(aProp->name().c_str()));
-    if (!aVal.isEmpty()) {
-      aProp->setValue(aVal.toStdString());
-    }
-  }
-}
-
-void XGUI_Preferences::updateResourcesByConfig()
-{
-  Config_Properties aProps = Config_PropManager::getProperties();
-  Config_Properties::iterator aIt;
-  for (aIt = aProps.begin(); aIt != aProps.end(); ++aIt) {
-    Config_Prop* aProp = (*aIt);
-    myResourceMgr->setValue(QString(aProp->section().c_str()), QString(aProp->name().c_str()),
-                            QString(aProp->value().c_str()));
-  }
-}
-
-void XGUI_Preferences::resetConfig()
-{
-  Config_Properties aProps = Config_PropManager::getProperties();
-  Config_Properties::iterator aIt;
-  for (aIt = aProps.begin(); aIt != aProps.end(); ++aIt) {
-    Config_Prop* aProp = (*aIt);
-    aProp->setValue(aProp->defaultValue());
-  }
-}
-
-void XGUI_Preferences::loadCustomProps()
-{
-  if(!myResourceMgr)
-    return;
-  QStringList aSections = myResourceMgr->sections();
-  foreach (QString aSection, aSections)
-  {
-    QStringList aParams = myResourceMgr->parameters(aSection);
-    foreach (QString aParam, aParams)
-    {
-      Config_Prop* aProp = Config_PropManager::registerProp(aSection.toStdString(),
-                                       aParam.toStdString(), "", Config_Prop::Disabled);
-      aProp->setValue(myResourceMgr->stringValue(aSection, aParam).toStdString());
-    }
-  }
-}
-
-
-void XGUI_Preferences::createEditContent(XGUI_IPrefMgr* thePref, int thePage)
-{
-  thePref->prefMgr()->setItemIcon(thePage, QIcon(":pictures/module.png"));
-  createCustomPage(thePref, thePage);
-}
-
-
-void XGUI_Preferences::createCustomPage(XGUI_IPrefMgr* thePref, int thePageId)
-{
-  SUIT_ResourceMgr* aResMgr = XGUI_Preferences::resourceMgr();
-  bool isResModified = false;
-
-  // Make a Tab from each section
-  std::list<std::string> aSections = Config_PropManager::getSections();
-  std::list<std::string>::const_iterator it;
-  for (it = aSections.cbegin(); it != aSections.cend(); ++it) {
-    Config_Properties aProps = Config_PropManager::getProperties(*it);
-    int aTab = thePref->prefMgr()->addItem(QString((*it).c_str()), thePageId);
-    thePref->prefMgr()->setItemProperty("columns", 2, aTab);
-
-    Config_Properties::const_iterator aIt;
-    for (aIt = aProps.cbegin(); aIt != aProps.cend(); ++aIt) {
-      Config_Prop* aProp = (*aIt);
-      // check that the property is defined
-      QString aSection(aProp->section().c_str());
-      QString aName(aProp->name().c_str());
-      if (!aResMgr->hasValue(aSection, aName)) {
-        aResMgr->setValue(aSection, aName, QString(aProp->value().c_str()));
-        isResModified = true;
-      }
-      // Add item
-      if (aProp->type() != Config_Prop::Disabled)
-        thePref->addPreference(QObject::tr(aProp->title().c_str()), aTab,
-                               (SUIT_PreferenceMgr::PrefItemType) aProp->type(),
-                               QString(aProp->section().c_str()), QString(aProp->name().c_str()));
-    }
-  }
-}
-
-//**********************************************************
-//**********************************************************
-//**********************************************************
-class XGUI_PrefMgr: public XGUI_IPrefMgr
-{
-public:
-  XGUI_PrefMgr(XGUI_PreferencesMgr* theMgr):myMgr(theMgr) {}
-
-  virtual int addPreference(const QString& theLbl, int pId, 
-                            SUIT_PreferenceMgr::PrefItemType theType,
-                            const QString& theSection, const QString& theName )
-  {
-    return myMgr->addItem(theLbl, pId, theType, theSection, theName);
-  }
-
-  virtual SUIT_PreferenceMgr* prefMgr() const { return myMgr; }
-
-private:
-  XGUI_PreferencesMgr* myMgr;
-};
-
-//**********************************************************
-//**********************************************************
-//**********************************************************
-XGUI_PreferencesDlg::XGUI_PreferencesDlg(SUIT_ResourceMgr* theResurces, QWidget* theParent)
-    : QDialog(theParent),
-      myIsChanged(false)
-{
-  setWindowTitle(tr("Edit preferences"));
-
-  QVBoxLayout* main = new QVBoxLayout(this);
-  main->setMargin(5);
-  main->setSpacing(5);
-
-  myPreferences = new XGUI_PreferencesMgr(theResurces, this);
-  main->addWidget(myPreferences);
-
-  setFocusProxy(myPreferences);
-  myPreferences->setFrameStyle(QFrame::Box | QFrame::Sunken);
-
-  QDialogButtonBox* aBtnBox = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel |
-                                                   QDialogButtonBox::Reset,
-                                                   Qt::Horizontal, this);
-  QPushButton* aDefaultButton = aBtnBox->button(QDialogButtonBox::Reset);
-  aDefaultButton->setText(tr("Default"));
-  connect(aDefaultButton, SIGNAL(clicked()), this, SLOT(onDefault()));
-
-  main->addWidget(aBtnBox);
-  connect(aBtnBox, SIGNAL(accepted()), this, SLOT(accept()));
-  connect(aBtnBox, SIGNAL(rejected()), this, SLOT(reject()));
-  createEditors();
-
-  myPreferences->retrieve();
-  setMinimumSize(800, 200);
-}
-
-XGUI_PreferencesDlg::~XGUI_PreferencesDlg()
-{
-}
-
-void XGUI_PreferencesDlg::createEditors()
-{
-  int aPage = myPreferences->addItem(tr("Desktop"));
-  myPreferences->setItemIcon(aPage, QIcon(":pictures/view_prefs.png"));
-
-  createMenuPage(aPage);
-  createViewerPage(aPage);
-
-  aPage = myPreferences->addItem(tr("Module"));
-  myPreferences->setItemIcon(aPage, QIcon(":pictures/module.png"));
-
-  XGUI_PrefMgr aMgr(myPreferences);
-  XGUI_Preferences::createEditContent(&aMgr, aPage);
-}
-
-void XGUI_PreferencesDlg::createViewerPage(int thePageId)
-{
-  int viewTab = myPreferences->addItem(tr("Viewer"), thePageId);
-
-  QStringList gradList;
-  gradList << tr("Horizontal gradient") << tr("Vertical gradient") << tr("First diagonal gradient")
-           << tr("Second diagonal gradient") << tr("First corner gradient")
-           << tr("Second corner gradient") << tr("Third corner gradient")
-           << tr("Fourth corner gradient");
-
-  QList<QVariant> idList;
-  for (int i = 0; i < gradList.size(); i++)
-    idList << i;
-
-  int bgGroup = myPreferences->addItem(tr("Background"), viewTab);
-
-  QString aImgFiles("Image files (*.bmp *.gif *.pix *.xwd *.rgb *.rs)");
-
-  int bgId = myPreferences->addItem(tr("Viewer 3d"), bgGroup, SUIT_PreferenceMgr::Background,
-                                    XGUI_Preferences::VIEWER_SECTION, "background");
-  myPreferences->setItemProperty("gradient_names", gradList, bgId);
-  myPreferences->setItemProperty("gradient_ids", idList, bgId);
-  myPreferences->setItemProperty("texture_enabled", true, bgId);
-  myPreferences->setItemProperty("texture_center_enabled", true, bgId);
-  myPreferences->setItemProperty("texture_tile_enabled", true, bgId);
-  myPreferences->setItemProperty("texture_stretch_enabled", true, bgId);
-  myPreferences->setItemProperty("custom_enabled", false, bgId);
-  myPreferences->setItemProperty("image_formats", aImgFiles, bgId);
-}
-
-void XGUI_PreferencesDlg::createMenuPage(int thePageId)
-{
-  int aMenuTab = myPreferences->addItem(tr("Main menu"), thePageId);
-
-  int aSizeGroup = myPreferences->addItem(tr("Size"), aMenuTab);
-  myPreferences->setItemProperty("columns", 1, aSizeGroup);
-
-  int aRowsNb = myPreferences->addItem(tr("Number of rows"), aSizeGroup,
-                                       SUIT_PreferenceMgr::IntSpin, XGUI_Preferences::MENU_SECTION,
-                                       "rows_number");
-  myPreferences->setItemProperty("min", 1, aRowsNb);
-  myPreferences->setItemProperty("max", 6, aRowsNb);
-}
-
-void XGUI_PreferencesDlg::accept()
-{
-  myPreferences->store();
-  myIsChanged = true;
-
-  // Save custom properties
-  XGUI_Preferences::updateConfigByResources();
-  QDialog::accept();
-}
-
-void XGUI_PreferencesDlg::modified(XGUI_Prefs& theModified) const
-{
-  theModified = myPreferences->modified();
-}
-
-void XGUI_PreferencesDlg::onDefault()
-{
-  // reset main resources
-#ifdef SALOME_750 // until SALOME 7.5.0 is released
-  QtxResourceMgr::WorkingMode aPrev =
-      myPreferences->resourceMgr()->setWorkingMode(QtxResourceMgr::IgnoreUserValues);
-  myPreferences->retrieve();
-  myPreferences->resourceMgr()->setWorkingMode(aPrev);
-#endif
-  // reset plugin's resources
-  XGUI_Preferences::resetConfig();
-  XGUI_Preferences::updateResourcesByConfig();
-
-  myPreferences->retrieve();
-}
-
-//**********************************************************
-//**********************************************************
-//**********************************************************
-void XGUI_PreferencesMgr::changedResources(const ResourceMap& theMap)
-{
-  myModified.clear();
-  ResourceMap::ConstIterator it;
-  QString sec, param;
-  for (it = theMap.begin(); it != theMap.end(); ++it) {
-    XGUI_Pref aPref;
-    it.key()->resource(aPref.first, aPref.second);
-    myModified.append(aPref);
-  }
-}
diff --git a/src/XGUI/XGUI_Preferences.h b/src/XGUI/XGUI_Preferences.h
deleted file mode 100644 (file)
index 3241d41..0000000
+++ /dev/null
@@ -1,124 +0,0 @@
-// File:        XGUI_Preferences.h
-// Created:     07 Aug 2014
-// Author:      Vitaly SMETANNIKOV
-
-#ifndef XGUI_Preferences_H
-#define XGUI_Preferences_H
-
-#include "XGUI.h"
-#include "XGUI_IPrefMgr.h"
-
-#include <SUIT_PreferenceMgr.h>
-#include <QDialog>
-
-class SUIT_ResourceMgr;
-class QWidget;
-
-// Pair of values: section name, value name
-typedef QPair<QString, QString> XGUI_Pref;
-typedef QList<XGUI_Pref> XGUI_Prefs;
-
-//***********************************************************************
-/// Class for manipulation  with preferences in the application
-class XGUI_EXPORT XGUI_Preferences
-{
- public:
-  static const QString VIEWER_SECTION;
-  static const QString MENU_SECTION;
-
-  static bool editPreferences(XGUI_Prefs& theModified);
-
-  /// Returns currently installed resource manager
-  static SUIT_ResourceMgr* resourceMgr();
-
-  /// Sets a resource manager
-  /// It is used in case of necessity to define external resource manager (not NewGeom)
-  static void setResourceMgr(SUIT_ResourceMgr* theMgr) { myResourceMgr = theMgr; }
-
-  /// Updates Config_PropManager properties by module from SUIT_ResourceMgr
-  static void updateConfigByResources();
-
-  /// Updates SUIT_ResourceMgr values by Config_PropManager properties
-  /// \param theUpdateOnlyInvalid flag to update only invalid values, if it is false, all are updated
-  static void updateResourcesByConfig();
-
-  /// Set default values to the Config_PropManager properties
-  static void resetConfig();
-
-  /// Loads properties defined by module to Config_PropManager
-  static void loadCustomProps();
-
-  /// 
-  static void createEditContent(XGUI_IPrefMgr* thePref, int thePage);
-
-private:
-  /// Creates content of preferences editing widget
-  static void createCustomPage(XGUI_IPrefMgr* thePref, int thePageId);
-
-  static SUIT_ResourceMgr* myResourceMgr;
-};
-
-//***********************************************************************
-/// Manager of preferences
-class XGUI_EXPORT XGUI_PreferencesMgr : public SUIT_PreferenceMgr
-{
-Q_OBJECT
- public:
-  XGUI_PreferencesMgr(QtxResourceMgr* theResource, QWidget* theParent)
-      : SUIT_PreferenceMgr(theResource, theParent)
-  {
-  }
-
-  virtual ~XGUI_PreferencesMgr()
-  {
-  }
-
-  XGUI_Prefs modified() const
-  {
-    return myModified;
-  }
-
- protected:
-  virtual void changedResources(const ResourceMap& theMap);
-
- private:
-  XGUI_Prefs myModified;
-};
-
-//***********************************************************************
-/// Dialog box for preferences editing
-class XGUI_EXPORT XGUI_PreferencesDlg : public QDialog
-{
-Q_OBJECT
- public:
-  XGUI_PreferencesDlg(SUIT_ResourceMgr* theResurces, QWidget* theParent = 0);
-  virtual ~XGUI_PreferencesDlg();
-
-  bool isChanged() const
-  {
-    return myIsChanged;
-  }
-
-  void modified(XGUI_Prefs& theModified) const;
-
- public slots:
-  virtual void accept();
-
-protected slots:
-  void onDefault();
-
- private:
-   /// Create editors for aplication properties
-   void createEditors();
-
-   /// Create a viewer page in dialog box
-   void createViewerPage(int thePageId);
-   
-   /// Create menu properties page in the dialog box
-   void createMenuPage(int thePageId);
-
-  XGUI_PreferencesMgr* myPreferences;
-  bool myIsChanged;
-};
-
-#endif
index caa9b07a429195744b440e98611f47a90b5bbb53..c3d200d41ae5f130f517a4802598062eafcd772e 100644 (file)
@@ -1,3 +1,5 @@
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D -->
+
 /*
  * XGUI_PropertyPanel.cpp
  *
@@ -6,8 +8,8 @@
  */
 
 #include <XGUI_PropertyPanel.h>
-#include <XGUI_Constants.h>
-#include <ModuleBase_WidgetPoint2D.h>
+//#include <AppElements_Constants.h>
+#include <ModuleBase_WidgetMultiSelector.h>
 
 #include <QWidget>
 #include <QVBoxLayout>
@@ -17,6 +19,7 @@
 #include <QVBoxLayout>
 #include <QEvent>
 #include <QKeyEvent>
+#include <QLayoutItem>
 
 #ifdef _DEBUG
 #include <iostream>
@@ -28,7 +31,7 @@ XGUI_PropertyPanel::XGUI_PropertyPanel(QWidget* theParent)
 {
   this->setWindowTitle(tr("Property Panel"));
   QAction* aViewAct = this->toggleViewAction();
-  this->setObjectName(XGUI::PROP_PANEL);
+  this->setObjectName(PROP_PANEL);
   setStyleSheet("::title { position: relative; padding-left: 5px; text-align: left center }");
 
   QWidget* aContent = new QWidget(this);
@@ -48,21 +51,21 @@ XGUI_PropertyPanel::XGUI_PropertyPanel(QWidget* theParent)
   aBtnLay->addWidget(aBtn);
   aBtnLay->addStretch(1);
   aBtn = new QPushButton(QIcon(":pictures/button_ok.png"), "", aFrm);
-  aBtn->setObjectName(XGUI::PROP_PANEL_OK);
+  aBtn->setObjectName(PROP_PANEL_OK);
   aBtn->setToolTip(tr("Ok"));
   aBtn->setFlat(true);
   aBtnLay->addWidget(aBtn);
 
   aBtn = new QPushButton(QIcon(":pictures/button_cancel.png"), "", aFrm);
   aBtn->setToolTip(tr("Cancel"));
-  aBtn->setObjectName(XGUI::PROP_PANEL_CANCEL);
+  aBtn->setObjectName(PROP_PANEL_CANCEL);
   aBtn->setFlat(true);
   aBtn->setShortcut(QKeySequence(Qt::Key_Escape));
   aBtnLay->addWidget(aBtn);
 
   myCustomWidget = new QWidget(aContent);
   myMainLayout->addWidget(myCustomWidget);
-  myMainLayout->addStretch(1);
+  setStretchEnabled(true);
 }
 
 XGUI_PropertyPanel::~XGUI_PropertyPanel()
@@ -71,40 +74,52 @@ XGUI_PropertyPanel::~XGUI_PropertyPanel()
 
 void XGUI_PropertyPanel::cleanContent()
 {
+  if (myActiveWidget)
+    myActiveWidget->deactivate();
   myWidgets.clear();
   qDeleteAll(myCustomWidget->children());
   myActiveWidget = NULL;
+  setWindowTitle(tr("Property Panel"));
 }
 
 void XGUI_PropertyPanel::setModelWidgets(const QList<ModuleBase_ModelWidget*>& theWidgets)
 {
   myWidgets = theWidgets;
-  int aS = myWidgets.size();
   if (theWidgets.empty()) return;
-
+  bool isEnableStretch = true;
   QList<ModuleBase_ModelWidget*>::const_iterator anIt = theWidgets.begin(), aLast =
       theWidgets.end();
   for (; anIt != aLast; anIt++) {
     connect(*anIt, SIGNAL(keyReleased(QKeyEvent*)), this, SIGNAL(keyReleased(QKeyEvent*)));
-
-    connect(*anIt, SIGNAL(focusOutWidget(ModuleBase_ModelWidget*)), this,
-            SLOT(activateNextWidget(ModuleBase_ModelWidget*)));
+    connect(*anIt, SIGNAL(focusOutWidget(ModuleBase_ModelWidget*)),
+            this,  SLOT(activateNextWidget(ModuleBase_ModelWidget*)));
     connect(*anIt, SIGNAL(focusInWidget(ModuleBase_ModelWidget*)),
-            this, SLOT(activateWidget(ModuleBase_ModelWidget*)));
-
-    ModuleBase_WidgetPoint2D* aPointWidget = dynamic_cast<ModuleBase_WidgetPoint2D*>(*anIt);
-    if (aPointWidget)
-      connect(aPointWidget, SIGNAL(storedPoint2D(ObjectPtr, const std::string&)), this,
-              SIGNAL(storedPoint2D(ObjectPtr, const std::string&)));
+            this,  SLOT(activateWidget(ModuleBase_ModelWidget*)));
+
+    //ModuleBase_WidgetPoint2D* aPointWidget = dynamic_cast<ModuleBase_WidgetPoint2D*>(*anIt);
+    //if (aPointWidget)
+    //  connect(aPointWidget, SIGNAL(storedPoint2D(ObjectPtr, const std::string&)), this,
+    //          SIGNAL(storedPoint2D(ObjectPtr, const std::string&)))
+    //}
+
+    if (!isEnableStretch) continue;
+    foreach(QWidget* eachWidget, (*anIt)->getControls()) {
+      QSizePolicy::Policy aVPolicy = eachWidget->sizePolicy().verticalPolicy();
+      if(aVPolicy == QSizePolicy::Expanding ||
+         aVPolicy == QSizePolicy::MinimumExpanding) {
+        isEnableStretch = false;
+      }
+    }
   }
+  setStretchEnabled(isEnableStretch);
   ModuleBase_ModelWidget* aLastWidget = theWidgets.last();
   if (aLastWidget) {
     QList<QWidget*> aControls = aLastWidget->getControls();
     if (!aControls.empty()) {
       QWidget* aLastControl = aControls.last();
 
-      QPushButton* anOkBtn = findChild<QPushButton*>(XGUI::PROP_PANEL_OK);
-      QPushButton* aCancelBtn = findChild<QPushButton*>(XGUI::PROP_PANEL_CANCEL);
+      QPushButton* anOkBtn = findChild<QPushButton*>(PROP_PANEL_OK);
+      QPushButton* aCancelBtn = findChild<QPushButton*>(PROP_PANEL_CANCEL);
 
       setTabOrder(aLastControl, anOkBtn);
       setTabOrder(anOkBtn, aCancelBtn);
@@ -138,6 +153,11 @@ void XGUI_PropertyPanel::updateContentWidget(FeaturePtr theFeature)
 
 void XGUI_PropertyPanel::activateNextWidget(ModuleBase_ModelWidget* theWidget)
 {
+  // TO CHECK: Editing operation does not have automatical activation of widgets
+  if (isEditingMode()) {
+    activateWidget(NULL);
+    return;
+  }
   ModuleBase_ModelWidget* aNextWidget = 0;
   QList<ModuleBase_ModelWidget*>::const_iterator anIt = myWidgets.begin(), aLast = myWidgets.end();
   bool isFoundWidget = false;
@@ -151,8 +171,23 @@ void XGUI_PropertyPanel::activateNextWidget(ModuleBase_ModelWidget* theWidget)
   }
   // Normaly focusTo is enough to activate widget
   // here is a special case on mouse click in the viewer
-  if(aNextWidget == NULL) {
-    activateWidget(NULL);
+  //if(aNextWidget == NULL) {
+    activateWidget(aNextWidget);
+  //}
+}
+
+void XGUI_PropertyPanel::setStretchEnabled(bool isEnabled)
+{
+  if (myMainLayout->count() == 0)
+    return;
+  int aStretchIdx = myMainLayout->count() - 1;
+  bool hasStretch = myMainLayout->itemAt(aStretchIdx)->spacerItem() != NULL;
+  QLayoutItem* aChild;
+  if (isEnabled) {
+    if (!hasStretch) myMainLayout->addStretch(1);
+  } else if (hasStretch) {
+    aChild = myMainLayout->takeAt(aStretchIdx);
+    delete aChild;
   }
 }
 
@@ -163,18 +198,52 @@ void XGUI_PropertyPanel::activateNextWidget()
 
 void XGUI_PropertyPanel::setAcceptEnabled(bool isEnabled)
 {
-  QPushButton* anOkBtn = findChild<QPushButton*>(XGUI::PROP_PANEL_OK);
+  QPushButton* anOkBtn = findChild<QPushButton*>(PROP_PANEL_OK);
   anOkBtn->setEnabled(isEnabled);
 }
 
 void XGUI_PropertyPanel::activateWidget(ModuleBase_ModelWidget* theWidget)
 {
+  // Avoid activation of already actve widget. It could happen on focusIn event many times
+  if (theWidget == myActiveWidget)
+    return;
   if(myActiveWidget) {
+    myActiveWidget->deactivate();
     myActiveWidget->setHighlighted(false);
   }
   if(theWidget) {
+    theWidget->activate();
     theWidget->setHighlighted(true);
   }
   myActiveWidget = theWidget;
-  emit widgetActivated(theWidget);
+  if (myActiveWidget)
+    emit widgetActivated(theWidget);
+  else if (!isEditingMode())
+    emit noMoreWidgets();
 }
+
+void XGUI_PropertyPanel::setOkEnabled(bool theEnabled)
+{
+  QPushButton* anOkBtn = findChild<QPushButton*>(PROP_PANEL_OK);
+  anOkBtn->setEnabled(theEnabled);
+}
+
+bool XGUI_PropertyPanel::isOkEnabled() const
+{
+  QPushButton* anOkBtn = findChild<QPushButton*>(PROP_PANEL_OK);
+  return anOkBtn->isEnabled();
+}
+
+void XGUI_PropertyPanel::setCancelEnabled(bool theEnabled)
+{
+  QPushButton* anCancelBtn = findChild<QPushButton*>(PROP_PANEL_CANCEL);
+  anCancelBtn->setEnabled(theEnabled);
+}
+
+bool XGUI_PropertyPanel::isCancelEnabled() const
+{
+  QPushButton* anCancelBtn = findChild<QPushButton*>(PROP_PANEL_CANCEL);
+  return anCancelBtn->isEnabled();
+}
+
+
index 04c4d1ed3c5521bfe40ab28368bc5de21968f906..071779431999597d0f990657037c22dc8690f43f 100644 (file)
@@ -1,3 +1,5 @@
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D -->
+
 /*
  * XGUI_PropertyPanel.h
  *
 class QKeyEvent;
 class QVBoxLayout;
 
+const static char* PROP_PANEL = "property_panel_dock";
+const static char* PROP_PANEL_OK = "property_panel_ok";
+const static char* PROP_PANEL_CANCEL = "property_panel_cancel";
+
 class XGUI_EXPORT XGUI_PropertyPanel : public ModuleBase_IPropertyPanel
 {
 Q_OBJECT
  public:
+
+
   XGUI_PropertyPanel(QWidget* theParent);
   virtual ~XGUI_PropertyPanel();
 
@@ -49,22 +57,35 @@ Q_OBJECT
   /// Activate the next from current widget in the property panel
   virtual void activateNextWidget();
 
+  void setStretchEnabled(bool isEnabled);
+
+  /// Set Enable/Disable state of Ok button
+  virtual void setOkEnabled(bool theEnabled);
+
+  /// Returns state of Ok button
+  virtual bool isOkEnabled() const;
+
+  /// Set Enable/Disable state of Ok button
+  virtual void setCancelEnabled(bool theEnabled);
+
+  /// Returns state of Ok button
+  virtual bool isCancelEnabled() const;
+
  public slots:
   void updateContentWidget(FeaturePtr theFeature);
   // Enables / disables "ok" ("accept") button
   void setAcceptEnabled(bool);
 
- protected slots:
   // Makes the given widget active, highlights it and removes
   // highlighting from the previous active widget
   // emits widgetActivated(theWidget) signal
-  void activateWidget(ModuleBase_ModelWidget* theWidget);
+  virtual void activateWidget(ModuleBase_ModelWidget* theWidget);
 
  signals:
   /// Signal about the point 2d set to the feature
   /// \param the feature
   /// \param the attribute of the feature
-  void storedPoint2D(ObjectPtr theFeature, const std::string& theAttribute);
+  //void storedPoint2D(ObjectPtr theFeature, const std::string& theAttribute);
 
 
  private:
index ac4f00e87fa2946ff616230ae2a44c3a090b17a3..72c94c4f4bc50387e053e055eedb2de02d6aef77 100644 (file)
@@ -1,3 +1,5 @@
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D -->
+
 /*
  * XGUI_QEvents.cpp
  *
index 5c389fade4036fe81a0926b68b98a6fc50900027..7aa6fc34f2dafcc3df5e0628d1a2fba94675f453 100644 (file)
@@ -1,3 +1,5 @@
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D -->
+
 /*
  * XGUI_QEvents.h
  *
diff --git a/src/XGUI/XGUI_RubberBand.cpp b/src/XGUI/XGUI_RubberBand.cpp
deleted file mode 100644 (file)
index 3903682..0000000
+++ /dev/null
@@ -1,242 +0,0 @@
-#include "XGUI_RubberBand.h"\r
-\r
-#include <QBitmap>\r
-#include <QImage>\r
-#include <QPaintEvent>\r
-#include <QPainter>\r
-#include <QPalette>\r
-#include <QShowEvent>\r
-#include <QVectorIterator>\r
-\r
-/*!\r
- \class QtxAbstractRubberBand\r
- \brief Analog of class QRubberBand with possibility of creation non-rectangular contour for selection.\r
\r
- Currently this class does not support Style functionality in full.\r
- */\r
-\r
-/*!\r
- \brief Constructor\r
- \param theParent parent widget\r
- */\r
-\r
-XGUI_AbstractRubberBand::XGUI_AbstractRubberBand(QWidget* theParent)\r
-    : QWidget(theParent),\r
-      myPoints(),\r
-      myIsClosed(false)\r
-{\r
-  setAttribute(Qt::WA_TransparentForMouseEvents);\r
-#ifndef WIN32\r
-  setAttribute(Qt::WA_NoSystemBackground);\r
-#endif //WIN32\r
-  setAttribute(Qt::WA_WState_ExplicitShowHide);\r
-  setVisible(false);\r
-  theParent->installEventFilter(this);\r
-  setGeometry(QRect(QPoint(0, 0), theParent->size()));\r
-}\r
-\r
-/*!\r
- \brief Destructor\r
- */\r
-XGUI_AbstractRubberBand::~XGUI_AbstractRubberBand()\r
-{\r
-}\r
-\r
-void XGUI_AbstractRubberBand::clearGeometry()\r
-{\r
-  myPoints.clear();\r
-}\r
-\r
-bool XGUI_AbstractRubberBand::isClosed()\r
-{\r
-  return myIsClosed;\r
-}\r
-\r
-void XGUI_AbstractRubberBand::paintEvent(QPaintEvent* theEvent)\r
-{\r
-  if (!myPoints.empty()) {\r
-    QPixmap tiledPixmap(16, 16);\r
-\r
-    QPainter pixmapPainter(&tiledPixmap);\r
-    pixmapPainter.setPen(Qt::NoPen);\r
-    pixmapPainter.setBrush(QBrush(Qt::black, Qt::Dense4Pattern));\r
-    pixmapPainter.setBackground(QBrush(Qt::white));\r
-    pixmapPainter.setBackgroundMode(Qt::OpaqueMode);\r
-    pixmapPainter.drawRect(0, 0, tiledPixmap.width(), tiledPixmap.height());\r
-    pixmapPainter.end();\r
-    // ### workaround for borked XRENDER\r
-    tiledPixmap = QPixmap::fromImage(tiledPixmap.toImage());\r
-\r
-    QPainter aPainter(this);\r
-    aPainter.setRenderHint(QPainter::Antialiasing);\r
-    QRect r = myPoints.boundingRect();\r
-    aPainter.setClipRegion(r.normalized().adjusted(-1, -1, 2, 2));\r
-    aPainter.drawTiledPixmap(0, 0, width(), height(), tiledPixmap);\r
-\r
-    aPainter.end();\r
-  }\r
-}\r
-\r
-void XGUI_AbstractRubberBand::showEvent(QShowEvent* theEvent)\r
-{\r
-  raise();\r
-  theEvent->ignore();\r
-}\r
-\r
-void XGUI_AbstractRubberBand::moveEvent(QMoveEvent*)\r
-{\r
-}\r
-\r
-void XGUI_AbstractRubberBand::resizeEvent(QResizeEvent*)\r
-{\r
-}\r
-\r
-bool XGUI_AbstractRubberBand::eventFilter(QObject* obj, QEvent* e)\r
-{\r
-  if (obj && obj == parent() && e->type() == QEvent::Resize) {\r
-    QWidget* p = (QWidget*) parent();\r
-    setGeometry(QRect(QPoint(0, 0), p->size()));\r
-  }\r
-  return QWidget::eventFilter(obj, e);\r
-}\r
-\r
-QRegion createRegion(const QPointF& p1, const QPointF& p2)\r
-{\r
-  if (p1 == p2)\r
-    return QRegion();\r
-\r
-  QLineF n = QLineF(p1, p2).normalVector();  //.unitVector();\r
-  n.setLength(1);\r
-  n.translate(p1 * -1);\r
-  QPointF nPoint = n.p2();\r
-\r
-  QPolygonF p;\r
-  p << p1 + nPoint << p2 + nPoint << p2 - nPoint << p1 - nPoint << p1 + nPoint;\r
-\r
-  return QRegion(p.toPolygon());\r
-}\r
-\r
-void XGUI_AbstractRubberBand::updateMask()\r
-{\r
-  QRegion r;\r
-\r
-  QVectorIterator<QPoint> it(myPoints);\r
-  while (it.hasNext()) {\r
-    QPoint p = it.next();\r
-    if (!it.hasNext())\r
-      break;\r
-\r
-    QPoint np = it.peekNext();\r
-\r
-    if (p == np)\r
-      continue;\r
-\r
-    r += createRegion(p, np);\r
-  }\r
-\r
-  if (isClosed())\r
-    r += createRegion(myPoints.last(), myPoints.first());\r
-\r
-  if (!r.isEmpty())\r
-    setMask(r);\r
-}\r
-\r
-//**********************************************************\r
-XGUI_RectRubberBand::XGUI_RectRubberBand(QWidget* parent)\r
-    : XGUI_AbstractRubberBand(parent)\r
-{\r
-  myPoints.resize(4);\r
-  myIsClosed = true;\r
-}\r
-\r
-XGUI_RectRubberBand::~XGUI_RectRubberBand()\r
-{\r
-}\r
-\r
-void XGUI_RectRubberBand::initGeometry(const QRect& theRect)\r
-{\r
-  myPoints.clear();\r
-  myPoints << theRect.topLeft() << theRect.topRight() << theRect.bottomRight()\r
-           << theRect.bottomLeft();\r
-  //setMask( QRegion( myPoints ) );\r
-  updateMask();\r
-}\r
-\r
-void XGUI_RectRubberBand::setStartPoint(const QPoint& thePoint)\r
-{\r
-  myPoints[0] = thePoint;\r
-  myPoints[1].setY(thePoint.y());\r
-  myPoints[3].setX(thePoint.x());\r
-  updateMask();\r
-}\r
-\r
-void XGUI_RectRubberBand::setEndPoint(const QPoint& thePoint)\r
-{\r
-  myPoints[2] = thePoint;\r
-  myPoints[1].setX(thePoint.x());\r
-  myPoints[3].setY(thePoint.y());\r
-  updateMask();\r
-}\r
-\r
-void XGUI_RectRubberBand::clearGeometry()\r
-{\r
-  QMutableVectorIterator<QPoint> i(myPoints);\r
-  while (i.hasNext()) {\r
-    i.next();\r
-    i.setValue(QPoint(-1, -1));\r
-  }\r
-}\r
-\r
-//**********************************************************\r
-XGUI_PolyRubberBand::XGUI_PolyRubberBand(QWidget* parent)\r
-    : XGUI_AbstractRubberBand(parent)\r
-{\r
-}\r
-\r
-XGUI_PolyRubberBand::~XGUI_PolyRubberBand()\r
-{\r
-}\r
-\r
-void XGUI_PolyRubberBand::initGeometry(const QPolygon& thePoints)\r
-{\r
-  myPoints = thePoints;\r
-  updateMask();\r
-}\r
-\r
-void XGUI_PolyRubberBand::initGeometry(const QPoint& thePoint)\r
-{\r
-  myPoints.clear();\r
-  myPoints << thePoint;\r
-  updateMask();\r
-}\r
-\r
-void XGUI_PolyRubberBand::addNode(const QPoint& thePoint)\r
-{\r
-  myPoints << thePoint;\r
-  updateMask();\r
-}\r
-\r
-void XGUI_PolyRubberBand::replaceLastNode(const QPoint& thePoint)\r
-{\r
-  if (!myPoints.empty()) {\r
-    myPoints.pop_back();\r
-    myPoints << thePoint;\r
-    updateMask();\r
-  }\r
-}\r
-\r
-void XGUI_PolyRubberBand::removeLastNode()\r
-{\r
-  if (!myPoints.empty()) {\r
-    myPoints.pop_back();\r
-    updateMask();\r
-  }\r
-}\r
-\r
-void XGUI_PolyRubberBand::setClosed(bool theFlag)\r
-{\r
-  if (myIsClosed != theFlag) {\r
-    myIsClosed = theFlag;\r
-    updateMask();\r
-  }\r
-}\r
diff --git a/src/XGUI/XGUI_RubberBand.h b/src/XGUI/XGUI_RubberBand.h
deleted file mode 100644 (file)
index e31eafd..0000000
+++ /dev/null
@@ -1,83 +0,0 @@
-#ifndef XGUI_RubberBand_H
-#define XGUI_RubberBand_H
-
-#include "XGUI.h"
-#include <QWidget>
-
-/*!
- \class XGUI_AbstractRubberBand
- \ingroup GUI
- \brief Analog of class QRubberBand with possibility of creation non-rectangular contour for selection.
- Currently this class does not support Style functionality in full.
- */
-class XGUI_EXPORT XGUI_AbstractRubberBand : public QWidget
-{
-Q_OBJECT
- protected:
-  XGUI_AbstractRubberBand(QWidget*);
-
- public:
-  virtual ~XGUI_AbstractRubberBand();
-
-  virtual void clearGeometry();
-
-  bool isClosed();
-
- protected:
-  virtual void paintEvent(QPaintEvent*);
-  virtual void showEvent(QShowEvent*);
-  virtual void moveEvent(QMoveEvent*);
-  virtual void resizeEvent(QResizeEvent*);
-
-  virtual bool eventFilter(QObject*, QEvent*);
-
-  virtual void updateMask();
-
- protected:
-  QPolygon myPoints;
-
-  bool myIsClosed;
-};
-
-/*!
- \class XGUI_RectRubberBand
- \ingroup GUI
- \brief Analog of class QRubberBand with possibility of creation non-rectangular contour for selection.
- Redefinition for rectangular rubber band
- */
-class XGUI_RectRubberBand : public XGUI_AbstractRubberBand
-{
-Q_OBJECT
-
- public:
-  XGUI_RectRubberBand(QWidget*);
-  virtual ~XGUI_RectRubberBand();
-
-  void initGeometry(const QRect&);
-  void setStartPoint(const QPoint&);
-  void setEndPoint(const QPoint&);
-
-  virtual void clearGeometry();
-};
-
-class XGUI_PolyRubberBand : public XGUI_AbstractRubberBand
-{
-Q_OBJECT
-
- public:
-  XGUI_PolyRubberBand(QWidget*);
-  virtual ~XGUI_PolyRubberBand();
-
-  void initGeometry(const QPolygon&);
-  void initGeometry(const QPoint&);
-
-  void addNode(const QPoint&);
-  void replaceLastNode(const QPoint&);
-  void removeLastNode();
-
-  void setClosed(bool);
-};
-
-#endif
index d055e67c37f13bdd2758cc7c4e878ed6feaf0deb..13ce80b05e6d4a02fd35c260a1ddc226ca9bf140 100644 (file)
@@ -1,3 +1,5 @@
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D -->
+
 #ifndef XGUI_SALOMECONNECTOR_H
 #define XGUI_SALOMECONNECTOR_H
 
index 265fb9029145f05e8a63370042d921408ef64bff..a4ca2212d0923951d50cc95fd5ff483dc3d4dad8 100644 (file)
@@ -1,3 +1,5 @@
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D -->
+
 // File:        XGUI_Selection.cpp
 // Created:     8 July 2014
 // Author:      Vitaly SMETANNIKOV
@@ -21,39 +23,54 @@ XGUI_Selection::XGUI_Selection(XGUI_Workshop* theWorkshop)
 
 QList<ModuleBase_ViewerPrs> XGUI_Selection::getSelected(int theShapeTypeToSkip) const
 {
-  //std::set<ObjectPtr> aPrsFeatures;
+  QList<long> aSelectedIds; // Remember of selected address in order to avoid duplicates
+
   QList<ModuleBase_ViewerPrs> aPresentations;
   XGUI_Displayer* aDisplayer = myWorkshop->displayer();
 
   Handle(AIS_InteractiveContext) aContext = myWorkshop->viewer()->AISContext();
-  for (aContext->InitSelected(); aContext->MoreSelected(); aContext->NextSelected()) {
-    ModuleBase_ViewerPrs aPrs;
-
-    Handle(AIS_InteractiveObject) anIO = aContext->SelectedInteractive();
-    aPrs.setInteractive(anIO);
-
-    ObjectPtr aFeature = aDisplayer->getObject(anIO);
-    // we should not check the appearance of this feature because there can be some selected shapes
-    // for one feature
-    //if (aPrsFeatures.find(aFeature) == aPrsFeatures.end()) {
-      aPrs.setFeature(aFeature);
-      //aPrsFeatures.insert(aFeature);
-    //}
-    if (aContext->HasOpenedContext()) {
+  if (aContext->HasOpenedContext()) {
+    for (aContext->InitSelected(); aContext->MoreSelected(); aContext->NextSelected()) {
+      ModuleBase_ViewerPrs aPrs;
+      Handle(AIS_InteractiveObject) anIO = aContext->SelectedInteractive();
+      if (aSelectedIds.contains((long)anIO.Access()))
+        continue;
+    
+      aSelectedIds.append((long)anIO.Access());
+      aPrs.setInteractive(anIO);
+
+      ObjectPtr aFeature = aDisplayer->getObject(anIO);
+      // we should not check the appearance of this feature because there can be some selected shapes
+      // for one feature
       TopoDS_Shape aShape = aContext->SelectedShape();
       if (!aShape.IsNull() && (aShape.ShapeType() != theShapeTypeToSkip))
         aPrs.setShape(aShape);
+      Handle(SelectMgr_EntityOwner) anOwner = aContext->SelectedOwner();
+      aPrs.setOwner(anOwner);
+      aPrs.setFeature(aFeature);
+      aPresentations.append(aPrs);
+    }
+  } else {
+    for (aContext->InitCurrent(); aContext->MoreCurrent(); aContext->NextCurrent()) {
+      ModuleBase_ViewerPrs aPrs;
+      Handle(AIS_InteractiveObject) anIO = aContext->Current();
+      if (aSelectedIds.contains((long)anIO.Access()))
+        continue;
+    
+      aSelectedIds.append((long)anIO.Access());
+      aPrs.setInteractive(anIO);
+
+      ObjectPtr aFeature = aDisplayer->getObject(anIO);
+      aPrs.setFeature(aFeature);
+      aPresentations.append(aPrs);
     }
-    Handle(SelectMgr_EntityOwner) anOwner = aContext->SelectedOwner();
-    aPrs.setOwner(anOwner);
-    aPresentations.append(aPrs);
   }
   return aPresentations;
 }
 
 QList<ModuleBase_ViewerPrs> XGUI_Selection::getHighlighted(int theShapeTypeToSkip) const
 {
-  //std::set<ObjectPtr> aPrsFeatures;
+  QList<long> aSelectedIds; // Remember of selected address in order to avoid duplicates
   QList<ModuleBase_ViewerPrs> aPresentations;
   XGUI_Displayer* aDisplayer = myWorkshop->displayer();
 
@@ -61,15 +78,16 @@ QList<ModuleBase_ViewerPrs> XGUI_Selection::getHighlighted(int theShapeTypeToSki
   for (aContext->InitDetected(); aContext->MoreDetected(); aContext->NextDetected()) {
     ModuleBase_ViewerPrs aPrs;
     Handle(AIS_InteractiveObject) anIO = aContext->DetectedInteractive();
+    if (aSelectedIds.contains((long)anIO.Access()))
+      continue;
+    
+    aSelectedIds.append((long)anIO.Access());
     aPrs.setInteractive(anIO);
 
     ObjectPtr aResult = aDisplayer->getObject(anIO);
     // we should not check the appearance of this feature because there can be some selected shapes
     // for one feature
-    //if (aPrsFeatures.find(aResult) == aPrsFeatures.end()) {
-      aPrs.setFeature(aResult);
-      //aPrsFeatures.insert(aResult);
-    //}
+    aPrs.setFeature(aResult);
     if (aContext->HasOpenedContext()) {
       TopoDS_Shape aShape = aContext->DetectedShape();
       if (!aShape.IsNull() && aShape.ShapeType() != theShapeTypeToSkip)
@@ -80,14 +98,14 @@ QList<ModuleBase_ViewerPrs> XGUI_Selection::getHighlighted(int theShapeTypeToSki
   return aPresentations;
 }
 
-QList<ObjectPtr> XGUI_Selection::selectedObjects() const
+QObjectPtrList XGUI_Selection::selectedObjects() const
 {
   return myWorkshop->objectBrowser()->selectedObjects();
 }
 
-QList<ObjectPtr> XGUI_Selection::selectedPresentations() const
+QObjectPtrList XGUI_Selection::selectedPresentations() const
 {
-  QList<ObjectPtr> aSelectedList;
+  QObjectPtrList aSelectedList;
 
   Handle(AIS_InteractiveContext) aContext = myWorkshop->viewer()->AISContext();
   for (aContext->InitSelected(); aContext->MoreSelected(); aContext->NextSelected()) {
index 4868a9a80f7ffad28785f15f05cc8d354a26d158..cfefd28a0cb0730b5e7fc4b58c0d809c972459c9 100644 (file)
@@ -1,3 +1,5 @@
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D -->
+
 // File:        XGUI_Selection.h
 // Created:     8 July 2014
 // Author:      Vitaly SMETANNIKOV
@@ -34,14 +36,14 @@ class XGUI_EXPORT XGUI_Selection : public ModuleBase_ISelection
   virtual QList<ModuleBase_ViewerPrs> getHighlighted(int theShapeTypeToSkip = -1) const;
 
   /**
-   * Returns list of currently selected objects
+   * Returns list of currently selected objects in object browser
    */
-  virtual QList<ObjectPtr> selectedObjects() const;
+  virtual QObjectPtrList selectedObjects() const;
 
   /**
    * Returns list of currently selected results
    */
-  virtual QList<ObjectPtr> selectedPresentations() const;
+  virtual QObjectPtrList selectedPresentations() const;
 
   //! Returns list of currently selected QModelIndexes
   virtual QModelIndexList selectedIndexes() const;
index 3d3937fc639087a78ac1f6045d4cc21110b21477..bafdeda30423f348fe2e8ca03a30d978d22df891 100644 (file)
@@ -1,13 +1,16 @@
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D -->
+
 #include "XGUI_SelectionMgr.h"
 
 #include "XGUI_Workshop.h"
-#include "XGUI_MainWindow.h"
 #include "XGUI_ObjectsBrowser.h"
 #include "XGUI_SalomeConnector.h"
 #include "XGUI_ViewerProxy.h"
 #include "XGUI_Displayer.h"
 #include "XGUI_Selection.h"
 
+#include <AppElements_MainWindow.h>
+
 #include <ModelAPI_Feature.h>
 #include <ModelAPI_Session.h>
 #include <ModelAPI_AttributeDocRef.h>
@@ -40,7 +43,7 @@ void XGUI_SelectionMgr::connectViewers()
 //**************************************************************
 void XGUI_SelectionMgr::onObjectBrowserSelection()
 {
-  QList<ObjectPtr> aObjects = myWorkshop->objectBrowser()->selectedObjects();
+  QObjectPtrList aObjects = myWorkshop->objectBrowser()->selectedObjects();
   XGUI_Displayer* aDisplayer = myWorkshop->displayer();
   aDisplayer->setSelected(aObjects);
   emit selectionChanged();
@@ -49,7 +52,7 @@ void XGUI_SelectionMgr::onObjectBrowserSelection()
 //**************************************************************
 void XGUI_SelectionMgr::onViewerSelection()
 {
-  QList<ObjectPtr> aFeatures;
+  QObjectPtrList aFeatures;
   Handle(AIS_InteractiveContext) aContext = myWorkshop->viewer()->AISContext();
   for (aContext->InitSelected(); aContext->MoreSelected(); aContext->NextSelected()) {
     Handle(AIS_InteractiveObject) anIO = aContext->SelectedInteractive();
index 7a445878c73f037d2e1e54ddf63faf5dd83f610b..6b45fff70adb6f2b564d602964cfd97ad3b20b79 100644 (file)
@@ -1,3 +1,5 @@
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D -->
+
 #ifndef XGUI_SelectionMgr_H
 #define XGUI_SelectionMgr_H
 
index 84e43abf37a498af1a52a8c1a7e768d1747af2f4..26672cd89bc4cdf295c2152632fe497bdb6c8048 100644 (file)
@@ -1,3 +1,5 @@
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D -->
+
 #include "XGUI_Tools.h"
 
 #include <TopoDS_Shape.hxx>
@@ -33,12 +35,6 @@ QString file(const QString& path, bool withExt)
     return QFileInfo(fPath).completeBaseName();
 }
 
-//******************************************************************
-QString extension(const QString& path, bool full)
-{
-  return full ? QFileInfo(path).completeSuffix() : QFileInfo(path).suffix();
-}
-
 //******************************************************************
 QString addSlash(const QString& path)
 {
@@ -49,12 +45,6 @@ QString addSlash(const QString& path)
   return res;
 }
 
-//******************************************************************
-QRect makeRect(const int x1, const int y1, const int x2, const int y2)
-{
-  return QRect(qMin(x1, x2), qMin(y1, y2), qAbs(x2 - x1), qAbs(y2 - y1));
-}
-
 //******************************************************************
 bool isModelObject(FeaturePtr theFeature)
 {
index cc80b28be6408b9e2e15dda760bd5179cab6ccb1..614b2be23ca15f8ac8b5e0fc79f195bbacd9aec6 100644 (file)
@@ -1,3 +1,5 @@
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D -->
+
 #ifndef XGUI_Tools_H
 #define XGUI_Tools_H
 
@@ -33,16 +35,6 @@ QString XGUI_EXPORT dir(const QString& path, bool isAbs = true);
  */
 QString XGUI_EXPORT file(const QString& path, bool withExt = true);
 
-/*!
- \brief Return extension part of the file path.
-
- \param path file path
- \param full if true complete extension (all extensions, dot separated)
- is returned, otherwise (default) only last extension is returned
- \return extension part of the file path 
- */
-QString XGUI_EXPORT extension(const QString& path, bool full = false);
-
 /*!
  \brief Add a slash (platform-specific) to the end of \a path
  if it is not already there.
@@ -51,12 +43,6 @@ QString XGUI_EXPORT extension(const QString& path, bool full = false);
  */
 QString XGUI_EXPORT addSlash(const QString& path);
 
-/*! 
- Creates a rect with TopLeft = ( min(x1,x2), min(y1,y2) )
- and BottomRight = ( TopLeft + (x2-x1)(y2-y1) )    
- */
-QRect XGUI_EXPORT makeRect(const int x1, const int y1, const int x2, const int y2);
-
 /// The model concerning tools
 
 /*!
diff --git a/src/XGUI/XGUI_ViewBackground.cpp b/src/XGUI/XGUI_ViewBackground.cpp
deleted file mode 100644 (file)
index c7ac791..0000000
+++ /dev/null
@@ -1,209 +0,0 @@
-#include "XGUI_ViewBackground.h"
-
-/*!
- \brief Default constructor.
- Creates invalid background data.
- */
-XGUI_ViewBackground::XGUI_ViewBackground()
-    : myTextureMode(XGUI::CenterTexture),
-      myGradientType(XGUI::NoGradient),
-      myTextureShown(false)
-{
-  setMode(XGUI::NoBackground);
-}
-
-/*!
- \brief Constructor.
- Creates background data initialized with the specified color
- \param c color
- */
-XGUI_ViewBackground::XGUI_ViewBackground(const QColor& theColor)
-    : myTextureMode(XGUI::CenterTexture),
-      myGradientType(XGUI::NoGradient),
-      myTextureShown(false)
-{
-  setColor(theColor);
-}
-
-/*!
- \brief Constructor.
- Creates background data initialized with the specified two-color gradient
- \param type gradient type identifier
- \param c1 first gradient color
- \param c2 second gradient color
- \note the interpretation of the gradient identifier should be done in the calling code
- */
-XGUI_ViewBackground::XGUI_ViewBackground(XGUI::GradientType type, const QColor& c1,
-                                         const QColor& c2)
-    : myTextureMode(XGUI::CenterTexture),
-      myGradientType(XGUI::NoGradient),
-      myTextureShown(false)
-{
-  setGradient(type, c1, c2);
-}
-
-/*!
- \brief Constructor.
- Creates background data initialized with the arbirtary gradient data
- \param grad gradient data
- */
-XGUI_ViewBackground::XGUI_ViewBackground(const QGradient& grad)
-    : myTextureMode(XGUI::CenterTexture),
-      myGradientType(XGUI::NoGradient),
-      myTextureShown(false)
-{
-  setGradient(grad);
-}
-
-/*!
- \brief Destructor.
- */
-XGUI_ViewBackground::~XGUI_ViewBackground()
-{
-}
-
-/*!
- \brief Compares two background data objects
- */
-bool XGUI_ViewBackground::operator==(const XGUI_ViewBackground& other) const
-{
-  return (myMode == other.myMode) && (myTextureMode == other.myTextureMode)
-      && (myFileName == other.myFileName) && (myColors == other.myColors)
-      && (myGradientType == other.myGradientType) && (myGradient == other.myGradient)
-      && (myTextureShown == other.myTextureShown);
-}
-
-/*!
- \brief Returns \c false if background data is not set (invalid)
- \return \c true if background data is valid or \c false otherwise
- \sa mode()
- */
-bool XGUI_ViewBackground::isValid() const
-{
-  return myMode != XGUI::NoBackground;
-}
-
-/*!
- \brief Get file name used as a texture image
- \return path to the texture image file
- \sa setTexture(), setTextureShown()
- */
-XGUI::TextureMode XGUI_ViewBackground::texture(QString& fileName) const
-{
-  fileName = myFileName;
-  return myTextureMode;
-}
-
-/*!
- \brief Set file name to be used as a texture image.
-
- \note To show texture image on the background it is necessary to call additionally
- setTextureShown() method.
-
- \param fileName path to the texture image file name
- \param m texture mode (CenterTexture by default)
- \sa texture(), setTextureShown()
- */
-void XGUI_ViewBackground::setTexture(const QString& fileName, const XGUI::TextureMode m)
-{
-  myFileName = fileName;
-  myTextureMode = m;
-}
-
-/*!
- \brief Check if "show texture" flag is switched on
- \return \c true if "show texture" flag is set or \c false otherwise
- \sa setTextureShown(), texture()
- */
-bool XGUI_ViewBackground::isTextureShown() const
-{
-  return myTextureShown;
-}
-
-/*!
- \brief Specify if texture should be shown on the background or no.
- \param on \c true if texture should be shown or \c false otherwise
- \sa isTextureShown(), texture()
- */
-void XGUI_ViewBackground::setTextureShown(bool on)
-{
-  myTextureShown = on;
-}
-
-/*!
- \brief Get background color. Returns null QColor if color is not set
- \return solid background color
- \sa setColor(), mode()
- */
-QColor XGUI_ViewBackground::color() const
-{
-  return myColors.count() > 0 ? myColors[0] : QColor();
-}
-
-/*!
- \brief Set background color and switch to the ColorBackground mode
- \param c color
- \sa color(), mode()
- */
-void XGUI_ViewBackground::setColor(const QColor& c)
-{
-  myColors.clear();
-  myColors << c;
-  setMode(XGUI::ColorBackground);
-}
-
-/*!
- \brief Get simple gradient data.
- Returns -1 and null QColor for \a c1 and \a c2 if gradient data is not set
- \param c1 first gradient color is returned via this parameter
- \param c2 second gradient color is returned via this parameter
- \return current two-colored gradient mode type identifier
- \note the interpretation of the gradient identifier should be done in the calling code
- \sa setGradient(int, const QColor&, const QColor&), mode()
- */
-int XGUI_ViewBackground::gradient(QColor& c1, QColor& c2) const
-{
-  c1 = myColors.count() > 0 ? myColors[0] : QColor();
-  c2 = myColors.count() > 1 ? myColors[1] : (myColors.count() > 0 ? myColors[0] : QColor());
-  return myGradientType;
-}
-
-/*!
- \brief Set simple background gradient data and switch to the SimpleGradientBackground mode
- \param type two-colored gradient mode type identifier
- \param c1 first gradient color is returned via this parameter
- \param c2 second gradient color is returned via this parameter
- \note the interpretation of the gradient identifier should be done in the calling code
- \sa gradient(QColor&, QColor&), mode()
- */
-void XGUI_ViewBackground::setGradient(XGUI::GradientType type, const QColor& c1, const QColor& c2)
-{
-  myColors.clear();
-  myColors << c1 << c2;
-  myGradientType = type;
-  setMode(XGUI::SimpleGradientBackground);
-}
-
-/*!
- \brief Get complex gradient data.
- Returns QGradient of QGradient::NoGradient if gradient data is not set
- \note This function does not transform simple gradient data set with 
- setGradient( const QString&, const QColor&, const QColor& ) to QGradient class
- \return gradient data
- \sa setGradient(const QGradient&), mode()
- */
-const QGradient* XGUI_ViewBackground::gradient() const
-{
-  return &myGradient;
-}
-
-/*!
- \brief Set complex background gradient data and switch to the CustomGradientBackground mode
- \param grad gradient data (QLinearGradient, QRadialGradient or QConicalGradient)
- \sa gradient(), mode()
- */
-void XGUI_ViewBackground::setGradient(const QGradient& grad)
-{
-  myGradient = grad;
-  setMode(XGUI::CustomGradientBackground);
-}
diff --git a/src/XGUI/XGUI_ViewBackground.h b/src/XGUI/XGUI_ViewBackground.h
deleted file mode 100644 (file)
index 7452849..0000000
+++ /dev/null
@@ -1,109 +0,0 @@
-#ifndef XGUI_ViewBackground_H
-#define XGUI_ViewBackground_H
-
-#include "XGUI.h"
-#include "XGUI_Constants.h"
-
-#include <QColor>
-#include <QGradient>
-#include <QString>
-#include <QCompleter>
-
-typedef QList<QColor> QColorList;     //!< list of colors
-
-/*!
- \class XGUI_ViewBackground
- \brief Stores background data
-
- This class is used to store background data. Depending on the mode,
- the background can be specified by:
- - image (by assigning the file name to be used as background texture), see setTexture(), setTextureShown()
- - single color (by assigning any color), see setColor()
- - simple two-color gradient (with the gradient type id and two colors), see setGradient( int, const QColor&, const QColor& )
- - complex gradient (by assigning arbitrary gradient data), see setGradient( const QGradient& )
-
- The class stores all the data passed to it, so switching between different modes can be done
- just by calling setMode() function.
-
- \note Texture is used with combination of the background mode.
-
- \note Two-color gradient is specified by two colors and integer identifier. The interpretation of 
- this identifier should be done in the calling code.
-
- \code
- XGUI_ViewBackground bg;
- bg.setColor( QColor(100, 100, 100) );                  // bg is switched to ColorBackground mode
- bg.setGradient( Qt::Horizontal, Qt::gray, Qt::white ); // bg is switched to ColorBackground mode
- QLinearGradient grad( 0,0,1,1 ); 
- grad.setColorAt( 0.0, Qt::gray ); 
- grad.setColorAt( 0.5, Qt::white );
- grad.setColorAt( 1.0, Qt::green );
- grad.setSpread( QGradient::PadSpread );
- bg.setGradient( grad );                                // bg is switched to CustomGradientBackground mode
- bg.setMode( ColorBackground );                    // bg is switched back to ColorBackground mode
- bg.setTexture( "/data/images/background.png" );        // specify texture (in the centered mode by default)
- bg.setTextureShown( true );                            // draw texture on the solid color background
- \endcode
- */
-class XGUI_EXPORT XGUI_ViewBackground
-{
- public:
-  XGUI_ViewBackground();
-  XGUI_ViewBackground(const QColor& theColor);
-  XGUI_ViewBackground(XGUI::GradientType type, const QColor& theColor1, const QColor& theColor2);
-  XGUI_ViewBackground(const QGradient&);
-  virtual ~XGUI_ViewBackground();
-
-  bool operator==(const XGUI_ViewBackground&) const;
-  inline bool operator!=(const XGUI_ViewBackground& other) const
-  {
-    return !operator==(other);
-  }
-
-  bool isValid() const;
-
-  /*!
-   \brief Get background mode
-   \return current background mode
-   \sa setMode()
-   */
-  XGUI::BackgroundMode mode() const
-  {
-    return myMode;
-  }
-
-  /*!
-   \brief Set background mode
-   \param m background mode being set
-   \sa mode()
-   */
-  void setMode(const XGUI::BackgroundMode m)
-  {
-    myMode = m;
-  }
-
-  XGUI::TextureMode texture(QString&) const;
-  void setTexture(const QString&, XGUI::TextureMode = XGUI::CenterTexture);
-  bool isTextureShown() const;
-  void setTextureShown(bool);
-
-  QColor color() const;
-  void setColor(const QColor&);
-
-  int gradient(QColor&, QColor&) const;
-  void setGradient(XGUI::GradientType, const QColor&, const QColor&);
-
-  const QGradient* gradient() const;
-  void setGradient(const QGradient&);
-
- private:
-  XGUI::BackgroundMode myMode;
-  XGUI::TextureMode myTextureMode;
-  QString myFileName;
-  QColorList myColors;
-  XGUI::GradientType myGradientType;
-  QGradient myGradient;
-  bool myTextureShown;
-};
-
-#endif
diff --git a/src/XGUI/XGUI_ViewPort.cpp b/src/XGUI/XGUI_ViewPort.cpp
deleted file mode 100644 (file)
index 02ed792..0000000
+++ /dev/null
@@ -1,557 +0,0 @@
-#include "XGUI_ViewPort.h"
-#include "XGUI_ViewWindow.h"
-#include "XGUI_Viewer.h"
-#include "XGUI_Constants.h"
-
-#include <QPaintEvent>
-#include <QPainter>
-#include <QFileInfo>
-#include <QApplication>
-
-#include <V3d_OrthographicView.hxx>
-#include <V3d_PerspectiveView.hxx>
-#include <Visual3d_View.hxx>
-#include <Graphic3d_GraphicDriver.hxx>
-
-#ifdef WIN32
-#include <WNT_Window.hxx>
-#else
-#include <Xw_Window.hxx>
-#endif
-
-#include <GL/gl.h>
-
-static double rx = 0.;
-static double ry = 0.;
-static int sx = 0;
-static int sy = 0;
-static Standard_Boolean zRotation = Standard_False;
-
-/*!
- Create native view window for CasCade view [ static ]
- */
-Handle(Aspect_Window) CreateCasWindow(const Handle(V3d_View)& view, WId winId)
-{
-  Aspect_Handle aWindowHandle = (Aspect_Handle) winId;
-#ifdef WIN32
-  Handle(WNT_Window) viewWindow = new WNT_Window(aWindowHandle);
-#else
-  Handle(Aspect_DisplayConnection) aDispConnection = view->Viewer()->Driver()->GetDisplayConnection();
-  Handle(Xw_Window) viewWindow = new Xw_Window( aDispConnection, aWindowHandle );
-#endif
-  return viewWindow;
-}
-
-//************************************************************************
-//************************************************************************
-//************************************************************************
-XGUI_ViewPort::XGUI_ViewPort(XGUI_ViewWindow* theParent, const Handle(V3d_Viewer)& theViewer,
-                             V3d_TypeOfView theType)
-    : QWidget(theParent),
-      myPaintersRedrawing(false),
-      myScale(1.0),
-      myIsAdvancedZoomingEnabled(false),
-      myBgImgHeight(0),
-      myBgImgWidth(0)
-{
-  setMouseTracking(true);
-  setBackgroundRole(QPalette::NoRole);
-
-  // set focus policy to threat QContextMenuEvent from keyboard  
-  setFocusPolicy(Qt::StrongFocus);
-  setAttribute(Qt::WA_PaintOnScreen);
-  setAttribute(Qt::WA_NoSystemBackground);
-  setAutoFillBackground(false);
-
-  if (theType == V3d_ORTHOGRAPHIC) {
-    myOrthoView = new V3d_OrthographicView(theViewer);
-    myActiveView = myOrthoView;
-    myPerspView = 0;
-  } else {
-    myPerspView = new V3d_PerspectiveView(theViewer);
-    myActiveView = myPerspView;
-  }
-  myActiveView->SetSurfaceDetail(V3d_TEX_ALL);
-}
-
-//***********************************************
-XGUI_ViewPort::~XGUI_ViewPort()
-{
-}
-
-//***********************************************
-bool XGUI_ViewPort::mapView(const Handle(V3d_View)& theView)
-{
-  if (!setWindow(theView))
-    return false;
-
-  if (!mapped(theView)) {
-    theView->SetWindow(myWindow);
-    //if (theView != activeView())
-    //theView->View()->Deactivate();
-  }
-
-  /* create static trihedron (16551: EDF PAL 501) */
-  //OCCViewer_ViewWindow* aVW = dynamic_cast<OCCViewer_ViewWindow*>( parentWidget()->parentWidget()->parentWidget() );
-  //if ( aVW ) {
-  //    OCCViewer_Viewer* aViewModel = dynamic_cast<OCCViewer_Viewer*>( aVW->getViewManager()->getViewModel() );
-  //    if ( aViewModel && aViewModel->isStaticTrihedronDisplayed() ){
-  //theView->ZBufferTriedronSetup();
-  theView->TriedronDisplay(Aspect_TOTP_LEFT_LOWER, Quantity_NOC_WHITE, 0.05, V3d_ZBUFFER);
-  //    }
-  //}
-
-  emit(vpMapped());
-
-  return true;
-}
-
-//***********************************************
-bool XGUI_ViewPort::setWindow(const Handle(V3d_View)& theView)
-{
-  if (!myWindow.IsNull())
-    return true;
-
-  if (theView.IsNull())
-    return false;
-
-  attachWindow(theView, CreateCasWindow(theView, winId()));
-
-  myWindow = theView->Window();
-  return !myWindow.IsNull();
-}
-
-//***********************************************
-bool XGUI_ViewPort::mapped(const Handle(V3d_View)& theView) const
-{
-  return (!theView.IsNull() && theView->View()->IsDefined());
-}
-
-//***********************************************
-void XGUI_ViewPort::updateBackground()
-{
-  if (activeView().IsNull())
-    return;
-  if (!myBackground.isValid())
-    return;
-
-  // VSR: Important note on below code.
-  // In OCCT (in version 6.5.2), things about the background drawing
-  // are not straightforward and not clearly understandable:
-  // - Horizontal gradient is drawn vertically (!), well ok, from top side to bottom one.
-  // - Vertical gradient is drawn horizontally (!), from right side to left one (!!!).
-  // - First and second diagonal gradients are confused.
-  // - Image texture, once set, can not be removed (!).
-  // - Texture image fill mode Aspect_FM_NONE is not taken into account (and means the same
-  //   as Aspect_FM_CENTERED).
-  // - The only way to cancel gradient background (and get back to single colored) is to
-  //   set gradient background style to Aspect_GFM_NONE while passing two colors is also needed
-  //   (see V3d_View::SetBgGradientColors() function).
-  // - Also, it is impossible to draw texture image above the gradiented background (only above
-  //   single-colored).
-  // In OCCT 6.5.3 all above mentioned problems are fixed; so, above comment should be removed as soon
-  // as SALOME is migrated to OCCT 6.5.3. The same concerns #ifdef statements in the below code
-  switch (myBackground.mode()) {
-    case Qtx::ColorBackground: {
-      QColor c = myBackground.color();
-      if (c.isValid()) {
-        // Unset texture should be done here
-        // ...
-        Quantity_Color qCol(c.red() / 255., c.green() / 255., c.blue() / 255., Quantity_TOC_RGB);
-        activeView()->SetBgGradientStyle(Aspect_GFM_NONE);  // cancel gradient background
-        activeView()->SetBgImageStyle(Aspect_FM_NONE);  // cancel texture background
-        // then change background color
-        activeView()->SetBackgroundColor(qCol);
-        // update viewer
-        activeView()->Update();
-      }
-      break;
-    }
-    case Qtx::SimpleGradientBackground: {
-      QColor c1, c2;
-      int type = myBackground.gradient(c1, c2);
-      if (c1.isValid() && type >= XGUI::HorizontalGradient && type <= XGUI::LastGradient) {
-        // Unset texture should be done here
-        // ...
-        // Get colors and set-up gradiented background
-        if (!c2.isValid())
-          c2 = c1;
-        Quantity_Color qCol1(c1.red() / 255., c1.green() / 255., c1.blue() / 255.,
-                             Quantity_TOC_RGB);
-        Quantity_Color qCol2(c2.red() / 255., c2.green() / 255., c2.blue() / 255.,
-                             Quantity_TOC_RGB);
-        activeView()->SetBgImageStyle(Aspect_FM_NONE);  // cancel texture background
-        switch (type) {
-          case XGUI::HorizontalGradient:
-            activeView()->SetBgGradientColors(qCol1, qCol2, Aspect_GFM_HOR,
-            Standard_True);
-            break;
-          case XGUI::VerticalGradient:
-            activeView()->SetBgGradientColors(qCol1, qCol2, Aspect_GFM_VER,
-            Standard_True);
-            break;
-          case XGUI::Diagonal1Gradient:
-            activeView()->SetBgGradientColors(qCol1, qCol2, Aspect_GFM_DIAG1,
-            Standard_True);
-            break;
-          case XGUI::Diagonal2Gradient:
-            activeView()->SetBgGradientColors(qCol1, qCol2, Aspect_GFM_DIAG2,
-            Standard_True);
-            break;
-          case XGUI::Corner1Gradient:
-            activeView()->SetBgGradientColors(qCol1, qCol2, Aspect_GFM_CORNER1,
-            Standard_True);
-            break;
-          case XGUI::Corner2Gradient:
-            activeView()->SetBgGradientColors(qCol1, qCol2, Aspect_GFM_CORNER2,
-            Standard_True);
-            break;
-          case XGUI::Corner3Gradient:
-            activeView()->SetBgGradientColors(qCol1, qCol2, Aspect_GFM_CORNER3,
-            Standard_True);
-            break;
-          case XGUI::Corner4Gradient:
-            activeView()->SetBgGradientColors(qCol1, qCol2, Aspect_GFM_CORNER4,
-            Standard_True);
-            break;
-          default:
-            break;
-        }
-      }
-      break;
-    }
-    case Qtx::CustomGradientBackground:
-      // NOT IMPLEMENTED YET
-      break;
-    default:
-      break;
-  }
-  // VSR: In OCCT before v6.5.3 below code can't be used because of very ugly bug - it has been impossible to
-  // clear the background texture image as soon as it was once set to the viewer.
-  if (myBackground.isTextureShown()) {
-    QString fileName;
-    int textureMode = myBackground.texture(fileName);
-    QFileInfo fi(fileName);
-    if (!fileName.isEmpty() && fi.exists()) {
-      // set texture image: file name and fill mode
-      switch (textureMode) {
-        case XGUI::CenterTexture:
-          activeView()->SetBackgroundImage(fi.absoluteFilePath().toLatin1().constData(),
-                                           Aspect_FM_CENTERED);
-          break;
-        case XGUI::TileTexture:
-          activeView()->SetBackgroundImage(fi.absoluteFilePath().toLatin1().constData(),
-                                           Aspect_FM_TILED);
-          break;
-        case XGUI::StretchTexture:
-          activeView()->SetBackgroundImage(fi.absoluteFilePath().toLatin1().constData(),
-                                           Aspect_FM_STRETCH);
-          break;
-        default:
-          break;
-      }
-      activeView()->Update();
-    }
-  }
-}
-
-//***********************************************
-void XGUI_ViewPort::attachWindow(const Handle(V3d_View)& theView,
-                                 const Handle(Aspect_Window)& theWnd)
-{
-  if (!theView.IsNull()) {
-    theView->SetWindow(theWnd);
-    updateBackground();
-  }
-}
-
-//***********************************************
-void XGUI_ViewPort::paintEvent(QPaintEvent* theEvent)
-{
-#ifndef WIN32
-  /* X11 : map before show doesn't work */
-  if ( !mapped( activeView() ) )
-  mapView( activeView() );
-#endif
-  if (!myWindow.IsNull()) {
-    QApplication::syncX();
-    QRect rc = theEvent->rect();
-    //if ( !myPaintersRedrawing ) {
-    //activeView()->Redraw();
-    activeView()->Redraw(rc.x(), rc.y(), rc.width(), rc.height());
-    emit vpUpdated();
-    //}
-  }
-  //if ( myPaintersRedrawing ) {
-  //    QPainter p( this );
-  //    //emit vpDrawExternal( &p );
-  //    myPaintersRedrawing = false;
-  //}
-}
-
-//***********************************************
-void XGUI_ViewPort::resizeEvent(QResizeEvent* theEvent)
-{
-#ifdef WIN32
-  /* Win32 : map before first show to avoid flicker */
-  if (!mapped(activeView()))
-    mapView(activeView());
-#endif
-  QApplication::syncX();
-  if (!activeView().IsNull()) {
-    activeView()->MustBeResized();
-  }
-  emit resized();
-}
-
-//***********************************************
-QImage XGUI_ViewPort::dumpView(unsigned char*& theData, QRect theRect, bool toUpdate)
-{
-  Handle(V3d_View) view = getView();
-  if (view.IsNull())
-    return QImage();
-
-  int aWidth;
-  int aHeight;
-  if (theRect.isNull()) {
-    aWidth = width();
-    aHeight = height();
-  } else {
-    aWidth = theRect.width();
-    aHeight = theRect.height();
-  }
-  QApplication::syncX();
-
-  theData = new unsigned char[aWidth * aHeight * 4];
-
-  QPoint p;
-  if (theRect.isNull()) {
-    if (toUpdate)
-      view->Redraw();
-    p = mapFromParent(geometry().topLeft());
-  } else {
-    if (toUpdate)
-      view->Redraw(theRect.x(), theRect.y(), theRect.width(), theRect.height());
-    p = theRect.topLeft();
-  }
-  glReadPixels(p.x(), p.y(), aWidth, aHeight, GL_RGBA, GL_UNSIGNED_BYTE, theData);
-
-  QImage anImage(theData, aWidth, aHeight, QImage::Format_ARGB32);
-  anImage = anImage.mirrored();
-  anImage = anImage.rgbSwapped();
-  return anImage;
-}
-
-/*!
- Inits 'rotation' transformation.
- */
-void XGUI_ViewPort::startRotation(int x, int y, int theRotationPointType,
-                                  const gp_Pnt& theSelectedPoint)
-{
-  if (!activeView().IsNull()) {
-    switch (theRotationPointType) {
-      case XGUI::GRAVITY:
-        activeView()->StartRotation(x, y, 0.45);
-        break;
-      case XGUI::SELECTED:
-        sx = x;
-        sy = y;
-
-        double X, Y;
-        activeView()->Size(X, Y);
-        rx = Standard_Real(activeView()->Convert(X));
-        ry = Standard_Real(activeView()->Convert(Y));
-
-        activeView()->Rotate(0., 0., 0., theSelectedPoint.X(), theSelectedPoint.Y(),
-                             theSelectedPoint.Z(),
-                             Standard_True);
-
-        Quantity_Ratio zRotationThreshold;
-        zRotation = Standard_False;
-        zRotationThreshold = 0.45;
-        if (zRotationThreshold > 0.) {
-          Standard_Real dx = Abs(sx - rx / 2.);
-          Standard_Real dy = Abs(sy - ry / 2.);
-          Standard_Real dd = zRotationThreshold * (rx + ry) / 2.;
-          if (dx > dd || dy > dd)
-            zRotation = Standard_True;
-        }
-        break;
-      default:
-        break;
-    }
-    activeView()->DepthFitAll();
-  }
-}
-
-/*!
- Rotates the viewport. 
- */
-void XGUI_ViewPort::rotate(int x, int y, int theRotationPointType, const gp_Pnt& theSelectedPoint)
-{
-  if (!activeView().IsNull()) {
-    switch (theRotationPointType) {
-      case XGUI::GRAVITY:
-        activeView()->Rotation(x, y);
-        break;
-      case XGUI::SELECTED:
-        double dx, dy, dz;
-        if (zRotation) {
-          dz = atan2(Standard_Real(x) - rx / 2., ry / 2. - Standard_Real(y))
-              - atan2(sx - rx / 2., ry / 2. - sy);
-          dx = dy = 0.;
-        } else {
-          dx = (Standard_Real(x) - sx) * M_PI / rx;
-          dy = (sy - Standard_Real(y)) * M_PI / ry;
-          dz = 0.;
-        }
-
-        activeView()->Rotate(dx, dy, dz, theSelectedPoint.X(), theSelectedPoint.Y(),
-                             theSelectedPoint.Z(),
-                             Standard_False);
-        break;
-      default:
-        break;
-    }
-    emit vpTransformed();
-  }
-  //  setZSize( getZSize() );
-}
-
-/*!
- Resets the viewport after 'rotation'. 
- */
-void XGUI_ViewPort::endRotation()
-{
-  if (!activeView().IsNull()) {
-    activeView()->ZFitAll(1.);
-    activeView()->SetZSize(0.);
-    activeView()->Update();
-    emit vpTransformed();
-  }
-}
-
-/*!
- Inits 'zoom' transformation.
- */
-void XGUI_ViewPort::startZoomAtPoint(int x, int y)
-{
-  if (!activeView().IsNull()/* && isAdvancedZoomingEnabled() */)
-    activeView()->StartZoomAtPoint(x, y);
-}
-
-/*!
- Centers the viewport. 
- */
-void XGUI_ViewPort::setCenter(int x, int y)
-{
-  if (!activeView().IsNull()) {
-    activeView()->Place(x, y, myScale);
-    emit vpTransformed();
-  }
-}
-
-/*!
- Called at 'pan' transformation. 
- */
-void XGUI_ViewPort::pan(int dx, int dy)
-{
-  if (!activeView().IsNull()) {
-    activeView()->Pan(dx, dy, 1.0);
-    emit vpTransformed();
-  }
-}
-
-/*!
- Called at 'window fit' transformation.
- */
-void XGUI_ViewPort::fitRect(const QRect& rect)
-{
-  if (!activeView().IsNull()) {
-    activeView()->WindowFit(rect.left(), rect.top(), rect.right(), rect.bottom());
-    emit vpTransformed();
-  }
-}
-
-/*!
- Called at 'zoom' transformation.
- */
-void XGUI_ViewPort::zoom(int x0, int y0, int x, int y)
-{
-  if (!activeView().IsNull()) {
-    if (isAdvancedZoomingEnabled())
-      activeView()->ZoomAtPoint(x0, y0, x, y);
-    else
-      activeView()->Zoom(x0 + y0, 0, x + y, 0);
-    emit vpTransformed();
-  }
-}
-
-/*!
- Sets the background data
- */
-void XGUI_ViewPort::setBackground(const Qtx::BackgroundData& bgData)
-{
-  if (bgData.isValid()) {
-    myBackground = bgData;
-    updateBackground();
-    emit vpChangeBackground(myBackground);
-  }
-}
-
-void XGUI_ViewPort::fitAll(bool theKeepScale, bool theWithZ, bool theUpd)
-{
-  if (activeView().IsNull())
-    return;
-
-  if (theKeepScale)
-    myScale = activeView()->Scale();
-
-  Standard_Real aMargin = 0.01;
-  activeView()->FitAll(aMargin, theWithZ, theUpd);
-  activeView()->SetZSize(0.);
-  emit vpTransformed();
-}
-
-void XGUI_ViewPort::syncronizeWith(const XGUI_ViewPort* ref)
-{
-  Handle(V3d_View) refView = ref->getView();
-  Handle(V3d_View) tgtView = getView();
-
-  /*  The following params are copied:
-   - view type( ortho/persp )
-   - position of view point
-   - orientation of high point
-   - position of the eye
-   - projection vector
-   - view center ( 2D )
-   - view twist
-   - view scale
-   */
-
-  /* we'll update after setting all params */
-  tgtView->SetImmediateUpdate( Standard_False);
-
-  /* perspective */
-  if (refView->Type() == V3d_PERSPECTIVE)
-    tgtView->SetFocale(refView->Focale());
-
-  /* copy params */
-  Standard_Real x, y, z;
-  refView->At(x, y, z);
-  tgtView->SetAt(x, y, z);
-  refView->Up(x, y, z);
-  tgtView->SetUp(x, y, z);
-  refView->Eye(x, y, z);
-  tgtView->SetEye(x, y, z);
-  refView->Proj(x, y, z);
-  tgtView->SetProj(x, y, z);
-  refView->Center(x, y);
-  tgtView->SetCenter(x, y);
-  tgtView->SetScale(refView->Scale());
-  tgtView->SetTwist(refView->Twist());
-
-  /* update */
-  tgtView->Update();
-  tgtView->SetImmediateUpdate( Standard_True);
-}
diff --git a/src/XGUI/XGUI_ViewPort.h b/src/XGUI/XGUI_ViewPort.h
deleted file mode 100644 (file)
index f22cc9d..0000000
+++ /dev/null
@@ -1,103 +0,0 @@
-#ifndef XGUI_ViewPort_H
-#define XGUI_ViewPort_H
-
-#include "XGUI.h"
-
-#include <Qtx.h>
-
-#include <QWidget>
-#include <V3d_Viewer.hxx>
-#include <V3d_View.hxx>
-#include <gp_Pnt.hxx>
-
-class XGUI_ViewWindow;
-
-class XGUI_EXPORT XGUI_ViewPort : public QWidget
-{
-Q_OBJECT
- public:
-  XGUI_ViewPort(XGUI_ViewWindow* theParent, const Handle(V3d_Viewer)& theViewer,
-                V3d_TypeOfView theType = V3d_ORTHOGRAPHIC);
-  virtual ~XGUI_ViewPort();
-
-  virtual QPaintEngine* paintEngine() const
-  {
-    return 0;
-  }
-
-  QImage dumpView(unsigned char*& theData, QRect theRect = QRect(), bool toUpdate = true);
-
-  Handle(V3d_View) getView() const
-  {
-    return activeView();
-  }
-
-  void startRotation(int x, int y, int theRotationPointType, const gp_Pnt& theSelectedPoint);
-  void rotate(int, int, int, const gp_Pnt&);
-  void endRotation();
-
-  // TRANSFORMATIONS
-  void pan(int dx, int dy);
-  void setCenter(int x, int y);
-  void fitRect(const QRect& rect);
-  void startZoomAtPoint(int x, int y);
-  void zoom(int x0, int y0, int x, int y);
-  void fitAll(bool theKeepScale = false, bool theWithZ = true, bool theUpd = true);
-
-  void setAdvancedZoomingEnabled(const bool theState)
-  {
-    myIsAdvancedZoomingEnabled = theState;
-  }
-  bool isAdvancedZoomingEnabled() const
-  {
-    return myIsAdvancedZoomingEnabled;
-  }
-
-  Qtx::BackgroundData background() const
-  {
-    return myBackground;
-  }
-
-  void setBackground(const Qtx::BackgroundData& bgData);
-
-  void syncronizeWith(const XGUI_ViewPort* ref);
-
-signals:
-  void vpChangeBackground(const Qtx::BackgroundData&);
-  void vpClosed();
-  void vpMapped();
-  void vpTransformed();
-  void vpUpdated();
-  void resized();
-
- protected:
-  virtual void paintEvent(QPaintEvent*);
-  virtual void resizeEvent(QResizeEvent*);
-
- private:
-  Handle(V3d_View) activeView() const
-  {
-    return myActiveView;
-  }
-
-  bool mapView(const Handle(V3d_View)& theView);
-  bool setWindow(const Handle(V3d_View)& theView);
-  bool mapped(const Handle(V3d_View)& theView) const;
-  void updateBackground();
-  void attachWindow(const Handle(V3d_View)& theView, const Handle(Aspect_Window)& theWnd);
-
-  Handle(V3d_View) myOrthoView;Handle(V3d_View) myPerspView;Handle(V3d_View) myActiveView;
-
-  Handle(Aspect_Window) myWindow;
-
-  bool myPaintersRedrawing;
-  bool myIsAdvancedZoomingEnabled;
-
-  double myScale;
-
-  Qtx::BackgroundData myBackground;
-  int myBgImgHeight;
-  int myBgImgWidth;
-};
-
-#endif
diff --git a/src/XGUI/XGUI_ViewWindow.cpp b/src/XGUI/XGUI_ViewWindow.cpp
deleted file mode 100644 (file)
index b07d467..0000000
+++ /dev/null
@@ -1,1217 +0,0 @@
-#include "XGUI_ViewWindow.h"
-#include "XGUI_ViewPort.h"
-#include "XGUI_Viewer.h"
-#include "XGUI_Tools.h"
-#include "XGUI_RubberBand.h"
-
-#include <QLayout>
-#include <QLabel>
-#include <QToolBar>
-#include <QAction>
-#include <QResizeEvent>
-#include <QApplication>
-#include <QMdiArea>
-#include <QMdiSubWindow>
-#include <QPainter>
-#include <QTimer>
-#include <QFileDialog>
-#include <QStyleOptionToolBar>
-
-#include <TopoDS_Shape.hxx>
-#include <BRep_Tool.hxx>
-#include <TopoDS.hxx>
-#include <Visual3d_View.hxx>
-
-#include <math.h>
-
-#define BORDER_SIZE 2
-
-const char* imageZoomCursor[] = { "32 32 3 1", ". c None", "a c #000000", "# c #ffffff",
-    "................................", "................................",
-    ".#######........................", "..aaaaaaa.......................",
-    "................................", ".............#####..............",
-    "...........##.aaaa##............", "..........#.aa.....a#...........",
-    ".........#.a.........#..........", ".........#a..........#a.........",
-    "........#.a...........#.........", "........#a............#a........",
-    "........#a............#a........", "........#a............#a........",
-    "........#a............#a........", ".........#...........#.a........",
-    ".........#a..........#a.........", ".........##.........#.a.........",
-    "........#####.....##.a..........", ".......###aaa#####.aa...........",
-    "......###aa...aaaaa.......#.....", ".....###aa................#a....",
-    "....###aa.................#a....", "...###aa...............#######..",
-    "....#aa.................aa#aaaa.", ".....a....................#a....",
-    "..........................#a....", "...........................a....",
-    "................................", "................................",
-    "................................", "................................" };
-
-const char* imageRotateCursor[] = { "32 32 3 1", ". c None", "a c #000000", "# c #ffffff",
-    "................................", "................................",
-    "................................", "................................",
-    "........#.......................", ".......#.a......................",
-    "......#######...................", ".......#aaaaa#####..............",
-    "........#..##.a#aa##........##..", ".........a#.aa..#..a#.....##.aa.",
-    ".........#.a.....#...#..##.aa...", ".........#a.......#..###.aa.....",
-    "........#.a.......#a..#aa.......", "........#a.........#..#a........",
-    "........#a.........#a.#a........", "........#a.........#a.#a........",
-    "........#a.........#a.#a........", ".........#.........#a#.a........",
-    "........##a........#a#a.........", "......##.a#.......#.#.a.........",
-    "....##.aa..##.....##.a..........", "..##.aa.....a#####.aa...........",
-    "...aa.........aaa#a.............", "................#.a.............",
-    "...............#.a..............", "..............#.a...............",
-    "...............a................", "................................",
-    "................................", "................................",
-    "................................", "................................" };
-
-const char* imageCrossCursor[] = { "32 32 3 1", ". c None", "a c #000000", "# c #ffffff",
-    "................................", "................................",
-    "................................", "................................",
-    "................................", "................................",
-    "................................", "...............#................",
-    "...............#a...............", "...............#a...............",
-    "...............#a...............", "...............#a...............",
-    "...............#a...............", "...............#a...............",
-    "...............#a...............", ".......#################........",
-    "........aaaaaaa#aaaaaaaaa.......", "...............#a...............",
-    "...............#a...............", "...............#a...............",
-    "...............#a...............", "...............#a...............",
-    "...............#a...............", "...............#a...............",
-    "................a...............", "................................",
-    "................................", "................................",
-    "................................", "................................",
-    "................................", "................................" };
-
-ViewerToolbar::ViewerToolbar(QWidget* theParent, XGUI_ViewPort* thePort)
-    : QToolBar(theParent),
-      myVPort(thePort),
-      myResize(false)
-{
-  connect(myVPort, SIGNAL(resized()), this, SLOT(onViewPortResized()));
-}
-
-void ViewerToolbar::paintEvent(QPaintEvent* theEvent)
-{
-  //QToolBar::paintEvent(theEvent);
-  // Paint background
-  QPainter aPainter(this);
-  QRect aRect = rect();
-  QRect aVPRect = myVPort->rect();
-  QPoint aGlobPnt = mapToGlobal(aRect.topLeft());
-  QPoint aPnt = myVPort->mapFromGlobal(aGlobPnt);
-
-  QRect aImgRect(
-      QRect(aPnt.x(), aPnt.y() + aVPRect.height() - aRect.height(), aRect.width(), aRect.height()));
-  unsigned char* aData = 0;
-  QImage aImg = myVPort->dumpView(aData, aImgRect, myResize);
-  if (!aImg.isNull())
-    aPainter.drawImage(aRect, aImg);
-  myResize = false;
-
-  // Paint foreground
-  QStyle *style = this->style();
-  QStyleOptionToolBar aOpt;
-  initStyleOption(&aOpt);
-
-  aOpt.rect = style->subElementRect(QStyle::SE_ToolBarHandle, &aOpt, this);
-  if (aOpt.rect.isValid())
-    style->drawPrimitive(QStyle::PE_IndicatorToolBarHandle, &aOpt, &aPainter, this);
-  if (aData)
-    delete aData;
-}
-
-//**************************************************************************
-ViewerLabel::ViewerLabel(QWidget* theParent, XGUI_ViewPort* thePort)
-    : QLabel(theParent),
-      myVPort(thePort),
-      myResize(false)
-{
-  connect(myVPort, SIGNAL(resized()), this, SLOT(onViewPortResized()));
-}
-
-void ViewerLabel::paintEvent(QPaintEvent* theEvent)
-{
-  QRect aRect = rect();
-  QRect aVPRect = myVPort->rect();
-  QPoint aGlobPnt = mapToGlobal(aRect.topLeft());
-  QPoint aPnt = myVPort->mapFromGlobal(aGlobPnt);
-
-  QRect aImgRect(
-      QRect(aPnt.x(), aPnt.y() + aVPRect.height() - aRect.height(), aRect.width(), aRect.height()));
-  unsigned char* aData = 0;
-  QImage aImg = myVPort->dumpView(aData, aImgRect, myResize);
-  if (!aImg.isNull())
-    QPainter(this).drawImage(aRect, aImg);
-  myResize = false;
-  QLabel::paintEvent(theEvent);
-  if (aData)
-    delete aData;
-}
-
-//**************************************************************************
-//**************************************************************************
-//**************************************************************************
-XGUI_ViewWindow::XGUI_ViewWindow(XGUI_Viewer* theViewer, V3d_TypeOfView theType)
-    : QFrame(),
-      myViewer(theViewer),
-      myMoving(false),
-      MinimizeIco(":pictures/wnd_minimize.png"),
-      MaximizeIco(":pictures/wnd_maximize.png"),
-      CloseIco(":pictures/wnd_close.png"),
-      RestoreIco(":pictures/wnd_restore.png"),
-      myInteractionStyle(XGUI::STANDARD),
-      myRectBand(0),
-      myIsKeyFree(false),
-      my2dMode(XGUI::No2dMode),
-      myCurrPointType(XGUI::GRAVITY),
-      myPrevPointType(XGUI::GRAVITY),
-      myRotationPointSelection(false),
-      myClosable(true),
-      myStartX(0),
-      myStartY(0),
-      myCurrX(0),
-      myCurrY(0),
-      myCurScale(0.0),
-      myCurSketch(0),
-      myDrawRect(false),
-      myEnableDrawMode(false),
-      myCursorIsHand(false),
-      myEventStarted(false),
-      myIsActive(false),
-      myLastState(WindowNormalState),
-      myOperation(NOTHING),
-      myGripWgt(0),
-      myPicture(0)
-{
-  mySelectedPoint = gp_Pnt(0., 0., 0.);
-  setFrameStyle(QFrame::Raised);
-  setFrameShape(QFrame::Panel);
-  setLineWidth(BORDER_SIZE);
-  setMouseTracking(true);
-
-  QVBoxLayout* aLay = new QVBoxLayout(this);
-  aLay->setContentsMargins(BORDER_SIZE, BORDER_SIZE, BORDER_SIZE, BORDER_SIZE);
-  myViewPort = new XGUI_ViewPort(this, myViewer->v3dViewer(), theType);
-  myViewPort->installEventFilter(this);
-  myViewPort->setCursor(Qt::ArrowCursor);
-  aLay->addWidget(myViewPort);
-
-  myPicture = new QLabel(this);
-  myPicture->setFrameStyle(QFrame::Sunken);
-  myPicture->setFrameShape(QFrame::Panel);
-  myPicture->setMouseTracking(true);
-  myPicture->installEventFilter(this);
-  aLay->addWidget(myPicture);
-  myPicture->hide();
-
-  QVBoxLayout* aVPLay = new QVBoxLayout(myViewPort);
-  aVPLay->setMargin(0);
-  aVPLay->setSpacing(0);
-  aVPLay->setContentsMargins(0, 0, 0, 0);
-
-  QHBoxLayout* aToolLay = new QHBoxLayout();
-  aToolLay->setMargin(0);
-  aToolLay->setSpacing(0);
-  aToolLay->setContentsMargins(0, 0, 0, 0);
-  aVPLay->addLayout(aToolLay);
-  aVPLay->addStretch();
-
-  myGripWgt = new ViewerLabel(this, myViewPort);
-  myGripWgt->setPixmap(QPixmap(":pictures/wnd_grip.png"));
-  myGripWgt->setMouseTracking(true);
-  myGripWgt->installEventFilter(this);
-  myGripWgt->setCursor(Qt::OpenHandCursor);
-  aToolLay->addWidget(myGripWgt);
-
-  // Create Viewer management buttons
-  myViewBar = new ViewerToolbar(this, myViewPort);
-  myViewBar->setCursor(Qt::PointingHandCursor);
-  aToolLay->addWidget(myViewBar);
-  aToolLay->addStretch();
-
-  QAction* aBtn;
-
-  // Dump view
-  aBtn = new QAction(QIcon(":pictures/occ_view_camera_dump.png"), tr("Dump view"), myViewBar);
-  connect(aBtn, SIGNAL(triggered()), SLOT(dumpView()));
-  myViewBar->addAction(aBtn);
-  // Fit all
-  aBtn = new QAction(QIcon(":pictures/occ_view_fitall.png"), tr("Fit all"), myViewBar);
-  connect(aBtn, SIGNAL(triggered()), SLOT(fitAll()));
-  myViewBar->addAction(aBtn);
-  // Fit area
-  aBtn = new QAction(QIcon(":pictures/occ_view_fitarea.png"), tr("Fit area"), myViewBar);
-  connect(aBtn, SIGNAL(triggered()), SLOT(activateWindowFit()));
-  myViewBar->addAction(aBtn);
-  // Zoom
-  aBtn = new QAction(QIcon(":pictures/occ_view_zoom.png"), tr("Zoom"), myViewBar);
-  connect(aBtn, SIGNAL(triggered()), SLOT(activateZoom()));
-  myViewBar->addAction(aBtn);
-  // Pan
-  aBtn = new QAction(QIcon(":pictures/occ_view_pan.png"), tr("Panning"), myViewBar);
-  connect(aBtn, SIGNAL(triggered()), SLOT(activatePanning()));
-  myViewBar->addAction(aBtn);
-  // Global Panning
-  aBtn = new QAction(QIcon(":pictures/occ_view_glpan.png"), tr("Global panning"), myViewBar);
-  connect(aBtn, SIGNAL(triggered()), SLOT(activateGlobalPanning()));
-  myViewBar->addAction(aBtn);
-  // Rotation
-  aBtn = new QAction(QIcon(":pictures/occ_view_rotate.png"), tr("Rotate"), myViewBar);
-  connect(aBtn, SIGNAL(triggered()), SLOT(activateRotation()));
-  myViewBar->addAction(aBtn);
-  // Reset
-  aBtn = new QAction(QIcon(":pictures/occ_view_reset.png"), tr("Reset"), myViewBar);
-  connect(aBtn, SIGNAL(triggered()), SLOT(reset()));
-  myViewBar->addAction(aBtn);
-  // Front view
-  aBtn = new QAction(QIcon(":pictures/occ_view_front.png"), tr("Front"), myViewBar);
-  connect(aBtn, SIGNAL(triggered()), SLOT(frontView()));
-  myViewBar->addAction(aBtn);
-  // Back view
-  aBtn = new QAction(QIcon(":pictures/occ_view_back.png"), tr("Back"), myViewBar);
-  connect(aBtn, SIGNAL(triggered()), SLOT(backView()));
-  myViewBar->addAction(aBtn);
-  // Top view
-  aBtn = new QAction(QIcon(":pictures/occ_view_top.png"), tr("Top"), myViewBar);
-  connect(aBtn, SIGNAL(triggered()), SLOT(topView()));
-  myViewBar->addAction(aBtn);
-  // Bottom view
-  aBtn = new QAction(QIcon(":pictures/occ_view_bottom.png"), tr("Bottom"), myViewBar);
-  connect(aBtn, SIGNAL(triggered()), SLOT(bottomView()));
-  myViewBar->addAction(aBtn);
-  // Left view
-  aBtn = new QAction(QIcon(":pictures/occ_view_left.png"), tr("Left"), myViewBar);
-  connect(aBtn, SIGNAL(triggered()), SLOT(leftView()));
-  myViewBar->addAction(aBtn);
-  // Right view
-  aBtn = new QAction(QIcon(":pictures/occ_view_right.png"), tr("Right"), myViewBar);
-  connect(aBtn, SIGNAL(triggered()), SLOT(rightView()));
-  myViewBar->addAction(aBtn);
-  // Clone view
-  aBtn = new QAction(QIcon(":pictures/occ_view_clone.png"), tr("Clone"), myViewBar);
-  connect(aBtn, SIGNAL(triggered()), SLOT(cloneView()));
-  myViewBar->addAction(aBtn);
-
-  // Create Window management buttons
-  myWindowBar = new ViewerToolbar(this, myViewPort);
-  myWindowBar->setCursor(Qt::PointingHandCursor);
-  aToolLay->addWidget(myWindowBar);
-
-  myMinimizeBtn = new QAction(myWindowBar);
-  myMinimizeBtn->setIcon(MinimizeIco);
-  myWindowBar->addAction(myMinimizeBtn);
-  connect(myMinimizeBtn, SIGNAL(triggered()), SLOT(onMinimize()));
-
-  myMaximizeBtn = new QAction(myWindowBar);
-  myMaximizeBtn->setIcon(MaximizeIco);
-  myWindowBar->addAction(myMaximizeBtn);
-  connect(myMaximizeBtn, SIGNAL(triggered()), SLOT(onMaximize()));
-
-  aBtn = new QAction(myWindowBar);
-  aBtn->setIcon(CloseIco);
-  myWindowBar->addAction(aBtn);
-  connect(aBtn, SIGNAL(triggered()), SLOT(onClose()));
-
-  //Support copy of background on updating of viewer
-  connect(myViewPort, SIGNAL(vpTransformed()), this, SLOT(updateToolBar()));
-  connect(myViewPort, SIGNAL(vpUpdated()), this, SLOT(updateToolBar()));
-  connect(this, SIGNAL(vpTransformationFinished(XGUI_ViewWindow::OperationType)), this,
-          SLOT(updateToolBar()));
-}
-
-//****************************************************************
-XGUI_ViewWindow::~XGUI_ViewWindow()
-{
-}
-
-//****************************************************************
-void XGUI_ViewWindow::showEvent(QShowEvent* theEvent)
-{
-  QFrame::showEvent(theEvent);
-  myWindowBar->setFixedSize(myWindowBar->sizeHint());
-}
-
-//****************************************************************
-void XGUI_ViewWindow::changeEvent(QEvent* theEvent)
-{
-
-  if (theEvent->type() == QEvent::WindowStateChange) {
-    if (isMinimized()) {
-      if (myPicture->isHidden()) {
-        myViewBar->hide();
-        myGripWgt->hide();
-        myWindowBar->hide();
-        myViewPort->hide();
-        myPicture->show();
-      }
-    } else {
-      if (myPicture->isVisible()) {
-        myPicture->hide();
-        myViewPort->show();
-      }
-      if (isMaximized()) {
-        myMinimizeBtn->setIcon(MinimizeIco);
-        myMaximizeBtn->setIcon(RestoreIco);
-      }
-      myViewBar->setVisible(myIsActive);
-      myWindowBar->setVisible(myIsActive);
-      myGripWgt->setVisible(myIsActive && (!isMaximized()));
-    }
-  } else
-    QWidget::changeEvent(theEvent);
-}
-
-//****************************************************************
-void XGUI_ViewWindow::windowActivated()
-{
-  if (!(isMinimized() || parentWidget()->isMinimized())) {
-    myIsActive = true;
-    if (isMaximized() || parentWidget()->isMaximized()) {
-      myMaximizeBtn->setIcon(RestoreIco);
-    } else {
-      myMaximizeBtn->setIcon(MaximizeIco);
-    }
-    myViewBar->show();
-    myWindowBar->show();
-    myGripWgt->setVisible(
-        !(isMaximized() || isMinimized() || parentWidget()->isMaximized()
-            || parentWidget()->isMinimized()));
-  } else
-    myIsActive = false;
-}
-
-//****************************************************************
-void XGUI_ViewWindow::windowDeactivated()
-{
-  myIsActive = false;
-  if (!(isMinimized() || parentWidget()->isMinimized())) {
-    if (isMaximized() || parentWidget()->isMaximized()) {
-      myMaximizeBtn->setIcon(RestoreIco);
-    } else {
-      myMaximizeBtn->setIcon(MaximizeIco);
-    }
-    myViewBar->hide();
-    myWindowBar->hide();
-    myGripWgt->hide();
-  }
-}
-
-//****************************************************************
-void XGUI_ViewWindow::onClose()
-{
-  if (parentWidget()) {
-    emit tryClosing(this);
-    if (closable()) {
-      emit closed(static_cast<QMdiSubWindow*>(parentWidget()));
-      parentWidget()->close();
-    }
-  }
-}
-
-//****************************************************************
-void XGUI_ViewWindow::onMinimize()
-{
-  unsigned char* aData = 0;
-  QPixmap aPMap = QPixmap::fromImage(myViewPort->dumpView(aData));
-  int aW = width();
-  int aH = height();
-  double aR = aW / 100.;
-  int aNewH = int(aH / aR);
-  myPicture->setPixmap(aPMap.scaled(100, aNewH));
-
-  myLastState =
-      (isMaximized() || parentWidget()->isMaximized()) ? MaximizedState : WindowNormalState;
-  showMinimized();
-  parentWidget()->showMinimized();
-  parentWidget()->setGeometry(parentWidget()->x(), parentWidget()->y(), 100, aNewH);
-  parentWidget()->lower();
-  windowDeactivated();
-  myViewer->onWindowMinimized((QMdiSubWindow*) parentWidget());
-  delete aData;
-}
-
-//****************************************************************
-void XGUI_ViewWindow::onMaximize()
-{
-  if (isMaximized() || parentWidget()->isMaximized()) {
-    myMaximizeBtn->setIcon(MaximizeIco);
-    myGripWgt->show();
-    showNormal();
-    parentWidget()->showNormal();
-  } else {
-    myMaximizeBtn->setIcon(RestoreIco);
-    myGripWgt->hide();
-    showMaximized();
-    parentWidget()->showMaximized();
-  }
-  parentWidget()->activateWindow();
-  myMinimizeBtn->setIcon(MinimizeIco);
-
-  //  In order to avoid frosen background in toolbars when it shown as a second view
-  QTimer::singleShot(50, parentWidget(), SLOT(setFocus()));
-}
-
-//****************************************************************
-bool XGUI_ViewWindow::processWindowControls(QObject *theObj, QEvent *theEvent)
-{
-  switch (theEvent->type()) {
-    case QEvent::MouseButtonPress: {
-      QMouseEvent* aEvent = static_cast<QMouseEvent*>(theEvent);
-      if ((aEvent->button() == Qt::LeftButton) && (!myMoving)) {
-        myMoving = true;
-        myMousePnt = aEvent->globalPos();
-        return true;
-      }
-    }
-      break;
-    case QEvent::MouseButtonRelease: {
-      QMouseEvent* aEvent = static_cast<QMouseEvent*>(theEvent);
-      if ((aEvent->button() == Qt::LeftButton) && myMoving) {
-        myMoving = false;
-        return true;
-      }
-    }
-      break;
-    case QEvent::MouseMove: {
-      QMouseEvent* aEvent = static_cast<QMouseEvent*>(theEvent);
-      if (myMoving) {
-        QMdiSubWindow* aParent = static_cast<QMdiSubWindow*>(parentWidget());
-        QMdiArea* aMDIArea = aParent->mdiArea();
-
-        QPoint aPnt = aEvent->globalPos();
-        QPoint aMDIPnt = aMDIArea->mapFromGlobal(aPnt);
-        if (aMDIArea->rect().contains(aMDIPnt)) {
-          int aX = aParent->x() + (aPnt.x() - myMousePnt.x());
-          int aY = aParent->y() + (aPnt.y() - myMousePnt.y());
-          aParent->move(aX, aY);
-          myMousePnt = aPnt;
-        }
-        return true;
-      }
-    }
-      break;
-    case QEvent::MouseButtonDblClick:
-      if (theObj == myPicture) {
-        myMoving = false;
-        if (myLastState == MaximizedState) {
-          showMaximized();
-        } else {
-          showNormal();
-        }
-        myViewer->onWindowActivated((QMdiSubWindow*) parentWidget());
-
-        //  In order to avoid frosen background in toolbars when it shown as a second view
-        QTimer::singleShot(20, parentWidget(), SLOT(setFocus()));
-
-        return true;
-      }
-  }
-  return false;
-}
-
-//****************************************************************
-bool XGUI_ViewWindow::processViewPort(QEvent *theEvent)
-{
-  switch (theEvent->type()) {
-    case QEvent::MouseButtonPress:
-      vpMousePressEvent((QMouseEvent*) theEvent);
-      return true;
-
-    case QEvent::MouseButtonRelease:
-      vpMouseReleaseEvent((QMouseEvent*) theEvent);
-      return true;
-
-    case QEvent::MouseMove:
-      vpMouseMoveEvent((QMouseEvent*) theEvent);
-      return true;
-
-    case QEvent::MouseButtonDblClick:
-      emit mouseDoubleClicked(this, (QMouseEvent*) theEvent);
-      return true;
-    case QEvent::Wheel: {
-      QWheelEvent* aEvent = (QWheelEvent*) theEvent;
-      myViewPort->startZoomAtPoint(aEvent->x(), aEvent->y());
-      double aDelta = (double) (aEvent->delta()) / (15 * 8);
-      int x = aEvent->x();
-      int y = aEvent->y();
-      int x1 = (int) (aEvent->x() + width() * aDelta / 100);
-      int y1 = (int) (aEvent->y() + height() * aDelta / 100);
-      myViewPort->zoom(x, y, x1, y1);
-    }
-      return true;
-  }
-  return false;
-}
-
-//****************************************************************
-bool XGUI_ViewWindow::eventFilter(QObject *theObj, QEvent *theEvent)
-{
-  if ((theObj == myGripWgt) || (theObj == myPicture)) {
-    if (processWindowControls(theObj, theEvent))
-      return true;
-  } else if (theObj == myViewPort) {
-    if (processViewPort(theEvent)) {
-      return true;
-    }
-    if (theEvent->type() == QEvent::KeyRelease) {
-      emit keyReleased(this, (QKeyEvent*) theEvent);
-      return true;
-    }
-  }
-  return QFrame::eventFilter(theObj, theEvent);
-}
-
-//****************************************************************
-XGUI_ViewWindow::OperationType XGUI_ViewWindow::getButtonState(
-    QMouseEvent* theEvent, XGUI::InteractionStyle theInteractionStyle)
-{
-  OperationType aOp = NOTHING;
-  XGUI::InteractionStyle aStyle = (XGUI::InteractionStyle) theInteractionStyle;
-  if ((theEvent->modifiers() == XGUI_Viewer::myStateMap[aStyle][XGUI::ZOOM])
-      && (theEvent->buttons() == XGUI_Viewer::myButtonMap[aStyle][XGUI::ZOOM]))
-    aOp = ZOOMVIEW;
-  else if ((theEvent->modifiers() == XGUI_Viewer::myStateMap[aStyle][XGUI::PAN])
-      && (theEvent->buttons() == XGUI_Viewer::myButtonMap[aStyle][XGUI::PAN]))
-    aOp = PANVIEW;
-  else if ((theEvent->modifiers() == XGUI_Viewer::myStateMap[aStyle][XGUI::ROTATE])
-      && (theEvent->buttons() == XGUI_Viewer::myButtonMap[aStyle][XGUI::ROTATE])
-      && (my2dMode == XGUI::No2dMode))
-    aOp = ROTATE;
-
-  return aOp;
-}
-
-//****************************************************************
-void XGUI_ViewWindow::vpMousePressEvent(QMouseEvent* theEvent)
-{
-  myStartX = theEvent->x();
-  myStartY = theEvent->y();
-  XGUI::InteractionStyle anInteractionStyle = interactionStyle();
-
-  // in "key free" interaction style zoom operation is activated by two buttons (simultaneously pressed),
-  // which are assigned for pan and rotate - these operations are activated immediately after pressing 
-  // of the first button, so it is necessary to switch to zoom when the second button is pressed
-  bool aSwitchToZoom = false;
-  if ((anInteractionStyle == XGUI::KEY_FREE) && (myOperation == PANVIEW || myOperation == ROTATE)) {
-    aSwitchToZoom = getButtonState(theEvent, anInteractionStyle) == ZOOMVIEW;
-  }
-
-  switch (myOperation) {
-    case WINDOWFIT:
-      if (theEvent->button() == Qt::LeftButton)
-        emit vpTransformationStarted(WINDOWFIT);
-      break;
-
-    case PANGLOBAL:
-      if (theEvent->button() == Qt::LeftButton)
-        emit vpTransformationStarted(PANGLOBAL);
-      break;
-
-    case ZOOMVIEW:
-      if (theEvent->button() == Qt::LeftButton) {
-        myViewPort->startZoomAtPoint(myStartX, myStartY);
-        emit vpTransformationStarted(ZOOMVIEW);
-      }
-      break;
-
-    case PANVIEW:
-      if (aSwitchToZoom) {
-        myViewPort->startZoomAtPoint(myStartX, myStartY);
-        activateZoom();
-      } else if (theEvent->button() == Qt::LeftButton)
-        emit vpTransformationStarted(PANVIEW);
-      break;
-
-    case ROTATE:
-      if (aSwitchToZoom) {
-        myViewPort->startZoomAtPoint(myStartX, myStartY);
-        activateZoom();
-      } else if (theEvent->button() == Qt::LeftButton) {
-        myViewPort->startRotation(myStartX, myStartY, myCurrPointType, mySelectedPoint);
-        emit vpTransformationStarted(ROTATE);
-      }
-      break;
-
-    default:
-      /*  Try to activate a transformation */
-      OperationType aState;
-      if (interactionStyle() == XGUI::STANDARD)
-        aState = getButtonState(theEvent, anInteractionStyle);
-      else {
-        aState = XGUI_ViewWindow::NOTHING;
-        myIsKeyFree = true;
-      }
-      switch (aState) {
-        case ZOOMVIEW:
-          myViewPort->startZoomAtPoint(myStartX, myStartY);
-          activateZoom();
-          break;
-        case PANVIEW:
-          activatePanning();
-          break;
-        case ROTATE:
-          activateRotation();
-          myViewPort->startRotation(myStartX, myStartY, myCurrPointType, mySelectedPoint);
-          break;
-        default:
-          if (myRotationPointSelection) {
-            if (theEvent->button() == Qt::LeftButton) {
-              Handle(AIS_InteractiveContext) ic = myViewer->AISContext();
-              ic->Select();
-              for (ic->InitSelected(); ic->MoreSelected(); ic->NextSelected()) {
-                TopoDS_Shape aShape = ic->SelectedShape();
-                if (!aShape.IsNull() && aShape.ShapeType() == TopAbs_VERTEX) {
-                  gp_Pnt aPnt = BRep_Tool::Pnt(TopoDS::Vertex(ic->SelectedShape()));
-                  /*if ( mySetRotationPointDlg ) {
-                   myRotationPointSelection = false;
-                   mySetRotationPointDlg->setCoords(aPnt.X(), aPnt.Y(), aPnt.Z());
-                   }*/
-                } else {
-                  myCurrPointType = myPrevPointType;
-                  break;
-                }
-              }
-              if (ic->NbSelected() == 0)
-                myCurrPointType = myPrevPointType;
-              //if ( mySetRotationPointDlg ) mySetRotationPointDlg->toggleChange();
-              ic->CloseAllContexts();
-              myOperation = NOTHING;
-              myViewPort->setCursor(myCursor);
-              myCursorIsHand = false;
-              myRotationPointSelection = false;
-            }
-          } else
-            emit mousePressed(this, theEvent);
-          break;
-      }
-      /* notify that we start a transformation */
-      if (transformRequested())
-        emit vpTransformationStarted(myOperation);
-  }
-  if (transformRequested())
-    setTransformInProcess(true);
-
-  /* we may need it for sketching... */
-  /*    if ( l_mbPressEvent )
-   delete l_mbPressEvent;
-   l_mbPressEvent = new QMouseEvent( *theEvent );*/
-}
-
-//****************************************************************
-void XGUI_ViewWindow::contextMenuEvent(QContextMenuEvent* theEvent)
-{
-  if (theEvent->modifiers() == Qt::NoModifier) {
-    // Temporary: has to be removed when viewer popup will be defined
-    //QFrame::contextMenuEvent(theEvent);
-    emit contextMenuRequested(theEvent);
-  }
-}
-
-//****************************************************************
-void XGUI_ViewWindow::vpMouseReleaseEvent(QMouseEvent* theEvent)
-{
-  switch (myOperation) {
-    case NOTHING: {
-      int prevState = myCurSketch;
-      /*            if(theEvent->button() == Qt::RightButton) {
-       QList<OCCViewer_ViewSketcher*>::Iterator it;
-       for ( it = mySketchers.begin(); it != mySketchers.end() && myCurSketch != -1; ++it ) {
-       OCCViewer_ViewSketcher* sk = (*it);
-       if( ( sk->sketchButton() & theEvent->button() ) && sk->sketchButton() == myCurSketch )
-       myCurSketch = -1;
-       }
-       }
-       */
-      emit mouseReleased(this, theEvent);
-    }
-      break;
-    case ROTATE:
-      myViewPort->endRotation();
-      resetState();
-      break;
-
-    case PANVIEW:
-    case ZOOMVIEW:
-      resetState();
-      break;
-
-    case PANGLOBAL:
-      if (theEvent->button() == Qt::LeftButton) {
-        myViewPort->setCenter(theEvent->x(), theEvent->y());
-        myViewPort->getView()->SetScale(myCurScale);
-        resetState();
-      }
-      break;
-
-    case WINDOWFIT:
-      if (theEvent->button() == Qt::LeftButton) {
-        myCurrX = theEvent->x();
-        myCurrY = theEvent->y();
-        drawRect();
-        QRect rect = XGUI_Tools::makeRect(myStartX, myStartY, myCurrX, myCurrY);
-        if (!rect.isEmpty())
-          myViewPort->fitRect(rect);
-        endDrawRect();
-        resetState();
-      }
-      break;
-  }
-
-  // NOTE: viewer 3D detects a rectangle of selection using this event
-  // so we must emit it BEFORE resetting the selection rectangle
-  if (theEvent->button() == Qt::LeftButton && myDrawRect) {
-    drawRect();
-    endDrawRect();
-    resetState();
-    myViewPort->update();
-  }
-  /*    if ( l_mbPressEvent ) {
-   delete l_mbPressEvent;
-   l_mbPressEvent = 0;
-   }*/
-}
-
-//****************************************************************
-void XGUI_ViewWindow::vpMouseMoveEvent(QMouseEvent* theEvent)
-{
-  if (myIsKeyFree && interactionStyle() == XGUI::KEY_FREE) {
-    myIsKeyFree = false;
-    switch (getButtonState(theEvent, interactionStyle())) {
-      case ZOOMVIEW:
-        myViewPort->startZoomAtPoint(myStartX, myStartY);
-        activateZoom();
-        break;
-      case PANVIEW:
-        activatePanning();
-        break;
-      case ROTATE:
-        activateRotation();
-        myViewPort->startRotation(myStartX, myStartY, myCurrPointType, mySelectedPoint);
-        break;
-      default:
-        break;
-    }
-  }
-
-  myCurrX = theEvent->x();
-  myCurrY = theEvent->y();
-  switch (myOperation) {
-    case ROTATE:
-      myViewPort->rotate(myCurrX, myCurrY, myCurrPointType, mySelectedPoint);
-      break;
-
-    case ZOOMVIEW:
-      myViewPort->zoom(myStartX, myStartY, myCurrX, myCurrY);
-      myStartX = myCurrX;
-      myStartY = myCurrY;
-      break;
-
-    case PANVIEW:
-      myViewPort->pan(myCurrX - myStartX, myStartY - myCurrY);
-      myStartX = myCurrX;
-      myStartY = myCurrY;
-      break;
-
-    case PANGLOBAL:
-      break;
-
-    default:
-      if (myRotationPointSelection /*|| isSketcherStyle()*/) {
-        emit mouseMoving(this, theEvent);
-      } else {
-        int aState = theEvent->modifiers();
-        int aButton = theEvent->buttons();
-        int anInteractionStyle = interactionStyle();
-        if (((anInteractionStyle == XGUI::STANDARD) && (aButton == Qt::LeftButton)
-            && (aState == Qt::NoModifier || Qt::ShiftModifier))
-            || ((anInteractionStyle == XGUI::KEY_FREE) && (aButton == Qt::LeftButton)
-                && (aState == Qt::ControlModifier
-                    || aState == (Qt::ControlModifier | Qt::ShiftModifier)))) {
-          myDrawRect = myEnableDrawMode;
-          if (myDrawRect) {
-            drawRect();
-            if (!myCursorIsHand) {   // we are going to sketch a rectangle
-              QCursor handCursor(Qt::PointingHandCursor);
-              myCursorIsHand = true;
-              myCursor = cursor();
-              myViewPort->setCursor(handCursor);
-            }
-          }
-          emit mouseMoving(this, theEvent);
-        } /* else if ( ( (anInteractionStyle == XGUI::STANDARD) &&
-         (aButton == Qt::RightButton) && 
-         ( aState == Qt::NoModifier || Qt::ShiftModifier ) ) ||
-         ( (anInteractionStyle == XGUI::KEY_FREE) &&
-         (aButton == Qt::RightButton) && 
-         ( aState == Qt::ControlModifier || aState == ( Qt::ControlModifier|Qt::ShiftModifier ) ) ) ) {
-         OCCViewer_ViewSketcher* sketcher = 0;
-         QList<OCCViewer_ViewSketcher*>::Iterator it;
-         for ( it = mySketchers.begin(); it != mySketchers.end() && !sketcher; ++it ) {
-         OCCViewer_ViewSketcher* sk = (*it);
-         if( sk->isDefault() && sk->sketchButton() == aButton )
-         sketcher = sk;
-         }
-         if ( sketcher && myCurSketch == -1 ) {
-         activateSketching( sketcher->type() );
-         if ( mypSketcher ) {
-         myCurSketch = mypSketcher->sketchButton();
-
-         if ( l_mbPressEvent )  {
-         QApplication::sendEvent( getViewPort(), l_mbPressEvent );
-         delete l_mbPressEvent;
-         l_mbPressEvent = 0;
-         }
-         QApplication::sendEvent( getViewPort(), theEvent );
-         }
-         }
-         } */else
-          emit mouseMoving(this, theEvent);
-      }
-  }
-}
-
-/*!
- \brief Draw rubber band rectangle.
- */
-void XGUI_ViewWindow::drawRect()
-{
-  if (!myRectBand) {
-    myRectBand = new XGUI_RectRubberBand(myViewPort);
-  }
-
-  myRectBand->setUpdatesEnabled(false);
-  QRect aRect = XGUI_Tools::makeRect(myStartX, myStartY, myCurrX, myCurrY);
-  myRectBand->initGeometry(aRect);
-
-  if (!myRectBand->isVisible())
-    myRectBand->show();
-
-  myRectBand->setUpdatesEnabled(true);
-}
-
-/*!
- \brief Clear rubber band rectangle on the end on the dragging operation.
- */
-void XGUI_ViewWindow::endDrawRect()
-{
-  if (myRectBand) {
-    myRectBand->clearGeometry();
-    myRectBand->hide();
-  }
-}
-
-void XGUI_ViewWindow::activateZoom()
-{
-  if (!transformRequested() && !myCursorIsHand)
-    myCursor = cursor(); /* save old cursor */
-
-  if (myOperation != ZOOMVIEW) {
-    QPixmap zoomPixmap(imageZoomCursor);
-    QCursor zoomCursor(zoomPixmap);
-    if (setTransformRequested(ZOOMVIEW))
-      myViewPort->setCursor(zoomCursor);
-  }
-}
-
-bool XGUI_ViewWindow::transformRequested() const
-{
-  return (myOperation != NOTHING);
-}
-
-/*!
- \brief Start delayed viewer operation.
- */
-bool XGUI_ViewWindow::setTransformRequested(OperationType op)
-{
-  bool ok = transformEnabled(op);
-  myOperation = ok ? op : NOTHING;
-  myViewPort->setMouseTracking(myOperation == NOTHING);
-  return ok;
-}
-
-/*!
- Set enabled state of transformation (rotate, zoom, etc)
- */
-void XGUI_ViewWindow::setTransformEnabled(const OperationType id, const bool on)
-{
-  if (id != NOTHING)
-    myStatus.insert(id, on);
-}
-
-/*!
- \return enabled state of transformation (rotate, zoom, etc)
- */
-bool XGUI_ViewWindow::transformEnabled(const OperationType id) const
-{
-  return myStatus.contains(id) ? myStatus[id] : true;
-}
-
-/*!
- \brief Start panning operation.
-
- Sets the corresponding cursor for the widget.
- */
-void XGUI_ViewWindow::activatePanning()
-{
-  if (!transformRequested() && !myCursorIsHand)
-    myCursor = cursor();                // save old cursor
-
-  if (myOperation != PANVIEW) {
-    QCursor panCursor(Qt::SizeAllCursor);
-    if (setTransformRequested(PANVIEW))
-      myViewPort->setCursor(panCursor);
-  }
-}
-
-/*!
- \brief Start global panning operation
-
- Sets the corresponding cursor for the widget.
- */
-void XGUI_ViewWindow::activateGlobalPanning()
-{
-  Handle(V3d_View) aView3d = myViewPort->getView();
-  if (!aView3d.IsNull()) {
-    QPixmap globalPanPixmap(imageCrossCursor);
-    QCursor glPanCursor(globalPanPixmap);
-    myCurScale = aView3d->Scale();
-    aView3d->FitAll(0.01, false);
-    myCursor = cursor();                // save old cursor
-    myViewPort->fitAll();  // fits view before selecting a new scene center
-    if (setTransformRequested(PANGLOBAL))
-      myViewPort->setCursor(glPanCursor);
-  }
-}
-
-/*!
- \brief Start rotation operation
-
- Sets the corresponding cursor for the widget.
- */
-void XGUI_ViewWindow::activateRotation()
-{
-  if (!transformRequested() && !myCursorIsHand)
-    myCursor = cursor();                // save old cursor
-
-  if (myOperation != ROTATE) {
-    QPixmap rotatePixmap(imageRotateCursor);
-    QCursor rotCursor(rotatePixmap);
-    if (setTransformRequested(ROTATE))
-      myViewPort->setCursor(rotCursor);
-  }
-}
-
-/*!
- \brief Reset the viewport to its initial state
- ( no transformations in process etc. )
- */
-void XGUI_ViewWindow::resetState()
-{
-  myDrawRect = false;
-
-  if (myRotationPointSelection) {
-    QCursor handCursor(Qt::PointingHandCursor);
-    myViewPort->setCursor(handCursor);
-  } else {
-    if (transformRequested() || myCursorIsHand)
-      myViewPort->setCursor(myCursor);
-    myCursorIsHand = false;
-  }
-
-  if (transformRequested())
-    emit vpTransformationFinished(myOperation);
-
-  setTransformInProcess(false);
-  setTransformRequested(NOTHING);
-}
-
-Qtx::BackgroundData XGUI_ViewWindow::background() const
-{
-  return myViewPort ? myViewPort->background() : Qtx::BackgroundData();
-}
-
-void XGUI_ViewWindow::setBackground(const Qtx::BackgroundData& theBackground)
-{
-  if (myViewPort)
-    myViewPort->setBackground(theBackground);
-}
-
-/*!
- \brief Create one more window with same content.
- */
-void XGUI_ViewWindow::cloneView()
-{
-  QMdiSubWindow* vw = myViewer->createView();
-  XGUI_ViewWindow* aNewWnd = static_cast<XGUI_ViewWindow*>(vw->widget());
-  aNewWnd->viewPort()->syncronizeWith(myViewPort);
-
-  emit viewCloned(vw);
-
-  //  In order to avoid frosen background in toolbars when it shown as a second view
-  QTimer::singleShot(20, vw, SLOT(setFocus()));
-}
-
-void XGUI_ViewWindow::dumpView()
-{
-  QString aFilter(tr("Images Files (*.bmp *.png *.jpg *.jpeg *.eps *.ps)"));
-  QString aSelectedFilter;
-  QString aFileName = QFileDialog::getSaveFileName(this, "Save picture", QString(), aFilter,
-                                                   &aSelectedFilter);
-  if (!aFileName.isNull()) {
-    QApplication::setOverrideCursor(Qt::WaitCursor);
-    unsigned char* aData = 0;
-    QImage aPicture = myViewPort->dumpView(aData);
-
-    QString aFmt = XGUI_Tools::extension(aFileName).toUpper();
-    if (aFmt.isEmpty())
-      aFmt = QString("BMP");  // default format
-    else if (aFmt == "JPG")
-      aFmt = "JPEG";
-
-    Handle(Visual3d_View) a3dView = myViewPort->getView()->View();
-    if (aFmt == "PS")
-#ifdef WIN32
-      a3dView->Export(_strdup(qPrintable(aFileName)), Graphic3d_EF_PostScript);
-#else
-      a3dView->Export(strdup(qPrintable(aFileName)), Graphic3d_EF_PostScript);
-#endif
-    else if (aFmt == "EPS")
-#ifdef WIN32
-      a3dView->Export(_strdup(qPrintable(aFileName)), Graphic3d_EF_EnhPostScript);
-#else
-      a3dView->Export(strdup(qPrintable(aFileName)), Graphic3d_EF_EnhPostScript);
-#endif
-    else
-      aPicture.save(aFileName, aFmt.toLatin1());
-    delete aData;
-    QApplication::restoreOverrideCursor();
-  }
-}
-
-void XGUI_ViewWindow::fitAll()
-{
-  emit vpTransformationStarted(FITALLVIEW);
-  myViewPort->fitAll();
-  emit vpTransformationFinished(FITALLVIEW);
-}
-
-/*!
- \brief Starts fit operation.
-
- Sets the corresponding cursor for the widget.
- */
-void XGUI_ViewWindow::activateWindowFit()
-{
-  if (!transformRequested() && !myCursorIsHand)
-    myCursor = cursor(); /* save old cursor */
-
-  if (myOperation != WINDOWFIT) {
-    QCursor handCursor(Qt::PointingHandCursor);
-    if (setTransformRequested(WINDOWFIT)) {
-      myViewPort->setCursor(handCursor);
-      myCursorIsHand = true;
-    }
-  }
-}
-
-/*!
- \brief Perform "front view" transformation.
- */
-void XGUI_ViewWindow::frontView()
-{
-  emit vpTransformationStarted(FRONTVIEW);
-  Handle(V3d_View) aView3d = myViewPort->getView();
-  if (!aView3d.IsNull())
-    aView3d->SetProj(V3d_Xpos);
-  myViewPort->fitAll();
-  emit vpTransformationFinished(FRONTVIEW);
-}
-
-/*!
- \brief Perform "back view" transformation.
- */
-void XGUI_ViewWindow::backView()
-{
-  emit vpTransformationStarted(BACKVIEW);
-  Handle(V3d_View) aView3d = myViewPort->getView();
-  if (!aView3d.IsNull())
-    aView3d->SetProj(V3d_Xneg);
-  myViewPort->fitAll();
-  emit vpTransformationFinished(BACKVIEW);
-}
-
-/*!
- \brief Perform "top view" transformation.
- */
-void XGUI_ViewWindow::topView()
-{
-  emit vpTransformationStarted(TOPVIEW);
-  Handle(V3d_View) aView3d = myViewPort->getView();
-  if (!aView3d.IsNull())
-    aView3d->SetProj(V3d_Zpos);
-  myViewPort->fitAll();
-  emit vpTransformationFinished(TOPVIEW);
-}
-
-/*!
- \brief Perform "bottom view" transformation.
- */
-void XGUI_ViewWindow::bottomView()
-{
-  emit vpTransformationStarted(BOTTOMVIEW);
-  Handle(V3d_View) aView3d = myViewPort->getView();
-  if (!aView3d.IsNull())
-    aView3d->SetProj(V3d_Zneg);
-  myViewPort->fitAll();
-  emit vpTransformationFinished(BOTTOMVIEW);
-}
-
-/*!
- \brief Perform "left view" transformation.
- */
-void XGUI_ViewWindow::leftView()
-{
-  emit vpTransformationStarted(LEFTVIEW);
-  Handle(V3d_View) aView3d = myViewPort->getView();
-  if (!aView3d.IsNull())
-    aView3d->SetProj(V3d_Yneg);
-  myViewPort->fitAll();
-  emit vpTransformationFinished(LEFTVIEW);
-}
-
-/*!
- \brief Perform "right view" transformation.
- */
-void XGUI_ViewWindow::rightView()
-{
-  emit vpTransformationStarted(RIGHTVIEW);
-  Handle(V3d_View) aView3d = myViewPort->getView();
-  if (!aView3d.IsNull())
-    aView3d->SetProj(V3d_Ypos);
-  myViewPort->fitAll();
-  emit vpTransformationFinished(RIGHTVIEW);
-}
-
-void XGUI_ViewWindow::reset()
-{
-  emit vpTransformationStarted(RESETVIEW);
-  bool upd = myViewPort->getView()->SetImmediateUpdate(false);
-  myViewPort->getView()->Reset(false);
-  myViewPort->fitAll(false, true, false);
-  myViewPort->getView()->SetImmediateUpdate(upd);
-  myViewPort->getView()->Update();
-  emit vpTransformationFinished(RESETVIEW);
-}
-
-void XGUI_ViewWindow::updateToolBar()
-{
-  myGripWgt->update();
-  myViewBar->update();
-  myWindowBar->update();
-}
-
-/*!
- \brief Update state of enable draw mode state.
- */
-void XGUI_ViewWindow::updateEnabledDrawMode()
-{
-  myEnableDrawMode = myViewer->isSelectionEnabled() && myViewer->isMultiSelectionEnabled();
-}
diff --git a/src/XGUI/XGUI_ViewWindow.h b/src/XGUI/XGUI_ViewWindow.h
deleted file mode 100644 (file)
index bd2aef2..0000000
+++ /dev/null
@@ -1,362 +0,0 @@
-#ifndef XGUI_ViewWindow_H
-#define XGUI_ViewWindow_H
-
-#include "XGUI.h"
-#include "XGUI_Constants.h"
-
-#include <Qtx.h>
-
-#include <QFrame>
-#include <QIcon>
-#include <QToolBar>
-#include <QLabel>
-#include <QMap>
-
-#include <V3d_View.hxx>
-#include <V3d_Viewer.hxx>
-
-class XGUI_ViewPort;
-class XGUI_Viewer;
-class ViewerToolbar;
-class ViewerLabel;
-class XGUI_RectRubberBand;
-class QMdiSubWindow;
-
-/*!
- \class XGUI_ViewWindow
- \ingroup GUI
- \brief Implements a one view window of 3d viewer object.
- It contains a view port object (drawing area) and toolbars for view camera and window management.
- Also it managements events in view port
- */
-class XGUI_EXPORT XGUI_ViewWindow : public QFrame
-{
-Q_OBJECT
- public:
-  //! Types of viewer operations
-  enum OperationType
-  {
-    NOTHING,
-    PANVIEW,
-    ZOOMVIEW,
-    ROTATE,
-    PANGLOBAL,
-    WINDOWFIT,
-    FITALLVIEW,
-    RESETVIEW,
-    FRONTVIEW,
-    BACKVIEW,
-    TOPVIEW,
-    BOTTOMVIEW,
-    LEFTVIEW,
-    RIGHTVIEW,
-    CLOCKWISEVIEW,
-    ANTICLOCKWISEVIEW
-  };
-
-  XGUI_ViewWindow(XGUI_Viewer* theViewer, V3d_TypeOfView theType);
-
-  virtual ~XGUI_ViewWindow();
-
-  //! Returns view port object
-  XGUI_ViewPort* viewPort() const
-  {
-    return myViewPort;
-  }
-
-  //! Retrurns current interaction style
-  XGUI::InteractionStyle interactionStyle() const
-  {
-    return myInteractionStyle;
-  }
-
-  //! Disable or enable given operation type
-  void setTransformEnabled(const OperationType, const bool);
-
-  //! Returns true if the given operation type is enabled
-  bool transformEnabled(const OperationType) const;
-
-  //! Returns View background object
-  Qtx::BackgroundData background() const;
-
-  //! Sets View background object
-  void setBackground(const Qtx::BackgroundData& theBackground);
-
-  //! Returns true if the current view window can be closed
-  bool closable() const
-  {
-    return myClosable;
-  }
-
-  //! Sets the current view window closable or not
-  void setClosable(const bool isClosable)
-  {
-    myClosable = isClosable;
-  }
-
-  //! Enable/Disable drawing of ribbon line
-  void enableDrawMode(bool toEnable)
-  {
-    myEnableDrawMode = toEnable;
-  }
-
-  //! Returns true if ribbon line drawing enabled
-  bool isDrawModeEnabled() const
-  {
-    return myEnableDrawMode;
-  }
-
-  //! Updates drawing mode in the view window
-  void updateEnabledDrawMode();
-
-signals:
-  //! Emited whien view transformation operation is started
-  void vpTransformationStarted(XGUI_ViewWindow::OperationType type);
-
-  //! Emited whien view transformation operation is finished
-  void vpTransformationFinished(XGUI_ViewWindow::OperationType type);
-
-  //void Show(QShowEvent *);
-  //void Hide(QHideEvent *);
-  //void maximized(XGUI_ViewWindow*, bool);
-  //void returnedTo3d();
-
-  //! Emited before the window closing
-  void tryClosing(XGUI_ViewWindow*);
-
-  //! Emited when window is closing
-  void closed(QMdiSubWindow*);
-
-  //! Emited on mouse press in view port
-  void mousePressed(XGUI_ViewWindow*, QMouseEvent*);
-
-  //! Emited on mouse release in view port
-  void mouseReleased(XGUI_ViewWindow*, QMouseEvent*);
-
-  //! Emited on mouse double click in view port
-  void mouseDoubleClicked(XGUI_ViewWindow*, QMouseEvent*);
-
-  //! Emited on mouse moving in view port
-  void mouseMoving(XGUI_ViewWindow*, QMouseEvent*);
-
-  //! Emited on key press in view port
-  void keyPressed(XGUI_ViewWindow*, QKeyEvent*);
-
-  //! Emited on key release in view port
-  void keyReleased(XGUI_ViewWindow*, QKeyEvent*);
-
-  //! Emited on context menu request in view port
-  void contextMenuRequested(QContextMenuEvent *e);
-
-  //void viewModified(XGUI_ViewWindow*);
-  void viewCloned(QMdiSubWindow* theView);
-
- public slots:
-  //! Start zooming operation
-  void activateZoom();
-
-  //! Start rotation operation
-  void activateRotation();
-
-  //! Start panning operation
-  void activatePanning();
-
-  //! Start window fit operation
-  void activateWindowFit();
-
-  //! Start global panning operation
-  void activateGlobalPanning();
-
-  //! Clone the view window preserving a view point of the current view
-  void cloneView();
-
-  //! Dump the view window into external file (*.bmp *.png *.jpg *.jpeg *.eps *.ps)
-  void dumpView();
-
-  //! Fit all command
-  void fitAll();
-
-  //! Set front view
-  void frontView();
-
-  //! Set back view
-  void backView();
-
-  //! Set top view
-  void topView();
-
-  //! Set bottom view
-  void bottomView();
-
-  //! Set left view
-  void leftView();
-
-  //! Set right view
-  void rightView();
-
-  //! Reset point of view
-  void reset();
-
-  void windowActivated();
-
-  void windowDeactivated();
-
- protected:
-  virtual void changeEvent(QEvent* theEvent);
-
-  virtual bool eventFilter(QObject *theObj, QEvent *theEvent);
-
-  virtual void showEvent(QShowEvent* theEvent);
-
-  virtual void contextMenuEvent(QContextMenuEvent* theEvent);
-
- private slots:
-  void onClose();
-  void onMinimize();
-  void onMaximize();
-
-  void updateToolBar();
-//  void repaintToolBar();
-
- private:
-  enum WindowState
-  {
-    MinimizedState,
-    MaximizedState,
-    WindowNormalState
-  };
-
-  bool processWindowControls(QObject *theObj, QEvent *theEvent);
-  bool processViewPort(QEvent *theEvent);
-
-  void vpMousePressEvent(QMouseEvent* theEvent);
-  void vpMouseReleaseEvent(QMouseEvent* theEvent);
-  void vpMouseMoveEvent(QMouseEvent* theEvent);
-
-  OperationType getButtonState(QMouseEvent* theEvent, XGUI::InteractionStyle theInteractionStyle);
-
-  void resetState();
-  void drawRect();
-  void endDrawRect();
-
-  bool transformRequested() const;
-  bool setTransformRequested(OperationType);
-
-  // Transformation is selected and already started
-  bool transformInProcess() const
-  {
-    return myEventStarted;
-  }
-  void setTransformInProcess(bool bOn)
-  {
-    myEventStarted = bOn;
-  }
-
- private:
-  XGUI_Viewer* myViewer;
-
-  QLabel* myPicture;
-  ViewerLabel* myGripWgt;
-  XGUI_ViewPort* myViewPort;
-  ViewerToolbar* myViewBar;
-  ViewerToolbar* myWindowBar;
-  QAction* myMinimizeBtn;
-  QAction* myMaximizeBtn;
-
-  QIcon MinimizeIco;
-  QIcon MaximizeIco;
-  QIcon CloseIco;
-  QIcon RestoreIco;
-
-  bool myMoving;
-  QPoint myMousePnt;
-
-  WindowState myLastState;
-
-  int myStartX;
-  int myStartY;
-  int myCurrX;
-  int myCurrY;
-
-  XGUI::InteractionStyle myInteractionStyle;
-  OperationType myOperation;
-  XGUI::Mode2dType my2dMode;
-
-  int myCurSketch;
-  bool myDrawRect;          // set when a rect is used for selection or magnify 
-  bool myEnableDrawMode;
-  bool myRotationPointSelection;
-  bool myCursorIsHand;
-  bool myIsKeyFree;
-  bool myEventStarted;       // set when transformation is in process 
-  bool myClosable;
-  bool myIsActive;
-
-  QCursor myCursor;
-
-  XGUI::RotationPointType myCurrPointType;
-  XGUI::RotationPointType myPrevPointType;
-
-  gp_Pnt mySelectedPoint;
-
-  XGUI_RectRubberBand* myRectBand;  //!< selection rectangle rubber band
-
-  typedef QMap<OperationType, bool> MapOfTransformStatus;
-  MapOfTransformStatus myStatus;
-
-  double myCurScale;
-};
-
-//******************************************************
-/*!
- \class ViewerToolbar
- \ingroup GUI
- \brief Provides a toolbar widget with treansparent background over OCCT View window
- */
-class ViewerToolbar : public QToolBar
-{
-Q_OBJECT
- public:
-  ViewerToolbar(QWidget* theParent, XGUI_ViewPort* thePort);
-
- protected slots:
-  void onViewPortResized()
-  {
-    myResize = true;
-  }
-
- protected:
-  virtual void paintEvent(QPaintEvent* theEvent);
-
- private:
-  XGUI_ViewPort* myVPort;
-  bool myResize;
-};
-
-//******************************************************
-/*!
- \class ViewerToolbar
- \ingroup GUI
- \brief Provides a Label widget with treansparent background over OCCT View window
- */
-class ViewerLabel : public QLabel
-{
-Q_OBJECT
- public:
-  ViewerLabel(QWidget* theParent, XGUI_ViewPort* thePort);
-
- protected slots:
-  void onViewPortResized()
-  {
-    myResize = true;
-  }
-
- protected:
-  virtual void paintEvent(QPaintEvent* theEvent);
-
- private:
-  XGUI_ViewPort* myVPort;
-  bool myResize;
-};
-
-#endif
diff --git a/src/XGUI/XGUI_Viewer.cpp b/src/XGUI/XGUI_Viewer.cpp
deleted file mode 100644 (file)
index 47100f7..0000000
+++ /dev/null
@@ -1,652 +0,0 @@
-#include "XGUI_Viewer.h"
-#include "XGUI_MainWindow.h"
-#include "XGUI_ViewWindow.h"
-#include "XGUI_ViewPort.h"
-#include "XGUI_Preferences.h"
-
-#include <SUIT_ResourceMgr.h>
-
-#include <QMdiArea>
-#include <QMdiSubWindow>
-#include <QApplication>
-#include <QMouseEvent>
-#include <QMenu>
-
-#include <V3d_View.hxx>
-
-#include <Aspect_DisplayConnection.hxx>
-#include <Graphic3d.hxx>
-#include <Graphic3d_GraphicDriver.hxx>
-#include <Geom_Axis2Placement.hxx>
-#include <AIS_Drawer.hxx>
-#include <Prs3d_DatumAspect.hxx>
-#include <Prs3d_LineAspect.hxx>
-#include <V3d_View.hxx>
-#include <Visual3d_View.hxx>
-#include <AIS_ListOfInteractive.hxx>
-#include <AIS_ListIteratorOfListOfInteractive.hxx>
-#include <AIS_Shape.hxx>
-
-#ifdef WIN32
-#include <WNT_Window.hxx>
-#else
-#include <Xw_Window.hxx>
-#endif
-
-XGUI_Viewer::InteractionStyle2StatesMap XGUI_Viewer::myStateMap;
-XGUI_Viewer::InteractionStyle2ButtonsMap XGUI_Viewer::myButtonMap;
-static bool isInitialized = false;
-
-/*!
- Creates viewer 3d [ static ]
- */
-Handle(V3d_Viewer) CreateViewer(const Standard_ExtString name, const Standard_CString displayName,
-                                const Standard_CString domain, const Standard_Real viewSize,
-                                const V3d_TypeOfOrientation viewProjection,
-                                const Standard_Boolean computedMode,
-                                const Standard_Boolean defaultComputedMode)
-{
-  static Handle(Graphic3d_GraphicDriver) aGraphicDriver;
-  if (aGraphicDriver.IsNull()) {
-    Handle(Aspect_DisplayConnection) aDisplayConnection;
-#ifndef WIN32
-    aDisplayConnection = new Aspect_DisplayConnection( displayName );
-#else
-    aDisplayConnection = new Aspect_DisplayConnection();
-#endif
-    aGraphicDriver = Graphic3d::InitGraphicDriver(aDisplayConnection);
-  }
-
-  return new V3d_Viewer(aGraphicDriver, name, domain, viewSize, viewProjection, Quantity_NOC_GRAY30,
-                        V3d_ZBUFFER, V3d_GOURAUD, V3d_WAIT, computedMode, defaultComputedMode,
-                        V3d_TEX_NONE);
-}
-
-// VSR: Uncomment below line to allow texture background support in OCC viewer
-#define OCC_ENABLE_TEXTURED_BACKGROUND
-
-/*!
- Get data for supported background modes: gradient types, identifiers and supported image formats
- */
-QString XGUI_Viewer::backgroundData(QStringList& gradList, QIntList& idList, QIntList& txtList)
-{
-  gradList << tr("Horizontal gradient") << tr("Vertical gradient") << tr("First diagonal gradient")
-           << tr("Second diagonal gradient") << tr("First corner gradient")
-           << tr("Second corner gradient") << tr("Third corner gradient")
-           << tr("Fourth corner gradient");
-  idList << XGUI::HorizontalGradient << XGUI::VerticalGradient << XGUI::Diagonal1Gradient
-         << XGUI::Diagonal2Gradient << XGUI::Corner1Gradient << XGUI::Corner2Gradient
-         << XGUI::Corner3Gradient << XGUI::Corner4Gradient;
-#ifdef OCC_ENABLE_TEXTURED_BACKGROUND
-  txtList << XGUI::CenterTexture << XGUI::TileTexture << XGUI::StretchTexture;
-#endif
-  return tr("Image files (*.bmp *.gif *.pix *.xwd *.rgb *.rs)");
-}
-
-XGUI_Viewer::XGUI_Viewer(XGUI_MainWindow* theParent, bool DisplayTrihedron)
-    : QObject(theParent),
-      myMainWindow(theParent),
-      myPreselectionEnabled(true),
-      mySelectionEnabled(true),
-      myMultiSelectionEnabled(true),
-      myIsRelative(true),
-      myInteractionStyle(XGUI::STANDARD),
-      myTrihedronSize(100),
-      myActiveView(0),
-      myWndIdCount(0)
-{
-  if (!isInitialized) {
-    isInitialized = true;
-
-    // standard interaction style
-    XGUI_Viewer::myStateMap[XGUI::STANDARD][XGUI::ZOOM] = Qt::ControlModifier;
-    XGUI_Viewer::myButtonMap[XGUI::STANDARD][XGUI::ZOOM] = Qt::LeftButton;
-
-    XGUI_Viewer::myStateMap[XGUI::STANDARD][XGUI::PAN] = Qt::ControlModifier;
-    XGUI_Viewer::myButtonMap[XGUI::STANDARD][XGUI::PAN] = Qt::MidButton;
-
-    XGUI_Viewer::myStateMap[XGUI::STANDARD][XGUI::ROTATE] = Qt::ControlModifier;
-    XGUI_Viewer::myButtonMap[XGUI::STANDARD][XGUI::ROTATE] = Qt::RightButton;
-
-    XGUI_Viewer::myStateMap[XGUI::STANDARD][XGUI::FIT_AREA] = Qt::ControlModifier;
-    XGUI_Viewer::myButtonMap[XGUI::STANDARD][XGUI::FIT_AREA] = Qt::RightButton;
-
-    // "key free" interaction style
-    XGUI_Viewer::myStateMap[XGUI::KEY_FREE][XGUI::ZOOM] = Qt::NoModifier;
-    XGUI_Viewer::myButtonMap[XGUI::KEY_FREE][XGUI::ZOOM] = Qt::RightButton;
-
-    XGUI_Viewer::myStateMap[XGUI::KEY_FREE][XGUI::PAN] = Qt::NoModifier;
-    XGUI_Viewer::myButtonMap[XGUI::KEY_FREE][XGUI::PAN] = Qt::MidButton;
-
-    XGUI_Viewer::myStateMap[XGUI::KEY_FREE][XGUI::ROTATE] = Qt::NoModifier;
-    XGUI_Viewer::myButtonMap[XGUI::KEY_FREE][XGUI::ROTATE] = Qt::LeftButton;
-
-    XGUI_Viewer::myStateMap[XGUI::KEY_FREE][XGUI::FIT_AREA] = Qt::NoModifier;  // unused
-    XGUI_Viewer::myButtonMap[XGUI::KEY_FREE][XGUI::FIT_AREA] = Qt::NoButton;  // unused
-  }
-
-  // init CasCade viewers
-  myV3dViewer = CreateViewer(TCollection_ExtendedString("Viewer3d").ToExtString(), "", "", 1000.0,
-                             V3d_XposYnegZpos, Standard_True, Standard_True);
-  myV3dViewer->SetDefaultLights();
-
-  // init selector
-  myAISContext = new AIS_InteractiveContext(myV3dViewer);
-  myAISContext->SelectionColor(Quantity_NOC_WHITE);
-
-  // display isoline on planar faces (box for ex.)
-  myAISContext->IsoOnPlane(true);
-
-  if (DisplayTrihedron) {
-    Handle(Geom_Axis2Placement) anAxis = new Geom_Axis2Placement(gp::XOY());
-    myTrihedron = new AIS_Trihedron(anAxis);
-    myTrihedron->SetInfiniteState( Standard_True);
-
-    Quantity_Color Col(193 / 255., 205 / 255., 193 / 255., Quantity_TOC_RGB);
-    myTrihedron->SetArrowColor(Col.Name());
-    myTrihedron->SetSize(myTrihedronSize);
-    Handle(AIS_Drawer) drawer = myTrihedron->Attributes();
-    if (drawer->HasDatumAspect()) {
-      Handle(Prs3d_DatumAspect) daspect = drawer->DatumAspect();
-      daspect->FirstAxisAspect()->SetColor(Quantity_Color(1.0, 0.0, 0.0, Quantity_TOC_RGB));
-      daspect->SecondAxisAspect()->SetColor(Quantity_Color(0.0, 1.0, 0.0, Quantity_TOC_RGB));
-      daspect->ThirdAxisAspect()->SetColor(Quantity_Color(0.0, 0.0, 1.0, Quantity_TOC_RGB));
-    }
-  }
-  // set zooming style to standard
-  //myZoomingStyle = 0;
-
-  QMdiArea* aMDI = myMainWindow->mdiArea();
-  connect(aMDI, SIGNAL(subWindowActivated(QMdiSubWindow*)), this,
-          SLOT(onWindowActivated(QMdiSubWindow*)));
-
-}
-
-XGUI_Viewer::~XGUI_Viewer(void)
-{
-  myAISContext.Nullify();
-  myV3dViewer.Nullify();
-}
-
-QMdiSubWindow* XGUI_Viewer::createView(V3d_TypeOfView theType)
-{
-  // create view frame
-  XGUI_ViewWindow* view = new XGUI_ViewWindow(this, theType);
-  // get main view window (created by view frame)
-  //OCCViewer_ViewWindow* vw = view->getView(OCCViewer_ViewFrame::MAIN_VIEW);
-  // initialize main view window
-  //initView( vw );
-  // set default background for view window
-  //vw->setBackground( background(0) ); // 0 means MAIN_VIEW (other views are not yet created here)
-  // connect signal from viewport
-  //connect(view->viewPort(), SIGNAL(vpClosed()), this, SLOT(onViewClosed()));
-  //connect(view->viewPort(), SIGNAL(vpMapped()), this, SLOT(onViewMapped()));
-  if (myViews.size() == 0)
-    setTrihedronShown(true);
-
-  Qtx::BackgroundData aBk = XGUI_Preferences::resourceMgr()->backgroundValue("Viewer",
-                                                                             "background");
-  view->setBackground(aBk);
-  view->updateEnabledDrawMode();
-
-  QMdiArea* aMDI = myMainWindow->mdiArea();
-  QMdiSubWindow* aWnd = aMDI->addSubWindow(view, Qt::FramelessWindowHint);
-  addView(aWnd);
-  aWnd->setGeometry(0, 0, aMDI->width() / 2, aMDI->height() / 2);
-  aWnd->show();
-  aWnd->setWindowTitle(QString("Viewer #%1").arg(++myWndIdCount));
-  emit viewCreated(view);
-  return aWnd;
-}
-
-void XGUI_Viewer::updateFromResources()
-{
-  Qtx::BackgroundData aBk = XGUI_Preferences::resourceMgr()->backgroundValue("Viewer",
-                                                                             "background");
-  foreach (QMdiSubWindow* aWnd, myViews)
-  {
-    XGUI_ViewWindow* aView = dynamic_cast<XGUI_ViewWindow*>(aWnd->widget());
-    if (aView)
-      aView->setBackground(aBk);
-  }
-}
-
-XGUI_ViewWindow* XGUI_Viewer::activeViewWindow() const
-{
-  if (myActiveView)
-    return dynamic_cast<XGUI_ViewWindow*>(myActiveView->widget());
-  return 0;
-}
-
-void XGUI_Viewer::getSelectedObjects(AIS_ListOfInteractive& theList)
-{
-  theList.Clear();
-  for (myAISContext->InitSelected(); myAISContext->MoreSelected(); myAISContext->NextSelected())
-    theList.Append(myAISContext->SelectedInteractive());
-}
-
-void XGUI_Viewer::getSelectedShapes(NCollection_List<TopoDS_Shape>& theList)
-{
-  Handle(AIS_InteractiveContext) ic = AISContext();
-
-  for (ic->InitSelected(); ic->MoreSelected(); ic->NextSelected()) {
-    TopoDS_Shape aShape = ic->SelectedShape();
-    if (!aShape.IsNull())
-      theList.Append(aShape);
-  }
-}
-
-void XGUI_Viewer::setObjectsSelected(const AIS_ListOfInteractive& theList)
-{
-  AIS_ListIteratorOfListOfInteractive aIt;
-  for (aIt.Initialize(theList); aIt.More(); aIt.Next())
-    myAISContext->AddOrRemoveSelected(aIt.Value(), false);
-  myAISContext->UpdateCurrentViewer();
-}
-
-/*! Sets hot button
- *\param theOper - hot operation
- *\param theState - adding state to state map operations.
- *\param theButton - adding state to button map operations.
- */
-void XGUI_Viewer::setHotButton(XGUI::InteractionStyle theInteractionStyle,
-                               XGUI::HotOperation theOper, Qt::KeyboardModifiers theState,
-                               Qt::MouseButtons theButton)
-{
-  myStateMap[theInteractionStyle][theOper] = theState;
-  myButtonMap[theInteractionStyle][theOper] = theButton;
-}
-
-/*! Gets hot button for operation \a theOper.
- *\param theOper - input hot operation
- *\param theState - output state from state map operations.
- *\param theButton - output state from button map operations.
- */
-void XGUI_Viewer::getHotButton(XGUI::InteractionStyle theInteractionStyle,
-                               XGUI::HotOperation theOper, Qt::KeyboardModifiers& theState,
-                               Qt::MouseButtons& theButton)
-{
-  theState = myStateMap[theInteractionStyle][theOper];
-  theButton = myButtonMap[theInteractionStyle][theOper];
-}
-
-/*!
- Changes visibility of trihedron to opposite
- */
-void XGUI_Viewer::toggleTrihedron()
-{
-  setTrihedronShown(!isTrihedronVisible());
-}
-
-/*!
- \return true if trihedron is visible
- */
-bool XGUI_Viewer::isTrihedronVisible() const
-{
-  return !myTrihedron.IsNull() && !myAISContext.IsNull() && myAISContext->IsDisplayed(myTrihedron);
-}
-
-/*!
- Sets visibility state of trihedron
- \param on - new state
- */
-
-void XGUI_Viewer::setTrihedronShown(bool on)
-{
-  if (myTrihedron.IsNull())
-    return;
-
-  if (on) {
-    myAISContext->Display(myTrihedron);
-    myAISContext->Deactivate(myTrihedron);
-  } else {
-    myAISContext->Erase(myTrihedron);
-  }
-}
-
-/*!
- \return trihedron size
- */
-double XGUI_Viewer::trihedronSize() const
-{
-  double sz = 0;
-  if (!myTrihedron.IsNull())
-    sz = myTrihedron->Size();
-  return sz;
-}
-
-/*!
- Changes trihedron size
- \param sz - new size
- */
-void XGUI_Viewer::setTrihedronSize(const double sz, bool isRelative)
-{
-  if (myTrihedronSize != sz || isRelative != myIsRelative) {
-    myTrihedronSize = sz;
-    myIsRelative = isRelative;
-    updateTrihedron();
-  }
-}
-
-/*! 
- * Update the size of the trihedron
- */
-void XGUI_Viewer::updateTrihedron()
-{
-  if (myTrihedron.IsNull())
-    return;
-
-  if (myIsRelative) {
-    double newSz, oldSz;
-
-    if (computeTrihedronSize(newSz, oldSz))
-      myTrihedron->SetSize(newSz);
-
-  } else if (myTrihedron->Size() != myTrihedronSize) {
-    myTrihedron->SetSize(myTrihedronSize);
-  }
-}
-
-/*!
- Get new and current trihedron size corresponding to the current model size
- */
-bool XGUI_Viewer::computeTrihedronSize(double& theNewSize, double& theSize)
-{
-  theNewSize = 100;
-  theSize = 100;
-
-  //SRN: BUG IPAL8996, a usage of method ActiveView without an initialization
-  Handle(V3d_Viewer) viewer = v3dViewer();
-  viewer->InitActiveViews();
-  if (!viewer->MoreActiveViews())
-    return false;
-
-  Handle(V3d_View) view3d = viewer->ActiveView();
-  //SRN: END of fix
-
-  if (view3d.IsNull())
-    return false;
-
-  double Xmin = 0, Ymin = 0, Zmin = 0, Xmax = 0, Ymax = 0, Zmax = 0;
-  double aMaxSide;
-
-  view3d->View()->MinMaxValues(Xmin, Ymin, Zmin, Xmax, Ymax, Zmax);
-
-  if (Xmin == RealFirst() || Ymin == RealFirst() || Zmin == RealFirst() || Xmax == RealLast()
-      || Ymax == RealLast() || Zmax == RealLast())
-    return false;
-
-  aMaxSide = Xmax - Xmin;
-  if (aMaxSide < Ymax - Ymin)
-    aMaxSide = Ymax - Ymin;
-  if (aMaxSide < Zmax - Zmin)
-    aMaxSide = Zmax - Zmin;
-
-  // IPAL21687
-  // The boundary box of the view may be initialized but nullified
-  // (case of infinite objects)
-  if (aMaxSide < Precision::Confusion())
-    return false;
-
-  static float EPS = (float) 5.0E-3;
-  theSize = trihedron()->Size();
-  //theNewSize = aMaxSide*aSizeInPercents / 100.0;
-
-  return fabs(theNewSize - theSize) > theSize * EPS || fabs(theNewSize - theSize) > theNewSize * EPS;
-}
-
-void XGUI_Viewer::onViewClosed(QMdiSubWindow* theView)
-{
-  if (!theView)
-    return;
-
-  emit deleteView(static_cast<XGUI_ViewWindow*>(theView->widget()));
-  removeView(theView);
-
-  // if this is last view
-  if (myViews.size() == 0) {
-    Standard_Integer aViewsNb = 0;
-    for (myV3dViewer->InitActiveViews(); myV3dViewer->MoreActiveViews();
-        myV3dViewer->NextActiveViews())
-      ++aViewsNb;
-    if (aViewsNb < 2) {
-      //clean up presentations before last view is closed
-      myAISContext->RemoveAll(Standard_False);
-    }
-  }
-}
-
-/*!Remove view window \a theView from view manager.
- *And close the last view, if it has \a theView.
- */
-void XGUI_Viewer::removeView(QMdiSubWindow* theView)
-{
-  XGUI_ViewWindow* aWindow = static_cast<XGUI_ViewWindow*>(theView->widget());
-
-  aWindow->disconnect(this);
-  myViews.removeAt(myViews.indexOf(theView));
-  if (myActiveView == theView)
-    myActiveView = 0;
-  if (myViews.size() == 0)
-    emit lastViewClosed();
-}
-
-/*void XGUI_Viewer::onViewMapped()
- {
- setTrihedronShown(true);
- }*/
-
-void XGUI_Viewer::addView(QMdiSubWindow* theView)
-{
-  XGUI_ViewWindow* aWindow = dynamic_cast<XGUI_ViewWindow*>(theView->widget());
-
-  connect(aWindow, SIGNAL(closed(QMdiSubWindow*)), this, SLOT(onViewClosed(QMdiSubWindow*)));
-
-  connect(aWindow, SIGNAL(tryClosing(XGUI_ViewWindow*)), this,
-          SIGNAL(tryCloseView(XGUI_ViewWindow*)));
-
-  connect(aWindow, SIGNAL(mousePressed(XGUI_ViewWindow*, QMouseEvent*)), this,
-          SLOT(onMousePressed(XGUI_ViewWindow*, QMouseEvent*)));
-
-  connect(aWindow, SIGNAL(mouseDoubleClicked(XGUI_ViewWindow*, QMouseEvent*)), this,
-          SIGNAL(mouseDoubleClick(XGUI_ViewWindow*, QMouseEvent*)));
-
-  connect(aWindow, SIGNAL(mouseMoving(XGUI_ViewWindow*, QMouseEvent*)), this,
-          SIGNAL(mouseMove(XGUI_ViewWindow*, QMouseEvent*)));
-
-  connect(aWindow, SIGNAL(keyPressed(XGUI_ViewWindow*, QKeyEvent*)), this,
-          SIGNAL(keyPress(XGUI_ViewWindow*, QKeyEvent*)));
-
-  connect(aWindow, SIGNAL(keyReleased(XGUI_ViewWindow*, QKeyEvent*)), this,
-          SLOT(onKeyRelease(XGUI_ViewWindow*, QKeyEvent*)));
-
-  //connect(aWindow, SIGNAL(contextMenuRequested( QContextMenuEvent* )),
-  //        this,    SLOT  (onContextMenuRequested( QContextMenuEvent* )));
-  connect(aWindow, SIGNAL(contextMenuRequested(QContextMenuEvent*)), this,
-          SIGNAL(contextMenuRequested(QContextMenuEvent*)));
-
-  connect(aWindow, SIGNAL(mouseMoving(XGUI_ViewWindow*, QMouseEvent*)), this,
-          SLOT(onMouseMove(XGUI_ViewWindow*, QMouseEvent*)));
-
-  connect(aWindow, SIGNAL(mouseReleased(XGUI_ViewWindow*, QMouseEvent*)), this,
-          SLOT(onMouseReleased(XGUI_ViewWindow*, QMouseEvent*)));
-
-  myViews.append(theView);
-}
-
-/*!
- Emit activated for view \a view.
- */
-void XGUI_Viewer::onWindowActivated(QMdiSubWindow* view)
-{
-  if (view && (view != myActiveView) && (!view->isMinimized())) {
-    myActiveView = view;
-    ((XGUI_ViewWindow*) myActiveView->widget())->windowActivated();
-    QList<QMdiSubWindow*>::iterator aIt;
-    for (aIt = myViews.begin(); aIt != myViews.end(); ++aIt) {
-      if ((*aIt) != myActiveView) {
-        ((XGUI_ViewWindow*) (*aIt)->widget())->windowDeactivated();
-      }
-    }
-  }
-}
-
-void XGUI_Viewer::onWindowMinimized(QMdiSubWindow* theWnd)
-{
-  if (myActiveView == theWnd) {
-    myActiveView = 0;
-    QList<QMdiSubWindow*>::iterator aIt;
-    for (aIt = myViews.begin(); aIt != myViews.end(); ++aIt) {
-      if (!(*aIt)->widget()->isMinimized()) {
-        (*aIt)->raise();
-        onWindowActivated(*aIt);
-        break;
-      }
-    }
-  }
-}
-
-/*!
- SLOT: called on mouse button press, stores current mouse position as start point for transformations
- */
-void XGUI_Viewer::onMousePressed(XGUI_ViewWindow* theWindow, QMouseEvent* theEvent)
-{
-  myStartPnt.setX(theEvent->x());
-  myStartPnt.setY(theEvent->y());
-  emit mousePress(theWindow, theEvent);
-}
-
-/*!
- SLOT: called on mouse move, processes hilighting
- */
-void XGUI_Viewer::onMouseMove(XGUI_ViewWindow* theWindow, QMouseEvent* theEvent)
-{
-  myCurPnt.setX(theEvent->x());
-  myCurPnt.setY(theEvent->y());
-  if (!mySelectionEnabled)
-    return;
-
-  Handle(V3d_View) aView3d = theWindow->viewPort()->getView();
-  if (!aView3d.IsNull()) {
-    myAISContext->MoveTo(theEvent->x(), theEvent->y(), aView3d);
-    if (myAISContext->HasDetected())
-      theWindow->viewPort()->setFocus(Qt::MouseFocusReason);
-  }
-}
-
-/*!
- SLOT: called on mouse button release, finishes selection
- */
-void XGUI_Viewer::onMouseReleased(XGUI_ViewWindow* theWindow, QMouseEvent* theEvent)
-{
-  if (!mySelectionEnabled || theEvent->button() != Qt::LeftButton) {
-    emit mouseRelease(theWindow, theEvent);
-    return;
-  }
-
-  myEndPnt.setX(theEvent->x());
-  myEndPnt.setY(theEvent->y());
-  bool aHasShift = (theEvent->modifiers() & Qt::ShiftModifier);
-
-  //if (!aHasShift) 
-  //  emit deselection();
-
-  if (myStartPnt == myEndPnt) {
-    // the MoveTo is necessary for the second click in the same point. Otherwise the selection is lost.
-    //Handle(V3d_View) aView3d = theWindow->viewPort()->getView();
-    //if (!aView3d.IsNull()) {
-    //  myAISContext->MoveTo(theEvent->x(), theEvent->y(), aView3d);
-    //}
-    if (aHasShift && myMultiSelectionEnabled)
-      myAISContext->ShiftSelect();
-    else
-      myAISContext->Select();
-  } else {
-    if (aHasShift && myMultiSelectionEnabled)
-      myAISContext->ShiftSelect(myStartPnt.x(), myStartPnt.y(), myEndPnt.x(), myEndPnt.y(),
-                                theWindow->viewPort()->getView(), false);
-    else
-      myAISContext->Select(myStartPnt.x(), myStartPnt.y(), myEndPnt.x(), myEndPnt.y(),
-                           theWindow->viewPort()->getView(), false);
-
-    int Nb = myAISContext->NbSelected();
-    if (Nb > 1 && !myMultiSelectionEnabled) {
-      myAISContext->InitSelected();
-      Handle( SelectMgr_EntityOwner ) anOwner = myAISContext->SelectedOwner();
-      if (!anOwner.IsNull()) {
-        myAISContext->ClearSelected( Standard_False);
-        myAISContext->AddOrRemoveSelected(anOwner, Standard_False);
-      }
-    }
-
-    myAISContext->UpdateCurrentViewer();
-  }
-  emit mouseRelease(theWindow, theEvent);
-  emit selectionChanged();
-}
-
-//******************************************************
-void XGUI_Viewer::setMultiSelectionEnabled(bool toEnable)
-{
-  myMultiSelectionEnabled = toEnable;
-  updateViewsDrawMode();
-}
-
-//******************************************************
-void XGUI_Viewer::setSelectionEnabled(bool toEnable)
-{
-  mySelectionEnabled = toEnable;
-  updateViewsDrawMode();
-}
-
-//******************************************************
-void XGUI_Viewer::updateViewsDrawMode() const
-{
-  foreach(QMdiSubWindow* aWnd, myViews)
-  {
-    XGUI_ViewWindow* aView = static_cast<XGUI_ViewWindow*>(aWnd->widget());
-    aView->updateEnabledDrawMode();
-  }
-}
-
-//******************************************************
-void XGUI_Viewer::onKeyRelease(XGUI_ViewWindow* theView, QKeyEvent* theKey)
-{
-  Handle(V3d_View) aView = theView->viewPort()->getView();
-  bool noModifiers = (theKey->modifiers() == Qt::NoModifier);
-  if ((theKey->key() == Qt::Key_N) && noModifiers) {
-    myAISContext->HilightNextDetected(aView);
-  } else if ((theKey->key() == Qt::Key_P) && noModifiers) {
-    myAISContext->HilightPreviousDetected(aView);
-  } else {
-    emit keyRelease(theView, theKey);
-  }
-}
-
-//******************************************************
-//void XGUI_Viewer::onContextMenuRequested(QContextMenuEvent* theEvent)
-//{
-//  XGUI_ViewWindow* aWnd = dynamic_cast<XGUI_ViewWindow*>(sender());
-//  if (!aWnd) return;
-//
-//  QMenu aMenu;
-//
-//  // Include Viewer actions
-//  if (myActions.size() > 0) {
-//    aMenu.addActions(myActions);
-//    aMenu.addSeparator();
-//  }
-//  if (aWnd->actions().size() > 0) {
-//    aMenu.addActions(aWnd->actions());
-//    aMenu.addSeparator();
-//  }
-//
-//  QMdiArea* aMDI = myMainWindow->mdiArea();
-//  if (aMenu.actions().size() > 0) {
-//    QMenu* aSubMenu = aMenu.addMenu(tr("Windows"));
-//    aSubMenu->addActions(aMDI->actions());
-//  } else {
-//    aMenu.addActions(aMDI->actions());
-//  }
-//  aMenu.exec(theEvent->globalPos());
-//}
diff --git a/src/XGUI/XGUI_Viewer.h b/src/XGUI/XGUI_Viewer.h
deleted file mode 100644 (file)
index 2cc4c02..0000000
+++ /dev/null
@@ -1,225 +0,0 @@
-#ifndef XGUI_Viewer_H
-#define XGUI_Viewer_H
-
-#include "XGUI.h"
-#include "XGUI_Constants.h"
-#include <ModuleBase_Definitions.h>
-
-#include <QObject>
-#include <QMap>
-#include <QList>
-#include <QPoint>
-#include <QAction>
-
-#include <V3d_Viewer.hxx>
-#include <AIS_InteractiveContext.hxx>
-#include <AIS_Trihedron.hxx>
-#include <NCollection_List.hxx>
-#include <TopoDS_Shape.hxx>
-
-class XGUI_MainWindow;
-class QMdiSubWindow;
-class XGUI_ViewWindow;
-class QMouseEvent;
-class QKeyEvent;
-
-class AIS_ListOfInteractive;
-
-/**\class XGUI_Viewer
- * \ingroup GUI
- * \brief Represents a 3d viewer. The viewer manages 3d scene and a set of view windows
- * when each of view window is a one point of view on this scene.
- */
-class XGUI_EXPORT XGUI_Viewer : public QObject
-{
-Q_OBJECT
- public:
-  static QString backgroundData(QStringList&, QIntList&, QIntList&);
-
-  XGUI_Viewer(XGUI_MainWindow* theParent, bool DisplayTrihedron = true);
-  ~XGUI_Viewer();
-
-  //! Creates a new view window
-  QMdiSubWindow* createView(V3d_TypeOfView theType = V3d_ORTHOGRAPHIC);
-
-  //! Return pointer on a main window - parent of the Viewer
-  XGUI_MainWindow* mainWindow() const
-  {
-    return myMainWindow;
-  }
-
-  //! Returns OCCT object which manages 3d scene
-  Handle(V3d_Viewer) v3dViewer() const
-  {
-    return myV3dViewer;
-  }
-
-  //! Returns OCCT object which manages displaying and selection in 3d scene
-  Handle(AIS_InteractiveContext) AISContext() const
-  {
-    return myAISContext;
-  }
-
-  //! Returns an active view window or NULL
-  XGUI_ViewWindow* activeViewWindow() const;
-
-  /// Return objects selected in 3D viewer
-  /// \param theList - list to be filled with selected objects
-  void getSelectedObjects(AIS_ListOfInteractive& theList);
-
-  /// Return shapes selected in 3D viewer
-  /// \param theList - list to be filled with selected shapes
-  void getSelectedShapes(NCollection_List<TopoDS_Shape>& theList);
-
-  /// Selects objects in 3D viewer. Other selected objects are left as selected
-  /// \param theList - list objects to be selected
-  void setObjectsSelected(const AIS_ListOfInteractive& theList);
-
-  /// Returns true if selection in the viewer is enabled
-  bool isSelectionEnabled() const
-  {
-    return mySelectionEnabled;
-  }
-
-  /// Enable or disable selectioon in the viewer
-  // \param toEnable - true or false (enable or disable selection)
-  void setSelectionEnabled(bool toEnable);
-
-  /// Returns true if multi-selection in the viewer is enabled
-  bool isMultiSelectionEnabled() const
-  {
-    return myMultiSelectionEnabled;
-  }
-
-  /// Enable or disable selectioon in the viewer
-  // \param toEnable - true or false (enable or disable selection)
-  void setMultiSelectionEnabled(bool toEnable);
-
-  /// Select the object in 3D viewer.
-  /// \param theIO - list objects to be selected
-  void setSelected(const Handle(AIS_InteractiveObject)& theIO)
-  {
-    myAISContext->SetSelected(theIO);
-  }
-
-  //! Trihedron 3d object shown in the viewer
-  Handle(AIS_Trihedron) trihedron() const
-  {
-    return myTrihedron;
-  }
-
-  //! On/Off visibility of the trihedron object
-  void toggleTrihedron();
-
-  //! Returns true if trihedron is visible
-  bool isTrihedronVisible() const;
-
-  //! Returns true if trihedron is visible
-  void setTrihedronShown(bool on);
-
-  //! Returns trihedron size
-  double trihedronSize() const;
-
-  //! Sets trihedron size
-  void setTrihedronSize(const double sz, bool isRelative);
-
-  bool trihedronRelative() const
-  {
-    return myIsRelative;
-  }
-  //! Update trihedron
-  void updateTrihedron();
-
-  //! Compute trihedron size dependent on 3d scene size
-  bool computeTrihedronSize(double& theNewSize, double& theSize);
-
-  //! Add action to the viewer
-  void addAction(QAction* theAction)
-  {
-    myActions.append(theAction);
-  }
-
-  void updateFromResources();
-
-  static void setHotButton(XGUI::InteractionStyle theInteractionStyle, XGUI::HotOperation theOper,
-                           Qt::KeyboardModifiers theState, Qt::MouseButtons theButton);
-  static void getHotButton(XGUI::InteractionStyle theInteractionStyle, XGUI::HotOperation theOper,
-                           Qt::KeyboardModifiers& theState, Qt::MouseButtons& theButton);
-
-  typedef QMap<XGUI::HotOperation, Qt::KeyboardModifiers> StatesMap;
-  typedef QMap<XGUI::HotOperation, Qt::MouseButtons> ButtonsMap;
-
-  typedef QMap<XGUI::InteractionStyle, StatesMap> InteractionStyle2StatesMap;
-  typedef QMap<XGUI::InteractionStyle, ButtonsMap> InteractionStyle2ButtonsMap;
-
-  static InteractionStyle2StatesMap myStateMap;
-  static InteractionStyle2ButtonsMap myButtonMap;
-
-signals:
-  void lastViewClosed();
-  void tryCloseView(XGUI_ViewWindow* theWindow);
-  void deleteView(XGUI_ViewWindow* theWindow);
-  void viewCreated(XGUI_ViewWindow* theWindow);
-  void mousePress(XGUI_ViewWindow* theWindow, QMouseEvent* theEvent);
-  void mouseRelease(XGUI_ViewWindow* theWindow, QMouseEvent* theEvent);
-  void mouseDoubleClick(XGUI_ViewWindow* theWindow, QMouseEvent* theEvent);
-  void mouseMove(XGUI_ViewWindow* theWindow, QMouseEvent* theEvent);
-  void keyPress(XGUI_ViewWindow* theWindow, QKeyEvent* theEvent);
-  void keyRelease(XGUI_ViewWindow* theWindow, QKeyEvent* theEvent);
-  void activated(XGUI_ViewWindow* theWindow);
-  void selectionChanged();
-
-  void contextMenuRequested(QContextMenuEvent*);
-
- public slots:
-  void onWindowMinimized(QMdiSubWindow*);
-  void onWindowActivated(QMdiSubWindow*);
-
- private slots:
-  void onViewClosed(QMdiSubWindow*);
-  void onMouseMove(XGUI_ViewWindow* theWindow, QMouseEvent* theEvent);
-  void onMouseReleased(XGUI_ViewWindow* theWindow, QMouseEvent* theEvent);
-  void onMousePressed(XGUI_ViewWindow* theWindow, QMouseEvent* theEvent);
-  //void onContextMenuRequested(QContextMenuEvent* theEvent);
-
-  void onKeyRelease(XGUI_ViewWindow* theView, QKeyEvent* theKey);
-
- private:
-  void addView(QMdiSubWindow* theView);
-
-  /*! Removes the View from internal Views list.*/
-  void removeView(QMdiSubWindow* theView);
-
-  void updateViewsDrawMode() const;
-
- private:
-  XGUI_MainWindow* myMainWindow;
-
-  Handle(V3d_Viewer) myV3dViewer;
-  Handle(AIS_Trihedron) myTrihedron;
-  Handle(AIS_InteractiveContext) myAISContext;
-
-  XGUI::InteractionStyle myInteractionStyle;
-
-  bool myPreselectionEnabled;
-  bool mySelectionEnabled;
-  bool myMultiSelectionEnabled;
-  bool myIsRelative;
-
-  double myTrihedronSize;
-
-  QList<QMdiSubWindow*> myViews;
-
-  QMdiSubWindow* myActiveView;
-
-  /// Points used for selection management
-  QPoint myStartPnt, myEndPnt, myCurPnt;
-
-  /// A counter of created windows
-  int myWndIdCount;
-
-  /// List of Viewer actions
-  QList<QAction*> myActions;
-};
-
-#endif
index 782023d870aa6cb4bdfaf996f1c2436c2b8624fc..25baff9a741524e6dd77d836cbaacad2714fdcf7 100644 (file)
@@ -1,10 +1,14 @@
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D -->
+
 #include "XGUI_ViewerProxy.h"
 #include "XGUI_Workshop.h"
-#include "XGUI_MainWindow.h"
-#include "XGUI_ViewPort.h"
-#include "XGUI_ViewWindow.h"
-#include "XGUI_Viewer.h"
 #include "XGUI_SalomeConnector.h"
+#include "XGUI_Displayer.h"
+
+#include <AppElements_MainWindow.h>
+#include <AppElements_ViewPort.h>
+#include <AppElements_ViewWindow.h>
+#include <AppElements_Viewer.h>
 
 XGUI_ViewerProxy::XGUI_ViewerProxy(XGUI_Workshop* theParent)
     : ModuleBase_IViewer(theParent),
@@ -35,7 +39,7 @@ Handle(V3d_View) XGUI_ViewerProxy::activeView() const
   if (myWorkshop->isSalomeMode()) {
     return myWorkshop->salomeConnector()->viewer()->activeView();
   } else {
-    XGUI_Viewer* aViewer = myWorkshop->mainWindow()->viewer();
+    AppElements_Viewer* aViewer = myWorkshop->mainWindow()->viewer();
     return (aViewer->activeViewWindow()) ? aViewer->activeViewWindow()->viewPort()->getView() :
     Handle(V3d_View)();
   }
@@ -46,7 +50,7 @@ void XGUI_ViewerProxy::setViewProjection(double theX, double theY, double theZ)
   Handle(V3d_View) aView3d = activeView();
   if (!aView3d.IsNull()) {
     aView3d->SetProj(theX, theY, theZ);
-    aView3d->FitAll(0.01, true, true);
+    aView3d->FitAll(0.01, true);
     aView3d->SetZSize(0.);
   }
 }
@@ -56,7 +60,7 @@ void XGUI_ViewerProxy::fitAll()
   if (myWorkshop->isSalomeMode()) {
     myWorkshop->salomeConnector()->viewer()->fitAll();
   } else {
-    XGUI_Viewer* aViewer = myWorkshop->mainWindow()->viewer();
+    AppElements_Viewer* aViewer = myWorkshop->mainWindow()->viewer();
     if (aViewer->activeViewWindow())
       aViewer->activeViewWindow()->viewPort()->fitAll();
   }
@@ -68,49 +72,74 @@ void XGUI_ViewerProxy::connectToViewer()
     ModuleBase_IViewer* aViewer = myWorkshop->salomeConnector()->viewer();
 
     connect(aViewer, SIGNAL(lastViewClosed()), this, SIGNAL(lastViewClosed()));
-    connect(aViewer, SIGNAL(tryCloseView()), this, SIGNAL(tryCloseView()));
-    connect(aViewer, SIGNAL(deleteView()), this, SIGNAL(deleteView()));
-    connect(aViewer, SIGNAL(viewCreated()), this, SIGNAL(viewCreated()));
-    connect(aViewer, SIGNAL(activated()), this, SIGNAL(activated()));
+    connect(aViewer, SIGNAL(tryCloseView(ModuleBase_IViewWindow*)), 
+      this, SIGNAL(tryCloseView(ModuleBase_IViewWindow*)));
+
+    connect(aViewer, SIGNAL(deleteView(ModuleBase_IViewWindow*)), 
+      this, SIGNAL(deleteView(ModuleBase_IViewWindow*)));
+
+    connect(aViewer, SIGNAL(viewCreated(ModuleBase_IViewWindow*)), 
+      this, SIGNAL(viewCreated(ModuleBase_IViewWindow*)));
+
+    connect(aViewer, SIGNAL(activated(ModuleBase_IViewWindow*)), 
+      this, SIGNAL(activated(ModuleBase_IViewWindow*)));
 
-    connect(aViewer, SIGNAL(mousePress(QMouseEvent*)), this, SIGNAL(mousePress(QMouseEvent*)));
+    connect(aViewer, SIGNAL(mousePress(ModuleBase_IViewWindow*, QMouseEvent*)), 
+      this, SIGNAL(mousePress(ModuleBase_IViewWindow*, QMouseEvent*)));
 
-    connect(aViewer, SIGNAL(mouseRelease(QMouseEvent*)), this, SIGNAL(mouseRelease(QMouseEvent*)));
+    connect(aViewer, SIGNAL(mouseRelease(ModuleBase_IViewWindow*, QMouseEvent*)), 
+      this, SIGNAL(mouseRelease(ModuleBase_IViewWindow*, QMouseEvent*)));
 
-    connect(aViewer, SIGNAL(mouseDoubleClick(QMouseEvent*)), this,
-            SIGNAL(mouseDoubleClick(QMouseEvent*)));
+    connect(aViewer, SIGNAL(mouseDoubleClick(ModuleBase_IViewWindow*, QMouseEvent*)), this,
+            SIGNAL(mouseDoubleClick(ModuleBase_IViewWindow*, QMouseEvent*)));
 
-    connect(aViewer, SIGNAL(mouseMove(QMouseEvent*)), this, SIGNAL(mouseMove(QMouseEvent*)));
+    connect(aViewer, SIGNAL(mouseMove(ModuleBase_IViewWindow*, QMouseEvent*)), 
+      this, SIGNAL(mouseMove(ModuleBase_IViewWindow*, QMouseEvent*)));
 
-    connect(aViewer, SIGNAL(keyPress(QKeyEvent*)), this, SIGNAL(keyPress(QKeyEvent*)));
+    connect(aViewer, SIGNAL(keyPress(ModuleBase_IViewWindow*, QKeyEvent*)), 
+      this, SIGNAL(keyPress(ModuleBase_IViewWindow*, QKeyEvent*)));
 
-    connect(aViewer, SIGNAL(keyRelease(QKeyEvent*)), this, SIGNAL(keyRelease(QKeyEvent*)));
+    connect(aViewer, SIGNAL(keyRelease(ModuleBase_IViewWindow*, QKeyEvent*)), 
+      this, SIGNAL(keyRelease(ModuleBase_IViewWindow*, QKeyEvent*)));
 
     connect(aViewer, SIGNAL(selectionChanged()), this, SIGNAL(selectionChanged()));
     connect(aViewer, SIGNAL(contextMenuRequested(QContextMenuEvent*)), this,
             SIGNAL(contextMenuRequested(QContextMenuEvent*)));
 
   } else {
-    XGUI_Viewer* aViewer = myWorkshop->mainWindow()->viewer();
+    AppElements_Viewer* aViewer = myWorkshop->mainWindow()->viewer();
 
     connect(aViewer, SIGNAL(lastViewClosed()), this, SIGNAL(lastViewClosed()));
-    connect(aViewer, SIGNAL(tryCloseView(XGUI_ViewWindow*)), this, SIGNAL(tryCloseView()));
-    connect(aViewer, SIGNAL(deleteView(XGUI_ViewWindow*)), this, SIGNAL(deleteView()));
-    connect(aViewer, SIGNAL(viewCreated(XGUI_ViewWindow*)), this, SIGNAL(viewCreated()));
-    connect(aViewer, SIGNAL(activated(XGUI_ViewWindow*)), this, SIGNAL(activated()));
-
-    connect(aViewer, SIGNAL(mousePress(XGUI_ViewWindow*, QMouseEvent*)), this,
-            SLOT(onMousePress(XGUI_ViewWindow*, QMouseEvent*)));
-    connect(aViewer, SIGNAL(mouseRelease(XGUI_ViewWindow*, QMouseEvent*)), this,
-            SLOT(onMouseRelease(XGUI_ViewWindow*, QMouseEvent*)));
-    connect(aViewer, SIGNAL(mouseDoubleClick(XGUI_ViewWindow*, QMouseEvent*)), this,
-            SLOT(onMouseDoubleClick(XGUI_ViewWindow*, QMouseEvent*)));
-    connect(aViewer, SIGNAL(mouseMove(XGUI_ViewWindow*, QMouseEvent*)), this,
-            SLOT(onMouseMove(XGUI_ViewWindow*, QMouseEvent*)));
-    connect(aViewer, SIGNAL(keyPress(XGUI_ViewWindow*, QKeyEvent*)), this,
-            SLOT(onKeyPress(XGUI_ViewWindow*, QKeyEvent*)));
-    connect(aViewer, SIGNAL(keyRelease(XGUI_ViewWindow*, QKeyEvent*)), this,
-            SLOT(onKeyRelease(XGUI_ViewWindow*, QKeyEvent*)));
+
+    connect(aViewer, SIGNAL(tryCloseView(AppElements_ViewWindow*)), 
+            this, SLOT(onTryCloseView(AppElements_ViewWindow*)));
+
+    connect(aViewer, SIGNAL(deleteView(AppElements_ViewWindow*)), 
+            this, SLOT(onDeleteView(AppElements_ViewWindow*)));
+
+    connect(aViewer, SIGNAL(viewCreated(AppElements_ViewWindow*)), 
+            this, SLOT(onViewCreated(AppElements_ViewWindow*)));
+
+    connect(aViewer, SIGNAL(activated(AppElements_ViewWindow*)), 
+            this, SLOT(onActivated(AppElements_ViewWindow*)));
+
+    connect(aViewer, SIGNAL(mousePress(AppElements_ViewWindow*, QMouseEvent*)), this,
+            SLOT(onMousePress(AppElements_ViewWindow*, QMouseEvent*)));
+
+    connect(aViewer, SIGNAL(mouseRelease(AppElements_ViewWindow*, QMouseEvent*)), this,
+            SLOT(onMouseRelease(AppElements_ViewWindow*, QMouseEvent*)));
+
+    connect(aViewer, SIGNAL(mouseDoubleClick(AppElements_ViewWindow*, QMouseEvent*)), this,
+            SLOT(onMouseDoubleClick(AppElements_ViewWindow*, QMouseEvent*)));
+
+    connect(aViewer, SIGNAL(mouseMove(AppElements_ViewWindow*, QMouseEvent*)), this,
+            SLOT(onMouseMove(AppElements_ViewWindow*, QMouseEvent*)));
+
+    connect(aViewer, SIGNAL(keyPress(AppElements_ViewWindow*, QKeyEvent*)), this,
+            SLOT(onKeyPress(AppElements_ViewWindow*, QKeyEvent*)));
+
+    connect(aViewer, SIGNAL(keyRelease(AppElements_ViewWindow*, QKeyEvent*)), this,
+            SLOT(onKeyRelease(AppElements_ViewWindow*, QKeyEvent*)));
 
     connect(aViewer, SIGNAL(selectionChanged()), this, SIGNAL(selectionChanged()));
     connect(aViewer, SIGNAL(contextMenuRequested(QContextMenuEvent*)), this,
@@ -118,36 +147,59 @@ void XGUI_ViewerProxy::connectToViewer()
   }
 }
 
-void XGUI_ViewerProxy::onMousePress(XGUI_ViewWindow*, QMouseEvent* theEvent)
+
+void XGUI_ViewerProxy::onTryCloseView(AppElements_ViewWindow* theWnd)
 {
-  emit mousePress(theEvent);
+  emit tryCloseView(theWnd);
 }
 
-void XGUI_ViewerProxy::onMouseRelease(XGUI_ViewWindow*, QMouseEvent* theEvent)
+void XGUI_ViewerProxy::onDeleteView(AppElements_ViewWindow* theWnd)
 {
-  emit mouseRelease(theEvent);
+  emit deleteView(theWnd);
 }
 
-void XGUI_ViewerProxy::onMouseDoubleClick(XGUI_ViewWindow*, QMouseEvent* theEvent)
+void XGUI_ViewerProxy::onViewCreated(AppElements_ViewWindow* theWnd)
 {
-  emit mouseDoubleClick(theEvent);
+  emit viewCreated(theWnd);
 }
 
-void XGUI_ViewerProxy::onMouseMove(XGUI_ViewWindow*, QMouseEvent* theEvent)
+void XGUI_ViewerProxy::onActivated(AppElements_ViewWindow* theWnd)
 {
-  emit mouseMove(theEvent);
+  emit activated(theWnd);
 }
 
-void XGUI_ViewerProxy::onKeyPress(XGUI_ViewWindow*, QKeyEvent* theEvent)
+void XGUI_ViewerProxy::onMousePress(AppElements_ViewWindow* theWnd, QMouseEvent* theEvent)
 {
-  emit keyPress(theEvent);
+  emit mousePress(theWnd, theEvent);
 }
 
-void XGUI_ViewerProxy::onKeyRelease(XGUI_ViewWindow*, QKeyEvent* theEvent)
+void XGUI_ViewerProxy::onMouseRelease(AppElements_ViewWindow* theWnd, QMouseEvent* theEvent)
 {
-  emit keyRelease(theEvent);
+  emit mouseRelease(theWnd, theEvent);
 }
 
+void XGUI_ViewerProxy::onMouseDoubleClick(AppElements_ViewWindow* theWnd, QMouseEvent* theEvent)
+{
+  emit mouseDoubleClick(theWnd, theEvent);
+}
+
+void XGUI_ViewerProxy::onMouseMove(AppElements_ViewWindow* theWnd, QMouseEvent* theEvent)
+{
+  emit mouseMove(theWnd, theEvent);
+}
+
+void XGUI_ViewerProxy::onKeyPress(AppElements_ViewWindow* theWnd, QKeyEvent* theEvent)
+{
+  emit keyPress(theWnd, theEvent);
+}
+
+void XGUI_ViewerProxy::onKeyRelease(AppElements_ViewWindow* theWnd, QKeyEvent* theEvent)
+{
+  emit keyRelease(theWnd, theEvent);
+}
+
+
+
 //***************************************
 void XGUI_ViewerProxy::enableSelection(bool isEnabled)
 {
@@ -191,26 +243,17 @@ bool XGUI_ViewerProxy::isMultiSelectionEnabled() const
 //***************************************
 void XGUI_ViewerProxy::addSelectionFilter(const Handle(SelectMgr_Filter)& theFilter)
 {
-  Handle(AIS_InteractiveContext) aContext = AISContext();
-  if (!aContext.IsNull()) {
-    aContext->AddFilter(theFilter);
-  }
+  myWorkshop->displayer()->addSelectionFilter(theFilter);
 }
 
 //***************************************
 void XGUI_ViewerProxy::removeSelectionFilter(const Handle(SelectMgr_Filter)& theFilter)
 {
-  Handle(AIS_InteractiveContext) aContext = AISContext();
-  if (!aContext.IsNull()) {
-    aContext->RemoveFilter(theFilter);
-  }
+  myWorkshop->displayer()->removeSelectionFilter(theFilter);
 }
 
 //***************************************
 void XGUI_ViewerProxy::clearSelectionFilters()
 {
-  Handle(AIS_InteractiveContext) aContext = AISContext();
-  if (!aContext.IsNull()) {
-    aContext->RemoveFilters();
-  }
+  myWorkshop->displayer()->removeFilters();
 }
index caca6ec42133103af9f64c78e0ab2291764e1cbe..1f20b281b41cd01a5e55e0b02c8e595cf8e16dcc 100644 (file)
@@ -1,3 +1,5 @@
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D -->
+
 #ifndef XGUI_VIEWERPROXY_H
 #define XGUI_VIEWERPROXY_H
 
@@ -5,10 +7,10 @@
 #include <ModuleBase_IViewer.h>
 
 class XGUI_Workshop;
-class XGUI_ViewWindow;
+class AppElements_ViewWindow;
 
 /**
- * Proxy class which repersents or XGUI_Viewer or Salome Viewer
+ * Proxy class which repersents or AppElements_Viewer or Salome Viewer
  * dependently on current launching environment.
  * It is reccomennded to use this class in operation for accessing to viewer 
  * functionality instead of direct access to a viewer
@@ -61,13 +63,19 @@ Q_OBJECT
   /// Remove all selection filters from the viewer
   virtual void clearSelectionFilters();
 
- private slots:
-  void onMousePress(XGUI_ViewWindow*, QMouseEvent*);
-  void onMouseRelease(XGUI_ViewWindow*, QMouseEvent*);
-  void onMouseDoubleClick(XGUI_ViewWindow*, QMouseEvent*);
-  void onMouseMove(XGUI_ViewWindow*, QMouseEvent*);
-  void onKeyPress(XGUI_ViewWindow*, QKeyEvent*);
-  void onKeyRelease(XGUI_ViewWindow*, QKeyEvent*);
+private slots:
+  void onTryCloseView(AppElements_ViewWindow*);
+  void onDeleteView(AppElements_ViewWindow*);
+  void onViewCreated(AppElements_ViewWindow*);
+  void onActivated(AppElements_ViewWindow*);
+
+  void onMousePress(AppElements_ViewWindow*, QMouseEvent*);
+  void onMouseRelease(AppElements_ViewWindow*, QMouseEvent*);
+  void onMouseDoubleClick(AppElements_ViewWindow*, QMouseEvent*);
+  void onMouseMove(AppElements_ViewWindow*, QMouseEvent*);
+
+  void onKeyPress(AppElements_ViewWindow*, QKeyEvent*);
+  void onKeyRelease(AppElements_ViewWindow*, QKeyEvent*);
 
  private:
   XGUI_Workshop* myWorkshop;
diff --git a/src/XGUI/XGUI_Workbench.cpp b/src/XGUI/XGUI_Workbench.cpp
deleted file mode 100644 (file)
index 8826b33..0000000
+++ /dev/null
@@ -1,196 +0,0 @@
-#include "XGUI_Workbench.h"
-#include "XGUI_MenuGroupPanel.h"
-
-#include <QLayout>
-#include <QResizeEvent>
-#include <QPushButton>
-
-#define SCROLL_STEP 20
-
-//**************************************************
-class CommandsArea : public QScrollArea
-{
- public:
-  CommandsArea(QWidget* theParent)
-      : QScrollArea(theParent)
-  {
-  }
-
- protected:
-  virtual void resizeEvent(QResizeEvent * theEvent);
-};
-
-void CommandsArea::resizeEvent(QResizeEvent* theEvent)
-{
-  int x = widget()->x();
-  QScrollArea::resizeEvent(theEvent);
-  QRect aRect = widget()->childrenRect();
-  QSize aNewSize = theEvent->size();
-  if (aRect.width() > aNewSize.width())
-    aNewSize.setWidth(aRect.width() * 2);
-  widget()->resize(aNewSize);
-  widget()->move(x, 0);
-}
-
-//**************************************************
-XGUI_Workbench::XGUI_Workbench(QWidget *theParent)
-    : QWidget(theParent)
-{
-  setMinimumHeight(30);
-  QHBoxLayout* aMainLayout = new QHBoxLayout(this);
-  aMainLayout->setSpacing(0);
-  aMainLayout->setMargin(0);
-  aMainLayout->setContentsMargins(0, 0, 0, 0);
-
-  myLeftButton = new QPushButton("<", this);
-  myLeftButton->setMaximumWidth(14);
-  myLeftButton->setVisible(false);
-  connect(myLeftButton, SIGNAL(clicked()), this, SLOT(onLeftScroll()));
-  aMainLayout->addWidget(myLeftButton);
-
-  myCommandsArea = new CommandsArea(this);
-  aMainLayout->addWidget(myCommandsArea);
-  myCommandsArea->viewport()->installEventFilter(this);
-
-  myChildWidget = new QWidget(myCommandsArea);
-  myCommandsArea->setWidget(myChildWidget);
-  myCommandsArea->setAlignment(Qt::AlignLeft | Qt::AlignTop);
-  myCommandsArea->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
-  myCommandsArea->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
-
-  myLayout = new QHBoxLayout(myChildWidget);
-  myLayout->setSpacing(0);
-  myLayout->setMargin(0);
-  myLayout->setContentsMargins(0, 0, 0, 0);
-
-  myRightButton = new QPushButton(">", this);
-  myRightButton->setMaximumWidth(14);
-  myRightButton->setVisible(false);
-  connect(myRightButton, SIGNAL(clicked()), this, SLOT(onRightScroll()));
-  aMainLayout->addWidget(myRightButton);
-
-}
-
-/*
- * Creates a new group in the workbench with given object name.
- */
-XGUI_MenuGroupPanel* XGUI_Workbench::addGroup(const QString& theId)
-{
-  if (!myLayout->isEmpty()) {
-    int aNb = myLayout->count();
-    QLayoutItem* aItem = myLayout->itemAt(aNb - 1);
-    myLayout->removeItem(aItem);
-  }
-  XGUI_MenuGroupPanel* aGroup = new XGUI_MenuGroupPanel(myChildWidget);
-  aGroup->setObjectName(theId);
-  myLayout->addWidget(aGroup);
-  if (theId != "Default") {
-    addSeparator();
-  }
-  myLayout->addStretch();
-  myGroups.append(aGroup);
-  return aGroup;
-}
-
-/*
- * Searches for already created group with given name.
- */
-XGUI_MenuGroupPanel* XGUI_Workbench::findGroup(const QString& theId)
-{
-  XGUI_MenuGroupPanel* aPanel;
-  foreach(aPanel, myGroups)
-  {
-    if (aPanel->objectName() == theId) {
-      return aPanel;
-    }
-  }
-  return NULL;
-}
-
-void XGUI_Workbench::addSeparator()
-{
-  QFrame* aLine = new QFrame(myChildWidget);
-  aLine->setFrameShape(QFrame::VLine);
-  aLine->setFrameShadow(QFrame::Sunken);
-  myLayout->addWidget(aLine);
-}
-
-void XGUI_Workbench::resizeEvent(QResizeEvent* theEvent)
-{
-  QWidget::resizeEvent(theEvent);
-  QSize aSize = theEvent->size();
-  myLeftButton->setMinimumHeight(aSize.height() - 2);
-  myRightButton->setMinimumHeight(aSize.height() - 2);
-
-  QSize aS = myChildWidget->sizeHint();
-  int aW = myChildWidget->width();
-  if (aW < aS.width())
-    myChildWidget->resize(aS.width(), myChildWidget->height());
-
-  myLeftButton->setVisible(isExceedsLeft());
-  myRightButton->setVisible(isExceedsRight());
-}
-
-void XGUI_Workbench::onLeftScroll()
-{
-  if (!isExceedsLeft())
-    return;
-  myChildWidget->move(myChildWidget->pos().x() + SCROLL_STEP, 0);
-  myLeftButton->setVisible(isExceedsLeft());
-  myRightButton->setVisible(isExceedsRight());
-}
-
-void XGUI_Workbench::onRightScroll()
-{
-  if (!isExceedsRight())
-    return;
-  myChildWidget->move(myChildWidget->pos().x() - SCROLL_STEP, 0);
-  myLeftButton->setVisible(isExceedsLeft());
-  myRightButton->setVisible(isExceedsRight());
-}
-
-bool XGUI_Workbench::isExceedsLeft()
-{
-  QPoint aPos = myChildWidget->pos();
-  return (aPos.x() < 0);
-}
-
-bool XGUI_Workbench::isExceedsRight()
-{
-  QPoint aPos = myChildWidget->pos();
-  int aVPWidth = myCommandsArea->viewport()->rect().width();
-  int aWgtWidth = myChildWidget->childrenRect().width();
-  return ((aVPWidth - aPos.x()) < aWgtWidth);
-}
-
-bool XGUI_Workbench::eventFilter(QObject *theObj, QEvent *theEvent)
-{
-  if (theObj == myCommandsArea->viewport()) {
-    if (theEvent->type() == QEvent::Resize) {
-      myLeftButton->setVisible(isExceedsLeft());
-      myRightButton->setVisible(isExceedsRight());
-    }
-  }
-  return QWidget::eventFilter(theObj, theEvent);
-}
-
-XGUI_Command* XGUI_Workbench::feature(const QString& theId) const
-{
-  QList<XGUI_MenuGroupPanel*>::const_iterator aIt;
-  for (aIt = myGroups.constBegin(); aIt != myGroups.constEnd(); ++aIt) {
-    XGUI_Command* aCmd = (*aIt)->feature(theId);
-    if (aCmd)
-      return aCmd;
-  }
-  return 0;
-}
-
-QList<XGUI_Command*> XGUI_Workbench::features() const
-{
-  QList<XGUI_Command*> aList;
-  foreach (XGUI_MenuGroupPanel* aGroup, myGroups)
-  {
-    aList.append(aGroup->features());
-  }
-  return aList;
-}
diff --git a/src/XGUI/XGUI_Workbench.h b/src/XGUI/XGUI_Workbench.h
deleted file mode 100644 (file)
index 7ede0b9..0000000
+++ /dev/null
@@ -1,53 +0,0 @@
-#ifndef XGUI_Workbench_H
-#define XGUI_Workbench_H
-
-#include "XGUI.h"
-#include <QWidget>
-#include <QScrollArea>
-#include <QList>
-
-class XGUI_Command;
-class XGUI_MenuGroupPanel;
-class CommandsArea;
-
-class QHBoxLayout;
-class QPushButton;
-
-class XGUI_EXPORT XGUI_Workbench : public QWidget
-{
-Q_OBJECT
- public:
-  XGUI_Workbench(QWidget* theParent);
-
-  XGUI_MenuGroupPanel* addGroup(const QString& theId);
-  XGUI_MenuGroupPanel* findGroup(const QString& theName);
-
-  //! Returns already created command by its ID
-  XGUI_Command* feature(const QString& theId) const;
-
-  //! Returns list of created commands
-  QList<XGUI_Command*> features() const;
-
- private slots:
-  void onLeftScroll();
-  void onRightScroll();
-
- protected:
-  virtual void resizeEvent(QResizeEvent * theEvent);
-  virtual bool eventFilter(QObject *theObj, QEvent *theEvent);
-
- private:
-  void addSeparator();
-  bool isExceedsLeft();
-  bool isExceedsRight();
-
-  QWidget* myChildWidget;
-  QHBoxLayout* myLayout;
-  QList<XGUI_MenuGroupPanel*> myGroups;
-
-  CommandsArea* myCommandsArea;
-  QPushButton* myRightButton;
-  QPushButton* myLeftButton;
-};
-
-#endif
index 12f3a4767fc4a1921fe71165269af02b57e70aed..fa583caead741b96b4c821e5adfb8c5a49a147cb 100644 (file)
@@ -1,13 +1,8 @@
-#include "ModuleBase_IModule.h"
-#include "XGUI_Constants.h"
-#include "XGUI_Command.h"
-#include "XGUI_MainMenu.h"
-#include "XGUI_MainWindow.h"
-#include "XGUI_MenuGroupPanel.h"
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D -->
+
+//#include "XGUI_Constants.h"
 #include "XGUI_Tools.h"
-#include "XGUI_Workbench.h"
 #include "XGUI_Workshop.h"
-#include "XGUI_Viewer.h"
 #include "XGUI_SelectionMgr.h"
 #include "XGUI_Selection.h"
 #include "XGUI_ObjectsBrowser.h"
 #include "XGUI_PropertyPanel.h"
 #include "XGUI_ContextMenuMgr.h"
 #include "XGUI_ModuleConnector.h"
-#include "XGUI_Preferences.h"
 #include <XGUI_QtEvents.h>
 
+#include <AppElements_Workbench.h>
+#include <AppElements_Viewer.h>
+#include <AppElements_Command.h>
+#include <AppElements_MainMenu.h>
+#include <AppElements_MainWindow.h>
+#include <AppElements_MenuGroupPanel.h>
+
+#include <ModuleBase_IModule.h>
+#include <ModuleBase_Preferences.h>
+
 #include <ModelAPI_Events.h>
 #include <ModelAPI_Session.h>
 #include <ModelAPI_Feature.h>
@@ -33,7 +37,7 @@
 #include <ModelAPI_ResultConstruction.h>
 #include <ModelAPI_ResultBody.h>
 
-#include <PartSetPlugin_Part.h>
+//#include <PartSetPlugin_Part.h>
 
 #include <Events_Loop.h>
 #include <Events_Error.h>
 #include <ModuleBase_WidgetFactory.h>
 #include <ModuleBase_Tools.h>
 #include <ModuleBase_IViewer.h>
+#include<ModuleBase_FilterFactory.h>
 
 #include <Config_Common.h>
 #include <Config_FeatureMessage.h>
 #include <Config_PointerMessage.h>
 #include <Config_ModuleReader.h>
+#include <Config_PropManager.h>
+#include <Config_SelectionFilterMessage.h>
 
 #include <QApplication>
 #include <QFileDialog>
 
 QMap<QString, QString> XGUI_Workshop::myIcons;
 
-QString XGUI_Workshop::featureIcon(const std::string& theId)
+
+QIcon XGUI_Workshop::featureIcon(const FeaturePtr& theFeature)
 {
-  QString aId(theId.c_str());
-  if (myIcons.contains(aId))
-    return myIcons[aId];
-  return QString();
+  QIcon anIcon;
+
+  std::string aKind = theFeature->getKind();
+  QString aId(aKind.c_str());
+  if (!myIcons.contains(aId))
+    return anIcon;
+
+  QString anIconString = myIcons[aId];
+
+  ModelAPI_ExecState aState = theFeature->data()->execState();
+  switch(aState) {
+    case ModelAPI_StateDone:
+    case ModelAPI_StateNothing: {
+      anIcon = QIcon(anIconString);
+    }
+    break;
+    case ModelAPI_StateMustBeUpdated: {
+      anIcon = ModuleBase_Tools::lighter(anIconString);
+    }
+    break;
+    case ModelAPI_StateExecFailed: {
+      anIcon = ModuleBase_Tools::composite(":pictures/exec_state_failed.png", anIconString);
+    }
+    break;
+    case ModelAPI_StateInvalidArgument: {
+      anIcon = ModuleBase_Tools::composite(":pictures/exec_state_invalid_parameters.png",
+                                           anIconString);
+    }
+    break;
+    default: break;  
+  }
+  return anIcon;  
 }
 
 XGUI_Workshop::XGUI_Workshop(XGUI_SalomeConnector* theConnector)
@@ -94,7 +130,7 @@ XGUI_Workshop::XGUI_Workshop(XGUI_SalomeConnector* theConnector)
       myUpdatePrefs(false),
       myPartActivating(false)
 {
-  myMainWindow = mySalomeConnector ? 0 : new XGUI_MainWindow();
+  myMainWindow = mySalomeConnector ? 0 : new AppElements_MainWindow();
 
   myDisplayer = new XGUI_Displayer(this);
 
@@ -109,21 +145,22 @@ XGUI_Workshop::XGUI_Workshop(XGUI_SalomeConnector* theConnector)
           SLOT(onContextMenuCommand(const QString&, bool)));
 
   myViewerProxy = new XGUI_ViewerProxy(this);
-  connect(myViewerProxy, SIGNAL(selectionChanged()), this, SLOT(updateCommandsOnViewSelection()));
+  connect(myViewerProxy, SIGNAL(selectionChanged()),
+          myActionsMgr,  SLOT(updateOnViewSelection()));
 
   myModuleConnector = new XGUI_ModuleConnector(this);
 
   connect(myOperationMgr, SIGNAL(operationStarted(ModuleBase_Operation*)), 
-          SLOT(onOperationStarted()));
-  connect(myOperationMgr, SIGNAL(operationResumed()), SLOT(onOperationStarted()));
+          SLOT(onOperationStarted(ModuleBase_Operation*)));
+  connect(myOperationMgr, SIGNAL(operationResumed(ModuleBase_Operation*)),
+          SLOT(onOperationResumed(ModuleBase_Operation*)));
   connect(myOperationMgr, SIGNAL(operationStopped(ModuleBase_Operation*)),
           SLOT(onOperationStopped(ModuleBase_Operation*)));
+  connect(myOperationMgr, SIGNAL(operationCommitted(ModuleBase_Operation*)), 
+          SLOT(onOperationCommitted(ModuleBase_Operation*)));
+  connect(myOperationMgr, SIGNAL(operationAborted(ModuleBase_Operation*)), 
+          SLOT(onOperationAborted(ModuleBase_Operation*)));
   connect(myMainWindow, SIGNAL(exitKeySequence()), SLOT(onExit()));
-  // TODO(sbh): It seems that application works properly without update on operationStarted
-  connect(myOperationMgr, SIGNAL(operationStarted(ModuleBase_Operation*)),
-          myActionsMgr,   SLOT(update()));
-  connect(myOperationMgr, SIGNAL(operationStopped(ModuleBase_Operation*)),
-          myActionsMgr,   SLOT(update()));
   connect(this, SIGNAL(errorOccurred(const QString&)), myErrorDlg, SLOT(addError(const QString&)));
 }
 
@@ -137,6 +174,10 @@ XGUI_Workshop::~XGUI_Workshop(void)
 void XGUI_Workshop::startApplication()
 {
   initMenu();
+
+  Config_PropManager::registerProp("Plugins", "default_path", "Default Path",
+                                   Config_Prop::Directory, "");
+
   //Initialize event listening
   Events_Loop* aLoop = Events_Loop::loop();
   aLoop->registerListener(this, Events_Error::errorID());  //!< Listening application errors.
@@ -151,14 +192,19 @@ void XGUI_Workshop::startApplication()
   aLoop->registerListener(this, Events_Loop::eventByName("CurrentDocumentChanged"));
   aLoop->registerListener(this, Events_Loop::eventByName(EVENT_OBJECT_TOSHOW));
   aLoop->registerListener(this, Events_Loop::eventByName(EVENT_OBJECT_TOHIDE));
+  aLoop->registerListener(this, Events_Loop::eventByName(EVENT_SELFILTER_LOADED));
 
   registerValidators();
+
+  // Calling of  loadCustomProps before activating module is required
+  // by Config_PropManger to restore user-defined path to plugins
+  ModuleBase_Preferences::loadCustomProps();
   activateModule();
   if (myMainWindow) {
     myMainWindow->show();
     updateCommandStatus();
   }
-  XGUI_Preferences::loadCustomProps();
+  
   onNew();
 }
 
@@ -199,9 +245,9 @@ void XGUI_Workshop::initMenu()
     return;
   }
   // File commands group
-  XGUI_MenuGroupPanel* aGroup = myMainWindow->menuObject()->generalPage();
+  AppElements_MenuGroupPanel* aGroup = myMainWindow->menuObject()->generalPage();
 
-  XGUI_Command* aCommand;
+  AppElements_Command* aCommand;
 
   aCommand = aGroup->addFeature("SAVE_CMD", tr("Save..."), tr("Save the document"),
                                 QIcon(":pictures/save.png"), QKeySequence::Save);
@@ -249,9 +295,9 @@ void XGUI_Workshop::initMenu()
 }
 
 //******************************************************
-XGUI_Workbench* XGUI_Workshop::addWorkbench(const QString& theName)
+AppElements_Workbench* XGUI_Workshop::addWorkbench(const QString& theName)
 {
-  XGUI_MainMenu* aMenuBar = myMainWindow->menuObject();
+  AppElements_MainMenu* aMenuBar = myMainWindow->menuObject();
   return aMenuBar->addWorkbench(theName);
 }
 
@@ -324,7 +370,7 @@ void XGUI_Workshop::processEvent(const std::shared_ptr<Events_Message>& theMessa
     std::shared_ptr<ModelAPI_ObjectUpdatedMessage> anUpdateMsg =
         std::dynamic_pointer_cast<ModelAPI_ObjectUpdatedMessage>(theMessage);
     const std::set<ObjectPtr>& aObjList = anUpdateMsg->objects();
-    QList<ObjectPtr> aList;
+    QObjectPtrList aList;
     std::set<ObjectPtr>::const_iterator aIt;
     for (aIt = aObjList.cbegin(); aIt != aObjList.cend(); ++aIt)
       aList.append(*aIt);
@@ -335,7 +381,7 @@ void XGUI_Workshop::processEvent(const std::shared_ptr<Events_Message>& theMessa
     std::shared_ptr<ModelAPI_ObjectUpdatedMessage> anUpdateMsg =
         std::dynamic_pointer_cast<ModelAPI_ObjectUpdatedMessage>(theMessage);
     const std::set<ObjectPtr>& aObjList = anUpdateMsg->objects();
-    QList<ObjectPtr> aList;
+    QObjectPtrList aList;
     std::set<ObjectPtr>::const_iterator aIt;
     for (aIt = aObjList.cbegin(); aIt != aObjList.cend(); ++aIt)
       aList.append(*aIt);
@@ -380,7 +426,21 @@ void XGUI_Workshop::processEvent(const std::shared_ptr<Events_Message>& theMessa
     // If not found then activate global document
     activatePart(ResultPartPtr()); 
 
-  } else {
+  }
+  else if (theMessage->eventID() == Events_Loop::eventByName(EVENT_SELFILTER_LOADED)) {
+    std::shared_ptr<Config_SelectionFilterMessage> aMsg = 
+      std::dynamic_pointer_cast<Config_SelectionFilterMessage>(theMessage);
+    if (aMsg) {
+      ModuleBase_FilterFactory* aFactory = moduleConnector()->selectionFilters();
+      if (!aMsg->attributeId().empty()) {
+        aFactory->assignFilter(aMsg->selectionFilterId(), aMsg->featureId(), aMsg->attributeId(),
+                               aMsg->parameters());
+      }
+    }
+  }
+
+  
+  else {
     //Show error dialog if error message received.
     std::shared_ptr<Events_Error> anAppError = std::dynamic_pointer_cast<Events_Error>(theMessage);
     if (anAppError) {
@@ -428,7 +488,6 @@ void XGUI_Workshop::onFeatureRedisplayMsg(const std::shared_ptr<ModelAPI_ObjectU
 {
   std::set<ObjectPtr> aObjects = theMsg->objects();
   std::set<ObjectPtr>::const_iterator aIt;
-  QIntList aModes;
   for (aIt = aObjects.begin(); aIt != aObjects.end(); ++aIt) {
     ObjectPtr aObj = (*aIt);
     bool aHide = !aObj->data() || !aObj->data()->isValid();
@@ -443,15 +502,14 @@ void XGUI_Workshop::onFeatureRedisplayMsg(const std::shared_ptr<ModelAPI_ObjectU
         myDisplayer->display(aObj, false);  // In order to update presentation
         if (myOperationMgr->hasOperation()) {
           ModuleBase_Operation* aOperation = myOperationMgr->currentOperation();
-          if (!aOperation->hasObject(aObj))
-            if (!myDisplayer->isActive(aObj))
-              myDisplayer->activate(aObj, aModes);
+          if (aOperation->hasObject(aObj) && myDisplayer->isActive(aObj))
+            myDisplayer->deactivate(aObj);
         }
       } else {
         if (myOperationMgr->hasOperation()) {
           ModuleBase_Operation* aOperation = myOperationMgr->currentOperation();
           // Display only current operation results if operation has preview
-          if (aOperation->hasObject(aObj) && aOperation->hasPreview()) {
+          if (aOperation->hasObject(aObj)/* && aOperation->hasPreview()*/) {
             myDisplayer->display(aObj, false);
             // Deactivate object of current operation from selection
             if (myDisplayer->isActive(aObj))
@@ -504,50 +562,34 @@ void XGUI_Workshop::onObjectDeletedMsg(const std::shared_ptr<ModelAPI_ObjectDele
 }
 
 //******************************************************
-void XGUI_Workshop::onOperationStarted()
+void XGUI_Workshop::onOperationStarted(ModuleBase_Operation* theOperation)
 {
-  ModuleBase_Operation* aOperation = myOperationMgr->currentOperation();
-  if (this->isSalomeMode()) 
-    aOperation->setNestedFeatures(mySalomeConnector->nestedActions(aOperation->id()));
-  else 
-    aOperation->setNestedFeatures(myActionsMgr->nestedCommands(aOperation->id()));
-  
-  if (aOperation->getDescription()->hasXmlRepresentation()) {  //!< No need for property panel
-    connectWithOperation(aOperation);
-
-    showPropertyPanel();
-    QString aXmlRepr = aOperation->getDescription()->xmlRepresentation();
-    ModuleBase_WidgetFactory aFactory = ModuleBase_WidgetFactory(aXmlRepr.toStdString(),
-                                                                 myModuleConnector);
-
-    myPropertyPanel->cleanContent();
-    aFactory.createWidget(myPropertyPanel->contentWidget());
-    ModuleBase_Tools::zeroMargins(myPropertyPanel->contentWidget());
-
-    QList<ModuleBase_ModelWidget*> aWidgets = aFactory.getModelWidgets();
-    foreach (ModuleBase_ModelWidget* aWidget, aWidgets) {
-      aWidget->setFeature(aOperation->feature());
-      aWidget->enableFocusProcessing();
-      QObject::connect(aWidget, SIGNAL(valuesChanged()), this, SLOT(onWidgetValuesChanged()));
-      // Init default values
-      if (!aOperation->isEditOperation() && !aWidget->isComputedDefault()) {
-        aWidget->storeValue();
-      }
-    }
+  setNestedFeatures(theOperation);
 
-    aOperation->setPropertyPanel(myPropertyPanel);
-    myPropertyPanel->setModelWidgets(aWidgets);
-    if (!aOperation->activateByPreselection())
-      myPropertyPanel->activateNextWidget(NULL);
-    // Widget activation (from the previous method) may commit the current operation
-    // if pre-selection is enougth for it. So we shouldn't update prop panel's title
-    if(myOperationMgr->isCurrentOperation(aOperation)) {
-      myPropertyPanel->setWindowTitle(aOperation->getDescription()->description());
-    }
+  if (theOperation->getDescription()->hasXmlRepresentation()) {  //!< No need for property panel
+    connectWithOperation(theOperation);
+    setPropertyPanel(theOperation);
+  }
+  updateCommandStatus();
+
+  myModule->operationStarted(theOperation);
+}
+
+//******************************************************
+void XGUI_Workshop::onOperationResumed(ModuleBase_Operation* theOperation)
+{
+  setNestedFeatures(theOperation);
+
+  if (theOperation->getDescription()->hasXmlRepresentation()) {  //!< No need for property panel
+    connectWithOperation(theOperation);
+    setPropertyPanel(theOperation);
   }
   updateCommandStatus();
+
+  myModule->operationResumed(theOperation);
 }
 
+
 //******************************************************
 void XGUI_Workshop::onOperationStopped(ModuleBase_Operation* theOperation)
 {
@@ -555,6 +597,65 @@ void XGUI_Workshop::onOperationStopped(ModuleBase_Operation* theOperation)
   updateCommandStatus();
   hidePropertyPanel();
   myPropertyPanel->cleanContent();
+
+  // Activate objects created by current operation
+  FeaturePtr aFeature = theOperation->feature();
+  myDisplayer->activate(aFeature);
+  const std::list<ResultPtr>& aResults = aFeature->results();
+  std::list<ResultPtr>::const_iterator aIt;
+  for (aIt = aResults.cbegin(); aIt != aResults.cend(); ++aIt) {
+    myDisplayer->activate(*aIt);
+  }
+  myModule->operationStopped(theOperation);
+}
+
+
+void XGUI_Workshop::onOperationCommitted(ModuleBase_Operation* theOperation)
+{
+  myModule->operationCommitted(theOperation);
+}
+
+void XGUI_Workshop::onOperationAborted(ModuleBase_Operation* theOperation)
+{
+  myModule->operationAborted(theOperation);
+}
+
+void XGUI_Workshop::setNestedFeatures(ModuleBase_Operation* theOperation)
+{
+  if (this->isSalomeMode()) 
+    theOperation->setNestedFeatures(mySalomeConnector->nestedActions(theOperation->id()));
+  else 
+    theOperation->setNestedFeatures(myActionsMgr->nestedCommands(theOperation->id()));
+}
+
+void XGUI_Workshop::setPropertyPanel(ModuleBase_Operation* theOperation)
+{
+  showPropertyPanel();
+  QString aXmlRepr = theOperation->getDescription()->xmlRepresentation();
+  ModuleBase_WidgetFactory aFactory = ModuleBase_WidgetFactory(aXmlRepr.toStdString(),
+                                                                myModuleConnector);
+
+  myPropertyPanel->cleanContent();
+  aFactory.createWidget(myPropertyPanel->contentWidget());
+  ModuleBase_Tools::zeroMargins(myPropertyPanel->contentWidget());
+
+  QList<ModuleBase_ModelWidget*> aWidgets = aFactory.getModelWidgets();
+  foreach (ModuleBase_ModelWidget* aWidget, aWidgets) {
+    aWidget->setFeature(theOperation->feature());
+    aWidget->enableFocusProcessing();
+    QObject::connect(aWidget, SIGNAL(valuesChanged()), this, SLOT(onWidgetValuesChanged()));
+    // Init default values
+    if (!theOperation->isEditOperation() && !aWidget->isComputedDefault()) {
+      aWidget->storeValue();
+    }
+  }
+  
+  myPropertyPanel->setModelWidgets(aWidgets);
+  theOperation->setPropertyPanel(myPropertyPanel);
+
+  myModule->propertyPanelDefined(theOperation);
+
+  myPropertyPanel->setWindowTitle(theOperation->getDescription()->description());
 }
 
 bool XGUI_Workshop::event(QEvent * theEvent)
@@ -598,17 +699,17 @@ void XGUI_Workshop::addFeature(const std::shared_ptr<Config_FeatureMessage>& the
     salomeConnector()->setDocumentKind(aFeatureId, QString::fromStdString(theMessage->documentKind()));
 
     myActionsMgr->addCommand(aAction);
-    myModule->featureCreated(aAction);
+    myModule->actionCreated(aAction);
   } else {
 
-    XGUI_MainMenu* aMenuBar = myMainWindow->menuObject();
-    XGUI_Workbench* aPage = aMenuBar->findWorkbench(aWchName);
+    AppElements_MainMenu* aMenuBar = myMainWindow->menuObject();
+    AppElements_Workbench* aPage = aMenuBar->findWorkbench(aWchName);
     if (!aPage) {
       aPage = addWorkbench(aWchName);
     }
     //Find or create Group
     QString aGroupName = QString::fromStdString(theMessage->groupId());
-    XGUI_MenuGroupPanel* aGroup = aPage->findGroup(aGroupName);
+    AppElements_MenuGroupPanel* aGroup = aPage->findGroup(aGroupName);
     if (!aGroup) {
       aGroup = aPage->addGroup(aGroupName);
     }
@@ -617,7 +718,7 @@ void XGUI_Workshop::addFeature(const std::shared_ptr<Config_FeatureMessage>& the
     QKeySequence aHotKey = myActionsMgr->registerShortcut(
         QString::fromStdString(theMessage->keysequence()));
     // Create feature...
-    XGUI_Command* aCommand = aGroup->addFeature(aFeatureId,
+    AppElements_Command* aCommand = aGroup->addFeature(aFeatureId,
                                                 QString::fromStdString(theMessage->text()),
                                                 QString::fromStdString(theMessage->tooltip()),
                                                 QIcon(theMessage->icon().c_str()),
@@ -626,7 +727,7 @@ void XGUI_Workshop::addFeature(const std::shared_ptr<Config_FeatureMessage>& the
                                                 isUsePropPanel);
     aCommand->setNestedCommands(aNestedFeatures.split(" ", QString::SkipEmptyParts));
     myActionsMgr->addCommand(aCommand);
-    myModule->featureCreated(aCommand);
+    myModule->actionCreated(aCommand);
   }
 }
 
@@ -641,7 +742,7 @@ void XGUI_Workshop::connectWithOperation(ModuleBase_Operation* theOperation)
   if (isSalomeMode()) {
     aCommand = salomeConnector()->command(theOperation->getDescription()->operationId());
   } else {
-    XGUI_MainMenu* aMenu = myMainWindow->menuObject();
+    AppElements_MainMenu* aMenu = myMainWindow->menuObject();
     FeaturePtr aFeature = theOperation->feature();
     if(aFeature)
       aCommand = aMenu->feature(QString::fromStdString(aFeature->getKind()));
@@ -841,17 +942,17 @@ void XGUI_Workshop::onRebuild()
 //******************************************************
 void XGUI_Workshop::onPreferences()
 {
-  XGUI_Prefs aModif;
-  XGUI_Preferences::editPreferences(aModif);
+  ModuleBase_Prefs aModif;
+  ModuleBase_Preferences::editPreferences(aModif);
   if (aModif.size() > 0) {
     QString aSection;
-    foreach (XGUI_Pref aPref, aModif)
+    foreach (ModuleBase_Pref aPref, aModif)
     {
       aSection = aPref.first;
-      if (aSection == XGUI_Preferences::VIEWER_SECTION) {
+      if (aSection == ModuleBase_Preferences::VIEWER_SECTION) {
         if (!isSalomeMode())
           myMainWindow->viewer()->updateFromResources();
-      } else if (aSection == XGUI_Preferences::MENU_SECTION) {
+      } else if (aSection == ModuleBase_Preferences::MENU_SECTION) {
         if (!isSalomeMode())
           myMainWindow->menuObject()->updateFromResources();
       }
@@ -938,8 +1039,8 @@ void XGUI_Workshop::updateCommandStatus()
   if (isSalomeMode()) {  // update commands in SALOME mode
     aCommands = salomeConnector()->commandList();
   } else {
-    XGUI_MainMenu* aMenuBar = myMainWindow->menuObject();
-    foreach (XGUI_Command* aCmd, aMenuBar->features())
+    AppElements_MainMenu* aMenuBar = myMainWindow->menuObject();
+    foreach (AppElements_Command* aCmd, aMenuBar->features())
       aCommands.append(aCmd);
   }
   SessionPtr aMgr = ModelAPI_Session::get();
@@ -969,22 +1070,7 @@ void XGUI_Workshop::updateCommandStatus()
     }
   }
   myActionsMgr->update();
-}
-
-//******************************************************
-QList<QAction*> XGUI_Workshop::getModuleCommands() const
-{
-  QList<QAction*> aCommands;
-  if (isSalomeMode()) {  // update commands in SALOME mode
-    aCommands = salomeConnector()->commandList();
-  } else {
-    XGUI_MainMenu* aMenuBar = myMainWindow->menuObject();
-    foreach(XGUI_Command* aCmd, aMenuBar->features())
-    {
-      aCommands.append(aCmd);
-    }
-  }
-  return aCommands;
+  emit commandStatusUpdated();
 }
 
 //******************************************************
@@ -1016,15 +1102,18 @@ void XGUI_Workshop::createDockWidgets()
   aDesktop->addDockWidget(Qt::LeftDockWidgetArea, aObjDock);
   myPropertyPanel = new XGUI_PropertyPanel(aDesktop);
   myPropertyPanel->setAllowedAreas(Qt::LeftDockWidgetArea | Qt::RightDockWidgetArea | Qt::BottomDockWidgetArea);
+
+  connect(myPropertyPanel, SIGNAL(noMoreWidgets()), myModule, SLOT(onNoMoreWidgets()));
+
   aDesktop->addDockWidget(Qt::LeftDockWidgetArea, myPropertyPanel);
   hidePropertyPanel();  //<! Invisible by default
   hideObjectBrowser();
   aDesktop->tabifyDockWidget(aObjDock, myPropertyPanel);
   myPropertyPanel->installEventFilter(myOperationMgr);
 
-  QPushButton* aOkBtn = myPropertyPanel->findChild<QPushButton*>(XGUI::PROP_PANEL_OK);
+  QPushButton* aOkBtn = myPropertyPanel->findChild<QPushButton*>(PROP_PANEL_OK);
   connect(aOkBtn, SIGNAL(clicked()), myOperationMgr, SLOT(onCommitOperation()));
-  QPushButton* aCancelBtn = myPropertyPanel->findChild<QPushButton*>(XGUI::PROP_PANEL_CANCEL);
+  QPushButton* aCancelBtn = myPropertyPanel->findChild<QPushButton*>(PROP_PANEL_CANCEL);
   connect(aCancelBtn, SIGNAL(clicked()), myOperationMgr, SLOT(onAbortOperation()));
   connect(myPropertyPanel, SIGNAL(keyReleased(QKeyEvent*)), myOperationMgr,
           SLOT(onKeyReleased(QKeyEvent*)));
@@ -1107,7 +1196,7 @@ ModuleBase_IViewer* XGUI_Workshop::salomeViewer() const
 //**************************************************************
 void XGUI_Workshop::onContextMenuCommand(const QString& theId, bool isChecked)
 {
-  QList<ObjectPtr> aObjects = mySelector->selection()->selectedObjects();
+  QObjectPtrList aObjects = mySelector->selection()->selectedObjects();
   if ((theId == "ACTIVATE_PART_CMD") && (aObjects.size() > 0)) {
     ResultPartPtr aPart = std::dynamic_pointer_cast<ModelAPI_ResultPart>(aObjects.first());
     activatePart(aPart);
@@ -1127,6 +1216,11 @@ void XGUI_Workshop::onContextMenuCommand(const QString& theId, bool isChecked)
     setDisplayMode(aObjects, XGUI_Displayer::Wireframe);
   else if (theId == "HIDEALL_CMD")
     myDisplayer->eraseAll();
+  else if (theId == "EDIT_CMD") {
+    FeaturePtr aFeature = std::dynamic_pointer_cast<ModelAPI_Feature>(aObjects.first());
+    if (aFeature)
+      myModule->editFeature(aFeature);
+  }
 }
 
 //**************************************************************
@@ -1136,15 +1230,12 @@ void XGUI_Workshop::onWidgetValuesChanged()
   FeaturePtr aFeature = anOperation->feature();
 
   ModuleBase_ModelWidget* aSenderWidget = dynamic_cast<ModuleBase_ModelWidget*>(sender());
-  //if (aCustom)
-  //  aCustom->storeValue(aFeature);
 
   const QList<ModuleBase_ModelWidget*>& aWidgets = myPropertyPanel->modelWidgets();
   QList<ModuleBase_ModelWidget*>::const_iterator anIt = aWidgets.begin(), aLast = aWidgets.end();
   for (; anIt != aLast; anIt++) {
     ModuleBase_ModelWidget* aCustom = *anIt;
-    if (aCustom && (/*!aCustom->isInitialized(aFeature) ||*/aCustom == aSenderWidget)) {
-      //aCustom->storeValue(aFeature);
+    if (aCustom && (aCustom == aSenderWidget)) {
       aCustom->storeValue();
     }
   }
@@ -1177,7 +1268,7 @@ void XGUI_Workshop::activateLastPart()
 }
 
 //**************************************************************
-void XGUI_Workshop::deleteObjects(const QList<ObjectPtr>& theList)
+void XGUI_Workshop::deleteObjects(const QObjectPtrList& theList)
 {
   QMainWindow* aDesktop = isSalomeMode() ? salomeConnector()->desktop() : myMainWindow;
   QMessageBox::StandardButton aRes = QMessageBox::warning(
@@ -1208,70 +1299,26 @@ void XGUI_Workshop::deleteObjects(const QList<ObjectPtr>& theList)
 }
 
 //**************************************************************
-void XGUI_Workshop::showObjects(const QList<ObjectPtr>& theList, bool isVisible)
+void XGUI_Workshop::showObjects(const QObjectPtrList& theList, bool isVisible)
 {
   foreach (ObjectPtr aObj, theList)
   {
-    ResultPtr aRes = std::dynamic_pointer_cast<ModelAPI_Result>(aObj);
-    if (aRes) {
-      if (isVisible) {
-        myDisplayer->display(aRes, false);
-      } else {
-        myDisplayer->erase(aRes, false);
-      }
+    if (isVisible) {
+      myDisplayer->display(aObj, false);
+    } else {
+      myDisplayer->erase(aObj, false);
     }
   }
   myDisplayer->updateViewer();
 }
 
 //**************************************************************
-void XGUI_Workshop::showOnlyObjects(const QList<ObjectPtr>& theList)
+void XGUI_Workshop::showOnlyObjects(const QObjectPtrList& theList)
 {
-  myDisplayer->eraseAll(false);
-  showObjects(theList, true);
+  myDisplayer->showOnly(theList);
 }
 
 
-//**************************************************************
-void XGUI_Workshop::updateCommandsOnViewSelection()
-{
-  XGUI_Selection* aSelection = mySelector->selection();
-  if (aSelection->getSelected().size() == 0)
-    return;
-
-  // Restrict validators to manage only nested (child) features
-  // of the current feature i.e. if current feature is Sketch -
-  // Sketch Features & Constraints can be validated.
-  QStringList aNestedIds;
-  if(myOperationMgr->hasOperation()) {
-    FeaturePtr aFeature = myOperationMgr->currentOperation()->feature();
-    if(aFeature) {
-      aNestedIds << myActionsMgr->nestedCommands(QString::fromStdString(aFeature->getKind()));
-    }
-  }
-  SessionPtr aMgr = ModelAPI_Session::get();
-  ModelAPI_ValidatorsFactory* aFactory = aMgr->validators();
-  QList<QAction*> aActions = getModuleCommands();
-  foreach(QAction* aAction, aActions) {
-    QString aId = aAction->data().toString();
-    if(!aNestedIds.contains(aId))
-      continue;
-    std::list<ModelAPI_Validator*> aValidators;
-    std::list<std::list<std::string> > anArguments;
-    aFactory->validators(aId.toStdString(), aValidators, anArguments);
-    std::list<ModelAPI_Validator*>::iterator aValidator = aValidators.begin();
-    for (; aValidator != aValidators.end(); aValidator++) {
-      if (*aValidator) {
-        const ModuleBase_SelectionValidator* aSelValidator =
-            dynamic_cast<const ModuleBase_SelectionValidator*>(*aValidator);
-        if (aSelValidator) {
-          aAction->setEnabled(aSelValidator->isValid(aSelection));
-        }
-      }
-    }
-  }
-}
-
 //**************************************************************
 void XGUI_Workshop::registerValidators() const
 {
@@ -1310,7 +1357,7 @@ void XGUI_Workshop::displayGroupResults(DocumentPtr theDoc, std::string theGroup
 }
 
 //**************************************************************
-void XGUI_Workshop::setDisplayMode(const QList<ObjectPtr>& theList, int theMode)
+void XGUI_Workshop::setDisplayMode(const QObjectPtrList& theList, int theMode)
 {
   foreach(ObjectPtr aObj, theList) {
     myDisplayer->setDisplayMode(aObj, (XGUI_Displayer::DisplayMode)theMode, false);
index 400465898930d63a3d93ddfdb40b55c46e9e2314..4db6052fe75adebdd0ddf4239698addb4f2e89d6 100644 (file)
@@ -1,20 +1,24 @@
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D -->
+
 #ifndef XGUI_WORKSHOP_H
 #define XGUI_WORKSHOP_H
 
 #include "XGUI.h"
-#include "XGUI_Constants.h"
+//#include "XGUI_Constants.h"
 #include <Events_Listener.h>
 #include <ModuleBase_Definitions.h>
 #include <ModelAPI_Document.h>
+#include <ModelAPI_Feature.h>
 
 #include <QObject>
 #include <QMap>
-#include <QIcon>
 #include <QKeySequence>
+#include <QIcon>
+
+class AppElements_MainWindow;
+class AppElements_Command;
+class AppElements_Workbench;
 
-class XGUI_MainWindow;
-class XGUI_Command;
-class XGUI_Workbench;
 class XGUI_SelectionMgr;
 class XGUI_Displayer;
 class XGUI_OperationMgr;
@@ -59,7 +63,7 @@ Q_OBJECT
   void startApplication();
 
   //! Returns main window (Desktop) of the application
-  XGUI_MainWindow* mainWindow() const
+  AppElements_MainWindow* mainWindow() const
   {
     return myMainWindow;
   }
@@ -87,7 +91,6 @@ Q_OBJECT
   {
     return myActionsMgr;
   }
-  ;
 
   //! Returns property panel widget
   XGUI_PropertyPanel* propertyPanel() const
@@ -102,7 +105,7 @@ Q_OBJECT
   }
 
   //! Creates and adds a new workbench (menu group) with the given name and returns it
-  XGUI_Workbench* addWorkbench(const QString& theName);
+  AppElements_Workbench* addWorkbench(const QString& theName);
 
   //! Redefinition of Events_Listener method
   virtual void processEvent(const std::shared_ptr<Events_Message>& theMessage);
@@ -142,23 +145,23 @@ Q_OBJECT
     return myModuleConnector;
   }
 
-  //! Returns icon name according to feature Id
-  static QString featureIcon(const std::string& theId);
+  //! Returns icon name according to feature
+  static QIcon featureIcon(const FeaturePtr& theFeature);
 
   //! Activates or deactivates a part
   //! If PartPtr is Null pointer then PartSet will be activated
   void activatePart(std::shared_ptr<ModelAPI_ResultPart> theFeature);
 
   //! Delete features
-  void deleteObjects(const QList<ObjectPtr>& theList);
+  void deleteObjects(const QObjectPtrList& theList);
 
   //! Show the given features in 3d Viewer
-  void showObjects(const QList<ObjectPtr>& theList, bool isVisible);
+  void showObjects(const QObjectPtrList& theList, bool isVisible);
 
   //! Show the given features in 3d Viewer
-  void showOnlyObjects(const QList<ObjectPtr>& theList);
+  void showOnlyObjects(const QObjectPtrList& theList);
 
-  void setDisplayMode(const QList<ObjectPtr>& theList, int theMode);
+  void setDisplayMode(const QObjectPtrList& theList, int theMode);
 
   ModuleBase_IModule* module() const
   {
@@ -189,10 +192,11 @@ Q_OBJECT
 signals:
   void salomeViewerSelection();
   void errorOccurred(const QString&);
+  //! the signal about the workshop actions states are updated.
+  void commandStatusUpdated();
 
  public slots:
   void updateCommandStatus();
-  void updateCommandsOnViewSelection();
 
   void onNew();
   void onOpen();
@@ -217,6 +221,14 @@ signals:
   void closeDocument();
 
  protected:
+  // Find the nested features and set them into the operation
+  // \param theOperation an operation
+  void setNestedFeatures(ModuleBase_Operation* theOperation);
+  // Update the property panel content by the XML description of the operation and set the panel
+  // into the operation
+  // \param theOperation an operation
+  void setPropertyPanel(ModuleBase_Operation* theOperation);
+
   bool event(QEvent * theEvent);
   //Event-loop processing methods:
   void addFeature(const std::shared_ptr<Config_FeatureMessage>&);
@@ -229,8 +241,6 @@ signals:
 
   void validateOperation(const QString& theOperationId);
 
-  QList<QAction*> getModuleCommands() const;
-
   void displayAllResults();
   void displayDocumentResults(DocumentPtr theDoc);
   void displayGroupResults(DocumentPtr theDoc, std::string theGroup);
@@ -238,11 +248,26 @@ signals:
  private 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.
-  void onOperationStarted();
+  /// \param theOpertion a started operation
+  void onOperationStarted(ModuleBase_Operation* theOperation);
+
+  /// SLOT, that is called after the operation is resumed. Update workshop state according to
+  /// the started operation, e.g. visualizes the property panel and connect to it.
+  /// \param theOpertion a resumed operation
+  virtual void onOperationResumed(ModuleBase_Operation* theOperation);
+
   /// SLOT, that is called after the operation is stopped. Update workshop state, e.g.
   /// hides the property panel and udpate the command status.
   /// \param theOpertion a stopped operation
-  void onOperationStopped(ModuleBase_Operation* theOperation);
+  virtual void onOperationStopped(ModuleBase_Operation* theOperation);
+
+  /// SLOT, that is called after the operation is committed.
+  /// \param theOpertion a commmitted operation
+  virtual void onOperationCommitted(ModuleBase_Operation* theOperation);
+
+  /// SLOT, that is called after the operation is aborted.
+  /// \param theOpertion an aborted operation
+  void onOperationAborted(ModuleBase_Operation* theOperation);
 
   void onContextMenuCommand(const QString& theId, bool isChecked);
 
@@ -264,7 +289,7 @@ signals:
   // Creates Dock widgets: Object browser and Property panel
   void createDockWidgets();
 
-  XGUI_MainWindow* myMainWindow;
+  AppElements_MainWindow* myMainWindow;
   ModuleBase_IModule* myModule;
   XGUI_ObjectsBrowser* myObjectBrowser;
   XGUI_PropertyPanel* myPropertyPanel;
index 6aaa267620b50aa984e140184e5c97758566d091..b7c79dd9bb6456e486649959355613b1dbc57bb7 100644 (file)
@@ -8,28 +8,6 @@
      <file>pictures/undo.png</file>
      <file>pictures/rebuild.png</file>
      <file>pictures/preferences.png</file>
-
-     <file>pictures/occ_view_back.png</file>
-     <file>pictures/occ_view_bottom.png</file>
-     <file>pictures/occ_view_camera_dump.png</file>
-     <file>pictures/occ_view_clone.png</file>
-     <file>pictures/occ_view_fitall.png</file>
-     <file>pictures/occ_view_fitarea.png</file>
-     <file>pictures/occ_view_front.png</file>
-     <file>pictures/occ_view_left.png</file>
-     <file>pictures/occ_view_pan.png</file>
-     <file>pictures/occ_view_glpan.png</file>
-     <file>pictures/occ_view_reset.png</file>
-     <file>pictures/occ_view_right.png</file>
-     <file>pictures/occ_view_rotate.png</file>
-     <file>pictures/occ_view_top.png</file>
-     <file>pictures/occ_view_zoom.png</file>
-     
-     <file>pictures/wnd_close.png</file>
-     <file>pictures/wnd_minimize.png</file>
-     <file>pictures/wnd_maximize.png</file>
-     <file>pictures/wnd_restore.png</file>
-     <file>pictures/wnd_grip.png</file>
      
      <file>pictures/params_folder.png</file>
      <file>pictures/constr_folder.png</file>
      <file>pictures/button_help.png</file>
      <file>pictures/button_ok.png</file>
    
-     <file>pictures/cascade_views.png</file>
-     <file>pictures/tile_views.png</file>
-     <file>pictures/new_view.png</file>
      <file>pictures/edit.png</file>
+     <file>pictures/exec_state_failed.png</file>
+     <file>pictures/exec_state_invalid_parameters.png</file>
      <file>pictures/assembly.png</file>
      <file>pictures/activate.png</file>
      <file>pictures/delete.png</file>
index 3047d921234a9c96d98dd0aedbc595d060d76aa8..08909e78dd4b8ac6d96f070942731d2e0024280e 100644 (file)
Binary files a/src/XGUI/pictures/box.png and b/src/XGUI/pictures/box.png differ
diff --git a/src/XGUI/pictures/cascade_views.png b/src/XGUI/pictures/cascade_views.png
deleted file mode 100644 (file)
index db45111..0000000
Binary files a/src/XGUI/pictures/cascade_views.png and /dev/null differ
diff --git a/src/XGUI/pictures/exec_state_failed.png b/src/XGUI/pictures/exec_state_failed.png
new file mode 100644 (file)
index 0000000..738f303
Binary files /dev/null and b/src/XGUI/pictures/exec_state_failed.png differ
diff --git a/src/XGUI/pictures/exec_state_invalid_parameters.png b/src/XGUI/pictures/exec_state_invalid_parameters.png
new file mode 100644 (file)
index 0000000..1346f97
Binary files /dev/null and b/src/XGUI/pictures/exec_state_invalid_parameters.png differ
diff --git a/src/XGUI/pictures/new_view.png b/src/XGUI/pictures/new_view.png
deleted file mode 100644 (file)
index 352437d..0000000
Binary files a/src/XGUI/pictures/new_view.png and /dev/null differ
diff --git a/src/XGUI/pictures/occ_view_back.png b/src/XGUI/pictures/occ_view_back.png
deleted file mode 100644 (file)
index 51beb0c..0000000
Binary files a/src/XGUI/pictures/occ_view_back.png and /dev/null differ
diff --git a/src/XGUI/pictures/occ_view_bottom.png b/src/XGUI/pictures/occ_view_bottom.png
deleted file mode 100644 (file)
index fa558e2..0000000
Binary files a/src/XGUI/pictures/occ_view_bottom.png and /dev/null differ
diff --git a/src/XGUI/pictures/occ_view_camera_dump.png b/src/XGUI/pictures/occ_view_camera_dump.png
deleted file mode 100644 (file)
index b02616f..0000000
Binary files a/src/XGUI/pictures/occ_view_camera_dump.png and /dev/null differ
diff --git a/src/XGUI/pictures/occ_view_clone.png b/src/XGUI/pictures/occ_view_clone.png
deleted file mode 100644 (file)
index 441482d..0000000
Binary files a/src/XGUI/pictures/occ_view_clone.png and /dev/null differ
diff --git a/src/XGUI/pictures/occ_view_fitall.png b/src/XGUI/pictures/occ_view_fitall.png
deleted file mode 100644 (file)
index 87e001d..0000000
Binary files a/src/XGUI/pictures/occ_view_fitall.png and /dev/null differ
diff --git a/src/XGUI/pictures/occ_view_fitarea.png b/src/XGUI/pictures/occ_view_fitarea.png
deleted file mode 100644 (file)
index 450dc56..0000000
Binary files a/src/XGUI/pictures/occ_view_fitarea.png and /dev/null differ
diff --git a/src/XGUI/pictures/occ_view_front.png b/src/XGUI/pictures/occ_view_front.png
deleted file mode 100644 (file)
index d917960..0000000
Binary files a/src/XGUI/pictures/occ_view_front.png and /dev/null differ
diff --git a/src/XGUI/pictures/occ_view_glpan.png b/src/XGUI/pictures/occ_view_glpan.png
deleted file mode 100644 (file)
index 28ab547..0000000
Binary files a/src/XGUI/pictures/occ_view_glpan.png and /dev/null differ
diff --git a/src/XGUI/pictures/occ_view_left.png b/src/XGUI/pictures/occ_view_left.png
deleted file mode 100644 (file)
index 1b787b0..0000000
Binary files a/src/XGUI/pictures/occ_view_left.png and /dev/null differ
diff --git a/src/XGUI/pictures/occ_view_pan.png b/src/XGUI/pictures/occ_view_pan.png
deleted file mode 100644 (file)
index ec56cac..0000000
Binary files a/src/XGUI/pictures/occ_view_pan.png and /dev/null differ
diff --git a/src/XGUI/pictures/occ_view_reset.png b/src/XGUI/pictures/occ_view_reset.png
deleted file mode 100644 (file)
index 66f81e6..0000000
Binary files a/src/XGUI/pictures/occ_view_reset.png and /dev/null differ
diff --git a/src/XGUI/pictures/occ_view_right.png b/src/XGUI/pictures/occ_view_right.png
deleted file mode 100644 (file)
index 5c6e161..0000000
Binary files a/src/XGUI/pictures/occ_view_right.png and /dev/null differ
diff --git a/src/XGUI/pictures/occ_view_rotate.png b/src/XGUI/pictures/occ_view_rotate.png
deleted file mode 100644 (file)
index 28ec89f..0000000
Binary files a/src/XGUI/pictures/occ_view_rotate.png and /dev/null differ
diff --git a/src/XGUI/pictures/occ_view_top.png b/src/XGUI/pictures/occ_view_top.png
deleted file mode 100644 (file)
index cef9504..0000000
Binary files a/src/XGUI/pictures/occ_view_top.png and /dev/null differ
diff --git a/src/XGUI/pictures/occ_view_zoom.png b/src/XGUI/pictures/occ_view_zoom.png
deleted file mode 100644 (file)
index 386c966..0000000
Binary files a/src/XGUI/pictures/occ_view_zoom.png and /dev/null differ
index 909df3d18db75ef00e0791f22d9fbb89e05bad29..25ce6c649ca893612cfbb1f20a99cee8eaf8fa81 100644 (file)
Binary files a/src/XGUI/pictures/shading.png and b/src/XGUI/pictures/shading.png differ
diff --git a/src/XGUI/pictures/tile_views.png b/src/XGUI/pictures/tile_views.png
deleted file mode 100644 (file)
index fd9fece..0000000
Binary files a/src/XGUI/pictures/tile_views.png and /dev/null differ
index e500831bc66a6e3555be8fc49f2ed519ccb7f1a6..5cd73bd2fda580096b57f3edbe0bb7d21d68b0d5 100644 (file)
Binary files a/src/XGUI/pictures/wireframe.png and b/src/XGUI/pictures/wireframe.png differ
diff --git a/src/XGUI/pictures/wnd_close.png b/src/XGUI/pictures/wnd_close.png
deleted file mode 100644 (file)
index 74b9af9..0000000
Binary files a/src/XGUI/pictures/wnd_close.png and /dev/null differ
diff --git a/src/XGUI/pictures/wnd_grip.png b/src/XGUI/pictures/wnd_grip.png
deleted file mode 100644 (file)
index 032a29f..0000000
Binary files a/src/XGUI/pictures/wnd_grip.png and /dev/null differ
diff --git a/src/XGUI/pictures/wnd_maximize.png b/src/XGUI/pictures/wnd_maximize.png
deleted file mode 100644 (file)
index 3874a25..0000000
Binary files a/src/XGUI/pictures/wnd_maximize.png and /dev/null differ
diff --git a/src/XGUI/pictures/wnd_minimize.png b/src/XGUI/pictures/wnd_minimize.png
deleted file mode 100644 (file)
index f7c3f7b..0000000
Binary files a/src/XGUI/pictures/wnd_minimize.png and /dev/null differ
diff --git a/src/XGUI/pictures/wnd_restore.png b/src/XGUI/pictures/wnd_restore.png
deleted file mode 100644 (file)
index 65a123e..0000000
Binary files a/src/XGUI/pictures/wnd_restore.png and /dev/null differ
index e6aff9e6d6d7f1bd6ebac75f52e122ee674e9a2a..792304879c9c8865157ef8940bcfc0c9b161fed3 100644 (file)
Binary files a/src/XGUI/pictures/x_point.png and b/src/XGUI/pictures/x_point.png differ
index f3ee8312792b602e2bf10111b05df7644009f728..d52ed576973a6baf9fd23a068bc5015b8c4c67c3 100644 (file)
Binary files a/src/XGUI/pictures/x_size.png and b/src/XGUI/pictures/x_size.png differ
index d9658dd082f84623a7528b1da6a634e5b3d6bd7e..bdba52b88559795b99ad1fc6bd66fc2494e29b32 100644 (file)
Binary files a/src/XGUI/pictures/y_point.png and b/src/XGUI/pictures/y_point.png differ
index 9b39fda5561482538ca50576c0206386daa5e076..44752d4e2ff74da3245a780b4671e6e450f29c8b 100644 (file)
Binary files a/src/XGUI/pictures/y_size.png and b/src/XGUI/pictures/y_size.png differ
index 33fe92baac872ed2475b797706a04f929f8cf210..5bc553d2f0e24ee40b68218cfb2f8ae1cc497b99 100644 (file)
Binary files a/src/XGUI/pictures/z_point.png and b/src/XGUI/pictures/z_point.png differ
index 7ac1139985eb015f3e2161f7f25cd0f13351d97d..9a3b480ebe81c58918eb9c08f92c8e89fdaa3ae1 100644 (file)
Binary files a/src/XGUI/pictures/z_size.png and b/src/XGUI/pictures/z_size.png differ