ARB
NT_edconf.cxx
Go to the documentation of this file.
1 // =============================================================== //
2 // //
3 // File : NT_edconf.cxx //
4 // Purpose : //
5 // //
6 // Institute of Microbiology (Technical University Munich) //
7 // http://www.arb-home.de/ //
8 // //
9 // =============================================================== //
10 
11 #include "NT_local.h"
12 #include "ad_trees.h"
13 
14 #include <TreeNode.h>
15 #include <TreeDisplay.hxx>
16 #include <RegExpr.hxx>
17 
18 #include <awt_sel_boxes.hxx>
19 #include <awt_misc.hxx>
20 #include <awt_config_manager.hxx>
21 #include <awt_modules.hxx>
22 
23 #include <aw_awars.hxx>
24 #include <aw_root.hxx>
25 #include <aw_msg.hxx>
26 #include <aw_select.hxx>
27 
28 #include <ad_config.h>
29 #include <ad_cb_prot.h>
30 
31 #include <arb_strbuf.h>
32 #include <arb_global_defs.h>
33 
34 #include <map>
35 #include <set>
36 #include <string>
37 
38 using namespace std;
39 
40 // AWT_canvas-local (%i=canvas-id):
41 #define AWAR_CL_SELECTED_CONFIGS "configuration_data/win%i/selected"
42 #define AWAR_CL_DISPLAY_CONFIG_MARKERS "configuration_data/win%i/display"
43 
44 #define AWAR_CONFIG_COMMENT "tmp/configuration/comment"
45 
51  CONF_COMBINE // logical AND
52 };
53 static void nt_extract_configuration(UNFIXED, extractType ext_type);
54 
55 typedef map<string, string> ConfigHits; // key=speciesname; value[markerIdx]==1 -> highlighted
56 
57 class ConfigMarkerDisplay FINAL_TYPE : public MarkerDisplay, virtual Noncopyable {
58  GBDATA *gb_main;
59  SmartPtr<ConstStrArray> config; // configuration names
60  StrArray errors; // config load-errors
61  ConfigHits hits;
62 
63  void updateHits() {
64  flush_cache();
65  hits.clear();
66  errors.erase();
67  for (int c = 0; c<size(); ++c) {
69  GBT_config cfg(gb_main, (*config)[c], error);
70 
71  for (int area = 0; area<=1 && !error; ++area) {
72  GBT_config_parser cparser(cfg, area);
73 
74  while (1) {
75  const GBT_config_item& item = cparser.nextItem(error);
76  if (error || item.type == CI_END_OF_CONFIG) break;
77  if (item.type == CI_SPECIES) {
78  ConfigHits::iterator found = hits.find(item.name);
79  if (found == hits.end()) {
80  string h(size(), '0');
81  h[c] = '1';
82  hits[item.name] = h;
83  }
84  else {
85  (found->second)[c] = '1';
86  }
87  }
88  }
89  }
90 
91  errors.put(ARB_strdup(null2empty(error)));
92  }
93  }
94 
95 public:
97  : MarkerDisplay(config_->size()),
98  gb_main(gb_main_),
99  config(config_)
100  {
101  updateHits();
102  }
103  const char *get_marker_name(int markerIdx) const OVERRIDE {
104  const char *error = errors[markerIdx];
105  const char *name = (*config)[markerIdx];
106  if (error && error[0]) return GBS_global_string("%s (Error: %s)", name, error);
107  return name;
108  }
109  void retrieve_marker_state(const char *speciesName, NodeMarkers& node) OVERRIDE {
110  ConfigHits::const_iterator found = hits.find(speciesName);
111  if (found != hits.end()) {
112  const string& hit = found->second;
113 
114  for (int c = 0; c<size(); ++c) {
115  if (hit[c] == '1') node.incMarker(c);
116  }
117  }
118  node.incNodeSize();
119  }
120 
121  void handle_click(int markerIdx, AW_MouseButton button, AWT_graphic_exports& exports) OVERRIDE {
122  if (button == AW_BUTTON_LEFT || button == AW_BUTTON_RIGHT) {
123  AW_root::SINGLETON->awar(AWAR_CONFIGURATION)->write_string(get_marker_name(markerIdx)); // select config of clicked marker
124  if (button == AW_BUTTON_RIGHT) { // extract configuration
126  exports.request_structure_update(); // needed to recalculate branch colors
127  }
128  }
129  }
130 };
131 
132 inline bool displays_config_markers(MarkerDisplay *md) { return dynamic_cast<ConfigMarkerDisplay*>(md); }
133 
134 #define CONFIG_SEPARATOR "\1"
135 
136 inline AW_awar *get_canvas_awar(const char *awar_name_format, int canvas_id) {
137  return AW_root::SINGLETON->awar_no_error(GBS_global_string(awar_name_format, canvas_id));
138 }
139 inline AW_awar *get_config_awar (int canvas_id) { return get_canvas_awar(AWAR_CL_SELECTED_CONFIGS, canvas_id); }
141 
143  // returns configs stored in awar as array (empty array if awar undefined!)
145 
146  AW_awar *awar = get_config_awar(canvas_id);
147  if (awar) {
148  char *config_str = awar->read_string();
149  GBT_splitNdestroy_string(*config, config_str, CONFIG_SEPARATOR, true);
150  }
151 
152  return config;
153 }
154 static void write_configs_to_awar(int canvas_id, const CharPtrArray& configs) {
155  char *config_str = GBT_join_strings(configs, CONFIG_SEPARATOR[0]);
157  free(config_str);
158 }
159 
160 // --------------------------------------------------------------------------------
161 
163 static bool allow_selection2awar_update = true;
164 static bool allow_to_activate_display = false;
165 
166 static void init_config_awars(AW_root *root) {
168 }
171  int ntw_id = ntw->get_index();
173  bool redraw = false;
174 
175  if (config->empty() || get_display_toggle_awar(ntw_id)->read_int() == 0) {
176  if (displays_config_markers(agt->get_marker_display())) { // only hide config markers
177  agt->hide_marker_display();
178  redraw = true;
179  }
180  }
181  else {
183 
184  if (activate) {
185  init_config_awars(aw_root);
186  ConfigMarkerDisplay *disp = new ConfigMarkerDisplay(config, ntw->gb_main);
187  agt->set_marker_display(disp);
188  redraw = true;
189  }
190  }
191 
192  if (selected_configs_list[ntw_id]) { // if configuration_marker_window has been opened
193  // update content of subset-selection (needed when reloading a config-set (not implemented yet) or after renaming a config)
195  awt_set_subset_selection_content(selected_configs_list[ntw_id], *config);
196  }
197 
199 }
200 
202  LocallyModify<bool> allowInteractiveActivation(allow_to_activate_display, true);
204 }
205 
206 static void configs_selectionlist_changed_cb(AW_selection *selected_configs, bool interactive_change, AW_CL ntw_id) {
208  LocallyModify<bool> allowInteractiveActivation(allow_to_activate_display, interactive_change);
209 
210  StrArray config;
211  selected_configs->get_values(config);
212  write_configs_to_awar(ntw_id, config);
213  }
214 }
215 
216 static void config_modified_cb(GBDATA *gb_cfg_area) { // called with "top_area" AND "middle_area" entry!
217  static GBDATA *gb_lastname = NULp;
218  static GB_ULONG lastcall = 0;
219 
220  GBDATA *gb_name = GB_entry(GB_get_father(gb_cfg_area), "name");
221  GB_ULONG thiscall = GB_time_of_day();
222 
223  bool is_same_modification = gb_name == gb_lastname && (thiscall == lastcall || thiscall == (lastcall+1));
224  if (!is_same_modification) { // avoid duplicate check if "top_area" and "middle_area" changed (=standard case)
225  // touch all canvas-specific awars that contain 'name'
226  const char *name = GB_read_char_pntr(gb_name);
227 
228  for (int canvas_id = 0; canvas_id<MAX_NT_WINDOWS; ++canvas_id) {
230  for (size_t c = 0; c<config->size(); ++c) {
231  if (strcmp((*config)[c], name) == 0) {
232  get_config_awar(canvas_id)->touch();
233  break;
234  }
235  }
236  }
237  }
238  gb_lastname = gb_name;
239  lastcall = thiscall;
240 }
241 
242 #define CONFIG_BASE_PATH "/configuration_data/configuration"
243 
245  static bool installed = false;
246  if (!installed) {
247  DatabaseCallback dbcb = makeDatabaseCallback(config_modified_cb);
250 
251  installed = true;
252  }
253 }
254 
256  GBDATA *gb_main = ntw->gb_main;
257 
258  int ntw_idx = ntw->get_index();
259  AW_awar *awar_selCfgs = ntw->awr->awar_string(GBS_global_string(AWAR_CL_SELECTED_CONFIGS, ntw_idx), "", gb_main);
260  awar_selCfgs->add_callback(makeRootCallback(selected_configs_awar_changed_cb, ntw));
261 
262  AW_awar *awar_dispCfgs = ntw->awr->awar_int(GBS_global_string(AWAR_CL_DISPLAY_CONFIG_MARKERS, ntw_idx), 1, gb_main);
263  awar_dispCfgs->add_callback(makeRootCallback(selected_configs_display_awar_changed_cb, ntw));
264 
265  awar_selCfgs->touch(); // force initial refresh
267 }
268 
269 // define where to store config-sets (using config-manager):
270 #define MANAGED_CONFIGSET_SECTION "configmarkers"
271 #define MANAGED_CONFIGSET_ENTRY "selected_configs"
272 
273 static void setup_configmarker_config_cb(AWT_config_definition& config, int ntw_id) {
274  AW_awar *selcfg_awar = get_config_awar(ntw_id);
275  nt_assert(selcfg_awar);
276  if (selcfg_awar) {
277  config.add(selcfg_awar->awar_name, MANAGED_CONFIGSET_ENTRY);
278  }
279 }
280 
281 struct ConfigModifier : virtual Noncopyable {
282  virtual ~ConfigModifier() {}
283  virtual const char *modify(const char *old) const = 0;
284 
285  bool modifyConfig(ConstStrArray& config) const {
286  bool changed = false;
287  for (size_t i = 0; i<config.size(); ++i) {
288  const char *newContent = modify(config[i]);
289  if (!newContent) {
290  config.remove(i);
291  changed = true;
292  }
293  else if (strcmp(newContent, config[i]) != 0) {
294  config.replace(i, newContent);
295  changed = true;
296  }
297  }
298  return changed;
299  }
300 };
301 class ConfigRenamer : public ConfigModifier { // derived from Noncopyable
302  const char *oldName;
303  const char *newName;
304  const char *modify(const char *name) const OVERRIDE {
305  return strcmp(name, oldName) == 0 ? newName : name;
306  }
307 public:
308  ConfigRenamer(const char *oldName_, const char *newName_)
309  : oldName(oldName_),
310  newName(newName_)
311  {}
312 };
313 class ConfigDeleter : public ConfigModifier { // derived from Noncopyable
314  const char *toDelete;
315  const char *modify(const char *name) const OVERRIDE {
316  return strcmp(name, toDelete) == 0 ? NULp : name;
317  }
318 public:
319  ConfigDeleter(const char *toDelete_)
320  : toDelete(toDelete_)
321  {}
322 };
323 
324 static char *correct_managed_configsets_cb(const char *key, const char *value, AW_CL cl_ConfigModifier) {
325  char *modified_value = NULp;
326  if (strcmp(key, MANAGED_CONFIGSET_ENTRY) == 0) {
327  const ConfigModifier *mod = (const ConfigModifier*)cl_ConfigModifier;
328  ConstStrArray config;
329  GBT_split_string(config, value, CONFIG_SEPARATOR, true);
330  if (mod->modifyConfig(config)) {
331  modified_value = GBT_join_strings(config, CONFIG_SEPARATOR[0]);
332  }
333  }
334  return modified_value ? modified_value : ARB_strdup(value);
335 }
336 static void modify_configurations(const ConfigModifier& mod) {
337  for (int canvas_id = 0; canvas_id<MAX_NT_WINDOWS; ++canvas_id) {
338  // modify currently selected configs:
340  if (mod.modifyConfig(*config)) {
341  write_configs_to_awar(canvas_id, *config);
342  }
343  }
344  // change all configuration-sets stored in config-manager (shared by all windows)
346 }
347 
348 static void configuration_renamed_cb(const char *old_name, const char *new_name) { modify_configurations(ConfigRenamer(old_name, new_name)); }
349 static void configuration_deleted_cb(const char *name) { modify_configurations(ConfigDeleter(name)); }
350 
352  AW_window_simple *aws = new AW_window_simple;
353 
354  int ntw_id = ntw->get_index();
355  aws->init(root, GBS_global_string("MARK_CONFIGS_%i", ntw_id), "Highlight configurations in tree");
356  aws->load_xfig("mark_configs.fig");
357 
358  aws->auto_space(10, 10);
359 
360  aws->at("close");
361  aws->callback(AW_POPDOWN);
362  aws->create_button("CLOSE", "CLOSE", "C");
363 
364  aws->at("help");
365  aws->callback(makeHelpCallback("species_configs_highlight.hlp"));
366  aws->create_button("HELP", "HELP", "H");
367 
368 
369  aws->at("list");
371  AW_selection *sub_sel;
372  {
373  LocallyModify<bool> avoid(allow_selection2awar_update, false); // avoid awar gets updated from empty sub-selectionlist
374  sub_sel = awt_create_subset_selection_list(aws, all_configs->get_sellist(), "selected", "add", "sort", false, configs_selectionlist_changed_cb, ntw->get_index());
375  }
376 
378  selected_configs_list[ntw_id] = sub_sel;
379 
380  // @@@ would like to use ntw-specific awar for this selection list (opening two lists links them)
381 
382  aws->at("show");
383  aws->label("Display?");
384  aws->create_toggle(get_display_toggle_awar(ntw_id)->awar_name);
385 
386  aws->at("settings");
387  aws->callback(TREE_create_marker_settings_window);
388  aws->create_autosize_button("SETTINGS", "Settings", "S");
389 
391 
392  return aws;
393 }
394 
395 // -----------------------------
396 // class Store_species
397 
398 class Store_species : virtual Noncopyable {
399  // stores an amount of species:
400  TreeNode *node;
401  Store_species *next;
402 public:
404  node = aNode;
405  next = NULp;
406  }
407  ~Store_species();
408 
410  nt_assert(!next);
411  next = list;
412  return this;
413  }
414 
415  Store_species* remove() {
416  Store_species *follower = next;
417  next = NULp;
418  return follower;
419  }
420 
421  TreeNode *getNode() const { return node; }
422 
423  void call(void (*aPizza)(TreeNode*)) const;
424 };
425 
427  delete next;
428 }
429 
430 void Store_species::call(void (*aPizza)(TreeNode*)) const {
431  aPizza(node);
432  if (next) next->call(aPizza);
433 }
434 
435 static void unmark_species(TreeNode *node) {
436  nt_assert(node);
437  nt_assert(node->gb_node);
438  nt_assert(GB_read_flag(node->gb_node)!=0);
439  GB_write_flag(node->gb_node, 0);
440 }
441 
442 static void mark_species(TreeNode *node, Store_species **extra_marked_species) {
443  nt_assert(node);
444  nt_assert(node->gb_node);
445  nt_assert(GB_read_flag(node->gb_node)==0);
446  GB_write_flag(node->gb_node, 1);
447 
448  *extra_marked_species = (new Store_species(node))->add(*extra_marked_species);
449 }
450 
451 
452 
454  nt_assert(node);
455  while (!node->is_leaf()) {
456  node = node->get_rightson();
457  nt_assert(node);
458  }
459  return node;
460 }
461 
463  if (node) {
464  TreeNode *father = node->get_father();
465  while (father) {
466  if (father->rightson==node) {
467  node = rightmost_leaf(father->get_leftson());
468  nt_assert(node->is_leaf());
469  if (!node->gb_node) { // Zombie
470  node = left_neighbour_leaf(node);
471  }
472  return node;
473  }
474  node = father;
475  father = node->get_father();
476  }
477  }
478  return NULp;
479 }
480 
482  Store_species **extra_marked_species, int use_species_aside,
483  int *auto_mark, int marked_at_left, int *marked_at_right)
484 {
516  if (!tree) return 0;
517  if (tree->is_leaf()) {
518  if (!tree->gb_node) {
519  *marked_at_right = marked_at_left;
520  return 0; // Zombie
521  }
522 
523  if (!GB_read_flag(tree->gb_node)) { // unmarked species
524  if (*auto_mark) {
525  (*auto_mark)--;
526  mark_species(tree, extra_marked_species);
527  }
528  else {
529  *marked_at_right = 0;
530  return 0;
531  }
532  }
533  else { // marked species
534  if (marked_at_left<use_species_aside) {
535  // on the left side there are not as many marked species as needed!
536 
537  nt_assert(marked_at_left>=0);
538 
539  TreeNode *leaf_at_left = tree;
540  int step_over = marked_at_left+1; // step over myself
541  int then_mark = use_species_aside-marked_at_left;
542 
543  while (step_over--) { // step over self and over any adjacent, marked species
544  leaf_at_left = left_neighbour_leaf(leaf_at_left);
545  }
546 
547  Store_species *marked_back = NULp;
548  while (leaf_at_left && then_mark--) { // then additionally mark some species
549  if (GB_read_flag(leaf_at_left->gb_node) == 0) { // if they are not marked yet
550  mark_species(leaf_at_left, extra_marked_species);
551  marked_back = (new Store_species(leaf_at_left))->add(marked_back);
552  }
553  leaf_at_left = left_neighbour_leaf(leaf_at_left);
554  }
555 
556  while (marked_back) {
557  GBS_chrcat(memfile, 1); // Separated by 1
558  GBS_strcat(memfile, "L");
559  GBS_strcat(memfile, marked_back->getNode()->name);
560  GBS_write_hash(used, marked_back->getNode()->name, 1); // Mark species
561 
562  Store_species *rest = marked_back->remove();
563  delete marked_back;
564  marked_back = rest;
565  }
566 
567  marked_at_left = use_species_aside;
568  }
569  // now use_species_aside species to left are marked!
570  *auto_mark = use_species_aside;
571  }
572 
573  GBS_chrcat(memfile, 1); // Separated by 1
574  GBS_strcat(memfile, "L");
575  GBS_strcat(memfile, tree->name);
576  GBS_write_hash(used, tree->name, 1); // Mark species
577 
578  *marked_at_right = marked_at_left+1;
579  return 1;
580  }
581 
582  long oldpos = GBS_memoffset(memfile);
583  if (tree->gb_node && tree->name) { // but we are a group
584  GBDATA *gb_grouped = GB_entry(tree->gb_node, "grouped");
585  GBS_chrcat(memfile, 1); // Separated by 1
586  if (gb_grouped && GB_read_byte(gb_grouped)) {
587  GBS_strcat(memfile, "F");
588  }
589  else {
590  GBS_strcat(memfile, "G");
591  }
592 
593  GBS_strcat(memfile, tree->name);
594  }
595 
596  int right_of_leftson;
597  long nspecies= nt_build_conf_string_rek(used, tree->get_leftson(), memfile, extra_marked_species, use_species_aside, auto_mark, marked_at_left, &right_of_leftson);
598  nspecies += nt_build_conf_string_rek(used, tree->get_rightson(), memfile, extra_marked_species, use_species_aside, auto_mark, right_of_leftson, marked_at_right);
599 
600  if (tree->gb_node && tree->name) { // but we are a group
601  GBS_chrcat(memfile, 1); // Separated by 1
602  GBS_chrcat(memfile, 'E'); // Group end indicated by 'E'
603  }
604 
605  if (!nspecies) {
606  long newpos = GBS_memoffset(memfile);
607  GBS_str_cut_tail(memfile, newpos-oldpos); // delete group info
608  }
609  return nspecies;
610 }
611 
614  const char *last_group_name;
615 };
616 
617 static void nt_build_sai_string_by_hash(const char *key, long /*val*/, void *cd_sai_builder) {
618  SAI_string_builder *sai_builder = (SAI_string_builder*)cd_sai_builder;
619 
620  const char *sep = strchr(key, 1);
621  if (sep) {
622  GBS_strstruct *sai_middle = sai_builder->sai_middle;
623  const char *last_group_name = sai_builder->last_group_name;
624 
625  if (!last_group_name || strncmp(key, last_group_name, sep-key)) { // new group
626  if (last_group_name) {
627  GBS_chrcat(sai_middle, 1); // Separated by 1
628  GBS_chrcat(sai_middle, 'E'); // End of old group
629  }
630  GBS_chrcat(sai_middle, 1); // Separated by 1
631  GBS_strcat(sai_middle, "FSAI:");
632  GBS_strncat(sai_middle, key, sep-key);
633  sai_builder->last_group_name = key;
634  }
635  GBS_chrcat(sai_middle, 1); // Separated by 1
636  GBS_strcat(sai_middle, "S");
637  GBS_strcat(sai_middle, sep+1);
638  }
639 }
640 
641 static void nt_build_sai_string(const char *topAreaSaiList, GBS_strstruct *topfile, GBS_strstruct *middlefile) {
642  // collect all Sais,
643  // place some SAI in top area (those listed in 'toparea_SAIs'; SAI-groups will be ignored here)
644  // rest of SAI goes into middle area (SAI-groups respected here)
645 
646  GBDATA *gb_sai_data = GBT_get_SAI_data(GLOBAL.gb_main);
647  if (gb_sai_data) {
649 
650  ConstStrArray topAreaSai;
651  GBT_split_string(topAreaSai, topAreaSaiList, ",;: \t", true);
652 
653  for (GBDATA *gb_sai = GBT_first_SAI_rel_SAI_data(gb_sai_data); gb_sai; gb_sai = GBT_next_SAI(gb_sai)) {
654  GBDATA *gb_name = GB_search(gb_sai, "name", GB_FIND);
655  if (gb_name) {
656  char *name = GB_read_string(gb_name);
657 
658  bool wantedInTop = false;
659  for (unsigned s = 0; !wantedInTop && s<topAreaSai.size(); ++s) {
660  wantedInTop = strcmp(name, topAreaSai[s]) == 0;
661  }
662 
663  if (!wantedInTop) {
664  GBDATA *gb_gn = GB_search(gb_sai, "sai_group", GB_FIND);
665  char *gn;
666 
667  if (gb_gn) gn = GB_read_string(gb_gn);
668  else gn = ARB_strdup("SAI's");
669 
670  char *cn = new char[strlen(gn) + strlen(name) + 2];
671  sprintf(cn, "%s%c%s", gn, 1, name);
672  GBS_write_hash(hash, cn, 1);
673  delete [] cn;
674  free(gn);
675  }
676  free(name);
677  }
678  }
679 
680  // add top area SAIs in defined order:
681  for (unsigned s = 0; s<topAreaSai.size(); ++s) {
682  GBDATA *gb_sai = GBT_find_SAI_rel_SAI_data(gb_sai_data, topAreaSai[s]);
683  if (gb_sai) {
684  GBS_chrcat(topfile, 1); // separated by ASCII 1
685  GBS_strcat(topfile, "S");
686  GBS_strcat(topfile, topAreaSai[s]);
687  }
688  }
689 
690  // open surrounding SAI-group:
691  GBS_chrcat(middlefile, 1);
692  GBS_strcat(middlefile, "GSAI-Maingroup");
693 
694  SAI_string_builder sai_builder = { middlefile, NULp };
696  if (sai_builder.last_group_name) {
697  GBS_chrcat(middlefile, 1); // Separated by 1
698  GBS_chrcat(middlefile, 'E'); // End of old group
699  }
700 
701  // close surrounding SAI-group:
702  GBS_chrcat(middlefile, 1);
703  GBS_chrcat(middlefile, 'E');
704 
705  GBS_free_hash(hash);
706  }
707 }
708 
709 static void nt_build_conf_marked(GB_HASH *used, GBS_strstruct *file) {
710  GBS_chrcat(file, 1); // Separated by 1
711  GBS_strcat(file, "FMore Sequences");
712  GBDATA *gb_species;
713  for (gb_species = GBT_first_marked_species(GLOBAL.gb_main);
714  gb_species;
715  gb_species = GBT_next_marked_species(gb_species)) {
716  char *name = GBT_read_string(gb_species, "name");
717  if (GBS_read_hash(used, name)) {
718  free(name);
719  continue;
720  }
721  GBS_chrcat(file, 1);
722  GBS_strcat(file, "L");
723  GBS_strcat(file, name);
724  free(name);
725  }
726 
727  GBS_chrcat(file, 1); // Separated by 1
728  GBS_chrcat(file, 'E'); // Group end indicated by 'E'
729 }
730 
733  AW_root *aw_root = AW_root::SINGLETON;
734  char *cn = aw_root->awar(AWAR_CONFIGURATION)->read_string();
735 
736  if (strcmp(cn, NO_CONFIG_SELECTED) == 0) {
737  aw_message("Please select a configuration");
738  }
739  else {
740  GB_ERROR error = NULp;
741  GBT_config cfg(GLOBAL.gb_main, cn, error);
742 
743  if (!error) {
744  size_t unknown_species = 0;
745  bool refresh = false;
746 
747  GB_HASH *was_marked = NULp; // only used for CONF_COMBINE
748 
749  switch (ext_type) {
750  case CONF_EXTRACT: // unmark all
752  refresh = true;
753  break;
754 
755  case CONF_COMBINE: // store all marked species in hash and unmark them
758  refresh = GBS_hash_elements(was_marked);
759  break;
760 
761  default:
762  break;
763  }
764 
765  for (int area = 0; area<=1 && !error; ++area) {
766  GBT_config_parser cparser(cfg, area);
767 
768  while (1) {
769  const GBT_config_item& citem = cparser.nextItem(error);
770  if (error || citem.type == CI_END_OF_CONFIG) break;
771 
772  if (citem.type == CI_SPECIES) {
773  GBDATA *gb_species = GBT_find_species(GLOBAL.gb_main, citem.name);
774 
775  if (gb_species) {
776  int oldmark = GB_read_flag(gb_species);
777  int newmark = oldmark;
778  switch (ext_type) {
779  case CONF_EXTRACT:
780  case CONF_MARK: newmark = 1; break;
781  case CONF_UNMARK: newmark = 0; break;
782  case CONF_INVERT: newmark = !oldmark; break;
783  case CONF_COMBINE: {
784  nt_assert(!oldmark); // should have been unmarked above
785  newmark = GBS_read_hash(was_marked, citem.name); // mark if was_marked
786  break;
787  }
788  default: nt_assert(0); break;
789  }
790  if (newmark != oldmark) {
791  GB_write_flag(gb_species, newmark);
792  refresh = true;
793  }
794  }
795  else {
796  unknown_species++;
797  }
798  }
799  }
800  }
801 
802  if (was_marked) GBS_free_hash(was_marked);
803  if (unknown_species>0 && !error) error = GBS_global_string("configuration '%s' contains %zu unknown species", cn, unknown_species);
804  if (refresh) aw_root->awar(AWAR_TREE_REFRESH)->touch();
805  }
806  aw_message_if(error);
807  }
808  free(cn);
809 }
810 
813 
814  AW_awar *awar_selected = aww->get_root()->awar(AWAR_CONFIGURATION);
815  char *name = awar_selected->read_string();
816  GBDATA *gb_configuration = GBT_find_configuration(GLOBAL.gb_main, name);
817 
818  if (gb_configuration) {
819  dbsel->get_sellist()->move_selection(1);
820 
821  GB_ERROR error = GB_delete(gb_configuration);
822  error = ta.close(error);
823  if (error) {
824  aw_message(error);
825  }
826  else {
828  }
829  }
830  free(name);
831 }
832 
837 };
838 
839 static GB_ERROR nt_create_configuration(TreeNode *tree, const char *conf_name, int use_species_aside, ConfigCreation creation) {
840  GB_ERROR error = NULp;
841 
842  if (!conf_name || !conf_name[0]) error = "no config name given";
843  else {
844  if (use_species_aside==-1) {
845  static int last_used_species_aside = 3;
846  {
847  const char *val = GBS_global_string("%i", last_used_species_aside);
848  char *use_species = aw_input("How many extra species to view aside marked:", val);
849  if (use_species) use_species_aside = atoi(use_species);
850  free(use_species);
851  }
852 
853  if (use_species_aside<1) error = "illegal number of 'species aside'";
854  else last_used_species_aside = use_species_aside; // remember for next time
855  }
856 
857  if (!error) {
858  GB_transaction ta(GLOBAL.gb_main); // open close transaction
860 
861  GBT_config newcfg;
862  {
864  GBS_strstruct topfile(1000);
865  GBS_strstruct midfile(10000);
866  {
867  GBS_strstruct middlefile(10000);
868 
869  nt_build_sai_string(awr->awar(AWAR_TOPAREA_SAIS)->read_char_pntr(), &topfile, &midfile);
870 
871  if (use_species_aside) {
872  Store_species *extra_marked_species = NULp;
873  int auto_mark = 0;
874  int marked_at_right;
875 
876  nt_build_conf_string_rek(used, tree, &middlefile, &extra_marked_species, use_species_aside, &auto_mark, use_species_aside, &marked_at_right);
877  if (extra_marked_species) {
878  extra_marked_species->call(unmark_species);
879  delete extra_marked_species;
880  }
881  }
882  else {
883  int dummy_1=0, dummy_2;
884  nt_build_conf_string_rek(used, tree, &middlefile, NULp, 0, &dummy_1, 0, &dummy_2);
885  }
886  nt_build_conf_marked(used, &midfile);
887  midfile.ncat(middlefile.get_data(), middlefile.get_position());
888  }
889 
890  newcfg.set_definition(GBT_config::TOP_AREA, topfile.release());
892 
893  GBS_free_hash(used);
894  }
895 
896  GBT_config previous(GLOBAL.gb_main, conf_name, error);
897  error = NULp; // ignore
898 
899  const char *prevComment = NULp; // old or fixed comment
900  const char *comment = NULp;
901  bool warnIfSavingDefault = true;
902  switch (creation) {
903  case BY_CALLING_THE_EDITOR: { // always saves DEFAULT_CONFIGURATION!
904  prevComment = "This configuration will be OVERWRITTEN each time\nARB_EDIT4 is started w/o specifying a config!\n---";
905  comment = "created for ARB_EDIT4";
906  warnIfSavingDefault = false;
907  break;
908  }
909  case FROM_MANAGER: {
910  if (previous.exists()) {
911  prevComment = previous.get_comment();
912  comment = "updated manually";
913  }
914  else {
915  prevComment = awr->awar(AWAR_CONFIG_COMMENT)->read_char_pntr();
916  if (!prevComment[0]) prevComment = NULp;
917  comment = "created manually";
918  }
919  break;
920  }
921  case FROM_IMPORTER:
922  nt_assert(!previous.exists());
923  comment = "created by importer";
924  break;
925  }
926 
927  nt_assert(implicated(prevComment, comment));
928  if (comment) {
929  // annotate with treename
930  const char *treename = awr->awar(AWAR_TREE_NAME)->read_char_pntr();
931  if (treename[0]) {
932  comment = GBS_global_string("%s (tree=%s)", comment, treename);
933  }
934  else {
935  comment = GBS_global_string("%s (no tree)", comment);
936  }
937  char *dated = GBS_log_action_to(prevComment, comment, true);
938  newcfg.set_comment(dated);
939  free(dated);
940  }
941 
942  error = newcfg.save(GLOBAL.gb_main, conf_name, warnIfSavingDefault);
943  awr->awar(AWAR_CONFIGURATION)->touch(); // refreshes comment field
944  }
945  }
946 
947  return error;
948 }
949 
951  const char *cfgName = AW_root::SINGLETON->awar(AWAR_CONFIGURATION)->read_char_pntr();
953  aw_message_if(err);
954 }
955 
957  AW_awar *awar_curr_cfg = aww->get_root()->awar(AWAR_CONFIGURATION);
958  char *old_name = awar_curr_cfg->read_string();
959 
960  {
961  char *new_name = aw_input("Rename selection", "Enter the new name of the selection", old_name);
962  if (new_name) {
963  GB_ERROR err = NULp;
964 
965  {
967 
968  GBDATA *gb_existing_cfg = GBT_find_configuration(GLOBAL.gb_main, new_name);
969  if (gb_existing_cfg) err = GBS_global_string("There is already a selection named '%s'", new_name);
970  else {
971  GBDATA *gb_old_cfg = GBT_find_configuration(GLOBAL.gb_main, old_name);
972  if (gb_old_cfg) {
973  GBDATA *gb_name = GB_entry(gb_old_cfg, "name");
974  if (gb_name) {
975  err = GB_write_string(gb_name, new_name);
976  if (!err) awar_curr_cfg->write_string(new_name);
977  }
978  else err = "Selection has no name";
979  }
980  else err = "Can't find that selection";
981  }
982  err = ta.close(err);
983  }
984 
985  if (err) {
986  aw_message(err);
987  }
988  else {
989  nt_assert(GB_get_transaction_level(GLOBAL.gb_main) == 0); // otherwise callback below behaves wrong
990  configuration_renamed_cb(old_name, new_name);
991  }
992  free(new_name);
993  }
994  }
995  free(old_name);
996 }
997 
999  const char *config = root->awar(AWAR_CONFIGURATION)->read_char_pntr();
1000 
1001  bool nonexisting_config = false;
1002  GBDATA *gb_target_commment = NULp;
1003  if (config[0]) {
1004  GBDATA *gb_configuration = GBT_find_configuration(GLOBAL.gb_main, config);
1005  if (gb_configuration) {
1006  gb_target_commment = GB_entry(gb_configuration, "comment");
1007  }
1008  else {
1009  nonexisting_config = true;
1010  }
1011  }
1012 
1013  AW_awar *awar_comment = root->awar(AWAR_CONFIG_COMMENT);
1014  if (gb_target_commment) {
1015  if (!awar_comment->is_mapped()) awar_comment->write_string("");
1016  awar_comment->map(gb_target_commment);
1017  }
1018  else {
1019  char *reuse_comment = nonexisting_config ? awar_comment->read_string() : ARB_strdup("");
1020  if (awar_comment->is_mapped()) {
1021  awar_comment->unmap();
1022  }
1023  awar_comment->write_string(reuse_comment);
1024  free(reuse_comment);
1025  }
1026 }
1028  // called when comment-awar changes or gets re-map-ped
1029 
1030  AW_awar *awar_comment = root->awar(AWAR_CONFIG_COMMENT);
1031  const char *comment = awar_comment->read_char_pntr();
1032 
1033  const char *config = root->awar(AWAR_CONFIGURATION)->read_char_pntr();
1034  GBDATA *gb_configuration = config[0] ? GBT_find_configuration(GLOBAL.gb_main, config) : NULp;
1035 
1036  GB_ERROR error = NULp;
1037  if (awar_comment->is_mapped()) {
1038  if (!comment[0]) { // empty existing comment
1039  nt_assert(gb_configuration);
1040  GBDATA *gb_commment = GB_entry(gb_configuration, "comment");
1041  nt_assert(gb_commment);
1042  if (gb_commment) {
1043  awar_comment->unmap();
1044  error = GB_delete(gb_commment);
1045  }
1046  }
1047  }
1048  else {
1049  if (comment[0]) { // ignore empty comment for unmapped awar
1050  if (gb_configuration) {
1051  nt_assert(!GB_entry(gb_configuration, "comment"));
1052  error = GBT_write_string(gb_configuration, "comment", comment);
1053  if (!error) {
1054  awar_comment->write_string("");
1056  }
1057  }
1058  else if (!config[0]) {
1059  // do NOT warn if name field contains (not yet) existing name
1060  // (allows to edit comment while creating new config)
1061  error = "Please select an existing species selection to edit its comment";
1062  }
1063  }
1064  }
1065 
1066  aw_message_if(error);
1067 }
1068 
1069 static void init_config_admin_awars(AW_root *root) {
1070  init_config_awars(root);
1073 }
1074 
1075 #pragma GCC diagnostic push
1076 #if (GCC_VERSION_CODE<700)
1077 #pragma GCC diagnostic ignored "-Wstrict-overflow" // gcc 6.x produces a bogus overflow warning (gcc 7.x is smart enough)
1078 #endif
1079 
1080 static GB_ERROR swap_configs(GBDATA *gb_main, StrArray& config, int i1, int i2) {
1081  GB_ERROR error = NULp;
1082 
1083  if (i1>i2) swap(i1, i2); // otherwise overwrite below does not work
1084  nt_assert(i1<i2 && i1>=0 && i2<int(config.size()));
1085 
1086  GBT_config c1(gb_main, config[i1], error);
1087  if (!error) {
1088  GBT_config c2(gb_main, config[i2], error);
1089  if (!error) error = c1.saveAsOver(gb_main, config[i1], config[i2], false);
1090  if (!error) error = c2.saveAsOver(gb_main, config[i2], config[i1], false);
1091  if (!error) config.swap(i1, i2);
1092  }
1093  return error;
1094 }
1095 
1096 #pragma GCC diagnostic pop
1097 
1099  AW_root *awr = aww->get_root();
1100  AW_awar *awar_config = awr->awar(AWAR_CONFIGURATION);
1101  const char *selected = awar_config->read_char_pntr();
1102 
1103  if (selected && selected[0]) {
1104  AW_selection_list *sellist = sel->get_sellist();
1105 
1106  int source_idx = sellist->get_index_of(AW_scalar(selected));
1107  int target_idx = -1;
1108  switch (mode) {
1109  case ARM_TOP: target_idx = 0; break;
1110  case ARM_UP: target_idx = source_idx-1; break;
1111  case ARM_DOWN: target_idx = source_idx+1; break;
1112  case ARM_BOTTOM: target_idx = -1; break;
1113  }
1114 
1115  int entries = sellist->size();
1116  target_idx = (target_idx+entries)%entries;
1117 
1118  {
1119  GBDATA *gb_main = sel->get_gb_main();
1120  GB_transaction ta(gb_main);
1121 
1122  StrArray config;
1123  sellist->to_array(config, true);
1124 
1125  GB_ERROR error = NULp;
1126  if (source_idx<target_idx) {
1127  for (int i = source_idx+1; i<=target_idx; ++i) {
1128  swap_configs(gb_main, config, i-1, i);
1129  }
1130  }
1131  else if (source_idx>target_idx) {
1132  for (int i = source_idx-1; i>=target_idx; --i) {
1133  swap_configs(gb_main, config, i+1, i);
1134  }
1135  }
1136 
1137  error = ta.close(error);
1138  aw_message_if(error);
1139  }
1140  awar_config->touch();
1141  }
1142 }
1143 
1144 static void clear_comment_cb(AW_window *aww) {
1145  AW_awar *awar_comment = aww->get_root()->awar(AWAR_CONFIG_COMMENT);
1146  char *comment = awar_comment->read_string();
1147 
1149  GBT_splitNdestroy_string(line, comment, '\n');
1150 
1151  bool removedDatedLines = false;
1152  RegExpr datedLine("^([A-Z][a-z]{2}\\s){2}[0-9]+\\s([0-9]{2}:){2}[0-9]{2}\\s[0-9]{4}:\\s", false); // matches lines created with GBS_log_action_to(..., stamp=true)
1153  for (int i = line.size()-1; i >= 0; --i) {
1154  const RegMatch *match = datedLine.match(line[i]);
1155  gb_assert(implicated(!match, !datedLine.has_failed())); // assert RegExpr compiles
1156  if (match && match->didMatch()) {
1157  line.safe_remove(i);
1158  removedDatedLines = true;
1159  }
1160  }
1161 
1162  if (!removedDatedLines) line.clear(); // erase all
1163 
1164  comment = GBT_join_strings(line, '\n');
1165  awar_comment->write_string(comment);
1166 }
1167 
1169  static AW_window_simple *existing_aws[MAX_NT_WINDOWS] = { MAX_NT_WINDOWS_NULLINIT };
1170 
1171  int ntw_id = ntw->get_index();
1172  if (!existing_aws[ntw_id]) {
1174 
1175  AW_window_simple *aws = new AW_window_simple;
1176  aws->init(root, GBS_global_string("SPECIES_SELECTIONS_%i", ntw_id), "Species Selections");
1177  aws->load_xfig("nt_selection.fig");
1178 
1179  aws->at("close");
1180  aws->callback(AW_POPDOWN);
1181  aws->create_button("CLOSE", "CLOSE", "C");
1182 
1183  aws->at("help");
1184  aws->callback(makeHelpCallback("species_configs.hlp"));
1185  aws->create_button("HELP", "HELP", "H");
1186 
1187  aws->at("name");
1188  aws->create_input_field(AWAR_CONFIGURATION);
1189 
1190  aws->at("comment");
1191  aws->create_text_field(AWAR_CONFIG_COMMENT);
1192 
1193  aws->at("clr");
1194  aws->callback(clear_comment_cb);
1195  aws->create_autosize_button("CLEAR", "Clear", "l");
1196 
1197  aws->at("list");
1199 
1200  aws->button_length(8);
1201 
1202  aws->at("store");
1203  aws->callback(makeWindowCallback(nt_store_configuration, ntw));
1204  aws->create_button(GBS_global_string("STORE_%i", ntw_id), "STORE", "S");
1205 
1206  aws->at("extract");
1207  aws->callback(makeWindowCallback(nt_extract_configuration, CONF_EXTRACT));
1208  aws->create_button("EXTRACT", "EXTRACT", "E");
1209 
1210  aws->at("mark");
1211  aws->callback(makeWindowCallback(nt_extract_configuration, CONF_MARK));
1212  aws->create_button("MARK", "MARK", "M");
1213 
1214  aws->at("unmark");
1215  aws->callback(makeWindowCallback(nt_extract_configuration, CONF_UNMARK));
1216  aws->create_button("UNMARK", "UNMARK", "U");
1217 
1218  aws->at("invert");
1219  aws->callback(makeWindowCallback(nt_extract_configuration, CONF_INVERT));
1220  aws->create_button("INVERT", "INVERT", "I");
1221 
1222  aws->at("combine");
1223  aws->callback(makeWindowCallback(nt_extract_configuration, CONF_COMBINE));
1224  aws->create_button("COMBINE", "COMBINE", "C");
1225 
1226  aws->at("delete");
1227  aws->callback(makeWindowCallback(nt_delete_configuration, dbsel));
1228  aws->create_button("DELETE", "DELETE", "D");
1229 
1230  aws->at("rename");
1231  aws->callback(nt_rename_configuration);
1232  aws->create_button("RENAME", "RENAME", "R");
1233 
1234  aws->at("highlight");
1235  aws->callback(makeCreateWindowCallback(create_configuration_marker_window, ntw));
1236  aws->create_autosize_button(GBS_global_string("HIGHLIGHT_%i", ntw_id), "Highlight in tree", "t");
1237 
1238  aws->button_length(0);
1239  aws->at("sort");
1241 
1242  existing_aws[ntw_id] = aws;
1243  }
1244  return existing_aws[ntw_id];
1245 }
1246 
1248  create_configuration_admin_window(aw_main->get_root(), ntw)->activate();
1249 }
1250 
1251 // -----------------------------------------
1252 // various ways to start the editor
1253 
1255  aww->hide();
1256 
1257  const char *cfgName = aww->get_root()->awar(AWAR_CONFIGURATION)->read_char_pntr();
1258  char *quotedCfg = GBK_singlequote(cfgName);
1259 
1260  AWT_system_cb(GBS_global_string("arb_edit4 -c %s &", quotedCfg));
1261 
1262  free(quotedCfg);
1263 }
1264 
1266  static AW_window_simple *aws = NULp;
1267  if (!aws) {
1268  init_config_awars(awr);
1269 
1270  aws = new AW_window_simple;
1271  aws->init(awr, "SELECT_CONFIGURATION", "SELECT A CONFIGURATION");
1272  aws->at(10, 10);
1273  aws->auto_space(0, 0);
1275  aws->at_newline();
1276 
1277  aws->callback(nt_start_editor_on_configuration);
1278  aws->create_button("START", "START");
1279 
1280  aws->callback(AW_POPDOWN);
1281  aws->create_button("CLOSE", "CLOSE", "C");
1282 
1283  aws->window_fit();
1284  }
1285  return aws;
1286 }
1287 
1288 void NT_start_editor_on_tree(AW_window *aww, int use_species_aside, TREE_canvas *ntw) {
1289  init_config_awars(aww->get_root());
1291  if (!error) error = GBK_system("arb_edit4 -c " DEFAULT_CONFIGURATION " &");
1292  aw_message_if(error);
1293 }
1294 
1296  init_config_awars(ntw->awr);
1297 
1298  const char *dated_suffix = ARB_dateTime_suffix();
1299  char *configName = GBS_global_string_copy("imported_%s", dated_suffix);
1300 
1301  // ensure unique config-name
1302  {
1303  int unique = 1;
1304  GB_transaction ta(ntw->gb_main);
1305  while (GBT_find_configuration(ntw->gb_main, configName)) {
1306  freeset(configName, GBS_global_string_copy("imported_%s_%i", dated_suffix, ++unique));
1307  }
1308  }
1309 
1311  aw_message_if(error);
1312 
1313  free(configName);
1314 }
1315 
1316 void NT_create_config_after_import(TREE_canvas *ntw, bool imported_from_scratch) {
1322  if (imported_from_scratch) {
1324  }
1325  else {
1326  GB_transaction ta(ntw->gb_main);
1327 
1328  // remember marks + mark queried species:
1329  for (GBDATA *gb_species = GBT_first_species(ntw->gb_main); gb_species; gb_species = GBT_next_species(gb_species)) {
1330  GB_write_user_flag(gb_species, GB_USERFLAG_WASMARKED, GB_read_flag(gb_species));
1331  GB_write_flag(gb_species, GB_user_flag(gb_species, GB_USERFLAG_QUERY));
1332  }
1333 
1335 
1336  // restore old marks:
1337  for (GBDATA *gb_species = GBT_first_species(ntw->gb_main); gb_species; gb_species = GBT_next_species(gb_species)) {
1338  GB_write_flag(gb_species, GB_user_flag(gb_species, GB_USERFLAG_WASMARKED));
1340  }
1341  }
1342 }
1343 
1344 
1345 
void NT_popup_configuration_admin(AW_window *aw_main, TREE_canvas *ntw)
Definition: NT_edconf.cxx:1247
GB_HASH * GBT_create_marked_species_hash(GBDATA *gb_main)
Definition: adhashtools.cxx:40
GB_ERROR GBK_system(const char *system_command)
Definition: arb_msg.cxx:519
void GBS_hash_do_const_sorted_loop(const GB_HASH *hs, gb_hash_const_loop_type func, gbs_hash_compare_function sorter, void *client_data)
Definition: adhash.cxx:644
const char * GB_ERROR
Definition: arb_core.h:25
void set_marker_display(MarkerDisplay *display)
static void reorder_configs_cb(AW_window *aww, awt_reorder_mode mode, AW_DB_selection *sel)
Definition: NT_edconf.cxx:1098
static void configuration_deleted_cb(const char *name)
Definition: NT_edconf.cxx:349
static AW_selection * selected_configs_list[MAX_NT_WINDOWS]
Definition: NT_edconf.cxx:162
void add(const char *awar_name, const char *config_name)
GBDATA * GBT_first_marked_species(GBDATA *gb_main)
Definition: aditem.cxx:113
size_t size() const
Definition: arb_strarray.h:85
AW_window * NT_create_startEditorOnOldConfiguration_window(AW_root *awr)
Definition: NT_edconf.cxx:1265
static void selected_configs_display_awar_changed_cb(AW_root *root, TREE_canvas *ntw)
Definition: NT_edconf.cxx:201
#define GB_USERFLAG_WASMARKED
Definition: arbdb.h:56
void NT_create_config_after_import(TREE_canvas *ntw, bool imported_from_scratch)
Definition: NT_edconf.cxx:1316
Store_species(TreeNode *aNode)
Definition: NT_edconf.cxx:403
GB_ERROR GB_add_hierarchy_callback(GBDATA *gb_main, const char *db_path, GB_CB_TYPE type, const DatabaseCallback &dbcb)
Definition: ad_cb.cxx:432
#define implicated(hypothesis, conclusion)
Definition: arb_assert.h:289
static void nt_build_sai_string_by_hash(const char *key, long, void *cd_sai_builder)
Definition: NT_edconf.cxx:617
long GBS_write_hash(GB_HASH *hs, const char *key, long val)
Definition: adhash.cxx:457
GB_ERROR GB_write_string(GBDATA *gbd, const char *s)
Definition: arbdb.cxx:1385
static AW_window * create_configuration_marker_window(AW_root *root, TREE_canvas *ntw)
Definition: NT_edconf.cxx:351
#define CONFIG_SEPARATOR
Definition: NT_edconf.cxx:134
#define ASSERT_NO_ERROR(errorExpr)
Definition: arb_assert.h:360
static const int MIDDLE_AREA
Definition: ad_config.h:46
Store_species * add(Store_species *list)
Definition: NT_edconf.cxx:409
GBS_strstruct * sai_middle
Definition: NT_edconf.cxx:613
static void nt_build_sai_string(const char *topAreaSaiList, GBS_strstruct *topfile, GBS_strstruct *middlefile)
Definition: NT_edconf.cxx:641
static void init_config_awars(AW_root *root)
Definition: NT_edconf.cxx:166
AW_selection * awt_create_subset_selection_list(AW_window *aww, AW_selection_list *parent_selection, const char *at_box, const char *at_add, const char *at_sort, bool autocorrect_subselection, SubsetChangedCb subChanged_cb, AW_CL cl_user)
void add(int v)
Definition: ClustalV.cxx:461
#define AWAR_CONFIG_COMMENT
Definition: NT_edconf.cxx:44
#define AWAR_CL_DISPLAY_CONFIG_MARKERS
Definition: NT_edconf.cxx:42
extractType
Definition: NT_edconf.cxx:46
char * ARB_strdup(const char *str)
Definition: arb_string.h:27
void AWT_insert_config_manager(AW_window *aww, AW_default default_file_, const char *id, const StoreConfigCallback &store_cb, const RestoreConfigCallback &load_or_reset_cb, const char *macro_id, const AWT_predefined_config *predef)
long read_int() const
Definition: AW_awar.cxx:187
static const int TOP_AREA
Definition: ad_config.h:45
void NT_start_editor_on_tree(AW_window *aww, int use_species_aside, TREE_canvas *ntw)
Definition: NT_edconf.cxx:1288
const char * GBS_global_string(const char *templat,...)
Definition: arb_msg.cxx:204
#define AWAR_CONFIGURATION
AW_root * awr
Definition: awt_canvas.hxx:338
static void init_config_admin_awars(AW_root *root)
Definition: NT_edconf.cxx:1069
STL namespace.
void AW_POPDOWN(AW_window *window)
Definition: AW_window.cxx:52
char * release()
Definition: arb_strbuf.h:80
void GBS_strncat(GBS_strstruct *strstr, const char *ptr, size_t len)
Definition: arb_strbuf.cxx:101
void GBS_free_hash(GB_HASH *hs)
Definition: adhash.cxx:541
#define MANAGED_CONFIGSET_ENTRY
Definition: NT_edconf.cxx:271
static void nt_delete_configuration(AW_window *aww, AW_DB_selection *dbsel)
Definition: NT_edconf.cxx:811
AW_DB_selection * awt_create_CONFIG_selection_list(GBDATA *gb_main, AW_window *aws, const char *varname, bool fallback2default)
TreeNode * getNode() const
Definition: NT_edconf.cxx:421
void get_values(StrArray &intoArray)
Definition: aw_select.hxx:198
bool modifyConfig(ConstStrArray &config) const
Definition: NT_edconf.cxx:285
static GB_ERROR swap_configs(GBDATA *gb_main, StrArray &config, int i1, int i2)
Definition: NT_edconf.cxx:1080
ConfigRenamer(const char *oldName_, const char *newName_)
Definition: NT_edconf.cxx:308
ConfigCreation
Definition: NT_edconf.cxx:833
bool is_mapped() const
Definition: aw_awar.hxx:153
GBDATA * GB_get_father(GBDATA *gbd)
Definition: arbdb.cxx:1720
AW_awar * get_config_awar(int canvas_id)
Definition: NT_edconf.cxx:139
#define MAX_NT_WINDOWS_NULLINIT
Definition: NT_local.h:33
bool empty() const
Definition: arb_strarray.h:86
unsigned long GB_ULONG
Definition: arbdb_base.h:42
ConfigDeleter(const char *toDelete_)
Definition: NT_edconf.cxx:319
static void unmark_species(TreeNode *node)
Definition: NT_edconf.cxx:435
#define DEFAULT_CONFIGURATION
Definition: ad_config.h:27
static SmartPtr< ConstStrArray > get_selected_configs_from_awar(int canvas_id)
Definition: NT_edconf.cxx:142
TreeNode * rightson
Definition: TreeNode.h:131
#define DOWNCAST(totype, expr)
Definition: downcast.h:141
ConfigMarkerDisplay(SmartPtr< ConstStrArray > config_, GBDATA *gb_main_)
Definition: NT_edconf.cxx:96
void GBT_split_string(ConstStrArray &dest, const char *namelist, const char *separator, bool dropEmptyTokens)
Definition: arb_strarray.h:232
const char * ARB_dateTime_suffix()
Definition: arb_string.cxx:45
AW_awar * add_callback(const RootCallback &cb)
Definition: AW_awar.cxx:234
GB_ERROR GB_delete(GBDATA *&source)
Definition: arbdb.cxx:1904
struct Unfixed_cb_parameter * UNFIXED
Definition: cb_base.h:15
static struct aisc_static_set_mem md
#define AWAR_CL_SELECTED_CONFIGS
Definition: NT_edconf.cxx:41
static void nt_build_conf_marked(GB_HASH *used, GBS_strstruct *file)
Definition: NT_edconf.cxx:709
static TreeNode * left_neighbour_leaf(TreeNode *node)
Definition: NT_edconf.cxx:462
POS_TREE1 * father
Definition: probe_tree.h:39
const char * read_char_pntr() const
Definition: AW_awar.cxx:171
bool GB_user_flag(GBDATA *gbd, unsigned char user_bit)
Definition: arbdb.cxx:2738
static void configuration_renamed_cb(const char *old_name, const char *new_name)
Definition: NT_edconf.cxx:348
void to_array(StrArray &array, bool values)
Definition: AW_select.cxx:516
bool didMatch() const
Definition: RegExpr.hxx:37
static AW_root * SINGLETON
Definition: aw_root.hxx:102
TreeNode * NT_get_tree_root_of_canvas(TREE_canvas *ntw)
Definition: NT_extern.cxx:825
AW_window * TREE_create_marker_settings_window(AW_root *root)
bool exists() const
Definition: ad_config.h:48
WindowCallback makeHelpCallback(const char *helpfile)
Definition: aw_window.hxx:106
static void selected_config_changed_cb(AW_root *root)
Definition: NT_edconf.cxx:998
char * GBT_read_string(GBDATA *gb_container, const char *fieldpath)
Definition: adtools.cxx:267
static char * correct_managed_configsets_cb(const char *key, const char *value, AW_CL cl_ConfigModifier)
Definition: NT_edconf.cxx:324
AW_MouseButton
Definition: aw_window.hxx:70
GBDATA * get_gb_main()
Definition: AW_select.cxx:592
long GB_number_of_subentries(GBDATA *gbd)
Definition: arbdb.cxx:2880
static void config_modified_cb(GBDATA *gb_cfg_area)
Definition: NT_edconf.cxx:216
void hide_marker_display()
bool displays_config_markers(MarkerDisplay *md)
Definition: NT_edconf.cxx:132
static void selected_configs_awar_changed_cb(AW_root *aw_root, TREE_canvas *ntw)
Definition: NT_edconf.cxx:169
GBT_CONFIG_ITEM_TYPE type
Definition: ad_config.h:80
static void nt_extract_configuration(UNFIXED, extractType ext_type)
Definition: NT_edconf.cxx:731
MarkerDisplay * get_marker_display()
#define AWAR_TREE_NAME
Definition: ad_trees.h:18
static void modify_configurations(const ConfigModifier &mod)
Definition: NT_edconf.cxx:336
#define MAX_NT_WINDOWS
Definition: NT_local.h:32
Store_species * remove()
Definition: NT_edconf.cxx:415
long GBS_memoffset(GBS_strstruct *strstr)
Definition: arb_strbuf.cxx:91
int get_index_of(const AW_scalar &searched_value)
Definition: AW_select.cxx:303
virtual ~ConfigModifier()
Definition: NT_edconf.cxx:282
void touch()
Definition: AW_awar.cxx:210
const char * get_comment() const
Definition: ad_config.h:60
void GBS_strcat(GBS_strstruct *strstr, const char *ptr)
Definition: arb_strbuf.cxx:108
static void error(const char *msg)
Definition: mkptypes.cxx:96
#define AWAR_TREE_REFRESH
#define NO_CONFIG_SELECTED
void remove(int i)
Definition: arb_strarray.h:103
const RegMatch * match(const std::string &versus, size_t offset=0) const
Definition: RegExpr.cxx:80
void set_comment(const char *newComment)
Definition: ad_config.h:61
void GBT_splitNdestroy_string(ConstStrArray &names, char *&namelist, const char *separator, bool dropEmptyTokens)
static AW_window * create_configuration_admin_window(AW_root *root, TREE_canvas *ntw)
Definition: NT_edconf.cxx:1168
static void install_config_change_callbacks(GBDATA *gb_main)
Definition: NT_edconf.cxx:244
GBDATA * GBT_next_marked_species(GBDATA *gb_species)
Definition: aditem.cxx:116
static bool allow_selection2awar_update
Definition: NT_edconf.cxx:163
CONSTEXPR_INLINE_Cxx14 void swap(unsigned char &c1, unsigned char &c2)
Definition: ad_io_inline.h:19
GB_ULONG GB_time_of_day(void)
Definition: adsocket.cxx:357
GB_ERROR save(GBDATA *gb_main, const char *name, bool warnIfSavingDefault) const
Definition: ad_config.h:64
size_t GBS_hash_elements(const GB_HASH *hs)
Definition: adhash.cxx:573
GBDATA * GBT_first_SAI_rel_SAI_data(GBDATA *gb_sai_data)
Definition: aditem.cxx:159
static void mark_species(TreeNode *node, Store_species **extra_marked_species)
Definition: NT_edconf.cxx:442
AW_awar * get_canvas_awar(const char *awar_name_format, int canvas_id)
Definition: NT_edconf.cxx:136
AW_awar * get_display_toggle_awar(int canvas_id)
Definition: NT_edconf.cxx:140
static void nt_store_configuration(AW_window *, TREE_canvas *ntw)
Definition: NT_edconf.cxx:950
void GBS_str_cut_tail(GBS_strstruct *strstr, size_t byte_count)
Definition: arb_strbuf.cxx:96
void safe_remove(int i)
Definition: arb_strarray.h:114
static void nt_start_editor_on_configuration(AW_window *aww)
Definition: NT_edconf.cxx:1254
static TreeNode * rightmost_leaf(TreeNode *node)
Definition: NT_edconf.cxx:453
map< string, string > ConfigHits
Definition: NT_edconf.cxx:55
static SearchTree * tree[SEARCH_PATTERNS]
Definition: ED4_search.cxx:629
int GB_read_flag(GBDATA *gbd)
Definition: arbdb.cxx:2784
char * read_string() const
Definition: AW_awar.cxx:201
AW_awar * awar_no_error(const char *awar)
end timer stuff
Definition: AW_root.cxx:549
GB_ERROR saveAsOver(GBDATA *gb_main, const char *name, const char *oldName, bool warnIfSavingDefault) const
Definition: ad_config.cxx:102
AW_awar * awar(const char *awar)
Definition: AW_root.cxx:554
void awt_create_order_buttons(AW_window *aws, awt_orderfun reorder_cb, AW_CL cl_user)
Definition: AWT_modules.cxx:17
char * GBS_log_action_to(const char *comment, const char *action, bool stamp)
Definition: adstring.cxx:990
void awt_set_subset_selection_content(AW_selection *subset_sel_, const CharPtrArray &values)
AW_awar * unmap()
Definition: AW_awar.cxx:598
Definition: arbdb.h:86
GBDATA * GBT_find_configuration(GBDATA *gb_main, const char *name)
Definition: ad_config.cxx:59
void call(void(*aPizza)(TreeNode *)) const
Definition: NT_edconf.cxx:430
const char * get_marker_name(int markerIdx) const OVERRIDE
Definition: NT_edconf.cxx:103
static void configs_selectionlist_changed_cb(AW_selection *selected_configs, bool interactive_change, AW_CL ntw_id)
Definition: NT_edconf.cxx:206
int get_index() const
#define nt_assert(cond)
Definition: NT_local.h:27
static GB_ERROR nt_create_configuration(TreeNode *tree, const char *conf_name, int use_species_aside, ConfigCreation creation)
Definition: NT_edconf.cxx:839
const std::string * has_failed() const
Definition: RegExpr.hxx:78
char * awar_name
Definition: aw_awar.hxx:103
void GBS_chrcat(GBS_strstruct *strstr, char ch)
Definition: arb_strbuf.cxx:119
static void setup_configmarker_config_cb(AWT_config_definition &config, int ntw_id)
Definition: NT_edconf.cxx:273
AWT_graphic * gfx
Definition: awt_canvas.hxx:339
char * GBT_join_strings(const CharPtrArray &strings, char separator)
GBDATA * GBT_next_SAI(GBDATA *gb_sai)
Definition: aditem.cxx:166
#define AWAR_TOPAREA_SAIS
Definition: NT_local.h:30
void ncat(const char *from, size_t count)
Definition: arb_strbuf.h:151
bool is_leaf() const
Definition: TreeNode.h:171
AW_awar * awar_int(const char *var_name, long default_value=0, AW_default default_file=AW_ROOT_DEFAULT)
Definition: AW_root.cxx:580
#define CONFIG_BASE_PATH
Definition: NT_edconf.cxx:242
#define gb_assert(cond)
Definition: arbdbt.h:11
xml element
void NT_activate_configMarkers_display(TREE_canvas *ntw)
Definition: NT_edconf.cxx:255
GB_ERROR close(GB_ERROR error)
Definition: arbdbpp.cxx:32
char * GBK_singlequote(const char *arg)
Definition: arb_msg.cxx:547
void GB_write_flag(GBDATA *gbd, long flag)
Definition: arbdb.cxx:2761
long AW_CL
Definition: cb.h:21
void GB_write_user_flag(GBDATA *gbd, unsigned char user_bit, bool state)
Definition: arbdb.cxx:2753
GB_ERROR GBT_write_string(GBDATA *gb_container, const char *fieldpath, const char *content)
Definition: adtools.cxx:451
const GBT_config_item & nextItem(GB_ERROR &error)
Definition: ad_config.cxx:140
#define OVERRIDE
Definition: cxxforward.h:93
void move_selection(int offset)
Definition: AW_select.cxx:415
void nt_create_config_after_import(TREE_canvas *ntw)
Definition: NT_edconf.cxx:1295
char * name
Definition: TreeNode.h:134
int GB_read_byte(GBDATA *gbd)
Definition: arbdb.cxx:728
awt_reorder_mode
Definition: awt_modules.hxx:22
AW_awar * map(const char *awarn)
Definition: AW_awar.cxx:523
char * GB_read_string(GBDATA *gbd)
Definition: arbdb.cxx:903
void AWT_modify_managed_configs(AW_default default_file, const char *id, ConfigModifyCallback mod_cb, AW_CL cl_user)
GBDATA * GBT_first_species(GBDATA *gb_main)
Definition: aditem.cxx:124
void aw_message(const char *msg)
Definition: AW_status.cxx:932
static void config_comment_changed_cb(AW_root *root)
Definition: NT_edconf.cxx:1027
void hide()
Definition: AW_window.cxx:1807
void GB_clear_user_flag(GBDATA *gbd, unsigned char user_bit)
Definition: arbdb.cxx:2748
int GBS_HCF_sortedByKey(const char *k0, long dummy_1x, const char *k1, long dummy_2x)
Definition: adhash.cxx:656
#define MANAGED_CONFIGSET_SECTION
Definition: NT_edconf.cxx:270
AW_root * get_root()
Definition: aw_window.hxx:348
static int line
Definition: arb_a2ps.c:296
GBDATA * GBT_next_species(GBDATA *gb_species)
Definition: aditem.cxx:128
#define NULp
Definition: cxxforward.h:97
GBDATA * gb_main
Definition: NT_local.h:37
static void write_configs_to_awar(int canvas_id, const CharPtrArray &configs)
Definition: NT_edconf.cxx:154
GBDATA * GBT_find_species(GBDATA *gb_main, const char *name)
Definition: aditem.cxx:139
static void clear_comment_cb(AW_window *aww)
Definition: NT_edconf.cxx:1144
static int nt_build_conf_string_rek(GB_HASH *used, TreeNode *tree, GBS_strstruct *memfile, Store_species **extra_marked_species, int use_species_aside, int *auto_mark, int marked_at_left, int *marked_at_right)
Definition: NT_edconf.cxx:481
void retrieve_marker_state(const char *speciesName, NodeMarkers &node) OVERRIDE
Definition: NT_edconf.cxx:109
GB_ERROR write_string(const char *aw_string)
const char * get_data() const
Definition: arb_strbuf.h:70
GBDATA * GBT_find_SAI_rel_SAI_data(GBDATA *gb_sai_data, const char *name)
Definition: aditem.cxx:171
#define GB_USERFLAG_QUERY
Definition: arbdb.h:55
int GB_get_transaction_level(GBDATA *gbd)
Definition: arbdb.cxx:2578
void GBT_mark_all(GBDATA *gb_main, int flag)
Definition: aditem.cxx:295
void handle_click(int markerIdx, AW_MouseButton button, AWT_graphic_exports &exports) OVERRIDE
Definition: NT_edconf.cxx:121
long GBT_get_species_count(GBDATA *gb_main)
Definition: aditem.cxx:207
GB_transaction ta(gb_var)
GB_CSTR GB_read_char_pntr(GBDATA *gbd)
Definition: arbdb.cxx:898
GBDATA * gb_node
Definition: TreeNode.h:133
GBDATA * gb_main
Definition: adname.cxx:33
AW_awar * awar_string(const char *var_name, const char *default_value="", AW_default default_file=AW_ROOT_DEFAULT)
Definition: AW_root.cxx:570
GBDATA * GBT_get_SAI_data(GBDATA *gb_main)
Definition: aditem.cxx:154
GBDATA * GB_search(GBDATA *gbd, const char *fieldpath, GB_TYPES create)
Definition: adquery.cxx:531
char * aw_input(const char *title, const char *prompt, const char *default_input)
Definition: AW_modal.cxx:251
const char * replace(int i, const char *elem)
Definition: arb_strarray.h:217
static void nt_rename_configuration(AW_window *aww)
Definition: NT_edconf.cxx:956
long GBS_read_hash(const GB_HASH *hs, const char *key)
Definition: adhash.cxx:395
GBDATA * GB_entry(GBDATA *father, const char *key)
Definition: adquery.cxx:334
size_t get_position() const
Definition: arb_strbuf.h:65
AW_selection_list * get_sellist()
Definition: aw_select.hxx:196
void aw_message_if(GB_ERROR error)
Definition: aw_msg.hxx:21
char * GBS_global_string_copy(const char *templat,...)
Definition: arb_msg.cxx:195
NT_global GLOBAL
Definition: NT_main.cxx:44
void set_definition(int area, char *new_def)
Definition: ad_config.h:54
const char * last_group_name
Definition: NT_edconf.cxx:614
GBDATA * gb_main
Definition: awt_canvas.hxx:336
GB_HASH * GBS_create_hash(long estimated_elements, GB_CASE case_sens)
Definition: adhash.cxx:253
void AWT_system_cb(AW_window *, const char *command)
Definition: AWT_misc.cxx:84
static bool allow_to_activate_display
Definition: NT_edconf.cxx:164
GB_write_int const char s
Definition: AW_awar.cxx:156