ContourNodeTreeFactory Class Reference

Creates a new contour node with the given parameters. More...

#include <ncntrcnt.h>

Inheritance diagram for ContourNodeTreeFactory:

CompoundNodeTreeFactory ListItem CCObject SimpleCCObject List of all members.

Public Member Functions

 ContourNodeTreeFactory ()
 Constructor.
 ~ContourNodeTreeFactory ()
 Destructor.
NodeCompoundCreateNode (List *pList, UndoableOperation *pOp=NULL)
 Creates the node tree given the parameters & the list of nodes to address.
void SetNumberOfSteps (UINT32 Steps)
void SetWidth (UINT32 Width)
UINT32 GetNumberOfSteps ()
UINT32 GetWidth ()
void SetAttributeMap (CCAttrMap *pMap)
void SetInsetPathFlag (BOOL b)

Protected Attributes

UINT32 m_Steps
UINT32 m_Width
CCAttrMapm_pMap
BOOL m_bInsetPath

Private Member Functions

 CC_DECLARE_DYNCREATE (ContourNodeTreeFactory)

Detailed Description

Creates a new contour node with the given parameters.

Author:
David_McClarnon (Xara Group Ltd) <camelotdev@xara.com>
Date:
18/8/99

Definition at line 314 of file ncntrcnt.h.


Constructor & Destructor Documentation

ContourNodeTreeFactory::ContourNodeTreeFactory  ) 
 

Constructor.

Author:
David_McClarnon (Xara Group Ltd) <camelotdev@xara.com>
Date:
12/8/99
Parameters:
[INPUTS] 

Definition at line 2688 of file ncntrcnt.cpp.

02689 {
02690     m_Steps = 5;
02691     m_Width = 5000;
02692     m_pMap = NULL;
02693     m_bInsetPath = FALSE;
02694 }

ContourNodeTreeFactory::~ContourNodeTreeFactory  ) 
 

Destructor.

Author:
David_McClarnon (Xara Group Ltd) <camelotdev@xara.com>
Date:
12/8/99
Parameters:
[INPUTS] 

Definition at line 2706 of file ncntrcnt.cpp.

02707 {
02708     if (m_pMap)
02709     {
02710         delete m_pMap;
02711         m_pMap = NULL;
02712     }
02713 }


Member Function Documentation

ContourNodeTreeFactory::CC_DECLARE_DYNCREATE ContourNodeTreeFactory   )  [private]
 

NodeCompound * ContourNodeTreeFactory::CreateNode List pList,
UndoableOperation pOp = NULL
[virtual]
 

Creates the node tree given the parameters & the list of nodes to address.

Author:
David_McClarnon (Xara Group Ltd) <camelotdev@xara.com>
Date:
12/8/99
Parameters:
[INPUTS] 

Reimplemented from CompoundNodeTreeFactory.

Definition at line 2725 of file ncntrcnt.cpp.

