PageRenderTime 36ms CodeModel.GetById 0ms RepoModel.GetById 0ms app.codeStats 0ms

/src/sys/draw/impls/x/xops.c.html

https://bitbucket.org/alexei-matveev/petsc-debian-pkg
HTML | 519 lines | 450 code | 69 blank | 0 comment | 0 complexity | d430ed3a85d99029804b2208f990bf64 MD5 | raw file
  1. <center><a href="xops.c">Actual source code: xops.c</a></center><br>
  2. <html>
  3. <head> <link rel="canonical" href="http://www.mcs.anl.gov/petsc/petsc-current/src/sys/draw/impls/x/xops.c.html" />
  4. <title></title>
  5. <meta name="generator" content="c2html 0.9.5">
  6. <meta name="date" content="2012-08-29T16:33:55+00:00">
  7. </head>
  8. <body bgcolor="#FFFFFF">
  9. <div id="version" align=right><b>petsc-3.3-p3 2012-08-29</b></div>
  10. <pre width="80">
  11. <a name="line2"> 2: </a><font color="#B22222">/*</font>
  12. <a name="line3"> 3: </a><font color="#B22222"> Defines the operations for the X <A href="../../../../../docs/manualpages/Draw/PetscDraw.html#PetscDraw">PetscDraw</A> implementation.</font>
  13. <a name="line4"> 4: </a><font color="#B22222">*/</font>
  14. <a name="line6"> 6: </a><font color="#A020F0">#include &lt;../src/sys/draw/impls/x/ximpl.h&gt; </font><font color="#B22222">/*I "petscsys.h" I*/</font><font color="#A020F0"></font>
  15. <a name="line8"> 8: </a><font color="#B22222">/*</font>
  16. <a name="line9"> 9: </a><font color="#B22222"> These macros transform from the users coordinates to the </font>
  17. <a name="line10"> 10: </a><font color="#B22222"> X-window pixel coordinates.</font>
  18. <a name="line11"> 11: </a><font color="#B22222">*/</font>
  19. <a name="line12"> 12: </a><strong><font color="#228B22">#define XTRANS(draw,xwin,x) \</font></strong>
  20. <a name="line13"> 13: </a><strong><font color="#228B22"> (int)(((xwin)-&gt;w)*((draw)-&gt;port_xl + (((x - (draw)-&gt;coor_xl)*((draw)-&gt;port_xr - (draw)-&gt;port_xl))/((draw)-&gt;coor_xr - (draw)-&gt;coor_xl))))</font></strong>
  21. <a name="line14"> 14: </a><strong><font color="#228B22">#define YTRANS(draw,xwin,y) \</font></strong>
  22. <a name="line15"> 15: </a><strong><font color="#228B22"> (int)(((xwin)-&gt;h)*(1.0-(draw)-&gt;port_yl - (((y - (draw)-&gt;coor_yl)*((draw)-&gt;port_yr - (draw)-&gt;port_yl))/((draw)-&gt;coor_yr - (draw)-&gt;coor_yl))))</font></strong>
  23. <a name="line19"> 19: </a><strong><font color="#4169E1"><a name="PetscDrawLine_X"></a><A href="../../../../../docs/manualpages/Sys/PetscErrorCode.html#PetscErrorCode">PetscErrorCode</A> PetscDrawLine_X(<A href="../../../../../docs/manualpages/Draw/PetscDraw.html#PetscDraw">PetscDraw</A> draw,<A href="../../../../../docs/manualpages/Sys/PetscReal.html#PetscReal">PetscReal</A> xl,<A href="../../../../../docs/manualpages/Sys/PetscReal.html#PetscReal">PetscReal</A> yl,<A href="../../../../../docs/manualpages/Sys/PetscReal.html#PetscReal">PetscReal</A> xr,<A href="../../../../../docs/manualpages/Sys/PetscReal.html#PetscReal">PetscReal</A> yr,int cl)</font></strong>
  24. <a name="line20"> 20: </a>{
  25. <a name="line21"> 21: </a> PetscDraw_X* XiWin = (PetscDraw_X*)draw-&gt;data;
  26. <a name="line22"> 22: </a> int x1,y_1,x2,y2;
  27. <a name="line25"> 25: </a> PetscDrawXiSetColor(XiWin,cl);
  28. <a name="line26"> 26: </a> x1 = XTRANS(draw,XiWin,xl); x2 = XTRANS(draw,XiWin,xr);
  29. <a name="line27"> 27: </a> y_1 = YTRANS(draw,XiWin,yl); y2 = YTRANS(draw,XiWin,yr);
  30. <a name="line28"> 28: </a> <font color="#4169E1">if</font> (x1 == x2 &amp;&amp; y_1 == y2) <font color="#4169E1">return</font>(0);
  31. <a name="line29"> 29: </a> XDrawLine(XiWin-&gt;disp,PetscDrawXiDrawable(XiWin),XiWin-&gt;gc.set,x1,y_1,x2,y2);
  32. <a name="line30"> 30: </a> <font color="#4169E1">return</font>(0);
  33. <a name="line31"> 31: </a>}
  34. <a name="line35"> 35: </a><strong><font color="#4169E1"><a name="PetscDrawArrow_X"></a><A href="../../../../../docs/manualpages/Sys/PetscErrorCode.html#PetscErrorCode">PetscErrorCode</A> PetscDrawArrow_X(<A href="../../../../../docs/manualpages/Draw/PetscDraw.html#PetscDraw">PetscDraw</A> draw,<A href="../../../../../docs/manualpages/Sys/PetscReal.html#PetscReal">PetscReal</A> xl,<A href="../../../../../docs/manualpages/Sys/PetscReal.html#PetscReal">PetscReal</A> yl,<A href="../../../../../docs/manualpages/Sys/PetscReal.html#PetscReal">PetscReal</A> xr,<A href="../../../../../docs/manualpages/Sys/PetscReal.html#PetscReal">PetscReal</A> yr,int cl)</font></strong>
  35. <a name="line36"> 36: </a>{
  36. <a name="line37"> 37: </a> PetscDraw_X* XiWin = (PetscDraw_X*)draw-&gt;data;
  37. <a name="line38"> 38: </a> int x1,y_1,x2,y2;
  38. <a name="line41"> 41: </a> PetscDrawXiSetColor(XiWin,cl);
  39. <a name="line42"> 42: </a> x1 = XTRANS(draw,XiWin,xl); x2 = XTRANS(draw,XiWin,xr);
  40. <a name="line43"> 43: </a> y_1 = YTRANS(draw,XiWin,yl); y2 = YTRANS(draw,XiWin,yr);
  41. <a name="line44"> 44: </a> <font color="#4169E1">if</font> (x1 == x2 &amp;&amp; y_1 == y2) <font color="#4169E1">return</font>(0);
  42. <a name="line45"> 45: </a> XDrawLine(XiWin-&gt;disp,PetscDrawXiDrawable(XiWin),XiWin-&gt;gc.set,x1,y_1,x2,y2);
  43. <a name="line46"> 46: </a> <font color="#4169E1">if</font> (x1 == x2 &amp;&amp; PetscAbs(y_1 - y2) &gt; 7) {
  44. <a name="line47"> 47: </a> <font color="#4169E1">if</font> (y2 &gt; y_1) {
  45. <a name="line48"> 48: </a> XDrawLine(XiWin-&gt;disp,PetscDrawXiDrawable(XiWin),XiWin-&gt;gc.set,x2,y2,x2-3,y2-3);
  46. <a name="line49"> 49: </a> XDrawLine(XiWin-&gt;disp,PetscDrawXiDrawable(XiWin),XiWin-&gt;gc.set,x2,y2,x2+3,y2-3);
  47. <a name="line50"> 50: </a> } <font color="#4169E1">else</font> {
  48. <a name="line51"> 51: </a> XDrawLine(XiWin-&gt;disp,PetscDrawXiDrawable(XiWin),XiWin-&gt;gc.set,x2,y2,x2-3,y2+3);
  49. <a name="line52"> 52: </a> XDrawLine(XiWin-&gt;disp,PetscDrawXiDrawable(XiWin),XiWin-&gt;gc.set,x2,y2,x2+3,y2+3);
  50. <a name="line53"> 53: </a> }
  51. <a name="line54"> 54: </a> }
  52. <a name="line55"> 55: </a> <font color="#4169E1">return</font>(0);
  53. <a name="line56"> 56: </a>}
  54. <a name="line60"> 60: </a><strong><font color="#4169E1"><a name="PetscDrawPoint_X"></a>static <A href="../../../../../docs/manualpages/Sys/PetscErrorCode.html#PetscErrorCode">PetscErrorCode</A> PetscDrawPoint_X(<A href="../../../../../docs/manualpages/Draw/PetscDraw.html#PetscDraw">PetscDraw</A> draw,<A href="../../../../../docs/manualpages/Sys/PetscReal.html#PetscReal">PetscReal</A> x,<A href="../../../../../docs/manualpages/Sys/PetscReal.html#PetscReal">PetscReal</A> y,int c)</font></strong>
  55. <a name="line61"> 61: </a>{
  56. <a name="line62"> 62: </a> int xx,yy;
  57. <a name="line63"> 63: </a> PetscDraw_X* XiWin = (PetscDraw_X*)draw-&gt;data;
  58. <a name="line66"> 66: </a> xx = XTRANS(draw,XiWin,x); yy = YTRANS(draw,XiWin,y);
  59. <a name="line67"> 67: </a> PetscDrawXiSetColor(XiWin,c);
  60. <a name="line68"> 68: </a> XDrawPoint(XiWin-&gt;disp,PetscDrawXiDrawable(XiWin),XiWin-&gt;gc.set,xx,yy);
  61. <a name="line69"> 69: </a> <font color="#4169E1">return</font>(0);
  62. <a name="line70"> 70: </a>}
  63. <a name="line74"> 74: </a><strong><font color="#4169E1"><a name="PetscDrawRectangle_X"></a>static <A href="../../../../../docs/manualpages/Sys/PetscErrorCode.html#PetscErrorCode">PetscErrorCode</A> PetscDrawRectangle_X(<A href="../../../../../docs/manualpages/Draw/PetscDraw.html#PetscDraw">PetscDraw</A> draw,<A href="../../../../../docs/manualpages/Sys/PetscReal.html#PetscReal">PetscReal</A> xl,<A href="../../../../../docs/manualpages/Sys/PetscReal.html#PetscReal">PetscReal</A> yl,<A href="../../../../../docs/manualpages/Sys/PetscReal.html#PetscReal">PetscReal</A> xr,<A href="../../../../../docs/manualpages/Sys/PetscReal.html#PetscReal">PetscReal</A> yr,int c1,int c2,int c3,int c4)</font></strong>
  64. <a name="line75"> 75: </a>{
  65. <a name="line76"> 76: </a> PetscDraw_X* XiWin = (PetscDraw_X*)draw-&gt;data;
  66. <a name="line77"> 77: </a> int x1,y_1,w,h,c = (c1 + c2 + c3 + c4)/4;
  67. <a name="line80"> 80: </a> PetscDrawXiSetColor(XiWin,c);
  68. <a name="line81"> 81: </a> x1 = XTRANS(draw,XiWin,xl); w = XTRANS(draw,XiWin,xr) - x1;
  69. <a name="line82"> 82: </a> y_1 = YTRANS(draw,XiWin,yr); h = YTRANS(draw,XiWin,yl) - y_1;
  70. <a name="line83"> 83: </a> <font color="#4169E1">if</font> (w &lt;= 0) w = 1; <font color="#4169E1">if</font> (h &lt;= 0) h = 1;
  71. <a name="line84"> 84: </a> XFillRectangle(XiWin-&gt;disp,PetscDrawXiDrawable(XiWin),XiWin-&gt;gc.set,x1,y_1,w,h);
  72. <a name="line85"> 85: </a> <font color="#4169E1">return</font>(0);
  73. <a name="line86"> 86: </a>}
  74. <a name="line90"> 90: </a><strong><font color="#4169E1"><a name="PetscDrawEllipse_X"></a>static <A href="../../../../../docs/manualpages/Sys/PetscErrorCode.html#PetscErrorCode">PetscErrorCode</A> PetscDrawEllipse_X(<A href="../../../../../docs/manualpages/Draw/PetscDraw.html#PetscDraw">PetscDraw</A> Win, <A href="../../../../../docs/manualpages/Sys/PetscReal.html#PetscReal">PetscReal</A> x, <A href="../../../../../docs/manualpages/Sys/PetscReal.html#PetscReal">PetscReal</A> y, <A href="../../../../../docs/manualpages/Sys/PetscReal.html#PetscReal">PetscReal</A> a, <A href="../../../../../docs/manualpages/Sys/PetscReal.html#PetscReal">PetscReal</A> b, int c)</font></strong>
  75. <a name="line91"> 91: </a>{
  76. <a name="line92"> 92: </a> PetscDraw_X* XiWin = (PetscDraw_X*) Win-&gt;data;
  77. <a name="line93"> 93: </a> int xA, yA, w, h;
  78. <a name="line96"> 96: </a> PetscDrawXiSetColor(XiWin, c);
  79. <a name="line97"> 97: </a> xA = XTRANS(Win, XiWin, x - a/2.0); w = XTRANS(Win, XiWin, x + a/2.0) - xA;
  80. <a name="line98"> 98: </a> yA = YTRANS(Win, XiWin, y + b/2.0); h = YTRANS(Win, XiWin, y - b/2.0) - yA;
  81. <a name="line99"> 99: </a> XFillArc(XiWin-&gt;disp, PetscDrawXiDrawable(XiWin), XiWin-&gt;gc.set, xA, yA, w, h, 0, 23040);
  82. <a name="line100">100: </a> <font color="#4169E1">return</font>(0);
  83. <a name="line101">101: </a>}
  84. <a name="line103">103: </a><strong><font color="#4169E1">extern <A href="../../../../../docs/manualpages/Sys/PetscErrorCode.html#PetscErrorCode">PetscErrorCode</A> PetscDrawInterpolatedTriangle_X(PetscDraw_X*,int,int,int,int,int,int,int,int,int)</font></strong>;
  85. <a name="line107">107: </a><strong><font color="#4169E1"><a name="PetscDrawTriangle_X"></a>static <A href="../../../../../docs/manualpages/Sys/PetscErrorCode.html#PetscErrorCode">PetscErrorCode</A> PetscDrawTriangle_X(<A href="../../../../../docs/manualpages/Draw/PetscDraw.html#PetscDraw">PetscDraw</A> draw,<A href="../../../../../docs/manualpages/Sys/PetscReal.html#PetscReal">PetscReal</A> X1,<A href="../../../../../docs/manualpages/Sys/PetscReal.html#PetscReal">PetscReal</A> Y_1,<A href="../../../../../docs/manualpages/Sys/PetscReal.html#PetscReal">PetscReal</A> X2,<A href="../../../../../docs/manualpages/Sys/PetscReal.html#PetscReal">PetscReal</A> Y2,<A href="../../../../../docs/manualpages/Sys/PetscReal.html#PetscReal">PetscReal</A> X3,<A href="../../../../../docs/manualpages/Sys/PetscReal.html#PetscReal">PetscReal</A> Y3,int c1,int c2,int c3)</font></strong>
  86. <a name="line108">108: </a>{
  87. <a name="line109">109: </a> PetscDraw_X* XiWin = (PetscDraw_X*)draw-&gt;data;
  88. <a name="line113">113: </a> <font color="#4169E1">if</font> (c1 == c2 &amp;&amp; c2 == c3) {
  89. <a name="line114">114: </a> XPoint pt[3];
  90. <a name="line115">115: </a> PetscDrawXiSetColor(XiWin,c1);
  91. <a name="line116">116: </a> pt[0].x = XTRANS(draw,XiWin,X1);
  92. <a name="line117">117: </a> pt[0].y = YTRANS(draw,XiWin,Y_1);
  93. <a name="line118">118: </a> pt[1].x = XTRANS(draw,XiWin,X2);
  94. <a name="line119">119: </a> pt[1].y = YTRANS(draw,XiWin,Y2);
  95. <a name="line120">120: </a> pt[2].x = XTRANS(draw,XiWin,X3);
  96. <a name="line121">121: </a> pt[2].y = YTRANS(draw,XiWin,Y3);
  97. <a name="line122">122: </a> XFillPolygon(XiWin-&gt;disp,PetscDrawXiDrawable(XiWin),XiWin-&gt;gc.set,pt,3,Convex,CoordModeOrigin);
  98. <a name="line123">123: </a> } <font color="#4169E1">else</font> {
  99. <a name="line124">124: </a> int x1,y_1,x2,y2,x3,y3;
  100. <a name="line125">125: </a> x1 = XTRANS(draw,XiWin,X1);
  101. <a name="line126">126: </a> y_1 = YTRANS(draw,XiWin,Y_1);
  102. <a name="line127">127: </a> x2 = XTRANS(draw,XiWin,X2);
  103. <a name="line128">128: </a> y2 = YTRANS(draw,XiWin,Y2);
  104. <a name="line129">129: </a> x3 = XTRANS(draw,XiWin,X3);
  105. <a name="line130">130: </a> y3 = YTRANS(draw,XiWin,Y3);
  106. <a name="line131">131: </a> PetscDrawInterpolatedTriangle_X(XiWin,x1,y_1,c1,x2,y2,c2,x3,y3,c3);
  107. <a name="line132">132: </a> }
  108. <a name="line133">133: </a> <font color="#4169E1">return</font>(0);
  109. <a name="line134">134: </a>}
  110. <a name="line138">138: </a><strong><font color="#4169E1"><a name="PetscDrawString_X"></a>static <A href="../../../../../docs/manualpages/Sys/PetscErrorCode.html#PetscErrorCode">PetscErrorCode</A> PetscDrawString_X(<A href="../../../../../docs/manualpages/Draw/PetscDraw.html#PetscDraw">PetscDraw</A> draw,<A href="../../../../../docs/manualpages/Sys/PetscReal.html#PetscReal">PetscReal</A> x,<A href="../../../../../docs/manualpages/Sys/PetscReal.html#PetscReal">PetscReal</A> y,int c,const char chrs[])</font></strong>
  111. <a name="line139">139: </a>{
  112. <a name="line141">141: </a> int xx,yy;
  113. <a name="line142">142: </a> size_t len;
  114. <a name="line143">143: </a> PetscDraw_X *XiWin = (PetscDraw_X*)draw-&gt;data;
  115. <a name="line144">144: </a> char *substr;
  116. <a name="line145">145: </a> <A href="../../../../../docs/manualpages/Sys/PetscToken.html#PetscToken">PetscToken</A> token;
  117. <a name="line148">148: </a> xx = XTRANS(draw,XiWin,x); yy = YTRANS(draw,XiWin,y);
  118. <a name="line149">149: </a> PetscDrawXiSetColor(XiWin,c);
  119. <a name="line150">150: </a>
  120. <a name="line151">151: </a> <A href="../../../../../docs/manualpages/Sys/PetscTokenCreate.html#PetscTokenCreate">PetscTokenCreate</A>(chrs,'\n',&amp;token);
  121. <a name="line152">152: </a> <A href="../../../../../docs/manualpages/Sys/PetscTokenFind.html#PetscTokenFind">PetscTokenFind</A>(token,&amp;substr);
  122. <a name="line153">153: </a> <A href="../../../../../docs/manualpages/Sys/PetscStrlen.html#PetscStrlen">PetscStrlen</A>(substr,&amp;len);
  123. <a name="line154">154: </a> XDrawString(XiWin-&gt;disp,PetscDrawXiDrawable(XiWin),XiWin-&gt;gc.set,xx,yy - XiWin-&gt;font-&gt;font_descent,substr,len);
  124. <a name="line155">155: </a> <A href="../../../../../docs/manualpages/Sys/PetscTokenFind.html#PetscTokenFind">PetscTokenFind</A>(token,&amp;substr);
  125. <a name="line156">156: </a> <font color="#4169E1">while</font> (substr) {
  126. <a name="line157">157: </a> yy += 4*XiWin-&gt;font-&gt;font_descent;
  127. <a name="line158">158: </a> <A href="../../../../../docs/manualpages/Sys/PetscStrlen.html#PetscStrlen">PetscStrlen</A>(substr,&amp;len);
  128. <a name="line159">159: </a> XDrawString(XiWin-&gt;disp,PetscDrawXiDrawable(XiWin),XiWin-&gt;gc.set,xx,yy - XiWin-&gt;font-&gt;font_descent,substr,len);
  129. <a name="line160">160: </a> <A href="../../../../../docs/manualpages/Sys/PetscTokenFind.html#PetscTokenFind">PetscTokenFind</A>(token,&amp;substr);
  130. <a name="line161">161: </a> }
  131. <a name="line162">162: </a> <A href="../../../../../docs/manualpages/Sys/PetscTokenDestroy.html#PetscTokenDestroy">PetscTokenDestroy</A>(&amp;token);
  132. <a name="line164">164: </a> <font color="#4169E1">return</font>(0);
  133. <a name="line165">165: </a>}
  134. <a name="line167">167: </a><strong><font color="#4169E1">extern <A href="../../../../../docs/manualpages/Sys/PetscErrorCode.html#PetscErrorCode">PetscErrorCode</A> PetscDrawXiFontFixed(PetscDraw_X*,int,int,PetscDrawXiFont **)</font></strong>;
  135. <a name="line171">171: </a><strong><font color="#4169E1"><a name="PetscDrawStringSetSize_X"></a>static <A href="../../../../../docs/manualpages/Sys/PetscErrorCode.html#PetscErrorCode">PetscErrorCode</A> PetscDrawStringSetSize_X(<A href="../../../../../docs/manualpages/Draw/PetscDraw.html#PetscDraw">PetscDraw</A> draw,<A href="../../../../../docs/manualpages/Sys/PetscReal.html#PetscReal">PetscReal</A> x,<A href="../../../../../docs/manualpages/Sys/PetscReal.html#PetscReal">PetscReal</A> y)</font></strong>
  136. <a name="line172">172: </a>{
  137. <a name="line173">173: </a> PetscDraw_X* XiWin = (PetscDraw_X*)draw-&gt;data;
  138. <a name="line175">175: </a> int w,h;
  139. <a name="line178">178: </a> w = (int)((XiWin-&gt;w)*x*(draw-&gt;port_xr - draw-&gt;port_xl)/(draw-&gt;coor_xr - draw-&gt;coor_xl));
  140. <a name="line179">179: </a> h = (int)((XiWin-&gt;h)*y*(draw-&gt;port_yr - draw-&gt;port_yl)/(draw-&gt;coor_yr - draw-&gt;coor_yl));
  141. <a name="line180">180: </a> <A href="../../../../../docs/manualpages/Sys/PetscFree.html#PetscFree">PetscFree</A>(XiWin-&gt;font);
  142. <a name="line181">181: </a> PetscDrawXiFontFixed(XiWin,w,h,&amp;XiWin-&gt;font);
  143. <a name="line182">182: </a> <font color="#4169E1">return</font>(0);
  144. <a name="line183">183: </a>}
  145. <a name="line187">187: </a><strong><font color="#4169E1"><a name="PetscDrawStringGetSize_X"></a><A href="../../../../../docs/manualpages/Sys/PetscErrorCode.html#PetscErrorCode">PetscErrorCode</A> PetscDrawStringGetSize_X(<A href="../../../../../docs/manualpages/Draw/PetscDraw.html#PetscDraw">PetscDraw</A> draw,<A href="../../../../../docs/manualpages/Sys/PetscReal.html#PetscReal">PetscReal</A> *x,<A href="../../../../../docs/manualpages/Sys/PetscReal.html#PetscReal">PetscReal</A> *y)</font></strong>
  146. <a name="line188">188: </a>{
  147. <a name="line189">189: </a> PetscDraw_X* XiWin = (PetscDraw_X*)draw-&gt;data;
  148. <a name="line190">190: </a> <A href="../../../../../docs/manualpages/Sys/PetscReal.html#PetscReal">PetscReal</A> w,h;
  149. <a name="line193">193: </a> w = XiWin-&gt;font-&gt;font_w; h = XiWin-&gt;font-&gt;font_h;
  150. <a name="line194">194: </a> *x = w*(draw-&gt;coor_xr - draw-&gt;coor_xl)/((XiWin-&gt;w)*(draw-&gt;port_xr - draw-&gt;port_xl));
  151. <a name="line195">195: </a> *y = h*(draw-&gt;coor_yr - draw-&gt;coor_yl)/((XiWin-&gt;h)*(draw-&gt;port_yr - draw-&gt;port_yl));
  152. <a name="line196">196: </a> <font color="#4169E1">return</font>(0);
  153. <a name="line197">197: </a>}
  154. <a name="line201">201: </a><strong><font color="#4169E1"><a name="PetscDrawStringVertical_X"></a><A href="../../../../../docs/manualpages/Sys/PetscErrorCode.html#PetscErrorCode">PetscErrorCode</A> PetscDrawStringVertical_X(<A href="../../../../../docs/manualpages/Draw/PetscDraw.html#PetscDraw">PetscDraw</A> draw,<A href="../../../../../docs/manualpages/Sys/PetscReal.html#PetscReal">PetscReal</A> x,<A href="../../../../../docs/manualpages/Sys/PetscReal.html#PetscReal">PetscReal</A> y,int c,const char chrs[])</font></strong>
  155. <a name="line202">202: </a>{
  156. <a name="line204">204: </a> int xx,yy;
  157. <a name="line205">205: </a> PetscDraw_X *XiWin = (PetscDraw_X*)draw-&gt;data;
  158. <a name="line206">206: </a> char tmp[2];
  159. <a name="line207">207: </a> <A href="../../../../../docs/manualpages/Sys/PetscReal.html#PetscReal">PetscReal</A> tw,th;
  160. <a name="line208">208: </a> size_t i,n;
  161. <a name="line209">209: </a>
  162. <a name="line211">211: </a> <A href="../../../../../docs/manualpages/Sys/PetscStrlen.html#PetscStrlen">PetscStrlen</A>(chrs,&amp;n);
  163. <a name="line212">212: </a> tmp[1] = 0;
  164. <a name="line213">213: </a> PetscDrawXiSetColor(XiWin,c);
  165. <a name="line214">214: </a> PetscDrawStringGetSize_X(draw,&amp;tw,&amp;th);
  166. <a name="line215">215: </a> xx = XTRANS(draw,XiWin,x);
  167. <a name="line216">216: </a> <font color="#4169E1">for</font> (i=0; i&lt;n; i++) {
  168. <a name="line217">217: </a> tmp[0] = chrs[i];
  169. <a name="line218">218: </a> yy = YTRANS(draw,XiWin,y-th*i);
  170. <a name="line219">219: </a> XDrawString(XiWin-&gt;disp,PetscDrawXiDrawable(XiWin),XiWin-&gt;gc.set, xx,yy - XiWin-&gt;font-&gt;font_descent,tmp,1);
  171. <a name="line220">220: </a> }
  172. <a name="line221">221: </a> <font color="#4169E1">return</font>(0);
  173. <a name="line222">222: </a>}
  174. <a name="line226">226: </a><strong><font color="#4169E1"><a name="PetscDrawFlush_X"></a>static <A href="../../../../../docs/manualpages/Sys/PetscErrorCode.html#PetscErrorCode">PetscErrorCode</A> PetscDrawFlush_X(<A href="../../../../../docs/manualpages/Draw/PetscDraw.html#PetscDraw">PetscDraw</A> draw)</font></strong>
  175. <a name="line227">227: </a>{
  176. <a name="line228">228: </a> PetscDraw_X* XiWin = (PetscDraw_X*)draw-&gt;data;
  177. <a name="line231">231: </a> <font color="#4169E1">if</font> (XiWin-&gt;drw) {
  178. <a name="line232">232: </a> XCopyArea(XiWin-&gt;disp,XiWin-&gt;drw,XiWin-&gt;win,XiWin-&gt;gc.set,0,0,XiWin-&gt;w,XiWin-&gt;h,0,0);
  179. <a name="line233">233: </a> }
  180. <a name="line234">234: </a> XFlush(XiWin-&gt;disp); XSync(XiWin-&gt;disp,False);
  181. <a name="line235">235: </a> <font color="#4169E1">return</font>(0);
  182. <a name="line236">236: </a>}
  183. <a name="line240">240: </a><strong><font color="#4169E1"><a name="PetscDrawSynchronizedFlush_X"></a>static <A href="../../../../../docs/manualpages/Sys/PetscErrorCode.html#PetscErrorCode">PetscErrorCode</A> PetscDrawSynchronizedFlush_X(<A href="../../../../../docs/manualpages/Draw/PetscDraw.html#PetscDraw">PetscDraw</A> draw)</font></strong>
  184. <a name="line241">241: </a>{
  185. <a name="line243">243: </a> <A href="../../../../../docs/manualpages/Sys/PetscMPIInt.html#PetscMPIInt">PetscMPIInt</A> rank;
  186. <a name="line244">244: </a> PetscDraw_X* XiWin = (PetscDraw_X*)draw-&gt;data;
  187. <a name="line247">247: </a> XFlush(XiWin-&gt;disp);
  188. <a name="line248">248: </a> <font color="#4169E1">if</font> (XiWin-&gt;drw) {
  189. <a name="line249">249: </a> <A href="http://www.mcs.anl.gov/mpi/www/www3/MPI_Comm_rank.html#MPI_Comm_rank">MPI_Comm_rank</A>(((<A href="../../../../../docs/manualpages/Sys/PetscObject.html#PetscObject">PetscObject</A>)draw)-&gt;comm,&amp;rank);
  190. <a name="line250">250: </a> <font color="#B22222">/* make sure data has actually arrived at server */</font>
  191. <a name="line251">251: </a> XSync(XiWin-&gt;disp,False);
  192. <a name="line252">252: </a> <A href="http://www.mcs.anl.gov/mpi/www/www3/MPI_Barrier.html#MPI_Barrier">MPI_Barrier</A>(((<A href="../../../../../docs/manualpages/Sys/PetscObject.html#PetscObject">PetscObject</A>)draw)-&gt;comm);
  193. <a name="line253">253: </a> <font color="#4169E1">if</font> (!rank) {
  194. <a name="line254">254: </a> XCopyArea(XiWin-&gt;disp,XiWin-&gt;drw,XiWin-&gt;win,XiWin-&gt;gc.set,0,0,XiWin-&gt;w,XiWin-&gt;h,0,0);
  195. <a name="line255">255: </a> XFlush(XiWin-&gt;disp);
  196. <a name="line256">256: </a> }
  197. <a name="line257">257: </a> XSync(XiWin-&gt;disp,False);
  198. <a name="line258">258: </a> <A href="http://www.mcs.anl.gov/mpi/www/www3/MPI_Barrier.html#MPI_Barrier">MPI_Barrier</A>(((<A href="../../../../../docs/manualpages/Sys/PetscObject.html#PetscObject">PetscObject</A>)draw)-&gt;comm);
  199. <a name="line259">259: </a> } <font color="#4169E1">else</font> {
  200. <a name="line260">260: </a> <A href="http://www.mcs.anl.gov/mpi/www/www3/MPI_Barrier.html#MPI_Barrier">MPI_Barrier</A>(((<A href="../../../../../docs/manualpages/Sys/PetscObject.html#PetscObject">PetscObject</A>)draw)-&gt;comm);
  201. <a name="line261">261: </a> XSync(XiWin-&gt;disp,False);
  202. <a name="line262">262: </a> <A href="http://www.mcs.anl.gov/mpi/www/www3/MPI_Barrier.html#MPI_Barrier">MPI_Barrier</A>(((<A href="../../../../../docs/manualpages/Sys/PetscObject.html#PetscObject">PetscObject</A>)draw)-&gt;comm);
  203. <a name="line263">263: </a> }
  204. <a name="line264">264: </a> <font color="#4169E1">return</font>(0);
  205. <a name="line265">265: </a>}
  206. <a name="line269">269: </a><strong><font color="#4169E1"><a name="PetscDrawSetViewport_X"></a>static <A href="../../../../../docs/manualpages/Sys/PetscErrorCode.html#PetscErrorCode">PetscErrorCode</A> PetscDrawSetViewport_X(<A href="../../../../../docs/manualpages/Draw/PetscDraw.html#PetscDraw">PetscDraw</A> draw,<A href="../../../../../docs/manualpages/Sys/PetscReal.html#PetscReal">PetscReal</A> xl,<A href="../../../../../docs/manualpages/Sys/PetscReal.html#PetscReal">PetscReal</A> yl,<A href="../../../../../docs/manualpages/Sys/PetscReal.html#PetscReal">PetscReal</A> xr,<A href="../../../../../docs/manualpages/Sys/PetscReal.html#PetscReal">PetscReal</A> yr)</font></strong>
  207. <a name="line270">270: </a>{
  208. <a name="line271">271: </a> PetscDraw_X* XiWin = (PetscDraw_X*)draw-&gt;data;
  209. <a name="line272">272: </a> XRectangle box;
  210. <a name="line275">275: </a> box.x = (int)(xl*XiWin-&gt;w); box.y = (int)((1.0-yr)*XiWin-&gt;h);
  211. <a name="line276">276: </a> box.width = (int)((xr-xl)*XiWin-&gt;w);box.height = (int)((yr-yl)*XiWin-&gt;h);
  212. <a name="line277">277: </a> XSetClipRectangles(XiWin-&gt;disp,XiWin-&gt;gc.set,0,0,&amp;box,1,Unsorted);
  213. <a name="line278">278: </a> <font color="#4169E1">return</font>(0);
  214. <a name="line279">279: </a>}
  215. <a name="line283">283: </a><strong><font color="#4169E1"><a name="PetscDrawClear_X"></a>static <A href="../../../../../docs/manualpages/Sys/PetscErrorCode.html#PetscErrorCode">PetscErrorCode</A> PetscDrawClear_X(<A href="../../../../../docs/manualpages/Draw/PetscDraw.html#PetscDraw">PetscDraw</A> draw)</font></strong>
  216. <a name="line284">284: </a>{
  217. <a name="line285">285: </a> PetscDraw_X* XiWin = (PetscDraw_X*)draw-&gt;data;
  218. <a name="line286">286: </a> int x, y, w, h;
  219. <a name="line290">290: </a> <A href="../../../../../docs/manualpages/Draw/PetscDrawSave.html#PetscDrawSave">PetscDrawSave</A>(draw);
  220. <a name="line291">291: </a> x = (int)(draw-&gt;port_xl*XiWin-&gt;w);
  221. <a name="line292">292: </a> w = (int)((draw-&gt;port_xr - draw-&gt;port_xl)*XiWin-&gt;w);
  222. <a name="line293">293: </a> y = (int)((1.0-draw-&gt;port_yr)*XiWin-&gt;h);
  223. <a name="line294">294: </a> h = (int)((draw-&gt;port_yr - draw-&gt;port_yl)*XiWin-&gt;h);
  224. <a name="line295">295: </a> PetscDrawXiSetPixVal(XiWin,XiWin-&gt;background);
  225. <a name="line296">296: </a> XFillRectangle(XiWin-&gt;disp,PetscDrawXiDrawable(XiWin),XiWin-&gt;gc.set,x,y,w,h);
  226. <a name="line297">297: </a> <font color="#4169E1">return</font>(0);
  227. <a name="line298">298: </a>}
  228. <a name="line302">302: </a><strong><font color="#4169E1"><a name="PetscDrawSynchronizedClear_X"></a>static <A href="../../../../../docs/manualpages/Sys/PetscErrorCode.html#PetscErrorCode">PetscErrorCode</A> PetscDrawSynchronizedClear_X(<A href="../../../../../docs/manualpages/Draw/PetscDraw.html#PetscDraw">PetscDraw</A> draw)</font></strong>
  229. <a name="line303">303: </a>{
  230. <a name="line305">305: </a> <A href="../../../../../docs/manualpages/Sys/PetscMPIInt.html#PetscMPIInt">PetscMPIInt</A> rank;
  231. <a name="line306">306: </a> PetscDraw_X* XiWin = (PetscDraw_X*)draw-&gt;data;
  232. <a name="line309">309: </a> <A href="http://www.mcs.anl.gov/mpi/www/www3/MPI_Barrier.html#MPI_Barrier">MPI_Barrier</A>(((<A href="../../../../../docs/manualpages/Sys/PetscObject.html#PetscObject">PetscObject</A>)draw)-&gt;comm);
  233. <a name="line310">310: </a> <A href="http://www.mcs.anl.gov/mpi/www/www3/MPI_Comm_rank.html#MPI_Comm_rank">MPI_Comm_rank</A>(((<A href="../../../../../docs/manualpages/Sys/PetscObject.html#PetscObject">PetscObject</A>)draw)-&gt;comm,&amp;rank);
  234. <a name="line311">311: </a> <font color="#4169E1">if</font> (!rank) {
  235. <a name="line312">312: </a> PetscDrawClear_X(draw);
  236. <a name="line313">313: </a> }
  237. <a name="line314">314: </a> XFlush(XiWin-&gt;disp);
  238. <a name="line315">315: </a> <A href="http://www.mcs.anl.gov/mpi/www/www3/MPI_Barrier.html#MPI_Barrier">MPI_Barrier</A>(((<A href="../../../../../docs/manualpages/Sys/PetscObject.html#PetscObject">PetscObject</A>)draw)-&gt;comm);
  239. <a name="line316">316: </a> XSync(XiWin-&gt;disp,False);
  240. <a name="line317">317: </a> <A href="http://www.mcs.anl.gov/mpi/www/www3/MPI_Barrier.html#MPI_Barrier">MPI_Barrier</A>(((<A href="../../../../../docs/manualpages/Sys/PetscObject.html#PetscObject">PetscObject</A>)draw)-&gt;comm);
  241. <a name="line318">318: </a> <font color="#4169E1">return</font>(0);
  242. <a name="line319">319: </a>}
  243. <a name="line323">323: </a><strong><font color="#4169E1"><a name="PetscDrawSetDoubleBuffer_X"></a>static <A href="../../../../../docs/manualpages/Sys/PetscErrorCode.html#PetscErrorCode">PetscErrorCode</A> PetscDrawSetDoubleBuffer_X(<A href="../../../../../docs/manualpages/Draw/PetscDraw.html#PetscDraw">PetscDraw</A> draw)</font></strong>
  244. <a name="line324">324: </a>{
  245. <a name="line325">325: </a> PetscDraw_X* win = (PetscDraw_X*)draw-&gt;data;
  246. <a name="line327">327: </a> <A href="../../../../../docs/manualpages/Sys/PetscMPIInt.html#PetscMPIInt">PetscMPIInt</A> rank;
  247. <a name="line330">330: </a> <font color="#4169E1">if</font> (win-&gt;drw) <font color="#4169E1">return</font>(0);
  248. <a name="line332">332: </a> <A href="http://www.mcs.anl.gov/mpi/www/www3/MPI_Comm_rank.html#MPI_Comm_rank">MPI_Comm_rank</A>(((<A href="../../../../../docs/manualpages/Sys/PetscObject.html#PetscObject">PetscObject</A>)draw)-&gt;comm,&amp;rank);
  249. <a name="line333">333: </a> <font color="#4169E1">if</font> (!rank) {
  250. <a name="line334">334: </a> win-&gt;drw = XCreatePixmap(win-&gt;disp,win-&gt;win,win-&gt;w,win-&gt;h,win-&gt;depth);
  251. <a name="line335">335: </a> }
  252. <a name="line336">336: </a> <font color="#B22222">/* try to make sure it is actually done before passing info to all */</font>
  253. <a name="line337">337: </a> XSync(win-&gt;disp,False);
  254. <a name="line338">338: </a> <A href="http://www.mcs.anl.gov/mpi/www/www3/MPI_Bcast.html#MPI_Bcast">MPI_Bcast</A>(&amp;win-&gt;drw,1,MPI_UNSIGNED_LONG,0,((<A href="../../../../../docs/manualpages/Sys/PetscObject.html#PetscObject">PetscObject</A>)draw)-&gt;comm);
  255. <a name="line339">339: </a> <font color="#4169E1">return</font>(0);
  256. <a name="line340">340: </a>}
  257. <a name="line342">342: </a><font color="#A020F0">#include &lt;X11/cursorfont.h&gt;</font>
  258. <a name="line346">346: </a><strong><font color="#4169E1"><a name="PetscDrawGetMouseButton_X"></a>static <A href="../../../../../docs/manualpages/Sys/PetscErrorCode.html#PetscErrorCode">PetscErrorCode</A> PetscDrawGetMouseButton_X(<A href="../../../../../docs/manualpages/Draw/PetscDraw.html#PetscDraw">PetscDraw</A> draw,<A href="../../../../../docs/manualpages/Draw/PetscDrawButton.html#PetscDrawButton">PetscDrawButton</A> *button,<A href="../../../../../docs/manualpages/Sys/PetscReal.html#PetscReal">PetscReal</A>* x_user,<A href="../../../../../docs/manualpages/Sys/PetscReal.html#PetscReal">PetscReal</A> *y_user,<A href="../../../../../docs/manualpages/Sys/PetscReal.html#PetscReal">PetscReal</A> *x_phys,<A href="../../../../../docs/manualpages/Sys/PetscReal.html#PetscReal">PetscReal</A> *y_phys)</font></strong>
  259. <a name="line347">347: </a>{
  260. <a name="line348">348: </a> XEvent report;
  261. <a name="line349">349: </a> PetscDraw_X* win = (PetscDraw_X*)draw-&gt;data;
  262. <a name="line350">350: </a> Window root,child;
  263. <a name="line351">351: </a> int root_x,root_y,px,py;
  264. <a name="line352">352: </a> unsigned int keys_button;
  265. <a name="line353">353: </a> Cursor cursor = 0;
  266. <a name="line356">356: </a> <font color="#B22222">/* change cursor to indicate input */</font>
  267. <a name="line357">357: </a> <font color="#4169E1">if</font> (!cursor) {
  268. <a name="line358">358: </a> cursor = XCreateFontCursor(win-&gt;disp,XC_hand2);
  269. <a name="line359">359: </a> <font color="#4169E1">if</font> (!cursor) <A href="../../../../../docs/manualpages/Sys/SETERRQ.html#SETERRQ">SETERRQ</A>(<A href="../../../../../docs/manualpages/Sys/PETSC_COMM_SELF.html#PETSC_COMM_SELF">PETSC_COMM_SELF</A>,PETSC_ERR_LIB,<font color="#666666">"Unable to create X cursor"</font>);
  270. <a name="line360">360: </a> }
  271. <a name="line361">361: </a> XDefineCursor(win-&gt;disp,win-&gt;win,cursor);
  272. <a name="line362">362: </a> XSelectInput(win-&gt;disp,win-&gt;win,ButtonPressMask | ButtonReleaseMask);
  273. <a name="line364">364: </a> <font color="#4169E1">while</font> (XCheckTypedEvent(win-&gt;disp,ButtonPress,&amp;report));
  274. <a name="line365">365: </a> XMaskEvent(win-&gt;disp,ButtonReleaseMask,&amp;report);
  275. <a name="line366">366: </a> <font color="#4169E1">switch</font> (report.xbutton.button) {
  276. <a name="line367">367: </a> <font color="#4169E1">case</font> Button1:
  277. <a name="line368">368: </a> <font color="#4169E1">if</font> (report.xbutton.state &amp; ShiftMask)
  278. <a name="line369">369: </a> *button = PETSC_BUTTON_LEFT_SHIFT;
  279. <a name="line370">370: </a> <font color="#4169E1">else</font>
  280. <a name="line371">371: </a> *button = PETSC_BUTTON_LEFT;
  281. <a name="line372">372: </a> <font color="#4169E1">break</font>;
  282. <a name="line373">373: </a> <font color="#4169E1">case</font> Button2:
  283. <a name="line374">374: </a> <font color="#4169E1">if</font> (report.xbutton.state &amp; ShiftMask)
  284. <a name="line375">375: </a> *button = PETSC_BUTTON_CENTER_SHIFT;
  285. <a name="line376">376: </a> <font color="#4169E1">else</font>
  286. <a name="line377">377: </a> *button = PETSC_BUTTON_CENTER;
  287. <a name="line378">378: </a> <font color="#4169E1">break</font>;
  288. <a name="line379">379: </a> <font color="#4169E1">case</font> Button3:
  289. <a name="line380">380: </a> <font color="#4169E1">if</font> (report.xbutton.state &amp; ShiftMask)
  290. <a name="line381">381: </a> *button = PETSC_BUTTON_RIGHT_SHIFT;
  291. <a name="line382">382: </a> <font color="#4169E1">else</font>
  292. <a name="line383">383: </a> *button = PETSC_BUTTON_RIGHT;
  293. <a name="line384">384: </a> <font color="#4169E1">break</font>;
  294. <a name="line385">385: </a> }
  295. <a name="line386">386: </a> XQueryPointer(win-&gt;disp,report.xmotion.window,&amp;root,&amp;child,&amp;root_x,&amp;root_y,&amp;px,&amp;py,&amp;keys_button);
  296. <a name="line388">388: </a> <font color="#4169E1">if</font> (x_phys) *x_phys = ((double)px)/((double)win-&gt;w);
  297. <a name="line389">389: </a> <font color="#4169E1">if</font> (y_phys) *y_phys = 1.0 - ((double)py)/((double)win-&gt;h);
  298. <a name="line391">391: </a> <font color="#4169E1">if</font> (x_user) *x_user = draw-&gt;coor_xl + ((((double)px)/((double)win-&gt;w)-draw-&gt;port_xl))*(draw-&gt;coor_xr - draw-&gt;coor_xl)/(draw-&gt;port_xr - draw-&gt;port_xl);
  299. <a name="line392">392: </a> <font color="#4169E1">if</font> (y_user) *y_user = draw-&gt;coor_yl + ((1.0 - ((double)py)/((double)win-&gt;h)-draw-&gt;port_yl))*(draw-&gt;coor_yr - draw-&gt;coor_yl)/(draw-&gt;port_yr - draw-&gt;port_yl);
  300. <a name="line394">394: </a> XUndefineCursor(win-&gt;disp,win-&gt;win);
  301. <a name="line395">395: </a> XFlush(win-&gt;disp); XSync(win-&gt;disp,False);
  302. <a name="line396">396: </a> <font color="#4169E1">return</font>(0);
  303. <a name="line397">397: </a>}
  304. <a name="line401">401: </a><strong><font color="#4169E1"><a name="PetscDrawPause_X"></a>static <A href="../../../../../docs/manualpages/Sys/PetscErrorCode.html#PetscErrorCode">PetscErrorCode</A> PetscDrawPause_X(<A href="../../../../../docs/manualpages/Draw/PetscDraw.html#PetscDraw">PetscDraw</A> draw)</font></strong>
  305. <a name="line402">402: </a>{
  306. <a name="line406">406: </a> <font color="#4169E1">if</font> (draw-&gt;pause &gt; 0) <A href="../../../../../docs/manualpages/Sys/PetscSleep.html#PetscSleep">PetscSleep</A>(draw-&gt;pause);
  307. <a name="line407">407: </a> <font color="#4169E1">else</font> <font color="#4169E1">if</font> (draw-&gt;pause &lt; 0) {
  308. <a name="line408">408: </a> <A href="../../../../../docs/manualpages/Draw/PetscDrawButton.html#PetscDrawButton">PetscDrawButton</A> button;
  309. <a name="line409">409: </a> <A href="../../../../../docs/manualpages/Sys/PetscMPIInt.html#PetscMPIInt">PetscMPIInt</A> rank;
  310. <a name="line410">410: </a> <A href="http://www.mcs.anl.gov/mpi/www/www3/MPI_Comm_rank.html#MPI_Comm_rank">MPI_Comm_rank</A>(((<A href="../../../../../docs/manualpages/Sys/PetscObject.html#PetscObject">PetscObject</A>)draw)-&gt;comm,&amp;rank);
  311. <a name="line411">411: </a> <font color="#4169E1">if</font> (!rank) {
  312. <a name="line412">412: </a> <A href="../../../../../docs/manualpages/Draw/PetscDrawGetMouseButton.html#PetscDrawGetMouseButton">PetscDrawGetMouseButton</A>(draw,&amp;button,0,0,0,0);
  313. <a name="line413">413: </a> <font color="#4169E1">if</font> (button == PETSC_BUTTON_CENTER) draw-&gt;pause = 0;
  314. <a name="line414">414: </a> }
  315. <a name="line415">415: </a> <A href="http://www.mcs.anl.gov/mpi/www/www3/MPI_Bcast.html#MPI_Bcast">MPI_Bcast</A>(&amp;draw-&gt;pause,1,MPI_INT,0,((<A href="../../../../../docs/manualpages/Sys/PetscObject.html#PetscObject">PetscObject</A>)draw)-&gt;comm);
  316. <a name="line416">416: </a> }
  317. <a name="line417">417: </a> <font color="#4169E1">return</font>(0);
  318. <a name="line418">418: </a>}
  319. <a name="line422">422: </a><strong><font color="#4169E1"><a name="PetscDrawGetPopup_X"></a>static <A href="../../../../../docs/manualpages/Sys/PetscErrorCode.html#PetscErrorCode">PetscErrorCode</A> PetscDrawGetPopup_X(<A href="../../../../../docs/manualpages/Draw/PetscDraw.html#PetscDraw">PetscDraw</A> draw,<A href="../../../../../docs/manualpages/Draw/PetscDraw.html#PetscDraw">PetscDraw</A> *popup)</font></strong>
  320. <a name="line423">423: </a>{
  321. <a name="line425">425: </a> PetscDraw_X* win = (PetscDraw_X*)draw-&gt;data;
  322. <a name="line428">428: </a> <A href="../../../../../docs/manualpages/Draw/PetscDrawOpenX.html#PetscDrawOpenX">PetscDrawOpenX</A>(((<A href="../../../../../docs/manualpages/Sys/PetscObject.html#PetscObject">PetscObject</A>)draw)-&gt;comm,<A href="../../../../../docs/manualpages/Sys/PETSC_NULL.html#PETSC_NULL">PETSC_NULL</A>,<A href="../../../../../docs/manualpages/Sys/PETSC_NULL.html#PETSC_NULL">PETSC_NULL</A>,win-&gt;x,win-&gt;y+win-&gt;h+36,220,220,popup);
  323. <a name="line429">429: </a> draw-&gt;popup = *popup;
  324. <a name="line430">430: </a> <font color="#4169E1">return</font>(0);
  325. <a name="line431">431: </a>}
  326. <a name="line435">435: </a><strong><font color="#4169E1"><a name="PetscDrawSetTitle_X"></a>static <A href="../../../../../docs/manualpages/Sys/PetscErrorCode.html#PetscErrorCode">PetscErrorCode</A> PetscDrawSetTitle_X(<A href="../../../../../docs/manualpages/Draw/PetscDraw.html#PetscDraw">PetscDraw</A> draw,const char title[])</font></strong>
  327. <a name="line436">436: </a>{
  328. <a name="line437">437: </a> PetscDraw_X *win = (PetscDraw_X*)draw-&gt;data;
  329. <a name="line438">438: </a> XTextProperty prop;
  330. <a name="line440">440: </a> size_t len;
  331. <a name="line443">443: </a> XGetWMName(win-&gt;disp,win-&gt;win,&amp;prop);
  332. <a name="line444">444: </a> XFree((void*)prop.value);
  333. <a name="line445">445: </a> prop.value = (unsigned char *)title;
  334. <a name="line446">446: </a> <A href="../../../../../docs/manualpages/Sys/PetscStrlen.html#PetscStrlen">PetscStrlen</A>(title,&amp;len);
  335. <a name="line447">447: </a> prop.nitems = (long) len;
  336. <a name="line448">448: </a> XSetWMName(win-&gt;disp,win-&gt;win,&amp;prop);
  337. <a name="line449">449: </a> <font color="#4169E1">return</font>(0);
  338. <a name="line450">450: </a>}
  339. <a name="line454">454: </a><strong><font color="#4169E1"><a name="PetscDrawResizeWindow_X"></a>static <A href="../../../../../docs/manualpages/Sys/PetscErrorCode.html#PetscErrorCode">PetscErrorCode</A> PetscDrawResizeWindow_X(<A href="../../../../../docs/manualpages/Draw/PetscDraw.html#PetscDraw">PetscDraw</A> draw,int w,int h)</font></strong>
  340. <a name="line455">455: </a>{
  341. <a name="line456">456: </a> PetscDraw_X *win = (PetscDraw_X*)draw-&gt;data;
  342. <a name="line457">457: </a> unsigned int ww,hh,border,depth;
  343. <a name="line458">458: </a> int x,y;
  344. <a name="line460">460: </a> Window root;
  345. <a name="line463">463: </a> XResizeWindow(win-&gt;disp,win-&gt;win,w,h);
  346. <a name="line464">464: </a> XGetGeometry(win-&gt;disp,win-&gt;win,&amp;root,&amp;x,&amp;y,&amp;ww,&amp;hh,&amp;border,&amp;depth);
  347. <a name="line465">465: </a> <A href="../../../../../docs/manualpages/Draw/PetscDrawCheckResizedWindow.html#PetscDrawCheckResizedWindow">PetscDrawCheckResizedWindow</A>(draw);
  348. <a name="line466">466: </a> <font color="#4169E1">return</font>(0);
  349. <a name="line467">467: </a>}
  350. <a name="line471">471: </a><strong><font color="#4169E1"><a name="PetscDrawCheckResizedWindow_X"></a>static <A href="../../../../../docs/manualpages/Sys/PetscErrorCode.html#PetscErrorCode">PetscErrorCode</A> PetscDrawCheckResizedWindow_X(<A href="../../../../../docs/manualpages/Draw/PetscDraw.html#PetscDraw">PetscDraw</A> draw)</font></strong>
  351. <a name="line472">472: </a>{
  352. <a name="line473">473: </a> PetscDraw_X *win = (PetscDraw_X*)draw-&gt;data;
  353. <a name="line475">475: </a> int x,y;
  354. <a name="line476">476: </a> <A href="../../../../../docs/manualpages/Sys/PetscMPIInt.html#PetscMPIInt">PetscMPIInt</A> rank;
  355. <a name="line477">477: </a> Window root;
  356. <a name="line478">478: </a> unsigned int w,h,border,depth,geo[2];
  357. <a name="line479">479: </a> <A href="../../../../../docs/manualpages/Sys/PetscReal.html#PetscReal">PetscReal</A> xl,xr,yl,yr;
  358. <a name="line480">480: </a> XRectangle box;
  359. <a name="line483">483: </a> <A href="http://www.mcs.anl.gov/mpi/www/www3/MPI_Comm_rank.html#MPI_Comm_rank">MPI_Comm_rank</A>(((<A href="../../../../../docs/manualpages/Sys/PetscObject.html#PetscObject">PetscObject</A>)draw)-&gt;comm,&amp;rank);
  360. <a name="line484">484: </a> <font color="#4169E1">if</font> (!rank) {
  361. <a name="line485">485: </a> XSync(win-&gt;disp,False);
  362. <a name="line486">486: </a> XGetGeometry(win-&gt;disp,win-&gt;win,&amp;root,&amp;x,&amp;y,geo,geo+1,&amp;border,&amp;depth);
  363. <a name="line487">487: </a> }
  364. <a name="line488">488: </a> <A href="http://www.mcs.anl.gov/mpi/www/www3/MPI_Bcast.html#MPI_Bcast">MPI_Bcast</A>(geo,2,MPI_INT,0,((<A href="../../../../../docs/manualpages/Sys/PetscObject.html#PetscObject">PetscObject</A>)draw)-&gt;comm);
  365. <a name="line489">489: </a> w = geo[0];
  366. <a name="line490">490: </a> h = geo[1];
  367. <a name="line491">491: </a> <font color="#4169E1">if</font> (w == (unsigned int) win-&gt;w &amp;&amp; h == (unsigned int) win-&gt;h) <font color="#4169E1">return</font>(0);
  368. <a name="line493">493: </a> <font color="#B22222">/* record new window sizes */</font>
  369. <a name="line495">495: </a> win-&gt;h = h; win-&gt;w = w;
  370. <a name="line497">497: </a> <font color="#B22222">/* Free buffer space and create new version (only first processor does this) */</font>
  371. <a name="line498">498: </a> <font color="#4169E1">if</font> (win-&gt;drw) {
  372. <a name="line499">499: </a> win-&gt;drw = XCreatePixmap(win-&gt;disp,win-&gt;win,win-&gt;w,win-&gt;h,win-&gt;depth);
  373. <a name="line500">500: </a> }
  374. <a name="line501">501: </a> <font color="#B22222">/* reset the clipping */</font>
  375. <a name="line502">502: </a> xl = draw-&gt;port_xl; yl = draw-&gt;port_yl;
  376. <a name="line503">503: </a> xr = draw-&gt;port_xr; yr = draw-&gt;port_yr;
  377. <a name="line504">504: </a> box.x = (int)(xl*win-&gt;w); box.y = (int)((1.0-yr)*win-&gt;h);
  378. <a name="line505">505: </a> box.width = (int)((xr-xl)*win-&gt;w);box.height = (int)((yr-yl)*win-&gt;h);
  379. <a name="line506">506: </a> XSetClipRectangles(win-&gt;disp,win-&gt;gc.set,0,0,&amp;box,1,Unsorted);
  380. <a name="line508">508: </a> <font color="#B22222">/* try to make sure it is actually done before passing info to all */</font>
  381. <a name="line509">509: </a> XSync(win-&gt;disp,False);
  382. <a name="line510">510: </a> <A href="http://www.mcs.anl.gov/mpi/www/www3/MPI_Bcast.html#MPI_Bcast">MPI_Bcast</A>(&amp;win-&gt;drw,1,MPI_UNSIGNED_LONG,0,((<A href="../../../../../docs/manualpages/Sys/PetscObject.html#PetscObject">PetscObject</A>)draw)-&gt;comm);
  383. <a name="line511">511: </a> <font color="#4169E1">return</font>(0);
  384. <a name="line512">512: </a>}
  385. <a name="line514">514: </a><strong><font color="#4169E1">static <A href="../../../../../docs/manualpages/Sys/PetscErrorCode.html#PetscErrorCode">PetscErrorCode</A> PetscDrawGetSingleton_X(<A href="../../../../../docs/manualpages/Draw/PetscDraw.html#PetscDraw">PetscDraw</A>,<A href="../../../../../docs/manualpages/Draw/PetscDraw.html#PetscDraw">PetscDraw</A>*)</font></strong>;
  386. <a name="line515">515: </a><strong><font color="#4169E1">static <A href="../../../../../docs/manualpages/Sys/PetscErrorCode.html#PetscErrorCode">PetscErrorCode</A> PetscDrawRestoreSingleton_X(<A href="../../../../../docs/manualpages/Draw/PetscDraw.html#PetscDraw">PetscDraw</A>,<A href="../../../../../docs/manualpages/Draw/PetscDraw.html#PetscDraw">PetscDraw</A>*)</font></strong>;
  387. <a name="line519">519: </a><strong><font color="#4169E1"><a name="PetscDrawDestroy_X"></a><A href="../../../../../docs/manualpages/Sys/PetscErrorCode.html#PetscErrorCode">PetscErrorCode</A> PetscDrawDestroy_X(<A href="../../../../../docs/manualpages/Draw/PetscDraw.html#PetscDraw">PetscDraw</A> draw)</font></strong>
  388. <a name="line520">520: </a>{
  389. <a name="line521">521: </a> PetscDraw_X *win = (PetscDraw_X*)draw-&gt;data;
  390. <a name="line523">523: </a><font color="#A020F0">#if defined(PETSC_HAVE_POPEN)</font>
  391. <a name="line524">524: </a> char command[PETSC_MAX_PATH_LEN];
  392. <a name="line525">525: </a> <A href="../../../../../docs/manualpages/Sys/PetscMPIInt.html#PetscMPIInt">PetscMPIInt</A> rank;
  393. <a name="line526">526: </a> FILE *fd;
  394. <a name="line527">527: </a><font color="#A020F0">#endif</font>
  395. <a name="line530">530: </a> <A href="../../../../../docs/manualpages/Draw/PetscDrawSynchronizedClear.html#PetscDrawSynchronizedClear">PetscDrawSynchronizedClear</A>(draw);
  396. <a name="line532">532: </a><font color="#A020F0">#if defined(PETSC_HAVE_POPEN)</font>
  397. <a name="line533">533: </a> <A href="http://www.mcs.anl.gov/mpi/www/www3/MPI_Comm_rank.html#MPI_Comm_rank">MPI_Comm_rank</A>(((<A href="../../../../../docs/manualpages/Sys/PetscObject.html#PetscObject">PetscObject</A>)draw)-&gt;comm,&amp;rank);
  398. <a name="line534">534: </a> <font color="#4169E1">if</font> (draw-&gt;savefilename &amp;&amp; !rank &amp;&amp; draw-&gt;savefilemovie) {
  399. <a name="line535">535: </a> <A href="../../../../../docs/manualpages/Sys/PetscSNPrintf.html#PetscSNPrintf">PetscSNPrintf</A>(command,PETSC_MAX_PATH_LEN,<font color="#666666">"ffmpeg -i %s_%%d.Gif %s.m4v"</font>,draw-&gt;savefilename,draw-&gt;savefilename);
  400. <a name="line536">536: </a> <A href="../../../../../docs/manualpages/Sys/PetscPOpen.html#PetscPOpen">PetscPOpen</A>(((<A href="../../../../../docs/manualpages/Sys/PetscObject.html#PetscObject">PetscObject</A>)draw)-&gt;comm,<A href="../../../../../docs/manualpages/Sys/PETSC_NULL.html#PETSC_NULL">PETSC_NULL</A>,command,<font color="#666666">"r"</font>,&amp;fd);
  401. <a name="line537">537: </a> <A href="../../../../../docs/manualpages/Sys/PetscPClose.html#PetscPClose">PetscPClose</A>(((<A href="../../../../../docs/manualpages/Sys/PetscObject.html#PetscObject">PetscObject</A>)draw)-&gt;comm,fd);
  402. <a name="line538">538: </a> }
  403. <a name="line539">539: </a><font color="#A020F0">#endif</font>
  404. <a name="line541">541: </a> XFreeGC(win-&gt;disp,win-&gt;gc.set);
  405. <a name="line542">542: </a> XCloseDisplay(win-&gt;disp);
  406. <a name="line543">543: </a> <A href="../../../../../docs/manualpages/Draw/PetscDrawDestroy.html#PetscDrawDestroy">PetscDrawDestroy</A>(&amp;draw-&gt;popup);
  407. <a name="line544">544: </a> <A href="../../../../../docs/manualpages/Sys/PetscFree.html#PetscFree">PetscFree</A>(win-&gt;font);
  408. <a name="line545">545: </a> <A href="../../../../../docs/manualpages/Sys/PetscFree.html#PetscFree">PetscFree</A>(win);
  409. <a name="line546">546: </a> <font color="#4169E1">return</font>(0);
  410. <a name="line547">547: </a>}
  411. <a name="line549">549: </a><strong><font color="#4169E1"><A href="../../../../../docs/manualpages/Sys/PetscErrorCode.html#PetscErrorCode">PetscErrorCode</A> PetscDrawSave_X(<A href="../../../../../docs/manualpages/Draw/PetscDraw.html#PetscDraw">PetscDraw</A>)</font></strong>;
  412. <a name="line550">550: </a><strong><font color="#4169E1"><A href="../../../../../docs/manualpages/Sys/PetscErrorCode.html#PetscErrorCode">PetscErrorCode</A> PetscDrawSetSave_X(<A href="../../../../../docs/manualpages/Draw/PetscDraw.html#PetscDraw">PetscDraw</A>,const char*)</font></strong>;
  413. <a name="line552">552: </a>static <font color="#4169E1">struct _PetscDrawOps</font> DvOps = { PetscDrawSetDoubleBuffer_X,
  414. <a name="line553">553: </a> PetscDrawFlush_X,PetscDrawLine_X,
  415. <a name="line554">554: </a> 0,
  416. <a name="line555">555: </a> 0,
  417. <a name="line556">556: </a> PetscDrawPoint_X,
  418. <a name="line557">557: </a> 0,
  419. <a name="line558">558: </a> PetscDrawString_X,
  420. <a name="line559">559: </a> PetscDrawStringVertical_X,
  421. <a name="line560">560: </a> PetscDrawStringSetSize_X,
  422. <a name="line561">561: </a> PetscDrawStringGetSize_X,
  423. <a name="line562">562: </a> PetscDrawSetViewport_X,
  424. <a name="line563">563: </a> PetscDrawClear_X,
  425. <a name="line564">564: </a> PetscDrawSynchronizedFlush_X,
  426. <a name="line565">565: </a> PetscDrawRectangle_X,
  427. <a name="line566">566: </a> PetscDrawTriangle_X,
  428. <a name="line567">567: </a> PetscDrawEllipse_X,
  429. <a name="line568">568: </a> PetscDrawGetMouseButton_X,
  430. <a name="line569">569: </a> PetscDrawPause_X,
  431. <a name="line570">570: </a> PetscDrawSynchronizedClear_X,
  432. <a name="line571">571: </a> 0,
  433. <a name="line572">572: </a> 0,
  434. <a name="line573">573: </a> PetscDrawGetPopup_X,
  435. <a name="line574">574: </a> PetscDrawSetTitle_X,
  436. <a name="line575">575: </a> PetscDrawCheckResizedWindow_X,
  437. <a name="line576">576: </a> PetscDrawResizeWindow_X,
  438. <a name="line577">577: </a> PetscDrawDestroy_X,
  439. <a name="line578">578: </a> 0,
  440. <a name="line579">579: </a> PetscDrawGetSingleton_X,
  441. <a name="line580">580: </a> PetscDrawRestoreSingleton_X,
  442. <a name="line581">581: </a><font color="#A020F0">#if defined(PETSC_HAVE_AFTERIMAGE)</font>
  443. <a name="line582">582: </a> PetscDrawSave_X,
  444. <a name="line583">583: </a><font color="#A020F0">#else</font>
  445. <a name="line584">584: </a> 0,
  446. <a name="line585">585: </a><font color="#A020F0">#endif</font>
  447. <a name="line586">586: </a> PetscDrawSetSave_X,
  448. <a name="line587">587: </a> 0,
  449. <a name="line588">588: </a> PetscDrawArrow_X};
  450. <a name="line591">591: </a><strong><font colo