#include "PartSet_WidgetPoint2d.h"
#include <PartSet_Tools.h>
#include <PartSet_Module.h>
-#include <PartSet_LockApplyMgr.h>
#include <ModuleBase_ParamSpinBox.h>
#include <ModuleBase_Tools.h>
#include <SketchPlugin_Feature.h>
#include <SketchPlugin_ConstraintCoincidence.h>
+#include <SketchPlugin_Line.h>
+#include <SketchPlugin_Arc.h>
+#include <SketchPlugin_Circle.h>
+#include <SketchPlugin_Point.h>
#include <QGroupBox>
#include <QGridLayout>
const double MaxCoordinate = 1e12;
+static QStringList MyFeaturesForCoincedence;
PartSet_WidgetPoint2D::PartSet_WidgetPoint2D(QWidget* theParent,
ModuleBase_IWorkshop* theWorkshop,
const std::string& theParentId)
: ModuleBase_ModelWidget(theParent, theData, theParentId), myWorkshop(theWorkshop)
{
- myLockApplyMgr = new PartSet_LockApplyMgr(theParent, myWorkshop);
+ if (MyFeaturesForCoincedence.isEmpty()) {
+ MyFeaturesForCoincedence << SketchPlugin_Line::ID().c_str()
+ << SketchPlugin_Arc::ID().c_str()
+ << SketchPlugin_Point::ID().c_str()
+ << SketchPlugin_Circle::ID().c_str();
+ }
// the control should accept the focus, so the boolen flag is corrected to be true
myIsObligatory = true;
myXSpin->setToolTip(tr("X"));
aGroupLay->addWidget(myXSpin, 0, 1);
- connect(myXSpin, SIGNAL(valueChanged(const QString&)), this, SLOT(onValuesChanged()));
+ connect(myXSpin, SIGNAL(valueChanged(const QString&)), this, SIGNAL(valuesModified()));
}
{
QLabel* aLabel = new QLabel(myGroupBox);
myYSpin->setToolTip(tr("Y"));
aGroupLay->addWidget(myYSpin, 1, 1);
- connect(myYSpin, SIGNAL(valueChanged(const QString&)), this, SLOT(onValuesChanged()));
+ connect(myYSpin, SIGNAL(valueChanged(const QString&)), this, SIGNAL(valuesModified()));
}
QVBoxLayout* aLayout = new QVBoxLayout(this);
ModuleBase_Tools::zeroMargins(aLayout);
setLayout(aLayout);
}
-bool PartSet_WidgetPoint2D::reset()
+bool PartSet_WidgetPoint2D::resetCustom()
{
bool aDone = false;
if (!isUseReset() || isComputedDefault() || myXSpin->hasVariable() || myYSpin->hasVariable()) {
return false;
std::shared_ptr<GeomDataAPI_Point2D> aPoint = std::dynamic_pointer_cast<GeomDataAPI_Point2D>(
aData->attribute(attributeID()));
-
+
PartSet_WidgetPoint2D* that = (PartSet_WidgetPoint2D*) this;
bool isBlocked = that->blockSignals(true);
bool isImmutable = aPoint->setImmutable(true);
aModes << TopAbs_VERTEX;
aModes << TopAbs_EDGE;
myWorkshop->activateSubShapesSelection(aModes);
-
- myLockApplyMgr->activate();
}
void PartSet_WidgetPoint2D::deactivate()
{
+ ModuleBase_ModelWidget::deactivate();
ModuleBase_IViewer* aViewer = myWorkshop->viewer();
disconnect(aViewer, SIGNAL(mouseMove(ModuleBase_IViewWindow*, QMouseEvent*)),
this, SLOT(onMouseMove(ModuleBase_IViewWindow*, QMouseEvent*)));
this, SLOT(onMouseRelease(ModuleBase_IViewWindow*, QMouseEvent*)));
myWorkshop->deactivateSubShapesSelection();
-
- myLockApplyMgr->deactivate();
}
bool PartSet_WidgetPoint2D::getPoint2d(const Handle(V3d_View)& theView,
setPoint(aX, aY);
}
else {
+ if (getPoint2d(aView, aShape, aX, aY))
+ setPoint(aX, aY);
setConstraintWith(aObject);
emit vertexSelected();
emit focusOutWidget(this);
// 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.
- if (getPoint2d(aView, aShape, aX, aY))
+ if (getPoint2d(aView, aShape, aX, aY)) {
+ setPoint(aX, aY);
PartSet_Tools::setConstraints(mySketch, feature(), attributeID(), aX, aY);
- else if (aShape.ShapeType() == TopAbs_EDGE)
- setConstraintWith(aObject);
-
+ }
+ else if (aShape.ShapeType() == TopAbs_EDGE) {
+ if (MyFeaturesForCoincedence.contains(myFeature->getKind().c_str()))
+ setConstraintWith(aObject);
+ }
// it is important to perform updateObject() in order to the current value is
// processed by Sketch Solver. Test case: line is created from a previous point
// to some distance, but in the area of the highlighting of the point. Constraint
double aX, anY;
PartSet_Tools::convertTo2D(aPoint, mySketch, theWnd->v3dView(), aX, anY);
+ // we need to block the value state change
+ bool isBlocked = blockValueState(true);
setPoint(aX, anY);
+ blockValueState(isBlocked);
+ setValueState(ModifiedInViewer);
}
double PartSet_WidgetPoint2D::x() const
std::list<AttributePtr> anAttributes =
myFeature->data()->attributes(GeomDataAPI_Point2D::typeId());
std::list<AttributePtr>::iterator anIter = anAttributes.begin();
- for(; anIter != anAttributes.end(); anIter++) {
+ for(; anIter != anAttributes.end() && !aPointIsFound; anIter++) {
AttributePoint2DPtr aPoint2DAttribute =
std::dynamic_pointer_cast<GeomDataAPI_Point2D>(*anIter);
if (aPoint2DAttribute == aWidgetAttribute)
continue;
- if (aPoint2DAttribute.get()) {
+ if (aPoint2DAttribute.get() && aPoint2DAttribute->isInitialized()) {
aPointIsFound = aPoint2DAttribute->pnt()->isEqual(aPnt2d);
}
}
return aPointIsFound;
}
-void PartSet_WidgetPoint2D::onValuesChanged()
+/*void PartSet_WidgetPoint2D::onValuesChanged()
{
- myLockApplyMgr->valuesChanged();
emit valuesChanged();
+}*/
+
+bool PartSet_WidgetPoint2D::processEnter()
+{
+ bool isModified = myXSpin->isModified() || myYSpin->isModified();
+ if (isModified) {
+ bool isXModified = myXSpin->isModified();
+ emit valuesChanged();
+ //onValuesChanged();
+ myXSpin->clearModified();
+ myYSpin->clearModified();
+ if (isXModified)
+ myXSpin->selectAll();
+ else
+ myYSpin->selectAll();
+ }
+ return isModified;
}