]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
ExtrusionCut launch
authorvsv <vitaly.smetannikov@opencascade.com>
Tue, 9 Jun 2015 15:07:29 +0000 (18:07 +0300)
committervsv <vitaly.smetannikov@opencascade.com>
Tue, 9 Jun 2015 15:09:23 +0000 (18:09 +0300)
16 files changed:
src/FeaturesPlugin/FeaturesPlugin_Extrusion.cpp
src/FeaturesPlugin/FeaturesPlugin_ExtrusionCut.cpp
src/FeaturesPlugin/FeaturesPlugin_ExtrusionCut.h
src/FeaturesPlugin/extrusioncut_widget.xml
src/ModuleBase/ModuleBase_IModule.cpp
src/ModuleBase/ModuleBase_IModule.h
src/PartSet/CMakeLists.txt
src/PartSet/PartSet_Module.cpp
src/PartSet/PartSet_Module.h
src/PartSet/PartSet_SketcherMgr.cpp
src/PartSet/PartSet_WidgetSketchCreator.cpp [new file with mode: 0644]
src/PartSet/PartSet_WidgetSketchCreator.h [new file with mode: 0644]
src/PartSet/PartSet_WidgetSketchLabel.cpp
src/XGUI/XGUI_PropertyPanel.cpp
src/XGUI/XGUI_Workshop.cpp
src/XGUI/XGUI_Workshop.h

index 1decb449c2ebb77ed1bdd4a67ffa1312a507d4b1..7fd7c13017cb9eed0c3d886f2081a3712240f43e 100644 (file)
@@ -44,8 +44,6 @@ void FeaturesPlugin_Extrusion::initAttributes()
   data()->addAttribute(FeaturesPlugin_Extrusion::TO_SIZE_ID(), ModelAPI_AttributeDouble::typeId());
   data()->addAttribute(FeaturesPlugin_Extrusion::FROM_SIZE_ID(), ModelAPI_AttributeDouble::typeId());
 
-  //data()->addAttribute(FeaturesPlugin_Extrusion::AXIS_OBJECT_ID(), ModelAPI_AttributeReference::typeId());
-
   data()->addAttribute(FeaturesPlugin_Extrusion::FROM_OBJECT_ID(), ModelAPI_AttributeSelection::typeId());
   data()->addAttribute(FeaturesPlugin_Extrusion::TO_OBJECT_ID(), ModelAPI_AttributeSelection::typeId());
 
index cfd5b5d567fa2d584785b4ed8b19fa60d5b4cfaf..09d56a48671f14f59a05d69dbcf5c858a93ebb1c 100755 (executable)
@@ -11,6 +11,8 @@
 #include <ModelAPI_AttributeReference.h>
 #include <ModelAPI_Validator.h>
 #include <ModelAPI_Session.h>
+#include <ModelAPI_Data.h>
+#include <ModelAPI_AttributeRefList.h>
 
 //=================================================================================================
 FeaturesPlugin_ExtrusionCut::FeaturesPlugin_ExtrusionCut()
