DimScale Class Reference

This class is used to scale millipoint dimension values to and from a user-set preference. E.g. the user may specify that 1 mile = 2 centimetres. This class will record the units (in this case miles) and the scale factor used to convert internal millipoint values to and from the units the user wishes to work in. More...

#include <convert.h>

Inheritance diagram for DimScale:

CCObject SimpleCCObject List of all members.

Public Member Functions

 DimScale ()
 Constructor.
BOOL IsActive ()
 Interogate the active state of this object.
void SetActiveState (BOOL State)
 Used to set the active state of this dimension scaling object. When inactive, no scaling is performed.
double GetScaleFactor ()
BOOL SetScaleFactor (double NewScaleFactor)
BOOL SetScaleFactor ()
 Reads the DrawingScaleStr and RealScaleStr, which should specify the drawing and real scaling factors, and calculates the new scale factor from these. If either are negative or zero then it will return FALSE and no new scaling factor is set.
UnitType GetUnits ()
 For getting hold of those pesky units.
UnitType GetScaleUnits ()
 For getting hold of those pesky scale units.
String_32 GetDrawingScaleStr ()
 This is the string that the user has typed into the "Drawing scale" editable field of the scale factor dialog.
BOOL SetDrawingScaleStr (String_32 &NewStr)
 Allows the setting of a new string that is to be used as the drawing scaling factor. This has usually been typed in by the user into the "Drawing scale" editable field of the scale factor dialog. The string is attempted to be converted to a value and the value checked. If it is ok then TRUE is returned otherwise FALSE is returned.
String_32 GetRealScaleStr ()
 This is the string that the user has typed into the "Real scale" editable field of the scale factor dialog.
BOOL SetRealScaleStr (String_32 &NewStr)
 Allows the setting of a new string that is to be used as the real scaling factor. This has usually been typed in by the user into the "Real scale" editable field of the scale factor dialog. The string is attempted to be converted to a value and the value checked. If it is ok then TRUE is ereturned otherwise FALSE is returned.
BOOL ConvertToUnits (double Value, String_256 *pStr, BOOL UnitSpecifier=TRUE, INT32 dp=-1, UnitType units=NOTYPE, BOOL bSquare=FALSE)
 This converts a millipoint value into a string representation that reflects the dimension scaling specified in this object. If this object represented a scaling of 1 mile = 1 inch, then if MpValue = 72000 pStr would contain "1 mi" on exit.
BOOL ConvertToMillipoints (const StringBase &Str, MILLIPOINT *pMpValue)
 This takes a string of the form "45.3 km" and converts it to the correctly scaled millipoint value. E.g if 1 km = 2 cm then "45.3 km" would give (45.3 * 2 * 28346.52715) millipoints, where 28346.52715 is the num millipoints in one centimetre.
BOOL ConvertToDouble (const StringBase &Str, double *pResult)
 This takes a string of the form "45.3 km" and converts it to the correctly scaled millipoint value. E.g if 1 km = 2 cm then "45.3 km" would give (45.3 * 2 * 28346.52715) millipoints, where 28346.52715 is the num millipoints in one centimetre.
BOOL ComponentsToMillipoint (double *pMillipoint, double Number, UnitType Units)
 Convert a number of specified units to an accurate millipoint value Note: Unfortunately this duplicate some functionality in other routines but these functions are considered stable to change at the moment.
DimScaleoperator= (const DimScale &other)
 Assignment (set equal to) operator.
BOOL operator== (const DimScale &other)
 Equivalence operator.

Static Public Member Functions

static BOOL Init ()
 Initialises this class. Must be called before any other function in this class.
static void Deinit ()
 Initialises this class. Must be called before any other function in this class.
static DimScaleGetPtrDimScale (Node *pNode)
 Ptr to a DimScale object that can be used to scale dimension values to and from internal millipoint values. The DimScale object is taken from the node's parent Spread. If a parent spread is not found or the spread's DimScale object is inactive, the default DimScale is returned.
