Skip to content

Commit

Permalink
Merge pull request root-project#34 from alja/reve-selection
Browse files Browse the repository at this point in the history
Reduce updates from client to server and redraws
  • Loading branch information
alja authored Apr 23, 2019
2 parents 122d471 + da48c48 commit 06d7cf6
Show file tree
Hide file tree
Showing 8 changed files with 485 additions and 201 deletions.
21 changes: 21 additions & 0 deletions js/scripts/JSRoot3DPainter.js
Original file line number Diff line number Diff line change
Expand Up @@ -503,6 +503,27 @@
}

control.MainProcessMouseMove = function(evnt) {
// check timeout
var toutval = 100;

// first time
var dt = new Date();
if (!this.mouse_tmout) {
this.mouse_tmout = setTimeout(this.MainProcessMouseMove.bind(this,evnt), toutval);
this.tt = dt.getTime();
return;
}
else {
var tdiff = dt.getTime() - this.tt;
if (tdiff < toutval) {
clearTimeout(this.mouse_tmout);
this.mouse_tmout = setTimeout(this.MainProcessMouseMove.bind(this,evnt), tdiff);
return;
}
}
this.tt = dt.getTime();
//console.log("control.MainProcessMouseMove");

if (this.control_active && evnt.buttons && (evnt.buttons & 2))
this.block_ctxt = true; // if right button in control was active, block next context menu

Expand Down
19 changes: 19 additions & 0 deletions js/scripts/JSRootGeoPainter.js
Original file line number Diff line number Diff line change
Expand Up @@ -1915,6 +1915,24 @@
this._effectComposer = new THREE.EffectComposer( this._renderer );
this._effectComposer.addPass( new THREE.RenderPass( this._scene, this._camera ) );

this._outlinePass = new THREE.OutlinePass( new THREE.Vector2( w, h ), this._scene, this._camera );
this._outlinePass.edgeStrength = 7.5;
this._outlinePass.edgeGlow = 0.5;
this._outlinePass.edgeThickness = 1.0;
this._outlinePass.usePatternTexture = false;
this._outlinePass.downSampleRatio = 2;

const sh = THREE.OutlinePass.selection_enum["select"]; // doesnt stand for spherical harmonics :P
THREE.OutlinePass.selection_atts[sh].visibleEdgeColor.set('#dd1111');
THREE.OutlinePass.selection_atts[sh].hiddenEdgeColor.set('#1111dd');

this._effectComposer.addPass( this._outlinePass );

this._effectFXAA = new THREE.ShaderPass( THREE.FXAAShader );
this._effectFXAA.uniforms[ 'resolution' ].value.set( 1 / w, 1 / h );
this._effectFXAA.renderToScreen = true;
this._effectComposer.addPass( this._effectFXAA );

if (this._enableSSAO)
this.createSSAO();

Expand Down Expand Up @@ -3574,6 +3592,7 @@
this._camera.updateProjectionMatrix();
this._renderer.setSize( this._scene_width, this._scene_height, !this._fit_main_area );
this._effectComposer.setSize( this._scene_width, this._scene_height );
this._effectFXAA.uniforms[ 'resolution' ].value.set( 1 / this._scene_width, 1 / this._scene_height );

if (!this.drawing_stage) this.Render3D();
}
Expand Down
38 changes: 26 additions & 12 deletions tutorials/eve7/lineset.C
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/// \file
/// \ingroup tutorial_eve7
/// \ingroup tutorial_eve
/// Demonstrates usage of class REveStraightLineSet.
///
/// \macro_code
Expand All @@ -15,29 +15,43 @@
//#include <ROOT/REveJetCone.hxx>
namespace REX = ROOT::Experimental;