@@ -20,26 +22,74 @@ FeaturesPlugin_ExtrusionCut::FeaturesPlugin_ExtrusionCut()
 //=================================================================================================
 void FeaturesPlugin_ExtrusionCut::initAttributes()
 {
-  data()->addAttribute(FeaturesPlugin_ExtrusionCut::SKETCH_OBJECT_ID(), ModelAPI_AttributeReference::typeId());
 
-  data()->addAttribute(FeaturesPlugin_ExtrusionCut::TO_SIZE_ID(), ModelAPI_AttributeDouble::typeId());
-  data()->addAttribute(FeaturesPlugin_ExtrusionCut::FROM_SIZE_ID(), ModelAPI_AttributeDouble::typeId());
+  data()->addAttribute(SKETCH_OBJECT_ID(), ModelAPI_AttributeReference::typeId());
 
-  data()->addAttribute(FeaturesPlugin_ExtrusionCut::AXIS_OBJECT_ID(), ModelAPI_AttributeReference::typeId());
+  data()->addAttribute(FROM_OBJECT_ID(), ModelAPI_AttributeSelection::typeId());
+  data()->addAttribute(FROM_SIZE_ID(), ModelAPI_AttributeDouble::typeId());
 
-  data()->addAttribute(FeaturesPlugin_ExtrusionCut::FROM_OBJECT_ID(), ModelAPI_AttributeSelection::typeId());
-  data()->addAttribute(FeaturesPlugin_ExtrusionCut::TO_OBJECT_ID(), ModelAPI_AttributeSelection::typeId());
+  data()->addAttribute(TO_OBJECT_ID(), ModelAPI_AttributeSelection::typeId());
+  data()->addAttribute(TO_SIZE_ID(), ModelAPI_AttributeDouble::typeId());
 
   ModelAPI_Session::get()->validators()->registerNotObligatory(getKind(), FeaturesPlugin_ExtrusionCut::FROM_OBJECT_ID());
   ModelAPI_Session::get()->validators()->registerNotObligatory(getKind(), FeaturesPlugin_ExtrusionCut::TO_OBJECT_ID());
 
-  AttributeSelectionListPtr aSelection = 
-    std::dynamic_pointer_cast<ModelAPI_AttributeSelectionList>(data()->addAttribute(
-    FeaturesPlugin_ExtrusionCut::LIST_ID(), ModelAPI_AttributeSelectionList::typeId()));
+  data()->addAttribute(CUTLIST_ID(), ModelAPI_AttributeSelectionList::typeId());
+
   // extrusion works with faces always
+  AttributeSelectionListPtr aSelection = data()->selectionList(CUTLIST_ID());
   aSelection->setSelectionType("SOLID");
 }
 
