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

TrapperView Class Reference

The view to graphically present the reads and their features. The user will mainly interact with this window. More...

#include <trapperview.h>

Collaboration diagram for TrapperView:

Collaboration graph
[legend]
List of all members.

Public Slots

void slotSwitchToMode (int i)
void slotStartAlgo (int i)
void slotScrollToMouse ()
void slotScrollToPos ()
void slotSetCenter ()
void slotClearCenter ()

Signals

void createView (QString)
void message (const QString &)

Public Member Functions

 TrapperView (TrapperDoc *pDoc, QWidget *parent, const char *name, QString _viewMode=QString("everything"))
 ~TrapperView ()
TrapperDocgetDocument () const
void update (TrapperView *pSender)
void print (QPrinter *pPrinter)
QString mode ()
void zoomIn ()
void zoomInX ()
void zoomInY ()
void zoomOut ()
void zoomOutX ()
void zoomOutY ()
void selectAll ()
void selectBetween ()
void findRead ()
void enlarge ()
void shrink ()
void setDragMode (bool status)
void copy ()
void paste ()
void cut ()
void undo ()
TR_DNA mousePressedRow ()
TR_DNA mousePressedCol ()
void sendMsg (const QString &msg)

Protected Types

typedef std::set< db_recno_t > RecnoMap

Protected Member Functions

void contentsDragEnterEvent (QDragEnterEvent *event)
void contentsDropEvent (QDropEvent *event)
void contentsMouseMoveEvent (QMouseEvent *e)
void contentsMouseReleaseEvent (QMouseEvent *e)
void contentsContextMenuEvent (QContextMenuEvent *e)
void contentsMousePressEvent (QMouseEvent *e)
void contentsDragMoveEvent (QDragMoveEvent *)
virtual void closeEvent (QCloseEvent *)
void doZoom ()
void scrollTo (TR_PIX x, TR_PIX y)
void drawContents (QPainter *p, TR_PIX cx, TR_PIX cy, TR_PIX cw, TR_PIX ch)
void drawContents_helper (QPainter *p, QPainter *bitmapPainter, int cx, int cy, int cw, int ch, int dx, int dy)
 paint a rectangle of the window
void paintFeatures (QPainter *p, QPainter *bitmapPainter, db_recno_t readRecno, TR_PIX x_pix, TR_PIX y_pix, TR_DNA x_dna_relative, TR_DNA dna_len, double width, TR_PIX height, bool selected, int center_relative, bool overlap, TR_DNA bg, TR_DNA eg)
 paint border line around the read rectangle. Then divide the rectangle into layers and paint features of the read into these layers.
void paintGrid (QPainter *p, TR_PIX cx, TR_PIX cy, TR_PIX cw, TR_PIX ch)
 paint some extra dots in the background of the window. These will move along when the user scrolls. Nice to have some visual feedback of movement when there are no reads in the window
void convertToPixelCoordinates (TR_PIX &x_pix, TR_PIX &y_pix, TR_DNA x_dna, TR_DNA y_dna)
void convertToDnaCoordinates (TR_DNA &x_dna, TR_DNA &y_dna, const TR_PIX cx, const TR_PIX cy)
TR_PIX dnaCoordToPixel_X (TR_DNA cx)
TR_PIX dnaCoordToPixel_Y (TR_DNA cy)
TR_DNA pixelCoordToDna_X (TR_PIX x_dna)
TR_DNA pixelCoordToDna_Y (TR_PIX y_dna)
std::set< db_recno_t > & getSelectedReads ()
void select (db_recno_t recno, bool status)
bool isSelected (db_recno_t recno)
void clearSelected ()
std::vector< std::list< std::string > > getInfo (const QPoint &pos)
void runAlgo (const std::string &AlgoType, std::set< db_recno_t > &recnoList, AlgoParam *param=0)
void writeSelected (QDataStream &data_stream)
void readSelected (QDataStream &data_stream)
void moveData (TR_PIX dx, TR_PIX dy)
void fitContentsizeToData ()
void clearLastMove ()

Protected Attributes

TR_PIX basewidth
TR_PIX spaceBetweenRows
TR_PIX rowheight
TR_DNA globalRows
TR_DNA globalBases
TR_DNA center_point
TrapperDocdoc
QLabel * lab
double magnifyX
u_int16_t magnifyY
int zoomfactor
ViewModesviewModes
QPopupMenu * switchViewMenu
QPopupMenu * algoMenu
QPopupMenu * infoMenu
std::set< db_recno_t > selectedReads
std::map< std::string, int > zoom_cutoff
ReadsInRectreadsInRect
bool dragging
bool allow_dragging
bool moving
bool last_click_selected_read
bool last_click_changed_selection
db_recno_t last_selected_recno
QPoint curr_mouse_pos
TR_PIX y_delta
TR_PIX y_delta_previous
TR_DNA last_move_x
TR_DNA last_move_y

Private Member Functions

void drawRubber (QPainter *p)

Private Attributes

QPixmap dragPixmap
QBitmap dragBitmap
QPainter p3
QPoint mousePressedPoint
QPoint dragWindowPoint
QRect * rubber_band
QPoint RubberStart
QPoint RubberEnd
bool RubberOn
QPoint oldMovePoint
bool moveOn

Friends

class TrapperDoc

Detailed Description

The view to graphically present the reads and their features. The user will mainly interact with this window.

Functionality given to the user: Scrolling, zooming, drag and drop of the reads to move them around, selecting reads and start algorithms.

This software is designed to have totally decoupled view and data classes. The view is stateless ( it does not store any data ) and will for every update newly read in all data needed to paint up the view. In other words, the view does not cash anything.

This has some nice implications: Data algorithm classes will work directly with the data classes and will not be aware of any views. Any number of views can be opened up and they will be independent and will not be aware of each other.

For it to be possible to take this design approach the data classes must respond quickly to queries because any delay here will make the views appear sluggish. Scrolling will here be the toughest test for the speed of the data class queries. Because by scrolling, new data should be painted very fast to the view. The user would not like big delays here.

To make the data class queries very fast, the data is stored in the embedded database Berkeley Db.

About how the reads and features get shown in TrapperView: TrapperView is inherited from QScrollView. QScrollView gives us the scroll bars and also gives convertion methods between the coordinate system of the actual window ( the viewport ) and the coordinate system of the content window ( the big window the user has to scroll to see all of it ). QScrollView gives us the possibility to place out "static" widgets on the content window, and QScrollView would then handle the scrolling automatically. But we would like a totally stateless view so we take another approach. We reimplement the virtual method drawContents() that is called everytime some part of the window should be painted, e.g. when the user has dragged the scrollbars. The method drawContents() takes as arguments the "content" pixel coordinates of a rectangle to be painted. Some background pixels are painted to enhance the "movement feeling" when scrolling. Then drawContents_helper() is called ( which is also is reused when painting reads in a drag & drop ). In drawContents_helper() we first convert to DNA coordinates, i.e. the x-axis unit is a nucleotid-base and the y-axis unit is a row. We then use the class ReadsInRect that can tell us which reads are visible in our painting rectangle. Now paintFeatures() is called for each read. In paintFeatures(), features for the read are painted in different layers inside the read rectangle.

Definition at line 115 of file trapperview.h.


Member Typedef Documentation

typedef std::set<db_recno_t> TrapperView::RecnoMap [protected]
 

Definition at line 280 of file trapperview.h.


Constructor & Destructor Documentation

TrapperView::TrapperView TrapperDoc pDoc,
QWidget *  parent,
const char *  name,
QString  _viewMode = QString("everything")
 

Constructor for the view

Parameters:
pDoc your document instance that the view represents. Create a document before calling the constructor or connect an already existing document to a new MDI child widget.

Definition at line 71 of file trapperview.cpp.

References allow_dragging, basewidth, center_point, doc, dragging, fitContentsizeToData(), globalBases, globalRows, last_click_changed_selection, last_click_selected_read, GeneralMaker::listRegistered(), magnifyX, magnifyY, moving, rowheight, rubber_band, spaceBetweenRows, viewModes, zoom_cutoff, and zoomfactor.

00072   : QScrollView(parent, name,/** wflags**/ WResizeNoErase|WStaticContents|WDestructiveClose/*|WNoAutoErase*/), doc( pDoc )
00073 {
00074 //   cerr << "in TrapperView::TrapperView" << endl;
00075 //   cerr<<"doc: "<<doc<<endl;
00076   viewport()->setAcceptDrops( true );
00077   setDragAutoScroll( true );
00078   allow_dragging = true;
00079   dragging = false;
00080   moving = false;
00081   rubber_band = 0;
00082   last_click_selected_read = false;
00083   last_click_changed_selection = false;
00084   
00085   
00086   if ( _viewMode.isNull() )
00087     {
00088       _viewMode = "closeup";
00089     }
00090 
00091   viewModes = new ViewModes( _viewMode, doc );
00092   
00093   //Ugly business here...
00094   list<string> type_list = GeneralMaker::listRegistered();
00095   for( list<string>::iterator it = type_list.begin(); it != type_list.end(); ++it ) {
00096     zoom_cutoff[ *it ] = 0;
00097   }
00098   zoom_cutoff["DnaStrData"] = 4;
00099   zoom_cutoff["QualityData"] = 4;
00100   zoom_cutoff["ChromatData"] = 8;
00101 
00102 
00103 //   globalRows = 1000;
00104 //   globalBases = 50000;
00105   globalRows = 50;
00106   globalBases = 2000;
00107 //   rowheight = 20;
00108 //   basewidth = 10;
00109   rowheight = 5;
00110   basewidth = 1;
00111   magnifyX = magnifyY = 1;
00112   zoomfactor = 2;
00113   spaceBetweenRows = 0;
00114   center_point = 0;
00115   
00116   fitContentsizeToData();
00117   
00118 
00119   viewport()->setPaletteBackgroundColor(white);
00120   viewport()->setBackgroundMode( Qt::FixedColor );
00121   setCaption( "yes" );
00122   viewport()->setMouseTracking(TRUE);
00123 }

TrapperView::~TrapperView  ) 
 

Destructor for the main view

Definition at line 126 of file trapperview.cpp.

References viewModes.

00127 {
00128  
00129   if ( viewModes ) {
00130     delete viewModes;
00131     viewModes = NULL;
00132   }
00133 }


Member Function Documentation

void TrapperView::clearLastMove  )  [protected]
 

Definition at line 566 of file trapperview.cpp.

References last_move_x, and last_move_y.

Referenced by clearSelected(), readSelected(), select(), and slotStartAlgo().

00567 {
00568   last_move_x = last_move_y = 0;
00569 }

void TrapperView::clearSelected  )  [protected]
 

Definition at line 1139 of file trapperview.cpp.

References clearLastMove(), and selectedReads.

Referenced by contentsMousePressEvent(), contentsMouseReleaseEvent(), cut(), findRead(), readSelected(), selectAll(), and selectBetween().

01140 {
01141   selectedReads.clear();
01142   clearLastMove();
01143 }

void TrapperView::closeEvent QCloseEvent *   )  [protected, virtual]
 

Definition at line 190 of file trapperview.cpp.

00191 {
00192     // LEAVE THIS EMPTY: THE EVENT FILTER IN THE TrapperApp CLASS TAKES CARE FOR CLOSING
00193     // QWidget closeEvent must be prevented.
00194 }

void TrapperView::contentsContextMenuEvent QContextMenuEvent *  e  )  [protected]
 

Definition at line 907 of file trapperview.cpp.

References algoMenu, AlgoMaker::algosRegistered(), getInfo(), infoMenu, TrapperConf::instance(), last_click_changed_selection, last_click_selected_read, moving, slotClearCenter(), slotScrollToMouse(), slotScrollToPos(), slotSetCenter(), slotStartAlgo(), slotSwitchToMode(), switchViewMenu, and TrapperConf::viewModeNames().

