#include <featuregui.h>
Inheritance diagram for ChromatGui:
Public Member Functions | |
ChromatGui (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 | |
ChromatData * | chromatData () |
Definition at line 108 of file featuregui.h.
ChromatGui::ChromatGui | ( | SpatialFeatureData * | data | ) |
void ChromatGui::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 168 of file featuregui.cpp.
References ChromatData::cagt_vec, chromatData(), QPainter::drawPolyline(), FeatureData::endPos(), ChromatData::gap_vec, QPainter::pen(), ChromatData::phd_vec, QBrush::setColor(), QPainter::setPen(), QPointArray::setPoint(), QBrush::setStyle(), TrapperVector< T >::size(), FeatureData::startPos(), and TrapperVector< T >::stlVector().
00170 { 00171 00172 00173 00174 QString str; 00175 QBrush brush; 00176 brush.setStyle( Qt::SolidPattern ); 00177 brush.setColor( Qt::red ); 00178 00179 00180 // int numPoints = ( x2_dna - x1_dna +1)*2 ; 00181 int num_tot = chromatData()->cagt_vec[0].stlVector().size(); 00182 int length = chromatData()->endPos() - chromatData()->startPos(); 00183 00184 int points_per_dna = num_tot/length; 00185 00186 size_t numPoints = points_per_dna*( x2_dna - x1_dna +1); 00187 00188 00189 //Shift calc 00190 if ( x2_dna > chromatData()->endPos() || x1_dna < chromatData()->startPos()) { 00191 // cerr<<"*************** STRANGE "<<endl; 00192 cerr<<"Out of bounds error"<<endl; 00193 return; 00194 } 00195 int shift = 0; 00196 if ( chromatData()->phd_vec.size() > 0 && 00197 chromatData()->gap_vec.size() > 0) { 00198 00199 //Recalc shift 00200 00201 00202 00203 if ( center > 0 && center < chromatData()->endPos()) { 00204 int shift_dna = chromatData()->gap_vec.stlVector()[ center ]; 00205 if ( center >= shift_dna ) { 00206 //Should always be true unless we have end gaps which should be impossible... 00207 int phd_index = chromatData()->phd_vec.stlVector()[center - shift_dna ]; 00208 shift = center*points_per_dna + points_per_dna/2 - phd_index; 00209 } 00210 } 00211 } 00212 00213 00214 00215 double height_scale = double(height)/double(1600); 00216 00217 QPointArray c( numPoints ); 00218 QPointArray a( numPoints ); 00219 QPointArray g( numPoints ); 00220 QPointArray t( numPoints ); 00221 00222 for( size_t i = 0; i < numPoints; i++ ) { 00223 int index = i + points_per_dna*x1_dna; 00224 00225 index -= shift; 00226 if ( index < 0 ) index = 0; 00227 // if ( index > chromatData()->cagt_vec[0].size() - 1 ) index = index > chromatData()->cagt_vec[0].size() - 1; 00228 if ( static_cast<size_t>(index) > chromatData()->cagt_vec[0].size() - 1 ) index = chromatData()->cagt_vec[0].size() - 1; 00229 00230 // g.setPoint(i, i* width/points_per_dna + x_pix, y_pix + height - chromatData()->cagt_vec[0].stlVector()[index]*height_scale); 00231 // a.setPoint(i, i* width/points_per_dna + x_pix, y_pix + height - chromatData()->cagt_vec[1].stlVector()[index]*height_scale); 00232 // t.setPoint(i, i* width/points_per_dna + x_pix, y_pix + height - chromatData()->cagt_vec[2].stlVector()[index]*height_scale); 00233 // c.setPoint(i, i* width/points_per_dna + x_pix, y_pix + height - chromatData()->cagt_vec[3].stlVector()[index]*height_scale); 00234 c.setPoint(i, static_cast<int>(i* width/points_per_dna + x_pix), static_cast<int>(y_pix + height - chromatData()->cagt_vec[0].stlVector()[index]*height_scale)); 00235 a.setPoint(i, static_cast<int>(i* width/points_per_dna + x_pix), static_cast<int>(y_pix + height - chromatData()->cagt_vec[1].stlVector()[index]*height_scale)); 00236 g.setPoint(i, static_cast<int>(i* width/points_per_dna + x_pix), static_cast<int>(y_pix + height - chromatData()->cagt_vec[2].stlVector()[index]*height_scale)); 00237 t.setPoint(i, static_cast<int>(i* width/points_per_dna + x_pix), static_cast<int>(y_pix + height - chromatData()->cagt_vec[3].stlVector()[index]*height_scale)); 00238 } 00239 /* 00240 C = cyan 00241 A = green 00242 G = magenta 00243 T = red 00244 */ 00245 /* 00246 normal: 00247 C = red 00248 A = green 00249 G = cyan 00250 T = magenta 00251 */ 00252 /* 00253 reverse: 00254 C = magenta 00255 A = cyan 00256 G = green 00257 T = red 00258 */ 00259 QPen origpen(p->pen()); 00260 00261 p->setPen(QPen(Qt::cyan)); 00262 p->drawPolyline(c); 00263 p->setPen(QPen(Qt::green)); 00264 p->drawPolyline(a); 00265 p->setPen(QPen(Qt::magenta)); 00266 p->drawPolyline(g); 00267 p->setPen(QPen(Qt::red)); 00268 p->drawPolyline(t); 00269 00270 p->setPen(origpen); 00271 return; 00272 }
ChromatData * ChromatGui::chromatData | ( | ) | [private] |
Definition at line 163 of file featuregui.cpp.
References FeatureGui::m_data.
Referenced by paintMe().
00164 { 00165 return dynamic_cast<ChromatData *>( m_data ); 00166 }