13 #include "msdevstudio/MSconfig.h"
29 #ifdef ITERATOR_MEMBER_DEFECT
39 using namespace hippodraw;
41 LogTransform::LogTransform ()
87 vector< double >::iterator first = x.begin();
88 for ( ; first != x.end(); ++first ) {
89 *first = log10 ( *first );
103 double lo = range.
low ();
104 double hi = range.
high ();
106 if ( hi <= 0.0 ) hi = 1.0;
108 if ( lo <= 0.0 ) lo = range.
pos();
115 const vector < AxisTick > &
128 double low = range.
low();
129 double high = range.
high();
130 double rangeMag = high / low;
133 double rmag = floor( log10( rangeMag ) );
136 double pmag = ceil( log10( low ) );
140 double tmag = floor( rmag / 3.0 );
142 double tick_step = pow( 10.0, tmag );
153 double low = range.
low();
160 double first_tick = pow( 10.0, pmag );
162 while( ( tmp =
prevStep( first_tick, axis )) >= low ) {
175 return ( (
double)abs( x - y ) <= 2.0 * ( y * FLT_EPSILON + FLT_MIN ) );
181 const vector < AxisTick > &
203 double range_low = range.
low();
204 double range_high = range.
high();
206 double last_tick = first_tick;
208 while ( ( tmp =
nextStep( last_tick, axis ) ) <= range_high ) {
214 ( floor( log10( last_tick ) ) > 3.0 ) ||
215 ( floor ( log10 ( first_tick ) ) ) < -3.0;
217 sprintf( pstr,
"%%1.0fe%%d" );
220 double value = first_tick / tick_step;
222 while( value <= range_high ||
FLT_EQUAL( range_high, value ) ) {
223 if( num_ticks >= max_ticks ) {
237 if( value > range_high )
break;
239 mag = floor( log10( value ) );
240 ylabel = value / pow( 10.0, mag );
241 sprintf( pstr,
"%%1.0fe%%d" );
242 sprintf( labl, pstr, ylabel, static_cast<int>( mag ) );
245 double tmp = floor( log10( value ) );
246 if( tmp > 0.0 ) tmp = 0.0;
248 sprintf( pstr,
"%%1.%df", static_cast<int>( tmp ) );
249 sprintf( labl, pstr, ylabel );
252 double y = value / scale_factor;
263 double xx = (log10(range_high) - log10(range_low)) / 4;
264 double yy = log10(range_low);
266 for(
int i=1;
i<4;
i++)
269 value = pow (10.0, xx *
i + yy);
271 if( value > range_high )
continue;
273 double tmp = floor( log10( value ) );
274 if( tmp > 0.0 ) tmp = 0.0;
278 value = floor(value);
281 sprintf( pstr,
"%%1.%df", static_cast<int>( tmp ) );
282 sprintf( labl, pstr, value);
284 double y = value / scale_factor;
296 if( tick_step == 1.0 ) {
297 int bottom =
static_cast<int>( current /
298 pow( 10.0, floor( log10( current ) ) ) );
328 current *= tick_step;
338 if( tick_step == 1.0 ) {
339 int base =
static_cast<int>( current /
340 pow( 10.0, floor( log10( current ) ) ) );
366 current /= tick_step;
378 double mylow, myhigh;
390 double low = init_range.
low();
391 double high = init_range.
high();
393 myhigh = mylow = pow( 10.0, axis.
getPMag() );
398 while( mylow >= low * scale_factor ) {
404 while( myhigh <= high * scale_factor ) {
410 if( myhigh / mylow < 10.0 ) {
416 while( myhigh / mylow < 10.0 ) {
420 myhigh /= scale_factor;
421 mylow /= scale_factor;
423 Range new_range ( mylow, myhigh, init_range.
pos() );
428 double new_width = new_range.
length();
429 double init_width = init_range.
length();
431 if ( new_width > init_width * 10 ){
447 Range newRange ( low, high, init_range.
pos() );
462 double low = r.
low();
463 double high = r.
high();
464 double pos = r.
pos();
466 if( low > 0.0 )
return r;
469 double l = pos / 10.0;
470 double h = pos * 10.0;
475 if( pos == DBL_MAX || pos <= 0.0 ) {
479 if ( low <= 0.0 ) axis.
setRange ( 0.5 * pos, high, pos );
480 else axis.
setRange ( pos, high, pos );
virtual LogTransform * clone() const
Creates a new Transform object by copying an existing one.
virtual const std::vector< AxisTick > & setTicks(AxisModelBase &axis)
Sets the vector of ticks along the axis to which this Log transform is applied.
void setFirstTick(AxisModelBase &)
double high() const
Returns the maximum of the range object.
A class to maintain tick coordinates and string values.
void setTickStep(AxisModelBase &)
A transform that transforms coordinates from one coordinate system to another.
void setFirstTick(const double &first_tick)
Sets the value for first tick step.
A UnaryTransform which takes the log of the coordinate.
double getMaxTicks() const
Returns the value for maximum number of ticks.
virtual ~LogTransform()
The virtual destructor.
void setLow(double x)
Sets the minimum of the range object.
virtual void validate(Range &) const
Validates the Range, and adjusts the argument Range so that the values are positive.
const Range & adjustLogValues(AxisModelBase &axis)
LogTransform()
The default constructor.
void setRange(double low, double high, double pos)
Sets the Range to the low and high values.
virtual void transform(double &x) const
Transforms the coordinate @ x.
const std::vector< AxisTick > & genTicks(AxisModelBase &)
void setHigh(double x)
Sets the maximum of the range object.
double FLT_EQUAL(double x, double y)
const Range & adjustValues(AxisModelBase &axis, const Range &limit)
Sets the range of given axis to be a new "nice" within the limits given.
void setPMag(const double &pmag)
Sets the magnitude of the power of ten for the tick labels.
double prevStep(double current, AxisModelBase &axis)
virtual bool isLinear() const
The AxisModelBase class maintains the Range and scaling of an axis.
double length() const
Returns the length of the range object.
double getScaleFactor() const
Returns the scale factor.
LogTransform class interface.
std::string m_name
Name of the Transform.
hippodraw::AxisModelBase class interface
double nextStep(double current, AxisModelBase &axis)
double getPMag() const
Returns the magnitude of the power of ten for the tick labels.
const Range & getRange(bool scaled) const
Returns the range represented by this AxisModel.
A transform that transforms coordinates in one dimension from one coordinate system to another...
void setRMag(const double &rmag)
Sets the magnitude of the range.
double low() const
Returns the minimum of the range object.
void setTickStep(const double &t_step)
Sets the tick step.
Expresses a range of values.
void setIntersectRange(const Range &, const Range &)
Sets the Range to overlap of the two ranges.
double getFirstTick() const
Returns the value for the first tick step.
double pos() const
Returns the first positive element in range.
std::vector< AxisTick > m_ticks
The ticks generated by this transform.
virtual void inverseTransform(double &x) const
Inverse transforms the coordinate x.
AxisTick class interface.
double getTickStep() const
Returns the tick step in the true coordinate system.