@@ -8,7 +8,8 @@ namespace Calculation {
88
99TrigonometryGraphView::TrigonometryGraphView (TrigonometryModel * model) :
1010 CurveView (model),
11- m_model (model)
11+ m_model (model),
12+ m_shouldDisplayTan (false )
1213{
1314}
1415
@@ -22,17 +23,33 @@ void TrigonometryGraphView::drawRect(KDContext * ctx, KDRect rect) const {
2223 drawCurve (ctx, rect, 0 .0f , 2 .0f *M_PI, M_PI/180 .0f , [](float t, void * model, void * context) {
2324 return Poincare::Coordinate2D<float >(std::cos (t), std::sin (t));
2425 }, nullptr , nullptr , true , Palette::SecondaryText, false );
25- // Draw dashed segment to indicate sine and cosine
26- drawHorizontalOrVerticalSegment (ctx, rect, Axis::Vertical, c, 0 .0f , s, Palette::CalculationTrigoAndComplexForeground, 1 , 3 );
27- drawHorizontalOrVerticalSegment (ctx, rect, Axis::Horizontal, s, 0 .0f , c, Palette::CalculationTrigoAndComplexForeground, 1 , 3 );
26+
27+ if (!m_shouldDisplayTan) {
28+ // Draw dashed segment to indicate sine and cosine
29+ drawHorizontalOrVerticalSegment (ctx, rect, Axis::Vertical, c, 0 .0f , s, Palette::CalculationTrigoAndComplexForeground, 1 , 3 );
30+ drawHorizontalOrVerticalSegment (ctx, rect, Axis::Horizontal, s, 0 .0f , c, Palette::CalculationTrigoAndComplexForeground, 1 , 3 );
31+ }
32+
33+ if (m_shouldDisplayTan) {
34+ float t = std::tan (m_model->angle ());
35+ drawHorizontalOrVerticalSegment (ctx, rect, Axis::Vertical, 1 .0f , m_model->yMin (), m_model->yMax (), Palette::SecondaryText, 2 );
36+ drawSegment (ctx, rect, 0 .0f , 0 .0f , 1 .0f , t, Palette::SecondaryText, false );
37+ drawDot (ctx, rect, 1 .0f , t, Palette::CalculationTrigoAndComplexForeground, Size::Large);
38+ drawLabel (ctx, rect, 0 .0f , t, " tan(θ)" , Palette::CalculationTrigoAndComplexForeground, CurveView::RelativePosition::Before, CurveView::RelativePosition::None);
39+ drawHorizontalOrVerticalSegment (ctx, rect, Axis::Horizontal, t, 0 .0f , 1 .0f , Palette::CalculationTrigoAndComplexForeground, 1 , 3 );
40+ }
41+
2842 // Draw angle position on the circle
29- drawDot (ctx, rect, c, s, Palette::CalculationTrigoAndComplexForeground, Size::Large);
43+ drawDot (ctx, rect, c, s, m_shouldDisplayTan ? Palette::SecondaryText : Palette:: CalculationTrigoAndComplexForeground, m_shouldDisplayTan ? Size::Tiny : Size::Large);
3044 // Draw graduations
3145 drawLabelsAndGraduations (ctx, rect, Axis::Vertical, false , true );
3246 drawLabelsAndGraduations (ctx, rect, Axis::Horizontal, false , true );
33- // Draw labels
34- drawLabel (ctx, rect, 0 .0f , s, " sin(θ)" , Palette::CalculationTrigoAndComplexForeground, c >= 0 .0f ? CurveView::RelativePosition::Before : CurveView::RelativePosition::After, CurveView::RelativePosition::None);
35- drawLabel (ctx, rect, c, 0 .0f , " cos(θ)" , Palette::CalculationTrigoAndComplexForeground, CurveView::RelativePosition::None, s >= 0 .0f ? CurveView::RelativePosition::Before : CurveView::RelativePosition::After);
47+
48+ if (!m_shouldDisplayTan) {
49+ // Draw labels
50+ drawLabel (ctx, rect, 0 .0f , s, " sin(θ)" , Palette::CalculationTrigoAndComplexForeground, c >= 0 .0f ? CurveView::RelativePosition::Before : CurveView::RelativePosition::After, CurveView::RelativePosition::None);
51+ drawLabel (ctx, rect, c, 0 .0f , " cos(θ)" , Palette::CalculationTrigoAndComplexForeground, CurveView::RelativePosition::None, s >= 0 .0f ? CurveView::RelativePosition::Before : CurveView::RelativePosition::After);
52+ }
3653}
3754
3855}
0 commit comments