]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
Split: selection of a part of a segment.
authornds <nds@opencascade.com>
Mon, 25 Jul 2016 14:57:33 +0000 (17:57 +0300)
committernds <nds@opencascade.com>
Mon, 25 Jul 2016 14:57:33 +0000 (17:57 +0300)
src/GeomAPI/GeomAPI_Lin.cpp
src/PartSet/PartSet_SketcherMgr.cpp
src/PartSet/PartSet_WidgetSubShapeSelector.cpp
src/PartSet/PartSet_WidgetSubShapeSelector.h
src/XGUI/XGUI_Displayer.cpp
src/XGUI/XGUI_Displayer.h
src/XGUI/XGUI_Workshop.cpp
src/XGUI/XGUI_Workshop.h

index 9ccc30f2bca5aca396bda13bc1055f856cf3b76e..40e456e592f7905833d6d9c37af8affb7f9e01ea 100644 (file)
@@ -101,7 +101,7 @@ const std::shared_ptr<GeomAPI_Pnt> GeomAPI_Lin::project(
   const gp_XYZ& aPnt = thePoint->impl<gp_Pnt>().XYZ();
   double aParam = aDir.Dot(aPnt - aLoc);
 
-  gp_XYZ aResult = aPnt + aDir * aParam;
+  gp_XYZ aResult = aLoc + aDir * aParam;
   return std::shared_ptr<GeomAPI_Pnt>(new GeomAPI_Pnt(aResult.X(), aResult.Y(), aResult.Z()));
 }
 
index 78d9dfa02d79c94d04b7a05d1574425b27517c6a..ce2b209ce5267d39a35b0d33c746de2bcac970c9 100755 (executable)
@@ -419,22 +419,10 @@ void PartSet_SketcherMgr::onMouseReleased(ModuleBase_IViewWindow* theWnd, QMouse
   ModuleBase_Operation* aOp = getCurrentOperation();
   if (aOp) {
     if (isNestedSketchOperation(aOp, activeSketch())) {
-      //get2dPoint(theWnd, theEvent, myClickedPoint);
-
       // Only for sketcher operations
       if (myIsDragging) {
         if (myDragDone) {
-          //aOp->commit();
           myCurrentSelection.clear();
-          /*Handle(AIS_InteractiveContext) aContext = aViewer->AISContext();
-          if (!aContext.IsNull()) {
-          // Reselect edited object
-          aContext->MoveTo(theEvent->x(), theEvent->y(), theWnd->v3dView());
-          if (theEvent->modifiers() & Qt::ShiftModifier)
-            aContext->ShiftSelect();
-          else
-            aContext->Select();
-          */
         }
       }
     }
index fe3f2a609d4b96a43ad5417684caa8a6479c4b82..f73d61e98299a71da30b84fd8d2e4350cfa2215b 100755 (executable)
 
 #include <Config_WidgetAPI.h>
 
+#include <XGUI_Tools.h>
+#include <XGUI_Workshop.h>
+#include <XGUI_Displayer.h>
+
 #include <QWidget>
 #include <QMouseEvent>
 
@@ -38,6 +42,8 @@ PartSet_WidgetSubShapeSelector::PartSet_WidgetSubShapeSelector(QWidget* theParen
                                                          const Config_WidgetAPI* theData)
 : PartSet_WidgetShapeSelector(theParent, theWorkshop, theData)
 {
+  myCurrentSubShape = std::shared_ptr<ModuleBase_ViewerPrs>(new ModuleBase_ViewerPrs());
+
   //myUseSketchPlane = theData->getBooleanAttribute("use_sketch_plane", true);
   //myExternalObjectMgr = new PartSet_ExternalObjectsMgr(theData->getProperty("use_external"), true);
 }
@@ -46,6 +52,23 @@ PartSet_WidgetSubShapeSelector::~PartSet_WidgetSubShapeSelector()
 {
 }
 
+//********************************************************************
+void PartSet_WidgetSubShapeSelector::activateCustom()
+{
+  PartSet_WidgetShapeSelector::activateCustom();
+
+  myWorkshop->module()->activateCustomPrs(myFeature,
+                            ModuleBase_IModule::CustomizeHighlightedObjects, true);
+}
+
+//********************************************************************
+void PartSet_WidgetSubShapeSelector::deactivate()
+{
+  PartSet_WidgetShapeSelector::deactivate();
+
+  myWorkshop->module()->deactivateCustomPrs(ModuleBase_IModule::CustomizeHighlightedObjects, true);
+}
+
 //********************************************************************
 void PartSet_WidgetSubShapeSelector::mouseMoved(ModuleBase_IViewWindow* theWindow,
                                                 QMouseEvent* theEvent)
@@ -69,16 +92,22 @@ void PartSet_WidgetSubShapeSelector::mouseMoved(ModuleBase_IViewWindow* theWindo
           GeomShapePtr aBaseShape = *anIt;
           std::shared_ptr<GeomAPI_Pnt> aProjectedPoint;
           if (ModelGeomAlgo_Point2D::isPointOnEdge(aBaseShape, aPoint, aProjectedPoint)) {
-            myCurrentSubShape->setObject(anObject);
-            myCurrentSubShape->setShape(aBaseShape);
+            XGUI_Tools::workshop(myWorkshop)->displayer()->clearSelected(false);
+            if (myCurrentSubShape->object() != anObject ||
+                myCurrentSubShape->shape() != aBaseShape) {
+              myCurrentSubShape->setObject(anObject);
+              myCurrentSubShape->setShape(aBaseShape);
+              myWorkshop->module()->customizeObject(myFeature,
+                                       ModuleBase_IModule::CustomizeHighlightedObjects, true);
+            }
+            else
+              XGUI_Tools::workshop(myWorkshop)->displayer()->updateViewer();;
             break;
           }
         }
       }
     }
   }
