ContourTool Class Reference

The Contour tool class Notes: Copied from the blend tool. More...

#include <cntrtool.h>

Inheritance diagram for ContourTool:

DragTool Tool_v1 List of all members.

Public Member Functions

 ContourTool ()
 Default Constructor. Other initialisation is done in ContourTool::Init which is called by the Tool Manager.
 ~ContourTool ()
 Destructor.
BOOL Init ()
 Used to check if the Tool was properly constructed.
void Describe (void *InfoPtr)
 Allows the tool manager to extract information about the tool.
UINT32 GetID ()
void SelectChange (BOOL isSelected)
 Starts up and closes down the blend tool.
void OnClick (DocCoord, ClickType, ClickModifiers, Spread *)
 To handle a Mouse Click event for the Blend Tool.
void OnMouseMove (DocCoord PointerPos, Spread *pSpread, ClickModifiers ClickMods)
 To handle a Mouse Move event for the Blend Tool.
void RenderToolBlobs (Spread *pSpread, DocRect *pDocRect)
 Handles the RenderToolBlobs method. Renders the tool's blobs into the current doc view.
BOOL GetStatusLineText (String_256 *ptext, Spread *, DocCoord, ClickModifiers)
 Each tool should override this function to return valid status line text.
BOOL OnKeyPress (KeyPress *pKeyPress)
 To handle keypress events for the Blend Tool.
BOOL AreToolBlobsRenderedOnSelection ()
void SetupToolBlobs ()
 Sets up the tool blobs for the current selection.
void SetBlobRendering (BOOL b)

Static Public Member Functions

static ContourInfoBarOpGetContourInfoBarOp ()
static BOOL IsCurrent ()
 Is the blend tool the current one? Call this to find out.
static void DisplayStatusBarHelp (UINT32 StatusID)
 Displays the given status help string in the status bar.
static BlendToolRefGetPtrRefStart ()
static BlendToolRefGetPtrRefEnd ()
static void UpdateRef (BlendToolRef *pRef, Spread *pSpread, DocCoord PointerPos, BOOL CheckNodeUnderPoint=TRUE)
 This will update the blend tool ref depending on the current pointer pos. If CheckNodeUnderPoint is TRUE, then the routine will revert to a click-detection search to find out which node lies under the given point. This is potentially very time-consuming.
static void UpdateCursorAndStatus ()
 This will update the cursor and status line text depending on the data in the two blend tool references within ContourTool.
static void CheckNodeRemapping (BlendToolRef *pRefStart, BlendToolRef *pRefEnd)
 This checks to see if the two references actually represent a node remapping within a blend. In order to cope with multi-stage blends, both references have to be looked at the same time.
static INT32 CalculateContourWidth (DocRect &br, DocCoord &PointerPos)
 Calculates the contour width for a given rect.
static INT32 CalculateContourWidth (Node *pNode, DocCoord &PointerPos)
 Calculates the contour width for a given node given a pointer position.

Static Public Attributes

static OpContourNodesm_pOpContourNodes = NULL

Private Member Functions

 CC_DECLARE_MEMDUMP (ContourTool)
BOOL CreateCursors ()
 Creates all the blend tool cursors.
void DestroyCursors ()
 Destroys all the blend tool cursors.
BOOL IsPointOverBlob (DocCoord &Point, DocRect *pBlobRect=NULL)
 Creates all the blend tool cursors.
void InformWarningBevelExistsInSelection ()
 Brings up the associated warning dialog.

Static Private Member Functions

static NodeRenderableInkFindObject (Spread *pSpread, DocCoord ClickPos)
 Looks for a (possibly grouped) node(s) in the given spread at the given mouse-click position. Convenient shorthand for the hit-testing functions.
static BOOL IsPointOverPathBlob (DocCoord *pPointerPos, BlendToolRef *pRef)
 Scans for selected paths. If the coord is over a selected path's blob, it returns TRUE and pRef->pNode points to the path, and pRef->Index contains the element index of the blob. Also, *pPointerPos is snapped to the coord of the centre of the blob, if found.
static BOOL IsPointOverBlendBlob (DocCoord *pPointerPos, BlendToolRef *pRef)
 Scans for selected blends. If the coord is over a selected blend's blob, it returns TRUE and pRef->pNode points to the path, pRef->pNodeBlend points to the blend containing the path, and *pIndex contains the element index of the blob. Also, if found, *pPointerPos = centre of blob.

Private Attributes

DocCoord m_BlobPoints [8]
BOOL m_bDisableBlobRenderingFlag

Static Private Attributes