+
+std::shared_ptr<ModelAPI_Feature> FeaturesPlugin_ExtrusionCut::addFeature(std::string theID)
+{
+  std::shared_ptr<ModelAPI_Feature> aNew = document()->addFeature(theID, false);
+  if (aNew) {
+    data()->reference(SKETCH_OBJECT_ID())->setValue(aNew);
+  }
+   // set as current also after it becomes sub to set correctly enabled for other sketch subs
+  //document()->setCurrentFeature(aNew, false);
+  return aNew;
+}
+
+  
+int FeaturesPlugin_ExtrusionCut::numberOfSubs() const
+{
+  ObjectPtr aObj = data()->reference(SKETCH_OBJECT_ID())->value();
+  return aObj.get()? 1 : 0;
+}
+
+std::shared_ptr<ModelAPI_Feature> FeaturesPlugin_ExtrusionCut::subFeature(const int theIndex) const
+{
+  if (theIndex == 0)
+    return std::dynamic_pointer_cast<ModelAPI_Feature>(data()->reference(SKETCH_OBJECT_ID())->value());
+  return std::shared_ptr<ModelAPI_Feature>();
+}
+
+int FeaturesPlugin_ExtrusionCut::subFeatureId(const int theIndex) const
+{
+  std::shared_ptr<ModelAPI_Feature> aFeature = subFeature(theIndex);
+  if (aFeature.get())
+    return aFeature->data()->featureId();
+  return -1;
+}
+
+bool FeaturesPlugin_ExtrusionCut::isSub(ObjectPtr theObject) const
+{
+  // check is this feature of result
+  FeaturePtr aFeature = std::dynamic_pointer_cast<ModelAPI_Feature>(theObject);
+  if (!aFeature)
+    return false;
+  ObjectPtr aSub = data()->reference(SKETCH_OBJECT_ID())->value();
+  return aSub == theObject;
+}
+
+void FeaturesPlugin_ExtrusionCut::removeFeature(std::shared_ptr<ModelAPI_Feature> theFeature)
+{
+}
+
 //=================================================================================================
 void FeaturesPlugin_ExtrusionCut::execute()
 {
index 8285682ee50dc48125f15feb40792a79c35e11e9..650a6bcc0d7994e60bbfb4f1cbc000adf2411122 100755 (executable)
@@ -9,12 +9,12 @@
 
 #include <FeaturesPlugin.h>
 
-#include <ModelAPI_Feature.h>
+#include <ModelAPI_CompositeFeature.h>
 
 /** \class FeaturesPlugin_ExtrusionCut
  *  \ingroup Plugins
  */
-class FeaturesPlugin_ExtrusionCut : public ModelAPI_Feature
+class FeaturesPlugin_ExtrusionCut : public ModelAPI_CompositeFeature
 {
  public:
   /// Revolution kind.
@@ -26,10 +26,10 @@ class FeaturesPlugin_ExtrusionCut : public ModelAPI_Feature
 
   /// attribute name of references sketch entities list, it should contain a sketch result or
   /// a pair a sketch result to sketch face
-  inline static const std::string& LIST_ID()
+  inline static const std::string& CUTLIST_ID()
   {
-    static const std::string MY_GROUP_LIST_ID("main_objects");
-    return MY_GROUP_LIST_ID;
+    static const std::string MY_CUT_LIST_ID("cut_objects");
+    return MY_CUT_LIST_ID;
   }
 
   /// attribute name of an object to which the extrusion grows
@@ -39,13 +39,6 @@ class FeaturesPlugin_ExtrusionCut : public ModelAPI_Feature
     return MY_TO_OBJECT_ID;
   }
 
-  /// Attribute name of an object to which the extrusion grows.
-  inline static const std::string& AXIS_OBJECT_ID()
-  {
-    static const std::string MY_TO_OBJECT_ID("axis_object");
-    return MY_TO_OBJECT_ID;
-  }
-
   /// attribute name of extrusion size
   inline static const std::string& TO_SIZE_ID()
   {
@@ -53,13 +46,6 @@ class FeaturesPlugin_ExtrusionCut : public ModelAPI_Feature
     return MY_TO_SIZE_ID;
   }
 
-  /// attribute name of extrusion size
-  inline static const std::string& FROM_SIZE_ID()
-  {
-    static const std::string MY_FROM_SIZE_ID("from_size");
-    return MY_FROM_SIZE_ID;
-  }
-
   /// attribute name of an object to which the extrusion grows
   inline static const std::string& TO_OBJECT_ID()
   {
@@ -74,6 +60,13 @@ class FeaturesPlugin_ExtrusionCut : public ModelAPI_Feature
     return MY_FROM_OBJECT_ID;
   }
 
+  /// attribute name of extrusion size
+  inline static const std::string& FROM_SIZE_ID()
+  {
+    static const std::string MY_FROM_SIZE_ID("from_size");
+    return MY_FROM_SIZE_ID;
+  }
+
   /// Returns the kind of a feature
   FEATURESPLUGIN_EXPORT virtual const std::string& getKind()
   {
@@ -89,6 +82,25 @@ class FeaturesPlugin_ExtrusionCut : public ModelAPI_Feature
 
   /// Use plugin manager for features creation.
   FeaturesPlugin_ExtrusionCut();
+
+  /// appends a feature to the sketch sub-elements container
+  FEATURESPLUGIN_EXPORT virtual std::shared_ptr<ModelAPI_Feature> addFeature(std::string theID);
+  
+  /// Returns the number of sub-elements
+  FEATURESPLUGIN_EXPORT virtual int numberOfSubs() const;
+
+  /// Returns the sub-feature by zero-base index
+  FEATURESPLUGIN_EXPORT virtual std::shared_ptr<ModelAPI_Feature> subFeature(const int theIndex) const;
+
+  /// Returns the sub-feature unique identifier in this composite feature by zero-base index
+  FEATURESPLUGIN_EXPORT virtual int subFeatureId(const int theIndex) const;
+
+  /// Returns true if feature or reuslt belong to this composite feature as subs
+  FEATURESPLUGIN_EXPORT virtual bool isSub(ObjectPtr theObject) const;
+
+  /// This method to inform that sub-feature is removed and must be removed from the internal data
+  /// structures of the owner (the remove from the document will be done outside just after)
+  FEATURESPLUGIN_EXPORT virtual void removeFeature(std::shared_ptr<ModelAPI_Feature> theFeature);
 };
 
 #endif
index dc541d1cc5738138efc943f73a2895c272240d52..80f1b714c855ac9495aaf5dde893acaad66bcc15 100755 (executable)
@@ -2,13 +2,12 @@
 
 <source>
   <groupbox title="Extrusion">
-    <shape_selector id="main_objects"
-      label="Select a planar face"
+    <sketch_launcher id="sketch"
+      label="Sketch"
       icon=":icons/sketch.png"
-      tooltip="Select a destination element"
-      shape_types="face edge vertex"
-      default="&lt;sketch&gt;"
-    />
+      tooltip="Create or edit a sketch">
+      <validator id="GeomValidators_Face" parameters="plane"/>
+    </sketch_launcher>
     <groupbox title="From">
       <shape_selector id="from_object"
                       icon=":icons/plane.png"
                       default="&lt;sketch&gt;">
         <validator id="GeomValidators_Face" parameters="plane"/>
       </shape_selector>
-      <doublevalue
-        id="from_size"
-        label="Size"
-        min="0"
-        step="1.0"
-        default="0"
+      <doublevalue id="from_size" label="Size"
+        min="0" step="1.0" default="0"
         icon=":icons/dimension_down.png"
         tooltip="Height">
       </doublevalue>
                       default="&lt;sketch&gt;">
         <validator id="GeomValidators_Face" parameters="plane"/>
       </shape_selector>
-      <doublevalue
-        id="to_size"
-        label="Size"
-        min="0"
-        step="1.0"
-        default="0"
+      <doublevalue  id="to_size"
+        label="Size" min="0" step="1.0" default="0"
         icon=":icons/dimension_up.png"
         tooltip="Height">
       </doublevalue>
     </groupbox>
   </groupbox>
-  <multi_selector id="main_objects"
+  <multi_selector id="cut_objects"
     label="Cut from:"
     icon=":icons/cut_shape.png"
     tooltip="Objects to Cut"
index 5aba16c4cb19378dd3b6f718ab6ed8b8e0b4207b..66c3debd7c0695a4ecb4dcd2bcd3e24bc23b161d 100644 (file)
@@ -135,6 +135,7 @@ void ModuleBase_IModule::onFeatureTriggered()
   if (aCmd->isCheckable() && !aCmd->isChecked())
     return;
   launchOperation(aCmd->data().toString());
+  emit operationLaunched();
 }
 
 
