~ubuntu-branches/debian/jessie/arb/jessie

« back to all changes in this revision

Viewing changes to SECEDIT/SEC_graphic.cxx

  • Committer: Package Import Robot
  • Author(s): Elmar Pruesse, Andreas Tille, Elmar Pruesse
  • Date: 2014-09-02 15:15:06 UTC
  • mfrom: (1.1.6)
  • Revision ID: package-import@ubuntu.com-20140902151506-jihq58b3iz342wif
Tags: 6.0.2-1
[ Andreas Tille ]
* New upstream version
  Closes: #741890
* debian/upstream -> debian/upstream/metadata
* debian/control:
   - Build-Depends: added libglib2.0-dev
   - Depends: added mafft, mrbayes
* debian/rules
   - Add explicite --remove-section=.comment option to manual strip call
* cme fix dpkg-control
* arb-common.dirs: Do not create unneeded lintian dir
* Add turkish debconf translation (thanks for the patch to Mert Dirik
  <mertdirik@gmail.com>)
  Closes: #757497

[ Elmar Pruesse ]
* patches removed:
   - 10_config.makefiles.patch,
     80_no_GL.patch
       removed in favor of creating file from config.makefile.template via 
       sed in debian/control
   - 20_Makefile_main.patch
       merged upstream
   - 21_Makefiles.patch
       no longer needed
   - 30_tmpfile_CVE-2008-5378.patch: 
       merged upstream
   - 50_fix_gcc-4.8.patch:
       merged upstream
   - 40_add_libGLU.patch:
       libGLU not needed for arb_ntree)
   - 60_use_debian_packaged_raxml.patch:
       merged upstream
   - 70_hardening.patch
       merged upstream
   - 72_add_math_lib_to_linker.patch
       does not appear to be needed
* patches added:
   - 10_upstream_r12793__show_db_load_progress:
       backported patch showing progress while ARB is loading a database
       (needed as indicator/splash screen while ARB is launching)
   - 20_upstream_r12794__socket_permissions:
       backported security fix
   - 30_upstream_r12814__desktop_keywords:
       backported add keywords to desktop (fixes lintian warning)
   - 40_upstream_r12815__lintian_spelling:
       backported fix for lintian reported spelling errors
   - 50_private_nameservers
       change configuration to put nameservers into users home dirs
       (avoids need for shared writeable directory)
   - 60_use_debian_phyml
       use phyml from debian package for both interfaces in ARB
* debian/rules:
   - create config.makefile from override_dh_configure target
   - use "make tarfile" in override_dh_install
   - remove extra cleaning not needed for ARB 6
   - use "dh_install --list-missing" to avoid missing files
   - added override_dh_fixperms target
* debian/control:
   - added libarb-dev package
   - Depends: added phyml, xdg-utils
   - Suggests: removed phyml
   - fix lintian duplicate-short-description (new descriptions)