static ContourInfoBarOppContourInfoBarOp = NULL
static CursorpcNormalCursor = NULL
static CursorpcOverBlob = NULL
static CursorpcCurrentCursor = NULL
static INT32 CurrentCursorID = 0
static UINT32 StatusID = _R(IDS_CONTOURDRAGHELP)
static BlendToolRefpRefStart = NULL
static BlendToolRefpRefEnd = NULL
static TCHARFamilyName = _T("Contour Tools")
static TCHARToolName = _T("Contour Tool")
static TCHARPurpose = _T("Contour manipulation")
static TCHARAuthor = _T("David Mc")

Detailed Description

The Contour tool class Notes: Copied from the blend tool.

Author:
David_McClarnon (Xara Group Ltd) <camelotdev@xara.com> Mc
Date:
4/10/94

Definition at line 238 of file cntrtool.h.


Constructor & Destructor Documentation

ContourTool::ContourTool  ) 
 

Default Constructor. Other initialisation is done in ContourTool::Init which is called by the Tool Manager.

Author:
Mark_Neves (Xara Group Ltd) <camelotdev@xara.com>
Date:
3/10/94
See also:
ContourTool::Init

Definition at line 216 of file cntrtool.cpp.

00217 {
00218     pcCurrentCursor = NULL;
00219     m_bDisableBlobRenderingFlag = FALSE;
00220 }

ContourTool::~ContourTool  ) 
 

Destructor.

Author:
Mark_Neves (Xara Group Ltd) <camelotdev@xara.com>
Date:
3/10/94

Definition at line 232 of file cntrtool.cpp.

00233 {
00234     if (pRefStart != NULL)
00235     {
00236         delete pRefStart;
00237         pRefStart = NULL;
00238     }
00239 
00240     if (pRefEnd != NULL)
00241     {
00242         delete pRefEnd;
00243         pRefEnd = NULL;
00244     }
00245 
00246     if (m_pOpContourNodes)
00247     {
00248         delete m_pOpContourNodes;
00249         m_pOpContourNodes = NULL;
00250     }
00251 }


Member Function Documentation

BOOL ContourTool::AreToolBlobsRenderedOnSelection  )  [inline, virtual]
 

Reimplemented from Tool_v1.

Definition at line 275 of file cntrtool.h.

00275 { return TRUE; }

INT32 ContourTool::CalculateContourWidth Node pNode,
DocCoord PointerPos
[static]
 

Calculates the contour width for a given node given a pointer position.

Author:
David_McClarnon (Xara Group Ltd) <camelotdev@xara.com>
Date:
11/9/99
Parameters:
- [INPUTS]
- [OUTPUTS]
Returns:
The width of the contour
See also:
-

Definition at line 1580 of file cntrtool.cpp.

01581 {
01582     // get the bounding rect of the node to be contoured
01583     DocRect br = ((NodeRenderableBounded *)pNode)->GetBoundingRect();
01584 
01585     Node * pParent = pNode;
01586 
01587     BOOL bContourExists = FALSE;
01588 
01589     while (pParent && !bContourExists)
01590     {
01591         if (pParent->IsKindOf(CC_RUNTIME_CLASS(NodeContourController)))
01592         {
01593             pNode = pParent;
01594             bContourExists = TRUE;
01595 
01596             br = ((NodeContourController *)pNode)->GetInsideBoundingRect();
01597         }
01598 
01599         pParent = pParent->FindParent();
01600     }
01601 
01602     return CalculateContourWidth(br, PointerPos);
01603 
01604     
01605 }

INT32 ContourTool::CalculateContourWidth DocRect br,
DocCoord PointerPos
[static]
 

Calculates the contour width for a given rect.

Author:
David_McClarnon (Xara Group Ltd) <camelotdev@xara.com>
Date:
11/9/99
Parameters:
The doc rect to calculate the width from, and the pointer position [INPUTS]
- [OUTPUTS]
Returns:
The width of the contour
See also:
-

Definition at line 1289 of file cntrtool.cpp.

