void scigraphics::painter::drawPointW( const wpoint &Point, const pointStyle &Style ) { if ( ! ableToDraw() ) return; brushStyle BrushStyle( Style.getColor() ); switch ( Style.getShape() ) { case pointStyle::None: break; case pointStyle::Square: { wpoint LU( Point.x() - Style.width()/2, Point.y() - Style.width()/2 ); wpoint RD( LU.x() + Style.width(), LU.y() + Style.width() ); Drawer->setBrushStyle( BrushStyle ); Drawer->setLineStyle( lineStyle(BrushStyle.getColor()) ); Drawer->drawRectangle( wrectangle(LU,RD) ); } break; default: abort(); } }
void scigraphics::painter::updatePlotRectangle() { if ( ableToDraw() ) PlotRectangle = Indents.apply( Drawer->plotRectangle() ); else PlotRectangle = wrectangle(); }
void scigraphics::painter::drawTextW( const std::string &String, wpoint Point, unsigned Position, const textStyle &Style, int ShiftLeft, int ShiftUp, double Angle ) { if ( ! ableToDraw() ) return; int Width = Drawer->textWidth( String, Style ); int Height = Drawer->textHeight( String, Style ); switch ( Position & 0x00FF ) { case HLeft: ShiftLeft += 0; break; case HRight: ShiftLeft += Width; break; case HCenter: ShiftLeft += Width/2; break; } switch ( Position & 0xFF00 ) { case VUp: ShiftUp += 0; break; case VDown: ShiftUp += Height; break; case VCenter: ShiftUp += Height/2; break; } wpoint LU( Point.x() - ShiftLeft, Point.y() - ShiftUp ); wpoint RD( LU.x() + Width, LU.y() + Height ); Drawer->setTextStyle( Style ); Drawer->drawText( String, wrectangle(LU,RD), Angle ); }
void scigraphics::painter::clearBordersArea() { if ( ! ableToDraw() ) return; const int Shift = 10; wpoint Point1( -Shift, -Shift ); wpoint Point2( Indents.left(), Drawer->height() + Shift ); Drawer->eraseRectangle( wrectangle(Point1,Point2) ); wpoint Point3( Drawer->width() + Shift, Drawer->height() - Indents.down() ); Drawer->eraseRectangle( wrectangle(Point2,Point3) ); wpoint Point4( Drawer->width() - Indents.right(), -Shift ); Drawer->eraseRectangle( wrectangle(Point3,Point4) ); wpoint Point5( -Shift, Indents.up() ); Drawer->eraseRectangle( wrectangle(Point4,Point5) ); }
scigraphics::wcoord scigraphics::legend::drawGraphLegend( painter &Painter, wcoord y, const graph &Graph, const textStyle &Style ) { const wcoord TextHeight = Painter.textHeight( Graph.legend(), Style ); const wcoord XForExample = getRectangle().left() + textHorizontalIndent(); const wcoord ExampleWidth = Graph.legendExampleWidth(); const wcoord GraphLegendHeight = std::max( Graph.legendExampleHeight(), TextHeight ); Graph.drawLegendExample( Painter, wrectangle( wpoint( XForExample, y-GraphLegendHeight ), wpoint(XForExample+ExampleWidth,y) ) ); const wcoord XForText = XForExample + ExampleWidth + textHorizontalIndent(); Painter.drawTextW( Graph.legend(), wpoint( XForText, y-GraphLegendHeight/2 ), painter::HLeft|painter::VCenter, Style ); return GraphLegendHeight; }
void scigraphics::floatRectangle::setRectangle( const wpoint &A, const wpoint &B ) { setRectangle( wrectangle(A,B) ); }
scigraphics::wrectangle scigraphics::legend::createInitialRectangle( painter &Painter ) { const wpoint Point( Painter.width() - 30, 90 ); return wrectangle( Point, Point ); }