From 5259ad3d241480a929516fe1c78a361ed9e92439 Mon Sep 17 00:00:00 2001 From: wmayer Date: Tue, 13 Aug 2013 20:12:08 +0200 Subject: [PATCH] 0001201: Highlight coincident constraint in sketch view when clicking on (coincident) constraint in constraints list --- src/Mod/Sketcher/App/Sketch.h | 4 +-- src/Mod/Sketcher/Gui/ViewProviderSketch.cpp | 31 ++++++++++++++------- 2 files changed, 23 insertions(+), 12 deletions(-) diff --git a/src/Mod/Sketcher/App/Sketch.h b/src/Mod/Sketcher/App/Sketch.h index a5c3e6f19..851cb2443 100644 --- a/src/Mod/Sketcher/App/Sketch.h +++ b/src/Mod/Sketcher/App/Sketch.h @@ -80,6 +80,8 @@ public: /// get the geometry as python objects Py::Tuple getPyGeometry(void) const; + /// retrieves the index of a point + int getPointId(int geoId, PointPos pos) const; /// retrieves a point Base::Vector3d getPoint(int geoId, PointPos pos); @@ -220,8 +222,6 @@ protected: bool isFine; private: - /// retrieves the index of a point - int getPointId(int geoId, PointPos pos) const; bool updateGeometry(void); diff --git a/src/Mod/Sketcher/Gui/ViewProviderSketch.cpp b/src/Mod/Sketcher/Gui/ViewProviderSketch.cpp index 3ea0cf19d..6ba7bcf6d 100644 --- a/src/Mod/Sketcher/Gui/ViewProviderSketch.cpp +++ b/src/Mod/Sketcher/Gui/ViewProviderSketch.cpp @@ -1770,41 +1770,52 @@ void ViewProviderSketch::updateColor(void) SoSeparator *s = dynamic_cast(edit->constrGroup->getChild(i)); // Check Constraint Type - ConstraintType type = getSketchObject()->Constraints.getValues()[i]->Type; + Sketcher::Constraint* constraint = getSketchObject()->Constraints.getValues()[i]; + ConstraintType type = constraint->Type; bool hasDatumLabel = (type == Sketcher::Angle || type == Sketcher::Radius || type == Sketcher::Symmetric || type == Sketcher::Distance || - type == Sketcher::DistanceX || type == Sketcher::DistanceY); + type == Sketcher::DistanceX || + type == Sketcher::DistanceY); // Non DatumLabel Nodes will have a material excluding coincident bool hasMaterial = false; SoMaterial *m; if (!hasDatumLabel && type != Sketcher::Coincident) { - hasMaterial = true; - m = dynamic_cast(s->getChild(0)); + hasMaterial = true; + m = dynamic_cast(s->getChild(0)); } if (edit->SelConstraintSet.find(i) != edit->SelConstraintSet.end()) { if (hasDatumLabel) { SoDatumLabel *l = dynamic_cast(s->getChild(0)); l->textColor = SelectColor; - } else if (hasMaterial) - m->diffuseColor = SelectColor; + } else if (hasMaterial) { + m->diffuseColor = SelectColor; + } else if (type == Sketcher::Coincident) { + int index; + index = edit->ActSketch.getPointId(constraint->First, constraint->FirstPos) + 1; + if (index >= 0 && index < PtNum) pcolor[index] = SelectColor; + index = edit->ActSketch.getPointId(constraint->Second, constraint->SecondPos) + 1; + if (index >= 0 && index < PtNum) pcolor[index] = SelectColor; + } } else if (edit->PreselectConstraint == i) { if (hasDatumLabel) { SoDatumLabel *l = dynamic_cast(s->getChild(0)); l->textColor = PreselectColor; - } else if (hasMaterial) - m->diffuseColor = PreselectColor; + } else if (hasMaterial) { + m->diffuseColor = PreselectColor; + } } else { if (hasDatumLabel) { SoDatumLabel *l = dynamic_cast(s->getChild(0)); l->textColor = ConstrDimColor; - } else if (hasMaterial) - m->diffuseColor = ConstrDimColor; + } else if (hasMaterial) { + m->diffuseColor = ConstrDimColor; + } } }