]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
Merge branch 'Dev_0.6' of newgeom:newgeom into Dev_0.6
authornds <natalia.donis@opencascade.com>
Mon, 8 Dec 2014 16:40:58 +0000 (19:40 +0300)
committernds <natalia.donis@opencascade.com>
Mon, 8 Dec 2014 16:40:58 +0000 (19:40 +0300)
src/Config/Config_FeatureReader.cpp
src/Events/Events_Loop.cpp
src/Events/Events_Loop.h
src/Model/Model_Update.cpp
src/ModuleBase/ModuleBase_WidgetShapeSelector.cpp
src/PartSet/PartSet_Module.cpp
src/PartSet/PartSet_Module.h
src/PartSetPlugin/CMakeLists.txt
src/PartSetPlugin/plugin-PartSet.xml
src/SketchPlugin/plugin-Sketch.xml
src/SketchSolver/SketchSolver_ConstraintManager.cpp

index 9ebc93f78f821c399ec5106c85bb5844db09e5d5..bf780f3301c0442b94aa05988f351dd8e44dbad3 100644 (file)
@@ -102,7 +102,12 @@ void Config_FeatureReader::fillFeature(xmlNodePtr theNode,
   outFeatureMessage->setKeysequence(getProperty(theNode, FEATURE_KEYSEQUENCE));
   outFeatureMessage->setGroupId(restoreAttribute(NODE_GROUP, _ID));
   outFeatureMessage->setWorkbenchId(restoreAttribute(NODE_WORKBENCH, _ID));
-  outFeatureMessage->setDocumentKind(restoreAttribute(NODE_WORKBENCH, WORKBENCH_DOC));
+  // Get document kind of a feature, if empty set workbench's kind (might be empty too)
+  std::string aDocKind = getProperty(theNode, WORKBENCH_DOC);
+  if(aDocKind.empty()) {
+    aDocKind = restoreAttribute(NODE_WORKBENCH, WORKBENCH_DOC);
+  }
+  outFeatureMessage->setDocumentKind(aDocKind);
 }
 
 void Config_FeatureReader::storeAttribute(xmlNodePtr theNode,
index 9447c376b97c6a4f017be8206e8c13f41325fed6..f9b9d004626bb4dbfe9c16cf12266277f9a60793 100644 (file)
@@ -115,14 +115,18 @@ void Events_Loop::flush(const Events_ID& theID)
 {
   if (!myFlushActive)
     return;
-  std::map<char*, std::shared_ptr<Events_Message>>::iterator aMyGroup =
-    myGroups.find(theID.eventText());
-  if (aMyGroup != myGroups.end()) {  // really sends
-    myFlushed.insert(theID.myID);
+  std::map<char*, std::shared_ptr<Events_Message> >::iterator aMyGroup;
+  for(aMyGroup = myGroups.find(theID.eventText());
+    aMyGroup != myGroups.end(); aMyGroup = myGroups.find(theID.eventText()))
+  {  // really sends
+    bool aWasFlushed = myFlushed.find(theID.myID) != myFlushed.end();
+    if (!aWasFlushed)
+      myFlushed.insert(theID.myID);
     std::shared_ptr<Events_Message> aGroup = aMyGroup->second;
     myGroups.erase(aMyGroup);
     send(aGroup, false);
-    myFlushed.erase(myFlushed.find(theID.myID));
+    if (!aWasFlushed)
+      myFlushed.erase(myFlushed.find(theID.myID));
   }
 }
 
@@ -147,3 +151,16 @@ void Events_Loop::autoFlush(const Events_ID& theID, const bool theAuto)
   else
     myFlushed.erase(myFlushed.find(theID.myID));
 }
+
+bool Events_Loop::isFlushed(const Events_ID& theID)
+{
+  return myFlushed.find(theID.myID) != myFlushed.end();
+}
+
+void Events_Loop::setFlushed(const Events_ID& theID, const bool theValue)
+{
+  if (theValue)
+    myFlushed.insert(theID.myID);
+  else
+    myFlushed.erase(myFlushed.find(theID.myID));
+}
index c8b7798c0e06944cdc3348fdbe6e60126a662ee1..317c62d3b9e9dea0b5ef33b4c75684ede9c328ef 100644 (file)
@@ -72,6 +72,11 @@ class Events_Loop
 
   //! Enables flush without grouping for the given message
   EVENTS_EXPORT void autoFlush(const Events_ID& theID, const bool theAuto = true);
+
+  //! Returns true if the evement is flushed right now
+  EVENTS_EXPORT bool isFlushed(const Events_ID& theID);
+  //! Sets the flag that the event is flished right now
+  EVENTS_EXPORT void setFlushed(const Events_ID& theID, const bool theValue);
 };
 
 #endif
