Salome HOME
Create Extrusion Cut
authorvsv <vitaly.smetannikov@opencascade.com>
Wed, 10 Jun 2015 14:44:01 +0000 (17:44 +0300)
committervsv <vitaly.smetannikov@opencascade.com>
Wed, 10 Jun 2015 14:44:01 +0000 (17:44 +0300)
src/FeaturesPlugin/extrusioncut_widget.xml
src/ModuleBase/ModuleBase_Operation.cpp
src/PartSet/PartSet_WidgetSketchCreator.cpp
src/PartSet/PartSet_WidgetSketchCreator.h

index 80f1b714c855ac9495aaf5dde893acaad66bcc15..6a974761f1503fadbaedb85398328899bb2c51d9 100755 (executable)
@@ -5,8 +5,7 @@
     <sketch_launcher id="sketch"
       label="Sketch"
       icon=":icons/sketch.png"
-      tooltip="Create or edit a sketch">
-      <validator id="GeomValidators_Face" parameters="plane"/>
+      tooltip="Create or edit a sketch">/>
     </sketch_launcher>
     <groupbox title="From">
       <shape_selector id="from_object"
index cdd43b2bf9521d4d1f72fd3b37081401b7078baf..ba23b886ec12351780db210025bd967cd9b4c55e 100644 (file)
@@ -186,8 +186,8 @@ void ModuleBase_Operation::abort()
       new Events_Message(Events_Loop::eventByName(EVENT_UPDATE_VIEWER_BLOCKED)));
   Events_Loop::loop()->send(aMsg);
 
