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()));
}
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();
- */
}
}
}
#include <Config_WidgetAPI.h>
+#include <XGUI_Tools.h>
+#include <XGUI_Workshop.h>
+#include <XGUI_Displayer.h>
+
#include <QWidget>
#include <QMouseEvent>
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);
}
{
}
+//********************************************************************
+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)
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);
}
//********************************************************************
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
// 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;
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);
}
}
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
}
//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();
/// 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();