~ubuntu-branches/ubuntu/trusty/rasmol/trusty

« back to all changes in this revision

Viewing changes to src/gtkwin.c

  • Committer: Bazaar Package Importer
  • Author(s): Teemu Ikonen
  • Date: 2009-11-24 16:48:04 UTC
  • mfrom: (3.1.4 squeeze)
  • Revision ID: james.westby@ubuntu.com-20091124164804-liuvywcs6l45ibl3
Tags: 2.7.5-1
* New upstream release
* Imakefile: Use Debian versions of library dependencies
* control:
  - Add build-deps to libcvector2-dev, libcqrlib2-dev, libneartree3-dev
  - Update to standards-version 3.8.3

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/***************************************************************************
2
 
 *                             RasMol 2.7.4.2                              *
 
2
 *                              RasMol 2.7.5                               *
3
3
 *                                                                         *
4
4
 *                                 RasMol                                  *
5
5
 *                 Molecular Graphics Visualisation Tool                   *
6
 
 *                            19 November 2007                             *
7
 
 *                          (rev. 21 March 2008)                           *
 
6
 *                              13 June 2009                               *
8
7
 *                                                                         *
9
8
 *                   Based on RasMol 2.6 by Roger Sayle                    *
10
9
 * Biomolecular Structures Group, Glaxo Wellcome Research & Development,   *
31
30
 *                   RasMol 2.7.4   Nov 07                                 *
32
31
 *                   RasMol 2.7.4.1 Jan 08                                 *
33
32
 *                   RasMol 2.7.4.2 Mar 08                                 *
34
 
 *                                                                         *
35
 
 * RasMol 2.7.3 incorporates changes by Clarice Chigbo, Ricky Chachra,     *
36
 
 * and Mamoru Yamanishi.  Work on RasMol 2.7.3 supported in part by        *
37
 
 * grants DBI-0203064, DBI-0315281 and EF-0312612 from the U.S. National   *
38
 
 * Science Foundation and grant DE-FG02-03ER63601 from the U.S. Department *
39
 
 * of Energy.  RasMol 2.7.4 incorporates changes by G. Todorov, Nan Jia,   *
40
 
 * N. Darakev, P. Kamburov, G. McQuillan, J. Jemilawon.  Work on RasMol    *
41
 
 * 2.7.4 supported in part by grant 1R15GM078077-01 from the National      *
42
 
 * Institute of General Medical Sciences (NIGMS). The content is solely    *
43
 
 * the responsibility of the authors and does not necessarily represent    * 
44
 
 * the official views of the funding organizations.                        *
45
 
 *                                                                         *
46
 
 * The code for use of RasMol under GTK in RasMol 2.7.4.2 was written by   *
47
 
 * Teemu  Ikonen.                                                          *
 
33
 *                   RasMol 2.7.5   May 09                                 *
 
34
 *                                                                         *
 
35
 * RasMol 2.7.5 incorporates changes by T. Ikonen, G. McQuillan, N. Darakev*
 
36
 * and L. Andrews (via the neartree package).  Work on RasMol 2.7.5        *
 
37
 * supported in part by grant 1R15GM078077-01 from the National Institute  *
 
38
 * of General Medical Sciences (NIGMS), U.S. National Institutes of Health *
 
39
 * and by grant ER63601-1021466-0009501 from the Office of Biological &    *
 
40
 * Environmental Research (BER), Office of Science, U. S. Department of    *
 
41
 * Energy.  RasMol 2.7.4 incorporated  changes by G. Todorov, Nan Jia,     *
 
42
 * N. Darakev, P. Kamburov, G. McQuillan, and J. Jemilawon. Work on RasMol *
 
43
 * 2.7.4 supported in part by grant 1R15GM078077-01 from the NIGMS/NIH and *
 
44
 * grant ER63601-1021466-0009501 from BER/DOE.  RasMol 2.7.3 incorporates  *
 
45
 * changes by Clarice Chigbo, Ricky Chachra, and Mamoru Yamanishi.  Work   *
 
46
 * on RasMol 2.7.3 supported in part by grants DBI-0203064, DBI-0315281    *
 
47
 * and EF-0312612 from the U.S. National Science Foundation and grant      *
 
48
 * DE-FG02-03ER63601 from BER/DOE. The content is solely the responsibility*
 
49
 * of the authors and does not necessarily represent the official views of *
 
50
 * the funding organizations.                                              *
 
51
 *                                                                         *
 
52
 * The code for use of RasMol under GTK in RasMol 2.7.4.2 and 2.7.5 was    *
 
53
 * written by Teemu Ikonen.                                                *
48
54
 *                                                                         *
49
55
 *                    and Incorporating Translations by                    *
50
56
 *  Author                               Item                     Language *
101
107
#include "gtkui.h"
102
108
#include "eggfileformatchooser.h"
103
109
 
104
 
#define XScrlDial  1 /*1*/
105
 
