- <b>Curve type</b> you can select from \em Points, \em Lines or
\em Spline.
-- <b>Show legend</b> here you can define the position of the
+- <b>Marker size</b> - size of the points (markers) forming curve lines.
+
+- <b>Background color</b> of the XY plot.
+
+- <b>Selection color</b> - this submenu allows to select the color of selected object in the viewer.
+
+- <b>Legend</b> allows specifying the properties of the legend.
+
+ - <b>Show legend</b> - this options specifies if it's necessary to show legend by default.
+
+ - <b>Legend Position</b> here you can define the position of the
description table on the XY plot (to the \em Left, to the \em Right,
on \em Top or on \em Bottom).
+
+ - <b>Symbol type</b> you can select the type of legend item symbol from "Marker on line" or "Marker above line"
-- <b>Legend font</b> here you can set type, face and color for the
+ - <b>Legend font</b> here you can set type, face and color for the
font of Legend item.
+
+ - <b>Legend font color</b> - this allows to select the color of the font of the legend item.
-- <b>Marker size</b> - size of the points (markers) forming curve lines.
-
-- <b>Background color</b> of the XY plot.
+ - <b>Highlighted legend font color</b> - this submenu allows to select the color of the font of the selected legend item.
- <b>Deviation marker</b> allows specifying the properties of the
marker, which is used for drawing deviations data.
\image html pref_salome_plot2dviewer.png
-- <b>Show legend</b> - this options specifies if it's necessary to
-show legend by default.
-- <b>Legend Position</b> - this submenu allows to set the default position
-of the legend, it can be located to the left, to the right, on top or
-on bottom of the graph.
-- <b>Legend font</b> - this allows to set type and face for the font of Legend item.
-- <b>Curve Type</b> - this allows to set the representation of graphs in
-your presentations. You can see only <b>Points</b>, points connected with
-<b>Lines</b> or points connected with smooth <b>Splines</b>.
-- <b>Marker Size</b> - this submenu allows you to set the size of
-markers in your graphs.
-- <b>Horizontal</b> and <b>Vertical axis scale</b> - this submenus allow you to set
-the scale for vertical and horizontal axes. It can be either <b>Linear</b> or
-<b>Logarithmic</b>. Note that the <b>Logarithmic</b> scale can be used only
-if the minimum value of corresponding component (abscissa or ordinate)
-of all points displayed in the viewer is greater than zero.
-If this condition is not met, the scale is switched to <b>Linear</b>
-automatically, even if it is set to <b>Logarithmic</b>.
- <b>Background color</b> - this submenu allows to select the background
color. Click on the colored line to access to the
\ref select_color_and_font_page "Select Color" dialog box.
-- <b>Legend font color</b> - this allows to select the color of the
-font of the legend item.
-- <b>Highlighted legend font color</b> - this submenu allows to select
-the color of the font of the selected legend item.
- <b>Selection color</b> - this submenu allows to select the color of
selected object in the viewer.
-- <b>Deviation marker color</b> - this submenu allows to select the
-color of the deviation marker.
-- <b>Deviation marker line width</b> allows to define line width of
-the deviation marker.
-- <b>Deviation marker tick size</b> allows to define size of the upper
-and lower horizontal lines of the deviation marker.
+- <b>Viewer</b> - allows specifying the properties of the Plot 2D Viewer.
+ - <b>Curve Type</b> - this allows to set the representation of graphs in
+ your presentations. You can see only <b>Points</b>, points connected with
+ <b>Lines</b> or points connected with smooth <b>Splines</b>.
+ - <b>Marker Size</b> - this submenu allows you to set the size of
+ markers in your graphs.
+ - <b>Horizontal</b> and <b>Vertical axis scale</b> - this submenus allow you to set
+ the scale for vertical and horizontal axes. It can be either <b>Linear</b> or
+ <b>Logarithmic</b>. Note that the <b>Logarithmic</b> scale can be used only
+ if the minimum value of corresponding component (abscissa or ordinate)
+ of all points displayed in the viewer is greater than zero.
+ If this condition is not met, the scale is switched to <b>Linear</b>
+ automatically, even if it is set to <b>Logarithmic</b>.
+ - <b>Deviation marker color</b> - this submenu allows to select the
+ color of the deviation marker.
+ - <b>Deviation marker line width</b> allows to define line width of
+ the deviation marker.
+ - <b>Deviation marker tick size</b> allows to define size of the upper
+ and lower horizontal lines of the deviation marker.
+- <b>Legend</b> - allows specifying the properties of the legend.
+ - <b>Show legend</b> - this options specifies if it's necessary to
+ show legend by default.
+ - <b>Legend Position</b> - this submenu allows to set the default position
+ of the legend, it can be located to the left, to the right, on top or
+ on bottom of the graph.
+ - <b>Symbol type</b> you can select the type of legend item symbol from "Marker on line"
+ or "Marker above line"
+ - <b>Legend font</b> - this allows to set type and face for the font of Legend item.
+ - <b>Legend font color</b> - this allows to select the color of the
+ font of the legend item.
+ - <b>Highlighted legend font color</b> - this submenu allows to select
+ the color of the font of the selected legend item.
<br><h2>Directories Preferences</h2>
int plot2dGroup = pref->addPreference( tr( "PREF_GROUP_PLOT2DVIEWER" ), salomeCat ); //viewTab
//pref->setItemProperty( "columns", 2, plot2dGroup );
- // ... -> show legend
- pref->addPreference( tr( "PREF_SHOW_LEGEND" ), plot2dGroup,
- LightApp_Preferences::Bool, "Plot2d", "ShowLegend" );
- // ... -> legend position
- int legendPosition = pref->addPreference( tr( "PREF_LEGEND_POSITION" ), plot2dGroup,
- LightApp_Preferences::Selector, "Plot2d", "LegendPos" );
- aValuesList.clear();
- anIndicesList.clear();
- aValuesList << tr("PREF_LEFT") << tr("PREF_RIGHT") << tr("PREF_TOP") << tr("PREF_BOTTOM");
- anIndicesList << 0 << 1 << 2 << 3 ;
- pref->setItemProperty( "strings", aValuesList, legendPosition );
- pref->setItemProperty( "indexes", anIndicesList, legendPosition );
- // ... -> legend font
- pref->addPreference( tr( "PREF_LEGEND_FONT" ), plot2dGroup, LightApp_Preferences::Font, "Plot2d", "LegendFont" );
- // ... -> curve type
- int curveType = pref->addPreference( tr( "PREF_CURVE_TYPE" ), plot2dGroup,
+ // ... -> background
+ pref->addPreference( tr( "PREF_VIEWER_BACKGROUND_COLOR" ), plot2dGroup,
+ LightApp_Preferences::Color, "Plot2d", "Background" );
+ // ... -> selection color
+ pref->addPreference( tr( "PREF_VIEWER_SELECTION" ), plot2dGroup,
+ LightApp_Preferences::Color, "Plot2d", "SelectionColor" );
+
+ // ... "Viewer" group <<start>>
+ int plot2dViewerGroup = pref->addPreference( tr( "PREF_GROUP_VIEWER" ), plot2dGroup );
+
+ // .... -> curve type
+ int curveType = pref->addPreference( tr( "PREF_CURVE_TYPE" ), plot2dViewerGroup,
LightApp_Preferences::Selector, "Plot2d", "CurveType" );
aValuesList.clear();
anIndicesList.clear();
anIndicesList << 0 << 1 << 2 ;
pref->setItemProperty( "strings", aValuesList, curveType );
pref->setItemProperty( "indexes", anIndicesList, curveType );
- // ... -> marker size
- int markerSize = pref->addPreference( tr( "PREF_MARKER_SIZE" ), plot2dGroup,
+ // .... -> marker size
+ int markerSize = pref->addPreference( tr( "PREF_MARKER_SIZE" ), plot2dViewerGroup,
LightApp_Preferences::IntSpin, "Plot2d", "MarkerSize" );
pref->setItemProperty( "min", 0, markerSize );
pref->setItemProperty( "max", 100, markerSize );
- // ... -> horizontal scaling mode
- int horScale = pref->addPreference( tr( "PREF_HOR_AXIS_SCALE" ), plot2dGroup,
+ // .... -> horizontal scaling mode
+ int horScale = pref->addPreference( tr( "PREF_HOR_AXIS_SCALE" ), plot2dViewerGroup,
LightApp_Preferences::Selector, "Plot2d", "HorScaleMode" );
aValuesList.clear();
anIndicesList.clear();
anIndicesList << 0 << 1 ;
pref->setItemProperty( "strings", aValuesList, horScale );
pref->setItemProperty( "indexes", anIndicesList, horScale );
- // ... -> vertical scaling mode
- int verScale = pref->addPreference( tr( "PREF_VERT_AXIS_SCALE" ), plot2dGroup,
+ // .... -> vertical scaling mode
+ int verScale = pref->addPreference( tr( "PREF_VERT_AXIS_SCALE" ), plot2dViewerGroup,
LightApp_Preferences::Selector, "Plot2d", "VerScaleMode" );
pref->setItemProperty( "strings", aValuesList, verScale );
pref->setItemProperty( "indexes", anIndicesList, verScale );
- // ... -> background
- pref->addPreference( tr( "PREF_VIEWER_BACKGROUND_COLOR" ), plot2dGroup,
- LightApp_Preferences::Color, "Plot2d", "Background" );
- // ... -> font color
- pref->addPreference( tr( "PREF_FONT_COLOR" ), plot2dGroup, LightApp_Preferences::Color, "Plot2d", "LegendFontColor" );
- // ... -> selection font color
- pref->addPreference( tr( "PREF_SELECTED_FONT_COLOR" ), plot2dGroup, LightApp_Preferences::Color, "Plot2d", "SelectedLegendFontColor" );
- // ... -> selection color
- pref->addPreference( tr( "PREF_VIEWER_SELECTION" ), plot2dGroup,
- LightApp_Preferences::Color, "Plot2d", "SelectionColor" );
- // ... -> errors/deviation colot
- pref->addPreference( tr( "PREF_DEVIATION_COLOR" ), plot2dGroup,
+
+ // .... -> errors/deviation colot
+ pref->addPreference( tr( "PREF_DEVIATION_COLOR" ), plot2dViewerGroup,
LightApp_Preferences::Color, "Plot2d", "DeviationMarkerColor" );
- // ... -> deviation markers line size
- int deviationMarkerLw = pref->addPreference( tr( "PREF_DEVIATION_MARKER_LW" ), plot2dGroup,
+ // .... -> deviation markers line size
+ int deviationMarkerLw = pref->addPreference( tr( "PREF_DEVIATION_MARKER_LW" ), plot2dViewerGroup,
LightApp_Preferences::IntSpin, "Plot2d", "DeviationMarkerLineWidth" );
pref->setItemProperty( "min", 1, deviationMarkerLw );
pref->setItemProperty( "max", 5, deviationMarkerLw );
- // ... -> deviation markers tick mark size
- int deviationMarkerTs = pref->addPreference( tr( "PREF_DEVIATION_MARKER_TS" ), plot2dGroup,
+ // .... -> deviation markers tick mark size
+ int deviationMarkerTs = pref->addPreference( tr( "PREF_DEVIATION_MARKER_TS" ), plot2dViewerGroup,
LightApp_Preferences::IntSpin, "Plot2d", "DeviationMarkerTickSize" );
pref->setItemProperty( "min", 1, deviationMarkerTs );
pref->setItemProperty( "max", 5, deviationMarkerTs );
+ // .... "Viewer" group <<end>>
+
+ // ... "Legend" group <<start>>
+ int plot2dLegendGroup = pref->addPreference( tr( "PREF_GROUP_LEGEND" ), plot2dGroup );
+
+ // .... -> show legend
+ pref->addPreference( tr( "PREF_SHOW_LEGEND" ), plot2dLegendGroup,
+ LightApp_Preferences::Bool, "Plot2d", "ShowLegend" );
+ // .... -> legend position
+ int legendPosition = pref->addPreference( tr( "PREF_LEGEND_POSITION" ), plot2dLegendGroup,
+ LightApp_Preferences::Selector, "Plot2d", "LegendPos" );
+ aValuesList.clear();
+ anIndicesList.clear();
+ aValuesList << tr("PREF_LEFT") << tr("PREF_RIGHT") << tr("PREF_TOP") << tr("PREF_BOTTOM");
+ anIndicesList << 0 << 1 << 2 << 3 ;
+ pref->setItemProperty( "strings", aValuesList, legendPosition );
+ pref->setItemProperty( "indexes", anIndicesList, legendPosition );
+ // .... -> Symbol type
+ int legendSymbolType = pref->addPreference( tr( "PREF_LEGEND_SYMBOL_TYPE" ), plot2dLegendGroup,
+ LightApp_Preferences::Selector, "Plot2d", "LegendSymbolType" );
+ aValuesList.clear();
+ anIndicesList.clear();
+ aValuesList << tr("PREF_MARKER_ON_LINE") << tr("PREF_MARKER_ABOVE_LINE");
+ anIndicesList << 0 << 1 ;
+ pref->setItemProperty( "strings", aValuesList, legendSymbolType );
+ pref->setItemProperty( "indexes", anIndicesList, legendSymbolType );
+ // .... -> legend font
+ pref->addPreference( tr( "PREF_LEGEND_FONT" ), plot2dLegendGroup, LightApp_Preferences::Font, "Plot2d", "LegendFont" );
+ // ... -> font color
+ pref->addPreference( tr( "PREF_FONT_COLOR" ), plot2dLegendGroup, LightApp_Preferences::Color, "Plot2d", "LegendFontColor" );
+ // ... -> selection font color
+ pref->addPreference( tr( "PREF_SELECTED_FONT_COLOR" ), plot2dLegendGroup, LightApp_Preferences::Color, "Plot2d", "SelectedLegendFontColor" );
+ // ... "Legend" group <<end>>
+
// .. "Plot2d viewer" group <<end>>
// .. "Directories" preferences tab <<start>>
}
#ifndef DISABLE_PLOT2DVIEWER
- if ( sec == "Plot2d" ) {
- if( param == "SelectionColor" ) {
- QColor c = resMgr->colorValue( sec, param );
- Plot2d_Object::setSelectionColor(c);
- }
- else if (param == "SelectedLegendFontColor") {
- QColor c = resMgr->colorValue( sec, param );
- Plot2d_Object::setHighlightedLegendTextColor(c);
+ QList<SUIT_ViewManager*> lst;
+ viewManagers( Plot2d_Viewer::Type(), lst );
+ QListIterator<SUIT_ViewManager*> itPlot2d( lst );
+ while ( itPlot2d.hasNext() ) {
+ SUIT_ViewManager* viewMgr = itPlot2d.next();
+ SUIT_ViewModel* vm = viewMgr->getViewModel();
+ if ( !vm || !vm->inherits( "Plot2d_Viewer" ) )
+ continue;
+
+ Plot2d_Viewer* Plot2dVM = dynamic_cast<Plot2d_Viewer*>( vm );
+
+ viewMgr->setViewModel( vm );
+ Plot2d_ViewWindow* wnd = dynamic_cast<Plot2d_ViewWindow*>( viewMgr->getActiveView() );
+ if( wnd ) {
+ Plot2d_ViewFrame* frame = wnd->getViewFrame();
+ frame->SetPreference();
}
}
#endif
<parameter name="CurveType" value="1" />
<parameter name="HorScaleMode" value="0" />
<parameter name="LegendPos" value="1" />
+ <parameter name="LegendSymbolType" value="0" />
<parameter name="LegendFont" value="Helvetic,12" />
<parameter name="LegendFontColor" value="0, 0, 0" />
<parameter name="SelectedLegendFontColor" value="255, 255, 255" />
<source>PREF_GROUP_PLOT2DVIEWER</source>
<translation>Plot 2D Viewer</translation>
</message>
+ <message>
+ <source>PREF_GROUP_VIEWER</source>
+ <translation>Viewer</translation>
+ </message>
+ <message>
+ <source>PREF_GROUP_LEGEND</source>
+ <translation>Legend</translation>
+ </message>
+ <message>
+ <source>PREF_LEGEND_SYMBOL_TYPE</source>
+ <translation>Symbol type:</translation>
+ </message>
+ <message>
+ <source>PREF_MARKER_ABOVE_LINE</source>
+ <translation>Marker above line</translation>
+ </message>
+ <message>
+ <source>PREF_MARKER_ON_LINE</source>
+ <translation>Marker on line</translation>
+ </message>
<message>
<source>PREF_DEVIATION_COLOR</source>
<translation>Deviation marker color</translation>
<source>PREF_GROUP_PLOT2DVIEWER</source>
<translation>Scène Plot2d</translation>
</message>
+ <message>
+ <source>PREF_GROUP_VIEWER</source>
+ <translation>Scène</translation>
+ </message>
+ <message>
+ <source>PREF_GROUP_LEGEND</source>
+ <translation>Légende</translation>
+ </message>
+ <message>
+ <source>PREF_LEGEND_SYMBOL_TYPE</source>
+ <translation>Type de symbole:</translation>
+ </message>
+ <message>
+ <source>PREF_MARKER_ABOVE_LINE</source>
+ <translation>Marqueur dessus de la ligne</translation>
+ </message>
+ <message>
+ <source>PREF_MARKER_ON_LINE</source>
+ <translation>Marqueur sur la ligne</translation>
+ </message>
<message>
<source>PREF_DEVIATION_COLOR</source>
<translation>Couleur des marqueurs de déviation</translation>
if ( anItem && anItem->rtti() == rtti ) {
QwtPlotCurve* crv = dynamic_cast<QwtPlotCurve*>( anItem );
if ( crv ) {
- QwtSymbol::Style aStyle = crv->symbol().style();
+ QwtSymbol::Style aStyle = crv->symbol()->style();
QColor aColor = crv->pen().color();
Qt::PenStyle aLine = crv->pen().style();
ok = closeColors( aColor, color ) && aStyle == typeMarker && aLine == typeLine;
#endif
#include <qwt_symbol.h>
-#include <Qt>
+#include <QString>
+#include <QColor>
+#include <QPixmap>
class QPainter;
class QwtPlot;
aCurve->setSelected(isSelected());
aCurve->setPen( QPen(aColor , lineW, ps ) );
- aCurve->setSymbol( QwtSymbol( ms, QBrush( aColor ),
- QPen( aColor ),
- QSize( markerS , markerS ) ) );
+ aCurve->setSymbol( new QwtSymbol( ms, QBrush( aColor ),
+ QPen( aColor ),
+ QSize( markerS , markerS ) ) );
aCurve->setLegendPen(QPen(getColor(), getLineWidth(), ps ));
- aCurve->setLegendSymbol( QwtSymbol( ms, QBrush( getColor() ),
- QPen( getColor() ),
- QSize( getMarkerSize() , getMarkerSize() )));
+ aCurve->setLegendSymbol( new QwtSymbol( ms, QBrush( getColor() ),
+ QPen( getColor() ),
+ QSize( getMarkerSize() , getMarkerSize() )));
double *x, *y;
long nb = getData( &x, &y );
- aCurve->setData( x, y, nb );
+ aCurve->setSamples( x, y, nb );
aCurve->setTitle(getName());
}
*/
bool Plot2d_AnalyticalCurve::checkCurve( const QwtPlot* thePlot) {
if( !myExpression.isEmpty() && thePlot ) {
- const QwtScaleDiv* div = thePlot->axisScaleDiv(QwtPlot::xBottom);
- setRangeBegin(div->lowerBound());
- setRangeEnd(div->upperBound());
- calculate();
+ const QwtScaleDiv div = thePlot->axisScaleDiv(QwtPlot::xBottom);
+ setRangeBegin(div.lowerBound());
+ setRangeEnd(div.upperBound());
+ calculate();
}
return myState == Plot2d_AnalyticalCurve::StateOk;
}
aCurve->setSelected(isSelected());
aCurve->setPen( QPen(aColor , lineW, ps ) );
- aCurve->setSymbol( QwtSymbol( ms, QBrush( aColor ),
- QPen( aColor ),
- QSize( markerS , markerS ) ) );
+ aCurve->setSymbol( new QwtSymbol( ms, QBrush( aColor ),
+ QPen( aColor ),
+ QSize( markerS , markerS ) ) );
aCurve->setLegendPen(QPen(getColor(), getLineWidth(), ps ));
- aCurve->setLegendSymbol( QwtSymbol( ms, QBrush( getColor() ),
- QPen( getColor() ),
- QSize( getMarkerSize() , getMarkerSize() )));
+ aCurve->setLegendSymbol( new QwtSymbol( ms, QBrush( getColor() ),
+ QPen( getColor() ),
+ QSize( getMarkerSize() , getMarkerSize() )));
double *x, *y, *min, *max;
long nb = getData( &x, &y );
if(nb > 0 && x && y) {
- aCurve->setData( x, y, nb );
+ aCurve->setSamples( x, y, nb );
delete [] x;
delete [] y;
QList<int> idx;
aCurve->clearDeviationData();
}
} else {
- aCurve->setData( NULL, NULL, 0 );
+ aCurve->setSamples( NULL, NULL, 0 );
}
}
/*!
Gets data
*/
-QwtIntervalData Plot2d_Histogram::getData() const
+QwtIntervalSeriesData Plot2d_Histogram::getData() const
{
pointList aPoints = getPointList();
int aSize = aPoints.size();
- QwtArray<QwtDoubleInterval> anIntervals( aSize );
- QwtArray<double> aValues( aSize );
+ QwtArray<QwtIntervalSample> anIntervals( aSize );
double aX;
double aWidth = myWidth <= 0 ? myDefWidth : myWidth; // VSR: width is either manually assigned or auto-calculated
for ( int i = 0; i < aSize; i++ ) {
aX = aPoints[i].x;
- anIntervals[i] = QwtDoubleInterval( aX - aWidth/2, aX + aWidth/2 );
- aValues[i] = aPoints[i].y;
+ anIntervals[i] = QwtIntervalSample( aPoints[i].y, aX - aWidth/2, aX + aWidth/2 );
}
- return QwtIntervalData( anIntervals, aValues );
+ return QwtIntervalSeriesData( anIntervals );
}
/*!
#include "Plot2d.h"
#include "Plot2d_Object.h"
-#include <qwt_interval_data.h>
+#include <qwt_series_data.h>
class PLOT2D_EXPORT Plot2d_Histogram : public Plot2d_Object
{
virtual ~Plot2d_Histogram();
Plot2d_Histogram& operator= ( const Plot2d_Histogram& );
- virtual int rtti();
- virtual QwtPlotItem* createPlotItem();
- virtual void autoFill( const QwtPlot* );
- virtual void updatePlotItem( QwtPlotItem* );
+ virtual int rtti();
+ virtual QwtPlotItem* createPlotItem();
+ virtual void autoFill( const QwtPlot* );
+ virtual void updatePlotItem( QwtPlotItem* );
- void setData( const QList<double>&, const QList<double>& );
- QwtIntervalData getData() const;
+ void setData( const QList<double>&, const QList<double>& );
+ QwtIntervalSeriesData getData() const;
- void setColor( const QColor& );
- QColor getColor() const;
+ void setColor( const QColor& );
+ QColor getColor() const;
- void setWidth( const double );
- double getWidth( const bool ) const;
+ void setWidth( const double );
+ double getWidth( const bool ) const;
- static double getMinInterval( const QList<double>& );
+ static double getMinInterval( const QList<double>& );
protected:
- QColor getNextColor( const QwtPlot* );
- bool existColor( const QwtPlot*, const QColor& );
+ QColor getNextColor( const QwtPlot* );
+ bool existColor( const QwtPlot*, const QColor& );
private:
- QColor myColor;
- double myWidth;
- double myDefWidth;
+ QColor myColor;
+ double myWidth;
+ double myDefWidth;
};
#endif // PLOT2D_HISTOGRAM_H
#include "Plot2d_Object.h"
-#ifndef NO_SUIT
-#include <SUIT_Session.h>
-#include <SUIT_ResourceMgr.h>
-#endif
-
// Static members
QColor Plot2d_Object::mySelectionColor;
QColor Plot2d_Object::myHighlightedLegendTextColor;
-/*
- * Read colors from the resource manager.
-*/
-void Plot2d_Object::initColors() {
-#ifndef NO_SUIT
- SUIT_Session* session = SUIT_Session::session();
- if(!session)
- return;
-
- SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
- if(resMgr) {
- mySelectionColor = resMgr->colorValue( "Plot2d", "SelectionColor", QColor(80,80,80) );
- myHighlightedLegendTextColor = resMgr->colorValue( "Plot2d", "SelectedLegendFontColor", QColor(255,255,255) );
- }
-#else
- mySelectionColor = QColor(80,80,80);
- myHighlightedLegendTextColor = QColor(255,255,255);
-#endif
-}
/*!
Constructor
return;
if ( theItem->yAxis() != getYAxis() || theItem->xAxis() != getXAxis() ) {
- theItem->setAxis( getXAxis(), getYAxis() );
+ theItem->setAxes( getXAxis(), getYAxis() );
QwtPlot* aPlot = theItem->plot();
if ( aPlot ) {
void setSelected(const bool);
bool isSelected() const;
- static void initColors();
-
static void setSelectionColor(const QColor& c);
static QColor selectionColor();
#include "Plot2d_PlotItems.h"
#include "Plot2d_Object.h"
+#include "Plot2d_ViewFrame.h"
#include <QPainter>
#include <QPalette>
#include <QLayout>
#include <QLine>
#include <QVariant>
+#include <QStyleOption>
+#include <QPaintEvent>
#include <qwt_plot.h>
#include <qwt_painter.h>
#include <qwt_scale_map.h>
#include <qwt_legend.h>
-#include <qwt_legend_item.h>
+#include <qwt_legend_label.h>
#include <qwt_plot_dict.h>
+const int SPACING = 10;
+const int SYMBOL_SIZE = 13;
+
const char* yAxisLeft[] = {
"12 12 2 1",
" c None",
" "};
/*!
- Constructor of Plot2d_QwtLegendItem
+ Constructor of Plot2d_QwtLegendLabel
*/
-Plot2d_QwtLegendItem::Plot2d_QwtLegendItem( QWidget* parent ) :
- QwtLegendItem( parent ),
+Plot2d_QwtLegendLabel::Plot2d_QwtLegendLabel( QWidget* parent ) :
+ QwtLegendLabel( parent ),
myYAxisIdentifierMode( IM_None ),
- myIsSelected(false)
+ myIsSelected(false),
+ mySymbol( new QwtSymbol() ),
+ mySymbolType(0),
+ myPen( QPen() )
{
myYAxisLeftIcon = yAxisLeft;
myYAxisRightIcon = yAxisRight;
int anIconWidth = qMax( myYAxisLeftIcon.width(), myYAxisRightIcon.width() );
+ setSpacing( SPACING );
mySpacingCollapsed = spacing();
- mySpacingExpanded = anIconWidth - mySpacingCollapsed;
+ mySpacingExpanded = anIconWidth + mySpacingCollapsed;
}
/*!
- Destructor of Plot2d_QwtLegendItem
+ Destructor of Plot2d_QwtLegendLabel
*/
-Plot2d_QwtLegendItem::~Plot2d_QwtLegendItem()
+Plot2d_QwtLegendLabel::~Plot2d_QwtLegendLabel()
{
}
/*!
Set Y axis identifier displaying mode
*/
-void Plot2d_QwtLegendItem::setYAxisIdentifierMode( const int theMode )
+void Plot2d_QwtLegendLabel::setYAxisIdentifierMode( const int theMode )
{
myYAxisIdentifierMode = theMode;
setSpacing( theMode == IM_None ? mySpacingCollapsed : mySpacingExpanded );
}
/*!
- Redefined method of drawing identifier of legend item
+ Paint the identifier to a given rect.
+ \param painter Painter
+ \param rect Rect where to paint
*/
-void Plot2d_QwtLegendItem::drawIdentifier( QPainter* painter, const QRect& rect ) const
+void Plot2d_QwtLegendLabel::drawIdentifier( QPainter* painter, const QRect& rect )
{
- QwtLegendItem::drawIdentifier( painter, rect );
+ if ( rect.isEmpty() )
+ return;
+ if( myPen.style() != Qt::NoPen ) {
+ painter->save();
+ painter->setPen(myPen);
+ QwtPainter::drawLine( painter, rect.left() - 2, rect.center().y() + mySymbolType * 4,
+ rect.right() + 2, rect.center().y() + mySymbolType * 4 );
+ painter->restore();
+ }
+ if ( mySymbol->style() != QwtSymbol::NoSymbol )
+ {
+ QRect symbolRect;
+ symbolRect.setSize( QSize( SYMBOL_SIZE, SYMBOL_SIZE ) );
+ symbolRect.moveCenter( QPoint( rect.center().x(), rect.center().y() - mySymbolType * 4 ) );
+ painter->save();
+ painter->setBrush( mySymbol->brush() );
+ painter->setPen( mySymbol->pen() );
+ mySymbol->drawSymbol( painter, symbolRect );
+ painter->restore();
+ }
if( myYAxisIdentifierMode != IM_None ) {
QPixmap aPixmap( myYAxisIdentifierMode == IM_Left ? yAxisLeft : yAxisRight );
painter->save();
/*!
Update highliting on the item.
*/
-void Plot2d_QwtLegendItem::updateHighlit() {
+void Plot2d_QwtLegendLabel::updateHighlit() {
QwtText txt = text();
- if(isSelected()) {
+ if( isSelected() ) {
QColor highlightColor = Plot2d_Object::selectionColor();
- if(highlightColor != txt.backgroundBrush().color()) {
- txt.setBackgroundBrush(highlightColor);
+ if( highlightColor != txt.backgroundBrush().color() ) {
+ txt.setBackgroundBrush( highlightColor );
setText(txt);
}
- } else if( QWidget* parent = qobject_cast<QWidget*>(this->parent()->parent()) ) {
- QPalette aPal = parent->palette();
- if(aPal.color(QPalette::Background) != txt.backgroundBrush().color()) {
- txt.setBackgroundBrush(aPal.color(QPalette::Background));
- setText(txt);
+ }
+ else if( this->parent() ) {
+ if(QWidget* parent = qobject_cast<QWidget*>( this->parent()->parent() ) ) {
+ QPalette aPal = parent->palette();
+ if( aPal.color( QPalette::Background) != txt.backgroundBrush().color() ) {
+ txt.setBackgroundBrush( aPal.color( QPalette::Background ) );
+ setText( txt );
+ }
}
}
}
/*!
Sets selected property.
*/
-void Plot2d_QwtLegendItem::setSelected(const bool on) {
+void Plot2d_QwtLegendLabel::setSelected(const bool on) {
myIsSelected = on;
}
/*!
Gets selected property.
*/
-bool Plot2d_QwtLegendItem::isSelected() const {
+bool Plot2d_QwtLegendLabel::isSelected() const {
return myIsSelected;
}
/*
Draw text of the item.
*/
-void Plot2d_QwtLegendItem::drawText(QPainter * painter, const QRect &rect) {
+void Plot2d_QwtLegendLabel::drawText( QPainter * painter, const QRectF &rect ) {
painter->setPen( isSelected() ? Plot2d_Object::highlightedLegendTextColor() :
- getColorFromPalette( QPalette::Text) );
+ getColorFromPalette( QPalette::Text) );
- QwtLegendItem::drawText( painter, rect );
+ QwtTextLabel::drawText( painter, rect );
+}
+
+/*!
+ Sets symbol.
+*/
+void Plot2d_QwtLegendLabel::setSymbol( const QwtSymbol* theSymbol )
+{
+ mySymbol = new QwtSymbol( theSymbol->style(), theSymbol->brush(),
+ theSymbol->pen(), theSymbol->size() );
+}
+
+/*!
+ Sets symbol type 0(marker on line) or 1(marker above line).
+*/
+void Plot2d_QwtLegendLabel::setSymbolType( const int theType )
+{
+ mySymbolType = theType;
+}
+
+/*!
+ Sets pen.
+*/
+void Plot2d_QwtLegendLabel::setPen (const QPen& thePen )
+{
+ myPen = thePen;
+}
+
+/*!
+ Redefined method paintEvent of QwtLegendLabel
+*/
+void Plot2d_QwtLegendLabel::paintEvent( QPaintEvent *e )
+{
+ const QRect cr = contentsRect();
+
+ int ButtonFrame = 6;
+ QPainter painter( this );
+ painter.setClipRegion( e->region() );
+
+ if ( isDown() )
+ {
+ qDrawWinButton( &painter, 0, 0, width(), height(),
+ palette(), true );
+ }
+
+ painter.save();
+ painter.setClipRect( cr );
+
+ drawContents( &painter );
+
+ QRect iconRect = cr;
+ if ( !icon().isNull() )
+ {
+ if ( itemMode() != QwtLegendData::ReadOnly )
+ iconRect.setX( iconRect.x() + ButtonFrame );
+ iconRect.setSize( QSize( icon().size().width() + spacing() ,
+ icon().size().height() + spacing() ) );
+ iconRect.moveCenter( QPoint( iconRect.center().x(), cr.center().y() ) );
+ }
+
+ drawIdentifier( &painter, iconRect );
+
+ painter.restore();
}
/*
Get color from the legend pallete by 'role' flag.
*/
-QColor Plot2d_QwtLegendItem::getColorFromPalette(QPalette::ColorRole role) {
+QColor Plot2d_QwtLegendLabel::getColorFromPalette(QPalette::ColorRole role) {
QWidget* pw = parentWidget();
QColor col = palette().color( role );
while( pw ) {
/*!
Redefined method, which updates legend of the curve
*/
-void Plot2d_QwtPlotCurve::updateLegend( QwtLegend* legend ) const
+void Plot2d_QwtPlotCurve::updateLegend( const QwtPlotItem* thePlotItem,
+ const QList<QwtLegendData>& theLegendData )
{
- if ( !legend )
+ if ( !thePlotItem || !thePlotItem->plot() )
return;
- QWidget* widget = legend->find( this );
-
- if ( testItemAttribute(QwtPlotItem::Legend) ) {
-
- if ( widget == NULL ) {
- widget = legendItem();
- if ( widget ) {
- if ( widget->inherits("QwtLegendItem") ) {
- QwtLegendItem *label = (QwtLegendItem *)widget;
- label->setItemMode(legend->itemMode());
-
- if ( plot() ) {
- QObject::connect(label, SIGNAL(clicked()),
- plot(), SLOT(legendItemClicked()));
- QObject::connect(label, SIGNAL(checked(bool)),
- plot(), SLOT(legendItemChecked(bool)));
- }
- }
- legend->contentsWidget()->layout()->addWidget(widget);
- legend->insert(this, widget);
- }
- }
-
- QwtPlotCurve::updateLegend( legend );
-
+ if ( !testItemAttribute( QwtPlotItem::Legend ) )
+ return;
- if( Plot2d_QwtLegendItem* anItem = dynamic_cast<Plot2d_QwtLegendItem*>( widget ) ) {
- int aMode = Plot2d_QwtLegendItem::IM_None;
- if( myYAxisIdentifierEnabled )
- aMode = myYAxis == QwtPlot::yRight ?
- Plot2d_QwtLegendItem::IM_Right :
- Plot2d_QwtLegendItem::IM_Left;
- anItem->setYAxisIdentifierMode( aMode );
- if(isSelected()) {
- anItem->setCurvePen(legendPen());
- anItem->setSymbol(legendSymbol());
- }
- anItem->setSelected(isSelected());
- anItem->updateHighlit();
- }
+ QwtPlotCurve::updateLegend( thePlotItem, theLegendData );
+
+ const QVariant itemInfo = thePlotItem->plot()->itemToInfo( const_cast< QwtPlotItem *>( thePlotItem ) );
+ QwtLegend* legend = dynamic_cast<QwtLegend*>( thePlotItem->plot()->legend() );
+ QWidget* widget = legend->legendWidget( itemInfo );
+ QwtLegendLabel* label = dynamic_cast<QwtLegendLabel*>( widget );
+ if( Plot2d_QwtLegendLabel* anItem = (Plot2d_QwtLegendLabel*)label ) {
+ int aMode = Plot2d_QwtLegendLabel::IM_None;
+ if( myYAxisIdentifierEnabled )
+ aMode = myYAxis == QwtPlot::yRight ?
+ Plot2d_QwtLegendLabel::IM_Right :
+ Plot2d_QwtLegendLabel::IM_Left;
+ anItem->setYAxisIdentifierMode( aMode );
+
+ anItem->setSymbol( legendSymbol() );
+ if( Plot2d_Plot2d* plot = dynamic_cast<Plot2d_Plot2d*>( thePlotItem->plot() ) )
+ anItem->setSymbolType( plot->getLegendSymbolType() );
+ anItem->setPen( legendPen() );
+
+ anItem->setSelected( isSelected() );
+ anItem->updateHighlit();
+ anItem->repaint();
}
}
/*!
- Redefined method, which creates and returns legend item of the curve
+ Redefined method, which updates and calls QwtPlot::autoRefresh() for the parent plot
*/
-QWidget* Plot2d_QwtPlotCurve::legendItem() const
+void Plot2d_QwtPlotCurve::itemChanged()
{
- return new Plot2d_QwtLegendItem;
+ if ( plot() )
+ updateLegend( this, legendData() );
+
+ QwtPlotItem::itemChanged();
}
/*!
Redefined method, which draw a set of points of a curve.
*/
-void Plot2d_QwtPlotCurve::draw(QPainter *painter,
- const QwtScaleMap &xMap, const QwtScaleMap &yMap,
- int from, int to) const
+void Plot2d_QwtPlotCurve::drawSeries( QPainter *painter,
+ const QwtScaleMap &xMap,
+ const QwtScaleMap &yMap,
+ const QRectF &canvasRect,
+ int from, int to) const
{
if (to < 0)
to = dataSize() - 1;
- QwtPlotCurve::draw(painter, xMap, yMap, from, to);
+ QwtPlotCurve::drawSeries(painter, xMap, yMap, canvasRect, from, to);
//draw deviation data
if(hasDeviationData()) {
painter->setPen(p);
for (int i = from; i <= to; i++) {
if(!myDeviationData->values(i,min,max)) continue;
- xi = x(i);
- yi = y(i);
+ const QPointF sample = data()->sample( i );
+ xi = sample.x();
+ yi = sample.y();
xp = xMap.transform(xi);
ytop = yMap.transform(yi + max);
ybtm = yMap.transform(yi - min);
Constructor.
*/
Plot2d_SelectableItem::Plot2d_SelectableItem():
- myIsSelected(false)
+ myIsSelected(false),
+ myLegendSymbol( new QwtSymbol() ),
+ myLegendPen( QPen() )
{
}
/*!
Sets legend symbol property.
*/
-void Plot2d_SelectableItem::setLegendSymbol(const QwtSymbol& s) {
- myLegendSymbol = s;
+void Plot2d_SelectableItem::setLegendSymbol( const QwtSymbol* s ) {
+ myLegendSymbol->setStyle( s->style() );
+ myLegendSymbol->setBrush( s->brush() );
+ myLegendSymbol->setPen( s->pen() );
+ myLegendSymbol->setSize( s->size() );
}
/*!
Sets legend symbol property.
*/
-QwtSymbol Plot2d_SelectableItem::legendSymbol() const {
- return myLegendSymbol;
+QwtSymbol* Plot2d_SelectableItem::legendSymbol() const {
+ return new QwtSymbol( myLegendSymbol->style(), myLegendSymbol->brush(),
+ myLegendSymbol->pen(), myLegendSymbol->size() );
}
/*!
/*!
Sets data to object
*/
-void Plot2d_HistogramQwtItem::setData( const QwtIntervalData& theData )
+void Plot2d_HistogramQwtItem::setData( const QwtIntervalSeriesData& theData )
{
- myData = theData;
+ myData.setSamples( theData.samples() );
itemChanged();
}
/*!
Returns data from object
*/
-const QwtIntervalData& Plot2d_HistogramQwtItem::data() const
+const QwtIntervalSeriesData& Plot2d_HistogramQwtItem::data() const
{
return myData;
}
void Plot2d_HistogramQwtItem::draw( QPainter* thePainter,
const QwtScaleMap& theXMap,
const QwtScaleMap& theYMap,
- const QRect& ) const
+ const QRectF& ) const
{
thePainter->setPen( QPen( myColor ) );
for ( int i = 0; i < (int)myData.size(); i++ ) {
if ( myAttributes & Plot2d_HistogramQwtItem::Xfy ) {
- const int x2 = theXMap.transform( myData.value( i ) );
+ const int x2 = theXMap.transform( myData.sample(i).value );
if ( x2 == x0 )
continue;
- int y1 = theYMap.transform( myData.interval( i ).minValue() );
- int y2 = theYMap.transform( myData.interval( i ).maxValue() );
+ int y1 = theYMap.transform( myData.sample( i ).interval.minValue() );
+ int y2 = theYMap.transform( myData.sample( i ).interval.maxValue() );
if ( y1 > y2 )
qSwap( y1, y2 );
if ( i < (int)myData.size() - 2 ) {
- const int yy1 = theYMap.transform( myData.interval(i+1).minValue() );
- const int yy2 = theYMap.transform( myData.interval(i+1).maxValue() );
+ const int yy1 = theYMap.transform( myData.sample(i+1).interval.minValue() );
+ const int yy2 = theYMap.transform( myData.sample(i+1).interval.maxValue() );
if ( y2 == qwtMin( yy1, yy2 ) ) {
- const int xx2 = theXMap.transform( myData.interval(i+1).minValue() );
+ const int xx2 = theXMap.transform( myData.sample(i+1).interval.minValue() );
if ( xx2 != x0 && ( ( xx2 < x0 && x2 < x0 ) ||
( xx2 > x0 && x2 > x0 ) ) ) {
// One pixel distance between neighboured bars
drawBar( thePainter, Qt::Horizontal, QRect( x0, y1, x2 - x0, y2 - y1 ) );
}
else {
- const int y2 = theYMap.transform( myData.value( i ) );
+ const int y2 = theYMap.transform( myData.sample( i ).value );
if ( y2 == y0 )
continue;
- int x1 = theXMap.transform( myData.interval( i ).minValue() );
- int x2 = theXMap.transform( myData.interval( i ).maxValue() );
+ int x1 = theXMap.transform( myData.sample( i ).interval.minValue() );
+ int x2 = theXMap.transform( myData.sample( i ).interval.maxValue() );
if ( x1 > x2 )
qSwap( x1, x2 );
if ( i < (int)myData.size() - 2 ) {
- const int xx1 = theXMap.transform( myData.interval(i+1).minValue() );
- const int xx2 = theXMap.transform( myData.interval(i+1).maxValue() );
+ const int xx1 = theXMap.transform( myData.sample(i+1).interval.minValue() );
+ const int xx2 = theXMap.transform( myData.sample(i+1).interval.maxValue() );
if ( x2 == qwtMin( xx1, xx2 ) ) {
- const int yy2 = theYMap.transform( myData.value(i+1) );
+ const int yy2 = theYMap.transform( myData.sample(i+1).value );
if ( yy2 != y0 && ( ( yy2 < y0 && y2 < y0 ) ||
( yy2 > y0 && y2 > y0 ) ) ) {
// One pixel distance between neighboured bars
/*!
Set to legend item symbol with color of item
*/
-void Plot2d_HistogramItem::updateLegend( QwtLegend* theLegend ) const
+void Plot2d_HistogramItem::updateLegend( QwtPlotItem* thePlotItem,
+ QList<QwtLegendData>& theLegendData )
{
- if ( !theLegend )
+ if ( !thePlotItem || !thePlotItem->plot() )
return;
- Plot2d_HistogramQwtItem::updateLegend( theLegend );
+ Plot2d_HistogramQwtItem::updateLegend( thePlotItem, theLegendData );
- QWidget* theWidget = theLegend->find( this );
- if ( !theWidget || !theWidget->inherits( "QwtLegendItem" ) )
+ const QVariant itemInfo = thePlotItem->plot()->itemToInfo( const_cast< QwtPlotItem *>( thePlotItem ) );
+ QwtLegend *legend = dynamic_cast<QwtLegend *>( thePlotItem->plot()->legend() );
+ QWidget* widget = legend->legendWidget( itemInfo );
+
+ if ( !widget || !widget->inherits( "QwtLegendItem" ) )
return;
- Plot2d_QwtLegendItem* anItem = ( Plot2d_QwtLegendItem* )theWidget;
- QFontMetrics aFMetrics( anItem->font() );
- int aSize = aFMetrics.height();
- QwtSymbol aSymbol( QwtSymbol::Rect, QBrush( legendPen().color() ),
- QPen( legendPen().color() ), QSize( aSize, aSize ) );
- anItem->setSymbol( aSymbol );
- anItem->setIdentifierMode( theLegend->identifierMode()
- | QwtLegendItem::ShowSymbol );
- anItem->setSelected(isSelected());
- anItem->updateHighlit();
- anItem->update();
+ QwtLegendLabel* label = dynamic_cast<QwtLegendLabel*>( widget );
+ if( Plot2d_QwtLegendLabel* anItem = (Plot2d_QwtLegendLabel*)( label ) ) {
+ QFontMetrics aFMetrics( anItem->font() );
+ int aSize = aFMetrics.height();
+ QwtSymbol* aSymbol = new QwtSymbol( QwtSymbol::Rect, QBrush( legendPen().color() ),
+ QPen( legendPen().color() ), QSize( aSize, aSize ) );
+ anItem->setSymbol( aSymbol );
+ if( Plot2d_Plot2d* plot = dynamic_cast<Plot2d_Plot2d*>( thePlotItem->plot() ) )
+ anItem->setSymbolType( plot->getLegendSymbolType() );
+ anItem->setSelected( isSelected() );
+ anItem->updateHighlit();
+ anItem->update();
+ anItem->repaint();
+ }
}
/*!
void Plot2d_HistogramItem::draw( QPainter* thePainter,
const QwtScaleMap& theXMap,
const QwtScaleMap& theYMap,
- const QRect& ) const
+ const QRectF& ) const
{
// nds: clear list of bar items
Plot2d_HistogramItem* anItem = (Plot2d_HistogramItem*)this;
const int x0 = theXMap.transform( baseline() );
const int y0 = theYMap.transform( baseline() );
- const QwtIntervalData& iData = data();
+ const QwtIntervalSeriesData& iData = data();
for ( int i = 0; i < (int)iData.size(); i++ ) {
if ( testHistogramAttribute( Plot2d_HistogramItem::Xfy ) ) {
- const int x2 = theXMap.transform( iData.value( i ) );
+ const int x2 = theXMap.transform( iData.sample(i).value );
if ( x2 == x0 )
continue;
- int y1 = theYMap.transform( iData.interval( i ).minValue() );
- int y2 = theYMap.transform( iData.interval( i ).maxValue() );
+ int y1 = theYMap.transform( iData.sample(i).interval.minValue() );
+ int y2 = theYMap.transform( iData.sample(i).interval.maxValue() );
if ( y1 > y2 )
qSwap( y1, y2 );
if ( i < (int)iData.size() - 2 ) {
- const int yy1 = theYMap.transform( iData.interval(i+1).minValue() );
- const int yy2 = theYMap.transform( iData.interval(i+1).maxValue() );
+ const int yy1 = theYMap.transform( iData.sample(i+1).interval.minValue() );
+ const int yy2 = theYMap.transform( iData.sample(i+1).interval.maxValue() );
if ( y2 == qwtMin( yy1, yy2 ) ) {
- const int xx2 = theXMap.transform( iData.interval(i+1).minValue() );
+ const int xx2 = theXMap.transform( iData.sample(i+1).interval.minValue() );
if ( xx2 != x0 && ( ( xx2 < x0 && x2 < x0 ) ||
( xx2 > x0 && x2 > x0 ) ) ) {
// One pixel distance between neighboured bars
anItem->myBarItems.append( aRect );
}
else {
- const int y2 = theYMap.transform( iData.value( i ) );
+ const int y2 = theYMap.transform( iData.sample(i).value );
if ( y2 == y0 )
continue;
- int x1 = theXMap.transform( iData.interval( i ).minValue() );
- int x2 = theXMap.transform( iData.interval( i ).maxValue() );
+ int x1 = theXMap.transform( iData.sample(i).interval.minValue() );
+ int x2 = theXMap.transform( iData.sample(i).interval.maxValue() );
if ( x1 > x2 )
qSwap( x1, x2 );
if ( i < (int)iData.size() - 2 ) {
- const int xx1 = theXMap.transform( iData.interval(i+1).minValue() );
- const int xx2 = theXMap.transform( iData.interval(i+1).maxValue() );
+ const int xx1 = theXMap.transform( iData.sample(i+1).interval.minValue() );
+ const int xx2 = theXMap.transform( iData.sample(i+1).interval.maxValue() );
if ( x2 == qwtMin( xx1, xx2 ) ) {
- const int yy2 = theYMap.transform( iData.value(i+1) );
+ const int yy2 = theYMap.transform( iData.sample(i+1).value );
if ( yy2 != y0 && ( ( yy2 < y0 && y2 < y0 ) ||
( yy2 > y0 && y2 > y0 ) ) ) {
// One pixel distance between neighboured bars
return myCrossed;
}
-/*!
- Redefined method, which creates and returns legend item of the curve
-*/
-QWidget* Plot2d_HistogramItem::legendItem() const
-{
- return new Plot2d_QwtLegendItem;
-}
-
-
/*!
Draws bar of histogram and on it bars of histograms with lower height.
*/
}
return aRes;
}
+
+Plot2d_QwtLegend::Plot2d_QwtLegend( QWidget *parent ):
+QwtLegend( parent )
+{
+ setAutoFillBackground(true);
+}
+
+Plot2d_QwtLegend::~Plot2d_QwtLegend()
+{
+}
+
+/*!
+ Redefined method, which create a widget to be inserted into the legend.
+*/
+QWidget *Plot2d_QwtLegend::createWidget( const QwtLegendData &data ) const
+{
+ Q_UNUSED( data );
+
+ Plot2d_QwtLegendLabel *label = new Plot2d_QwtLegendLabel();
+ label->setItemMode( defaultItemMode() );
+
+ connect( label, SIGNAL( clicked() ), SLOT( itemClicked() ) );
+ connect( label, SIGNAL( checked( bool ) ), SLOT( itemChecked( bool ) ) );
+
+ return label;
+}
#include "Plot2d.h"
-#include <qwt_legend_item.h>
+#include <qwt_legend_label.h>
+#include <qwt_legend.h>
#include <qwt_plot_item.h>
#include <qwt_plot_curve.h>
-#include <qwt_interval_data.h>
#include <qwt_plot.h>
+#include <qwt_series_data.h>
+#include <qwt_compat.h>
-class PLOT2D_EXPORT Plot2d_QwtLegendItem : public QwtLegendItem
+class PLOT2D_EXPORT Plot2d_QwtLegendLabel : public QwtLegendLabel
{
public:
enum YAxisIdentifierMode { IM_None = 0, IM_Left, IM_Right };
public:
- Plot2d_QwtLegendItem( QWidget* = 0 );
- virtual ~Plot2d_QwtLegendItem();
+ Plot2d_QwtLegendLabel( QWidget* = 0 );
+ virtual ~Plot2d_QwtLegendLabel();
public:
void setYAxisIdentifierMode( const int );
void updateHighlit();
- void setSelected(const bool on);
+ void setSelected( const bool on );
bool isSelected() const;
- QColor getColorFromPalette(QPalette::ColorRole role);
+ QColor getColorFromPalette( QPalette::ColorRole role );
+ void drawIdentifier( QPainter*, const QRect& );
+ void setSymbol( const QwtSymbol* );
+ void setSymbolType( const int );
+ void setPen( const QPen& );
protected:
- virtual void drawIdentifier( QPainter*, const QRect& ) const;
- virtual void drawText(QPainter *, const QRect &);
+ virtual void drawText( QPainter*, const QRectF& );
+ virtual void paintEvent( QPaintEvent* );
private:
int mySpacingCollapsed;
int mySpacingExpanded;
bool myIsSelected;
+ QwtSymbol* mySymbol;
+ int mySymbolType;
+ QPen myPen;
};
class PLOT2D_EXPORT Plot2d_SelectableItem {
public:
- Plot2d_SelectableItem();
- ~Plot2d_SelectableItem();
-
- void setSelected( const bool );
- bool isSelected() const;
-
- void setLegendPen( const QPen & );
- QPen legendPen() const;
-
- void setLegendSymbol( const QwtSymbol& );
- QwtSymbol legendSymbol() const;
-
+ Plot2d_SelectableItem();
+ ~Plot2d_SelectableItem();
+
+ void setSelected( const bool );
+ bool isSelected() const;
+
+ void setLegendPen( const QPen& );
+ QPen legendPen() const;
+
+ void setLegendSymbol( const QwtSymbol* );
+ QwtSymbol* legendSymbol() const;
+
private:
bool myIsSelected;
QPen myLegendPen;
- QwtSymbol myLegendSymbol;
+ QwtSymbol* myLegendSymbol;
};
class PLOT2D_EXPORT Plot2d_QwtPlotCurve : public QwtPlotCurve, public Plot2d_SelectableItem
public:
virtual void setYAxisIdentifierEnabled( const bool );
- virtual void draw(QPainter *p,
- const QwtScaleMap &xMap,
- const QwtScaleMap &yMap,
- int from, int to) const;
+ virtual void drawSeries( QPainter* p,
+ const QwtScaleMap& xMap,
+ const QwtScaleMap& yMap,
+ const QRectF& canvasRect,
+ int from, int to) const;
- void setDeviationData(const double* min, const double* max, const QList<int> &idx);
+ void setDeviationData( const double* min, const double* max, const QList<int>& idx );
bool hasDeviationData() const;
void clearDeviationData();
-
protected:
- virtual void updateLegend( QwtLegend* ) const;
- virtual QWidget* legendItem() const;
+ virtual void updateLegend( const QwtPlotItem*,
+ const QList<QwtLegendData>& );
+ virtual void itemChanged();
QColor deviationMarkerColor() const;
int deviationMarkerLineWidth() const;
int deviationMarkerTickSize() const;
private:
- QwtPlot::Axis myYAxis;
- bool myYAxisIdentifierEnabled;
+ QwtPlot::Axis myYAxis;
+ bool myYAxisIdentifierEnabled;
class Plot2d_DeviationData;
Plot2d_DeviationData* myDeviationData;
explicit Plot2d_HistogramQwtItem( const QwtText& );
virtual ~Plot2d_HistogramQwtItem();
- void setData( const QwtIntervalData& );
- const QwtIntervalData& data() const;
+ void setData( const QwtIntervalSeriesData& );
+ const QwtIntervalSeriesData& data() const;
void setColor( const QColor& );
QColor color() const;
virtual QwtDoubleRect boundingRect() const;
virtual int rtti() const;
virtual void draw( QPainter*, const QwtScaleMap&,
- const QwtScaleMap&, const QRect& ) const;
+ const QwtScaleMap&, const QRectF& ) const;
void setBaseline( double );
double baseline() const;
private:
int myAttributes;
- QwtIntervalData myData;
+ QwtIntervalSeriesData myData;
QColor myColor;
double myReference;
};
explicit Plot2d_HistogramItem( const QwtText& );
virtual ~Plot2d_HistogramItem();
- QList<QRect> getBars() const;
+ QList<QRect> getBars() const;
- virtual void updateLegend( QwtLegend* ) const;
- virtual void draw( QPainter*, const QwtScaleMap&,
- const QwtScaleMap&, const QRect& ) const;
+ virtual void updateLegend( QwtPlotItem*,
+ QList<QwtLegendData>& );
+ virtual void draw( QPainter*, const QwtScaleMap&,
+ const QwtScaleMap&, const QRectF& ) const;
+
+ void setCrossItems( bool theCross );
+ bool isCrossItems() const;
- void setCrossItems( bool theCross );
- bool isCrossItems() const;
+protected:
+ void drawRectAndLowers( QPainter*, Qt::Orientation,
+ const QRect& ) const;
+ int getCrossedTop( const QRect& ) const;
protected:
- void drawRectAndLowers( QPainter*, Qt::Orientation,
- const QRect& ) const;
- int getCrossedTop( const QRect& ) const;
+ QList<QRect> myBarItems;
+ bool myCrossed;
+};
- virtual QWidget* legendItem() const;
+class PLOT2D_EXPORT Plot2d_QwtLegend : public QwtLegend
+{
+public:
+ explicit Plot2d_QwtLegend( QWidget *parent = NULL );
+ virtual ~Plot2d_QwtLegend();
protected:
- QList<QRect> myBarItems;
- bool myCrossed;
+ virtual QWidget* createWidget( const QwtLegendData& ) const;
};
#endif // PLOT2D_PLOTITEMS_H
myCurveCombo->addItem( tr( "PLOT2D_CURVE_TYPE_LINES" ) );
myCurveCombo->addItem( tr( "PLOT2D_CURVE_TYPE_SPLINE" ) );
- // legend
- myLegendCheck = new QCheckBox( tr( "PLOT2D_ENABLE_LEGEND" ), this );
- myLegendCombo = new QComboBox( this );
- myLegendFont = new QtxFontEdit( this );
- myLegendColor = new QtxColorButton( this );
- QLabel* aLegendFontLab = new QLabel( tr( "PLOT2D_LEGEND_FONT" ), this );
- myLegendCombo->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
- myLegendCombo->setMinimumWidth( MIN_COMBO_WIDTH );
- myLegendCombo->addItem( tr( "PLOT2D_LEGEND_POSITION_LEFT" ) );
- myLegendCombo->addItem( tr( "PLOT2D_LEGEND_POSITION_RIGHT" ) );
- myLegendCombo->addItem( tr( "PLOT2D_LEGEND_POSITION_TOP" ) );
- myLegendCombo->addItem( tr( "PLOT2D_LEGEND_POSITION_BOTTOM" ) );
-
// marker size
QLabel* aMarkerLab = new QLabel( tr( "PLOT2D_MARKER_SIZE_LBL" ), this );
myMarkerSpin = new QSpinBox( this );
QLabel* aBGLab = new QLabel( tr( "PLOT2D_BACKGROUND_COLOR_LBL" ), this );
myBackgroundBtn = new QtxColorButton( this );
+ // selection color
+ QLabel* aSelectionLab = new QLabel( tr( "PLOT2D_SELECTION_COLOR_LBL" ), this );
+ mySelectionBtn = new QtxColorButton( this );
+
+ QHBoxLayout* ViewerColorLayout = new QHBoxLayout;
+ ViewerColorLayout->addWidget( aBGLab );
+ ViewerColorLayout->addWidget( myBackgroundBtn );
+ ViewerColorLayout->addStretch();
+ ViewerColorLayout->addWidget( aSelectionLab );
+ ViewerColorLayout->addWidget( mySelectionBtn );
+ ViewerColorLayout->addStretch();
+
+ // legend
+ QGroupBox* aLegendGrp = new QGroupBox( tr( "PLOT2D_LEGEND_GROUP" ), this );
+ QGridLayout* aLegendLayout = new QGridLayout( aLegendGrp );
+ aLegendLayout->setMargin( MARGIN_SIZE ); aLegendLayout->setSpacing( SPACING_SIZE );
+ aLegendGrp->setLayout( aLegendLayout );
+
+ myLegendCheck = new QCheckBox( tr( "PLOT2D_ENABLE_LEGEND" ), this );
+
+ QLabel* aLegendPosition = new QLabel( tr( "PLOT2D_LEGEND_POSITION" ), this );
+ myLegendCombo = new QComboBox( this );
+ myLegendCombo->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
+ myLegendCombo->setMinimumWidth( MIN_COMBO_WIDTH );
+ myLegendCombo->addItem( tr( "PLOT2D_LEGEND_POSITION_LEFT" ) );
+ myLegendCombo->addItem( tr( "PLOT2D_LEGEND_POSITION_RIGHT" ) );
+ myLegendCombo->addItem( tr( "PLOT2D_LEGEND_POSITION_TOP" ) );
+ myLegendCombo->addItem( tr( "PLOT2D_LEGEND_POSITION_BOTTOM" ) );
+
+ QLabel* aLegendSymbolType = new QLabel( tr( "PLOT2D_LEGEND_SYMBOL_TYPE" ), this );
+ myLegendSymbolType = new QComboBox( this );
+ myLegendSymbolType->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
+ myLegendSymbolType->setMinimumWidth( MIN_COMBO_WIDTH );
+ myLegendSymbolType->addItem( tr( "PLOT2D_MARKER_ON_LINE" ) );
+ myLegendSymbolType->addItem( tr( "PLOT2D_MARKER_ABOVE_LINE" ) );
+
+ QLabel* aLegendFontLab = new QLabel( tr( "PLOT2D_LEGEND_FONT" ), this );
+ myLegendFont = new QtxFontEdit( this );
+
+ QLabel* aLegendFontColor = new QLabel( tr( "PLOT2D_LEGEND_FONT_COLOR" ), this );
+ myLegendFontColor = new QtxColorButton( this );
+
+ QLabel* aSelectLegendFontColor = new QLabel( tr( "PLOT2D_SELECTED_LEGEND_FONT_COLOR" ), this );
+ mySelectedLegendFontColor = new QtxColorButton( this );
+
+ QHBoxLayout* FontLayout = new QHBoxLayout;
+ FontLayout->addWidget( aLegendFontColor );
+ FontLayout->addWidget( myLegendFontColor );
+ FontLayout->addStretch();
+ FontLayout->addWidget( aSelectLegendFontColor );
+ FontLayout->addWidget( mySelectedLegendFontColor );
+ FontLayout->addStretch();
+
+ aLegendLayout->addWidget( myLegendCheck, 0, 0 );
+ aLegendLayout->addWidget( aLegendPosition, 1, 0 );
+ aLegendLayout->addWidget( myLegendCombo, 1, 1 );
+ aLegendLayout->addWidget( aLegendSymbolType, 2, 0 );
+ aLegendLayout->addWidget( myLegendSymbolType, 2, 1 );
+ aLegendLayout->addWidget( aLegendFontLab, 3, 0 );
+ aLegendLayout->addWidget( myLegendFont, 3, 1 );
+ aLegendLayout->addLayout( FontLayout, 4, 0, 1, 2 );
+
//Deviation marker parameters
QGroupBox* aDeviationGrp = new QGroupBox( tr( "PLOT2D_DEVIATION_MARKER_TLT" ), this );
QHBoxLayout* aDeviationLayout = new QHBoxLayout(aDeviationGrp);
btnLayout->addWidget( myHelpBtn );
// layout widgets
- topLayout->addWidget( myTitleCheck, 0, 0 );
- topLayout->addWidget( myTitleEdit, 0, 1, 1, 3 );
- topLayout->addWidget( myLegendCheck, 1, 0 );
- topLayout->addWidget( myLegendCombo, 1, 1 );
- topLayout->addWidget( aCurveLab, 1, 2 );
- topLayout->addWidget( myCurveCombo, 1, 3 );
- topLayout->addWidget( aLegendFontLab,2, 0 );
- topLayout->addWidget( myLegendFont, 2, 1 );
- topLayout->addWidget( myLegendColor, 2, 2 );
-
- topLayout->addWidget( aMarkerLab, 3, 0 );
- topLayout->addWidget( myMarkerSpin, 3, 1 );
- QHBoxLayout* bgLayout = new QHBoxLayout;
- bgLayout->addWidget( myBackgroundBtn ); bgLayout->addStretch();
- topLayout->addWidget( aBGLab, 3, 2 );
- topLayout->addLayout( bgLayout, 3, 3 );
- topLayout->addWidget( aDeviationGrp, 4, 0, 1, 4 );
- topLayout->addWidget( aNormalizeGrp, 5, 0, 1, 4 );
- topLayout->addWidget( aScaleGrp, 6, 0, 1, 4 );
- topLayout->addWidget( aTabWidget, 7, 0, 1, 4 );
- topLayout->addWidget( myDefCheck, 8, 0, 1, 4 );
- topLayout->setRowStretch( 9, 5 );
-
- topLayout->addLayout( btnLayout, 10, 0, 1, 4 );
+ topLayout->addWidget( myTitleCheck, 0, 0 );
+ topLayout->addWidget( myTitleEdit, 0, 1, 1, 3 );
+ topLayout->addWidget( aCurveLab, 1, 0 );
+ topLayout->addWidget( myCurveCombo, 1, 1 );
+ topLayout->addWidget( aMarkerLab, 2, 0 );
+ topLayout->addWidget( myMarkerSpin, 2, 1 );
+ topLayout->addLayout( ViewerColorLayout, 3, 0, 1, 4 );
+ topLayout->addWidget( aLegendGrp, 4, 0, 1, 4 );
+ topLayout->addWidget( aDeviationGrp, 5, 0, 1, 4 );
+ topLayout->addWidget( aNormalizeGrp, 6, 0, 1, 4 );
+ topLayout->addWidget( aScaleGrp, 7, 0, 1, 4 );
+ topLayout->addWidget( aTabWidget, 8, 0, 1, 4 );
+ topLayout->addWidget( myDefCheck, 9, 0, 1, 4 );
+ topLayout->setRowStretch( 10, 5 );
+ topLayout->addLayout( btnLayout, 11, 0, 1, 4 );
if ( !showDefCheck )
myDefCheck->hide();
\param col legend font color
\sa isLegendEnabled(), getLegendPos(), getLegendFont()
*/
-void Plot2d_SetupViewDlg::setLegend( bool enable, int pos, const QFont& fnt, const QColor& col )
+void Plot2d_SetupViewDlg::setLegend( bool enable, int pos, int symbolType,
+ const QFont& fnt, const QColor& fontColor, const QColor& selFontColor )
{
myLegendCheck->setChecked( enable );
myLegendCombo->setCurrentIndex( pos );
+ myLegendSymbolType->setCurrentIndex( symbolType );
myLegendFont->setCurrentFont( fnt );
- myLegendColor->setColor( col );
+ myLegendFontColor->setColor( fontColor );
+ mySelectedLegendFontColor->setColor( selFontColor );
onLegendChecked();
}
return myLegendCombo->currentIndex();
}
+/*!
+ \brief Get legend symbol type.
+ \return legend symbol type: 0 (marker on line), 1 (marker above line)
+ \sa setLegend()
+*/
+int Plot2d_SetupViewDlg::getLegendSymbolType()
+{
+ return myLegendSymbolType->currentIndex();
+}
+
/*!
\brief Get legend font.
\return legend font
*/
QColor Plot2d_SetupViewDlg::getLegendColor()
{
- return myLegendColor->color();
+ return myLegendFontColor->color();
+}
+
+/*!
+ \brief Get selected legend font color.
+ \return selected legend font color
+ \sa setLegend()
+*/
+QColor Plot2d_SetupViewDlg::getSelectedLegendColor()
+{
+ return mySelectedLegendFontColor->color();
}
/*!
return myBackgroundBtn->color();
}
+/*!
+ \brief Set selection color.
+ \param color selection color
+ \sa getSelectionColor()
+*/
+void Plot2d_SetupViewDlg::setSelectionColor( const QColor& color )
+{
+ mySelectionBtn->setColor( color );
+}
+
+/*!
+ \brief Get selection color.
+ \return selection color
+ \sa setSelectionColor()
+*/
+QColor Plot2d_SetupViewDlg::getSelectionColor()
+{
+ return mySelectionBtn->color();
+}
+
/*!
\brief Set major grid parameters.
\param enableX if \c true, horizontal major grid is enabled
bool getRMinNormMode();
void setRMinNormMode(const bool);
- void setLegend( bool, int, const QFont&, const QColor& );
+ void setLegend( bool, int, int, const QFont&, const QColor&, const QColor& );
bool isLegendEnabled();
int getLegendPos();
+ int getLegendSymbolType();
QFont getLegendFont();
QColor getLegendColor();
+ QColor getSelectedLegendColor();
void setMarkerSize( const int );
int getMarkerSize();
void setBackgroundColor( const QColor& );
QColor getBackgroundColor();
+ void setSelectionColor( const QColor& );
+ QColor getSelectionColor();
+
void setMajorGrid( bool, const int, bool, const int, bool, const int );
void getMajorGrid( bool&, int&, bool&, int&, bool&, int& );
void setMinorGrid( bool, const int, bool, const int, bool, const int );
QLineEdit* myTitleYEdit;
QLineEdit* myTitleY2Edit;
QtxColorButton* myBackgroundBtn;
- QtxColorButton* myLegendColor;
+ QtxColorButton* mySelectionBtn;
+ QtxColorButton* myLegendFontColor;
+ QtxColorButton* mySelectedLegendFontColor;
QtxFontEdit* myLegendFont;
QCheckBox* myXGridCheck;
QSpinBox* myXGridSpin;
QComboBox* myCurveCombo;
QCheckBox* myLegendCheck;
QComboBox* myLegendCombo;
+ QComboBox* myLegendSymbolType;
QSpinBox* myMarkerSpin;
QComboBox* myXModeCombo;
QComboBox* myYModeCombo;
#include <qwt_scale_engine.h>
#include <qwt_plot_zoomer.h>
#include <qwt_curve_fitter.h>
+#include <qwt_plot_renderer.h>
#include <stdlib.h>
#include <limits>
: QWidget (parent, 0),
myOperation( NoOpId ),
myCurveType( 1 ),
- myShowLegend( true ), myLegendPos( 1 ), myLegendFont("Helvetic",12),
- myLegendColor(Qt::black),
+ myShowLegend( true ), myLegendPos( 1 ), myLegendSymbolType( 0 ), myLegendFont("Helvetic",12),
+ myLegendColor(Qt::black), mySelectedLegendFontColor( Qt::darkBlue ),
myMarkerSize( DEFAULT_MARKER_SIZE ),
myBackground( Qt::white ),
+ mySelectionColor( Qt::gray ),
myTitle( "" ), myXTitle( "" ), myYTitle( "" ), myY2Title( "" ),
myTitleEnabled( true ), myXTitleEnabled( true ),
myYTitleEnabled( true ), myY2TitleEnabled (true),
aLayout->addWidget( myPlot );
- // createActions();
- connect( myPlot, SIGNAL( legendClicked( QwtPlotItem* ) ),
- this, SIGNAL( legendClicked( QwtPlotItem* ) ) );
-
- // IPAL 21465
- /* connect( myPlot->axisWidget( QwtPlot::xBottom ), SIGNAL( scaleDivChanged() ),
- myPlot, SLOT( onScaleDivChanged() ) );
- connect( myPlot->axisWidget( QwtPlot::yLeft ), SIGNAL( scaleDivChanged() ),
- myPlot, SLOT( onScaleDivChanged() ) );
- if (mySecondY)
- connect( myPlot->axisWidget( QwtPlot::yRight ), SIGNAL( scaleDivChanged() ),
- myPlot, SLOT( onScaleDivChanged() ) );*/
#ifndef NO_SUIT
Init();
#endif
/* Initial Setup - get from the preferences */
readPreferences();
- myPlot->setMargin( 5 );
setCurveType( myCurveType, false );
setXGrid( myXGridMajorEnabled, myXGridMaxMajor, myXGridMinorEnabled, myXGridMaxMinor, false );
setYGrid( myYGridMajorEnabled, myYGridMaxMajor, myYGridMinorEnabled, myYGridMaxMinor,
setHorScaleMode( myXMode, false );
setVerScaleMode( myYMode, false );
setBackgroundColor( myBackground );
+ setSelectionColor( mySelectionColor );
setLegendPos( myLegendPos );
+ setLegendSymbolType( myLegendSymbolType );
setLegendFont( myLegendFont );
setLegendFontColor( myLegendColor );
+ setSelectedLegendFontColor( mySelectedLegendFontColor );
showLegend( myShowLegend, false );
myPlot->replot();
}
myPlot->canvas()->installEventFilter( this );
}
+void Plot2d_ViewFrame::SetPreference()
+{
+ readPreferences();
+ setBackgroundColor( myBackground );
+ setSelectionColor( mySelectionColor );
+ setCurveType( myCurveType, true );
+ setMarkerSize( myMarkerSize, true );
+ showLegend( myShowLegend, true );
+ setLegendPos( myLegendPos );
+ setLegendSymbolType( myLegendSymbolType );
+ setLegendFont( myLegendFont );
+ setLegendFontColor( myLegendColor );
+ setSelectedLegendFontColor( mySelectedLegendFontColor );
+ myPlot->replot();
+}
/*!
Gets window's central widget
*/
myShowLegend = resMgr->booleanValue( "Plot2d", "ShowLegend", myShowLegend );
myLegendPos = resMgr->integerValue( "Plot2d", "LegendPos", myLegendPos );
+ myLegendSymbolType = resMgr->integerValue( "Plot2d", "LegendSymbolType", myLegendSymbolType );
myLegendFont = resMgr->fontValue( "Plot2d", "LegendFont", myLegendFont );
myLegendColor = resMgr->colorValue( "Plot2d", "LegendFontColor", myLegendColor );
+ mySelectedLegendFontColor = resMgr->colorValue( "Plot2d", "SelectedLegendFontColor", mySelectedLegendFontColor );
myMarkerSize = resMgr->integerValue( "Plot2d", "MarkerSize", myMarkerSize );
myBackground = resMgr->colorValue( "Plot2d", "Background", myBackground );
+ mySelectionColor = resMgr->colorValue( "Plot2d", "SelectionColor", mySelectionColor );
myTitleEnabled = resMgr->booleanValue( "Plot2d", "ShowTitle", myTitleEnabled );
myXTitleEnabled = resMgr->booleanValue( "Plot2d", "ShowHorTitle", myXTitleEnabled );
resMgr->setValue( "Plot2d", "CurveType", myCurveType );
resMgr->setValue( "Plot2d", "ShowLegend", myShowLegend );
resMgr->setValue( "Plot2d", "LegendPos", myLegendPos );
+ resMgr->setValue( "Plot2d", "LegendSymbolType", myLegendSymbolType );
resMgr->setValue( "Plot2d", "LegendFont", myLegendFont );
resMgr->setValue( "Plot2d", "LegendFontColor", myLegendColor );
+ resMgr->setValue( "Plot2d", "SelectedLegendFontColor", mySelectedLegendFontColor );
resMgr->setValue( "Plot2d", "MarkerSize", myMarkerSize );
resMgr->setValue( "Plot2d", "Background", myBackground );
+ resMgr->setValue( "Plot2d", "SelectionColor", mySelectionColor );
resMgr->setValue( "Plot2d", "ShowTitle", myTitleEnabled );
resMgr->setValue( "Plot2d", "ShowHorTitle", myXTitleEnabled );
resMgr->setValue( "Plot2d", "ShowVerLeftTitle", myYTitleEnabled );
+ resMgr->setValue( "Plot2d", "DeviationMarkerColor", myPlot->property(PLOT2D_DEVIATION_COLOR).value<QColor>() );
+ resMgr->setValue( "Plot2d", "DeviationMarkerLineWidth", myPlot->property(PLOT2D_DEVIATION_LW).toInt() );
+ resMgr->setValue( "Plot2d", "DeviationMarkerTickSize", myPlot->property(PLOT2D_DEVIATION_TS).toInt() );
if ( mySecondY )
resMgr->setValue( "Plot2d", "ShowVerRightTitle", myY2TitleEnabled );
QwtValueList aTicks;
bool xFound = false, yFound = false;
double xCoord, yCoord;
- const QwtScaleDiv* aXscale = myPlot->axisScaleDiv( QwtPlot::xBottom );
- aTicks = aXscale->ticks( QwtScaleDiv::MajorTick );
+ const QwtScaleDiv& aXscale = myPlot->axisScaleDiv( QwtPlot::xBottom );
+ aTicks = aXscale.ticks( QwtScaleDiv::MajorTick );
for ( i = 0; i < aTicks.count(); i++ ) {
double majXmark = aTicks[i];
int xmark = myPlot->transform( QwtPlot::xBottom, majXmark );
}
}
if ( !xFound ) {
- aTicks = aXscale->ticks( QwtScaleDiv::MinorTick );
+ aTicks = aXscale.ticks( QwtScaleDiv::MinorTick );
for ( i = 0; i < aTicks.count(); i++ ) {
double minXmark = aTicks[i];
int xmark = myPlot->transform( QwtPlot::xBottom, minXmark );
}
}
}
- const QwtScaleDiv* aYscale = myPlot->axisScaleDiv( QwtPlot::yLeft );
- aTicks = aYscale->ticks( QwtScaleDiv::MajorTick );
+ const QwtScaleDiv& aYscale = myPlot->axisScaleDiv( QwtPlot::yLeft );
+ aTicks = aYscale.ticks( QwtScaleDiv::MajorTick );
for ( i = 0; i < aTicks.count(); i++ ) {
double majYmark = aTicks[i];
int ymark = myPlot->transform( QwtPlot::yLeft, majYmark );
}
}
if ( !yFound ) {
- aTicks = aYscale->ticks( QwtScaleDiv::MinorTick );
+ aTicks = aYscale.ticks( QwtScaleDiv::MinorTick );
for ( i = 0; i < aTicks.count(); i++ ) {
double minYmark = aTicks[i];
int ymark = myPlot->transform( QwtPlot::yLeft, minYmark );
bool yFound2 = false;
double yCoord2;
- const QwtScaleDiv* aYscale2 = myPlot->axisScaleDiv( QwtPlot::yRight );
- aTicks = aYscale2->ticks( QwtScaleDiv::MajorTick );
+ const QwtScaleDiv& aYscale2 = myPlot->axisScaleDiv( QwtPlot::yRight );
+ aTicks = aYscale2.ticks( QwtScaleDiv::MajorTick );
for ( i = 0; i < aTicks.count(); i++ ) {
double majYmark = aTicks[i];
int ymark = myPlot->transform( QwtPlot::yRight, majYmark );
}
}
if ( !yFound2 ) {
- aTicks = aYscale2->ticks( QwtScaleDiv::MinorTick );
+ aTicks = aYscale2.ticks( QwtScaleDiv::MinorTick );
for ( i = 0; i < aTicks.count(); i++ ) {
double minYmark = aTicks[i];
int ymark = myPlot->transform( QwtPlot::yRight, minYmark );
bool displayLegend, const QList< bool >& sides)
{
// Consider the new legend's entries
- // (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
+ // (PB: to update the legend we must remove it and put a new QwtAbstractLegend in the QwtPlot)
+ myPlot->insertLegend( (QwtAbstractLegend*)NULL); // we remove here, we shall put at the end
int nbAllCurves = curveList.size();
int nbGroups = nbAllCurves / groupSize;
QwtPlotCurve* plotCurve = dynamic_cast<QwtPlotCurve *>(getPlotObject(plot2dCurve));
vectCurve[ig].push_back(plotCurve);
// Modify the points' markers
- QwtSymbol symbol(plotCurve->symbol()) ;
- symbol.setStyle(symbolStyle1);
- symbol.setPen(QPen(color1,lineWidth1));
+ QwtSymbol* symbol = new QwtSymbol(plotCurve->symbol()->style(), plotCurve->symbol()->brush(),
+ plotCurve->symbol()->pen(), plotCurve->symbol()->size()) ;
+ symbol->setStyle(symbolStyle1);
+ symbol->setPen(QPen(color1,lineWidth1));
//symbol.setBrush( QBrush( color1));
//QSize size = 0.5*(symbol.size());
//symbol.setSize(size);
{
if (!displayLegend)
{
- myPlot->insertLegend( (QwtLegend*)NULL);
+ myPlot->insertLegend( (QwtAbstractLegend*)NULL);
}
displayCurve( plot2dCurve);
}
// Modify points' markers
- QwtSymbol symbol (plotCurve->symbol()) ;
- symbol.setStyle( markerKind);
+ QwtSymbol* symbol = new QwtSymbol( plotCurve->symbol()->style(), plotCurve->symbol()->brush(),
+ plotCurve->symbol()->pen(), plotCurve->symbol()->size() ) ;
+ symbol->setStyle( markerKind );
//
if (markerKind != QwtSymbol::NoSymbol)
{
- symbol.setPen( QPen( theColor, lineWidth));
- symbol.setBrush( QBrush( theColor));
- QSize size = 2.0*(symbol.size()); //0.5
- symbol.setSize(size);
+ symbol->setPen( QPen( theColor, lineWidth));
+ symbol->setBrush( QBrush( theColor));
+ QSize size = 2.0*(symbol->size()); //0.5
+ symbol->setSize(size);
}
plotCurve->setSymbol( symbol);
QColor & lineColor,
QwtSymbol::Style markerKind, bool side)
{
- QwtPlotCurve* aPCurve = new QwtPlotCurve();
+ QwtPlotCurve* aPCurve = new QwtPlotCurve( QString::null );
- aPCurve->setData( X, Y, nbPoint);
+ aPCurve->setSamples( X, Y, nbPoint);
aPCurve->setPen( QPen( lineColor, lineWidth, lineKind));
- QwtSymbol aSymbol;
- aSymbol.setStyle( markerKind);
- aPCurve->setSymbol( aSymbol);
+ QwtSymbol* aSymbol;
+ aSymbol->setStyle( markerKind );
+ aPCurve->setSymbol( aSymbol );
// The segment must not have legend's entry
aPCurve->setItemAttribute( QwtPlotItem::Legend, false);
Plot2d_Curve* aCurve = dynamic_cast<Plot2d_Curve*>( object );
if ( aCurve )
{
- //myMarkerSize = 1;
- //aCurve->setMarkerSize( myMarkerSize );
-
- if (aCurve->getMarkerSize() == 0)
- {
- aCurve->setMarkerSize( myMarkerSize );
- }
+ if ( aCurve->getMarkerSize() == 0 )
+ aCurve->setMarkerSize( myMarkerSize );
processFiltering(update);
updatePlotItem( aCurve, anItem );
update legend
*/
void Plot2d_ViewFrame::updateLegend() {
- if ( myPlot->getLegend() ) {
- ObjectDict::iterator it = myObjects.begin();
- for( ; it != myObjects.end(); ++it )
- it.key()->updateLegend(myPlot->getLegend());
+ const QwtPlotItemList& items = myPlot->itemList();
+ QwtPlotItemIterator it;
+ for ( it = items.begin(); it != items.end(); it++ ) {
+ QwtPlotItem* item = *it;
+ if ( item )
+ item->updateLegend( item, item->legendData() );
}
}
*/
void Plot2d_ViewFrame::fitAll()
{
- // Postpone fitAll operation until QwtPlot geometry
- // has been fully defined
- if ( !myPlot->polished() ){
- QApplication::postEvent( this, new QEvent( (QEvent::Type)FITALL_EVENT ) );
- return;
- }
-
- // no need to set auto scaling, it wiil be disabled by setAxisScale() method call
+ // no need to set auto scaling, it will be disabled by setAxisScale() method call
// myPlot->setAxisAutoScale( QwtPlot::yLeft );
// myPlot->setAxisAutoScale( QwtPlot::xBottom );
// myPlot->replot();
if (mySecondY)
dlg->setY2Title( myY2TitleEnabled, myY2Title );
dlg->setCurveType( myCurveType );
- dlg->setLegend( myShowLegend, myLegendPos, myLegendFont, myLegendColor );
+ dlg->setLegend( myShowLegend, myLegendPos, myLegendSymbolType, myLegendFont,
+ myLegendColor, mySelectedLegendFontColor );
dlg->setMarkerSize( myMarkerSize );
dlg->setBackgroundColor( myBackground );
+ dlg->setSelectionColor( mySelectionColor );
dlg->setScaleMode(myXMode, myYMode);
dlg->setLMinNormMode(myNormLMin);
dlg->setLMaxNormMode(myNormLMax);
}
if ( myLegendPos != dlg->getLegendPos() ) {
setLegendPos( dlg->getLegendPos() );
+ }
+ if ( myLegendSymbolType != dlg->getLegendSymbolType() ) {
+ setLegendSymbolType( dlg->getLegendSymbolType() );
}
if ( myLegendFont != dlg->getLegendFont() ) {
setLegendFont( dlg->getLegendFont() );
if ( myLegendColor != dlg->getLegendColor() ) {
setLegendFontColor( dlg->getLegendColor() );
}
+ if ( mySelectedLegendFontColor != dlg->getSelectedLegendColor() ) {
+ setSelectedLegendFontColor( dlg->getSelectedLegendColor() );
+ }
// marker size
if ( myMarkerSize != dlg->getMarkerSize() ) {
if ( myBackground != dlg->getBackgroundColor() ) {
setBackgroundColor( dlg->getBackgroundColor() );
}
+ // selection color
+ if ( mySelectionColor != dlg->getSelectionColor() ) {
+ setSelectionColor( dlg->getSelectionColor() );
+ }
// grid
bool aXGridMajorEnabled, aXGridMinorEnabled, aYGridMajorEnabled, aYGridMinorEnabled,
aY2GridMajorEnabled, aY2GridMinorEnabled;
{
#ifndef DISABLE_PYCONSOLE
if(!c) return;
- QwtScaleDiv* div = myPlot->axisScaleDiv(QwtPlot::xBottom);
- c->setRangeBegin(div->lowerBound());
- c->setRangeEnd(div->upperBound());
+ QwtScaleDiv div = myPlot->axisScaleDiv(QwtPlot::xBottom);
+ c->setRangeBegin(div.lowerBound());
+ c->setRangeEnd(div.upperBound());
c->calculate();
c->setMarkerSize(myMarkerSize);
QwtPlotItem* item = c->plotItem();
if( c->isActive() ) {
c->updatePlotItem();
item->attach( myPlot );
+ item->itemChanged();
item->show();
}
c->setAction(Plot2d_AnalyticalCurve::ActNothing);
{
myShowLegend = show;
if ( myShowLegend ) {
- QwtLegend* legend = myPlot->legend();
- if ( !legend ) {
- legend = new QwtLegend( myPlot );
+ QwtAbstractLegend* absLegend = myPlot->legend();
+ QwtLegend* legend = 0;
+ if ( !absLegend ) {
+ legend = new Plot2d_QwtLegend( myPlot );
+ legend->setDefaultItemMode(QwtLegendData::Clickable);
+ connect( legend, SIGNAL( clicked (const QVariant&, int) ),
+ this, SIGNAL( clicked (const QVariant&, int) ) );
legend->setFrameStyle( QFrame::Box | QFrame::Sunken );
}
- legend->setItemMode( QwtLegend::ClickableItem );
- myPlot->insertLegend( legend );
- setLegendPos( myLegendPos );
- setLegendFont( myLegendFont );
- setLegendFontColor( myLegendColor );
+ else {
+ legend = dynamic_cast<QwtLegend*>(absLegend);
+ }
+ if(legend) {
+ myPlot->insertLegend( legend );
+ setLegendPos( myLegendPos );
+ setLegendFont( myLegendFont );
+ setLegendFontColor( myLegendColor );
+ }
}
else
myPlot->insertLegend( 0 );
+
+ if( show && update )
+ updateLegend();
+
if ( update )
myPlot->replot();
}
void Plot2d_ViewFrame::setLegendPos( int pos )
{
myLegendPos = pos;
- QwtLegend* legend = myPlot->legend();
+ QwtAbstractLegend* legend = myPlot->legend();
if ( legend ) {
switch( pos ) {
case 0:
return myLegendPos;
}
+/*!
+ Sets legend symbol type : 0 - marker on line, 1 - marker above line
+*/
+void Plot2d_ViewFrame::setLegendSymbolType( int type )
+{
+ myLegendSymbolType = type;
+ myPlot->setLegendSymbolType( type );
+ updateLegend();
+}
+
+/*!
+ Gets legend symbol type : 0 - marker on line, 1 - marker above line
+*/
+int Plot2d_ViewFrame::getLegendSymbolType() const
+{
+ return myLegendSymbolType;
+}
+
/*!
Sets legend font
*/
void Plot2d_ViewFrame::setLegendFont( const QFont& fnt )
{
myLegendFont = fnt;
- QwtLegend* legend = myPlot->legend();
+ QwtAbstractLegend* legend = myPlot->legend();
if ( legend ) {
legend->setFont(fnt);
}
return myLegendFont;
}
-/*!
- Gets legend font color
-*/
-QColor Plot2d_ViewFrame::getLegendFontColor() const
-{
- return myLegendColor;
-}
-
/*!
Sets legend font color
*/
void Plot2d_ViewFrame::setLegendFontColor( const QColor& col )
{
myLegendColor = col;
- QwtLegend* legend = myPlot->legend();
+ QwtAbstractLegend* legend = myPlot->legend();
if ( legend ) {
QPalette pal = legend->palette();
pal.setColor( QPalette::Text, col );
}
}
+/*!
+ Gets legend font color
+*/
+QColor Plot2d_ViewFrame::getLegendFontColor() const
+{
+ return myLegendColor;
+}
+
+/*!
+ Sets selected legend font color
+*/
+void Plot2d_ViewFrame::setSelectedLegendFontColor( const QColor& col )
+{
+ mySelectedLegendFontColor = col;
+ Plot2d_Object::setHighlightedLegendTextColor( col );
+}
+
+/*!
+ Gets selected legend font color
+*/
+QColor Plot2d_ViewFrame::getSelectedLegendFontColor() const
+{
+ return mySelectedLegendFontColor;
+}
+
/*!
Sets new marker size
*/
QwtPlotCurve* crv = it.key();
if ( crv )
{
- QwtSymbol aSymbol = crv->symbol();
- aSymbol.setSize( myMarkerSize, myMarkerSize );
+ QwtSymbol* aSymbol = new QwtSymbol( crv->symbol()->style(), crv->symbol()->brush(),
+ crv->symbol()->pen(), QSize( myMarkerSize, myMarkerSize ) );
crv->setSymbol( aSymbol );
- if(it.value())
- it.value()->setMarkerSize( myMarkerSize );
+ if( it.value() )
+ it.value()->setMarkerSize( myMarkerSize );
}
}
if ( update )
}
Repaint();
}
+
/*!
Gets background color
*/
{
return myBackground;
}
+
+/*!
+ Sets selection color
+*/
+void Plot2d_ViewFrame::setSelectionColor( const QColor& color )
+{
+ mySelectionColor = color;
+ Plot2d_Object::setSelectionColor( color );
+}
+
+/*!
+ Gets selection color
+*/
+QColor Plot2d_ViewFrame::selectionColor() const
+{
+ return mySelectionColor;
+}
+
/*!
Sets hor.axis grid parameters
*/
myPlot->setAxisMaxMinor( QwtPlot::xBottom, myXGridMaxMinor );
QwtPlotGrid* grid = myPlot->grid();
- if ( myPlot->axisScaleDiv( QwtPlot::xBottom ) )
- grid->setXDiv( *myPlot->axisScaleDiv( QwtPlot::xBottom ) );
+ if ( !myPlot->axisScaleDiv( QwtPlot::xBottom ).isEmpty() )
+ grid->setXDiv( myPlot->axisScaleDiv( QwtPlot::xBottom ) );
grid->enableX( myXGridMajorEnabled );
grid->enableXMin( myXGridMinorEnabled );
}
QwtPlotGrid* grid = myPlot->grid();
- if ( myPlot->axisScaleDiv( QwtPlot::yLeft ) )
- grid->setYDiv( *myPlot->axisScaleDiv( QwtPlot::yLeft ) );
+ if ( !myPlot->axisScaleDiv( QwtPlot::yLeft ).isEmpty() )
+ grid->setYDiv( myPlot->axisScaleDiv( QwtPlot::yLeft ) );
if (mySecondY) {
if (myYGridMajorEnabled) {
grid->enableYMin( myYGridMinorEnabled );
}
else if (myY2GridMajorEnabled) {
- if ( myPlot->axisScaleDiv( QwtPlot::yRight ) )
- grid->setYDiv( *myPlot->axisScaleDiv( QwtPlot::yRight ) );
+ if ( !myPlot->axisScaleDiv( QwtPlot::yRight ).isEmpty() )
+ grid->setYDiv( myPlot->axisScaleDiv( QwtPlot::yRight ) );
grid->enableY( myY2GridMajorEnabled );
grid->enableYMin( myY2GridMinorEnabled );
}
myXMode = mode;
+ // set bounds of logarithmic scale
+ if( myXMode != 0 ) {
+ myPlot->setAxisScale( QwtPlot::xBottom, 1.0, 1e5 );
+ myPlot->updateAxes();
+ }
+
myPlot->setLogScale(QwtPlot::xBottom, myXMode != 0);
if ( update )
}
myYMode = mode;
+
+ // set bounds of logarithmic scale
+ if( myYMode != 0 ){
+ myPlot->setAxisScale( QwtPlot::yLeft, 1.0, 1e5 );
+ myPlot->updateAxes();
+ }
+
myPlot->setLogScale(QwtPlot::yLeft, myYMode != 0);
- if (mySecondY)
+ if (mySecondY) {
+ if( myYMode != 0 ){
+ myPlot->setAxisScale( QwtPlot::yRight, 1.0, 1e5 );
+ myPlot->updateAxes();
+ }
myPlot->setLogScale( QwtPlot::yRight, myYMode != 0 );
+ }
if ( update )
fitAll();
class Plot2d_QwtPlotZoomer : public QwtPlotZoomer
{
public:
- Plot2d_QwtPlotZoomer( int xAxis, int yAxis, QwtPlotCanvas* canvas )
+ Plot2d_QwtPlotZoomer( int xAxis, int yAxis, QWidget* canvas )
: QwtPlotZoomer( xAxis, yAxis, canvas )
{
qApp->installEventFilter( this );
*/
Plot2d_Plot2d::Plot2d_Plot2d( QWidget* parent )
: QwtPlot( parent ),
- myIsPolished( false ),
myPicker( 0 )
{
// Create alternative scales
setAxisScaleDraw( QwtPlot::yRight, new Plot2d_ScaleDraw() );
myPlotZoomer = new Plot2d_QwtPlotZoomer( QwtPlot::xBottom, QwtPlot::yLeft, canvas() );
- myPlotZoomer->setSelectionFlags( QwtPicker::DragSelection | QwtPicker::CornerToCorner );
myPlotZoomer->setTrackerMode( QwtPicker::AlwaysOff );
myPlotZoomer->setRubberBand( QwtPicker::RectRubberBand );
myPlotZoomer->setRubberBandPen( QColor( Qt::green ) );
myScaleDraw = NULL;
// grid
myGrid = new QwtPlotGrid();
- QPen aMajPen = myGrid->majPen();
+ QPen aMajPen = myGrid->majorPen();
aMajPen.setStyle( Qt::DashLine );
myGrid->setPen( aMajPen );
void Plot2d_Plot2d::setLogScale( int axisId, bool log10 )
{
if ( log10 )
- setAxisScaleEngine( axisId, new QwtLog10ScaleEngine() );
+ setAxisScaleEngine( axisId, new QwtLogScaleEngine() );
else
setAxisScaleEngine( axisId, new QwtLinearScaleEngine() );
}
/*!
Get legend
*/
-QwtLegend* Plot2d_Plot2d::getLegend()
+QwtAbstractLegend* Plot2d_Plot2d::getLegend()
{
#if QWT_VERSION < 0x040200
return d_legend;
myPlotZoomer->setMousePattern( QwtEventPattern::MouseSelect1,
Qt::RightButton, Qt::ControlModifier ); // zooming button
for ( int i = QwtEventPattern::MouseSelect2; i < QwtEventPattern::MouseSelect6; i++ )
- myPlotZoomer->setMousePattern( i, Qt::NoButton, Qt::NoButton );
+ myPlotZoomer->setMousePattern( (QwtEventPattern::MousePatternCode)i, Qt::NoButton,
+ Qt::NoModifier );
}
void Plot2d_Plot2d::setPickerMousePattern( int button, int state )
{
- myPlotZoomer->setMousePattern( QwtEventPattern::MouseSelect1, button, state );
+ myPlotZoomer->setMousePattern( QwtEventPattern::MouseSelect1, (Qt::MouseButton)button,
+ (Qt::KeyboardModifiers)state );
}
/*!
/*!
* Create marker and tooltip associed with a point
*/
-QwtPlotMarker* Plot2d_Plot2d::createMarkerAndTooltip( QwtSymbol symbol,
- double X,
- double Y,
- QString & tooltip,
- Plot2d_QwtPlotPicker *picker)
+QwtPlotMarker* Plot2d_Plot2d::createMarkerAndTooltip( QwtSymbol* symbol,
+ double X,
+ double Y,
+ QString & tooltip,
+ Plot2d_QwtPlotPicker *picker)
{
QwtPlotMarker* aPlotMarker = new QwtPlotMarker();
return aPlotMarker;
}
-bool Plot2d_Plot2d::polished() const
-{
- return myIsPolished;
-}
-
QwtPlotGrid* Plot2d_Plot2d::grid() const
{
return myGrid;
return myPlotZoomer;
}
-/*!
- Slot: checks the current labels format and change it if needed
-*/
-void Plot2d_Plot2d::onScaleDivChanged()
-{
- QwtScaleWidget* aSW = 0;
- if ( ( aSW = dynamic_cast<QwtScaleWidget*>(sender()) ) ) {
- int axisId = -1;
- switch ( aSW->alignment() ) {
- case QwtScaleDraw::BottomScale:
- axisId = QwtPlot::xBottom;
- break;
- case QwtScaleDraw::LeftScale:
- axisId = QwtPlot::yLeft;
- break;
- case QwtScaleDraw::RightScale:
- axisId = QwtPlot::yRight;
- break;
- default:
- break;
- }
-
- if ( axisId >= 0 ) {
- QwtScaleMap map = canvasMap(axisId);
- double aDist = fabs(map.s2()-map.s1()) / (axisMaxMajor(axisId)*axisMaxMinor(axisId));
-
- QString aDistStr;
- aDistStr.sprintf("%e",aDist);
- int aPrecision = aDistStr.right(aDistStr.length()-aDistStr.indexOf('e')-2).toInt();
-
- QwtScaleDraw* aQwtSD = axisScaleDraw(axisId);
- Plot2d_ScaleDraw* aPlot2dSD = dynamic_cast<Plot2d_ScaleDraw*>(aQwtSD);
- if ( ( !aPlot2dSD && aPrecision > 6 ) || ( aPlot2dSD && aPlot2dSD->precision() != aPrecision ) )
- setAxisScaleDraw( axisId, new Plot2d_ScaleDraw(*aQwtSD, 'f', aPrecision) );
- }
- }
-}
-
/*!
Updates identifiers of Y axis type in the legend.
*/
if ( Plot2d_QwtPlotCurve* aPCurve = dynamic_cast<Plot2d_QwtPlotCurve*>( item ) )
aPCurve->setYAxisIdentifierEnabled( enableYLeft && enableYRight );
if ( item && item->isVisible() && legend() )
- item->updateLegend( legend() );
+ item->updateLegend( item, item->legendData() );
}
}
-/*!
- Sets the flag saying that QwtPlot geometry has been fully defined.
-*/
-void Plot2d_Plot2d::polish()
-{
- QwtPlot::polish();
- myIsPolished = true;
-}
-
// Methods to manage axis graduations
/* Create definition and graduations of axes
mySeparationLineList.clear();
}
+/* Set type of legend symbol
+ */
+void Plot2d_Plot2d::setLegendSymbolType( const int type )
+{
+ myLegendSymbolType = type;
+}
+
+/* Get type of legend symbol
+ */
+int Plot2d_Plot2d::getLegendSymbolType()
+{
+ return myLegendSymbolType;
+}
+
/*!
Creates presentation of object
Default implementation is empty
myCurveType = vf->myCurveType;
myShowLegend = vf->myShowLegend;
myLegendPos = vf->myLegendPos;
+ myLegendSymbolType = vf->myLegendSymbolType;
+ myLegendFont = vf->myLegendFont;
+ mySelectedLegendFontColor = vf->mySelectedLegendFontColor;
myMarkerSize = vf->myMarkerSize;
myBackground = vf->myBackground;
+ mySelectionColor = vf->mySelectionColor;
myTitle = vf->myTitle;
myXTitle = vf->myXTitle;
myYTitle = vf->myYTitle;
if( pd )
{
- myPlot->print( *pd );
+ QwtPlotRenderer* pr = new QwtPlotRenderer();
+ pr->renderTo( myPlot, *pd );
res = true;
delete pd;
}
}
return res;
#endif
+
}
/**
* Print Plot2d window
*/
-void Plot2d_ViewFrame::printPlot( QPainter* p, const QRect& rect,
- const QwtPlotPrintFilter& filter ) const
+void Plot2d_ViewFrame::printPlot( QPainter* p, const QRectF& rect) const
{
- myPlot->print( p, rect, filter );
+ QwtPlotRenderer* pr = new QwtPlotRenderer();
+ pr->render( myPlot, p, rect );
}
/*!
xNew[j] = itTmp.value().at(j).first;
yNew[j] = itTmp.value().at(j).second;
}
- cu->setData(xNew, yNew,j);
+ cu->setSamples(xNew, yNew,j);
delete [] xNew;
delete [] yNew;
if(aNormAlgo->getNormalizationMode() != Plot2d_NormalizeAlgorithm::NormalizeNone) {
*/
QwtPlotCanvas* Plot2d_ViewFrame::getPlotCanvas() const
{
- return myPlot ? myPlot->canvas() : 0;
+ return myPlot ? (QwtPlotCanvas*)myPlot->canvas() : 0;
}
/*!
invalidateCache();
}
-Plot2d_ScaleDraw::Plot2d_ScaleDraw( const QwtScaleDraw& scaleDraw, char f, int prec )
- : QwtScaleDraw(scaleDraw),
- myFormat(f),
- myPrecision(prec)
-{
- invalidateCache();
-}
-
QwtText Plot2d_ScaleDraw::label( double value ) const
{
- QwtScaleMap m = map();
+ QwtScaleMap m = scaleMap();
QString str1 = QwtScaleDraw::label( m.s1() ).text();
QString str2 = QwtScaleDraw::label( m.s2() ).text();
if ( str1 == str2 ) {
- double aDist = fabs(map().s2()-map().s1())/5;
+ double aDist = fabs(scaleMap().s2()-scaleMap().s1())/5;
int precision = 0;
while (aDist < 1 ) {
precision++;
major_ticks.clear();
major_ticks.append( myTicks);
- myPlot->axisScaleDiv(QwtPlot::xBottom)->setTicks(QwtScaleDiv::MajorTick, major_ticks);
- myPlot->axisScaleDiv(QwtPlot::xBottom)->setTicks(QwtScaleDiv::MediumTick, medium_ticks);
- myPlot->axisScaleDiv(QwtPlot::xBottom)->setTicks(QwtScaleDiv::MinorTick, minor_ticks);
+
+ QwtScaleDiv aScaleDiv = myPlot->axisScaleDiv( QwtPlot::xBottom );
+ aScaleDiv.setTicks( QwtScaleDiv::MajorTick, major_ticks );
+ aScaleDiv.setTicks( QwtScaleDiv::MediumTick, medium_ticks );
+ aScaleDiv.setTicks( QwtScaleDiv::MinorTick, minor_ticks );
+ myPlot->setAxisScaleDiv( QwtPlot::xBottom, aScaleDiv );
+
QwtScaleDraw *scale = myPlot->axisScaleDraw(QwtPlot::xBottom);
((Plot2d_AxisScaleDraw*)(scale))->applyTicks();
medium_ticks.clear();
minor_ticks.clear();
- myPlot->axisScaleDiv(QwtPlot::xBottom)->setTicks(QwtScaleDiv::MajorTick, myTicks);
- myPlot->axisScaleDiv(QwtPlot::xBottom)->setTicks(QwtScaleDiv::MediumTick, medium_ticks);
- myPlot->axisScaleDiv(QwtPlot::xBottom)->setTicks(QwtScaleDiv::MinorTick, minor_ticks);
+ QwtScaleDiv aQwtScaleDiv = myPlot->axisScaleDiv( QwtPlot::xBottom );
+ aQwtScaleDiv.setTicks( QwtScaleDiv::MajorTick, myTicks );
+ aQwtScaleDiv.setTicks( QwtScaleDiv::MediumTick, medium_ticks );
+ aQwtScaleDiv.setTicks( QwtScaleDiv::MinorTick, minor_ticks );
+ myPlot->setAxisScaleDiv( QwtPlot::xBottom, aQwtScaleDiv );
QwtScaleDiv* aScaleDiv = (QwtScaleDiv*) &scaleDiv();
//const char *c_label = std_label.c_str();
//std::cout << " deviceLabel= |" << c_label << "|" << std::endl;
- QPoint p = labelPosition( value );
+ QPointF p = labelPosition( value );
p += QPoint(0, DEVICE_BY);
QFont prevf = painter->font();
//QColor prevc = (painter->pen()).color();
Plot2d_QwtPlotPicker::Plot2d_QwtPlotPicker( int xAxis,
int yAxis,
- int selectionFlags,
RubberBand rubberBand,
DisplayMode trackerMode,
QwtPlotCanvas *canvas)
: QwtPlotPicker( xAxis,
yAxis,
- selectionFlags,
rubberBand,
trackerMode,
canvas) // of drawing zone QwtPlot
/* Return the tooltip associated with a point when the mouse cursor pass near
*/
-QwtText Plot2d_QwtPlotPicker::trackerText( const QwtDoublePoint & pos ) const
+QwtText Plot2d_QwtPlotPicker::trackerText( const QPoint & pos ) const
{
for (QList<QwtPlotMarker* >::const_iterator pMarkerIt = pMarkers.begin();pMarkerIt != pMarkers.end(); ++pMarkerIt )
{
QwtPlotMarker* pMarker = *pMarkerIt;
if ( pMarker != NULL )
{
- const QwtSymbol &symb=pMarker->symbol();
- const QSize& sz=symb.size();
+ const QwtSymbol* symb=pMarker->symbol();
+ const QSize& sz=symb->size();
const QwtScaleMap yMapRef=plot()->canvasMap(QwtPlot::yLeft);
const QwtScaleMap xMap=plot()->canvasMap(pMarker->xAxis());
const QwtScaleMap yMap=plot()->canvasMap(pMarker->yAxis());
QwtDoubleRect bound0=pMarker->boundingRect();
- QRect bound00=pMarker->transform(xMap,yMap,bound0);
+ int x1 = qRound(xMap.transform(bound0.left()));
+ int x2 = qRound(xMap.transform(bound0.right()));
+ int y1 = qRound(yMap.transform(bound0.top()));
+ int y2 = qRound(yMap.transform(bound0.bottom()));
+
+ if ( x2 < x1 )
+ qSwap(x1, x2);
+ if ( y2 < y1 )
+ qSwap(y1, y2);
+
+ QRect bound00=QRect(x1, y1, x2 - x1 + 1, y2 - y1 + 1);
QPoint toto(xMap.transform(pos.x()),yMapRef.transform(pos.y()));
bound00.setX(bound00.x()-sz.width());
bound00.setY(bound00.y()-sz.height());
#include <qwt_scale_draw.h>
#include <qwt_plot_marker.h>
#include <qwt_plot_picker.h>
+#include <qwt_plot_canvas.h>
+#include <qwt_legend.h>
#include <iostream>
#include <ostream>
virtual ~Plot2d_ViewFrame();
void Init();
+ void SetPreference();
enum ObjectType { MainTitle, XTitle, YTitle, Y2Title, XAxis, YAxis, Y2Axis };
void showLegend( bool, bool = true );
void setLegendPos( int );
int getLegendPos() const;
+ void setLegendSymbolType( int );
+ int getLegendSymbolType() const;
void setLegendFont( const QFont& );
QFont getLegendFont() const;
void setLegendFontColor( const QColor& );
QColor getLegendFontColor() const;
+ void setSelectedLegendFontColor( const QColor& );
+ QColor getSelectedLegendFontColor() const;
void setMarkerSize( const int, bool = true );
int getMarkerSize() const;
virtual void setBackgroundColor( const QColor& );
QColor backgroundColor() const;
+ virtual void setSelectionColor( const QColor& );
+ QColor selectionColor() const;
void setXGrid( bool, const int, bool, const int, bool = true );
void setYGrid( bool, const int, bool, const int,
bool, const int, bool, const int, bool = true );
void setEnableAxis( QwtPlot::Axis, bool );
virtual bool print( const QString&, const QString& ) const;
- void printPlot( QPainter*, const QRect&,
- const QwtPlotPrintFilter& = QwtPlotPrintFilter() ) const;
+ void printPlot( QPainter*, const QRectF& ) const;
QString getVisualParameters();
void setVisualParameters( const QString& );
void vpNormRModeChanged();
void vpCurveChanged();
void contextMenuRequested( QContextMenuEvent* );
- void legendClicked( QwtPlotItem* );
+ void clicked (const QVariant&, int );
protected:
Plot2d_Plot2d* myPlot;
int myCurveType;
bool myShowLegend;
int myLegendPos;
+ int myLegendSymbolType;
QFont myLegendFont;
QColor myLegendColor;
+ QColor mySelectedLegendFontColor;
int myMarkerSize;
QColor myBackground;
+ QColor mySelectionColor;
QString myTitle, myXTitle, myYTitle, myY2Title;
bool myTitleEnabled, myXTitleEnabled, myYTitleEnabled, myY2TitleEnabled;
bool myXGridMajorEnabled, myYGridMajorEnabled, myY2GridMajorEnabled;
Plot2d_Plot2d( QWidget* );
virtual ~Plot2d_Plot2d();
- void setLogScale( int, bool );
+ void setLogScale( int, bool );
- void replot();
- QwtLegend* getLegend();
- QSize sizeHint() const;
- QSize minimumSizeHint() const;
- void defaultPicker();
- void setPickerMousePattern( int, int = Qt::NoButton );
- void setPicker( Plot2d_QwtPlotPicker *picker);
+ void replot();
+ QwtAbstractLegend* getLegend();
+ QSize sizeHint() const;
+ QSize minimumSizeHint() const;
+ void defaultPicker();
+ void setPickerMousePattern( int, int = Qt::NoButton );
+ void setPicker( Plot2d_QwtPlotPicker *picker);
Plot2d_QwtPlotPicker* getPicker() { return myPicker; }
Plot2d_AxisScaleDraw* getScaleDraw() { return myScaleDraw; }
QList<QwtPlotMarker*> getSeparationLineList() { return mySeparationLineList; }
void clearSeparationLineList();
- QwtPlotMarker *createMarkerAndTooltip( QwtSymbol symbol,
- double X,
- double Y,
- QString & tooltip,
- Plot2d_QwtPlotPicker *picker);
+ void setLegendSymbolType( const int );
+ int getLegendSymbolType();
+ QwtPlotMarker *createMarkerAndTooltip( QwtSymbol* symbol,
+ double X,
+ double Y,
+ QString & tooltip,
+ Plot2d_QwtPlotPicker *picker);
- bool polished() const;
QwtPlotGrid* grid() const;
QwtPlotZoomer* zoomer() const;
void createSeparationLine( double Xpos);
-
-public slots:
- virtual void polish();
-
-protected slots:
- void onScaleDivChanged();
-
protected:
QwtPlotGrid* myGrid;
QList<QColor> myColors;
- bool myIsPolished;
QwtPlotZoomer* myPlotZoomer;
Plot2d_AxisScaleDraw* myScaleDraw;
// The point picker associated with the graphic view
private:
// List of verticals segments between two curves
QList<QwtPlotMarker*> mySeparationLineList;
+ int myLegendSymbolType;
};
class Plot2d_ScaleDraw: public QwtScaleDraw
{
public:
Plot2d_ScaleDraw( char f = 'g', int prec = 6 );
- Plot2d_ScaleDraw( const QwtScaleDraw& scaleDraw, char f = 'g', int prec = 6 );
virtual QwtText label( double value ) const;
Plot2d_QwtPlotPicker( int xAxis,
int yAxis,
- int selectionFlags,
RubberBand rubberBand,
DisplayMode trackerMode,
QwtPlotCanvas *canvas);
protected:
- virtual QwtText trackerText( const QwtDoublePoint & pos ) const;
+ virtual QwtText trackerText( const QPoint & pos ) const;
};
Plot2d_ViewFrame* aViewFrame = view->getViewFrame();
Plot2d_Viewer* aViewer = getPlot2dModel();
- connect( aViewFrame, SIGNAL( legendClicked( QwtPlotItem* ) ),
- aViewer, SLOT( onLegendClicked( QwtPlotItem* ) ) );
+ connect( aViewFrame, SIGNAL( clicked(const QVariant&, int) ),
+ aViewer, SLOT( onClicked(const QVariant&, int) ) );
}
return res;
}
{
myPrs = 0;
myAutoDel = theAutoDel;
- Plot2d_Object::initColors();
+ Plot2d_Object::setSelectionColor( QColor(80,80,80) );
+ Plot2d_Object::setHighlightedLegendTextColor( QColor(255,255,255) );
}
/*!
/*
SLOT: called when clicked item in the legend from Plot2d_ViewManager
*/
-void Plot2d_Viewer::onLegendClicked( QwtPlotItem* plotItem )
+void Plot2d_Viewer::onClicked(const QVariant& itemInfo, int index)
{
}
void onDumpView();
void onShowToolbar();
virtual void onCloneView( Plot2d_ViewFrame*, Plot2d_ViewFrame* );
- virtual void onLegendClicked( QwtPlotItem* );
+ virtual void onClicked( const QVariant&, int );
private:
Plot2d_Prs* myPrs;
}
QMap< QwtPlotCurve*, QPen > aCurvToPen;
- QMap< QwtPlotCurve*, QwtSymbol > aCurvToSymbol;
+ QMap< QwtPlotCurve*, QwtSymbol* > aCurvToSymbol;
if ( needColorCorrection )
{
aCurve->setPen( aPen );
// symbol
- QwtSymbol aSymbol = aCurve->symbol();
+ QwtSymbol* aSymbol = const_cast<QwtSymbol*>( aCurve->symbol() );
aCurvToSymbol[ aCurve ] = aSymbol;
- aPen = aSymbol.pen();
+ aPen = aSymbol->pen();
aPen.setColor( QColor( 0, 0, 0 ) );
aPen.setWidthF( 1.5 );
- aSymbol.setPen( aPen );
+ aSymbol->setPen( aPen );
aCurve->setSymbol( aSymbol );
}
<source>PLOT2D_BACKGROUND_COLOR_LBL</source>
<translation>Background color:</translation>
</message>
+ <message>
+ <source>PLOT2D_SELECTION_COLOR_LBL</source>
+ <translation>Selection color:</translation>
+ </message>
<message>
<source>PLOT2D_DEVIATION_MARKER_TLT</source>
<translation>Deviation marker</translation>
<source>PLOT2D_ENABLE_MAIN_TITLE</source>
<translation>Main title</translation>
</message>
+ <message>
+ <source>PLOT2D_LEGEND_GROUP</source>
+ <translation>Legend</translation>
+ </message>
+ <message>
+ <source>PLOT2D_LEGEND_POSITION</source>
+ <translation>Legend position:</translation>
+ </message>
+ <message>
+ <source>PLOT2D_LEGEND_SYMBOL_TYPE</source>
+ <translation>Symbol type:</translation>
+ </message>
+ <message>
+ <source>PLOT2D_MARKER_ABOVE_LINE</source>
+ <translation>Marker above line</translation>
+ </message>
+ <message>
+ <source>PLOT2D_MARKER_ON_LINE</source>
+ <translation>Marker on line</translation>
+ </message>
+ <message>
+ <source>PLOT2D_LEGEND_FONT_COLOR</source>
+ <translation>Legend font color:</translation>
+ </message>
+ <message>
+ <source>PLOT2D_SELECTED_LEGEND_FONT_COLOR</source>
+ <translation>Highlighted legend font color:</translation>
+ </message>
<message>
<source>TOT_PLOT2D_CURVES_LINES</source>
<translation>Draw lines</translation>
<source>PLOT2D_BACKGROUND_COLOR_LBL</source>
<translation>Couleur d'arrière-plan:</translation>
</message>
+ <message>
+ <source>PLOT2D_SELECTION_COLOR_LBL</source>
+ <translation>Couleur de sélection:</translation>
+ </message>
<message>
<source>PLOT2D_DEVIATION_MARKER_TLT</source>
<translation>Marqueur de déviation</translation>
<source>PLOT2D_ENABLE_MAIN_TITLE</source>
<translation>Titre principal</translation>
</message>
+ <message>
+ <source>PLOT2D_LEGEND_GROUP</source>
+ <translation>Légende</translation>
+ </message>
+ <message>
+ <source>PLOT2D_LEGEND_POSITION</source>
+ <translation>Position de la Légende:</translation>
+ </message>
+ <message>
+ <source>PLOT2D_LEGEND_SYMBOL_TYPE</source>
+ <translation>Type de symbole:</translation>
+ </message>
+ <message>
+ <source>PLOT2D_MARKER_ABOVE_LINE</source>
+ <translation>Marqueur dessus de la ligne</translation>
+ </message>
+ <message>
+ <source>PLOT2D_MARKER_ON_LINE</source>
+ <translation>Marqueur sur la ligne</translation>
+ </message>
+ <message>
+ <source>PLOT2D_LEGEND_FONT_COLOR</source>
+ <translation>Couleur de police de la légende:</translation>
+ </message>
+ <message>
+ <source>PLOT2D_SELECTED_LEGEND_FONT_COLOR</source>
+ <translation>Couleur de surlignement de la légende:</translation>
+ </message>
<message>
<source>TOT_PLOT2D_CURVES_LINES</source>
<translation>Dessiner des lignes</translation>
SLOT: called when action "Legend Clicked" is activated.
override "onLegendClicked" method from Plot2d_ViewModel.
*/
-void SPlot2d_Viewer::onLegendClicked( QwtPlotItem* plotItem )
+void SPlot2d_Viewer::onClicked( const QVariant& itemInfo, int index )
{
Plot2d_ViewFrame* aViewFrame = getActiveViewFrame();
if(aViewFrame == NULL) return;
+ QwtPlotItem* plotItem = aViewFrame->getPlot()->infoToItem( itemInfo );
+
bool isAnalytical = false;
AnalyticalCurveList curves = aViewFrame->getAnalyticalCurves();
foreach ( Plot2d_AnalyticalCurve* curve, curves ) {
Handle(SALOME_InteractiveObject) FindIObject( const char* Entry );
protected slots:
- virtual void onLegendClicked( QwtPlotItem* plotItem );
+ virtual void onClicked( const QVariant&, int );
signals:
void legendSelected( const QString& );