15c6c1daeSBarry Smith 25c6c1daeSBarry Smith /* 35c6c1daeSBarry Smith Provides the registration process for PETSc PetscDraw routines 45c6c1daeSBarry Smith */ 55c6c1daeSBarry Smith #include <petsc-private/drawimpl.h> /*I "petscdraw.h" I*/ 65c6c1daeSBarry Smith 75c6c1daeSBarry Smith /* 85c6c1daeSBarry Smith Contains the list of registered PetscDraw routines 95c6c1daeSBarry Smith */ 10140e18c1SBarry Smith PetscFunctionList PetscDrawList = 0; 115c6c1daeSBarry Smith 125c6c1daeSBarry Smith #undef __FUNCT__ 135c6c1daeSBarry Smith #define __FUNCT__ "PetscDrawCreate" 145c6c1daeSBarry Smith /*@C 155c6c1daeSBarry Smith PetscDrawCreate - Creates a graphics context. 165c6c1daeSBarry Smith 175c6c1daeSBarry Smith Collective on MPI_Comm 185c6c1daeSBarry Smith 195c6c1daeSBarry Smith Input Parameter: 205c6c1daeSBarry Smith + comm - MPI communicator 215c6c1daeSBarry Smith . display - X display when using X windows 225c6c1daeSBarry Smith . title - optional title added to top of window 235c6c1daeSBarry Smith . x,y - coordinates of lower left corner of window or PETSC_DECIDE 245c6c1daeSBarry Smith - w, h - width and height of window or PETSC_DECIDE or PETSC_DRAW_HALF_SIZE, PETSC_DRAW_FULL_SIZE, 255c6c1daeSBarry Smith or PETSC_DRAW_THIRD_SIZE or PETSC_DRAW_QUARTER_SIZE 265c6c1daeSBarry Smith 275c6c1daeSBarry Smith Output Parameter: 285c6c1daeSBarry Smith . draw - location to put the PetscDraw context 295c6c1daeSBarry Smith 305c6c1daeSBarry Smith Level: beginner 315c6c1daeSBarry Smith 325c6c1daeSBarry Smith Concepts: graphics^creating context 335c6c1daeSBarry Smith Concepts: drawing^creating context 345c6c1daeSBarry Smith 355c6c1daeSBarry Smith .seealso: PetscDrawSetFromOptions(), PetscDrawDestroy(), PetscDrawSetType() 365c6c1daeSBarry Smith @*/ 375c6c1daeSBarry Smith PetscErrorCode PetscDrawCreate(MPI_Comm comm,const char display[],const char title[],int x,int y,int w,int h,PetscDraw *indraw) 385c6c1daeSBarry Smith { 395c6c1daeSBarry Smith PetscDraw draw; 405c6c1daeSBarry Smith PetscErrorCode ierr; 415c6c1daeSBarry Smith PetscReal dpause; 425c6c1daeSBarry Smith PetscBool flag; 435c6c1daeSBarry Smith 445c6c1daeSBarry Smith PetscFunctionBegin; 45519f805aSKarl Rupp #if !defined(PETSC_USE_DYNAMIC_LIBRARIES) 46607a6623SBarry Smith ierr = PetscDrawInitializePackage();CHKERRQ(ierr); 475c6c1daeSBarry Smith #endif 485c6c1daeSBarry Smith *indraw = 0; 4967c2884eSBarry Smith ierr = PetscHeaderCreate(draw,_p_PetscDraw,struct _PetscDrawOps,PETSC_DRAW_CLASSID,"Draw","Graphics","Draw",comm,PetscDrawDestroy,0);CHKERRQ(ierr); 50a297a907SKarl Rupp 515c6c1daeSBarry Smith draw->data = 0; 525c6c1daeSBarry Smith ierr = PetscStrallocpy(title,&draw->title);CHKERRQ(ierr); 535c6c1daeSBarry Smith ierr = PetscStrallocpy(display,&draw->display);CHKERRQ(ierr); 545c6c1daeSBarry Smith draw->x = x; 555c6c1daeSBarry Smith draw->y = y; 565c6c1daeSBarry Smith draw->w = w; 575c6c1daeSBarry Smith draw->h = h; 585c6c1daeSBarry Smith draw->pause = 0.0; 595c6c1daeSBarry Smith draw->coor_xl = 0.0; 605c6c1daeSBarry Smith draw->coor_xr = 1.0; 615c6c1daeSBarry Smith draw->coor_yl = 0.0; 625c6c1daeSBarry Smith draw->coor_yr = 1.0; 635c6c1daeSBarry Smith draw->port_xl = 0.0; 645c6c1daeSBarry Smith draw->port_xr = 1.0; 655c6c1daeSBarry Smith draw->port_yl = 0.0; 665c6c1daeSBarry Smith draw->port_yr = 1.0; 675c6c1daeSBarry Smith draw->popup = 0; 68a297a907SKarl Rupp 690298fd71SBarry Smith ierr = PetscOptionsGetReal(NULL,"-draw_pause",&dpause,&flag);CHKERRQ(ierr); 705c6c1daeSBarry Smith if (flag) draw->pause = dpause; 710298fd71SBarry Smith draw->savefilename = NULL; 725c6c1daeSBarry Smith draw->savefilemovie = PETSC_FALSE; 735c6c1daeSBarry Smith draw->savefilecount = -1; 74a297a907SKarl Rupp 755c6c1daeSBarry Smith ierr = PetscDrawSetCurrentPoint(draw,.5,.9);CHKERRQ(ierr); 76a297a907SKarl Rupp 775c6c1daeSBarry Smith draw->boundbox_xl = .5; 785c6c1daeSBarry Smith draw->boundbox_xr = .5; 795c6c1daeSBarry Smith draw->boundbox_yl = .9; 805c6c1daeSBarry Smith draw->boundbox_yr = .9; 815c6c1daeSBarry Smith 825c6c1daeSBarry Smith *indraw = draw; 835c6c1daeSBarry Smith PetscFunctionReturn(0); 845c6c1daeSBarry Smith } 855c6c1daeSBarry Smith 865c6c1daeSBarry Smith #undef __FUNCT__ 875c6c1daeSBarry Smith #define __FUNCT__ "PetscDrawSetType" 885c6c1daeSBarry Smith /*@C 895c6c1daeSBarry Smith PetscDrawSetType - Builds graphics object for a particular implementation 905c6c1daeSBarry Smith 915c6c1daeSBarry Smith Collective on PetscDraw 925c6c1daeSBarry Smith 935c6c1daeSBarry Smith Input Parameter: 945c6c1daeSBarry Smith + draw - the graphics context 955c6c1daeSBarry Smith - type - for example, PETSC_DRAW_X 965c6c1daeSBarry Smith 975c6c1daeSBarry Smith Options Database Command: 985c6c1daeSBarry Smith . -draw_type <type> - Sets the type; use -help for a list 995c6c1daeSBarry Smith of available methods (for instance, x) 1005c6c1daeSBarry Smith 1015c6c1daeSBarry Smith Level: intermediate 1025c6c1daeSBarry Smith 1035c6c1daeSBarry Smith Notes: 1045c6c1daeSBarry Smith See "petsc/include/petscdraw.h" for available methods (for instance, 1055c6c1daeSBarry Smith PETSC_DRAW_X) 1065c6c1daeSBarry Smith 1075c6c1daeSBarry Smith Concepts: drawing^X windows 1085c6c1daeSBarry Smith Concepts: X windows^graphics 1095c6c1daeSBarry Smith Concepts: drawing^Microsoft Windows 1105c6c1daeSBarry Smith 1115c6c1daeSBarry Smith .seealso: PetscDrawSetFromOptions(), PetscDrawCreate(), PetscDrawDestroy() 1125c6c1daeSBarry Smith @*/ 1135c6c1daeSBarry Smith PetscErrorCode PetscDrawSetType(PetscDraw draw,PetscDrawType type) 1145c6c1daeSBarry Smith { 1155c6c1daeSBarry Smith PetscErrorCode ierr,(*r)(PetscDraw); 1165c6c1daeSBarry Smith PetscBool match; 1175c6c1daeSBarry Smith PetscBool flg=PETSC_FALSE; 1185c6c1daeSBarry Smith 1195c6c1daeSBarry Smith PetscFunctionBegin; 1205c6c1daeSBarry Smith PetscValidHeaderSpecific(draw,PETSC_DRAW_CLASSID,1); 1215c6c1daeSBarry Smith PetscValidCharPointer(type,2); 1225c6c1daeSBarry Smith 1235c6c1daeSBarry Smith ierr = PetscObjectTypeCompare((PetscObject)draw,type,&match);CHKERRQ(ierr); 1245c6c1daeSBarry Smith if (match) PetscFunctionReturn(0); 1255c6c1daeSBarry Smith 1265c6c1daeSBarry Smith /* User requests no graphics */ 1270298fd71SBarry Smith ierr = PetscOptionsHasName(NULL,"-nox",&flg);CHKERRQ(ierr); 1285c6c1daeSBarry Smith 1295c6c1daeSBarry Smith /* 1305c6c1daeSBarry Smith This is not ideal, but it allows codes to continue to run if X graphics 1315c6c1daeSBarry Smith was requested but is not installed on this machine. Mostly this is for 1325c6c1daeSBarry Smith testing. 1335c6c1daeSBarry Smith */ 1345c6c1daeSBarry Smith #if !defined(PETSC_HAVE_X) 1355c6c1daeSBarry Smith if (!flg) { 1365c6c1daeSBarry Smith ierr = PetscStrcmp(type,PETSC_DRAW_X,&match);CHKERRQ(ierr); 1375c6c1daeSBarry Smith if (match) { 1385c6c1daeSBarry Smith PetscBool dontwarn = PETSC_TRUE; 1395c6c1daeSBarry Smith flg = PETSC_TRUE; 1400298fd71SBarry Smith ierr = PetscOptionsHasName(NULL,"-nox_warning",&dontwarn);CHKERRQ(ierr); 141a297a907SKarl Rupp if (!dontwarn) (*PetscErrorPrintf)("PETSc installed without X windows on this machine\nproceeding without graphics\n"); 1425c6c1daeSBarry Smith } 1435c6c1daeSBarry Smith } 1445c6c1daeSBarry Smith #endif 145a297a907SKarl Rupp if (flg) type = PETSC_DRAW_NULL; 1465c6c1daeSBarry Smith 1475c6c1daeSBarry Smith if (draw->data) { 1485c6c1daeSBarry Smith /* destroy the old private PetscDraw context */ 1495c6c1daeSBarry Smith ierr = (*draw->ops->destroy)(draw);CHKERRQ(ierr); 1500298fd71SBarry Smith draw->ops->destroy = NULL; 1515c6c1daeSBarry Smith draw->data = 0; 1525c6c1daeSBarry Smith } 1535c6c1daeSBarry Smith 1541c9cd337SJed Brown ierr = PetscFunctionListFind(PetscDrawList,type,&r);CHKERRQ(ierr); 1555c6c1daeSBarry Smith if (!r) SETERRQ1(PETSC_COMM_SELF,PETSC_ERR_ARG_UNKNOWN_TYPE,"Unknown PetscDraw type given: %s",type); 1565c6c1daeSBarry Smith ierr = PetscObjectChangeTypeName((PetscObject)draw,type);CHKERRQ(ierr); 1575c6c1daeSBarry Smith draw->data = 0; 1585c6c1daeSBarry Smith ierr = (*r)(draw);CHKERRQ(ierr); 1595c6c1daeSBarry Smith PetscFunctionReturn(0); 1605c6c1daeSBarry Smith } 1615c6c1daeSBarry Smith 1625c6c1daeSBarry Smith #undef __FUNCT__ 1635c6c1daeSBarry Smith #define __FUNCT__ "PetscDrawGetType" 1645c6c1daeSBarry Smith /*@C 1655c6c1daeSBarry Smith PetscDrawGetType - Gets the PetscDraw type as a string from the PetscDraw object. 1665c6c1daeSBarry Smith 1675c6c1daeSBarry Smith Not Collective 1685c6c1daeSBarry Smith 1695c6c1daeSBarry Smith Input Parameter: 1705c6c1daeSBarry Smith . draw - Krylov context 1715c6c1daeSBarry Smith 1725c6c1daeSBarry Smith Output Parameters: 1735c6c1daeSBarry Smith . name - name of PetscDraw method 1745c6c1daeSBarry Smith 1755c6c1daeSBarry Smith Level: advanced 1765c6c1daeSBarry Smith 1775c6c1daeSBarry Smith @*/ 1785c6c1daeSBarry Smith PetscErrorCode PetscDrawGetType(PetscDraw draw,PetscDrawType *type) 1795c6c1daeSBarry Smith { 1805c6c1daeSBarry Smith PetscFunctionBegin; 1815c6c1daeSBarry Smith PetscValidHeaderSpecific(draw,PETSC_DRAW_CLASSID,1); 1825c6c1daeSBarry Smith PetscValidPointer(type,2); 1835c6c1daeSBarry Smith *type = ((PetscObject)draw)->type_name; 1845c6c1daeSBarry Smith PetscFunctionReturn(0); 1855c6c1daeSBarry Smith } 1865c6c1daeSBarry Smith 1875c6c1daeSBarry Smith #undef __FUNCT__ 1885c6c1daeSBarry Smith #define __FUNCT__ "PetscDrawRegister" 189607a6623SBarry Smith /*@C 1901c84c290SBarry Smith PetscDrawRegister - Adds a method to the graphics package. 1911c84c290SBarry Smith 1921c84c290SBarry Smith Not Collective 1931c84c290SBarry Smith 1941c84c290SBarry Smith Input Parameters: 1951c84c290SBarry Smith + name_solver - name of a new user-defined solver 1961c84c290SBarry Smith - routine_create - routine to create method context 1971c84c290SBarry Smith 1981c84c290SBarry Smith Level: developer 1991c84c290SBarry Smith 2001c84c290SBarry Smith Notes: 2011c84c290SBarry Smith PetscDrawRegister() may be called multiple times to add several user-defined solvers. 2021c84c290SBarry Smith 2031c84c290SBarry Smith Sample usage: 2041c84c290SBarry Smith .vb 205bdf89e91SBarry Smith PetscDrawRegister("my_draw_type", MyDrawCreate); 2061c84c290SBarry Smith .ve 2071c84c290SBarry Smith 2081c84c290SBarry Smith Then, your solver can be chosen with the procedural interface via 2091c84c290SBarry Smith $ PetscDrawSetType(ksp,"my_draw_type") 2101c84c290SBarry Smith or at runtime via the option 2111c84c290SBarry Smith $ -draw_type my_draw_type 2121c84c290SBarry Smith 2131c84c290SBarry Smith Concepts: graphics^registering new draw classes 2141c84c290SBarry Smith Concepts: PetscDraw^registering new draw classes 2151c84c290SBarry Smith 2161c84c290SBarry Smith .seealso: PetscDrawRegisterAll(), PetscDrawRegisterDestroy() 2171c84c290SBarry Smith @*/ 218bdf89e91SBarry Smith PetscErrorCode PetscDrawRegister(const char *sname,PetscErrorCode (*function)(PetscDraw)) 2195c6c1daeSBarry Smith { 2205c6c1daeSBarry Smith PetscErrorCode ierr; 2215c6c1daeSBarry Smith 2225c6c1daeSBarry Smith PetscFunctionBegin; 223a240a19fSJed Brown ierr = PetscFunctionListAdd(&PetscDrawList,sname,function);CHKERRQ(ierr); 2245c6c1daeSBarry Smith PetscFunctionReturn(0); 2255c6c1daeSBarry Smith } 2265c6c1daeSBarry Smith 2275c6c1daeSBarry Smith #undef __FUNCT__ 2285c6c1daeSBarry Smith #define __FUNCT__ "PetscDrawSetFromOptions" 2295c6c1daeSBarry Smith /*@ 2305c6c1daeSBarry Smith PetscDrawSetFromOptions - Sets the graphics type from the options database. 2315c6c1daeSBarry Smith Defaults to a PETSc X windows graphics. 2325c6c1daeSBarry Smith 2335c6c1daeSBarry Smith Collective on PetscDraw 2345c6c1daeSBarry Smith 2355c6c1daeSBarry Smith Input Parameter: 2365c6c1daeSBarry Smith . draw - the graphics context 2375c6c1daeSBarry Smith 2385c6c1daeSBarry Smith Options Database Keys: 2395c6c1daeSBarry Smith + -nox - do not use X graphics (ignore graphics calls, but run program correctly) 2405c6c1daeSBarry Smith . -nox_warning - when X windows support is not installed this prevents the warning message 2415c6c1daeSBarry Smith from being printed 2427450148dSBarry Smith . -draw_pause <pause amount> -- -1 indicates wait for mouse input, -2 indicates pause when window is to be destroyed 2435c6c1daeSBarry Smith . -draw_save [optional filename] - (X windows only) saves each image before it is cleared to a file 244a4494fc1SBarry Smith . -draw_save_movie - converts image files to a movie at the end of the run. See PetscDrawSetSave() 245*8b7fcac6SBarry Smith . -draw_save_on_flush - saves an image on each flush in addition to each clear 246*8b7fcac6SBarry Smith - -draw_save_single_file - saves each new image in the same file, normally each new image is saved in a new file with filename_%d 2475c6c1daeSBarry Smith 2485c6c1daeSBarry Smith Level: intermediate 2495c6c1daeSBarry Smith 2505c6c1daeSBarry Smith Notes: 2515c6c1daeSBarry Smith Must be called after PetscDrawCreate() before the PetscDrawtor is used. 2525c6c1daeSBarry Smith 2535c6c1daeSBarry Smith Concepts: drawing^setting options 2545c6c1daeSBarry Smith Concepts: graphics^setting options 2555c6c1daeSBarry Smith 2565c6c1daeSBarry Smith .seealso: PetscDrawCreate(), PetscDrawSetType(), PetscDrawSetSave() 2575c6c1daeSBarry Smith 2585c6c1daeSBarry Smith @*/ 2595c6c1daeSBarry Smith PetscErrorCode PetscDrawSetFromOptions(PetscDraw draw) 2605c6c1daeSBarry Smith { 2615c6c1daeSBarry Smith PetscErrorCode ierr; 2625c6c1daeSBarry Smith PetscBool flg,nox; 2635c6c1daeSBarry Smith char vtype[256]; 2645c6c1daeSBarry Smith const char *def; 2657450148dSBarry Smith PetscReal dpause; 2665c6c1daeSBarry Smith #if !defined(PETSC_USE_WINDOWS_GRAPHICS) && !defined(PETSC_HAVE_X) 2675c6c1daeSBarry Smith PetscBool warn; 2685c6c1daeSBarry Smith #endif 2695c6c1daeSBarry Smith 2705c6c1daeSBarry Smith PetscFunctionBegin; 2715c6c1daeSBarry Smith PetscValidHeaderSpecific(draw,PETSC_DRAW_CLASSID,1); 2725c6c1daeSBarry Smith 2735c6c1daeSBarry Smith if (!PetscDrawList) { 274607a6623SBarry Smith ierr = PetscDrawRegisterAll();CHKERRQ(ierr); 2755c6c1daeSBarry Smith } 2765c6c1daeSBarry Smith 277a297a907SKarl Rupp if (((PetscObject)draw)->type_name) def = ((PetscObject)draw)->type_name; 278a297a907SKarl Rupp else { 2790298fd71SBarry Smith ierr = PetscOptionsHasName(NULL,"-nox",&nox);CHKERRQ(ierr); 2805c6c1daeSBarry Smith def = PETSC_DRAW_NULL; 2815c6c1daeSBarry Smith #if defined(PETSC_USE_WINDOWS_GRAPHICS) 2825c6c1daeSBarry Smith if (!nox) def = PETSC_DRAW_WIN32; 2835c6c1daeSBarry Smith #elif defined(PETSC_HAVE_X) 2845c6c1daeSBarry Smith if (!nox) def = PETSC_DRAW_X; 2855c6c1daeSBarry Smith #elif defined(PETSC_HAVE_GLUT) 2865c6c1daeSBarry Smith if (!nox) def = PETSC_DRAW_GLUT; 2875c6c1daeSBarry Smith #elif defined(PETSC_HAVE_OPENGLES) 2885c6c1daeSBarry Smith if (!nox) def = PETSC_DRAW_OPENGLES; 2895c6c1daeSBarry Smith #else 2900298fd71SBarry Smith ierr = PetscOptionsHasName(NULL,"-nox_warning",&warn);CHKERRQ(ierr); 291a297a907SKarl Rupp if (!nox && !warn) (*PetscErrorPrintf)("PETSc installed without X windows, Microsoft Graphics, OpenGL ES, or GLUT/OpenGL on this machine\nproceeding without graphics\n"); 2925c6c1daeSBarry Smith #endif 2935c6c1daeSBarry Smith } 2945c6c1daeSBarry Smith ierr = PetscObjectOptionsBegin((PetscObject)draw);CHKERRQ(ierr); 2955c6c1daeSBarry Smith ierr = PetscOptionsList("-draw_type","Type of graphical output","PetscDrawSetType",PetscDrawList,def,vtype,256,&flg);CHKERRQ(ierr); 2965c6c1daeSBarry Smith if (flg) { 2975c6c1daeSBarry Smith ierr = PetscDrawSetType(draw,vtype);CHKERRQ(ierr); 2985c6c1daeSBarry Smith } else if (!((PetscObject)draw)->type_name) { 2995c6c1daeSBarry Smith ierr = PetscDrawSetType(draw,def);CHKERRQ(ierr); 3005c6c1daeSBarry Smith } 3015c6c1daeSBarry Smith ierr = PetscOptionsName("-nox","Run without graphics","None",&nox);CHKERRQ(ierr); 3025c6c1daeSBarry Smith #if defined(PETSC_HAVE_X) 3035c6c1daeSBarry Smith { 3045c6c1daeSBarry Smith char filename[PETSC_MAX_PATH_LEN]; 3055c6c1daeSBarry Smith PetscBool save,movie = PETSC_FALSE; 3060298fd71SBarry Smith ierr = PetscOptionsBool("-draw_save_movie","Make a movie from the images saved (X Windows only)","PetscDrawSetSave",movie,&movie,NULL);CHKERRQ(ierr); 307*8b7fcac6SBarry Smith ierr = PetscOptionsBool("-draw_save_single_file","Each new image replaces previous image in file","PetscDrawSetSave",draw->savesinglefile,&draw->savesinglefile,NULL);CHKERRQ(ierr); 3085c6c1daeSBarry Smith ierr = PetscOptionsString("-draw_save","Save graphics to file (X Windows only)","PetscDrawSetSave",filename,filename,PETSC_MAX_PATH_LEN,&save);CHKERRQ(ierr); 3095c6c1daeSBarry Smith if (save) { 3105c6c1daeSBarry Smith ierr = PetscDrawSetSave(draw,filename,movie);CHKERRQ(ierr); 3115c6c1daeSBarry Smith } 312a4494fc1SBarry Smith ierr = PetscOptionsBool("-draw_save_on_flush","Save graphics to file (X Windows only) on each flush","PetscDrawSetSave",draw->saveonflush,&draw->saveonflush,NULL);CHKERRQ(ierr); 3135c6c1daeSBarry Smith } 3145c6c1daeSBarry Smith #endif 3157450148dSBarry Smith ierr = PetscOptionsGetReal(NULL,"-draw_pause",&dpause,&flg);CHKERRQ(ierr); 3167450148dSBarry Smith if (flg) draw->pause = dpause; 3175c6c1daeSBarry Smith 3185c6c1daeSBarry Smith /* process any options handlers added with PetscObjectAddOptionsHandler() */ 3195c6c1daeSBarry Smith ierr = PetscObjectProcessOptionsHandlers((PetscObject)draw);CHKERRQ(ierr); 3205c6c1daeSBarry Smith ierr = PetscOptionsEnd();CHKERRQ(ierr); 3215c6c1daeSBarry Smith PetscFunctionReturn(0); 3225c6c1daeSBarry Smith } 3235c6c1daeSBarry Smith 3245c6c1daeSBarry Smith #undef __FUNCT__ 3255c6c1daeSBarry Smith #define __FUNCT__ "PetscDrawSetSave" 3265c6c1daeSBarry Smith /*@C 32799bbeb84SJed Brown PetscDrawSetSave - Saves images produced in a PetscDraw into a file as a Gif file using AfterImage 3285c6c1daeSBarry Smith 3295c6c1daeSBarry Smith Collective on PetscDraw 3305c6c1daeSBarry Smith 3315c6c1daeSBarry Smith Input Parameter: 3325c6c1daeSBarry Smith + draw - the graphics context 3330298fd71SBarry Smith . filename - name of the file, if NULL uses name of draw object 3345c6c1daeSBarry Smith - movie - produce a movie of all the images 3355c6c1daeSBarry Smith 3365c6c1daeSBarry Smith Options Database Command: 3375c6c1daeSBarry Smith + -draw_save <filename> 3385c6c1daeSBarry Smith - -draw_save_movie 3395c6c1daeSBarry Smith 3405c6c1daeSBarry Smith Level: intermediate 3415c6c1daeSBarry Smith 3425c6c1daeSBarry Smith Concepts: X windows^graphics 3435c6c1daeSBarry Smith 3445c6c1daeSBarry Smith Notes: You should call this BEFORE calling PetscDrawClear() and creating your image. 3455c6c1daeSBarry Smith 3465c6c1daeSBarry Smith Requires that PETSc be configured with the option --with-afterimage to save the images and ffmpeg must be in your path to make the movie 3475c6c1daeSBarry Smith 3485c6c1daeSBarry Smith If X windows generates an error message about X_CreateWindow() failing then Afterimage was installed without X windows. Reinstall Afterimage using the 3495c6c1daeSBarry Smith ./configure flags --x-includes=/pathtoXincludes --x-libraries=/pathtoXlibraries For example under Mac OS X Mountain Lion --x-includes=/opt/X11/include -x-libraries=/opt/X11/lib 3505c6c1daeSBarry Smith 3515c6c1daeSBarry Smith 35299bbeb84SJed Brown .seealso: PetscDrawSetFromOptions(), PetscDrawCreate(), PetscDrawDestroy() 3535c6c1daeSBarry Smith @*/ 3545c6c1daeSBarry Smith PetscErrorCode PetscDrawSetSave(PetscDraw draw,const char *filename,PetscBool movie) 3555c6c1daeSBarry Smith { 3565c6c1daeSBarry Smith PetscErrorCode ierr; 3575c6c1daeSBarry Smith 3585c6c1daeSBarry Smith PetscFunctionBegin; 3595c6c1daeSBarry Smith PetscValidHeaderSpecific(draw,PETSC_DRAW_CLASSID,1); 3605c6c1daeSBarry Smith ierr = PetscFree(draw->savefilename);CHKERRQ(ierr); 361a297a907SKarl Rupp 3625c6c1daeSBarry Smith draw->savefilemovie = movie; 3635c6c1daeSBarry Smith if (filename && filename[0]) { 3645c6c1daeSBarry Smith ierr = PetscStrallocpy(filename,&draw->savefilename);CHKERRQ(ierr); 3655c6c1daeSBarry Smith } else { 3665c6c1daeSBarry Smith const char *name; 3675c6c1daeSBarry Smith ierr = PetscObjectGetName((PetscObject)draw,&name);CHKERRQ(ierr); 3685c6c1daeSBarry Smith ierr = PetscStrallocpy(name,&draw->savefilename);CHKERRQ(ierr); 3695c6c1daeSBarry Smith } 3705c6c1daeSBarry Smith if (draw->ops->setsave) { 3715c6c1daeSBarry Smith ierr = (*draw->ops->setsave)(draw,filename);CHKERRQ(ierr); 3725c6c1daeSBarry Smith } 3735c6c1daeSBarry Smith PetscFunctionReturn(0); 3745c6c1daeSBarry Smith } 375