static DimScaleGetPtrDefaultDimScale ()
 Ptr to the default DimScale object that is returned by GetPtrDimScale if it can't find one in the tree.

Private Attributes

BOOL Active
double ScaleFactor
String_32 DrawingScaleStr
String_32 RealScaleStr

Detailed Description

This class is used to scale millipoint dimension values to and from a user-set preference. E.g. the user may specify that 1 mile = 2 centimetres. This class will record the units (in this case miles) and the scale factor used to convert internal millipoint values to and from the units the user wishes to work in.

Author:
Mark_Neves (Xara Group Ltd) <camelotdev@xara.com>
Date:
14/6/93
See also:
Spread, Layer

Definition at line 223 of file convert.h.


Constructor & Destructor Documentation

DimScale::DimScale  ) 
 

Constructor.

Author:
Mark_Neves (Xara Group Ltd) <camelotdev@xara.com>
Date:
14/6/94
Parameters:
- [INPUTS]
- [OUTPUTS]
Returns:
-
See also:
-

Definition at line 1493 of file convert.cpp.

01494 {
01495     // Set up some useful defaults
01496     Active          = FALSE;
01497     DrawingScaleStr = _R(IDS_CONVERT_ONE_CM); //"1 cm";
01498     RealScaleStr    = _R(IDS_CONVERT_ONE_MI); //"1 mi";
01499     ScaleFactor     = MI_MP_VAL / CM_MP_VAL;
01500 }


Member Function Documentation

BOOL DimScale::ComponentsToMillipoint double *  pMillipoint,
double  Number,
UnitType  Units
 

Convert a number of specified units to an accurate millipoint value Note: Unfortunately this duplicate some functionality in other routines but these functions are considered stable to change at the moment.

Author:
Ed_Cornes (Xara Group Ltd) <camelotdev@xara.com>
Date:
15/10/95
Parameters:
Number - [INPUTS] Units -
pMillipoint - [OUTPUTS]
Returns:
FALSE if fails

Definition at line 2160 of file convert.cpp.

02161 {
02162     ERROR2IF(pMillipoint==NULL,  FALSE,"DimScale::ComponentsToMillipoint() - pMillipoint==NULL");
02163     ERROR2IF(      Units==NOTYPE,FALSE,"DimScale::ComponentsToMillipoint() - Units==NOTYPE");
02164     DocUnitList* pDocUnitList = DocUnitList::GetCurrentDocUnitList();
02165     ERROR2IF(pDocUnitList==NULL,FALSE,"DimScale::ComponentsToMillipoint() - pDocUnitList==NULL");
02166     Unit* pUnit = pDocUnitList->FindUnit(Units);
02167     ERROR2IF(pUnit==NULL,FALSE,"DimScale::ComponentsToMillipoint() - pUnit==NULL");
02168 
02169     double Divisor = 1;
02170     if (Active)
02171         Divisor = ScaleFactor;
02172 
02173     *pMillipoint = Number * pUnit->GetMillipoints() / Divisor;
02174     return TRUE;
02175 }

BOOL DimScale::ConvertToDouble const StringBase str,
double *  pResult
 

This takes a string of the form "45.3 km" and converts it to the correctly scaled millipoint value. E.g if 1 km = 2 cm then "45.3 km" would give (45.3 * 2 * 28346.52715) millipoints, where 28346.52715 is the num millipoints in one centimetre.

Author:
Mark_Neves (Xara Group Ltd) <camelotdev@xara.com>
Date:
22/6/94
Parameters:
pStr = Ptr to a string containing value to convert [INPUTS]
pResult = Ptr to the resultant millipoint value in fp form. [OUTPUTS]
Returns:
TRUE if successfully converted, FALSE otherwise
See also:
-

Definition at line 1970 of file convert.cpp.

