]> SALOME platform Git repositories - modules/hydro.git/commitdiff
Salome HOME
Fix for the bug #124: Split is shown wrong in OCC 3D viewer
authorrkv <rkv@opencascade.com>
Thu, 28 Nov 2013 10:28:12 +0000 (10:28 +0000)
committerrkv <rkv@opencascade.com>
Thu, 28 Nov 2013 10:28:12 +0000 (10:28 +0000)
src/HYDROGUI/HYDROGUI_DataModel.cxx
src/HYDROGUI/HYDROGUI_Shape.cxx

index f3440a44f4371644ad9da531366e8a0142e99612..675d2f4898ef2f59c4fdaaf9f72131c11840ee63 100644 (file)
@@ -262,116 +262,119 @@ void HYDROGUI_DataModel::update( const int theStudyId )
   for( ; anIterator.More(); anIterator.Next() ) {
     Handle(HYDROData_Entity) anObj = anIterator.Current();
 
-    switch ( anObj->GetKind() ) {
-      case KIND_IMAGE:
-      {
-        Handle(HYDROData_Image) anImageObj =
-          Handle(HYDROData_Image)::DownCast( anObj );
-        if( !anImageObj.IsNull() ) {
-          createObject( anImageRootObj, anImageObj );
-        }
+    if ( !anObj.IsNull() )
+    {
+      switch ( anObj->GetKind() ) {
+        case KIND_IMAGE:
+        {
+          Handle(HYDROData_Image) anImageObj =
+            Handle(HYDROData_Image)::DownCast( anObj );
+          if( !anImageObj.IsNull() ) {
+            createObject( anImageRootObj, anImageObj );
+          }
 
-        break;
-      }
-      case KIND_BATHYMETRY:
-      {
-        Handle(HYDROData_Bathymetry) aBathymetryObj =
-          Handle(HYDROData_Bathymetry)::DownCast( anObj );
-        if( !aBathymetryObj.IsNull() ) {
-          createObject( aBathymetryRootObj, aBathymetryObj );
+          break;
         }
+        case KIND_BATHYMETRY:
+        {
+          Handle(HYDROData_Bathymetry) aBathymetryObj =
+            Handle(HYDROData_Bathymetry)::DownCast( anObj );
+          if( !aBathymetryObj.IsNull() ) {
+            createObject( aBathymetryRootObj, aBathymetryObj );
+          }
 
-        break;
-      }
-      case KIND_CHANNEL:
-      {
-        Handle(HYDROData_Channel) aChannelObj =
-          Handle(HYDROData_Channel)::DownCast( anObj );
-        if( !aChannelObj.IsNull() ) {
-          createObject( anArtificialObjectsRootObj, aChannelObj );
+          break;
         }
+        case KIND_CHANNEL:
+        {
+          Handle(HYDROData_Channel) aChannelObj =
+            Handle(HYDROData_Channel)::DownCast( anObj );
+          if( !aChannelObj.IsNull() ) {
+            createObject( anArtificialObjectsRootObj, aChannelObj );
+          }
 
-        break;
-      }
-      case KIND_DIGUE:
-      {
-        Handle(HYDROData_Digue) aDigueObj =
-          Handle(HYDROData_Digue)::DownCast( anObj );
-        if( !aDigueObj.IsNull() ) {
-          createObject( anArtificialObjectsRootObj, aDigueObj );
+          break;
         }
+        case KIND_DIGUE:
+        {
+          Handle(HYDROData_Digue) aDigueObj =
+            Handle(HYDROData_Digue)::DownCast( anObj );
+          if( !aDigueObj.IsNull() ) {
+            createObject( anArtificialObjectsRootObj, aDigueObj );
+          }
 
-        break;
-      }
-      case KIND_IMMERSIBLE_ZONE:
-      {
-        Handle(HYDROData_ImmersibleZone) anImmersibleZoneObj =
-          Handle(HYDROData_ImmersibleZone)::DownCast( anObj );
-        if( !anImmersibleZoneObj.IsNull() ) {
-          createObject( aNaturalObjectsRootObj, anImmersibleZoneObj );
+          break;
         }
+        case KIND_IMMERSIBLE_ZONE:
+        {
+          Handle(HYDROData_ImmersibleZone) anImmersibleZoneObj =
+            Handle(HYDROData_ImmersibleZone)::DownCast( anObj );
+          if( !anImmersibleZoneObj.IsNull() ) {
+            createObject( aNaturalObjectsRootObj, anImmersibleZoneObj );
+          }
 
-        break;
-      }
-      case KIND_RIVER:
-      {
-        Handle(HYDROData_River) aRiverObj =
-          Handle(HYDROData_River)::DownCast( anObj );
-        if( !aRiverObj.IsNull() ) {
-          createObject( aNaturalObjectsRootObj, aRiverObj );
+          break;
         }
+        case KIND_RIVER:
+        {
+          Handle(HYDROData_River) aRiverObj =
+            Handle(HYDROData_River)::DownCast( anObj );
+          if( !aRiverObj.IsNull() ) {
+            createObject( aNaturalObjectsRootObj, aRiverObj );
+          }
 
-        break;
-      }
-      case KIND_OBSTACLE:
-      {
-        Handle(HYDROData_Obstacle) anObstacleObj =
-          Handle(HYDROData_Obstacle)::DownCast( anObj );
-        if( !anObstacleObj.IsNull() ) {
-          createObject( anObstaclesRootObj, anObstacleObj );
+          break;
         }
+        case KIND_OBSTACLE:
+        {
+          Handle(HYDROData_Obstacle) anObstacleObj =
+            Handle(HYDROData_Obstacle)::DownCast( anObj );
+          if( !anObstacleObj.IsNull() ) {
+            createObject( anObstaclesRootObj, anObstacleObj );
+          }
 
-        break;
-      }
-      case KIND_CALCULATION:
-      {
-        Handle(HYDROData_CalculationCase) aCalculObj =
-          Handle(HYDROData_CalculationCase)::DownCast( anObj );
-        if( !aCalculObj.IsNull() ) {
-          createObject( aCalculRootObj, aCalculObj );
+          break;
         }
+        case KIND_CALCULATION:
+        {
+          Handle(HYDROData_CalculationCase) aCalculObj =
+            Handle(HYDROData_CalculationCase)::DownCast( anObj );
+          if( !aCalculObj.IsNull() ) {
+            createObject( aCalculRootObj, aCalculObj );
+          }
 
-        break;
-      }
-      case KIND_POLYLINEXY:
-      {
-        Handle(HYDROData_PolylineXY) aPolylineObj =
-          Handle(HYDROData_PolylineXY)::DownCast( anObj );
-        if( !aPolylineObj.IsNull() ) {
-          createObject( aPolylineRootObj, aPolylineObj );
+          break;
         }
+        case KIND_POLYLINEXY:
+        {
+          Handle(HYDROData_PolylineXY) aPolylineObj =
+            Handle(HYDROData_PolylineXY)::DownCast( anObj );
+          if( !aPolylineObj.IsNull() ) {
+            createObject( aPolylineRootObj, aPolylineObj );
+          }
 
-        break;
-      }
-      case KIND_PROFILE:
-      {
-        Handle(HYDROData_Profile) aProfileObj =
-          Handle(HYDROData_Profile)::DownCast( anObj );
-        if( !aProfileObj.IsNull() ) {
-          createObject( aProfileRootObj, aProfileObj );
+          break;
         }
+        case KIND_PROFILE:
+        {
+          Handle(HYDROData_Profile) aProfileObj =
+            Handle(HYDROData_Profile)::DownCast( anObj );
+          if( !aProfileObj.IsNull() ) {
+            createObject( aProfileRootObj, aProfileObj );
+          }
 
-        break;
-      }
-      case KIND_VISUAL_STATE:
-      {
-        Handle(HYDROData_VisualState) aVisualStateObj =
-          Handle(HYDROData_VisualState)::DownCast( anObj );
-        if( !aVisualStateObj.IsNull() ) {
-          createObject( aVisualStateRootObj, aVisualStateObj );
+          break;
         }
+        case KIND_VISUAL_STATE:
+        {
+          Handle(HYDROData_VisualState) aVisualStateObj =
+            Handle(HYDROData_VisualState)::DownCast( anObj );
+          if( !aVisualStateObj.IsNull() ) {
+            createObject( aVisualStateRootObj, aVisualStateObj );
+          }
 
-        break;
+          break;
+        }
       }
     }
   }
index 5c4aa75a37d79da14e8c3c2988a3ae209f38ffff..799c09f2b36eb4763ae8c2cba2d89e94ff5971fe 100644 (file)
@@ -217,8 +217,18 @@ void HYDROGUI_Shape::update( const bool theIsUpdateViewer )
       QTransform anInversion = QTransform::fromScale( -1, -1 );
       anImage = anImage.transformed( anInversion * aTrsf, Qt::SmoothTransformation );
 
+      // Workaround: Scale the texture image to the nearest width multiple 4 due to the CASCADE bug 23813
+      int aTrsfWidth = anImage.width();
+      int aDelta = aTrsfWidth % 4;
+      if ( aDelta > 0 )
+      {
+        aTrsfWidth += ( 4 - aDelta );
+      }
+      anImage = anImage.scaledToWidth( aTrsfWidth );
+
       // temporary optimization, to reduce the saved image size (and the texture quality)
-      QImage anImageToSave = reduceTexture( anImage, 500 );
+      QImage anImageToSave = anImage; //RKV:reduceTexture( anImage, 500 );
+
       bool isSaved = anImageToSave.save( aTextureFileName );
       if ( !isSaved ) {
         QString aTitle = QObject::tr( "FILE_ERROR" );
@@ -226,10 +236,10 @@ void HYDROGUI_Shape::update( const bool theIsUpdateViewer )
         SUIT_MessageBox::warning( 0, aTitle, aMessage );
       }
 
-      QPointF aPoint1( 0, 0 );
-      QPointF aPoint2( aWidth, 0 );
-      QPointF aPoint3( aWidth, aHeight );
-      QPointF aPoint4( 0, aHeight );
+      QPointF aPoint1( 0, 0 );            // 1: top left
+      QPointF aPoint2( aWidth, 0 );       // 2: top right
+      QPointF aPoint3( aWidth, aHeight ); // 3: bottom right
+      QPointF aPoint4( 0, aHeight );      // 4: bottom left
 
       aPoint1 = aTrsf.map( aPoint1 );
       aPoint2 = aTrsf.map( aPoint2 );
@@ -250,6 +260,7 @@ void HYDROGUI_Shape::update( const bool theIsUpdateViewer )
       TopoDS_Edge anEdge4 = BRepBuilderAPI_MakeEdge( aPnt4, aPnt1 ).Edge();
 
       TopoDS_Wire aWire = BRepBuilderAPI_MakeWire( anEdge1, anEdge2, anEdge3, anEdge4 ).Wire();
+      aWire.Closed( true );
 
       setTextureFileName( aTextureFileName, false, false );
       setFace( aWire, false, false );
@@ -477,7 +488,9 @@ void HYDROGUI_Shape::buildShape()
 
     aTexturedShape->SetTextureFileName( HYDROGUI_Tool::ToAsciiString( aTextureFileName ) );
     aTexturedShape->SetTextureMapOn();
+    // Just use the texture image as is
     aTexturedShape->DisableTextureModulate();
+    aTexturedShape->SetTextureRepeat( false ); // don't repeat the texture image on the face
   }
 
     // Init default params for shape