index 31c8b7565956247856dac960f303e15b1565f893..3a70e463a2b8a73b74c16cc938fa877ce197f907 100644 (file)
@@ -163,7 +163,7 @@ void Model_Update::updateInDoc(std::shared_ptr<ModelAPI_Document> theDoc)
 
 void Model_Update::redisplayWithResults(FeaturePtr theFeature, const ModelAPI_ExecState theState) 
 {
-  // maske updated and redisplay all results
+  // make updated and redisplay all results
   static Events_ID EVENT_DISP = Events_Loop::loop()->eventByName(EVENT_OBJECT_TO_REDISPLAY);
   const std::list<std::shared_ptr<ModelAPI_Result> >& aResults = theFeature->results();
   std::list<std::shared_ptr<ModelAPI_Result> >::const_iterator aRIter = aResults.begin();
index 0a15d04b6e674b3fc1f8c181d610d4f069ed83fe..cf0e748dba6bb608b1320b4861fbc87338b58e93 100644 (file)
@@ -304,8 +304,9 @@ bool ModuleBase_WidgetShapeSelector::setSelection(ModuleBase_ViewerPrs theValue)
   if (isValid(aObject, aShape)) {
     setObject(aObject, aShape);
     emit focusOutWidget(this);
+    return true;
   }
-  return true;
+  return false;
 }
 
 //********************************************************************
index 5641f05550d7dfc216fee4cb241130df933fa1ea..7ecd6033b6905972b5214d9abda3640c414cc35e 100644 (file)
@@ -11,6 +11,7 @@
 #include <ModuleBase_IViewer.h>
 #include <ModuleBase_IViewWindow.h>
 #include <ModuleBase_IPropertyPanel.h>
+#include <ModuleBase_WidgetEditor.h>
 
 #include <ModelAPI_Object.h>
 #include <ModelAPI_Events.h>
@@ -106,6 +107,9 @@ PartSet_Module::PartSet_Module(ModuleBase_IWorkshop* theWshop)
   connect(aViewer, SIGNAL(mouseMove(ModuleBase_IViewWindow*, QMouseEvent*)),
           this, SLOT(onMouseMoved(ModuleBase_IViewWindow*, QMouseEvent*)));
 
+  connect(aViewer, SIGNAL(mouseDoubleClick(ModuleBase_IViewWindow*, QMouseEvent*)),
+          this, SLOT(onMouseDoubleClick(ModuleBase_IViewWindow*, QMouseEvent*)));
+
   XGUI_ModuleConnector* aConnector = dynamic_cast<XGUI_ModuleConnector*>(theWshop);
   XGUI_Workshop* aWorkshop = aConnector->workshop();
 
@@ -526,6 +530,29 @@ void PartSet_Module::onMouseMoved(ModuleBase_IViewWindow* theWnd, QMouseEvent* t
   }
 }
 