01971 {
01972     double Result=72000.0;  // Provide something useful in case BOOL result is ignored
01973     BOOL ok;
01974 
01975     // Convert the string into its component parts
01976     // Use scale units if units are NOT specified in the string
01977     Result = Convert::StringToDouble(str,GetUnits(),&ok);
01978 
01979     if (ok)
01980     {
01981         // Only scale down if this object is active
01982         if (Active)
01983             Result /= ScaleFactor;      // Scale result to internal millipoints
01984     }
01985 
01986     *pResult = Result;                  // Store the result
01987 
01988     return (ok);
01989 }

BOOL DimScale::ConvertToMillipoints const StringBase Str,
MILLIPOINT pMpValue
 

This takes a string of the form "45.3 km" and converts it to the correctly scaled millipoint value. E.g if 1 km = 2 cm then "45.3 km" would give (45.3 * 2 * 28346.52715) millipoints, where 28346.52715 is the num millipoints in one centimetre.

Author:
Mark_Neves (Xara Group Ltd) <camelotdev@xara.com>
Date:
14/6/94
Parameters:
pStr = Ptr to a string containing value to convert [INPUTS]
pMpValue= Ptr to the resultant millipoint value. [OUTPUTS]
Returns:
TRUE if successfully converted, FALSE otherwise

Errors: ConvertToDouble() fails result overflows

Definition at line 2009 of file convert.cpp.

02010 {
02011     // Set a sensible return value just in case we exit early and nobody notices
02012     // the boolean result
02013     *pMpValue = 72000;
02014 
02015     double result = 1.0;
02016     if (ConvertToDouble( Str, &result) == FALSE)
02017         return FALSE;
02018 
02019     result+=0.5;    // round up
02020 
02021     // We are going to try and convert this to a MILLIPOINT value so check that
02022     // we are not going to overflow. If we are then return FALSE and the maximum
02023     // possible value. 
02024     //if (result>MaxDocCoord || result<MinDocCoord)
02025     //  ERROR2(FALSE,"DimScale::ConvertToMillipoints() - overflow");
02026     // Rather than erroring do something sensible like returning false.
02027     if (result > MaxDocCoord)
02028     {
02029         *pMpValue = MaxDocCoord;
02030         return FALSE;
02031     }   
02032 
02033     if (result < MinDocCoord)
02034     {
02035         *pMpValue = MinDocCoord;
02036         return FALSE;
02037     }   
02038         
02039     // We should be fairly happy with that result so return it to the user
02040     *pMpValue=(MILLIPOINT)result;
02041 
02042     return TRUE;
02043 }

BOOL DimScale::ConvertToUnits double  MpValue,
String_256 pStr,
BOOL  UnitSpecifier = TRUE,
INT32  dp = -1,
UnitType  units = NOTYPE,
BOOL  bSquare = FALSE
 

This converts a millipoint value into a string representation that reflects the dimension scaling specified in this object. If this object represented a scaling of 1 mile = 1 inch, then if MpValue = 72000 pStr would contain "1 mi" on exit.

Author:
Mark_Neves (Xara Group Ltd) <camelotdev@xara.com>
Date:
14/6/94
Parameters:
MpValue = A value in Camelot's internal millipoints [INPUTS] pStr = Ptr to a string to store the converted MpValue UnitSpecifier - If TRUE the unit specifier is included e.g. "1.27 cm" or "1.27" for TRUE or FALSE respectively dp - number of decimal places (-1 means use system default) (100+n means use n significant figures) units - type of units to convert to bSquare - MpValue measures an area
Returns:
TRUE if successfully converted, FALSE otherwise

Errors: dp<0

If the unit type is <= millimeters, clamp decimal-places to 1. [Harrison Ainsworth 19/11/97] Why? - hide the accuracy limits of my scaling fix (OpScale2Trans)

Definition at line 1795 of file convert.cpp.

