]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
Issue #1343 Improvement of Extrusion and Revolution operations: sketch is filled...
authornds <nds@opencascade.com>
Fri, 18 Mar 2016 09:13:34 +0000 (12:13 +0300)
committerdbv <dbv@opencascade.com>
Wed, 6 Apr 2016 10:21:37 +0000 (13:21 +0300)
src/PartSet/PartSet_WidgetSketchCreator.cpp
src/PartSet/PartSet_WidgetSketchCreator.h
src/PartSet/PartSet_WidgetSketchLabel.cpp
src/PartSet/PartSet_WidgetSketchLabel.h

index 71069fe365f10c0bb4e79025aaf201f3eda19782..874d917b1bd4990d19aa6c678323e23297775b09 100644 (file)
@@ -6,6 +6,7 @@
 
 #include "PartSet_WidgetSketchCreator.h"
 #include "PartSet_Module.h"
+#include "PartSet_WidgetSketchLabel.h"
 
 #include <Config_Keywords.h>
 
@@ -180,7 +181,7 @@ void PartSet_WidgetSketchCreator::onSelectionChanged()
   QList<ModuleBase_ViewerPrs> aSelected = getFilteredSelected();
 
   if (aSelected.size() == 1) { // plane or planar face of not sketch object
-    startSketchOperation();
+    startSketchOperation(aSelected.front());
   }
   else if (aSelected.size() > 1) {
     QList<ModuleBase_ViewerPrs>::const_iterator anIt = aSelected.begin(), aLast = aSelected.end();
@@ -223,7 +224,7 @@ void PartSet_WidgetSketchCreator::onStarted()
   setVisibleSelectionControl(true);
 }
 
-void PartSet_WidgetSketchCreator::startSketchOperation()
+void PartSet_WidgetSketchCreator::startSketchOperation(const ModuleBase_ViewerPrs& theValue)
 {
   // Check that model already has bodies
   /*XGUI_ModuleConnector* aConnector = dynamic_cast<XGUI_ModuleConnector*>(myModule->workshop());
@@ -254,6 +255,9 @@ void PartSet_WidgetSketchCreator::startSketchOperation()
     DocumentPtr aDoc = aMgr->activeDocument();
     FeaturePtr aPreviousCurrentFeature = aDoc->currentFeature(false);
     FeaturePtr aSketch = aCompFeature->addFeature("Sketch");
+
+    PartSet_WidgetSketchLabel::fillSketchPlaneBySelection(aSketch, theValue);
+
     aDoc->setCurrentFeature(aPreviousCurrentFeature, false);
 
     // start edit operation for the sketch
index 7349d16159cefd3b2b3c1fdc1cc3a32be7a06043..e14352a0c3e3efdd7a4e073a8466cd9fdc80078e 100644 (file)
@@ -93,7 +93,8 @@ private slots:
 
 private:
   /// Append new Sketch, set the selected plane for the sketch and start Edit operation.
-  void startSketchOperation();
+  /// \param theValue a selected object to obtain a plane for sketch
+  void startSketchOperation(const ModuleBase_ViewerPrs& theValue);
 
 private:
   std::string myAttributeListID;
index 8718bf149bf848714b8e31653d5096b58f2fd0c2..81ba4a8982d930fd2854df668461291153734f32 100644 (file)
@@ -316,14 +316,20 @@ void PartSet_WidgetSketchLabel::restoreAttributeValue(const bool theValid)
 }
 
 bool PartSet_WidgetSketchLabel::setSelectionCustom(const ModuleBase_ViewerPrs& thePrs)
+{
+  return fillSketchPlaneBySelection(feature(), thePrs);
+}
+
+bool PartSet_WidgetSketchLabel::fillSketchPlaneBySelection(const FeaturePtr& theFeature,
+                                                           const ModuleBase_ViewerPrs& thePrs)
 {
   bool isOwnerSet = false;
 
   const GeomShapePtr& aShape = thePrs.shape();
   std::shared_ptr<GeomAPI_Dir> aDir;
 
-  if (thePrs.object() && (feature() != thePrs.object())) {
-    DataPtr aData = feature()->data();
+  if (thePrs.object() && (theFeature != thePrs.object())) {
+    DataPtr aData = theFeature->data();
     AttributeSelectionPtr aSelAttr = 
       std::dynamic_pointer_cast<ModelAPI_AttributeSelection>
       (aData->attribute(SketchPlugin_SketchEntity::EXTERNAL_ID()));
@@ -477,7 +483,8 @@ AISObjectPtr PartSet_WidgetSketchLabel::createPreviewPlane(std::shared_ptr<GeomA
 }
 
 
-std::shared_ptr<GeomAPI_Dir> PartSet_WidgetSketchLabel::setSketchPlane(const TopoDS_Shape& theShape)
+std::shared_ptr<GeomAPI_Dir> PartSet_WidgetSketchLabel::setSketchPlane(const FeaturePtr& theFeature,
+                                                                       const TopoDS_Shape& theShape)
 {
   if (theShape.IsNull())
     return std::shared_ptr<GeomAPI_Dir>();
@@ -494,7 +501,7 @@ std::shared_ptr<GeomAPI_Dir> PartSet_WidgetSketchLabel::setSketchPlane(const Top
     return std::shared_ptr<GeomAPI_Dir>();
 
   // set plane parameters to feature
-  std::shared_ptr<ModelAPI_Data> aData = feature()->data();
+  std::shared_ptr<ModelAPI_Data> aData = theFeature->data();
   double anA, aB, aC, aD;
   aPlane->coefficients(anA, aB, aC, aD);
 
index 90c291bcdcf56086d4b717ebdb019469f62b85b3..ff6689d1cb74bc333cb99596c50cdf544cb3581f 100644 (file)
@@ -79,6 +79,9 @@ public:
   virtual void setHighlighted(bool) { /*do nothing*/ };
   virtual void enableFocusProcessing();
 
+  static bool fillSketchPlaneBySelection(const FeaturePtr& theFeature,
+                                         const ModuleBase_ViewerPrs& thePrs);
+
 signals:
   /// Signal on plane selection
   void planeSelected(const std::shared_ptr<GeomAPI_Pln>& thePln);
@@ -163,7 +166,8 @@ protected:
 
   /// Set sketch plane by shape
   /// \param theShape a planar face
-  std::shared_ptr<GeomAPI_Dir> setSketchPlane(const TopoDS_Shape& theShape);
+  static std::shared_ptr<GeomAPI_Dir> setSketchPlane(const FeaturePtr& theFeature,
+                                                     const TopoDS_Shape& theShape);
 
   /// Erase preview planes
   void erasePreviewPlanes();