Revision 943aa6e2

View differences:

ide/org.omnetpp.sequencechart/src/org/omnetpp/sequencechart/editors/SequenceChartContributor.java
176 176
	
177 177
	protected SequenceChartAction showEventOverlappingAction;
178 178
	protected SequenceChartAction showCriticalPathAction;
179
	protected SequenceChartAction showCriticalPathColorsAction;
179 180
	
180 181
	protected SequenceChartAction previousBottleneckAction;
181 182
	protected SequenceChartAction nextBottleneckAction;
......
224 225
		this.showEventNumbersAction = createShowEventNumbersAction();
225 226
		this.showEventOverlappingAction = createShowEventOverlappingAction();
226 227
		this.showCriticalPathAction = createShowCriticalPathAction();
228
		this.showCriticalPathColorsAction = createShowCriticalPathColorsAction();
227 229
		this.previousBottleneckAction = createPreviousBottleneckAction();
228 230
		this.nextBottleneckAction     = createNextBottleneckAction();
229 231
		this.showBottleneckPreferencesAction = createShowBottleneckPreferencesAction();
......
362 364
                showHideSubmenu.add(showEventNumbersAction);
363 365
                showHideSubmenu.add(showEventOverlappingAction);
364 366
                showHideSubmenu.add(showCriticalPathAction);
367
                showHideSubmenu.add(showCriticalPathColorsAction);
365 368
                showHideSubmenu.add(showMessageNamesAction);
366 369
                showHideSubmenu.add(showArrowHeadsAction);
367 370
                showHideSubmenu.add(showAxisLabelsAction);
......
436 439
		toolBarManager.add(showEventNumbersAction);
437 440
		toolBarManager.add(showEventOverlappingAction);
438 441
		toolBarManager.add(showCriticalPathAction);
442
		toolBarManager.add(showCriticalPathColorsAction);
439 443
		toolBarManager.add(showMessageNamesAction);
440 444
        toolBarManager.add(showMessageSendsAction);
441 445
        toolBarManager.add(showSelfMessagesAction);
......
944 948
		};
945 949
	}
946 950
	
951
	private SequenceChartAction createShowCriticalPathColorsAction() {
952
		return new SequenceChartAction("Show Critical Path Colors", Action.AS_CHECK_BOX, SequenceChartPlugin.getImageDescriptor(IMAGE_SHOW_CRITICAL_PATH)) {
953
			@Override
954
			protected void doRun() {
955
				sequenceChart.setShowCriticalPathColors(!sequenceChart.getShowCriticalPathColors());
956
				sequenceChart.setShowEventOverlapping(false);
957
				update();
958
			}
959

  
960
			@Override
961
			public void update() {
962
				setChecked(sequenceChart.getShowCriticalPathColors());
963
				showEventOverlappingAction.setChecked(sequenceChart.getShowEventOverlapping());
964
			}
965
			@Override
966
			public boolean isEnabled() {
967
				return sequenceChart!=null && !sequenceChart.isLegacyTrace();
968
			}
969
		};
970
	}
971
	