01797 {
01798     ERROR2IF(pStr == NULL, FALSE,"DimScale::ConvertToUnits() result string = Null");
01799 
01800     // If dp is -1 then use the default preference value specified by the user.
01801     if (dp == -1)
01802         dp = Convert::GetNumberDecimalPlaces(); // Use the default preference value
01803     else if (dp == 100)
01804         dp = 100 + Convert::GetNumberDecimalPlaces(); // Use the default preference value
01805 
01806     // If dp is anything else i.e. negative then make zero but warn debug users as bad value.
01807     if (dp < 0)
01808     {
01809         ERROR3("DimScale::ConvertToUnits() - dp<0");
01810         dp = 0; // Use no decimal places
01811     }
01812 
01813     double ScaledValue  = 1.0;
01814     double sf           = 1.0;
01815     String_32 Specifier;
01816     TCHAR p[256];
01817     
01818     // Get the current unit list from the document and the the current scale units
01819     DocUnitList* pDocUnitList = DocUnitList::GetCurrentDocUnitList();
01820 //  ERROR2IF(pDocUnitList == NULL, FALSE,"DimScale::ConvertToUnits() No current document units");
01821     if (pDocUnitList == NULL)
01822     {
01823         TRACE( wxT("No Unit list - if this not an OLE paste, PANIC!!!\n") );
01824         return FALSE;
01825     }
01826 
01827     if (units==NOTYPE)
01828         units = GetUnits();
01829     Unit* pScaleUnit = pDocUnitList->FindUnit(units);
01830     ERROR2IF(pScaleUnit == NULL, FALSE,"DimScale::ConvertToUnits() Null scale units");
01831 
01832     // If active, use the scale factor, otherwise use 1.0 (i.e. no scaling)
01833     if (Active)
01834     {
01835         sf = ScaleFactor;
01836         if (bSquare)
01837             sf *= ScaleFactor;
01838     }
01839     else
01840         sf = 1.0;
01841 
01842     // Find out how many Units MpValue represents, avoiding div by zero's
01843     double NumMpInUnit = pScaleUnit->GetMillipoints();
01844     if (NumMpInUnit != 0)
01845     {
01846         ScaledValue = MpValue*sf / NumMpInUnit;
01847         if (bSquare)
01848             ScaledValue = ScaledValue / NumMpInUnit;
01849     }
01850     else
01851         ScaledValue = 0;
01852 
01855     //
01856     // [Phil 26/09/2005]
01857     // This kludge is retained only for back-compatibility with X1 - OpScale2Trans has
01858     // been removed
01859     if( ( NumMpInUnit <= ((double)MM_MP_VAL + (double)MP_MP_VAL))  &&  ( dp > 1 ) )
01860         dp  =  1;
01861 
01862     // If the value to 2dp is 1.00, use the singular unit name
01863     // (Only applicable when ExpandUnitName is TRUE)
01864 //  Plural = (abs((INT32)((ScaledValue+0.005)*100.0)) != 100);
01865 
01866     // Get the specifier of the units we're in
01867     Specifier = pScaleUnit->GetSpecifier();
01868 
01869     // Create the string to stick in an editable field (or wherever you like)
01870     if (UnitSpecifier)
01871     {
01872         if (dp<=100)
01873         {
01874             if (pScaleUnit->IsPrefix())
01875             {
01876                 // Prefix units required so print them first followed by the number
01877                 camSnprintf( p, 256, _T("%s%.*f"), (LPCTSTR) Specifier, (INT32) dp, (double)ScaledValue );      // uses * & FP
01878 
01879                 // Look for all zeros after decimal point and if so then remove
01880                 *pStr = p;
01881                 Convert::StripTrailingZeros(pStr);
01882             }
01883             else
01884             {
01885                 // Suffix units required so print number followed by units
01886                 // Used to do this in one go but makes life more difficult on the trailing
01887                 // zero supression front.
01888                 //_stprintf(p,"%.*f%s",dp,ScaledValue,(char*)Specifier);
01889                 camSnprintf( p, 256, _T("%.*f") , (INT32) dp, (double) ScaledValue );   // uses * & FP
01890 
01891                 // Look for all zeros after decimal point and if so then remove
01892                 *pStr = p;
01893                 Convert::StripTrailingZeros(pStr);
01894 
01895                 // And finally add the units in
01896                 *pStr += Specifier;
01897             }
01898         }
01899         else
01900         {
01901             if (pScaleUnit->IsPrefix())
01902             {
01903                 // Prefix units required so print them first followed by the number
01904                 camSnprintf( p, 256, _T("%s%.*g"), (LPCTSTR) Specifier, (INT32) dp-100, (double) ScaledValue);
01905 
01906                 // Look for all zeros after decimal point and if so then remove
01907                 *pStr = p;
01908             }
01909             else
01910             {
01911                 // Suffix units required so print number followed by units
01912                 camSnprintf( p, 256, _T("%.*g%s"), (INT32) dp-100, (double)ScaledValue, (LPCTSTR)Specifier );
01913 
01914                 // Look for all zeros after decimal point and if so then remove
01915                 *pStr = p;
01916             }
01917         }
01918     }
01919     else
01920     {
01921         if (dp<=100)
01922         {
01923             // No units so just output the value
01924             camSnprintf( p, 256, wxT("%.*f"), (INT32) dp, (double) ScaledValue);                                // uses * & FP
01925 
01926             // Look for all zeros after decimal point and if so then remove
01927             *pStr = p;
01928             Convert::StripTrailingZeros(pStr);
01929         }
01930         else
01931         {
01932             // No units so just output the value
01933             camSnprintf( p, 256, wxT("%.*g"), (INT32) dp-100, (double)ScaledValue );
01934 
01935             // Look for all zeros after decimal point and if so then remove
01936             *pStr = p;
01937         }
01938     }
01939 
01940     //*pStr = p;
01941 
01942     // Extra bodge required so that if the user has specified display values using
01943     // a non full stop to show decimal points then we must replace the point that
01944     // is present by the specified character.
01945     if (Convert::GetDecimalPointChar() != '.')
01946     {
01947         Convert::ReplaceDecimalPoint(pStr);
01948     }
01949 
01950     return TRUE;
01951 }

