Hot Door CORE Forum
Transform Again - Printable Version

+- Hot Door CORE Forum (http://hotdoorcore.com/forum)
+-- Forum: All forums (http://hotdoorcore.com/forum/forumdisplay.php?fid=1)
+--- Forum: General discussion (http://hotdoorcore.com/forum/forumdisplay.php?fid=3)
+--- Thread: Transform Again (/showthread.php?tid=233)



Transform Again - Rick Johnson - 03-21-2020

Can someone describe how to handle a TransformAgain message?

I get that I need to register a notifier with the Dispatcher (where I specify the callback) and then respond to a notifier in that callback.

I would presume that my plugins transform-again method needs to transform the selection in the same way as the last operation, but shouldn't there be some way for my plugin to register itself as "about to do a transformation" so that it knows that it was the last plugin to do a transform? Do I re-register a new TransformAgainMessageType in the Dispatcher before each new transformation? What does the registerMessageCallback method of Dispatcher that includes a caller and selector string add?

Currently, Transform Again does whatever the transformation was before my plugin transformed something. Any suggestions would be very much appreciated.


RE: Transform Again - garrett - 06-30-2020

I'm sorry to say that none of us here have any experience with handling Illustrator's "Transform Again" feature via the SDK, so you will probably have to reference their official SDK to make any headway there.


RE: Transform Again - Rick Johnson - 07-04-2020

I added Transform Again support using the SDK, and also added support for custom Undo and Redo text. The hardest part was the busywork of adding all of the search paths to the SDK in each build version.

There's more to accessing the SDK than just this, but if you have a project that already uses the SDK, you won't have to add much to use Transform Again and custom Undo and Redo text.

I declared the suites in my SDK header file:

Code:
#include "AITransformAgain.h"
#include "AIUndo.h"
#include "AIUnicodeString.h"

extern "C" AIUndoSuite* sUndo;
extern "C" AITransformAgainSuite* sAgain;
extern "C" AIUnicodeStringSuite* sUnicodeStr;
extern "C" SPBasicSuite* sSPBasic;

 and cpp file:

Code:
AITransformAgainSuite* sAgain = NULL;
AIUndoSuite* sUndo = NULL;
AIUnicodeStringSuite* sUnicodeStr = NULL;

... and load them in my startup sequence.

Code:
if (sAgain == NULL)
 sSPBasic->AcquireSuite ( kAITransformAgainSuite,  kAITransformAgainVersion,
   (const void**) &sAgain);
if (sUndo == NULL)
 sSPBasic->AcquireSuite ( kAIUndoSuite,  kAIUndoVersion,
   (const void**) &sUndo);
if (sUnicodeStr == NULL)
 sSPBasic->AcquireSuite ( kAIUnicodeStringSuite,  kAIUnicodeStringSuiteVersion,
   (const void**) &sUnicodeStr);

Also in startup I registered a message callback for Transform Again like this:
Code:
this->__corePlug->dispatcher()->registerMessageCallback(hdi::core::TransformAgainMessageType, HDI_CORE_CALLBACK(awesome::Plugin, this, __transformAgainCB));

For the callback, I did something like this, to do some operation based on which of my tools is current:

Code:
void awesome::Plugin::__transformAgainCB(){
 if (this->__corePlug->currentTool()->number() == this->toolANo){
   // do some function, passing stored parameters from the last operation
 }
 else if (this->__corePlug->currentTool()->number() == this->toolBNo){
   // do some other function
 }
}

After each transform operation I stored parameters for a Transform Again and added code like this:

Code:
sUndo->SetUndoTextUS(ai::UnicodeString("Undo Awesome Transform"),ai::UnicodeString("Redo Awesome Transform"));
sAgain->SetTransformAgain(HDI_CORE_PLUGIN->spPluginRef());

Then finally, release the suits in your shutdown sequence.

Code:
if (sAgain != NULL)
 sSPBasic->ReleaseSuite (kAITransformAgainSuite, kAITransformAgainVersion);
if (sUndo != NULL)
 sSPBasic->ReleaseSuite (kAIUndoSuite, kAIUndoVersion);
if (sUnicodeStr != NULL)
 sSPBasic->ReleaseSuite (kAIUnicodeStringSuite, kAIUnicodeStringSuiteVersion);

I'm sure there are better and more elegant ways to do this, but it's been working for me.


RE: Transform Again - garrett - 07-07-2020

Nice review there Rick!


RE: Transform Again - Rick Johnson - 07-10-2020

Thanks, Garrett! I've learned a lot from others here and am happy to give back where I can. I'll be posting more tips in the near future. CORE is a great environment to work in!