From: Paul RASCLE Date: Tue, 5 Jan 2016 09:42:59 +0000 (+0100) Subject: détection des problèmes de chargement d'images X-Git-Tag: SALOME_HYDRO_V1.0~25 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=88d05a5ab428b1cb7387d9c8098127f3fbd6e9ac;p=modules%2Fhydro.git détection des problèmes de chargement d'images --- diff --git a/doc/salome/examples/h001_importImage.py b/doc/salome/examples/h001_importImage.py index 184e2434..6c072bff 100644 --- a/doc/salome/examples/h001_importImage.py +++ b/doc/salome/examples/h001_importImage.py @@ -20,7 +20,8 @@ hydro_doc.SetLocalCS( 0, 0 ) garonne_ign_01 = hydro_doc.CreateObject( KIND_IMAGE ) garonne_ign_01.SetName( "garonne_ign_01" ) -garonne_ign_01.LoadImage( os.path.join(HYDRO_SAMPLES , "garonne_ign_01.png" )) +if not(garonne_ign_01.LoadImage( os.path.join(HYDRO_SAMPLES , "garonne_ign_01.png" ))): + raise ValueError('problem while loading image') garonne_ign_01.SetLocalPoints( QPoint( 40, 817 ), QPoint( 1325, 85 ) ) diff --git a/doc/salome/examples/h002_importImage.py b/doc/salome/examples/h002_importImage.py index d884dc80..efa0ead5 100644 --- a/doc/salome/examples/h002_importImage.py +++ b/doc/salome/examples/h002_importImage.py @@ -23,7 +23,8 @@ garonne_ign_01.SetName( "garonne_ign_01" ) garonne_ign_01.SetZLevel( 0 ) -garonne_ign_01.LoadImage(os.path.join(HYDRO_SAMPLES, "garonne_ign_01.png" )) +if not(garonne_ign_01.LoadImage(os.path.join(HYDRO_SAMPLES, "garonne_ign_01.png" ))): + raise ValueError('problem while loading image') garonne_ign_01.SetLocalPoints( QPoint( 40, 817 ), QPoint( 1325, 85 ) ) @@ -40,7 +41,8 @@ garonne_ign_02.SetName( "garonne_ign_02" ) garonne_ign_02.SetZLevel( 1 ) -garonne_ign_02.LoadImage( os.path.join(HYDRO_SAMPLES, "garonne_ign_02.png" )) +if not(garonne_ign_02.LoadImage( os.path.join(HYDRO_SAMPLES, "garonne_ign_02.png" ))): + raise ValueError('problem while loading image') garonne_ign_02.SetLocalPoints( QPoint( 1389, 447 ), QPoint( 784, 481 ) ) diff --git a/doc/salome/examples/h003_changeLCS.py b/doc/salome/examples/h003_changeLCS.py index a5b88f7b..be02467e 100644 --- a/doc/salome/examples/h003_changeLCS.py +++ b/doc/salome/examples/h003_changeLCS.py @@ -23,7 +23,8 @@ garonne_ign_01.SetName( "garonne_ign_01" ) garonne_ign_01.SetZLevel( 0 ) -garonne_ign_01.LoadImage(os.path.join(HYDRO_SAMPLES, "garonne_ign_01.png" )) +if not(garonne_ign_01.LoadImage(os.path.join(HYDRO_SAMPLES, "garonne_ign_01.png" ))): + raise ValueError('problem while loading image') garonne_ign_01.SetLocalPoints( QPoint( 40, 817 ), QPoint( 1325, 85 ) ) @@ -40,7 +41,8 @@ garonne_ign_02.SetName( "garonne_ign_02" ) garonne_ign_02.SetZLevel( 1 ) -garonne_ign_02.LoadImage( os.path.join(HYDRO_SAMPLES, "garonne_ign_02.png" )) +if not(garonne_ign_02.LoadImage( os.path.join(HYDRO_SAMPLES, "garonne_ign_02.png" ))): + raise ValueError('problem while loading image') garonne_ign_02.SetLocalPoints( QPoint( 1389, 447 ), QPoint( 784, 481 ) ) diff --git a/doc/salome/examples/h005_importImageBad.py b/doc/salome/examples/h005_importImageBad.py index e9ece758..d2e6887c 100644 --- a/doc/salome/examples/h005_importImageBad.py +++ b/doc/salome/examples/h005_importImageBad.py @@ -20,19 +20,10 @@ hydro_doc.SetLocalCS( 0, 0 ) garonne_ign_inexistant = hydro_doc.CreateObject( KIND_IMAGE ) garonne_ign_inexistant.SetName( "garonne_ign_inexistant" ) -garonne_ign_inexistant.LoadImage( os.path.join(HYDRO_SAMPLES , "garonne_ign_inexistant.png" )) +ret = garonne_ign_inexistant.LoadImage( os.path.join(HYDRO_SAMPLES , "garonne_ign_inexistant.png" )) -# TODO : ce chargement doit echouer avec un retour d'erreur à traiter -raise ValueError('file not found') - -garonne_ign_inexistant.SetLocalPoints( QPoint( 40, 817 ), - QPoint( 1325, 85 ) ) - -garonne_ign_inexistant.SetGlobalPoints( 1, - QPointF( 471562, 6.36775e+06 ), - QPointF( 489400, 6.37702e+06 ) ) - -garonne_ign_inexistant.Update() +if ret: + raise ValueError('loading problem not detected: return value should be null') if salome.sg.hasDesktop(): salome.sg.updateObjBrowser(1) diff --git a/doc/salome/examples/h009_normalCaseManual.py b/doc/salome/examples/h009_normalCaseManual.py index b1d8dfa1..cd407f19 100644 --- a/doc/salome/examples/h009_normalCaseManual.py +++ b/doc/salome/examples/h009_normalCaseManual.py @@ -27,7 +27,8 @@ garonne_ign_01.SetName( "garonne_ign_01" ) garonne_ign_01.SetZLevel( 0 ) -garonne_ign_01.LoadImage(os.path.join(HYDRO_SAMPLES, "garonne_ign_01.png" )) +if not(garonne_ign_01.LoadImage(os.path.join(HYDRO_SAMPLES, "garonne_ign_01.png" ))): + raise ValueError('problem while loading image') garonne_ign_01.SetLocalPoints( QPoint( 40, 817 ), QPoint( 1325, 85 ) ) @@ -44,7 +45,8 @@ garonne_ign_02.SetName( "garonne_ign_02" ) garonne_ign_02.SetZLevel( 1 ) -garonne_ign_02.LoadImage( os.path.join(HYDRO_SAMPLES, "garonne_ign_02.png" )) +if not(garonne_ign_02.LoadImage( os.path.join(HYDRO_SAMPLES, "garonne_ign_02.png" ))): + raise ValueError('problem while loading image') garonne_ign_02.SetLocalPoints( QPoint( 1389, 447 ), QPoint( 784, 481 ) ) diff --git a/doc/salome/examples/h010_normalCaseManualMesh.py b/doc/salome/examples/h010_normalCaseManualMesh.py index 5f63d530..6c5272d0 100644 --- a/doc/salome/examples/h010_normalCaseManualMesh.py +++ b/doc/salome/examples/h010_normalCaseManualMesh.py @@ -27,7 +27,8 @@ garonne_ign_01.SetName( "garonne_ign_01" ) garonne_ign_01.SetZLevel( 0 ) -garonne_ign_01.LoadImage(os.path.join(HYDRO_SAMPLES, "garonne_ign_01.png" )) +if not(garonne_ign_01.LoadImage(os.path.join(HYDRO_SAMPLES, "garonne_ign_01.png" ))): + raise ValueError('problem while loading image') garonne_ign_01.SetLocalPoints( QPoint( 40, 817 ), QPoint( 1325, 85 ) ) @@ -44,7 +45,8 @@ garonne_ign_02.SetName( "garonne_ign_02" ) garonne_ign_02.SetZLevel( 1 ) -garonne_ign_02.LoadImage( os.path.join(HYDRO_SAMPLES, "garonne_ign_02.png" )) +if not(garonne_ign_02.LoadImage( os.path.join(HYDRO_SAMPLES, "garonne_ign_02.png" ))): + raise ValueError('problem while loading image') garonne_ign_02.SetLocalPoints( QPoint( 1389, 447 ), QPoint( 784, 481 ) ) diff --git a/doc/salome/examples/h011_normalCaseManualInterpolZ.py b/doc/salome/examples/h011_normalCaseManualInterpolZ.py index b995db47..49282307 100644 --- a/doc/salome/examples/h011_normalCaseManualInterpolZ.py +++ b/doc/salome/examples/h011_normalCaseManualInterpolZ.py @@ -27,7 +27,8 @@ garonne_ign_01.SetName( "garonne_ign_01" ) garonne_ign_01.SetZLevel( 0 ) -garonne_ign_01.LoadImage(os.path.join(HYDRO_SAMPLES, "garonne_ign_01.png" )) +if not(garonne_ign_01.LoadImage(os.path.join(HYDRO_SAMPLES, "garonne_ign_01.png" ))): + raise ValueError('problem while loading image') garonne_ign_01.SetLocalPoints( QPoint( 40, 817 ), QPoint( 1325, 85 ) ) @@ -44,7 +45,8 @@ garonne_ign_02.SetName( "garonne_ign_02" ) garonne_ign_02.SetZLevel( 1 ) -garonne_ign_02.LoadImage( os.path.join(HYDRO_SAMPLES, "garonne_ign_02.png" )) +if not(garonne_ign_02.LoadImage( os.path.join(HYDRO_SAMPLES, "garonne_ign_02.png" ))): + raise ValueError('problem while loading image') garonne_ign_02.SetLocalPoints( QPoint( 1389, 447 ), QPoint( 784, 481 ) ) diff --git a/doc/salome/examples/h012_caseDigueManual.py b/doc/salome/examples/h012_caseDigueManual.py index de2f5cf1..6b679b4b 100644 --- a/doc/salome/examples/h012_caseDigueManual.py +++ b/doc/salome/examples/h012_caseDigueManual.py @@ -27,7 +27,8 @@ garonne_ign_01.SetName( "garonne_ign_01" ) garonne_ign_01.SetZLevel( 0 ) -garonne_ign_01.LoadImage(os.path.join(HYDRO_SAMPLES, "garonne_ign_01.png" )) +if not(garonne_ign_01.LoadImage(os.path.join(HYDRO_SAMPLES, "garonne_ign_01.png" ))): + raise ValueError('problem while loading image') garonne_ign_01.SetLocalPoints( QPoint( 40, 817 ), QPoint( 1325, 85 ) ) @@ -44,7 +45,8 @@ garonne_ign_02.SetName( "garonne_ign_02" ) garonne_ign_02.SetZLevel( 1 ) -garonne_ign_02.LoadImage( os.path.join(HYDRO_SAMPLES, "garonne_ign_02.png" )) +if not(garonne_ign_02.LoadImage( os.path.join(HYDRO_SAMPLES, "garonne_ign_02.png" ))): + raise ValueError('problem while loading image') garonne_ign_02.SetLocalPoints( QPoint( 1389, 447 ), QPoint( 784, 481 ) ) diff --git a/doc/salome/examples/h013_caseDigueManualMesh.py b/doc/salome/examples/h013_caseDigueManualMesh.py index 73d07f75..6e013f8d 100644 --- a/doc/salome/examples/h013_caseDigueManualMesh.py +++ b/doc/salome/examples/h013_caseDigueManualMesh.py @@ -27,7 +27,8 @@ garonne_ign_01.SetName( "garonne_ign_01" ) garonne_ign_01.SetZLevel( 0 ) -garonne_ign_01.LoadImage(os.path.join(HYDRO_SAMPLES, "garonne_ign_01.png" )) +if not(garonne_ign_01.LoadImage(os.path.join(HYDRO_SAMPLES, "garonne_ign_01.png" ))): + raise ValueError('problem while loading image') garonne_ign_01.SetLocalPoints( QPoint( 40, 817 ), QPoint( 1325, 85 ) ) @@ -44,7 +45,8 @@ garonne_ign_02.SetName( "garonne_ign_02" ) garonne_ign_02.SetZLevel( 1 ) -garonne_ign_02.LoadImage( os.path.join(HYDRO_SAMPLES, "garonne_ign_02.png" )) +if not(garonne_ign_02.LoadImage( os.path.join(HYDRO_SAMPLES, "garonne_ign_02.png" ))): + raise ValueError('problem while loading image') garonne_ign_02.SetLocalPoints( QPoint( 1389, 447 ), QPoint( 784, 481 ) ) diff --git a/doc/salome/examples/h014_caseDigueManualInterpolZ.py b/doc/salome/examples/h014_caseDigueManualInterpolZ.py index fd95340e..174c6bee 100644 --- a/doc/salome/examples/h014_caseDigueManualInterpolZ.py +++ b/doc/salome/examples/h014_caseDigueManualInterpolZ.py @@ -27,7 +27,8 @@ garonne_ign_01.SetName( "garonne_ign_01" ) garonne_ign_01.SetZLevel( 0 ) -garonne_ign_01.LoadImage(os.path.join(HYDRO_SAMPLES, "garonne_ign_01.png" )) +if not(garonne_ign_01.LoadImage(os.path.join(HYDRO_SAMPLES, "garonne_ign_01.png" ))): + raise ValueError('problem while loading image') garonne_ign_01.SetLocalPoints( QPoint( 40, 817 ), QPoint( 1325, 85 ) ) @@ -44,7 +45,8 @@ garonne_ign_02.SetName( "garonne_ign_02" ) garonne_ign_02.SetZLevel( 1 ) -garonne_ign_02.LoadImage( os.path.join(HYDRO_SAMPLES, "garonne_ign_02.png" )) +if not(garonne_ign_02.LoadImage( os.path.join(HYDRO_SAMPLES, "garonne_ign_02.png" ))): + raise ValueError('problem while loading image') garonne_ign_02.SetLocalPoints( QPoint( 1389, 447 ), QPoint( 784, 481 ) ) diff --git a/doc/salome/examples/h015_normalCaseManualTelemac.py b/doc/salome/examples/h015_normalCaseManualTelemac.py index 4df4002f..5395883f 100644 --- a/doc/salome/examples/h015_normalCaseManualTelemac.py +++ b/doc/salome/examples/h015_normalCaseManualTelemac.py @@ -27,7 +27,8 @@ garonne_ign_01.SetName( "garonne_ign_01" ) garonne_ign_01.SetZLevel( 0 ) -garonne_ign_01.LoadImage(os.path.join(HYDRO_SAMPLES, "garonne_ign_01.png" )) +if not(garonne_ign_01.LoadImage(os.path.join(HYDRO_SAMPLES, "garonne_ign_01.png" ))): + raise ValueError('problem while loading image') garonne_ign_01.SetLocalPoints( QPoint( 40, 817 ), QPoint( 1325, 85 ) ) @@ -44,7 +45,8 @@ garonne_ign_02.SetName( "garonne_ign_02" ) garonne_ign_02.SetZLevel( 1 ) -garonne_ign_02.LoadImage( os.path.join(HYDRO_SAMPLES, "garonne_ign_02.png" )) +if not(garonne_ign_02.LoadImage( os.path.join(HYDRO_SAMPLES, "garonne_ign_02.png" ))): + raise ValueError('problem while loading image') garonne_ign_02.SetLocalPoints( QPoint( 1389, 447 ), QPoint( 784, 481 ) ) diff --git a/src/HYDROData/HYDROData_Image.cxx b/src/HYDROData/HYDROData_Image.cxx index 6a3e9a3b..9cabbc12 100644 --- a/src/HYDROData/HYDROData_Image.cxx +++ b/src/HYDROData/HYDROData_Image.cxx @@ -71,8 +71,9 @@ QStringList HYDROData_Image::DumpToPython( const QString& thePyScriptPath, if ( !aFilePath.isEmpty() ) { aResList << QString( "" ); - aResList << QString( "%1.LoadImage( \"%2\" )" ) + aResList << QString( "if not(%1.LoadImage( \"%2\" )):" ) .arg( anImageName ).arg( aFilePath ); + aResList << QString( " raise ValueError('problem while loading image')" ); aResList << QString( "" ); // Dump transformation points for image