index 81652a0b3011811a5d609c365593a74e70407536..435d2c5b96939098c016fa8244b6bd89f4d9facb 100644 (file)
@@ -137,6 +137,17 @@ class MODULEBASE_EXPORT ModuleBase_IModule : public QObject
   /// \param theObjectBrowser a pinter on Object Browser widget\r
   virtual void customizeObjectBrowser(QWidget* theObjectBrowser) {}\r
 \r
+  /// Creates a new operation\r
+  /// \param theCmdId the operation name\r
+  virtual ModuleBase_Operation* createOperation(const std::string& theCmdId);\r
+\r
+  /// Sends the operation for launching\r
+  /// \param theOperation the operation\r
+  virtual void sendOperation(ModuleBase_Operation* theOperation);\r
+\r
+signals:\r
+  void operationLaunched();\r
+\r
 public slots:\r
   /// Called on call of command corresponded to a feature\r
   virtual void onFeatureTriggered();\r
@@ -156,14 +167,6 @@ protected slots:
   virtual void onSelectionChanged() {}\r
 \r
  protected:\r
-  /// Sends the operation for launching\r
-  /// \param theOperation the operation\r
-  virtual void sendOperation(ModuleBase_Operation* theOperation);\r
-\r
-  /// Creates a new operation\r
-  /// \param theCmdId the operation name\r
-  virtual ModuleBase_Operation* createOperation(const std::string& theCmdId);\r
-\r
   /// Register validators for this module\r
   virtual void registerValidators() {}\r
 \r
