seqgraphic_render.cpp

来自「ncbi源码」· C++ 代码 · 共 755 行 · 第 1/2 页

CPP
755
字号
        // prevent Y from resizing in feature panel    TModelRect& rcV = m_FP.GetVisibleRect();    rcV.SetTop(0);    rcV.SetBottom( abs(m_FP.GetViewport().Height()) - 1 );    m_FP.SetVisibleRect(rcV);    m_MaxZoomX = log(m_FP.GetModelLimitsRect().Width() / rc.Width());}// this function takes an absolute mouse coordinate and determines if any// features lie underneath the mouse position// x & y are GL coordinatesconst CLayoutObject* CSeqGraphicRenderer::HitTest(int x, int y){    // Main Feature Panel    if (PanelHitTest(x, y) == eFeatures) {        return m_FeatPanel.HitTest(m_FP, x, y);    }    return NULL;}CSeqGraphicRenderer::TRendererPanelCSeqGraphicRenderer::PanelHitTest(int x, int y) const{    if (m_FP.GetViewport().PtInRect(x, y))        return eFeatures;    if (m_RP.GetViewport().PtInRect(x, y))        return eRuler;    return eNone;}void CSeqGraphicRenderer::GetTooltip(int x,                     int y, string* title){    *title = "";        const CLayoutObject* obj = HitTest(x, y);    if (!obj) return;        TRendererPanel pan = PanelHitTest(x, y);    if (pan == eFeatures)        m_FeatPanel.GetTooltip(obj, title);}void CSeqGraphicRenderer::SelectObject(const CObject* obj){    m_SelectedObjects.push_back(        CRef<CObject>(const_cast<CObject*>(obj)));}void CSeqGraphicRenderer::SetLensZoom(int x, int y){     TVPRect& rcFP = m_FP.GetViewport();    if (rcFP.PtInRect(x, y)) {        m_NeedLensZoom = true;        m_FP.OpenOrtho();        m_LensZoom = m_FP.UnProject(x, y);        m_FP.Close();    } else {        m_NeedLensZoom = false;    }}void CSeqGraphicRenderer::CancelLensZoom(){    m_NeedLensZoom = false;}float CSeqGraphicRenderer::GetZoomX(void) const{    TModelUnit scale_x = log(m_FP.GetScaleX());    return 1.0f - (scale_x - m_MinZoomX) / (m_MaxZoomX - m_MinZoomX);}void CSeqGraphicRenderer::SetZoomX(float value){//	cout << "In Renderer::SetZoomX" << endl;    // slider is set up from 0 to 1. Convert to our units:    TModelUnit scale = m_MinZoomX + (m_MaxZoomX - m_MinZoomX) * (1.0f - value);    NON_CONST_ITERATE(TGlPanes, iter, m_ScrollXPanes) {        CGlPane& pane = **iter;        pane.SetScale(exp(scale), pane.GetScaleY(),                       pane.GetVisibleRect().CenterPoint() );    }}void CSeqGraphicRenderer::ZoomInCenter(){    ITERATE(TGlPanes, iter, m_ScrollXPanes) {        (*iter)->ZoomInCenter();    }}void CSeqGraphicRenderer::ZoomOutCenter(){    ITERATE(TGlPanes, iter, m_ScrollXPanes) {        (*iter)->ZoomOutCenter();    }} void CSeqGraphicRenderer::ZoomAll(){    ITERATE(TGlPanes, iter, m_ScrollXPanes) {        (*iter)->ZoomAll();    }} void CSeqGraphicRenderer::SetScaleRef(TModelUnit scale_x, TModelUnit scale_y,                                       const TModelPoint& point){    if(scale_x > m_FP.GetMinScaleX())  {        ITERATE(TGlPanes, iter, m_ScrollXPanes) {            TModelPoint ref_p(point.X(),  (*iter)->GetVisibleRect().Top());                        // It may be a little confusing, but            // model space is setup differently in m_RP panel            (*iter)->SetScaleRefPoint(scale_x, *iter == &m_RP ? 1 : -1, ref_p);        }    }}void CSeqGraphicRenderer::ZoomOnObject(const CLayoutObject* obj){    if (!obj)         return;            TSeqRange range = obj->GetLocation().GetTotalRange();    ZoomOnRange(range);}void CSeqGraphicRenderer::ZoomOnRange(const TSeqRange& range){    NON_CONST_ITERATE(TGlPanes, iter, m_ScrollXPanes) {        CGlPane& pane = **iter;        TModelRect& rc = pane.GetVisibleRect();        //TModelUnit height = -rc.Height();        rc.SetLeft (range.GetFrom());        rc.SetRight(range.GetTo()  );        //rc.SetTop(0);        //rc.SetBottom(height);        //pane.SetVisibleRect(rc);        pane.ZoomRect(rc);    }}TSeqRange CSeqGraphicRenderer::GetVisibleRange() const{    const TModelRect& rc = m_FP.GetVisibleRect();    return TSeqRange( TSeqPos(rc.Left()), TSeqPos(rc.Right()) );}CGlPane& CSeqGraphicRenderer::GetFeatGlPane(){    return m_FP;}CGlPane& CSeqGraphicRenderer::GetRulerGlPane(){    return m_RP;}void CSeqGraphicRenderer::Scroll(TModelUnit x, TModelUnit y){    const TModelRect& rc = m_FP.GetVisibleRect();        double dX = x - rc.Left();    double dY = y - rc.Top();        // Handle horizintal scrollbar    ITERATE(TGlPanes, iter, m_ScrollXPanes) {        (*iter)->Scroll(dX, 0.0f);    }        // Handle vertical scrollbar    m_FP.Scroll(0.0f, dY);}TModelUnit CSeqGraphicRenderer::GetScrollLineSize(){    m_FP.OpenOrtho();    TModelUnit value = m_FP.UnProjectWidth(kMaxPixelsBase);    m_FP.Close();        return value;}    END_NCBI_SCOPE/* * =========================================================================== * $Log: seqgraphic_render.cpp,v $ * Revision 1000.7  2004/06/01 21:12:56  gouriano * PRODUCTION: UPGRADED [GCC34_MSVC7] Dev-tree R1.97 * * Revision 1.97  2004/05/31 00:29:47  dicuccio * Reverted changed with regard to background - use glClear() instead of * CGlBackground, avoids rendering artifact for now * * Revision 1.96  2004/05/21 22:27:55  gorelenk * Added PCH ncbi_pch.hpp * * Revision 1.95  2004/05/21 13:50:13  lebedev * Adjust object panel model space when using  ruler panel offsets * * Revision 1.94  2004/05/14 15:57:11  lebedev * Optional argument to specify the type of title/tooltip added * * Revision 1.93  2004/05/13 16:20:57  lebedev * Respect Ruler bar size for HTML active areas * * Revision 1.92  2004/05/12 16:54:12  lebedev * Added  option to specify a space between the ruler and the rest of the dispay * * Revision 1.91  2004/05/10 15:06:32  lebedev * Offset HTML Active areas by the height of the ruler bar * * Revision 1.90  2004/04/16 15:54:11  dicuccio * Removed dead code * * Revision 1.89  2004/04/14 11:25:48  lebedev * Added rendering of Mate Pairs. * * Revision 1.88  2004/04/06 13:44:17  dicuccio * Changed draw -> Render.  Changed resize -> Resize * * Revision 1.87  2004/03/31 16:08:58  lebedev * Methods to get HTML active areas added. * * Revision 1.86  2004/03/30 13:58:37  lebedev * Use elements colors from configuration instead of setting colors directly. * * Revision 1.85  2004/03/24 15:15:34  dicuccio * Changed include for renderer.  Added GetHeight().  Rewrote x_SetupViewports() * to handleviewports that have non-zero origins.  Changed clearing of background * - use CGlBackground indtead of glClear() * * Revision 1.84  2004/03/23 12:33:55  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.83  2004/03/12 15:58:15  lebedev * ZoomAll method added * * Revision 1.82  2004/03/11 17:53:06  dicuccio * Deprecated typedefs TPosition, TDimension, TIndex, TColor.  Use TSeqRange instead of TRange * * Revision 1.81  2004/03/04 14:39:27  lebedev * Re-enable lens zoom. * * Revision 1.80  2004/02/24 14:43:14  lebedev * Genome-scale rendering policy added * * Revision 1.79  2004/02/13 18:14:33  lebedev * Make use of new ILayoutPolicy interface * * Revision 1.78  2004/02/10 13:15:33  lebedev * ISelHandlerHost interface implemented for selections on sequence pane * * Revision 1.77  2004/01/29 14:11:54  dicuccio * Wrapped draw() in try/catch to minimize unhandled exceptions.  Use TSeqRange * instead of TRange * * Revision 1.76  2004/01/27 16:14:42  lebedev * Methods for working with selections added * * Revision 1.75  2004/01/20 20:34:12  rsmith * add ConfigureRenderPolicy and UpdateConfig methods, so that render policy can be changed on the fly. * * Revision 1.74  2004/01/16 18:43:56  dicuccio * Dropped const on GetTooltip() - cascade of const functions made inavlid by this * * Revision 1.73  2004/01/16 13:40:15  lebedev * Tooltips added * * Revision 1.72  2003/12/22 12:55:53  lebedev * Old files removed * * Revision 1.71  2003/12/16 18:56:37  lebedev * Introduced Rendering Policies for feature panels * * Revision 1.70  2003/12/09 12:40:00  lebedev * Implemented IMouseZoomHandlerHost interface for zooming and scrolling with mouse * * Revision 1.69  2003/11/20 12:22:33  lebedev * Changed model space coordinates for Ruler pane (missing ruler bug) * * Revision 1.68  2003/11/19 20:37:46  friedman * API to detect and reset visible range change * * Revision 1.67  2003/11/14 13:51:49  lebedev * Do not scroll ruler bar vertically * * Revision 1.66  2003/11/13 19:11:07  lebedev * Objects selection reorganized. One row ofset bug in selection fixed * * Revision 1.65  2003/11/13 15:31:53  lebedev * Methods to get visible sequence range added * * Revision 1.64  2003/11/04 17:00:39  lebedev * Reverse and Compliment the sequence displayed under CDSs and Proteins on negative strand * * Revision 1.63  2003/11/04 12:43:06  lebedev * Ruler bar added * * Revision 1.62  2003/10/31 19:06:43  yazhuk * Fixed "mouse zoom drifting" bug. * * Revision 1.61  2003/10/30 13:21:59  lebedev * Display of master sequence under selected CDSs and Proteins added * * Revision 1.60  2003/10/28 19:01:43  dicuccio * Fixed compilation errors.  Pass CBioseq_Handle by const-ref and store as value, * not as pointer * * Revision 1.59  2003/10/28 15:29:07  lebedev * Use new configuration library * * Revision 1.58  2003/10/24 13:59:56  lebedev * Make vertical scrollbar always visible * * Revision 1.57  2003/10/24 13:25:56  lebedev * Use logarithmic scale fo zoom. * Better scrolling in sequence pane. * * Revision 1.56  2003/10/22 18:32:56  lebedev * Histogram display of features added (and compressed display) * Zoom to mouse and scroll with mouse added. * * Revision 1.55  2003/10/21 13:44:48  lebedev * Variable renamed to solve name conflict in CodeWarrior * * Revision 1.54  2003/10/10 15:29:11  lebedev * Selection on a sequence and icon view added * * Revision 1.53  2003/10/10 12:57:48  lebedev * Zoom sensitivity reduced * * Revision 1.52  2003/10/09 17:59:38  lebedev * Compilation error fixed * * Revision 1.51  2003/10/09 16:27:09  lebedev * Widget redesign: Use independent IRenderable panels for display * * =========================================================================== */

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?