//----------------------------------------------------------------------------
void mafViewImageCompound::UpdateWindowing(bool enable,mafNode *node)
//----------------------------------------------------------------------------
{
	if(enable)
	{
		EnableWidgets(enable);
		mafVMEImage *image=mafVMEImage::SafeDownCast(node);
		double sr[2];
		image->GetOutput()->GetVTKData()->GetScalarRange(sr);

    m_ColorLUT = ((mafPipeImage3D *)m_ChildViewList[ID_VIEW_IMAGE]->GetNodePipe(node))->GetLUT();;

    m_ColorLUT->SetRange(sr);
    m_ColorLUT->Build();
      
    m_LutWidget->SetLut(m_ColorLUT);
		m_LutWidget->Enable(true);
		m_LutSlider->SetRange((long)sr[0],(long)sr[1]);
		m_LutSlider->SetSubRange((long)sr[0],(long)sr[1]);
	}
	else
	{
		EnableWidgets(enable);
		m_LutSlider->SetRange(-100,100);
		m_LutSlider->SetSubRange(-100,100);
	}
}
Esempio n. 2
0
//-------------------------------------------------------------------------
mafGUI* mafViewOrthoSlice::CreateGui()
//-------------------------------------------------------------------------
{
  wxString layout_choices[3] = {"default","layout 1","layout 2"};

  assert(m_Gui == NULL);

  mafView::CreateGui();

  m_Gui->Combo(ID_LAYOUT_CHOOSER,"layout",&m_LayoutConfiguration,3,layout_choices);
  m_Gui->Divider();
  m_LutWidget = m_Gui->Lut(ID_LUT_CHOOSER,"lut",m_ColorLUT);
  m_Gui->Divider(2);

  wxString sidesName[2];
  sidesName[0] = "left";
  sidesName[1] = "right";
  // m_Gui->Radio(ID_SIDE_ORTHO, "side", &m_Side, 2, sidesName, 2);

	m_Gui->Bool(ID_SNAP,"Snap on grid",&m_Snap,1);

  m_Gui->Button(ID_RESET_SLICES,"reset slices","");
  m_Gui->Divider();

	m_Gui->Bool(ID_ALL_SURFACE,"All Surface",&m_AllSurface);
	m_Gui->FloatSlider(ID_BORDER_CHANGE,"Border",&m_Border,1.0,5.0);

  EnableWidgets(m_CurrentVolume != NULL);
  for(int i=1; i<m_NumOfChildView; i++)
  {
    m_ChildViewList[i]->GetGui();
  }

  // Added by Losi 11.25.2009
  if (m_CurrentVolume)
  {
    for (int i=0; i<m_NumOfChildView; i++)
    {
      mafPipeVolumeSlice_BES *p = NULL;
      p = mafPipeVolumeSlice_BES::SafeDownCast(((mafViewSlice *)m_ChildViewList[i])->GetNodePipe(m_CurrentVolume));
      if (p)
      {
        p->SetEnableGPU(m_EnableGPU);
        p->SetTrilinearInterpolation(m_TrilinearInterpolationOn);
      }
    }
  }
  m_Gui->Divider(1);
  //m_Gui->Bool(ID_ENABLE_GPU,"Enable GPU",&m_EnableGPU,1);
  m_Gui->Bool(ID_TRILINEAR_INTERPOLATION,"Interpolation",&m_TrilinearInterpolationOn,1);

  m_Gui->Divider();
  return m_Gui;
}
Esempio n. 3
0
//----------------------------------------------------------------------------
void mafViewOrthoSlice::CreateGuiView()
//----------------------------------------------------------------------------
{
  m_GuiView = new mafGUI(this);
  m_LutSlider = new mafGUILutSlider(m_GuiView,-1,wxPoint(0,0),wxSize(500,24));
  m_LutSlider->SetListener(this);
  m_LutSlider->SetSize(500,24);
  m_LutSlider->SetMinSize(wxSize(500,24));
  m_GuiView->Add(m_LutSlider);
  m_GuiView->Reparent(m_Win);
  EnableWidgets(m_CurrentVolume != NULL);
}
//----------------------------------------------------------------------------
void mafViewImageCompound::CreateGuiView()
//----------------------------------------------------------------------------
{
	m_GuiView = new mafGUI(this);
  
  m_LutSlider = new mafGUILutSlider(m_GuiView,-1,wxPoint(0,0),wxSize(500,24));
  m_LutSlider->SetListener(this);
  m_LutSlider->SetSize(500,24);
  m_LutSlider->SetMinSize(wxSize(500,24));
  EnableWidgets(false);
  m_GuiView->Add(m_LutSlider);
  m_GuiView->Reparent(m_Win);
}
Esempio n. 5
0
//----------------------------------------------------------------------------
void mafViewOrthoSlice::VmeRemove(mafNode *node)
//----------------------------------------------------------------------------
{
  if (m_CurrentVolume && node == m_CurrentVolume) 
  {
    // Disable ChildViews
    for(int j=1; j<m_NumOfChildView; j++) 
      m_ChildViewList[j]->VmeShow(node, false);
    DestroyOrthoSlicesAndGizmos();
    EnableWidgets(false);
  }
  // Remove node from list
  int pos=-1;
  for (int i=0; i<m_VMElist.size(); i++)
    if(node==m_VMElist[i])
      pos=i;
  if (pos>=0)
    m_VMElist.erase(m_VMElist.begin()+pos);

  Superclass::VmeRemove(node);
}
//----------------------------------------------------------------------------
void mafOpImporterRAWVolume_BES::	OnEvent(mafEventBase *maf_event) 
//----------------------------------------------------------------------------
{
	if (mafEvent *e = mafEvent::SafeDownCast(maf_event))
	{
		switch(e->GetId())
		{	  
		case ID_FILE:
			EnableWidgets(true);
			m_CurrentSlice = m_DataDimemsion[2]/2;
			UpdateReader();

			m_Actor->VisibilityOn();
			m_Dialog->GetRWI()->CameraReset();
			m_SliceSlider->SetRange(0,m_DataDimemsion[2] - 1);	 
			m_Gui->Update();
			break;

    case ID_DIM:      
      m_VOI[1] = m_DataDimemsion[0] - 1;
      m_VOI[3] = m_DataDimemsion[1] - 1;
      m_VOI[5] = m_DataDimemsion[2] - 1;
      m_VOI[0] = m_VOI[2] = m_VOI[4] = 0;
      //fall through to Slicer
    case ID_VOI_Z:
      if (m_CurrentSlice > m_VOI[5]) 
        m_CurrentSlice = m_VOI[5];
      else if (m_CurrentSlice < m_VOI[4]) 
        m_CurrentSlice = m_VOI[4];

      m_SliceSlider->SetRange(m_VOI[4], m_VOI[5]);
      //fall through to Resolution settings
    case ID_VOI_X:
    case ID_VOI_Y:      
    case ID_SPC:
      {
        double x_sp = (m_VOI[1] - m_VOI[0])*m_DataSpacing[0];
        double y_sp = (m_VOI[3] - m_VOI[2])*m_DataSpacing[1];
        if (x_sp > y_sp)
        {
          y_sp /= x_sp;
          x_sp = 1.0;
        }
        else
        {
          x_sp /= y_sp;
          y_sp = 1.0;
        }
        
        double origin[3];
        m_Plane->GetOrigin(origin);
        m_Plane->SetPoint1(x_sp + origin[0], origin[1], origin[2]);
        m_Plane->SetPoint2(origin[0], y_sp + origin[1], origin[2]);        

        m_Plane->Update();
      }
      //fall through to update
		case ID_BITS:
		case ID_SCALAR_TYPE:
		case ID_SIGNED:
    case ID_COMPONENTS:    
      m_Gui->Update();
      UpdateReader();
      m_Dialog->GetRWI()->CameraUpdate();
      break;

    case ID_LOOKUPTABLE:
      m_Texture->SetMapColorScalarsThroughLookupTable(m_UseLookupTable);
      m_Dialog->GetRWI()->CameraUpdate();
      break;
      			
		case ID_SLICE:
			m_GuiSlider->Update();
			UpdateReader();
			m_Dialog->GetRWI()->CameraUpdate();
			break;

		case ID_GUESS:
			{
#ifdef VME_VOLUME_LARGE
        long long len = (long long)mafVMEVolumeLargeUtils::GetFileLength(m_RawFile);
#else
        long long len = (long long)GetFileLength(m_RawFile);
#endif
				m_FileHeader = (int)(len - ((long long)m_DataDimemsion[0]*
					m_DataDimemsion[1]*m_DataDimemsion[2]*m_NumberOfByte*
          m_NumberOfScalarComponents));

				m_Gui->Update();
				UpdateReader();
			}
			break;

		case ID_COORD:
			{
				wxString dir = mafGetApplicationDirectory().c_str();
				dir += _("/Data/External");
				wxString wildc =_("Z_coordinates (*.txt)|*.txt");
				wxString file = mafGetOpenFile(dir,wildc,_("Open Z coordinates file")).c_str();
				if(!file.IsEmpty())
				{
					m_CoordFile = file;
					m_BuildRectilinearGrid = true;
					m_DataSpacing[2] = 1.0;

					const char *nome = m_CoordFile.GetCStr();
					std::ifstream f_in;
					f_in.open(nome);
					char title[256];
					f_in.getline(title,256);

					if(strcmp(title,_("Z coordinates:"))!=0)
					{
						wxMessageDialog dialog(NULL,_("This is not a Z coordinates file!"),"",wxOK|wxICON_ERROR);
						dialog.ShowModal();
						f_in.close();
						return;
					}

					int j = 0;
					double value;
					while(!f_in.eof())
					{
						f_in>>value;
						j++;
					}

					j-=1;

					if(j!=m_DataDimemsion[2])
					{
						wxMessageDialog dialog(NULL,_("z dimension is not correct!"),"",wxOK|wxICON_ERROR);
						dialog.ShowModal();
						m_DataDimemsion[2]=j;
						m_Gui->Update();
					}
					f_in.close();
				}
			}
			break;
		case wxOK:
#ifdef VME_VOLUME_LARGE
			if (VolumeLargeCheck())				
#endif // VME_VOLUME_LARGE
				m_Dialog->EndModal(wxID_OK);	//otherwise user should modify it
			break;
		case wxCANCEL:
			m_Dialog->EndModal(wxID_CANCEL);
			break;
		default:
			mafEventMacro(*e);
			break;
		}	
	}
//----------------------------------------------------------------------------
void mafOpImporterRAWVolume_BES::OpRun()
//----------------------------------------------------------------------------
{
	m_Gui = new mafGUI(this);

	//dialog +++++++++++++++++++++++++++++++++++++++
	m_Dialog = new mafGUIDialogPreview(_("raw importer"), mafCLOSEWINDOW | mafRESIZABLE | mafUSEGUI | mafUSERWI);

	//Preview Pipeline ++++++++++++++++++++++++++++++
	vtkNEW(m_Reader);
#ifdef VME_VOLUME_LARGE
	vtkNEW(m_ReaderLarge);
#endif // VME_VOLUME_LARGE
	vtkNEW(m_LookupTable);
	vtkNEW(m_Texture);
  vtkNEW(m_Plane);

//  texture input will be set according to update
//	texture->SetInput((vtkImageData*)m_Reader->GetOutput()->GetSnapshot());
	m_Texture->InterpolateOn();
	m_Texture->MapColorScalarsThroughLookupTableOn();
	m_Texture->SetLookupTable((vtkLookupTable *)m_LookupTable);	

	vtkMAFSmartPointer<vtkPolyDataMapper> mapper;
	mapper ->SetInput(m_Plane->GetOutput());

	vtkNEW(m_Actor);
	m_Actor->SetMapper(mapper);
	m_Actor->SetTexture(m_Texture);
	m_Actor->VisibilityOff();

	//GUI +++++++++++++++++++++++++++++++++++++++++++
	m_Gui->Show(true);
	m_Gui->Divider(0);
	mafString wildc = _("Raw data (*.raw)|*.raw|All files (*.*)|*.*");
	m_Gui->FileOpen(ID_FILE,_("file"),&m_RawFile,wildc);

	wxString endian_choices[2] = {_("Big Endian"),_("Little Endian")};
	wxString scalar_choices[5] = {_("char"),_("short"),_("int"),_("float"),_("double")};
	m_Gui->Divider(0);
	m_Gui->Combo(ID_BITS,_("endian"),&m_Endian,2,endian_choices);
	m_Gui->Combo(ID_SCALAR_TYPE,"scalar type",&m_ScalarType,5,scalar_choices);
	m_Gui->Bool(ID_SIGNED,"signed",&m_Signed);

  m_Gui->Integer(ID_COMPONENTS,"comps", &m_NumberOfScalarComponents, 1, 4,
    _("define the number of components in the data set, e.g., typical grey-scale data sets have"
      "one component only, RGB data sets have 3 components"));

	m_Gui->Divider(0);
	m_Gui->Label(_("dimensions (x,y,z)"));
	m_Gui->Vector(ID_DIM, "",m_DataDimemsion,1,100000);   
	m_Gui->VectorN(ID_VOI_X, "VOI x" ,&m_VOI[0],2,0,MAXINT,_("define the range of voxels in x dimension to import."));
  m_Gui->VectorN(ID_VOI_Y, "VOI y" ,&m_VOI[2],2,0,MAXINT,_("define the range of voxels in y dimension to import."));
  m_Gui->VectorN(ID_VOI_Z, "VOI z" ,&m_VOI[4],2,0,MAXINT,_("define the range of voxels in z dimension to import."));

	m_Gui->Divider(0);
	m_Gui->Label(_("spacing in mm/pixel (x,y,z)"));
	m_Gui->Vector(ID_SPC, "",m_DataSpacing,0.0000001, 100000,-1);

	m_Gui->Button(ID_COORD,_("load"),_("z coords"),_("load the file for non regulary spaced raw volume"));

	m_Gui->Divider(0);
	m_Gui->Button(ID_GUESS,_("guess"),_("header size"));
	m_Gui->Integer(ID_HEADER,_(" "),&m_FileHeader,0);

	m_Gui->Divider(0);

#ifdef VME_VOLUME_LARGE
#ifdef __WIN32__
	MEMORYSTATUSEX ms; 
	ms.dwLength = sizeof(ms);
	GlobalMemoryStatusEx(&ms);
	
	int nMaxMem = ms.ullAvailPhys / (1024*1024);	//available memory
#else
	int nMaxMem = 512;	//some constant
#endif

	nMaxMem /= 2;		//keep 50% free

	m_Gui->Label(_("memory limit [MB]: "));
	m_Gui->Slider(ID_MEMLIMIT, "", &m_MemLimit, 1, nMaxMem, 
		_("if the data to be loaded is larger than the specified memory limit,"
		  "it will be loaded as VolumeLarge VME"));
#endif // VME_VOLUME_LARGE
  
	m_Gui->Label("");
	m_Gui->OkCancel();

	//slice slider +++++++++++++++++++++++++++++++++++++++++++
	m_GuiSlider = new mafGUI(this);  
	m_SliceSlider = m_GuiSlider->Slider(ID_SLICE,_("slice num"),&m_CurrentSlice,0);
  m_GuiSlider->Bool(ID_LOOKUPTABLE, _("use lookup table"), &m_UseLookupTable, 1, 
    _("determines whether the default lookup table should be used for the preview"));
	m_GuiSlider->Show(true);
	m_GuiSlider->Reparent(m_Dialog);
	wxBoxSizer *slider_sizer = new wxBoxSizer( wxHORIZONTAL );
	slider_sizer->Add(m_GuiSlider, 0, wxEXPAND);

	EnableWidgets(false);

	//sizing & positioning +++++++++++++++++++++++++++++++++++++++++++
	m_Gui->Update();

	m_Dialog->GetGui()->AddGui(m_Gui);
	m_Dialog->GetRWI()->SetSize(0,0,400,400);
	m_Dialog->m_RwiSizer->Add(slider_sizer, 0, wxEXPAND);
	m_Dialog->GetRWI()->m_RwiBase->SetMouse(m_Mouse);
	m_Dialog->GetRWI()->m_RenFront->AddActor(m_Actor);
	m_Dialog->GetRWI()->CameraSet(CAMERA_CT);

	int x_pos,y_pos,w,h;
	mafGetFrame()->GetPosition(&x_pos,&y_pos);
	m_Dialog->GetSize(&w,&h);
	m_Dialog->SetSize(x_pos+5,y_pos+5,w,h);

	//show the dialog (show return when the user choose ok or cancel ) ++++++++
	m_Dialog->ShowModal();

	//Import the file if required +++++++++++++++++++++++++++++++++
	int res = (m_Dialog->GetReturnCode() == wxID_OK) ? OP_RUN_OK : OP_RUN_CANCEL;

	if(res == OP_RUN_OK)
	{
		if (m_TestMode)
		{
			//messages are suppressed in Test Mode
			if (!Import()) 
				res = OP_RUN_CANCEL;
		}
		else
		{
			wxBusyInfo wait(_("Importing RAW data, please wait..."));

			if (!Import()) 
				res = OP_RUN_CANCEL;			
		}
	}

	//cleanup +++++++++++++++++++++++++++++++++  
	m_Dialog->GetRWI()->m_RenFront->RemoveActor(m_Actor);

	vtkDEL(m_Plane);
  vtkDEL(m_Reader);
#ifdef VME_VOLUME_LARGE
	vtkDEL(m_ReaderLarge);
#endif // VME_VOLUME_LARGE
	vtkDEL(m_LookupTable);
	vtkDEL(m_Actor);
	vtkDEL(m_Texture);
	cppDEL(m_GuiSlider);
	cppDEL(m_Dialog);

	//finish the Run +++++++++++++++++++++++++++++++++
	mafEventMacro(mafEvent(this,res));

#ifdef VME_VOLUME_LARGE
if (res == OP_RUN_OK && (IsVolumeLarge()/* || IsFileLarge()*/))
	{
		//save the VME data, it should not prompt for saving
		mafEventMacro( mafEvent(this, MENU_FILE_SAVE));
	}
#endif // VME_VOLUME_LARGE
}
Esempio n. 8
0
//----------------------------------------------------------------------------
void mafViewOrthoSlice::VmeShow(mafNode *node, bool show)
//----------------------------------------------------------------------------
{
	wxWindowDisabler wait1;
	wxBusyCursor wait2;

  // Disable Visual pipes plug at run time
  m_CanPlugVisualPipes=false;

  // Detect selected vme pos
  int pos=-1;
  for (int i=0; i<m_VMElist.size(); i++)
    if(node==m_VMElist[i])
      pos=i;

  // if i want to show a vme that is not in list i add it to the list
  if (show && pos == -1)
    m_VMElist.push_back(node);
  // else if i want to un-show a vme i remove it only if is in the list
  else if (!show && pos>=0)
    m_VMElist.erase(m_VMElist.begin()+pos);
  


  // Enable perspective View for every VME
  m_ChildViewList[PERSPECTIVE_VIEW]->VmeShow(node, show);
  // Disable ChildView XN, YN and ZN when no Volume is selected
  if (m_CurrentVolume != NULL)
 	  for(int j=1; j<m_NumOfChildView; j++) 
		{
      m_ChildViewList[j]->VmeShow(node, show);
			if(show && j==YN_VIEW && mafPipeMeshSlice::SafeDownCast(m_ChildViewList[j]->GetNodePipe(node)))
				mafPipeMeshSlice::SafeDownCast(m_ChildViewList[j]->GetNodePipe(node))->SetFlipNormalOff();
		}
  
	if (((mafVME *)node)->GetOutput()->IsA("mafVMEOutputVolume"))
	{
    for(int j=1; j<m_NumOfChildView; j++)
      m_ChildViewList[j]->VmeShow(node, show);

		if (show)
		{
      // Create Ortho Stuff
      CreateOrthoslicesAndGizmos(node);
      
      // Definig radius of polylines at the equivalent side of the medium voxel
      double bounds[6], edges[3], vol, nPoints;
      vtkDataSet *volOutput;
      volOutput=((mafVME *)node)->GetOutput()->GetVTKData();
      volOutput->GetBounds(bounds);
      nPoints=volOutput->GetNumberOfPoints();
      edges[0]=bounds[1]-bounds[0];
      edges[1]=bounds[3]-bounds[2];
      edges[2]=bounds[5]-bounds[4];
      vol=edges[0]*edges[1]*edges[2];
      m_PolylineRadiusSize=pow(vol/nPoints,1.0/3.0)/2.0;
		}
		else
		{
      DestroyOrthoSlicesAndGizmos();
    }

    // When one volume is selected/unselected we enable/disable ChildViews for all vme selected
    for (int i=0;i<m_VMElist.size();i++)
      for(int j=1; j<m_NumOfChildView; j++)
      {
        m_ChildViewList[j]->VmeShow(m_VMElist[i], show);
				if(show && j==YN_VIEW && mafPipeMeshSlice::SafeDownCast(m_ChildViewList[j]->GetNodePipe(m_VMElist[i])))
					 mafPipeMeshSlice::SafeDownCast(m_ChildViewList[j]->GetNodePipe(m_VMElist[i]))->SetFlipNormalOff();
        ApplyViewSettings(m_VMElist[i]);
      }
	}
  else if (show)
    ApplyViewSettings(node);

	//CameraUpdate();
	EnableWidgets(m_CurrentVolume != NULL);
}
Esempio n. 9
0
	void DCAMFormatsPage::UpdateWidgets()
	{
        if ( m_pCamera == NULL || IsConnected() != true )
        {
            DisableWidgets();
            return;	
        }

        EnableWidgets();

		// Query the camera for the availability of video modes and
		// toggle visibility as needed
		
        Error error;
		std::map<Gtk::RadioButton*, VideoMode>::iterator iterVideoMode;
		std::map<Gtk::RadioButton*, FrameRate>::iterator iterFrameRate;

        if ( IsIIDC() )
        {
            Camera* pCamera = dynamic_cast<Camera*>(m_pCamera);

            // Update the video mode radio buttons
            // Loop through all the video modes
            // For each video mode, loop through all the frame rates
            // If the camera supports this video mode at any frame rate, then
            // the radio button should be shown
            for ( iterVideoMode = m_mapVideoMode.begin(); iterVideoMode != m_mapVideoMode.end(); iterVideoMode++ )
            {			
                iterVideoMode->first->hide();

                if ( iterVideoMode->second == VIDEOMODE_FORMAT7 )
                {
                    iterVideoMode->first->show();                   
                    continue;
                }

                for ( iterFrameRate = m_mapFrameRate.begin(); iterFrameRate != m_mapFrameRate.end(); iterFrameRate++ )
                {                
                    bool supported = false;

                    error = pCamera->GetVideoModeAndFrameRateInfo( iterVideoMode->second, iterFrameRate->second, &supported );
                    if ( error != PGRERROR_OK )
                    {
                        // Error	
                        ShowErrorMessageDialog( "Error querying video mode and frame rate", error );
                        break;
                    }

                    if ( supported == true )
                    {
                        // Enable this video mode button
                        iterVideoMode->first->show();

                        // Move on to next video mode
                        break;
                    }
                }
            }
        }
        else if ( IsGEV() )
        {
            for ( iterVideoMode = m_mapVideoMode.begin(); iterVideoMode != m_mapVideoMode.end(); iterVideoMode++ )
            {			
                iterVideoMode->first->hide();

                if ( iterVideoMode->second == VIDEOMODE_FORMAT7 )
                {
                    iterVideoMode->first->show();                   
                    continue;
                }                
            }
        }		
		
		VideoMode currVideoMode;
		FrameRate currFrameRate;
		
        if ( IsIIDC() )
        {
            Camera* pCamera = dynamic_cast<Camera*>(m_pCamera);

            error = pCamera->GetVideoModeAndFrameRate( &currVideoMode, &currFrameRate );
            if ( error != PGRERROR_OK )
            {
                // Error		
                ShowErrorMessageDialog( "Error getting current video mode and frame rate", error );
            }
        }
        else
        {
            currVideoMode = VIDEOMODE_FORMAT7;
            currFrameRate = FRAMERATE_FORMAT7;
        }
		
		// Set the right video mode button to be active
		for ( iterVideoMode = m_mapVideoMode.begin(); iterVideoMode != m_mapVideoMode.end(); iterVideoMode++ )
		{
            if ( currVideoMode == iterVideoMode->second )
			{
				iterVideoMode->first->set_active( true );
			}
		}
		
		// Update the available frame rates for the current video mode
		UpdateFrameRatesForVideoMode( currVideoMode, currFrameRate );
	}
Esempio n. 10
0
//----------------------------------------------------------------------------
void mafViewRXCT::VmeShow(mafNode *node, bool show)
//----------------------------------------------------------------------------
{
  for(int i=0; i<CT_COMPOUND_VIEW; i++)
    m_ChildViewList[i]->VmeShow(node, show);

  //if (node->IsMAFType(mafVMEVolume))
  if (((mafVME *)node)->GetOutput()->IsA("mafVMEOutputVolume"))
  {
    if (show)
    {
      double center[3],b[CT_CHILD_VIEWS_NUMBER],step;
    
      // set the range for every slider widget
      mafVME *volumeVme = mafVME::SafeDownCast(node);
      mafVMEOutputVolume *volumeOutput = mafVMEOutputVolume::SafeDownCast(volumeVme->GetOutput());
      for (int childID = RX_FRONT_VIEW; childID < CT_COMPOUND_VIEW; childID++)
      {
        double advLow,advHigh;
        double range[2];
        if(volumeOutput->GetMaterial())
        {
          
          ((mafViewRX *)m_ChildViewList[childID])->GetLutRange(range); //range of projected
          double volTableRange[2];
          vtkLookupTable *cl = volumeOutput->GetMaterial()->m_ColorLut;
          
          double volRange[2];
          volumeOutput->GetVTKData()->GetScalarRange(volRange);

          if (volumeOutput->GetMaterial()->m_TableRange[1] < volumeOutput->GetMaterial()->m_TableRange[0]) 
          {
            volTableRange[0] = volRange[0];
            volTableRange[1] = volRange[1];
          }
          else
          {
            volTableRange[0] = volumeOutput->GetMaterial()->m_TableRange[0];
            volTableRange[1] = volumeOutput->GetMaterial()->m_TableRange[1];
          }
          

          

          double proportionalConstant = ((range[1] - range[0])/(volRange[1] - volRange[0]));
          double inverseProportionalConstant = 1.0 / proportionalConstant;
          
          //advLow = range[0] + ((range[1] - range[0])/(volTableRange[1] - volTableRange[0])) * (range[0] - volTableRange[0]);
          //advHigh = range[1] + ((range[1] - range[0])/(volTableRange[1] - volTableRange[0])) * (range[1] - volTableRange[1]);
          advLow = proportionalConstant * (volTableRange[0] - volRange[0] + inverseProportionalConstant * range[0]);
          advHigh = proportionalConstant * (volTableRange[1] - volRange[1] + inverseProportionalConstant * range[1]);

          ((mafViewRX *)m_ChildViewList[childID])->SetLutRange(advLow,advHigh);
        }
        else
        {
          ((mafViewRX *)m_ChildViewList[childID])->GetLutRange(range);
          advLow = range[0];
          advHigh = range[1];
        }

        m_LutSliders[childID]->SetRange(range[0],range[1]);
        m_LutSliders[childID]->SetSubRange(advLow,advHigh);
      
        // create a lookup table for each RX view
        /*vtkNEW(m_vtkLUT[childID]);
        if(volumeOutput->GetMaterial()->m_ColorLut)
        {
          m_vtkLUT[childID]->DeepCopy(volumeOutput->GetMaterial()->m_ColorLut);
          m_vtkLUT[childID]->SetRange(advLow,advHigh);
          m_vtkLUT[childID]->Build();
        }
        else
        {
          m_vtkLUT[childID]->SetRange(advLow,advHigh);
          m_vtkLUT[childID]->Build();
          lutPreset(4,m_vtkLUT[childID]);
        }*/
        
        
       
        ((mafViewRX *)m_ChildViewList[childID])->SetLutRange(advLow,advHigh);

      }

      double sr[CT_COMPOUND_VIEW];

      // get the VTK volume
      vtkDataSet *data = ((mafVME *)node)->GetOutput()->GetVTKData();
      data->Update();
      data->GetCenter(center);
      data->GetScalarRange(sr);
      double totalSR[2];
      totalSR[0] = sr[0];
      totalSR[1] = sr[1];

      if(volumeVme)
      { 
        if(volumeOutput->GetMaterial())
        {
          if (volumeOutput->GetMaterial()->m_TableRange[1] > volumeOutput->GetMaterial()->m_TableRange[0]) 
          {
            sr[0] = volumeOutput->GetMaterial()->m_TableRange[0];
            sr[1] = volumeOutput->GetMaterial()->m_TableRange[1];
          }
        }
      }
      
      // set the slider for the CT compound view
      m_LutSliders[CT_COMPOUND_VIEW]->SetRange(totalSR[0],totalSR[1]);
      m_LutSliders[CT_COMPOUND_VIEW]->SetSubRange(sr[0],sr[1]);
      
      // create a lookup table for CT views
      
      if(volumeOutput->GetMaterial()->m_ColorLut)
      {
        /*m_vtkLUT[CT_COMPOUND_VIEW] = volumeOutput->GetMaterial()->m_ColorLut;
        m_vtkLUT[CT_COMPOUND_VIEW]->SetRange(sr);
        m_vtkLUT[CT_COMPOUND_VIEW]->Build();*/
        
        m_Lut = volumeOutput->GetMaterial()->m_ColorLut;
        m_Lut->SetRange(sr);
        m_Lut->Build();
      }
      

      // gather data to initialize CT slices
      data->GetBounds(b);
      step = (b[5]-b[4])/7.0;
      for(int i=0; i<CT_CHILD_VIEWS_NUMBER; i++)
      {
        center[2] = b[5]-step*(i+1);
        ((mafViewSlice *)((mafViewCompound *)m_ChildViewList[CT_COMPOUND_VIEW])->GetSubView(i))->InitializeSlice(center);
        ((mafViewSlice *)((mafViewCompound *)m_ChildViewList[CT_COMPOUND_VIEW])->GetSubView(i))->SetTextColor(m_BorderColor[i]);
        ((mafViewSlice *)((mafViewCompound *)m_ChildViewList[CT_COMPOUND_VIEW])->GetSubView(i))->VmeShow(node,show);

        mafPipeVolumeSlice_BES *p = NULL;
        // set pipe lookup table
        p = mafPipeVolumeSlice_BES::SafeDownCast(((mafViewSlice *)((mafViewCompound *)m_ChildViewList[CT_COMPOUND_VIEW])->GetSubView(i))->GetNodePipe(node));

        p->SetEnableGPU(m_EnableGPU);
        p->SetTrilinearInterpolation(m_TrilinearInterpolationOn);

        //p->SetColorLookupTable(m_vtkLUT[CT_COMPOUND_VIEW]);
        p->SetColorLookupTable(m_Lut);
        m_Pos[i] = b[5]-step*(i+1);
      }
      m_CurrentVolume = mafVME::SafeDownCast(node);
      GizmoCreate();

      //BEGIN cycle for remove old surface and redraw the right slice
      
      mafNodeIterator *iter = node->GetRoot()->NewIterator();
      for (mafNode *node = iter->GetFirstNode(); node; node = iter->GetNextNode())
      {
        if(node->IsA("mafVMESurface"))
        {
          mafPipe *p=(m_ChildViewList[RX_FRONT_VIEW])->GetNodePipe(node);
          if(p)
          {
            this->VmeShow(node,false);
            this->VmeShow(node,true);
          }
        } 
      }
      iter->Delete();
      //END cycle for remove old surface and redraw the rigth slice
    }
    else
    {
      m_ChildViewList[CT_COMPOUND_VIEW]->VmeShow(node, show);
      m_CurrentVolume = NULL;
      GizmoDelete();
    }

  }
  else if (node->IsMAFType(mafVMESurface)||node->IsMAFType(mafVMESurfaceParametric))
  {
    // showing a surface with the volume present already
    if (show && m_CurrentVolume)
    {
      // create the slice in every CT views
      mafNode *node_selected = this->GetSceneGraph()->GetSelectedVme();
      ((mafViewCompound *)m_ChildViewList[CT_COMPOUND_VIEW])->VmeShow(node,show);
      for(int j=0;j<CT_CHILD_VIEWS_NUMBER;j++)
      {
        int i=0;
        while (j!=m_Sort[i]) i++;
        double pos[3]={0.0,0.0,m_Pos[m_Sort[i]]};
        ((mafViewSlice *)((mafViewCompound *)m_ChildViewList[CT_COMPOUND_VIEW])->GetSubView(i))->SetSliceLocalOrigin(pos);
        ((mafViewSlice *)((mafViewCompound *)m_ChildViewList[CT_COMPOUND_VIEW])->GetSubView(i))->CameraUpdate();
      }
      mafPipe *p=((mafViewSlice *)((mafViewCompound *)m_ChildViewList[CT_COMPOUND_VIEW])->GetSubView(0))->GetNodePipe(node);
  
      if (node_selected==node)
      {
        m_Gui->Enable(ID_ALL_SURFACE,true);
        m_Gui->Enable(ID_BORDER_CHANGE,true);
        m_Gui->Enable(ID_ADJUST_SLICES,true);
        if (p)
        {
          double old_thickness=((mafPipeSurfaceSlice *)p)->GetThickness();
          m_Border=old_thickness;
          m_Gui->Update();
        }
        else
          m_Border=1;
      }

    }//if (show)
    else if (!show)
    {
      // hide the surface
      m_ChildViewList[CT_COMPOUND_VIEW]->VmeShow(node, show);
      mafNode *node_selected = this->GetSceneGraph()->GetSelectedVme();
      if (node_selected==node)
      {
        m_Gui->Enable(ID_ALL_SURFACE,false);
        m_Gui->Enable(ID_BORDER_CHANGE,false);
        m_Gui->Enable(ID_ADJUST_SLICES,false);
      }
      for(int i=0; i<CT_CHILD_VIEWS_NUMBER; i++)
      {
        ((mafViewSlice *)((mafViewCompound *)m_ChildViewList[CT_COMPOUND_VIEW])->GetSubView(i))->UpdateSurfacesList(node);
      }
    }//else if(show)
  }
  else
  {
    m_ChildViewList[CT_COMPOUND_VIEW]->VmeShow(node, show);
  }

  EnableWidgets(m_CurrentVolume != NULL);
}