[vtkusers] MPR crosshairs Call Back

rohit rppatil3210 at gmail.com
Wed Nov 8 06:00:25 EST 2017


Hello all VTK users, I am new to vtk and nowadays working on an MPR
(MultiPlanar Reconstruction) of a CT/MRI image in JAVA I have successfully
developed the view which it is required to view the MPR and its crosshairs,
but from two days I am stuck in the crosshairs movement callback, I want to
one crosshair along with this other two view + crosshairs have to change.
Help me to solve this problem. I am attaching my code below for the
reference and also image too. I can also provide the whole MPR project in
java for reference.

Used  - VTK8.0.jar file, vtk dll files, java 8, IDE - Eclipse


 
<http://vtk.1045678.n5.nabble.com/file/t342239/MPR_CallBack_Not_Working.png> 


package test_vtk_blog;
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.EventQueue;
import java.awt.Font;
import java.awt.GraphicsEnvironment;
import java.awt.GridLayout;
import java.awt.Point;
import java.awt.Rectangle;
import java.awt.Toolkit;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import java.io.File;
import java.io.IOException;

import javax.swing.BorderFactory;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JMenuItem;
import javax.swing.JPanel;
import javax.swing.JPopupMenu;
import javax.swing.JSplitPane;
import javax.swing.JTextArea;
import javax.swing.SwingUtilities;
import javax.swing.border.TitledBorder;

import org.dcm4che2.data.DicomObject;
import org.dcm4che2.data.Tag;
import org.dcm4che2.io.DicomInputStream;

import vtk.vtkCamera;
import vtk.vtkCanvas;
import vtk.vtkCursor2D;
import vtk.vtkDICOMImageReader;
import vtk.vtkImageActor;
import vtk.vtkImageMapToColors;
import vtk.vtkImageReslice;
import vtk.vtkInteractorStyleImage;
import vtk.vtkLookupTable;
import vtk.vtkNativeLibrary;
import vtk.vtkPointPicker;
import vtk.vtkPoints;
import vtk.vtkPolyDataMapper;
import vtk.vtkResliceCursorLineRepresentation;
import vtk.vtkResliceCursorWidget;
import vtk.vtkResliceImageViewer;
import vtk.vtkWindowLevelLookupTable;

@SuppressWarnings("serial")
public class Mpr2DFrame extends JFrame {

	// label and panel
	String patientName, age, studyid;
	static String patientID;
	String modality;
	String gender;
	String date;
	String time;
	String studyDesc;
	String seriesDesc;
	JPanel mainPan;
	JSplitPane splitsPane;
	JPanel mprPan;

	private JPanel pnlAxialView;
	private JPanel pnlCoronalView;
	private JPanel pnlSagittalView;
	private JPanel pnlAnnotationView;
	private JTextArea taPageStartCor;
	private JTextArea taPageEnd;
	private JTextArea taPageStart;
	private JTextArea taPageEndCor;
	private JTextArea taPageStartSag;
	private JTextArea taPageEndSag;

	String tittle = "Multi-Plannar Reconstruction (MPR)";

	vtkPoints points = new vtkPoints();

	vtkCanvas vpanAxial = new vtkCanvas();
	vtkCanvas vpanCoronal = new vtkCanvas();
	vtkCanvas vpanSagittal = new vtkCanvas();
	
	vtkImageReslice resliceAxial;
	vtkImageReslice resliceCoronal;
	vtkImageReslice resliceSagittal;
	
	vtkInteractorStyleImage interactorStyle = new vtkInteractorStyleImage();
	
	//vtkInteractorStyleTrackball interactorStyle = new
vtkInteractorStyleTrackball();
	
	//vtkInteractorStyleJoystickCamera interactorStyle = new
vtkInteractorStyleJoystickCamera();
	
	vtkImageActor actorAxial;
	vtkImageActor actorCoronal;
	vtkImageActor actorSagittal;
	
