]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
refs #30 - Sketch base GUI: create, draw lines
authornds <natalia.donis@opencascade.com>
Mon, 5 May 2014 15:16:20 +0000 (19:16 +0400)
committernds <natalia.donis@opencascade.com>
Mon, 5 May 2014 15:16:20 +0000 (19:16 +0400)
Create feature/set feature methods.

src/ModuleBase/ModuleBase_Operation.cpp
src/ModuleBase/ModuleBase_Operation.h

index 908f2f0c5d11ce91392a4ab8ca94230900d1b49d..44138fd1fb7a92e1a2a61dad900c4916d340cce7 100644 (file)
@@ -66,7 +66,7 @@ void ModuleBase_Operation::storeCustomValue()
 
 void ModuleBase_Operation::startOperation()
 {
-  createFeature();
+  setFeature(createFeature());
   //emit callSlot();
   //commit();
 }
@@ -84,10 +84,17 @@ void ModuleBase_Operation::commitOperation()
   if (myFeature) myFeature->execute();
 }
 
-void ModuleBase_Operation::createFeature()
+boost::shared_ptr<ModelAPI_Feature> ModuleBase_Operation::createFeature()
 {
   boost::shared_ptr<ModelAPI_Document> aDoc = document();
-  myFeature = aDoc->addFeature(getDescription()->operationId().toStdString());
-  if (myFeature) // TODO: generate an error if feature was not created
-    myFeature->execute();
+  boost::shared_ptr<ModelAPI_Feature> aFeature = aDoc->addFeature(
+                                           getDescription()->operationId().toStdString());
+  if (aFeature) // TODO: generate an error if feature was not created
+    aFeature->execute();
+  return aFeature;
+}
+
+void ModuleBase_Operation::setFeature(boost::shared_ptr<ModelAPI_Feature> theFeature)
+{
+  myFeature = theFeature;
 }
index 4632ad455e832f47e6fdc7a2afbb0ef32076b5cb..2f2aca0fa23a1cc3c0e2d15c77428788650ed21d 100644 (file)
@@ -70,8 +70,13 @@ protected:
   /// Virtual method called when operation committed (see commit() method for more description)
   virtual void commitOperation();
 
-  /// Creates a new feature and save it in the operation internal field
-  virtual void createFeature();
+  /// Creates an operation new feature
+  /// \returns the created feature
+  virtual boost::shared_ptr<ModelAPI_Feature> createFeature();
+
+  /// Returns the operation feature
+  /// \return the feature
+  void setFeature(boost::shared_ptr<ModelAPI_Feature> theFeature);
 
 private:
   boost::shared_ptr<ModelAPI_Feature> myFeature; /// the operation feature to be handled