From: vsv Date: Thu, 30 Oct 2014 08:11:49 +0000 (+0300) Subject: Merge branch 'master' of newgeom:newgeom X-Git-Tag: V_0.5~60^2~3 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=382d93420f7c2a22034b9d74a0d2dbc955e24acb;hp=342e2b041c468ebc85e5d6cffc9b69cdcec2429c;p=modules%2Fshaper.git Merge branch 'master' of newgeom:newgeom --- diff --git a/src/GeomDataAPI/GeomDataAPI_Point2D.h b/src/GeomDataAPI/GeomDataAPI_Point2D.h index 6189e87d2..c0eb001cf 100644 --- a/src/GeomDataAPI/GeomDataAPI_Point2D.h +++ b/src/GeomDataAPI/GeomDataAPI_Point2D.h @@ -30,6 +30,13 @@ class GeomDataAPI_Point2D : public ModelAPI_Attribute /// Returns the 2D point virtual boost::shared_ptr pnt() = 0; + /// Appends the delta values to point + void move(const double theDeltaX, const double theDeltaY) + { + setValue(x() + theDeltaX, y() + theDeltaY); + } + + /// Returns the type of this class of attributes static inline std::string type() { diff --git a/src/ModuleBase/ModuleBase_IModule.cpp b/src/ModuleBase/ModuleBase_IModule.cpp index df2502fbb..36e09437e 100644 --- a/src/ModuleBase/ModuleBase_IModule.cpp +++ b/src/ModuleBase/ModuleBase_IModule.cpp @@ -34,7 +34,7 @@ void ModuleBase_IModule::launchOperation(const QString& theCmdId) ModuleBase_Operation* anOperation = createOperation(theCmdId.toStdString()); ModuleBase_ISelection* aSelection = myWorkshop->selection(); // Initialise operation with preliminary selection - anOperation->initSelection(aSelection); + anOperation->initSelection(aSelection, myWorkshop->viewer()); sendOperation(anOperation); } diff --git a/src/ModuleBase/ModuleBase_Operation.cpp b/src/ModuleBase/ModuleBase_Operation.cpp index 5ffb8b760..30410bfdc 100644 --- a/src/ModuleBase/ModuleBase_Operation.cpp +++ b/src/ModuleBase/ModuleBase_Operation.cpp @@ -285,7 +285,8 @@ bool ModuleBase_Operation::activateByPreselection() return false; } -void ModuleBase_Operation::initSelection(ModuleBase_ISelection* theSelection) +void ModuleBase_Operation::initSelection(ModuleBase_ISelection* theSelection, + ModuleBase_IViewer* /*theViewer*/) { myPreSelection.clear(); diff --git a/src/ModuleBase/ModuleBase_Operation.h b/src/ModuleBase/ModuleBase_Operation.h index 9d1a1c04a..07b413218 100644 --- a/src/ModuleBase/ModuleBase_Operation.h +++ b/src/ModuleBase/ModuleBase_Operation.h @@ -22,6 +22,7 @@ class ModuleBase_ModelWidget; class ModuleBase_OperationDescription; class ModuleBase_IPropertyPanel; class ModuleBase_ISelection; +class ModuleBase_IViewer; class QKeyEvent; @@ -117,7 +118,9 @@ Q_OBJECT /// Initialisation of operation with preliminary selection /// \param theSelected the list of selected presentations /// \param theHighlighted the list of highlighted presentations - virtual void initSelection(ModuleBase_ISelection* theSelection); + /// \param theViewer a viewer to have the viewer the eye position + virtual void initSelection(ModuleBase_ISelection* theSelection, + ModuleBase_IViewer* /* theViewer*/); virtual void setPropertyPanel(ModuleBase_IPropertyPanel* theProp); diff --git a/src/PartSet/PartSet_Module.cpp b/src/PartSet/PartSet_Module.cpp index f38381ef8..035444ba9 100644 --- a/src/PartSet/PartSet_Module.cpp +++ b/src/PartSet/PartSet_Module.cpp @@ -311,7 +311,7 @@ void PartSet_Module::onRestartOperation(std::string theName, ObjectPtr theObject } ModuleBase_ISelection* aSelection = workshop()->selection(); // Initialise operation with preliminary selection - aSketchOp->initSelection(aSelection); + aSketchOp->initSelection(aSelection, myWorkshop->viewer()); } //else if (aFeature) { //anOperation->setFeature(aFeature); ////Deactivate result of current feature in order to avoid its selection diff --git a/src/PartSet/PartSet_OperationFeatureEdit.cpp b/src/PartSet/PartSet_OperationFeatureEdit.cpp index f84466fe2..a9d85bb8c 100644 --- a/src/PartSet/PartSet_OperationFeatureEdit.cpp +++ b/src/PartSet/PartSet_OperationFeatureEdit.cpp @@ -30,6 +30,9 @@ #include #include +#include +#include +#include #include #include @@ -54,6 +57,80 @@ PartSet_OperationFeatureEdit::~PartSet_OperationFeatureEdit() { } +void PartSet_OperationFeatureEdit::initSelection(ModuleBase_ISelection* theSelection, + ModuleBase_IViewer* theViewer) +{ + PartSet_OperationFeatureBase::initSelection(theSelection, theViewer); + // 1. unite selected and hightlighted objects in order to have an opportunity to drag + // by the highlighted object + QList aFeatures = theSelection->getSelected(); + QList aHighlighted = theSelection->getHighlighted(); + // add highlighted elements if they are not selected + foreach (ModuleBase_ViewerPrs aPrs, aHighlighted) { + if (!PartSet_Tools::isContainPresentation(aFeatures, aPrs)) + aFeatures.append(aPrs); + } + + // 1. find all features with skipping features with selected vertex shapes + myFeature2Attribute.clear(); + // firstly, collect the features without local selection + /*foreach (ModuleBase_ViewerPrs aPrs, aFeatures) { + const TopoDS_Shape& aShape = aPrs.shape(); + if (!aShape.IsNull() && aShape.ShapeType() == TopAbs_VERTEX) { // a point is selected + const TopoDS_Vertex& aVertex = TopoDS::Vertex(aShape); + if (!aVertex.IsNull()) { + continue; + } + } + else { + ObjectPtr aObject = aPrs.object(); + if (!aObject) + continue; + FeaturePtr aFeature = ModelAPI_Feature::feature(aObject); + if (aFeature && myFeature2Attribute.find(aFeature) == myFeature2Attribute.end()) { + std::list aList; + // using an empty list as a sign, that this feature should be moved itself + myFeature2Attribute[aFeature] = aList; + } + } + }*/ + // 2. collect the features with a local selection on them. + // if the list already has this feature, the local selection is skipped + // that means that if the selection contains a feature and a feature with local selected point, + // the edit is performed for a full feature + Handle(V3d_View) aView = theViewer->activeView(); + foreach (ModuleBase_ViewerPrs aPrs, aFeatures) { + const TopoDS_Shape& aShape = aPrs.shape(); + if (!aShape.IsNull() && aShape.ShapeType() == TopAbs_VERTEX) { // a point is selected + const TopoDS_Vertex& aVertex = TopoDS::Vertex(aShape); + if (aVertex.IsNull()) + continue; + ObjectPtr aObject = aPrs.object(); + if (!aObject) + continue; + FeaturePtr aFeature = ModelAPI_Feature::feature(aObject); + if (!aFeature) + continue; + // if the feature is already moved, do nothing for this feature local selection + if (myFeature2Attribute.find(aFeature) != myFeature2Attribute.end()) + continue; + + // append the attribute of the vertex if it is found on the current feature + gp_Pnt aPoint = BRep_Tool::Pnt(aVertex); + double aVX, aVY; + PartSet_Tools::convertTo2D(aPoint, sketch(), aView, aVX, aVY); + boost::shared_ptr aPoint2D = PartSet_Tools::getFeaturePoint( + aFeature, aVX, aVY); + std::string anAttribute = aFeature->data()->id(aPoint2D); + std::list aList; + if (myFeature2Attribute.find(aFeature) != myFeature2Attribute.end()) + aList = myFeature2Attribute[aFeature]; + + aList.push_back(anAttribute); + myFeature2Attribute[aFeature] = aList; + } + } +} void PartSet_OperationFeatureEdit::mousePressed(QMouseEvent* theEvent, ModuleBase_IViewer* theViewer, ModuleBase_ISelection* theSelection) { @@ -137,11 +214,46 @@ void PartSet_OperationFeatureEdit::mouseMoved(QMouseEvent* theEvent, ModuleBase_ boost::shared_ptr aSketchFeature = boost::dynamic_pointer_cast< SketchPlugin_Feature>(feature()); - // MPV: added condition because it could be external edge of some object, not sketch - if (aSketchFeature && aSketchFeature->sketch() == sketch().get()) { - aSketchFeature->move(aDeltaX, aDeltaY); - static Events_ID anEvent = Events_Loop::eventByName(EVENT_OBJECT_TO_REDISPLAY); - ModelAPI_EventCreator::get()->sendUpdated(feature(), anEvent); + + bool isMoved = false; + // the functionality to move the feature attribute if it exists in the internal map + std::map>::iterator aFeatIter = myFeature2Attribute.begin(); + while (aFeatIter != myFeature2Attribute.end()) { + FeaturePtr aFeature = aFeatIter->first; + std::list anAttributes = aFeatIter->second; + // perform edit for the feature + /*if (anAttributes.empty()) { + boost::shared_ptr aSketchFeature = + boost::dynamic_pointer_cast(aFeature); + if (aSketchFeature) { + aSketchFeature->move(aDeltaX, aDeltaY); + } + }*/ + // perform edit for the feature's attribute + //else { + if (!anAttributes.empty()) { + std::list::const_iterator anAttrIter = anAttributes.begin(), + anAttrEnd = anAttributes.end(); + for (; anAttrIter != anAttrEnd; anAttrIter++) { + boost::shared_ptr aPointAttr = boost::dynamic_pointer_cast< + GeomDataAPI_Point2D>(aFeature->data()->attribute(*anAttrIter)); + if (aPointAttr) { + aPointAttr->move(aDeltaX, aDeltaY); + isMoved = true; + } + } + } + aFeatIter++; + } + + // the feature is moved only if there is no a local selection on this feature + if (!isMoved) { + // MPV: added condition because it could be external edge of some object, not sketch + if (aSketchFeature && aSketchFeature->sketch() == sketch().get()) { + aSketchFeature->move(aDeltaX, aDeltaY); + static Events_ID anEvent = Events_Loop::eventByName(EVENT_OBJECT_TO_REDISPLAY); + ModelAPI_EventCreator::get()->sendUpdated(feature(), anEvent); + } } } sendFeatures(); diff --git a/src/PartSet/PartSet_OperationFeatureEdit.h b/src/PartSet/PartSet_OperationFeatureEdit.h index 293c63d95..5e612c2ef 100644 --- a/src/PartSet/PartSet_OperationFeatureEdit.h +++ b/src/PartSet/PartSet_OperationFeatureEdit.h @@ -71,6 +71,14 @@ Q_OBJECT /// Destructor virtual ~PartSet_OperationFeatureEdit(); + + /// Initialisation of operation with preliminary selection + /// \param theSelected the list of selected presentations + /// \param theHighlighted the list of highlighted presentations + /// \param theViewer a viewer to have the viewer the eye position + virtual void initSelection(ModuleBase_ISelection* theSelection, + ModuleBase_IViewer* theViewer); + /// Processes the mouse pressed in the point /// \param theEvent the mouse event /// \param theView a viewer to have the viewer the eye position @@ -127,6 +135,9 @@ Q_OBJECT void sendFeatures(); private: + // the next map should be removed when selection is processed in the move function + std::map > myFeature2Attribute; /// a map of a feature to attributes + Point myCurPoint; ///< the current 3D point clicked or moved bool myIsBlockedSelection; ///< the state of the last state of selection blocked signal }; diff --git a/src/PartSet/PartSet_OperationFeatureEditMulti.cpp b/src/PartSet/PartSet_OperationFeatureEditMulti.cpp index 4b10858a0..ddf9b8d47 100644 --- a/src/PartSet/PartSet_OperationFeatureEditMulti.cpp +++ b/src/PartSet/PartSet_OperationFeatureEditMulti.cpp @@ -25,6 +25,9 @@ #include #include +#include +#include +#include #include #ifdef _DEBUG @@ -47,48 +50,77 @@ PartSet_OperationFeatureEditMulti::~PartSet_OperationFeatureEditMulti() { } - -bool isContains(const QList& theSelected, const ModuleBase_ViewerPrs& thePrs) +void PartSet_OperationFeatureEditMulti::initSelection(ModuleBase_ISelection* theSelection, + ModuleBase_IViewer* theViewer) { - foreach (ModuleBase_ViewerPrs aPrs, theSelected) { - if (aPrs.object() == thePrs.object()) - return true; - } - return false; -} - - -void PartSet_OperationFeatureEditMulti::initSelection(ModuleBase_ISelection* theSelection) -{ - //if (!theHighlighted.empty()) { - // // if there is highlighted object, we check whether it is in the list of selected objects - // // in that case this object is a handle of the moved lines. If there no such object in the selection, - // // the hightlighted object should moved and the selection is skipped. The skipped selection will be - // // deselected in the viewer by blockSelection signal in the startOperation method. - // bool isSelected = false; - // std::list::const_iterator anIt = theSelected.begin(), - // aLast = theSelected.end(); - // for (; anIt != aLast && !isSelected; anIt++) { - // isSelected = ModelAPI_Feature::feature((*anIt).object()) == feature(); - // } - // if (!isSelected) - // myFeatures = theHighlighted; - // else - // myFeatures = theSelected; - //} else - myFeatures = theSelection->getSelected(); + // 1. unite selected and hightlighted objects in order to have an opportunity to drag + // by the highlighted object + QList aFeatures; + aFeatures = theSelection->getSelected(); QList aHighlighted = theSelection->getHighlighted(); // add highlighted elements if they are not selected foreach (ModuleBase_ViewerPrs aPrs, aHighlighted) { - if (!isContains(myFeatures, aPrs)) - myFeatures.append(aPrs); + if (!PartSet_Tools::isContainPresentation(aFeatures, aPrs)) + aFeatures.append(aPrs); } - // Remove current feature if it is in the list (it will be moved as main feature) - foreach (ModuleBase_ViewerPrs aPrs, myFeatures) { - FeaturePtr aF = ModelAPI_Feature::feature(aPrs.object()); - if (ModelAPI_Feature::feature(aPrs.object()) == feature()) { - myFeatures.removeOne(aPrs); - break; + + // 1. find all features with skipping features with selected vertex shapes + myFeature2Attribute.clear(); + // firstly, collect the features without local selection + foreach (ModuleBase_ViewerPrs aPrs, aFeatures) { + const TopoDS_Shape& aShape = aPrs.shape(); + if (!aShape.IsNull() && aShape.ShapeType() == TopAbs_VERTEX) { // a point is selected + const TopoDS_Vertex& aVertex = TopoDS::Vertex(aShape); + if (!aVertex.IsNull()) { + continue; + } + } + else { + ObjectPtr aObject = aPrs.object(); + if (!aObject) + continue; + FeaturePtr aFeature = ModelAPI_Feature::feature(aObject); + if (aFeature && myFeature2Attribute.find(aFeature) == myFeature2Attribute.end()) { + std::list aList; + // using an empty list as a sign, that this feature should be moved itself + myFeature2Attribute[aFeature] = aList; + } + } + } + // 2. collect the features with a local selection on them. + // if the list already has this feature, the local selection is skipped + // that means that if the selection contains a feature and a feature with local selected point, + // the edit is performed for a full feature + Handle(V3d_View) aView = theViewer->activeView(); + foreach (ModuleBase_ViewerPrs aPrs, aFeatures) { + const TopoDS_Shape& aShape = aPrs.shape(); + if (!aShape.IsNull() && aShape.ShapeType() == TopAbs_VERTEX) { // a point is selected + const TopoDS_Vertex& aVertex = TopoDS::Vertex(aShape); + if (aVertex.IsNull()) + continue; + ObjectPtr aObject = aPrs.object(); + if (!aObject) + continue; + FeaturePtr aFeature = ModelAPI_Feature::feature(aObject); + if (!aFeature) + continue; + // if the feature is already moved, do nothing for this feature local selection + if (myFeature2Attribute.find(aFeature) != myFeature2Attribute.end()) + continue; + + // append the attribute of the vertex if it is found on the current feature + gp_Pnt aPoint = BRep_Tool::Pnt(aVertex); + double aVX, aVY; + PartSet_Tools::convertTo2D(aPoint, sketch(), aView, aVX, aVY); + boost::shared_ptr aPoint2D = PartSet_Tools::getFeaturePoint( + aFeature, aVX, aVY); + std::string anAttribute = aFeature->data()->id(aPoint2D); + std::list aList; + if (myFeature2Attribute.find(aFeature) != myFeature2Attribute.end()) + aList = myFeature2Attribute[aFeature]; + + aList.push_back(anAttribute); + myFeature2Attribute[aFeature] = aList; } } } @@ -124,20 +156,31 @@ void PartSet_OperationFeatureEditMulti::mouseMoved(QMouseEvent* theEvent, Module double aDeltaX = aX - aCurX; double aDeltaY = anY - aCurY; - boost::shared_ptr aSketchFeature = boost::dynamic_pointer_cast< - SketchPlugin_Feature>(feature()); - aSketchFeature->move(aDeltaX, aDeltaY); - - foreach (ModuleBase_ViewerPrs aPrs, myFeatures) { - ObjectPtr aObject = aPrs.object(); - if (!aObject || aObject == feature()) - continue; - FeaturePtr aFeature = ModelAPI_Feature::feature(aObject); - if (aFeature) { - aSketchFeature = boost::dynamic_pointer_cast(aFeature); - if (aSketchFeature) + std::map>::iterator aFeatIter = myFeature2Attribute.begin(); + while (aFeatIter != myFeature2Attribute.end()) { + FeaturePtr aFeature = aFeatIter->first; + std::list anAttributes = aFeatIter->second; + // perform edit for the feature + if (anAttributes.empty()) { + boost::shared_ptr aSketchFeature = + boost::dynamic_pointer_cast(aFeature); + if (aSketchFeature) { aSketchFeature->move(aDeltaX, aDeltaY); + } } + // perform edit for the feature's attribute + else { + std::list::const_iterator anAttrIter = anAttributes.begin(), + anAttrEnd = anAttributes.end(); + for (; anAttrIter != anAttrEnd; anAttrIter++) { + boost::shared_ptr aPointAttr = boost::dynamic_pointer_cast< + GeomDataAPI_Point2D>(aFeature->data()->attribute(*anAttrIter)); + if (aPointAttr) { + aPointAttr->move(aDeltaX, aDeltaY); + } + } + } + aFeatIter++; } } sendFeatures(); @@ -151,11 +194,13 @@ void PartSet_OperationFeatureEditMulti::mouseReleased( { theViewer->enableSelection(true); if (commit()) { - foreach (ModuleBase_ViewerPrs aPrs, myFeatures) { - ObjectPtr aFeature = aPrs.object(); + std::map>::iterator aFeatIter = myFeature2Attribute.begin(); + while (aFeatIter != myFeature2Attribute.end()) { + FeaturePtr aFeature = aFeatIter->first; if (aFeature) { emit featureConstructed(aFeature, FM_Deactivation); } + aFeatIter++; } } } @@ -176,7 +221,7 @@ void PartSet_OperationFeatureEditMulti::stopOperation() //blockSelection(false, true); - myFeatures.clear(); + myFeature2Attribute.clear(); } //void PartSet_OperationFeatureEditMulti::blockSelection(bool isBlocked, @@ -206,13 +251,15 @@ void PartSet_OperationFeatureEditMulti::sendFeatures() { static Events_ID anEvent = Events_Loop::eventByName(EVENT_OBJECT_MOVED); - foreach (ModuleBase_ViewerPrs aPrs, myFeatures) { - ObjectPtr aFeature = aPrs.object(); - if (!aFeature) - continue; - - ModelAPI_EventCreator::get()->sendUpdated(aFeature, anEvent); + std::map>::iterator aFeatIter = myFeature2Attribute.begin(); + while (aFeatIter != myFeature2Attribute.end()) { + FeaturePtr aFeature = aFeatIter->first; + if (aFeature) { + ModelAPI_EventCreator::get()->sendUpdated(aFeature, anEvent); + } + aFeatIter++; } + Events_Loop::loop()->flush(anEvent); flushUpdated(); } diff --git a/src/PartSet/PartSet_OperationFeatureEditMulti.h b/src/PartSet/PartSet_OperationFeatureEditMulti.h index 77a9dbb54..5b50a7bd6 100644 --- a/src/PartSet/PartSet_OperationFeatureEditMulti.h +++ b/src/PartSet/PartSet_OperationFeatureEditMulti.h @@ -12,6 +12,7 @@ #include #include +#include class QMouseEvent; @@ -76,7 +77,9 @@ Q_OBJECT /// Initialisation of operation with preliminary selection /// \param theSelected the list of selected presentations /// \param theHighlighted the list of highlighted presentations - virtual void initSelection(ModuleBase_ISelection* theSelection); + /// \param theViewer a viewer to have the viewer the eye position + virtual void initSelection(ModuleBase_ISelection* theSelection, + ModuleBase_IViewer* theViewer); /// Returns the operation sketch feature /// \returns the sketch instance @@ -123,9 +126,11 @@ Q_OBJECT /// Sends the features void sendFeatures(); - private: +private: + // the next map should be removed when selection is processed in the move function + std::map > myFeature2Attribute; /// a map of a feature to attributes + CompositeFeaturePtr mySketch; ///< the sketch feature - QList myFeatures; ///< the features to apply the edit operation Point myCurPoint; ///< the current 3D point clicked or moved bool myIsBlockedSelection; ///< the state of the last state of selection blocked signal }; diff --git a/src/PartSet/PartSet_Tools.cpp b/src/PartSet/PartSet_Tools.cpp index 14971c097..f11abff58 100644 --- a/src/PartSet/PartSet_Tools.cpp +++ b/src/PartSet/PartSet_Tools.cpp @@ -178,16 +178,24 @@ boost::shared_ptr PartSet_Tools::document() return ModelAPI_Session::get()->moduleDocument(); } -void PartSet_Tools::setFeaturePoint(FeaturePtr theFeature, double theX, double theY, - const std::string& theAttribute) +boost::shared_ptr PartSet_Tools::getFeaturePoint(FeaturePtr theFeature, + double theX, double theY) { - if (!theFeature) - return; - boost::shared_ptr aData = theFeature->data(); - boost::shared_ptr aPoint = - boost::dynamic_pointer_cast(aData->attribute(theAttribute)); - if (aPoint) - aPoint->setValue(theX, theY); + boost::shared_ptr aClickedPoint = boost::shared_ptr( + new GeomAPI_Pnt2d(theX, theY)); + std::list > anAttiributes = + theFeature->data()->attributes(GeomDataAPI_Point2D::type()); + std::list >::const_iterator anIt = anAttiributes.begin(), + aLast = anAttiributes.end(); + boost::shared_ptr aFPoint; + for (; anIt != aLast && !aFPoint; anIt++) { + boost::shared_ptr aCurPoint = boost::dynamic_pointer_cast< + GeomDataAPI_Point2D>(*anIt); + if (aCurPoint && aCurPoint->pnt()->distance(aClickedPoint) < Precision::Confusion()) + aFPoint = aCurPoint; + } + + return aFPoint; } void PartSet_Tools::setFeatureValue(FeaturePtr theFeature, double theValue, @@ -409,4 +417,14 @@ ResultPtr PartSet_Tools::createFixedObjectByEdge(const ModuleBase_ViewerPrs& the } } return ResultPtr(); -} \ No newline at end of file +} + +bool PartSet_Tools::isContainPresentation(const QList& theSelected, + const ModuleBase_ViewerPrs& thePrs) +{ + foreach (ModuleBase_ViewerPrs aPrs, theSelected) { + if (aPrs.object() == thePrs.object()) + return true; + } + return false; +} diff --git a/src/PartSet/PartSet_Tools.h b/src/PartSet/PartSet_Tools.h index 16c79788d..c847a1ad1 100644 --- a/src/PartSet/PartSet_Tools.h +++ b/src/PartSet/PartSet_Tools.h @@ -65,13 +65,13 @@ class PARTSET_EXPORT PartSet_Tools /// Returns pointer to the root document. static boost::shared_ptr document(); - /// \brief Save the point to the feature. If the attribute is 2D geometry point, it is filled. + + /// Returns a point attribute of the feature by the coordinates if it is /// \param theFeature the feature /// \param theX the horizontal coordinate /// \param theY the vertical coordinate - /// \param theAttribute the feature attribute - static void setFeaturePoint(FeaturePtr theFeature, double theX, double theY, - const std::string& theAttribute); + static boost::shared_ptr getFeaturePoint(FeaturePtr theFeature, + double theX, double theY); /// \brief Save the double to the feature. If the attribute is double, it is filled. /// \param theFeature the feature @@ -133,6 +133,14 @@ class PARTSET_EXPORT PartSet_Tools /// \param theEdge - an edge /// \return - result of created feature static ResultPtr createFixedObjectByEdge(const ModuleBase_ViewerPrs& thePrs, CompositeFeaturePtr theSketch); + + /// Checks whether the list of selected presentations contains the given one + /// \param theSelected a list of presentations + /// \param thePrs a presentation to be found + /// \return - result of check, true if the list contains the prs + static bool isContainPresentation(const QList& theSelected, + const ModuleBase_ViewerPrs& thePrs); + }; #endif diff --git a/src/SketchPlugin/SketchPlugin_Arc.cpp b/src/SketchPlugin/SketchPlugin_Arc.cpp index ae0b225ec..d9afa4fa9 100644 --- a/src/SketchPlugin/SketchPlugin_Arc.cpp +++ b/src/SketchPlugin/SketchPlugin_Arc.cpp @@ -109,15 +109,15 @@ void SketchPlugin_Arc::move(double theDeltaX, double theDeltaY) boost::shared_ptr aPoint1 = boost::dynamic_pointer_cast( aData->attribute(SketchPlugin_Arc::CENTER_ID())); - aPoint1->setValue(aPoint1->x() + theDeltaX, aPoint1->y() + theDeltaY); + aPoint1->move(theDeltaX, theDeltaY); boost::shared_ptr aPoint2 = boost::dynamic_pointer_cast( aData->attribute(SketchPlugin_Arc::START_ID())); - aPoint2->setValue(aPoint2->x() + theDeltaX, aPoint2->y() + theDeltaY); + aPoint2->move(theDeltaX, theDeltaY); boost::shared_ptr aPoint3 = boost::dynamic_pointer_cast( aData->attribute(SketchPlugin_Arc::END_ID())); - aPoint3->setValue(aPoint3->x() + theDeltaX, aPoint3->y() + theDeltaY); + aPoint3->move(theDeltaX, theDeltaY); } double SketchPlugin_Arc::distanceToPoint(const boost::shared_ptr& thePoint) diff --git a/src/SketchPlugin/SketchPlugin_Circle.cpp b/src/SketchPlugin/SketchPlugin_Circle.cpp index e4d9d8e94..992fc321d 100644 --- a/src/SketchPlugin/SketchPlugin_Circle.cpp +++ b/src/SketchPlugin/SketchPlugin_Circle.cpp @@ -92,7 +92,7 @@ void SketchPlugin_Circle::move(double theDeltaX, double theDeltaY) boost::shared_ptr aPoint1 = boost::dynamic_pointer_cast( aData->attribute(SketchPlugin_Circle::CENTER_ID())); - aPoint1->setValue(aPoint1->x() + theDeltaX, aPoint1->y() + theDeltaY); + aPoint1->move(theDeltaX, theDeltaY); } double SketchPlugin_Circle::distanceToPoint(const boost::shared_ptr& thePoint) diff --git a/src/SketchPlugin/SketchPlugin_ConstraintDistance.cpp b/src/SketchPlugin/SketchPlugin_ConstraintDistance.cpp index 65c6cf9ce..90e1a2437 100644 --- a/src/SketchPlugin/SketchPlugin_ConstraintDistance.cpp +++ b/src/SketchPlugin/SketchPlugin_ConstraintDistance.cpp @@ -143,9 +143,9 @@ void SketchPlugin_ConstraintDistance::move(double theDeltaX, double theDeltaY) if (!aData->isValid()) return; - boost::shared_ptr aPoint1 = boost::dynamic_pointer_cast( + boost::shared_ptr aPoint = boost::dynamic_pointer_cast( aData->attribute(SketchPlugin_Constraint::FLYOUT_VALUE_PNT())); - aPoint1->setValue(aPoint1->x() + theDeltaX, aPoint1->y() + theDeltaY); + aPoint->setValue(theDeltaX, theDeltaY); } //************************************************************************************* diff --git a/src/SketchPlugin/SketchPlugin_ConstraintLength.cpp b/src/SketchPlugin/SketchPlugin_ConstraintLength.cpp index 00061c739..ff8a480b4 100644 --- a/src/SketchPlugin/SketchPlugin_ConstraintLength.cpp +++ b/src/SketchPlugin/SketchPlugin_ConstraintLength.cpp @@ -110,8 +110,8 @@ void SketchPlugin_ConstraintLength::move(double theDeltaX, double theDeltaY) if (!aData->isValid()) return; - boost::shared_ptr aPoint1 = boost::dynamic_pointer_cast( + boost::shared_ptr aPoint = boost::dynamic_pointer_cast( aData->attribute(SketchPlugin_Constraint::FLYOUT_VALUE_PNT())); - aPoint1->setValue(aPoint1->x() + theDeltaX, aPoint1->y() + theDeltaY); + aPoint->move(theDeltaX, theDeltaY); } diff --git a/src/SketchPlugin/SketchPlugin_ConstraintParallel.cpp b/src/SketchPlugin/SketchPlugin_ConstraintParallel.cpp index 056eda939..ae105caa3 100644 --- a/src/SketchPlugin/SketchPlugin_ConstraintParallel.cpp +++ b/src/SketchPlugin/SketchPlugin_ConstraintParallel.cpp @@ -98,6 +98,6 @@ void SketchPlugin_ConstraintParallel::move(double theDeltaX, double theDeltaY) boost::shared_ptr aPoint = boost::dynamic_pointer_cast( aData->attribute(SketchPlugin_Constraint::FLYOUT_VALUE_PNT())); - aPoint->setValue(aPoint->x() + theDeltaX, aPoint->y() + theDeltaY); + aPoint->move(theDeltaX, theDeltaY); } diff --git a/src/SketchPlugin/SketchPlugin_Line.cpp b/src/SketchPlugin/SketchPlugin_Line.cpp index ccefb4bec..dac422267 100644 --- a/src/SketchPlugin/SketchPlugin_Line.cpp +++ b/src/SketchPlugin/SketchPlugin_Line.cpp @@ -65,11 +65,11 @@ void SketchPlugin_Line::move(double theDeltaX, double theDeltaY) boost::shared_ptr aPoint1 = boost::dynamic_pointer_cast( aData->attribute(SketchPlugin_Line::START_ID())); - aPoint1->setValue(aPoint1->x() + theDeltaX, aPoint1->y() + theDeltaY); + aPoint1->move(theDeltaX, theDeltaY); boost::shared_ptr aPoint2 = boost::dynamic_pointer_cast( aData->attribute(SketchPlugin_Line::END_ID())); - aPoint2->setValue(aPoint2->x() + theDeltaX, aPoint2->y() + theDeltaY); + aPoint2->move(theDeltaX, theDeltaY); } double SketchPlugin_Line::distanceToPoint(const boost::shared_ptr& thePoint) diff --git a/src/SketchPlugin/SketchPlugin_Point.cpp b/src/SketchPlugin/SketchPlugin_Point.cpp index 1ad78684f..7cbdb647c 100644 --- a/src/SketchPlugin/SketchPlugin_Point.cpp +++ b/src/SketchPlugin/SketchPlugin_Point.cpp @@ -55,7 +55,7 @@ void SketchPlugin_Point::move(double theDeltaX, double theDeltaY) boost::shared_ptr aPoint1 = boost::dynamic_pointer_cast( aData->attribute(SketchPlugin_Point::COORD_ID())); - aPoint1->setValue(aPoint1->x() + theDeltaX, aPoint1->y() + theDeltaY); + aPoint1->move(theDeltaX, theDeltaY); } double SketchPlugin_Point::distanceToPoint(const boost::shared_ptr& thePoint)