⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 plot.c

📁 GESPI 2.0动态系统模拟工具  
💻 C
📖 第 1 页 / 共 2 页
字号:
#include "copyleft.h"

/*
    GEPASI - a simulator of metabolic pathways and other dynamical systems
    Copyright (C) 1989, 1992, 1993  Pedro Mendes
*/

/*************************************/
/*                                   */
/*         GWSIM - Simulation        */
/*        MS-WINDOWS front end       */
/*                                   */
/*            GNUPLOT shell          */
/*             dialog box            */
/*                                   */
/*           QuickC/WIN 1.0          */
/*                                   */
/*   (include here compilers that    */
/*   compiled GWSIM successfully)    */
/*                                   */
/*************************************/


#include <windows.h>
#include <string.h>
#include <io.h>
#include "globals.h"
#include "defines.h"
#include "strtbl.h"
#include "gwsim.h"
#include "simgvar.h"
#include "basic.h"
#include "gep2.h"

void AddXYZLst( HWND hControl, LPSTR text );
void plot_text( LPSTR Buff );
void label_dyn( int idx, LPSTR str );
void label_dat( int idx, LPSTR str );

#pragma alloc_text( CODE16, AddXYZLst, Plot, plot_text, label_dyn, label_dat, GnuPlot )


/* function to add column titles on the X, Y and Z lists	*/

void AddXYZLst( HWND hControl, LPSTR text )
{
 int i;
 WORD ElWidth;
 HANDLE hDC;

 hDC = GetDC( hControl );
 ElWidth = 5 + LOWORD( GetTextExtent( hDC, text, _fstrlen(text) ) );
 SetTextJustification( hDC, 0, 0 );
 ReleaseDC( hControl, hDC );
 if( ElWidth > lbWidth )
 {
  lbWidth = ElWidth;
  SendMessage( hControl, LB_SETHORIZONTALEXTENT, lbWidth, 0 );
 }
 SendMessage( hControl, LB_INSERTSTRING, -1, (DWORD) text );
}



/* Function for the Plot... dialog box	*/