	Point mouseXYAxial, mouseXYCoronal, mouseXYSagittal;
	private vtkDICOMImageReader reader = null;
	double[] dataExtent;
	private int WL = -20, WW = 110;

	
	private vtkLookupTable axialTable;
	private vtkImageMapToColors axialColor;
	private vtkLookupTable coronalTable;
	private vtkImageMapToColors coronnalColor;
	private vtkLookupTable saggitalTable;
	private vtkImageMapToColors saggitalColor;
 
	private vtkResliceCursorWidget resliceWidget_resliceImageViewerXY;
	private vtkResliceImageViewer resliceImageViewerXY;
	private vtkResliceImageViewer resliceImageViewerXZ;
	private vtkResliceImageViewer resliceImageViewerYZ;
    
    static String imagepath = "";
    private static String path_tag_read;
	private static String modality_name;
	private static String patient_name;
	private static String patient_age;
	private static String patient_gender;
	private static String study_date;
	private static String patient_id;
	
	static {

		if (!vtkNativeLibrary.LoadAllNativeLibraries()) {
			for (vtkNativeLibrary lib : vtkNativeLibrary.values()) {

				if (!lib.IsLoaded()) {
					System.out.println(lib.GetLibraryName() + " not loaded");
				}
			}
			System.out.println("Make sure the search path is correct: ");
			System.out.println(System.getProperty("java.library.path"));
		}

	}

	public static void main(String[] args) {
		
		System.out.println("Mpr2DFrame Called");
		
		imagepath = "C:\\3D VR\\kidney\\series001\\compression\\";
		//tag_reader(imagepath);
		
		System.out.println( "imagepath = "+ imagepath);
		
		EventQueue.invokeLater(new Runnable() {
			public void run() {
				
				Mpr2DFrame frame = new Mpr2DFrame();
				frame.readDicomDir(imagepath);				
				frame.setLocationRelativeTo(null);
				frame.setVisible(true);

			}
		});

	}

	public Mpr2DFrame() {

		System.gc();
		setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
		setFrameSize();
		initComponents();
		addComponents(true);
		setStyles();
		addListners();		

		System.gc();

		this.addWindowListener(new WindowAdapter() {
			@Override
			public void windowClosing(WindowEvent e) {
				super.windowClosing(e);
				System.gc();
			}
		});

	}
	
	static void tag_reader(String path)
	{
		
		//---------------------------
		
		File folder = new File(path);
		File[] listOfFiles = folder.listFiles();
		path_tag_read = listOfFiles[2].getAbsolutePath();
		System.out.println(path_tag_read);
		
		//---------------------------
		
		File f = new File(path_tag_read);

		DicomInputStream dcmInputStream = null;
		try {
			dcmInputStream = new DicomInputStream(f);
		} catch (IOException e1) {
			e1.printStackTrace();
		}

		DicomObject dcmObject = null;

		try {
			dcmObject = dcmInputStream.readDicomObject();
		} catch (IOException e1) {
			e1.printStackTrace();
		}

		// Read DICOM TAG IN Variables

		modality_name = dcmObject.getString(Tag.Modality);
		patient_id = dcmObject.getString(Tag.PatientID);		
		patient_name = dcmObject.getString(Tag.PatientName);		
		patient_age = dcmObject.getString(Tag.PatientAge);
		patient_gender = dcmObject.getString(Tag.PatientSex);
		study_date = dcmObject.getString(Tag.StudyDate);
		study_date = convertDateTag(study_date);

	}

	public void setFrameSize() {
		Dimension scrnSize = Toolkit.getDefaultToolkit().getScreenSize();
		Rectangle winSize =
GraphicsEnvironment.getLocalGraphicsEnvironment().getMaximumWindowBounds();
		int taskBarHeight = scrnSize.height - winSize.height;
		this.setSize(Toolkit.getDefaultToolkit().getScreenSize().width - 200,
				(Toolkit.getDefaultToolkit().getScreenSize().height - taskBarHeight));

		// set main Frame in the center
		Dimension dim = Toolkit.getDefaultToolkit().getScreenSize();
		this.setLocation(dim.width / 2 - this.getSize().width / 2, (dim.height / 2
- this.getSize().height / 2) + 50);
	}