void DimScale::Deinit void   )  [static]
 

Initialises this class. Must be called before any other function in this class.

Author:
Mark_Neves (Xara Group Ltd) <camelotdev@xara.com>
Date:
28/6/94
Parameters:
- [INPUTS]
- [OUTPUTS]
Returns:
-
See also:
-

Definition at line 1470 of file convert.cpp.

01471 {
01472     if (pDefaultDimScale != NULL)
01473     {
01474         delete pDefaultDimScale;
01475         pDefaultDimScale = NULL;
01476     }
01477 }

String_32 DimScale::GetDrawingScaleStr  ) 
 

This is the string that the user has typed into the "Drawing scale" editable field of the scale factor dialog.

Author:
Mark_Neves (Xara Group Ltd) <camelotdev@xara.com>
Date:
22/6/94
Parameters:
- [INPUTS]
Returns:
The string that represents the document scale

Definition at line 1606 of file convert.cpp.

01607 {
01608     return DrawingScaleStr;
01609 }

DimScale * DimScale::GetPtrDefaultDimScale  )  [static]
 

Ptr to the default DimScale object that is returned by GetPtrDimScale if it can't find one in the tree.

Author:
Mark_Neves (Xara Group Ltd) <camelotdev@xara.com>
Date:
22/6/94
Parameters:
- [INPUTS]
Returns:
Ptr to the default DimScale
See also:
DimScale::GetPtrDimScale

Definition at line 2140 of file convert.cpp.

02141 {
02142     return pDefaultDimScale;
02143 }

DimScale * DimScale::GetPtrDimScale Node pNode  )  [static]
 

Ptr to a DimScale object that can be used to scale dimension values to and from internal millipoint values. The DimScale object is taken from the node's parent Spread. If a parent spread is not found or the spread's DimScale object is inactive, the default DimScale is returned.

Author:
Mark_Neves (Xara Group Ltd) <camelotdev@xara.com>
Date:
15/6/94
Parameters:
A ptr to a node in the tree [INPUTS]
Returns:
Ptr to a DimScale

Definition at line 2106 of file convert.cpp.

