Go to the documentation of this file.
20 #include "../lina/vec3f"
75 static const desc_fields s_v(parent::node_desc_fields(),27,
108 if(parent::touched())
return true;
117 parent::reset_touched();
184 parent::search(a_action);
185 if(a_action.
done())
return;
292 parent::operator=(a_from);
396 for(
size_t index=0;index<num;index++) {
413 for(
unsigned int index=0;index<
tick_number;index++) {
473 scale_rot.
mul_scale(text_size,text_size,1);
479 for(
unsigned int index=0;index<number;index++) {
482 if(index==(number-1))
continue;
501 vec[0],vec[1],vec[2],
551 vec[0],vec[1],vec[2],
600 vec[0],vec[1],vec[2],
655 float hData = YSIZ-YMGL-YMGU;
658 float to1 =
width/hData;
660 float vsiz = VSIZ * to1;
661 float yval = YVAL * to1;
662 float xtic = XTIC * to1;
663 float ylab = YLAB * to1;
664 float asiz = ASIZ * to1;
707 style_t::const_iterator it;
708 for(it=a_style.begin();it!=a_style.end();++it) {
709 const std::string& key = (*it).first;
710 const std::string& sv = (*it).second;
731 if(key==
"divisions") {
735 }
else if(key==
"modeling") {
737 }
else if(key==
"is_log") {
742 }
else if(key==
"tick_up") {
746 }
else if(key==
"tick_length") {
751 }
else if(key==
"title") {
753 }
else if(key==
"title_to_axis") {
757 }
else if(key==
"title_height") {
761 }
else if(key==
"title_hjust") {
767 }
else if(key==
"label_to_axis") {
771 }
else if(key==
"label_height") {
776 }
else if(key==
"labels_no_overlap_automated") {
780 }
else if(key==
"labels_gap") {
786 a_out <<
"axis::set_from_style :"
787 <<
" unknown key " << key <<
"."
802 std::vector<float> x_mins;
803 std::vector<float> x_maxs;
808 (*it)->bbox(_action);
820 float dx_overlap = 0;
821 {
size_t number = x_mins.size();
822 for(
size_t index=1;index<number;index++) {
823 float dx = x_mins[index]-x_maxs[index-1];
826 dx_overlap =
mx(dx_overlap,-dx);
833 float first_scale = 1;
836 float second_scale = 1.1f;
838 (*it)->mul_scale(second_scale,second_scale,1);
844 float a = (second_overlap-first_overlap)/(second_scale-first_scale);
845 float b = first_overlap-a*first_scale;
848 float wanted_scale = (-wanted_gap-b)/a;
849 if(wanted_scale<=0) wanted_scale = 1;
850 wanted_scale /= second_scale;
852 (*it)->mul_scale(wanted_scale,wanted_scale,1);
856 (*it)->mul_scale(1.0f/second_scale,1.0f/second_scale,1);
863 const std::string& a_key,
864 const std::string& a_value) {
865 a_out <<
"axis::set_from_style :"
866 <<
" failed for key " <<
sout(a_key)
867 <<
" and value " <<
sout(a_value) <<
"."
892 if((
mn<=0) || (
mx<=0) ) a_is_log =
false;
895 float magxxx,y,yr,startTick,tickSize;
900 unsigned int tick_num = 0;
901 std::vector<float> tick_values;
902 std::vector<std::string> tick_labels;
906 float NUM_FUZZ = 0.01f;
924 startTick =
fceil(
mn / tickSize) * tickSize;
926 if (
ffabs(magxxx) <= 3)
931 snpf(pstr,
sizeof(pstr),
"%%1.%df",(
int)max_of<float>((pmag-magxxx),0.0));
934 while (y <=
mx*(1.0+NUM_FUZZ)) {
938 snpf(tmp,
sizeof(tmp),pstr,yr*
fpow(10,magxxx-pmag));
940 {
float val = yr *
fpow(10.0,magxxx);
941 if((val>=
mn)&&(val<=
mx)) {
942 tick_values.push_back(val);
943 tick_labels.push_back(tmp);
949 if (
ffabs(magxxx) <= 3.0) magxxx = 0.0;
972 float magrng = maghigh - maglow;
983 magStep = magrng <= 7 ? 1.0F : 2.0F;
986 pmag = (nLogTicks == 3 && (
ffabs(maglow)>3 ||
ffabs(maghigh)>3)) ?
991 while ((y=logTicks[i]*
fpow(10,magxxx)) <
mx*(1+NUM_FUZZ)) {
996 if ((magxxx-pmag) > 4 || (magxxx-pmag) < -3) {
997 ::strcpy(pstr,
"%1.0e");
999 snpf(pstr,
sizeof(pstr),
1000 "%%1.%df",(
int)((magxxx-pmag)>0?0.:-(magxxx-pmag)));
1002 snpf(tmp,
sizeof(tmp),pstr,y*
fpow(10.0,-pmag));
1006 tick_values.push_back(val);
1007 tick_labels.push_back(tmp);
1024 float range =
mx -
mn;
1030 for(
unsigned int index=0;index<tick_num;index++) {
1031 float val = tick_values[index];
1032 float coord =
width * (val-
mn)/range;
1040 for(
size_t index=n;index<tick_num;index++)
labels.
add(
"");
1053 unsigned int MIN_TICKS = 4;
1057 aSize =
ffabs(aSize);
1058 if (aSize == 0.0) aSize = 1.0;
1062 if (aSize/
fpow(10.0,a_mag) < MIN_TICKS) (a_mag)--;
1068 static const float goodTicks[] = {10.0, 5.0, 4.0, 2.0, 1.0};
1070 aSize/(tickSize=goodTicks[tickIndex]*
fpow(10.0,a_mag))<MIN_TICKS;
1073 if (tickIndex == 0) a_mag++;
1099 if((
mn<=0) || (
mx<=0) ) a_is_log =
false;
1107 double xmax =
width;
1110 double gridlength = 0;
1112 if(a_is_log) chopt +=
"G";
1114 std::vector<float> linesGrid;
1115 std::vector<hplot::_text> texts;
1134 sbAxisHPLOT.
paint(xmin,ymin,xmax,ymax,
1136 chopt,gridlength,
false,
1144 float range =
mx -
mn;
1146 size_t tick_num = texts.size();
1152 if(::sscanf(texts[tick_num-1].fString.c_str(),
"x10^%d!",&pmag)==1) {
1161 for(
size_t index=0;index<tick_num;index++) {
1162 float coord = (float)texts[index].fX;
1172 for(
size_t index=n;index<tick_num;index++)
labels.
add(
"");
1176 for(
size_t index=0;index<tick_num;index++) {
1184 for(
size_t index=0;index<num;index++) {
1188 for(
size_t i=0;i<tick_num;i++) {
1189 if((
float)texts[i].fX==coord) {
sf_enum< sg::vjust > vjust
#define TOOLS_NODE(a__class, a__sclass, a__parent)
sf_enum< sg::font_modeling > font_modeling
sf_vec< colorf, float > color
sf_enum< sg::hjust > hjust
#define TOOLS_FIELD_DESC_NODE_CLASS(a__class)
#define tools_vforcit(a__T, a__v, a__it)
#define TOOLS_ARG_FIELD_DESC(a__field)