1 /*----------------------------------------------------------------------------
2 axis.cc (axis object)
3 This file is a part of topaz systems
4 Copyright: Hisao Kawaura, All rights reserved
5 1997 - 98
6
7
8 This program is free software; you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation; either version 2 of the License, or
11 (at your option) any later version.
12
13 This program is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
17
18 You should have received a copy of the GNU General Public License
19 along with this program; if not, write to the Free Software
20 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21
22 ----------------------------------------------------------------------------*/
23
24 #include <stdio.h>
25 #include <stdlib.h>
26 #include <math.h>
27 #include "axis.h"
28 #include "frame.h"
29 #include "graph.h"
30 #include "col.h"
31 #include "gdi.h"
32 #include "minmax.h"
33 #include "pointdefs.h"
34 #include "naninf.h"
35 #include "filepoint.h"
36 #include "topazvalues.h"
37
38 extern void message(const char *msg);
39 extern void StyleLinePath(bool flag, FILE* f, doublepointarray *array, int no_of_point, int style, int width,
40 bool Clip, intrect *AxisRect, intrect *boundrect);
41
42 extern FileHandleArray *fhvuff;
43
44
rot_x(double x,double y,double th)45 double rot_x(double x, double y, double th)
46 {
47 double ra = th / 180.0 * M_PI;
48
49 return (x * cos(ra) + y * sin(ra));
50 }
rot_y(double x,double y,double th)51 double rot_y(double x, double y, double th)
52 {
53 double ra = th / 180.0 * M_PI;
54
55 return (-x * sin(ra) + y * cos(ra));
56 }
57
BBboxrotatedrect(intrect * r,double th)58 void BBboxrotatedrect(intrect *r, double th)
59 {
60 // origin of rotation is assumed to be (0, 0)
61
62 double minx, maxx, miny, maxy;
63 double x, y;
64
65 minx = rot_x((double)r->left, (double)r->top, th);
66 maxx = rot_x((double)r->left, (double)r->top, th);
67 miny = rot_y((double)r->left, (double)r->top, th);
68 maxy = rot_y((double)r->left, (double)r->top, th);
69
70 x = rot_x((double)r->right, (double)r->top, th);
71 y = rot_y((double)r->right, (double)r->top, th);
72
73 minx = min(minx, x);
74 maxx = max(maxx, x);
75 miny = min(miny, y);
76 maxy = max(maxy, y);
77
78 x = rot_x((double)r->right, (double)r->bottom, th);
79 y = rot_y((double)r->right, (double)r->bottom, th);
80
81 minx = min(minx, x);
82 maxx = max(maxx, x);
83 miny = min(miny, y);
84 maxy = max(maxy, y);
85
86 x = rot_x((double)r->left, (double)r->bottom, th);
87 y = rot_y((double)r->left, (double)r->bottom, th);
88
89 minx = min(minx, x);
90 maxx = max(maxx, x);
91 miny = min(miny, y);
92 maxy = max(maxy, y);
93
94 r->left = (int)minx;
95 r->top = (int)miny;
96 r->right = (int)maxx;
97 r->bottom = (int)maxy;
98
99 }
100
axis()101 axis::axis():plobj()
102 {
103 version = 4;
104 id = 0;
105 label = new std::string("");
106 selected = false;
107
108 axistype = 0;
109 display = true;
110 commonset = true;
111 scaling = SCALE_LINEAR;
112 invertscale = false;
113 origin.x = 0;
114 origin.y = 0;
115 length = 10000;
116 angle = 0.0;
117 baselinestyle.init();
118 basecolor.setblack();
119 tickarea_start = 0.0;
120 tickarea_end = 100.0;
121
122 /*mumerical range*/
123 start = 0.0;
124 end = 10.0;
125 unit = 2.0;
126 crosspoint = 0.0;
127 autocrosspoint = true;
128
129 /*tick*/
130 tickparity = TICKPARITY_PLUS;
131 tickwidth = 10;
132 ticklength = 200;
133 division = 2;
134
135 /*tickline*/
136 majorticklinecolor.setblack();
137 minorticklinecolor.setblack();
138 majorticklinestyle.init();
139 majorticklinestyle.style = LINESTYLENULL;
140 minorticklinestyle.init();
141 minorticklinestyle.style = LINESTYLENULL;
142
143 /*label*/
144 fo.init();
145 fontcolor.setblack();
146 format = LABEL_FORMAT_DECIMAL;
147 addplus = false;
148 offset = 0;
149 skip = 0;
150 autoprecision = true;
151 intprecision = 5;
152 decimalprecision = 5;
153 labelparity = LABELPARITY_PLUS;
154 crosspointparity = CROSSPOINTPARITY_CENTER;
155 crosspointoffset = 0;
156 }
157
~axis()158 axis::~axis()
159 {
160 delete label;
161 }
162
operator =(const axis & axis)163 axis& axis::operator = (const axis& axis)
164 {
165 // id = axis.id;
166 selected = axis.selected;
167 axistype = axis.axistype;
168 display = axis.display;
169 commonset = axis.commonset;
170 scaling = axis.scaling;
171 invertscale = axis.invertscale;
172 origin.x = axis.origin.x;
173 origin.y = axis.origin.y;
174 length = axis.length;
175 angle = axis.angle;
176 baselinestyle = axis.baselinestyle;
177 basecolor = axis.basecolor;
178 tickarea_start = axis.tickarea_start;
179 tickarea_end = axis.tickarea_end;
180
181
182 /*mumerical range*/
183 start = axis.start;
184 end = axis.end;
185 unit = axis.unit;
186 crosspoint = axis.crosspoint;
187 autocrosspoint = axis.autocrosspoint;
188
189 /*tick*/
190 tickparity = axis.tickparity;
191 tickwidth = axis.tickwidth;
192 ticklength = axis.ticklength;
193 division = axis.division;
194
195 /*tickline*/
196 majorticklinecolor = axis.majorticklinecolor;
197 minorticklinecolor = axis.minorticklinecolor;
198 majorticklinestyle = axis.majorticklinestyle;
199 minorticklinestyle = axis.minorticklinestyle;
200
201 /*label*/
202 fo = axis.fo;
203 fontcolor = axis.fontcolor;
204 format = axis.format;
205 addplus = axis.addplus;
206 offset = axis.offset;
207 skip = axis.skip;
208 autoprecision = axis.autoprecision;
209 intprecision = axis.intprecision;
210 decimalprecision = axis.decimalprecision;
211 labelparity = axis.labelparity;
212 crosspointparity = axis.crosspointparity;
213 crosspointoffset = axis.crosspointoffset;
214
215 return *this;
216 }
217
218
get(std::string * member,tokenbuff * outvalue)219 bool axis::get(std::string* member, tokenbuff* outvalue)
220 {
221 std::string out;
222 int iid;
223 char stemp[100];
224
225 if (topobject(member, &out, &iid) == true)
226 {
227 if (out == std::string("id") && iid == -1)
228 {
229 sprintf(stemp, "%d", id);
230 outvalue->value->add(stemp);
231 return true;
232 }
233 else if (out == std::string("label") && iid == -1)
234 {
235 outvalue->value->add(label->c_str());
236 return true;
237 }
238 else if (out == std::string("selected") && iid == -1)
239 {
240 sprintf(stemp, "%d", selected);
241 outvalue->value->add(stemp);
242 return true;
243 }
244 else if (out == std::string("axistype") && iid == -1)
245 {
246 sprintf(stemp, "%d", axistype);
247 outvalue->value->add(stemp);
248 return true;
249 }
250 else if (out == std::string("show") && iid == -1)
251 {
252 sprintf(stemp, "%d", display);
253 outvalue->value->add(stemp);
254 return true;
255 }
256 else if (out == std::string("commonset") && iid == -1)
257 {
258 sprintf(stemp, "%d", commonset);
259 outvalue->value->add(stemp);
260 return true;
261 }
262 else if (out == std::string("scaling") && iid == -1)
263 {
264 sprintf(stemp, "%d", scaling);
265 outvalue->value->add(stemp);
266 return true;
267 }
268 else if (out == std::string("invertscale") && iid == -1)
269 {
270 sprintf(stemp, "%d", invertscale);
271 outvalue->value->add(stemp);
272 return true;
273 }
274 else if (out == std::string("x") && iid == -1)
275 {
276 sprintf(stemp, "%d", origin.x);
277 outvalue->value->add(stemp);
278 return true;
279 }
280 else if (out == std::string("y") && iid == -1)
281 {
282 sprintf(stemp, "%d", origin.y);
283 outvalue->value->add(stemp);
284 return true;
285 }
286 else if (out == std::string("length") && iid == -1)
287 {
288 sprintf(stemp, "%d", length);
289 outvalue->value->add(stemp);
290 return true;
291 }
292 else if (out == std::string("angle") && iid == -1)
293 {
294 sprintf(stemp, "%.15g", angle);
295 outvalue->value->add(stemp);
296 return true;
297 }
298 else if (out == std::string("baselinewidth") && iid == -1)
299 {
300 sprintf(stemp, "%d", baselinestyle.width);
301 outvalue->value->add(stemp);
302 return true;
303 }
304 else if (out == std::string("baselinecap") && iid == -1)
305 {
306 sprintf(stemp, "%d", baselinestyle.cap);
307 outvalue->value->add(stemp);
308 return true;
309 }
310 else if (out == std::string("baselinejoin") && iid == -1)
311 {
312 sprintf(stemp, "%d", baselinestyle.join);
313 outvalue->value->add(stemp);
314 return true;
315 }
316 else if (out == std::string("baselinestyle") && iid == -1)
317 {
318 sprintf(stemp, "%d", baselinestyle.style);
319 outvalue->value->add(stemp);
320 return true;
321 }
322 else if (out == std::string("baselinecolor_red") && iid == -1)
323 {
324 sprintf(stemp, "%u", basecolor.red);
325 outvalue->value->add(stemp);
326 return true;
327 }
328 else if (out == std::string("baselinecolor_green") && iid == -1)
329 {
330 sprintf(stemp, "%u", basecolor.green);
331 outvalue->value->add(stemp);
332 return true;
333 }
334 else if (out == std::string("baselinecolor_blue") && iid == -1)
335 {
336 sprintf(stemp, "%u", basecolor.blue);
337 outvalue->value->add(stemp);
338 return true;
339 }
340 else if (out == std::string("tickarea_start") && iid == -1)
341 {
342 sprintf(stemp, "%.15g", tickarea_start);
343 outvalue->value->add(stemp);
344 return true;
345 }
346 else if (out == std::string("tickarea_end") && iid == -1)
347 {
348 sprintf(stemp, "%.15g", tickarea_end);
349 outvalue->value->add(stemp);
350 return true;
351 }
352 else if (out == std::string("start") && iid == -1)
353 {
354 sprintf(stemp, "%.15g", start);
355 outvalue->value->add(stemp);
356 return true;
357 }
358 else if (out == std::string("end") && iid == -1)
359 {
360 sprintf(stemp, "%.15g", end);
361 outvalue->value->add(stemp);
362 return true;
363 }
364 else if (out == std::string("unit") && iid == -1)
365 {
366 sprintf(stemp, "%.15g", unit);
367 outvalue->value->add(stemp);
368 return true;
369 }
370 else if (out == std::string("crosspoint") && iid == -1)
371 {
372 sprintf(stemp, "%.15g", crosspoint);
373 outvalue->value->add(stemp);
374 return true;
375 }
376 else if (out == std::string("autocrosspoint") && iid == -1)
377 {
378 sprintf(stemp, "%d", autocrosspoint);
379 outvalue->value->add(stemp);
380 return true;
381 }
382 else if (out == std::string("tickparity") && iid == -1)
383 {
384 sprintf(stemp, "%d", tickparity);
385 outvalue->value->add(stemp);
386 return true;
387 }
388 else if (out == std::string("tickwidth") && iid == -1)
389 {
390 sprintf(stemp, "%d", tickwidth);
391 outvalue->value->add(stemp);
392 return true;
393 }
394 else if (out == std::string("ticklength") && iid == -1)
395 {
396 sprintf(stemp, "%d", ticklength);
397 outvalue->value->add(stemp);
398 return true;
399 }
400 else if (out == std::string("tickdivision") && iid == -1)
401 {
402 sprintf(stemp, "%d", division);
403 outvalue->value->add(stemp);
404 return true;
405 }
406 else if (out == std::string("majorticklinecolor_red") && iid == -1)
407 {
408 sprintf(stemp, "%u", majorticklinecolor.red);
409 outvalue->value->add(stemp);
410 return true;
411 }
412 else if (out == std::string("majorticklinecolor_green") && iid == -1)
413 {
414 sprintf(stemp, "%u", majorticklinecolor.green);
415 outvalue->value->add(stemp);
416 return true;
417 }
418 else if (out == std::string("majorticklinecolor_blue") && iid == -1)
419 {
420 sprintf(stemp, "%u", majorticklinecolor.blue);
421 outvalue->value->add(stemp);
422 return true;
423 }
424 else if (out == std::string("minorticklinecolor_red") && iid == -1)
425 {
426 sprintf(stemp, "%u", minorticklinecolor.red);
427 outvalue->value->add(stemp);
428 return true;
429 }
430 else if (out == std::string("minorticklinecolor_green") && iid == -1)
431 {
432 sprintf(stemp, "%u", minorticklinecolor.green);
433 outvalue->value->add(stemp);
434 return true;
435 }
436 else if (out == std::string("minorticklinecolor_blue") && iid == -1)
437 {
438 sprintf(stemp, "%u", minorticklinecolor.blue);
439 outvalue->value->add(stemp);
440 return true;
441 }
442 else if (out == std::string("majorticklinewidth") && iid == -1)
443 {
444 sprintf(stemp, "%d", majorticklinestyle.width);
445 outvalue->value->add(stemp);
446 return true;
447 }
448 else if (out == std::string("majorticklinecap") && iid == -1)
449 {
450 sprintf(stemp, "%d", majorticklinestyle.cap);
451 outvalue->value->add(stemp);
452 return true;
453 }
454 else if (out == std::string("majorticklinejoin") && iid == -1)
455 {
456 sprintf(stemp, "%d", majorticklinestyle.join);
457 outvalue->value->add(stemp);
458 return true;
459 }
460 else if (out == std::string("majorticklinestyle") && iid == -1)
461 {
462 sprintf(stemp, "%d", majorticklinestyle.style);
463 outvalue->value->add(stemp);
464 return true;
465 }
466 else if (out == std::string("minorticklinewidth") && iid == -1)
467 {
468 sprintf(stemp, "%d", minorticklinestyle.width);
469 outvalue->value->add(stemp);
470 return true;
471 }
472 else if (out == std::string("minorticklinecap") && iid == -1)
473 {
474 sprintf(stemp, "%d", minorticklinestyle.cap);
475 outvalue->value->add(stemp);
476 return true;
477 }
478 else if (out == std::string("minorticklinejoin") && iid == -1)
479 {
480 sprintf(stemp, "%d", minorticklinestyle.join);
481 outvalue->value->add(stemp);
482 return true;
483 }
484 else if (out == std::string("minorticklinestyle") && iid == -1)
485 {
486 sprintf(stemp, "%d", minorticklinestyle.style);
487 outvalue->value->add(stemp);
488 return true;
489 }
490 else if (out == std::string("fontface") && iid == -1)
491 {
492 sprintf(stemp, "%d", fo.face);
493 outvalue->value->add(stemp);
494 return true;
495 }
496 else if (out == std::string("fontsize") && iid == -1)
497 {
498 sprintf(stemp, "%d", fo.size);
499 outvalue->value->add(stemp);
500 return true;
501 }
502 else if (out == std::string("fontangle") && iid == -1)
503 {
504 sprintf(stemp, "%.15g", fo.angle);
505 outvalue->value->add(stemp);
506 return true;
507 }
508 else if (out == std::string("fontcolor_red") && iid == -1)
509 {
510 sprintf(stemp, "%u", fontcolor.red);
511 outvalue->value->add(stemp);
512 return true;
513 }
514 else if (out == std::string("fontcolor_green") && iid == -1)
515 {
516 sprintf(stemp, "%u", fontcolor.green);
517 outvalue->value->add(stemp);
518 return true;
519 }
520 else if (out == std::string("fontcolor_blue") && iid == -1)
521 {
522 sprintf(stemp, "%u", fontcolor.blue);
523 outvalue->value->add(stemp);
524 return true;
525 }
526 else if (out == std::string("format") && iid == -1)
527 {
528 sprintf(stemp, "%d", format);
529 outvalue->value->add(stemp);
530 return true;
531 }
532 else if (out == std::string("addplus") && iid == -1)
533 {
534 sprintf(stemp, "%d", addplus);
535 outvalue->value->add(stemp);
536 return true;
537 }
538 else if (out == std::string("offset") && iid == -1)
539 {
540 sprintf(stemp, "%d", offset);
541 outvalue->value->add(stemp);
542 return true;
543 }
544 else if (out == std::string("skip") && iid == -1)
545 {
546 sprintf(stemp, "%d", skip);
547 outvalue->value->add(stemp);
548 return true;
549 }
550 else if (out == std::string("autoprecision") && iid == -1)
551 {
552 sprintf(stemp, "%d", autoprecision);
553 outvalue->value->add(stemp);
554 return true;
555 }
556 else if (out == std::string("intprecision") && iid == -1)
557 {
558 sprintf(stemp, "%d", intprecision);
559 outvalue->value->add(stemp);
560 return true;
561 }
562 else if (out == std::string("decimalprecision") && iid == -1)
563 {
564 sprintf(stemp, "%d", decimalprecision);
565 outvalue->value->add(stemp);
566 return true;
567 }
568 else if (out == std::string("labelparity") && iid == -1)
569 {
570 sprintf(stemp, "%d", labelparity);
571 outvalue->value->add(stemp);
572 return true;
573 }
574 else if (out == std::string("crosspointparity") && iid == -1)
575 {
576 sprintf(stemp, "%d", crosspointparity);
577 outvalue->value->add(stemp);
578 return true;
579 }
580 else if (out == std::string("crosspointoffset") && iid == -1)
581 {
582 sprintf(stemp, "%d", crosspointoffset);
583 outvalue->value->add(stemp);
584 return true;
585 }
586 else
587 return false;
588 }
589 else
590 return false;
591
592 return true;
593
594 }
595
596
set(std::string * member,std::string * setvalue)597 bool axis::set(std::string* member, std::string* setvalue)
598 {
599 std::string out;
600 int iid;
601
602 if (topobject(member, &out, &iid) == true)
603 {
604 if (out == std::string("id") && iid == -1)
605 {
606 id = atoi(setvalue->c_str());
607 return true;
608 }
609 else if (out == std::string("label") && iid == -1)
610 {
611 *label = *setvalue;
612 return true;
613 }
614 else if (out == std::string("selected") && iid == -1)
615 {
616 selected = atoi(setvalue->c_str());
617 return true;
618 }
619 else if (out == std::string("axistype") && iid == -1)
620 {
621 axistype = atoi(setvalue->c_str());
622 return true;
623 }
624 else if (out == std::string("show") && iid == -1)
625 {
626 display = atoi(setvalue->c_str());
627 return true;
628 }
629 else if (out == std::string("commonset") && iid == -1)
630 {
631 commonset = atoi(setvalue->c_str());
632 return true;
633 }
634 else if (out == std::string("scaling") && iid == -1)
635 {
636 scaling = atoi(setvalue->c_str());
637 return true;
638 }
639 else if (out == std::string("invertscale") && iid == -1)
640 {
641 invertscale = atoi(setvalue->c_str());
642 return true;
643 }
644 else if (out == std::string("x") && iid == -1)
645 {
646 origin.x = atoi(setvalue->c_str());
647 return true;
648 }
649 else if (out == std::string("y") && iid == -1)
650 {
651 origin.y = atoi(setvalue->c_str());
652 return true;
653 }
654 else if (out == std::string("length") && iid == -1)
655 {
656 length = atoi(setvalue->c_str());
657 return true;
658 }
659 else if (out == std::string("angle") && iid == -1)
660 {
661 angle = atof(setvalue->c_str());
662 return true;
663 }
664 else if (out == std::string("baselinewidth") && iid == -1)
665 {
666 baselinestyle.width = atoi(setvalue->c_str());
667 return true;
668 }
669 else if (out == std::string("baselinecap") && iid == -1)
670 {
671 baselinestyle.cap = atoi(setvalue->c_str());
672 return true;
673 }
674 else if (out == std::string("baselinejoin") && iid == -1)
675 {
676 baselinestyle.join = atoi(setvalue->c_str());
677 return true;
678 }
679 else if (out == std::string("baselinestyle") && iid == -1)
680 {
681 baselinestyle.style = atoi(setvalue->c_str());
682 return true;
683 }
684 else if (out == std::string("baselinecolor_red") && iid == -1)
685 {
686 basecolor.red = atol(setvalue->c_str());
687 return true;
688 }
689 else if (out == std::string("baselinecolor_green") && iid == -1)
690 {
691 basecolor.green = atol(setvalue->c_str());
692 return true;
693 }
694 else if (out == std::string("baselinecolor_blue") && iid == -1)
695 {
696 basecolor.blue = atol(setvalue->c_str());
697 return true;
698 }
699 else if (out == std::string("tickarea_start") && iid == -1)
700 {
701 tickarea_start = atof(setvalue->c_str());
702 return true;
703 }
704 else if (out == std::string("tickarea_end") && iid == -1)
705 {
706 tickarea_end = atof(setvalue->c_str());
707 return true;
708 }
709 else if (out == std::string("start") && iid == -1)
710 {
711 start = atof(setvalue->c_str());
712 return true;
713 }
714 else if (out == std::string("end") && iid == -1)
715 {
716 end = atof(setvalue->c_str());
717 return true;
718 }
719 else if (out == std::string("unit") && iid == -1)
720 {
721 unit = atof(setvalue->c_str());
722 return true;
723 }
724 else if (out == std::string("crosspoint") && iid == -1)
725 {
726 crosspoint = atof(setvalue->c_str());
727 return true;
728 }
729 else if (out == std::string("autocrosspoint") && iid == -1)
730 {
731 autocrosspoint = atoi(setvalue->c_str());
732 return true;
733 }
734 else if (out == std::string("tickparity") && iid == -1)
735 {
736 tickparity = atoi(setvalue->c_str());
737 return true;
738 }
739 else if (out == std::string("tickwidth") && iid == -1)
740 {
741 tickwidth = atoi(setvalue->c_str());
742 return true;
743 }
744 else if (out == std::string("ticklength") && iid == -1)
745 {
746 ticklength = atoi(setvalue->c_str());
747 return true;
748 }
749 else if (out == std::string("tickdivision") && iid == -1)
750 {
751 division = atoi(setvalue->c_str());
752 return true;
753 }
754 else if (out == std::string("majorticklinecolor_red") && iid == -1)
755 {
756 majorticklinecolor.red = atol(setvalue->c_str());
757 return true;
758 }
759 else if (out == std::string("majorticklinecolor_green") && iid == -1)
760 {
761 majorticklinecolor.green = atol(setvalue->c_str());
762 return true;
763 }
764 else if (out == std::string("majorticklinecolor_blue") && iid == -1)
765 {
766 majorticklinecolor.blue = atol(setvalue->c_str());
767 return true;
768 }
769 else if (out == std::string("minorticklinecolor_red") && iid == -1)
770 {
771 minorticklinecolor.red = atol(setvalue->c_str());
772 return true;
773 }
774 else if (out == std::string("minorticklinecolor_green") && iid == -1)
775 {
776 minorticklinecolor.green = atol(setvalue->c_str());
777 return true;
778 }
779 else if (out == std::string("minorticklinecolor_blue") && iid == -1)
780 {
781 minorticklinecolor.blue = atol(setvalue->c_str());
782 return true;
783 }
784 else if (out == std::string("majorticklinewidth") && iid == -1)
785 {
786 majorticklinestyle.width = atoi(setvalue->c_str());
787 return true;
788 }
789 else if (out == std::string("majorticklinecap") && iid == -1)
790 {
791 majorticklinestyle.cap = atoi(setvalue->c_str());
792 return true;
793 }
794 else if (out == std::string("majorticklinejoin") && iid == -1)
795 {
796 majorticklinestyle.join = atoi(setvalue->c_str());
797 return true;
798 }
799 else if (out == std::string("majorticklinestyle") && iid == -1)
800 {
801 majorticklinestyle.style = atoi(setvalue->c_str());
802 return true;
803 }
804 else if (out == std::string("minorticklinewidth") && iid == -1)
805 {
806 minorticklinestyle.width = atoi(setvalue->c_str());
807 return true;
808 }
809 else if (out == std::string("minorticklinecap") && iid == -1)
810 {
811 minorticklinestyle.cap = atoi(setvalue->c_str());
812 return true;
813 }
814 else if (out == std::string("minorticklinejoin") && iid == -1)
815 {
816 minorticklinestyle.join = atoi(setvalue->c_str());
817 return true;
818 }
819 else if (out == std::string("minorticklinestyle") && iid == -1)
820 {
821 minorticklinestyle.style = atoi(setvalue->c_str());
822 return true;
823 }
824 else if (out == std::string("fontface") && iid == -1)
825 {
826 fo.face = atoi(setvalue->c_str());
827 return true;
828 }
829 else if (out == std::string("fontsize") && iid == -1)
830 {
831 fo.size = atoi(setvalue->c_str());
832 return true;
833 }
834 else if (out == std::string("fontangle") && iid == -1)
835 {
836 fo.angle = atof(setvalue->c_str());
837 return true;
838 }
839 else if (out == std::string("fontcolor_red") && iid == -1)
840 {
841 fontcolor.red = atol(setvalue->c_str());
842 return true;
843 }
844 else if (out == std::string("fontcolor_green") && iid == -1)
845 {
846 fontcolor.green = atol(setvalue->c_str());
847 return true;
848 }
849 else if (out == std::string("fontcolor_blue") && iid == -1)
850 {
851 fontcolor.blue = atol(setvalue->c_str());
852 return true;
853 }
854 else if (out == std::string("format") && iid == -1)
855 {
856 format = atoi(setvalue->c_str());
857 return true;
858 }
859 else if (out == std::string("addplus") && iid == -1)
860 {
861 addplus = atoi(setvalue->c_str());
862 return true;
863 }
864 else if (out == std::string("offset") && iid == -1)
865 {
866 offset = atoi(setvalue->c_str());
867 return true;
868 }
869 else if (out == std::string("skip") && iid == -1)
870 {
871 skip = atoi(setvalue->c_str());
872 return true;
873 }
874 else if (out == std::string("autoprecision") && iid == -1)
875 {
876 autoprecision = atoi(setvalue->c_str());
877 return true;
878 }
879 else if (out == std::string("intprecision") && iid == -1)
880 {
881 intprecision = atoi(setvalue->c_str());
882 return true;
883 }
884 else if (out == std::string("decimalprecision") && iid == -1)
885 {
886 decimalprecision = atoi(setvalue->c_str());
887 return true;
888 }
889 else if (out == std::string("labelparity") && iid == -1)
890 {
891 labelparity = atoi(setvalue->c_str());
892 return true;
893 }
894 else if (out == std::string("crosspointparity") && iid == -1)
895 {
896 crosspointparity = atoi(setvalue->c_str());
897 return true;
898 }
899 else if (out == std::string("crosspointoffset") && iid == -1)
900 {
901 crosspointoffset = atoi(setvalue->c_str());
902 return true;
903 }
904 else
905 return false;
906 }
907 else
908 return false;
909
910 return true;
911
912 }
913
914
exec(std::string * function,buffarray * argument,tokenbuff * outvalue)915 bool axis::exec(std::string* function, buffarray *argument, tokenbuff* outvalue)
916 {
917 std::string out, shrunk, str1;
918 int iid, arglength;
919 intpoint ip;
920 char stemp[1000];
921 double ftemp;
922 frame *fr = (frame *)parent;
923 FILE* fp;
924 int itemp;
925
926 outvalue->value->setbuff(0);
927 if (topobject(function, &out, &iid) == true)
928 {
929 arglength = argument->getarraylength();
930
931 // paint
932 if (out == std::string("paint") && iid == -1)
933 {
934 if (arglength == 1)
935 {
936 if (fhvuff->get(&(*argument)[0], &fp, &itemp, &str1))
937 {
938 paint(true, fp);
939 return true;
940 }
941 return false;
942 }
943 else
944 return false;
945 }
946 // setbbox
947 else if (out == std::string("setbbox") && iid == -1)
948 {
949 if (arglength == 1 && (*argument)[0] == std::string("null"))
950 {
951 paint(false, fp);
952 return true;
953 }
954 else
955 return false;
956 }
957 // virtual to world
958 else if (out == std::string("virtow") && iid == -1)
959 {
960 if (arglength == 1)
961 {
962 ip = virtual_to_world(atof((*argument)[0].c_str()));
963 outvalue->value->setbuff(0);
964 sprintf(stemp, "%d", ip.x);
965 outvalue->value->add(stemp);
966 sprintf(stemp, "%d", ip.y);
967 outvalue->value->add(stemp);
968 return true;
969 }
970 else
971 return false;
972 }
973 // virtual to view
974 else if (out == std::string("virtov") && iid == -1)
975 {
976 if (arglength == 1)
977 {
978 outvalue->value->setbuff(0);
979 ip = virtual_to_world(atof((*argument)[0].c_str()));
980 sprintf(stemp, "%d", fr->wtov_x(ip.x));
981 outvalue->value->add(stemp);
982 sprintf(stemp, "%d", fr->wtov_y(ip.y));
983 outvalue->value->add(stemp);
984 return true;
985 }
986 else
987 return false;
988 }
989 // world to virtual
990 else if (out == std::string("wtovir") && iid == -1)
991 {
992 if (arglength == 2)
993 {
994 ftemp = doubleworld_to_virtual(atof((*argument)[0].c_str()), atof((*argument)[1].c_str()));
995 sprintf(stemp, "%.15g", ftemp);
996 outvalue->value->setbuff(0);
997 outvalue->value->add(stemp);
998 return true;
999 }
1000 else
1001 return false;
1002 }
1003 // view to virtual
1004 else if (out == std::string("vtovir") && iid == -1)
1005 {
1006 if (arglength == 2)
1007 {
1008 ftemp = doubleworld_to_virtual(fr->vtow_x(atoi((*argument)[0].c_str())),
1009 fr->vtow_y(atoi((*argument)[1].c_str())));
1010 sprintf(stemp, "%.15g", ftemp);
1011 outvalue->value->setbuff(0);
1012 outvalue->value->add(stemp);
1013 return true;
1014 }
1015 else
1016 return false;
1017 }
1018 else
1019 return false;
1020 }
1021 else
1022 return false;
1023
1024 return true;
1025 }
1026
1027
paint(bool flag,FILE * f)1028 bool axis::paint(bool flag, FILE* f)
1029 {
1030 frame *fra = (frame *)parent;
1031
1032 if (display == false)
1033 return true;
1034
1035 plinestyle(flag, f, fra->scale(baselinestyle.width), baselinestyle.cap, baselinestyle.join, baselinestyle.style);
1036 psetforecolor(flag, f, basecolor.red, basecolor.green, basecolor.blue);
1037
1038 //baseline
1039 switch(fra->frametype)
1040 {
1041 case FRAME_BOX:
1042 case FRAME_XY:
1043 case FRAME_INDIV:
1044
1045 //baseline
1046 pbeginpath(flag, f);
1047 pmoveto(flag, f, fra->wtov_x(0 + origin.x), fra->wtov_y(0 + origin.y));
1048 plineto(flag, f, fra->wtov_x((int)rot_x(length, 0, angle) + origin.x),
1049 fra->wtov_y((int)rot_y(length, 0, angle) + origin.y));
1050 pstroke(flag, f);
1051 break;
1052
1053 }
1054
1055 if (!paintmajortick(flag, f))
1056 return false;
1057 if (!paintminortick(flag, f))
1058 return false;
1059 if (!drawlabel(flag, f))
1060 return false;
1061
1062 return true;
1063
1064 }
1065
virtual_to_doubleworld(double x)1066 doublepoint axis::virtual_to_doubleworld(double x)
1067 {
1068 double fa;
1069
1070 fa = virtual_to_axis(x);
1071 return axis_to_world(fa, 0.0);
1072 }
1073
virtual_to_world(double x)1074 intpoint axis::virtual_to_world(double x)
1075 {
1076 doublepoint fa;
1077 intpoint ia;
1078
1079 fa = virtual_to_doubleworld(x);
1080 if (fabs(fa.x) >= (double)MAXSHORT)
1081 ia.x = MAXSHORT;
1082 else
1083 ia.x = (int)fa.x;
1084
1085 if (fabs(fa.y) >= (double)MAXSHORT)
1086 ia.y = MAXSHORT;
1087 else
1088 ia.y = (int)fa.y;
1089
1090 return ia;
1091 }
1092
virtual_to_axis(double x)1093 double axis::virtual_to_axis(double x)
1094 {
1095 double fa = 0.0;
1096 double elength = (tickarea_end - tickarea_start) / 100.0 * length;
1097 double estart = tickarea_start / 100.0 * length;
1098
1099 switch(scaling)
1100 {
1101 case SCALE_LINEAR:
1102 fa = x - start;
1103 fa /= end - start;
1104 fa = elength * fa + estart;
1105 break;
1106
1107 case SCALE_LOG:
1108 case SCALE_LOGLINEAR:
1109 fa = log10(x) - log10(start);
1110 fa /= log10(end) - log10(start);
1111 fa = elength * fa + estart;
1112 break;
1113
1114 case SCALE_INV:
1115 case SCALE_INVLINEAR:
1116 fa = 1.0 / x - 1.0 / start;
1117 fa /= 1.0 / end - 1.0 / start;
1118 fa = elength * fa + estart;
1119 break;
1120 }
1121
1122 if (invertscale)
1123 fa = length - fa;
1124
1125 return fa;
1126 }
1127
axis_to_world(double x,double y)1128 doublepoint axis::axis_to_world(double x, double y)
1129 {
1130 doublepoint returnpoint;
1131
1132 returnpoint.x = rot_x(x, y, angle);
1133 returnpoint.y = rot_y(x, y, angle);
1134
1135 returnpoint.x += (double)origin.x;
1136 returnpoint.y += (double)origin.y;
1137
1138 return (returnpoint);
1139 }
1140
axis_to_virtual(double x)1141 double axis::axis_to_virtual(double x)
1142 {
1143 double fa = 0.0;
1144 double elength = (tickarea_end - tickarea_start) / 100.0 * length;
1145 double estart = tickarea_start / 100.0 * length;
1146 double eend = tickarea_end / 100.0 * length;
1147
1148 if (length == 0.0)
1149 return infvalue();
1150
1151 if (invertscale)
1152 {
1153 switch(scaling)
1154 {
1155 case SCALE_LINEAR:
1156 fa = (x - length + eend) / elength;
1157 fa *= start - end;
1158 fa += end;
1159 break;
1160
1161 case SCALE_LOG:
1162 case SCALE_LOGLINEAR:
1163 fa = (x - length + eend)/ elength;
1164 fa *= log10(start) - log10(end);
1165 fa += log10(end);
1166 fa = pow(10.0, fa);
1167 break;
1168
1169 case SCALE_INV:
1170 case SCALE_INVLINEAR:
1171 fa = (x - length + eend)/ elength;
1172 fa *= 1.0 / start - 1.0 / end;
1173 fa += 1.0 / end;
1174 fa = 1.0 / fa;
1175 break;
1176 }
1177 }
1178 else
1179 {
1180 switch(scaling)
1181 {
1182 case SCALE_LINEAR:
1183 fa = (x - estart)/ elength;
1184 fa *= end - start;
1185 fa += start;
1186 break;
1187
1188 case SCALE_LOG:
1189 case SCALE_LOGLINEAR:
1190 fa = (x - estart)/ elength;
1191 fa *= log10(end) - log10(start);
1192 fa += log10(start);
1193 fa = pow(10.0, fa);
1194 break;
1195
1196 case SCALE_INV:
1197 case SCALE_INVLINEAR:
1198 fa = (x - estart)/ elength;
1199 fa *= 1.0 / end - 1.0 / start;
1200 fa += 1.0 / start;
1201 fa = 1.0 / fa;
1202 break;
1203 }
1204 }
1205 return fa;
1206 }
1207
world_to_axis(double x,double y)1208 double axis::world_to_axis(double x, double y)
1209 {
1210 doublepoint returnpoint;
1211
1212 returnpoint.x = x - (double)origin.x;
1213 returnpoint.y = y - (double)origin.y;
1214
1215 returnpoint.x = rot_x(returnpoint.x,returnpoint. y, -angle);
1216
1217 return (returnpoint.x);
1218 }
1219
doubleworld_to_virtual(double x,double y)1220 double axis::doubleworld_to_virtual(double x, double y)
1221 {
1222 double fa;
1223
1224 fa = world_to_axis(x, y);
1225 return axis_to_virtual(fa);
1226 }
1227
paintmajortick(bool flag,FILE * f)1228 bool axis::paintmajortick(bool flag, FILE* f)
1229 {
1230 frame *fra = (frame *)parent;
1231 double virstart, virend, startval, endval;
1232 double delta;
1233 int itercount;
1234 intpoint valpos, fixedpos;
1235 doublepoint tempdpoint;
1236 double fa;
1237 double tickstart = 0.0, tickend = 0.0;
1238 doublepointarray *da;
1239 intrect axisrect, cliprect;
1240
1241 da = new doublepointarray;
1242
1243 // determine tickstart, tickend
1244 switch(tickparity)
1245 {
1246 case TICKPARITY_NULL:
1247 tickstart = 0.0; tickend = 0.0;
1248 break;
1249 case TICKPARITY_PLUS:
1250 tickstart = 0.0; tickend = ticklength;
1251 break;
1252 case TICKPARITY_MINUS:
1253 tickstart = -ticklength; tickend = 0.0;
1254 break;
1255 case TICKPARITY_BOTH:
1256 tickstart = -ticklength; tickend = ticklength;
1257 break;
1258 }
1259
1260 // tick style
1261 plinestyle(flag, f, fra->scale(tickwidth), baselinestyle.cap, baselinestyle.join, LINESTYLESOLID);
1262
1263 //majortick
1264 switch(scaling)
1265 {
1266 case SCALE_LINEAR:
1267 case SCALE_LOGLINEAR:
1268 case SCALE_INVLINEAR:
1269
1270 if (unit == 0.0)
1271 {
1272 message("Invalid unit!!\n");
1273 delete da;
1274 return false;
1275 }
1276
1277 virstart = floor(start / unit) * unit;
1278 virend = floor(end / unit) * unit;
1279 virend += unit;
1280 delta = DELTA_AXIS * (end - start);
1281 startval = start - delta;
1282 endval = end + delta;
1283 itercount = (int)((virend - virstart) / unit) + 2;
1284
1285 if (itercount >100)
1286 {
1287 message("Too much ticks!!\n");
1288 delete da;
1289 return false;
1290 }
1291
1292 for (int i = 0; i <= itercount; i++)
1293 {
1294 fa = virstart + (double)i * unit;
1295 if ((fa >= startval) && (fa <= endval))
1296 {
1297 tempdpoint = axis_to_world(virtual_to_axis(fa), tickstart);
1298 valpos.x = fra->wtov_x((int)tempdpoint.x);
1299 valpos.y = fra->wtov_y((int)tempdpoint.y);
1300 tempdpoint = axis_to_world(virtual_to_axis(fa), tickend);
1301 fixedpos.x = fra->wtov_x((int)tempdpoint.x);
1302 fixedpos.y = fra->wtov_y((int)tempdpoint.y);
1303
1304 pbeginpath(flag, f);
1305 da->setbuff(0);
1306 da->add(new doublepoint(fixedpos.x, fixedpos.y));
1307 da->add(new doublepoint(valpos.x, valpos.y));
1308 StyleLinePath(flag, f, da, da->getarraylength() - 1,
1309 LINESTYLESOLID, fra->scale(tickwidth),
1310 false, &axisrect, &cliprect);
1311 pstroke(flag, f);
1312 }
1313 }
1314 break;
1315 case SCALE_LOG:
1316 case SCALE_INV:
1317 virstart = pow(10.0, floor(log10(start)));
1318 virend = pow(10.0, floor(log10(end)));
1319 virend += 1.0;
1320 delta = DELTA_AXIS * (log10(end) - log10(start));
1321 startval = start / pow(10.0, delta);
1322 endval = end * pow(10.0, delta);
1323
1324 itercount = (int)(log10(virend / virstart)) + 2;
1325 for (int i = 0; i <= itercount; i++)
1326 {
1327 fa = virstart * pow(10.0, (double)i);
1328 if ((fa >= startval) && (fa <= endval))
1329 {
1330 tempdpoint = axis_to_world(virtual_to_axis(fa), tickstart);
1331 valpos.x = fra->wtov_x((int)tempdpoint.x);
1332 valpos.y = fra->wtov_y((int)tempdpoint.y);
1333 tempdpoint = axis_to_world(virtual_to_axis(fa), tickend);
1334 fixedpos.x = fra->wtov_x((int)tempdpoint.x);
1335 fixedpos.y = fra->wtov_y((int)tempdpoint.y);
1336
1337 pbeginpath(flag, f);
1338 da->setbuff(0);
1339 da->add(new doublepoint(fixedpos.x, fixedpos.y));
1340 da->add(new doublepoint(valpos.x, valpos.y));
1341 StyleLinePath(flag, f, da, da->getarraylength() - 1,
1342 LINESTYLESOLID, fra->scale(tickwidth),
1343 false, &axisrect, &cliprect);
1344 pstroke(flag, f);
1345 }
1346 }
1347 break;
1348 }
1349
1350 delete da;
1351 return true;
1352 }
1353
paintminortick(bool flag,FILE * f)1354 bool axis::paintminortick(bool flag, FILE* f)
1355 {
1356 frame *fra = (frame *)parent;
1357 double virstart, virend, startval, endval;
1358 double delta;
1359 int itercount;
1360 intpoint valpos, fixedpos;
1361 doublepoint tempdpoint;
1362 double fa;
1363 double tickstart = 0.0, tickend = 0.0;
1364 int logminortickstart, logminortickend, logminortickunit;
1365 doublepointarray *da;
1366 intrect axisrect, cliprect;
1367
1368 da = new doublepointarray;
1369
1370 // determine tickstart, tickend
1371 switch(tickparity)
1372 {
1373 case TICKPARITY_NULL:
1374 tickstart = 0.0; tickend = 0.0;
1375 break;
1376 case TICKPARITY_PLUS:
1377 tickstart = 0.0; tickend = ticklength / 2;
1378 break;
1379 case TICKPARITY_MINUS:
1380 tickstart = -ticklength / 2; tickend = 0.0;
1381 break;
1382 case TICKPARITY_BOTH:
1383 tickstart = -ticklength / 2; tickend = ticklength / 2;
1384 break;
1385 }
1386
1387 // tick style
1388 plinestyle(flag, f, fra->scale(tickwidth), baselinestyle.cap, baselinestyle.join, LINESTYLESOLID);
1389
1390 //minortick
1391 switch(scaling)
1392 {
1393 case SCALE_LINEAR:
1394 case SCALE_LOGLINEAR:
1395 case SCALE_INVLINEAR:
1396
1397 if (unit == 0.0)
1398 {
1399 message("Invalid unit!!\n");
1400 delete da;
1401 return false;
1402 }
1403
1404 if (division > 100)
1405 {
1406 message("Too much division number!!\n");
1407 delete da;
1408 return false;
1409 }
1410
1411 virstart = floor(start / unit) * unit;
1412 virend = floor(end / unit) * unit;
1413 virend += unit;
1414 delta = DELTA_AXIS * (end - start);
1415 startval = start - delta;
1416 endval = end + delta;
1417 itercount = (int)((virend - virstart) / unit * (double)division) + 2;
1418
1419
1420 for (int i = 0; i <= itercount; i++)
1421 {
1422 fa = virstart + (double)i * unit / (double)division;
1423
1424 if ((fa >= startval) && (fa <= endval))
1425 {
1426 if ((i % division) != 0) // except tick position
1427 {
1428 tempdpoint = axis_to_world(virtual_to_axis(fa), tickstart);
1429 valpos.x = fra->wtov_x((int)tempdpoint.x);
1430 valpos.y = fra->wtov_y((int)tempdpoint.y);
1431 tempdpoint = axis_to_world(virtual_to_axis(fa), tickend);
1432 fixedpos.x = fra->wtov_x((int)tempdpoint.x);
1433 fixedpos.y = fra->wtov_y((int)tempdpoint.y);
1434
1435 pbeginpath(flag, f);
1436 da->setbuff(0);
1437 da->add(new doublepoint(fixedpos.x, fixedpos.y));
1438 da->add(new doublepoint(valpos.x, valpos.y));
1439 StyleLinePath(flag, f, da, da->getarraylength() - 1,
1440 LINESTYLESOLID, fra->scale(tickwidth),
1441 false, &axisrect, &cliprect);
1442 pstroke(flag, f);
1443 }
1444 }
1445 }
1446 break;
1447 case SCALE_LOG:
1448 case SCALE_INV:
1449 switch(division)
1450 {
1451 case 1:
1452 logminortickstart = 1;
1453 logminortickend = -1;
1454 logminortickunit = 1;
1455 break;
1456 case 2:
1457 logminortickstart = 5;
1458 logminortickend = 5;
1459 logminortickunit = 1;
1460 break;
1461 case 5:
1462 logminortickstart = 2;
1463 logminortickend = 8;
1464 logminortickunit = 2;
1465 break;
1466 case 10:
1467 default:
1468 logminortickstart = 2;
1469 logminortickend = 9;
1470 logminortickunit = 1;
1471 break;
1472 }
1473
1474 virstart = pow(10.0, floor(log10(start)));
1475 virend = pow(10.0, floor(log10(end)));
1476 virend += 1.0;
1477 delta = DELTA_AXIS * (log10(end) - log10(start));
1478 startval = start / pow(10.0, delta);
1479 endval = end * pow(10.0, delta);
1480
1481 itercount = (int)(log10(virend / virstart)) + 2;
1482
1483 for (int i = 0; i <= itercount; i++)
1484 {
1485 for (int j = logminortickstart; j <= logminortickend; j = j + logminortickunit)
1486 {
1487 fa = virstart * pow(10.0, (double)i) * (double)j;
1488 if ((fa >= startval) && (fa <= endval))
1489 {
1490 tempdpoint = axis_to_world(virtual_to_axis(fa), tickstart);
1491 valpos.x = fra->wtov_x((int)tempdpoint.x);
1492 valpos.y = fra->wtov_y((int)tempdpoint.y);
1493 tempdpoint = axis_to_world(virtual_to_axis(fa), tickend);
1494 fixedpos.x = fra->wtov_x((int)tempdpoint.x);
1495 fixedpos.y = fra->wtov_y((int)tempdpoint.y);
1496
1497 pbeginpath(flag, f);
1498 da->setbuff(0);
1499 da->add(new doublepoint(fixedpos.x, fixedpos.y));
1500 da->add(new doublepoint(valpos.x, valpos.y));
1501 StyleLinePath(flag, f, da, da->getarraylength() - 1,
1502 LINESTYLESOLID, fra->scale(tickwidth),
1503 false, &axisrect, &cliprect);
1504 pstroke(flag, f);
1505 }
1506 }
1507 }
1508 break;
1509 }
1510
1511 delete da;
1512 return true;
1513 }
1514
1515
NormalizeTickLabel(std::string * OutputText,std::string * NormFactor,double InitValue,double EndValue,double UnitValue,double Value,bool IsLinearScale,int Formula,bool IsAddPlus,bool AutoNumPrecision,int IntPrecision,int DecimalPrecision)1516 void NormalizeTickLabel(std::string *OutputText, std::string *NormFactor
1517 , double InitValue, double EndValue, double UnitValue, double Value
1518 , bool IsLinearScale, int Formula, bool IsAddPlus
1519 , bool AutoNumPrecision, int IntPrecision, int DecimalPrecision)
1520 {
1521
1522 bool KikakuFlag = false;
1523 double fkikaku = 1.0, fkikakumin, fkikakumax;
1524 char stemp[30];
1525 char stemp1[100];
1526 double LogValue;
1527 int shousuu, shisuu;
1528 double kasuu;
1529
1530
1531 *OutputText = std::string("");
1532
1533 if(IsLinearScale)
1534 {
1535 LogValue = floor(Value / UnitValue - .001) + 1;
1536
1537 //$B5,3J2=0x;R(B
1538 if (fabs(InitValue) <= fabs(EndValue))
1539 {
1540 fkikakumax = fabs(EndValue);
1541 fkikakumin = fabs(InitValue);
1542 }
1543 else
1544 {
1545 fkikakumax = fabs(InitValue);
1546 fkikakumin = fabs(EndValue);
1547 }
1548
1549 sprintf(stemp,"%g", fkikakumax);
1550 if (strchr(stemp,'e') != 0)
1551 {
1552 KikakuFlag = true;
1553 fkikaku = fkikakumax;
1554 }
1555 else
1556 KikakuFlag = false;
1557
1558 //normalize factor
1559 if (KikakuFlag)
1560 fkikaku = pow(10.0, floor(log10(fabs(fkikaku))));
1561 else
1562 fkikaku=1.0;
1563
1564 //$B>.?tE@0J2<$N7W;;(B
1565 sprintf(stemp,"%.15g", UnitValue / fkikaku);
1566 if (strchr(stemp, '.') != 0)
1567 shousuu = strlen(strchr(stemp, '.')) - 1;
1568 else
1569 shousuu = 0;
1570
1571 if (!AutoNumPrecision)
1572 {
1573 if (DecimalPrecision == -1)
1574 {
1575 if (IsAddPlus)
1576 sprintf(stemp,"%%+.%dlf",shousuu);
1577 else
1578 sprintf(stemp,"%%.%dlf",shousuu);
1579 }
1580 else
1581 {
1582 if (IsAddPlus)
1583 sprintf(stemp,"%%+%d.%dlf",IntPrecision, DecimalPrecision);
1584 else
1585 sprintf(stemp,"%%%d.%dlf",IntPrecision, DecimalPrecision);
1586 }
1587 sprintf(stemp1, stemp, LogValue * UnitValue / fkikaku);
1588
1589 }
1590 else
1591 {
1592 if (IsAddPlus)
1593 sprintf(stemp1, "%+.15g", LogValue * UnitValue / fkikaku);
1594 else
1595 sprintf(stemp1, "%.15g", LogValue * UnitValue / fkikaku);
1596 }
1597 *OutputText = std::string(stemp1);
1598
1599 //$B5,3J2=0x;R$NI=<((B
1600 if (KikakuFlag)
1601 {
1602 sprintf(stemp1, "(#G\\264#F10^%d|)", (int)floor(log10(fkikaku) + .5));
1603 *NormFactor = std::string(stemp1);
1604 }
1605 else
1606 {
1607 *NormFactor = std::string("");
1608 }
1609 }
1610 else
1611 {
1612
1613 LogValue = floor(log10(Value) / log10(UnitValue) - .001) + 1;
1614
1615 if(Formula == 1) //decimal
1616 {
1617 if (IsAddPlus)
1618 sprintf(stemp1, "%+.15g",pow(10.0, LogValue));
1619 else
1620 sprintf(stemp1, "%.15g", pow(10.0, LogValue));
1621
1622 }
1623 else if (Formula == 2) //exp
1624 {
1625 shisuu = (int)LogValue;
1626 kasuu = (InitValue * pow(UnitValue, LogValue)) / pow(10.0, (double)shisuu);
1627
1628 if (IsAddPlus)
1629 sprintf(stemp1, "10^%+d", shisuu);
1630 else
1631 sprintf(stemp1, "10^%d", shisuu);
1632 }
1633 *OutputText = std::string(stemp1);
1634 }
1635 }
1636
1637
drawlabel(bool flag,FILE * f)1638 bool axis::drawlabel(bool flag, FILE* f)
1639 {
1640 frame *fra = (frame *)parent;
1641 double virstart, virend, startval, endval;
1642 double delta;
1643 int itercount;
1644 intpoint valpos, fixedpos;
1645 doublepoint tempdpoint;
1646 double fa;
1647 double tickstart = 0.0, tickend = 0.0;
1648 intrect axisrect, cliprect;
1649 parts* t;
1650 intrect ir;
1651 int h, w;
1652 std::string normfactor;
1653 int skipfactor, labelcountfromzero;
1654 int lateralposition = 0;
1655 double cprange = .001;
1656 double cp = 0.0;
1657
1658 if (display == false)
1659 return true;
1660
1661 //label is null
1662 if (format == LABEL_FORMAT_NULL)
1663 return true;
1664
1665 t = new parts;
1666 t->fo = fo;
1667 t->fo.angle = fo.angle + angle;
1668 t->fontcolor = fontcolor;
1669 t->parent = parent;
1670
1671 // set ascend
1672 h = (int)((double)t->getascend(&t->fo, false));
1673
1674 // select textcolor
1675 psetforecolor(flag, f, fontcolor.red, fontcolor.green, fontcolor.blue);
1676
1677
1678 // determine tickstart, tickend
1679 switch(tickparity)
1680 {
1681 case TICKPARITY_NULL:
1682 tickstart = 0.0; tickend = 0.0;
1683 break;
1684 case TICKPARITY_PLUS:
1685 tickstart = 0.0; tickend = ticklength;
1686 break;
1687 case TICKPARITY_MINUS:
1688 tickstart = -ticklength; tickend = 0.0;
1689 break;
1690 case TICKPARITY_BOTH:
1691 tickstart = -ticklength; tickend = ticklength;
1692 break;
1693 }
1694
1695 // tick style
1696 plinestyle(flag, f, fra->scale(tickwidth), baselinestyle.cap, baselinestyle.join, LINESTYLESOLID);
1697
1698
1699 normfactor = std::string("");
1700 //majortick
1701 switch(scaling)
1702 {
1703 case SCALE_LINEAR:
1704 case SCALE_LOGLINEAR:
1705 case SCALE_INVLINEAR:
1706
1707 if (unit == 0.0)
1708 {
1709 message("Invalid unit!!\n");
1710 delete t;
1711 return false;
1712 }
1713
1714 virstart = floor(start / unit) * unit;
1715 virend = floor(end / unit) * unit;
1716 virend += unit;
1717 delta = DELTA_AXIS * (end - start);
1718 startval = start - delta;
1719 endval = end + delta;
1720 itercount = (int)((virend - virstart) / unit) + 2;
1721
1722 if (itercount >100)
1723 {
1724 message("Too much ticks!!\n");
1725 delete t;
1726 return false;
1727 }
1728
1729 // set skip factor
1730 if (skip == 0)
1731 {
1732 if (fabs(end - start) / unit > 30.0)
1733 skipfactor = 10;
1734 else if (fabs(end - start) / unit >= 11.0)
1735 skipfactor = 5;
1736 else
1737 skipfactor = 1;
1738 }
1739 else
1740 skipfactor = skip;
1741
1742 // crosspoint
1743 if (autocrosspoint)
1744 cp = start;
1745 else
1746 cp = crosspoint;
1747
1748 for (int i = 0; i <= itercount; i++)
1749 {
1750 fa = virstart + (double)i * unit;
1751 if ((fa >= startval) && (fa <= endval))
1752 {
1753 labelcountfromzero = (int)(fabs(floor(fa / unit)) + .4);
1754 if (labelcountfromzero % skipfactor == 0)
1755 {
1756 NormalizeTickLabel(t->text, &normfactor, start, end, unit, fa,
1757 true, format, addplus
1758 ,autoprecision, intprecision, decimalprecision);
1759
1760 w = (int)((double)t->gettextwidth());
1761 ir.left = 0;
1762 ir.right = w;
1763 ir.top = -h;
1764 ir.bottom = t->fo.size - h;
1765 BBboxrotatedrect(&ir, fo.angle);
1766
1767 if (cp - cprange * unit < fa &&
1768 fa < cp + cprange * unit)
1769 {
1770 switch(crosspointparity)
1771 {
1772 case CROSSPOINTPARITY_CENTER:
1773 lateralposition = (int)virtual_to_axis(fa) - (ir.left + ir.right) / 2;
1774 break;
1775 case CROSSPOINTPARITY_MINUS:
1776 lateralposition = (int)virtual_to_axis(fa) - ir.right
1777 - crosspointoffset;
1778 break;
1779 case CROSSPOINTPARITY_PLUS:
1780 lateralposition = (int)virtual_to_axis(fa) - ir.left
1781 + crosspointoffset;
1782 break;
1783 }
1784 }
1785 else
1786 lateralposition = (int)virtual_to_axis(fa) - (ir.left + ir.right) / 2;
1787
1788 if (labelparity == 1)
1789 tempdpoint = axis_to_world(lateralposition,
1790 tickend - ir.top + offset);
1791 else
1792 tempdpoint = axis_to_world(lateralposition,
1793 tickstart - ir.bottom - offset);
1794
1795 t->p1.x = (int)tempdpoint.x;
1796 t->p1.y = (int)tempdpoint.y;
1797
1798 if (cp - cprange * unit < fa && fa < cp + cprange * unit)
1799 {
1800 if(crosspointparity != CROSSPOINTPARITY_NULL)
1801 t->drawtext(flag, f, 0, 0);
1802 }
1803 else
1804 t->drawtext(flag, f, 0, 0);
1805 }
1806 }
1807 }
1808 break;
1809 case SCALE_LOG:
1810 case SCALE_INV:
1811 virstart = pow(10.0, floor(log10(start)));
1812 virend = pow(10.0, floor(log10(end)));
1813 virend += 1.0;
1814 delta = DELTA_AXIS * (log10(end) - log10(start));
1815 startval = start / pow(10.0, delta);
1816 endval = end * pow(10.0, delta);
1817
1818 itercount = (int)(log10(virend / virstart)) + 2;
1819
1820 // set skip factor
1821 if (skip == 0)
1822 {
1823 if (log10(end) - log10(start) >= 60.0)
1824 skipfactor = 10;
1825 else if (log10(end) - log10(start) >= 18.0)
1826 skipfactor = 5;
1827 else if (log10(end) - log10(start) >= 12.0)
1828 skipfactor = 3;
1829 else if (log10(end) - log10(start) >= 7.0)
1830 skipfactor = 2;
1831 else
1832 skipfactor = 1;
1833 }
1834 else
1835 skipfactor = skip;
1836
1837 for (int i = 0; i <= itercount; i++)
1838 {
1839 fa = virstart * pow(10.0, (double)i);
1840 if ((fa >= startval) && (fa <= endval))
1841 {
1842 labelcountfromzero = (int)floor((log10(fa)+.4));
1843 if (labelcountfromzero % skipfactor == 0)
1844 {
1845 NormalizeTickLabel(t->text, &normfactor, start, end, 10, fa,
1846 false, format, addplus
1847 ,autoprecision, intprecision, decimalprecision);
1848
1849 w = (int)((double)t->gettextwidth());
1850 ir.left = 0;
1851 ir.right = w;
1852
1853 if (format == LABEL_FORMAT_EXP)
1854 {
1855 ir.top = -(int)((double)h * 1.2);
1856 ir.bottom = t->fo.size - (int)((double)h * 1.2);
1857 }
1858 else
1859 {
1860 ir.top = -h;
1861 ir.bottom = t->fo.size - h;
1862 }
1863 BBboxrotatedrect(&ir, fo.angle);
1864
1865 if (cp - cprange * unit < fa &&
1866 fa < cp + cprange * unit)
1867 {
1868 switch(crosspointparity)
1869 {
1870 case CROSSPOINTPARITY_CENTER:
1871 lateralposition = (int)virtual_to_axis(fa) - (ir.left + ir.right) / 2;
1872 break;
1873 case CROSSPOINTPARITY_MINUS:
1874 lateralposition = (int)virtual_to_axis(fa) - ir.right
1875 - crosspointoffset;
1876 break;
1877 case CROSSPOINTPARITY_PLUS:
1878 lateralposition = (int)virtual_to_axis(fa) - ir.left
1879 + crosspointoffset;
1880 break;
1881 }
1882 }
1883 else
1884 lateralposition = (int)virtual_to_axis(fa) - (ir.left + ir.right) / 2;
1885
1886 if (labelparity == 1)
1887 tempdpoint = axis_to_world(lateralposition,
1888 tickend - ir.top + offset);
1889 else
1890 tempdpoint = axis_to_world(lateralposition,
1891 tickstart - ir.bottom - offset);
1892
1893 t->p1.x = (int)tempdpoint.x;
1894 t->p1.y = (int)tempdpoint.y;
1895
1896 if (cp - cprange * unit < fa && fa < cp + cprange * unit)
1897 {
1898 if(crosspointparity != CROSSPOINTPARITY_NULL)
1899 t->drawtext(flag, f, 0, 0);
1900 }
1901 else
1902 t->drawtext(flag, f, 0, 0);
1903 }
1904 }
1905 }
1906 break;
1907 }
1908
1909 // normalize factor
1910 if (normfactor != std::string(""))
1911 {
1912 *t->text = normfactor;
1913 w = (int)((double)t->gettextwidth());
1914 ir.left = 0;
1915 ir.right = w;
1916 ir.top = -h;
1917 ir.bottom = t->fo.size - h;
1918
1919 BBboxrotatedrect(&ir, fo.angle);
1920
1921 if (labelparity == 1)
1922 tempdpoint = axis_to_world(length - (ir.right - ir.left),
1923 tickend - ir.top + t->fo.size + offset);
1924 else
1925 tempdpoint = axis_to_world(length - (ir.right - ir.left),
1926 tickstart - ir.bottom - t->fo.size - offset);
1927
1928
1929 t->p1.x = (int)tempdpoint.x;
1930 t->p1.y = (int)tempdpoint.y;
1931 t->drawtext(flag, f, 0, 0);
1932 }
1933
1934
1935 delete t;
1936 return true;
1937
1938 }
1939
readaxis(FILE * fp)1940 bool axis::readaxis(FILE *fp)
1941 {
1942 char stemp[10000];
1943 std::string str;
1944 char *p;
1945 int readversion;
1946
1947
1948 // version
1949 if (getnextline(stemp, sizeof(stemp), fp))
1950 {
1951 if (nextitem(stemp, &str) != 0)
1952 readversion = atoi(str.c_str());
1953 else
1954 return false;
1955 }
1956 else
1957 return false;
1958
1959 // id
1960 if (getnextline(stemp, sizeof(stemp), fp))
1961 {
1962 if (nextitem(stemp, &str) != 0)
1963 {
1964 if (readversion >= 4)
1965 id = atoi(str.c_str());
1966 }
1967 else
1968 return false;
1969 }
1970 else
1971 return false;
1972
1973 // axistype, display, commonset, scaling, invertscale
1974 if (getnextline(stemp, sizeof(stemp), fp))
1975 {
1976 p = stemp;
1977 // axistype
1978 p = nextitem(p, &str);
1979 if (p != 0)
1980 axistype = atoi(str.c_str());
1981 else
1982 return false;
1983 // display
1984 p = nextitem(p, &str);
1985 if (p != 0)
1986 display = atoi(str.c_str());
1987 else
1988 return false;
1989 // commonset
1990 p = nextitem(p, &str);
1991 if (p != 0)
1992 commonset = atoi(str.c_str());
1993 else
1994 return false;
1995 // scaling
1996 p = nextitem(p, &str);
1997 if (p != 0)
1998 scaling = atoi(str.c_str());
1999 else
2000 return false;
2001 // invertscale
2002 p = nextitem(p, &str);
2003 if (p != 0)
2004 invertscale = atoi(str.c_str());
2005 else
2006 return false;
2007 }
2008 else
2009 return false;
2010
2011
2012 // origin.x, origin.y, length, angl
2013 if (getnextline(stemp, sizeof(stemp), fp))
2014 {
2015 p = stemp;
2016 // origin.x
2017 p = nextitem(p, &str);
2018 if (p != 0)
2019 origin.x = atoi(str.c_str());
2020 else
2021 return false;
2022 // origin.y
2023 p = nextitem(p, &str);
2024 if (p != 0)
2025 origin.y = atoi(str.c_str());
2026 else
2027 return false;
2028 // length
2029 p = nextitem(p, &str);
2030 if (p != 0)
2031 length = atoi(str.c_str());
2032 else
2033 return false;
2034 // angle
2035 p = nextitem(p, &str);
2036 if (p != 0)
2037 angle = atoi(str.c_str());
2038 else
2039 return false;
2040 }
2041 else
2042 return false;
2043
2044 // basecolor
2045 if (getnextline(stemp, sizeof(stemp), fp))
2046 {
2047 p = stemp;
2048 // basecolor.red
2049 p = nextitem(p, &str);
2050 if (p != 0)
2051 basecolor.red = atoi(str.c_str());
2052 else
2053 return false;
2054 // basecolor.green
2055 p = nextitem(p, &str);
2056 if (p != 0)
2057 basecolor.green = atoi(str.c_str());
2058 else
2059 return false;
2060 // basecolor.blue
2061 p = nextitem(p, &str);
2062 if (p != 0)
2063 basecolor.blue = atoi(str.c_str());
2064 else
2065 return false;
2066 }
2067 else
2068 return false;
2069
2070 // baselinestyle
2071 if (getnextline(stemp, sizeof(stemp), fp))
2072 {
2073 p = stemp;
2074 // framelinestyle.width
2075 p = nextitem(p, &str);
2076 if (p != 0)
2077 baselinestyle.width = atoi(str.c_str());
2078 else
2079 return false;
2080 // baselinestyle.cap
2081 p = nextitem(p, &str);
2082 if (p != 0)
2083 baselinestyle.cap = atoi(str.c_str());
2084 else
2085 return false;
2086 // baselinestyle.join
2087 p = nextitem(p, &str);
2088 if (p != 0)
2089 baselinestyle.join = atoi(str.c_str());
2090 else
2091 return false;
2092 // baselinestyle.style
2093 p = nextitem(p, &str);
2094 if (p != 0)
2095 baselinestyle.style = atoi(str.c_str());
2096 else
2097 return false;
2098 }
2099 else
2100 return false;
2101
2102 // tickarea
2103 if (getnextline(stemp, sizeof(stemp), fp))
2104 {
2105 p = stemp;
2106 // tickarea_start
2107 p = nextitem(p, &str);
2108 if (p != 0)
2109 tickarea_start = atof(str.c_str());
2110 else
2111 return false;
2112 // tickarea_end
2113 p = nextitem(p, &str);
2114 if (p != 0)
2115 tickarea_end = atof(str.c_str());
2116 else
2117 return false;
2118 }
2119 else
2120 return false;
2121
2122 // start, end, unit, crosspoint, autocrosspoint
2123 if (getnextline(stemp, sizeof(stemp), fp))
2124 {
2125 p = stemp;
2126 // start
2127 p = nextitem(p, &str);
2128 if (p != 0)
2129 start = atof(str.c_str());
2130 else
2131 return false;
2132 // end
2133 p = nextitem(p, &str);
2134 if (p != 0)
2135 end = atof(str.c_str());
2136 else
2137 return false;
2138 // unit
2139 p = nextitem(p, &str);
2140 if (p != 0)
2141 unit = atof(str.c_str());
2142 else
2143 return false;
2144 // crosspoint
2145 p = nextitem(p, &str);
2146 if (p != 0)
2147 crosspoint = atof(str.c_str());
2148 else
2149 return false;
2150 // autocrosspoint
2151 p = nextitem(p, &str);
2152 if (p != 0)
2153 autocrosspoint = atoi(str.c_str());
2154 else
2155 return false;
2156 }
2157 else
2158 return false;
2159
2160 // tickparity, tickwidth, ticklength, divisio
2161 if (getnextline(stemp, sizeof(stemp), fp))
2162 {
2163 p = stemp;
2164 // tickparity
2165 p = nextitem(p, &str);
2166 if (p != 0)
2167 tickparity = atoi(str.c_str());
2168 else
2169 return false;
2170 // tickwidth
2171 p = nextitem(p, &str);
2172 if (p != 0)
2173 tickwidth = atoi(str.c_str());
2174 else
2175 return false;
2176 // ticklength
2177 p = nextitem(p, &str);
2178 if (p != 0)
2179 ticklength = atoi(str.c_str());
2180 else
2181 return false;
2182 // division
2183 p = nextitem(p, &str);
2184 if (p != 0)
2185 division = atoi(str.c_str());
2186 else
2187 return false;
2188 }
2189 else
2190 return false;
2191
2192 // majorticklinecolor
2193 if (getnextline(stemp, sizeof(stemp), fp))
2194 {
2195 p = stemp;
2196 // majorticklinecolor.red
2197 p = nextitem(p, &str);
2198 if (p != 0)
2199 majorticklinecolor.red = atoi(str.c_str());
2200 else
2201 return false;
2202 // majorticklinecolor.green
2203 p = nextitem(p, &str);
2204 if (p != 0)
2205 majorticklinecolor.green = atoi(str.c_str());
2206 else
2207 return false;
2208 // majorticklinecolor.blue
2209 p = nextitem(p, &str);
2210 if (p != 0)
2211 majorticklinecolor.blue = atoi(str.c_str());
2212 else
2213 return false;
2214 }
2215 else
2216 return false;
2217
2218 // minorticklinecolor
2219 if (getnextline(stemp, sizeof(stemp), fp))
2220 {
2221 p = stemp;
2222 // minorticklinecolor.red
2223 p = nextitem(p, &str);
2224 if (p != 0)
2225 minorticklinecolor.red = atoi(str.c_str());
2226 else
2227 return false;
2228 // minorticklinecolor.green
2229 p = nextitem(p, &str);
2230 if (p != 0)
2231 minorticklinecolor.green = atoi(str.c_str());
2232 else
2233 return false;
2234 // minorticklinecolor.blue
2235 p = nextitem(p, &str);
2236 if (p != 0)
2237 minorticklinecolor.blue = atoi(str.c_str());
2238 else
2239 return false;
2240 }
2241 else
2242 return false;
2243
2244 // majorticklinestyle
2245 if (getnextline(stemp, sizeof(stemp), fp))
2246 {
2247 p = stemp;
2248 // width
2249 p = nextitem(p, &str);
2250 if (p != 0)
2251 majorticklinestyle.width = atoi(str.c_str());
2252 else
2253 return false;
2254 // cap
2255 p = nextitem(p, &str);
2256 if (p != 0)
2257 majorticklinestyle.cap = atoi(str.c_str());
2258 else
2259 return false;
2260 // join
2261 p = nextitem(p, &str);
2262 if (p != 0)
2263 majorticklinestyle.join = atoi(str.c_str());
2264 else
2265 return false;
2266 // style
2267 p = nextitem(p, &str);
2268 if (p != 0)
2269 majorticklinestyle.style = atoi(str.c_str());
2270 else
2271 return false;
2272 }
2273 else
2274 return false;
2275
2276 // minorticklinestyle
2277 if (getnextline(stemp, sizeof(stemp), fp))
2278 {
2279 p = stemp;
2280 // width
2281 p = nextitem(p, &str);
2282 if (p != 0)
2283 minorticklinestyle.width = atoi(str.c_str());
2284 else
2285 return false;
2286 // cap
2287 p = nextitem(p, &str);
2288 if (p != 0)
2289 minorticklinestyle.cap = atoi(str.c_str());
2290 else
2291 return false;
2292 // join
2293 p = nextitem(p, &str);
2294 if (p != 0)
2295 minorticklinestyle.join = atoi(str.c_str());
2296 else
2297 return false;
2298 // style
2299 p = nextitem(p, &str);
2300 if (p != 0)
2301 minorticklinestyle.style = atoi(str.c_str());
2302 else
2303 return false;
2304 }
2305 else
2306 return false;
2307
2308
2309 // label
2310 // fo
2311 if (getnextline(stemp, sizeof(stemp), fp))
2312 {
2313 p = stemp;
2314 // face
2315 p = nextitem(p, &str);
2316 if (p != 0)
2317 fo.face = atoi(str.c_str());
2318 else
2319 return false;
2320
2321 if (readversion >= 2)
2322 {
2323 // jpface
2324 p = nextitem(p, &str);
2325 if (p != 0)
2326 fo.jpface = atoi(str.c_str());
2327 else
2328 return false;
2329 }
2330
2331 // size
2332 p = nextitem(p, &str);
2333 if (p != 0)
2334 fo.size = atoi(str.c_str());
2335 else
2336 return false;
2337 // angle
2338 p = nextitem(p, &str);
2339 if (p != 0)
2340 fo.angle = atof(str.c_str());
2341 else
2342 return false;
2343 }
2344 else
2345 return false;
2346
2347 // fontcolor
2348 if (getnextline(stemp, sizeof(stemp), fp))
2349 {
2350 p = stemp;
2351 // red
2352 p = nextitem(p, &str);
2353 if (p != 0)
2354 fontcolor.red = atoi(str.c_str());
2355 else
2356 return false;
2357 // green
2358 p = nextitem(p, &str);
2359 if (p != 0)
2360 fontcolor.green = atoi(str.c_str());
2361 else
2362 return false;
2363 // blue
2364 p = nextitem(p, &str);
2365 if (p != 0)
2366 fontcolor.blue = atoi(str.c_str());
2367 else
2368 return false;
2369 }
2370 else
2371 return false;
2372
2373 if (getnextline(stemp, sizeof(stemp), fp))
2374 {
2375 p = stemp;
2376 // format
2377 p = nextitem(p, &str);
2378 if (p != 0)
2379 format = atoi(str.c_str());
2380 else
2381 return false;
2382 // addplus
2383 p = nextitem(p, &str);
2384 if (p != 0)
2385 addplus = atoi(str.c_str());
2386 else
2387 return false;
2388 // offset
2389 p = nextitem(p, &str);
2390 if (p != 0)
2391 offset = atoi(str.c_str());
2392 else
2393 return false;
2394 // skip
2395 p = nextitem(p, &str);
2396 if (p != 0)
2397 skip = atoi(str.c_str());
2398 else
2399 return false;
2400 // autoprecision
2401 p = nextitem(p, &str);
2402 if (p != 0)
2403 autoprecision = atoi(str.c_str());
2404 else
2405 return false;
2406 // intprecision
2407 p = nextitem(p, &str);
2408 if (p != 0)
2409 intprecision = atoi(str.c_str());
2410 else
2411 return false;
2412 // decimalprecision
2413 p = nextitem(p, &str);
2414 if (p != 0)
2415 decimalprecision = atoi(str.c_str());
2416 else
2417 return false;
2418 // labelparity
2419 p = nextitem(p, &str);
2420 if (p != 0)
2421 labelparity = atoi(str.c_str());
2422 else
2423 return false;
2424 // crosspointparity
2425 if (readversion >= 4)
2426 {
2427 p = nextitem(p, &str);
2428 if (p != 0)
2429 crosspointparity = atoi(str.c_str());
2430 else
2431 return false;
2432 }
2433 else
2434 crosspointparity = CROSSPOINTPARITY_CENTER;
2435 // crosspointoffset
2436 p = nextitem(p, &str);
2437 if (p != 0)
2438 crosspointoffset = atoi(str.c_str());
2439 else
2440 return false;
2441 }
2442 else
2443 return false;
2444
2445 return true;
2446 }
2447
2448
writeaxis(FILE * fp)2449 bool axis::writeaxis(FILE *fp)
2450 {
2451 fprintf(fp, "[axis]\n");
2452
2453 // base
2454 fprintf(fp, "%d\n", version);
2455 fprintf(fp, "%d\n", id);
2456 fprintf(fp, "%d %d %d %d %d\n", axistype, display, commonset, scaling, invertscale);
2457 fprintf(fp, "%d %d %d %f\n", origin.x, origin.y, length, angle);
2458 fprintf(fp, "%u %u %u\n", basecolor.red, basecolor.green, basecolor.blue);
2459 fprintf(fp, "%d %d %d %d\n", baselinestyle.width, baselinestyle.cap, baselinestyle.join, baselinestyle.style);
2460 fprintf(fp, "%.15g %.15g\n", tickarea_start, tickarea_end);
2461
2462 // range
2463 fprintf(fp, "%.15g %.15g %.15g %.15g %d\n", start, end, unit, crosspoint, autocrosspoint);
2464
2465 //tick, subtick
2466 fprintf(fp, "%d %d %d %d\n", tickparity, tickwidth, ticklength, division);
2467 fprintf(fp, "%u %u %u\n", majorticklinecolor.red, majorticklinecolor.green, majorticklinecolor.blue);
2468 fprintf(fp, "%u %u %u\n", minorticklinecolor.red, minorticklinecolor.green, minorticklinecolor.blue);
2469 fprintf(fp, "%d %d %d %d\n", majorticklinestyle.width, majorticklinestyle.cap, majorticklinestyle.join, majorticklinestyle.style);
2470 fprintf(fp, "%d %d %d %d\n", minorticklinestyle.width, minorticklinestyle.cap, minorticklinestyle.join, minorticklinestyle.style);
2471
2472 //label
2473 fprintf(fp, "%d %d %d %.15g\n", fo.face, fo.jpface, fo.size, fo.angle);
2474 fprintf(fp, "%u %u %u\n", fontcolor.red, fontcolor.green, fontcolor.blue);
2475 fprintf(fp, "%d %d %d %d %d %d %d %d %d %d\n", format, addplus, offset, skip, autoprecision,
2476 intprecision, decimalprecision, labelparity, crosspointparity, crosspointoffset);
2477
2478 return true;
2479 }
2480
2481
2482
2483
2484
2485
2486
2487
2488