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

Go to the SVN repository for this file.

1 #ifndef GUI_WIDGETS_SEQ_GRAPHIC___LAYOUT_CONF__HPP
2 #define GUI_WIDGETS_SEQ_GRAPHIC___LAYOUT_CONF__HPP
3 
4 /* $Id: layout_conf.hpp 46256 2021-02-25 19:36:40Z shkeda $
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  * Author: Liangshou Wu
30  *
31  */
32 
33  /**
34  * File Description:
35  */
36 
37 #include <corelib/ncbistr.hpp>
38 #include <gui/objects/CheckBox.hpp>
40 #include <gui/objects/TextBox.hpp>
41 #include <gui/objects/Choice.hpp>
43 #include <gui/objects/Category.hpp>
46 #include <gui/objects/Comment.hpp>
49 
50 #include <map>
51 
52 
54 
56 {
57 
58 public:
59  //typedef vector< CRef<objects::CTrackConfig> > TTrackConfigSet;
60 
61  static CRef<objects::CChoiceItem> CreateChoiceItem(const string& name,
62  const string& disp_name,
63  const string& help,
64  const string& legend_txt,
65  bool optional = false)
66  {
67  CRef<objects::CChoiceItem> item(new objects::CChoiceItem);
68  item->SetName() = name;
69  item->SetDisplay_name() = disp_name;
70  item->SetHelp() = help;
71  item->SetLegend_text() = legend_txt;
72  if (optional)
73  item->SetOptional(optional);
74 
75  return item;
76  }
77 
78 
79  static CRef<objects::CChoice> CreateChoice(const string& name,
80  const string& disp_name,
81  const string& curr_val,
82  const string& help,
83  bool optional = false)
84  {
85  CRef<objects::CChoice> choice(new objects::CChoice);
86  choice->SetName() = name;
87  choice->SetDisplay_name() = disp_name;
88  choice->SetCurr_value() = curr_val;
89  choice->SetHelp() = help;
90  if (optional)
91  choice->SetOptional(optional);
92  return choice;
93  }
94 
95 
96  static CRef<objects::CCheckBox> CreateCheckBox(const string& name,
97  const string& disp_n,
98  const string& help_text,
99  const string& legend_txt,
100  bool value,
101  bool optional = false)
102  {
103  CRef<objects::CCheckBox> cb(new objects::CCheckBox);
104  cb->SetName() = name;
105  cb->SetValue() = value;
106  cb->SetDisplay_name() = disp_n;
107  cb->SetHelp() = help_text;
108  cb->SetLegend_text() = legend_txt;
109  if (optional)
110  cb->SetOptional(optional);
111  return cb;
112  }
113 
114  static CRef<objects::CTextBox> CreateTextBox(const string& name,
115  const string& disp_n,
116  const string& help_text,
117  const string& value)
118  {
119  CRef<objects::CTextBox> tb(new objects::CTextBox);
120  tb->SetName(name);
121  tb->SetValue(value);
122  tb->SetDisplay_name(disp_n);
123  tb->SetHelp(help_text);
124  tb->SetLegend_text(help_text);
125  return tb;
126  }
127 
129  const string& value)
130  {
131  CRef<objects::CHiddenSetting> hs(new objects::CHiddenSetting);
132  hs->SetName() = name;
133  hs->SetValue() = value;
134  return hs;
135  }
136 
137 
139  const string& pos_str)
140  {
141  CRef<objects::CComment> comment(new objects::CComment);
142  comment->SetLabel() = label;
143  comment->SetPos_str() = pos_str;
144  return comment;
145  }
146 
147 
148  static CRef<objects::CCategory> CreateCategory(const string& name,
149  const string& disp_name,
150  const string& help,
151  int order)
152  {
153  CRef<objects::CCategory> cat(new objects::CCategory);
154  cat->SetName() = name;
155  cat->SetDisplay_name() = disp_name;
156  cat->SetHelp() = help;
157  cat->SetOrder() = order;
158  return cat;
159  }
160 
162  const string& disp_name,
163  const string& help,
164  const string& value_min,
165  const string& value_max,
166  bool autoscale = true,
167  bool inverse = false,
168  bool optional = false)
169  {
170  CRef<objects::CRangeControl> range(new objects::CRangeControl);
171  range->SetName() = name;
172  range->SetDisplay_name() = disp_name;
173  range->SetHelp() = help;
174  range->SetValue().SetMin(value_min);
175  range->SetValue().SetMax(value_max);
176  range->SetValue().SetAutoscale(autoscale);
177  range->SetValue().SetInverse(inverse);
178  if (optional)
179  range->SetOptional(optional);
180  return range;
181  }
182 
183  // range=min:max|auto
184  // min - float or 'inf' where inf(inity) indicator of no value
185  // max - float or 'inf' where inf(inity) indicator of no value
186  // auto - optional flag indicate if autoscale should be apply
187 
188  static void DecodeValueRange(const string& value_range, string& range_min, string& range_max, bool& range_auto)
189  {
190  range_min.clear();
191  range_max.clear();
192  range_auto = true;
193  if (value_range.empty())
194  return;
195  vector<string> vals;
196  NStr::Split(value_range, "|", vals, NStr::fSplit_Tokenize);
197  auto val_size = vals.size();
198  if (val_size < 2 || val_size > 3)
199  return;
200  range_min = vals[0];
201  range_max = vals[1];
202  range_auto = val_size == 3 && vals[2] == "auto";
203  }
204 
205  static void EncodeValueRange(const string& range_min, const string& range_max, bool range_auto, string& value_range)
206  {
207  value_range.clear();
208  value_range = range_min.empty() ? "inf" : range_min;
209  value_range += "|";
210  value_range += range_max.empty() ? "inf" : range_max;
211  if (range_auto)
212  value_range += "|auto";
213  }
214 
215 };
216 
217 
218 ///////////////////////////////////////////////////////////////////////////////
219 /// data structure holding configuration for a track.
221 {
222 public:
223  /// group/subgroup settings from TMS
224  /// string is group name, int is group order
226 
227  /// first string is group name, second is subgroups name
228  typedef pair<string, string> TSubgroupName;
229 
230  /// int is subgroup order
232 
234 
236  {
239 
241  {
242  m_Subcategories[sub_cat->GetName()] = sub_cat;
243  }
244  };
245 
247 
249  {
250  m_Categories[cat.m_Category->GetName()] = cat;
251  }
252 
253  void AddSubcategory(const string& cat_name, CRef<objects::CCategory> sub_cat)
254  {
255  m_Categories[cat_name].m_Subcategories[sub_cat->GetName()] = sub_cat;
256  }
257 
258  CRef<objects::CCategory> GetCategory(const string& cat_name)
259  {
261  TCategories::const_iterator iter = m_Categories.find(cat_name);
262  if (iter != m_Categories.end()) {
263  cat = iter->second.m_Category;
264  }
265  return cat;
266  }
267 
269  GetSubcategory(const string& cat_name, const string& sub_cat)
270  {
272  TCategories::const_iterator iter = m_Categories.find(cat_name);
273  if (iter != m_Categories.end()) {
275  iter->second.m_Subcategories.find(sub_cat);
276  if (s_iter != iter->second.m_Subcategories.end()) {
277  cat = s_iter->second;
278  }
279  }
280  return cat;
281  }
282 
283 private:
284 
286 };
287 
288 
289 
291 
292 #endif // GUI_WIDGETS_SEQ_GRAPHIC___LAYOUT_CONF__HPP
User-defined methods of the data storage class.
User-defined methods of the data storage class.
User-defined methods of the data storage class.
User-defined methods of the data storage class.
User-defined methods of the data storage class.
User-defined methods of the data storage class.
User-defined methods of the data storage class.
User-defined methods of the data storage class.
User-defined methods of the data storage class.
User-defined methods of the data storage class.
User-defined methods of the data storage class.
data structure holding configuration for a track.
map< string, CRef< objects::CCategory > > TSubcategories
map< string, int > TGroupMap
group/subgroup settings from TMS string is group name, int is group order
CRef< objects::CCategory > GetCategory(const string &cat_name)
map< string, SCategorySettings > TCategories
map< TSubgroupName, int > TSubgroupMap
int is subgroup order
pair< string, string > TSubgroupName
first string is group name, second is subgroups name
CRef< objects::CCategory > GetSubcategory(const string &cat_name, const string &sub_cat)
void AddCategory(const SCategorySettings &cat)
void AddSubcategory(const string &cat_name, CRef< objects::CCategory > sub_cat)
TCategories m_Categories
CObject –.
Definition: ncbiobj.hpp:180
CRef –.
Definition: ncbiobj.hpp:618
File Description:
Definition: layout_conf.hpp:56
static void EncodeValueRange(const string &range_min, const string &range_max, bool range_auto, string &value_range)
static CRef< objects::CCategory > CreateCategory(const string &name, const string &disp_name, const string &help, int order)
static CRef< objects::CChoice > CreateChoice(const string &name, const string &disp_name, const string &curr_val, const string &help, bool optional=false)
Definition: layout_conf.hpp:79
static CRef< objects::CHiddenSetting > CreateHiddenSetting(const string &name, const string &value)
static CRef< objects::CCheckBox > CreateCheckBox(const string &name, const string &disp_n, const string &help_text, const string &legend_txt, bool value, bool optional=false)
Definition: layout_conf.hpp:96
static CRef< objects::CRangeControl > CreateRangeControl(const string &name, const string &disp_name, const string &help, const string &value_min, const string &value_max, bool autoscale=true, bool inverse=false, bool optional=false)
static CRef< objects::CComment > CreateComment(const string &label, const string &pos_str)
static void DecodeValueRange(const string &value_range, string &range_min, string &range_max, bool &range_auto)
static CRef< objects::CTextBox > CreateTextBox(const string &name, const string &disp_n, const string &help_text, const string &value)
static CRef< objects::CChoiceItem > CreateChoiceItem(const string &name, const string &disp_name, const string &help, const string &legend_txt, bool optional=false)
Definition: layout_conf.hpp:61
The NCBI C++ standard methods for dealing with std::string.
#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 list< string > & Split(const CTempString str, const CTempString delim, list< string > &arr, TSplitFlags flags=0, vector< SIZE_TYPE > *token_pos=NULL)
Split a string using specified delimiters.
Definition: ncbistr.cpp:3461
@ fSplit_Tokenize
All delimiters are merged and trimmed, to get non-empty tokens only.
Definition: ncbistr.hpp:2508
#define NCBI_GUIWIDGETS_SEQGRAPHIC_EXPORT
Definition: gui_export.h:536
static const char label[]
range(_Ty, _Ty) -> range< _Ty >
const GenericPointer< typename T::ValueType > T2 value
Definition: pointer.h:1227
static void help(void)
Definition: pcregrep.c:870
CRef< objects::CCategory > m_Category
void AddSubcategory(CRef< objects::CCategory > sub_cat)
Modified on Tue Apr 23 07:40:12 2024 by modify_doxy.py rev. 669887