00908 {
00909   if ( last_click_changed_selection ) {
00910     updateContents();
00911   }
00912   moving = false;
00913   last_click_selected_read = false;
00914   last_click_changed_selection = false;
00915   
00916   QPopupMenu* contextMenu = new QPopupMenu( this );
00917   Q_CHECK_PTR( contextMenu );
00918   QLabel *caption = new QLabel( "<font color=darkblue><u><b>"
00919                                 "Context Menu</b></u></font>", this );
00920   caption->setAlignment( Qt::AlignCenter );
00921   contextMenu->insertItem( caption );
00922   
00923 
00924   
00925 
00926   //Algo stuff
00927   algoMenu = new QPopupMenu( this );
00928   Q_CHECK_PTR( algoMenu );
00929   list<string> algos = AlgoMaker::algosRegistered();
00930   list<string>::iterator stIt;
00931   
00932   for (stIt = algos.begin() ; stIt != algos.end(); ++stIt )
00933     {
00934       algoMenu->insertItem (  stIt->c_str()  );
00935     }
00936   connect( algoMenu, SIGNAL( activated( int ) ),
00937            this, SLOT( slotStartAlgo( int ) ) );
00938   contextMenu->insertItem( "&Operations", algoMenu );
00939   
00940 
00941 
00942   //Info stuff
00943   infoMenu = new QPopupMenu(this);
00944 
00945   vector<list<string> > infos = getInfo( e->pos() );
00946   QPtrList<QPopupMenu> infolist;
00947   infolist.setAutoDelete( true );
00948   
00949   for( size_t i = 0; i < infos.size(); i++ ) {
00950     stIt = infos[i].begin();
00951     if ( stIt == infos[i].end() ) continue;
00952     infolist.append(new QPopupMenu(this));
00953     ++stIt;
00954 
00955     for ( ; stIt != infos[i].end(); ++stIt ) {
00956 //       infoMenu->insertItem (  stIt->c_str()  );
00957 
00958       infolist.last()->insertItem (  stIt->c_str()  );
00959     }
00960 
00961     
00962     infoMenu->insertItem(infos[i].begin()->c_str(), infolist.last());
00963   }
00964 
00965   //No connecting here, 'cause only info...
00966   contextMenu->insertItem( "&Info", infoMenu );
00967 
00968 
00969   //Viewmode stuff
00970   switchViewMenu = new QPopupMenu( this );
00971   Q_CHECK_PTR( switchViewMenu );
00972   TrapperConf * conf = TrapperConf::instance();
00973   QStringList names = conf->viewModeNames();
00974   
00975   QStringList::Iterator it = names.begin();
00976   for ( ; it != names.end(); ++it )
00977     {
00978       switchViewMenu->insertItem ( *it );
00979     }
00980   connect( switchViewMenu, SIGNAL( activated( int ) ),
00981            this, SLOT( slotSwitchToMode( int ) ) );
00982   contextMenu->insertItem( "&Switch to viewmode", switchViewMenu );
00983 
00984 
00985   contextMenu->insertSeparator();
00986   contextMenu->insertItem("Set chromat center", this, SLOT(slotSetCenter()));
00987   contextMenu->insertItem("Clear chromat center", this, SLOT(slotClearCenter()));
00988 
00989   contextMenu->insertSeparator();
00990   contextMenu->insertItem("Scroll Here", this, SLOT(slotScrollToMouse()) );
00991   contextMenu->insertItem("Scroll to pos", this, SLOT(slotScrollToPos()) );
00992 
00993   contextMenu->exec( QCursor::pos() );
00994   delete contextMenu;
00995   delete switchViewMenu;//Previous memory leak??
00996   delete algoMenu;
00997   delete infoMenu;
00998 }

void TrapperView::contentsDragEnterEvent QDragEnterEvent *  event  )  [protected]
 

Definition at line 1448 of file trapperview.cpp.

01449 {
01450 //   cerr << "in TrapperView::dragEnterEvent" << endl;
01451   event->accept(
01452                 TRUE
01453                 );
01454 }

void TrapperView::contentsDragMoveEvent QDragMoveEvent *   )  [protected]
 

Definition at line 1456 of file trapperview.cpp.

01457 {
01458   
01459 //   e->setPoint( QPoint( mousePressedPoint.x(), e->pos().y() ) );
01460 
01461 //   cerr << "in TrapperView::dragMoveEvent" << endl;  
01462 //   cerr<<"x(): "<<e->pos().x()<<endl;
01463 //   cerr<<"y(): "<<e->pos().y()<<endl;
01464  
01465 }

void TrapperView::contentsDropEvent QDropEvent *  event  )  [protected]
 

Definition at line 1467 of file trapperview.cpp.

References convertToDnaCoordinates(), getDocument(), mousePressedPoint, moveData(), readSelected(), and TR_DNA.

01468 {
01469 //   cerr << "in TrapperView::dropEvent" << endl;
01470 
01471  QPoint deltaMovement = event->pos() - mousePressedPoint;
01472  TR_DNA x_dna_movDelta;
01473  TR_DNA y_dna_movDelta;
01474 
01475  convertToDnaCoordinates( x_dna_movDelta, y_dna_movDelta, deltaMovement.x(), deltaMovement.y() );
01476 //  cerr << "dropped happened with delta x=" << x_dna_movDelta << " y=" << y_dna_movDelta << endl; 
01477  
01478  TrapperView* w = dynamic_cast<TrapperView*>( event->source() );
01479 
01480  if ( !w) {
01481    //Drop from another app...
01482    return;
01483  }
01484  
01485 
01486  assert(w);
01487  
01488  if ( w->getDocument() == this->getDocument() ) {
01489 
01490    moveData( deltaMovement.x(), deltaMovement.y() );
01491  }
01492  else {
01493    QByteArray ar( event->encodedData("min_mime_type") );
01494    QDataStream data_stream(ar, IO_ReadOnly);
01495    
01496    readSelected(data_stream);
01497    updateContents();
01498  }
01499  
01500 
01501 }

void TrapperView::contentsMouseMoveEvent QMouseEvent *  e  )  [protected]
 

Definition at line 720 of file trapperview.cpp.

References allow_dragging, curr_mouse_pos, dragging, dragPixmap, dragWindowPoint, drawContents_helper(), drawRubber(), last_click_selected_read, mousePressedPoint, moving, pixelCoordToDna_X(), pixelCoordToDna_Y(), rubber_band, RubberEnd, RubberOn, sendMsg(), writeSelected(), y_delta, and y_delta_previous.

00721 {
00722   QString msg = "Row: " + QString().setNum(pixelCoordToDna_Y(e->y())) + ", col: " + QString().setNum(pixelCoordToDna_X(e->x()));
00723   sendMsg( msg );
00724 
00725   bool nobutton = Qt::NoButton & e->state();
00726 
00727   if ( nobutton ) {
00728     moving = false;
00729     return;
00730   }
00731   
00732 
00733   if ( allow_dragging && dragging ) {
00734 //   if ( dragging ) {
00735 //     cerr<<"Dragging..."<<endl;
00736 
00737     ReadDrag *d = new ReadDrag( dragPixmap, dragWindowPoint, this );
00738 //     QCString ar("hej");
00739     QByteArray ar;
00740     QDataStream data_stream(ar, IO_WriteOnly);
00741     writeSelected(data_stream);
00742 
00743     d->setEncodedData(ar);
00744     d->dragCopy(); // do NOT delete d.
00745     dragging = FALSE;
00746     moving = false;
00747     last_click_selected_read = false;
00748 //     cerr<<"Stopped dragging"<<endl;
00749   }
00750   else if ( last_click_selected_read ) {
00751 //   else if ( !selectedReads.empty() ) {
00752     //"Normal" moving
00753     moving = true;
00754     
00755     curr_mouse_pos = e->pos();//Don't really need this??
00756 //     y_delta = pixelCoordToDna_Y( (curr_mouse_pos - mousePressedPoint).y() );
00757     y_delta = (curr_mouse_pos - mousePressedPoint).y();
00758 
00759     if ( pixelCoordToDna_Y( y_delta) == pixelCoordToDna_Y( y_delta_previous ) ) {
00760 //       moving = false;
00761       return;
00762     }
00763     
00764     y_delta_previous = y_delta;
00765 
00766     //MOVINGTEST
00767 
00768     QPainter p(viewport());
00769     drawContents_helper(&p, 0,0,0,0,0,0,0);
00770     return;
00771     //END MOVINGTEST
00772     
00773     updateContents();
00774   }
00775   else if ( rubber_band != 0 ) {
00776 
00777     //RUBBERTEST
00778     QPainter p(viewport());
00779     p.setPen(QColor(255,255,255));
00780     p.setRasterOp(NotROP);
00781     if(RubberOn) drawRubber(&p);
00782     RubberEnd= contentsToViewport(e->pos());
00783     drawRubber(&p);
00784     RubberOn=TRUE;
00785     return;
00786     //END RUBBERTEST
00787     
00788     curr_mouse_pos = e->pos();
00789     
00790     QRect oldband = rubber_band->normalize();
00791 
00792     rubber_band->setSize( QSize( curr_mouse_pos.x() - mousePressedPoint.x(),
00793                                  curr_mouse_pos.y() - mousePressedPoint.y() ) );
00794     
00795 //     updateContents();
00796     QPoint margin( 1, 1 );
00797     QRect norm = rubber_band->normalize();
00798     
00799     updateContents( QRect( norm.topLeft() - margin, norm.bottomRight() + margin ).unite( QRect(oldband.topLeft() - margin, oldband.bottomRight() + margin ) ) );
00800   }
00801   
00802 }

void TrapperView::contentsMousePressEvent QMouseEvent *  e  )  [protected]
 

Definition at line 572 of file trapperview.cpp.

References clearSelected(), convertToDnaCoordinates(), doc, dragBitmap, dragging, dragPixmap, dragWindowPoint, drawContents_helper(), ReadsInRect::first(), GeneralData::getRecno(), isSelected(), last_click_changed_selection, last_click_selected_read, last_selected_recno, mousePressedPoint, moveOn, moving, p3, pixelCoordToDna_X(), pixelCoordToDna_Y(), readsInRect, rubber_band, RubberEnd, RubberOn, RubberStart, select(), selectedReads, sendMsg(), ReadsInRect::setWindowCoord(), TR_DNA, y_delta, and y_delta_previous.

00573 {
00574   QString msg = "Row: " + QString().setNum(pixelCoordToDna_Y(e->y())) + ", col: " + QString().setNum(pixelCoordToDna_X(e->x()));
00575   sendMsg( msg );
00576 
00577   y_delta = 0;
00578   y_delta_previous = 0;
00579   
00580   bool ctrlclick = Qt::ControlButton & e->state();
00581   bool leftbutton = Qt::LeftButton & e->stateAfter();
00582 
00583 //   if ( ctrlclick )
00584 //     cerr<<"ctrlclick!!!!!!!!!!!!!! "<<endl;
00585   
00586   
00587   mousePressedPoint.setX( e->x() );
00588   mousePressedPoint.setY( e->y() );
00589 
00590   
00591   //RUBBERTEST
00592   RubberStart=contentsToViewport(e->pos());
00593   RubberEnd = RubberStart;
00594   RubberOn=FALSE;
00595   //END RUBBERTEST
00596 
00597   //MOVINGTEST
00598   moveOn = false;
00599   //END MOVINGTEST
00600 
00601   TR_DNA x_dna, y_dna;
00602   convertToDnaCoordinates( x_dna, y_dna, e->x(), e->y() );
00603   
00604   readsInRect = new ReadsInRect( doc );
00605 //   readsInRect->setWindowCoord( x_dna, y_dna, 1, 1 );  /* a rectangle with dimension 1x1 */
00606   readsInRect->setWindowCoord( x_dna, y_dna, 3, 3 );  /* a rectangle with dimension 3x3 */
00607   ReadData * r = readsInRect->first(); 
00608   if ( r ) {//hit read
00609     if ( ctrlclick ) {
00610       if ( isSelected( r->getRecno() ) ) {
00611         select( r->getRecno(), false );
00612         last_click_selected_read = false;
00613         last_click_changed_selection = true;
00614       }
00615       else {
00616         select( r->getRecno(), true);
00617         last_click_selected_read = true;
00618         last_selected_recno = r->getRecno();
00619         last_click_changed_selection = true;
00620       }
00621     }//end ctrlclick
00622     else {//no ctrlclick
00623       if ( isSelected( r->getRecno() ) ) {
00624         last_click_selected_read = true;
00625         last_selected_recno = r->getRecno();
00626         last_click_changed_selection = false;
00627       }
00628       else {
00629         clearSelected();
00630         select( r->getRecno(), true);       
00631         last_click_selected_read = true;        
00632         last_selected_recno = r->getRecno();
00633         last_click_changed_selection = true;
00634       }
00635       
00636     }//end no ctrlclick
00637     if ( last_click_selected_read )
00638       dragging = TRUE; 
00639   }// end hit read
00640   else {//didn't hit read
00641 //     if ( rubber_band != 0 ) {
00642 //       delete rubber_band;
00643 //     }
00644 //     rubber_band = new QRect( mousePressedPoint, mousePressedPoint );
00645     if ( ctrlclick ) {
00646       last_click_selected_read = false;
00647       last_click_changed_selection = false;
00648     }//end ctrlclick
00649     else {//no ctrlclick
00650       last_click_selected_read = false;
00651       if ( selectedReads.size() > 0 )
00652         last_click_changed_selection = true;
00653         
00654       clearSelected();
00655 
00656       //"Rubber band"
00657 //       if ( rubber_band != 0 ) {
00658 //         delete rubber_band;
00659 //       }
00660 //       if ( leftbutton )
00661 //         rubber_band = new QRect( mousePressedPoint, mousePressedPoint );
00662       
00663       
00664     }//end no ctrlclick
00665     if ( rubber_band != 0 ) {
00666       delete rubber_band;
00667     }
00668     if (leftbutton && !last_click_selected_read) {
00669       moving = false;
00670       rubber_band = new QRect( mousePressedPoint, mousePressedPoint );
00671     }
00672     
00673   }//end didn't hit read
00674 
00675 //   updateContents();//Removed this because of visual bug...
00676   delete readsInRect;
00677   
00678   // From here on: about Start a drag and painting
00679   {
00680     dragWindowPoint.setX( size().width()      );
00681     dragWindowPoint.setY( size().height() );
00682     QRect re( mousePressedPoint - dragWindowPoint, mousePressedPoint + dragWindowPoint );
00683     
00684     
00685     dragPixmap.resize( re.size() );
00686     QPainter p2;
00687     p2.begin(&dragPixmap, this);
00688     dragBitmap.resize( re.size()  );
00689     p3.begin(&dragBitmap, this);
00690     QBrush brush;
00691     brush.setStyle( Qt::SolidPattern );
00692     brush.setColor( Qt::white );
00693     p2.fillRect( 0  , 0 , re.width() , re.height() ,brush) ;
00694     brush.setColor( Qt::color0 );
00695     
00696     p3.fillRect( 0  , 0 , re.width() , re.height() ,brush) ;
00697     
00698     QPoint tl = re.topLeft() ;
00699     QPoint br = re.bottomRight() ;
00700     
00701     drawContents_helper(&p2, &p3, tl.x(), tl.y(), br.x() - tl.x() + 1, br.y() - tl.y() + 1, 
00702                         - ( mousePressedPoint.x() - dragWindowPoint.x() ),  - ( mousePressedPoint.y() - dragWindowPoint.y() ));
00703     
00704     //Test:
00705 //     QPen a_pen;
00706 //     p2.setPen(a_pen);
00707 //     p2.drawRect(dragPixmap.rect());
00708 //     a_pen.setColor(Qt::color1);
00709 //     p3.setPen(a_pen);
00710 //     p3.drawRect(dragPixmap.rect());
00711     //End test
00712     dragPixmap.setMask(dragBitmap);
00713 
00714     p2.end();
00715     p3.end();
00716   }
00717 }

void TrapperView::contentsMouseReleaseEvent QMouseEvent *  e  )  [protected]
 

Definition at line 804 of file trapperview.cpp.

References clearSelected(), convertToDnaCoordinates(), doc, dragging, drawRubber(), ReadsInRect::first(), last_click_changed_selection, last_click_selected_read, last_selected_recno, moveData(), moveOn, moving, ReadsInRect::next(), readsInRect, rubber_band, RubberEnd, RubberOn, RubberStart, select(), ReadsInRect::setWindowCoord(), TR_DNA, TR_PIX, and y_delta.

00805 {
00806   dragging = false;
00807   //Maybe dragging code here? NO!
00808   
00809   if ( moving ) {
00810     //Moving stuff...
00811     moveData(0, y_delta);
00812 
00813     
00814 
00815     //MOVINGTEST
00816     if(moveOn) 
00817       {
00818         updateContents();
00819         moveOn=FALSE;
00820       }    
00821     //END MOVINGTEST
00822 
00823     moving = false;
00824   }
00825   else { //not moving
00826     
00827     bool ctrlclick = Qt::ControlButton & e->state();
00828 
00829     if ( !ctrlclick && last_click_selected_read ) {
00830       clearSelected();
00831       select( last_selected_recno, true );
00832       last_click_changed_selection = true;
00833 //       updateContents();
00834     }
00835     if ( last_click_changed_selection ) {
00836       updateContents();
00837     }
00838     
00839 
00840     if ( rubber_band != 0 ) {
00841       
00842       readsInRect = new ReadsInRect( doc );
00843       
00844       TR_DNA x_dna, y_dna, w_dna, h_dna, x2_dna, y2_dna;
00845       TR_PIX x_pix, y_pix, w_pix, h_pix;
00846       
00847       QRect norm = rubber_band->normalize();
00848       //RUBBERTEST
00849       RubberStart = viewportToContents( RubberStart );
00850       RubberEnd = viewportToContents( RubberEnd );
00851       
00852       norm = QRect(
00853                 RubberStart.x(),
00854                 RubberStart.y(),
00855                 RubberEnd.x()-RubberStart.x(),
00856                 RubberEnd.y()-RubberStart.y()
00857                 ).normalize();
00858       //END RUBBERTEST
00859 
00860       rubber_band->setTopLeft( norm.topLeft() );      
00861       rubber_band->setBottomRight( norm.bottomRight() );      
00862 
00863       rubber_band->rect( &x_pix, &y_pix, &w_pix, &h_pix);
00864       convertToDnaCoordinates( x_dna, y_dna, x_pix, y_pix );
00865       convertToDnaCoordinates( x2_dna, y2_dna, x_pix + w_pix, y_pix + h_pix);
00866       
00867       w_dna = x2_dna - x_dna;
00868       h_dna = y2_dna - y_dna;
00869 
00870 
00871       readsInRect->setWindowCoord( x_dna, y_dna,  w_dna,h_dna );
00872       if ( !ctrlclick) 
00873         clearSelected();
00874       
00875       for ( ReadData * r = readsInRect->first(); r; r = readsInRect->next() ) {
00876         select( r->getRecno(), true);
00877       }
00878       //RUBBERTEST
00879       QPainter p(viewport());
00880       p.setPen(QColor(255,255,255));
00881       p.setRasterOp(NotROP);
00882       if(RubberOn) 
00883         {
00884           drawRubber(&p);
00885           RubberOn=FALSE;
00886         }
00887       else
00888         {
00889           RubberEnd=RubberStart;
00890         }
00891       //END RUBBERTEST
00892       
00893       delete rubber_band;
00894       rubber_band = 0;
00895       delete readsInRect;
00896       updateContents();
00897     }
00898 
00899   }
00900   moving = false;
00901   dragging = false;
00902   last_click_changed_selection = false;
00903   last_click_selected_read = false;
00904   
00905 }

void TrapperView::convertToDnaCoordinates TR_DNA &  x_dna,
TR_DNA &  y_dna,
const TR_PIX  cx,
const TR_PIX  cy
[protected]
 

Definition at line 196 of file trapperview.cpp.

References pixelCoordToDna_X(), and pixelCoordToDna_Y().

Referenced by contentsDropEvent(), contentsMousePressEvent(), contentsMouseReleaseEvent(), and drawContents_helper().

00197 {
00198     x_dna = pixelCoordToDna_X(cx);
00199     y_dna = pixelCoordToDna_Y(cy);
00200     return;
00201 }

void TrapperView::convertToPixelCoordinates TR_PIX &  x_pix,
TR_PIX &  y_pix,
TR_DNA  x_dna,
TR_DNA  y_dna
[protected]
 

Definition at line 219 of file trapperview.cpp.

References dnaCoordToPixel_X(), and dnaCoordToPixel_Y().

Referenced by drawContents_helper().

00220 {
00221     x_pix = dnaCoordToPixel_X(x_dna);
00222     y_pix = dnaCoordToPixel_Y(y_dna);
00223     return;
00224 }

void TrapperView::copy  ) 
 

copies selected data

Definition at line 1636 of file trapperview.cpp.

References writeSelected().

Referenced by cut(), and TrapperApp::slotEditCopy().

01637 {
01638   QByteArray ar;
01639   QDataStream str(ar, IO_WriteOnly);
01640   
01641   writeSelected(str);
01642   QClipboard* cb = QApplication::clipboard();
01643   ReadDrag* r = new ReadDrag(this);
01644   r->setEncodedData(ar);
01645   cb->setData(r, QClipboard::Clipboard);
01646   
01647 }

void TrapperView::createView QString   )  [signal]
 

void TrapperView::cut  ) 
 

cuts selected data

Definition at line 1662 of file trapperview.cpp.

References clearSelected(), copy(), Destroyer::destroy(), doc, and selectedReads.

Referenced by TrapperApp::slotEditCut().

01663 {
01664   copy();
01665   Destroyer d(doc);
01666   for( set<db_recno_t>::iterator it = selectedReads.begin(); it != selectedReads.end(); ++it ) {
01667     d.destroy(*it);
01668   }
01669   clearSelected();
01670   updateContents();
01671   
01672 }

TR_PIX TrapperView::dnaCoordToPixel_X TR_DNA  cx  )  [protected]
 

Definition at line 226 of file trapperview.cpp.

References basewidth, and magnifyX.

Referenced by convertToPixelCoordinates(), findRead(), paintGrid(), readSelected(), slotScrollToPos(), and undo().

00227 {
00228 //   if ( x_dna * basewidth * magnifyX < 1 ) {
00229 //     cerr<<"x_dna: "<<x_dna<<endl;
00230 //     cerr<<"basewidth: "<<basewidth<<endl;
00231 //     cerr<<"x_dna * basewidth * magnifyX: "<<x_dna * basewidth * magnifyX<<endl;
00232 //   }
00233   
00234 
00235   return x_dna * basewidth * magnifyX;
00236 }

TR_PIX TrapperView::dnaCoordToPixel_Y TR_DNA  cy  )  [protected]
 

Definition at line 238 of file trapperview.cpp.

References magnifyY, and rowheight.

Referenced by convertToPixelCoordinates(), drawContents_helper(), findRead(), paintGrid(), readSelected(), slotScrollToPos(), and undo().

00239 {
00240   return y_dna * rowheight * magnifyY;
00241 }

void TrapperView::doZoom  )  [protected]
 

Definition at line 1339 of file trapperview.cpp.

References basewidth, globalBases, globalRows, magnifyX, magnifyY, and rowheight.

01340 {
01341 //   QPoint p = viewportToContents(viewport()->rect().topLeft());
01342 
01343 //   if ( globalBases * magnifyX * basewidth < 1 ) {
01344 //     cerr<<"globalBases: "<<globalBases<<endl;
01345 //     cerr<<"globalBases * magnifyX * basewidth: "<<globalBases * magnifyX * basewidth<<endl;
01346 //   }
01347   resizeContents(globalBases * magnifyX * basewidth , globalRows * rowheight * magnifyY);
01348   //     QPoint p = viewportToContents(viewport()->rect().center());
01349   //     center( p.x()* factor , p.y()*factor );
01350 //   setContentsPos(p.x()*zoomfactor, p.y()*zoomfactor);
01351 //   setContentsPos(p.x(), p.y());
01352   updateContents();
01353   
01354 }

