#include <featuregui.h>
Inheritance diagram for DnaStrGui:
Public Member Functions | |
DnaStrGui (SpatialFeatureData *data) | |
void | paintMe (QPainter *p, TR_PIX x_pix, TR_PIX y_pix, TR_DNA x1_dna, TR_DNA x2_dna, double width, int height, int center) |
Private Member Functions | |
DnaStrData * | dnaStrData () |
Private Attributes | |
QFont | f |
int | currentWidth |
int | currentHeight |
int | oldRequestedHeight |
int | oldRequestedWidth |
int | currentDescent |
Definition at line 83 of file featuregui.h.
DnaStrGui::DnaStrGui | ( | SpatialFeatureData * | data | ) | [inline] |
Definition at line 86 of file featuregui.h.
References currentDescent, currentHeight, currentWidth, f, oldRequestedHeight, oldRequestedWidth, QFont::setFamily(), and QFont::setFixedPitch().
00086 : FeatureGui( data ) 00087 { 00088 f.setFamily("Luxi Mono"); 00089 f.setFixedPitch( true ); 00090 oldRequestedHeight = 0; 00091 oldRequestedWidth = 0; 00092 currentHeight = 0; 00093 currentWidth = 0; 00094 currentDescent = 0; 00095 // cerr << "in dnastrgui ctor" << endl; 00096 }
void DnaStrGui::paintMe | ( | QPainter * | p, | |
TR_PIX | x_pix, | |||
TR_PIX | y_pix, | |||
TR_DNA | x1_dna, | |||
TR_DNA | x2_dna, | |||
double | width, | |||
int | height, | |||
int | center | |||
) | [virtual] |
Paints the visual appearance of a feature.
p | the QPainter to paint to | |
x_pix | the pixel coordinate of the upper left corner of the rectangle where the feature should be painted | |
y_pix | the pixel coordinate of the upper left corner of the rectangle where the feature should be painted | |
x1_dna | the left most position that should be painted given as a dna coordinate relative the left side of the read. | |
x2_dna | the right most position that should be painted given as a dna coordinate relative the left side of the read. |
Implements FeatureGui.
Definition at line 115 of file featuregui.cpp.
References currentDescent, currentHeight, currentWidth, QFontMetrics::descent(), dnaStrData(), QPainter::drawText(), f, QFontMetrics::height(), oldRequestedHeight, oldRequestedWidth, QBrush::setColor(), QPainter::setFont(), QFont::setPointSize(), QBrush::setStyle(), and QFontMetrics::width().
00117 { 00118 if ( height != oldRequestedHeight || width != oldRequestedWidth ) { 00119 oldRequestedHeight = height; 00120 oldRequestedWidth = static_cast<int>(width); 00121 00122 int sz = height; 00123 00124 while ( sz > 0 ) { 00125 f.setPointSize( sz ); 00126 QFontMetrics fm( f ); 00127 00128 if ( fm.width('m') <= width && fm.height() <= height ) { 00129 currentHeight = fm.height(); 00130 currentDescent = fm.descent(); 00131 currentWidth = fm.width('m'); 00132 break; 00133 } 00134 --sz; 00135 } 00136 } 00137 00138 QString str; 00139 QBrush brush; 00140 brush.setStyle( Qt::SolidPattern ); 00141 00142 QColor color; 00143 brush.setColor( Qt::black ); 00144 00145 p->setFont(f); 00146 00147 int pixelsHigh = currentHeight; 00148 00149 00150 for ( int i = x1_dna; i <= x2_dna ; ++i ) { 00151 char c = dnaStrData()->dnaVector.stlVector()[i]; 00152 QChar c2( c ); 00153 QString a( c2 ); 00154 p->drawText( static_cast<int>(x_pix + ( ( i- x1_dna ) + 0.25)* width), y_pix + height - ( ( height - pixelsHigh ) / 2 )- currentDescent, a ); 00155 } 00156 return; 00157 }
DnaStrData * DnaStrGui::dnaStrData | ( | ) | [private] |
Definition at line 110 of file featuregui.cpp.
References FeatureGui::m_data.
Referenced by paintMe().
00111 { 00112 return dynamic_cast<DnaStrData *>( m_data ); 00113 }
QFont DnaStrGui::f [private] |
int DnaStrGui::currentWidth [private] |
int DnaStrGui::currentHeight [private] |
int DnaStrGui::oldRequestedHeight [private] |
int DnaStrGui::oldRequestedWidth [private] |
int DnaStrGui::currentDescent [private] |