Skip to content

Commit

Permalink
don't create view for Real Molecules screen, #65
Browse files Browse the repository at this point in the history
  • Loading branch information
pixelzoom committed Jul 19, 2017
1 parent 0bbc5d6 commit 44f4feb
Showing 1 changed file with 101 additions and 101 deletions.
202 changes: 101 additions & 101 deletions js/realmolecules/view/RealMoleculesScreenView.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,112 +35,112 @@ define( function( require ) {
*/
function RealMoleculesScreenView( model ) {

var self = this;

ScreenView.call( this, MPConstants.SCREEN_VIEW_OPTIONS );

// view-specific Properties
var viewProperties = new RealMoleculesViewProperties();

// @private
this.moleculeViewer = new RealMoleculeViewer( model.moleculeProperty, viewProperties, {
viewerFill: MPColors.SCREEN_BACKGROUND,
viewerSize: new Dimension2( 450, 450 )
} );

var electronegativityTableNode = new ElectronegativityTableNode( this.moleculeViewer );
var comboBoxListParent = new Node();
var moleculesComboBox = new RealMoleculesComboBox( model.molecules, model.moleculeProperty, comboBoxListParent );

var electrostaticPotentialColorKey = new Node();

// unlink not needed
MPConstants.GLOBAL_OPTIONS.surfaceColorProperty.link( function( surfaceType ) {
electrostaticPotentialColorKey.removeAllChildren();
if ( surfaceType === 'RWB' ) {
electrostaticPotentialColorKey.addChild( SurfaceColorKey.createElectrostaticPotentialRWBColorKey() );
}
else {
electrostaticPotentialColorKey.addChild( SurfaceColorKey.createElectrostaticPotentialROYGBColorKey() );
}
} );

var electronDensityColorKey = SurfaceColorKey.createElectronDensityColorKey();

var controlPanel = new MPControlPanel( [
new RealMoleculesViewControls( viewProperties ),
new SurfaceTypeControl( viewProperties.surfaceTypeProperty )
] );

var resetAllButton = new ResetAllButton( {
listener: function() {
self.interruptSubtreeInput();
model.reset();
viewProperties.reset();
},
scale: 1.32
} );

// Parent for all nodes added to this screen
var rootNode = new Node( {
children: [
this.moleculeViewer,
electronegativityTableNode,
moleculesComboBox,
controlPanel,
electrostaticPotentialColorKey,
electronDensityColorKey,
resetAllButton,
comboBoxListParent // last, so that combo box list is on top
]
} );

// layout ---------------------------------

this.moleculeViewer.left = 100;

// centered above viewer
electronegativityTableNode.centerX = this.moleculeViewer.centerX;
electronegativityTableNode.top = this.layoutBounds.top + 25;

// centered below electronegativity table
electrostaticPotentialColorKey.centerX = electronDensityColorKey.centerX = electronegativityTableNode.centerX;
electrostaticPotentialColorKey.top = electronDensityColorKey.top = electronegativityTableNode.bottom + 15;

// below color keys
this.moleculeViewer.top = electrostaticPotentialColorKey.bottom + 15;

// centered below viewer
moleculesComboBox.centerX = this.moleculeViewer.centerX;
moleculesComboBox.top = this.moleculeViewer.bottom + 15;

// right of viewer
controlPanel.left = this.moleculeViewer.right + 100;
controlPanel.centerY = this.layoutBounds.centerY;

// bottom-right corner of the screen
resetAllButton.right = this.layoutBounds.right - 40;
resetAllButton.bottom = this.layoutBounds.bottom - 20;

// synchronization with view Properties ------------------------------

// unlink not needed
viewProperties.atomElectronegativitiesVisibleProperty.link( function( visible ) {
electronegativityTableNode.visible = visible;
} );

// unlink not needed
viewProperties.surfaceTypeProperty.link( function( surfaceType ) {
electrostaticPotentialColorKey.visible = ( surfaceType === SurfaceType.ELECTROSTATIC_POTENTIAL );
electronDensityColorKey.visible = ( surfaceType === SurfaceType.ELECTRON_DENSITY );
} );

//TODO Hide everything and show a dialog until Real Molecules screen is fully implemented, see #32
if ( MPQueryParameters.realMolecules ) {
this.addChild( rootNode );
if ( !MPQueryParameters.realMolecules ) {
this.addChild( new UnderDevelopmentPlane( this.layoutBounds ) );
}
else {
this.addChild( new UnderDevelopmentPlane( this.layoutBounds ) );

var self = this;

// view-specific Properties
var viewProperties = new RealMoleculesViewProperties();

// @private
this.moleculeViewer = new RealMoleculeViewer( model.moleculeProperty, viewProperties, {
viewerFill: MPColors.SCREEN_BACKGROUND,
viewerSize: new Dimension2( 450, 450 )
} );

var electronegativityTableNode = new ElectronegativityTableNode( this.moleculeViewer );
var comboBoxListParent = new Node();
var moleculesComboBox = new RealMoleculesComboBox( model.molecules, model.moleculeProperty, comboBoxListParent );

var electrostaticPotentialColorKey = new Node();

// unlink not needed
MPConstants.GLOBAL_OPTIONS.surfaceColorProperty.link( function( surfaceType ) {
electrostaticPotentialColorKey.removeAllChildren();
if ( surfaceType === 'RWB' ) {
electrostaticPotentialColorKey.addChild( SurfaceColorKey.createElectrostaticPotentialRWBColorKey() );
}
else {
electrostaticPotentialColorKey.addChild( SurfaceColorKey.createElectrostaticPotentialROYGBColorKey() );
}
} );

var electronDensityColorKey = SurfaceColorKey.createElectronDensityColorKey();

var controlPanel = new MPControlPanel( [
new RealMoleculesViewControls( viewProperties ),
new SurfaceTypeControl( viewProperties.surfaceTypeProperty )
] );

var resetAllButton = new ResetAllButton( {
listener: function() {
self.interruptSubtreeInput();
model.reset();
viewProperties.reset();
},
scale: 1.32
} );

// Parent for all nodes added to this screen
var rootNode = new Node( {
children: [
this.moleculeViewer,
electronegativityTableNode,
moleculesComboBox,
controlPanel,
electrostaticPotentialColorKey,
electronDensityColorKey,
resetAllButton,
comboBoxListParent // last, so that combo box list is on top
]
} );
this.addChild( rootNode );

// layout ---------------------------------

this.moleculeViewer.left = 100;

// centered above viewer
electronegativityTableNode.centerX = this.moleculeViewer.centerX;
electronegativityTableNode.top = this.layoutBounds.top + 25;

// centered below electronegativity table
electrostaticPotentialColorKey.centerX = electronDensityColorKey.centerX = electronegativityTableNode.centerX;
electrostaticPotentialColorKey.top = electronDensityColorKey.top = electronegativityTableNode.bottom + 15;

// below color keys
this.moleculeViewer.top = electrostaticPotentialColorKey.bottom + 15;

// centered below viewer
moleculesComboBox.centerX = this.moleculeViewer.centerX;
moleculesComboBox.top = this.moleculeViewer.bottom + 15;

// right of viewer
controlPanel.left = this.moleculeViewer.right + 100;
controlPanel.centerY = this.layoutBounds.centerY;

// bottom-right corner of the screen
resetAllButton.right = this.layoutBounds.right - 40;
resetAllButton.bottom = this.layoutBounds.bottom - 20;

// synchronization with view Properties ------------------------------

// unlink not needed
viewProperties.atomElectronegativitiesVisibleProperty.link( function( visible ) {
electronegativityTableNode.visible = visible;
} );

// unlink not needed
viewProperties.surfaceTypeProperty.link( function( surfaceType ) {
electrostaticPotentialColorKey.visible = ( surfaceType === SurfaceType.ELECTROSTATIC_POTENTIAL );
electronDensityColorKey.visible = ( surfaceType === SurfaceType.ELECTRON_DENSITY );
} );
}
}

Expand Down

0 comments on commit 44f4feb

Please sign in to comment.