FigureToFile.c File Reference

#include "FigureToFile.h"
#include "win_mem_alloc.h"
#include "../../../modules/graphics/includes/xs2file.h"

Include dependency graph for FigureToFile.c:

Go to the source code of this file.

Defines

#define stricmp   _stricmp

Functions

void ExportBMP (struct BCG *ScilabGC, char *pszflname)
void ExportEMF (struct BCG *ScilabGC, char *pszflname)
BOOL ExportStyle (struct BCG *ScilabGC)
void CallTranslateMacroGraphicWindow (char *string)
static void ModifyFilenameExtension (char *Filename, char *ext)
void SavePs (struct BCG *ScilabGC)
void dos2win32 (char *filename, char *filename1)
char * GetFileExtension (char *filename)

Variables

LS ls


Define Documentation

#define stricmp   _stricmp

Definition at line 9 of file FigureToFile.c.

Referenced by C2F(), Console_Main(), DumpExternals(), DumpROMFObjFile(), ModifyFilenameExtension(), TestRegistryKey(), and Windows_Main().


Function Documentation

void CallTranslateMacroGraphicWindow ( char *  string  ) 

Definition at line 281 of file wgmenu.c.

References TranslateMacro().

Referenced by SavePs().

00282 {
00283         TranslateMacro(string);
00284 }

Here is the call graph for this function:

Here is the caller graph for this function:

static void dos2win32 ( char *  filename,
char *  filename1 
)

Definition at line 190 of file FigureToFile.c.

Referenced by main(), PrintPs(), and SavePs().

00191 {
00192 #ifdef CVT_PATH_BEG
00193   if (filename[1] == ':')
00194     {
00195       *filename1++ = '/';
00196       *filename1++ = '/';
00197       *filename1++ = *filename++;
00198       filename++;
00199     }
00200 #endif
00201   while (*filename != '\0')
00202     {
00203       *filename1++ = *filename++;
00204       if (*(filename1 - 1) == '\\')
00205         *(filename1 - 1) = '/';
00206     }
00207   *filename1 = '\0';
00208 }

Here is the caller graph for this function:

void ExportBMP ( struct BCG ScilabGC,
char *  pszflname 
)

Definition at line 332 of file ExportBmpEmf.c.

00333 {
00334         LPGW lpgw;
00335         HBITMAP hBitmap;
00336         HDC hmemDC=NULL;
00337         HWND hwnd;
00338         HDC hdc=NULL;
00339         integer SaveCurrentWindow=0;
00340 
00341 
00342         Setscig_buzyState(TRUE);
00343 
00344         SaveCurrentWindow=GetCurrentFigureWindows();
00345         SetCurrentFigureWindows (ScilabGC->CurWindow);
00346 
00347         /* view the window */
00348         lpgw = ScilabGC->lpgw;
00349         hwnd = ScilabGC->CWindow;
00350 
00351         if (IsIconic (hwnd)) ShowWindow (hwnd, SW_SHOWNORMAL);
00352         BringWindowToTop (hwnd);
00353         UpdateWindow (hwnd);
00354 
00355         SetActiveWindow(ScilabGC->hWndParent);      
00356         
00357         /* get the context */
00358         hdc = TryToGetDC (hwnd);
00359 
00360         /* make a bitmap and copy it there */
00361         if (hdc)
00362         {
00364                         scig_replay_hdc ('C', ScilabGC->CurWindow, hdc,ScilabGC->CWindowWidth,ScilabGC->CWindowHeight, 1);
00365                         ReleaseDC (hwnd, hdc);
00366 
00367                         hmemDC = CreateCompatibleDC (hdc);
00368                         hBitmap = CreateCompatibleBitmap (hdc,ScilabGC->CWindowWidth,ScilabGC->CWindowHeight);
00369 
00370                         if (hBitmap)
00371                         {
00372                                 POINT DCSize;
00373                                 SelectBitmap (hmemDC, hBitmap);
00374                                 scig_replay_hdc ('C', ScilabGC->CurWindow, hmemDC,ScilabGC->CWindowWidth,ScilabGC->CWindowHeight, 1);
00375                                 DCSize.x=ScilabGC->CWindowWidth;
00376                                 DCSize.y=ScilabGC->CWindowHeight;
00377 
00378                                 HdcToBmpFile(hmemDC,pszflname,DCSize);
00379 
00380                                 DeleteDC(hmemDC);
00381                                 DeleteBitmap(hBitmap);
00382                         }
00383         }
00384         else
00385         {
00386                 MessageBox(NULL,MSG_ERROR36,MSG_ERROR20,MB_ICONWARNING);
00387         }
00388 
00389         SetCurrentFigureWindows (SaveCurrentWindow);
00390 
00391         Setscig_buzyState(FALSE);
00392 
00393 }