02107 {
02108     Spread*   pSpread;
02109     DimScale* pDimScale;
02110 
02111     if (!pNode->IsKindOf(CC_RUNTIME_CLASS(Spread)))
02112         pSpread = pNode->FindParentSpread();
02113     else
02114         pSpread = (Spread*)pNode;
02115 
02116     if (pSpread != NULL)
02117     {
02118         pDimScale = pSpread->GetPtrDimScale();
02119         if (pDimScale->IsActive())
02120             return pDimScale;
02121     }
02122 
02123     return (DimScale::GetPtrDefaultDimScale());
02124 }

String_32 DimScale::GetRealScaleStr  ) 
 

This is the string that the user has typed into the "Real scale" editable field of the scale factor dialog.

Author:
Mark_Neves (Xara Group Ltd) <camelotdev@xara.com>
Date:
22/6/94
Parameters:
- [INPUTS]
Returns:
The string that represents the document scale

Definition at line 1670 of file convert.cpp.

01671 {
01672     return RealScaleStr;
01673 }

double DimScale::GetScaleFactor  ) 
 

UnitType DimScale::GetScaleUnits  ) 
 

For getting hold of those pesky scale units.

Author:
Ed_Cornes (Xara Group Ltd) <camelotdev@xara.com>
Date:
18/10/95
Returns:
Scale units if active else NOTYPE (NOTYPE for error)

Definition at line 1534 of file convert.cpp.

01535 {
01536     if (IsActive()==FALSE)
01537         return NOTYPE;
01538 
01539     DocUnitList* pDocUnitList = DocUnitList::GetCurrentDocUnitList();
01540     ERROR2IF(pDocUnitList==NULL,NOTYPE,"DimScale::GetScaleUnits() - pDocUnitList==NULL");
01541 
01542     UnitType ScaleUnits = pDocUnitList->GetScaleUnits();
01543     if (ScaleUnits==AUTOMATIC)
01544     {
01545         double dummy = 1.0;
01546         BOOL ok = Convert::StringToComponents( RealScaleStr,&dummy,&ScaleUnits);
01547         if (!ok || ScaleUnits==NOTYPE)
01548             ScaleUnits = pDocUnitList->GetPageUnits();
01549     }
01550 
01551     return ScaleUnits;
01552 }

UnitType DimScale::GetUnits  ) 
 

For getting hold of those pesky units.

Author:
Ed_Cornes (Xara Group Ltd) <camelotdev@xara.com>
Date:
18/10/95
Returns:
Scale units if scaling active else page units (NOTYPE for error)

Definition at line 1511 of file convert.cpp.

01512 {
01513     UnitType Units=GetScaleUnits();
01514     if (Units==NOTYPE)
01515     {
01516         DocUnitList* pDocUnitList = DocUnitList::GetCurrentDocUnitList();
01517         ERROR2IF(pDocUnitList==NULL,NOTYPE,"DimScale::GetUnits() - pDocUnitList==NULL");
01518         Units = pDocUnitList->GetPageUnits();
01519     }
01520 
01521     return Units;
01522 }

BOOL DimScale::Init void   )  [static]
 

Initialises this class. Must be called before any other function in this class.

Author:
Mark_Neves (Xara Group Ltd) <camelotdev@xara.com>
Date:
22/6/94
Parameters:
- [INPUTS]
- [OUTPUTS]
Returns:
TRUE if successfully initialised
See also:
-

Reimplemented from SimpleCCObject.

Definition at line 1444 of file convert.cpp.

01445 {
01446     BOOL ok;
01447 
01448     pDefaultDimScale = new DimScale;
01449     ok = (pDefaultDimScale != NULL);
01450     if (ok) pDefaultDimScale->SetActiveState(FALSE);
01451 
01452     return ok;
01453 }

BOOL DimScale::IsActive  ) 
 

Interogate the active state of this object.

Author:
Mark_Neves (Xara Group Ltd) <camelotdev@xara.com>
Date:
14/6/94
Parameters:
- [INPUTS]
- [OUTPUTS]
Returns:
The active state of this object
See also:
-

