diff --git a/src/Mod/Sketcher/Gui/CommandConstraints.cpp b/src/Mod/Sketcher/Gui/CommandConstraints.cpp index a8f675aca..b00676d5e 100644 --- a/src/Mod/Sketcher/Gui/CommandConstraints.cpp +++ b/src/Mod/Sketcher/Gui/CommandConstraints.cpp @@ -531,12 +531,16 @@ void CmdSketcherConstrainDistance::activated(int iMsg) if (SubNames.size() >= 1) { if (SubNames[0].size() > 4 && SubNames[0].substr(0,4) == "Edge") GeoId1 = std::atoi(SubNames[0].substr(4,4000).c_str()); + else if (SubNames[0].size() > 12 && SubNames[0].substr(0,12) == "ExternalEdge") + GeoId1 = -3 - std::atoi(SubNames[0].substr(12,4000).c_str()); else if (SubNames[0].size() > 6 && SubNames[0].substr(0,6) == "Vertex") VtId1 = std::atoi(SubNames[0].substr(6,4000).c_str()); } if (SubNames.size() == 2) { if (SubNames[1].size() > 4 && SubNames[1].substr(0,4) == "Edge") GeoId2 = std::atoi(SubNames[1].substr(4,4000).c_str()); + else if (SubNames[1].size() > 12 && SubNames[1].substr(0,12) == "ExternalEdge") + GeoId2 = -3 - std::atoi(SubNames[1].substr(12,4000).c_str()); else if (SubNames[1].size() > 6 && SubNames[1].substr(0,6) == "Vertex") VtId2 = std::atoi(SubNames[1].substr(6,4000).c_str()); } @@ -678,12 +682,16 @@ void CmdSketcherConstrainPointOnObject::activated(int iMsg) if (SubNames.size() >= 1) { if (SubNames[0].size() > 4 && SubNames[0].substr(0,4) == "Edge") GeoId1 = std::atoi(SubNames[0].substr(4,4000).c_str()); + else if (SubNames[0].size() > 12 && SubNames[0].substr(0,12) == "ExternalEdge") + GeoId1 = -3 - std::atoi(SubNames[0].substr(12,4000).c_str()); else if (SubNames[0].size() > 6 && SubNames[0].substr(0,6) == "Vertex") VtId1 = std::atoi(SubNames[0].substr(6,4000).c_str()); } if (SubNames.size() == 2) { if (SubNames[1].size() > 4 && SubNames[1].substr(0,4) == "Edge") GeoId2 = std::atoi(SubNames[1].substr(4,4000).c_str()); + else if (SubNames[1].size() > 12 && SubNames[1].substr(0,12) == "ExternalEdge") + GeoId2 = -3 - std::atoi(SubNames[1].substr(12,4000).c_str()); else if (SubNames[1].size() > 6 && SubNames[1].substr(0,6) == "Vertex") VtId2 = std::atoi(SubNames[1].substr(6,4000).c_str()); } @@ -767,19 +775,30 @@ void CmdSketcherConstrainDistanceX::activated(int iMsg) if (SubNames.size() >= 1) { if (SubNames[0].size() > 4 && SubNames[0].substr(0,4) == "Edge") GeoId1 = std::atoi(SubNames[0].substr(4,4000).c_str()); + else if (SubNames[0].size() == 6 && SubNames[0].substr(0,6) == "V_Axis") + GeoId1 = -2; else if (SubNames[0].size() > 6 && SubNames[0].substr(0,6) == "Vertex") VtId1 = std::atoi(SubNames[0].substr(6,4000).c_str()); } if (SubNames.size() == 2) { if (SubNames[1].size() > 4 && SubNames[1].substr(0,4) == "Edge") GeoId2 = std::atoi(SubNames[1].substr(4,4000).c_str()); + else if (SubNames[1].size() == 6 && SubNames[0].substr(0,6) == "V_Axis") + GeoId2 = -2; else if (SubNames[1].size() > 6 && SubNames[1].substr(0,6) == "Vertex") VtId2 = std::atoi(SubNames[1].substr(6,4000).c_str()); } + if (GeoId2 == -2 && GeoId1 == Constraint::GeoUndef) { + std::swap(GeoId1,GeoId2); + std::swap(VtId1,VtId2); + } - if (VtId1 >= 0 && VtId2 >= 0) { // point to point horizontal distance + if ((GeoId1 == -2 || VtId1 >= 0) && VtId2 >= 0) { // point to point horizontal distance Sketcher::PointPos PosId1,PosId2; - Obj->getGeoVertexIndex(VtId1,GeoId1,PosId1); + if (GeoId1 == -2) + PosId1 = Sketcher::start; + else + Obj->getGeoVertexIndex(VtId1,GeoId1,PosId1); Obj->getGeoVertexIndex(VtId2,GeoId2,PosId2); Base::Vector3d pnt1 = Obj->getPoint(GeoId1,PosId1); Base::Vector3d pnt2 = Obj->getPoint(GeoId2,PosId2); @@ -901,19 +920,30 @@ void CmdSketcherConstrainDistanceY::activated(int iMsg) if (SubNames.size() >= 1) { if (SubNames[0].size() > 4 && SubNames[0].substr(0,4) == "Edge") GeoId1 = std::atoi(SubNames[0].substr(4,4000).c_str()); + else if (SubNames[0].size() == 6 && SubNames[0].substr(0,6) == "H_Axis") + GeoId1 = -1; else if (SubNames[0].size() > 6 && SubNames[0].substr(0,6) == "Vertex") VtId1 = std::atoi(SubNames[0].substr(6,4000).c_str()); } if (SubNames.size() == 2) { if (SubNames[1].size() > 4 && SubNames[1].substr(0,4) == "Edge") GeoId2 = std::atoi(SubNames[1].substr(4,4000).c_str()); + else if (SubNames[1].size() == 6 && SubNames[0].substr(0,6) == "H_Axis") + GeoId2 = -1; else if (SubNames[1].size() > 6 && SubNames[1].substr(0,6) == "Vertex") VtId2 = std::atoi(SubNames[1].substr(6,4000).c_str()); } + if (GeoId2 == -1 && GeoId1 == Constraint::GeoUndef) { + std::swap(GeoId1,GeoId2); + std::swap(VtId1,VtId2); + } - if (VtId1 >= 0 && VtId2 >= 0) { // point to point horizontal distance + if ((GeoId1 == -1 || VtId1 >= 0) && VtId2 >= 0) { // point to point horizontal distance Sketcher::PointPos PosId1,PosId2; - Obj->getGeoVertexIndex(VtId1,GeoId1,PosId1); + if (GeoId1 == -1) + PosId1 = Sketcher::start; + else + Obj->getGeoVertexIndex(VtId1,GeoId1,PosId1); Obj->getGeoVertexIndex(VtId2,GeoId2,PosId2); Base::Vector3d pnt1 = Obj->getPoint(GeoId1,PosId1); Base::Vector3d pnt2 = Obj->getPoint(GeoId2,PosId2); @@ -1039,6 +1069,8 @@ void CmdSketcherConstrainParallel::activated(int iMsg) std::string subName = *it; if (subName.size() > 4 && subName.substr(0,4) == "Edge") index = std::atoi(subName.substr(4,4000).c_str()); + else if (subName.size() > 12 && subName.substr(0,12) == "ExternalEdge") + index = -3 - std::atoi(subName.substr(12,4000).c_str()); else { QMessageBox::warning(Gui::getMainWindow(), QObject::tr("Wrong selection"), QObject::tr("Select a valid line")); diff --git a/src/Mod/Sketcher/Gui/DrawSketchHandler.cpp b/src/Mod/Sketcher/Gui/DrawSketchHandler.cpp index c1bff588b..947299062 100644 --- a/src/Mod/Sketcher/Gui/DrawSketchHandler.cpp +++ b/src/Mod/Sketcher/Gui/DrawSketchHandler.cpp @@ -198,7 +198,7 @@ int DrawSketchHandler::seekAutoConstraint(std::vector &suggested float smlTangDist = 1e15; // Get geometry list - const std::vector geomlist = sketchgui->getSketchObject()->Geometry.getValues(); + const std::vector geomlist = sketchgui->getSketchObject()->getCompleteGeometry(); // Iterate through geometry int i = 0; @@ -254,6 +254,8 @@ int DrawSketchHandler::seekAutoConstraint(std::vector &suggested } if (tangId != Constraint::GeoUndef) { + if (tangId > getHighestCurveIndex()) // external Geometry + tangId = getHighestCurveIndex() - tangId; // Suggest vertical constraint AutoConstraint tangConstr; tangConstr.Index = tangId; diff --git a/src/Mod/Sketcher/Gui/ViewProviderSketch.cpp b/src/Mod/Sketcher/Gui/ViewProviderSketch.cpp index 0998d95e4..468a49a27 100644 --- a/src/Mod/Sketcher/Gui/ViewProviderSketch.cpp +++ b/src/Mod/Sketcher/Gui/ViewProviderSketch.cpp @@ -102,6 +102,7 @@ using namespace Sketcher; SbColor ViewProviderSketch::VertexColor (1.0f,0.149f,0.0f); // #FF2600 -> (255, 38, 0) SbColor ViewProviderSketch::CurveColor (1.0f,1.0f,1.0f); // #FFFFFF -> (255,255,255) SbColor ViewProviderSketch::CurveDraftColor (0.0f,0.0f,0.86f); // #0000DC -> ( 0, 0,220) +SbColor ViewProviderSketch::CurveExternalColor (0.8f,0.2f,0.6f); // #CC3399 -> (204, 51,153) SbColor ViewProviderSketch::CrossColorV (0.8f,0.4f,0.4f); // #CC6666 -> (204,102,102) SbColor ViewProviderSketch::CrossColorH (0.4f,0.8f,0.4f); // #66CC66 -> (102,204,102) SbColor ViewProviderSketch::FullyConstrainedColor (0.0f,1.0f,0.0f); // #00FF00 -> ( 0,255, 0) @@ -190,6 +191,15 @@ struct EditData { }; +// this function is used to simulate cyclic periodic negative geometry indices (for external geometry) +const Part::Geometry* GeoById(const std::vector GeoList, int Id) +{ + if (Id >= 0) + return GeoList[Id]; + else + return GeoList[GeoList.size()+Id]; +} + //************************************************************************** // Construction/Destruction @@ -425,8 +435,14 @@ bool ViewProviderSketch::mouseButtonPressed(int Button, bool pressed, const SbVe case STATUS_SELECT_Edge: if (pp) { //Base::Console().Log("Select Point:%d\n",this->DragPoint); + int maxGeoId = getSketchObject()->getHighestCurveIndex(); std::stringstream ss; - ss << "Edge" << edit->PreselectCurve; + if (edit->PreselectCurve <= maxGeoId) + ss << "Edge" << edit->PreselectCurve; + else { // external geometry + int extGeoCount = getSketchObject()->getExternalGeometryCount(); + ss << "ExternalEdge" << extGeoCount - 2 - (edit->PreselectCurve - maxGeoId); + } // If edge already selected move from selection if (Gui::Selection().isSelected(getSketchObject()->getDocument()->getName() @@ -849,8 +865,13 @@ void ViewProviderSketch::moveConstraint(int constNum, const Base::Vector2D &toPo if (Constr->Type == Distance || Constr->Type == DistanceX || Constr->Type == DistanceY || Constr->Type == Radius) { - const std::vector geomlist = edit->ActSketch.extractGeometry(); - assert(Constr->First < int(geomlist.size())); + int intGeoCount = getSketchObject()->getHighestCurveIndex() + 1; + int extGeoCount = getSketchObject()->getExternalGeometryCount(); + const std::vector geomlist = edit->ActSketch.extractGeometry(true, true); + + assert(int(geomlist.size()) == extGeoCount + intGeoCount); + assert((Constr->First >= -extGeoCount && Constr->First < intGeoCount) + || Constr->First != Constraint::GeoUndef); Base::Vector3d p1(0.,0.,0.), p2(0.,0.,0.); if (Constr->SecondPos != Sketcher::none) { // point to point distance @@ -858,7 +879,7 @@ void ViewProviderSketch::moveConstraint(int constNum, const Base::Vector2D &toPo p2 = edit->ActSketch.getPoint(Constr->Second, Constr->SecondPos); } else if (Constr->Second != Constraint::GeoUndef) { // point to line distance p1 = edit->ActSketch.getPoint(Constr->First, Constr->FirstPos); - const Part::Geometry *geo = geomlist[Constr->Second]; + const Part::Geometry *geo = GeoById(geomlist, Constr->Second); if (geo->getTypeId() == Part::GeomLineSegment::getClassTypeId()) { const Part::GeomLineSegment *lineSeg = dynamic_cast(geo); Base::Vector3d l2p1 = lineSeg->getStartPoint(); @@ -871,7 +892,7 @@ void ViewProviderSketch::moveConstraint(int constNum, const Base::Vector2D &toPo } else if (Constr->FirstPos != Sketcher::none) { p2 = edit->ActSketch.getPoint(Constr->First, Constr->FirstPos); } else if (Constr->First != Constraint::GeoUndef) { - const Part::Geometry *geo = geomlist[Constr->First]; + const Part::Geometry *geo = GeoById(geomlist, Constr->First); if (geo->getTypeId() == Part::GeomLineSegment::getClassTypeId()) { const Part::GeomLineSegment *lineSeg = dynamic_cast(geo); p1 = lineSeg->getStartPoint(); @@ -914,13 +935,18 @@ void ViewProviderSketch::moveConstraint(int constNum, const Base::Vector2D &toPo } } else if (Constr->Type == Angle) { - const std::vector geomlist = edit->ActSketch.extractGeometry(); - assert(Constr->First < int(geomlist.size())); + int intGeoCount = getSketchObject()->getHighestCurveIndex() + 1; + int extGeoCount = getSketchObject()->getExternalGeometryCount(); + const std::vector geomlist = edit->ActSketch.extractGeometry(true, true); + + assert(int(geomlist.size()) == extGeoCount + intGeoCount); + assert((Constr->First >= -extGeoCount && Constr->First < intGeoCount) + || Constr->First != Constraint::GeoUndef); Base::Vector3d p0(0.,0.,0.); if (Constr->Second != Constraint::GeoUndef) { // line to line angle - const Part::Geometry *geo1 = geomlist[Constr->First]; - const Part::Geometry *geo2 = geomlist[Constr->Second]; + const Part::Geometry *geo1 = GeoById(geomlist, Constr->First); + const Part::Geometry *geo2 = GeoById(geomlist, Constr->Second); if (geo1->getTypeId() != Part::GeomLineSegment::getClassTypeId() || geo2->getTypeId() != Part::GeomLineSegment::getClassTypeId()) return; @@ -946,7 +972,7 @@ void ViewProviderSketch::moveConstraint(int constNum, const Base::Vector2D &toPo p0 = Base::Vector3d(x,y,0); } } else if (Constr->First != Constraint::GeoUndef) { // line angle - const Part::Geometry *geo = geomlist[Constr->First]; + const Part::Geometry *geo = GeoById(geomlist, Constr->First); if (geo->getTypeId() != Part::GeomLineSegment::getClassTypeId()) return; const Part::GeomLineSegment *lineSeg = dynamic_cast(geo); @@ -1043,6 +1069,11 @@ void ViewProviderSketch::onSelectionChanged(const Gui::SelectionChanges& msg) edit->SelCurvSet.insert(index); this->updateColor(); } + else if (shapetype.size() > 12 && shapetype.substr(0,12) == "ExternalEdge") { + int index=std::atoi(&shapetype[12]); + edit->SelCurvSet.insert(-index-3); + this->updateColor(); + } else if (shapetype.size() > 6 && shapetype.substr(0,6) == "Vertex") { int index=std::atoi(&shapetype[6]); addSelectPoint(index); @@ -1082,6 +1113,11 @@ void ViewProviderSketch::onSelectionChanged(const Gui::SelectionChanges& msg) edit->SelCurvSet.erase(index); this->updateColor(); } + else if (shapetype.size() > 12 && shapetype.substr(0,12) == "ExternalEdge") { + int index=std::atoi(&shapetype[12]); + edit->SelCurvSet.erase(-index-3); + this->updateColor(); + } else if (shapetype.size() > 6 && shapetype.substr(0,6) == "Vertex") { int index=std::atoi(&shapetype[6]); removeSelectPoint(index); @@ -1200,8 +1236,14 @@ bool ViewProviderSketch::detectPreselection(const SoPickedPoint *Point, int &PtI return true; } } else if (CurvIndex >= 0 && CurvIndex != edit->PreselectCurve) { // if a new curve is hit + int maxGeoId = getSketchObject()->getHighestCurveIndex(); std::stringstream ss; - ss << "Edge" << CurvIndex; + if (CurvIndex <= maxGeoId) + ss << "Edge" << CurvIndex; + else { // external geometry + int extGeoCount = getSketchObject()->getExternalGeometryCount(); + ss << "ExternalEdge" << extGeoCount - 2 - (CurvIndex - maxGeoId); + } bool accepted = Gui::Selection().setPreselect(getSketchObject()->getDocument()->getName() ,getSketchObject()->getNameInDocument() @@ -1318,12 +1360,17 @@ void ViewProviderSketch::updateColor(void) } // colors of the curves + int intGeoCount = getSketchObject()->getHighestCurveIndex() + 1; + int extGeoCount = getSketchObject()->getExternalGeometryCount(); for (int i=0; i < CurvNum; i++) { - if (edit->SelCurvSet.find(i) != edit->SelCurvSet.end()) + int GeoId = (i < intGeoCount) ? i : -(extGeoCount - (i - intGeoCount)); + if (edit->SelCurvSet.find(GeoId) != edit->SelCurvSet.end()) color[i] = SelectColor; else if (edit->PreselectCurve == i) color[i] = PreselectColor; - else if (getSketchObject()->getGeometry(i)->Construction) + else if (GeoId < -2) // external Geometry + color[i] = CurveExternalColor; + else if (getSketchObject()->getGeometry(GeoId)->Construction) color[i] = CurveDraftColor; else if (edit->FullyConstrained) color[i] = FullyConstrainedColor; @@ -1544,15 +1591,22 @@ void ViewProviderSketch::draw(bool temp) std::vector Points; std::vector Index; + int intGeoCount = getSketchObject()->getHighestCurveIndex() + 1; + int extGeoCount = getSketchObject()->getExternalGeometryCount(); + const std::vector *geomlist; std::vector tempGeo; - if (temp) { - tempGeo = edit->ActSketch.extractGeometry(); - geomlist = &tempGeo; - } else - geomlist = &getSketchObject()->Geometry.getValues(); + if (temp) + tempGeo = edit->ActSketch.extractGeometry(true, true); // with memory allocation + else + tempGeo = getSketchObject()->getCompleteGeometry(); // without memory allocation + geomlist = &tempGeo; - for (std::vector::const_iterator it = geomlist->begin(); it != geomlist->end(); ++it) { + + assert(int(geomlist->size()) == extGeoCount + intGeoCount); + assert(int(geomlist->size()) >= 2); + + for (std::vector::const_iterator it = geomlist->begin(); it != geomlist->end()-2; ++it) { if ((*it)->getTypeId() == Part::GeomLineSegment::getClassTypeId()) { // add a line const Part::GeomLineSegment *lineSeg = dynamic_cast(*it); // create the definition struct for that geom @@ -1695,7 +1749,7 @@ void ViewProviderSketch::draw(bool temp) const std::vector &constrlist = getSketchObject()->Constraints.getValues(); // After an undo/redo it can happen that we have an empty geometry list but a non-empty constraint list // In this case just ignore the constraints. (See bug #0000421) - if (geomlist->empty() && !constrlist.empty()) { + if (geomlist->size() <= 2 && !constrlist.empty()) { rebuildConstraintsVisual(); return; } @@ -1724,9 +1778,9 @@ Restart: case Horizontal: // write the new position of the Horizontal constraint Same as vertical position. case Vertical: // write the new position of the Vertical constraint { - assert(Constr->First < int(geomlist->size())); + assert(Constr->First >= -extGeoCount && Constr->First < intGeoCount); // get the geometry - const Part::Geometry *geo = (*geomlist)[Constr->First]; + const Part::Geometry *geo = GeoById(*geomlist, Constr->First); // Vertical can only be a GeomLineSegment assert(geo->getTypeId() == Part::GeomLineSegment::getClassTypeId()); const Part::GeomLineSegment *lineSeg = dynamic_cast(geo); @@ -1758,11 +1812,11 @@ Restart: case Perpendicular: case Equal: { - assert(Constr->First < int(geomlist->size())); - assert(Constr->Second < int(geomlist->size())); + assert(Constr->First >= -extGeoCount && Constr->First < intGeoCount); + assert(Constr->Second >= -extGeoCount && Constr->Second < intGeoCount); // get the geometry - const Part::Geometry *geo1 = (*geomlist)[Constr->First]; - const Part::Geometry *geo2 = (*geomlist)[Constr->Second]; + const Part::Geometry *geo1 = GeoById(*geomlist, Constr->First); + const Part::Geometry *geo2 = GeoById(*geomlist, Constr->Second); Base::Vector3d midpos1, dir1, norm1; Base::Vector3d midpos2, dir2, norm2; @@ -1856,7 +1910,7 @@ Restart: case DistanceX: case DistanceY: { - assert(Constr->First < int(geomlist->size())); + assert(Constr->First >= -extGeoCount && Constr->First < intGeoCount); Base::Vector3d pnt1(0.,0.,0.), pnt2(0.,0.,0.); if (Constr->SecondPos != Sketcher::none) { // point to point distance @@ -1873,7 +1927,7 @@ Restart: } else { pnt1 = getSketchObject()->getPoint(Constr->First, Constr->FirstPos); } - const Part::Geometry *geo = (*geomlist)[Constr->Second]; + const Part::Geometry *geo = GeoById(*geomlist, Constr->Second); if (geo->getTypeId() == Part::GeomLineSegment::getClassTypeId()) { const Part::GeomLineSegment *lineSeg = dynamic_cast(geo); Base::Vector3d l2p1 = lineSeg->getStartPoint(); @@ -1890,7 +1944,7 @@ Restart: pnt2 = getSketchObject()->getPoint(Constr->First, Constr->FirstPos); } } else if (Constr->First != Constraint::GeoUndef) { - const Part::Geometry *geo = (*geomlist)[Constr->First]; + const Part::Geometry *geo = GeoById(*geomlist, Constr->First); if (geo->getTypeId() == Part::GeomLineSegment::getClassTypeId()) { const Part::GeomLineSegment *lineSeg = dynamic_cast(geo); pnt1 = lineSeg->getStartPoint(); @@ -1996,8 +2050,8 @@ Restart: case PointOnObject: case Tangent: { - assert(Constr->First < int(geomlist->size())); - assert(Constr->Second < int(geomlist->size())); + assert(Constr->First >= -extGeoCount && Constr->First < intGeoCount); + assert(Constr->Second >= -extGeoCount && Constr->Second < intGeoCount); Base::Vector3d pos, relPos; if (Constr->Type == PointOnObject) { @@ -2008,8 +2062,8 @@ Restart: } else if (Constr->Type == Tangent) { // get the geometry - const Part::Geometry *geo1 = (*geomlist)[Constr->First]; - const Part::Geometry *geo2 = (*geomlist)[Constr->Second]; + const Part::Geometry *geo1 = GeoById(*geomlist, Constr->First); + const Part::Geometry *geo2 = GeoById(*geomlist, Constr->Second); if (geo1->getTypeId() == Part::GeomLineSegment::getClassTypeId() && geo2->getTypeId() == Part::GeomLineSegment::getClassTypeId()) { @@ -2109,8 +2163,8 @@ Restart: break; case Symmetric: { - assert(Constr->First < int(geomlist->size())); - assert(Constr->Second < int(geomlist->size())); + assert(Constr->First >= -extGeoCount && Constr->First < intGeoCount); + assert(Constr->Second >= -extGeoCount && Constr->Second < intGeoCount); Base::Vector3d pnt1 = edit->ActSketch.getPoint(Constr->First, Constr->FirstPos); Base::Vector3d pnt2 = edit->ActSketch.getPoint(Constr->Second, Constr->SecondPos); @@ -2153,14 +2207,14 @@ Restart: break; case Angle: { - assert(Constr->First < int(geomlist->size())); - assert(Constr->Second < int(geomlist->size())); + assert(Constr->First >= -extGeoCount && Constr->First < intGeoCount); + assert(Constr->Second >= -extGeoCount && Constr->Second < intGeoCount); SbVec3f p0; double startangle,range,endangle; if (Constr->Second != Constraint::GeoUndef) { - const Part::Geometry *geo1 = (*geomlist)[Constr->First]; - const Part::Geometry *geo2 = (*geomlist)[Constr->Second]; + const Part::Geometry *geo1 = GeoById(*geomlist, Constr->First); + const Part::Geometry *geo2 = GeoById(*geomlist, Constr->Second); if (geo1->getTypeId() != Part::GeomLineSegment::getClassTypeId() || geo2->getTypeId() != Part::GeomLineSegment::getClassTypeId()) break; @@ -2192,7 +2246,7 @@ Restart: endangle = startangle + range; } else if (Constr->First != Constraint::GeoUndef) { - const Part::Geometry *geo = (*geomlist)[Constr->First]; + const Part::Geometry *geo = GeoById(*geomlist, Constr->First); if (geo->getTypeId() != Part::GeomLineSegment::getClassTypeId()) break; const Part::GeomLineSegment *lineSeg = dynamic_cast(geo); @@ -2272,11 +2326,11 @@ Restart: break; case Radius: { - assert(Constr->First < int(geomlist->size())); + assert(Constr->First >= -extGeoCount && Constr->First < intGeoCount); Base::Vector3d pnt1(0.,0.,0.), pnt2(0.,0.,0.); if (Constr->First != Constraint::GeoUndef) { - const Part::Geometry *geo = (*geomlist)[Constr->First]; + const Part::Geometry *geo = GeoById(*geomlist, Constr->First); if (geo->getTypeId() == Part::GeomArcOfCircle::getClassTypeId()) { const Part::GeomArcOfCircle *arc = dynamic_cast(geo); @@ -2375,8 +2429,9 @@ Restart: this->updateColor(); // delete the cloned objects - for (std::vector::iterator it=tempGeo.begin(); it != tempGeo.end(); ++it) - if (*it) delete *it; + if (temp) + for (std::vector::iterator it=tempGeo.begin(); it != tempGeo.end(); ++it) + if (*it) delete *it; if (mdi && mdi->isDerivedFrom(Gui::View3DInventor::getClassTypeId())) { static_cast(mdi)->getViewer()->render(); @@ -2528,8 +2583,9 @@ void ViewProviderSketch::updateData(const App::Property *prop) if (edit && (prop == &(getSketchObject()->Geometry) || &(getSketchObject()->Constraints))) { edit->FullyConstrained = false; - int dofs = edit->ActSketch.setUpSketch(getSketchObject()->Geometry.getValues(), - getSketchObject()->Constraints.getValues()); + int dofs = edit->ActSketch.setUpSketch(getSketchObject()->getCompleteGeometry(), + getSketchObject()->Constraints.getValues(), + true, getSketchObject()->getExternalGeometryCount()); std::string msg; if (getSketchObject()->Geometry.getSize() == 0) { signalSetUp(-1, 0, msg); @@ -2644,9 +2700,10 @@ bool ViewProviderSketch::setEdit(int ModNum) color = (unsigned long)(FullyConstrainedColor.getPackedValue()); color = hGrp->GetUnsigned("FullyConstrainedColor", color); FullyConstrainedColor.setPackedValue((uint32_t)color, transparency); - // constraints dimensions and icons colors are hard coded + // constraints dimensions, icons and external geometry colors are hard coded // ConstrDimColor; // ConstrIcoColor; + // CurveExternalColor; // set the highlight color unsigned long highlight = (unsigned long)(PreselectColor.getPackedValue()); @@ -2664,8 +2721,9 @@ bool ViewProviderSketch::setEdit(int ModNum) Gui::Control().showDialog(new TaskDlgEditSketch(this)); // set up the sketch and diagnose possible conflicts - int dofs = edit->ActSketch.setUpSketch(getSketchObject()->Geometry.getValues(), - getSketchObject()->Constraints.getValues()); + int dofs = edit->ActSketch.setUpSketch(getSketchObject()->getCompleteGeometry(), + getSketchObject()->Constraints.getValues(), + true, getSketchObject()->getExternalGeometryCount()); std::string msg; if (getSketchObject()->Geometry.getSize() == 0) { signalSetUp(-1, 0, msg); @@ -3011,10 +3069,15 @@ bool ViewProviderSketch::onDelete(const std::vector &subList) Base::Console().Error("%s\n", e.what()); } } + for (rit = edit->SelCurvSet.rbegin(); rit != edit->SelCurvSet.rend(); rit++) { try { - Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.%s.delGeometry(%i)" - ,getObject()->getNameInDocument(), *rit); + if (*rit >= 0) + Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.%s.delGeometry(%i)" + ,getObject()->getNameInDocument(), *rit); + else if (*rit < -2) // external geometry + Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.%s.delExternal(%i)" + ,getObject()->getNameInDocument(), -3-*rit); } catch (const Base::Exception& e) { Base::Console().Error("%s\n", e.what()); diff --git a/src/Mod/Sketcher/Gui/ViewProviderSketch.h b/src/Mod/Sketcher/Gui/ViewProviderSketch.h index b97ea8493..572547186 100644 --- a/src/Mod/Sketcher/Gui/ViewProviderSketch.h +++ b/src/Mod/Sketcher/Gui/ViewProviderSketch.h @@ -215,6 +215,7 @@ protected: static SbColor VertexColor; static SbColor CurveColor; static SbColor CurveDraftColor; + static SbColor CurveExternalColor; static SbColor CrossColorV; static SbColor CrossColorH; static SbColor FullyConstrainedColor;