]> Creatis software - creaWT.git/blobdiff - wt/bbtk_wt_PKG/src/bbwtViewerNVWeb.cxx
#2691 creaWT Feature New Normal - Implementation temp files
[creaWT.git] / wt / bbtk_wt_PKG / src / bbwtViewerNVWeb.cxx
index 34c75e619eecc69d7a210fc5869fe87da7d3bdad..8fa80e4ef377bcbac25cb308f8b53f3b27024291 100644 (file)
@@ -82,265 +82,80 @@ BBTK_BLACK_BOX_IMPLEMENTATION(ViewerNVWeb,bbtk::WtBlackBox);
 //===== 
 // Before editing this file, make sure it's a file of your own (i.e.: it wasn't generated from xml description; if so : your modifications will be lost)
 //===== 
-/*void ViewerNVWeb::Process()
-{
 
-  //------------- This part works perfectly, uncomment it for use it safe
 
-  /*Wt::WContainerWidget* w = (Wt::WContainerWidget*)bbGetOutputWidget();
 
-       cont++;
-       std::string jsCom;
-       
 
-               
-        //jsCom = "\
-                      " + wtWindow1->jsRef() + ".mRenderer.add(" +bbGetInputImagePath() + ".mObject);\
-                      " + wtWindow1->jsRef() + ".mRenderer.render();";
-
-       std::cout<<std::endl;
-       std::cout<<std::endl;
-       std::cout<<std::endl;
-       std::cout<<std::endl;
-       std::cout<<"CADENA -- "<<std::endl;
-       std::cout<<jsCom<<std::endl;
-
- //jsCom = "\
-                       var volume = new X.volume();\
-                       volume.file = '" + bbGetInputImagePath() + "';\
-                       " + wtWindow1->jsRef() + ".mRenderer.add(volume);\
-                       " + wtWindow1->jsRef() + ".mRenderer.render();";
-  
-  
- jsCom = "\
-                       var volume = new X.volume();\
-                       volume.file = '" + bbGetInputImagePath() + "';\
-                                                                       " + w->jsRef() +".mVolume = volume;\
-                       " + wtWindow1->jsRef() + ".mRenderer.add(" +w->jsRef() + ".mVolume);\
-                       " + wtWindow1->jsRef() + ".mRenderer.render();";
-
-
-  if(nType.size() >1)
-       {
-               jsCom = jsCom + "\
-                       " + wtWindow2->jsRef() + ".mRenderer.add(" +w->jsRef() + ".mVolume);\
-                       " + wtWindow2->jsRef() + ".mRenderer.render();";
-       }
-  if(nType.size() >2 )
-       {
-               jsCom = jsCom + "\
-                       " + wtWindow3->jsRef() + ".mRenderer.add(" +w->jsRef() + ".mVolume);\
-                       " + wtWindow3->jsRef() + ".mRenderer.render();";
-       }
-       if(nType.size() > 3)
-       {
-               jsCom = jsCom + "\
-                       " + wtWindow4->jsRef() + ".mRenderer.add(" +w->jsRef() + ".mVolume);\
-                       " + wtWindow4->jsRef() + ".mRenderer.render();";
-       }
-
-  
-
-
-       std::cout<<"PROCESSSSS>>>>"<<jsCom<<std::endl;
-       w->doJavaScript(jsCom);
-  */
-  
- /* Wt::WContainerWidget* w = (Wt::WContainerWidget*)bbGetOutputWidget();
+//--------------------------------------------------------------------------------------------------------
+void ViewerNVWeb::Process()
+{
+       printf("EED ViewerNVWeb::Process start\n ");
 
-       cont++;
+       Wt::WContainerWidget* w = (Wt::WContainerWidget*)bbGetOutputWidget();
        std::string jsCom;
        
-  std::cout<<"Process ----"<<std::endl; 
-
-  //if(cont ==1) 
- // {
-  
-      jsCom = "\
+       //jsCom = "\
                        var volume = new X.volume();\
                        volume.spacing = [0.7,0.7,0.7 ];\
-                       volume.center = [0,0,0];\
                        volume.file = '" + bbGetInputImagePath() + "';\
-                                                                       " + w->jsRef() +".mVolume = volume;\
-                       " + wtWindow1->jsRef() + ".mRenderer.add(" +w->jsRef() + ".mVolume);\
-                       " + wtWindow1->jsRef() + ".mRenderer.render();";
-                       
-        //   jsCom = jsCom + "\
-                     var gui = new dat.GUI();\
-                var volumegui = gui.addFolder('Volume');\
-                var vrController = volumegui.add(volume, 'volumeRendering');\
-                var opacityController = volumegui.add(volume, 'opacity', 0, 1).listen();\
-                var lowerThresholdController = volumegui.add(volume, 'lowerThreshold',volume.min, volume.max);\
-                var upperThresholdController = volumegui.add(volume, 'upperThreshold',volume.min, volume.max);\
-                volumegui.open();";
-        
-        //jsCom = jsCom + "\
-                     var gui = new dat.GUI();\
-                var volumegui = gui.addFolder('Volume');\
-                var vrController = volumegui.add(" + w->jsRef() +".mVolume, 'volumeRendering');\
-                var opacityController = volumegui.add(" + w->jsRef() +".mVolume, 'opacity', 0, 1).listen();\
-                var lowerWindowController = volumegui.add(" + w->jsRef() +".mVolume, 'windowLow', " + w->jsRef() +".mVolume.min," + w->jsRef() +".mVolume.max);\
-                var upperWindowController = volumegui.add(" + w->jsRef() +".mVolume, 'windowHigh', " + w->jsRef() +".mVolume.min," + w->jsRef() +".mVolume.max);\
-                volumegui.open();";
-        
-        
-                
-                
-
-
-
-         
-    if(nType.size() >1)
-         {
-                 jsCom = jsCom + "\
-                               setTimeout(function(){\
+                       " +w->jsRef() + ".mVolume = volume;\
+                       setTimeout(function(){\
+                       var center = [0,0,0\
+                  ];\
+                       " +w->jsRef() + ".mVolume.center = center;\
+                       volume.center = [0,0,0];\
+                       " + wtWindow1->jsRef() + ".mRenderer.add(" + w->jsRef() + ".mVolume);\
+                       " + wtWindow1->jsRef() + ".mRenderer.onShowTime = function(){\
+                       " + w->jsRef() +".mVolume.upperThreshold =20000;\
+                       " + w->jsRef() +".mVolume.windowHigh =1670;\
+                       var gui = new dat.GUI();\
+                  var volumegui = gui.addFolder('Volume');\
+                  var vrController = volumegui.add(" + w->jsRef() +".mVolume, 'volumeRendering');\
+                  var opacityController = volumegui.add(" + w->jsRef() +".mVolume, 'opacity', 0, 1);\
+                  var lowerWindowController = volumegui.add(" + w->jsRef() +".mVolume, 'windowLow', 0,2000);\
+                  var upperWindowController = volumegui.add(" + w->jsRef() +".mVolume, 'windowHigh', 0,2000);\
+                  var sliceXController = volumegui.add(" + w->jsRef() +".mVolume, 'indexX', 0,volume.range[0] - 1);\
+                  var sliceYController = volumegui.add(" + w->jsRef() +".mVolume, 'indexY', 0,volume.range[1] - 1);\
+                  var sliceZController = volumegui.add(" + w->jsRef() +".mVolume, 'indexZ', 0,volume.range[2] - 1);\
                        " + wtWindow2->jsRef() + ".mRenderer.add(" +w->jsRef() + ".mVolume);\
-                         " + wtWindow2->jsRef() + ".mRenderer.render();";
-         }
-
-    if(nType.size() >2 )
-         {
-                 jsCom = jsCom + "\
+                         " + wtWindow2->jsRef() + ".mRenderer.render();\
                        " + wtWindow3->jsRef() + ".mRenderer.add(" +w->jsRef() + ".mVolume);\
-                         " + wtWindow3->jsRef() + ".mRenderer.render();";
-         }
-
-         if(nType.size() > 3)
-         {
-                 jsCom = jsCom + "\
+                         " + wtWindow3->jsRef() + ".mRenderer.render();\
                        " + wtWindow4->jsRef() + ".mRenderer.add(" +w->jsRef() + ".mVolume);\
                          " + wtWindow4->jsRef() + ".mRenderer.render();\
-                       " + w->jsRef() +".mVolume.upperTheshold =0;\
-                       " + w->jsRef() +".mVolume.windowLow =0;\
-                       " + w->jsRef() +".mVolume.windowHigh =1900;";
-                         
-
-      jsCom = jsCom + "\
-                     var gui = new dat.GUI();\
-                var volumegui = gui.addFolder('Volume');\
-                var vrController = volumegui.add(" + w->jsRef() +".mVolume, 'volumeRendering');\
-                var opacityController = volumegui.add(" + w->jsRef() +".mVolume, 'opacity', 0, 1).listen();\
-                var lowerWindowController = volumegui.add(" + w->jsRef() +".mVolume, 'windowLow', 0,2000);\
-                var upperWindowController = volumegui.add(" + w->jsRef() +".mVolume, 'windowHigh', 0,2000);\
-                volumegui.open();\
-                var lowerThresholdController = volumegui.add(" + w->jsRef() +".mVolume, 'lowerThreshold'," + w->jsRef() +".mVolume.min, " + w->jsRef() +".mVolume.max);\
-                var upperThresholdController = volumegui.add(" + w->jsRef() +".mVolume, 'upperThreshold'," + w->jsRef() +".mVolume.min, " + w->jsRef() +".mVolume.max);";          
-      }
-      
-      
-      if(nType.size() >1)
-           {
-                  jsCom = jsCom + "\
-                         },2000);";
-           }
-
-  
-
-
-       std::cout<<"PROCESSSSS>>>>"<<jsCom<<std::endl;
-       //w->doJavaScript(jsCom);
-       
-       Wt::WApplication::instance()->refresh();
-  
-
-
-}*/
-
-void ViewerNVWeb::Process()
-{
-
-
-  Wt::WContainerWidget* w = (Wt::WContainerWidget*)bbGetOutputWidget();
+                         };\
+                       " + wtWindow1->jsRef() + ".mRenderer.render();\
+                       },500";
 
