From bc55d67c3c9a795288ddf0e04eeb88c083ae914a Mon Sep 17 00:00:00 2001 From: vsr Date: Fri, 8 Oct 2010 11:52:41 +0000 Subject: [PATCH] Merge fixes from V6_1_0 --- src/Qtx/QtxDoubleSpinBox.cxx | 24 ++++++- src/Qtx/QtxIntSpinBox.cxx | 12 ++++ src/SVTK/SALOME_Actor.cxx | 83 +++++++++++++---------- src/SalomeApp/SalomeApp_DoubleSpinBox.cxx | 2 +- 4 files changed, 80 insertions(+), 41 deletions(-) diff --git a/src/Qtx/QtxDoubleSpinBox.cxx b/src/Qtx/QtxDoubleSpinBox.cxx index 87120b243..2c8b3baac 100644 --- a/src/Qtx/QtxDoubleSpinBox.cxx +++ b/src/Qtx/QtxDoubleSpinBox.cxx @@ -75,6 +75,12 @@ QtxDoubleSpinBox::QtxDoubleSpinBox( QWidget* parent ) : QDoubleSpinBox( parent ), myCleared( false ) { + // VSR 01/07/2010: Disable thousands separator for spin box + // (to avoid incosistency of double-2-string and string-2-double conversion) + QLocale loc; + loc.setNumberOptions(loc.numberOptions() | QLocale::OmitGroupSeparator | QLocale::RejectGroupSeparator); + setLocale(loc); + // Use precision equal to default Qt decimals myPrecision = decimals(); @@ -98,6 +104,12 @@ QtxDoubleSpinBox::QtxDoubleSpinBox( double min, double max, double step, QWidget : QDoubleSpinBox( parent ), myCleared( false ) { + // VSR 01/07/2010: Disable thousands separator for spin box + // (to avoid incosistency of double-2-string and string-2-double conversion) + QLocale loc; + loc.setNumberOptions(loc.numberOptions() | QLocale::OmitGroupSeparator | QLocale::RejectGroupSeparator); + setLocale(loc); + // Use precision equal to default Qt decimals myPrecision = decimals(); @@ -129,6 +141,12 @@ QtxDoubleSpinBox::QtxDoubleSpinBox( double min, double max, double step, int pre myCleared( false ), myPrecision( prec ) { + // VSR 01/07/2010: Disable thousands separator for spin box + // (to avoid incosistency of double-2-string and string-2-double conversion) + QLocale loc; + loc.setNumberOptions(loc.numberOptions() | QLocale::OmitGroupSeparator | QLocale::RejectGroupSeparator); + setLocale(loc); + setDecimals( dec ); setMinimum( min ); setMaximum( max ); @@ -221,7 +239,7 @@ double QtxDoubleSpinBox::valueFromText( const QString& text ) const */ QString QtxDoubleSpinBox::textFromValue( double val ) const { - QString s = QLocale().toString( val, myPrecision >= 0 ? 'f' : 'g', qAbs( myPrecision ) ); + QString s = locale().toString( val, myPrecision >= 0 ? 'f' : 'g', qAbs( myPrecision ) ); return removeTrailingZeroes( s ); } @@ -232,7 +250,7 @@ QString QtxDoubleSpinBox::textFromValue( double val ) const */ QString QtxDoubleSpinBox::removeTrailingZeroes( const QString& src ) const { - QString delim( QLocale().decimalPoint() ); + QString delim( locale().decimalPoint() ); int idx = src.lastIndexOf( delim ); if ( idx == -1 ) @@ -344,7 +362,7 @@ QValidator::State QtxDoubleSpinBox::validate( QString& str, int& pos ) const } else if ( myPrecision < 0 ){ // Consider too large negative exponent as Invalid - QChar e( QLocale().exponential() ); + QChar e( locale().exponential() ); int epos = str.indexOf( e, 0, Qt::CaseInsensitive ); if ( epos != -1 ){ epos++; // Skip exponential symbol itself diff --git a/src/Qtx/QtxIntSpinBox.cxx b/src/Qtx/QtxIntSpinBox.cxx index cb3dd5bff..a851c3cf4 100755 --- a/src/Qtx/QtxIntSpinBox.cxx +++ b/src/Qtx/QtxIntSpinBox.cxx @@ -61,6 +61,12 @@ QtxIntSpinBox::QtxIntSpinBox( QWidget* parent ) : QSpinBox( parent ), myCleared( false ) { + // VSR 01/07/2010: Disable thousands separator for spin box + // (to avoid incosistency of double-2-string and string-2-double conversion) + QLocale loc; + loc.setNumberOptions(loc.numberOptions() | QLocale::OmitGroupSeparator | QLocale::RejectGroupSeparator); + setLocale(loc); + setCorrectionMode( QSpinBox::CorrectToNearestValue ); connect( lineEdit(), SIGNAL( textChanged( const QString& ) ), this, SLOT( onTextChanged( const QString& ) ) ); @@ -81,6 +87,12 @@ QtxIntSpinBox::QtxIntSpinBox( int min, int max, int step, QWidget* parent ) : QSpinBox( parent ), myCleared( false ) { + // VSR 01/07/2010: Disable thousands separator for spin box + // (to avoid incosistency of double-2-string and string-2-double conversion) + QLocale loc; + loc.setNumberOptions(loc.numberOptions() | QLocale::OmitGroupSeparator | QLocale::RejectGroupSeparator); + setLocale(loc); + setMinimum( min ); setMaximum( max ); setSingleStep( step ); diff --git a/src/SVTK/SALOME_Actor.cxx b/src/SVTK/SALOME_Actor.cxx index f7b54f6bc..13b2a0224 100644 --- a/src/SVTK/SALOME_Actor.cxx +++ b/src/SVTK/SALOME_Actor.cxx @@ -495,14 +495,15 @@ SALOME_Actor if( !theIsHighlight ) { SetPreSelected( false ); - VTK::ActorCollectionCopy aCopy(aRenderer->GetActors()); - vtkActorCollection* theActors = aCopy.GetActors(); - theActors->InitTraversal(); - while( vtkActor *ac = theActors->GetNextActor() ) - if( SALOME_Actor* anActor = SALOME_Actor::SafeDownCast( ac ) ) - if( anActor->hasIO() && myIO->isSame( anActor->getIO() ) ) - anActor->SetPreSelected( false ); - + if ( hasIO() ) { + VTK::ActorCollectionCopy aCopy(aRenderer->GetActors()); + vtkActorCollection* theActors = aCopy.GetActors(); + theActors->InitTraversal(); + while( vtkActor *ac = theActors->GetNextActor() ) + if( SALOME_Actor* anActor = SALOME_Actor::SafeDownCast( ac ) ) + if( anActor->hasIO() && myIO->isSame( anActor->getIO() ) ) + anActor->SetPreSelected( false ); + } }else{ switch(aSelectionMode) { case NodeSelection: @@ -595,15 +596,17 @@ SALOME_Actor if( !mySelector->IsSelected( myIO ) ) { SetPreSelected( true ); - VTK::ActorCollectionCopy aCopy(aRenderer->GetActors()); - vtkActorCollection* theActors = aCopy.GetActors(); - theActors->InitTraversal(); - while( vtkActor *anAct = theActors->GetNextActor() ) { - if( anAct != this ) - if( SALOME_Actor* anActor = SALOME_Actor::SafeDownCast( anAct ) ) - if( anActor->hasIO() && myIO->isSame( anActor->getIO() ) ) - anActor->SetPreSelected( true ); - } + if ( hasIO() ) { + VTK::ActorCollectionCopy aCopy(aRenderer->GetActors()); + vtkActorCollection* theActors = aCopy.GetActors(); + theActors->InitTraversal(); + while( vtkActor *anAct = theActors->GetNextActor() ) { + if( anAct != this ) + if( SALOME_Actor* anActor = SALOME_Actor::SafeDownCast( anAct ) ) + if( anActor->hasIO() && myIO->isSame( anActor->getIO() ) ) + anActor->SetPreSelected( true ); + } + } } } default: @@ -658,7 +661,7 @@ SALOME_Actor int aVtkId = myPointPicker->GetPointId(); if( aVtkId >= 0 && mySelector->IsValid( this, aVtkId, true ) ) { int anObjId = GetNodeObjId( aVtkId ); - if( anObjId >= 0 ) { + if( hasIO() && anObjId >= 0 ) { mySelector->AddOrRemoveIndex( myIO, anObjId, anIsShift ); mySelector->AddIObject( this ); } @@ -677,7 +680,7 @@ SALOME_Actor if( aVtkId >= 0 && mySelector->IsValid( this, aVtkId ) ) { int anObjId = GetElemObjId( aVtkId ); if( anObjId >= 0 ) { - if ( CheckDimensionId(aSelectionMode,this,anObjId) ) { + if ( hasIO() && CheckDimensionId(aSelectionMode,this,anObjId) ) { mySelector->AddOrRemoveIndex( myIO, anObjId, anIsShift ); mySelector->AddIObject( this ); } @@ -695,7 +698,7 @@ SALOME_Actor int anObjId = GetElemObjId( aVtkId ); if( anObjId >= 0 ) { int anEdgeId = GetEdgeId(this,myCellPicker.GetPointer(),anObjId); - if( anEdgeId < 0 ) { + if( hasIO() && anEdgeId < 0 ) { mySelector->AddOrRemoveIndex( myIO, anObjId, false ); mySelector->AddOrRemoveIndex( myIO, anEdgeId, true ); mySelector->AddIObject( this ); @@ -706,10 +709,12 @@ SALOME_Actor } case ActorSelection : { - if( mySelector->IsSelected( myIO ) && anIsShift ) - mySelector->RemoveIObject( this ); - else { - mySelector->AddIObject( this ); + if ( hasIO() ) { + if( mySelector->IsSelected( myIO ) && anIsShift ) + mySelector->RemoveIObject( this ); + else { + mySelector->AddIObject( this ); + } } break; } @@ -749,14 +754,15 @@ SALOME_Actor } } - if( !anIndexes.IsEmpty() ) { - mySelector->AddOrRemoveIndex( myIO, anIndexes, anIsShift ); - mySelector->AddIObject( this ); - anIndexes.Clear(); + if ( hasIO() ) { + if( !anIndexes.IsEmpty() ) { + mySelector->AddOrRemoveIndex( myIO, anIndexes, anIsShift ); + mySelector->AddIObject( this ); + anIndexes.Clear(); + } + else if ( !anIsShift ) + mySelector->RemoveIObject( this ); } - else if ( !anIsShift ) - mySelector->RemoveIObject( this ); - break; } case ActorSelection : @@ -811,13 +817,16 @@ SALOME_Actor } } } - if( !anIndexes.IsEmpty() ) { - mySelector->AddOrRemoveIndex( myIO, anIndexes, anIsShift ); - mySelector->AddIObject( this ); - anIndexes.Clear(); + + if ( hasIO() ) { + if( !anIndexes.IsEmpty() ) { + mySelector->AddOrRemoveIndex( myIO, anIndexes, anIsShift ); + mySelector->AddIObject( this ); + anIndexes.Clear(); + } + else if ( !anIsShift ) + mySelector->RemoveIObject( this ); } - else if ( !anIsShift ) - mySelector->RemoveIObject( this ); } default: break; diff --git a/src/SalomeApp/SalomeApp_DoubleSpinBox.cxx b/src/SalomeApp/SalomeApp_DoubleSpinBox.cxx index 984bb04b0..3ef39e1bf 100644 --- a/src/SalomeApp/SalomeApp_DoubleSpinBox.cxx +++ b/src/SalomeApp/SalomeApp_DoubleSpinBox.cxx @@ -377,7 +377,7 @@ SalomeApp_DoubleSpinBox::State SalomeApp_DoubleSpinBox::isValid( const QString& if( aSearchState == NotFound ) { bool ok = false; - value = QLocale().toDouble( text, &ok ); + value = locale().toDouble( text, &ok ); if ( !ok ) return NoVariable; } -- 2.39.2