#include <VisReco/VisMuonCSC/interface/VisCSCPlotWidgetAxisX.h>
Public Member Functions | |
QSize | minimumSizeHint () const |
QSize | sizeHint () const |
VisCSCPlotWidgetAxisX (const int nbins, QWidget *parent=0, const char *name=0) | |
~VisCSCPlotWidgetAxisX (void) | |
Protected Member Functions | |
void | paintEvent (QPaintEvent *) |
Private Attributes | |
int | m_bins |
Definition at line 5 of file VisCSCPlotWidgetAxisX.h.
VisCSCPlotWidgetAxisX::VisCSCPlotWidgetAxisX | ( | const int | nbins, | |
QWidget * | parent = 0 , |
|||
const char * | name = 0 | |||
) |
VisCSCPlotWidgetAxisX::~VisCSCPlotWidgetAxisX | ( | void | ) |
QSize VisCSCPlotWidgetAxisX::minimumSizeHint | ( | ) | const |
Definition at line 16 of file VisCSCPlotWidgetAxisX.cc.
00017 { 00018 // minimumSizeHint/sizeHint must be coordinated with y axis/VisCSCPlotWidget 00019 return QSize( 80, 40 ); 00020 }
void VisCSCPlotWidgetAxisX::paintEvent | ( | QPaintEvent * | ) | [protected] |
Definition at line 25 of file VisCSCPlotWidgetAxisX.cc.
References i, int, j, label, m_bins, scale, and width.
00026 { 00027 QPainter painter(this); 00028 painter.setPen(Qt::blue); 00029 QFont sansFont( "Helvetica", 9 ); 00030 painter.setFont( sansFont ); 00031 QFontMetrics fm( sansFont ); 00032 00033 // assume every five bins is a good choice: change to 16 for CSC 00034 const int bin_spacing = 16; 00035 QPointArray scale( 4 * int(floor(float(m_bins) / bin_spacing)) ); 00036 int yoffset = 2; 00037 int tickHeight = 4; 00038 00039 // don't forget that the last pixel is width()-1 00040 for (int i = bin_spacing, j = 0; i <= m_bins; i += bin_spacing ) 00041 { 00042 // labels go under center of bin before tick marks 00043 QString label = QString("%1").arg(i); 00044 int labelWidth = fm.width(label); 00045 int xtext = int(floor( (i - 0.5F)*width()/m_bins - labelWidth/2.F + 0.5F) ); 00046 // check to see last label doesn't stick over the edge 00047 if (xtext > width()-1 - fm.width(label)) 00048 { 00049 xtext = width()-1 - fm.width(label); 00050 } 00051 painter.drawText( xtext, fm.height(), label ); 00052 // draw tick marks 00053 scale.setPoint(j++, int(float(i - bin_spacing)*(width()-1)/m_bins + 0.5F), yoffset+tickHeight ); 00054 scale.setPoint(j++, int(float(i - bin_spacing)*(width()-1)/m_bins + 0.5F), yoffset ); 00055 scale.setPoint(j++, int(float(i )*(width()-1)/m_bins + 0.5F), yoffset ); 00056 scale.setPoint(j++, int(float(i )*(width()-1)/m_bins + 0.5F), yoffset+tickHeight ); 00057 } 00058 painter.drawPolyline(scale); 00059 }
QSize VisCSCPlotWidgetAxisX::sizeHint | ( | void | ) | const |
int VisCSCPlotWidgetAxisX::m_bins [private] |
Definition at line 16 of file VisCSCPlotWidgetAxisX.h.
Referenced by paintEvent(), and VisCSCPlotWidgetAxisX().