myIsMouseOverWindow(false),
myIsMouseOverViewProcessed(true),
myIsPopupMenuActive(false),
+ myLastMouseEventType(QEvent::None),
myPreviousUpdateViewerEnabled(true),
myExternalPointsMgr(0),
myNoDragMoving(false)
myMousePoint.setX(theEvent->x());
myMousePoint.setY(theEvent->y());
- if (myModule->sketchReentranceMgr()->processMousePressed(theWnd, theEvent))
+ if (myModule->sketchReentranceMgr()->processMousePressed(theWnd, theEvent)) {
+ myLastMouseEventType = theEvent->type();
return;
- //get2dPoint(theWnd, theEvent, myClickedPoint);
- if (!(theEvent->buttons() & Qt::LeftButton))
+ }
+ //get2dPoint(theWnd, theEvent->pos(), myClickedPoint);
+ if (!(theEvent->buttons() & Qt::LeftButton)) {
+ myLastMouseEventType = theEvent->type();
return;
+ }
ModuleBase_IWorkshop* aWorkshop = myModule->workshop();
ModuleBase_IViewer* aViewer = aWorkshop->viewer();
ModuleBase_OperationFeature* aFOperation = dynamic_cast<ModuleBase_OperationFeature*>
(getCurrentOperation());
- if (!aFOperation)
+ if (!aFOperation) {
+ myLastMouseEventType = theEvent->type();
return;
+ }
bool isEditing = aFOperation->isEditOperation();
bool aCanDrag = aViewer->canDragByMouse();
// If the current widget is a selector, do nothing, it processes the mouse press
ModuleBase_ModelWidget* anActiveWidget = getActiveWidget();
if(anActiveWidget && anActiveWidget->isViewerSelector()) {
+ myLastMouseEventType = theEvent->type();
return;
}
}
// Use only for sketch operations
if (myCurrentSketch) {
- if (!PartSet_Tools::sketchPlane(myCurrentSketch))
+ if (!PartSet_Tools::sketchPlane(myCurrentSketch)) {
+ myLastMouseEventType = theEvent->type();
return;
+ }
bool isSketcher = isSketchOperation(aFOperation);
bool isSketchOpe = isNestedSketchOperation(aFOperation);
// Avoid non-sketch operations
- if ((!isSketchOpe) && (!isSketcher))
+ if ((!isSketchOpe) && (!isSketcher)) {
+ myLastMouseEventType = theEvent->type();
return;
+ }
// Ignore creation sketch operation
if ((!isSketcher) && (!isEditing)) {
aProcessor->mouseReleased(theWnd, theEvent);
}
}
+ myLastMouseEventType = theEvent->type();
return;
}
bool aHasShift = (theEvent->modifiers() & Qt::ShiftModifier);
// commit previous operation
if (!aFOperation->commit())
aFOperation->abort();
+
+ myLastMouseEventType = theEvent->type();
return;
}
// Init flyout point for radius rotation
FeaturePtr aFeature = myCurrentSelection.begin().key();
- get2dPoint(theWnd, theEvent, myCurrentPoint);
+ get2dPoint(theWnd, theEvent->pos(), myCurrentPoint);
if (isSketcher) {
if (aCanDrag) {
myIsDragging = true;
}
}
}
+
+ myLastMouseEventType = theEvent->type();
}
void PartSet_SketcherMgr::onMouseReleased(ModuleBase_IViewWindow* theWnd, QMouseEvent* theEvent)
bool aWasDragging = myIsDragging;
myIsDragging = false;
- if (myModule->sketchReentranceMgr()->processMouseReleased(theWnd, theEvent))
+ if (myModule->sketchReentranceMgr()->processMouseReleased(theWnd, theEvent)) {
+ myLastMouseEventType = theEvent->type();
return;
+ }
// if mouse is pressed when it was over view and at release the mouse is out of view, do nothing
- if (!myIsMouseOverViewProcessed)
+ if (!myIsMouseOverViewProcessed) {
+ myLastMouseEventType = theEvent->type();
return;
+ }
ModuleBase_OperationFeature* aOp =
dynamic_cast<ModuleBase_OperationFeature*>(getCurrentOperation());
else
myNoDragMoving = false;
- if (myNoDragMoving)
+ if (myNoDragMoving) {
+ myLastMouseEventType = theEvent->type();
return;
+ }
else {
ModuleBase_OperationFeature* aOp =
dynamic_cast<ModuleBase_OperationFeature*>(getCurrentOperation());
myNoDragMoving = !myNoDragMoving;
else
myNoDragMoving = false;
- if (myNoDragMoving)
+ if (myNoDragMoving) {
+ myLastMouseEventType = theEvent->type();
return;
+ }
else {
restoreSelection(myCurrentSelection);
myCurrentSelection.clear();
if (MyModeByDrag && aOp) {
aViewer->enableMultiselection(true);
QString aOpId = aOp->id();
- if (aOpId == "Sketch")
+ if (aOpId == "Sketch") {
+ myLastMouseEventType = theEvent->type();
return;
+ }
QPoint aPnt(theEvent->x(), theEvent->y());
anActiveWidget = getActiveWidget();
if ((aPnt == myMousePoint) && anActiveWidget) {
aOp->abort();
+ myLastMouseEventType = theEvent->type();
return;
}
bool aCanRestart = !anActiveWidget && !isEditing;
module()->launchOperation(aOpId, true);
}
}
+ myLastMouseEventType = theEvent->type();
}
void PartSet_SketcherMgr::onMouseMoved(ModuleBase_IViewWindow* theWnd, QMouseEvent* theEvent)
}
#endif
- if (myModule->sketchReentranceMgr()->processMouseMoved(theWnd, theEvent))
+ if (myModule->sketchReentranceMgr()->processMouseMoved(theWnd, theEvent)) {
+ myLastMouseEventType = theEvent->type();
return;
+ }
ModuleBase_IWorkshop* aWorkshop = myModule->workshop();
XGUI_ModuleConnector* aConnector = dynamic_cast<XGUI_ModuleConnector*>(aWorkshop);
XGUI_Displayer* aDisplayer = aConnector->workshop()->displayer();
if (isNestedCreateOperation(getCurrentOperation(), activeSketch())) {
-
#ifdef DRAGGING_DEBUG
QTime t;
t.start();
// deselected). This flag should be restored in the slot, processed the mouse release signal.
ModuleBase_Operation* aCurrentOperation = getCurrentOperation();
if (!aCurrentOperation) {
+ myLastMouseEventType = theEvent->type();
return;
}
if (isSketchOperation(aCurrentOperation)) {
+ myLastMouseEventType = theEvent->type();
return; // No edit operation activated
}
#endif
Handle(V3d_View) aView = theWnd->v3dView();
- Point aMousePnt;
- get2dPoint(theWnd, theEvent, aMousePnt);
+ Point aMousePnt, aHoverPnt;
+ get2dPoint(theWnd, theEvent->pos(), aMousePnt, true /*theSnap*/);
+ get2dPoint(theWnd, theEvent->pos(), aHoverPnt, myLastMouseEventType == QEvent::MouseMove /*theSnap*/);
- std::shared_ptr<GeomAPI_Pnt2d> anOriginalPosition = std::shared_ptr<GeomAPI_Pnt2d>(
- new GeomAPI_Pnt2d(myCurrentPoint.myCurX, myCurrentPoint.myCurY));
- std::shared_ptr<GeomAPI_Pnt2d> aCurrentPosition = std::shared_ptr<GeomAPI_Pnt2d>(
- new GeomAPI_Pnt2d(aMousePnt.myCurX, aMousePnt.myCurY));
+ auto anOriginalPosition = std::shared_ptr<GeomAPI_Pnt2d>(new GeomAPI_Pnt2d(myCurrentPoint.myCurX, myCurrentPoint.myCurY));
+ auto aCurrentPosition = std::shared_ptr<GeomAPI_Pnt2d>(new GeomAPI_Pnt2d(aMousePnt.myCurX, aMousePnt.myCurY));
// 3. the flag to disable the update viewer should be set in order to avoid blinking in the
// viewer happens by deselect/select the modified objects. The flag should be restored after
anAttLast = anAttributes.end();
for (; anAttIt != anAttLast; anAttIt++) {
AttributePtr anAttr = anAttIt->first;
+
if (anAttr.get() == NULL)
continue;
+
std::string aAttrId = anAttr->id();
DataPtr aData = aFeature->data();
if (aData->isValid()) {
aPoint->attributeType() == GeomDataAPI_Point2DArray::typeId()) {
bool isImmutable = aPoint->setImmutable(true);
- std::shared_ptr<ModelAPI_ObjectMovedMessage> aMessage = std::shared_ptr
- <ModelAPI_ObjectMovedMessage>(new ModelAPI_ObjectMovedMessage(this));
+ auto aMessage = std::shared_ptr<ModelAPI_ObjectMovedMessage>(new ModelAPI_ObjectMovedMessage(this));
aMessage->setMovedAttribute(aPoint, anAttIt->second);
aMessage->setOriginalPosition(anOriginalPosition);
aMessage->setCurrentPosition(aCurrentPosition);
}
}
}
- else {
+ else
+ {
// Process selection by feature
- std::shared_ptr<SketchPlugin_Feature> aSketchFeature =
- std::dynamic_pointer_cast<SketchPlugin_Feature>(aFeature);
+ auto aSketchFeature = std::dynamic_pointer_cast<SketchPlugin_Feature>(aFeature);
if (aSketchFeature) {
- std::shared_ptr<ModelAPI_ObjectMovedMessage> aMessage = std::shared_ptr
- <ModelAPI_ObjectMovedMessage>(new ModelAPI_ObjectMovedMessage(this));
+ auto aMessage = std::shared_ptr<ModelAPI_ObjectMovedMessage>(new ModelAPI_ObjectMovedMessage(this));
aMessage->setMovedObject(aFeature);
aMessage->setOriginalPosition(anOriginalPosition);
aMessage->setCurrentPosition(aCurrentPosition);
#endif
myDragDone = true;
- myCurrentPoint = aMousePnt;
+ myCurrentPoint = aHoverPnt;
}
+
+ myLastMouseEventType = theEvent->type();
}
void PartSet_SketcherMgr::onMouseDoubleClick(ModuleBase_IViewWindow* theWnd, QMouseEvent* theEvent)
PartSet_WidgetEditor* anEditor = dynamic_cast<PartSet_WidgetEditor*>(aWgt);
if (anEditor)
anEditor->showPopupEditor();
+
+ myLastMouseEventType = theEvent->type();
return;
}
}
}
}
+
+ myLastMouseEventType = theEvent->type();
}
void PartSet_SketcherMgr::onApplicationStarted()
myIsPopupMenuActive = false;
}
-void PartSet_SketcherMgr::get2dPoint(ModuleBase_IViewWindow* theWnd, QMouseEvent* theEvent,
- Point& thePoint)
+void PartSet_SketcherMgr::get2dPoint(ModuleBase_IViewWindow* theWnd, const QPoint& theEventPos, Point& thePoint, bool theSnap)
{
- Handle(V3d_View) aView = theWnd->v3dView();
- gp_Pnt aPoint = PartSet_Tools::convertClickToPoint(theEvent->pos(), aView);
- double aX, anY;
- PartSet_Tools::convertTo2D(aPoint, myCurrentSketch, aView, aX, anY);
- thePoint.setValue(aX, anY);
+ double aX = 0, aY = 0; // Coords at sketch plane.
+ bool success = PartSet_MouseProcessor::convertPointToLocal(workshop()->moduleConnector(), myCurrentSketch, theWnd, theEventPos, aX, aY, theSnap, true, false);
+ if (!success)
+ return;
+
+ thePoint.setValue(aX, aY);
}
void PartSet_SketcherMgr::launchEditing()