Skip to content

Commit

Permalink
Merge pull request #2365 from joshmoore/12145-rnd-settings
Browse files Browse the repository at this point in the history
Shared rendering settings
  • Loading branch information
sbesson committed May 19, 2014
2 parents 9c14586 + a363cd2 commit 5b39a71
Show file tree
Hide file tree
Showing 22 changed files with 920 additions and 199 deletions.
6 changes: 4 additions & 2 deletions components/blitz/resources/omero/api/RenderingEngine.ice
Expand Up @@ -68,8 +68,10 @@ module omero {
void updateCodomainMap(omero::romio::CodomainMapContext mapCtx) throws ServerError;
void removeCodomainMap(omero::romio::CodomainMapContext mapCtx) throws ServerError;
void saveCurrentSettings() throws ServerError;
void resetDefaults() throws ServerError;
void resetDefaultsNoSave() throws ServerError;
long saveAsNewSettings() throws ServerError;
["deprecated:resetDefaults() is deprecated"] void resetDefaults() throws ServerError;
["deprecated:resetDefaultsNoSave() is deprecated"] void resetDefaultsNoSave() throws ServerError;
long resetDefaultsSettings(bool save) throws ServerError;
void setCompressionLevel(float percentage) throws ServerError;
float getCompressionLevel() throws ServerError;
bool isPixelsTypeSigned() throws ServerError;
Expand Down
13 changes: 13 additions & 0 deletions components/blitz/src/ome/services/blitz/impl/RenderingEngineI.java
Expand Up @@ -51,6 +51,8 @@
import omero.api.AMD_RenderingEngine_renderProjectedCompressed;
import omero.api.AMD_RenderingEngine_resetDefaults;
import omero.api.AMD_RenderingEngine_resetDefaultsNoSave;
import omero.api.AMD_RenderingEngine_resetDefaultsSettings;
import omero.api.AMD_RenderingEngine_saveAsNewSettings;
import omero.api.AMD_RenderingEngine_saveCurrentSettings;
import omero.api.AMD_RenderingEngine_setActive;
import omero.api.AMD_RenderingEngine_setChannelWindow;
Expand Down Expand Up @@ -376,6 +378,17 @@ public void resetDefaults_async(AMD_RenderingEngine_resetDefaults __cb,
callInvokerOnRawArgs(__cb, __current);
}

public void resetDefaultsSettings_async(AMD_RenderingEngine_resetDefaultsSettings __cb,
boolean save, Current __current) throws ServerError {
callInvokerOnRawArgs(__cb, __current);
}

public void saveAsNewSettings_async(
AMD_RenderingEngine_saveAsNewSettings __cb, Current __current)
throws ServerError {
callInvokerOnRawArgs(__cb, __current);
}

public void saveCurrentSettings_async(
AMD_RenderingEngine_saveCurrentSettings __cb, Current __current)
throws ServerError {
Expand Down
19 changes: 17 additions & 2 deletions components/common/src/omeis/providers/re/RenderingEngine.java
@@ -1,7 +1,7 @@
/*
* omeis.providers.re.RenderingEngine
*
* Copyright 2006 University of Dundee. All rights reserved.
* Copyright 2006-2014 University of Dundee. All rights reserved.
* Use is subject to license terms supplied in LICENSE.txt
*/

Expand Down Expand Up @@ -509,6 +509,12 @@ public void setQuantizationMap(int w, Family family, double coefficient,
/** Saves the current rendering settings in the database. */
public void saveCurrentSettings();

/** Saves the current rendering settings in the database
* <em>as a new {@link RenderingDef} and loads the object
* into the current {@link RenderingEngine}.
*/
public long saveAsNewSettings();

/**
* Resets the default settings i.e. the default values internal to the
* Rendering engine. The settings will be saved.
Expand All @@ -521,7 +527,16 @@ public void setQuantizationMap(int w, Family family, double coefficient,
* be saved.
*/
public void resetDefaultsNoSave();


/**
* Resets the default settings i.e. the default values internal to the
* Rendering engine. The settings will be saved.
*
* @param save Pass <code>true</code> to save the settings,
* <code>false</code> otherwise.
*/
public long resetDefaultsSettings(boolean save);

/**
* Sets the current compression level for the service. (The default is 85%)
*
Expand Down
Expand Up @@ -143,6 +143,13 @@ private void handleException(Throwable e, boolean notify)
UserNotifier un = MetadataViewerAgent.getRegistry().getUserNotifier();
if (e instanceof RenderingServiceException) {
RenderingServiceException ex = (RenderingServiceException) e;
switch (ex.getIndex()) {
case RenderingServiceException.CONNECTION:
return;
case RenderingServiceException.OPERATION_NOT_SUPPORTED:
un.notifyInfo("Image", "Operation not Supported");
return;
}
if (ex.getIndex() == RenderingServiceException.CONNECTION)
return;
}
Expand Down
Expand Up @@ -1074,9 +1074,7 @@ public void loadViewedBy(Component source, Point location)
{
Object ref = model.getRefObject();
if (ref instanceof ImageData || ref instanceof WellSampleData) {
if (model.getViewedBy() != null)
setViewedBy(model.getViewedBy(), source, location);
else model.fireViewedByLoading(source, location);
model.fireViewedByLoading(source, location);
}
}

Expand Down Expand Up @@ -1125,6 +1123,9 @@ public void saveSettings()
{
//Previewed the image.
Renderer rnd = model.getEditor().getRenderer();
if (rnd != null) {
model.fireThumbnailsLoading();
}
if (rnd != null && getRndIndex() == RND_GENERAL) {
//save settings
long imageID = -1;
Expand Down
Expand Up @@ -913,8 +913,11 @@ void setViewedBy(Map viewedBy)
}
}
}
this.viewedBy = m;
getEditor().getRenderer().loadRndSettings(true, null);
this.viewedBy = m;
Renderer rnd = getEditor().getRenderer();
if (rnd != null) {
rnd.loadRndSettings(true, null);
}
}

/**
Expand Down Expand Up @@ -944,6 +947,7 @@ else if (refObject instanceof WellSampleData)
/** Starts an asynchronous retrieval of the thumbnails. */
void fireThumbnailsLoading()
{
if (viewedBy == null) return;
ImageData image = null;
if (refObject instanceof ImageData) image = (ImageData) refObject;
else if (refObject instanceof WellSampleData)
Expand Down
Expand Up @@ -246,42 +246,45 @@ void setLocationAndSource(Component source, Point location)
*/
void viewedBy(Component source, Point location)
{
if (viewedByMenu == null) {
Map m = model.getViewedBy();
viewedByMenu = new JPopupMenu();
ViewerSorter sorter = new ViewerSorter();
List list = sorter.sort(m.keySet());
Iterator i = list.iterator();
ViewedByItem item ;
ExperimenterData exp;
while (i.hasNext()) {
exp = (ExperimenterData) i.next();
item = new ViewedByItem(exp, (RndProxyDef) m.get(exp));
item.addPropertyChangeListener(
ViewedByItem.VIEWED_BY_PROPERTY, this);
viewedByMenu.add(item);
}
if (list.size() == 0) {
thumbnailsMenuItem = new JMenuItem("Not viewed");
thumbnailsMenuItem.setToolTipText("No other users " +
"viewed the image.");
} else {
IconManager icons = IconManager.getInstance();
thumbnailsMenuItem = new JMenuItem("Show thumbnails");
thumbnailsMenuItem.setIcon(icons.getIcon(
IconManager.PREVIEW_THUMBNAILS_32));
thumbnailsMenuItem.addActionListener(new ActionListener() {

public void actionPerformed(ActionEvent e)
{
showViewedBy();
}
});
}

viewedByMenu.add(thumbnailsMenuItem);
if (viewedByMenu == null) {
viewedByMenu = new JPopupMenu();
}
viewedByMenu.removeAll();
Map m = model.getViewedBy();
ViewerSorter sorter = new ViewerSorter();
List list = sorter.sort(m.keySet());
Iterator i = list.iterator();
ViewedByItem item ;
ExperimenterData exp;
while (i.hasNext()) {
exp = (ExperimenterData) i.next();
item = new ViewedByItem(exp, (RndProxyDef) m.get(exp));
item.addPropertyChangeListener(
ViewedByItem.VIEWED_BY_PROPERTY, this);
viewedByMenu.add(item);
}
if (list.size() == 0) {
thumbnailsMenuItem = new JMenuItem("No settings saved");
thumbnailsMenuItem.setToolTipText("No other users " +
"saved the rendering settings.");
} else {
IconManager icons = IconManager.getInstance();
thumbnailsMenuItem = new JMenuItem("Show thumbnails");
thumbnailsMenuItem.setIcon(icons.getIcon(
IconManager.PREVIEW_THUMBNAILS_32));
thumbnailsMenuItem.addActionListener(new ActionListener() {

public void actionPerformed(ActionEvent e)
{
showViewedBy();
}
});
}

viewedByMenu.add(thumbnailsMenuItem);
if (source != null && source.isVisible()) {
viewedByMenu.show(source, location.x, location.y);
}
viewedByMenu.show(source, location.x, location.y);
}

/** Displays all the thumbnails. */
Expand Down Expand Up @@ -341,6 +344,7 @@ void setThumbnails(Map<Long, BufferedImage> thumbnails)
}
}
}
if (items != null) showViewedBy();
thumbnailsMenuItem.setEnabled(items.size() > 0);
model.getEditor().getRenderer().loadRndSettings(true, null);
}
Expand Down
Expand Up @@ -8452,4 +8452,28 @@ Map<Long, List<IObject>> loadLogFiles(SecurityContext ctx,
}
return new HashMap();
}

