#include <Graphic3d_AspectFillArea3d.hxx>
#include <Graphic3d_MaterialAspect.hxx>
+#include <HYDROData_Channel.h>
#include <HYDROData_Document.h>
#include <HYDROData_Image.h>
#include <HYDROData_ImmersibleZone.h>
+#include <HYDROData_Obstacle.h>
#include <HYDROData_PolylineXY.h>
+#include <HYDROData_Profile.h>
#include <HYDROData_Region.h>
+#include <HYDROData_Stream.h>
#include <HYDROData_Zone.h>
-#include <HYDROData_Obstacle.h>
#include <TopoDS.hxx>
#include <TopoDS_Wire.hxx>
HYDROGUI_Shape::~HYDROGUI_Shape()
{
- erase();
+ erase( false );
if ( !myShape.IsNull() )
myShape.Nullify();
TopoDS_Face aZoneFace = TopoDS::Face( aZone->GetShape() );
- // Generate the filling color for zone
- QStringList aGeomObjectsNames;
-
- HYDROData_SequenceOfObjects aRefObjects = aZone->GetGeometryObjects();
- HYDROData_SequenceOfObjects::Iterator anIter( aRefObjects );
- for ( ; anIter.More(); anIter.Next() )
- {
- Handle(HYDROData_Object) aRefbject =
- Handle(HYDROData_Object)::DownCast( anIter.Value() );
- if ( aRefbject.IsNull() )
- continue;
-
- QString aRefObjectName = aRefbject->GetName();
- if ( aRefObjectName.isEmpty() )
- continue;
-
- aGeomObjectsNames.append( aRefObjectName );
- }
-
setFace( aZoneFace, false, false );
if (aZone->IsMergingNeed() && aZone->GetMergeType() == HYDROData_Zone::Merge_UNKNOWN )
{
}
else
{
+ // Generate the filling color for zone
+ QStringList aGeomObjectsNames;
+
+ HYDROData_SequenceOfObjects aRefObjects = aZone->GetGeometryObjects();
+ HYDROData_SequenceOfObjects::Iterator anIter( aRefObjects );
+ for ( ; anIter.More(); anIter.Next() )
+ {
+ Handle(HYDROData_Object) aRefbject =
+ Handle(HYDROData_Object)::DownCast( anIter.Value() );
+ if ( aRefbject.IsNull() )
+ continue;
+
+ QString aRefObjectName = aRefbject->GetName();
+ if ( aRefObjectName.isEmpty() )
+ continue;
+
+ aGeomObjectsNames.append( aRefObjectName );
+ }
+
setFillingColor( HYDROGUI_Tool::GenerateFillingColor( aDocument, aGeomObjectsNames ) );
}
}
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 );
updateShape( false, false );
//TODO END of the block of code to be reimplemented
}
+ else if ( myObject->IsKind( STANDARD_TYPE(HYDROData_Profile) ) )
+ {
+ Handle(HYDROData_Profile) aProfile =
+ Handle(HYDROData_Profile)::DownCast( myObject );
+
+ TopoDS_Wire aProfileWire;
+
+ if ( aProfile->IsValid() ) {
+ TopoDS_Shape aProfileShape = aProfile->GetShape3D();
+
+ if ( !aProfileShape.IsNull() &&
+ aProfileShape.ShapeType() == TopAbs_WIRE ) {
+ aProfileWire = TopoDS::Wire( aProfileShape );
+ }
+ }
+
+ setWire( aProfileWire, false, false );
+ }
+ else if ( myObject->IsKind( STANDARD_TYPE(HYDROData_Stream) ) )
+ {
+ Handle(HYDROData_Stream) aStream =
+ Handle(HYDROData_Stream)::DownCast( myObject );
+
+ TopoDS_Shell aStreamShape = TopoDS::Shell( aStream->GetTopShape() );
+
+ setShape( aStreamShape, false, false );
+
+ QColor aFillingColor = aStream->GetFillingColor();
+ QColor aBorderColor = aStream->GetBorderColor();
+
+ setFillingColor( aFillingColor, false, false );
+ setBorderColor( aBorderColor, false, false );
+ }
+ else if ( myObject->IsKind( STANDARD_TYPE(HYDROData_Channel) ) )
+ {
+ Handle(HYDROData_Channel) aChannel =
+ Handle(HYDROData_Channel)::DownCast( myObject );
+
+ TopoDS_Face aChannelShape = TopoDS::Face( aChannel->GetTopShape() );
+
+ setShape( aChannelShape, false, false );
+
+ QColor aFillingColor = aChannel->GetFillingColor();
+ QColor aBorderColor = aChannel->GetBorderColor();
+
+ setFillingColor( aFillingColor, false, false );
+ setBorderColor( aBorderColor, false, false );
+ }
}
if ( myShape.IsNull() || !isVisible() )
// Erase previously created shape
erase();
- if ( myTopoShape.IsNull() )
+ if ( myTopoShape.IsNull() ) {
+ myShape.Nullify();
return;
+ }
QString aTextureFileName = getTextureFileName();
bool anIsTexture = !aTextureFileName.isEmpty();
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
const Handle(AIS_Drawer)& anAttributes = myShape->Attributes();
if ( !anAttributes.IsNull() )
{
- if ( myDisplayMode == AIS_Shaded )
- {
- Handle(Prs3d_IsoAspect) anIsoAspect = anAttributes->UIsoAspect();
- if ( !anIsoAspect.IsNull() )
- anIsoAspect->SetNumber( 0 );
+ Handle(Prs3d_IsoAspect) anIsoAspect = anAttributes->UIsoAspect();
+ if ( !anIsoAspect.IsNull() ) {
+ anIsoAspect->SetNumber( 0 );
+ anAttributes->SetUIsoAspect( anIsoAspect );
+ }
- anIsoAspect = anAttributes->VIsoAspect();
- if ( !anIsoAspect.IsNull() )
- anIsoAspect->SetNumber( 0 );
+ anIsoAspect = anAttributes->VIsoAspect();
+ if ( !anIsoAspect.IsNull() ) {
+ anIsoAspect->SetNumber( 0 );
+ anAttributes->SetVIsoAspect( anIsoAspect );
+ }
+ if ( myDisplayMode == AIS_Shaded )
+ {
Handle(Prs3d_ShadingAspect) aShadingAspect = anAttributes->ShadingAspect();
if ( !aShadingAspect.IsNull() )
{