Definition at line 1589 of file convert.cpp.

01590 {
01591     return (Active);
01592 }

DimScale & DimScale::operator= const DimScale other  ) 
 

Assignment (set equal to) operator.

Author:
Mark_Neves (Xara Group Ltd) <camelotdev@xara.com>
Date:
15/6/94
Parameters:
A reference to a constant DimScale. [INPUTS]
Returns:
A reference to this.

Definition at line 2057 of file convert.cpp.

02058 {
02059     Active          = other.Active;
02060     ScaleFactor     = other.ScaleFactor;
02061     DrawingScaleStr = other.DrawingScaleStr;
02062     RealScaleStr    = other.RealScaleStr;
02063 
02064     return *this;
02065 }

BOOL DimScale::operator== const DimScale other  ) 
 

Equivalence operator.

Author:
Mark_Neves (Xara Group Ltd) <camelotdev@xara.com>
Date:
15/6/94
Parameters:
A DimScale. [INPUTS]
Returns:
TRUE if they are identical in every way

Definition at line 2079 of file convert.cpp.

02080 {
02081 return (
02082             Active          == other.Active &&
02083             ScaleFactor     == other.ScaleFactor &&
02084             DrawingScaleStr == other.DrawingScaleStr &&
02085             RealScaleStr    == other.RealScaleStr
02086         );
02087 }

void DimScale::SetActiveState BOOL  State  ) 
 

Used to set the active state of this dimension scaling object. When inactive, no scaling is performed.

Author:
Mark_Neves (Xara Group Ltd) <camelotdev@xara.com>
Date:
14/6/94
Parameters:
State = Boolean value of activity [INPUTS]
- [OUTPUTS]
Returns:
-
See also:
-

Definition at line 1570 of file convert.cpp.

01571 {
01572     Active = State;
01573 }

BOOL DimScale::SetDrawingScaleStr String_32 NewStr  ) 
 

Allows the setting of a new string that is to be used as the drawing scaling factor. This has usually been typed in by the user into the "Drawing scale" editable field of the scale factor dialog. The string is attempted to be converted to a value and the value checked. If it is ok then TRUE is returned otherwise FALSE is returned.

Author:
Mark_Neves (Xara Group Ltd) <camelotdev@xara.com>
Date:
22/6/94
Parameters:
Reference to the new drawing scale string [INPUTS]
Returns:
TRUE if string represents a good value, FALSE otherwise.
This ***MUST *** not ERROR2 or set an error on bad values as the scale options tab code tries to produce a nice error for the user when they have entered incorrect values rather than completely incomprehensible internal errors.
See also:
ScaleTab::CommitSection; Document::ImportViewInfo;

Definition at line 1633 of file convert.cpp.

01634 {
01635     double Scale = 1.0;
01636     BOOL ok = TRUE;
01637     //changed char to TCHAR for DBCS
01638 //  TCHAR* p = DrawingScaleStr;     // for debugging purposes
01639 
01640     ok = ConvertToDouble( NewStr,&Scale);
01641     if (!ok)
01642         return FALSE;           // let the caller decide what error to show!  
01643     //ERROR2IF(!ok,FALSE,"DrawingScaleStr is bad!");
01644 
01645     // Check that the converted value is a real positive value and certainly not zero!
01646     if (Scale <= 0)
01647         return FALSE;
01648 
01649     // Only if everything went ok will we set the DrawingScaleStr to be the newly
01650     // specified value.
01651     if (ok)
01652         DrawingScaleStr = NewStr;
01653 
01654     return TRUE;
01655 }

BOOL DimScale::SetRealScaleStr String_32 NewStr  ) 
 

Allows the setting of a new string that is to be used as the real scaling factor. This has usually been typed in by the user into the "Real scale" editable field of the scale factor dialog. The string is attempted to be converted to a value and the value checked. If it is ok then TRUE is ereturned otherwise FALSE is returned.

