Hi Uwe;
I know there is no grouping support for default qwtLegend but I have developed myself as a virtual grouping support which is based on dummy curves in legend. I have created dummy curves (which hasn't ant CurveData) and set as a group curve after then when I am creating new curve I send related group index which is index of QwtPlotItemList. Then I create my curve like below;
/*!
\brief Adds new curve by given properties.
\param curveGroupIndex curve will be child of curve group index
\param curveName curve name
\param curvePen curve pen
\param curveVisibility curve visibility state
\param curveStyle curve style
\return new curve index
\retval -1 curve creation fails
\retval >= 0 curve created and returns curve index
\author Umit Uzun
\date 04/04/2010
\sa QwtPlotCurve::CurveStyle QwtPlot::Axis
*/
short CurveManager::setCurveAddCurve(const ushort &curveGroupIndex,
const bool curveVisibility,
{
short curveIndex = -1;
name.setText(curveName);
name.setColor(curvePen.color());
if ( curve != NULL )
{
curve->setPen(curvePen);
curve->setVisible(curveVisibility);
curve
->setAxis
(QwtPlot::xBottom, curveAxis
);
curve->setStyle(curveStyle);
curve->setData(new CurveData());
curve
->setLegendAttribute
(QwtPlotCurve::LegendShowSymbol,
!curveVisibility
);
curve->attach(privateData.qGraph);
if ( legendItem != NULL )
{
legendItem->setChecked(curveVisibility);
legendItem->setMargin(-1);
legendItem->setSpacing(10);
}
QwtPlotItemList plotItemList
= privateData.
qGraph->itemList
(QwtPlotItem::Rtti_PlotCurve);
if ( plotItemList.size() > 0 )
{
curveIndex
= plotItemList.
indexOf((QwtPlotItem *)curve
);
privateData.curveTree.insert(plotItemList.at(curveGroupIndex), plotItemList.at(curveIndex));
}
}
return curveIndex;
}
/*!
\brief Adds new curve by given properties.
\param curveGroupIndex curve will be child of curve group index
\param curveName curve name
\param curvePen curve pen
\param curveVisibility curve visibility state
\param curveStyle curve style
\return new curve index
\retval -1 curve creation fails
\retval >= 0 curve created and returns curve index
\author Umit Uzun
\date 04/04/2010
\sa QwtPlotCurve::CurveStyle QwtPlot::Axis
*/
short CurveManager::setCurveAddCurve(const ushort &curveGroupIndex,
const QString &curveName,
const QPen &curvePen,
const bool curveVisibility,
const QwtPlot::Axis curveAxis,
const QwtPlotCurve::CurveStyle curveStyle)
{
short curveIndex = -1;
QwtText name;
name.setText(curveName);
name.setColor(curvePen.color());
QwtPlotCurve *curve = new QwtPlotCurve(name);
if ( curve != NULL )
{
curve->setPen(curvePen);
curve->setVisible(curveVisibility);
curve->setAxis(QwtPlot::xBottom, curveAxis);
curve->setStyle(curveStyle);
curve->setData(new CurveData());
curve->setPaintAttribute(QwtPlotCurve::ClipPolygons);
curve->setRenderHint(QwtPlotItem::RenderAntialiased);
curve->setLegendAttribute(QwtPlotCurve::LegendShowSymbol, !curveVisibility);
curve->attach(privateData.qGraph);
QwtLegendItem *legendItem = (QwtLegendItem *)privateData.qGraph->legend()->find(curve);
if ( legendItem != NULL )
{
legendItem->setChecked(curveVisibility);
legendItem->setMargin(-1);
legendItem->setSpacing(10);
}
QwtPlotItemList plotItemList = privateData.qGraph->itemList(QwtPlotItem::Rtti_PlotCurve);
if ( plotItemList.size() > 0 )
{
curveIndex = plotItemList.indexOf((QwtPlotItem *)curve);
privateData.curveTree.insert(plotItemList.at(curveGroupIndex), plotItemList.at(curveIndex));
}
}
return curveIndex;
}
To copy to clipboard, switch view to plain text mode
I can give my curves space, margin and indent properties but any of them not change curve identifier position in legend. My real target is indenting curve name and identifier together but I can only set indention for curve text in legend as you can see from attached screenshot.
How can I indent curve identifier with text in my legend?
Another question; do you think add groping support for formatted curve managing on the legend in the future?
Regards.
Bookmarks