1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75
|
//
// Lynkeos
// $Id:$
//
// Created by Jean-Etienne LAMIAUD on Fri Oct 20 2017.
// Copyright (c) 2017-2018. Jean-Etienne LAMIAUD
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
//
#import <Foundation/Foundation.h>
#include "LynkeosInterpolator.h"
#include "MyPluginsController.h"
static NSDictionary *namedInterpolator = nil;
@implementation LynkeosInterpolatorManager
+ (Class) interpolatorWithScaling:(Scaling_t)scaling transform:(NSAffineTransformStruct)transform
{
// Iterate on known interpolators, and select the (autodeclared) best
int bestScore = 0;
Class bestInterpolator = nil;
NSEnumerator *interpolators
= [[[MyPluginsController defaultPluginController] getInterpolators] objectEnumerator];
Class interpolator;
while ((interpolator = [interpolators nextObject]) != nil)
{
int score = [interpolator isCompatibleWithScaling:scaling
withTransform:transform];
// NSLog(@"%@ interpolator score is %d", [interpolator name], score);
if (score > bestScore)
{
bestScore = score;
bestInterpolator = interpolator;
}
}
return(bestInterpolator);
}
+ (Class) interpolatorWithName:(NSString*)name
{
if ( namedInterpolator == nil )
{
NSMutableDictionary *interpolatorDict = [[NSMutableDictionary alloc] init];
NSEnumerator *interpolators
= [[[MyPluginsController defaultPluginController] getInterpolators] objectEnumerator];
Class interpolator;
while ((interpolator = [interpolators nextObject]) != nil)
{
[interpolatorDict setObject:interpolator forKey:[interpolator name]];
}
namedInterpolator = interpolatorDict;
}
return( [namedInterpolator objectForKey:name] );
}
@end
|