Skip to content

Commit

Permalink
tmf.ui: Instrument Histogram
Browse files Browse the repository at this point in the history
Add two flow scope logs and one scope log.

Change-Id: I1b59629da5f7f417880d8f35694fb296eaaddc62
Signed-off-by: Matthew Khouzam <[email protected]>
  • Loading branch information
MatthewKhouzam committed Nov 19, 2024
1 parent 0a0b76d commit 6b5cb85
Showing 1 changed file with 32 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@

package org.eclipse.tracecompass.tmf.ui.views.histogram;

import java.util.logging.Level;
import java.util.logging.Logger;

import org.eclipse.jdt.annotation.NonNull;
import org.eclipse.jface.action.IStatusLineManager;
import org.eclipse.jface.layout.GridDataFactory;
Expand Down Expand Up @@ -48,6 +51,9 @@
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Label;
import org.eclipse.tracecompass.common.core.log.TraceCompassLog;
import org.eclipse.tracecompass.common.core.log.TraceCompassLogUtils;
import org.eclipse.tracecompass.common.core.log.TraceCompassLogUtils.ScopeLog;
import org.eclipse.tracecompass.internal.tmf.ui.views.histogram.HistogramTimeAdapter;
import org.eclipse.tracecompass.tmf.core.signal.TmfSignalHandler;
import org.eclipse.tracecompass.tmf.core.signal.TmfSignalManager;
Expand Down Expand Up @@ -110,6 +116,7 @@ public abstract class Histogram implements ControlListener, PaintListener, KeyLi
// ------------------------------------------------------------------------

private static final int TIME_SCALE_HEIGHT = 27;
private static final Logger LOGGER = TraceCompassLog.getLogger(Histogram.class);

// Histogram colors

Expand Down Expand Up @@ -250,7 +257,6 @@ public abstract class Histogram implements ControlListener, PaintListener, KeyLi
*/
static boolean showTraces = true;


private boolean fSendTimeAlignSignals = false;

private IStatusLineManager fStatusLineManager;
Expand Down Expand Up @@ -655,17 +661,25 @@ protected void moveCursor(final int keyCode) {
*/
@Override
public void modelUpdated() {
if (!fCanvas.isDisposed() && fCanvas.getDisplay() != null) {
fCanvas.getDisplay().asyncExec(() -> {
if (!fCanvas.isDisposed()) {
// Retrieve and normalize the data
final int canvasWidth = fCanvas.getBounds().width;
final int canvasHeight = fCanvas.getBounds().height;
if (canvasWidth <= 0 || canvasHeight <= 0) {
return;
try (TraceCompassLogUtils.FlowScopeLog fs = new TraceCompassLogUtils.FlowScopeLogBuilder(LOGGER, Level.FINER, "Histogram:ModelUpdated").setCategory("Histogram").build()) { //$NON-NLS-1$ //$NON-NLS-2$
if (!fCanvas.isDisposed() && fCanvas.getDisplay() != null) {
fCanvas.getDisplay().asyncExec(() -> {
int canvasWidth = -1;
int canvasHeight = -1;
try (TraceCompassLogUtils.FlowScopeLog fs1 = new TraceCompassLogUtils.FlowScopeLogBuilder(LOGGER, Level.FINER, "Histogram:getbounds").setParentScope(fs).build()) { //$NON-NLS-1$
if (!fCanvas.isDisposed()) {
// Retrieve and normalize the data
canvasWidth = fCanvas.getBounds().width;
canvasHeight = fCanvas.getBounds().height;
}
fDataModel.setSelection(fSelectionBegin, fSelectionEnd);
fScaledData = fDataModel.scaleTo(canvasWidth, canvasHeight, 1);
}

if (canvasHeight <= 0 || canvasWidth <= 0) {
return;
}
fDataModel.setSelection(fSelectionBegin, fSelectionEnd);
fScaledData = fDataModel.scaleTo(canvasWidth, canvasHeight, 1);
try (TraceCompassLogUtils.FlowScopeLog fs1 = new TraceCompassLogUtils.FlowScopeLogBuilder(LOGGER, Level.FINER, "Histogram:ui").setParentScope(fs).build()) { //$NON-NLS-1$
synchronized (fDataModel) {
if (fScaledData != null) {
fCanvas.redraw();
Expand All @@ -679,16 +693,16 @@ public void modelUpdated() {
GridData gd = (GridData) fMaxNbEventsLabel.getLayoutData();
gd.widthHint = Math.max(gd.widthHint, fMaxNbEventsLabel.computeSize(SWT.DEFAULT, SWT.DEFAULT).x);
fMaxNbEventsLabel.getParent().layout();
if (old.length() < fMaxNbEventsLabel.getText().length()) {
if ((fSendTimeAlignSignals) && (fParentView instanceof ITmfTimeAligned)) {
TmfSignalManager.dispatchSignal(new TmfTimeViewAlignmentSignal(this, ((ITmfTimeAligned) fParentView).getTimeViewAlignmentInfo(), true));
}
if (old.length() < fMaxNbEventsLabel.getText().length() && (fSendTimeAlignSignals) && (fParentView instanceof ITmfTimeAligned)) {
TmfSignalManager.dispatchSignal(new TmfTimeViewAlignmentSignal(this, ((ITmfTimeAligned) fParentView).getTimeViewAlignmentInfo(), true));
}

}
fTimeLineScale.redraw();
}
}
});
}
});
}
}
}

Expand Down Expand Up @@ -786,7 +800,7 @@ private void formatImage(final GC imageGC, final Image image) {

final HistogramScaledData scaledData = new HistogramScaledData(fScaledData);

try {
try (ScopeLog sl = new ScopeLog(LOGGER, Level.FINER, "Histogram:FmtImg")) { //$NON-NLS-1$
final int height = image.getBounds().height;

// Clear the drawing area
Expand Down

0 comments on commit 6b5cb85

Please sign in to comment.