02726 {
02727     ERROR2IF(pList == NULL, NULL, "List is null");
02728     ERROR2IF(pList->IsEmpty(), NULL, "List is empty");
02729 
02730     String_256 StatusString;
02731     StatusString.Load(_R(IDS_CONTOUR_CREATE_STATUS_STRING));
02732     GetApplication()->UpdateStatusBarText(&StatusString, FALSE);
02733 PORTNOTE("status","Removed UpdateStatusLineFont usage")
02734 #ifndef EXCLUDE_FROM_XARALX
02735     GetApplication()->GetpCCStatusBar()->UpdateStatusLineFont();
02736 #endif
02737     
02738     NodeContourController * pController = NULL;
02739     ALLOC_WITH_FAIL(pController, new NodeContourController, pOp);
02740 
02741     pController->SetNumberOfSteps(m_Steps);
02742     pController->SetWidth(m_Width);
02743     pController->SetInsetPathFlag(m_bInsetPath);
02744 
02745     NodeContour * pContour = NULL;
02746 
02747     NodeListItem * pItem = (NodeListItem *)pList->GetHead();
02748 
02749     CCAttrMap * pMap = m_pMap;
02750 
02751     if (!m_pMap)
02752     {
02753         if (!pItem->pNode->IS_KIND_OF(NodeBlend))
02754         {
02755             pMap = CCAttrMap::MakeAppliedAttrMap((NodeRenderableInk *)pItem->pNode);
02756         }
02757         else
02758         {
02759             pMap = CCAttrMap::MakeAppliedAttrMap((NodeRenderableInk *)
02760                 (pItem->pNode->FindFirstChild(CC_RUNTIME_CLASS(NodeRenderableInk))));
02761         }
02762 
02763         if (!pMap)
02764         {
02765             ERROR3("can't create attribute map");
02766             return NULL;
02767         }
02768     }
02769 
02770     List AttrList;
02771 
02772     pMap->BuildListOfAttributes(&AttrList);
02773     
02774     // insert the controller into the tree before the first element in the list
02775     BOOL bOK = TRUE;
02776 
02777     // send a message indicating that the light angle has changed
02778     ObjChangeFlags flgs(FALSE, FALSE, FALSE, FALSE);
02779     flgs.RegenerateNode = TRUE;
02780     ObjChangeParam OP(OBJCHANGE_FINISHED, flgs, pItem->pNode, pOp, OBJCHANGE_CALLEDBYOP);
02781 
02782 //  NodeAttribute * pAttrNode = NULL;
02783 
02784     Node * pNodeCopy = NULL;
02785 
02786     DocColour *pStartColour = NULL;
02787 
02788 //  INT32 R = 0;
02789 //  INT32 B = 0;
02790 //  INT32 G = 0;
02791 
02792     INT32 H = 0;
02793     INT32 S = 0;
02794     INT32 V = 0;
02795 
02796     BOOL bFoundColourFill = FALSE;
02797 
02798 //  BOOL bFirst = TRUE;
02799     if (pOp && pItem)
02800     {
02801         // can we do a contour to this node ?
02802         bFoundColourFill = FALSE;
02803         if (pItem->pNode->AllowOp(&OP, FALSE))
02804         {
02805             if (bOK)
02806             {
02807                 bOK = pOp->DoInsertNewNode(pController, pItem->pNode, PREV, TRUE, FALSE, FALSE, TRUE);
02808             }
02809 
02810             while (pItem && bOK)
02811             {
02812                 bOK = pOp->DoMoveNode(pItem->pNode, pController, LASTCHILD);
02813 
02814                 if (pItem->pNode->IsAnObject() && bOK)
02815                 {
02816                     bOK = pOp->DoSelectNode((NodeRenderableInk *)pItem->pNode);
02817                 }
02818                 
02819                 pItem = (NodeListItem *)pList->GetNext(pItem);
02820             }
02821 
02822             if (bOK)
02823             {
02824                 ALLOC_WITH_FAIL(pContour, new NodeContour, pOp);
02825                 
02826                 if (!pContour)
02827                 {
02828                     ERROR3("cant' create contour node");
02829                     return NULL;
02830                 }
02831                 
02832                 // apply the attribute list
02833                 pItem = (NodeListItem *)AttrList.GetHead();
02834                 
02835                 while (pItem && bOK)
02836                 {
02837                     // if (((NodeAttribute *)pItem->pNode)->CanBeAppliedToObject())
02838                     // only apply these attributes
02839                     NodeAttribute * pNodeAttr = (NodeAttribute *)pItem->pNode;
02840                     if (pNodeAttr->IsAColourFill() || pNodeAttr->IsATranspFill() ||
02841                         pNodeAttr->IsAStrokeColour() || pNodeAttr->IsAStrokeTransp() ||
02842                         pNodeAttr->IS_KIND_OF(AttrLineWidth) ||
02843                         pNodeAttr->IS_KIND_OF(AttrJoinType) ||
02844                         pNodeAttr->IS_KIND_OF(AttrFillMapping) ||
02845                         pNodeAttr->IS_KIND_OF(AttrTranspFillMapping))
02846                     {
02847                         pItem->pNode->NodeCopy(&pNodeCopy);
02848 
02849                         if (pNodeCopy)
02850                         {
02851                             if (((NodeAttribute *)pNodeCopy)->IsAColourFill() && 
02852                                 !((NodeAttribute *)pNodeCopy)->IsATranspFill())
02853                             {
02854                                 // invert the colour fill
02855                                 pStartColour = ((AttrFillGeometry *)pNodeCopy)->GetStartColour();
02856 
02857                                 if (pStartColour)
02858                                 {
02859                                     if (!pStartColour->IsTransparent())
02860                                     {
02861                                         bFoundColourFill = TRUE;
02862 
02863                                         pStartColour->GetHSVValue(&H, &S, &V);
02864 
02865                                         if (!m_bInsetPath)
02866                                         {
02867                                             V = (4 * (255 - V) / 5) + V;
02868                                             
02869                                             S = S / 5;
02870                                         }
02871                                         
02872                                         pStartColour->SetHSVValue(H,S,V);
02873                                     }
02874                                 }
02875                             }
02876                             
02877                             pNodeCopy->AttachNode(pContour, FIRSTCHILD, FALSE, FALSE);
02878                         }
02879                         else
02880                         {
02881                             bOK = FALSE;
02882                         }
02883                     }
02884                     
02885                     
02886                     pItem = (NodeListItem *)AttrList.GetNext(pItem);
02887                 }
02888                 
02889                 AttrList.DeleteAll();
02890                 
02891                 // do the winding rule
02892                 AttrWindingRule * pWinding = (AttrWindingRule *)pContour->FindFirstChild(
02893                     CC_RUNTIME_CLASS(AttrWindingRule));
02894                 
02895                 if (pWinding)
02896                 {
02897                     pWinding->Value.WindingRule = NegativeWinding;
02898                 }
02899 
02900                 if (bOK)
02901                 {
02902                     // insert the node, factoring out all the common attributes
02903                     // outer contours come before, inners after 
02904                     if (pController->GetWidth() < 0)
02905                     {
02906                         Node * pInsertNode = pController->FindFirstChild(CC_RUNTIME_CLASS(NodeRenderableInk));
02907 
02908                         if (pInsertNode)
02909                             bOK = pOp->DoInsertNewNode(pContour, pInsertNode, PREV, TRUE, FALSE, FALSE, TRUE);
02910                         else
02911                             ERROR2(NULL, "No insertion node !");
02912                     }
02913                     else
02914                     {
02915                         bOK = pOp->DoInsertNewNode(pContour, pController, LASTCHILD, TRUE, FALSE, FALSE, TRUE);
02916                     }
02917 
02918                 }
02919             }
02920 
02921             if (bOK && !bFoundColourFill)
02922             {
02923                 // does the controller node have a non-default fill ?
02924                 // right, we must choose one then
02925                 Node * pColourNode = pController->FindFirstDepthFirst();
02926 
02927                 while (pColourNode && pColourNode != pController)
02928                 {
02929                     if (pColourNode->IsAnAttribute())
02930                     {
02931                         // found it !
02932                         // clone it onto the contour node
02933                         if (((NodeAttribute *)pColourNode)->IsAColourFill() && 
02934                             !((NodeAttribute *)pColourNode)->IsATranspFill())
02935                         {
02936                             // invert the colour fill
02937                             pColourNode->NodeCopy(&pNodeCopy);
02938                             pStartColour = ((AttrFillGeometry *)pNodeCopy)->GetStartColour();
02939                             
02940                             if (pStartColour)
02941                             {
02942                                 if (!pStartColour->IsTransparent())
02943                                 {
02944                                     bFoundColourFill = TRUE;
02945                                     pStartColour->GetHSVValue(&H, &S, &V);
02946 
02947                                     if (!m_bInsetPath)
02948                                     {                                   
02949                                         V = (4 * (255 - V) / 5) + V;
02950                                     
02951                                         S = S / 5;
02952                                     }
02953                                     
02954                                     pStartColour->SetHSVValue(H,S,V);
02955                                 }
02956 
02957                                 pNodeCopy->AttachNode(pContour, FIRSTCHILD, FALSE, FALSE);
02958 
02959                                 break;
02960                             }
02961                             else
02962                             {
02963                                 delete pNodeCopy;
02964                             }
02965                         }
02966                     }
02967 
02968                     pColourNode = pColourNode->FindNextDepthFirst(pController);
02969                 }
02970             }
02971             
02972             if (bOK)
02973             {
02974                 // now, factor out all the children         
02975                 bOK = pOp->DoFactorOutCommonChildAttributes(pController, TRUE);
02976             }
02977 
02978             if (bOK)
02979             {
02980                 //  Karim 28/06/2000
02981                 //  NodeContourController should never be selected.
02982 //              pController->SetSelected(TRUE);
02983 
02984                 // check the controller width on inner bevels so it can't be greater
02985                 // than a certain amount
02986                 if (pController->GetWidth() > 0)
02987                 {
02988                     MILLIPOINT MaxWidth = ContourNodePathProcessor::GetMaxInnerContourWidth(pController);
02989                     if (pController->GetWidth() > MaxWidth)
02990                     {
02991                         pController->SetWidth(MaxWidth);
02992                     }
02993                 }
02994 
02995                 pController->RegenerateNode(pOp, FALSE);
02996             }
02997             
02998             if (bOK)
02999             {
03000                 bOK = pOp->DoInvalidateNodeRegion(pController, TRUE);
03001             }
03002         }
03003     }   
03004 
03005     AttrList.DeleteAll();
03006 
03007     if (m_bInsetPath)
03008     {
03009         // change the selection for inset path stuff
03010         pController->SetSelected(FALSE);
03011         pContour->SetSelected(TRUE);
03012     }
03013 
03014     GetApplication()->UpdateSelection();
03015 
03016     if (pMap)
03017     {
03018         delete pMap;
03019         m_pMap = NULL;
03020     }
03021 
03022     if (bOK)
03023         return pController;
03024 
03025     return NULL;
03026 }

