Changeset 574
 Timestamp:
 08/09/16 01:08:59 (5 years ago)
 Location:
 cpp/frams/param
 Files:

 2 edited
Legend:
 Unmodified
 Added
 Removed

cpp/frams/param/param.cpp
r535 r574 72 72 int ParamInterface::getMinMax(int prop, paInt& minumum, paInt& maximum, paInt &def) 73 73 { 74 const char* t = type(prop) + 1; 74 return getMinMax(type(prop),minumum,maximum,def); 75 } 76 77 int ParamInterface::getMinMax(int prop, double& minumum, double& maximum, double& def) 78 { 79 return getMinMax(type(prop),minumum,maximum,def); 80 } 81 82 int ParamInterface::getMinMax(int prop, int& minumum, int& maximum, SString& def) 83 { 84 return getMinMax(type(prop),minumum,maximum,def); 85 } 86 87 int ParamInterface::getMinMax(const char* t, paInt& minumum, paInt& maximum, paInt &def) 88 { 75 89 while (*t) if (*t == ' ') break; else t++; 76 90 return sscanf(t, PA_INT_SCANF " " PA_INT_SCANF " " PA_INT_SCANF, &minumum, &maximum, &def); 77 91 } 78 92 79 int ParamInterface::getMinMax(int prop, double& minumum, double& maximum, double& def) 80 { 81 const char* t = type(prop) + 1; 93 int ParamInterface::getMinMax(const char* t, double& minumum, double& maximum, double& def) 94 { 82 95 while (*t) if (*t == ' ') break; else t++; 83 96 return sscanf(t, "%lg %lg %lg", &minumum, &maximum, &def); 84 97 } 85 98 86 int ParamInterface::getMinMax(int prop, int& minumum, int& maximum, SString& def) 87 { 88 const char* t = type(prop) + 1; 99 int ParamInterface::getMinMax(const char* t, int& minumum, int& maximum, SString& def) 100 { 89 101 while (*t) if (*t == ' ') break; else t++; 90 102 int ret = sscanf(t, "%d %d", &minumum, &maximum); … … 138 150 { 139 151 double mn = 0, mx = 0, def = 0; 140 if (getMinMax( i, mn, mx, def) < 3) def = mn;152 if (getMinMax(t, mn, mx, def) < 3) def = mn; 141 153 setDouble(i, def); 142 154 } … … 145 157 { 146 158 paInt mn = 0, mx = 0, def = 0; 147 if (getMinMax( i, mn, mx, def) < 3) def = mn;159 if (getMinMax(t, mn, mx, def) < 3) def = mn; 148 160 setInt(i, def); 149 161 } … … 152 164 { 153 165 int mn, mx; SString def; 154 getMinMax( i, mn, mx, def);166 getMinMax(t, mn, mx, def); 155 167 if (*t == 's') 156 168 setString(i, def); … … 175 187 { 176 188 double mn = 0, mx = 0, def = 0; 177 getMinMax( i, mn, mx, def);189 getMinMax(t, mn, mx, def); 178 190 setDouble(i, mn); 179 191 } … … 182 194 { 183 195 paInt mn = 0, mx = 0, def = 0; 184 getMinMax( i, mn, mx, def);196 getMinMax(t, mn, mx, def); 185 197 setInt(i, mn); 186 198 } … … 198 210 { 199 211 double mn = 0, mx = 0, def = 0; 200 getMinMax( i, mn, mx, def);212 getMinMax(t, mn, mx, def); 201 213 setDouble(i, mx); 202 214 } … … 205 217 { 206 218 paInt mn = 0, mx = 0, def = 0; 207 getMinMax( i, mn, mx, def);219 getMinMax(t, mn, mx, def); 208 220 setInt(i, mx); 209 221 } … … 678 690 paInt mn, mx, def; 679 691 int value = getInt(i); 680 if (getMinMax( i, mn, mx, def) >= 2)692 if (getMinMax(t, mn, mx, def) >= 2) 681 693 { 682 694 if (value > mx) … … 715 727 if (*t==0) return false; 716 728 if (strchr("dfsoxp", *t)==NULL) return false; 729 switch(*t) 730 { 731 case 'd': 732 {paInt a,b,c; if (getMinMax(t,a,b,c)==1) return false;} 733 break; 734 case 'f': 735 {double a,b,c; if (getMinMax(t,a,b,c)==1) return false;} 736 break; 737 } 717 738 return true; 718 739 } … … 858 879 if (pe>flags&PARAM_READONLY) return PSET_RONLY; 859 880 paInt xcopy = x; //only needed for messageOnExceedRange(): retain original, requested value of x because it may be changed below 860 paInt mn = 0, mx = 0 ;881 paInt mn = 0, mx = 0, de = 0; 861 882 int result = 0; 862 const char* t = pe>type + 1; 863 while (*t) if (*t == ' ') break; else t++; 864 if (sscanf(t, PA_INT_SCANF " " PA_INT_SCANF, &mn, &mx) == 2) 883 if (getMinMax(pe>type,mn,mx,de)>=2) 865 884 if (mn <= mx) // else if mn>mx then the min/max constraint makes no sense and there is no checking 866 885 { … … 894 913 if (pe>flags&PARAM_READONLY) return PSET_RONLY; 895 914 double xcopy = x; //only needed for messageOnExceedRange(): retain original, requested value of x because it may be changed below 896 double mn = 0, mx = 0 ;915 double mn = 0, mx = 0, de = 0; 897 916 int result = 0; 898 const char* t = pe>type + 1; 899 while (*t) if (*t == ' ') break; else t++; 900 if (sscanf(t, "%lg %lg", &mn, &mx) == 2) 917 if (getMinMax(pe>type,mn,mx,de)>=2) 901 918 if (mn <= mx) // else if mn>mx then the min/max constraint makes no sense and there is no checking 902 919 { 
cpp/frams/param/param.h
r535 r574 144 144 int getMinMax(int prop, double& minumum, double& maximum, double& def); 145 145 int getMinMax(int prop, int& minumum, int& maximum, SString& def); 146 static int getMinMax(const char* type, paInt& minumum, paInt& maximum, paInt& def); 147 static int getMinMax(const char* type, double& minumum, double& maximum, double& def); 148 static int getMinMax(const char* type, int& minumum, int& maximum, SString& def); 146 149 147 150 virtual void setDefault();
Note: See TracChangeset
for help on using the changeset viewer.