07-21-2016, 06:02 PM
Am I going in the right direction with this? Say I want to find all selected objects at a given point:
This code seems to work, but I'm flying by the seat of my pants here. The docs say we're responsible for the memory used by the ArtVector; does the clear() function suffice for aforementioned memory management? I saw in hdicoreMemory.h a template (I've never used one of those before!) that deletes each object pointed to in the vector, then performs a .clear(). Isn't the ArtVector returned by matchingArt, etc., analogous to an address list of the relevant objects, rather than complete copies of them? I'd be most grateful if someone can keep me out of trouble with this...
Code:
// ArtboardPoint variable pt passed to the function
hdi::core::CurrentDocument* currDoc = HDI_CORE_ILLUSTRATOR->currentDocument();
hdi::core::Art::ArtVector vMatches;
vMatches = currDoc->artAtPoint(Pt, hdi::core::SegPointOrInteriorHitRequest);
bool sel;
for(std::vector<hdi::core::Art*>::iterator iter = vMatches.begin(); iter != vMatches.end(); ++iter)
{
sel = (*iter)->selected();
if ( !sel ) vMatches.erase(iter);
}
// do something with the art object
vMatches.clear();
This code seems to work, but I'm flying by the seat of my pants here. The docs say we're responsible for the memory used by the ArtVector; does the clear() function suffice for aforementioned memory management? I saw in hdicoreMemory.h a template (I've never used one of those before!) that deletes each object pointed to in the vector, then performs a .clear(). Isn't the ArtVector returned by matchingArt, etc., analogous to an address list of the relevant objects, rather than complete copies of them? I'd be most grateful if someone can keep me out of trouble with this...