/**
* Retrieves the rendering settings for the specified pixels set.
*
* @param ctx The security context.
* @param rndID The rendering settings ID.
* @return See above.
* @throws DSOutOfServiceException If the connection is broken, or logged
* in.
* @throws DSAccessException If an error occurred while trying to
* retrieve data from OMEDS service.
*/
RenderingDef getRenderingDef(SecurityContext ctx, long rndID)
throws DSOutOfServiceException, DSAccessException
{
Connector c = getConnector(ctx, true, false);
try {
IPixelsPrx service = c.getPixelsService();
return service.loadRndSettings(rndID);
} catch (Exception e) {
handleException(e, "Cannot retrieve the rendering settings");
}
return null;
}
}
Expand Up @@ -2,10 +2,10 @@
* org.openmicroscopy.shoola.env.data.OmeroImageService
*
*------------------------------------------------------------------------------
* Copyright (C) 2006-2013 University of Dundee. All rights reserved.
* Copyright (C) 2006-2014 University of Dundee. All rights reserved.
*
*
* This program is free software; you can redistribute it and/or modify
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
Expand Down Expand Up @@ -40,7 +40,6 @@
import omero.api.ThumbnailStorePrx;
//Application-internal dependencies
import omero.constants.projection.ProjectionType;
import omero.model.RenderingDef;
import omero.romio.PlaneDef;
import org.openmicroscopy.shoola.env.data.model.ImportableFile;
import org.openmicroscopy.shoola.env.data.model.ImportableObject;
Expand Down Expand Up @@ -68,9 +67,6 @@
* @author Donald MacDonald &nbsp;&nbsp;&nbsp;&nbsp;
* <a href="mailto:donald@lifesci.dundee.ac.uk">donald@lifesci.dundee.ac.uk</a>
* @version 3.0
* <small>
* (<b>Internal version:</b> $Revision: $ $Date: $)
* </small>
* @since OME2.2
*/
public interface OmeroImageService
Expand Down Expand Up @@ -898,4 +894,17 @@ ThumbnailStorePrx createThumbnailStore(SecurityContext ctx)
Long getRenderingDef(SecurityContext ctx, long pixelsID, long userID)
throws DSOutOfServiceException, DSAccessException;

