From 80580dc30432dac075ab21b6bc20008b4cfcc5e7 Mon Sep 17 00:00:00 2001
From: Stephane ALBERT <stephane.albert@c-s.fr>
Date: Tue, 19 Dec 2017 13:00:00 +0100
Subject: [PATCH] ENH: Added -o, --no-overviews command-line option to
 Monteverdi.

---
 .../Monteverdi/include/mvdMainWindow.h        |  2 +-
 Modules/Visualization/Monteverdi/src/main.cxx | 26 ++++++++++++++-----
 .../Monteverdi/src/mvdMainWindow.cxx          |  8 +++---
 3 files changed, 26 insertions(+), 10 deletions(-)

diff --git a/Modules/Visualization/Monteverdi/include/mvdMainWindow.h b/Modules/Visualization/Monteverdi/include/mvdMainWindow.h
index f8523b7f5d..dcd7d76b52 100644
--- a/Modules/Visualization/Monteverdi/include/mvdMainWindow.h
+++ b/Modules/Visualization/Monteverdi/include/mvdMainWindow.h
@@ -150,7 +150,7 @@ public slots:
 
   /**
    */
-  void ImportImages( const QStringList & filenames );
+  void ImportImages( const QStringList & filenames, bool enableOverviews );
 
   /*-[ SIGNALS SECTION ]-----------------------------------------------------*/
 
diff --git a/Modules/Visualization/Monteverdi/src/main.cxx b/Modules/Visualization/Monteverdi/src/main.cxx
index e44dbb8459..6fcd93e297 100644
--- a/Modules/Visualization/Monteverdi/src/main.cxx
+++ b/Modules/Visualization/Monteverdi/src/main.cxx
@@ -65,12 +65,14 @@ struct Flags
 {
   Flags() :
     loadOTBApplications( false ),
-    forceNoGLSL( false )
+    forceNoGLSL( false ),
+    forceNoOverviews( false )
   {
   }
 
   bool loadOTBApplications: 1;
   bool forceNoGLSL: 1;
+  bool forceNoOverviews: 1;
 };
 
 
@@ -111,9 +113,13 @@ main( int argc, char* argv[] )
 	  QCoreApplication::translate(
 	    PROJECT_NAME,
 	    "Usage: %1 [-h|--help] [-a|--applications] [<filename>...]\n"
-	    "  -n, --no-glsl      force OpenGL 1.x compatible rendering."
-	    "  -a, --applications load OTB-applications from OTB_APPLICATIONS_PATH."
-	    "  -h, --help         display this help message.\n"
+	    "  -a, --applications    load OTB-applications from OTB_APPLICATIONS_PATH."
+	    "  -h, --help            display this help message.\n"
+	    "  -g, --no-glsl         force OpenGL 1.x compatible rendering."
+	    "  -o, --no-overviews    ignore build GDAL overviews step."
+#if 0
+	    "  -O, --force-overviews force build GDAL overviews step."
+#endif
 	  )
 	  .arg( QFileInfo( argv[ 0 ] ).baseName() )
 	)
@@ -130,7 +136,15 @@ main( int argc, char* argv[] )
       it = args.erase( it );
       }
 
-    else if(it->compare( "-n" )==0 ||
+    else if(it->compare( "-o" )==0 ||
+	    it->compare( "--no-overviews" )==0 )
+      {
+      flags.forceNoOverviews = true;
+
+      it = args.erase( it );
+      }
+
+    else if(it->compare( "-g" )==0 ||
 	    it->compare( "--no-glsl" )==0 )
       {
       flags.forceNoGLSL = true;
@@ -212,7 +226,7 @@ main( int argc, char* argv[] )
   // 6. Load command-line filenames.
   args.pop_front();
 
-  mainWindow.ImportImages( args );
+  mainWindow.ImportImages( args, !flags.forceNoOverviews );
 
   //
   // 6. Let's go: run the application and return exit code.
diff --git a/Modules/Visualization/Monteverdi/src/mvdMainWindow.cxx b/Modules/Visualization/Monteverdi/src/mvdMainWindow.cxx
index 80155f6fdb..1371577ce9 100644
--- a/Modules/Visualization/Monteverdi/src/mvdMainWindow.cxx
+++ b/Modules/Visualization/Monteverdi/src/mvdMainWindow.cxx
@@ -1362,7 +1362,7 @@ MainWindow
 /*****************************************************************************/
 void
 MainWindow
-::ImportImages( const QStringList & filenames )
+::ImportImages( const QStringList & filenames, bool enableOverviews )
 {
   if( filenames.isEmpty() )
     return;
@@ -1376,7 +1376,8 @@ MainWindow
       )
     );
 
-    if( ( value.isValid() ? value.toBool() : OVERVIEWS_ENABLED_DEFAULT ) &&
+    if( enableOverviews &&
+	( value.isValid() ? value.toBool() : OVERVIEWS_ENABLED_DEFAULT ) &&
 	!BuildGDALOverviews( filenames ) )
       return;
   }
@@ -1809,7 +1810,8 @@ MainWindow
   // Select filename.
   QString caption(tr("Open file..."));
   ImportImages(
-    otb::GetOpenFileNames( this, caption )
+    otb::GetOpenFileNames( this, caption ),
+    true
   );
 }
 
-- 
GitLab