NCBI C++ ToolKit
seq_text_pane_conf.cpp
Go to the documentation of this file.

Go to the SVN repository for this file.

1 /* $Id: seq_text_pane_conf.cpp 39602 2017-10-13 19:04:41Z katargir $
2  * ===========================================================================
3  *
4  * PUBLIC DOMAIN NOTICE
5  * National Center for Biotechnology Information
6  *
7  * This software/database is a "United States Government Work" under the
8  * terms of the United States Copyright Act. It was written as part of
9  * the author's official duties as a United States Government employee and
10  * thus cannot be copyrighted. This software/database is freely available
11  * to the public for use. The National Library of Medicine and the U.S.
12  * Government have not placed any restriction on its use or reproduction.
13  *
14  * Although all reasonable efforts have been taken to ensure the accuracy
15  * and reliability of the software and data, the NLM and the U.S.
16  * Government do not and cannot warrant the performance or results that
17  * may be obtained by using this software or data. The NLM and the U.S.
18  * Government disclaim all warranties, express or implied, including
19  * warranties of performance, merchantability or fitness for any particular
20  * purpose.
21  *
22  * Please cite the author in any work or product based on this material.
23  *
24  * ===========================================================================
25  *
26  * Authors: Colleen Bollin, based on a file by Vlad Lebedev
27  *
28  * File Description:
29  *
30  */
31 
32 #include <ncbi_pch.hpp>
33 #include <gui/objutils/utils.hpp>
38 #include <corelib/ncbistr.hpp>
39 
42 
43 const string kCaseFeature("case_feature");
44 const string kCaseLower("show_feat_as_lower");
45 const string kFontSize("font_size");
46 const string kShowAbsolute("show_absolute_position");
47 const string kFeatureColoration("feature_coloration");
48 const string kCodonDraw("codon_draw");
49 
50 // string representations of EFeatureDisplayType
51 const string kDisplayAll("all");
52 const string kDisplayNone("none");
53 const string kDisplaySelected("selected");
54 const string kDisplayMouseOver("mouseover");
55 
56 
58  : CSettingsSet("SequenceTextView", config_cache)
59 {
60 }
61 
62 
64 {
65 }
66 
67 
69 {
70  /// cached colors by feature subtype
71  Uncache();
72 }
73 
74 
76 {
77  CFeatListItem config_item;
78  const CFeatList* cfg_list = CSeqFeatData::GetFeatList();
79 
80  cfg_list->GetItemBySubtype (subtype, config_item);
81  string desc = config_item.GetDescription();
82 
83  Set(kCaseFeature, desc);
84  objects::SAnnotSelector sel = CSeqUtils::GetAnnotSelector();
85  sel.SetFeatSubtype(static_cast<objects::CSeqFeatData::ESubtype>(subtype));
86  m_CaseFeatureSel = sel;
87 }
88 
89 
90 objects::SAnnotSelector *CSeqTextPaneConfig::GetCaseFeature ()
91 {
92  int type=0, subtype=0;
93  string desc = GetString(kCaseFeature);
95  objects::SAnnotSelector sel = CSeqUtils::GetAnnotSelector();
96  sel.SetFeatSubtype(static_cast<objects::CSeqFeatData::ESubtype>(subtype));
97  m_CaseFeatureSel = sel;
98  return &m_CaseFeatureSel;
99 }
100 
101 
103 {
104  int type=0, subtype=0;
105  string desc = GetString(kCaseFeature);
106  CSeqFeatData::GetFeatList()->GetTypeSubType(desc, type, subtype);
107  return subtype;
108 }
109 
110 
112 {
113  Set (kFontSize, font_size);
114 }
115 
116 
118 {
119  return GetInt(kFontSize);
120 }
121 
122 
124 {
125  Set (kShowAbsolute, show_abs);
126 }
127 
128 
130 {
131  return GetBool(kShowAbsolute);
132 }
133 
134 
136 {
137  return GetBool(kCaseLower);
138 }
139 
140 
142 {
143  Set(kCaseLower, show_lower);
144 }
145 
146 
148 {
149  if (NStr::CompareNocase (str, kDisplayAll) == 0) {
150  return eAll;
151  } else if (NStr::CompareNocase (str, kDisplaySelected) == 0) {
152  return eSelected;
153  } else if (NStr::CompareNocase (str, kDisplayMouseOver) == 0) {
154  return eMouseOver;
155  } else {
156  return eNone;
157  }
158 }
159 
160 
162 {
163  if (disp == eAll) {
164  return kDisplayAll;
165  } else if (disp == eSelected) {
166  return kDisplaySelected;
167  } else if (disp == eMouseOver) {
168  return kDisplayMouseOver;
169  } else {
170  return kDisplayNone;
171  }
172 }
173 
174 
176 {
177  string desc = GetString (kFeatureColoration);
178  return ConfigStringToFeatureDisplayType (desc);
179 }
180 
181 
183 {
185 }
186 
187 
189 {
190  string desc = GetString (kCodonDraw);
191  return ConfigStringToFeatureDisplayType (desc);
192 }
193 
194 
196 {
198 }
199 
200 
CFeatListItem - basic configuration data for one "feature" type.
string GetDescription() const
CConfigurableItems - a static list of items that can be configured.
bool GetItemBySubtype(int subtype, CFeatListItem &config_item) const
bool GetTypeSubType(const string &desc, int &type, int &subtype) const
Get the feature's type and subtype from its description.
static const CFeatList * GetFeatList()
void SetShowFeatAsLower(bool show_lower)
const string FeatureDisplayTypeToConfigString(EFeatureDisplayType disp)
void Reload()
uncache any cached data
void SetShowAbsolutePosition(bool show_abs)
void SetFontSize(int font_size)
objects::SAnnotSelector * GetCaseFeature()
void SetFeatureColorationChoice(EFeatureDisplayType ftype)
EFeatureDisplayType GetCodonDrawChoice()
void SetCodonDrawChoice(EFeatureDisplayType ftype)
EFeatureDisplayType ConfigStringToFeatureDisplayType(string str)
EFeatureDisplayType GetFeatureColorationChoice()
void SetCaseFeature(TFeatSubtype subtype)
objects::SAnnotSelector m_CaseFeatureSel
CSeqTextPaneConfig(CGuiRegistry *config_cache=0)
CSettingsSet is an adapter of the CGuiRegistry to provide persistance of and easy access to view's (o...
void Set(const string &key, int val)
set a named integer value
void Uncache()
uncache any cached lookup data
int GetInt(const string &key, int default_val=0) const
Retrieve a named int value from a section.key.
int TFeatSubtype
we use int instead of CSeqFeatData::ESubtype for two reasons:
string GetString(const string &key, const string &default_val=kEmptyStr) const
Retrieve a named string value from a section.key.
bool GetBool(const string &key, bool default_val=false) const
Retrieve a named bool value from a section.key.
The NCBI C++ standard methods for dealing with std::string.
static const char * str(char *buf, int n)
Definition: stats.c:84
static objects::SAnnotSelector GetAnnotSelector(TAnnotFlags flags=0)
request an annotation selector for a given type
Definition: utils.cpp:167
#define END_NCBI_SCOPE
End previously defined NCBI scope.
Definition: ncbistl.hpp:103
#define BEGIN_NCBI_SCOPE
Define ncbi namespace.
Definition: ncbistl.hpp:100
static int CompareNocase(const CTempString s1, SIZE_TYPE pos, SIZE_TYPE n, const char *s2)
Case-insensitive compare of a substring with another string.
Definition: ncbistr.cpp:219
USING_SCOPE(objects)
const string kFeatureColoration("feature_coloration")
const string kFontSize("font_size")
const string kDisplayMouseOver("mouseover")
const string kDisplayAll("all")
const string kCaseFeature("case_feature")
const string kDisplaySelected("selected")
const string kShowAbsolute("show_absolute_position")
const string kCaseLower("show_feat_as_lower")
const string kCodonDraw("codon_draw")
const string kDisplayNone("none")
Definition: type.c:6
Modified on Mon Apr 22 04:07:26 2024 by modify_doxy.py rev. 669887