}
/////////////////// OCC SHAPES PROCESSING
+QList<HYDROGUI_Shape*> HYDROGUI_Module::getObjectShapes( const int theViewId,
+ ObjectKind theKind ) const
+{
+ QList<HYDROGUI_Shape*> aResult;
+
+ if ( myShapesMap.contains( theViewId ) )
+ {
+ const ListOfShapes& aViewShapes = myShapesMap.value( theViewId );
+ foreach ( HYDROGUI_Shape* aShape, aViewShapes )
+ {
+ if( aShape && aShape->getObject()->GetKind()==theKind )
+ aResult.append( aShape );
+ }
+ }
+ return aResult;
+}
+
HYDROGUI_Shape* HYDROGUI_Module::getObjectShape( const int theViewId,
const Handle(HYDROData_Entity)& theObject ) const
{
*/
void setIsToUpdate( const Handle(HYDROData_Entity)& theObject,
const bool theState = true );
+ QList<HYDROGUI_Shape*> getObjectShapes( const int theViewId,
+ ObjectKind theKind ) const;
HYDROGUI_Shape* getObjectShape( const int theViewId,
const Handle(HYDROData_Entity)& theObject ) const;
void setObjectShape( const int theViewId,
#include <AIS_ListIteratorOfListOfInteractive.hxx>
#include <AIS_ListOfInteractive.hxx>
+#include <Aspect_ColorScale.hxx>
+
#include <TColStd_SequenceOfInteger.hxx>
#include <LightApp_Application.h>
#include <OCCViewer_ViewManager.h>
#include <OCCViewer_ViewModel.h>
#include <OCCViewer_ViewWindow.h>
+#include <OCCViewer_ViewPort3d.h>
HYDROGUI_OCCDisplayer::HYDROGUI_OCCDisplayer( HYDROGUI_Module* theModule )
: HYDROGUI_AbstractDisplayer( theModule )
return;
module()->removeViewShapes( (size_t)aViewer );
+ UpdateColorScale( aViewer );
}
void HYDROGUI_OCCDisplayer::Erase( const HYDROData_SequenceOfObjects& theObjs,
module()->removeObjectShape( (size_t)aViewer, anObj );
}
aViewer->update();
+ UpdateColorScale( aViewer );
}
HYDROGUI_Shape* HYDROGUI_OCCDisplayer::createShape( const int theViewerId,
else if ( !aCtx.IsNull() ) { // TODO: determine if this code is necessary (added as a fix for issue# 359)
aCtx->UpdateSelected();
}
+
+ UpdateColorScale( aViewer );
}
void HYDROGUI_OCCDisplayer::purgeObjects( const int theViewerId )
aRes = true;
}
+ UpdateColorScale( theViewer );
return aRes;
}
// Set Z layer
if ( anObjShape ) {
- aCtx->SetZLayer( anObjShape->getAISShape(), theZLayerId );
+ aCtx->SetZLayer( anObjShape->getAISObject(), theZLayerId );
+ }
+}
+
+void HYDROGUI_OCCDisplayer::UpdateColorScale( const OCCViewer_Viewer* theViewer )
+{
+ OCCViewer_ViewWindow* aWnd = dynamic_cast<OCCViewer_ViewWindow*>( theViewer->getViewManager()->getActiveView() );
+ Handle(V3d_View) aView = aWnd->getViewPort()->getView();
+
+ int aViewerId = (size_t)theViewer;//TODO: check if viewer id is correct
+ QList<HYDROGUI_Shape*> aBaths = module()->getObjectShapes( aViewerId, KIND_BATHYMETRY );
+
+ bool isDisplayColorScale = !aBaths.empty();
+ Standard_Real anXPos = 0.05; //TODO
+ Standard_Real anYPos = 0.1; //TODO
+ Standard_Real aWidth = 0.2; //TODO
+ Standard_Real aHeight = 0.5; //TODO
+ Standard_Integer aTextHeight = 14; //TODO
+ Standard_Integer aNbIntervals = 20; //TODO
+ TCollection_ExtendedString aColorScaleTitle = "";//TODO
+
+ Standard_Real aColorScaleMin = 0, aColorScaleMax = 1, aMin, aMax;
+ bool isFirst = true;
+ foreach( HYDROGUI_Shape* aBathShape, aBaths )
+ {
+ aBathShape->GetRange( aMin, aMax );
+
+ if( isFirst || aMin < aColorScaleMin )
+ aColorScaleMin = aMin;
+ if( isFirst || aMax > aColorScaleMax )
+ aColorScaleMax = aMax;
+
+ isFirst = false;
+ }
+
+ if( isDisplayColorScale )
+ {
+ Handle(Aspect_ColorScale) aColorScale = aView->ColorScale();
+ if( !aColorScale.IsNull() )
+ {
+ aColorScale->SetXPosition( anXPos );
+ aColorScale->SetYPosition( anYPos );
+ aColorScale->SetWidth( aWidth );
+ aColorScale->SetHeight( aHeight );
+
+ aColorScale->SetTextHeight( aTextHeight );
+ aColorScale->SetNumberOfIntervals( aNbIntervals );
+
+ aColorScale->SetTitle( aColorScaleTitle );
+ aColorScale->SetRange( aColorScaleMin, aColorScaleMax );
+
+ foreach( HYDROGUI_Shape* aBathShape, aBaths )
+ aBathShape->UpdateWithColorScale( aColorScale );
+ }
+ if( !aView->ColorScaleIsDisplayed() )
+ aView->ColorScaleDisplay();
+ }
+ else
+ {
+ if( aView->ColorScaleIsDisplayed() )
+ aView->ColorScaleErase();
}
-}
\ No newline at end of file
+}
*/
void purgeObjects( const int theViewerId );
+ void UpdateColorScale( const OCCViewer_Viewer* );
+
private:
/**
* \brief Creates new OCC shape.
#include <AIS_Drawer.hxx>
#include <AIS_TexturedShape.hxx>
-
+#include <AIS_PointCloud.hxx>
#include <V3d_Viewer.hxx>
#include <BRepBuilderAPI_MakeEdge.hxx>
#include <Graphic3d_AspectFillArea3d.hxx>
#include <Graphic3d_MaterialAspect.hxx>
+#include <Aspect_ColorScale.hxx>
+
#include <HYDROData_Channel.h>
#include <HYDROData_Document.h>
+#include <HYDROData_Bathymetry.h>
#include <HYDROData_DummyObject3D.h>
#include <HYDROData_Image.h>
#include <HYDROData_ImmersibleZone.h>
#include <Prs3d_ShadingAspect.hxx>
#include <Prs3d_LineAspect.hxx>
#include <Prs3d_IsoAspect.hxx>
-
+#include <Prs3d_PointAspect.hxx>
#include <SUIT_MessageBox.h>
#include <QColor>
setShape( aCompound, false, false );
}
+ else if ( myObject->IsKind( STANDARD_TYPE(HYDROData_Bathymetry) ) )
+ {
+ buildShape();
+ updateShape( false, false );
+ }
}
if ( myShape.IsNull() || !isVisible() )
myContext->SetZLayer( myShape, myZLayer );
}
+#include <NCollection_Sequence.hxx>
void HYDROGUI_Shape::buildShape()
{
// Erase previously created shape
erase();
- if ( myTopoShape.IsNull() ) {
+ Handle_HYDROData_Bathymetry aBath = Handle_HYDROData_Bathymetry::DownCast( myObject );
+ bool isBath = !aBath.IsNull();
+
+ if( !isBath && myTopoShape.IsNull() ) {
myShape.Nullify();
return;
}
QString aTextureFileName = getTextureFileName();
bool anIsTexture = !aTextureFileName.isEmpty();
-
if ( anIsTexture )
{
myShape = new AIS_TexturedShape( myTopoShape );
}
+ else if( isBath )
+ {
+ Handle_AIS_PointCloud aPntCloud = new AIS_PointCloud();
+ aPntCloud->Attributes()->SetPointAspect (new Prs3d_PointAspect (Aspect_TOM_POINT, Quantity_NOC_WHITE, 1.0));
+
+ myShape = aPntCloud;
+ const HYDROData_Bathymetry::AltitudePoints& aBathPoints = aBath->GetAltitudePoints();
+ int aLower = aBathPoints.Lower();
+ int anUpper = aBathPoints.Upper();
+ myCoords = new TColgp_HArray1OfPnt( aLower, anUpper );
+ myColors = new Quantity_HArray1OfColor( aLower, anUpper );
+ for( int i=aLower; i<=anUpper; i++ )
+ myCoords->SetValue( i, aBathPoints.Value( i ) );
+ }
else
{
myShape = new AIS_Shape( myTopoShape );
}
- myShape->SetHLRAngleAndDeviation( 0.001 );
+ Handle_AIS_Shape anAISShape = Handle_AIS_Shape::DownCast( myShape );
+ if( !anAISShape.IsNull() )
+ anAISShape ->SetHLRAngleAndDeviation( 0.001 );
if ( !myObject.IsNull() )
myShape->SetOwner( myObject );
getQuantityColorVal( theColor.green() ),
getQuantityColorVal( theColor.blue() ),
Quantity_TOC_RGB );
-
- if ( myTopoShape.ShapeType() == TopAbs_WIRE ) // Note that we display polylines in shaded mode
- {
- myShape->SetColor( aBorderColor );
- } else if ( myDisplayMode == AIS_Shaded )
+ if( !myTopoShape.IsNull() )
{
- if ( theColor.alpha() == 0 )
+ if ( myTopoShape.ShapeType() == TopAbs_WIRE ) // Note that we display polylines in shaded mode
{
- anAttributes->SetFaceBoundaryDraw( false );
+ myShape->SetColor( aBorderColor );
}
- else
+ else if ( myDisplayMode == AIS_Shaded )
{
- anAttributes->SetFaceBoundaryDraw( true );
-
- Handle(Prs3d_LineAspect) aBoundaryAspect = anAttributes->FaceBoundaryAspect();
- if ( !aBoundaryAspect.IsNull() )
+ if ( theColor.alpha() == 0 )
{
- aBoundaryAspect->SetColor( aBorderColor );
- anAttributes->SetFaceBoundaryAspect( aBoundaryAspect );
+ anAttributes->SetFaceBoundaryDraw( false );
}
- Handle(Prs3d_LineAspect) aWireAspect = anAttributes->WireAspect();
- if ( !aWireAspect.IsNull() )
+ else
{
- aWireAspect->SetColor( aBorderColor );
- anAttributes->SetWireAspect( aWireAspect );
+ anAttributes->SetFaceBoundaryDraw( true );
+
+ Handle(Prs3d_LineAspect) aBoundaryAspect = anAttributes->FaceBoundaryAspect();
+ if ( !aBoundaryAspect.IsNull() )
+ {
+ aBoundaryAspect->SetColor( aBorderColor );
+ anAttributes->SetFaceBoundaryAspect( aBoundaryAspect );
+ }
+ Handle(Prs3d_LineAspect) aWireAspect = anAttributes->WireAspect();
+ if ( !aWireAspect.IsNull() )
+ {
+ aWireAspect->SetColor( aBorderColor );
+ anAttributes->SetWireAspect( aWireAspect );
+ }
}
}
- }
- else if ( myDisplayMode == AIS_WireFrame )
- {
- myShape->SetColor( aBorderColor );
+ else if ( myDisplayMode == AIS_WireFrame )
+ {
+ myShape->SetColor( aBorderColor );
+ }
}
}
}
return theImage.scaled( aWidth, aHeight, Qt::KeepAspectRatio, Qt::SmoothTransformation );
}
+
+void HYDROGUI_Shape::GetRange( double& theMin, double& theMax ) const
+{
+ theMin = 0;
+ theMax = 0;
+ if( myCoords.IsNull() )
+ return;
+
+ bool isFirst = true;
+ for( int i=myCoords->Lower(), n=myCoords->Upper(); i<=n; i++ )
+ {
+ double aValue = myCoords->Value( i ).Z();
+ if( isFirst || aValue < theMin )
+ theMin = aValue;
+ if( isFirst || aValue > theMax )
+ theMax = aValue;
+ isFirst = false;
+ }
+}
+
+void HYDROGUI_Shape::UpdateWithColorScale( const Handle(Aspect_ColorScale)& theColorScale )
+{
+ for( int i=myCoords->Lower(), n=myCoords->Upper(); i<=n; i++ )
+ {
+ double z = myCoords->Value( i ).Z();
+ Quantity_Color aColor;
+ theColorScale->FindColor( z, aColor );
+ myColors->SetValue( i, aColor );
+ }
+ Handle_AIS_PointCloud aPntCloud = Handle_AIS_PointCloud::DownCast( myShape );
+ aPntCloud->SetPoints( myCoords, myColors );
+ myContext->Redisplay( aPntCloud, Standard_False );
+}
#define HYDROGUI_SHAPE_H
#include <AIS_InteractiveContext.hxx>
-#include <AIS_Shape.hxx>
+#include <AIS_InteractiveObject.hxx>
+#include <Aspect_ColorScale.hxx>
+#include <TColgp_HArray1OfPnt.hxx>
+#include <Quantity_HArray1OfColor.hxx>
#include <HYDROData_Entity.h>
const bool theIsUpdateViewer = true );
virtual QString getTextureFileName() const;
- virtual Handle(AIS_Shape) getAISShape() const { return myShape; }
+ virtual Handle(AIS_InteractiveObject) getAISObject() const { return myShape; }
void setZLayer( const int theZLayer );
+ void GetRange( double& theMin, double& theMax ) const;
+ void UpdateWithColorScale( const Handle(Aspect_ColorScale)& );
+
protected:
virtual void buildShape();
virtual void updateShape( const bool theToDisplay = true,
private:
Handle(AIS_InteractiveContext) myContext;
Handle(HYDROData_Entity) myObject;
- Handle(AIS_Shape) myShape;
+ Handle(AIS_InteractiveObject) myShape;
int myZLayer;
QColor myHighlightColor;
QString myTextureFileName;
+
+ Handle_TColgp_HArray1OfPnt myCoords;
+ Handle_Quantity_HArray1OfColor myColors;
};
#endif
}
else if ( anObject->GetKind() == KIND_BATHYMETRY && aVisibility )
{
- if ( !(anUpdateFlags & UF_VTKViewer) )
+ if ( anUpdateFlags & UF_OCCViewer )
+ {
+ aModule->setObjectVisible( aViewId, anObject, aVisibility );
+ }
+ else if ( !(anUpdateFlags & UF_VTKViewer) )
{
// Activate VTK viewer if show a bathymetry
aVTKMgr = aModule->getApp()->viewManager( SVTK_Viewer::Type() );
anObjectKind == KIND_STREAM ||
anObjectKind == KIND_CHANNEL ||
anObjectKind == KIND_DIGUE ||
- anObjectKind == KIND_DUMMY_3D
+ anObjectKind == KIND_DUMMY_3D ||
+ anObjectKind == KIND_BATHYMETRY
#ifdef DEB_GROUPS
|| anObjectKind == KIND_SHAPES_GROUP ||
anObjectKind == KIND_SPLITTED_GROUP
#include <HYDROData_Tool.h>
#include <SALOME_Actor.h>
-#include <gp_XYZ.hxx>
+#include <gp_Pnt.hxx>
#include <vtkDoubleArray.h>
#include <vtkPoints.h>
#include <vtkPolyData.h>