pixel position of a point
- From: ferri_marllo gva es
- To: gtk-app-devel-list gnome org
- Subject: pixel position of a point
- Date: Wed, 7 Feb 2007 12:20:46 +0100
Hello!!
I have plot points in an X-Y plot using this code:
void grafica(GtkWidget *plot)
{
GdkColor color;
GtkPlotAxis *axis;
int i,j,k,l;
int np_x,np_y;
np_x=0;
np_y=0;
t1a=g_array_new(FALSE,FALSE,sizeof(gdouble));
t2a=g_array_new(FALSE,FALSE,sizeof(gdouble));
v1a=g_array_new(FALSE,FALSE,sizeof(gdouble));
v2a=g_array_new(FALSE,FALSE,sizeof(gdouble));
matriz = &mat[0][0];
tiempo[FILAS] = mat[FILAS][0];
var1[FILAS] = mat[FILAS][1];
var2[FILAS] = mat[FILAS][2];
fp=fopen(fichero_partida,"r");
fp_sal=fopen("c:\\dev-cpp\\datos\\greca_matriz.txt","w");
matriz=(double*)malloc(FILAS*COL*sizeof(double*));
if(matriz==NULL)
{
g_print("No hay memoria");
}
for(i=0;i<FILAS;i++)
{
for(j=0;j<COL;j++)
{
fscanf(fp,"%d",&mat[i][j]);
}
}
for(l=0;l<FILAS;l++)
{
tiempo[l]=mat[l][0];
var1[l]=mat[l][1];
var2[l]=mat[l][2];
}
fprintf(fp_sal,"tiempo_1 %lf vari_2 %lf\n",tiempo[0],var1[1]);
for(k=0;k<FILAS;k++)
{
if(tiempo[k]>=0.0 && var2[k]>=-50.0)
{g_array_append_val(t2a,tiempo[k]);
np_y=np_y+1;}
if(var2[k]>=-50.0)
{g_array_append_val(v2a,var2[k]);}
if(tiempo[k]>=0.0 && var1[k]>=-50.0)
{
np_x=np_x+1;
g_array_append_val(t1a,tiempo[k]);}
if(var1[k]>=-50.0)
{g_array_append_val(v1a,var1[k]);}
}
fprintf(fp_sal,"%d %d\n",np_x,np_y);
t1=(gdouble*)t1a->data;
t2=(gdouble*)t2a->data;
v1=(gdouble*)v1a->data;
v2=(gdouble*)v2a->data;
g_array_free(t1a,FALSE);
g_array_free(t2a,FALSE);
g_array_free(v1a,FALSE);
g_array_free(v2a,FALSE);
dataset[0] = GTK_PLOT_DATA(gtk_plot_data_new());
gtk_plot_add_data(GTK_PLOT(plot), dataset[0]);
gtk_widget_show(GTK_WIDGET(dataset[0]));
gtk_plot_data_set_points(dataset[0], t1, v1,NULL,NULL,np_x);
gdk_color_parse("red", &color);
gdk_color_alloc(gdk_colormap_get_system(), &color);
gtk_plot_data_set_symbol(dataset[0],GTK_PLOT_SYMBOL_DIAMOND,
GTK_PLOT_SYMBOL_EMPTY,10, 2, &color, &color);
gtk_plot_data_set_line_attributes(dataset[0],GTK_PLOT_LINE_SOLID,0, 0, 1,
&color);
fclose(fp);
fclose(fp_sal);
}
but i'd like to know the pixel position of each plotted point in reference to
all the screen.
How can i Do it??
thanks a lot!
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]