void TrapperView::drawContents QPainter *  p,
TR_PIX  cx,
TR_PIX  cy,
TR_PIX  cw,
TR_PIX  ch
[protected]
 

Definition at line 373 of file trapperview.cpp.

References drawContents_helper(), and paintGrid().

00374 {
00375 //   QPoint qp = viewportToContents(viewport()->rect().topLeft());
00376 //   cerr<<"qp.x(): "<<qp.x()<<endl;
00377 //   cerr<<"qp.y(): "<<qp.y()<<endl;
00378 
00379   drawContents_helper(p, NULL, cx, cy, cw, ch, 0, 0);
00380   paintGrid( p, cx, cy, cw, ch);
00381 }

void TrapperView::drawContents_helper QPainter *  p,
QPainter *  bitmapPainter,
int  cx,
int  cy,
int  cw,
int  ch,
int  dx,
int  dy
[protected]
 

paint a rectangle of the window

Parameters:
p where to paint to
bmp where to paint a bitmask, we paint to the bitmask on the same places as we paint to p.
cx x coordinate of rectangle in "content" coordinate system
cy y coordinate of rectangle in "content" coordinate system
cw width of rectangle in "content" coordinate system
ch height of rectangle in "content" coordinate system
dx displace painting with this
dy displace painting with this

Definition at line 383 of file trapperview.cpp.

References basewidth, center_point, convertToDnaCoordinates(), convertToPixelCoordinates(), dnaCoordToPixel_Y(), doc, dragPixmap, dragWindowPoint, ReadsInRect::first(), isSelected(), magnifyX, magnifyY, mousePressedPoint, moveOn, moving, ReadsInRect::next(), oldMovePoint, paintFeatures(), pixelCoordToDna_Y(), readsInRect, rowheight, rubber_band, ReadsInRect::setWindowCoord(), spaceBetweenRows, TR_DNA, TR_PIX, and y_delta.

Referenced by contentsMouseMoveEvent(), contentsMousePressEvent(), and drawContents().

00384 {
00385   /* We have the window to paint in pixel coordinates, but the biological data ( the reads ) are stored
00386      in dna coordinates. The pixel coordinates are on a smaler scale than the dna coordinates, so therefore
00387      the pixel coordinates might lay a fraction of a dna coordinate. Thus we seak the minimal overlapping window 
00388      in dna coordinates. */
00389 
00390   if ( moving ) {
00391     assert( bitmapPainter == 0 );
00392     //MOVINGTEST
00393 //     p->setRasterOp(NotROP);
00394     p->setRasterOp(NotXorROP);
00395 //      p->setRasterOp(XorROP);
00396     if ( moveOn ) {
00397       p->drawPixmap(oldMovePoint, dragPixmap);
00398     }
00399     else {
00400       oldMovePoint = contentsToViewport(mousePressedPoint - dragWindowPoint);
00401       p->setRasterOp(NotXorROP);
00402       p->drawPixmap(oldMovePoint, dragPixmap);
00403       
00404     }
00405     
00406 
00407     oldMovePoint = contentsToViewport(mousePressedPoint - dragWindowPoint + QPoint(0, dnaCoordToPixel_Y(pixelCoordToDna_Y(y_delta)) ));
00408     //END MOVINGTEST
00409 //     oldMovePoint = mousePressedPoint - dragWindowPoint + QPoint(0, dnaCoordToPixel_Y(pixelCoordToDna_Y(y_delta)) );
00410     p->drawPixmap(oldMovePoint, dragPixmap);
00411     //MOVINGTEST
00412     moveOn = true;
00413     return;
00414     //END MOVINGTEST
00415   }
00416 
00417   
00418   TR_DNA x_dna, y_dna; /* the dna coordinate of upperleft corner of the overlapping dna window */
00419   TR_DNA x2_dna, y2_dna;
00420   TR_DNA h_dna, w_dna; /* representing the width and height of the overlapping dna window */
00421   
00422   convertToDnaCoordinates( x_dna, y_dna, cx, cy );
00423   convertToDnaCoordinates( x2_dna, y2_dna, cx + cw - 1, cy + ch - 1 );
00424   
00425   /* to be on the safe side that we paint on a rectangle big enough we add some on the edges.
00426      The reason comes from the fact that vertical read border is drawn up on the uttermost pixels
00427      of the feature area. */
00428    x_dna -= 10;
00429    x2_dna += 10;
00430   
00431   w_dna = x2_dna - x_dna + 1;
00432   h_dna = y2_dna - y_dna + 1;
00433   
00434   
00435   
00436   
00437   TR_PIX x_pix, y_pix; /* the pixel coordinate of upperleft corner of the overlapping dna window */
00438   convertToPixelCoordinates( x_pix, y_pix, x_dna, y_dna );
00439   
00440   TR_PIX cx_paint = x_pix + dx;
00441   TR_PIX cy_paint = y_pix + dy;
00442 
00443 
00444   
00445   readsInRect = new ReadsInRect( doc );
00446 
00447 
00448   readsInRect->setWindowCoord( x_dna, y_dna,  w_dna,h_dna );
00449 //   cerr<<"rowheight*magnifyY - spaceBetweenRows: "<<rowheight*magnifyY - spaceBetweenRows<<endl;
00450   int previous_row(-1), previous_end(-1);
00451   for ( ReadData * r = readsInRect->first(); r; r = readsInRect->next() )
00452     {
00453 //       cerr<<r->name()<<'\t'<<r->getRecno()<<endl;
00454       
00455       bool overlap(false);
00456       if ( r->row() == previous_row && (r->startPos() <= previous_end ) ) {
00457         overlap = true;
00458       }
00459       previous_row = r->row();
00460       previous_end = r->endPos();
00461       
00462       bool selected = isSelected( r->getRecno() );
00463       
00464       /* we just have to paint the part of the read that is visible in the current window.
00465          Therefore we seak max and min values 
00466           */
00467       
00468       TR_DNA x1_dna_paint = max( r->startPos(), x_dna    ) ;
00469       TR_DNA x2_dna_paint = min( r->endPos(), x_dna + w_dna - 1  ) ;
00470       
00471       TR_PIX x_pix_adjust, y_pix_adjust;
00472       convertToPixelCoordinates( x_pix_adjust, y_pix_adjust, x1_dna_paint - x_dna, r->row() - y_dna );
00473       
00474       // x_pix += cx;
00475       //            y_pix += cy;
00476       
00477       TR_DNA len = x2_dna_paint - x1_dna_paint +1 ;
00478       
00479       paintFeatures( p, bitmapPainter, r->getRecno(), 
00480                      x_pix_adjust + cx_paint , y_pix_adjust + cy_paint,  
00481                      x1_dna_paint - r->startPos(), len, 
00482                      basewidth*magnifyX, rowheight*magnifyY - spaceBetweenRows , selected, center_point - r->startPos(), 
00483                      overlap, r->beginGood(), r->endGood() );
00484 
00485     }
00486 
00487 
00488   delete readsInRect;
00489 
00490 
00491 
00492 
00493   if ( rubber_band ) {
00494     QPen oldpen( p->pen() );
00495     QPen newpen( Qt::black, 0, Qt::DotLine );
00496     
00497     p->setPen( newpen );
00498     p->drawRect( *rubber_band );
00499     p->setPen( oldpen );    
00500     
00501   }
00502   
00503 }

void TrapperView::drawRubber QPainter *  p  )  [inline, private]
 

Definition at line 324 of file trapperview.h.

References RubberEnd, and RubberStart.

Referenced by contentsMouseMoveEvent(), and contentsMouseReleaseEvent().

00325   {
00326     QPen ppen = p->pen();
00327     ppen.setStyle(Qt::DotLine);
00328     p->setPen(ppen);
00329     p->drawRect(
00330                 RubberStart.x(),
00331                 RubberStart.y(),
00332                 RubberEnd.x()-RubberStart.x(),
00333                 RubberEnd.y()-RubberStart.y()
00334                 );
00335   }

void TrapperView::enlarge  ) 
 

enlarges view

Definition at line 1364 of file trapperview.cpp.

References basewidth, globalBases, globalRows, magnifyX, magnifyY, and rowheight.

Referenced by TrapperApp::slotEnlarge().

01365 {
01366   globalRows *= 2;
01367   globalBases *= 1.25;
01368   resizeContents(globalBases * magnifyX * basewidth , globalRows * rowheight * magnifyY);
01369   updateContents();
01370 }

void TrapperView::findRead  ) 
 

finds a read

Definition at line 1087 of file trapperview.cpp.

References Database::SecondaryIterator< T >::answer(), clearSelected(), dnaCoordToPixel_X(), dnaCoordToPixel_Y(), doc, GeneralData::getRecno(), Database::SecondaryIterator< T >::key(), ReadData::row(), scrollTo(), select(), Database::SecondaryIterator< T >::set(), ReadData::setName(), ReadData::startPos(), and TR_PIX.

Referenced by TrapperApp::slotEditFindRead().

01088 {
01089   bool ok;
01090   QString res = QInputDialog::getText ( "Find read", "Enter read name:", QLineEdit::Normal, QString::null, &ok );
01091   
01092 
01093   if ( ok ) {
01094     // user entered something and pressed OK
01095   } else {
01096     // user pressed Cancel
01097     return;
01098   }
01099 
01100   Database::SecondaryIterator<ReadData> name_it( "name", doc, "ReadData" );
01101   name_it.key()->setName( res );
01102   if ( name_it.set() != 0 ) {
01103     cerr<<"Error, couldn't find "<<res<<" in db"<<endl;
01104     return;
01105   }
01106   clearSelected();
01107   select(name_it.answer()->getRecno(), true);
01108   TR_PIX y = dnaCoordToPixel_Y(name_it.answer()->row());
01109   TR_PIX x = dnaCoordToPixel_X(name_it.answer()->startPos());
01110   scrollTo(x, y);
01111 
01112 }

void TrapperView::fitContentsizeToData  )  [protected]
 

Definition at line 135 of file trapperview.cpp.

References Database::SecondaryIterator< T >::answer(), basewidth, doc, ReadData::endPos(), globalBases, globalRows, Database::SecondaryIterator< T >::last(), magnifyX, magnifyY, ReadData::row(), and rowheight.

Referenced by readSelected(), runAlgo(), and TrapperView().

00136 {
00137   Database::SecondaryIterator<ReadData>* end_it = new Database::SecondaryIterator<ReadData>( "end", doc, "ReadData" );
00138   int ret_end = end_it->last();
00139   Database::SecondaryIterator<ReadData>* row_it = new Database::SecondaryIterator<ReadData>( "pos", doc, "ReadData" );
00140   int ret_row = row_it->last();
00141   ReadData* r_end = (ret_end != DB_NOTFOUND) ? end_it->answer() : 0;
00142   ReadData* r_row = (ret_row != DB_NOTFOUND) ? row_it->answer() : 0;
00143   if ( r_end ) {
00144     
00145     globalBases = r_end->endPos() + 50;    
00146   }
00147   if ( r_row ) {
00148     
00149     globalRows = r_row->row() + 500;
00150   }
00151   
00152   delete end_it;
00153   delete row_it;
00154   
00155   resizeContents(globalBases * magnifyX * basewidth , globalRows * rowheight * magnifyY);
00156  
00157 }

TrapperDoc * TrapperView::getDocument  )  const
 

returns a pointer to the document connected to the view

Definition at line 164 of file trapperview.cpp.

References doc.

Referenced by contentsDropEvent(), TrapperApp::eventFilter(), TrapperApp::slotCreateClient(), TrapperApp::slotFileClose(), TrapperApp::slotFileSave(), TrapperApp::slotFileSaveAs(), TrapperApp::slotShowStatistics(), TrapperApp::slotWindowNewWindow(), SubsetAlgo::start(), ReadnamesAlgo::start(), and ConsAlgo::start().

