added combined bit vectors
This commit is contained in:
1 parent
a4215fceb1
commit
42e0d83403
17 files changed
+1066
-14
No files matched your search
+44
@@ -0,0 +1,44 @@
|
||||
/*******************************************************************************
|
||||
* Copyright (c) 2026 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.List;
|
||||
import com.minres.scviewer.database.BitVector;
|
||||
import com.minres.scviewer.database.CombinedBitVectorWaveform.SourceBit;
|
||||
import com.minres.scviewer.database.EventEntry;
|
||||
import com.minres.scviewer.database.WaveformType;
|
||||
|
||||
/** Selection and source normalization shared by the combine action and viewer. */
|
||||
public final class BitVectorComposition {
|
||||
private BitVectorComposition() { }
|
||||
|
||||
public static boolean isSingleBit(TrackEntry track) {
|
||||
if (track.waveform == null || track.waveform.getType() != WaveformType.SIGNAL
|
||||
|| track.waveform.getWidth() != 1) return false;
|
||||
EventEntry first = track.waveform.getEvents().firstEntry();
|
||||
return first == null || (first.events != null && first.events.length > 0
|
||||
&& first.events[first.events.length - 1] instanceof BitVector);
|
||||
}
|
||||
|
||||
public static List<TrackEntry> selectedBits(List<TrackEntry> roots, List<TrackEntry> selection) {
|
||||
List<TrackEntry> ordered = TrackEntry.visibleTracks(roots).stream()
|
||||
.filter(track -> selection.stream().anyMatch(selected -> selected == track)).toList();
|
||||
return ordered.size() >= 2 && ordered.size() == selection.size() && ordered.stream().allMatch(BitVectorComposition::isSingleBit)
|
||||
? ordered : List.of();
|
||||
}
|
||||
|
||||
public static List<SourceBit> sources(List<TrackEntry> tracks) {
|
||||
if (tracks.size() < 2 || !tracks.stream().allMatch(BitVectorComposition::isSingleBit))
|
||||
throw new IllegalArgumentException("Select at least two single-bit signals");
|
||||
return tracks.stream().map(track -> track.waveform instanceof BitWaveform bit
|
||||
? new SourceBit(bit.getSource(), bit.getBitIndex()) : new SourceBit(track.waveform, 0)).toList();
|
||||
}
|
||||
}
|
||||
+3
@@ -38,6 +38,9 @@ public final class BitWaveform extends HierNode implements IWaveform {
|
||||
}
|
||||
|
||||
@Override public String getFullName() { return source.getFullName() + getName(); }
|
||||
@Override public String getDisplayName() { return source.getDisplayName() + getName(); }
|
||||
public IWaveform getSource() { return source; }
|
||||
public int getBitIndex() { return bit; }
|
||||
@Override public DirectionType getDirection() { return source.getDirection(); }
|
||||
@Override public long getId() { return source.getId(); }
|
||||
@Override public WaveformType getType() { return WaveformType.SIGNAL; }
|
||||
|
||||
+2
-2
@@ -648,7 +648,7 @@ public class WaveformView implements IWaveformView {
|
||||
for (TrackEntry entry : TrackEntry.visibleTracks(streams)) {
|
||||
addPainter(even, entry);
|
||||
trackVerticalOffset.put(tracksVerticalHeight, entry);
|
||||
tl.setText(entry.waveform.getFullName());
|
||||
tl.setText(entry.waveform.getDisplayName());
|
||||
nameMaxWidth = Math.max(nameMaxWidth, tl.getBounds().width + nameIndent(entry)
|
||||
+ (entry.hierState == HierState.NONE && nameIndent(entry) == 0 ? 5 : 18));
|
||||
tracksVerticalHeight += entry.height;
|
||||
@@ -1261,7 +1261,7 @@ public class WaveformView implements IWaveformView {
|
||||
protected void drawName(GC gc, Rectangle subArea, Integer firstKey, TrackEntry entry) {
|
||||
IWaveform w = entry.waveform;
|
||||
subArea.height = w.getRowCount() * styleProvider.getTrackHeight();
|
||||
drawTextFormat(gc, subArea, firstKey, w.getFullName(), entry.selected, entry.hierState, nameIndent(entry));
|
||||
drawTextFormat(gc, subArea, firstKey, w.getDisplayName(), entry.selected, entry.hierState, nameIndent(entry));
|
||||
}
|
||||
|
||||
protected void drawValue(GC gc, Rectangle subArea, Integer yOffset, String value, boolean highlite) {
|
||||
|
||||
Reference in new issue
Block a user