PageRenderTime 80ms CodeModel.GetById 15ms RepoModel.GetById 0ms app.codeStats 0ms

/hpc_kernel_samples/sparse_linear_algebra/casestudies/pagerank-petsc/petsc-2.3.2-p10/src/sys/draw/impls/x/xops.c.html

https://gitlab.com/steinret/CodeVault
HTML | 528 lines | 454 code | 74 blank | 0 comment | 0 complexity | 1558f133b350c104c31d1f9eb941cd7c MD5 | raw file
  1. <center><a href="xops.c">Actual source code: xops.c</a></center><br>
  2. <html>
  3. <head>
  4. <title></title>
  5. <meta name="generator" content="c2html 0.9.5">
  6. <meta name="date" content="2007-03-29T00:17:43+00:00">
  7. </head>
  8. <body bgcolor="#FFFFFF">
  9. <pre width="80">
  10. <a name="line2"> 2: </a><font color="#B22222">/*</font>
  11. <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>
  12. <a name="line4"> 4: </a><font color="#B22222">*/</font>
  13. <a name="line6"> 6: </a> #include <A href="../../../../../src/sys/draw/impls/x/ximpl.h.html">src/sys/draw/impls/x/ximpl.h</A>
  14. <a name="line8"> 8: </a><font color="#B22222">/*</font>
  15. <a name="line9"> 9: </a><font color="#B22222"> These macros transform from the users coordinates to the </font>
  16. <a name="line10"> 10: </a><font color="#B22222"> X-window pixel coordinates.</font>
  17. <a name="line11"> 11: </a><font color="#B22222">*/</font>
  18. <a name="line12"> 12: </a><strong><font color="#228B22">#define XTRANS(draw,xwin,x) \</font></strong>
  19. <a name="line13"> 13: </a><strong><font color="#228B22"> (int)(((xwin)-&gt;w)*((draw)-&gt;port_xl + (((x - (draw)-&gt;coor_xl)*\</font></strong>
  20. <a name="line14"> 14: </a><strong><font color="#228B22"> ((draw)-&gt;port_xr - (draw)-&gt;port_xl))/\</font></strong>
  21. <a name="line15"> 15: </a><strong><font color="#228B22"> ((draw)-&gt;coor_xr - (draw)-&gt;coor_xl))))</font></strong>
  22. <a name="line16"> 16: </a><strong><font color="#228B22">#define YTRANS(draw,xwin,y) \</font></strong>
  23. <a name="line17"> 17: </a><strong><font color="#228B22"> (int)(((xwin)-&gt;h)*(1.0-(draw)-&gt;port_yl - (((y - (draw)-&gt;coor_yl)*\</font></strong>
  24. <a name="line18"> 18: </a><strong><font color="#228B22"> ((draw)-&gt;port_yr - (draw)-&gt;port_yl))/\</font></strong>
  25. <a name="line19"> 19: </a><strong><font color="#228B22"> ((draw)-&gt;coor_yr - (draw)-&gt;coor_yl))))</font></strong>
  26. <a name="line23"> 23: </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>
  27. <a name="line24"> 24: </a>{
  28. <a name="line25"> 25: </a> PetscDraw_X* XiWin = (PetscDraw_X*)draw-&gt;data;
  29. <a name="line26"> 26: </a> int x1,y_1,x2,y2;
  30. <a name="line29"> 29: </a> XiSetColor(XiWin,cl);
  31. <a name="line30"> 30: </a> x1 = XTRANS(draw,XiWin,xl); x2 = XTRANS(draw,XiWin,xr);
  32. <a name="line31"> 31: </a> y_1 = YTRANS(draw,XiWin,yl); y2 = YTRANS(draw,XiWin,yr);
  33. <a name="line32"> 32: </a> XDrawLine(XiWin-&gt;disp,XiDrawable(XiWin),XiWin-&gt;gc.set,x1,y_1,x2,y2);
  34. <a name="line33"> 33: </a> <font color="#4169E1">return</font>(0);
  35. <a name="line34"> 34: </a>}
  36. <a name="line38"> 38: </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>
  37. <a name="line39"> 39: </a>{
  38. <a name="line40"> 40: </a> int xx,yy;
  39. <a name="line41"> 41: </a> PetscDraw_X* XiWin = (PetscDraw_X*)draw-&gt;data;
  40. <a name="line44"> 44: </a> xx = XTRANS(draw,XiWin,x); yy = YTRANS(draw,XiWin,y);
  41. <a name="line45"> 45: </a> XiSetColor(XiWin,c);
  42. <a name="line46"> 46: </a> XDrawPoint(XiWin-&gt;disp,XiDrawable(XiWin),XiWin-&gt;gc.set,xx,yy);
  43. <a name="line47"> 47: </a> <font color="#4169E1">return</font>(0);
  44. <a name="line48"> 48: </a>}
  45. <a name="line52"> 52: </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>
  46. <a name="line53"> 53: </a>{
  47. <a name="line54"> 54: </a> PetscDraw_X* XiWin = (PetscDraw_X*)draw-&gt;data;
  48. <a name="line55"> 55: </a> int x1,y_1,w,h,c = (c1 + c2 + c3 + c4)/4;
  49. <a name="line58"> 58: </a> XiSetColor(XiWin,c);
  50. <a name="line59"> 59: </a> x1 = XTRANS(draw,XiWin,xl); w = XTRANS(draw,XiWin,xr) - x1;
  51. <a name="line60"> 60: </a> y_1 = YTRANS(draw,XiWin,yr); h = YTRANS(draw,XiWin,yl) - y_1;
  52. <a name="line61"> 61: </a> <font color="#4169E1">if</font> (w &lt;= 0) w = 1; <font color="#4169E1">if</font> (h &lt;= 0) h = 1;
  53. <a name="line62"> 62: </a> XFillRectangle(XiWin-&gt;disp,XiDrawable(XiWin),XiWin-&gt;gc.set,x1,y_1,w,h);
  54. <a name="line63"> 63: </a> <font color="#4169E1">return</font>(0);
  55. <a name="line64"> 64: </a>}
  56. <a name="line68"> 68: </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>
  57. <a name="line69"> 69: </a>{
  58. <a name="line70"> 70: </a> PetscDraw_X* XiWin = (PetscDraw_X*) Win-&gt;data;
  59. <a name="line71"> 71: </a> int xA, yA, w, h;
  60. <a name="line74"> 74: </a> XiSetColor(XiWin, c);
  61. <a name="line75"> 75: </a> xA = XTRANS(Win, XiWin, x - a/2.0); w = XTRANS(Win, XiWin, x + a/2.0) - xA;
  62. <a name="line76"> 76: </a> yA = YTRANS(Win, XiWin, y + b/2.0); h = YTRANS(Win, XiWin, y - b/2.0) - yA;
  63. <a name="line77"> 77: </a> XFillArc(XiWin-&gt;disp, XiDrawable(XiWin), XiWin-&gt;gc.set, xA, yA, w, h, 0, 23040);
  64. <a name="line78"> 78: </a> <font color="#4169E1">return</font>(0);
  65. <a name="line79"> 79: </a>}
  66. <a name="line81"> 81: </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>;
  67. <a name="line85"> 85: </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,</font></strong>
  68. <a name="line86"> 86: </a><strong><font color="#4169E1"> <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>
  69. <a name="line87"> 87: </a>{
  70. <a name="line88"> 88: </a> PetscDraw_X* XiWin = (PetscDraw_X*)draw-&gt;data;
  71. <a name="line92"> 92: </a> <font color="#4169E1">if</font> (c1 == c2 &amp;&amp; c2 == c3) {
  72. <a name="line93"> 93: </a> XPoint pt[3];
  73. <a name="line94"> 94: </a> XiSetColor(XiWin,c1);
  74. <a name="line95"> 95: </a> pt[0].x = XTRANS(draw,XiWin,X1);
  75. <a name="line96"> 96: </a> pt[0].y = YTRANS(draw,XiWin,Y_1);
  76. <a name="line97"> 97: </a> pt[1].x = XTRANS(draw,XiWin,X2);
  77. <a name="line98"> 98: </a> pt[1].y = YTRANS(draw,XiWin,Y2);
  78. <a name="line99"> 99: </a> pt[2].x = XTRANS(draw,XiWin,X3);
  79. <a name="line100">100: </a> pt[2].y = YTRANS(draw,XiWin,Y3);
  80. <a name="line101">101: </a> XFillPolygon(XiWin-&gt;disp,XiDrawable(XiWin),XiWin-&gt;gc.set,pt,3,Convex,CoordModeOrigin);
  81. <a name="line102">102: </a> } <font color="#4169E1">else</font> {
  82. <a name="line103">103: </a> int x1,y_1,x2,y2,x3,y3;
  83. <a name="line104">104: </a> x1 = XTRANS(draw,XiWin,X1);
  84. <a name="line105">105: </a> y_1 = YTRANS(draw,XiWin,Y_1);
  85. <a name="line106">106: </a> x2 = XTRANS(draw,XiWin,X2);
  86. <a name="line107">107: </a> y2 = YTRANS(draw,XiWin,Y2);
  87. <a name="line108">108: </a> x3 = XTRANS(draw,XiWin,X3);
  88. <a name="line109">109: </a> y3 = YTRANS(draw,XiWin,Y3);
  89. <a name="line110">110: </a> PetscDrawInterpolatedTriangle_X(XiWin,x1,y_1,c1,x2,y2,c2,x3,y3,c3);
  90. <a name="line111">111: </a> }
  91. <a name="line112">112: </a> <font color="#4169E1">return</font>(0);
  92. <a name="line113">113: </a>}
  93. <a name="line117">117: </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>
  94. <a name="line118">118: </a>{
  95. <a name="line120">120: </a> int xx,yy;
  96. <a name="line121">121: </a> size_t len;
  97. <a name="line122">122: </a> PetscDraw_X *XiWin = (PetscDraw_X*)draw-&gt;data;
  98. <a name="line123">123: </a> char *substr;
  99. <a name="line124">124: </a> <A href="../../../../../docs/manualpages/Sys/PetscToken.html#PetscToken">PetscToken</A> *token;
  100. <a name="line127">127: </a> xx = XTRANS(draw,XiWin,x); yy = YTRANS(draw,XiWin,y);
  101. <a name="line128">128: </a> XiSetColor(XiWin,c);
  102. <a name="line129">129: </a>
  103. <a name="line130">130: </a> <A href="../../../../../docs/manualpages/Sys/PetscTokenCreate.html#PetscTokenCreate">PetscTokenCreate</A>(chrs,'\n',&amp;token);
  104. <a name="line131">131: </a> <A href="../../../../../docs/manualpages/Sys/PetscTokenFind.html#PetscTokenFind">PetscTokenFind</A>(token,&amp;substr);
  105. <a name="line132">132: </a> <A href="../../../../../docs/manualpages/Sys/PetscStrlen.html#PetscStrlen">PetscStrlen</A>(substr,&amp;len);
  106. <a name="line133">133: </a> XDrawString(XiWin-&gt;disp,XiDrawable(XiWin),XiWin-&gt;gc.set,xx,yy - XiWin-&gt;font-&gt;font_descent,substr,len);
  107. <a name="line134">134: </a> <A href="../../../../../docs/manualpages/Sys/PetscTokenFind.html#PetscTokenFind">PetscTokenFind</A>(token,&amp;substr);
  108. <a name="line135">135: </a> <font color="#4169E1">while</font> (substr) {
  109. <a name="line136">136: </a> yy += 4*XiWin-&gt;font-&gt;font_descent;
  110. <a name="line137">137: </a> <A href="../../../../../docs/manualpages/Sys/PetscStrlen.html#PetscStrlen">PetscStrlen</A>(substr,&amp;len);
  111. <a name="line138">138: </a> XDrawString(XiWin-&gt;disp,XiDrawable(XiWin),XiWin-&gt;gc.set,xx,yy - XiWin-&gt;font-&gt;font_descent,substr,len);
  112. <a name="line139">139: </a> <A href="../../../../../docs/manualpages/Sys/PetscTokenFind.html#PetscTokenFind">PetscTokenFind</A>(token,&amp;substr);
  113. <a name="line140">140: </a> }
  114. <a name="line141">141: </a> <A href="../../../../../docs/manualpages/Sys/PetscTokenDestroy.html#PetscTokenDestroy">PetscTokenDestroy</A>(token);
  115. <a name="line143">143: </a> <font color="#4169E1">return</font>(0);
  116. <a name="line144">144: </a>}
  117. <a name="line146">146: </a><strong><font color="#4169E1">EXTERN <A href="../../../../../docs/manualpages/Sys/PetscErrorCode.html#PetscErrorCode">PetscErrorCode</A> XiFontFixed(PetscDraw_X*,int,int,XiFont **)</font></strong>;
  118. <a name="line150">150: </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>
  119. <a name="line151">151: </a>{
  120. <a name="line152">152: </a> PetscDraw_X* XiWin = (PetscDraw_X*)draw-&gt;data;
  121. <a name="line154">154: </a> int w,h;
  122. <a name="line157">157: </a> w = (int)((XiWin-&gt;w)*x*(draw-&gt;port_xr - draw-&gt;port_xl)/(draw-&gt;coor_xr - draw-&gt;coor_xl));
  123. <a name="line158">158: </a> h = (int)((XiWin-&gt;h)*y*(draw-&gt;port_yr - draw-&gt;port_yl)/(draw-&gt;coor_yr - draw-&gt;coor_yl));
  124. <a name="line159">159: </a> <A href="../../../../../docs/manualpages/Sys/PetscFree.html#PetscFree">PetscFree</A>(XiWin-&gt;font);
  125. <a name="line160">160: </a> XiFontFixed(XiWin,w,h,&amp;XiWin-&gt;font);
  126. <a name="line161">161: </a> <font color="#4169E1">return</font>(0);
  127. <a name="line162">162: </a>}
  128. <a name="line166">166: </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>
  129. <a name="line167">167: </a>{
  130. <a name="line168">168: </a> PetscDraw_X* XiWin = (PetscDraw_X*)draw-&gt;data;
  131. <a name="line169">169: </a> <A href="../../../../../docs/manualpages/Sys/PetscReal.html#PetscReal">PetscReal</A> w,h;
  132. <a name="line172">172: </a> w = XiWin-&gt;font-&gt;font_w; h = XiWin-&gt;font-&gt;font_h;
  133. <a name="line173">173: </a> *x = w*(draw-&gt;coor_xr - draw-&gt;coor_xl)/(XiWin-&gt;w)*(draw-&gt;port_xr - draw-&gt;port_xl);
  134. <a name="line174">174: </a> *y = h*(draw-&gt;coor_yr - draw-&gt;coor_yl)/(XiWin-&gt;h)*(draw-&gt;port_yr - draw-&gt;port_yl);
  135. <a name="line175">175: </a> <font color="#4169E1">return</font>(0);
  136. <a name="line176">176: </a>}
  137. <a name="line180">180: </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>
  138. <a name="line181">181: </a>{
  139. <a name="line183">183: </a> int xx,yy;
  140. <a name="line184">184: </a> PetscDraw_X *XiWin = (PetscDraw_X*)draw-&gt;data;
  141. <a name="line185">185: </a> char tmp[2];
  142. <a name="line186">186: </a> <A href="../../../../../docs/manualpages/Sys/PetscReal.html#PetscReal">PetscReal</A> tw,th;
  143. <a name="line187">187: </a> size_t i,n;
  144. <a name="line188">188: </a>
  145. <a name="line190">190: </a> <A href="../../../../../docs/manualpages/Sys/PetscStrlen.html#PetscStrlen">PetscStrlen</A>(chrs,&amp;n);
  146. <a name="line191">191: </a> tmp[1] = 0;
  147. <a name="line192">192: </a> XiSetColor(XiWin,c);
  148. <a name="line193">193: </a> PetscDrawStringGetSize_X(draw,&amp;tw,&amp;th);
  149. <a name="line194">194: </a> xx = XTRANS(draw,XiWin,x);
  150. <a name="line195">195: </a> <font color="#4169E1">for</font> (i=0; i&lt;n; i++) {
  151. <a name="line196">196: </a> tmp[0] = chrs[i];
  152. <a name="line197">197: </a> yy = YTRANS(draw,XiWin,y-th*i);
  153. <a name="line198">198: </a> XDrawString(XiWin-&gt;disp,XiDrawable(XiWin),XiWin-&gt;gc.set,
  154. <a name="line199">199: </a> xx,yy - XiWin-&gt;font-&gt;font_descent,tmp,1);
  155. <a name="line200">200: </a> }
  156. <a name="line201">201: </a> <font color="#4169E1">return</font>(0);
  157. <a name="line202">202: </a>}
  158. <a name="line206">206: </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>
  159. <a name="line207">207: </a>{
  160. <a name="line208">208: </a> PetscDraw_X* XiWin = (PetscDraw_X*)draw-&gt;data;
  161. <a name="line211">211: </a> <font color="#4169E1">if</font> (XiWin-&gt;drw) {
  162. <a name="line212">212: </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);
  163. <a name="line213">213: </a> }
  164. <a name="line214">214: </a> XFlush(XiWin-&gt;disp); XSync(XiWin-&gt;disp,False);
  165. <a name="line215">215: </a> <font color="#4169E1">return</font>(0);
  166. <a name="line216">216: </a>}
  167. <a name="line220">220: </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>
  168. <a name="line221">221: </a>{
  169. <a name="line223">223: </a> <A href="../../../../../docs/manualpages/Sys/PetscMPIInt.html#PetscMPIInt">PetscMPIInt</A> <A href="../../../../../docs/manualpages/Sys/rank.html#rank">rank</A>;
  170. <a name="line224">224: </a> PetscDraw_X* XiWin = (PetscDraw_X*)draw-&gt;data;
  171. <a name="line227">227: </a> XFlush(XiWin-&gt;disp);
  172. <a name="line228">228: </a> <font color="#4169E1">if</font> (XiWin-&gt;drw) {
  173. <a name="line229">229: </a> <A href="http://www.mcs.anl.gov/mpi/www/www3/MPI_Comm_rank.html#MPI_Comm_rank">MPI_Comm_rank</A>(draw-&gt;<A href="../../../../../docs/manualpages/Sys/comm.html#comm">comm</A>,&amp;<A href="../../../../../docs/manualpages/Sys/rank.html#rank">rank</A>);
  174. <a name="line230">230: </a> <font color="#B22222">/* make sure data has actually arrived at server */</font>
  175. <a name="line231">231: </a> XSync(XiWin-&gt;disp,False);
  176. <a name="line232">232: </a> <A href="http://www.mcs.anl.gov/mpi/www/www3/MPI_Barrier.html#MPI_Barrier">MPI_Barrier</A>(draw-&gt;<A href="../../../../../docs/manualpages/Sys/comm.html#comm">comm</A>);
  177. <a name="line233">233: </a> <font color="#4169E1">if</font> (!<A href="../../../../../docs/manualpages/Sys/rank.html#rank">rank</A>) {
  178. <a name="line234">234: </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="line235">235: </a> XFlush(XiWin-&gt;disp);
  180. <a name="line236">236: </a> }
  181. <a name="line237">237: </a> XSync(XiWin-&gt;disp,False);
  182. <a name="line238">238: </a> <A href="http://www.mcs.anl.gov/mpi/www/www3/MPI_Barrier.html#MPI_Barrier">MPI_Barrier</A>(draw-&gt;<A href="../../../../../docs/manualpages/Sys/comm.html#comm">comm</A>);
  183. <a name="line239">239: </a> } <font color="#4169E1">else</font> {
  184. <a name="line240">240: </a> <A href="http://www.mcs.anl.gov/mpi/www/www3/MPI_Barrier.html#MPI_Barrier">MPI_Barrier</A>(draw-&gt;<A href="../../../../../docs/manualpages/Sys/comm.html#comm">comm</A>);
  185. <a name="line241">241: </a> XSync(XiWin-&gt;disp,False);
  186. <a name="line242">242: </a> <A href="http://www.mcs.anl.gov/mpi/www/www3/MPI_Barrier.html#MPI_Barrier">MPI_Barrier</A>(draw-&gt;<A href="../../../../../docs/manualpages/Sys/comm.html#comm">comm</A>);
  187. <a name="line243">243: </a> }
  188. <a name="line244">244: </a> <font color="#4169E1">return</font>(0);
  189. <a name="line245">245: </a>}
  190. <a name="line249">249: </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>
  191. <a name="line250">250: </a>{
  192. <a name="line251">251: </a> PetscDraw_X* XiWin = (PetscDraw_X*)draw-&gt;data;
  193. <a name="line252">252: </a> XRectangle box;
  194. <a name="line255">255: </a> box.x = (int)(xl*XiWin-&gt;w); box.y = (int)((1.0-yr)*XiWin-&gt;h);
  195. <a name="line256">256: </a> box.width = (int)((xr-xl)*XiWin-&gt;w);box.height = (int)((yr-yl)*XiWin-&gt;h);
  196. <a name="line257">257: </a> XSetClipRectangles(XiWin-&gt;disp,XiWin-&gt;gc.set,0,0,&amp;box,1,Unsorted);
  197. <a name="line258">258: </a> <font color="#4169E1">return</font>(0);
  198. <a name="line259">259: </a>}
  199. <a name="line263">263: </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>
  200. <a name="line264">264: </a>{
  201. <a name="line265">265: </a> PetscDraw_X* XiWin = (PetscDraw_X*)draw-&gt;data;
  202. <a name="line266">266: </a> int x, y, w, h;
  203. <a name="line269">269: </a> x = (int)(draw-&gt;port_xl*XiWin-&gt;w);
  204. <a name="line270">270: </a> w = (int)((draw-&gt;port_xr - draw-&gt;port_xl)*XiWin-&gt;w);
  205. <a name="line271">271: </a> y = (int)((1.0-draw-&gt;port_yr)*XiWin-&gt;h);
  206. <a name="line272">272: </a> h = (int)((draw-&gt;port_yr - draw-&gt;port_yl)*XiWin-&gt;h);
  207. <a name="line273">273: </a> XiSetPixVal(XiWin,XiWin-&gt;background);
  208. <a name="line274">274: </a> XFillRectangle(XiWin-&gt;disp,XiDrawable(XiWin),XiWin-&gt;gc.set,x,y,w,h);
  209. <a name="line275">275: </a> <font color="#4169E1">return</font>(0);
  210. <a name="line276">276: </a>}
  211. <a name="line280">280: </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>
  212. <a name="line281">281: </a>{
  213. <a name="line283">283: </a> <A href="../../../../../docs/manualpages/Sys/PetscMPIInt.html#PetscMPIInt">PetscMPIInt</A> <A href="../../../../../docs/manualpages/Sys/rank.html#rank">rank</A>;
  214. <a name="line284">284: </a> PetscDraw_X* XiWin = (PetscDraw_X*)draw-&gt;data;
  215. <a name="line287">287: </a> <A href="http://www.mcs.anl.gov/mpi/www/www3/MPI_Barrier.html#MPI_Barrier">MPI_Barrier</A>(draw-&gt;<A href="../../../../../docs/manualpages/Sys/comm.html#comm">comm</A>);
  216. <a name="line288">288: </a> <A href="http://www.mcs.anl.gov/mpi/www/www3/MPI_Comm_rank.html#MPI_Comm_rank">MPI_Comm_rank</A>(draw-&gt;<A href="../../../../../docs/manualpages/Sys/comm.html#comm">comm</A>,&amp;<A href="../../../../../docs/manualpages/Sys/rank.html#rank">rank</A>);
  217. <a name="line289">289: </a> <font color="#4169E1">if</font> (!<A href="../../../../../docs/manualpages/Sys/rank.html#rank">rank</A>) {
  218. <a name="line290">290: </a> PetscDrawClear_X(draw);
  219. <a name="line291">291: </a> }
  220. <a name="line292">292: </a> XFlush(XiWin-&gt;disp);
  221. <a name="line293">293: </a> <A href="http://www.mcs.anl.gov/mpi/www/www3/MPI_Barrier.html#MPI_Barrier">MPI_Barrier</A>(draw-&gt;<A href="../../../../../docs/manualpages/Sys/comm.html#comm">comm</A>);
  222. <a name="line294">294: </a> XSync(XiWin-&gt;disp,False);
  223. <a name="line295">295: </a> <A href="http://www.mcs.anl.gov/mpi/www/www3/MPI_Barrier.html#MPI_Barrier">MPI_Barrier</A>(draw-&gt;<A href="../../../../../docs/manualpages/Sys/comm.html#comm">comm</A>);
  224. <a name="line296">296: </a> <font color="#4169E1">return</font>(0);
  225. <a name="line297">297: </a>}
  226. <a name="line301">301: </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>
  227. <a name="line302">302: </a>{
  228. <a name="line303">303: </a> PetscDraw_X* win = (PetscDraw_X*)draw-&gt;data;
  229. <a name="line305">305: </a> <A href="../../../../../docs/manualpages/Sys/PetscMPIInt.html#PetscMPIInt">PetscMPIInt</A> <A href="../../../../../docs/manualpages/Sys/rank.html#rank">rank</A>;
  230. <a name="line308">308: </a> <font color="#4169E1">if</font> (win-&gt;drw) <font color="#4169E1">return</font>(0);
  231. <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>(draw-&gt;<A href="../../../../../docs/manualpages/Sys/comm.html#comm">comm</A>,&amp;<A href="../../../../../docs/manualpages/Sys/rank.html#rank">rank</A>);
  232. <a name="line311">311: </a> <font color="#4169E1">if</font> (!<A href="../../../../../docs/manualpages/Sys/rank.html#rank">rank</A>) {
  233. <a name="line312">312: </a> win-&gt;drw = XCreatePixmap(win-&gt;disp,win-&gt;win,win-&gt;w,win-&gt;h,win-&gt;depth);
  234. <a name="line313">313: </a> }
  235. <a name="line314">314: </a> <font color="#B22222">/* try to make sure it is actually done before passing info to all */</font>
  236. <a name="line315">315: </a> XSync(win-&gt;disp,False);
  237. <a name="line316">316: </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,draw-&gt;<A href="../../../../../docs/manualpages/Sys/comm.html#comm">comm</A>);
  238. <a name="line317">317: </a> <font color="#4169E1">return</font>(0);
  239. <a name="line318">318: </a>}
  240. <a name="line320">320: </a><font color="#A020F0">#include &lt;X11/cursorfont.h&gt;</font>
  241. <a name="line324">324: </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,</font></strong>
  242. <a name="line325">325: </a><strong><font color="#4169E1"> <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>
  243. <a name="line326">326: </a>{
  244. <a name="line327">327: </a> XEvent report;
  245. <a name="line328">328: </a> PetscDraw_X* win = (PetscDraw_X*)draw-&gt;data;
  246. <a name="line329">329: </a> Window root,child;
  247. <a name="line330">330: </a> int root_x,root_y,px,py;
  248. <a name="line331">331: </a> unsigned int keys_button;
  249. <a name="line332">332: </a> Cursor cursor = 0;
  250. <a name="line335">335: </a> <font color="#B22222">/* change cursor to indicate input */</font>
  251. <a name="line336">336: </a> <font color="#4169E1">if</font> (!cursor) {
  252. <a name="line337">337: </a> cursor = XCreateFontCursor(win-&gt;disp,XC_hand2);
  253. <a name="line338">338: </a> <font color="#4169E1">if</font> (!cursor) <A href="../../../../../docs/manualpages/Sys/SETERRQ.html#SETERRQ">SETERRQ</A>(PETSC_ERR_LIB,<font color="#666666">"Unable to create X cursor"</font>);
  254. <a name="line339">339: </a> }
  255. <a name="line340">340: </a> XDefineCursor(win-&gt;disp,win-&gt;win,cursor);
  256. <a name="line342">342: </a> XSelectInput(win-&gt;disp,win-&gt;win,ButtonPressMask | ButtonReleaseMask);
  257. <a name="line344">344: </a> <font color="#4169E1">while</font> (XCheckTypedEvent(win-&gt;disp,ButtonPress,&amp;report));
  258. <a name="line345">345: </a> XMaskEvent(win-&gt;disp,ButtonReleaseMask,&amp;report);
  259. <a name="line346">346: </a> <font color="#4169E1">switch</font> (report.xbutton.button) {
  260. <a name="line347">347: </a> <font color="#4169E1">case</font> Button1:
  261. <a name="line348">348: </a> <font color="#4169E1">if</font> (report.xbutton.state &amp; ShiftMask)
  262. <a name="line349">349: </a> *button = BUTTON_LEFT_SHIFT;
  263. <a name="line350">350: </a> <font color="#4169E1">else</font>
  264. <a name="line351">351: </a> *button = BUTTON_LEFT;
  265. <a name="line352">352: </a> <font color="#4169E1">break</font>;
  266. <a name="line353">353: </a> <font color="#4169E1">case</font> Button2:
  267. <a name="line354">354: </a> <font color="#4169E1">if</font> (report.xbutton.state &amp; ShiftMask)
  268. <a name="line355">355: </a> *button = BUTTON_CENTER_SHIFT;
  269. <a name="line356">356: </a> <font color="#4169E1">else</font>
  270. <a name="line357">357: </a> *button = BUTTON_CENTER;
  271. <a name="line358">358: </a> <font color="#4169E1">break</font>;
  272. <a name="line359">359: </a> <font color="#4169E1">case</font> Button3:
  273. <a name="line360">360: </a> <font color="#4169E1">if</font> (report.xbutton.state &amp; ShiftMask)
  274. <a name="line361">361: </a> *button = BUTTON_RIGHT_SHIFT;
  275. <a name="line362">362: </a> <font color="#4169E1">else</font>
  276. <a name="line363">363: </a> *button = BUTTON_RIGHT;
  277. <a name="line364">364: </a> <font color="#4169E1">break</font>;
  278. <a name="line365">365: </a> }
  279. <a name="line366">366: </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);
  280. <a name="line368">368: </a> <font color="#4169E1">if</font> (x_phys) *x_phys = ((double)px)/((double)win-&gt;w);
  281. <a name="line369">369: </a> <font color="#4169E1">if</font> (y_phys) *y_phys = 1.0 - ((double)py)/((double)win-&gt;h);
  282. <a name="line371">371: </a> <font color="#4169E1">if</font> (x_user) *x_user = draw-&gt;coor_xl + ((((double)px)/((double)win-&gt;w)-draw-&gt;port_xl))*
  283. <a name="line372">372: </a> (draw-&gt;coor_xr - draw-&gt;coor_xl)/(draw-&gt;port_xr - draw-&gt;port_xl);
  284. <a name="line373">373: </a> <font color="#4169E1">if</font> (y_user) *y_user = draw-&gt;coor_yl +
  285. <a name="line374">374: </a> ((1.0 - ((double)py)/((double)win-&gt;h)-draw-&gt;port_yl))*
  286. <a name="line375">375: </a> (draw-&gt;coor_yr - draw-&gt;coor_yl)/(draw-&gt;port_yr - draw-&gt;port_yl);
  287. <a name="line377">377: </a> XUndefineCursor(win-&gt;disp,win-&gt;win);
  288. <a name="line378">378: </a> XFlush(win-&gt;disp); XSync(win-&gt;disp,False);
  289. <a name="line379">379: </a> <font color="#4169E1">return</font>(0);
  290. <a name="line380">380: </a>}
  291. <a name="line384">384: </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>
  292. <a name="line385">385: </a>{
  293. <a name="line389">389: </a> <font color="#4169E1">if</font> (draw-&gt;pause &gt; 0) <A href="../../../../../docs/manualpages/Sys/PetscSleep.html#PetscSleep">PetscSleep</A>(draw-&gt;pause);
  294. <a name="line390">390: </a> <font color="#4169E1">else</font> <font color="#4169E1">if</font> (draw-&gt;pause &lt; 0) {
  295. <a name="line391">391: </a> <A href="../../../../../docs/manualpages/Draw/PetscDrawButton.html#PetscDrawButton">PetscDrawButton</A> button;
  296. <a name="line392">392: </a> <A href="../../../../../docs/manualpages/Sys/PetscMPIInt.html#PetscMPIInt">PetscMPIInt</A> <A href="../../../../../docs/manualpages/Sys/rank.html#rank">rank</A>;
  297. <a name="line393">393: </a> <A href="http://www.mcs.anl.gov/mpi/www/www3/MPI_Comm_rank.html#MPI_Comm_rank">MPI_Comm_rank</A>(draw-&gt;<A href="../../../../../docs/manualpages/Sys/comm.html#comm">comm</A>,&amp;<A href="../../../../../docs/manualpages/Sys/rank.html#rank">rank</A>);
  298. <a name="line394">394: </a> <font color="#4169E1">if</font> (!<A href="../../../../../docs/manualpages/Sys/rank.html#rank">rank</A>) {
  299. <a name="line395">395: </a> <A href="../../../../../docs/manualpages/Draw/PetscDrawGetMouseButton.html#PetscDrawGetMouseButton">PetscDrawGetMouseButton</A>(draw,&amp;button,0,0,0,0);
  300. <a name="line396">396: </a> <font color="#4169E1">if</font> (button == BUTTON_CENTER) draw-&gt;pause = 0;
  301. <a name="line397">397: </a> }
  302. <a name="line398">398: </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,draw-&gt;<A href="../../../../../docs/manualpages/Sys/comm.html#comm">comm</A>);
  303. <a name="line399">399: </a> }
  304. <a name="line400">400: </a> <font color="#4169E1">return</font>(0);
  305. <a name="line401">401: </a>}
  306. <a name="line405">405: </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>
  307. <a name="line406">406: </a>{
  308. <a name="line408">408: </a> PetscDraw_X* win = (PetscDraw_X*)draw-&gt;data;
  309. <a name="line411">411: </a> <A href="../../../../../docs/manualpages/Draw/PetscDrawOpenX.html#PetscDrawOpenX">PetscDrawOpenX</A>(draw-&gt;<A href="../../../../../docs/manualpages/Sys/comm.html#comm">comm</A>,<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,150,220,popup);
  310. <a name="line412">412: </a> draw-&gt;popup = *popup;
  311. <a name="line413">413: </a> <font color="#4169E1">return</font>(0);
  312. <a name="line414">414: </a>}
  313. <a name="line418">418: </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>
  314. <a name="line419">419: </a>{
  315. <a name="line420">420: </a> PetscDraw_X *win = (PetscDraw_X*)draw-&gt;data;
  316. <a name="line421">421: </a> XTextProperty prop;
  317. <a name="line423">423: </a> size_t len;
  318. <a name="line426">426: </a> XGetWMName(win-&gt;disp,win-&gt;win,&amp;prop);
  319. <a name="line427">427: </a> prop.value = (unsigned char *)title;
  320. <a name="line428">428: </a> <A href="../../../../../docs/manualpages/Sys/PetscStrlen.html#PetscStrlen">PetscStrlen</A>(title,&amp;len);
  321. <a name="line429">429: </a> prop.nitems = (long) len;
  322. <a name="line430">430: </a> XSetWMName(win-&gt;disp,win-&gt;win,&amp;prop);
  323. <a name="line431">431: </a> <font color="#4169E1">return</font>(0);
  324. <a name="line432">432: </a>}
  325. <a name="line436">436: </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>
  326. <a name="line437">437: </a>{
  327. <a name="line438">438: </a> PetscDraw_X *win = (PetscDraw_X*)draw-&gt;data;
  328. <a name="line439">439: </a> unsigned int ww,hh,border,depth;
  329. <a name="line440">440: </a> int x,y;
  330. <a name="line442">442: </a> Window root;
  331. <a name="line445">445: </a> XResizeWindow(win-&gt;disp,win-&gt;win,w,h);
  332. <a name="line446">446: </a> XGetGeometry(win-&gt;disp,win-&gt;win,&amp;root,&amp;x,&amp;y,&amp;ww,&amp;hh,&amp;border,&amp;depth);
  333. <a name="line447">447: </a> <A href="../../../../../docs/manualpages/Draw/PetscDrawCheckResizedWindow.html#PetscDrawCheckResizedWindow">PetscDrawCheckResizedWindow</A>(draw);
  334. <a name="line448">448: </a> <font color="#4169E1">return</font>(0);
  335. <a name="line449">449: </a>}
  336. <a name="line453">453: </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>
  337. <a name="line454">454: </a>{
  338. <a name="line455">455: </a> PetscDraw_X *win = (PetscDraw_X*)draw-&gt;data;
  339. <a name="line457">457: </a> int x,y;
  340. <a name="line458">458: </a> <A href="../../../../../docs/manualpages/Sys/PetscMPIInt.html#PetscMPIInt">PetscMPIInt</A> <A href="../../../../../docs/manualpages/Sys/rank.html#rank">rank</A>;
  341. <a name="line459">459: </a> Window root;
  342. <a name="line460">460: </a> unsigned int w,h,border,depth,geo[2];
  343. <a name="line461">461: </a> <A href="../../../../../docs/manualpages/Sys/PetscReal.html#PetscReal">PetscReal</A> xl,xr,yl,yr;
  344. <a name="line462">462: </a> XRectangle box;
  345. <a name="line465">465: </a> <A href="http://www.mcs.anl.gov/mpi/www/www3/MPI_Comm_rank.html#MPI_Comm_rank">MPI_Comm_rank</A>(draw-&gt;<A href="../../../../../docs/manualpages/Sys/comm.html#comm">comm</A>,&amp;<A href="../../../../../docs/manualpages/Sys/rank.html#rank">rank</A>);
  346. <a name="line466">466: </a> <font color="#4169E1">if</font> (!<A href="../../../../../docs/manualpages/Sys/rank.html#rank">rank</A>) {
  347. <a name="line467">467: </a> XSync(win-&gt;disp,False);
  348. <a name="line468">468: </a> XGetGeometry(win-&gt;disp,win-&gt;win,&amp;root,&amp;x,&amp;y,geo,geo+1,&amp;border,&amp;depth);
  349. <a name="line469">469: </a> }
  350. <a name="line470">470: </a> <A href="http://www.mcs.anl.gov/mpi/www/www3/MPI_Bcast.html#MPI_Bcast">MPI_Bcast</A>(geo,2,MPI_INT,0,draw-&gt;<A href="../../../../../docs/manualpages/Sys/comm.html#comm">comm</A>);
  351. <a name="line471">471: </a> w = geo[0];
  352. <a name="line472">472: </a> h = geo[1];
  353. <a name="line473">473: </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);
  354. <a name="line475">475: </a> <font color="#B22222">/* record new window sizes */</font>
  355. <a name="line477">477: </a> win-&gt;h = h; win-&gt;w = w;
  356. <a name="line479">479: </a> <font color="#B22222">/* Free buffer space and create new version (only first processor does this) */</font>
  357. <a name="line480">480: </a> <font color="#4169E1">if</font> (win-&gt;drw) {
  358. <a name="line481">481: </a> win-&gt;drw = XCreatePixmap(win-&gt;disp,win-&gt;win,win-&gt;w,win-&gt;h,win-&gt;depth);
  359. <a name="line482">482: </a> }
  360. <a name="line483">483: </a> <font color="#B22222">/* reset the clipping */</font>
  361. <a name="line484">484: </a> xl = draw-&gt;port_xl; yl = draw-&gt;port_yl;
  362. <a name="line485">485: </a> xr = draw-&gt;port_xr; yr = draw-&gt;port_yr;
  363. <a name="line486">486: </a> box.x = (int)(xl*win-&gt;w); box.y = (int)((1.0-yr)*win-&gt;h);
  364. <a name="line487">487: </a> box.width = (int)((xr-xl)*win-&gt;w);box.height = (int)((yr-yl)*win-&gt;h);
  365. <a name="line488">488: </a> XSetClipRectangles(win-&gt;disp,win-&gt;gc.set,0,0,&amp;box,1,Unsorted);
  366. <a name="line490">490: </a> <font color="#B22222">/* try to make sure it is actually done before passing info to all */</font>
  367. <a name="line491">491: </a> XSync(win-&gt;disp,False);
  368. <a name="line492">492: </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,draw-&gt;<A href="../../../../../docs/manualpages/Sys/comm.html#comm">comm</A>);
  369. <a name="line493">493: </a> <font color="#4169E1">return</font>(0);
  370. <a name="line494">494: </a>}
  371. <a name="line496">496: </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>;
  372. <a name="line497">497: </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>;
  373. <a name="line501">501: </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>
  374. <a name="line502">502: </a>{
  375. <a name="line503">503: </a> PetscDraw_X *win = (PetscDraw_X*)draw-&gt;data;
  376. <a name="line507">507: </a> XFreeGC(win-&gt;disp,win-&gt;gc.set);
  377. <a name="line508">508: </a> XCloseDisplay(win-&gt;disp);
  378. <a name="line509">509: </a> <font color="#4169E1">if</font> (draw-&gt;popup) {<A href="../../../../../docs/manualpages/Draw/PetscDrawDestroy.html#PetscDrawDestroy">PetscDrawDestroy</A>(draw-&gt;popup);}
  379. <a name="line510">510: </a> <A href="../../../../../docs/manualpages/Sys/PetscFree.html#PetscFree">PetscFree</A>(win-&gt;font);
  380. <a name="line511">511: </a> <A href="../../../../../docs/manualpages/Sys/PetscFree.html#PetscFree">PetscFree</A>(win);
  381. <a name="line512">512: </a> <font color="#4169E1">return</font>(0);
  382. <a name="line513">513: </a>}
  383. <a name="line515">515: </a>static <font color="#4169E1">struct _PetscDrawOps</font> DvOps = { PetscDrawSetDoubleBuffer_X,
  384. <a name="line516">516: </a> PetscDrawFlush_X,PetscDrawLine_X,
  385. <a name="line517">517: </a> 0,
  386. <a name="line518">518: </a> 0,
  387. <a name="line519">519: </a> PetscDrawPoint_X,
  388. <a name="line520">520: </a> 0,
  389. <a name="line521">521: </a> PetscDrawString_X,
  390. <a name="line522">522: </a> PetscDrawStringVertical_X,
  391. <a name="line523">523: </a> PetscDrawStringSetSize_X,
  392. <a name="line524">524: </a> PetscDrawStringGetSize_X,
  393. <a name="line525">525: </a> PetscDrawSetViewport_X,
  394. <a name="line526">526: </a> PetscDrawClear_X,
  395. <a name="line527">527: </a> PetscDrawSynchronizedFlush_X,
  396. <a name="line528">528: </a> PetscDrawRectangle_X,
  397. <a name="line529">529: </a> PetscDrawTriangle_X,
  398. <a name="line530">530: </a> PetscDrawEllipse_X,
  399. <a name="line531">531: </a> PetscDrawGetMouseButton_X,
  400. <a name="line532">532: </a> PetscDrawPause_X,
  401. <a name="line533">533: </a> PetscDrawSynchronizedClear_X,
  402. <a name="line534">534: </a> 0,
  403. <a name="line535">535: </a> 0,
  404. <a name="line536">536: </a> PetscDrawGetPopup_X,
  405. <a name="line537">537: </a> PetscDrawSetTitle_X,
  406. <a name="line538">538: </a> PetscDrawCheckResizedWindow_X,
  407. <a name="line539">539: </a> PetscDrawResizeWindow_X,
  408. <a name="line540">540: </a> PetscDrawDestroy_X,
  409. <a name="line541">541: </a> 0,
  410. <a name="line542">542: </a> PetscDrawGetSingleton_X,
  411. <a name="line543">543: </a> PetscDrawRestoreSingleton_X };
  412. <a name="line546">546: </a><strong><font color="#4169E1">EXTERN <A href="../../../../../docs/manualpages/Sys/PetscErrorCode.html#PetscErrorCode">PetscErrorCode</A> XiQuickWindow(PetscDraw_X*,char*,char*,int,int,int,int)</font></strong>;
  413. <a name="line547">547: </a><strong><font color="#4169E1">EXTERN <A href="../../../../../docs/manualpages/Sys/PetscErrorCode.html#PetscErrorCode">PetscErrorCode</A> XiQuickWindowFromWindow(PetscDraw_X*,char*,Window)</font></strong>;
  414. <a name="line551">551: </a><strong><font color="#4169E1"><a name="PetscDrawGetSingleton_X"></a>static <A href="../../../../../docs/manualpages/Sys/PetscErrorCode.html#PetscErrorCode">PetscErrorCode</A> PetscDrawGetSingleton_X(<A href="../../../../../docs/manualpages/Draw/PetscDraw.html#PetscDraw">PetscDraw</A> draw,<A href="../../../../../docs/manualpages/Draw/PetscDraw.html#PetscDraw">PetscDraw</A> *sdraw)</font></strong>
  415. <a name="line552">552: </a>{
  416. <a name="line554">554: </a> PetscDraw_X *Xwin = (PetscDraw_X*)draw-&gt;data,*sXwin;
  417. <a name="line558">558: </a> <A href="../../../../../docs/manualpages/Draw/PetscDrawCreate.html#PetscDrawCreate">PetscDrawCreate</A>(<A href="../../../../../docs/manualpages/Sys/PETSC_COMM_SELF.html#PETSC_COMM_SELF">PETSC_COMM_SELF</A>,draw-&gt;display,draw-&gt;title,draw-&gt;x,draw-&gt;y,draw-&gt;w,draw-&gt;h,sdraw);
  418. <a name="line559">559: </a> PetscObjectChangeTypeName((<A href="../../../../../docs/manualpages/Sys/PetscObject.html#PetscObject">PetscObject</A>)*sdraw,PETSC_DRAW_X);
  419. <a name="line560">560: </a> <A href="../../../../../docs/manualpages/Sys/PetscMemcpy.html#PetscMemcpy">PetscMemcpy</A>((*sdraw)-&gt;ops,&amp;DvOps,<font color="#4169E1">sizeof</font>(DvOps));
  420. <a name="line561">561: </a> (*sdraw)-&gt;ops-&gt;destroy = 0;
  421. <a name="line563">563: </a> (*sdraw)-&gt;pause = draw-&gt;pause;
  422. <a name="line564">564: </a> (*sdraw)-&gt;coor_xl = draw-&gt;coor_xl;
  423. <a name="line565">565: </a> (*sdraw)-&gt;coor_xr = draw-&gt;coor_xr;
  424. <a name="line566">566: </a> (*sdraw)-&gt;coor_yl = draw-&gt;coor_yl;
  425. <a name="line567">567: </a> (*sdraw)-&gt;coor_yr = draw-&gt;coor_yr;
  426. <a name="line568">568: </a> (*sdraw)-&gt;port_xl = draw-&gt;port_xl;
  427. <a name="line569">569: </a> (*sdraw)-&gt;port_xr = draw-&gt;port_xr;
  428. <a name="line570">570: </a> (*sdraw)-&gt;port_yl = draw-&gt;port_yl;
  429. <a name="line571">571: </a> (*sdraw)-&gt;port_yr = draw-&gt;port_yr;
  430. <a name="line572">572: </a> (*sdraw)-&gt;popup = draw-&gt;popup;
  431. <a name="line574">574: </a> <font color="#B22222">/* actually create and open the window */</font>
  432. <a name="line575">575: </a> <A href="../../../../../docs/manualpages/Sys/PetscNew.html#PetscNew">PetscNew</A>(PetscDraw_X,&amp;sXwin);
  433. <a name="line576">576: </a> XiQuickWindowFromWindow(sXwin,draw-&gt;display,Xwin-&gt;win);
  434. <a name="line578">578: </a> sXwin-&gt;x = Xwin-&gt;x;
  435. <a name="line579">579: </a> sXwin-&gt;y = Xwin-&gt;y;
  436. <a name="line580">580: </a> sXwin-&gt;w = Xwin-&gt;w;
  437. <a name="line581">581: </a> sXwin-&gt;h = Xwin-&gt;h;
  438. <a name="line582">582: </a> (*sdraw)-&gt;data = (void*)sXwin;
  439. <a name="line583">583: </a> <font color="#4169E1">return</font>(0);
  440. <a name="line584">584: </a>}
  441. <a name="line588">588: </a><strong><font color="#4169E1"><a name="PetscDrawRestoreSingleton_X"></a>static <A href="../../../../../docs/manualpages/Sys/PetscErrorCode.html#PetscErrorCode">PetscErrorCode</A> PetscDrawRestoreSingleton_X(<A href="../../../../../docs/manualpages/Draw/PetscDraw.html#PetscDraw">PetscDraw</A> draw,<A href="../../../../../docs/manualpages/Draw/PetscDraw.html#PetscDraw">PetscDraw</A> *sdraw)</font></strong>
  442. <a name="line589">589: </a>{
  443. <a name="line591">591: </a> PetscDraw_X *sXwin = (PetscDraw_X*)(*sdraw)-&gt;data;
  444. <a name="line594">594: </a> XFreeGC(sXwin-&gt;disp,sXwin-&gt;gc.set);
  445. <a name="line595">595: </a> XCloseDisplay(sXwin-&gt;disp);
  446. <a name="line596">596: </a> <font color="#4169E1">if</font> ((*sdraw)-&gt;popup) {<A href="../../../../../docs/manualpages/Draw/PetscDrawDestroy.html#PetscDrawDestroy">PetscDrawDestroy</A>((*sdraw)-&gt;popup);}
  447. <a name="line597">597: </a> <A href="../../../../../docs/manualpages/Sys/PetscStrfree.html#PetscStrfree">PetscStrfree</A>((*sdraw)-&gt;title);
  448. <a name="line598">598: </a> <A href="../../../../../docs/manualpages/Sys/PetscStrfree.html#PetscStrfree">PetscStrfree</A>((*sdraw)-&gt;display);
  449. <a name="line599">599: </a> <A href="../../../../../docs/manualpages/Sys/PetscFree.html#PetscFree">PetscFree</A>(sXwin-&gt;font);
  450. <a name="line600">600: </a> <A href="../../../../../docs/manualpages/Sys/PetscFree.html#PetscFree">PetscFree</A>(sXwin);
  451. <a name="line601">601: </a> PetscHeaderDestroy(*sdraw);
  452. <a name="line602">602: </a> <font color="#4169E1">return</font>(0);
  453. <a name="line603">603: </a>}
  454. <a name="line607">607: </a><strong><font color="#4169E1"><a name="PetscDrawXGetDisplaySize_Private"></a><A href="../../../../../docs/manualp