/**********************************************************************************/
/*                                                                                */
/*  DLG_3DAG - dialog callbacks for 3DAG parameter dialogs                        */
/*                                                                                */
/**********************************************************************************/

#define STRICT
#include <windows.h>
#include <commctrl.h>
#include <assert.h>
#include <stdlib.h>
#include <stdio.h>
#include <math.h>
#include <string.h>
#include <ctype.h>
#include "const.h"
#include "classes.h"
#include "funcdefs.h"
#include "lin.rh"
#include "extern.h"


extern "C"

INT_PTR CALLBACK Dialog3DAGParams ( HWND hdwnd , UINT message ,
                                    WPARAM wParam , LPARAM /* lParam */ )
{
   int id ;
   char msg[2048] ;

   switch ( message ) {
      
      case WM_INITDIALOG:
         SetDlgItemInt ( hdwnd , IDC_IMAGE_ROWS , AG3D_params.nrows , TRUE ) ;
         SetDlgItemInt ( hdwnd , IDC_IMAGE_COLS , AG3D_params.ncols , TRUE ) ;
         SetDlgItemInt ( hdwnd , IDC_LINE_WIDTH , AG3D_params.width , TRUE ) ;
         SetDlgItemInt ( hdwnd , IDC_DEPTH , AG3D_params.depth , TRUE ) ;
         sprintf_s ( msg , "%.2lf", AG3D_params.angle ) ;
         SetDlgItemText ( hdwnd , IDC_ANGLE , msg ) ;
         sprintf_s ( msg , "%.2lf", AG3D_params.shrink ) ;
         SetDlgItemText ( hdwnd , IDC_SHRINK , msg ) ;
         sprintf_s ( msg , "%.2lf", AG3D_params.azimuth ) ;
         SetDlgItemText ( hdwnd , IDC_AZIMUTH , msg ) ;
         sprintf_s ( msg , "%.2lf", AG3D_params.elevation ) ;
         SetDlgItemText ( hdwnd , IDC_ELEVATION , msg ) ;
         sprintf_s ( msg , "%.2lf", AG3D_params.stepsize ) ;
         SetDlgItemText ( hdwnd , IDC_STEPSIZE , msg ) ;
         return TRUE ;
         
      case WM_COMMAND:
         id = LOWORD ( wParam ) ;
         switch ( id ) {
            case IDOK:
               AG3D_params.bad_rule = 0 ;
               AG3D_params.nrows = GetDlgItemInt ( hdwnd , IDC_IMAGE_ROWS , NULL , FALSE ) ;
               AG3D_params.ncols = GetDlgItemInt ( hdwnd , IDC_IMAGE_COLS , NULL , FALSE ) ;
               AG3D_params.width = GetDlgItemInt ( hdwnd , IDC_LINE_WIDTH , NULL , FALSE ) ;
               AG3D_params.depth = GetDlgItemInt ( hdwnd , IDC_DEPTH , NULL , FALSE ) ;
               GetDlgItemText ( hdwnd , IDC_ANGLE , msg , 2048 ) ;
               AG3D_params.angle = atof ( msg ) ;
               GetDlgItemText ( hdwnd , IDC_SHRINK , msg , 2048 ) ;
               AG3D_params.shrink = atof ( msg ) ;
               GetDlgItemText ( hdwnd , IDC_AZIMUTH , msg , 2048 ) ;
               AG3D_params.azimuth = atof ( msg ) ;
               GetDlgItemText ( hdwnd , IDC_ELEVATION , msg , 2048 ) ;
               AG3D_params.elevation = atof ( msg ) ;
               GetDlgItemText ( hdwnd , IDC_STEPSIZE , msg , 2048 ) ;
               AG3D_params.stepsize = atof ( msg ) ;
               EndDialog ( hdwnd , TRUE ) ;
               return TRUE ;  // Tell Windows we processed this message
            case IDCANCEL:
               EndDialog ( hdwnd , FALSE ) ;
               return TRUE ;  // Tell Windows we processed this message
            }
      }
      
   return FALSE ;  // Tell Windows we did not process this message
}
