implement continous zoom and removed zoom level status control

This commit is contained in:
2021-11-27 14:04:06 +01:00
parent aa459b0ea6
commit 44812310b0
18 changed files with 674 additions and 954 deletions

View File

@@ -139,19 +139,7 @@
</visibleWhen>
</command>
<command
commandId="com.minres.scviewer.ui.zoom"
id="com.minres.scviewer.ui.zoom.command"
style="pulldown"
tooltip="Set zoom level">
<visibleWhen
checkEnabled="false">
<reference
definitionId="com.minres.scviewer.ui.waveEditorActive">
</reference>
</visibleWhen>
</command>
<command
commandId="com.minres.scviewer.ui.zoomin"
commandId="com.minres.scviewer.ui.zoom.in"
label="Zoom in"
style="push"
tooltip="Zoom into">
@@ -163,7 +151,7 @@
</visibleWhen>
</command>
<command
commandId="com.minres.scviewer.ui.zoomout"
commandId="com.minres.scviewer.ui.zoom.out"
label="Zoom out"
style="push"
tooltip="Zoom out of">
@@ -176,119 +164,6 @@
</command>
</toolbar>
</menuContribution>
<menuContribution
locationURI="menu:com.minres.scviewer.ui.zoom.command">
<command
commandId="com.minres.scviewer.ui.zoom"
label="100ps"
style="push"
tooltip="Resolution 100ps">
<parameter
name="com.minres.scviewer.ui.zoom.level"
value="5">
</parameter>
</command>
<command
commandId="com.minres.scviewer.ui.zoom"
label="1ns"
style="push"
tooltip="Resolution 1ns">
<parameter
name="com.minres.scviewer.ui.zoom.level"
value="6">
</parameter>
</command>
<command
commandId="com.minres.scviewer.ui.zoom"
label="10ns"
style="push"
tooltip="Resolution 10ns">
<parameter
name="com.minres.scviewer.ui.zoom.level"
value="7">
</parameter>
</command>
<command
commandId="com.minres.scviewer.ui.zoom"
label="100ns"
style="push"
tooltip="Resolution 100ns">
<parameter
name="com.minres.scviewer.ui.zoom.level"
value="8">
</parameter>
</command>
<command
commandId="com.minres.scviewer.ui.zoom"
label="1µs"
style="push"
tooltip="Resolution 1us">
<parameter
name="com.minres.scviewer.ui.zoom.level"
value="9">
</parameter>
</command>
<command
commandId="com.minres.scviewer.ui.zoom"
label="10µs"
style="push"
tooltip="Resolution 10us">
<parameter
name="com.minres.scviewer.ui.zoom.level"
value="10">
</parameter>
</command>
<command
commandId="com.minres.scviewer.ui.zoom"
label="100µs"
style="push"
tooltip="Resolution 100us">
<parameter
name="com.minres.scviewer.ui.zoom.level"
value="11">
</parameter>
</command>
<command
commandId="com.minres.scviewer.ui.zoom"
label="1ms"
style="push"
tooltip="Resolution 1ms">
<parameter
name="com.minres.scviewer.ui.zoom.level"
value="12">
</parameter>
</command>
<command
commandId="com.minres.scviewer.ui.zoom"
label="10ms"
style="push"
tooltip="Resolution 10ms">
<parameter
name="com.minres.scviewer.ui.zoom.level"
value="13">
</parameter>
</command>
<command
commandId="com.minres.scviewer.ui.zoom"
label="100ms"
style="push"
tooltip="Resolution 100ms">
<parameter
name="com.minres.scviewer.ui.zoom.level"
value="14">
</parameter>
</command>
<command
commandId="com.minres.scviewer.ui.zoom"
label="1s"
style="push"
tooltip="Resolution 1s">
<parameter
name="com.minres.scviewer.ui.zoom.level"
value="15">
</parameter>
</command>
</menuContribution>
<menuContribution
allPopups="false"
locationURI="popup:com.minres.scviewer.ui.TxEditorPart">
@@ -305,7 +180,7 @@
</visibleWhen>
</command>
<command
commandId="com.minres.scviewer.ui.zoomin"
commandId="com.minres.scviewer.ui.zoom.in"
label="Zoom in"
style="push"
tooltip="Zoom into">
@@ -317,7 +192,7 @@
</visibleWhen>
</command>
<command
commandId="com.minres.scviewer.ui.zoomout"
commandId="com.minres.scviewer.ui.zoom.out"
label="Zoom out"
style="push"
tooltip="Zoom out of">
@@ -367,24 +242,21 @@
name="Prev">
</command>
<command
defaultHandler="com.minres.scviewer.ui.handler.Zoom"
description="Set the zoom level"
id="com.minres.scviewer.ui.zoom"
name="Zoom">
<commandParameter
id="com.minres.scviewer.ui.zoom.level"
name="level"
optional="true">
</commandParameter>
</command>
<command
id="com.minres.scviewer.ui.zoomin"
id="com.minres.scviewer.ui.zoom.in"
name="Zoom in">
</command>
<command
id="com.minres.scviewer.ui.zoomout"
id="com.minres.scviewer.ui.zoom.out"
name="Zoom out">
</command>
<command
id="com.minres.scviewer.ui.zoom.fit"
name="Zoom fit">
</command>
<command
id="com.minres.scviewer.ui.zoom.full"
name="Zoom full">
</command>
<command
id="com.minres.scviewer.ui.removeWave"
name="Remove wave">
@@ -411,8 +283,8 @@
</enabledWhen>
</handler>
<handler
class="com.minres.scviewer.ui.handler.ZoomInOut"
commandId="com.minres.scviewer.ui.zoomin">
class="com.minres.scviewer.ui.handler.Zoom"
commandId="com.minres.scviewer.ui.zoom.in">
<enabledWhen>
<reference
definitionId="com.minres.scviewer.ui.waveEditorActive">
@@ -420,8 +292,8 @@
</enabledWhen>
</handler>
<handler
class="com.minres.scviewer.ui.handler.ZoomInOut"
commandId="com.minres.scviewer.ui.zoomout">
class="com.minres.scviewer.ui.handler.Zoom"
commandId="com.minres.scviewer.ui.zoom.out">
<enabledWhen>
<reference
definitionId="com.minres.scviewer.ui.waveEditorActive">
@@ -493,15 +365,11 @@
icon="res/images/next-green.png">
</image>
<image
commandId="com.minres.scviewer.ui.zoom"
icon="res/images/zoom.png">
</image>
<image
commandId="com.minres.scviewer.ui.zoomin"
commandId="com.minres.scviewer.ui.zoom.in"
icon="res/images/zoom_in.png">
</image>
<image
commandId="com.minres.scviewer.ui.zoomout"
commandId="com.minres.scviewer.ui.zoom.out"
icon="res/images/zoom_out.png">
</image>
<image