00165 {
00166     return doc;
00167 }

std::vector< std::list< std::string > > TrapperView::getInfo const QPoint &  pos  )  [protected]
 

Definition at line 1145 of file trapperview.cpp.

References Database::SecondaryIterator< T >::answer(), ReadData::beginGood(), doc, ReadData::endGood(), ReadData::endPos(), ReadsInRect::first(), FeatureInfo::getPosInfo(), FeatureInfo::getRangeInfo(), GeneralData::getRecno(), FeatureData::info(), Database::SecondaryIterator< T >::key(), GeneralMaker::listRegistered(), ReadData::mate(), ReadData::mateLength(), ReadData::name(), GeneralMaker::newData(), Database::SecondaryIterator< T >::nextdup(), pixelCoordToDna_X(), pixelCoordToDna_Y(), readsInRect, Database::SecondaryIterator< T >::set(), FeatureData::setReadRecno(), ReadsInRect::setWindowCoord(), ReadData::startPos(), ReadData::strand(), and TR_DNA.

Referenced by contentsContextMenuEvent().

01146 {
01147   vector<list<string> > result;
01148   list<string> readResult;
01149   list<string> featResult;
01150   list<string> generalResult;
01151   
01152   //Recalc pos
01153   TR_DNA row = pixelCoordToDna_Y( pos.y() );
01154   TR_DNA col = pixelCoordToDna_X( pos.x() );
01155 
01156   readsInRect = new ReadsInRect( doc );
01157   readsInRect->setWindowCoord( col, row, 1, 1 );  /* a rectangle with dimension 1x1 */
01158 //   readsInRect->setWindowCoord( col, row, 3, 3 );  /* a rectangle with dimension 3x3 */
01159   ReadData * r = readsInRect->first();
01160 
01161   ostringstream os;
01162   if ( r ) {
01163     list<string> types = GeneralMaker::listRegistered();
01164     readResult.push_back( "Read info" );
01165     readResult.push_back( r->name() );
01166     
01167     os<<"Strand: "<<r->strand();
01168     readResult.push_back( r->strand() );
01169     os.str("");
01170     os<<"Mate: "<<r->mate() << ' ' << r->mateLength();
01171     readResult.push_back( os.str() );
01172     os.str("");
01173     os<<"Begin good: "<<r->beginGood();
01174     readResult.push_back( os.str() );
01175     os.str("");
01176     os<<"End good: "<<r->endGood();
01177     readResult.push_back( os.str() );
01178     os.str("");
01179     os<<"Read index: "<<col - r->startPos();
01180     readResult.push_back( os.str() );
01181     
01182 
01183     featResult.push_back( "Feature info" );
01184     
01185     //Feature stuff
01186     for( list<string>::iterator it = types.begin(); it != types.end(); ++it ) {
01187       GeneralData * data = GeneralMaker::newData( *it );
01188       FeatureData * fdata = dynamic_cast<FeatureData *>( data );
01189       // fdata is just used to see that the registered string is corresponding to
01190       // a feature
01191       if ( fdata ) {
01192         Database::SecondaryIterator<FeatureData> featIt( "readRecno", doc, it->c_str() );
01193         
01194         featIt.key()->setReadRecno( r->getRecno() );
01195         
01196         string featInfo;
01197         
01198         if ( featIt.set() == 0 ) {
01199 
01200           int ret;
01201           do {
01202             
01203             featInfo = featIt.answer()->info()->getPosInfo( col - r->startPos() );
01204             if ( !featInfo.empty() ) {
01205               featResult.push_back( featInfo );
01206             }
01207             featInfo = featIt.answer()->info()->getRangeInfo( 0, r->endPos() - r->startPos() );
01208             if ( !featInfo.empty() ) {
01209               readResult.push_back( featInfo );
01210             }
01211             
01212             
01213           } while ( (ret = featIt.nextdup())  == 0);
01214         }
01215       }
01216       
01217       delete data;
01218       
01219     }
01220 
01221     
01222   }
01223   generalResult.push_back("General info");
01224   os.str("");
01225   os<<"Row: "<<row<<", Col: "<<col;
01226   generalResult.push_back( os.str() );
01227   
01228   result.push_back(readResult);
01229   result.push_back(featResult);
01230   result.push_back(generalResult);
01231   
01232   delete readsInRect;
01233   return result;
01234 }

std::set< db_recno_t > & TrapperView::getSelectedReads  )  [protected]
 

Definition at line 1115 of file trapperview.cpp.

References selectedReads.

Referenced by moveData(), and slotStartAlgo().

01116 {
01117   return selectedReads;
01118 }

bool TrapperView::isSelected db_recno_t  recno  )  [protected]
 

Definition at line 1134 of file trapperview.cpp.

References selectedReads.

Referenced by contentsMousePressEvent(), drawContents_helper(), and select().

01135 {
01136   return selectedReads.find( recno ) != selectedReads.end();
01137 }

void TrapperView::message const QString &   )  [signal]
 

Referenced by sendMsg(), and TrapperParser::startElement().

QString TrapperView::mode  ) 
 

the name of the view mode that the TrapperView is using right now

Definition at line 159 of file trapperview.cpp.

References ViewModes::currentViewMode(), ViewMode::name(), and viewModes.

Referenced by TrapperDoc::changedViewList().

00160 {
00161     return viewModes->currentViewMode()->name();
00162 }

TR_DNA TrapperView::mousePressedCol  ) 
 

gets col position of last mouse press

Definition at line 1686 of file trapperview.cpp.

References mousePressedPoint, and pixelCoordToDna_X().

Referenced by slotSetCenter().

01687 {
01688   return pixelCoordToDna_X( mousePressedPoint.x() );
01689   
01690 }

TR_DNA TrapperView::mousePressedRow  ) 
 

gets row position of last mouse press

Definition at line 1679 of file trapperview.cpp.

References mousePressedPoint, and pixelCoordToDna_Y().

01680 {
01681   return pixelCoordToDna_Y( mousePressedPoint.y() );
01682   
01683   
01684 }

void TrapperView::moveData TR_PIX  dx,
TR_PIX  dy
[protected]
 

Definition at line 549 of file trapperview.cpp.

References AlgoMoveParam::get_x_delta(), AlgoMoveParam::get_y_delta(), getSelectedReads(), last_move_x, last_move_y, pixelCoordToDna_X(), pixelCoordToDna_Y(), runAlgo(), and TR_DNA.

Referenced by contentsDropEvent(), contentsMouseReleaseEvent(), readSelected(), and undo().

00550 {
00551 //     cerr<<"PLEASE NOTE: ALGO PARAMS SHOULD BE FIXED!!!"<<endl;
00552   TR_DNA col_delta, row_delta;
00553   row_delta = pixelCoordToDna_Y( dy );
00554   col_delta = pixelCoordToDna_X( dx);
00555 
00556   AlgoMoveParam param( col_delta, row_delta );
00557   
00558   runAlgo( "Move Reads", getSelectedReads(), &param );
00559 
00560   last_move_x = param.get_x_delta();
00561   last_move_y = param.get_y_delta();
00562   
00563   
00564 }

void TrapperView::paintFeatures QPainter *  p,
QPainter *  bitmapPainter,
db_recno_t  readRecno,
TR_PIX  x_pix,
TR_PIX  y_pix,
TR_DNA  x_dna_relative,
TR_DNA  dna_len,
double  width,
TR_PIX  height,
bool  selected,
int  center_relative,
bool  overlap,
TR_DNA  bg,
TR_DNA  eg
[protected]
 

paint border line around the read rectangle. Then divide the rectangle into layers and paint features of the read into these layers.

Parameters:
p where to paint
bmp where to paint a bitmask, we paint to the bitmask on the same places as we paint to p.
readRecno the index of the read in the underlying berkeley db.
x_pix x "content" coordinate of the upperleft corner of the paint area
y_pix y "content" coordinate of the upperleft corner of the paint area
x1_dna x dna coordinate of the left most position to paint seen relative the left side of the read
x2_dna x dna coordinate of the right most position to paint seen relative the left side of the read
width the pixel width of one x dna coordinate
height the pixel width of one x dna coordinate
highlight if true change the read border color

Definition at line 243 of file trapperview.cpp.

References Database::SecondaryIterator< T >::answer(), Database::SecondaryIterator< T >::closeCursor(), ViewModes::currentViewMode(), Layer::featureList, FeatureData::gui(), Layer::heightInPix(), Database::SecondaryIterator< T >::key(), ViewMode::layerList, magnifyX, magnifyY, moving, Database::SecondaryIterator< T >::name(), Database::SecondaryIterator< T >::nextdup(), FeatureGui::paint(), Database::SecondaryIterator< T >::set(), FeatureData::setReadRecno(), TR_PIX, viewModes, and zoom_cutoff.

Referenced by drawContents_helper().

00248 {
00249   
00250 //   cerr << "  db_recno_t = "<<readRecno
00251 //        << "  x_pix ="<< x_pix
00252 //        << "  y_pix ="<< y_pix
00253 //        << "  x_dna_relative ="<< x_dna_relative
00254 //        << "  dna_len ="<< dna_len
00255 //        << "  width =" << width
00256 //        << "  height ="<<height
00257 //        << endl;
00258   
00259   
00260   Layer * layer;
00261   
00262   p->setPen( Qt::black );
00263   
00264   /* clear away old painted stuff, by painting white in the read rectangle */
00265   QBrush brush;
00266   brush.setStyle( Qt::SolidPattern );
00267   brush.setColor( Qt::white );
00268   p->fillRect( x_pix  , y_pix ,  dna_len*width , height ,brush) ;
00269   
00270   brush.setColor( Qt::color1 );
00271   
00272   if ( bitmapPainter && selected )
00273     bitmapPainter->fillRect( x_pix  , y_pix , dna_len*width , height ,brush) ;
00274   
00275   /*  finished clearing */
00276   
00277   
00278   
00279   
00280   
00281   // we use two pixels in the height to draw the paintReadBorder
00282   y_pix += 1;
00283   height -= 2;
00284   
00285   
00286   
00287   /* starting painting features */
00288   
00289   
00290   TR_PIX heightLayerSum = 0; /* each feature knows how many percent of the total height
00291                                 it may use when painting itself. The variable heightLayerSum stores how much of the
00292                                 total height has already been painted to by other feature layers */
00293   for (layer = viewModes->currentViewMode()->layerList.first(); layer; layer =  viewModes->currentViewMode()->layerList.next() )
00294     {
00295       TR_PIX heightLayer = layer->heightInPix( height );
00296       Database::SecondaryIterator<FeatureData> * it;
00297       for (it  = layer->featureList.first(); it; it = layer->featureList.next() )
00298         {
00299           int cutoff = zoom_cutoff[ it->name() ];
00300           if ( magnifyX < cutoff || magnifyY < cutoff ) continue;
00301           
00302           it->key()->setReadRecno( readRecno );
00303           if ( it->set() == 0 ) {
00304             int ret;
00305             do {
00306 //               if ( readRecno == 654 ) {
00307 //                 cerr<<'\t'<<it->answer()->uniqueName()<<'\t'<<it->answer()->getRecno()<<endl;
00308 //               }
00309               
00310               
00311               it->answer()->gui()->paint( p, x_pix, y_pix + heightLayerSum , x_dna_relative, x_dna_relative + dna_len -1 , width, heightLayer, center_relative );
00312               
00313             } while ( (ret = it->nextdup())  == 0);
00314             
00315             
00316           }
00317           it->closeCursor();
00318         }
00319       heightLayerSum += heightLayer;
00320     }
00321   /* finished painting features */
00322   
00323   
00324   /* paint readBorder, start */
00325   
00326   /* the horisontal border is painted just outside the features,
00327      but the vertical border is painted on the features side, so the 
00328      features lose one pixel of width on the left and right sides */
00329   
00330   QPen oldpen( p->pen() ), newpen( p->pen() );
00331   
00332   if ( selected ) {
00333     newpen.setColor( Qt::red );
00334     if ( moving )
00335       newpen.setStyle( Qt::DashLine);
00336   }
00337   if ( overlap ) {
00338     newpen.setColor(Qt::green);
00339   }
00340   p->setPen(newpen);
00341   
00342   if ( magnifyX < 1.0 ) {
00343     //       cerr<<"x_pix: "<<x_pix<<endl;
00344     //       cerr<<"y_pix: "<<y_pix<<endl;
00345     //       cerr<<"dna_len: "<<dna_len<<endl;
00346     //       cerr<<"width: "<<width<<endl;
00347     //       cerr<<"dna_len * width: "<<dna_len * width<<endl;
00348     //       cerr<<"height: "<<height<<endl;
00349   }
00350   
00351   p->drawRect( x_pix  , y_pix,  dna_len*width  , height ) ;
00352 
00353   //Quality trimming
00354   brush.setStyle( Qt::Dense4Pattern );
00355   brush.setColor( Qt::white );
00356   if ( x_dna_relative < bg ) {
00357     p->fillRect( x_pix  , y_pix,  (bg - x_dna_relative)*width  , height, brush ) ;
00358   }
00359   if ( x_dna_relative + dna_len > eg ) {
00360     int goodlen = eg - x_dna_relative + 1;
00361     if ( goodlen < 0 ) goodlen = 0;
00362     p->fillRect( x_pix + goodlen*width  , y_pix, (dna_len - goodlen )*width, height, brush ) ;
00363   }
00364   
00365 
00366   
00367   p->setPen( oldpen );
00368   
00369   /* finished painting readBorder */
00370 }