UINT32 ContourNodeTreeFactory::GetNumberOfSteps  )  [inline]
 

Definition at line 326 of file ncntrcnt.h.

00326 { return m_Steps; }

UINT32 ContourNodeTreeFactory::GetWidth void   )  [inline]
 

Definition at line 327 of file ncntrcnt.h.

00327 { return m_Width; }

void ContourNodeTreeFactory::SetAttributeMap CCAttrMap pMap  )  [inline]
 

Definition at line 328 of file ncntrcnt.h.

00328 { m_pMap = pMap; }

void ContourNodeTreeFactory::SetInsetPathFlag BOOL  b  )  [inline]
 

Definition at line 329 of file ncntrcnt.h.

00329 { m_bInsetPath = b; }

void ContourNodeTreeFactory::SetNumberOfSteps UINT32  Steps  )  [inline]
 

Definition at line 324 of file ncntrcnt.h.

00324 { m_Steps = Steps; }

void ContourNodeTreeFactory::SetWidth UINT32  Width  )  [inline]
 

Definition at line 325 of file ncntrcnt.h.

00325 { m_Width = Width; }


Member Data Documentation

BOOL ContourNodeTreeFactory::m_bInsetPath [protected]
 

Definition at line 334 of file ncntrcnt.h.

CCAttrMap* ContourNodeTreeFactory::m_pMap [protected]
 

Definition at line 333 of file ncntrcnt.h.

UINT32 ContourNodeTreeFactory::m_Steps [protected]
 

Definition at line 331 of file ncntrcnt.h.

UINT32 ContourNodeTreeFactory::m_Width [protected]
 

Definition at line 332 of file ncntrcnt.h.


The documentation for this class was generated from the following files:
Generated on Sat Nov 10 03:53:07 2007 for Camelot by  doxygen 1.4.4