947 972
	private SequenceChartAction createPreviousBottleneckAction() {
948 973
		return new SequenceChartAction("Jump to previous Bottleneck", Action.AS_PUSH_BUTTON, SequenceChartPlugin.getImageDescriptor(IMAGE_JUMP_TO_PREVIOUS_BOTTLENECK)) {
949 974
			@Override
ide/org.omnetpp.sequencechart/src/org/omnetpp/sequencechart/widgets/SequenceChart.java
152 152
	private static final Color OVERLAPPING_EVENT_BACKGROUND_COLOR = ColorFactory.DARK_BLUE;
153 153
	private static final Color NON_OVERLAPPING_EVENT_BACKGROUND_COLOR = ColorFactory.LIGHT_BLUE;
154 154
	
155
	private static final Color CRITICAL_EVENT_BACKGROUND_COLOR = ColorFactory.DARK_RED;
156
	private static final Color NON_CRITICAL_EVENT_BACKGROUND_COLOR = ColorFactory.SALMON;
155
	private static final Color CRITICAL_EVENT_BACKGROUND_COLOR = ColorFactory.DARK_BLUE;
156
	private static final Color NON_CRITICAL_EVENT_BACKGROUND_COLOR = ColorFactory.LIGHT_BLUE;
157 157
	
158 158
	private static final Color SELF_EVENT_BACKGROUND_COLOR = ColorFactory.GREEN2;
159 159

  
......
190 190
	private int fontHeight = -1; // cached for cases where a graphics is not available
191 191
	
192 192
	private static final int CRITICAL_PATH_LINE_WIDTH = 3+3; // line width for message dependencies on the critical path
193
	private static final Color CRITICAL_PATH_LINE_COLOR = ColorFactory.RED; // line color for message dependencies on the critical path
193
	private static final Color CRITICAL_PATH_LINE_COLOR = ColorFactory.BLUE; // line color for message dependencies on the critical path
194 194
	
195 195

  
196 196
	/*************************************************************************************
......
220 220
	private boolean showEventNumbers = true;
221 221
	private boolean showEventOverlapping = false;
222 222
	private boolean showCriticalPath = false;
223
	private boolean showCriticalPathColors = false;
223 224
    private boolean showZeroSimulationTimeRegions = true;
224 225
    private boolean showAxisLabels = true;
225 226
    private boolean showAxesWithoutEvents = false;
......
668 669
	}
669 670
	
670 671
	/**
672
	 * Returns whether critical path colors are shown on the chart.
673
	 */
674
	public boolean getShowCriticalPathColors() {
675
		return showCriticalPathColors;
676
	}
677

  
678
	/**
679
	 * Shows/Hides critical path colors.
680
	 */
681
	public void setShowCriticalPathColors(boolean showCriticalPathColors) {
682
		this.showCriticalPathColors = showCriticalPathColors;
683
		clearCanvasCacheAndRedraw();
684
	}
685
	
686
	/**
671 687
	 * Shows/hides arrow heads.
672 688
	 */
673 689
	public boolean getShowArrowHeads() {
......
2550 2566
			
2551 2567
			long startEventPtr = eventPtrRange[0];
2552 2568
			long endEventPtr = eventPtrRange[1];
2553

  
2554 2569
            if (showZeroSimulationTimeRegions)
2555 2570
			    drawZeroSimulationTimeRegions(graphics, startEventPtr, endEventPtr);
2556 2571

  
......
2761 2776
	        if (debug)
2762 2777
	            Debug.println("Drawing events with event range: " + sequenceChartFacade.IEvent_getEventNumber(startEventPtr) + " ->: " + sequenceChartFacade.IEvent_getEventNumber(endEventPtr));
2763 2778

  
2764
			HashMap<Integer, Integer> axisYtoLastX = new HashMap<Integer, Integer>();
2779
			//HashMap<Integer, Integer> axisYtoLastX = new HashMap<Integer, Integer>();
2765 2780

  
2766 2781
			// NOTE: navigating through next event takes care about leaving events out which are not in the filter's result
2767 2782
			for (long eventPtr = startEventPtr;; eventPtr = sequenceChartFacade.IEvent_getNextEvent(eventPtr)) {
......
2770 2785
			    else {
2771 2786
	                int x = (int)getEventXViewportCoordinate(eventPtr);
2772 2787
	                int y = getEventYViewportCoordinate(eventPtr);
2773
	                Integer lastX = axisYtoLastX.get(y);
2788
	               // Integer lastX = axisYtoLastX.get(y);
2774 2789

  
2775 2790
    				// performance optimization: don't draw event if there's one already drawn exactly there
2776
    				if (lastX == null || lastX.intValue() != x) {
2777
    					axisYtoLastX.put(y, x);
2791
    				//if (lastX == null || lastX.intValue() != x) {
2792
    					//axisYtoLastX.put(y, x);
2778 2793
    					drawEvent(graphics, eventPtr, getEventAxisModuleIndex(eventPtr), x, y);
2779
    				}
2794
    				//}
2780 2795
			    }
2781 2796

  
2782 2797
				if (eventPtr == endEventPtr)
......
2928 2943
				}
2929 2944
				break;
2930 2945
			case DURATION: // Show Complexity as colors
2946
			{	double intensity = getComplexityPercentage(sequenceChartFacade
2947
						.IEvent_getEvent(eventPtr)
2948
						.getComplexity());
2931 2949
				graphics
2932 2950
						.setBackgroundColor(new Color(
2933 2951
								null,
2934
								(int)(255 * (getComplexityPercentage(sequenceChartFacade
2935
										.IEvent_getEvent(eventPtr)
2936
										.getComplexity()))),
2937
								(int)(255 - 255 * (getComplexityPercentage(sequenceChartFacade
2938
										.IEvent_getEvent(eventPtr)
2939
										.getComplexity()))), 0));
2952
								(int)(255 * Math.pow(intensity, 1/3.0)),
2953
								(int)(255 - 255 * Math.pow(intensity, 1/3.0)), 0));
2940 2954
				break;
2955
			}
2941 2956
			case COMPLEXITY: // Show Duration as colors
2957
			{
2958
				double intensity = getEventLengthPercentage(sequenceChartFacade
2959
						.IEvent_getEvent(eventPtr)
2960
						.getEventEntry().getDuration());
2942 2961
				graphics
2943 2962
						.setBackgroundColor(new Color(
2944 2963
								null,
2945
								(int)(255 * (getEventLengthPercentage(sequenceChartFacade
2946
										.IEvent_getEvent(eventPtr)
2947
										.getEventEntry().getDuration()))),
2948
								(int)(255 - 255 * (getEventLengthPercentage(sequenceChartFacade
2949
										.IEvent_getEvent(eventPtr)
2950
										.getEventEntry().getDuration()))), 0));
2964
								(int)(255 * Math.pow(intensity, 1/3.0)),
2965
								(int)(255 - 255 * Math.pow(intensity, 1/3.0)), 0));
2951 2966
				break;
2952 2967
			}
2968
			}
2953 2969
		} else if (showCriticalPath){ 
2954 2970
			graphics.setForegroundColor(EVENT_BORDER_COLOR);
2955 2971
			if (sequenceChartFacade.isOnCriticalPath(sequenceChartFacade.IEvent_getEvent(eventPtr))) {
2956
				graphics.setBackgroundColor(CRITICAL_EVENT_BACKGROUND_COLOR);
2972
				if(showCriticalPathColors) {
2973
					double intensity = sequenceChartFacade.getOverlappingQuotient(eventPtr);
2974
					graphics
2975
					.setBackgroundColor(new Color(
2976
							null,
2977
							(int)(255-255 * Math.pow(intensity, 1/3.0)),
2978
							(int)(255 * Math.pow(intensity, 1/3.0)),0));
2979
				} else {
2980
					graphics.setBackgroundColor(CRITICAL_EVENT_BACKGROUND_COLOR);	
2981
				}
2957 2982
			} else {
2958 2983
				graphics.setBackgroundColor(NON_CRITICAL_EVENT_BACKGROUND_COLOR);
2959 2984
			}
src/eventlog/sequencechartfacade.cc
42 42
    smallestDuration = -1;
43 43
    largestDuration = -1;
44 44

  
45
    maximumOverlapping = -1;
46

  
45 47
    biggestEarliestProcessingTime = 0;
46 48

  
47 49
    biggestEndTimeEvent = NULL;
......
1073 1075

  
1074 1076
}
1075 1077

  
1078
double SequenceChartFacade::getOverlapping(ptr_t eventPtr) {
1079
    long overlapping = 0;
1080
    IEvent* event = (IEvent*) eventPtr;
1081

  
1082
    long eventProcessingTime = event->getEarliestProcessingTime();
1083
    long eventStartTime = event->getEarliestStartTime();
1084

  
1085
    for (IEvent *current = eventLog->getFirstEvent(); current; current = current->getNextEvent()) {
1086

  
1087
        if(current->getComplexity() == 0) {
1088
            continue;
1089
        }
1090

  
1091
        long currentStartTime = current->getEarliestStartTime();
1092
        long currentProcessingTime = current->getEarliestProcessingTime();
1093

  
1094
        if(eventStartTime <= currentStartTime && eventProcessingTime >= currentStartTime) {
1095
            overlapping += eventProcessingTime - currentStartTime;
1096
        } else if (currentStartTime <= eventStartTime && currentProcessingTime >= eventStartTime) {
1097
            overlapping += currentProcessingTime - eventStartTime;
1098
        } else if (currentStartTime <= eventStartTime && currentProcessingTime >= eventProcessingTime) {
1099
            overlapping += event->getComplexity();
1100
        }
1101
    }
1102
    printf("overlapping %i %f %i %i\n", overlapping, overlapping / (event->getComplexity() * 1.0), event->getComplexity(), event->getEventNumber());
1103
    return overlapping / (event->getComplexity() * 1.0);
1104
}
1105

  
1106
double SequenceChartFacade::getMaximumOverlapping() {
1107
    double maxOverlapping = 0;
1108
    for (IEvent *current = eventLog->getFirstEvent(); current; current = current->getNextEvent()) {
1109
        if(!isOnCriticalPath(current) || current->getComplexity() == 0) {
1110
            continue;
1111
        }
1112
        double overlapping = getOverlapping((ptr_t) current);
1113
        if (overlapping > maxOverlapping){
1114
            maxOverlapping = overlapping;
1115
        }
1116
    }
1117
    printf("maxoverlapping %i \n", maxOverlapping);
1118
    return maxOverlapping;
1119
}
1120

  
1121
/*
1122
 * returns the quotient of
1123
 * relative overlapping cputime with the event / maximum relative overlapping
1124
 * cputime with any event of the critical path
1125
 */
1126
double SequenceChartFacade::getOverlappingQuotient(ptr_t eventPtr) {
1127

  
1128
    if (((IEvent*)eventPtr)->getComplexity() == 0) {
1129
        return 0;
1130
    }
1131
    double overlapping = getOverlapping(eventPtr);
1132

  
1133
    if (maximumOverlapping == -1) {
1134
        maximumOverlapping = getMaximumOverlapping();
1135
    }
1136

  
1137
    return overlapping / maximumOverlapping;
1138
}
1139

  
src/eventlog/sequencechartfacade.h
49 49
        long smallestComplexity;
50 50
        long largestComplexity;
51 51

  
52
        double maximumOverlapping;
53

  
52 54
        simtime_t smallestDuration;
53 55
        simtime_t largestDuration;
54 56

  
......
115 117
         */
116 118
        simtime_t getLargestEventDuration();
117 119

  
120
        double getOverlappingQuotient(ptr_t eventPtr);
121

  
118 122

  
119 123
        /*
120 124
        * Returns whether an event not part of a set of parallel events with more than treshold elements.
......
164 168

  
165 169
        void calculateCriticalPath();
166 170

  
171
        double getOverlapping(ptr_t eventPtr);
172

  
173
        double getMaximumOverlapping();
174

  
167 175

  
168 176
};
169 177

  

Also available in: Unified diff