Пример #1
0
/**
 * 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)};
}
Пример #2
0
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() );
}
Пример #3
0
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 );
}
Пример #4
0
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() );
}
Пример #5
0
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;
}