NCBI C++ ToolKit
linear_sel_handler.hpp
Go to the documentation of this file.

Go to the SVN repository for this file.

1 #ifndef __GUI_WIDGETS_ALNMULTI___LINEAR_SEL_HANDLER__HPP
2 #define __GUI_WIDGETS_ALNMULTI___LINEAR_SEL_HANDLER__HPP
3 
4 /* $Id: linear_sel_handler.hpp 40801 2018-04-12 15:07:28Z katargir $
5  * ===========================================================================
6  *
7  * PUBLIC DOMAIN NOTICE
8  * National Center for Biotechnology Information
9  *
10  * This software/database is a "United States Government Work" under the
11  * terms of the United States Copyright Act. It was written as part of
12  * the author's official duties as a United States Government employee and
13  * thus cannot be copyrighted. This software/database is freely available
14  * to the public for use. The National Library of Medicine and the U.S.
15  * Government have not placed any restriction on its use or reproduction.
16  *
17  * Although all reasonable efforts have been taken to ensure the accuracy
18  * and reliability of the software and data, the NLM and the U.S.
19  * Government do not and cannot warrant the performance or results that
20  * may be obtained by using this software or data. The NLM and the U.S.
21  * Government disclaim all warranties, express or implied, including
22  * warranties of performance, merchantability or fitness for any particular
23  * purpose.
24  *
25  * Please cite the author in any work or product based on this material.
26  *
27  * ===========================================================================
28  *
29  * Authors: Andrey Yazhuk
30  *
31  * File Description:
32  *
33  */
34 
35 #include <corelib/ncbistl.hpp>
36 
38 
40 
43 #include <gui/opengl/glpane.hpp>
44 
45 #include <util/range_coll.hpp>
46 
47 
49 
50 ////////////////////////////////////////////////////////////////////////////////
51 /// class ISelHandlerHost
52 
54 {
55 public:
56  virtual ~ISelHandlerHost() { }
57 
58  virtual void SHH_OnChanged() = 0;
59  virtual TModelUnit SHH_GetModelByWindow(int z, EOrientation orient) = 0;
61 };
62 
63 
64 ////////////////////////////////////////////////////////////////////////////////
65 /// Class CLinearSelHandler represents in GUI a one-dimnesional multi-segment
66 /// selection. CLinearSelHandler renders the selection in a given CGlPane and
67 /// allows to interactively modify the selection.
68 ///
69 /// CLinearSelHandler implements IGlEventHandler what makes it compatible with
70 /// IGlEventHandler-supproting widgets.
71 /// CLinearSelHandler provides API for programmatical manipulation of the
72 // selection.
74  public wxEvtHandler,
75  public IGlEventHandler
76 {
77  DECLARE_EVENT_TABLE()
78 public:
80 
82  {
84  ePassiveState
85  };
86 
87  enum EColorType {
90  eSymbol
91  };
92 
93  enum EExtState {
96  eExtRangeEnd
97  };
98  enum EOpType {
100  eAdd, // add a new segment
102  eReplace, // replace existing segments with a new one
103  eChange //resize and existing segment
104  };
105 
106 public:
108  virtual ~CLinearSelHandler();
109 
110  /// @name IGlEventHandler implementaion
111  /// @{
112  virtual void SetPane(CGlPane* pane);
113  virtual wxEvtHandler* GetEvtHandler();
114  /// @}
115 
116  void SetHost(ISelHandlerHost* host);
117  IGenericHandlerHost* GetGenericHost();
118  void SetOrientation(EOrientation orient);
119 
120  void Render(CGlPane& Pane, ERenderingOption option = eActiveState);
121 
122  // colors
123  void SetColor(EColorType type, const CRgbaColor& color);
124  void SetShowRangeCoords(bool flag);
125 
126  // commands
127  TSeqRange GetSelectionLimits() const;
128  const TRangeColl& GetSelection() const;
129  void SetSelection(const TRangeColl& C, bool bRedraw);
130  void ResetSelection(bool bRedraw);
131 
132  void OnLeftDown(wxMouseEvent& event);
133  void OnLeftDoubleClick(wxMouseEvent& event);
134  void OnLeftUp(wxMouseEvent& event);
135  void OnMotion(wxMouseEvent& event);
136  void OnMouseCaptureLost(wxMouseCaptureLostEvent& evt);
137 
138 protected:
139  // signal handlers - invoked by event handlers
140  void x_OnStartSel(const wxPoint& ms_pos, CGUIEvent::EGUIState state);
141  void x_OnChangeSelRange(const wxPoint& ms_pos);
142  void x_OnEndSelRange();
143  void x_OnResetAll();
144  void x_OnOpChange(CGUIEvent& event);
145 
146  void x_OnSelectCursor(const wxPoint& ms_pos);
147  void x_SetCursor();
148 
149 protected:
150 
152  EOpType x_GetOpTypeByState(CGUIEvent::EGUIState state) const;
153 
154  TModelUnit x_MouseToSeqPos(const wxPoint& ms_pos);
155  TModelUnit x_ClipPosByRange(TModelUnit Pos);
156 
157  void x_HitTest(const wxPoint& ms_pos, TSeqRange& Range, bool& bHitStart);
158 
159  void x_AddToSelection(const TSeqRange& Range);
160  void x_RemoveFromSelection(const TSeqRange& Range);
161 
162 private:
165  TSeqRange m_CurrRange; ///< range being modified
166 
167  EExtState m_ExtState; ///< current range extension state
168  EOpType m_OpType; ///< operation type
171  /// Flag indicating to show range coordinates during selection.
173 
175 
180 
183 };
184 
186 
187 #endif // __GUI_WIDGETS_ALNMULTI___LINEAR_SEL_HANDLER__HPP
CGUIEvent provides mapping of FLTK events to Semantic Events.
Definition: gui_event.hpp:82
class CGlPane
Definition: glpane.hpp:62
Class CLinearSelHandler represents in GUI a one-dimnesional multi-segment selection.
EOpType x_GetOpTypeByEvent(CGUIEvent &event) const
CGlTextureFont m_TexFont
TSeqRange m_CurrRange
range being modified
EOpType m_OpType
operation type
EExtState m_ExtState
current range extension state
bool m_ShowCoordinates
Flag indicating to show range coordinates during selection.
CRangeCollection< TSeqPos > TRangeColl
void x_OnOpChange(CGUIEvent &event)
ISelHandlerHost * m_Host
class CRgbaColor provides a simple abstraction for managing colors.
Definition: rgba_color.hpp:58
IGenericHandlerHost.
IGlEventHandler.
virtual void SetPane(CGlPane *)
virtual wxEvtHandler * GetEvtHandler()=0
class ISelHandlerHost
virtual TModelUnit SHH_GetModelByWindow(int z, EOrientation orient)=0
virtual void SHH_OnChanged()=0
virtual TVPUnit SHH_GetWindowByModel(TModelUnit z, EOrientation orient)=0
unsigned short Pos
#define C(s)
Definition: common.h:231
#define option
GLdouble TModelUnit
Definition: gltypes.hpp:48
int TVPUnit
Definition: gltypes.hpp:47
EOrientation
Definition: gltypes.hpp:58
@ eHorz
Definition: gltypes.hpp:59
#define END_NCBI_SCOPE
End previously defined NCBI scope.
Definition: ncbistl.hpp:103
#define BEGIN_NCBI_SCOPE
Define ncbi namespace.
Definition: ncbistl.hpp:100
#define NCBI_GUIWIDGETS_GL_EXPORT
Definition: gui_export.h:529
n background color
EColorType
Definition: map_control.hpp:48
The NCBI C++/STL use hints.
Definition: type.c:6
Modified on Thu May 02 14:30:45 2024 by modify_doxy.py rev. 669887