From: ouv Date: Fri, 23 Sep 2005 13:09:27 +0000 (+0000) Subject: Working with Point Sprite textures corrected X-Git-Tag: BR-D5-38-2003_D2005-12-10~143 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=263f8521c4b6d6e398c5892f5ff241889b199102;p=modules%2Fvisu.git Working with Point Sprite textures corrected --- diff --git a/src/VISUGUI/VISUM_msg_en.po b/src/VISUGUI/VISUM_msg_en.po index ec671c94..d1766c0d 100644 --- a/src/VISUGUI/VISUM_msg_en.po +++ b/src/VISUGUI/VISUM_msg_en.po @@ -159,15 +159,15 @@ msgstr "Geometrical Sphere" msgid "VisuGUI_GaussPointsDlg::MAXIMUM_SIZE" msgstr "Maximum Size (Clamp) : " -msgid "VisuGUI_GaussPointsDlg::ALPHA_CHANNEL_THRESHOLD" -msgstr "Alpha Channel Threshold : " - msgid "VisuGUI_GaussPointsDlg::MAIN_TEXTURE" msgstr "Main Texture (16x16) : " -msgid "VisuGUI_GaussPointsDlg::ALPHA_CHANNEL_TEXTURE" +msgid "VisuGUI_GaussPointsDlg::ALPHA_TEXTURE" msgstr "Alpha Channel Texture (16x16) : " +msgid "VisuGUI_GaussPointsDlg::ALPHA_THRESHOLD" +msgstr "Alpha Channel Threshold : " + msgid "VisuGUI_GaussPointsDlg::SIZE_TITLE" msgstr "Size" diff --git a/src/VISUGUI/VisuGUI_GaussPointsDlg.cxx b/src/VISUGUI/VisuGUI_GaussPointsDlg.cxx index 1cd66bde..80e53916 100644 --- a/src/VISUGUI/VisuGUI_GaussPointsDlg.cxx +++ b/src/VISUGUI/VisuGUI_GaussPointsDlg.cxx @@ -792,26 +792,26 @@ VisuGUI_GaussPointsDlg::VisuGUI_GaussPointsDlg(SalomeApp_Module* theModule, bool PrimitiveGroupLayout->addWidget( myMainTextureLineEdit, 2, 1 ); PrimitiveGroupLayout->addWidget( aMainTextureButton, 2, 2 ); - // Alpha Channel Texture - QLabel* aAlphaChannelTextureLabel = new QLabel( tr( "ALPHA_CHANNEL_TEXTURE" ), PrimitiveGroup ); - myAlphaChannelTextureLineEdit = new QLineEdit( PrimitiveGroup ); - QPushButton* aAlphaChannelTextureButton = new QPushButton( PrimitiveGroup ); - aAlphaChannelTextureButton->setAutoDefault( false ); - aAlphaChannelTextureButton->setPixmap( aResourceMgr->loadPixmap( "VISU", tr( "ICON_LOAD_TEXTURE" ) ) ); - connect( aAlphaChannelTextureButton, SIGNAL( clicked() ), this, SLOT( onBrowseAlphaChannelTexture() ) ); - - PrimitiveGroupLayout->addWidget( aAlphaChannelTextureLabel, 3, 0 ); - PrimitiveGroupLayout->addWidget( myAlphaChannelTextureLineEdit, 3, 1 ); - PrimitiveGroupLayout->addWidget( aAlphaChannelTextureButton, 3, 2 ); - - // Alpha Channel Threshold - QLabel* aAlphaChannelThresholdLabel = new QLabel( tr( "ALPHA_CHANNEL_THRESHOLD" ), PrimitiveGroup ); - QtxDblSpinBox* aAlphaChannelThresholdSpinBox = new QtxDblSpinBox( 0.0, 1.0, 0.1, PrimitiveGroup ); - aAlphaChannelThresholdSpinBox->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) ); - aAlphaChannelThresholdSpinBox->setValue( 0.1 ); - - PrimitiveGroupLayout->addWidget( aAlphaChannelThresholdLabel, 4, 0 ); - PrimitiveGroupLayout->addMultiCellWidget( aAlphaChannelThresholdSpinBox, 4, 4, 1, 2 ); + // Alpha Texture + QLabel* aAlphaTextureLabel = new QLabel( tr( "ALPHA_TEXTURE" ), PrimitiveGroup ); + myAlphaTextureLineEdit = new QLineEdit( PrimitiveGroup ); + QPushButton* aAlphaTextureButton = new QPushButton( PrimitiveGroup ); + aAlphaTextureButton->setAutoDefault( false ); + aAlphaTextureButton->setPixmap( aResourceMgr->loadPixmap( "VISU", tr( "ICON_LOAD_TEXTURE" ) ) ); + connect( aAlphaTextureButton, SIGNAL( clicked() ), this, SLOT( onBrowseAlphaTexture() ) ); + + PrimitiveGroupLayout->addWidget( aAlphaTextureLabel, 3, 0 ); + PrimitiveGroupLayout->addWidget( myAlphaTextureLineEdit, 3, 1 ); + PrimitiveGroupLayout->addWidget( aAlphaTextureButton, 3, 2 ); + + // Alpha Threshold + QLabel* aAlphaThresholdLabel = new QLabel( tr( "ALPHA_THRESHOLD" ), PrimitiveGroup ); + myAlphaThresholdSpinBox = new QtxDblSpinBox( 0.0, 1.0, 0.1, PrimitiveGroup ); + myAlphaThresholdSpinBox->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) ); + myAlphaThresholdSpinBox->setValue( 0.0 ); + + PrimitiveGroupLayout->addWidget( aAlphaThresholdLabel, 4, 0 ); + PrimitiveGroupLayout->addMultiCellWidget( myAlphaThresholdSpinBox, 4, 4, 1, 2 ); // Size QGroupBox* SizeGroup = new QGroupBox ( tr( "SIZE_TITLE" ), aBox, "SizeGroup" ); @@ -828,7 +828,7 @@ VisuGUI_GaussPointsDlg::VisuGUI_GaussPointsDlg(SalomeApp_Module* theModule, bool mySizeLabel = new QLabel( tr( "SIZE" ), SizeGroup ); mySizeSpinBox = new QtxDblSpinBox( 0, 100, 1, SizeGroup ); mySizeSpinBox->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) ); - mySizeSpinBox->setValue( 10 ); + //mySizeSpinBox->setValue( 10 ); SizeGroupLayout->addWidget( mySizeLabel, 0, 0 ); SizeGroupLayout->addWidget( mySizeSpinBox, 0, 1 ); @@ -837,7 +837,7 @@ VisuGUI_GaussPointsDlg::VisuGUI_GaussPointsDlg(SalomeApp_Module* theModule, bool myMinSizeLabel = new QLabel( tr( "MIN_SIZE" ), SizeGroup ); myMinSizeSpinBox = new QtxDblSpinBox( 0, 100, 1, SizeGroup ); myMinSizeSpinBox->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) ); - myMinSizeSpinBox->setValue( 10 ); + //myMinSizeSpinBox->setValue( 10 ); SizeGroupLayout->addWidget( myMinSizeLabel, 1, 0 ); SizeGroupLayout->addWidget( myMinSizeSpinBox, 1, 1 ); @@ -846,7 +846,7 @@ VisuGUI_GaussPointsDlg::VisuGUI_GaussPointsDlg(SalomeApp_Module* theModule, bool myMaxSizeLabel = new QLabel( tr( "MAX_SIZE" ), SizeGroup ); myMaxSizeSpinBox = new QtxDblSpinBox( 0, 100, 1, SizeGroup ); myMaxSizeSpinBox->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) ); - myMaxSizeSpinBox->setValue( 33 ); + //myMaxSizeSpinBox->setValue( 33 ); SizeGroupLayout->addWidget( myMaxSizeLabel, 1, 2 ); SizeGroupLayout->addWidget( myMaxSizeSpinBox, 1, 3 ); @@ -855,7 +855,7 @@ VisuGUI_GaussPointsDlg::VisuGUI_GaussPointsDlg(SalomeApp_Module* theModule, bool QLabel* aMagnificationLabel = new QLabel( tr( "MAGNIFICATION" ), SizeGroup ); myMagnificationSpinBox = new QtxDblSpinBox( 10, 1000, 10, SizeGroup ); myMagnificationSpinBox->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) ); - myMagnificationSpinBox->setValue( 100 ); + //myMagnificationSpinBox->setValue( 100 ); SizeGroupLayout->addWidget( aMagnificationLabel, 2, 0 ); SizeGroupLayout->addWidget( myMagnificationSpinBox, 2, 1 ); @@ -864,7 +864,7 @@ VisuGUI_GaussPointsDlg::VisuGUI_GaussPointsDlg(SalomeApp_Module* theModule, bool QLabel* aIncrementLabel = new QLabel( tr( "INCREMENT" ), SizeGroup ); myIncrementSpinBox = new QtxDblSpinBox( 5, 50, 5, SizeGroup ); myIncrementSpinBox->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) ); - myIncrementSpinBox->setValue( 10 ); + //myIncrementSpinBox->setValue( 10 ); SizeGroupLayout->addWidget( aIncrementLabel, 2, 2 ); SizeGroupLayout->addWidget( myIncrementSpinBox, 2, 3 ); @@ -881,12 +881,12 @@ VisuGUI_GaussPointsDlg::VisuGUI_GaussPointsDlg(SalomeApp_Module* theModule, bool ColorGroupLayout->setSpacing(6); ColorGroupLayout->setMargin(11); - QLabel* aColorLabel = new QLabel( tr( "COLOR" ), ColorGroup ); + myColorLabel = new QLabel( tr( "COLOR" ), ColorGroup ); myColorButton = new QPushButton( ColorGroup ); myColorButton->setPaletteBackgroundColor( Qt::blue ); myColorButton->setPaletteForegroundColor( Qt::blue ); - ColorGroupLayout->addWidget( aColorLabel, 0, 0 ); + ColorGroupLayout->addWidget( myColorLabel, 0, 0 ); ColorGroupLayout->addWidget( myColorButton, 0, 1 ); connect( myColorButton, SIGNAL( clicked() ), this, SLOT( onColorButtonPressed() ) ); @@ -899,15 +899,6 @@ VisuGUI_GaussPointsDlg::VisuGUI_GaussPointsDlg(SalomeApp_Module* theModule, bool connect( myResultsButton, SIGNAL( toggled( bool ) ), myMaxSizeLabel, SLOT( setEnabled( bool ) ) ); connect( myResultsButton, SIGNAL( toggled( bool ) ), myMaxSizeSpinBox, SLOT( setEnabled( bool ) ) ); - bool isResults = myResultsButton->isChecked(); - ColorGroup->setEnabled( !isResults ); - mySizeLabel->setEnabled( !isResults ); - mySizeSpinBox->setEnabled( !isResults ); - myMinSizeLabel->setEnabled( isResults ); - myMinSizeSpinBox->setEnabled( isResults ); - myMaxSizeLabel->setEnabled( isResults ); - myMaxSizeSpinBox->setEnabled( isResults ); - myScalarPane = new VisuGUI_GaussScalarBarPane(this, SetPref); myScalarPane->setMargin(5); @@ -949,6 +940,15 @@ void VisuGUI_GaussPointsDlg::initFromPrsObject( VISU::GaussPoints_i* thePrs ) myResultsButton->setChecked( isResults ); myGeometryButton->setChecked( !isResults ); + myColorLabel->setEnabled( !isResults ); + myColorButton->setEnabled( !isResults ); + mySizeLabel->setEnabled( !isResults ); + mySizeSpinBox->setEnabled( !isResults ); + myMinSizeLabel->setEnabled( isResults ); + myMinSizeSpinBox->setEnabled( isResults ); + myMaxSizeLabel->setEnabled( isResults ); + myMaxSizeSpinBox->setEnabled( isResults ); + myColorButton->setPaletteBackgroundColor( thePrs->GetColor() ); myClampSpinBox->setMaxValue( thePrs->GetGaussPointsPL()->GetMaximumSupportedSize() ); @@ -962,7 +962,8 @@ void VisuGUI_GaussPointsDlg::initFromPrsObject( VISU::GaussPoints_i* thePrs ) myIncrementSpinBox->setValue( thePrs->GetGaussPointsPL()->GetMagnificationIncrement() * 100.0 ); myMainTextureLineEdit->setText( thePrs->GetMainTexture().section( '/', -1 ) ); - myAlphaChannelTextureLineEdit->setText( thePrs->GetAlphaChannelTexture().section( '/', -1 ) ); + myAlphaTextureLineEdit->setText( thePrs->GetAlphaTexture().section( '/', -1 ) ); + myAlphaThresholdSpinBox->setValue( thePrs->GetGaussPointsPL()->GetAlphaThreshold() ); myScalarPane->initFromPrsObject(thePrs); } @@ -987,35 +988,13 @@ int VisuGUI_GaussPointsDlg::storeToPrsObject( VISU::GaussPoints_i* thePrs ) thePrs->GetGaussPointsPL()->SetMagnification( myMagnificationSpinBox->value() / 100.0 ); thePrs->GetGaussPointsPL()->SetMagnificationIncrement( myIncrementSpinBox->value() / 100.0 ); - myScalarPane->storeToPrsObject(thePrs); + myMainTexture = myMainTexture.isNull() ? thePrs->GetMainTexture() : myMainTexture; + myAlphaTexture = myAlphaTexture.isNull() ? thePrs->GetAlphaTexture() : myAlphaTexture; + thePrs->SetTextures( myMainTexture, myAlphaTexture ); - // Texture - if( myMainTexture.isNull() || myAlphaChannelTexture.isNull() ) - { - myMainTexture = QString( getenv( "VISU_ROOT_DIR") ) + "/share/salome/resources/sprite_texture.bmp"; - myAlphaChannelTexture = QString( getenv( "VISU_ROOT_DIR") ) + "/share/salome/resources/sprite_alpha.bmp"; - } - - QString mainTextureImage = myMainTexture; - QString mainTextureFormat = mainTextureImage.section( '.', -1 ); - QString mainTextureVTI = mainTextureImage.section( '.', 0, -2 ) + ".vti"; - - QString command1 = QString( "VISU_img2vti " ) + mainTextureFormat + " " + mainTextureImage + " " + mainTextureVTI; - if(system(command1.latin1()) == 0){ - QString alphaTextureImage = myAlphaChannelTexture; - QString alphaTextureFormat = alphaTextureImage.section( '.', -1 ); - QString alphaTextureVTI = alphaTextureImage.section( '.', 0, -2 ) + ".vti"; - - QString command2 = QString( "VISU_img2vti " ) + alphaTextureFormat + " " + alphaTextureImage + " " + alphaTextureVTI; - if(system(command2.latin1()) == 0){ - thePrs->SetMainTexture( mainTextureImage ); - thePrs->SetAlphaChannelTexture( alphaTextureImage ); - thePrs->MakeTexture( mainTextureVTI, alphaTextureVTI ); - return true; - } - } + thePrs->GetGaussPointsPL()->SetAlphaThreshold( myAlphaThresholdSpinBox->value() ); - return false; + return myScalarPane->storeToPrsObject(thePrs); } void VisuGUI_GaussPointsDlg::accept() @@ -1036,7 +1015,7 @@ void VisuGUI_GaussPointsDlg::onBrowseMainTexture() myMainTextureLineEdit->setText( aFileName.section( '/', -1 ) ); } -void VisuGUI_GaussPointsDlg::onBrowseAlphaChannelTexture() +void VisuGUI_GaussPointsDlg::onBrowseAlphaTexture() { QString aRootDir = QString( getenv( "VISU_ROOT_DIR") ) + "/share/salome/resources/"; QString aFileName = QFileDialog::getOpenFileName( aRootDir, "Bitmap (*.bmp *.jpg *.png)", this ); @@ -1044,13 +1023,13 @@ void VisuGUI_GaussPointsDlg::onBrowseAlphaChannelTexture() if( aFileName.isNull() ) return; - myAlphaChannelTexture = aFileName; - myAlphaChannelTextureLineEdit->setText( aFileName.section( '/', -1 ) ); + myAlphaTexture = aFileName; + myAlphaTextureLineEdit->setText( aFileName.section( '/', -1 ) ); } void VisuGUI_GaussPointsDlg::onColorButtonPressed() { - QColor aColor = myColorButton->paletteBackgroundColor(); - aColor = QColorDialog::getColor( aColor, this ); - myColorButton->setPaletteBackgroundColor( aColor ); + QColor aColor = QColorDialog::getColor( myColorButton->paletteBackgroundColor(), this ); + if( aColor.isValid() ) + myColorButton->setPaletteBackgroundColor( aColor ); } diff --git a/src/VISUGUI/VisuGUI_GaussPointsDlg.h b/src/VISUGUI/VisuGUI_GaussPointsDlg.h index b15310b0..2e117301 100644 --- a/src/VISUGUI/VisuGUI_GaussPointsDlg.h +++ b/src/VISUGUI/VisuGUI_GaussPointsDlg.h @@ -131,19 +131,20 @@ protected slots: void accept(); void onBrowseMainTexture(); - void onBrowseAlphaChannelTexture(); + void onBrowseAlphaTexture(); void onColorButtonPressed(); private: VisuGUI_GaussScalarBarPane* myScalarPane; QString myMainTexture; - QString myAlphaChannelTexture; + QString myAlphaTexture; QtxDblSpinBox* myClampSpinBox; QLineEdit* myMainTextureLineEdit; - QLineEdit* myAlphaChannelTextureLineEdit; + QLineEdit* myAlphaTextureLineEdit; + QtxDblSpinBox* myAlphaThresholdSpinBox; QRadioButton* myResultsButton; QRadioButton* myGeometryButton; @@ -158,6 +159,7 @@ private: QtxDblSpinBox* myMagnificationSpinBox; QtxDblSpinBox* myIncrementSpinBox; + QLabel* myColorLabel; QPushButton* myColorButton; };