index 8c69ea96b1017673d68e69fa75d4b2277e5bc667..5a243ebfbb32664d6ea5ff4321b4bfc5ebb0e6a4 100644 (file)
@@ -25,6 +25,7 @@ SET(PROJECT_HEADERS
     PartSet_DocumentDataModel.h
     PartSet_PartDataModel.h
     PartSet_DataTreeModel.h
+       PartSet_WidgetSketchCreator.h
 )
 
 SET(PROJECT_SOURCES
@@ -45,6 +46,7 @@ SET(PROJECT_SOURCES
        PartSet_MenuMgr.cpp
     PartSet_DocumentDataModel.cpp
     PartSet_PartDataModel.cpp
+       PartSet_WidgetSketchCreator.cpp
 )
 
 SET(PROJECT_RESOURCES 
index ce055596907252ef8db18aba9684dda1582e4be5..b6d90bd0c39f73f7552ca1a870370ee01dc9777b 100644 (file)
@@ -11,6 +11,7 @@
 #include "PartSet_WidgetMultiSelector.h"
 #include "PartSet_WidgetEditor.h"
 #include "PartSet_WidgetFileSelector.h"
+#include "PartSet_WidgetSketchCreator.h"
 #include "PartSet_SketcherMgr.h"
 #include "PartSet_MenuMgr.h"
 
@@ -514,7 +515,9 @@ ModuleBase_ModelWidget* PartSet_Module::createWidgetByType(const std::string& th
     aWgt = new PartSet_WidgetEditor(theParent, workshop(), theWidgetApi, theParentId);
   } else if (theType == "export_file_selector") {
     aWgt = new PartSet_WidgetFileSelector(theParent, workshop(), theWidgetApi, theParentId);
-  } 
+  } else if (theType == "sketch_launcher") {
+    aWgt = new PartSet_WidgetSketchCreator(theParent, this, theWidgetApi, theParentId);
+  }
   return aWgt;
 }
 
index e4388e0bbe0b17cfc317d7c28c8af8903ddb34f1..1228a03ba06b0ff87e77345630eb8cf130435c9b 100644 (file)
@@ -138,6 +138,10 @@ public:
   /// \param theObjectBrowser a pinter on Object Browser widget
   virtual void customizeObjectBrowser(QWidget* theObjectBrowser);
 
+  /// Sends the operation for launching
+  /// \param theOperation the operation
+  virtual void sendOperation(ModuleBase_Operation* theOperation);
+
 public slots:
   /// SLOT, that is called by no more widget signal emitted by property panel
   /// Set a specific flag to restart the sketcher operation
@@ -180,10 +184,6 @@ protected slots:
   /// Register properties of this module
   virtual void registerProperties();
 
-  /// Sends the operation for launching
-  /// \param theOperation the operation
-  virtual void sendOperation(ModuleBase_Operation* theOperation);
-
  private slots:
    /// Processing of vertex selected
    void onVertexSelected();
index a4c9cf1c8993f006c79ec03f74f7bd731c295a7e..a086aa8685b0dafb1caa80733939b1a2c7697f6b 100644 (file)
@@ -719,7 +719,8 @@ void PartSet_SketcherMgr::startSketch(ModuleBase_Operation* theOperation)
   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 (aPln.get())
+      myPlaneFilter->setPlane(aPln->impl<gp_Pln>());
   }
   Events_Loop::loop()->flush(Events_Loop::eventByName(EVENT_OBJECT_TO_REDISPLAY));
   // all sketch objects should be activated in the sketch selection modes by edit operation start
