-// Copyright (C) 2014-2017 CEA/DEN, EDF R&D
+// Copyright (C) 2014-2019 CEA/DEN, EDF R&D
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
//
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software
-// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
-// See http://www.salome-platform.org/ or
-// email : webmaster.salome@opencascade.com<mailto:webmaster.salome@opencascade.com>
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
//
#include "PartSet_WidgetPoint2d.h"
// the control should accept the focus, so the boolean flag is corrected to be true
myIsObligatory = true;
- QString aPageName = QString::fromStdString(theData->getProperty(CONTAINER_PAGE_NAME));
+ QString aPageName = translate(theData->getProperty(CONTAINER_PAGE_NAME));
myGroupBox = new QGroupBox(aPageName, theParent);
myGroupBox->setFlat(false);
GeomShapePtr aShape = theValue->shape();
if (aShape.get() && !aShape->isNull()) {
Handle(V3d_View) aView = myWorkshop->viewer()->activeView();
- double aX = 0, aY = 0;
const TopoDS_Shape& aTDShape = aShape->impl<TopoDS_Shape>();
- if (getPoint2d(aView, aTDShape, aX, aY)) {
- fillRefAttribute(aX, aY, theValue);
+ GeomPnt2dPtr aPnt = PartSet_Tools::getPnt2d(aView, aTDShape, mySketch);
+ if (aPnt) {
+ fillRefAttribute(aPnt->x(), aPnt->y(), theValue);
isDone = true;
}
else if (aTDShape.ShapeType() == TopAbs_EDGE) {
GeomShapePtr aShape = aValue->shape();
if (aShape.get() && !aShape->isNull()) {
Handle(V3d_View) aView = myWorkshop->viewer()->activeView();
- double aX = 0, aY = 0;
const TopoDS_Shape& aTDShape = aShape->impl<TopoDS_Shape>();
- if (getPoint2d(aView, aTDShape, aX, aY)) {
- isDone = setPoint(aX, aY);
- setConstraintToPoint(aX, aY, aValue);
+ GeomPnt2dPtr aPnt = PartSet_Tools::getPnt2d(aView, aTDShape, mySketch);
+ if (aPnt) {
+ isDone = setPoint(aPnt->x(), aPnt->y());
+ setConstraintToPoint(aPnt->x(), aPnt->y(), aValue);
}
}
}
bool PartSet_WidgetPoint2D::storeValueCustom()
{
std::shared_ptr<ModelAPI_Data> aData = myFeature->data();
- if (!aData) // can be on abort of sketcher element
+ if (!aData || !aData->isValid()) // can be on abort of sketcher element
return false;
AttributePoint2DPtr aPoint = std::dynamic_pointer_cast<GeomDataAPI_Point2D>(
aData->attribute(attributeID()));
ModuleBase_ModelWidget::deactivate();
}
-bool PartSet_WidgetPoint2D::getPoint2d(const Handle(V3d_View)& theView,
- const TopoDS_Shape& theShape,
- double& theX, double& theY) const
-{
- if (!theShape.IsNull()) {
- if (theShape.ShapeType() == TopAbs_VERTEX) {
- const TopoDS_Vertex& aVertex = TopoDS::Vertex(theShape);
- if (!aVertex.IsNull()) {
- // A case when point is taken from existing vertex
- gp_Pnt aPoint = BRep_Tool::Pnt(aVertex);
- PartSet_Tools::convertTo2D(aPoint, mySketch, theView, theX, theY);
- return true;
- }
- }
- }
- return false;
-}
-
bool PartSet_WidgetPoint2D::setConstraintToPoint(double theClickedX, double theClickedY,
const std::shared_ptr<ModuleBase_ViewerPrs>& theValue)
{
AttributePoint2DPtr aFeaturePoint;
if (aFeature->isMacro()) {
// the macro feature will be removed after the operation is stopped, so we need to build
- // coicidence to possible sub-features
+ // coincidence to possible sub-features
aFeaturePoint = findFirstEqualPointInArgumentFeatures(aFeature, aClickedPoint);
}
else {
AttributePoint2DPtr anAttrPoint = std::dynamic_pointer_cast<GeomDataAPI_Point2D>(aThisAttr);
if (anAttrPoint.get()) {
// the macro feature will be removed after the operation is stopped, so we need to build
- // coicidence to possible sub-features
+ // coincidence to possible sub-features
aFeaturePoint = findFirstEqualPointInArgumentFeatures(feature(),
anAttrPoint->pnt());
}
}
}
if (anExternal) {
+ GeomPnt2dPtr aPnt = PartSet_Tools::getPnt2d(aView, aShape, mySketch);
double aX = 0, aY = 0;
- if (getPoint2d(aView, aShape, aX, aY) && isFeatureContainsPoint(myFeature, aX, aY)) {
+ if (aPnt) {
+ aX = aPnt->x();
+ aY = aPnt->y();
+ }
+ if (aPnt && isFeatureContainsPoint(myFeature, aX, aY)) {
// do not create a constraint to the point, which already used by the feature
// if the feature contains the point, focus is not switched
setPoint(aX, aY);
}
else {
- if (getPoint2d(aView, aShape, aX, aY))
+ if (aPnt)
setPoint(aX, aY);
else {
if (aShape.ShapeType() == TopAbs_EDGE) {
if (!anOrphanPoint)
emit vertexSelected(); // it stops the reentrant operation
+ myPreSelected.reset();
emit focusOutWidget(this);
}
}
if (!anExternal) {
- double aX = 0, aY = 0;
bool isProcessed = false;
- if (getPoint2d(aView, aShape, aX, aY) && isFeatureContainsPoint(myFeature, aX, aY)) {
+ GeomPnt2dPtr aPnt = PartSet_Tools::getPnt2d(aView, aShape, mySketch);
+ if (aPnt && isFeatureContainsPoint(myFeature, aPnt->x(), aPnt->y())) {
// when the point is selected, the coordinates of the point should be set into the attribute
// if the feature contains the point, focus is not switched
- setPoint(aX, aY);
+ setPoint(aPnt->x(), aPnt->y());
}
else {
+ double aX = 0, aY = 0;
bool anOrphanPoint = isOrphanPoint(aSelectedFeature, mySketch, aX, aY);
// do not set a coincidence constraint in the attribute if the feature contains a point
// with the same coordinates. It is important for line creation in order to do not set
// the same constraints for the same points, oterwise the result line has zero length.
bool isAuxiliaryFeature = false;
- if (getPoint2d(aView, aShape, aX, aY)) {
+ if (aPnt) {
+ aX = aPnt->x();
+ aY = aPnt->y();
setPoint(aX, aY);
setConstraintToPoint(aX, aY, aFirstValue);
}
updateObject(feature());
if (!anOrphanPoint && !anExternal && !isAuxiliaryFeature)
emit vertexSelected();
+ myPreSelected.reset();
emit focusOutWidget(this);
}
}
// external objects e.g. selection of trihedron axis when input end arc point
updateObject(feature());
- double aX = 0, aY = 0;
- if (getPoint2d(aView, aShape, aX, aY)) {
+ GeomPnt2dPtr aPnt = PartSet_Tools::getPnt2d(aView, aShape, mySketch);
+ if (aPnt) {
// do not create a constraint to the point, which already used by the feature
// if the feature contains the point, focus is not switched
- setPoint(aX, aY);
+ setPoint(aPnt->x(), aPnt->y());
}
emit vertexSelected(); // it stops the reentrant operation
+ myPreSelected.reset();
emit focusOutWidget(this);
}
}
if (!setPoint(aX, aY) || isFeatureContainsPoint(myFeature, aX, aY))
return;
+ myPreSelected.reset();
emit focusOutWidget(this);
}
}
{
myPreSelected = thePreSelected;
mouseReleased(theWnd, theEvent);
- myPreSelected = ModuleBase_ViewerPrsPtr();
}
void PartSet_WidgetPoint2D::getGeomSelection_(const std::shared_ptr<ModuleBase_ViewerPrs>& theValue,