11#ifndef lint
2- static char * RCSid () { return RCSid ("$Id: graphics.c,v 1.575 2017-09-29 19:23:36 sfeam Exp $" ); }
2+ static char * RCSid () { return RCSid ("$Id: graphics.c,v 1.576 2017-10-31 18:52:59 sfeam Exp $" ); }
33#endif
44
55/* GNUPLOT - graphics.c */
@@ -2414,17 +2414,18 @@ plot_vectors(struct curve_points *plot)
24142414{
24152415 int i ;
24162416 int x1 , y1 , x2 , y2 ;
2417- struct termentry * t = term ;
24182417 struct coordinate points [2 ];
2419- double ex , ey ;
2420- double lx [2 ], ly [2 ];
24212418 arrow_style_type ap ;
2419+ BoundingBox * clip_save = clip_area ;
24222420
24232421 /* Normally this is only necessary once because all arrows equal */
24242422 ap = plot -> arrow_properties ;
24252423 term_apply_lp_properties (& ap .lp_properties );
24262424 apply_head_properties (& ap );
24272425
2426+ /* Clip to plot */
2427+ clip_area = & plot_bounds ;
2428+
24282429 for (i = 0 ; i < plot -> p_count ; i ++ ) {
24292430
24302431 points [0 ] = plot -> points [i ];
@@ -2445,58 +2446,15 @@ plot_vectors(struct curve_points *plot)
24452446 /* variable color read from extra data column. */
24462447 check_for_variable_color (plot , & plot -> varcolor [i ]);
24472448
2448- if (inrange (points [1 ].x , X_AXIS .min , X_AXIS .max )
2449- && inrange (points [1 ].y , Y_AXIS .min , Y_AXIS .max )) {
2450- /* to inrange */
2451- points [1 ].type = INRANGE ;
2452- x2 = map_x (points [1 ].x );
2453- y2 = map_y (points [1 ].y );
2454- if (points [0 ].type == INRANGE ) {
2455- x1 = map_x (points [0 ].x );
2456- y1 = map_y (points [0 ].y );
2457- (* t -> arrow ) (x1 , y1 , x2 , y2 , ap .head );
2458- } else if (points [0 ].type == OUTRANGE ) {
2459- /* from outrange to inrange */
2460- if (clip_lines1 ) {
2461- edge_intersect (points , 1 , & ex , & ey );
2462- x1 = map_x (ex );
2463- y1 = map_y (ey );
2464- if (ap .head & END_HEAD )
2465- (* t -> arrow ) (x1 , y1 , x2 , y2 , END_HEAD );
2466- else
2467- (* t -> arrow ) (x1 , y1 , x2 , y2 , NOHEAD );
2468- }
2469- }
2470- } else {
2471- /* to outrange */
2472- points [1 ].type = OUTRANGE ;
2473- if (points [0 ].type == INRANGE ) {
2474- /* from inrange to outrange */
2475- if (clip_lines1 ) {
2476- x1 = map_x (points [0 ].x );
2477- y1 = map_y (points [0 ].y );
2478- edge_intersect (points , 1 , & ex , & ey );
2479- x2 = map_x (ex );
2480- y2 = map_y (ey );
2481- if (ap .head & BACKHEAD )
2482- (* t -> arrow ) (x2 , y2 , x1 , y1 , BACKHEAD );
2483- else
2484- (* t -> arrow ) (x1 , y1 , x2 , y2 , NOHEAD );
2485- }
2486- } else if (points [0 ].type == OUTRANGE ) {
2487- /* from outrange to outrange */
2488- if (clip_lines2 ) {
2489- if (two_edge_intersect (points , 1 , lx , ly )) {
2490- x1 = map_x (lx [0 ]);
2491- y1 = map_y (ly [0 ]);
2492- x2 = map_x (lx [1 ]);
2493- y2 = map_y (ly [1 ]);
2494- (* t -> arrow ) (x1 , y1 , x2 , y2 , NOHEAD );
2495- }
2496- }
2497- }
2498- }
2449+ /* draw_clip_arrow does the hard work for us */
2450+ x1 = map_x (points [0 ].x );
2451+ y1 = map_y (points [0 ].y );
2452+ x2 = map_x (points [1 ].x );
2453+ y2 = map_y (points [1 ].y );
2454+ draw_clip_arrow (x1 , y1 , x2 , y2 , ap .head );
24992455 }
2456+
2457+ clip_area = clip_save ;
25002458}
25012459
25022460
0 commit comments