/** * Returns the nth mode of the scale sc. */ scale mode(const scale& sc, const units::scale_offset& n) { using namespace units; auto first = sc.interval(n); auto size = sc.size(); intervals_type newscale; for (unsigned int i = 0; i < size; ++i) { newscale.emplace_back(sc.interval(n + units::scale_offset{(int)i}) - first); } return scale{std::move(newscale)}; }
void scigraphics::axisTicksY::drawOneTick( painter &Painter, const scale &Scale, number Value ) { double FLength = std::fabs( Painter.wcoord2fcoordX( getTickLength() ) - Painter.wcoord2fcoordX( 0 ) ); fcoord Y = Scale.numberToFraction( Value ); fcoord X0 = BaseX; fcoord X1 = X0 + ( BaseX < 0.5 ? +1 : -1 ) * FLength; Painter.drawLineF( fpoint(X0,Y), fpoint(X1,Y), getTickStyle() ); }
void scigraphics::axisLabelsX::drawOneLabel( painter &Painter, const scale &Scale, number Value ) const { fcoord X = Scale.numberToFraction( Value ); std::string Text = getNumberStyle().numberText( Value ); unsigned Flags = ( BaseY < 0.5 ) ? painter::HCenter|painter::VUp : painter::HCenter|painter::VDown; int Shift = ( BaseY < 0.5 ? +1 : -1 ) * (-3); // std::cout << "axisTicksX: draw " << Text << " crd " << Coord << " clr " << getTextStyle().getColor().name() << std::endl; Painter.drawTextF( Text, fpoint(X,BaseY), Flags, getTextStyle(), 0, Shift ); }
void scigraphics::axisTicksX::drawOneTick( painter &Painter, const scale &Scale, number Value ) { double FLength = std::fabs( Painter.wcoord2fcoordY( getTickLength() ) - Painter.wcoord2fcoordY( 0 ) ); fcoord X = Scale.numberToFraction( Value ); fcoord Y0 = BaseY; fcoord Y1 = Y0 + ( BaseY < 0.5 ? +1 : -1 ) * FLength; Painter.drawLineF( fpoint(X,Y0), fpoint(X,Y1), getTickStyle() ); }
void scigraphics::axisLabelsY::drawOneLabel( painter &Painter, const scale &Scale, number Value ) const { fcoord Y = Scale.numberToFraction( Value ); std::string Text = getNumberStyle().numberText( Value ); unsigned Flags = ( BaseX < 0.5 ) ? painter::HRight|painter::VCenter : painter::HLeft|painter::VCenter; int Shift = ( BaseX < 0.5 ? +1 : -1 ) * 6; Painter.drawTextF( Text, fpoint(BaseX,Y), Flags, getTextStyle(), Shift, 0 ); // std::cout << "axisLabelsY::drawOneLabel: " << Text << " - " << BaseX << " " << Y << " " << Shift << std::endl; }