DXFCON.C

Go to the documentation of this file.
00001 /* --
00002 OpenFX version 1.0 - Modelling, Animation and Rendering Package
00003 Copyright (C) 2000 OpenFX Development Team
00004 
00005 This program is free software; you can redistribute it and/or
00006 modify it under the terms of the GNU General Public License
00007 as published by the Free Software Foundation; either version 2
00008 of the License, or (at your option) any later version.
00009 
00010 This program is distributed in the hope that it will be useful,
00011 but WITHOUT ANY WARRANTY; without even the implied warranty of
00012 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00013 GNU General Public License for more details.
00014 
00015 You should have received a copy of the GNU General Public License
00016 along with this program; if not, write to the Free Software
00017 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
00018 
00019 You may contact the OpenFX development team via elecronic mail
00020 at core@openfx.org, or visit our website at http://openfx.org for
00021 further information and support details.
00022 -- */
00023 
00024 /* file dxcon.c */
00025 
00026 #include <windows.h>
00027 #include <commctrl.h>
00028 #include <stdlib.h>
00029 #include <stdarg.h>
00030 #include <math.h>
00031 
00032 #include "struct.h"
00033 #include "dstruct.h"
00034 #include "dxfcon.h"
00035 
00036 int  (*X__pri)(const char *,...);
00037 int  X__local_print(const char *,...);
00038 
00039 HWND      hWndParent;
00040 HINSTANCE hInstance;
00041 HWND dlg=NULL,hwndProgress=NULL;
00042 
00043 #if __WATCOMC__
00044 int APIENTRY LibMain(HANDLE hDLL, DWORD dwReason, LPVOID lpReserved){
00045 #elif __BCC__
00046 int APIENTRY DllEntryPoint(HANDLE hDLL, DWORD dwReason, LPVOID lpReserved){
00047 #else
00048 BOOL WINAPI DllMain(HANDLE hDLL, DWORD dwReason, LPVOID lpReserved){
00049 #endif
00050   switch (dwReason) {
00051     case DLL_PROCESS_ATTACH:
00052       hInstance=hDLL;
00053       break;
00054     case DLL_PROCESS_DETACH:
00055       break;
00056   }
00057   return TRUE;
00058 }
00059 
00060 BOOL CALLBACK DlgProc(HWND hwnd,UINT msg,WPARAM wparam,LPARAM lparam){
00061  switch( msg ) {
00062    case WM_INITDIALOG:
00063      hwndProgress=GetDlgItem(hwnd,DLG_PROGRESS);
00064      SendMessage(hwndProgress,PBM_SETRANGE,0,MAKELPARAM(0,99));
00065      SendMessage(hwndProgress,PBM_SETSTEP,(WPARAM)1,0);
00066      SendMessage(hwndProgress,PBM_SETPOS,(WPARAM)0,0);
00067      CentreDlgOnS(hwnd);
00068      break;
00069    default: break;
00070  }
00071  return( FALSE );
00072 }
00073 
00074 BOOL CALLBACK DlgProcSettings(HWND hwnd,UINT msg,WPARAM wparam,LPARAM lparam){
00075  char str[32];
00076  static struct bp {
00077    short h_type,l_freeze,b_freeze,no_weld,d2,d3,cs;
00078    double wt;
00079  } *dp;
00080  switch( msg ) {
00081    case WM_INITDIALOG:
00082      dp=(struct bp *)lparam;
00083      if(dp->h_type == 0)SendDlgItemMessage(hwnd,DLG_SET_HX,BM_SETCHECK,TRUE,0);
00084      if(dp->h_type == 1)SendDlgItemMessage(hwnd,DLG_SET_HL,BM_SETCHECK,TRUE,0);
00085      if(dp->h_type == 2)SendDlgItemMessage(hwnd,DLG_SET_HB,BM_SETCHECK,TRUE,0);
00086      if(dp->l_freeze == 1)SendDlgItemMessage(hwnd,DLG_SET_FL,BM_SETCHECK,TRUE,0);
00087      if(dp->no_weld == 0)SendDlgItemMessage(hwnd,DLG_SET_NW,BM_SETCHECK,TRUE,0);
00088      if(dp->d2 == 1)SendDlgItemMessage(hwnd,DLG_SET_D2,BM_SETCHECK,TRUE,0);
00089      sprintf(str,"%.4lf",dp->wt);
00090      SetDlgItemText(hwnd,DLG_SET_WT,(LPCTSTR)str);
00091      sprintf(str,"%ld",dp->cs);
00092      SetDlgItemText(hwnd,DLG_SET_CS,(LPCTSTR)str);
00093      CentreDlgOnS(hwnd);
00094      return (TRUE);
00095    case WM_COMMAND:
00096       switch(LOWORD(wparam)){
00097         case IDCANCEL:
00098           EndDialog(hwnd,FALSE);
00099           return(TRUE);
00100         case IDOK:
00101           if(SendDlgItemMessage(hwnd,DLG_SET_HX,BM_GETCHECK,0,0))
00102             dp->h_type=0;
00103           else if(SendDlgItemMessage(hwnd,DLG_SET_HL,BM_GETCHECK,0,0))
00104             dp->h_type=1;
00105           else if(SendDlgItemMessage(hwnd,DLG_SET_HB,BM_GETCHECK,0,0))
00106             dp->h_type=2;
00107           if(SendDlgItemMessage(hwnd,DLG_SET_FL,BM_GETCHECK,0,0))
00108                dp->l_freeze=1;
00109           else dp->l_freeze=0;
00110           if(SendDlgItemMessage(hwnd,DLG_SET_NW,BM_GETCHECK,0,0))
00111                dp->no_weld=0;
00112           else dp->no_weld=1;
00113           if(SendDlgItemMessage(hwnd,DLG_SET_D2,BM_GETCHECK,0,0))
00114                dp->d2=1;
00115           else dp->d2=0;
00116           if(GetDlgItemText(hwnd,DLG_SET_WT,str,10) == 0){
00117             EndDialog(hwnd,FALSE); return TRUE;
00118           }
00119           dp->wt=atof(str);
00120           if(GetDlgItemText(hwnd,DLG_SET_CS,str,10) == 0){
00121             EndDialog(hwnd,FALSE); return TRUE;
00122           }
00123           dp->cs=atoi(str);
00124           if(dp->cs < 3)dp->cs=3;
00125           EndDialog(hwnd,TRUE);
00126           return(TRUE);
00127         default: break;
00128       }
00129    default: break;
00130  }
00131  return( FALSE );
00132 }
00133 
00134 BOOL CALLBACK DlgProcScale(HWND hwnd,UINT msg,WPARAM wparam,LPARAM lparam){
00135  char str[32];
00136  static double *scale;
00137  switch( msg ) {
00138    case WM_INITDIALOG:
00139      scale = (double *)lparam;
00140      sprintf(str,"%.3le",*scale);
00141      SetDlgItemText(hwnd,DLG_SCALE_SCALE,(LPCTSTR)str);
00142      CentreDlgOnS(hwnd);
00143      return (TRUE);
00144    case WM_COMMAND:
00145       switch(LOWORD(wparam)){
00146         case IDCANCEL:
00147           EndDialog(hwnd,FALSE);
00148           return(TRUE);
00149         case IDOK:
00150           if(GetDlgItemText(hwnd,DLG_SCALE_SCALE,str,31) == 0){
00151             EndDialog(hwnd,FALSE); return TRUE;
00152           }
00153           sscanf(str,"%lf",scale);
00154           if(*scale < 1.e-10)*scale=1.e-10;
00155           EndDialog(hwnd,TRUE);
00156           return(TRUE);
00157         default: break;
00158       }
00159    default: break;
00160  }
00161  return( FALSE );
00162 }
00163 
00164 
00165 long _Convert(
00166      HWND parent,
00167      char *iname,
00168      char *oname,
00169      X__STRUCTURE *lpevi
00170                               ){
00171  long i,r;
00172  double wt = 0.0001;
00173  short h_type=0,l_freeze=0,b_freeze=0,no_weld=0,d2=0,
00174        d3=1,cs=15;
00175  struct bp {
00176    short h_type,l_freeze,b_freeze,no_weld,d2,d3,cs;
00177    double wt;
00178  } d;
00179  lpEVI=lpevi;
00180  hWndParent=parent;
00181  X__pri=X__local_print;
00182  d.h_type=h_type;
00183  d.l_freeze=l_freeze;
00184  d.b_freeze=b_freeze;
00185  d.no_weld=no_weld;
00186  d.d2=d2;
00187  d.d3=d3;
00188  d.cs=cs;
00189  d.wt=wt;
00190  if(!DialogBoxParam(hInstance,MAKEINTRESOURCE(DLG_SET),hWndParent,
00191                     (DLGPROC)DlgProcSettings,(LPARAM)&d))return 0;
00192  dlg=CreateDialog(hInstance,MAKEINTRESOURCE(DLG),parent,(DLGPROC)DlgProc);
00193  r=(long)DoDxfConvert(iname,oname,
00194                       d.wt,d.h_type,d.l_freeze,d.b_freeze,d.no_weld,
00195                       d.d2,d.d3,d.cs);
00196  if(dlg != NULL)DestroyWindow(dlg); dlg=NULL;
00197  return r;
00198 }
00199 
00200 int X__local_print(const char *format,...){
00201  char line[80];
00202  va_list arg_ptr;
00203  va_start(arg_ptr,format);
00204  vsprintf(line,format,arg_ptr);
00205  va_end(arg_ptr);
00206 // WindowedRenderString(line);
00207  return 1;
00208 }

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