#include <opbezier.h>
Inheritance diagram for OpSelectPathPoints:
Public Member Functions | |
OpSelectPathPoints () | |
Constructor. This simply sets a few of the operation flags. | |
void | DoDrag (DocCoord Anchor, Spread *, BOOL isAdjust, BezierTool *toolptr, ClickModifiers) |
Starts dragging a rectangle, and when the drag finishes, any points inside the rectangle will be selected. If isAdjust, points inside the rectangle will be toggled. | |
virtual void | DragPointerMove (DocCoord PointerPos, ClickModifiers ClickMods, Spread *, BOOL bSolidDrag) |
Handles the event of the mouse moving during a drag. | |
virtual void | DragFinished (DocCoord PointerPos, ClickModifiers ClickMods, Spread *, BOOL Success, BOOL bSolidDrag) |
Handles the drag finishing by rubbing out an EOR on the screen and selecting any points which fall within the rectangle dragged out. | |
void | RenderDragBlobs (DocRect, Spread *, BOOL bSolidDrag) |
EORs the rectangle onto the screen. | |
Static Public Member Functions | |
static BOOL | Declare () |
Adds the operation to the list of all known operations. | |
static OpState | GetState (String_256 *Description, OpDescriptor *) |
Find out the state of the operation at the specific time. | |
static BOOL | Init () |
Adds the operation to the list of all known operations. | |
static BOOL | DragInProgress () |
To find out if there is a select points operation in progress. | |
Private Member Functions | |
CC_DECLARE_DYNCREATE (OpSelectPathPoints) | |
void | ChangeCursor (Cursor *cursor) |
void | PushCursor (Cursor *cursor) |
void | PopCursor () |
void | RemoveDragBlobs (BOOL, BOOL) |
Implement a common bit of code shared by two bits at the end of DragFinished. Both want to go through all selected paths although they do different things with them. | |
void | RenderRubberRect (DocRect *Rect) |
EORs the selection rectangle onto the screen. The rectangle is rendered using the coordinates StartPoint to PreviousPoint. | |
void | RenderRubberSelection (RenderRegion *pRegion) |
EORs the blobs on the selected paths onto the screen. This is is needed to solve quite an ugly situation. If the path(s) are scrolled then their blobs will be redrawn as per their document status. We need to go through all the paths rendering their selection status as we want them to be. | |
Private Attributes | |
DocCoord | StartPoint |
Spread * | StartSpread |
DocCoord | PreviousPoint |
BOOL | AdjustDrag |
BezierTool * | BezToolPtr |
ClickModifiers | Mods |
Cursor * | pcMarqueeCursor |
Static Private Attributes | |
static BOOL | DragUnderway = FALSE |
Definition at line 122 of file opbezier.h.
|
Constructor. This simply sets a few of the operation flags.
Definition at line 145 of file opbezier.cpp.
|
|
|
|
|
|
Adds the operation to the list of all known operations.
Definition at line 747 of file opbezier.cpp. 00748 { 00749 return (RegisterOpDescriptor( 00750 0, 00751 _R(IDS_SELECTPATHPOINTS), 00752 CC_RUNTIME_CLASS(OpSelectPathPoints), 00753 OPTOKEN_BEZTOOL, 00754 OpSelectPathPoints::GetState, 00755 0, /* help ID */ 00756 _R(IDBBL_FREEHANDTOOLOP), 00757 0 /* bitmap ID */)); 00758 }
|
|
Starts dragging a rectangle, and when the drag finishes, any points inside the rectangle will be selected. If isAdjust, points inside the rectangle will be toggled.
On the drag start all control point blobs are removed, also if the drag is a select drag (as opposed to an adjust drag) the selected endpoints blobs are replaced with unselected blobs. Definition at line 221 of file opbezier.cpp. 00226 { 00227 // Make a mental note of the start point 00228 StartPoint = Anchor; 00229 StartSpread = pSpread; 00230 PreviousPoint = Anchor; 00231 AdjustDrag = isAdjust; 00232 BezToolPtr = tptr; 00233 Mods = ClickMods; 00234 00235 // Go through all the selected NodePaths and remove all the 00236 // control point blobs 00237 SelRange* Selection = GetApplication()->FindSelection(); 00238 Node* pNode = Selection->FindFirst(); 00239 NodePath* pSelected = NULL; 00240 00241 while (pNode != NULL) 00242 { 00243 if (pNode->IsNodePath()) 00244 pSelected = (NodePath*)pNode; 00245 else 00246 pSelected = (NodePath*) (pNode->HasEditableChild(CC_RUNTIME_CLASS(NodePath), NULL)); 00247 00248 if (pSelected) 00249 { 00250 Path* ThisPath = &(pSelected->InkPath); 00251 Spread* pSpread = pNode->FindParentSpread(); 00252 00253 // Dereference the pointers 00254 DocCoord* Coords = ThisPath->GetCoordArray(); 00255 PathFlags* Flags = ThisPath->GetFlagArray(); 00256 PathVerb* Verbs = ThisPath->GetVerbArray(); 00257 INT32 UsedSlots = ThisPath->GetNumCoords(); 00258 00259 DocCoord StartCoord = Coords[0]; 00260 00261 // Go into a RenderOnTop loop 00262 RenderRegion* pRender = DocView::RenderOnTop(NULL, pSpread, ClippedEOR); 00263 while (pRender!=NULL) 00264 { 00265 // loop through the path and count the selected blobs 00266 INT32 endcount = 0; // Count the number of selected endpoints 00267 INT32 EndPtIndex = 0; // Index of only selected endpoint 00268 for (INT32 i=0; i<UsedSlots; i++) 00269 { 00270 if (Flags[i].IsEndPoint && Flags[i].IsSelected) 00271 { 00272 if (!(Verbs[i] & PT_CLOSEFIGURE)) 00273 { 00274 EndPtIndex = i; 00275 endcount++; 00276 if (!AdjustDrag) 00277 { 00278 // If in select mode then remove the selection blob 00279 ThisPath->DrawBlob(pRender, Coords[i], TRUE); 00280 ThisPath->DrawBlob(pRender, Coords[i], FALSE); 00281 } 00282 } 00283 } 00284 } 00285 if (endcount == 1) 00286 { 00287 // Remove the control points and lines 00288 ThisPath->RenderPathControlBlobs(pSpread,EndPtIndex); 00289 } 00290 pRender = DocView::GetNextOnTop(NULL); 00291 } // while the render region 00292 } // if its a node path 00293 pNode = Selection->FindNext(pNode); 00294 } // while there are selected nodes 00295 00296 // And tell the Dragging system that we need drags to happen 00297 StartDrag( DRAGTYPE_AUTOSCROLL ); 00298 00299 DragUnderway = TRUE; 00300 }
|
|
Handles the drag finishing by rubbing out an EOR on the screen and selecting any points which fall within the rectangle dragged out.
Reimplemented from Operation. Definition at line 428 of file opbezier.cpp. 00430 { 00431 00432 DocRect RubberRect(StartPoint, StartPoint); 00433 RubberRect.IncludePoint(PreviousPoint); 00434 RenderRubberRect(&RubberRect); 00435 00436 DragUnderway = FALSE; 00437 00438 BeginSlowJob(); 00439 // End the Drag 00440 if ( !EndDrag() ) 00441 { 00442 FailAndExecute(); 00443 End(); 00444 } 00445 00446 // select any points within the rectangle if the drag completed properly 00447 // If the rectangle is tiny, we're not selecting points, we're inserting a new 00448 // path at the click position 00449 00450 if ( Success ) 00451 { 00452 DocRect temp; 00453 GetApplication()->GetBlobManager()->GetBlobRect(StartPoint,&temp); 00454 if (!temp.ContainsCoord(PreviousPoint)) 00455 { 00456 // Must be selecting points 00457 // Get all selected points, and remove any selected EORing, replacing it with 00458 // normal EORing 00459 00460 SelRange* Selected = GetApplication()->FindSelection(); 00461 Node* pNode = Selected->FindFirst(); 00462 NodePath* pSelected = NULL; 00463 00464 while (pNode) 00465 { 00466 if (pNode->IsNodePath()) 00467 pSelected = (NodePath*)pNode; 00468 else 00469 pSelected = (NodePath*) (pNode->HasEditableChild(CC_RUNTIME_CLASS(NodePath), NULL)); 00470 00471 if ((pSelected) && (pSelected->FindParentSpread() == StartSpread)) 00472 { 00473 // Go through the points in this path. 00474 // Select any unselected points that fall in the rectangle. 00475 // If Adjust, deselected any selected points that fall in the rectangle. 00476 // If not Adjust, deselect any selected points that fall outside. 00477 00478 DocCoord testcoord; 00479 Path* ThisPath = &(pSelected->InkPath); 00480 DocCoord* Coords = ThisPath->GetCoordArray(); 00481 PathFlags* Flags = ThisPath->GetFlagArray(); 00482 PathVerb* Verbs = ThisPath->GetVerbArray(); 00483 INT32 UsedSlots = ThisPath->GetNumCoords(); 00484 INT32 SelectedEndPoints = 0; 00485 INT32 EndPtIndex = 0; 00486 00487 for (INT32 i=0; i<UsedSlots; i++) 00488 { 00489 if (Flags[i].IsEndPoint) 00490 { 00491 // Selected points change depending on Adjust and whether they are 00492 // within the rectangle. 00493 if (Flags[i].IsSelected) 00494 { 00495 if (!AdjustDrag && !RubberRect.ContainsCoord(Coords[i])) 00496 { 00497 Flags[i].IsSelected = FALSE; 00498 } 00499 else 00500 { 00501 if (!(Verbs[i] & PT_CLOSEFIGURE)) 00502 { 00503 SelectedEndPoints++; 00504 EndPtIndex = i; 00505 } 00506 } 00507 } 00508 else 00509 { 00510 // unselected points inside rect are selected 00511 if (RubberRect.ContainsCoord(Coords[i])) 00512 { 00513 Flags[i].IsSelected = TRUE; 00514 if (!(Verbs[i] & PT_CLOSEFIGURE)) 00515 { 00516 SelectedEndPoints++; 00517 EndPtIndex = i; 00518 } 00519 } 00520 } 00521 } 00522 } 00523 ThisPath->EnsureSelection(TRUE); 00524 // Now render on the control points if there was just one selected endpoint 00525 if (SelectedEndPoints == 1) 00526 { 00527 ThisPath->RenderPathControlBlobs(pSpread,EndPtIndex); 00528 } 00529 } 00530 pNode = Selected->FindNext(pNode); 00531 } // while 00532 00533 } 00534 else 00535 { 00536 // Must have been a single click. If Adjust was down, clear all selected points 00537 // if not, still clear all selected points, but tell the bezier tool that 00538 // the user wants to start a new path at this point 00539 // Get all selected points, and remove any selected EORing, replacing it with 00540 // normal EORing 00541 RemoveDragBlobs(FALSE, TRUE); 00542 00543 // Now we've cleared the selection, check Adjust. If adjust is not set 00544 // we have to put in a floating endpoint 00545 if (!Mods.Adjust) 00546 { 00547 DocView::SnapCurrent(pSpread, &StartPoint); 00548 BezToolPtr->SetMoveTo(StartPoint, pSpread, GetWorkingDoc()); 00549 00550 if (!RemoveFloaterAction::DoRemove(this, &UndoActions, BezToolPtr)) 00551 { 00552 FailAndExecute(); 00553 End(); 00554 return; 00555 } 00556 } 00557 } 00558 } 00559 else 00560 { 00561 // Escape was pressed, we just have to restore the blob state to the previous 00562 RemoveDragBlobs(TRUE, FALSE); 00563 } 00564 GetApplication()->UpdateSelection(); 00565 End(); 00566 }
|
|
To find out if there is a select points operation in progress.
Definition at line 186 of file opbezier.cpp. 00187 { 00188 return DragUnderway; 00189 }
|
|
Handles the event of the mouse moving during a drag.
Reimplemented from Operation. Definition at line 320 of file opbezier.cpp. 00322 { 00323 // If drag has moved onto a different spread, convert the coord to be relative to the 00324 // original spread. 00325 if (pSpread != StartSpread) 00326 PointerPos = MakeRelativeToSpread(StartSpread, pSpread, PointerPos); 00327 00328 // Remove old rubber rectangle 00329 DocRect OldOutline(StartPoint, StartPoint); 00330 OldOutline.IncludePoint(PreviousPoint); 00331 RenderRubberRect(&OldOutline); 00332 00333 // Change the variable that remembers the other corner of the rectangle 00334 PreviousPoint = PointerPos; 00335 00336 // And render the rubber rect in its new position 00337 DocRect NewOutline(StartPoint, StartPoint); 00338 NewOutline.IncludePoint(PreviousPoint); 00339 RenderRubberRect(&NewOutline); 00340 00341 // Now we need to render selection status of newly entered/exited endpoints 00342 // Go through all the endpoints on selected NodePaths. 00343 SelRange* Selection = GetApplication()->FindSelection(); 00344 Node* pNode = Selection->FindFirst(); 00345 NodePath* pSelected = NULL; 00346 00347 while (pNode != NULL) 00348 { 00349 if (pNode->IsNodePath()) 00350 pSelected = (NodePath*)pNode; 00351 else 00352 pSelected = (NodePath*) (pNode->HasEditableChild(CC_RUNTIME_CLASS(NodePath), NULL)); 00353 00354 if (pSelected) 00355 { 00356 Path* ThisPath = &(pSelected->InkPath); 00357 Spread* pSpread = pNode->FindParentSpread(); 00358 00359 // Dereference the pointers 00360 DocCoord* Coords = ThisPath->GetCoordArray(); 00361 PathFlags* Flags = ThisPath->GetFlagArray(); 00362 PathVerb* Verbs = ThisPath->GetVerbArray(); 00363 INT32 UsedSlots = ThisPath->GetNumCoords(); 00364 00365 // Go into a RenderOnTop loop 00366 RenderRegion* pRender = DocView::RenderOnTop(NULL, pSpread, ClippedEOR); 00367 while (pRender!=NULL) 00368 { 00369 // loop through the path, processing every endpoint 00370 for (INT32 i=0; i<UsedSlots; i++) 00371 { 00372 if (Flags[i].IsEndPoint && !(Verbs[i] & PT_CLOSEFIGURE) ) 00373 { 00374 BOOL First = TRUE; // Default selection status/es/i/whatever 00375 BOOL Second = FALSE; // This means we can skip doing thigs 00376 BOOL Render = FALSE; 00377 if (!(AdjustDrag && Flags[i].IsSelected)) 00378 { 00379 if (NewOutline.ContainsCoord(Coords[i]) && 00380 !OldOutline.ContainsCoord(Coords[i]) ) 00381 { 00382 // Point has just entered the selection rect 00383 First = FALSE; 00384 Second = TRUE; 00385 Render = TRUE; 00386 } 00387 if (!NewOutline.ContainsCoord(Coords[i]) 00388 && OldOutline.ContainsCoord(Coords[i]) ) 00389 { 00390 // Point has just left the selection rect 00391 Render = TRUE; 00392 } 00393 } 00394 if (Render) 00395 { 00396 ThisPath->DrawBlob(pRender, Coords[i], First); 00397 ThisPath->DrawBlob(pRender, Coords[i], Second); 00398 } 00399 } 00400 } 00401 pRender = DocView::GetNextOnTop(NULL); 00402 } // while the render region 00403 } // if its a node path 00404 pNode = Selection->FindNext(pNode); 00405 } // while there are selected nodes 00406 }
|
|
Find out the state of the operation at the specific time.
Definition at line 865 of file opbezier.cpp. 00866 { 00867 OpState Blobby; 00868 00869 return Blobby; 00870 }
|
|
Adds the operation to the list of all known operations.
Reimplemented from SimpleCCObject. Definition at line 160 of file opbezier.cpp. 00161 { 00162 return (RegisterOpDescriptor( 0, 00163 _R(IDS_NODEPATH_EDIT), 00164 CC_RUNTIME_CLASS(OpSelectPathPoints), 00165 OPTOKEN_NODEPATH, 00166 OpSelectPathPoints::GetState, 00167 0, /* help ID */ 00168 _R(IDBBL_NODEPATHOP), 00169 0 /* bitmap ID */)); 00170 }
|
|
|
|
|
|
Implement a common bit of code shared by two bits at the end of DragFinished. Both want to go through all selected paths although they do different things with them.
Definition at line 778 of file opbezier.cpp. 00779 { 00780 DocRect RubberRect(StartPoint, StartPoint); 00781 RubberRect.IncludePoint(PreviousPoint); 00782 00783 SelRange* Selected = GetApplication()->FindSelection(); 00784 Node* pNode = Selected->FindFirst(); 00785 NodePath* pSelected = NULL; 00786 00787 while (pNode) 00788 { 00789 if (pNode->IsNodePath()) 00790 pSelected = (NodePath*)pNode; 00791 else 00792 pSelected = (NodePath*) (pNode->HasEditableChild(CC_RUNTIME_CLASS(NodePath), NULL)); 00793 00794 if ((pSelected) && (pSelected->FindParentSpread() == StartSpread)) 00795 { 00796 Path* ThisPath = &(pSelected->InkPath); 00797 INT32 UsedSlots = ThisPath->GetNumCoords(); 00798 DocCoord* Coords = ThisPath->GetCoordArray(); 00799 PathFlags* Flags = ThisPath->GetFlagArray(); 00800 PathVerb* Verbs = ThisPath->GetVerbArray(); 00801 00802 RenderRegion* pRender = DocView::RenderOnTop(NULL, StartSpread, ClippedEOR); 00803 while (pRender!=NULL) 00804 { 00805 INT32 SelectedEndPoints = 0; 00806 INT32 EndPtIndex = 0; 00807 DocCoord EndPtCoord; 00808 for (INT32 i=0; i<UsedSlots; i++) 00809 { 00810 if (Flags[i].IsEndPoint) 00811 { 00812 if ( ((AdjustDrag && Flags[i].IsSelected) || 00813 RubberRect.ContainsCoord(Coords[i])) 00814 && !(Verbs[i] & PT_CLOSEFIGURE) ) 00815 { 00816 // Remove the selection blobs 00817 ThisPath->DrawBlob(pRender, Coords[i], TRUE); 00818 ThisPath->DrawBlob(pRender, Coords[i], FALSE); 00819 } 00820 if (Flags[i].IsSelected) 00821 { 00822 SelectedEndPoints ++; 00823 EndPtIndex = i; 00824 EndPtCoord = Coords[i]; 00825 } 00826 } 00827 if (Deselect) 00828 { 00829 Flags[i].IsSelected = FALSE; 00830 } 00831 } 00832 if ((SelectedEndPoints == 1) && (RenderControlBlobs)) 00833 { 00834 ThisPath->RenderPathControlBlobs(StartSpread,EndPtIndex); 00835 if (!(AdjustDrag && RubberRect.ContainsCoord(EndPtCoord))) 00836 { 00837 ThisPath->DrawBlob(pRender, EndPtCoord, FALSE); 00838 ThisPath->DrawBlob(pRender, EndPtCoord, TRUE); 00839 } 00840 } 00841 pRender = DocView::GetNextOnTop(NULL); 00842 } 00843 } 00844 pNode = Selected->FindNext(pNode); 00845 } 00846 }
|
|
EORs the rectangle onto the screen.
Reimplemented from Operation. Definition at line 583 of file opbezier.cpp. 00584 { 00585 // If being called from DocView::RenderView, then the spread could be wrong - so 00586 // convert the rectangle if necessary. 00587 if (pSpread != StartSpread) 00588 { 00589 Rect.lo = MakeRelativeToSpread(StartSpread, pSpread, Rect.lo); 00590 Rect.hi = MakeRelativeToSpread(StartSpread, pSpread, Rect.hi); 00591 } 00592 00593 RenderRubberRect(&Rect); 00594 RenderRegion* pRegion = DocView::RenderOnTop(&Rect, StartSpread, UnclippedEOR); 00595 00596 while (pRegion) 00597 { 00598 if (DragUnderway) 00599 RenderRubberSelection(pRegion); 00600 00601 // Get the Next render region 00602 pRegion = DocView::GetNextOnTop(&Rect); 00603 } 00604 }
|
|
EORs the selection rectangle onto the screen. The rectangle is rendered using the coordinates StartPoint to PreviousPoint.
Definition at line 622 of file opbezier.cpp. 00623 { 00624 RenderRegion* pRegion = DocView::RenderOnTop(Rect, StartSpread, UnclippedEOR); 00625 while (pRegion) 00626 { 00627 // Set the line colour 00628 pRegion -> SetLineColour(COLOUR_XORNEW); 00629 pRegion -> SetFillColour(COLOUR_NONE); 00630 00631 // And Draw the rect 00632 DocRect RubberBox(StartPoint, StartPoint); 00633 RubberBox.IncludePoint(PreviousPoint); 00634 00635 // Draw the rectangle 00636 pRegion->DrawDragRect(&RubberBox); 00637 00638 // Get the Next render region 00639 pRegion = DocView::GetNextOnTop(Rect); 00640 } 00641 }
|
|
EORs the blobs on the selected paths onto the screen. This is is needed to solve quite an ugly situation. If the path(s) are scrolled then their blobs will be redrawn as per their document status. We need to go through all the paths rendering their selection status as we want them to be.
Definition at line 661 of file opbezier.cpp. 00662 { 00663 ERROR3IF (pRegion == NULL, "Pointer to RenderRegion was NULL"); 00664 ERROR3IF (!DragUnderway, "RenderRubberSelection called when no drag was underway"); 00665 00666 SelRange* Selection = GetApplication()->FindSelection(); 00667 Node* pNode = Selection->FindFirst(); 00668 00669 DocRect RubberBox(StartPoint, StartPoint); 00670 RubberBox.IncludePoint(PreviousPoint); 00671 NodePath* pSelected = NULL; 00672 00673 while (pNode) 00674 { 00675 if (pNode->IsNodePath()) 00676 pSelected = (NodePath*)pNode; 00677 else 00678 pSelected = (NodePath*) (pNode->HasEditableChild(CC_RUNTIME_CLASS(NodePath), NULL)); 00679 00680 if ((pSelected) && (pSelected->FindParentSpread() == StartSpread)) 00681 { 00682 Path* ThisPath = &(pSelected->InkPath); 00683 INT32 UsedSlots = ThisPath->GetNumCoords(); 00684 DocCoord* Coords = ThisPath->GetCoordArray(); 00685 PathFlags* Flags = ThisPath->GetFlagArray(); 00686 PathVerb* Verbs = ThisPath->GetVerbArray(); 00687 INT32 EndPtIndex =0; 00688 INT32 endcount = 0; 00689 00690 for (INT32 i=0; i<UsedSlots; i++) 00691 { 00692 if (Flags[i].IsEndPoint && !(Verbs[i] & PT_CLOSEFIGURE)) 00693 { 00694 // Now we need to render on the selection blob status 00695 BOOL First = TRUE; // By default deselect a selected blob 00696 BOOL Second = FALSE; 00697 BOOL Render = FALSE; 00698 00699 if (Flags[i].IsSelected) 00700 { 00701 EndPtIndex = i; 00702 endcount++; 00703 Render = TRUE; 00704 } 00705 00706 if (AdjustDrag) 00707 Render = FALSE; 00708 00709 if (RubberBox.ContainsCoord(Coords[i]) && !Flags[i].IsSelected) 00710 { 00711 // Render an unselected blob as selected 00712 Render = TRUE; 00713 First = FALSE; 00714 Second = TRUE; 00715 } 00716 00717 if (Render) 00718 { 00719 ThisPath->DrawBlob(pRegion, Coords[i], First); 00720 ThisPath->DrawBlob(pRegion, Coords[i], Second); 00721 } 00722 } 00723 } 00724 if (endcount == 1) 00725 { 00726 // Remove the control points and lines 00727 ThisPath->RenderPathControlBlobs(StartSpread,EndPtIndex); 00728 } 00729 } 00730 pNode = Selection->FindNext(pNode); 00731 } 00732 }
|
|
Definition at line 155 of file opbezier.h. |
|
Definition at line 156 of file opbezier.h. |
|
Definition at line 158 of file opbezier.h. |
|
Definition at line 157 of file opbezier.h. |
|
Definition at line 160 of file opbezier.h. |
|
Definition at line 154 of file opbezier.h. |
|
Definition at line 152 of file opbezier.h. |
|
Definition at line 153 of file opbezier.h. |