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 #include "camtypes.h"
00102 #include "opdrbrsh.h"
00103
00104 #include "pen.h"
00105
00106
00107
00108 #include "opfree.h"
00109
00110 #include "freehand.h"
00111 #include "csrstack.h"
00112
00113 #include "combshps.h"
00114
00115
00116 #include "ndbldpth.h"
00117
00118 #include "progress.h"
00119
00120
00121 #include "objchge.h"
00122
00123 #include "attrmap.h"
00124 #include "nodershp.h"
00125 #include "opbevel.h"
00126 #include "nodebev.h"
00127
00128 #include "blndtool.h"
00129 #include "brshattr.h"
00130 #include "brshcomp.h"
00131 #include "pathproc.h"
00132 #include "lineattr.h"
00133 #include "freehand.h"
00134
00135
00136
00137 #include "rsmooth.h"
00138 #include "camelot.h"
00139 #include "nodeshad.h"
00140 #include "nodecntr.h"
00141 #include "lineattr.h"
00142 #include "samplist.h"
00143 #include "linwthop.h"
00144
00145 #include "ophist.h"
00146 #include "ppbrush.h"
00147
00148 #include "qualattr.h"
00149
00150
00151 CC_IMPLEMENT_DYNCREATE( OpDrawBrush, SelOperation );
00152 CC_IMPLEMENT_DYNCREATE( OpChangeBrush, SelOperation );
00153 CC_IMPLEMENT_DYNAMIC(ChangeBrushOpParam, OpParam);
00154 CC_IMPLEMENT_DYNCREATE(ChangeBrushAction, Action);
00155 CC_IMPLEMENT_DYNCREATE(RemoveTimeStampPointsAction, Action);
00156 CC_IMPLEMENT_DYNCREATE(AddTimeStampPointsAction, Action);
00157 CC_IMPLEMENT_DYNCREATE(UpdateBrushAction, Action);
00158 CC_IMPLEMENT_DYNCREATE(SetTimeStampUpdateTypeAction, Action);
00159 CC_IMPLEMENT_DYNCREATE(RemovePressurePointsAction, Action);
00160 CC_IMPLEMENT_DYNCREATE(AddPressurePointsAction, Action);
00161
00162 #define DELPTR(p) if (p != NULL) { delete p; p = NULL; }
00163 #define SWAP(type,a,b) { type x=a; a=b; b=x; }
00164
00165
00166 #define new CAM_DEBUG_NEW
00167
00168 const UINT32 PressureValsThreshold = 3;
00169
00170
00171
00172
00173
00174
00175
00176
00177
00178
00179
00180
00181
00182
00183 OpDrawBrush::OpDrawBrush()
00184 {
00185 ResetMembers();
00186 }
00187
00188
00189
00190
00191
00192
00193
00194
00195
00196
00197
00198 OpDrawBrush::OpDrawBrush(FreeHandTool *pTool)
00199 {
00200 ResetMembers();
00201 if (pTool != NULL)
00202 m_pTool = pTool;
00203 }
00204
00205
00206
00207
00208
00209
00210
00211
00212
00213
00214
00215
00216 OpDrawBrush::~OpDrawBrush()
00217 {
00218
00219
00220 if (m_pProcPathDistance != NULL)
00221 delete m_pProcPathDistance;
00222
00223
00224 if (m_pPathProcBrush != NULL)
00225 delete m_pPathProcBrush;
00226
00227 if (m_pPressureList != NULL)
00228 delete m_pPressureList;
00229
00230 if (m_pPointsCache != NULL)
00231 delete m_pPointsCache;
00232
00233 if (m_pPressureSampler != NULL)
00234 delete m_pPressureSampler;
00235 }
00236
00237
00238
00239
00240
00241
00242
00243
00244
00245
00246
00247
00248 void OpDrawBrush::ResetMembers()
00249 {
00250
00251 pFreeHandCursor = NULL;
00252 pJoinCursor = NULL;
00253 pStraightCursor = NULL;
00254 pRubOutCursor = NULL;
00255 pModifyCursor = NULL;
00256
00257
00258 TrackData = NULL;
00259 StartSpread = NULL;
00260 PreviousSpread = NULL;
00261 Smoothness = 512;
00262 LineSegmentCount = 0;
00263 CanLineJoin = FALSE;
00264 IsStraightLineMode = FALSE;
00265 AddPressureToPath = FALSE;
00266 FreeHandPressure = 0;
00267
00268
00269 pJoinInfo = NULL;
00270 StartPath = NULL;
00271 EndPath = NULL;
00272 CloseTo = 0;
00273 Mu = 0.0;
00274 IsEndNearEndpoint = FALSE;
00275 CurrentCursorID = 0;
00276
00277 m_pGRenderBrush = NULL;
00278 m_pPathProcBrush = NULL;
00279
00280 m_pBrushDefinition = NULL;
00281 mustClearStatusBar = TRUE;
00282 pApp = GetApplication ();
00283 ERROR3IF (!pApp, "Could not find the application!");
00284
00285 m_pProcPathDistance = NULL;
00286 m_BrushScaling = 1.0;
00287
00288 #ifdef OPBRUSHPOINTSCACHE
00289 m_pPointsCache = NULL;
00290 #endif
00291
00292 m_pTimeStampList = NULL;
00293 m_TimeStamp = 0;
00294 m_LastTimeStamp = -1;
00295
00296 m_pPressureList = NULL;
00297
00298 m_LastPathIndexRendered = 1;
00299
00300 m_FirstSpacing = 25;
00301
00302 m_pPressureSampler = NULL;
00303 m_NumPressureVals = 0;
00304
00305
00306 }
00307
00308
00309
00310
00311
00312
00313
00314
00315
00316
00317
00318
00319
00320
00321
00322
00323
00324
00325
00326
00327
00328
00329 void OpDrawBrush::DoDrag(DocCoord Anchor, Spread *pSpread, INT32 Smooth, BrushHandle Handle,
00330 FreeHandJoinInfo* pFreeHandInfo, Path* ToolPath,
00331 GRenderBrush* pGRndRgn, ClickModifiers ClickMods)
00332 {
00333 TRACEUSER( "Diccon", _T("Drag started\n"));
00334 if (pSpread == NULL)
00335 {
00336 ERROR3("No spread");
00337 FailAndExecute();
00338 End();
00339 return;
00340 }
00341 if (ToolPath == NULL)
00342 {
00343 ERROR3("Tool path is NULL");
00344 FailAndExecute();
00345 End();
00346 return;
00347 }
00348
00349
00350
00351 #ifdef VECTOR_STROKING
00352
00353 CCPen *pPen = pApp->GetPressurePen();
00354 if (pPen != NULL)
00355 pPen->StartStroke();
00356 #endif // VECTOR_STROKING
00357
00358
00359 if ((pFreeHandInfo==NULL) || (pFreeHandInfo->pJoinPath==NULL))
00360 DocView::SnapCurrent(pSpread, &Anchor, FALSE, TRUE);
00361
00362
00363 TrackData = ToolPath;
00364 Smoothness = Smooth;
00365 pJoinInfo = pFreeHandInfo;
00366 StartPath = pJoinInfo->pJoinPath;
00367 EndPath = NULL;
00368
00369
00370 StartPoint = Anchor;
00371 StartSpread = pSpread;
00372 PreviousSpread= pSpread;
00373 PreviousPoint = Anchor;
00374 LineSegmentCount = 0;
00375 IsStraightLineMode = FALSE;
00376 CanLineJoin = FALSE;
00377
00378
00379 if (!PrepareTrackDataPath())
00380 {
00381
00382 InformError(_R(IDS_OUT_OF_MEMORY), _R(IDS_OK));
00383 FailAndExecute();
00384 End();
00385 return;
00386 }
00387
00388
00389 if (!LoadCursors())
00390 {
00391
00392 FailAndExecute();
00393 End();
00394 return;
00395 }
00396
00397
00398
00399 CurrentCursorID = CursorStack::GPush(pFreeHandCursor, TRUE);
00400 MyCurrentCursor = pFreeHandCursor;
00401
00402
00403 TRACEUSER( "Diccon", _T("DRAG STARTED\n"));
00404 if (pGRndRgn == NULL)
00405 {
00406 ERROR3("No GRenderBrush");
00407 FailAndExecute();
00408 End();
00409 return;
00410 }
00411 else
00412 m_pGRenderBrush = pGRndRgn;
00413
00414
00415 if (pFreeHandInfo->m_BrushHandle != BrushHandle_NoBrush)
00416 Handle = pFreeHandInfo->m_BrushHandle;
00417
00418 if (!InitialisePathProcessorBrush(Handle, pFreeHandInfo->BrushDistance))
00419 {
00420 FailAndExecute();
00421 End();
00422 return;
00423 }
00424
00425
00426
00427 if (pFreeHandInfo->m_BrushHandle != BrushHandle_NoBrush && pFreeHandInfo->pAttrBrush != NULL)
00428 {
00429
00430 m_pPathProcBrush->GetSpacingAndScalingAtDistance(pFreeHandInfo->BrushDistance, &m_FirstSpacing, &m_BrushScaling);
00431
00432 m_pPathProcBrush->CopyDataFromObject(&(pFreeHandInfo->m_BrushData));
00433 m_LastSpacing = m_pPathProcBrush->GetSpacing();
00434
00435
00436
00437 m_BrushScaling = pFreeHandInfo->m_BrushData.m_BrushScaling;
00438
00439 m_pPathProcBrush->AdvanceBrushToDistance(pFreeHandInfo->BrushDistance);
00440
00441 m_LastInkObjectRendered = m_pPathProcBrush->GetLastObject();
00442
00443
00444 m_pPathProcBrush->SetUseLocalFillColour(pFreeHandInfo->UseLocalColour);
00445 m_pPathProcBrush->SetUseNamedColours(pFreeHandInfo->UseNamedColour);
00446 if (pFreeHandInfo->UseLocalColour || !pFreeHandInfo->UseNamedColour)
00447 m_pPathProcBrush->SetStrokeColour(pFreeHandInfo->StrokeColour);
00448
00449
00450
00451
00452 }
00453
00454 if (!InitialiseProcessPathDistance())
00455 {
00456 FailAndExecute();
00457 End();
00458 return;
00459 }
00460
00461 if (!InitialisePressureSampler())
00462 {
00463 FailAndExecute();
00464 End();
00465 return;
00466 }
00467 if (AddPressureToPath == TRUE)
00468 {
00469
00470
00471 }
00472
00473 if (m_pPathProcBrush != NULL)
00474 {
00475 m_NumInkObjects = m_pPathProcBrush->GetNumBrushObjects();
00476 m_BrushSpacing = m_pPathProcBrush->GetSpacing();
00477 m_pPathProcBrush->SetParentAttribute(pFreeHandInfo->pAttrBrush);
00478 }
00479 else
00480 {
00481 FailAndExecute();
00482 End();
00483 return;
00484 }
00485 if (m_NumInkObjects < 1)
00486 {
00487 ERROR3("No brush ink objects");
00488 FailAndExecute();
00489 End();
00490 return;
00491 }
00492
00493
00494
00495 #ifdef OPBRUSHPOINTSCACHE
00496 if (m_TimeStamp <= 0 && pFreeHandInfo->m_BrushHandle == BrushHandle_NoBrush)
00497 {
00498
00499 m_pPointsCache = new PointsMap;
00500
00501
00502
00503
00504
00505
00506
00507 }
00508 #endif
00509
00510 if (m_TimeStamp > 0)
00511 {
00512 if (!InitialiseTimeStampList())
00513 {
00514
00515 FailAndExecute();
00516 End();
00517 return;
00518 }
00519 }
00520
00521
00522 m_StartPoint = Anchor;
00523
00524
00525 m_LastPoint = Anchor;
00526 m_LastPointRendered = Anchor;
00527 m_LastDistanceRendered = 0;
00528 m_DistanceSinceLastObject = 0;
00529 m_LastSpacing = m_BrushSpacing;
00530 m_NumBrushObjects = 0;
00531
00532 AddPointsToPath(Anchor, pSpread);
00533 m_bFirstPointRendered = FALSE;
00534
00535 StartDrag( DRAGTYPE_NOSCROLL );
00536
00537
00538
00539 PORTNOTE("other", "Removed m_pRenderGBrush");
00540 #ifndef EXCLUDE_FROM_XARALX
00541
00542 View* pView = View::GetCurrent();
00543 CCamView* pCCamView = pView->GetConnectionToOilView();
00544 CDC* pDevContext = pCCamView->GetRenderDC();
00545 HDC DeviceHdc = pDevContext->GetSafeHdc();
00546
00547 m_pGRenderBrush->SetView (pView);
00548 m_pGRenderBrush->SetCamView (pView->GetConnectionToOilView());
00549 m_pGRenderBrush->SetCDC (pCCamView->GetRenderDC());
00550 m_pGRenderBrush->SetHDC (pDevContext->GetSafeHdc());
00551
00552 #endif
00553 }
00554
00555
00556
00557
00558
00559
00560
00561
00562
00563
00564
00565
00566
00567
00568
00569
00570
00571
00572 void OpDrawBrush::DragPointerMove( DocCoord PointerPos, ClickModifiers ClickMods,
00573 Spread *pSpread, BOOL bSolidDrag)
00574 {
00575
00576 if (AddPressureToPath)
00577 FreeHandPressure = ClickMods.Pressure;
00578
00579
00580
00581 if (pSpread != StartSpread)
00582 #ifdef NEWFASTBRUSHES
00583 PointerPos = MakeRelativeToSpreadNoOverhead(StartSpread, pSpread, PointerPos);
00584 #else
00585 PointerPos = MakeRelativeToSpread(StartSpread, pSpread, PointerPos);
00586 #endif
00587
00588
00589 ClickMods.Alternative1 = FALSE;
00590 ClickMods.Adjust = FALSE;
00591
00592
00593 SetCursorOnMove(ClickMods, StartSpread, &PointerPos);
00594
00595 AddPointsToPath(PointerPos, StartSpread);
00596
00597 PreviousSpread = pSpread;
00598
00599
00600 double Distance = (PointerPos.Distance(m_LastPoint));
00601 m_DistanceSinceLastObject += (MILLIPOINT)Distance;
00602
00603 m_LastPoint = PointerPos;
00604
00605 if (m_pPressureSampler != NULL)
00606 {
00607 m_NumPressureVals++;
00608 if (m_NumPressureVals > PressureValsThreshold)
00609 {
00610 TRACEUSER( "Diccon", _T("Pressure = %d\n"), ClickMods.Pressure);
00611
00612 if (!m_pPressureSampler->CollectData(PointerPos, FreeHandPressure))
00613 {
00614 ERROR3("Error in Pressure sampler, aborting..");
00615 FailAndExecute();
00616 End();
00617 return;
00618 }
00619 }
00620 else
00621 return;
00622
00623 }
00624
00625
00626
00627 {
00628 PORTNOTE("other", "Removed m_pRenderGBrush");
00629 #ifndef EXCLUDE_FROM_XARALX
00630 if(m_pGRenderBrush != NULL)
00631 {
00632 QualityAttribute *pQuality = (QualityAttribute *) m_pGRenderBrush->GetCurrentAttribute(ATTR_QUALITY);
00633 if (pQuality != NULL && pQuality->QualityValue.GetBlendQuality() != Quality::FullBlend)
00634 {
00635 RenderRegion* pRegion = DocView::RenderOnTop(NULL, pSpread, UnclippedEOR );
00636 while ( pRegion )
00637 {
00638 RenderLine(pRegion, TrackData, TrackData->GetNumCoords()-1, FALSE);
00639
00640 pRegion = DocView::GetNextOnTop(NULL);
00641 }
00642 return;
00643 }
00644 }
00645 #endif
00646 }
00647
00648
00649
00650
00651 RenderStepsForTime(50, pSpread);
00652
00653
00654
00655
00656
00657
00658
00659 }
00660
00661
00662
00663
00664
00665
00666
00667
00668
00669
00670
00671
00672
00673
00674
00675
00676
00677
00678 void OpDrawBrush::DragPointerIdle(DocCoord PointerPos, ClickModifiers ClickMods, Spread* pSpread, BOOL bSolidDrag)
00679 {
00680 BOOL bAllowRender = TRUE;
00681
00682
00683
00684
00685 {
00686 PORTNOTE("other", "Removed m_pRenderGBrush");
00687 #ifndef EXCLUDE_FROM_XARALX
00688 if(m_pGRenderBrush != NULL)
00689 {
00690 QualityAttribute *pQuality = (QualityAttribute *) m_pGRenderBrush->GetCurrentAttribute(ATTR_QUALITY);
00691 if (pQuality != NULL && pQuality->QualityValue.GetBlendQuality() != Quality::FullBlend)
00692 {
00693 bAllowRender = FALSE;
00694
00695 }
00696 }
00697 #endif
00698 }
00699
00700
00701
00702 if (AddPressureToPath)
00703 {
00704 if (m_NumPressureVals > PressureValsThreshold && bAllowRender)
00705 RenderStepsForTime(75, pSpread);
00706 }
00707 else
00708 {
00709 if(bAllowRender)
00710 RenderStepsForTime(75, pSpread);
00711 }
00712
00713
00714 }
00715
00716
00717
00718
00719
00720
00721
00722
00723
00724
00725
00726
00727
00728
00729
00730
00731
00732
00733
00734
00735
00736
00737
00738
00739 void OpDrawBrush::RenderStepsForTime(double TimeSlice, Spread* pSpread)
00740 {
00741 if ( (m_pProcPathDistance == NULL) || (m_pPathProcBrush == NULL)
00742 || (m_pGRenderBrush == NULL) || (TrackData == NULL))
00743 {
00744 ERROR3("One or more members are NULL");
00745 return;
00746 }
00747
00748 MonotonicTime timer;
00749
00750
00751 DocCoord Point;
00752 double Angle;
00753 UINT32 Pressure = 0;
00754 CSampleItem TheItem;
00755 BrushPointInfo PathPoint;
00756
00757
00758 MILLIPOINT DistanceToGetPoint = m_LastDistanceRendered;
00759
00760
00761
00762
00763
00764 MILLIPOINT Spacing = m_LastSpacing;
00765 if (!m_bFirstPointRendered)
00766 {
00767 Spacing = m_FirstSpacing;
00768 if (m_pPressureSampler != NULL)
00769 {
00770 if (m_pPressureSampler->GetAt(0, &TheItem))
00771 Pressure = TheItem.m_Pressure;
00772 else
00773 Pressure =127;
00774 m_pPathProcBrush->SetCurrentPressure(Pressure);
00775 }
00776 }
00777
00778
00779 BOOL Found;
00780
00781 #ifdef SCALESPACING
00782 double ActualSpacing = (double)Spacing * m_BrushScaling;
00783 #else
00784 double ActualSpacing = (double)Spacing * m_pPathProcBrush->GetBrushScaling();
00785 #endif
00786
00787
00788 UINT32 Dummy = 0;
00789
00790 while (m_DistanceSinceLastObject >= (MILLIPOINT)ActualSpacing)
00791 {
00792
00793
00794 m_pPathProcBrush->SetNextOffsetType();
00795
00796
00797 DistanceToGetPoint += (MILLIPOINT)ActualSpacing;
00798
00799
00800 m_pProcPathDistance->GetCoordAndTangentWithCache(&Point, &Angle, &Found,
00801 DistanceToGetPoint, TrackData, &Dummy);
00802 if (Found)
00803 {
00804
00805
00806 PathPoint.m_Point = Point;
00807 PathPoint.m_Tangent = Angle;
00808 PathPoint.m_Pressure = Dummy;
00809
00810
00811 PORTNOTE("other", "Removed m_pRenderGBrush");
00812 #ifndef EXCLUDE_FROM_XARALX
00813 if (m_BrushScaling > 0)
00814 {
00815 m_pPathProcBrush->RenderBrushAtPoint(Point, Angle, m_LastInkObjectRendered, m_NumBrushObjects,
00816 m_pGRenderBrush, NULL, TRUE, m_pBrushDefinition);
00817 }
00818 #endif
00819
00820 if (m_pPressureSampler != NULL && m_bFirstPointRendered)
00821 {
00822 m_pPressureSampler->SetSampleRateFromSpacing((MILLIPOINT)ActualSpacing);
00823
00824 if (m_pPressureSampler->GetNext(&TheItem))
00825 Pressure = TheItem.m_Pressure;
00826 else
00827 Pressure = 127;
00828 m_pPathProcBrush->SetCurrentPressure(Pressure);
00829
00830 }
00831
00832 PORTNOTE("other", "Removed m_pRenderGBrush");
00833 #ifndef EXCLUDE_FROM_XARALX
00834
00835 m_pGRenderBrush->DrawToScreenNow();
00836 #endif
00837
00838 m_DistanceSinceLastObject -= (MILLIPOINT)(ActualSpacing);
00839 m_LastDistanceRendered = DistanceToGetPoint;
00840
00841
00842 Spacing = m_pPathProcBrush->GetNextSpacing();
00843 m_BrushScaling = m_pPathProcBrush->GetLastScaling();
00844 #ifdef SCALESPACING
00845 ActualSpacing = Spacing * m_BrushScaling;
00846 #else
00847 ActualSpacing = (double)Spacing * m_pPathProcBrush->GetBrushScaling();
00848 #endif
00849
00850 m_pPathProcBrush->SwitchAlternateValue();
00851
00852 #ifdef OPBRUSHPOINTSCACHE
00853
00854 if (m_pPointsCache != NULL)
00855 (*m_pPointsCache)[DistanceToGetPoint]=PathPoint;
00856 #endif
00857
00858
00859 m_LastInkObjectRendered = m_pPathProcBrush->GetNextInkObject(m_LastInkObjectRendered,
00860 m_NumInkObjects);
00861
00862 m_pPathProcBrush->DecideWhetherToUseActualScaling(m_LastInkObjectRendered);
00863
00864 m_NumBrushObjects++;
00865 m_bFirstPointRendered = TRUE;
00866
00867 }
00868
00869
00870 if (timer.Elapsed(UINT32(TimeSlice * 1000.0)))
00871 break;
00872 }
00873
00874
00875 m_LastSpacing = Spacing;
00876 }
00877
00878
00879
00880
00881
00882
00883
00884
00885
00886
00887
00888
00889
00890
00891
00892 void OpDrawBrush::RenderTimeStamp()
00893 {
00894 if (m_TimeStamp <=0)
00895 {
00896 ERROR3("Invalid timestamp value");
00897 return;
00898 }
00899
00900 if (m_Timer.Elapsed((UINT32)(m_TimeStamp * 1000.0)))
00901 {
00902 m_Timer.Sample();
00903
00904
00905 MILLIPOINT DistanceAlongPath = m_LastDistanceRendered + m_DistanceSinceLastObject;
00906
00907 DocCoord Point;
00908 double Angle = 0;
00909 BOOL Found = FALSE;
00910
00911 m_pProcPathDistance->GetCoordAndTangentWithCache(&Point, &Angle, &Found,
00912 DistanceAlongPath, TrackData);
00913
00914 if (Found)
00915 {
00916 TimeStampBrushPoint TSP(Point, Angle, DistanceAlongPath);
00917
00918
00919 m_LastInkObjectRendered = m_pPathProcBrush->GetNextInkObject(m_LastInkObjectRendered,
00920 m_NumInkObjects);
00921
00922 PORTNOTE("other", "Removed m_pRenderGBrush");
00923 #ifndef EXCLUDE_FROM_XARALX
00924
00925 if (m_pGRenderBrush != NULL)
00926 {
00927 m_pPathProcBrush->RenderBrushAtPoint(Point, Angle, m_LastInkObjectRendered++, 1,
00928 m_pGRenderBrush, NULL, TRUE);
00929
00930 m_pGRenderBrush->DrawToScreenNow();
00931 TRACEUSER( "Diccon", _T("OpDrawBrush Rendered TimeStamp"));
00932 }
00933 #endif
00934
00935 m_DistanceSinceLastObject = 0;
00936 m_LastDistanceRendered = DistanceAlongPath;
00937
00938
00939 if (m_pTimeStampList != NULL)
00940 m_pTimeStampList->push_back(TSP);
00941 }
00942 }
00943 }
00944
00945
00946
00947
00948
00949
00950
00951
00952
00953
00954
00955
00956
00957
00958
00959
00960
00961
00962
00963
00964
00965
00966 void OpDrawBrush::DragFinished( DocCoord PointerPos, ClickModifiers ClickMods,
00967 Spread *pSpread, BOOL Success, BOOL bSolidDrag)
00968 {
00969 TRACEUSER( "Diccon", _T("Drag finished\n"));
00970
00971 DocRect ClipRect(0,0,0,0);
00972 RenderDragBlobs(ClipRect, StartSpread, bSolidDrag);
00973
00974
00975 RemoveCursors();
00976
00977
00978
00979 String_32 ProgString = _T("Calculating brush, please wait..");
00980 Progress Hourglass(&ProgString, -1, FALSE);
00981
00982 EndDrag();
00983
00984
00985
00986 BOOL Worked = FALSE;
00987 if (Success)
00988 {
00989
00990 if (IsStraightLineMode)
00991 {
00992
00993 AddStraightLine();
00994 PreviousPoint = StraightLinePos;
00995 IsStraightLineMode = FALSE;
00996 }
00997 BeginSlowJob(-1, TRUE, NULL);
00998
00999
01000
01001 DocRect BRect = m_pPathProcBrush->GetCachedRect();
01002
01003 Node* pANode = NULL;
01004 if (m_pPathProcBrush->GetParentAttribute())
01005 {
01006 pANode = m_pPathProcBrush->GetParentAttribute()->FindParent();
01007 if (pANode->IsBounded())
01008 {
01009 ((NodeRenderableBounded*)pANode)->ReleaseCached();
01010 }
01011 }
01012 DoInvalidateRegion(pSpread, BRect);
01013
01014
01015 m_pPathProcBrush->CleanUpAfterRender();
01016
01017 BrushDefinition* pDef = BrushComponent::FindBrushDefinition(m_pPathProcBrush->GetBrushDefinitionHandle());
01018 if (pDef)
01019 pDef->StopRender();
01020 else
01021 ERROR3("Unable to get brush definition in OpDrawBrush::DragFinished");
01022
01023
01024 Worked = CompleteOperation();
01025 EndSlowJob();
01026 }
01027
01028
01029
01030 #ifdef VECTOR_STROKING
01031
01032 CCPen *pPen = pApp->GetPressurePen();
01033 if (pPen != NULL)
01034 pPen->EndStroke();
01035 #endif // VECTOR_STROKING
01036
01037
01038 if (m_pTool != NULL)
01039 m_pTool->BrushFinished();
01040
01041
01042 m_pGRenderBrush = NULL;
01043
01044
01045 if (Worked==FALSE)
01046 FailAndExecute();
01047 else
01048 {
01049
01050 ObjChangeFlags cFlags;
01051 ObjChangeParam ObjChange(OBJCHANGE_STARTING,cFlags,NULL,this);
01052 ObjChange.Define(OBJCHANGE_FINISHED,cFlags,NULL,this);
01053 UpdateChangedNodes(&ObjChange);
01054 }
01055
01056 End();
01057 }
01058
01059
01060
01061
01062
01063
01064
01065
01066
01067
01068
01069
01070
01071
01072
01073
01074
01075
01076
01077
01078
01079
01080
01081
01082
01083
01084 BOOL OpDrawBrush::ApplyAttributes(NodePath* pNewPath, Document *pDocument)
01085 {
01086 ERROR2IF(pNewPath == NULL, FALSE, "pNewNodePath is NULL in OpDrawBrush::ApplyAttributes");
01087 ERROR2IF(pDocument == NULL, FALSE, "pDocument is NULL in OpDrawBrush::ApplyAttributes");
01088
01089
01090
01091
01092 ENSURE(pDocument!=NULL, "Null Document while setting attributes for new NodePath");
01093 if (pDocument!=NULL)
01094 {
01095
01096 AttrBrushType* pNewAttr = CreateNewAttribute();
01097 if (pNewAttr == NULL)
01098 return FALSE;
01099 #ifdef NEWFASTBRUSHES
01100 BrushAttrValue* pAttrVal = (BrushAttrValue*) pNewAttr->GetAttributeValue();
01101 pAttrVal->SetBoundsParent (pNewPath);
01102 #endif
01103
01104
01105 MILLIPOINT LineWidth = GetCurrentLineWidthIfNotDefault();
01106 if (LineWidth == -1)
01107 LineWidth = pNewAttr->GetDefaultLineWidth(!AddPressureToPath);
01108
01109
01110
01111 if (!pDocument->GetAttributeMgr().ApplyCurrentAttribsToNode((NodeRenderableInk*)pNewPath))
01112 ERROR3("Failed to apply current attributes in OpDrawBrush::ApplyAttributes");
01113
01114
01115 AttrLineWidth* pLineWidth = (AttrLineWidth*)pNewPath->FindFirstChild(CC_RUNTIME_CLASS(AttrLineWidth));
01116 if (pLineWidth != NULL)
01117 pLineWidth->Value.LineWidth = LineWidth;
01118 else
01119 ERROR3("Unable to find line width in OpDrawBrush::ApplyAttributes");
01120
01121
01122 Node* pDocBrush = pNewPath->FindFirstChild(CC_RUNTIME_CLASS(AttrBrushType));
01123 if (pDocBrush)
01124 {
01125 pDocBrush->CascadeDelete();
01126 delete pDocBrush;
01127 pDocBrush = NULL;
01128 }
01129
01130
01131
01132 pNewPath->ApplyAttributeToObject(pNewAttr, FALSE);
01133
01134
01135 pNewAttr->SetFreeHandTool(m_pTool);
01136
01137 if (pNewAttr->GetBrushHandle() != BrushHandle_NoBrush)
01138 {
01139
01140 #ifdef OPBRUSHPOINTSCACHE
01141 if (m_TimeStamp <= 0)
01142 pNewAttr->SetCache(m_pPointsCache);
01143
01144
01145
01146 m_pPointsCache = NULL;
01147 #endif
01148 BrushAttrValue* pVal = (BrushAttrValue*)pNewAttr->GetAttributeValue();
01149
01150 if (m_TimeStamp > 0)
01151 {
01152 if (pVal !=