int FAR PASCAL Plot(HWND hDlg, WORD Message, WORD wParam, LONG lParam)
{
 static HWND hX, hY, hZ, hZlog, hZtext, hDyn, hSs, hCont, hHidd;
 static int file, type;
 int  i,j;
 char auxstr[NAME_L+5];

 switch(Message)
 {
  case WM_INITDIALOG:
   /* save file and type							*/
   file = plot.file;
   type = plot.type;

   /* check if any data can be available			*/
   if( ( (totsel==0) ) && (!options.dyn) )
    SendMessage( hDlg, WM_COMMAND, IDCANCEL, 0 );

   /* get handles to controls						*/
   hX     = GetDlgItem( hDlg, IDC_X );
   hY     = GetDlgItem( hDlg, IDC_Y );
   hZ     = GetDlgItem( hDlg, IDC_Z );
   hZlog  = GetDlgItem( hDlg, IDRB_3E );
   hZtext = GetDlgItem( hDlg, IDSTAT_5 );
   hDyn   = GetDlgItem( hDlg, IDC_DYNAMICS );
   hSs    = GetDlgItem( hDlg, IDC_SS );
   hCont  = GetDlgItem( hDlg, IDRB_5E );
   hHidd  = GetDlgItem( hDlg, IDRB_5I );

   /* disable Z and check boxes if type is 2D */
   if( type==0 )
   {
    EnableWindow( hZ, FALSE );
    EnableWindow( hZlog, FALSE );
    EnableWindow( hZtext, FALSE );
    EnableWindow( hCont, FALSE );
    EnableWindow( hHidd, FALSE );
   }

   /* check the appropriate file radio button		*/
   if( ! options.dyn )
   {
    EnableWindow( hDyn, FALSE );
    file = 1;
   }
   if( totsel==0 )
   {
    EnableWindow( hSs, FALSE );
    file = 0;
   }

   if( file==0 )
    SendMessage( hDyn, BM_SETCHECK, (WORD) 1, 0 );
   else
    SendMessage( hSs, BM_SETCHECK, (WORD) 1, 0 );


   /* check the appropriate type radio button		*/
   SendDlgItemMessage( hDlg, IDRB_0E+plot.type, BM_SETCHECK, (WORD) 1, 0 );

   /* check boxes									*/
   SendDlgItemMessage( hDlg, IDRB_4E, BM_SETCHECK, (WORD) plot.lines, 0 );
   SendDlgItemMessage( hDlg, IDRB_2E, BM_SETCHECK, (WORD) plot.logx, 0 );
   SendDlgItemMessage( hDlg, IDRB_2I, BM_SETCHECK, (WORD) plot.logy, 0 );
   SendDlgItemMessage( hDlg, IDRB_3E, BM_SETCHECK, (WORD) plot.logz, 0 );
   SendDlgItemMessage( hDlg, IDRB_4I, BM_SETCHECK, (WORD) plot.colour, 0 );
   SendDlgItemMessage( hDlg, IDRB_5E, BM_SETCHECK, (WORD) plot.contour, 0 );
   SendDlgItemMessage( hDlg, IDRB_5I, BM_SETCHECK, (WORD) plot.hidden, 0 );

   /* initialize hX, hY and hZ: add all columns		*/
   if( file==1 )
   {
    if( plot.ny > totsel )
     plot.ny = 0;
    else
     for(i=0; i<plot.ny; i++ )
      if( plot.y[i] > totsel )
       for( j=i; j<plot.ny; j++ )
       {
        plot.y[j] = plot.y[j+1];
        i--;
       }
    for( i=0, lbWidth=0; i<totsel; i++ )
     for( j=0; j<noutpel; j++ )
      if( (outpel[j].idx-1) == (unsigned int) i )
      {
       AddElLst( hX, outpel, j, FALSE );
       AddElLst( hY, outpel, j, FALSE );
       AddElLst( hZ, outpel, j, FALSE );
      }
   }
   else
   {
    lbWidth=0;
    AddXYZLst( hX, (LPSTR) "time" );
    AddXYZLst( hY, (LPSTR) "time" );
    AddXYZLst( hZ, (LPSTR) "time" );
    for( i=0; i<nmetab; i++ )
    {
     wsprintf( (LPSTR) auxstr, "[%s]", (LPSTR) metname[i] );
     AddXYZLst( hX, (LPSTR) auxstr );
     AddXYZLst( hY, (LPSTR) auxstr );
     AddXYZLst( hZ, (LPSTR) auxstr );
    }
    for( i=0; i<nsteps; i++ )
    {
     wsprintf( (LPSTR) auxstr, "J(%s)", (LPSTR) stepname[i] );
     AddXYZLst( hX, (LPSTR) auxstr );
     AddXYZLst( hY, (LPSTR) auxstr );
     AddXYZLst( hZ, (LPSTR) auxstr );
    }
   }

   /* highlight the current selections			*/
   SendMessage( hX, LB_SETCURSEL, (WORD) plot.x, 0 );
   SendMessage( hZ, LB_SETCURSEL, (WORD) plot.z, 0 );
   for( i=0; i<plot.ny; i++)
    SendMessage( hY, LB_SELITEMRANGE, 1, MAKELONG( plot.y[i], plot.y[i] ) );

   /* cause a WM_PAINT to be sent to the window	*/
   InvalidateRect( hDlg, NULL, FALSE );
   return TRUE;

  case WM_COMMAND:
   switch(wParam)
   {
    case IDC_Y:
     if( HIWORD( lParam ) == LBN_SELCHANGE )
     {
      if( type!=0 )
      {
       for( i=0; i<plot.ny; i++ )
        SendMessage( hY, LB_SELITEMRANGE, 0, MAKELONG( plot.y[i], plot.y[i] ) );
      }
      plot.ny = (int) SendMessage( hY, LB_GETSELITEMS, (WORD) 10, (DWORD) (int huge *) plot.y );
     }
     return TRUE;


    case IDRB_0E:
     if( SendDlgItemMessage( hDlg, IDRB_0E, BM_GETCHECK, 0, 0 ) )
     {
      type = 0;
      SendMessage( hZ, LB_SETCURSEL, -1, 0 );
      EnableWindow( hZ, FALSE );
      EnableWindow( hZlog, FALSE );
      EnableWindow( hZtext, FALSE );
      EnableWindow( hCont, FALSE );
      EnableWindow( hHidd, FALSE );
      InvalidateRect( hDlg, NULL, FALSE );
     }
     return TRUE;

    case IDRB_0I:
     if( SendDlgItemMessage( hDlg, IDRB_0I, BM_GETCHECK, 0, 0 ) )
      if( type == 0 )
      {
       plot.ny = (int) SendMessage( hY, LB_GETSELITEMS, (WORD) 10, (DWORD) (int huge *) plot.y );
       for( i=0; i<plot.ny; i++ )
        SendMessage( hY, LB_SELITEMRANGE, 0, MAKELONG( plot.y[i], plot.y[i] ) );
       EnableWindow( hZ, TRUE );
       EnableWindow( hZlog, TRUE );
       EnableWindow( hZtext, TRUE );
       EnableWindow( hCont, TRUE );
       EnableWindow( hHidd, TRUE );
       InvalidateRect( hDlg, NULL, FALSE );
      }
      type = 1;
     return TRUE;

    case IDC_SS:
     if(  ( SendDlgItemMessage( hDlg, IDC_SS, BM_GETCHECK, 0, 0 ) )
        &&
          ( file==0 )
       )
     {
      file=1;
      SendMessage( hX, LB_RESETCONTENT, 0, 0 );
      SendMessage( hY, LB_RESETCONTENT, 0, 0 );
      SendMessage( hZ, LB_RESETCONTENT, 0, 0 );
      for( i=0, lbWidth=0; i<totsel; i++ )
       for( j=0; j<noutpel; j++ )
        if( (outpel[j].idx-1) == (unsigned int) i )
        {
         AddElLst( hX, outpel, j, FALSE );
         AddElLst( hY, outpel, j, FALSE );
         AddElLst( hZ, outpel, j, FALSE );
        }
     }
     return TRUE;

    case IDC_DYNAMICS:
     if(  ( SendDlgItemMessage( hDlg, IDC_DYNAMICS, BM_GETCHECK, 0, 0 ) )
        &&
          ( file==1 )
       )
     {
      file=0;
      SendMessage( hX, LB_RESETCONTENT, 0, 0 );
      SendMessage( hY, LB_RESETCONTENT, 0, 0 );
      SendMessage( hZ, LB_RESETCONTENT, 0, 0 );
      lbWidth=0;
      AddXYZLst( hX, (LPSTR) "time" );
      AddXYZLst( hY, (LPSTR) "time" );
      AddXYZLst( hZ, (LPSTR) "time" );
      for( i=0; i<nmetab; i++ )
      {
       wsprintf( (LPSTR) auxstr, "[%s]", (LPSTR) metname[i] );
       AddXYZLst( hX, (LPSTR) auxstr );
       AddXYZLst( hY, (LPSTR) auxstr );
       AddXYZLst( hZ, (LPSTR) auxstr );
      }

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -