NodeGridIso Class Reference

A class defining an isometric grid node. More...

#include <grid.h>

Inheritance diagram for NodeGridIso:

NodeGrid NodeRenderablePaper NodeRenderableBounded NodeRenderable Node CCObject SimpleCCObject List of all members.

Public Member Functions

 NodeGridIso ()
 This constructor creates a NodeGridIso linked to no other nodes, with all status flags false, and NULL bounding and pasteboard rectangles.
String Describe (BOOL Plural, BOOL Verbose)
 To return a description of the Node object in either the singular or the plural. This method is called by the DescribeRange method.
void Render (RenderRegion *pRender)
 Renders the isometric grid item.
void GetDebugDetails (StringBase *Str)
 For obtaining debug information about the Node.
BOOL Snap (DocCoord *pDocCoord)
 Snaps to given coord to the nearest grid point. If it is not appropriate to snap the coord to the grid (at the moment this means the coord lies outside the grid object's bounding box), then FALSE is returned.
BOOL Snap (DocCoord *pDocCoord, double Step)
 Same as Snap(pDocCoord), except the coord is snapped to grid points at the given intervals.
BOOL Snap (DocRect *pDocRect, const DocCoord &PrevCoord, const DocCoord &CurCoord)
 Snaps the given rect to the nearest position on the grid, preserving its width and height. The coords of the rect used for the snapping are determined by the PrevCoord and CurCoord coords supplied. This is done to allow the user to control how a selection rectangle is snapped to the grid by the direction of his/her last mouse movement. To force the bottom left hand corner of the rect to be snapped, supply PrevCoord=(0,0) and CurCoord(-1,-1). Scope: public.
BOOL SetGridParams (double Div, UINT32 SubDiv, UnitType Units, BOOL Scale=TRUE)
 Defines the grid.
double GetDivisions (BOOL Scale=TRUE)
 Used to get the number of Units between each main grid point.
UINT32 GetSubdivisions ()
 Used to get the number of subdivisions between each main grid point.
UnitType GetUnits (BOOL Scale=TRUE)
 Gets the units used by the grid.
GridType GetGridType ()
double GetMainStep ()
NodeSimpleCopy ()
 This method returns a shallow copy of the node with all Node pointers NULL. The function is virtual, and must be defined for all derived classes.
virtual UINT32 GetNodeSize () const
 For finding the size of a node, in concrete classes derived from Node.
virtual void PolyCopyNodeContents (NodeRenderable *pNodeCopy)
 Polymorphically copies the contents of this node to another.

Protected Member Functions

void CopyNodeContents (NodeGridIso *NodeCopy)
 This method copies the node's contents to the node pointed to by NodeCopy.

Private Member Functions

void RenderPoints (RenderRegion *pRender, DocRect RendRect, MILLIPOINT pixelWidth)
 Renders the grid points within the given renderable rectangle.
void RenderSubPoints (RenderRegion *pRender, const DocCoord &MainGridPoint, MILLIPOINT MainRenderStep, MILLIPOINT SubRenderStep, MILLIPOINT pixelWidth, DocRect &ScaledBB)
 Renders the sub grid points from the given main point.
MILLIPOINT CalcYOrigin (MILLIPOINT x, double Step)
 The Y origin used for snapping Y coords alternates between YOrigin and YOrigin+(Step/2) depending on a point's snapped x coord. This function returns the correct one to use.

Private Attributes

double MainStep
double SubStep
UnitType Units
double Divisions
UINT32 Subdivisions

Detailed Description

A class defining an isometric grid node.

Author:
Mark_Neves (Xara Group Ltd) <camelotdev@xara.com>
Date:
8/2/94 Base Classes: NodeGrid, NodeRenderablePaper, NodeRenderable, Node, CCObject
See the Node class for an important note about producing derived classes of Node.

See also:
NodeGrid, NodeRenderablePaper

Definition at line 379 of file grid.h.


Constructor & Destructor Documentation

NodeGridIso::NodeGridIso  ) 
 

This constructor creates a NodeGridIso linked to no other nodes, with all status flags false, and NULL bounding and pasteboard rectangles.

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

Errors:

Definition at line 1680 of file grid.cpp.

01680                         : NodeGrid()
01681 {   
01682     Units        = INCHES;
01683     Divisions    = 1.0;
01684     Subdivisions = 4;
01685 
01686     MainStep = 72000.0;
01687     SubStep = MainStep/Subdivisions;
01688 }                    


Member Function Documentation

MILLIPOINT NodeGridIso::CalcYOrigin MILLIPOINT  x,
double  Step
[private]
 

The Y origin used for snapping Y coords alternates between YOrigin and YOrigin+(Step/2) depending on a point's snapped x coord. This function returns the correct one to use.

