Adobe.com
Contents Suites Classes Class Index Member Index

IAIDocumentUtils.hpp

Go to the documentation of this file.
00001 /*************************************************************************
00002  *
00003  * ADOBE CONFIDENTIAL
00004  *
00005  * Copyright 2019 Adobe
00006  *
00007  * All Rights Reserved.
00008  *
00009  * NOTICE: Adobe permits you to use, modify, and distribute this file in
00010  * accordance with the terms of the Adobe license agreement accompanying
00011  * it. If you have received this file from a source other than Adobe,
00012  * then your use, modification, or distribution of it requires the prior
00013  * written permission of Adobe.
00014  *
00015  **************************************************************************/
00016 
00017 /*      Utility functions for operations on AIDocumentSuite.
00018 */
00019 #pragma once
00020 #include "AIBasicTypes.h"
00021 #include "AITypes.h"
00022 #include "AIRealMath.h"
00023 #include "AITransformArt.h"
00024 
00025 namespace ai
00026 {
00027         namespace DocumentUtils
00028         {
00037                 AIReal GetDocumentScale();
00038 
00042         AIRealMatrix GetTransFormMatrixForDocumentScale();
00043         
00049         AIRealMatrix GetTransformMatrixForDocumentScaleFromReference( const AIRealPoint& referencePoint);
00050         
00054         AIRealMatrix GetTransFormMatrixForScaleFactor(const AIReal& scaleFactor );
00055         
00061         AIRealMatrix GetTransformMatrixForScaleFactorFromReference(const AIReal& scaleFactor, const AIRealPoint& referencePoint);
00062         
00068                 template <typename Rect>
00069                 void ApplyScaleToRect(const Rect& inRect, Rect& outRect, const AIReal scale)
00070                 {
00071                         outRect.left = inRect.left * static_cast<decltype(inRect.left)>(scale);
00072                         outRect.top = inRect.top * static_cast<decltype(inRect.top)>(scale);
00073                         outRect.right = inRect.right * static_cast<decltype(inRect.right)>(scale);
00074                         outRect.bottom = inRect.bottom * static_cast<decltype(inRect.bottom)>(scale);
00075                 }
00076 
00082         template <typename Rect>
00083                 void ApplyDocumentScaleToRect( const Rect& inRect, Rect& outRect)
00084         {
00085             AIReal docScale = GetDocumentScale();
00086                         ApplyScaleToRect(inRect, outRect, docScale);
00087         }
00088                                 
00093         template <typename Point>
00094         void ApplyDocumentScaleToPoint(const Point& inPoint, Point& outPoint)
00095         {
00096             AIReal docScale = GetDocumentScale();
00097             outPoint.h = inPoint.h *  static_cast<decltype(inPoint.h)>(docScale);
00098             outPoint.v = inPoint.v *  static_cast<decltype(inPoint.v)>(docScale);
00099             
00100         }
00101 
00106                 void ApplyDocumentScaleToAIReal( const AIReal& inReal, AIReal& outReal);
00107                 
00112         template <typename Rect>
00113         void DropDocumentScaleFromRect( const Rect& inRect, Rect& outRect)
00114         {
00115             AIReal docScale = GetDocumentScale();
00116             outRect.left = inRect.left / static_cast<decltype(inRect.left)>(docScale);
00117             outRect.top = inRect.top / static_cast<decltype(inRect.top)>(docScale);
00118             outRect.right = inRect.right / static_cast<decltype(inRect.right)>(docScale);
00119             outRect.bottom = inRect.bottom / static_cast<decltype(inRect.bottom)>(docScale);
00120         }
00121         
00126         template <typename Point>
00127         void DropDocumentScaleFromPoint(const Point& inPoint, Point& outPoint)
00128         {
00129             AIReal docScale = GetDocumentScale();
00130             outPoint.h = inPoint.h / static_cast<decltype(inPoint.h)>(docScale);
00131             outPoint.v = inPoint.v / static_cast<decltype(inPoint.v)>(docScale);
00132         }
00133         
00138         void DropDocumentScaleFromAIReal( const AIReal& inReal, AIReal& outReal);
00139 
00140                 class ArtScaler
00141                 {
00142                 public:
00143                         ArtScaler(AIReal scale, ai::int32 transformOptions)
00144                                 : mScaleFactor{ scale },
00145                                 mTransformOptions{ transformOptions }
00146                         {}
00147 
00148                         AIErr ScaleArt(AIArtHandle art);
00149 
00150                         AIErr DownScaleArt(AIArtHandle art);
00151 
00152                         bool IsScaleFactorOne()
00153                         {
00154                                 return mScaleFactor == kAIRealOne;
00155                         }
00156 
00157                 private:
00158                         AIReal mScaleFactor{ kAIRealOne };
00159                         ai::int32 mTransformOptions{ 0 };
00160             AIRealMatrix GetScaledXformMatrix(AIArtHandle art, AIReal scale);
00161                 };
00162         } // Document Utils
00163 } // ai


Contents Suites Classes Class Index Member Index
Adobe Solutions Network
 
Copyright © 2014 Adobe Systems Incorporated. All rights reserved.
Terms of Use Online Privacy Policy Adobe and accessibility Avoid software piracy Permissions and Trademarks