void lineset(Int_t nlines = 40, Int_t nmarkers = 4)
{
auto eveMng = REX::REveManager::Create();

REX::REveStraightLineSet* makeLineSet(Int_t nlines = 40, Int_t nmarkers = 4)
{
TRandom r(0);
Float_t s = 100;

auto ls = new REX::REveStraightLineSet();
ls->SetMainColor(kBlue);
ls->SetMarkerColor(kRed);

for (Int_t i = 0; i < nlines; i++) {
for (Int_t i = 0; i<nlines; i++) {
ls->AddLine( r.Uniform(-s,s), r.Uniform(-s,s), r.Uniform(-s,s),
r.Uniform(-s,s), r.Uniform(-s,s), r.Uniform(-s,s));
// add random number of markers
Int_t nm = Int_t(nmarkers* r.Rndm());
for (Int_t m = 0; m < nm; m++)
ls->AddMarker(i, r.Rndm());
for (Int_t m = 0; m < nm; m++) ls->AddMarker(i, r.Rndm());
}

ls->SetMarkerSize(1.5);
ls->SetMarkerStyle(4);
eveMng->GetEventScene()->AddElement(ls);
ls->SetMarkerSize(0.5);
ls->SetMarkerStyle(1);
REX::gEve->GetEventScene()->AddElement(ls);

return ls;
}

void lineset()
{
auto eveMng = REX::REveManager::Create();

auto ls1 = makeLineSet(10, 50);
ls1->SetMainColor(kViolet);
ls1->SetName("LineSet_1");

auto ls2 = makeLineSet(3, 4);
ls2->SetMainColor(kBlue);
ls2->SetName("LineSet_2");
//ls2->InitMainTrans();
// ls2->RefMainTrans().Move3LF(40, 100, 100);


eveMng->Show();
}
67 changes: 47 additions & 20 deletions ui5/eve7/controller/GL.controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -295,7 +295,8 @@ sap.ui.define([


var options = "";
if (this.kind != "3D") options = "ortho_camera";
// options += " black, ";
if (this.kind != "3D") options += "ortho_camera";


// TODO: should be specified somehow in XML file
Expand All @@ -321,28 +322,55 @@ sap.ui.define([
this.geo_painter._camera.bottom = -this.getView().$().height();
this.geo_painter._camera.updateProjectionMatrix();
}
painter._controls.ProcessMouseMove = function(intersects) {
var active_mesh = null, tooltip = null, resolve = null, names = [], geo_object, geo_index;

// try to find mesh from intersections
for (var k=0;k<intersects.length;++k) {
var obj = intersects[k].object, info = null;
if (!obj) continue;
if (obj.geo_object) info = obj.geo_name; else
if (obj.stack) info = painter.GetStackFullName(obj.stack);
if (info===null) continue;

if (info.indexOf("<prnt>")==0)
info = painter.GetItemName() + info.substr(6);

names.push(info);

if (!active_mesh) {
active_mesh = obj;
tooltip = info;
geo_object = obj.geo_object;
if (obj.get_ctrl) {
geo_index = obj.get_ctrl().extractIndex(intersects[k]);
if ((geo_index !== undefined) && (typeof tooltip == "string")) tooltip += " indx:" + JSON.stringify(geo_index);
}
if (active_mesh.stack) resolve = painter.ResolveStack(active_mesh.stack);
}
}

//painter.HighlightMesh(active_mesh, undefined, geo_object, geo_index); AMT override
if (active_mesh && active_mesh.get_ctrl()) active_mesh.get_ctrl().setHighlight( 0xffaa33, geo_index);

if (painter.options.update_browser) {
if (painter.options.highlight && tooltip) names = [ tooltip ];
painter.ActivateInBrowser(names);
}

if (!resolve || !resolve.obj) return tooltip;

var lines = JSROOT.GEO.provideInfo(resolve.obj);
lines.unshift(tooltip);

return { name: resolve.obj.fName, title: resolve.obj.fTitle || resolve.obj._typename, lines: lines };
}

// this.geo_painter._highlight_handlers = [ this ]; // register ourself for highlight handling
this.last_highlight = null;

this.composer = this.geo_painter._effectComposer;
let width = this.geo_painter._scene_width;
let height = this.geo_painter._scene_height;

this.outlinePass = new THREE.OutlinePass( new THREE.Vector2( width, height ), this.geo_painter._scene, this.geo_painter._camera );
this.outlinePass.edgeStrength = 7.5;
this.outlinePass.edgeGlow = 0.5;
this.outlinePass.edgeThickness = 1.0;
this.outlinePass.usePatternTexture = false;
this.outlinePass.downSampleRatio = 2;
this.outlinePass.visibleEdgeColor.set('#dd1111');
this.outlinePass.hiddenEdgeColor.set('#1111dd');
this.composer.addPass( this.outlinePass );

this.effectFXAA = new THREE.ShaderPass( THREE.FXAAShader );
this.effectFXAA.uniforms[ 'resolution' ].value.set( 1 / width, 1 / height );
this.effectFXAA.renderToScreen = true;
this.composer.addPass( this.effectFXAA );
// outlinePass passthrough
this.outlinePass = this.geo_painter._outlinePass;

// create only when geo painter is ready
this.createScenes();
Expand All @@ -364,7 +392,6 @@ sap.ui.define([
this.getView().$().css("overflow", "hidden").css("width", "100%").css("height", "100%");
if (this.geo_painter){
this.geo_painter.CheckResize();
this.effectFXAA.uniforms[ 'resolution' ].value.set( 1 / this.geo_painter._scene_width, 1 / this.geo_painter._scene_height );
}
}

Expand Down
8 changes: 5 additions & 3 deletions ui5/eve7/lib/EveElements.js
Original file line number Diff line number Diff line change
Expand Up @@ -573,7 +573,7 @@ sap.ui.define(['rootui5/eve7/lib/EveManager'], function(EveManager) {
var color = JSROOT.Painter.root_colors[m.eve_el.fMainColor];
var lineMaterial = new THREE.LineBasicMaterial({ color: color, linewidth: 4 });
var line = new THREE.LineSegments(geom, lineMaterial);
dest.add(line);
dest.push(line);

var el = m.eve_el, mindx = []

Expand All @@ -592,7 +592,8 @@ sap.ui.define(['rootui5/eve7/lib/EveManager'], function(EveManager) {

if (mindx.length > 0)
{
var pnts = new JSROOT.Painter.PointsCreator(mindx.length, true, 5);
let mark_size = 5;
var pnts = new JSROOT.Painter.PointsCreator(mindx.length, true, mark_size);

var arr = m.children[1].geometry.getAttribute("position").array;

Expand All @@ -602,7 +603,8 @@ sap.ui.define(['rootui5/eve7/lib/EveManager'], function(EveManager) {
pnts.AddPoint(arr[p], arr[p+1], arr[p+2] );
}
var mark = pnts.CreatePoints(color);
dest.add(mark);
mark.material.size = mark_size;
dest.push(mark);
}

}
Expand Down
Loading

0 comments on commit 06d7cf6

Please sign in to comment.