Author:
Mark_Neves (Xara Group Ltd) <camelotdev@xara.com>
Date:
16/2/94
Parameters:
x = Snapped x coord [INPUTS] Step = step rate of underlying grid
[OUTPUTS] 
Returns:
The Y origin that should be used to snap Y coords to the grid

Errors: Scope: private

Definition at line 2189 of file grid.cpp.

02190 {
02191     double xdist = mod((double)(x-XOrigin),Step*2); 
02192     if (xdist<0) xdist = 0-xdist;
02193 
02194     if ((xdist > (Step/2)) && (xdist < ((Step*2)-(Step/2))) )
02195         return YOrigin+((MILLIPOINT)((Step/2)+0.5));
02196     else
02197         return YOrigin;
02198 
02199 
02200 /*
02201     MILLIPOINT xdist =  abs((x-XOrigin) % (Step*2));
02202 
02203     if ((xdist > (Step/2)) && (xdist < ((Step*2)-(Step/2))) )
02204         return YOrigin+(Step/2);
02205     else
02206         return YOrigin;
02207 */
02208 }

void NodeGridIso::CopyNodeContents NodeGridIso NodeCopy  )  [protected]
 

This method copies the node's contents to the node pointed to by NodeCopy.

Author:
Mark_Neves (Xara Group Ltd) <camelotdev@xara.com>
Date:
15/2/94
Parameters:
- [INPUTS]
A copy of this node [OUTPUTS]
Returns:
-

Errors: An assertion failure will occur if NodeCopy is NULL

Scope: protected

Definition at line 2259 of file grid.cpp.

02260 {
02261     ENSURE(NodeCopy != NULL,"Trying to copy a NodeGridIso's contents to a NULL node");  
02262     NodeGrid::CopyNodeContents(NodeCopy); 
02263 
02264     NodeCopy->MainStep      = this->MainStep;
02265     NodeCopy->SubStep       = this->SubStep;    
02266 
02267     NodeCopy->Units         = this->Units;
02268     NodeCopy->Divisions     = this->Divisions;
02269     NodeCopy->Subdivisions  = this->Subdivisions;
02270 }

String NodeGridIso::Describe BOOL  Plural,
BOOL  Verbose
[virtual]
 

To return a description of the Node object in either the singular or the plural. This method is called by the DescribeRange method.

Author:
Mark_Neves (Xara Group Ltd) <camelotdev@xara.com>
Date:
15/2/94
Parameters:
Plural,: Flag indicating if the string description should be plural or [INPUTS] singular.
- [OUTPUTS] Retuns: Description of the object
The description will always begin with a lower case letter.

Returns:
Errors: A resource exception will be thrown if a problem occurs when loading the string resource.
See also:
-

Reimplemented from NodeGrid.

Definition at line 1718 of file grid.cpp.

01719 {   
01720     if (Plural)
01721         return (String(_R(IDS_GRIDISO_DESCRP)));
01722     else
01723         return (String(_R(IDS_GRIDISO_DESCRS)));
01724 }; 

void NodeGridIso::GetDebugDetails StringBase Str  )  [virtual]
 

For obtaining debug information about the Node.

Author:
Mark_Neves (Xara Group Ltd) <camelotdev@xara.com>
Date:
15/2/94
Parameters:
- [INPUTS]
Str,: String giving debug info about the node [OUTPUTS]
Returns:
-

Errors: -

See also:
-

Reimplemented from NodeGrid.

Definition at line 2312 of file grid.cpp.

02313 {          
02314     NodeGrid::GetDebugDetails(Str); 
02315 }

double NodeGridIso::GetDivisions BOOL  Scale = TRUE  )  [virtual]
 

Used to get the number of Units between each main grid point.

Author:
Ed_Cornes (Xara Group Ltd) <camelotdev@xara.com>
Date:
17/10/95
Parameters:
Scale - account for scaling (only FALSE when saving for doc compatibility) [INPUTS]
Returns:
Number of Units between each main grid point

Reimplemented from NodeGrid.

Definition at line 2412 of file grid.cpp.

02413 {
02414     return NodeGrid::CalcDivisions(Scale);
02415 }

GridType NodeGridIso::GetGridType  )  [inline, virtual]
 

Reimplemented from NodeGrid.

Definition at line 406 of file grid.h.

00406 { return ISOMETRIC; }

double NodeGridIso::GetMainStep  )  [inline, virtual]
 

Reimplemented from NodeGrid.

Definition at line 408 of file grid.h.

00408 { return MainStep; }

virtual UINT32 NodeGridIso::GetNodeSize  )  const [inline, virtual]
 

For finding the size of a node, in concrete classes derived from Node.

