]> Creatis software - creaMaracasVisu.git/commitdiff
#3554 window color level reset base viewer 2D
authoreduardo.davila@creatis.insa-lyon.fr <eduardo.davila@creatis.insa-lyon.fr>
Mon, 25 Mar 2024 16:23:40 +0000 (17:23 +0100)
committereduardo.davila@creatis.insa-lyon.fr <eduardo.davila@creatis.insa-lyon.fr>
Mon, 25 Mar 2024 16:23:40 +0000 (17:23 +0100)
bbtk/src/bbcreaMaracasVisuSetwxVtkBaseViewSetOpacityAxis.cxx
lib/maracasVisuLib/src/interface/wxWindows/widgets/manualInteractorWindowLevel.cxx
lib/maracasVisuLib/src/interface/wxWindows/widgets/wxVtk2DBaseView.cxx

index cae0c2f6ce8b037f5225b9132f652a9a9153b379..bf542ff60e5194e7ccd4f9d2eb5610bde3461be0 100644 (file)
@@ -16,7 +16,6 @@ BBTK_BLACK_BOX_IMPLEMENTATION(SetwxVtkBaseViewSetOpacityAxis,bbtk::AtomicBlackBo
 //===== 
 void SetwxVtkBaseViewSetOpacityAxis::Process()
 {
-
 // THE MAIN PROCESSING METHOD BODY
 //   Here we simply set the input 'In' value to the output 'Out'
 //   And print out the output value
@@ -30,7 +29,6 @@ void SetwxVtkBaseViewSetOpacityAxis::Process()
 //      (the one provided in the attribute 'type' of the tag 'input')
 //    bbSetOutputOut( bbGetInputIn() );
 //    std::cout << "Output value = " <<bbGetOutputOut() << std::endl;
-  
        if (bbGetInputwxVtkBaseView()!=NULL)
        {
                vtkMPRBaseData* vtkmprbasedata = (vtkMPRBaseData*) (bbGetInputwxVtkBaseView()->GetVtkBaseData());
@@ -50,38 +48,34 @@ void SetwxVtkBaseViewSetOpacityAxis::Process()
 //===== 
 void SetwxVtkBaseViewSetOpacityAxis::bbUserSetDefaultValues()
 {
-
 //  SET HERE THE DEFAULT INPUT/OUTPUT VALUES OF YOUR BOX 
 //    Here we initialize the input 'In' to 0
   bbSetInputOpacity( 1 ) ;  
   bbSetInputwxVtkBaseView( NULL ) ;  
 }
-//===== 
+
+//=====
 // 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 SetwxVtkBaseViewSetOpacityAxis::bbUserInitializeProcessing()
 {
-
 //  THE INITIALIZATION METHOD BODY :
 //    Here does nothing 
 //    but this is where you should allocate the internal/output pointers 
-//    if any 
-
-  
+//    if any
 }
-//===== 
+
+//=====
 // 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 SetwxVtkBaseViewSetOpacityAxis::bbUserFinalizeProcessing()
 {
-
 //  THE FINALIZATION METHOD BODY :
 //    Here does nothing 
 //    but this is where you should desallocate the internal/output pointers 
 //    if any
-  
-}
 }
-// EO namespace bbcreaMaracasVisu
+
+}// EO namespace bbcreaMaracasVisu
 
 
index 8ecfd9e6e32c385c490dec4096200e2682867a84..8868df4ca180a9d8547321e56ce9cc221e5602b2 100644 (file)
@@ -40,44 +40,58 @@ manualInteractorWindowLevel::manualInteractorWindowLevel()
 }
 
 //-------------------------------------------------------------------
-
 manualInteractorWindowLevel::~manualInteractorWindowLevel()
 {
 }
 
 //-------------------------------------------------------------------
