void scigraphics::sequence::graphViewGeneralLine::drawLegendExample( painter &Painter, const wrectangle &Rectangle ) const { const wcoord VCenter = ( Rectangle.up() + Rectangle.down() )/2; std::vector<wpoint> Polyline; Polyline.push_back( wpoint( Rectangle.left()+1, VCenter ) ); Polyline.push_back( wpoint( Rectangle.right()-1, VCenter ) ); Painter.setLineStyle( getStyle() ); drawLineBetweenPoints( Painter, &Polyline ); }
void scigraphics::painter::drawHorizontalErrorBarW( const wpoint &Min, const wpoint &Max, const errorBarStyle &Style ) { assert( Min.y() == Max.y() ); lineStyle LineStyle = Style.getLineStyle(); wcoord HatWidth = Style.hatWidth(); wcoord Y = Min.y(); drawLineW( Min, Max, LineStyle ); drawLineW( wpoint(Min.x(),Y-HatWidth), wpoint(Min.x(),Y+HatWidth), LineStyle ); drawLineW( wpoint(Max.x(),Y-HatWidth), wpoint(Max.x(),Y+HatWidth), LineStyle ); }
void scigraphics::painter::drawVecticalErrorBarW( const wpoint &Min, const wpoint &Max, const errorBarStyle &Style ) { assert( Min.x() == Max.x() ); lineStyle LineStyle = Style.getLineStyle(); wcoord HatWidth = Style.hatWidth(); wcoord X = Min.x(); drawLineW( Min, Max, LineStyle ); drawLineW( wpoint(X-HatWidth,Min.y()), wpoint(X+HatWidth,Min.y()), LineStyle ); drawLineW( wpoint(X-HatWidth,Max.y()), wpoint(X+HatWidth,Max.y()), LineStyle ); }
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::sequence::graphViewLineHystogram::drawLineBetweenPoints( painter &Painter, std::vector<wpoint> *Points ) const { assert( Points != NULL ); const size_t Size = Points->size(); if ( Size <= 1 ) return; Points->resize( 2*Size-1, wpoint(0,0) ); for ( size_t i = Size-1; i >= 1; i-- ) { const size_t j = i*2; assert( j >= 1 ); assert( j >= i ); assert( j < Points->size() ); wpoint Prev = (*Points)[i-1]; wpoint Next = (*Points)[i]; wpoint Middle( Next.x(), Prev.y() ); (*Points)[j] = Next; (*Points)[j-1] = Middle; } Painter.drawLineW( *Points ); }
void pointsWithSameXCoord::addToPolyline( std::vector<wpoint> *Polyline ) const { assert( Polyline != NULL ); if ( Count == 0 ) return; Polyline->push_back( wpoint( X, FirstY ) ); if ( MinY != FirstY ) Polyline->push_back( wpoint( X, MinY ) ); if ( MaxY != MinY ) Polyline->push_back( wpoint( X, MaxY ) ); if ( MaxY != LastY ) Polyline->push_back( wpoint( X, LastY ) ); }
scigraphics::wpoint scigraphics::painter::fpoint2wpoint( fpoint Pt ) const { wcoord X = fcoord2wcoordX(Pt.x()); wcoord Y = fcoord2wcoordY(Pt.y()); return wpoint( X, Y ); }
// ============================================================ #include "scigraphics/legend.h" #include "scigraphics/textstyle.h" #include "scigraphics/graphcollection.h" #include "scigraphics/graph.h" #include "scigraphics/painter.h" #include <iostream> #include <algorithm> #include <cassert> // ============================================================ const scigraphics::wrectangle scigraphics::legend::InitLegendRectangle( wpoint(0,0), wpoint(0,0) ); // ============================================================ scigraphics::legend::legendSize::legendSize() : Width(0), Height(0) { } // ------------------------------------------------------------ scigraphics::legend::legendSize::legendSize( wcoord W, wcoord H ) : Width(W), Height(H) {
wpoint last() const { return wpoint( X, LastY ); }
wpoint max() const { return wpoint( X, MaxY ); }
wpoint min() const { return wpoint( X, MinY ); }
void scigraphics::sequence::graphViewPoints::drawLegendExample( painter &Painter, const wrectangle &Rectangle ) const { const wcoord VCenter = ( Rectangle.up() + Rectangle.down() )/2; const wcoord HCenter = ( Rectangle.left() + Rectangle.right() )/2; Painter.drawPointW( wpoint(HCenter,VCenter), getStyle() ); }