Customizing Gantt Chart Grids
The
IlvGanttChart class has methods for dealing with a chart grid. Using these methods, you can show or hide the grid, compute its points, and draw it.
In the grapher views, you can choose to show the grid or not using the method
showGrid. If the
redraw parameter is
IlTrue, the grapher views will be redrawn.
You can specify the grid points using the method
computeGridPoints. This method computes the grid points for the grapher view specified by the
index parameter (
0,
1,
2, or
3). It stores them in two internal data members (one each for the x and y coordinates):
_gridXPoints and
_gridYPoints. There are two internal data members for every grapher view.
You can draw the grid with the virtual method
drawGrid. This method draws the grid in the given destination port
. Its
index parameter indicates for which grapher view the grid points are computed. Its
skipCompute parameter indicates whether this function calls the
computeGridPoints member function. This increases performance; for example, it is useless to call
computeGridPoints if there is no change in the point values and there is just a simple redraw.
The month example shows how to customize the drawing of the grid. The weekend periods are highlighted by drawing additional filled rectangles:
void
MonthGanttChart::drawGrid(IlvPort* dst, IlvUShort ix,
IlvBoolean skipCompute, const IlvRegion* clip,
IlvTransformer*, IlvDirection)
{
if (!isShowingGrid() || !getGadgetContainer() || rows() == 0)
return;
if (clip)
_holidayPalette->setClip(clip);
// The time graduation (step) is 1 hour, 24 means 24 hours per day
IlvUShort dayInWeek,
startDay = (IlvUShort)
((getShownStart((IlvUShort)(ix&1))-getStart())/24),
endDay = (IlvUShort)
((getShownEnd((IlvUShort)(ix&1))-getStart())/24);
IlvUShort fvRow = firstVisibleRow((IlvUShort)(ix/2));
IlvUShort lvRow = lastVisibleRow((IlvUShort)(ix/2));
IlvUShort toRow = IlvMin((IlvUShort)(lvRow+2), rows());
// Gets the current grapher view transformer
IlvTransformer* t = getGrapher()->getTransformer(getGrapherView(ix));
IlvRect rect;
// In the visible part, check if there is a Sunday or a Saturday
// and fill the grapher view regions that correspond to these
// days with a specific pattern (_holidayPalette)
IlvRect fromRect, toRect;
rowBBox(fvRow, fromRect);
rowBBox(toRow, toRect);
for (IlvUShort day = startDay; day < endDay; ++day) {
dayInWeek = (IlvUShort)(((IlvInt)day + (IlvInt)_day - 1) % 7);
if ((dayInWeek == 6) || (dayInWeek == 0)) {
rect.moveResize(day*24, fromRect.y(),
(IlvDim)getStep((IlvUShort)(ix&1)),
(IlvDim)(toRect.y()-fromRect.y()));
if (t)
t->apply(rect);
dst->fillRectangle(_holidayPalette, rect);
}
}
LoadGanttChart::drawGrid(dst, ix, skipCompute, clip);
if (clip)
_holidayPalette->setClip();
}
Version 6.3
Copyright © 2018, Rogue Wave Software, Inc. All Rights Reserved.