#include <fillattr2.h>
Inheritance diagram for AttrSquareFill:
Public Member Functions | |
AttrSquareFill () | |
AttrSquareFill (Node *ContextNode, AttachNodeDirection Direction, BOOL Locked=FALSE, BOOL Mangled=FALSE, BOOL Marked=FALSE, BOOL Selected=FALSE) | |
virtual void | Transform (TransformBase &) |
Transform a grad fill attribute by moving the start and end points. | |
virtual BOOL | CanTransform () |
Indicate that this attribute can be transformed. | |
virtual void | RenderFillBlobs (RenderRegion *pRender) |
virtual void | RenderFillMesh (RenderRegion *, DocCoord *, BOOL *, INT32 NumControlPoints=0) |
virtual void | OnControlDrag (DocCoord, FillControl &, ClickModifiers) |
virtual AttributeValue * | GetAttributeValue ()=0 |
virtual FillControl | TestColourDrop (AttrColourDrop *ColDrop) |
Check to see which colour will be changed if dropped at this point. | |
virtual BOOL | IsAGradFill () const |
Virtual function for determining if the node is an attribute. | |
virtual DocRect | GetBlobBoundingRect () |
Calculates the bounding rectangle of the attrs blobs.This should always be calculated on the fly as the view scale can change without the attr knowing, giving an incorrect result. | |
virtual BOOL | NeedsToRenderAtEachBrushStroke () const |
So that don't have to keep re-rendering attributes whilst drawing a brush, this identifies whether or not the attribute need to be rendered at each step, e.g. radial fills. | |
virtual INT32 | GetNumberOfControlPoints () |
Protected Member Functions | |
virtual void | ValidateAttributeValue () |
Makes sure the Coords of the Fill are sensible. |
Definition at line 1267 of file fillattr2.h.
|
Definition at line 1272 of file fillattr2.h. 01272 : AttrFillGeometry() {}
|
|
Definition at line 1273 of file fillattr2.h. 01278 : 01279 AttrFillGeometry(ContextNode, Direction, Locked, Mangled, Marked, Selected) {}
|
|
Indicate that this attribute can be transformed.
Reimplemented from NodeRenderable. Definition at line 9944 of file fillattr.cpp. 09945 { 09946 return TRUE; 09947 }
|
|
Implements AttrFillGeometry. Implemented in AttrSquareColourFill, and AttrSquareTranspFill. |
|
Calculates the bounding rectangle of the attrs blobs.This should always be calculated on the fly as the view scale can change without the attr knowing, giving an incorrect result.
Reimplemented from AttrFillGeometry. Definition at line 10230 of file fillattr.cpp. 10231 { 10232 #if !defined(EXCLUDE_FROM_RALPH) 10233 // Optimisation. If there is currently no interest in Fill Blobs 10234 // and this fill is not being Dragged (Fill blobs are turned off during 10235 // a fill drag), then we needn't bother doing anything. 10236 if ( (!GetApplication()->GetBlobManager()->GetCurrentInterest(TRUE).Fill || !IsVisible()) && DraggedFill != this ) 10237 return DocRect(0,0, 0,0); 10238 10239 // Get the Start and End Points 10240 DocCoord StartPoint = *GetStartPoint(); 10241 DocCoord EndPoint = *GetEndPoint(); 10242 DocCoord EndPoint2 = *GetEndPoint2(); 10243 10244 // Make a dummy bounds from just the Start Point 10245 DocRect BoundingRect(StartPoint, StartPoint); 10246 10247 if (DraggedFill == this) 10248 { 10249 // This fill is being dragged, so we have to include the Parallelagram 10250 // bounding rect as well 10251 DocRect StartBlobRect; 10252 DocRect EndBlobRect; 10253 DocRect DragRect = GetParallelagramBounds(StartPoint, EndPoint, EndPoint2); 10254 10255 // Get the Bounding rect of Blobs on each of the ends 10256 (Camelot.GetBlobManager())->GetBlobRect(DragRect.lo, &StartBlobRect); 10257 (Camelot.GetBlobManager())->GetBlobRect(DragRect.hi, &EndBlobRect); 10258 10259 // Now include the Bottom Left and Top Right of each blob in the Bounds. 10260 // We have to do it like this to make sure that the DocRect's coords 10261 // are valid. ie. The Hi's are Higher than the Lo's. 10262 BoundingRect.IncludePoint(StartBlobRect.lo); 10263 BoundingRect.IncludePoint(StartBlobRect.hi); 10264 BoundingRect.IncludePoint(EndBlobRect.lo); 10265 BoundingRect.IncludePoint(EndBlobRect.hi); 10266 } 10267 else 10268 { 10269 // We're not being dragged, so just calc the bounds of the Start and End Blobs 10270 DocRect StartBlobRect; 10271 DocRect EndBlobRect; 10272 DocRect End2BlobRect; 10273 10274 // Get the Bounding rect of the Fill Line, including the Blobs on the ends 10275 (Camelot.GetBlobManager())->GetBlobRect(StartPoint, &StartBlobRect); 10276 (Camelot.GetBlobManager())->GetBlobRect(EndPoint, &EndBlobRect); 10277 (Camelot.GetBlobManager())->GetBlobRect(EndPoint2, &End2BlobRect); 10278 10279 // Now include the Bottom Left and Top Right of each blob in the Bounds. 10280 // We have to do it like this to make sure that the DocRect's coords 10281 // are valid. ie. The Hi's are Higher than the Lo's. 10282 BoundingRect.IncludePoint(StartBlobRect.lo); 10283 BoundingRect.IncludePoint(StartBlobRect.hi); 10284 BoundingRect.IncludePoint(EndBlobRect.lo); 10285 BoundingRect.IncludePoint(EndBlobRect.hi); 10286 BoundingRect.IncludePoint(End2BlobRect.lo); 10287 BoundingRect.IncludePoint(End2BlobRect.hi); 10288 } 10289 10290 IncludeArrowHead(&BoundingRect, StartPoint, EndPoint); 10291 IncludeArrowHead(&BoundingRect, StartPoint, EndPoint2); 10292 10293 // and return it 10294 return BoundingRect; 10295 #else 10296 return DocRect(0,0,0,0); 10297 #endif 10298 }
|
|
Reimplemented from AttrFillGeometry. Definition at line 1300 of file fillattr2.h.
|
|
Virtual function for determining if the node is an attribute.
Reimplemented from NodeAttribute. Definition at line 1293 of file fillattr2.h. 01293 { return TRUE; }
|
|
So that don't have to keep re-rendering attributes whilst drawing a brush, this identifies whether or not the attribute need to be rendered at each step, e.g. radial fills.
Reimplemented from NodeAttribute. Definition at line 1296 of file fillattr2.h. 01296 { return TRUE;}
|
|
Reimplemented from AttrFillGeometry. Definition at line 10119 of file fillattr.cpp. 10120 { 10121 #if !defined(EXCLUDE_FROM_RALPH) 10122 // Get the current Control Positions 10123 DocCoord StartPoint = *GetStartPoint(); 10124 DocCoord EndPoint = *GetEndPoint(); 10125 DocCoord EndPoint2 = *GetEndPoint2(); 10126 10127 INT32 dx, dy; 10128 10129 // Which control point is being dragged ? 10130 switch (DragControl) 10131 { 10132 case FILLCONTROL_STARTPOINT: 10133 10134 // Someone is dragging the Centre of the Fill 10135 dx = StartPoint.x - Pos.x; 10136 dy = StartPoint.y - Pos.y; 10137 // Move the other points relative 10138 EndPoint.translate(-dx, -dy); 10139 EndPoint2.translate(-dx, -dy); 10140 10141 SetEndPoint(&EndPoint); 10142 SetEndPoint2(&EndPoint2); 10143 SetStartPoint(&Pos); 10144 break; 10145 10146 case FILLCONTROL_ENDPOINT: 10147 10148 // Someone is dragging the first End Point 10149 10150 // Constrain the angle if necessary 10151 if (ClickMods.Constrain) 10152 DocView::ConstrainToAngle(StartPoint, &Pos); 10153 10154 // The Aspect ratio can be locked either by it being circular 10155 // or by the Shift key 10156 if (ClickMods.Adjust) 10157 { 10158 double OldLen = StartPoint.Distance(EndPoint); 10159 double NewLen = StartPoint.Distance(Pos); 10160 double Ratio = 1.0; 10161 10162 if (OldLen == 0) 10163 Ratio = 0; 10164 else 10165 Ratio = NewLen/OldLen; 10166 10167 // Calculate the new end point based on the aspect ratio 10168 DocCoord temp = MakeLineAtAngle(StartPoint, Pos, 90, INT32(StartPoint.Distance(EndPoint2) * Ratio)); 10169 SetEndPoint2(&temp); 10170 } 10171 10172 SetEndPoint(&Pos); 10173 break; 10174 10175 case FILLCONTROL_SECONDARYPOINT: 10176 10177 // Someone is dragging the second End Point 10178 10179 // Constrain the angle if necessary 10180 if (ClickMods.Constrain) 10181 DocView::ConstrainToAngle(StartPoint, &Pos); 10182 10183 // The Aspect ratio can be locked either by it being circular 10184 // or by the Shift key 10185 if (ClickMods.Adjust) 10186 { 10187 double OldLen = StartPoint.Distance(EndPoint2); 10188 double NewLen = StartPoint.Distance(Pos); 10189 double Ratio = 1.0; 10190 10191 if (OldLen == 0) 10192 Ratio = 0; 10193 else 10194 Ratio = NewLen/OldLen; 10195 10196 // Calculate the new end point based on the aspect ratio 10197 DocCoord temp = MakeLineAtAngle(StartPoint, Pos, -90, INT32(StartPoint.Distance(EndPoint) * Ratio)); 10198 SetEndPoint(&temp); 10199 } 10200 10201 SetEndPoint2(&Pos); 10202 break; 10203 10204 default: 10205 // check for dragging a ramp point 10206 if (ISA_RAMPINDEX(DragControl)) 10207 { 10208 AttrFillGeometry::OnControlDrag( Pos, DragControl, ClickMods); 10209 } 10210 break; 10211 } 10212 #endif 10213 }
|
|
Reimplemented from AttrFillGeometry. Reimplemented in AttrSquareColourFill, and AttrSquareTranspFill. Definition at line 1285 of file fillattr2.h.
|
|
Reimplemented from AttrFillGeometry. Definition at line 9968 of file fillattr.cpp. 09971 { 09972 #if !defined(EXCLUDE_FROM_RALPH) 09973 if (AllowRampRedraw == FALSE) 09974 { 09975 FillRamp *pRamp = GetFillRamp(); 09976 if (pRamp) 09977 { 09978 pRamp->RenderSelectedBlob (ATTRVALUE(), pRender); 09979 } 09980 09981 return; 09982 } 09983 09984 DocCoord StartPoint = ControlPoints[FILLCONTROL_STARTPOINT]; 09985 DocCoord EndPoint = ControlPoints[FILLCONTROL_ENDPOINT]; 09986 09987 if (StartPoint == EndPoint) 09988 return; 09989 09990 if (SelState == NULL) 09991 { 09992 // If no selection state passed in, then assume 09993 // all the points are deselected 09994 BOOL Selected[NUMCONTROLPOINTS]; 09995 for (INT32 i=0; i< NumControlPoints; i++) 09996 { 09997 Selected[i] = FALSE; 09998 } 09999 SelState = Selected; 10000 } 10001 10002 DocCoord EndPoint2 = ControlPoints[FILLCONTROL_SECONDARYPOINT]; 10003 10004 // Remember what attributes were here before 10005 pRender->SaveContext(); 10006 10007 // Get the current blob size in Doc Units 10008 INT32 BlobSize = (Camelot.GetBlobManager())->GetBlobSize(); 10009 10010 // Calculate the Arrow on the End of the Line 10011 Path ArrowPath; 10012 ArrowPath.Initialise(); 10013 DocCoord LineEnd; 10014 MakeMeshArrow(&ArrowPath, StartPoint, EndPoint, &LineEnd); 10015 10016 // Calculate the Arrow on the End of the Line2 10017 Path ArrowPath2; 10018 ArrowPath2.Initialise(); 10019 DocCoord LineEnd2; 10020 MakeMeshArrow(&ArrowPath2, StartPoint, EndPoint2, &LineEnd2); 10021 10022 // Set the line colours etc as we need them 10023 pRender->SetLineWidth(0); 10024 pRender->SetLineColour(COLOUR_UNSELECTEDBLOB); 10025 pRender->SetFillColour(COLOUR_UNSELECTEDBLOB); 10026 10027 // First Draw the Line 10028 pRender->SetLineWidth(BlobSize/4); 10029 pRender->DrawLine(StartPoint, LineEnd); 10030 10031 // Draw the secondary line 10032 pRender->DrawLine(StartPoint, LineEnd2); 10033 10034 // Render an Arrow at the end of the line 10035 pRender->SetLineWidth(0); 10036 pRender->SetLineColour(COLOUR_NONE); 10037 pRender->DrawPath(&ArrowPath); 10038 10039 // and on the end of the secondary line 10040 pRender->DrawPath(&ArrowPath2); 10041 10042 if (DraggedFill == this) 10043 { 10044 if (AllowBoundsRedraw) 10045 { 10046 // If we are being dragged then draw a Parallelgram to 10047 // show the shape of the bitmap 10048 pRender->SetLineColour(COLOUR_SELECTEDBLOB); 10049 pRender->SetFillColour(COLOUR_NONE); 10050 10051 Path ParaPath; 10052 ParaPath.Initialise(); 10053 MakeMeshParallelagram(&ParaPath, StartPoint, EndPoint, EndPoint2); 10054 10055 // Draw the parallelagram 10056 pRender->DrawPath(&ParaPath); 10057 } 10058 } 10059 10060 // Now Render the blobs on the path 10061 // Set the line colour to none 10062 pRender->SetLineColour(COLOUR_NONE); 10063 10064 // Draw a blob at the start point 10065 if (SelState[FILLCONTROL_STARTPOINT]) 10066 { 10067 // Draw Selected Blob 10068 pRender->SetFillColour(COLOUR_SELECTEDBLOB); 10069 pRender->DrawBlob(StartPoint, BT_SELECTED); 10070 } 10071 else 10072 { 10073 // Draw Unselected Blob 10074 pRender->SetFillColour(COLOUR_UNSELECTEDBLOB); 10075 pRender->DrawBlob(StartPoint, BT_UNSELECTED); 10076 } 10077 10078 // Draw the blobs at the end points 10079 if (SelState[FILLCONTROL_ENDPOINT]) 10080 { 10081 // Draw Selected Blobs 10082 pRender->SetFillColour(COLOUR_SELECTEDBLOB); 10083 pRender->DrawBlob(EndPoint, BT_SELECTED); 10084 pRender->DrawBlob(EndPoint2,BT_SELECTED); 10085 } 10086 else 10087 { 10088 // Draw Unselected Blobs 10089 pRender->SetFillColour(COLOUR_UNSELECTEDBLOB); 10090 pRender->DrawBlob(EndPoint, BT_UNSELECTED); 10091 pRender->DrawBlob(EndPoint2,BT_UNSELECTED); 10092 } 10093 10094 // now render any ramp blobs 10095 FillRamp *pRamp = GetFillRamp(); 10096 if (pRamp) 10097 pRamp->RenderRampBlobs(ATTRVALUE(), pRender, NULL); 10098 10099 // Put all the old attributes back 10100 pRender->RestoreContext(); 10101 #endif 10102 }
|
|
Check to see which colour will be changed if dropped at this point.
Reimplemented from AttrFillGeometry. Definition at line 9821 of file fillattr.cpp. 09822 { 09823 #if !defined(EXCLUDE_FROM_RALPH) 09824 // So, where was it dropped (or where will it be dropped) 09825 DocCoord DropPoint = ColDrop->GetDropPoint(); 09826 09827 // Look to see if the DropPoint is over any of the Fill Control Points 09828 FillControl ControlHit = CheckForControlHit(DropPoint); 09829 09830 // If it hit one of our control points, then use that 09831 if (ControlHit != FILLCONTROL_NULL) 09832 return ControlHit; 09833 09834 // It didn't hit any of our control points, so if the drop is over 09835 // the object then we'll make a guess as to which control point 09836 // the user would like to change, depending on which area of the 09837 // object the pointer is over. 09838 09839 // First make sure we're actually over an object 09840 NodeRenderableInk* pParentObject = ColDrop->GetObjectDroppedOn(); 09841 if (pParentObject == NULL) 09842 return FILLCONTROL_NULL; // We're not over any object 09843 09844 // Make sure this fill type has some Control Points 09845 if (GetStartPoint() == NULL || GetEndPoint() == NULL || GetEndPoint2() == NULL) 09846 return FILLCONTROL_NULL; 09847 09848 // This next bit effectively transforms the drop point into the parallelogram coord space 09849 // t & u specify the coords (i.e. EndPoint is t = 1 and u = 0 and EndPoint2 is t = 0 and u = 1 09850 // If the absolute value of either coord is less than 0.5 then we are closer to the start point 09851 09852 DocCoord StartPoint = *GetStartPoint(); 09853 DocCoord EndPoint = *GetEndPoint(); 09854 DocCoord EndPoint2 = *GetEndPoint2(); 09855 09856 DocCoord P = EndPoint - StartPoint; 09857 DocCoord Q = EndPoint2 - StartPoint; 09858 DocCoord N = DropPoint - StartPoint; 09859 09860 double px = P.x; 09861 double py = P.y; 09862 double qx = Q.x; 09863 double qy = Q.y; 09864 double nx = N.x; 09865 double ny = N.y; 09866 09867 double den = (px * qy) - (py * qx); 09868 09869 // Default to end point 09870 ControlHit = FILLCONTROL_ENDPOINT; 09871 09872 // Guard against divide by zero 09873 // If this is zero it indicates that the fill is collapsed in some way 09874 // We always hit the end point because that is what is displayed 09875 09876 if (den != 0.0) 09877 { 09878 // Calculate u 09879 double u = ((px * ny) - (py * nx)) / den; 09880 09881 // If this is smaller than 0.5 then we need to calculate t 09882 if (fabs(u) < 0.5) 09883 { 09884 double t = 1.0; 09885 09886 if (px != 0.0) 09887 t = (nx - (u * qx)) / px; 09888 else 09889 t = (ny - (u * qy)) / py; 09890 09891 if (fabs(t) < 0.5) 09892 ControlHit = FILLCONTROL_STARTPOINT; 09893 } 09894 } 09895 09896 return ControlHit; 09897 09898 #else 09899 return FILLCONTROL_NULL; 09900 #endif 09901 }
|
|
Transform a grad fill attribute by moving the start and end points.
Reimplemented from NodeRenderable. Definition at line 9917 of file fillattr.cpp. 09918 { 09919 if ( Trans.TransFills ) 09920 { 09921 Trans.Transform( GetStartPoint(), 1); 09922 Trans.Transform( GetEndPoint(), 1); 09923 Trans.Transform( GetEndPoint2(), 1); 09924 09925 if (IsPerspective()) 09926 Trans.Transform( GetEndPoint3(), 1); 09927 } 09928 }
|
|
Makes sure the Coords of the Fill are sensible.
Reimplemented from AttrFillGeometry. Definition at line 10312 of file fillattr.cpp. 10313 { 10314 #if !defined(EXCLUDE_FROM_RALPH) 10315 if ((*GetStartPoint()) != DocCoord(0,0) && (*GetEndPoint()) != DocCoord(0,0)) 10316 { 10317 // If the EndPoint2 is 'NULL' then make it sensible 10318 if (*GetEndPoint2() == DocCoord(0,0)) 10319 { 10320 DocCoord temp = MakeLineAtAngle((*GetStartPoint()), (*GetEndPoint()), 90); 10321 SetEndPoint2(&temp); 10322 } 10323 10324 return; 10325 } 10326 10327 // Make up some sensible defaults 10328 DocRect AttrBounds = DocRect(0,0,0,0); 10329 10330 INT32 Width = DEFAULT_FILLWIDTH; 10331 INT32 Height = DEFAULT_FILLHEIGHT; 10332 10333 // Are we an Orphan ? 10334 if (FindParent() != NULL) 10335 { 10336 // Nope, so we can use Daddies Bounding Box 10337 SelRange* Selected = GetApplication()->FindSelection(); 10338 10339 if (Selected == NULL || Selected->Count() <= 1) 10340 AttrBounds = ((NodeRenderableBounded*)FindParent())->GetBoundingRect(TRUE); 10341 else 10342 AttrBounds = Selected->GetBoundingRect(); 10343 10344 Width = AttrBounds.Width(); 10345 Height = AttrBounds.Height(); 10346 } 10347 10348 // If the StartPoint is 'NULL' then make all points sensible 10349 if ((*GetStartPoint()) == DocCoord(0,0)) 10350 { 10351 // Start in the centre of the bounds 10352 DocCoord temp = CentreOf(AttrBounds); 10353 SetStartPoint(&temp); 10354 10355 // and set End Points to Middle Right, and Middle Top 10356 temp = DocCoord((*GetStartPoint()).x + (Width/2), (*GetStartPoint()).y); 10357 SetEndPoint(&temp); 10358 temp = DocCoord((*GetStartPoint()).x, (*GetStartPoint()).y + (Height/2)); 10359 SetEndPoint2(&temp); 10360 } 10361 10362 // If the EndPoint is 'NULL' then make end points sensible 10363 if ((*GetEndPoint()) == DocCoord(0,0)) 10364 { 10365 DocCoord temp = DocCoord((*GetStartPoint()).x + (Width/2), (*GetStartPoint()).y); 10366 SetEndPoint(&temp); 10367 temp = DocCoord((*GetStartPoint()).x, (*GetStartPoint()).y + (Height/2)); 10368 SetEndPoint2(&temp); 10369 } 10370 10371 if ((*GetEndPoint2()) == DocCoord(0,0)) 10372 { 10373 DocCoord temp = MakeLineAtAngle((*GetStartPoint()), (*GetEndPoint()), 90, Height/2); 10374 SetEndPoint2(&temp); 10375 } 10376 #endif 10377 }
|