From 0f133a3df6aba962e12bfc0b786ec7d679be9373 Mon Sep 17 00:00:00 2001 From: Eyck Jentzsch Date: Mon, 27 Aug 2018 16:27:11 +0200 Subject: [PATCH] Added UI support for real value signals --- .../org.eclipse.jdt.groovy.core.prefs | 2 +- .../database/swt/internal/SignalPainter.java | 92 ++++++++++++++++++- .../database/swt/internal/WaveformCanvas.java | 2 + .../database/swt/internal/WaveformViewer.java | 3 + .../scviewer/database/ui/WaveformColors.java | 2 +- .../preferences/DefaultValuesInitializer.java | 2 + .../SCViewer (restart).launch | 34 ------- com.minres.scviewer.target/neon.target | 7 +- .../org.eclipse.jdt.groovy.core.prefs | 3 +- 9 files changed, 102 insertions(+), 45 deletions(-) delete mode 100644 com.minres.scviewer.e4.product/SCViewer (restart).launch diff --git a/com.minres.scviewer.database.text/.settings/org.eclipse.jdt.groovy.core.prefs b/com.minres.scviewer.database.text/.settings/org.eclipse.jdt.groovy.core.prefs index a7f72ec..ae98fea 100644 --- a/com.minres.scviewer.database.text/.settings/org.eclipse.jdt.groovy.core.prefs +++ b/com.minres.scviewer.database.text/.settings/org.eclipse.jdt.groovy.core.prefs @@ -1,2 +1,2 @@ eclipse.preferences.version=1 -groovy.compiler.level=23 +groovy.compiler.level=24 diff --git a/com.minres.scviewer.database.ui.swt/src/com/minres/scviewer/database/swt/internal/SignalPainter.java b/com.minres.scviewer.database.ui.swt/src/com/minres/scviewer/database/swt/internal/SignalPainter.java index d41ff93..955618b 100644 --- a/com.minres.scviewer.database.ui.swt/src/com/minres/scviewer/database/swt/internal/SignalPainter.java +++ b/com.minres.scviewer.database.ui.swt/src/com/minres/scviewer/database/swt/internal/SignalPainter.java @@ -25,6 +25,7 @@ import org.eclipse.swt.graphics.Rectangle; import com.minres.scviewer.database.ISignal; import com.minres.scviewer.database.ISignalChange; import com.minres.scviewer.database.ISignalChangeMulti; +import com.minres.scviewer.database.ISignalChangeReal; import com.minres.scviewer.database.ISignalChangeSingle; import com.minres.scviewer.database.ui.TrackEntry; import com.minres.scviewer.database.ui.WaveformColors; @@ -107,8 +108,13 @@ public class SignalPainter extends TrackPainter { NavigableMap entries = signal.getEvents().subMap(first.getKey(), false, last.getKey(), true); SignalChange left = new SignalChange(first); SignalChange right = new SignalChange(entries.size() > 0 ? entries.firstEntry() : first); - SignalStencil stencil = left.value instanceof ISignalChangeSingle ? new SingleBitStencil() : new MultiBitStencil(gc); - + SignalStencil stencil = null; + if(left.value instanceof ISignalChangeSingle) + stencil= new SingleBitStencil(); + else if(left.value instanceof ISignalChangeMulti) + stencil= new MultiBitStencil(gc); + else + stencil= new RealStencil(left.value, entries); maxX = area.x + area.width; yOffsetT = this.waveCanvas.getTrackHeight() / 5 + area.y; yOffsetM = this.waveCanvas.getTrackHeight() / 2 + area.y; @@ -122,7 +128,6 @@ public class SignalPainter extends TrackPainter { // b) left to close to right if (left.time == right.time) { right.time = endTime; - } else { multiple = true; long eTime = (xBegin + 1) * this.waveCanvas.getScaleFactor(); @@ -144,7 +149,9 @@ public class SignalPainter extends TrackPainter { if (xEnd == xBegin) { multiple = true; long eTime = (xBegin + 1) * this.waveCanvas.getScaleFactor(); - right.set(entries.floorEntry(eTime), endTime); + Entry entry = entries.floorEntry(eTime); + if(entry!=null && entry.getKey()> right.time) + right.set(entry, endTime); xEnd = getXEnd(eTime); } } while (left.time < endTime); @@ -254,7 +261,84 @@ public class SignalPainter extends TrackPainter { } } } + } + private class RealStencil implements SignalStencil { + double min; + double max; + double diff; + + public RealStencil(ISignalChange value, NavigableMap entries) { + min=((ISignalChangeReal) value).getValue(); + max=min; + for (ISignalChange e : entries.values()) { + double v = ((ISignalChangeReal)e).getValue(); + max= Double.isNaN(max)? v : Math.max(max, v); + min= Double.isNaN(min)? v : Math.min(min, v); + } + int nans = (Double.isNaN(max)?2:0) + (Double.isNaN(max)?1:0); + switch(nans) { + case 0: + break; + case 1: + max=min; + break; + case 2: + min=max; + case 3: + max=min=0; + } + diff=max-min; + if(diff==0.0) { + if(max>0) + min=0.0; + else if(min<0.0) + max=0.0; + else { + max=1.0; + min=0.0; + } + diff=max-min; + } + } + + public void draw(GC gc, Rectangle area, ISignalChange left, ISignalChange right, int xBegin, int xEnd, boolean multiple) { + double value = ((ISignalChangeReal)left).getValue(); + if(Double.isNaN(value)) { + Color color = waveCanvas.colors[WaveformColors.SIGNAL_NAN.ordinal()]; + int width = xEnd - xBegin; + if (width > 1) { + int[] points = { + xBegin, yOffsetT, + xEnd, yOffsetT, + xEnd, yOffsetB, + xBegin, yOffsetB + }; + gc.setForeground(color); + gc.drawPolygon(points); + gc.setBackground(color); + gc.fillPolygon(points); + } else { + gc.setForeground(color); + gc.drawLine(xEnd, yOffsetT, xEnd, yOffsetB); + } + } else { + Color color = waveCanvas.colors[WaveformColors.SIGNAL_ANALOG.ordinal()]; + int height=yOffsetT-yOffsetB; + double offset=value-min; + int yOffset=diff>0?(int)(height*(offset/diff)) + yOffsetB:yOffsetM; + gc.setForeground(color); + if (xEnd > maxX) { + gc.drawLine(xBegin, yOffset, maxX, yOffset); + } else { + gc.drawLine(xBegin, yOffset, xEnd, yOffset); + double nextOffset = ((ISignalChangeReal)right).getValue()-min; + int yNext = diff>0?(int)(height*(nextOffset/diff)) + yOffsetB:height/2; + if (yOffset != yNext) + gc.drawLine(xEnd, yOffset, xEnd, yNext); + } + } + } } public ISignal getSignal() { diff --git a/com.minres.scviewer.database.ui.swt/src/com/minres/scviewer/database/swt/internal/WaveformCanvas.java b/com.minres.scviewer.database.ui.swt/src/com/minres/scviewer/database/swt/internal/WaveformCanvas.java index 333cb4f..76ed874 100644 --- a/com.minres.scviewer.database.ui.swt/src/com/minres/scviewer/database/swt/internal/WaveformCanvas.java +++ b/com.minres.scviewer.database.ui.swt/src/com/minres/scviewer/database/swt/internal/WaveformCanvas.java @@ -156,6 +156,8 @@ public class WaveformCanvas extends Canvas { colors[WaveformColors.SIGNALZ.ordinal()] = SWTResourceManager.getColor(SWT.COLOR_DARK_YELLOW); colors[WaveformColors.SIGNALX.ordinal()] = SWTResourceManager.getColor(255, 51, 51); colors[WaveformColors.SIGNALU.ordinal()] = SWTResourceManager.getColor(SWT.COLOR_YELLOW); + colors[WaveformColors.SIGNAL_ANALOG.ordinal()] = SWTResourceManager.getColor(SWT.COLOR_GREEN); + colors[WaveformColors.SIGNAL_NAN.ordinal()] = SWTResourceManager.getColor(SWT.COLOR_RED); colors[WaveformColors.SIGNAL_TEXT.ordinal()] = SWTResourceManager.getColor(SWT.COLOR_WHITE); colors[WaveformColors.CURSOR.ordinal()] = SWTResourceManager.getColor(SWT.COLOR_RED); colors[WaveformColors.CURSOR_DRAG.ordinal()] = SWTResourceManager.getColor(SWT.COLOR_GRAY); diff --git a/com.minres.scviewer.database.ui.swt/src/com/minres/scviewer/database/swt/internal/WaveformViewer.java b/com.minres.scviewer.database.ui.swt/src/com/minres/scviewer/database/swt/internal/WaveformViewer.java index 59d2b78..7f38f38 100644 --- a/com.minres.scviewer.database.ui.swt/src/com/minres/scviewer/database/swt/internal/WaveformViewer.java +++ b/com.minres.scviewer.database.ui.swt/src/com/minres/scviewer/database/swt/internal/WaveformViewer.java @@ -72,6 +72,7 @@ import com.google.common.collect.Lists; import com.minres.scviewer.database.ISignal; import com.minres.scviewer.database.ISignalChange; import com.minres.scviewer.database.ISignalChangeMulti; +import com.minres.scviewer.database.ISignalChangeReal; import com.minres.scviewer.database.ISignalChangeSingle; import com.minres.scviewer.database.ITx; import com.minres.scviewer.database.ITxEvent; @@ -458,6 +459,8 @@ public class WaveformViewer implements IWaveformViewer { entry.setValue("b'"+((ISignalChangeSingle)event).getValue()); } else if(event instanceof ISignalChangeMulti){ entry.setValue("h'"+((ISignalChangeMulti)event).getValue().toHexString()); + } else if(event instanceof ISignalChangeReal){ + entry.setValue(Double.toString(((ISignalChangeReal)event).getValue())); } } else if(entry.getKey() instanceof ITxStream){ ITxStream stream = (ITxStream) entry.getKey(); diff --git a/com.minres.scviewer.database.ui/src/com/minres/scviewer/database/ui/WaveformColors.java b/com.minres.scviewer.database.ui/src/com/minres/scviewer/database/ui/WaveformColors.java index 382f526..9ec2786 100644 --- a/com.minres.scviewer.database.ui/src/com/minres/scviewer/database/ui/WaveformColors.java +++ b/com.minres.scviewer.database.ui/src/com/minres/scviewer/database/ui/WaveformColors.java @@ -14,7 +14,7 @@ public enum WaveformColors { LINE, LINE_HIGHLITE, TRACK_BG_EVEN, TRACK_BG_ODD, TRACK_BG_HIGHLITE, TX_BG, TX_BG_HIGHLITE, TX_BORDER, - SIGNAL0, SIGNAL1, SIGNALZ, SIGNALX, SIGNALU, SIGNAL_TEXT, + SIGNAL0, SIGNAL1, SIGNALZ, SIGNALX, SIGNALU, SIGNAL_TEXT, SIGNAL_ANALOG, SIGNAL_NAN, CURSOR, CURSOR_DRAG, CURSOR_TEXT, MARKER, MARKER_TEXT, REL_ARROW, REL_ARROW_HIGHLITE } \ No newline at end of file diff --git a/com.minres.scviewer.e4.application/src/com/minres/scviewer/e4/application/preferences/DefaultValuesInitializer.java b/com.minres.scviewer.e4.application/src/com/minres/scviewer/e4/application/preferences/DefaultValuesInitializer.java index 4cdcf2b..5497a15 100644 --- a/com.minres.scviewer.e4.application/src/com/minres/scviewer/e4/application/preferences/DefaultValuesInitializer.java +++ b/com.minres.scviewer.e4.application/src/com/minres/scviewer/e4/application/preferences/DefaultValuesInitializer.java @@ -46,6 +46,8 @@ public class DefaultValuesInitializer extends AbstractPreferenceInitializer { colors[WaveformColors.SIGNALZ.ordinal()] = SWTResourceManager.getColor(SWT.COLOR_YELLOW); colors[WaveformColors.SIGNALX.ordinal()] = SWTResourceManager.getColor(255, 51, 51); colors[WaveformColors.SIGNALU.ordinal()] = SWTResourceManager.getColor(SWT.COLOR_DARK_YELLOW); + colors[WaveformColors.SIGNAL_ANALOG.ordinal()] = SWTResourceManager.getColor(SWT.COLOR_GREEN); + colors[WaveformColors.SIGNAL_NAN.ordinal()] = SWTResourceManager.getColor(SWT.COLOR_RED); colors[WaveformColors.SIGNAL_TEXT.ordinal()] = SWTResourceManager.getColor(SWT.COLOR_WHITE); colors[WaveformColors.CURSOR.ordinal()] = SWTResourceManager.getColor(SWT.COLOR_RED); colors[WaveformColors.CURSOR_DRAG.ordinal()] = SWTResourceManager.getColor(SWT.COLOR_GRAY); diff --git a/com.minres.scviewer.e4.product/SCViewer (restart).launch b/com.minres.scviewer.e4.product/SCViewer (restart).launch deleted file mode 100644 index 623bed5..0000000 --- a/com.minres.scviewer.e4.product/SCViewer (restart).launch +++ /dev/null @@ -1,34 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/com.minres.scviewer.target/neon.target b/com.minres.scviewer.target/neon.target index 0f5dda0..16f94a8 100644 --- a/com.minres.scviewer.target/neon.target +++ b/com.minres.scviewer.target/neon.target @@ -9,7 +9,7 @@ - + @@ -17,8 +17,7 @@ x86_64 de_DE - --Dosgi.requiredJavaVersion=1.6 -XstartOnFirstThread -Dorg.eclipse.swt.internal.carbon.smallFonts -XX:MaxPermSize=256m -Xdock:icon=../Resources/Eclipse.icns -XstartOnFirstThread -Dorg.eclipse.swt.internal.carbon.smallFonts -Xms40m -Xmx512m -Xdock:icon=../Resources/Eclipse.icns -XstartOnFirstThread -Dorg.eclipse.swt.internal.carbon.smallFonts +-Dosgi.requiredJavaVersion=1.7 -XX:MaxPermSize=256 -Xms40m -Xmx2G - + \ No newline at end of file diff --git a/com.minres.scviewer.ui/.settings/org.eclipse.jdt.groovy.core.prefs b/com.minres.scviewer.ui/.settings/org.eclipse.jdt.groovy.core.prefs index a7f72ec..54bc0c1 100644 --- a/com.minres.scviewer.ui/.settings/org.eclipse.jdt.groovy.core.prefs +++ b/com.minres.scviewer.ui/.settings/org.eclipse.jdt.groovy.core.prefs @@ -1,2 +1,3 @@ eclipse.preferences.version=1 -groovy.compiler.level=23 +groovy.compiler.level=24 +groovy.script.filters=**/*.dsld,y,**/*.gradle,n