-
 bool manualInteractorWindowLevel::OnMouseMove()                        // virtual 
 {
        if (_stateWindowLevel==true)
        {
+        
+//        char keyCode    = _vtkInteractorStyleBaseView->GetInteractor()-> GetKeyCode();
+//        int  ctrlkey        = _vtkInteractorStyleBaseView->GetInteractor()->GetControlKey();
+
                int tmpPx,tmpPy;
                crea::wxVTKRenderWindowInteractor *wxVTKiren;
                wxVTKiren = _vtkInteractorStyleBaseView->GetWxVtk2DBaseView()->GetWxVTKRenderWindowInteractor();
                wxVTKiren->GetEventPosition( tmpPx , tmpPy );
+        
+//        int keyCode    = (int)(wxVTKiren->GetKeyCode());
+        int  ctrlkey    = wxVTKiren->GetControlKey();
+//        printf("EED manualInteractorWindowLevel::OnMouseMove  keyCode=%d  ctrlkey=%d\n", keyCode,ctrlkey);
+
                double colorWin;
                double colorLev;
                vtkImageData* imgrange = ((wxVtk2DBaseView*)_vtkInteractorStyleBaseView->GetWxVtk2DBaseView())->GetVtkBaseData()->GetImageData();
                if(imgrange != NULL)
                {
-                       double* scalarrange = imgrange->GetScalarRange();
-                       double scalarr;
-                       if (scalarrange[1] == scalarrange[0])
-                       {
-                               scalarr=scalarrange[1];
-                               if (scalarrange[1]==0) {scalarr=100;}
-                       } else {
-                               scalarr = scalarrange[1] - scalarrange[0];
-                       }
-                       //std::cout<<"scalar r="<<scalarr<<std::endl;
-                       int w, h;
-                       ((wxWindow*)wxVTKiren)->GetSize(&w, &h);                        
-                       double dw=w,dh=h;
-                       double dx = (scalarr*( _backPx - tmpPx ))/dw;
-                       double dy = (scalarr*( _backPy - tmpPy ))/dh;
-                       //colorWin=_backWindow - (scalarr)*( _backPx - tmpPx );
-                       colorWin=_backWindow - dx;
-                       colorLev=_backLevel  + dy;
+            double* scalarrange = imgrange->GetScalarRange();
+            if (ctrlkey==0) {
+                double scalarr;
+                if (scalarrange[1] == scalarrange[0])
+                {
+                    scalarr=scalarrange[1];
+                    if (scalarrange[1]==0) {scalarr=100;}
+                } else {
+                    scalarr = scalarrange[1] - scalarrange[0];
+                }
+                //std::cout<<"scalar r="<<scalarr<<std::endl;
+                int w, h;
+                ((wxWindow*)wxVTKiren)->GetSize(&w, &h);
+                double dw=w,dh=h;
+                double dx = (scalarr*( _backPx - tmpPx ))/dw;
+                double dy = (scalarr*( _backPy - tmpPy ))/dh;
+                //colorWin=_backWindow - (scalarr)*( _backPx - tmpPx );
+                colorWin=_backWindow - dx;
+                colorLev=_backLevel  + dy;
+            } else { // ctrlkey == 1
+                colorWin = scalarrange[1] - scalarrange[0];
+                colorLev = (scalarrange[1] + scalarrange[0])/2;
+                _backWindow = colorWin;
+                _backLevel  = colorLev;
+            }
                } else {
                        colorWin=_backWindow - 2*( _backPx - tmpPx );
                        colorLev=_backLevel  + 2*( _backPy - tmpPy );
@@ -130,7 +144,6 @@ bool manualInteractorWindowLevel::OnMiddleButtonDown()      // virtual
 }
 
 //-------------------------------------------------------------------
-
 bool manualInteractorWindowLevel::OnMiddleButtonUp()           // virtual
 {
        if (_stateWindowLevel==true)
index 61ad9f6f7c43b32ab47089153e638e31ee198ea4..b96c58a1bfaeb8cf0eabb80555cdfb5096c120c1 100644 (file)
@@ -209,7 +209,6 @@ void wxVtk2DBaseView::Configure(bool okimage)
        vtkImageData *imageData = GetVtkBaseData()->GetMarImageData()->GetImageData();
        if (imageData!=NULL)
        {
-
 //EED 2017-01-01 Migration VTK7
 #if VTK_MAJOR_VERSION <= 5
                imageData->UpdateInformation();
@@ -218,13 +217,11 @@ void wxVtk2DBaseView::Configure(bool okimage)
 #else
                //...
 #endif
-
                if (okimage==true){
                        imageData->GetSpacing (spx,spy,spz);
                        imageData->GetExtent (x1,x2,y1,y2,z1,z2);
                        SetImageToVtkViewer(imageData);
                        _imageViewer2XYZ->SetExtentDimension(x1,x2,y1,y2,z1,z2);
-                       
 /*EED Borrame,  now is syncroniced in vtkBaseData for all windows                      
                        double range[2];
                        imageData->GetScalarRange(range);
@@ -235,8 +232,7 @@ void wxVtk2DBaseView::Configure(bool okimage)
                                 _imageViewer2XYZ->GetVtkImageViewer2()->SetColorWindow( 1000 );
                                 _imageViewer2XYZ->GetVtkImageViewer2()->SetColorLevel( 500 );
                        }
-*/ 
-                       
+*/
 // EED 31 Janvier 2007
 //vtkImageActor *vtkimageactor = _imageViewer2XYZ->GetVtkImageViewer2()->GetImageActor ();
 //vtkimageactor->InterpolateOff ();
@@ -251,7 +247,6 @@ void wxVtk2DBaseView::Configure(bool okimage)
 
 // EED 17 Oct 2007
 //                     SetInteractorStyleImage( vtkInteractorStyleBaseView2D::New() );
-
                        vtkImageViewer2 *IV2            =       _imageViewer2XYZ->GetVtkImageViewer2();
                        vtkCamera               *camera         =       IV2->GetRenderer()->GetActiveCamera();
 
@@ -268,16 +263,15 @@ void wxVtk2DBaseView::Configure(bool okimage)
                        camera->SetFocalPoint   ( spx*(x1+x2)/2 , spy*(y1+y2)/2 , spz*0         );
 */
 
-                       
                        camera->SetClippingRange( 0.01                  , 1000000 );
                        camera->ComputeViewPlaneNormal();
-               
                        double cameraparallelScale=spx*(x2-x1)/3.0;     
                        camera->SetParallelScale( cameraparallelScale );
                        GetVtkBaseData()->SetCameraParallelScale( cameraparallelScale );
 
                        // text information over the graphic window
-                       if(_vtkIinfoTextImage == NULL){
+                       if(_vtkIinfoTextImage == NULL)
+            {
                                _vtkIinfoTextImage                                      = new vtkInfoTextImage();
                                _vtkIinfoTextImageInteractor            = new vtkInfoTextImageInteractor();
                                ((vtkInteractorStyleBaseView*)this->GetInteractorStyleBaseView())->AddInteractorStyleMaracas(_vtkIinfoTextImageInteractor);
@@ -286,14 +280,11 @@ void wxVtk2DBaseView::Configure(bool okimage)
                        _vtkIinfoTextImage->SetMarImageData( GetVtkBaseData()->GetMarImageData() );
                        _vtkIinfoTextImageInteractor->SetModelVtkInfoTextImage(_vtkIinfoTextImage);
                        _vtkIinfoTextImage->Configure();
-
                } // okimage
        } // imageData
-    
 }
 
 //-------------------------------------------------------------------
-
 int wxVtk2DBaseView::GetActualSlice()  // virtual
 {
    return (int)(GetVtkBaseData()->GetZ());