]> SALOME platform Git repositories - modules/hydro.git/commitdiff
Salome HOME
size of image is limited by 7000 pixels
authorasl <asl@opencascade.com>
Mon, 30 Oct 2017 07:04:49 +0000 (10:04 +0300)
committerasl <asl@opencascade.com>
Mon, 30 Oct 2017 07:04:49 +0000 (10:04 +0300)
src/HYDROGUI/HYDROGUI_ShapeImage.cxx
src/HYDROGUI/HYDROGUI_ShapeImage.h

index d57f726dac12cf044c2699d731436a6d89e14984..765e75d615d7f9e3751439d8b9386f1b7b672c8f 100644 (file)
@@ -25,6 +25,9 @@
 #include <HYDROData_Document.h>
 
 #include <gp_Pnt.hxx>
+#include <QMessageBox>
+#include <QApplication>
+#include <QDesktopWidget>
 
 HYDROGUI_ShapeImage::HYDROGUI_ShapeImage( const Handle(AIS_InteractiveContext)& theContext,
                                           const Handle(HYDROData_Image)&         theImage,
@@ -55,14 +58,17 @@ QList<Handle(AIS_InteractiveObject)> HYDROGUI_ShapeImage::createShape() const
   Handle(HYDROData_Image) anImageObj = Handle(HYDROData_Image)::DownCast( getObject() );
   if ( !anImageObj.IsNull() )
   {
-    aPrs = new HYDROGUI_ImagePrs( imagePixMap( anImageObj ), imageContour( anImageObj ) );
+       QString aMsg;
+    aPrs = new HYDROGUI_ImagePrs( imagePixMap( anImageObj, aMsg ), imageContour( anImageObj ) );
+       if( !aMsg.isEmpty() )
+               QMessageBox::warning( qApp->desktop(), "Warning", aMsg ); 
     shapes.append( aPrs );
   }
 
   return shapes;
 }
 
-Handle(Image_PixMap) HYDROGUI_ShapeImage::imagePixMap( const Handle(HYDROData_Image)& theImageObj ) const
+Handle(Image_PixMap) HYDROGUI_ShapeImage::imagePixMap( const Handle(HYDROData_Image)& theImageObj, QString& theMessage ) const
 {
     Handle(Image_PixMap) aPix;
     if ( !theImageObj.IsNull() )
@@ -79,7 +85,14 @@ Handle(Image_PixMap) HYDROGUI_ShapeImage::imagePixMap( const Handle(HYDROData_Im
             if ( aDelta > 0 )
                 aTrsfWidth += ( 4 - aDelta );
       
+                       const int maxWidth = 7000;
+                       if( aTrsfWidth>maxWidth )
+                       {
+                               aTrsfWidth = maxWidth;
+                               theMessage = QString( "The size of image is scaled to %0" ).arg( aTrsfWidth );
+                       }
             anImage = anImage.scaledToWidth( aTrsfWidth );
+                       int pix = anImage.width() * anImage.height();
 
             aPix = HYDROGUI_Tool::Pixmap( anImage );
         }
index 17c6dec0437a70a99bf2d0af6058d0f5c15a334b..71941262a5e3717889878fc778fc32fb01bf308c 100644 (file)
@@ -37,7 +37,7 @@ public:
 
 protected:
   virtual QList<Handle(AIS_InteractiveObject)> createShape() const;
-  Handle(Image_PixMap)                  imagePixMap( const Handle(HYDROData_Image)& ) const;
+  Handle(Image_PixMap)                  imagePixMap( const Handle(HYDROData_Image)&, QString& theMessage ) const;
   QPolygonF                             imageContour( const Handle(HYDROData_Image)& ) const;
 };