📄 sequence_viewer_widget.cpp
字号:
}void SequenceViewerWidget_TitleArea::SetBackgroundColor(const wxColor& backgroundColor){ currentBackgroundColor = backgroundColor;}void SequenceViewerWidget_TitleArea::OnPaint(wxPaintEvent& event){ wxPaintDC dc(this); int vsX, vsY, updTop, updBottom, firstRow, lastRow, row; dc.BeginDrawing(); // set font for characters if (alignment) { dc.SetFont(*titleFont); dc.SetMapMode(wxMM_TEXT); // characters to be drawn transparently over background dc.SetBackgroundMode(wxTRANSPARENT); // get upper left corner of visible area sequenceArea->GetViewStart(&vsX, &vsY); // returns coordinates in scroll units (cells) } // get the update rect list, so that we can draw *only* the cells // in the part of the window that needs redrawing; update region // coordinates are relative to the visible part of the drawing area wxRegionIterator upd(GetUpdateRegion()); for (; upd; ++upd) {// if (upd.GetW() == GetClientSize().GetWidth() &&// upd.GetH() == GetClientSize().GetHeight())// TESTMSG("repainting whole SequenceViewerWidget_TitleArea"); // draw background dc.SetPen(*(wxThePenList-> FindOrCreatePen(currentBackgroundColor, 1, wxSOLID))); dc.SetBrush(*(wxTheBrushList-> FindOrCreateBrush(currentBackgroundColor, wxSOLID))); dc.DrawRectangle(upd.GetX(), upd.GetY(), upd.GetW(), upd.GetH()); if (!alignment) continue; // figure out which cells contain the corners of the update region // get coordinates of update region corners relative to virtual area updTop = vsY*cellHeight + upd.GetY(); updBottom = updTop + upd.GetH() - 1; firstRow = updTop / cellHeight; lastRow = updBottom / cellHeight; // restrict to size of virtual area, if visible area is larger // than the virtual area if (lastRow >= nTitles) lastRow = nTitles - 1; // draw titles wxString title; wxColor color; wxCoord tW, tH; for (row=firstRow; row<=lastRow; ++row) { if (!alignment->GetRowTitle(row, &title, &color)) continue; // set character color if (row == highlightedTitleRow) dc.SetTextForeground(*wxRED); else dc.SetTextForeground(color); // draw title centered vertically in the cell dc.GetTextExtent(title, &tW, &tH); dc.DrawText(title, 0, cellHeight * (row - vsY) + (cellHeight - tH)/2); } } dc.EndDrawing();}void SequenceViewerWidget_TitleArea::OnMouseEvent(wxMouseEvent& event){ static const ViewableAlignment *prevAlignment = NULL; static int prevMOY = -1; if (!alignment) { prevAlignment = NULL; prevMOY = -1; return; } if (alignment != prevAlignment) { prevMOY = -1; prevAlignment = alignment; } // get coordinates of mouse when it's over the drawing area wxCoord mX, mY; event.GetPosition(&mX, &mY); // translate visible area coordinates to cell coordinates int vsX, vsY, MOY; sequenceArea->GetViewStart(&vsX, &vsY); MOY = vsY + mY / cellHeight; // if the mouse is leaving the window or is outside area if (event.Leaving() || MOY >= sequenceArea->GetAreaHeight()) MOY = -1; // do MouseOver if not in the same cell as last time if (MOY != prevMOY) alignment->MouseOver(-1, MOY); prevMOY = MOY; // process button press if (event.LeftDown()) { // find out which (if any) control keys are down at this time unsigned int controls = 0; if (event.ShiftDown()) controls |= ViewableAlignment::eShiftDown;#ifdef __WXMAC__ if (event.MetaDown()) // control key + mouse doesn't work on Mac?#else if (event.ControlDown())#endif controls |= ViewableAlignment::eControlDown; if (event.AltDown() || event.MetaDown()) controls |= ViewableAlignment::eAltOrMetaDown; // send MouseDown message alignment->MouseDown(-1, MOY, controls); // (temporarily) highlight this title highlightedTitleRow = MOY; Refresh(); }}/////////////////////////////////////////////////////////////////////////////// This is the implementation of SequenceViewerWidget ///////////////////////////////////////////////////////////////////////////////SequenceViewerWidget::SequenceViewerWidget( wxWindow* parent, wxWindowID id, const wxPoint& pos, const wxSize& size) : wxSplitterWindow(parent, -1, wxPoint(0,0), parent->GetClientSize(), wxSP_3DBORDER | wxNO_3D){ sequenceArea = new SequenceViewerWidget_SequenceArea(this); titleArea = new SequenceViewerWidget_TitleArea(this); sequenceArea->SetTitleArea(titleArea); titleArea->SetSequenceArea(sequenceArea); SplitVertically(titleArea, sequenceArea);}SequenceViewerWidget::~SequenceViewerWidget(void){}void SequenceViewerWidget::OnDoubleClickSash(int x, int y){ Unsplit(titleArea);}void SequenceViewerWidget::TitleAreaOn(void){ if (!IsSplit()) { titleArea->Show(true); SplitVertically(titleArea, sequenceArea, titleArea->GetMaxTitleWidth() + 10); }}void SequenceViewerWidget::TitleAreaOff(void){ if (IsSplit()) Unsplit(titleArea);}void SequenceViewerWidget::TitleAreaToggle(void){ if (IsSplit()) Unsplit(titleArea); else { titleArea->Show(true); SplitVertically(titleArea, sequenceArea, titleArea->GetMaxTitleWidth() + 10); }}bool SequenceViewerWidget::AttachAlignment(ViewableAlignment *newAlignment, int initX, int initY){ // do titles first, since on Mac sequence area update causes title redraw titleArea->ShowTitles(newAlignment); sequenceArea->AttachAlignment(newAlignment, initX, initY); SetSashPosition(titleArea->GetMaxTitleWidth() + 10, true); return true;}void SequenceViewerWidget::SetMouseMode(eMouseMode mode){ sequenceArea->SetMouseMode(mode);}SequenceViewerWidget::eMouseMode SequenceViewerWidget::GetMouseMode(void) const{ return sequenceArea->GetMouseMode();}void SequenceViewerWidget::SetBackgroundColor(const wxColor& backgroundColor){ sequenceArea->SetBackgroundColor(backgroundColor); titleArea->SetBackgroundColor(backgroundColor);}void SequenceViewerWidget::SetCharacterFont(wxFont *font){ wxFont *newFont = new wxFont(font->GetPointSize(), font->GetFamily(), wxNORMAL, wxNORMAL, false, font->GetFaceName(), font->GetDefaultEncoding()); sequenceArea->SetCharacterFont(newFont); newFont = new wxFont(font->GetPointSize(), font->GetFamily(), wxITALIC, wxNORMAL, false, font->GetFaceName(), font->GetDefaultEncoding()); titleArea->SetCharacterFont(newFont, sequenceArea->GetCellHeight()); delete font; // toggle title area twice to reset the sash to the right width - crude but effective TitleAreaToggle(); TitleAreaToggle(); Refresh(true);}void SequenceViewerWidget::SetRubberbandColor(const wxColor& rubberbandColor){ sequenceArea->SetRubberbandColor(rubberbandColor);}void SequenceViewerWidget::ScrollTo(int column, int row){ sequenceArea->Scroll(column, row);}void SequenceViewerWidget::GetScroll(int *vsX, int *vsY) const{ sequenceArea->GetViewStart(vsX, vsY);}void SequenceViewerWidget::MakeCharacterVisible(int column, int row) const{ int vsX, vsY, nCells; sequenceArea->GetViewStart(&vsX, &vsY); // scroll horizontally if necessary if (column >= 0) { nCells = sequenceArea->GetClientSize().GetWidth() / sequenceArea->cellWidth; if (column < vsX || column >= vsX + nCells) { vsX = column - nCells / 2; if (vsX < 0) vsX = 0; } } // scroll vertically if necessary if (row >= 0) { nCells = sequenceArea->GetClientSize().GetHeight() / sequenceArea->cellHeight; if (row < vsY || row >= vsY + nCells) { vsY = row - nCells / 2; if (vsY < 0) vsY = 0; } } sequenceArea->Scroll(vsX, vsY);}void SequenceViewerWidget::Refresh(bool eraseBackground, const wxRect *rect){ sequenceArea->Refresh(eraseBackground, rect); titleArea->Refresh(eraseBackground, rect);}/** ---------------------------------------------------------------------------* $Log: sequence_viewer_widget.cpp,v $* Revision 1000.2 2004/06/01 18:29:15 gouriano* PRODUCTION: UPGRADED [GCC34_MSVC7] Dev-tree R1.42** Revision 1.42 2004/05/22 15:45:53 thiessen* support mouse wheel; update status bar on scroll** Revision 1.41 2004/05/21 21:41:39 gorelenk* Added PCH ncbi_pch.hpp** Revision 1.40 2004/03/15 18:32:03 thiessen* prefer prefix vs. postfix ++/-- operators** Revision 1.39 2004/02/19 17:05:10 thiessen* remove cn3d/ from include paths; add pragma to disable annoying msvc warning** Revision 1.38 2003/02/03 19:20:06 thiessen* format changes: move CVS Log to bottom of file, remove std:: from .cpp files, and use new diagnostic macros** Revision 1.37 2003/01/22 14:47:30 thiessen* cache PSSM in BlockMultipleAlignment** Revision 1.36 2002/10/07 13:29:32 thiessen* add double-click -> show row to taxonomy tree** Revision 1.35 2002/08/15 22:13:16 thiessen* update for wx2.3.2+ only; add structure pick dialog; fix MultitextDialog bug** Revision 1.34 2002/04/27 16:32:14 thiessen* fix small leaks/bugs found by BoundsChecker** Revision 1.33 2002/04/26 13:46:38 thiessen* comment out all blast/pssm methods** Revision 1.32 2002/02/22 14:24:01 thiessen* sort sequences in reject dialog ; general identifier comparison** Revision 1.31 2002/02/21 12:26:30 thiessen* fix row delete bug ; remember threader options** Revision 1.30 2002/02/05 18:53:25 thiessen* scroll to residue in sequence windows when selected in structure window** Revision 1.29 2001/11/01 19:01:45 thiessen* use meta key instead of ctrl on Mac** Revision 1.28 2001/09/26 15:27:54 thiessen* tweak sequence viewer widget for wx2.3.2, tweak cdd annotation** Revision 1.27 2001/08/14 17:18:22 thiessen* add user font selection, store in registry** Revision 1.26 2001/07/19 19:14:38 thiessen* working CDD alignment annotator ; misc tweaks** Revision 1.25 2001/06/07 19:05:38 thiessen* functional (although incomplete) render settings panel ; highlight title - not sequence - upon mouse click** Revision 1.24 2001/05/31 18:47:09 thiessen* add preliminary style dialog; remove LIST_TYPE; add thread single and delete all; misc tweaks** Revision 1.23 2001/05/31 14:32:33 thiessen* tweak font handling** Revision 1.22 2001/05/22 19:09:31 thiessen* many minor fixes to compile/run on Solaris/GTK** Revision 1.21 2001/05/03 14:39:14 thiessen* put ViewableAlignment in its own (non-wx) header** Revision 1.20 2001/05/02 16:35:15 thiessen* launch entrez web page on sequence identifier** Revision 1.19 2001/04/18 15:46:53 thiessen* show description, length, and PDB numbering in status line** Revision 1.18 2001/04/04 00:27:15 thiessen* major update - add merging, threader GUI controls** Revision 1.17 2000/12/21 23:42:16 thiessen* load structures from cdd's** Revision 1.16 2000/11/02 16:56:02 thiessen* working editor undo; dynamic slave transforms** Revision 1.15 2000/10/16 20:03:07 thiessen* working block creation** Revision 1.14 2000/10/12 16:22:45 thiessen* working block split** Revision 1.13 2000/10/05 18:34:43 thiessen* first working editing operation** Revision 1.12 2000/10/04 17:41:31 thiessen* change highlight color (cell background) handling** Revision 1.11 2000/10/03 18:59:23 thiessen* added row/column selection** Revision 1.10 2000/10/02 23:25:23 thiessen* working sequence identifier window in sequence viewer** Revision 1.9 2000/09/20 22:22:28 thiessen* working conservation coloring; split and center unaligned justification** Revision 1.8 2000/09/14 14:55:35 thiessen* add row reordering; misc fixes** Revision 1.7 2000/09/12 01:47:39 thiessen* fix minor but obscure bug** Revision 1.6 2000/09/11 22:57:33 thiessen* working highlighting** Revision 1.5 2000/09/11 01:46:16 thiessen* working messenger for sequence<->structure window communication** Revision 1.4 2000/09/09 14:35:15 thiessen* fix wxWin problem with large alignments** Revision 1.3 2000/09/07 21:41:40 thiessen* fix return type of min_max** Revision 1.2 2000/09/07 17:37:35 thiessen* minor fixes** Revision 1.1 2000/09/03 18:46:49 thiessen* working generalized sequence viewer** Revision 1.2 2000/08/30 23:46:28 thiessen* working alignment display** Revision 1.1 2000/08/30 19:48:42 thiessen* working sequence window**/
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -