feat: WIP unified workspace shared mask objects and OpenCV tracker core
这个提交包含在:
1 父节点
78e53b3889
当前提交
ca352248c1
36 个文件已更改
+5298
-164
没有与搜索条件相匹配的文件
@@ -1,5 +1,5 @@
|
||||
// Methods of DYViewerParameterPanel. Geometry is shared by drawing and input.
|
||||
- (BOOL)graphicKind:(NSString*)kind{return [@[@"curvePlot",@"wheel",@"hslPlot",@"spiderPlot"]containsObject:kind];}
|
||||
- (BOOL)graphicKind:(NSString*)kind{return [@[@"curvePlot",@"wheel",@"hslPlot",@"spiderPlot",@"lensFrame",@"lensCenter",@"lensStrength"]containsObject:kind];}
|
||||
- (NSData*)spiderData {if(_spiderDraft)return _spiderDraft;return [_nodeID hasPrefix:@"base:"]?_snapshot[@"spider"]:[self node][@"layer"][@"spider"];}
|
||||
- (void)beginSpiderData {[_bridge beginSpider:[self spiderData] node:_nodeID enabled:[self graphicValue:@"spiderEnabled"] atTime:_time];}
|
||||
- (void)spiderAction:(NSInteger)action {
|
||||
@@ -40,6 +40,18 @@
|
||||
- (NSPoint)curvePosition:(NSDictionary*)p rect:(NSRect)r{return NSMakePoint(r.origin.x+[p[@"x"]doubleValue]*r.size.width,r.origin.y+(1-[p[@"y"]doubleValue])*r.size.height);}
|
||||
- (void)drawGraphic:(NSDictionary*)area{
|
||||
CGFloat s=_scale;NSRect r=[area[@"rect"]rectValue];NSColor*ink=DYThemeColor(@"text"),*accent=DYThemeColor(@"accent");
|
||||
if([@[@"curve",@"lens"]containsObject:_toolType]){ink=NSColor.whiteColor;accent=NSColor.systemCyanColor;NSShadow *shadow=[[[NSShadow alloc]init]autorelease];shadow.shadowColor=[NSColor colorWithWhite:0 alpha:.9];shadow.shadowBlurRadius=2;shadow.shadowOffset=NSZeroSize;[shadow set];}
|
||||
if([area[@"kind"]isEqual:@"lensFrame"]){
|
||||
NSBezierPath *grid=[NSBezierPath bezierPath];grid.lineWidth=.6*s;
|
||||
for(int i=1;i<8;i++){CGFloat x=NSMinX(r)+r.size.width*i/8.,y=NSMinY(r)+r.size.height*i/8.;[grid moveToPoint:NSMakePoint(x,NSMinY(r))];[grid lineToPoint:NSMakePoint(x,NSMaxY(r))];[grid moveToPoint:NSMakePoint(NSMinX(r),y)];[grid lineToPoint:NSMakePoint(NSMaxX(r),y)];}[[NSColor colorWithWhite:1 alpha:.3]setStroke];[grid stroke];return;
|
||||
}
|
||||
if([area[@"kind"]isEqual:@"lensCenter"]||[area[@"kind"]isEqual:@"lensStrength"]){
|
||||
BOOL center=[area[@"kind"]isEqual:@"lensCenter"];NSPoint point=NSMakePoint(NSMidX(r),NSMidY(r));NSBezierPath *mark=[NSBezierPath bezierPath];mark.lineWidth=1.4*s;
|
||||
[mark moveToPoint:NSMakePoint(point.x-7*s,point.y)];[mark lineToPoint:NSMakePoint(point.x+7*s,point.y)];
|
||||
if(center){[mark moveToPoint:NSMakePoint(point.x,point.y-7*s)];[mark lineToPoint:NSMakePoint(point.x,point.y+7*s)];}else{[mark moveToPoint:NSMakePoint(point.x-3*s,point.y-4*s)];[mark lineToPoint:NSMakePoint(point.x-7*s,point.y)];[mark lineToPoint:NSMakePoint(point.x-3*s,point.y+4*s)];[mark moveToPoint:NSMakePoint(point.x+3*s,point.y-4*s)];[mark lineToPoint:NSMakePoint(point.x+7*s,point.y)];[mark lineToPoint:NSMakePoint(point.x+3*s,point.y+4*s)];}
|
||||
[accent setStroke];[mark stroke];if(_hover==[area[@"part"]integerValue]||_pressed==[area[@"part"]integerValue]){NSString *hint=center?@"光学中心":[NSString stringWithFormat:@"畸变 %.1f",[self graphicValue:@"lensStrength"]];[self text:hint rect:NSMakeRect(point.x-50*s,point.y+12*s,100*s,18*s)size:10 color:ink alignment:NSTextAlignmentCenter];}return;
|
||||
}
|
||||
|
||||
if([area[@"kind"]isEqual:@"hslPlot"]){
|
||||
[NSGraphicsContext saveGraphicsState];NSRectClip(r);[[ink colorWithAlphaComponent:.18]setStroke];NSBezierPath *mid=[NSBezierPath bezierPath];[mid moveToPoint:NSMakePoint(NSMinX(r),NSMidY(r))];[mid lineToPoint:NSMakePoint(NSMaxX(r),NSMidY(r))];[mid stroke];
|
||||
NSBezierPath *curve=[NSBezierPath bezierPath];curve.lineWidth=1.5*s;
|
||||
@@ -68,7 +80,7 @@
|
||||
NSPoint p=NSMakePoint(NSMidX(r)+cos(angle)*rad,NSMidY(r)-sin(angle)*rad);[NSColor.blackColor setStroke];NSBezierPath*knob=[NSBezierPath bezierPathWithOvalInRect:NSMakeRect(p.x-5*s,p.y-5*s,10*s,10*s)];knob.lineWidth=3*s;[knob stroke];[NSColor.whiteColor setStroke];knob.lineWidth=1.4*s;[knob stroke];
|
||||
return;
|
||||
}
|
||||
[[ink colorWithAlphaComponent:.06]setFill];[[NSBezierPath bezierPathWithRect:r]fill];[NSGraphicsContext saveGraphicsState];NSRectClip(r);
|
||||
[NSGraphicsContext saveGraphicsState];NSRectClip(r);
|
||||
NSData *rawHistogram=_snapshot[@"histogram"];const DYHistogram *hist=rawHistogram.length==sizeof(DYHistogram)?(const DYHistogram*)rawHistogram.bytes:nullptr;
|
||||
if(hist&&hist->samples){uint32_t peak=1;for(int c=0;c<4;c++)if(_channel==0||c==_channel)for(int b=0;b<256;b++)peak=MAX(peak,hist->bins[c][b]);NSArray *colors=@[ink,NSColor.systemRedColor,NSColor.systemGreenColor,NSColor.systemBlueColor];for(int c=3;c>=0;c--){if(_channel&&c!=_channel)continue;NSBezierPath *area=[NSBezierPath bezierPath];[area moveToPoint:NSMakePoint(NSMinX(r),NSMaxY(r))];for(int b=0;b<256;b++)[area lineToPoint:NSMakePoint(NSMinX(r)+b/255.*r.size.width,NSMaxY(r)-sqrt(hist->bins[c][b]/double(peak))*r.size.height*.86)];[area lineToPoint:NSMakePoint(NSMaxX(r),NSMaxY(r))];[area closePath];[[colors[c]colorWithAlphaComponent:c==0?.08:.2]setFill];[area fill];}}
|
||||
[[ink colorWithAlphaComponent:.16]setStroke];NSBezierPath*grid=[NSBezierPath bezierPath];grid.lineWidth=.5*s;
|
||||
@@ -83,10 +95,14 @@
|
||||
for(int sample=0;sample<=256;sample++){double x=sample/256.;while(segment+2<p.size()&&x>p[segment+1].x)segment++;double width=MAX(.0001,p[segment+1].x-p[segment].x),t=MAX(0.,MIN(1.,(x-p[segment].x)/width)),t2=t*t,t3=t2*t;double y=(2*t3-3*t2+1)*p[segment].y+(t3-2*t2+t)*width*m[segment]+(-2*t3+3*t2)*p[segment+1].y+(t3-t2)*width*m[segment+1];NSPoint q=NSMakePoint(r.origin.x+x*r.size.width,r.origin.y+(1-MAX(0.,MIN(1.,y)))*r.size.height);if(sample==0)[curve moveToPoint:q];else[curve lineToPoint:q];}
|
||||
NSColor*color=_channel==0?accent:_channel==1?NSColor.systemRedColor:_channel==2?NSColor.systemGreenColor:NSColor.systemBlueColor;[color setStroke];[curve stroke];
|
||||
for(NSDictionary*point in points){NSPoint q=[self curvePosition:point rect:r];BOOL selected=[point[@"xKey"]isEqual:_selectedX];[color setFill];NSBezierPath*dot=[NSBezierPath bezierPathWithOvalInRect:NSMakeRect(q.x-4*s,q.y-4*s,8*s,8*s)];[dot fill];[(selected?NSColor.whiteColor:ink)setStroke];dot.lineWidth=(selected?2:1)*s;[dot stroke];}
|
||||
[NSGraphicsContext restoreGraphicsState];[self text:@"0 输入 → 1" rect:NSMakeRect(r.origin.x,NSMaxY(r)+2*s,r.size.width,14*s)size:8 color:ink alignment:NSTextAlignmentCenter];
|
||||
[NSGraphicsContext restoreGraphicsState];
|
||||
}
|
||||
- (void)beginGraphicAt:(NSPoint)p{
|
||||
if(!_snapshot||![self node])return;NSMutableDictionary*c=[[_captured mutableCopy]autorelease];NSRect r=[c[@"rect"]rectValue];NSString*xKey=nil,*yKey=nil;
|
||||
if([c[@"kind"]isEqual:@"lensCenter"]||[c[@"kind"]isEqual:@"lensStrength"]){
|
||||
BOOL center=[c[@"kind"]isEqual:@"lensCenter"];NSArray *keys=center?@[@"lensCenterX",@"lensCenterY"]:@[@"lensStrength"];NSMutableArray *descriptors=[NSMutableArray array];NSMutableDictionary *values=[NSMutableDictionary dictionary];for(NSString *key in keys){[descriptors addObject:[self descriptorForKey:key]];values[key]=@([self graphicValue:key]);}c[@"lensStart"]=values;[_captured release];_captured=[c copy];[_bridge beginParameters:descriptors node:_nodeID values:values atTime:_time];return;
|
||||
}
|
||||
|
||||
if([c[@"kind"]isEqual:@"spiderPlot"]){auto mesh=DYSpiderMesh([self spiderData]);double best=12*_scale;NSInteger chosen=-1;for(int i=0;i<dy::meshCount(mesh);i++){double distance=hypot(p.x-(r.origin.x+mesh.x[i]*r.size.width),p.y-(r.origin.y+mesh.y[i]*r.size.height));if(distance<best){best=distance;chosen=i;}}if(chosen<0)return;_selectedSpider=chosen;c[@"meshStart"]=[NSData dataWithBytes:&mesh length:sizeof(mesh)];[_captured release];_captured=[c copy];[self beginSpiderData];return;}
|
||||
if([c[@"kind"]isEqual:@"hslPlot"]){NSInteger color=MAX(0,MIN(7,(NSInteger)((p.x-r.origin.x)/r.size.width*8)));NSString *key=[NSString stringWithFormat:@"hsl%ld_%ld",(long)_hslAxis,(long)color];c[@"hslKey"]=key;[_captured release];_captured=[c copy];[_bridge beginParameter:[self descriptorForKey:key]node:_nodeID value:[self graphicValue:key]atTime:_time];return;}
|
||||
if([c[@"kind"]isEqual:@"curvePlot"]){NSDictionary*nearest=nil;double distance=12*_scale;for(NSDictionary*point in [self curvePoints]){NSPoint q=[self curvePosition:point rect:r];double d=hypot(q.x-p.x,q.y-p.y);if(d<distance){distance=d;nearest=point;}}
|
||||
@@ -98,6 +114,13 @@
|
||||
if([c[@"newPoint"]boolValue]||[c[@"kind"]isEqual:@"wheel"])[self updateGraphicAt:p];
|
||||
}
|
||||
- (void)updateGraphicAt:(NSPoint)p{
|
||||
if([_captured[@"kind"]isEqual:@"lensCenter"]||[_captured[@"kind"]isEqual:@"lensStrength"]){
|
||||
NSDictionary *start=_captured[@"lensStart"];if(!start)return;NSDictionary *values;
|
||||
if([_captured[@"kind"]isEqual:@"lensCenter"]){values=@{@"lensCenterX":@(MAX(0.,MIN(1.,[start[@"lensCenterX"]doubleValue]+(p.x-_down.x)/MAX(1.,_viewport.size.width)))),@"lensCenterY":@(MAX(0.,MIN(1.,[start[@"lensCenterY"]doubleValue]+(p.y-_down.y)/MAX(1.,_viewport.size.height))))};}
|
||||
else values=@{@"lensStrength":@(MAX(-100.,MIN(100.,[start[@"lensStrength"]doubleValue]+(p.x-_down.x)/MAX(1.,_viewport.size.width)*400)))};
|
||||
[_draftValues addEntriesFromDictionary:values];[_bridge changeValues:values];return;
|
||||
}
|
||||
|
||||
if([_captured[@"kind"]isEqual:@"spiderPlot"]){NSData *start=_captured[@"meshStart"];if(!start||_selectedSpider<0)return;NSRect r=[_captured[@"rect"]rectValue];auto mesh=DYSpiderMesh(start);std::bitset<dy::SpiderMeshCapacity> selected;selected[_selectedSpider]=true;auto moved=dy::moveMesh(mesh,selected,(p.x-_down.x)/r.size.width,(p.y-_down.y)/r.size.height);[_spiderDraft release];_spiderDraft=[[NSData alloc]initWithBytes:&moved length:sizeof(moved)];[_bridge changeSpider:_spiderDraft];return;}
|
||||
if([_captured[@"kind"]isEqual:@"hslPlot"]){NSString *key=_captured[@"hslKey"];if(!key)return;NSRect r=[_captured[@"rect"]rectValue];double v=MAX(-100.,MIN(100.,(NSMidY(r)-p.y)/r.size.height*200));_draftValues[key]=@(v);[_bridge changeValue:v];return;}
|
||||
NSString*xKey=_captured[@"xKey"],*yKey=_captured[@"yKey"];if(!xKey||!yKey)return;NSRect r=[_captured[@"rect"]rectValue];double x,y;
|
||||
|
||||
在新工单中引用
屏蔽一个用户