Commit 84066f3b authored by Claes Sjofors's avatar Claes Sjofors

Xtt curve bugfix for large zooming

parent b6babc16
......@@ -1574,15 +1574,16 @@ int GlowDrawGtk::polyline( GlowWind *wind, glow_sPointX *points, int point_cnt,
if ( w->clip_on)
set_clip( w, get_gc( this, gc_type+highlight, idx));
GdkPoint* gpoints = points_to_gdk_points( points, point_cnt);
int cnt;
GdkPoint* gpoints = points_to_gdk_points_curve( wind, points, point_cnt, &cnt);
if ( !w->draw_buffer_only)
gdk_draw_lines( w->window,
get_gc( this, gc_type+highlight, idx),
gpoints, point_cnt);
gpoints, cnt);
if ( w->double_buffer_on)
gdk_draw_lines( w->buffer,
get_gc( this, gc_type+highlight, idx),
gpoints, point_cnt);
gpoints, cnt);
free( gpoints);
if ( w->clip_on)
......@@ -1626,15 +1627,16 @@ int GlowDrawGtk::polyline_erase( GlowWind *wind, glow_sPointX *points, int point
if ( w->clip_on)
set_clip( w, get_gc( this, glow_eDrawType_LineErase, idx));
GdkPoint* gpoints = points_to_gdk_points( points, point_cnt);
int cnt;
GdkPoint* gpoints = points_to_gdk_points_curve( wind, points, point_cnt, &cnt);
if ( !w->draw_buffer_only)
gdk_draw_lines( w->window,
get_gc( this, glow_eDrawType_LineErase, idx),
gpoints, point_cnt);
gpoints, cnt);
if ( w->double_buffer_on)
gdk_draw_lines( w->buffer,
get_gc( this, glow_eDrawType_LineErase, idx),
gpoints, point_cnt);
gpoints, cnt);
free( gpoints);
if ( w->clip_on)
......@@ -2767,6 +2769,34 @@ GdkPoint *GlowDrawGtk::points_to_gdk_points( glow_sPointX *points, int point_cnt
return gpoints;
}
//
// Points outside window in x direction excluded
//
GdkPoint *GlowDrawGtk::points_to_gdk_points_curve( GlowWind *w, glow_sPointX *points, int point_cnt, int *cnt)
{
GdkPoint *gpoints = (GdkPoint *)malloc( point_cnt * sizeof(GdkPoint));
int idx = 0;
int last_idx = 0;
for ( int i = 0; i < point_cnt; i++) {
if ( idx == 0 && i != point_cnt - 1 &&
((points[i].x < 0 && points[i+1].x < 0) ||
(points[i].x > w->window_width && points[i+1].x > w->window_width)))
continue;
if ( idx != 0 &&
!((points[i].x < 0 && points[i-1].x < 0) ||
(points[i].x > w->window_width && points[i-1].x > w->window_width)))
last_idx = idx;
gpoints[idx].x = points[i].x;
gpoints[idx].y = points[i].y;
idx++;
}
*cnt = idx;
if ( last_idx != 0)
*cnt = last_idx + 1;
return gpoints;
}
void GlowDrawGtk::load_font( glow_eFont font_idx, int font_type, int idx)
{
if ( !font[font_idx][font_type][idx])
......
......@@ -194,6 +194,7 @@ class GlowDrawGtk : public GlowDraw {
virtual void remove_timer( void *id);
int init_nav( GtkWidget *nav_widget);
GdkPoint *points_to_gdk_points( glow_sPointX *points, int point_cnt);
GdkPoint *points_to_gdk_points_curve( GlowWind *w, glow_sPointX *points, int point_cnt, int *cnt);
int get_font_type( int gc_type);
void load_font( glow_eFont font_idx, int font_type, int idx);
......
......@@ -40,6 +40,7 @@
#include <iostream>
#include <float.h>
#include <math.h>
#include <limits.h>
#include <stdlib.h>
#include "glow_growpolyline.h"
#include "glow_draw.h"
......@@ -389,6 +390,11 @@ void GrowPolyLine::draw( GlowWind *w, GlowTransform *t, int highlight, int hot,
y1 = trf.y( t, ((GlowPoint *)a_points[i])->x, ((GlowPoint *)a_points[i])->y);
}
if ( x1 * w->zoom_factor_x - w->offset_x > SHRT_MAX)
point_p->x = SHRT_MAX;
else if (x1 * w->zoom_factor_x - w->offset_x < SHRT_MIN)
point_p->x = SHRT_MIN;
else
point_p->x = int( x1 * w->zoom_factor_x + 0.5) - w->offset_x;
point_p->y = int( y1 * w->zoom_factor_y + 0.5) - w->offset_y;
point_p++;
......
......@@ -499,8 +499,17 @@ void GrowTrend::draw( GlowWind *w, GlowTransform *t, int highlight, int hot, voi
drawtype = ctx->get_drawtype( fill_drawtype, glow_eDrawType_FillHighlight,
highlight, (GrowNode *)colornode, 1);
if ( grad == glow_eGradient_No)
ctx->gdraw->fill_rect( w, ll_x, ll_y, ur_x - ll_x, ur_y - ll_y, drawtype);
if ( grad == glow_eGradient_No) {
int width = ur_x - ll_x;
int x = ll_x;
if ( x < 0) {
x = 0;
width += ll_x;
}
if ( ur_x > w->window_width)
width -= ur_x - w->window_width;
ctx->gdraw->fill_rect( w, x, ll_y, width, ur_y - ll_y, drawtype);
}
else {
glow_eDrawType f1, f2;
double rotation;
......@@ -557,7 +566,15 @@ void GrowTrend::draw( GlowWind *w, GlowTransform *t, int highlight, int hot, voi
for ( i = 0; i < horizontal_lines; i++) {
int y = int( ll_y + double(ur_y - ll_y) / (horizontal_lines + 1) * (i + 1));
ctx->gdraw->line( w, ll_x, y, ur_x, y, drawtype, 0, 0);
int width = ur_x - ll_x;
int x = ll_x;
if ( x < 0) {
x = 0;
width += ll_x;
}
if ( ur_x > w->window_width)
width -= ur_x - w->window_width;
ctx->gdraw->line( w, x, y, x + width, y, drawtype, 0, 0);
}
if ( fill_curve)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment