3DSCON.C

Go to the documentation of this file.
00001 /* --
00002 OpenFX version 2.4 - Modelling, Animation and Rendering Package
00003 Copyright (C) 2000 - 2014 OpenFX Development Team
00004 -- */
00005 
00006 /* file 3dscon.c */
00007 
00008 #include <windows.h>
00009 #include <commctrl.h>
00010 
00011 #include <stdlib.h>
00012 #include <stdarg.h>
00013 #include <stdio.h>
00014 #include <math.h>
00015 #include <fcntl.h>
00016 #include <io.h>
00017 #include <string.h>
00018 #include <ctype.h>
00019 #include <sys\types.h>
00020 #include <sys\stat.h>
00021 
00022 
00023 #define _DSTRUCT_MAIN 1
00024 
00025 #include "struct.h"
00026 #include "dstruct.h"
00027 #include "3dscon.h"
00028 
00029 int  (*X__pri)(const char *,...);
00030 int  X__local_print(const char *,...);
00031 
00032 HWND      dlg=NULL;
00033 HWND      hWndParent;
00034 HWND      hWndProgress=NULL;
00035 HINSTANCE hInstance;
00036 long      file_size=1;
00037 
00038 #if __WATCOMC__
00039 int APIENTRY LibMain(HANDLE hDLL, DWORD dwReason, LPVOID lpReserved){
00040 #elif __BCC__
00041 int APIENTRY DllEntryPoint(HANDLE hDLL, DWORD dwReason, LPVOID lpReserved){
00042 #else
00043 BOOL WINAPI DllMain(HANDLE hDLL, DWORD dwReason, LPVOID lpReserved){
00044 #endif
00045   switch (dwReason) {
00046     case DLL_PROCESS_ATTACH:
00047       hInstance=hDLL;
00048       break;
00049     case DLL_PROCESS_DETACH:
00050       break;
00051   }
00052   return TRUE;
00053 }
00054 
00055 BOOL CALLBACK DlgProc(HWND hwnd,UINT msg,WPARAM wparam,LPARAM lparam){
00056  switch( msg ) {
00057    case WM_INITDIALOG:
00058      hWndProgress=GetDlgItem(hwnd,DLG_PROGRESS);
00059      SendMessage(hWndProgress,PBM_SETRANGE,0,MAKELPARAM(0,99));
00060      SendMessage(hWndProgress,PBM_SETSTEP,(WPARAM)1,0);
00061      SendMessage(hWndProgress,PBM_SETPOS,(WPARAM)0,0);
00062      CentreDlgOnS(hwnd);
00063      break;
00064    default: break;
00065  }
00066  return( FALSE );
00067 }
00068 
00069 BOOL CALLBACK DlgProcScale(HWND hwnd,UINT msg,WPARAM wparam,LPARAM lparam){
00070  char str[32];
00071  static struct SC {double scale,xc,yc,zc,c;} *Sc;
00072  switch( msg ) {
00073    case WM_INITDIALOG:
00074      Sc = (struct SC *)lparam;
00075      sprintf(str,"%.3le",Sc->scale);
00076      SetDlgItemText(hwnd,DLG_SCALE_SCALE,(LPCTSTR)str);
00077      sprintf(str,"%.1le",Sc->xc);
00078      SetDlgItemText(hwnd,DLG_SCALE_XCEN,(LPCTSTR)str);
00079      sprintf(str,"%.1le",Sc->yc);
00080      SetDlgItemText(hwnd,DLG_SCALE_YCEN,(LPCTSTR)str);
00081      sprintf(str,"%.1le",Sc->zc);
00082      SetDlgItemText(hwnd,DLG_SCALE_ZCEN,(LPCTSTR)str);
00083      if(Sc->c == 1)SendDlgItemMessage(hwnd,DLG_SCALE_CEN,BM_SETCHECK,TRUE,0);
00084      CentreDlgOnS(hwnd);
00085      return (TRUE);
00086    case WM_COMMAND:
00087       switch(LOWORD(wparam)){
00088         case IDCANCEL:
00089           EndDialog(hwnd,FALSE);
00090           return(TRUE);
00091         case IDOK:
00092           if(SendDlgItemMessage(hwnd,DLG_SCALE_CEN,BM_GETCHECK,0,0))Sc->c=1;
00093           else Sc->c=0;
00094           if(GetDlgItemText(hwnd,DLG_SCALE_SCALE,str,31) == 0){
00095             EndDialog(hwnd,FALSE); return TRUE;
00096           }
00097           sscanf(str,"%lf",&(Sc->scale));
00098           if(Sc->scale < 1.e-10)Sc->scale=1.e-10;
00099           if(GetDlgItemText(hwnd,DLG_SCALE_XCEN,str,31) == 0){
00100             EndDialog(hwnd,FALSE); return TRUE;
00101           }
00102           sscanf(str,"%lf",&(Sc->xc));
00103           if(GetDlgItemText(hwnd,DLG_SCALE_YCEN,str,31) == 0){
00104             EndDialog(hwnd,FALSE); return TRUE;
00105           }
00106           sscanf(str,"%lf",&(Sc->yc));
00107           if(GetDlgItemText(hwnd,DLG_SCALE_ZCEN,str,31) == 0){
00108             EndDialog(hwnd,FALSE); return TRUE;
00109           }
00110           sscanf(str,"%lf",&(Sc->zc));
00111           EndDialog(hwnd,TRUE);
00112           return(TRUE);
00113         default: break;
00114       }
00115    default: break;
00116  }
00117  return( FALSE );
00118 }
00119 
00120 void UpdateProgress(FILE *dxfp){
00121  long p;
00122  if(hWndProgress == NULL)return;
00123  p=ftell(dxfp);
00124  p=(p*100)/file_size;
00125  SendMessage(hWndProgress,PBM_SETPOS,(WPARAM)p,0);
00126  Sleep(0);
00127  return;
00128 }
00129 
00130 long _Convert(
00131      HWND parent,
00132      char *iname,
00133      char *oname,
00134      X__STRUCTURE *lpevi
00135                               ){
00136  char *s[32];
00137  long i,r;
00138  int fhandle;
00139  lpEVI=lpevi;
00140  if(lpEVI == NULL)MessageBox(NULL,"Bad Pointer 1",NULL,MB_OK);
00141 
00142  hWndParent=parent;
00143  if((fhandle=open(iname,O_RDONLY)) >= 0){
00144    struct stat buffer;
00145    if(fstat(fhandle,&buffer) == 0){
00146      file_size=buffer.st_size;
00147    }
00148    else MessageBox(NULL,"File size",NULL,MB_OK);
00149    close(fhandle);
00150  }
00151  else MessageBox(NULL,"Open for size",NULL,MB_OK);
00152 
00153  X__pri=X__local_print;
00154  for(i=1;i<3;i++)s[i]=X__Malloc(256);
00155  strcpy(s[1],iname);
00156  strcpy(s[2],oname);
00157  dlg=CreateDialog(hInstance,MAKEINTRESOURCE(DLG),parent,(DLGPROC)DlgProc);
00158  r=(long)Do3dsConvert(3,s);
00159  if(dlg != NULL)DestroyWindow(dlg);
00160  for(i=1;i<3;i++)X__Free(s[i]);
00161  return r;
00162 }
00163 
00164 int X__local_print(const char *format,...){
00165  char line[80];
00166  va_list arg_ptr;
00167  va_start(arg_ptr,format);
00168  vsprintf(line,format,arg_ptr);
00169  va_end(arg_ptr);
00170 // WindowedRenderString(line);
00171  return 1;
00172 }

Generated on Sun Apr 27 14:20:10 2014 for OpenFX by  doxygen 1.5.6