#include <scunit.h>
Inheritance diagram for ScaleUnit:
Public Member Functions | |
ScaleUnit () | |
Default constructor for a ScaleUnit giving a scale of 0 to 1 Scope: public. | |
ScaleUnit (const double dScale, const double dMin, const double dMax) | |
Constructor for a ScaleUnit Scope: Public. | |
ScaleUnit (const double dScale, const UINT32 nDPtoShow) | |
Constructor for a ScaleUnit, with a range 0..dScale. Scope: Public. | |
ScaleUnit (const ScaleUnit &UnitToCopy) | |
Copy constructor. | |
virtual ScaleUnit & | operator= (const ScaleUnit &UnitToCopy) |
Assignment operator. | |
virtual | ~ScaleUnit () |
Default destructor for a ScaleUnit - does nothing Scope: public. | |
virtual BOOL | operator== (const ScaleUnit &RhsUnit) const |
Compares two ScaleUnits for equality Scope: public. | |
virtual BOOL | operator!= (const ScaleUnit &RhsUnit) const |
Compares two ScaleUnits for inequality Scope: public. | |
BOOL | SetQualifier (Qualifier &NewQualifier) |
Allows the Qualifier for the given ScaleUnit to be specified Scope: public. | |
BOOL | SetQualifier (const StringBase &QualifierParseString, const Qualifier::QUALIFIER_SHOWN WhetherShown) |
Allows the Qualifier for the given ScaleUnit to be specified Scope: public. | |
const Qualifier * | GetQualifier () const |
Allows access to the Qualifier for the ScaleUnit. The Qualifier to which the returned value is pointing is read-only and should be copied if necessary. Scope: public. | |
BOOL | SetDPtoShow (const UINT32 uNumber) |
When a value of this unit is displayed we may need to provide some default for the number of decimal places to display. This member sets that default. Scope: public. | |
UINT32 | GetDPtoShow () const |
When displaying a number for a ScaleUnit we frequently wish to have it restricted to a given number of decimal places when displayed. This number is returned here to be used by display routines. Scope: public. | |
BOOL | SetMin (const double dMin) |
The minimum value provides an offset from which numbers for this ScaleUnit will start when provided with 0 as the scaled value. Scope: public. | |
double | GetMin () const |
Retrieves the starting offset value to be used by the conversion routines (or displaying the limits) Scope: public. | |
BOOL | SetMax (const double dMax) |
The maximum value is the value for which, when scaled, 1 will be returned by ConvertTo0To1(). This member function allows that maximum to be set. Scope: public. | |
double | GetMax () const |
Returns the maximum value, which when scaled will return 1. Scope: public. | |
BOOL | SetScale (const double dScale) |
Sets the value by which all numbers in the given max & min will be scaled to produce a value between 0 & 1. Scope: public. | |
double | GetScale () const |
Returns the value by which all numbers in the given max & min will be scaled to produce a value between 0 & 1. Scope: public. | |
BOOL | SetRange (const double dMin, const double dMax) |
BOOL | ConvertTo0to1 (double &dValue) const |
Converts the given double to a value between 0 & 1 depending on the ScaleUnit's scale. | |
BOOL | ConvertFrom0to1 (double &dValue) const |
Converts the given double to a value between 0 & 1 depending on the ScaleUnit's scale. | |
BOOL | StringFromScale (double &dNumber, StringBase *pResult, const UINT32 uSigFigs) const |
Will produce a string of the form <number>[<qualifier>] | <qualifier><number> depending on the units specification. | |
Protected Attributes | |
double | m_dScale |
Qualifier * | m_pQualifier |
UINT32 | m_nDPtoShow |
double | m_dMin |
double | m_dMax |
Private Attributes | |
BOOL | m_bInternalQualifier |
Definition at line 236 of file scunit.h.
|
Default constructor for a ScaleUnit giving a scale of 0 to 1 Scope: public.
Definition at line 337 of file scunit.cpp. 00338 { 00339 m_dScale = 1.0; 00340 m_dMin = 0.0; 00341 m_dMax = 1.0; 00342 m_nDPtoShow = 0; 00343 m_bInternalQualifier = FALSE; 00344 }
|
|
Constructor for a ScaleUnit Scope: Public.
Definition at line 360 of file scunit.cpp. 00361 { 00362 m_dScale = dScale; 00363 m_dMin = dMin; 00364 m_dMax = dMax; 00365 m_bInternalQualifier = FALSE; 00366 }
|
|
Constructor for a ScaleUnit, with a range 0..dScale. Scope: Public.
Definition at line 383 of file scunit.cpp. 00384 { 00385 m_dScale = m_dMax = dScale; 00386 m_dMin = 0.0; 00387 m_nDPtoShow = nDPtoShow; 00388 m_bInternalQualifier = FALSE; 00389 }
|
|
Copy constructor.
Definition at line 402 of file scunit.cpp. 00403 { 00404 if (this == &UnitToCopy) return; 00405 00406 m_dScale = UnitToCopy.m_dScale; 00407 m_dMin = UnitToCopy.m_dMin; 00408 m_dMax = UnitToCopy.m_dMax; 00409 m_pQualifier = UnitToCopy.m_pQualifier; 00410 m_nDPtoShow = UnitToCopy.m_nDPtoShow; 00411 m_bInternalQualifier = FALSE; 00412 }
|
|
Default destructor for a ScaleUnit - does nothing Scope: public.
Definition at line 451 of file scunit.cpp. 00452 { 00453 if (m_bInternalQualifier && m_pQualifier != NULL) 00454 delete m_pQualifier; 00455 }
|
|
Converts the given double to a value between 0 & 1 depending on the ScaleUnit's scale.
Definition at line 822 of file scunit.cpp.
|
|
Converts the given double to a value between 0 & 1 depending on the ScaleUnit's scale.
Definition at line 796 of file scunit.cpp. 00797 { 00798 ERROR2IF(m_dScale == 0, FALSE, "ScaleUnit scale is zero"); 00799 00800 value /= m_dScale; 00801 return TRUE; 00802 }
|
|
When displaying a number for a ScaleUnit we frequently wish to have it restricted to a given number of decimal places when displayed. This number is returned here to be used by display routines. Scope: public.
Definition at line 653 of file scunit.cpp. 00654 { 00655 return m_nDPtoShow; 00656 }
|
|
Returns the maximum value, which when scaled will return 1. Scope: public.
Definition at line 734 of file scunit.cpp. 00735 { 00736 return m_dMax; 00737 }
|
|
Retrieves the starting offset value to be used by the conversion routines (or displaying the limits) Scope: public.
Definition at line 693 of file scunit.cpp. 00694 { 00695 return m_dMin; 00696 }
|
|
Allows access to the Qualifier for the ScaleUnit. The Qualifier to which the returned value is pointing is read-only and should be copied if necessary. Scope: public.
Definition at line 609 of file scunit.cpp. 00610 { 00611 return m_pQualifier; 00612 }
|
|
Returns the value by which all numbers in the given max & min will be scaled to produce a value between 0 & 1. Scope: public.
Definition at line 774 of file scunit.cpp. 00775 { 00776 return m_dScale; 00777 }
|
|
Compares two ScaleUnits for inequality Scope: public.
Definition at line 497 of file scunit.cpp.
|
|
Assignment operator.
Definition at line 425 of file scunit.cpp. 00426 { 00427 if (this == &UnitToCopy) return *this; 00428 00429 m_dScale = UnitToCopy.m_dScale; 00430 m_dMin = UnitToCopy.m_dMin; 00431 m_dMax = UnitToCopy.m_dMax; 00432 m_pQualifier = UnitToCopy.m_pQualifier; 00433 m_nDPtoShow = UnitToCopy.m_nDPtoShow; 00434 m_bInternalQualifier = FALSE; 00435 00436 return *this; 00437 }
|
|
Compares two ScaleUnits for equality Scope: public.
Definition at line 473 of file scunit.cpp. 00474 { 00475 return (m_dScale == rhsUnit.m_dScale && 00476 m_pQualifier->GetToken() == rhsUnit.m_pQualifier->GetToken() && 00477 m_dMin == rhsUnit.m_dMin && 00478 m_dMax == rhsUnit.m_dMax && 00479 m_nDPtoShow == rhsUnit.m_nDPtoShow); 00480 }
|
|
When a value of this unit is displayed we may need to provide some default for the number of decimal places to display. This member sets that default. Scope: public.
Definition at line 632 of file scunit.cpp. 00633 { 00634 m_nDPtoShow = nNumber; 00635 return TRUE; 00636 }
|
|
The maximum value is the value for which, when scaled, 1 will be returned by ConvertTo0To1(). This member function allows that maximum to be set. Scope: public.
Definition at line 716 of file scunit.cpp.
|
|
The minimum value provides an offset from which numbers for this ScaleUnit will start when provided with 0 as the scaled value. Scope: public.
Definition at line 673 of file scunit.cpp.
|
|
Allows the Qualifier for the given ScaleUnit to be specified Scope: public.
Definition at line 550 of file scunit.cpp. 00552 { 00553 const String_32 StringString = TEXT("#1%s"); 00554 INT32 numberPosition = QualifierParseString.Sub(StringString); 00555 ERROR2IF(numberPosition == -1, FALSE, "invalid QualifierParseString"); 00556 00557 UINT32 tokenLength = QualifierParseString.Length() - StringString.Length(); 00558 00559 String_32 NewToken; 00560 Qualifier* pNewQualifier = NULL; 00561 if (tokenLength == 0) // there is no token 00562 { 00563 pNewQualifier = new NullQualifier; 00564 } 00565 else 00566 { 00567 if (numberPosition == 0) // numberPosition came first...we have a suffix qualifier 00568 { 00569 QualifierParseString.Right(&NewToken, tokenLength); 00570 pNewQualifier = new SuffixQualifier; 00571 } 00572 else 00573 { 00574 QualifierParseString.Left(&NewToken, tokenLength); 00575 pNewQualifier = new PrefixQualifier; 00576 } 00577 } 00578 if (pNewQualifier == NULL) 00579 return FALSE; 00580 00581 if (pNewQualifier->SetAttributes(NewToken, WhetherShown) == FALSE) 00582 { 00583 delete pNewQualifier; 00584 return FALSE; 00585 } 00586 00587 SetQualifier(*pNewQualifier); 00588 m_bInternalQualifier = TRUE; // ensure the qualifier's deleted in the destructor 00589 00590 return TRUE; 00591 }
|
|
Allows the Qualifier for the given ScaleUnit to be specified Scope: public.
Definition at line 521 of file scunit.cpp. 00522 { 00523 if (m_bInternalQualifier && m_pQualifier != NULL) 00524 delete m_pQualifier; 00525 m_bInternalQualifier = FALSE; 00526 m_pQualifier = &NewQualifier; 00527 return TRUE; 00528 }
|
|
|
|
Sets the value by which all numbers in the given max & min will be scaled to produce a value between 0 & 1. Scope: public.
Definition at line 755 of file scunit.cpp.
|
|
Will produce a string of the form <number>[<qualifier>] | <qualifier><number> depending on the units specification.
Definition at line 849 of file scunit.cpp. 00850 { 00851 ERROR2IF(pResult == NULL, FALSE, "pResult is NULL"); 00852 ERROR2IF(uSigFigs > 32, FALSE, "uSigFigs out of range"); 00853 00854 if (ConvertFrom0to1(dNumber) == FALSE) 00855 return FALSE; 00856 00857 String_32 TempString; 00858 Convert::DoubleToString(dNumber, (StringBase*)&TempString, GetDPtoShow()); 00859 TempString.Left(&TempString, uSigFigs); 00860 00861 const Qualifier* pQualifier = GetQualifier(); 00862 if (pQualifier == NULL) 00863 { 00864 return FALSE; 00865 } 00866 ERROR3IF(!pQualifier->IS_KIND_OF(Qualifier), "ScaleUnit::StringFromScale - pQualifier is not"); 00867 00868 // Return the number and stick the qualifier token in there somewhere if needed 00869 // ...that darned lack of subclassing. May take some thought to do it properly (for the 00870 // reverse conversion) 00871 pQualifier->MakeDisplayString(TempString, pResult); 00872 return TRUE; 00873 }
|
|
|
|
|
|
|
|
|
|
|
|
|