#include <grid.h>
Inheritance diagram for NodeGrid:
Public Member Functions | |
NodeGrid () | |
This constructor creates a NodeGrid linked to no other nodes, with all status flags false, and NULL bounding and pasteboard rectangles. | |
virtual SubtreeRenderState | RenderSubtree (RenderRegion *pRender, Node **ppNextNode=NULL, BOOL bClip=TRUE) |
This function will indicate to the caller whether or not we want to render the given node, according to the information passed in. | |
virtual 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. | |
virtual void | Render (RenderRegion *pRender) |
For rendering a node. | |
virtual void | GetDebugDetails (StringBase *Str) |
For obtaining debug information about the Node. | |
virtual BOOL | Snap (DocCoord *pDocCoord) |
Place holder for derived classes. | |
virtual BOOL | Snap (DocRect *pDocRect, const DocCoord &PrevCoord, const DocCoord &CurCoord) |
Place holder for derived classes. | |
BOOL | IsGridSelected () const |
Find out if the grid is selected. | |
void | SetGridSelected (BOOL selected) |
Change the grid's selected flag. | |
BOOL | IsDefault () const |
Find out if the grid is a Default grid, i.e. one that covers a spread completely. These behave slightly differently in the selection model. | |
void | SetDefault (BOOL Default) |
Change the grid's Default flag. | |
BOOL | IsDisabled () const |
Find out if the grid is disabled. A disabled grid does not render and cannot be snapped to. This mechanism is used to disable Default grids without deleting them from the tree. | |
void | SetDisabled (BOOL Disabled) |
Change the grid's disabled flag. Also, if the grid is disabled, its selected flag is cleared as a disabled grid cannot be selected. | |
virtual BOOL | IsRenderedAsInk () const |
DocRect | GetBoundingRect () |
Returns the bounding rect of the grid. | |
void | SetBoundingRect (const DocRect &BRect) |
Sets the bounding rect of the grid, plus any other data that is needed. Should call this after the Node's bounds has been set up using something like SetInitialBounds. | |
DocRect | GetBlobBoundingRect () |
Returns the blob bounding rect of the grid. | |
DocCoord | GetBlobCoord (GridBlobType GridBlob) |
Returns the coord of the required blob of the grid. | |
void | SetOrigin (MILLIPOINT X, MILLIPOINT Y) |
Used for setting the origin of the grid. | |
void | GetOrigin (MILLIPOINT *pX, MILLIPOINT *pY) |
Used for retrieving the origin of the grid. | |
virtual BOOL | SetGridParams (double, UINT32, UnitType, BOOL Scale=TRUE) |
virtual double | CalcDivisions (BOOL Scale) |
Used to get the number of Units between each main grid point. Note: No longer uses 'Divisions' as this is a cached value which is not updated when unit scaling is changed. Dynamically caclulating this overcomes this problem Divisons has not been removed from the class as it also entails removing all code setting the value. I have proposed the whole system needs revamping! | |
virtual double | GetDivisions (BOOL Scale=TRUE) |
virtual UnitType | GetUnits (BOOL Scale=TRUE) |
virtual UINT32 | GetSubdivisions () |
virtual GridType | GetGridType () |
virtual double | GetMainStep () |
virtual void | PolyCopyNodeContents (NodeRenderable *pNodeCopy) |
Polymorphically copies the contents of this node to another. | |
virtual BOOL | WritePreChildrenWeb (BaseCamelotFilter *pFilter) |
Writes the grid record to the filter (if it's required). | |
virtual BOOL | WritePreChildrenNative (BaseCamelotFilter *pFilter) |
Static Public Member Functions | |
static void | RecalcNumSelectedGrids (Spread *pSpread) |
Recalculates the number of selected grids there are in the given spread. | |
static void | ProcessAllGrids (ProcessGrid *pProcessGrid) |
Processes all the grids in the current doc using the grid processing object provided as a parameter. | |
static void | ProcessGridsInSpread (ProcessGrid *pProcessGrid, Spread *pSpread) |
Processes all grids in this spread using the given grid processor param. | |
static void | ForceRedrawAllGrids () |
Forces a redraw on all the grids in the current view. | |
static void | MakeDefaultGrid (Spread *pSpread, BOOL Scale=TRUE) |
Creates a grid covering the whole spread. The grid is defined using the default parameters. | |
static void | ResetDocRectSnap () |
Call this before starting a drag that will use the DocRect version of the snap function. | |
static UINT32 | GetNumSelectedGrids () |
static UINT32 | GetNumNonDefaultSelectedGrids () |
static GridType | GetTypeForDefaultGrid () |
static BOOL | GetDefaultGridDisabled () |
static double | GetDefaultDivisions () |
static UINT32 | GetDefaultSubdivisions () |
static UnitType | GetDefaultUnits () |
static GridType | GetDefaultGridType () |
static void | SetTypeForDefaultGrid (GridType GType) |
static void | SetDefaultGridDisabled (BOOL state) |
static void | SetDefaultDivisions (double Div) |
static void | SetDefaultSubdivisions (UINT32 Sub) |
static void | SetDefaultUnits (UnitType UType) |
static void | SetDefaultGridType (GridType GType) |
Protected Member Functions | |
virtual BOOL | WriteGridAndRulerSettings (BaseCamelotFilter *pFilter) |
Exports the settings for the grid and rulers to the filter. This is the default grid, as this acts as the settings for the grid, as you would expect, and the page rulers. | |
virtual BOOL | WriteGirdAndRulerOrigin (BaseCamelotFilter *pFilter) |
Exports the origin for the grid and ruler to the filter. This is the default grid, as this acts as the settings for the grid, as you would expect, and the page rulers. | |
virtual 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. | |
void | CopyNodeContents (NodeGrid *NodeCopy) |
This method copies the node's contents to the node pointed to by NodeCopy. | |
void | UpdateBlobsData () |
Updates the internel select blobs data for the grid. This involves putting the coords of all the select blobs into the BlobCoords array of the grid. | |
void | CalcGridRenderSteps (MILLIPOINT PixelWidth, double *pStep, double DomStep, UnitType Units) |
MILLIPOINT | SnapOrdinate (MILLIPOINT ord, double Step, MILLIPOINT origin) |
General linear floating point ordinate snapping routine. | |
void | DumpRect (DocRect &R, TCHAR *S) |
Protected Attributes | |
MILLIPOINT | XOrigin |
MILLIPOINT | YOrigin |
DocColour | GridColour |
DocRect | GridBoundingRect |
Static Protected Attributes | |
static INT32 | LastXDir = 0 |
static INT32 | LastYDir = 0 |
Private Attributes | |
GridFlagsType | GridFlags |
DocCoord | BlobCoords [NumGridBlobTypes] |
Static Private Attributes | |
static UINT32 | NumSelected = 0 |
static UINT32 | NumNonDefaultSelected = 0 |
static GridType | TypeForDefaultGrid = RECTANGULAR |
static BOOL | DefaultGridDisabled = FALSE |
static double | DefaultDivisions = 1.0 |
static UINT32 | DefaultSubdivisions = 2 |
static UnitType | DefaultUnits = INCHES |
static GridType | DefaultGridType = RECTANGULAR |
Definition at line 164 of file grid.h.
|
This constructor creates a NodeGrid linked to no other nodes, with all status flags false, and NULL bounding and pasteboard rectangles.
Definition at line 177 of file grid.cpp. 00177 : NodeRenderablePaper() 00178 { 00179 SetOrigin(0,0); 00180 GridColour = DocColour(COLOUR_GRID); 00181 00182 GridFlags.Selected = FALSE; 00183 GridFlags.RelativeOrigin = FALSE; 00184 GridFlags.DefaultGrid = FALSE; 00185 GridFlags.Disabled = FALSE; 00186 00187 GridBoundingRect = DocRect(0,0,0,0); 00188 }
|
|
Used to get the number of Units between each main grid point. Note: No longer uses 'Divisions' as this is a cached value which is not updated when unit scaling is changed. Dynamically caclulating this overcomes this problem Divisons has not been removed from the class as it also entails removing all code setting the value. I have proposed the whole system needs revamping!
Definition at line 896 of file grid.cpp. 00897 { 00898 double Spacing = GetMainStep(); 00899 UnitType Units = GetUnits(Scale); 00900 BOOL ok = TRUE; 00901 String_256 Str; 00902 00903 if (Scale==FALSE) 00904 ok = Convert::MillipointsToString(Spacing,Units,&Str,10); 00905 else 00906 { 00907 DimScale* pDimScale = DimScale::GetPtrDimScale(this); 00908 ERROR2IF(pDimScale==NULL,FALSE,"NodeGridRect::CalcDivisions() - pDimScale==NULL"); 00909 ok = pDimScale->ConvertToUnits(Spacing,&Str,TRUE,10,Units); 00910 } 00911 00912 double Divs; 00913 UnitType DummyUnits; 00914 if (ok) ok=Convert::StringToComponents(Str, &Divs, &DummyUnits); 00915 if (!ok) Divs=1; 00916 00917 return Divs; 00918 }
|
|
Definition at line 406 of file grid.cpp. 00410 { 00411 if (Units == NOTYPE) return; // The get-out clause of the recursive contract 00412 00413 double MinRenderWidth = (double)(PixelWidth*MIN_PIX_RENDER_COUNT); // min distance between rendered grid points 00414 00415 if ((DomStep < MinRenderWidth)) 00416 { 00417 double ExtraDomStep = DomStep*::GetUnitMultiple(Units); 00418 CalcGridRenderSteps(PixelWidth,&DomStep,ExtraDomStep,::GetDominantUnit(Units)); 00419 } 00420 00421 double InitialStep = *pStep; 00422 double RenderStep = *pStep; 00423 00424 // Apply the grid step rules to RenderXStep 00425 00426 if (RenderStep < MinRenderWidth) 00427 { 00428 while (RenderStep < MinRenderWidth) 00429 { 00430 do 00431 { 00432 RenderStep += InitialStep; 00433 } while ((mod(DomStep,RenderStep) > (InitialStep/2)) && (RenderStep < DomStep)); 00434 } 00435 } 00436 00437 *pStep = RenderStep; 00438 }
|
|
This method copies the node's contents to the node pointed to by NodeCopy.
Definition at line 241 of file grid.cpp. 00242 { 00243 ENSURE(NodeCopy != NULL,"Trying to copy a NodeGridRect's contents to a NULL node"); 00244 00245 NodeRenderablePaper::CopyNodeContents(NodeCopy); 00246 00247 NodeCopy->XOrigin = this->XOrigin; 00248 NodeCopy->YOrigin = this->YOrigin; 00249 NodeCopy->GridColour = this->GridColour; 00250 NodeCopy->GridFlags = this->GridFlags; 00251 00252 for (INT32 i=0;i<NumGridBlobTypes;i++) 00253 NodeCopy->BlobCoords[i] = this->BlobCoords[i]; 00254 }
|
|
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 Node. Reimplemented in NodeGridRect, and NodeGridIso. Definition at line 328 of file grid.cpp. 00329 { 00330 ENSURE (FALSE,"The illegal function NodeGrid::Describe was called\n"); 00331 00332 return _T(""); // Just to keep the compiler happy 00333 };
|
|
Definition at line 871 of file grid.cpp. 00872 { 00873 #ifdef _DEBUG 00874 TRACEUSER( "MarkN", _T("%s.lo.x = %ld\n"), S,R.lo.x ); 00875 TRACEUSER( "MarkN", _T("%s.lo.y = %ld\n"), S,R.lo.y); 00876 TRACEUSER( "MarkN", _T("%s.hi.x = %ld\n"), S,R.hi.x); 00877 TRACEUSER( "MarkN", _T("%s.hi.y = %ld\n\n"),S,R.hi.y); 00878 #endif 00879 }
|
|
Forces a redraw on all the grids in the current view.
Definition at line 2671 of file grid.cpp. 02672 { 02673 ProcessGridForceRedraw ProcGrid; 02674 NodeGrid::ProcessAllGrids(&ProcGrid); 02675 }
|
|
Returns the blob bounding rect of the grid.
Reimplemented from NodeRenderable. Definition at line 624 of file grid.cpp. 00625 { 00626 // Find the paths bounding rectangle 00627 DocRect Rect = GridBoundingRect; 00628 00629 // And if we can find the selected view, add on the size of a selection blob 00630 DocView* pDocView = DocView::GetSelected(); 00631 if ( pDocView != NULL ) 00632 { 00633 DocRect BlobSize; 00634 00635 // Add the size of a blob to the top corner of the bounding rectangle 00636 OSRenderRegion::GetBlobRect(pDocView->GetViewScale(), Rect.HighCorner(), 00637 BT_SELECTEDLARGEST, &BlobSize); 00638 Rect.IncludePoint( BlobSize.HighCorner() ); 00639 00640 // add the size of a blob to the bottom corner of the bounding rectangle 00641 OSRenderRegion::GetBlobRect(pDocView->GetViewScale(), Rect.LowCorner(), 00642 BT_SELECTEDLARGEST, &BlobSize); 00643 Rect.IncludePoint( BlobSize.LowCorner() ); 00644 } 00645 00646 return Rect; 00647 }
|
|
Returns the coord of the required blob of the grid.
Definition at line 567 of file grid.cpp. 00568 { 00569 return BlobCoords[GridBlob]; 00570 }
|
|
Returns the bounding rect of the grid.
Definition at line 606 of file grid.cpp. 00607 { 00608 return GridBoundingRect; 00609 }
|
|
For obtaining debug information about the Node.
Reimplemented from NodeRenderablePaper. Reimplemented in NodeGridRect, and NodeGridIso. Definition at line 296 of file grid.cpp. 00297 { 00298 NodeRenderablePaper::GetDebugDetails(Str); 00299 }
|
|
Definition at line 2765 of file grid.cpp. 02765 { return DefaultDivisions; }
|
|
Definition at line 2764 of file grid.cpp. 02764 { return DefaultGridDisabled; }
|
|
Definition at line 2768 of file grid.cpp. 02768 { return DefaultGridType; }
|
|
Definition at line 2766 of file grid.cpp. 02766 { return DefaultSubdivisions; }
|
|
Definition at line 2767 of file grid.cpp. 02767 { return DefaultUnits; }
|
|
Reimplemented in NodeGridRect, and NodeGridIso. Definition at line 208 of file grid.h.
|
|
Reimplemented in NodeGridRect, and NodeGridIso. Definition at line 211 of file grid.h. 00211 { return INVALID_GRID_TYPE; }
|
|
Reimplemented in NodeGridRect, and NodeGridIso. Definition at line 212 of file grid.h.
|
|
For finding the size of a node, in concrete classes derived from Node.
Reimplemented from Node. Reimplemented in NodeGridRect, and NodeGridIso. Definition at line 253 of file grid.h.
|
|
Definition at line 2761 of file grid.cpp. 02761 { return NumNonDefaultSelected; }
|
|
Definition at line 2760 of file grid.cpp. 02760 { return NumSelected; }
|
|
Used for retrieving the origin of the grid.
Definition at line 691 of file grid.cpp.
|
|
Reimplemented in NodeGridRect, and NodeGridIso. Definition at line 210 of file grid.h.
|
|
Definition at line 2763 of file grid.cpp. 02763 { return TypeForDefaultGrid; }
|
|
Reimplemented in NodeGridRect, and NodeGridIso. Definition at line 209 of file grid.h. 00209 { return INCHES; }
|
|
Find out if the grid is a Default grid, i.e. one that covers a spread completely. These behave slightly differently in the selection model.
Definition at line 756 of file grid.cpp. 00757 { 00758 return GridFlags.DefaultGrid; 00759 }
|
|
Find out if the grid is disabled. A disabled grid does not render and cannot be snapped to. This mechanism is used to disable Default grids without deleting them from the tree.
Definition at line 794 of file grid.cpp.
|
|
Find out if the grid is selected.
Definition at line 710 of file grid.cpp. 00711 { 00712 // Grids have their own special selected flag. 00713 return GridFlags.Selected; 00714 }
|
|
Reimplemented from Node. Definition at line 193 of file grid.h. 00193 {return TRUE;}
|
|
Creates a grid covering the whole spread. The grid is defined using the default parameters.
Definition at line 2688 of file grid.cpp. 02689 { 02690 if (pSpread != NULL) 02691 { 02692 NodeGrid* pNewGrid = NULL; // This will point to the new grid 02693 switch (GetDefaultGridType()) // Create the new grid of the right type 02694 { 02695 case RECTANGULAR : pNewGrid = new NodeGridRect(); break; 02696 case ISOMETRIC : pNewGrid = new NodeGridIso(); break; 02697 default: break; // we check it below 02698 } 02699 02700 if (pNewGrid != NULL) 02701 { 02702 // Build the grid rectangle to completely cover the pasteboard 02703 DocRect Rect = pSpread->GetPasteboardRect(FALSE); 02704 pSpread->DocCoordToSpreadCoord(&Rect); 02705 02706 pNewGrid->AttachNode(pSpread, LASTCHILD); 02707 // pNewGrid->SetInitialBounds(Rect); 02708 pNewGrid->SetBoundingRect(Rect); // Tell the NodeGrid of the new bounds 02709 pNewGrid->SetDefault(TRUE); 02710 pNewGrid->SetDisabled(GetDefaultGridDisabled()); 02711 02712 // Set the grid (and user coord) origin to the bottom left corner of the 1st page 02713 // DocRect PageRect; 02714 // if (pSpread->GetPagesRect(&PageRect)) 02715 // pNewGrid->SetOrigin(PageRect.lo.x, PageRect.lo.y); 02716 02717 // Set the grid params to the default grid settings 02718 // If the default unit type is NOTYPE, get the page units from the doc unit list 02719 // of the current document 02720 UnitType Units = GetDefaultUnits(); 02721 if (Units == NOTYPE) 02722 { 02723 // Get the node's dic unit list 02724 DocUnitList* pDocUnitList = DocUnitList::GetCurrentDocUnitList(); 02725 02726 ENSURE(pDocUnitList != NULL,"No doc unit list attached to this doc yet"); 02727 if (pDocUnitList != NULL) 02728 Units = pDocUnitList->GetPageUnits(); // Set to the page units. 02729 } 02730 02731 if (Units != NOTYPE) 02732 pNewGrid->SetGridParams(GetDefaultDivisions(),GetDefaultSubdivisions(),Units,Scale); 02733 } 02734 } 02735 }
|
|
Polymorphically copies the contents of this node to another.
Reimplemented from NodeRenderablePaper. Reimplemented in NodeGridRect, and NodeGridIso. Definition at line 269 of file grid.cpp. 00270 { 00271 ENSURE(pNodeCopy, "Trying to copy a node's contents into a NULL node"); 00272 ENSURE(IS_A(pNodeCopy, NodeGrid), "PolyCopyNodeContents given wrong dest node type"); 00273 00274 if (IS_A(pNodeCopy, NodeGrid)) 00275 CopyNodeContents((NodeGrid*)pNodeCopy); 00276 }
|
|
Processes all the grids in the current doc using the grid processing object provided as a parameter.
Definition at line 2480 of file grid.cpp. 02481 { 02482 ERROR3IF(Document::GetSelected() == NULL,"What, no doc? Surely some mistake!"); 02483 02484 pProcessGrid->pDoc = Document::GetSelected(); 02485 if (pProcessGrid->pDoc == NULL) return; 02486 02487 // Now we need to scan all spreads throughout the current doc 02488 02489 pProcessGrid->pChapter = Node::FindFirstChapter(pProcessGrid->pDoc); 02490 while (pProcessGrid->pChapter != NULL) 02491 { 02492 // For each chapter in the doc... 02493 Node* pNode = pProcessGrid->pChapter->FindFirstChild(); 02494 while (pNode != NULL) 02495 { 02496 // If the child node of the chapter is a spread... 02497 if (pNode->IsKindOf(CC_RUNTIME_CLASS(Spread))) 02498 ProcessGridsInSpread(pProcessGrid,(Spread*)pNode); 02499 02500 pNode = pNode->FindNext(); 02501 } 02502 pProcessGrid->pChapter = pProcessGrid->pChapter->FindNextChapter(); 02503 } 02504 }
|
|
Processes all grids in this spread using the given grid processor param.
Definition at line 2521 of file grid.cpp. 02522 { 02523 pProcessGrid->pSpread = pSpread; 02524 02525 // scan the children of the spread for grids 02526 Node* pNode = pSpread->FindFirstChild(); 02527 while (pNode != NULL) 02528 { 02529 if (pNode->IsKindOf(CC_RUNTIME_CLASS(NodeGrid))) 02530 // we now have a ptr to a grid, so process it 02531 pProcessGrid->Process((NodeGrid*)pNode); 02532 02533 pNode = pNode->FindNext(); 02534 } 02535 }
|
|
Recalculates the number of selected grids there are in the given spread.
Definition at line 833 of file grid.cpp. 00834 { 00835 if (pSpread == NULL) return; 00836 00837 NodeGrid::NumSelected = 0; 00838 NodeGrid::NumNonDefaultSelected = 0; 00839 00840 // Start from the last node in the spread 00841 Node* pNode = pSpread->FindLastChild(); 00842 while (pNode != NULL) 00843 { 00844 if (pNode->IsKindOf(CC_RUNTIME_CLASS(NodeGrid))) 00845 { 00846 NodeGrid* pGrid = (NodeGrid*)pNode; 00847 00848 if (pGrid->IsGridSelected() && !pGrid->IsDisabled()) 00849 { 00850 NodeGrid::NumSelected++; 00851 00852 if (!pGrid->IsDefault()) 00853 NodeGrid::NumNonDefaultSelected++; 00854 } 00855 } 00856 // Scan back along the sibling list 00857 pNode = pNode->FindPrevious(); 00858 } 00859 }
|
|
For rendering a node.
Reimplemented from Node. Reimplemented in NodeGridRect, and NodeGridIso. Definition at line 348 of file grid.cpp.
|
|
This function will indicate to the caller whether or not we want to render the given node, according to the information passed in.
Reimplemented from NodeRenderablePaper. Definition at line 367 of file grid.cpp. 00368 { 00369 // If no cliprect supplied, assume we do need to render 00370 if (pRender==NULL || !bClip) 00371 return SUBTREE_ROOTANDCHILDREN; 00372 00373 DocRect ClipRect = pRender->GetClipRect(); 00374 00375 return ClipRect.IsIntersectedWith(GridBoundingRect) ? SUBTREE_ROOTANDCHILDREN : SUBTREE_NORENDER; 00376 }
|
|
Call this before starting a drag that will use the DocRect version of the snap function.
Definition at line 2751 of file grid.cpp.
|
|
Sets the bounding rect of the grid, plus any other data that is needed. Should call this after the Node's bounds has been set up using something like SetInitialBounds.
Definition at line 587 of file grid.cpp. 00588 { 00589 GridBoundingRect = Rect; 00590 UpdateBlobsData(); 00591 }
|
|
Change the grid's Default flag.
Definition at line 774 of file grid.cpp. 00775 { 00776 GridFlags.DefaultGrid = Default; 00777 }
|
|
Definition at line 2772 of file grid.cpp. 02772 { DefaultDivisions = Div; }
|
|
Definition at line 2771 of file grid.cpp. 02771 { DefaultGridDisabled = state; }
|
|
Definition at line 2775 of file grid.cpp. 02775 { DefaultGridType = GType; }
|
|
Definition at line 2773 of file grid.cpp. 02773 { DefaultSubdivisions = Sub; }
|
|
Definition at line 2774 of file grid.cpp. 02774 { DefaultUnits = UType; }
|
|
Change the grid's disabled flag. Also, if the grid is disabled, its selected flag is cleared as a disabled grid cannot be selected.
Definition at line 814 of file grid.cpp. 00815 { 00816 GridFlags.Disabled = disabled; 00817 if (disabled) SetGridSelected(FALSE); 00818 }
|
|
Reimplemented in NodeGridRect, and NodeGridIso. Definition at line 204 of file grid.h. 00204 { return FALSE; }
|
|
Change the grid's selected flag.
Definition at line 729 of file grid.cpp. 00730 { 00731 BOOL OldState = GridFlags.Selected; 00732 GridFlags.Selected = selected; 00733 00734 if (OldState != selected) 00735 { 00736 if (selected) 00737 NodeGrid::NumSelected++; 00738 else 00739 NodeGrid::NumSelected--; 00740 } 00741 }
|
|
Used for setting the origin of the grid.
Definition at line 662 of file grid.cpp. 00663 { 00664 XOrigin = X; 00665 YOrigin = Y; 00666 00667 // a bit of a bodge, but for v1.1 the user origin will be permenently linked to the grid origin 00668 // (during import the grid may not yet be in the tree and has no parent spread - eek!) 00669 Node* pNode = FindParent(); 00670 while (pNode!=NULL && pNode->IsSpread() == FALSE) 00671 pNode = pNode->FindParent(); 00672 if (pNode!=NULL) 00673 ((Spread*)pNode)->SetUserOrigin(DocCoord(X,Y)); 00674 }
|
|
Definition at line 2770 of file grid.cpp. 02770 { TypeForDefaultGrid = GType; }
|
|
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 NodeRenderablePaper. Reimplemented in NodeGridRect, and NodeGridIso. Definition at line 213 of file grid.cpp. 00214 { 00215 NodeGrid* NodeCopy = new NodeGrid(); 00216 if (NodeCopy != NULL) 00217 CopyNodeContents(NodeCopy); 00218 return (NodeCopy); 00219 }
|
|
Place holder for derived classes.
Reimplemented from NodeRenderableBounded. Reimplemented in NodeGridRect, and NodeGridIso. Definition at line 475 of file grid.cpp. 00476 { 00477 return (FALSE); 00478 }
|
|
Place holder for derived classes.
Reimplemented from NodeRenderableBounded. Reimplemented in NodeGridRect, and NodeGridIso. Definition at line 456 of file grid.cpp. 00457 { 00458 return FALSE; 00459 }
|
|
General linear floating point ordinate snapping routine.
Definition at line 498 of file grid.cpp. 00499 { 00500 double fp_ord = ord; 00501 00502 fp_ord -= origin; // Translate to 0 00503 00504 double sign = sgn(fp_ord); // sign = 1 when fp_ord is >=0, sign = -1 when fp_ord<0 00505 00506 fp_ord *= sign; // make +ve if it is -ve 00507 00508 double dist = mod(fp_ord,Step); 00509 if (dist > (Step/2)) dist -= Step; // if closest to min adjacent snap point, snap to it 00510 fp_ord -= dist; 00511 00512 fp_ord += 0.5; // Round up before convertion to MILLIPOINTS, and while still +ve 00513 fp_ord *= sign; // make -ve again if it was -ve on entry 00514 fp_ord += origin; // Translate back to the origin 00515 00516 return (MILLIPOINT)fp_ord; 00517 }
|
|
Updates the internel select blobs data for the grid. This involves putting the coords of all the select blobs into the BlobCoords array of the grid.
Definition at line 535 of file grid.cpp. 00536 { 00537 DocRect& BB = GridBoundingRect; 00538 00539 BlobCoords[BottomLeft] = DocCoord(BB.lo.x,BB.lo.y); 00540 BlobCoords[TopLeft] = DocCoord(BB.lo.x,BB.hi.y); 00541 BlobCoords[TopRight] = DocCoord(BB.hi.x,BB.hi.y); 00542 BlobCoords[BottomRight] = DocCoord(BB.hi.x,BB.lo.y); 00543 00544 MILLIPOINT midX = BB.lo.x+((BB.hi.x-BB.lo.x)/2); 00545 MILLIPOINT midY = BB.lo.y+((BB.hi.y-BB.lo.y)/2); 00546 00547 BlobCoords[LeftMiddle] = DocCoord(BB.lo.x,midY); 00548 BlobCoords[RightMiddle] = DocCoord(BB.hi.x,midY); 00549 BlobCoords[TopMiddle] = DocCoord(midX,BB.hi.y); 00550 BlobCoords[BottomMiddle] = DocCoord(midX,BB.lo.y); 00551 }
|
|
Exports the origin for the grid and ruler to the filter. This is the default grid, as this acts as the settings for the grid, as you would expect, and the page rulers.
Definition at line 3012 of file grid.cpp. 03013 { 03014 #ifdef DO_EXPORT 03015 ERROR2IF(pFilter == NULL,FALSE,"NULL filter param"); 03016 03017 BOOL ok = FALSE; 03018 03019 // Only write out this set of details if it is the default grid 03020 if (IsDefault()) 03021 { 03022 // Read the grid (user) origin 03023 DocCoord Origin(0,0); 03024 GetOrigin(&Origin.x, &Origin.y); 03025 03026 // We will now translate this to be relative to the page origin, as it will be displayed 03027 // to the user 03028 Spread* pSpread = pFilter->GetSpread(); 03029 DocCoord PageRelGridOrigin = Origin; 03030 if (pSpread) 03031 pSpread->SpreadCoordToPagesCoord(&PageRelGridOrigin, Origin); 03032 03033 CXaraFileRecord Rec(TAG_GRIDRULERORIGIN, TAG_GRIDRULERORIGIN_SIZE); 03034 03035 ok = Rec.Init(); 03036 03037 // Write out the origin 03038 if (ok) ok = Rec.WriteCoord(PageRelGridOrigin); 03039 03040 // Finally, write the record out to file 03041 // In the process get the record number that this was written out as 03042 INT32 RecordNumber = 0L; 03043 if (ok) RecordNumber = pFilter->Write(&Rec); 03044 03045 // If we have had a problem at any of the stages then return that to the caller 03046 if (!ok || RecordNumber <= 0) 03047 ok = FALSE; 03048 } 03049 03050 03051 return ok; 03052 #else 03053 return TRUE; 03054 #endif //DO_EXPORT 03055 }
|
|
Exports the settings for the grid and rulers to the filter. This is the default grid, as this acts as the settings for the grid, as you would expect, and the page rulers.
Definition at line 2944 of file grid.cpp. 02945 { 02946 #ifdef DO_EXPORT 02947 ERROR2IF(pFilter == NULL,FALSE,"NULL filter param"); 02948 02949 BOOL ok = FALSE; 02950 02951 // Only write out this set of details if it is the default grid 02952 if (IsDefault()) 02953 { 02954 // Go and get the numbers out of the grid 02955 // BODGE - old builds (hence docs) save the grid spacing in divisions and units but don't 02956 // account for unit scaling, so as not to change doc format new docs do the same so we must 02957 // read the grid 'Divisions' with scaling turned off - yuk! 02958 // But surely, it is safer to save out the units unscaled! 02959 BOOL Scale = FALSE; 02960 double Divisions = GetDivisions(Scale); 02961 UnitType Unit = GetUnits(Scale); 02962 UINT32 SubDivisions = GetSubdivisions(); 02963 GridType TypeOfGrid = GetGridType(); 02964 02965 // Convert the unittype into a reference 02966 UnitListComponent * pUnitsComponent = pFilter->GetUnitDocComponent(); 02967 ERROR2IF(pUnitsComponent == NULL,FALSE,"WriteGridAndRulerSettings No units doc component present"); 02968 02969 INT32 UnitsRef = pUnitsComponent->GetWriteUnitReference(Unit, pFilter); 02970 02971 CXaraFileRecord Rec(TAG_GRIDRULERSETTINGS, TAG_GRIDRULERSETTINGS_SIZE); 02972 02973 ok = Rec.Init(); 02974 02975 if (ok) ok = Rec.WriteINT32(UnitsRef); 02976 if (ok) ok = Rec.WriteDOUBLE(Divisions); 02977 if (ok) ok = Rec.WriteUINT32(SubDivisions); 02978 if (ok) ok = Rec.WriteBYTE((BYTE)TypeOfGrid); 02979 02980 // Finally, write the record out to file 02981 // In the process get the record number that this was written out as 02982 INT32 RecordNumber = 0L; 02983 if (ok) RecordNumber = pFilter->Write(&Rec); 02984 02985 // If we have had a problem at any of the stages then return that to the caller 02986 if (!ok || RecordNumber <= 0) 02987 ok = FALSE; 02988 } 02989 02990 return ok; 02991 #else 02992 return TRUE; 02993 #endif //DO_EXPORT 02994 }
|
|
Reimplemented from Node. Definition at line 2913 of file grid.cpp. 02914 { 02915 #ifdef DO_EXPORT 02916 BOOL RecordWritten = TRUE; 02917 02918 // Write out the page sizes etc for this spread 02919 if (RecordWritten) RecordWritten = WriteGridAndRulerSettings(pFilter); 02920 if (RecordWritten) RecordWritten = WriteGirdAndRulerOrigin(pFilter); 02921 02922 return RecordWritten; 02923 #else 02924 return TRUE; 02925 #endif //DO_EXPORT 02926 }
|
|
Writes the grid record to the filter (if it's required).
Reimplemented from Node. Definition at line 2904 of file grid.cpp. 02905 { 02906 // do nothing in the web format 02907 return FALSE; 02908 }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|