diff --git a/src/graphicswin.cpp b/src/graphicswin.cpp index f57448da..894c48f4 100644 --- a/src/graphicswin.cpp +++ b/src/graphicswin.cpp @@ -318,6 +318,7 @@ void GraphicsWindow::HandlePointForZoomToFit(Vector p, Point2d *pmax, Point2d *p *wmin = min(*wmin, w); } void GraphicsWindow::LoopOverPoints(const std::vector &entities, + const std::vector &faces, Point2d *pmax, Point2d *pmin, double *wmin, bool usePerspective, bool includeMesh) { @@ -350,16 +351,26 @@ void GraphicsWindow::LoopOverPoints(const std::vector &entities, } } - if(!includeMesh) return; + if(!includeMesh && faces.empty()) return; Group *g = SK.GetGroup(activeGroup); g->GenerateDisplayItems(); for(i = 0; i < g->displayMesh.l.n; i++) { STriangle *tr = &(g->displayMesh.l.elem[i]); + if(!includeMesh) { + bool found = false; + for(const hEntity &face : faces) { + if(face.v != tr->meta.face) continue; + found = true; + break; + } + if(!found) continue; + } HandlePointForZoomToFit(tr->a, pmax, pmin, wmin, usePerspective); HandlePointForZoomToFit(tr->b, pmax, pmin, wmin, usePerspective); HandlePointForZoomToFit(tr->c, pmax, pmin, wmin, usePerspective); } + if(!includeMesh) return; for(i = 0; i < g->polyLoops.l.n; i++) { SContour *sc = &(g->polyLoops.l.elem[i]); for(j = 0; j < sc->l.n; j++) { @@ -369,15 +380,24 @@ void GraphicsWindow::LoopOverPoints(const std::vector &entities, } void GraphicsWindow::ZoomToFit(bool includingInvisibles, bool useSelection) { std::vector entities; - bool selectionUsed = useSelection && selection.n > 0; - if(selectionUsed) { + std::vector faces; + + if(useSelection) { for(int i = 0; i < selection.n; i++) { Selection *s = &selection.elem[i]; if(s->entity.v == 0) continue; Entity *e = SK.entity.FindById(s->entity); + if(e->IsFace()) { + faces.push_back(e->h); + continue; + } entities.push_back(e); } - } else { + } + + bool selectionUsed = !entities.empty() || !faces.empty(); + + if(!selectionUsed) { for(int i = 0; i &entity, Point2d *pmax, Point2d *pmin, + void LoopOverPoints(const std::vector &entity, const std::vector &faces, Point2d *pmax, Point2d *pmin, double *wmin, bool usePerspective, bool includeMesh); void ZoomToFit(bool includingInvisibles, bool useSelection = false);