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) ) )
{
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;
}
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 );
}
}
if( isScalarMode != isLandCoverColoringOn )
{
aLandCoverMapShape->setScalarMapModeEnabled( isLandCoverColoringOn );
- theViewer->getAISContext()->Redisplay( aLandCoverMapShape->getAISObject() );
+ theViewer->getAISContext()->Redisplay( aLandCoverMapShape->getAISObjects()[0], Standard_False );
}
}
//
#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)
const Standard_Integer aMode)
{
//AIS_Shape::Compute(aPresentationManager, aPrs, aMode);
+ //return;
aPrs->Clear();
Handle(Graphic3d_Group) aGroup = Prs3d_Root::CurrentGroup( aPrs );
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 );
}
#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
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) ) ||
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;
}
HYDROGUI_Shape::~HYDROGUI_Shape()
{
erase( false );
-
- if ( !myShape.IsNull() )
- myShape.Nullify();
}
Handle(AIS_InteractiveContext) HYDROGUI_Shape::getContext() 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 );
void HYDROGUI_Shape::erase( const bool theIsUpdateViewer )
{
- if ( myContext.IsNull() || myShape.IsNull() )
+ if ( myContext.IsNull() || myShapes.empty() )
return;
eraseShape( theIsUpdateViewer );
}
}
- 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,
{
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 ) {
myIsHighlight = theIsHighlight;
- if ( myContext.IsNull() || myShape.IsNull() )
+ if ( myContext.IsNull() || myShapes.empty() )
return;
colorShapeBorder( getActiveColor() );
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();
}
}
- 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()
// 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 );
+ }
}
}
}
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;
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();
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
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 );
+ }
}
}
}
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,
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 );
private:
Handle(AIS_InteractiveContext) myContext;
Handle(HYDROData_Entity) myObject;
- Handle(AIS_InteractiveObject) myShape;
+ QList<Handle(AIS_InteractiveObject)> myShapes;
int myZLayer;
}
-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() );
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
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 );
}
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 );
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 );
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 );
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 );
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 );
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
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;
};
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();
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() )
{
}
}
}
- return aLandCoverMapPrs;
+ shapes.append( aLandCoverMapPrs );
}
- return NULL;
+ return shapes;
}
void HYDROGUI_ShapeLandCoverMap::display( const bool theIsUpdateViewer )
protected:
virtual void displayShape( const bool theIsUpdateViewer );
- virtual Handle(AIS_InteractiveObject) createShape() const;
+ virtual QList<Handle(AIS_InteractiveObject)> createShape() const;
private:
HYDROGUI_OCCDisplayer* myDisplayer;
}
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,
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)
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)
int theLinesToOmit,
QString& theMsg );
+ static void fitAll();
+
private:
static OCCViewer_ViewManager* myViewManager;
static OCCViewer_ViewWindow* myViewWindow;
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;
#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>
#include <QColor>
#include <QList>
#include <QPointF>
+#include <QTest>
#include <TestShape.h>
#include <TestViewer.h>
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()
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;