seqgraphic_pane.cpp
上传用户:yhdzpy8989
上传日期:2007-06-13
资源大小:13604k
文件大小:26k
- /*
- * ===========================================================================
- * PRODUCTION $Log: seqgraphic_pane.cpp,v $
- * PRODUCTION Revision 1000.2 2004/06/01 21:12:53 gouriano
- * PRODUCTION PRODUCTION: UPGRADED [GCC34_MSVC7] Dev-tree R1.31
- * PRODUCTION
- * ===========================================================================
- */
- /* $Id: seqgraphic_pane.cpp,v 1000.2 2004/06/01 21:12:53 gouriano Exp $
- * ===========================================================================
- *
- * PUBLIC DOMAIN NOTICE
- * National Center for Biotechnology Information
- *
- * This software/database is a "United States Government Work" under the
- * terms of the United States Copyright Act. It was written as part of
- * the author's official duties as a United States Government employee and
- * thus cannot be copyrighted. This software/database is freely available
- * to the public for use. The National Library of Medicine and the U.S.
- * Government have not placed any restriction on its use or reproduction.
- *
- * Although all reasonable efforts have been taken to ensure the accuracy
- * and reliability of the software and data, the NLM and the U.S.
- * Government do not and cannot warrant the performance or results that
- * may be obtained by using this software or data. The NLM and the U.S.
- * Government disclaim all warranties, express or implied, including
- * warranties of performance, merchantability or fitness for any particular
- * purpose.
- *
- * Please cite the author in any work or product based on this material.
- *
- * ===========================================================================
- *
- * Authors: Vlad Lebedev
- *
- */
- #include <ncbi_pch.hpp>
- #include "seqgraphic_pane.hpp"
- #include <gui/utils/fltk_utils.hpp>
- #include <gui/objutils/obj_clipboard.hpp>
- #include <gui/widgets/seq_graphic/seqgraphic_conf.hpp>
- #include <gui/config/feat_config_list.hpp>
- #include <objmgr/util/feature.hpp>
- #include <util/regexp.hpp>
- #include <algorithm>
- #include <math.h>
- #include <FL/glut.H>
- #include <FL/fl_draw.H>
- BEGIN_NCBI_SCOPE
- const TModelUnit kMouseZoomFactor = 25.0; // per pixel of mouse movement
- CSeqGraphicPane::CSeqGraphicPane(int x, int y, int w, int h)
- : CGlPaneWidgetChild(x, y, w, h, "")
- {
- m_VisibleRangeChanged = false;
- m_Renderer.Reset(new CSeqGraphicRenderer());
-
- m_Event.StandardConfig();
-
- // Register additional widget-specific states
- // ZoomIn, ZoomOut and Lense Zoom:
- m_Event.RegisterState(CGUIEvent::eInsZoomStateIn, 0, 'i');
- m_Event.RegisterState(CGUIEvent::eInsZoomStateOut, CGUIEvent::fShift, 'i');
- m_Event.RegisterState(CGUIEvent::eLensZoomState, 0, 'l');
-
- /**
- m_Event.RegisterState(eLensZoomState, 0, 'l');
- m_Event.RegisterState(eZoomInState, 0, '+');
- m_Event.RegisterState(eZoomOutState, 0, '-');
- m_Event.RegisterState(eZoomInFullState, 0, '*');
- m_Event.RegisterState(eZoomOutFullState, 0, '=');
- **/
- m_TimerActive = false;
- //m_MouseScrollHandler.SetHost(static_cast<IMouseScrollHandlerHost*>(this));
- //x_RegisterHandler(dynamic_cast<IEventHandler*>(&m_MouseScrollHandler), fScrollArea, &m_Renderer->GetFixedGlPane());
- m_MouseZoomHandler.SetHost(static_cast<IMouseZoomHandlerHost*>(this));
- x_RegisterHandler(dynamic_cast<IEventHandler*>(&m_MouseZoomHandler), fFeaturesArea, &m_Renderer->GetFeatGlPane());
-
- m_SelHandler.SetHost(static_cast<ISelHandlerHost*>(this));
- x_RegisterHandler(dynamic_cast<IEventHandler*>(&m_SelHandler), fSeqRulerArea, &m_Renderer->GetRulerGlPane());
-
- m_Tooltip.EnableActiveMode(static_cast<ITooltipClient*>(this));
- m_Tooltip.SetMode(CTooltip::eHideOnMove);
- }
- CSeqGraphicPane::~CSeqGraphicPane()
- {
- }
- void CSeqGraphicPane::SetDataSource(CSeqGraphicDataSource* ds)
- {
- TVPRect rc(0, 0, w() - 0, h() - 0);
- m_Renderer->SetDataSource(rc, ds);
- m_DS.Reset(ds);
-
- m_SelHandler.ResetSelection(false);
-
- invalidate();
- redraw();
- }
- void CSeqGraphicPane::SetWidget(CSeqGraphicWidget* widget)
- {
- m_ParentWidget = widget;
- }
- // Set/Clear selection
- void CSeqGraphicPane::SelectObject(const CObject* obj)
- {
- if (!obj) {
- return;
- }
-
- m_LastSelObj.Reset(obj);
-
- m_Renderer->SelectObject(obj);
- redraw();
- }
- void CSeqGraphicPane::SelectSeqLoc(const CSeq_loc* loc)
- {
- TRangeColl r = TRangeColl( loc->GetTotalRange() );
- m_SelHandler.SetSelection(r, false);
- redraw();
- }
- void CSeqGraphicPane::ClearSelection()
- {
- m_SelHandler.ResetSelection(false);
- m_Renderer->ClearObjectSelection();
-
- redraw();
- }
- // retrieve the selections from our renderer
- const TConstObjects& CSeqGraphicPane::GetSelectedObjects(void) const
- {
- return m_Renderer->GetSelectedObjects();
- }
- const CSeqGraphicPane::TRangeColl&
- CSeqGraphicPane::GetSelectedSeqRanges(void) const
- {
- return m_SelHandler.GetSelection();
- }
- const CSeqGraphicDataSource* CSeqGraphicPane::GetDataSource(void) const
- {
- return m_DS.GetPointer();
- }
- void CSeqGraphicPane::SetZoomX(float value)
- {
- m_Renderer->SetZoomX(value);
- // indicate a visible range change
- m_VisibleRangeChanged = true;
- invalidate();
- redraw();
- }
- int CSeqGraphicPane::SearchFeature(string pattern,
- string feature, bool is_local)
- {
- m_SearchResults.clear();
- m_SearchIndex = 0;
-
- int (*pf)(int) = tolower; // explicit cast to resolve the ambiguity
-
- const TModelRect& rc = is_local ?
- m_Renderer->GetFeatGlPane().GetVisibleRect() :
- m_Renderer->GetFeatGlPane().GetModelLimitsRect();
-
- TSeqRange range = TSeqRange(TSeqPos(rc.Left()), TSeqPos(rc.Right()));
-
- std::transform(pattern.begin(), pattern.end(),
- pattern.begin(), pf);
- CRegexp exp_pattern(pattern);
-
- int type, sub_type;
- GetFeatConfigList()->GetTypeSubType(feature, type, sub_type);
- SAnnotSelector selector =
- CSeqUtils::GetAnnotSelector
- (static_cast<CSeqFeatData::ESubtype>(sub_type));
-
- CLayoutFeat::TFeatList feats;
- CSeqUtils::GetFeatures(m_DS->GetBioseqHandle(), range, selector, feats);
- NON_CONST_ITERATE (CLayoutFeat::TFeatList, iter, feats) {
- CLayoutFeat& feat = **iter;
-
- string label;
- feature::GetLabel(feat.GetFeature(), &label,
- feature::eContent,
- &m_DS->GetBioseqHandle().GetScope());
-
- std::transform(label.begin(), label.end(), label.begin(), pf);
-
- if (exp_pattern.GetMatch(label.c_str()).length() > 0) {
- m_SearchResults.push_back(*iter);
- }
- }
- if (m_SearchResults.size() > 0)
- m_Renderer->ZoomOnObject(m_SearchResults[m_SearchIndex]); // actual zoom
-
-
- invalidate();
- redraw();
-
- return m_SearchResults.size();
- }
- int CSeqGraphicPane::SearchFeatureNext()
- {
- if (m_SearchIndex < m_SearchResults.size() - 1) {
- ++m_SearchIndex;
- m_Renderer->ZoomOnObject(m_SearchResults[m_SearchIndex]);
-
- invalidate();
- redraw();
- }
- return m_SearchIndex;
- }
- int CSeqGraphicPane::SearchFeaturePrev()
- {
- if (m_SearchIndex > 0) {
- m_SearchIndex--;
- m_Renderer->ZoomOnObject(m_SearchResults[m_SearchIndex]);
-
- invalidate();
- redraw();
- }
- return m_SearchIndex;
- }
- void CSeqGraphicPane::x_AdjustScrollBars(void)
- {
- Fl_Scrollbar* scrollX = (Fl_Scrollbar*)(parent()->parent()->child(0));
- Fl_Scrollbar* scrollY = (Fl_Scrollbar*)(parent()->parent()->child(1));
- scrollX->linesize(1);
- scrollY->linesize(1);
-
- const TModelRect& rcV = m_Renderer->GetFeatGlPane().GetVisibleRect();
- const TModelRect& rcM = m_Renderer->GetFeatGlPane().GetModelLimitsRect();
-
- scrollX->value(int(rcV.Left()), int(rcV.Width()), 0, int(rcM.Width()-1));
-
- if (m_Renderer->GetFeatGlPane().NeedsScrollX()) {
- scrollX->show();
- } else {
- scrollX->hide();
- }
- scrollX->linesize( int(m_Renderer->GetScrollLineSize()) );
- scrollY->value(int(rcV.Top()), abs(int(rcV.Height())),
- 0, abs(int(rcM.Height())) );
- /*if (m_Renderer->NeedsScrollY()) {
- scrollY->show();
- } else {
- scrollY->hide();
- }*/
- }
- void CSeqGraphicPane::x_AdjustZoomSlider(void)
- {
- Fl_Value_Slider* m_SlideZoomX =
- (Fl_Value_Slider*)(parent()->parent()->child(2));
-
- m_SlideZoomX->range(0, 1);
- m_SlideZoomX->value(m_Renderer->GetZoomX());
- m_SlideZoomX->step(0.001);
- }
- void CSeqGraphicPane::x_Render()
- {
- if (!valid()) {
- TVPRect rc(0, 0, w() - 0, h() - 0);
- m_Renderer->Resize(rc);
- }
-
- glClearColor(1, 1, 1, 0);
- glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
- if ( !m_DS ) {
- return;
- }
-
- m_Renderer->Render();
-
- // ZoomHandler indicator and Linear selection
- glEnable(GL_BLEND);
- glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
- m_MouseZoomHandler.Render(m_Renderer->GetFeatGlPane());
-
- //m_MouseScrollHandler.Render(m_Renderer->GetFixedGlPane());
- // draw linear selection
- CGlColor m_SelGray (0.5f, 0.5f, 0.5f, 0.20f);
- CGlColor m_SelBlue (0.0f, 0.0f, 0.5f, 0.50f);
- CGlColor m_SelBlueBorder(0.0f, 0.0f, 0.6f, 0.55f);
-
-
- // draw linear selection
- m_SelHandler.SetColor(CLinearSelHandler::eSelection, m_SelBlue);
- m_SelHandler.SetColor(CLinearSelHandler::ePasssiveSelection, m_SelBlueBorder);
- m_SelHandler.Render(m_Renderer->GetRulerGlPane());
-
- m_SelHandler.SetColor(CLinearSelHandler::ePasssiveSelection, m_SelGray);
-
- // Linear selection handler does not honor EnableOffset flags yet
- // disable offsets before drawing and reenable them after
- m_Renderer->GetFeatGlPane().EnableOffset(false);
- m_SelHandler.Render(m_Renderer->GetFeatGlPane(), CLinearSelHandler::ePassiveState);
- m_Renderer->GetFeatGlPane().EnableOffset(true);
-
- glDisable(GL_BLEND);
-
- x_AdjustScrollBars();
- x_AdjustZoomSlider();
- }
- int CSeqGraphicPane::handle(int event)
- {
- int ev_x = Fl::event_x();
- int ev_y = Fl::event_y();
- CGUIEvent::EGUIState state = m_Event.GetGUIState();
- CGUIEvent::EGUISignal signal = m_Event.GetGUISignal();
-
- switch (state) {
- case CGUIEvent::eCopyState:
- x_Handle_ClipboardCopy();
- break;
- case CGUIEvent::eCutState:
- case CGUIEvent::ePasteState:
- case CGUIEvent::eUndoState:
- case CGUIEvent::eRedoState:
- // editing not yet supported
- break;
- case CGUIEvent::eSelectState:
- case CGUIEvent::eSelectIncState:
- if (signal == CGUIEvent::eSelectSignal) {
- const CLayoutObject* obj = m_Renderer->HitTest(ev_x, h()-ev_y);
- // Distinguish selection and incremental selection
- if (state == CGUIEvent::eSelectState) {
- m_Renderer->ClearObjectSelection();
- }
- // Save last clicked objects
- if (obj) {
- const CObject* sel_obj = obj->GetObject(
- TSeqPos(m_Renderer->GetFeatGlPane().UnProjectX(ev_x)) );
-
- m_LastSelLayoutObj.Reset(obj);
- SelectObject(sel_obj);
- }
- // double click zooms on the feature/alignment/etc
- if (Fl::event_clicks()) {
- m_Renderer->ZoomOnObject(obj);
- }
-
- // ping the callback on selection
- if (obj) {
- parent()->parent()->do_callback(parent()->parent());
- }
- redraw();
- }
- break;
- case CGUIEvent::ePopupState:
- break;
-
- case CGUIEvent::eInsZoomStateIn:
- case CGUIEvent::eInsZoomStateOut:
- m_ZoomingIn = state == CGUIEvent::eInsZoomStateIn;
- x_Handle_TimerZoom();
- break;
-
- case CGUIEvent::eLensZoomState:
- x_Handle_LensZoom();
- break;
-
- default:
- break;
- }
- // pass events to the tooltip object
- m_Tooltip.Handle(event);
-
- return CGlPaneWidgetChild::handle(event);
- }
- // called by Fl::add_timeout
- void s_CSeqGraphicPane_ZoomTimer(void* parent)
- {
- CSeqGraphicPane* pane = (CSeqGraphicPane*)parent;
- if (pane->m_TimerActive) { // still need zoom?
- CGlPane& ref_pane = pane->m_Renderer->GetFeatGlPane();
- TModelPoint ref_point = ref_pane.UnProject(pane->m_TimerX,
- pane->MZHH_GetVPPosByY(pane->m_TimerY));
- TModelUnit scaleX = ref_pane.GetScaleX();
- TModelUnit scaleY = ref_pane.GetScaleY();
- // Zoom In or Zoom Out
- scaleX = pane->m_ZoomingIn ? scaleX / 1.5f : scaleX * 1.5f;
-
- pane->m_Renderer->SetScaleRef(scaleX, scaleY, ref_point);
-
- pane->m_VisibleRangeChanged = true; // visible range changed
- pane->redraw();
- if (pane->m_TimerActive) // if still active
- Fl::add_timeout(0.25, s_CSeqGraphicPane_ZoomTimer, parent);
- }
- }
- void CSeqGraphicPane::x_Handle_TimerZoom()
- {
- switch(m_Event.GetFLTKEvent()) {
- case FL_PUSH:
- m_TimerActive = true;
- m_TimerX = Fl::event_x();
- m_TimerY = h() - Fl::event_y();
-
- s_CSeqGraphicPane_ZoomTimer(this);
- break;
- case FL_DRAG:
- m_TimerActive = false;
- break;
-
- case FL_RELEASE:
- m_TimerActive = false;
- break;
- default:
- break;
- } // switch (FLTK event)
- }
- void CSeqGraphicPane::x_Handle_LensZoom()
- {
- // it will make sence to move the Lens Zoom into separate handler
- // like mouse_scroll_handler
- switch(m_Event.GetFLTKEvent()) {
- 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 clipboard
- void 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 implementation
- TModelUnit 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 implementation
- void 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" mode
- bool 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 requirements
- TVPPoint CSeqGraphicPane::GetPortSize(void)
- {
- return TVPPoint(0,0);
- }
- // Zoom command handlers
- void 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 implementation
- int 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
- * ===========================================================================
- */