How to use the ConvertCoordinates in the AIHardSoftSuite in CS5
Hi,
I am trying to make a plugin with the CS5 version on MacOSX.
This version has new functions for the rulers. You can have a ruler for each artboard and a global ruler for the document.
There are new functions in AIHardSoftSuite to deal with the different rulers.
I need to retrieve some values from a dialog box. These values are the position of the active crop area or an area given by the user.
The user sets the values in the dialog box. He can change the origin of the rulers (artboard or global). So I need to retrieve the correct values.
Internally Illustrator use a different coordinates system ( for more details see the doc). I need to convert the values from kAIDocumentCoordinateSystem to kAICurrentCoordinateSystem and in the reverse order.
I have written a small code to check if the conversion is correct or if I use correctly these new functions.
ASInt32 index;
sAICropArea->GetActive(&index);
if (index >= 0){
// Retrievess the current active crop area
AICropAreaPtr properties;
sAICropArea->Get(index, &properties);
AICropAreaPtr properties;
sAICropArea->Get(index, &properties);
AIRealRect rect = properties->m_CropAreaRect;
/// Checks if the conversion is correct
ai::int32 apiCoordinate;
sAIHardSoft->GetCoordinateSystem(apiCoordinate);
AIBoolean convertForDisplay = true;
for(int i = 0; i < 2; ++i){ // I am checking two points of the rectangle (bottom, left) and (top, right)
AIRealPoint input;
if (i == 0){
input.h = rect.left; input.v = rect.bottom;
}
else if (i == 1){
input.h = rect.right; input.v = rect.top;
}
std::cout << "Pinput " << input.h << " " << input.v << std::endl;
sAIHardSoft->ConvertCoordinates(input, apiCoordinate, kAICurrentCoordinateSystem, convertForDisplay);
std::cout << "Ptemp " << input.h << " " << input.v << std::endl;
sAIHardSoft->ConvertCoordinates(input, kAICurrentCoordinateSystem, apiCoordinate, convertForDisplay);
std::cout << "Poutput " << input.h << " " << input.v << std::endl;
}
}
To check if the code is working the input and the ouput variables must be equal. But when I change the origin of a ruler, it is not the case.
Did I write something wrong ?