void ExportEMF ( struct BCG ScilabGC,
char *  pszflname 
)

Definition at line 395 of file ExportBmpEmf.c.

00396 {    
00397         RECT rect;
00398         HWND hwnd;
00399         HDC hdc;
00400         HDC hdcTmp;
00401         HENHMETAFILE metafile;
00402 
00403         integer SaveCurrentFigure=0; 
00404 
00405         Setscig_buzyState(TRUE);
00406 
00407         SaveCurrentFigure=GetCurrentFigureWindows();
00408         SetCurrentFigureWindows (ScilabGC->CurWindow);
00409 
00410         hwnd = ScilabGC->CWindow;
00411 
00412         /* view the window */
00413         if (IsIconic (hwnd)) ShowWindow (hwnd, SW_SHOWNORMAL);
00414         BringWindowToTop (hwnd);
00415         UpdateWindow (hwnd);
00416 
00417         /* get the context */
00418         hdcTmp=TryToGetDC (hwnd);
00419         hdc = CreateEnhMetaFile (hdcTmp, pszflname, NULL, "Scilab Graphics");
00420 
00421         GetClientRect (hwnd, &rect);
00422         SetMapMode (hdc, MM_TEXT);
00423         SetTextAlign (hdc, TA_LEFT | TA_BOTTOM);
00424         
00425         SetWindowExtEx (hdc,ScilabGC->CWindowWidth,ScilabGC->CWindowHeight, (LPSIZE) NULL);
00426         Rectangle (hdc, 0, 0,ScilabGC->CWindowWidth,ScilabGC->CWindowHeight);
00427 
00430         scig_replay_hdc ('C', ScilabGC->CurWindow,hdcTmp,ScilabGC->CWindowWidth,ScilabGC->CWindowHeight, 1);
00431         ReleaseDC(hwnd,hdcTmp);
00432 
00433         scig_replay_hdc ('C', ScilabGC->CurWindow,hdc,ScilabGC->CWindowWidth,ScilabGC->CWindowHeight, 1);
00434 
00435         metafile = CloseEnhMetaFile(hdc);
00436         DeleteDC(hdc);
00437         DeleteEnhMetaFile( metafile );
00438 
00439         SetCurrentFigureWindows (SaveCurrentFigure);
00440 
00441         Setscig_buzyState(FALSE);
00442         return;
00443 }

BOOL ExportStyle ( struct BCG ScilabGC  ) 

Definition at line 87 of file ExportBox.c.

00088 {
00089   DLGPROC lpfnExportStyleDlgProc;
00090   BOOL status = FALSE;
00091   lpfnExportStyleDlgProc = (DLGPROC) MyGetProcAddress ("ExportStyleDlgProc",ExportStyleDlgProc);
00092   if (DialogBox (hdllInstance,"ExportStyleDlgBox",
00093                  ScilabGC->hWndParent, lpfnExportStyleDlgProc) == IDOK)
00094     {
00095       status = TRUE;
00096     }
00097   return status;
00098 }

char* GetFileExtension ( char *  filename  ) 

Definition at line 210 of file FigureToFile.c.

References buffer, MALLOC, MAX_PATH, and NULL.

Referenced by ModifyFilenameExtension().

00211 {
00212         char *StrReturn=NULL;
00213         char ChaineTemp[MAX_PATH];
00214         char *buffer=NULL;
00215         char *lastdot=NULL;
00216         
00217         strcpy(ChaineTemp,filename);
00218         /* Recherche de l'extension du fichier */
00219         buffer=strtok(ChaineTemp,".");
00220         while ( buffer = strtok(NULL,"."))
00221         {
00222                 lastdot=buffer;
00223         }
00224 
00225         if (lastdot)
00226         {
00227                 StrReturn = (char *) MALLOC ((strlen(lastdot)+2)*sizeof(char));
00228                 strcpy(StrReturn,".");
00229                 strcat(StrReturn,lastdot);
00230         }
00231         else
00232         {
00233                 StrReturn = NULL;
00234         }
00235         return StrReturn;
00236 }

Here is the caller graph for this function:

static void ModifyFilenameExtension ( char *  Filename,
char *  ext 
) [static]

Definition at line 238 of file FigureToFile.c.

References FREE, GetFileExtension(), NULL, and stricmp.

Referenced by SavePs().

