From 8e3ef3bf09e64f88f29d959317e04e4e7e851400 Mon Sep 17 00:00:00 2001 From: sln Date: Thu, 19 Jul 2012 09:55:08 +0000 Subject: [PATCH] External 2.5.3: Thickness of lines and points in Plot 2D. External: 2.5.5: Suppress internal markers in Plot 2D --- src/Plot2d/Plot2d_SetupCurvesDlg.cxx | 60 ++++++++++++++++++++------- src/Plot2d/Plot2d_SetupCurvesDlg.h | 6 ++- src/Plot2d/Plot2d_ViewFrame.cxx | 15 ++++++- src/Plot2d/resources/Plot2d_msg_en.ts | 16 +++++++ src/Plot2d/resources/Plot2d_msg_fr.ts | 16 +++++++ 5 files changed, 95 insertions(+), 18 deletions(-) diff --git a/src/Plot2d/Plot2d_SetupCurvesDlg.cxx b/src/Plot2d/Plot2d_SetupCurvesDlg.cxx index 711137416..fbf3b362d 100755 --- a/src/Plot2d/Plot2d_SetupCurvesDlg.cxx +++ b/src/Plot2d/Plot2d_SetupCurvesDlg.cxx @@ -49,6 +49,7 @@ #define MARKER_COL 2 #define COLOR_COL 3 #define NB_MARKERS_COL 4 +#define LINE_WIDTH_COL 5 Plot2d_PixmapWg::Plot2d_PixmapWg( QWidget* theParent ) @@ -149,7 +150,7 @@ Plot2d_SetupCurvesDlg::Plot2d_SetupCurvesDlg( QWidget* theParent ) aLay->addWidget( myTable ); myTable->setRowCount( 0 ); - myTable->setColumnCount( 5 ); + myTable->setColumnCount( 6 ); QStringList aLabels; aLabels.append( tr( "FIG" ) ); @@ -157,6 +158,7 @@ Plot2d_SetupCurvesDlg::Plot2d_SetupCurvesDlg( QWidget* theParent ) aLabels.append( tr( "MARKER" ) ); aLabels.append( tr( "COLOR" ) ); aLabels.append( tr( "NB_MARKERS" ) ); + aLabels.append( tr( "LINE_WIDTH" ) ); myTable->setHorizontalHeaderLabels( aLabels ); myTable->verticalHeader()->hide(); myTable->setSelectionMode( QTableWidget::NoSelection ); @@ -175,6 +177,7 @@ Plot2d_SetupCurvesDlg::Plot2d_SetupCurvesDlg( QWidget* theParent ) myTable->horizontalHeader()->setResizeMode( MARKER_COL, QHeaderView::Fixed ); myTable->horizontalHeader()->setResizeMode( COLOR_COL, QHeaderView::Fixed ); myTable->horizontalHeader()->setResizeMode( NB_MARKERS_COL, QHeaderView::Fixed ); + myTable->horizontalHeader()->setResizeMode( LINE_WIDTH_COL, QHeaderView::Fixed ); myTable->horizontalHeader()->setHighlightSections( false ); // Minus button @@ -189,6 +192,9 @@ Plot2d_SetupCurvesDlg::Plot2d_SetupCurvesDlg( QWidget* theParent ) setButtonPosition( Right, Cancel ); setMinimumHeight( 250 ); + + // TO DO: for PRECOS only + myTable->setColumnHidden( NB_MARKERS_COL, true ); } /*! @@ -247,10 +253,13 @@ void Plot2d_SetupCurvesDlg::setText( const int theRow, void Plot2d_SetupCurvesDlg::SetParameters( const QVector< int >& theMarker, const QVector< QString >& theText, const QVector< QColor >& theColor, - const QVector< int >& theNbMarkers ) + const QVector< int >& theNbMarkers, + const QVector< int >& theWidth ) { - int nbRows = qMax( qMax( theMarker.size(), theText.size()), - qMax( theColor.size(), theNbMarkers.size() ) ); + int nbRows = qMin( qMin( theMarker.size(), theText.size()), + qMin( theColor.size(), theNbMarkers.size() ) ); + + nbRows = qMin( nbRows, theWidth.size() ); myTable->setRowCount( nbRows ); @@ -289,6 +298,9 @@ void Plot2d_SetupCurvesDlg::SetParameters( const QVector< int >& theMarker, // Nb markers setText( i, NB_MARKERS_COL, QString( "%1" ).arg( theNbMarkers[ i ] ) ); + + // Line width + setText( i, LINE_WIDTH_COL, QString( "%1" ).arg( theWidth[ i ] ) ); } myTable->setColumnWidth( PIXMAP_COL, 24 ); @@ -296,9 +308,10 @@ void Plot2d_SetupCurvesDlg::SetParameters( const QVector< int >& theMarker, myTable->setColumnWidth( MARKER_COL, strWidth + 10 ); myTable->setColumnWidth( COLOR_COL, fm.width( tr( "COLOR" ) ) + 10 ); myTable->setColumnWidth( NB_MARKERS_COL, fm.width( tr( "NB_MARKERS" ) ) + 10 ); + myTable->setColumnWidth( LINE_WIDTH_COL, fm.width( tr( "LINE_WIDTH" ) ) + 10 ); int aWidth = myTable->columnWidth( PIXMAP_COL ) + myTable->columnWidth( TEXT_COL )+ myTable->columnWidth( MARKER_COL ) + myTable->columnWidth( COLOR_COL ) + - myTable->columnWidth( NB_MARKERS_COL ); + myTable->columnWidth( NB_MARKERS_COL ) + myTable->columnWidth( LINE_WIDTH_COL ); QFrame* aWg = (QFrame*)myTable->viewport()->parentWidget(); @@ -320,7 +333,8 @@ void Plot2d_SetupCurvesDlg::SetParameters( const QVector< int >& theMarker, void Plot2d_SetupCurvesDlg::GetParameters( QVector< int >& theMarkers, QVector< QString >& theTexts, QVector< QColor >& theColors, - QVector< int >& theNbMarkers ) const + QVector< int >& theNbMarkers, + QVector< int >& theWidth ) const { int nbRows = myTable->rowCount(); @@ -328,6 +342,7 @@ void Plot2d_SetupCurvesDlg::GetParameters( QVector< int >& theMarkers, theTexts.resize( nbRows ); theColors.resize( nbRows ); theNbMarkers.resize( nbRows ); + theWidth.resize( nbRows ); for ( int i = 0; i < nbRows; i++ ) { @@ -357,6 +372,15 @@ void Plot2d_SetupCurvesDlg::GetParameters( QVector< int >& theMarkers, theNbMarkers[ i ] = nbMarkers; else theNbMarkers[ i ] = -1; + + // Line width + it = myTable->item( i, LINE_WIDTH_COL ); + aStr = it ? it->text() : ""; + int aWidth = aStr.toInt( &isOk ); + if ( isOk ) + theWidth[ i ] = aWidth; + else + theWidth[ i ] = -1; } } @@ -375,19 +399,27 @@ const QList< int >& Plot2d_SetupCurvesDlg::GetRemovedIndexes() const //============================================================================= bool Plot2d_SetupCurvesDlg::acceptData() const { + QList< int > toCheck; + toCheck << NB_MARKERS_COL << LINE_WIDTH_COL; + ((Plot2d_SetupCurvesDlg*)this)->setButtonFocus( OK ); int nbRows = myTable->rowCount(); for ( int i = 0; i < nbRows; i++ ) { - QTableWidgetItem* it = myTable->item( i, NB_MARKERS_COL ); - QString aStr = it ? it->text() : ""; - bool isOk = false; - int nbMarkers = aStr.toInt( &isOk ); - if ( !isOk || nbMarkers<= 0 ) + QList< int >::iterator colIt; + for ( colIt = toCheck.begin(); colIt != toCheck.end(); ++colIt ) { - SUIT_MessageBox::information( (QWidget*)this, tr( "PLOT2D_INSUFFICIENT_DATA" ), - tr( "PLOT2D_ENTER_VALID_DATA" ), tr( "BUT_OK" ) ); - return false; + int col = *colIt; + QTableWidgetItem* it = myTable->item( i, col ); + QString aStr = it ? it->text() : ""; + bool isOk = false; + int aVal = aStr.toInt( &isOk ); + if ( !isOk || aVal <= 0 ) + { + SUIT_MessageBox::information( (QWidget*)this, tr( "PLOT2D_INSUFFICIENT_DATA" ), + tr( "PLOT2D_ENTER_VALID_DATA" ), tr( "BUT_OK" ) ); + return false; + } } } diff --git a/src/Plot2d/Plot2d_SetupCurvesDlg.h b/src/Plot2d/Plot2d_SetupCurvesDlg.h index c7fb1c1c8..e7b040c5a 100755 --- a/src/Plot2d/Plot2d_SetupCurvesDlg.h +++ b/src/Plot2d/Plot2d_SetupCurvesDlg.h @@ -54,12 +54,14 @@ public: void SetParameters( const QVector< int >& theMarker, const QVector< QString >& theText, const QVector< QColor >& theColor, - const QVector< int >& theNbMarkers ); + const QVector< int >& theNbMarkers, + const QVector< int >& theWidth ); void GetParameters( QVector< int >& theMarker, QVector< QString >& theText, QVector< QColor >& theColor, - QVector< int >& theNbMarkers ) const; + QVector< int >& theNbMarkers, + QVector< int >& theWidth ) const; const QList< int >& GetRemovedIndexes() const; diff --git a/src/Plot2d/Plot2d_ViewFrame.cxx b/src/Plot2d/Plot2d_ViewFrame.cxx index cbe46896d..c5a043771 100755 --- a/src/Plot2d/Plot2d_ViewFrame.cxx +++ b/src/Plot2d/Plot2d_ViewFrame.cxx @@ -1079,6 +1079,7 @@ void Plot2d_ViewFrame::onCurvesSettings() QVector< QString > aTexts( nbCurves ); QVector< QColor > aColors( nbCurves ); QVector< int > nbMarkers( nbCurves ); + QVector< int > aWidths( nbCurves ); QList< Plot2d_Curve* > aCurves; @@ -1096,16 +1097,18 @@ void Plot2d_ViewFrame::onCurvesSettings() aText = aCurve->getVerTitle(); QColor aColor = aCurve->getColor(); int nbMarker = aCurve->getNbMarkers(); + int aWidth = aCurve->getLineWidth(); aMarkers[ i ] = aMarkerType; aTexts[ i ] = aText; aColors[ i ] = aColor; nbMarkers[ i ] = nbMarker; + aWidths[ i ] = aWidth + 1; // 0 'system' width corresponds to 1 'user' width aCurves.append( aCurve ); } - aDlg->SetParameters( aMarkers, aTexts, aColors, nbMarkers ); + aDlg->SetParameters( aMarkers, aTexts, aColors, nbMarkers, aWidths ); if ( aDlg->exec() != QDialog::Accepted ) return; @@ -1134,7 +1137,7 @@ void Plot2d_ViewFrame::onCurvesSettings() anIndexToCurve[ i ] = *aCurvIter; } - aDlg->GetParameters( aMarkers, aTexts, aColors, nbMarkers ); + aDlg->GetParameters( aMarkers, aTexts, aColors, nbMarkers, aWidths ); int n; for ( i = 0, n = aMarkers.size(); i < n; i++ ) @@ -1153,6 +1156,7 @@ void Plot2d_ViewFrame::onCurvesSettings() } QColor anOldColor = aCurve->getColor(); int anOldNbMarker = aCurve->getNbMarkers(); + int anOldWidth = aCurve->getLineWidth(); // new values @@ -1160,6 +1164,7 @@ void Plot2d_ViewFrame::onCurvesSettings() QString aText = aTexts[ i ]; QColor aColor = aColors[ i ]; int nbMarker = nbMarkers[ i ]; + int aWidth = aWidths[ i ]; bool toUpdate = false; @@ -1187,6 +1192,12 @@ void Plot2d_ViewFrame::onCurvesSettings() toUpdate = true; } + if ( anOldWidth != aWidth ) + { + aCurve->setLine( aCurve->getLine(), aWidth - 1 ); + toUpdate = true; + } + if ( toUpdate ) { updateCurve( aCurve, false ); diff --git a/src/Plot2d/resources/Plot2d_msg_en.ts b/src/Plot2d/resources/Plot2d_msg_en.ts index 88c83f905..7c7f256a3 100644 --- a/src/Plot2d/resources/Plot2d_msg_en.ts +++ b/src/Plot2d/resources/Plot2d_msg_en.ts @@ -1,6 +1,10 @@ @default + + BUT_OK + &OK + PLOT2D_CURVE_TYPE_LBL Curve type: @@ -536,6 +540,14 @@ Are you sure you want to continue? Plot2d_SetupCurvesDlg + + PLOT2D_ENTER_VALID_DATA + Please enter valid data and try again. + + + PLOT2D_INSUFFICIENT_DATA + Insufficient input data + SETUP_CURVES Setup curves @@ -564,6 +576,10 @@ Are you sure you want to continue? NB_MARKERS Nb markers + + LINE_WIDTH + Line width + diff --git a/src/Plot2d/resources/Plot2d_msg_fr.ts b/src/Plot2d/resources/Plot2d_msg_fr.ts index 1524a7a0f..54bb54ae4 100755 --- a/src/Plot2d/resources/Plot2d_msg_fr.ts +++ b/src/Plot2d/resources/Plot2d_msg_fr.ts @@ -3,6 +3,10 @@ @default + + BUT_OK + &OK + PLOT2D_CURVE_TYPE_LBL Type de Courbe: @@ -547,6 +551,14 @@ L'échelle logarithmique de l'ordonnée n'est pas permise. Plot2d_SetupCurvesDlg + + PLOT2D_ENTER_VALID_DATA + Entrez les données valides et essayez de nouveau. + + + PLOT2D_INSUFFICIENT_DATA + Les données d'entrée ne sont pas suffisantes. + SETUP_CURVES Définir les courbes @@ -575,5 +587,9 @@ L'échelle logarithmique de l'ordonnée n'est pas permise.NB_MARKERS Numéro de repères + + LINE_WIDTH + Largeur de ligne + -- 2.39.2