Author:
Simon_Maneggio (Xara Group Ltd) <camelotdev@xara.com>
Date:
6/10/93
Parameters:
- [INPUTS]
- [OUTPUTS]
Returns:
The size of the node in bytes

Errors: If this function has not been overloaded in a non-abstract class then an ENSURE failure will occur.

See also:
-

Reimplemented from NodeGrid.

Definition at line 411 of file grid.h.

00411 { return sizeof(*this); }

UINT32 NodeGridIso::GetSubdivisions  )  [virtual]
 

Used to get the number of subdivisions between each main grid point.

Author:
Mark_Neves (Xara Group Ltd) <camelotdev@xara.com>
Date:
1/3/94
Parameters:
- [INPUTS]
- [OUTPUTS]
Returns:
Num subdivisions

Errors: -

See also:
-

Reimplemented from NodeGrid.

Definition at line 2433 of file grid.cpp.

02434 {
02435     return Subdivisions;
02436 }

UnitType NodeGridIso::GetUnits BOOL  Scale = TRUE  )  [virtual]
 

Gets the units used by the grid.

Author:
Ed_Cornes (Xara Group Ltd) <camelotdev@xara.com>
Date:
20/10/95
Parameters:
Scale - account for unit scaling (only FALSE when saving for compatibility with old docs) [INPUTS]
Returns:
Units used by the grid

Reimplemented from NodeGrid.

Definition at line 2448 of file grid.cpp.

02449 {
02450     DimScale* pDimScale = DimScale::GetPtrDimScale(this);
02451     ERROR2IF(pDimScale==NULL,NOTYPE,"NodeGridIso::GetUnits() - pDimScale==NULL");
02452 
02453     // if scaling turned on return scale units
02454     // (except if scaling is not to be accounted for  - ie during saving for compatibility with old docs)
02455     UnitType ScaleUnits = pDimScale->GetScaleUnits();
02456     if (Scale && ScaleUnits!=NOTYPE)
02457         return ScaleUnits;
02458 
02459     return Units;
02460 }

void NodeGridIso::PolyCopyNodeContents NodeRenderable pNodeCopy  )  [virtual]
 

Polymorphically copies the contents of this node to another.

Author:
Phil_Martin (Xara Group Ltd) <camelotdev@xara.com>
Date:
18/12/2003
Parameters:
- [OUTPUTS]
Returns:
Errors: An assertion failure will occur if NodeCopy is NULL Scope: protected

Reimplemented from NodeGrid.

Definition at line 2285 of file grid.cpp.

02286 {
02287     ENSURE(pNodeCopy, "Trying to copy a node's contents into a NULL node");
02288     ENSURE(IS_A(pNodeCopy, NodeGridIso), "PolyCopyNodeContents given wrong dest node type");
02289 
02290     if (IS_A(pNodeCopy, NodeGridIso))
02291         CopyNodeContents((NodeGridIso*)pNodeCopy);
02292 }

void NodeGridIso::Render RenderRegion pRender  )  [virtual]
 

Renders the isometric grid item.

Author:
Mark_Neves (Xara Group Ltd) <camelotdev@xara.com>
Date:
15/2/94
Parameters:
pRender = a render region [INPUTS]
- [OUTPUTS]
Returns:
-

Errors: -

See also:
-

Reimplemented from NodeGrid.

Definition at line 1743 of file grid.cpp.

01744 {      
01745 #if !defined(EXCLUDE_FROM_RALPH)
01746     if (IsDisabled()) return;
01747 
01748     View* pView = pRender->GetRenderView();
01749     if ((pView == NULL) || (!IS_A(pView, DocView)))
01750         // No docview to render to.
01751         return;
01752 
01753     DocView *pDocView = (DocView *) pView;
01754 
01755     if (!pDocView->GetShowGridState() && Tool::GetCurrentID() != TOOLID_GRID) return;
01756 
01757     // Set up attributes for drawing grid points
01758     pRender->SaveContext();
01759 // Don't setup for line rendering because grid points now rendered as filled rects...
01760 //  pRender->SetLineWidth(0);                               // Means single-pixel lines
01761 //  pRender->SetLineColour(GridColour);                     // Grid blobs are in this colour
01762 
01763     // Setup for rendering grid point rects...
01764     pRender->SetLineWidth(0);
01765     pRender->SetLineColour(COLOUR_TRANS); 
01766     pRender->SetFillColour(GridColour);
01767         
01768     DocRect ClipRect = pRender->GetClipRect();              // Get the current clip rect
01769     DocRect RendRect;
01770 
01771     RendRect.lo.x = max(GridBoundingRect.lo.x,ClipRect.lo.x);   // hi and lo renderable grid points
01772     RendRect.lo.y = max(GridBoundingRect.lo.y,ClipRect.lo.y);   // derived from the clip rect and the 
01773     RendRect.hi.x = min(GridBoundingRect.hi.x,ClipRect.hi.x);   // node's bounding rect
01774     RendRect.hi.y = min(GridBoundingRect.hi.y,ClipRect.hi.y);
01775 
01776     if (RendRect.IsValid())
01777     {
01778         MILLIPOINT PixelWidth = pRender->GetScaledPixelWidth(); // the width of a single pixel 
01779 
01780         RenderPoints(pRender,RendRect,PixelWidth);          // Render the grid points (crosshairs and sub grid dots)
01781     }
01782 
01783     pRender->RestoreContext();
01784 #endif
01785 }  