+void PartSet_Module::onMouseDoubleClick(ModuleBase_IViewWindow* theWnd, QMouseEvent* theEvent)
+{
+  ModuleBase_Operation* aOperation = myWorkshop->currentOperation();
+  if (aOperation->isEditOperation()) {
+    std::string aId = aOperation->id().toStdString();
+    if ((aId == SketchPlugin_ConstraintLength::ID()) ||
+      (aId == SketchPlugin_ConstraintDistance::ID()) ||
+      (aId == SketchPlugin_ConstraintRadius::ID())) 
+    {
+      // Activate dimension value editing on double click
+      ModuleBase_IPropertyPanel* aPanel = aOperation->propertyPanel();
+      QList<ModuleBase_ModelWidget*> aWidgets = aPanel->modelWidgets();
+      // Find corresponded widget to activate value editing
+      foreach (ModuleBase_ModelWidget* aWgt, aWidgets) {
+        if (aWgt->attributeID() == "ConstraintValue") {
+          aWgt->focusTo();
+          return;
+        }
+      }
+    }
+  }
+}
+
 void PartSet_Module::onKeyRelease(ModuleBase_IViewWindow* theWnd, QKeyEvent* theEvent)
 {
   XGUI_ModuleConnector* aConnector = dynamic_cast<XGUI_ModuleConnector*>(workshop());
@@ -635,3 +662,4 @@ QWidget* PartSet_Module::createWidgetByType(const std::string& theType, QWidget*
   }else
     return 0;
 }
+
index 42619830db193a82ed69f8d5d594378e6e89e354..bf61299979a4d43be788abf0fc8acff7a572ecfd 100644 (file)
@@ -69,19 +69,24 @@ protected slots:
   virtual void onSelectionChanged();
 
   /// SLOT, that is called by mouse press in the viewer.
-  /// The mouse released point is sent to the current operation to be processed.
+  /// \param theWnd - the window where the event happens
   /// \param theEvent the mouse event
   void onMousePressed(ModuleBase_IViewWindow* theWnd, QMouseEvent* theEvent);
 
   /// SLOT, that is called by mouse release in the viewer.
-  /// The mouse released point is sent to the current operation to be processed.
+  /// \param theWnd - the window where the event happens
   /// \param theEvent the mouse event
-  virtual void onMouseReleased(ModuleBase_IViewWindow* theWnd, QMouseEvent* theEvent);
+  void onMouseReleased(ModuleBase_IViewWindow* theWnd, QMouseEvent* theEvent);
   
   /// SLOT, that is called by mouse move in the viewer.
-  /// The mouse moved point is sent to the current operation to be processed.
+  /// \param theWnd - the window where the event happens
+  /// \param theEvent the mouse event
+  void onMouseMoved(ModuleBase_IViewWindow* theWnd, QMouseEvent* theEvent);
+
+  /// SLOT, that is called by mouse double click in the viewer.
+  /// \param theWnd - the window where the event happens
   /// \param theEvent the mouse event
-  virtual void onMouseMoved(ModuleBase_IViewWindow* theWnd, QMouseEvent* theEvent);
+  void onMouseDoubleClick(ModuleBase_IViewWindow* theWnd, QMouseEvent* theEvent);
 
   /// SLOT, that is called by key release in the viewer.
   /// The mouse moved point is sent to the current operation to be processed.
index e115ab9db5433d23f261f48b55a0d7a0b81badbe..1f249f9b622dfe78bbbb71945dcd6a812468c498 100644 (file)
@@ -15,8 +15,12 @@ SET(PROJECT_SOURCES
     PartSetPlugin_Remove.cpp
 )
 
+SET(XML_RESOURCES
+  plugin-PartSet.xml
+)
+
 ADD_DEFINITIONS(-DPARTSETPLUGIN_EXPORTS)
