Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | File List | Namespace Members | Class Members | File Members

ChromatGui Class Reference

The visual appearance of a ChromatData. More...

#include <featuregui.h>

Inheritance diagram for ChromatGui:

Inheritance graph
[legend]
Collaboration diagram for ChromatGui:

Collaboration graph
[legend]
List of all members.

Public Member Functions

 ChromatGui (FeatureData *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

ChromatDatachromatData ()

Detailed Description

The visual appearance of a ChromatData.

Definition at line 106 of file featuregui.h.


Constructor & Destructor Documentation

ChromatGui::ChromatGui FeatureData data  ) 
 

Definition at line 157 of file featuregui.cpp.

00157                                          : FeatureGui( data )
00158 {
00159   
00160 }


Member Function Documentation

ChromatData * ChromatGui::chromatData  )  [private]
 

Definition at line 162 of file featuregui.cpp.

References FeatureGui::m_data.

Referenced by paintMe().

00163 {
00164     return dynamic_cast<ChromatData *>( m_data );
00165 }

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.

Parameters:
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 167 of file featuregui.cpp.

References ChromatData::cagt_vec, chromatData(), FeatureData::endPos(), ChromatData::gap_vec, ChromatData::phd_vec, TrapperVector< T >::size(), FeatureData::startPos(), and TrapperVector< T >::stlVector().

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


The documentation for this class was generated from the following files:
Generated on Fri Mar 17 17:44:57 2006 for trapper by  doxygen 1.4.4