#include <fillramp.h>
Inheritance diagram for FillRamp:
Public Member Functions | |
void | GetSelectionState (BOOL *SelState) const |
Record the selection state of all the ramp blobs in this array. | |
UINT32 | CountSelBlobs () const |
Simply count all the selected items in this list. | |
INT32 | GetSelectedIndex () const |
Return the index of the first selected item in this list. The index is adjusted by FILLRAMP_INDEXBASE i.e. this constant value is always added to an index to give the range [FILLRAMP_INDEXBASE...FILLRAMP_INDEXBASE+n-1]. This is done so one can distinguish between indexes for fill geometry end points (usually 0..7 or thereabouts) and the fill ramp blobs. | |
BOOL | GetIndexRange (UINT32 *pFirst, UINT32 *pLast) const |
Return the index of the first and last entries in this list. As the list indexes are biased by an unknown value, at least unknown to everyone but the author, one needs to use this class function to find out the values of the first and last indexes. All I'll tell you is that they behaviour linearly between the two extreems. | |
BOOL | IsSelected (UINT32 index) const |
Find out whether this ramp index is selected or not. | |
void | DeselectAll () const |
Deselect all selection states in this fill ramp. | |
FillControl | RotateSelRight (BOOL StartPointSelected, BOOL EndPointSelected, FillControl &OldSelectedBlob) const |
Roll the selection state of the items in the list to the right. That equates to rolling the selection down the list by one element. | |
BOOL | RotateSelLeft (BOOL StartPointSelected, BOOL EndPointSelected, FillControl &OldSelectedBlob) const |
Roll the selection state of the items in the list to the left. That equates to rolling the selection up the list by one element. | |
void | SetSelState (UINT32 index, INT32 state) |
Sets the state of a fill ramp blob. | |
UINT32 | SetPosition (UINT32 index, float pos) |
Sets the position of an existing ramp item identified by index. As we keep our list of items ordered on position, the fact that it is being changed will likely result in a shuffling of the item in the list. Hence we return a new index (which obviously may or may not be the same as index). Those who are keeping up amoung you might even be able to spot when an item shuffles by looking at the input and ouput index values. | |
UINT32 | HitBlob (FillGeometryAttribute *pGeom, DocCoord &ClickPos) const |
Check to see if a ramp item was hit by this click. If so return yes. We also set and internal pointer on the result of this check, which can be used to make edits. | |
DocCoord | GetGeometryCoord (FillGeometryAttribute *pGeom, UINT32 index) const |
Find the absolute coordinate of Blob[index]. The start coordinate will be returned if index is out of range. | |
void | RenderRampBlobs (FillGeometryAttribute *pGeom, RenderRegion *pRender, BOOL *pSelState=NULL) const |
Render the fill blobs in their positions as they appear on the geometry this fill ramp is associated with. We simply ask the geometry where they are and render appropriately. | |
void | RenderSelectedBlob (FillGeometryAttribute *pGeom, RenderRegion *pRender) |
void | SortRamp () |
Ensures all positions of all items in the list are in numerical order. | |
RampItem * | GetValidIndexedItem (UINT32 index) const |
Find the i'th item in this fill ramp. The index is the normal biased index passed into us from the external world. We convert the index and perform some error checking on it before we attempt to find the relevant item. | |
void | Blend (FillGeometryAttribute *pNewAttr, BlendAttrParam *pBlendParam, FillGeometryAttribute *pOtherFill, BOOL notInvert=FALSE) |
Blends mutistage fill ramps. Well actually its support functions do, but this one works out which blending case we are doing. | |
Protected Member Functions | |
RampItem * | GetIndexedItem (INT32 index) const |
Find the i'th item in this fill ramp. | |
UINT32 | InsertNewItem (RampItem *pItem) |
Adds pNewItem to the growing list. | |
Private Member Functions | |
RampItem * | FindInsertPosition (float pos, INT32 *pInsert, UINT32 *index) const |
Finds an insert context given a position. The idea is, if you have a new record to add, it needs to be added to the list after all items with a position less than pos. This func finds the insert position and returns a value indicating before or after. The index of your new item will depend on the pInsert value. If 0, then the new index will be (*pIndex) otherwise its (*pIndex)+1;. | |
UINT32 | ShuffleItem (RampItem *pItem, UINT32 index) |
ShuffleItem checks the validity of pItem. If the item's position in the list is invalid, it will be shuffled into a valid position. This needs to be done when the position parameter is changed, as we keep an ascending order of item positions. | |
void | DoOneToOneBlend (FillGeometryAttribute *pNewAttr, BlendAttrParam *pBlendParam, FillRamp *OtherRamp, BOOL notInvert) |
Blends mutistage fill ramps. This function blends equal numbers of blobs. | |
void | DoNoneToManyBlend (FillGeometryAttribute *pNewAttr, BlendAttrParam *pBlendParam, FillRamp *OtherRamp, BOOL notInvert) |
Blends mutistage fill ramps. This function blends none to many blobs. | |
void | DoManyToNoneBlend (FillGeometryAttribute *pNewAttr, BlendAttrParam *pBlendParam, FillGeometryAttribute *pOtherFill, BOOL notInvert) |
Blends mutistage fill ramps. This function blends many to no none fill blobs. | |
void | DoManyToManyBlend (FillGeometryAttribute *pNewAttr, BlendAttrParam *pBlendParam, FillRamp *OtherRamp, BOOL notInvert) |
Blends mutistage fill ramps. This function handles the many to many case. |
Definition at line 241 of file fillramp.h.
|
Blends mutistage fill ramps. Well actually its support functions do, but this one works out which blending case we are doing.
Definition at line 520 of file fillramp.cpp. 00521 { 00522 //ERRORIF (!pOtherFill, "Dodgy entry params!", NULL); 00523 00524 FillRamp* OtherRamp = pOtherFill->GetColourRamp (); 00525 00526 // if neither contains a fill ramp - then return 00527 if ((this == NULL) && (OtherRamp == NULL)) 00528 { 00529 return; 00530 } 00531 00532 // ok we've got at least one fillramp - so proceed .... 00533 // now decide the type of blending that we need to do .... 00534 00535 enum MappingType { MT_ONETOONE, // equal numbers of fill blobs 00536 MT_NONETOMANY, // no fill blobs to many 00537 MT_MANYTONONE, // many fill blobs to none 00538 MT_MANYTOMANY, // many fills blobs to many fills blobs 00539 // (but different numbers of fill blobs) 00540 //MT_MANYTOMANYLESS, // less fill blobs to more fill blobs 00541 //MT_MANYTOMANYMORE, // more fill blobs to less fill blobs 00542 MT_NONE }; // sensible default 00543 00544 MappingType FunctionMapper = MT_NONE; 00545 00546 if (this == NULL) 00547 { 00548 if (OtherRamp != NULL) 00549 { 00550 FunctionMapper = MT_NONETOMANY; 00551 } 00552 // else - nothing (this is impossible) 00553 } 00554 else if (OtherRamp == NULL) 00555 { 00556 if (this != NULL) 00557 { 00558 FunctionMapper = MT_MANYTONONE; 00559 } 00560 // else - nothing (this is impossible) 00561 } 00562 else 00563 { 00564 if (GetCount () == OtherRamp->GetCount ()) 00565 { 00566 FunctionMapper = MT_ONETOONE; 00567 } 00568 else 00569 { 00570 // were in the dreaded many-to-many case .... 00571 00572 FunctionMapper = MT_MANYTOMANY; 00573 } 00574 } 00575 00576 // invoke the appropriate support function .... 00577 00578 switch (FunctionMapper) 00579 { 00580 case MT_ONETOONE: 00581 { 00582 DoOneToOneBlend (pNewAttr, pBlendParam, OtherRamp, notInvert); 00583 } 00584 break; 00585 case MT_NONETOMANY: 00586 { 00587 DoNoneToManyBlend (pNewAttr, pBlendParam, OtherRamp, notInvert); 00588 } 00589 break; 00590 case MT_MANYTONONE: 00591 { 00592 DoManyToNoneBlend (pNewAttr, pBlendParam, pOtherFill, notInvert); 00593 } 00594 break; 00595 case MT_MANYTOMANY: 00596 { 00597 DoManyToManyBlend (pNewAttr, pBlendParam, OtherRamp, notInvert); 00598 } 00599 break; 00600 default: 00601 return; // um ..... 00602 break; 00603 } 00604 }
|
|
Simply count all the selected items in this list.
Definition at line 1168 of file fillramp.cpp. 01169 { 01170 // perform a ROL on the selection in this fill ramp 01171 UINT32 count=0; 01172 RampItem *pItem = (RampItem*)GetHead(); 01173 while (pItem) 01174 { 01175 count += ((pItem->GetSelState()==TRUE) ? 1 : 0); 01176 pItem = (RampItem*)GetNext(pItem); 01177 } 01178 return count; 01179 }
|
|
Deselect all selection states in this fill ramp.
Definition at line 443 of file fillramp.cpp. 00444 { 00445 RampItem *pItem = (RampItem*)GetHead(); 00446 while (pItem) 00447 { 00448 pItem->SetSelState(FALSE); 00449 pItem = (RampItem*)GetNext(pItem); 00450 } 00451 }
|
|
Blends mutistage fill ramps. This function handles the many to many case.
Definition at line 842 of file fillramp.cpp. 00843 { 00844 // find what point along the blend we are at 00845 double Ratio = pBlendParam->GetBlendRatio (); 00846 00847 DocColour BlendedColour; 00848 ColourContext *cc = ColourManager::GetColourContext (COLOURMODEL_RGBT); 00849 00850 RampItem* pItem = (RampItem*) GetHead (); 00851 RampItem* pOtherItem = (RampItem*) OtherRamp->GetHead (); 00852 00853 ColourRamp* NewColourRamp1 = new ColourRamp (); 00854 *NewColourRamp1 = *((ColourRamp*) this); 00855 ColourRamp* NewColourRamp2 = new ColourRamp (); 00856 *NewColourRamp2 = *((ColourRamp*) OtherRamp); 00857 ColourRamp* NewColourRamp3 = new ColourRamp (); 00858 00859 ColRampItem* pFirstItem = (ColRampItem*) GetHead (); 00860 ColRampItem* pSecondItem = (ColRampItem*) OtherRamp->GetHead (); 00861 00862 DocColour* StartCol = NULL;//pNewAttr->GetStartColour (); 00863 DocColour* EndCol = NULL;//&pFirstItem->GetColour (); 00864 00865 DocColour tempStartCol; 00866 DocColour tempEndCol; // these avoid taking the address of a temporary 00867 00868 // now insert the first blobs into the second .... 00869 00870 float PrevPos = -1, NextPos = -1; 00871 00872 while (pSecondItem) 00873 { 00874 ColRampItem* pNewItem = new ColRampItem (*pSecondItem); 00875 00876 NewColourRamp1->InsertNewItem (pNewItem); 00877 00878 ColRampItem* pPrevItem = (ColRampItem*) NewColourRamp1->GetPrev (pNewItem); 00879 ColRampItem* pNextItem = (ColRampItem*) NewColourRamp1->GetNext (pNewItem); 00880 00881 if (!pPrevItem) 00882 { 00883 StartCol = pNewAttr->GetStartColour (); 00884 PrevPos = 0.0; 00885 } 00886 else 00887 { 00888 tempStartCol = pPrevItem->GetColour (); 00889 StartCol = &tempStartCol; 00890 PrevPos = pPrevItem->GetPosition (); 00891 } 00892 00893 if (!pNextItem) 00894 { 00895 EndCol = pNewAttr->GetEndColour (); 00896 NextPos = 1.0; 00897 } 00898 else 00899 { 00900 tempEndCol = pNextItem->GetColour (); 00901 EndCol = &tempEndCol; 00902 NextPos = pNextItem->GetPosition (); 00903 } 00904 00905 BlendedColour.Mix ( 00906 StartCol, // start blend colour 00907 EndCol, // end blend colour 00908 NextPos - PrevPos, // the blend ratio 00909 cc // RGB space please 00910 ); 00911 00912 pNewItem->SetColour (&BlendedColour); 00913 00914 pSecondItem = (ColRampItem*) GetNext (pSecondItem); 00915 } 00916 00917 pFirstItem = (ColRampItem*) GetHead (); 00918 pSecondItem = (ColRampItem*) OtherRamp->GetHead (); 00919 00920 // now insert the first blobs into the second .... 00921 00922 PrevPos = -1, NextPos = -1; 00923 00924 while (pFirstItem) 00925 { 00926 ColRampItem* pNewItem = new ColRampItem (*pFirstItem); 00927 00928 NewColourRamp2->InsertNewItem (pNewItem); 00929 00930 ColRampItem* pPrevItem = (ColRampItem*) NewColourRamp2->GetPrev (pNewItem); 00931 ColRampItem* pNextItem = (ColRampItem*) NewColourRamp2->GetNext (pNewItem); 00932 00933 if (!pPrevItem) 00934 { 00935 StartCol = pNewAttr->GetStartColour (); 00936 PrevPos = 0.0; 00937 } 00938 else 00939 { 00940 tempStartCol = pPrevItem->GetColour (); 00941 StartCol = &tempStartCol; 00942 PrevPos = pPrevItem->GetPosition (); 00943 } 00944 00945 if (!pNextItem) 00946 { 00947 EndCol = pNewAttr->GetEndColour (); 00948 NextPos = 1.0; 00949 } 00950 else 00951 { 00952 tempEndCol = pNextItem->GetColour (); 00953 EndCol = &tempEndCol; 00954 NextPos = pNextItem->GetPosition (); 00955 } 00956 00957 BlendedColour.Mix ( 00958 StartCol, // start blend colour 00959 EndCol, // end blend colour 00960 NextPos - PrevPos, // the blend ratio 00961 cc // RGB space please 00962 ); 00963 00964 pNewItem->SetColour (&BlendedColour); 00965 00966 pFirstItem = (ColRampItem*) GetNext (pFirstItem); 00967 } 00968 00969 // simply interpolate between the respective colour ramp blobs .... 00970 00971 pItem = (RampItem*) NewColourRamp1->GetHead (); 00972 pOtherItem = (RampItem*) NewColourRamp2->GetHead (); 00973 00974 while (pItem && pOtherItem) 00975 { 00976 ColRampItem* pNewItem = new ColRampItem (*((ColRampItem*) pItem)); 00977 00978 NewColourRamp3->InsertNewItem (pNewItem); 00979 00980 tempStartCol = ((ColRampItem*) pItem->GetItem ())->GetColour (); 00981 tempEndCol = ((ColRampItem*) pOtherItem->GetItem ())->GetColour (); 00982 BlendedColour.Mix ( 00983 &tempStartCol, // start blend colour 00984 &tempEndCol, // end blend colour 00985 Ratio, // the blend ratio 00986 cc // RGB space please 00987 ); 00988 00989 pNewItem->SetColour (&BlendedColour); 00990 00991 pItem = (RampItem*) NewColourRamp1->GetNext (pItem); 00992 pOtherItem = (RampItem*) NewColourRamp2->GetNext (pOtherItem); 00993 } 00994 pNewAttr->SetColourRamp (NewColourRamp3); 00995 00996 delete (NewColourRamp1); 00997 delete (NewColourRamp2); 00998 delete (NewColourRamp3); 00999 }
|
|
Blends mutistage fill ramps. This function blends many to no none fill blobs.
Definition at line 744 of file fillramp.cpp. 00745 { 00746 // find what point along the blend we are at 00747 double Ratio = 1; 00748 00749 if (!notInvert) 00750 { 00751 Ratio = 1 - pBlendParam->GetBlendRatio (); 00752 } 00753 else 00754 { 00755 Ratio = pBlendParam->GetBlendRatio (); 00756 } 00757 00758 DocColour* StartCol = pOtherFill->GetStartColour ();//pNewAttr->GetStartColour (); 00759 DocColour* EndCol = pOtherFill->GetEndColour ();//pNewAttr->GetEndColour (); 00760 00761 if (!EndCol) 00762 { 00763 EndCol = StartCol; 00764 } 00765 00766 if ((EndCol == NULL) && (StartCol == NULL)) 00767 { 00768 // do nothing 00769 return; 00770 } 00771 00772 ColourRamp* NewColourRamp = new ColourRamp (); 00773 00774 DocColour BlendedColour; 00775 DocColour BlendedColour2; 00776 00777 ColourContext *cc = ColourManager::GetColourContext (COLOURMODEL_RGBT); 00778 00779 if (NewColourRamp) 00780 { 00781 ColRampItem* pItem = (ColRampItem*) GetHead (); 00782 00783 while (pItem) 00784 { 00785 ColRampItem* pNewItem = new ColRampItem (*pItem); 00786 00787 // first mix the two endpoints based upon the other fillramp blob positions .... 00788 00789 BlendedColour.Mix ( 00790 StartCol, // start blend colour 00791 EndCol, // end blend colour 00792 ((ColRampItem*) pItem->GetItem ())->GetPosition (), // the blend ratio 00793 cc // RGB space please 00794 ); 00795 00796 // then mix this new colour with the other fillramp blob colours .... 00797 DocColour EndColour = ((ColRampItem*) pItem->GetItem ())->GetColour (); 00798 BlendedColour2.Mix ( 00799 &BlendedColour, 00800 &EndColour, 00801 Ratio, // the blend ratio 00802 cc // RGB space please 00803 ); 00804 00805 pNewItem->SetColour (&BlendedColour2); 00806 00807 NewColourRamp->InsertNewItem (pNewItem); 00808 00809 pItem = (ColRampItem*) GetNext (pItem); 00810 } 00811 pNewAttr->SetColourRamp (NewColourRamp); 00812 } 00813 00814 delete (NewColourRamp); 00815 }
|
|
Blends mutistage fill ramps. This function blends none to many blobs.
Definition at line 666 of file fillramp.cpp. 00667 { 00668 // find what point along the blend we are at 00669 double Ratio = pBlendParam->GetBlendRatio (); 00670 00671 DocColour* StartCol = pNewAttr->GetStartColour (); 00672 DocColour* EndCol = pNewAttr->GetEndColour (); 00673 00674 // first see if weve got something that we can safely blend with 00675 // if either colour is NULL, then forget it; just set the colour ramp to NULL .... 00676 00677 if (!((StartCol == NULL) && (EndCol == NULL))) 00678 { 00679 ColourRamp* NewColourRamp = new ColourRamp (); 00680 00681 DocColour BlendedColour; 00682 DocColour BlendedColour2; 00683 00684 ColourContext *cc = ColourManager::GetColourContext (COLOURMODEL_RGBT); 00685 00686 if (NewColourRamp) 00687 { 00688 ColRampItem* pOtherItem = (ColRampItem*) OtherRamp->GetHead (); 00689 00690 while (pOtherItem) 00691 { 00692 ColRampItem* pNewItem = new ColRampItem (*pOtherItem); 00693 00694 // first mix the two endpoints based upon the other fillramp blob positions .... 00695 00696 BlendedColour.Mix ( 00697 StartCol, // start blend colour 00698 EndCol, // end blend colour 00699 ((ColRampItem*) pOtherItem->GetItem ())->GetPosition (), // the blend ratio 00700 cc // RGB space please 00701 ); 00702 00703 // then mix this new colour with the other fillramp blob colours .... 00704 00705 DocColour EndColour = ((ColRampItem*) pOtherItem->GetItem ())->GetColour (); 00706 BlendedColour2.Mix ( 00707 &BlendedColour, 00708 &EndColour, 00709 Ratio, // the blend ratio 00710 cc // RGB space please 00711 ); 00712 00713 pNewItem->SetColour (&BlendedColour2); 00714 00715 NewColourRamp->InsertNewItem (pNewItem); 00716 00717 pOtherItem = (ColRampItem*) OtherRamp->GetNext (pOtherItem); 00718 } 00719 pNewAttr->SetColourRamp (NewColourRamp); 00720 } 00721 00722 delete (NewColourRamp); 00723 } 00724 else 00725 { 00726 pNewAttr->SetColourRamp (NULL); 00727 } 00728 }
|
|
Blends mutistage fill ramps. This function blends equal numbers of blobs.
Definition at line 620 of file fillramp.cpp. 00621 { 00622 // find what point along the blend we are at 00623 double Ratio = pBlendParam->GetBlendRatio (); 00624 00625 RampItem* pItem = (RampItem*) GetHead (); 00626 RampItem* pOtherItem = (RampItem*) OtherRamp->GetHead (); 00627 00628 // simply interpolate between the respective colour ramp blobs .... 00629 00630 DocColour BlendedColour; 00631 00632 ColourContext *cc = ColourManager::GetColourContext (COLOURMODEL_RGBT); 00633 00634 while (pItem && pOtherItem) 00635 { 00636 DocColour StartColour = ((ColRampItem*) pItem->GetItem ())->GetColour (); 00637 DocColour EndColour = ((ColRampItem*) pOtherItem->GetItem ())->GetColour (); 00638 BlendedColour.Mix ( 00639 &StartColour, // start blend colour 00640 &EndColour, // end blend colour 00641 Ratio, // the blend ratio 00642 cc // RGB space please 00643 ); 00644 00645 ((ColRampItem*) pItem->GetItem ())->SetColour (&BlendedColour); 00646 00647 pItem = (RampItem*) GetNext (pItem); 00648 pOtherItem = (RampItem*) OtherRamp->GetNext (pOtherItem); 00649 } 00650 }
|
|
Finds an insert context given a position. The idea is, if you have a new record to add, it needs to be added to the list after all items with a position less than pos. This func finds the insert position and returns a value indicating before or after. The index of your new item will depend on the pInsert value. If 0, then the new index will be (*pIndex) otherwise its (*pIndex)+1;.
Definition at line 372 of file fillramp.cpp. 00373 { 00374 ERROR3IF(pInsert==NULL, "NULL insert pointer passed to FillRamp::FindInsertPosition()"); 00375 00376 // need to search for 00377 RampItem *pLastItem=NULL, *pItem = (RampItem*)GetHead(); 00378 (*pInsert) = 1; 00379 (*pIndex) = FILLRAMP_INDEXBASE-1; 00380 00381 while (pItem) 00382 { 00383 (*pIndex)++; 00384 if (pItem->GetPosition() > pos) 00385 { 00386 (*pInsert) = 0; 00387 return pItem; 00388 } 00389 pLastItem = pItem; 00390 pItem = (RampItem*)GetNext(pItem); 00391 } 00392 return pLastItem; 00393 }
|
|
Find the absolute coordinate of Blob[index]. The start coordinate will be returned if index is out of range.
Definition at line 1458 of file fillramp.cpp. 01459 { 01460 if (pGeom==NULL) 01461 { 01462 ERROR3("NULL geometry passed to FillRamp::GetGeometryCoord"); 01463 return DocCoord(0,0); 01464 } 01465 01466 RampItem* pItem = GetValidIndexedItem(index); 01467 if (pItem==NULL) 01468 return DocCoord(0,0); 01469 01470 return pGeom->GetGeometryCoord(pItem->GetPosition()); 01471 }
|
|
Find the i'th item in this fill ramp.
Definition at line 1356 of file fillramp.cpp. 01357 { 01358 if (index>=0) 01359 { 01360 RampItem *pItem = (RampItem*)GetHead(); 01361 while (pItem) 01362 { 01363 if (index==0) 01364 return pItem; 01365 index--; 01366 pItem = (RampItem*)GetNext(pItem); 01367 } 01368 } 01369 return NULL; 01370 }
|
|
Return the index of the first and last entries in this list. As the list indexes are biased by an unknown value, at least unknown to everyone but the author, one needs to use this class function to find out the values of the first and last indexes. All I'll tell you is that they behaviour linearly between the two extreems.
Definition at line 1234 of file fillramp.cpp. 01235 { 01236 INT32 c=GetCount(); 01237 if (pFirst!=NULL) 01238 *pFirst = FILLRAMP_INDEXBASE; 01239 if (pLast!=NULL) 01240 *pLast = FILLRAMP_INDEXBASE+c-1; 01241 return (c>0); 01242 }
|
|
Return the index of the first selected item in this list. The index is adjusted by FILLRAMP_INDEXBASE i.e. this constant value is always added to an index to give the range [FILLRAMP_INDEXBASE...FILLRAMP_INDEXBASE+n-1]. This is done so one can distinguish between indexes for fill geometry end points (usually 0..7 or thereabouts) and the fill ramp blobs.
Definition at line 1200 of file fillramp.cpp. 01201 { 01202 UINT32 index=FILLRAMP_INDEXBASE; 01203 RampItem *pItem = (RampItem*)GetHead(); 01204 while (pItem) 01205 { 01206 if (pItem->GetSelState()) 01207 return index; 01208 index++; 01209 pItem = (RampItem*)GetNext(pItem); 01210 } 01211 return -1; 01212 }
|
|
Record the selection state of all the ramp blobs in this array.
Definition at line 1312 of file fillramp.cpp. 01313 { 01314 RampItem *pItem = (RampItem*)GetHead(); 01315 while (pItem) 01316 { 01317 *SelState++ = (pItem->GetSelState()); 01318 pItem = (RampItem*)GetNext(pItem); 01319 } 01320 }
|
|
Find the i'th item in this fill ramp. The index is the normal biased index passed into us from the external world. We convert the index and perform some error checking on it before we attempt to find the relevant item.
Definition at line 1386 of file fillramp.cpp. 01387 { 01388 INT32 i = ((INT32)(index)) - FILLRAMP_INDEXBASE; 01389 if (i<0) 01390 { 01391 ERROR3("Illegal index passed to FillRamp::GetValidIndexedItem()"); 01392 return NULL; 01393 } 01394 01395 RampItem *pItem = GetIndexedItem(i); 01396 if (pItem==NULL) 01397 { 01398 ERROR3("Index out of range in FillRamp::GetValidIndexedItem()"); 01399 return NULL; 01400 } 01401 01402 return pItem; 01403 }
|
|
Check to see if a ramp item was hit by this click. If so return yes. We also set and internal pointer on the result of this check, which can be used to make edits.
Definition at line 1271 of file fillramp.cpp. 01272 { 01273 DocRect BlobRect; 01274 DocCoord point; 01275 float pos; 01276 01277 if (pAttrValue!=NULL) 01278 { 01279 // search from the last first 01280 RampItem *pItem = (RampItem*)GetHead(); 01281 UINT32 i = FILLRAMP_INDEXBASE; 01282 // find a suitable blob rect around this point 01283 (GetApplication()->GetBlobManager())->GetBlobRect(ClickPos, &BlobRect, TRUE); 01284 while (pItem) 01285 { 01286 pos = pItem->GetPosition(); 01287 point = pAttrValue->GetGeometryCoord(pos); 01288 // See if the Click Position is within the rectangle 01289 if ( BlobRect.ContainsCoord(point) ) 01290 return i; 01291 // otherwise continue onwards 01292 i++; 01293 pItem = (RampItem*)GetNext(pItem); 01294 } 01295 } 01296 // nothing was under this click position 01297 return FILLRAMP_ILLEGALINDEX; 01298 }
|
|
Adds pNewItem to the growing list.
Definition at line 409 of file fillramp.cpp. 00410 { 00411 ERROR3IF(pNewItem==NULL, "NULL pointer passed to FillRamp::InsertNewItem"); 00412 00413 // keep an ordered list on pos please! 00414 INT32 insert; 00415 UINT32 index; 00416 RampItem *pContext = FindInsertPosition(pNewItem->GetPosition(),&insert,&index); 00417 if (pContext==NULL) 00418 { 00419 AddTail(pNewItem); 00420 return FILLRAMP_INDEXBASE; 00421 } 00422 if (insert==0) 00423 { 00424 InsertBefore(pContext, pNewItem); 00425 return index; 00426 } 00427 InsertAfter(pContext, pNewItem); 00428 return (index+1); 00429 }
|
|
Find out whether this ramp index is selected or not.
Definition at line 1334 of file fillramp.cpp. 01335 { 01336 RampItem* pItem = GetValidIndexedItem(index); 01337 if (pItem) 01338 return pItem->IsSelected(); 01339 01340 return FALSE; 01341 }
|
|
Render the fill blobs in their positions as they appear on the geometry this fill ramp is associated with. We simply ask the geometry where they are and render appropriately.
Definition at line 1491 of file fillramp.cpp. 01492 { 01493 BOOL Selected; 01494 DocCoord coord; 01495 RampItem* pItem = (RampItem*)GetHead(); 01496 INT32 i=0; 01497 while (pItem!=NULL) 01498 { 01499 if (pSelState!=NULL) 01500 Selected=pSelState[i]; 01501 else 01502 Selected=pItem->GetSelState(); 01503 01504 coord = pGeom->GetGeometryCoord(pItem->GetPosition()); 01505 01506 // Draw a blob at the end point 01507 if (Selected) 01508 { 01509 // Draw Selected Blob 01510 pRender->SetLineColour (COLOUR_SELECTEDBLOB); 01511 pRender->SetFillColour (COLOUR_SELECTEDBLOB); 01512 pRender->DrawBlob (coord, BT_MSTAGEFILLSELECTED); 01513 } 01514 else 01515 { 01516 // Draw Unselected Blob 01517 pRender->SetLineColour (COLOUR_NONE); 01518 pRender->SetFillColour (COLOUR_BLUE); 01519 pRender->DrawBlob (coord, BT_MSTAGEFILLUNSELECTED); 01520 } 01521 01522 i++; 01523 pItem = (RampItem*)GetNext(pItem); 01524 } 01525 }
|
|
Definition at line 1527 of file fillramp.cpp. 01528 { 01529 DocCoord coord; 01530 01531 RampItem* pItem = (RampItem*) GetHead(); 01532 01533 while (pItem) 01534 { 01535 if (pItem->IsSelected ()) 01536 { 01537 coord = pGeom->GetGeometryCoord(pItem->GetPosition()); 01538 01539 pRender->SetLineColour (COLOUR_SELECTEDBLOB); 01540 pRender->SetFillColour (COLOUR_SELECTEDBLOB); 01541 pRender->DrawBlob (coord, BT_MSTAGEFILLSELECTED); 01542 01543 return; 01544 } 01545 pItem = (RampItem*)GetNext(pItem); 01546 } 01547 }
|
|
Roll the selection state of the items in the list to the left. That equates to rolling the selection up the list by one element.
Definition at line 1086 of file fillramp.cpp. 01087 { 01088 if (StartPointSelected) 01089 { 01090 OldSelectedBlob = FILLCONTROL_STARTPOINT; 01091 return (FILLCONTROL_ENDPOINT); 01092 } 01093 01094 if (EndPointSelected) 01095 { 01096 // select first blob in list .... 01097 RampItem *pItem = (RampItem*) GetTail(); 01098 pItem->SetSelState (TRUE); 01099 01100 FillControl Ret = GetSelectedIndex (); 01101 pItem->SetSelState (FALSE); 01102 01103 OldSelectedBlob = FILLCONTROL_NULL; 01104 01105 return (Ret); 01106 } 01107 01108 // if we haven't returned yet, then the selection will within our ramp .... 01109 01110 RampItem* pItem = (RampItem*) GetTail(); 01111 RampItem* pSelectedBlob = NULL; 01112 while (pItem) 01113 { 01114 if (pItem->IsSelected ()) 01115 { 01116 pSelectedBlob = pItem; 01117 break; 01118 } 01119 pItem = (RampItem*)GetPrev(pItem); 01120 } 01121 01122 RampItem* pSelNext = (RampItem*) GetPrev (pSelectedBlob); 01123 01124 if (pSelNext != NULL) 01125 { 01126 OldSelectedBlob = GetSelectedIndex (); 01127 pSelectedBlob->SetSelState (FALSE); 01128 pSelNext->SetSelState (TRUE); 01129 01130 FillControl Ret = GetSelectedIndex (); 01131 pSelNext->SetSelState (FALSE); 01132 01133 return (Ret); 01134 } 01135 else 01136 { 01137 OldSelectedBlob = GetSelectedIndex (); 01138 pSelectedBlob->SetSelState (FALSE); 01139 return (FILLCONTROL_STARTPOINT); 01140 } 01141 01142 /* perform a ROL on the selection in this fill ramp 01143 BOOL Temp; 01144 RampItem *pItem = (RampItem*)GetTail(); 01145 while (pItem) 01146 { 01147 Temp = pItem->GetSelState(); 01148 pItem->SetSelState(RollIn); 01149 RollIn = Temp; 01150 pItem = (RampItem*)GetPrev(pItem); 01151 } 01152 return RollIn;*/ 01153 }
|
|
Roll the selection state of the items in the list to the right. That equates to rolling the selection down the list by one element.
Definition at line 1016 of file fillramp.cpp. 01017 { 01018 if (StartPointSelected) 01019 { 01020 // select first blob in list .... 01021 RampItem *pItem = (RampItem*) GetHead(); 01022 pItem->SetSelState (TRUE); 01023 01024 FillControl Ret = GetSelectedIndex (); 01025 pItem->SetSelState (FALSE); 01026 01027 OldSelectedBlob = FILLCONTROL_NULL; 01028 01029 return (Ret); 01030 } 01031 01032 if (EndPointSelected) 01033 { 01034 OldSelectedBlob = FILLCONTROL_ENDPOINT; 01035 return (FILLCONTROL_STARTPOINT); 01036 } 01037 01038 // if we haven't returned yet, then the selection will within our ramp .... 01039 01040 RampItem* pItem = (RampItem*) GetHead(); 01041 RampItem* pSelectedBlob = NULL; 01042 while (pItem) 01043 { 01044 if (pItem->IsSelected ()) 01045 { 01046 pSelectedBlob = pItem; 01047 break; 01048 } 01049 pItem = (RampItem*)GetNext(pItem); 01050 } 01051 01052 RampItem* pSelNext = (RampItem*) GetNext (pSelectedBlob); 01053 01054 if (pSelNext != NULL) 01055 { 01056 OldSelectedBlob = GetSelectedIndex (); 01057 pSelectedBlob->SetSelState (FALSE); 01058 pSelNext->SetSelState (TRUE); 01059 01060 FillControl Ret = GetSelectedIndex (); 01061 pSelNext->SetSelState (FALSE); 01062 01063 return (Ret); 01064 } 01065 else 01066 { 01067 OldSelectedBlob = GetSelectedIndex (); 01068 pSelectedBlob->SetSelState (FALSE); 01069 return (FILLCONTROL_ENDPOINT); 01070 } 01071 }
|
|
Sets the position of an existing ramp item identified by index. As we keep our list of items ordered on position, the fact that it is being changed will likely result in a shuffling of the item in the list. Hence we return a new index (which obviously may or may not be the same as index). Those who are keeping up amoung you might even be able to spot when an item shuffles by looking at the input and ouput index values.
Definition at line 1570 of file fillramp.cpp. 01571 { 01572 RampItem *pItem = GetValidIndexedItem(index); 01573 if (pItem==NULL) 01574 return FILLRAMP_ILLEGALINDEX; 01575 01576 pItem->SetPosition(pos); 01577 //SortRamp (TRUE); 01578 index = ShuffleItem(pItem,index); 01579 return index; 01580 }
|
|
Sets the state of a fill ramp blob.
Definition at line 1420 of file fillramp.cpp. 01421 { 01422 INT32 i = ((INT32)(index)) - FILLRAMP_INDEXBASE; 01423 ERROR3IF(i<0, "Illegal index passed to FillRamp::ChangeBlobState()"); 01424 if (i>=0) 01425 { 01426 RampItem* pItem = GetIndexedItem(i); 01427 if (pItem) 01428 { 01429 BOOL CurrState = pItem->GetSelState(); 01430 switch (NewState) 01431 { 01432 case 0: CurrState=FALSE; 01433 break; 01434 case 1: CurrState=TRUE; 01435 break; 01436 case 2: CurrState=!CurrState; 01437 } 01438 pItem->SetSelState(CurrState); 01439 } 01440 } 01441 }
|
|
ShuffleItem checks the validity of pItem. If the item's position in the list is invalid, it will be shuffled into a valid position. This needs to be done when the position parameter is changed, as we keep an ascending order of item positions.
Definition at line 1599 of file fillramp.cpp. 01600 { 01601 float curpos = pItem->GetPosition(); 01602 RampItem *pPrevContext = (RampItem*)GetPrev(pItem); 01603 RampItem *pNextContext = (RampItem*)GetNext(pItem); 01604 RampItem *pContext = NULL; 01605 01606 if (pPrevContext == pNextContext) // I don't know why this occurs, BUT it does sometimes! 01607 { 01608 pContext = pPrevContext; 01609 } 01610 else 01611 { 01612 if ((pPrevContext != NULL) && (pNextContext == NULL)) 01613 { 01614 pContext = pPrevContext; 01615 } 01616 else if ((pNextContext != NULL) && (pPrevContext == NULL)) 01617 { 01618 pContext = NULL; 01619 } 01620 else 01621 { 01622 float prevCurpos = pPrevContext->GetPosition (); 01623 float nextCurpos = pNextContext->GetPosition (); 01624 01625 float diffPrev = curpos - prevCurpos; 01626 if (diffPrev < 0) diffPrev = -diffPrev; 01627 float diffNext = curpos - nextCurpos; 01628 if (diffNext < 0) diffNext = -diffNext; 01629 01630 if (diffPrev < diffNext) 01631 { 01632 pContext = pPrevContext; 01633 } 01634 else 01635 { 01636 pContext = NULL; 01637 } 01638 } 01639 } 01640 01641 if (pContext) 01642 { 01643 if (!(pContext->IsSelected ())) 01644 { 01645 float contextPos = pContext->GetPosition(); 01646 BOOL shuffle = (curpos < contextPos); 01647 01648 // do we need to shuffle this item to keep order? 01649 if (shuffle) 01650 { 01651 RampItem *pRemoved = (RampItem*)RemoveItem(pItem); 01652 pRemoved->ClearPointers (); 01653 return InsertNewItem(pRemoved); 01654 01655 } 01656 } 01657 } 01658 else 01659 { 01660 pContext = (RampItem*)GetNext(pItem); 01661 01662 if (pContext) 01663 { 01664 if (!(pContext->IsSelected ())) 01665 { 01666 float contextPos = pContext->GetPosition(); 01667 BOOL shuffle = (curpos > contextPos); 01668 01669 // do we need to shuffle this item to keep order? 01670 if (shuffle) 01671 { 01672 RampItem *pRemoved = (RampItem*)RemoveItem(pItem); 01673 pRemoved->ClearPointers (); 01674 return InsertNewItem(pRemoved); 01675 } 01676 } 01677 } 01678 } 01679 01680 return index; 01681 }
|
|
Ensures all positions of all items in the list are in numerical order.
Definition at line 464 of file fillramp.cpp. 00465 { 00466 // bubble sort algorithm - not fast but should be fast enough for our purposes 00467 RampItem * pPrevItem = (RampItem *)GetHead(); 00468 RampItem * pThisItem = (RampItem *)GetNext(pPrevItem); 00469 00470 while (pThisItem) 00471 { 00472 if (pPrevItem->GetPosition() > pThisItem->GetPosition()) 00473 { 00474 // swap the values around, and then restart the list 00475 // first, remove this item 00476 RampItem * pRemovedItem = (RampItem *)RemoveItem(pThisItem); 00477 00478 if (InsertBefore(pPrevItem, pRemovedItem) == NULL) 00479 { 00480 ERROR3("Insert before failed"); 00481 return; 00482 } 00483 00484 pPrevItem = (RampItem *)GetHead(); 00485 pThisItem = (RampItem *)GetNext(pPrevItem); 00486 } 00487 // now, check for multiple points 00488 else if (pPrevItem->GetPosition() == pThisItem->GetPosition()) 00489 { 00490 pThisItem->SetPosition(pPrevItem->GetPosition() + 0.01f); 00491 pThisItem = (RampItem *)GetNext(pThisItem); 00492 pPrevItem = (RampItem *)GetNext(pPrevItem); 00493 } 00494 else 00495 { 00496 pThisItem = (RampItem *)GetNext(pThisItem); 00497 pPrevItem = (RampItem *)GetNext(pPrevItem); 00498 } 00499 } 00500 }
|