* debian/*.install:
   - "unrolled" confusing globbing to select files
   - pick files from debian/tmp
   - moved all config files to /etc/arb
* debian/arb-common.templates: updated
* scripts:
   - removed arb-add-pt-server
   - launch-wrapper: 
     - only add demo.arb to newly created $ARBUSERDATA
     - pass commandline arguments through bin/arb wrapper
   - preinst: removing old PT server index files on upgrade from 5.5*
   - postinst: set setgid on shared PT dir
* rewrote arb.1 manfile
* added file icon for ARB databases
* using upstream arb_tcp.dat

Show diffs side-by-side

added added

removed removed

Lines of Context:
8
8
//                                                                 //
9
9
// =============================================================== //
10
10
 
11
 
 
12
 
#include <cstdio>
13
 
#include <cstdlib>
14
 
#include <vector>
15
 
 
16
 
#include <arbdb.h>
17
 
#include <arbdbt.h>
18
 
#include <aw_awars.hxx>
19
 
#include <aw_global.hxx>
20
 
#include <aw_window.hxx>
21
 
#include <aw_preset.hxx>
22
 
#include <ed4_extern.hxx>
23
 
 
24
11
#include "SEC_graphic.hxx"
25
12
#include "SEC_root.hxx"
26
13
#include "SEC_iter.hxx"
27
14
#include "SEC_toggle.hxx"
28
15
 
29
 
// SEC_graphic *SEC_GRAPHIC = 0;
 
16
#include <ed4_extern.hxx>
 
17
 
 
18
#include <aw_awars.hxx>
 
19
#include <aw_global.hxx>
 
20
#include <aw_preset.hxx>
 
21
#include <aw_msg.hxx>
 
22
#include <aw_root.hxx>
 
23
#include <aw_question.hxx>
 
24
#include <arbdbt.h>
 
25
#include <ad_cb.h>
 
26
 
 
27
#include <vector>
30
28
 
31
29
using namespace std;
32
30
 
33
 
AW_gc_manager SEC_graphic::init_devices(AW_window *aww, AW_device *device, AWT_canvas* ntw, AW_CL)
 
31
AW_gc_manager SEC_graphic::init_devices(AW_window *aww, AW_device *device, AWT_canvas *scr)
34
32
{
35
 
    AW_gc_manager preset_window =
 
33
    AW_gc_manager gc_manager =
36
34
        AW_manage_GC(aww,
 
35
                     scr->get_gc_base_name(),
37
36
                     device,
38
37
                     SEC_GC_LOOP,
39
38
                     SEC_GC_MAX,
40
39
                     AW_GCM_DATA_AREA,
41
 
                     (AW_CB)AWT_expose_cb, (AW_CL)ntw, 0,
 
40
                     makeWindowCallback(AWT_expose_cb, scr),
42
41
                     false,
43
42
                     "#A1A1A1",
44
43
                     "LOOP$#247900",
63
62
 
64
63
                     // colors used to paint the skeleton of the structure
65
64
                     "+-SKELETON HELIX${HELIX}", "+-SKELETON LOOP${LOOP}", "-SKELETON NONHELIX${NONPAIRING HELIX}",
66
 
                     NULL );
 
65
                     NULL);
67
66
 
68
 
    return preset_window;
 
67
    return gc_manager;
69
68
}
70
69
 
71
70
static GB_ERROR change_constraints(SEC_base *elem) {
116
115
            }
117
116
 
118
117
            sec_assert(error);
119
 
            aw_popup_ok(error);
120
 
            
 
118
            aw_message(error);
 
119
 
121
120
            char *retry = aw_input(question, answer);
122
121
            free(answer);
123
122
 
135
134
    GB_ERROR error = 0;
136
135
 
137
136
    if (event == AW_Keyboard_Press) {
138
 
        bool wrapped   = false; // avoid deadlock
139
137
        int  curpos    = sec_root->get_cursor();
140
138
        int  maxIndex  = sec_root->max_index();
141
139
        bool setCurpos = false;
142
140
        bool handled   = false;
143
141
 
144
142
        if (key_modifier == AW_KEYMODE_NONE) {
 
143
            bool wrapped = false;   // avoid deadlock
 
144
 
145
145
            switch (key_code) {
146
146
                case AW_KEY_LEFT: {
147
147
                    while (1) {
188
188
 
189
189
                        case 's': toggle_awar = AWAR_SECEDIT_DISPLAY_SAI; break;
190
190
                        case 'r': toggle_awar = AWAR_SECEDIT_DISPLAY_SEARCH; break;
191
 
                            
 
191
 
192
192
                        case 'E': toggle_awar = AWAR_SECEDIT_DISPPOS_ECOLI; break;
193
193
                        case 'H': toggle_awar = AWAR_SECEDIT_DISPPOS_BINDING; break;
194
194
 
208
208
 
209
209
                        if (val>val_max) val = 0;
210
210
                        awar->write_int(val);
211
 
                        
 
211
 
212
212
                        handled = true;
213
213
                    }
214
214
 
223
223
            aw_root->awar_int(AWAR_SET_CURSOR_POSITION)->write_int(curpos);
224
224
            handled = true;
225
225
        }
226
 
        
 
226
 
227
227
        if (!handled) { // pass unhandled key events to EDIT4
228
228
            AW_event faked_event;
229
229
 
234
234
            faked_event.keycode     = key_code;
235
235
            faked_event.character   = key_char;
236
236
 
237
 
            ED4_remote_event(&faked_event);
 
237
            sec_root->host().forward_event(&faked_event);
238
238
        }
239
239
    }
240
240
 
244
244
GB_ERROR SEC_graphic::handleMouse(AW_device *device, AW_event_type event, int button, AWT_COMMAND_MODE cmd, const Position& world, SEC_base *elem, int abspos) {
245
245
    GB_ERROR error = 0;
246
246
 
247
 
    // -----------------------------------------
 
247
    // ------------------------------------------
248
248
    //      handle element dependent actions
249
 
    // -----------------------------------------
250
249
 
251
250
    if (elem) {
252
251
        static Position start;      // click position on mouse down
270
269
 
271
270
                switch (event) {
272
271
                    case AW_Mouse_Press:
273
 
                        if (button == AWT_M_LEFT) {
 
272
                        if (button == AW_BUTTON_LEFT) {
274
273
                            start_size = elem->drawnSize();
275
274
                            sec_root->set_show_constraints(elem->getType());
276
275
                            exports.refresh = 1;
282
281
                            exports.save    = 1;
283
282
                        }
284
283
                        break;
285
 
                            
 
284
 
286
285
                    case AW_Mouse_Drag:
287
 
                        if (button == AWT_M_LEFT) {
 
286
                        if (button == AW_BUTTON_LEFT) {
288
287
                            double dfix1 = Distance(fixpoint, start);
289
288
                            double dfix2 = Distance(fixpoint, world);
290
289
 
309
308
                }
310
309
                break;
311
310
            }
312
 
            case AWT_MODE_MOD:  // edit constraints
313
 
                if (button==AWT_M_LEFT && event==AW_Mouse_Press) {
 
311
            case AWT_MODE_EDIT:  // edit constraints
 
312
                if (button==AW_BUTTON_LEFT && event==AW_Mouse_Press) {
314
313
                    error = change_constraints(elem);
315
314
                    if (!error) {
316
315
                        elem->sizeChanged();
319
318
                }
320
319
                break;
321
320
 
322
 
            case AWT_MODE_ROT: { // rotate branches/loops
 
321
            case AWT_MODE_ROTATE: { // rotate branches/loops
323
322
                if (event == AW_Mouse_Release) {
324
323
                    exports.save = 1;
325
324
                }
335
334
                    if (event == AW_Mouse_Press) {
336
335
                        startClick = fix2world;
337
336
                        old.clear();
338
 
                        rotateSubStructure = (button == AWT_M_LEFT);
339
 
                            
 
337
                        rotateSubStructure = (button == AW_BUTTON_LEFT);
 
338
 
340
339
                        if (loop) {
341
340
                            old.push_back(loop->get_abs_angle());
342
341
                            if (!rotateSubStructure) {
376
375
                        elem->orientationChanged();
377
376
                    }
378
377
                }
379
 
                break ;
 
378
                break;
380
379
            }
381
380
 
382
381
            case AWT_MODE_SETROOT:  // set-root-mode / reset angles
383
382
                if (event == AW_Mouse_Press) {
384
 
                    if (button == AWT_M_LEFT) { // set root
 
383
                    if (button == AW_BUTTON_LEFT) { // set root
385
384
                        if (loop) {
386
385
                            sec_root->set_root(loop);
387
386
                            exports.save = 1;
389
388
                        else error = "Please click on a loop to change the root";
390
389
                    }
391
390
                    else { // reset angles
392
 
                        sec_assert(button == AWT_M_RIGHT);
 
391
                        sec_assert(button == AW_BUTTON_RIGHT);
393
392
                        elem->reset_angles();
394
393
                        elem->orientationChanged();
395
394
                        exports.save = 1;
396
395
                    }
397
396
                }
398
 
                break ;
 
397
                break;
399
398
 
400
 
            case AWT_MODE_MOVE: { // fold/unfold helix
 
399
            case AWT_MODE_FOLD: { // fold/unfold helix
401
400
                if (event == AW_Mouse_Press) {
402
 
                    if (button == AWT_M_LEFT) { // fold helix
 
401
                    if (button == AW_BUTTON_LEFT) { // fold helix
403
402
                        if (loop) {
404
403
                            const char *helix_nr = sec_root->helixNrAt(abspos);
405
404
                            if (helix_nr) {
420
419
                        }
421
420
                    }
422
421
                    else { // unfold helix
423
 
                        sec_assert(button == AWT_M_RIGHT);
 
422
                        sec_assert(button == AW_BUTTON_RIGHT);
424
423
                        if (helix) {
425
424
                            error = sec_root->unsplit_loop(helix->strandToRoot());
426
425
                            if (!error) {
433
432
                        }
434
433
                    }
435
434
                }
436
 
                break ;
 
435
                break;
437
436
            }
438
 
            case AWT_MODE_LINE:
439
 
            case AWT_MODE_PROINFO:
 
437
            case AWT_MODE_CURSOR:
 
438
            case AWT_MODE_PINFO:
440
439
                elem = 0; // handle element-independent
441
440
                break;
442
441
            default: sec_assert(0); break;
443
442
        }
444
443
    }
445
444
 
446
 
    // --------------------------------------
 
445
    // ---------------------------------------
447
446
    //      action independent of element
448
 
    // --------------------------------------
449
 
    
 
447
 
450
448
    if (!elem) {
451
449
        switch (cmd) {
452
 
            case AWT_MODE_LINE: // set cursor in ARB_EDIT4
 
450
            case AWT_MODE_CURSOR: // set cursor in ARB_EDIT4
453
451
                if (event == AW_Mouse_Press) {
454
452
                    if (abspos >= 0 && size_t(abspos) < sec_root->max_index()) {
455
453
                        // sequence position in AWAR_SET_CURSOR_POSITION is starting with 0!
458
456
                }
459
457
                break;
460
458
 
461
 
            case AWT_MODE_PROINFO: // display search pattern
 
459
            case AWT_MODE_PINFO: // display search pattern
462
460
                if (event == AW_Mouse_Press) {
463
 
                    if (button == AWT_M_LEFT) {
 
461
                    if (button == AW_BUTTON_LEFT) {
464
462
                        if (abspos >= 0 && size_t(abspos) < sec_root->max_index()) {
465
463
                            sec_root->paintSearchPatternStrings(device, abspos, world.xpos()+1, world.ypos());
466
464
                        }
467
 
                        // dont refresh here!
 
465
                        // don't refresh here!
468
466
                    }
469
467
                    else {
470
 
                        sec_assert(button == AWT_M_RIGHT);
 
468
                        sec_assert(button == AW_BUTTON_RIGHT);
471
469
                        exports.refresh = 1; // simply refresh to remove drawn patterns
472
470
                    }
473
471
                }
474
472
                break;
475
 
                
 
473
 
476
474
            default:
477
475
                break;
478
476
        }
483
481
    return error;
484
482
}
485
483
 
486
 
void SEC_graphic::command(AW_device *device, AWT_COMMAND_MODE cmd,
487
 
                          int button, AW_key_mod key_modifier, AW_key_code key_code, char key_char,
488
 
                          AW_event_type event, AW_pos screen_x, AW_pos screen_y,
489
 
                          AW_clicked_line *cl, AW_clicked_text *ct)
490
 
{
491
 
    if (cmd != AWT_MODE_MOD && cmd != AWT_MODE_STRETCH) sec_root->set_show_constraints(SEC_NO_TYPE);
 
484
void SEC_graphic::handle_command(AW_device *device, AWT_graphic_event& event) {
 
485
    if (event.cmd() != AWT_MODE_EDIT && event.cmd() != AWT_MODE_STRETCH) sec_root->set_show_constraints(SEC_NO_TYPE);
492
486
 
493
487
    GB_ERROR error = 0;
494
 
    if (event== AW_Keyboard_Press || event == AW_Keyboard_Release) {
495
 
        error = handleKey(event, key_modifier, key_code, key_char);
 
488
    if (event.type() == AW_Keyboard_Press || event.type() == AW_Keyboard_Release) {
 
489
        error = handleKey(event.type(), event.key_modifier(), event.key_code(), event.key_char());
496
490
    }
497
491
    else {
498
 
        if (button != AWT_M_MIDDLE && cmd != AWT_MODE_ZOOM) { // dont handle scroll + zoom
499
 
            AW_CL    cd1, cd2;
500
 
            Position world = device->rtransform(Position(screen_x, screen_y)); // current click position
501
 
 
502
 
            if (AW_getBestClick(world, cl, ct, &cd1, &cd2)) {
503
 
                SEC_base *elem   = reinterpret_cast<SEC_base*>(cd1);
504
 
                int       abspos = cd2;
505
 
 
506
 
#if defined(DEBUG) && 0
507
 
                if (cl->exists) device->line(SEC_GC_CURSOR, cl->x0, cl->y0, cl->x1, cl->y1, -1, 0, -1);
508
 
                if (ct->exists) device->box(SEC_GC_CURSOR, false, ct->textArea, -1, 0, -1);
509
 
#endif // DEBUG
510
 
 
511
 
                error = handleMouse(device, event, button, cmd, world, elem, abspos);
 
492
        if (event.button() != AW_BUTTON_MIDDLE && event.cmd() != AWT_MODE_ZOOM) { // don't handle scroll + zoom
 
493
            const AW_clicked_element *clicked = event.best_click();
 
494
            if (clicked) {
 
495
                SEC_base *elem   = reinterpret_cast<SEC_base*>(clicked->cd1());
 
496
                int       abspos = clicked->cd2();
 
497
 
 
498
                Position world = device->rtransform(event.position());
 
499
                error = handleMouse(device, event.type(), event.button(), event.cmd(), world, elem, abspos);
512
500
            }
513
501
        }
514
502
    }
516
504
    if (error) aw_message(error);
517
505
}
518
506
 
519
 
 
520
507
SEC_graphic::SEC_graphic(AW_root *aw_rooti, GBDATA *gb_maini)
521
 
    : update_requested(SEC_UPDATE_RELOAD)
522
 
    , load_error(0)
523
 
    , disp_device(0)
524
 
    , gb_main(gb_maini)
525
 
    , aw_root(aw_rooti)
526
 
    , sec_root(new SEC_root)
527
 
    , gb_struct(0)
528
 
    , gb_struct_ref(0)
529
 
    , last_saved(0)
 
508
    : update_requested(SEC_UPDATE_RELOAD),
 
509
      load_error(0),
 
510
      disp_device(0),
 
511
      gb_main(gb_maini),
 
512
      aw_root(aw_rooti),
 
513
      sec_root(new SEC_root),
 
514
      gb_struct(0),
 
515
      gb_struct_ref(0),
 
516
      last_saved(0)
530
517
{
531
 
    // update_requested = SEC_UPDATE_RELOAD; // // need to load structure!
532
 
 
533
 
    // gb_struct     = 0;
534
 
    // gb_struct_ref = 0;
535
 
    // last_saved    = 0;
536
 
 
537
 
    exports.dont_fit_x    = 0;
538
 
    exports.dont_fit_y    = 0;
539
 
    exports.left_offset   = 20;
540
 
    exports.right_offset  = 20;
541
 
    exports.top_offset    = 20;
542
 
    exports.bottom_offset = 20;
543
 
    exports.dont_scroll   = 0;
544
 
 
545
 
    // aw_root = aw_rooti;
546
 
    // gb_main = gb_maini;
547
 
    
548
 
    rot_ct.exists = false;
549
 
    rot_cl.exists = false;
550
 
    
551
 
    // sec_root      = new SEC_root;
 
518
    exports.set_standard_default_padding();
552
519
}
553
520
 
554
 
SEC_graphic::~SEC_graphic(void) {
 
521
SEC_graphic::~SEC_graphic() {
555
522
    delete sec_root;
556
523
    delete load_error;
557
524
}
558
525
 
559
 
void SEC_structure_changed_cb(GBDATA *gb_seq, SEC_graphic *gfx, GB_CB_TYPE type) { 
 
526
static void SEC_structure_changed_cb(GBDATA *gb_seq, SEC_graphic *gfx, GB_CB_TYPE type) {
560
527
    if (type == GB_CB_DELETE) {
561
528
        gfx->gb_struct     = NULL;
562
529
        gfx->gb_struct_ref = NULL;
568
535
    }
569
536
}
570
537
 
571
 
/** read awar AWAR_HELIX_NAME to get the name */
572
538
GB_ERROR SEC_graphic::load(GBDATA *, const char *, AW_CL, AW_CL) {
 
539
    //! (Re-)Load secondary structure from database
 
540
 
573
541
    sec_assert(sec_root->get_db()->canDisplay()); // need a sequence loaded (to fix bugs in versions < 3)
574
542
    sec_root->nail_cursor();
575
 
    
 
543
 
576
544
    GB_transaction ta(gb_main);
577
545
    // first check timestamp, do not load structure that we have saved !!!!
578
546
    if (gb_struct) {
579
547
        if (GB_read_clock(gb_struct) <= last_saved) return NULL;
580
548
    }
581
549
 
582
 
    /************************** Reset structure ***********************************/
 
550
    // Reset structure:
583
551
    if (gb_struct) {
584
 
        GB_remove_callback( gb_struct,  GB_CB_ALL, (GB_CB)SEC_structure_changed_cb, (int *)this);
585
 
        gb_struct = NULL;
586
 
        GB_remove_callback( gb_struct_ref,  GB_CB_ALL, (GB_CB)SEC_structure_changed_cb, (int *)this);
587
 
        gb_struct_ref = NULL;
 
552
        GB_remove_callback(gb_struct,     GB_CB_ALL, makeDatabaseCallback(SEC_structure_changed_cb, this)); gb_struct     = NULL;
 
553
        GB_remove_callback(gb_struct_ref, GB_CB_ALL, makeDatabaseCallback(SEC_structure_changed_cb, this)); gb_struct_ref = NULL;
588
554
    }
589
555
 
590
556
    request_update(SEC_UPDATE_RECOUNT);
594
560
    }
