Changeset - 0d495816e66c
[Not reviewed]
default
0 1 0
Hasan Yavuz Ă–ZDERYA - 8 years ago 2017-08-16 09:19:51
hy@ozderya.net
fix samples that are at the edges not shown or in very high zoom nothing is shown
1 file changed with 5 insertions and 4 deletions:
0 comments (0 inline, 0 general)
src/framebufferseries.cpp
Show inline comments
 
@@ -14,12 +14,13 @@
 
  GNU General Public License for more details.
 

	
 
  You should have received a copy of the GNU General Public License
 
  along with serialplot.  If not, see <http://www.gnu.org/licenses/>.
 
*/
 

	
 
#include <math.h>
 
#include "framebufferseries.h"
 

	
 
FrameBufferSeries::FrameBufferSeries(FrameBuffer* buffer)
 
{
 
    xAsIndex = true;
 
    _xmin = 0;
 
@@ -70,20 +71,20 @@ QRectF FrameBufferSeries::boundingRect()
 
}
 

	
 
void FrameBufferSeries::setRectOfInterest(const QRectF& rect)
 
{
 
    if (xAsIndex)
 
    {
 
        int_index_start = rect.left();
 
        int_index_end = rect.right();
 
        int_index_start = floor(rect.left())-1;
 
        int_index_end = ceil(rect.right())+1;
 
    }
 
    else
 
    {
 
        double xsize = _xmax - _xmin;
 
        size_t bsize = _buffer->size();
 
        int_index_start =  bsize * (rect.left()-_xmin) / xsize;
 
        int_index_end = bsize * (rect.right()-_xmin) / xsize;
 
        int_index_start =  floor(bsize * (rect.left()-_xmin) / xsize)-1;
 
        int_index_end = ceil(bsize * (rect.right()-_xmin) / xsize)+1;
 
    }
 

	
 
    int_index_start = std::max(int_index_start, (size_t) 0);
 
    int_index_end = std::min(_buffer->size(), int_index_end);
 
}
0 comments (0 inline, 0 general)