From: ouv Date: Wed, 14 Nov 2018 10:55:17 +0000 (+0300) Subject: 0004412: External 9984 Add text X-Git-Tag: CTH_2_3_2~3 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=ef4d0d2d183e2da7e0c4047d058c6df491b74b5e;p=modules%2Fgui.git 0004412: External 9984 Add text --- diff --git a/adm_local/win32/Plot2d.vcproj b/adm_local/win32/Plot2d.vcproj index 3b3051d54..e7506bbf9 100644 --- a/adm_local/win32/Plot2d.vcproj +++ b/adm_local/win32/Plot2d.vcproj @@ -1,7 +1,7 @@ + + + + + + + + + + + + + + @@ -707,6 +751,48 @@ /> + + + + + + + + + + + + + + @@ -725,7 +811,7 @@ > @@ -745,7 +831,7 @@ > @@ -948,6 +1034,10 @@ RelativePath="..\..\src\Plot2d\Plot2d_Prs.cxx" > + + @@ -960,6 +1050,10 @@ RelativePath="..\..\src\Plot2d\Plot2d_SetupViewDlg.cxx" > + + @@ -1073,6 +1167,50 @@ /> + + + + + + + + + + + + + + @@ -1962,6 +2100,10 @@ RelativePath="..\..\moc\moc_Plot2d_FitDataDlg.cxx" > + + diff --git a/src/Plot2d/Plot2d_SetupCommentsDlg.cxx b/src/Plot2d/Plot2d_SetupCommentsDlg.cxx new file mode 100644 index 000000000..74d246c69 --- /dev/null +++ b/src/Plot2d/Plot2d_SetupCommentsDlg.cxx @@ -0,0 +1,352 @@ +// Copyright (C) 2005 OPEN CASCADE, CEA/DEN, EDF R&D, PRINCIPIA R&D +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// +// SALOME Plot2d : implementation of desktop and GUI kernel +// +#include "Plot2d_SetupCommentsDlg.h" + +#include + +#include +#include + +#include +#include +#include +#include +#include +#include +#include + +#define TEXT_COL 0 +#define X_COL 1 +#define Y_COL 2 +#define ALIGNMENT_COL 3 + +//============================================================================= +// Class : Plot2d_SetupCommentsDlg::ItemDelegate +// Purpose : +//============================================================================= +class Plot2d_SetupCommentsDlg::ItemDelegate : public QItemDelegate +{ +public: + ItemDelegate( QObject* theParent, QValidator* theValidator ) + : myValidator( theValidator ) {} + +public: + virtual QWidget* createEditor( QWidget* theParent, + const QStyleOptionViewItem& theOption, + const QModelIndex& ) const + { + QLineEdit* aLineEdit = new QLineEdit( theParent ); + aLineEdit->setValidator( myValidator ); + return aLineEdit; + } + +private: + QValidator* myValidator; +}; + +//============================================================================= +// Function : Plot2d_SetupCommentsDlg +// Purpose : Constructor +//============================================================================= +Plot2d_SetupCommentsDlg::Plot2d_SetupCommentsDlg( QWidget* theParent ) +: QtxDialog( theParent, true, false, QtxDialog::OKCancel ) +{ + SUIT_ResourceMgr* aResMgr = SUIT_Session::session()->resourceMgr(); + setWindowTitle( tr( "SETUP_COMMENTS" ) ); + + QValidator* aDoubleValidator = new QDoubleValidator( this ); + + QFrame* aMainFrame = mainFrame(); + + QtxGroupBox* aGrp = new QtxGroupBox( aMainFrame ); + aGrp->setTitle( tr( "PARAMETERS" ) ); + + myTable = new QTableWidget( aGrp ); + myTable->setSelectionMode( QTableWidget::ExtendedSelection ); + + myTable->setRowCount( 0 ); + myTable->setColumnCount( 4 ); + + QStringList aLabels = QStringList() << tr( "TEXT" ) << tr( "X" ) << tr( "Y" ) << tr( "ALIGNMENT" ); + myTable->setHorizontalHeaderLabels( aLabels ); + + myTable->horizontalHeader()->setResizeMode( TEXT_COL, QHeaderView::Stretch ); + myTable->horizontalHeader()->setResizeMode( X_COL, QHeaderView::Fixed ); + myTable->horizontalHeader()->setResizeMode( Y_COL, QHeaderView::Fixed ); + myTable->horizontalHeader()->setResizeMode( ALIGNMENT_COL, QHeaderView::Fixed ); + myTable->horizontalHeader()->setHighlightSections( false ); + + myTable->setColumnWidth( X_COL, 80 ); + myTable->setColumnWidth( Y_COL, 80 ); + myTable->setColumnWidth( ALIGNMENT_COL, 100 ); + + myTable->verticalHeader()->setDefaultSectionSize( 20 ); + myTable->verticalHeader()->hide(); + + myTable->setItemDelegateForColumn( X_COL, new ItemDelegate( myTable, aDoubleValidator ) ); + myTable->setItemDelegateForColumn( Y_COL, new ItemDelegate( myTable, aDoubleValidator ) ); + + QPixmap aRemovePixmap = aResMgr->loadPixmap( "Plot2d", tr( "ICON_MINUS" ) ); + QToolButton* aRemoveBtn = new QToolButton( aGrp ); + aRemoveBtn->setIcon( aRemovePixmap ); + aRemoveBtn->setFixedSize( aRemovePixmap.size() ); + aGrp->insertTitleWidget( aRemoveBtn ); + + QVBoxLayout* aGrpLayout = new QVBoxLayout( aGrp ); + aGrpLayout->setMargin( 5 ); + aGrpLayout->setSpacing( 5 ); + aGrpLayout->addWidget( myTable ); + + QVBoxLayout* aMainLayout = new QVBoxLayout( aMainFrame ); + aMainLayout->setMargin( 0 ); + aMainLayout->setSpacing( 0 ); + aMainLayout->addWidget( aGrp ); + + connect( myTable, SIGNAL( cellChanged( int, int ) ), SLOT( onValueChanged( int, int ) ) ); + connect( aRemoveBtn, SIGNAL( clicked() ), SLOT( onRemove() ) ); + + setButtonPosition( Right, Cancel ); + + setMinimumSize( 500, 300 ); +} + +//============================================================================= +// Function : Plot2d_SetupCommentsDlg +// Purpose : Destructor +//============================================================================= +Plot2d_SetupCommentsDlg::~Plot2d_SetupCommentsDlg() +{ +} + +//============================================================================= +// Function : getAlignments +// Purpose : +//============================================================================= +void Plot2d_SetupCommentsDlg::getAlignments( QStringList& theStrings, + QList< Qt::Alignment >& theValues ) const +{ + static QStringList aStrings; + static QList< Qt::Alignment > aValues; + if( aStrings.isEmpty() && aValues.isEmpty() ) + { + aStrings.append( tr( "TOP_LEFT" ) ); + aValues.append( Qt::AlignTop | Qt::AlignLeft ); + + aStrings.append( tr( "TOP_RIGHT" ) ); + aValues.append( Qt::AlignTop | Qt::AlignRight ); + + aStrings.append( tr( "BOTTOM_LEFT" ) ); + aValues.append( Qt::AlignBottom | Qt::AlignLeft ); + + aStrings.append( tr( "BOTTOM_RIGHT" ) ); + aValues.append( Qt::AlignBottom | Qt::AlignRight ); + + aStrings.append( tr( "CENTER" ) ); + aValues.append( Qt::AlignCenter ); + } + theStrings = aStrings; + theValues = aValues; +} + +//============================================================================= +// Function : setCombo +// Purpose : +//============================================================================= +void Plot2d_SetupCommentsDlg::setCombo( const int theRow, + const int theCol, + const QStringList& theStrings, + const QList< Qt::Alignment >& theValues, + const Qt::Alignment theCurrentValue ) +{ + QComboBox* aCombo = new QComboBox( myTable ); + + int anIndex = 0; + QStringListIterator aStringIter( theStrings ); + QListIterator< Qt::Alignment > aValueIter( theValues ); + while( aStringIter.hasNext() && aValueIter.hasNext() ) + { + const QString& aString = aStringIter.next(); + Qt::Alignment aValue = aValueIter.next(); + aCombo->addItem( aString, int( aValue ) ); + if( aValue == theCurrentValue ) + aCombo->setCurrentIndex( anIndex ); + anIndex++; + } + + myTable->setCellWidget( theRow, theCol, aCombo ); +} + +//============================================================================= +// Function : setText +// Purpose : +//============================================================================= +void Plot2d_SetupCommentsDlg::setText( const int theRow, + const int theCol, + const QString& theText ) +{ + QTableWidgetItem* anItem = myTable->item( theRow, theCol ); + if ( !anItem ) + { + anItem = new QTableWidgetItem( theText ); + myTable->setItem( theRow, theCol, anItem ); + } + else + anItem->setText( theText ); +} + +//============================================================================= +// Function : getText +// Purpose : +//============================================================================= +QString Plot2d_SetupCommentsDlg::getText( const int theRow, + const int theCol ) const +{ + if( QTableWidgetItem* anItem = myTable->item( theRow, theCol ) ) + return anItem->text(); + return QString(); +} + +//============================================================================= +// Function : SetParameters +// Purpose : +//============================================================================= +void Plot2d_SetupCommentsDlg::SetParameters( const QVector< QString >& theTextList, + const QVector< double >& theXList, + const QVector< double >& theYList, + const QVector< Qt::Alignment >& theAlignmentList ) +{ + int nbRows = qMax( qMax( theTextList.size(), theAlignmentList.size() ), + qMax( theXList.size(), theYList.size() ) ); + myTable->setRowCount( nbRows ); + + QStringList anAlignmentStrings; + QList< Qt::Alignment > anAlignmentValues; + getAlignments( anAlignmentStrings, anAlignmentValues ); + + for ( int i = 0; i < nbRows; i++ ) + { + setText( i, TEXT_COL, theTextList[ i ] ); + setText( i, X_COL, QString( "%1" ).arg( theXList[ i ] ) ); + setText( i, Y_COL, QString( "%1" ).arg( theYList[ i ] ) ); + setCombo( i, ALIGNMENT_COL, anAlignmentStrings, anAlignmentValues, theAlignmentList[ i ] ); + } + + myRemovedIndexes.clear(); +} + +//============================================================================= +// Function : GetParameters +// Purpose : +//============================================================================= +void Plot2d_SetupCommentsDlg::GetParameters( QVector< QString >& theTextList, + QVector< double >& theXList, + QVector< double >& theYList, + QVector< Qt::Alignment >& theAlignmentList ) const +{ + int nbRows = myTable->rowCount(); + + theTextList.resize( nbRows ); + theXList.resize( nbRows ); + theYList.resize( nbRows ); + theAlignmentList.resize( nbRows ); + + bool anIsOk; + for ( int i = 0; i < nbRows; i++ ) + { + theTextList[ i ] = getText( i, TEXT_COL ); + + anIsOk = false; + double aX = getText( i, X_COL ).toDouble( &anIsOk ); + theXList[ i ] = anIsOk ? aX : 0; + + anIsOk = false; + double aY = getText( i, Y_COL ).toDouble( &anIsOk ); + theYList[ i ] = anIsOk ? aY : 0; + + anIsOk = false; + Qt::Alignment anAlignment = Qt::AlignTop | Qt::AlignLeft; + if( QComboBox* aCombo = dynamic_cast( myTable->cellWidget( i, ALIGNMENT_COL ) ) ) + { + anAlignment = (Qt::Alignment)aCombo->itemData( aCombo->currentIndex() ).toInt( &anIsOk ); + if( !anIsOk ) + anAlignment = Qt::AlignTop | Qt::AlignLeft; + } + theAlignmentList[ i ] = anAlignment; + } +} + +//============================================================================= +// Function : GetRemovedIndexes +// Purpose : +//============================================================================= +const QList< int >& Plot2d_SetupCommentsDlg::GetRemovedIndexes() const +{ + return myRemovedIndexes; +} + +//============================================================================= +// Function : onRemove +// Purpose : +//============================================================================= +void Plot2d_SetupCommentsDlg::onRemove() +{ + QList< int > toRemove; + + int aCurrRow = myTable->currentRow(); + int aCurrCol = myTable->currentColumn(); + + // get selected rows + QSet< int > aSelRows; + QList aRegs = myTable->selectedRanges(); + QList::iterator selIter; + for ( selIter = aRegs.begin(); selIter != aRegs.end(); ++selIter ) + { + const QTableWidgetSelectionRange& aReg = *selIter; + for ( int i = aReg.topRow(), n = aReg.bottomRow(); i <= n; i++ ) + aSelRows.insert( i ); + } + + int i, n; + for ( i = 0, n = myTable->rowCount(); i < n; i++ ) + { + if ( aSelRows.contains( i ) || aCurrRow == i ) + toRemove.append( i ); + } + + if ( !toRemove.count() ) + return; + + int nbRemoved = 0; + QList< int >::iterator anIter; + for ( anIter = toRemove.begin(); anIter != toRemove.end(); ++anIter ) + { + int aRow = *anIter - nbRemoved; + myTable->removeRow( aRow ); + myRemovedIndexes.append( aRow ); + nbRemoved++; + } + + int nbRows = myTable->rowCount(); + if ( aCurrRow < nbRows && aCurrRow >= 0 && aCurrCol >= 0 ) + myTable->setCurrentCell( aCurrRow, aCurrCol ); + else if ( nbRows > 0 && aCurrCol >= 0 ) + myTable->setCurrentCell( nbRows - 1, aCurrCol ); +} diff --git a/src/Plot2d/Plot2d_SetupCommentsDlg.h b/src/Plot2d/Plot2d_SetupCommentsDlg.h new file mode 100644 index 000000000..c88f84451 --- /dev/null +++ b/src/Plot2d/Plot2d_SetupCommentsDlg.h @@ -0,0 +1,83 @@ +// Copyright (C) 2005 OPEN CASCADE, CEA/DEN, EDF R&D, PRINCIPIA R&D +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// +#ifndef PLOT2D_SETUPCOMMENTSDLG_H +#define PLOT2D_SETUPCOMMENTSDLG_H + +#include "Plot2d.h" + +#include + +#include +#include + +class QTableWidget; + +/*! + \class Plot2d_SetupCommentsDlg + Dialog box for setup Plot2d comments parameters +*/ + +class PLOT2D_EXPORT Plot2d_SetupCommentsDlg : public QtxDialog +{ + Q_OBJECT + + class ItemDelegate; + +public: + Plot2d_SetupCommentsDlg( QWidget* theParent = 0 ); + virtual ~Plot2d_SetupCommentsDlg(); + + void SetParameters( const QVector< QString >& theTextList, + const QVector< double >& theXList, + const QVector< double >& theYList, + const QVector< Qt::Alignment >& theAlignmentList ); + + void GetParameters( QVector< QString >& theTextList, + QVector< double >& theXList, + QVector< double >& theYList, + QVector< Qt::Alignment >& theAlignmentList ) const; + + const QList< int >& GetRemovedIndexes() const; + +private slots: + void onRemove(); + +private: + void getAlignments( QStringList& theStrings, + QList< Qt::Alignment >& theValues ) const; + + void setCombo( const int theRow, + const int theCol, + const QStringList& theStrings, + const QList< Qt::Alignment >& theValues, + const Qt::Alignment theCurrentValue ); + + void setText( const int theRow, + const int theCol, + const QString& theText ); + + QString getText( const int theRow, + const int theCol ) const; + +private: + QTableWidget* myTable; + QList< int > myRemovedIndexes; +}; + +#endif diff --git a/src/Plot2d/Plot2d_TextMarker.cxx b/src/Plot2d/Plot2d_TextMarker.cxx new file mode 100644 index 000000000..ec8377b5c --- /dev/null +++ b/src/Plot2d/Plot2d_TextMarker.cxx @@ -0,0 +1,78 @@ +// Copyright (C) 2005 OPEN CASCADE, CEA/DEN, EDF R&D, PRINCIPIA R&D +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// +#include "Plot2d_TextMarker.h" + +//============================================================================= +// Function : Plot2d_TextMarker +// Purpose : Constructor +//============================================================================= +Plot2d_TextMarker::Plot2d_TextMarker() : QwtPlotMarker() +{ +} + +//============================================================================= +// Function : Plot2d_TextMarker +// Purpose : Destructor +//============================================================================= +Plot2d_TextMarker::~Plot2d_TextMarker() +{ +} + +//============================================================================= +// Function : setData +// Purpose : +//============================================================================= +void Plot2d_TextMarker::setData( const QString& theText, + const double theX, + const double theY, + const Qt::Alignment theAlignment ) +{ + QwtText aLabel = label(); + aLabel.setText( theText ); + setLabel( aLabel ); + + QwtSymbol aSymbol = symbol(); + if( theAlignment == Qt::AlignCenter ) + aSymbol.setStyle( QwtSymbol::NoSymbol ); + else + { + aSymbol.setStyle( QwtSymbol::Ellipse ); + aSymbol.setSize( QSize( 3, 3 ) ); + } + setSymbol( aSymbol ); + + setLabelAlignment( theAlignment ); + + setValue( theX, theY ); +} + +//============================================================================= +// Function : getData +// Purpose : +//============================================================================= +void Plot2d_TextMarker::getData( QString& theText, + double& theX, + double& theY, + Qt::Alignment& theAlignment ) const +{ + theText = label().text(); + theX = xValue(); + theY = yValue(); + theAlignment = labelAlignment(); +} diff --git a/src/Plot2d/Plot2d_TextMarker.h b/src/Plot2d/Plot2d_TextMarker.h new file mode 100644 index 000000000..37b01d20a --- /dev/null +++ b/src/Plot2d/Plot2d_TextMarker.h @@ -0,0 +1,45 @@ +// Copyright (C) 2005 OPEN CASCADE, CEA/DEN, EDF R&D, PRINCIPIA R&D +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// +#ifndef PLOT2D_TEXTMARKER_H +#define PLOT2D_TEXTMARKER_H + +#include "Plot2d.h" + +#include + +class PLOT2D_EXPORT Plot2d_TextMarker : public QwtPlotMarker +{ +public: + Plot2d_TextMarker(); + virtual ~Plot2d_TextMarker(); + + void setData( const QString& theText, + const double theX, + const double theY, + const Qt::Alignment theAlignment ); + + void getData( QString& theText, + double& theX, + double& theY, + Qt::Alignment& theAlignment ) const; + +protected: +}; + +#endif diff --git a/src/Plot2d/Plot2d_ViewFrame.cxx b/src/Plot2d/Plot2d_ViewFrame.cxx index edaf43c31..4ffc36b64 100755 --- a/src/Plot2d/Plot2d_ViewFrame.cxx +++ b/src/Plot2d/Plot2d_ViewFrame.cxx @@ -21,6 +21,7 @@ #include "Plot2d_Prs.h" #include "Plot2d_Curve.h" #include "Plot2d_SetupCurvesDlg.h" +#include "Plot2d_SetupCommentsDlg.h" #include "Plot2d_FitDataDlg.h" #include "Plot2d_ViewWindow.h" #include "Plot2d_SetupViewDlg.h" @@ -788,7 +789,7 @@ void Plot2d_ViewFrame::updateCurve( Plot2d_Curve* curve, bool update ) } /*! - Gets lsit of displayed curves + Gets list of displayed curves */ int Plot2d_ViewFrame::getCurves( curveList& clist ) { @@ -800,11 +801,45 @@ int Plot2d_ViewFrame::getCurves( curveList& clist ) return clist.count(); } +/*! + Gets list of displayed curves +*/ const CurveDict& Plot2d_ViewFrame::getCurves() { return myPlot->getCurves(); } +/*! + Displays comment +*/ +void Plot2d_ViewFrame::displayComment( Plot2d_TextMarker* comment, bool update ) +{ + comment->attach( myPlot ); + myPlot->getComments().append( comment ); + if( update ) + myPlot->replot(); +} + +/*! + Erases comment +*/ +void Plot2d_ViewFrame::eraseComment( Plot2d_TextMarker* comment, bool update ) +{ + comment->hide(); + comment->detach(); + myPlot->getComments().removeAll( comment ); + if( update ) + myPlot->replot(); +} + +/*! + Gets list of displayed comments +*/ +const CommentList& Plot2d_ViewFrame::getComments() +{ + return myPlot->getComments(); +} + /*! Returns true if the curve is visible */ @@ -1269,6 +1304,87 @@ void Plot2d_ViewFrame::onCurvesSettings() delete aDlg; } +/*! + "Comments settings" toolbar action slot +*/ +void Plot2d_ViewFrame::onCommentsSettings() +{ + Plot2d_SetupCommentsDlg* aDlg = new Plot2d_SetupCommentsDlg( this ); + + int nbComments = myPlot->getComments().count(); + if ( nbComments == 0 ) + return; + + QVector< QString > aTextList( nbComments ); + QVector< double > aXList( nbComments ); + QVector< double > aYList( nbComments ); + QVector< Qt::Alignment > anAlignmentList( nbComments ); + + CommentList aComments; + + CommentList::Iterator it = myPlot->getComments().begin(); + int i = 0; + for ( i = 0; it != myPlot->getComments().end(); it++, i++ ) + { + Plot2d_TextMarker* aComment = *it; + if ( !aComment ) + return; + + QString aText; + double aX = 0, aY = 0; + Qt::Alignment anAlignment = Qt::AlignTop | Qt::AlignLeft; + aComment->getData( aText, aX, aY, anAlignment ); + + aTextList[ i ] = aText; + aXList[ i ] = aX; + aYList[ i ] = aY; + anAlignmentList[ i ] = anAlignment; + + aComments.append( aComment ); + } + + aDlg->SetParameters( aTextList, aXList, aYList, anAlignmentList ); + + if ( aDlg->exec() != QDialog::Accepted ) + return; + + const QList< int >& toRemove = aDlg->GetRemovedIndexes(); + QList< int >::const_iterator aRemIter; + for ( aRemIter = toRemove.begin(); aRemIter != toRemove.end(); ++aRemIter ) + { + int anIndex = *aRemIter; + if ( anIndex >= 0 && anIndex < (int)aComments.count() ) + { + Plot2d_TextMarker* aComment = aComments[ anIndex ]; + aComments.removeAt( anIndex ); + eraseComment( aComment ); + } + } + + QMap< int, Plot2d_TextMarker* > anIndexToComment; + QList< Plot2d_TextMarker* >::iterator aCurvIter; + for ( i = 0, aCurvIter = aComments.begin(); aCurvIter != aComments.end(); ++aCurvIter, ++i ) + anIndexToComment[ i ] = *aCurvIter; + + aDlg->GetParameters( aTextList, aXList, aYList, anAlignmentList ); + + int n; + for ( i = 0, n = aTextList.size(); i < n; i++ ) + { + QString aText = aTextList[ i ]; + double aX = aXList[ i ]; + double aY = aYList[ i ]; + Qt::Alignment anAlignment = anAlignmentList[ i ]; + + if( Plot2d_TextMarker* aComment = anIndexToComment[ i ] ) + aComment->setData( aText, aX, aY, anAlignment ); + } + + Repaint(); + + delete aDlg; +} + /*! "Fit Data" command slot */ diff --git a/src/Plot2d/Plot2d_ViewFrame.h b/src/Plot2d/Plot2d_ViewFrame.h index 4ad6f7057..20e633cb7 100755 --- a/src/Plot2d/Plot2d_ViewFrame.h +++ b/src/Plot2d/Plot2d_ViewFrame.h @@ -20,6 +20,7 @@ #define PLOT2D_VIEWFRAME_H #include "Plot2d_Curve.h" +#include "Plot2d_TextMarker.h" #include #include @@ -38,6 +39,8 @@ typedef QwtPlotCurve* QwtPlotCurvePtr; typedef Plot2d_Curve* Plot2d_CurvePtr; typedef QtxMap CurveDict; +typedef QList CommentList; + class PLOT2D_EXPORT Plot2d_ViewFrame : public QWidget { Q_OBJECT @@ -76,6 +79,9 @@ public: void eraseCurves( const curveList& curves, bool update = false ); int getCurves( curveList& clist ); const CurveDict& getCurves(); + void displayComment( Plot2d_TextMarker* comment, bool update = false ); + void eraseComment( Plot2d_TextMarker* comment, bool update = false ); + const CommentList& getComments(); bool isVisible( Plot2d_Curve* curve ); void updateCurve( Plot2d_Curve* curve, bool update = false ); void updateLegend( const Plot2d_Prs* prs ); @@ -181,6 +187,7 @@ public slots: void onViewGlobalPan(); void onSettings(); void onCurvesSettings(); + void onCommentsSettings(); void onFitData(); void onChangeBackground(); void onPanLeft(); @@ -282,7 +289,8 @@ public: bool polished() const { return myIsPolished; } QwtPlotGrid* grid() { return myGrid; }; - CurveDict& getCurves() { return myCurves; } + CurveDict& getCurves() { return myCurves; } + CommentList& getComments() { return myComments; } Plot2d_Curve* getClosestCurve( QPoint p, double& distance, int& index ); QList getClosestPoints( QPoint thePoint, double theRadius, QList< QList< int > >& thePntIndex ); @@ -310,6 +318,7 @@ signals: protected: CurveDict myCurves; + CommentList myComments; QwtPlotGrid* myGrid; QList myColors; bool myIsPolished; diff --git a/src/Plot2d/Plot2d_ViewWindow.cxx b/src/Plot2d/Plot2d_ViewWindow.cxx index fc8680a5c..a4c8826b1 100755 --- a/src/Plot2d/Plot2d_ViewWindow.cxx +++ b/src/Plot2d/Plot2d_ViewWindow.cxx @@ -145,6 +145,7 @@ void Plot2d_ViewWindow::contextMenuPopup( QMenu* thePopup ) // settings thePopup->addAction( mgr->action( CurvSettingsId ) ); thePopup->addAction( mgr->action( CurvesSettingsId ) ); + thePopup->addAction( mgr->action( CommentsSettingsId ) ); } /*! @@ -360,15 +361,23 @@ void Plot2d_ViewWindow::createActions() connect( aAction, SIGNAL( triggered( bool ) ), myViewFrame, SLOT( onSettings() ) ); mgr->registerAction( aAction, CurvSettingsId ); - // 8. Curves Settings + // 9.1. Curves Settings aAction = new QtxAction( tr( "TOT_CURVES_SETTINGS"), aResMgr->loadPixmap("Plot2d", tr("ICON_CURVES_SETTINGS")), tr("MEN_CURVES_SETTINGS"), 0, this); aAction->setStatusTip( tr( "PRP_CURVES_SETTINGS") ); connect( aAction, SIGNAL( triggered( bool ) ), myViewFrame, SLOT( onCurvesSettings() ) ); mgr->registerAction( aAction, CurvesSettingsId ); - - // 9. Clone + + // 9.2. Comments Settings + aAction = new QtxAction( tr( "TOT_COMMENTS_SETTINGS"), + aResMgr->loadPixmap("Plot2d", tr("ICON_COMMENTS_SETTINGS")), + tr("MEN_COMMENTS_SETTINGS"), 0, this); + aAction->setStatusTip( tr( "PRP_COMMENTS_SETTINGS") ); + connect( aAction, SIGNAL( triggered( bool ) ), myViewFrame, SLOT( onCommentsSettings() ) ); + mgr->registerAction( aAction, CommentsSettingsId ); + + // 10. Clone aAction = new QtxAction( tr( "MNU_CLONE_VIEW" ), aResMgr->loadPixmap( "Plot2d", tr( "ICON_PLOT2D_CLONE_VIEW" ) ), tr( "MNU_CLONE_VIEW" ), @@ -414,6 +423,7 @@ void Plot2d_ViewWindow::createToolBar() mgr->append( LegendId, myToolBar ); mgr->append( CurvSettingsId, myToolBar ); mgr->append( CurvesSettingsId, myToolBar ); + mgr->append( CommentsSettingsId, myToolBar ); mgr->append( CloneId, myToolBar ); } diff --git a/src/Plot2d/Plot2d_ViewWindow.h b/src/Plot2d/Plot2d_ViewWindow.h index 2be1a9d4a..0e55bc112 100755 --- a/src/Plot2d/Plot2d_ViewWindow.h +++ b/src/Plot2d/Plot2d_ViewWindow.h @@ -51,7 +51,7 @@ public: PModeYLinearId, PModeYLogarithmicId, CurvPointsId, CurvLinesId, CurvSplinesId, LegendId, - CurvSettingsId, CurvesSettingsId, + CurvSettingsId, CurvesSettingsId, CommentsSettingsId, CloneId }; public: diff --git a/src/Plot2d/resources/Plot2d_images.ts b/src/Plot2d/resources/Plot2d_images.ts index 23101633b..3c1295013 100644 --- a/src/Plot2d/resources/Plot2d_images.ts +++ b/src/Plot2d/resources/Plot2d_images.ts @@ -73,6 +73,10 @@ ICON_CURVES_SETTINGS plot2d_curves_settings.png + + ICON_COMMENTS_SETTINGS + plot2d_comments_settings.png + ICON_MINUS plot2d_minus.png diff --git a/src/Plot2d/resources/Plot2d_msg_en.ts b/src/Plot2d/resources/Plot2d_msg_en.ts index ab6fcd6ec..27c27377c 100644 --- a/src/Plot2d/resources/Plot2d_msg_en.ts +++ b/src/Plot2d/resources/Plot2d_msg_en.ts @@ -457,6 +457,18 @@ to replace the non-positive values with negligible positive values?PRP_CURVES_SETTINGS Setups curves properties + + TOT_COMMENTS_SETTINGS + Comments settings + + + MEN_COMMENTS_SETTINGS + Comments settings + + + PRP_COMMENTS_SETTINGS + Setups comments properties + CIRCLE_MARKER_LBL Circle @@ -575,23 +587,51 @@ to replace the non-positive values with negligible positive values?Nb markers + + Plot2d_SetupCommentsDlg + + SETUP_COMMENTS + Setup comments + + + PARAMETERS + Parameters + + + TEXT + Text + + + X + X + + + Y + Y + + + ALIGNMENT + Alignment + + + TOP_LEFT + Top left + + + TOP_RIGHT + Top right + + + BOTTOM_LEFT + Bottom left + + + BOTTOM_RIGHT + Bottom right + + + CENTER + Center + + - - - - - - - - - - - - - - - - - - - diff --git a/src/Plot2d/resources/Plot2d_msg_fr.ts b/src/Plot2d/resources/Plot2d_msg_fr.ts index 76436a3b3..bc4207b76 100755 --- a/src/Plot2d/resources/Plot2d_msg_fr.ts +++ b/src/Plot2d/resources/Plot2d_msg_fr.ts @@ -445,6 +445,18 @@ L'échelle logarithmique de l'ordonnée n'est pas permise.PRP_CURVES_SETTINGS Définir les paramètres des courbes + + TOT_COMMENTS_SETTINGS + Paramètres des commentaires + + + MEN_COMMENTS_SETTINGS + Paramètres des commentaires + + + PRP_COMMENTS_SETTINGS + Définir les paramètres des commentaires + CIRCLE_MARKER_LBL Circle @@ -555,4 +567,51 @@ L'échelle logarithmique de l'ordonnée n'est pas permise.Numéro de repères + + Plot2d_SetupCommentsDlg + + SETUP_COMMENTS + Setup comments + + + PARAMETERS + Parameters + + + TEXT + Text + + + X + X + + + Y + Y + + + ALIGNMENT + Alignment + + + TOP_LEFT + Top left + + + TOP_RIGHT + Top right + + + BOTTOM_LEFT + Bottom left + + + BOTTOM_RIGHT + Bottom right + + + CENTER + Center + + diff --git a/src/Plot2d/resources/plot2d_comments_settings.png b/src/Plot2d/resources/plot2d_comments_settings.png new file mode 100644 index 000000000..13f9037d0 Binary files /dev/null and b/src/Plot2d/resources/plot2d_comments_settings.png differ