void NodeGridIso::RenderPoints RenderRegion pRender,
DocRect  RendRect,
MILLIPOINT  PixelWidth
[private]
 

Renders the grid points within the given renderable rectangle.

Author:
Mark_Neves (Xara Group Ltd) <camelotdev@xara.com>
Date:
15/2/94
Parameters:
pRender = region to render to [INPUTS] RendRect = Rectangle defining the renderable portion of the grid PixelWidth = width of a pixel in millipoints
[OUTPUTS] 
Returns:

Errors: Scope: private

Definition at line 1805 of file grid.cpp.

01806 {
01807 #if !defined(EXCLUDE_FROM_RALPH)
01808     TRACEUSER( "MarkN", _T("\n------------------\nNodeGridIso::RenderPoints\n\n"));
01809 
01810     // Set the fp render step value to be the underlying main grid step value
01811     double fp_MainRenderStep = MainStep;
01812 
01813     // Calculate the step for rendering the grid in relation to the width of a pixel and the
01814     // multiples of the dominant unit
01815     CalcGridRenderSteps(PixelWidth,&fp_MainRenderStep,fp_MainRenderStep*::GetUnitMultiple(Units),Units);
01816 
01817     // Snap the render rect to these adjusted steps so we render all points within the renderable
01818     // portion of the grid
01819 
01820     Snap(&RendRect.lo,fp_MainRenderStep);
01821     Snap(&RendRect.hi,fp_MainRenderStep);
01822     BOOL YOffAdjust = FALSE; // YOffAdjust = FALSE because we have snapped exactly to the main grid
01823     
01824     if (RendRect.lo.x > RendRect.hi.x) Swap(RendRect.lo.x,RendRect.hi.x);
01825     if (RendRect.lo.y > RendRect.hi.y) Swap(RendRect.lo.y,RendRect.hi.y);
01826 
01827     ENSURE(RendRect.IsValid(),"RendRect is invalid in NodeGridIso::RenderPoints");
01828 
01829     // Set the fp sub render step value to be the underlying sub grid step value
01830     double fp_SubRenderStep = SubStep;
01831     CalcGridRenderSteps(PixelWidth,&fp_SubRenderStep,fp_MainRenderStep,Units);
01832     if (fp_SubRenderStep >= fp_MainRenderStep)  fp_SubRenderStep = 0;
01833 
01834     // Get fixed point versions of the fp values for speedy grid rendering
01835     MILLIPOINT MainRenderStep = (MILLIPOINT)((fp_MainRenderStep * GRID_REND_FACTOR)+0.5);
01836     MILLIPOINT SubRenderStep  = (MILLIPOINT)((fp_SubRenderStep  * GRID_REND_FACTOR)+0.5);
01837 
01838     // Convert RendRect to fixed point values
01839     RendRect.lo.x *= GRID_REND_FACTOR;
01840     RendRect.lo.y *= GRID_REND_FACTOR;
01841     RendRect.hi.x *= GRID_REND_FACTOR;
01842     RendRect.hi.y *= GRID_REND_FACTOR;
01843 
01844     DocRect ScaledBB = GridBoundingRect;
01845     ScaledBB.lo.x *= GRID_REND_FACTOR;
01846     ScaledBB.lo.y *= GRID_REND_FACTOR;
01847     ScaledBB.hi.x *= GRID_REND_FACTOR;
01848     ScaledBB.hi.y *= GRID_REND_FACTOR;
01849 
01850     RendRect.Inflate(MainRenderStep); YOffAdjust = !YOffAdjust;
01851 
01852     // Make sure the render rectangle region doesn't lie outside the bounding rect
01853     while (RendRect.lo.x <  ScaledBB.lo.x) { RendRect.lo.x += MainRenderStep; YOffAdjust = !YOffAdjust; }
01854     while (RendRect.lo.y <  ScaledBB.lo.y)   RendRect.lo.y += MainRenderStep;
01855     while (RendRect.hi.x >  ScaledBB.hi.x)   RendRect.hi.x -= MainRenderStep;
01856     while (RendRect.hi.y >  ScaledBB.hi.y)   RendRect.hi.y -= MainRenderStep;
01857 
01858     RendRect.lo.x -= MainRenderStep;  YOffAdjust = !YOffAdjust;     // Need to plot to left of BB for sub grid dots
01859     RendRect.lo.y -= MainRenderStep;                            // Need to plot underneath BB for sub grid dots
01860 
01861     RendRect.hi.x += GRID_REND_FACTOR; // compensate for errors (i.e. add the bodge factor)
01862     RendRect.hi.y += GRID_REND_FACTOR; // compensate for errors
01863 
01864     RendRect.hi.y += MainRenderStep;
01865 
01866     // Render those grid points boy!
01867 
01868     DocCoord    GridPoint,TrueGridPoint;
01869     MILLIPOINT  yoff;
01870 
01871     const MILLIPOINT Pix = pRender->GetScaledPixelWidth();
01872 //  const MILLIPOINT PixBy2 = Pix/2;
01873     const MILLIPOINT Length = PIX_CROSSHAIR_SIZE * Pix;
01874 
01875     for (GridPoint.x=RendRect.lo.x;GridPoint.x<=RendRect.hi.x;GridPoint.x+=MainRenderStep)
01876     {
01877         if (YOffAdjust) yoff = MainRenderStep/2; else yoff = 0;
01878 
01879         RendRect.lo.y += yoff;
01880         RendRect.hi.y += yoff;
01881 
01882         for (GridPoint.y=RendRect.lo.y;GridPoint.y<=RendRect.hi.y;GridPoint.y+=MainRenderStep)
01883         {
01884             if (ScaledBB.ContainsCoord(GridPoint))
01885             {
01886                 // Scale the fixed point grid coord down to get the true coord of the grid point
01887                 TrueGridPoint.x = (GridPoint.x+(GRID_REND_FACTOR/2)) / GRID_REND_FACTOR;
01888                 TrueGridPoint.y = (GridPoint.y+(GRID_REND_FACTOR/2)) / GRID_REND_FACTOR;
01889 
01890 //              pRender->DrawCross(TrueGridPoint,PIX_CROSSHAIR_SIZE);
01891                 // Phil says: Don't use DrawPixel because it can't be trusted to plot the
01892                 // same pixel under GDI as it does under GDraw!
01893                 // Instead draw two rectangles centered around the required coord.
01894                 DocRect Horz(TrueGridPoint.x-Length, TrueGridPoint.y,TrueGridPoint.x+Length+Pix,TrueGridPoint.y+Pix);
01895                 pRender->DrawRect(&Horz);
01896 
01897                 DocRect Vert(TrueGridPoint.x, TrueGridPoint.y-Length,TrueGridPoint.x+Pix,TrueGridPoint.y+Length+Pix);
01898                 pRender->DrawRect(&Vert);
01899             }
01900 
01901             if (SubRenderStep != 0) 
01902                 RenderSubPoints(pRender,GridPoint,MainRenderStep,SubRenderStep,PixelWidth,ScaledBB);
01903         }
01904 
01905         RendRect.lo.y -= yoff;
01906         RendRect.hi.y -= yoff;
01907 
01908         YOffAdjust = !YOffAdjust;
01909     }
01910 #endif
01911 }

