138 if (str_len) *str_len = len;
145 bool detect_len =
true;
176 case GB_DB: result =
"GB_DB";
break;
177 case GB_INT: result =
"GB_INT";
break;
178 case GB_INTS: result =
"GB_INTS";
break;
179 case GB_FLOAT: result =
"GB_FLOAT";
break;
180 case GB_FLOATS: result =
"GB_FLOATS";
break;
183 result =
"Unknown data type\n";
191 *str_len = result ? strlen(result) : 0;
194 e4_assert(*str_len == (
int)strlen(result));
212 bool allow_write_data =
true;
217 if (old_checksum != new_checksum) {
219 allow_write_data =
false;
225 if (allow_write_data) {
253 aw_message(
"Couldn't read old sequence data");
259 if (old_seq) free(old_seq);
277 base->to_species_manager()->remove_all_callbacks();
287 parent_manager->rebuild_consensi(parent_manager,
ED4_U_UP);
293 if (species_manager->is_consensus_manager()) {
295 aw_message(
"This group has to exist - deleting it isn't allowed");
305 species_manager->Delete();
325 AW_pos target_x, target_y;
330 #define ARROW_LENGTH 3
331 AW_pos drag_line_x0[3], drag_line_y0[3];
332 AW_pos drag_line_x1[3], drag_line_y1[3];
334 drag_line_x0[0] = target_x + 5;
336 drag_line_x1[0] = drag_line_x0[0] + 50;
341 drag_line_x1[1] = drag_line_x0[0];
342 drag_line_y1[1] = drag_line_y0[0];
346 drag_line_x1[2] = drag_line_x0[0];
347 drag_line_y1[2] = drag_line_y0[0];
370 #if defined(DEBUG) && 1
372 printf(
"%s: x=%i y=%i\n", where, event->
x, event->
y);
375 #define dumpEvent(w, e)
389 static ED4_species_name_terminal *dragged_name_terminal =
NULp;
391 static bool pressed_left_button =
false;
392 static int other_x, other_y;
393 static bool dragged_was_selected =
false;
399 if (dragged_name_terminal) {
401 switch (event->
type) {
403 if (pressed_left_button) {
406 dragged_name_terminal->calc_world_coords(&world_x, &world_y);
409 drag.
old_x = world_x;
410 drag.
old_y = world_y;
411 drag.
off_x = world_x-other_x;
412 drag.
off_y = world_y-other_y;
415 pressed_left_button =
false;
418 GB_CSTR text = dragged_name_terminal->get_displayed_text();
420 if (dragged_name_terminal->dragged) {
427 dragged_name_terminal->draw_drag_box(new_x, new_y, text, event->
y);
433 dragged_name_terminal->dragged =
true;
437 if (dragged_name_terminal->dragged) {
439 char *db_pointer = dragged_name_terminal->resolve_pointer_to_string_copy();
442 dragged_name_terminal->dragged =
false;
449 mi.
object = dragged_name_terminal;
455 dragged_name_terminal->parent->move_requested_by_child(&mi);
460 for (
int i=0; i<device_manager->
members(); i++) {
464 member->to_area_manager()->get_multi_species_manager()->update_requested_by_child();
469 if (!dragged_was_selected) {
473 pressed_left_button =
false;
474 dragged_name_terminal =
NULp;
497 dragged_name_terminal = to_species_name_terminal();
498 pressed_left_button =
true;
504 if (!dragged_was_selected) {
513 static ED4_species_manager *prev_clicked_species_man =
NULp;
516 GBDATA *gbd = species_man->get_species_pointer();
518 bool acceptClick =
false;
519 static int markHow = -1;
521 switch (event->
type) {
528 acceptClick = prev_clicked_species_man != species_man;
532 acceptClick = prev_clicked_species_man != species_man;
533 prev_clicked_species_man =
NULp;
559 prev_clicked_species_man = species_man;
563 prev_clicked_species_man =
NULp;
571 to_bracket_terminal()->toggle_folding();
590 static bool select_started_on_seqterm =
false;
592 switch (event->
type) {
594 select_started_on_seqterm =
false;
598 if (species_man->is_consensus_manager()) {
603 if (!species_man->is_highlighted()) {
615 group->to_group_manager()->get_multi_species_manager()->toggle_selected_species();
621 select_started_on_seqterm =
true;
653 bool bb_changed =
false;
686 if (
id && strcmp(temp_id,
id) == 0)
return this;
703 ED4_base(spec_, temp_id, width, height, temp_parent)
719 ED4_tree_terminal::ED4_tree_terminal(
const char *temp_id,
AW_pos width,
AW_pos height,
ED4_manager *temp_parent)
723 void ED4_tree_terminal::draw() {
728 calc_world_coords(&x, &y);
734 db_pointer = resolve_pointer_to_string_copy();
751 #if defined(DEBUG) && 0
752 static bool toggle =
false;
755 #else // !defined(DEBUG)
765 for (
int i = 0; i<6; ++i) {
777 for (
int i = 0; i<3; ++i) {
800 highlight_info(
NULp),
804 #define MAXNAMELEN MAXNAME_WIDTH // @@@ seems wrong (MAXNAME_WIDTH contains pixel)
805 #define BUFFERSIZE (MAXNAMELEN<<1)
806 GB_CSTR ED4_species_name_terminal::get_displayed_text()
const {
807 static char *real_name;
808 static int allocatedSize;
810 if (!real_name || allocatedSize<(
BUFFERSIZE+1)) {
815 memset(real_name, 0, allocatedSize);
817 ED4_species_manager *spec_man = get_parent(
LEV_SPECIES)->to_species_manager();
819 if (spec_man->is_consensus_manager()) {
820 char *db_pointer = resolve_pointer_to_string_copy();
821 char *bracket = strchr(db_pointer,
'(');
824 int bracket_len = strlen(bracket);
825 int name_len = bracket-db_pointer;
827 if (bracket[-1]==
' ') {
832 strcpy(real_name, db_pointer);
835 int short_name_len =
MAXNAMELEN-bracket_len-1;
837 memcpy(real_name, db_pointer, short_name_len);
838 real_name[short_name_len] =
' ';
839 strcpy(real_name+short_name_len+1, bracket);
848 else if (spec_man->is_SAI_manager()) {
849 char *db_pointer = resolve_pointer_to_string_copy();
851 strcpy(real_name,
"SAI: ");
852 if (strcmp(db_pointer,
"ECOLI")==0) {
854 if (name_for_ecoli[0]==0) name_for_ecoli = db_pointer;
855 strncpy(real_name+5, name_for_ecoli,
BUFFERSIZE-5);
858 strncpy(real_name+5, db_pointer,
BUFFERSIZE-5);
874 ED4_sequence_info_terminal::ED4_sequence_info_terminal(
const char *temp_id,
AW_pos width,
AW_pos height,
ED4_manager *temp_parent)
886 return get_char_table().
size();
917 shall_display_secstruct_info(shall_display_secstruct_info_)
922 ED4_pure_text_terminal::ED4_pure_text_terminal(
const char *temp_id,
AW_pos width,
AW_pos height,
ED4_manager *temp_parent)
926 #if defined(DEVEL_RALF) && 0
929 # define DEBUG_SPACER_TERMINALS 2 // show all spacers
932 void ED4_spacer_terminal::Show(
bool ,
bool is_cleared) {
933 #if defined(DEBUG_SPACER_TERMINALS)
934 if (DEBUG_SPACER_TERMINALS == 1) {
938 else if (update_info.clear_at_refresh && !is_cleared) {
945 #else // !DEBUG_SPACER_TERMINALS
946 if (shallDraw || (update_info.clear_at_refresh && !is_cleared)) {
953 void ED4_spacer_terminal::draw() {
955 #if defined(DEBUG_SPACER_TERMINALS)
959 if (DEBUG_SPACER_TERMINALS != 2) {
960 bool highlight = bool(DEBUG_SPACER_TERMINALS) == shallDraw;
961 if (!highlight) gc = 0;
963 #endif // DEBUG_SPACER_TERMINALS
964 clear_background(gc);
967 ED4_spacer_terminal::ED4_spacer_terminal(
const char *temp_id,
bool shallDraw_,
AW_pos width,
AW_pos height,
ED4_manager *temp_parent)
969 shallDraw(shallDraw_)
1006 if (val==20)
return ' ';
1007 if (val==100)
return '^';
1011 return '0' + (is_upper_digit ? (val/10) : (val%10));
1029 for (b=0; b<4; b++) {
1031 if (sum>=sig && sum>=bestSum) {
1038 for (b=0; b<4; b++) {
1039 for (c=b+1; c<4; c++) {
1040 int sum = like[b]+like[c];
1041 if (sum>=sig && sum>=bestSum) {
1043 bestResult = (1<<b)|(1<<c);
1050 if (sumPtr) *sumPtr = bestSum;
1057 void ED4_columnStat_terminal::draw() {
1059 calc_world_coords(&x, &y);
1067 AW_pos text_y = y + term_height - font_height;
1071 if (!update_likelihood()) {
1072 const char *
warning =
"Failed to calculate likelihood";
1087 if (index_range.
is_empty())
return;
1090 const int left = index_range.
start();
1091 const int right = index_range.
end();
1093 char *sbuffer =
new char[right+2];
1094 memset(sbuffer,
' ', right+1);
1095 sbuffer[right+1] = 0;
1102 int significance =
int(get_threshold());
1109 AW_pos x2 = text_x + font_width*left + 1;
1115 for (
int i=left; i<=right; i++, x2+=font_width) {
1120 if (is_selected && selection.
contains(p)) {
1127 if (color!=old_color) {
1139 x2 = text_x + font_width*left + 1;
1141 for (
int i=left; i<=right; i++, x2+=font_width) {
1144 int found =
find_significant_positions(significance, likelihood[0][p], likelihood[1][p], likelihood[2][p], likelihood[3][p], &sum);
1146 if (found && significance<100) {
1147 e4_assert(sum>=significance && sum<=100);
1154 for (r=3, y2=text_y+1, bit=1<<3;
1168 for (r=3, y2=text_y;
1174 for (i=left; i<=right; i++) {
1176 int val = likelihood[r][p];
1182 for (i=left; i<=right; i++) {
1184 int val = likelihood[r][p];
1193 int ED4_columnStat_terminal::update_likelihood() {
1202 for (
int i=0; i<4; i++) likelihood[i] =
NULp;
1206 ED4_columnStat_terminal::~ED4_columnStat_terminal() {
1207 for (
int i=0; i<4; i++) free(likelihood[i]);
1217 GB_CSTR ED4_flag_header_terminal::get_displayed_text()
const {
1220 int ED4_flag_header_terminal::get_length()
const {
1231 double flag_centerx;
1237 Vector box_diag(boxsize, -boxsize);
1240 flag_centerx = curr_flag->center_xpos();
1242 box =
Rectangle(box_center-box_diag/2, box_diag);
1246 box.
move(
Vector(new_flag_centerx - flag_centerx, 0));
1247 flag_centerx = new_flag_centerx;
1253 void ED4_flag_terminal::draw() {
1256 int boxes = flags.size();
1268 for (
int b = 0; b<boxes && !
error; ++b) {
1269 bool filled =
false;
1271 GBDATA *gb_field =
GB_entry(gb_species, curr_flag->get_fieldname().c_str());
1274 if (error) error =
GBS_global_string(
"Failed to read flag value (Reason: %s)", error);
1275 else filled = as_byte;
1283 if (curr_flag != end) layout.move_box(curr_flag->center_xpos());
1290 void ED4_flag_terminal::handle_left_click(
const Position& click) {
1293 int boxes = flags.size();
1300 for (
int b = 0; b<boxes; ++b) {
1301 if (layout.get_box().contains(click))
break;
1303 if (curr_flag != end) layout.move_box(curr_flag->center_xpos());
1306 if (curr_flag != end) {
1308 GBDATA *gb_field =
GB_entry(gb_species, curr_flag->get_fieldname().c_str());
1311 if (!error && !gb_field) {
1312 const char *key = curr_flag->prepare_itemfield();
1323 if (!error) request_refresh();
1332 delete ref_sequence_info;
1333 delete ref_sequence;
1334 delete ref_column_stat;
1335 delete ref_column_stat_info;
1341 ED4_sequence_info_terminal *ref_column_stat_info_,
1342 ED4_columnStat_terminal *ref_column_stat_)
1345 ref_sequence_info = ref_sequence_info_;
1346 ref_sequence = ref_sequence_;
1347 ref_column_stat_info = ref_column_stat_info_;
1348 ref_column_stat = ref_column_stat_;
ED4_base * search_ID(const char *id) OVERRIDE
void clr_property(ED4_properties prop)
ED4_bracket_terminal(const char *id, AW_pos width, AW_pos height, ED4_manager *parent)
void resize_requested_children() OVERRIDE
GB_ERROR GB_write_bits(GBDATA *gbd, const char *bits, long size, const char *c_0)
AW_device * current_device()
const char * resolve_pointer_to_char_pntr(int *str_len=NULp) const FINAL_OVERRIDE
int screen_to_sequence(int screen_pos) const
#define ED4_AWAR_ANNOUNCE_CHECKSUM_CHANGES
void update_requested_children() OVERRIDE
const AW_bitset AW_SCREEN
Position centroid() const
#define COLUMN_STAT_ROW_HEIGHT(font_height)
ED4_level preferred_parent
bool nearlyEqual(const double &val1, const double &val2)
GB_ERROR GB_write_string(GBDATA *gbd, const char *s)
void remove_callbacks() FINAL_OVERRIDE
ED4_base * member(ED4_index i) const
const char * get_header_text() const
void deselect_all_species_and_SAI()
GBDATA * get_species_pointer() const
~ED4_orf_terminal() OVERRIDE
virtual void clear_part(const AW::Rectangle &rect, AW_bitset filteri)
ExplicitRange clip_screen_range(PosRange screen_range) const
static const SpeciesFlags & instance()
bool all_are_selected() const
void remove_from_consensus(ED4_manager *group_or_species_man)
void set_species_pointer(GBDATA *gbd)
int get_height(int gc) const
long GB_read_bytes_count(GBDATA *gbd)
const char * GBS_global_string(const char *templat,...)
void warning(int warning_num, const char *warning_message)
int is_species_manager() const
void ED4_trigger_instant_refresh()
ED4_update_info update_info
const AW_bitset AW_ALL_DEVICES
ED4_terminal * owner_of_cursor
char stat2display(int val, bool is_upper_digit)
int get_width(int gc) const
ED4_returncode clear_background(int color=0)
long GB_read_bits_count(GBDATA *gbd)
char * ED4_get_NDS_text(ED4_species_manager *species_man)
ED4_orf_terminal(const char *id, AW_pos width, AW_pos height, ED4_manager *parent)
GB_ERROR GB_push_transaction(GBDATA *gbd)
const Rectangle & get_box() const
static ED4_objspec sequence_info_terminal_spec(ED4_properties(PROP_IS_TERMINAL|PROP_DYNA_RESIZE), LEV_SEQUENCE_INFO, LEV_NONE, LEV_SEQUENCE, LEV_NONE)
int get_header_length() const
static int get_species(char *species_string, unsigned int species_number, char *buffer)
GB_ERROR GB_incur_error_if(bool error_may_occur)
void init(ED4_sequence_info_terminal *, ED4_sequence_terminal *, ED4_sequence_info_terminal *, ED4_columnStat_terminal *)
LineVector left_edge() const
void toggle_selected_species()
bool has_property(ED4_properties prop) const
void world_to_win_coords(AW_pos *xPtr, AW_pos *yPtr) const
const AW::Position & calc_world_coords() const
int get_no_of_selected_species()
const char * read_char_pntr() const
int get_min_flag_distance() const
static ED4_objspec column_stat_terminal_spec(PROP_IS_TERMINAL, LEV_COL_STAT, LEV_NONE, LEV_NONE, LEV_NONE)
GB_CSTR GB_read_bytes_pntr(GBDATA *gbd)
GB_ERROR GB_write_lossless_byte(GBDATA *gbd, uint8_t byte)
size_t GB_read_string_count(GBDATA *gbd)
#define ED4_AWAR_NDS_ECOLI_NAME
static ED4_objspec sequence_terminal_spec(PROP_IS_TERMINAL, LEV_SEQUENCE_STRING, LEV_NONE, LEV_NONE, LEV_NONE)
char * ARB_strduplen(const char *p, unsigned len)
GB_TYPES GB_read_type(GBDATA *gbd)
int SEQ_TERM_TEXT_YOFFSET
ED4_index members() const
unsigned int clear_at_refresh
TYPE * ARB_alloc(size_t nelem)
void ED4_no_dangerous_modes()
SpeciesFlagList::const_iterator SpeciesFlagCiter
PosRange calc_update_interval()
bool contains(int pos) const
GBDATA * get_gb_main() const
int sequence_to_screen(int sequence_pos) const
int get_length() const OVERRIDE
ED4_multi_species_manager * ED4_find_MoreSequences_manager()
void set_refresh(int value)
struct ED4_terminal::@8 tflag
void remove_from_highlighted(ED4_species_name_terminal *object)
ED4_sequence_terminal(const char *id, AW_pos width, AW_pos height, ED4_manager *parent, bool shall_display_secstruct_info_)
NOT4PERL uint8_t GB_read_lossless_byte(GBDATA *gbd, GB_ERROR &error)
ED4_returncode add_to_highlighted(ED4_species_name_terminal *object)
bool line(int gc, const AW::LineVector &Line, AW_bitset filteri=AW_ALL_DEVICES_SCALED)
ED4_window * first_window
static void error(const char *msg)
int get_length() const OVERRIDE
ED4_returncode show_clicked_cursor(AW_pos click_xpos, ED4_terminal *target_terminal)
void PV_RefreshWindow(AW_root *root)
const Position & upper_left_corner() const
bool calc_bounding_box() FINAL_OVERRIDE
bool set_size_does_change(int idx, AW_pos value)
ED4_root_group_manager * root_group_man
bool STAT_update_ml_likelihood(ST_ML *st_ml, char *result[4], int &latest_update, const char *species_name, AP_tree *node)
ED4_line_terminal(const char *id, AW_pos width, AW_pos height, ED4_manager *parent)
int find_significant_positions(int sig, int like_A, int like_C, int like_G, int like_TU, int *sumPtr)
#define AWAR_SPECIES_NAME
~ED4_abstract_sequence_terminal() OVERRIDE
ED4_terminal(const ED4_objspec &spec_, GB_CSTR id, AW_pos width, AW_pos height, ED4_manager *parent)
void calc_world_coords(AW_pos *x, AW_pos *y) const
int GB_read_flag(GBDATA *gbd)
AW_awar * awar(const char *awar)
GB_ERROR GB_pop_transaction(GBDATA *gbd)
static ED4_objspec flag_spec(ED4_properties(PROP_IS_TERMINAL|PROP_DYNA_RESIZE), LEV_FLAG, LEV_NONE, LEV_NONE, LEV_NONE)
GB_alignment_type alignment_type
ED4_returncode event_sent_by_parent(AW_event *event, AW_window *aww) OVERRIDE
const Vector & diagonal() const
static ED4_objspec tree_terminal_spec(PROP_IS_TERMINAL, LEV_TREE, LEV_NONE, LEV_NONE, LEV_NONE)
int adjust_clipping_rectangle()
GBDATA * GBT_searchOrCreate_itemfield_according_to_changekey(GBDATA *gb_item, const char *field_name, const char *change_key_path)
static ED4_objspec pure_text_terminal_spec(PROP_IS_TERMINAL, LEV_PURE_TEXT, LEV_NONE, LEV_NONE, LEV_NONE)
void Delete() FINAL_OVERRIDE
int aw_question(const char *unique_id, const char *question, const char *buttons, bool sameSizeButtons, const char *helpfile)
ED4_returncode update_bases_and_rebuild_consensi(const char *old_seq, int old_len, ED4_base *species, ED4_update_flag update_flag, PosRange range=PosRange::whole())
static ED4_objspec bracket_terminal_spec(PROP_IS_TERMINAL, LEV_BRACKET, LEV_NONE, LEV_NONE, LEV_NONE)
ED4_cursor & current_cursor()
#define IF_ASSERTION_USED(x)
void GB_write_flag(GBDATA *gbd, long flag)
void ED4_setColumnblockCorner(AW_event *event, ED4_sequence_terminal *seq_term)
ED4_returncode kill_object()
static ED4_objspec orf_terminal_spec(PROP_IS_TERMINAL, LEV_ORF, LEV_NONE, LEV_NONE, LEV_NONE)
static ED4_objspec spacer_terminal_spec(ED4_properties(PROP_IS_TERMINAL|PROP_DYNA_RESIZE), LEV_SPACER, LEV_NONE, LEV_NONE, LEV_NONE)
ED4_abstract_sequence_terminal(const ED4_objspec &spec_, const char *id, AW_pos width, AW_pos height, ED4_manager *parent)
ED4_returncode draw_drag_box(AW_pos x, AW_pos y, GB_CSTR text=NULp, int cursor_y=-1)
GB_ERROR write_sequence(const char *seq, int seq_len)
ED4_window * current_ed4w()
ED4_seq_colors * sequence_colors
FlagLayout(const Rectangle &area, const SpeciesFlags &flags)
ItemSelector & SPECIES_get_selector()
uint32_t GBS_checksum(const char *seq, int ignore_case, const char *exclude)
void request_refresh(int clear=1) FINAL_OVERRIDE
void aw_message(const char *msg)
void select_all(bool only_species)
ED4_returncode refresh_requested_by_child()
long GB_read_clock(GBDATA *gbd)
ED4_species_manager * containing_species_manager() const
bool ED4_get_highlighted_range(ED4_terminal *term, PosRange &range)
GB_CSTR GB_read_bits_pntr(GBDATA *gbd, char c_0, char c_1)
int is_area_manager() const
const ED4_remap * remap() const
AW::Rectangle get_win_area(ED4_window *ed4w) const
void request_resize_of_linked()
GB_ERROR write_string(const char *aw_string)
ED4_returncode search_target_species(ED4_extension *location, ED4_properties prop, ED4_base **found_member, ED4_level return_level)
int is_sequence_terminal() const
int is_flag_terminal() const
const char * GBT_get_name(GBDATA *gb_item)
ED4_species_mode species_mode
char * resolve_pointer_to_string_copy(int *str_len=NULp) const FINAL_OVERRIDE
void ED4_correctBlocktypeAfterModification()
int is_bracket_terminal() const
static ED4_objspec flag_header_spec(ED4_properties(PROP_IS_TERMINAL|PROP_DYNA_RESIZE), LEV_FLAG_HEADER, LEV_NONE, LEV_NONE, LEV_NONE)
GB_transaction ta(gb_var)
bool box(int gc, AW::FillStyle filled, const AW::Rectangle &rect, AW_bitset filteri=AW_ALL_DEVICES_SCALED)
GB_CSTR GB_read_char_pntr(GBDATA *gbd)
int INFO_TERM_TEXT_YOFFSET
ED4_device_manager * get_device_manager()
ED4_manager * get_parent(ED4_level lev) const
void set_clear_at_refresh(int value)
void update_consensus(ED4_manager *old_parent, ED4_manager *new_parent, ED4_base *sequence)
void move_box(double new_flag_centerx)
static ED4_objspec line_terminal_spec(ED4_properties(PROP_IS_TERMINAL|PROP_DYNA_RESIZE), LEV_LINE, LEV_NONE, LEV_NONE, LEV_NONE)
void Show(bool refresh_all, bool is_cleared) OVERRIDE
int is_group_manager() const
bool text(int gc, const SizedCstr &cstr, const AW::Position &pos, AW_pos alignment=0.0, AW_bitset filteri=AW_ALL_DEVICES_UNSCALED)
void move(const Vector &movement)
GBDATA * GB_entry(GBDATA *father, const char *key)
int is_species_name_terminal() const
void aw_message_if(GB_ERROR error)
ED4_consensus_sequence_terminal(const char *id, AW_pos width, AW_pos height, ED4_manager *parent)
static ED4_objspec species_name_terminal_spec(ED4_properties(PROP_IS_TERMINAL|PROP_DYNA_RESIZE), LEV_SPECIES_NAME, LEV_NONE, LEV_SPECIES, LEV_NONE)
GB_write_int const char s