From 50e7cdc45d18007ae65436315cd07cee37b27a0e Mon Sep 17 00:00:00 2001 From: ageay Date: Wed, 4 Apr 2012 07:40:55 +0000 Subject: [PATCH] Addons for multiaxe-X. --- src/Plot2d/Plot2d_ViewFrame.cxx | 39 +++++++++++++++++++++++++++------ src/Plot2d/Plot2d_ViewFrame.h | 13 ++++++++--- 2 files changed, 42 insertions(+), 10 deletions(-) diff --git a/src/Plot2d/Plot2d_ViewFrame.cxx b/src/Plot2d/Plot2d_ViewFrame.cxx index 2822e6dbf..e0c9dd322 100755 --- a/src/Plot2d/Plot2d_ViewFrame.cxx +++ b/src/Plot2d/Plot2d_ViewFrame.cxx @@ -270,6 +270,19 @@ void Plot2d_ViewFrame::EraseAll() getObjects( anObjects ); eraseObjects( anObjects, false ); myObjects.clear(); + // Erase all the intermittent segments who connect curves + // (cf displayPlot2dCurveList() and createSegment(() ) + // + { + int nbSeg = myIntermittentSegmentList.size(); + for (int iseg=0; iseg < nbSeg; iseg++) + { + QwtPlotCurve *segment = myIntermittentSegmentList[iseg]; + segment->detach(); // erase in QwtPlot window + delete segment; + } + myIntermittentSegmentList.clear(); + } myPlot->replot(); if ( myPlot->zoomer() ) myPlot->zoomer()->setZoomBase(); } @@ -624,7 +637,8 @@ void Plot2d_ViewFrame::createCurveTooltips( Plot2d_Curve *curve, * Draw connection segments (intermittent line) between all the curves of a component. */ void Plot2d_ViewFrame::displayPlot2dCurveList( QList< QList > sysCoCurveList, - Plot2d_QwtPlotPicker* picker) + Plot2d_QwtPlotPicker* picker, + bool displayLegend) { //std::cout << "Plot2d_ViewFrame::displayPlot2dCurveList() 1" << std::endl; @@ -668,7 +682,7 @@ void Plot2d_ViewFrame::displayPlot2dCurveList( QList< QList > sys // 2)- Display list curves by a component's curves group // Draw connection segments (intermittent line) between the curves - displayPlot2dCurveList( plot2dCurveCoSysList, nbSystem, picker); + displayPlot2dCurveList( plot2dCurveCoSysList, nbSystem, picker, displayLegend); // 3)- Size of graduations labels and texts under X axis @@ -692,12 +706,13 @@ void Plot2d_ViewFrame::displayPlot2dCurveList( QList< QList > sys */ void Plot2d_ViewFrame::displayPlot2dCurveList( QList curveList, int groupSize, - Plot2d_QwtPlotPicker* picker) + Plot2d_QwtPlotPicker* picker, + bool displayLegend) { //std::cout << "Plot2d_ViewFrame::displayPlot2dCurveList() 2" << std::endl; // Consider the new legend's entries - // (we must remove and put the QwtLegend in the QwtPlot) + // (PB: to update the legend we must remove it and put a new QwtLegend in the QwtPlot) myPlot->insertLegend( (QwtLegend*)NULL); // we remove here, we shall put at the end double X[2]; @@ -834,8 +849,11 @@ void Plot2d_ViewFrame::displayPlot2dCurveList( QList curveList, icur1 = icur2 + 1; } - // Consider the new legend's entries - showLegend( true, true); + if (displayLegend) + { + // Consider the new legend's entries + showLegend( true, true); + } //std::cout << "Ok for Plot2d_ViewFrame::displayPlot2dCurveList() 2" << std::endl; } @@ -857,7 +875,8 @@ Plot2d_Curve* Plot2d_ViewFrame::createPlot2dCurve( QString & title, QColor & lineColor, QwtSymbol::Style markerKind, Plot2d_QwtPlotPicker* picker, - bool toDraw) + bool toDraw, + bool displayLegend) { //std::cout << "Plot2d_ViewFrame::createPlot2dCurve()" << std::endl; @@ -890,6 +909,10 @@ Plot2d_Curve* Plot2d_ViewFrame::createPlot2dCurve( QString & title, // Graphical curve (QwtPlotCurve) in the drawing zone (QwtPlot) myPlot if (toDraw) { + if (!displayLegend) + { + myPlot->insertLegend( (QwtLegend*)NULL); + } displayCurve( plot2dCurve); // plot points marker create associated tooltips @@ -973,6 +996,8 @@ void Plot2d_ViewFrame::createSegment( double *X, double *Y, int nbPoint, aPCurve->setItemAttribute( QwtPlotItem::Legend, false); aPCurve->attach( myPlot); + // To deallocate in EraseAll() + myIntermittentSegmentList.append( aPCurve); } /*! diff --git a/src/Plot2d/Plot2d_ViewFrame.h b/src/Plot2d/Plot2d_ViewFrame.h index 23bca879a..8f5acac85 100755 --- a/src/Plot2d/Plot2d_ViewFrame.h +++ b/src/Plot2d/Plot2d_ViewFrame.h @@ -93,11 +93,13 @@ public: Plot2d_QwtPlotPicker *picker); void displayPlot2dCurveList( QList< QList > sysCoCurveList, - Plot2d_QwtPlotPicker* picker); + Plot2d_QwtPlotPicker* picker, + bool displayLegend); void displayPlot2dCurveList( QList curveList, int groupsize, - Plot2d_QwtPlotPicker* picker); + Plot2d_QwtPlotPicker* picker, + bool displayLegend); Plot2d_Curve* createPlot2dCurve( QString & title, QString & unit, @@ -109,7 +111,8 @@ public: QColor & lineColor, QwtSymbol::Style markerKind, Plot2d_QwtPlotPicker* picker, - bool toDraw); + bool toDraw, + bool displayLegend=true); QColor getPlot2dCurveColor( Plot2d_Curve* plot2dCurve); @@ -310,6 +313,10 @@ protected: Plot2d_NormalizeAlgorithm* myLNormAlgo; Plot2d_NormalizeAlgorithm* myRNormAlgo; bool myIsDefTitle; + private: + // List of intermittent segments to connect curves + // (cf displayPlot2dCurveList() and createSegment(() ) + QList myIntermittentSegmentList; }; class Plot2d_Plot2d : public QwtPlot -- 2.39.2