01290 {
01291     DocCoord Centre = br.Centre();
01292 
01293     INT32 Width = 0;
01294 
01295     INT32 OffsetX = 0;
01296     INT32 OffsetY = 0;
01297 
01298     double dOffsetX = 0;
01299     double dOffsetY = 0;
01300 
01301     // try to work out the width of the contour
01302     // first, are we dragging inside or outside the bounding rect ?
01303     if (!br.ContainsCoord(PointerPos))
01304     {
01305         // outside the bounding rect
01306         if (PointerPos.x < br.lo.x && PointerPos.y >= br.lo.y &&
01307             PointerPos.y <= br.hi.y)
01308         {
01309             Width = br.lo.x - PointerPos.x;
01310         }
01311         else if (PointerPos.x > br.hi.x && PointerPos.y >= br.lo.y &&
01312             PointerPos.y <= br.hi.y)
01313         {
01314             Width = PointerPos.x - br.hi.x;
01315         }
01316         else if (PointerPos.x >= br.lo.x && PointerPos.x <= br.hi.x &&
01317             PointerPos.y < br.lo.y)
01318         {
01319             Width = br.lo.y - PointerPos.y;
01320         }
01321         else if (PointerPos.x >= br.lo.x && PointerPos.x <= br.hi.x &&
01322             PointerPos.y > br.hi.y)
01323         {
01324             Width = PointerPos.y - br.hi.y;
01325         }
01326         else if (PointerPos.x < br.lo.x && PointerPos.y < br.lo.y)
01327         {
01328             OffsetX = br.lo.x - PointerPos.x;
01329             OffsetY = br.lo.y - PointerPos.y;
01330             
01331             if (OffsetX > OffsetY)
01332             {
01333                 Width = OffsetX;
01334             }
01335             else
01336             {
01337                 Width = OffsetY;
01338             }
01339         }
01340         else if (PointerPos.x > br.hi.x && PointerPos.y < br.lo.y)
01341         {
01342             OffsetX = PointerPos.x - br.hi.x ;
01343             OffsetY = br.lo.y - PointerPos.y;
01344             
01345             if (OffsetX > OffsetY)
01346             {
01347                 Width = OffsetX;
01348             }
01349             else
01350             {
01351                 Width = OffsetY;
01352             }
01353         }
01354         else if (PointerPos.x > br.hi.x && PointerPos.y > br.hi.y)
01355         {
01356             OffsetX = PointerPos.x - br.hi.x ;
01357             OffsetY = PointerPos.y - br.hi.y;
01358             
01359             if (OffsetX > OffsetY)
01360             {
01361                 Width = OffsetX;
01362             }
01363             else
01364             {
01365                 Width = OffsetY;
01366             }
01367         }
01368         else if (PointerPos.x < br.lo.x && PointerPos.y > br.hi.y)
01369         {
01370             OffsetX = br.lo.x - PointerPos.x ;
01371             OffsetY = PointerPos.y - br.hi.y;
01372             
01373             if (OffsetX > OffsetY)
01374             {
01375                 Width = OffsetX;
01376             }
01377             else
01378             {
01379                 Width = OffsetY;
01380             }
01381         }
01382         
01383         Width = -Width;
01384     }
01385     else
01386     {
01387         // inside the bounding rect then
01388 
01389         // work out which quadrant to access
01390         dOffsetX = ((double)(PointerPos.x - Centre.x));
01391         dOffsetY = ((double)(PointerPos.y - Centre.y));
01392 
01393         INT32 RWidth = br.Width()/2;
01394         INT32 RHeight = br.Height()/2;
01395 
01396         if (RWidth > RHeight)
01397         {
01398             INT32 DistX = RWidth - RHeight;
01399 
01400             if (PointerPos.x < Centre.x + DistX &&
01401                 PointerPos.x > Centre.x - DistX)
01402             {
01403                 if (dOffsetY > 0)
01404                 {
01405                     Width = br.hi.y - PointerPos.y;
01406                 }
01407                 else
01408                 {
01409                     Width = PointerPos.y - br.lo.y;
01410                 }
01411             }
01412             else if (PointerPos.x > Centre.x + DistX)
01413             {
01414                 dOffsetX -= (double)DistX;
01415 
01416                 if (dOffsetY > 0)
01417                 {
01418                     if (dOffsetX > dOffsetY)
01419                     {
01420                         Width = br.hi.x - PointerPos.x;
01421                     }
01422                     else
01423                     {
01424                         Width = br.hi.y - PointerPos.y;
01425                     }
01426                 }
01427                 else
01428                 {
01429                     if (dOffsetX > -dOffsetY)
01430                     {
01431                         Width = br.hi.x - PointerPos.x;
01432                     }
01433                     else
01434                     {
01435                         Width = PointerPos.y - br.lo.y;
01436                     }
01437                 }
01438             }
01439             else
01440             {
01441                 dOffsetX += (double)DistX;
01442                 dOffsetX = -dOffsetX;
01443 
01444                 if (dOffsetY > 0)
01445                 {
01446                     if (dOffsetX > dOffsetY)
01447                     {
01448                         Width = PointerPos.x - br.lo.x;
01449                     }
01450                     else
01451                     {
01452                         Width = br.hi.y - PointerPos.y;
01453                     }
01454                 }
01455                 else
01456                 {
01457                     if (dOffsetX > -dOffsetY)
01458                     {
01459                         Width = PointerPos.x - br.lo.x;
01460                     }
01461                     else
01462                     {
01463                         Width = PointerPos.y - br.lo.y;
01464                     }
01465                 }
01466             }
01467         }
01468         else
01469         {
01470             INT32 DistY = RHeight - RWidth;
01471 
01472             if (PointerPos.y < Centre.y + DistY &&
01473                 PointerPos.y > Centre.y - DistY)
01474             {
01475                 if (dOffsetX > 0)
01476                 {
01477                     Width = br.hi.x - PointerPos.x;
01478                 }
01479                 else
01480                 {
01481                     Width = PointerPos.x - br.lo.x;
01482                 }
01483             }
01484             else if (PointerPos.y > Centre.y + DistY)
01485             {
01486                 dOffsetY -= (double)DistY;
01487 
01488                 if (dOffsetX > 0)
01489                 {
01490                     if (dOffsetY > dOffsetX)
01491                     {
01492                         Width = br.hi.y - PointerPos.y;
01493                     }
01494                     else
01495                     {
01496                         Width = br.hi.x - PointerPos.x;
01497                     }
01498                 }
01499                 else
01500                 {
01501                     if (dOffsetY > -dOffsetX)
01502                     {
01503                         Width = br.hi.y - PointerPos.y;
01504                     }
01505                     else
01506                     {
01507                         Width = PointerPos.x - br.lo.x;
01508                     }
01509                 }
01510             }
01511             else
01512             {
01513                 dOffsetY += (double)DistY;
01514                 dOffsetY = -dOffsetY;
01515 
01516                 if (dOffsetX > 0)
01517                 {
01518                     if (dOffsetY > dOffsetX)
01519                     {
01520                         Width = PointerPos.y - br.lo.y;
01521                     }
01522                     else
01523                     {
01524                         Width = br.hi.x - PointerPos.x;
01525                     }
01526                 }
01527                 else
01528                 {
01529                     if (dOffsetY > -dOffsetX)
01530                     {
01531                         Width = PointerPos.y - br.lo.y;
01532                     }
01533                     else
01534                     {
01535                         Width = PointerPos.x - br.lo.x;
01536                     }
01537                 }
01538             }
01539         }
01540     }
01541 
01542     // check for max's and min's
01543     if (Width > 0)
01544     {
01545         if (Width > CONTOUR_DEPTH_MAX)
01546             Width = CONTOUR_DEPTH_MAX;
01547 
01548         if (Width < CONTOUR_DEPTH_MIN)
01549             Width = CONTOUR_DEPTH_MIN;
01550     }
01551     else
01552     {
01553         if (Width < -CONTOUR_DEPTH_MAX)
01554             Width = -CONTOUR_DEPTH_MAX;
01555 
01556         if (Width > -CONTOUR_DEPTH_MIN)
01557             Width = -CONTOUR_DEPTH_MIN;
01558     }
01559     
01560     return Width;
01561 }