-ADD_LIBRARY(PartSetPlugin MODULE ${PROJECT_SOURCES} ${PROJECT_HEADERS})
+ADD_LIBRARY(PartSetPlugin MODULE ${PROJECT_SOURCES} ${PROJECT_HEADERS} ${XML_RESOURCES})
 TARGET_LINK_LIBRARIES(PartSetPlugin ${PROJECT_LIBRARIES} ModelAPI)
 
 INCLUDE_DIRECTORIES(
@@ -24,9 +28,5 @@ INCLUDE_DIRECTORIES(
   ../GeomAPI
 )
 
-SET(XML_RESOURCES
-  plugin-PartSet.xml
-)
-
 INSTALL(TARGETS PartSetPlugin DESTINATION plugins)
 INSTALL(FILES ${XML_RESOURCES} DESTINATION plugins)
index 4a846cc42a98088901b5d05ae21d98a8f31b1b77..db6893e509f1ccf5de3c6711d8d49bb85a4d4e0c 100644 (file)
@@ -2,8 +2,15 @@
   <workbench id="Part">
     <group id="Operations">
       <feature id="Part" title="New part" tooltip="Create a new part" icon=":pictures/part_ico.png"/>
-      <feature id="Duplicate" title="Duplicate" tooltip="Duplicate selected part" icon=":icons/duplicate.png"/>
-      <feature id="Remove" title="Remove part"  tooltip="Remove active part" icon=":icons/remove.png"/>
+      <feature id="Duplicate" title="Duplicate"
+               tooltip="Duplicate selected part"
+               icon=":icons/duplicate.png"
+               document="Part"/>
+      <feature id="Remove"
+               title="Remove part"
+               tooltip="Remove active part"
+               icon=":icons/remove.png"
+               document="Part"/>
     </group>
   </workbench>
 </plugin>
index f616781541fd444e58286fbb33ce3890f069577f..d83e41b6b8ba90720f37de56b0d0231e1ebd1399 100644 (file)
                <sketch_constraint_shape_selector id="ConstraintEntityA" 
                        label="First line" tooltip="Select an line in the viewer" 
                        shape_types="edge" use_subshapes="true">
-                       <validator id="SketchPlugin_ResultLine"/>
                </sketch_constraint_shape_selector>
                
                <sketch_constraint_shape_selector id="ConstraintEntityB" label="Last line" tooltip="Select an line in the viewer" 
                        shape_types="edge" use_subshapes="true">
-                       <validator id="SketchPlugin_ResultLine"/>
                        <validator id="SketchPlugin_DifferentObjects"/>
                </sketch_constraint_shape_selector>
                
                <sketch_constraint_shape_selector id="ConstraintEntityA" 
                        label="First line" tooltip="Select an line in the viewer" 
                        shape_types="edge" use_subshapes="true">
-                       <validator id="SketchPlugin_ResultLine"/>
                </sketch_constraint_shape_selector>
                
                <sketch_constraint_shape_selector id="ConstraintEntityB" 
                        label="Last line" tooltip="Select an line in the viewer" 
                        shape_types="edge" use_subshapes="true">
-                       <validator id="SketchPlugin_ResultLine"/>
                        <validator id="SketchPlugin_DifferentObjects"/>
                </sketch_constraint_shape_selector>
         <validator id="PartSet_PerpendicularValidator"/>
index 3ba3fdda466add2db602fe914e8348843d1fa56f..a69eb95bcae4cf6f924d4cb1e7cb545ba45a1a93 100644 (file)
@@ -374,14 +374,24 @@ void SketchSolver_ConstraintManager::resolveConstraints()
 {
   myIsComputed = true;
   bool needToUpdate = false;
+  static Events_ID anUpdateEvent = Events_Loop::eventByName(EVENT_OBJECT_UPDATED);
+  // to avoid redisplay of each segment on update by solver one by one in the viewer
+  bool isUpdateFlushed = Events_Loop::loop()->isFlushed(anUpdateEvent);
+  if (isUpdateFlushed) {
+    Events_Loop::loop()->setFlushed(anUpdateEvent, false);
+  }
+
   std::vector<SketchSolver_ConstraintGroup*>::iterator aGroupIter;
   for (aGroupIter = myGroups.begin(); aGroupIter != myGroups.end(); aGroupIter++)
     if ((*aGroupIter)->resolveConstraints())
       needToUpdate = true;
 
-  // Features may be updated => send events
+  // Features may be updated => now send events, btu for all changed at once
+  if (isUpdateFlushed) {
+    Events_Loop::loop()->setFlushed(anUpdateEvent, true);
+  }
   if (needToUpdate)
-    Events_Loop::loop()->flush(Events_Loop::eventByName(EVENT_OBJECT_UPDATED));
+    Events_Loop::loop()->flush(anUpdateEvent);
   myIsComputed = false;
 }