Move to new library model and view
- Add new listview control for library content
- Migrate library providers to containers
- Cloud, Sqlite, Directories, Queue, History
- Migrate SideBar components to containers
- Primatives, Text, Braille, ImageConverter
- Create new library container types
- Zip files, Calibration parts, Printer SDCards
- Reduce leftnav to Library, Settings, Controls, Options
- Add DragDrop support for image content
2017-05-19 22:33:55 -07:00
|
|
|
|
/*
|
2022-01-24 14:49:29 -08:00
|
|
|
|
Copyright (c) 2022, John Lewin, Lars Brubaker
|
Move to new library model and view
- Add new listview control for library content
- Migrate library providers to containers
- Cloud, Sqlite, Directories, Queue, History
- Migrate SideBar components to containers
- Primatives, Text, Braille, ImageConverter
- Create new library container types
- Zip files, Calibration parts, Printer SDCards
- Reduce leftnav to Library, Settings, Controls, Options
- Add DragDrop support for image content
2017-05-19 22:33:55 -07:00
|
|
|
|
All rights reserved.
|
|
|
|
|
|
|
|
|
|
|
|
Redistribution and use in source and binary forms, with or without
|
|
|
|
|
|
modification, are permitted provided that the following conditions are met:
|
|
|
|
|
|
|
|
|
|
|
|
1. Redistributions of source code must retain the above copyright notice, this
|
|
|
|
|
|
list of conditions and the following disclaimer.
|
|
|
|
|
|
2. Redistributions in binary form must reproduce the above copyright notice,
|
|
|
|
|
|
this list of conditions and the following disclaimer in the documentation
|
|
|
|
|
|
and/or other materials provided with the distribution.
|
|
|
|
|
|
|
|
|
|
|
|
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
|
|
|
|
|
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
|
|
|
|
|
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
|
|
|
|
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
|
|
|
|
|
|
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
|
|
|
|
|
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
|
|
|
|
|
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
|
|
|
|
|
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
|
|
|
|
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
|
|
|
|
|
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
|
|
|
|
|
|
|
|
|
|
The views and conclusions contained in the software and documentation are those
|
|
|
|
|
|
of the authors and should not be interpreted as representing official policies,
|
|
|
|
|
|
either expressed or implied, of the FreeBSD Project.
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
|
|
|
|
|
|
|
namespace MatterHackers.MatterControl
|
|
|
|
|
|
{
|
|
|
|
|
|
using System;
|
|
|
|
|
|
using System.IO;
|
2022-02-16 08:17:39 -08:00
|
|
|
|
using System.IO.Compression;
|
|
|
|
|
|
using System.Linq;
|
|
|
|
|
|
using System.Threading;
|
Move to new library model and view
- Add new listview control for library content
- Migrate library providers to containers
- Cloud, Sqlite, Directories, Queue, History
- Migrate SideBar components to containers
- Primatives, Text, Braille, ImageConverter
- Create new library container types
- Zip files, Calibration parts, Printer SDCards
- Reduce leftnav to Library, Settings, Controls, Options
- Add DragDrop support for image content
2017-05-19 22:33:55 -07:00
|
|
|
|
using MatterHackers.Agg.Image;
|
2017-08-20 02:34:39 -07:00
|
|
|
|
using MatterHackers.Agg.Platform;
|
2022-07-15 17:28:39 -07:00
|
|
|
|
using MatterHackers.Agg.UI;
|
|
|
|
|
|
using MatterHackers.DataConverters3D;
|
2020-08-29 13:39:00 -07:00
|
|
|
|
using MatterHackers.ImageProcessing;
|
2022-02-15 11:20:05 -08:00
|
|
|
|
using MatterHackers.MatterControl.DataStorage;
|
2020-08-29 13:39:00 -07:00
|
|
|
|
using MatterHackers.MatterControl.DesignTools.Operations;
|
Move to new library model and view
- Add new listview control for library content
- Migrate library providers to containers
- Cloud, Sqlite, Directories, Queue, History
- Migrate SideBar components to containers
- Primatives, Text, Braille, ImageConverter
- Create new library container types
- Zip files, Calibration parts, Printer SDCards
- Reduce leftnav to Library, Settings, Controls, Options
- Add DragDrop support for image content
2017-05-19 22:33:55 -07:00
|
|
|
|
using MatterHackers.MatterControl.Library;
|
2022-02-15 11:20:05 -08:00
|
|
|
|
using MatterHackers.PolygonMesh.Processors;
|
|
|
|
|
|
using MatterHackers.RayTracer;
|
Move to new library model and view
- Add new listview control for library content
- Migrate library providers to containers
- Cloud, Sqlite, Directories, Queue, History
- Migrate SideBar components to containers
- Primatives, Text, Braille, ImageConverter
- Create new library container types
- Zip files, Calibration parts, Printer SDCards
- Reduce leftnav to Library, Settings, Controls, Options
- Add DragDrop support for image content
2017-05-19 22:33:55 -07:00
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
2017-09-28 15:51:31 -07:00
|
|
|
|
/// Loads IObject3D objects for mesh based ILibraryItems
|
Move to new library model and view
- Add new listview control for library content
- Migrate library providers to containers
- Cloud, Sqlite, Directories, Queue, History
- Migrate SideBar components to containers
- Primatives, Text, Braille, ImageConverter
- Create new library container types
- Zip files, Calibration parts, Printer SDCards
- Reduce leftnav to Library, Settings, Controls, Options
- Add DragDrop support for image content
2017-05-19 22:33:55 -07:00
|
|
|
|
/// </summary>
|
|
|
|
|
|
public class MeshContentProvider : ISceneContentProvider
|
|
|
|
|
|
{
|
|
|
|
|
|
private static readonly bool Is32Bit = IntPtr.Size == 4;
|
|
|
|
|
|
|
2018-03-14 16:43:53 -07:00
|
|
|
|
// For 32 bit max size to ray trace is 8 MB mesh for 64 bit the max size is 40 MB.
|
2018-06-19 17:04:04 -07:00
|
|
|
|
private long MaxFileSizeForTracing => Is32Bit ? 8 * 1000 * 1000 : 16 * 1000 * 1000;
|
2018-03-14 16:43:53 -07:00
|
|
|
|
|
2018-06-19 17:04:04 -07:00
|
|
|
|
private long MaxFileSizeForThumbnail => Is32Bit ? 16 * 1000 * 1000 : 32 * 1000 * 1000;
|
2018-02-11 10:30:08 -08:00
|
|
|
|
|
2020-08-29 13:39:00 -07:00
|
|
|
|
private ThemeConfig theme = null;
|
|
|
|
|
|
|
|
|
|
|
|
private ImageBuffer defaultIcon = new ImageBuffer();
|
|
|
|
|
|
|
2022-02-10 16:39:59 -08:00
|
|
|
|
public static IObject3D LoadMCX(string filename, Action<double, string> progressReporter = null)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (File.Exists(filename)
|
|
|
|
|
|
&& Path.GetExtension(filename).ToLower() == ".mcx")
|
|
|
|
|
|
{
|
|
|
|
|
|
var stream = File.OpenRead(filename);
|
|
|
|
|
|
return LoadMCX(stream, progressReporter);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return null;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public static IObject3D LoadMCX(Stream stream, Action<double, string> progressReporter = null)
|
|
|
|
|
|
{
|
|
|
|
|
|
return Object3D.Load(stream, ".mcx", CancellationToken.None, null /*itemCache*/, progressReporter);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2017-10-13 17:46:27 -07:00
|
|
|
|
public Task<IObject3D> CreateItem(ILibraryItem item, Action<double, string> progressReporter)
|
Move to new library model and view
- Add new listview control for library content
- Migrate library providers to containers
- Cloud, Sqlite, Directories, Queue, History
- Migrate SideBar components to containers
- Primatives, Text, Braille, ImageConverter
- Create new library container types
- Zip files, Calibration parts, Printer SDCards
- Reduce leftnav to Library, Settings, Controls, Options
- Add DragDrop support for image content
2017-05-19 22:33:55 -07:00
|
|
|
|
{
|
2017-10-13 17:46:27 -07:00
|
|
|
|
return Task.Run(async () =>
|
Move to new library model and view
- Add new listview control for library content
- Migrate library providers to containers
- Cloud, Sqlite, Directories, Queue, History
- Migrate SideBar components to containers
- Primatives, Text, Braille, ImageConverter
- Create new library container types
- Zip files, Calibration parts, Printer SDCards
- Reduce leftnav to Library, Settings, Controls, Options
- Add DragDrop support for image content
2017-05-19 22:33:55 -07:00
|
|
|
|
{
|
2017-10-13 17:46:27 -07:00
|
|
|
|
IObject3D loadedItem = null;
|
Move to new library model and view
- Add new listview control for library content
- Migrate library providers to containers
- Cloud, Sqlite, Directories, Queue, History
- Migrate SideBar components to containers
- Primatives, Text, Braille, ImageConverter
- Create new library container types
- Zip files, Calibration parts, Printer SDCards
- Reduce leftnav to Library, Settings, Controls, Options
- Add DragDrop support for image content
2017-05-19 22:33:55 -07:00
|
|
|
|
|
2017-10-13 17:46:27 -07:00
|
|
|
|
try
|
Move to new library model and view
- Add new listview control for library content
- Migrate library providers to containers
- Cloud, Sqlite, Directories, Queue, History
- Migrate SideBar components to containers
- Primatives, Text, Braille, ImageConverter
- Create new library container types
- Zip files, Calibration parts, Printer SDCards
- Reduce leftnav to Library, Settings, Controls, Options
- Add DragDrop support for image content
2017-05-19 22:33:55 -07:00
|
|
|
|
{
|
2022-02-06 08:22:31 -08:00
|
|
|
|
if (item is ILibraryAssetStream streamInterface)
|
Move to new library model and view
- Add new listview control for library content
- Migrate library providers to containers
- Cloud, Sqlite, Directories, Queue, History
- Migrate SideBar components to containers
- Primatives, Text, Braille, ImageConverter
- Create new library container types
- Zip files, Calibration parts, Printer SDCards
- Reduce leftnav to Library, Settings, Controls, Options
- Add DragDrop support for image content
2017-05-19 22:33:55 -07:00
|
|
|
|
{
|
2022-02-16 08:17:39 -08:00
|
|
|
|
// If we are loding a binary MCX file, coy its assets
|
|
|
|
|
|
await CopyAssetsFromBinaryMcx(streamInterface);
|
|
|
|
|
|
|
2018-02-12 14:32:18 -08:00
|
|
|
|
using (var contentStream = await streamInterface.GetStream(progressReporter))
|
Move to new library model and view
- Add new listview control for library content
- Migrate library providers to containers
- Cloud, Sqlite, Directories, Queue, History
- Migrate SideBar components to containers
- Primatives, Text, Braille, ImageConverter
- Create new library container types
- Zip files, Calibration parts, Printer SDCards
- Reduce leftnav to Library, Settings, Controls, Options
- Add DragDrop support for image content
2017-05-19 22:33:55 -07:00
|
|
|
|
{
|
2017-10-13 17:46:27 -07:00
|
|
|
|
if (contentStream != null)
|
2022-02-16 08:17:39 -08:00
|
|
|
|
{
|
|
|
|
|
|
// TODO: Wire up caching
|
|
|
|
|
|
loadedItem = Object3D.Load(contentStream.Stream, Path.GetExtension(streamInterface.FileName), CancellationToken.None, null, progressReporter);
|
|
|
|
|
|
|
|
|
|
|
|
// Set MeshPath for non-mcx content. Avoid on mcx to ensure serialization of children
|
|
|
|
|
|
if (loadedItem != null
|
|
|
|
|
|
&& item is FileSystemFileItem fileItem
|
|
|
|
|
|
&& !string.Equals(Path.GetExtension(fileItem.FileName), ".mcx", StringComparison.OrdinalIgnoreCase))
|
2022-02-15 11:20:05 -08:00
|
|
|
|
{
|
2022-02-16 08:17:39 -08:00
|
|
|
|
loadedItem.MeshPath = fileItem.FilePath;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
Move to new library model and view
- Add new listview control for library content
- Migrate library providers to containers
- Cloud, Sqlite, Directories, Queue, History
- Migrate SideBar components to containers
- Primatives, Text, Braille, ImageConverter
- Create new library container types
- Zip files, Calibration parts, Printer SDCards
- Reduce leftnav to Library, Settings, Controls, Options
- Add DragDrop support for image content
2017-05-19 22:33:55 -07:00
|
|
|
|
}
|
2017-10-13 17:46:27 -07:00
|
|
|
|
else
|
Move to new library model and view
- Add new listview control for library content
- Migrate library providers to containers
- Cloud, Sqlite, Directories, Queue, History
- Migrate SideBar components to containers
- Primatives, Text, Braille, ImageConverter
- Create new library container types
- Zip files, Calibration parts, Printer SDCards
- Reduce leftnav to Library, Settings, Controls, Options
- Add DragDrop support for image content
2017-05-19 22:33:55 -07:00
|
|
|
|
{
|
2018-02-12 13:05:42 -08:00
|
|
|
|
var contentInterface = item as ILibraryObject3D;
|
|
|
|
|
|
loadedItem = await contentInterface?.GetObject3D(progressReporter);
|
2017-10-13 17:46:27 -07:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
catch { }
|
Move to new library model and view
- Add new listview control for library content
- Migrate library providers to containers
- Cloud, Sqlite, Directories, Queue, History
- Migrate SideBar components to containers
- Primatives, Text, Braille, ImageConverter
- Create new library container types
- Zip files, Calibration parts, Printer SDCards
- Reduce leftnav to Library, Settings, Controls, Options
- Add DragDrop support for image content
2017-05-19 22:33:55 -07:00
|
|
|
|
|
2017-10-13 20:59:58 -07:00
|
|
|
|
if (loadedItem != null)
|
|
|
|
|
|
{
|
|
|
|
|
|
// Push the original Library item name through to the IObject3D
|
|
|
|
|
|
loadedItem.Name = item.Name;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2017-10-13 17:46:27 -07:00
|
|
|
|
// Notification should force invalidate and redraw
|
|
|
|
|
|
progressReporter?.Invoke(1, "");
|
2017-07-19 07:53:05 -07:00
|
|
|
|
|
2017-10-13 17:46:27 -07:00
|
|
|
|
return loadedItem;
|
|
|
|
|
|
});
|
Move to new library model and view
- Add new listview control for library content
- Migrate library providers to containers
- Cloud, Sqlite, Directories, Queue, History
- Migrate SideBar components to containers
- Primatives, Text, Braille, ImageConverter
- Create new library container types
- Zip files, Calibration parts, Printer SDCards
- Reduce leftnav to Library, Settings, Controls, Options
- Add DragDrop support for image content
2017-05-19 22:33:55 -07:00
|
|
|
|
}
|
|
|
|
|
|
|
2022-02-16 08:17:39 -08:00
|
|
|
|
private static async Task CopyAssetsFromBinaryMcx(ILibraryAssetStream streamInterface)
|
|
|
|
|
|
{
|
|
|
|
|
|
using (var testForZipStreamAndLength = await streamInterface.GetStream(null))
|
|
|
|
|
|
{
|
|
|
|
|
|
if (Path.GetExtension(streamInterface.FileName).ToLower() == ".mcx"
|
|
|
|
|
|
&& Object3D.IsBinaryMCX(testForZipStreamAndLength.Stream))
|
|
|
|
|
|
{
|
|
|
|
|
|
using (var zipArchive = new ZipArchive(testForZipStreamAndLength.Stream, ZipArchiveMode.Read))
|
|
|
|
|
|
{
|
|
|
|
|
|
// save everything from the zip asset folder to the application asset folder
|
|
|
|
|
|
foreach (var assetItem in zipArchive.Entries.Where(i => i.FullName.Contains("Assets")))
|
|
|
|
|
|
{
|
|
|
|
|
|
using (var zipAssetStream = assetItem.Open())
|
|
|
|
|
|
{
|
|
|
|
|
|
var assetsPath = Path.Combine(ApplicationDataStorage.Instance.ApplicationLibraryDataPath, "Assets", assetItem.Name);
|
|
|
|
|
|
if (!File.Exists(assetsPath))
|
|
|
|
|
|
{
|
|
|
|
|
|
using (var fileStream = File.Create(assetsPath))
|
|
|
|
|
|
{
|
|
|
|
|
|
zipAssetStream.CopyTo(fileStream);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private static object locker = new object();
|
2021-10-19 10:19:34 -07:00
|
|
|
|
|
2018-06-20 22:22:37 -07:00
|
|
|
|
public async Task<ImageBuffer> GetThumbnail(ILibraryItem libraryItem, int width, int height)
|
Move to new library model and view
- Add new listview control for library content
- Migrate library providers to containers
- Cloud, Sqlite, Directories, Queue, History
- Migrate SideBar components to containers
- Primatives, Text, Braille, ImageConverter
- Create new library container types
- Zip files, Calibration parts, Printer SDCards
- Reduce leftnav to Library, Settings, Controls, Options
- Add DragDrop support for image content
2017-05-19 22:33:55 -07:00
|
|
|
|
{
|
|
|
|
|
|
IObject3D object3D = null;
|
|
|
|
|
|
|
2018-03-14 16:43:53 -07:00
|
|
|
|
long fileSize = 0;
|
2018-06-19 17:04:04 -07:00
|
|
|
|
if (libraryItem is ILibraryAssetStream contentModel
|
2018-06-12 21:16:26 -07:00
|
|
|
|
// Only load the stream if it's available - prevents download of Internet content simply for thumbnails
|
2017-09-28 17:36:42 -07:00
|
|
|
|
&& contentModel.LocalContentExists
|
2018-03-14 16:43:53 -07:00
|
|
|
|
&& contentModel.FileSize < MaxFileSizeForThumbnail)
|
Move to new library model and view
- Add new listview control for library content
- Migrate library providers to containers
- Cloud, Sqlite, Directories, Queue, History
- Migrate SideBar components to containers
- Primatives, Text, Braille, ImageConverter
- Create new library container types
- Zip files, Calibration parts, Printer SDCards
- Reduce leftnav to Library, Settings, Controls, Options
- Add DragDrop support for image content
2017-05-19 22:33:55 -07:00
|
|
|
|
{
|
2018-03-14 16:43:53 -07:00
|
|
|
|
fileSize = contentModel.FileSize;
|
Move to new library model and view
- Add new listview control for library content
- Migrate library providers to containers
- Cloud, Sqlite, Directories, Queue, History
- Migrate SideBar components to containers
- Primatives, Text, Braille, ImageConverter
- Create new library container types
- Zip files, Calibration parts, Printer SDCards
- Reduce leftnav to Library, Settings, Controls, Options
- Add DragDrop support for image content
2017-05-19 22:33:55 -07:00
|
|
|
|
// TODO: Wire up limits for thumbnail generation. If content is too big, return null allowing the thumbnail to fall back to content default
|
2017-10-13 17:46:27 -07:00
|
|
|
|
object3D = await contentModel.CreateContent();
|
Move to new library model and view
- Add new listview control for library content
- Migrate library providers to containers
- Cloud, Sqlite, Directories, Queue, History
- Migrate SideBar components to containers
- Primatives, Text, Braille, ImageConverter
- Create new library container types
- Zip files, Calibration parts, Printer SDCards
- Reduce leftnav to Library, Settings, Controls, Options
- Add DragDrop support for image content
2017-05-19 22:33:55 -07:00
|
|
|
|
}
|
2022-09-19 22:48:34 -07:00
|
|
|
|
else if (libraryItem is ILibraryObject3D libraryObject3D)
|
Move to new library model and view
- Add new listview control for library content
- Migrate library providers to containers
- Cloud, Sqlite, Directories, Queue, History
- Migrate SideBar components to containers
- Primatives, Text, Braille, ImageConverter
- Create new library container types
- Zip files, Calibration parts, Printer SDCards
- Reduce leftnav to Library, Settings, Controls, Options
- Add DragDrop support for image content
2017-05-19 22:33:55 -07:00
|
|
|
|
{
|
2022-09-19 22:48:34 -07:00
|
|
|
|
object3D = await libraryObject3D.GetObject3D(null);
|
Move to new library model and view
- Add new listview control for library content
- Migrate library providers to containers
- Cloud, Sqlite, Directories, Queue, History
- Migrate SideBar components to containers
- Primatives, Text, Braille, ImageConverter
- Create new library container types
- Zip files, Calibration parts, Printer SDCards
- Reduce leftnav to Library, Settings, Controls, Options
- Add DragDrop support for image content
2017-05-19 22:33:55 -07:00
|
|
|
|
}
|
|
|
|
|
|
|
2018-06-21 21:44:44 -07:00
|
|
|
|
if (object3D == null)
|
|
|
|
|
|
{
|
|
|
|
|
|
return DefaultImage;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2018-06-19 17:04:04 -07:00
|
|
|
|
string thumbnailId = libraryItem.ID;
|
|
|
|
|
|
|
2021-09-13 17:47:24 -07:00
|
|
|
|
var thumbnail = GenerateThumbnail(object3D, thumbnailId, width, height);
|
2018-06-21 21:52:01 -07:00
|
|
|
|
if (thumbnail != null)
|
|
|
|
|
|
{
|
2021-10-19 10:19:34 -07:00
|
|
|
|
lock (locker)
|
|
|
|
|
|
{
|
|
|
|
|
|
var filename = ApplicationController.Instance.Thumbnails.CachePath(object3D.MeshRenderId().ToString(), width, height);
|
|
|
|
|
|
if (!File.Exists(filename))
|
|
|
|
|
|
{
|
|
|
|
|
|
// Cache content thumbnail
|
|
|
|
|
|
ImageIO.SaveImageData(filename, thumbnail);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// Cache library thumbnail
|
|
|
|
|
|
filename = ApplicationController.Instance.Thumbnails.CachePath(libraryItem, width, height);
|
|
|
|
|
|
if (!File.Exists(filename))
|
|
|
|
|
|
{
|
|
|
|
|
|
ImageIO.SaveImageData(filename, thumbnail);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2018-06-21 21:52:01 -07:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return thumbnail ?? DefaultImage;
|
2018-06-19 17:04:04 -07:00
|
|
|
|
}
|
|
|
|
|
|
|
2018-06-21 21:48:53 -07:00
|
|
|
|
// Limit to private scope until need returns
|
2021-09-13 17:47:24 -07:00
|
|
|
|
private ImageBuffer GenerateThumbnail(IObject3D item, string thumbnailId, int width, int height)
|
2018-06-19 17:04:04 -07:00
|
|
|
|
{
|
|
|
|
|
|
if (item == null)
|
|
|
|
|
|
{
|
2018-06-20 22:53:47 -07:00
|
|
|
|
return DefaultImage;
|
2018-06-19 17:04:04 -07:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
int estimatedMemorySize = item.EstimatedMemory();
|
|
|
|
|
|
if (estimatedMemorySize > MaxFileSizeForThumbnail)
|
|
|
|
|
|
{
|
2018-06-21 09:02:31 -07:00
|
|
|
|
return DefaultImage;
|
2018-06-19 17:04:04 -07:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool forceOrthographic = false;
|
|
|
|
|
|
if (estimatedMemorySize > MaxFileSizeForTracing)
|
|
|
|
|
|
{
|
|
|
|
|
|
forceOrthographic = true;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool RenderOrthographic = (forceOrthographic) ? true : UserSettings.Instance.ThumbnailRenderingMode == "orthographic";
|
|
|
|
|
|
|
2018-06-21 21:51:09 -07:00
|
|
|
|
return ThumbnailEngine.Generate(
|
2018-06-19 17:04:04 -07:00
|
|
|
|
item,
|
|
|
|
|
|
RenderOrthographic ? RenderType.ORTHOGROPHIC : RenderType.RAY_TRACE,
|
|
|
|
|
|
width,
|
|
|
|
|
|
height,
|
2018-11-11 13:45:48 -08:00
|
|
|
|
allowMultiThreading: !ApplicationController.Instance.AnyPrintTaskRunning);
|
2018-06-19 17:04:04 -07:00
|
|
|
|
}
|
2018-06-14 15:19:36 -07:00
|
|
|
|
|
2020-08-29 13:39:00 -07:00
|
|
|
|
public ImageBuffer DefaultImage
|
|
|
|
|
|
{
|
|
|
|
|
|
get
|
|
|
|
|
|
{
|
|
|
|
|
|
// Ensure icon is reloaded after theme change
|
|
|
|
|
|
if (theme != AppContext.Theme)
|
|
|
|
|
|
{
|
|
|
|
|
|
theme = AppContext.Theme;
|
|
|
|
|
|
|
2021-05-21 15:23:25 -07:00
|
|
|
|
defaultIcon = StaticData.Instance.LoadIcon("mesh.png").SetToColor(theme.TextColor); //.AnyAlphaToColor(theme.PrimaryAccentColor);
|
2020-08-29 13:39:00 -07:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return defaultIcon;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
Move to new library model and view
- Add new listview control for library content
- Migrate library providers to containers
- Cloud, Sqlite, Directories, Queue, History
- Migrate SideBar components to containers
- Primatives, Text, Braille, ImageConverter
- Create new library container types
- Zip files, Calibration parts, Printer SDCards
- Reduce leftnav to Library, Settings, Controls, Options
- Add DragDrop support for image content
2017-05-19 22:33:55 -07:00
|
|
|
|
}
|
|
|
|
|
|
}
|