From 7b314784870e805471ea551a0a7f33827a8fedcb Mon Sep 17 00:00:00 2001 From: "eduardo.davila@creatis.insa-lyon.fr" Date: Mon, 25 Mar 2024 17:23:40 +0100 Subject: [PATCH] #3554 window color level reset base viewer 2D --- ...acasVisuSetwxVtkBaseViewSetOpacityAxis.cxx | 20 +++---- .../widgets/manualInteractorWindowLevel.cxx | 55 ++++++++++++------- .../wxWindows/widgets/wxVtk2DBaseView.cxx | 15 +---- 3 files changed, 44 insertions(+), 46 deletions(-) diff --git a/bbtk/src/bbcreaMaracasVisuSetwxVtkBaseViewSetOpacityAxis.cxx b/bbtk/src/bbcreaMaracasVisuSetwxVtkBaseViewSetOpacityAxis.cxx index cae0c2f..bf542ff 100644 --- a/bbtk/src/bbcreaMaracasVisuSetwxVtkBaseViewSetOpacityAxis.cxx +++ b/bbtk/src/bbcreaMaracasVisuSetwxVtkBaseViewSetOpacityAxis.cxx @@ -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 = " <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 diff --git a/lib/maracasVisuLib/src/interface/wxWindows/widgets/manualInteractorWindowLevel.cxx b/lib/maracasVisuLib/src/interface/wxWindows/widgets/manualInteractorWindowLevel.cxx index 8ecfd9e..8868df4 100644 --- a/lib/maracasVisuLib/src/interface/wxWindows/widgets/manualInteractorWindowLevel.cxx +++ b/lib/maracasVisuLib/src/interface/wxWindows/widgets/manualInteractorWindowLevel.cxx @@ -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="<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="<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) diff --git a/lib/maracasVisuLib/src/interface/wxWindows/widgets/wxVtk2DBaseView.cxx b/lib/maracasVisuLib/src/interface/wxWindows/widgets/wxVtk2DBaseView.cxx index 61ad9f6..b96c58a 100644 --- a/lib/maracasVisuLib/src/interface/wxWindows/widgets/wxVtk2DBaseView.cxx +++ b/lib/maracasVisuLib/src/interface/wxWindows/widgets/wxVtk2DBaseView.cxx @@ -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()); -- 2.47.1