ContourTool::CC_DECLARE_MEMDUMP ContourTool   )  [private]
 

void ContourTool::CheckNodeRemapping BlendToolRef pRefStart,
BlendToolRef pRefEnd
[static]
 

This checks to see if the two references actually represent a node remapping within a blend. In order to cope with multi-stage blends, both references have to be looked at the same time.

Author:
Mark_Neves (Xara Group Ltd) <camelotdev@xara.com>
Date:
6/12/94
Parameters:
pRefStart = ptr to start ref [INPUTS] pRefEnd = ptr to end ref
Potentailly updates pRefStart and pRefEnd, so that if they represent a remapping of nodes, [OUTPUTS] they have the same remap reference
Returns:
-
This is not the neatest way of doing it, but it's the quickest and safest method, given that it has to work for the gamma release it a few days time.

Definition at line 1130 of file cntrtool.cpp.

01131 {
01132     ERROR3IF(pRefStart == NULL,"pRefStart == NULL");
01133     ERROR3IF(pRefEnd   == NULL,"pRefEnd == NULL");
01134 }

BOOL ContourTool::CreateCursors  )  [private]
 

Creates all the blend tool cursors.

Author:
Mark_Neves (Xara Group Ltd) <camelotdev@xara.com>
Date:
3/10/94
Parameters:
- [INPUTS]
- [OUTPUTS]
Returns:
TRUE if all the blend tool cursors have been successfully created
See also:
-

Definition at line 577 of file cntrtool.cpp.

00578 {
00579     // This tool has just been selected.  Create the cursors.
00580     pcNormalCursor          = new Cursor(this, _R(IDC_POINTER_CONTOUR));
00581     pcOverBlob              = new Cursor(this, _R(IDC_SELECT_CONTOUR));
00582     
00583     if ( pcNormalCursor         ==NULL || !pcNormalCursor->IsValid() ||
00584         pcOverBlob== NULL || !pcOverBlob->IsValid()
00585        )
00586     {
00587         DestroyCursors();
00588         return FALSE;
00589     }
00590     else
00591         return TRUE;
00592 }

void ContourTool::Describe void *  InfoPtr  )  [virtual]
 

Allows the tool manager to extract information about the tool.

