• Home
  • Members
  • Team
  • Help
  • Search
  • Register
  • Login
  • Home
  • Members
  • Help
  • Search
Hot Door CORE Forum All forums General discussion v
1 2 3 Next »
Placing art in customArt viewable art

 
  • 0 Vote(s) - 0 Average
Placing art in customArt viewable art
Rick Johnson
Offline

Senior Member

Posts: 259
Threads: 130
Joined: Jan 2014
Reputation: 0
#1
01-30-2019, 01:43 PM
I'm creating a custom art object and placing art in the editable art works fine. Either of these methods works, although one is likely preferable to the other:

Code:
    hdi::core::Art custObj = hdi::core::Art(hdi::core::ArtTypeCustom, hdi::core::PlaceAboveAll);
    hdi::core::ArtAP theRect = hdi::core::draw::rect(hdi::core::ArtboardRect::XYWidthHeight(100,100,50,50));
    hdi::core::ArtAP theEll = hdi::core::draw::ellipse(hdi::core::ArtboardPoint(125,125), 50, 50, true);
    hdi::core::Art* edArt = custObj.customArt()->editableArt().release();
    theEll->reorder(hdi::core::PlaceInsideOnTop, edArt);
    theRect->reorder(hdi::core::PlaceInsideOnTop, custObj.customArt()->editableArt().release());

Similar code, however, fails to move art into the viewableArt group. Using get() or release() on the auto_ptr seems to make no difference.

Code:
    hdi::core::Art custObj = hdi::core::Art(hdi::core::ArtTypeCustom, hdi::core::PlaceAboveAll);
    hdi::core::ArtAP theRect = hdi::core::draw::rect(hdi::core::ArtboardRect::XYWidthHeight(100,100,50,50));
    hdi::core::ArtAP theEll = hdi::core::draw::ellipse(hdi::core::ArtboardPoint(125,125), 50, 50, true);
    hdi::core::Art* vuArt = custObj.customArt()->viewableArt().release();
    theEll->reorder(hdi::core::PlaceInsideOnTop, vuArt);
    theRect->reorder(hdi::core::PlaceInsideOnTop, custObj.customArt()->viewableArt().release());

Any suggestions would be very much appreciated.
garrett
Offline

Super Moderator

Posts: 248
Threads: 24
Joined: Nov 2013
Reputation: 1
#2
01-30-2019, 10:22 PM
It's been a while since I've done much with custom art. If I remember correctly, the viewable art had to have a group at the root level. I think there might be other nuances to editable/viewable art, but that's where I would start.

Also, be careful with .get() and .release() with auto-pointers. The former acquires the raw pointer inside the auto-pointer, but the auto-pointer is still managing its memory. The latter releases the raw pointer from the auto-pointer, which can result (and definitely is resulting, in your example) in a memory leak.
Rick Johnson
Offline

Senior Member

Posts: 259
Threads: 130
Joined: Jan 2014
Reputation: 0
#3
01-31-2019, 12:45 PM (This post was last modified: 01-31-2019, 01:30 PM by Rick Johnson.)
Thanks, Garrett. It took some tinkering, but I found some interesting nuances with the viewable art that weren't there when I last used pluginArt with the SDK about 15 years ago.

- hdi::core::draw can't create art there.
- hdi::core::Art::reorder() can't move art there.
- art can only be duplicated there or built from scratch.

No additional grouping is needed.

I hope this approach to coercing an auto_ptr to plain pointer is correct for creating art there:

Code:
hdi::core::Art newArt = hdi::core::Art(hdi::core::ArtTypePath, hdi::core::PlaceInsideOnTop,custObj.customArt()->viewableArt().get());

Now that I can create the art, it's time to delve into the message data to respond appropriately when the art is moved or modified. It helps that each of the 11 or so customArt message types can register its own callback with the Dispatcher. hdi::core:Big Grinispatcher::lastMessage() returns a message pointer, but how can I obtain a CustomArtMessage to get the relevant customArt() pointer?
garrett
Offline

Super Moderator

Posts: 248
Threads: 24
Joined: Nov 2013
Reputation: 1
#4
02-03-2019, 12:13 AM
Yeah, your usage of the auto-pointer is right, but this is a smidge shorter:

Code:
hdi::core::Art newArt(hdi::core::ArtTypePath, hdi::core::PlaceInsideOnTop, custObj.customArt()->viewableArt().get());

Cast the Message pointer returned by hdi::core:Big Grinispatcher::lastMessage() to a CustomArtMessage pointer; just make sure you're doing so from within a callback registered as the handler for a custom art message type.
« Next Oldest | Next Newest »

Users browsing this thread: 1 Guest(s)



  • View a Printable Version
  • Subscribe to this thread
Forum Jump:

Linear Mode
Threaded Mode