void TrapperView::paintGrid QPainter *  p,
TR_PIX  cx,
TR_PIX  cy,
TR_PIX  cw,
TR_PIX  ch
[protected]
 

paint some extra dots in the background of the window. These will move along when the user scrolls. Nice to have some visual feedback of movement when there are no reads in the window

Definition at line 505 of file trapperview.cpp.

References center_point, dnaCoordToPixel_X(), dnaCoordToPixel_Y(), pixelCoordToDna_X(), pixelCoordToDna_Y(), and rowheight.

Referenced by drawContents().

00506 {
00507   p->setPen( Qt::black );
00508 
00509 //   int toprow=cy/rowheight;
00510 //   int bottomrow=(cy+ch+rowheight-1)/rowheight;
00511   int local_rowheight = 100;
00512   int toprow=cy/local_rowheight;
00513   int bottomrow=(cy+ch+local_rowheight-1)/local_rowheight;
00514   int colwidth=100;
00515   int leftcol=cx/colwidth;
00516   int rightcol=(cx+cw+colwidth-1)/colwidth;
00517   for (int r=toprow; r<=bottomrow; r++) {
00518 //     int py=r*rowheight;
00519     int py=r*local_rowheight - dnaCoordToPixel_Y(1)/2;
00520     for (int c=leftcol; c<=rightcol; c++) {
00521       int px=c*colwidth + dnaCoordToPixel_X(1)/2;
00522       p->drawLine(px, py, px+2, py);
00523       
00524     }
00525   }
00526   QFont f;
00527   f.setPointSize(10);
00528   p->setFont(f);
00529   int viewport_toprow=contentsY()/local_rowheight - 2;
00530   if (viewport_toprow <0 ) viewport_toprow = 0;
00531   
00532   int viewport_bottomrow=(cy+ch+local_rowheight-1)/local_rowheight + 1;
00533   int viewport_leftcol=contentsX()/colwidth;
00534   int viewport_rightcol=(contentsX() + contentsWidth() +colwidth-1)/colwidth;
00535 
00536 
00537   for( int i = viewport_leftcol; i < viewport_rightcol; i++ ) {
00538     p->drawText( i*colwidth + dnaCoordToPixel_X(1)/2, 10, QString().setNum(pixelCoordToDna_X( i*colwidth )) );
00539   }
00540   for( int i = viewport_toprow; i < viewport_bottomrow; i++ ) {
00541     p->drawText( 0, i*local_rowheight, QString().setNum(pixelCoordToDna_Y( i*local_rowheight )) );    
00542   }
00543 
00544   bottomrow=(cy+ch+rowheight-1)/rowheight;
00545   int center_x = dnaCoordToPixel_X(center_point) + dnaCoordToPixel_X(1)/2;
00546   p->drawLine(center_x, 0, center_x, bottomrow*rowheight );
00547 }

void TrapperView::paste  ) 
 

pastes selected data

Definition at line 1649 of file trapperview.cpp.

References readSelected().

Referenced by TrapperApp::slotEditPaste().

01650 {
01651   
01652   QClipboard* cb = QApplication::clipboard();
01653   QMimeSource* r = cb->data(QClipboard::Clipboard);
01654 
01655   QByteArray ar(r->encodedData("min_mime_type"));
01656   QDataStream str(ar, IO_ReadOnly);
01657   
01658   readSelected(str);
01659   updateContents();
01660 }

TR_DNA TrapperView::pixelCoordToDna_X TR_PIX  x_dna  )  [protected]
 

Definition at line 203 of file trapperview.cpp.

References basewidth, and magnifyX.

Referenced by contentsMouseMoveEvent(), contentsMousePressEvent(), convertToDnaCoordinates(), getInfo(), mousePressedCol(), moveData(), and paintGrid().

00204 {
00205 //   if ( basewidth * magnifyX < 1 ) {
00206 //     cerr<<"basewidth: "<<basewidth<<endl;
00207 //     cerr<<"basewidth * magnifyX: "<<basewidth * magnifyX<<endl;
00208 //   }
00209   
00210 
00211   return cx / ( basewidth * magnifyX );
00212 }

TR_DNA TrapperView::pixelCoordToDna_Y TR_PIX  y_dna  )  [protected]
 

Definition at line 214 of file trapperview.cpp.

References magnifyY, and rowheight.

Referenced by contentsMouseMoveEvent(), contentsMousePressEvent(), convertToDnaCoordinates(), drawContents_helper(), getInfo(), mousePressedRow(), moveData(), and paintGrid().

00215 {
00216   return cy / ( rowheight * magnifyY );
00217 }

void TrapperView::print QPrinter *  pPrinter  ) 
 

contains the implementation for printing functionality and gets called by TrapperApp::slotFilePrint()

Definition at line 175 of file trapperview.cpp.

Referenced by TrapperApp::slotFilePrint().

00176 {
00177     if (pPrinter->setup(this))
00178     {
00179         QPainter p;
00180         p.begin(pPrinter);
00181 
00182         ///////////////////////////////
00183         // TODO: add your printing code here
00184         ///////////////////////////////
00185 
00186         p.end();
00187     }
00188 }

void TrapperView::readSelected QDataStream &  data_stream  )  [protected]
 

Definition at line 1571 of file trapperview.cpp.

References clearLastMove(), clearSelected(), Database::Creator< T >::create(), Database::Creator< T >::data(), dnaCoordToPixel_X(), dnaCoordToPixel_Y(), doc, fitContentsizeToData(), moveData(), GeneralData::readStream(), select(), FeatureData::setReadRecno(), and TR_DNA.

Referenced by contentsDropEvent(), and paste().

01572 {
01573   //Read from stream
01574   clearSelected();
01575   
01576   db_recno_t recno(0);
01577 
01578   //Keep track of lowest row and start pos, and transpose the pasted reads there
01579 
01580   TR_DNA rowmin(numeric_limits<TR_DNA>::max());
01581   TR_DNA colmin(numeric_limits<TR_DNA>::max());
01582 
01583   while ( !data_stream.atEnd() ) {
01584     
01585     //Read data type
01586     char* data_type;
01587     
01588     data_stream>>data_type;//must delete this myself according to Qt docs
01589     
01590     string type(data_type);
01591     
01592     //Create Creator for general data with Data type name to constructor
01593     Database::Creator<GeneralData> a_creator(doc, type);
01594     
01595     //Read stream using readStream on Creators data() pointer
01596     a_creator.data()->readStream(data_stream);
01597     
01598     if ( ReadData* data = dynamic_cast<ReadData*>(a_creator.data())) {/* type is ReadData*/
01599       
01600       //Creator::create(false) and save read recno
01601       recno = a_creator.create(false);
01602       select(recno, true);
01603       if ( data->row() < rowmin ) {
01604         rowmin = data->row();
01605       }
01606       if ( data->startPos() < colmin ) {
01607         colmin = data->startPos();
01608       }
01609       
01610     }
01611     else {
01612       //Type is feature, but let's do a sanity check
01613       FeatureData* data = dynamic_cast<FeatureData*>(a_creator.data());
01614       assert( data  );
01615       assert( recno != 0 );
01616       
01617       //Set feature's read recno to saved recno
01618       data->setReadRecno(recno);
01619       
01620       //Creator::create()
01621       a_creator.create(false);
01622     }
01623     
01624     delete data_type;
01625   }
01626   fitContentsizeToData();
01627   moveData( -dnaCoordToPixel_X(colmin - 1), -dnaCoordToPixel_Y(rowmin - 1) );
01628   clearLastMove();
01629 }

void TrapperView::runAlgo const std::string &  AlgoType,
std::set< db_recno_t > &  recnoList,
AlgoParam param = 0
[protected]
 

Definition at line 1236 of file trapperview.cpp.

References TrapperDoc::addAlgorithm(), doc, fitContentsizeToData(), AlgoMaker::newAlgo(), TrapperDoc::removeAlgorithm(), selectedReads, and Algo::start().

Referenced by moveData(), and slotStartAlgo().

01237 {
01238   
01239   if (selectedReads.size() > 0 ) {
01240     
01241     Algo * algo = AlgoMaker::newAlgo( AlgoType, doc , recnoList, param );
01242     doc->addAlgorithm( algo );
01243     algo->start();
01244     doc->removeAlgorithm( algo );//POSSIBLE MEMORY LEAK!!!!!!!!!
01245     delete algo;//To avoid memory leak...
01246     
01247     updateContents();
01248     fitContentsizeToData();
01249   }
01250   
01251 }

void TrapperView::scrollTo TR_PIX  x,
TR_PIX  y
[protected]
 

Definition at line 1356 of file trapperview.cpp.

Referenced by findRead(), slotScrollToMouse(), and slotScrollToPos().

01357 {
01358   setContentsPos( x, y );
01359   updateContents();
01360   
01361 }

void TrapperView::select db_recno_t  recno,
bool  status
[protected]
 

Definition at line 1120 of file trapperview.cpp.

References clearLastMove(), isSelected(), and selectedReads.

Referenced by contentsMousePressEvent(), contentsMouseReleaseEvent(), findRead(), readSelected(), selectAll(), and selectBetween().

01121 {
01122   RecnoMap::iterator pos;
01123   if ( status == true && !isSelected(recno) ) {
01124     selectedReads.insert( recno );
01125     clearLastMove();
01126   }
01127   else if ( ( pos = selectedReads.find( recno )) != selectedReads.end() ) {
01128     selectedReads.erase( pos );
01129     clearLastMove();
01130   }
01131   
01132 }

void TrapperView::selectAll  ) 
 

selects all

Definition at line 1381 of file trapperview.cpp.

References Database::PrimaryIterator< T >::answer(), clearSelected(), doc, Database::PrimaryIterator< T >::first(), GeneralData::getRecno(), Database::PrimaryIterator< T >::next(), and select().

Referenced by TrapperApp::slotEditSelectAll().

01382 {
01383   clearSelected();
01384   Database::PrimaryIterator<ReadData> iter( doc, "ReadData" );
01385   
01386   if ( iter.first() == 0 ) {
01387   
01388     do {
01389       select( iter.answer()->getRecno(), true );
01390       
01391     } while ( iter.next() == 0 );
01392     
01393   }
01394   updateContents();
01395 
01396 }

void TrapperView::selectBetween  ) 
 

selects between rows

Definition at line 1398 of file trapperview.cpp.

