From: nds Date: Mon, 25 Jul 2016 14:57:33 +0000 (+0300) Subject: Split: selection of a part of a segment. X-Git-Tag: V_2.5.0~176 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=5a57a93cd947ba48410254d9717fb31fa2d33b96;p=modules%2Fshaper.git Split: selection of a part of a segment. --- diff --git a/src/GeomAPI/GeomAPI_Lin.cpp b/src/GeomAPI/GeomAPI_Lin.cpp index 9ccc30f2b..40e456e59 100644 --- a/src/GeomAPI/GeomAPI_Lin.cpp +++ b/src/GeomAPI/GeomAPI_Lin.cpp @@ -101,7 +101,7 @@ const std::shared_ptr GeomAPI_Lin::project( const gp_XYZ& aPnt = thePoint->impl().XYZ(); double aParam = aDir.Dot(aPnt - aLoc); - gp_XYZ aResult = aPnt + aDir * aParam; + gp_XYZ aResult = aLoc + aDir * aParam; return std::shared_ptr(new GeomAPI_Pnt(aResult.X(), aResult.Y(), aResult.Z())); } diff --git a/src/PartSet/PartSet_SketcherMgr.cpp b/src/PartSet/PartSet_SketcherMgr.cpp index 78d9dfa02..ce2b209ce 100755 --- a/src/PartSet/PartSet_SketcherMgr.cpp +++ b/src/PartSet/PartSet_SketcherMgr.cpp @@ -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(); - */ } } } diff --git a/src/PartSet/PartSet_WidgetSubShapeSelector.cpp b/src/PartSet/PartSet_WidgetSubShapeSelector.cpp index fe3f2a609..f73d61e98 100755 --- a/src/PartSet/PartSet_WidgetSubShapeSelector.cpp +++ b/src/PartSet/PartSet_WidgetSubShapeSelector.cpp @@ -30,6 +30,10 @@ #include +#include +#include +#include + #include #include @@ -38,6 +42,8 @@ PartSet_WidgetSubShapeSelector::PartSet_WidgetSubShapeSelector(QWidget* theParen const Config_WidgetAPI* theData) : PartSet_WidgetShapeSelector(theParent, theWorkshop, theData) { + myCurrentSubShape = std::shared_ptr(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 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); } //******************************************************************** diff --git a/src/PartSet/PartSet_WidgetSubShapeSelector.h b/src/PartSet/PartSet_WidgetSubShapeSelector.h index 4c0945799..34e7b371a 100644 --- a/src/PartSet/PartSet_WidgetSubShapeSelector.h +++ b/src/PartSet/PartSet_WidgetSubShapeSelector.h @@ -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 myCurrentSubShape; std::map > myCashedShapes; diff --git a/src/XGUI/XGUI_Displayer.cpp b/src/XGUI/XGUI_Displayer.cpp index b9105ef92..87dfcee80 100644 --- a/src/XGUI/XGUI_Displayer.cpp +++ b/src/XGUI/XGUI_Displayer.cpp @@ -670,12 +670,12 @@ void XGUI_Displayer::setSelected(const QList& 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); } } diff --git a/src/XGUI/XGUI_Displayer.h b/src/XGUI/XGUI_Displayer.h index 529aab5ef..fce5e0c9b 100644 --- a/src/XGUI/XGUI_Displayer.h +++ b/src/XGUI/XGUI_Displayer.h @@ -96,7 +96,9 @@ class XGUI_EXPORT XGUI_Displayer: public QObject void setSelected(const QList>& 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 diff --git a/src/XGUI/XGUI_Workshop.cpp b/src/XGUI/XGUI_Workshop.cpp index fd3b111b6..72574632f 100755 --- a/src/XGUI/XGUI_Workshop.cpp +++ b/src/XGUI/XGUI_Workshop.cpp @@ -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(); diff --git a/src/XGUI/XGUI_Workshop.h b/src/XGUI/XGUI_Workshop.h index 1a90b4dc6..81f6d7a91 100755 --- a/src/XGUI/XGUI_Workshop.h +++ b/src/XGUI/XGUI_Workshop.h @@ -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();