void NodeGridIso::RenderSubPoints RenderRegion pRender,
const DocCoord MainGridPoint,
MILLIPOINT  MainRenderStep,
MILLIPOINT  SubRenderStep,
MILLIPOINT  pixelWidth,
DocRect ScaledBB
[private]
 

Renders the sub grid points from the given main point.

Author:
Mark_Neves (Xara Group Ltd) <camelotdev@xara.com>
Date:
15/2/94
Parameters:
pRender = region to render to [INPUTS] MainGridPoint = coord of a main grid cross hair point (Scaled up by GRID_REND_FACTOR) MainRenderStep = step for rendering the main grid points (Scaled up by GRID_REND_FACTOR) SubRenderStep = step for rendering the sub grid points (Scaled up by GRID_REND_FACTOR) PixelWidth = width of a single pixel ScaledBB = The bounding rect of grid scaled up by GRID_REND_FACTOR
[OUTPUTS] 
Returns:

Errors: Scope: private

Definition at line 1940 of file grid.cpp.

01946 {
01947 #if !defined(EXCLUDE_FROM_RALPH)
01948     DocCoord SubGridPoint,TrueSubGridPoint;
01949     MILLIPOINT maxx,maxy;
01950 
01951     // Render the vertical sub grid dots from this point to the one above
01952     SubGridPoint.x = MainGridPoint.x;
01953     SubGridPoint.y = MainGridPoint.y+SubRenderStep;
01954     maxy = MainGridPoint.y+MainRenderStep;
01955 
01956     const MILLIPOINT Pix = pRender->GetScaledPixelWidth();
01957 //  const MILLIPOINT PixBy2 = Pix/2;
01958 
01959     while (SubGridPoint.y < maxy)
01960     {
01961         if (ScaledBB.ContainsCoord(SubGridPoint))
01962         {
01963             // Scale the fixed point grid coord down to get the true coord of the grid point
01964             TrueSubGridPoint.x = (SubGridPoint.x+(GRID_REND_FACTOR/2)) / GRID_REND_FACTOR;
01965             TrueSubGridPoint.y = (SubGridPoint.y+(GRID_REND_FACTOR/2)) / GRID_REND_FACTOR;
01966 //          pRender->DrawPixel(TrueSubGridPoint);
01967             // Phil says: Don't use DrawPixel because it can't be trusted to plot the
01968             // same pixel under GDI as it does under GDraw!
01969             // Instead draw a rectangle 1*1 pixels around the required coord.
01970             DocRect Pixel(  TrueSubGridPoint.x,
01971                             TrueSubGridPoint.y,
01972                             TrueSubGridPoint.x+Pix,
01973                             TrueSubGridPoint.y+Pix);
01974             pRender->DrawRect(&Pixel);
01975         }
01976         SubGridPoint.y += SubRenderStep;
01977     }
01978 
01979     // Render the diagonal dots from this point to the one to the right and up
01980     SubGridPoint.x = MainGridPoint.x+SubRenderStep;
01981     SubGridPoint.y = MainGridPoint.y+(SubRenderStep/2);
01982     maxx = MainGridPoint.x+MainRenderStep;
01983 
01984     while (SubGridPoint.x < maxx)
01985     {
01986         if (ScaledBB.ContainsCoord(SubGridPoint))
01987         {
01988             // Scale the fixed point grid coord down to get the true coord of the grid point
01989             TrueSubGridPoint.x = (SubGridPoint.x+(GRID_REND_FACTOR/2)) / GRID_REND_FACTOR;
01990             TrueSubGridPoint.y = (SubGridPoint.y+(GRID_REND_FACTOR/2)) / GRID_REND_FACTOR;
01991 
01992 //          pRender->DrawPixel(TrueSubGridPoint);
01993             // Phil says: Don't use DrawPixel because it can't be trusted to plot the
01994             // same pixel under GDI as it does under GDraw!
01995             // Instead draw a rectangle 1*1 pixels around the required coord.
01996             DocRect Pixel(  TrueSubGridPoint.x,
01997                             TrueSubGridPoint.y,
01998                             TrueSubGridPoint.x+Pix,
01999                             TrueSubGridPoint.y+Pix);
02000             pRender->DrawRect(&Pixel);
02001         }
02002         SubGridPoint.x += SubRenderStep;
02003         SubGridPoint.y += SubRenderStep/2;
02004     }
02005 
02006     // Render the diagonal dots from this point to the one to the right and down
02007     SubGridPoint.x = MainGridPoint.x+SubRenderStep;
02008     SubGridPoint.y = MainGridPoint.y-(SubRenderStep/2);
02009     maxx = MainGridPoint.x+MainRenderStep;
02010 
02011     while (SubGridPoint.x < maxx)
02012     {
02013         if (ScaledBB.ContainsCoord(SubGridPoint))
02014         {
02015             // Scale the fixed point grid coord down to get the true coord of the grid point
02016             TrueSubGridPoint.x = (SubGridPoint.x+(GRID_REND_FACTOR/2)) / GRID_REND_FACTOR;
02017             TrueSubGridPoint.y = (SubGridPoint.y+(GRID_REND_FACTOR/2)) / GRID_REND_FACTOR;
02018 
02019 //          pRender->DrawPixel(TrueSubGridPoint);
02020             // Phil says: Don't use DrawPixel because it can't be trusted to plot the
02021             // same pixel under GDI as it does under GDraw!
02022             // Instead draw a rectangle 1*1 pixels around the required coord.
02023             DocRect Pixel(  TrueSubGridPoint.x,
02024                             TrueSubGridPoint.y,
02025                             TrueSubGridPoint.x+Pix,
02026                             TrueSubGridPoint.y+Pix);
02027             pRender->DrawRect(&Pixel);
02028         }
02029         SubGridPoint.x += SubRenderStep;
02030         SubGridPoint.y -= SubRenderStep/2;
02031     }
02032 #endif
02033 }