00239 {
00240         char *Ext=NULL;
00241         Ext=GetFileExtension(Filename);
00242         if (Ext)
00243         {
00244                 if (stricmp(Ext,ext)!=0)
00245                 {
00246                         strcat(Filename,ext);
00247                 }
00248                 if (Ext) {FREE(Ext);Ext=NULL;}
00249         }
00250         else strcat(Filename,ext);
00251 }

Here is the call graph for this function:

Here is the caller graph for this function:

void SavePs ( struct BCG ScilabGC  ) 

Definition at line 20 of file FigureToFile.c.

References CallTranslateMacroGraphicWindow(), tagLS::colored, dos2win32(), ExportBMP(), ExportEMF(), ExportStyle(), FALSE, filename, filename1, ierr, tagLS::land, ls, MAXSTR, ModifyFilenameExtension(), MSG_SCIMSG100, MSG_SCIMSG101, MSG_SCIMSG102, MSG_SCIMSG103, MSG_SCIMSG104, MSG_SCIMSG96, MSG_SCIMSG97, MSG_SCIMSG98, MSG_SCIMSG99, NULL, tagLS::ps_type, s, scig_toPs(), ScilabPsToEps(), ScilabPsToTeX(), SciOpenSave(), str, TRUE, tagLS::use_printer, and wininfo().

Referenced by AddNewWin(), scig_export(), and SendGraphMacro().

