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 #include "camtypes.h"
00103 #include "nodecont.h"
00104 #include "saveeps.h"
00105
00106 #ifdef BUILDSHADOWS
00107
00108
00109
00110 #include "objchge.h"
00111
00112
00113
00114
00115
00116 #include "transop.h"
00117
00118
00119
00120 #include "cxftags.h"
00121
00122 #include "rechshad.h"
00123
00124 #include "opshadow.h"
00125
00126
00127 #include "attrbev.h"
00128 #include "lineattr.h"
00129
00130 #include "attrappl.h"
00131 #include "blobs.h"
00132
00133 #include "opgrad.h"
00134 #include "opbevel.h"
00135 #include "nbevcont.h"
00136 #include "moldtool.h"
00137 #include "attrmap.h"
00138 #include "nodetext.h"
00139
00140 #include "blndtool.h"
00141 #include "ncntrcnt.h"
00142
00143 #include "extender.h"
00144 #include "ngcore.h"
00145 #include "cmxrendr.h"
00146
00147
00148 #include "nodemold.h"
00149 #include "nodecntr.h"
00150 #include "textops.h"
00151
00152 #include "blendatt.h"
00153 #include "blndhelp.h"
00154 #include "nodebldr.h"
00155 #include "pathops.h"
00156 #include "brshattr.h"
00157 #include "fthrattr.h"
00158 #include "pathndge.h"
00159
00160 #include "slicehelper.h"
00161
00162 #include "pbecomea.h"
00163 #include "nodeshad.h"
00164 #include "nodeliveeffect.h"
00165 #include "ophist.h"
00166 #include "nodebev.h"
00167
00168 CC_IMPLEMENT_DYNAMIC(NodeShadowController, NodeEffect)
00169 CC_IMPLEMENT_DYNAMIC(ShadowRecordHandler, CamelotRecordHandler)
00170 CC_IMPLEMENT_DYNAMIC(ShadowNodeTreeFactory, CompoundNodeTreeFactory)
00171
00172
00173
00174 #define new CAM_DEBUG_NEW
00175
00176
00177
00178
00179
00180 const MILLIPOINT GlowShadowDragPathFlatness = 2048;
00181
00182
00183 const ShadowType NodeShadowController::DefaultType = SHADOWTYPE_WALL;
00184 const MILLIPOINT NodeShadowController::DefaultWallOffsetX = 5 * 750;
00185 const MILLIPOINT NodeShadowController::DefaultWallOffsetY = -5 * 750;
00186 const MILLIPOINT NodeShadowController::DefaultGlowWidth = 4 * 750;
00187 const double NodeShadowController::DefaultFloorAngle = PI / 4.0;
00188 const float NodeShadowController::DefaultFloorHeight = 0.5;
00189 const MILLIPOINT NodeShadowController::DefaultBlurSize = 6 * 750;
00190 const double NodeShadowController::DefaultDarkness = 0.25;
00191 const double NodeShadowController::DefaultScale = 1.0;
00192 const MILLIPOINT NodeShadowController::DefaultFeatherWidth = 2 * 750;
00193
00194
00195
00196
00197
00198
00199
00200
00201
00202
00203
00204
00205
00206
00207
00208
00209
00210
00211
00212 NodeShadowController::NodeShadowController() : NodeEffect()
00213 {
00214
00215 m_OffsetX = DefaultWallOffsetX;
00216 m_OffsetY = DefaultWallOffsetY;
00217 m_FloorShadowAngle = DefaultFloorAngle;
00218 m_FloorShadowHeight = DefaultFloorHeight;
00219 m_GlowWidth = DefaultGlowWidth;
00220 m_FeatherWidth = DefaultFeatherWidth;
00221
00222 SetPenumbraWidth(DefaultBlurSize);
00223 m_ShadowType = DefaultType;
00224 m_Scale = DefaultScale;
00225
00226 m_ShadowSelectionChanged = FALSE;
00227 m_PreviousRect.MakeEmpty();
00228
00229 m_GlowDragPath.Initialise();
00230 m_PerformedExtend = FALSE;
00231
00232 m_strPostProID = POSTPRO_ID_SHADOW;
00233
00234 #ifdef _DEBUG
00235 myShadowID = -1;
00236 myShadowBecomeAID = -1;
00237 #endif
00238
00239 TRACEUSER( "MarkH", _T("Just Made a NodeShadowController Class!\n"));
00240 }
00241
00242 NodeShadowController::~NodeShadowController()
00243 {
00244 #ifdef _DEBUG
00245
00246 if (myShadowID > -1)
00247 {
00248 TCHAR strId[100];
00249 camSnprintf( strId, 100, _T("Popping NodeShadowController ID: %i\n"), myShadowID );
00250
00251 TRACEUSER( "ChrisS", strId);
00252 }
00253
00254 #endif
00255 }
00256
00257
00258
00259
00260
00261
00262
00263
00264
00265
00266
00267
00268
00269
00270
00271
00272
00273
00274
00275
00276
00277
00278
00279
00280
00281
00282
00283
00284
00285
00286
00287
00288
00289
00290
00291
00292
00293
00294
00295
00296
00297
00298
00299
00300
00301
00302 NodeShadowController::NodeShadowController(Node* ContextNode,
00303 AttachNodeDirection Direction,
00304 BOOL Locked,
00305 BOOL Mangled,
00306 BOOL Marked,
00307 BOOL Selected
00308 ) : NodeEffect(ContextNode, Direction, Locked, Mangled, Marked,
00309 Selected)
00310 {
00311
00312 m_OffsetX = DefaultWallOffsetX;
00313 m_OffsetY = DefaultWallOffsetY;
00314 m_GlowWidth = DefaultGlowWidth;
00315 m_FeatherWidth = DefaultFeatherWidth;
00316
00317 SetPenumbraWidth (4 * 750);
00318 m_ShadowSelectionChanged = FALSE;
00319 m_PreviousRect.MakeEmpty();
00320 m_ShadowType = SHADOWTYPE_WALL;
00321 m_Scale = 1.0;
00322
00323 m_GlowDragPath.Initialise();
00324
00325 m_strPostProID = POSTPRO_ID_SHADOW;
00326
00327 #ifdef _DEBUG
00328 myShadowID = -1;
00329 myShadowBecomeAID = -1;
00330 #endif
00331
00332 TRACEUSER( "MarkH", _T("Just Made a NodeShadowController Class!\n"));
00333 }
00334
00335
00336
00337
00338
00339
00340
00341
00342
00343
00344
00345
00346
00347 void NodeShadowController::RenderEorDrag( RenderRegion* pRender )
00348 {
00349
00350
00351
00352 RenderEorDragChildren(pRender);
00353 }
00354
00355
00356
00357
00358
00359
00360
00361
00362
00363
00364
00365
00366
00367
00368
00369
00370
00371
00372
00373
00374
00375 BOOL NodeShadowController::AllowOp(ObjChangeParam *pParam, BOOL SetOpPermissionState,
00376 BOOL DoPreTriggerEdit)
00377 {
00378 ERROR2IF(pParam == NULL, FALSE, "NodeShadowController::AllowOp(); NULL input(s) !!");
00379
00380
00381 BOOL allowed = TRUE;
00382
00383
00384 UndoableOperation* pChangeOp = pParam->GetOpPointer();
00385
00386 if (pParam->GetDirection() != OBJCHANGE_CALLEDBYCHILD ||
00387 pParam->GetCallingChild() != NULL)
00388 {
00389 BOOL AnyAllowed = AllowOp_AccountForCompound( pParam,
00390 SetOpPermissionState,
00391 DoPreTriggerEdit );
00392
00393
00394 if (pParam->GetDirection() == OBJCHANGE_CALLEDBYPARENT)
00395 return AnyAllowed;
00396 }
00397
00398
00399
00400
00401 if (allowed && Parent != NULL)
00402 {
00403 ObjChangeDirection OldDirection = pParam->GetDirection();
00404 pParam->SetCallingChild(this);
00405 pParam->SetDirection(OBJCHANGE_CALLEDBYCHILD);
00406 allowed = Parent->AllowOp(pParam, SetOpPermissionState, DoPreTriggerEdit);
00407 pParam->SetDirection(OldDirection);
00408 }
00409
00410
00411 if (pChangeOp != NULL)
00412 {
00413
00414 if (pChangeOp->IS_KIND_OF(OpCreateNewMould))
00415 {
00416 if (pParam->GetDirection() == OBJCHANGE_CALLEDBYOP)
00417 allowed = FALSE;
00418 }
00419
00420
00421
00422
00423 else if (SetOpPermissionState)
00424 {
00425 if (pChangeOp->IS_KIND_OF(OpRemoveBlend))
00426 {
00427 ::InformWarning(_R(IDS_BLENDINSIDESHADOW));
00428 allowed = FALSE;
00429 }
00430 }
00431 }
00432
00433 else if ( pParam->GetChangeFlags().MultiReplaceNode &&
00434 pParam->GetDirection() == OBJCHANGE_CALLEDBYOP )
00435 {
00436 allowed = FALSE;
00437 }
00438
00439
00440 if (SetOpPermissionState)
00441 SetOpPermission(allowed ? PERMISSION_ALLOWED : PERMISSION_DENIED, TRUE);
00442
00443
00444
00445
00446 if (allowed && DoPreTriggerEdit)
00447 {
00448
00449 UndoableOperation* pChangeOp = pParam->GetOpPointer();
00450 if (pChangeOp != NULL && pChangeOp->MayChangeNodeBounds() && NameGallery::Instance())
00451 {
00452 allowed = NameGallery::Instance()->PreTriggerEdit(pChangeOp, pParam, this);
00453 }
00454 }
00455
00456 return allowed;
00457 }
00458
00459
00460
00461
00462
00463
00464
00465
00466
00467
00468
00469
00470
00471
00472
00473 void NodeShadowController::Transform( TransformBase& Trans )
00474 {
00475 #ifndef NEW_SHADOW_RENDER
00476 TransformBase *pTrans = &Trans;
00477
00478 Trans2DMatrix *p2D = NULL;
00479
00480 if (pTrans->IS_KIND_OF(Trans2DMatrix))
00481 {
00482 p2D = (Trans2DMatrix *)pTrans;
00483
00484 if (p2D->GetMatrix().IsTranslation())
00485 {
00486
00487 InvalidateBoundingRect();
00488
00489 Trans.Transform(&BoundingRectangle.lo, 1);
00490 Trans.Transform(&BoundingRectangle.hi, 1);
00491 NodeEffect::Transform(Trans);
00492
00493
00494 if (m_ShadowType == SHADOWTYPE_GLOW)
00495 {
00496 Trans.Transform(m_GlowDragPath.GetCoordArray(), m_GlowDragPath.GetNumCoords());
00497 }
00498
00499 return;
00500 }
00501 else
00502 {
00503 Matrix pMat = p2D->GetMatrix();
00504 FIXED16 Elem[4];
00505 INT32 LElem[2];
00506
00507 pMat.GetComponents(Elem, LElem);
00508
00509 double ScaleX = Elem[0].MakeDouble();
00510 double ScaleY = Elem[3].MakeDouble();
00511
00512 if (Elem[1].MakeDouble() == 0 && Elem[2].MakeDouble() == 0)
00513 {
00514 m_OffsetX = (MILLIPOINT)(((double)m_OffsetX) * ScaleX);
00515 m_OffsetY = (MILLIPOINT)(((double)m_OffsetY) * ScaleY);
00516
00517 if (ScaleX == ScaleY)
00518 {
00519 SetPenumbraWidth ((MILLIPOINT)(((double)m_PenumbraWidth) * fabs(ScaleX)));
00520 m_GlowWidth = (MILLIPOINT)(((double)m_GlowWidth) * fabs(ScaleX));
00521 m_FeatherWidth = (MILLIPOINT)(((double)m_FeatherWidth) * fabs(ScaleX));
00522 }
00523 }
00524 }
00525 }
00526
00527
00528
00529 NodeShadow* pShadow = GetShadow();
00530 if (pShadow != NULL)
00531 {
00532
00533 NodeEffect::Transform(Trans);
00534
00535
00536 List TextNodeList;
00537 NodeListItem * pItem = NULL;
00538
00539 BevelTools::GetAllNodesUnderNode(this, &TextNodeList,
00540 CC_RUNTIME_CLASS(TextStory));
00541
00542 pItem = (NodeListItem *)TextNodeList.GetHead();
00543
00544 while (pItem)
00545 {
00546 if (pItem->pNode)
00547 {
00548 ((TextStory *)pItem->pNode)->FormatAndChildren(NULL, FALSE);
00549 }
00550
00551 pItem = (NodeListItem *)TextNodeList.GetNext(pItem);
00552 }
00553
00554 TextNodeList.DeleteAll();
00555
00556 RegenerateNode(NULL, FALSE, FALSE);
00557 }
00558 #else // NEW_SHADOW_RENDER
00559
00560 if (IsCapturingChildren())
00561 {
00562 CBitmapCache* pBitmapCache = Camelot.GetBitmapCache();
00563 ERROR3IF(pBitmapCache==NULL, "Can't find BitmapCache");
00564
00565
00566 CCachedBitmap cbmp;
00567 CBitmapCacheKey inky(this, GetPixelWidth(), 0);
00568 BOOL bFound = pBitmapCache->Lookup(inky, cbmp);
00569 if (bFound)
00570 {
00571 cbmp.Transform(Trans);
00572 pBitmapCache->StoreBitmap(inky, cbmp);
00573 }
00574 else
00575 Trans.bHaveTransformedCached = FALSE;
00576 }
00577 else
00578 {
00579
00580
00581 Trans.bTransformYourChildren = TRUE;
00582 }
00583
00584
00585
00586
00587
00588 NodeEffect::Transform(Trans);
00589
00590
00591
00592 if (Trans.IS_KIND_OF(Trans2DMatrix))
00593 {
00594 Trans2DMatrix* p2D = (Trans2DMatrix*)&Trans;
00595
00596 if (Trans.IsTranslation())
00597 {
00598
00599 InvalidateBoundingRect();
00600
00601 Trans.Transform(&BoundingRectangle.lo, 1);
00602 Trans.Transform(&BoundingRectangle.hi, 1);
00603
00604
00605 if (m_ShadowType == SHADOWTYPE_GLOW)
00606 {
00607 Trans.Transform(m_GlowDragPath.GetCoordArray(), m_GlowDragPath.GetNumCoords());
00608 }
00609 }
00610 else
00611 {
00612 Matrix pMat = p2D->GetMatrix();
00613 FIXED16 Elem[4];
00614 INT32 LElem[2];
00615
00616 pMat.GetComponents(Elem, LElem);
00617
00618 double ScaleX = Elem[0].MakeDouble();
00619 double ScaleY = Elem[3].MakeDouble();
00620
00621 if (Elem[1].MakeDouble() == 0 && Elem[2].MakeDouble() == 0)
00622 {
00623 m_OffsetX = (MILLIPOINT)(((double)m_OffsetX) * ScaleX);
00624 m_OffsetY = (MILLIPOINT)(((double)m_OffsetY) * ScaleY);
00625
00626 if (ScaleX == ScaleY)
00627 {
00628 SetPenumbraWidth ((MILLIPOINT)(((double)m_PenumbraWidth) * fabs(ScaleX)));
00629 m_GlowWidth = (MILLIPOINT)(((double)m_GlowWidth) * fabs(ScaleX));
00630 m_FeatherWidth = (MILLIPOINT)(((double)m_FeatherWidth) * fabs(ScaleX));
00631 }
00632 }
00633 }
00634 }
00635
00636
00637 NodeShadow* pShadow = NULL;
00638 if (!Trans.IsTranslation())
00639 {
00640
00641
00642 List TextNodeList;
00643 NodeListItem * pItem = NULL;
00644 BevelTools::GetAllNodesUnderNode(this, &TextNodeList,
00645 CC_RUNTIME_CLASS(TextStory));
00646
00647 pItem = (NodeListItem *)TextNodeList.GetHead();
00648
00649 while (pItem)
00650 {
00651 if (pItem->pNode)
00652 ((TextStory *)pItem->pNode)->FormatAndChildren(NULL, FALSE);
00653
00654 pItem = (NodeListItem *)TextNodeList.GetNext(pItem);
00655 }
00656
00657 TextNodeList.DeleteAll();
00658
00659
00660
00661 if (!IsCapturingChildren())
00662 RegenerateNode(NULL, FALSE, FALSE);
00663 }
00664
00665 if (IsCapturingChildren())
00666 {
00667
00668 CBitmapCache* pBitmapCache = Camelot.GetBitmapCache();
00669 if (this->IsTopShadowController())
00670 {
00671
00672
00673 pShadow = FindBottomShadow();
00674 BOOL bRelease = FALSE;
00675 while (pShadow)
00676 {
00677
00678 BOOL bOK = pShadow->TransformShadow(Trans);
00679
00680
00681 if (!bOK)
00682 {
00683 pShadow->DeleteCache();
00684 bRelease = TRUE;
00685 }
00686
00687 if (bRelease)
00688 {
00689 NodeCompound* pController = pShadow->GetParentController();
00690 if (pController)
00691 {
00692
00693
00694
00695 if (pBitmapCache!=NULL)
00696 {
00697 CBitmapCacheKey inky(pController, 42);
00698 pBitmapCache->RemoveAllOwnedBitmaps(inky, FALSE, CACHEPRIORITY_PERMANENT);
00699 }
00700 }
00701 }
00702
00703 pShadow = FindShadowAbove(pShadow);
00704 }
00705 }
00706 }
00707
00708
00709
00710
00711
00712
00713
00714
00715
00716
00717
00718
00719
00720
00721
00722 #endif
00723 }
00724
00725
00726
00727
00728
00729
00730
00731
00732
00733
00734
00735
00736
00737
00738 DocRect NodeShadowController::GetBlobBoundingRect()
00739 {
00740 DocRect dr = GetBoundingRect(TRUE, FALSE);
00741
00742 dr = dr.Union(NodeRenderableInk::GetBlobBoundingRect());
00743
00744 BlobManager* BlobMgr = GetApplication()->GetBlobManager();
00745
00746
00747
00748 if (BlobMgr)
00749 {
00750 if (m_ShadowType == SHADOWTYPE_GLOW)
00751 {
00752 dr.Inflate(BlobMgr->GetBlobSize() * 3);
00753 }
00754 else
00755 {
00756 dr.Inflate(BlobMgr->GetBlobSize());
00757 }
00758 }
00759
00760 return dr;
00761
00762
00763 }
00764
00765
00766
00767
00768
00769
00770
00771
00772
00773
00774
00775
00776
00777
00778
00779
00780
00781
00782
00783
00784
00785
00786
00787
00788 String NodeShadowController::Describe(BOOL Plural, BOOL Verbose)
00789 {
00790 if (Plural)
00791 return(String(_R(IDS_SHADOWNODENAME_PLURAL)));
00792 else
00793 return(String(_R(IDS_SHADOWNODENAME)));
00794 };
00795
00796
00797
00798
00799
00800
00801
00802
00803
00804
00805
00806
00807
00808
00809
00810
00811
00812
00813
00814
00815
00816 Node* NodeShadowController::SimpleCopy()
00817 {
00818 NodeShadowController* NodeCopy;
00819 NodeCopy = new NodeShadowController();
00820 ERRORIF(NodeCopy == NULL, _R(IDE_NOMORE_MEMORY), NULL);
00821
00822 CopyNodeContents(NodeCopy);
00823
00824 return (NodeCopy);
00825 }
00826
00827
00828
00829
00830
00831
00832
00833
00834
00835
00836
00837
00838
00839
00840 void NodeShadowController::CopyNodeContents(NodeShadowController* pNewNode)
00841 {
00842 pNewNode->m_ShadowSelectionChanged = m_ShadowSelectionChanged;
00843
00844 pNewNode->m_sShadowName = m_sShadowName;
00845
00846 pNewNode->m_PreviousRect = m_PreviousRect;
00847
00848 pNewNode->m_PerformedExtend = m_PerformedExtend;
00849
00850
00851 pNewNode->m_GlowDragPath.Initialise(m_GlowDragPath.GetNumCoords());
00852 pNewNode->m_GlowDragPath.CopyPathDataFrom(&m_GlowDragPath);
00853
00854 pNewNode->SetOffsetX(m_OffsetX);
00855 pNewNode->SetOffsetY(m_OffsetY);
00856
00857 pNewNode->SetPenumbraWidth(m_PenumbraWidth);
00858
00859 pNewNode->SetFloorShadowAngle(m_FloorShadowAngle);
00860 pNewNode->SetFloorShadowHeight(m_FloorShadowHeight);
00861 pNewNode->SetShadowType(m_ShadowType);
00862 pNewNode->SetWallShadowScale(m_Scale);
00863 pNewNode->SetGlowWidth(m_GlowWidth);
00864 pNewNode->SetFeatherWidth(m_FeatherWidth);
00865
00866
00867 pNewNode->m_bBlendStartNode = m_bBlendStartNode;
00868 pNewNode->m_bBlendEndNode = m_bBlendEndNode;
00869 pNewNode->m_pBlendCreatedByNode = m_pBlendCreatedByNode;
00870
00871 NodeEffect::CopyNodeContents(pNewNode);
00872
00873 #ifdef NEW_SHADOW_RENDER
00874 if (IsCapturingChildren())
00875 {
00876 CopyCached(pNewNode, GetPixelWidth(), 0);
00877 }
00878 #endif
00879 }
00880
00881
00882
00883
00884
00885
00886
00887
00888
00889
00890
00891
00892
00893
00894
00895
00896 void NodeShadowController::PolyCopyNodeContents(NodeRenderable* pNodeCopy)
00897 {
00898 ENSURE(pNodeCopy, "Trying to copy a node's contents into a NULL node");
00899 ENSURE(IS_A(pNodeCopy, NodeShadowController), "PolyCopyNodeContents given wrong dest node type");
00900
00901 if (IS_A(pNodeCopy, NodeShadowController))
00902 CopyNodeContents((NodeShadowController*)pNodeCopy);
00903 }
00904
00905
00906
00907
00908
00909
00910
00911
00912
00913
00914
00915
00916
00917
00918
00919
00920
00921
00922
00923 UINT32 NodeShadowController::GetNodeSize() const
00924 {
00925 return (sizeof(NodeShadowController));
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
00952
00953
00954
00955
00956 BOOL NodeShadowController::CanBecomeA(BecomeA* pBecomeA)
00957 {
00958 BOOL bOK=FALSE;
00959
00960 Node* Current = FindFirstChild();
00961 while (Current != NULL)
00962 {
00963 if (Current->CanBecomeA(pBecomeA))
00964 {
00965 bOK = TRUE;
00966 if (!pBecomeA->IsCounting())
00967 return TRUE;
00968 }
00969
00970 Current = Current->FindNext();
00971 }
00972
00973 return bOK;
00974 }
00975
00976
00977
00978
00979
00980
00981
00982
00983
00984
00985
00986
00987
00988
00989
00990
00991
00992
00993
00994
00995
00996
00997
00998
00999
01000
01001
01002
01003 BOOL NodeShadowController::DoBecomeA(BecomeA* pBecomeA)
01004 {
01005 ERROR2IF(pBecomeA == NULL,FALSE,"NULL BecomeA ptr");
01006
01007
01008 Node * pNode = NULL;
01009
01010
01011
01012 UndoableOperation* pOp = pBecomeA->GetUndoOp();
01013
01014
01015
01016 if (pBecomeA->ResultsStayInPlace() && pBecomeA->IsCombineBecomeA())
01017 {
01018 return NodeEffect::DoBecomeA(pBecomeA);
01019 }
01020
01021 switch (pBecomeA->GetReason())
01022 {
01023 case BECOMEA_REPLACE:
01024 {
01025
01026
01027
01028
01029 BOOL fSelectBecomeAGroup = IsParentOfSelected();
01030
01031
01032 NodeCompound::DoBecomeA(pBecomeA);
01033
01034
01035 NodeGroup* pGroup = BecomeAGroup(pOp);
01036
01037
01038 if (fSelectBecomeAGroup && pGroup != NULL)
01039 pGroup->Select(FALSE);
01040 }
01041 break;
01042
01043 case BECOMEA_PASSBACK:
01044 {
01045
01046 if (pBecomeA->IsBlendBecomeA())
01047 {
01048 CompoundNodeBlendBecomeA MyBecomeA(BECOMEA_PASSBACK, CC_RUNTIME_CLASS(NodePath),
01049 NULL, FALSE, this, pBecomeA);
01050
01051
01052 Node * pChild = FindFirstChild();
01053
01054 while (pChild)
01055 {
01056 if (pChild->IsAnObject() && !pChild->NeedsParent(NULL))
01057 {
01058 MyBecomeA.ResetCount();
01059
01060 if (pChild->CanBecomeA(&MyBecomeA))
01061 {
01062
01063 MyBecomeA.SetNumPathNodes(MyBecomeA.GetCount());
01064 MyBecomeA.ResetCount();
01065
01066 pChild->DoBecomeA(&MyBecomeA);
01067 }
01068 }
01069
01070 pChild = pChild->FindNext();
01071 }
01072 }
01073
01074
01075
01076
01077
01078
01079 else if (pBecomeA->DoShadowSilhouettes())
01080 {
01081 BOOL bGlowOptimisations = (GetShadowType() == SHADOWTYPE_GLOW);
01082
01083 NodePath* pShadowPath = NULL;
01084 NodePath* pInkPath = NULL;
01085 NodeRenderableInk* pShadowedNode = GetShadowedNode();
01086
01087 Path WorkPath;
01088 WorkPath.Initialise();
01089 PathBecomeA baInfo(BECOMEA_PASSBACK, CC_RUNTIME_CLASS(NodePath), NULL, FALSE,
01090 &WorkPath, PathBecomeA::ADD_OUTLINES);
01091
01092 BOOL ok = pShadowedNode->DoBecomeA(&baInfo);
01093 if (ok) ok = NodePath::CreateFromPath(&pShadowPath, &WorkPath, pBecomeA->GetUndoOp());
01094
01095 if (ok && !bGlowOptimisations)
01096 ok = pShadowPath->NodeCopy((Node**)&pInkPath);
01097
01098 if (ok) ok = ApplyShadowTransform(&pShadowPath->InkPath);
01099 if (ok) ok = pShadowPath->DoBecomeA(pBecomeA);
01100
01101 if (ok && !bGlowOptimisations)
01102 ok = pInkPath->DoBecomeA(pBecomeA);
01103
01104 if (pShadowPath != NULL)
01105 {
01106 delete pShadowPath;
01107 pShadowPath = NULL;
01108 }
01109 if (pInkPath != NULL)
01110 {
01111 delete pInkPath;
01112 pInkPath = NULL;
01113 }
01114
01115 return ok;
01116 }
01117
01118 else
01119 {
01120
01121
01122
01123
01124 pNode = FindFirstChild();
01125 while (pNode != NULL)
01126 {
01127 if (!pNode->DoBecomeA(pBecomeA))
01128 return FALSE;
01129
01130 pNode = pNode->FindNext();
01131 }
01132 }
01133 }
01134 break;
01135 default: break;
01136 }
01137
01138 return TRUE;
01139
01140 }
01141
01142
01143
01144
01145
01146
01147
01148
01149
01150
01151
01152
01153
01154
01155
01156
01157
01158
01159
01160
01161
01162
01163 BOOL NodeShadowController::ApplyShadowTransform(Path* pTargetPath)
01164 {
01165 ERROR2IF(pTargetPath == NULL, FALSE,
01166 "NodeShadowController::ApplyShadowTransform; NULL param!");
01167
01168 switch (GetShadowType())
01169 {
01170
01171 case SHADOWTYPE_WALL:
01172 pTargetPath->Translate(GetWallShadowOffset());
01173 break;
01174
01175
01176
01177
01178 case SHADOWTYPE_GLOW:
01179 {
01180 Path ContouredPath;
01181 ContouredPath.Initialise();
01182 pTargetPath->InitializeContourValues(2 * GetGlowWidth());
01183 if (pTargetPath->GetContourForStep(&ContouredPath) > 0)
01184 {
01185 pTargetPath->ClearPath();
01186 pTargetPath->CloneFrom(ContouredPath);
01187 }
01188
01189 break;
01190 }
01191
01192
01193 case SHADOWTYPE_FLOOR:
01194 {
01195 DocRect InkRect;
01196 pTargetPath->GetTrueBoundingRect(&InkRect);
01197
01198 DocCoord dcOffset(-InkRect.Centre().x, -InkRect.lo.y);
01199
01200 Matrix ToOrigin = Matrix::CreateTransMatrix(dcOffset);
01201 Matrix FromOrigin = Matrix::CreateTransMatrix(-dcOffset);
01202 Matrix ScaleMat = Matrix::CreateScaleMatrix(1.0, GetFloorShadowHeight());
01203 Matrix ShearMat = Matrix::CreateShearMatrix(GetFloorShadowAngle());
01204
01205 Matrix FloorTransform(ToOrigin * ScaleMat * ShearMat * FromOrigin);
01206
01207 FloorTransform.transform(pTargetPath->GetCoordArray(), pTargetPath->GetNumCoords());
01208
01209 break;
01210 }
01211
01212 case SHADOWTYPE_FEATHER:
01213 {
01214
01215 break;
01216 }
01217
01218 default:
01219 ERROR3("NodeShadowController::ApplyShadowTransform; Unrecognised shadow type!");
01220 return FALSE;
01221 }
01222
01223 return TRUE;
01224 }
01225
01226
01227
01228
01229
01230
01231
01232
01233
01234
01235
01236
01237
01238
01239
01240
01241
01242
01243
01244
01245
01246
01247
01248
01249
01250
01251
01252
01253 void NodeShadowController::SelectInRect(const DocRect& Rect, SelStateAction st)
01254 {
01255
01256 NodeRenderableInk* pInkChild = NULL;
01257 Node* pChild = FindFirstChild();
01258 while (pChild != NULL)
01259 {
01260 if (pChild->IsAnObject())
01261 {
01262 pInkChild = (NodeRenderableInk*)pChild;
01263 if (Rect.ContainsRect(pInkChild->GetBoundingRect()))
01264 {
01265 switch (st)
01266 {
01267 case CLEAR:
01268 if (pInkChild->MarqueeSelectNode())
01269 {
01270 pInkChild->DeSelect(TRUE);
01271 }
01272 break;
01273
01274 case SET:
01275 if (pInkChild->MarqueeSelectNode())
01276 {
01277 pInkChild->Select(TRUE);
01278 }
01279 break;
01280
01281 case TOGGLE:
01282 if (pInkChild->MarqueeSelectNode())
01283 {
01284 if (pInkChild->IsSelected())
01285 pInkChild->DeSelect(TRUE);
01286 else
01287 pInkChild->Select(TRUE);
01288 }
01289 break;
01290
01291 default:
01292 ERROR3("NodeShadowController::SelectInRect; Unknown SelStateAction!\n");
01293 return;
01294 }
01295 }
01296 }
01297 pChild = pChild->FindNext();
01298 }
01299 }
01300
01301
01302
01303
01304
01305
01306
01307
01308
01309
01310
01311
01312
01313
01314
01315
01316
01317
01318
01319
01320 BOOL NodeShadowController::OnClick( DocCoord PointerPos, ClickType Click, ClickModifiers ClickMods,
01321 Spread* pSpread )
01322 {
01323
01324 return FALSE;
01325 }
01326
01327
01328
01329
01330
01331
01332
01333
01334
01335
01336
01337
01338
01339
01340
01341
01342
01343
01344
01345
01346
01347
01348
01349
01350
01351 ChangeCode NodeShadowController::OnChildChange(ObjChangeParam* pParam)
01352 {
01353 if (m_PerformedExtend)
01354 {
01355
01356
01357
01358
01359 m_PerformedExtend = FALSE;
01360 return CC_OK;
01361 }
01362
01363 if (!pParam)
01364 {
01365 return NodeEffect::OnChildChange(pParam);
01366 }
01367
01368
01369 if (!pParam->GetOpPointer())
01370 {
01371 TRACEUSER( "DavidM", _T("OnChildChange - no op\n"));
01372
01373
01374 Document * pDoc = Document::GetCurrent();
01375
01376 if (pParam->GetChangeFlags().RegenerateNode && pParam->GetChangeType() == OBJCHANGE_FINISHED)
01377 {
01378 RegenerateNode(NULL, FALSE, FALSE);
01379 }
01380
01381 pDoc->ForceRedraw(FindParentSpread(), GetBoundingRect(), FALSE, this);
01382
01383 return NodeEffect::OnChildChange(pParam);
01384 }
01385
01386 if (pParam->GetChangeType() != OBJCHANGE_FINISHED)
01387 return NodeEffect::OnChildChange(pParam);
01388
01389 UndoableOperation * pUndoOp = NULL;
01390
01391 if (pParam->GetOpPointer()->IS_KIND_OF(UndoableOperation))
01392 {
01393 pUndoOp = pParam->GetOpPointer();
01394 }
01395
01396 if (!pUndoOp)
01397 {
01398 return NodeEffect::OnChildChange(pParam);
01399 }
01400
01401 NodeAttribute * pAttrib = NULL;
01402 NodeListItem * pItem = NULL;
01403
01404
01405 if (pUndoOp->IS_KIND_OF(OpApplyAttrib) &&
01406 !pUndoOp->IS_KIND_OF(OpEditFill))
01407 {
01408 CCRuntimeClass * pClass = ((OpApplyAttrib *)pUndoOp)->GetValueChangeType();
01409 if (pClass)
01410 {
01411
01412 if (pClass->IS_KIND_OF(AttrTranspChange) ||
01413 pClass->IS_KIND_OF(AttrTranspFillGeometry) ||
01414 pClass->IS_KIND_OF(AttrBevelIndent) ||
01415 pClass->IS_KIND_OF(AttrBitmapTranspFill) ||
01416 pClass->IS_KIND_OF(AttrTextureTranspFill) ||
01417 pClass->IS_KIND_OF(AttrFillGeometry) ||
01418 pClass->IS_KIND_OF(AttrStartCap) ||
01419 pClass->IS_KIND_OF(AttrStartArrow) ||
01420 pClass->IS_KIND_OF(AttrDashPattern) ||
01421 pClass->IS_KIND_OF(AttrEndArrow) ||
01422 pClass->IS_KIND_OF(AttrJoinType) ||
01423 pClass->IS_KIND_OF(AttrBrushType)
01424 )
01425 {
01426 RegenerateNode(pUndoOp, FALSE, FALSE);
01427 return CC_OK;
01428 }
01429 }
01430 else
01431 {
01432 TRACEUSER( "DavidM", _T("3!\n"));
01433
01434 if (pUndoOp->IS_KIND_OF(OpEditFill))
01435 {
01436 pAttrib = ((OpEditFill *)pUndoOp)->GetGradFill();
01437
01438 if (pAttrib)
01439 {
01440 if (pAttrib->IsATranspFill())
01441 {
01442 TRACEUSER( "DavidM", _T("Trans fill edit\n"));
01443 RegenerateNode(pUndoOp, FALSE, FALSE);
01444 return CC_OK;
01445 }
01446 }
01447 }
01448 }
01449 }
01450
01451 Node * pParent = NULL;
01452 List ChildList;
01453 BOOL bRegen = FALSE;
01454
01455 if (pUndoOp->IS_KIND_OF (OpPathNudge))
01456 {
01457 RegenerateNode(pUndoOp, FALSE, FALSE);
01458 }
01459 else if (pUndoOp->IS_KIND_OF(TransOperation) &&
01460 !pUndoOp->IS_KIND_OF(OpMovePathPoint))
01461 {
01462 if (IsSelected())
01463 return CC_OK;
01464
01465
01466
01467
01468
01469
01470
01471
01472
01473
01474
01475
01476
01477
01478
01479 BevelTools::GetAllNodesUnderNode(this, &ChildList, CC_RUNTIME_CLASS(NodeRenderableInk));
01480
01481 pItem = (NodeListItem *)ChildList.GetHead();
01482
01483 bRegen = FALSE;
01484
01485 while (pItem)
01486 {
01487
01488 if (pItem->pNode->IsSelected())
01489 {
01490
01491 pParent = pItem->pNode->FindParent();
01492
01493 while (pParent)
01494 {
01495
01496 if (pParent->ShouldITransformWithChildren())
01497 {
01498
01499 if (pParent == this)
01500 {
01501
01502 bRegen = FALSE;
01503
01504
01505 pParent = NULL;
01506 }
01507 else
01508 {
01509
01510 pParent = pParent->FindParent();
01511 }
01512 }
01513 else
01514 {
01515
01516 bRegen = TRUE;
01517
01518
01519 pParent = NULL;
01520 }
01521 }
01522 }
01523
01524 pItem = (NodeListItem *)ChildList.GetNext(pItem);
01525 }
01526
01527 ChildList.DeleteAll();
01528
01529 if (bRegen)
01530 {
01531 RegenerateNode(pUndoOp, FALSE, FALSE);
01532 }
01533
01534 return CC_OK;
01535 }
01536 else if (pUndoOp && (pUndoOp->IsKindOf(CC_RUNTIME_CLASS(OpCut)) || pUndoOp->IsKindOf(CC_RUNTIME_CLASS(OpPaste))) )
01537 {
01538 RegenerateNode(pUndoOp, FALSE, FALSE);
01539 return CC_OK;
01540 }
01541
01542 Document * pDoc = Document::GetCurrent();
01543
01544 if (pParam->GetChangeType() == OBJCHANGE_FINISHED)
01545 {
01546 if (pParam->GetChangeFlags().RegenerateNode ||
01547 pParam->GetChangeFlags().DeleteNode)
01548 {
01549 Spread* pSpread = FindParentSpread();
01550 if (pSpread)
01551 {
01552 if (pDoc)
01553 pDoc->ForceRedraw(pSpread, BoundingRectangle, FALSE, this);
01554
01555 ReleaseCached();
01556 pUndoOp->DoInvalidateRegion(pSpread, GetBlobBoundingRect());
01557 RegenerateNode(pUndoOp, FALSE, FALSE);
01558 pUndoOp->DoInvalidateRegion(pSpread, GetBlobBoundingRect());
01559
01560 if (pDoc)
01561 pDoc->ForceRedraw(pSpread, GetBoundingRect(), FALSE, this);
01562 }
01563
01564 return NodeEffect::OnChildChange(pParam);
01565 }
01566 }
01567
01568
01569 if (pUndoOp)
01570 {
01571 Spread * pSpread = (Spread *)FindParent(CC_RUNTIME_CLASS(Spread));
01572
01573 if (pDoc && pSpread)
01574 {
01575 ReleaseCached(TRUE, FALSE, FALSE, TRUE);
01576 pDoc->ForceRedraw(pSpread, BoundingRectangle, FALSE, this, FALSE);
01577 }
01578
01579
01580 }
01581
01582
01583 if (pUndoOp)
01584 {
01585 if (pUndoOp->IS_KIND_OF(OpApplyAttribToNode))
01586 {
01587
01588 if (((OpApplyAttribToNode *)pUndoOp)->GetValueChangeType() == CC_RUNTIME_CLASS(AttrTranspChange))
01589 {
01590
01591 TRACEUSER( "Karim", _T("Should this code be running ?\n"));
01592 return CC_OK;
01593 }
01594 }
01595 }
01596
01597
01598 return NodeEffect::OnChildChange(pParam);
01599 }
01600
01601
01602
01603
01604
01605
01606
01607
01608
01609
01610
01611
01612
01613 BOOL NodeShadowController::WritePreChildrenWeb(BaseCamelotFilter* pFilter)
01614 {
01615 #ifdef DO_EXPORT
01616 ERROR2IF(pFilter == NULL,FALSE,"NULL filter param");
01617
01618 CXaraFileRecord Rec(TAG_SHADOWCONTROLLER, TAG_SHADOWCONTROLLER_SIZE);
01619
01620 BOOL ok = TRUE;
01621
01622 if (ok) ok = Rec.Init();
01623 if (ok) ok = Rec.WriteBYTE(m_ShadowType);
01624 if (ok) ok = Rec.WriteINT32(m_PenumbraWidth);
01625
01626
01627 if (ok) ok = Rec.WriteINT32(m_OffsetX);
01628 if (ok) ok = Rec.WriteINT32(m_OffsetY);
01629
01630
01631
01632
01633
01634 if (ok) ok = Rec.WriteINT32(this->FloorAngleToINT32(m_FloorShadowAngle));
01635
01636 INT32 Height = (INT32)(m_FloorShadowHeight * 100);
01637
01638 if (ok) ok = Rec.WriteINT32(Height);
01639
01640 INT32 Scale = (INT32)(m_Scale * 100.0);
01641
01642 if (ok) ok = Rec.WriteINT32(Scale);
01643
01644 if (m_ShadowType==SHADOWTYPE_FEATHER)
01645 {
01646 if (ok) ok = Rec.WriteINT32(m_FeatherWidth);
01647 }
01648 else
01649 {
01650 if (ok) ok = Rec.WriteINT32(m_GlowWidth);
01651 }
01652
01653 if (ok)
01654 {
01655 ok = ok && pFilter->Write(&Rec);
01656 }
01657
01658 return ok;
01659 #else
01660 return FALSE;
01661 #endif
01662 }
01663
01664 BOOL NodeShadowController::WritePreChildrenNative(BaseCamelotFilter* pFilter)
01665 {
01666 #ifdef DO_EXPORT
01667 return WritePreChildrenWeb(pFilter);
01668 #else
01669 return FALSE;
01670 #endif
01671 }
01672
01673
01674
01675
01676
01677
01678
01679
01680
01681
01682
01683
01684
01685
01686
01687
01688
01689
01690 inline double NodeShadowController::FloorAngleFromINT32(INT32 Angle)
01691 {
01692
01693 return fmod((double)Angle / 1000000.0, 2.0 * PI);
01694 }
01695
01696
01697
01698
01699
01700
01701
01702
01703
01704
01705
01706
01707
01708
01709
01710
01711
01712 inline INT32 NodeShadowController::FloorAngleToINT32(double Angle)
01713 {
01714
01715
01716 return (INT32)( 1000000.0 * fmod(m_FloorShadowAngle, 2.0 * PI) );
01717 }
01718
01719
01720
01721
01722
01723
01724
01725
01726
01727
01728
01729
01730
01731
01732 void NodeShadowController::ResetShadowSettings()
01733 {
01734
01735 NodeShadow* pShadow = GetShadow();
01736 ERROR3IF(pShadow == NULL,
01737 "NodeShadowController::ResetShadowSettings; where's my NodeShadow gone?!?");
01738
01739
01740 DocRect drInvalidArea;
01741 if (pShadow != NULL)
01742 drInvalidArea = GetShadow()->GetBoundingRect();
01743
01744
01745 switch (GetShadowType())
01746 {
01747 case SHADOWTYPE_WALL:
01748 SetWallShadowOffset(DocCoord(DefaultWallOffsetX, DefaultWallOffsetY), TRUE);
01749 break;
01750 case SHADOWTYPE_GLOW:
01751 SetGlowWidth(DefaultGlowWidth);
01752 break;
01753 case SHADOWTYPE_FLOOR:
01754 SetFloorShadowAngle(DefaultFloorAngle);
01755 SetFloorShadowHeight(DefaultFloorHeight);
01756 break;
01757 case SHADOWTYPE_FEATHER:
01758 SetFeatherWidth(DefaultFeatherWidth);
01759 break;
01760 default:
01761 ERROR3("NodeShadowController::ResetShadowSettings; unrecognised shadow type!");
01762 break;
01763 }
01764
01765 if (pShadow != NULL)
01766 drInvalidArea = drInvalidArea.Union(pShadow->GetBoundingRect());
01767
01768
01769 if (!drInvalidArea.IsEmpty())
01770 {
01771 Document* pDoc = Document::GetCurrent();
01772 Spread* pSpread = FindParentSpread();
01773 if (pDoc != NULL && pSpread != NULL)
01774 pDoc->ForceRedraw(pSpread, drInvalidArea, FALSE, pShadow);
01775 }
01776 }
01777
01778
01779
01780
01781
01782
01783
01784
01785
01786
01787
01788
01789 NodeRenderableInk* NodeShadowController::GetShadowedNode() const
01790 {
01791
01792 Node* pKid = GetShadow();
01793 if (pKid != NULL)
01794 {
01795 pKid = pKid->FindNext();
01796 while (pKid != NULL && !pKid->IsAnObject())
01797 pKid = pKid->FindNext();
01798 }
01799
01800
01801
01802
01803 #ifdef _DEBUG
01804 if (pKid==NULL)
01805 {
01806 TRACE( _T("NodeShadowController::GetShadowedNode; Can't find shadowed node!"));
01807 }
01808 #endif
01809 return (NodeRenderableInk*)pKid;
01810 }
01811
01812
01813
01814
01815
01816
01817
01818
01819
01820
01821
01822
01823
01824
01825
01826
01827
01828
01829
01830 NodeRenderableInk* NodeShadowController::GetInkNodeFromController() const
01831 {
01832 return GetShadowedNode();
01833 }
01834
01835
01836
01837
01838
01839
01840
01841
01842
01843
01844
01845
01846
01847
01848
01849
01850
01851 NodeRenderableInk* NodeShadowController::GetObjectToApplyTo(CCRuntimeClass* pAttrType)
01852 {
01853
01854
01855
01856
01857
01858
01859
01860
01861
01862
01863
01864
01865
01866
01867
01868
01869
01870
01871
01872
01873 NodeRenderableInk* pInk = GetInkNodeFromController();
01874 if (pInk)
01875 {
01876 NodeRenderableInk* pNode = pInk->GetObjectToApplyTo(pAttrType);
01877 if (pNode!=this)
01878 return pNode;
01879 }
01880
01881 return NodeEffect::GetObjectToApplyTo(pAttrType);
01882 }
01883
01884
01885
01886
01887
01888
01889
01890
01891
01892
01893
01894
01895
01896 NodeShadow* NodeShadowController::GetShadow() const
01897 {
01898 NodeShadow* pBob = (NodeShadow*)FindFirstChild(CC_RUNTIME_CLASS(NodeShadow));
01899
01900 return pBob;
01901 }
01902
01903
01904
01905
01906
01907
01908
01909
01910
01911
01912
01913
01914
01915
01916 INT32 NodeShadowController::ComplexHide(UndoableOperation* pOp, Node* pNextInRange)
01917 {
01918 NodeHidden * pHidden = NULL;
01919 BOOL ok = pOp->DoHideNode(this, TRUE, &pHidden, TRUE);
01920
01921 if (ok)
01922 return 1;
01923
01924 return -1;
01925 }
01926
01927
01928
01929
01930
01931
01932
01933
01934
01935
01936
01937
01938
01939 void NodeShadowController::ShowDebugTreeDetails() const
01940 {
01941 #ifdef _DEBUG
01942
01943
01944 TRACEALL( _T("NodeShadowController ") );
01945 NodeRenderableInk::ShowDebugTreeDetails();
01946 #endif
01947 }
01948
01949
01950
01951
01952
01953
01954
01955
01956
01957
01958
01959
01960
01961
01962 void NodeShadowController::GetDebugDetails(StringBase* Str)
01963 {
01964 #ifdef _DEBUG
01965 NodeRenderableInk::GetDebugDetails(Str);
01966
01967 if (Str == NULL)
01968 return;
01969
01970 String_256 TempStr;
01971
01972 TempStr._MakeMsg(TEXT("Penumbra width = #1%d\r\n"),m_PenumbraWidth);
01973 (*Str)+=TempStr;
01974
01975
01976
01977
01978
01979
01980
01981
01982
01983
01984
01985
01986
01987
01988
01989 #endif
01990 }
01991
01992
01993
01994
01995
01996
01997 ShadowRecordHandler::~ShadowRecordHandler()
01998 {
01999 TRACEUSER( "MarkH", _T("Killing off ShadowRecordHandler!\n"));
02000 }
02001
02002
02003
02004
02005
02006
02007
02008
02009
02010
02011
02012
02013
02014
02015
02016 UINT32* ShadowRecordHandler::GetTagList()
02017 {
02018 static UINT32 TagList[] = { TAG_SHADOWCONTROLLER,
02019 TAG_SHADOW,
02020 CXFRH_TAG_LIST_END};
02021
02022 return (UINT32*)&TagList;
02023 }
02024
02025
02026
02027
02028
02029
02030
02031
02032
02033
02034
02035
02036
02037
02038
02039 BOOL ShadowRecordHandler::HandleRecord(CXaraFileRecord* pCXaraFileRecord)
02040 {
02041 ERROR2IF(pCXaraFileRecord == NULL,FALSE,"pCXaraFileRecord is NULL");
02042
02043 BOOL ok = TRUE;
02044
02045 switch (pCXaraFileRecord->GetTag())
02046 {
02047 case TAG_SHADOWCONTROLLER:
02048 ok = HandleShadowControllerRecord(pCXaraFileRecord);
02049 break;
02050
02051 case TAG_SHADOW:
02052 ok = HandleShadowRecord(pCXaraFileRecord);
02053 break;
02054
02055 default:
02056 ok = FALSE;
02057 ERROR3_PF(("I don't handle records with the tag (%d)\n",pCXaraFileRecord->GetTag()));
02058 break;
02059 }
02060
02061 return ok;
02062 }
02063
02064
02065
02066
02067
02068
02069
02070
02071
02072
02073
02074
02075
02076
02077
02078
02079
02080 BOOL ShadowRecordHandler::HandleShadowControllerRecord(CXaraFileRecord* pCXaraFileRecord)
02081 {
02082 ERROR2IF(pCXaraFileRecord == NULL,FALSE,"pCXaraFileRecord is NULL");
02083 ERROR2IF(pCXaraFileRecord->GetTag() != TAG_SHADOWCONTROLLER,FALSE,"I don't handle this tag type");
02084
02085 TRACEUSER( "MarkH", _T("Reading in NodeShadowController!\n"));
02086
02087 MILLIPOINT Width = 0;
02088 INT32 XOffset = 0;
02089 INT32 YOffset = 0;
02090 INT32 INT32FloorShadowAngle = 0;
02091 INT32 FloorShadowHeight = 0;
02092 INT32 Scale = 0;
02093 INT32 GlowWidth = 0;
02094 ShadowType Type = SHADOWTYPE_WALL;
02095
02096 BYTE temp;
02097 BOOL ok = pCXaraFileRecord->ReadBYTE(&temp);
02098 Type = (ShadowType)temp;
02099 if (ok) ok = pCXaraFileRecord->ReadINT32(&Width);
02100
02101
02102 if (ok) ok = pCXaraFileRecord->ReadINT32(&XOffset);
02103 if (ok) ok = pCXaraFileRecord->ReadINT32(&YOffset);
02104
02105
02106
02107
02108
02109 if (ok) ok = pCXaraFileRecord->ReadINT32(&INT32FloorShadowAngle);
02110
02111 if (ok) ok = pCXaraFileRecord->ReadINT32(&FloorShadowHeight);
02112 if (ok) ok = pCXaraFileRecord->ReadINT32(&Scale);
02113 if (ok) ok = pCXaraFileRecord->ReadINT32(&GlowWidth);
02114
02115 if (ok)
02116 {
02117 NodeShadowController* pController = new NodeShadowController;
02118 if (pController != NULL)
02119 {
02120 pController->SetShadowType(Type);
02121 pController->SetOffsetX(XOffset);
02122 pController->SetOffsetY(YOffset);
02123 pController->SetPenumbraWidth(Width);
02124 pController->SetFloorShadowAngle(pController->FloorAngleFromINT32(INT32FloorShadowAngle));
02125 pController->SetFloorShadowHeight((float)(((double)FloorShadowHeight) / 100.0));
02126 pController->SetWallShadowScale((float)(((double)Scale) / 100.0));
02127 if (Type==SHADOWTYPE_FEATHER)
02128 pController->SetFeatherWidth(GlowWidth);
02129 else
02130 pController->SetGlowWidth(GlowWidth);
02131 pController->SetSelected(FALSE);
02132
02133 ok = InsertNode(pController);
02134 }
02135 else
02136 ok = FALSE;
02137 }
02138
02139 return ok;
02140 }
02141
02142
02143
02144
02145
02146
02147
02148
02149
02150
02151
02152
02153
02154
02155
02156
02157
02158
02159
02160
02161
02162
02163
02164
02165
02166 BOOL ShadowRecordHandler::HandleShadowRecord(CXaraFileRecord* pCXaraFileRecord)
02167 {
02168 ERROR2IF(pCXaraFileRecord == NULL,FALSE,"pCXaraFileRecord is NULL");
02169 ERROR2IF(pCXaraFileRecord->GetTag() != TAG_SHADOW,FALSE,"I don't handle this tag type");
02170
02171 TRACEUSER( "MarkH", _T("Reading in NodeShadow!\n"));
02172
02173 double Bias = 0;
02174 double Gain = 0;
02175 double Darkness = 1.0;
02176
02177
02178 BOOL ok = TRUE;
02179 if (ok) ok = pCXaraFileRecord->ReadDOUBLE(&Bias);
02180 if (ok) ok = pCXaraFileRecord->ReadDOUBLE(&Gain);
02181 if (ok) ok = pCXaraFileRecord->ReadDOUBLEnoError(&Darkness);
02182
02183 NodeShadow* pShadow = new NodeShadow;
02184 CProfileBiasGain Profile;
02185 Profile.SetBias((AFp)Bias);
02186 Profile.SetGain((AFp)Gain);
02187
02188 if (pShadow != NULL)
02189 {
02190 pShadow->SetBiasGain(Profile);
02191 pShadow->SetDarkness(Darkness);
02192 ok = InsertNode(pShadow);
02193 }
02194 else
02195 {
02196 ok = FALSE;
02197 }
02198
02199 return ok;
02200 }
02201
02202
02203
02204
02205
02206
02207
02208
02209
02210
02211
02212
02213
02214
02215
02216
02217
02218
02219 #ifdef XAR_TREE_DIALOG
02220 void ShadowRecordHandler::GetRecordDescriptionText(CXaraFileRecord* pRecord,StringBase* pStr)
02221 {
02222
02223
02224
02225
02226
02227
02228
02229
02230
02231
02232
02233
02234
02235
02236
02237
02238
02239
02240
02241
02242
02243
02244
02245
02246
02247
02248
02249
02250
02251
02252
02253
02254
02255
02256
02257
02258
02259
02260
02261
02262
02263
02264
02265 }
02266
02267 #endif
02268
02269
02270
02271
02272
02273
02274
02275
02276
02277
02278
02279
02280
02281
02282
02283
02284
02285
02286 BOOL NodeShadowController::PostImport()
02287 {
02288
02289
02290 NodeShadow* pShadow = GetShadow();
02291
02292 if (pShadow == NULL)
02293 {
02294 ERROR3("NodeShadowController::PostImport; Cannot find shadow child node!");
02295 return FALSE;
02296 }
02297
02298 pShadow->GenerateShadow();
02299
02300 return TRUE;
02301 }
02302
02303
02304
02305
02306
02307
02308
02309
02310
02311
02312
02313
02314
02315
02316
02317
02318 BOOL NodeShadowController::PostDuplicate(UndoableOperation* pOp)
02319 {
02320
02321 NodeShadow * pShadow = (NodeShadow *)FindFirstChild(CC_RUNTIME_CLASS(NodeShadow));
02322
02323 if (!pShadow)
02324 {
02325 ERROR3("Post duplicate - cannot find shadow child node !");
02326 return FALSE;
02327 }
02328
02329 pShadow->DeleteCache();
02330 pShadow->GenerateShadow();
02331
02332 NodeRenderableInk::PostDuplicate(pOp);
02333
02334 IsBoundingRectValid = FALSE;
02335 DocRect dr = GetBoundingRect(TRUE, FALSE);
02336
02337 return TRUE;
02338 }
02339
02340
02341
02342
02343
02344
02345
02346
02347
02348
02349
02350
02351
02352
02353
02354
02355 BOOL NodeShadowController::RegenerateNode(UndoableOperation * pUndoOp, BOOL bCacheRender,
02356 BOOL bInformParents)
02357 {
02358 Spread * pSpread = (Spread *)FindParent(CC_RUNTIME_CLASS(Spread));
02359
02360 if (!pSpread)
02361 pSpread = Document::GetSelectedSpread();
02362
02363 if (!pSpread)
02364 ERROR2(FALSE, "Can't regenerate node with no spread");
02365
02366 if (pUndoOp)
02367 {
02368
02369
02370 ReleaseCached(TRUE, FALSE, TRUE, TRUE);
02371 pUndoOp->DoInvalidateRegion(pSpread, BoundingRectangle);
02372
02373 ChangePenumbraSizeAction * pAction = NULL;
02374
02375 if (ChangePenumbraSizeAction::Init(pUndoOp,
02376 pUndoOp->GetUndoActionList(),
02377 this,
02378 m_PenumbraWidth,
02379 &pAction, TRUE, bCacheRender) != AC_OK)
02380 {
02381 return FALSE;
02382 }
02383 else
02384 {
02385
02386 pUndoOp->DoInvalidateRegion(pSpread, GetBoundingRect(TRUE, FALSE));
02387
02388 return TRUE;
02389 }
02390 }
02391 else
02392 {
02393
02394
02395
02396 if (bInformParents)
02397 {
02398 PreInformParentsOfRegenerate();
02399 }
02400
02401 Document * pDoc = Document::GetCurrent();
02402
02403 if (pDoc)
02404 {
02405 pDoc->ForceRedraw(pSpread, BoundingRectangle, FALSE, this, FALSE);
02406 pDoc->ForceRedraw(pSpread, GetShadow()->GetBoundingRect(TRUE, FALSE), FALSE, this, FALSE);
02407 }
02408
02409 BOOL ok = this->GetShadow()->GenerateShadow();
02410
02411 InvalidateBoundingRect(TRUE);
02412
02413 if (pDoc)
02414 {
02415 pDoc->ForceRedraw(pSpread, GetBoundingRect(TRUE, FALSE), FALSE, this, FALSE);
02416 }
02417
02418
02419 if (bInformParents)
02420 {
02421 PostInformParentsOfRegenerate();
02422 }
02423
02424 return ok;
02425 }
02426 return TRUE;
02427 }
02428
02429
02430
02431
02432
02433
02434
02435
02436
02437
02438
02439
02440
02441
02442
02443 UINT32 NodeShadowController::GetShadowTransp()
02444 {
02445 NodeShadow* pShadow = GetShadow();
02446
02447 if (pShadow == NULL)
02448 {
02449 ERROR3("NodeShadowController::GetShadowDarkness; No NodeShadow present!");
02450 return 0;
02451 }
02452
02453 return pShadow->GetTransp();
02454 }
02455
02456
02457
02458
02459
02460
02461
02462
02463
02464
02465
02466
02467
02468
02469
02470
02471
02472
02473
02474
02475
02476
02477
02478 DocRect NodeShadowController::ValidateExtend(const ExtendParams& ExtParams)
02479 {
02480 Node* pBob = GetShadow();
02481 DocRect drMinExtend(INT32_MAX, INT32_MAX, INT32_MAX, INT32_MAX), drThisMinExtend;
02482 for ( Node* pChildNode = FindFirstChild();
02483 pChildNode != NULL;
02484 pChildNode = pChildNode->FindNext() )
02485 {
02486 if (pChildNode == pBob)
02487 continue;
02488
02489 drThisMinExtend = pChildNode->ValidateExtend(ExtParams);
02490 if (drMinExtend.lo.x > drThisMinExtend.lo.x) drMinExtend.lo.x = drThisMinExtend.lo.x;
02491 if (drMinExtend.lo.y > drThisMinExtend.lo.y) drMinExtend.lo.y = drThisMinExtend.lo.y;
02492 if (drMinExtend.hi.x > drThisMinExtend.hi.x) drMinExtend.hi.x = drThisMinExtend.hi.x;
02493 if (drMinExtend.hi.y > drThisMinExtend.hi.y) drMinExtend.hi.y = drThisMinExtend.hi.y;
02494 }
02495 return drMinExtend;
02496 }
02497
02498
02499
02500
02501
02502
02503
02504
02505
02506
02507
02508
02509
02510
02511
02512
02513
02514
02515
02516
02517
02518
02519 void NodeShadowController::Extend(const ExtendParams& ExtParams)
02520 {
02521 Node* pBob = GetShadow();
02522 for ( Node* pChildNode = FindFirstChild();
02523 pChildNode != NULL;
02524 pChildNode = pChildNode->FindNext() )
02525 {
02526 if (pChildNode == pBob)
02527 continue;
02528
02529 pChildNode->Extend(ExtParams);
02530 }
02531
02532
02533
02534 m_PerformedExtend = TRUE;
02535 RegenerateNode(ExtParams.pOp, FALSE, FALSE);
02536 }
02537
02538
02539
02540
02541
02542
02543
02544
02545
02546
02547
02548
02549
02550
02551 BOOL NodeShadowController::EndBlendStep(BlendNodeParam * pParam)
02552 {
02553
02554
02555 if (!pParam->GetHandleBecomeA ())
02556 {
02557
02558
02559 BOOL okToRender = TRUE;
02560
02561
02562 if (pParam->GetPathProcessor ())
02563 {
02564 ERROR2IF(!pParam->GetPathProcessor ()->IS_KIND_OF(SumAllPathsPathProcessor),
02565 FALSE, "First path processor isn't a sum all paths path processor");
02566
02567
02568 SumAllPathsPathProcessor * pProc = (SumAllPathsPathProcessor *) pParam->GetPathProcessor ();
02569
02570 pProc->SetEnabled(FALSE);
02571
02572
02573
02574
02575
02576 Node* copy = NULL;
02577 this->NodeCopy (©);
02578
02579 NodeShadowController* ptrCopy = (NodeShadowController*) copy;
02580
02581 if (!ptrCopy) { return (FALSE); }
02582
02583
02584 NodeShadow * pShadowCopy = (NodeShadow *)ptrCopy->FindFirstChild(CC_RUNTIME_CLASS(NodeShadow));
02585 ERROR2IF(pShadowCopy == NULL, FALSE, "Can't find the contour node");
02586
02587 #ifdef _DEBUG // special debug info
02588 INT32 id = ++NodeShadowController::contourLastID;
02589 ptrCopy->myContourID = id;
02590
02591
02592
02593 TRACEUSER("ChrisS", _T("Pushing NodeShadowController ID: %i\n"), ptrCopy->myContourID);
02594 #endif
02595
02597
02598
02599
02600 CCAttrMap * pMap = NULL;
02601 CCAttrMap * pPrimaryShadowAttrMap = NULL;
02602
02603
02604 NodeShadowController * pEndControl = (NodeShadowController *)FindAssociatedBlendNode(pParam);
02605
02606 if (pEndControl)
02607 {
02608
02609
02610 NodeShadow * pEndShadow = (NodeShadow *)pEndControl->FindFirstChild(CC_RUNTIME_CLASS(NodeShadow));
02611 NodeRenderableInk * pOrigEndNode = pEndControl->GetBlendCreatedByNode();
02612
02613
02614 ERROR2IF(pOrigEndNode == NULL, FALSE, "Cant find the original contour node which this is based on");
02615 ERROR2IF(!pOrigEndNode->IS_KIND_OF(NodeShadowController), FALSE, "Original node isn't a NodeShadowController");
02616
02617 pOrigEndNode = (NodeShadow *)pOrigEndNode->FindFirstChild(CC_RUNTIME_CLASS(NodeShadow));
02618
02619 BlendPath MyStartPath;
02620 MyStartPath.Initialise((NodeRenderableInk *)pShadowCopy->PublicCopy(), -1, pShadowCopy, 1, 0, NULL);
02621
02622 BlendPath MyEndPath;
02623 MyEndPath.Initialise((NodeRenderableInk *)pEndShadow->PublicCopy(), -1, pOrigEndNode, 1, 0, NULL);
02624
02625 BlendNodeParam BNParam;
02626 BNParam.Init(pParam, &MyStartPath, &MyEndPath);
02627
02628 pMap = new CCAttrMap(30);
02629
02630 BlendHelpers * pHelp = new BlendHelpers;
02631 ERRORIF(pHelp == NULL, _R(IDE_NOMORE_MEMORY), FALSE);
02632
02633
02634 if (!pHelp->BlendAttributes(&BNParam, pMap))
02635 {
02636 pParam->GetRenderRegion()->PopPathProcessor();
02637 okToRender = FALSE;
02638 }
02639
02640 delete pHelp;
02641
02642
02643 ptrCopy->BlendParameters ((NodeShadowController*) m_pBlendCreatedByNode, (NodeShadowController*) pOrigEndNode->FindParent(), pParam, pMap);
02644 }
02645 else
02646 {
02647
02648
02649
02650
02651
02652
02653
02654 NodeShadow * pContour = (NodeShadow *) FindFirstChild (CC_RUNTIME_CLASS (NodeShadow));
02655
02656 ERROR2IF (pContour == NULL, FALSE, "Can't find Contour node");
02657
02658
02659 pPrimaryShadowAttrMap = CCAttrMap::MakeAppliedAttrMap(pContour);
02660
02661
02662 ptrCopy->BlendParameters ((NodeShadowController *) m_pBlendCreatedByNode, pParam);
02663 }
02664
02665
02666
02667 Node* newShadowing = GetShadowDeleteThisNode ();
02668
02669 if (!newShadowing)
02670 {
02671
02672 NodePath* currentPath = (NodePath *)ptrCopy->FindFirstChild(CC_RUNTIME_CLASS(NodePath));
02673
02674
02675
02676
02677
02678
02679
02680
02681
02682
02683 if (currentPath)
02684 {
02685 currentPath->CascadeDelete ();
02686 delete (currentPath);
02687 currentPath = NULL;
02688
02689 NodeGroup* newGroup = new NodeGroup ();
02690
02691 ListItem* pItem = pProc->GetList ()->GetHead ();
02692
02693 Path* blendPath = NULL;
02694 CCAttrMap* blendMap = NULL;
02695
02696 while (pItem)
02697 {
02698 blendPath = ((SumAllPathsElem *) pItem)->GetPath ();
02699 blendMap = ((SumAllPathsElem *) pItem)->GetAttrMap ();
02700
02701 NodePath* newPath = new NodePath ();
02702 INT32 numCoords = blendPath->GetNumCoords ();
02703 newPath->InkPath.ClearPath ();
02704 newPath->InkPath.Initialise (numCoords);
02705 newPath->InkPath.CopyPathDataFrom (blendPath);
02706 blendMap->ApplyAttributesToNode (newPath);
02707 newPath->AttachNode(newGroup, LASTCHILD);
02708
02709 pItem = pProc->GetList ()->GetNext (pItem);
02710 delete ((SumAllPathsElem *) pProc->GetList()->RemoveHead ());
02711 }
02712
02713 newGroup->AttachNode(pShadowCopy, NEXT);
02714 }
02715 }
02716 else
02717 {
02718
02719
02720 Node* pShadowing = pShadowCopy->FindNext ();
02721
02722 pShadowing->CascadeDelete ();
02723 delete (pShadowing);
02724
02725
02726
02727 newShadowing->AttachNode (pShadowCopy, NEXT);
02728 }
02729
02730
02731
02732 if (pMap)
02733 {
02734 pMap->ApplyAttributesToNode (pShadowCopy);
02735 }
02736
02737 if (pPrimaryShadowAttrMap)
02738 {
02739 pPrimaryShadowAttrMap->ApplyAttributesToNode (pShadowCopy);
02740 }
02741
02742
02743
02744 if (!pShadowCopy->GenerateShadow())
02745 {
02746 okToRender = FALSE;
02747 }
02748
02749
02750
02751 if (okToRender)
02752 {
02753 RenderRegion* pRegion = pParam->GetRenderRegion();
02754
02755 if (pRegion)
02756 pRegion->RenderTreeNoCache(ptrCopy);
02757 }
02758
02759 if (pMap)
02760 {
02761 pMap->DeleteAttributes ();
02762 delete pMap;
02763 }
02764
02765 if (pPrimaryShadowAttrMap)
02766 {
02767 delete pPrimaryShadowAttrMap;
02768 }
02769
02770
02771
02772
02773 if (newShadowing)
02774 {
02775
02776
02777 SetShadowDeleteThisNode (NULL);
02778 }
02779
02780 ptrCopy->CascadeDelete ();
02781 delete (ptrCopy);
02782 }
02783 }
02784 else
02785 {
02786
02787 if (pParam->GetPathProcessor ())
02788 {
02789 ERROR2IF(!pParam->GetPathProcessor ()->IS_KIND_OF(SumAllPathsPathProcessor),
02790 FALSE, "First path processor isn't a sum all paths path processor");
02791
02792
02793 SumAllPathsPathProcessor * pProc = (SumAllPathsPathProcessor *)pParam->GetPathProcessor ();
02794
02795 pProc->SetEnabled(FALSE);
02796
02797
02798
02799
02800
02801 Node* copy = NULL;
02802 this->NodeCopy (©);
02803
02804 NodeShadowController* ptrCopy = (NodeShadowController*) copy;
02805
02806 if (!ptrCopy) { return (FALSE); }
02807
02808
02809 NodeShadow * pShadowCopy = (NodeShadow *)ptrCopy->FindFirstChild(CC_RUNTIME_CLASS(NodeShadow));
02810 ERROR2IF(pShadowCopy == NULL, FALSE, "Can't find the contour node");
02811
02813
02814
02815
02816 CCAttrMap * pMap = NULL;
02817 CCAttrMap * pPrimaryShadowAttrMap = NULL;
02818
02819
02820 NodeShadowController * pEndControl = (NodeShadowController *)FindAssociatedBlendNode(pParam);
02821
02822 if (pEndControl)
02823 {
02824
02825
02826 NodeShadow * pEndShadow = (NodeShadow *)pEndControl->FindFirstChild(CC_RUNTIME_CLASS(NodeShadow));
02827 NodeRenderableInk * pOrigEndNode = pEndControl->GetBlendCreatedByNode();
02828
02829
02830 ERROR2IF(pOrigEndNode == NULL, FALSE, "Cant find the original contour node which this is based on");
02831 ERROR2IF(!pOrigEndNode->IS_KIND_OF(NodeShadowController), FALSE, "Original node isn't a NodeShadowController");
02832
02833 pOrigEndNode = (NodeShadow *)pOrigEndNode->FindFirstChild(CC_RUNTIME_CLASS(NodeShadow));
02834
02835 BlendPath MyStartPath;
02836 MyStartPath.Initialise((NodeRenderableInk *)pShadowCopy->PublicCopy(), -1, pShadowCopy, 1, 0, NULL);
02837
02838 BlendPath MyEndPath;
02839 MyEndPath.Initialise((NodeRenderableInk *)pEndShadow->PublicCopy(), -1, pOrigEndNode, 1, 0, NULL);
02840
02841 BlendNodeParam BNParam;
02842 BNParam.Init(pParam, &MyStartPath, &MyEndPath);
02843
02844 pMap = new CCAttrMap(30);
02845
02846 BlendHelpers * pHelp = new BlendHelpers;
02847 ERRORIF(pHelp == NULL, _R(IDE_NOMORE_MEMORY), FALSE);
02848
02849
02850 pHelp->BlendAttributes(&BNParam, pMap);
02851
02852 delete pHelp;
02853
02854
02855 ptrCopy->BlendParameters ((NodeShadowController*) m_pBlendCreatedByNode, (NodeShadowController*) pOrigEndNode->FindParent(), pParam, pMap);
02856 }
02857 else
02858 {
02859
02860
02861
02862
02863
02864
02865
02866 NodeShadow * pContour = (NodeShadow *) FindFirstChild (CC_RUNTIME_CLASS (NodeShadow));
02867
02868 ERROR2IF (pContour == NULL, FALSE, "Can't find Contour node");
02869
02870
02871 pPrimaryShadowAttrMap = CCAttrMap::MakeAppliedAttrMap(pContour);
02872
02873
02874 ptrCopy->BlendParameters ((NodeShadowController *) m_pBlendCreatedByNode, pParam);
02875 }
02876
02877
02878
02879 Node* newShadowing = GetShadowThisNode ();
02880 SetShadowThisNode (NULL);
02881
02882 std::list<NodePath*> pathPtrs;
02883
02884 BOOL normaliseAttributes = FALSE;
02885
02886 if (!newShadowing)
02887 {
02888
02889 NodePath* currentPath = (NodePath *)ptrCopy->FindFirstChild(CC_RUNTIME_CLASS(NodePath));
02890
02891
02892
02893
02894
02895
02896
02897
02898
02899
02900 if (currentPath)
02901 {
02902 currentPath->CascadeDelete ();
02903 delete (currentPath);
02904 currentPath = NULL;
02905
02906 NodeGroup* newGroup = new NodeGroup ();
02907
02908 ListItem* pItem = pProc->GetList ()->GetHead ();
02909
02910 Path* blendPath = NULL;
02911 CCAttrMap* blendMap = NULL;
02912
02913 while (pItem)
02914 {
02915 blendPath = ((SumAllPathsElem *) pItem)->GetPath ();
02916 blendMap = ((SumAllPathsElem *) pItem)->GetAttrMap ();
02917
02918 NodePath* newPath = new NodePath ();
02919 INT32 numCoords = blendPath->GetNumCoords ();
02920 newPath->InkPath.ClearPath ();
02921 newPath->InkPath.Initialise (numCoords);
02922 newPath->InkPath.CopyPathDataFrom (blendPath);
02923 blendMap->ApplyAttributesToNode (newPath);
02924 newPath->AttachNode(newGroup, LASTCHILD);
02925
02926 pathPtrs.push_back (newPath);
02927
02928 pItem = pProc->GetList ()->GetNext (pItem);
02929 delete ((SumAllPathsElem *) pProc->GetList()->RemoveHead ());
02930 }
02931
02932 newGroup->AttachNode(pShadowCopy, NEXT);
02933 }
02934 }
02935 else
02936 {
02937
02938
02939 Node* pShadowing = pShadowCopy->FindNext ();
02940
02941 pShadowing->CascadeDelete ();
02942 delete (pShadowing);
02943
02944
02945
02946 newShadowing->AttachNode (pShadowCopy, NEXT);
02947
02948 normaliseAttributes = TRUE;
02949 }
02950
02951
02952
02953 if (pMap)
02954 {
02955 pMap->ApplyAttributesToNode (pShadowCopy);
02956 }
02957
02958 if (pPrimaryShadowAttrMap)
02959 {
02960 pPrimaryShadowAttrMap->ApplyAttributesToNode (pShadowCopy);
02961 }
02962
02963
02964
02965 pShadowCopy->GenerateShadow();
02966
02967
02968
02969 BecomeA* accessPtr = pParam->GetHandleBecomeA ()->GetBecomeA ();
02970 UndoableOperation* pUndoOp = accessPtr->GetUndoOp ();
02971
02972
02973 if (accessPtr->GetReason () == BECOMEA_REPLACE)
02974 {
02975 if (pUndoOp)
02976 {
02977 if (!pUndoOp->DoInsertNewNode(ptrCopy,pParam->GetHandleBecomeA ()->GetContextNode (),PREV,TRUE,FALSE,FALSE,TRUE))
02978 {
02979 return FALSE;
02980 }
02981 }
02982 else
02983 {
02984 ptrCopy->AttachNode(pParam->GetHandleBecomeA()->GetContextNode(), PREV);
02985 }
02986
02987
02988
02989 pShadowCopy->NormaliseAttributes ();
02990
02991 std::list<NodePath*>::iterator i;
02992
02993 for (i = pathPtrs.begin (); i != pathPtrs.end (); i++)
02994 (*i)->NormaliseAttributes ();
02995
02996 if (normaliseAttributes)
02997 {
02998
02999
03000
03001
03002
03003
03004
03005 NodePath* pPath = (NodePath*) SliceHelper::FindNextOfClass(ptrCopy, ptrCopy, CC_RUNTIME_CLASS (NodePath));
03006
03007 while (pPath)
03008 {
03009 pPath->NormaliseAttributes ();
03010 pPath = (NodePath*) SliceHelper::FindNextOfClass(pPath, ptrCopy, CC_RUNTIME_CLASS (NodePath));
03011 }
03012
03013
03014
03015 NodeContour* pContour = (NodeContour*) SliceHelper::FindNextOfClass(ptrCopy, ptrCopy, CC_RUNTIME_CLASS (NodeContour));
03016
03017 while (pContour)
03018 {
03019 pContour->NormaliseAttributes ();
03020 pContour = (NodeContour*) SliceHelper::FindNextOfClass(pContour, ptrCopy, CC_RUNTIME_CLASS (NodeContour));
03021 }
03022
03023
03024
03025 NodeBevel* pBevel = (NodeBevel*) SliceHelper::FindNextOfClass(ptrCopy, ptrCopy, CC_RUNTIME_CLASS (NodeBevel));
03026
03027 while (pBevel)
03028 {
03029 pBevel->NormaliseAttributes ();
03030 pBevel = (NodeBevel*) SliceHelper::FindNextOfClass(pBevel, ptrCopy, CC_RUNTIME_CLASS (NodeBevel));
03031 }
03032 }
03033
03034
03035
03036
03037 if (accessPtr->GetInsertComplexBlendStepsAsPaths ())
03038 {
03039 ptrCopy->DoBecomeA (accessPtr);
03040 }
03041 }
03042
03043 else if (accessPtr->GetReason () == BECOMEA_PASSBACK)
03044 {
03045 ptrCopy->DoBecomeA (accessPtr);
03046 ptrCopy->SetBlenderNode (pParam->GetNodeBlend ());
03047
03048 #ifdef _DEBUG
03049 INT32 id = ++NodeShadowController::shadowLastBecomeAID;
03050 ptrCopy->myShadowBecomeAID = id;
03051
03052
03053
03054 TRACEUSER ("ChrisS", _T("Pushing NodeShadowController PASSBACK ID: %i\n"), ptrCopy->myShadowBecomeAID);
03055 #endif
03056
03057
03058
03059 if (AllocatedBlendConsList (LT_BECOMEA_SHADOWSLIST))
03060 {
03061 BlendConsListInsert (LT_BECOMEA_SHADOWSLIST, ptrCopy);
03062 }
03063 else
03064 {
03065 AllocBlendConsList (LT_BECOMEA_SHADOWSLIST);
03066 BlendConsListInsert (LT_BECOMEA_SHADOWSLIST, ptrCopy);
03067 }
03068 }
03069
03070 if (pMap)
03071 {
03072 pMap->DeleteAttributes ();
03073 delete pMap;
03074 }
03075
03076 if (pPrimaryShadowAttrMap)
03077 {
03078 delete pPrimaryShadowAttrMap;
03079 }
03080 }
03081 }
03082 return TRUE;
03083 }
03084
03085
03086
03087
03088
03089
03090
03091
03092
03093
03094
03095
03096
03097
03098
03099
03100
03101
03102
03103
03104 BOOL NodeShadowController::BlendParameters(NodeShadowController * pStart, NodeShadowController * pEnd,
03105 BlendNodeParam * pParam, CCAttrMap* pMap)
03106 {
03107 double Scale = pParam->GetAttrBlendRatio ();
03108 double Scale2 = pParam->GetBlendRatio ();
03109
03110
03111
03112 NodeShadow * pStartShad = (NodeShadow *) pStart->GetShadow ();
03113 ERROR2IF(!pStartShad, FALSE, "Can't find shadow child node for start");
03114
03115 NodeShadow * pEndShad = (NodeShadow *) pEnd->GetShadow ();
03116 ERROR2IF(!pEndShad, FALSE, "Can't find shadow child node for end");
03117
03118 NodeShadow * pThisShad = (NodeShadow *) GetShadow();
03119 ERROR2IF(!pThisShad, FALSE, "Can't find shadow child node for blend node");
03120
03121
03122 double startDarkness = pStartShad->GetDarkness();
03123 double endDarkness = pEndShad->GetDarkness();
03124 double newDarkness = startDarkness + Scale * (endDarkness - startDarkness);
03125 newDarkness = (newDarkness < 0.0) ? 0.0 :
03126 (newDarkness > 1.0) ? 1.0 : newDarkness;
03127
03128 pThisShad->SetDarkness(newDarkness);
03129
03130
03131
03132 AttrFillGeometry* pAttrStart = NULL, *pAttrEnd = NULL;
03133 ((NodeRenderableInk*)pStartShad)->FindAppliedAttribute(CC_RUNTIME_CLASS(AttrFillGeometry), (NodeAttribute **)&pAttrStart);
03134 ((NodeRenderableInk*)pEndShad)->FindAppliedAttribute(CC_RUNTIME_CLASS(AttrFillGeometry), (NodeAttribute **)&pAttrEnd);
03135
03136 ERROR2IF(!pAttrStart, FALSE, "Error - could NOT find start shadow fill!");
03137 ERROR2IF(!pAttrEnd, FALSE, "Error - could NOT find end shadow fill!");
03138
03139 AttrFillGeometry* pCurrentFill = NULL;
03140
03141
03142 if (((NodeRenderableInk*)pThisShad)->FindAppliedAttribute(CC_RUNTIME_CLASS(AttrFillGeometry), (NodeAttribute **)&pCurrentFill))
03143 {
03144 pCurrentFill->UnlinkNodeFromTree ();
03145 delete (pCurrentFill);
03146
03147
03148
03149 BlendAttrParam BlendParam;
03150
03151
03152 if (BlendParam.Init(NULL,
03153 pAttrEnd,Scale,
03154 COLOURBLEND_FADE,
03155 NULL, NULL))
03156 {
03157
03158 if (pAttrStart->Blend(&BlendParam))
03159 {
03160
03161
03162
03163 NodeAttribute* pBlendedNodeAttr = BlendParam.GetBlendedAttr();
03164
03165 if (pBlendedNodeAttr)
03166 {
03167 if (pMap)
03168 {
03169 delete (pMap->ReplaceAttribute (pBlendedNodeAttr));
03170 }
03171 }
03172 }
03173 }
03174 }
03175
03176
03177
03178 double StartBlur = (double)pStart->GetPenumbraWidth();
03179 double EndBlur = (double)pEnd->GetPenumbraWidth();
03180 double NewBlur = ((EndBlur - StartBlur) * Scale) + StartBlur;
03181
03182 SetPenumbraWidth ((MILLIPOINT)NewBlur);
03183
03184
03185
03186 double StartBias = pStartShad->GetBiasGain().GetBias();
03187 double EndBias = pEndShad->GetBiasGain().GetBias();
03188 double NewBias = ((EndBias - StartBias) * Scale) + StartBias;
03189
03190 double StartGain = pStartShad->GetBiasGain().GetGain();
03191 double EndGain = pEndShad->GetBiasGain().GetGain();
03192 double NewGain = ((EndGain - StartGain) * Scale) + StartGain;
03193
03194 CProfileBiasGain BiasGain( NewBias, NewGain );
03195 pThisShad->SetBiasGain( BiasGain );
03196
03197
03198
03199
03200 if (pStart->GetShadowType() == pEnd->GetShadowType())
03201 {
03202 switch (pStart->GetShadowType())
03203 {
03204 case SHADOWTYPE_WALL:
03205 {
03206
03207 double StartOffsetX = (double)pStart->GetOffsetX();
03208 double EndOffsetX = (double)pEnd->GetOffsetX();
03209
03210 double NewOffsetX = ((EndOffsetX - StartOffsetX) * Scale2) + StartOffsetX;
03211
03212 double StartOffsetY = (double)pStart->GetOffsetY();
03213 double EndOffsetY = (double)pEnd->GetOffsetY();
03214
03215 double NewOffsetY = ((EndOffsetY - StartOffsetY) * Scale2) + StartOffsetY;
03216
03217
03218 m_OffsetX = (MILLIPOINT)NewOffsetX;
03219 m_OffsetY = (MILLIPOINT)NewOffsetY;
03220 }
03221 break;
03222 case SHADOWTYPE_FLOOR:
03223 {
03224 double StartAngle = (double)pStart->GetFloorShadowAngle();
03225 double EndAngle = (double)pEnd->GetFloorShadowAngle();
03226
03227 double NewAngle = ((EndAngle - StartAngle) * Scale2) + StartAngle;
03228
03229 double StartHeight = (double)pStart->GetFloorShadowHeight();
03230 double EndHeight = (double)pEnd->GetFloorShadowHeight();
03231
03232 double NewHeight = ((EndHeight - StartHeight) * Scale2) + StartHeight;
03233
03234
03235 m_FloorShadowAngle = NewAngle;
03236 m_FloorShadowHeight = (double)NewHeight;
03237 }
03238 break;
03239 case SHADOWTYPE_GLOW:
03240 {
03241 double StartGlowWidth = (double)pStart->GetGlowWidth();
03242 double EndGlowWidth = (double)pEnd->GetGlowWidth();
03243
03244 double NewGlowWidth = ((EndGlowWidth - StartGlowWidth) * Scale2) + StartGlowWidth;
03245
03246 m_GlowWidth = (MILLIPOINT)NewGlowWidth;
03247 }
03248 break;
03249 case SHADOWTYPE_FEATHER:
03250 {
03251 double StartFeatherWidth = (double)pStart->GetFeatherWidth();
03252 double EndFeatherWidth = (double)pEnd->GetFeatherWidth();
03253
03254 double NewFeatherWidth = ((EndFeatherWidth - StartFeatherWidth) * Scale2) + StartFeatherWidth;
03255
03256 m_FeatherWidth = (MILLIPOINT)NewFeatherWidth;
03257 }
03258 break;
03259 default: break;
03260 }
03261 }
03262
03263 return TRUE;
03264 }
03265
03266
03267
03268
03269
03270
03271
03272
03273
03274
03275
03276
03277
03278
03279
03280
03281
03282
03283
03284 BOOL NodeShadowController::BlendParameters(NodeShadowController * pStart, BlendNodeParam * pParam)
03285 {
03286 double Scale = pParam->GetAttrBlendRatio ();
03287
03288
03289
03290 NodeShadow * pStartShad = (NodeShadow *) pStart->GetShadow ();
03291 ERROR2IF(!pStartShad, FALSE, "Can't find shadow child node for start");
03292
03293 NodeShadow * pThisShad = (NodeShadow *) GetShadow();
03294 ERROR2IF(!pThisShad, FALSE, "Can't find shadow child node for blend node");
03295
03296
03297 double startDarkness = pStartShad->GetDarkness();
03298 double endDarkness = 0.0;
03299 double newDarkness = startDarkness + (2 * Scale) * (endDarkness - startDarkness);
03300 newDarkness = (newDarkness < 0.0) ? 0.0 :
03301 (newDarkness > 1.0) ? 1.0 : newDarkness;
03302
03303 pThisShad->SetDarkness(newDarkness);
03304
03305
03306
03307
03308 double StartBlur = (double)pStart->GetPenumbraWidth();
03309 double EndBlur = 4 * 750;
03310 double NewBlur = ((EndBlur - StartBlur) * (2*Scale)) + StartBlur;
03311
03312 SetPenumbraWidth ((MILLIPOINT) NewBlur);
03313
03314
03315
03316 CProfileBiasGain defaultBiasGain;
03317
03318 double StartBias = pStartShad->GetBiasGain().GetBias();
03319 double EndBias = defaultBiasGain.GetBias();
03320 double NewBias = ((EndBias - StartBias) * (2*Scale)) + StartBias;
03321
03322 double StartGain = pStartShad->GetBiasGain().GetGain();
03323 double EndGain = defaultBiasGain.GetGain();
03324 double NewGain = ((EndGain - StartGain) * (2*Scale)) + StartGain;
03325
03326 CProfileBiasGain BiasGain( NewBias, NewGain );
03327 pThisShad->SetBiasGain( BiasGain );
03328
03329
03330
03331
03332
03333
03334
03335
03336
03337
03338
03339
03340
03341 switch (pStart->GetShadowType())
03342 {
03343 case SHADOWTYPE_WALL:
03344 {
03345
03346 double StartOffsetX = (double)pStart->GetOffsetX();
03347 double EndOffsetX = 0.0;
03348
03349 double NewOffsetX = ((EndOffsetX - StartOffsetX) * (2*Scale)) + StartOffsetX;
03350
03351 double StartOffsetY = (double)pStart->GetOffsetY();
03352 double EndOffsetY = 0.0;
03353
03354 double NewOffsetY = ((EndOffsetY - StartOffsetY) * (2*Scale)) + StartOffsetY;
03355
03356
03357 m_OffsetX = (MILLIPOINT)NewOffsetX;
03358 m_OffsetY = (MILLIPOINT)NewOffsetY;
03359 }
03360 break;
03361 case SHADOWTYPE_FLOOR:
03362 {
03363 double StartAngle = (double)pStart->GetFloorShadowAngle();
03364 double EndAngle = 0.0;
03365
03366 double NewAngle = ((EndAngle - StartAngle) * (2*Scale)) + StartAngle;
03367
03368 double StartHeight = (double)pStart->GetFloorShadowHeight();
03369 double EndHeight = 0.0;
03370
03371 double NewHeight = ((EndHeight - StartHeight) * (2*Scale)) + StartHeight;
03372
03373
03374 m_FloorShadowAngle = NewAngle;
03375 m_FloorShadowHeight = (double)NewHeight;
03376 }
03377 break;
03378 case SHADOWTYPE_GLOW:
03379 {
03380 double StartGlowWidth = (double)pStart->GetGlowWidth();
03381 double EndGlowWidth = 0.0;
03382
03383 double NewGlowWidth = ((EndGlowWidth - StartGlowWidth) * (2*Scale)) + StartGlowWidth;
03384
03385 m_GlowWidth = (MILLIPOINT)NewGlowWidth;
03386 }
03387 break;
03388 case SHADOWTYPE_FEATHER:
03389 {
03390 double StartFeatherWidth = (double)pStart->GetFeatherWidth();
03391 double EndFeatherWidth = 0.0;
03392
03393 double NewFeatherWidth = ((EndFeatherWidth - StartFeatherWidth) * (2*Scale)) + StartFeatherWidth;
03394
03395 m_FeatherWidth = (MILLIPOINT)NewFeatherWidth;
03396 }
03397 break;
03398 default:
03399 break;
03400 }
03401
03402 return (TRUE);
03403 }
03404
03405
03406
03407
03408
03409
03410
03411
03412
03413
03414
03415
03416
03417
03418
03419
03420 NodeRenderableInk *
03421 NodeShadowController::CreateTreeFromNodeToBlend(NodeRenderableInk * pNode,
03422 CCAttrMap * pAttrMap)
03423 {
03424
03425 ERROR2IF(pNode->FindParent() != NULL, NULL, "Node shouldn't have parents");
03426
03427 if (pNode->IsNodePath())
03428 {
03429 pNode->CascadeDelete();
03430 }
03431
03432
03433 if (pNode->IsNodePath() && pAttrMap)
03434 {
03435 pNode->ApplyAttributes(pAttrMap, FALSE);
03436 }
03437
03438
03439 NodeShadowController * pControl = NULL;
03440
03441 pControl = (NodeShadowController *)this->PublicCopy();
03442 ERRORIF(pControl == NULL, _R(IDE_NOMORE_MEMORY), NULL);
03443
03444 NodeShadow * pShadow = (NodeShadow *)FindFirstChild(CC_RUNTIME_CLASS(NodeShadow));
03445 ERROR2IF(pShadow == NULL, NULL, "Can't find bevel node");
03446
03447
03448 NodeShadow * pCopyShadow = (NodeShadow *)pShadow->PublicCopy();
03449 ERRORIF(pCopyShadow == NULL, _R(IDE_NOMORE_MEMORY), NULL);
03450
03451 CCAttrMap * pShadowMap = CCAttrMap::MakeAppliedAttrMap(pShadow);
03452 ERRORIF(pShadowMap == NULL, _R(IDE_NOMORE_MEMORY), NULL);
03453
03454 #ifdef _DEBUG
03455 CCAttrMap::iterator pos = pShadowMap->GetStartPosition();
03456 while( pos != pShadowMap->GetEndPosition() )
03457 {
03458 CCRuntimeClass *pKey;
03459 NodeAttribute *pVal;
03460 pShadowMap->GetNextAssoc( pos, pKey, (PVOID &)pVal );
03461
03462 INT32 i = 0;
03463 i++;
03464 }
03465 #endif
03466
03467 pCopyShadow->ApplyAttributes(pShadowMap, FALSE);
03468
03469 delete pShadowMap;
03470
03471 pNode->AttachNode(pControl, FIRSTCHILD);
03472
03473 pCopyShadow->AttachNode(pControl, FIRSTCHILD);
03474
03475 return pControl;
03476 }
03477
03478
03479
03480
03481
03482
03483
03484
03485
03486
03487
03488
03489
03490
03491
03492
03493
03494
03495
03496
03497 void NodeShadowController::SetFloorShadowVector(const DocCoord& dcControlVector)
03498 {
03499
03500
03501 INT32 BaseHeight = GetInsideBoundingRect().Height();
03502 double HeightRatio = 0.0;
03503 if (BaseHeight > 0)
03504 HeightRatio = (double)dcControlVector.y / (double)BaseHeight;
03505 else
03506 HeightRatio = 1.0;
03507
03508 if (HeightRatio > MAXSHADOWHEIGHT)
03509 HeightRatio = MAXSHADOWHEIGHT;
03510 else if (HeightRatio < 0.01)
03511 HeightRatio = 0.01;
03512
03513 SetFloorShadowHeight((float)HeightRatio);
03514
03515
03516
03517 double Angle = dcControlVector.AngleFromVertical();
03518 if (Angle < -MAXSHADOWANGLE)
03519 Angle = -MAXSHADOWANGLE;
03520 else if (Angle > MAXSHADOWANGLE)
03521 Angle = MAXSHADOWANGLE;
03522
03523 SetFloorShadowAngle(Angle);
03524 }
03525
03526
03527
03528
03529
03530
03531
03532
03533
03534
03535
03536
03537
03538
03539
03540 DocCoord NodeShadowController::GetFloorShadowVector()
03541 {
03542
03543
03544 INT32 BaseHeight = GetInsideBoundingRect().Height();
03545 INT32 Height = INT32(GetFloorShadowHeight() * BaseHeight);
03546 return DocCoord( INT32(Height * tan( GetFloorShadowAngle() )), Height);
03547 }
03548
03549
03550
03551
03552
03553
03554
03555
03556
03557
03558
03559
03560
03561
03562
03563
03564 void NodeShadowController::SetWallShadowOffset( const DocCoord& dcOffset,
03565 BOOL UpdateNodeShadow )
03566 {
03567
03568 NodeShadow* pShadow = GetShadow();
03569 if (pShadow == NULL)
03570 {
03571 ERROR3("NodeShadowController::SetWallShadowOffset; can't find NodeShadow!");
03572 return;
03573 }
03574
03575
03576 Trans2DMatrix transAttrs( dcOffset.x - m_OffsetX,
03577 dcOffset.y - m_OffsetY );
03578 pShadow->TransformChildren(transAttrs);
03579
03580
03581 m_OffsetX = dcOffset.x;
03582 m_OffsetY = dcOffset.y;
03583
03584
03585 if (UpdateNodeShadow)
03586 {
03587
03588
03589
03590 Node* pBlendParent = FindParent();
03591 while (pBlendParent != NULL && !pBlendParent->IsABlend())
03592 pBlendParent = pBlendParent->FindParent();
03593
03594 if (pBlendParent != NULL)
03595 RegenerateNode(NULL);
03596
03597 else
03598 pShadow->UpdateAfterWallOffset();
03599 }
03600 }
03601
03602
03603
03604
03605
03606
03607
03608
03609
03610
03611
03612
03613
03614 DocCoord NodeShadowController::GetWallShadowOffset()
03615 {
03616 return DocCoord(m_OffsetX, m_OffsetY);
03617 }
03618
03619
03620
03621 void NodeShadowController::PreExportRender(RenderRegion* pRegion)
03622 {
03623 #ifdef DO_EXPORT
03624 if (pRegion->IsKindOf(CC_RUNTIME_CLASS(EPSRenderRegion)))
03625 {
03626
03627 EPSExportDC *pDC = (EPSExportDC *) pRegion->GetRenderDC();
03628 pDC->OutputToken(_T("u"));
03629 pDC->OutputNewLine();
03630 }
03631 PORTNOTE("cmx", "Removed use of CMXRenderRegion")
03632 #ifndef EXCLUDE_FROM_XARALX
03633 else if(pRegion->IsKindOf(CC_RUNTIME_CLASS(CMXRenderRegion)))
03634 {
03635
03636 CMXExportDC *pDC = (CMXExportDC *) pRegion->GetRenderDC();
03637 DocRect BBox = GetBoundingRect();
03638 pDC->StartGroup(&BBox);
03639 }
03640 #endif
03641 #endif
03642 }
03643
03644 BOOL NodeShadowController::ExportRender(RenderRegion* pRegion)
03645 {
03646 #ifdef DO_EXPORT
03647 if (pRegion->IsKindOf(CC_RUNTIME_CLASS(EPSRenderRegion)))
03648 {
03649
03650 EPSExportDC *pDC = (EPSExportDC *) pRegion->GetRenderDC();
03651 pDC->OutputToken(_T("U"));
03652 pDC->OutputNewLine();
03653
03654
03655 return TRUE;
03656 }
03657 PORTNOTE("cmx", "Removed use of CMXRenderRegion")
03658 #ifndef EXCLUDE_FROM_XARALX
03659 else if(pRegion->IsKindOf(CC_RUNTIME_CLASS(CMXRenderRegion)))
03660 {
03661
03662 CMXExportDC *pDC = (CMXExportDC *) pRegion->GetRenderDC();
03663 pDC->EndGroup();
03664
03665 return TRUE;
03666 }
03667 #endif
03668 #endif
03669
03670 return FALSE;
03671 }
03672
03673
03674
03675
03676
03677
03678
03679
03680
03681
03682
03683
03684
03685 void NodeShadowController::RenderTinyBlobs(RenderRegion* pRegion)
03686 {
03687 #if !defined(EXCLUDE_FROM_RALPH)
03688
03689 Node* pNode = FindLastChild();
03690 while (pNode != NULL && !pNode->IsAnObject())
03691 pNode = pNode->FindPrevious();
03692
03693
03694 if (pNode == NULL)
03695 {
03696 ERROR3("NodeShadowController::RenderTinyBlobs; This group is empty! Shouldn't be!");
03697 return;
03698 }
03699 else
03700 {
03701 ((NodeRenderableInk*)pNode)->RenderTinyBlobs(pRegion);
03702 }
03703
03704 #endif
03705 }
03706
03707
03708
03709
03710
03711
03712
03713
03714
03715
03716
03717
03718
03719
03720 BOOL NodeShadowController::CompareState(NodeEffect* pPPNode)
03721 {
03722 if (!pPPNode->IsAShadowController())
03723 return FALSE;
03724
03725 NodeShadowController* pTest = (NodeShadowController*)pPPNode;
03726
03727
03728 BOOL bSame = (m_OffsetX==pTest->m_OffsetX && m_OffsetY==pTest->m_OffsetY);
03729 bSame = bSame && (m_PenumbraWidth==pTest->m_PenumbraWidth);
03730 bSame = bSame && (m_sShadowName==pTest->m_sShadowName && m_ShadowType==pTest->m_ShadowType);
03731 bSame = bSame && (m_FloorShadowAngle==pTest->m_FloorShadowAngle && m_FloorShadowHeight==pTest->m_FloorShadowHeight);
03732 bSame = bSame && (m_Scale==pTest->m_Scale);
03733 bSame = bSame && (m_GlowWidth==pTest->m_GlowWidth);
03734 bSame = bSame && (m_FeatherWidth==pTest->m_FeatherWidth);
03735
03736 if (bSame)
03737 {
03738
03739 NodeShadow* pShadow = GetShadow();
03740 NodeShadow* pTestShadow = pTest->GetShadow();
03741 bSame = bSame && (pShadow->GetBiasGain() == pTestShadow->GetBiasGain());
03742 bSame = bSame && (pShadow->GetDarkness() == pTestShadow->GetDarkness());
03743 }
03744
03745 return (bSame);
03746 }
03747
03748
03749
03750
03751
03752
03753
03754
03755
03756
03757
03758
03759
03760
03761
03762
03763 BOOL NodeShadowController::CompareState(NodeEffect* pPPNode, ShadowFieldMask mask)
03764 {
03765 if (!pPPNode->IsAShadowController())
03766 return FALSE;
03767
03768 NodeShadowController* pTest = (NodeShadowController*)pPPNode;
03769
03770
03771 BOOL bSame = TRUE;
03772 bSame = bSame && (!mask.OffsetX || (m_OffsetX==pTest->m_OffsetX));
03773 bSame = bSame && (!mask.OffsetY || (m_OffsetY==pTest->m_OffsetY));
03774 bSame = bSame && (!mask.Penumbra || (m_PenumbraWidth==pTest->m_PenumbraWidth));
03775 bSame = bSame && (!mask.Name || (m_sShadowName==pTest->m_sShadowName));
03776 bSame = bSame && (!mask.Type || (m_ShadowType==pTest->m_ShadowType));
03777 bSame = bSame && (!mask.FloorAngle || (m_FloorShadowAngle==pTest->m_FloorShadowAngle));
03778 bSame = bSame && (!mask.FloorHeight || (m_FloorShadowHeight==pTest->m_FloorShadowHeight));
03779 bSame = bSame && (!mask.Scale || (m_Scale==pTest->m_Scale));
03780 bSame = bSame && (!mask.GlowWidth || (m_GlowWidth==pTest->m_GlowWidth));
03781 bSame = bSame && (!mask.FeatherWidth || (m_FeatherWidth==pTest->m_FeatherWidth));
03782
03783 if (bSame)
03784 {
03785
03786 NodeShadow* pShadow = GetShadow();
03787 NodeShadow* pTestShadow = pTest->GetShadow();
03788 bSame = bSame && (!mask.BiasGain || (pShadow->GetBiasGain() == pTestShadow->GetBiasGain()));
03789 bSame = bSame && (!mask.Darkness || (pShadow->GetDarkness() == pTestShadow->GetDarkness()));
03790 }
03791
03792 return (bSame);
03793 }
03794
03795
03796
03797
03798
03799
03800
03801
03802
03803
03804
03805
03806
03807
03808
03809
03810
03811
03812
03813
03814
03815
03816
03817 void NodeShadowController::InvalidateBoundingRect(BOOL InvalidateChildBounds )
03818 {
03819
03820 if (IsBoundingRectValid)
03821 {
03822 NodeShadow* pShadow = GetShadow();
03823 if (pShadow)
03824 pShadow->InvalidateBoundingRect(InvalidateChildBounds);
03825 }
03826
03827 NodeEffect::InvalidateBoundingRect(InvalidateChildBounds);
03828 }
03829
03830
03831
03832 #ifdef NEW_SHADOW_RENDER
03833
03834
03835
03836
03837
03838
03839
03840
03841
03842
03843
03844
03845
03846
03847 SubtreeRenderState NodeShadowController::RenderSubtree(RenderRegion* pRender, Node** ppNextNode, BOOL bClip)
03848 {
03849 BOOL bRendered = FALSE;
03850
03851 if (pRender == NULL)
03852 return SUBTREE_ROOTANDCHILDREN;
03853
03854
03855
03856 if (!IsCapturingChildren())
03857 return SUBTREE_ROOTANDCHILDREN;
03858
03859
03860 if (!IsTopShadowController())
03861 return SUBTREE_ROOTANDCHILDREN;
03862
03863
03864
03865 if (pRender->RRQuality.GetFillQuality() <= Quality::NoFill)
03866 return SUBTREE_ROOTANDCHILDREN;
03867
03868 CBitmapCache* pBitmapCache = Camelot.GetBitmapCache();
03869 if (pBitmapCache==NULL)
03870 return SUBTREE_NORENDER;
03871
03872
03873 FindCachedEffect(pBitmapCache);
03874
03875
03876
03877
03878 DocRect BoundingRect = GetBoundingRect();
03879
03880
03881 DocRect ClipRect = pRender->GetClipRect();
03882
03883 if (bClip && !ClipRect.IsIntersectedWith(BoundingRect))
03884 return SUBTREE_NORENDER;
03885
03886
03887
03888
03889
03890 bRendered = RenderCachedEffect(pBitmapCache, pRender);
03891
03892 if (bRendered)
03893 {
03894 TRACEUSER( "Phil", _T("NSC::RenderSubtree rendered cached @ %fdpi\n"), GetPixelsPerInch());
03895 return SUBTREE_NORENDER;
03896 }
03897
03898
03899
03900
03901
03902
03903
03904 double PixelWidth = GetPixelWidth();
03905
03906
03907
03908 DocRect viewrect = ClipRect;
03909 DocRect CaptureRect = GetChildBoundingRect();
03910
03911
03912
03913
03914
03915 if (CaptureRect.Width()>=PixelWidth || CaptureRect.Height()>=PixelWidth)
03916 {
03917 TRACEUSER( "Phil", _T("NSC::RenderSubtree Capturing cached @ %fdpi\n"), GetPixelsPerInch());
03918 CaptureFlags caFlags = CaptureFlags(cfLOCKEDTRANSPARENT | cfFULLCOVERAGE);
03919 pRender->StartCapture(this, CaptureRect, CAPTUREINFO(ctNESTABLE, caFlags), TRUE, FALSE, GetPixelsPerInch());
03920 }
03921
03922 return bRendered ? SUBTREE_NORENDER : SUBTREE_ROOTANDCHILDREN;
03923 }
03924
03925
03926
03927
03928
03929
03930
03931
03932
03933
03934
03935
03936
03937
03938
03939 void NodeShadowController::RenderAfterSubtree(RenderRegion* pRender)
03940 {
03941 Capture* pCapture = pRender->GetTopCapture();
03942 if (pCapture==NULL)
03943 return;
03944
03945 CBitmapCache* pBitmapCache = Camelot.GetBitmapCache();
03946 if (pBitmapCache==NULL)
03947 {
03948 return;
03949 }
03950
03951
03952
03953 if (pCapture->GetOwner()==this)
03954 {
03955
03956
03957
03958 BOOL bCached = FALSE;
03959 LPBITMAPINFO lpInfo = NULL;
03960 LPBYTE lpBits = NULL;
03961 DocRect CaptureRect = GetChildBoundingRect();
03962 pRender->StopCapture(this, FALSE, FALSE, &lpInfo, &lpBits, &CaptureRect);
03963
03964
03965 if (lpInfo && lpBits && CaptureRect.IsValid())
03966 {
03967
03968
03969 double PixelWidth = GetPixelWidth();
03970 CBitmapCacheKey inky(this, PixelWidth, 0);
03971
03972 CCachedBitmap cbmp;
03973
03974 cbmp.pbmpBits = lpBits;
03975 cbmp.pbmpInfo = lpInfo;
03976 cbmp.SetCachedRect(CaptureRect);
03977 cbmp.nPriority = CACHEPRIORITY_TEMPBITMAP_HIGH;
03978
03979 if (cbmp.IsValid())
03980 {
03981 pBitmapCache->StoreBitmap(inky, cbmp);
03982 bCached = TRUE;
03983 }
03984
03985 RenderCachedEffect(pBitmapCache, pRender);
03986
03987 }
03988
03989
03990 if (lpInfo!=NULL && lpBits!=NULL && !bCached)
03991 {
03992 FreeDIB(lpInfo, lpBits, NULL, FALSE);
03993 }
03994 }
03995 }
03996
03997
03998
03999
04000
04001
04002
04003
04004
04005
04006
04007
04008
04009
04010
04011
04012
04013
04014
04015
04016
04017
04018
04019
04020
04021
04022
04023
04024
04025
04026
04027
04028
04029
04030
04031
04032
04033
04034
04035
04036
04037
04038
04039 BOOL NodeShadowController::FindCachedEffect(CBitmapCache* pBitmapCache)
04040 {
04041 CBitmapCacheKey inky(this, GetPixelWidth(), 0);
04042 CCachedBitmap cbmp;
04043 BOOL bFoundCached = pBitmapCache->Lookup(inky, cbmp);
04044
04045 return bFoundCached;
04046 }
04047
04048
04049
04050
04051
04052
04053
04054
04055
04056
04057
04058
04059
04060
04061
04062
04063
04064
04065
04066
04067
04068
04069 BOOL NodeShadowController::RenderCachedEffect(CBitmapCache* pBitmapCache, RenderRegion* pRender)
04070 {
04071 BOOL bRendered = FALSE;
04072
04073 CBitmapCacheKey inky(this, GetPixelWidth(), 0);
04074 CCachedBitmap cbmp;
04075 BOOL bFoundCached = pBitmapCache->Lookup(inky, cbmp);
04076
04077
04078 NodeShadow* pShadow = GetShadow();
04079 if (pShadow && bFoundCached)
04080 {
04081 double PixelWidth = GetPixelWidth();
04082
04083
04084
04085
04086
04087
04088 if (this->IsTopShadowController())
04089 {
04090 LPBITMAPINFO lpInfo = NULL;
04091 LPBYTE lpBits = NULL;
04092 DocRect CaptureRect;
04093
04094 pShadow = FindBottomShadow();
04095 while (pShadow)
04096 {
04097 if (bFoundCached && pShadow->NeedsRemake())
04098 {
04099
04100
04101 if (lpInfo==NULL || lpBits==NULL)
04102 {
04103
04104
04105 CaptureFlags caFlags = CaptureFlags(cfLOCKEDTRANSPARENT | cfPIXWIDTHSCALE);
04106 CaptureRect = cbmp.GetCachedRect();
04107 pRender->StartCapture(this, CaptureRect, CAPTUREINFO(ctNESTABLE, caFlags), TRUE, FALSE, 72000.0/PixelWidth);
04108 pRender->RenderBits(cbmp.pbmpInfo, cbmp.pbmpBits, &cbmp.coord0, 3, TRUE, this);
04109 pRender->StopCapture(this, FALSE, FALSE, &lpInfo, &lpBits, &CaptureRect);
04110 }
04111
04112 if (lpBits && lpInfo)
04113 pShadow->MakeShadow(lpInfo, lpBits, CaptureRect);
04114 }
04115
04116
04117 pShadow->RenderShadow(pRender);
04118
04119 pShadow = FindShadowAbove(pShadow);
04120 }
04121
04122
04123 if (lpInfo && lpBits)
04124 ::FreeDIB(lpInfo, lpBits);
04125 }
04126 }
04127
04128
04129
04130 if (bFoundCached)
04131 {
04132 bRendered = pRender->RenderBits(cbmp.pbmpInfo, cbmp.pbmpBits, &cbmp.coord0, 3, TRUE, this);
04133 }
04134
04135 return bRendered;
04136 }
04137
04138 BOOL NodeShadowController::IsTopShadowController()
04139 {
04140 Node* pParent = FindParent();
04141 return (pParent==NULL || !pParent->IsAShadowController());
04142 }
04143
04144 BOOL NodeShadowController::IsInShadowStack()
04145 {
04146 Node* pNode = FindParent();
04147 if (pNode && pNode->IsAShadowController())
04148 return TRUE;
04149
04150 pNode = GetInkNodeFromController();
04151 if (pNode && pNode->IsAShadowController())
04152 return TRUE;
04153
04154 return FALSE;
04155 }
04156
04157 NodeShadowController* NodeShadowController::FindBottomShadowController()
04158 {
04159 Node* pChild = GetInkNodeFromController();
04160 NodeShadowController* pBottomController = this;
04161
04162 while (pChild && pChild->IsAShadowController())
04163 {
04164 pBottomController = (NodeShadowController*)pChild;
04165 pChild = pBottomController->GetInkNodeFromController();
04166 }
04167
04168 return pBottomController;
04169 }
04170
04171 NodeShadow* NodeShadowController::FindBottomShadow()
04172 {
04173 NodeShadowController* pBottomController = this;
04174 pBottomController = FindBottomShadowController();
04175
04176 if (pBottomController)
04177 return pBottomController->GetShadow();
04178 else
04179 return NULL;
04180 }
04181
04182 NodeShadow* NodeShadowController::FindShadowAbove(NodeShadow* pCurrentShadow)
04183 {
04184 Node* pController = pCurrentShadow->GetParentController();
04185 pController = pController->FindParent();
04186 if (pController==NULL || !pController->IsAShadowController())
04187 return NULL;
04188 else
04189 return ((NodeShadowController*)pController)->GetShadow();
04190 }
04191
04192 void NodeShadowController::ReleaseStackedShadows()
04193 {
04194 NodeShadow* pShadow = FindBottomShadow();
04195 while (pShadow)
04196 {
04197 pShadow->ReleaseCached(FALSE, TRUE, TRUE, TRUE);
04198
04199 pShadow = FindShadowAbove(pShadow);
04200 }
04201 }
04202
04203
04204
04205
04206
04207
04208
04209
04210
04211
04212
04213
04214
04215
04216
04217
04218
04219
04220
04221 double NodeShadowController::GetPixelsPerInch()
04222
04223
04224
04225
04226
04227
04228
04229 {
04230
04231
04232
04233 double dPPI = 0.0;
04234
04235 if (NodeBitmapEffect::ShadowPixelsPerInch==0)
04236 {
04237
04238
04239
04240
04241 View* pView = View::GetCurrent();
04242 double dViewPPI = 96.0;
04243 if (pView)
04244 dViewPPI = 72000.0 / pView->GetPixelWidth().MakeDouble();
04245
04246 Node* pParent = this->FindParent();
04247 while (pParent && !pParent->IsLayer())
04248 {
04249 if (pParent->IsBitmapEffect())
04250 {
04251 dPPI = ((NodeBitmapEffect*)pParent)->GetPixelsPerInchValue();
04252 if (dPPI!=0)
04253 break;
04254
04255
04256 dPPI = dViewPPI;
04257 }
04258
04259 pParent = pParent->FindParent();
04260 }
04261
04262
04263
04264 if (dPPI==0)
04265 {
04266
04267
04268
04269
04270
04271 if (pView)
04272 {
04273 dPPI = 72000.0 / pView->GetPixelWidth().MakeDouble();
04274 double dScaledPPI = 72000.0 / pView->GetScaledPixelWidth().MakeDouble();
04275
04276
04277 if (dScaledPPI > dPPI*4.0)
04278 dScaledPPI = dPPI*4.0;
04279
04280
04281 if (dPPI < dScaledPPI)
04282 dPPI = dScaledPPI;
04283 }
04284 }
04285 }
04286
04287 if (dPPI==0)
04288 dPPI = NodeBitmapEffect::ShadowPixelsPerInch;
04289
04290 if (dPPI==0)
04291 {
04292
04293 ERROR3("GetPixelsPerInch can't get sensible PPI so defaulting to 96");
04294 dPPI = 96.0;
04295 }
04296
04297 return dPPI;
04298 };
04299
04300
04301
04302
04303
04304
04305
04306
04307
04308
04309
04310
04311
04312
04313
04314
04315
04316
04317
04318 double NodeShadowController::GetPixelWidth()
04319 {
04320
04321 return 72000.0 / GetPixelsPerInch();
04322 }
04323
04324
04325
04326
04327
04328
04329
04330
04331
04332
04333
04334
04335
04336
04337
04338
04339
04340
04341
04342
04343
04344 BOOL NodeShadowController::ReleaseCached(BOOL bAndParents, BOOL bAndChildren, BOOL bSelf, BOOL bAndDerived)
04345 {
04346 if (!IsCapturingChildren())
04347 {
04348 NodeShadow * pShadow = (NodeShadow *)FindFirstChild(CC_RUNTIME_CLASS(NodeShadow));
04349 if (pShadow && bAndDerived && !IsDragged())
04350 {
04351 pShadow->DeleteCache();
04352 }
04353
04354 return NodeEffect::ReleaseCached(bAndParents, bAndChildren, bSelf, bAndDerived);
04355 }
04356
04357
04358
04359 if (!IsDragged())
04360 {
04361 CBitmapCache* pBitmapCache = Camelot.GetBitmapCache();
04362 if (pBitmapCache!=NULL && bSelf)
04363 {
04364 CBitmapCacheKey inky(this, 42);
04365 pBitmapCache->RemoveAllOwnedBitmaps(inky, FALSE, CACHEPRIORITY_PERMANENT);
04366 }
04367
04368
04369
04370
04371 if (bAndDerived)
04372 {
04373 ReleaseStackedShadows();
04374
04375
04376
04377
04378
04379 }
04380 }
04381
04382
04383 if (bAndChildren)
04384 {
04385 Node* pChild = FindFirstChild();
04386 while (pChild)
04387 {
04388 if (pChild->IsBounded())
04389 ((NodeRenderableBounded*)pChild)->ReleaseCached(FALSE, TRUE, TRUE, TRUE);
04390
04391 pChild = pChild->FindNext();
04392 }
04393 }
04394
04395
04396 if (bAndParents && FindParent() && FindParent()->IsBounded())
04397 ((NodeRenderableBounded*)FindParent())->ReleaseCached(TRUE, FALSE, TRUE, TRUE);
04398
04399 return TRUE;
04400 }
04401
04402
04403
04404
04405
04406
04407
04408
04409
04410
04411
04412
04413
04414
04415
04416
04417
04418
04419
04420
04421
04422 BOOL NodeShadowController::IsCapturingChildren()
04423 {
04424
04425
04426 return HasEffectAttrs() || IsInShadowStack();
04427 }
04428
04429
04430
04431
04432
04433
04434
04435
04436
04437
04438
04439
04440
04441
04442
04443
04444
04445 DocRect NodeShadowController::GetChildBoundingRect(BOOL bIncludeAttrs)
04446 {
04447 NodeShadowController* pController = FindBottomShadowController();
04448 return pController->GetShadowedNode()->GetBoundingRect(!bIncludeAttrs);
04449
04450
04451
04452
04453
04454
04455
04456
04457
04458
04459
04460
04461
04462
04463
04464
04465
04466 }
04467
04468
04469
04470
04471 #endif
04472
04473
04474
04475
04477
04478
04479
04480
04481
04482
04483
04484
04485
04486
04487
04488
04489
04490 ShadowNodeTreeFactory::ShadowNodeTreeFactory()
04491 {
04492 m_ShadowType = SHADOWTYPE_NONE;
04493 m_OffsetX = 0;
04494 m_OffsetY = 0;
04495 m_PenumbraWidth = 0;
04496 m_FloorShadowAngle = 0;
04497 m_FloorShadowHeight = 0;
04498 m_Scale = 0;
04499 m_GlowWidth = 0;
04500 m_FeatherWidth = 0;
04501 }
04502
04503
04504
04505
04506
04507
04508
04509
04510
04511
04512
04513
04514 ShadowNodeTreeFactory::~ShadowNodeTreeFactory()
04515 {
04516 NodeListItem * pItem = (NodeListItem *)m_AttributeList.GetHead();
04517
04518 while (pItem)
04519 {
04520 delete pItem->pNode;
04521 pItem->pNode = NULL;
04522
04523 pItem = (NodeListItem *)m_AttributeList.GetNext(pItem);
04524 }
04525
04526 m_AttributeList.DeleteAll();
04527 }
04528
04529
04530
04531
04532
04533
04534
04535
04536
04537
04538
04539
04540 void ShadowNodeTreeFactory::SetUpAttributeList(Node * pShadow)
04541 {
04542 NodeListItem * pItem = NULL;
04543
04544
04545 CCAttrMap *pMap = CCAttrMap::MakeAppliedAttrMap((NodeRenderableInk *)pShadow);
04546
04547 CCAttrMap::iterator pos = pMap->GetStartPosition();
04548
04549 NodeAttribute * pAttrNode = NULL;
04550
04551
04552 while( pos != pMap->GetEndPosition() )
04553 {
04554 CCRuntimeClass *pKey;
04555 void *pVal;
04556 pMap->GetNextAssoc(pos, pKey, pVal);
04557
04558 pAttrNode = ((NodeAttribute *)pVal);
04559
04560 pItem = new NodeListItem;
04561
04562 if (!pItem)
04563 {
04564 ERROR3("Can't create NodeListItem");
04565 return;
04566 }
04567
04568 pAttrNode->NodeCopy(&(pItem->pNode));
04569
04570 m_AttributeList.AddTail(pItem);
04571 }
04572
04573 delete pMap;
04574 pMap = NULL;
04575 }
04576
04577
04578
04579
04580
04581
04582
04583
04584
04585
04586
04587
04588
04589 NodeCompound * ShadowNodeTreeFactory::CreateNode(List *pList, UndoableOperation * pOp )
04590 {
04591 NodeShadowController * pControl = NULL;
04592 NodeShadow * pShadow = NULL;
04593
04594 NodeListItem * pItem = NULL;
04595 NodeListItem * pAttrItem = NULL;
04596
04597
04598
04599 BOOL ok = TRUE;
04600
04601 if (pOp)
04602 {
04603
04604 ALLOC_WITH_FAIL(pControl, (new NodeShadowController), pOp);
04605 ALLOC_WITH_FAIL(pShadow, (new NodeShadow), pOp);
04606
04607
04608 pItem = (NodeListItem *)pList->GetHead();
04609
04610
04611 ok = pOp->DoInsertNewNode(pControl, (Node *)pItem->pNode, NEXT, TRUE);
04612
04613 while (pItem && ok)
04614 {
04615 ok = pOp->DoMoveNode(pItem->pNode, pControl, LASTCHILD);
04616
04617 pItem = (NodeListItem *)pList->GetNext(pItem);
04618 }
04619
04620
04621 pAttrItem = (NodeListItem *)m_AttributeList.GetHead();
04622
04623 while (pAttrItem)
04624 {
04625 if (((NodeAttribute *)pAttrItem->pNode)->CanBeAppliedToObject())
04626 {
04627 pAttrItem->pNode->CopyNode(pShadow, LASTCHILD);
04628 }
04629
04630 pAttrItem = (NodeListItem *)m_AttributeList.GetNext(pAttrItem);
04631 }
04632
04633
04634 pOp->DoInsertNewNode(pShadow, pControl, FIRSTCHILD, TRUE);
04635
04636
04637 pControl->SetPenumbraWidth(this->m_PenumbraWidth);
04638 pControl->SetOffsetX(m_OffsetX);
04639 pControl->SetOffsetY(m_OffsetY);
04640 pControl->SetGlowWidth(m_GlowWidth);
04641 pControl->SetFeatherWidth(m_FeatherWidth);
04642 pControl->SetFloorShadowAngle(m_FloorShadowAngle);
04643 pControl->SetFloorShadowHeight(m_FloorShadowHeight);
04644 pControl->SetWallShadowScale(m_Scale);
04645 pControl->SetShadowType(m_ShadowType);
04646
04647
04648 pControl->RegenerateNode(NULL, FALSE);
04649
04650 pOp->DoInvalidateNodeRegion(pControl, TRUE);
04651 }
04652
04653 if (!ok)
04654 {
04655 return NULL;
04656 }
04657
04658 return pControl;
04659 }
04660
04661 #endif // BUILDSHADOWS