diff --git a/src/PartSet/PartSet_WidgetSketchCreator.cpp b/src/PartSet/PartSet_WidgetSketchCreator.cpp
new file mode 100644 (file)
index 0000000..ffccda7
--- /dev/null
@@ -0,0 +1,127 @@
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
+// File:        PartSet_WidgetSketchCreator.cpp
+// Created:     08 June 2015
+// Author:      Vitaly SMETANNIKOV
+
+#include "PartSet_WidgetSketchCreator.h"
+#include "PartSet_Module.h"
+
+#include <XGUI_ModuleConnector.h>
+#include <XGUI_Workshop.h>
+#include <XGUI_Displayer.h>
+#include <XGUI_SelectionMgr.h>
+
+#include <GeomAPI_Face.h>
+
+#include <ModuleBase_Tools.h>
+#include <ModuleBase_Operation.h>
+#include <ModuleBase_IPropertyPanel.h>
+#include <Config_WidgetAPI.h>
+
+#include <QLabel>
+#include <QLineEdit>
+#include <QFormLayout>
+
+PartSet_WidgetSketchCreator::PartSet_WidgetSketchCreator(QWidget* theParent, 
+                                                         PartSet_Module* theModule,
+                                                         const Config_WidgetAPI* theData,
+                                                         const std::string& theParentId)
+: ModuleBase_ModelWidget(theParent, theData, theParentId), myModule(theModule)
+{
+  QFormLayout* aLayout = new QFormLayout(this);
+  ModuleBase_Tools::adjustMargins(aLayout);
+
+  QString aLabelText = QString::fromStdString(theData->widgetLabel());
+  QString aLabelIcon = QString::fromStdString(theData->widgetIcon());
+  myLabel = new QLabel(aLabelText, this);
+  if (!aLabelIcon.isEmpty())
+    myLabel->setPixmap(QPixmap(aLabelIcon));
+
+
+  QString aToolTip = QString::fromStdString(theData->widgetTooltip());
+  myTextLine = new QLineEdit(this);
+  myTextLine->setReadOnly(true);
+  myTextLine->setToolTip(aToolTip);
+  myTextLine->installEventFilter(this);
+
+  aLayout->addRow(myLabel, myTextLine);
+}
+
+PartSet_WidgetSketchCreator::~PartSet_WidgetSketchCreator()
+{
+}
+
+QList<QWidget*> PartSet_WidgetSketchCreator::getControls() const
+{
+  QList<QWidget*> aControls;
+  aControls.append(myTextLine);
+  return aControls;
+}
+
+bool PartSet_WidgetSketchCreator::restoreValue()
+{
+  return true;
+}
+
+bool PartSet_WidgetSketchCreator::storeValueCustom() const
+{
+  return true;
+}
+
+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);
+}
+
+void PartSet_WidgetSketchCreator::onStarted()
+{
+  disconnect(myModule, SIGNAL(operationLaunched()), this, SLOT(onStarted()));
+
+  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);
+}
+
+void PartSet_WidgetSketchCreator::storeAttributeValue()
+{
+}
+
+void PartSet_WidgetSketchCreator::restoreAttributeValue(const bool theValid)
+{
+}
+
+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);
+  return false;
+}
+
+bool PartSet_WidgetSketchCreator::setSelection(const QList<ModuleBase_ViewerPrs>& theValues, int& thePosition)
+{
+  return true;
+}
\ No newline at end of file
diff --git a/src/PartSet/PartSet_WidgetSketchCreator.h b/src/PartSet/PartSet_WidgetSketchCreator.h
new file mode 100644 (file)
index 0000000..827e6d9
--- /dev/null
@@ -0,0 +1,84 @@
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
+// File:        PartSet_WidgetSketchCreator.h
+// Created:     08 June 2015
+// Author:      Vitaly SMETANNIKOV
+
+#ifndef PartSet_WidgetSketchCreator_H
+#define PartSet_WidgetSketchCreator_H
+
+#include "PartSet.h"
+
+#include <ModuleBase_ModelWidget.h>
+
+class QLabel;
+class QLineEdit;
+class PartSet_Module;
+class ModuleBase_Operation;
+
+class PARTSET_EXPORT PartSet_WidgetSketchCreator : public ModuleBase_ModelWidget
+{
+Q_OBJECT
+ public:
+  /// Constructor
+  /// \param theParent the parent object
+  /// \param theData the widget configuation. The attribute of the model widget is obtained from
+  /// \param theParentId is Id of a parent of the current attribute
+  PartSet_WidgetSketchCreator(QWidget* theParent, PartSet_Module* theModule, 
+    const Config_WidgetAPI* theData, const std::string& theParentId);
+
+  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);
+
+  /// Saves the internal parameters to the given feature
+  /// \return True in success
+  virtual bool storeValueCustom() const;
+
+  /// The methiod called when widget is activated
+  virtual void activateCustom();
+
+private slots:
+  void onStarted();
+
+private:
+
+  PartSet_Module* myModule;
+
+  /// Label of the widget
+  QLabel* myLabel;
+
+  /// Input control of the widget
+  QLineEdit* myTextLine;
+
+};
+
+#endif
\ No newline at end of file
index 0b4b6b9466a1fddd06ceaed545c90f9d1be98dde..82b234fff5363f5fef6b90dbd1230a2407d6fab8 100644 (file)
@@ -354,11 +354,13 @@ std::shared_ptr<GeomAPI_Dir> PartSet_WidgetSketchLabel::setSketchPlane(const Top
 {
   if (theShape.IsNull())
     return std::shared_ptr<GeomAPI_Dir>();
-
+  int aType = theShape.ShapeType();
   // 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);
 
index 26ea5d021e587ad4a7a5820c1b3373a5e38bdb2f..6c53bb84347606c4d75a1f198e59bced1f1cec01 100644 (file)
@@ -132,7 +132,8 @@ void XGUI_PropertyPanel::updateContentWidget(FeaturePtr theFeature)
   if (theFeature->isAction() || !theFeature->data())
     return;
   foreach(ModuleBase_ModelWidget* eachWidget, myWidgets) {
-    eachWidget->setFeature(theFeature);
+    if (!eachWidget->feature().get())
+      eachWidget->setFeature(theFeature);
     eachWidget->restoreValue();
   }
   // the repaint is used here to immediately react in GUI to the values change.
index 2c4e2fdcb1585abe73557767e412cdd264408455..94ff9d955d9a8502c12ebda6283eaebb87df6a51 100644 (file)
@@ -1206,15 +1206,15 @@ void XGUI_Workshop::hideObjectBrowser()
 }
 
 //******************************************************
-void XGUI_Workshop::onFeatureTriggered()
-{
-  QAction* aCmd = dynamic_cast<QAction*>(sender());
-  if (aCmd) {
-    QString aId = salomeConnector()->commandId(aCmd);
-    if (!aId.isNull())
-      myModule->launchOperation(aId);
-  }
-}
+//void XGUI_Workshop::onFeatureTriggered()
+//{
+//  QAction* aCmd = dynamic_cast<QAction*>(sender());
+//  if (aCmd) {
+//    QString aId = salomeConnector()->commandId(aCmd);
+//    if (!aId.isNull())
+//      myModule->launchOperation(aId);
+//  }
+//}
 
 //******************************************************
 void XGUI_Workshop::salomeViewerSelectionChanged()
index ea4190af074fdd1ce82891cb4d93f05a930995de..f6d1cb7c8c67f260309d8410e41deccb6d053dd4 100644 (file)
@@ -234,6 +234,7 @@ signals:
 
   //! Signal to update Undo history list
   void updateUndoHistory(const QList<ActionInfo>&);
+
   //! Signal to update Redo history list
   void updateRedoHistory(const QList<ActionInfo>&);
 
@@ -284,7 +285,7 @@ signals:
   void hideObjectBrowser();
 
   /// Reaction on command call
-  void onFeatureTriggered();
+  //void onFeatureTriggered();
 
   /// Close document
   void closeDocument();