Subversion Repositories wimsdev

Rev

Rev 16847 | Rev 16882 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 16847 Rev 16872
Line 2510... Line 2510...
2510
            if(strstr(temp,"affine") != 0 ){use_affine = FALSE;affine_matrix[0] = 1.0;affine_matrix[1] = 0.0;affine_matrix[2] = 0.0;affine_matrix[3] = 1.0;affine_matrix[4] = 0.0;affine_matrix[5] = 0.0;}
2510
            if(strstr(temp,"affine") != 0 ){use_affine = FALSE;affine_matrix[0] = 1.0;affine_matrix[1] = 0.0;affine_matrix[2] = 0.0;affine_matrix[3] = 1.0;affine_matrix[4] = 0.0;affine_matrix[5] = 0.0;}
2511
            if(strstr(temp,"linear") != 0 ){affine_matrix[0] = 1.0;affine_matrix[1] = 0.0;affine_matrix[2] = 0.0;affine_matrix[3] = 1.0;}
2511
            if(strstr(temp,"linear") != 0 ){affine_matrix[0] = 1.0;affine_matrix[1] = 0.0;affine_matrix[2] = 0.0;affine_matrix[3] = 1.0;}
2512
            if(strstr(temp,"translation") != 0 || strstr(temp,"translate") != 0 ){affine_matrix[4] = 0.0;affine_matrix[5] = 0.0;}
2512
            if(strstr(temp,"translation") != 0 || strstr(temp,"translate") != 0 ){affine_matrix[4] = 0.0;affine_matrix[5] = 0.0;}
2513
            if(strstr(temp,"rotation") != 0 || strstr(temp,"rotate") != 0 ){use_rotate = FALSE;angle = 0.0;rotation_center="null";}
2513
            if(strstr(temp,"rotation") != 0 || strstr(temp,"rotate") != 0 ){use_rotate = FALSE;angle = 0.0;rotation_center="null";}
2514
            if(strstr(temp,"slider") != 0 ){slider_type = "0";my_sliders = "[-1]";last_slider = use_slider+1;}
2514
            if(strstr(temp,"slider") != 0 ){slider_type = "0";my_sliders = "[-1]";last_slider = use_slider+1;}
-
 
2515
            if(strstr(temp,"group") != 0 ){onclick = 0;drag_type = -1;slider_type = "0";my_sliders = "[-1]";last_slider = use_slider+1;use_slider = -1;reset();}
2515
            if(strstr(temp,"reset") != 0 ){if(no_reset == FALSE){no_reset = TRUE;}else{no_reset = FALSE;reset();}}
2516
            if(strstr(temp,"reset") != 0 ){if(no_reset == FALSE){no_reset = TRUE;}else{no_reset = FALSE;reset();}}
2516
            if(strstr(temp,"offset") != 0 ){use_offset = 0;}
2517
            if(strstr(temp,"offset") != 0 ){use_offset = 0;}
2517
            break;
2518
            break;
2518
        case KILLAFFINE:
2519
        case KILLAFFINE:
2519
        /*
2520
        /*
Line 4568... Line 4569...
4568
             int_data[c] = i; c++;
4569
             int_data[c] = i; c++;
4569
            }
4570
            }
4570
            my_sliders = data2js_array(int_data,use_slider - last_slider+1);
4571
            my_sliders = data2js_array(int_data,use_slider - last_slider+1);
4571
        break;
4572
        break;
4572
 
4573
 
4573
        case SLIDER_X:
4574
        case GROUP:
-
 
4575
            use_slider++;
4574
        /* TEMPORARILY REMOVED
4576
            add_slider(2);
-
 
4577
            int c = 0;
-
 
4578
            for(i=last_slider;i<=use_slider;i++){ int_data[c] = i; c++; }
-
 
4579
            my_sliders = data2js_array(int_data,use_slider - last_slider+1);
4575
         # sliderfunction_x some_function_in_x
4580
            if( precision == 0 ){precision = 100;}
-
 
4581
            onclick = 2;
4576
         # default value "x"
4582
            use_dragstuff = 2;
-
 
4583
            js_function[INTERACTIVE] = 1;
4577
         # the x-value of the slider object will be calculated with this function.
4584
            fprintf(js_include_file,"move_group(%d);dragdrop_precision = %d;use_dragdrop_reply = true;",use_slider,precision);
4578
         # default is the x-slider value itself
4585
            fprintf(js_include_file,"var slider%d;",use_slider);
-
 
4586
        /*
-
 
4587
         @ group
-
 
4588
         @ keyword
-
 
4589
         @ all objects after the command and until <a href="#kill">kill group</a> or <a href="#killslider">killslider</a> may be moved together with mouse moverments
4579
         # only used by command ''slider``
4590
         @ may be combined with slider driven movements or drag & drop
4580
         # define before a slider command !
4591
         @%group%%size 400,400%xrange -10,10%yrange -10,10%axis%axisnumbering%precision 1%grid 2,2,grey,2,2,5,grey%precision 100%linewidth 4%rotationcenter 0,0%slider -2*pi,2*pi,300,40,angle active,rotate%snaptogrid%ftriangle 0,-4,-2,-2,4,--5,blue%fillcolor red%fcircle -4.4,4.4,40,blue%kill slider%slider -20,20,300,40,x active,x-slide%ftriangle -2,0,0,4,2,0,green%fcircle 4.4,4.5,40,red%kill slider%slider -20,20,300,40,y active,y-slide%fcircle 4,-4,40,green%linewidth 4%fcircle -4,-4,40,orange%kill slider%group%fcircle -4.4,4.5,10,blue%fcircle -5.4,4.5,10,blue%fcircle -6.4,4.5,10,blue%fcircle -4.4,8,16,green%fcircle -5.4,8,16,green%fcircle -6.4,8,16,green%mouse red,22%zoom red
4581
        */
