alnmulti_widget.cpp
来自「ncbi源码」· C++ 代码 · 共 894 行 · 第 1/2 页
CPP
894 行
void CAlnMultiWidget::OnUnMarkAll(void){ m_pAlignPane->UnMarkAll(); m_pAlignPane->redraw();}void CAlnMultiWidget::OnHideSelected(){ CAlnMultiModel::TIndexVector vIndices; m_pModel->SLM_GetSelectedIndices(vIndices); m_pModel->SLM_SelectAll(false); size_t N = vIndices.size(); vector<TNumrow> rows; rows.resize(N); for(size_t i = 0; i<N; i++ ) { rows[i] = GetRowNumByLine(vIndices[i]); } SetVisible(rows, false);}void CAlnMultiWidget::OnShowAll(){ m_pModel->ShowAll(); x_AdjustVisible(false); x_SetScrollbars(); x_RedrawControls();}void CAlnMultiWidget::OnMoveSelectedUp(){ if(m_pModel) { vector<TNumrow> rows; m_pModel->GetSelectedRows(rows); if(rows.size()) { m_pModel->SetRowOrder(rows); x_RedrawControls(); } } }void CAlnMultiWidget::UpdateSortOrder(void){ m_pModel->UpdateSortOrder(); x_RedrawControls();}void CAlnMultiWidget::GetMarks(TPSeqLocList& ls_locs) const{ const CAlnMultiPane::TRowToMarkMap& map = m_pAlignPane->GetMarks(); ITERATE(CAlnMultiPane::TRowToMarkMap, it_m, map) { //for each marked row TNumrow row = it_m->first; if(GetDataSource()->CanGetId(row)) { const CSeq_id& seq_id = GetDataSource()->GetSeqId(row); // create CSeq_loc ls_locs.push_back(new CSeq_loc()); CSeq_loc& seq_loc = *ls_locs.back(); // put intervals CSeq_loc::TPacked_int& p_int = seq_loc.SetPacked_int(); const TRangeColl& mark = it_m->second; ITERATE(TRangeColl, it_r, mark) { // for each range in mark p_int.AddInterval(seq_id, it_r->GetFrom(), it_r->GetTo()); } } }}void CAlnMultiWidget::x_CreateControls(){ _ASSERT(! m_pAlignPane && ! m_pScrollX && ! m_pScrollY); const int kScrollbarSize = CAlnMultiSettings::GetScrollbarSize(); int client_w = w() - kScrollbarSize; int client_h = h() - kScrollbarSize; m_pAlignPane = new CAlnMultiPane(x(), y(), client_w, client_h); IAlnMultiPaneParent* pWidget = static_cast<IAlnMultiPaneParent*>(this); m_pAlignPane->SetWidget(pWidget); m_pAlignPane->SetContext(m_pModel); m_pModel->SLM_AddSLView(static_cast<TNumrowSelListView*>(m_pAlignPane)); // scrollbars m_pScrollX = new Fl_Scrollbar(x(), y() + client_h, client_w, kScrollbarSize); m_pScrollX->type(FL_HORIZONTAL); m_pScrollX->callback(CAlnMultiWidget::x_OnScrollX, this ); m_pScrollY = new Fl_Scrollbar(x() + client_w, y(), kScrollbarSize, client_h); m_pScrollY->type(FL_VERTICAL); m_pScrollY->callback(CAlnMultiWidget::x_OnScrollY, this ); resizable(m_pAlignPane); end();}void CAlnMultiWidget::x_SetScrollbars(){ TModelRect rcAll = x_GetAlignPort().GetModelLimitsRect(); TModelRect rcVisible = x_GetAlignPort().GetVisibleRect(); if (x_GetAlignPort().NeedsScrollX()) { m_pScrollX->value((int) rcVisible.Left(), (int) rcVisible.Width(), (int) rcAll.Left(), (int)rcAll.Width()); } else { m_pScrollX->value(0, 0, 0, 0); } if (x_GetAlignPort().NeedsScrollY()) { m_pScrollY->value((int) rcVisible.Top(), (int) -rcVisible.Height(), (int) rcAll.Top(), (int) -rcAll.Height()); } else { m_pScrollY->value(0, 0, 0, 0); }}void CAlnMultiWidget::x_OnResize(){ TVPRect rcVP; rcVP.SetSize(m_pAlignPane->GetAlignVPWidth(), m_pAlignPane->GetAlignVPHeight()); x_GetAlignPort().SetViewport(rcVP); x_AdjustVisible(false); x_SetScrollbars(); // do not redraw, FLTK will do it for us - }void CAlnMultiWidget::x_RedrawControls(){ m_pAlignPane->redraw();}/////////////////////////////////////////////////////////////////////////////////// Update handlersvoid CAlnMultiWidget::x_UpdateOnDataChanged(bool b_reset){ if(GetDataSource()) { x_AdjustVisible(b_reset); } m_pAlignPane->ResetSelection(false); m_pAlignPane->UnMarkAll(); x_SetScrollbars(); m_pAlignPane->Update(); x_RedrawControls();}void CAlnMultiWidget::x_AdjustVisible(bool b_reset){ TModelRect rcV; if(b_reset) { rcV = x_GetAlignPort().GetModelLimitsRect(); rcV.SetTop(0); } else { rcV = x_GetAlignPort().GetVisibleRect(); } rcV.SetBottom(rcV.Top() + m_pAlignPane->GetAlignVPHeight()); x_GetAlignPort().SetVisibleRect(rcV); x_GetAlignPort().AdjustToLimits();}void CAlnMultiWidget::x_UpdateOnRowHChanged(){ _ASSERT(GetDataSource()); // updating model m_pModel->UpdateOnRowHChanged(); // updating representation x_AdjustVisible(false); x_SetScrollbars(); x_RedrawControls();}void CAlnMultiWidget::x_UpdateOnSwitchMaster(TNumrow NewMasterRow){ TModelRect rcV = x_GetAlignPort().GetVisibleRect(); TSignedSeqPos SeqStart, SeqStop; if(GetDataSource()->GetAnchor() == NewMasterRow) return; // choose row that will be used for coordinate translations TNumrow SelRow = (NewMasterRow != -1) ? NewMasterRow : GetDataSource()->GetAnchor(); TRangeColl SeqSelection; //selection in coordinates of SelRow if(SelRow != -1) { TSeqPos AlnStart((TSeqPos) rcV.Left()); TSeqPos AlnStop((TSeqPos) rcV.Right()); SeqStart = GetDataSource()->GetSeqPosFromAlnPos(SelRow, AlnStart, IAlnMultiDataSource:: TSearchDirection::eRight); SeqStop = GetDataSource()->GetSeqPosFromAlnPos(SelRow, AlnStop, IAlnMultiDataSource:: TSearchDirection::eRight); // convert selection to SelRow coordinates const TRangeColl& Selection = m_pAlignPane->GetSelection(); ITERATE(TRangeColl, it, Selection) { TSeqPos Start = GetDataSource()->GetSeqPosFromAlnPos(SelRow, it->GetFrom(), IAlnMultiDataSource:: TSearchDirection::eRight); TSeqPos Stop = GetDataSource()->GetSeqPosFromAlnPos(SelRow, it->GetTo(), IAlnMultiDataSource:: TSearchDirection::eLeft); SeqSelection.CombineWith(TSeqRange(Start, Stop)); } } m_pModel->SetMasterRow(NewMasterRow); if(SelRow != -1) { // calculate new visible rect based on saved positions TSignedSeqPos AlnStart = GetDataSource()->GetAlnPosFromSeqPos(SelRow, SeqStart); TSignedSeqPos AlnStop = GetDataSource()->GetAlnPosFromSeqPos(SelRow, SeqStop); TModelRect rcNewV(AlnStart, rcV.Bottom(), AlnStop, rcV.Top()); x_GetAlignPort().SetVisibleRect(rcNewV); // convert Selection back to Alignment space TRangeColl AlnSelection; const TRangeColl& C = SeqSelection; ITERATE(TRangeColl, it, C) { TSeqPos Start = GetDataSource()->GetAlnPosFromSeqPos(SelRow, it->GetFrom()); TSeqPos Stop = GetDataSource()->GetAlnPosFromSeqPos(SelRow, it->GetTo()); AlnSelection.CombineWith(TSeqRange(Start, Stop)); } m_pAlignPane->SetSelection(AlnSelection, false); } m_pAlignPane->Update(); x_AdjustVisible(false); x_SetScrollbars(); x_RedrawControls(); }void CAlnMultiWidget::x_UpdateOnZoom(){ x_SetScrollbars(); m_pAlignPane->Update(); x_RedrawControls();}/////////////////////////////////////////////////////////////////////////////////// Scroll callbacksvoid CAlnMultiWidget::x_OnScrollX(Fl_Widget* pW, void* pData){ CAlnMultiWidget* pCont = reinterpret_cast<CAlnMultiWidget*>(pData); int V = pCont->m_pScrollX->value(); double dX = V - pCont->x_GetAlignPort().GetVisibleRect().Left(); pCont->x_GetAlignPort().Scroll(dX, 0); pCont->x_RedrawControls();}void CAlnMultiWidget::x_OnScrollY(Fl_Widget* pW, void* pData){ CAlnMultiWidget* pCont = reinterpret_cast<CAlnMultiWidget*>(pData); int V = pCont->m_pScrollY->value(); double dY = V - pCont->x_GetAlignPort().GetVisibleRect().Top(); pCont->x_GetAlignPort().Scroll(0, dY); pCont->x_RedrawControls();}END_NCBI_SCOPE/* * =========================================================================== * $Log: alnmulti_widget.cpp,v $ * Revision 1000.5 2004/06/01 21:07:16 gouriano * PRODUCTION: UPGRADED [GCC34_MSVC7] Dev-tree R1.49 * * Revision 1.49 2004/05/21 22:27:52 gorelenk * Added PCH ncbi_pch.hpp * * Revision 1.48 2004/05/10 17:46:35 yazhuk * Addressed GCC warnings * * Revision 1.47 2004/05/03 13:23:57 dicuccio * gui/utils --> gui/objutils where needed * * Revision 1.46 2004/04/29 21:39:56 johnson * make viewport reset in x_UpdateOnDataChanged optional * * Revision 1.45 2004/04/07 13:07:27 dicuccio * Changed use of Match() - scope is optional pointer * * Revision 1.44 2004/04/06 16:04:59 yazhuk * Implemented OnMoveSelectedUp() command handler * * Revision 1.43 2004/04/02 16:34:35 yazhuk * Implemented support for selection broadcasting * * Revision 1.42 2004/04/02 15:55:17 dicuccio * Added call to redraw() in OnHideSelected() * * Revision 1.41 2004/03/25 13:18:49 dicuccio * MInor code reformatting * * Revision 1.40 2004/03/24 19:20:32 yazhuk * Fixed initilization/destruction * * Revision 1.39 2004/03/18 17:07:11 yazhuk * Added "b_invert_others" argument to SetVisible() * * Revision 1.38 2004/03/17 20:11:32 yazhuk * Refined CAlnMultiWidget interface and implementation * * Revision 1.37 2004/03/11 17:50:41 dicuccio * Updated typedefs: dropped TDimension, TPosition, TIndex, TColor; use TSeqRange * instead of TRange * * Revision 1.36 2004/03/09 21:04:23 yazhuk * Separated part of CAlnMultiWidget class into CAlnMultiModel * * Revision 1.35 2004/03/08 15:40:18 yazhuk * Implemented new functions for IAlnMultiPaneParent interface * * Revision 1.34 2004/02/04 20:05:08 yazhuk * Clean-up * * Revision 1.33 2004/01/22 16:33:39 yazhuk * Fixed FL_MOVE handling * * Revision 1.32 2004/01/15 20:13:25 yazhuk * Implemented popup menus, added UpdateSortOrder() , renamed some x_Update... * functions. Fixed focus handling bug in x_UpdateRowOrder() * * Revision 1.31 2004/01/08 19:40:44 yazhuk * Implemented row sorting, bugfixes in hiding/showing rows * * Revision 1.30 2003/12/22 16:26:05 yazhuk * Refactored Update system, optimized visibility support implementation * * Revision 1.29 2003/12/18 21:19:48 yazhuk * Major refactoring - implemented rows hiding, support for display styles * * Revision 1.28 2003/12/17 19:15:06 yazhuk * Added GetSelection() * * Revision 1.27 2003/12/10 17:07:25 yazhuk * Added "ref. point" argument to OnSetScaleX(). Basic support for popup menus. * * Revision 1.26 2003/12/08 16:41:10 yazhuk * Fixed scrollbar setup * * Revision 1.25 2003/12/01 22:35:52 yazhuk * Fixed GCC warnings * * Revision 1.24 2003/12/01 16:57:41 yazhuk * Added OnZoomRect() and OnScroll() * * Revision 1.23 2003/11/26 16:52:00 johnson * switch IAlnMultiDataSource to use CAlnMap::ESearchDirection instead of it's * own ESearchDirection * * Revision 1.22 2003/11/18 17:58:08 yazhuk * Fixed GCC warnings * * Revision 1.21 2003/11/06 20:14:56 dicuccio * Added USING_SCOPE(objects) to implementation file * * Revision 1.20 2003/11/03 16:57:38 yazhuk * Added OnRowChanged(), x_UpdateOnRowChanged() functions * * Revision 1.19 2003/10/31 22:25:37 ucko * Properly capitalize FL/Fl.H * * Revision 1.18 2003/10/29 23:33:12 yazhuk * Migrated to new classes, did a lot of refactoring * * Revision 1.17 2003/10/20 15:49:06 yazhuk * Implemented OnSetScaleX(). Clean-up. * * Revision 1.16 2003/10/15 21:23:08 yazhuk * Migrated from using CAlnVec to accessing data via "generic" interface in IAlnMultiDataSource. * * Revision 1.15 2003/10/10 18:57:41 yazhuk * Added scoring, OnZoomSequence() and fonts * * Revision 1.14 2003/10/07 13:44:59 dicuccio * Code beautification * * Revision 1.13 2003/10/04 16:47:37 dicuccio * Fix for compilation on gcc * * Revision 1.12 2003/10/03 16:26:36 yazhuk * Added command map * * Revision 1.11 2003/09/29 15:53:42 dicuccio * Reordered #include statements * * Revision 1.10 2003/09/29 13:40:31 yazhuk * Added GetMarks() function, fixed bug with setting viewport limits * * Revision 1.9 2003/09/25 20:46:13 yazhuk * Update CGlPane calls, added scale limitation * * Revision 1.8 2003/09/24 18:33:16 dicuccio * Code reformatting. Changed to match API in new data source * * Revision 1.7 2003/09/23 20:51:45 yazhuk * Updated IAlnMultiPaneParent member function implementation, added Mark manipulation functions, removed code working with Consensus Row * * Revision 1.6 2003/09/10 20:45:20 yazhuk * Merged 4 Pane classes into CAlnMultiPane class * * Revision 1.5 2003/09/08 20:42:04 yazhuk * Added Selection translation for switching Master Row * * Revision 1.4 2003/09/08 16:17:27 yazhuk * Support for anchoring sequences, "Zoom Selection" and 'Reset Selection" operations, bugfixes * * Revision 1.3 2003/09/02 16:53:57 yazhuk * GCC compilation fixes * * Revision 1.2 2003/08/28 18:26:16 yazhuk * Modified to be used with new CAlnMultiWidget * * Revision 1.1 2003/07/14 17:36:47 dicuccio * Initial revision * * =========================================================================== */
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?