BOOL NodeGridIso::SetGridParams double  Div,
UINT32  Subdiv,
UnitType  NewUnits,
BOOL  Scale = TRUE
[virtual]
 

Defines the grid.

Author:
Ed_Cornes (Xara Group Ltd) <camelotdev@xara.com>
Date:
16/10/95
Parameters:
Div - Number of Units between each main step of the grid [INPUTS] Subdiv - Number of subdivisions between each main grid point NewUnits - The units the grid is defined in Scale - account for unit scaling (only FALSE when loading for compatibility with old docs)
Returns:
FALSE if fails

Reimplemented from NodeGrid.

Definition at line 2345 of file grid.cpp.

02346 {
02347     if (Div < 0)
02348     {
02349         ERROR3("NodeGridIso::SetGridParams() - Div < 0!");
02350         Div = 0.0;
02351     }
02352     if (Subdiv < 1)
02353     {
02354         ERROR3("NodeGridIso::SetGridParams() - SubDiv < 1!");
02355         Subdiv = 1;
02356     }
02357 
02358     DimScale* pDimScale = DimScale::GetPtrDimScale(this);
02359     ERROR2IF(pDimScale==NULL,FALSE,"NodeGridRect::SetGridParams() - pDimScale==NULL");
02360 
02361     // set the raw values in the grid - but only set units if scaling turned off
02362     // (except if scaling is not to be accounted for  - ie during loading for compatibility with old docs - yuk!)
02363     Divisions    = Div;
02364     Subdivisions = Subdiv;
02365     if (Scale==FALSE || pDimScale->GetScaleUnits()==NOTYPE)
02366         Units = NewUnits;
02367 
02368     // convert the divisions and units into a millipoint grid spacing (accounting for unit scaling) - yuk!
02369     double GridSpacing=0;
02370     if (Scale)
02371     {
02372         BOOL ok = pDimScale->ComponentsToMillipoint(&GridSpacing, Divisions, GetUnits());
02373         if (!ok) return FALSE;
02374     }
02375     else
02376     {
02377         DocUnitList* pDocUnitList = DocUnitList::GetCurrentDocUnitList();
02378         ERROR2IF(pDocUnitList==NULL,FALSE,"DimScale::ComponentsToMillipoint() - pDocUnitList==NULL");
02379         Unit* pUnit = pDocUnitList->FindUnit(Units);
02380         ERROR2IF(pUnit==NULL,FALSE,"DimScale::ComponentsToMillipoint() - pUnit==NULL");
02381         GridSpacing = Div * pUnit->GetMillipoints();
02382     }
02383 
02384     if (GridSpacing<1)
02385     {
02386         ERROR3("NodeGridIso::SetGridParams() - GridSpacing < 1!");
02387         GridSpacing=1;
02388     }
02389 
02390     MainStep = GridSpacing;
02391     SubStep  = MainStep/Subdivisions;
02392     if (SubStep<1)
02393     {
02394         ERROR3("NodeGridIso::SetGridParams() - SubXStep < 1!");
02395         SubStep=1;
02396     }
02397 
02398     return TRUE;
02399 }

