| 1 | #include <stdio.h> |
|---|
| 2 | |
|---|
| 3 | #include <stdlib.h> |
|---|
| 4 | #include <string.h> |
|---|
| 5 | |
|---|
| 6 | #include <iostream.h> |
|---|
| 7 | #include <fstream.h> |
|---|
| 8 | |
|---|
| 9 | #include <arbdb.h> |
|---|
| 10 | #include <arbdbt.h> |
|---|
| 11 | |
|---|
| 12 | #include <aw_root.hxx> |
|---|
| 13 | #include <aw_device.hxx> |
|---|
| 14 | #include <aw_window.hxx> |
|---|
| 15 | #include <aw_preset.hxx> |
|---|
| 16 | #include <aw_awars.hxx> |
|---|
| 17 | #include <awt_canvas.hxx> |
|---|
| 18 | #include <awt.hxx> |
|---|
| 19 | #define _USE_AW_WINDOW |
|---|
| 20 | #include <BI_helix.hxx> |
|---|
| 21 | #include <sec_graphic.hxx> |
|---|
| 22 | #include "secedit.hxx" |
|---|
| 23 | |
|---|
| 24 | #if defined(FREESTANDING) |
|---|
| 25 | AW_HEADER_MAIN |
|---|
| 26 | #endif |
|---|
| 27 | |
|---|
| 28 | extern GBDATA *gb_main; |
|---|
| 29 | SEC_graphic *SEC_GRAPHIC = 0; |
|---|
| 30 | |
|---|
| 31 | void SEC_distance_between_strands_changed_cb(AW_root *awr, AW_CL cl_ntw) |
|---|
| 32 | { |
|---|
| 33 | SEC_root *root = SEC_GRAPHIC->sec_root; |
|---|
| 34 | double distance = awr->awar(AWAR_SECEDIT_DIST_BETW_STRANDS)->read_float(); |
|---|
| 35 | AWT_canvas *ntw = (AWT_canvas*)cl_ntw; |
|---|
| 36 | |
|---|
| 37 | root->set_distance_between_strands(distance); |
|---|
| 38 | root->update(0); |
|---|
| 39 | ntw->refresh(); |
|---|
| 40 | } |
|---|
| 41 | |
|---|
| 42 | void SEC_pair_def_changed_cb(AW_root */*awr*/, AW_CL cl_ntw) |
|---|
| 43 | { |
|---|
| 44 | SEC_root *root = SEC_GRAPHIC->sec_root; |
|---|
| 45 | AWT_canvas *ntw = (AWT_canvas*)cl_ntw; |
|---|
| 46 | |
|---|
| 47 | SEC_GRAPHIC->bond.update(SEC_GRAPHIC->aw_root); |
|---|
| 48 | root->update(0); |
|---|
| 49 | ntw->refresh(); |
|---|
| 50 | } |
|---|
| 51 | |
|---|
| 52 | |
|---|
| 53 | #if defined(FREESTANDING) |
|---|
| 54 | void SEC_quit_cb(AW_window *aww, AW_CL, AW_CL){ |
|---|
| 55 | AWUSE(aww); |
|---|
| 56 | GB_exit(gb_main); |
|---|
| 57 | exit(0); |
|---|
| 58 | } |
|---|
| 59 | #endif |
|---|
| 60 | |
|---|
| 61 | void SEC_template_changed_cb(GBDATA *gb_seq, AWT_canvas *ntw, GB_CB_TYPE type){ |
|---|
| 62 | SEC_root * sec_root = SEC_GRAPHIC->sec_root; |
|---|
| 63 | GB_transaction tscope(gb_main); |
|---|
| 64 | |
|---|
| 65 | delete sec_root->template_sequence; |
|---|
| 66 | sec_root->template_sequence = 0; |
|---|
| 67 | sec_root->template_length = -1; |
|---|
| 68 | |
|---|
| 69 | if (type == GB_CB_DELETE){ |
|---|
| 70 | sec_root->gb_template = 0; |
|---|
| 71 | }else{ |
|---|
| 72 | sec_root->template_sequence = GB_read_string(gb_seq); |
|---|
| 73 | sec_root->template_length = GB_read_string_count(gb_seq); |
|---|
| 74 | } |
|---|
| 75 | if (sec_root->helix){ |
|---|
| 76 | sec_root->update(); |
|---|
| 77 | ntw->recalc_size(); |
|---|
| 78 | ntw->refresh(); |
|---|
| 79 | } |
|---|
| 80 | } |
|---|
| 81 | |
|---|
| 82 | void SEC_sequence_changed_cb(GBDATA *gb_seq, AWT_canvas *ntw, GB_CB_TYPE type){ |
|---|
| 83 | SEC_root * sec_root = SEC_GRAPHIC->sec_root; |
|---|
| 84 | GB_transaction tscope(gb_main); |
|---|
| 85 | |
|---|
| 86 | delete sec_root->sequence; |
|---|
| 87 | sec_root->sequence = 0; |
|---|
| 88 | sec_root->sequence_length = -1; |
|---|
| 89 | |
|---|
| 90 | if (type == GB_CB_DELETE || !sec_root->gb_sequence){ |
|---|
| 91 | sec_root->gb_sequence = 0; |
|---|
| 92 | }else{ |
|---|
| 93 | sec_root->sequence = GB_read_string(gb_seq); |
|---|
| 94 | sec_root->sequence_length = GB_read_string_count(gb_seq); |
|---|
| 95 | } |
|---|
| 96 | if (sec_root->helix){ |
|---|
| 97 | sec_root->update(); |
|---|
| 98 | ntw->recalc_size(); |
|---|
| 99 | ntw->refresh(); |
|---|
| 100 | } |
|---|
| 101 | } |
|---|
| 102 | |
|---|
| 103 | static inline int isInView(AW_pos x, AW_pos y, const AW_rectangle &view) { |
|---|
| 104 | double xborder = view.b - view.t; |
|---|
| 105 | double yborder = view.r - view.l; |
|---|
| 106 | |
|---|
| 107 | xborder = xborder*0.1; |
|---|
| 108 | yborder = yborder*0.1; |
|---|
| 109 | |
|---|
| 110 | return x >= (view.l+xborder) && |
|---|
| 111 | y >= (view.t+yborder) && |
|---|
| 112 | x <= (view.r-xborder) && |
|---|
| 113 | y <= (view.b-yborder); |
|---|
| 114 | } |
|---|
| 115 | |
|---|
| 116 | void SEC_cursor_position_changed_cb(AW_root *awr, AWT_canvas *ntw) { |
|---|
| 117 | SEC_root * sec_root = SEC_GRAPHIC->sec_root; |
|---|
| 118 | GB_transaction tscope(gb_main); |
|---|
| 119 | int seq_pos = awr->awar_int(AWAR_CURSOR_POSITION)->read_int()-1; // sequence position is starting with 1 |
|---|
| 120 | sec_root->set_cursor(seq_pos); |
|---|
| 121 | if (sec_root->helix) { |
|---|
| 122 | sec_root->update(); |
|---|
| 123 | ntw->recalc_size(); |
|---|
| 124 | ntw->refresh(); |
|---|
| 125 | |
|---|
| 126 | // check if cursor is in view |
|---|
| 127 | |
|---|
| 128 | AW_device *device = ntw->aww->get_device(AW_MIDDLE_AREA); |
|---|
| 129 | AW_rectangle screen; |
|---|
| 130 | device->get_area_size(&screen); |
|---|
| 131 | |
|---|
| 132 | AW_pos x1, y1, x2, y2; |
|---|
| 133 | sec_root->get_last_drawed_cursor_position(x1, y1, x2, y2); |
|---|
| 134 | |
|---|
| 135 | if (x1 || y1 || x2 || y2) { // valid position (calls at startup have no valid positions) |
|---|
| 136 | AW_pos X1, Y1, X2, Y2; |
|---|
| 137 | |
|---|
| 138 | device->transform(x1, y1, X1, Y1); |
|---|
| 139 | device->transform(x2, y2, X2, Y2); |
|---|
| 140 | |
|---|
| 141 | if (!isInView(X1, Y1, screen) || !isInView(X2, Y2, screen)) { // cursor is outside view |
|---|
| 142 | double curs_x = (X1+X2)/2; |
|---|
| 143 | double curs_y = (Y1+Y2)/2; |
|---|
| 144 | double offsetx = screen.l + (screen.l+screen.r)/2 - curs_x; |
|---|
| 145 | double offsety = screen.t + (screen.t+screen.b)/2 - curs_y; |
|---|
| 146 | |
|---|
| 147 | #if defined(DEBUG) && 1 |
|---|
| 148 | printf("Auto-Scroll: offsetx = %f / offsety = %f\n", offsetx, offsety); |
|---|
| 149 | #endif |
|---|
| 150 | ntw->scroll(NULL, (int)(-offsetx), (int)(-offsety), AW_FALSE); |
|---|
| 151 | ntw->refresh(); |
|---|
| 152 | } |
|---|
| 153 | } |
|---|
| 154 | } |
|---|
| 155 | } |
|---|
| 156 | |
|---|
| 157 | void SEC_center_cb(AW_window *aw, AWT_canvas *ntw, AW_CL) |
|---|
| 158 | { |
|---|
| 159 | ntw->recalc_size(); |
|---|
| 160 | ntw->refresh(); // do one refresh to calculate current cursor position |
|---|
| 161 | |
|---|
| 162 | AW_device *device = aw->get_device(AW_MIDDLE_AREA); |
|---|
| 163 | AW_rectangle screen; |
|---|
| 164 | device->get_area_size(&screen); |
|---|
| 165 | |
|---|
| 166 | AW_pos x1, y1, x2, y2; |
|---|
| 167 | SEC_root * sec_root = SEC_GRAPHIC->sec_root; |
|---|
| 168 | sec_root->get_last_drawed_cursor_position(x1, y1, x2, y2); |
|---|
| 169 | |
|---|
| 170 | if (x1 || y1 || x2 || y2) { // valid position (calls at startup have no valid positions) |
|---|
| 171 | AW_pos X1, Y1, X2, Y2; |
|---|
| 172 | |
|---|
| 173 | device->transform(x1, y1, X1, Y1); |
|---|
| 174 | device->transform(x2, y2, X2, Y2); |
|---|
| 175 | |
|---|
| 176 | double curs_x = (X1+X2)/2; |
|---|
| 177 | double curs_y = (Y1+Y2)/2; |
|---|
| 178 | double offsetx = screen.l + (screen.l+screen.r)/2 - curs_x; |
|---|
| 179 | double offsety = screen.t + (screen.t+screen.b)/2 - curs_y; |
|---|
| 180 | |
|---|
| 181 | ntw->scroll(NULL, (int)(-offsetx), (int)(-offsety), AW_FALSE); |
|---|
| 182 | ntw->refresh(); |
|---|
| 183 | } |
|---|
| 184 | } |
|---|
| 185 | |
|---|
| 186 | |
|---|
| 187 | void SEC_species_name_changed_cb(AW_root *awr, AWT_canvas *ntw){ |
|---|
| 188 | SEC_root * sec_root = SEC_GRAPHIC->sec_root; |
|---|
| 189 | GB_transaction tscope(gb_main); |
|---|
| 190 | if (sec_root->gb_sequence){ // remove old callback |
|---|
| 191 | GB_remove_callback(sec_root->gb_sequence,(GB_CB_TYPE)(GB_CB_DELETE | GB_CB_CHANGED),(GB_CB)SEC_sequence_changed_cb, (int *)ntw); |
|---|
| 192 | sec_root->gb_sequence = 0; |
|---|
| 193 | } |
|---|
| 194 | char *species_name = awr->awar_string(AWAR_SPECIES_NAME)->read_string(); |
|---|
| 195 | GBDATA *gb_species = GBT_find_species(gb_main,species_name); |
|---|
| 196 | if (gb_species){ |
|---|
| 197 | char *ali_name = GBT_get_default_alignment(gb_main); |
|---|
| 198 | sec_root->gb_sequence = GBT_read_sequence(gb_species, ali_name); |
|---|
| 199 | if (sec_root->gb_sequence){ |
|---|
| 200 | GB_add_callback(sec_root->gb_sequence,(GB_CB_TYPE)(GB_CB_DELETE | GB_CB_CHANGED),(GB_CB)SEC_sequence_changed_cb, (int *)ntw); |
|---|
| 201 | } |
|---|
| 202 | delete ali_name; |
|---|
| 203 | } |
|---|
| 204 | SEC_sequence_changed_cb( sec_root->gb_sequence, ntw, GB_CB_CHANGED); |
|---|
| 205 | |
|---|
| 206 | delete species_name; |
|---|
| 207 | } |
|---|
| 208 | |
|---|
| 209 | void SEC_root::init_sequences(AW_root *awr, AWT_canvas *ntw){ |
|---|
| 210 | GB_transaction tscope(gb_main); |
|---|
| 211 | |
|---|
| 212 | |
|---|
| 213 | GBDATA *gb_species = GBT_find_SAI(gb_main,"ECOLI"); |
|---|
| 214 | if (gb_species){ |
|---|
| 215 | char *ali_name = GBT_get_default_alignment(gb_main); |
|---|
| 216 | gb_template = GBT_read_sequence(gb_species, ali_name); |
|---|
| 217 | if (gb_template){ |
|---|
| 218 | GB_add_callback(gb_template,(GB_CB_TYPE)(GB_CB_DELETE | GB_CB_CHANGED),(GB_CB)SEC_template_changed_cb, (int *)ntw); |
|---|
| 219 | } |
|---|
| 220 | delete ali_name; |
|---|
| 221 | }else{ |
|---|
| 222 | aw_message("ECOLI SAI not found"); |
|---|
| 223 | } |
|---|
| 224 | |
|---|
| 225 | SEC_template_changed_cb( gb_template,ntw, GB_CB_CHANGED); |
|---|
| 226 | |
|---|
| 227 | awr->awar_string(AWAR_SPECIES_NAME,"",gb_main)->add_callback((AW_RCB1)SEC_species_name_changed_cb, (AW_CL)ntw);; |
|---|
| 228 | SEC_species_name_changed_cb(awr,ntw); |
|---|
| 229 | |
|---|
| 230 | awr->awar_string(AWAR_CURSOR_POSITION,"",gb_main)->add_callback((AW_RCB1)SEC_cursor_position_changed_cb, (AW_CL)ntw);; |
|---|
| 231 | SEC_cursor_position_changed_cb(awr, ntw); |
|---|
| 232 | |
|---|
| 233 | helix = new BI_helix(awr); |
|---|
| 234 | GB_ERROR error = helix->init(gb_main); |
|---|
| 235 | if (error){ |
|---|
| 236 | aw_message(error); |
|---|
| 237 | } |
|---|
| 238 | |
|---|
| 239 | ecoli = new BI_ecoli_ref(); |
|---|
| 240 | ecoli->init(gb_main); |
|---|
| 241 | |
|---|
| 242 | /****************************************************************************** |
|---|
| 243 | * Initialize the two strings that protocoll if a valid base-position was found |
|---|
| 244 | ******************************************************************************/ |
|---|
| 245 | //if (number_found == NULL) { |
|---|
| 246 | //number_found = new int[template_length]; |
|---|
| 247 | //} |
|---|
| 248 | //if (found_abs_pos == NULL) { |
|---|
| 249 | // found_abs_pos = new char[template_length]; |
|---|
| 250 | // } |
|---|
| 251 | |
|---|
| 252 | SEC_root * sec_root = SEC_GRAPHIC->sec_root; |
|---|
| 253 | sec_root->update(0); |
|---|
| 254 | } |
|---|
| 255 | |
|---|
| 256 | void sec_mode_event( AW_window *aws, AWT_canvas *ntw, AWT_COMMAND_MODE mode) |
|---|
| 257 | { |
|---|
| 258 | SEC_root *sec_root = SEC_GRAPHIC->sec_root; |
|---|
| 259 | AWUSE(aws); |
|---|
| 260 | const char *text = 0; |
|---|
| 261 | // static int story = 0; |
|---|
| 262 | |
|---|
| 263 | switch(mode){ |
|---|
| 264 | case AWT_MODE_ZOOM: { |
|---|
| 265 | text="ZOOM MODE LEFT: drag to zoom RIGHT: zoom out"; |
|---|
| 266 | sec_root->show_constraints = 0; |
|---|
| 267 | break; |
|---|
| 268 | } |
|---|
| 269 | case AWT_MODE_MOVE: { |
|---|
| 270 | text="HELIX MODE LEFT: build helix RIGHT: remove helix"; |
|---|
| 271 | sec_root->show_constraints = 0; |
|---|
| 272 | break; |
|---|
| 273 | } |
|---|
| 274 | case AWT_MODE_SETROOT: { |
|---|
| 275 | text="SET ROOT MODE LEFT: Set logical center of secondary structure"; |
|---|
| 276 | sec_root->show_constraints = 0; |
|---|
| 277 | break; |
|---|
| 278 | } |
|---|
| 279 | case AWT_MODE_ROT: { |
|---|
| 280 | text="ROTATE MODE LEFT: Rotate SUBhelix RIGHT: rotate strand"; |
|---|
| 281 | sec_root->show_constraints = 0; |
|---|
| 282 | break; |
|---|
| 283 | } |
|---|
| 284 | case AWT_MODE_MOD: { |
|---|
| 285 | text="CONSTRAINT MODE LEFT: modify constraint"; |
|---|
| 286 | sec_root->show_constraints = 1; |
|---|
| 287 | break; |
|---|
| 288 | } |
|---|
| 289 | case AWT_MODE_LINE: { |
|---|
| 290 | text="SET CURSOR MODE LEFT: Set Cursor in ARB_EDIT4"; |
|---|
| 291 | sec_root->show_constraints = 0; |
|---|
| 292 | break; |
|---|
| 293 | } |
|---|
| 294 | default: { |
|---|
| 295 | sec_assert(0); |
|---|
| 296 | break; |
|---|
| 297 | } |
|---|
| 298 | } |
|---|
| 299 | aws->get_root()->awar("tmp/LeftFooter")->write_string( text); |
|---|
| 300 | ntw->set_mode(mode); |
|---|
| 301 | ntw->refresh(); |
|---|
| 302 | } |
|---|
| 303 | |
|---|
| 304 | void SEC_undo_cb(AW_window *aw, AWT_canvas *ntw, AW_CL undo_type) |
|---|
| 305 | { |
|---|
| 306 | AWUSE(aw); |
|---|
| 307 | GB_ERROR error = GB_undo(gb_main,(GB_UNDO_TYPE)undo_type); |
|---|
| 308 | if (error) { |
|---|
| 309 | aw_message(error); |
|---|
| 310 | } |
|---|
| 311 | else{ |
|---|
| 312 | GB_begin_transaction(gb_main); |
|---|
| 313 | GB_commit_transaction(gb_main); |
|---|
| 314 | ntw->refresh(); |
|---|
| 315 | } |
|---|
| 316 | } |
|---|
| 317 | |
|---|
| 318 | #define MAXLINESIZE 500 |
|---|
| 319 | #define ASS "ARB secondary structure v1" |
|---|
| 320 | #define ASS_START "["ASS"]\n" |
|---|
| 321 | #define ASS_EOS "[end of structure]\n" |
|---|
| 322 | #define ASS_EOF "[end of "ASS"]\n" |
|---|
| 323 | |
|---|
| 324 | #if 0 |
|---|
| 325 | static GB_ERROR read_helix_info(char **helix, int *helix_length, char **helix_nr, int *helix_nr_length) |
|---|
| 326 | { |
|---|
| 327 | GB_transaction transAction(gb_main); |
|---|
| 328 | GB_ERROR err = 0; |
|---|
| 329 | |
|---|
| 330 | char *helix_name = GBT_get_default_helix(gb_main); |
|---|
| 331 | char *helix_nr_name = GBT_get_default_helix_nr(gb_main); |
|---|
| 332 | char *alignment_name = GBT_get_default_alignment(gb_main); |
|---|
| 333 | |
|---|
| 334 | GBDATA *gb_extended_data = GB_search(gb_main,"extended_data",GB_CREATE_CONTAINER); |
|---|
| 335 | long size2 = GBT_get_alignment_len(gb_main,alignment_name); |
|---|
| 336 | if (size2<=0) err = (char *)GB_get_error(); |
|---|
| 337 | if (!err) { |
|---|
| 338 | GBDATA *gb_helix_nr_con = GBT_find_SAI_rel_exdata(gb_extended_data, helix_nr_name); |
|---|
| 339 | GBDATA *gb_helix_con = GBT_find_SAI_rel_exdata(gb_extended_data, helix_name); |
|---|
| 340 | GBDATA *gb_helix = 0; |
|---|
| 341 | GBDATA *gb_helix_nr = 0; |
|---|
| 342 | |
|---|
| 343 | if (gb_helix_nr_con) gb_helix_nr = GBT_read_sequence(gb_helix_nr_con,alignment_name); |
|---|
| 344 | if (gb_helix_con) gb_helix = GBT_read_sequence(gb_helix_con,alignment_name); |
|---|
| 345 | |
|---|
| 346 | *helix = 0; |
|---|
| 347 | *helix_nr = 0; |
|---|
| 348 | |
|---|
| 349 | if (!gb_helix) { |
|---|
| 350 | err = "Cannot find the helix"; |
|---|
| 351 | } |
|---|
| 352 | else if (gb_helix_nr) { |
|---|
| 353 | *helix_nr = GB_read_string(gb_helix_nr); |
|---|
| 354 | *helix_nr_length = GB_read_string_count(gb_helix_nr); |
|---|
| 355 | } |
|---|
| 356 | |
|---|
| 357 | if (!err) { |
|---|
| 358 | *helix = GB_read_string(gb_helix); |
|---|
| 359 | *helix_length = GB_read_string_count(gb_helix); |
|---|
| 360 | } |
|---|
| 361 | } |
|---|
| 362 | |
|---|
| 363 | free(alignment_name); |
|---|
| 364 | free(helix_nr_name); |
|---|
| 365 | free(helix_name); |
|---|
| 366 | |
|---|
| 367 | return err; |
|---|
| 368 | } |
|---|
| 369 | #endif |
|---|
| 370 | |
|---|
| 371 | static char *encode_xstring_rel_helix(GB_CSTR x_string, int xlength, BI_helix *helix, int *no_of_helices_ptr) |
|---|
| 372 | { |
|---|
| 373 | int allocated = 100; |
|---|
| 374 | int no_of_helices = 0; |
|---|
| 375 | char *rel_helix = (char*)malloc(sizeof(*rel_helix)*allocated); |
|---|
| 376 | int pos; |
|---|
| 377 | int start_helix = -1; |
|---|
| 378 | char *start_helix_nr = 0; |
|---|
| 379 | int end_helix = -1; |
|---|
| 380 | |
|---|
| 381 | for (pos=0; ; pos++) { |
|---|
| 382 | BI_helix::BI_helix_entry *entry = &(helix->entries[pos]); |
|---|
| 383 | //char *helix_nr = 0; |
|---|
| 384 | |
|---|
| 385 | if (entry->pair_type!=HELIX_NONE) { |
|---|
| 386 | char *helix_nr = entry->helix_nr; |
|---|
| 387 | |
|---|
| 388 | if (helix_nr==start_helix_nr) { // same helix_nr as last |
|---|
| 389 | end_helix = pos; |
|---|
| 390 | } |
|---|
| 391 | else { // new helix_nr |
|---|
| 392 | if (start_helix_nr) { // not first helix -> store state of last helix |
|---|
| 393 | insert_helix: |
|---|
| 394 | helix_nr = entry->helix_nr; // re-init (needed in case of goto insert_helix) |
|---|
| 395 | int is_used_in_secondary_structure = !!(x_string[start_helix]=='x' && x_string[end_helix+1]=='x'); |
|---|
| 396 | |
|---|
| 397 | #if defined(DEBUG) && 0 |
|---|
| 398 | printf("Helix #%s von %i bis %i (used=%i)\n", start_helix_nr, start_helix, end_helix, is_used_in_secondary_structure); |
|---|
| 399 | #endif |
|---|
| 400 | |
|---|
| 401 | if (no_of_helices==allocated) { |
|---|
| 402 | allocated += 100; |
|---|
| 403 | rel_helix = (char*)realloc(rel_helix, sizeof(*rel_helix)*allocated); |
|---|
| 404 | } |
|---|
| 405 | rel_helix[no_of_helices++] = '0'+is_used_in_secondary_structure; |
|---|
| 406 | rel_helix[no_of_helices] = 0; |
|---|
| 407 | if (pos==(xlength-1)) { |
|---|
| 408 | break; |
|---|
| 409 | } |
|---|
| 410 | } |
|---|
| 411 | start_helix = pos; |
|---|
| 412 | end_helix = pos; |
|---|
| 413 | start_helix_nr = helix_nr; |
|---|
| 414 | } |
|---|
| 415 | } |
|---|
| 416 | |
|---|
| 417 | if (pos==(xlength-1)) { // last position? |
|---|
| 418 | if (start_helix_nr) { |
|---|
| 419 | goto insert_helix; |
|---|
| 420 | } |
|---|
| 421 | } |
|---|
| 422 | } |
|---|
| 423 | |
|---|
| 424 | *no_of_helices_ptr = no_of_helices; |
|---|
| 425 | return rel_helix; |
|---|
| 426 | } |
|---|
| 427 | |
|---|
| 428 | static void decode_xstring_rel_helix(GB_CSTR rel_helix, char *x_buffer, int xlength, BI_helix *helix, int *no_of_helices_ptr) |
|---|
| 429 | { |
|---|
| 430 | int no_of_helices = 0; |
|---|
| 431 | int pos; |
|---|
| 432 | int start_helix = 0; |
|---|
| 433 | int end_helix = -1; |
|---|
| 434 | char *start_helix_nr = 0; |
|---|
| 435 | int rel_pos = 0; |
|---|
| 436 | |
|---|
| 437 | for (pos=0; ; pos++) { |
|---|
| 438 | BI_helix::BI_helix_entry *entry = &(helix->entries[pos]); |
|---|
| 439 | //char *helix_nr; |
|---|
| 440 | |
|---|
| 441 | if (entry->pair_type!=HELIX_NONE) { |
|---|
| 442 | char *helix_nr = entry->helix_nr; |
|---|
| 443 | |
|---|
| 444 | if (helix_nr==start_helix_nr) { // same helix as last |
|---|
| 445 | end_helix = pos; |
|---|
| 446 | } |
|---|
| 447 | else { // new helix nr |
|---|
| 448 | if (start_helix_nr) { // not first helix -> write last to xstring |
|---|
| 449 | insert_helix: |
|---|
| 450 | helix_nr = entry->helix_nr; // re-init (needed in case of goto insert_helix) |
|---|
| 451 | char flag = rel_helix[rel_pos++]; |
|---|
| 452 | |
|---|
| 453 | no_of_helices++; |
|---|
| 454 | if (flag=='1') { |
|---|
| 455 | sec_assert(end_helix!=-1); |
|---|
| 456 | x_buffer[start_helix] = 'x'; |
|---|
| 457 | x_buffer[end_helix+1] = 'x'; |
|---|
| 458 | } |
|---|
| 459 | else if (flag!='0') { |
|---|
| 460 | if (flag==0) break; // eos |
|---|
| 461 | sec_assert(0); // illegal character |
|---|
| 462 | break; |
|---|
| 463 | } |
|---|
| 464 | if (pos==(xlength-1)) { |
|---|
| 465 | break; |
|---|
| 466 | } |
|---|
| 467 | } |
|---|
| 468 | start_helix = pos; |
|---|
| 469 | end_helix = pos; |
|---|
| 470 | start_helix_nr = helix_nr; |
|---|
| 471 | } |
|---|
| 472 | } |
|---|
| 473 | if (pos==(xlength-1)) { |
|---|
| 474 | if (start_helix_nr) { |
|---|
| 475 | goto insert_helix; |
|---|
| 476 | } |
|---|
| 477 | } |
|---|
| 478 | } |
|---|
| 479 | |
|---|
| 480 | *no_of_helices_ptr = no_of_helices; |
|---|
| 481 | } |
|---|
| 482 | |
|---|
| 483 | static void export_structure_to_file(AW_window *, AW_CL /*cl_ntw*/) |
|---|
| 484 | { |
|---|
| 485 | // AWT_canvas *ntw = (AWT_canvas*)cl_ntw; |
|---|
| 486 | // SEC_graphic *sec_graphic = (SEC_graphic*)ntw->tree_disp; |
|---|
| 487 | AW_root *aw_root = SEC_GRAPHIC->aw_root; |
|---|
| 488 | char *filename = aw_root->awar(AWAR_SECEDIT_IMEXPORT_BASE"/file_name")->read_string(); |
|---|
| 489 | FILE *out = fopen(filename, "wt"); |
|---|
| 490 | GB_ERROR error = 0; |
|---|
| 491 | |
|---|
| 492 | if (out) { |
|---|
| 493 | SEC_root *sec_root = SEC_GRAPHIC->sec_root; |
|---|
| 494 | |
|---|
| 495 | fputs(ASS_START, out); |
|---|
| 496 | |
|---|
| 497 | char *strct = sec_root->write_data(); |
|---|
| 498 | fputs(strct, out); |
|---|
| 499 | free(strct); |
|---|
| 500 | |
|---|
| 501 | fputs(ASS_EOS, out); |
|---|
| 502 | |
|---|
| 503 | char *x_string = sec_root->x_string; |
|---|
| 504 | int no_of_helices; |
|---|
| 505 | int xlength = strlen(x_string); |
|---|
| 506 | char *xstring_rel_helix = encode_xstring_rel_helix(x_string, xlength, sec_root->helix, &no_of_helices); |
|---|
| 507 | |
|---|
| 508 | fprintf(out, "no of helices=%i\nlength of xstring=%i\nxstring_rel_helix=%s\n", no_of_helices, xlength, xstring_rel_helix); |
|---|
| 509 | free(xstring_rel_helix); |
|---|
| 510 | |
|---|
| 511 | fputs(ASS_EOF, out); |
|---|
| 512 | fclose(out); |
|---|
| 513 | } |
|---|
| 514 | else { |
|---|
| 515 | error = GB_export_error("Can't write secondary structure to '%s'", filename); |
|---|
| 516 | } |
|---|
| 517 | |
|---|
| 518 | if (error) { |
|---|
| 519 | aw_message(error, "Not ok"); |
|---|
| 520 | } |
|---|
| 521 | } |
|---|
| 522 | |
|---|
| 523 | static const char *scan_token(char *line, const char *token) |
|---|
| 524 | { |
|---|
| 525 | char *gleich = strchr(line, '='); |
|---|
| 526 | |
|---|
| 527 | if (gleich) { |
|---|
| 528 | gleich[0] = 0; |
|---|
| 529 | if (strcmp(line, token)==0) { |
|---|
| 530 | return gleich+1; |
|---|
| 531 | } |
|---|
| 532 | } |
|---|
| 533 | |
|---|
| 534 | return 0; |
|---|
| 535 | } |
|---|
| 536 | |
|---|
| 537 | static void import_structure_from_file(AW_window *, AW_CL cl_ntw) |
|---|
| 538 | { |
|---|
| 539 | AWT_canvas *ntw = (AWT_canvas*)cl_ntw; |
|---|
| 540 | // SEC_graphic *sec_graphic = (SEC_graphic*)ntw->tree_disp; |
|---|
| 541 | AW_root *aw_root = SEC_GRAPHIC->aw_root; |
|---|
| 542 | char *filename = aw_root->awar(AWAR_SECEDIT_IMEXPORT_BASE"/file_name")->read_string(); |
|---|
| 543 | FILE *in = fopen(filename, "rt"); |
|---|
| 544 | GB_ERROR error = 0; |
|---|
| 545 | |
|---|
| 546 | if (!in) { |
|---|
| 547 | error = GB_export_error("Can't open file '%s'", filename); |
|---|
| 548 | } |
|---|
| 549 | |
|---|
| 550 | if (!error) { |
|---|
| 551 | int salloc = 1000; |
|---|
| 552 | char *strct = new char[salloc]; |
|---|
| 553 | int slen = 0; |
|---|
| 554 | char *x_string = 0; |
|---|
| 555 | char line[MAXLINESIZE]; |
|---|
| 556 | SEC_root *sec_root = SEC_GRAPHIC->sec_root; |
|---|
| 557 | |
|---|
| 558 | fgets(line, MAXLINESIZE, in); |
|---|
| 559 | int llen = strlen(line); |
|---|
| 560 | if (llen>=MAXLINESIZE) { |
|---|
| 561 | long_line: |
|---|
| 562 | error = GB_export_error("File '%s' contains line longer than %i chars -- import aborted", filename, llen); |
|---|
| 563 | } |
|---|
| 564 | |
|---|
| 565 | if (!error) { |
|---|
| 566 | if (strcmp(line, ASS_START)!=0) { |
|---|
| 567 | wrong_format: |
|---|
| 568 | error = GB_export_error("File '%s' is not a ARB secondary structure file", filename); |
|---|
| 569 | } |
|---|
| 570 | else { |
|---|
| 571 | while (1) { |
|---|
| 572 | fgets(line, MAXLINESIZE, in); |
|---|
| 573 | llen = strlen(line); |
|---|
| 574 | if (llen>=MAXLINESIZE) goto long_line; |
|---|
| 575 | |
|---|
| 576 | if (strcmp(line, ASS_EOS)==0) { // end of structure |
|---|
| 577 | break; |
|---|
| 578 | } |
|---|
| 579 | |
|---|
| 580 | if ((slen+llen+1)>salloc) { |
|---|
| 581 | salloc += 1000; |
|---|
| 582 | char *new_strct = new char[salloc]; |
|---|
| 583 | memcpy(new_strct, strct, slen); |
|---|
| 584 | delete strct; |
|---|
| 585 | strct = new_strct; |
|---|
| 586 | } |
|---|
| 587 | |
|---|
| 588 | strcpy(strct+slen, line); |
|---|
| 589 | slen += llen; |
|---|
| 590 | } |
|---|
| 591 | |
|---|
| 592 | fgets(line, MAXLINESIZE, in); |
|---|
| 593 | llen = strlen(line); |
|---|
| 594 | if (llen>=MAXLINESIZE) goto long_line; |
|---|
| 595 | const char *rest = scan_token(line, "no of helices"); |
|---|
| 596 | if (!rest) goto wrong_format; |
|---|
| 597 | int no_of_helices = atoi(rest); |
|---|
| 598 | |
|---|
| 599 | fgets(line, MAXLINESIZE, in); |
|---|
| 600 | llen = strlen(line); |
|---|
| 601 | if (llen>=MAXLINESIZE) goto long_line; |
|---|
| 602 | rest = scan_token(line, "length of xstring"); |
|---|
| 603 | if (!rest) goto wrong_format; |
|---|
| 604 | int xlength = atoi(rest); |
|---|
| 605 | |
|---|
| 606 | fgets(line, MAXLINESIZE, in); |
|---|
| 607 | llen = strlen(line); |
|---|
| 608 | if (llen>=MAXLINESIZE) goto long_line; |
|---|
| 609 | |
|---|
| 610 | char *rel_helix = 0; |
|---|
| 611 | { |
|---|
| 612 | const char *crel_helix = scan_token(line, "xstring_rel_helix"); |
|---|
| 613 | if (!crel_helix) goto wrong_format; |
|---|
| 614 | rel_helix = strdup(crel_helix); |
|---|
| 615 | int rh_len = strlen(rel_helix); |
|---|
| 616 | rel_helix[rh_len-1] = 0; // delete \n at eol |
|---|
| 617 | } |
|---|
| 618 | |
|---|
| 619 | x_string = new char[xlength+1]; |
|---|
| 620 | memset(x_string, '.', xlength); |
|---|
| 621 | x_string[xlength] = 0; |
|---|
| 622 | |
|---|
| 623 | #if defined(DEBUG) && 0 |
|---|
| 624 | printf("x_string='%s'\n", x_string); |
|---|
| 625 | #endif |
|---|
| 626 | |
|---|
| 627 | fgets(line, MAXLINESIZE, in); |
|---|
| 628 | llen = strlen(line); |
|---|
| 629 | if (llen>=MAXLINESIZE) goto long_line; |
|---|
| 630 | if (strcmp(line, ASS_EOF)!=0) goto wrong_format; |
|---|
| 631 | |
|---|
| 632 | int current_no_of_helices; |
|---|
| 633 | decode_xstring_rel_helix(rel_helix, x_string, xlength, sec_root->helix,¤t_no_of_helices); |
|---|
| 634 | free(rel_helix); |
|---|
| 635 | #if defined(DEBUG) && 0 |
|---|
| 636 | printf("x_string='%s'\n", x_string); |
|---|
| 637 | #endif |
|---|
| 638 | if (current_no_of_helices!=no_of_helices) { |
|---|
| 639 | error = GB_export_error("You can't import a secondary structure if you changed the # of helices"); |
|---|
| 640 | } |
|---|
| 641 | } |
|---|
| 642 | } |
|---|
| 643 | |
|---|
| 644 | if (!error) { |
|---|
| 645 | SEC_GRAPHIC->write_data_to_db(strct, x_string); |
|---|
| 646 | ntw->refresh(); |
|---|
| 647 | } |
|---|
| 648 | |
|---|
| 649 | delete strct; |
|---|
| 650 | delete x_string; |
|---|
| 651 | } |
|---|
| 652 | |
|---|
| 653 | if (in) { |
|---|
| 654 | fclose(in); |
|---|
| 655 | } |
|---|
| 656 | |
|---|
| 657 | if (error) { |
|---|
| 658 | aw_message(error, "Not ok"); |
|---|
| 659 | } |
|---|
| 660 | } |
|---|
| 661 | |
|---|
| 662 | |
|---|
| 663 | #undef MAXLINESIZE |
|---|
| 664 | #undef ASS |
|---|
| 665 | #undef ASS_START |
|---|
| 666 | #undef ASS_EOS |
|---|
| 667 | #undef ASS_EOF |
|---|
| 668 | |
|---|
| 669 | static AW_window *SEC_importExport(AW_root *root, int export_to_file, AWT_canvas *ntw) |
|---|
| 670 | { |
|---|
| 671 | AW_window_simple *aws = new AW_window_simple; |
|---|
| 672 | |
|---|
| 673 | if (export_to_file) aws->init(root, "export_secondary_structure", "Export secondary structure to ...", 100, 100); |
|---|
| 674 | else aws->init(root, "import_secondary_structure", "Import secondary structure from ...", 100, 100); |
|---|
| 675 | |
|---|
| 676 | aws->load_xfig("sec_imexport.fig"); |
|---|
| 677 | |
|---|
| 678 | aws->at("close"); |
|---|
| 679 | aws->callback((AW_CB0)AW_POPDOWN); |
|---|
| 680 | aws->create_button("CLOSE","CLOSE","C"); |
|---|
| 681 | |
|---|
| 682 | aws->at("help"); |
|---|
| 683 | aws->callback( AW_POPUP_HELP, (AW_CL)"sec_imexport.hlp"); |
|---|
| 684 | aws->create_button("HELP","HELP","H"); |
|---|
| 685 | |
|---|
| 686 | awt_create_selection_box((AW_window *)aws, AWAR_SECEDIT_IMEXPORT_BASE); |
|---|
| 687 | |
|---|
| 688 | aws->at("cancel"); |
|---|
| 689 | aws->callback( (AW_CB0)AW_POPDOWN); |
|---|
| 690 | aws->create_button("CANCEL","CANCEL","C"); |
|---|
| 691 | |
|---|
| 692 | aws->at("save"); |
|---|
| 693 | if (export_to_file) { |
|---|
| 694 | aws->callback(export_structure_to_file, (AW_CL)ntw); |
|---|
| 695 | aws->create_button("EXPORT","EXPORT","E"); |
|---|
| 696 | } |
|---|
| 697 | else { |
|---|
| 698 | aws->callback(import_structure_from_file, (AW_CL)ntw); |
|---|
| 699 | aws->create_button("IMPORT","IMPORT","I"); |
|---|
| 700 | } |
|---|
| 701 | |
|---|
| 702 | return aws; |
|---|
| 703 | } |
|---|
| 704 | |
|---|
| 705 | static AW_window *SEC_import(AW_root *root, AW_CL cl_ntw) { return SEC_importExport(root, 0, (AWT_canvas*)cl_ntw); } |
|---|
| 706 | static AW_window *SEC_export(AW_root *root, AW_CL cl_ntw) { return SEC_importExport(root, 1, (AWT_canvas*)cl_ntw); } |
|---|
| 707 | |
|---|
| 708 | static void SEC_new_structure(AW_window *, AW_CL cl_ntw, AW_CL) { |
|---|
| 709 | GB_transaction dummy(gb_main); |
|---|
| 710 | |
|---|
| 711 | if (aw_message("This will delete your current secondary structure!", "Abort,Continue")) { |
|---|
| 712 | AWT_canvas *ntw = (AWT_canvas*)cl_ntw; |
|---|
| 713 | // SEC_graphic *sec_graphic = (SEC_graphic *) ntw->tree_disp; |
|---|
| 714 | SEC_root *sec_root = SEC_GRAPHIC->sec_root; |
|---|
| 715 | char *ali_name = GBT_get_default_alignment(gb_main); |
|---|
| 716 | long ali_len = GBT_get_alignment_len(gb_main,ali_name); |
|---|
| 717 | |
|---|
| 718 | sec_root->create_default_bone(ali_len); |
|---|
| 719 | SEC_GRAPHIC->save(0, 0, 0, 0); |
|---|
| 720 | |
|---|
| 721 | ntw->recalc_size(); |
|---|
| 722 | ntw->refresh(); |
|---|
| 723 | } |
|---|
| 724 | } |
|---|
| 725 | |
|---|
| 726 | AW_window *SEC_create_layout_window(AW_root *awr) { |
|---|
| 727 | AW_window_simple *aws = new AW_window_simple; |
|---|
| 728 | |
|---|
| 729 | aws->init(awr, "SEC_LAYOUT", "SECEDIT Layout", 100, 100); |
|---|
| 730 | aws->load_xfig("sec_layout.fig"); |
|---|
| 731 | |
|---|
| 732 | aws->callback((AW_CB0)AW_POPDOWN); |
|---|
| 733 | aws->at("close"); |
|---|
| 734 | aws->create_button("CLOSE", "CLOSE", "C"); |
|---|
| 735 | |
|---|
| 736 | aws->callback( AW_POPUP_HELP,(AW_CL)"sec_layout.hlp"); |
|---|
| 737 | aws->at("help"); |
|---|
| 738 | aws->create_button("HELP","HELP","H"); |
|---|
| 739 | |
|---|
| 740 | aws->at("strand_dist"); |
|---|
| 741 | aws->label("Distance between strands:"); |
|---|
| 742 | aws->create_input_field(AWAR_SECEDIT_DIST_BETW_STRANDS); |
|---|
| 743 | |
|---|
| 744 | int x, dummy; |
|---|
| 745 | aws->at("chars"); |
|---|
| 746 | aws->get_at_position(&x, &dummy); |
|---|
| 747 | |
|---|
| 748 | #define PAIR_FIELDS(lower, upper) \ |
|---|
| 749 | aws->at(lower "_pair"); \ |
|---|
| 750 | aws->create_input_field(AWAR_SECEDIT_##upper##_PAIRS, 30); \ |
|---|
| 751 | aws->at_x(x); \ |
|---|
| 752 | aws->create_input_field(AWAR_SECEDIT_##upper##_PAIR_CHAR, 1) |
|---|
| 753 | |
|---|
| 754 | PAIR_FIELDS("strong", STRONG); |
|---|
| 755 | PAIR_FIELDS("normal", NORMAL); |
|---|
| 756 | PAIR_FIELDS("weak", WEAK); |
|---|
| 757 | PAIR_FIELDS("no", NO); |
|---|
| 758 | PAIR_FIELDS("user", USER); |
|---|
| 759 | |
|---|
| 760 | #undef PAIR_FIELDS |
|---|
| 761 | |
|---|
| 762 | return aws; |
|---|
| 763 | } |
|---|
| 764 | |
|---|
| 765 | AW_window *SEC_create_main_window(AW_root *awr){ |
|---|
| 766 | GB_transaction tscope(gb_main); |
|---|
| 767 | |
|---|
| 768 | AW_window_menu_modes *awm = new AW_window_menu_modes(); |
|---|
| 769 | awm->init(awr,"ARB_SECEDIT", "ARB_SECEDIT", 800,600,10,10); |
|---|
| 770 | |
|---|
| 771 | SEC_create_awars(awr, AW_ROOT_DEFAULT); |
|---|
| 772 | |
|---|
| 773 | AW_gc_manager aw_gc_manager; |
|---|
| 774 | SEC_GRAPHIC = new SEC_graphic(awr,gb_main); |
|---|
| 775 | AWT_canvas *ntw = new AWT_canvas(gb_main,awm, SEC_GRAPHIC, aw_gc_manager,AWAR_SPECIES_NAME); |
|---|
| 776 | |
|---|
| 777 | SEC_add_awar_callbacks(awr, AW_ROOT_DEFAULT, ntw); |
|---|
| 778 | |
|---|
| 779 | SEC_GRAPHIC->sec_root->init_sequences(awr,ntw); |
|---|
| 780 | GB_ERROR err = SEC_GRAPHIC->load(gb_main,0,0,0); |
|---|
| 781 | if (err) return 0; |
|---|
| 782 | |
|---|
| 783 | ntw->recalc_size(); |
|---|
| 784 | ntw->set_mode(AWT_MODE_ZOOM); // Default-Mode |
|---|
| 785 | |
|---|
| 786 | awm->create_menu( 0, "File", "F", "secedit_file.hlp", AWM_ALL ); |
|---|
| 787 | |
|---|
| 788 | awm->insert_menu_topic("secedit_new", "New Structure", "N", 0, AWM_ALL, (AW_CB)SEC_new_structure, (AW_CL)ntw, 0); |
|---|
| 789 | awm->insert_menu_topic("secedit_import", "Import Structure ...", "I", "secedit_imexport.hlp", AWM_ALL, AW_POPUP, (AW_CL)SEC_import, (AW_CL)ntw); |
|---|
| 790 | awm->insert_menu_topic("secedit_export", "Export Structure ...", "E", "secedit_imexport.hlp", AWM_ALL, AW_POPUP, (AW_CL)SEC_export, (AW_CL)ntw); |
|---|
| 791 | |
|---|
| 792 | awm->insert_menu_topic("print_secedit", "Print Structure ...", "P","secedit2prt.hlp", AWM_ALL, (AW_CB)AWT_create_print_window, (AW_CL)ntw, 0 ); |
|---|
| 793 | #if defined(FREESTANDING) |
|---|
| 794 | awm->insert_menu_topic( "quit", "Quit", "Q","quit.hlp", AWM_ALL, (AW_CB)SEC_quit_cb, 0,0); |
|---|
| 795 | #else |
|---|
| 796 | awm->insert_menu_topic( "close", "Close", "C","quit.hlp", AWM_ALL, (AW_CB)AW_POPDOWN, 1,0); |
|---|
| 797 | #endif |
|---|
| 798 | |
|---|
| 799 | awm->create_menu("props","Properties","r","properties.hlp", AWM_ALL); |
|---|
| 800 | awm->insert_menu_topic("props_menu", "Menu: Colors and Fonts ...", "M","props_frame.hlp", AWM_ALL, AW_POPUP, (AW_CL)AW_preset_window, 0 ); |
|---|
| 801 | awm->insert_menu_topic("props_secedit", "SECEDIT: Colors and Fonts ...","C","secedit_props_data.hlp",AWM_ALL, AW_POPUP, (AW_CL)AW_create_gc_window, (AW_CL)aw_gc_manager ); |
|---|
| 802 | awm->insert_menu_topic("sec_layout", "Layout", "L", "sec_layout.hlp", AWM_ALL, AW_POPUP, (AW_CL)SEC_create_layout_window, 0); |
|---|
| 803 | awm->insert_menu_topic("save_props", "Save Defaults (in ~/.arb_prop/secedit.arb)", "D","savedef.hlp", AWM_ALL, (AW_CB) AW_save_defaults, 0, 0 ); |
|---|
| 804 | |
|---|
| 805 | awm->create_mode( 0, "zoom.bitmap", "sec_mode.hlp", AWM_ALL, (AW_CB)sec_mode_event,(AW_CL)ntw,(AW_CL)AWT_MODE_ZOOM); |
|---|
| 806 | awm->create_mode( 0, "sec_modify.bitmap", "sec_mode.hlp", AWM_ALL, (AW_CB)sec_mode_event,(AW_CL)ntw,(AW_CL)AWT_MODE_MOVE); |
|---|
| 807 | awm->create_mode( 0, "setroot.bitmap", "sec_mode.hlp", AWM_ALL, (AW_CB)sec_mode_event,(AW_CL)ntw,(AW_CL)AWT_MODE_SETROOT); |
|---|
| 808 | awm->create_mode( 0, "rot.bitmap", "sec_mode.hlp", AWM_ALL, (AW_CB)sec_mode_event,(AW_CL)ntw,(AW_CL)AWT_MODE_ROT); |
|---|
| 809 | awm->create_mode( 0, "info.bitmap", "sec_mode.hlp", AWM_ALL, (AW_CB)sec_mode_event,(AW_CL)ntw,(AW_CL)AWT_MODE_MOD); |
|---|
| 810 | awm->create_mode( 0, "sec_setcurs.bitmap", "sec_mode.hlp", AWM_ALL, (AW_CB)sec_mode_event,(AW_CL)ntw,(AW_CL)AWT_MODE_LINE); |
|---|
| 811 | |
|---|
| 812 | awm->set_info_area_height( 250 ); |
|---|
| 813 | awm->at(5,2); |
|---|
| 814 | awm->auto_space(5,-2); |
|---|
| 815 | |
|---|
| 816 | int db_pathx,db_pathy; |
|---|
| 817 | awm->get_at_position( &db_pathx,&db_pathy ); |
|---|
| 818 | |
|---|
| 819 | awm->button_length(0); |
|---|
| 820 | awm->help_text("quit.hlp"); |
|---|
| 821 | #if defined(FREESTANDING) |
|---|
| 822 | awm->callback( SEC_quit_cb,0,0); |
|---|
| 823 | awm->create_button("Quit", "Quit"); |
|---|
| 824 | #else |
|---|
| 825 | awm->callback((AW_CB0)AW_POPDOWN); |
|---|
| 826 | awm->create_button("Close", "Close"); |
|---|
| 827 | #endif |
|---|
| 828 | |
|---|
| 829 | awm->callback(AW_POPUP_HELP,(AW_CL)"arb_secedit.hlp"); |
|---|
| 830 | awm->button_length(0); |
|---|
| 831 | awm->help_text("help.hlp"); |
|---|
| 832 | awm->create_button("HELP", "HELP","H"); |
|---|
| 833 | |
|---|
| 834 | awm->callback( AW_help_entry_pressed ); |
|---|
| 835 | awm->create_button(0,"?"); |
|---|
| 836 | |
|---|
| 837 | awm->callback((AW_CB)SEC_undo_cb,(AW_CL)ntw,(AW_CL)GB_UNDO_UNDO); |
|---|
| 838 | awm->help_text("undo.hlp"); |
|---|
| 839 | awm->create_button("Undo", "Undo"); |
|---|
| 840 | |
|---|
| 841 | awm->callback((AW_CB)SEC_undo_cb,(AW_CL)ntw,(AW_CL)GB_UNDO_REDO); |
|---|
| 842 | awm->help_text("undo.hlp"); |
|---|
| 843 | awm->create_button("Redo", "Redo"); |
|---|
| 844 | |
|---|
| 845 | awm->callback((AW_CB)SEC_center_cb,(AW_CL)ntw,(AW_CL)0); |
|---|
| 846 | awm->help_text("center.hlp"); |
|---|
| 847 | awm->create_button("Center", "Center"); |
|---|
| 848 | |
|---|
| 849 | awm->button_length(100); |
|---|
| 850 | awm->at_newline(); |
|---|
| 851 | awm->create_button(0,"tmp/LeftFooter"); |
|---|
| 852 | awm->at_newline(); |
|---|
| 853 | awm->get_at_position( &db_pathx,&db_pathy ); |
|---|
| 854 | awm->set_info_area_height( db_pathy+6 ); |
|---|
| 855 | |
|---|
| 856 | return awm; |
|---|
| 857 | } |
|---|
| 858 | |
|---|
| 859 | #if defined(FREESTANDING) |
|---|
| 860 | int |
|---|
| 861 | main(int argc, char **argv){ |
|---|
| 862 | AWUSE(argc); |
|---|
| 863 | AWUSE(argv); |
|---|
| 864 | |
|---|
| 865 | AW_root *aw_root; |
|---|
| 866 | AW_default aw_default; |
|---|
| 867 | aw_initstatus(); |
|---|
| 868 | aw_root = new AW_root; |
|---|
| 869 | aw_default = aw_root->open_default(".arb_prop/secedit.arb"); |
|---|
| 870 | aw_root->init_variables(aw_default); |
|---|
| 871 | aw_root->init("ARB_SECEDIT"); |
|---|
| 872 | gb_main = NULL; |
|---|
| 873 | |
|---|
| 874 | gb_main = GBT_open(":","rw",0); |
|---|
| 875 | if (!gb_main) { |
|---|
| 876 | aw_message(GB_get_error(),"OK"); |
|---|
| 877 | exit(0); |
|---|
| 878 | } |
|---|
| 879 | |
|---|
| 880 | |
|---|
| 881 | AW_window *aww = SEC_create_main_window(aw_root); |
|---|
| 882 | aww->show(); |
|---|
| 883 | |
|---|
| 884 | aw_root->main_loop(); |
|---|
| 885 | return 0; |
|---|
| 886 | } |
|---|
| 887 | #endif |
|---|
| 888 | |
|---|
| 889 | |
|---|
| 890 | |
|---|
| 891 | SEC_BASE_TYPE SEC_helix_strand::getType() { |
|---|
| 892 | return SEC_HELIX_STRAND; |
|---|
| 893 | } |
|---|
| 894 | |
|---|
| 895 | SEC_BASE_TYPE SEC_segment::getType() { |
|---|
| 896 | return SEC_SEGMENT; |
|---|
| 897 | } |
|---|
| 898 | |
|---|
| 899 | SEC_BASE_TYPE SEC_loop::getType() { |
|---|
| 900 | return SEC_LOOP; |
|---|
| 901 | } |
|---|
| 902 | |
|---|