grid.cpp File Reference

(r1785/r1361)

#include "camtypes.h"
#include <math.h>
#include "osrndrgn.h"
#include "paper.h"
#include "grid.h"
#include "chapter.h"
#include "cxftags.h"
#include "unitcomp.h"

Go to the source code of this file.

Defines

#define Swap(a, b)   { (a)^=(b), (b)^=(a), (a)^=(b); }
#define new   CAM_DEBUG_NEW

Functions

static double mod (double n, double d)
static double sgn (double n)
static UnitType GetDominantUnit (UnitType ThisUnit)
static double GetUnitMultiple (UnitType Units)

Variables

const UINT32 MIN_PIX_RENDER_COUNT = 10
const UINT32 PIX_CROSSHAIR_SIZE = 2
const INT32 GRID_REND_FACTOR = 128


Define Documentation

#define new   CAM_DEBUG_NEW
 

Definition at line 157 of file grid.cpp.

#define Swap a,
 )     { (a)^=(b), (b)^=(a), (a)^=(b); }
 

Definition at line 137 of file grid.cpp.


Function Documentation

static UnitType GetDominantUnit UnitType  ThisUnit  )  [static]
 

Definition at line 2783 of file grid.cpp.

02784 {
02785 //  for (INT32 u=0;(u<NUM_DEFAULT_UNIT_TYPES) && (UnitDataList[u].Units != Units);u++) ;
02786 //  if (u >= NUM_DEFAULT_UNIT_TYPES) return NOTYPE; else return UnitDataList[u].DominantUnit;
02787 
02788     DocUnitList* pDocUnitList = DocUnitList::GetCurrentDocUnitList();
02789     Unit* pThisUnit = pDocUnitList->FindUnit(ThisUnit);
02790     double NumMills = pThisUnit->GetMillipoints();
02791 
02792     UnitType ThisUnitBaseType = pThisUnit->GetBaseUnitType();
02793     if (ThisUnitBaseType != NOTYPE)
02794     {
02795         Unit*  pBaseUnit = pDocUnitList->FindUnit(pThisUnit->GetBaseUnitType());
02796 
02797         if (NumMills < pBaseUnit->GetMillipoints())
02798             return (pBaseUnit->GetUnitType());
02799     }
02800 
02801     INT32 NumUnits = pDocUnitList->GetNumUnits();
02802     INT32 u;
02803     double   ResultMills = 1.7E308;
02804     UnitType ResultUnitType = NOTYPE;
02805 
02806     for (u=0;u < NumUnits;u++)
02807     {
02808         Unit* pUnit = pDocUnitList->FindUnit(u);
02809         UnitType BaseUnitType = pUnit->GetBaseUnitType();
02810 
02811         if (BaseUnitType != NOTYPE)
02812         {
02813             if (BaseUnitType == ThisUnit)
02814             {
02815                 double m = pUnit->GetMillipoints();
02816                 if ((m > NumMills) && (m < ResultMills))
02817                 {
02818                     ResultMills = m;
02819                     ResultUnitType = pUnit->GetUnitType();
02820                 }
02821             }
02822         }
02823     }
02824 
02825     return ResultUnitType;
02826 }

static double GetUnitMultiple UnitType  Units  )  [static]
 

Definition at line 2828 of file grid.cpp.

02829 {
02830 //  for (INT32 u=0;(u<NUM_DEFAULT_UNIT_TYPES) && (UnitDataList[u].Units != Units);u++) ;
02831 //  if (u >= NUM_DEFAULT_UNIT_TYPES) return 1; else return UnitDataList[u].Multiple;
02832 
02833     UnitType DomUnitType = ::GetDominantUnit(Units);
02834 
02835     if (DomUnitType == NOTYPE)
02836         return 2.0;
02837 
02838     DocUnitList* pDocUnitList = DocUnitList::GetCurrentDocUnitList();
02839     Unit* pUnit    = pDocUnitList->FindUnit(Units);
02840     Unit* pDomUnit = pDocUnitList->FindUnit(DomUnitType);
02841     double Multiple;
02842     
02843     if (pUnit->GetBaseUnitType() == pDomUnit->GetUnitType())
02844         Multiple = pUnit->GetBaseDenominator()  / pUnit->GetBaseNumerator();
02845     else
02846         Multiple = pDomUnit->GetBaseNumerator() / pDomUnit->GetBaseDenominator();
02847 
02848     if (Multiple <= 1.0)
02849         return 2.0;
02850     else
02851         return Multiple;
02852 }

static double mod double  n,
double  d
[static]
 

Definition at line 131 of file grid.cpp.

00131 { double temp; return (modf(n/d,&temp)*d);}

static double sgn double  n  )  [static]
 

Definition at line 132 of file grid.cpp.

00132 { if (n<0) return (-1); else return (1); }


Variable Documentation

const INT32 GRID_REND_FACTOR = 128
 

Definition at line 129 of file grid.cpp.

const UINT32 MIN_PIX_RENDER_COUNT = 10
 

Definition at line 127 of file grid.cpp.

const UINT32 PIX_CROSSHAIR_SIZE = 2
 

Definition at line 128 of file grid.cpp.


Generated on Sat Nov 10 03:49:11 2007 for Camelot by  doxygen 1.4.4