Node * NodeGridIso::SimpleCopy void   )  [virtual]
 

This method returns a shallow copy of the node with all Node pointers NULL. The function is virtual, and must be defined for all derived classes.

Author:
Mark_Neves (Xara Group Ltd) <camelotdev@xara.com>
Date:
15/2/94
Parameters:
- [INPUTS]
[OUTPUTS] 
Returns:
A copy of the node, or NULL if memory runs out

Errors: If memory runs out when trying to copy, then ERROR is called with an out of memory error and the function returns NULL.

Scope: public

Reimplemented from NodeGrid.

Definition at line 2231 of file grid.cpp.

02232 {
02233     NodeGridIso* NodeCopy = new NodeGridIso();   
02234     if (NodeCopy != NULL)
02235         CopyNodeContents(NodeCopy);   
02236     return (NodeCopy);
02237 }          

BOOL NodeGridIso::Snap DocRect pDocRect,
const DocCoord PrevCoord,
const DocCoord CurCoord
[virtual]
 

Snaps the given rect to the nearest position on the grid, preserving its width and height. The coords of the rect used for the snapping are determined by the PrevCoord and CurCoord coords supplied. This is done to allow the user to control how a selection rectangle is snapped to the grid by the direction of his/her last mouse movement. To force the bottom left hand corner of the rect to be snapped, supply PrevCoord=(0,0) and CurCoord(-1,-1). Scope: public.

Author:
Mark_Neves (Xara Group Ltd) <camelotdev@xara.com>
Date:
15/2/94
Parameters:
pDocCoord - the rectangle to snap [INPUTS] StartDrag - Start coord of drag EndDrag - End coord of drag
[OUTPUTS] 
Returns:
TRUE - the DocRect been snapped to the grid. FALSE - the DocRect has not been processed.

Reimplemented from NodeGrid.

Definition at line 2102 of file grid.cpp.

