seqgraphic_pane.hpp
上传用户:yhdzpy8989
上传日期:2007-06-13
资源大小:13604k
文件大小:14k
- /*
- * ===========================================================================
- * PRODUCTION $Log: seqgraphic_pane.hpp,v $
- * PRODUCTION Revision 1000.1 2004/04/16 17:51:18 gouriano
- * PRODUCTION PRODUCTION: UPGRADED [CATCHUP_003] Dev-tree R1.17
- * PRODUCTION
- * ===========================================================================
- */
- #ifndef GUI_WIDGETS_SEQ_GRAPHIC___SEQGRAPHIC_PANE__HPP
- #define GUI_WIDGETS_SEQ_GRAPHIC___SEQGRAPHIC_PANE__HPP
- /* $Id: seqgraphic_pane.hpp,v 1000.1 2004/04/16 17:51:18 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
- *
- * File Description:
- * Pane for the Graphic Sequence Widget
- * (see <gui/widgets/seq_graphic/seqgraphic_widget.hpp>)
- *
- */
- #include <gui/widgets/seq_graphic/seqgraphic_render.hpp>
- #include <gui/gui.hpp>
- #include <gui/opengl.h>
- #include <gui/opengl/glcanvas2d.hpp>
- #include <gui/widgets/seq_graphic/seqgraphic_ds.hpp>
- #include <gui/widgets/seq_graphic/seqgraphic_widget.hpp>
- #include <gui/widgets/seq_graphic/seqgraphic_conf.hpp>
- //#include <gui/widgets/seq_graphic/mouse_scroll_handler.hpp>
- #include <gui/widgets/gl/linear_sel_handler.hpp>
- #include <gui/widgets/gl/mouse_zoom_handler.hpp>
- #include <gui/widgets/gl/glpane_widget.hpp>
- #include <gui/widgets/fl/tooltip.hpp>
- #include <FL/Fl.H>
- #include <FL/Fl_Slider.H>
- BEGIN_NCBI_SCOPE
- class CSeqGraphicPane : public CGlPaneWidgetChild,
- public IMouseZoomHandlerHost, // for zooming with mouse
- //public IMouseScrollHandlerHost, // for scrolling with mouse
- // in the sequence overview panel
- public ISelHandlerHost, // for linear selection
- public ITooltipClient // for using with "active" CTooltip
- {
- public:
- typedef CLinearSelHandler::TRangeColl TRangeColl;
-
- // special GUI states
- enum {
- eLensZoomState = (1<<8),
- eZoomInState,
- eZoomOutState,
- eZoomInFullState,
- eZoomOutFullState
- };
-
- // Feature navigation
- enum EDirection {
- eNext,
- ePrev
- };
- CSeqGraphicPane(int x, int y, int w, int h);
- virtual ~CSeqGraphicPane();
- void SetWidget(CSeqGraphicWidget* widget);
- void SetDataSource(CSeqGraphicDataSource* ds);
- const CSeqGraphicDataSource* GetDataSource(void) const;
- void GetFeatureNames(vector<string>& names);
-
- void ShowFeature(CSeqFeatData::E_Choice t,
- CSeqFeatData::ESubtype s, bool flag);
- bool IsFeatureShown(CSeqFeatData::E_Choice t,
- CSeqFeatData::ESubtype s);
- int SearchFeature(string pattern, string feature, bool is_local);
- int SearchFeatureNext();
- int SearchFeaturePrev();
-
- float GetZoomX(void) const;
- void SetZoomX (float value);
- void ZoomOnRange(const TSeqRange& range);
-
- // returns the visible sequence range
- TSeqRange GetVisibleRange(void) const;
-
- // indicates visible sequence range has changes
- bool VisibleRangeChanged() const;
- void ResetVisibleRangeChanged();
- void Scroll(TModelUnit x, TModelUnit y);
-
- void SetConfig(CRef<CSeqGraphicConfig> config);
-
- /// the config object just changed. Do what is necessary.
- void UpdateConfig();
- // set/clear selections
- //void SelectObject(const CLayoutObject* obj);
- void SelectObject(const CObject* obj);
- void SelectSeqLoc(const CSeq_loc* loc);
- void ClearSelection();
- // retrieve the selections from our renderer
- const TConstObjects& GetSelectedObjects(void) const;
- const TRangeColl& GetSelectedSeqRanges(void) const;
- // IMouseZoomHandlerHost implementation
- virtual TModelUnit MZHH_GetScale(EScaleType type);
- virtual void MZHH_SetScale(TModelUnit scale, const TModelPoint& point);
- virtual void MZHH_ZoomRect(const TModelRect& rc);
- virtual void MZHH_Scroll(TModelUnit d_x, TModelUnit d_y);
- virtual TVPUnit MZHH_GetVPPosByY(int y) const;
- virtual void MZHH_Redraw(void);
- // IMouseZoomHandlerHost end
- // IMouseScrollHandlerHost implementation
- //virtual void MSHH_Scroll(TVPUnit v_x);
- //virtual TVPUnit MSHH_GetVPPosByX(int y) const;
- //virtual void MSHH_Redraw(void);
- // IMouseScrollHandlerHost end
-
- // ISelHandlerHost implementation
- virtual void SHH_Redraw();
- virtual TModelUnit SHH_GetModelByWindow(int z, EOrientation orient);
- virtual TVPUnit SHH_GetWindowByModel(TModelUnit z, EOrientation orient);
- // ISelHandlerHost end
- // ITooltipClient implementation
- virtual bool TC_NeedTooltip(int x, int y);
- virtual string TC_GetTooltip(int& x, int& y, int& w, int& h);
- // ITooltipClient end
- public:
- // command handlers
- void ZoomIn(void);
- void ZoomOut(void);
- void ZoomAll(void);
- void ZoomObject(void);
- void NextPrevExon(EDirection dir);
-
- protected:
- enum EHandlerArea {
- fFeaturesArea = 0x1,
- fSeqRulerArea = 0x2,
- fScrollArea = 0x4,
- fOther = 0x80000000,
- fAllAreas = fFeaturesArea | fSeqRulerArea | fScrollArea | fOther
- };
- int x_GetAreaByMousePos();
- void x_OnShowPopup();
- friend void s_CSeqGraphicPane_ZoomTimer(void*);
-
- private:
- CRef<CSeqGraphicDataSource> m_DS;
- CRef<CSeqGraphicRenderer> m_Renderer;
- CRef<CSeqGraphicConfig> m_ConfigSettings;
-
- // always store the last selected object
- CConstRef<CObject> m_LastSelObj;
- CConstRef<CLayoutObject> m_LastSelLayoutObj;
-
- CSeqGraphicWidget* m_ParentWidget;
-
- CLinearSelHandler m_SelHandler;
- CMouseZoomHandler m_MouseZoomHandler;
- //CMouseScrollHandler m_MouseScrollHandler;
- // For Tooltips
- CTooltip m_Tooltip;
- string m_TooltipText;
-
- // For Searches
- CLayoutFeat::TFeatList m_SearchResults;
- size_t m_SearchIndex;
- // indicate visible sequence range changes
- bool m_VisibleRangeChanged;
-
- // Timer-specific
- bool m_TimerActive;
- bool m_ZoomingIn; // zooming In or Out
- TVPUnit m_TimerX, m_TimerY;
- void x_Render();
- virtual int handle(int event);
-
- TVPPoint GetPortSize(void);
- // --- Methods
- void x_AdjustScrollBars (void);
- void x_AdjustZoomSlider (void);
-
- // Event Handlers
- void x_Handle_ClipboardCopy(void);
- void x_Handle_LensZoom (void);
- void x_Handle_TimerZoom (void);
- };
- END_NCBI_SCOPE
- /*
- * ===========================================================================
- * $Log: seqgraphic_pane.hpp,v $
- * Revision 1000.1 2004/04/16 17:51:18 gouriano
- * PRODUCTION: UPGRADED [CATCHUP_003] Dev-tree R1.17
- *
- * Revision 1.17 2004/04/16 14:53:04 dicuccio
- * Pass objects using TConstObjects, not TObjSelections. Added ISelection
- * interfaces.
- *
- * Revision 1.16 2004/04/15 13:02:13 lebedev
- * HitTesting for LayoutObjects changed
- *
- * Revision 1.15 2004/03/24 15:48:55 dicuccio
- * Restored inadvertent delete
- *
- * Revision 1.13 2004/03/24 15:14:32 dicuccio
- * Changed #include for renderer
- *
- * Revision 1.12 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.11 2004/03/12 15:59:00 lebedev
- * Command handlers for zooming and feature navigation added.
- *
- * Revision 1.10 2004/03/11 17:53:06 dicuccio
- * Deprecated typedefs TPosition, TDimension, TIndex, TColor. Use TSeqRange instead of TRange
- *
- * Revision 1.9 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.8 2004/03/04 14:38:56 lebedev
- * Avoid event handlers conflicts by inheriting from CGlPaneWidgetChild.
- * Support for new mouse scroll handler added. Re-enable lens zoom (L key).
- *
- * Revision 1.7 2004/02/13 18:11:32 lebedev
- * Use SeqGraphic config for enabling/disabling viewing options
- *
- * Revision 1.6 2004/02/10 13:15:33 lebedev
- * ISelHandlerHost interface implemented for selections on sequence pane
- *
- * Revision 1.5 2004/01/30 21:10:01 dicuccio
- * Reworked event loop to use CGUIEvent entirely. Added handling of
- * copy-to-clipboard
- *
- * Revision 1.4 2004/01/27 16:14:19 lebedev
- * Changed stored selection from CLayoutObject to CObject
- *
- * Revision 1.3 2004/01/20 20:35:30 rsmith
- * Add UpdateConfig method to notify classes when the configuration object has changed.
- *
- * Revision 1.2 2004/01/16 13:40:15 lebedev
- * Tooltips added
- *
- * Revision 1.1 2003/12/22 12:59:01 lebedev
- * Files renamed
- *
- * Revision 1.31 2003/12/16 18:55:26 lebedev
- * ScaleRefPoint implementation fixed (do not project reference point into model space)
- *
- * Revision 1.30 2003/12/10 17:00:26 yazhuk
- * Updated implementation of IMouseZoomHandlerHost interface.
- *
- * Revision 1.29 2003/12/09 12:40:00 lebedev
- * Implemented IMouseZoomHandlerHost interface for zooming and scrolling with mouse
- *
- * Revision 1.28 2003/11/19 20:37:46 friedman
- * API to detect and reset visible range change
- *
- * Revision 1.27 2003/11/13 15:31:52 lebedev
- * Methods to get visible sequence range added
- *
- * Revision 1.26 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.25 2003/10/28 15:29:07 lebedev
- * Use new configuration library
- *
- * Revision 1.24 2003/10/24 13:25:56 lebedev
- * Use logarithmic scale fo zoom.
- * Better scrolling in sequence pane.
- *
- * Revision 1.23 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.22 2003/10/10 15:29:11 lebedev
- * Selection on a sequence and icon view added
- *
- * Revision 1.21 2003/10/09 16:27:09 lebedev
- * Widget redesign: Use independent IRenderable panels for display
- *
- * Revision 1.20 2003/08/18 16:18:33 lebedev
- * New methods to show/hide features added
- *
- * Revision 1.19 2003/08/14 18:39:46 lebedev
- * Search of features in the widget added.
- * Display panels are fully configurable now. Use feature type and subtype
- * combination to identify and configure features in the display. Some code
- * cleanup.
- *
- * Revision 1.18 2003/07/23 19:13:41 dicuccio
- * Added API to retrieve the value of a configured parameter
- *
- * Revision 1.17 2003/07/22 13:40:22 lebedev
- * Highlign master sequence in the alignment display
- * Anchor master sequence. In Lens 10x mode show viewing range on the
- * sequence bar. Improved (faster) drawing of STSs and Repeat regions.
- *
- * Revision 1.16 2003/07/21 19:36:42 dicuccio
- * Externalized selections. Make sure to call the correct base class when
- * passing to the base class. Moved some initialization into intializer lists.
- *
- * Revision 1.15 2003/07/18 18:16:14 lebedev
- * Get rid of static variable in handle method
- *
- * Revision 1.14 2003/06/20 14:55:21 dicuccio
- * Minor clean-ups. Changed derivation of the graphical widget from Fl_Gl_Window
- * to CGlCanvas2d
- *
- * Revision 1.13 2003/06/13 12:40:42 dicuccio
- * Modified handle() to use processed events from CFltkEvent
- *
- * Revision 1.12 2003/06/12 19:49:34 dicuccio
- * Derive CSeqGraphicRenderer from CObject; manage as CRef<> in panel
- *
- * Revision 1.11 2003/06/11 11:10:58 lebedev
- * New method to specify viewing area added
- *
- * Revision 1.10 2003/06/10 12:01:58 lebedev
- * Rendering engine separated from FLTK into it's own class
- *
- * Revision 1.9 2003/06/05 11:22:32 lebedev
- * Prepare to separate display renderer from the widget itself
- *
- * Revision 1.8 2003/06/03 16:20:11 lebedev
- * FLTK calls removed from feature rendering engine. Minor clean-up.
- *
- * Revision 1.7 2003/06/02 16:06:29 dicuccio
- * Rearranged src/objects/ subtree. This includes the following shifts:
- * - src/objects/asn2asn --> arc/app/asn2asn
- * - src/objects/testmedline --> src/objects/ncbimime/test
- * - src/objects/objmgr --> src/objmgr
- * - src/objects/util --> src/objmgr/util
- * - src/objects/alnmgr --> src/objtools/alnmgr
- * - src/objects/flat --> src/objtools/flat
- * - src/objects/validator --> src/objtools/validator
- * - src/objects/cddalignview --> src/objtools/cddalignview
- * In addition, libseq now includes six of the objects/seq... libs, and libmmdb
- * replaces the three libmmdb? libs.
- *
- * Revision 1.6 2003/05/30 11:29:19 lebedev
- * Added: Clickable Feature selection. Drawing of intervals.
- *
- * Revision 1.5 2003/05/23 16:01:51 lebedev
- * Show Labels for visible genes only
- *
- * Revision 1.4 2003/05/23 10:56:21 lebedev
- * New rendering engine, hit test engine, many other changes
- *
- * Revision 1.3 2003/05/19 16:53:55 dicuccio
- * Better memory management. Minor rearrangement of #includes
- *
- * Revision 1.2 2003/05/16 19:00:08 dicuccio
- * Fixed compilation errors for linux (const functions/variables,
- * #include <math.h>
- *
- * Revision 1.1 2003/05/16 16:46:02 lebedev
- * Initial revision
- *
- * ===========================================================================
- */
- #endif /* GUI_WIDGETS_SEQ_GRAPHIC___SEQGRAPHIC_PANE__HPP */