+  SessionPtr aMgr = ModelAPI_Session::get();
   if (myIsEditing) {
-    SessionPtr aMgr = ModelAPI_Session::get();
     DocumentPtr aDoc = aMgr->activeDocument();
     bool aIsOp = aMgr->isOperation();
     if (!aIsOp)
@@ -205,7 +205,7 @@ void ModuleBase_Operation::abort()
   // because abort removes the feature and activated filters should not check it
   propertyPanel()->cleanContent();
 
-  ModelAPI_Session::get()->abortOperation();
+  aMgr->abortOperation();
   emit stopped();
   // the viewer update should be unblocked in order to avoid the features blinking before they are
   // hidden
index ffccda73aacacb7621752184a65cc454b59b393c..ac1d449d86782ac1b12548d767d33040dbd230b4 100644 (file)
@@ -14,6 +14,8 @@
 
 #include <GeomAPI_Face.h>
 
+#include <ModelAPI_Session.h>
+
 #include <ModuleBase_Tools.h>
 #include <ModuleBase_Operation.h>
 #include <ModuleBase_IPropertyPanel.h>
@@ -61,6 +63,12 @@ QList<QWidget*> PartSet_WidgetSketchCreator::getControls() const
 
 bool PartSet_WidgetSketchCreator::restoreValue()
 {
+  CompositeFeaturePtr aCompFeature = 
+    std::dynamic_pointer_cast<ModelAPI_CompositeFeature>(myFeature);
+  if (aCompFeature->numberOfSubs() > 0) {
+    FeaturePtr aSubFeature = aCompFeature->subFeature(0);
+    myTextLine->setText(QString::fromStdString(aSubFeature->data()->name()));
+  }
   return true;
 }
 
@@ -71,26 +79,18 @@ bool PartSet_WidgetSketchCreator::storeValueCustom() const
 
 void PartSet_WidgetSketchCreator::activateCustom()
 {
-  connect(myModule, SIGNAL(operationLaunched()), SLOT(onStarted()));
-
-
-  //XGUI_ModuleConnector* aConnector = dynamic_cast<XGUI_ModuleConnector*>(myModule->workshop());
-  //XGUI_Workshop* aWorkshop = aConnector->workshop();
-  //XGUI_Displayer* aDisp = aWorkshop->displayer();
-
-  //QIntList aModes;
-  //aModes << TopAbs_FACE;
-  //aDisp->activateObjects(aModes);
-  //  
-  //connect(aWorkshop->selector(), SIGNAL(selectionChanged()), this, SLOT(onSelectionChanged()));
-  //activateFilters(myModule->workshop(), true);
+  CompositeFeaturePtr aCompFeature = 
+    std::dynamic_pointer_cast<ModelAPI_CompositeFeature>(myFeature);
+  if (aCompFeature->numberOfSubs() == 0)
+    connect(myModule, SIGNAL(operationLaunched()), SLOT(onStarted()));
 }
 
 void PartSet_WidgetSketchCreator::onStarted()
 {
   disconnect(myModule, SIGNAL(operationLaunched()), this, SLOT(onStarted()));
 
-  CompositeFeaturePtr aCompFeature = std::dynamic_pointer_cast<ModelAPI_CompositeFeature>(myFeature);
+  CompositeFeaturePtr aCompFeature = 
+    std::dynamic_pointer_cast<ModelAPI_CompositeFeature>(myFeature);
   FeaturePtr aSketch = aCompFeature->addFeature("Sketch");
 
   ModuleBase_Operation* anOperation = myModule->createOperation("Sketch");
@@ -98,30 +98,19 @@ void PartSet_WidgetSketchCreator::onStarted()
   myModule->sendOperation(anOperation);
 }
 
-void PartSet_WidgetSketchCreator::storeAttributeValue()
-{
-}
-
-void PartSet_WidgetSketchCreator::restoreAttributeValue(const bool theValid)
+bool PartSet_WidgetSketchCreator::focusTo()
 {
-}
-
-bool PartSet_WidgetSketchCreator::setSelectionCustom(const ModuleBase_ViewerPrs& thePrs)
-{
-  std::shared_ptr<GeomAPI_Face> aFace(new GeomAPI_Face());
-  aFace->setImpl(new TopoDS_Shape(thePrs.shape()));
-  if (aFace->isPlanar())
-    return true;
-  //CompositeFeaturePtr aCompFeature = std::dynamic_pointer_cast<ModelAPI_CompositeFeature>(myFeature);
-  //FeaturePtr aSketch = aCompFeature->addFeature("Sketch");
-
-  //ModuleBase_Operation* anOperation = myModule->createOperation("Sketch");
-  //anOperation->setFeature(aSketch);
-  //myModule->sendOperation(anOperation);
+  CompositeFeaturePtr aCompFeature = 
+    std::dynamic_pointer_cast<ModelAPI_CompositeFeature>(myFeature);
+  if (aCompFeature->numberOfSubs() == 0)
+    return ModuleBase_ModelWidget::focusTo(); 
+
+  SessionPtr aMgr = ModelAPI_Session::get();
+  bool aIsOp = aMgr->isOperation();
+  // Open transaction if it was closed before
+  if (!aIsOp)
+    aMgr->startOperation();
+
+  restoreValue();
   return false;
-}
-
-bool PartSet_WidgetSketchCreator::setSelection(const QList<ModuleBase_ViewerPrs>& theValues, int& thePosition)
-{
-  return true;
 }
\ No newline at end of file
index 827e6d95cc7610a47c57c871661779bd9268dd06..80e45b496ffe85d3b688c6d7acff984c4de3ba4c 100644 (file)
@@ -29,36 +29,18 @@ Q_OBJECT
 
   virtual ~PartSet_WidgetSketchCreator();
 
-  /// Set the given wrapped value to the current widget
-  /// This value should be processed in the widget according to the needs
-  /// The method is called by the current operation to process the operation preselection.
-  /// It is redefined to do nothing if the plane of the sketch has been already set.
-  /// \param theValues the wrapped selection values
-  /// \param thePosition an index in the list of values, the values should be get from the index
-  virtual bool setSelection(const QList<ModuleBase_ViewerPrs>& theValues, int& thePosition);
-
   virtual bool restoreValue();
 
   /// Returns list of widget controls
   /// \return a control list
   virtual QList<QWidget*> getControls() const;
 
-protected:
-  /// Creates a backup of the current values of the attribute
-  /// It should be realized in the specific widget because of different
-  /// parameters of the current attribute
-  virtual void storeAttributeValue();
-
-  /// Creates a backup of the current values of the attribute
-  /// It should be realized in the specific widget because of different
-  /// parameters of the current attribute
-  /// \param theValid a boolean flag, if restore happens for valid parameters
-  virtual void restoreAttributeValue(const bool theValid);
-
-  /// Fills the attribute with the value of the selected owner
-  /// \param theOwner a selected owner
-  virtual bool setSelectionCustom(const ModuleBase_ViewerPrs& thePrs);
+  /// Set focus to the first control of the current widget. The focus policy of the control is checked.
+  /// If the widget has the NonFocus focus policy, it is skipped.
+  /// \return the state whether the widget can accept the focus
+  virtual bool focusTo();
 
+protected:
   /// Saves the internal parameters to the given feature
   /// \return True in success
   virtual bool storeValueCustom() const;