@@ -73,7 +73,7 @@ extern {
73
73
pub struct Cell {
74
74
pub row : i32 ,
75
75
pub col : i32 ,
76
- pub title : String ,
76
+ pub title : * const c_char ,
77
77
pub cmap : ColorMap ,
78
78
}
79
79
@@ -284,7 +284,7 @@ impl Window {
284
284
/// - `ylabel` is y axis title
285
285
/// - `zlabel` is z axis title
286
286
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 } ;
288
288
let xstr = CString :: new ( xlabel) . unwrap ( ) ;
289
289
let ystr = CString :: new ( ylabel) . unwrap ( ) ;
290
290
let zstr = CString :: new ( zlabel) . unwrap ( ) ;
@@ -314,7 +314,7 @@ impl Window {
314
314
/// to next power of 2 and the magnitude remains the same.
315
315
pub fn set_axes_limits_compute ( & mut self , xrange : & Array , yrange : & Array ,
316
316
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 } ;
318
318
unsafe {
319
319
let err_val = af_set_axes_limits_compute ( self . handle as WndHandle ,
320
320
xrange. get ( ) as AfArray ,
@@ -343,7 +343,7 @@ impl Window {
343
343
/// are to extracted. If exact is false then the most significant digit is rounded up
344
344
/// to next power of 2 and the magnitude remains the same.
345
345
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 } ;
347
347
unsafe {
348
348
let err_val = af_set_axes_limits_2d ( self . handle as WndHandle , xmin as c_float ,
349
349
xmax as c_float , ymin as c_float , ymax as c_float ,
@@ -370,7 +370,7 @@ impl Window {
370
370
/// to next power of 2 and the magnitude remains the same.
371
371
pub fn set_axes_limits_3d ( & mut self , xmin : f32 , xmax : f32 , ymin : f32 , ymax : f32 ,
372
372
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 } ;
374
374
unsafe {
375
375
let err_val = af_set_axes_limits_3d ( self . handle as WndHandle , xmin as c_float ,
376
376
xmax as c_float , ymin as c_float , ymax as c_float ,
@@ -392,7 +392,8 @@ impl Window {
392
392
Some ( s) => s,
393
393
None => format ! ( "Cell({},{}))" , self . col, self . row)
394
394
} ;
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 } ;
396
397
unsafe {
397
398
let err_val = af_draw_image ( self . handle as WndHandle , input. get ( ) as AfArray ,
398
399
cprops as * const Cell as CellPtr ) ;
@@ -413,7 +414,8 @@ impl Window {
413
414
Some ( s) => s,
414
415
None => format ! ( "Cell({},{}))" , self . col, self . row)
415
416
} ;
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 } ;
417
419
unsafe {
418
420
let err_val = af_draw_plot_2d ( self . handle as WndHandle ,
419
421
x. get ( ) as AfArray , y. get ( ) as AfArray ,
@@ -436,7 +438,8 @@ impl Window {
436
438
Some ( s) => s,
437
439
None => format ! ( "Cell({},{}))" , self . col, self . row)
438
440
} ;
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 } ;
440
443
unsafe {
441
444
let err_val = af_draw_plot_3d ( self . handle as WndHandle ,
442
445
x. get ( ) as AfArray , y. get ( ) as AfArray , z. get ( ) as AfArray ,
@@ -457,7 +460,8 @@ impl Window {
457
460
Some ( s) => s,
458
461
None => format ! ( "Cell({},{}))" , self . col, self . row)
459
462
} ;
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 } ;
461
465
unsafe {
462
466
let err_val = af_draw_plot_nd ( self . handle as WndHandle , points. get ( ) as AfArray ,
463
467
cprops as * const Cell as CellPtr ) ;
@@ -479,7 +483,8 @@ impl Window {
479
483
Some ( s) => s,
480
484
None => format ! ( "Cell({},{}))" , self . col, self . row)
481
485
} ;
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 } ;
483
488
unsafe {
484
489
let err_val = af_draw_hist ( self . handle as WndHandle , hst. get ( ) as AfArray ,
485
490
minval as c_double , maxval as c_double ,
@@ -502,7 +507,8 @@ impl Window {
502
507
Some ( s) => s,
503
508
None => format ! ( "Cell({},{}))" , self . col, self . row)
504
509
} ;
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 } ;
506
512
unsafe {
507
513
let err_val = af_draw_surface ( self . handle as WndHandle ,
508
514
xvals. get ( ) as AfArray ,
@@ -528,7 +534,8 @@ impl Window {
528
534
Some ( s) => s,
529
535
None => format ! ( "Cell({},{}))" , self . col, self . row)
530
536
} ;
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 } ;
532
539
unsafe {
533
540
let err_val = af_draw_scatter_2d ( self . handle as WndHandle ,
534
541
xvals. get ( ) as AfArray , yvals. get ( ) as AfArray ,
@@ -553,7 +560,8 @@ impl Window {
553
560
Some ( s) => s,
554
561
None => format ! ( "Cell({},{}))" , self . col, self . row)
555
562
} ;
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 } ;
557
565
unsafe {
558
566
let err_val = af_draw_scatter_3d ( self . handle as WndHandle , xvals. get ( ) as AfArray ,
559
567
yvals. get ( ) as AfArray , zvals. get ( ) as AfArray ,
@@ -575,7 +583,8 @@ impl Window {
575
583
Some ( s) => s,
576
584
None => format ! ( "Cell({},{}))" , self . col, self . row)
577
585
} ;
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 } ;
579
588
unsafe {
580
589
let err_val = af_draw_scatter_nd ( self . handle as WndHandle , vals. get ( ) as AfArray ,
581
590
marker as c_int , cprops as * const Cell as CellPtr ) ;
@@ -599,7 +608,8 @@ impl Window {
599
608
Some ( s) => s,
600
609
None => format ! ( "Cell({},{}))" , self . col, self . row)
601
610
} ;
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 } ;
603
613
unsafe {
604
614
let err_val = af_draw_vector_field_2d ( self . handle as WndHandle ,
605
615
xpnts. get ( ) as AfArray , ypnts. get ( ) as AfArray ,
@@ -628,7 +638,8 @@ impl Window {
628
638
Some ( s) => s,
629
639
None => format ! ( "Cell({},{}))" , self . col, self . row)
630
640
} ;
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 } ;
632
643
unsafe {
633
644
let err_val = af_draw_vector_field_3d ( self . handle as WndHandle , xpnts. get ( ) as AfArray ,
634
645
ypnts. get ( ) as AfArray , zpnts. get ( ) as AfArray ,
@@ -653,7 +664,8 @@ impl Window {
653
664
Some ( s) => s,
654
665
None => format ! ( "Cell({},{}))" , self . col, self . row)
655
666
} ;
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 } ;
657
669
unsafe {
658
670
let err_val = af_draw_vector_field_nd ( self . handle as WndHandle ,
659
671
points. get ( ) as AfArray , directions. get ( ) as AfArray ,
0 commit comments