Implement persistent leveling and all standalone module templates; validation pending

这个提交包含在:
mac 于 2026-11-06 12:24:19 +08:00 提交
1 父节点 81b50538b4
当前提交 dc5769492d
33 个文件已更改
+8585 -88

没有与搜索条件相匹配的文件

+12 -9
查看文件
@@ -108,28 +108,31 @@
@synchronized(self){
double angle=[_toolCanvasDocument[@"levelRotation"] doubleValue];
if(rotation)*rotation=angle;
return DYLevelTransform(angle,_toolSourceAspect>0?_toolSourceAspect:fallback);
return DYLevelTransform([_toolCanvasDocument[@"levelMeasureOnly"]boolValue]?0:angle,_toolSourceAspect>0?_toolSourceAspect:fallback);
}
}
- (void)saveCanvasLevel:(double)rotation replacing:(double)previous completion:(void (^)(NSString *failure))completion {
- (NSDictionary *)toolCanvasLevelState {
@synchronized(self){NSMutableDictionary *state=[NSMutableDictionary dictionary];for(NSString *key in @[@"levelRotation",@"levelReference",@"levelMeasureOnly"])if(_toolCanvasDocument[key])state[key]=_toolCanvasDocument[key];return [[state copy]autorelease];}
}
- (void)saveCanvasLevel:(NSDictionary *)state replacing:(NSDictionary *)previous completion:(void (^)(NSString *failure))completion {
dispatch_async(dispatch_get_main_queue(),^{
NSString *failure=nil;
id<FxCustomParameterActionAPI_v4> action=[self->_apiManager apiForProtocol:@protocol(FxCustomParameterActionAPI_v4)];
if(!action){completion(@"宿主暂时无法保存水平校正。");return;}
[action startAction:self];
@try {
// The correction is clip-wide. Use the action clock for the document write.
CMTime time=DYHostDisplayedFrameTime(self->_apiManager,action.currentTime);
DYToolDocument *stored=nil;
id<FxParameterRetrievalAPI_v6> get=[self->_apiManager apiForProtocol:@protocol(FxParameterRetrievalAPI_v6)];
if(!CMTIME_IS_NUMERIC(time)||![get getCustomParameterValue:&stored fromParameter:DYToolsParameterID atTime:time]||
![stored isKindOfClass:DYToolDocument.class]||[stored.document[@"levelRotation"] doubleValue]!=previous){
failure=@"水平校正状态已变化,请重新画线。";
}else if(rotation!=previous){
BOOL read=CMTIME_IS_NUMERIC(time)&&[get getCustomParameterValue:&stored fromParameter:DYToolsParameterID atTime:time]&&[stored isKindOfClass:DYToolDocument.class];
NSMutableDictionary *actual=[NSMutableDictionary dictionary];
for(NSString *key in @[@"levelRotation",@"levelReference",@"levelMeasureOnly"])if(stored.document[key])actual[key]=stored.document[key];
if(!read||![actual isEqual:previous])failure=@"水平校正状态已变化,请重试。";
else if(![state isEqual:actual]){
NSMutableDictionary *doc=DYMutablePlist(stored.document);
doc[@"levelRotation"]=rotation?@(rotation):nil;
for(NSString *key in @[@"levelRotation",@"levelReference",@"levelMeasureOnly"])doc[key]=state[key];
id<FxUndoAPI> undo=[self->_apiManager apiForProtocol:@protocol(FxUndoAPI)];
BOOL grouped=[undo startUndoGroup:rotation?@"水平校正":@"重置水平校正"];
BOOL grouped=[undo startUndoGroup:state[@"levelReference"]?@"水平校正":@"重置水平校正"];
@try {
if(DYWriteTools(self->_apiManager,doc,time)){
DYToolDocument *saved=[[[DYToolDocument alloc]init]autorelease];saved.document=doc;