00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041 #include <stdio.h>
00042 #ifndef __UNIX_
00043 #ifndef _Windows
00044 #include <graphics.h>
00045 #else
00046 #include <windows.h>
00047 #endif
00048 #endif
00049 #include "mensagem.h"
00050 #include "memvirtu.h"
00051 #include "lowparam.h"
00052 #include "lowmacro.h"
00053 #include "lowsolid.h"
00054 #include "vectorop.h"
00055 #include "disdispl.h"
00056 #include "gphgraph.h"
00057 #include "mancommd.h"
00058
00059 extern int MaxColors;
00060
00061 void MSD_execDisplayCoordinates(void)
00062 {
00063 int acolor, mcolor = 0, dir = 0;
00064 char opt;
00065 float l;
00066 real dis = 0.0, dl = 0.0;
00067
00068 for ( ; ;)
00069 {
00070 switch (opt = optin())
00071 {
00072 case 'a':
00073 if (2 == sscanf(restbuf, "%f %d", &l, &acolor))
00074 {
00075 MSD_highDisplayCoordinates(opt, dir, dis, l, dl, acolor, mcolor);
00076 return;
00077 }
00078 break;
00079
00080 case 'm':
00081 skipsp(&restbuf);
00082 switch (*restbuf++)
00083 {
00084 case 'x':
00085 case 'X':
00086 dir = 0;
00087 break;
00088
00089 case 'y':
00090 case 'Y':
00091 dir = 1;
00092 break;
00093
00094 case 'z':
00095 case 'Z':
00096 dir = 2;
00097 break;
00098
00099 default:
00100 dir = -1;
00101 }
00102 skipsp(&restbuf);
00103 if ((dir == -1) || (*restbuf++ != '='))
00104 {
00105 break;
00106 }
00107 if (5 == sscanf(restbuf, "%f %f %f %d %d", &dis, &l, &dl,
00108 &acolor, &mcolor))
00109 {
00110 MSD_highDisplayCoordinates(opt, dir, dis, l, dl, acolor, mcolor);
00111 return;
00112 }
00113 }
00114 printf(MEN_CoordenadasParametros, NAM_DisplayCoordinates);
00115 if (!lineins("? "))
00116 {
00117 return;
00118 }
00119 }
00120 }
00121
00122 int MSD_highDisplayCoordinates(int opt, int dir, real dis, real l, real dl,
00123 int acolor, int mcolor)
00124 {
00125 if (!monicptr)
00126 {
00127 fprintf(stderr, MEN_NenhumaCamaraMonitora, NAM_DisplayCoordinates);
00128 return(FALSE);
00129 }
00130 if ((0 > acolor) || (acolor > MaxColors - 1) && (0 > mcolor) && (mcolor > MaxColors - 1))
00131 {
00132 fprintf(stderr, MEN_CorInvalida, NAM_DisplayCoordinates);
00133 return(TRUE);
00134 }
00135
00136 switch (opt)
00137 {
00138 case 'a':
00139 return(MSD_lowDisplayAxis(l, acolor));
00140
00141 case 'm':
00142 return(MSD_lowDisplayMesh(dir, dis, l, dl, acolor, mcolor));
00143 }
00144 fprintf(stderr, MEN_ParametrosIncorretos, NAM_DisplayCoordinates);
00145 return(FALSE);
00146 }
00147
00148 int MSD_lowDisplayAxis(real len, int acolor)
00149 {
00150 static vector zero = { 0.0, 0.0, 0.0, 0.0 };
00151 vector v3;
00152
00153 camptr = monicptr;
00154 g_pcolor(acolor);
00155
00156 v3[0] = len;
00157 v3[1] = v3[2] = 0.0;
00158 MSD_lowDisplayLineCoordinates(SOLID_LINE, v3, zero);
00159 v3[0] = -len;
00160 MSD_lowDisplayLineCoordinates(DASHED_LINE, v3, zero);
00161
00162 v3[1] = len;
00163 v3[0] = v3[2] = 0.0;
00164 MSD_lowDisplayLineCoordinates(SOLID_LINE, v3, zero);
00165 v3[1] = -len;
00166 MSD_lowDisplayLineCoordinates(DASHED_LINE, v3, zero);
00167
00168 v3[2] = len;
00169 v3[0] = v3[1] = 0.0;
00170 MSD_lowDisplayLineCoordinates(SOLID_LINE, v3, zero);
00171 v3[2] = -len;
00172 MSD_lowDisplayLineCoordinates(DASHED_LINE, v3, zero);
00173 return(TRUE);
00174 }
00175
00176 int MSD_lowDisplayMesh(int dir, real dis, real len, real dl, int acolor, int mcolor)
00177 {
00178 vector v0, v3;
00179 real d;
00180 int idx1, idx2, dn, i, j;
00181
00182 camptr = monicptr;
00183 dn = (int)((len + abseps) / dl);
00184 switch (dir)
00185 {
00186 case 0:
00187 idx1 = 1;
00188 idx2 = 2;
00189 break;
00190
00191 case 1:
00192 idx1 = 2;
00193 idx2 = 0;
00194 break;
00195
00196 case 2:
00197 idx1 = 0;
00198 idx2 = 1;
00199 break;
00200 }
00201 v0[dir] = v3[dir] = dis;
00202 for (i = 0; i < 2; ++i)
00203 {
00204 for (d = dl * (-dn), j = -dn; j <= dn; d += dl, ++j)
00205 {
00206 g_pcolor(j ? mcolor : acolor);
00207 v0[idx2] = v3[idx2] = d;
00208 v0[idx1] = 0.0;
00209 v3[idx1] = len;
00210 MSD_lowDisplayLineCoordinates(SOLID_LINE, v0, v3);
00211 v3[idx1] = -len;
00212 MSD_lowDisplayLineCoordinates(DASHED_LINE, v0, v3);
00213 }
00214 j = idx1;
00215 idx1 = idx2;
00216 idx2 = j;
00217 }
00218 return(TRUE);
00219 }
00220
00221 void MSD_lowDisplayLineCoordinates(int lt, vector sv, vector ev)
00222 {
00223 vect2 sv2, ev2;
00224
00225 if (MSD_lowExecDisplayTransformation(sv, ev, sv2, ev2))
00226 {
00227 g_tline(lt, sv2, ev2);
00228 }
00229 }