3DSCON.C

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