#include <nodeelip.h>
Inheritance diagram for NodeEllipse:
Public Member Functions | |
NodeEllipse () | |
This constructor creates a NodeRect linked to no other with all status flags false and an uninitialized bounding rectangle. Note: SetUpPath() must be called before the NodeRect is in a state in which it can be used. | |
NodeEllipse (Node *ContextNode, AttachNodeDirection Direction, BOOL Locked=FALSE, BOOL Mangled=FALSE, BOOL Marked=FALSE, BOOL Selected=FALSE) | |
This constructor initialises the nodes flags and links it to ContextNode in the direction specified by Direction. All neccesary tree links are updated. Note: SetUpPath() must be called before the NodeRect is in a state in which it can be used. | |
virtual Node * | SimpleCopy () |
Makes a copy of all the data in the node. | |
virtual String | Describe (BOOL Plural, BOOL Verbose) |
To return a description of the NodeRect object in either the singular or the plural. This method is called by the DescribeRange method. The description will always begin with a lower case letter. | |
void | PreExportRender (RenderRegion *pRegion) |
Output data required to mark this object as an ellipse, as opposed to an arbitrary path. | |
virtual void | CreateShape (DocRect NewRect) |
Creates an Ellipse using a path that fills the rectangle specified. | |
virtual void | UpdateShape () |
Updates Ellipse node to fit the current parallelogram. | |
virtual DocRect | GetBlobBoundingRect () |
Calculates the ellipses bounding rect along with its blobs. | |
virtual UINT32 | GetNodeSize () const |
For finding the size of the node. | |
virtual void | HandleBlobDrag (DocCoord &, Spread *, INT32) |
When a drag is started on one of the paths blobs this is called. It tries to fire up an operation that will perform a drag of all the selected points, including all the EORing of the relavent parts of the curve. If it fails it will inform the user and not bother. | |
Static Public Member Functions | |
static void | CalcEllipseEdge (const DocCoord &, const DocCoord &, DocCoord *, DocCoord *, DocCoord *) |
This function is used to fit an Ellipse inside a parallelogram using Bezier Curves. Along each side of the parallelogram there will be 3 coordinates (an Endpoint and 2 control points). This function calculate the 3 coordinates along a single side of the parallelogram (to calc all the control points the function would need to be called 4 times). The Coords P1 and P1 are assumed to be adjacent coordinates of the parallelogram. The maths for calculating coordinates for Rounded Rectangles is very similar. I have made optimisations in this function as not as much maths is needed. For a full description of the maths used here see the document Camelot/doc/ellipse.doc. | |
Private Member Functions | |
CC_DECLARE_DYNCREATE (NodeEllipse) |
Definition at line 120 of file nodeelip.h.
|
This constructor creates a NodeRect linked to no other with all status flags false and an uninitialized bounding rectangle. Note: SetUpPath() must be called before the NodeRect is in a state in which it can be used.
Definition at line 178 of file nodeelip.cpp. 00178 : NodeSimpleShape() 00179 { 00180 }
|
|
This constructor initialises the nodes flags and links it to ContextNode in the direction specified by Direction. All neccesary tree links are updated. Note: SetUpPath() must be called before the NodeRect is in a state in which it can be used.
Definition at line 150 of file nodeelip.cpp. 00156 :NodeSimpleShape(ContextNode, Direction, Locked, Mangled, Marked, Selected ) 00157 { 00158 }
|
|
This function is used to fit an Ellipse inside a parallelogram using Bezier Curves. Along each side of the parallelogram there will be 3 coordinates (an Endpoint and 2 control points). This function calculate the 3 coordinates along a single side of the parallelogram (to calc all the control points the function would need to be called 4 times). The Coords P1 and P1 are assumed to be adjacent coordinates of the parallelogram. The maths for calculating coordinates for Rounded Rectangles is very similar. I have made optimisations in this function as not as much maths is needed. For a full description of the maths used here see the document Camelot/doc/ellipse.doc.
Definition at line 364 of file nodeelip.cpp. 00366 { 00367 // Do the maths. This is described in the document camelot\docs\ellipse.doc 00368 // Find the length of the first side (pythag) 00369 INT32 dx = P1.x - P0.x; 00370 INT32 dy = P1.y - P0.y; 00371 //double SideLength = sqrt(dx*dx + dy*dy); 00372 //ENSURE(SideLength!=0.0, "CalcEllipseEdge was thinking of doing a div 0!"); 00373 00374 // This would be different if we were calculating a rounded rectangle 00375 //double ArcRadius = SideLength / 2.0; 00376 //double ControlDist = ArcRadius/(SideLength*2.2336); 00377 // This is equivalent to the above 2 lines, only less maths is needed 00378 // (ie none as the compiler should do it) 00379 double ControlDist = 1.0 / (2 * 2.2336); 00380 00381 // Find the control point closest to P0 00382 NewCoordA->x = (INT32) (P0.x + (dx * ControlDist)); 00383 NewCoordA->y = (INT32) (P0.y + (dy * ControlDist)); 00384 00385 // Find the mid point of the side, for the middle control point 00386 NewCoordB->x = (INT32) (P0.x + (dx / 2)); 00387 NewCoordB->y = (INT32) (P0.y + (dy / 2)); 00388 00389 // Find the Control point closest to p1 00390 NewCoordC->x = (INT32) (P1.x - dx * ControlDist); 00391 NewCoordC->y = (INT32) (P1.y - dy * ControlDist); 00392 }
|
|
|
|
Creates an Ellipse using a path that fills the rectangle specified.
Reimplemented from NodeSimpleShape. Definition at line 275 of file nodeelip.cpp. 00276 { 00277 // Copy the rectangle into the parallelogram 00278 Parallel[0] = DocCoord(NewRect.lo.x, NewRect.hi.y); 00279 Parallel[1] = DocCoord(NewRect.hi.x, NewRect.hi.y); 00280 Parallel[2] = DocCoord(NewRect.hi.x, NewRect.lo.y); 00281 Parallel[3] = DocCoord(NewRect.lo.x, NewRect.lo.y); 00282 00283 // Get an array to put the 12 different coords needed to specify an ellipse 00284 DocCoord NewCoords[12]; 00285 00286 // Calculate the 3 coordinates along each side of the parallelogram 00287 CalcEllipseEdge(Parallel[0], Parallel[1], &NewCoords[11], &NewCoords[0], &NewCoords[1]); 00288 CalcEllipseEdge(Parallel[1], Parallel[2], &NewCoords[2], &NewCoords[3], &NewCoords[4]); 00289 CalcEllipseEdge(Parallel[2], Parallel[3], &NewCoords[5], &NewCoords[6], &NewCoords[7]); 00290 CalcEllipseEdge(Parallel[3], Parallel[0], &NewCoords[8], &NewCoords[9], &NewCoords[10]); 00291 00292 // build a path 00293 InkPath.ClearPath(); 00294 InkPath.FindStartOfPath(); 00295 00296 // Start at bottom left corner 00297 PathFlags NewFlags; 00298 NewFlags.IsRotate = TRUE; 00299 InkPath.InsertMoveTo(NewCoords[0], &NewFlags); 00300 InkPath.InsertCurveTo(NewCoords[1], NewCoords[2], NewCoords[3], &NewFlags); 00301 InkPath.InsertCurveTo(NewCoords[4], NewCoords[5], NewCoords[6], &NewFlags); 00302 InkPath.InsertCurveTo(NewCoords[7], NewCoords[8], NewCoords[9], &NewFlags); 00303 InkPath.InsertCurveTo(NewCoords[10], NewCoords[11], NewCoords[0], &NewFlags); 00304 00305 // Close the path properly 00306 InkPath.CloseSubPath(); 00307 }
|
|
To return a description of the NodeRect object in either the singular or the plural. This method is called by the DescribeRange method. The description will always begin with a lower case letter.
Reimplemented from Node. Definition at line 221 of file nodeelip.cpp. 00222 { 00223 if (Plural) 00224 return(String(_R(IDS_ELLIPSE_DESCRP))); 00225 else 00226 return(String(_R(IDS_ELLIPSE_DESCRS))); 00227 }
|
|
Calculates the ellipses bounding rect along with its blobs.
Reimplemented from NodeSimpleShape. Definition at line 408 of file nodeelip.cpp. 00409 { 00410 #if !defined(EXCLUDE_FROM_RALPH) 00411 // Find the paths bounding rectangle 00412 DocRect ShapeRect = GetBoundingRect(); 00413 DocRect Rect(Parallel[0], Parallel[0]); 00414 Rect.IncludePoint(Parallel[1]); 00415 Rect.IncludePoint(Parallel[2]); 00416 Rect.IncludePoint(Parallel[3]); 00417 00418 // Find the blob manager 00419 BlobManager* pBlobMgr = GetApplication()->GetBlobManager(); 00420 00421 // Get a rect to put the extra rectangle on 00422 DocRect BlobRect; 00423 00424 // Get the rect round a blob in the corner of the ellipse and add it to the total 00425 DocCoord Corner = Rect.HighCorner(); 00426 pBlobMgr->GetBlobRect(Corner, &BlobRect); 00427 Rect = Rect.Union(BlobRect); 00428 00429 // and the same with the other corner 00430 Corner = Rect.LowCorner(); 00431 pBlobMgr->GetBlobRect(Corner, &BlobRect); 00432 Rect = Rect.Union(BlobRect); 00433 00434 // and union it with the rect of the shape or things like Linewidth get in the way 00435 Rect = Rect.Union(ShapeRect); 00436 00437 // Make sure we include the Bounds of our children 00438 IncludeChildrensBoundingRects(&Rect); 00439 00440 // return the rectangle with the blobs included 00441 return Rect; 00442 #else 00443 return DocRect(0,0,0,0); 00444 #endif 00445 }
|
|
For finding the size of the node.
Reimplemented from NodeSimpleShape. Definition at line 462 of file nodeelip.cpp. 00463 { 00464 return (sizeof(NodeEllipse)); 00465 }
|
|
When a drag is started on one of the paths blobs this is called. It tries to fire up an operation that will perform a drag of all the selected points, including all the EORing of the relavent parts of the curve. If it fails it will inform the user and not bother.
Reimplemented from NodeSimpleShape. Definition at line 487 of file nodeelip.cpp. 00488 { 00489 /* OpEditEllipse* pOp = new OpEditEllipse; 00490 if (pOp==NULL) 00491 { 00492 // Failed to get the memory to do the job 00493 if (IsUserName( "Rik" )) TRACE( _T("The Node Ellipse Edit Operation failed to start\n") ); 00494 00495 // Inform the person doing the clicking that life is not looking so good 00496 InformError(); 00497 } 00498 else 00499 { 00500 // Start the drag operation and pass in the Anchor Point to the operation 00501 pOp->DoDrag(PointerPos, pSpread, this, FixedCorner); 00502 }*/ 00503 }
|
|
Output data required to mark this object as an ellipse, as opposed to an arbitrary path.
Reimplemented from Node. Definition at line 241 of file nodeelip.cpp. 00242 { 00243 #ifdef DO_EXPORT 00244 if (pRegion->IsKindOf(CC_RUNTIME_CLASS(ArtWorksEPSRenderRegion))) 00245 { 00246 // Output "ArtWorks ellipse" token 00247 EPSExportDC *pDC = (EPSExportDC *) pRegion->GetRenderDC(); 00248 00249 // Output the 3 coords defining the ellipse's bounding parallelogram 00250 pDC->OutputCoord(Parallel[0]); 00251 pDC->OutputCoord(Parallel[1]); 00252 pDC->OutputCoord(Parallel[2]); 00253 00254 // And the token itself 00255 pDC->OutputToken(_T("ae")); 00256 pDC->OutputNewLine(); 00257 } 00258 #endif 00259 }
|
|
Makes a copy of all the data in the node.
Reimplemented from NodeSimpleShape. Definition at line 193 of file nodeelip.cpp. 00194 { 00195 // Make a new NodeSimpleShape and then copy things into it 00196 NodeEllipse* NodeCopy = new NodeEllipse(); 00197 if (NodeCopy) 00198 CopyNodeContents(NodeCopy); 00199 00200 return NodeCopy; 00201 }
|
|
Updates Ellipse node to fit the current parallelogram.
Reimplemented from NodeSimpleShape. Definition at line 322 of file nodeelip.cpp. 00323 { 00324 // make sure the path seems to have the correct number of coords in it 00325 ENSURE(InkPath.GetNumCoords()==13, "NodeEllipse::UpdateShape found its path corrupt" ); 00326 00327 // Get the array of coords in the path 00328 DocCoord* Coords = InkPath.GetCoordArray(); 00329 00330 // Update them to what we now have 00331 CalcEllipseEdge(Parallel[0], Parallel[1], &Coords[11], &Coords[0], &Coords[1]); 00332 CalcEllipseEdge(Parallel[1], Parallel[2], &Coords[2], &Coords[3], &Coords[4]); 00333 CalcEllipseEdge(Parallel[2], Parallel[3], &Coords[5], &Coords[6], &Coords[7]); 00334 CalcEllipseEdge(Parallel[3], Parallel[0], &Coords[8], &Coords[9], &Coords[10]); 00335 Coords[12] = Coords[0]; 00336 }
|