#define YScrlDial  0 /*0*/
106
110
 
107
111
#define RASGTK_MINWIDTH  300
108
112
#define RASGTK_MINHEIGHT 300
256
260
        if(menu == m_o_stereo) {
257
261
                gtk_toggle_action_set_active((GtkToggleAction *)action, UseStereo);
258
262
        }
259
 
        if( ReDrawFlag )
 
263
        if( ReDrawFlag ) {
260
264
        RefreshScreen();
 
265
        ReDrawFlag = NextReDrawFlag;
 
266
        }
261
267
        return FALSE;
262
268
}
263
269
 
267
273
 
268
274
        value = gtk_radio_action_get_current_value (action);
269
275
        HandleMenu(value);
270
 
        if( ReDrawFlag )
 
276
        if( ReDrawFlag ) {
271
277
        RefreshScreen();
 
278
        ReDrawFlag = NextReDrawFlag;
 
279
        }
272
280
}
273
281
 
274
282
void open_cb(GtkAction *action, gpointer user_data)
283
291
        GTK_FILE_CHOOSER_ACTION_OPEN,
284
292
        GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
285
293
        GTK_STOCK_OPEN, GTK_RESPONSE_ACCEPT,
286
 
        NULL);          
 
294
        NULL);
287
295
 
288
296
    filter = gtk_file_filter_new();
289
297
    gtk_file_filter_set_name(filter, "Molecular structures");
325
333
            g_free (prevname);
326
334
        prevname = gtk_file_chooser_get_filename (
327
335
            GTK_FILE_CHOOSER (opendialog));
328
 
        strcpy(DataFileName, prevname); 
 
336
        strcpy(DataFileName, prevname);
329
337
        if(FetchFile(FormatPDB, False, prevname)) {
330
338
            char tmp[PATH_MAX+10];
331
339
 
335
343
                gtk_recent_manager_add_item(rman, tmp);
336
344
            }
337
345
            DefaultRepresentation();
338
 
            RefreshScreen();    
 
346
            RefreshScreen();
339
347
        } else {
340
348
            ;
341
349
        }
422
430
        
423
431
        ReDrawFlag |= RFReSize;
424
432
        RefreshScreen();
 
433
        ReDrawFlag = NextReDrawFlag;
425
434
}
426
435
 
427
436
gboolean sizespin_cb(GtkSpinButton button, gpointer data)
945
954
        strcpy(DataFileName, uri+5);
946
955
        FetchFile(FormatPDB, False, uri+5);
947
956
        DefaultRepresentation();
948
 
        RefreshScreen();        
 
957
        RefreshScreen();
949
958
    }
950
959
}
951
960
 
1280
1289
    gdouble new, old;
1281
1290
 
1282
1291
    if ( RotMode == RotAll ) {
1283
 
                new = WRotValue[YScrlDial]; 
 
1292
                new = WorldDialValue[YScrlDial]; 
1284
1293
    } else {
1285
1294
                new = DialValue[YScrlDial];
1286
1295
    }
1297
1306
                new = BondSelected->BRotValue;
1298
1307
    } else {
1299
1308
                if ( RotMode == RotAll ) {
1300
 
                new = WRotValue[XScrlDial];
 
1309
                new = WorldDialValue[XScrlDial];
1301
1310
                } else {
1302
1311
                new = DialValue[XScrlDial];
1303
1312
                }
1386
1395
    
1387
1396
    ReDrawFlag |= RFReSize;
1388
1397
        RefreshScreen();
 
1398
        ReDrawFlag = NextReDrawFlag;
1389
1399
        
1390
1400
    return FALSE;
1391
1401
}
1393
1403
 
1394
1404
void vscroll_cb(GtkRange *range, gpointer user_data)
1395
1405
{
1396
 
    WRotValue[YScrlDial] = gtk_range_get_value(range);
 
1406
    WorldDialValue[YScrlDial] = gtk_range_get_value(range);
1397
1407
    ReDrawFlag |= (1<<YScrlDial);
1398
1408
    RefreshScreen();
 
1409
    ReDrawFlag = NextReDrawFlag;
1399
1410
}
1400
1411
 
1401
1412
void hscroll_cb(GtkRange *range, gpointer user_data)
1407
1418
          BondSelected->BRotValue =  val;
1408
1419
          ReDrawFlag |= RFRotBond;
1409
1420
        } else {
1410
 
        WRotValue[XScrlDial] = val;
 
1421
        WorldDialValue[XScrlDial] = val;
1411
1422
        ReDrawFlag |= (1<<XScrlDial);
1412
1423
        }
1413
1424
    RefreshScreen();
 
1425
    ReDrawFlag = NextReDrawFlag;
1414
1426
}
1415
1427
 
1416
1428
static gboolean popup_cb (GtkWidget *widget)
1427
1439
        dragging = TRUE;