References Database::SecondaryIterator< T >::answer(), clearSelected(), doc, GeneralData::getRecno(), Database::SecondaryIterator< T >::key(), Database::SecondaryIterator< T >::next(), ReadData::row(), select(), Database::SecondaryIterator< T >::setRange(), ReadData::setRow(), ReadData::setStartPos(), and TR_DNA.

Referenced by TrapperApp::slotEditSelectBetween().

01399 {
01400   clearSelected();
01401   bool ok;
01402   TR_DNA start, stop;
01403   int res = QInputDialog::getInteger("Select between rows", "Enter start row for selected reads:", 0, 1, numeric_limits<int>::max(), 1,
01404                                      &ok, 0 );
01405   if ( ok ) {
01406     start = res;
01407   }
01408   else {
01409     return;
01410   }
01411   
01412   res = QInputDialog::getInteger("Select between rows", 
01413                                  "Enter stop row for selected reads:", 
01414                                  0, 1, numeric_limits<int>::max(), 1,
01415                                  &ok, 0 );
01416   if ( ok ) {
01417     stop = res;
01418     if ( start > stop ) {
01419       TR_DNA tmp = start;
01420       start = stop;
01421       stop = tmp;
01422     }
01423   }
01424   else {
01425     return;
01426   }
01427 
01428   Database::SecondaryIterator<ReadData> row_it( "pos", doc, "ReadData" );
01429   row_it.key()->setRow(start);
01430   row_it.key()->setStartPos(0);
01431   
01432   if ( row_it.setRange() != 0 ) {
01433 
01434     return;
01435   }
01436   
01437   do {
01438     select( row_it.answer()->getRecno(), true );
01439   }while( row_it.next() == 0 && row_it.answer()->row() <= stop );
01440 
01441   updateContents();
01442 
01443 }

void TrapperView::sendMsg const QString &  msg  ) 
 

Sends out a message

Definition at line 1692 of file trapperview.cpp.

References message().

Referenced by contentsMouseMoveEvent(), and contentsMousePressEvent().

01693 {
01694   emit message(msg);
01695 }

void TrapperView::setDragMode bool  status  ) 
 

sets pointer mode

Definition at line 1631 of file trapperview.cpp.

References allow_dragging.

Referenced by TrapperApp::slotActivatedWindow(), TrapperApp::slotDragMode(), and TrapperApp::slotNormalMode().

01632 {
01633   allow_dragging = status;
01634 }

void TrapperView::shrink  ) 
 

shrinks view

Definition at line 1372 of file trapperview.cpp.

References basewidth, globalBases, globalRows, magnifyX, magnifyY, and rowheight.

Referenced by TrapperApp::slotShrink().

01373 {
01374   globalRows *= 0.5;
01375   globalBases *= 0.8;
01376   resizeContents(globalBases * magnifyX * basewidth , globalRows * rowheight * magnifyY);
01377   updateContents();
01378 }

void TrapperView::slotClearCenter  )  [slot]
 

Definition at line 1081 of file trapperview.cpp.

References center_point.

Referenced by contentsContextMenuEvent().

01082 {
01083   center_point = 0;
01084   updateContents();
01085 }

void TrapperView::slotScrollToMouse  )  [slot]
 

Definition at line 1036 of file trapperview.cpp.

References mousePressedPoint, and scrollTo().

Referenced by contentsContextMenuEvent().

01037 {
01038   scrollTo(mousePressedPoint.x(), mousePressedPoint.y());
01039 
01040 }

void TrapperView::slotScrollToPos  )  [slot]
 

Definition at line 1042 of file trapperview.cpp.

References dnaCoordToPixel_X(), dnaCoordToPixel_Y(), scrollTo(), and TR_PIX.

Referenced by contentsContextMenuEvent().

01043 {
01044   bool ok;
01045   int res = QInputDialog::getInteger(
01046                                      "Scroll to position", "Enter row:", 0, 0, numeric_limits<int>::max(), 1,
01047                                      &ok, 0 );
01048   
01049   if ( ok ) {
01050     // user entered something and pressed OK
01051   } else {
01052     // user pressed Cancel
01053     return;
01054   }
01055   TR_PIX y = dnaCoordToPixel_Y(res);
01056 
01057   res = QInputDialog::getInteger(
01058                                  "Scroll to position", "Enter column:", 0, 0, numeric_limits<int>::max(), 1,
01059                                  &ok, 0 );
01060   
01061   if ( ok ) {
01062     // user entered something and pressed OK
01063   } else {
01064     // user pressed Cancel
01065     return;
01066   }
01067 
01068   TR_PIX x = dnaCoordToPixel_X(res);
01069   
01070   scrollTo(x, y);
01071 
01072 }

void TrapperView::slotSetCenter  )  [slot]
 

Definition at line 1074 of file trapperview.cpp.

References center_point, and mousePressedCol().

Referenced by contentsContextMenuEvent().

01075 {
01076   center_point = mousePressedCol();
01077 //   cerr<<center_point<<endl;
01078   updateContents();
01079 }

void TrapperView::slotStartAlgo int  i  )  [slot]
 

Definition at line 1008 of file trapperview.cpp.

References algoMenu, clearLastMove(), getSelectedReads(), and runAlgo().

Referenced by contentsContextMenuEvent().

01009 {
01010   QString algoStr =  algoMenu->text(i);
01011   
01012   /* Right now the Algo constructor takes a list of db_recno_t.
01013      We create such a list from the keys in the map, selectedReads.
01014      
01015      Todo: To make the code prettier: is it be possible to
01016      pass the map iterators to the constructor of the list?
01017      Instead of our manual forloop.
01018   */
01019   
01020   
01021   //     std::list< db_recno_t > alist = getSelectedReads();
01022   //     Algo * algo = AlgoMaker::newAlgo( algoStr.ascii(), doc , alist );
01023   //     doc->addAlgorithm( algo );
01024   //     algo->start();
01025   //     doc->removeAlgorithm( algo );//POSSIBLE MEMORY LEAK!!!!!!!!!
01026   //     updateContents();
01027   
01028   ViewParam param(this);
01029 
01030   updateContents();
01031   runAlgo( algoStr.ascii(), getSelectedReads(), &param );
01032   //To be on the safe side...
01033   clearLastMove();
01034 }

void TrapperView::slotSwitchToMode int  i  )  [slot]
 

Definition at line 1000 of file trapperview.cpp.

References TrapperDoc::changedViewList(), doc, ViewModes::setMode(), switchViewMenu, and viewModes.

Referenced by contentsContextMenuEvent().

01001 {
01002     QString viewMode =  switchViewMenu->text(i);
01003     viewModes->setMode( viewMode );
01004     doc->changedViewList();
01005     updateContents();
01006 }

void TrapperView::undo  ) 
 

undoes last move

Definition at line 1674 of file trapperview.cpp.

References dnaCoordToPixel_X(), dnaCoordToPixel_Y(), last_move_x, last_move_y, and moveData().

Referenced by TrapperApp::slotEditUndo().

void TrapperView::update TrapperView pSender  ) 
 

gets called to redraw the document contents if it has been modified

Definition at line 169 of file trapperview.cpp.

Referenced by TrapperDoc::updateAllViews().

00170 {
00171     if(pSender != this)
00172         repaint();
00173 }

void TrapperView::writeSelected QDataStream &  data_stream  )  [protected]
 

Definition at line 1503 of file trapperview.cpp.

References Database::SecondaryIterator< T >::answer(), Database::PrimaryIterator< T >::answer(), doc, Database::SecondaryIterator< T >::key(), GeneralMaker::listRegistered(), GeneralMaker::newData(), Database::SecondaryIterator< T >::nextdup(), selectedReads, Database::SecondaryIterator< T >::set(), Database::PrimaryIterator< T >::setFromRecno(), FeatureData::setReadRecno(), FeatureData::writeStream(), and ReadData::writeStream().

Referenced by contentsMouseMoveEvent(), and copy().

01504 {
01505   //Write to stream
01506 
01507   
01508   //Get registered types
01509   
01510   list<string> type_list = GeneralMaker::listRegistered();
01511   
01512   
01513   //Loop over selected reads
01514   for( set<db_recno_t>::iterator recno_it = selectedReads.begin(); recno_it != selectedReads.end(); ++recno_it ) {
01515     //Get recno
01516     db_recno_t recno(*recno_it);
01517     
01518     //Create primary iterator for ReadData with new
01519     Database::PrimaryIterator<ReadData>* read_it = new Database::PrimaryIterator<ReadData>(doc, "ReadData");
01520     
01521     //Set iterator from recno
01522     read_it->setFromRecno(recno);
01523     
01524     //Write dataname to stream - null terminated, right?? Must check size stuff...
01525     data_stream<<"ReadData";
01526     
01527     //write ReadData to stream using writeStream
01528     read_it->answer()->writeStream(data_stream);
01529     
01530     //Delete primary readiterator
01531     delete read_it;
01532     
01533     //Loop over types
01534     for( list<string>::iterator type_it = type_list.begin(); type_it != type_list.end(); ++type_it ) {
01535       
01536       GeneralData * data = GeneralMaker::newData( *type_it );
01537       FeatureData * fdata = dynamic_cast<FeatureData *>( data );
01538       // fdata is just used to see that the registered string is corresponding to
01539       // a feature
01540       if ( fdata ) {/* Can cast type to feature */
01541         //Create secondary feature iterator
01542         Database::SecondaryIterator<FeatureData> featIt( "readRecno", doc, type_it->c_str() );
01543         
01544         //Set iterator key read recno
01545         featIt.key()->setReadRecno( recno );
01546         
01547         if ( featIt.set() == 0 ) {//Read has such feature
01548           int ret;
01549           do {
01550             
01551             //write feat name to stream
01552             data_stream<<type_it->c_str();
01553             
01554             //write FeatureData to stream using writeStream
01555             featIt.answer()->writeStream(data_stream);
01556             
01557           } while ((ret = featIt.nextdup())== 0);
01558           
01559         }
01560         
01561       }
01562       
01563       delete data;
01564       
01565     }
01566     
01567   }
01568   
01569 }

void TrapperView::zoomIn  ) 
 

zooms in

Definition at line 1253 of file trapperview.cpp.

References zoomInX(), and zoomInY().

Referenced by TrapperApp::slotZoomIn().

01254 {
01255   zoomInX();
01256   zoomInY();
01257 }

void TrapperView::zoomInX  ) 
 

zooms in X-direction

Definition at line 1259 of file trapperview.cpp.

References basewidth, globalBases, globalRows, magnifyX, magnifyY, rowheight, and zoomfactor.

Referenced by TrapperApp::slotZoomInX(), and zoomIn().

01260 {
01261   if ( magnifyX >= 128 )
01262     return;
01263   
01264   magnifyX *= zoomfactor;
01265 //   doZoom();
01266   
01267   QPoint p = viewportToContents(viewport()->rect().topLeft());
01268 //   if ( globalBases * magnifyX * basewidth < 1 ) {
01269 //     cerr<<"globalBases: "<<globalBases<<endl;
01270 //     cerr<<"globalBases * magnifyX * basewidth: "<<globalBases * magnifyX * basewidth<<endl;
01271 //   }
01272 
01273   resizeContents(globalBases * magnifyX * basewidth , globalRows * rowheight * magnifyY);
01274   setContentsPos(p.x()*zoomfactor, p.y());
01275 
01276   updateContents();
01277 
01278 }

void TrapperView::zoomInY  ) 
 

zooms in Y-direction

Definition at line 1280 of file trapperview.cpp.

References basewidth, globalBases, globalRows, magnifyX, magnifyY, rowheight, and zoomfactor.

Referenced by TrapperApp::slotZoomInY(), and zoomIn().

01281 {
01282   if ( magnifyY >= 128 )
01283     return;
01284   magnifyY *= zoomfactor;
01285 //   doZoom();
01286 
01287   QPoint p = viewportToContents(viewport()->rect().topLeft());
01288   
01289   resizeContents(globalBases * magnifyX * basewidth , globalRows * rowheight * magnifyY);
01290   setContentsPos(p.x(), p.y()*zoomfactor);
01291 
01292   updateContents();
01293 }

