pref->setItemProperty( "strings", aValuesList, legendPosition );
pref->setItemProperty( "indexes", anIndicesList, legendPosition );
- pref->addPreference( tr( "PREF_FONT" ), plot2dGroup, LightApp_Preferences::Font, "Plot2d", "LegendFont" );
-
- pref->addPreference( tr( "PREF_FONT_COLOR" ), plot2dGroup, LightApp_Preferences::Color, "Plot2d", "LegendColor" );
+ pref->addPreference( tr( "PREF_LEGEND_FONT" ), plot2dGroup, LightApp_Preferences::Font, "Plot2d", "LegendFont" );
int curveType = pref->addPreference( tr( "PREF_CURVE_TYPE" ), plot2dGroup,
LightApp_Preferences::Selector, "Plot2d", "CurveType" );
pref->addPreference( tr( "PREF_VIEWER_BACKGROUND" ), plot2dGroup,
LightApp_Preferences::Color, "Plot2d", "Background" );
+ pref->addPreference( tr( "PREF_FONT_COLOR" ), plot2dGroup, LightApp_Preferences::Color, "Plot2d", "LegendFontColor" );
+
+ pref->addPreference( tr( "PREF_SELECTED_FONT_COLOR" ), plot2dGroup, LightApp_Preferences::Color, "Plot2d", "SelectedLegendFontColor" );
+
+ pref->addPreference( tr( "PREF_VIEWER_SELECTION" ), plot2dGroup,
+ LightApp_Preferences::Color, "Plot2d", "SelectionColor" );
+
+
int dirTab = pref->addPreference( tr( "PREF_TAB_DIRECTORIES" ), salomeCat );
int dirGroup = pref->addPreference( tr( "PREF_GROUP_DIRECTORIES" ), dirTab );
pref->addPreference( tr( "" ), dirGroup,
QtxWebBrowser::webBrowser()->close();
}
}
+
+#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);
+ }
+ }
+#endif
}
/*!
#include "LightApp_DataObject.h"
#include "LightApp_Application.h"
+#include <SPlot2d_ViewModel.h>
+
+#include <SALOME_ListIO.hxx>
+
/*!
Constructor
*/
LightApp_Plot2dSelector::LightApp_Plot2dSelector( Plot2d_Viewer* v, SUIT_SelectionMgr* mgr )
-: SUIT_Selector( mgr, v )
+ : SUIT_Selector( mgr, v ),
+ myViewer(v)
{
if ( v )
connect( v, SIGNAL( legendSelected( const QString& ) ), this, SLOT( onSelectionChanged( const QString& ) ) );
void LightApp_Plot2dSelector::getSelection( SUIT_DataOwnerPtrList& theList ) const
{
if( !myCurEntry.isNull() )
- theList.append( new LightApp_DataOwner( myCurEntry ) );
+ theList.append( new LightApp_DataOwner( new SALOME_InteractiveObject(qPrintable(myCurEntry),"","") ) );
}
/*!Sets selection.*/
void LightApp_Plot2dSelector::setSelection( const SUIT_DataOwnerPtrList& theList )
{
- /* if( theList.count()>0 )
- myCurEntry = theList.first()->getEntry();
- else*/
- myCurEntry = QString::null;
+ SALOME_ListIO anIOList;
+ for ( SUIT_DataOwnerPtrList::const_iterator it = theList.begin(); it != theList.end(); ++it ) {
+ const LightApp_DataOwner* owner = dynamic_cast<const LightApp_DataOwner*>( (*it).operator->() );
+ if ( owner ) {
+ if( !owner->IO().IsNull() ) {
+ anIOList.Append(owner->IO());
+ } else if ( !owner->entry().isEmpty() ) {
+ anIOList.Append( new SALOME_InteractiveObject(qPrintable(owner->entry()),"","") );
+ }
+ }
+ }
+ SPlot2d_Viewer* v = dynamic_cast<SPlot2d_Viewer*>(myViewer);
+
+ if(v)
+ v->setObjectsSelected(anIOList);
}
/*!On selection changed.*/
{
myCurEntry = entry;
selectionChanged();
+ myCurEntry = QString();
}
virtual void setSelection( const SUIT_DataOwnerPtrList& );
private:
- QString myCurEntry;
+ QString myCurEntry;
+ Plot2d_Viewer* myViewer;
};
#endif
<section name="Plot2d" >
<!-- Plot2d viewer preferences -->
<parameter name="Background" value="255, 255, 255" />
+ <parameter name="SelectionColor" value="80, 80, 80" />
<parameter name="CurveType" value="1" />
<parameter name="HorScaleMode" value="0" />
<parameter name="LegendPos" value="1" />
<parameter name="LegendFont" value="Helvetic,12" />
- <parameter name="LegendColor" value="0, 0, 0" />
+ <parameter name="LegendFontColor" value="0, 0, 0" />
+ <parameter name="SelectedLegendFontColor" value="255, 255, 255" />
<parameter name="MarkerSize" value="9" />
<parameter name="ShowLegend" value="true" />
<parameter name="VerScaleMode" value="0" />
<source>PREF_VIEWER_BACKGROUND</source>
<translation>Background color</translation>
</message>
+ <message>
+ <source>PREF_VIEWER_SELECTION</source>
+ <translation>Selection color</translation>
+ </message>
<message>
<source>PREF_XYVIEWER_BACKGROUND</source>
<translation>XY View background color</translation>
<source>PREF_FONT</source>
<translation>Font</translation>
</message>
+ <message>
+ <source>PREF_LEGEND_FONT</source>
+ <translation>Legend font</translation>
+ </message>
<message>
<source>PREF_FONT_COLOR</source>
<translation>Legend font color</translation>
</message>
+ <message>
+ <source>PREF_SELECTED_FONT_COLOR</source>
+ <translation>Highlighted legend font color</translation>
+ </message>
<message>
<source>PREF_LEFT</source>
<translation>Left</translation>
if ( theItem->rtti() != rtti() )
return;
- QwtPlotCurve* aCurve = dynamic_cast<QwtPlotCurve*>( theItem );
+ Plot2d_QwtPlotCurve* aCurve = dynamic_cast<Plot2d_QwtPlotCurve*>( theItem );
if ( !aCurve )
return;
Qt::PenStyle ps = Plot2d::plot2qwtLine( getLine() );
QwtSymbol::Style ms = Plot2d::plot2qwtMarker( getMarker() );
+
+ QColor aColor = isSelected() ? Plot2d_Object::selectionColor() : getColor();
+ int lineW = getLineWidth();
+ if ( isSelected() ) lineW += (lineW == 0 ? 3 : 2);
- aCurve->setPen( QPen( getColor(), getLineWidth(), ps ) );
- aCurve->setSymbol( QwtSymbol( ms, QBrush( getColor() ),
- QPen( getColor() ),
- QSize( getMarkerSize(), getMarkerSize() ) ) );
+ int markerS = isSelected() ? getMarkerSize() + 2 : getMarkerSize();
+
+ aCurve->setSelected(isSelected());
+
+ aCurve->setPen( QPen(aColor , lineW, ps ) );
+ aCurve->setSymbol( 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() )));
+
double *x, *y;
long nb = getData( &x, &y );
aCurve->setData( x, y, nb );
Plot2d_Object::updatePlotItem( theItem );
anItem->setData( getData() );
- anItem->setColor( getColor() );
+ anItem->setLegendPen(getColor());
+ anItem->setSelected(isSelected());
+ anItem->setColor( isSelected() ? Plot2d_Object::selectionColor() : getColor() );
}
/*!
#include "Plot2d_Object.h"
+
+#include <SUIT_Session.h>
+#include <SUIT_ResourceMgr.h>
+
// color tolerance (used to compare color values)
const long COLOR_DISTANCE = 100;
+
+// Static members
+QColor Plot2d_Object::mySelectionColor;
+QColor Plot2d_Object::myHighlightedLegendTextColor;
+
+/*
+ * Read colors from the resource manager.
+*/
+void Plot2d_Object::initColors() {
+ 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) );
+ }
+}
+
/*!
Constructor
*/
myHorUnits( "" ), myVerUnits( "" ),
myName( "" ),
myXAxis( QwtPlot::xBottom ),
- myYAxis( QwtPlot::yLeft )
+ myYAxis( QwtPlot::yLeft ),
+ myIsSelected(false)
{
}
return tol <= 0;
}
+/*!
+ Sets object's selected property
+*/
+void Plot2d_Object::setSelected(const bool on) {
+ myIsSelected = on;
+}
+
+/*!
+ Gets object's selected property
+*/
+bool Plot2d_Object::isSelected() const {
+ return myIsSelected;
+}
+
+/*!
+ * Sets selection color of the object.
+*/
+void Plot2d_Object::setSelectionColor(const QColor& c) {
+ mySelectionColor = c;
+}
+
+/*!
+ * Return selection color of the object.
+*/
+QColor Plot2d_Object::selectionColor() {
+ return mySelectionColor;
+}
+
+/*!
+ * Sets font color of the selected legend item.
+*/
+void Plot2d_Object::setHighlightedLegendTextColor(const QColor& c) {
+ myHighlightedLegendTextColor = c;
+}
+
+/*!
+ * Sets font color of the selected legend item.
+*/
+QColor Plot2d_Object::highlightedLegendTextColor() {
+ return myHighlightedLegendTextColor;
+}
double getMaxX() const;
double getMinY() const;
double getMaxY() const;
+
+ void setSelected(const bool);
+ bool isSelected() const;
static bool closeColors( const QColor&, const QColor&, int distance = -1 );
+
+ static void initColors();
+
+ static void setSelectionColor(const QColor& c);
+ static QColor selectionColor();
+
+ static void setHighlightedLegendTextColor(const QColor& c);
+ static QColor highlightedLegendTextColor();
protected:
bool myAutoAssign;
QwtPlot::Axis myYAxis;
pointList myPoints;
+ bool myIsSelected;
+
+ private:
+ static QColor mySelectionColor; //!< Color of the selected curve or histogram
+ static QColor myHighlightedLegendTextColor; //!< Color of the selected legend item font
};
typedef QList<Plot2d_Object*> objectList;
// Author : Natalia ERMOLAEVA, Open CASCADE S.A.S. (natalia.donis@opencascade.com)
#include "Plot2d_PlotItems.h"
+#include "Plot2d_Object.h"
#include <QPainter>
+#include <QPalette>
+#include <QLayout>
#include <qwt_plot.h>
#include <qwt_painter.h>
#include <qwt_scale_map.h>
*/
Plot2d_QwtLegendItem::Plot2d_QwtLegendItem( QWidget* parent ) :
QwtLegendItem( parent ),
- myYAxisIdentifierMode( IM_None )
+ myYAxisIdentifierMode( IM_None ),
+ myIsSelected(false)
{
myYAxisLeftIcon = yAxisLeft;
myYAxisRightIcon = yAxisRight;
}
}
+/*!
+ Update highliting on the item.
+*/
+void Plot2d_QwtLegendItem::updateHighlit() {
+ QwtText txt = text();
+ if(isSelected()) {
+ QColor highlightColor = Plot2d_Object::selectionColor();
+ 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);
+ }
+ }
+}
+
+/*!
+ Sets selected property.
+*/
+void Plot2d_QwtLegendItem::setSelected(const bool on) {
+ myIsSelected = on;
+}
+
+/*!
+ Gets selected property.
+*/
+bool Plot2d_QwtLegendItem::isSelected() const {
+ return myIsSelected;
+}
+
+
+/*
+ Draw text of the item.
+*/
void Plot2d_QwtLegendItem::drawText(QPainter * painter, const QRect &rect) {
+ painter->setPen( isSelected() ? Plot2d_Object::highlightedLegendTextColor() :
+ getColorFromPalette( QPalette::Text) );
+
+ QwtLegendItem::drawText( painter, rect );
+}
+
+/*
+ Get color from the legend pallete by 'role' flag.
+*/
+QColor Plot2d_QwtLegendItem::getColorFromPalette(QPalette::ColorRole role) {
QWidget* pw = parentWidget();
- QColor col = palette().color( QPalette::WindowText );
+ QColor col = palette().color( role );
while( pw ) {
if ( qobject_cast<QwtLegend*>( pw ) ) {
- col = pw->palette().color( QPalette::WindowText );
+ col = pw->palette().color(role );
break;
}
pw = pw->parentWidget();
}
- painter->setPen( col );
- QwtLegendItem::drawText( painter, rect );
+ return col;
}
/*!
*/
Plot2d_QwtPlotCurve::Plot2d_QwtPlotCurve( const QString& title,
QwtPlot::Axis yAxis /*const int index*/ ) :
+ Plot2d_SelectableItem(),
QwtPlotCurve( title ),
myYAxis( yAxis ),
- myYAxisIdentifierEnabled( false )
+ myYAxisIdentifierEnabled( false )
{
}
*/
void Plot2d_QwtPlotCurve::updateLegend( QwtLegend* legend ) const
{
- QwtPlotCurve::updateLegend( legend );
-
- if ( legend ) {
- QWidget* widget = legend->find( this );
+ if ( !legend )
+ 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( Plot2d_QwtLegendItem* anItem = dynamic_cast<Plot2d_QwtLegendItem*>( widget ) ) {
int aMode = Plot2d_QwtLegendItem::IM_None;
if( myYAxisIdentifierEnabled )
Plot2d_QwtLegendItem::IM_Right :
Plot2d_QwtLegendItem::IM_Left;
anItem->setYAxisIdentifierMode( aMode );
+ if(isSelected()) {
+ anItem->setCurvePen(legendPen());
+ anItem->setSymbol(legendSymbol());
+ }
+ anItem->setSelected(isSelected());
+ anItem->updateHighlit();
}
}
}
{
return new Plot2d_QwtLegendItem;
}
+/*!
+ Constructor.
+*/
+Plot2d_SelectableItem::Plot2d_SelectableItem():
+ myIsSelected(false)
+{
+}
+
+/*!
+ Destructor.
+*/
+Plot2d_SelectableItem::~Plot2d_SelectableItem()
+{
+}
+
+/*!
+ Sets selected property.
+*/
+void Plot2d_SelectableItem::setSelected( const bool on) {
+ myIsSelected = on;
+}
+
+/*!
+ Return selected property.
+*/
+bool Plot2d_SelectableItem::isSelected() const {
+ return myIsSelected;
+}
+
+/*!
+ Sets legend pen property.
+*/
+void Plot2d_SelectableItem::setLegendPen( const QPen & p) {
+ myLegendPen = p;
+}
+
+/*!
+ Return legend pen property.
+*/
+QPen Plot2d_SelectableItem::legendPen() const {
+ return myLegendPen;
+}
+
+/*!
+ Sets legend symbol property.
+*/
+void Plot2d_SelectableItem::setLegendSymbol(const QwtSymbol& s) {
+ myLegendSymbol = s;
+}
+
+/*!
+ Sets legend symbol property.
+*/
+QwtSymbol Plot2d_SelectableItem::legendSymbol() const {
+ return myLegendSymbol;
+}
/*!
Constructor
Constructor
*/
Plot2d_HistogramItem::Plot2d_HistogramItem( const QwtText& theTitle )
-: Plot2d_HistogramQwtItem( theTitle ),
+: Plot2d_HistogramQwtItem( theTitle ),
+ Plot2d_SelectableItem(),
myCrossed( true )
{
}
if ( !theWidget || !theWidget->inherits( "QwtLegendItem" ) )
return;
- QwtLegendItem* anItem = ( QwtLegendItem* )theWidget;
+ Plot2d_QwtLegendItem* anItem = ( Plot2d_QwtLegendItem* )theWidget;
QFontMetrics aFMetrics( anItem->font() );
int aSize = aFMetrics.height();
- QwtSymbol aSymbol( QwtSymbol::Rect, QBrush( color() ),
- QPen( color() ), QSize( aSize, aSize ) );
+ 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();
}
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.
*/
public:
void setYAxisIdentifierMode( const int );
+ void updateHighlit();
+ void setSelected(const bool on);
+ bool isSelected() const;
+ QColor getColorFromPalette(QPalette::ColorRole role);
protected:
virtual void drawIdentifier( QPainter*, const QRect& ) const;
virtual void drawText(QPainter *, const QRect &);
+private:
+
private:
int myYAxisIdentifierMode;
QPixmap myYAxisLeftIcon;
QPixmap myYAxisRightIcon;
int mySpacingCollapsed;
int mySpacingExpanded;
+ bool myIsSelected;
};
-class PLOT2D_EXPORT Plot2d_QwtPlotCurve : public QwtPlotCurve
+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;
+
+private:
+ bool myIsSelected;
+ QPen myLegendPen;
+ QwtSymbol myLegendSymbol;
+};
+
+class PLOT2D_EXPORT Plot2d_QwtPlotCurve : public QwtPlotCurve, public Plot2d_SelectableItem
{
public:
Plot2d_QwtPlotCurve( const QString&, QwtPlot::Axis = QwtPlot::yLeft );
double myReference;
};
-class PLOT2D_EXPORT Plot2d_HistogramItem : public Plot2d_HistogramQwtItem
+class PLOT2D_EXPORT Plot2d_HistogramItem : public Plot2d_HistogramQwtItem, public Plot2d_SelectableItem
{
public:
explicit Plot2d_HistogramItem( const QString& = QString() );
const QRect& ) const;
int getCrossedTop( const QRect& ) const;
+ virtual QWidget* legendItem() const;
+
protected:
QList<QRect> myBarItems;
bool myCrossed;
setBackgroundColor( myBackground );
setLegendPos( myLegendPos );
setLegendFont( myLegendFont );
- setLegendColor( myLegendColor );
+ setLegendFontColor( 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 );
+ myLegendColor = resMgr->colorValue( "Plot2d", "LegendFontColor", myLegendColor );
myMarkerSize = resMgr->integerValue( "Plot2d", "MarkerSize", myMarkerSize );
myBackground = resMgr->colorValue( "Plot2d", "Background", myBackground );
resMgr->setValue( "Plot2d", "ShowLegend", myShowLegend );
resMgr->setValue( "Plot2d", "LegendPos", myLegendPos );
resMgr->setValue( "Plot2d", "LegendFont", myLegendFont );
- resMgr->setValue( "Plot2d", "LegendColor", myLegendColor );
+ resMgr->setValue( "Plot2d", "LegendFontColor", myLegendColor );
resMgr->setValue( "Plot2d", "MarkerSize", myMarkerSize );
resMgr->setValue( "Plot2d", "Background", myBackground );
resMgr->setValue( "Plot2d", "ShowTitle", myTitleEnabled );
{
if ( !object )
return;
-
+
if ( object->getYAxis() == QwtPlot::yRight )
mySecondY = true;
}
}
+/*!
+ update legend
+*/
+void Plot2d_ViewFrame::updateLegend() {
+ if ( myPlot->getLegend() ) {
+ ObjectDict::iterator it = myObjects.begin();
+ for( ; it != myObjects.end(); ++it )
+ it.key()->updateLegend(myPlot->getLegend());
+ }
+}
+
+
/*!
Fits the view to see all data
*/
setLegendFont( dlg->getLegendFont() );
}
if ( myLegendColor != dlg->getLegendColor() ) {
- setLegendColor( dlg->getLegendColor() );
+ setLegendFontColor( dlg->getLegendColor() );
}
// marker size
QwtLegend* legend = myPlot->legend();
if ( !legend ) {
legend = new QwtLegend( myPlot );
- legend->setFrameStyle( QFrame::Box | QFrame::Sunken );
+ legend->setFrameStyle( QFrame::Box | QFrame::Sunken );
}
legend->setItemMode( QwtLegend::ClickableItem );
myPlot->insertLegend( legend );
setLegendPos( myLegendPos );
setLegendFont( myLegendFont );
- setLegendColor( myLegendColor );
+ setLegendFontColor( myLegendColor );
}
else
myPlot->insertLegend( 0 );
/*!
Gets legend font color
*/
-QColor Plot2d_ViewFrame::getLegendColor() const
+QColor Plot2d_ViewFrame::getLegendFontColor() const
{
return myLegendColor;
}
/*!
Sets legend font color
*/
-void Plot2d_ViewFrame::setLegendColor( const QColor& col )
+void Plot2d_ViewFrame::setLegendFontColor( const QColor& col )
{
myLegendColor = col;
QwtLegend* legend = myPlot->legend();
if ( legend ) {
QPalette pal = legend->palette();
- pal.setColor( QPalette::WindowText, col );
+ pal.setColor( QPalette::Text, col );
legend->setPalette( pal );
}
}
QwtSymbol aSymbol = crv->symbol();
aSymbol.setSize( myMarkerSize, myMarkerSize );
crv->setSymbol( aSymbol );
+ if(it.value())
+ it.value()->setMarkerSize( myMarkerSize );
}
}
if ( update )
aPal.setColor( QPalette::Background, myBackground );
}
myPlot->getLegend()->setPalette( aPal );
+ updateLegend();
}
Repaint();
}
void updateObject( Plot2d_Object*, bool = false );
void updateLegend( const Plot2d_Prs* );
+ void updateLegend();
void fitAll();
void fitArea( const QRect& );
void fitData( const int, const double, const double,
int getLegendPos() const;
void setLegendFont( const QFont& );
QFont getLegendFont() const;
- void setLegendColor( const QColor& );
- QColor getLegendColor() const;
+ void setLegendFontColor( const QColor& );
+ QColor getLegendFontColor() const;
void setMarkerSize( const int, bool = true );
int getMarkerSize() const;
void setBackgroundColor( const QColor& );
{
myPrs = 0;
myAutoDel = theAutoDel;
+ Plot2d_Object::initColors();
}
/*!
public:
static QString Type() { return "Plot2d"; }
-
+
Plot2d_Viewer(bool theAutoDel = false);
~Plot2d_Viewer();
#include "SUIT_ViewManager.h"
#include "SALOME_ListIO.hxx"
+#include "SALOME_ListIteratorOfListIO.hxx"
#include <QApplication>
#include <QToolBar>
emit legendSelected( anEntry );
}
}
+
+/*!
+
+*/
+void SPlot2d_Viewer::setObjectsSelected( SALOME_ListIO& theList ) {
+ Plot2d_ViewFrame* aViewFrame = getActiveViewFrame();
+ if(aViewFrame) {
+
+ objectList allObjects;
+ aViewFrame->getObjects( allObjects );
+
+ bool isSelected = false;
+ SPlot2d_Histogram* h = 0;
+ SPlot2d_Curve* c =0;
+
+ foreach ( Plot2d_Object* o, allObjects ) {
+ isSelected = false;
+
+ Handle(SALOME_InteractiveObject) io;
+ if( (h = dynamic_cast<SPlot2d_Histogram*>(o)) && h->hasIO() ) {
+ io = h->getIO();
+ } else if((c = dynamic_cast<SPlot2d_Curve*>(o)) && c->hasIO()) {
+ io = c->getIO();
+ } else {
+ continue;
+ }
+
+ SALOME_ListIteratorOfListIO anIter( theList );
+
+ for( ; anIter.More(); anIter.Next() ) {
+ if ( anIter.Value()->hasEntry() ) {
+ if( io->isSame(anIter.Value()) ) {
+ isSelected = o->isSelected();
+ if( !isSelected ) {
+ o->setSelected(true);
+ aViewFrame->updateObject(o);
+ theList.Remove(anIter);
+ isSelected = true;
+ break;
+ } else
+ break;
+ }
+ }
+ }
+ if( !isSelected && o->isSelected() != false ) {
+ o->setSelected(false);
+ aViewFrame->updateObject(o);
+ }
+ }
+ aViewFrame->Repaint();
+ }
+}
virtual bool isVisible( const Handle(SALOME_InteractiveObject)& IObject );
virtual void GetVisible( SALOME_ListIO& theList );
+ virtual void setObjectsSelected( SALOME_ListIO& theList );
+
/* operations */
SPlot2d_Curve* getCurveByIO( const Handle(SALOME_InteractiveObject)&, Plot2d_ViewFrame* = 0 );