47 Lines.append(
new Line(0, 0,
cx, 0, QPen(Qt::black,0)));
48 Lines.append(
new Line(0, 0, 0,
cy, QPen(Qt::black,0)));
60 double rX = double(
rotX) *
M_PI/180.0;
61 double rY = double(
rotY) *
M_PI/180.0;
62 double rZ = double(
rotZ) *
M_PI/180.0;
64 cxy = sin(rZ);
cxx = cos(rZ);
65 cxz = sin(rY); rY = cos(rY);
66 cyz = sin(rX);
czz = cos(rX);
72 cxx *= rY; cxy *= -rY;
cyz *= -rY;
czz *= rY;
99 double x3D, y3D, z3D, x2D[8], y2D[8], z2D;
100 double XMIN_2D, XMAX_2D, YMIN_2D, YMAX_2D, ZMIN_2D;
104 XMIN_2D = YMIN_2D = XMAX_2D = YMAX_2D = ZMIN_2D = 0.0;
106 if(z & 1) x3D = 1.0;
else x3D = 0.0;
107 if(z & 2) y3D = 1.0;
else y3D = 0.0;
108 if(z & 4) z3D = 1.0;
else z3D = 0.0;
113 if(x2D[z] < XMIN_2D) XMIN_2D = x2D[z];
114 if(x2D[z] > XMAX_2D) XMAX_2D = x2D[z];
115 if(y2D[z] < YMIN_2D) YMIN_2D = y2D[z];
116 if(y2D[z] > YMAX_2D) YMAX_2D = y2D[z];
117 if(z2D < ZMIN_2D) { ZMIN_2D = z2D; Center = z; }
120 scaleX = double(
x2) / (XMAX_2D - XMIN_2D);
121 scaleY = double(
y2) / (YMAX_2D - YMIN_2D);
126 *(Xses+z) =
int(x2D[z] * scaleX + 0.5 +
xorig);
127 *(Yses+z) =
int(y2D[z] * scaleY + 0.5 +
yorig);
135 float *px,
float *py,
Axis*)
137 double x3D = *(zD++);
138 double y3D = *(zD++);
141 z3D = sqrt(x3D*x3D + y3D*y3D);
148 if(fabs(y3D) > 1e-250)
149 x3D = sqrt(x3D*x3D + y3D*y3D);
190 zr = sqrt(zr*zr + zi*zi);
197 if(fabs(zi) > 1e-250)
198 zr = sqrt(zr*zr + zi*zi);
233 if( (Bounds+x)->max < y ) (Bounds+x)->max = y;
234 if( (Bounds+x)->min > y ) (Bounds+x)->min = y;
237 return ( *(zBuffer + (y>>3) + x * ((
y2+7)>>3)) & (1 << (y & 7)) ) != 0;
245 int Size = MemEnd -
Mem + 256;
248 pMem += Mem - MemEnd;
249 MemEnd = Mem + Size - 5;
261 tBound *Bounds,
char *zBuffer)
264 int x1_ = p->
x, y1_ = p->
y;
265 int x2_ = (p+1)->x, y2_ = (p+1)->y;
267 bool wasHidden =
isHidden(x1_, y1_, Bounds, zBuffer);
269 if((p->
done & 1) == 0)
272 int ax_ = 0, ay_ = 0;
273 int ix_, iy_, dx_, dy_, of_;
304 for(
int i=dx_; i>1; i--) {
314 if(
isHidden(x1_, y1_, Bounds, zBuffer) != wasHidden )
315 if((p->
done & 1) == 0) {
316 wasHidden = !wasHidden;
332 if(
isHidden((p+1)->x, (p+1)->y, Bounds, zBuffer))
333 if(((p+1)->done & 1) == 0)
357 double *px, *py, *pz;
361 int i, j, z, dx, dy, Size=0;
379 if(g->
cPointsX.count() < 1)
continue;
391 for(i=g->
countY-1; i>=0; i--) {
392 px = g->
cPointsX.getFirst()->Points;
394 for(j=dx; j>0; j--) {
401 if(dy > 0)
if((i % dy) == 0)
404 (
pMem-1)->done |= 512;
410 for(j=g->
countY/dy; j>0; j--) {
411 for(i=dx; i>0; i--) {
412 for(z=dy; z>0; z--) {
430 (
pMem-1)->done |= 256;
441 for(i=g->
countY-1; i>=0; i--) {
442 if(dy > 0)
if(i % dy) {
443 for(j=dx-1; j>0; j--) {
444 zp->
z += (zp+1)->z + (zp+dx)->z + (zp+dx+1)->z;
453 for(j=dx; j>0; j--) {
469 qDebug(
"##########################################");
470 qDebug(
"Size 1b: Size=%d, %d, %d", Size,
pMem-
Mem, zp-zMem);
472 qDebug(
"xyPoints: %d/%d - %d - %d", p->
x, p->
y, p->
No, p->
done);
473 qDebug(
"------------------------------------------");
474 for(
tPointZ *p=zMem; p-zMem<Size; p++)
475 qDebug(
"zPoints: %g - %d", p->z, p->
No);
486 qDebug(
"--------------------------- z sorting");
487 for(
tPointZ *p=zMem; p-zMem<Size; p++)
488 qDebug(
"zPoints: %g - %d", p->z, p->
No);
504 for(
int No = g->
countY/dy * (dx-1)*(dy-1); No>0; No--) {
507 for(i=
x2; i>=0; i--) {
508 (Bounds+i)->max = INT_MIN;
509 (Bounds+i)->min = INT_MAX;
514 calcLine(p, MemEnd, Bounds, zBuffer);
517 calcLine(p, MemEnd, Bounds, zBuffer);
520 calcLine(p, MemEnd, Bounds, zBuffer);
523 calcLine(p, MemEnd, Bounds, zBuffer);
526 for(i=
x2-1; i>=0; i--)
527 if( (Bounds+i)->max > INT_MIN) {
528 pc = zBuffer + i * ((
y2+7)>>3);
529 for(j=(Bounds+i)->min; j<=(Bounds+i)->max; j++)
530 *(pc + (j>>3)) |= (1 << (j & 7));
539 qDebug(
"--------------------------- hidden lines %d", pMem-
Mem);
541 qDebug(
"xyPoints: %d/%d - %d - %d", p->
x, p->
y, p->
No, p->
done);
550 qDebug(
"--------------------------- last sorting %d", pMem-
Mem);
552 qDebug(
"xyPoints: %d/%d - %d - %d", p->
x, p->
y, p->
No, p->
done);
560 char *zBuffer,
tBound *Bounds)
582 if(((p-1)->done & 4) == 0)
583 Lines.append(
new Line((p-1)->x, (p-1)->y, p->
x, p->
y, QPen(Qt::black,0)));
627 double xD,
double phi,
bool Right)
629 double GridStep, corr, yD, stepD, GridNum, Expo;
630 double xstepD, ystepD;
635 int count, gx, gy, w;
637 if(phi > 0.0) Expo = phi -
M_PI/2.0;
638 else Expo = phi +
M_PI/2.0;
639 gx = int(5.4 * cos(Expo) + 0.5);
640 gy = int(5.4 * sin(Expo) + 0.5);
647 double upD = Axis->
up;
648 if(yD > 1.5*stepD) yD = 10.0*stepD;
656 ystepD = corr * log10(yD / fabs(Axis->
low));
657 while(ystepD <= xD) {
660 if(Axis->
up < 0.0) tmp =
'-'+tmp;
661 w = metrics.width(tmp);
662 if(maxWidth < w) maxWidth = w;
664 xLen = int(ystepD * cos(phi) + 0.5) + x;
665 yLen = int(ystepD * sin(phi) + 0.5) + y;
667 Texts.append(
new Text(xLen+3+gx, yLen-6+gy, tmp));
669 Texts.append(
new Text(xLen-w-2-gx, yLen-6-gy, tmp));
672 Lines.append(
new Line(xLen-gx, yLen-gy, xLen+gx, yLen+gy,
681 count = int((xD - yD) / stepD) + 1;
683 xstepD = stepD * cos(phi);
684 ystepD = stepD * sin(phi);
685 xD = yD * cos(phi) + 0.5 + double(x);
686 yD = yD * sin(phi) + 0.5 + double(y);
688 if(Axis->
up == 0.0) Expo = log10(fabs(Axis->
up-Axis->
low));
689 else Expo = log10(fabs(Axis->
up));
691 for(; count>0; count--) {
694 if(fabs(GridNum) < 0.01*pow(10.0, Expo)) GridNum = 0.0;
697 w = metrics.width(tmp);
698 if(maxWidth < w) maxWidth = w;
700 Texts.append(
new Text(x+3+gx, y-6+gy, tmp));
702 Texts.append(
new Text(x-w-2-gx, y-6-gy, tmp));
706 Lines.append(
new Line(x-gx, y-gy, x+gx, y+gy, QPen(Qt::black,0)));
717 int x1_,
int y1_,
int x2_,
int y2_)
721 double phi, cos_phi, sin_phi;
722 int x, y, z, w, valid, Index = 0;
723 if(Axis == &
yAxis) Index = 1;
730 cos_phi = sqrt(
double(x*x) +
double(y*y));
731 phi = atan2(
double(y),
double(x));
733 valid =
calcAxis(Axis, x1_, y1_, cos_phi, phi, Qt::DockRight);
738 if(fabs(phi-1e-5) >
M_PI/2.0) {
739 x1_ = x2_; cos_phi *= -1;
740 y1_ = y2_; sin_phi *= -1;
742 x = x1_ + int(
double(valid)*sin_phi);
743 y = y1_ - int(
double(valid)*cos_phi);
744 if(Axis->
Label.isEmpty()) {
762 x += int(
double(metrics.lineSpacing())*sin_phi);
763 y -= int(
double(metrics.lineSpacing())*cos_phi);
764 w = metrics.width(s);
765 Texts.append(
new Text(x+
int(
double((z-w)>>1)*cos_phi),
766 y+
int(
double((z-w)>>1)*sin_phi),
767 s, pg->
Color, 12.0, cos_phi, sin_phi));
771 x += int(
double(metrics.lineSpacing())*sin_phi);
772 y -= int(
double(metrics.lineSpacing())*cos_phi);
773 w = metrics.width(Axis->
Label);
774 Texts.append(
new Text(x+
int(
double((z-w)>>1)*cos_phi),
775 y+
int(
double((z-w)>>1)*sin_phi),
776 Axis->
Label, Qt::black, 12.0, cos_phi, sin_phi));
787 double GridStep, corr, zD, zDstep, GridNum;
851 Lines.append(
new Line(X[o^1], Y[o^1], X[o^3], Y[o^3], QPen(Qt::black,0)));
852 Lines.append(
new Line(X[o^2], Y[o^2], X[o^3], Y[o^3], QPen(Qt::black,0)));
855 Lines.append(
new Line(X[o^2], Y[o^2], X[o^6], Y[o^6], QPen(Qt::black,0)));
856 Lines.append(
new Line(X[o^4], Y[o^4], X[o^6], Y[o^6], QPen(Qt::black,0)));
859 Lines.append(
new Line(X[o^1], Y[o^1], X[o^5], Y[o^5], QPen(Qt::black,0)));
860 Lines.append(
new Line(X[o^4], Y[o^4], X[o^5], Y[o^5], QPen(Qt::black,0)));
864 if(X[o^1] < X[o^2]) w = 2;
884 w = (
x2+1) * (
y2/8 + 1);
887 zBuffer = (
char*)malloc(w);
888 memset(zBuffer, 0, w);
913 Lines.append(
new Line(X[o], Y[o], X[o^1], Y[o^1], QPen(Qt::black,0)));
914 Lines.append(
new Line(X[o], Y[o], X[o^2], Y[o^2], QPen(Qt::black,0)));
915 Lines.append(
new Line(X[o], Y[o], X[o^4], Y[o^4], QPen(Qt::black,0)));
925 Lines.append(
new Line(0, 0,
x2, 0, QPen(Qt::black,0)));
926 Lines.append(
new Line(0,
y2, 0, 0, QPen(Qt::black,0)));
938 int Size = ((2*(g->
cPointsX.getFirst()->count) + 1) * g->
countY) + 10;
944 float *p = (
float*)malloc( Size*
sizeof(
float) );
951 float dx=0.0, dy=0.0, xtmp=0.0, ytmp=0.0;
952 double Stroke=10.0, Space=10.0;
961 if((
pMem-1)->done & 12)
980 }
while(((
pMem++)->done & 256) == 0);
985 Stroke = 10.0; Space = 6.0;
988 Stroke = 2.0; Space = 4.0;
991 Stroke = 24.0; Space = 8.0;
1000 if((
pMem-1)->done & 12)
1013 }
while(((
pMem++)->done & 512) == 0);
1021 double alpha, dist = -Stroke;
1028 if((
pMem-1)->done & 12)
1048 dist += sqrt(
double(dx*dx + dy*dy));
1049 if((Flag == 1) && (dist <= 0.0)) {
1055 alpha = atan2(
double(dy),
double(dx));
1059 *(p++) = xtmp -
float(dist*cos(alpha));
1060 *(p++) = ytmp -
float(dist*sin(alpha));
1071 if(*(p-3) < 0) p -= 2;
1088 if((*(p-2) < 0) || (*(p-1) < 0))
1101 }
while(((
pMem++)->done & 256) == 0);
1140 Name = QObject::tr(
"3D-Cartesian");
1141 BitmapFile = (
char *)
"rect3d";
int regionCode(float, float)
static Element * info(QString &, char *&, bool getNewOne=false)
#define GRAPHSTYLE_LONGDASH
Rect3DDiagram(int _cx=0, int _cy=0)
double calcX_2D(double, double, double)
double calcZ_2D(double, double, double)
void removeHiddenLines(char *, tBound *)
Definitions and declarations for the main application.
QString StringNiceNum(double num)
static int comparePointZ(const void *, const void *)
bool insideDiagram(float, float)
void removeHiddenCross(int, int, int, int, char *, tBound *)
void calcCoordinate3D(double, double, double, double, tPoint3D *, tPointZ *)
void calcLine(tPoint3D *&, tPoint3D *&, tBound *, char *)
Q3PtrList< Graph > Graphs
Q3PtrList< struct Arc > Arcs
bool isHidden(int, int, tBound *, char *)
void enlargeMemoryBlock(tPoint3D *&)
bool calcAxisLogScale(Axis *, int &, double &, double &, double &, int)
Superclass of all schematic drawing elements.
double calcY_2D(double, double, double)
int calcCross(int *, int *)
void createAxis(Axis *, bool, int, int, int, int)
bool calcAxisScale(Axis *, double &, double &, double &, double &, double)
Q3PtrList< DataX > cPointsX
static int comparePoint3D(const void *, const void *)
int calcAxis(Axis *, int, int, double, double, bool)
void calcCoordinate(double *&, double *&, double *&, float *, float *, Axis *)