07-31-2016, 09:53 AM
Thanks, Garrett. That approach ultimately worked, although not quite as visually intuitive to the user as if deleted objects stayed deleted as the user dragged. I ultimately stored the hit points as well as the mouse trail in ArtboardPointVectors. It seems to me an iterator would be more elegant than a vanilla for loop, but here's what I did:
I'm too embarrassed to admit how much time I spent trying to use an iterator here--what I found in books, forums, tutorials, etc., didn't seem to apply here. Maybe what I came up with can be helpful to others as either a way to do this, or as a clumsy way not to...
For the "scribble" type mode, I'd have liked to use a Polyline variation of the Polygon in the Draw class, but short Line segments worked fine for the visual representation of the mouse trail.
To make deleted art disappear again during subsequent drags I considered storing a vector of object references and re-deleting them each drag event, but experiments showed that they were drawn before they were deleted, ruining the effect. It also struck me that it probably wasn't safe or reliable to store references as they could change; empty objects could be tested easily enough, but duplicates with old IDs reassigned to new art could cause problems. It may not be as polished as I'd like, but it works!
Code:
// ArtboardPoint vector named hitPoints
long numPts (hitPoints.size());
for(long iter = 0;
iter < numPts;
iter++){
hdi::core::HitData aHit(NULL, hitPoints[iter], hdi::core::SegPointOrInteriorHitRequest, 2);
if ( aHit.hit()) {
if (aHit.art()->artType() == hdi::core::ArtTypePath) // or other conditions tested
// do stuff
}
}
}
I'm too embarrassed to admit how much time I spent trying to use an iterator here--what I found in books, forums, tutorials, etc., didn't seem to apply here. Maybe what I came up with can be helpful to others as either a way to do this, or as a clumsy way not to...
For the "scribble" type mode, I'd have liked to use a Polyline variation of the Polygon in the Draw class, but short Line segments worked fine for the visual representation of the mouse trail.
To make deleted art disappear again during subsequent drags I considered storing a vector of object references and re-deleting them each drag event, but experiments showed that they were drawn before they were deleted, ruining the effect. It also struck me that it probably wasn't safe or reliable to store references as they could change; empty objects could be tested easily enough, but duplicates with old IDs reassigned to new art could cause problems. It may not be as polished as I'd like, but it works!