Author:
Mark_Neves (Xara Group Ltd) <camelotdev@xara.com>
Date:
3/10/94
Parameters:
InfoPtr - A pointer to a tool info block. It is passed cast to void* as [INPUTS] the version of the tool is unknown at this point. Later versions of the Tool class may have more items in this block, that this tool will not use
InfoPtr - The structure pointed to by InfoPtr will have had all the info [OUTPUTS] that this version of the Tool knows about

Reimplemented from Tool_v1.

Definition at line 347 of file cntrtool.cpp.

00348 {
00349     // Cast structure into the latest one we understand.
00350     ToolInfo_v1 *Info = (ToolInfo_v1 *) InfoPtr;
00351 
00352     Info->InfoVersion = 1;
00353     
00354     Info->InterfaceVersion = GetToolInterfaceVersion();  // You should always have this line.
00355         
00356     // These are all arbitrary at present.
00357     Info->Version = 1;
00358     Info->ID      = GetID();
00359     Info->TextID  = _R(IDS_CONTOUR_TOOL);
00360 
00361     Info->Family  = FamilyName;
00362     Info->Name    = ToolName;
00363     Info->Purpose = Purpose;
00364     Info->Author  = Author;
00365 
00366     Info->BubbleID = _R(IDBBL_CONTOUR_TOOLBOX);
00367 }

void ContourTool::DestroyCursors  )  [private]
 

Destroys all the blend tool cursors.

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

Definition at line 654 of file cntrtool.cpp.

00655 {
00656     if (pcNormalCursor          != NULL) delete pcNormalCursor;
00657     if (pcOverBlob              != NULL) delete pcOverBlob;
00658 
00659     pcNormalCursor = NULL;
00660     pcOverBlob = NULL;
00661 }

void ContourTool::DisplayStatusBarHelp UINT32  StatusIDX  )  [static]
 

Displays the given status help string in the status bar.

Author:
Mark_Neves (Xara Group Ltd) <camelotdev@xara.com>
Date:
3/10/94
Parameters:
StatusID = ID of status help string [INPUTS]
- [OUTPUTS]
Returns:
-
See also:
-

Definition at line 1249 of file cntrtool.cpp.

01250 {
01251     String_256 StatusMsg("");
01252     StatusMsg.Load(StatusIDX);
01253     GetApplication()->UpdateStatusBarText(&StatusMsg);
01254     ContourTool::StatusID = StatusIDX;
01255 }

NodeRenderableInk * ContourTool::FindObject Spread pSpread,
DocCoord  PointerPos
[static, private]
 

Looks for a (possibly grouped) node(s) in the given spread at the given mouse-click position. Convenient shorthand for the hit-testing functions.

Author:
Mark_Neves (Xara Group Ltd) <camelotdev@xara.com>
Date:
7/10/94
Parameters:
pSpread = ptr to spread click occurred [INPUTS] PointerPos = the DocCoord of the click
- [OUTPUTS]
Returns:
-

Errors: -

See also:
-

Definition at line 1152 of file cntrtool.cpp.

01153 {
01154     return NodeRenderableInk::FindCompoundAtPoint(pSpread,PointerPos,NULL);
01155 }

static ContourInfoBarOp* ContourTool::GetContourInfoBarOp  )  [inline, static]
 

Definition at line 261 of file cntrtool.h.

00261 { return pContourInfoBarOp; }

UINT32 ContourTool::GetID void   )  [inline, virtual]
 

Reimplemented from Tool_v1.

Definition at line 250 of file cntrtool.h.

00250 { return TOOLID_CONTOURTOOL; };

static BlendToolRef* ContourTool::GetPtrRefEnd  )  [inline, static]
 

Definition at line 266 of file cntrtool.h.

00266 { return pRefEnd; }

static BlendToolRef* ContourTool::GetPtrRefStart  )  [inline, static]
 

Definition at line 265 of file cntrtool.h.

00265 { return pRefStart; }

BOOL ContourTool::GetStatusLineText String_256 pStr,
Spread pSpread,
DocCoord  DocPos,
ClickModifiers  ClickMods
[virtual]
 

Each tool should override this function to return valid status line text.

Author:
Ed_Cornes (Xara Group Ltd) <camelotdev@xara.com>
Date:
14/11/94
Returns:
TRUE if returning valid text

Reimplemented from Tool_v1.

Definition at line 977 of file cntrtool.cpp.

00978 {
00979     if (StatusID != 0)
00980     {
00981         *pStr = String_256(StatusID);
00982     }
00983     else
00984     {
00985         *pStr = String_256(_R(IDS_CONTOURDRAGHELP));
00986     }
00987 
00988     return TRUE;
00989 }

void ContourTool::InformWarningBevelExistsInSelection  )  [private]
 

Brings up the associated warning dialog.

Author:
David_McClarnon (Xara Group Ltd) <camelotdev@xara.com>
Date:
7/4/2000
See also:
Tool::MouseClick; ClickType; ClickModifiers

Definition at line 825 of file cntrtool.cpp.