-       cont++;
-       std::string jsCom;
-       
-  std::cout<<"Process ----"<<std::endl; 
 
-   jsCom = "\
+       if (firstTime==false)
+       {
+               firstTime=false;
+                 jsCom = "\
                        var volume = new X.volume();\
                        volume.spacing = [0.7,0.7,0.7 ];\
-                       volume.center = [0,0,0];\
                        volume.file = '" + bbGetInputImagePath() + "';\
-                                                                       " + w->jsRef() +".mVolume = volume;\
+                       " +w->jsRef() + ".mVolume = volume;\
+                       var center = [0,0,0];\
+                       " +w->jsRef() + ".mVolume.center = center;\
+                       volume.center = [0,0,0];\
+                       setTimeout(function(){\
                        " + wtWindow1->jsRef() + ".mRenderer.add(" +w->jsRef() + ".mVolume);\
-                       " + wtWindow1->jsRef() + ".onShowTime = function(){";
-
-         
-    if(nType.size() >1)
-         {
-                 jsCom = jsCom + "\
-                       " + wtWindow2->jsRef() + ".mRenderer.add(" +w->jsRef() + ".mVolume);\
-                         " + wtWindow2->jsRef() + ".mRenderer.render();";
-         }
-
-    if(nType.size() >2 )
-         {
-                 jsCom = jsCom + "\
-                       " + wtWindow3->jsRef() + ".mRenderer.add(" +w->jsRef() + ".mVolume);\
-                         " + wtWindow3->jsRef() + ".mRenderer.render();";
-         }
-
-         if(nType.size() > 3)
-         {
-                 jsCom = jsCom + "\
-                       " + wtWindow4->jsRef() + ".mRenderer.add(" +w->jsRef() + ".mVolume);\
-                         " + wtWindow4->jsRef() + ".mRenderer.render();\
-                       " + w->jsRef() +".mVolume.upperTheshold =0;\
-                       " + w->jsRef() +".mVolume.windowLow =0;\
-                       " + w->jsRef() +".mVolume.windowHigh =1900;";
-                         
-
-      jsCom = jsCom + "\
-                     var gui = new dat.GUI();\
-                var volumegui = gui.addFolder('Volume');\
-                var vrController = volumegui.add(" + w->jsRef() +".mVolume, 'volumeRendering');\
-                var opacityController = volumegui.add(" + w->jsRef() +".mVolume, 'opacity', 0, 1).listen();\
-                var lowerWindowController = volumegui.add(" + w->jsRef() +".mVolume, 'windowLow', 0,2000);\
-                var upperWindowController = volumegui.add(" + w->jsRef() +".mVolume, 'windowHigh', 0,2000);\
-                volumegui.open();\
-                var lowerThresholdController = volumegui.add(" + w->jsRef() +".mVolume, 'lowerThreshold'," + w->jsRef() +".mVolume.min, " + w->jsRef() +".mVolume.max);\
-                var upperThresholdController = volumegui.add(" + w->jsRef() +".mVolume, 'upperThreshold'," + w->jsRef() +".mVolume.min, " + w->jsRef() +".mVolume.max);";          
-      }
-      
-      
-     jsCom = jsCom + "\
-                  };\
-                  " + wtWindow1->jsRef() + ".mRenderer.render();";
-  
-
-
-       std::cout<<"PROCESSSSS>>>>"<<jsCom<<std::endl;
-       //w->doJavaScript(jsCom);
-       
-       Wt::WApplication::instance()->refresh();
-  
-
-
-}
-
-
-//--------------------------------------------------------------------------------------------------------
-//--------------------------------------------------------------------------------------------------------
-
-
-
-void ViewerNVWeb::loadImage()
-{
-
-  
-  Wt::WContainerWidget* w = (Wt::WContainerWidget*)bbGetOutputWidget();
-       std::string jsCom;
-       
-  std::cout<<"Process ----"<<std::endl; 
+                       " + wtWindow1->jsRef() + ".mRenderer.render();\
+                     },300);\
+                     ";
+               w->doJavaScript(jsCom);
+       }
 
