}
}
+void Plot2d_QwtLegendItem::drawText(QPainter * painter, const QRect &rect) {
+ QWidget* pw = parentWidget();
+ QColor col = palette().color( QPalette::WindowText );
+ while( pw ) {
+ if ( qobject_cast<QwtLegend*>( pw ) ) {
+ col = pw->palette().color( QPalette::WindowText );
+ break;
+ }
+ pw = pw->parentWidget();
+ }
+ painter->setPen( col );
+ QwtLegendItem::drawText( painter, rect );
+}
+
/*!
Constructor of Plot2d_QwtPlotCurve
*/
protected:
virtual void drawIdentifier( QPainter*, const QRect& ) const;
+ virtual void drawText(QPainter *, const QRect &);
private:
int myYAxisIdentifierMode;
#include <SUIT_Session.h>
#include <SUIT_Application.h>
#include <QtxColorButton.h>
+#include <QtxFontEdit.h>
#include <QCheckBox>
#include <QLineEdit>
// 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" ) );
// layout widgets
topLayout->addWidget( myTitleCheck, 0, 0 );
topLayout->addWidget( myTitleEdit, 0, 1, 1, 3 );
- topLayout->addWidget( aCurveLab, 1, 0 );
- topLayout->addWidget( myCurveCombo, 1, 1 );
- topLayout->addWidget( myLegendCheck, 1, 2 );
- topLayout->addWidget( myLegendCombo, 1, 3 );
- topLayout->addWidget( aMarkerLab, 2, 0 );
- topLayout->addWidget( myMarkerSpin, 2, 1 );
+ 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, 2, 2 );
- topLayout->addLayout( bgLayout, 2, 3 );
- topLayout->addWidget( aScaleGrp, 3, 0, 1, 4 );
- topLayout->addWidget( aTabWidget, 4, 0, 1, 4 );
- topLayout->addWidget( myDefCheck, 5, 0, 1, 4 );
- topLayout->setRowStretch( 5, 5 );
-
- topLayout->addLayout( btnLayout, 6, 0, 1, 4 );
+ topLayout->addWidget( aBGLab, 3, 2 );
+ topLayout->addLayout( bgLayout, 3, 3 );
+ topLayout->addWidget( aScaleGrp, 4, 0, 1, 4 );
+ topLayout->addWidget( aTabWidget, 5, 0, 1, 4 );
+ topLayout->addWidget( myDefCheck, 6, 0, 1, 4 );
+ topLayout->setRowStretch( 6, 5 );
+
+ topLayout->addLayout( btnLayout, 7, 0, 1, 4 );
if ( !showDefCheck )
myDefCheck->hide();
\brief Set legend attribute.
\param if \c true legend is shown
\param pos legend position: 0 (left), 1 (right), 2 (top), 3 (bottom)
- \sa isLegendEnabled(), getLegendPos()
+ \param fnt legend font
+ \param col legend font color
+ \sa isLegendEnabled(), getLegendPos(), getLegendFont()
*/
-void Plot2d_SetupViewDlg::setLegend( bool enable, int pos )
+void Plot2d_SetupViewDlg::setLegend( bool enable, int pos, const QFont& fnt, const QColor& col )
{
myLegendCheck->setChecked( enable );
myLegendCombo->setCurrentIndex( pos );
+ myLegendFont->setCurrentFont( fnt );
+ myLegendColor->setColor( col );
onLegendChecked();
}
return myLegendCombo->currentIndex();
}
+/*!
+ \brief Get legend font.
+ \return legend font
+ \sa setLegend()
+*/
+QFont Plot2d_SetupViewDlg::getLegendFont()
+{
+ return myLegendFont->currentFont();
+}
+
+/*!
+ \brief Get legend font color.
+ \return legend font color
+ \sa setLegend()
+*/
+QColor Plot2d_SetupViewDlg::getLegendColor()
+{
+ return myLegendColor->color();
+}
+
/*!
\brief Set marker size.
\param size marker size
class QComboBox;
class QPushButton;
class QtxColorButton;
+class QtxFontEdit;
class PLOT2D_EXPORT Plot2d_SetupViewDlg : public QDialog
{
void setCurveType( const int );
int getCurveType();
- void setLegend( bool, int );
+ void setLegend( bool, int, const QFont&, const QColor& );
bool isLegendEnabled();
int getLegendPos();
+ QFont getLegendFont();
+ QColor getLegendColor();
void setMarkerSize( const int );
int getMarkerSize();
QLineEdit* myTitleYEdit;
QLineEdit* myTitleY2Edit;
QtxColorButton* myBackgroundBtn;
+ QtxColorButton* myLegendColor;
+ QtxFontEdit* myLegendFont;
QCheckBox* myXGridCheck;
QSpinBox* myXGridSpin;
QCheckBox* myYGridCheck;
: QWidget (parent, 0),
myOperation( NoOpId ),
myCurveType( 1 ),
- myShowLegend( true ), myLegendPos( 1 ),
+ myShowLegend( true ), myLegendPos( 1 ), myLegendFont("Helvetic",12),
+ myLegendColor(Qt::black),
myMarkerSize( DEFAULT_MARKER_SIZE ),
myBackground( Qt::white ),
myTitle( "" ), myXTitle( "" ), myYTitle( "" ), myY2Title( "" ),
setVerScaleMode( myYMode, false );
setBackgroundColor( myBackground );
setLegendPos( myLegendPos );
+ setLegendFont( myLegendFont );
+ setLegendColor( myLegendColor );
showLegend( myShowLegend, false );
myPlot->replot();
myShowLegend = resMgr->booleanValue( "Plot2d", "ShowLegend", myShowLegend );
myLegendPos = resMgr->integerValue( "Plot2d", "LegendPos", myLegendPos );
+ myLegendFont = resMgr->fontValue( "Plot2d", "LegendFont", myLegendFont );
+ myLegendColor = resMgr->colorValue( "Plot2d", "LegendColor", myLegendColor );
myMarkerSize = resMgr->integerValue( "Plot2d", "MarkerSize", myMarkerSize );
myBackground = resMgr->colorValue( "Plot2d", "Background", myBackground );
resMgr->setValue( "Plot2d", "CurveType", myCurveType );
resMgr->setValue( "Plot2d", "ShowLegend", myShowLegend );
resMgr->setValue( "Plot2d", "LegendPos", myLegendPos );
+ resMgr->setValue( "Plot2d", "LegendFont", myLegendFont );
+ resMgr->setValue( "Plot2d", "LegendColor", myLegendColor );
resMgr->setValue( "Plot2d", "MarkerSize", myMarkerSize );
resMgr->setValue( "Plot2d", "Background", myBackground );
resMgr->setValue( "Plot2d", "ShowTitle", myTitleEnabled );
if (mySecondY)
dlg->setY2Title( myY2TitleEnabled, myY2Title );
dlg->setCurveType( myCurveType );
- dlg->setLegend( myShowLegend, myLegendPos );
+ dlg->setLegend( myShowLegend, myLegendPos, myLegendFont, myLegendColor );
dlg->setMarkerSize( myMarkerSize );
dlg->setBackgroundColor( myBackground );
dlg->setScaleMode(myXMode, myYMode);
if ( myLegendPos != dlg->getLegendPos() ) {
setLegendPos( dlg->getLegendPos() );
}
+ if ( myLegendFont != dlg->getLegendFont() ) {
+ setLegendFont( dlg->getLegendFont() );
+ }
+ if ( myLegendColor != dlg->getLegendColor() ) {
+ setLegendColor( dlg->getLegendColor() );
+ }
+
// marker size
if ( myMarkerSize != dlg->getMarkerSize() ) {
setMarkerSize( dlg->getMarkerSize(), false );
legend->setItemMode( QwtLegend::ClickableItem );
myPlot->insertLegend( legend );
setLegendPos( myLegendPos );
+ setLegendFont( myLegendFont );
+ setLegendColor( myLegendColor );
}
else
myPlot->insertLegend( 0 );
return myLegendPos;
}
+/*!
+ Sets legend font
+*/
+void Plot2d_ViewFrame::setLegendFont( const QFont& fnt )
+{
+ myLegendFont = fnt;
+ QwtLegend* legend = myPlot->legend();
+ if ( legend ) {
+ legend->setFont(fnt);
+ }
+}
+
+/*!
+ Gets legend font
+*/
+QFont Plot2d_ViewFrame::getLegendFont() const
+{
+ return myLegendFont;
+}
+
+/*!
+ Gets legend font color
+*/
+QColor Plot2d_ViewFrame::getLegendColor() const
+{
+ return myLegendColor;
+}
+
+/*!
+ Sets legend font color
+*/
+void Plot2d_ViewFrame::setLegendColor( const QColor& col )
+{
+ myLegendColor = col;
+ QwtLegend* legend = myPlot->legend();
+ if ( legend ) {
+ QPalette pal = legend->palette();
+ pal.setColor( QPalette::WindowText, col );
+ legend->setPalette( pal );
+ }
+}
+
/*!
Sets new marker size
*/
void showLegend( bool, bool = true );
void setLegendPos( int );
int getLegendPos() const;
+ void setLegendFont( const QFont& );
+ QFont getLegendFont() const;
+ void setLegendColor( const QColor& );
+ QColor getLegendColor() const;
void setMarkerSize( const int, bool = true );
int getMarkerSize() const;
void setBackgroundColor( const QColor& );
int myCurveType;
bool myShowLegend;
int myLegendPos;
+ QFont myLegendFont;
+ QColor myLegendColor;
int myMarkerSize;
QColor myBackground;
QString myTitle, myXTitle, myYTitle, myY2Title;
<source>PLOT2D_ENABLE_LEGEND</source>
<translation>Show legend</translation>
</message>
+ <message>
+ <source>PLOT2D_LEGEND_FONT</source>
+ <translation>Legend font</translation>
+ </message>
<message>
<source>DSC_ZOOM_VIEW</source>
<translation>Zoom the view</translation>