@@ -113,7 +113,7 @@ EidosValue_SP Plot::ExecuteInstanceMethod(EidosGlobalStringID p_method_id, const
113113 }
114114}
115115
116- // ********************* – (void)abline([Nif a = NULL], [Nif b = NULL], [Nif h = NULL], [Nif v = NULL], [string color = "red"], [numeric lwd = 1.0])
116+ // ********************* – (void)abline([Nif a = NULL], [Nif b = NULL], [Nif h = NULL], [Nif v = NULL], [string color = "red"], [numeric lwd = 1.0], [float alpha = 1.0] )
117117//
118118EidosValue_SP Plot::ExecuteMethod_abline (EidosGlobalStringID p_method_id, const std::vector<EidosValue_SP> &p_arguments, EidosInterpreter &p_interpreter)
119119{
@@ -124,6 +124,7 @@ EidosValue_SP Plot::ExecuteMethod_abline(EidosGlobalStringID p_method_id, const
124124 EidosValue *v_value = p_arguments[3 ].get ();
125125 EidosValue *color_value = p_arguments[4 ].get ();
126126 EidosValue *lwd_value = p_arguments[5 ].get ();
127+ EidosValue *alpha_value = p_arguments[6 ].get ();
127128 double *a = nullptr , *b = nullptr , *h = nullptr , *v = nullptr ;
128129 int line_count;
129130
@@ -225,7 +226,24 @@ EidosValue_SP Plot::ExecuteMethod_abline(EidosGlobalStringID p_method_id, const
225226 lwds->push_back (lwd);
226227 }
227228
228- plotview_->addABLineData (a, b, h, v, line_count, colors, lwds); // takes ownership of buffers
229+ // alpha
230+ std::vector<double > *alphas = new std::vector<double >;
231+ int alpha_count = alpha_value->Count ();
232+
233+ if ((alpha_count != 1 ) && (alpha_count != line_count))
234+ EIDOS_TERMINATION << " ERROR (Plot::ExecuteMethod_abline): abline() requires alpha to match the number of lines, or be singleton." << EidosTerminate ();
235+
236+ for (int index = 0 ; index < alpha_count; ++index)
237+ {
238+ double alpha = alpha_value->FloatAtIndex_NOCAST (index, nullptr );
239+
240+ if ((alpha < 0.0 ) || (alpha > 1.0 ))
241+ EIDOS_TERMINATION << " ERROR (Plot::ExecuteMethod_abline): abline() requires the elements of alpha to be in [0, 1]." << EidosTerminate (nullptr );
242+
243+ alphas->push_back (alpha);
244+ }
245+
246+ plotview_->addABLineData (a, b, h, v, line_count, colors, alphas, lwds); // takes ownership of buffers
229247
230248 return gStaticEidosValueVOID ;
231249}
@@ -553,7 +571,7 @@ EidosValue_SP Plot::ExecuteMethod_legendSwatchEntry(EidosGlobalStringID p_method
553571 return gStaticEidosValueVOID ;
554572}
555573
556- // ********************* – (void)lines(numeric x, numeric y, [string$ color = "red"], [numeric$ lwd = 1.0])
574+ // ********************* – (void)lines(numeric x, numeric y, [string$ color = "red"], [numeric$ lwd = 1.0], [float$ alpha = 1.0] )
557575//
558576EidosValue_SP Plot::ExecuteMethod_lines (EidosGlobalStringID p_method_id, const std::vector<EidosValue_SP> &p_arguments, EidosInterpreter &p_interpreter)
559577{
@@ -562,6 +580,7 @@ EidosValue_SP Plot::ExecuteMethod_lines(EidosGlobalStringID p_method_id, const s
562580 EidosValue *y_value = p_arguments[1 ].get ();
563581 EidosValue *color_value = p_arguments[2 ].get ();
564582 EidosValue *lwd_value = p_arguments[3 ].get ();
583+ EidosValue *alpha_value = p_arguments[4 ].get ();
565584
566585 // x and y
567586 int xcount = x_value->Count ();
@@ -620,12 +639,22 @@ EidosValue_SP Plot::ExecuteMethod_lines(EidosGlobalStringID p_method_id, const s
620639
621640 lineWidths->push_back (lwd);
622641
623- plotview_->addLineData (x, y, xcount, colors, lineWidths); // takes ownership of buffers
642+ // alpha
643+ double alpha = alpha_value->FloatAtIndex_NOCAST (0 , nullptr );
644+
645+ if ((alpha < 0.0 ) || (alpha > 1.0 ))
646+ EIDOS_TERMINATION << " ERROR (Plot::ExecuteMethod_lines): lines() requires the line width alpha to be in [0, 1]." << EidosTerminate (nullptr );
647+
648+ std::vector<double > *lineAlphas = new std::vector<double >; // we only take a singleton alpha, but the API expects a buffer
649+
650+ lineAlphas->push_back (alpha);
651+
652+ plotview_->addLineData (x, y, xcount, colors, lineAlphas, lineWidths); // takes ownership of buffers
624653
625654 return gStaticEidosValueVOID ;
626655}
627656
628- // ********************* – (void)points(numeric x, numeric y, [integer symbol = 0], [string color = "red"], [string border = "black"], [numeric lwd = 1.0], [numeric size = 1.0])
657+ // ********************* – (void)points(numeric x, numeric y, [integer symbol = 0], [string color = "red"], [string border = "black"], [numeric lwd = 1.0], [numeric size = 1.0], [float alpha = 1.0] )
629658//
630659EidosValue_SP Plot::ExecuteMethod_points (EidosGlobalStringID p_method_id, const std::vector<EidosValue_SP> &p_arguments, EidosInterpreter &p_interpreter)
631660{
@@ -637,6 +666,7 @@ EidosValue_SP Plot::ExecuteMethod_points(EidosGlobalStringID p_method_id, const
637666 EidosValue *border_value = p_arguments[4 ].get ();
638667 EidosValue *lwd_value = p_arguments[5 ].get ();
639668 EidosValue *size_value = p_arguments[6 ].get ();
669+ EidosValue *alpha_value = p_arguments[7 ].get ();
640670
641671 // x and y
642672 int xcount = x_value->Count ();
@@ -760,12 +790,29 @@ EidosValue_SP Plot::ExecuteMethod_points(EidosGlobalStringID p_method_id, const
760790 sizes->push_back (size);
761791 }
762792
763- plotview_->addPointData (x, y, xcount, symbols, colors, borders, lwds, sizes); // takes ownership of buffers
793+ // alpha
794+ std::vector<double > *alphas = new std::vector<double >;
795+ int alpha_count = alpha_value->Count ();
796+
797+ if ((alpha_count != 1 ) && (alpha_count != xcount))
798+ EIDOS_TERMINATION << " ERROR (Plot::ExecuteMethod_points): points() requires alpha to match the length of x and y, or be singleton." << EidosTerminate ();
799+
800+ for (int index = 0 ; index < alpha_count; ++index)
801+ {
802+ double alpha = alpha_value->FloatAtIndex_NOCAST (index, nullptr );
803+
804+ if ((alpha < 0.0 ) || (alpha > 1.0 ))
805+ EIDOS_TERMINATION << " ERROR (Plot::ExecuteMethod_points): points() requires the elements of alpha to be in [0, 1]." << EidosTerminate (nullptr );
806+
807+ alphas->push_back (alpha);
808+ }
809+
810+ plotview_->addPointData (x, y, xcount, symbols, colors, borders, alphas, lwds, sizes); // takes ownership of buffers
764811
765812 return gStaticEidosValueVOID ;
766813}
767814
768- // ********************* – (void)text(numeric x, numeric y, string labels, [string color = "black"], [numeric size = 10.0], [Nif adj = NULL])
815+ // ********************* – (void)text(numeric x, numeric y, string labels, [string color = "black"], [numeric size = 10.0], [Nif adj = NULL], [float alpha = 1.0] )
769816//
770817EidosValue_SP Plot::ExecuteMethod_text (EidosGlobalStringID p_method_id, const std::vector<EidosValue_SP> &p_arguments, EidosInterpreter &p_interpreter)
771818{
@@ -776,6 +823,7 @@ EidosValue_SP Plot::ExecuteMethod_text(EidosGlobalStringID p_method_id, const st
776823 EidosValue *color_value = p_arguments[3 ].get ();
777824 EidosValue *size_value = p_arguments[4 ].get ();
778825 EidosValue *adj_value = p_arguments[5 ].get ();
826+ EidosValue *alpha_value = p_arguments[6 ].get ();
779827
780828 // x and y
781829 int xcount = x_value->Count ();
@@ -868,7 +916,24 @@ EidosValue_SP Plot::ExecuteMethod_text(EidosGlobalStringID p_method_id, const st
868916 adj[1 ] = adj_value->NumericAtIndex_NOCAST (1 , nullptr );
869917 }
870918
871- plotview_->addTextData (x, y, labels, xcount, colors, sizes, adj); // takes ownership of buffers
919+ // alpha
920+ std::vector<double > *alphas = new std::vector<double >;
921+ int alpha_count = alpha_value->Count ();
922+
923+ if ((alpha_count != 1 ) && (alpha_count != xcount))
924+ EIDOS_TERMINATION << " ERROR (Plot::ExecuteMethod_text): text() requires alpha to match the length of x and y, or be singleton." << EidosTerminate ();
925+
926+ for (int index = 0 ; index < alpha_count; ++index)
927+ {
928+ double alpha = alpha_value->FloatAtIndex_NOCAST (index, nullptr );
929+
930+ if ((alpha < 0.0 ) || (alpha > 1.0 ))
931+ EIDOS_TERMINATION << " ERROR (Plot::ExecuteMethod_text): text() requires the elements of alpha to be in [0, 1]." << EidosTerminate (nullptr );
932+
933+ alphas->push_back (alpha);
934+ }
935+
936+ plotview_->addTextData (x, y, labels, xcount, colors, alphas, sizes, adj); // takes ownership of buffers
872937
873938 return gStaticEidosValueVOID ;
874939}
@@ -933,7 +998,7 @@ const std::vector<EidosMethodSignature_CSP> *Plot_Class::Methods(void) const
933998 ->AddNumeric_ON (" a" , gStaticEidosValueNULL )->AddNumeric_ON (" b" , gStaticEidosValueNULL )
934999 ->AddNumeric_ON (" h" , gStaticEidosValueNULL )->AddNumeric_ON (" v" , gStaticEidosValueNULL )
9351000 ->AddString_O (" color" , EidosValue_String_SP (new (gEidosValuePool ->AllocateChunk ()) EidosValue_String (" red" )))
936- ->AddNumeric_O (" lwd" , gStaticEidosValue_Float1 )));
1001+ ->AddNumeric_O (" lwd" , gStaticEidosValue_Float1 )-> AddFloat_O ( " alpha " , gStaticEidosValue_Float1 ) ));
9371002 methods->emplace_back (static_cast <EidosInstanceMethodSignature *>((new EidosInstanceMethodSignature (gStr_addLegend , kEidosValueMaskVOID ))
9381003 ->AddString_OSN (" position" , gStaticEidosValueNULL )->AddInt_OSN (" inset" , gStaticEidosValueNULL )
9391004 ->AddNumeric_OSN (" labelSize" , gStaticEidosValueNULL )->AddNumeric_OSN (" lineHeight" , gStaticEidosValueNULL )
@@ -954,17 +1019,17 @@ const std::vector<EidosMethodSignature_CSP> *Plot_Class::Methods(void) const
9541019 ->AddString_S (" label" )->AddString_OS (" color" , EidosValue_String_SP (new (gEidosValuePool ->AllocateChunk ()) EidosValue_String (" red" )))));
9551020 methods->emplace_back (static_cast <EidosInstanceMethodSignature *>((new EidosInstanceMethodSignature (gStr_lines , kEidosValueMaskVOID ))
9561021 ->AddNumeric (" x" )->AddNumeric (" y" )->AddString_OS (" color" , EidosValue_String_SP (new (gEidosValuePool ->AllocateChunk ()) EidosValue_String (" red" )))
957- ->AddNumeric_OS (" lwd" , gStaticEidosValue_Float1 )));
1022+ ->AddNumeric_OS (" lwd" , gStaticEidosValue_Float1 )-> AddFloat_OS ( " alpha " , gStaticEidosValue_Float1 ) ));
9581023 methods->emplace_back (static_cast <EidosInstanceMethodSignature *>((new EidosInstanceMethodSignature (gStr_points , kEidosValueMaskVOID ))
9591024 ->AddNumeric (" x" )->AddNumeric (" y" )->AddInt_O (" symbol" , gStaticEidosValue_Integer0 )
9601025 ->AddString_O (" color" , EidosValue_String_SP (new (gEidosValuePool ->AllocateChunk ()) EidosValue_String (" red" )))
9611026 ->AddString_O (" border" , EidosValue_String_SP (new (gEidosValuePool ->AllocateChunk ()) EidosValue_String (" black" )))
962- ->AddNumeric_O (" lwd" , gStaticEidosValue_Float1 )->AddNumeric_O (" size" , gStaticEidosValue_Float1 )));
1027+ ->AddNumeric_O (" lwd" , gStaticEidosValue_Float1 )->AddNumeric_O (" size" , gStaticEidosValue_Float1 )-> AddFloat_O ( " alpha " , gStaticEidosValue_Float1 ) ));
9631028 methods->emplace_back (static_cast <EidosInstanceMethodSignature *>((new EidosInstanceMethodSignature (gStr_text , kEidosValueMaskVOID ))
9641029 ->AddNumeric (" x" )->AddNumeric (" y" )->AddString (" labels" )
9651030 ->AddString_O (" color" , EidosValue_String_SP (new (gEidosValuePool ->AllocateChunk ()) EidosValue_String (" black" )))
9661031 ->AddNumeric_O (" size" , EidosValue_Float_SP (new (gEidosValuePool ->AllocateChunk ()) EidosValue_Float (10 )))
967- ->AddNumeric_ON (" adj" , gStaticEidosValueNULL )));
1032+ ->AddNumeric_ON (" adj" , gStaticEidosValueNULL )-> AddFloat_O ( " alpha " , gStaticEidosValue_Float1 ) ));
9681033 methods->emplace_back (static_cast <EidosInstanceMethodSignature *>((new EidosInstanceMethodSignature (gEidosStr_write , kEidosValueMaskVOID ))
9691034 ->AddString_S (gEidosStr_filePath )));
9701035
0 commit comments