00826 {
00827     String_256 QueryString(_R(IDS_CANTCONTOURBEVEL));
00828 
00829     Error::SetError(0, QueryString, 0);             
00830     // The only way of bringing up a box with a string in it
00831     INT32 DlgResult = InformError(_R(IDS_CANTCONTOURBEVEL),
00832         _R(IDS_OK), _R(IDS_HELP));
00833                 
00834     if (DlgResult == 2)
00835     {
00836         HelpUserTopic(_R(IDS_HELPPATH_Message__Bevel_already_applied));
00837     }
00838 }

BOOL ContourTool::Init void   )  [virtual]
 

Used to check if the Tool was properly constructed.

Author:
Mark_Neves (Xara Group Ltd) <camelotdev@xara.com>
Date:
3/10/94
Returns:
FALSE if it does not want to be created, TRUE otherwise
See also:
ContourTool::ContourTool

Reimplemented from Tool_v1.

Definition at line 266 of file cntrtool.cpp.

00267 {
00268     // Declare all your ops here and only succeed if all declarations succeed
00269     BOOL ok =   OpContourNodes::Declare() &&
00270         OpChangeContourToInner::Declare() &&
00271         OpChangeContourToOuter::Declare() &&
00272         OpRemoveContour::Declare() &&
00273         OpChangeContourSteps::Declare() &&
00274         OpChangeContourColourType::Declare() &&
00275         OpChangeContourAttributeProfile::Declare() &&
00276         OpChangeContourObjectProfile::Declare() &&
00277         OpChangeContourStepDistance::Declare() &&
00278         OpToggleContourInsetPath::Declare();
00279     
00280     if (!ok) return FALSE;
00281 
00282     m_pOpContourNodes = new OpContourNodes;
00283 
00284     if (!m_pOpContourNodes)
00285         return FALSE;
00286 
00287     // We need two BlendToolRef objects
00288     ContourTool::pRefStart = new BlendToolRef;
00289     ContourTool::pRefEnd   = new BlendToolRef;
00290 
00291     ok = (ContourTool::pRefStart != NULL && ContourTool::pRefEnd != NULL);
00292 
00293     // This section reads in the infobar definition and creates an instance of
00294     // ContourInfoBarOp.  Also pContourInfoBarOp, the ptr to the tool's infobar, is set up
00295     // after the infobar is successfully read and created.
00296     if (ok)
00297     {
00298 #if 0       
00299         CCResTextFile       file;               // Resource File
00300         ContourInfoBarOpCreate BarCreate;           // Object that creates ContourInfoBarOp objects
00301 
00302 //              ok = file.open(_R(IDM_BLEND_BAR), _R(IDT_INFO_BAR_RES));        // Open resource
00303                 ok = file.open( _R(IDM_CONTOUR_BAR), _R(IDT_INFO_BAR_RES) );
00304         if (ok) ok = DialogBarOp::ReadBarsFromFile(file,BarCreate); // Read and create info bar
00305         if (ok) file.close();                                       // Close resource
00306 
00307         ENSURE(ok,"Unable to load blendbar.ini from resource\n"); 
00308 
00309         if (ok)
00310         {
00311             // Info bar now exists.  Now get a pointer to it
00312             String_32 str = String_32(_R(IDS_CONTOURTOOL_INFOBARNAME));
00313             DialogBarOp* pDialogBarOp = DialogBarOp::FindDialogBarOp(str);
00314 
00315                     ok = (pDialogBarOp != NULL);
00316             if (ok) ok = pDialogBarOp->IsKindOf(CC_RUNTIME_CLASS(ContourInfoBarOp));
00317             if (ok) pContourInfoBarOp = (ContourInfoBarOp*)pDialogBarOp;
00318 
00319             ENSURE(ok,"Error finding the blend tool info bar");
00320         }
00321 #endif
00322         pContourInfoBarOp = new ContourInfoBarOp();
00323         ok = (pContourInfoBarOp != NULL);
00324 
00325     }
00326 
00327     return (ok);
00328 }

BOOL ContourTool::IsCurrent  )  [static]
 

Is the blend tool the current one? Call this to find out.

Author:
Mark_Neves (Xara Group Ltd) <camelotdev@xara.com>
Date:
4/11/94
Parameters:
- [INPUTS]
- [OUTPUTS]
Returns:
TRUE if the blend tool is the current tool
See also:
-

Definition at line 1271 of file cntrtool.cpp.

01272 {
01273     return (Tool::GetCurrentID() == TOOLID_CONTOURTOOL);
01274 }

BOOL ContourTool::IsPointOverBlendBlob DocCoord pPointerPos,
BlendToolRef pRef
[static, private]
 

Scans for selected blends. If the coord is over a selected blend's blob, it returns TRUE and pRef->pNode points to the path, pRef->pNodeBlend points to the blend containing the path, and *pIndex contains the element index of the blob. Also, if found, *pPointerPos = centre of blob.