void TrapperView::zoomOut  ) 
 

zooms out

Definition at line 1295 of file trapperview.cpp.

References zoomOutX(), and zoomOutY().

Referenced by TrapperApp::slotZoomOut().

01296 {
01297   zoomOutX();
01298   zoomOutY();
01299 }

void TrapperView::zoomOutX  ) 
 

zooms out X-dir

Definition at line 1301 of file trapperview.cpp.

References basewidth, globalBases, globalRows, magnifyX, magnifyY, rowheight, and zoomfactor.

Referenced by TrapperApp::slotZoomOutX(), and zoomOut().

01302 {
01303 //   if ( magnifyX <= 1 )
01304   if ( magnifyX <= 0.25 )
01305     {
01306       return;
01307     }
01308   magnifyX /= zoomfactor;
01309 //   doZoom();
01310 
01311   QPoint p = viewportToContents(viewport()->rect().topLeft());
01312 
01313 //   if ( globalBases * magnifyX * basewidth < 1 ) {
01314 //     cerr<<"globalBases: "<<globalBases<<endl;
01315 //     cerr<<"globalBases * magnifyX * basewidth: "<<globalBases * magnifyX * basewidth<<endl;
01316 //   }
01317   resizeContents(globalBases * magnifyX * basewidth , globalRows * rowheight * magnifyY);
01318   setContentsPos(p.x()/zoomfactor, p.y());
01319 
01320   updateContents();
01321 }

void TrapperView::zoomOutY  ) 
 

zooms out Y-dir

Definition at line 1323 of file trapperview.cpp.

References basewidth, globalBases, globalRows, magnifyX, magnifyY, rowheight, and zoomfactor.

Referenced by TrapperApp::slotZoomOutY(), and zoomOut().

01324 {
01325   if ( magnifyY <= 1 )
01326     {
01327       return;
01328     }
01329   magnifyY /= zoomfactor;
01330 //   doZoom();
01331 
01332   QPoint p = viewportToContents(viewport()->rect().topLeft());
01333   resizeContents(globalBases * magnifyX * basewidth , globalRows * rowheight * magnifyY);
01334   setContentsPos(p.x(), p.y()/zoomfactor);
01335 
01336   updateContents();
01337 }


Friends And Related Function Documentation

friend class TrapperDoc [friend]
 

Definition at line 119 of file trapperview.h.

Referenced by TrapperParser::startElement().


Member Data Documentation

QPopupMenu* TrapperView::algoMenu [protected]
 

Definition at line 276 of file trapperview.h.

Referenced by contentsContextMenuEvent(), and slotStartAlgo().

bool TrapperView::allow_dragging [protected]
 

Definition at line 298 of file trapperview.h.

Referenced by contentsMouseMoveEvent(), setDragMode(), and TrapperView().

TR_PIX TrapperView::basewidth [protected]
 

Definition at line 262 of file trapperview.h.

Referenced by dnaCoordToPixel_X(), doZoom(), drawContents_helper(), enlarge(), fitContentsizeToData(), pixelCoordToDna_X(), shrink(), TrapperView(), zoomInX(), zoomInY(), zoomOutX(), and zoomOutY().

TR_DNA TrapperView::center_point [protected]
 

Definition at line 266 of file trapperview.h.

Referenced by drawContents_helper(), paintGrid(), slotClearCenter(), slotSetCenter(), and TrapperView().

QPoint TrapperView::curr_mouse_pos [protected]
 

Definition at line 303 of file trapperview.h.

Referenced by contentsMouseMoveEvent().

TrapperDoc* TrapperView::doc [protected]
 

Definition at line 268 of file trapperview.h.

Referenced by contentsMousePressEvent(), contentsMouseReleaseEvent(), cut(), drawContents_helper(), findRead(), fitContentsizeToData(), getDocument(), getInfo(), readSelected(), runAlgo(), selectAll(), selectBetween(), slotSwitchToMode(), TrapperView(), and writeSelected().

QBitmap TrapperView::dragBitmap [private]
 

Definition at line 312 of file trapperview.h.

Referenced by contentsMousePressEvent().

bool TrapperView::dragging [protected]
 

Definition at line 297 of file trapperview.h.

Referenced by contentsMouseMoveEvent(), contentsMousePressEvent(), contentsMouseReleaseEvent(), and TrapperView().

QPixmap TrapperView::dragPixmap [private]
 

Definition at line 311 of file trapperview.h.

Referenced by contentsMouseMoveEvent(), contentsMousePressEvent(), and drawContents_helper().

QPoint TrapperView::dragWindowPoint [private]
 

Definition at line 315 of file trapperview.h.

Referenced by contentsMouseMoveEvent(), contentsMousePressEvent(), and drawContents_helper().

TR_DNA TrapperView::globalBases [protected]
 

Definition at line 265 of file trapperview.h.

Referenced by doZoom(), enlarge(), fitContentsizeToData(), shrink(), TrapperView(), zoomInX(), zoomInY(), zoomOutX(), and zoomOutY().

TR_DNA TrapperView::globalRows [protected]
 

Definition at line 265 of file trapperview.h.

Referenced by doZoom(), enlarge(), fitContentsizeToData(), shrink(), TrapperView(), zoomInX(), zoomInY(), zoomOutX(), and zoomOutY().

QPopupMenu* TrapperView::infoMenu [protected]
 

Definition at line 277 of file trapperview.h.

Referenced by contentsContextMenuEvent().

QLabel* TrapperView::lab [protected]
 

Definition at line 269 of file trapperview.h.

bool TrapperView::last_click_changed_selection [protected]
 

Definition at line 301 of file trapperview.h.

Referenced by contentsContextMenuEvent(), contentsMousePressEvent(), contentsMouseReleaseEvent(), and TrapperView().

bool TrapperView::last_click_selected_read [protected]
 

Definition at line 300 of file trapperview.h.

Referenced by contentsContextMenuEvent(), contentsMouseMoveEvent(), contentsMousePressEvent(), contentsMouseReleaseEvent(), and TrapperView().

TR_DNA TrapperView::last_move_x [protected]
 

Definition at line 307 of file trapperview.h.

Referenced by clearLastMove(), moveData(), and undo().

TR_DNA TrapperView::last_move_y [protected]
 

Definition at line 308 of file trapperview.h.

Referenced by clearLastMove(), moveData(), and undo().

db_recno_t TrapperView::last_selected_recno [protected]
 

Definition at line 302 of file trapperview.h.

Referenced by contentsMousePressEvent(), and contentsMouseReleaseEvent().

double TrapperView::magnifyX [protected]
 

Definition at line 271 of file trapperview.h.

Referenced by dnaCoordToPixel_X(), doZoom(), drawContents_helper(), enlarge(), fitContentsizeToData(), paintFeatures(), pixelCoordToDna_X(), shrink(), TrapperView(), zoomInX(), zoomInY(), zoomOutX(), and zoomOutY().

u_int16_t TrapperView::magnifyY [protected]
 

Definition at line 272 of file trapperview.h.

Referenced by dnaCoordToPixel_Y(), doZoom(), drawContents_helper(), enlarge(), fitContentsizeToData(), paintFeatures(), pixelCoordToDna_Y(), shrink(), TrapperView(), zoomInX(), zoomInY(), zoomOutX(), and zoomOutY().

QPoint TrapperView::mousePressedPoint [private]
 

Definition at line 314 of file trapperview.h.

Referenced by contentsDropEvent(), contentsMouseMoveEvent(), contentsMousePressEvent(), drawContents_helper(), mousePressedCol(), mousePressedRow(), and slotScrollToMouse().

bool TrapperView::moveOn [private]
 

Definition at line 322 of file trapperview.h.

Referenced by contentsMousePressEvent(), contentsMouseReleaseEvent(), and drawContents_helper().

bool TrapperView::moving [protected]
 

Definition at line 299 of file trapperview.h.

Referenced by contentsContextMenuEvent(), contentsMouseMoveEvent(), contentsMousePressEvent(), contentsMouseReleaseEvent(), drawContents_helper(), paintFeatures(), and TrapperView().

QPoint TrapperView::oldMovePoint [private]
 

Definition at line 321 of file trapperview.h.

Referenced by drawContents_helper().

QPainter TrapperView::p3 [private]
 

Definition at line 313 of file trapperview.h.

Referenced by contentsMousePressEvent().

ReadsInRect* TrapperView::readsInRect [protected]
 

Definition at line 296 of file trapperview.h.

Referenced by contentsMousePressEvent(), contentsMouseReleaseEvent(), drawContents_helper(), and getInfo().

TR_PIX TrapperView::rowheight [protected]
 

Definition at line 264 of file trapperview.h.

Referenced by dnaCoordToPixel_Y(), doZoom(), drawContents_helper(), enlarge(), fitContentsizeToData(), paintGrid(), pixelCoordToDna_Y(), shrink(), TrapperView(), zoomInX(), zoomInY(), zoomOutX(), and zoomOutY().

QRect* TrapperView::rubber_band [private]
 

Definition at line 316 of file trapperview.h.

Referenced by contentsMouseMoveEvent(), contentsMousePressEvent(), contentsMouseReleaseEvent(), drawContents_helper(), and TrapperView().

QPoint TrapperView::RubberEnd [private]
 

Definition at line 319 of file trapperview.h.

Referenced by contentsMouseMoveEvent(), contentsMousePressEvent(), contentsMouseReleaseEvent(), and drawRubber().

bool TrapperView::RubberOn [private]
 

Definition at line 320 of file trapperview.h.

Referenced by contentsMouseMoveEvent(), contentsMousePressEvent(), and contentsMouseReleaseEvent().

QPoint TrapperView::RubberStart [private]
 

Definition at line 319 of file trapperview.h.

Referenced by contentsMousePressEvent(), contentsMouseReleaseEvent(), and drawRubber().

std::set<db_recno_t> TrapperView::selectedReads [protected]
 

The index values ( of type db_recno_t ) of all selected reads.

Just some thoughts about implemantion: Right now they are stored as an STL map but there are other alternatives of how to implement this: Maybe an STL bitset or STL vector<bool> or maybe store it in a berkeley db. If you want to select all possible reads, 4^32, then you would lower your memory consumption if used a bitset. And going with a berkeley db you would have even lower memory demands.

040315: Changed selectedReads into std::set --EA

Definition at line 293 of file trapperview.h.

Referenced by clearSelected(), contentsMousePressEvent(), cut(), getSelectedReads(), isSelected(), runAlgo(), select(), and writeSelected().

TR_PIX TrapperView::spaceBetweenRows [protected]
 

Definition at line 263 of file trapperview.h.

Referenced by drawContents_helper(), and TrapperView().

QPopupMenu* TrapperView::switchViewMenu [protected]
 

Definition at line 275 of file trapperview.h.

Referenced by contentsContextMenuEvent(), and slotSwitchToMode().

ViewModes* TrapperView::viewModes [protected]
 

Definition at line 274 of file trapperview.h.

Referenced by mode(), paintFeatures(), slotSwitchToMode(), TrapperView(), and ~TrapperView().

TR_PIX TrapperView::y_delta [protected]
 

Definition at line 304 of file trapperview.h.

Referenced by contentsMouseMoveEvent(), contentsMousePressEvent(), contentsMouseReleaseEvent(), and drawContents_helper().

TR_PIX TrapperView::y_delta_previous [protected]
 

Definition at line 305 of file trapperview.h.

Referenced by contentsMouseMoveEvent(), and contentsMousePressEvent().

std::map<std::string, int> TrapperView::zoom_cutoff [protected]
 

Definition at line 294 of file trapperview.h.

Referenced by paintFeatures(), and TrapperView().

int TrapperView::zoomfactor [protected]
 

Definition at line 273 of file trapperview.h.

Referenced by TrapperView(), zoomInX(), zoomInY(), zoomOutX(), and zoomOutY().


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