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

« back to all changes in this revision

Viewing changes to src/raswin.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 *
71
77
 *package and for license terms (GPL or RASLIC).                           *
72
78
 ***************************************************************************/
73
79
/* raswin.c
74
 
 $Log: raswin.c,v $
 
80
 $Log$
 
81
 Revision 1.8  2008/06/27 02:47:58  yaya
 
82
 Finished update of windows code for 32-bit color -- HJB
 
83
 
 
84
 Revision 1.7  2008/06/11 01:40:54  yaya
 
85
 Improve gradient for map surfaces and brighten image;
 
86
 Add parenthesized selections before all commands;
 
87
 Change saveSelection and loadSelection to
 
88
 SaveAtomSelection and LoadAtomSelection -- HJB
 
89
 
75
90
 Revision 1.6  2008/03/22 17:06:49  yaya
76
91
 Post release cleanup with credits to Ikonen in file headers. -- HJB
77
92
 
1393
1408
    register int i; 
1394
1409
   
1395
1410
    if( format==CF_PALETTE )
 
1411
#ifdef EIGHTBIT
1396
1412
    {   if( ColourMap )
1397
1413
        {   return CreatePalette(Palette);
1398
1414
        } else return NULL;
1399
 
    }    
 
1415
    }
 
1416
#else
 
1417
      return NULL;
 
1418
#endif
1400
1419
    
1401
1420
    if( !PixMap || (format!=CF_DIB) )
1402
1421
        return NULL;
1403
1422
 
1404
1423
    len = (long)XRange*YRange*sizeof(Pixel);
1405
 
    size = sizeof(BITMAPINFOHEADER) + 256*sizeof(RGBQUAD);
 
1424
#ifdef EIGHTBIT
 
1425
    size = sizeof(BITMAPINFOHEADER)  + 256*sizeof(RGBQUAD);
 
1426
#else
 
1427
    size = sizeof(BITMAPINFOHEADER);
 
1428
#endif
1406
1429
    if( !(result=GlobalAlloc(GHND,size+len)) ) return NULL;
1407
1430
    
1408
1431
    bitmap = (BITMAPINFO __far *)GlobalLock(result);
1410
1433
    bitmap->bmiHeader.biWidth = XRange;
1411
1434
    bitmap->bmiHeader.biHeight = YRange;
1412
1435
    bitmap->bmiHeader.biPlanes = 1;
 
1436
#ifdef EIGHTBIT
1413
1437
    bitmap->bmiHeader.biBitCount = 8;
 
1438
#else
 
1439
    bitmap->bmiHeader.biBitCount = 32;
 
1440
#endif
1414
1441
    bitmap->bmiHeader.biCompression = BI_RGB;
1415
1442
    bitmap->bmiHeader.biSizeImage = len;
1416
1443
    bitmap->bmiHeader.biXPelsPerMeter = 0;
1418
1445
    bitmap->bmiHeader.biClrImportant = 0;
1419
1446
    bitmap->bmiHeader.biClrUsed = 0;
1420
1447
    
 
1448
#ifdef EIGHTBIT
1421
1449
    for( i=0; i<256; i++ )
1422
1450
        if( ULut[i] )
1423
1451
        {   bitmap->bmiColors[Lut[i]].rgbBlue  = BLut[i];
1424
1452
            bitmap->bmiColors[Lut[i]].rgbGreen = GLut[i];
1425
1453
            bitmap->bmiColors[Lut[i]].rgbRed   = RLut[i];
1426
1454
        }
1427
 
    
 
1455
#endif
1428
1456
   
1429
1457
    src = (Pixel __huge*)GlobalLock(FBufHandle);
 
1458
#ifdef EIGHTBIT
1430
1459
    dst = ((Pixel __huge*)bitmap)+size;
 
1460
#else
 
1461
    dst = ((Pixel __huge*)bitmap)+size/4;
 
1462
#endif
1431
1463
    
1432
1464
    /* Transfer the frame buffer */
1433
1465
    while( len-- ) *dst++ = *src++;
1733
1765
 