Author:
Mark_Neves (Xara Group Ltd) <camelotdev@xara.com>
Date:
10/11/94
Parameters:
pPointerPos = ptr to position of mouse in DocCoords [INPUTS] pRef = ptr to blend tool ref to update
Updates pRef->pNode pRef->pNodeBlend and pRef->Index if a blend blob was found. [OUTPUTS] Also, if found, *pPointerPos = centre of blob
Returns:
TRUE if the coord is over a blob of a selected blend

Definition at line 1070 of file cntrtool.cpp.

01071 {
01072     if (pRef == NULL) return FALSE;
01073 
01074     // Find the selected range of objects
01075     SelRange* pSelRange = GetApplication()->FindSelection();
01076     Node* pNode = pSelRange->FindFirst();
01077 
01078     BOOL BlobFound = FALSE;
01079 
01080     // Scan the selection for NodePath objects
01081     while (pNode != NULL && !BlobFound)
01082     {
01083         if (pNode->GetRuntimeClass() == CC_RUNTIME_CLASS(NodeBlend))
01084         {
01085             NodeBlend* pNodeBlend = (NodeBlend*)pNode;
01086 
01087             if (pNodeBlend->GetUnionBlobBoundingRect().ContainsCoord(*pPointerPos))
01088             {
01089                 BlobFound = pNodeBlend->IsPointOverBlob(pPointerPos,
01090                                                         &(pRef->pBlendPath),
01091                                                         &(pRef->Index),
01092                                                         &(pRef->AStartNode),
01093                                                         &(pRef->RemapRef));
01094 
01095                 if (BlobFound)
01096                 {
01097                     pRef->pNode      = pNodeBlend;
01098                     pRef->pNodeBlend = pNodeBlend;
01099 //                  *pPointerPos = pRef->pBlendPath->GetPathCoord(pRef->Index);
01100                 }
01101             }
01102         }
01103 
01104         // Now find the next selected node
01105         pNode = pSelRange->FindNext(pNode);
01106     }
01107 
01108     return BlobFound;
01109 }

BOOL ContourTool::IsPointOverBlob DocCoord Point,
DocRect pBlobRect = NULL
[private]
 

Creates all the blend tool cursors.

Author:
Mark_Neves (Xara Group Ltd) <camelotdev@xara.com>
Date:
3/10/94
Parameters:
A point in document coordinates, and the doc rect variable to [INPUTS] put the blob rect into
- [OUTPUTS]
Returns:
TRUE if the point is over a blob, false otherwise
See also:
-

Definition at line 608 of file cntrtool.cpp.

00609 {
00610     // check to see if I'm over a blob
00611     BlobManager * pBlobMgr = GetApplication()->GetBlobManager();
00612 
00613     INT32 BlobSize = 0;
00614 
00615     // Karim 18/09/2000
00616     // The contour blobs are about twice the size of normal blobs,
00617     // so I'm doubling the value of BlobSize when checking for them.
00618     if (pBlobMgr)
00619         BlobSize = pBlobMgr->GetBlobSize();
00620 //      BlobSize = pBlobMgr->GetBlobSize()/2;
00621 
00622     for (INT32 i = 0; i < 8; i++)
00623     {
00624         DocRect dr( m_BlobPoints[i].x - BlobSize,
00625                     m_BlobPoints[i].y - BlobSize,
00626                     m_BlobPoints[i].x + BlobSize,
00627                     m_BlobPoints[i].y + BlobSize);
00628 
00629         if (dr.ContainsCoord(Point))
00630         {
00631             if (pBlobRect)
00632                 *pBlobRect = dr;
00633             return TRUE;
00634         }
00635     }
00636 
00637     return FALSE;
00638 }

BOOL ContourTool::IsPointOverPathBlob DocCoord pPointerPos,
BlendToolRef pRef
[static, private]
 

Scans for selected paths. If the coord is over a selected path's blob, it returns TRUE and pRef->pNode points to the path, and pRef->Index contains the element index of the blob. Also, *pPointerPos is snapped to the coord of the centre of the blob, if found.

Author:
Mark_Neves (Xara Group Ltd) <camelotdev@xara.com>
Date:
10/10/94
Parameters:
pPointerPos = ptr to position of mouse in DocCoords [INPUTS] pRef = ptr to blend tool ref to update
Updates pRef->pNode and pRef->pIndex if a path blob was found. [OUTPUTS] Also, if blob found, *pPointerPos is snapped to coord of blob
Returns:
TRUE if the coord is over a blob of a selected path

Definition at line 1009 of file cntrtool.cpp.

