Revise IContentProvider GetThumbnail signature
- Issue MatterHackers/MCCentral#3695 ContentProvider GetThumbnail fails for non-mesh content
This commit is contained in:
parent
40a0bcf472
commit
0e574131a9
6 changed files with 15 additions and 22 deletions
|
|
@ -70,10 +70,9 @@ namespace MatterHackers.MatterControl
|
|||
return null;
|
||||
}
|
||||
|
||||
public Task GetThumbnail(ILibraryItem item, int width, int height, ThumbnailSetter imageCallback)
|
||||
public Task<ImageBuffer> GetThumbnail(ILibraryItem item, int width, int height)
|
||||
{
|
||||
imageCallback(thumbnailImage, false);
|
||||
return Task.CompletedTask;
|
||||
return Task.FromResult(thumbnailImage);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -39,7 +39,7 @@ namespace MatterHackers.MatterControl.Library
|
|||
|
||||
public interface IContentProvider
|
||||
{
|
||||
Task GetThumbnail(ILibraryItem item, int width, int height, ThumbnailSetter imageCallback);
|
||||
Task<ImageBuffer> GetThumbnail(ILibraryItem item, int width, int height);
|
||||
ImageBuffer DefaultImage { get; }
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -96,10 +96,9 @@ namespace MatterHackers.MatterControl.DesignTools
|
|||
return null;
|
||||
}
|
||||
|
||||
public async Task GetThumbnail(ILibraryItem item, int width, int height, ThumbnailSetter imageCallback)
|
||||
public async Task<ImageBuffer> GetThumbnail(ILibraryItem item, int width, int height)
|
||||
{
|
||||
var imageBuffer = await LoadImage(item);
|
||||
imageCallback(imageBuffer, raytracedImage: true);
|
||||
return await LoadImage(item);
|
||||
}
|
||||
|
||||
public ImageBuffer DefaultImage => AggContext.StaticData.LoadIcon("140.png");
|
||||
|
|
|
|||
|
|
@ -101,7 +101,7 @@ namespace MatterHackers.MatterControl
|
|||
}
|
||||
|
||||
|
||||
public async Task GetThumbnail(ILibraryItem libraryItem, int width, int height, ThumbnailSetter imageCallback)
|
||||
public async Task<ImageBuffer> GetThumbnail(ILibraryItem libraryItem, int width, int height)
|
||||
{
|
||||
IObject3D object3D = null;
|
||||
|
||||
|
|
@ -122,8 +122,7 @@ namespace MatterHackers.MatterControl
|
|||
|
||||
string thumbnailId = libraryItem.ID;
|
||||
|
||||
var thumbnail = GetThumbnail(object3D, thumbnailId, width, height, false);
|
||||
imageCallback?.Invoke(thumbnail, true);
|
||||
return GetThumbnail(object3D, thumbnailId, width, height, false);
|
||||
}
|
||||
|
||||
public ImageBuffer GetThumbnail(IObject3D item, string thumbnailId, int width, int height, bool onlyUseCache)
|
||||
|
|
|
|||
|
|
@ -114,11 +114,7 @@ namespace MatterHackers.MatterControl.CustomWidgets
|
|||
this.SetItemThumbnail(generatingThumbnailIcon, raytracedImage: false);
|
||||
|
||||
// Ask the provider for a content specific thumbnail
|
||||
await contentProvider.GetThumbnail(
|
||||
libraryItem,
|
||||
thumbWidth,
|
||||
thumbHeight,
|
||||
this.SetItemThumbnail);
|
||||
thumbnail = await contentProvider.GetThumbnail(libraryItem, thumbWidth, thumbHeight);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -141,7 +137,7 @@ namespace MatterHackers.MatterControl.CustomWidgets
|
|||
|
||||
ApplicationController.Instance.QueueForGeneration(async () =>
|
||||
{
|
||||
// When this widget is dequeued for generation, validate before processing. Off-screen widgets should be skipped and will requeue next time they become visible
|
||||
// When dequeued for generation, ensure visible before raytracing. Off-screen widgets are dequeue and will reschedule if redrawn
|
||||
if (!this.ActuallyVisibleOnScreen())
|
||||
{
|
||||
// Skip raytracing operation, requeue on next draw
|
||||
|
|
@ -158,11 +154,11 @@ namespace MatterHackers.MatterControl.CustomWidgets
|
|||
this.SetItemThumbnail(generatingThumbnailIcon, raytracedImage: false);
|
||||
|
||||
// Ask the MeshContentProvider to RayTrace the image
|
||||
await meshContentProvider.GetThumbnail(
|
||||
listViewItem.Model,
|
||||
thumbWidth,
|
||||
thumbHeight,
|
||||
this.SetItemThumbnail);
|
||||
var thumbnail = await meshContentProvider.GetThumbnail(listViewItem.Model, thumbWidth, thumbHeight);
|
||||
if (thumbnail != null)
|
||||
{
|
||||
this.SetItemThumbnail(thumbnail, raytracedImage: true);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue