From: vsv Date: Mon, 22 Dec 2014 09:45:48 +0000 (+0300) Subject: Merge branch 'Dev_0.6.1' of newgeom:newgeom into Dev_0.6.1 X-Git-Tag: V_0.7.0_rc1~56^2~8 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=a07cdcdf600fc224bc862686439dfbe01d72524a;p=modules%2Fshaper.git Merge branch 'Dev_0.6.1' of newgeom:newgeom into Dev_0.6.1 Conflicts: src/PartSet/PartSet_Module.cpp --- a07cdcdf600fc224bc862686439dfbe01d72524a diff --cc src/PartSet/PartSet_Module.cpp index 309c6a607,4d84d8168..94c577a55 --- a/src/PartSet/PartSet_Module.cpp +++ b/src/PartSet/PartSet_Module.cpp @@@ -255,6 -345,214 +255,7 @@@ void PartSet_Module::onSelectionChanged } } -void PartSet_Module::onMousePressed(ModuleBase_IViewWindow* theWnd, QMouseEvent* theEvent) -{ - if (!(theEvent->buttons() & Qt::LeftButton)) - return; - - ModuleBase_Operation* aOperation = myWorkshop->currentOperation(); - // Use only for sketch operations - if (aOperation && myCurrentSketch) { - if (!PartSet_Tools::sketchPlane(myCurrentSketch)) - return; - - bool isSketcher = (aOperation->id().toStdString() == SketchPlugin_Sketch::ID()); - bool isSketchOpe = sketchOperationIdList().contains(aOperation->id()); - - // Avoid non-sketch operations - if ((!isSketchOpe) && (!isSketcher)) - return; - - bool isEditing = aOperation->isEditOperation(); - - // Ignore creation sketch operation - if ((!isSketcher) && (!isEditing)) - return; - - if (theEvent->modifiers()) { - // If user performs multiselection - if (isSketchOpe && (!isSketcher)) - if (!aOperation->commit()) - aOperation->abort(); - return; - } - // Remember highlighted objects for editing - ModuleBase_ISelection* aSelect = myWorkshop->selection(); - QList aHighlighted = aSelect->getHighlighted(); - QList aSelected = aSelect->getSelected(); - myEditingFeatures.clear(); - myEditingAttr.clear(); - if ((aHighlighted.size() == 0) && (aSelected.size() == 0)) { - if (isSketchOpe && (!isSketcher)) - // commit previous operation - if (!aOperation->commit()) - aOperation->abort(); - return; - } - - QObjectPtrList aSelObjects = getSumList(aHighlighted, aSelected); - if ((aHighlighted.size() == 1) && (aSelected.size() == 0)) { - // Move by selected shape (vertex). Can be used only for single selection - foreach(ModuleBase_ViewerPrs aPrs, aHighlighted) { - FeaturePtr aFeature = ModelAPI_Feature::feature(aHighlighted.first().object()); - if (aFeature) { - myEditingFeatures.append(aFeature); - TopoDS_Shape aShape = aPrs.shape(); - if (!aShape.IsNull()) { - if (aShape.ShapeType() == TopAbs_VERTEX) { - AttributePtr aAttr = PartSet_Tools::findAttributeBy2dPoint(myEditingFeatures.first(), - aShape, myCurrentSketch); - if (aAttr) - myEditingAttr.append(aAttr); - } - } - } - } - } else { - // Provide multi-selection. Can be used only for features - foreach (ObjectPtr aObj, aSelObjects) { - FeaturePtr aFeature = ModelAPI_Feature::feature(aObj); - if (aFeature && (!myEditingFeatures.contains(aFeature))) - myEditingFeatures.append(aFeature); - } - - } - // If nothing highlighted - return - if (myEditingFeatures.size() == 0) - return; - - if (isSketcher) { - myIsDragging = true; - get2dPoint(theWnd, theEvent, myCurX, myCurY); - myDragDone = false; - myWorkshop->viewer()->enableSelection(false); - launchEditing(); - - } else if (isSketchOpe && isEditing) { - // If selected another object - aOperation->abort(); - - myIsDragging = true; - get2dPoint(theWnd, theEvent, myCurX, myCurY); - myDragDone = false; - myWorkshop->viewer()->enableSelection(false); - - // This is necessary in order to finalize previous operation - QApplication::processEvents(); - launchEditing(); - } - } -} - - -void PartSet_Module::get2dPoint(ModuleBase_IViewWindow* theWnd, QMouseEvent* theEvent, - double& theX, double& theY) -{ - Handle(V3d_View) aView = theWnd->v3dView(); - gp_Pnt aPoint = PartSet_Tools::convertClickToPoint(theEvent->pos(), aView); - PartSet_Tools::convertTo2D(aPoint, myCurrentSketch, aView, theX, theY); -} - - -void PartSet_Module::launchEditing() -{ - if (myEditingFeatures.size() > 0) { - FeaturePtr aFeature = myEditingFeatures.first(); - std::shared_ptr aSPFeature = - std::dynamic_pointer_cast(aFeature); - if (aSPFeature) { - editFeature(aSPFeature); - } - } -} - -void PartSet_Module::onMouseReleased(ModuleBase_IViewWindow* theWnd, QMouseEvent* theEvent) -{ - myWorkshop->viewer()->enableSelection(true); - if (myIsDragging) { - myIsDragging = false; - if (myDragDone) { - myWorkshop->currentOperation()->commit(); - myEditingFeatures.clear(); - myEditingAttr.clear(); - } - } -} - - -void PartSet_Module::onMouseMoved(ModuleBase_IViewWindow* theWnd, QMouseEvent* theEvent) -{ - if (myIsDragging) { - ModuleBase_Operation* aOperation = myWorkshop->currentOperation(); - if (aOperation->id().toStdString() == SketchPlugin_Sketch::ID()) - return; // No edit operation activated - - static Events_ID anEvent = Events_Loop::eventByName(EVENT_OBJECT_MOVED); - Handle(V3d_View) aView = theWnd->v3dView(); - gp_Pnt aPoint = PartSet_Tools::convertClickToPoint(theEvent->pos(), aView); - double aX, aY; - PartSet_Tools::convertTo2D(aPoint, myCurrentSketch, aView, aX, aY); - double dX = aX - myCurX; - double dY = aY - myCurY; - - if ((aOperation->id().toStdString() == SketchPlugin_Line::ID()) && - (myEditingAttr.size() == 1) && - myEditingAttr.first()) { - // probably we have prehighlighted point - AttributePtr aAttr = myEditingAttr.first(); - std::string aAttrId = aAttr->id(); - ModuleBase_IPropertyPanel* aPanel = aOperation->propertyPanel(); - QList aWidgets = aPanel->modelWidgets(); - // Find corresponded widget to provide dragging - foreach (ModuleBase_ModelWidget* aWgt, aWidgets) { - if (aWgt->attributeID() == aAttrId) { - PartSet_WidgetPoint2D* aWgt2d = dynamic_cast(aWgt); - if (aWgt2d) { - aWgt2d->setPoint(aWgt2d->x() + dX, aWgt2d->y() + dY); - break; - } - } - } - } else { - foreach(FeaturePtr aFeature, myEditingFeatures) { - std::shared_ptr aSketchFeature = - std::dynamic_pointer_cast(aFeature); - if (aSketchFeature) { - aSketchFeature->move(dX, dY); - ModelAPI_EventCreator::get()->sendUpdated(aSketchFeature, anEvent); - } - } + // after movement the solver will call the update event: optimization - Events_Loop::loop()->flush(Events_Loop::eventByName(EVENT_OBJECT_MOVED)); - } - myDragDone = true; - myCurX = aX; - myCurY = aY; - } -} - -void PartSet_Module::onMouseDoubleClick(ModuleBase_IViewWindow* theWnd, QMouseEvent* theEvent) -{ - ModuleBase_Operation* aOperation = myWorkshop->currentOperation(); - if (aOperation && 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 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) {