Skip to content

Commit

Permalink
Fix loading of STL files
Browse files Browse the repository at this point in the history
  • Loading branch information
martinRenou committed Oct 23, 2024
1 parent d4b2c55 commit 7878150
Showing 1 changed file with 16 additions and 5 deletions.
21 changes: 16 additions & 5 deletions python/jupytercad_core/src/stlplugin/modelfactory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,22 @@ import { IJupyterCadDoc, JupyterCadModel } from '@jupytercad/schema';
import { DocumentRegistry } from '@jupyterlab/docregistry';
import { Contents } from '@jupyterlab/services';

class JupyterCadSTLModel extends JupyterCadModel {

fromString(data: string): void {
this.sharedModel.transact(() => {
this.sharedModel.setSource(data);
});
this.dirty = true;
}

}

/**
* A Model factory to create new instances of JupyterCadModel.
* A Model factory to create new instances of JupyterCadSTLModel.
*/
export class JupyterCadStlModelFactory
implements DocumentRegistry.IModelFactory<JupyterCadModel>
implements DocumentRegistry.IModelFactory<JupyterCadSTLModel>
{
/**
* Whether the model is collaborative or not.
Expand Down Expand Up @@ -68,14 +79,14 @@ export class JupyterCadStlModelFactory
}

/**
* Create a new instance of JupyterCadModel.
* Create a new instance of JupyterCadSTLModel.
*
* @returns The model
*/
createNew(
options: DocumentRegistry.IModelOptions<IJupyterCadDoc>
): JupyterCadModel {
const model = new JupyterCadModel({
): JupyterCadSTLModel {
const model = new JupyterCadSTLModel({
sharedModel: options.sharedModel,
languagePreference: options.languagePreference
});
Expand Down

0 comments on commit 7878150

Please sign in to comment.