]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
Merge branch 'master' of newgeom:newgeom
authormpv <mikhail.ponikarov@opencascade.com>
Mon, 8 Sep 2014 13:51:25 +0000 (17:51 +0400)
committermpv <mikhail.ponikarov@opencascade.com>
Mon, 8 Sep 2014 13:51:25 +0000 (17:51 +0400)
13 files changed:
src/FeaturesPlugin/FeaturesPlugin_Extrusion.cpp
src/ModuleBase/ModuleBase_WidgetPoint2D.cpp
src/SketchPlugin/SketchPlugin_ConstraintDistance.cpp
src/SketchPlugin/SketchPlugin_ConstraintLength.cpp
src/SketchPlugin/SketchPlugin_ConstraintRadius.cpp
src/SketchPlugin/plugin-Sketch.xml
src/XGUI/XGUI_ContextMenuMgr.cpp
src/XGUI/XGUI_Displayer.cpp
src/XGUI/XGUI_Displayer.h
src/XGUI/XGUI_OperationMgr.cpp
src/XGUI/XGUI_OperationMgr.h
src/XGUI/XGUI_Workshop.cpp
src/XGUI/XGUI_Workshop.h

index 7c6a0eaebb82f4763ebcd333163a2e127c346648..1fb6e46d58089ea69e474bbf0f0daa8fff9bcecc 100644 (file)
@@ -33,12 +33,20 @@ void FeaturesPlugin_Extrusion::execute()
       ModelAPI_AttributeReference>(data()->attribute(FeaturesPlugin_Extrusion::FACE_ID()));
   if (!aFaceRef)
     return;
+  boost::shared_ptr<GeomAPI_Shape> aFace;
   boost::shared_ptr<ModelAPI_ResultConstruction> aConstr = boost::dynamic_pointer_cast<
       ModelAPI_ResultConstruction>(aFaceRef->value());
-  if (!aConstr)
-    return;
-  boost::shared_ptr<GeomAPI_Shape> aFace = aConstr->shape();
-  if (!aFace)
+  if (aConstr) {
+    aFace = aConstr->shape();
+  }
+  if (!aFace) {
+    // Check for body
+    boost::shared_ptr<ModelAPI_ResultBody> aBody = boost::dynamic_pointer_cast<
+        ModelAPI_ResultBody>(aFaceRef->value());
+    if (aBody) 
+      aFace = aBody->shape();
+  }
+  if (!aFace) 
     return;
 
   double aSize = data()->real(FeaturesPlugin_Extrusion::SIZE_ID())->value();
index 157ccb45d74fd5737bcdfd4387bc2dd7a2c090cc..5e447ef1deeeaa74f9fd8cc17ccc4dba815d6e4a 100644 (file)
@@ -110,8 +110,6 @@ bool ModuleBase_WidgetPoint2D::storeValue() const
 
   ModuleBase_WidgetPoint2D* that = (ModuleBase_WidgetPoint2D*) this;
   bool isBlocked = that->blockSignals(true);
-  double aX = myXSpin->value();
-  double aY = myYSpin->value();
   aPoint->setValue(myXSpin->value(), myYSpin->value());
   updateObject(myFeature);
   that->blockSignals(isBlocked);
index e8ea4bfbed0c10497c1a1b40e82b36023e3b74cf..97a08e13403e3f60850dd654e88b9b832bfeb917 100644 (file)
@@ -36,26 +36,24 @@ void SketchPlugin_ConstraintDistance::execute()
   AttributeDoublePtr anAttr_Value = boost::dynamic_pointer_cast<ModelAPI_AttributeDouble>(
       aData->attribute(SketchPlugin_Constraint::VALUE()));
 
-  if (!anAttr_Value->isInitialized()) {
-    boost::shared_ptr<GeomDataAPI_Point2D> aPoint_A = getFeaturePoint(
-        aData, SketchPlugin_Constraint::ENTITY_A());
-    boost::shared_ptr<GeomDataAPI_Point2D> aPoint_B = getFeaturePoint(
-        aData, SketchPlugin_Constraint::ENTITY_B());
+  boost::shared_ptr<GeomDataAPI_Point2D> aPoint_A = getFeaturePoint(
+      aData, SketchPlugin_Constraint::ENTITY_A());
+  boost::shared_ptr<GeomDataAPI_Point2D> aPoint_B = getFeaturePoint(
+      aData, SketchPlugin_Constraint::ENTITY_B());
 
-    if (aPoint_A && aPoint_B) {  // both points
-      anAttr_Value->setValue(aPoint_A->pnt()->distance(aPoint_B->pnt()));
-    } else {
-      if (!aPoint_A && aPoint_B) {  //Line and point
-        boost::shared_ptr<SketchPlugin_Line> aLine = getFeatureLine(
-            aData, SketchPlugin_Constraint::ENTITY_A());
-        if (aLine)
-          anAttr_Value->setValue(aLine->distanceToPoint(aPoint_B->pnt()));
-      } else if (aPoint_A && !aPoint_B) {  // Point and line
-        boost::shared_ptr<SketchPlugin_Line> aLine = getFeatureLine(
-            aData, SketchPlugin_Constraint::ENTITY_B());
-        if (aLine)
-          anAttr_Value->setValue(aLine->distanceToPoint(aPoint_A->pnt()));
-      }
+  if (aPoint_A && aPoint_B) {  // both points
+    anAttr_Value->setValue(aPoint_A->pnt()->distance(aPoint_B->pnt()));
+  } else {
+    if (!aPoint_A && aPoint_B) {  //Line and point
+      boost::shared_ptr<SketchPlugin_Line> aLine = getFeatureLine(
+          aData, SketchPlugin_Constraint::ENTITY_A());
+      if (aLine)
+        anAttr_Value->setValue(aLine->distanceToPoint(aPoint_B->pnt()));
+    } else if (aPoint_A && !aPoint_B) {  // Point and line
+      boost::shared_ptr<SketchPlugin_Line> aLine = getFeatureLine(
+          aData, SketchPlugin_Constraint::ENTITY_B());
+      if (aLine)
+        anAttr_Value->setValue(aLine->distanceToPoint(aPoint_A->pnt()));
     }
   }
 }
index 94f23ae872d71596462cfc77dc844f7ee91c4cbf..e7ed5411ccb608c54e03e606d0b20b994ed4c0dd 100644 (file)
@@ -31,25 +31,21 @@ void SketchPlugin_ConstraintLength::initAttributes()
 
 void SketchPlugin_ConstraintLength::execute()
 {
-  if (data()->attribute(SketchPlugin_Constraint::ENTITY_A())->isInitialized()
-      && !data()->attribute(SketchPlugin_Constraint::VALUE())->isInitialized()) {
-
-    boost::shared_ptr<ModelAPI_AttributeRefAttr> aRef = boost::dynamic_pointer_cast<
-        ModelAPI_AttributeRefAttr>(data()->attribute(SketchPlugin_Constraint::ENTITY_A()));
-    FeaturePtr aFeature = ModelAPI_Feature::feature(aRef->object());
-    if (aFeature) {
-      // set length value
-      boost::shared_ptr<GeomDataAPI_Point2D> aPoint1 = boost::dynamic_pointer_cast<
-          GeomDataAPI_Point2D>(aFeature->data()->attribute(SketchPlugin_Line::START_ID()));
-      boost::shared_ptr<GeomDataAPI_Point2D> aPoint2 = boost::dynamic_pointer_cast<
-          GeomDataAPI_Point2D>(aFeature->data()->attribute(SketchPlugin_Line::END_ID()));
-
-      double aLenght = aPoint1->pnt()->distance(aPoint2->pnt());
-
-      boost::shared_ptr<ModelAPI_AttributeDouble> aValueAttr = boost::dynamic_pointer_cast<
-          ModelAPI_AttributeDouble>(data()->attribute(SketchPlugin_Constraint::VALUE()));
-      aValueAttr->setValue(aLenght);
-    }
+  boost::shared_ptr<ModelAPI_AttributeRefAttr> aRef = boost::dynamic_pointer_cast<
+      ModelAPI_AttributeRefAttr>(data()->attribute(SketchPlugin_Constraint::ENTITY_A()));
+  FeaturePtr aFeature = ModelAPI_Feature::feature(aRef->object());
+  if (aFeature) {
+    // set length value
+    boost::shared_ptr<GeomDataAPI_Point2D> aPoint1 = boost::dynamic_pointer_cast<
+        GeomDataAPI_Point2D>(aFeature->data()->attribute(SketchPlugin_Line::START_ID()));
+    boost::shared_ptr<GeomDataAPI_Point2D> aPoint2 = boost::dynamic_pointer_cast<
+        GeomDataAPI_Point2D>(aFeature->data()->attribute(SketchPlugin_Line::END_ID()));
+
+    double aLenght = aPoint1->pnt()->distance(aPoint2->pnt());
+
+    boost::shared_ptr<ModelAPI_AttributeDouble> aValueAttr = boost::dynamic_pointer_cast<
+        ModelAPI_AttributeDouble>(data()->attribute(SketchPlugin_Constraint::VALUE()));
+    aValueAttr->setValue(aLenght);
   }
 }
 
index dcbd7c9ae7fdd9b092edfcf10bf0526cf2b516a4..133bc91bb74e8639694c2193eb7e372e1b58518d 100644 (file)
@@ -34,32 +34,28 @@ void SketchPlugin_ConstraintRadius::initAttributes()
 
 void SketchPlugin_ConstraintRadius::execute()
 {
-  if (data()->attribute(SketchPlugin_Constraint::ENTITY_A())->isInitialized()
-      && !data()->attribute(SketchPlugin_Constraint::VALUE())->isInitialized()) {
-
-    boost::shared_ptr<ModelAPI_AttributeRefAttr> aRef = boost::dynamic_pointer_cast<
-        ModelAPI_AttributeRefAttr>(data()->attribute(SketchPlugin_Constraint::ENTITY_A()));
-    FeaturePtr aFeature = ModelAPI_Feature::feature(aRef->object());
-    if (aFeature) {
-      double aRadius = 0;
-      boost::shared_ptr<ModelAPI_Data> aData = aFeature->data();
-      if (aFeature->getKind() == SketchPlugin_Circle::ID()) {
-        AttributeDoublePtr anAttribute = boost::dynamic_pointer_cast<ModelAPI_AttributeDouble>(
-            aData->attribute(SketchPlugin_Circle::RADIUS_ID()));
-        if (anAttribute)
-          aRadius = anAttribute->value();
-      } else if (aFeature->getKind() == SketchPlugin_Arc::ID()) {
-        boost::shared_ptr<GeomDataAPI_Point2D> aCenterAttr = boost::dynamic_pointer_cast<
-            GeomDataAPI_Point2D>(aData->attribute(SketchPlugin_Arc::CENTER_ID()));
-        boost::shared_ptr<GeomDataAPI_Point2D> aStartAttr = boost::dynamic_pointer_cast<
-            GeomDataAPI_Point2D>(aData->attribute(SketchPlugin_Arc::START_ID()));
-        if (aCenterAttr && aStartAttr)
-          aRadius = aCenterAttr->pnt()->distance(aStartAttr->pnt());
-      }
-      boost::shared_ptr<ModelAPI_AttributeDouble> aValueAttr = boost::dynamic_pointer_cast<
-          ModelAPI_AttributeDouble>(data()->attribute(SketchPlugin_Constraint::VALUE()));
-      aValueAttr->setValue(aRadius);
+  boost::shared_ptr<ModelAPI_AttributeRefAttr> aRef = boost::dynamic_pointer_cast<
+      ModelAPI_AttributeRefAttr>(data()->attribute(SketchPlugin_Constraint::ENTITY_A()));
+  FeaturePtr aFeature = ModelAPI_Feature::feature(aRef->object());
+  if (aFeature) {
+    double aRadius = 0;
+    boost::shared_ptr<ModelAPI_Data> aData = aFeature->data();
+    if (aFeature->getKind() == SketchPlugin_Circle::ID()) {
+      AttributeDoublePtr anAttribute = boost::dynamic_pointer_cast<ModelAPI_AttributeDouble>(
+          aData->attribute(SketchPlugin_Circle::RADIUS_ID()));
+      if (anAttribute)
+        aRadius = anAttribute->value();
+    } else if (aFeature->getKind() == SketchPlugin_Arc::ID()) {
+      boost::shared_ptr<GeomDataAPI_Point2D> aCenterAttr = boost::dynamic_pointer_cast<
+          GeomDataAPI_Point2D>(aData->attribute(SketchPlugin_Arc::CENTER_ID()));
+      boost::shared_ptr<GeomDataAPI_Point2D> aStartAttr = boost::dynamic_pointer_cast<
+          GeomDataAPI_Point2D>(aData->attribute(SketchPlugin_Arc::START_ID()));
+      if (aCenterAttr && aStartAttr)
+        aRadius = aCenterAttr->pnt()->distance(aStartAttr->pnt());
     }
+    boost::shared_ptr<ModelAPI_AttributeDouble> aValueAttr = boost::dynamic_pointer_cast<
+        ModelAPI_AttributeDouble>(data()->attribute(SketchPlugin_Constraint::VALUE()));
+    aValueAttr->setValue(aRadius);
   }
 }
 
index e7396865d5b8219d6dfbcedc5c27b8db9459e717..a077a466cc7a1e48273d86acbd007b14f58e1b2f 100644 (file)
       <feature id="SketchConstraintCoincidence" title="Coincident" tooltip="Create constraint for the coincidence of two points" internal="1"/>
 
       <feature id="SketchConstraintDistance" title="Distance" tooltip="Create constraint for the distance from a point to an object">
-        <label title="Select point and another object (point or point on line) between which to calculate distance" tooltip="Select point and another feature (point or point on line) between which to calculate distance"/>
-        <feature_or_attribute_selector id="ConstraintEntityA" label="First object" tooltip="Select an point in the viewer">
+        <label title="Select objects for distance difinition. Following objects can be accepted: point, line end point, line, 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_ResultPointValidator"/>
           <validator id="SketchPlugin_ResultLineValidator"/>
         </feature_or_attribute_selector>
-        <feature_or_attribute_selector id="ConstraintEntityB" label="Last object" tooltip="Select an point in the viewer">
+        <feature_or_attribute_selector id="ConstraintEntityB" label="Last object" tooltip="Select point, line end point, line, center of circle or arc.">
           <validator id="SketchPlugin_ResultPointValidator"/>
           <validator id="SketchPlugin_ResultLineValidator"/>
           <validator id="SketchPlugin_DistanceAttrValidator" parameters="ConstraintEntityA"/>
index 914cce3217c605a514e13a57b1ea4b27ce35734a..c24669c70ad97414ff895c6f29031f73544156da 100644 (file)
@@ -46,6 +46,9 @@ void XGUI_ContextMenuMgr::createActions()
   aAction = new QAction(QIcon(":pictures/eye_pencil.png"), tr("Show"), this);
   addAction("SHOW_CMD", aAction);
 
+  aAction = new QAction(QIcon(":pictures/eye_pencil.png"), tr("Show only"), this);
+  addAction("SHOW_ONLY_CMD", aAction);
+
   aAction = new QAction(QIcon(":pictures/eye_pencil_closed.png"), tr("Hide"), this);
   addAction("HIDE_CMD", aAction);
 }
@@ -121,8 +124,10 @@ QMenu* XGUI_ContextMenuMgr::objectBrowserMenu() const
         } else {
           if (aDisplayer->isVisible(aObject))
             aMenu->addAction(action("HIDE_CMD"));
-          else
+          else {
             aMenu->addAction(action("SHOW_CMD"));
+          }
+          aMenu->addAction(action("SHOW_ONLY_CMD"));
         }
       } else {  // If feature is 0 the it means that selected root object (document)
         if (aMgr->currentDocument() != aMgr->rootDocument())
@@ -145,6 +150,7 @@ QMenu* XGUI_ContextMenuMgr::objectBrowserMenu() const
       if (hasResult) {
         aMenu->addAction(action("SHOW_CMD"));
         aMenu->addAction(action("HIDE_CMD"));
+        aMenu->addAction(action("SHOW_ONLY_CMD"));
       }
       if (hasFeature)
         aMenu->addAction(action("DELETE_CMD"));
index 26def2f04855d27112bc55dee573509876f2d47d..840ade6713d7b7b0bc4d782e98141fed06be057e 100644 (file)
@@ -279,25 +279,22 @@ void XGUI_Displayer::setSelected(const QList<ObjectPtr>& theResults, const bool
     updateViewer();
 }
 
-/*void XGUI_Displayer::EraseAll(const bool isUpdateViewer)
+void XGUI_Displayer::eraseAll(const bool isUpdateViewer)
  {
- Handle(AIS_InteractiveContext) ic = AISContext();
-
- AIS_ListOfInteractive aList;
- ic->DisplayedObjects(aList);
- AIS_ListIteratorOfListOfInteractive anIter(aList);
- for (; anIter.More(); anIter.Next()) {
- if ((anIter.Value()->DynamicType() == STANDARD_TYPE(AIS_Trihedron)))
- continue;
-
- // erase an object
- Handle(AIS_InteractiveObject) anIO = anIter.Value();
- ic->Erase(anIO, false);
+   Handle(AIS_InteractiveContext) ic = AISContext();
+
+   ResultToAISMap::iterator aIt;
+   for (aIt = myResult2AISObjectMap.begin(); aIt != myResult2AISObjectMap.end(); aIt++) {
+     // erase an object
+     boost::shared_ptr<GeomAPI_AISObject> aAISObj = (*aIt).second;
+     Handle(AIS_InteractiveObject) anIO = aAISObj->impl<Handle(AIS_InteractiveObject)>();
+     if (!anIO.IsNull())
+      ic->Remove(anIO, false);
+   }
+   myResult2AISObjectMap.clear();
+   if (isUpdateViewer)
+     updateViewer();
  }
- myResult2AISObjectMap.clear();
- if (isUpdateViewer)
- updateViewer();
- }*/
 
 void XGUI_Displayer::eraseDeletedResults(const bool isUpdateViewer)
 {
index 5c54857d07bf4cab3ef6ca813907ce91e2703f94..7d0970659d54dd6457c062562df919c0b58362c0 100644 (file)
@@ -97,7 +97,7 @@ class XGUI_EXPORT XGUI_Displayer
 
   /// Erase all presentations
   /// \param isUpdateViewer the parameter whether the viewer should be update immediatelly
-  //void EraseAll(const bool isUpdateViewer = true);
+  void eraseAll(const bool isUpdateViewer = true);
 
   /// Erase AIS interactive objects, which has an empty feature in the internal map
   /// \param isUpdateViewer the parameter whether the viewer should be update immediatelly
index 88e625e36297aa367d362e2d540796259eb35786..53f324b40362976fcd209799b4ee63a346e70b32 100644 (file)
@@ -152,6 +152,7 @@ bool XGUI_OperationMgr::canStopOperation()
 void XGUI_OperationMgr::onCommitOperation()
 {
   ModuleBase_Operation* anOperation = currentOperation();
+  anOperation->onWidgetActivated(NULL);
   if (anOperation)
     anOperation->commit();
 }
index 6e55108e33192a07163142b8508a02825b0cd6bc..f363da6b5203f3e0e91d31481098f072bd6f36c0 100644 (file)
@@ -17,10 +17,10 @@ class QKeyEvent;
 
 /**\class XGUI_OperationMgr
  * \ingroup GUI
- * \brief Operation manager. Servers to manupulate to the workshop operations. Contains a stack
- * of started operations. In simple case, if only one operration is started, the stack contains
+ * \brief Operation manager. Servers to manipulate to the workshop operations. Contains a stack
+ * of started operations. In simple case, if only one operation is started, the stack contains
  * one operation. It is possible for some kind of operations to start them above already
- * started one. In that case, the previous active operation becames suspended, a new one - active.
+ * started one. In that case, the previous active operation becomes suspended, a new one - active.
  * The new operation is added to the top of the stack. Then it is finished, it is removed from
  * the stack and the previous operation is activated.
  */
index be21a28256d55f988f769f812c1bfb8aaca47be8..9d51cd86584a90175da8428851aa23bd1e74b3db 100644 (file)
@@ -960,6 +960,8 @@ void XGUI_Workshop::onContextMenuCommand(const QString& theId, bool isChecked)
     showObjects(aObjects, true);
   else if (theId == "HIDE_CMD")
     showObjects(aObjects, false);
+  else if (theId == "SHOW_ONLY_CMD")
+    showOnlyObjects(aObjects);
 }
 
 //**************************************************************
@@ -1050,6 +1052,14 @@ void XGUI_Workshop::showObjects(const QList<ObjectPtr>& theList, bool isVisible)
   myDisplayer->updateViewer();
 }
 
+//**************************************************************
+void XGUI_Workshop::showOnlyObjects(const QList<ObjectPtr>& theList)
+{
+  myDisplayer->eraseAll(false);
+  showObjects(theList, true);
+}
+
+
 //**************************************************************
 void XGUI_Workshop::updateCommandsOnViewSelection()
 {
index 458b8a4c415a9a35c8d358ce98d574adc325900a..95644a07fb1f25913f4141afd7223d137fce8680 100644 (file)
@@ -154,6 +154,9 @@ Q_OBJECT
   //! Show the given features in 3d Viewer
   void showObjects(const QList<ObjectPtr>& theList, bool isVisible);
 
+  //! Show the given features in 3d Viewer
+  void showOnlyObjects(const QList<ObjectPtr>& theList);
+
   ModuleBase_IModule* module() const
   {
     return myModule;