Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/vfb loader #547

Merged
merged 2 commits into from
May 11, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions actions/generals.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ export const VFB_ERROR = 'VFB_ERROR';
export const VFB_LOAD_ID = 'VFB_LOAD_ID';
export const VFB_ID_LOADED = 'VFB_ID_LOADED';
export const VFB_UI_UPDATED = 'VFB_UI_UPDATED';
export const INSTANCE_ADDED = 'INSTANCE_ADDED'

export const vfbError = errorMessage => ({
type: VFB_ERROR,
Expand All @@ -26,3 +27,8 @@ export const vfbUIUpdated = layout => ({
type: VFB_UI_UPDATED,
data: layout
});

export const instanceAdded = instance => ({
type: INSTANCE_ADDED,
data: instance
});
23 changes: 14 additions & 9 deletions components/VFBMain.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ export default class VFBMain extends React.Component {
quickHelpVisible: undefined,
UIUpdated: false,
htmlFromToolbar: undefined,
idOnFocus: undefined,
instanceOnFocus: undefined,
idSelected: undefined,
};
Expand Down Expand Up @@ -76,10 +75,10 @@ export default class VFBMain extends React.Component {
this.idOnFocus = undefined;
this.instanceOnFocus = undefined;
this.idFromURL = undefined;
this.firstLoad = true;
this.idsFromURL = [];
this.urlQueryLoader = undefined;
this.quickHelpRender = undefined;
this.firstLoad = true;

this.UIElementsVisibility = {};

Expand Down Expand Up @@ -229,13 +228,9 @@ export default class VFBMain extends React.Component {
continue;
}
if (this.hasVisualType(variableIds[singleId])) {
this.handlerInstanceUpdate(Instances[variableIds[singleId]]);
/*
* FIXME: the handlerInstanceUpdate above has been placed there to provide the meta data earlier
* and avoid to wait for the 3d viewer and slice to be loaded before to display the data
* we need to edit the callback passed to resolve3d here below to avoid the double switching
* with the metadata.
*/
if (!this.firstLoad) {
this.handlerInstanceUpdate(meta);
}
this.resolve3D(variableIds[singleId], function (id) {
var instance = Instances.getInstance(id);
GEPPETTO.SceneController.deselectAll();
Expand Down Expand Up @@ -751,6 +746,7 @@ export default class VFBMain extends React.Component {
name={"Canvas"}
baseZoom="1.2"
wireframeEnabled={true}
minimiseAnimation={false}
onLoad={this.ThreeDViewerIdLoaded}
ref={ref => this.canvasReference = ref} />)
} else if (component === "termInfo") {
Expand Down Expand Up @@ -1030,6 +1026,11 @@ export default class VFBMain extends React.Component {
}

var that = this;

GEPPETTO.on(GEPPETTO.Events.Instance_added, function (instance) {
that.props.instanceAdded(instance);
});

GEPPETTO.on(GEPPETTO.Events.Model_loaded, function () {
that.addVfbId(that.idsFinalList);

Expand Down Expand Up @@ -1178,18 +1179,22 @@ export default class VFBMain extends React.Component {
*/
for (var counter = 0; counter < this.idsFromURL.length; counter++) {
if (this.idsFromURL[counter] === this.idOnFocus && this.idFromURL !== this.idOnFocus) {
this.TermInfoIdLoaded(this.idOnFocus);
this.idsFromURL.splice(counter, 1);
return;
}
if (this.idsFromURL[counter] === this.idOnFocus && this.idFromURL === this.idOnFocus) {
this.idsFromURL.splice(counter, 1);
this.firstLoad = false;
break;
}
}

// Update the term info component
if (this.termInfoReference !== undefined && this.termInfoReference !== null) {
this.termInfoReference.setTermInfo(this.instanceOnFocus, this.idOnFocus);
} else {
this.TermInfoIdLoaded(this.idOnFocus);
}

// Update the tree browser
Expand Down
Loading