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

Go to the SVN repository for this file.

1 #ifndef GUI_WIDGET_SEQ_GRAPHICS___FEATURE_PANEL__HPP
2 #define GUI_WIDGET_SEQ_GRAPHICS___FEATURE_PANEL__HPP
3 
4 /* $Id: feature_panel.hpp 47029 2022-05-16 18:09:35Z asztalos $
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: Vlad Lebedev, Liangshou Wu
30  *
31  */
32 
33 #include <gui/gui.hpp>
41 
43 
44 class IServiceLocator;
45 class INonAsnTrackData;
46 
48 public:
49  void SetMappedFeat(const objects::CMappedFeat& mapped_feat) { m_MappedFeat = mapped_feat; m_isMappedFeatSet = true; }
50  void SetRange(const TSeqRange& range) { m_Range = range; }
51  void SetObject(const CObject* object) { m_Object.Reset(object); }
52  const CObject* GetObject() { return m_Object.GetPointer(); }
53  bool HasMappedFeat() const { return m_isMappedFeatSet; }
54  TSeqRange GetRange() const { return HasMappedFeat() ? m_MappedFeat.GetRange() : m_Range; }
55  const objects::CMappedFeat& GetMappedFeat() const { return m_MappedFeat; }
56 private:
57  bool m_isMappedFeatSet{false};
58  objects::CMappedFeat m_MappedFeat;
61 };
62 
63 
65  public CTrackContainer,
66  public ITrackInitObserver
67 {
68  friend class CConfigureTracksDlg;
69 
70 public:
71  /// key-value pair for track settings
73  typedef list< TTrackSettings > TTrackSettingsSet;
74  typedef list< CWeakRef<CSeqGlyph> > TSelectedGlyphs;
76 
77  CFeaturePanel(CRenderingContext* r_cntx, bool cgi_mode);
78  virtual ~CFeaturePanel();
79 
80  /// @name CSeqGlyph virtual method.
81  /// @{
82  virtual void Update(bool layout_only);
83  virtual CRef<CSeqGlyph> HitTest(const TModelPoint& p);
84  virtual bool HitTestHor(TSeqPos x, const CObject *obj);
85  /// @}
86 
87  void SetDSContext(ISGDataSourceContext* ds_ctx);
88  void SetInputObject(SConstScopedObject& obj);
89  void SetNonAsnInput(const INonAsnTrackData& data);
90  void ConfigureTracks();
91  void OnDataChanging();
92  void OnDataChanged();
93  void SetSelectedFeats(const TSelectedGlyphs& feats);
94  void SetSelectedCDSFeats(const TSelectedGlyphs& cds_feats);
95  void SetExternalGlyphs(const CSeqGlyph::TObjects& objs);
96  void UpdateGridStep(int step);
97 
98  void SetAssembly(const string& assembly);
99  void ShowConfigureTracksDlg(const string& category);
100 
101  CMappedFeatOrObject FindText(const string &text, bool match_case);
102  virtual void ResetSearch();
103  void SetServiceLocator(IServiceLocator* s) { m_ServiceLocator = s; }
104 
105  /// Optional image info structure to return data to (cgi) caller
106  void SetImageInfo(TImageInfo* info) { m_ImageInfo = info; }
107 
108  /// Reset tracks to the original default track list.
109  /// Resetting completely wipes out current track list and
110  /// user settings.
111  void LoadDefaultTracks();
112 
113  /// @name cgi mode-related methods
114  /// @{
115  /// Reset the track configuration with input settings.
116  void SetTrackConfig(const TTrackSettingsSet& settings_set);
117  void SetTrackConfig(const TTrackProxies& track_settings);
118 
119  /// skip track existence verification.
120  /// Assume tracks exist.
121  void SkipGenuineCheck();
122 
123  /// Turn on an existing track.
124  void ShowTrack(const string& track_key);
125  /// @}
126 
127  void SaveTrackConfig();
128 
129  /// @name CLayoutTrack public methods.
130  /// @{
131  virtual const CTrackTypeInfo& GetTypeInfo() const;
132  /// @}
133 
134  /// @name ITrackInitObserver interface implementation.
135  /// @{
136  virtual void OnTrackInitFinished(const CLayoutTrack* sender);
137  /// @}
138 
139  void SetConfigKey(const string& config_key);
140 
141  void SetDiscoverTracks(bool value = true);
142 
143  set<string> GetAnnotNames();
144 
145 protected:
146  virtual void x_Draw() const;
147 
148  /// @name data track pure virtual methods.
149  /// @{
150  virtual bool x_IsJobNeeded(CAppJobDispatcher::TJobID id) const;
151  virtual void x_OnJobCompleted(CAppJobNotification& notify);
152  /// @}
153 
154  /// @name CLayoutTrack virtual methods
155  /// @{
156  /// make sure we never collapse feature panel
157  virtual void x_Expand(bool /*expand*/) {};
158  virtual void x_LoadSettings(const string& preset_style,
159  const TKeyValuePairs& settings);
160  virtual void x_SaveSettings(const string& preset_style);
161  virtual bool x_Empty() const;
162  virtual void x_GetTBRect(TModelRect& rect) const;
163  virtual void x_RenderTitleBar() const;
164  virtual void x_OnIconClicked(TIconID id);
165  /// @}
166 
167 private:
169  eIcon_Color = eIcon_MaxTrackIconID + 1, ///< color theme
170  eIcon_Size, ///< size level
171  eIcon_Decoration, ///< feature decoration
172  eIcon_Label ///< feature label position
173  };
174 
175  void x_OnLayoutIconClicked();
176  void x_OnColorIconClicked();
177  void x_OnSizeIconClicked();
178  void x_OnDecorationIconClicked();
179  void x_OnLabelIconClicked();
180 
181  /// reset the track status to be ready for reconfiguring layout tracks.
182  void x_ConfigureTracks(bool makeContainersVisible = false);
183 
184  /// Create all the exsiting layout tracks.
185  /// @param group the container into which the created tracks will be added.
186  /// @param level the feature retrieving level used for annotation selector.
187  /// There are twofold meanings here. If level >=0, then those tracks with
188  /// concept of level will be initialized with that exact level, all other
189  /// tracks without level concept won't be initialized. If level == -1, all
190  /// registered tracks will be initialized. For those tracks with level
191  /// concept will use adpative annotation selector. if level == -2, only
192  /// those tracks without level concept will be initialized.
193  void x_ConfigureSubtracks_Recursive(CTrackContainer* parent,
194  const TTrackProxies& proxies, int level);
195 
196  CTrackContainer* x_ConfigureSubtracks(CTrackContainer* parent,
197  const CTrackProxy* param, int level, const set<string>& usedFeatureSubkeys);
198 
199  /// Load settings for feature panel.
200  void x_LoadSettings();
201 
202  /// Save settings for feature panel.
203  void x_SaveSettings();
204 
205  void x_InitTrackIcons();
206 
207  void x_RenderHairLineSelections() const;
208  // returns true if the line was actually drawn
209  bool x_DrawHairLine(int opt, size_t total, const multiset <TSeqPos>& all_pos,
210  TSeqPos pos, TModelUnit line_y) const;
211  void x_RenderFeatureGrid() const;
212  double x_CalcGridStep(double base_step, double min_step, double max_step) const;
213 
214  typedef int TLevel;
215  typedef vector<TLevel> TDisplayLevels;
216 
217  /// Only meaningful if Multilevel is true.
218  bool x_GetShowDisplayLevel(TLevel level) const;
219  void x_SetShowDisplayLevel(TLevel level, bool show);
220 
221  /// create track container for a given annotation level.
222  /// This will be used only in multiple level layout mode.
223  CRef<CTrackContainer> x_CreateLevelTrack(int level, int id,
224  const string& track_name, bool shown);
225 
226  /// need show special grid for the selected cds features.
227  bool x_NeedSpecialGrid() const;
228 
229 protected:
232 
233  void x_InitNATracks(bool makeContainersVisible);
234 
235 private:
237 
238  /// initial track layout settings.
240 
243 
244  /// graphical grid.
247 
250 
251  /// flag indicating whether icon textures have been created.
252  mutable bool m_IconTexInitialized;
253 
254  /// special flag indicating if it is in cgi mode.
255  /// we need this to avoid rendering some glyphs (like texture/icons)
256  bool m_CgiMode;
257 
259 
260  /// Information about image that can be returned to client
262 
263  /// Base regitry key for panel setting and tracks
264  /// default "GBPlugins.SeqGraphicFeatPanel" is for SV
265  /// MSA sets its own "GBPlugins.MSAFeatPanel" to separate MSA and SV tracks
266  string m_ConfigKey;
267 
268  // if true, DataSource loads NA metadata for tracks discovery
269  // not applicable if in CgiMode
270  bool m_DiscoverTracks = true;
271 
273 
275  vector<CRef<objects::CGC_Assembly> > m_Assemblies;
277 
278  void x_StartAssemblyJob();
279  void x_OnAssemblyLoaded(const list<CRef<objects::CGC_Assembly> >& assemblies);
280 
281 public:
282  void SetDefaultAssembly(const string& defaultAssembly) { m_DefaultAssembly = defaultAssembly; }
283  bool AssemblyLoaded() const { return m_AssemblyLoaded; }
284  const vector<CRef<objects::CGC_Assembly> >& GetAssemblies() const { return m_Assemblies; }
285  string GetCurrentAssembly() const;
286 
287 private:
289  bool m_search_match_case = false;
290  size_t m_next_result = 0;
291  vector<CMappedFeatOrObject> m_search_results;
292  IServiceLocator* m_ServiceLocator = 0;
293 };
294 
295 inline
297 { m_DSContext.Reset(ds_ctx); }
298 
299 inline
301 { m_SelFeatures = &feats; }
302 
303 inline
305 { m_SelCDSFeatures = &cds_feats; }
306 
307 inline
309 { m_Gen.SetStep((double)step); }
310 
311 inline
313 { SetSkipGenuineCheck(true); }
314 
315 inline
317 { return m_SelCDSFeatures && !m_SelCDSFeatures->empty(); }
318 
319 inline
320 void CFeaturePanel::SetConfigKey(const string& config_key)
321 {
322  _ASSERT(!config_key.empty());
323  m_ConfigKey = config_key;
324 }
325 
326 inline
327 void CFeaturePanel::SetTrackConfig(const TTrackProxies& track_settings)
328 {
329  m_TrackSettings = track_settings;
330 }
331 
332 inline
334 {
336 }
337 
339 
340 
341 #endif // GUI_WIDGET_SEQ_GRAPHICS___FEATURE_PANEL__HPP
CAppJobNotification Notification send by CAppJobEventTranslator.
virtual void x_SaveSettings(CRegistryWriteView view) const
virtual void x_LoadSettings(const CRegistryReadView &view)
override these functions in derived classes
CRegularGridGen m_Gen
graphical grid.
CIRef< ISGDataSourceContext > m_DSContext
void SetImageInfo(TImageInfo *info)
Optional image info structure to return data to (cgi) caller.
void SetSelectedFeats(const TSelectedGlyphs &feats)
const TSelectedGlyphs * m_SelCDSFeatures
map< string, string > TTrackSettings
key-value pair for track settings
vector< TLevel > TDisplayLevels
bool m_CgiMode
special flag indicating if it is in cgi mode.
const TSelectedGlyphs * m_SelFeatures
string m_DefaultAssembly
SConstScopedObject m_InputObj
bool x_NeedSpecialGrid() const
need show special grid for the selected cds features.
vector< CRef< objects::CGC_Assembly > > m_Assemblies
void SetConfigKey(const string &config_key)
CRegularGridRenderer m_Grid
TAnnotMetaDataList m_NAData
vector< CMappedFeatOrObject > m_search_results
static CTrackTypeInfo m_TypeInfo
bool m_IconTexInitialized
flag indicating whether icon textures have been created.
void UpdateGridStep(int step)
TImageInfo * m_ImageInfo
Information about image that can be returned to client.
CRef< CExternalLayoutTrack > m_ExtLayoutTrack
void SetTrackConfig(const TTrackSettingsSet &settings_set)
@ eIcon_Size
size level
@ eIcon_Decoration
feature decoration
void SetDSContext(ISGDataSourceContext *ds_ctx)
string m_ConfigKey
Base regitry key for panel setting and tracks default "GBPlugins.SeqGraphicFeatPanel" is for SV MSA s...
void SetSelectedCDSFeats(const TSelectedGlyphs &cds_feats)
void SkipGenuineCheck()
skip track existence verification.
void SetDiscoverTracks(bool value=true)
TDisplayLevels m_DisplayLevels
bool AssemblyLoaded() const
CSeqGraphicImageInfo TImageInfo
void SetDefaultAssembly(const string &defaultAssembly)
list< TTrackSettings > TTrackSettingsSet
TTrackProxies m_TrackSettings
initial track layout settings.
list< CWeakRef< CSeqGlyph > > TSelectedGlyphs
void SetServiceLocator(IServiceLocator *s)
virtual void x_Expand(bool)
Collapse or expand the track.
const vector< CRef< objects::CGC_Assembly > > & GetAssemblies() const
File Description:
bool HasMappedFeat() const
const objects::CMappedFeat & GetMappedFeat() const
void SetMappedFeat(const objects::CMappedFeat &mapped_feat)
void SetRange(const TSeqRange &range)
void SetObject(const CObject *object)
objects::CMappedFeat m_MappedFeat
TSeqRange GetRange() const
const CObject * GetObject()
CConstRef< CObject > m_Object
CObject –.
Definition: ncbiobj.hpp:180
CRegularGridGen.
CRegularGridRenderer.
CRenderingContext offers the basic context and utility methods for rendering layout objects in featur...
list< CRef< CSeqGlyph > > TObjects
Definition: seq_glyph.hpp:85
CTrackContainer - a track container in the form of layout track.
void SetSkipGenuineCheck(bool flag)
CTempTrackProxy::TTrackProxies TTrackProxies
CTrackProxy data structure contains information about the position of a track in its parent scope,...
CTrackTypeInfo - holds description of a layout track type.
ISGDSManager is seqgraphic data source manage that serves as an data source context.
IServiceLocator - an abstract mechanism for locating services.
Definition: service.hpp:71
ITrackInitObserver: interface class work as an observer of a track that is responsible of intializing...
char data[12]
Definition: iconv.c:80
unsigned int TSeqPos
Type for sequence locations and lengths.
Definition: ncbimisc.hpp:875
void SetStep(double step)
allow adjusting step externally.
GLdouble TModelUnit
Definition: gltypes.hpp:48
void Reset(void)
Reset reference object.
Definition: ncbiobj.hpp:773
#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_SEQGRAPHIC_EXPORT
Definition: gui_export.h:536
static void text(MDB_val *v)
Definition: mdb_dump.c:62
static MDB_envinfo info
Definition: mdb_load.c:37
range(_Ty, _Ty) -> range< _Ty >
const GenericPointer< typename T::ValueType > T2 value
Definition: pointer.h:1227
#define _ASSERT
Modified on Fri Sep 20 14:57:44 2024 by modify_doxy.py rev. 669887