@@ -73,7 +73,7 @@ extern {
7373pub struct Cell {
7474 pub row : i32 ,
7575 pub col : i32 ,
76- pub title : String ,
76+ pub title : * const c_char ,
7777 pub cmap : ColorMap ,
7878}
7979
@@ -284,7 +284,7 @@ impl Window {
284284 /// - `ylabel` is y axis title
285285 /// - `zlabel` is z axis title
286286 pub fn set_axes_titles ( & mut self , xlabel : String , ylabel : String , zlabel : String ) {
287- let cprops = & Cell { row : self . row , col : self . col , title : String :: from ( "" ) , cmap : self . cmap } ;
287+ let cprops = & Cell { row : self . row , col : self . col , title : [ 0 ] . as_ptr ( ) , cmap : self . cmap } ;
288288 let xstr = CString :: new ( xlabel) . unwrap ( ) ;
289289 let ystr = CString :: new ( ylabel) . unwrap ( ) ;
290290 let zstr = CString :: new ( zlabel) . unwrap ( ) ;
@@ -314,7 +314,7 @@ impl Window {
314314 /// to next power of 2 and the magnitude remains the same.
315315 pub fn set_axes_limits_compute ( & mut self , xrange : & Array , yrange : & Array ,
316316 zrange : Option < & Array > , exact : bool ) {
317- let cprops = & Cell { row : self . row , col : self . col , title : String :: from ( "" ) , cmap : self . cmap } ;
317+ let cprops = & Cell { row : self . row , col : self . col , title : [ 0 ] . as_ptr ( ) , cmap : self . cmap } ;
318318 unsafe {
319319 let err_val = af_set_axes_limits_compute ( self . handle as WndHandle ,
320320 xrange. get ( ) as AfArray ,
@@ -343,7 +343,7 @@ impl Window {
343343 /// are to extracted. If exact is false then the most significant digit is rounded up
344344 /// to next power of 2 and the magnitude remains the same.
345345 pub fn set_axes_limits_2d ( & mut self , xmin : f32 , xmax : f32 , ymin : f32 , ymax : f32 , exact : bool ) {
346- let cprops = & Cell { row : self . row , col : self . col , title : String :: from ( "" ) , cmap : self . cmap } ;
346+ let cprops = & Cell { row : self . row , col : self . col , title : [ 0 ] . as_ptr ( ) , cmap : self . cmap } ;
347347 unsafe {
348348 let err_val = af_set_axes_limits_2d ( self . handle as WndHandle , xmin as c_float ,
349349 xmax as c_float , ymin as c_float , ymax as c_float ,
@@ -370,7 +370,7 @@ impl Window {
370370 /// to next power of 2 and the magnitude remains the same.
371371 pub fn set_axes_limits_3d ( & mut self , xmin : f32 , xmax : f32 , ymin : f32 , ymax : f32 ,
372372 zmin : f32 , zmax : f32 , exact : bool ) {
373- let cprops = & Cell { row : self . row , col : self . col , title : String :: from ( "" ) , cmap : self . cmap } ;
373+ let cprops = & Cell { row : self . row , col : self . col , title : [ 0 ] . as_ptr ( ) , cmap : self . cmap } ;
374374 unsafe {
375375 let err_val = af_set_axes_limits_3d ( self . handle as WndHandle , xmin as c_float ,
376376 xmax as c_float , ymin as c_float , ymax as c_float ,
@@ -392,7 +392,8 @@ impl Window {
392392 Some ( s) => s,
393393 None => format ! ( "Cell({},{}))" , self . col, self . row)
394394 } ;
395- let cprops = & Cell { row : self . row , col : self . col , title : tstr. clone ( ) , cmap : self . cmap } ;
395+ let tstr = CString :: new ( tstr) . unwrap ( ) ;
396+ let cprops = & Cell { row : self . row , col : self . col , title : tstr. as_ptr ( ) , cmap : self . cmap } ;
396397 unsafe {
397398 let err_val = af_draw_image ( self . handle as WndHandle , input. get ( ) as AfArray ,
398399 cprops as * const Cell as CellPtr ) ;
@@ -413,7 +414,8 @@ impl Window {
413414 Some ( s) => s,
414415 None => format ! ( "Cell({},{}))" , self . col, self . row)
415416 } ;
416- let cprops = & Cell { row : self . row , col : self . col , title : tstr. clone ( ) , cmap : self . cmap } ;
417+ let tstr = CString :: new ( tstr) . unwrap ( ) ;
418+ let cprops = & Cell { row : self . row , col : self . col , title : tstr. as_ptr ( ) , cmap : self . cmap } ;
417419 unsafe {
418420 let err_val = af_draw_plot_2d ( self . handle as WndHandle ,
419421 x. get ( ) as AfArray , y. get ( ) as AfArray ,
@@ -436,7 +438,8 @@ impl Window {
436438 Some ( s) => s,
437439 None => format ! ( "Cell({},{}))" , self . col, self . row)
438440 } ;
439- let cprops = & Cell { row : self . row , col : self . col , title : tstr. clone ( ) , cmap : self . cmap } ;
441+ let tstr = CString :: new ( tstr) . unwrap ( ) ;
442+ let cprops = & Cell { row : self . row , col : self . col , title : tstr. as_ptr ( ) , cmap : self . cmap } ;
440443 unsafe {
441444 let err_val = af_draw_plot_3d ( self . handle as WndHandle ,
442445 x. get ( ) as AfArray , y. get ( ) as AfArray , z. get ( ) as AfArray ,
@@ -457,7 +460,8 @@ impl Window {
457460 Some ( s) => s,
458461 None => format ! ( "Cell({},{}))" , self . col, self . row)
459462 } ;
460- let cprops = & Cell { row : self . row , col : self . col , title : tstr. clone ( ) , cmap : self . cmap } ;
463+ let tstr = CString :: new ( tstr) . unwrap ( ) ;
464+ let cprops = & Cell { row : self . row , col : self . col , title : tstr. as_ptr ( ) , cmap : self . cmap } ;
461465 unsafe {
462466 let err_val = af_draw_plot_nd ( self . handle as WndHandle , points. get ( ) as AfArray ,
463467 cprops as * const Cell as CellPtr ) ;
@@ -479,7 +483,8 @@ impl Window {
479483 Some ( s) => s,
480484 None => format ! ( "Cell({},{}))" , self . col, self . row)
481485 } ;
482- let cprops = & Cell { row : self . row , col : self . col , title : tstr. clone ( ) , cmap : self . cmap } ;
486+ let tstr = CString :: new ( tstr) . unwrap ( ) ;
487+ let cprops = & Cell { row : self . row , col : self . col , title : tstr. as_ptr ( ) , cmap : self . cmap } ;
483488 unsafe {
484489 let err_val = af_draw_hist ( self . handle as WndHandle , hst. get ( ) as AfArray ,
485490 minval as c_double , maxval as c_double ,
@@ -502,7 +507,8 @@ impl Window {
502507 Some ( s) => s,
503508 None => format ! ( "Cell({},{}))" , self . col, self . row)
504509 } ;
505- let cprops = & Cell { row : self . row , col : self . col , title : tstr. clone ( ) , cmap : self . cmap } ;
510+ let tstr = CString :: new ( tstr) . unwrap ( ) ;
511+ let cprops = & Cell { row : self . row , col : self . col , title : tstr. as_ptr ( ) , cmap : self . cmap } ;
506512 unsafe {
507513 let err_val = af_draw_surface ( self . handle as WndHandle ,
508514 xvals. get ( ) as AfArray ,
@@ -528,7 +534,8 @@ impl Window {
528534 Some ( s) => s,
529535 None => format ! ( "Cell({},{}))" , self . col, self . row)
530536 } ;
531- let cprops = & Cell { row : self . row , col : self . col , title : tstr. clone ( ) , cmap : self . cmap } ;
537+ let tstr = CString :: new ( tstr) . unwrap ( ) ;
538+ let cprops = & Cell { row : self . row , col : self . col , title : tstr. as_ptr ( ) , cmap : self . cmap } ;
532539 unsafe {
533540 let err_val = af_draw_scatter_2d ( self . handle as WndHandle ,
534541 xvals. get ( ) as AfArray , yvals. get ( ) as AfArray ,
@@ -553,7 +560,8 @@ impl Window {
553560 Some ( s) => s,
554561 None => format ! ( "Cell({},{}))" , self . col, self . row)
555562 } ;
556- let cprops = & Cell { row : self . row , col : self . col , title : tstr. clone ( ) , cmap : self . cmap } ;
563+ let tstr = CString :: new ( tstr) . unwrap ( ) ;
564+ let cprops = & Cell { row : self . row , col : self . col , title : tstr. as_ptr ( ) , cmap : self . cmap } ;
557565 unsafe {
558566 let err_val = af_draw_scatter_3d ( self . handle as WndHandle , xvals. get ( ) as AfArray ,
559567 yvals. get ( ) as AfArray , zvals. get ( ) as AfArray ,
@@ -575,7 +583,8 @@ impl Window {
575583 Some ( s) => s,
576584 None => format ! ( "Cell({},{}))" , self . col, self . row)
577585 } ;
578- let cprops = & Cell { row : self . row , col : self . col , title : tstr. clone ( ) , cmap : self . cmap } ;
586+ let tstr = CString :: new ( tstr) . unwrap ( ) ;
587+ let cprops = & Cell { row : self . row , col : self . col , title : tstr. as_ptr ( ) , cmap : self . cmap } ;
579588 unsafe {
580589 let err_val = af_draw_scatter_nd ( self . handle as WndHandle , vals. get ( ) as AfArray ,
581590 marker as c_int , cprops as * const Cell as CellPtr ) ;
@@ -599,7 +608,8 @@ impl Window {
599608 Some ( s) => s,
600609 None => format ! ( "Cell({},{}))" , self . col, self . row)
601610 } ;
602- let cprops = & Cell { row : self . row , col : self . col , title : tstr. clone ( ) , cmap : self . cmap } ;
611+ let tstr = CString :: new ( tstr) . unwrap ( ) ;
612+ let cprops = & Cell { row : self . row , col : self . col , title : tstr. as_ptr ( ) , cmap : self . cmap } ;
603613 unsafe {
604614 let err_val = af_draw_vector_field_2d ( self . handle as WndHandle ,
605615 xpnts. get ( ) as AfArray , ypnts. get ( ) as AfArray ,
@@ -628,7 +638,8 @@ impl Window {
628638 Some ( s) => s,
629639 None => format ! ( "Cell({},{}))" , self . col, self . row)
630640 } ;
631- let cprops = & Cell { row : self . row , col : self . col , title : tstr. clone ( ) , cmap : self . cmap } ;
641+ let tstr = CString :: new ( tstr) . unwrap ( ) ;
642+ let cprops = & Cell { row : self . row , col : self . col , title : tstr. as_ptr ( ) , cmap : self . cmap } ;
632643 unsafe {
633644 let err_val = af_draw_vector_field_3d ( self . handle as WndHandle , xpnts. get ( ) as AfArray ,
634645 ypnts. get ( ) as AfArray , zpnts. get ( ) as AfArray ,
@@ -653,7 +664,8 @@ impl Window {
653664 Some ( s) => s,
654665 None => format ! ( "Cell({},{}))" , self . col, self . row)
655666 } ;
656- let cprops = & Cell { row : self . row , col : self . col , title : tstr. clone ( ) , cmap : self . cmap } ;
667+ let tstr = CString :: new ( tstr) . unwrap ( ) ;
668+ let cprops = & Cell { row : self . row , col : self . col , title : tstr. as_ptr ( ) , cmap : self . cmap } ;
657669 unsafe {
658670 let err_val = af_draw_vector_field_nd ( self . handle as WndHandle ,
659671 points. get ( ) as AfArray , directions. get ( ) as AfArray ,
0 commit comments