/**
* Retrieves the rendering settings for the specified pixels set.
*
* @param ctx The security context.
* @param rndID The rendering settings ID.
* @return See above.
* @throws DSOutOfServiceException If the connection is broken, or logged
* in.
* @throws DSAccessException If an error occurred while trying to
* retrieve data from OMEDS service.
*/
RndProxyDef getSettings(SecurityContext ctx, long rndID)
throws DSOutOfServiceException, DSAccessException;
}
Expand Up @@ -2,10 +2,10 @@
* org.openmicroscopy.shoola.env.data.OmeroImageServiceImpl
*
*------------------------------------------------------------------------------
* Copyright (C) 2006-2013 University of Dundee. All rights reserved.
* Copyright (C) 2006-2014 University of Dundee. All rights reserved.
*
*
* This program is free software; you can redistribute it and/or modify
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
Expand Down Expand Up @@ -122,10 +122,6 @@
* <a href="mailto:j.burel@dundee.ac.uk">j.burel@dundee.ac.uk</a>
* @author Donald MacDonald &nbsp;&nbsp;&nbsp;&nbsp;
* <a href="mailto:donald@lifesci.dundee.ac.uk">donald@lifesci.dundee.ac.uk</a>
* @version 3.0
* <small>
* (<b>Internal version:</b> $Revision: $ $Date: $)
* </small>
* @since OME3.0
*/
class OmeroImageServiceImpl
Expand Down Expand Up @@ -1906,4 +1902,17 @@ public Long getRenderingDef(SecurityContext ctx, long pixelsID,
return def.getId().getValue();
}

