Skip to content

Commit

Permalink
Merge pull request #104 in STRUC/icn3d from release252b to master
Browse files Browse the repository at this point in the history
* commit 'b9d7a86c7718dccb8ac199f20c8187d4a4a3b864':
  The style Lines was fixed by replacing THREE.Line with THREE.LineSegments
  The style Lines was fixed by replacing THREE.Line with THREE.LineSegments
  The style Lines was fixed by replacing THREE.Line with THREE.LineSegments
  • Loading branch information
jiywang3 committed Mar 5, 2019
2 parents bb29479 + b9d7a86 commit 8dc6140
Show file tree
Hide file tree
Showing 3 changed files with 1,098 additions and 1 deletion.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ See the [help page](https://www.ncbi.nlm.nih.gov/Structure/icn3d/docs/icn3d_help

iCn3D can be embedded in a web page by including the URL in HTML iframe, e.g. <iframe src="https://www.ncbi.nlm.nih.gov/Structure/icn3d/full.html?mmdbid=1tup&showanno=1&show2d=1&showsets=1&width=800&height=450&showmenu=1&showcommand=1&rotate=right" width="900" height="600" style="border:none"></iframe>. This method always shows the most recent version of iCn3D.

To embed iCn3D with JavaScript libraries, the following libraries need to be included: jQuery, jQuery UI, Three.js, and iCn3D library. An html div tag to hold the 3D viewer is added: "<div id='icn3dwrap'></div>". The iCn3D widget is initialized with the custom defined parameter "cfg": "var icn3dui = new iCn3DUI(cfg); icn3dui.show3DStructure();". Multiple iCn3D widgets can be embedded in a single page.
To embed iCn3D with JavaScript libraries, the following libraries need to be included: jQuery, jQuery UI, Three.js, and iCn3D library. An html div tag to hold the 3D viewer is added. The iCn3D widget is initialized with the custom defined parameter "cfg": "var icn3dui = new iCn3DUI(cfg); icn3dui.show3DStructure();". Multiple iCn3D widgets can be embedded in a single page.

Users can choose to show the most recent version of iCn3D, or a locked version of iCn3D. To show the most recent version, use the library files without the version postfix as shown in the [iCn3D Web API page] (https://www.ncbi.nlm.nih.gov/Structure/icn3d/icn3d.html#HowToUse). To show a locked version, use the library files with the version postfix as shown in the source code of [iCn3D page] (https://www.ncbi.nlm.nih.gov/Structure/icn3d/full.html?mmdbid=1tup). If the input is provided as an MMDB ID, both library files and backend cgis are versioned so that the 3D display will be stable.

Expand Down
99 changes: 99 additions & 0 deletions src/icn3dui/highlight/hl_update_simple.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
/**
* @author Jiyao Wang <wangjiy@ncbi.nlm.nih.gov> / https://github.com/ncbi/icn3d
*/

iCn3DUI.prototype.removeHlAll = function() { var me = this;
me.removeHlObjects();
};

iCn3DUI.prototype.removeHlObjects = function() { var me = this;
me.icn3d.removeHlObjects();
};

iCn3DUI.prototype.updateHlAll = function(commandnameArray, bSetMenu, bUnion) { var me = this;
me.updateHlObjects();
};

iCn3DUI.prototype.updateHlObjects = function() { var me = this;
me.icn3d.removeHlObjects();
me.icn3d.addHlObjects();
};

iCn3DUI.prototype.toggleHighlight = function() { var me = this;
//me.setLogCmd("toggle highlight", true);

if(me.icn3d.prevHighlightObjects.length > 0 || me.icn3d.prevHighlightObjects_ghost.length > 0) { // remove
me.clearHighlight();
}
else { // add
me.showHighlight();
}

me.setLogCmd("toggle highlight", true);
};

iCn3DUI.prototype.clearHighlight = function() { var me = this;
me.icn3d.labels['picking']=[];
me.icn3d.draw();

me.icn3d.removeHlObjects();
me.icn3d.render();
};

iCn3DUI.prototype.showHighlight = function() { var me = this;
me.icn3d.addHlObjects();
me.updateHlAll();
//me.bSelectResidue = true;
};

iCn3DUI.prototype.selectAChain = function (chainid, commandname, bAlign, bUnion) { var me = this;
var commandname = commandname.replace(/\s/g, '');
var command = 'select chain ' + chainid;

//var residueHash = {}, chainHash = {};

if(bUnion === undefined || !bUnion) {
me.icn3d.hAtoms = {};
me.menuHlHash = {};
}
else {
me.icn3d.hAtoms = me.icn3d.unionHash(me.icn3d.hAtoms, me.icn3d.chains[chainid]);

if(me.menuHlHash === undefined) me.menuHlHash = {};
}

me.menuHlHash[chainid] = 1;

//chainHash[chainid] = 1;

var chnsSeq = (bAlign) ? me.icn3d.alnChainsSeq[chainid] : me.icn3d.chainsSeq[chainid];

var oriResidueHash = {};
for(var i = 0, il = chnsSeq.length; i < il; ++i) { // get residue number
var resObj = chnsSeq[i];
var residueid = chainid + "_" + resObj.resi;

var value = resObj.name;

if(value !== '' && value !== '-') {
oriResidueHash[residueid] = 1;
for(var j in me.icn3d.residues[residueid]) {
me.icn3d.hAtoms[j] = 1;
}
}
}

if((me.icn3d.defNames2Atoms === undefined || !me.icn3d.defNames2Atoms.hasOwnProperty(chainid)) && (me.icn3d.defNames2Residues === undefined || !me.icn3d.defNames2Residues.hasOwnProperty(chainid)) ) {
me.addCustomSelection(Object.keys(oriResidueHash), commandname, commandname, command, true);
}

if(bAlign) {
me.updateHlAll(undefined, undefined, bUnion);
}
else {
me.updateHlAll(Object.keys(me.menuHlHash), undefined, bUnion);
}

// me.icn3d.addHlObjects();
// me.updateHl2D(Object.keys(chainHash));
};
Loading

0 comments on commit 8dc6140

Please sign in to comment.