- else if ( myObject->IsKind( STANDARD_TYPE(HYDROData_Image) ) )
- {
- Handle(HYDROData_Image) anImageObj =
- Handle(HYDROData_Image)::DownCast( myObject );
-
- removeTextureFile();
-
- QString aTextureFileName = generateTextureFileName( anImageObj );
-
- QImage anImage = anImageObj->Image();
- QString aFilePath = anImageObj->GetFilePath();
- QTransform aTrsf = anImageObj->Trsf();
-
- int aWidth = anImage.width();
- int aHeight = anImage.height();
-
- 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 = anImage; //RKV:reduceTexture( anImage, 500 );
-
- bool isSaved = anImageToSave.save( aTextureFileName );
- if ( !isSaved ) {
- QString aTitle = QObject::tr( "FILE_ERROR" );
- QString aMessage = QObject::tr( "FILE_CAN_NOT_BE_CREATED" ).arg( aTextureFileName );
- SUIT_MessageBox::warning( 0, aTitle, aMessage );
- }
-
- 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 );
- aPoint3 = aTrsf.map( aPoint3 );
- aPoint4 = aTrsf.map( aPoint4 );
-
- QPolygonF aPolygon = QPolygonF() << aPoint1 << aPoint2 << aPoint3 << aPoint4;
- QRectF aRect = aPolygon.boundingRect();
-
- gp_Pnt aPnt1( aRect.topLeft().x(), aRect.topLeft().y(), 0 );
- gp_Pnt aPnt2( aRect.topRight().x(), aRect.topRight().y(), 0 );
- gp_Pnt aPnt3( aRect.bottomRight().x(), aRect.bottomRight().y(), 0 );
- gp_Pnt aPnt4( aRect.bottomLeft().x(), aRect.bottomLeft().y(), 0 );
-
- TopoDS_Edge anEdge1 = BRepBuilderAPI_MakeEdge( aPnt1, aPnt2 ).Edge();
- TopoDS_Edge anEdge2 = BRepBuilderAPI_MakeEdge( aPnt2, aPnt3 ).Edge();
- TopoDS_Edge anEdge3 = BRepBuilderAPI_MakeEdge( aPnt3, aPnt4 ).Edge();
- 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 );
- }
- else if ( myObject->IsKind( STANDARD_TYPE(HYDROData_Obstacle) ) )
- {
- Handle(HYDROData_Obstacle) anObstacle =
- Handle(HYDROData_Obstacle)::DownCast( myObject );
-
- //TODO BEGIN of the block of code to be reimplemented
- //TODO GetTopShape() to be used in future
- myTopoShape = anObstacle->GetShape3D();
- myDisplayMode = AIS_Shaded;
-
- QColor aFillingColor = anObstacle->GetFillingColor();
- QColor aBorderColor = anObstacle->GetBorderColor();
-
- setFillingColor( aFillingColor, false, false );
- setBorderColor( aBorderColor, false, false );
-
- buildShape();
- updateShape( false, false );
- //TODO END of the block of code to be reimplemented
- }