-  myWorkshop->module()->customizeObject(myFeature, ModuleBase_IModule::CustomizeHighlightedObjects,
-                                        true);
 }
 
 //********************************************************************
index 4c094579948f9078025575d63f4b2672a31a77c9..34e7b371a4cc6fd6135f2e4e175730dc5b1a1267 100644 (file)
@@ -46,6 +46,9 @@ Q_OBJECT
 
   virtual ~PartSet_WidgetSubShapeSelector();
 
+  /// The methiod called when widget is deactivated
+  virtual void deactivate();
+
   /// Processing the mouse move event in the viewer
   /// \param theWindow a view window
   /// \param theEvent a mouse event
@@ -70,6 +73,10 @@ protected:
   //                              GeomShapePtr& theShape);
   void fillObjectShapes(const ObjectPtr& theObject);
 
+protected:
+  /// The methiod called when widget is activated
+  virtual void activateCustom();
+
 protected:
   std::shared_ptr<ModuleBase_ViewerPrs> myCurrentSubShape;
   std::map<ObjectPtr, std::set<GeomShapePtr> > myCashedShapes;
index b9105ef9232aff3608d4334a8fa67972a1740af4..87dfcee80d01d46780443ce4ae6e7d72eee0b1e6 100644 (file)
@@ -670,12 +670,12 @@ void XGUI_Displayer::setSelected(const  QList<ModuleBase_ViewerPrsPtr>& theValue
     updateViewer();
 }
 
-void XGUI_Displayer::clearSelected()
+void XGUI_Displayer::clearSelected(const bool theUpdateViewer)
 {
   Handle(AIS_InteractiveContext) aContext = AISContext();
   if (!aContext.IsNull()) {
     aContext->UnhilightCurrents(false);
-    aContext->ClearSelected();
+    aContext->ClearSelected(theUpdateViewer);
   }
 }
 
index 529aab5ef9a03c6fe135764c26c0997b744a6757..fce5e0c9b70837add3dd2781b8ca1d6ad029205a 100644 (file)
@@ -96,7 +96,9 @@ class XGUI_EXPORT XGUI_Displayer: public QObject
   void setSelected(const  QList<std::shared_ptr<ModuleBase_ViewerPrs>>& theValues, bool theUpdateViewer = true);
 
   /// Unselect all objects
-  void clearSelected();
+  /// \param theUpdateViewer the parameter whether the viewer should be update immediatelly
+  /// \param theUpdateViewer the parameter to update viewer
+  void clearSelected(const bool theUpdateViewer = true);
 
   /// Erase the feature and a shape.
   /// \param theObject an object instance
index fd3b111b61e1cc307b3822606074d6982a90db17..72574632fa5ce0246af994ff04b8de1eea16c478 100755 (executable)
@@ -719,16 +719,26 @@ void XGUI_Workshop::onOpen()
   }
 
   //show file dialog, check if readable and open
-  myCurrentDir = QFileDialog::getExistingDirectory(desktop(), tr("Select directory"));
+  QString aDirectory = QFileDialog::getExistingDirectory(desktop(), tr("Select directory"));
+  openDirectory(aDirectory);
+}
+
+//******************************************************
+void XGUI_Workshop::openDirectory(const QString& theDirectory)
+{
+  myCurrentDir = theDirectory;
   if (myCurrentDir.isEmpty())
     return;
+
   QFileInfo aFileInfo(myCurrentDir);
   if (!aFileInfo.exists() || !aFileInfo.isReadable()) {
     QMessageBox::critical(desktop(), tr("Warning"), tr("Unable to open the file."));
     myCurrentDir = "";
     return;
   }
+
   QApplication::setOverrideCursor(Qt::WaitCursor);
+  SessionPtr aSession = ModelAPI_Session::get();
   aSession->closeAll();
   aSession->load(myCurrentDir.toLatin1().constData());
   myObjectBrowser->rebuildDataTree();
index 1a90b4dc674b1cd43e77171e602f0f8d53c449af..81f6d7a91b35cd8064ab06d1bed82386718e6bf1 100755 (executable)
@@ -308,6 +308,10 @@ Q_OBJECT
   /// It is used for specific processing of Undo/Redo for this command.
   static QString MOVE_TO_END_COMMAND;
 
+  //! Closes all in the current session and load the directory
+  //! \param theDirectory a path to directory
+  void openDirectory(const QString& theDirectory);
+
 signals:
   /// Emitted when selection happens in Salome viewer
   void salomeViewerSelection();