#include <grid.h>
Inheritance diagram for NodeGridIso:
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 () |
Node * | SimpleCopy () |
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 |
Definition at line 379 of file grid.h.
|
This constructor creates a NodeGridIso linked to no other nodes, with all status flags false, and NULL bounding and pasteboard rectangles.
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 }
|
|
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.
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 }
|
|
This method copies the node's contents to the node pointed to by NodeCopy.
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 }
|
|
To return a description of the Node object in either the singular or the plural. This method is called by the DescribeRange method.
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 };
|
|
For obtaining debug information about the Node.
Reimplemented from NodeGrid. Definition at line 2312 of file grid.cpp. 02313 { 02314 NodeGrid::GetDebugDetails(Str); 02315 }
|
|
Used to get the 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 }
|
|
Reimplemented from NodeGrid. Definition at line 406 of file grid.h. 00406 { return ISOMETRIC; }
|
|
Reimplemented from NodeGrid. Definition at line 408 of file grid.h. 00408 { return MainStep; }
|
|
For finding the size of a node, in concrete classes derived from Node.
Reimplemented from NodeGrid. Definition at line 411 of file grid.h.
|
|
Used to get the number of subdivisions between each main grid point.
Reimplemented from NodeGrid. Definition at line 2433 of file grid.cpp. 02434 { 02435 return Subdivisions; 02436 }
|
|
Gets the 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 }
|
|
Polymorphically copies the contents of this node to another.
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 }
|
|
Renders the isometric grid item.
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 }
|
|
Renders the grid points within the given renderable rectangle.
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 }
|
|
Renders the sub grid points from the given main point.
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 }
|
|
Defines the grid.
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 }
|
|
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.
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 }
|
|
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.
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 }
|
|
Same as Snap(pDocCoord), except the coord is snapped to grid points at the given intervals.
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 }
|
|
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.
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 }
|
|
|
|
|
|
|
|
|
|
|