00021 {
00022   char *d, ori;
00023   char filename[MAXSTR],filename1[MAXSTR];
00024   BYTE *s;
00025   char str[1024];
00026   char formatmacro[]= "[SAVESCG]Export to %s[EOS]%s[EOS]";
00027   int flag, ierr = 0;
00029   ls.use_printer = 0;
00030   if (ExportStyle (ScilabGC) == FALSE) return;
00031 
00033   d = filename;
00034 
00035   switch (ls.ps_type)
00036   {
00037     case 0:
00038                 {
00039                         wsprintf(str,formatmacro,"Postscript","*.eps");
00040                         CallTranslateMacroGraphicWindow(str);
00041                         s = str;
00042                         flag = SciOpenSave (ScilabGC->hWndParent, &s,TRUE,&d, &ierr);
00043                         if (flag == 0 || ierr == 1) return;
00044                         *d = '\0';
00045 
00046                         ModifyFilenameExtension(filename,".pos");
00047 
00049                         SetCursor (LoadCursor (NULL, IDC_WAIT));
00050                         wininfo (MSG_SCIMSG96);
00051                         dos2win32 (filename, filename1);
00052                         scig_toPs (ScilabGC->CurWindow, ls.colored, filename1, "Pos");
00053                         ori = (ls.land == 1) ? 'l' : 'p';
00054                         ScilabPsToEps (ori, filename1, filename);
00055                         wininfo (MSG_SCIMSG97);
00056                         SetCursor (LoadCursor (NULL, IDC_CROSS));
00057                 }
00058                 break;
00059     case 1:
00060                 {
00061                         wsprintf(str,formatmacro,"Postscript No Preamble","*.ps");
00062 
00063                         CallTranslateMacroGraphicWindow(str);
00064                         s = str;
00065                         flag = SciOpenSave (ScilabGC->hWndParent, &s,TRUE,&d, &ierr);
00066                         if (flag == 0 || ierr == 1) return;
00067                         *d = '\0';
00068 
00069                         ModifyFilenameExtension(filename,".ps");
00070 
00071                         SetCursor (LoadCursor (NULL, IDC_WAIT));
00072                         scig_toPs (ScilabGC->CurWindow, ls.colored, filename, "Pos");
00073                         wininfo (MSG_SCIMSG98);
00074                         SetCursor (LoadCursor (NULL, IDC_CROSS));
00075                 }
00076                 break;
00077 
00078     case 2:
00079                 {
00080                         wsprintf(str,formatmacro,"Postscript-Latex","*.tex");
00081 
00082                         CallTranslateMacroGraphicWindow(str);
00083                         s = str;
00084                         flag = SciOpenSave (ScilabGC->hWndParent, &s,TRUE,&d, &ierr);
00085                         if (flag == 0 || ierr == 1) return;
00086                         *d = '\0';
00087 
00088                         ModifyFilenameExtension(filename,".tex");
00089 
00091                         SetCursor (LoadCursor (NULL, IDC_WAIT));
00092                         wininfo (MSG_SCIMSG99);
00093                         dos2win32 (filename, filename1);
00094                         scig_toPs (ScilabGC->CurWindow, ls.colored, filename1, "Pos");
00095                         ori = (ls.land == 1) ? 'l' : 'p';
00096                         ScilabPsToTeX (ori, filename1, filename, 1.0, 1.0);
00097                         wininfo (MSG_SCIMSG100);
00098                         SetCursor (LoadCursor (NULL, IDC_CROSS));
00099                 }
00100     break;
00101     case 3:
00102                 {
00103                         wsprintf(str,formatmacro,"Xfig","*.fig");
00104                         CallTranslateMacroGraphicWindow(str);
00105                         s = str;
00106                         flag = SciOpenSave (ScilabGC->hWndParent, &s,TRUE,&d, &ierr);
00107                         if (flag == 0 || ierr == 1) return;
00108                         *d = '\0';
00109 
00110                         ModifyFilenameExtension(filename,".fig");
00111 
00112                         SetCursor (LoadCursor (NULL, IDC_WAIT));
00113                         scig_toPs (ScilabGC->CurWindow, ls.colored, filename, "Fig");
00114                         wininfo (MSG_SCIMSG101);
00115                         SetCursor (LoadCursor (NULL, IDC_CROSS));
00116                 }
00117                 break;
00118     case 4:
00119                 {
00120                         wsprintf(str,formatmacro,"gif","*.gif");
00121                         CallTranslateMacroGraphicWindow(str);
00122                         s = str;
00123                         flag = SciOpenSave (ScilabGC->hWndParent, &s,TRUE,&d, &ierr);
00124                         if (flag == 0 || ierr == 1) return;
00125                         *d = '\0';
00126 
00127                         ModifyFilenameExtension(filename,".gif");
00128 
00129                         SetCursor (LoadCursor (NULL, IDC_WAIT));
00130                         scig_toPs (ScilabGC->CurWindow, ls.colored, filename, "GIF");
00131                         wininfo (MSG_SCIMSG102);
00132                         SetCursor (LoadCursor (NULL, IDC_CROSS));
00133                 }
00134                 break;
00135     case 5:
00136                 {
00137                         wsprintf(str,formatmacro,"PPM","*.ppm");
00138                         CallTranslateMacroGraphicWindow(str);
00139                         s = str;
00140                         flag = SciOpenSave (ScilabGC->hWndParent, &s,TRUE,&d, &ierr);
00141                         if (flag == 0 || ierr == 1) return;
00142                         *d = '\0';
00143 
00144                         ModifyFilenameExtension(filename,".ppm");
00145 
00146                         SetCursor (LoadCursor (NULL, IDC_WAIT));
00147                         scig_toPs (ScilabGC->CurWindow, ls.colored, filename, "PPM");
00148                         wininfo (MSG_SCIMSG103);
00149                         SetCursor (LoadCursor (NULL, IDC_CROSS));
00150                 }
00151     break;
00152     case 6:
00153                 {
00154                         wsprintf(str,formatmacro,"Bmp","*.bmp");
00155                         CallTranslateMacroGraphicWindow(str);
00156                         s = str;
00157                         flag = SciOpenSave (ScilabGC->hWndParent, &s,TRUE,&d, &ierr);
00158                         if (flag == 0 || ierr == 1) return;
00159                         *d = '\0';
00160 
00161                         ModifyFilenameExtension(filename,".bmp");
00162 
00163                         SetCursor (LoadCursor (NULL, IDC_WAIT));
00164                         ExportBMP(ScilabGC,filename);
00165                         wininfo (MSG_SCIMSG104);
00166                         SetCursor (LoadCursor (NULL, IDC_CROSS));
00167                 }
00168     break;
00169     case 7:
00170                 {
00171                         wsprintf(str,formatmacro,"Enhanced Metafile","*.emf");
00172                         CallTranslateMacroGraphicWindow(str);
00173                         s = str;
00174                         flag = SciOpenSave (ScilabGC->hWndParent, &s,TRUE,&d, &ierr);
00175                         if (flag == 0 || ierr == 1) return;
00176                         *d = '\0';
00177 
00178                         ModifyFilenameExtension(filename,".emf");
00179 
00180                         SetCursor (LoadCursor (NULL, IDC_WAIT));
00181                         ExportEMF(ScilabGC,filename);
00182                         wininfo (MSG_SCIMSG104);
00183                         SetCursor (LoadCursor (NULL, IDC_CROSS));
00184                 }
00185     break;
00186   }
00187         
00188 }

Here is the call graph for this function:

Here is the caller graph for this function:


Variable Documentation

LS ls

Definition at line 20 of file ExportBox.c.


Generated on Sun Mar 4 15:57:08 2007 for Scilab [trunk] by  doxygen 1.5.1