adds rendering of hierarchy indicator
This commit is contained in:
parent
d657843541
commit
3890a87a8c
|
@ -11,12 +11,17 @@
|
||||||
package com.minres.scviewer.database.ui;
|
package com.minres.scviewer.database.ui;
|
||||||
|
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import com.minres.scviewer.database.EmptyWaveform;
|
||||||
import com.minres.scviewer.database.IWaveform;
|
import com.minres.scviewer.database.IWaveform;
|
||||||
|
|
||||||
public class TrackEntry {
|
public class TrackEntry {
|
||||||
|
public enum HierState {
|
||||||
|
NONE, CLOSED, OPENED
|
||||||
|
}
|
||||||
|
|
||||||
IWaveformStyleProvider styleProvider;
|
|
||||||
|
|
||||||
public enum ValueDisplay {
|
public enum ValueDisplay {
|
||||||
DEFAULT, BINARY, SIGNED, UNSIGNED
|
DEFAULT, BINARY, SIGNED, UNSIGNED
|
||||||
|
|
||||||
|
@ -26,28 +31,45 @@ public class TrackEntry {
|
||||||
DEFAULT, STEP_WISE, CONTINOUS
|
DEFAULT, STEP_WISE, CONTINOUS
|
||||||
}
|
}
|
||||||
|
|
||||||
|
IWaveformStyleProvider styleProvider = null;
|
||||||
|
|
||||||
final public IWaveform waveform;
|
final public IWaveform waveform;
|
||||||
|
|
||||||
public int vOffset;
|
public int vOffset=0;
|
||||||
|
|
||||||
public int height;
|
public int height=0;
|
||||||
|
|
||||||
public boolean selected;
|
public boolean selected=false;
|
||||||
|
|
||||||
|
public HierState hierState=HierState.NONE;
|
||||||
|
|
||||||
|
public List<TrackEntry> waveforms = new ArrayList<>();
|
||||||
|
|
||||||
public String currentValue="";
|
public String currentValue="";
|
||||||
|
|
||||||
public ValueDisplay valueDisplay = ValueDisplay.DEFAULT;
|
public ValueDisplay valueDisplay = ValueDisplay.DEFAULT;
|
||||||
|
|
||||||
public WaveDisplay waveDisplay = WaveDisplay.DEFAULT;
|
public WaveDisplay waveDisplay = WaveDisplay.DEFAULT;
|
||||||
|
|
||||||
|
public TrackEntry() {
|
||||||
|
this.waveform = null;
|
||||||
|
this.styleProvider=null;
|
||||||
|
}
|
||||||
|
|
||||||
public TrackEntry(IWaveform waveform, IWaveformStyleProvider styleProvider) {
|
public TrackEntry(IWaveform waveform, IWaveformStyleProvider styleProvider) {
|
||||||
this.waveform = waveform;
|
this.waveform = waveform;
|
||||||
this.styleProvider=styleProvider;
|
this.styleProvider=styleProvider;
|
||||||
vOffset=0;
|
this.hierState = (waveform!=null && waveform.getChildNodes().size()>0)?HierState.CLOSED:HierState.NONE;
|
||||||
height=0;
|
|
||||||
selected=false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public TrackEntry(TrackEntry[] waveform, IWaveformStyleProvider styleProvider) {
|
||||||
|
this(new EmptyWaveform(), styleProvider);
|
||||||
|
this.hierState = HierState.CLOSED;
|
||||||
|
for (TrackEntry iWaveform : waveform) {
|
||||||
|
waveforms.add(iWaveform);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean equals(Object obj) {
|
public boolean equals(Object obj) {
|
||||||
if(obj instanceof TrackEntry){
|
if(obj instanceof TrackEntry){
|
||||||
|
@ -56,4 +78,5 @@ public class TrackEntry {
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
|
@ -1,32 +0,0 @@
|
||||||
/*******************************************************************************
|
|
||||||
* Copyright (c) 2015-2023 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 java.util.ArrayList;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import com.minres.scviewer.database.EmptyWaveform;
|
|
||||||
|
|
||||||
public class TrackEntryGroup extends TrackEntry {
|
|
||||||
|
|
||||||
public List<TrackEntry> waveforms = new ArrayList<>();
|
|
||||||
|
|
||||||
public Boolean is_open = true;
|
|
||||||
|
|
||||||
public TrackEntryGroup(TrackEntry[] waveform, IWaveformStyleProvider styleProvider) {
|
|
||||||
super(new EmptyWaveform(), styleProvider);
|
|
||||||
for (TrackEntry iWaveform : waveform) {
|
|
||||||
waveforms.add(iWaveform);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -91,7 +91,6 @@ import com.minres.scviewer.database.ui.IWaveformView;
|
||||||
import com.minres.scviewer.database.ui.IWaveformZoom;
|
import com.minres.scviewer.database.ui.IWaveformZoom;
|
||||||
import com.minres.scviewer.database.ui.IWaveformviewEventListener;
|
import com.minres.scviewer.database.ui.IWaveformviewEventListener;
|
||||||
import com.minres.scviewer.database.ui.TrackEntry;
|
import com.minres.scviewer.database.ui.TrackEntry;
|
||||||
import com.minres.scviewer.database.ui.TrackEntryGroup;
|
|
||||||
import com.minres.scviewer.database.ui.swt.internal.slider.ZoomBar;
|
import com.minres.scviewer.database.ui.swt.internal.slider.ZoomBar;
|
||||||
|
|
||||||
public class WaveformView implements IWaveformView {
|
public class WaveformView implements IWaveformView {
|
||||||
|
@ -589,9 +588,8 @@ public class WaveformView implements IWaveformView {
|
||||||
TextLayout tl = new TextLayout(waveformCanvas.getDisplay());
|
TextLayout tl = new TextLayout(waveformCanvas.getDisplay());
|
||||||
tl.setFont(styleProvider.getNameFont());
|
tl.setFont(styleProvider.getNameFont());
|
||||||
for (TrackEntry streamEntry : streams) {
|
for (TrackEntry streamEntry : streams) {
|
||||||
if(streamEntry instanceof TrackEntryGroup && ((TrackEntryGroup)streamEntry).is_open) {
|
if(streamEntry.hierState == TrackEntry.HierState.OPENED) {
|
||||||
TrackEntryGroup streamEntryGroup = (TrackEntryGroup)streamEntry;
|
for (TrackEntry trackEntry : streamEntry.waveforms) {
|
||||||
for (TrackEntry trackEntry : streamEntryGroup.waveforms) {
|
|
||||||
addPainter(even, trackEntry);
|
addPainter(even, trackEntry);
|
||||||
trackVerticalOffset.put(tracksVerticalHeight, trackEntry);
|
trackVerticalOffset.put(tracksVerticalHeight, trackEntry);
|
||||||
tl.setText(trackEntry.waveform.getFullName());
|
tl.setText(trackEntry.waveform.getFullName());
|
||||||
|
@ -1140,19 +1138,11 @@ public class WaveformView implements IWaveformView {
|
||||||
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, styleProvider.getTrackHeight());
|
Rectangle subArea = new Rectangle(rect.x, 0, rect.width, styleProvider.getTrackHeight());
|
||||||
if (lastKey.equals(firstKey)) {
|
if (lastKey.equals(firstKey)) {
|
||||||
TrackEntry trackEntry = trackVerticalOffset.get(firstKey);
|
drawName(gc, subArea, firstKey, trackVerticalOffset.get(firstKey));
|
||||||
IWaveform w = trackEntry.waveform;
|
|
||||||
if (w.getType() == WaveformType.TRANSACTION)
|
|
||||||
subArea.height *= w.getRowCount();
|
|
||||||
drawTextFormat(gc, subArea, firstKey, w.getFullName(), trackEntry.selected);
|
|
||||||
} else {
|
} else {
|
||||||
for (Entry<Integer, TrackEntry> entry : trackVerticalOffset.subMap(firstKey, true, lastKey, true)
|
for (Entry<Integer, TrackEntry> entry : trackVerticalOffset.subMap(firstKey, true, lastKey, true)
|
||||||
.entrySet()) {
|
.entrySet()) {
|
||||||
IWaveform w = entry.getValue().waveform;
|
drawName(gc, subArea, entry.getKey(), entry.getValue());
|
||||||
subArea.height = styleProvider.getTrackHeight();
|
|
||||||
if (w.getType() == WaveformType.TRANSACTION)
|
|
||||||
subArea.height *= w.getRowCount();
|
|
||||||
drawTextFormat(gc, subArea, entry.getKey(), w.getFullName(), entry.getValue().selected);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (NoSuchElementException e) {
|
} catch (NoSuchElementException e) {
|
||||||
|
@ -1190,6 +1180,13 @@ public class WaveformView implements IWaveformView {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void drawName(GC gc, Rectangle subArea, Integer firstKey, TrackEntry entry) {
|
||||||
|
IWaveform w = entry.waveform;
|
||||||
|
if (w.getType() == WaveformType.TRANSACTION)
|
||||||
|
subArea.height *= w.getRowCount();
|
||||||
|
drawTextFormat(gc, subArea, firstKey, w.getFullName(), entry.selected, entry.hierState);
|
||||||
|
}
|
||||||
|
|
||||||
protected void drawValue(GC gc, Rectangle subArea, Integer yOffset, String value, boolean highlite) {
|
protected void drawValue(GC gc, Rectangle subArea, Integer yOffset, String value, boolean highlite) {
|
||||||
int beginIndex = 0;
|
int beginIndex = 0;
|
||||||
for (int offset = 0; offset < subArea.height; offset += styleProvider.getTrackHeight()) {
|
for (int offset = 0; offset < subArea.height; offset += styleProvider.getTrackHeight()) {
|
||||||
|
@ -1202,7 +1199,12 @@ public class WaveformView implements IWaveformView {
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void drawTextFormat(GC gc, Rectangle subArea, int yOffset, String value, boolean highlite) {
|
protected void drawTextFormat(GC gc, Rectangle subArea, int yOffset, String value, boolean highlite) {
|
||||||
|
drawTextFormat(gc, subArea, yOffset, value, highlite, TrackEntry.HierState.NONE);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void drawTextFormat(GC gc, Rectangle subArea, int yOffset, String value, boolean highlite, TrackEntry.HierState state) {
|
||||||
Point size = gc.textExtent(value);
|
Point size = gc.textExtent(value);
|
||||||
|
int height = styleProvider.getTrackHeight();
|
||||||
if (highlite) {
|
if (highlite) {
|
||||||
gc.setBackground(SWTResourceManager.getColor(SWT.COLOR_LIST_SELECTION));
|
gc.setBackground(SWTResourceManager.getColor(SWT.COLOR_LIST_SELECTION));
|
||||||
gc.setForeground(SWTResourceManager.getColor(SWT.COLOR_LIST_SELECTION_TEXT));
|
gc.setForeground(SWTResourceManager.getColor(SWT.COLOR_LIST_SELECTION_TEXT));
|
||||||
|
@ -1213,7 +1215,14 @@ public class WaveformView implements IWaveformView {
|
||||||
gc.setForeground(namePaneHeader.getForeground());
|
gc.setForeground(namePaneHeader.getForeground());
|
||||||
gc.setFont(styleProvider.getNameFont());
|
gc.setFont(styleProvider.getNameFont());
|
||||||
}
|
}
|
||||||
gc.drawText(value, subArea.x + 5, subArea.y + yOffset + (styleProvider.getTrackHeight() - size.y) / 2, true);
|
if(state==TrackEntry.HierState.NONE) {
|
||||||
|
gc.drawText(value, subArea.x + 5, subArea.y + yOffset + (height - size.y) / 2, true);
|
||||||
|
} else {
|
||||||
|
gc.setBackground(highlite?SWTResourceManager.getColor(SWT.COLOR_LIST_SELECTION_TEXT):namePaneHeader.getForeground());
|
||||||
|
gc.fillPolygon(new int[]{3, yOffset+(height-10)/2, 10, yOffset+height/2, 3, yOffset+(height+10)/2});
|
||||||
|
Rectangle textArea = new Rectangle(subArea.x+12, subArea.y, subArea.width-12, subArea.height);
|
||||||
|
gc.drawText(value, textArea.x + 5, subArea.y + yOffset + (height - size.y) / 2, true);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setHighliteRelation(RelationType relationType) {
|
public void setHighliteRelation(RelationType relationType) {
|
||||||
|
|
|
@ -34,7 +34,7 @@ public class WaveformPopupMenuContribution {
|
||||||
|
|
||||||
@Inject MPart activePart;
|
@Inject MPart activePart;
|
||||||
|
|
||||||
final TrackEntry nullEntry = new TrackEntry(null, null);
|
final TrackEntry nullEntry = new TrackEntry();
|
||||||
|
|
||||||
private boolean selHasBitVector(ISelection sel, boolean checkForDouble) {
|
private boolean selHasBitVector(ISelection sel, boolean checkForDouble) {
|
||||||
if(!sel.isEmpty() && sel instanceof IStructuredSelection) {
|
if(!sel.isEmpty() && sel instanceof IStructuredSelection) {
|
||||||
|
|
Loading…
Reference in New Issue