4592
        */
4582
         /* slider_function_x = get_string(infile,1);*/
-
 
4583
        break;
-
 
4584
        case SLIDER_Y:
-
 
4585
         /*slider_function_y = get_string(infile,1);*/
-
 
4586
         /* TEMPORARILY REMOVED
-
 
4587
         # sliderfunction_y some_function_in_y
-
 
4588
         # default value "y"
-
 
4589
         # the y-value of the slider object(s) will be calculated with this function.
-
 
4590
         # only used by command ''slider``
-
 
4591
         # define before a slider command !
-
 
4592
         */
-
 
4593
        break;
4593
        break;
4594
        case SGRAPH:
4594
        case SGRAPH:
4595
        /*
4595
        /*
4596
         @ sgraph xstart,ystart,xmajor,ymajor,xminor,yminor,majorgrid_color,minorgrid_color
4596
         @ sgraph xstart,ystart,xmajor,ymajor,xminor,yminor,majorgrid_color,minorgrid_color
4597
         @ primitive implementation of a ''broken scale`` graph...
4597
         @ primitive implementation of a ''broken scale`` graph...
Line 4645... Line 4645...
4645
        @ a userdraw object will snap to these points.
4645
        @ a userdraw object will snap to these points.
4646
        @ the array size (e.g. the number of points) of command ''snaptopoints`` is limited by constant MAX_INT (canvasdraw.h)
4646
        @ the array size (e.g. the number of points) of command ''snaptopoints`` is limited by constant MAX_INT (canvasdraw.h)
4647
        @ a draggable object (use command ''drag x|y|xy``) will snap to the closed of these points when dragged (mouseup)
4647
        @ a draggable object (use command ''drag x|y|xy``) will snap to the closed of these points when dragged (mouseup)
4648
        @ other options: use keyword ''snaptogrid``, ''xsnaptogrid`` or ''ysnaptogrid``
4648
        @ other options: use keyword ''snaptogrid``, ''xsnaptogrid`` or ''ysnaptogrid``
4649
        @%snaptopoints%size 400,400%xrange -5,5%yrange -5,5%snaptopoints -1,-3,-1,-2,-1,0,-1,1,-1,2,-1,3,1,-3,1,-2,1,-1,1,0,1,1,1,2,1,3%linewidth 2%points red,-1,-3,-1,-2,-1,0,-1,1,-1,2,-1,3,1,-3,1,-2,1,-1,1,0,1,1,1,2,1,3%userdraw arrows,red
4649
        @%snaptopoints%size 400,400%xrange -5,5%yrange -5,5%snaptopoints -1,-3,-1,-2,-1,0,-1,1,-1,2,-1,3,1,-3,1,-2,1,-1,1,0,1,1,1,2,1,3%linewidth 2%points red,-1,-3,-1,-2,-1,0,-1,1,-1,2,-1,3,1,-3,1,-2,1,-1,1,0,1,1,1,2,1,3%userdraw arrows,red
-
 
4650
        @%snaptopoints%size 400,400%xrange -5,5%yrange -5,5%snaptopoints -1,-3,-1,-2,-1,0,-1,1,-1,2,-1,3,1,-3,1,-2,1,-1,1,0,1,1,1,2,1,3%linewidth 3%%points blue,-1,-3,-1,-2,-1,0,-1,1,-1,2,-1,3,1,-3,1,-2,1,-1,1,0,1,1,1,2,1,3%drag xy%ftriangle -4,0,-2,3,0,0,red
4650
        */
4651
        */
4651
            i = 0;
4652
            i = 0;
4652
            use_snap = 4;
4653
            use_snap = 4;
