From 701733e69d05ade7b4efd64f1358b4f9313353c0 Mon Sep 17 00:00:00 2001 From: Eyck Jentzsch Date: Fri, 15 Mar 2019 08:50:12 +0100 Subject: [PATCH 1/4] Updated version numbers and display in about dialog --- com.minres.scviewer.e4.application/META-INF/MANIFEST.MF | 2 +- com.minres.scviewer.e4.application/pom.xml | 2 +- .../minres/scviewer/e4/application/messages.properties | 4 ++-- .../minres/scviewer/e4/application/parts/AboutDialog.java | 8 +++++++- com.minres.scviewer.e4.product/pom.xml | 2 +- com.minres.scviewer.e4.product/scviewer.product | 2 +- 6 files changed, 13 insertions(+), 7 deletions(-) diff --git a/com.minres.scviewer.e4.application/META-INF/MANIFEST.MF b/com.minres.scviewer.e4.application/META-INF/MANIFEST.MF index 0d9c4c9..0e1400a 100644 --- a/com.minres.scviewer.e4.application/META-INF/MANIFEST.MF +++ b/com.minres.scviewer.e4.application/META-INF/MANIFEST.MF @@ -2,7 +2,7 @@ Manifest-Version: 1.0 Bundle-ManifestVersion: 2 Bundle-Name: %Bundle-Name Bundle-SymbolicName: com.minres.scviewer.e4.application;singleton:=true -Bundle-Version: 2.0.2.qualifier +Bundle-Version: 2.0.4.qualifier Bundle-Vendor: %Bundle-Vendor Require-Bundle: javax.inject;bundle-version="1.0.0", org.eclipse.core.runtime;bundle-version="3.11.1", diff --git a/com.minres.scviewer.e4.application/pom.xml b/com.minres.scviewer.e4.application/pom.xml index 58c79e5..cd58a3e 100644 --- a/com.minres.scviewer.e4.application/pom.xml +++ b/com.minres.scviewer.e4.application/pom.xml @@ -1,7 +1,7 @@ 4.0.0 com.minres.scviewer.e4.application - 2.0.2-SNAPSHOT + 2.0.4-SNAPSHOT com.minres.scviewer com.minres.scviewer.parent diff --git a/com.minres.scviewer.e4.application/src/com/minres/scviewer/e4/application/messages.properties b/com.minres.scviewer.e4.application/src/com/minres/scviewer/e4/application/messages.properties index 5485315..c5e0081 100644 --- a/com.minres.scviewer.e4.application/src/com/minres/scviewer/e4/application/messages.properties +++ b/com.minres.scviewer.e4.application/src/com/minres/scviewer/e4/application/messages.properties @@ -1,5 +1,5 @@ -AboutDialog_0=\nSCViewer - a SystemC waveform viewer\n\nVersion: 2.0\n -AboutDialog_1=\nCopyright (c) 2015, 2018 MINRES Technologies GmbH and others.\n\nAll rights reserved. MINRES and the MINRES logo are trademarks of MINRES Technologies GmbH, http://www.minres.com/. 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\n\nParts of the software are governed by the Apache License Version 2.0 available at http://www.apache.org/licenses/. These are namely org.mapdb and org.sqlite JDBC driver\n\nSource code is hosted at https://git.minres.com/VP/SCViewer and the master branch is mirrored to GitHub: https://git.com/minres/SCViewer\n +AboutDialog_0=\nSCViewer - a SystemC waveform viewer\n\nVersion: {0}\n +AboutDialog_1=\nCopyright (c) 2015, 2019 MINRES Technologies GmbH and others.\n\nAll rights reserved. MINRES and the MINRES logo are trademarks of MINRES Technologies GmbH, http://www.minres.com/. 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\n\nParts of the software are governed by the Apache License Version 2.0 available at http://www.apache.org/licenses/. These are namely org.mapdb and org.sqlite JDBC driver\n\nSource code is hosted at https://git.minres.com/VP/SCViewer and the master branch is mirrored to GitHub: https://git.com/minres/SCViewer\n DesignBrowser_12=Append all after DesignBrowser_16=Insert all before DesignBrowser_2=Enter text to filter waveforms diff --git a/com.minres.scviewer.e4.application/src/com/minres/scviewer/e4/application/parts/AboutDialog.java b/com.minres.scviewer.e4.application/src/com/minres/scviewer/e4/application/parts/AboutDialog.java index 691e378..b832f0b 100644 --- a/com.minres.scviewer.e4.application/src/com/minres/scviewer/e4/application/parts/AboutDialog.java +++ b/com.minres.scviewer.e4.application/src/com/minres/scviewer/e4/application/parts/AboutDialog.java @@ -19,8 +19,10 @@ import java.util.regex.Pattern; import javax.annotation.PostConstruct; import javax.inject.Inject; +import org.eclipse.core.runtime.Platform; import org.eclipse.jface.dialogs.Dialog; import org.eclipse.jface.dialogs.IDialogConstants; +import org.eclipse.osgi.util.NLS; import org.eclipse.swt.SWT; import org.eclipse.swt.custom.StyleRange; import org.eclipse.swt.custom.StyledText; @@ -39,6 +41,7 @@ import org.eclipse.swt.widgets.Listener; import org.eclipse.swt.widgets.Shell; import org.eclipse.wb.swt.ResourceManager; import org.eclipse.wb.swt.SWTResourceManager; +import org.osgi.framework.Version; import com.minres.scviewer.e4.application.Messages; @@ -101,7 +104,10 @@ public class AboutDialog extends Dialog { styledText.setEditable(false); GridData gd_styledText = new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1); styledText.setLayoutData(gd_styledText); - styledText.setText(productTitle+copyrightText); + Version version = Platform.getProduct().getDefiningBundle().getVersion(); + String versionString = String.format("%d.%d.%d", version.getMajor(), version.getMinor(), version.getMicro()); + String pt = NLS.bind(Messages.AboutDialog_0, versionString); + styledText.setText(pt+copyrightText); styledText.setBackground(white); styledText.setWordWrap(true); styledText.setLeftMargin(5); diff --git a/com.minres.scviewer.e4.product/pom.xml b/com.minres.scviewer.e4.product/pom.xml index a3cc935..e196163 100644 --- a/com.minres.scviewer.e4.product/pom.xml +++ b/com.minres.scviewer.e4.product/pom.xml @@ -10,7 +10,7 @@ ../com.minres.scviewer.parent com.minres.scviewer.e4.product - 2.0.2-SNAPSHOT + 2.0.4-SNAPSHOT eclipse-repository com.minres.scviewer diff --git a/com.minres.scviewer.e4.product/scviewer.product b/com.minres.scviewer.e4.product/scviewer.product index fe82252..bd763f1 100644 --- a/com.minres.scviewer.e4.product/scviewer.product +++ b/com.minres.scviewer.e4.product/scviewer.product @@ -1,7 +1,7 @@ - + From 73e952faea0581f39a8de628136442a49634a5f9 Mon Sep 17 00:00:00 2001 From: Brita Keller Date: Sun, 17 Mar 2019 20:03:22 +0100 Subject: [PATCH 2/4] Fixed #11 - No more display problems in waveforms when zooming in and scrolling --- .../database/swt/internal/ArrowPainter.java | 18 +++-- .../database/swt/internal/CursorPainter.java | 24 +++++-- .../database/swt/internal/RulerPainter.java | 30 ++++---- .../database/swt/internal/SignalPainter.java | 72 ++++++++++++------- .../database/swt/internal/StreamPainter.java | 22 ++++-- .../database/swt/internal/WaveformCanvas.java | 32 +++++---- .../database/swt/internal/WaveformViewer.java | 4 +- 7 files changed, 132 insertions(+), 70 deletions(-) diff --git a/com.minres.scviewer.database.ui.swt/src/com/minres/scviewer/database/swt/internal/ArrowPainter.java b/com.minres.scviewer.database.ui.swt/src/com/minres/scviewer/database/swt/internal/ArrowPainter.java index 4834914..04dcbca 100644 --- a/com.minres.scviewer.database.ui.swt/src/com/minres/scviewer/database/swt/internal/ArrowPainter.java +++ b/com.minres.scviewer.database.ui.swt/src/com/minres/scviewer/database/swt/internal/ArrowPainter.java @@ -46,6 +46,8 @@ public class ArrowPainter implements IPainter { private RelationType highlightType; + private long selectionOffset; + long scaleFactor; boolean deferredUpdate; @@ -87,8 +89,9 @@ public class ArrowPainter implements IPainter { deferredUpdate = true; return; } + selectionOffset = waveCanvas.getXOffset(); int laneHeight = painter.getHeight() / stream.getMaxConcurrency(); - txRectangle = new Rectangle((int) (tx.getBeginTime() / scaleFactor), + txRectangle = new Rectangle((int) (tx.getBeginTime() / scaleFactor-waveCanvas.getXOffset()), waveCanvas.rulerHeight + painter.getVerticalOffset() + laneHeight * tx.getConcurrencyIndex(), (int) ((tx.getEndTime() - tx.getBeginTime()) / scaleFactor), laneHeight); deriveGeom(tx.getIncomingRelations(), iRect, false); @@ -102,7 +105,7 @@ public class ArrowPainter implements IPainter { ITxStream stream = otherTx.getStream(); IWaveformPainter painter = waveCanvas.wave2painterMap.get(stream); int laneHeight = painter.getHeight() / stream.getMaxConcurrency(); - Rectangle bb = new Rectangle((int) (otherTx.getBeginTime() / scaleFactor), + Rectangle bb = new Rectangle((int) (otherTx.getBeginTime() / scaleFactor-waveCanvas.getXOffset()), waveCanvas.rulerHeight + painter.getVerticalOffset() + laneHeight * otherTx.getConcurrencyIndex(), (int) ((otherTx.getEndTime() - otherTx.getBeginTime()) / scaleFactor), laneHeight); @@ -120,14 +123,19 @@ public class ArrowPainter implements IPainter { scaleFactor = waveCanvas.getScaleFactor(); calculateGeometries(); } + if(txRectangle == null) return; + int correctionValue = (int)(selectionOffset - waveCanvas.getXOffset()); + Rectangle correctedTargetRectangle = new Rectangle(txRectangle.x+correctionValue, txRectangle.y, txRectangle.width, txRectangle.height); for (LinkEntry entry : iRect) { + Rectangle correctedRectangle = new Rectangle(entry.rectangle.x+correctionValue, entry.rectangle.y, entry.rectangle.width, entry.rectangle.height); Point target = drawPath(gc, highlightType.equals(entry.relationType) ? highliteColor : fgColor, - entry.rectangle, txRectangle); + correctedRectangle, correctedTargetRectangle); drawArrow(gc, target); } for (LinkEntry entry : oRect) { - Point target = drawPath(gc, highlightType.equals(entry.relationType) ? highliteColor : fgColor, txRectangle, - entry.rectangle); + Rectangle correctedRectangle = new Rectangle(entry.rectangle.x+correctionValue, entry.rectangle.y, entry.rectangle.width, entry.rectangle.height); + Point target = drawPath(gc, highlightType.equals(entry.relationType) ? highliteColor : fgColor, correctedTargetRectangle, + correctedRectangle); drawArrow(gc, target); } } diff --git a/com.minres.scviewer.database.ui.swt/src/com/minres/scviewer/database/swt/internal/CursorPainter.java b/com.minres.scviewer.database.ui.swt/src/com/minres/scviewer/database/swt/internal/CursorPainter.java index ac0e528..a23e8c2 100644 --- a/com.minres.scviewer.database.ui.swt/src/com/minres/scviewer/database/swt/internal/CursorPainter.java +++ b/com.minres.scviewer.database.ui.swt/src/com/minres/scviewer/database/swt/internal/CursorPainter.java @@ -30,6 +30,11 @@ public class CursorPainter implements IPainter, ICursor { public final int id; + /// maximum visible canvas position in canvas coordinates + int maxPosX; + /// maximum visible position in waveform coordinates + int maxValX; + /** * @param i * @param txDisplay @@ -56,23 +61,32 @@ public class CursorPainter implements IPainter, ICursor { this.isDragging = isDragging; } + public void paintArea(GC gc, Rectangle area) { if(this.waveCanvas.painterList.size()>0){ + long scaleFactor=waveCanvas.getScaleFactor(); + long beginPos = area.x; + + maxPosX = area.x + area.width; + maxValX = maxPosX + (int)waveCanvas.getXOffset(); + + // x position of marker in pixels on canvas int x = (int) (time/scaleFactor); + // distance of marker from the top of Canvas' painting area int top = id<0?area.y:area.y+15; + Color drawColor=waveCanvas.colors[id<0?WaveformColors.CURSOR.ordinal():WaveformColors.MARKER.ordinal()]; Color dragColor = waveCanvas.colors[WaveformColors.CURSOR_DRAG.ordinal()]; Color textColor=waveCanvas.colors[id<0?WaveformColors.CURSOR_TEXT.ordinal():WaveformColors.MARKER_TEXT.ordinal()]; - if(x>=area.x && x<=(area.x+area.width)){ + if(x>=beginPos && x<=maxValX){ gc.setForeground(isDragging?dragColor:drawColor); - gc.drawLine(x, top, x, area.y+area.height); + gc.drawLine(x-(int)waveCanvas.getXOffset(), top, x-(int)waveCanvas.getXOffset(), area.y+area.height); gc.setBackground(drawColor); gc.setForeground(textColor); Double dTime=new Double(time); - gc.drawText((dTime/waveCanvas.getScaleFactorPow10())+waveCanvas.getUnitStr(), x+1, top); + gc.drawText((dTime/waveCanvas.getScaleFactorPow10())+waveCanvas.getUnitStr(), x+1-(int)waveCanvas.getXOffset(), top); } } - } - + } } \ No newline at end of file diff --git a/com.minres.scviewer.database.ui.swt/src/com/minres/scviewer/database/swt/internal/RulerPainter.java b/com.minres.scviewer.database.ui.swt/src/com/minres/scviewer/database/swt/internal/RulerPainter.java index b629632..96cee3b 100644 --- a/com.minres.scviewer.database.ui.swt/src/com/minres/scviewer/database/swt/internal/RulerPainter.java +++ b/com.minres.scviewer.database.ui.swt/src/com/minres/scviewer/database/swt/internal/RulerPainter.java @@ -32,6 +32,7 @@ public class RulerPainter implements IPainter { @Override public void paintArea(GC gc, Rectangle area) { + Color headerFgColor=waveCanvas.getDisplay().getSystemColor(SWT.COLOR_WIDGET_FOREGROUND); if(headerFgColor.isDisposed()) headerFgColor=SWTResourceManager.getColor(0,0,0); @@ -41,9 +42,11 @@ public class RulerPainter implements IPainter { String unit=waveCanvas.getUnitStr(); int unitMultiplier=waveCanvas.getUnitMultiplier(); long scaleFactor=waveCanvas.getScaleFactor(); -// long zoomLevel = waveCanvas.getZoomLevel(); - long start=area.x*scaleFactor; - long end=start+area.width*scaleFactor; + + long startPos=area.x*scaleFactor; + long startVal=startPos + waveCanvas.getXOffset()*scaleFactor; + long endPos=startPos+area.width*scaleFactor; + long endVal=startVal+area.width*scaleFactor; long rulerTickMinor = rulerTickMinorC*scaleFactor; long rulerTickMajor = rulerTickMajorC*scaleFactor; @@ -54,9 +57,9 @@ public class RulerPainter implements IPainter { int baselineY=waveCanvas.rulerHeight - 1; int bottom=waveCanvas.rulerHeight - 2; - long startMinorIncr = start; - long modulo = start % rulerTickMinor; - startMinorIncr+=rulerTickMinor-modulo; + long modulo = startVal % rulerTickMinor; + long startMinorIncrPos = startPos+rulerTickMinor-modulo; + long startMinorIncrVal = startVal+rulerTickMinor-modulo; gc.setBackground(waveCanvas.getDisplay().getSystemColor(SWT.COLOR_WIDGET_BACKGROUND)); gc.fillRectangle(new Rectangle(area.x, area.y, area.width, waveCanvas.rulerHeight)); @@ -65,15 +68,18 @@ public class RulerPainter implements IPainter { gc.setForeground(headerFgColor); gc.drawLine(area.x, area.y+bottom, area.x+area.width, area.y+bottom); - for (long tick = startMinorIncr; tick < end; tick += rulerTickMinor) { - int x0 = (int) (tick/scaleFactor); + int x0_max = 0; + + for (long pos = startMinorIncrPos, tick = startMinorIncrVal; pos < endPos; pos+= rulerTickMinor, tick += rulerTickMinor) { + int x0_pos = (int) (pos/scaleFactor); + long x0_val = tick/scaleFactor; + x0_max = x0_pos; if ((tick % rulerTickMajor) == 0) { - gc.drawText(df.format(tick/scaleFactor*unitMultiplier)+unit, x0, area.y+textY); - gc.drawLine(x0, area.y+majorTickY, x0,area.y+ bottom); + gc.drawText(df.format(x0_val*unitMultiplier)+unit, x0_pos, area.y+textY); + gc.drawLine(x0_pos, area.y+majorTickY, x0_pos,area.y+ bottom); } else { - gc.drawLine(x0, area.y+minorTickY, x0, area.y+bottom); + gc.drawLine(x0_pos, area.y+minorTickY, x0_pos, area.y+bottom); } } - } } diff --git a/com.minres.scviewer.database.ui.swt/src/com/minres/scviewer/database/swt/internal/SignalPainter.java b/com.minres.scviewer.database.ui.swt/src/com/minres/scviewer/database/swt/internal/SignalPainter.java index d39ed81..a011541 100644 --- a/com.minres.scviewer.database.ui.swt/src/com/minres/scviewer/database/swt/internal/SignalPainter.java +++ b/com.minres.scviewer.database.ui.swt/src/com/minres/scviewer/database/swt/internal/SignalPainter.java @@ -68,18 +68,26 @@ public class SignalPainter extends TrackPainter { int yOffsetT; int yOffsetM; int yOffsetB; - int maxX; + /// maximum visible canvas position in canvas coordinates + int maxPosX; + /// maximum visible position in waveform coordinates + int maxValX; public SignalPainter(WaveformCanvas txDisplay, boolean even, TrackEntry trackEntry) { super(trackEntry, even); this.waveCanvas = txDisplay; } - private int getXEnd(long time) { + private int getXValEnd(long time) { long ltmp = time / this.waveCanvas.getScaleFactor(); - return ltmp > maxX ? maxX : (int) ltmp; + return ltmp > maxValX ? maxValX : (int) ltmp; } + private int getXPosEnd(long time) { + long ltmp = time / this.waveCanvas.getScaleFactor() - waveCanvas.getXOffset(); + return ltmp > maxPosX ? maxPosX : (int) ltmp; + } + public void paintArea(GC gc, Rectangle area) { ISignal signal = trackEntry.getSignal(); if (trackEntry.selected) @@ -88,8 +96,13 @@ public class SignalPainter extends TrackPainter { gc.setBackground(this.waveCanvas.colors[even ? WaveformColors.TRACK_BG_EVEN.ordinal() : WaveformColors.TRACK_BG_ODD.ordinal()]); gc.setFillRule(SWT.FILL_EVEN_ODD); gc.fillRectangle(area); - long beginTime = area.x * this.waveCanvas.getScaleFactor(); - long endTime = (area.x + area.width) * this.waveCanvas.getScaleFactor(); + + long scaleFactor = this.waveCanvas.getScaleFactor(); + long beginPos = area.x; + long beginTime = (beginPos + waveCanvas.getXOffset())*scaleFactor; + long endPos = beginPos + area.width; + long endTime = beginTime + area.width*scaleFactor; + Entry first = signal.getEvents().floorEntry(beginTime); Entry last = signal.getEvents().floorEntry(endTime); if (first == null) { @@ -105,14 +118,18 @@ public class SignalPainter extends TrackPainter { NavigableMap entries = signal.getEvents().subMap(first.getKey(), false, last.getKey(), true); SignalChange left = new SignalChange(first); SignalChange right = new SignalChange(entries.size() > 0 ? entries.firstEntry() : first); - maxX = area.x + area.width; + maxPosX = area.x + area.width; + maxValX = maxPosX + (int)waveCanvas.getXOffset(); yOffsetT = this.waveCanvas.getTrackHeight() / 5 + area.y; yOffsetM = this.waveCanvas.getTrackHeight() / 2 + area.y; yOffsetB = 4 * this.waveCanvas.getTrackHeight() / 5 + area.y; - int xBegin = Math.max(area.x, (int) (left.time / this.waveCanvas.getScaleFactor())); - int xEnd = Math.max(area.x, getXEnd(right.time)); + int xSigChangeBeginVal = Math.max(area.x + (int)waveCanvas.getXOffset(), (int) (left.time / this.waveCanvas.getScaleFactor())); + int xSigChangeBeginPos = area.x; + int xSigChangeEndVal = Math.max(area.x + (int)waveCanvas.getXOffset(), getXValEnd(right.time)); + int xSigChangeEndPos = Math.max(area.x, getXPosEnd(right.time)); + boolean multiple = false; - if (xEnd == xBegin) { + if (xSigChangeEndPos == xSigChangeBeginPos) { // this can trigger if // a) left == right // b) left to close to right @@ -120,30 +137,31 @@ public class SignalPainter extends TrackPainter { right.time = endTime; } else { multiple = true; - long eTime = (xBegin + 1) * this.waveCanvas.getScaleFactor(); + long eTime = (xSigChangeBeginVal + 1) * this.waveCanvas.getScaleFactor(); right.set(entries.floorEntry(eTime), endTime); right.time = eTime; } - xEnd = getXEnd(right.time); + xSigChangeEndPos = getXPosEnd(right.time); } + SignalStencil stencil = getStencil(gc, left, entries); do { - stencil.draw(gc, area, left.value, right.value, xBegin, xEnd, multiple); + stencil.draw(gc, area, left.value, right.value, xSigChangeBeginPos, xSigChangeEndPos, multiple); if (right.time >= endTime) break; left.assign(right); - xBegin = xEnd; + xSigChangeBeginPos = xSigChangeEndPos; right.set(entries.higherEntry(left.time), endTime); - xEnd = getXEnd(right.time); + xSigChangeEndPos = getXPosEnd(right.time); multiple = false; - if (xEnd == xBegin) { + if (xSigChangeEndPos == xSigChangeBeginPos) { multiple = true; - long eTime = (xBegin + 1) * this.waveCanvas.getScaleFactor(); + long eTime = (xSigChangeBeginPos + 1) * this.waveCanvas.getScaleFactor(); Entry entry = entries.floorEntry(eTime); if(entry!=null && entry.getKey()> right.time) right.set(entry, endTime); - xEnd = getXEnd(eTime); + xSigChangeEndPos = getXPosEnd(eTime); } } while (left.time < endTime); } @@ -273,14 +291,14 @@ public class SignalPainter extends TrackPainter { int yOffsetLeft = (int) ((leftVal-minVal) / range * (yOffsetB-yOffsetT)); int yOffsetRight = (int) ((rightVal-minVal) / range * (yOffsetB-yOffsetT)); if(continous) { - if (xEnd > maxX) { - gc.drawLine(xBegin, yOffsetB-yOffsetLeft, maxX, yOffsetB-yOffsetRight); + if (xEnd > maxPosX) { + gc.drawLine(xBegin, yOffsetB-yOffsetLeft, maxPosX, yOffsetB-yOffsetRight); } else { gc.drawLine(xBegin, yOffsetB-yOffsetLeft, xEnd, yOffsetB-yOffsetRight); } } else { - if (xEnd > maxX) { - gc.drawLine(xBegin, yOffsetB-yOffsetLeft, maxX, yOffsetB-yOffsetLeft); + if (xEnd > maxPosX) { + gc.drawLine(xBegin, yOffsetB-yOffsetLeft, maxPosX, yOffsetB-yOffsetLeft); } else { gc.drawLine(xBegin, yOffsetB-yOffsetLeft, xEnd, yOffsetB-yOffsetLeft); if(yOffsetRight!=yOffsetLeft) { @@ -316,8 +334,8 @@ public class SignalPainter extends TrackPainter { default: } gc.setForeground(color); - if (xEnd > maxX) { - gc.drawLine(xBegin, yOffset, maxX, yOffset); + if (xEnd > maxPosX) { + gc.drawLine(xBegin, yOffset, maxPosX, yOffset); } else { gc.drawLine(xBegin, yOffset, xEnd, yOffset); int yNext = yOffsetM; @@ -398,14 +416,14 @@ public class SignalPainter extends TrackPainter { int yOffsetLeft = (int) ((leftVal-minVal) / range * (yOffsetB-yOffsetT)); int yOffsetRight = Double.isNaN(rightVal)?yOffsetLeft:(int) ((rightVal-minVal) / range * (yOffsetB-yOffsetT)); if(continous) { - if (xEnd > maxX) { - gc.drawLine(xBegin, yOffsetB-yOffsetLeft, maxX, yOffsetB-yOffsetRight); + if (xEnd > maxPosX) { + gc.drawLine(xBegin, yOffsetB-yOffsetLeft, maxPosX, yOffsetB-yOffsetRight); } else { gc.drawLine(xBegin, yOffsetB-yOffsetLeft, xEnd, yOffsetB-yOffsetRight); } } else { - if (xEnd > maxX) { - gc.drawLine(xBegin, yOffsetB-yOffsetLeft, maxX, yOffsetB-yOffsetLeft); + if (xEnd > maxPosX) { + gc.drawLine(xBegin, yOffsetB-yOffsetLeft, maxPosX, yOffsetB-yOffsetLeft); } else { gc.drawLine(xBegin, yOffsetB-yOffsetLeft, xEnd, yOffsetB-yOffsetLeft); if(yOffsetRight!=yOffsetLeft) { diff --git a/com.minres.scviewer.database.ui.swt/src/com/minres/scviewer/database/swt/internal/StreamPainter.java b/com.minres.scviewer.database.ui.swt/src/com/minres/scviewer/database/swt/internal/StreamPainter.java index 81f8faf..d9e748a 100644 --- a/com.minres.scviewer.database.ui.swt/src/com/minres/scviewer/database/swt/internal/StreamPainter.java +++ b/com.minres.scviewer.database.ui.swt/src/com/minres/scviewer/database/swt/internal/StreamPainter.java @@ -57,15 +57,23 @@ public class StreamPainter extends TrackPainter{ gc.setBackground(this.waveCanvas.colors[even?WaveformColors.TRACK_BG_EVEN.ordinal():WaveformColors.TRACK_BG_ODD.ordinal()]); gc.setFillRule(SWT.FILL_EVEN_ODD); gc.fillRectangle(area); - Entry firstTx=stream.getEvents().floorEntry(area.x*waveCanvas.getScaleFactor()); - Entry lastTx=stream.getEvents().ceilingEntry((area.x+area.width)*waveCanvas.getScaleFactor()); + + long scaleFactor = this.waveCanvas.getScaleFactor(); + long beginPos = area.x; + long beginTime = (beginPos + waveCanvas.getXOffset())*scaleFactor; + long endPos = beginPos + area.width; + long endTime = beginTime + area.width*scaleFactor; + + Entry firstTx=stream.getEvents().floorEntry(beginTime); + Entry lastTx=stream.getEvents().ceilingEntry(endTime); if(firstTx==null) firstTx = stream.getEvents().firstEntry(); if(lastTx==null) lastTx=stream.getEvents().lastEntry(); gc.setFillRule(SWT.FILL_EVEN_ODD); gc.setLineStyle(SWT.LINE_SOLID); gc.setLineWidth(1); gc.setForeground(this.waveCanvas.colors[WaveformColors.LINE.ordinal()]); - for(int y1=area.y+trackHeight/2; y1)firstTx.getValue()) @@ -97,12 +105,13 @@ public class StreamPainter extends TrackPainter{ } } } - + protected void drawTx(GC gc, Rectangle area, ITx tx) { int offset = tx.getConcurrencyIndex()*this.waveCanvas.getTrackHeight(); Rectangle bb = new Rectangle( - (int)(tx.getBeginTime()/this.waveCanvas.getScaleFactor()), area.y+offset+txBase, + (int)(tx.getBeginTime()/this.waveCanvas.getScaleFactor()-waveCanvas.getXOffset()), area.y+offset+txBase, (int)((tx.getEndTime()-tx.getBeginTime())/this.waveCanvas.getScaleFactor()), txHeight); + if(bb.x+bb.widtharea.x+area.width) return; if(bb.width==0){ gc.drawLine(bb.x, bb.y, bb.x, bb.y+bb.height); @@ -110,7 +119,6 @@ public class StreamPainter extends TrackPainter{ gc.fillRectangle(bb); gc.drawRectangle(bb); } else { - // adjusting drawing width to circumvent issues in canvas algos if(bb.x < area.x) { bb.width = bb.width-(area.x-bb.x)+5; bb.x=area.x-5; @@ -121,7 +129,7 @@ public class StreamPainter extends TrackPainter{ bb_x2=area_x2+5; bb.width= bb_x2-bb.x; } - gc.fillRoundRectangle(bb.x, bb.y, bb.width, bb.height, 5, 5); + gc.fillRoundRectangle(bb.x, bb.y, bb.width, bb.height, 5, 5); gc.drawRoundRectangle(bb.x, bb.y, bb.width, bb.height, 5, 5); } } diff --git a/com.minres.scviewer.database.ui.swt/src/com/minres/scviewer/database/swt/internal/WaveformCanvas.java b/com.minres.scviewer.database.ui.swt/src/com/minres/scviewer/database/swt/internal/WaveformCanvas.java index 0ee05df..0da478c 100644 --- a/com.minres.scviewer.database.ui.swt/src/com/minres/scviewer/database/swt/internal/WaveformCanvas.java +++ b/com.minres.scviewer.database.ui.swt/src/com/minres/scviewer/database/swt/internal/WaveformCanvas.java @@ -45,7 +45,7 @@ import com.minres.scviewer.database.ui.IWaveformViewer; import com.minres.scviewer.database.ui.TrackEntry; import com.minres.scviewer.database.ui.WaveformColors; -public class WaveformCanvas extends Canvas { +public class WaveformCanvas extends Canvas{ Color[] colors = new Color[WaveformColors.values().length]; @@ -84,13 +84,13 @@ public class WaveformCanvas extends Canvas { * Constructor for ScrollableCanvas. * * @param parent - * the parent of this control. + * the parent of this control.super(parent, style | SWT.DOUBLE_BUFFERED | SWT.NO_BACKGROUND | SWT.NO_REDRAW_RESIZE | SWT.V_SCROLL | SWT.H_SCROLL); * @param style * the style of this control. */ public WaveformCanvas(final Composite parent, int style) { super(parent, style | SWT.DOUBLE_BUFFERED | SWT.NO_BACKGROUND | SWT.NO_REDRAW_RESIZE | SWT.V_SCROLL | SWT.H_SCROLL); - addControlListener(new ControlAdapter() { /* resize listener. */ + addControlListener(new ControlAdapter() { /* resize listener. */ public void controlResized(ControlEvent event) { syncScrollBars(); } @@ -149,7 +149,11 @@ public class WaveformCanvas extends Canvas { colors[WaveformColors.REL_ARROW_HIGHLITE.ordinal()] = SWTResourceManager.getColor(255, 128, 255); } - + + public long getXOffset() { + return -origin.x; + } + public void addCursoPainter(CursorPainter cursorPainter){ painterList.add(cursorPainter); cursorPainters.add(cursorPainter); @@ -243,10 +247,11 @@ public class WaveformCanvas extends Canvas { long xoffs=xc+origin.x; // cursor offset relative to left border long xcn=tc/scaleFactor; // new total x-offset long originX=xcn-xoffs; - if(originX>0) + if(originX>0) { origin.x=(int) -originX; // new cursor time offset relative to left border - else + }else { origin.x=0; + } syncScrollBars(); arrowPainter.setTx(tx); redraw(); @@ -354,7 +359,7 @@ public class WaveformCanvas extends Canvas { return; } int height = trackAreaPainter.getHeight(); // incl. Ruler - int width = (int) (maxTime / scaleFactor); + long width = maxTime / scaleFactor; Rectangle clientArea=getClientArea(); ScrollBar horizontal = getHorizontalBar(); horizontal.setIncrement((int) (getClientArea().width / 100)); @@ -362,10 +367,11 @@ public class WaveformCanvas extends Canvas { int clientWidthw = clientArea.width; if (width > clientWidthw) { /* image is wider than client area */ horizontal.setMinimum(0); - horizontal.setMaximum(width); + horizontal.setMaximum((int)width); horizontal.setEnabled(true); - if (((int) -origin.x) > horizontal.getMaximum() - clientWidthw) + if (((int) -origin.x) > horizontal.getMaximum() - clientWidthw) { origin.x = -horizontal.getMaximum() + clientWidthw; + } } else { /* image is narrower than client area */ horizontal.setEnabled(false); } @@ -380,8 +386,9 @@ public class WaveformCanvas extends Canvas { vertical.setMinimum(0); vertical.setMaximum(height); vertical.setEnabled(true); - if (((int) -origin.y) > vertical.getMaximum() - clientHeighth) + if (((int) -origin.y) > vertical.getMaximum() - clientHeighth) { origin.y = -vertical.getMaximum() + clientHeighth; + } } else { /* image is less higher than client area */ vertical.setMaximum((int) (clientHeighth)); vertical.setEnabled(false); @@ -396,12 +403,13 @@ public class WaveformCanvas extends Canvas { /* Paint function */ private void paint(GC gc) { Rectangle clientRect = getClientArea(); /* Canvas' painting area */ - clientRect.x = -origin.x; +// clientRect.x = -origin.x; clientRect.y = -origin.y; // reset the transform transform.identity(); // shift the content - transform.translate(origin.x, origin.y); + // DO NOT SHIFT HORIZONTALLY, the range is WAY TOO BIG for float!!! + transform.translate(0, origin.y); gc.setTransform(transform); gc.setClipping(clientRect); if (painterList.size() > 0 ) { diff --git a/com.minres.scviewer.database.ui.swt/src/com/minres/scviewer/database/swt/internal/WaveformViewer.java b/com.minres.scviewer.database.ui.swt/src/com/minres/scviewer/database/swt/internal/WaveformViewer.java index 5872254..2cbfe2b 100644 --- a/com.minres.scviewer.database.ui.swt/src/com/minres/scviewer/database/swt/internal/WaveformViewer.java +++ b/com.minres.scviewer.database.ui.swt/src/com/minres/scviewer/database/swt/internal/WaveformViewer.java @@ -225,7 +225,7 @@ public class WaveformViewer implements IWaveformViewer { SashForm topSash = new SashForm(top, SWT.SMOOTH); topSash.setBackground(topSash.getDisplay().getSystemColor(SWT.COLOR_GRAY)); - + Composite composite = new Composite(topSash, SWT.NONE); composite.setLayout(new FillLayout(SWT.HORIZONTAL)); @@ -304,7 +304,7 @@ public class WaveformViewer implements IWaveformViewer { valueList.addMouseListener(nameValueMouseListener); valueListScrolled.setContent(valueList); - waveformCanvas.setMaxTime(1); + waveformCanvas.setMaxTime(1); waveformCanvas.addMouseListener(waveformMouseListener); nameListScrolled.getVerticalBar().addSelectionListener(new SelectionAdapter() { From f8765518bc9ce4acb312a2199010e24e9d12f7ac Mon Sep 17 00:00:00 2001 From: Brita Keller Date: Sun, 17 Mar 2019 20:07:19 +0100 Subject: [PATCH 3/4] Fixed #10 -all status bar parts now visible after starting program --- .../internal/status/WaveStatusBarControl.java | 21 +++++++++++-------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/com.minres.scviewer.e4.application/src/com/minres/scviewer/e4/application/internal/status/WaveStatusBarControl.java b/com.minres.scviewer.e4.application/src/com/minres/scviewer/e4/application/internal/status/WaveStatusBarControl.java index 8483068..a1c2006 100644 --- a/com.minres.scviewer.e4.application/src/com/minres/scviewer/e4/application/internal/status/WaveStatusBarControl.java +++ b/com.minres.scviewer.e4.application/src/com/minres/scviewer/e4/application/internal/status/WaveStatusBarControl.java @@ -59,7 +59,7 @@ public class WaveStatusBarControl extends StatusBarControl { final String labelString; /** The width. */ - final int width; + //final int width; /** The text. */ CLabel label, text; @@ -73,10 +73,10 @@ public class WaveStatusBarControl extends StatusBarControl { * @param labelString the label string * @param width the width */ - public TextContributionItem(String labelString, int width) { + public TextContributionItem(String labelString /*, int width */) { super(); this.labelString = labelString; - this.width=width; + //this.width=width; content=""; //$NON-NLS-1$ } @@ -85,14 +85,16 @@ public class WaveStatusBarControl extends StatusBarControl { */ @Override public void fill(Composite parent) { - Composite box=new Composite(parent, SWT.NONE); + Composite box=new Composite(parent, SWT.NONE); //NONE box.setLayout(new GridLayout(2, false)); label=new CLabel(box, SWT.SHADOW_NONE); label.setText(labelString); text=new CLabel(box, SWT.SHADOW_IN); text.setAlignment(SWT.RIGHT); + //GridData layoutData=new GridData(SWT.DEFAULT, SWT.DEFAULT, true, false); GridData layoutData=new GridData(SWT.DEFAULT, SWT.DEFAULT, true, false); - layoutData.minimumWidth=width; + layoutData.minimumWidth=70; + //layoutData.minimumWidth=width; text.setLayoutData(layoutData); } @@ -127,10 +129,11 @@ public class WaveStatusBarControl extends StatusBarControl { @Inject public WaveStatusBarControl(UISynchronize sync) { super(sync); - cursorContribution = new TextContributionItem(Messages.WaveStatusBarControl_5, 150); - markerContribution = new TextContributionItem(Messages.WaveStatusBarControl_6, 150); - markerDiffContribution = new TextContributionItem(Messages.WaveStatusBarControl_7, 150); - zoomContribution = new TextContributionItem(Messages.WaveStatusBarControl_8, 60); + + cursorContribution = new TextContributionItem(Messages.WaveStatusBarControl_5 /*, 150 */); //150 + markerContribution = new TextContributionItem(Messages.WaveStatusBarControl_6 /*, 150 */); //150 + markerDiffContribution = new TextContributionItem(Messages.WaveStatusBarControl_7 /*, 150 */); //150 + zoomContribution = new TextContributionItem(Messages.WaveStatusBarControl_8 /*, 60 */); //60 manager.appendToGroup(StatusLineManager.BEGIN_GROUP,cursorContribution); manager.appendToGroup(StatusLineManager.BEGIN_GROUP,markerContribution); manager.appendToGroup(StatusLineManager.BEGIN_GROUP,markerDiffContribution); From b5e408595bf8548ee83aca5d98975abb43c62f12 Mon Sep 17 00:00:00 2001 From: Eyck Jentzsch Date: Tue, 19 Mar 2019 19:14:39 +0100 Subject: [PATCH 4/4] Updated version numbers --- com.minres.scviewer.database.ui.swt/META-INF/MANIFEST.MF | 2 +- com.minres.scviewer.database.ui.swt/pom.xml | 1 + com.minres.scviewer.e4.application/META-INF/MANIFEST.MF | 2 +- com.minres.scviewer.e4.application/pom.xml | 2 +- com.minres.scviewer.e4.product/pom.xml | 2 +- com.minres.scviewer.e4.product/scviewer.product | 2 +- 6 files changed, 6 insertions(+), 5 deletions(-) diff --git a/com.minres.scviewer.database.ui.swt/META-INF/MANIFEST.MF b/com.minres.scviewer.database.ui.swt/META-INF/MANIFEST.MF index 26854e4..9797612 100644 --- a/com.minres.scviewer.database.ui.swt/META-INF/MANIFEST.MF +++ b/com.minres.scviewer.database.ui.swt/META-INF/MANIFEST.MF @@ -2,7 +2,7 @@ Manifest-Version: 1.0 Bundle-ManifestVersion: 2 Bundle-Name: SWT widget Bundle-SymbolicName: com.minres.scviewer.database.ui.swt -Bundle-Version: 2.0.0.qualifier +Bundle-Version: 2.0.1.qualifier Bundle-Vendor: MINRES Technologies GmbH Bundle-RequiredExecutionEnvironment: JavaSE-1.8 Require-Bundle: org.eclipse.swt;bundle-version="3.103.1", diff --git a/com.minres.scviewer.database.ui.swt/pom.xml b/com.minres.scviewer.database.ui.swt/pom.xml index 8079c8c..926a135 100644 --- a/com.minres.scviewer.database.ui.swt/pom.xml +++ b/com.minres.scviewer.database.ui.swt/pom.xml @@ -8,4 +8,5 @@ 2.0.0-SNAPSHOT ../com.minres.scviewer.parent + 2.0.1-SNAPSHOT \ No newline at end of file diff --git a/com.minres.scviewer.e4.application/META-INF/MANIFEST.MF b/com.minres.scviewer.e4.application/META-INF/MANIFEST.MF index 0e1400a..7f8023e 100644 --- a/com.minres.scviewer.e4.application/META-INF/MANIFEST.MF +++ b/com.minres.scviewer.e4.application/META-INF/MANIFEST.MF @@ -2,7 +2,7 @@ Manifest-Version: 1.0 Bundle-ManifestVersion: 2 Bundle-Name: %Bundle-Name Bundle-SymbolicName: com.minres.scviewer.e4.application;singleton:=true -Bundle-Version: 2.0.4.qualifier +Bundle-Version: 2.0.5.qualifier Bundle-Vendor: %Bundle-Vendor Require-Bundle: javax.inject;bundle-version="1.0.0", org.eclipse.core.runtime;bundle-version="3.11.1", diff --git a/com.minres.scviewer.e4.application/pom.xml b/com.minres.scviewer.e4.application/pom.xml index cd58a3e..dd10091 100644 --- a/com.minres.scviewer.e4.application/pom.xml +++ b/com.minres.scviewer.e4.application/pom.xml @@ -1,7 +1,7 @@ 4.0.0 com.minres.scviewer.e4.application - 2.0.4-SNAPSHOT + 2.0.5-SNAPSHOT com.minres.scviewer com.minres.scviewer.parent diff --git a/com.minres.scviewer.e4.product/pom.xml b/com.minres.scviewer.e4.product/pom.xml index e196163..105e1c8 100644 --- a/com.minres.scviewer.e4.product/pom.xml +++ b/com.minres.scviewer.e4.product/pom.xml @@ -10,7 +10,7 @@ ../com.minres.scviewer.parent com.minres.scviewer.e4.product - 2.0.4-SNAPSHOT + 2.0.5-SNAPSHOT eclipse-repository com.minres.scviewer diff --git a/com.minres.scviewer.e4.product/scviewer.product b/com.minres.scviewer.e4.product/scviewer.product index bd763f1..458d546 100644 --- a/com.minres.scviewer.e4.product/scviewer.product +++ b/com.minres.scviewer.e4.product/scviewer.product @@ -1,7 +1,7 @@ - +