/**
* Implemented as specified by {@link OmeroDataService}.
* @see OmeroImageService#getRenderingDef(SecurityContext, long)
*/
public RndProxyDef getSettings(SecurityContext ctx, long rndID)
throws DSOutOfServiceException, DSAccessException
{
if (rndID < 0) return null;
RenderingDef def = gateway.getRenderingDef(ctx, rndID);
if (def == null) return null;
return PixelsServicesFactory.convert(def);
}

}
Expand Up @@ -2,10 +2,10 @@
* org.openmicroscopy.shoola.env.rnd.RenderingControlFactory
*
*------------------------------------------------------------------------------
* Copyright (C) 2006 University of Dundee. All rights reserved.
* Copyright (C) 2006-2014 University of Dundee. All rights reserved.
*
*
* This program is free software; you can redistribute it and/or modify
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
Expand Down Expand Up @@ -75,10 +75,6 @@
* <a href="mailto:j.burel@dundee.ac.uk">j.burel@dundee.ac.uk</a>
* @author Andrea Falconi &nbsp;&nbsp;&nbsp;&nbsp;
* <a href="mailto:a.falconi@dundee.ac.uk">a.falconi@dundee.ac.uk</a>
* @version 3.0
* <small>
* (<b>Internal version:</b> $Revision: $ $Date: $)
* </small>
* @since OME2.2
*/
public class PixelsServicesFactory
Expand Down Expand Up @@ -146,7 +142,7 @@ public static RndProxyDef convert(RenderingDef rndDef)
{
if (rndDef == null) return null;

RndProxyDef proxy = new RndProxyDef();
RndProxyDef proxy = new RndProxyDef(rndDef);
try {
long v = rndDef.getDetails().getUpdateEvent().getTime().getValue();
proxy.setLastModified(new Timestamp(v));
Expand Down

0 comments on commit 5b39a71

Please sign in to comment.