Skip to content

Commit

Permalink
fixes #180
Browse files Browse the repository at this point in the history
  • Loading branch information
NicoKiaru committed May 7, 2021
1 parent fcf6a68 commit 0cee843
Show file tree
Hide file tree
Showing 37 changed files with 648 additions and 653 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -110,19 +110,19 @@ public void run() {
for (SourceAndConverter sourceAndConverter : sacs) {

// Wraps into a Transformed Source, if the source was displayed originally
if (SourceAndConverterServices.getSourceAndConverterDisplayService().getDisplaysOf(sourceAndConverter).contains(bdvHandle)) {
if (SourceAndConverterServices.getSourceAndConverterDisplayService().isVisible(sourceAndConverter, bdvHandle)) {
if (SourceAndConverterServices.getBdvDisplayService().getDisplaysOf(sourceAndConverter).contains(bdvHandle)) {
if (SourceAndConverterServices.getBdvDisplayService().isVisible(sourceAndConverter, bdvHandle)) {
displayedSacsWrapped.add(new SourceAffineTransformer(sourceAndConverter, new AffineTransform3D()).getSourceOut());
originallyDisplayedSacs.add(sourceAndConverter);
}
}
}

// Remove from display the originally displayed sources
SourceAndConverterServices.getSourceAndConverterDisplayService().remove(bdvHandle, originallyDisplayedSacs.toArray(new SourceAndConverter[0]));
SourceAndConverterServices.getBdvDisplayService().remove(bdvHandle, originallyDisplayedSacs.toArray(new SourceAndConverter[0]));

// Shows the displayed wrapped Source
SourceAndConverterServices.getSourceAndConverterDisplayService().show(bdvHandle, displayedSacsWrapped.toArray(new SourceAndConverter[0]));
SourceAndConverterServices.getBdvDisplayService().show(bdvHandle, displayedSacsWrapped.toArray(new SourceAndConverter[0]));

// View of the BdvHandle before starting the registration
AffineTransform3D originalViewTransform = new AffineTransform3D();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ public void run() {

// Removes temporary TransformedSourceAndConverter - a two step process in order to improve performance
List<SourceAndConverter> tempSacs = starter.getTransformedSourceAndConverterDisplayed();
SourceAndConverterServices.getSourceAndConverterDisplayService().remove(starter.bdvHandle,tempSacs.toArray(new SourceAndConverter[0]));
SourceAndConverterServices.getBdvDisplayService().remove(starter.bdvHandle,tempSacs.toArray(new SourceAndConverter[0]));

for (SourceAndConverter sac: tempSacs) {
SourceAndConverterServices.getSourceAndConverterService().remove(sac);
Expand All @@ -114,7 +114,7 @@ public void run() {
}

// Calls display ( array for better performance )
SourceAndConverterServices.getSourceAndConverterDisplayService().show(starter.getBdvHandle(),
SourceAndConverterServices.getBdvDisplayService().show(starter.getBdvHandle(),
transformedSacsToDisplay.toArray(new SourceAndConverter[0]));

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,6 @@ public void run() {

@Override
public void accept(SourceAndConverter... sacs) {
SourceAndConverterServices.getSourceAndConverterDisplayService().show(bdvh, sacs);
SourceAndConverterServices.getBdvDisplayService().show(bdvh, sacs);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -73,10 +73,10 @@ public void run() {
public void accept(SourceAndConverter... sacs) {
if (bdvh==null) {
// Remove from all displays
SourceAndConverterServices.getSourceAndConverterDisplayService().removeFromAllBdvs(sacs);
SourceAndConverterServices.getBdvDisplayService().removeFromAllBdvs(sacs);
} else {
// Remove from a specific bdvHandle
SourceAndConverterServices.getSourceAndConverterDisplayService().remove(bdvh, sacs);
SourceAndConverterServices.getBdvDisplayService().remove(bdvh, sacs);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ public void isDisabled() {
ssb.addToggleListener(toggleListener);

// Provides a way to retrieve this installer -> can be used to uninstalling it {@link EditorBehaviourUninstaller}
SourceAndConverterServices.getSourceAndConverterDisplayService().setDisplayMetadata(
SourceAndConverterServices.getBdvDisplayService().setDisplayMetadata(
bdvh, EditorBehaviourInstaller.class.getSimpleName(), this);

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,10 @@ public EditorBehaviourUnInstaller(BdvHandle bdvh) {
@Override
public void run() {

SourceSelectorBehaviour ssb = (SourceSelectorBehaviour) SourceAndConverterServices.getSourceAndConverterDisplayService().getDisplayMetadata(
SourceSelectorBehaviour ssb = (SourceSelectorBehaviour) SourceAndConverterServices.getBdvDisplayService().getDisplayMetadata(
bdvh, SourceSelectorBehaviour.class.getSimpleName());

EditorBehaviourInstaller ebi = (EditorBehaviourInstaller) SourceAndConverterServices.getSourceAndConverterDisplayService().getDisplayMetadata(
EditorBehaviourInstaller ebi = (EditorBehaviourInstaller) SourceAndConverterServices.getBdvDisplayService().getDisplayMetadata(
bdvh, EditorBehaviourInstaller.class.getSimpleName());

if ((ssb==null)||(ebi==null)) {
Expand All @@ -65,7 +65,7 @@ public void run() {
ssb.removeToggleListener(ebi.getToggleListener());

// Cleans the MetaData hashMap
SourceAndConverterServices.getSourceAndConverterDisplayService().setDisplayMetadata(
SourceAndConverterServices.getBdvDisplayService().setDisplayMetadata(
bdvh, EditorBehaviourInstaller.class.getSimpleName(), null);

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,9 +82,9 @@ public JsonElement serialize(SourceAndConverter sourceAndConverter,
if (sourceAndConverter.getConverter() instanceof ColorConverter) {
ColorConverter colorConverter = (ColorConverter) sourceAndConverter.getConverter();
obj.add("color", jsonSerializationContext.serialize(colorConverter.getColor().get()));
double min = SourceAndConverterServices.getSourceAndConverterDisplayService()
double min = SourceAndConverterServices.getBdvDisplayService()
.getConverterSetup(sourceAndConverter).getDisplayRangeMin();
double max = SourceAndConverterServices.getSourceAndConverterDisplayService()
double max = SourceAndConverterServices.getBdvDisplayService()
.getConverterSetup(sourceAndConverter).getDisplayRangeMax();
obj.addProperty("converter_setup_min", min);
obj.addProperty("converter_setup_max", max);
Expand Down Expand Up @@ -147,7 +147,7 @@ public SourceAndConverter deserialize(JsonElement jsonElement, Type type, JsonDe
int color = jsonObject.getAsJsonPrimitive("color").getAsInt();
new ColorChanger(sac, new ARGBType(color)).run(); // TO deal with volatile and non volatile
// Min Max display
SourceAndConverterServices.getSourceAndConverterDisplayService()
SourceAndConverterServices.getBdvDisplayService()
.getConverterSetup(sac).setDisplayRange(
jsonObject.getAsJsonPrimitive("converter_setup_min").getAsDouble(),
jsonObject.getAsJsonPrimitive("converter_setup_max").getAsDouble());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ public class BdvSourcesAdderCommand implements BdvPlaygroundActionCommand {
@Override
public void run() {

SourceAndConverterServices.getSourceAndConverterDisplayService().show(bdvh, sacs);
SourceAndConverterServices.getBdvDisplayService().show(bdvh, sacs);
if (autocontrast) {
for (SourceAndConverter sac : sacs) {
int timepoint = bdvh.getViewerPanel().state().getCurrentTimepoint();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public class BdvSourcesRemoverCommand implements BdvPlaygroundActionCommand {
@Override
public void run() {
for (SourceAndConverter sac:sacs) {
SourceAndConverterServices.getSourceAndConverterDisplayService().remove(bdvh, sac);
SourceAndConverterServices.getBdvDisplayService().remove(bdvh, sac);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ public class BdvSourcesShowCommand implements BdvPlaygroundActionCommand {
public void run() {
bdvh = sacDisplayService.getNewBdv();

SourceAndConverterServices.getSourceAndConverterDisplayService().show(bdvh, sacs);
SourceAndConverterServices.getBdvDisplayService().show(bdvh, sacs);
if (autocontrast) {
for (SourceAndConverter sac : sacs) {
int timepoint = bdvh.getViewerPanel().state().getCurrentTimepoint();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public class MultiBdvSourcesAdderCommand implements BdvPlaygroundActionCommand {
@Override
public void run() {
for (BdvHandle bdvh : bdvhs) {
SourceAndConverterServices.getSourceAndConverterDisplayService().show(bdvh, sacs);
SourceAndConverterServices.getBdvDisplayService().show(bdvh, sacs);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ public void run() {

// Starting synchronization of selected bdvhandles
sync = new ViewerTransformSyncStarter(bdvhs, synchronizetime);
sync.setBdvHandleInitialReference( SourceAndConverterServices.getSourceAndConverterDisplayService().getActiveBdv());
sync.setBdvHandleInitialReference( SourceAndConverterServices.getBdvDisplayService().getActiveBdv());
sync.run();

// JFrame serving the purpose of stopping synchronization when it is being closed
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ public void run() {

for (SourceAndConverter sac : sacs) {
bvvh.getConverterSetups()
.put(sac,SourceAndConverterServices.getSourceAndConverterDisplayService().getConverterSetup(sac));
.put(sac,SourceAndConverterServices.getBdvDisplayService().getConverterSetup(sac));
bvvh.getViewerPanel()
.state().addSource(sac);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ public void run() {
}
}
}
SourceAndConverterServices.getSourceAndConverterDisplayService()
SourceAndConverterServices.getBdvDisplayService()
.updateDisplays(sacs);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,8 +104,8 @@ public void updateMessage() {
public void init() {
if (sources!=null)
if (sources.length>0) {
double minSource = SourceAndConverterServices.getSourceAndConverterDisplayService().getConverterSetup(sources[0]).getDisplayRangeMin();
double maxSource = SourceAndConverterServices.getSourceAndConverterDisplayService().getConverterSetup(sources[0]).getDisplayRangeMax();
double minSource = SourceAndConverterServices.getBdvDisplayService().getConverterSetup(sources[0]).getDisplayRangeMin();
double maxSource = SourceAndConverterServices.getBdvDisplayService().getConverterSetup(sources[0]).getDisplayRangeMax();

if (minSource>=0) {
min = 0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -319,7 +319,7 @@ public void initialize() {
scriptService.addAlias(BdvHandle.class);
displayToMetadata = CacheBuilder.newBuilder().weakKeys().build();//new HashMap<>();
bdvSourceAndConverterService.setDisplayService(this);
SourceAndConverterServices.setSourceAndConverterDisplayService(this);
SourceAndConverterServices.setBdvDisplayService(this);
// Catching bdv supplier from Prefs
log.accept("Bdv Playground Display Service initialized.");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,14 +77,14 @@ public void importSourcesAndConverters(TransferSupport support, List<SourceAndCo
// Can be extended for custom action on sources import
Optional<BdvHandle> bdvh = getBdvHandleFromViewerPanel(((bdv.viewer.ViewerPanel)support.getComponent()));
if (bdvh.isPresent()) {
SourceAndConverterServices.getSourceAndConverterDisplayService()
SourceAndConverterServices.getBdvDisplayService()
.show(bdvh.get(), sacs.toArray(new SourceAndConverter[0]));
}
}

public Optional<BdvHandle> getBdvHandleFromViewerPanel(ViewerPanel viewerPanel) {
return SourceAndConverterServices.
getSourceAndConverterDisplayService()
getBdvDisplayService()
.getDisplays().stream().filter(bdvh -> bdvh.getViewerPanel().equals(viewerPanel)).findFirst();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,11 @@ public static void setSourceAndConverterService(ISourceAndConverterService sourc
SourceAndConverterServices.sourceAndConverterService = sourceAndConverterService;
}

public static SourceAndConverterBdvDisplayService getSourceAndConverterDisplayService() {
public static SourceAndConverterBdvDisplayService getBdvDisplayService() {
return sourceAndConverterBdvDisplayService;
}

public static void setSourceAndConverterDisplayService(SourceAndConverterBdvDisplayService sourceAndConverterBdvDisplayService) {
public static void setBdvDisplayService(SourceAndConverterBdvDisplayService sourceAndConverterBdvDisplayService) {
SourceAndConverterServices.sourceAndConverterBdvDisplayService = sourceAndConverterBdvDisplayService;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@
import bdv.viewer.Interpolation;
import bdv.viewer.Source;
import bdv.viewer.SourceAndConverter;
import bdv.viewer.SourceGroup;
import mpicbg.spim.data.generic.AbstractSpimData;
import net.imglib2.*;
import net.imglib2.converter.Converter;
Expand Down Expand Up @@ -813,10 +812,10 @@ public static double getCharacteristicVoxelSize(AffineTransform3D sourceTransfor
bdvHandle.getBdvHandle().getViewerPanel().getGlobalMouseCoordinates( mousePosInBdv );
int timePoint = bdvHandle.getViewerPanel().state().getCurrentTimepoint();

final List< SourceAndConverter< ? > > sourceAndConverters = SourceAndConverterServices.getSourceAndConverterDisplayService().getSourceAndConverterOf( bdvHandle )
final List< SourceAndConverter< ? > > sourceAndConverters = SourceAndConverterServices.getBdvDisplayService().getSourceAndConverterOf( bdvHandle )
.stream()
.filter( sac -> isSourcePresentAt( sac, timePoint, mousePosInBdv ) )
.filter( sac -> SourceAndConverterServices.getSourceAndConverterDisplayService().isVisible( sac, bdvHandle ) )
.filter( sac -> SourceAndConverterServices.getBdvDisplayService().isVisible( sac, bdvHandle ) )
.collect( Collectors.toList() );

return sourceAndConverters;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public BrightnessAdjuster(final SourceAndConverter sac, double min, double max )
@Override
public void run()
{
SourceAndConverterServices.getSourceAndConverterDisplayService().getConverterSetup( sac ).setDisplayRange(min, max);
SourceAndConverterServices.getBdvDisplayService().getConverterSetup( sac ).setDisplayRange(min, max);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ public void run()

//minMaxGroup.getMinBoundedValue().setCurrentValue( min );
//minMaxGroup.getMaxBoundedValue().setCurrentValue( max );
ConverterSetup converterSetup = SourceAndConverterServices.getSourceAndConverterDisplayService().getConverterSetup( sac );
ConverterSetup converterSetup = SourceAndConverterServices.getBdvDisplayService().getConverterSetup( sac );
converterSetup.setDisplayRange(min, max);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,8 @@ public void accept(SourceAndConverter sourceAndConverter) {
((ColorConverter) sourceAndConverter.asVolatile().getConverter()).setColor(color);
}
// Updates display, if any
if ( SourceAndConverterServices.getSourceAndConverterDisplayService()!=null)
SourceAndConverterServices.getSourceAndConverterDisplayService().getConverterSetup(sourceAndConverter).setColor(color);
if ( SourceAndConverterServices.getBdvDisplayService()!=null)
SourceAndConverterServices.getBdvDisplayService().getConverterSetup(sourceAndConverter).setColor(color);
} else {
new SystemLogger().err("sourceAndConverter Converter is not an instance of Color Converter");
}
Expand Down
Loading

0 comments on commit 0cee843

Please sign in to comment.