/*========================================================================= Program: FusionViewer Module: $RCSfile: ImageDisplayModel.java,v $ Language: Java Date: $Date: 2007/02/02 19:27:10 $ Version: $Revision: 1.4 $ Copyright (c) Insightful Corporation. All rights reserved. See Copyright.txt for details. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the above copyright notice for more information. =========================================================================*/ package org.fusionviewer.model; import org.fusionviewer.display.Colormap; import org.fusionviewer.display.ColormapManager; import org.fusionviewer.display.Image; /**\interface ImageDisplayModel *\brief Access to image display parameters. * Each model may have multiple images indexed from 0 to n. * The implementation decides which parameters should be shared between images. */ public interface ImageDisplayModel { /** * Used by model listeners to signal an image has changed. */ public final static int IMAGE_CHANGED = 1; /** * Used by model listeners to signal the image position has changed. */ public final static int POSITION_CHANGED = 2; /** * Used by model listeners to signal the window and level have changed. */ public final static int WINDOWLEVEL_CHANGED = 3; /** * Used by model listeners to signal the color map has changed. */ public final static int COLORMAP_CHANGED = 4; /** * Used by model listeners to signal the crosshair visibility has changed. */ public final static int CROSSHAIRS_CHANGED = 5; /** * Used by model listeners to signal the image size has changed. */ public final static int SIZE_CHANGED = 6; public final static int LAST_MESSAGE_VALUE = CROSSHAIRS_CHANGED; /** * Bit mask indicating all images have been modified */ public final static int ALL_IMAGES = 0xFFFFFFFF; /** * Left-mouse button navigates a 3D image */ public final static int MOUSE_MODE_NAVIGATE = 1; /** * Left-mouse changes the zoom/magnification of an image display */ public final static int MOUSE_MODE_ZOOM = 2; /** * Left-mouse pans in a zoomed/magnified image display */ public final static int MOUSE_MODE_PAN = 3; /** * Left-mouse copies the image display */ public final static int MOUSE_MODE_COPYIMAGE = 4; /** * Left-mouse draws a rectangular region of interest */ public final static int MOUSE_MODE_RECTANGLE_ROI = 5; /** * Left-mouse measures a line */ public final static int MOUSE_MODE_MEASURE_LINE = 6; /** * get the reference image * * @param image reference image to get */ public int getReferenceImgId(); /** * Update an image slot in the model with a new image * * @param idx image to replace * @param image new image to add * @param refImage reference image with maximum physical size; * @param notify true if listeners should be notified a new image was loaded */ public void setImage(int idx, Image image, boolean fusionMode, boolean notify); /** * Get the number of images in this model * * @return number of images */ public int getNumImages(); /** * Get an image in the model * * @param idx index for the image * @return image */ public Image getImage(int idx); /** * Get the pixel scaling offset: output = slope * input + offset * * @param image image identifier * @return scaling offset */ public float getOffset(int image); /** * Get the pixel scaling slope: output = slope * input + offset * * @param image image identifier * @return scaling slope */ public float getSlope(int image); /** * Get the pixel scaling window * * @param image image identifier * @return scaling window */ public float getWindow(int image); /** * Get the pixel scaling level * * @param image image identifier * @return scaling level */ public float getLevel(int image); /** * Get the minimum pixel value of the image * * @param image image identifier * @return the minimum value */ public float getMinValue(int image); /** * Get the range of pixel values in the image * * @param image image identifier * @return the maximum window */ public float getPixelRange(int image); /** * Set the pixel scaling as window and level. * output = MAX_PIXEL_VALUE / window * input + (level - window / 2) * * @param image image identifier * @param offset scaling offset * @param slope scaling slope */ public void setOffsetSlope(int image, float offset, float slope); /** * Set the pixel scaling as window and level. * output = MAX_PIXEL_VALUE / window * input + (level - window / 2) * * @param image image identifier * @param window scaling window * @param level scaling level */ public void setWindowLevel(int image, float window, float level); /** * Get a component of the cursor position. The components are indexed from 0-2. * * @param image image identifier * @param idx cursor position index * @return position at index */ public float getPosition(int image, int idx); /** * Get the cursor position. * * @param image image identifier * @return the x, y, z cursor position */ public float[] getPosition(int image); /** * Set a component of the cursor position. The components are indexed from 0-2. * * @param image image identifier * @param idx component to set * @param value set the position component to this value * @param notify true if listeners should be notified of the change (i.e., this * could be false if you want to make several changes and only notify on the last change) */ public void setPosition(int image, int idx, float value, boolean notify); /** * Set the cursor position. * * @param image image identifier * @param position an array containing the x, y, z coordinates * @param notify true if listeners should be notified of the change */ public void setPosition(int image, float[] position, boolean notify); /** * Get the current color map. * * @param image image identifier * @return color map */ public Colormap getColormap(int image); /** * Set the color map. * * @param image image identifier * @param map color map */ public void setColormap(int image, Colormap map); /** * Query whether the image should be shown as inverted * * @param image image identifier * @return true if the image should be shown as inverted */ public boolean isInverted(int image); /** * Get the colormaps array. * * @return colormapManager */ public ColormapManager getColormapArray(); /** * Set whether the image should be shown as inverted * * @param image image identifier * @param inverted true if the image should be inverted */ public void setInverted(int image, boolean inverted); /** * Returns the function of the left mouse button. See the CURSOR_MODE_* static members * for allowable values. * * @return left mouse button mode */ public int getMouseMode(); /** * Sets the function of the left mouse button. See the CURSOR_MODE_* static members * for allowable values. * * @param mode left mouse button mode */ public void setMouseMode(int mode); /** * Query whether crosshairs should be drawn at the current position. * * @return true if crosshairs should be drawn */ public boolean getCrosshairsVisible(); /** * Set whether crosshairs should be drawn at the current position. * * @param visible true if crosshairs should be drawn */ public void setCrosshairsVisible(boolean visible); /** * Add an object that should be notified of state changes. * * @param listener object to add */ public void addListener(ImageDisplayModelListener listener); /** * Remove an object that is no longer interested in state changes. * * @param listener object to remove */ public void removeListener(ImageDisplayModelListener listener); /** * Notify listeners of a change in this object's state * * @param type parameter changed * @param images bit mask for the affected images */ public void notifyListeners(int type, int images); /** * Test whether an image id is included in an image set. This method is used * in conjunction with ImageDisplayModelListener's modelChanged method, * which includes a mask as a parameter. * * @param id image id * @param imageSet set of images * @return true if the image is in the set */ public boolean setIncludesImage(int id, int imageSet); }