1734
1766
void RefreshScreen( void )
1735
1767
{
 
1768
    int ReDrawFlagSave;
1736
1769
    ReDrawFlag &= ~RFTransZ;
1737
1770
 
1738
 
    if( ReDrawFlag )
1739
 
    {   if( RasWinDDEReady )
1740
 
        {   RasWinDDEReady = False;
1741
 
            AdviseUpdate( -4 );
1742
 
        }
 
1771
    if( ReDrawFlag ) {
 
1772
      if( RasWinDDEReady ) {
 
1773
          RasWinDDEReady = False;
 
1774
              AdviseUpdate( -4 );
 
1775
          }
1743
1776
        
1744
 
        if( ReDrawFlag & RFReSize )
 
1777
          if( ReDrawFlag & RFReSize )
1745
1778
            ReSizeScreen();
1746
1779
 
1747
 
        if( ReDrawFlag & RFColour )
1748
 
        {   ClearImage();
1749
 
            DefineColourMap();
1750
 
        }
 
1780
          if( ReDrawFlag & RFColour )
 
1781
          {   ClearImage();
 
1782
              DefineColourMap();
 
1783
          }
1751
1784
 
1752
 
        if( Database )
1753
 
        {   BeginWait();
1754
 
            if( ReDrawFlag & RFApply ) 
1755
 
                ApplyTransform();
1756
 
            DrawFrame();
1757
 
            TransferImage();
1758
 
            EndWait();
1759
 
        } else
1760
 
        {   ClearBuffers();
1761
 
            TransferImage();
1762
 
        }
1763
 
        ReDrawFlag = 0;
 
1785
      NextReDrawFlag = 0;
 
1786
      ReDrawFlagSave = ReDrawFlag;
 
1787
          if( Database )
 
1788
          {   BeginWait();
 
1789
              if( ReDrawFlag & RFApply ) 
 
1790
                  ApplyTransform();
 
1791
              DrawFrame();
 
1792
              TransferImage();
 
1793
              EndWait();
 
1794
          } else
 
1795
          {   ClearBuffers();
 
1796
              TransferImage();
 
1797
          }
 
1798
          if ((ReDrawFlagSave & RFApply) && record_on[0] && !RecordPause ) {
 
1799
              WriteMovieFrame();
 
1800
              record_frame[0]++;
 
1801
              record_frame[1] = 0;
 
1802
          } else if ((ReDrawFlagSave & RFAppear) && record_on[1] && !RecordPause) {
 
1803
              WriteMovieFrame();
 
1804
              record_frame[0]++;
 
1805
              record_frame[1]++;
 
1806
              if ((double)(record_frame[1]) <= record_fps*record_dwell) {
 
1807
                NextReDrawFlag |= RFRefresh;
 
1808
              } else {
 
1809
                NextReDrawFlag = 0;
 
1810
                record_frame[1] = 0;
 
1811
              }
 
1812
          }
1764
1813
    }
1765
1814
}
1766
1815
 
1973
2022
                    if( (stat==IPC_Quit) || (stat==IPC_Exit) )
1974
2023
                        RasMolExit();
1975
2024
 
1976
 
                    if( ReDrawFlag )
1977
 
                        RefreshScreen();
 
2025
                    if( ReDrawFlag ) {
 
2026
                            RefreshScreen();
 
2027
                        ReDrawFlag = NextReDrawFlag;
 
2028
                    }
 
2029
                    
1978
2030
                    if( !CommandActive )
1979
2031
                        ResetCommandLine(0);
1980
2032
                    return 0L;
2017
2069
    if ( (RotMode == RotBond) && BondSelected)
2018
2070
        BondSelected->BRotValue = temp;
2019
2071
    else if ( RotMode == RotAll )
2020
 
        WRotValue[1] = temp;
 
2072
        WorldDialValue[1] = temp;
2021
2073
    else
2022
2074
        DialValue[1] = temp;
2023
2075
    ReDrawFlag |= RFRotateY;
2028
2080
    float temp = 1.0-(pos/50.0);
2029
2081
 
2030
2082
    if ( RotMode == RotAll )
2031
 
        WRotValue[0] = temp;
 
2083
        WorldDialValue[DialRX] = temp;
2032
2084
    else
2033
 
        DialValue[0] = temp;
 
2085
        DialValue[DialRX] = temp;
2034
2086
    ReDrawFlag |= RFRotateX;
2035
2087
}
2036
2088
 
2207
2259
         default:  return DefWindowProc(hWin,uMsg,wArg,lArg);
2208
2260
    }
2209
2261
 
2210
 
    if( ReDrawFlag )
2211
 
        RefreshScreen();
 
2262
    if( ReDrawFlag ) {
 
2263
          RefreshScreen();
 
2264
      ReDrawFlag = NextReDrawFlag;
 
2265
    }
2212
2266
    if( !CommandActive )
2213
2267
        ResetCommandLine(0);
2214
2268
    return 0L;
3038
3092
    register int pos,status;
3039
3093
    register int x,y;
3040
3094
 
3041
 
    register COLORREF BackColRef;    
 
3095
    register COLORREF BackColRef;
 
3096
#ifdef EIGHTBIT    
3042
3097
    register HPALETTE hCMap;
 
3098
#endif
3043
3099
    register HANDLE hand;
