| 1 | // =============================================================== // |
|---|
| 2 | // // |
|---|
| 3 | // File : ED4_terminal.cxx // |
|---|
| 4 | // Purpose : // |
|---|
| 5 | // // |
|---|
| 6 | // Institute of Microbiology (Technical University Munich) // |
|---|
| 7 | // http://www.arb-home.de/ // |
|---|
| 8 | // // |
|---|
| 9 | // =============================================================== // |
|---|
| 10 | |
|---|
| 11 | #include <arbdb.h> |
|---|
| 12 | #include <ed4_extern.hxx> |
|---|
| 13 | #include "ed4_class.hxx" |
|---|
| 14 | #include "ed4_awars.hxx" |
|---|
| 15 | #include "ed4_edit_string.hxx" |
|---|
| 16 | #include "ed4_block.hxx" |
|---|
| 17 | #include "ed4_nds.hxx" |
|---|
| 18 | #include "ed4_ProteinViewer.hxx" |
|---|
| 19 | |
|---|
| 20 | #include <aw_preset.hxx> |
|---|
| 21 | #include <aw_awar.hxx> |
|---|
| 22 | #include <aw_msg.hxx> |
|---|
| 23 | #include <aw_root.hxx> |
|---|
| 24 | #include <aw_question.hxx> |
|---|
| 25 | #include <awt_seq_colors.hxx> |
|---|
| 26 | #include <st_window.hxx> |
|---|
| 27 | |
|---|
| 28 | // ----------------------------------- |
|---|
| 29 | // static terminal properties |
|---|
| 30 | |
|---|
| 31 | static ED4_objspec tree_terminal_spec( |
|---|
| 32 | ED4_P_IS_TERMINAL, // static props |
|---|
| 33 | ED4_L_TREE, // level |
|---|
| 34 | ED4_L_NO_LEVEL, // allowed children level |
|---|
| 35 | ED4_L_NO_LEVEL, // handled object |
|---|
| 36 | ED4_L_NO_LEVEL // restriction level |
|---|
| 37 | ); |
|---|
| 38 | |
|---|
| 39 | static ED4_objspec bracket_terminal_spec( |
|---|
| 40 | ED4_P_IS_TERMINAL, // static props |
|---|
| 41 | ED4_L_BRACKET, // level |
|---|
| 42 | ED4_L_NO_LEVEL, // allowed children level |
|---|
| 43 | ED4_L_NO_LEVEL, // handled object |
|---|
| 44 | ED4_L_NO_LEVEL // restriction level |
|---|
| 45 | ); |
|---|
| 46 | |
|---|
| 47 | static ED4_objspec species_name_terminal_spec( |
|---|
| 48 | ED4_P_IS_TERMINAL, // static props |
|---|
| 49 | ED4_L_SPECIES_NAME, // level |
|---|
| 50 | ED4_L_NO_LEVEL, // allowed children level |
|---|
| 51 | ED4_L_SPECIES, // handled object |
|---|
| 52 | ED4_L_NO_LEVEL // restriction level |
|---|
| 53 | ); |
|---|
| 54 | |
|---|
| 55 | static ED4_objspec sequence_info_terminal_spec( |
|---|
| 56 | ED4_P_IS_TERMINAL, // static props |
|---|
| 57 | ED4_L_SEQUENCE_INFO, // level |
|---|
| 58 | ED4_L_NO_LEVEL, // allowed children level |
|---|
| 59 | ED4_L_SEQUENCE, // handled object |
|---|
| 60 | ED4_L_NO_LEVEL // restriction level |
|---|
| 61 | ); |
|---|
| 62 | |
|---|
| 63 | static ED4_objspec sequence_terminal_spec( |
|---|
| 64 | ED4_P_IS_TERMINAL, // static props |
|---|
| 65 | ED4_L_SEQUENCE_STRING, // level |
|---|
| 66 | ED4_L_NO_LEVEL, // allowed children level |
|---|
| 67 | ED4_L_NO_LEVEL, // handled object |
|---|
| 68 | ED4_L_NO_LEVEL // restriction level |
|---|
| 69 | ); |
|---|
| 70 | |
|---|
| 71 | static ED4_objspec orf_terminal_spec( |
|---|
| 72 | ED4_P_IS_TERMINAL, // static props |
|---|
| 73 | ED4_L_ORF, // level |
|---|
| 74 | ED4_L_NO_LEVEL, // allowed children level |
|---|
| 75 | ED4_L_NO_LEVEL, // handled object |
|---|
| 76 | ED4_L_NO_LEVEL // restriction level |
|---|
| 77 | ); |
|---|
| 78 | |
|---|
| 79 | static ED4_objspec pure_text_terminal_spec( |
|---|
| 80 | ED4_P_IS_TERMINAL, // static props |
|---|
| 81 | ED4_L_PURE_TEXT, // level |
|---|
| 82 | ED4_L_NO_LEVEL, // allowed children level |
|---|
| 83 | ED4_L_NO_LEVEL, // handled object |
|---|
| 84 | ED4_L_NO_LEVEL // restriction level |
|---|
| 85 | ); |
|---|
| 86 | |
|---|
| 87 | static ED4_objspec spacer_terminal_spec( |
|---|
| 88 | ED4_P_IS_TERMINAL, // static props |
|---|
| 89 | ED4_L_SPACER, // level |
|---|
| 90 | ED4_L_NO_LEVEL, // allowed children level |
|---|
| 91 | ED4_L_NO_LEVEL, // handled object |
|---|
| 92 | ED4_L_NO_LEVEL // restriction level |
|---|
| 93 | ); |
|---|
| 94 | |
|---|
| 95 | static ED4_objspec line_terminal_spec( |
|---|
| 96 | ED4_P_IS_TERMINAL, // static props |
|---|
| 97 | ED4_L_LINE, // level |
|---|
| 98 | ED4_L_NO_LEVEL, // allowed children level |
|---|
| 99 | ED4_L_NO_LEVEL, // handled object |
|---|
| 100 | ED4_L_NO_LEVEL // restriction level |
|---|
| 101 | ); |
|---|
| 102 | |
|---|
| 103 | static ED4_objspec column_stat_terminal_spec( |
|---|
| 104 | ED4_P_IS_TERMINAL, // static props |
|---|
| 105 | ED4_L_COL_STAT, // level |
|---|
| 106 | ED4_L_NO_LEVEL, // allowed children level |
|---|
| 107 | ED4_L_NO_LEVEL, // handled object |
|---|
| 108 | ED4_L_NO_LEVEL // restriction level |
|---|
| 109 | ); |
|---|
| 110 | |
|---|
| 111 | |
|---|
| 112 | char *ED4_terminal::resolve_pointer_to_string_copy(int *str_len) const { |
|---|
| 113 | int len; |
|---|
| 114 | const char *s = resolve_pointer_to_char_pntr(&len); |
|---|
| 115 | char *t = GB_strduplen(s, len); // space for zero byte is allocated by GB_strduplen |
|---|
| 116 | |
|---|
| 117 | if (str_len) *str_len = len; |
|---|
| 118 | return t; |
|---|
| 119 | } |
|---|
| 120 | |
|---|
| 121 | const char *ED4_terminal::resolve_pointer_to_char_pntr(int *str_len) const |
|---|
| 122 | { |
|---|
| 123 | GB_TYPES gb_type; |
|---|
| 124 | const char *db_pointer = NULL; |
|---|
| 125 | GBDATA *gbd = get_species_pointer(); |
|---|
| 126 | |
|---|
| 127 | if (!gbd) { |
|---|
| 128 | if (str_len) { |
|---|
| 129 | if (id) *str_len = strlen(id); |
|---|
| 130 | else *str_len = 0; |
|---|
| 131 | } |
|---|
| 132 | return id; // if we don't have a link to the database we have to use our id |
|---|
| 133 | } |
|---|
| 134 | |
|---|
| 135 | GB_push_transaction(GLOBAL_gb_main); |
|---|
| 136 | |
|---|
| 137 | const char *copy_of = 0; // if set, return a copy of this string |
|---|
| 138 | |
|---|
| 139 | gb_type = GB_read_type(gbd); |
|---|
| 140 | #if defined(WARN_TODO) |
|---|
| 141 | #warning temporary workaround - gb_type GB_INT and GB_FLOAT in the switch directive must not be displayed but ignored |
|---|
| 142 | #endif |
|---|
| 143 | switch (gb_type) |
|---|
| 144 | { |
|---|
| 145 | case GB_STRING: |
|---|
| 146 | db_pointer = GB_read_char_pntr(gbd); |
|---|
| 147 | if (str_len) { |
|---|
| 148 | *str_len = GB_read_string_count(gbd); |
|---|
| 149 | e4_assert(*str_len == (int)strlen(db_pointer)); |
|---|
| 150 | } |
|---|
| 151 | break; |
|---|
| 152 | case GB_BITS: |
|---|
| 153 | db_pointer = GB_read_bits_pntr(gbd, '.', '+'); |
|---|
| 154 | if (str_len) { |
|---|
| 155 | *str_len = GB_read_bits_count(gbd); |
|---|
| 156 | e4_assert(*str_len == (int)strlen(db_pointer)); |
|---|
| 157 | } |
|---|
| 158 | break; |
|---|
| 159 | case GB_BYTES: |
|---|
| 160 | db_pointer = GB_read_bytes_pntr(gbd); |
|---|
| 161 | if (str_len) { |
|---|
| 162 | *str_len = GB_read_bytes_count(gbd); |
|---|
| 163 | e4_assert(*str_len == (int)strlen(db_pointer)); |
|---|
| 164 | } |
|---|
| 165 | break; |
|---|
| 166 | case GB_DB: |
|---|
| 167 | copy_of = "GB_DB"; |
|---|
| 168 | break; |
|---|
| 169 | case GB_INT: // FIXME: temporary Workaround |
|---|
| 170 | copy_of = "GB_INT"; |
|---|
| 171 | break; |
|---|
| 172 | case GB_INTS: |
|---|
| 173 | copy_of = "GB_INTS"; |
|---|
| 174 | break; |
|---|
| 175 | case GB_FLOAT: // FIXME: temporary Workaround |
|---|
| 176 | copy_of = "GB_FLOAT"; |
|---|
| 177 | break; |
|---|
| 178 | case GB_FLOATS: |
|---|
| 179 | copy_of = "GB_FLOATS"; |
|---|
| 180 | break; |
|---|
| 181 | default: |
|---|
| 182 | printf("Unknown data type - Please contact administrator\n"); |
|---|
| 183 | e4_assert(0); |
|---|
| 184 | break; |
|---|
| 185 | } |
|---|
| 186 | |
|---|
| 187 | if (copy_of) { |
|---|
| 188 | e4_assert(db_pointer == 0); |
|---|
| 189 | |
|---|
| 190 | int len = strlen(copy_of); |
|---|
| 191 | db_pointer = GB_strduplen(copy_of, len); |
|---|
| 192 | |
|---|
| 193 | if (str_len) *str_len = len; |
|---|
| 194 | } |
|---|
| 195 | |
|---|
| 196 | GB_pop_transaction(GLOBAL_gb_main); |
|---|
| 197 | |
|---|
| 198 | return db_pointer; |
|---|
| 199 | } |
|---|
| 200 | |
|---|
| 201 | GB_ERROR ED4_terminal::write_sequence(const char *seq, int seq_len) |
|---|
| 202 | { |
|---|
| 203 | GB_ERROR err = 0; |
|---|
| 204 | GBDATA *gbd = get_species_pointer(); |
|---|
| 205 | e4_assert(gbd); // we must have a link to the database! |
|---|
| 206 | |
|---|
| 207 | GB_push_transaction(GLOBAL_gb_main); |
|---|
| 208 | |
|---|
| 209 | int old_seq_len; |
|---|
| 210 | char *old_seq = resolve_pointer_to_string_copy(&old_seq_len); |
|---|
| 211 | |
|---|
| 212 | bool allow_write_data = true; |
|---|
| 213 | if (ED4_ROOT->aw_root->awar(ED4_AWAR_ANNOUNCE_CHECKSUM_CHANGES)->read_int()) { |
|---|
| 214 | long old_checksum = GBS_checksum(old_seq, 1, "-."); |
|---|
| 215 | long new_checksum = GBS_checksum(seq, 1, "-."); |
|---|
| 216 | |
|---|
| 217 | if (old_checksum != new_checksum) { |
|---|
| 218 | if (aw_question(NULL, "Checksum changed!", "Allow, Reject") == 1) { |
|---|
| 219 | allow_write_data = false; |
|---|
| 220 | } |
|---|
| 221 | |
|---|
| 222 | } |
|---|
| 223 | } |
|---|
| 224 | |
|---|
| 225 | if (allow_write_data) { |
|---|
| 226 | GB_TYPES gb_type = GB_read_type(gbd); |
|---|
| 227 | switch (gb_type) { |
|---|
| 228 | case GB_STRING: { |
|---|
| 229 | err = GB_write_string(gbd, seq); |
|---|
| 230 | break; |
|---|
| 231 | } |
|---|
| 232 | case GB_BITS: { |
|---|
| 233 | err = GB_write_bits(gbd, seq, seq_len, ".-"); |
|---|
| 234 | break; |
|---|
| 235 | } |
|---|
| 236 | default: { |
|---|
| 237 | e4_assert(0); |
|---|
| 238 | break; |
|---|
| 239 | } |
|---|
| 240 | } |
|---|
| 241 | } |
|---|
| 242 | |
|---|
| 243 | GB_pop_transaction(GLOBAL_gb_main); |
|---|
| 244 | |
|---|
| 245 | if (!err && dynamic_prop&ED4_P_CONSENSUS_RELEVANT) { |
|---|
| 246 | if (old_seq) { |
|---|
| 247 | curr_timestamp = GB_read_clock(GLOBAL_gb_main); |
|---|
| 248 | |
|---|
| 249 | get_parent(ED4_L_MULTI_SPECIES)->to_multi_species_manager() |
|---|
| 250 | ->update_bases_and_rebuild_consensi(old_seq, old_seq_len, get_parent(ED4_L_SPECIES)->to_species_manager(), ED4_U_UP); // bases_check |
|---|
| 251 | } |
|---|
| 252 | else { |
|---|
| 253 | aw_message("Couldn't read old sequence data"); |
|---|
| 254 | } |
|---|
| 255 | |
|---|
| 256 | request_refresh(); |
|---|
| 257 | } |
|---|
| 258 | |
|---|
| 259 | if (old_seq) free(old_seq); |
|---|
| 260 | |
|---|
| 261 | return err; |
|---|
| 262 | } |
|---|
| 263 | |
|---|
| 264 | |
|---|
| 265 | ED4_returncode ED4_terminal::remove_callbacks() // removes callbacks and gb_alignment |
|---|
| 266 | { |
|---|
| 267 | if (get_species_pointer()) { |
|---|
| 268 | set_species_pointer(0); |
|---|
| 269 | tflag.deleted = 1; // @@@ why ? |
|---|
| 270 | clr_property(ED4_P_CURSOR_ALLOWED); |
|---|
| 271 | request_refresh(); |
|---|
| 272 | } |
|---|
| 273 | return ED4_R_OK; |
|---|
| 274 | } |
|---|
| 275 | |
|---|
| 276 | #if 0 |
|---|
| 277 | static ARB_ERROR ed4_remove_species_manager_callbacks(ED4_base *base) { // @@@ unused since [8286] |
|---|
| 278 | if (base->is_species_manager()) { |
|---|
| 279 | base->to_species_manager()->remove_all_callbacks(); |
|---|
| 280 | } |
|---|
| 281 | return NULL; |
|---|
| 282 | } |
|---|
| 283 | #endif |
|---|
| 284 | |
|---|
| 285 | inline void remove_from_consensus(ED4_manager *group_or_species_man) { |
|---|
| 286 | GB_transaction ta(GLOBAL_gb_main); |
|---|
| 287 | ED4_manager *parent_manager = group_or_species_man->parent; |
|---|
| 288 | parent_manager->update_consensus(parent_manager, NULL, group_or_species_man); |
|---|
| 289 | parent_manager->rebuild_consensi(parent_manager, ED4_U_UP); |
|---|
| 290 | } |
|---|
| 291 | |
|---|
| 292 | ED4_returncode ED4_terminal::kill_object() { |
|---|
| 293 | ED4_species_manager *species_manager = get_parent(ED4_L_SPECIES)->to_species_manager(); |
|---|
| 294 | |
|---|
| 295 | if (species_manager->is_consensus_manager()) { // kill whole group |
|---|
| 296 | if (ED4_new_species_multi_species_manager()==species_manager->parent) { |
|---|
| 297 | aw_message("This group has to exist - deleting it isn't allowed"); |
|---|
| 298 | return ED4_R_IMPOSSIBLE; |
|---|
| 299 | } |
|---|
| 300 | |
|---|
| 301 | ED4_manager *group_manager = species_manager->get_parent(ED4_L_GROUP)->to_group_manager(); |
|---|
| 302 | remove_from_consensus(group_manager); |
|---|
| 303 | group_manager->Delete(); |
|---|
| 304 | } |
|---|
| 305 | else { // kill single species/SAI |
|---|
| 306 | remove_from_consensus(species_manager); |
|---|
| 307 | species_manager->Delete(); |
|---|
| 308 | } |
|---|
| 309 | |
|---|
| 310 | return ED4_R_OK; |
|---|
| 311 | } |
|---|
| 312 | |
|---|
| 313 | ED4_base *ED4_terminal::get_competent_clicked_child(AW_pos /* x */, AW_pos /* y */, ED4_properties /* relevant_prop */) |
|---|
| 314 | { |
|---|
| 315 | e4_assert(0); |
|---|
| 316 | return NULL; |
|---|
| 317 | } |
|---|
| 318 | |
|---|
| 319 | ED4_returncode ED4_terminal::handle_move(ED4_move_info * /* moveinfo */) |
|---|
| 320 | { |
|---|
| 321 | e4_assert(0); |
|---|
| 322 | return ED4_R_IMPOSSIBLE; |
|---|
| 323 | } |
|---|
| 324 | |
|---|
| 325 | ED4_returncode ED4_terminal::move_requested_by_child(ED4_move_info * /* moveinfo */) |
|---|
| 326 | { |
|---|
| 327 | e4_assert(0); |
|---|
| 328 | return ED4_R_IMPOSSIBLE; |
|---|
| 329 | } |
|---|
| 330 | |
|---|
| 331 | |
|---|
| 332 | ED4_base *ED4_terminal::get_competent_child(AW_pos /* x */, AW_pos /* y */, ED4_properties /* relevant_prop */) |
|---|
| 333 | { |
|---|
| 334 | e4_assert(0); |
|---|
| 335 | return NULL; |
|---|
| 336 | } |
|---|
| 337 | |
|---|
| 338 | ED4_returncode ED4_terminal::draw_drag_box(AW_pos x, AW_pos y, GB_CSTR text, int cursor_y) { |
|---|
| 339 | // draws drag box of object at location abs_x, abs_y |
|---|
| 340 | |
|---|
| 341 | if (cursor_y!=-1) { |
|---|
| 342 | ED4_base *drag_target = NULL; |
|---|
| 343 | { |
|---|
| 344 | ED4_extension location; |
|---|
| 345 | location.position[X_POS] = 0; |
|---|
| 346 | location.position[Y_POS] = (AW_pos)cursor_y; // cursor_y is already in world coordinates |
|---|
| 347 | |
|---|
| 348 | ED4_ROOT->get_device_manager()->children->search_target_species(&location, ED4_P_HORIZONTAL, &drag_target, ED4_L_NO_LEVEL); |
|---|
| 349 | } |
|---|
| 350 | |
|---|
| 351 | if (drag_target) { |
|---|
| 352 | AW_pos target_x, target_y; |
|---|
| 353 | |
|---|
| 354 | drag_target->calc_world_coords (&target_x, &target_y); |
|---|
| 355 | current_ed4w()->world_to_win_coords(&target_x, &target_y); |
|---|
| 356 | |
|---|
| 357 | #define ARROW_LENGTH 3 |
|---|
| 358 | AW_pos drag_line_x0[3], drag_line_y0[3]; |
|---|
| 359 | AW_pos drag_line_x1[3], drag_line_y1[3]; |
|---|
| 360 | |
|---|
| 361 | drag_line_x0[0] = target_x + 5; // horizontal |
|---|
| 362 | drag_line_y0[0] = target_y + drag_target->extension.size[HEIGHT]; |
|---|
| 363 | drag_line_x1[0] = drag_line_x0[0] + 50; |
|---|
| 364 | drag_line_y1[0] = target_y + drag_target->extension.size[HEIGHT]; |
|---|
| 365 | |
|---|
| 366 | drag_line_x0[1] = drag_line_x0[0] -ARROW_LENGTH; // arrow |
|---|
| 367 | drag_line_y0[1] = drag_line_y0[0] -ARROW_LENGTH; |
|---|
| 368 | drag_line_x1[1] = drag_line_x0[0]; |
|---|
| 369 | drag_line_y1[1] = drag_line_y0[0]; |
|---|
| 370 | |
|---|
| 371 | drag_line_x0[2] = drag_line_x0[0] -ARROW_LENGTH; // arrow |
|---|
| 372 | drag_line_y0[2] = drag_line_y0[0] + ARROW_LENGTH; |
|---|
| 373 | drag_line_x1[2] = drag_line_x0[0]; |
|---|
| 374 | drag_line_y1[2] = drag_line_y0[0]; |
|---|
| 375 | #undef ARROW_LENGTH |
|---|
| 376 | |
|---|
| 377 | for (ED4_index i = 0; i <= 2; i++) { |
|---|
| 378 | current_device()->line(ED4_G_DRAG, drag_line_x0[i], drag_line_y0[i], drag_line_x1[i], drag_line_y1[i], AW_SCREEN); |
|---|
| 379 | } |
|---|
| 380 | } |
|---|
| 381 | } |
|---|
| 382 | |
|---|
| 383 | if (text != NULL) { |
|---|
| 384 | current_device()->text(ED4_G_DRAG, text, (x + 20), (y + INFO_TERM_TEXT_YOFFSET), 0, AW_SCREEN); |
|---|
| 385 | } |
|---|
| 386 | |
|---|
| 387 | return ED4_R_OK; |
|---|
| 388 | } |
|---|
| 389 | |
|---|
| 390 | ED4_returncode ED4_terminal::move_requested_by_parent(ED4_move_info *) { // handles a move request coming from parent |
|---|
| 391 | e4_assert(0); |
|---|
| 392 | return (ED4_R_IMPOSSIBLE); |
|---|
| 393 | } |
|---|
| 394 | |
|---|
| 395 | void ED4_multi_species_manager::toggle_selected_species() { |
|---|
| 396 | if (all_are_selected()) deselect_all_species_and_SAI(); |
|---|
| 397 | else select_all(false); // species and SAI |
|---|
| 398 | |
|---|
| 399 | ED4_correctBlocktypeAfterSelection(); |
|---|
| 400 | } |
|---|
| 401 | |
|---|
| 402 | #if defined(DEBUG) && 1 |
|---|
| 403 | static inline void dumpEvent(const char *where, AW_event *event) { |
|---|
| 404 | printf("%s: x=%i y=%i\n", where, event->x, event->y); |
|---|
| 405 | } |
|---|
| 406 | #else |
|---|
| 407 | #define dumpEvent(w, e) |
|---|
| 408 | #endif |
|---|
| 409 | |
|---|
| 410 | ED4_returncode ED4_terminal::event_sent_by_parent(AW_event *event, AW_window *aww) // handles an input event coming from parent |
|---|
| 411 | { |
|---|
| 412 | static ED4_species_name_terminal *dragged_name_terminal = 0; |
|---|
| 413 | static int dragged_was_selected; |
|---|
| 414 | static bool pressed_left_button = 0; |
|---|
| 415 | static int other_x, other_y; // coordinates of last event |
|---|
| 416 | static bool right_button_started_on_sequence_term = 0; |
|---|
| 417 | |
|---|
| 418 | switch (event->type) { |
|---|
| 419 | case AW_Mouse_Press: { |
|---|
| 420 | switch (event->button) { |
|---|
| 421 | case AW_BUTTON_LEFT: { |
|---|
| 422 | pressed_left_button = 0; |
|---|
| 423 | if (is_species_name_terminal()) { |
|---|
| 424 | switch (ED4_ROOT->species_mode) { |
|---|
| 425 | case ED4_SM_KILL: { |
|---|
| 426 | if (containing_species_manager()->is_selected()) ED4_ROOT->remove_from_selected(this->to_species_name_terminal()); |
|---|
| 427 | kill_object(); |
|---|
| 428 | return ED4_R_BREAK; |
|---|
| 429 | } |
|---|
| 430 | case ED4_SM_MOVE: { |
|---|
| 431 | dragged_name_terminal = to_species_name_terminal(); |
|---|
| 432 | pressed_left_button = 1; |
|---|
| 433 | other_x = event->x; |
|---|
| 434 | other_y = event->y; |
|---|
| 435 | |
|---|
| 436 | if (!containing_species_manager()->is_selected()) { |
|---|
| 437 | ED4_ROOT->add_to_selected(dragged_name_terminal); |
|---|
| 438 | dragged_was_selected = 0; |
|---|
| 439 | ED4_trigger_instant_refresh(); |
|---|
| 440 | } |
|---|
| 441 | else { |
|---|
| 442 | dragged_was_selected = 1; |
|---|
| 443 | } |
|---|
| 444 | break; |
|---|
| 445 | } |
|---|
| 446 | case ED4_SM_MARK: { |
|---|
| 447 | ED4_species_manager *species_man = get_parent(ED4_L_SPECIES)->to_species_manager(); |
|---|
| 448 | GBDATA *gbd = species_man->get_species_pointer(); |
|---|
| 449 | |
|---|
| 450 | if (gbd) { |
|---|
| 451 | GB_write_flag(gbd, !GB_read_flag(gbd)); |
|---|
| 452 | request_refresh(); |
|---|
| 453 | // ProtView: Refreshing orf terminals |
|---|
| 454 | if (ED4_ROOT->alignment_type == GB_AT_DNA) { |
|---|
| 455 | PV_RefreshWindow(aww->get_root()); |
|---|
| 456 | } |
|---|
| 457 | } |
|---|
| 458 | break; |
|---|
| 459 | } |
|---|
| 460 | default: { |
|---|
| 461 | e4_assert(0); |
|---|
| 462 | break; |
|---|
| 463 | } |
|---|
| 464 | } |
|---|
| 465 | } |
|---|
| 466 | else if (is_bracket_terminal()) { // fold/unfold group |
|---|
| 467 | if (dynamic_prop & ED4_P_IS_FOLDED) { |
|---|
| 468 | to_bracket_terminal()->unfold(); |
|---|
| 469 | } |
|---|
| 470 | else { |
|---|
| 471 | to_bracket_terminal()->fold(); |
|---|
| 472 | } |
|---|
| 473 | } |
|---|
| 474 | else { |
|---|
| 475 | if (dynamic_prop & ED4_P_CURSOR_ALLOWED) { |
|---|
| 476 | ED4_no_dangerous_modes(); |
|---|
| 477 | current_cursor().show_clicked_cursor(event->x, this); |
|---|
| 478 | } |
|---|
| 479 | } |
|---|
| 480 | break; |
|---|
| 481 | } |
|---|
| 482 | case AW_BUTTON_RIGHT: { |
|---|
| 483 | right_button_started_on_sequence_term = 0; |
|---|
| 484 | if (is_bracket_terminal()) { // right click on bracket terminal |
|---|
| 485 | ED4_base *group = get_parent(ED4_L_GROUP); |
|---|
| 486 | if (group) { |
|---|
| 487 | group->to_group_manager()->get_multi_species_manager()->toggle_selected_species(); |
|---|
| 488 | } |
|---|
| 489 | } |
|---|
| 490 | else if (is_species_name_terminal()) { |
|---|
| 491 | ED4_species_manager *species_man = get_parent(ED4_L_SPECIES)->to_species_manager(); |
|---|
| 492 | |
|---|
| 493 | if (species_man->is_consensus_manager()) { // click on consensus-name |
|---|
| 494 | ED4_multi_species_manager *multi_man = species_man->get_parent(ED4_L_MULTI_SPECIES)->to_multi_species_manager(); |
|---|
| 495 | multi_man->toggle_selected_species(); |
|---|
| 496 | } |
|---|
| 497 | else { // click on species or SAI name |
|---|
| 498 | if (!species_man->is_selected()) { // select if not selected |
|---|
| 499 | if (ED4_ROOT->add_to_selected(this->to_species_name_terminal()) == ED4_R_OK) ED4_correctBlocktypeAfterSelection(); |
|---|
| 500 | } |
|---|
| 501 | else { // deselect if already selected |
|---|
| 502 | ED4_ROOT->remove_from_selected(this->to_species_name_terminal()); |
|---|
| 503 | ED4_correctBlocktypeAfterSelection(); |
|---|
| 504 | } |
|---|
| 505 | } |
|---|
| 506 | } |
|---|
| 507 | else if (is_sequence_terminal()) { |
|---|
| 508 | dumpEvent("Press", event); |
|---|
| 509 | |
|---|
| 510 | ED4_no_dangerous_modes(); |
|---|
| 511 | ED4_setColumnblockCorner(event, to_sequence_terminal()); // mark columnblock |
|---|
| 512 | right_button_started_on_sequence_term = 1; |
|---|
| 513 | } |
|---|
| 514 | break; |
|---|
| 515 | } |
|---|
| 516 | default : break; |
|---|
| 517 | } |
|---|
| 518 | break; |
|---|
| 519 | } |
|---|
| 520 | case AW_Mouse_Drag: { |
|---|
| 521 | switch (event->button) { |
|---|
| 522 | case AW_BUTTON_LEFT: { |
|---|
| 523 | if (dragged_name_terminal) { |
|---|
| 524 | ED4_selection_entry *sel_info = dragged_name_terminal->selection_info; |
|---|
| 525 | |
|---|
| 526 | if (pressed_left_button) { |
|---|
| 527 | AW_pos world_x, world_y; |
|---|
| 528 | |
|---|
| 529 | dragged_name_terminal->calc_world_coords(&world_x, &world_y); |
|---|
| 530 | current_ed4w()->world_to_win_coords(&world_x, &world_y); |
|---|
| 531 | |
|---|
| 532 | sel_info->drag_old_x = world_x; |
|---|
| 533 | sel_info->drag_old_y = world_y; |
|---|
| 534 | sel_info->drag_off_x = world_x-other_x; |
|---|
| 535 | sel_info->drag_off_y = world_y-other_y; |
|---|
| 536 | sel_info->old_event_y = -1; |
|---|
| 537 | |
|---|
| 538 | pressed_left_button = 0; |
|---|
| 539 | } |
|---|
| 540 | |
|---|
| 541 | GB_CSTR text = dragged_name_terminal->get_displayed_text(); |
|---|
| 542 | |
|---|
| 543 | if (dragged_name_terminal->dragged) { |
|---|
| 544 | dragged_name_terminal->draw_drag_box(sel_info->drag_old_x, sel_info->drag_old_y, text, sel_info->old_event_y); |
|---|
| 545 | } |
|---|
| 546 | |
|---|
| 547 | AW_pos new_x = sel_info->drag_off_x + event->x; |
|---|
| 548 | AW_pos new_y = sel_info->drag_off_y + event->y; |
|---|
| 549 | |
|---|
| 550 | dragged_name_terminal->draw_drag_box(new_x, new_y, text, event->y); // @@@ event->y ist falsch, falls vertikal gescrollt ist! |
|---|
| 551 | |
|---|
| 552 | sel_info->drag_old_x = new_x; |
|---|
| 553 | sel_info->drag_old_y = new_y; |
|---|
| 554 | sel_info->old_event_y = event->y; |
|---|
| 555 | |
|---|
| 556 | dragged_name_terminal->dragged = true; |
|---|
| 557 | } |
|---|
| 558 | |
|---|
| 559 | break; |
|---|
| 560 | } |
|---|
| 561 | case AW_BUTTON_RIGHT: { |
|---|
| 562 | if (is_sequence_terminal() && right_button_started_on_sequence_term) { |
|---|
| 563 | ED4_no_dangerous_modes(); |
|---|
| 564 | ED4_setColumnblockCorner(event, to_sequence_terminal()); // mark columnblock |
|---|
| 565 | } |
|---|
| 566 | break; |
|---|
| 567 | } |
|---|
| 568 | default: break; |
|---|
| 569 | } |
|---|
| 570 | break; |
|---|
| 571 | } |
|---|
| 572 | case AW_Mouse_Release: { |
|---|
| 573 | switch (event->button) { |
|---|
| 574 | case AW_BUTTON_LEFT: { |
|---|
| 575 | if (dragged_name_terminal) { |
|---|
| 576 | if (dragged_name_terminal->dragged) { |
|---|
| 577 | { |
|---|
| 578 | char *db_pointer = dragged_name_terminal->resolve_pointer_to_string_copy(); |
|---|
| 579 | ED4_selection_entry *sel_info = dragged_name_terminal->selection_info; |
|---|
| 580 | |
|---|
| 581 | dragged_name_terminal->draw_drag_box(sel_info->drag_old_x, sel_info->drag_old_y, db_pointer, sel_info->old_event_y); |
|---|
| 582 | dragged_name_terminal->dragged = false; |
|---|
| 583 | |
|---|
| 584 | free(db_pointer); |
|---|
| 585 | } |
|---|
| 586 | { |
|---|
| 587 | ED4_move_info mi; |
|---|
| 588 | |
|---|
| 589 | mi.object = dragged_name_terminal; |
|---|
| 590 | mi.end_x = event->x; |
|---|
| 591 | mi.end_y = event->y; |
|---|
| 592 | mi.mode = ED4_M_FREE; |
|---|
| 593 | mi.preferred_parent = ED4_L_NO_LEVEL; |
|---|
| 594 | |
|---|
| 595 | dragged_name_terminal->parent->move_requested_by_child(&mi); |
|---|
| 596 | } |
|---|
| 597 | { |
|---|
| 598 | ED4_device_manager *device_manager = ED4_ROOT->get_device_manager(); |
|---|
| 599 | |
|---|
| 600 | for (int i=0; i<device_manager->children->members(); i++) { // when moving species numbers have to be recalculated |
|---|
| 601 | ED4_base *member = device_manager->children->member(i); |
|---|
| 602 | |
|---|
| 603 | if (member->is_area_manager()) { |
|---|
| 604 | member->to_area_manager()->get_multi_species_manager()->update_requested_by_child(); |
|---|
| 605 | } |
|---|
| 606 | } |
|---|
| 607 | } |
|---|
| 608 | } |
|---|
| 609 | if (!dragged_was_selected) { |
|---|
| 610 | ED4_ROOT->remove_from_selected(dragged_name_terminal); |
|---|
| 611 | } |
|---|
| 612 | |
|---|
| 613 | pressed_left_button = 0; |
|---|
| 614 | dragged_name_terminal = 0; |
|---|
| 615 | } |
|---|
| 616 | break; |
|---|
| 617 | } |
|---|
| 618 | |
|---|
| 619 | case AW_BUTTON_RIGHT: { |
|---|
| 620 | if (right_button_started_on_sequence_term && is_sequence_terminal()) { |
|---|
| 621 | dumpEvent("Relea", event); |
|---|
| 622 | ED4_no_dangerous_modes(); |
|---|
| 623 | ED4_setColumnblockCorner(event, to_sequence_terminal()); // mark columnblock |
|---|
| 624 | } |
|---|
| 625 | break; |
|---|
| 626 | } |
|---|
| 627 | default: break; |
|---|
| 628 | } |
|---|
| 629 | break; |
|---|
| 630 | } |
|---|
| 631 | default: |
|---|
| 632 | #ifdef ARB_GTK |
|---|
| 633 | // there can be many other events here... |
|---|
| 634 | #else |
|---|
| 635 | e4_assert(0); |
|---|
| 636 | #endif |
|---|
| 637 | break; |
|---|
| 638 | } |
|---|
| 639 | return (ED4_R_OK); |
|---|
| 640 | } |
|---|
| 641 | |
|---|
| 642 | void ED4_terminal::update_requested_children() {} |
|---|
| 643 | |
|---|
| 644 | bool ED4_terminal::calc_bounding_box() { |
|---|
| 645 | // calculates the smallest rectangle containing the object. |
|---|
| 646 | // requests refresh and returns true if bounding box has changed. |
|---|
| 647 | |
|---|
| 648 | bool bb_changed = false; |
|---|
| 649 | |
|---|
| 650 | if (width_link) { |
|---|
| 651 | if (extension.size[WIDTH] != width_link->extension.size[WIDTH]) { // all bounding Boxes have the same size !!! |
|---|
| 652 | extension.size[WIDTH] = width_link->extension.size[WIDTH]; |
|---|
| 653 | bb_changed = true; |
|---|
| 654 | } |
|---|
| 655 | } |
|---|
| 656 | |
|---|
| 657 | if (height_link) { |
|---|
| 658 | if (extension.size[HEIGHT] != height_link->extension.size[HEIGHT]) { |
|---|
| 659 | extension.size[HEIGHT] = height_link->extension.size[HEIGHT]; |
|---|
| 660 | bb_changed = true; |
|---|
| 661 | } |
|---|
| 662 | } |
|---|
| 663 | |
|---|
| 664 | |
|---|
| 665 | if (bb_changed) { |
|---|
| 666 | request_resize_of_linked(); |
|---|
| 667 | request_refresh(); |
|---|
| 668 | } |
|---|
| 669 | return bb_changed; |
|---|
| 670 | } |
|---|
| 671 | |
|---|
| 672 | void ED4_terminal::resize_requested_children() { |
|---|
| 673 | if (update_info.resize) { // likes to resize? |
|---|
| 674 | if (calc_bounding_box()) { |
|---|
| 675 | request_resize(); |
|---|
| 676 | } |
|---|
| 677 | } |
|---|
| 678 | } |
|---|
| 679 | |
|---|
| 680 | |
|---|
| 681 | void ED4_terminal::request_refresh(int clear) { |
|---|
| 682 | update_info.set_refresh(1); |
|---|
| 683 | update_info.set_clear_at_refresh(clear); |
|---|
| 684 | if (parent) parent->refresh_requested_by_child(); |
|---|
| 685 | } |
|---|
| 686 | |
|---|
| 687 | |
|---|
| 688 | ED4_base* ED4_terminal::search_ID(const char *temp_id) |
|---|
| 689 | { |
|---|
| 690 | if (id && strcmp(temp_id, id) == 0) return (this); |
|---|
| 691 | return (NULL); |
|---|
| 692 | } |
|---|
| 693 | |
|---|
| 694 | ED4_terminal::ED4_terminal(const ED4_objspec& spec_, GB_CSTR temp_id, AW_pos x, AW_pos y, AW_pos width, AW_pos height, ED4_manager *temp_parent) : |
|---|
| 695 | ED4_base(spec_, temp_id, x, y, width, height, temp_parent) |
|---|
| 696 | { |
|---|
| 697 | memset((char*)&tflag, 0, sizeof(tflag)); |
|---|
| 698 | curr_timestamp = 0; |
|---|
| 699 | } |
|---|
| 700 | |
|---|
| 701 | |
|---|
| 702 | ED4_terminal::~ED4_terminal() { |
|---|
| 703 | for (ED4_window *window = ED4_ROOT->first_window; window; window=window->next) { |
|---|
| 704 | ED4_cursor& cursor = window->cursor; |
|---|
| 705 | if (this == cursor.owner_of_cursor) { |
|---|
| 706 | cursor.init(); |
|---|
| 707 | } |
|---|
| 708 | } |
|---|
| 709 | } |
|---|
| 710 | |
|---|
| 711 | ED4_tree_terminal::ED4_tree_terminal(const char *temp_id, AW_pos x, AW_pos y, AW_pos width, AW_pos height, ED4_manager *temp_parent) |
|---|
| 712 | : ED4_terminal(tree_terminal_spec, temp_id, x, y, width, height, temp_parent) |
|---|
| 713 | { |
|---|
| 714 | } |
|---|
| 715 | |
|---|
| 716 | ED4_returncode ED4_tree_terminal::Show(int IF_ASSERTION_USED(refresh_all), int is_cleared) |
|---|
| 717 | { |
|---|
| 718 | e4_assert(update_info.refresh || refresh_all); |
|---|
| 719 | current_device()->push_clip_scale(); |
|---|
| 720 | if (adjust_clipping_rectangle()) { |
|---|
| 721 | if (update_info.clear_at_refresh && !is_cleared) { |
|---|
| 722 | clear_background(); |
|---|
| 723 | } |
|---|
| 724 | draw(); |
|---|
| 725 | } |
|---|
| 726 | current_device()->pop_clip_scale(); |
|---|
| 727 | |
|---|
| 728 | return (ED4_R_OK); |
|---|
| 729 | } |
|---|
| 730 | |
|---|
| 731 | |
|---|
| 732 | |
|---|
| 733 | ED4_returncode ED4_tree_terminal::draw() { |
|---|
| 734 | AW_pos x, y; |
|---|
| 735 | AW_pos text_x, text_y; |
|---|
| 736 | char *db_pointer; |
|---|
| 737 | |
|---|
| 738 | calc_world_coords(&x, &y); |
|---|
| 739 | current_ed4w()->world_to_win_coords(&x, &y); |
|---|
| 740 | |
|---|
| 741 | text_x = x + CHARACTEROFFSET; // don't change |
|---|
| 742 | text_y = y + SEQ_TERM_TEXT_YOFFSET; |
|---|
| 743 | |
|---|
| 744 | db_pointer = resolve_pointer_to_string_copy(); |
|---|
| 745 | current_device()->text(ED4_G_STANDARD, db_pointer, text_x, text_y, 0, AW_SCREEN); |
|---|
| 746 | free(db_pointer); |
|---|
| 747 | |
|---|
| 748 | return (ED4_R_OK); |
|---|
| 749 | } |
|---|
| 750 | |
|---|
| 751 | ED4_bracket_terminal::ED4_bracket_terminal(const char *temp_id, AW_pos x, AW_pos y, AW_pos width, AW_pos height, ED4_manager *temp_parent) |
|---|
| 752 | : ED4_terminal(bracket_terminal_spec, temp_id, x, y, width, height, temp_parent) |
|---|
| 753 | { |
|---|
| 754 | } |
|---|
| 755 | |
|---|
| 756 | ED4_returncode ED4_bracket_terminal::Show(int IF_ASSERTION_USED(refresh_all), int is_cleared) |
|---|
| 757 | { |
|---|
| 758 | e4_assert(update_info.refresh || refresh_all); |
|---|
| 759 | current_device()->push_clip_scale(); |
|---|
| 760 | if (adjust_clipping_rectangle()) { |
|---|
| 761 | if (update_info.clear_at_refresh && !is_cleared) { |
|---|
| 762 | clear_background(); |
|---|
| 763 | } |
|---|
| 764 | draw(); |
|---|
| 765 | } |
|---|
| 766 | current_device()->pop_clip_scale(); |
|---|
| 767 | |
|---|
| 768 | return ED4_R_OK; |
|---|
| 769 | } |
|---|
| 770 | |
|---|
| 771 | |
|---|
| 772 | ED4_returncode ED4_bracket_terminal::draw() { |
|---|
| 773 | using namespace AW; |
|---|
| 774 | |
|---|
| 775 | Rectangle term_area = get_win_area(current_ed4w()); |
|---|
| 776 | AW_device *device = current_device(); |
|---|
| 777 | |
|---|
| 778 | ED4_multi_species_manager *multi_man = get_parent(ED4_L_GROUP)->to_group_manager()->get_multi_species_manager(); |
|---|
| 779 | if (multi_man->get_no_of_selected_species()) { // if multi_species_manager contains selected species |
|---|
| 780 | #if defined(DEBUG) && 0 |
|---|
| 781 | static bool toggle = false; |
|---|
| 782 | toggle = !toggle; |
|---|
| 783 | device->box(toggle ? ED4_G_SELECTED : ED4_G_SELECTED+1, true, term_area); |
|---|
| 784 | #else // !defined(DEBUG) |
|---|
| 785 | device->box(ED4_G_SELECTED, true, term_area); |
|---|
| 786 | #endif |
|---|
| 787 | } |
|---|
| 788 | |
|---|
| 789 | if (dynamic_prop & ED4_P_IS_FOLDED) { // paint triangle for folded group |
|---|
| 790 | Position t = term_area.upper_left_corner()+Vector(4,4); |
|---|
| 791 | Position b = t+Vector(0,12); |
|---|
| 792 | |
|---|
| 793 | for (int i = 0; i<6; ++i) { |
|---|
| 794 | device->line(ED4_G_STANDARD, t, b, AW_SCREEN); |
|---|
| 795 | t += Vector(1, 1); |
|---|
| 796 | b += Vector(1, -1); |
|---|
| 797 | } |
|---|
| 798 | e4_assert(nearlyEqual(t, b)); |
|---|
| 799 | device->line(ED4_G_STANDARD, t, b, AW_SCREEN); // arrowhead |
|---|
| 800 | } |
|---|
| 801 | else { |
|---|
| 802 | Position l = term_area.upper_left_corner()+Vector(4,5); |
|---|
| 803 | Position r = l+Vector(6,0); |
|---|
| 804 | |
|---|
| 805 | for (int i = 0; i<3; ++i) { |
|---|
| 806 | device->line(ED4_G_STANDARD, l, r, AW_SCREEN); |
|---|
| 807 | l += Vector( 0, 1); |
|---|
| 808 | r += Vector( 0, 1); |
|---|
| 809 | device->line(ED4_G_STANDARD, l, r, AW_SCREEN); |
|---|
| 810 | l += Vector( 1, 1); |
|---|
| 811 | r += Vector(-1, 1); |
|---|
| 812 | } |
|---|
| 813 | e4_assert(nearlyEqual(l, r)); |
|---|
| 814 | device->line(ED4_G_STANDARD, l, r+Vector(0,1), AW_SCREEN); // arrowhead |
|---|
| 815 | } |
|---|
| 816 | |
|---|
| 817 | { |
|---|
| 818 | Rectangle bracket(term_area.upper_left_corner()+Vector(2,2), term_area.diagonal()+Vector(-2,-4)); |
|---|
| 819 | |
|---|
| 820 | device->line(ED4_G_STANDARD, bracket.upper_edge(), AW_SCREEN); |
|---|
| 821 | device->line(ED4_G_STANDARD, bracket.lower_edge(), AW_SCREEN); |
|---|
| 822 | device->line(ED4_G_STANDARD, bracket.left_edge(), AW_SCREEN); |
|---|
| 823 | } |
|---|
| 824 | |
|---|
| 825 | return (ED4_R_OK); |
|---|
| 826 | } |
|---|
| 827 | |
|---|
| 828 | ED4_species_name_terminal::ED4_species_name_terminal(GB_CSTR temp_id, AW_pos x, AW_pos y, AW_pos width, AW_pos height, ED4_manager *temp_parent) : |
|---|
| 829 | ED4_text_terminal(species_name_terminal_spec, temp_id, x, y, width, height, temp_parent), |
|---|
| 830 | selection_info(NULL), |
|---|
| 831 | dragged(false) |
|---|
| 832 | { |
|---|
| 833 | } |
|---|
| 834 | |
|---|
| 835 | #define MAXNAMELEN MAXSPECIESWIDTH |
|---|
| 836 | #define BUFFERSIZE (MAXNAMELEN<<1) |
|---|
| 837 | GB_CSTR ED4_species_name_terminal::get_displayed_text() const |
|---|
| 838 | { |
|---|
| 839 | static char *real_name; |
|---|
| 840 | static int allocatedSize; |
|---|
| 841 | |
|---|
| 842 | if (!real_name || allocatedSize<(BUFFERSIZE+1)) { |
|---|
| 843 | free(real_name); |
|---|
| 844 | allocatedSize = BUFFERSIZE+1; |
|---|
| 845 | real_name = (char*)malloc(allocatedSize); |
|---|
| 846 | } |
|---|
| 847 | memset(real_name, 0, allocatedSize); |
|---|
| 848 | |
|---|
| 849 | ED4_species_manager *spec_man = get_parent(ED4_L_SPECIES)->to_species_manager(); |
|---|
| 850 | |
|---|
| 851 | if (spec_man->is_consensus_manager()) { |
|---|
| 852 | char *db_pointer = resolve_pointer_to_string_copy(); |
|---|
| 853 | char *bracket = strchr(db_pointer, '('); |
|---|
| 854 | |
|---|
| 855 | if (bracket) { |
|---|
| 856 | int bracket_len = strlen(bracket); |
|---|
| 857 | int name_len = bracket-db_pointer; |
|---|
| 858 | |
|---|
| 859 | if (bracket[-1]==' ') { |
|---|
| 860 | name_len--; |
|---|
| 861 | } |
|---|
| 862 | |
|---|
| 863 | if ((name_len+1+bracket_len)<=MAXNAMELEN) { |
|---|
| 864 | strcpy(real_name, db_pointer); |
|---|
| 865 | } |
|---|
| 866 | else { |
|---|
| 867 | int short_name_len = MAXNAMELEN-bracket_len-1; |
|---|
| 868 | |
|---|
| 869 | memcpy(real_name, db_pointer, short_name_len); |
|---|
| 870 | real_name[short_name_len] = ' '; |
|---|
| 871 | strcpy(real_name+short_name_len+1, bracket); |
|---|
| 872 | } |
|---|
| 873 | } |
|---|
| 874 | else { |
|---|
| 875 | strncpy(real_name, db_pointer, BUFFERSIZE); |
|---|
| 876 | } |
|---|
| 877 | |
|---|
| 878 | free(db_pointer); |
|---|
| 879 | } |
|---|
| 880 | else if (spec_man->is_SAI_manager()) { |
|---|
| 881 | char *db_pointer = resolve_pointer_to_string_copy(); |
|---|
| 882 | |
|---|
| 883 | strcpy(real_name, "SAI: "); |
|---|
| 884 | if (strcmp(db_pointer, "ECOLI")==0) { |
|---|
| 885 | const char *name_for_ecoli = ED4_ROOT->aw_root->awar(ED4_AWAR_NDS_ECOLI_NAME)->read_char_pntr(); |
|---|
| 886 | if (name_for_ecoli[0]==0) name_for_ecoli = db_pointer; |
|---|
| 887 | strncpy(real_name+5, name_for_ecoli, BUFFERSIZE-5); |
|---|
| 888 | } |
|---|
| 889 | else { |
|---|
| 890 | strncpy(real_name+5, db_pointer, BUFFERSIZE-5); |
|---|
| 891 | } |
|---|
| 892 | free(db_pointer); |
|---|
| 893 | } |
|---|
| 894 | else { // normal species |
|---|
| 895 | char *result = ED4_get_NDS_text(spec_man); |
|---|
| 896 | strncpy(real_name, result, BUFFERSIZE); |
|---|
| 897 | free(result); |
|---|
| 898 | } |
|---|
| 899 | |
|---|
| 900 | return real_name; |
|---|
| 901 | } |
|---|
| 902 | #undef MAXNAMELEN |
|---|
| 903 | #undef BUFFERSIZE |
|---|
| 904 | |
|---|
| 905 | |
|---|
| 906 | ED4_sequence_info_terminal::ED4_sequence_info_terminal(const char *temp_id, /* GBDATA *gbd, */ AW_pos x, AW_pos y, AW_pos width, AW_pos height, ED4_manager *temp_parent) |
|---|
| 907 | : ED4_text_terminal(sequence_info_terminal_spec, temp_id, x, y, width, height, temp_parent) |
|---|
| 908 | { |
|---|
| 909 | } |
|---|
| 910 | |
|---|
| 911 | ED4_consensus_sequence_terminal::ED4_consensus_sequence_terminal(const char *temp_id, AW_pos x, AW_pos y, AW_pos width, AW_pos height, ED4_manager *temp_parent) |
|---|
| 912 | : ED4_sequence_terminal(temp_id, x, y, width, height, temp_parent, false) |
|---|
| 913 | { |
|---|
| 914 | species_name = NULL; |
|---|
| 915 | } |
|---|
| 916 | |
|---|
| 917 | ED4_abstract_sequence_terminal::ED4_abstract_sequence_terminal(const ED4_objspec& spec_, const char *temp_id, AW_pos x, AW_pos y, AW_pos width, AW_pos height, ED4_manager *temp_parent) |
|---|
| 918 | : ED4_text_terminal(spec_, temp_id, x, y, width, height, temp_parent) |
|---|
| 919 | { |
|---|
| 920 | species_name = NULL; |
|---|
| 921 | } |
|---|
| 922 | |
|---|
| 923 | ED4_abstract_sequence_terminal::~ED4_abstract_sequence_terminal() { |
|---|
| 924 | free(species_name); |
|---|
| 925 | } |
|---|
| 926 | |
|---|
| 927 | ED4_orf_terminal::ED4_orf_terminal(const char *temp_id, AW_pos x, AW_pos y, AW_pos width, AW_pos height, ED4_manager *temp_parent) |
|---|
| 928 | : ED4_abstract_sequence_terminal(orf_terminal_spec, temp_id, x, y, width, height, temp_parent) |
|---|
| 929 | { |
|---|
| 930 | aaSequence = 0; |
|---|
| 931 | aaSeqLen = 0; |
|---|
| 932 | aaColor = 0; |
|---|
| 933 | aaStartPos = 0; |
|---|
| 934 | aaStrandType = 0; |
|---|
| 935 | } |
|---|
| 936 | |
|---|
| 937 | GB_alignment_type ED4_orf_terminal::GetAliType() |
|---|
| 938 | { |
|---|
| 939 | return (GB_alignment_type) GB_AT_AA; |
|---|
| 940 | } |
|---|
| 941 | |
|---|
| 942 | ED4_orf_terminal::~ED4_orf_terminal() |
|---|
| 943 | { |
|---|
| 944 | free(aaSequence); |
|---|
| 945 | free(aaColor); |
|---|
| 946 | } |
|---|
| 947 | |
|---|
| 948 | ED4_sequence_terminal::ED4_sequence_terminal(const char *temp_id, AW_pos x, AW_pos y, AW_pos width, AW_pos height, ED4_manager *temp_parent, bool shall_display_secstruct_info_) |
|---|
| 949 | : ED4_abstract_sequence_terminal(sequence_terminal_spec, temp_id, x, y, width, height, temp_parent), |
|---|
| 950 | shall_display_secstruct_info(shall_display_secstruct_info_) |
|---|
| 951 | { |
|---|
| 952 | st_ml_node = NULL; |
|---|
| 953 | } |
|---|
| 954 | |
|---|
| 955 | GB_alignment_type ED4_sequence_terminal::GetAliType() |
|---|
| 956 | { |
|---|
| 957 | return ED4_ROOT->alignment_type; |
|---|
| 958 | } |
|---|
| 959 | |
|---|
| 960 | ED4_pure_text_terminal::ED4_pure_text_terminal(const char *temp_id, AW_pos x, AW_pos y, AW_pos width, AW_pos height, ED4_manager *temp_parent) |
|---|
| 961 | : ED4_text_terminal(pure_text_terminal_spec, temp_id, x, y, width, height, temp_parent) |
|---|
| 962 | { |
|---|
| 963 | } |
|---|
| 964 | |
|---|
| 965 | ED4_returncode ED4_spacer_terminal::Show(int /* refresh_all */, int is_cleared) { |
|---|
| 966 | if (shallDraw) { |
|---|
| 967 | if (update_info.clear_at_refresh && !is_cleared) { |
|---|
| 968 | clear_background(); |
|---|
| 969 | } |
|---|
| 970 | draw(); |
|---|
| 971 | } |
|---|
| 972 | return ED4_R_OK; |
|---|
| 973 | } |
|---|
| 974 | |
|---|
| 975 | |
|---|
| 976 | ED4_returncode ED4_spacer_terminal::draw() { |
|---|
| 977 | #if defined(DEBUG) && 0 |
|---|
| 978 | clear_background(ED4_G_FIRST_COLOR_GROUP); // draw colored spacers to make them visible |
|---|
| 979 | #else |
|---|
| 980 | clear_background(0); |
|---|
| 981 | #endif // DEBUG |
|---|
| 982 | return (ED4_R_OK); |
|---|
| 983 | } |
|---|
| 984 | |
|---|
| 985 | ED4_spacer_terminal::ED4_spacer_terminal(const char *temp_id, bool shallDraw_, AW_pos x, AW_pos y, AW_pos width, AW_pos height, ED4_manager *temp_parent) |
|---|
| 986 | : ED4_terminal(spacer_terminal_spec, temp_id, x, y, width, height, temp_parent), |
|---|
| 987 | shallDraw(shallDraw_) |
|---|
| 988 | { |
|---|
| 989 | } |
|---|
| 990 | |
|---|
| 991 | ED4_returncode ED4_line_terminal::draw() { |
|---|
| 992 | AW_pos x1, y1; |
|---|
| 993 | calc_world_coords(&x1, &y1); |
|---|
| 994 | current_ed4w()->world_to_win_coords(&x1, &y1); |
|---|
| 995 | |
|---|
| 996 | AW_pos x2 = x1+extension.size[WIDTH]-1; |
|---|
| 997 | AW_pos y2 = y1+extension.size[HEIGHT]-1; |
|---|
| 998 | |
|---|
| 999 | AW_device *device = current_device(); |
|---|
| 1000 | |
|---|
| 1001 | device->line(ED4_G_STANDARD, x1, y1, x2, y1); |
|---|
| 1002 | #if defined(DEBUG) |
|---|
| 1003 | device->box(ED4_G_MARKED, true, x1, y1+1, x2-x1+1, y2-y1-1); |
|---|
| 1004 | #else |
|---|
| 1005 | device->clear_part(x1, y1+1, x2-x1+1, y2-y1-1, AW_ALL_DEVICES); |
|---|
| 1006 | #endif // DEBUG |
|---|
| 1007 | device->line(ED4_G_STANDARD, x1, y2, x2, y2); |
|---|
| 1008 | |
|---|
| 1009 | return ED4_R_OK; |
|---|
| 1010 | } |
|---|
| 1011 | |
|---|
| 1012 | ED4_returncode ED4_line_terminal::Show(int /* refresh_all */, int is_cleared) |
|---|
| 1013 | { |
|---|
| 1014 | if (update_info.clear_at_refresh && !is_cleared) { |
|---|
| 1015 | clear_background(); |
|---|
| 1016 | } |
|---|
| 1017 | draw(); |
|---|
| 1018 | return ED4_R_OK; |
|---|
| 1019 | } |
|---|
| 1020 | |
|---|
| 1021 | |
|---|
| 1022 | ED4_line_terminal::ED4_line_terminal(const char *temp_id, AW_pos x, AW_pos y, AW_pos width, AW_pos height, ED4_manager *temp_parent) |
|---|
| 1023 | : ED4_terminal(line_terminal_spec, temp_id, x, y, width, height, temp_parent) |
|---|
| 1024 | { |
|---|
| 1025 | } |
|---|
| 1026 | |
|---|
| 1027 | // --------------------------------- |
|---|
| 1028 | // ED4_columnStat_terminal |
|---|
| 1029 | |
|---|
| 1030 | ED4_returncode ED4_columnStat_terminal::Show(int IF_ASSERTION_USED(refresh_all), int is_cleared) |
|---|
| 1031 | { |
|---|
| 1032 | e4_assert(update_info.refresh || refresh_all); |
|---|
| 1033 | current_device()->push_clip_scale(); |
|---|
| 1034 | if (adjust_clipping_rectangle()) { |
|---|
| 1035 | if (update_info.clear_at_refresh && !is_cleared) { |
|---|
| 1036 | clear_background(); |
|---|
| 1037 | } |
|---|
| 1038 | draw(); |
|---|
| 1039 | } |
|---|
| 1040 | current_device()->pop_clip_scale(); |
|---|
| 1041 | |
|---|
| 1042 | return ED4_R_OK; |
|---|
| 1043 | } |
|---|
| 1044 | |
|---|
| 1045 | inline char stat2display(int val, bool is_upper_digit) { |
|---|
| 1046 | if (val<0) { |
|---|
| 1047 | e4_assert(val==-1); // -1 indicates that no statistic is existing for that column |
|---|
| 1048 | return '?'; |
|---|
| 1049 | } |
|---|
| 1050 | if (val==20) return ' '; // value if ACGT and - are distributed equally |
|---|
| 1051 | if (val==100) return '^'; // we have only 2 characters to display likelihood (100 cannot be displayed) |
|---|
| 1052 | |
|---|
| 1053 | e4_assert(val>=0 && val<100); |
|---|
| 1054 | |
|---|
| 1055 | return '0' + (is_upper_digit ? (val/10) : (val%10)); |
|---|
| 1056 | } |
|---|
| 1057 | |
|---|
| 1058 | inline int find_significant_positions(int sig, int like_A, int like_C, int like_G, int like_TU, int *sumPtr) { |
|---|
| 1059 | // result == 0 -> no base-char has a significant likelihood (>=sig) |
|---|
| 1060 | // result == 1, 2, 4, 8 -> A, C, G, T/U has a significant likelihood |
|---|
| 1061 | // else -> the sum two of the likelihoods >= sig (bit-or-ed as in line above) |
|---|
| 1062 | |
|---|
| 1063 | int like[4]; |
|---|
| 1064 | like[0] = like_A; |
|---|
| 1065 | like[1] = like_C; |
|---|
| 1066 | like[2] = like_G; |
|---|
| 1067 | like[3] = like_TU; |
|---|
| 1068 | |
|---|
| 1069 | int bestSum = 0; |
|---|
| 1070 | int bestResult = 0; |
|---|
| 1071 | |
|---|
| 1072 | int b, c; |
|---|
| 1073 | for (b=0; b<4; b++) { |
|---|
| 1074 | int sum = like[b]; |
|---|
| 1075 | if (sum>=sig && sum>=bestSum) { |
|---|
| 1076 | bestSum = sum; |
|---|
| 1077 | bestResult = 1<<b; |
|---|
| 1078 | } |
|---|
| 1079 | } |
|---|
| 1080 | |
|---|
| 1081 | if (!bestResult) { |
|---|
| 1082 | for (b=0; b<4; b++) { |
|---|
| 1083 | for (c=b+1; c<4; c++) { |
|---|
| 1084 | int sum = like[b]+like[c]; |
|---|
| 1085 | if (sum>=sig && sum>=bestSum) { |
|---|
| 1086 | bestSum = sum; |
|---|
| 1087 | bestResult = (1<<b)|(1<<c); |
|---|
| 1088 | } |
|---|
| 1089 | } |
|---|
| 1090 | } |
|---|
| 1091 | } |
|---|
| 1092 | |
|---|
| 1093 | if (bestResult) { |
|---|
| 1094 | if (sumPtr) *sumPtr = bestSum; |
|---|
| 1095 | return bestResult; |
|---|
| 1096 | } |
|---|
| 1097 | |
|---|
| 1098 | return 0; |
|---|
| 1099 | } |
|---|
| 1100 | |
|---|
| 1101 | #define PROBE_MATCH_TARGET_STRING_LENGTH 32 |
|---|
| 1102 | |
|---|
| 1103 | GB_CSTR ED4_columnStat_terminal::build_probe_match_string(PosRange range) const { |
|---|
| 1104 | static char result[PROBE_MATCH_TARGET_STRING_LENGTH+1]; // see create_probe_match_window() for length |
|---|
| 1105 | int max_insert = PROBE_MATCH_TARGET_STRING_LENGTH; |
|---|
| 1106 | char *r = result; |
|---|
| 1107 | int significance = int(get_threshold()); |
|---|
| 1108 | ED4_sequence_terminal *seq_term = corresponding_sequence_terminal(); |
|---|
| 1109 | char *seq = seq_term->resolve_pointer_to_string_copy(); |
|---|
| 1110 | |
|---|
| 1111 | for (int pos=range.start(); pos<=range.end(); pos++) { |
|---|
| 1112 | int found = find_significant_positions(significance, likelihood[0][pos], likelihood[1][pos], likelihood[2][pos], likelihood[3][pos], 0); |
|---|
| 1113 | |
|---|
| 1114 | if (found || strchr("-=.", seq[pos])==0) { |
|---|
| 1115 | // '?' is inserted at every base position without significant bases (not at gaps!) |
|---|
| 1116 | |
|---|
| 1117 | *r++ = "NACMGRSVUWYHKDBN"[found]; // this creates a string containing the full IUPAC code |
|---|
| 1118 | |
|---|
| 1119 | if (max_insert--==0) { |
|---|
| 1120 | r--; |
|---|
| 1121 | break; |
|---|
| 1122 | } |
|---|
| 1123 | } |
|---|
| 1124 | } |
|---|
| 1125 | r[0] = 0; |
|---|
| 1126 | free(seq); |
|---|
| 1127 | |
|---|
| 1128 | if (max_insert<0) { |
|---|
| 1129 | aw_message(GBS_global_string("Max. %i bases allowed in Probe Match", PROBE_MATCH_TARGET_STRING_LENGTH)); |
|---|
| 1130 | result[0] = 0; |
|---|
| 1131 | } |
|---|
| 1132 | return result; |
|---|
| 1133 | } |
|---|
| 1134 | #undef PROBE_MATCH_TARGET_STRING_LENGTH |
|---|
| 1135 | |
|---|
| 1136 | ED4_returncode ED4_columnStat_terminal::draw() { |
|---|
| 1137 | if (!update_likelihood()) { |
|---|
| 1138 | aw_message("Can't calculate likelihood."); |
|---|
| 1139 | return ED4_R_IMPOSSIBLE; |
|---|
| 1140 | } |
|---|
| 1141 | |
|---|
| 1142 | AW_pos x, y; |
|---|
| 1143 | calc_world_coords(&x, &y); |
|---|
| 1144 | current_ed4w()->world_to_win_coords(&x, &y); |
|---|
| 1145 | |
|---|
| 1146 | AW_pos term_height = extension.size[HEIGHT]; |
|---|
| 1147 | AW_pos font_height = ED4_ROOT->font_group.get_height(ED4_G_SEQUENCES); |
|---|
| 1148 | AW_pos font_width = ED4_ROOT->font_group.get_width(ED4_G_SEQUENCES); |
|---|
| 1149 | |
|---|
| 1150 | AW_pos text_x = x + CHARACTEROFFSET; |
|---|
| 1151 | AW_pos text_y = y + term_height - font_height; |
|---|
| 1152 | |
|---|
| 1153 | AW_device *device = current_device(); |
|---|
| 1154 | ED4_sequence_terminal *seq_term = corresponding_sequence_terminal(); |
|---|
| 1155 | const ED4_remap *rm = ED4_ROOT->root_group_man->remap(); |
|---|
| 1156 | |
|---|
| 1157 | PosRange index_range = rm->clip_screen_range(seq_term->calc_update_interval()); |
|---|
| 1158 | { |
|---|
| 1159 | int max_seq_len = seq_term->get_length(); |
|---|
| 1160 | int max_seq_pos = rm->sequence_to_screen(max_seq_len); |
|---|
| 1161 | |
|---|
| 1162 | index_range = ExplicitRange(index_range, max_seq_pos); |
|---|
| 1163 | if (index_range.is_empty()) return ED4_R_OK; |
|---|
| 1164 | } |
|---|
| 1165 | |
|---|
| 1166 | const int left = index_range.start(); |
|---|
| 1167 | const int right = index_range.end(); |
|---|
| 1168 | |
|---|
| 1169 | char *sbuffer = new char[right+2]; // used to build displayed terminal content (values = '0'-'9') |
|---|
| 1170 | memset(sbuffer, ' ', right+1); |
|---|
| 1171 | sbuffer[right+1] = 0; // eos |
|---|
| 1172 | |
|---|
| 1173 | AW_pos y2; |
|---|
| 1174 | int r; |
|---|
| 1175 | |
|---|
| 1176 | // Set background: |
|---|
| 1177 | { |
|---|
| 1178 | int significance = int(get_threshold()); |
|---|
| 1179 | // normal columns are colored in ED4_G_STANDARD |
|---|
| 1180 | // all columns with one (or sum of two) probability above 'significance' are back-colored in ED4_G_CBACK_0 |
|---|
| 1181 | // the responsible probabilities (one or two) are back-colored in ED4_G_CBACK_1..ED4_G_CBACK_9 |
|---|
| 1182 | |
|---|
| 1183 | int old_color = ED4_G_STANDARD; |
|---|
| 1184 | |
|---|
| 1185 | AW_pos x2 = text_x + font_width*left + 1; |
|---|
| 1186 | AW_pos old_x2 = x2; |
|---|
| 1187 | |
|---|
| 1188 | PosRange selection; |
|---|
| 1189 | bool is_selected = ED4_get_selected_range(seq_term, selection); |
|---|
| 1190 | |
|---|
| 1191 | for (int i=left; i<=right; i++, x2+=font_width) { // colorize significant columns in ALL rows |
|---|
| 1192 | int p = rm->screen_to_sequence(i); |
|---|
| 1193 | int found = find_significant_positions(significance, likelihood[0][p], likelihood[1][p], likelihood[2][p], likelihood[3][p], 0); |
|---|
| 1194 | |
|---|
| 1195 | int color; |
|---|
| 1196 | if (is_selected && selection.contains(p)) { |
|---|
| 1197 | color = ED4_G_SELECTED; |
|---|
| 1198 | } |
|---|
| 1199 | else { |
|---|
| 1200 | color = found ? ED4_G_CBACK_0 : ED4_G_STANDARD; |
|---|
| 1201 | } |
|---|
| 1202 | |
|---|
| 1203 | if (color!=old_color) { |
|---|
| 1204 | if (x2>old_x2 && old_color!=ED4_G_STANDARD) { |
|---|
| 1205 | device->box(old_color, true, old_x2, y, x2-old_x2, term_height); |
|---|
| 1206 | } |
|---|
| 1207 | old_color = color; |
|---|
| 1208 | old_x2 = x2; |
|---|
| 1209 | } |
|---|
| 1210 | } |
|---|
| 1211 | if (x2>old_x2 && old_color!=ED4_G_STANDARD) { |
|---|
| 1212 | device->box(old_color, true, old_x2, y, x2-old_x2, term_height); |
|---|
| 1213 | } |
|---|
| 1214 | |
|---|
| 1215 | x2 = text_x + font_width*left + 1; |
|---|
| 1216 | |
|---|
| 1217 | for (int i=left; i<=right; i++, x2+=font_width) { // colorize significant columns in SINGLE rows |
|---|
| 1218 | int p = rm->screen_to_sequence(i); |
|---|
| 1219 | int sum; |
|---|
| 1220 | int found = find_significant_positions(significance, likelihood[0][p], likelihood[1][p], likelihood[2][p], likelihood[3][p], &sum); |
|---|
| 1221 | |
|---|
| 1222 | if (found && significance<100) { |
|---|
| 1223 | e4_assert(sum>=significance && sum<=100); |
|---|
| 1224 | int color = ED4_G_CBACK_1+((sum-significance)*(ED4_G_CBACK_9-ED4_G_CBACK_1))/(100-significance); |
|---|
| 1225 | e4_assert(color>=ED4_G_CBACK_1 && color<=ED4_G_CBACK_9); |
|---|
| 1226 | |
|---|
| 1227 | if (color!=ED4_G_STANDARD) { |
|---|
| 1228 | int bit; |
|---|
| 1229 | |
|---|
| 1230 | for (r=3, y2=text_y+1, bit=1<<3; |
|---|
| 1231 | r>=0; |
|---|
| 1232 | r--, y2-=COLUMN_STAT_ROW_HEIGHT(font_height), bit>>=1) |
|---|
| 1233 | { |
|---|
| 1234 | if (found&bit) { |
|---|
| 1235 | device->box(color, true, x2, y2-2*font_height+1, font_width, 2*font_height); |
|---|
| 1236 | } |
|---|
| 1237 | } |
|---|
| 1238 | } |
|---|
| 1239 | } |
|---|
| 1240 | } |
|---|
| 1241 | } |
|---|
| 1242 | |
|---|
| 1243 | // Draw text: |
|---|
| 1244 | for (r=3, y2=text_y; |
|---|
| 1245 | r>=0; |
|---|
| 1246 | r--, y2-=COLUMN_STAT_ROW_HEIGHT(font_height)) { // 4 rows (one for T/U, G, C and A) |
|---|
| 1247 | |
|---|
| 1248 | int gc = ED4_ROOT->sequence_colors->char_2_gc[(unsigned char)"ACGU"[r]]; |
|---|
| 1249 | int i; |
|---|
| 1250 | for (i=left; i<=right; i++) { |
|---|
| 1251 | int p = rm->screen_to_sequence(i); |
|---|
| 1252 | int val = likelihood[r][p]; |
|---|
| 1253 | sbuffer[i] = stat2display(val, 0); // calc lower digit |
|---|
| 1254 | } |
|---|
| 1255 | device->text(gc, sbuffer, text_x+font_width*0.2, y2, 0, AW_SCREEN, right); // draw lower-significant digit (shifted a bit to the right) |
|---|
| 1256 | |
|---|
| 1257 | for (i=left; i<=right; i++) { |
|---|
| 1258 | int p = rm->screen_to_sequence(i); |
|---|
| 1259 | int val = likelihood[r][p]; |
|---|
| 1260 | sbuffer[i] = stat2display(val, 1); // calc upper digit |
|---|
| 1261 | } |
|---|
| 1262 | device->text(gc, sbuffer, text_x, y2-font_height, 0, AW_SCREEN, right); // draw higher-significant digit |
|---|
| 1263 | } |
|---|
| 1264 | |
|---|
| 1265 | delete [] sbuffer; |
|---|
| 1266 | return ED4_R_OK; |
|---|
| 1267 | } |
|---|
| 1268 | |
|---|
| 1269 | int ED4_columnStat_terminal::update_likelihood() { |
|---|
| 1270 | ED4_sequence_terminal *seq_term = corresponding_sequence_terminal(); |
|---|
| 1271 | |
|---|
| 1272 | return STAT_update_ml_likelihood(ED4_ROOT->st_ml, likelihood, latest_update, 0, seq_term->st_ml_node); |
|---|
| 1273 | } |
|---|
| 1274 | |
|---|
| 1275 | ED4_columnStat_terminal::ED4_columnStat_terminal(GB_CSTR temp_id, AW_pos x, AW_pos y, AW_pos width, AW_pos height, ED4_manager *temp_parent) : |
|---|
| 1276 | ED4_text_terminal(column_stat_terminal_spec, temp_id, x, y, width, height, temp_parent) |
|---|
| 1277 | { |
|---|
| 1278 | for (int i=0; i<4; i++) likelihood[i] = 0; |
|---|
| 1279 | latest_update = 0; |
|---|
| 1280 | } |
|---|
| 1281 | |
|---|
| 1282 | ED4_columnStat_terminal::~ED4_columnStat_terminal() |
|---|
| 1283 | { |
|---|
| 1284 | for (int i=0; i<4; i++) free(likelihood[i]); |
|---|
| 1285 | } |
|---|
| 1286 | |
|---|
| 1287 | // --------------------------------- |
|---|
| 1288 | // ED4_reference_terminals |
|---|
| 1289 | |
|---|
| 1290 | void ED4_reference_terminals::clear() |
|---|
| 1291 | { |
|---|
| 1292 | delete ref_sequence_info; |
|---|
| 1293 | delete ref_sequence; |
|---|
| 1294 | delete ref_column_stat; |
|---|
| 1295 | delete ref_column_stat_info; |
|---|
| 1296 | null(); |
|---|
| 1297 | } |
|---|
| 1298 | |
|---|
| 1299 | void ED4_reference_terminals::init(ED4_sequence_info_terminal *ref_sequence_info_, |
|---|
| 1300 | ED4_sequence_terminal *ref_sequence_, |
|---|
| 1301 | ED4_sequence_info_terminal *ref_column_stat_info_, |
|---|
| 1302 | ED4_columnStat_terminal *ref_column_stat_) |
|---|
| 1303 | { |
|---|
| 1304 | clear(); |
|---|
| 1305 | ref_sequence_info = ref_sequence_info_; |
|---|
| 1306 | ref_sequence = ref_sequence_; |
|---|
| 1307 | ref_column_stat_info = ref_column_stat_info_; |
|---|
| 1308 | ref_column_stat = ref_column_stat_; |
|---|
| 1309 | } |
|---|