]> SALOME platform Git repositories - modules/hydro.git/commitdiff
Salome HOME
refs #1330: basic implementation of the not zoomable polyline arrows
authorasl <asl@opencascade.com>
Wed, 20 Sep 2017 14:01:08 +0000 (17:01 +0300)
committerasl <asl@opencascade.com>
Wed, 20 Sep 2017 14:01:08 +0000 (17:01 +0300)
19 files changed:
src/HYDROGUI/HYDROGUI_ImportLandCoverMapOp.cxx
src/HYDROGUI/HYDROGUI_OCCDisplayer.cxx
src/HYDROGUI/HYDROGUI_Polyline.cxx
src/HYDROGUI/HYDROGUI_Polyline.h
src/HYDROGUI/HYDROGUI_RecognizeContoursOp.cxx
src/HYDROGUI/HYDROGUI_Shape.cxx
src/HYDROGUI/HYDROGUI_Shape.h
src/HYDROGUI/HYDROGUI_ShapeBathymetry.cxx
src/HYDROGUI/HYDROGUI_ShapeBathymetry.h
src/HYDROGUI/HYDROGUI_ShapeImage.cxx
src/HYDROGUI/HYDROGUI_ShapeImage.h
src/HYDROGUI/HYDROGUI_ShapeLandCoverMap.cxx
src/HYDROGUI/HYDROGUI_ShapeLandCoverMap.h
src/HYDRO_tests/TestViewer.cxx
src/HYDRO_tests/TestViewer.h
src/HYDRO_tests/reference_data/Polyline_Presentation.png
src/HYDRO_tests/test_HYDROData_DTM.cxx
src/HYDRO_tests/test_HYDROData_PolylineXY.cxx
src/HYDRO_tests/test_HYDROGUI_Shape.cxx

