Mercurial > hg > svgui
comparison layer/RegionLayer.cpp @ 846:f84f1828420b
Clarify some sneaky logic
author | Chris Cannam |
---|---|
date | Wed, 03 Sep 2014 11:41:58 +0100 |
parents | 1d526ba11a24 |
children | b66fb15de477 |
comparison
equal
deleted
inserted
replaced
845:0f5961c1bb6c | 846:f84f1828420b |
---|---|
45 | 45 |
46 RegionLayer::RegionLayer() : | 46 RegionLayer::RegionLayer() : |
47 SingleColourLayer(), | 47 SingleColourLayer(), |
48 m_model(0), | 48 m_model(0), |
49 m_editing(false), | 49 m_editing(false), |
50 m_dragPointX(0), | |
51 m_dragPointY(0), | |
52 m_dragStartX(0), | |
53 m_dragStartY(0), | |
50 m_originalPoint(0, 0.0, 0, tr("New Region")), | 54 m_originalPoint(0, 0.0, 0, tr("New Region")), |
51 m_editingPoint(0, 0.0, 0, tr("New Region")), | 55 m_editingPoint(0, 0.0, 0, tr("New Region")), |
52 m_editingCommand(0), | 56 m_editingCommand(0), |
53 m_verticalScale(EqualSpaced), | 57 m_verticalScale(EqualSpaced), |
54 m_colourMap(0), | 58 m_colourMap(0), |
562 float epsilon = 0.0001; | 566 float epsilon = 0.0001; |
563 | 567 |
564 i = close.begin(); | 568 i = close.begin(); |
565 | 569 |
566 // Scan through the close points first, then the more distant ones | 570 // Scan through the close points first, then the more distant ones |
567 // if no suitable close one is found | 571 // if no suitable close one is found. So the while-termination |
572 // condition here can only happen once i has passed through the | |
573 // whole of the close container and then the whole of the separate | |
574 // points container. The two iterators are totally distinct, but | |
575 // have the same type so we cheekily use the same variable and a | |
576 // single loop for both. | |
568 | 577 |
569 while (i != points.end()) { | 578 while (i != points.end()) { |
570 | 579 |
571 if (i == close.end()) { | 580 if (!distant) { |
572 i = points.begin(); | 581 if (i == close.end()) { |
573 distant = true; | 582 // switch from the close container to the points container |
583 i = points.begin(); | |
584 distant = true; | |
585 } | |
574 } | 586 } |
575 | 587 |
576 if (snap == SnapRight) { | 588 if (snap == SnapRight) { |
577 | 589 |
578 if (i->frame > matchframe && | 590 if (i->frame > matchframe && |