595
561
 
596
562
 
597
 
    GB_ERROR err = 0;
598
 
 
599
 
    /************************** Setup new structure *******************************/
600
 
 
601
 
    long    ali_len = -1;
602
 
    GBDATA *gb_ali  = 0;
 
563
 
 
564
    // Setup new structure:
 
565
    GB_ERROR  err    = 0;
 
566
    GBDATA   *gb_ali = 0;
603
567
    {
604
568
        char *helix_name = GBT_get_default_helix(gb_main);
605
569
        char *name       = GBT_readOrCreate_string(gb_main, AWAR_HELIX_NAME, helix_name);
607
571
 
608
572
        GBDATA *gb_species = GBT_find_SAI(gb_main, name);
609
573
        if (!gb_species) {
610
 
            err = GB_export_errorf("Cannot find helix template SAI '%s'",name);
 
574
            err = GB_export_errorf("Cannot find helix template SAI '%s'", name);
611
575
        }
612
576
        else {
613
577
            char *ali_name = GBT_get_default_alignment(gb_main);
 
578
            long  ali_len  = GBT_get_alignment_len(gb_main, ali_name);
614
579
 
615
 
            ali_len = GBT_get_alignment_len(gb_main,ali_name);
616
580
            if (ali_len < 10) {
617
 
                err = GB_export_errorf("alignment '%s' to short to generate helix",ali_name);
 
581
                err = GB_export_errorf("alignment '%s' to short to generate helix", ali_name);
618
582
            }
619
583
            else {
620
584
                gb_ali = GB_search(gb_species, ali_name, GB_FIND);
621
585
                if (!gb_ali) {
622
 
                    err = GB_export_errorf("Your helix structure template '%s' has no valid sequence for alignment '%s'", name,ali_name); // no sequence for name in the database !!!
 
586
                    err = GB_export_errorf("Your helix structure template '%s' has no valid sequence for alignment '%s'", name, ali_name); // no sequence for name in the database !!!
623
587
                }
624
588
            }
625
589
            free(ali_name);
626
590
        }
627
 
        
 
591
 
628
592
        free(name);
629
593
        free(helix_name);
630
594
    }