-  jsCom = "\
+       if (firstTime==true)
+       {
+               firstTime=false;
+                 jsCom = "\
                        var volume = new X.volume();\
                        volume.spacing = [0.7,0.7,0.7 ];\
                        volume.file = '" + bbGetInputImagePath() + "';\
                        " +w->jsRef() + ".mVolume = volume;\
-                       var center = [0,0,0\
-                  ];\
+                       var center = [0,0,0];\
                        " +w->jsRef() + ".mVolume.center = center;\
                        volume.center = [0,0,0];\
                        setTimeout(function(){\
@@ -365,9 +180,10 @@ void ViewerNVWeb::loadImage()
                          " + wtWindow3->jsRef() + ".mRenderer.render();\
                        " + wtWindow4->jsRef() + ".mRenderer.add(" +w->jsRef() + ".mVolume);\
                          " + wtWindow4->jsRef() + ".mRenderer.render();\
-                     },1500);";
+                     },3000);\
+                               ";
                      
-    //jsCom = "\
+   // jsCom = "\
                        var volume = new X.volume();\
                        volume.spacing = [0.7,0.7,0.7 ];\
                        volume.file = '" + bbGetInputImagePath() + "';\
@@ -400,12 +216,9 @@ void ViewerNVWeb::loadImage()
                          };\
                        " + wtWindow1->jsRef() + ".mRenderer.render();";
                        