View File

@@ -50,6 +50,7 @@ import com.minres.scviewer.database.IWaveformDbFactory;
import com.minres.scviewer.database.ui.GotoDirection;
import com.minres.scviewer.database.ui.IWaveformView;
import com.minres.scviewer.database.ui.TrackEntry;
import com.minres.scviewer.database.ui.ZoomKind;
import com.minres.scviewer.database.ui.swt.WaveformViewFactory;
import com.minres.scviewer.ui.views.TxOutlinePage;
@@ -66,13 +67,6 @@ public class TxEditorPart extends EditorPart implements ITabbedPropertySheetPage
waveformDbFactory=null;
}
private final static String[] zoomLevel={
"1fs", "10fs", "100fs",
"1ps", "10ps", "100ps",
"1ns", "10ns", "100ns",
"1µs", "10µs", "10µs",
"1ms", "10ms", "100ms", "1s"};
public static final String ID = "com.minres.scviewer.ui.TxEditorPart"; //$NON-NLS-1$
public static final String WAVE_ACTION_ID = "com.minres.scviewer.ui.action.AddToWave";
@@ -85,7 +79,6 @@ public class TxEditorPart extends EditorPart implements ITabbedPropertySheetPage
private Composite myParent;
private StatusLineContributionItem cursorStatusLineItem;
private StatusLineContributionItem zoomStatusLineItem;
public TxEditorPart() {
}
@@ -132,7 +125,6 @@ public class TxEditorPart extends EditorPart implements ITabbedPropertySheetPage
}
}
}).run();
zoomStatusLineItem.setText("Zoom level: "+zoomLevel[waveformView.getZoomLevel()]);
cursorStatusLineItem.setText("Cursor: "+ waveformView.getCursorTime()/1000000+"ns");
MenuManager menuMgr = new MenuManager("#PopupMenu");
// menuMgr.setRemoveAllWhenShown(true);
@@ -306,11 +298,9 @@ public class TxEditorPart extends EditorPart implements ITabbedPropertySheetPage
// Initialize the editor part
setSite(site);
setInput(input);
zoomStatusLineItem = new StatusLineContributionItem("TxEditorZoomContributionItem");
cursorStatusLineItem = new StatusLineContributionItem("TxEditorCursorContributionItem");
IActionBars actionBars = getEditorSite().getActionBars();
IStatusLineManager manager = actionBars.getStatusLineManager();
manager.add(zoomStatusLineItem);
manager.add(cursorStatusLineItem);
actionBars.updateActionBars();
}
@@ -388,16 +378,8 @@ public class TxEditorPart extends EditorPart implements ITabbedPropertySheetPage
waveformView.moveSelection( next);
}
public void setZoomLevel(Integer level) {
waveformView.setZoomLevel(level);
}
public void setZoomFit() {
waveformView.setZoomLevel(6);
}
public int getZoomLevel() {
return waveformView.getZoomLevel();
public void setZoom(ZoomKind kind) {
waveformView.getWaveformZoom().zoom(kind);
}
public void removeSelected() {

View File

@@ -16,25 +16,30 @@ import org.eclipse.core.commands.ExecutionException;
import org.eclipse.ui.IEditorPart;
import org.eclipse.ui.handlers.HandlerUtil;
import com.minres.scviewer.database.ui.ZoomKind;
import com.minres.scviewer.ui.TxEditorPart;
public class Zoom extends AbstractHandler {
private static final String PARM_MSG = "com.minres.scviewer.ui.zoom.level";
private static final String ZOOMIN_ID = "com.minres.scviewer.ui.zoom.in";
private static final String ZOOMOUT_ID = "com.minres.scviewer.ui.zoom.out";
private static final String ZOOMFIT_ID = "com.minres.scviewer.ui.zoom.fit";
private static final String ZOOMFULL_ID = "com.minres.scviewer.ui.zoom.full";
@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
IEditorPart editor = HandlerUtil.getActiveEditor(event);
String msg = event.getParameter(PARM_MSG);
if (msg == null) {
if(editor instanceof TxEditorPart){
((TxEditorPart)editor).setZoomFit();
}
} else {
Integer level = Integer.parseInt(msg);
if(editor instanceof TxEditorPart){
((TxEditorPart)editor).setZoomLevel(level);
}
}
if(editor instanceof TxEditorPart){
String id = event.getCommand().getId();
TxEditorPart txEditor=(TxEditorPart) editor;
if (ZOOMIN_ID.compareTo(id) == 0)
txEditor.setZoom(ZoomKind.IN);
else if(ZOOMOUT_ID.compareTo(id) == 0)
txEditor.setZoom(ZoomKind.OUT);
else if(ZOOMFIT_ID.compareTo(id) == 0)
txEditor.setZoom(ZoomKind.FIT);
else if(ZOOMFULL_ID.compareTo(id) == 0)
txEditor.setZoom(ZoomKind.FULL);
}
return null;
}

View File

@@ -1,39 +0,0 @@
/*******************************************************************************
* Copyright (c) 2015-2021 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.ui.handler;
import org.eclipse.core.commands.AbstractHandler;
import org.eclipse.core.commands.ExecutionEvent;
import org.eclipse.core.commands.ExecutionException;
import org.eclipse.ui.IEditorPart;
import org.eclipse.ui.handlers.HandlerUtil;
import com.minres.scviewer.ui.TxEditorPart;
public class ZoomInOut extends AbstractHandler {
private static final String ZOOMIN_ID = "com.minres.scviewer.ui.zoomin";
private static final String ZOOMOUT_ID= "com.minres.scviewer.ui.zoomout";
@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
IEditorPart editor = HandlerUtil.getActiveEditor(event);
if(editor instanceof TxEditorPart){
String id = event.getCommand().getId();
TxEditorPart txEditor=(TxEditorPart) editor;
if (ZOOMIN_ID.compareTo(id) == 0)
txEditor.setZoomLevel(txEditor.getZoomLevel()-1);
else if(ZOOMOUT_ID.compareTo(id) == 0)
txEditor.setZoomLevel(txEditor.getZoomLevel()+1);
}
return null;
}
}