MCPcopy Create free account
hub / github.com/Gecode/gecode / zoomToFit

Method zoomToFit

gecode/gist/treecanvas.cpp:537–571  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

535 }
536
537 void
538 TreeCanvas::zoomToFit(void) {
539 QMutexLocker locker(&layoutMutex);
540 if (root != nullptr) {
541 BoundingBox bb;
542 bb = root->getBoundingBox();
543 QWidget* p = parentWidget();
544 if (p) {
545 double newXScale =
546 static_cast<double>(p->width()) / (bb.right - bb.left +
547 Layout::extent);
548 double newYScale =
549 static_cast<double>(p->height()) / (root->getShape()->depth() *
550 Layout::dist_y +
551 2*Layout::extent);
552 int scale0 = static_cast<int>(std::min(newXScale, newYScale)*100);
553 if (scale0<LayoutConfig::minScale)
554 scale0 = LayoutConfig::minScale;
555 if (scale0>LayoutConfig::maxAutoZoomScale)
556 scale0 = LayoutConfig::maxAutoZoomScale;
557
558 if (!smoothScrollAndZoom) {
559 scaleTree(scale0);
560 } else {
561 zoomTimeLine.stop();
562 int zoomCurrent = static_cast<int>(scale*100);
563 int targetZoom = scale0;
564 targetZoom = std::min(std::max(targetZoom, LayoutConfig::minScale),
565 LayoutConfig::maxAutoZoomScale);
566 zoomTimeLine.setFrameRange(zoomCurrent,targetZoom);
567 zoomTimeLine.start();
568 }
569 }
570 }
571 }
572
573 void
574 TreeCanvas::centerCurrentNode(void) {

Callers

nothing calls this directly

Calls 9

getBoundingBoxMethod · 0.80
getShapeMethod · 0.80
minFunction · 0.50
maxFunction · 0.50
widthMethod · 0.45
heightMethod · 0.45
depthMethod · 0.45
stopMethod · 0.45
startMethod · 0.45

Tested by

no test coverage detected