01010 {
01011     if (pRef == NULL) return FALSE;
01012 
01013     // Find the selected range of objects
01014     SelRange* pSelRange = GetApplication()->FindSelection();
01015     Node* pNode = pSelRange->FindFirst();
01016 
01017     BOOL BlobFound = FALSE;
01018 
01019     // Scan the selection for NodePath objects
01020     while (!BlobFound && pNode != NULL && pNode->FindParent() != NULL)
01021     {
01022         // Only look at selected NodePaths that are NOT selected inside another node.
01023         if (IS_A(pNode,NodePath) && IS_A(pNode->FindParent(),Layer))
01024         {
01025             NodePath* pNodePath = (NodePath*)pNode;
01026 
01027             if (pNodePath->GetUnionBlobBoundingRect().ContainsCoord(*pPointerPos))
01028             {
01029                 // Get a pointer to the Path object within the NodePath
01030                 Path* pPath = &(pNodePath->InkPath);
01031 
01032                 // Is it over a blob? (Only check end points. Forget about control points)
01033                 BlobFound = pPath->FindNearestPoint(*pPointerPos,POINTFLAG_ENDPOINTS,&(pRef->Index));
01034 
01035                 // If a blob is found, store ptr to the node
01036                 if (BlobFound)
01037                 {
01038                     pRef->pNode = pNodePath;
01039                     pPath->SetPathPosition(pRef->Index);
01040                     *pPointerPos = pPath->GetCoord();
01041                 }
01042             }
01043         }
01044 
01045         // Now find the next selected node
01046         pNode = pSelRange->FindNext(pNode);
01047     }
01048 
01049     return BlobFound;
01050 }

void ContourTool::OnClick DocCoord  PointerPos,
ClickType  Click,
ClickModifiers  ClickMods,
Spread pSpread
[virtual]
 

To handle a Mouse Click event for the Blend Tool.

Author:
Mark_Neves (Xara Group Ltd) <camelotdev@xara.com>
Date:
3/10/94
Parameters:
PointerPos - The DocCoord of the point where the mouse button was clicked [INPUTS] Click - Describes the type of click that was detected. ClickMods - Indicates which buttons caused the click and which modifers were pressed at the same time pSpread - The spread in which the click happened
Returns:
-
See also:
Tool::MouseClick; ClickType; ClickModifiers

Reimplemented from DragTool.

Definition at line 748 of file cntrtool.cpp.

00750 {
00751 // Stub out this function if the tool isn't wanted
00752 #ifndef NO_ADVANCED_TOOLS
00753     if (ClickMods.Menu) return;                         // Don't do anything if the user clicked the Menu button
00754 
00755     ERROR3IF_PF(pSpread==NULL,("pSpread is NULL"));
00756 
00757 //  NodeCompound * pCompound = NULL;
00758 
00759     DocRect BlobRect;
00760 
00761     switch (Click)
00762     {
00763         // if a drag was started, we alter or create a contour.
00764         case CLICKTYPE_DRAG:
00765         {
00766             if (m_pOpContourNodes)
00767             {
00768                 m_pOpContourNodes->DoDrag(this, pContourInfoBarOp, PointerPos,
00769                     IsPointOverBlob(PointerPos, &BlobRect), &BlobRect);
00770                 return;
00771             }
00772         }
00773         break;
00774 
00775         // we ignore all other click types, but note that they aren't drag-clicks.
00776         case CLICKTYPE_SINGLE:
00777         {
00778             // check for bevels existing
00779             List BevelList;
00780             BevelTools::BuildListOfSelectedNodes(&BevelList, CC_RUNTIME_CLASS(NodeBevelController));
00781             
00782             if (!BevelList.IsEmpty())
00783             {
00784                 BevelList.DeleteAll();
00785                 
00786                 DocRect BlobRect;
00787 
00788                 // disable the drag
00789                 if (IsPointOverBlob(PointerPos, &BlobRect))
00790                 {
00791                     DocView * pView = DocView::GetCurrent();
00792 
00793                     if (pView)
00794                         pView->EndDrag(NULL);               
00795                     
00796                     InformWarningBevelExistsInSelection();
00797                 }
00798             }
00799 
00800             // call the base class ....
00801 
00802             DragTool::OnClick (PointerPos, Click, ClickMods, pSpread);
00803         }
00804         break;
00805         
00806         default:
00807             // call the base class ....
00808             
00809             DragTool::OnClick (PointerPos, Click, ClickMods, pSpread);
00810         break;
00811     }
00812 #endif  // NO_ADVANCED_TOOLS
00813 }

BOOL ContourTool::OnKeyPress KeyPress pKeyPress  )  [virtual]
 

To handle keypress events for the Blend Tool.

Author:
Mark_Neves (Xara Group Ltd) <camelotdev@xara.com>
Date:
1/6/99
Parameters:
pKeyPress - pointer to a keypress object [INPUTS]
Returns:
TRUE if it handled the keypress, FALSE otherwise

Reimplemented from Too