-
-
-
-
-       std::cout<<"LOADzzzzzzzzzzzzzzzzzzzzzzzzzzzz"<<jsCom<<std::endl;
-       w->doJavaScript(jsCom);
+                       std::cout<<"LOADzzzzzzzzzzzzzzzzzzzzzzzzzzzz"<<jsCom<<std::endl;
+                       w->doJavaScript(jsCom);
+       }
        
        
        //Wt::WApplication::instance()->refresh();
@@ -417,6 +230,7 @@ void ViewerNVWeb::loadImage()
         Wt::WApplication::instance()->refresh();
        
   
+  printf("EED ViewerNVWeb::Process END\n ");
 
 
 }
@@ -429,10 +243,11 @@ void ViewerNVWeb::bbUserSetDefaultValues()
 
 //  SET HERE THE DEFAULT INPUT/OUTPUT VALUES OF YOUR BOX 
 //    Here we initialize the input 'In' to 0
-  bbSetInputImagePath("");
-  int n[] = {3,2,1,0};
-  std::vector<int> nn (n,n+sizeof(n)/sizeof(int));
-  bbSetInputnTypeView(nn);
+       firstTime=true;
+       bbSetInputImagePath("");
+       int n[] = {3,2,1,0};
+       std::vector<int> nn (n,n+sizeof(n)/sizeof(int));
+       bbSetInputnTypeView(nn);
        bbSetOutputviewer1("");
        bbSetOutputviewer2("");
        bbSetOutputviewer3("");