4653
            while( ! done ){     /* get next item until EOL*/
4654
            while( ! done ){     /* get next item until EOL*/
4654
                if(i > MAX_INT - 1){canvas_error("too many points in argument: repeat command multiple times to fit");}
4655
                if(i > MAX_INT - 1){canvas_error("too many points in argument: repeat command multiple times to fit");}
Line 5735... Line 5736...
5735
                    case 1: fill_color = get_color(infile,1);
5736
                    case 1: fill_color = get_color(infile,1);
5736
                        string_length = 1 + snprintf(NULL,0,"draw_grid%d(%d,%d,\"%s\",\"%s\",%.2f,%.2f,%d,\"%s\",\"%s\",%d,%d); ",canvas_root_id,GRID_CANVAS,line_width,stroke_color,fill_color,stroke_opacity,fill_opacity,font_size,font_family,font_color,use_axis_numbering,precision);
5737
                        string_length = 1 + snprintf(NULL,0,"draw_grid%d(%d,%d,\"%s\",\"%s\",%.2f,%.2f,%d,\"%s\",\"%s\",%d,%d); ",canvas_root_id,GRID_CANVAS,line_width,stroke_color,fill_color,stroke_opacity,fill_opacity,font_size,font_family,font_color,use_axis_numbering,precision);
5737
                        tmp_buffer = my_newmem(string_length);
5738
                        tmp_buffer = my_newmem(string_length);
5738
                        snprintf(tmp_buffer,string_length,"draw_grid%d(%d,%d,\"%s\",\"%s\",%.2f,%.2f,%d,\"%s\",\"%s\",%d,%d); ",canvas_root_id,GRID_CANVAS,line_width,stroke_color,fill_color,stroke_opacity,fill_opacity,font_size,font_family,font_color,use_axis_numbering,precision);
5739
                        snprintf(tmp_buffer,string_length,"draw_grid%d(%d,%d,\"%s\",\"%s\",%.2f,%.2f,%d,\"%s\",\"%s\",%d,%d); ",canvas_root_id,GRID_CANVAS,line_width,stroke_color,fill_color,stroke_opacity,fill_opacity,font_size,font_family,font_color,use_axis_numbering,precision);
5739
                        fprintf(js_include_file,"use_xlogscale=1;use_ylogscale=1;snap_x = xlogbase;snap_y = ylogbase;");
5740
                        fprintf(js_include_file,"use_xlogscale=1;use_ylogscale=1;snap_x = xlogbase;snap_y = ylogbase;");
5740
                        add_to_buffer(tmp_buffer);
5741
                        add_to_buffer(tmp_buffer);
5741
                        break;
5742
                        break;
5742
                    default:break;
5743
                    default:break;
5743
                }
5744
                }
5744
            }
5745
            }
5745
        break;
5746
        break;
5746
 
5747
 
5747
 
5748
 
5748
        case Y_AXIS_STRINGS:
5749
        case Y_AXIS_STRINGS:
5749
        /*
5750
        /*
5750
         @ yaxis num1:string1:num2:string2:num3:string3:num4:string4:....num_n:string_n
5751
         @ yaxis num1:string1:num2:string2:num3:string3:num4:string4:....num_n:string_n
Line 6510... Line 6511...
6510
    temp[0] = '[';/* start js-array */
6511
    temp[0] = '[';/* start js-array */
6511
    for(i = 0; i < len;i = i + 2){ /*  x_points[] */
6512
    for(i = 0; i < len;i = i + 2){ /*  x_points[] */
6512
        if(i == len - 2){sprintf(tmp, "%.*f",decimals, xy[i]);}else{sprintf(tmp, "%.*f,",decimals,xy[i]);}
6513
        if(i == len - 2){sprintf(tmp, "%.*f",decimals, xy[i]);}else{sprintf(tmp, "%.*f,",decimals,xy[i]);}
6513
        space_left = (int) (sizeof(temp) - strlen(temp) - strlen(tmp) - 1);
6514
        space_left = (int) (sizeof(temp) - strlen(temp) - strlen(tmp) - 1);
6514
        if( space_left > 0 ){ strncat(temp,tmp,space_left - 1);}else{canvas_error("can not parse integer to js-array:\nYour curve plotting produces too many data \nreduce your image size or plotsteps ");}
6515
        if( space_left > 0 ){ strncat(temp,tmp,space_left - 1);}else{canvas_error("can not parse integer to js-array:\nYour curve plotting produces too many data \nreduce your image size or plotsteps ");}
6515
    }
6516
    }
6516
    strncat(temp,"],[",4); /* close js x_values array and start new */
6517
    strncat(temp,"],[",4); /* close js x_values array and start new */