02103 {
02104     if (IsDisabled()) return FALSE;
02105 
02106     ENSURE(MainStep!=0,"MainStep==0 in NodeGridIso::Snap");
02107     ENSURE(SubStep !=0,"SubStep ==0 in NodeGridIso::Snap");
02108     
02109     INT32 xdir = CurCoord.x - PrevCoord.x;
02110     INT32 ydir = CurCoord.y - PrevCoord.y;
02111     INT32 x,y,prevx, prevy;
02112     
02113     if (LastXDir == 0)  LastXDir = xdir;
02114     if (xdir == 0)      xdir = LastXDir;
02115     LastXDir = xdir;
02116 
02117     if (xdir <= 0) x = pDocRect->lo.x; else x = pDocRect->hi.x;
02118 
02119     if (LastYDir == 0)  LastYDir = ydir;
02120     if (ydir == 0)      ydir = LastYDir;
02121     LastYDir = ydir;
02122 
02123     if (ydir <= 0) y = pDocRect->lo.y; else y = pDocRect->hi.y;
02124 
02125     if (!GridBoundingRect.ContainsCoord(DocCoord(x,y)))
02126         return (FALSE);
02127 
02128     prevx   = x;
02129     prevy   = y;
02130     x       = SnapOrdinate(x,SubStep,XOrigin);
02131     y       = SnapOrdinate(y,SubStep,CalcYOrigin(x,SubStep));
02132 
02133     if (!GridBoundingRect.ContainsCoord(DocCoord(x,y)))
02134         return (FALSE);
02135 
02136     pDocRect->Translate(x-prevx,y-prevy);
02137 
02138     return (TRUE);
02139 }

BOOL NodeGridIso::Snap DocCoord pDocCoord,
double  Step
 

Same as Snap(pDocCoord), except the coord is snapped to grid points at the given intervals.

Author:
Mark_Neves (Xara Group Ltd) <camelotdev@xara.com>
Date:
9/2/94
Parameters:
pDocCoord - the coord to snap [INPUTS] XStep - the step to use when snapping the point
[OUTPUTS] 
Returns:
TRUE - the DocCoord has been snapped to the grid. FALSE - the DocCoord has not been processed.

Errors: Scope: public

Definition at line 2159 of file grid.cpp.

02160 {
02161     if (IsDisabled()) return FALSE;
02162 
02163     ENSURE(Step!=0,"Step==0 in NodeGridIso::Snap");
02164 
02165     pDocCoord->x = SnapOrdinate(pDocCoord->x,Step,XOrigin);
02166     pDocCoord->y = SnapOrdinate(pDocCoord->y,Step,CalcYOrigin(pDocCoord->x,Step));
02167 
02168     return (TRUE);
02169 }

BOOL NodeGridIso::Snap DocCoord pDocCoord  )  [virtual]
 

Snaps to given coord to the nearest grid point. If it is not appropriate to snap the coord to the grid (at the moment this means the coord lies outside the grid object's bounding box), then FALSE is returned.

Author:
Mark_Neves (Xara Group Ltd) <camelotdev@xara.com>
Date:
15/2/94
Parameters:
pDocCoord = a coord in Spread coords [INPUTS]
[OUTPUTS] 
Returns:
TRUE - the DocCoord has been snapped to the grid. FALSE - the DocCoord has not been processed.

Errors: Scope: public

Reimplemented from NodeGrid.

Definition at line 2055 of file grid.cpp.

02056 {
02057     if (IsDisabled()) return FALSE;
02058 
02059     ENSURE(MainStep!=0,"MainStep==0 in NodeGridIso::Snap");
02060     ENSURE(SubStep !=0,"SubStep ==0 in NodeGridIso::Snap");
02061 
02062     if (!GridBoundingRect.ContainsCoord(DocCoord(pDocCoord->x,pDocCoord->y)))
02063         return (FALSE);
02064 
02065     MILLIPOINT x = SnapOrdinate(pDocCoord->x,SubStep,XOrigin);
02066     MILLIPOINT y = SnapOrdinate(pDocCoord->y,SubStep,CalcYOrigin(pDocCoord->x,SubStep));
02067 
02068     if (!GridBoundingRect.ContainsCoord(DocCoord(x,y)))
02069         return (FALSE);
02070 
02071     pDocCoord->x = x;
02072     pDocCoord->y = y;
02073 
02074     return (TRUE);
02075 }


Member Data Documentation

double NodeGridIso::Divisions [private]
 

Definition at line 437 of file grid.h.

double NodeGridIso::MainStep [private]
 

Definition at line 433 of file grid.h.

UINT32 NodeGridIso::Subdivisions [private]
 

Definition at line 438 of file grid.h.

double NodeGridIso::SubStep [private]
 

Definition at line 434 of file grid.h.

UnitType NodeGridIso::Units [private]
 

Definition at line 436 of file grid.h.


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