Changed track entry from Waveform to TrackEntry allowing multiple use of

the same waveform
This commit is contained in:
Eyck Jentzsch 2015-11-06 19:29:36 +01:00
parent 7d3c37e989
commit c1d84ceb01
22 changed files with 526 additions and 291 deletions

View File

@ -15,6 +15,4 @@
<version>3.8.7</version> <version>3.8.7</version>
</dependency> </dependency>
</dependencies> </dependencies>
<groupId>com.minres.scviewer</groupId> </project>
<version>1.0.0-SNAPSHOT</version>
</project>

View File

@ -12,5 +12,4 @@ Require-Bundle: org.eclipse.swt;bundle-version="3.103.1",
org.eclipse.equinox.registry, org.eclipse.equinox.registry,
com.minres.scviewer.database.ui com.minres.scviewer.database.ui
Export-Package: com.minres.scviewer.database.swt Export-Package: com.minres.scviewer.database.swt
Bundle-ClassPath: ., Bundle-ClassPath: .
swing2swt.jar

View File

@ -0,0 +1,26 @@
/*******************************************************************************
* Copyright (c) 2015 MINRES Technologies GmbH and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* MINRES Technologies GmbH - initial API and implementation
*******************************************************************************/
package com.minres.scviewer.database.swt;
import org.eclipse.swt.widgets.Composite;
import com.minres.scviewer.database.swt.internal.WaveformViewer;
import com.minres.scviewer.database.ui.IWaveformViewer;
import com.minres.scviewer.database.ui.IWaveformViewerFactory;
public class WaveformViewerFactory implements IWaveformViewerFactory {
@Override
public IWaveformViewer createPanel(Composite parent) {
return new WaveformViewer(parent);
}
}

View File

@ -0,0 +1,48 @@
/*******************************************************************************
* Copyright (c) 2015 MINRES Technologies GmbH and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* MINRES Technologies GmbH - initial API and implementation
*******************************************************************************/
package com.minres.scviewer.database.swt.internal;
import java.util.Collection;
import org.eclipse.swt.graphics.GC;
import org.eclipse.swt.graphics.Rectangle;
import com.minres.scviewer.database.ITx;
import com.minres.scviewer.database.ITxRelation;
public class ArrowPainter implements IPainter {
private WaveformCanvas waveCanvas;
private ITx tx;
private Collection<ITxRelation> incoming;
private Collection<ITxRelation> outgoing;
public ArrowPainter(WaveformCanvas waveCanvas, ITx tx) {
this.waveCanvas = waveCanvas;
this.tx=tx;
this.incoming = tx.getIncomingRelations();
this.outgoing = tx.getOutgoingRelations();
}
@Override
public void paintArea(GC gc, Rectangle area) {
Rectangle txRectangle = getBounds(tx);
}
private Rectangle getBounds(ITx tx) {
return null;
}
}

View File