@@ -480,7 +295,7 @@ void ViewerNVWeb::CreateWidget(Wt::WContainerWidget* parent)
     
     l->addWidget(wtWindow1);
     l->addWidget(wtWindow2);
-    
+    l->setResizable(0,true,400);
     w->setLayout(l);
     
                wtWindow1->configureWt();       
@@ -507,7 +322,7 @@ void ViewerNVWeb::CreateWidget(Wt::WContainerWidget* parent)
                wtWindow3 = new Viewer_NV(0,nType[2]);
 
        /*
-               l->addWidget(wtWindow2);
+               l->addWidget(wtWindow2);http://www.creatis.insa-lyon.fr/~davila/links/links_EED.html
                l->addWidget(wtWindow3);
                
                
@@ -520,11 +335,12 @@ void ViewerNVWeb::CreateWidget(Wt::WContainerWidget* parent)
                
                l->addWidget(wtWindow2);
                l->addWidget(wtWindow3);
+               l->setResizable(0,true,400);
                aux1->setLayout(l);
                
                l2->addWidget(wtWindow1);
                l2->addWidget(aux1);
-               
+               l2->setResizable(0,true,400);
                w->setLayout(l2);
                
          wtWindow1->configureWt();     
@@ -570,11 +386,14 @@ void ViewerNVWeb::CreateWidget(Wt::WContainerWidget* parent)
                l->addWidget(wtWindow2,0,1);
                l->addWidget(wtWindow3,0,2);
                l->addWidget(wtWindow4,0,3);
+               l->setColumnResizable(0,true,400);
+               l->setColumnResizable(1,true,400);
+               l->setColumnResizable(2,true,400);
                aux1->setLayout(l);
                
                l2->addWidget(wtWindow1);
                l2->addWidget(aux1);
-               
+               l2->setResizable(0,true,600);
                w->setLayout(l2);
        
        
@@ -593,13 +412,18 @@ void ViewerNVWeb::CreateWidget(Wt::WContainerWidget* parent)
                bbSetOutputviewer3(wtWindow3->jsRef());
                bbSetOutputviewer4(wtWindow4->jsRef());
 
+               bbSetOutputViewer1(wtWindow1);
+               bbSetOutputViewer2(wtWindow2);
+               bbSetOutputViewer3(wtWindow3);
+               bbSetOutputViewer4(wtWindow4);
+
+
        }
 
 
   
   bbSetOutputWidget(w);
-  loadImage();
-  //Process();
+//EED  loadImage();
 
 }