1428
1440
    stat = GetStatus(event->state);
1429
1441
    ProcessMouseMove(event->x,event->y,stat);
1430
 
    if(ReDrawFlag)
 
1442
    if(ReDrawFlag) {
1431
1443
                RefreshScreen();
 
1444
        ReDrawFlag = NextReDrawFlag;
 
1445
    }
1432
1446
    xorig = event->x;
1433
1447
    yorig = event->y;
1434
1448
    gdk_window_get_pointer(canvas->window, &x, &y, &mask);
1471
1485
        if(!CommandActive) {
1472
1486
            ResetCommandLine(0);
1473
1487
            RefreshScreen();
 
1488
            ReDrawFlag = NextReDrawFlag;
1474
1489
        }
1475
1490
    }   
1476
1491
}
1559
1574
 
1560
1575
    sprintf (VersionStr,"RasMol Version %s", VERSION);
1561
1576
 
1562
 
    for( i=0; i<8; i++ )
 
1577
    for( i=0; i<11; i++ )
1563
1578
        DialValue[i] = 0.0;
1564
1579
 
1565
1580
    RLut[0]=0;   GLut[0]=0;   BLut[0]=0;    ULut[0]=True;
1568
1583
    RLut[3]=200; GLut[3]=200; BLut[3]=200;  ULut[3]=True;
1569
1584
    RLut[4]=255; GLut[4]=255; BLut[4]=255;  ULut[4]=True;
1570
1585
 
1571
 
    XRange = DefaultWide;  
1572
 
    YRange = DefaultHigh;  
 
1586
    XRange = DefaultWide;
 
1587
    YRange = DefaultHigh;
1573
1588
    if (InitWidth  >= RASGTK_MINWIDTH) XRange = InitWidth;
1574
1589
    if (InitHeight >= RASGTK_MINHEIGHT) YRange = InitHeight;
1575
1590
    WRange = XRange>>1;
1582
1597
    g_set_application_name("RasMol");
1583
1598
    mainwin = gtk_window_new (GTK_WINDOW_TOPLEVEL);
1584
1599
    gtk_widget_add_events(mainwin, GDK_KEY_PRESS_MASK);
1585
 
    g_signal_connect (mainwin, "delete-event", 
 
1600
    g_signal_connect (mainwin, "delete-event",
1586
1601
        G_CALLBACK (RasMolExit), NULL);
1587
1602
 
1588
1603
    menubar = build_gtkmenu();
1599
1614
    g_signal_connect (G_OBJECT (canvasarea), "expose-event",  
1600
1615
        G_CALLBACK (expose_cb), NULL);
1601
1616
    g_signal_connect (G_OBJECT (canvasarea), "configure-event",  
1602
 
        G_CALLBACK (configure_cb), NULL);            
 
1617
        G_CALLBACK (configure_cb), NULL);
1603
1618
    g_signal_connect (G_OBJECT (canvasarea), "motion-notify-event",  
1604
1619
        G_CALLBACK (motion_cb), NULL);
1605
1620
    g_signal_connect (G_OBJECT (canvasarea), "button-press-event",  
1607
1622
    g_signal_connect (G_OBJECT (canvasarea), "button-release-event",  
1608
1623
        G_CALLBACK (button_release_cb), NULL);
1609
1624
    g_signal_connect (G_OBJECT (canvasarea), "popup-menu",  
1610
 
        G_CALLBACK (popup_cb), NULL);                   
 
1625
        G_CALLBACK (popup_cb), NULL);
1611
1626
 
1612
1627
    vscrollbar = gtk_vscrollbar_new(NULL);
1613
1628
    gtk_range_set_update_policy(GTK_RANGE(vscrollbar),
1623
1638
    gtk_range_set_range(GTK_RANGE(hscrollbar), -1.0, 1.0);
1624
1639
    gtk_range_set_increments(GTK_RANGE(hscrollbar), 0.01, 0.1);
1625
1640
    hscr_handler = g_signal_connect(G_OBJECT(hscrollbar), "value-changed",
1626
 
        G_CALLBACK(hscroll_cb), NULL);
 
1641
                                    G_CALLBACK(hscroll_cb), NULL);
1627
1642
 
1628
1643
    vte = vte_terminal_new();
1629
1644
    g_assert(vte);
1670
1685
    register Pixel *ptr;
1671
1686
  
1672
1687
        if( FBuffer ) 
1673
 
                free(FBuffer);
 
1688
                _ffree(FBuffer);
1674
1689
        size = (long)XRange*YRange*sizeof(Pixel);
1675
 
        FBuffer = (Pixel*)malloc( size+32 );
 
1690
        FBuffer = (Pixel*)_fmalloc( size+32 );
1676
1691
        
1677
1692
        return((FBuffer!=(Pixel*)NULL)?True : False);
1678
1693
}