seqgraphic_pane.cpp
来自「ncbi源码」· C++ 代码 · 共 993 行 · 第 1/2 页
CPP
993 行
case FL_PUSH: case FL_DRAG: m_Renderer->SetLensZoom(Fl::event_x(), h() - Fl::event_y()); redraw(); break; case FL_RELEASE: m_Renderer->CancelLensZoom(); redraw(); break; default: break; } // switch (FLTK event)} // Place selected objects into clipboardvoid CSeqGraphicPane::x_Handle_ClipboardCopy(){ CClipboard::Clear(); // retrieve and process selections CScope& scope = m_DS->GetBioseqHandle().GetScope(); TConstObjects sel_objs = m_Renderer->GetSelectedObjects(); ITERATE (TConstObjects, iter, sel_objs) { CObjClipboard::Add(scope, **iter); } const CSeq_id* id = m_DS->GetBioseqHandle().GetSeqId(); const TRangeColl& sel_ranges = GetSelectedSeqRanges(); ITERATE (TRangeColl, iter, sel_ranges) { CRef<CSeq_loc> loc(new CSeq_loc()); loc->SetInt().SetFrom(iter->GetFrom()); loc->SetInt().SetTo (iter->GetTo()); loc->SetId(*id); CObjClipboard::Add(scope, *loc); } CObjClipboard::Copy();}/*int CSeqGraphicPane::handle(int event){ case eLensZoomState: switch (signal) { case CGUIEvent::ePush: // unhandled state - we have a few special cases here m_Renderer->SetLensZoom(ev_x, h() - ev_y); redraw(); return 1; case CGUIEvent::eDrag: m_Renderer->SetLensZoom(ev_x, h() - ev_y); redraw(); return 1; case CGUIEvent::eRelease: m_Renderer->CancelLensZoom(); redraw(); return 1; default: break; } break; case eZoomInState: m_Renderer->ZoomInCenter(); return 1; case eZoomOutState: m_Renderer->ZoomOutCenter(); return 1; case eZoomInFullState: m_Renderer->SetZoomX(0.0f); return 1; case eZoomOutFullState: m_Renderer->SetZoomX(1.0f); return 1; default: break; } // pass events to the tooltip object m_Tooltip.Handle(event); return CGlCanvas2d::handle(event);}*/// IMouseZoomHandlerHost implementationTModelUnit CSeqGraphicPane::MZHH_GetScale(EScaleType type){ switch(type) { case eCurrent: return m_Renderer->GetFeatGlPane().GetScaleX(); case eMin: return m_Renderer->GetFeatGlPane().GetMinScaleX(); case eMax: return m_Renderer->GetFeatGlPane().GetZoomAllScaleX(); default: _ASSERT(false); return -1; }}void CSeqGraphicPane::MZHH_SetScale(TModelUnit scale, const TModelPoint& point) { m_Renderer->SetScaleRef(scale, m_Renderer->GetFeatGlPane().GetScaleY(), point); m_VisibleRangeChanged = true; // visible range changed redraw();}void CSeqGraphicPane::MZHH_ZoomRect(const TModelRect& rc){ m_VisibleRangeChanged = true; // visible range changed ZoomOnRange( TSeqRange(TSeqPos(rc.Left()), TSeqPos(rc.Right())) );}void CSeqGraphicPane::MZHH_Scroll(TModelUnit d_x, TModelUnit d_y){ const TModelRect& rc = m_Renderer->GetFeatGlPane().GetVisibleRect(); Scroll(rc.Left() + d_x, 0);}TVPUnit CSeqGraphicPane::MZHH_GetVPPosByY(int y) const{ return h() - 1 - y;}void CSeqGraphicPane::MZHH_Redraw(void){ redraw();}// IMouseZoomHandlerHost end// IMouseScrollHandlerHost implementation/*void CSeqGraphicPane::MSHH_Scroll(TVPUnit v_x){ m_Renderer->Scroll(v_x); m_VisibleRangeChanged = true; // visible range changed}void CSeqGraphicPane::MSHH_Redraw(void){ redraw();}*/// IMouseScrollHandlerHost end/// ISelHandlerHost implementationvoid CSeqGraphicPane::SHH_Redraw(){ parent()->parent()->do_callback(parent()->parent()); redraw();}TModelUnit CSeqGraphicPane::SHH_GetModelByWindow(int z, EOrientation orient){ switch(orient) { case eHorz: return m_Renderer->GetRulerGlPane().UnProjectX(z); case eVert: return m_Renderer->GetRulerGlPane().UnProjectY(h() - z); default: _ASSERT(false); return -1; }}TVPUnit CSeqGraphicPane::SHH_GetWindowByModel(TModelUnit z, EOrientation orient){ switch(orient) { case eHorz: return m_Renderer->GetRulerGlPane().ProjectX(z); case eVert: return h() - m_Renderer->GetRulerGlPane().ProjectY(z); default: _ASSERT(false); return -1; }}////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// ITooltip Implementation/// TC_NeedTooltip() and TC_GetTooltip() is evrything needed to show toolitps/// in "active" modebool CSeqGraphicPane::TC_NeedTooltip(int x, int y){ m_Renderer->GetTooltip(x, h() - y, &m_TooltipText); return m_TooltipText.length() > 0;}string CSeqGraphicPane::TC_GetTooltip(int& x, int& y, int& w, int& h){ return m_TooltipText;}// ITooltip end// --- Scrolling --------------------------------------------------void CSeqGraphicPane::Scroll(TModelUnit x, TModelUnit y){ m_Renderer->Scroll(x, y); m_VisibleRangeChanged = true; // indicate a visible range change redraw();}void CSeqGraphicPane::ZoomOnRange(const TSeqRange& range){ m_Renderer->ZoomOnRange(range);}TSeqRange CSeqGraphicPane::GetVisibleRange() const{ return m_Renderer->GetVisibleRange();}bool CSeqGraphicPane::VisibleRangeChanged() const{ return m_VisibleRangeChanged;}void CSeqGraphicPane::ResetVisibleRangeChanged(){ m_VisibleRangeChanged = false;}void CSeqGraphicPane::GetFeatureNames(vector<string>& names){ names.clear(); const CFeatConfigList& feat_list = *GetFeatConfigList(); ITERATE (CFeatConfigList, iter, feat_list) { names.push_back(iter->GetDescription()); }}void CSeqGraphicPane::SetConfig(CRef<CSeqGraphicConfig> config){ m_ConfigSettings = config; m_Renderer->SetConfig(m_ConfigSettings);} void CSeqGraphicPane::UpdateConfig(){ m_Renderer->UpdateConfig(); redraw();}// CGlPaneWidgetChild requirementsTVPPoint CSeqGraphicPane::GetPortSize(void) { return TVPPoint(0,0); }// Zoom command handlersvoid CSeqGraphicPane::ZoomIn(void){ m_Renderer->ZoomInCenter(); redraw();}void CSeqGraphicPane::ZoomOut(void){ m_Renderer->ZoomOutCenter(); redraw();}void CSeqGraphicPane::ZoomAll(void){ m_Renderer->ZoomAll(); redraw();}void CSeqGraphicPane::ZoomObject(void){ if (m_LastSelObj) { TSeqRange range = m_LastSelLayoutObj->GetLocation().GetTotalRange(); ZoomOnRange(range); redraw(); }}void CSeqGraphicPane::NextPrevExon(EDirection dir){ if (!m_LastSelObj) return; const CLayoutFeat* feat = dynamic_cast<const CLayoutFeat*>(m_LastSelObj.GetPointer()); if (!feat) return; TModelRect rc = m_Renderer->GetFeatGlPane().GetVisibleRect(); TSeqPos center_x = TSeqPos( rc.CenterPoint().X() ); TSeqPos d_x = INT_MAX; ITERATE (vector<TSeqRange>, iter, feat->GetIntervals()) { const TSeqRange& curr = *iter; if (dir == eNext) { // Next exon if (curr.GetFrom() > center_x) d_x = min(d_x, curr.GetFrom() - center_x); if (curr.GetTo() > center_x) d_x = min(d_x, curr.GetTo() - center_x); } if (dir == ePrev) { // Prev exon if (center_x > curr.GetFrom()) d_x = min(d_x, center_x - curr.GetFrom()); if (center_x > curr.GetTo()) d_x = min(d_x, center_x - curr.GetTo()); } } if (d_x > 0 && d_x < INT_MAX) { // need scroll if (dir == eNext) Scroll(rc.Left() + d_x, 0); if (dir == ePrev) Scroll(rc.Left() - d_x, 0); redraw(); }}void CSeqGraphicPane::x_OnShowPopup() { if (m_ParentWidget) { m_ParentWidget->OnShowPopup(); }}// handlers specific implementationint CSeqGraphicPane::x_GetAreaByMousePos(){ int vp_x = Fl::event_x(); int vp_y = h() - Fl::event_y(); const TVPRect& rc_zoom = m_Renderer->GetFeatGlPane().GetViewport(); const TVPRect& rc_select = m_Renderer->GetRulerGlPane().GetViewport(); // Deside where the mouse is: if(rc_zoom.PtInRect(vp_x, vp_y)) { return fFeaturesArea; } else if(rc_select.PtInRect(vp_x, vp_y)) { return fSeqRulerArea; } return fOther;}END_NCBI_SCOPE/* * =========================================================================== * $Log: seqgraphic_pane.cpp,v $ * Revision 1000.2 2004/06/01 21:12:53 gouriano * PRODUCTION: UPGRADED [GCC34_MSVC7] Dev-tree R1.31 * * Revision 1.31 2004/05/21 22:27:55 gorelenk * Added PCH ncbi_pch.hpp * * Revision 1.30 2004/05/10 15:06:32 lebedev * Offset HTML Active areas by the height of the ruler bar * * Revision 1.29 2004/05/07 15:43:36 dicuccio * Use CObjClipboard * * Revision 1.28 2004/05/03 13:23:58 dicuccio * gui/utils --> gui/objutils where needed * * Revision 1.27 2004/04/19 15:43:21 lebedev * Code cleanup * * Revision 1.26 2004/04/16 14:53:04 dicuccio * Pass objects using TConstObjects, not TObjSelections. Added ISelection * interfaces. * * Revision 1.25 2004/04/15 13:02:13 lebedev * HitTesting for LayoutObjects changed * * Revision 1.24 2004/04/12 18:48:34 dicuccio * Removed five pixel border from the graphical view * * Revision 1.23 2004/04/07 13:12:19 dicuccio * Split GetAnnotSelector() API for features to use feature sbtype separately from * feature type * * Revision 1.22 2004/04/06 13:45:31 dicuccio * Formatting changes * * Revision 1.21 2004/03/23 12:33:56 lebedev * Made sequence and histograms bars a layout objects in the object panel. * Made segment map a number of layout objects. Get rid of fixed size rows in the object panel. * * Revision 1.20 2004/03/12 15:59:00 lebedev * Command handlers for zooming and feature navigation added. * * Revision 1.19 2004/03/11 17:53:06 dicuccio * Deprecated typedefs TPosition, TDimension, TIndex, TColor. Use TSeqRange instead of TRange * * Revision 1.18 2004/03/08 17:00:03 lebedev * Zooming clicking and holding the mouse button added. 'I' key to zoom in and * 'Shift-I' key to zoom out. * * Revision 1.17 2004/03/05 18:04:35 ucko * Revert previous revision, as eLensZoomState has now materialized. * * Revision 1.16 2004/03/05 03:02:46 ucko * Don't try to use CGUIEvent::eLensZoomState, which hasn't yet been defined.... * * Revision 1.15 2004/03/04 14:38:57 lebedev * Avoid event handlers conflicts by inheriting from CGlPaneWidgetChild. * Support for new mouse scroll handler added. Re-enable lens zoom (L key). * * Revision 1.14 2004/02/27 15:51:22 lebedev * Correctly handle eSelectState * * Revision 1.13 2004/02/13 18:11:32 lebedev * Use SeqGraphic config for enabling/disabling viewing options * * Revision 1.12 2004/02/10 13:15:33 lebedev * ISelHandlerHost interface implemented for selections on sequence pane * * Revision 1.11 2004/02/04 14:33:00 dicuccio * Return 1 from all handled events in handle() * * Revision 1.10 2004/02/03 16:54:43 dicuccio * Event handler clean-up. Dropped explicit handling of zomm events in favor of * IMouseEventHandler interface functions * * Revision 1.9 2004/01/30 21:10:01 dicuccio * Reworked event loop to use CGUIEvent entirely. Added handling of * copy-to-clipboard * * Revision 1.8 2004/01/28 14:10:00 lebedev * Indicate a visible range change where needed * * Revision 1.7 2004/01/27 16:14:19 lebedev * Changed stored selection from CLayoutObject to CObject * * Revision 1.6 2004/01/20 20:35:30 rsmith * Add UpdateConfig method to notify classes when the configuration object has changed. * * Revision 1.5 2004/01/20 14:08:44 rsmith * CFeatConfigList knows about feature descriptions and types, not the configuration object. * * Revision 1.4 2004/01/16 13:40:15 lebedev * Tooltips added * * Revision 1.3 2004/01/05 21:24:28 dicuccio * Code clean-up. Removed dead code. * * Revision 1.2 2003/12/29 14:54:13 rsmith * config classes no longer contain the list of feature types. Use GetFeatConfigList() * * Revision 1.1 2003/12/22 12:59:00 lebedev * Files renamed * * Revision 1.60 2003/12/16 18:55:26 lebedev * ScaleRefPoint implementation fixed (do not project reference point into model space) * * Revision 1.59 2003/12/10 17:00:43 yazhuk * Updated implementation of IMouseZoomHandlerHost interface. * * Revision 1.58 2003/12/09 12:39:59 lebedev * Implemented IMouseZoomHandlerHost interface for zooming and scrolling with mouse * =========================================================================== */
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?