3044
3100
    register HDC hMemDC;
3045
3101
    register HDC hDC;
3093
3149
#endif
3094
3150
 
3095
3151
        case(WM_QUERYNEWPALETTE):
 
3152
#ifdef EIGHTBIT
3096
3153
                              if( ColourMap )
3097
3154
                              {   hDC = GetDC(hWin);
3098
3155
                                  hCMap = SelectPalette(hDC,ColourMap,False);
3099
3156
                                  status = RealizePalette(hDC);
3100
3157
                                  if( hCMap ) SelectPalette(hDC,hCMap,False);
3101
3158
                                  ReleaseDC(hWin,hDC);
3102
 
                                  
3103
3159
                                  if( status )
3104
3160
                                  {   InvalidateRect(hWin,NULL,True);
3105
3161
                                      return True;
3106
3162
                                  }
3107
3163
                              }
 
3164
#endif
3108
3165
                              return 0L;
3109
3166
                              
3110
3167
        case(WM_PALETTECHANGED):
 
3168
#ifdef EIGHTBIT
3111
3169
                              if( ColourMap && ((HWND)wArg != hWin) )
3112
3170
                              {   hDC = GetDC(hWin);
3113
3171
                                  hCMap = SelectPalette(hDC,ColourMap,False);
3116
3174
                                  if( hCMap ) SelectPalette(hDC,hCMap,False);
3117
3175
                                  ReleaseDC(hWin,hDC);
3118
3176
                              }
 
3177
#endif
3119
3178
                              return 0L;
3120
3179
                                                     
3121
3180
        case(WM_INITMENUPOPUP):  /* Initialise Checks */
3235
3294
        
3236
3295
        case(WM_PAINT):       hDC = BeginPaint(hWin,&ps);
3237
3296
                              SetBkMode(hDC,TRANSPARENT);
 
3297
#ifdef EIGHTBIT
3238
3298
                              if( PixMap )
3239
3299
                              {   hCMap = SelectPalette(hDC,ColourMap,False);
3240
3300
                                  RealizePalette(hDC);
 
3301
#endif
3241
3302
#ifdef _WIN32
3242
3303
                                  SetWindowOrgEx(hDC,0,0,NULL);
3243
3304
#else
3248
3309
                                  BitBlt(hDC,0,0,XRange,YRange,
3249
3310
                                         hMemDC,0,0,SRCCOPY);
3250
3311
                                         
3251
 
                                  SelectPalette(hDC,hCMap,False);      
 
3312
#ifdef EIGHTBIT
 
3313
                                  SelectPalette(hDC,hCMap,False);
 
3314
#endif      
3252
3315
                                  DeleteDC(hMemDC);
 
3316
#ifdef EIGHTBIT
3253
3317
                              } else /* Erase Update Region */
3254
 
                              {    if( ColourMap )
 
3318
#endif
 
3319
                              {
 
3320
#ifdef EIGHTBIT
 
3321
                               if( ColourMap )
3255
3322
                                   {   hCMap=SelectPalette(hDC,ColourMap,0);
 
3323
                                   BackColRef = RGB(BackR,BackG,BackB);
3256
3324
                                       RealizePalette(hDC);
 
3325
                                   } else {
 
3326
                                           BackColRef = RGB(0,0,0);
3257
3327
                                   }
 
3328
#else
3258
3329
                                   BackColRef = RGB(BackR,BackG,BackB);
 
3330
#endif
3259
3331
                                   hand = CreateSolidBrush(BackColRef);
3260
3332
                                   GetUpdateRect(hWin,&rc,False);
3261
3333
                                   FillRect( hDC, &rc, hand );
 
3334
#ifdef EIGHTBIT
3262
3335
                                   if( ColourMap && hCMap )
3263
3336
                                       SelectPalette(hDC,hCMap,False);
 
3337
#endif
3264
3338
                                   DeleteObject(hand);
3265
3339
                              }
3266
3340
                              EndPaint(hWin,&ps);
3341
3415
 
3342
3416
    }
3343
3417
        
3344
 
    if( ReDrawFlag )
3345
 
        RefreshScreen();
 
3418
    if( ReDrawFlag ) {
 
3419
          RefreshScreen();
 
3420
      ReDrawFlag = NextReDrawFlag;
 
3421
    }
 
3422
    
3346
3423
    if( !CommandActive )
3347
3424
        ResetCommandLine(0);    
3348
3425
    return 0L;
3884
3961
    }
3885
3962
 
3886
3963
    RefreshScreen();
 
3964
    ReDrawFlag = NextReDrawFlag;
3887
3965
    if( !CommandActive )
3888
3966
        ResetCommandLine(0);
3889
3967