	public void initComponents() {

		getContentPane().setLayout(new BorderLayout());

		axialTable = new vtkLookupTable();
		saggitalTable = new vtkLookupTable();
		coronalTable = new vtkLookupTable();
		coronnalColor = new vtkImageMapToColors();
		axialColor = new vtkImageMapToColors();
		saggitalColor = new vtkImageMapToColors();

		pnlAxialView = new JPanel();
		pnlAxialView.setVisible(true);

		// second panel
		pnlCoronalView = new JPanel();
		pnlCoronalView.setVisible(true);

		// third panel
		pnlSagittalView = new JPanel();
		pnlSagittalView.setVisible(true);

		// forth Panel
		pnlAnnotationView = new JPanel();
		pnlAnnotationView.setVisible(true);

		mainPan = new JPanel();
		mainPan.setLayout(new GridLayout(1, 2, 1, 1));
		mainPan.revalidate();		
		mainPan.setVisible(true);
		// this.sldWL.setOpaque(false);

		// main panel
		mprPan = new JPanel();
		mprPan.setLayout(new GridLayout(2, 2, 5, 5));
		splitsPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, true);
		splitsPane.setDividerSize(1);

		String Space = "                           ";
		taPageStart = new JTextArea("Patient ID:" + patient_id +
"\t\t\t\t\t"+Space+ "Gender :" + patient_gender, 3, 10);
		taPageStart.append("\nPatient Name :" + patient_name + "\t\t\t\t\tAge :" +
patient_age);  

		taPageStart.setEditable(false);
		taPageStart.setBackground(Color.black);
		taPageStart.setOpaque(false);
		taPageStart.setForeground(Color.white);

		taPageEnd = new JTextArea("Date :" + study_date, 3, 10);
		//taPageEnd.append("\nModality :" + modality_name + "\t\t\t\t\t\t" +
"Series Desc :" + seriesDesc);
		taPageEnd.append("\nModality :" + modality_name);

		taPageEnd.setEditable(false);
		taPageEnd.setOpaque(false);
		taPageEnd.setBackground(Color.black);
		taPageEnd.setForeground(Color.white);

		pnlAxialView.setLayout(new BorderLayout());
	
		taPageStartCor = new JTextArea("Patient ID:" + patient_id +
"\t\t\t\t\t"+Space+ "Gender :" + patient_gender, 3, 10);
		taPageStartCor.append("\nPatient Name :" + patient_name + "\t\t\t\t\tAge
:" + patient_age);

		taPageStartCor.setEditable(false);
		taPageStartCor.setBackground(Color.black);
		taPageStartCor.setOpaque(false);
		taPageStartCor.setForeground(Color.white);

		taPageEndCor = new JTextArea("Date :" + study_date ,3, 10);
		taPageEndCor.append("\nModality :" + modality_name);

		taPageEndCor.setEditable(false);
		taPageEndCor.setOpaque(false);
		taPageEndCor.setBackground(Color.black);
		taPageEndCor.setForeground(Color.white);
		pnlCoronalView.setLayout(new BorderLayout());

		taPageStartSag = new JTextArea("Patient ID:" + patient_id +
"\t\t\t\t\t"+Space+ "Gender :" + patient_gender, 3, 10);
		taPageStartSag.append("\nPatient Name :" + patient_name + "\t\t\t\t\tAge
:" + patient_age);

		taPageStartSag.setEditable(false);
		taPageStartSag.setBackground(Color.black);
		taPageStartSag.setOpaque(false);
		taPageStartSag.setForeground(Color.white);

		taPageEndSag = new JTextArea("Date :" + study_date, 3, 10);
		taPageEndSag.append("\nModality :" + modality_name);

		taPageEndSag.setEditable(false);
		taPageEndSag.setOpaque(false);
		taPageEndSag.setBackground(Color.black);
		taPageEndSag.setForeground(Color.white);
		pnlSagittalView.setLayout(new BorderLayout());
	
	}

	public void setStyles() {
		pnlAxialView.setBackground(Color.BLACK);
	
pnlAxialView.setBorder(BorderFactory.createTitledBorder(BorderFactory.createLineBorder(Color.WHITE,
2),
				"Axial View", TitledBorder.RIGHT, TitledBorder.TOP, new Font("calibri",
Font.BOLD, 14), Color.white));

		pnlCoronalView.setBackground(Color.BLACK);
	
pnlCoronalView.setBorder(BorderFactory.createTitledBorder(BorderFactory.createLineBorder(Color.WHITE,
2),
				"Coronal View", TitledBorder.RIGHT, TitledBorder.TOP, new
Font("calibri", Font.BOLD, 14), Color.white));

		pnlSagittalView.setBackground(Color.BLACK);
		pnlSagittalView.setBorder(
			
BorderFactory.createTitledBorder(BorderFactory.createLineBorder(Color.WHITE,
2), "Sagittal View",
						TitledBorder.RIGHT, TitledBorder.TOP, new Font("calibri", Font.BOLD,
14), Color.white));

		pnlAnnotationView.setBackground(Color.black);

		mprPan.setBackground(Color.black);
		this.setTitle(tittle);
		System.gc();
	}

	public void addComponents(boolean flag) {

		try {

			if (flag == true) {

				pnlSagittalView.add(taPageStartSag, BorderLayout.PAGE_START);
				pnlSagittalView.add(taPageEndSag, BorderLayout.PAGE_END);
				pnlCoronalView.add(taPageStartCor, BorderLayout.PAGE_START);
				pnlCoronalView.add(taPageEndCor, BorderLayout.PAGE_END);
				pnlAxialView.add(taPageStart, BorderLayout.PAGE_START);
				pnlAxialView.add(taPageEnd, BorderLayout.PAGE_END);

			} else {
				pnlSagittalView.remove(taPageStartSag);
				pnlSagittalView.remove(taPageEndSag);
				pnlCoronalView.remove(taPageStartCor);
				pnlCoronalView.remove(taPageEndCor);
				pnlAxialView.remove(taPageStart);
				pnlAxialView.remove(taPageEnd);
			}
			
			mprPan.add(pnlCoronalView);
			mprPan.add(pnlSagittalView);
			splitsPane.add(pnlAxialView);

			mainPan.add(splitsPane);
			mainPan.add(mprPan);

			this.setLocationRelativeTo(null);
			this.setExtendedState(java.awt.Frame.MAXIMIZED_BOTH);

			getContentPane().add(mainPan, BorderLayout.CENTER);
			setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
			this.revalidate();
			this.setVisible(true);
			this.setAlwaysOnTop(true);
			System.gc();

			vpanAxial.GetRenderer().SetBackground(0.0, 0.0, 0.0);
			//vpanAxial.setSize((pnlAxialView.getWidth() - 30),
(pnlAxialView.getHeight() - 40));
			vpanAxial.setSize((pnlAxialView.getWidth()), (pnlAxialView.getHeight()));
			pnlAxialView.add(vpanAxial);
			
			System.out.println("pnlAxialView.add(vpanAxial); added ");

			// change vtk background color
			vpanCoronal.GetRenderer().SetBackground(0.0, 0.0, 0.0);
			// set size of image from here in vtk panel..manually
			//vpanCoronal.setSize((pnlCoronalView.getWidth() + 60),
(pnlCoronalView.getHeight() + 50));
			vpanCoronal.setSize((pnlCoronalView.getWidth()),
(pnlCoronalView.getHeight()));
			pnlCoronalView.add(vpanCoronal);

			vpanSagittal.GetRenderer().SetBackground(0.0, 0.0, 0.0);
			//vpanSagittal.setSize((pnlSagittalView.getWidth() + 60),
(pnlSagittalView.getHeight() + 50));
			vpanSagittal.setSize((pnlSagittalView.getWidth()),
(pnlSagittalView.getHeight()));
			pnlSagittalView.add(vpanSagittal);

			System.gc();

		} catch (Exception ex) {
			ex.printStackTrace();
		}

	}
	
	public void readDicomDir(String path) {
		


		String path1 = "C:\\3D VR\\kidney\\series001\\compression\\";

		reader = new vtkDICOMImageReader();
		reader.SetDirectoryName(path1);
		reader.SetDataScalarTypeToUnsignedShort();
		reader.UpdateWholeExtent();
		reader.Update();
		
		
		
		vtkWindowLevelLookupTable win_table = new vtkWindowLevelLookupTable();
		win_table.SetLevel(110);
		win_table.SetWindow(1300);		
		win_table.SetRampToLinear();
		win_table.Build();		
				

// ---------------------------- XY vtkResliceImageViewer  
		
        resliceImageViewerXY = new vtkResliceImageViewer();
        resliceImageViewerXY.SetInputData(reader.GetOutput());        
        //resliceImageViewerXY.SetSize(512, 512);        
       
resliceImageViewerXY.SetupInteractor(vpanAxial.GetRenderWindow().GetInteractor());        
        resliceImageViewerXY.SliceScrollOnMouseWheelOff();
		resliceImageViewerXY.SetRenderWindow(vpanAxial.GetRenderWindow());
		resliceImageViewerXY.SetRenderer(vpanAxial.GetRenderer());
		
// -------------------------- Reslice cursor XY
------------------------------		    
	
		resliceWidget_resliceImageViewerXY =
resliceImageViewerXY.GetResliceCursorWidget();
	    vtkResliceCursorLineRepresentation rep =
(vtkResliceCursorLineRepresentation)
resliceWidget_resliceImageViewerXY.GetRepresentation();
	    rep.NeedToRenderOn();
	    resliceImageViewerXY.SetResliceCursor(rep.GetResliceCursor());     
       
rep.GetResliceCursorActor().GetCursorAlgorithm().SetReslicePlaneNormal(2); 
	    resliceWidget_resliceImageViewerXY.ManagesCursorOn();
        resliceWidget_resliceImageViewerXY.SetEnabled(1);
     
        resliceImageViewerXY.AddObserver("LeftButtonPressEvent", this,
"myCallback");
        vpanAxial.GetRenderer().ResetCamera();	
        
		interactorStyle.AddObserver("LeftButtonPressEvent",this,"myCallback"); //
Callback not working

		
// ---------------------------- XZ vtkResliceImageViewer   
        
        resliceImageViewerXZ = new vtkResliceImageViewer();
        resliceImageViewerXZ.SetInputData(reader.GetOutput());
        resliceImageViewerXZ.SetSliceOrientationToXZ();        
       
resliceImageViewerXZ.SetupInteractor(vpanCoronal.GetRenderWindow().GetInteractor());
        resliceImageViewerXZ.SliceScrollOnMouseWheelOff();
        resliceImageViewerXZ.SetRenderWindow(vpanCoronal.GetRenderWindow());
        resliceImageViewerXZ.SetRenderer(vpanCoronal.GetRenderer());        
        resliceImageViewerXZ.SetColorWindow(2700.0);
        
        
// -------------------------- Reslice cursor ------------------------------
        
		vtkResliceCursorWidget resliceWidget_resliceImageViewerXZ =
resliceImageViewerXZ.GetResliceCursorWidget();
	    vtkResliceCursorLineRepresentation rep1 =
(vtkResliceCursorLineRepresentation)resliceWidget_resliceImageViewerXZ.GetRepresentation();
	            
	    resliceImageViewerXZ.SetResliceCursor(rep1.GetResliceCursor()); 
	   
rep1.GetResliceCursorActor().GetCursorAlgorithm().SetReslicePlaneNormal(1); 
	    resliceWidget_resliceImageViewerXZ.ManagesCursorOn();
        resliceWidget_resliceImageViewerXZ.SetEnabled(1);
        vpanCoronal.GetRenderer().ResetCamera();
        
        
		interactorStyle.AddObserver("LeftButtonPressEvent",this,"myCallback"); //
Callback not working

        
        
// ---------------------------- YZ vtkResliceImageViewer
        
        resliceImageViewerYZ = new vtkResliceImageViewer();
        resliceImageViewerYZ.SetInputData(reader.GetOutput());
        resliceImageViewerYZ.SetSliceOrientationToYZ();
       
resliceImageViewerYZ.SetupInteractor(vpanSagittal.GetRenderWindow().GetInteractor());
        resliceImageViewerYZ.SetResliceMode(3);
        resliceImageViewerYZ.SetSize(512, 512);
        resliceImageViewerYZ.SliceScrollOnMouseWheelOff();
        
       
resliceImageViewerYZ.SetRenderWindow(vpanSagittal.GetRenderWindow());
        resliceImageViewerYZ.SetRenderer(vpanSagittal.GetRenderer());
        
               
// -------------------------- Reslice cursor YZ
------------------------------
        
		vtkResliceCursorWidget resliceWidget_resliceImageViewerYZ =
resliceImageViewerYZ.GetResliceCursorWidget();
	    vtkResliceCursorLineRepresentation rep11 =
(vtkResliceCursorLineRepresentation)resliceWidget_resliceImageViewerYZ.GetRepresentation();
	    
	    resliceImageViewerYZ.SetResliceCursor(rep11.GetResliceCursor()); 	    
       
rep11.GetResliceCursorActor().GetCursorAlgorithm().SetReslicePlaneNormal(0); 
        resliceWidget_resliceImageViewerYZ.ManagesCursorOn();
        resliceWidget_resliceImageViewerYZ.SetEnabled(1);        
        
		vpanSagittal.GetRenderer().ResetCamera();
		
		interactorStyle.AddObserver("LeftButtonPressEvent",this,"myCallback"); //
Callback not working		

		
}

	void lookUpTableAxial() {


		axialTable.SetRange(WL, WW);
		axialTable.SetValueRange(0.0, 1.0);
		axialTable.SetSaturationRange(0.0, 0.0);
		axialTable.SetRampToLinear();
		axialTable.Build();

		axialColor.SetLookupTable(axialTable);
		axialColor.SetInputConnection(this.resliceAxial.GetOutputPort());

		this.actorAxial = new vtkImageActor();
		this.actorAxial.SetInputData(axialColor.GetOutput());


	}

	void lookUpTableCoronal() {

		coronalTable.SetRange(WL, WW);
		coronalTable.SetValueRange(0.0, 1.0);
		coronalTable.SetSaturationRange(0.0, 0.0);
		coronalTable.SetRampToLinear();
		coronalTable.Build();

		coronnalColor.SetLookupTable(coronalTable);
		coronnalColor.SetInputConnection(this.resliceCoronal.GetOutputPort());

		this.actorCoronal = new vtkImageActor();
		this.actorCoronal.SetInputData(coronnalColor.GetOutput());


	}

	void lookUpTableSaggital() {
	
		saggitalTable.SetRange(WL, WW);
		saggitalTable.SetValueRange(0.0, 1.0);
		saggitalTable.SetSaturationRange(0.0, 0.0);
		saggitalTable.SetRampToLinear();
		saggitalTable.Build();
		saggitalColor.SetLookupTable(saggitalTable);
		saggitalColor.SetInputConnection(this.resliceSagittal.GetOutputPort());

		this.actorSagittal = new vtkImageActor();
		this.actorSagittal.SetInputData(saggitalColor.GetOutput());
	

	}

	@Override
	protected void finalize() throws Throwable {

		vpanAxial = null;
		vpanCoronal = null;
		vpanSagittal = null;
		reader = null;
		actorSagittal = null;
		actorCoronal = null;
		actorAxial = null;

		interactorStyle = null;

		resliceAxial = null;
		resliceCoronal = null;
		resliceSagittal = null;
		pnlAxialView = null;
		pnlCoronalView = null;
		pnlSagittalView = null;
		splitsPane = null;
	}


	
	public static String convertDateTag(String date)
	{
		String year = date.substring(0, 4);
		String month = date.substring(4, 6);
		String day = date.substring(6, 8);
		
		switch(month)
		{
		case "01":
			month = "Jan";
			break;
		case "02":
			month = "Feb";
			break;
		case "03":
			month = "Mar";
			break;
		case "04":
			month = "Apr";
			break;
		case "05":
			month = "May";
			break;
		case "06":
			month = "Jun";
			break;
		case "07":
			month = "Jul";
			break;
		case "08":
			month = "Aug";
			break;
		case "09":
			month = "Sep";
			break;
		case "10":
			month = "Oct";
			break;
		case "11":
			month = "Nov";
			break;
		case "12":
			month = "Dec";
			break;
		}
		return month + " " + day + ", " + year;
	}
	
	public void myCallback() {	
		
		// Not Calling from Observer and Don't know what to right to synchronize
three views
		System.out.println("I am Called");
		
		
		
	}
	
	public void addListners(){
		
		vpanSagittal.addMouseListener(new MouseListener() {
			
			@Override
			public void mouseReleased(MouseEvent e) {
				// TODO Auto-generated method stub
				
			}
			
			@Override
			public void mousePressed(MouseEvent e) {
				// TODO Auto-generated method stub
				
			}
			
			@Override
			public void mouseExited(MouseEvent e) {
				// TODO Auto-generated method stub
				
			}
			
			@Override
			public void mouseEntered(MouseEvent e) {
				// TODO Auto-generated method stub
				
			}
			
			@Override
			public void mouseClicked(MouseEvent me) {
				// TODO Auto-generated method stub

				vtkPointPicker pick_xY = new vtkPointPicker();
				pick_xY.Pick(me.getX(), me.getY(), 0,
resliceImageViewerXY.GetRenderer());
				System.out.println(me.getX() + "     " + me.getX());

				boolean left = SwingUtilities.isLeftMouseButton(me);

				if (left == true) {

					mouseXYAxial = me.getPoint();

					vtkPointPicker pickerAxial = new vtkPointPicker();
					int pickTest = pickerAxial.Pick(mouseXYAxial.x, mouseXYAxial.y, 0.0,
vpanAxial.GetRenderer());

					if (pickTest != 0) {

						// -------------------- cross hairs
						// ----------------------------------

						double[] picked_point = pick_xY.GetMapperPosition();
						double[][] f_point = { picked_point };

						System.out.println(
								"f_point[] = " + f_point[0][0] + ",,," + f_point[0][1] + ",,," +
f_point[0][2]);

						vtkCursor2D cursor = new vtkCursor2D();
						// cursor.SetModelBounds(-512, 512, -512, 512, 0, 0);
					
cursor.SetModelBounds(vpanSagittal.GetRenderer().ComputeVisiblePropBounds());
						System.out.println("vpanAxial.getMousePosition() =" +
vpanSagittal.getMousePosition());
						cursor.SetFocalPoint(f_point[0][0], f_point[0][1], f_point[0][2]);
						cursor.SetWrap(10);

						vtkPolyDataMapper cursorMapper = new vtkPolyDataMapper();
						cursorMapper.SetInputConnection(cursor.GetOutputPort());

						vpanSagittal.Render();

						// --------------------------------- cross hairs
						// ---------------------

					}
					// removeListeners();

				}

			}
		});
		
	}
	
	
	
}





--
Sent from: http://vtk.1045678.n5.nabble.com/VTK-Users-f1224199.html


More information about the vtkusers mailing list