From: ouv Date: Tue, 20 Dec 2005 09:04:15 +0000 (+0000) Subject: Fixed bug GVIEW10978 : warning 'too many faces' not implemented X-Git-Tag: TG-D5-38-2003_D2005-20-12~2 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=18b7ad336248002c99eddae1bcb85f25853ad71f;p=modules%2Fvisu.git Fixed bug GVIEW10978 : warning 'too many faces' not implemented --- diff --git a/src/VISUGUI/VISUM_msg_en.po b/src/VISUGUI/VISUM_msg_en.po index 4f3467bb..4de1b4e4 100644 --- a/src/VISUGUI/VISUM_msg_en.po +++ b/src/VISUGUI/VISUM_msg_en.po @@ -499,6 +499,9 @@ msgstr "" msgid "VisuGUI_GaussPointsDlg::&OK" msgstr "" +msgid "VisuGUI_GaussPointsDlg::WARNING" +msgstr "Warning" + msgid "VisuGUI_GaussPointsDlg::DLG_TITLE" msgstr "Gauss Points" diff --git a/src/VISUGUI/VisuGUI_GaussPointsDlg.cxx b/src/VISUGUI/VisuGUI_GaussPointsDlg.cxx index b4d4778d..8da51a71 100644 --- a/src/VISUGUI/VisuGUI_GaussPointsDlg.cxx +++ b/src/VISUGUI/VisuGUI_GaussPointsDlg.cxx @@ -55,6 +55,10 @@ #include #include +#include +#include +#include + using namespace std; VisuGUI_GaussScalarBarPane::VisuGUI_GaussScalarBarPane (QWidget * parent, bool SetPref): @@ -502,7 +506,8 @@ void VisuGUI_GaussScalarBarPane::onTextPref() VisuGUI_GaussPointsDlg::VisuGUI_GaussPointsDlg(SalomeApp_Module* theModule, bool SetPref): QDialog(VISU::GetDesktop(theModule), "VisuGUI_GaussPointsDlg", true, - WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu) + WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu), + myPrs(NULL) { setName("VisuGUI_ScalarBarDlg"); setCaption(SetPref ? tr("DLG_PREF_TITLE") : tr("DLG_PROP_TITLE")); @@ -614,7 +619,7 @@ void VisuGUI_GaussPointsDlg::initFromPrsObject( VISU::GaussPoints_i* thePrs ) myPrimitiveBox->setAlphaTexture( thePrs->GetAlphaTexture() ); myPrimitiveBox->setAlphaThreshold( thePrs->GetAlphaThreshold() ); myPrimitiveBox->setResolution( thePrs->GetResolution() ); - myPrimitiveBox->setFaceLimit( 500 ); + myPrimitiveBox->setFaceLimit( thePrs->GetFaceLimit() ); mySizeBox->setType( isResults || isDeformed ? VVTK_SizeBox::Results : VVTK_SizeBox::Geometry ); mySizeBox->setGeomSize( thePrs->GetGeomSize() ); @@ -625,6 +630,8 @@ void VisuGUI_GaussPointsDlg::initFromPrsObject( VISU::GaussPoints_i* thePrs ) mySizeBox->setColor( thePrs->GetColor() ); myScalarPane->initFromPrsObject(thePrs); + + myPrs = thePrs; } int VisuGUI_GaussPointsDlg::storeToPrsObject( VISU::GaussPoints_i* thePrs ) @@ -647,6 +654,7 @@ int VisuGUI_GaussPointsDlg::storeToPrsObject( VISU::GaussPoints_i* thePrs ) thePrs->SetAlphaThreshold( myPrimitiveBox->getAlphaThreshold() ); thePrs->SetResolution( myPrimitiveBox->getResolution() ); + thePrs->SetFaceLimit( myPrimitiveBox->getFaceLimit() ); bool isColored = !myGeometryButton->isChecked(); if( isColored ) @@ -681,6 +689,43 @@ void VisuGUI_GaussPointsDlg::onToggleDefShape( bool on ) void VisuGUI_GaussPointsDlg::accept() { + if( myPrs && myPrimitiveBox->getPrimitiveType() == VISU_OpenGLPointSpriteMapper::GeomSphere ) + { + int aNumberOfFaces = myPrimitiveBox->getFaceNumber(); + int aNumberOfPoints = ( (vtkPolyData*)myPrs->GetGaussPointsPL()->GetInput() )->GetNumberOfCells(); + + if( aNumberOfFaces * aNumberOfPoints > myPrimitiveBox->getFaceLimit() ) + { + QString aWarning = "The number of faces needed to perform the 'Geometrical Sphere' primitive\n"; + aWarning.append( "presentation might be too important to ensure an acceptable frame rate.\n\n" ); + aWarning.append( "Can you please confirm that you want to continue anyway?" ); + if( SUIT_MessageBox::warn2( this, tr( "Warning" ), aWarning, tr( "&OK" ), tr( "&Cancel" ), 0, 1, 1 ) == 1 ) + return; + } + + /* + float aMemory = 50.0 * 1024.0 * (float)aNumberOfFaces * (float)aNumberOfPoints; + + cout << aNumberOfFaces << endl; + cout << aNumberOfPoints << endl; + cout << aMemory << endl; + + vtkSphereSource* aSphere = vtkSphereSource::New(); + aSphere->SetThetaResolution( myPrimitiveBox->getResolution() ); + aSphere->SetPhiResolution( myPrimitiveBox->getResolution() ); + aSphere->GetOutput()->Update(); + aSphere->GetOutput()->GetActualMemorySize(); + + aMemory = aSphere->GetOutput()->GetActualMemorySize() * 1024.0 * (float)aNumberOfPoints; + + if( VISU_PipeLine::CheckAvailableMemory( aMemory ) == 0 ) + { + SUIT_MessageBox::error1( this, "caption", "text", "ok" ); + return 0; + } + */ + } + //if( myScalarPane->check() ) QDialog::accept(); } diff --git a/src/VISUGUI/VisuGUI_GaussPointsDlg.h b/src/VISUGUI/VisuGUI_GaussPointsDlg.h index 27b46071..c845d013 100644 --- a/src/VISUGUI/VisuGUI_GaussPointsDlg.h +++ b/src/VISUGUI/VisuGUI_GaussPointsDlg.h @@ -145,6 +145,7 @@ protected slots: void accept(); private: + VISU::GaussPoints_i* myPrs; VisuGUI_GaussScalarBarPane* myScalarPane; QRadioButton* myResultsButton; diff --git a/src/VISU_I/VISU_GaussPoints_i.cc b/src/VISU_I/VISU_GaussPoints_i.cc index 7de16afc..3539d262 100644 --- a/src/VISU_I/VISU_GaussPoints_i.cc +++ b/src/VISU_I/VISU_GaussPoints_i.cc @@ -108,7 +108,8 @@ GaussPoints_i(Result_i* theResult, myColor(Qt::blue), myIsActiveLocalScalarBar(true), myIsDispGlobalScalarBar(true), - mySpacing(0.01) + mySpacing(0.01), + myFaceLimit(50000) { if(MYDEBUG) MESSAGE("GaussPoints_i::GaussPoints_i - this = "<integerValue( "VISU", "geom_sphere_face_limit", GetFaceLimit() ); + SetFaceLimit( aFaceLimit ); + QString aMainTexture = QString( getenv( "VISU_ROOT_DIR") ) + "/share/salome/resources/sprite_texture.bmp"; aMainTexture = aResourceMgr->stringValue( "VISU", "point_sprite_main_texture", aMainTexture ); @@ -227,6 +232,8 @@ VISU::GaussPoints_i SetIsDeformed(Storable::FindValue(theMap,"myIsDeformed").toInt()); SetScaleFactor(Storable::FindValue(theMap,"myScaleFactor").toDouble()); + SetFaceLimit(Storable::FindValue(theMap,"myFaceLimit").toInt()); + SetIsColored(Storable::FindValue(theMap,"myIsColored").toInt()); int aRed = Storable::FindValue(theMap,"myColor.R").toInt(); int aGreen = Storable::FindValue(theMap,"myColor.G").toInt(); @@ -268,6 +275,8 @@ VISU::GaussPoints_i Storable::DataToStream( theStr, "myIsDeformed", GetIsDeformed() ); Storable::DataToStream( theStr, "myScaleFactor", GetScaleFactor() ); + Storable::DataToStream( theStr, "myFaceLimit", GetFaceLimit() ); + Storable::DataToStream( theStr, "myIsColored", GetIsColored() ); QColor aColor = GetColor(); Storable::DataToStream( theStr, "myColor.R", aColor.red() ); diff --git a/src/VISU_I/VISU_GaussPoints_i.hh b/src/VISU_I/VISU_GaussPoints_i.hh index 60def88d..5a0fe102 100644 --- a/src/VISU_I/VISU_GaussPoints_i.hh +++ b/src/VISU_I/VISU_GaussPoints_i.hh @@ -75,6 +75,12 @@ namespace VISU VISU_GaussPointsPL* GetGaussPointsPL(); + int + GetFaceLimit() { return myFaceLimit; } + + void + SetFaceLimit( int theFaceLimit ) { myFaceLimit = theFaceLimit; } + bool GetIsDeformed(); @@ -275,6 +281,7 @@ namespace VISU bool myIsActiveLocalScalarBar; QColor myColor; float mySpacing; + int myFaceLimit; QString myMainTexture; QString myAlphaTexture; diff --git a/src/VVTK/VVTK_MainWindow.cxx b/src/VVTK/VVTK_MainWindow.cxx index 743509fa..8bb20dff 100644 --- a/src/VVTK/VVTK_MainWindow.cxx +++ b/src/VVTK/VVTK_MainWindow.cxx @@ -317,6 +317,7 @@ VVTK_MainWindow1 connect(myStyleSwitchAction, SIGNAL(toggled(bool)), this, SLOT(OnInteractorStyleSwitch(bool))); mySegmentationCursorDlg->SetWidgetCtrl( theRenderer->GetWidgetCtrl() ); + mySegmentationCursorDlg->SetInteractor( theInteractor ); connect( theInteractor, SIGNAL( selectionChanged() ), SLOT( OnSelectionChanged() ) ); myPickingDlg->SetInteractor( theInteractor ); diff --git a/src/VVTK/VVTK_PrimitiveBox.cxx b/src/VVTK/VVTK_PrimitiveBox.cxx index de8817f3..84ef52b9 100644 --- a/src/VVTK/VVTK_PrimitiveBox.cxx +++ b/src/VVTK/VVTK_PrimitiveBox.cxx @@ -142,7 +142,7 @@ VVTK_PrimitiveBox::VVTK_PrimitiveBox( QWidget* parent ) : // Notification ( Geometrical Sphere ) myFaceLimitLabel = new QLabel( tr( "FACE_LIMIT" ), this ); - myFaceLimitSpinBox = new QtxIntSpinBox( 10, 10000, 10, this ); + myFaceLimitSpinBox = new QtxIntSpinBox( 10, 1000000, 10, this ); myFaceLimitSpinBox->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) ); aLayout->addWidget( myFaceLimitLabel, 3, 0 ); @@ -313,7 +313,9 @@ void VVTK_PrimitiveBox::setResolution( int theResolution ) int VVTK_PrimitiveBox::getFaceNumber() const { - return myFaceNumberLineEdit->text().toInt(); + int aResolution = getResolution(); + return 2 * aResolution * ( aResolution - 2 ); + //return myFaceNumberLineEdit->text().toInt(); } void VVTK_PrimitiveBox::setFaceNumber( int theFaceNumber ) diff --git a/src/VVTK/VVTK_SegmentationCursorDlg.cxx b/src/VVTK/VVTK_SegmentationCursorDlg.cxx index b15e62fc..63487fed 100644 --- a/src/VVTK/VVTK_SegmentationCursorDlg.cxx +++ b/src/VVTK/VVTK_SegmentationCursorDlg.cxx @@ -22,9 +22,12 @@ #include "VISU_GaussPointsPL.hxx" #include "VISU_OpenGLPointSpriteMapper.hxx" +#include "SUIT_MessageBox.h" #include "SUIT_ResourceMgr.h" #include "SUIT_Session.h" +#include "SVTK_RenderWindowInteractor.h" + #include #include #include @@ -126,7 +129,8 @@ VVTK_SegmentationCursorDlg::VVTK_SegmentationCursorDlg( QWidget* parent, const c myInsideCursorSettings( VISU_InsideCursorSettings::New() ), myOutsideCursorSettings( VISU_OutsideCursorSettings::New() ), myIsPlaneSegmentation( true ), - myWidgetCtrl(NULL) + myWidgetCtrl(NULL), + myInteractor(NULL) { myPriority = 0.0; myEventCallbackCommand->Delete(); @@ -554,6 +558,8 @@ void VVTK_SegmentationCursorDlg::UpdateInsideGaussPoints() anIncrement = aResourceMgr->doubleValue( "VISU", "inside_point_sprite_increment", anIncrement ); this->setIncrement( anIncrement ); + myInsidePrimitiveBox->setFaceLimit( 50000 ); + ApplyInsideGaussPoints(); } @@ -618,6 +624,8 @@ void VVTK_SegmentationCursorDlg::UpdateOutsideGaussPoints() aColor = aResourceMgr->colorValue( "VISU", "outside_point_sprite_color", aColor ); myOutsideSizeBox->setColor( aColor ); + myOutsidePrimitiveBox->setFaceLimit( 50000 ); + ApplyOutsideGaussPoints(); } @@ -668,8 +676,18 @@ void VVTK_SegmentationCursorDlg::onClickApply() ApplySegmentationCursor(); else { - ApplyInsideGaussPoints(); - ApplyOutsideGaussPoints(); + QString aWarning = "The number of faces needed to perform the 'Geometrical Sphere' primitive\n"; + aWarning.append( "presentation might be too important to ensure an acceptable frame rate.\n\n" ); + aWarning.append( "Can you please confirm that you want to continue anyway?" ); + bool toApply = CheckNumberOfFaces() || + SUIT_MessageBox::warn2( this, tr( "Warning" ), aWarning, + tr( "&OK" ), tr( "&Cancel" ), 0, 1, 1 ) == 0; + + if( toApply ) + { + ApplyInsideGaussPoints(); + ApplyOutsideGaussPoints(); + } } } @@ -794,3 +812,28 @@ void VVTK_SegmentationCursorDlg::done( int r ) QDialog::done( r ); } + +bool VVTK_SegmentationCursorDlg::CheckNumberOfFaces() +{ + if( !myInteractor ) + return false; + + vtkRenderer* aRenderer = myInteractor->getRenderer(); + + if( !aRenderer ) + return false; + + int aNumberOfPoints = 0; + + vtkActor* anActor; + vtkActorCollection* anActColl = aRenderer->GetActors(); + for( anActColl->InitTraversal(); ( anActor = anActColl->GetNextActor() ) != NULL; ) + { + if( VISU_GaussPtsAct1* aGaussActor = VISU_GaussPtsAct1::SafeDownCast( anActor ) ) + aNumberOfPoints += aGaussActor->GetInput()->GetNumberOfCells(); + } + return !( myInsidePrimitiveBox->getPrimitiveType() == VISU_OpenGLPointSpriteMapper::GeomSphere && + aNumberOfPoints * myInsidePrimitiveBox->getFaceNumber() * 2 > myInsidePrimitiveBox->getFaceLimit() || + myOutsidePrimitiveBox->getPrimitiveType() == VISU_OpenGLPointSpriteMapper::GeomSphere && + aNumberOfPoints * myOutsidePrimitiveBox->getFaceNumber() > myOutsidePrimitiveBox->getFaceLimit() ); +} diff --git a/src/VVTK/VVTK_SegmentationCursorDlg.h b/src/VVTK/VVTK_SegmentationCursorDlg.h index ea6d3bdf..edac2165 100644 --- a/src/VVTK/VVTK_SegmentationCursorDlg.h +++ b/src/VVTK/VVTK_SegmentationCursorDlg.h @@ -40,6 +40,8 @@ class VISU_WidgetCtrl; class VVTK_PrimitiveBox; class VVTK_SizeBox; +class SVTK_RenderWindowInteractor; + namespace VISU { typedef vtkSmartPointer TTextureValue; @@ -82,6 +84,8 @@ public: vtkSmartPointer GetEventCallbackCommand() { return myEventCallbackCommand; } + void SetInteractor( SVTK_RenderWindowInteractor* theInteractor ) { myInteractor = theInteractor; } + public: float getMagnification() const; void setMagnification( float ); @@ -94,6 +98,8 @@ protected: void ApplyInsideGaussPoints(); void ApplyOutsideGaussPoints(); + bool CheckNumberOfFaces(); + VISU::TTextureValue MakeImageData( bool theInside, const QString& theMainTexture, @@ -115,6 +121,8 @@ signals: void scgClose(); private: + SVTK_RenderWindowInteractor* myInteractor; + QTabWidget* myTabBox; // Segmentation cursor