- Timestamp:
- 02/20/14 21:40:16 (11 years ago)
- Location:
- trunk/src
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/Plotter2.cpp
r2895 r2896 2 2 3 3 namespace asap { 4 5 Plotter2AnnotationInfo::Plotter2AnnotationInfo() { 6 text = ""; 7 posx = 0.0; 8 posy = 0.0; 9 angle = 0.0; 10 fjust = 0.0; 11 size = 1.0; 12 color = 1; // black 13 bgcolor = -1; // transparent 14 } 15 16 Plotter2AnnotationInfo::~Plotter2AnnotationInfo() { 17 } 18 19 Plotter2ArrowInfo::Plotter2ArrowInfo() { 20 xhead = 1.0; 21 xtail = 0.0; 22 yhead = 1.0; 23 ytail = 0.0; 24 color = 1; // black 25 width = 1; 26 lineStyle = 1; // solid line 27 headSize = 1.0; 28 headFillStyle = 1; // solid 29 headAngle = 45.0; 30 headVent = 0.3; 31 } 32 33 Plotter2ArrowInfo::~Plotter2ArrowInfo() { 34 } 4 35 5 36 Plotter2RectInfo::Plotter2RectInfo() { … … 71 102 vData.clear(); 72 103 vRect.clear(); 104 vArro.clear(); 105 vAnno.clear(); 73 106 74 107 labelXString = ""; … … 104 137 Plotter2ViewportInfo::~Plotter2ViewportInfo() { 105 138 vData.clear(); 139 vRect.clear(); 140 vArro.clear(); 141 vAnno.clear(); 106 142 } 107 143 … … 353 389 354 390 void Plotter2::setViewport(const float xmin, const float xmax, const float ymin, const float ymax, const int id) { 391 if (id >= (int)vInfo.size()) { 392 return; 393 } 355 394 Plotter2ViewportInfo* vi = &vInfo[id]; 356 395 … … 365 404 void Plotter2::showViewport(const int inVpid) { 366 405 int vpid = inVpid; 406 if (vpid >= (int)vInfo.size()) { 407 return; 408 } 367 409 if (vpid < 0) { 368 410 vpid = vInfo.size() - 1; … … 378 420 void Plotter2::hideViewport(const int inVpid) { 379 421 int vpid = inVpid; 422 if (vpid >= (int)vInfo.size()) { 423 return; 424 } 380 425 if (vpid < 0) { 381 426 vpid = vInfo.size() - 1; … … 536 581 void Plotter2::setRangeX(const float xmin, const float xmax, const int inVpid) { 537 582 int vpid = inVpid; 583 if (vpid >= (int)vInfo.size()) { 584 return; 585 } 538 586 if (vpid < 0) { 539 587 vpid = vInfo.size() - 1; … … 553 601 void Plotter2::setRangeY(const float ymin, const float ymax, const int inVpid) { 554 602 int vpid = inVpid; 603 if (vpid >= (int)vInfo.size()) { 604 return; 605 } 555 606 if (vpid < 0) { 556 607 vpid = vInfo.size() - 1; … … 570 621 std::vector<float> Plotter2::getRangeX(const int inVpid) { 571 622 int vpid = inVpid; 623 if (vpid >= (int)vInfo.size()) { 624 exit(0); 625 } 572 626 if (vpid < 0) { 573 627 vpid = vInfo.size() - 1; … … 582 636 std::vector<float> Plotter2::getRangeY(const int inVpid) { 583 637 int vpid = inVpid; 638 if (vpid >= (int)vInfo.size()) { 639 exit(0); 640 } 584 641 if (vpid < 0) { 585 642 vpid = vInfo.size() - 1; … … 599 656 void Plotter2::setAutoRangeX(const int inVpid) { 600 657 int vpid = inVpid; 658 if (vpid >= (int)vInfo.size()) { 659 exit(0); 660 } 601 661 if (vpid < 0) { 602 662 vpid = vInfo.size() - 1; … … 614 674 void Plotter2::setAutoRangeY(const int inVpid) { 615 675 int vpid = inVpid; 676 if (vpid >= (int)vInfo.size()) { 677 exit(0); 678 } 616 679 if (vpid < 0) { 617 680 vpid = vInfo.size() - 1; … … 629 692 void Plotter2::setFontSizeDef(const float size, const int inVpid) { 630 693 int vpid = inVpid; 694 if (vpid >= (int)vInfo.size()) { 695 exit(0); 696 } 631 697 if (vpid < 0) { 632 698 vpid = vInfo.size() - 1; … … 644 710 void Plotter2::setTicksX(const float interval, const int num, const int inVpid) { 645 711 int vpid = inVpid; 712 if (vpid >= (int)vInfo.size()) { 713 exit(0); 714 } 646 715 if (vpid < 0) { 647 716 vpid = vInfo.size() - 1; … … 661 730 void Plotter2::setTicksY(const float interval, const int num, const int inVpid) { 662 731 int vpid = inVpid; 732 if (vpid >= (int)vInfo.size()) { 733 exit(0); 734 } 663 735 if (vpid < 0) { 664 736 vpid = vInfo.size() - 1; … … 683 755 void Plotter2::setAutoTicksX(const int inVpid) { 684 756 int vpid = inVpid; 757 if (vpid >= (int)vInfo.size()) { 758 exit(0); 759 } 685 760 if (vpid < 0) { 686 761 vpid = vInfo.size() - 1; … … 698 773 void Plotter2::setAutoTicksY(const int inVpid) { 699 774 int vpid = inVpid; 775 if (vpid >= (int)vInfo.size()) { 776 exit(0); 777 } 700 778 if (vpid < 0) { 701 779 vpid = vInfo.size() - 1; … … 713 791 void Plotter2::setNumIntervalX(const float interval, const int inVpid) { 714 792 int vpid = inVpid; 793 if (vpid >= (int)vInfo.size()) { 794 exit(0); 795 } 715 796 if (vpid < 0) { 716 797 vpid = vInfo.size() - 1; … … 728 809 void Plotter2::setNumIntervalY(const float interval, const int inVpid) { 729 810 int vpid = inVpid; 811 if (vpid >= (int)vInfo.size()) { 812 exit(0); 813 } 730 814 if (vpid < 0) { 731 815 vpid = vInfo.size() - 1; … … 743 827 void Plotter2::setNumLocationX(const std::string& side, const int inVpid) { 744 828 int vpid = inVpid; 829 if (vpid >= (int)vInfo.size()) { 830 exit(0); 831 } 745 832 if (vpid < 0) { 746 833 vpid = vInfo.size() - 1; … … 758 845 void Plotter2::setNumLocationY(const std::string& side, const int inVpid) { 759 846 int vpid = inVpid; 847 if (vpid >= (int)vInfo.size()) { 848 exit(0); 849 } 760 850 if (vpid < 0) { 761 851 vpid = vInfo.size() - 1; … … 773 863 void Plotter2::setData(const std::vector<float>& xdata, const std::vector<float>& ydata, const int inVpid, const int inDataid) { 774 864 int vpid = inVpid; 865 if (vpid >= (int)vInfo.size()) { 866 exit(0); 867 } 775 868 if (vpid < 0) { 776 869 vpid = vInfo.size() - 1; … … 789 882 vi->vData.push_back(di); 790 883 dataid = vi->vData.size() - 1; 884 } else if (dataid >= (int)vi->vData.size()) { 885 exit(0); 791 886 } 792 887 … … 796 891 void Plotter2::setLine(const int color, const int width, const int style, const int inVpid, const int inDataid) { 797 892 int vpid = inVpid; 798 if (vpid < 0) { 799 vpid = vInfo.size() - 1; 800 } 801 if (vpid < 0) { 802 Plotter2ViewportInfo vi; 803 vInfo.push_back(vi); 804 vpid = 0; 805 } 893 if (vpid >= (int)vInfo.size()) { 894 exit(0); 895 } 896 if (vpid < 0) { 897 vpid = vInfo.size() - 1; 898 } 899 if (vpid < 0) { 900 Plotter2ViewportInfo vi; 901 vInfo.push_back(vi); 902 vpid = 0; 903 } 904 905 Plotter2ViewportInfo* vi = &vInfo[vpid]; 806 906 807 907 int dataid = inDataid; 808 908 if (dataid < 0) { 809 dataid = vInfo[vpid].vData.size() - 1; 810 } 811 812 Plotter2ViewportInfo* vi = &vInfo[vpid]; 813 vi->vData[dataid].drawLine = true; 814 vi->vData[dataid].lineColor = color; 815 vi->vData[dataid].lineWidth = width; 816 vi->vData[dataid].lineStyle = style; 909 dataid = vi->vData.size() - 1; 910 } else if (dataid >= (int)vi->vData.size()) { 911 exit(0); 912 } 913 914 Plotter2DataInfo* di = &vi->vData[dataid]; 915 di->drawLine = true; 916 di->lineColor = color; 917 di->lineWidth = width; 918 di->lineStyle = style; 919 //vi->vData[dataid].lineStyle = style; 817 920 } 818 921 819 922 void Plotter2::showLine(const int inVpid, const int inDataid) { 820 923 int vpid = inVpid; 924 if (vpid >= (int)vInfo.size()) { 925 exit(0); 926 } 821 927 if (vpid < 0) { 822 928 vpid = vInfo.size() - 1; … … 827 933 828 934 int dataid = inDataid; 935 if (dataid >= (int)vInfo[vpid].vData.size()) { 936 exit(0); 937 } 829 938 if (dataid < 0) { 830 939 dataid = vInfo[vpid].vData.size() - 1; … … 840 949 void Plotter2::hideLine(const int inVpid, const int inDataid) { 841 950 int vpid = inVpid; 951 if (vpid >= (int)vInfo.size()) { 952 exit(0); 953 } 842 954 if (vpid < 0) { 843 955 vpid = vInfo.size() - 1; … … 848 960 849 961 int dataid = inDataid; 962 if (dataid >= (int)vInfo[vpid].vData.size()) { 963 exit(0); 964 } 850 965 if (dataid < 0) { 851 966 dataid = vInfo[vpid].vData.size() - 1; … … 861 976 void Plotter2::setPoint(const int type, const float size, const int color, const int inVpid, const int inDataid) { 862 977 int vpid = inVpid; 978 if (vpid >= (int)vInfo.size()) { 979 exit(0); 980 } 863 981 if (vpid < 0) { 864 982 vpid = vInfo.size() - 1; … … 871 989 872 990 int dataid = inDataid; 991 if (dataid >= (int)vInfo[vpid].vData.size()) { 992 exit(0); 993 } 873 994 if (dataid < 0) { 874 995 dataid = vInfo[vpid].vData.size() - 1; … … 884 1005 void Plotter2::showPoint(const int inVpid, const int inDataid) { 885 1006 int vpid = inVpid; 1007 if (vpid >= (int)vInfo.size()) { 1008 exit(0); 1009 } 886 1010 if (vpid < 0) { 887 1011 vpid = vInfo.size() - 1; … … 892 1016 893 1017 int dataid = inDataid; 1018 if (dataid >= (int)vInfo[vpid].vData.size()) { 1019 exit(0); 1020 } 894 1021 if (dataid < 0) { 895 1022 dataid = vInfo[vpid].vData.size() - 1; … … 905 1032 void Plotter2::hidePoint(const int inVpid, const int inDataid) { 906 1033 int vpid = inVpid; 1034 if (vpid >= (int)vInfo.size()) { 1035 exit(0); 1036 } 907 1037 if (vpid < 0) { 908 1038 vpid = vInfo.size() - 1; … … 913 1043 914 1044 int dataid = inDataid; 1045 if (dataid >= (int)vInfo[vpid].vData.size()) { 1046 exit(0); 1047 } 915 1048 if (dataid < 0) { 916 1049 dataid = vInfo[vpid].vData.size() - 1; … … 926 1059 void Plotter2::setMaskX(const float xmin, const float xmax, const int color, const int fill, const int width, const float hsep, const int inVpid) { 927 1060 int vpid = inVpid; 1061 if (vpid >= (int)vInfo.size()) { 1062 exit(0); 1063 } 928 1064 if (vpid < 0) { 929 1065 vpid = vInfo.size() - 1; … … 953 1089 } 954 1090 955 void Plotter2::setLabelX(const std::string& label, const float inPosx, const float inPosy, const float size, const std::string& style, const int color, const int bgcolor, const int inVpid) { 956 int vpid = inVpid; 957 if (vpid < 0) { 958 vpid = vInfo.size() - 1; 959 } 960 if (vpid < 0) { 961 Plotter2ViewportInfo vi; 962 vInfo.push_back(vi); 963 vpid = 0; 964 } 965 966 Plotter2ViewportInfo* vi = &vInfo[vpid]; 1091 void Plotter2::setArrow(const float xtail, const float xhead, const float ytail, 1092 const float yhead, const int color, const int width, 1093 const int lineStyle, const float headSize, 1094 const int headFillStyle, const float headAngle, 1095 const float headVent, const int inVpid, const int inArrowid) { 1096 int vpid = inVpid; 1097 if (vpid >= (int)vInfo.size()) { 1098 exit(0); 1099 } 1100 if (vpid < 0) { 1101 vpid = vInfo.size() - 1; 1102 } 1103 if (vpid < 0) { 1104 Plotter2ViewportInfo vi; 1105 vInfo.push_back(vi); 1106 vpid = 0; 1107 } 1108 1109 Plotter2ViewportInfo* vi = &vInfo[vpid]; 1110 1111 int arrowid = inArrowid; 1112 if (arrowid < 0) { 1113 Plotter2ArrowInfo ai; 1114 vi->vArro.push_back(ai); 1115 arrowid = vi->vArro.size() - 1; 1116 } else if (arrowid >= (int)vi->vArro.size()) { 1117 exit(0); 1118 } 1119 1120 Plotter2ArrowInfo* ai = &vi->vArro[arrowid]; 1121 1122 ai->xhead = xhead; 1123 ai->xtail = xtail; 1124 ai->yhead = yhead; 1125 ai->ytail = ytail; 1126 ai->color = color; 1127 ai->width = width; 1128 ai->lineStyle = lineStyle; 1129 ai->headSize = headSize; 1130 ai->headFillStyle = headFillStyle; 1131 ai->headAngle = headAngle; 1132 ai->headVent = headVent; 1133 } 1134 1135 void Plotter2::setAnnotation(const std::string& label, const float posx, const float posy, const float angle, const float fjust, const float size, const std::string& style, const int color, const int bgcolor, const int inVpid, const int inAnnid) { 1136 int vpid = inVpid; 1137 if (vpid >= (int)vInfo.size()) { 1138 exit(0); 1139 } 1140 if (vpid < 0) { 1141 vpid = vInfo.size() - 1; 1142 } 1143 if (vpid < 0) { 1144 Plotter2ViewportInfo vi; 1145 vInfo.push_back(vi); 1146 vpid = 0; 1147 } 1148 1149 Plotter2ViewportInfo* vi = &vInfo[vpid]; 1150 1151 int annotationid = inAnnid; 1152 if (annotationid < 0) { 1153 Plotter2AnnotationInfo ai; 1154 vi->vAnno.push_back(ai); 1155 annotationid = vi->vAnno.size() - 1; 1156 } else if (annotationid >= (int)vi->vAnno.size()) { 1157 exit(0); 1158 } 1159 1160 Plotter2AnnotationInfo* ai = &vi->vAnno[annotationid]; 967 1161 968 1162 std::string styleString; … … 976 1170 styleString = "\\fs"; 977 1171 } 978 vi->labelXString = styleString + label; 979 980 float posx = inPosx; 981 if (posx < 0.0) { 982 posx = 0.5*(vi->vpPosXMin + vi->vpPosXMax); 983 } 984 vi->labelXPosX = posx; 985 986 float posy = inPosy; 987 if (posy < 0.0) { 988 posy = 0.35*vi->vpPosYMin; 989 } 990 vi->labelXPosY = posy; 991 992 vi->labelXAngle = 0.0; 993 vi->labelXFJust = 0.5; 994 vi->labelXSize = size; 995 vi->labelXColor = color; 996 vi->labelXBColor = bgcolor; 997 } 998 999 void Plotter2::setLabelY(const std::string& label, const float inPosx, const float inPosy, const float size, const std::string& style, const int color, const int bgcolor, const int inVpid) { 1000 int vpid = inVpid; 1172 1173 ai->text = styleString + label; 1174 ai->posx = posx; 1175 ai->posy = posy; 1176 ai->angle = angle; 1177 ai->fjust = fjust; 1178 ai->size = size; 1179 ai->color = color; 1180 ai->bgcolor = bgcolor; 1181 } 1182 1183 void Plotter2::setLabelX(const std::string& label, const float inPosx, const float inPosy, const float size, const std::string& style, const int color, const int bgcolor, const int inVpid) { 1184 int vpid = inVpid; 1185 if (vpid >= (int)vInfo.size()) { 1186 exit(0); 1187 } 1001 1188 if (vpid < 0) { 1002 1189 vpid = vInfo.size() - 1; … … 1020 1207 styleString = "\\fs"; 1021 1208 } 1022 vi->label YString = styleString + label;1209 vi->labelXString = styleString + label; 1023 1210 1024 1211 float posx = inPosx; 1025 1212 if (posx < 0.0) { 1026 posx = 0. 35*vi->vpPosXMin;1027 } 1028 vi->label YPosX = posx;1213 posx = 0.5*(vi->vpPosXMin + vi->vpPosXMax); 1214 } 1215 vi->labelXPosX = posx; 1029 1216 1030 1217 float posy = inPosy; 1031 1218 if (posy < 0.0) { 1032 posy = 0.5*(vi->vpPosYMin + vi->vpPosYMax); 1033 } 1034 vi->labelYPosY = posy; 1035 1036 vi->labelYAngle = 90.0; 1037 vi->labelYFJust = 0.5; 1038 vi->labelYSize = size; 1039 vi->labelYColor = color; 1040 vi->labelYBColor = bgcolor; 1041 } 1042 1043 void Plotter2::setTitle(const std::string& label, const float inPosx, const float inPosy, const float size, const std::string& style, const int color, const int bgcolor, const int inVpid) { 1044 int vpid = inVpid; 1219 posy = 0.35*vi->vpPosYMin; 1220 } 1221 vi->labelXPosY = posy; 1222 1223 vi->labelXAngle = 0.0; 1224 vi->labelXFJust = 0.5; 1225 vi->labelXSize = size; 1226 vi->labelXColor = color; 1227 vi->labelXBColor = bgcolor; 1228 } 1229 1230 void Plotter2::setLabelY(const std::string& label, const float inPosx, const float inPosy, const float size, const std::string& style, const int color, const int bgcolor, const int inVpid) { 1231 int vpid = inVpid; 1232 if (vpid >= (int)vInfo.size()) { 1233 exit(0); 1234 } 1045 1235 if (vpid < 0) { 1046 1236 vpid = vInfo.size() - 1; … … 1064 1254 styleString = "\\fs"; 1065 1255 } 1066 vi-> titleString = styleString + label;1256 vi->labelYString = styleString + label; 1067 1257 1068 1258 float posx = inPosx; 1069 1259 if (posx < 0.0) { 1070 posx = 0. 5*(vi->vpPosXMin + vi->vpPosXMax);1071 } 1072 vi-> titlePosX = posx;1260 posx = 0.35*vi->vpPosXMin; 1261 } 1262 vi->labelYPosX = posx; 1073 1263 1074 1264 float posy = inPosy; 1075 1265 if (posy < 0.0) { 1076 posy = vi->vpPosYMax + 0.25*(1.0 - vi->vpPosYMax); 1077 } 1078 vi->titlePosY = posy; 1079 1080 vi->titleAngle = 0.0; 1081 vi->titleFJust = 0.5; 1082 vi->titleSize = size; 1083 vi->titleColor = color; 1084 vi->titleBColor = bgcolor; 1085 } 1086 1087 void Plotter2::setViewportBackgroundColor(const int bgcolor, const int inVpid) { 1088 int vpid = inVpid; 1089 if (vpid < 0) { 1090 vpid = vInfo.size() - 1; 1091 } 1092 if (vpid < 0) { 1093 exit(0); 1094 } 1095 1096 Plotter2ViewportInfo* vi = &vInfo[vpid]; 1097 vi->vpBColor = bgcolor; 1098 } 1099 1100 /* 1101 void Plotter2::setAnnotation(const std::string& label, const float posx, const float posy, const float angle, const float fjust, const float size, const std::string& style, const int color, const int bgcolor, const int inVpid) { 1102 int vpid = inVpid; 1103 if (vpid < 0) { 1104 vpid = vInfo.size() - 1; 1105 } 1106 if (vpid < 0) { 1107 Plotter2ViewportInfo vi; 1108 vInfo.push_back(vi); 1109 vpid = 0; 1110 } 1266 posy = 0.5*(vi->vpPosYMin + vi->vpPosYMax); 1267 } 1268 vi->labelYPosY = posy; 1269 1270 vi->labelYAngle = 90.0; 1271 vi->labelYFJust = 0.5; 1272 vi->labelYSize = size; 1273 vi->labelYColor = color; 1274 vi->labelYBColor = bgcolor; 1275 } 1276 1277 void Plotter2::setTitle(const std::string& label, const float inPosx, const float inPosy, const float size, const std::string& style, const int color, const int bgcolor, const int inVpid) { 1278 int vpid = inVpid; 1279 if (vpid >= (int)vInfo.size()) { 1280 exit(0); 1281 } 1282 if (vpid < 0) { 1283 vpid = vInfo.size() - 1; 1284 } 1285 if (vpid < 0) { 1286 Plotter2ViewportInfo vi; 1287 vInfo.push_back(vi); 1288 vpid = 0; 1289 } 1290 1291 Plotter2ViewportInfo* vi = &vInfo[vpid]; 1111 1292 1112 1293 std::string styleString; … … 1120 1301 styleString = "\\fs"; 1121 1302 } 1122 1123 Plotter2ViewportInfo* vi = &vInfo[vpid]; 1124 //vi->titleString = styleString + label; 1125 //vi->titlePosX = posx; 1126 //vi->titlePosY = posy; 1127 //vi->titleAngle = angle; 1128 //vi->titleFJust = fjust; 1129 //vi->titleSize = size; 1130 //vi->titleColor = color; 1131 //vi->titleBColor = bgcolor; 1132 } 1133 */ 1303 vi->titleString = styleString + label; 1304 1305 float posx = inPosx; 1306 if (posx < 0.0) { 1307 posx = 0.5*(vi->vpPosXMin + vi->vpPosXMax); 1308 } 1309 vi->titlePosX = posx; 1310 1311 float posy = inPosy; 1312 if (posy < 0.0) { 1313 posy = vi->vpPosYMax + 0.25*(1.0 - vi->vpPosYMax); 1314 } 1315 vi->titlePosY = posy; 1316 1317 vi->titleAngle = 0.0; 1318 vi->titleFJust = 0.5; 1319 vi->titleSize = size; 1320 vi->titleColor = color; 1321 vi->titleBColor = bgcolor; 1322 } 1323 1324 void Plotter2::setViewportBackgroundColor(const int bgcolor, const int inVpid) { 1325 int vpid = inVpid; 1326 if (vpid >= (int)vInfo.size()) { 1327 exit(0); 1328 } 1329 if (vpid < 0) { 1330 vpid = vInfo.size() - 1; 1331 } 1332 if (vpid < 0) { 1333 exit(0); 1334 } 1335 1336 Plotter2ViewportInfo* vi = &vInfo[vpid]; 1337 vi->vpBColor = bgcolor; 1338 } 1134 1339 1135 1340 void Plotter2::close() { … … 1140 1345 } 1141 1346 1347 void Plotter2::resetAttributes(const Plotter2ViewportInfo& vi) { 1348 cpgstbg(0); // reset background colour to the initial one (white) 1349 cpgsci(1); // reset foreground colour to the initial one (black) 1350 cpgsls(1); // reset line style to solid 1351 cpgslw(1); // reset line width to 1 1352 cpgscf(1); // reset font style to normal 1353 cpgsch(vi.fontSizeDef);// reset font size 1354 cpgsfs(1); // reset fill style (solid) 1355 } 1356 1142 1357 void Plotter2::plot() { 1143 1358 open(); … … 1154 1369 1155 1370 if (vi.showViewport) { 1156 cpgstbg(0); // reset background colour to the initial one (white) 1157 cpgsci(1); // reset foreground colour to the initial one (black) 1158 cpgsls(1); // reset line style to solid 1159 cpgslw(1); // reset line width to 1 1160 cpgscf(1); // reset font style to normal 1161 cpgsch(vi.fontSizeDef);// reset font size 1162 cpgsfs(1); // reset fill style (solid) 1371 resetAttributes(vi); 1163 1372 1164 1373 // setup viewport … … 1175 1384 // data 1176 1385 for (unsigned int j = 0; j < vi.vData.size(); ++j) { 1177 cpgstbg(0); // reset background colour to the initial one (white) 1178 cpgsci(1); // reset foreground colour to the initial one (black) 1179 cpgsls(1); // reset line style to solid 1180 cpgslw(1); // reset line width to 1 1181 cpgscf(1); // reset font style to normal 1182 cpgsch(vi.fontSizeDef);// reset font size 1386 resetAttributes(vi); 1183 1387 1184 1388 Plotter2DataInfo di = vi.vData[j]; … … 1221 1425 // masks 1222 1426 for (unsigned int j = 0; j < vi.vRect.size(); ++j) { 1223 cpgstbg(0); // reset background colour to the initial one (white) 1224 cpgsci(1); // reset foreground colour to the initial one (black) 1225 cpgsls(1); // reset line style to solid 1226 cpgslw(1); // reset line width to 1 1227 cpgscf(1); // reset font style to normal 1228 cpgsch(vi.fontSizeDef);// reset font size 1229 cpgsfs(1); // reset fill style (solid) 1427 resetAttributes(vi); 1230 1428 1231 1429 Plotter2RectInfo ri = vi.vRect[j]; … … 1247 1445 } 1248 1446 1249 cpgstbg(0); // reset background colour to the initial one (white) 1250 cpgsci(1); // reset foreground colour to the initial one (black) 1251 cpgsls(1); // reset line style to solid 1252 cpgslw(1); // reset line width to 1 1253 cpgscf(1); // reset font style to normal 1254 cpgsch(vi.fontSizeDef);// reset font size 1255 cpgsfs(1); // reset fill style (solid) 1447 // arrows 1448 for (unsigned int j = 0; j < vi.vArro.size(); ++j) { 1449 resetAttributes(vi); 1450 1451 Plotter2ArrowInfo ai = vi.vArro[j]; 1452 cpgsci(ai.color); 1453 cpgslw(ai.width); 1454 cpgsls(ai.lineStyle); 1455 cpgsch(ai.headSize); 1456 cpgsah(ai.headFillStyle, ai.headAngle, ai.headVent); 1457 cpgarro(ai.xtail, ai.ytail, ai.xhead, ai.yhead); 1458 } 1459 1460 // annotations 1461 for (unsigned int j = 0; j < vi.vAnno.size(); ++j) { 1462 resetAttributes(vi); 1463 1464 Plotter2AnnotationInfo ai = vi.vAnno[j]; 1465 cpgsch(ai.size); 1466 cpgsci(ai.color); 1467 cpgstbg(ai.bgcolor); 1468 cpgptxt(ai.posx, ai.posy, ai.angle, ai.fjust, ai.text.c_str()); 1469 } 1470 1471 // viewport outline and ticks 1472 resetAttributes(vi); 1256 1473 1257 1474 cpgbox("BCTS", vi.majorTickIntervalX, vi.nMinorTickWithinMajorTicksX, 1258 1475 "BCTSV", vi.majorTickIntervalY, vi.nMinorTickWithinMajorTicksY); 1259 1476 1260 // viewport outline, ticks and number labels1477 // viewport numberings 1261 1478 std::string numformatx, numformaty; 1262 1479 if (vi.numLocationX == "b") { -
trunk/src/Plotter2.h
r2895 r2896 10 10 11 11 namespace asap { 12 13 class Plotter2AnnotationInfo { 14 public: 15 Plotter2AnnotationInfo(); 16 ~Plotter2AnnotationInfo(); 17 18 std::string text; 19 float posx; 20 float posy; 21 float angle; 22 float fjust; 23 float size; 24 int color; 25 int bgcolor; 26 }; 27 28 class Plotter2ArrowInfo { 29 public: 30 Plotter2ArrowInfo(); 31 ~Plotter2ArrowInfo(); 32 33 float xhead; 34 float xtail; 35 float yhead; 36 float ytail; 37 38 int color; 39 int width; 40 int lineStyle; 41 float headSize; 42 int headFillStyle; 43 float headAngle; 44 float headVent; 45 }; 12 46 13 47 class Plotter2RectInfo { … … 101 135 // rectangles 102 136 std::vector<Plotter2RectInfo> vRect; 137 138 // arrows 139 std::vector<Plotter2ArrowInfo> vArro; 140 141 //annotations 142 std::vector<Plotter2AnnotationInfo> vAnno; 103 143 104 144 // x-label … … 198 238 void hidePoint(const int inVpid, const int inDataid); 199 239 void setMaskX(const float xmin, const float xmax, const int color, const int fill, const int width, const float hsep, const int inVpid); 240 void setArrow(const float xtail, const float xhead, const float ytail, const float yhead, const int color, const int width, const int lineStyle, const float headSize, const int headFillStyle, const float headAngle, const float headVent, const int inVpid, const int inArrowid); 241 void setAnnotation(const std::string& label, const float posx, const float posy, const float angle, const float fjust, const float size, const std::string& style, const int color, const int bgcolor, const int inVpid, const int inAnnid); 200 242 void setLabelX(const std::string& label, const float posx, const float posy, const float size, const std::string& style, const int color, const int bgcolor, const int inVpid); 201 243 void setLabelY(const std::string& label, const float posx, const float posy, const float size, const std::string& style, const int color, const int bgcolor, const int inVpid); 202 244 void setTitle(const std::string& label, const float posx, const float posy, const float size, const std::string& style, const int color, const int bgcolor, const int inVpid); 203 245 void setViewportBackgroundColor(const int bgcolor, const int inVpid); 204 //void setAnnotation(const std::string& label, const float posx, const float posy, const float angle, const float fjust, const float size, const std::string& style, const int color, const int bgcolor, const int inVpid);205 246 void plot(); 206 247 private: … … 215 256 void open(); 216 257 void close(); 258 void resetAttributes(const Plotter2ViewportInfo& vi); 217 259 }; 218 260 -
trunk/src/python_Plotter2.cpp
r2895 r2896 81 81 .def("hide_point",&Plotter2::hidePoint) 82 82 .def("set_mask_x",&Plotter2::setMaskX) 83 .def("set_arrow",&Plotter2::setArrow) 84 .def("set_annotation",&Plotter2::setAnnotation) 83 85 .def("set_label_x",&Plotter2::setLabelX) 84 86 .def("set_label_y",&Plotter2::setLabelY) 85 87 .def("set_title",&Plotter2::setTitle) 86 88 .def("set_vpbgcolor",&Plotter2::setViewportBackgroundColor) 87 //.def("set_annotation",&Plotter2::setAnnotation)88 89 89 90 .def("plot",&Plotter2::plot)
Note:
See TracChangeset
for help on using the changeset viewer.