Author:
Mark_Neves (Xara Group Ltd) <camelotdev@xara.com>
Date:
22/6/94
Parameters:
Reference to the new Real scale string [INPUTS]
Returns:
TRUE if string represents a good value, FALSE otherwise.
This ***MUST *** not ERROR2 or set an error on bad values as the scale options tab code tries to produce a nice error for the user when they have entered incorrect values rather than completely incomprehensible internal errors.
See also:
ScaleTab::CommitSection; Document::ImportViewInfo;

Definition at line 1697 of file convert.cpp.

01698 {
01699     double Scale = 1.0;
01700     BOOL ok;
01701     //From char to TCHAR for DBCS
01702 //  TCHAR* p = RealScaleStr;        // for debugging purposes
01703 
01704     ok = ConvertToDouble( NewStr,&Scale);
01705     if (!ok)
01706         return FALSE;           // let the caller decide what error to show!  
01707     //ERROR2IF(!ok,FALSE,"RealScaleStr is bad!"); VERY BAD!!!!
01708 
01709     // Check that the converted value is a real positive value and certainly not zero!
01710     if (Scale <= 0)
01711         return FALSE;
01712 
01713     // Only if everything went ok will we set the DrawingScaleStr to be the newly
01714     // specified value.
01715     if (ok)
01716         RealScaleStr = NewStr;
01717 
01718     return TRUE;
01719 }

BOOL DimScale::SetScaleFactor  ) 
 

Reads the DrawingScaleStr and RealScaleStr, which should specify the drawing and real scaling factors, and calculates the new scale factor from these. If either are negative or zero then it will return FALSE and no new scaling factor is set.

Author:
Mark_Neves (Xara Group Ltd) <camelotdev@xara.com>
Date:
22/6/94
Parameters:
- [INPUTS]
Returns:
TRUE if successfully converted and a new scaling factor set, FALSE otherwise.
This ***MUST *** not ERROR2 or set an error on bad values as the scale options tab code tries to produce a nice error for the user when they have entered incorrect values rather than completely incomprehensible internal errors.
See also:
ScaleTab::CommitSection; Document::ImportViewInfo;

Definition at line 1741 of file convert.cpp.

01742 {
01743     double  RealScale       = 1.0;
01744     double  DrawingScale    = 1.0;
01745     BOOL    ok              = TRUE;
01746     //char to TCHAR for DBCS
01747 //  TCHAR* pD = DrawingScaleStr;    // for debugging purposes
01748 //  TCHAR* pR = RealScaleStr;       // for debugging purposes
01749 
01750     RealScale = Convert::StringToDouble( RealScaleStr,GetUnits(),&ok);
01751     if (!ok)
01752         return FALSE;           // let the caller decide what error to show!  
01753     //ERROR2IF(!ok,FALSE,"RealScaleStr is bad!");
01754 
01755     // Check that the converted value is a real positive value and certainly not zero!
01756     if (RealScale <= 0)
01757         return FALSE;
01758 
01759     DrawingScale = Convert::StringToDouble( DrawingScaleStr,GetUnits(),&ok);
01760     if (!ok)
01761         return FALSE;           // let the caller decide what error to show!  
01762     //ERROR2IF(!ok,FALSE,"DrawingScaleStr is bad!");
01763 
01764     // Check that we are not going to get a division by zero error
01765     if (DrawingScale != 0)
01766         ScaleFactor = RealScale / DrawingScale;
01767     else
01768         return FALSE;
01769 
01770     return TRUE;
01771 }

BOOL DimScale::SetScaleFactor double  NewScaleFactor  ) 
 


Member Data Documentation

BOOL DimScale::Active [private]
 

Definition at line 260 of file convert.h.

String_32 DimScale::DrawingScaleStr [private]
 

Definition at line 262 of file convert.h.

String_32 DimScale::RealScaleStr [private]
 

Definition at line 263 of file convert.h.

double DimScale::ScaleFactor [private]
 

Definition at line 261 of file convert.h.


The documentation for this class was generated from the following files:
Generated on Sat Nov 10 03:53:40 2007 for Camelot by  doxygen 1.4.4