00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060
00061
00062
00063
00064
00065
00066
00067
00068
00069
00070
00071
00072
00073
00074
00075
00076
00077
00078
00079
00080
00081
00082
00083
00084
00085
00086
00087
00088
00089
00090
00091
00092
00093
00094
00095
00096
00097
00098
00099
00100
00101
00102
00103 #include "camtypes.h"
00104 #include "oilfiles.h"
00105 #include "csrstack.h"
00106
00107
00108
00109 #include "nodepath.h"
00110 #include "progress.h"
00111 #include "nodeblnd.h"
00112 #include "nodebldr.h"
00113
00114 #include "blobs.h"
00115
00116 #include "objchge.h"
00117
00118
00119
00120 #include "filltool.h"
00121 #include "bubbleid.h"
00122
00123 #include "attrmap.h"
00124 #include "ndbldpth.h"
00125 #include "pathedit.h"
00126 #include "keypress.h"
00127 #include "vkextra.h"
00128 #include "ezmodule.h"
00129 #include "opbevel.h"
00130
00131
00132 #include "opcntr.h"
00133 #include "cntrtool.h"
00134 #include "ppbevel.h"
00135 #include "nodetxts.h"
00136
00137 #include "layer.h"
00138 #include "ophist.h"
00139
00140
00141 #include "gclips.h"
00142
00143
00144 #include "nodecont.h"
00145 #include "nodecntr.h"
00146 #include "ncntrcnt.h"
00147
00148 #include "nodemold.h"
00149 #include "ndclpcnt.h"
00150 #include "biasdlg.h"
00151 #include "helpuser.h"
00152
00153
00154 #include "dragmgr.h"
00155 #include "lineattr.h"
00156 #include "effects_stack.h"
00157 #include "blndtool.h"
00158 #include "nbevcont.h"
00159
00160 DECLARE_SOURCE( "$Revision: 1386 $" );
00161
00162 CC_IMPLEMENT_MEMDUMP(ContourTool,Tool_v1)
00163 CC_IMPLEMENT_DYNCREATE(ContourInfoBarOp,InformationBarOp)
00164 CC_IMPLEMENT_DYNCREATE(OpContourNodes,SelOperation)
00165
00166
00167 #define new CAM_DEBUG_NEW
00168
00169
00170 TCHAR* ContourTool::FamilyName = _T("Contour Tools");
00171 TCHAR* ContourTool::ToolName = _T("Contour Tool");
00172 TCHAR* ContourTool::Purpose = _T("Contour manipulation");
00173 TCHAR* ContourTool::Author = _T("David Mc");
00174
00175
00176 ContourInfoBarOp* ContourTool::pContourInfoBarOp = NULL;
00177 BlendToolRef* ContourTool::pRefStart = NULL;
00178 BlendToolRef* ContourTool::pRefEnd = NULL;
00179 Cursor* ContourTool::pcNormalCursor = NULL;
00180 Cursor* ContourTool::pcOverBlob = NULL;
00181 Cursor* ContourTool::pcCurrentCursor = NULL;
00182 INT32 ContourTool::CurrentCursorID = 0;
00183 UINT32 ContourTool::StatusID = _R(IDS_CONTOURDRAGHELP);
00184
00185 OpContourNodes *ContourTool::m_pOpContourNodes = NULL;
00186
00187
00188 #define CONTOUR_DEPTH_MIN 10
00189 #define CONTOUR_DEPTH_MAX 250000
00190
00191
00192
00193 #define SWAP(type,a,b) { type x=a; a=b; b=x; }
00194
00196
00197 const INT32 ContourToolFlatness=2048;
00198
00200
00201 CProfileBiasGain SliderProfile((AFp)0.7, (AFp)0.0);
00202
00203
00204
00205
00206
00207
00208
00209
00210
00211
00212
00213
00214
00215
00216 ContourTool::ContourTool()
00217 {
00218 pcCurrentCursor = NULL;
00219 m_bDisableBlobRenderingFlag = FALSE;
00220 }
00221
00222
00223
00224
00225
00226
00227
00228
00229
00230
00231
00232 ContourTool::~ContourTool()
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 }
00252
00253
00254
00255
00256
00257
00258
00259
00260
00261
00262
00263
00264
00265
00266 BOOL ContourTool::Init()
00267 {
00268
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
00288 ContourTool::pRefStart = new BlendToolRef;
00289 ContourTool::pRefEnd = new BlendToolRef;
00290
00291 ok = (ContourTool::pRefStart != NULL && ContourTool::pRefEnd != NULL);
00292
00293
00294
00295
00296 if (ok)
00297 {
00298 #if 0
00299 CCResTextFile file;
00300 ContourInfoBarOpCreate BarCreate;
00301
00302
00303 ok = file.open( _R(IDM_CONTOUR_BAR), _R(IDT_INFO_BAR_RES) );
00304 if (ok) ok = DialogBarOp::ReadBarsFromFile(file,BarCreate);
00305 if (ok) file.close();
00306
00307 ENSURE(ok,"Unable to load blendbar.ini from resource\n");
00308
00309 if (ok)
00310 {
00311
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 }
00329
00330
00331
00332
00333
00334
00335
00336
00337
00338
00339
00340
00341
00342
00343
00344
00345
00346
00347 void ContourTool::Describe(void *InfoPtr)
00348 {
00349
00350 ToolInfo_v1 *Info = (ToolInfo_v1 *) InfoPtr;
00351
00352 Info->InfoVersion = 1;
00353
00354 Info->InterfaceVersion = GetToolInterfaceVersion();
00355
00356
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 }
00368
00369
00370
00371
00372
00373
00374
00375
00376
00377
00378
00379
00380
00381
00382
00383
00384
00385 void ContourTool::SelectChange(BOOL isSelected)
00386 {
00387
00388 #ifndef NO_ADVANCED_TOOLS
00389 if (isSelected)
00390 {
00391 if (!CreateCursors()) return;
00392 CurrentCursorID = CursorStack::GPush(pcNormalCursor, FALSE);
00393 pcCurrentCursor = pcNormalCursor;
00394
00395
00396 pContourInfoBarOp->Create();
00397
00398
00399 BlobManager* BlobMgr = GetApplication()->GetBlobManager();
00400 if (BlobMgr != NULL)
00401 {
00402
00403 BlobStyle MyBlobs;
00404 MyBlobs.Object = FALSE;
00405 MyBlobs.Tiny = TRUE;
00406
00407 BlobMgr->ToolInterest(MyBlobs);
00408 }
00409
00410 Document* pDoc = Document::GetCurrent();
00411 SetupToolBlobs();
00412
00413 if (pDoc != NULL)
00414 RenderToolBlobs(pDoc->GetSelectedSpread(),NULL);
00415
00416 pContourInfoBarOp->m_pTool = this;
00417 }
00418 else
00419 {
00420
00421 if (pcCurrentCursor != NULL)
00422 {
00423 CursorStack::GPop(CurrentCursorID);
00424 pcCurrentCursor = NULL;
00425 CurrentCursorID = 0;
00426 }
00427 DestroyCursors();
00428
00429 pContourInfoBarOp->CloseProfileDialog (pContourInfoBarOp->m_BiasGainObjectGadget);
00430 pContourInfoBarOp->CloseProfileDialog (pContourInfoBarOp->m_BiasGainAttrGadget);
00431
00432
00433 pContourInfoBarOp->Delete();
00434
00435
00436 BlobManager* BlobMgr = GetApplication()->GetBlobManager();
00437 if (BlobMgr != NULL)
00438 {
00439 BlobStyle bsRemoves;
00440 bsRemoves.ToolObject = TRUE;
00441 BlobMgr->RemoveInterest(bsRemoves);
00442 }
00443
00444 Document* pDoc = Document::GetCurrent();
00445 if (pDoc != NULL)
00446 RenderToolBlobs(pDoc->GetSelectedSpread(),NULL);
00447 }
00448 #endif // NO_ADVANCED_TOOLS
00449 }
00450
00451
00452
00453
00454
00455
00456
00457
00458
00459
00460
00461
00462
00463
00464
00465
00466
00467
00468
00469
00470
00471
00472
00473
00474
00475
00476
00477 void ContourTool::SetupToolBlobs()
00478 {
00479
00480 for (INT32 i = 0 ; i < 8; i++)
00481 {
00482 m_BlobPoints[i].x = 0;
00483 m_BlobPoints[i].y = 0;
00484 }
00485
00486
00487 if (GetApplication()->FindSelection() == NULL)
00488 return;
00489
00490 if (GetApplication()->FindSelection()->IsEmpty())
00491 return;
00492
00493 BlobManager * pBlobMgr = GetApplication()->GetBlobManager();
00494 if (pBlobMgr == NULL)
00495 return;
00496
00497
00498 INT32 BlobGap = 0;
00499 DocView* pDocView = DocView::GetSelected();
00500 if (pDocView != NULL)
00501 BlobGap = pDocView->GetScaledPixelWidth().MakeLong();
00502
00503
00504 SelRange Sel(*(GetApplication()->FindSelection()));
00505 DocRect drBounds;
00506 Node* pN = Sel.FindFirst();
00507 while (pN != NULL)
00508 {
00509 if (pN->IsBounded())
00510 {
00511 Node* pParent = pN->FindParent();
00512 while (pParent != NULL && pParent->IS_KIND_OF(NodeContourController))
00513 {
00514 pN = pParent;
00515 pParent = pN->FindParent();
00516 }
00517
00518 drBounds = drBounds.Union( ((NodeRenderableBounded*)pN)->GetBoundingRect() );
00519 }
00520 pN = Sel.FindNext(pN);
00521 }
00522
00523
00524 DocCoord dc;
00525 drBounds.Inflate(BlobGap);
00526 INT32 BlobSize = pBlobMgr->GetBlobSize();
00527
00528 dc.x = drBounds.lo.x - BlobSize;
00529 dc.y = drBounds.lo.y - BlobSize;
00530 m_BlobPoints[0] = dc;
00531
00532 dc.x = drBounds.hi.x + BlobSize;
00533 dc.y = drBounds.lo.y - BlobSize;
00534 m_BlobPoints[1] = dc;
00535
00536 dc.x = drBounds.lo.x - BlobSize;
00537 dc.y = drBounds.hi.y + BlobSize;
00538 m_BlobPoints[2] = dc;
00539
00540 dc.x = drBounds.hi.x + BlobSize;
00541 dc.y = drBounds.hi.y + BlobSize;
00542 m_BlobPoints[3] = dc;
00543
00544 dc.x = (drBounds.lo.x + drBounds.hi.x) / 2;
00545 dc.y = drBounds.hi.y + BlobSize + BlobGap;
00546 m_BlobPoints[4] = dc;
00547
00548 dc.x = (drBounds.lo.x + drBounds.hi.x) / 2;
00549 dc.y = drBounds.lo.y - BlobSize - BlobGap;
00550 m_BlobPoints[5] = dc;
00551
00552 dc.x = drBounds.lo.x - BlobSize - BlobGap;
00553 dc.y = (drBounds.lo.y + drBounds.hi.y) / 2;
00554 m_BlobPoints[6] = dc;
00555
00556 dc.x = drBounds.hi.x + BlobSize + BlobGap;
00557 dc.y = (drBounds.lo.y + drBounds.hi.y) / 2;
00558 m_BlobPoints[7] = dc;
00559 }
00560
00561
00562
00563
00564
00565
00566
00567
00568
00569
00570
00571
00572
00573
00574
00575
00576
00577 BOOL ContourTool::CreateCursors()
00578 {
00579
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 }
00593
00594
00595
00596
00597
00598
00599
00600
00601
00602
00603
00604
00605
00606
00607
00608 BOOL ContourTool::IsPointOverBlob(DocCoord &Point, DocRect * pBlobRect)
00609 {
00610
00611 BlobManager * pBlobMgr = GetApplication()->GetBlobManager();
00612
00613 INT32 BlobSize = 0;
00614
00615
00616
00617
00618 if (pBlobMgr)
00619 BlobSize = pBlobMgr->GetBlobSize();
00620
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 }
00639
00640
00641
00642
00643
00644
00645
00646
00647
00648
00649
00650
00651
00652
00653
00654 void ContourTool::DestroyCursors()
00655 {
00656 if (pcNormalCursor != NULL) delete pcNormalCursor;
00657 if (pcOverBlob != NULL) delete pcOverBlob;
00658
00659 pcNormalCursor = NULL;
00660 pcOverBlob = NULL;
00661 }
00662
00663
00664
00665
00666
00667
00668
00669
00670
00671
00672
00673
00674
00675 BOOL ContourTool::OnKeyPress(KeyPress* pKeyPress)
00676 {
00677 #ifdef _DEBUG
00678 if (pKeyPress == NULL)
00679 return FALSE;
00680
00681 if (pKeyPress->IsRepeat())
00682 return FALSE;
00683
00684 if (pKeyPress->IsRelease())
00685 return FALSE;
00686
00687 AFp BiasDelta = 0.0;
00688 AFp GainDelta = 0.0;
00689 BOOL Reset = FALSE;
00690 if (*pKeyPress == KeyPress(CAMKEY(Z))) { BiasDelta = -0.1; TRACEUSER( "Markn", _T("Decrease Bias by 0.1\n"));}
00691 if (*pKeyPress == KeyPress(CAMKEY(X))) { BiasDelta = 0.1; TRACEUSER( "Markn", _T("Increase Bias by 0.1\n"));}
00692 if (*pKeyPress == KeyPress(CAMKEY(N))) { GainDelta = -0.1; TRACEUSER( "Markn", _T("Decrease Gain by 0.1\n"));}
00693 if (*pKeyPress == KeyPress(CAMKEY(M))) { GainDelta = 0.1; TRACEUSER( "Markn", _T("Increase Gain by 0.1\n"));}
00694
00695 if (*pKeyPress == KeyPress(CAMKEY(R))) { Reset = TRUE; TRACEUSER( "Markn", _T("Resetting Bias and Gain\n"));}
00696
00697 SelRange* pSelRange = GetApplication()->FindSelection();
00698 Node* pNode = pSelRange->FindFirst();
00699 while (pNode)
00700 {
00701 if (IS_A(pNode,NodeBlend))
00702 {
00703 NodeBlend* pNodeBlend = (NodeBlend*)pNode;
00704
00705
00706 CProfileBiasGain* pProfile = pNodeBlend->GetAttrProfile();
00707 if (pProfile)
00708 {
00709 AFp Bias = pProfile->GetBias() + BiasDelta;
00710 AFp Gain = pProfile->GetGain() + GainDelta;
00711 if (Reset)
00712 Bias = Gain = 0.0;
00713
00714 if (Bias < -0.9) Bias = -0.9;
00715 if (Bias > 0.9) Bias = 0.9;
00716 if (Gain < -0.9) Gain = -0.9;
00717 if (Gain > 0.9) Gain = 0.9;
00718
00719 pProfile->SetBiasGain(Bias,Gain);
00720 }
00721 }
00722
00723 pNode = pSelRange->FindNext(pNode);
00724 }
00725 #endif // _DEBUG
00726
00727 return FALSE;
00728 }
00729
00730
00731
00732
00733
00734
00735
00736
00737
00738
00739
00740
00741
00742
00743
00744
00745
00746
00747
00748 void ContourTool::OnClick( DocCoord PointerPos, ClickType Click, ClickModifiers ClickMods,
00749 Spread* pSpread )
00750 {
00751
00752 #ifndef NO_ADVANCED_TOOLS
00753 if (ClickMods.Menu) return;
00754
00755 ERROR3IF_PF(pSpread==NULL,("pSpread is NULL"));
00756
00757
00758
00759 DocRect BlobRect;
00760
00761 switch (Click)
00762 {
00763
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
00776 case CLICKTYPE_SINGLE:
00777 {
00778
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
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
00801
00802 DragTool::OnClick (PointerPos, Click, ClickMods, pSpread);
00803 }
00804 break;
00805
00806 default:
00807
00808
00809 DragTool::OnClick (PointerPos, Click, ClickMods, pSpread);
00810 break;
00811 }
00812 #endif // NO_ADVANCED_TOOLS
00813 }
00814
00815
00816
00817
00818
00819
00820
00821
00822
00823
00824
00825 void ContourTool::InformWarningBevelExistsInSelection()
00826 {
00827 String_256 QueryString(_R(IDS_CANTCONTOURBEVEL));
00828
00829 Error::SetError(0, QueryString, 0);
00830
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 }
00839
00840
00841
00842
00843
00844
00845
00846
00847
00848
00849
00850
00851
00852
00853
00854
00855 void ContourTool::OnMouseMove(DocCoord PointerPos,Spread* pSpread,ClickModifiers ClickMods)
00856 {
00857
00858 #ifndef NO_ADVANCED_TOOLS
00859 ERROR3IF_PF(pSpread==NULL,("pSpread is NULL"));
00860
00861
00862
00863
00864 if (IsPointOverBlob(PointerPos))
00865 {
00866
00867 if (pcCurrentCursor != pcOverBlob )
00868 {
00869 if (pcCurrentCursor)
00870 {
00871 CursorStack::GPop(CurrentCursorID);
00872 }
00873
00874 CurrentCursorID = CursorStack::GPush(pcOverBlob, TRUE);
00875 pcCurrentCursor = pcOverBlob;
00876 DisplayStatusBarHelp(_R(IDS_CONTOUROVERBLOBHELP));
00877 }
00878 }
00879 else
00880 {
00881
00882 if (pcCurrentCursor != pcNormalCursor )
00883 {
00884 if (pcCurrentCursor)
00885 {
00886 CursorStack::GPop(CurrentCursorID);
00887 }
00888
00889 CurrentCursorID = CursorStack::GPush(pcNormalCursor, TRUE);
00890 pcCurrentCursor = pcNormalCursor;
00891 DisplayStatusBarHelp(_R(IDS_CONTOURDRAGHELP));
00892 }
00893 }
00894 #endif // NO_ADVANCED_TOOLS
00895 }
00896
00897
00898
00899
00900
00901
00902
00903
00904
00905
00906
00907
00908
00909
00910
00911
00912
00913
00914
00915
00916
00917
00918 void ContourTool::UpdateRef(BlendToolRef* pRef,Spread* pSpread, DocCoord PointerPos,BOOL CheckNodeUnderPoint)
00919 {
00920 ERROR3IF_PF(pRef ==NULL,("pRef is NULL"));
00921 ERROR3IF_PF(pSpread==NULL,("pSpread is NULL"));
00922
00923
00924 pRef->pSpread = pSpread;
00925 pRef->PointerPos = PointerPos;
00926 }
00927
00928
00929
00930
00931
00932
00933
00934
00935
00936
00937
00938
00939
00940
00941
00942
00943
00944
00945
00946
00947
00948
00949
00950
00951 void ContourTool::UpdateCursorAndStatus()
00952 {
00953 ERROR3IF_PF(pRefStart==NULL,("pRefStart is NULL"));
00954 ERROR3IF_PF(pRefEnd ==NULL,("pRefEnd is NULL"));
00955
00956 DisplayStatusBarHelp(StatusID);
00957 }
00958
00959
00960
00961
00962
00963
00964
00965
00966
00967
00968
00969
00970
00971
00972
00973
00974
00975
00976
00977 BOOL ContourTool::GetStatusLineText(String_256* pStr,Spread* pSpread,DocCoord DocPos,ClickModifiers ClickMods)
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 }
00990
00991
00992
00993
00994
00995
00996
00997
00998
00999
01000
01001
01002
01003
01004
01005
01006
01007
01008
01009 BOOL ContourTool::IsPointOverPathBlob(DocCoord* pPointerPos,BlendToolRef* pRef)
01010 {
01011 if (pRef == NULL) return FALSE;
01012
01013
01014 SelRange* pSelRange = GetApplication()->FindSelection();
01015 Node* pNode = pSelRange->FindFirst();
01016
01017 BOOL BlobFound = FALSE;
01018
01019
01020 while (!BlobFound && pNode != NULL && pNode->FindParent() != NULL)
01021 {
01022
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
01030 Path* pPath = &(pNodePath->InkPath);
01031
01032
01033 BlobFound = pPath->FindNearestPoint(*pPointerPos,POINTFLAG_ENDPOINTS,&(pRef->Index));
01034
01035
01036 if (BlobFound)
01037 {
01038 pRef->pNode = pNodePath;
01039 pPath->SetPathPosition(pRef->Index);
01040 *pPointerPos = pPath->GetCoord();
01041 }
01042 }
01043 }
01044
01045
01046 pNode = pSelRange->FindNext(pNode);
01047 }
01048
01049 return BlobFound;
01050 }
01051
01052
01053
01054
01055
01056
01057
01058
01059
01060
01061
01062
01063
01064
01065
01066
01067
01068
01069
01070 BOOL ContourTool::IsPointOverBlendBlob(DocCoord* pPointerPos,BlendToolRef* pRef)
01071 {
01072 if (pRef == NULL) return FALSE;
01073
01074
01075 SelRange* pSelRange = GetApplication()->FindSelection();
01076 Node* pNode = pSelRange->FindFirst();
01077
01078 BOOL BlobFound = FALSE;
01079
01080
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
01100 }
01101 }
01102 }
01103
01104
01105 pNode = pSelRange->FindNext(pNode);
01106 }
01107
01108 return BlobFound;
01109 }
01110
01111
01112
01113
01114
01115
01116
01117
01118
01119
01120
01121
01122
01123
01124
01125
01126
01127
01128
01129
01130 void ContourTool::CheckNodeRemapping(BlendToolRef* pRefStart, BlendToolRef* pRefEnd)
01131 {
01132 ERROR3IF(pRefStart == NULL,"pRefStart == NULL");
01133 ERROR3IF(pRefEnd == NULL,"pRefEnd == NULL");
01134 }
01135
01136
01137
01138
01139
01140
01141
01142
01143
01144
01145
01146
01147
01148
01149
01150
01151
01152 NodeRenderableInk* ContourTool::FindObject(Spread* pSpread, DocCoord PointerPos)
01153 {
01154 return NodeRenderableInk::FindCompoundAtPoint(pSpread,PointerPos,NULL);
01155 }
01156
01157
01158
01159
01160
01161
01162
01163
01164
01165
01166
01167
01168
01169
01170
01171
01172
01173
01174
01175
01176
01177
01178
01179
01180 void ContourTool::RenderToolBlobs(Spread* pSpread,DocRect* pDocRect)
01181 {
01182
01183
01184 if (m_bDisableBlobRenderingFlag)
01185 return;
01186
01187
01188 BOOL bZeroBlobs = TRUE;
01189
01190 for (UINT32 i = 0 ; i < 8; i++)
01191 {
01192 if (m_BlobPoints[i].x != 0 ||
01193 m_BlobPoints[i].y != 0)
01194 {
01195 bZeroBlobs = FALSE;
01196 break;
01197 }