6517
    for(i = 1; i < len;i = i + 2){ /* y_points */
6518
    for(i = 1; i < len;i = i + 2){ /* y_points */
6518
        if(i == len - 1){ sprintf(tmp, "%.*f",decimals,xy[i]);}else{sprintf(tmp, "%.*f,",decimals,xy[i]);}
6519
        if(i == len - 1){ sprintf(tmp, "%.*f",decimals,xy[i]);}else{sprintf(tmp, "%.*f,",decimals,xy[i]);}
6519
        space_left = (int) (sizeof(temp) - strlen(temp) - strlen(tmp) - 1);
6520
        space_left = (int) (sizeof(temp) - strlen(temp) - strlen(tmp) - 1);
6520
        if( space_left > 0 ){ strncat(temp,tmp,space_left - 1);}else{canvas_error("can not parse integer to js-array:\nYour curve plotting produces too many data \nreduce your image size or plotsteps");}
6521
        if( space_left > 0 ){ strncat(temp,tmp,space_left - 1);}else{canvas_error("can not parse integer to js-array:\nYour curve plotting produces too many data \nreduce your image size or plotsteps");}
Line 6886... Line 6887...
6886
        *centerstring="centerstring",
6887
        *centerstring="centerstring",
6887
        *xunit="xunit",
6888
        *xunit="xunit",
6888
        *yunit="yunit",
6889
        *yunit="yunit",
6889
        *slider="slider",
6890
        *slider="slider",
6890
        *killslider="killslider",
6891
        *killslider="killslider",
-
 
6892
        *killgroup="killgroup",
6891
        *angle="angle",
6893
        *angle="angle",
6892
        *halflines="halflines",
6894
        *halflines="halflines",
6893
        *demilines="demilines",
6895
        *demilines="demilines",
6894
        *halfline="halfline",
6896
        *halfline="halfline",
6895
        *demiline="demiline",
6897
        *demiline="demiline",
6896
        *hlines="hlines",
6898
        *hlines="hlines",
6897
        *vlines="vlines",
6899
        *vlines="vlines",
6898
        *bezier="bezier",
6900
        *bezier="bezier",
6899
        *functionlabel="functionlabel",
6901
        *functionlabel="functionlabel",
6900
        *functionlabels="functionlabels",
6902
        *functionlabels="functionlabels",
6901
        *sliderfunction_x="sliderfunction_x",
-
 
6902
        *sliderfunction_y="sliderfunction_y",
6903
        *group="group",
6903
        *multidraw="multidraw",
6904
        *multidraw="multidraw",
6904
        *multilinewidth="multilinewidth",
6905
        *multilinewidth="multilinewidth",
6905
        *linewidths="linewidths",
6906
        *linewidths="linewidths",
6906
        *multistrokecolors="multistrokecolors",
6907
        *multistrokecolors="multistrokecolors",
6907
        *multicolors="multicolors",
6908
        *multicolors="multicolors",
Line 7486... Line 7487...
7486
        }
7487
        }
7487
        if( strcmp(input_type, slider) == 0 ){
7488
        if( strcmp(input_type, slider) == 0 ){
7488
        free(input_type);
7489
        free(input_type);
7489
        return SLIDER;
7490
        return SLIDER;
7490
        }
7491
        }
7491
        if( strcmp(input_type, killslider) == 0 ){
7492
        if( strcmp(input_type, killslider) == 0 || strcmp(input_type, killgroup) == 0 ){
7492
        free(input_type);
7493
        free(input_type);
7493
        return KILLSLIDER;
7494
        return KILLSLIDER;
7494
        }
7495
        }
7495
        if( strcmp(input_type, copy) == 0 ){
7496
        if( strcmp(input_type, copy) == 0 ){
7496
        free(input_type);
7497
        free(input_type);
Line 7667... Line 7668...
7667
        }
7668
        }
7668
        if( strcmp(input_type, functionlabel) == 0 ||  strcmp(input_type, functionlabels) == 0 ){
7669
        if( strcmp(input_type, functionlabel) == 0 ||  strcmp(input_type, functionlabels) == 0 ){
7669
        free(input_type);
7670
        free(input_type);
7670
        return FUNCTION_LABEL;
7671
        return FUNCTION_LABEL;
7671
        }
7672
        }
7672
        if( strcmp(input_type, sliderfunction_x) == 0 ){
7673
        if( strcmp(input_type, group) == 0 ){
7673
        free(input_type);
-
 
7674
        return SLIDER_X;
-
 
7675
        }
-
 
7676
        if( strcmp(input_type, sliderfunction_y) == 0 ){
-
 
7677
        free(input_type);
7674
        free(input_type);
7678
        return SLIDER_Y;
7675
        return GROUP;
7679
        }
7676
        }
7680
        if( strcmp(input_type, multidraw) == 0 ){
7677
        if( strcmp(input_type, multidraw) == 0 ){
7681
        free(input_type);
7678
        free(input_type);
7682
        return MULTIDRAW;
7679
        return MULTIDRAW;
7683
        }
7680
        }