631
595
 
632
 
    // -----------------------
 
596
    // ------------------------
633
597
    //      read structure
634
 
    // -----------------------
635
598
 
636
599
    if (!err) {
637
 
        gb_struct = GB_search(gb_ali,NAME_OF_STRUCT_SEQ, GB_FIND);
 
600
        gb_struct = GB_search(gb_ali, NAME_OF_STRUCT_SEQ, GB_FIND);
638
601
 
639
602
        if (gb_struct) {
640
 
            gb_struct_ref = GB_search(gb_ali , NAME_OF_REF_SEQ , GB_STRING);
 
603
            gb_struct_ref = GB_search(gb_ali,  NAME_OF_REF_SEQ,  GB_STRING);
641
604
 
642
605
            char *strct = GB_read_string(gb_struct);
643
606
            char *ref = GB_read_string(gb_struct_ref);
644
 
            err = sec_root->read_data(strct,ref);
 
607
            err = sec_root->read_data(strct, ref);
645
608
            if (err) {
646
609
                err = GBS_global_string("Defect structure in DB (read-error: '%s')", err);
647
610
            }
687
650
        last_saved = GB_read_clock(gb_struct); // mark as loaded
688
651
        request_update(SEC_UPDATE_RECOUNT);
689
652
        if (load_error) { // previous load error?
690
 
            freeset(load_error, 0);
 
653
            freenull(load_error);
691
654
            request_update(SEC_UPDATE_ZOOM_RESET);
692
655
        }
693
656
    }
696
659
        request_update(SEC_UPDATE_ZOOM_RESET);
697
660
    }
