implement continous zoom and removed zoom level status control
This commit is contained in:
@ -18,6 +18,7 @@ import org.eclipse.e4.core.di.annotations.Execute;
|
||||
import org.eclipse.e4.ui.model.application.ui.basic.MPart;
|
||||
import org.eclipse.e4.ui.workbench.modeling.EPartService;
|
||||
|
||||
import com.minres.scviewer.database.ui.ZoomKind;
|
||||
import com.minres.scviewer.e4.application.parts.WaveformViewer;
|
||||
|
||||
public class ZoomHandler {
|
||||
@ -35,15 +36,14 @@ public class ZoomHandler {
|
||||
Object obj = part.getObject();
|
||||
if(obj instanceof WaveformViewer){
|
||||
WaveformViewer waveformViewerPart = (WaveformViewer) obj;
|
||||
int zoomLevel = waveformViewerPart.getZoomLevel();
|
||||
if("in".equalsIgnoreCase(level)) //$NON-NLS-1$
|
||||
waveformViewerPart.setZoomLevel(zoomLevel-1);
|
||||
waveformViewerPart.setZoom(ZoomKind.IN);
|
||||
else if("out".equalsIgnoreCase(level)) //$NON-NLS-1$
|
||||
waveformViewerPart.setZoomLevel(zoomLevel+1);
|
||||
waveformViewerPart.setZoom(ZoomKind.OUT);
|
||||
else if("fit".equalsIgnoreCase(level)) //$NON-NLS-1$
|
||||
waveformViewerPart.setZoomFit();
|
||||
waveformViewerPart.setZoom(ZoomKind.FIT);
|
||||
else if("full".equalsIgnoreCase(level)) //$NON-NLS-1$
|
||||
waveformViewerPart.setZoomFull();
|
||||
waveformViewerPart.setZoom(ZoomKind.FULL);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -27,9 +27,6 @@ import com.minres.scviewer.e4.application.Messages;
|
||||
*/
|
||||
public class WaveStatusBarControl extends StatusBarControl {
|
||||
|
||||
/** The Constant ZOOM_LEVEL. */
|
||||
public static final String ZOOM_LEVEL="ZoomLevelUpdate"; //$NON-NLS-1$
|
||||
|
||||
/** The Constant CURSOR_TIME. */
|
||||
public static final String CURSOR_TIME="CursorPosUpdate"; //$NON-NLS-1$
|
||||
|
||||
@ -45,7 +42,7 @@ public class WaveStatusBarControl extends StatusBarControl {
|
||||
|
||||
|
||||
/** The zoom contribution. */
|
||||
StatusLineContributionItem cursorContribution, markerContribution, markerDiffContribution, zoomContribution;
|
||||
StatusLineContributionItem cursorContribution, markerContribution, markerDiffContribution;
|
||||
|
||||
/**
|
||||
* Instantiates a new wave status bar control.
|
||||
@ -59,11 +56,9 @@ public class WaveStatusBarControl extends StatusBarControl {
|
||||
cursorContribution = new StatusLineContributionItem(Messages.WaveStatusBarControl_5, true, 20);
|
||||
markerContribution = new StatusLineContributionItem(Messages.WaveStatusBarControl_6, true, 20);
|
||||
markerDiffContribution = new StatusLineContributionItem(Messages.WaveStatusBarControl_7, true, 20);
|
||||
zoomContribution = new StatusLineContributionItem(Messages.WaveStatusBarControl_8, true, 8);
|
||||
manager.appendToGroup(StatusLineManager.BEGIN_GROUP,cursorContribution);
|
||||
manager.appendToGroup(StatusLineManager.BEGIN_GROUP,markerContribution);
|
||||
manager.appendToGroup(StatusLineManager.BEGIN_GROUP,markerDiffContribution);
|
||||
manager.appendToGroup(StatusLineManager.BEGIN_GROUP, zoomContribution);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -88,17 +83,6 @@ public class WaveStatusBarControl extends StatusBarControl {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the zoom event.
|
||||
*
|
||||
* @param text the text
|
||||
* @return the zoom event
|
||||
*/
|
||||
@Inject @Optional
|
||||
public void getZoomEvent(@UIEventTopic(ZOOM_LEVEL) String text) {
|
||||
zoomContribution.setText(text);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the cursor event.
|
||||
*
|
||||
|
@ -94,6 +94,7 @@ import com.minres.scviewer.database.ui.IWaveformView;
|
||||
import com.minres.scviewer.database.ui.TrackEntry;
|
||||
import com.minres.scviewer.database.ui.TrackEntry.ValueDisplay;
|
||||
import com.minres.scviewer.database.ui.TrackEntry.WaveDisplay;
|
||||
import com.minres.scviewer.database.ui.ZoomKind;
|
||||
import com.minres.scviewer.database.ui.swt.Constants;
|
||||
import com.minres.scviewer.database.ui.swt.IToolTipContentProvider;
|
||||
import com.minres.scviewer.database.ui.swt.IToolTipHelpTextProvider;
|
||||
@ -131,7 +132,7 @@ public class WaveformViewer implements IFileChangeListener, IPreferenceChangeLis
|
||||
protected static final String SHOWN_CURSOR = "SHOWN_CURSOR"; //$NON-NLS-1$
|
||||
|
||||
/** The Constant ZOOM_LEVEL. */
|
||||
protected static final String ZOOM_LEVEL = "ZOOM_LEVEL"; //$NON-NLS-1$
|
||||
protected static final String SCALING_FACTOR = "SCALING_FACTOR"; //$NON-NLS-1$
|
||||
|
||||
/** The Constant BASE_LINE_TIME. */
|
||||
protected static final String BASE_LINE_TIME = "BASE_LINE_TIME"; //$NON-NLS-1$
|
||||
@ -151,9 +152,6 @@ public class WaveformViewer implements IFileChangeListener, IPreferenceChangeLis
|
||||
/** The Constant TX_DETAILS_SHOWN. */
|
||||
protected static final String TX_DETAILS_SHOWN = "TX_DETAILS_SHOWN"; //$NON-NLS-1$
|
||||
|
||||
/** The zoom level. */
|
||||
private String[] zoomLevel;
|
||||
|
||||
/** The Constant ID. */
|
||||
public static final String ID = "com.minres.scviewer.ui.TxEditorPart"; //$NON-NLS-1$
|
||||
|
||||
@ -299,15 +297,15 @@ public class WaveformViewer implements IFileChangeListener, IPreferenceChangeLis
|
||||
|
||||
waveformPane.addPropertyChangeListener(IWaveformView.CURSOR_PROPERTY, evt -> {
|
||||
Long time = (Long) evt.getNewValue();
|
||||
eventBroker.post(WaveStatusBarControl.CURSOR_TIME, waveformPane.getScaledTime(time));
|
||||
long marker = waveformPane.getMarkerTime(waveformPane.getSelectedMarkerId());
|
||||
eventBroker.post(WaveStatusBarControl.MARKER_DIFF, waveformPane.getScaledTime(time - marker));
|
||||
eventBroker.post(WaveStatusBarControl.CURSOR_TIME, waveformPane.getWaveformZoom().timeToString(time));
|
||||
long marker = waveformPane.getMarkerTime(waveformPane.getSelectedMarker());
|
||||
eventBroker.post(WaveStatusBarControl.MARKER_DIFF, waveformPane.getWaveformZoom().timeToString(time - marker));
|
||||
});
|
||||
waveformPane.addPropertyChangeListener(IWaveformView.MARKER_PROPERTY, evt -> {
|
||||
Long time = (Long) evt.getNewValue();
|
||||
eventBroker.post(WaveStatusBarControl.MARKER_TIME, waveformPane.getScaledTime(time));
|
||||
eventBroker.post(WaveStatusBarControl.MARKER_TIME, waveformPane.getWaveformZoom().timeToString(time));
|
||||
long cursor = waveformPane.getCursorTime();
|
||||
eventBroker.post(WaveStatusBarControl.MARKER_DIFF, waveformPane.getScaledTime(cursor - time));
|
||||
eventBroker.post(WaveStatusBarControl.MARKER_DIFF, waveformPane.getWaveformZoom().timeToString(cursor - time));
|
||||
});
|
||||
|
||||
waveformPane.addSelectionChangedListener(event -> {
|
||||
@ -319,17 +317,14 @@ public class WaveformViewer implements IFileChangeListener, IPreferenceChangeLis
|
||||
waveformPane.getWaveformControl().addListener(SWT.KeyDown, e -> {
|
||||
if((e.stateMask&SWT.MOD3)!=0) { // Alt key
|
||||
} else if((e.stateMask&SWT.MOD1)!=0) { //Ctrl/Cmd
|
||||
int zoomlevel = waveformPane.getZoomLevel();
|
||||
switch(e.keyCode) {
|
||||
case '+':
|
||||
case SWT.KEYPAD_ADD:
|
||||
if(zoomlevel>0)
|
||||
waveformPane.setZoomLevel(zoomlevel-1);
|
||||
waveformPane.getWaveformZoom().zoom(ZoomKind.IN);
|
||||
return;
|
||||
case '-':
|
||||
case SWT.KEYPAD_SUBTRACT:
|
||||
if(zoomlevel<waveformPane.getZoomLevels().length-1)
|
||||
waveformPane.setZoomLevel(zoomlevel+1);
|
||||
waveformPane.getWaveformZoom().zoom(ZoomKind.OUT);
|
||||
return;
|
||||
case SWT.ARROW_UP:
|
||||
waveformPane.moveSelectedTrack(-1);
|
||||
@ -381,7 +376,6 @@ public class WaveformViewer implements IFileChangeListener, IPreferenceChangeLis
|
||||
}
|
||||
});
|
||||
|
||||
zoomLevel = waveformPane.getZoomLevels();
|
||||
checkForUpdates = store.getBoolean(PreferenceConstants.DATABASE_RELOAD, true);
|
||||
filesToLoad = new ArrayList<>();
|
||||
persistedState = part.getPersistedState();
|
||||
@ -392,7 +386,6 @@ public class WaveformViewer implements IFileChangeListener, IPreferenceChangeLis
|
||||
}
|
||||
if (!filesToLoad.isEmpty())
|
||||
loadDatabase(persistedState);
|
||||
eventBroker.post(WaveStatusBarControl.ZOOM_LEVEL, zoomLevel[waveformPane.getZoomLevel()]);
|
||||
menuService.registerContextMenu(waveformPane.getNameControl(), MENU_CONTEXT);
|
||||
menuService.registerContextMenu(waveformPane.getValueControl(), MENU_CONTEXT);
|
||||
menuService.registerContextMenu(waveformPane.getWaveformControl(), MENU_CONTEXT);
|
||||
@ -750,8 +743,8 @@ public class WaveformViewer implements IFileChangeListener, IPreferenceChangeLis
|
||||
persistingState.put(SHOWN_CURSOR + index, Long.toString(cursor.getTime()));
|
||||
index++;
|
||||
}
|
||||
persistingState.put(ZOOM_LEVEL, Integer.toString(waveformPane.getZoomLevel()));
|
||||
persistingState.put(BASE_LINE_TIME, Long.toString(waveformPane.getBaselineTime()));
|
||||
persistingState.put(SCALING_FACTOR, Long.toString(waveformPane.getWaveformZoom().getScale()));
|
||||
persistingState.put(BASE_LINE_TIME, Long.toString(waveformPane.getWaveformZoom().getMinVisibleTime()));
|
||||
|
||||
// get selected transaction of a stream
|
||||
ISelection selection = waveformPane.getSelection();
|
||||
@ -822,17 +815,17 @@ public class WaveformViewer implements IFileChangeListener, IPreferenceChangeLis
|
||||
cursors.get(i).setTime(time);
|
||||
}
|
||||
}
|
||||
if (state.containsKey(ZOOM_LEVEL)) {
|
||||
if (state.containsKey(SCALING_FACTOR)) {
|
||||
try {
|
||||
Integer scale = Integer.parseInt(state.get(ZOOM_LEVEL));
|
||||
waveformPane.setZoomLevel(scale);
|
||||
long scale = Long.parseLong(state.get(SCALING_FACTOR));
|
||||
waveformPane.getWaveformZoom().setScale(scale);
|
||||
} catch (NumberFormatException e) {
|
||||
}
|
||||
}
|
||||
if (state.containsKey(BASE_LINE_TIME)) {
|
||||
try {
|
||||
Long scale = Long.parseLong(state.get(BASE_LINE_TIME));
|
||||
waveformPane.setBaselineTime(scale);
|
||||
waveformPane.getWaveformZoom().setMinVisibleTime(scale);
|
||||
} catch (NumberFormatException e) {
|
||||
}
|
||||
}
|
||||
@ -871,12 +864,11 @@ public class WaveformViewer implements IFileChangeListener, IPreferenceChangeLis
|
||||
*/
|
||||
private void updateAll() {
|
||||
eventBroker.post(ACTIVE_WAVEFORMVIEW, this);
|
||||
eventBroker.post(WaveStatusBarControl.ZOOM_LEVEL, zoomLevel[waveformPane.getZoomLevel()]);
|
||||
long cursor = waveformPane.getCursorTime();
|
||||
long marker = waveformPane.getMarkerTime(waveformPane.getSelectedMarkerId());
|
||||
eventBroker.post(WaveStatusBarControl.CURSOR_TIME, waveformPane.getScaledTime(cursor));
|
||||
eventBroker.post(WaveStatusBarControl.MARKER_TIME, waveformPane.getScaledTime(marker));
|
||||
eventBroker.post(WaveStatusBarControl.MARKER_DIFF, waveformPane.getScaledTime(cursor - marker));
|
||||
long marker = waveformPane.getMarkerTime(waveformPane.getSelectedMarker());
|
||||
eventBroker.post(WaveStatusBarControl.CURSOR_TIME, waveformPane.getWaveformZoom().timeToString(cursor));
|
||||
eventBroker.post(WaveStatusBarControl.MARKER_TIME, waveformPane.getWaveformZoom().timeToString(marker));
|
||||
eventBroker.post(WaveStatusBarControl.MARKER_DIFF, waveformPane.getWaveformZoom().timeToString(cursor - marker));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -1047,44 +1039,13 @@ public class WaveformViewer implements IFileChangeListener, IPreferenceChangeLis
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the zoom level.
|
||||
*
|
||||
* @param level the new zoom level
|
||||
* Execute the zoom kind.
|
||||
*/
|
||||
public void setZoomLevel(Integer level) {
|
||||
if (level < 0)
|
||||
level = 0;
|
||||
if (level > zoomLevel.length - 1)
|
||||
level = zoomLevel.length - 1;
|
||||
waveformPane.setZoomLevel(level);
|
||||
public void setZoom(ZoomKind kind) {
|
||||
waveformPane.getWaveformZoom().zoom(kind);
|
||||
updateAll();
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the zoom fit.
|
||||
*/
|
||||
public void setZoomFit() {
|
||||
waveformPane.setZoomLevel(-2);
|
||||
updateAll();
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the zoom fit.
|
||||
*/
|
||||
public void setZoomFull() {
|
||||
waveformPane.setZoomLevel(-1);
|
||||
updateAll();
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the zoom level.
|
||||
*
|
||||
* @return the zoom level
|
||||
*/
|
||||
public int getZoomLevel() {
|
||||
return waveformPane.getZoomLevel();
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the selection.
|
||||
*
|
||||
@ -1113,7 +1074,7 @@ public class WaveformViewer implements IFileChangeListener, IPreferenceChangeLis
|
||||
* @return the scaled time
|
||||
*/
|
||||
public String getScaledTime(Long time) {
|
||||
return waveformPane.getScaledTime(time);
|
||||
return waveformPane.getWaveformZoom().timeToString(time);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -1239,7 +1200,6 @@ public class WaveformViewer implements IFileChangeListener, IPreferenceChangeLis
|
||||
public void widgetDisposed(DisposeEvent e) {
|
||||
disposeListenerNumber -= 1;
|
||||
if( disposeListenerNumber == 0) { //if the last tab is closed, reset statusbar
|
||||
eventBroker.post(WaveStatusBarControl.ZOOM_LEVEL, null);
|
||||
eventBroker.post(WaveStatusBarControl.CURSOR_TIME, null);
|
||||
eventBroker.post(WaveStatusBarControl.MARKER_TIME, null);
|
||||
eventBroker.post(WaveStatusBarControl.MARKER_DIFF, null);
|
||||
|
Reference in New Issue
Block a user