#include <pathops.h>
Inheritance diagram for OpBaseConvertPathSegment:
Public Member Functions | |
OpBaseConvertPathSegment () | |
OpBaseConvertPathSegment constructor - does nothing itself. | |
void | Do (OpDescriptor *) |
Performs the common SelRange scanning part of converting path segments. Calls the ProcessSegment function in derived classes to do the actual processing. | |
Static Public Member Functions | |
static OpState | BaseGetState (INT32 PathType) |
For finding the state of this op. | |
Protected Member Functions | |
virtual INT32 | GetProcessPathType () |
virtual INT32 | GetPathType () |
virtual BOOL | ProcessSegment (NodePath *pPath, INT32 *Index, INT32 PrevIndex) |
Definition at line 127 of file pathops.h.
|
OpBaseConvertPathSegment constructor - does nothing itself.
Definition at line 185 of file pathops.cpp. 00185 : SelOperation() 00186 { 00187 }
|
|
For finding the state of this op.
Definition at line 201 of file pathops.cpp. 00202 { 00203 OpState OpSt; 00204 00205 #ifndef STANDALONE 00206 00207 SelRange* Selected = GetApplication()->FindSelection(); 00208 00209 if ((Document::GetSelected() == NULL) || (Selected == NULL) ) 00210 { // There is no selected document or selrange is invalid 00211 OpSt.Greyed = TRUE; 00212 return OpSt; 00213 } 00214 00215 Node* pNode = Selected->FindFirst(); 00216 BOOL FoundSegment = FALSE; 00217 BOOL AllConverted = TRUE; 00218 BOOL PrevSelected = FALSE; 00219 00220 while ((pNode != NULL) && AllConverted) 00221 { 00222 if (pNode->IsNodePath() && ((NodePath*)pNode)->IsPathAllowable()) 00223 { 00224 Path* ThisPath = &(((NodePath*)pNode)->InkPath); 00225 PathFlags* Flags = ThisPath->GetFlagArray(); 00226 PathVerb* Verbs = ThisPath->GetVerbArray(); 00227 INT32 UsedSlots = ThisPath->GetNumCoords(); 00228 PrevSelected = FALSE; 00229 00230 for (INT32 i=0; i<UsedSlots; i++) 00231 { 00232 if (Flags[i].IsEndPoint) 00233 { 00234 if (Flags[i].IsSelected) 00235 { 00236 if (PrevSelected && ((Verbs[i] & ~PT_CLOSEFIGURE) != PT_MOVETO) ) 00237 { 00238 FoundSegment = TRUE; 00239 if ((Verbs[i] & ~PT_CLOSEFIGURE) != PathType) 00240 AllConverted = FALSE; 00241 } 00242 PrevSelected = TRUE; 00243 } 00244 else 00245 { 00246 PrevSelected = FALSE; 00247 } 00248 } 00249 } 00250 } 00251 pNode = Selected->FindNext(pNode); 00252 } 00253 00254 OpSt.Greyed = !FoundSegment; 00255 OpSt.Ticked = AllConverted && FoundSegment; 00256 00257 #endif // #ifdef STANDALONE 00258 00259 return OpSt; 00260 }
|
|
Performs the common SelRange scanning part of converting path segments. Calls the ProcessSegment function in derived classes to do the actual processing.
Reimplemented from Operation. Definition at line 275 of file pathops.cpp. 00276 { 00277 #ifndef STANDALONE 00278 00279 // Obtain the current selections and the first node in the selection 00280 SelRange* Selected = GetApplication()->FindSelection(); 00281 BOOL ok = (Selected != NULL); 00282 00283 // Start the op 00284 BeginSlowJob(); 00285 if (ok) 00286 ok = DoStartSelOp(TRUE,TRUE); 00287 00288 // Check with the selrange it is ok to run this op 00289 ObjChangeFlags cFlags; 00290 ObjChangeParam ObjChange(OBJCHANGE_STARTING,cFlags,NULL,this); 00291 if (ok) 00292 { 00293 if (!Selected->AllowOp(&ObjChange)) 00294 { 00295 EndSlowJob(); 00296 FailAndExecute(); 00297 End(); 00298 return; 00299 } 00300 } 00301 00302 Node* pNode = Selected->FindFirst(); 00303 NodePath* ThisPath = NULL; 00304 00305 while (ok && (pNode != NULL)) 00306 { // we're only interested in NodePaths which have selected points 00307 BOOL DoThisNode = pNode->IsNodePath(); 00308 if (DoThisNode) 00309 DoThisNode = (((NodePath*)pNode)->InkPath.IsSubSelection()); 00310 if (DoThisNode) 00311 DoThisNode = (((NodePath*)pNode)->IsPathAllowable()); 00312 00313 if ( DoThisNode ) 00314 { 00315 // for convenience, cast the pointer to a pointer to a NodePath 00316 ThisPath = (NodePath*)pNode; 00317 00318 // First get pointers to the arrays 00319 PathVerb* Verbs = NULL; 00320 PathFlags* Flags = NULL; 00321 DocCoord* Coords = NULL; 00322 ThisPath->InkPath.GetPathArrays(&Verbs, &Coords, &Flags); 00323 INT32 NumCoords = ThisPath->InkPath.GetNumCoords(); 00324 BOOL PrevSelected = FALSE; 00325 INT32 PrevPos = 0; 00326 00327 // Set the NeedToRender flags 00328 INT32 loop; 00329 for (loop = 0; loop < NumCoords; loop++) 00330 { 00331 if (Flags[loop].IsEndPoint && Flags[loop].IsSelected) 00332 Flags[loop].NeedToRender = TRUE; 00333 else 00334 Flags[loop].NeedToRender = FALSE; 00335 } 00336 00337 // Force a re-draw of the place where the path used to be 00338 if (ok) 00339 ok = (RecalcBoundsAction::DoRecalc(this, &UndoActions, ThisPath, TRUE) != AC_FAIL); 00340 00341 // loop through the points 00342 for (loop = 0; loop<NumCoords; loop++) 00343 { 00344 if (Flags[loop].IsEndPoint) 00345 { // its an endpoint 00346 if (Flags[loop].IsSelected) 00347 { // which is selected 00348 if (PrevSelected && ((Verbs[loop] & ~PT_CLOSEFIGURE) == GetProcessPathType()) ) 00349 { // and the previous was selected and it's a processable segment 00350 if (ok) 00351 ok = ProcessSegment(ThisPath, &loop, PrevPos); 00352 // Recache array pointers 00353 ThisPath->InkPath.GetPathArrays(&Verbs, &Coords, &Flags); 00354 NumCoords = ThisPath->InkPath.GetNumCoords(); 00355 Flags[loop].NeedToRender = TRUE; 00356 } 00357 PrevSelected = TRUE; 00358 PrevPos = loop; 00359 } 00360 else 00361 PrevSelected = FALSE; 00362 } 00363 } 00364 00365 // Having finished processing this path go round and smooth it. 00366 DocCoord NewCoord; 00367 for (loop = 0; (ok && (loop < NumCoords)); loop++) 00368 { 00369 if (Verbs[loop] == PT_BEZIERTO && !(Flags[loop].IsEndPoint) && Flags[loop].IsSmooth) 00370 { 00371 NewCoord = ThisPath->InkPath.SmoothControlPoint(loop); 00372 if (ok && (NewCoord != Coords[loop])) 00373 { 00374 ok = DoAlterPathElement(ThisPath, loop, NewCoord, Flags[loop], Verbs[loop], FALSE); 00375 ThisPath->InkPath.GetPathArrays(&Verbs, &Coords, &Flags); 00376 } 00377 } 00378 } 00379 00380 ThisPath->InvalidateBoundingRect(); 00381 00382 // Force a redraw of the place where the path is now. 00383 if (ok) 00384 ok = (RecordBoundsAction::DoRecord(this, &UndoActions, ThisPath, TRUE) != AC_FAIL); 00385 } 00386 pNode = Selected->FindNext(pNode); 00387 } 00388 00389 if (ok) 00390 { 00391 ObjChange.Define(OBJCHANGE_FINISHED,cFlags,NULL,this); 00392 if (!UpdateChangedNodes(&ObjChange)) 00393 { 00394 FailAndExecute(); 00395 End(); 00396 return; 00397 } 00398 } 00399 00400 EndSlowJob(); 00401 00402 if (!ok) 00403 { 00404 FailAndExecute(); 00405 InformError(); 00406 } 00407 00408 #endif 00409 00410 End(); 00411 }
|
|
Reimplemented in OpMakeSegmentsLines, and OpMakeSegmentsCurves. Definition at line 138 of file pathops.h. 00138 { ERROR3("Dont call the base class"); return 0;}
|
|
Reimplemented in OpMakeSegmentsLines, and OpMakeSegmentsCurves. Definition at line 137 of file pathops.h. 00137 { ERROR3("Dont call the base class"); return 0;}
|
|
Reimplemented in OpMakeSegmentsLines, and OpMakeSegmentsCurves. Definition at line 139 of file pathops.h. 00139 { ERROR3("Dont call the base class"); return 0;}
|