698
661
 
699
 
    /************************* Listen to the database ***************************/
700
 
    GB_add_callback(gb_struct,GB_CB_ALL,(GB_CB)SEC_structure_changed_cb, (int *)this);
701
 
    GB_add_callback(gb_struct_ref,GB_CB_ALL,(GB_CB)SEC_structure_changed_cb, (int *)this);
 
662
    // set structure-change-callbacks:
 
663
    if(gb_struct)     GB_add_callback(gb_struct,     GB_CB_ALL, makeDatabaseCallback(SEC_structure_changed_cb, this));
 
664
    if(gb_struct_ref) GB_add_callback(gb_struct_ref, GB_CB_ALL, makeDatabaseCallback(SEC_structure_changed_cb, this));
702
665
 
703
666
    return err;
704
667
}
705
668
 
706
 
/** Save secondary structure to database */
707
 
GB_ERROR SEC_graphic::save(GBDATA *, const char *,AW_CL,AW_CL)
708
 
{
 
669
GB_ERROR SEC_graphic::save(GBDATA *, const char *, AW_CL, AW_CL) {
 
670
    //! Save secondary structure to database
 
671
 
709
672
    if (!gb_struct) return 0;   // not loaded, so don't save
710
673
    if (!sec_root) return 0;
711
 
    
 
674
 
712
675
    char           *data  = sec_root->buildStructureString();
713
676
    GB_transaction  ta(gb_main);
714
 
    GB_ERROR        error = GB_write_string(gb_struct,data);
 
677
    GB_ERROR        error = GB_write_string(gb_struct, data);
715
678
    if (!error) {
716
679
        const XString&  xstr     = sec_root->get_xString();
717
680
        const char     *x_string = xstr.get_x_string();
718
681
 
719
 
        error = GB_write_string(gb_struct_ref,x_string);
 
682
        error = GB_write_string(gb_struct_ref, x_string);
720
683
 
721
684
        if (!error && xstr.alignment_too_short()) {
722
685
            aw_message("Your helix needs one gap at end. Please format your alignment!");
746
709
GB_ERROR SEC_graphic::write_data_to_db(const char *data, const char *x_string) const {
747
710
    if (!gb_struct) return 0;
748
711
    if (!sec_root) return 0;
749
 
    
 
712
 
750
713
    GB_transaction ta(gb_main);
751
714
    GB_ERROR       error = GB_write_string(gb_struct, data);
752
715
    if (!error) {
758
721
 
759
722
int SEC_graphic::check_update(GBDATA *) {
760
723
    GB_transaction ta(gb_main);
761
 
    
 
724
 
762
725
    const SEC_db_interface *db = sec_root->get_db();
763
726
 
764
727
    if (db && db->canDisplay()) {
778
741
            update_requested = static_cast<SEC_update_request>((update_requested^SEC_UPDATE_SHOWN_POSITIONS)|SEC_UPDATE_RECOUNT); // clear reload flag
779
742
            exports.refresh  = 1;
780
743
        }
781
 
    
 
744
 
782
745
        if (update_requested & SEC_UPDATE_RECOUNT) {
783
746
            sec_root->invalidate_base_positions();
784
747
            sec_root->relayout();
786
749
            update_requested = static_cast<SEC_update_request>(update_requested^SEC_UPDATE_RECOUNT); // clear recount flag
787
750
            exports.refresh  = 1;
788
751
        }
789
 
    
 
752
 
790
753
        sec_root->perform_autoscroll();
791
754
    }
792
755
 
793
756
    int res = 0;
794
757
    if (update_requested & SEC_UPDATE_ZOOM_RESET) {
795
 
        res              = 1; // signal zoom reset
 
758
        res              = 1; // report zoom reset
796
759
        update_requested = static_cast<SEC_update_request>(update_requested^SEC_UPDATE_ZOOM_RESET); // clear zoom reset flag
797
760
    }
798
761
    return res;
808
771
    sec_root->clear_last_drawed_cursor_position();
809
772
 
810
773
    if (sec_root->canDisplay()) {
811
 
        if (sec_root->get_root_loop())  {
 
774
        if (sec_root->get_root_loop()) {
812
775
            GB_ERROR paint_error = sec_root->paint(device);
813
776
            if (paint_error) textToDisplay = GBS_global_string("Error: %s", paint_error);
814
777
        }
827
790
 
828
791
    if (textToDisplay) { // no structure
829
792
        sec_assert(strchr(textToDisplay, '\n') == 0); // linefeeds do not work here
830
 
        device->text(SEC_GC_ECOLI, textToDisplay, 0, 0, 0, 1, 0, 0, 0);
 
793
        device->text(SEC_GC_ECOLI, textToDisplay, 0, 0, 0, AW_SCREEN, 0);
831
794
        sec_root->set_last_drawed_cursor_position(LineVector(Origin, ZeroVector));
832
795
    }
833
796
}
834
797
 
835
 
void SEC_graphic::info(AW_device *device, AW_pos x, AW_pos y, AW_clicked_line *cl, AW_clicked_text *ct)
836
 
{
 
798
void SEC_graphic::info(AW_device */*device*/, AW_pos /*x*/, AW_pos /*y*/, AW_clicked_line */*cl*/, AW_clicked_text */*ct*/) {
837
799
    aw_message("INFO MESSAGE");
838
 
    AWUSE(device);
839
 
    AWUSE(x);
840
 
    AWUSE(y);
841
 
    AWUSE(cl);
842
 
    AWUSE(ct);
843
800
}
844
801
 
 
802