@ -54,7 +54,7 @@ public class CursorPainter implements IPainter {
} }
public void paintArea(GC gc, Rectangle area) { public void paintArea(GC gc, Rectangle area) {
if(this.waveCanvas.streams.size()>0){ if(this.waveCanvas.painterList.size()>0){
long scaleFactor=waveCanvas.getScaleFactor(); long scaleFactor=waveCanvas.getScaleFactor();
int x = (int) (time/scaleFactor); int x = (int) (time/scaleFactor);
int top = id<0?area.y:area.y+15; int top = id<0?area.y:area.y+15;

View File

@ -10,9 +10,14 @@
*******************************************************************************/ *******************************************************************************/
package com.minres.scviewer.database.swt.internal; package com.minres.scviewer.database.swt.internal;
import com.minres.scviewer.database.ui.TrackEntry;
public interface IWaveformPainter extends IPainter { public interface IWaveformPainter extends IPainter {
public int getMinHeight(); public int getHeight();
public int getVerticalOffset();
public TrackEntry getTrackEntry();
} }

View File

@ -20,29 +20,28 @@ import org.eclipse.swt.graphics.Rectangle;
import com.minres.scviewer.database.ISignal; import com.minres.scviewer.database.ISignal;
import com.minres.scviewer.database.ISignalChange; import com.minres.scviewer.database.ISignalChange;
import com.minres.scviewer.database.IWaveformEvent; import com.minres.scviewer.database.ui.TrackEntry;
import com.minres.scviewer.database.ISignalChangeMulti; import com.minres.scviewer.database.ISignalChangeMulti;
import com.minres.scviewer.database.ISignalChangeSingle; import com.minres.scviewer.database.ISignalChangeSingle;
import com.minres.scviewer.database.IWaveform;
public class SignalPainter implements IWaveformPainter { public class SignalPainter extends TrackPainter {
/** /**
* *
*/ */
private final WaveformCanvas waveCanvas; private final WaveformCanvas waveCanvas;
private ISignal<? extends ISignalChange> signal; private ISignal<? extends ISignalChange> signal;
private int height;
private boolean even;
public SignalPainter(WaveformCanvas txDisplay, boolean even, int height, ISignal<? extends IWaveformEvent> signal) { @SuppressWarnings("unchecked")
public SignalPainter(WaveformCanvas txDisplay, boolean even, TrackEntry trackEntry) {
super(trackEntry, even);
this.waveCanvas = txDisplay; this.waveCanvas = txDisplay;
this.signal=signal; this.signal=trackEntry.getSignal();
this.height=height;
this.even=even;
} }
public void paintArea(GC gc, Rectangle area) { public void paintArea(GC gc, Rectangle area) {
if(waveCanvas.currentWaveformSelection!=null && waveCanvas.currentWaveformSelection.equals(signal)) if(trackEntry.selected)
gc.setBackground(this.waveCanvas.colors[WaveformCanvas.Colors.TRACK_BG_HIGHLITE.ordinal()]); gc.setBackground(this.waveCanvas.colors[WaveformCanvas.Colors.TRACK_BG_HIGHLITE.ordinal()]);
else else
gc.setBackground(this.waveCanvas.colors[even?WaveformCanvas.Colors.TRACK_BG_EVEN.ordinal():WaveformCanvas.Colors.TRACK_BG_ODD.ordinal()]); gc.setBackground(this.waveCanvas.colors[even?WaveformCanvas.Colors.TRACK_BG_EVEN.ordinal():WaveformCanvas.Colors.TRACK_BG_ODD.ordinal()]);
@ -139,10 +138,6 @@ public class SignalPainter implements IWaveformPainter {
} }
} }
@Override
public int getMinHeight() {
return height;
}
public ISignal<? extends ISignalChange> getSignal() { public ISignal<? extends ISignalChange> getSignal() {
return signal; return signal;

View File

@ -24,34 +24,36 @@ import org.eclipse.swt.graphics.Rectangle;
import com.minres.scviewer.database.ITx; import com.minres.scviewer.database.ITx;
import com.minres.scviewer.database.ITxEvent; import com.minres.scviewer.database.ITxEvent;
import com.minres.scviewer.database.ITxStream; import com.minres.scviewer.database.ITxStream;
import com.minres.scviewer.database.IWaveform;
import com.minres.scviewer.database.ui.TrackEntry;
public class StreamPainter implements IWaveformPainter{ public class StreamPainter extends TrackPainter{
/** /**
* *
*/ */
private final WaveformCanvas waveCanvas; private final WaveformCanvas waveCanvas;
private ITxStream<? extends ITxEvent> stream; private ITxStream<? extends ITxEvent> stream;
private int height, upper, txHeight; private int txBase, txHeight;
private int totalHeight; private int totalHeight;
private boolean even; private boolean even;
private TreeSet<ITx> seenTx; private TreeSet<ITx> seenTx;
public StreamPainter(WaveformCanvas txDisplay, boolean even, int height, ITxStream<? extends ITxEvent> stream) { @SuppressWarnings("unchecked")
this.waveCanvas = txDisplay; public StreamPainter(WaveformCanvas waveCanvas, boolean even, TrackEntry trackEntry) {
this.stream=stream; super(trackEntry, even);
this.height=height; this.waveCanvas = waveCanvas;
this.upper=this.waveCanvas.getTrackHeight()/5; this.stream=trackEntry.getStream();
this.txHeight=3*this.waveCanvas.getTrackHeight()/5;
this.totalHeight=stream.getMaxConcurrency()*this.waveCanvas.getTrackHeight();
this.even=even;
this.seenTx=new TreeSet<ITx>(); this.seenTx=new TreeSet<ITx>();
} }
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
public void paintArea(GC gc, Rectangle area) { public void paintArea(GC gc, Rectangle area) {
if(stream.getEvents().size()==0) return; if(stream.getEvents().size()==0) return;
if(waveCanvas.currentWaveformSelection!=null && waveCanvas.currentWaveformSelection.equals(stream)) int trackHeight=trackEntry.height/stream.getMaxConcurrency();
txBase=trackHeight/5;
txHeight=trackHeight*3/5;
if(trackEntry.selected)
gc.setBackground(this.waveCanvas.colors[WaveformCanvas.Colors.TRACK_BG_HIGHLITE.ordinal()]); gc.setBackground(this.waveCanvas.colors[WaveformCanvas.Colors.TRACK_BG_HIGHLITE.ordinal()]);
else else
gc.setBackground(this.waveCanvas.colors[even?WaveformCanvas.Colors.TRACK_BG_EVEN.ordinal():WaveformCanvas.Colors.TRACK_BG_ODD.ordinal()]); gc.setBackground(this.waveCanvas.colors[even?WaveformCanvas.Colors.TRACK_BG_EVEN.ordinal():WaveformCanvas.Colors.TRACK_BG_ODD.ordinal()]);
@ -65,7 +67,7 @@ public class StreamPainter implements IWaveformPainter{
gc.setLineStyle(SWT.LINE_SOLID); gc.setLineStyle(SWT.LINE_SOLID);
gc.setLineWidth(1); gc.setLineWidth(1);
gc.setForeground(this.waveCanvas.colors[WaveformCanvas.Colors.LINE.ordinal()]); gc.setForeground(this.waveCanvas.colors[WaveformCanvas.Colors.LINE.ordinal()]);
for(int y1=area.y+this.waveCanvas.getTrackHeight()/2; y1<area.y+totalHeight; y1+=this.waveCanvas.getTrackHeight()) for(int y1=area.y+trackHeight/2; y1<area.y+trackEntry.height; y1+=trackHeight)
gc.drawLine(area.x, y1, area.x+area.width, y1); gc.drawLine(area.x, y1, area.x+area.width, y1);
if(firstTx==lastTx) if(firstTx==lastTx)
for(ITxEvent txEvent:(Collection<? extends ITxEvent>)firstTx.getValue()) for(ITxEvent txEvent:(Collection<? extends ITxEvent>)firstTx.getValue())
@ -101,7 +103,7 @@ public class StreamPainter implements IWaveformPainter{
protected void drawTx(GC gc, Rectangle area, ITx tx) { protected void drawTx(GC gc, Rectangle area, ITx tx) {
int offset = tx.getConcurrencyIndex()*this.waveCanvas.getTrackHeight(); int offset = tx.getConcurrencyIndex()*this.waveCanvas.getTrackHeight();
Rectangle bb = new Rectangle( Rectangle bb = new Rectangle(
(int)(tx.getBeginTime()/this.waveCanvas.getScaleFactor()), area.y+offset+upper, (int)(tx.getBeginTime()/this.waveCanvas.getScaleFactor()), area.y+offset+txBase,
(int)((tx.getEndTime()-tx.getBeginTime())/this.waveCanvas.getScaleFactor()), txHeight); (int)((tx.getEndTime()-tx.getBeginTime())/this.waveCanvas.getScaleFactor()), txHeight);
if(bb.x+bb.width<area.x || bb.x>area.x+area.width) return; if(bb.x+bb.width<area.x || bb.x>area.x+area.width) return;
if(bb.width==0){ if(bb.width==0){
@ -115,12 +117,7 @@ public class StreamPainter implements IWaveformPainter{
} }
} }
@Override public ITx getClicked(Point point) {
public int getMinHeight() {
return height;
}
public Object getClicked(Point point) {
int lane=point.y/waveCanvas.getTrackHeight(); int lane=point.y/waveCanvas.getTrackHeight();
Entry<Long, List<ITxEvent>> firstTx=stream.getEvents().floorEntry(point.x*waveCanvas.getScaleFactor()); Entry<Long, List<ITxEvent>> firstTx=stream.getEvents().floorEntry(point.x*waveCanvas.getScaleFactor());
if(firstTx!=null){ if(firstTx!=null){
@ -130,7 +127,7 @@ public class StreamPainter implements IWaveformPainter{
firstTx=stream.getEvents().lowerEntry(firstTx.getKey()); firstTx=stream.getEvents().lowerEntry(firstTx.getKey());
}while(firstTx!=null); }while(firstTx!=null);
} }
return stream; return null;
} }
public ITxStream<? extends ITxEvent> getStream() { public ITxStream<? extends ITxEvent> getStream() {

View File

@ -0,0 +1,74 @@
/*******************************************************************************
* Copyright (c) 2015 MINRES Technologies GmbH and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* MINRES Technologies GmbH - initial API and implementation
*******************************************************************************/
package com.minres.scviewer.database.swt.internal;
import java.util.Map.Entry;
import java.util.TreeMap;
import org.eclipse.swt.SWT;
import org.eclipse.swt.graphics.GC;
import org.eclipse.swt.graphics.Rectangle;
public class TrackAreaPainter implements IPainter {
/**
*
*/
private final WaveformCanvas waveCanvas;
TreeMap<Integer, IWaveformPainter> trackVerticalOffset;
/**
* @param txDisplay
*/
public TrackAreaPainter(WaveformCanvas waveCanvas) {
this.waveCanvas = waveCanvas;
this.trackVerticalOffset= new TreeMap<>();
}
public void paintArea(GC gc, Rectangle a) {
Rectangle area = new Rectangle(a.x, a.y+waveCanvas.rulerHeight, a.width, a.height-waveCanvas.rulerHeight);
gc.setBackground(this.waveCanvas.colors[WaveformCanvas.Colors.TRACK_BG_EVEN.ordinal()]);
gc.setFillRule(SWT.FILL_EVEN_ODD);
gc.fillRectangle(area);
if(trackVerticalOffset.size()>0){
Integer firstKey=trackVerticalOffset.floorKey(area.y);
if(firstKey==null) firstKey=trackVerticalOffset.firstKey();
Integer lastKey = trackVerticalOffset.floorKey(area.y+area.height);
Rectangle subArea = new Rectangle(area.x, 0, area.width, 0);
if(lastKey==firstKey){
subArea.y=firstKey;
IWaveformPainter p = trackVerticalOffset.get(firstKey);
subArea.height=p.getHeight();
p.paintArea(gc, subArea);
}else{
for(Entry<Integer, IWaveformPainter> entry : trackVerticalOffset.subMap(firstKey, true, lastKey, true).entrySet()){
subArea.y=entry.getKey();
subArea.height=entry.getValue().getHeight();
entry.getValue().paintArea(gc, subArea);
}
}
}
}
public TreeMap<Integer, IWaveformPainter> getTrackVerticalOffset() {
return trackVerticalOffset;
}
public void addTrackPainter(IWaveformPainter trackPainter){
trackVerticalOffset.put(trackPainter.getVerticalOffset()+waveCanvas.rulerHeight, trackPainter);
}
public int getHeight(){
if(trackVerticalOffset.size()==0) return 1;
return trackVerticalOffset.lastKey() + trackVerticalOffset.lastEntry().getValue().getHeight();
}
}

View File

@ -10,50 +10,33 @@
*******************************************************************************/ *******************************************************************************/
package com.minres.scviewer.database.swt.internal; package com.minres.scviewer.database.swt.internal;
import java.util.Map.Entry; import com.minres.scviewer.database.ui.TrackEntry;
import java.util.TreeMap;
import org.eclipse.swt.SWT; public abstract class TrackPainter implements IWaveformPainter {
import org.eclipse.swt.graphics.GC;
import org.eclipse.swt.graphics.Rectangle;
public class TrackPainter implements IPainter { protected boolean even;
/** protected TrackEntry trackEntry;
*
*/
private final WaveformCanvas waveCanvas;
/** public TrackPainter(TrackEntry trackEntry, boolean even) {
* @param txDisplay this.trackEntry = trackEntry;
*/ this.even=even;
public TrackPainter(WaveformCanvas waveCanvas) {
this.waveCanvas = waveCanvas;
} }
public void paintArea(GC gc, Rectangle a) { public int getHeight() {
Rectangle area = new Rectangle(a.x, a.y+waveCanvas.rulerHeight, a.width, a.height-waveCanvas.rulerHeight); return trackEntry.height;
gc.setBackground(this.waveCanvas.colors[WaveformCanvas.Colors.TRACK_BG_EVEN.ordinal()]);
gc.setFillRule(SWT.FILL_EVEN_ODD);
gc.fillRectangle(area);
TreeMap<Integer, IWaveformPainter> offsets = this.waveCanvas.trackVerticalOffset;
if(this.waveCanvas.streams.size()>0){
Integer firstKey=offsets.floorKey(area.y);
if(firstKey==null) firstKey=offsets.firstKey();
Integer lastKey = offsets.floorKey(area.y+area.height);
Rectangle subArea = new Rectangle(area.x, 0, area.width, 0);
if(lastKey==firstKey){
subArea.y=firstKey;
IWaveformPainter p = offsets.get(firstKey);
subArea.height=p.getMinHeight();
p.paintArea(gc, subArea);
}else{
for(Entry<Integer, IWaveformPainter> entry : offsets.subMap(firstKey, true, lastKey, true).entrySet()){
subArea.y=entry.getKey();
subArea.height=entry.getValue().getMinHeight();
entry.getValue().paintArea(gc, subArea);
} }
public int getVerticalOffset() {
return trackEntry.vOffset;
} }
public boolean isEven() {
return even;
} }
public TrackEntry getTrackEntry() {
return trackEntry;
} }
} }

View File

@ -10,11 +10,11 @@
*******************************************************************************/ *******************************************************************************/
package com.minres.scviewer.database.swt.internal; package com.minres.scviewer.database.swt.internal;
import java.util.ArrayList;
import java.util.HashMap; import java.util.HashMap;
import java.util.LinkedList; import java.util.LinkedList;
import java.util.List; import java.util.List;
import java.util.Map.Entry; import java.util.Map.Entry;
import java.util.TreeMap;
import org.eclipse.swt.SWT; import org.eclipse.swt.SWT;
import org.eclipse.swt.events.ControlAdapter; import org.eclipse.swt.events.ControlAdapter;
@ -54,25 +54,38 @@ public class WaveformCanvas extends Canvas {
Color[] colors = new Color[Colors.values().length]; Color[] colors = new Color[Colors.values().length];
private int trackHeight = 50; private int trackHeight = 50;
private long scaleFactor = 1000000L; // 1ns
String unit="ns";
private int level = 12;
public final static String[] unitString={"fs", "ps", "ns", "µs", "ms"};//, "s"};
public final static int[] unitMultiplier={1, 3, 10, 30, 100, 300};
private long maxTime;
protected Point origin; /* original size */
protected Transform transform;
protected int rulerHeight=40;
protected List<IPainter> painterList;
TreeMap<Integer, IWaveformPainter> trackVerticalOffset;
protected List<IWaveform<? extends IWaveformEvent>> streams; private long scaleFactor = 1000000L; // 1ns
String unit="ns";
private int level = 12;
public final static String[] unitString={"fs", "ps", "ns", "µs", "ms"};//, "s"};
public final static int[] unitMultiplier={1, 3, 10, 30, 100, 300};
private long maxTime;
protected Point origin; /* original size */
protected Transform transform;
protected int rulerHeight=40;
protected List<IPainter> painterList;
ITx currentSelection; ITx currentSelection;
IWaveform<? extends IWaveformEvent> currentWaveformSelection;
private List<SelectionAdapter> selectionListeners; private List<SelectionAdapter> selectionListeners;
private RulerPainter rulerPainter;
private TrackAreaPainter trackAreaPainter;
private List<CursorPainter> cursorPainters;
private HashMap<IWaveform<?>, IWaveformPainter> wave2painterMap;
/** /**
* Constructor for ScrollableCanvas. * Constructor for ScrollableCanvas.
* *
@ -96,10 +109,29 @@ public class WaveformCanvas extends Canvas {
painterList = new LinkedList<IPainter>(); painterList = new LinkedList<IPainter>();
origin = new Point(0, 0); origin = new Point(0, 0);
transform = new Transform(getDisplay()); transform = new Transform(getDisplay());
trackVerticalOffset = new TreeMap<Integer, IWaveformPainter>();
selectionListeners = new LinkedList<>(); selectionListeners = new LinkedList<>();
cursorPainters= new ArrayList<>();
wave2painterMap=new HashMap<>();
initScrollBars(); initScrollBars();
initColors(null); initColors(null);
// order is important: it is bottom to top
trackAreaPainter=new TrackAreaPainter(this);
painterList.add(trackAreaPainter);
rulerPainter=new RulerPainter(this, getDisplay().getSystemColor(SWT.COLOR_BLACK), getDisplay().getSystemColor(SWT.COLOR_WHITE));
painterList.add(rulerPainter);
CursorPainter cp = new CursorPainter(this, scaleFactor * 10, cursorPainters.size()-1);
painterList.add(cp);
cursorPainters.add(cp);
CursorPainter marker = new CursorPainter(this, scaleFactor * 100, cursorPainters.size()-1);
painterList.add(marker);
cursorPainters.add(marker);
wave2painterMap=new HashMap<>();
}
public void addCursoPainter(CursorPainter cursorPainter){
painterList.add(cursorPainter);
cursorPainters.add(cursorPainter);
} }
private void initColors(HashMap<Colors, RGB> colourMap) { private void initColors(HashMap<Colors, RGB> colourMap) {
@ -133,14 +165,6 @@ public class WaveformCanvas extends Canvas {
} }
} }
public List<IWaveform<? extends IWaveformEvent>> getStreams() {
return streams;
}
public void setStreams(List<IWaveform<? extends IWaveformEvent>> streams) {
this.streams = streams;
}
public Point getOrigin() { public Point getOrigin() {
return origin; return origin;
} }
@ -229,16 +253,22 @@ public class WaveformCanvas extends Canvas {
redraw(); redraw();
} }
public void clearAllWavefromPainter() { public void clearAllWaveformPainter() {
trackVerticalOffset.clear(); trackAreaPainter.getTrackVerticalOffset().clear();
wave2painterMap.clear();
syncScrollBars(); syncScrollBars();
} }
public void addWavefromPainter(int yoffs, IWaveformPainter painter) { public void addWaveformPainter(IWaveformPainter painter) {
trackVerticalOffset.put(yoffs+rulerHeight, painter); trackAreaPainter.addTrackPainter(painter);
wave2painterMap.put(painter.getTrackEntry().waveform, painter);
syncScrollBars(); syncScrollBars();
} }
public List<CursorPainter> getCursorPainters() {
return cursorPainters;
}
/** /**
* Dispose the garbage here * Dispose the garbage here
*/ */
@ -278,15 +308,12 @@ public class WaveformCanvas extends Canvas {
* range, it will correct it. This function considers only following factors * range, it will correct it. This function considers only following factors
* :<b> transform, image size, client area</b>. * :<b> transform, image size, client area</b>.
*/ */
private void syncScrollBars() { public void syncScrollBars() {
if (painterList.size() == 0) { if (painterList.size() == 0) {
redraw(); redraw();
return; return;
} }
int height = 1; int height = trackAreaPainter.getHeight();
if (trackVerticalOffset.size() > 0)
height = trackVerticalOffset.lastKey() + trackVerticalOffset.lastEntry().getValue().getMinHeight();
int width = (int) (maxTime / scaleFactor); int width = (int) (maxTime / scaleFactor);
ScrollBar horizontal = getHorizontalBar(); ScrollBar horizontal = getHorizontalBar();
horizontal.setIncrement((int) (getClientArea().width / 100)); horizontal.setIncrement((int) (getClientArea().width / 100));
@ -334,7 +361,7 @@ public class WaveformCanvas extends Canvas {
transform.translate(origin.x, origin.y); transform.translate(origin.x, origin.y);
gc.setTransform(transform); gc.setTransform(transform);
gc.setClipping(clientRect); gc.setClipping(clientRect);
if (painterList.size() > 0 && trackVerticalOffset.size() > 0) { if (painterList.size() > 0 ) {
for (IPainter painter : painterList) for (IPainter painter : painterList)
painter.paintArea(gc, clientRect); painter.paintArea(gc, clientRect);
} else { } else {
@ -346,15 +373,17 @@ public class WaveformCanvas extends Canvas {
public List<Object> getClicked(Point point) { public List<Object> getClicked(Point point) {
LinkedList<Object> result=new LinkedList<>(); LinkedList<Object> result=new LinkedList<>();
for (IPainter p : Lists.reverse(painterList)) { for (IPainter p : Lists.reverse(painterList)) {
if (p instanceof TrackPainter) { if (p instanceof TrackAreaPainter) {
int y = point.y - origin.y; int y = point.y - origin.y;
int x = point.x - origin.x; int x = point.x - origin.x;
Entry<Integer, IWaveformPainter> entry = trackVerticalOffset.floorEntry(y); Entry<Integer, IWaveformPainter> entry = trackAreaPainter.getTrackVerticalOffset().floorEntry(y);
if (entry != null) { if (entry != null) {
if (entry.getValue() instanceof StreamPainter) { if (entry.getValue() instanceof StreamPainter) {
result.add(((StreamPainter) entry.getValue()).getClicked(new Point(x, y - entry.getKey()))); ITx tx = ((StreamPainter) entry.getValue()).getClicked(new Point(x, y - entry.getKey()));
} else if (entry.getValue() instanceof SignalPainter) if(tx!=null)
result.add(((SignalPainter) entry.getValue()).getSignal()); result.add(tx);
}
result.add(entry.getValue().getTrackEntry());
} }
} else if (p instanceof CursorPainter) { } else if (p instanceof CursorPainter) {
if (Math.abs(point.x - origin.x - ((CursorPainter) p).getTime()/scaleFactor) < 2) { if (Math.abs(point.x - origin.x - ((CursorPainter) p).getTime()/scaleFactor) < 2) {
@ -368,7 +397,7 @@ public class WaveformCanvas extends Canvas {
public List<Object> getEntriesAtPosition(IWaveform<? extends IWaveformEvent> iWaveform, int i) { public List<Object> getEntriesAtPosition(IWaveform<? extends IWaveformEvent> iWaveform, int i) {
LinkedList<Object> result=new LinkedList<>(); LinkedList<Object> result=new LinkedList<>();
int x = i - origin.x; int x = i - origin.x;
for(IPainter p: trackVerticalOffset.values()){ for(IPainter p: wave2painterMap.values()){
if (p instanceof StreamPainter && ((StreamPainter)p).getStream()==iWaveform) { if (p instanceof StreamPainter && ((StreamPainter)p).getStream()==iWaveform) {
result.add(((StreamPainter) p).getClicked(new Point(x, trackHeight/2))); result.add(((StreamPainter) p).getClicked(new Point(x, trackHeight/2)));
} }
@ -376,9 +405,8 @@ public class WaveformCanvas extends Canvas {
return result; return result;
} }
public void setSelected(ITx currentSelection, IWaveform<? extends IWaveformEvent> currentWaveformSelection) { public void setSelected(ITx currentSelection) {
this.currentSelection = currentSelection; this.currentSelection = currentSelection;
this.currentWaveformSelection = currentWaveformSelection;
if (currentSelection != null) if (currentSelection != null)
reveal(currentSelection); reveal(currentSelection);
redraw(); redraw();
@ -395,9 +423,9 @@ public class WaveformCanvas extends Canvas {
} else if (higher > (size.x - origin.x)) { } else if (higher > (size.x - origin.x)) {
setOrigin(size.x - higher, origin.y); setOrigin(size.x - higher, origin.y);
} }
for (Entry<Integer, IWaveformPainter> entry : trackVerticalOffset.entrySet()) { for (IWaveformPainter painter : wave2painterMap.values()) {
if (entry.getValue() instanceof StreamPainter && ((StreamPainter) entry.getValue()).getStream() == tx.getStream()) { if (painter instanceof StreamPainter && ((StreamPainter) painter).getStream() == tx.getStream()) {
int top = entry.getKey() + trackHeight * tx.getConcurrencyIndex(); int top = painter.getVerticalOffset() + trackHeight * tx.getConcurrencyIndex();
int bottom = top + trackHeight; int bottom = top + trackHeight;
if (top < -origin.y) { if (top < -origin.y) {
setOrigin(origin.x, -(top-trackHeight)); setOrigin(origin.x, -(top-trackHeight));

View File

@ -8,7 +8,7 @@
* Contributors: * Contributors:
* MINRES Technologies GmbH - initial API and implementation * MINRES Technologies GmbH - initial API and implementation
*******************************************************************************/ *******************************************************************************/
package com.minres.scviewer.database.swt; package com.minres.scviewer.database.swt.internal;
import java.beans.PropertyChangeEvent; import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener; import java.beans.PropertyChangeListener;
@ -19,7 +19,6 @@ import java.util.List;
import java.util.Map.Entry; import java.util.Map.Entry;
import java.util.NavigableMap; import java.util.NavigableMap;
import java.util.TreeMap; import java.util.TreeMap;
import java.util.Vector;
import org.eclipse.core.runtime.ListenerList; import org.eclipse.core.runtime.ListenerList;
import org.eclipse.jface.util.LocalSelectionTransfer; import org.eclipse.jface.util.LocalSelectionTransfer;
@ -75,18 +74,11 @@ import com.minres.scviewer.database.ITxEvent;
import com.minres.scviewer.database.ITxStream; import com.minres.scviewer.database.ITxStream;
import com.minres.scviewer.database.IWaveform; import com.minres.scviewer.database.IWaveform;
import com.minres.scviewer.database.IWaveformEvent; import com.minres.scviewer.database.IWaveformEvent;
import com.minres.scviewer.database.swt.internal.CursorPainter;
import com.minres.scviewer.database.swt.internal.IWaveformPainter;
import com.minres.scviewer.database.swt.internal.ObservableList;
import com.minres.scviewer.database.swt.internal.RulerPainter;
import com.minres.scviewer.database.swt.internal.SignalPainter;
import com.minres.scviewer.database.swt.internal.StreamPainter;
import com.minres.scviewer.database.swt.internal.TrackPainter;
import com.minres.scviewer.database.swt.internal.WaveformCanvas;
import com.minres.scviewer.database.ui.GotoDirection; import com.minres.scviewer.database.ui.GotoDirection;
import com.minres.scviewer.database.ui.IWaveformPanel; import com.minres.scviewer.database.ui.IWaveformViewer;
import com.minres.scviewer.database.ui.TrackEntry;
public class TxDisplay implements IWaveformPanel { public class WaveformViewer implements IWaveformViewer {
private ListenerList selectionChangedListeners = new ListenerList(); private ListenerList selectionChangedListeners = new ListenerList();
@ -96,7 +88,7 @@ public class TxDisplay implements IWaveformPanel {
private ITx currentTxSelection; private ITx currentTxSelection;
private IWaveform<? extends IWaveformEvent> currentWaveformSelection; private TrackEntry currentWaveformSelection;
private ScrolledComposite nameListScrolled; private ScrolledComposite nameListScrolled;
@ -110,15 +102,13 @@ public class TxDisplay implements IWaveformPanel {
private Composite top; private Composite top;
protected ObservableList<IWaveform<? extends IWaveformEvent>> streams; protected ObservableList<TrackEntry> streams;
Vector<CursorPainter> cursorPainters;
int selectedMarker = 0; int selectedMarker = 0;
private int trackVerticalHeight; private int trackVerticalHeight;
private TreeMap<Integer, IWaveform<? extends IWaveformEvent>> trackVerticalOffset; private TreeMap<Integer, TrackEntry> trackVerticalOffset;
private HashMap<IWaveform<? extends IWaveformEvent>, String> actualValues; private HashMap<IWaveform<? extends IWaveformEvent>, String> actualValues;
@ -128,9 +118,9 @@ public class TxDisplay implements IWaveformPanel {
@Override @Override
public void mouseDown(MouseEvent e) { public void mouseDown(MouseEvent e) {
if ((e.button == 1 || e.button == 3)) { if ((e.button == 1 || e.button == 3)) {
Entry<Integer, IWaveform<? extends IWaveformEvent>> entry = trackVerticalOffset.floorEntry(e.y); Entry<Integer, TrackEntry> entry = trackVerticalOffset.floorEntry(e.y);
if (entry != null) if (entry != null)
setSelection(new StructuredSelection(entry.getValue())); setSelection(new StructuredSelection(entry.getValue().waveform));
} }
if (e.button == 3) { if (e.button == 3) {
Menu topMenu= top.getMenu(); Menu topMenu= top.getMenu();
@ -150,15 +140,8 @@ public class TxDisplay implements IWaveformPanel {
initialSelected = waveformCanvas.getClicked(start); initialSelected = waveformCanvas.getClicked(start);
} else if (e.button == 3) { } else if (e.button == 3) {
List<Object> hitted = waveformCanvas.getClicked(start); List<Object> hitted = waveformCanvas.getClicked(start);
for(Object entry:hitted){ if(hitted!=null && hitted.size()>0)
if(entry instanceof IWaveform<?>){ setSelection(new StructuredSelection(hitted));
setSelection(new StructuredSelection(entry));
break;
}else if(entry instanceof ITx){
setSelection(new StructuredSelection(((ITx)entry).getStream()));
break;
}
}
Menu topMenu= top.getMenu(); Menu topMenu= top.getMenu();
if(topMenu!=null) topMenu.setVisible(true); if(topMenu!=null) topMenu.setVisible(true);
} }
@ -197,14 +180,17 @@ public class TxDisplay implements IWaveformPanel {
long scaling=5*waveformCanvas.getScaleFactor(); long scaling=5*waveformCanvas.getScaleFactor();
for(Object o:waveformCanvas.getClicked(start)){ for(Object o:waveformCanvas.getClicked(start)){
Entry<Long, ?> floorEntry=null, ceilEntry=null; Entry<Long, ?> floorEntry=null, ceilEntry=null;
if(o instanceof ISignal<?>){ if(o instanceof TrackEntry){
NavigableMap<Long, ?> map = ((ISignal<?>)o).getEvents(); TrackEntry entry = (TrackEntry) o;
if(entry.waveform instanceof ISignal<?>){
NavigableMap<Long, ?> map = ((ISignal<?>)entry.waveform).getEvents();
floorEntry = map.floorEntry(time); floorEntry = map.floorEntry(time);
ceilEntry = map.ceilingEntry(time); ceilEntry = map.ceilingEntry(time);
} else if (o instanceof ITxStream<?>){ } else if (entry.waveform instanceof ITxStream<?>){
NavigableMap<Long, ?> map = ((ITxStream<?>)o).getEvents(); NavigableMap<Long, ?> map = ((ITxStream<?>)entry.waveform).getEvents();
floorEntry = map.floorEntry(time); floorEntry = map.floorEntry(time);
ceilEntry = map.ceilingEntry(time); ceilEntry = map.ceilingEntry(time);
}
} else if(o instanceof ITx){ } else if(o instanceof ITx){
NavigableMap<Long, ?> map = ((ITx)o).getStream().getEvents(); NavigableMap<Long, ?> map = ((ITx)o).getStream().getEvents();
floorEntry = map.floorEntry(time); floorEntry = map.floorEntry(time);
@ -226,18 +212,17 @@ public class TxDisplay implements IWaveformPanel {
} }
}; };
public TxDisplay(Composite parent) { public WaveformViewer(Composite parent) {
pcs=new PropertyChangeSupport(this); pcs=new PropertyChangeSupport(this);
trackVerticalOffset = new TreeMap<Integer, IWaveform<? extends IWaveformEvent>>(); trackVerticalOffset = new TreeMap<Integer, TrackEntry>();
trackVerticalHeight=0; trackVerticalHeight=0;
actualValues = new HashMap<IWaveform<? extends IWaveformEvent>, String>(); actualValues = new HashMap<IWaveform<? extends IWaveformEvent>, String>();
cursorPainters = new Vector<CursorPainter>();
nameFont = parent.getDisplay().getSystemFont(); nameFont = parent.getDisplay().getSystemFont();
nameFontB = SWTResourceManager.getBoldFont(nameFont); nameFontB = SWTResourceManager.getBoldFont(nameFont);
streams = new ObservableList<IWaveform<? extends IWaveformEvent>>(); streams = new ObservableList<>();
streams.addPropertyChangeListener(this); streams.addPropertyChangeListener(this);
top = new Composite(parent, SWT.NONE); top = new Composite(parent, SWT.NONE);
@ -319,17 +304,6 @@ public class TxDisplay implements IWaveformPanel {
valueList.addMouseListener(nameValueMouseListener); valueList.addMouseListener(nameValueMouseListener);
valueListScrolled.setContent(valueList); valueListScrolled.setContent(valueList);
waveformCanvas.setStreams(streams);
// order is important: it is bottom to top
waveformCanvas.addPainter(new TrackPainter(waveformCanvas));
waveformCanvas.addPainter(new RulerPainter(
waveformCanvas, waveformCanvas.getDisplay().getSystemColor(SWT.COLOR_BLACK), waveformCanvas.getDisplay().getSystemColor(SWT.COLOR_WHITE)));
CursorPainter cp = new CursorPainter(waveformCanvas, waveformCanvas.getScaleFactor() * 10, cursorPainters.size()-1);
waveformCanvas.addPainter(cp);
cursorPainters.add(cp);
CursorPainter marker = new CursorPainter(waveformCanvas, waveformCanvas.getScaleFactor() * 100, cursorPainters.size()-1);
waveformCanvas.addPainter(marker);
cursorPainters.add(marker);
waveformCanvas.setMaxTime(1); waveformCanvas.setMaxTime(1);
waveformCanvas.addMouseListener(waveformMouseListener); waveformCanvas.addMouseListener(waveformMouseListener);
@ -406,28 +380,28 @@ public class TxDisplay implements IWaveformPanel {
IWaveformPainter painter = null; IWaveformPainter painter = null;
trackVerticalOffset.clear(); trackVerticalOffset.clear();
actualValues.clear(); actualValues.clear();
waveformCanvas.clearAllWavefromPainter(); waveformCanvas.clearAllWaveformPainter();
boolean even = true; boolean even = true;
boolean clearSelection = true; boolean clearSelection = true;
TextLayout tl = new TextLayout(waveformCanvas.getDisplay()); TextLayout tl = new TextLayout(waveformCanvas.getDisplay());
tl.setFont(nameFontB); tl.setFont(nameFontB);
for (IWaveform<? extends IWaveformEvent> waveform : streams) { for (TrackEntry streamEntry : streams) {
int height = waveformCanvas.getTrackHeight(); streamEntry.height = waveformCanvas.getTrackHeight();
clearSelection &= (waveform != currentWaveformSelection); streamEntry.vOffset=trackVerticalHeight;
if (waveform instanceof ITxStream<?>) { clearSelection &= currentWaveformSelection!=null && (streamEntry.waveform != currentWaveformSelection.waveform);
ITxStream<? extends ITxEvent> stream = (ITxStream<? extends ITxEvent>) waveform; if (streamEntry.isStream()) {
height *= stream.getMaxConcurrency(); streamEntry.height *= streamEntry.getStream().getMaxConcurrency();
painter = new StreamPainter(waveformCanvas, even, height, (ITxStream<? extends ITxEvent>) waveform); painter = new StreamPainter(waveformCanvas, even, streamEntry);
actualValues.put(stream, ""); actualValues.put(streamEntry.waveform, "");
} else if (waveform instanceof ISignal<?>) { } else if (streamEntry.isSignal()) {
painter = new SignalPainter(waveformCanvas, even, height, (ISignal<?>) waveform); painter = new SignalPainter(waveformCanvas, even, streamEntry);
actualValues.put(waveform, "---"); actualValues.put(streamEntry.waveform, "---");
} }
waveformCanvas.addWavefromPainter(trackVerticalHeight, painter); waveformCanvas.addWaveformPainter(painter);
trackVerticalOffset.put(trackVerticalHeight, waveform); trackVerticalOffset.put(trackVerticalHeight, streamEntry);
tl.setText(waveform.getFullName()); tl.setText(streamEntry.waveform.getFullName());
nameMaxWidth = Math.max(nameMaxWidth, tl.getBounds().width); nameMaxWidth = Math.max(nameMaxWidth, tl.getBounds().width);
trackVerticalHeight += height; trackVerticalHeight += streamEntry.height;
even = !even; even = !even;
} }
nameList.setSize(nameMaxWidth + 15, trackVerticalHeight); nameList.setSize(nameMaxWidth + 15, trackVerticalHeight);
@ -438,7 +412,9 @@ public class TxDisplay implements IWaveformPanel {
updateValueList(); updateValueList();
waveformCanvas.redraw(); waveformCanvas.redraw();
top.layout(new Control[] { valueList, nameList, waveformCanvas }); top.layout(new Control[] { valueList, nameList, waveformCanvas });
if (trackVerticalOffset.isEmpty() || previousHeight > trackVerticalOffset.lastKey()) { if (trackVerticalOffset.isEmpty()){
waveformCanvas.setOrigin(0, 0);
}else if(previousHeight > trackVerticalOffset.lastKey()){
Point o = waveformCanvas.getOrigin(); Point o = waveformCanvas.getOrigin();
waveformCanvas.setOrigin(o.x, o.y - (previousHeight - trackVerticalOffset.lastKey())); waveformCanvas.setOrigin(o.x, o.y - (previousHeight - trackVerticalOffset.lastKey()));
} }
@ -563,7 +539,7 @@ public class TxDisplay implements IWaveformPanel {
if (currentTxSelection != null) if (currentTxSelection != null)
return new StructuredSelection(currentTxSelection); return new StructuredSelection(currentTxSelection);
else if (currentWaveformSelection != null) else if (currentWaveformSelection != null)
return new StructuredSelection(currentWaveformSelection); return new StructuredSelection(currentWaveformSelection.waveform);
else else
return new StructuredSelection(); return new StructuredSelection();
} }
@ -583,6 +559,7 @@ public class TxDisplay implements IWaveformPanel {
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
public void setSelection(ISelection selection, boolean addIfNeeded) { public void setSelection(ISelection selection, boolean addIfNeeded) {
boolean selectionChanged = false; boolean selectionChanged = false;
if(currentWaveformSelection!=null) currentWaveformSelection.selected=false;
if (selection instanceof IStructuredSelection) { if (selection instanceof IStructuredSelection) {
if(((IStructuredSelection) selection).size()==0){ if(((IStructuredSelection) selection).size()==0){
selectionChanged = currentTxSelection!=null||currentWaveformSelection!=null; selectionChanged = currentTxSelection!=null||currentWaveformSelection!=null;
@ -592,19 +569,18 @@ public class TxDisplay implements IWaveformPanel {
for(Object sel:((IStructuredSelection) selection).toArray()){ for(Object sel:((IStructuredSelection) selection).toArray()){
if (sel instanceof ITx && currentTxSelection != sel){ if (sel instanceof ITx && currentTxSelection != sel){
ITx txSel = (ITx) sel; ITx txSel = (ITx) sel;
if (streams.contains(((ITx)sel).getStream())) { TrackEntry trackEntry = getEntryForStream(txSel.getStream());
currentTxSelection = txSel; if(trackEntry==null && addIfNeeded){
currentWaveformSelection = txSel.getStream(); trackEntry=new TrackEntry(txSel.getStream());
selectionChanged = true; streams.add(trackEntry);
} else if(addIfNeeded){ currentWaveformSelection = trackEntry;
streams.add(txSel.getStream());
currentTxSelection = txSel;
currentWaveformSelection = txSel.getStream();
selectionChanged = true;
} }
} else if (sel instanceof IWaveform<?> && currentWaveformSelection != sel&& streams.contains(sel)) { currentTxSelection = txSel;
currentTxSelection = null; selectionChanged = true;
currentWaveformSelection = (IWaveform<? extends IWaveformEvent>) sel; } else if (sel instanceof TrackEntry && currentWaveformSelection != sel) {
currentWaveformSelection = (TrackEntry) sel;
if(currentTxSelection!=null && currentTxSelection.getStream()!=currentWaveformSelection)
currentTxSelection=null;
selectionChanged = true; selectionChanged = true;
} }
} }
@ -615,17 +591,25 @@ public class TxDisplay implements IWaveformPanel {
currentTxSelection = null; currentTxSelection = null;
currentWaveformSelection = null; currentWaveformSelection = null;
} }
if(currentWaveformSelection!=null) currentWaveformSelection.selected=true;
if (selectionChanged) { if (selectionChanged) {
waveformCanvas.setSelected(currentTxSelection, currentWaveformSelection); waveformCanvas.setSelected(currentTxSelection);
nameList.setData(SELECTION, currentWaveformSelection);
valueList.redraw(); valueList.redraw();
nameList.redraw(); nameList.redraw();
fireSelectionChanged();
}
}
protected void fireSelectionChanged() {
if(currentWaveformSelection==null) return;
IStructuredSelection selection=currentTxSelection!=null?
new StructuredSelection(new Object[]{currentTxSelection, currentWaveformSelection.waveform}):
new StructuredSelection(currentWaveformSelection.waveform);
Object[] list = selectionChangedListeners.getListeners(); Object[] list = selectionChangedListeners.getListeners();
for (int i = 0; i < list.length; i++) { for (int i = 0; i < list.length; i++) {
((ISelectionChangedListener) list[i]).selectionChanged(new SelectionChangedEvent(this, selection)); ((ISelectionChangedListener) list[i]).selectionChanged(new SelectionChangedEvent(this, selection));
} }
} }
}
/* (non-Javadoc) /* (non-Javadoc)
* @see com.minres.scviewer.database.swt.IWaveformPanel#moveSelection(com.minres.scviewer.database.swt.GotoDirection) * @see com.minres.scviewer.database.swt.IWaveformPanel#moveSelection(com.minres.scviewer.database.swt.GotoDirection)
@ -633,8 +617,8 @@ public class TxDisplay implements IWaveformPanel {
@Override @Override
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
public void moveSelection(GotoDirection direction) { public void moveSelection(GotoDirection direction) {
if (currentWaveformSelection instanceof ITxStream<?>) { if (currentWaveformSelection.isStream()) {
ITxStream<ITxEvent> stream = (ITxStream<ITxEvent>) currentWaveformSelection; ITxStream<? extends ITxEvent> stream = currentWaveformSelection.getStream();
ITx transaction = null; ITx transaction = null;
if (direction == GotoDirection.NEXT) { if (direction == GotoDirection.NEXT) {
List<ITxEvent> thisEntryList = stream.getEvents().get(currentTxSelection.getBeginTime()); List<ITxEvent> thisEntryList = stream.getEvents().get(currentTxSelection.getBeginTime());
@ -701,10 +685,10 @@ public class TxDisplay implements IWaveformPanel {
public void moveCursor(GotoDirection direction) { public void moveCursor(GotoDirection direction) {
long time = getCursorTime(); long time = getCursorTime();
NavigableMap<Long, ?> map=null; NavigableMap<Long, ?> map=null;
if(currentWaveformSelection instanceof ITxStream<?>){ if(currentWaveformSelection.isStream()){
map=((ITxStream<?>) currentWaveformSelection).getEvents(); map=currentWaveformSelection.getStream().getEvents();
} else if(currentWaveformSelection instanceof ISignal<?>){ } else if(currentWaveformSelection.isSignal()){
map=((ISignal<?>) currentWaveformSelection).getEvents(); map=currentWaveformSelection.getSignal().getEvents();
} }
if(map!=null){ if(map!=null){
Entry<Long, ?> entry=direction==GotoDirection.PREV?map.lowerEntry(time):map.higherEntry(time); Entry<Long, ?> entry=direction==GotoDirection.PREV?map.lowerEntry(time):map.higherEntry(time);
@ -722,7 +706,7 @@ public class TxDisplay implements IWaveformPanel {
* @see com.minres.scviewer.database.swt.IWaveformPanel#getStreamList() * @see com.minres.scviewer.database.swt.IWaveformPanel#getStreamList()
*/ */
@Override @Override
public List<IWaveform<? extends IWaveformEvent>> getStreamList() { public List<TrackEntry> getStreamList() {
return streams; return streams;
} }
@ -733,16 +717,16 @@ public class TxDisplay implements IWaveformPanel {
public void moveSelected(int i) { public void moveSelected(int i) {
if(currentWaveformSelection!=null){ if(currentWaveformSelection!=null){
ITx selectedTx=currentTxSelection; ITx selectedTx=currentTxSelection;
IWaveform<? extends IWaveformEvent> selectedWaveform=currentWaveformSelection; TrackEntry selectedWaveform=currentWaveformSelection;
int idx = streams.indexOf(currentWaveformSelection); int idx = streams.indexOf(currentWaveformSelection);
int newIdx=idx+i; int newIdx=idx+i;
if(newIdx>=0 && newIdx<streams.size()){ if(newIdx>=0 && newIdx<streams.size()){
Collections.swap(streams,idx,newIdx); Collections.swap(streams,idx,newIdx);
updateTracklist(); updateTracklist();
if(selectedTx!=null){ if(selectedTx!=null){
setSelection(new StructuredSelection(new Object[]{selectedTx, selectedWaveform})); setSelection(new StructuredSelection(new Object[]{selectedTx, selectedWaveform.waveform}));
} else } else
setSelection(new StructuredSelection(selectedWaveform)); setSelection(new StructuredSelection(selectedWaveform.waveform));
} }
} }
} }
@ -750,53 +734,50 @@ public class TxDisplay implements IWaveformPanel {
protected void paintNames(GC gc, Rectangle rect) { protected void paintNames(GC gc, Rectangle rect) {
if (streams.size() > 0) { if (streams.size() > 0) {
@SuppressWarnings("unchecked")
IWaveform<? extends IWaveformEvent> wave = (IWaveform<? extends IWaveformEvent>) nameList.getData(SELECTION);
Integer firstKey = trackVerticalOffset.floorKey(rect.y); Integer firstKey = trackVerticalOffset.floorKey(rect.y);
if (firstKey == null) if (firstKey == null)
firstKey = trackVerticalOffset.firstKey(); firstKey = trackVerticalOffset.firstKey();
Integer lastKey = trackVerticalOffset.floorKey(rect.y + rect.height); Integer lastKey = trackVerticalOffset.floorKey(rect.y + rect.height);
Rectangle subArea = new Rectangle(rect.x, 0, rect.width, waveformCanvas.getTrackHeight()); Rectangle subArea = new Rectangle(rect.x, 0, rect.width, waveformCanvas.getTrackHeight());
if (lastKey == firstKey) { if (lastKey == firstKey) {
IWaveform<? extends IWaveformEvent> w = trackVerticalOffset.get(firstKey); TrackEntry trackEntry=trackVerticalOffset.get(firstKey);
IWaveform<? extends IWaveformEvent> w = trackEntry.waveform;
if (w instanceof ITxStream<?>) if (w instanceof ITxStream<?>)
subArea.height *= ((ITxStream<?>) w).getMaxConcurrency(); subArea.height *= ((ITxStream<?>) w).getMaxConcurrency();
drawTextFormat(gc, subArea, firstKey, w.getFullName(), w.equals(wave)); drawTextFormat(gc, subArea, firstKey, w.getFullName(), trackEntry.selected);
} else { } else {
for (Entry<Integer, IWaveform<? extends IWaveformEvent>> entry : trackVerticalOffset.subMap(firstKey, true, lastKey, true) for (Entry<Integer, TrackEntry> entry : trackVerticalOffset.subMap(firstKey, true, lastKey, true).entrySet()) {
.entrySet()) { IWaveform<? extends IWaveformEvent> w = entry.getValue().waveform;
IWaveform<? extends IWaveformEvent> w = entry.getValue();
subArea.height = waveformCanvas.getTrackHeight(); subArea.height = waveformCanvas.getTrackHeight();
if (w instanceof ITxStream<?>) if (w instanceof ITxStream<?>)
subArea.height *= ((ITxStream<?>) w).getMaxConcurrency(); subArea.height *= ((ITxStream<?>) w).getMaxConcurrency();
drawTextFormat(gc, subArea, entry.getKey(), w.getFullName(), w.equals(wave)); drawTextFormat(gc, subArea, entry.getKey(), w.getFullName(), entry.getValue().selected);
} }
} }
} }
} }
@SuppressWarnings("unchecked")
protected void paintValues(GC gc, Rectangle rect) { protected void paintValues(GC gc, Rectangle rect) {
if (streams.size() > 0) { if (streams.size() > 0) {
IWaveform<? extends IWaveformEvent> wave = (IWaveform<? extends IWaveformEvent>) nameList.getData(SELECTION);
Integer firstKey = trackVerticalOffset.floorKey(rect.y); Integer firstKey = trackVerticalOffset.floorKey(rect.y);
if (firstKey == null) if (firstKey == null)
firstKey = trackVerticalOffset.firstKey(); firstKey = trackVerticalOffset.firstKey();
Integer lastKey = trackVerticalOffset.floorKey(rect.y + rect.height); Integer lastKey = trackVerticalOffset.floorKey(rect.y + rect.height);
Rectangle subArea = new Rectangle(rect.x, 0, rect.width, waveformCanvas.getTrackHeight()); Rectangle subArea = new Rectangle(rect.x, 0, rect.width, waveformCanvas.getTrackHeight());
if (lastKey == firstKey) { if (lastKey == firstKey) {
IWaveform<? extends IWaveformEvent> w = trackVerticalOffset.get(firstKey); TrackEntry trackEntry=trackVerticalOffset.get(firstKey);
IWaveform<? extends IWaveformEvent> w = trackEntry.waveform;
if (w instanceof ITxStream<?>) if (w instanceof ITxStream<?>)
subArea.height *= ((ITxStream<?>) w).getMaxConcurrency(); subArea.height *= ((ITxStream<?>) w).getMaxConcurrency();
drawValue(gc, subArea, firstKey, actualValues.get(w), w.equals(wave)); drawValue(gc, subArea, firstKey, actualValues.get(w), trackEntry.selected);
} else { } else {
for (Entry<Integer, IWaveform<? extends IWaveformEvent>> entry : trackVerticalOffset.subMap(firstKey, true, lastKey, true) for (Entry<Integer, TrackEntry> entry : trackVerticalOffset.subMap(firstKey, true, lastKey, true)
.entrySet()) { .entrySet()) {
IWaveform<? extends IWaveformEvent> w = entry.getValue(); IWaveform<? extends IWaveformEvent> w = entry.getValue().waveform;
subArea.height = waveformCanvas.getTrackHeight(); subArea.height = waveformCanvas.getTrackHeight();
if (w instanceof ITxStream<?>) if (w instanceof ITxStream<?>)
subArea.height *= ((ITxStream<?>) w).getMaxConcurrency(); subArea.height *= ((ITxStream<?>) w).getMaxConcurrency();
drawValue(gc, subArea, entry.getKey(), actualValues.get(w), w.equals(wave)); drawValue(gc, subArea, entry.getKey(), actualValues.get(w), entry.getValue().selected);
} }
} }
} }
@ -865,8 +846,8 @@ public class TxDisplay implements IWaveformPanel {
*/ */
@Override @Override
public void setCursorTime(long time){ public void setCursorTime(long time){
final Long oldVal= cursorPainters.get(0).getTime(); final Long oldVal= waveformCanvas.getCursorPainters().get(0).getTime();
cursorPainters.get(0).setTime(time); waveformCanvas.getCursorPainters().get(0).setTime(time);
pcs.firePropertyChange(CURSOR_PROPERTY, oldVal, time); pcs.firePropertyChange(CURSOR_PROPERTY, oldVal, time);
} }
@ -875,9 +856,9 @@ public class TxDisplay implements IWaveformPanel {
*/ */
@Override @Override
public void setMarkerTime(long time, int index){ public void setMarkerTime(long time, int index){
if(cursorPainters.size()>index+1){ if(waveformCanvas.getCursorPainters().size()>index+1){
final Long oldVal= cursorPainters.get(1+index).getTime(); final Long oldVal= waveformCanvas.getCursorPainters().get(1+index).getTime();
cursorPainters.get(1+index).setTime(time); waveformCanvas.getCursorPainters().get(1+index).setTime(time);
pcs.firePropertyChange(MARKER_PROPERTY, oldVal, time); pcs.firePropertyChange(MARKER_PROPERTY, oldVal, time);
} }
} }
@ -887,7 +868,7 @@ public class TxDisplay implements IWaveformPanel {
*/ */
@Override @Override
public long getCursorTime(){ public long getCursorTime(){
return cursorPainters.get(0).getTime(); return waveformCanvas.getCursorPainters().get(0).getTime();
} }
/* (non-Javadoc) /* (non-Javadoc)
@ -903,7 +884,7 @@ public class TxDisplay implements IWaveformPanel {
*/ */
@Override @Override
public long getMarkerTime(int index){ public long getMarkerTime(int index){
return cursorPainters.get(index+1).getTime(); return waveformCanvas.getCursorPainters().get(index+1).getTime();
} }
private void createStreamDragSource(final Canvas canvas) { private void createStreamDragSource(final Canvas canvas) {
@ -948,14 +929,15 @@ public class TxDisplay implements IWaveformPanel {
if(source instanceof IWaveform<?> && target instanceof IWaveform<?>){ if(source instanceof IWaveform<?> && target instanceof IWaveform<?>){
IWaveform<? extends IWaveformEvent> srcWave=(IWaveform<? extends IWaveformEvent>) source; IWaveform<? extends IWaveformEvent> srcWave=(IWaveform<? extends IWaveformEvent>) source;
int srcIdx=streams.indexOf(srcWave); int srcIdx=streams.indexOf(srcWave);
streams.remove(source); streams.remove(getEntryForStream((IWaveform<?>)source));
int tgtIdx=streams.indexOf(target); int tgtIdx=streams.indexOf(target);
if(srcIdx<=tgtIdx) tgtIdx++; if(srcIdx<=tgtIdx) tgtIdx++;
TrackEntry entry = new TrackEntry(srcWave);
if(tgtIdx>=streams.size()) if(tgtIdx>=streams.size())
streams.add(srcWave); streams.add(entry);
else else
streams.add(tgtIdx, srcWave); streams.add(tgtIdx, entry);
currentWaveformSelection=srcWave; currentWaveformSelection=entry;
updateTracklist(); updateTracklist();
} else if(source instanceof CursorPainter){ } else if(source instanceof CursorPainter){
((CursorPainter)source).setTime(0); ((CursorPainter)source).setTime(0);
@ -975,6 +957,12 @@ public class TxDisplay implements IWaveformPanel {
}); });
} }
public TrackEntry getEntryForStream(IWaveform<?> source) {
for(TrackEntry trackEntry:streams)
if(trackEntry.waveform.equals(source)) return trackEntry;
return null;
}
private void createWaveformDragSource(final Canvas canvas) { private void createWaveformDragSource(final Canvas canvas) {
Transfer[] types = new Transfer[] { LocalSelectionTransfer.getTransfer() }; Transfer[] types = new Transfer[] { LocalSelectionTransfer.getTransfer() };
DragSource dragSource = new DragSource(canvas, DND.DROP_MOVE); DragSource dragSource = new DragSource(canvas, DND.DROP_MOVE);

View File

@ -1,12 +1,12 @@
/******************************************************************************* /*******************************************************************************
* Copyright (c) 2011 Google, Inc. * Copyright (c) 2015 MINRES Technologies GmbH and others.
* All rights reserved. This program and the accompanying materials * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0 * are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at * which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html * http://www.eclipse.org/legal/epl-v10.html
* *
* Contributors: * Contributors:
* Google, Inc. - initial API and implementation * MINRES Technologies GmbH - initial API and implementation
*******************************************************************************/ *******************************************************************************/
package org.eclipse.wb.swt; package org.eclipse.wb.swt;

View File

@ -10,4 +10,4 @@
*******************************************************************************/ *******************************************************************************/
package com.minres.scviewer.database.ui; package com.minres.scviewer.database.ui;
public enum GotoDirection {PREV, NEXT} public enum GotoDirection {PREV, NEXT, UP, DOWN}

View File

@ -1,3 +1,13 @@
/*******************************************************************************
* Copyright (c) 2015 MINRES Technologies GmbH and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* MINRES Technologies GmbH - initial API and implementation
*******************************************************************************/
package com.minres.scviewer.database.ui; package com.minres.scviewer.database.ui;
import java.beans.PropertyChangeListener; import java.beans.PropertyChangeListener;
@ -9,9 +19,8 @@ import org.eclipse.jface.viewers.ISelectionProvider;
import org.eclipse.swt.widgets.Control; import org.eclipse.swt.widgets.Control;
import com.minres.scviewer.database.IWaveform; import com.minres.scviewer.database.IWaveform;
import com.minres.scviewer.database.IWaveformEvent;
public interface IWaveformPanel extends PropertyChangeListener, ISelectionProvider{ public interface IWaveformViewer extends PropertyChangeListener, ISelectionProvider{
String CURSOR_PROPERTY = "cursor_time"; String CURSOR_PROPERTY = "cursor_time";
String MARKER_PROPERTY = "marker_time"; String MARKER_PROPERTY = "marker_time";
@ -38,7 +47,9 @@ public interface IWaveformPanel extends PropertyChangeListener, ISelectionProvid
void moveCursor(GotoDirection direction); void moveCursor(GotoDirection direction);
List<IWaveform<? extends IWaveformEvent>> getStreamList(); List<TrackEntry> getStreamList();
public TrackEntry getEntryForStream(IWaveform<?> source);
void moveSelected(int i); void moveSelected(int i);

View File

@ -0,0 +1,17 @@
/*******************************************************************************
* Copyright (c) 2015 MINRES Technologies GmbH and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* MINRES Technologies GmbH - initial API and implementation
*******************************************************************************/
package com.minres.scviewer.database.ui;
import org.eclipse.swt.widgets.Composite;
public interface IWaveformViewerFactory {
public IWaveformViewer createPanel(Composite parent);
}

View File

@ -0,0 +1,60 @@
/*******************************************************************************
* Copyright (c) 2015 MINRES Technologies GmbH and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* MINRES Technologies GmbH - initial API and implementation
*******************************************************************************/
package com.minres.scviewer.database.ui;
import com.minres.scviewer.database.ISignal;
import com.minres.scviewer.database.ISignalChange;
import com.minres.scviewer.database.ITxEvent;
import com.minres.scviewer.database.ITxStream;
import com.minres.scviewer.database.IWaveform;
import com.minres.scviewer.database.IWaveformEvent;
public class TrackEntry {
final public IWaveform<? extends IWaveformEvent> waveform;
public int vOffset;
public int height;
public boolean selected;
public TrackEntry(IWaveform<? extends IWaveformEvent> waveform) {
this.waveform = waveform;
vOffset=0;
height=0;
selected=false;
}
public boolean isStream(){
return waveform instanceof ITxStream<?>;
}
public ITxStream<? extends ITxEvent> getStream(){
return (ITxStream<?>) waveform;
}
public boolean isSignal(){
return waveform instanceof ISignal<?>;
}
public ISignal<? extends ISignalChange> getSignal(){
return (ISignal<?>) waveform;
}
@Override
public boolean equals(Object obj) {
if(obj instanceof TrackEntry){
TrackEntry o = (TrackEntry) obj;
return waveform==o.waveform && vOffset==o.vOffset;
}
return false;
}
}

View File

@ -8,6 +8,4 @@
<relativePath>../com.minres.scviewer.parent</relativePath> <relativePath>../com.minres.scviewer.parent</relativePath>
</parent> </parent>
<packaging>eclipse-plugin</packaging> <packaging>eclipse-plugin</packaging>
<version>1.0.0-SNAPSHOT</version> </project>
<groupId>com.minres.scviewer</groupId>
</project>

View File

@ -8,6 +8,4 @@
<relativePath>../com.minres.scviewer.parent</relativePath> <relativePath>../com.minres.scviewer.parent</relativePath>
</parent> </parent>
<packaging>eclipse-plugin</packaging> <packaging>eclipse-plugin</packaging>
<groupId>com.minres.scviewer</groupId> </project>
<version>1.0.0-SNAPSHOT</version>
</project>

View File

@ -48,21 +48,26 @@ import org.eclipse.jface.viewers.SelectionChangedEvent;
import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Composite;
import com.minres.scviewer.database.ITx; import com.minres.scviewer.database.ITx;
import com.minres.scviewer.database.ITxEvent;
import com.minres.scviewer.database.ITxStream;
import com.minres.scviewer.database.IWaveform; import com.minres.scviewer.database.IWaveform;
import com.minres.scviewer.database.IWaveformDb; import com.minres.scviewer.database.IWaveformDb;
import com.minres.scviewer.database.IWaveformDbFactory; import com.minres.scviewer.database.IWaveformDbFactory;
import com.minres.scviewer.database.IWaveformEvent; import com.minres.scviewer.database.IWaveformEvent;
import com.minres.scviewer.database.swt.TxDisplay; import com.minres.scviewer.database.swt.WaveformViewerFactory;
import com.minres.scviewer.database.ui.GotoDirection; import com.minres.scviewer.database.ui.GotoDirection;
import com.minres.scviewer.database.ui.IWaveformPanel; import com.minres.scviewer.database.ui.IWaveformViewer;
import com.minres.scviewer.database.ui.TrackEntry;
import com.minres.scviewer.e4.application.internal.WaveStatusBarControl; import com.minres.scviewer.e4.application.internal.WaveStatusBarControl;
public class WaveformViewerPart { public class WaveformViewerPart {
public static final String ACTIVE_WAVEFORMVIEW="Active_Waveform_View"; public static final String ACTIVE_WAVEFORMVIEW="Active_Waveform_View";
public static final String ADD_WAVEFORM="AddWaveform"; public static final String ADD_WAVEFORM="AddWaveform";
protected static final String DATABASE_FILE = "DATABASE_FILE"; protected static final String DATABASE_FILE = "DATABASE_FILE";
protected static final String SHOWN_WAVEFORM = "SHOWN_WAVEFORM"; protected static final String SHOWN_WAVEFORM = "SHOWN_WAVEFORM";
private String[] zoomLevel; private String[] zoomLevel;
@ -71,7 +76,9 @@ public class WaveformViewerPart {
public static final String WAVE_ACTION_ID = "com.minres.scviewer.ui.action.AddToWave"; public static final String WAVE_ACTION_ID = "com.minres.scviewer.ui.action.AddToWave";
private IWaveformPanel waveformPane; WaveformViewerFactory factory = new WaveformViewerFactory();
private IWaveformViewer waveformPane;
@Inject private IEventBroker eventBroker; @Inject private IEventBroker eventBroker;
@ -105,9 +112,9 @@ public class WaveformViewerPart {
} }
} }
}); });
waveformPane = new TxDisplay(parent); waveformPane = factory.createPanel(parent);
waveformPane.setMaxTime(0); waveformPane.setMaxTime(0);
waveformPane.addPropertyChangeListener(IWaveformPanel.CURSOR_PROPERTY, new PropertyChangeListener() { waveformPane.addPropertyChangeListener(IWaveformViewer.CURSOR_PROPERTY, new PropertyChangeListener() {
@Override @Override
public void propertyChange(PropertyChangeEvent evt) { public void propertyChange(PropertyChangeEvent evt) {
Long time = (Long) evt.getNewValue(); Long time = (Long) evt.getNewValue();
@ -117,7 +124,7 @@ public class WaveformViewerPart {
} }
}); });
waveformPane.addPropertyChangeListener(IWaveformPanel.MARKER_PROPERTY, new PropertyChangeListener() { waveformPane.addPropertyChangeListener(IWaveformViewer.MARKER_PROPERTY, new PropertyChangeListener() {
@Override @Override
public void propertyChange(PropertyChangeEvent evt) { public void propertyChange(PropertyChangeEvent evt) {
Long time = (Long) evt.getNewValue(); Long time = (Long) evt.getNewValue();
@ -237,8 +244,8 @@ public class WaveformViewerPart {
} }
persistedState.put(SHOWN_WAVEFORM+"S", Integer.toString(waveformPane.getStreamList().size())); persistedState.put(SHOWN_WAVEFORM+"S", Integer.toString(waveformPane.getStreamList().size()));
index=0; index=0;
for(IWaveform<? extends IWaveformEvent> waveform:waveformPane.getStreamList()){ for(TrackEntry trackEntry:waveformPane.getStreamList()){
persistedState.put(SHOWN_WAVEFORM+index, waveform.getFullName()); persistedState.put(SHOWN_WAVEFORM+index, trackEntry.waveform.getFullName());
index++; index++;
} }
} }
@ -246,10 +253,10 @@ public class WaveformViewerPart {
protected void restoreState() { protected void restoreState() {
updateAll(); updateAll();
Integer waves = persistedState.containsKey(SHOWN_WAVEFORM+"S")?Integer.parseInt(persistedState.get(SHOWN_WAVEFORM+"S")):0; Integer waves = persistedState.containsKey(SHOWN_WAVEFORM+"S")?Integer.parseInt(persistedState.get(SHOWN_WAVEFORM+"S")):0;
List<IWaveform<? extends IWaveformEvent>> res = new LinkedList<>(); List<TrackEntry> res = new LinkedList<>();
for(int i=0; i<waves;i++){ for(int i=0; i<waves;i++){
IWaveform<? extends IWaveformEvent> waveform = database.getStreamByName(persistedState.get(SHOWN_WAVEFORM+i)); IWaveform<? extends IWaveformEvent> waveform = database.getStreamByName(persistedState.get(SHOWN_WAVEFORM+i));
if(waveform!=null) res.add(waveform); if(waveform!=null) res.add(new TrackEntry(waveform));
} }
if(res.size()>0) waveformPane.getStreamList().addAll(res); if(res.size()>0) waveformPane.getStreamList().addAll(res);
} }
@ -325,23 +332,25 @@ public class WaveformViewerPart {
} }
public void addStreamsToList(IWaveform<? extends IWaveformEvent>[] iWaveforms, boolean insert){ public void addStreamsToList(IWaveform<? extends IWaveformEvent>[] iWaveforms, boolean insert){
List<IWaveform<? extends IWaveformEvent>> streams= new LinkedList<>(); List<TrackEntry> streams= new LinkedList<>();
for(IWaveform<? extends IWaveformEvent> stream:iWaveforms) for(IWaveform<? extends IWaveformEvent> stream:iWaveforms)
streams.add(stream); streams.add(new TrackEntry(stream));
IStructuredSelection selection = (IStructuredSelection) waveformPane.getSelection(); IStructuredSelection selection = (IStructuredSelection) waveformPane.getSelection();
if(selection.size()==0) if(selection.size()==0){
waveformPane.getStreamList().addAll(streams); waveformPane.getStreamList().addAll(streams);
else { }else {
IWaveform<?> selectedStream = (selection.getFirstElement() instanceof ITx)? Object first=selection.getFirstElement();
((ITx)selection.getFirstElement()).getStream():(IWaveform<?>)selection.getFirstElement(); IWaveform<?> stream = (first instanceof ITx)?((ITx)first).getStream():(IWaveform<?>)first;
int index = waveformPane.getStreamList().indexOf(selectedStream); TrackEntry trackEntry=waveformPane.getEntryForStream(stream);
int index = waveformPane.getStreamList().indexOf(trackEntry);
if(!insert) index++; if(!insert) index++;
waveformPane.getStreamList().addAll(index, streams); waveformPane.getStreamList().addAll(index, streams);
} }
} }
public void removeStreamFromList(IWaveform<? extends IWaveformEvent> obj){ public void removeStreamFromList(IWaveform<? extends IWaveformEvent> stream){
waveformPane.getStreamList().remove(obj); TrackEntry trackEntry=waveformPane.getEntryForStream(stream);
waveformPane.getStreamList().remove(trackEntry);
} }
public void removeStreamsFromList(IWaveform<? extends IWaveformEvent>[] iWaveforms){ public void removeStreamsFromList(IWaveform<? extends IWaveformEvent>[] iWaveforms){
@ -349,10 +358,6 @@ public class WaveformViewerPart {
removeStreamFromList(stream); removeStreamFromList(stream);
} }
public List<IWaveform<? extends IWaveformEvent>> getStreamList(){
return waveformPane.getStreamList();
}
public void moveSelected(int i) { public void moveSelected(int i) {
waveformPane.moveSelected(i); waveformPane.moveSelected(i);
} }

View File

@ -22,8 +22,8 @@
<stringAttribute key="pde.version" value="3.3"/> <stringAttribute key="pde.version" value="3.3"/>
<stringAttribute key="product" value="com.minres.scviewer.e4.application.product"/> <stringAttribute key="product" value="com.minres.scviewer.e4.application.product"/>
<stringAttribute key="productFile" value="/com.minres.scviewer.e4.application/com.minres.scviewer.e4.application.product"/> <stringAttribute key="productFile" value="/com.minres.scviewer.e4.application/com.minres.scviewer.e4.application.product"/>
<stringAttribute key="selected_target_plugins" value="com.google.guava*15.0.0.v201403281430@default:default,com.ibm.icu@default:default,javax.annotation@default:default,javax.inject@default:default,javax.servlet*3.1.0.v201410161800@default:default,javax.xml@default:default,org.apache.ant@default:default,org.apache.batik.css@default:default,org.apache.batik.util.gui@default:default,org.apache.batik.util@default:default,org.apache.commons.jxpath@default:default,org.apache.commons.logging@default:default,org.apache.felix.gogo.command@default:default,org.apache.felix.gogo.runtime@default:default,org.apache.felix.gogo.shell@default:default,org.codehaus.groovy*2.4.3.xx-201508121448-e45@default:default,org.eclipse.ant.core@default:default,org.eclipse.compare.core@default:default,org.eclipse.core.commands@default:default,org.eclipse.core.contenttype@default:default,org.eclipse.core.databinding.beans@default:default,org.eclipse.core.databinding.observable@default:default,org.eclipse.core.databinding.property@default:default,org.eclipse.core.databinding@default:default,org.eclipse.core.expressions@default:default,org.eclipse.core.filesystem.java7@default:false,org.eclipse.core.filesystem.macosx@default:false,org.eclipse.core.filesystem@default:default,org.eclipse.core.jobs@default:default,org.eclipse.core.resources@default:default,org.eclipse.core.runtime.compatibility.registry@default:false,org.eclipse.core.runtime@default:true,org.eclipse.core.variables@default:default,org.eclipse.e4.core.commands@default:default,org.eclipse.e4.core.contexts@default:default,org.eclipse.e4.core.di.annotations@default:default,org.eclipse.e4.core.di.extensions@default:default,org.eclipse.e4.core.di@default:default,org.eclipse.e4.core.services@default:default,org.eclipse.e4.emf.xpath@default:default,org.eclipse.e4.ui.bindings@default:default,org.eclipse.e4.ui.css.core@default:default,org.eclipse.e4.ui.css.swt.theme@default:default,org.eclipse.e4.ui.css.swt@default:default,org.eclipse.e4.ui.di@default:default,org.eclipse.e4.ui.model.workbench@default:default,org.eclipse.e4.ui.services@default:default,org.eclipse.e4.ui.widgets@default:default,org.eclipse.e4.ui.workbench.addons.swt@default:default,org.eclipse.e4.ui.workbench.renderers.swt.cocoa@default:false,org.eclipse.e4.ui.workbench.renderers.swt@default:default,org.eclipse.e4.ui.workbench.swt@default:default,org.eclipse.e4.ui.workbench3@default:default,org.eclipse.e4.ui.workbench@default:default,org.eclipse.emf.common@default:default,org.eclipse.emf.databinding@default:default,org.eclipse.emf.ecore.change@default:default,org.eclipse.emf.ecore.xmi@default:default,org.eclipse.emf.ecore@default:default,org.eclipse.equinox.app@default:default,org.eclipse.equinox.bidi@default:default,org.eclipse.equinox.common@2:true,org.eclipse.equinox.concurrent@default:default,org.eclipse.equinox.console@default:default,org.eclipse.equinox.ds@1:true,org.eclipse.equinox.event@default:default,org.eclipse.equinox.preferences@default:default,org.eclipse.equinox.registry@default:default,org.eclipse.equinox.util@default:default,org.eclipse.help@default:default,org.eclipse.jface.databinding@default:default,org.eclipse.jface.text@default:default,org.eclipse.jface@default:default,org.eclipse.osgi.compatibility.state@default:false,org.eclipse.osgi.services@default:default,org.eclipse.osgi@-1:true,org.eclipse.swt.cocoa.macosx.x86_64@default:false,org.eclipse.swt@default:default,org.eclipse.team.core@default:default,org.eclipse.text@default:default,org.eclipse.ui.cocoa@default:false,org.eclipse.ui.console@default:default,org.eclipse.ui.trace@default:default,org.eclipse.ui.workbench.texteditor@default:default,org.eclipse.ui.workbench@default:default,org.eclipse.ui@default:default,org.eclipse.wb.core.lib@default:default,org.hamcrest.core@default:default,org.junit@default:default,org.w3c.css.sac@default:default,org.w3c.dom.events@default:default,org.w3c.dom.smil@default:default,org.w3c.dom.svg@default:default"/> <stringAttribute key="selected_target_plugins" value="com.google.guava@default:default,com.ibm.icu@default:default,javax.annotation@default:default,javax.inject@default:default,javax.servlet@default:default,javax.xml@default:default,org.apache.ant@default:default,org.apache.batik.css@default:default,org.apache.batik.util.gui@default:default,org.apache.batik.util@default:default,org.apache.commons.jxpath@default:default,org.apache.commons.logging@default:default,org.apache.felix.gogo.command@default:default,org.apache.felix.gogo.runtime@default:default,org.apache.felix.gogo.shell@default:default,org.codehaus.groovy@default:default,org.eclipse.ant.core@default:default,org.eclipse.compare.core@default:default,org.eclipse.core.commands@default:default,org.eclipse.core.contenttype@default:default,org.eclipse.core.databinding.beans@default:default,org.eclipse.core.databinding.observable@default:default,org.eclipse.core.databinding.property@default:default,org.eclipse.core.databinding@default:default,org.eclipse.core.expressions@default:default,org.eclipse.core.filesystem.java7@default:false,org.eclipse.core.filesystem.macosx@default:false,org.eclipse.core.filesystem@default:default,org.eclipse.core.jobs@default:default,org.eclipse.core.resources@default:default,org.eclipse.core.runtime.compatibility.registry@default:false,org.eclipse.core.runtime@default:true,org.eclipse.core.variables@default:default,org.eclipse.e4.core.commands@default:default,org.eclipse.e4.core.contexts@default:default,org.eclipse.e4.core.di.annotations@default:default,org.eclipse.e4.core.di.extensions@default:default,org.eclipse.e4.core.di@default:default,org.eclipse.e4.core.services@default:default,org.eclipse.e4.emf.xpath@default:default,org.eclipse.e4.ui.bindings@default:default,org.eclipse.e4.ui.css.core@default:default,org.eclipse.e4.ui.css.swt.theme@default:default,org.eclipse.e4.ui.css.swt@default:default,org.eclipse.e4.ui.di@default:default,org.eclipse.e4.ui.model.workbench@default:default,org.eclipse.e4.ui.services@default:default,org.eclipse.e4.ui.widgets@default:default,org.eclipse.e4.ui.workbench.addons.swt@default:default,org.eclipse.e4.ui.workbench.renderers.swt.cocoa@default:false,org.eclipse.e4.ui.workbench.renderers.swt@default:default,org.eclipse.e4.ui.workbench.swt@default:default,org.eclipse.e4.ui.workbench3@default:default,org.eclipse.e4.ui.workbench@default:default,org.eclipse.emf.common@default:default,org.eclipse.emf.ecore.change@default:default,org.eclipse.emf.ecore.xmi@default:default,org.eclipse.emf.ecore@default:default,org.eclipse.equinox.app@default:default,org.eclipse.equinox.bidi@default:default,org.eclipse.equinox.common@2:true,org.eclipse.equinox.concurrent@default:default,org.eclipse.equinox.console@default:default,org.eclipse.equinox.ds@1:true,org.eclipse.equinox.event@default:default,org.eclipse.equinox.preferences@default:default,org.eclipse.equinox.registry@default:default,org.eclipse.equinox.util@default:default,org.eclipse.help@default:default,org.eclipse.jface.databinding@default:default,org.eclipse.jface.text@default:default,org.eclipse.jface@default:default,org.eclipse.osgi.compatibility.state@default:false,org.eclipse.osgi.services@default:default,org.eclipse.osgi@-1:true,org.eclipse.swt.cocoa.macosx.x86_64@default:false,org.eclipse.swt@default:default,org.eclipse.team.core@default:default,org.eclipse.text@default:default,org.eclipse.ui.cocoa@default:false,org.eclipse.ui.console@default:default,org.eclipse.ui.workbench.texteditor@default:default,org.eclipse.ui.workbench@default:default,org.eclipse.ui@default:default,org.hamcrest.core@default:default,org.junit@default:default,org.w3c.css.sac@default:default,org.w3c.dom.events@default:default,org.w3c.dom.smil@default:default,org.w3c.dom.svg@default:default"/>
<stringAttribute key="selected_workspace_plugins" value="com.minres.scviewer.database.sqlite@default:default,com.minres.scviewer.database.swt@default:default,com.minres.scviewer.database.text@default:default,com.minres.scviewer.database.vcd@default:default,com.minres.scviewer.database@default:default,com.minres.scviewer.e4.application@default:default"/> <stringAttribute key="selected_workspace_plugins" value="com.minres.scviewer.database.sqlite@default:default,com.minres.scviewer.database.text@default:default,com.minres.scviewer.database.ui.swt@default:default,com.minres.scviewer.database.ui@default:default,com.minres.scviewer.database.vcd@default:default,com.minres.scviewer.database@default:default,com.minres.scviewer.e4.application@default:default"/>
<booleanAttribute key="show_selected_only" value="false"/> <booleanAttribute key="show_selected_only" value="false"/>
<booleanAttribute key="tracing" value="false"/> <booleanAttribute key="tracing" value="false"/>
<booleanAttribute key="useCustomFeatures" value="false"/> <booleanAttribute key="useCustomFeatures" value="false"/>

View File

@ -16,6 +16,7 @@ import java.io.File;
import java.io.IOException; import java.io.IOException;
import java.lang.reflect.InvocationTargetException; import java.lang.reflect.InvocationTargetException;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.LinkedList;
import java.util.List; import java.util.List;
import java.util.regex.Matcher; import java.util.regex.Matcher;
import java.util.regex.Pattern; import java.util.regex.Pattern;
@ -48,9 +49,10 @@ import com.minres.scviewer.database.IWaveform;
import com.minres.scviewer.database.IWaveformDb; import com.minres.scviewer.database.IWaveformDb;
import com.minres.scviewer.database.IWaveformDbFactory; import com.minres.scviewer.database.IWaveformDbFactory;
import com.minres.scviewer.database.IWaveformEvent; import com.minres.scviewer.database.IWaveformEvent;
import com.minres.scviewer.database.swt.TxDisplay; import com.minres.scviewer.database.swt.WaveformViewerFactory;
import com.minres.scviewer.database.ui.GotoDirection; import com.minres.scviewer.database.ui.GotoDirection;
import com.minres.scviewer.database.ui.IWaveformPanel; import com.minres.scviewer.database.ui.IWaveformViewer;
import com.minres.scviewer.database.ui.TrackEntry;
import com.minres.scviewer.ui.views.TxOutlinePage; import com.minres.scviewer.ui.views.TxOutlinePage;
public class TxEditorPart extends EditorPart implements ITabbedPropertySheetPageContributor { public class TxEditorPart extends EditorPart implements ITabbedPropertySheetPageContributor {
@ -77,7 +79,7 @@ public class TxEditorPart extends EditorPart implements ITabbedPropertySheetPage
public static final String WAVE_ACTION_ID = "com.minres.scviewer.ui.action.AddToWave"; public static final String WAVE_ACTION_ID = "com.minres.scviewer.ui.action.AddToWave";
private TxDisplay txDisplay; private IWaveformViewer txDisplay;
/** This is the root of the editor's model. */ /** This is the root of the editor's model. */
private IWaveformDb database; private IWaveformDb database;
@ -111,9 +113,10 @@ public class TxEditorPart extends EditorPart implements ITabbedPropertySheetPage
} }
} }
}); });
txDisplay = new TxDisplay(parent); WaveformViewerFactory factory = new WaveformViewerFactory();
txDisplay = factory.createPanel(parent);
txDisplay.setMaxTime(0); txDisplay.setMaxTime(0);
txDisplay.addPropertyChangeListener(IWaveformPanel.CURSOR_PROPERTY, new PropertyChangeListener() { txDisplay.addPropertyChangeListener(IWaveformViewer.CURSOR_PROPERTY, new PropertyChangeListener() {
@Override @Override
public void propertyChange(PropertyChangeEvent evt) { public void propertyChange(PropertyChangeEvent evt) {
Long time = (Long) evt.getNewValue(); Long time = (Long) evt.getNewValue();
@ -237,11 +240,13 @@ public class TxEditorPart extends EditorPart implements ITabbedPropertySheetPage
txDisplay.setMaxTime(database.getMaxTime()); txDisplay.setMaxTime(database.getMaxTime());
if(TxEditorPart.this.getEditorInput() instanceof TxEditorInput && if(TxEditorPart.this.getEditorInput() instanceof TxEditorInput &&
((TxEditorInput) TxEditorPart.this.getEditorInput()).getStreamNames().size()>0){ ((TxEditorInput) TxEditorPart.this.getEditorInput()).getStreamNames().size()>0){
LinkedList<TrackEntry> entries= new LinkedList<>();
for(String streamName:((TxEditorInput) TxEditorPart.this.getEditorInput()).getStreamNames()){ for(String streamName:((TxEditorInput) TxEditorPart.this.getEditorInput()).getStreamNames()){
IWaveform<? extends IWaveformEvent> stream = database.getStreamByName(streamName); IWaveform<? extends IWaveformEvent> stream = database.getStreamByName(streamName);
if(stream!=null) if(stream!=null)
txDisplay.getStreamList().add(stream); entries.add(new TrackEntry(stream));
} }
txDisplay.getStreamList().addAll(entries);
} }
} }
@ -331,9 +336,9 @@ public class TxEditorPart extends EditorPart implements ITabbedPropertySheetPage
public void addStreamToList(IWaveform<? extends IWaveformEvent> obj){ public void addStreamToList(IWaveform<? extends IWaveformEvent> obj){
if(getEditorInput() instanceof TxEditorInput && !((TxEditorInput) getEditorInput()).getStreamNames().contains(obj.getFullName())){ if(getEditorInput() instanceof TxEditorInput && !((TxEditorInput) getEditorInput()).getStreamNames().contains(obj.getFullName())){
((TxEditorInput) getEditorInput()).getStreamNames().add(obj.getFullName()); ((TxEditorInput) getEditorInput()).getStreamNames().add(obj.getFullName());
txDisplay.getStreamList().add(obj); txDisplay.getStreamList().add(new TrackEntry(obj));
} else } else
txDisplay.getStreamList().add(obj); txDisplay.getStreamList().add(new TrackEntry(obj));
} }
@ -355,7 +360,7 @@ public class TxEditorPart extends EditorPart implements ITabbedPropertySheetPage
removeStreamFromList(stream); removeStreamFromList(stream);
} }
public List<IWaveform<? extends IWaveformEvent>> getStreamList(){ public List<TrackEntry> getStreamList(){
return txDisplay.getStreamList(); return txDisplay.getStreamList();
} }