index ecae18361cb619bea75232c9b8ada2d15f44852d..c4a5a0d5f851756953061a3ce8aad9cf2e8f28d3 100644 (file)
@@ -311,7 +311,7 @@ void HYDROGUI_ImportLandCoverMapOp::onSelectionChanged( const QStringList& theSe
     foreach ( QString aName, myPolygonName2PrsShape.keys() ) 
     {
       Handle(AIS_InteractiveObject) anObject = 
-        myPolygonName2PrsShape.value(aName)->getAISObject();
+        myPolygonName2PrsShape.value(aName)->getAISObjects()[0];
 
       bool isSelected = theSelectedNames.contains( aName );
       if ( ( isSelected && !aCtx->IsSelected( anObject) ) || ( !isSelected && aCtx->IsSelected( anObject) ) )
@@ -353,7 +353,7 @@ void HYDROGUI_ImportLandCoverMapOp::onViewerSelectionChanged()
   {
     QStringList aSelectedNames;
     foreach ( QString aName, myPolygonName2PrsShape.keys() ) {
-      bool isSelected = aCtx->IsSelected( myPolygonName2PrsShape.value(aName)->getAISObject() );
+      bool isSelected = aCtx->IsSelected( myPolygonName2PrsShape.value(aName)->getAISObjects()[0] );
       if ( isSelected )
         aSelectedNames << aName;
     }
index f0386a463fe7a568a55a7de8c01c6c1c8fdc0f50..d447abbe844546803c0a3fcaf3f0223c898cd524 100644 (file)
@@ -398,8 +398,11 @@ void HYDROGUI_OCCDisplayer::SetZLayer( const OCCViewer_Viewer* theViewer,
   HYDROGUI_Shape* anObjShape = module()->getObjectShape( aViewerId, theObject );
 
   // Set Z layer
-  if ( anObjShape ) {
-    aCtx->SetZLayer( anObjShape->getAISObject(), theZLayerId );
+  if ( anObjShape )
+  {
+    QList<Handle(AIS_InteractiveObject)> shapes = anObjShape->getAISObjects();
+    foreach( Handle(AIS_InteractiveObject) shape, shapes )
+      aCtx->SetZLayer( shape, theZLayerId );
   }
 }
 
@@ -517,7 +520,7 @@ void HYDROGUI_OCCDisplayer::UpdateColorScale( const OCCViewer_Viewer* theViewer
     if( isScalarMode != isLandCoverColoringOn )
     {
       aLandCoverMapShape->setScalarMapModeEnabled( isLandCoverColoringOn );
-      theViewer->getAISContext()->Redisplay( aLandCoverMapShape->getAISObject() );
+      theViewer->getAISContext()->Redisplay( aLandCoverMapShape->getAISObjects()[0], Standard_False );
     }
   }
   
index b9a7a2aacb62ab1c041395bc3438460992192639..e640f9a7e49baac19907c02404e7120c8128f0fa 100644 (file)
 //
 
 #include <HYDROGUI_Polyline.h>
-
-#include <AIS_InteractiveContext.hxx>
+#include <BRepAdaptor_Curve.hxx>
+#include <BRepBndLib.hxx>
 #include <BRep_Tool.hxx>
 #include <GCPnts_AbscissaPoint.hxx>
-#include <GeomAdaptor_Curve.hxx>
-#include <Graphic3d_AspectLine3d.hxx>
-#include <gp_Pnt.hxx>
-#include <gp_Dir.hxx>
+#include <GCPnts_QuasiUniformDeflection.hxx>
+#include <Graphic3d_ArrayOfPolylines.hxx>
 #include <Prs3d_Arrow.hxx>
-#include <TopExp.hxx>
-#include <TopoDS_Shape.hxx>
+#include <Prs3d_LineAspect.hxx>
+#include <Prs3d_Point.hxx>
+#include <Prs3d_Root.hxx>
 #include <TopExp.hxx>
 #include <TopExp_Explorer.hxx>
 #include <TopoDS.hxx>
 #include <TopoDS_Edge.hxx>
-#include <TopoDS_Shape.hxx>
 #include <TopoDS_Vertex.hxx>
-#include <BRepBndLib.hxx>
-#include <Precision.hxx>
-#include <Graphic3d_ArrayOfPolylines.hxx>
-#include <GCPnts_QuasiUniformDeflection.hxx>
-#include <BRepAdaptor_Curve.hxx>
-#include <Prs3d_LineAspect.hxx>
 
 IMPLEMENT_STANDARD_RTTIEXT(HYDROGUI_Polyline, AIS_Shape)
 
@@ -75,6 +67,7 @@ void HYDROGUI_Polyline::Compute(const Handle(PrsMgr_PresentationManager3d)& aPre
                             const Standard_Integer aMode)
 {  
   //AIS_Shape::Compute(aPresentationManager, aPrs, aMode);
+  //return;
 
   aPrs->Clear();
   Handle(Graphic3d_Group) aGroup = Prs3d_Root::CurrentGroup( aPrs );
@@ -106,79 +99,76 @@ void HYDROGUI_Polyline::Compute(const Handle(PrsMgr_PresentationManager3d)& aPre
       aGroup->AddPrimitiveArray( anArray );
     }
   }
+}
 
-   
-  TopExp_Explorer Exp ( myshape, TopAbs_EDGE );
-  for ( ; Exp.More(); Exp.Next() ) {
-    TopoDS_Vertex aV1, aV2;
+QList<Handle(AIS_InteractiveObject)> HYDROGUI_Polyline::createPresentations( const TopoDS_Shape& shape )
+{
+  QList<Handle(AIS_InteractiveObject)> shapes;
+
+  // 1. Main shape
+  shapes.append( new HYDROGUI_Polyline( shape ) );
+
+  // 2. Shapes for direction arrows on edges
+  TopExp_Explorer Exp ( shape, TopAbs_EDGE );
+  for ( ; Exp.More(); Exp.Next() )
+  {
     TopoDS_Edge anEdge = TopoDS::Edge(Exp.Current());
-    
-    if ( anEdge.IsNull() ) 
-      continue;
-    TopExp::Vertices(anEdge, aV1, aV2);
-    gp_Pnt aP = BRep_Tool::Pnt(aV1);
-    gp_Vec aDirVec;
-    double aFp, aLp;
-    Handle(Geom_Curve) C = BRep_Tool::Curve(anEdge,aFp,aLp);
-    if ( C.IsNull() ) 
-      continue;
-  
-    Bnd_Box aBB;
-    BRepBndLib::Add(anEdge, aBB);
-    Standard_Real aXmin,aYmin,aZmin,aXmax,aYmax,aZmax;
-    aBB.Get(aXmin,aYmin,aZmin,aXmax,aYmax,aZmax);
-    Standard_Real aLen = Max(Abs(aXmax - aXmin), Max (Abs(aZmax - aZmin), Abs(aYmax - aYmin)));
-  
-    GeomAdaptor_Curve aAdC;
-    aAdC.Load(C, aFp, aLp);
-    double aLenC;
-    double aLenH;
-    int aNbSegments = 20;
-    double aArrLen = aLen / 10.;
-    double anIncr = (aLp-aFp)/aNbSegments;
-    double aMaxRatio = 0;
-    double aMaxRatioStep = 1;
-    for (double t = aFp; t < aLp - anIncr; t += anIncr)
-    {
-       aLenC  = GCPnts_AbscissaPoint::Length(aAdC, t, t + anIncr);
-       aLenH = C->Value (t).Distance (C->Value (t + anIncr));
-       if ( aLenH / aLenC > aMaxRatio) {
-         aMaxRatio = aLenH / aLenC;
-         aMaxRatioStep = t;
-       }
-    }
+    if ( !anEdge.IsNull() ) 
+      shapes.append( new HYDROGUI_Arrow( anEdge ) );
+  }
 
-    bool UseD1 = false;
-    if (Abs(aMaxRatioStep) < Precision::Confusion())
-    {
-      aMaxRatioStep = (aLp - aFp)/2.0;
-      UseD1 = true;
-    }
+  return shapes;
+}
 
-    if (Abs(aLp - aMaxRatioStep) < Precision::Confusion())
-    {
-      aMaxRatioStep =  (aLp - aFp)/2.0;
-      UseD1 = true;
-    }      
-    
-    gp_Pnt aPnt1 = C->Value (aMaxRatioStep);
-    gp_Vec aDir;
-    if (!UseD1) 
-    {
-      GCPnts_AbscissaPoint aAbsPoint(aAdC, -aArrLen, aMaxRatioStep);
-      double aParam = aAbsPoint.Parameter();      
-      gp_Pnt aPnt2 = C->Value (aParam);
-      gp_XYZ D = aPnt1.XYZ();
-      D.Subtract (aPnt2.XYZ());
-      aDir = D;
-    }
 
-    if (UseD1 || aDir.IsEqual (gp_Vec(0,0,0), Precision::Confusion(), Precision::Angular()))
-      C->D1(aMaxRatioStep, aPnt1, aDir);
-  
-    if ( anEdge.Orientation() == TopAbs_REVERSED )
-      aDir = -aDir;
-  
-    Prs3d_Arrow::Draw(aPrs, aPnt1, aDir, M_PI/180.*12., aArrLen);     
-  }
+
+
+
+IMPLEMENT_STANDARD_RTTIEXT(HYDROGUI_Arrow, AIS_Shape)
+
+
+HYDROGUI_Arrow::HYDROGUI_Arrow( const TopoDS_Edge& edge )
+  : AIS_Shape( edge )
+{
+}
+
+HYDROGUI_Arrow::~HYDROGUI_Arrow()
+{
+}
+
+void HYDROGUI_Arrow::Compute( const Handle(PrsMgr_PresentationManager3d)& aPresentationManager,
+                                                     const Handle(Prs3d_Presentation)& aPrs,
+                                                     const Standard_Integer aMode )
+{
+  aPrs->Clear();
+
+  TopoDS_Edge anEdge = TopoDS::Edge( myshape );
+  if( anEdge.IsNull() )
+    return;
+
+  BRepAdaptor_Curve anAdaptor( anEdge );
+  double curveLen = GCPnts_AbscissaPoint::Length( anAdaptor, anAdaptor.FirstParameter(), anAdaptor.LastParameter() );
+  double arrowLen = qMin( curveLen/10, 35.0 );
+
+  double t = ( anAdaptor.FirstParameter() + anAdaptor.LastParameter() ) / 2;
+  gp_Pnt P;
+  gp_Vec V;
+  anAdaptor.D1( t, P, V );
+
+  gp_Trsf tr;
+  tr.SetTranslation( -gp_Vec( gp_Pnt(), P ) );
+  aPrs->SetTransformation( new Geom_Transformation( tr ) );
+
+  Handle(Graphic3d_TransformPers) tp = new Graphic3d_TransformPers( Graphic3d_TMF_ZoomPers, P );
+  SetTransformPersistence( tp );
+
+  Handle(Graphic3d_Group) aGroup = Prs3d_Root::CurrentGroup( aPrs );
+  Quantity_Color aColor;
+  Aspect_TypeOfLine aType;
+  Standard_Real anWidth;
+  Attributes()->LineAspect()->Aspect()->Values( aColor, aType, anWidth );
+  anWidth = 1;
+  Handle(Graphic3d_AspectLine3d) anAspect = new Graphic3d_AspectLine3d( aColor, aType, anWidth );
+  aGroup->SetPrimitivesAspect( anAspect );
+  Prs3d_Arrow::Draw( aGroup, gp_Pnt(), V, M_PI/180.*12., arrowLen );
 }
index 7b70a15fd1303197554c7cb40ce413d0a5f7849e..130dc8791408562bc5206de720a65e8bfc0f6c5a 100644 (file)
 #define _HYDROGUI_Polyline_HeaderFile
 
 #include <AIS_Shape.hxx>
-#include <AIS_InteractiveObject.hxx>
-
-#include <Standard.hxx>
-#include <Standard_DefineHandle.hxx>
-#include <PrsMgr_PresentationManager.hxx>
-#include <Prs3d_Presentation.hxx>
-#include <TCollection_AsciiString.hxx>
-#include <AIS_DisplayMode.hxx>
+#include <QList>
 
 class TopoDS_Shape;
+class TopoDS_Edge;
 
 class HYDROGUI_Polyline : public AIS_Shape
 {
 public:
-  
-  Standard_EXPORT HYDROGUI_Polyline(const TopoDS_Shape& shape);
-  Standard_EXPORT ~HYDROGUI_Polyline();
+  HYDROGUI_Polyline( const TopoDS_Shape& shape );
+  virtual ~HYDROGUI_Polyline();
 
-  Standard_EXPORT virtual void Compute(const Handle(PrsMgr_PresentationManager3d)& aPresentationManager,
+  virtual void Compute(const Handle(PrsMgr_PresentationManager3d)& aPresentationManager,
                                       const Handle(Prs3d_Presentation)& aPresentation,
                                       const Standard_Integer aMode = 0);
   
+  static QList<Handle(AIS_InteractiveObject)> createPresentations( const TopoDS_Shape& shape );
+
 public:
   DEFINE_STANDARD_RTTIEXT(HYDROGUI_Polyline, AIS_Shape);
 };
 
+class HYDROGUI_Arrow : public AIS_Shape
+{
+public:
+  HYDROGUI_Arrow( const TopoDS_Edge& edge );
+  virtual ~HYDROGUI_Arrow();
+
+  virtual void Compute( const Handle(PrsMgr_PresentationManager3d)& aPresentationManager,
+                                               const Handle(Prs3d_Presentation)& aPresentation,
+                                               const Standard_Integer aMode = 0 );
+  
+public:
+  DEFINE_STANDARD_RTTIEXT(HYDROGUI_Arrow, AIS_Shape);
+};
+
 #endif
index dfb279ffed474376c0fe8054dc05b783b8ed6105..20220731762f8d1c9c7587a5d1be40a6ef3108e5 100644 (file)
@@ -443,7 +443,7 @@ void HYDROGUI_RecognizeContoursOp::onSelectionChanged( const QStringList& theSel
   if ( !aCtx.IsNull() ) {
     foreach ( QString aName, myPolylineShapes.keys() ) {
       Handle(AIS_InteractiveObject) anObject = 
-        myPolylineShapes.value(aName)->getAISObject();
+        myPolylineShapes.value(aName)->getAISObjects()[0];
 
       bool isSelected = theSelectedNames.contains( aName );
       if ( ( isSelected && !aCtx->IsSelected( anObject) ) ||
@@ -481,7 +481,7 @@ void HYDROGUI_RecognizeContoursOp::onViewerSelectionChanged()
     QStringList aSelectedNames;
 
     foreach ( QString aName, myPolylineShapes.keys() ) {
-      bool isSelected = aCtx->IsSelected( myPolylineShapes.value(aName)->getAISObject() );
+      bool isSelected = aCtx->IsSelected( myPolylineShapes.value(aName)->getAISObjects()[0] );
       if ( isSelected ) {
         aSelectedNames << aName;
       }
index c34f2cc9522f4807a01529c4c8848175aa1fc626..8f271e54ff1bd599e0c826530571bf91984d86b2 100644 (file)
@@ -62,9 +62,6 @@ HYDROGUI_Shape::HYDROGUI_Shape( const Handle(AIS_InteractiveContext)& theContext
 HYDROGUI_Shape::~HYDROGUI_Shape()
 {
   erase( false );
-
-  if ( !myShape.IsNull() )
-    myShape.Nullify();
 }
 
 Handle(AIS_InteractiveContext) HYDROGUI_Shape::getContext() const
@@ -97,14 +94,14 @@ bool HYDROGUI_Shape::isVisible() const
   return myIsVisible;
 }
 
-Handle(AIS_InteractiveObject) HYDROGUI_Shape::getAISObject() const
+QList<Handle(AIS_InteractiveObject)> HYDROGUI_Shape::getAISObjects() const
 {
-  return myShape;
+  return myShapes;
 }
 
 void HYDROGUI_Shape::display( const bool theIsUpdateViewer )
 {
-  if ( myContext.IsNull() || myShape.IsNull() || !isVisible() )
+  if ( myContext.IsNull() || myShapes.empty() || !isVisible() )
     return;
 
   displayShape( theIsUpdateViewer );
@@ -112,7 +109,7 @@ void HYDROGUI_Shape::display( const bool theIsUpdateViewer )
 
 void HYDROGUI_Shape::erase( const bool theIsUpdateViewer )
 {
-  if ( myContext.IsNull() || myShape.IsNull() )
+  if ( myContext.IsNull() || myShapes.empty() )
     return;
 
   eraseShape( theIsUpdateViewer );
@@ -305,13 +302,14 @@ void HYDROGUI_Shape::update( bool isUpdateViewer,
     }
   }
  
-  if ( myShape.IsNull() || !isVisible() )
+  if ( myShapes.empty() || !isVisible() )
     return;
 
   displayShape( isUpdateViewer );
 
   if (isDeactivateSelection)
-    myContext->Deactivate(myShape);
+    foreach( Handle(AIS_InteractiveObject) aShape, myShapes )
+      myContext->Deactivate( aShape );
 }
 
 void HYDROGUI_Shape::setVisible( const bool theState,
@@ -319,11 +317,11 @@ void HYDROGUI_Shape::setVisible( const bool theState,
 {
   myIsVisible = theState;
 
-  if ( myShape.IsNull() )
+  if ( myShapes.empty() )
     return;
 
-  if ( ( myIsVisible && myContext->IsDisplayed( myShape ) ) ||
-       ( !myIsVisible && !myContext->IsDisplayed( myShape ) ) )
+  if ( ( myIsVisible && myContext->IsDisplayed( myShapes[0] ) ) ||
+       ( !myIsVisible && !myContext->IsDisplayed( myShapes[0] ) ) )
     return;
 
   if ( myIsVisible ) {
@@ -340,7 +338,7 @@ void HYDROGUI_Shape::highlight( bool theIsHighlight, bool isUpdateViewer )
 
   myIsHighlight = theIsHighlight;
 
-  if ( myContext.IsNull() || myShape.IsNull() )
+  if ( myContext.IsNull() || myShapes.empty() )
     return;
 
   colorShapeBorder( getActiveColor() );
@@ -476,14 +474,16 @@ void HYDROGUI_Shape::setZLayer( const int theZLayer )
     return;
 
   myZLayer = theZLayer;
-  if ( !myShape.IsNull() && isVisible() && !myContext.IsNull() && myZLayer >= 0 )
-    myContext->SetZLayer( myShape, myZLayer );
+  if( isVisible() && !myContext.IsNull() && myZLayer >= 0 )
+    foreach( Handle(AIS_InteractiveObject) aShape, myShapes )
+      myContext->SetZLayer( aShape, myZLayer );
 }
 
-Handle(AIS_InteractiveObject) HYDROGUI_Shape::createShape() const
+QList<Handle(AIS_InteractiveObject)> HYDROGUI_Shape::createShape() const
 {
+  QList<Handle(AIS_InteractiveObject)> shapes;
   if( myTopoShape.IsNull() ) {
-    return Handle(AIS_InteractiveObject)();
+    return shapes;
   }
 
   TopAbs_ShapeEnum aShapeType = myTopoShape.ShapeType();
@@ -497,11 +497,15 @@ Handle(AIS_InteractiveObject) HYDROGUI_Shape::createShape() const
     }
   }
 
-  if ( aShapeType==TopAbs_EDGE || aShapeType==TopAbs_WIRE || IsWireEdgeCompound) {
-    return new HYDROGUI_Polyline( myTopoShape );
-  } else {
-    return new HYDROGUI_AISShape( myTopoShape );
+  if ( aShapeType==TopAbs_EDGE || aShapeType==TopAbs_WIRE || IsWireEdgeCompound)
+  {
+    shapes.append( HYDROGUI_Polyline::createPresentations( myTopoShape ) );
+  }
+  else
+  {
+    shapes.append( new HYDROGUI_AISShape( myTopoShape ) );
   }
+  return shapes;
 }
 
 void HYDROGUI_Shape::buildShape()
@@ -509,45 +513,48 @@ void HYDROGUI_Shape::buildShape()
   // Erase previously created shape
   erase(false);
 
-  myShape = createShape();
-  if( myShape.IsNull() )
+  myShapes = createShape();
+  if( myShapes.empty() )
     return;
 
-  Handle(AIS_Shape) anAISShape = Handle(AIS_Shape)::DownCast( myShape );
-  if( !anAISShape.IsNull() )
-    anAISShape ->SetHLRAngleAndDeviation( 0.001 );
+  foreach( Handle(AIS_InteractiveObject) aShape, myShapes )
+  {
+    Handle(AIS_Shape) anAISShape = Handle(AIS_Shape)::DownCast( aShape );
+    if( !anAISShape.IsNull() )
+      anAISShape ->SetHLRAngleAndDeviation( 0.001 );
 
-  if ( !myObject.IsNull() )
-    myShape->SetOwner( myObject );
+    if ( !myObject.IsNull() )
+      aShape->SetOwner( myObject );
 
-  if ( !myObject.IsNull() && !myObject->IsKind( STANDARD_TYPE(HYDROData_LandCoverMap) ) )
-    myShape->SetTransparency( 0 );
-  myShape->SetDisplayMode( (AIS_DisplayMode)myDisplayMode );
+    if ( !myObject.IsNull() && !myObject->IsKind( STANDARD_TYPE(HYDROData_LandCoverMap) ) )
+      aShape->SetTransparency( 0 );
+    aShape->SetDisplayMode( (AIS_DisplayMode)myDisplayMode );
 
-  // Init default params for shape
-  const Handle(Prs3d_Drawer)& anAttributes = myShape->Attributes();
-  if ( !anAttributes.IsNull() )
-  {
-    Handle(Prs3d_IsoAspect) anIsoAspect = anAttributes->UIsoAspect();
-    if ( !anIsoAspect.IsNull() ) {
-      anIsoAspect->SetNumber( 0 );
-      anAttributes->SetUIsoAspect( anIsoAspect );
-    }
-      
-    anIsoAspect = anAttributes->VIsoAspect();
-    if ( !anIsoAspect.IsNull() )
+    // Init default params for shape
+    const Handle(Prs3d_Drawer)& anAttributes = aShape->Attributes();
+    if ( !anAttributes.IsNull() )
     {
-      anIsoAspect->SetNumber( 0 );
-      anAttributes->SetVIsoAspect( anIsoAspect );
-    }
+      Handle(Prs3d_IsoAspect) anIsoAspect = anAttributes->UIsoAspect();
+      if ( !anIsoAspect.IsNull() ) {
+        anIsoAspect->SetNumber( 0 );
+        anAttributes->SetUIsoAspect( anIsoAspect );
+      }
+      
+      anIsoAspect = anAttributes->VIsoAspect();
+      if ( !anIsoAspect.IsNull() )
+      {
+        anIsoAspect->SetNumber( 0 );
+        anAttributes->SetVIsoAspect( anIsoAspect );
+      }
 
-    if ( myDisplayMode == AIS_Shaded )
-    {
-      myShape->SetMaterial( Graphic3d_NOM_PLASTIC );
-    }
-    else if ( myDisplayMode == AIS_WireFrame )
-    {
-      anAttributes->SetWireDraw( true );
+      if ( myDisplayMode == AIS_Shaded )
+      {
+        aShape->SetMaterial( Graphic3d_NOM_PLASTIC );
+      }
+      else if ( myDisplayMode == AIS_WireFrame )
+      {
+        anAttributes->SetWireDraw( true );
+      }
     }
   }
 }
@@ -555,30 +562,30 @@ void HYDROGUI_Shape::buildShape()
 void HYDROGUI_Shape::updateShape( const bool theToDisplay,
                                   const bool theIsUpdateViewer )
 {
-  if ( myShape.IsNull() )
-    return;
-
-  const Handle(Prs3d_Drawer)& anAttributes = myShape->Attributes();
-  if ( !anAttributes.IsNull() )
+  foreach( Handle(AIS_InteractiveObject) aShape, myShapes )
   {
-    if ( myDisplayMode == AIS_Shaded && myFillingColor.isValid() )
-    {
-      Quantity_Color aFillingColor( getQuantityColorVal( myFillingColor.red() ), 
-                                    getQuantityColorVal( myFillingColor.green() ),
-                                    getQuantityColorVal( myFillingColor.blue() ),
-                                    Quantity_TOC_RGB );
-
-      myShape->SetColor( aFillingColor );
-      myShape->SetTransparency( 1 - getQuantityColorVal( myFillingColor.alpha() ) );
-    }
-    else if ( myDisplayMode == AIS_WireFrame )
+    const Handle(Prs3d_Drawer)& anAttributes = aShape->Attributes();
+    if ( !anAttributes.IsNull() )
     {
+      if ( myDisplayMode == AIS_Shaded && myFillingColor.isValid() )
+      {
+        Quantity_Color aFillingColor( getQuantityColorVal( myFillingColor.red() ), 
+                                      getQuantityColorVal( myFillingColor.green() ),
+                                      getQuantityColorVal( myFillingColor.blue() ),
+                                      Quantity_TOC_RGB );
+  
+        aShape->SetColor( aFillingColor );
+        aShape->SetTransparency( 1 - getQuantityColorVal( myFillingColor.alpha() ) );
+      }
+      else if ( myDisplayMode == AIS_WireFrame )
+      {
+      }
+  
+      // Coloring borders
     }
-
-    // Coloring borders
-    colorShapeBorder( myBorderColor );
   }
-
+  
+  colorShapeBorder( myBorderColor );
   if ( !theToDisplay || !isVisible() || myContext.IsNull() )
     return;
   
@@ -590,27 +597,34 @@ void HYDROGUI_Shape::displayShape( const bool theIsUpdateViewer )
   if ( myContext->HasOpenedContext() && mySelectionMode > 0 )
     myContext->CloseLocalContext();
 
-  if ( mySelectionMode > 0 )
-    // Display object in local context with selection
-    myContext->Display( myShape, myDisplayMode, mySelectionMode, Standard_False, Standard_False );
-  else
+  foreach( Handle(AIS_InteractiveObject) aShape, myShapes )
   {
-    if ( !myContext->HasOpenedContext() )
-      // Ordinary display of object published in the Object Browser
-      myContext->Display( myShape, Standard_False );
+    if ( mySelectionMode > 0 )
+      // Display object in local context with selection
+      myContext->Display( aShape, myDisplayMode, mySelectionMode, Standard_False, Standard_False );
     else
-      // Display object in local context without selection
-      myContext->Display( myShape, myDisplayMode, -1, Standard_False, Standard_False );
+    {
+      if ( !myContext->HasOpenedContext() )
+        // Ordinary display of object published in the Object Browser
+        myContext->Display( aShape, Standard_False );
+      else
+        // Display object in local context without selection
+        myContext->Display( aShape, myDisplayMode, -1, Standard_False, Standard_False );
+    }
   }
   
   if ( mySelectionMode > 0 )
   {
     myContext->OpenLocalContext();
-    myContext->Activate( myShape, mySelectionMode, Standard_True );
+    foreach( Handle(AIS_InteractiveObject) aShape, myShapes )
+      myContext->Activate( aShape, mySelectionMode, Standard_True );
   }
 
   if ( myZLayer >= 0 )
-    myContext->SetZLayer( myShape, myZLayer );
+  {
+    foreach( Handle(AIS_InteractiveObject) aShape, myShapes )
+      myContext->SetZLayer( aShape, myZLayer );
+  }
 
   if ( theIsUpdateViewer ) {
     myContext->UpdateCurrentViewer();
@@ -622,7 +636,11 @@ void HYDROGUI_Shape::eraseShape( const bool theIsUpdateViewer )
   if ( myContext->HasOpenedContext() && mySelectionMode > 0 )
     myContext->CloseLocalContext();
 
-  myContext->Erase( myShape, theIsUpdateViewer );
+  foreach( Handle(AIS_InteractiveObject) aShape, myShapes )
+    myContext->Erase( aShape, Standard_False );
+
+  if( theIsUpdateViewer )
+    myContext->UpdateCurrentViewer();
 }
 
 QColor HYDROGUI_Shape::getActiveColor() const
@@ -637,33 +655,33 @@ double HYDROGUI_Shape::getQuantityColorVal( const int theColorVal )
 
 void HYDROGUI_Shape::colorShapeBorder( const QColor& theColor )
 {
-  if ( myShape.IsNull() )
-    return;
-
-  const Handle(Prs3d_Drawer)& anAttributes = myShape->Attributes();
-  if ( anAttributes.IsNull() )
-    return;
+  foreach( Handle(AIS_InteractiveObject) aShape1, myShapes )
+  {
+    const Handle(Prs3d_Drawer)& anAttributes = aShape1->Attributes();
+    if ( anAttributes.IsNull() )
+      continue;
 
-  Quantity_Color aBorderColor( getQuantityColorVal( theColor.red() ), 
-                               getQuantityColorVal( theColor.green() ),
-                               getQuantityColorVal( theColor.blue() ),
-                               Quantity_TOC_RGB );
+    Quantity_Color aBorderColor( getQuantityColorVal( theColor.red() ), 
+                                 getQuantityColorVal( theColor.green() ),
+                                 getQuantityColorVal( theColor.blue() ),
+                                 Quantity_TOC_RGB );
   
-  if( !myTopoShape.IsNull() )
-  {
-    if ( myTopoShape.ShapeType() == TopAbs_WIRE ) // Note that we display polylines in shaded mode
-    {
-      myShape->SetColor( aBorderColor );
-    }
-    else if ( myDisplayMode == AIS_Shaded )
+    if( !myTopoShape.IsNull() )
     {
-      Handle(HYDROGUI_AISShape) aShape = Handle(HYDROGUI_AISShape)::DownCast( myShape );
-      if( !aShape.IsNull() )
-        aShape->SetBorderColor( aBorderColor );
-    }
-    else if ( myDisplayMode == AIS_WireFrame )
-    {
-      myShape->SetColor( aBorderColor );
+      if ( myTopoShape.ShapeType() == TopAbs_WIRE ) // Note that we display polylines in shaded mode
+      {
+        aShape1->SetColor( aBorderColor );
+      }
+      else if ( myDisplayMode == AIS_Shaded )
+      {
+        Handle(HYDROGUI_AISShape) aShape = Handle(HYDROGUI_AISShape)::DownCast( aShape1 );
+        if( !aShape.IsNull() )
+          aShape->SetBorderColor( aBorderColor );
+      }
+      else if ( myDisplayMode == AIS_WireFrame )
+      {
+        aShape1->SetColor( aBorderColor );
+      }
     }
   }
 }
index 76113ba1a6da1ebbb494b68ccdc77ebb17b42d95..76b002ca1741b2d95a0344a2adab5f8212cfcee2 100644 (file)
@@ -95,12 +95,11 @@ public:
   virtual void               setHighlightColor( const QColor& theColor );
   virtual QColor             getHighlightColor() const;
 
-  virtual Handle(AIS_InteractiveObject)  getAISObject() const;
-
   void                       setZLayer( const int theZLayer );
-
   void                       setSelectionMode( int theSelectionMode );
 
+  QList<Handle(AIS_InteractiveObject)> getAISObjects() const;
+
 protected:
   virtual void               buildShape();
   virtual void               updateShape( const bool theToDisplay      = true,
@@ -109,7 +108,7 @@ protected:
   virtual void               eraseShape( const bool theIsUpdateViewer );
 
   virtual QColor             getActiveColor() const;
-  virtual Handle(AIS_InteractiveObject) createShape() const;
+  virtual QList<Handle(AIS_InteractiveObject)> createShape() const;
 
   void setDisplayMode( int theDisplayMode );
 
@@ -120,7 +119,7 @@ private:
 private:
   Handle(AIS_InteractiveContext) myContext;
   Handle(HYDROData_Entity)       myObject;
-  Handle(AIS_InteractiveObject)  myShape;
+  QList<Handle(AIS_InteractiveObject)>  myShapes;
 
   int                            myZLayer;
 
index a88b5069923989e42e06f4bcf2ef403b7ef4b692..3a72a138893dc1707e32925cd620335dedcaa9c8 100644 (file)
@@ -58,8 +58,10 @@ void HYDROGUI_ShapeBathymetry::update( bool theIsUpdateViewer, bool isDeactivate
 }
 
 
-Handle(AIS_InteractiveObject) HYDROGUI_ShapeBathymetry::createShape() const
+QList<Handle(AIS_InteractiveObject)> HYDROGUI_ShapeBathymetry::createShape() const
 {
+  QList<Handle(AIS_InteractiveObject)> shapes;
+
   Handle(AIS_InteractiveObject) aPntCloud;
 
   Handle(HYDROData_Bathymetry) aBath = Handle(HYDROData_Bathymetry)::DownCast( getObject() );
@@ -78,9 +80,11 @@ Handle(AIS_InteractiveObject) HYDROGUI_ShapeBathymetry::createShape() const
     aThat->myColors = new Quantity_HArray1OfColor( aLower, anUpper );
     for( int i=aLower; i<=anUpper; i++ )
       aThat->myCoords->SetValue( i, gp_Pnt( aBathPoints[i].X, aBathPoints[i].Y, aBathPoints[i].Z ) );
+
+    shapes.append( aPntCloud );
   }
 
-  return aPntCloud;
+  return shapes;
 }
 
 void HYDROGUI_ShapeBathymetry::GetRange( double& theMin, double& theMax ) const
@@ -113,7 +117,7 @@ void HYDROGUI_ShapeBathymetry::UpdateWithColorScale( const Handle(AIS_ColorScale
     theColorScale->FindColor( z, aColor );
     myColors->SetValue( i, aColor );
   }
-  Handle(AIS_PointCloud) aPntCloud = Handle(AIS_PointCloud)::DownCast( getAISObject() );
+  Handle(AIS_PointCloud) aPntCloud = Handle(AIS_PointCloud)::DownCast( getAISObjects()[0] );
   aPntCloud->SetPoints( myCoords, myColors );
   getContext()->Redisplay( aPntCloud, Standard_False );
 }
@@ -121,7 +125,7 @@ void HYDROGUI_ShapeBathymetry::UpdateWithColorScale( const Handle(AIS_ColorScale
 void HYDROGUI_ShapeBathymetry::setVisible( const bool theState,
                                            const bool theIsUpdateViewer )
 {
-  bool isShown = getContext()->IsDisplayed( getAISObject() );
+  bool isShown = getContext()->IsDisplayed( getAISObjects()[0] );
   bool isChanged = ( isShown != theState );
   HYDROGUI_Shape::setVisible( theState, theIsUpdateViewer );
   setToUpdateColorScale( isChanged );
@@ -129,7 +133,7 @@ void HYDROGUI_ShapeBathymetry::setVisible( const bool theState,
 
 void HYDROGUI_ShapeBathymetry::displayShape( const bool theIsUpdateViewer )
 {
-  bool isShown = getContext()->IsDisplayed( getAISObject() );
+  bool isShown = getContext()->IsDisplayed( getAISObjects()[0] );
   bool isChanged = ( !isShown  );
   HYDROGUI_Shape::displayShape( theIsUpdateViewer );
   setToUpdateColorScale( isChanged );
@@ -137,7 +141,7 @@ void HYDROGUI_ShapeBathymetry::displayShape( const bool theIsUpdateViewer )
 
 void HYDROGUI_ShapeBathymetry::display( const bool theIsUpdateViewer )
 {
-  bool isShown = getContext()->IsDisplayed( getAISObject() );
+  bool isShown = getContext()->IsDisplayed( getAISObjects()[0] );
   bool isChanged = ( !isShown  );
   HYDROGUI_Shape::display( theIsUpdateViewer );
   setToUpdateColorScale( isChanged );
@@ -145,7 +149,7 @@ void HYDROGUI_ShapeBathymetry::display( const bool theIsUpdateViewer )
 
 void HYDROGUI_ShapeBathymetry::erase( const bool theIsUpdateViewer )
 {
-  bool isShown = getContext()->IsDisplayed( getAISObject() );
+  bool isShown = getContext()->IsDisplayed( getAISObjects()[0] );
   bool isChanged = ( isShown  );
   HYDROGUI_Shape::erase( theIsUpdateViewer );
   setToUpdateColorScale( isChanged );
index c736c60fd1765b072cf1a489a1a9e32b9ec0b7da..91a0a7729b46bc70dbaf32d941e5d0ee342d775b 100644 (file)
@@ -48,7 +48,7 @@ public:
   virtual void               setVisible( const bool theState,
                                          const bool theIsUpdateViewer = true );
 protected:
-  virtual Handle(AIS_InteractiveObject) createShape() const;
+  virtual QList<Handle(AIS_InteractiveObject)> createShape() const;
   virtual void displayShape( const bool theIsUpdateViewer );
 
   void setToUpdateColorScale( bool isChanged );
index 4f832399d26895271f03bb09d14b9c3469372d0e..d57f726dac12cf044c2699d731436a6d89e14984 100644 (file)
@@ -46,17 +46,20 @@ void HYDROGUI_ShapeImage::update( bool theIsUpdateViewer, bool isDeactivateSelec
   HYDROGUI_Shape::update( theIsUpdateViewer, isDeactivateSelection );
 }
 
-Handle(AIS_InteractiveObject) HYDROGUI_ShapeImage::createShape() const
+QList<Handle(AIS_InteractiveObject)> HYDROGUI_ShapeImage::createShape() const
 {
+  QList<Handle(AIS_InteractiveObject)> shapes;
+
   Handle(HYDROGUI_ImagePrs) aPrs;
 
   Handle(HYDROData_Image) anImageObj = Handle(HYDROData_Image)::DownCast( getObject() );
   if ( !anImageObj.IsNull() )
   {
     aPrs = new HYDROGUI_ImagePrs( imagePixMap( anImageObj ), imageContour( anImageObj ) );
+    shapes.append( aPrs );
   }
 
-  return aPrs;
+  return shapes;
 }
 
 Handle(Image_PixMap) HYDROGUI_ShapeImage::imagePixMap( const Handle(HYDROData_Image)& theImageObj ) const
index aba5b82b4b2d45516f9fb8dcb547fb18abebc514..17c6dec0437a70a99bf2d0af6058d0f5c15a334b 100644 (file)
@@ -36,7 +36,7 @@ public:
   virtual void                         update( bool isUpdateViewer, bool isDeactivateSelection );
 
 protected:
-  virtual Handle(AIS_InteractiveObject) createShape() const;
+  virtual QList<Handle(AIS_InteractiveObject)> createShape() const;
   Handle(Image_PixMap)                  imagePixMap( const Handle(HYDROData_Image)& ) const;
   QPolygonF                             imageContour( const Handle(HYDROData_Image)& ) const;
 };
index 3446545e3db4973a5ed49219077f8079eaa82aa3..66e56301c5ae14eaaaacca2fab8a15bd25b1940e 100644 (file)
@@ -60,7 +60,8 @@ void HYDROGUI_ShapeLandCoverMap::update( bool theIsUpdateViewer, bool isDeactiva
     setShape( aLandCoverMapShape, false, false );
   }
 
-  Handle(HYDROGUI_LandCoverMapPrs) aLandCoverMapPrs = Handle(HYDROGUI_LandCoverMapPrs)::DownCast( getAISObject() );
+  Handle(HYDROGUI_LandCoverMapPrs) aLandCoverMapPrs = 
+    Handle(HYDROGUI_LandCoverMapPrs)::DownCast( getAISObjects()[0] );
   if ( !aLandCoverMapPrs.IsNull() )
     aLandCoverMapPrs->UpdateColors();
 
@@ -91,8 +92,10 @@ void HYDROGUI_ShapeLandCoverMap::displayShape( const bool theIsUpdateViewer )
   myDisplayer->SetToUpdateColorScale();
 }
 
-Handle(AIS_InteractiveObject) HYDROGUI_ShapeLandCoverMap::createShape() const
+QList<Handle(AIS_InteractiveObject)> HYDROGUI_ShapeLandCoverMap::createShape() const
 {
+  QList<Handle(AIS_InteractiveObject)> shapes;
+
   Handle(HYDROData_LandCoverMap) aLandCoverMap = Handle(HYDROData_LandCoverMap)::DownCast( getObject() );
   if ( !aLandCoverMap.IsNull() )
   {
@@ -119,9 +122,9 @@ Handle(AIS_InteractiveObject) HYDROGUI_ShapeLandCoverMap::createShape() const
         }
       }
     }
-    return aLandCoverMapPrs;
+    shapes.append( aLandCoverMapPrs );
   }
-  return NULL;
+  return shapes;
 }
 
 void HYDROGUI_ShapeLandCoverMap::display( const bool theIsUpdateViewer )
index 526c52e59ce03d97a4e8d4040842bb1690368a80..a030a370ecfaa29b41550aa0f318722c353c12aa 100644 (file)
@@ -54,7 +54,7 @@ public:
 
 protected:
   virtual void              displayShape( const bool theIsUpdateViewer );
-  virtual Handle(AIS_InteractiveObject) createShape() const;
+  virtual QList<Handle(AIS_InteractiveObject)> createShape() const;
 
 private:
   HYDROGUI_OCCDisplayer*           myDisplayer;
index 5ef6d2d9529afa0b6042d491bb0535c1eebb8232..71cd941b27ab2e332f21742e5f9e3dcc75818aab 100644 (file)
@@ -142,10 +142,13 @@ void TestViewer::show( const Handle(AIS_InteractiveObject)& theObject,
   }
 
   if( isFitAll )
-  {
-    viewWindow()->onTopView();
-    viewWindow()->onFitAll();
-  }
+    fitAll();
+}
+
+void TestViewer::fitAll()
+{
+  viewWindow()->onTopView();
+  viewWindow()->onFitAll();
 }
 
 void TestViewer::show( const TopoDS_Shape& theShape, int theMode, bool isFitAll, const QColor& theColor,
@@ -167,10 +170,7 @@ void TestViewer::show( const TopoDS_Shape& theShape, int theMode, bool isFitAll,
   context()->Display( aShape, theMode, 0, Standard_False );
 
   if( isFitAll )
-  {
-    viewWindow()->onTopView();
-    viewWindow()->onFitAll();
-  }
+    fitAll();
 }
 void TestViewer::show( const TopoDS_Shape& theShape, int theMode, bool isFitAll, const char* theKey,
                        int theUIANb, int theVIANb)
@@ -217,10 +217,7 @@ void TestViewer::show( const TopoDS_Shape& theShape, int theMode, bool isFitAll,
     show( aLE.Value(), theMode, false, GetColor(i) );
 
   if( isFitAll )
-  {
-    viewWindow()->onTopView();
-    viewWindow()->onFitAll();
-  }
+    fitAll();
 }
 
 /*void TestViewer::ShowShape(const TopoDS_Shape& theShape, int theMode, int& i)
index 90aac8407416c022026ab94f02608623e11edf2b..8a0db3c9d00e5edec952a11c29aae25c3323aa24 100644 (file)
@@ -60,6 +60,8 @@ public:
                                int theLinesToOmit,
                                QString& theMsg );
 
+  static void fitAll();
+
 private:
   static OCCViewer_ViewManager* myViewManager;
   static OCCViewer_ViewWindow* myViewWindow;
index 1a4f14fdff8e0e089bbb72736205a6e533a3f08b..0e9f0134bf46ea364e08f74c07b031cef2395a8d 100644 (file)
Binary files a/src/HYDRO_tests/reference_data/Polyline_Presentation.png and b/src/HYDRO_tests/reference_data/Polyline_Presentation.png differ
index d433872248c39cf96cbb268c618ba61b5e856ef6..9c06cc7e1fa22078972f99e30f6d2337a0d91427 100644 (file)
@@ -48,7 +48,7 @@ class DTM_item : public QGraphicsItem
 public:
   DTM_item( HYDROGUI_ShapeBathymetry* theDTM, double d )
   {
-    Handle(AIS_PointCloud) pc = Handle(AIS_PointCloud)::DownCast( theDTM->getAISObject() );
+    Handle(AIS_PointCloud) pc = Handle(AIS_PointCloud)::DownCast( theDTM->getAISObjects()[0] );
     Handle(Graphic3d_ArrayOfPoints) pp = pc->GetPoints();
     myBB = QRectF();
     double xmin, xmax, ymin, ymax;
index 57d6435fcfd3cc192ab2167e50cea74e5cf22722..b3af935f64ed9b79cc50d5d56da586bffc6f44e3 100644 (file)
@@ -27,7 +27,7 @@
 #include <HYDROData_Iterator.h>
 #include <HYDROData_ImmersibleZone.h>
 #include <HYDROData_Tool.h>
-#include <HYDROGUI_Polyline.h>
+#include <HYDROGUI_Shape.h>
 
 #include <AIS_DisplayMode.hxx>
 #include <AIS_PointCloud.hxx>
@@ -37,6 +37,7 @@
 #include <QColor>
 #include <QList>
 #include <QPointF>
+#include <QTest>
 
 #include <TestShape.h>
 #include <TestViewer.h>
@@ -253,15 +254,19 @@ void test_HYDROData_PolylineXY::test_presentation()
   aPointsPrs->SetColor( Quantity_NOC_BLUE1 );
   aPointsPrs->Attributes()->PointAspect()->SetTypeOfMarker( Aspect_TOM_O );
 
-  Handle(HYDROGUI_Polyline) aNewPolylinePrs = new HYDROGUI_Polyline( aPolyline2d->GetShape() );
-  aNewPolylinePrs->SetColor( Quantity_NOC_DARKGREEN );
+  aPolyline2d->SetWireColor( Qt::darkGreen );
+  HYDROGUI_Shape* aNewPolylinePrs = new HYDROGUI_Shape( TestViewer::context(), aPolyline2d );
+  aNewPolylinePrs->update( true, true );
 
   TestViewer::show( aPointsPrs, AIS_PointCloud::DM_Points, 0, true, "Polyline_Presentation" );
   TestViewer::show( aPolyline2d->GetShape(), 0, true, Qt::red );
-  TestViewer::show( aNewPolylinePrs, AIS_PointCloud::DM_Points, 0, true, "" );
+  //TestViewer::show( aNewPolylinePrs, AIS_PointCloud::DM_Points, 0, true, "" );
+  aNewPolylinePrs->display();
+  TestViewer::fitAll();
   CPPUNIT_ASSERT_IMAGES
 
   aDoc->Close();
+  //QTest::qWait( 50000 );
 }
 
 void test_HYDROData_PolylineXY::test_split_refs_627()
index ee5ca41f6d53f94d05117f187b19959ec67ee1b4..30b2d776b1ff55d36086850c912d5527f81d444d 100644 (file)
@@ -39,7 +39,7 @@ void test_HYDROGUI_Shape::test_face_in_preview()
   aPreview->setFillingColor( Qt::red, false, false );
   aPreview->setBorderColor( Qt::darkBlue, false, false );
   
-  TestViewer::show( aPreview->getAISObject(), AIS_Shaded, 0, true, "Shape_preview_im_zone" );
+  TestViewer::show( aPreview->getAISObjects()[0], AIS_Shaded, 0, true, "Shape_preview_im_zone" );
   CPPUNIT_ASSERT_IMAGES
 
   delete aPreview;