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;
+ }
}
}
}
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" );
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 );
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 );
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