From: aba Date: Fri, 25 Jan 2013 14:11:16 +0000 (+0400) Subject: 0023663: Removing 2D viewer library X-Git-Tag: V6_6_0_beta~110 X-Git-Url: http://git.dev.opencascade.org/gitweb/?p=occt.git;a=commitdiff_plain;h=128cc8df34de9065f1739503feb3581b00a0a7dd 0023663: Removing 2D viewer library Deleted TKV2d toolkit and CGM, MFT,FontMFT, PlotMgt, PS packages. Deleted 2d test cases. Deleted WNT_WDriver and Xw_Driver, edited Aspect_Driver. Deleted trailing spaces, removed WNT_FontMapEntry, WNT_FontTable, WNT_HFontTable Deleting tests for 2D viewer --- diff --git a/adm/UDLIST b/adm/UDLIST index cc72240f8c..e55a28e35f 100644 --- a/adm/UDLIST +++ b/adm/UDLIST @@ -208,33 +208,23 @@ t TKTopAlgo t TKXMesh n InterfaceGraphic p AIS -p AIS2D p AlienImage p Aspect -p CGM p DsgPrs -p GGraphic2d -p Graphic2d p Graphic3d p Image p ImageUtility -p MFT p MeshVS p NIS p OpenGl -p PS -p PlotMgt -p Prs2d p Prs3d p PrsMgr -p Select2D p Select3D p SelectBasics p SelectMgr p StdPrs p StdSelect p TColQuantity -p V2d p V3d p Viewer p Visual3d @@ -242,13 +232,11 @@ p Voxel p WNT p Xw p Cocoa -r FontMFT r Textures t TKMeshVS t TKNIS t TKOpenGl t TKService -t TKV2d t TKV3d t TKVoxel n BinTObjDrivers @@ -475,7 +463,6 @@ p TObjDRAW p TestTopOpe p TestTopOpeDraw p TestTopOpeTools -p Viewer2dTest p ViewerTest p XDEDRAW p XSDRAW @@ -497,7 +484,6 @@ p QANCollection p QANewBRepNaming p QANewDBRepNaming p QANewModTopOpe -p QAViewer2dTest r QAResources t TKQADraw p QADNaming diff --git a/src/AIS/AIS.cdl b/src/AIS/AIS.cdl index 63fbf91185..b52fe7b230 100755 --- a/src/AIS/AIS.cdl +++ b/src/AIS/AIS.cdl @@ -141,7 +141,6 @@ uses Geom, Bnd, Aspect, - Graphic2d, Graphic3d, V3d, TopAbs, diff --git a/src/AIS/AIS_AngleDimension.cdl b/src/AIS/AIS_AngleDimension.cdl index 69d4b445fc..c0be9ef6fd 100755 --- a/src/AIS/AIS_AngleDimension.cdl +++ b/src/AIS/AIS_AngleDimension.cdl @@ -39,9 +39,7 @@ uses Shape from TopoDS, Line from Geom, Ax1 from gp, Projector from Prs3d, - Transformation from Geom, - PresentationManager2d from PrsMgr, - GraphicObject from Graphic2d, + Transformation from Geom, Plane from Geom, Surface from Geom, ExtendedString from TCollection, @@ -191,12 +189,6 @@ is aPresentation: mutable Presentation from Prs3d) is redefined static private; - Compute(me:mutable; - aPresentationManager: PresentationManager2d from PrsMgr; - aPresentation: mutable GraphicObject from Graphic2d; - aMode: Integer from Standard = 0) - is redefined static private; - Compute(me : mutable; aProjector : Projector from Prs3d; aTrsf : Transformation from Geom; diff --git a/src/AIS/AIS_AngleDimension.cxx b/src/AIS/AIS_AngleDimension.cxx index 85590f71a8..9736e2c597 100755 --- a/src/AIS/AIS_AngleDimension.cxx +++ b/src/AIS/AIS_AngleDimension.cxx @@ -472,19 +472,6 @@ void AIS_AngleDimension::Compute(const Handle(Prs3d_Projector)& aProjector, PrsMgr_PresentableObject::Compute( aProjector , aPresentation ) ; } -//======================================================================= -//function : Compute -//purpose : : to avoid warning -//======================================================================= - -void AIS_AngleDimension::Compute(const Handle(PrsMgr_PresentationManager2d)& aPresentationManager2d, - const Handle(Graphic2d_GraphicObject)& aGraphicObject, - const Standard_Integer anInteger) -{ -// Standard_NotImplemented::Raise("AIS_AngleDimension::Compute(const Handle(PrsMgr_PresentationManager2d)&,const Handle(Graphic2d_GraphicObject)&,const Standard_Integer)"); - PrsMgr_PresentableObject::Compute( aPresentationManager2d ,aGraphicObject,anInteger) ; -} - void AIS_AngleDimension::Compute(const Handle_Prs3d_Projector& aProjector, const Handle_Geom_Transformation& aTransformation, const Handle_Prs3d_Presentation& aPresentation) { // Standard_NotImplemented::Raise("AIS_AngleDimension::Compute(const Handle_Prs3d_Projector&, const Handle_Geom_Transformation&, const Handle_Prs3d_Presentation&)"); diff --git a/src/AIS/AIS_Axis.cdl b/src/AIS/AIS_Axis.cdl index f7590d78a3..87758c39d8 100755 --- a/src/AIS/AIS_Axis.cdl +++ b/src/AIS/AIS_Axis.cdl @@ -39,8 +39,6 @@ uses Selection from SelectMgr, Projector from Prs3d, Transformation from Geom, - PresentationManager2d from PrsMgr, - GraphicObject from Graphic2d, Pnt from gp, Dir from gp, LineAspect from Prs3d, @@ -134,13 +132,7 @@ is Compute(me:mutable; aProjector: Projector from Prs3d; aPresentation: mutable Presentation from Prs3d) - is redefined static private; - - Compute(me:mutable; - aPresentationManager: PresentationManager2d from PrsMgr; - aPresentation: mutable GraphicObject from Graphic2d; - aMode: Integer from Standard = 0) - is redefined static private; + is redefined static private; Compute(me : mutable; aProjector : Projector from Prs3d; diff --git a/src/AIS/AIS_Axis.cxx b/src/AIS/AIS_Axis.cxx index d6a98f38e0..55c00c2fe7 100755 --- a/src/AIS/AIS_Axis.cxx +++ b/src/AIS/AIS_Axis.cxx @@ -248,16 +248,6 @@ void AIS_Axis::SetWidth(const Standard_Real aValue) } -//======================================================================= -//function : Compute -//purpose : to avoid warning -//======================================================================= -void AIS_Axis::Compute(const Handle(PrsMgr_PresentationManager2d)&, - const Handle(Graphic2d_GraphicObject)&, - const Standard_Integer) -{ -} - //======================================================================= //function : Compute //purpose : to avoid warning diff --git a/src/AIS/AIS_Chamf2dDimension.cdl b/src/AIS/AIS_Chamf2dDimension.cdl index e9e2f20e85..f7b0b16c64 100755 --- a/src/AIS/AIS_Chamf2dDimension.cdl +++ b/src/AIS/AIS_Chamf2dDimension.cdl @@ -39,8 +39,6 @@ uses Dir from gp, Projector from Prs3d, Transformation from Geom, - PresentationManager2d from PrsMgr, - GraphicObject from Graphic2d, ExtendedString from TCollection, ArrowSide from DsgPrs, KindOfDimension from AIS @@ -94,12 +92,6 @@ is aPresentation: mutable Presentation from Prs3d) is redefined static private; - Compute(me:mutable; - aPresentationManager: PresentationManager2d from PrsMgr; - aPresentation: mutable GraphicObject from Graphic2d; - aMode: Integer from Standard = 0) - is redefined static private; - Compute(me : mutable; aProjector : Projector from Prs3d; aTrsf : Transformation from Geom; diff --git a/src/AIS/AIS_Chamf2dDimension.cxx b/src/AIS/AIS_Chamf2dDimension.cxx index c09c403171..043d72a901 100755 --- a/src/AIS/AIS_Chamf2dDimension.cxx +++ b/src/AIS/AIS_Chamf2dDimension.cxx @@ -242,19 +242,6 @@ void AIS_Chamf2dDimension::Compute(const Handle(Prs3d_Projector)& aProjector, PrsMgr_PresentableObject::Compute( aProjector , aPresentation ) ; } -//======================================================================= -//function : Compute -//purpose : to avoid warning -//======================================================================= - -void AIS_Chamf2dDimension::Compute(const Handle(PrsMgr_PresentationManager2d)& aPresentationManager2d, - const Handle(Graphic2d_GraphicObject)& aGraphicObject, - const Standard_Integer anInteger) -{ -// Standard_NotImplemented::Raise("AIS_Chamf2dDimension::Compute(const Handle(PrsMgr_PresentationManager2d)&,const Handle(Graphic2d_GraphicObject)&,const Standard_Integer)"); - PrsMgr_PresentableObject::Compute( aPresentationManager2d ,aGraphicObject,anInteger) ; -} - void AIS_Chamf2dDimension::Compute(const Handle_Prs3d_Projector& aProjector, const Handle_Geom_Transformation& aTransformation, const Handle_Prs3d_Presentation& aPresentation) { // Standard_NotImplemented::Raise("AIS_Chamf2dDimension::Compute(const Handle_Prs3d_Projector&, const Handle_Geom_Transformation&, const Handle_Prs3d_Presentation&)"); diff --git a/src/AIS/AIS_Chamf3dDimension.cdl b/src/AIS/AIS_Chamf3dDimension.cdl index 6fa0771194..b172382229 100755 --- a/src/AIS/AIS_Chamf3dDimension.cdl +++ b/src/AIS/AIS_Chamf3dDimension.cdl @@ -38,8 +38,6 @@ uses Dir from gp, Projector from Prs3d, Transformation from Geom, - PresentationManager2d from PrsMgr, - GraphicObject from Graphic2d, ExtendedString from TCollection, ArrowSide from DsgPrs, KindOfDimension from AIS @@ -90,11 +88,6 @@ is aPresentation: mutable Presentation from Prs3d) is redefined static private; - Compute(me:mutable; - aPresentationManager: PresentationManager2d from PrsMgr; - aPresentation: mutable GraphicObject from Graphic2d; - aMode: Integer from Standard = 0) - is redefined static private; Compute(me : mutable; aProjector : Projector from Prs3d; aTrsf : Transformation from Geom; diff --git a/src/AIS/AIS_Chamf3dDimension.cxx b/src/AIS/AIS_Chamf3dDimension.cxx index 8bfba3e3b9..0b3bfd77ce 100755 --- a/src/AIS/AIS_Chamf3dDimension.cxx +++ b/src/AIS/AIS_Chamf3dDimension.cxx @@ -217,19 +217,6 @@ void AIS_Chamf3dDimension::Compute(const Handle(Prs3d_Projector)& aProjector, PrsMgr_PresentableObject::Compute( aProjector , aPresentation ) ; } -//======================================================================= -//function : Compute -//purpose : to avoid warning -//======================================================================= - -void AIS_Chamf3dDimension::Compute(const Handle(PrsMgr_PresentationManager2d)& aPresentationManager2d, - const Handle(Graphic2d_GraphicObject)& aGraphicObject, - const Standard_Integer anInteger) -{ -// Standard_NotImplemented::Raise("AIS_Chamf3dDimension::Compute(const Handle(PrsMgr_PresentationManager2d)&,const Handle(Graphic2d_GraphicObject)&,const Standard_Integer)"); - PrsMgr_PresentableObject::Compute( aPresentationManager2d ,aGraphicObject,anInteger) ; -} - void AIS_Chamf3dDimension::Compute(const Handle_Prs3d_Projector& aProjector, const Handle_Geom_Transformation& aTransformation, const Handle_Prs3d_Presentation& aPresentation) { // Standard_NotImplemented::Raise("AIS_Chamf3dDimension::Compute(const Handle_Prs3d_Projector&, const Handle_Geom_Transformation&, const Handle_Prs3d_Presentation&)"); diff --git a/src/AIS/AIS_Circle.cdl b/src/AIS/AIS_Circle.cdl index 2d5798d687..9b8e5df82f 100755 --- a/src/AIS/AIS_Circle.cdl +++ b/src/AIS/AIS_Circle.cdl @@ -36,8 +36,6 @@ uses Selection from SelectMgr, Projector from Prs3d, Transformation from Geom, - PresentationManager2d from PrsMgr, - GraphicObject from Graphic2d, Line from AIS, KindOfInteractive from AIS @@ -68,12 +66,6 @@ is aPresentation: mutable Presentation from Prs3d) is redefined static private; - Compute(me:mutable; - aPresentationManager: PresentationManager2d from PrsMgr; - aPresentation: mutable GraphicObject from Graphic2d; - aMode: Integer from Standard = 0) - is redefined static private; - Compute(me : mutable; aProjector : Projector from Prs3d; aTrsf : Transformation from Geom; diff --git a/src/AIS/AIS_Circle.cxx b/src/AIS/AIS_Circle.cxx index 92fbb3c89c..c12dd36f2b 100755 --- a/src/AIS/AIS_Circle.cxx +++ b/src/AIS/AIS_Circle.cxx @@ -254,15 +254,6 @@ void AIS_Circle::ComputeArcSelection(const Handle(SelectMgr_Selection)& aSelecti myComponent,myUStart,myUEnd); aSelection->Add(seg); } -//======================================================================= -//function : Compute -//purpose : to avoid warning -//======================================================================= -void AIS_Circle::Compute(const Handle(PrsMgr_PresentationManager2d)&, - const Handle(Graphic2d_GraphicObject)&, - const Standard_Integer) -{ -} //======================================================================= //function : Compute diff --git a/src/AIS/AIS_ConcentricRelation.cdl b/src/AIS/AIS_ConcentricRelation.cdl index cab31652fb..6f8262dddf 100755 --- a/src/AIS/AIS_ConcentricRelation.cdl +++ b/src/AIS/AIS_ConcentricRelation.cdl @@ -40,8 +40,6 @@ uses Dir from gp, Projector from Prs3d, Transformation from Geom, - PresentationManager2d from PrsMgr, - GraphicObject from Graphic2d , Plane from Geom is @@ -68,12 +66,6 @@ is aProjector: Projector from Prs3d; aPresentation: mutable Presentation from Prs3d) is redefined static private; - - Compute(me:mutable; - aPresentationManager: PresentationManager2d from PrsMgr; - aPresentation: mutable GraphicObject from Graphic2d; - aMode: Integer from Standard = 0) - is redefined static private; Compute(me : mutable; aProjector : Projector from Prs3d; diff --git a/src/AIS/AIS_ConcentricRelation.cxx b/src/AIS/AIS_ConcentricRelation.cxx index c586d2bded..bff6f653da 100755 --- a/src/AIS/AIS_ConcentricRelation.cxx +++ b/src/AIS/AIS_ConcentricRelation.cxx @@ -238,17 +238,6 @@ void AIS_ConcentricRelation::Compute(const Handle(Prs3d_Projector)&, { } -//======================================================================= -//function : Compute -//purpose : to avoid warning -//======================================================================= - -void AIS_ConcentricRelation::Compute(const Handle(PrsMgr_PresentationManager2d)&, - const Handle(Graphic2d_GraphicObject)&, - const Standard_Integer) -{ -} - //======================================================================= //function : ComputeSelection //purpose : diff --git a/src/AIS/AIS_ConnectedInteractive.cdl b/src/AIS/AIS_ConnectedInteractive.cdl index 5d532f5c7e..238f67f3fc 100755 --- a/src/AIS/AIS_ConnectedInteractive.cdl +++ b/src/AIS/AIS_ConnectedInteractive.cdl @@ -49,8 +49,6 @@ uses Location from TopLoc, Transformation from Geom, PresentationManager3d from PrsMgr, - GraphicObject from Graphic2d, - PresentationManager2d from PrsMgr, Presentation from Prs3d, TypeOfPresentation3d from PrsMgr, Selection from SelectMgr, @@ -145,18 +143,6 @@ is aProjector: Projector from Prs3d; aPresentation: mutable Presentation from Prs3d) is redefined; - - Compute(me:mutable; - aPresentationManager: PresentationManager2d from PrsMgr; - aPresentation: mutable GraphicObject from Graphic2d; - aMode: Integer from Standard = 0) - ---Level: Internal - ---Purpose: this method should fill the presentation according to the - -- enumerated mode of the application and to the display parameter - -- of the application. - - raises NotImplemented from Standard - is redefined; ComputeSelection(me:mutable; aSelection :mutable Selection from SelectMgr; aMode : Integer) is redefined virtual private; diff --git a/src/AIS/AIS_ConnectedInteractive.cxx b/src/AIS/AIS_ConnectedInteractive.cxx index 72a3a31fcf..a524dcc2b8 100755 --- a/src/AIS/AIS_ConnectedInteractive.cxx +++ b/src/AIS/AIS_ConnectedInteractive.cxx @@ -152,12 +152,6 @@ void AIS_ConnectedInteractive::Compute(const Handle_Prs3d_Projector& aProjector, PrsMgr_PresentableObject::Compute( aProjector , aPresentation ) ; } -void AIS_ConnectedInteractive::Compute(const Handle_PrsMgr_PresentationManager2d& aPresentationManager2d, const Handle_Graphic2d_GraphicObject& aGraphicObject, const int anInteger) -{ -// Standard_NotImplemented::Raise("AIS_ConnectedInteractive::Compute(const Handle_PrsMgr_PresentationManager2d&, const Handle_Graphic2d_GraphicObject&, const int)"); - PrsMgr_PresentableObject::Compute( aPresentationManager2d ,aGraphicObject,anInteger) ; -} - //======================================================================= //function : ComputeSelection //purpose : diff --git a/src/AIS/AIS_ConnectedShape.cdl b/src/AIS/AIS_ConnectedShape.cdl index 1bc1467446..4efdf2587d 100755 --- a/src/AIS/AIS_ConnectedShape.cdl +++ b/src/AIS/AIS_ConnectedShape.cdl @@ -42,9 +42,7 @@ uses Integer from Standard, Shape from AIS, TypeOfPresentation3d from PrsMgr, - GraphicObject from Graphic2d, PresentationManager3d from PrsMgr, - PresentationManager2d from PrsMgr, InteractiveObject from AIS, KindOfInteractive from AIS, Location from TopLoc, @@ -113,17 +111,6 @@ is aPresentation : mutable Presentation from Prs3d) is redefined virtual private; - Compute(me:mutable; - aPresentationManager: PresentationManager2d from PrsMgr; - aPresentation: mutable GraphicObject from Graphic2d; - aMode: Integer from Standard = 0) - raises NotImplemented from Standard - is redefined; - ---Level: Internal - ---Purpose: this method should fill the presentation according to the - -- enumerated mode of the application and to the display parameter - -- of the application. - ComputeSelection(me:mutable; aSelection :mutable Selection from SelectMgr; aMode : Integer from Standard) is redefined virtual private; diff --git a/src/AIS/AIS_ConnectedShape.cxx b/src/AIS/AIS_ConnectedShape.cxx index ff63d24b73..c79a6b8ce3 100755 --- a/src/AIS/AIS_ConnectedShape.cxx +++ b/src/AIS/AIS_ConnectedShape.cxx @@ -166,19 +166,6 @@ void AIS_ConnectedShape::Compute(const Handle(Prs3d_Projector)& aProjector, } } -//======================================================================= -//function : Compute -//purpose : -//======================================================================= - -void AIS_ConnectedShape::Compute(const Handle_PrsMgr_PresentationManager2d& aPresentationManager2d, - const Handle_Graphic2d_GraphicObject& aGraphicObject, - const int anInteger) -{ -// Standard_NotImplemented::Raise("AIS_ConnectedShape::Compute(const Handle_PrsMgr_PresentationManager2d&, const Handle_Graphic2d_GraphicObject&, const int)"); - AIS_ConnectedInteractive::Compute( aPresentationManager2d ,aGraphicObject,anInteger) ; -} - //======================================================================= //function : ComputeSelection //purpose : Attention fragile... diff --git a/src/AIS/AIS_DiameterDimension.cdl b/src/AIS/AIS_DiameterDimension.cdl index 8a69e02b88..7dae78c2aa 100755 --- a/src/AIS/AIS_DiameterDimension.cdl +++ b/src/AIS/AIS_DiameterDimension.cdl @@ -46,9 +46,7 @@ uses PresentationManager3d from PrsMgr, Selection from SelectMgr, Projector from Prs3d, - Transformation from Geom, - PresentationManager2d from PrsMgr, - GraphicObject from Graphic2d, + Transformation from Geom, ExtendedString from TCollection, ArrowSide from DsgPrs, KindOfSurface from AIS, @@ -126,12 +124,6 @@ is aProjector: Projector from Prs3d; aPresentation: mutable Presentation from Prs3d) is redefined static private; - - Compute(me:mutable; - aPresentationManager: PresentationManager2d from PrsMgr; - aPresentation: mutable GraphicObject from Graphic2d; - aMode: Integer from Standard = 0) - is redefined static private; Compute(me : mutable; aProjector : Projector from Prs3d; diff --git a/src/AIS/AIS_DiameterDimension.cxx b/src/AIS/AIS_DiameterDimension.cxx index dd220f4599..a51fa6bab4 100755 --- a/src/AIS/AIS_DiameterDimension.cxx +++ b/src/AIS/AIS_DiameterDimension.cxx @@ -168,19 +168,6 @@ void AIS_DiameterDimension::Compute(const Handle(Prs3d_Projector)& aProjector, PrsMgr_PresentableObject::Compute( aProjector , aPresentation ) ; } -//======================================================================= -//function : Compute -//purpose : to avoid warning -//======================================================================= - -void AIS_DiameterDimension::Compute(const Handle(PrsMgr_PresentationManager2d)& aPresentationManager, - const Handle(Graphic2d_GraphicObject)& aPresentation, - const Standard_Integer aMode) -{ -// Standard_NotImplemented::Raise("AIS_DiameterDimension::Compute(const Handle(PrsMgr_PresentationManager2d)& aPresentationManager, const Handle(Graphic2d_GraphicObject)& aPresentation, const Standard_Integer aMode)"); - PrsMgr_PresentableObject::Compute( aPresentationManager ,aPresentation,aMode) ; -} - void AIS_DiameterDimension::Compute(const Handle_Prs3d_Projector& aProjector, const Handle_Geom_Transformation& aTransformation, const Handle_Prs3d_Presentation& aPresentation) { // Standard_NotImplemented::Raise("AIS_DiameterDimension::Compute(const Handle_Prs3d_Projector&, const Handle_Geom_Transformation&, const Handle_Prs3d_Presentation&)"); diff --git a/src/AIS/AIS_EqualDistanceRelation.cdl b/src/AIS/AIS_EqualDistanceRelation.cdl index da4075fdba..0b5b57284d 100755 --- a/src/AIS/AIS_EqualDistanceRelation.cdl +++ b/src/AIS/AIS_EqualDistanceRelation.cdl @@ -35,8 +35,6 @@ uses Presentation from Prs3d, Projector from Prs3d, Transformation from Geom, - PresentationManager2d from PrsMgr, - GraphicObject from Graphic2d, Selection from SelectMgr, Pnt from gp, Drawer from AIS, @@ -102,13 +100,7 @@ is Compute( me : mutable; aProjector : Projector from Prs3d; aPresentation : mutable Presentation from Prs3d ) - is redefined static private; - - Compute( me : mutable; - aPresentationManager : PresentationManager2d from PrsMgr; - aPresentation : mutable GraphicObject from Graphic2d; - aMode : Integer from Standard = 0 ) - is redefined static private; + is redefined static private; Compute(me : mutable; aProjector : Projector from Prs3d; diff --git a/src/AIS/AIS_EqualDistanceRelation.cxx b/src/AIS/AIS_EqualDistanceRelation.cxx index 3a1198b93c..58d623c06e 100755 --- a/src/AIS/AIS_EqualDistanceRelation.cxx +++ b/src/AIS/AIS_EqualDistanceRelation.cxx @@ -221,21 +221,6 @@ void AIS_EqualDistanceRelation::Compute( const Handle( Prs3d_Projector )& aProje // PrsMgr_PresentableObject::Compute( aProjector , aPresentation ) ; } - -//======================================================================= -//function : Compute -//purpose : to avoid warning at compilation (SUN) -//======================================================================= - -void AIS_EqualDistanceRelation::Compute( const Handle( PrsMgr_PresentationManager2d )& aPresentationManager2d, - const Handle( Graphic2d_GraphicObject )& aGraphicObject, - const Standard_Integer anInteger) -{ -// Standard_NotImplemented::Raise("AIS_EqualDistanceRelation::Compute( const Handle( PrsMgr_PresentationManager2d )&, -// const Handle( Graphic2d_GraphicObject )&,const Standard_Integer )"); -// PrsMgr_PresentableObject::Compute( aPresentationManager2d ,aGraphicObject,anInteger) ; -} - //======================================================================= //function : Compute //purpose : to avoid warning at compilation (SUN) diff --git a/src/AIS/AIS_EqualRadiusRelation.cdl b/src/AIS/AIS_EqualRadiusRelation.cdl index 595137b64e..2e0e298916 100755 --- a/src/AIS/AIS_EqualRadiusRelation.cdl +++ b/src/AIS/AIS_EqualRadiusRelation.cdl @@ -31,8 +31,6 @@ uses Presentation from Prs3d, Projector from Prs3d, Transformation from Geom, - PresentationManager2d from PrsMgr, - GraphicObject from Graphic2d, Selection from SelectMgr, Pnt from gp @@ -56,13 +54,7 @@ is Compute( me : mutable; aProjector : Projector from Prs3d; aPresentation : mutable Presentation from Prs3d ) - is redefined static private; - - Compute( me : mutable; - aPresentationManager : PresentationManager2d from PrsMgr; - aPresentation : mutable GraphicObject from Graphic2d; - aMode : Integer from Standard = 0 ) - is redefined static private; + is redefined static private; Compute(me : mutable; aProjector : Projector from Prs3d; diff --git a/src/AIS/AIS_EqualRadiusRelation.cxx b/src/AIS/AIS_EqualRadiusRelation.cxx index 473ca347c0..50704c867c 100755 --- a/src/AIS/AIS_EqualRadiusRelation.cxx +++ b/src/AIS/AIS_EqualRadiusRelation.cxx @@ -164,19 +164,6 @@ void AIS_EqualRadiusRelation::Compute( const Handle( Prs3d_Projector )& /*aProje // PrsMgr_PresentableObject::Compute( aProjector , aPresentation ) ; } -//======================================================================= -//function : Compute -//purpose : to avoid warning at compilation (SUN) -//======================================================================= - -void AIS_EqualRadiusRelation::Compute( const Handle( PrsMgr_PresentationManager2d )& /*aPresentationManager2d*/, - const Handle( Graphic2d_GraphicObject )& /*aGraphicObject*/, - const Standard_Integer /*anInteger*/) -{ -// Standard_NotImplemented::Raise("AIS_EqualRadiusRelation::Compute( const Handle( PrsMgr_PresentationManager2d )&,const Handle( Graphic2d_GraphicObject )&,const Standard_Integer )"); -// PrsMgr_PresentableObject::Compute( aPresentationManager2d ,aGraphicObject,anInteger) ; -} - //======================================================================= //function : Compute //purpose : diff --git a/src/AIS/AIS_FixRelation.cdl b/src/AIS/AIS_FixRelation.cdl index f59540d80f..b6ce1a8c74 100755 --- a/src/AIS/AIS_FixRelation.cdl +++ b/src/AIS/AIS_FixRelation.cdl @@ -45,8 +45,6 @@ uses Pnt from gp, Projector from Prs3d, Transformation from Geom, - PresentationManager2d from PrsMgr, - GraphicObject from Graphic2d, Plane from Geom is @@ -109,14 +107,8 @@ is Compute(me:mutable; aProjector: Projector from Prs3d; aPresentation: mutable Presentation from Prs3d) - is redefined static private; - - Compute(me:mutable; - aPresentationManager: PresentationManager2d from PrsMgr; - aPresentation: mutable GraphicObject from Graphic2d; - aMode: Integer from Standard = 0) is redefined static private; - + Compute(me : mutable; aProjector : Projector from Prs3d; aTrsf : Transformation from Geom; diff --git a/src/AIS/AIS_FixRelation.cxx b/src/AIS/AIS_FixRelation.cxx index 9334d9c62b..04b77d7b0c 100755 --- a/src/AIS/AIS_FixRelation.cxx +++ b/src/AIS/AIS_FixRelation.cxx @@ -235,19 +235,6 @@ void AIS_FixRelation::Compute(const Handle(Prs3d_Projector)& aProjector, PrsMgr_PresentableObject::Compute( aProjector , aPresentation ) ; } -//======================================================================= -//function : Compute -//purpose : to avoid warning -//======================================================================= - -void AIS_FixRelation::Compute(const Handle(PrsMgr_PresentationManager2d)& aPresentationManager2d, - const Handle(Graphic2d_GraphicObject)& aGraphicObject, - const Standard_Integer anInteger) -{ -// Standard_NotImplemented::Raise("AIS_FixRelation::Compute(const Handle(PrsMgr_PresentationManager2d)&,const Handle(Graphic2d_GraphicObject)&,const Standard_Integer)"); - PrsMgr_PresentableObject::Compute( aPresentationManager2d ,aGraphicObject,anInteger) ; -} - //======================================================================= //function : Compute //purpose : diff --git a/src/AIS/AIS_IdenticRelation.cdl b/src/AIS/AIS_IdenticRelation.cdl index b262ba9858..0aabd2c952 100755 --- a/src/AIS/AIS_IdenticRelation.cdl +++ b/src/AIS/AIS_IdenticRelation.cdl @@ -34,9 +34,7 @@ uses PresentationManager3d from PrsMgr, Selection from SelectMgr, Projector from Prs3d, - Transformation from Geom, - PresentationManager2d from PrsMgr, - GraphicObject from Graphic2d, + Transformation from Geom, Plane from Geom, Curve from Geom, Line from Geom, @@ -75,12 +73,6 @@ is aPresentation: mutable Presentation from Prs3d) is redefined static private; - Compute(me:mutable; - aPresentationManager: PresentationManager2d from PrsMgr; - aPresentation: mutable GraphicObject from Graphic2d; - aMode: Integer from Standard = 0) - is redefined static private; - Compute(me : mutable; aProjector : Projector from Prs3d; aTrsf : Transformation from Geom; diff --git a/src/AIS/AIS_IdenticRelation.cxx b/src/AIS/AIS_IdenticRelation.cxx index 784ed822a0..26fac691b4 100755 --- a/src/AIS/AIS_IdenticRelation.cxx +++ b/src/AIS/AIS_IdenticRelation.cxx @@ -379,18 +379,6 @@ void AIS_IdenticRelation::Compute(const Handle(Prs3d_Projector)& aProjector, PrsMgr_PresentableObject::Compute( aProjector , aPresentation ) ; } -//======================================================================= -//function : Compute -//purpose : -//======================================================================= -void AIS_IdenticRelation::Compute(const Handle(PrsMgr_PresentationManager2d)& aPresentationManager2d, - const Handle(Graphic2d_GraphicObject)& aGraphicObject, - const Standard_Integer anInteger) -{ -// Standard_NotImplemented::Raise("AIS_IdenticRelation::Compute(const Handle(PrsMgr_PresentationManager2d)&,const Handle(Graphic2d_GraphicObject)&,const Standard_Integer)"); - PrsMgr_PresentableObject::Compute( aPresentationManager2d ,aGraphicObject,anInteger) ; -} - void AIS_IdenticRelation::Compute(const Handle_Prs3d_Projector& aProjector, const Handle_Geom_Transformation& aTransformation, const Handle_Prs3d_Presentation& aPresentation) { // Standard_NotImplemented::Raise("AIS_IdenticRelation::Compute(const Handle_Prs3d_Projector&, const Handle_Geom_Transformation&, const Handle_Prs3d_Presentation&)"); diff --git a/src/AIS/AIS_LengthDimension.cdl b/src/AIS/AIS_LengthDimension.cdl index a7ae6c2581..67522444ef 100755 --- a/src/AIS/AIS_LengthDimension.cdl +++ b/src/AIS/AIS_LengthDimension.cdl @@ -34,9 +34,7 @@ uses Shape from TopoDS, Dir from gp, Pnt from gp, Projector from Prs3d, - Transformation from Geom, - PresentationManager2d from PrsMgr, - GraphicObject from Graphic2d, + Transformation from Geom, ExtendedString from TCollection, Plane from Geom, TypeOfDist from AIS, @@ -150,12 +148,6 @@ is aPresentation : mutable Presentation from Prs3d) is redefined static private; - Compute(me:mutable; - aPresentationManager: PresentationManager2d from PrsMgr; - aPresentation: mutable GraphicObject from Graphic2d; - aMode: Integer from Standard = 0) - is redefined static private; - Compute(me : mutable; aProjector : Projector from Prs3d; aTrsf : Transformation from Geom; diff --git a/src/AIS/AIS_LengthDimension.cxx b/src/AIS/AIS_LengthDimension.cxx index a260c6e041..8c053de858 100755 --- a/src/AIS/AIS_LengthDimension.cxx +++ b/src/AIS/AIS_LengthDimension.cxx @@ -387,19 +387,6 @@ void AIS_LengthDimension::Compute(const Handle(Prs3d_Projector)& aProjector, PrsMgr_PresentableObject::Compute( aProjector , aPresentation ) ; } -//======================================================================= -//function : Compute -//purpose : to avoid warning -//======================================================================= - -void AIS_LengthDimension::Compute(const Handle(PrsMgr_PresentationManager2d)& aPresentationManager2d, - const Handle(Graphic2d_GraphicObject)& aGraphicObject, - const Standard_Integer anInteger) -{ -// Standard_NotImplemented::Raise("AIS_LengthDimension::Compute(const Handle(PrsMgr_PresentationManager2d)&,const Handle(Graphic2d_GraphicObject)&,const Standard_Integer)"); - PrsMgr_PresentableObject::Compute( aPresentationManager2d ,aGraphicObject,anInteger) ; -} - void AIS_LengthDimension::Compute(const Handle_Prs3d_Projector& aProjector, const Handle_Geom_Transformation& aTransformation, const Handle_Prs3d_Presentation& aPresentation) { // Standard_NotImplemented::Raise("AIS_LengthDimension::Compute(const Handle_Prs3d_Projector&, const Handle_Geom_Transformation&, const Handle_Prs3d_Presentation&)"); diff --git a/src/AIS/AIS_Line.cdl b/src/AIS/AIS_Line.cdl index e45a69f040..dac1156410 100755 --- a/src/AIS/AIS_Line.cdl +++ b/src/AIS/AIS_Line.cdl @@ -36,8 +36,6 @@ uses Selection from SelectMgr, Projector from Prs3d, Transformation from Geom, - PresentationManager2d from PrsMgr, - GraphicObject from Graphic2d, Line from AIS, KindOfInteractive from AIS @@ -61,13 +59,7 @@ is Compute(me:mutable; aProjector: Projector from Prs3d; aPresentation: mutable Presentation from Prs3d) - is redefined static private; - - Compute(me:mutable; - aPresentationManager: PresentationManager2d from PrsMgr; - aPresentation: mutable GraphicObject from Graphic2d; - aMode: Integer from Standard = 0) - is redefined static private; + is redefined static private; Compute(me : mutable; aProjector : Projector from Prs3d; diff --git a/src/AIS/AIS_Line.cxx b/src/AIS/AIS_Line.cxx index 95dfca094d..9e9fed24ba 100755 --- a/src/AIS/AIS_Line.cxx +++ b/src/AIS/AIS_Line.cxx @@ -298,15 +298,6 @@ void AIS_Line::ComputeSegmentLineSelection(const Handle(SelectMgr_Selection)& aS myEndPoint->Pnt()); aSelection->Add(seg); } -//======================================================================= -//function : Compute -//purpose : to avoid warning -//======================================================================= -void AIS_Line::Compute(const Handle(PrsMgr_PresentationManager2d)&, - const Handle(Graphic2d_GraphicObject)&, - const Standard_Integer) -{ -} //======================================================================= //function : Compute diff --git a/src/AIS/AIS_MaxRadiusDimension.cdl b/src/AIS/AIS_MaxRadiusDimension.cdl index e18c56dcda..5b0e582702 100755 --- a/src/AIS/AIS_MaxRadiusDimension.cdl +++ b/src/AIS/AIS_MaxRadiusDimension.cdl @@ -40,9 +40,7 @@ uses PresentationManager3d from PrsMgr, Selection from SelectMgr, Projector from Prs3d, - Transformation from Geom, - PresentationManager2d from PrsMgr, - GraphicObject from Graphic2d, + Transformation from Geom, ExtendedString from TCollection, ArrowSide from DsgPrs, KindOfSurface from AIS, @@ -85,13 +83,7 @@ is Compute(me:mutable; aProjector: Projector from Prs3d; aPresentation: mutable Presentation from Prs3d) - is redefined static private; - - Compute(me:mutable; - aPresentationManager: PresentationManager2d from PrsMgr; - aPresentation: mutable GraphicObject from Graphic2d; - aMode: Integer from Standard = 0) - is redefined static private; + is redefined static private; Compute(me : mutable; aProjector : Projector from Prs3d; diff --git a/src/AIS/AIS_MaxRadiusDimension.cxx b/src/AIS/AIS_MaxRadiusDimension.cxx index 05c853ad5d..a5cf43bdaa 100755 --- a/src/AIS/AIS_MaxRadiusDimension.cxx +++ b/src/AIS/AIS_MaxRadiusDimension.cxx @@ -146,19 +146,6 @@ void AIS_MaxRadiusDimension::Compute(const Handle(Prs3d_Projector)& aProjector, PrsMgr_PresentableObject::Compute( aProjector , aPresentation ) ; } -//======================================================================= -//function : Compute -//purpose : to avoid warning -//======================================================================= - -void AIS_MaxRadiusDimension::Compute(const Handle(PrsMgr_PresentationManager2d)& aPresentationManager, - const Handle(Graphic2d_GraphicObject)& aPresentation, - const Standard_Integer aMode) -{ -// Standard_NotImplemented::Raise("AIS_MaxRadiusDimension::Compute(const Handle(PrsMgr_PresentationManager2d)& aPresentationManager, const Handle(Graphic2d_GraphicObject)& aPresentation, const Standard_Integer aMode)"); - PrsMgr_PresentableObject::Compute( aPresentationManager ,aPresentation,aMode) ; -} - //======================================================================= //function : Compute //purpose : diff --git a/src/AIS/AIS_MidPointRelation.cdl b/src/AIS/AIS_MidPointRelation.cdl index 1c646a60b3..5ac4066cb1 100755 --- a/src/AIS/AIS_MidPointRelation.cdl +++ b/src/AIS/AIS_MidPointRelation.cdl @@ -26,10 +26,8 @@ uses ExtendedString from TCollection, Projector from Prs3d, Presentation from Prs3d, - PresentationManager2d from PrsMgr, PresentationManager3d from PrsMgr, Selection from SelectMgr, - GraphicObject from Graphic2d, Dir from gp, Pnt from gp, Lin from gp, @@ -70,12 +68,6 @@ is aPresentation: mutable Presentation from Prs3d) is redefined static private; - Compute(me: mutable; - aPresentationManager: PresentationManager2d from PrsMgr; - aPresentation : mutable GraphicObject from Graphic2d; - aMode : Integer from Standard = 0) - is redefined static private; - Compute(me: mutable; aProjector : Projector from Prs3d; aTrsf : Transformation from Geom; diff --git a/src/AIS/AIS_MidPointRelation.cxx b/src/AIS/AIS_MidPointRelation.cxx index 84e54d7e6a..ced1fa084c 100755 --- a/src/AIS/AIS_MidPointRelation.cxx +++ b/src/AIS/AIS_MidPointRelation.cxx @@ -155,18 +155,6 @@ void AIS_MidPointRelation::Compute(const Handle(Prs3d_Projector)& /*aProjector*/ // PrsMgr_PresentableObject::Compute( aProjector , aPresentation ) ; } -//======================================================================= -//function : Compute -//purpose : to avoid warning at compilation (SUN) -//======================================================================= -void AIS_MidPointRelation::Compute(const Handle(PrsMgr_PresentationManager2d)& /*aPresentationManager2d*/, - const Handle(Graphic2d_GraphicObject)& /*aGraphicObject*/, - const Standard_Integer /*anInteger*/) -{ -// Standard_NotImplemented::Raise("AIS_MidPointRelation::Compute(const Handle(PrsMgr_PresentationManager2d)&,const Handle(Graphic2d_GraphicObject)&,const Standard_Integer)"); -// PrsMgr_PresentableObject::Compute( aPresentationManager2d ,aGraphicObject,anInteger) ; -} - void AIS_MidPointRelation::Compute(const Handle_Prs3d_Projector& aProjector, const Handle_Geom_Transformation& aTransformation, const Handle_Prs3d_Presentation& aPresentation) diff --git a/src/AIS/AIS_MinRadiusDimension.cdl b/src/AIS/AIS_MinRadiusDimension.cdl index 28cf8fea14..1786ef8922 100755 --- a/src/AIS/AIS_MinRadiusDimension.cdl +++ b/src/AIS/AIS_MinRadiusDimension.cdl @@ -39,9 +39,7 @@ uses PresentationManager3d from PrsMgr, Selection from SelectMgr, Projector from Prs3d, - Transformation from Geom, - PresentationManager2d from PrsMgr, - GraphicObject from Graphic2d, + Transformation from Geom, ExtendedString from TCollection, ArrowSide from DsgPrs, KindOfSurface from AIS, @@ -87,12 +85,6 @@ is aProjector: Projector from Prs3d; aPresentation: mutable Presentation from Prs3d) is redefined static private; - - Compute(me:mutable; - aPresentationManager: PresentationManager2d from PrsMgr; - aPresentation: mutable GraphicObject from Graphic2d; - aMode: Integer from Standard = 0) - is redefined static private; Compute(me : mutable; aProjector : Projector from Prs3d; diff --git a/src/AIS/AIS_MinRadiusDimension.cxx b/src/AIS/AIS_MinRadiusDimension.cxx index 1b5a5aa182..0053a0ad69 100755 --- a/src/AIS/AIS_MinRadiusDimension.cxx +++ b/src/AIS/AIS_MinRadiusDimension.cxx @@ -148,19 +148,6 @@ void AIS_MinRadiusDimension::Compute(const Handle(Prs3d_Projector)& aProjector, PrsMgr_PresentableObject::Compute( aProjector , aPresentation ) ; } -//======================================================================= -//function : Compute -//purpose : to avoid warning -//======================================================================= - -void AIS_MinRadiusDimension::Compute(const Handle(PrsMgr_PresentationManager2d)& aPresentationManager, - const Handle(Graphic2d_GraphicObject)& aPresentation, - const Standard_Integer aMode) -{ -// Standard_NotImplemented::Raise("AIS_MinRadiusDimension::Compute(const Handle(PrsMgr_PresentationManager2d)& aPresentationManager, const Handle(Graphic2d_GraphicObject)& aPresentation, const Standard_Integer aMode)"); - PrsMgr_PresentableObject::Compute( aPresentationManager ,aPresentation,aMode) ; -} - //======================================================================= //function : Compute //purpose : diff --git a/src/AIS/AIS_MultipleConnectedInteractive.cdl b/src/AIS/AIS_MultipleConnectedInteractive.cdl index 19081b8d00..3c364665dd 100755 --- a/src/AIS/AIS_MultipleConnectedInteractive.cdl +++ b/src/AIS/AIS_MultipleConnectedInteractive.cdl @@ -38,8 +38,6 @@ uses SequenceOfInteractive from AIS, KindOfInteractive from AIS, PresentationManager3d from PrsMgr, - PresentationManager2d from PrsMgr, - GraphicObject from Graphic2d, Presentation from Prs3d, Projector from Prs3d, Transformation from Geom, @@ -97,12 +95,6 @@ is -- a transformation if there's one stored. is redefined virtual protected; - Compute(me:mutable; - aPresentationManager: PresentationManager2d from PrsMgr; - aPresentation: mutable GraphicObject from Graphic2d; - aMode: Integer from Standard = 0) - is redefined; - Compute(me : mutable; aProjector : Projector from Prs3d; aTrsf : Transformation from Geom; diff --git a/src/AIS/AIS_MultipleConnectedInteractive.cxx b/src/AIS/AIS_MultipleConnectedInteractive.cxx index 03efed5610..e3b776e8ac 100755 --- a/src/AIS/AIS_MultipleConnectedInteractive.cxx +++ b/src/AIS/AIS_MultipleConnectedInteractive.cxx @@ -176,19 +176,6 @@ void AIS_MultipleConnectedInteractive::Compute(const Handle_Prs3d_Projector& aPr //purpose : //======================================================================= -void AIS_MultipleConnectedInteractive::Compute(const Handle_PrsMgr_PresentationManager2d& aPresentationManager2d, - const Handle_Graphic2d_GraphicObject& aGraphicObject, - const int anInteger) -{ -// Standard_NotImplemented::Raise("AIS_MultipleConnectedInteractive::Compute(const Handle_PrsMgr_PresentationManager2d&, const Handle_Graphic2d_GraphicObject&, const int)"); - PrsMgr_PresentableObject::Compute( aPresentationManager2d ,aGraphicObject,anInteger) ; -} - -//======================================================================= -//function : Compute -//purpose : -//======================================================================= - void AIS_MultipleConnectedInteractive::Compute(const Handle_Prs3d_Projector& aProjector, const Handle_Geom_Transformation& aTransformation, const Handle_Prs3d_Presentation& aPresentation) diff --git a/src/AIS/AIS_MultipleConnectedShape.cdl b/src/AIS/AIS_MultipleConnectedShape.cdl index 0cf096a11b..7c461ceccd 100755 --- a/src/AIS/AIS_MultipleConnectedShape.cdl +++ b/src/AIS/AIS_MultipleConnectedShape.cdl @@ -33,8 +33,6 @@ class MultipleConnectedShape from AIS inherits MultipleConnectedInteractive from uses PresentationManager3d from PrsMgr, - PresentationManager2d from PrsMgr, - GraphicObject from Graphic2d, Shape from TopoDS, Projector from Prs3d, Presentation from Prs3d, @@ -108,18 +106,6 @@ is -- presentation of this last object, with -- a transformation if there's one stored. is redefined virtual private; - - Compute(me:mutable; - aPresentationManager: PresentationManager2d from PrsMgr; - aPresentation: mutable GraphicObject from Graphic2d; - aMode: Integer from Standard = 0) - ---Level: Internal - ---Purpose: this method should fill the presentation according to the - -- enumerated mode of the application and to the display parameter - -- of the application. - - raises NotImplemented from Standard - is redefined; fields myShape : Shape from TopoDS; -- celle qui sert au compute Hidden lines et selection diff --git a/src/AIS/AIS_MultipleConnectedShape.cxx b/src/AIS/AIS_MultipleConnectedShape.cxx index b0a24b790a..b61967cf57 100755 --- a/src/AIS/AIS_MultipleConnectedShape.cxx +++ b/src/AIS/AIS_MultipleConnectedShape.cxx @@ -171,19 +171,6 @@ void AIS_MultipleConnectedShape::Compute(const Handle_PrsMgr_PresentationManager AIS_MultipleConnectedInteractive::Compute( aPresentationManager3d , aPresentation , anint ) ; } -//======================================================================= -//function : Compute -//purpose : -//======================================================================= - -void AIS_MultipleConnectedShape::Compute(const Handle_PrsMgr_PresentationManager2d& aPresentationManager2d, - const Handle_Graphic2d_GraphicObject& aGraphicObject, - const int anInteger) -{ -// Standard_NotImplemented::Raise("AIS_MultipleConnectedShape::Compute(const Handle_PrsMgr_PresentationManager2d&, const Handle_Graphic2d_GraphicObject&, const int)"); - PrsMgr_PresentableObject::Compute( aPresentationManager2d ,aGraphicObject,anInteger) ; -} - //======================================================================= //function : ComputeSelection //purpose : diff --git a/src/AIS/AIS_OffsetDimension.cdl b/src/AIS/AIS_OffsetDimension.cdl index 00a7b4775e..012f201502 100755 --- a/src/AIS/AIS_OffsetDimension.cdl +++ b/src/AIS/AIS_OffsetDimension.cdl @@ -32,11 +32,9 @@ uses Shape from TopoDS, Presentation from Prs3d, Projector from Prs3d, - Transformation from Geom, + Transformation from Geom, PresentationManager3d from PrsMgr, - PresentationManager2d from PrsMgr, Selection from SelectMgr, - GraphicObject from Graphic2d, Dir from gp, Pnt from gp, Trsf from gp, @@ -62,12 +60,6 @@ is aProjector: Projector from Prs3d; aPresentation: mutable Presentation from Prs3d) is redefined static private; - - Compute(me:mutable; - aPresentationManager: PresentationManager2d from PrsMgr; - aPresentation: mutable GraphicObject from Graphic2d; - aMode: Integer from Standard = 0) - is redefined static private; Compute(me : mutable; aProjector : Projector from Prs3d; diff --git a/src/AIS/AIS_OffsetDimension.cxx b/src/AIS/AIS_OffsetDimension.cxx index 816c688d41..7e690d2bfd 100755 --- a/src/AIS/AIS_OffsetDimension.cxx +++ b/src/AIS/AIS_OffsetDimension.cxx @@ -148,18 +148,6 @@ void AIS_OffsetDimension::Compute(const Handle(Prs3d_Projector)& /*aProjector*/, // PrsMgr_PresentableObject::Compute( aProjector , aPresentation ) ; } -//======================================================================= -//function : Compute -//purpose : to avoid warning at compilation (SUN) -//======================================================================= -void AIS_OffsetDimension::Compute(const Handle(PrsMgr_PresentationManager2d)& /*aPresentationManager2d*/, - const Handle(Graphic2d_GraphicObject)& /*aGraphicObject*/, - const Standard_Integer /*anInteger*/) -{ -// Standard_NotImplemented::Raise("AIS_OffsetDimension::Compute(const Handle(PrsMgr_PresentationManager2d)&,const Handle(Graphic2d_GraphicObject)&,const Standard_Integer)"); -// PrsMgr_PresentableObject::Compute( aPresentationManager2d ,aGraphicObject,anInteger) ; -} - void AIS_OffsetDimension::Compute(const Handle(Prs3d_Projector)& aProjector, const Handle(Geom_Transformation)& aTransformation, const Handle(Prs3d_Presentation)& aPresentation) diff --git a/src/AIS/AIS_ParallelRelation.cdl b/src/AIS/AIS_ParallelRelation.cdl index 9d6ec61f6d..db842a762b 100755 --- a/src/AIS/AIS_ParallelRelation.cdl +++ b/src/AIS/AIS_ParallelRelation.cdl @@ -34,9 +34,7 @@ uses Shape from TopoDS, Dir from gp, Pnt from gp, Projector from Prs3d, - Transformation from Geom, - PresentationManager2d from PrsMgr, - GraphicObject from Graphic2d, + Transformation from Geom, ArrowSide from DsgPrs is @@ -79,13 +77,6 @@ is aPresentation: mutable Presentation from Prs3d) is redefined static private; - Compute(me:mutable; - aPresentationManager: PresentationManager2d from PrsMgr; - aPresentation: mutable GraphicObject from Graphic2d; - aMode: Integer from Standard = 0) - is redefined static private; - - Compute(me : mutable; aProjector : Projector from Prs3d; aTrsf : Transformation from Geom; diff --git a/src/AIS/AIS_ParallelRelation.cxx b/src/AIS/AIS_ParallelRelation.cxx index 1578640583..6b3d6a6680 100755 --- a/src/AIS/AIS_ParallelRelation.cxx +++ b/src/AIS/AIS_ParallelRelation.cxx @@ -145,18 +145,6 @@ void AIS_ParallelRelation::Compute(const Handle(Prs3d_Projector)& aProjector, PrsMgr_PresentableObject::Compute( aProjector , aPresentation ) ; } -//======================================================================= -//function : Compute -//purpose : to avoid warning -//======================================================================= -void AIS_ParallelRelation::Compute(const Handle(PrsMgr_PresentationManager2d)& aPresentationManager2d, - const Handle(Graphic2d_GraphicObject)& aGraphicObject, - const Standard_Integer anInteger) -{ -// Standard_NotImplemented::Raise("AIS_ParallelRelation::Compute(const Handle(PrsMgr_PresentationManager2d)&,const Handle(Graphic2d_GraphicObject)&,const Standard_Integer)"); - PrsMgr_PresentableObject::Compute( aPresentationManager2d ,aGraphicObject,anInteger) ; -} - void AIS_ParallelRelation::Compute(const Handle_Prs3d_Projector& aProjector, const Handle_Geom_Transformation& aTransformation, const Handle_Prs3d_Presentation& aPresentation) { // Standard_NotImplemented::Raise("AIS_ParallelRelation::Compute(const Handle_Prs3d_Projector&, const Handle_Geom_Transformation&, const Handle_Prs3d_Presentation&)"); diff --git a/src/AIS/AIS_PerpendicularRelation.cdl b/src/AIS/AIS_PerpendicularRelation.cdl index efeeea2f6c..daceb4a92d 100755 --- a/src/AIS/AIS_PerpendicularRelation.cdl +++ b/src/AIS/AIS_PerpendicularRelation.cdl @@ -30,9 +30,7 @@ uses Shape from TopoDS, Pnt from gp, Dir from gp, Projector from Prs3d, - Transformation from Geom, - PresentationManager2d from PrsMgr, - GraphicObject from Graphic2d, + Transformation from Geom, Plane from Geom is @@ -69,12 +67,6 @@ is aPresentation: mutable Presentation from Prs3d) is redefined static private; - Compute(me:mutable; - aPresentationManager: PresentationManager2d from PrsMgr; - aPresentation: mutable GraphicObject from Graphic2d; - aMode: Integer from Standard = 0) - is redefined static private; - Compute(me : mutable; aProjector : Projector from Prs3d; aTrsf : Transformation from Geom; diff --git a/src/AIS/AIS_PerpendicularRelation.cxx b/src/AIS/AIS_PerpendicularRelation.cxx index 10b620a26e..1a0fe0c140 100755 --- a/src/AIS/AIS_PerpendicularRelation.cxx +++ b/src/AIS/AIS_PerpendicularRelation.cxx @@ -129,19 +129,6 @@ void AIS_PerpendicularRelation::Compute(const Handle(Prs3d_Projector)& aProjecto PrsMgr_PresentableObject::Compute( aProjector , aPresentation ) ; } -//======================================================================= -//function : Compute -//purpose : to avoid warning -//======================================================================= -void AIS_PerpendicularRelation::Compute(const Handle(PrsMgr_PresentationManager2d)& aPresentationManager2d, - const Handle(Graphic2d_GraphicObject)& -aGraphicObject, - const Standard_Integer anInteger) -{ -// Standard_NotImplemented::Raise("AIS_PerpendicularRelation::Compute(const Handle(PrsMgr_PresentationManager2d)&,const Handle(Graphic2d_GraphicObject)&,const Standard_Integer)"); - PrsMgr_PresentableObject::Compute( aPresentationManager2d ,aGraphicObject,anInteger) ; -} - void AIS_PerpendicularRelation::Compute(const Handle_Prs3d_Projector& aProjector, const Handle_Geom_Transformation& aTransformation, const Handle_Prs3d_Presentation& aPresentation) { // Standard_NotImplemented::Raise("AIS_PerpendicularRelation::Compute(const Handle_Prs3d_Projector&, const Handle_Geom_Transformation&, const Handle_Prs3d_Presentation&)"); diff --git a/src/AIS/AIS_Plane.cdl b/src/AIS/AIS_Plane.cdl index 8b0d14928f..aa4c4f947c 100755 --- a/src/AIS/AIS_Plane.cdl +++ b/src/AIS/AIS_Plane.cdl @@ -38,8 +38,6 @@ uses Pnt from gp, Projector from Prs3d, Transformation from Geom, - PresentationManager2d from PrsMgr, - GraphicObject from Graphic2d, NameOfMaterial from Graphic3d, TypeOfPlane from AIS, Axis2Placement from Geom, @@ -200,13 +198,7 @@ is Compute(me:mutable; aProjector: Projector from Prs3d; aPresentation: mutable Presentation from Prs3d) - is redefined virtual private; - - Compute(me:mutable; - aPresentationManager: PresentationManager2d from PrsMgr; - aPresentation: mutable GraphicObject from Graphic2d; - aMode: Integer from Standard = 0) - is redefined virtual private; + is redefined virtual private; Compute(me : mutable; aProjector : Projector from Prs3d; diff --git a/src/AIS/AIS_Plane.cxx b/src/AIS/AIS_Plane.cxx index 570177e31d..2737f49182 100755 --- a/src/AIS/AIS_Plane.cxx +++ b/src/AIS/AIS_Plane.cxx @@ -535,16 +535,6 @@ void AIS_Plane::ComputeFrame() } } -//======================================================================= -//function : Compute -//purpose : to avoid warning -//======================================================================= -void AIS_Plane::Compute(const Handle(PrsMgr_PresentationManager2d)&, - const Handle(Graphic2d_GraphicObject)&, - const Standard_Integer) -{ -} - //======================================================================= //function : Compute //purpose : to avoid warning diff --git a/src/AIS/AIS_PlaneTrihedron.cdl b/src/AIS/AIS_PlaneTrihedron.cdl index 3c67a8dbb4..552904cf9b 100755 --- a/src/AIS/AIS_PlaneTrihedron.cdl +++ b/src/AIS/AIS_PlaneTrihedron.cdl @@ -55,8 +55,6 @@ uses Projector from Prs3d, Transformation from Geom, Drawer from Prs3d, - PresentationManager2d from PrsMgr, - GraphicObject from Graphic2d, Line from AIS, Point from AIS, Plane from Geom, @@ -109,11 +107,6 @@ is aPresentation: mutable Presentation from Prs3d) is redefined static private; - Compute(me:mutable; - aPresentationManager: PresentationManager2d from PrsMgr; - aPresentation: mutable GraphicObject from Graphic2d; - aMode: Integer from Standard = 0) - is redefined static private; Compute(me : mutable; aProjector : Projector from Prs3d; diff --git a/src/AIS/AIS_PlaneTrihedron.cxx b/src/AIS/AIS_PlaneTrihedron.cxx index 947c25ccbf..7b5686ee53 100755 --- a/src/AIS/AIS_PlaneTrihedron.cxx +++ b/src/AIS/AIS_PlaneTrihedron.cxx @@ -291,15 +291,6 @@ void AIS_PlaneTrihedron::SetColor(const Quantity_Color &aCol) myDrawer->DatumAspect()->SecondAxisAspect()->SetColor(aCol); } -//======================================================================= -//function : Compute -//purpose : to avoid warning -//======================================================================= -void AIS_PlaneTrihedron::Compute(const Handle(PrsMgr_PresentationManager2d)&, - const Handle(Graphic2d_GraphicObject)&, - const Standard_Integer) -{ -} void AIS_PlaneTrihedron::Compute(const Handle(Prs3d_Projector)&, const Handle(Prs3d_Presentation)&) diff --git a/src/AIS/AIS_Point.cdl b/src/AIS/AIS_Point.cdl index b2cc71ef89..e25a56e1b7 100755 --- a/src/AIS/AIS_Point.cdl +++ b/src/AIS/AIS_Point.cdl @@ -36,8 +36,6 @@ uses Selection from SelectMgr, Projector from Prs3d, Transformation from Geom, - PresentationManager2d from PrsMgr, - GraphicObject from Graphic2d, Vertex from TopoDS, KindOfInteractive from AIS @@ -75,13 +73,7 @@ is Compute(me:mutable; aProjector: Projector from Prs3d; aPresentation: mutable Presentation from Prs3d) - is redefined static private; - - Compute(me:mutable; - aPresentationManager: PresentationManager2d from PrsMgr; - aPresentation: mutable GraphicObject from Graphic2d; - aMode: Integer from Standard = 0) - is redefined static private; + is redefined static private; Compute(me : mutable; aProjector : Projector from Prs3d; diff --git a/src/AIS/AIS_Point.cxx b/src/AIS/AIS_Point.cxx index a9a13b6e31..39a22a62c2 100755 --- a/src/AIS/AIS_Point.cxx +++ b/src/AIS/AIS_Point.cxx @@ -168,15 +168,7 @@ TopoDS_Vertex AIS_Point::Vertex() const return BRepBuilderAPI_MakeVertex(P); } -//======================================================================= -//function : Compute -//purpose : to avoid warning -//======================================================================= -void AIS_Point::Compute(const Handle(PrsMgr_PresentationManager2d)&, - const Handle(Graphic2d_GraphicObject)&, - const Standard_Integer) -{ -} + //======================================================================= //function : Compute //purpose : to avoid warning diff --git a/src/AIS/AIS_RadiusDimension.cdl b/src/AIS/AIS_RadiusDimension.cdl index cce14fe5b7..e8c8dc37db 100755 --- a/src/AIS/AIS_RadiusDimension.cdl +++ b/src/AIS/AIS_RadiusDimension.cdl @@ -42,9 +42,7 @@ uses Shape from TopoDS, Lin from gp, Circ from gp, Projector from Prs3d, - Transformation from Geom, - PresentationManager2d from PrsMgr, - GraphicObject from Graphic2d, + Transformation from Geom, ExtendedString from TCollection, ArrowSide from DsgPrs, KindOfDimension from AIS @@ -114,12 +112,6 @@ is aProjector: Projector from Prs3d; aPresentation: mutable Presentation from Prs3d) is redefined static private; - - Compute(me:mutable; - aPresentationManager: PresentationManager2d from PrsMgr; - aPresentation: mutable GraphicObject from Graphic2d; - aMode: Integer from Standard = 0) - is redefined static private; Compute(me : mutable; aProjector : Projector from Prs3d; diff --git a/src/AIS/AIS_RadiusDimension.cxx b/src/AIS/AIS_RadiusDimension.cxx index 0ea35514ef..afbb4d836a 100755 --- a/src/AIS/AIS_RadiusDimension.cxx +++ b/src/AIS/AIS_RadiusDimension.cxx @@ -292,18 +292,6 @@ void AIS_RadiusDimension::Compute(const Handle(Prs3d_Projector)& aProjector, PrsMgr_PresentableObject::Compute( aProjector , aPresentation ) ; } -//======================================================================= -//function : Compute -//purpose : to avoid warning -//======================================================================= -void AIS_RadiusDimension::Compute(const Handle(PrsMgr_PresentationManager2d)& aPresentationManager, - const Handle(Graphic2d_GraphicObject)& aPresentation, - const Standard_Integer aMode) -{ -// Standard_NotImplemented::Raise("AIS_RadiusDimension::Compute(const Handle(PrsMgr_PresentationManager2d)& aPresentationManager,const Handle(Graphic2d_GraphicObject)& aPresentation,const Standard_Integer aMode)"); - PrsMgr_PresentableObject::Compute( aPresentationManager ,aPresentation,aMode) ; -} - //======================================================================= //function : Compute //purpose : diff --git a/src/AIS/AIS_Shape.cdl b/src/AIS/AIS_Shape.cdl index 4b563f5c33..d18fbf46b5 100755 --- a/src/AIS/AIS_Shape.cdl +++ b/src/AIS/AIS_Shape.cdl @@ -58,13 +58,11 @@ uses Box from Bnd, ShapeEnum from TopAbs, Shape from TopoDS, - GraphicObject from Graphic2d, NameOfMaterial from Graphic3d , ---NameOfPhysicalMaterial from Graphic3d , MaterialAspect from Graphic3d, Presentation from Prs3d, Projector from Prs3d, - PresentationManager2d from PrsMgr, PresentationManager3d from PrsMgr, Selection from SelectMgr, KindOfInteractive from AIS, @@ -174,11 +172,6 @@ uses aMode : Integer from Standard = 0) is redefined virtual protected; - Compute(me : mutable; - aPresentationManager : PresentationManager2d from PrsMgr; - aPresentation : mutable GraphicObject from Graphic2d;aMode:Integer from Standard = 0) - is redefined virtual protected; - Compute(me : mutable; aProjector : Projector from Prs3d; aPresentation : mutable Presentation from Prs3d) diff --git a/src/AIS/AIS_Shape.cxx b/src/AIS/AIS_Shape.cxx index 864bf780c2..91cfc10cb2 100755 --- a/src/AIS/AIS_Shape.cxx +++ b/src/AIS/AIS_Shape.cxx @@ -275,17 +275,6 @@ void AIS_Shape::Compute(const Handle(PrsMgr_PresentationManager3d)& /*aPresentat aPrs->ReCompute(); // for hidden line recomputation if necessary... } -//======================================================================= -//function : Compute -//purpose : -//======================================================================= - -void AIS_Shape::Compute(const Handle(PrsMgr_PresentationManager2d)& /*aPresentationManager*/, - const Handle(Graphic2d_GraphicObject)& /*aGRO*/, - const Standard_Integer /*aMode*/) -{ -} - //======================================================================= //function : Compute //purpose : Hidden Line Removal diff --git a/src/AIS/AIS_SymmetricRelation.cdl b/src/AIS/AIS_SymmetricRelation.cdl index 61a4595c1a..b6163b62b1 100755 --- a/src/AIS/AIS_SymmetricRelation.cdl +++ b/src/AIS/AIS_SymmetricRelation.cdl @@ -34,9 +34,7 @@ uses Shape from TopoDS, Dir from gp, Pnt from gp, Projector from Prs3d, - Transformation from Geom, - PresentationManager2d from PrsMgr, - GraphicObject from Graphic2d, + Transformation from Geom, ExtendedString from TCollection, Plane from Geom @@ -87,12 +85,6 @@ is aPresentation: mutable Presentation from Prs3d) is redefined static private; - Compute(me:mutable; - aPresentationManager: PresentationManager2d from PrsMgr; - aPresentation: mutable GraphicObject from Graphic2d; - aMode: Integer from Standard = 0) - is redefined static private; - Compute(me : mutable; aProjector : Projector from Prs3d; aTrsf : Transformation from Geom; diff --git a/src/AIS/AIS_SymmetricRelation.cxx b/src/AIS/AIS_SymmetricRelation.cxx index 8929246570..1d6620a29d 100755 --- a/src/AIS/AIS_SymmetricRelation.cxx +++ b/src/AIS/AIS_SymmetricRelation.cxx @@ -141,19 +141,6 @@ void AIS_SymmetricRelation::Compute(const Handle(Prs3d_Projector)& /*aProjector* // PrsMgr_PresentableObject::Compute( aProjector , aPresentation ) ; } -//======================================================================= -//function : Compute -//purpose : to avoid warning at compilation (SUN) -//======================================================================= -void AIS_SymmetricRelation::Compute - (const Handle(PrsMgr_PresentationManager2d)& /*aPresentationManager2d*/, - const Handle(Graphic2d_GraphicObject)& /*aGraphicObject*/, - const Standard_Integer /*anInteger*/) -{ -// Standard_NotImplemented::Raise("AIS_SymmetricRelation::Compute(const Handle(PrsMgr_PresentationManager2d)&,const Handle(Graphic2d_GraphicObject)&,const Standard_Integer)"); -// PrsMgr_PresentableObject::Compute( aPresentationManager2d ,aGraphicObject,anInteger) ; -} - void AIS_SymmetricRelation::Compute(const Handle_Prs3d_Projector& aProjector, const Handle_Geom_Transformation& aTransformation, const Handle_Prs3d_Presentation& aPresentation) diff --git a/src/AIS/AIS_TangentRelation.cdl b/src/AIS/AIS_TangentRelation.cdl index fbdd9eeca5..71ff8a67c4 100755 --- a/src/AIS/AIS_TangentRelation.cdl +++ b/src/AIS/AIS_TangentRelation.cdl @@ -30,9 +30,7 @@ uses Shape from TopoDS, Pnt from gp, Dir from gp, Projector from Prs3d, - Transformation from Geom, - PresentationManager2d from PrsMgr, - GraphicObject from Graphic2d, + Transformation from Geom, Plane from Geom is @@ -75,13 +73,7 @@ is Compute(me:mutable; aProjector: Projector from Prs3d; aPresentation: mutable Presentation from Prs3d) - is redefined static private; - - Compute(me:mutable; - aPresentationManager: PresentationManager2d from PrsMgr; - aPresentation: mutable GraphicObject from Graphic2d; - aMode: Integer from Standard = 0) - is redefined static private; + is redefined static private; Compute(me : mutable; aProjector : Projector from Prs3d; diff --git a/src/AIS/AIS_TangentRelation.cxx b/src/AIS/AIS_TangentRelation.cxx index f9e3545ece..9c5d22e170 100755 --- a/src/AIS/AIS_TangentRelation.cxx +++ b/src/AIS/AIS_TangentRelation.cxx @@ -129,18 +129,6 @@ void AIS_TangentRelation::Compute(const Handle(Prs3d_Projector)& aProjector, PrsMgr_PresentableObject::Compute( aProjector , aPresentation ) ; } -//======================================================================= -//function : Compute -//purpose : to avoid warning -//======================================================================= -void AIS_TangentRelation::Compute(const Handle(PrsMgr_PresentationManager2d)& aPresentationManager2d, - const Handle(Graphic2d_GraphicObject)& aGraphicObject, - const Standard_Integer anInteger) -{ -// Standard_NotImplemented::Raise("AIS_TangentRelation::Compute(const Handle(PrsMgr_PresentationManager2d)&,const Handle(Graphic2d_GraphicObject)&,const Standard_Integer)"); - PrsMgr_PresentableObject::Compute( aPresentationManager2d ,aGraphicObject,anInteger) ; -} - void AIS_TangentRelation::Compute(const Handle_Prs3d_Projector& aProjector, const Handle_Geom_Transformation& aTransformation, const Handle_Prs3d_Presentation& aPresentation) diff --git a/src/AIS/AIS_Trihedron.cdl b/src/AIS/AIS_Trihedron.cdl index cf29d66d8d..3188e7b549 100755 --- a/src/AIS/AIS_Trihedron.cdl +++ b/src/AIS/AIS_Trihedron.cdl @@ -58,8 +58,6 @@ uses Selection from SelectMgr, Projector from Prs3d, Transformation from Geom, - PresentationManager2d from PrsMgr, - GraphicObject from Graphic2d, Axis from AIS, Point from AIS, Plane from AIS, @@ -141,11 +139,7 @@ is aPresentation: mutable Presentation from Prs3d) is redefined static private; - Compute(me:mutable; - aPresentationManager: PresentationManager2d from PrsMgr; - aPresentation: mutable GraphicObject from Graphic2d; - aMode: Integer from Standard = 0) - is redefined static private; + Compute(me : mutable; aProjector : Projector from Prs3d; diff --git a/src/AIS/AIS_Trihedron.cxx b/src/AIS/AIS_Trihedron.cxx index 4d3434f76d..52b1eb4977 100755 --- a/src/AIS/AIS_Trihedron.cxx +++ b/src/AIS/AIS_Trihedron.cxx @@ -519,15 +519,6 @@ Quantity_NameOfColor AIS_Trihedron::ArrowColor() const { } #endif -//======================================================================= -//function : Compute -//purpose : to avoid warning -//======================================================================= -void AIS_Trihedron::Compute(const Handle(PrsMgr_PresentationManager2d)&, - const Handle(Graphic2d_GraphicObject)&, - const Standard_Integer) -{ -} //======================================================================= //function : Compute diff --git a/src/AIS2D/AIS2D.cdl b/src/AIS2D/AIS2D.cdl deleted file mode 100755 index d488cc1d7b..0000000000 --- a/src/AIS2D/AIS2D.cdl +++ /dev/null @@ -1,241 +0,0 @@ --- Created on: 2000-04-07 --- Created by: Tanya COOL --- Copyright (c) 2000-2012 OPEN CASCADE SAS --- --- The content of this file is subject to the Open CASCADE Technology Public --- License Version 6.5 (the "License"). You may not use the content of this file --- except in compliance with the License. Please obtain a copy of the License --- at http://www.opencascade.org and read it completely before using this file. --- --- The Initial Developer of the Original Code is Open CASCADE S.A.S., having its --- main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. --- --- The Original Code and all software distributed under the License is --- distributed on an "AS IS" basis, without warranty of any kind, and the --- Initial Developer hereby disclaims all such warranties, including without --- limitation, any warranties of merchantability, fitness for a particular --- purpose or non-infringement. Please see the License for the specific terms --- and conditions governing the rights and limitations under the License. - - -package AIS2D - - ---Purpose: FOR APPLICATION INTERACTIVE SERVICES - -- - -- This package provides the classes and methods - -- to the maintenance of the high level 2D visualization . - -- The central entity is Interactive Context for easily - -- piloting presentation and selection. - -- AIS2D package proposes the classes of standard Interactive Objects - -- and this one allows to implement users classes of interactive objects, - -- by respecting a certain rules of creating of Interactive Object. - - uses - - Aspect, - Quantity, - TColStd, - TCollection, - V2d, - Graphic2d, - GGraphic2d, - TopoDS, - TopTools, - HLRAlgo, - HLRBRep, - Prs2d - - is - - enumeration KindOfIO is - - KOI_None, - KOI_DATUM, - KOI_DIMENSION, - KOI_SHAPE, - KOI_PROJSHAPE, - KOI_COMPOUND - - end KindOfIO; - - enumeration KindOfDimension is - - KOD_NONE, - KOD_LENGTH, - KOD_ANGLE, - KOD_DIAMETER, - KOD_RADIUS - - end KindOfDimension; - - enumeration KindOfPrimitive is - - KOP_NONE, - KOP_CIRCLE, - KOP_CIRCLEMARKER, - KOP_ELLIPS, - KOP_ELLIPSEMARKER, - KOP_FRAMEDTEXT, - KOP_HIDINGTEXT, - KOP_IMAGE, - KOP_IMAGEFILE, - KOP_INFINITELINE, - KOP_MARKER, - KOP_PARAGRAPH, - KOP_POLYLINE, - KOP_POLYLINEMARKER, - KOP_SEGMENT, - KOP_SETOFMARKERS, - KOP_SETOFPOLYLINES, - KOP_SETOFSEGMENTS, - KOP_TEXT, - KOP_CURVE, - KOP_SETOFCURVES, - KOP_ANGLE, - KOP_ANGULARITY, - KOP_ARROW, - KOP_AXIS, - KOP_CIRCULARITY, - KOP_CONCENTRIC, - KOP_CYLINDRIC, - KOP_DIAMETER, - KOP_FLATNESS, - KOP_LENGTH, - KOP_LINEPROFILE, - KOP_PARALLELISM, - KOP_PERPENDICULAR, - KOP_POINT, - KOP_RADIUS, - KOP_RADIUSINDEP, - KOP_REPERE, - KOP_STRAIGHTNESS, - KOP_SURFPROFILE, - KOP_SYMCIRCULAR, - KOP_SYMMETRY, - KOP_SYMTOTAL, - KOP_TAPER, - KOP_TOLERANCEFRAME - - end KindOfPrimitive; - - enumeration TypeOfAxis is - - TOAX_Unknown, - TOAX_XAxis, - TOAX_YAxis - - end TypeOfAxis; - - enumeration DisplayStatus is - - DS_Displayed, -- displayed in main viewer - DS_Erased, -- erased in the collector - DS_FullErased, -- erased but not in the collector - DS_Temporary, -- temporary displayed - DS_None -- nowhere - - end DisplayStatus; - - enumeration SelectStatus is - - SS_Added, - SS_Removed, - SS_NotDone - - end SelectStatus; - - enumeration StatusOfPick is - - SOP_Error, - SOP_NothingSelected, - SOP_Removed, - SOP_OneSelected, - SOP_SeveralSelected - - end StatusOfPick; - - enumeration StatusOfDetection is - - SOD_Error, - SOD_Nothing, - SOD_AllBad, - SOD_Selected, - SOD_OnlyOneDetected, - SOD_OnlyOneGood, - SOD_SeveralGood - - end StatusOfDetection; - - enumeration TypeOfDetection is - TOD_OBJECT, - TOD_PRIMITIVE, - TOD_ELEMENT, - TOD_VERTEX, - TOD_NONE - end TypeOfDetection; - - enumeration ClearMode is - - CM_All, - CM_Interactive, - CM_StandardModes, - CM_TemporaryShapePrs - - end ClearMode; - - class InteractiveContext; - class InteractiveObject; - class ProjShape; - - private class LocalStatus; - private class GlobalStatus; - private class LocalContext; - - private class PrimitiveArchit; - - private class SequenceOfIO instantiates Sequence from TCollection - ( InteractiveObject from AIS2D ); - - private class HSequenceOfIO instantiates HSequence from TCollection - ( InteractiveObject from AIS2D, SequenceOfIO from AIS2D ); - - private class SequenceOfPrimArchit instantiates Sequence from TCollection - ( PrimitiveArchit from AIS2D ); - - private class HSequenceOfPrimArchit instantiates HSequence from TCollection - ( PrimitiveArchit from AIS2D, SequenceOfPrimArchit from AIS2D ); - - private class DataMapOfIOStatus instantiates DataMap from TCollection - ( InteractiveObject from AIS2D, - GlobalStatus from AIS2D, - MapTransientHasher from TColStd ); - -- Management of interactiveObjects Status... - - class ListOfIO instantiates List from TCollection - ( InteractiveObject from AIS2D ); - - class DataMapOfPrimAspects instantiates DataMap from TCollection - ( Primitive from Graphic2d, - AspectRoot from Prs2d, - MapTransientHasher from TColStd); - - private class DataMapOfLC instantiates DataMap from TCollection - ( Integer from Standard, - LocalContext from AIS2D, - MapIntegerHasher from TColStd ); - - private class DataMapOfLocStat instantiates DataMap from TCollection - ( InteractiveObject from AIS2D, - LocalStatus from AIS2D, - MapTransientHasher from TColStd ); - -- to tell if an object is sensitive to Standard Modes Of Selection.... - - - pointer PToListOfInt to ListOfInteger from TColStd; - - Save( aCntx: InteractiveContext from AIS2D; aFile: CString from Standard ) - returns Boolean; - Retrieve( aCntx: InteractiveContext from AIS2D; aFile: CString from Standard ) - returns InteractiveObject from AIS2D; - -end AIS2D; diff --git a/src/AIS2D/AIS2D.cxx b/src/AIS2D/AIS2D.cxx deleted file mode 100755 index 284c487246..0000000000 --- a/src/AIS2D/AIS2D.cxx +++ /dev/null @@ -1,144 +0,0 @@ -// Copyright (c) 1999-2012 OPEN CASCADE SAS -// -// The content of this file is subject to the Open CASCADE Technology Public -// License Version 6.5 (the "License"). You may not use the content of this file -// except in compliance with the License. Please obtain a copy of the License -// at http://www.opencascade.org and read it completely before using this file. -// -// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its -// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. -// -// The Original Code and all software distributed under the License is -// distributed on an "AS IS" basis, without warranty of any kind, and the -// Initial Developer hereby disclaims all such warranties, including without -// limitation, any warranties of merchantability, fitness for a particular -// purpose or non-infringement. Please see the License for the specific terms -// and conditions governing the rights and limitations under the License. - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include - -#include - -#include -#include -#include -#include - -#include -#include -#include - -#ifdef HAVE_CONFIG_H -# include -#endif - -#include -Standard_Boolean AIS2D::Save( const Handle(AIS2D_InteractiveContext)& aCntx, - const Standard_CString aFile ) { - - - if ( !aCntx.IsNull() ) { - - Handle( Graphic2d_DisplayList ) theDL = aCntx->CurrentViewer()->View()->DisplayList(); - - if ( !theDL->IsEmpty() ) { - - Aspect_FStream ofs = new ofstream; - ofs->open( aFile, ios::out ); - - int LnOfDL = theDL->Length(); - TCollection_AsciiString thestr; - for ( int i = 1; i <= LnOfDL; ++i ) - { - Handle(AIS2D_InteractiveObject) theIO = - Handle(AIS2D_InteractiveObject)::DownCast( theDL->Value(i) ); - theIO->Save( ofs ); - - /* int lnOfPr = theIO->Length(); - - for ( int j = 1; j <= lnOfPr; j++ ) { - - Handle(Graphic2d_Primitive) thePrm = theIO->Primitive( j ); - Handle( Prs2d_AspectRoot ) theAsp = theIO->GetAspect( thePrm ); - - if ( thePrm->IsKind( STANDARD_TYPE( Graphic2d_Line ) ) ) { - Handle(Prs2d_AspectLine) theAL = Handle(Prs2d_AspectLine)::DownCast( theAsp ); - Quantity_Color theColor; - Aspect_TypeOfLine theTOL; - Aspect_WidthOfLine theWOL; - theAL->ValuesOfLine( theColor, theTOL, theWOL ); - Standard_Real R1, R2, R3; - theColor.Values( R1, R2, R3, Quantity_TOC_RGB ); - - } else if ( thePrm->IsKind( STANDARD_TYPE( Graphic2d_Paragraph ) ) ) { - - } else if ( thePrm->IsKind( STANDARD_TYPE( Graphic2d_Image ) ) ) { - - } else if ( thePrm->IsKind( STANDARD_TYPE( Graphic2d_ImageFile ) ) ) { - - } else if ( thePrm->IsKind( STANDARD_TYPE( Graphic2d_Text ) ) ) { - - Handle(Prs2d_AspectText) theAT = Handle(Prs2d_AspectText)::DownCast( theAsp ); - Quantity_Color aColor; - Aspect_FontStyle aFont; - Quantity_PlaneAngle aSlant; - Aspect_TypeOfText aType; - Standard_Boolean isUnderlined; - theAT->Values( aColor, aFont, aSlant, aType, isUnderlined ); - } - }*/ - } - ofs->close(); - } //if sequence of displyed objects isn't empty - } // if context isn't NULL - return Standard_False; -} - - Handle (AIS2D_InteractiveObject) - AIS2D::Retrieve( const Handle(AIS2D_InteractiveContext)& /*aCntx*/, - const Standard_CString aFile ) -{ - char buf[100]; - Aspect_IFStream ifs = new ifstream; - Handle(AIS2D_InteractiveObject) theIO; - ifs->open(aFile, ios::in); - ifs->getline(buf, 100); - while (! ifs->eof()) - { - if (! strcmp(buf, "AIS2D_InteractiveObject")) - { - theIO = new AIS2D_InteractiveObject(); - theIO->Retrieve(ifs); - } - ifs->getline(buf, 100); - } - ifs->close(); - - return theIO; -} diff --git a/src/AIS2D/AIS2D_GlobalStatus.cdl b/src/AIS2D/AIS2D_GlobalStatus.cdl deleted file mode 100755 index e57cb0743d..0000000000 --- a/src/AIS2D/AIS2D_GlobalStatus.cdl +++ /dev/null @@ -1,159 +0,0 @@ --- Created by: Tanya COOL --- Copyright (c) 2000-2012 OPEN CASCADE SAS --- --- The content of this file is subject to the Open CASCADE Technology Public --- License Version 6.5 (the "License"). You may not use the content of this file --- except in compliance with the License. Please obtain a copy of the License --- at http://www.opencascade.org and read it completely before using this file. --- --- The Initial Developer of the Original Code is Open CASCADE S.A.S., having its --- main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. --- --- The Original Code and all software distributed under the License is --- distributed on an "AS IS" basis, without warranty of any kind, and the --- Initial Developer hereby disclaims all such warranties, including without --- limitation, any warranties of merchantability, fitness for a particular --- purpose or non-infringement. Please see the License for the specific terms --- and conditions governing the rights and limitations under the License. - - -private class GlobalStatus from AIS2D inherits TShared from MMgt - - ---Purpose: Stores information about objects in graphic context: - -- - Status Of Display : in the main viewer - -- in the collector - -- fully Erased - -- - Displayed Modes - -- - Active Selection Modes - -- - is the Interactive Object Current ? - -- - Layer Index - - -uses - - ListOfInteger from TColStd, - PToListOfInt from AIS2D, - DisplayStatus from AIS2D, - NameOfColor from Quantity - -is - - Create returns mutable GlobalStatus from AIS2D; - ---Purpose: Initialize GlobalStatus the default properties - - Create( aStat : DisplayStatus from AIS2D; - aDMode : Integer from Standard; - aSMode : Integer from Standard; - isHighlight : Boolean from Standard=Standard_False; - aHighlCol : NameOfColor from Quantity = Quantity_NOC_WHITE; - aLayerIndex : Integer from Standard = 0) - returns mutable GlobalStatus from AIS2D; - ---Purpose: Initialize GlobalStatus the concrete properties - - SetGraphicStatus( me: mutable; aStat : DisplayStatus from AIS2D ); - ---C++: inline - ---Level: Internal - ---Purpose: Sets the graphic status - - AddDisplayMode( me: mutable; aMode: Integer from Standard ); - ---Level: Internal - ---Purpose: Adds the display mode to the list of display modes - - RemoveDisplayMode( me: mutable; aMode: Integer from Standard); - ---Level: Internal - ---Purpose: Removes the display mode from the list of display modes - - IsDModeIn( me; aMode: Integer from Standard ) returns Boolean from Standard; - ---Level: Internal - ---Purpose: Returns True if the list of display modes - -- contains the display mode - - AddSelectionMode( me: mutable; aMode: Integer from Standard ); - ---Level: Internal - ---Purpose: Adds the selection mode to the list of selection modes - - RemoveSelectionMode( me: mutable; aMode: Integer from Standard ); - ---Level: Internal - ---Purpose: Removes the selection mode from the list of selection modes - - ClearSelectionModes( me: mutable ); - ---Level: Internal - ---Purpose: Removes all selection modes from the list of selection modes - - IsSModeIn( me; aMode: Integer from Standard ) returns Boolean from Standard; - ---Level: Internal - ---Purpose: Returns True if the list of selection modes - -- contains the selection mode - - SetLayerIndex( me: mutable; anIndex: Integer from Standard ); - ---C++: inline - ---Level: Internal - ---Purpose: Sets the layer index - - SetHighlightStatus( me: mutable; aStat: Boolean from Standard ); - ---C++: inline - ---Level: Internal - ---Purpose: Sets the highlight status - - SetHighlightColor( me: mutable; aHiCol: NameOfColor from Quantity ); - ---C++: inline - ---Level: Internal - ---Purpose: Sets the color of highight - - IsSubIntensityOn( me ) returns Boolean from Standard; - ---C++: inline - ---Level: Internal - ---Purpose: Return True if SubIntensity is on - - SubIntensityOn( me: mutable ); - ---C++: inline - ---Level: Internal - ---Purpose: Sets the SubIntensity - - SubIntensityOff( me: mutable ); - ---C++: inline - ---Level: Internal - ---Purpose: Unsets the SubIntensity - - GraphicStatus( me ) returns DisplayStatus from AIS2D; - ---C++: inline - ---Level: Internal - ---Purpose: Indicates the display status - - DisplayedModes( me: mutable ) returns PToListOfInt from AIS2D; - ---C++: inline - ---Level: Internal - ---Purpose: keeps the information of displayed modes in the - -- main viewer. - -- (The convention is that the object is displayed - -- with the mode 0 in the collector...) - - SelectionModes( me: mutable ) returns PToListOfInt from AIS2D; - ---C++: inline - ---Level: Internal - ---Purpose: keeps the active selection modes of the object - -- in the main viewer. - -- (The convention is that the active selection mode - -- for an object in the collector is the mode 0). - - IsHighlight(me) returns Boolean from Standard; - ---C++: inline - ---Level: Internal - ---Purpose: Returns True if highlight is on - - HighlightColor( me ) returns NameOfColor from Quantity; - ---C++: inline - ---Level: Internal - ---Purpose: Returns the color of highlight - -fields - - myStatus : DisplayStatus from AIS2D; - myDispModes : ListOfInteger from TColStd; - mySelModes : ListOfInteger from TColStd; - myLayerIndex : Integer from Standard; - myIsHighl : Boolean from Standard; - myHiCol : NameOfColor from Quantity; - mySubInt : Boolean from Standard; - -end GlobalStatus; diff --git a/src/AIS2D/AIS2D_GlobalStatus.cxx b/src/AIS2D/AIS2D_GlobalStatus.cxx deleted file mode 100755 index df6ae02245..0000000000 --- a/src/AIS2D/AIS2D_GlobalStatus.cxx +++ /dev/null @@ -1,97 +0,0 @@ -// Copyright (c) 1999-2012 OPEN CASCADE SAS -// -// The content of this file is subject to the Open CASCADE Technology Public -// License Version 6.5 (the "License"). You may not use the content of this file -// except in compliance with the License. Please obtain a copy of the License -// at http://www.opencascade.org and read it completely before using this file. -// -// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its -// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. -// -// The Original Code and all software distributed under the License is -// distributed on an "AS IS" basis, without warranty of any kind, and the -// Initial Developer hereby disclaims all such warranties, including without -// limitation, any warranties of merchantability, fitness for a particular -// purpose or non-infringement. Please see the License for the specific terms -// and conditions governing the rights and limitations under the License. - -#include -#include - -static TColStd_ListIteratorOfListOfInteger It; - - -AIS2D_GlobalStatus::AIS2D_GlobalStatus(): - - myStatus( AIS2D_DS_None ), - myDispModes(), - mySelModes(), - myLayerIndex( 0 ), - myIsHighl( Standard_False ), - myHiCol( Quantity_NOC_WHITE ), - mySubInt( Standard_False ) -{ -} - -AIS2D_GlobalStatus::AIS2D_GlobalStatus( - const AIS2D_DisplayStatus DS, - const Standard_Integer DMode, - const Standard_Integer SMode, - const Standard_Boolean /*isHighlight*/, - const Quantity_NameOfColor aHighlCol, - const Standard_Integer aLayerIndex ): - myStatus( DS ), - myLayerIndex( aLayerIndex ), - myIsHighl( Standard_False ), - myHiCol( aHighlCol ), - mySubInt( Standard_False ) -{ - myDispModes.Append( DMode ); - mySelModes.Append( SMode ); -} - - -void AIS2D_GlobalStatus::RemoveDisplayMode( const Standard_Integer aMode ) { - - for ( It.Initialize( myDispModes ); It.More(); It.Next() ) - if ( It.Value() == aMode ) { - myDispModes.Remove( It ); - return; - } -} - -void AIS2D_GlobalStatus::RemoveSelectionMode( const Standard_Integer aMode) { - - for ( It.Initialize( mySelModes ); It.More(); It.Next() ) - if ( It.Value() == aMode ) { - mySelModes.Remove( It ); - return; - } -} - -void AIS2D_GlobalStatus::ClearSelectionModes() { - mySelModes.Clear(); -} - -void AIS2D_GlobalStatus::AddSelectionMode( const Standard_Integer aMode ) { - if ( !IsSModeIn( aMode ) ) - mySelModes.Append( aMode ); -} - -Standard_Boolean AIS2D_GlobalStatus::IsDModeIn( const Standard_Integer aMode) const { - for ( It.Initialize( myDispModes ); It.More(); It.Next() ) - if ( It.Value() == aMode ) return Standard_True; - return Standard_False; -} - -Standard_Boolean AIS2D_GlobalStatus::IsSModeIn( const Standard_Integer aMode) const { - for ( It.Initialize( mySelModes ); It.More(); It.Next() ) - if ( It.Value() == aMode ) return Standard_True; - return Standard_False; -} - -void AIS2D_GlobalStatus::AddDisplayMode( const Standard_Integer aMode ) { - if ( !IsDModeIn( aMode ) ) - myDispModes.Append( aMode ); -} - diff --git a/src/AIS2D/AIS2D_GlobalStatus.lxx b/src/AIS2D/AIS2D_GlobalStatus.lxx deleted file mode 100755 index cc00645c8d..0000000000 --- a/src/AIS2D/AIS2D_GlobalStatus.lxx +++ /dev/null @@ -1,64 +0,0 @@ -// Copyright (c) 1999-2012 OPEN CASCADE SAS -// -// The content of this file is subject to the Open CASCADE Technology Public -// License Version 6.5 (the "License"). You may not use the content of this file -// except in compliance with the License. Please obtain a copy of the License -// at http://www.opencascade.org and read it completely before using this file. -// -// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its -// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. -// -// The Original Code and all software distributed under the License is -// distributed on an "AS IS" basis, without warranty of any kind, and the -// Initial Developer hereby disclaims all such warranties, including without -// limitation, any warranties of merchantability, fitness for a particular -// purpose or non-infringement. Please see the License for the specific terms -// and conditions governing the rights and limitations under the License. - -inline void AIS2D_GlobalStatus::SetGraphicStatus( const AIS2D_DisplayStatus aStat ) { - myStatus = aStat; -} - -inline void AIS2D_GlobalStatus::SetLayerIndex( const Standard_Integer AnIndex ) { - myLayerIndex=AnIndex; -} - -inline void AIS2D_GlobalStatus::SetHighlightStatus( const Standard_Boolean aStat ) { - myIsHighl = aStat; -} - -inline void AIS2D_GlobalStatus::SetHighlightColor( const Quantity_NameOfColor aCol ) { - myHiCol = aCol; -} - -inline Standard_Boolean AIS2D_GlobalStatus::IsSubIntensityOn() const { - return mySubInt; -} - -inline void AIS2D_GlobalStatus::SubIntensityOn() { - mySubInt = Standard_True; -} -inline void AIS2D_GlobalStatus::SubIntensityOff() { - mySubInt = Standard_False; -} - -inline AIS2D_DisplayStatus AIS2D_GlobalStatus::GraphicStatus() const { - return myStatus; -} - -inline AIS2D_PToListOfInt AIS2D_GlobalStatus::DisplayedModes() { - return & myDispModes; -} - -inline AIS2D_PToListOfInt AIS2D_GlobalStatus::SelectionModes() { - return & mySelModes; -} - -inline Standard_Boolean AIS2D_GlobalStatus::IsHighlight() const { - return myIsHighl; -} - -inline Quantity_NameOfColor AIS2D_GlobalStatus::HighlightColor() const { - return myHiCol; -} - diff --git a/src/AIS2D/AIS2D_InteractiveContext.cdl b/src/AIS2D/AIS2D_InteractiveContext.cdl deleted file mode 100755 index 5bf6dadb1f..0000000000 --- a/src/AIS2D/AIS2D_InteractiveContext.cdl +++ /dev/null @@ -1,776 +0,0 @@ --- Created by: Tanya COOL --- Copyright (c) 2000-2012 OPEN CASCADE SAS --- --- The content of this file is subject to the Open CASCADE Technology Public --- License Version 6.5 (the "License"). You may not use the content of this file --- except in compliance with the License. Please obtain a copy of the License --- at http://www.opencascade.org and read it completely before using this file. --- --- The Initial Developer of the Original Code is Open CASCADE S.A.S., having its --- main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. --- --- The Original Code and all software distributed under the License is --- distributed on an "AS IS" basis, without warranty of any kind, and the --- Initial Developer hereby disclaims all such warranties, including without --- limitation, any warranties of merchantability, fitness for a particular --- purpose or non-infringement. Please see the License for the specific terms --- and conditions governing the rights and limitations under the License. - - --- Modified: EAV: 07-09-01 : NbSelected(), InitSelected(), --- MoreSelected(), NextSelected() - --- SAV: 15/11/01 MoveCircleTo(). detection by circle. SetDetectionMode(). --- Detect() - internal - -class InteractiveContext from AIS2D inherits TShared from MMgt - - ---Purpose: The InteractiveContext class allows you to manage - -- graphic behavior and selection of Interactive Objects - -- in one or more viewers. - -uses - - TypeOfLine from Aspect, - WidthOfLine from Aspect, - MarkerStyle from Aspect, - TypeOfMarker from Aspect, - FontStyle from Aspect, - GenericColorMap from Aspect, - TypeMap from Aspect, - WidthMap from Aspect, - MarkMap from Aspect, - FontMap from Aspect, - GridType from Aspect, - GridDrawMode from Aspect, - CardinalPoints from Aspect, - Color from Quantity, - PlaneAngle from Quantity, - Length from Quantity, - NameOfColor from Quantity, - ExtendedString from TCollection, - Primitive from Graphic2d, - PickMode from Graphic2d, - TransientManager from Graphic2d, - DisplayList from Graphic2d, - Viewer from V2d, - View from V2d, - Drawer from Prs2d, - InteractiveObject from AIS2D, - KindOfIO from AIS2D, - DataMapOfIOStatus from AIS2D, - DataMapOfLC from AIS2D, - StatusOfDetection from AIS2D, - DisplayStatus from AIS2D, - StatusOfPick from AIS2D, - TypeOfDetection from AIS2D, - PToListOfInt from AIS2D, - ListOfIO from AIS2D, - HSequenceOfIO from AIS2D - -is - - Create( MainViewer: Viewer from V2d ) - returns mutable InteractiveContext from AIS2D; - ---Purpose: Initiates - - Create( MainViewer, aCollector: Viewer from V2d) - returns mutable InteractiveContext from AIS2D; - ---Purpose: Initiates the principal viewer and Collector(trash) viewer together - - -- ************************************************************* - ---Category: Editing general Display Services - -- ************************************************************* - - Display( me : mutable; - anIObj : InteractiveObject from AIS2D; - UpdateVwr : Boolean from Standard = Standard_True); - ---Level: Public - ---Purpose: Display when no local context is opened. - -- if has no proper display mode, the defaut - -- display mode of the session is used - -- Same for the selection Mode (by default =0) - - Display( me : mutable; - anIObj : InteractiveObject from AIS2D; - aDispMode : Integer from Standard ; - aSelectMode : Integer from Standard; - UpdateVwr : Boolean from Standard = Standard_True; - AllowDecomp : Boolean from Standard = Standard_True); - ---Level: Public - ---Purpose: Use only if a local context is opened. Displays the - -- the presentation of interactive object, - -- activates the selection mode if - -- = Standard_False, the object is - -- displayed but no viewer will be updated; CONVENTION : - -- = -1 means no activation for - -- : it will be displayed but not selectable. (Option - -- only available for local context...) - -- = true means that is - -- able to have subshapes detected by selection mechanisms. - -- 2 conditions: must be able to give a shape - -- selection modes fit the AIS2D_Shape - -- selection modes ( 1->vertex, 2->edges, 3->wires...) - - Load( me: mutable; - anIObj: InteractiveObject from AIS2D; - SelMode : Integer from Standard = -1; - AllowDecomp : Boolean from Standard = Standard_False ); - ---Purpose: Available when opened local contexts only; - -- option to load in the selector objects which will - -- be selectable but not displayed. Nevertheless, they - -- will be hilighted when detected by the selector. - -- ex : be able to select center of a line without - -- displaying all centers before selection process - - Erase( me : mutable; - anIObj : InteractiveObject from AIS2D; - UpdateVwr : Boolean from Standard = Standard_True; - PutInCollector : Boolean from Standard = Standard_True ); - ---Level: Public - ---Purpose: Erases presentations in current local context, - -- or failing that, in other local contexts which allow erasing. - -- If is false, the object is erased but - -- not put in the Collector. - - EraseAll( me : mutable; - PutInCollector : Boolean from Standard = Standard_True; - updateVwr : Boolean from Standard = Standard_True ); - ---Purpose: Every erased object goes into the Collector viewer - - DisplayAll( me : mutable; - OnlyFromCollector : Boolean from Standard = Standard_True; - updateVwr : Boolean from Standard = Standard_True); - ---Purpose: Displays all erased objects, in other words, - -- all objects in the Collector viewer. - - EraseSelected( me : mutable; - PutInCollector : Boolean from Standard = Standard_True; - updateVwr : Boolean from Standard = Standard_True ); - ---Purpose: Erases selected objects if a local context is open. - -- Erases current objects if there is no active local context. - -- If a local context is open and if equals - -- Standard_False, the presentation of the Interactive Object - -- activates the selection mode; the object is displayed but - -- no viewer will be updated. - - DisplaySelected( me : mutable; - updateVwr : Boolean from Standard = Standard_True ); - ---Purpose: Displays or erases selected objects if a local - -- context is open. If no active local context is found, - -- only current objects can be displayed or erased. - - KeepTemporary( me : mutable; - anIObj : InteractiveObject from AIS2D; - InWhichLocal: Integer from Standard = -1) - returns Boolean from Standard; - ---Purpose: Changes the status of a temporary object it will be -- - -- kept at the neutral point, i.e. put in the list of - -- displayed objects, with its temporary attributes - -- (displaymode,selection mode) returns true if done -- - -- inWhichLocal means that gives the local context in - -- which is displayed. By default, -1 means the - -- last opened one - - Redisplay( me : mutable; - anIObj : InteractiveObject from AIS2D; - updateVwr : Boolean from Standard = Standard_True; - allModes : Boolean from Standard = Standard_False); - ---Purpose: Forces Recompute of the seen presentations of the object; - -- if = True -> recomputes all the - -- presentations . - - --*********************************************************************** - ---Category: Querying and Editing Selection Process - --*********************************************************************** - - IsCurrent( me; anIObj: InteractiveObject from AIS2D ) - returns Boolean from Standard; - ---Purpose: Finds the current selected entity in Neutral Point. - - IsSelected( me; anIObj: InteractiveObject from AIS2D ) - returns Boolean from Standard; - ---Purpose: Confirms selection. Returns true if is selected in the interactive context - - Highlight( me : mutable; - anIObj : InteractiveObject from AIS2D; - updateVwr: Boolean from Standard = Standard_True); - ---Purpose: Updates the display in the viewer to take dynamic detection - -- into account. - -- If a local context is open and if equals Standard_False, - -- the presentation of the Interactive Object activates the selection - -- mode; the object is displayed but no viewer will be updated. - - HighlightWithColor( me: mutable; - anIObj:InteractiveObject from AIS2D; - aCol: NameOfColor from Quantity; - updateVwr: Boolean from Standard = Standard_True ); - ---Purpose: Changes the color of the object in view . - -- It paints this object the color passed as the argument - -- If a local context is open and if equals Standard_False, - -- the presentation of the Interactive Object activates the selection - -- mode; the object is displayed but no viewer will be updated. - - Unhighlight( me : mutable; - anIObj : InteractiveObject from AIS2D; - updateVwr : Boolean from Standard = Standard_True ); - ---Purpose: Removes hilighting from the entity . Updates the viewer. - -- If a local context is open and if equals Standard_False, - -- the presentation of the Interactive Object activates the selection - -- mode; the object is displayed but no viewer will be updated. - - - --**************************************************************** - ---Category: Graphic Detection and Selection - --**************************************************************** - - SetPrecision( me: mutable; aPrec: Integer from Standard ); - ---C++: inline - ---Level: Public - ---Purpose: Sets the precision of detection - - DetectPrecision( me ) returns Integer from Standard; - ---C++: inline - ---Level: Public - ---Purpose: Returns the precision of detection - - Place( me : mutable; - XPix, YPix : Integer from Standard; - aView : View from V2d; - anIO : InteractiveObject from AIS2D; - isTemporary : Boolean from Standard = Standard_False ); - ---Level: Public - ---Purpose: Places object to the pixel position (XPix, YPix) - -- in the view is using TransientManager. - -- It's possible to use without preliminary application of Display method. - - Drag( me : mutable; - XPix, YPix : Integer from Standard; - aView : View from V2d; - isTemporary: Boolean from Standard = Standard_True ); - ---Level: Public - ---Purpose: Places selected objects to the pixel position (XPix, YPix) - -- in the view . If is True, is used TransientManager. - - MoveTo( me: mutable; - XPix, YPix: Integer from Standard; - aView: View from V2d ) returns StatusOfDetection from AIS2D; - ---Level: Public - ---Purpose: Relays mouse position in pixels XPix and YPix to the - -- interactive context selectors. This is done by the view - -- passing this position to the main viewer and updating it. - -- Functions in both Neutral Point and local contexts. - - ---SAV - MoveCircleTo( me: mutable; XPix, YPix, Radius : Integer from Standard; - aView: View from V2d ) returns StatusOfDetection from AIS2D; - ---Level: Public - ---Purpose: Relays mouse position in circle and to the - -- interactive context selectors. This is done by the view - -- passing this position to the main viewer and updating it. - -- Functions in both Neutral Point and local contexts. - - MoveTo( me: mutable; - Xmin, Ymin, Xmax, Ymax: Integer from Standard; - aView: View from V2d ) returns StatusOfDetection from AIS2D; - ---Level: Public - ---Purpose: Relays mouse position in rectangle Xmin, Ymin, Xmax, Ymax to the - -- interactive context selectors. This is done by the view - -- passing this position to the main viewer and updating it. - -- Functions in both Neutral Point and local contexts. - - - ---SAV - Detect( me: mutable; dList : DisplayList from Graphic2d; aView : View from V2d ) - returns StatusOfDetection from AIS2D is private; - - Select( me : mutable; - UpdateVwr : Boolean from Standard = Standard_True) - returns StatusOfPick from AIS2D; - ---Level: Public - ---Purpose: Stores and hilights the previous detected; Unhilights - -- the previous picked. - - ShiftSelect( me: mutable; UpdateVwr: Boolean from Standard = Standard_True ) - returns StatusOfPick from AIS2D; - ---Level: Public - ---Purpose: adds the last detected to the list of previous picked. - -- if the last detected was already declared as picked, - -- removes it from the Picked List. - - ShiftSelect( me: mutable; XPMin, YPMin, XPMax, YPMax: Integer from Standard; - aView: View from V2d; UpdateVwr : Boolean from Standard = Standard_True) - returns StatusOfPick from AIS2D; - ---Level: Public - ---Purpose: rectangle of selection ; adds new detected entities into the - -- picked list, removes the detected entities that were already stored... - - - SetHighlightColor( me: mutable; aCol: NameOfColor from Quantity ); - ---Purpose: Allows to set the color used to show highlighted entities, - -- that is, entities picked out by the mouse. - - SetSelectionColor( me: mutable; aCol: NameOfColor from Quantity ); - ---Purpose: Sets the color used to show selected entities - - SetSubIntensityColor( me: mutable; aCol: NameOfColor from Quantity ); - ---Purpose: Allows you to set the color used to show that an object - -- is not currently selected - - DisplayMode( me ) returns Integer from Standard; - ---C++: inline - ---Purpose: Returns the display mode setting - - HighlightColor( me ) returns NameOfColor from Quantity; - ---C++: inline - ---Level: Public - ---Purpose: Returns the name of the color used to show highlighted entities, - -- that is, entities picked out by the mouse - - SelectionColor( me ) returns NameOfColor from Quantity; - ---C++: inline - ---Level: Public - ---Purpose: Returns the name of the color used to show selected entities. - - SubIntensityColor( me ) returns NameOfColor from Quantity; - ---C++: inline - ---Level: Public - ---Purpose: Returns the name of the color used to show - -- that an object is not currently selected. - - SubIntensityOn( me : mutable; - anIObj : InteractiveObject from AIS2D; - UpdateVwr : Boolean from Standard = Standard_True); - ---Level: Public - ---Purpose: Highlights, and removes highlights from, the displayed object - -- which is displayed at Neutral Point with subintensity - -- color; available only for active local context. - -- There is no effect if there is no local context. - - SubIntensityOff( me : mutable; - anIObj : InteractiveObject from AIS2D; - UpdateVwr : Boolean from Standard = Standard_True); - ---Level: Public - ---Purpose: Removes the subintensity option for the entity . - - - -- ************************************************************* - -- Management of the Trash Bin Viewer - -- ************************************************************* - - IsCollectorClosed( me ) returns Boolean from Standard; - ---C++: inline - ---Level: Internal - ---Purpose: - - CloseCollector( me: mutable ); - ---C++: inline - ---Level: Internal - ---Purpose: Allows to close Collector - - OpenCollector( me: mutable ); - ---Level: Internal - ---Purpose: Allows to open Collector - - --************************************************************************ - ---Category: Specific Local Context Action - --************************************************************************ - - OpenLocalContext( me : mutable; - UseDispObj : Boolean from Standard = Standard_True; - AllowDecomposit : Boolean from Standard = Standard_True; - AcceptEraseOfObj: Boolean from Standard = Standard_False ) - returns Integer from Standard; - ---Level: Public - ---Purpose: Opens a local context of display and selection - -- returns the index of new opened local context. - -- Must be stored and used to close the local context. - - CloseLocalContext( me : mutable; - ind : Integer from Standard = -1; - updateVwr : Boolean from Standard = Standard_True ); - ---Level: Public - ---Purpose: close the current opened local context. - -- Use to be sure to close the local context you Opened ! - -- if == -1 the current local context is closed - -- WITHOUT VERIFICATION. - -- if is greater than the current opened local context, - -- nothing is done. - - IndexOfCurrentLocal( me ) returns Integer from Standard; - ---Level: Public - ---Purpose: returns -1 if no opened local context. - - CloseAllContext( me: mutable; updateVwr: Boolean from Standard = Standard_True); - ---Level: Public - ---Purpose: Allows to close all local contexts at one go and return to - -- Neutral Point. - - --**************************************************************** - ---Category: non interactive actions about Selection - -- 2 categories are distinct: - -- - Current Objects - -- - Selected Objects - -- a Current object is the object picked - -- at neutral Point. - -- The Selected objects are objects picked - -- when a local context is opened - - - SetCurrentObject( me : mutable; - anIObj : InteractiveObject from AIS2D; - UpdateVwr: Boolean from Standard = Standard_True ); - ---Level: Public - ---Purpose: Updates the view of the current object in open context. - -- Objects selected when there is no open local context - -- are called current objects; those selected in open local context, - -- selected objects. - - AddOrRemoveCurObject( me : mutable; - anIObj : InteractiveObject from AIS2D; - UpdateVwr : Boolean from Standard = Standard_True); - ---Level: Public - ---Purpose: Allows to add a current object to the list of current objects - -- or remove it from that list. - -- Objects selected when there is no open local context are called - -- current objects; those selected in open local context, - -- selected objects. - - - UpdateCurrent( me: mutable ); - ---Level: Public - ---Purpose: updates the list of current objects - -- i.e. hilights new current objects, - -- unhighlights old current objects - -- - - SetOkCurrent( me: mutable ); - ---Level: Internal - ---Purpose: - - --FirstCurrentObject( me: mutable ) returns InteractiveObject from AIS2D; - ---Level: Public - ---Purpose: Returns the first current object in the list of current objects. - - HighlightCurrent( me: mutable; - UpdateVwr: Boolean from Standard = Standard_True); - ---Level: Public - ---Purpose: Highlights current objects. - - UnhighlightCurrent( me: mutable; - UpdateVwr: Boolean from Standard = Standard_True); - ---Level: Public - ---Purpose: Unhighlights current objects. - - ClearCurrent(me: mutable; UpdateVwr: Boolean from Standard = Standard_True); - ---Level: Public - ---Purpose: Empties previous current objects in order to get the current - -- objects detected by the selector using UpdateCurrent. - - SetSelected( me: mutable; anIObj: InteractiveObject from AIS2D; - UpdateVwr: Boolean from Standard = Standard_True ); - ---Level: Public - ---Purpose: Puts the selected in the current objects list. - - SetSelectedCurrent( me: mutable ); - ---Level: Public - ---Purpose: Puts the selected list in the current objects list. - - UpdateSelected( me: mutable; - UpdateVwr: Boolean from Standard=Standard_True ); - ---Level: Public - ---Purpose: Updates the list of selected objects, i.e. hilights - -- new selected objects, removes hilighting from former - -- selected objects. - - AddOrRemoveSelected( me: mutable; - anIObj : InteractiveObject from AIS2D; - UpdateVwr: Boolean from Standard = Standard_True); - ---Level: Public - ---Purpose: Allows you to add a selected object to the list of selected - -- objects or remove it from that list. - - HighlightSelected( me: mutable; - UpdateVwr: Boolean from Standard = Standard_True); - ---Level: Public - ---Purpose: Highlights selected objects. - - UnhighlightSelected( me: mutable; - UpdateVwr: Boolean from Standard = Standard_True ); - ---Level: Public - ---Purpose: UnHighlights selected objects. - - ClearSelected( me: mutable; - UpdateVwr: Boolean from Standard = Standard_True); - ---Level: Public - ---Purpose: Empties previous selected objects in order to get - -- the selected objects detected by the selector using UpdateSelected. - - NbSelected( me ) returns Integer from Standard; - ---Level: Public - ---Purpose: Returns number of objects selected in - --- local context ( if opened ) or in neutral context - - InitSelected( me: mutable ); - ---Level: Public - ---Purpose: Iteration - - MoreSelected( me ) returns Boolean from Standard; - ---Level: Public - ---Purpose: Iteration - - NextSelected( me: mutable ); - ---Level: Public - ---Purpose: Iteration - - SelectedObject( me ) returns TShared from MMgt; - ---Level: Public - ---Purpose: Returns current selected object ( see InitSelected() .. ) - -- The object type depends on highlight mode - -- ( OBJECT, PRIMITIVE etc ) - - - --***************************************************************** - -- Querying Graphic Attributes - --***************************************************************** - - DisplayStatus( me; anIObj: InteractiveObject from AIS2D ) - returns DisplayStatus from AIS2D; - ---Level: Public - ---Purpose: Returns the display status of the entity . - - DisplayedModes( me; anIObj: InteractiveObject from AIS2D ) - returns PToListOfInt from AIS2D; - ---Level: Public - ---Purpose: Returns the list of active display modes for the entity - - IsDisplayed( me; anIObj:InteractiveObject from AIS2D ) - returns Boolean from Standard; - ---Level: Public - ---Purpose: Returns true if is displayed in the interactive context - - IsDisplayed( me; - anIObj: InteractiveObject from AIS2D; - aMode : Integer from Standard ) - returns Boolean from Standard; - - ---Level: Public - ---Purpose: Returns true if is displayed in the interactive context with display mode - - IsHighlighted( me; anIObj: InteractiveObject from AIS2D ) - returns Boolean from Standard; - ---Level: Public - ---Purpose: Returns true if the Interactive Object - -- is highlighted in the interactive context. - - IsHighlighted( me; - anIObj : InteractiveObject from AIS2D; - WithColor : out Boolean from Standard; - theHiCol : out NameOfColor from Quantity ) - returns Boolean from Standard; - ---Level: Public - ---Purpose: if is highlighted with a specific color - -- will be returned TRUE - -- gives the name of the hilightcolor - - IsInCollector( me; anIObj: InteractiveObject from AIS2D ) - returns Boolean from Standard; - ---Level: Public - ---Purpose: Returns true if the entity is in the Collector viewer. - - Status( me; - anIObj : InteractiveObject from AIS2D; - aStatus: in out ExtendedString from TCollection); - ---Level: Public - ---Purpose: Modified the status of the entity - - UpdateCurrentViewer( me: mutable ); - ---Level: Public - ---Purpose: Updates the current viewer, the viewer in Neutral Point. - - UpdateCollector( me: mutable ); - ---Level: Public - ---Purpose: Updates the Collector viewer - - --******************************************************************************** - ---Category: Information methods - Get Fields - --******************************************************************************** - - CurrentViewer( me ) returns any Viewer from V2d; - ---C++: inline - ---Level: Public - ---Purpose: Returns the current viewer. - - HasOpenedContext( me ) returns Boolean from Standard; - ---C++: inline - ---Level: Public - ---Purpose: Returns true if there is an open context. - - DisplayedObjects( me; - aListOfIO : in out ListOfIO from AIS2D; - OnlyFromNeutral : Boolean from Standard = Standard_False ); - ---Level: Public - ---Purpose: gives the list of displayed objects in the main viewer. - - --******************************************************************************** - - GetDefModes( me; - anIObj : InteractiveObject from AIS2D; - Dmode : out Integer from Standard; - HiMod : out TypeOfDetection from AIS2D; - SelMode : out Integer from Standard ) is private; - ---Level: Public - ---Purpose: Returns display, highlight and selection modes of the - - EraseGlobal( me : mutable; - anIObj : InteractiveObject from AIS2D; - UpdateVwr : Boolean from Standard = Standard_True; - PutInCollector : Boolean from Standard = Standard_True) is private; - ---Level: Internal - ---Purpose: - - SetPickMode( me: mutable; aMode: PickMode from Graphic2d ); - ---C++: inline - ---Level: Public - ---Purpose: Allows to provide settings for pick mode. - - GetPickMode( me) returns PickMode from Graphic2d; - ---C++: inline - ---Level: Public - ---Purpose: Returns the pick mode - - - --********************************************************************************** - - HighestIndex( me ) returns Integer from Standard; - ---Level: Internal - ---Purpose: - - --********************************************************************************** - -- Category: initialization of the attributes - --********************************************************************************** - - InitializeColor( me: mutable; aColor: Color from Quantity ) returns Integer from Standard; - ---Purpose: Initialize in the color map - - InitializeStyle( me: mutable; aType: TypeOfLine from Aspect ) returns Integer from Standard; - ---Purpose: Initialize in the type map - - InitializeWidth( me: mutable; aWidth: WidthOfLine from Aspect ) returns Integer from Standard; - ---Purpose: Initialize in the width map - - InitializeMarker( me: mutable; aMark: TypeOfMarker from Aspect ) returns Integer from Standard; - ---Purpose: Initialize in the mark map - - InitializeFont( me: mutable; aFont: FontStyle from Aspect ) returns Integer from Standard; - ---Purpose: Initialize in the font map - - --********************************************************************************** - ResetOriginalState( me : mutable; - updateVwr : Boolean from Standard = Standard_True ); - ---Level: Public - ---Purpose: to be used only with no opened - -- local context.. displays and activates objects in their - -- original state before local contexts were opened... - - - DrawObject( me: mutable; anObj: InteractiveObject from AIS2D; aDispMode: Integer from Standard ) - is private; - - AvailableToDetect( me; anObj: InteractiveObject from AIS2D ) returns Boolean from Standard - is private; - DoDetectObject( me: mutable; anObj: InteractiveObject from AIS2D; aDrawer: TransientManager from Graphic2d ) - is private; - IsIOPicked( me; anObj: InteractiveObject from AIS2D ) - returns Boolean from Standard is private; - IsPrimPicked( me; anObj: InteractiveObject from AIS2D; aPrim: Primitive from Graphic2d ) - returns Boolean from Standard is private; - IsElemPicked( me; anObj: InteractiveObject from AIS2D; - aPrim: Primitive from Graphic2d; ind: Integer from Standard ) - returns Boolean from Standard is private; - IsElemSelected( me; anObj: InteractiveObject from AIS2D; - aPrim: Primitive from Graphic2d; ind: Integer from Standard ) - returns Boolean from Standard is private; - - IsIOSelected( me; anObj: InteractiveObject from AIS2D ) - returns Boolean from Standard is private; - IsPrimSelected( me; anObj: InteractiveObject from AIS2D; - aPrim: Primitive from Graphic2d ) - returns Boolean from Standard is private; - - --********************************************************************************** - -- Category: immediate mode management - --********************************************************************************** - - BeginImmediateDraw( me: mutable; aView: View from V2d ); - ---Level: Public - ---Purpose: switches on immediate mode - - ImmediateDraw(me: mutable; anIObj: InteractiveObject from AIS2D; aView: View from V2d ); - ---Level: Public - ---Purpose: draws object into immediate mode - - EndImmediateDraw( me: mutable; aView: View from V2d ); - ---Level: Public - ---Purpose: switches of immediate mode - - IsImmediateModeOn( me; aView: View from V2d ) returns Boolean from Standard; - ---Level: Public - ---Purpose: returns true if immediate mode is on - - ---SAV - SetDetectionMode(me:mutable; mode : TypeOfDetection from AIS2D); - -fields - - myMainVwr : Viewer from V2d; - myCollectorVwr : Viewer from V2d; - myIsCollClosed : Boolean from Standard; - myObjects : DataMapOfIOStatus from AIS2D; - - -- the selection and current objects. - - myDetectPrecision: Integer from Standard; - myResetDetect : Boolean from Standard; - - myLastPicked : InteractiveObject from AIS2D; - myLastinMain : InteractiveObject from AIS2D; - myLastinColl : InteractiveObject from AIS2D; - - mySeqOfDetIO : HSequenceOfIO from AIS2D; - mySeqOfSelIO : HSequenceOfIO from AIS2D; - - myCurDetectMode : TypeOfDetection from AIS2D; - - myWasLastMain : Boolean from Standard; - myPickMode : PickMode from Graphic2d; - - -- the attributes of session... - - myHighlightColor : NameOfColor from Quantity; - mySelectionColor : NameOfColor from Quantity; - mySubIntensity : NameOfColor from Quantity; - myDisplayMode : Integer from Standard; - - -- The Local Context... - - myLocalContexts : DataMapOfLC from AIS2D; - myCurLocalIndex : Integer from Standard; - myLastMoveView : View from V2d; - - myColorMap : GenericColorMap from Aspect is protected; - myTypeMap : TypeMap from Aspect is protected; - myWidthMap : WidthMap from Aspect is protected; - myMarkMap : MarkMap from Aspect is protected; - myFontMap : FontMap from Aspect is protected; - - -- Iteration - - myCurSelected : Integer from Standard; - myMaxSelected : Integer from Standard; - -friends - - class LocalContext from AIS2D - -end InteractiveContext; diff --git a/src/AIS2D/AIS2D_InteractiveContext.cxx b/src/AIS2D/AIS2D_InteractiveContext.cxx deleted file mode 100755 index 6f0824aa60..0000000000 --- a/src/AIS2D/AIS2D_InteractiveContext.cxx +++ /dev/null @@ -1,2602 +0,0 @@ -// Copyright (c) 1999-2012 OPEN CASCADE SAS -// -// The content of this file is subject to the Open CASCADE Technology Public -// License Version 6.5 (the "License"). You may not use the content of this file -// except in compliance with the License. Please obtain a copy of the License -// at http://www.opencascade.org and read it completely before using this file. -// -// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its -// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. -// -// The Original Code and all software distributed under the License is -// distributed on an "AS IS" basis, without warranty of any kind, and the -// Initial Developer hereby disclaims all such warranties, including without -// limitation, any warranties of merchantability, fitness for a particular -// purpose or non-infringement. Please see the License for the specific terms -// and conditions governing the rights and limitations under the License. - -#define IMP140901 //GG 14/09/01 goback to avoid a regression -// See V2d_Viewer - -// SAV 14/11/01 - modification for detection/highlighting/selection elements of -// SetOf<>. Fully used for SetOfMarkers. - -#define OCC197 // jfa 01/03/2002 // for multiple selection of elements -#define OCC146 // jfa 01/03/2002 // for single selection two times -#define OCC154 // jfa 06/03/2002 // for correct erasing -#define OCC389 // vro 19/06/2002 // for Display(obj,dispMode...) setting a view for the IO - -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include - -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -//SAV -#include -#include - -static TColStd_ListIteratorOfListOfInteger ItL; -static Standard_Boolean RectMoveTo = Standard_False; - -AIS2D_InteractiveContext::AIS2D_InteractiveContext(const Handle(V2d_Viewer)& MainViewer): - - myMainVwr( MainViewer ), - myDetectPrecision( 4 ), - myResetDetect( Standard_True ), - myLastPicked(), - myLastinMain(), - myLastinColl(), - mySeqOfDetIO( new AIS2D_HSequenceOfIO() ), - mySeqOfSelIO( new AIS2D_HSequenceOfIO() ), - myCurDetectMode( AIS2D_TOD_NONE ), - myWasLastMain(), - myPickMode( Graphic2d_PM_INCLUDE ), - myHighlightColor( Quantity_NOC_CYAN1 ), - mySelectionColor( Quantity_NOC_GRAY80 ), - mySubIntensity( Quantity_NOC_GRAY40 ), - myDisplayMode( 0 ), - myLocalContexts( ), - myCurLocalIndex( 0 ), - myLastMoveView() , - myCurSelected( 0 ), - myMaxSelected( 0 ) -{ - - myMainVwr->View()->SetDefaultOverrideColor( myMainVwr->InitializeColor( mySelectionColor ) ); -} - -AIS2D_InteractiveContext::AIS2D_InteractiveContext(const Handle(V2d_Viewer)& MainViewer,const Handle(V2d_Viewer)& aCollector): - - myMainVwr( MainViewer ), - - myCollectorVwr( aCollector ), - myIsCollClosed( Standard_False ), - myDetectPrecision( 4 ), - myResetDetect( Standard_True ), - myLastPicked(), - myLastinMain(), - myLastinColl(), - mySeqOfDetIO( new AIS2D_HSequenceOfIO() ), - mySeqOfSelIO( new AIS2D_HSequenceOfIO() ), - myCurDetectMode( AIS2D_TOD_NONE ), - myWasLastMain(), - myPickMode( Graphic2d_PM_INCLUDE ), - myHighlightColor( Quantity_NOC_CYAN1 ), - mySelectionColor( Quantity_NOC_GRAY80 ), - mySubIntensity( Quantity_NOC_GRAY40 ), - myDisplayMode( 0 ), - myLocalContexts( ), - myCurLocalIndex( 0 ), - myLastMoveView() -{ - myMainVwr->View()->SetDefaultOverrideColor( myMainVwr->InitializeColor( mySelectionColor ) ); - myCollectorVwr->View()->SetDefaultOverrideColor( myMainVwr->InitializeColor( mySelectionColor ) ); -} - - - //************************************************************* - // Management of the Trash Bin Viewer - // ************************************************************* - - void AIS2D_InteractiveContext::OpenCollector() { - myIsCollClosed = Standard_False; - } - - - // ************************************************************* - // Editing general Display Services - // ************************************************************* - -void AIS2D_InteractiveContext::Display( const Handle(AIS2D_InteractiveObject)& anIObj, - const Standard_Boolean UpdateVwr ) { - - if ( anIObj.IsNull() ) return; - - Standard_Integer DispMode, SelMode; - AIS2D_TypeOfDetection HiMod; - Standard_Boolean UpdateCol; - Handle( AIS2D_GlobalStatus ) GStatus; - - GetDefModes( anIObj, DispMode, HiMod, SelMode ); - - if ( !anIObj->HasInteractiveContext() ) - anIObj->SetContext( this ); - - anIObj->SetView( myMainVwr->View() ); - - if ( !HasOpenedContext() ) { - - if ( IsDisplayed( anIObj ) ) return; - UpdateCol = Standard_False; - - if ( !myObjects.IsBound( anIObj ) ) { - - GStatus = new AIS2D_GlobalStatus( AIS2D_DS_Displayed, DispMode, 0); - myObjects.Bind( anIObj, GStatus ); - DrawObject( anIObj, DispMode ) ; - - } else { - - GStatus = myObjects( anIObj ); - switch ( GStatus->GraphicStatus() ) { - - case AIS2D_DS_Erased: { - - if ( GStatus->IsHighlight() ) - UpdateCol = UpdateVwr ; - } - case AIS2D_DS_FullErased: { - - for ( ItL.Initialize( * GStatus -> DisplayedModes()); ItL.More(); ItL.Next()) - if ( GStatus->IsSubIntensityOn() ) { - // Standard_Integer indCol = myMainVwr->InitializeColor(mySubIntensity); - // myMainPM->SetHighlightColor(indCol); - // myMainPM->ColorHighlight( anIObj, indCol, ItL.Value() ); - } - - for ( ItL.Initialize( * GStatus -> SelectionModes() ); ItL.More();ItL.Next() ) - // mySelectorMgr->Activate( anIObj, ItL.Value(), myMainSelector ); - GStatus->SetGraphicStatus( AIS2D_DS_Displayed ); - if ( GStatus->IsHighlight() ) - Highlight( anIObj, HiMod ); - break; - } - default: - break; - } // end switch - } //endif !myObjects.IsBound - - anIObj->Display(); - - if ( UpdateCol && !myCollectorVwr.IsNull() ) myCollectorVwr->UpdateNew(); - - } else { - - myLocalContexts( myCurLocalIndex )->Display( anIObj, DispMode, Standard_True,SelMode ); - - }//endif !HasOpenedContext - - if ( UpdateVwr ) myMainVwr->UpdateNew(); - -} - -void AIS2D_InteractiveContext::Display( - const Handle(AIS2D_InteractiveObject)& anIObj, - const Standard_Integer aDispMode, - const Standard_Integer aSelectMode, - const Standard_Boolean UpdateVwr, - const Standard_Boolean AllowDecomp) { - - if ( anIObj.IsNull() ) return; - if ( !anIObj->HasInteractiveContext() ) anIObj->SetContext(this); - -#ifdef OCC389 - anIObj->SetView(myMainVwr->View()); -#endif - - if ( !HasOpenedContext() ) { - - if ( !anIObj->HasDisplayMode() ) - anIObj->SetDisplayMode(aDispMode); - - if ( !myObjects.IsBound(anIObj) ) { - Handle(AIS2D_GlobalStatus) GStatus= - new AIS2D_GlobalStatus( AIS2D_DS_Displayed, aDispMode, aSelectMode ); - myObjects.Bind( anIObj, GStatus ); - DrawObject( anIObj, aDispMode ); - - if ( aSelectMode != -1 ) { - //if ( !mySelectorMgr->Contains( anIObj ) ) - // mySelectorMgr->Load( anIObj, myMainSelector,aSelectMode ); - //mySelectorMgr->Activate( anIObj, aSelectMode, myMainSelector ); - } - - anIObj->SetSelectionMode(aSelectMode); - - } else { - - Handle(AIS2D_GlobalStatus) GStatus = myObjects( anIObj ); - if ( !GStatus->IsDModeIn( aDispMode ) ) { - DrawObject( anIObj, aDispMode ); - GStatus->AddDisplayMode( aDispMode ); - if ( GStatus->IsSubIntensityOn() ) { -#ifdef DEB - Standard_Integer indCol = myMainVwr->InitializeColor(mySubIntensity); - //myMainPM->SetHighlightColor( indCol ); - //myMainPM->ColorHighlight( anIObj, indCol, aDispMode ); -#endif - } - } - if ( aSelectMode != -1 ) { - GStatus->AddSelectionMode( aSelectMode ); - //mySelectorMgr->Activate( anIObj, aSelectMode, myMainSelector ); - } - - } - anIObj->Display(); - } else - - myLocalContexts(myCurLocalIndex)->Display( anIObj, aDispMode, AllowDecomp, aSelectMode); - - if (UpdateVwr) myMainVwr->Update(); - -} - -void AIS2D_InteractiveContext::Redisplay( const Handle(AIS2D_InteractiveObject)& anIObj, - const Standard_Boolean updateVwr, - const Standard_Boolean /*allModes*/ ) { - - if ( anIObj.IsNull() ) return; - //anIObj->Update(allModes); - - if ( updateVwr ) { - if ( HasOpenedContext() ) - myMainVwr->Update(); - else { - if ( myObjects.IsBound( anIObj ) ) { - switch ( myObjects(anIObj)->GraphicStatus() ) { - case AIS2D_DS_Displayed: - DrawObject( anIObj, 0 ); - myMainVwr->Update(); - break; - case AIS2D_DS_Erased: - if ( !myCollectorVwr.IsNull() ) - myCollectorVwr->Update(); - default: - break; - } - } - } - } - -} - -void AIS2D_InteractiveContext::Load( - const Handle(AIS2D_InteractiveObject)& anIObj, - const Standard_Integer SelMode, - const Standard_Boolean AllowDecomp) { - - if ( anIObj.IsNull() ) return; - if ( !anIObj->HasInteractiveContext() ) anIObj->SetContext( this ); - - if ( !HasOpenedContext() ) { - if ( SelMode == -1 && !AllowDecomp ) { - Standard_Integer DispMode; - AIS2D_TypeOfDetection HiMod; - Standard_Integer selMode = SelMode; - - GetDefModes( anIObj, DispMode, HiMod, selMode ); - Handle(AIS2D_GlobalStatus) GStatus= - new AIS2D_GlobalStatus( AIS2D_DS_FullErased, DispMode, selMode ); - myObjects.Bind( anIObj,GStatus ); - return; - } - } - //endif !HasOpenedContext - myLocalContexts(myCurLocalIndex)->Load( anIObj, AllowDecomp, SelMode); -} - -void AIS2D_InteractiveContext::Erase( - const Handle(AIS2D_InteractiveObject)& anIObj, - const Standard_Boolean UpdateVwr, - const Standard_Boolean /*PutInCollector*/) { - - if ( anIObj.IsNull() ) return; - - if ( !HasOpenedContext() ) -#ifdef OCC154 - { - anIObj->Erase(); - if (myObjects.IsBound(anIObj)) - myObjects(anIObj)->SetGraphicStatus(AIS2D_DS_Erased); - } -#else - anIObj->Remove(); -#endif - if ( UpdateVwr ) myMainVwr->UpdateNew(); - -} - -void AIS2D_InteractiveContext::EraseAll (const Standard_Boolean /*PutInCollector*/, - const Standard_Boolean UpdateVwr) -{ - if ( !HasOpenedContext() ) -#ifdef OCC154 - { - myMainVwr->View()->Erase(); - AIS2D_DataMapIteratorOfDataMapOfIOStatus anItr (myObjects); - for (; anItr.More(); anItr.Next()) - { - anItr.Value()->SetGraphicStatus(AIS2D_DS_Erased); - } - } -#else - myMainVwr->View()->Remove(); -#endif - if ( UpdateVwr ) myMainVwr->Update(); -} - -void AIS2D_InteractiveContext::DisplayAll (const Standard_Boolean /*OnlyFromCollector*/, - const Standard_Boolean /*updateVwr*/) { - -} - -void AIS2D_InteractiveContext::EraseSelected (const Standard_Boolean PutInCollector, - const Standard_Boolean UpdateVwr) { - if ( !HasOpenedContext() ) { - Standard_Boolean found = Standard_False; - if ( mySeqOfSelIO->IsEmpty() ) return; - for ( int i = 1; i <= mySeqOfSelIO->Length(); ++i ) - Erase( mySeqOfSelIO->Value(i), Standard_False, PutInCollector ); - found = Standard_True; - if ( found && UpdateVwr ) { - myMainVwr->Update(); - if ( PutInCollector && !myCollectorVwr.IsNull() ) - myCollectorVwr->Update(); - } - } - -} - -void AIS2D_InteractiveContext::DisplaySelected( const Standard_Boolean updateVwr ) { - - if ( !HasOpenedContext() ) { - Standard_Boolean found = Standard_False; - if ( mySeqOfSelIO->IsEmpty() ) return; - for ( int i = 1; i <= mySeqOfSelIO->Length(); ++i ) { - Display( mySeqOfSelIO->Value(i), Standard_False ); - found = Standard_True; - } - if ( found && updateVwr ) { - myMainVwr->Update(); - if ( !(myIsCollClosed && myCollectorVwr.IsNull()) ) - myCollectorVwr->Update(); - } - } - -} - -Standard_Boolean AIS2D_InteractiveContext::KeepTemporary( const Handle(AIS2D_InteractiveObject)& anIObj, - const Standard_Integer WhichContext ) { - - if ( anIObj.IsNull() ) return Standard_False; - - if ( !HasOpenedContext() ) return Standard_False; - if ( myObjects.IsBound(anIObj) ) return Standard_False; - if ( WhichContext != -1 && !myLocalContexts.IsBound(WhichContext) ) return Standard_False; - - Standard_Integer IsItInLocal = myCurLocalIndex; - Standard_Boolean Found( Standard_False ); - - while ( IsItInLocal > 0 && !Found ) { - if ( !myLocalContexts.IsBound( IsItInLocal ) ) - IsItInLocal--; - else if ( myLocalContexts(IsItInLocal)->IsIn( anIObj ) ) - Found = Standard_True; - else - IsItInLocal--; - } - - if ( !Found ) return Standard_False; - - Handle(AIS2D_LocalStatus) LS = myLocalContexts(IsItInLocal)->Status(anIObj); - - - if ( LS->IsTemporary() ){ - Standard_Integer DM,SM; - AIS2D_TypeOfDetection HM; - GetDefModes( anIObj, DM, HM, SM ); - - SM = LS->SelectionModes()->IsEmpty() ? SM : LS->SelectionModes()->First(); - if (LS->DisplayMode() != DM ) { - Standard_Integer LSM = LS->SelectionModes()->IsEmpty() ? -1 : LS->SelectionModes()->First(); - myLocalContexts(IsItInLocal)->Display(anIObj,DM,LS->Decomposed(),LSM); - } - - Handle(AIS2D_GlobalStatus) GS = new AIS2D_GlobalStatus( AIS2D_DS_Displayed, - DM, SM, Standard_False); - myObjects.Bind( anIObj, GS ); - - LS->SetTemporary(Standard_False); - } - return Standard_True; -} - -Standard_Boolean AIS2D_InteractiveContext::IsSelected(const Handle(AIS2D_InteractiveObject)& anIObj) const { - - if ( anIObj.IsNull() ) return Standard_False; - if ( !HasOpenedContext() ) - return ( anIObj->State() == 1 ); - else - return myLocalContexts(myCurLocalIndex)->IsSelected(anIObj); -} - -Standard_Boolean AIS2D_InteractiveContext::IsCurrent(const Handle(AIS2D_InteractiveObject)& anIObj) const { - - if ( anIObj.IsNull() ) return Standard_False; - return ( anIObj->State() ); -} - -Standard_Integer AIS2D_InteractiveContext::OpenLocalContext( const Standard_Boolean UseDispObj, - const Standard_Boolean AllowDecomposit, - const Standard_Boolean AcceptEraseOfObj ) { - if ( !IsCurrent( myLastPicked ) ) - if ( !myLastPicked.IsNull() ) { - myLastPicked->Unhighlight(); - } - - if ( !myLastMoveView.IsNull() ) - if ( myCurLocalIndex > 0 ) - myLocalContexts( myCurLocalIndex )->UnhighLastDetect( myLastMoveView ); - - myLastinMain.Nullify(); - myLastinColl.Nullify(); - myLastPicked.Nullify(); - myWasLastMain = Standard_True; - -// Standard_Integer untilNow = myCurLocalIndex; - - myCurLocalIndex = HighestIndex() + 1; - - Handle(AIS2D_LocalContext) NewLocal= new AIS2D_LocalContext(this, - myCurLocalIndex, - UseDispObj, - AllowDecomposit, - AcceptEraseOfObj ); - - myLocalContexts.Bind( myCurLocalIndex, NewLocal ); - - if ( UseDispObj ) { - if ( AllowDecomposit ) - cout<<"\t\tDecomposition Authorized for Loaded Shapes"<Terminate(); - myLocalContexts.UnBind(myCurLocalIndex); - myCurLocalIndex = 0; - - ResetOriginalState(Standard_False); - - } else { - - myLocalContexts(GoodIndex)->Terminate(); - myLocalContexts.UnBind(GoodIndex); - - if ( GoodIndex == myCurLocalIndex ) { - myCurLocalIndex = HighestIndex(); - } - - } - - if ( updateVwr ) myMainVwr->Update(); - -} - -Standard_Integer AIS2D_InteractiveContext::IndexOfCurrentLocal() const { - return myCurLocalIndex; -} - -void AIS2D_InteractiveContext::CloseAllContext( const Standard_Boolean /*updateVwr*/ ) { - - - -} - -void AIS2D_InteractiveContext::SetCurrentObject( const Handle(AIS2D_InteractiveObject)& anIObj, - const Standard_Boolean UpdateVwr ) { - - if ( anIObj.IsNull() ) return; - - /*if ( NbCurrents() == 1 && anIObj->State() == 1 ) { - Quantity_NameOfColor HiCol; - Standard_Boolean HasHiCol; - if ( IsHighlighted( anIObj, HasHiCol, HiCol ) ) - if ( HasHiCol && HiCol != mySelectionColor ) - Highlight( anIObj, UpdateVwr ); - return; - } - */ - if ( !HasOpenedContext() ) { - if ( !myObjects.IsBound(anIObj) ) - HighlightWithColor( anIObj, mySelectionColor, Standard_False ); - - anIObj->SetState(1); - Quantity_NameOfColor HiCol; - Standard_Boolean HasHiCol; - if ( IsHighlighted( anIObj, HasHiCol, HiCol ) ) { - if ( HasHiCol && HiCol != mySelectionColor ) - Highlight( anIObj,UpdateVwr ); - } else { - Highlight( anIObj, UpdateVwr ); - } - //if (UpdateVwr) - // UpdateCurrentViewer(); - } - -} - -void AIS2D_InteractiveContext::AddOrRemoveCurObject( const Handle(AIS2D_InteractiveObject)& anIObj, - const Standard_Boolean UpdateVwr ) { - - - if ( !HasOpenedContext() ) { - if ( anIObj.IsNull() ) return; - - switch ( anIObj->HighlightMode() ) { - default: - case AIS2D_TOD_OBJECT: { - if ( IsIOSelected( anIObj ) ) { - Unhighlight( anIObj, Standard_False ); - anIObj->SetState( 0 ); - for ( int i = 1; i <= mySeqOfSelIO->Length(); ++i ) - if ( mySeqOfSelIO->Value(i) == anIObj ) { - mySeqOfSelIO->Remove(i); - break; - } - } else { - anIObj->SetState( 1 ); - Highlight( anIObj, Standard_False ); - mySeqOfSelIO->Append(anIObj); - } - } - break; - case AIS2D_TOD_PRIMITIVE: { - Standard_Boolean found = Standard_False; - Handle(AIS2D_HSequenceOfPrimArchit) thePA; - Handle(Graphic2d_Primitive) thePrim = anIObj->Primitive(anIObj->PickedIndex()); - thePA = anIObj->GetSelectedSeqPrim(); - for ( int i = 1; i <= thePA->Length(); ++i ) - if ( thePA->Value(i)->GetPrimitive() == thePrim ) { - //thePrim->Unhighlight(); - Unhighlight( anIObj, Standard_False ); - thePA->Remove(i); - found = Standard_True; - break; - } - if ( !found ) { - Highlight( anIObj, Standard_False ); - thePrim->Highlight(); - anIObj->AddSelectPrim( thePrim, 0 ); - if ( ! IsIOSelected( anIObj ) ) { - mySeqOfSelIO->Append(anIObj); - anIObj->SetState( 1 ); - } - } - } - break; - case AIS2D_TOD_ELEMENT:{ - Standard_Boolean found = Standard_False; - Handle(AIS2D_HSequenceOfPrimArchit) thePA; - Handle(Graphic2d_Primitive) thePrim = anIObj->Primitive(anIObj->PickedIndex()); - Standard_Integer ind = thePrim->PickedIndex(); - thePA = anIObj->GetSelectedSeqPrim(); - for ( int i = 1; i <= thePA->Length(); ++i ) - if ( thePA->Value(i)->GetPrimitive() == thePrim && - thePA->Value(i)->GetIndex() == ind ) { -#ifdef OCC197 - // unhighlight the element - // thePrim->Unhighlight(ind); - Handle(TColStd_HSequenceOfInteger) aHiInds = thePrim->HighlightIndices(); - for (int k = 1; k <= aHiInds->Length(); k++) - { - if (aHiInds->Value(k) == ind) - { - aHiInds->Remove(k); - break; - } - } - // unhighlight entire object only if we remove last selected element of it - if (thePA->Length() == 1) -#endif - Unhighlight( anIObj, Standard_False ); - thePA->Remove(i); - found = Standard_True; - break; - } - if ( !found ) { - Highlight( anIObj, Standard_False ); - thePrim->Highlight( ind ); - anIObj->AddSelectPrim( thePrim, ind ); - if ( ! IsIOSelected( anIObj ) ) { - mySeqOfSelIO->Append(anIObj); - anIObj->SetState( 1 ); - } - } - } - break; - case AIS2D_TOD_VERTEX: { - Standard_Boolean found = Standard_False; - Handle(AIS2D_HSequenceOfPrimArchit) thePA; - Handle(Graphic2d_Primitive) thePrim = anIObj->Primitive(anIObj->PickedIndex()); - Standard_Integer ind = thePrim->PickedIndex(); - thePA = anIObj->GetSelectedSeqPrim(); - for ( int i = 1; i <= thePA->Length(); ++i ) - if ( thePA->Value(i)->GetPrimitive() == thePrim && - thePA->Value(i)->GetIndex() == ind ) { -#ifdef OCC197 - // unhighlight the vertex - // thePrim->Unhighlight(ind); - Handle(TColStd_HSequenceOfInteger) aHiInds = thePrim->HighlightIndices(); - for (int k = 1; k <= aHiInds->Length(); k++) - { - if (aHiInds->Value(k) == ind) - { - aHiInds->Remove(k); - break; - } - } - // unhighlight entire object only if we remove last selected vertex of it - if (thePA->Length() == 1) -#endif - Unhighlight( anIObj, Standard_False ); - thePA->Remove(i); - found = Standard_True; - break; - } - if ( !found ) { - Highlight( anIObj, Standard_False ); - thePrim->Highlight( ind ); - anIObj->AddSelectPrim( thePrim, ind ); - if ( ! IsIOSelected( anIObj ) ) { - mySeqOfSelIO->Append(anIObj); - anIObj->SetState( 1 ); - } - } - } - break; - - } // end switch - -#ifdef OCC197 - if ( UpdateVwr ) myWasLastMain ? myMainVwr->Update() : UpdateCollector(); -#else - if ( UpdateVwr ) UpdateCurrentViewer(); -#endif - } else { - -// cout<<"Nothing Done : Opened Local Context"<IsEmpty() ) return; - Handle(AIS2D_InteractiveObject) IO; - AIS2D_TypeOfDetection theTOD; - for ( int i = 1; i <= mySeqOfSelIO->Length(); ++i ) { - IO = mySeqOfSelIO->Value(i); - theTOD = IO->HighlightMode(); - if ( theTOD == AIS2D_TOD_OBJECT ) - Highlight(IO,Standard_False); - else if ( theTOD == AIS2D_TOD_PRIMITIVE || - theTOD == AIS2D_TOD_ELEMENT || - theTOD == AIS2D_TOD_VERTEX ) { - Standard_Integer pLength = IO->PickList()->Length(); - if ( pLength ) { - IO->Highlight(myMainVwr->InitializeColor( mySelectionColor )); - IO->Unhighlight(); - for ( int j = 1; j <= pLength; j++ ) - IO->Primitive(IO->PickList()->Value(j))->Highlight(); - } - } - } // end for - if ( UpdateVwr ) - UpdateCurrentViewer(); - -} - -void AIS2D_InteractiveContext::UnhighlightCurrent(const Standard_Boolean UpdateVwr) { - if ( mySeqOfSelIO->IsEmpty() ) return; - for ( int i = 1; i <= mySeqOfSelIO->Length(); ++i ) { - Unhighlight( mySeqOfSelIO->Value(i), Standard_False ); - mySeqOfSelIO->Value(i)->SetState(0); - } - if ( UpdateVwr ) - UpdateCurrentViewer(); -} - - -void AIS2D_InteractiveContext::ClearCurrent(const Standard_Boolean UpdateVwr) { - if ( mySeqOfSelIO->IsEmpty() ) return; - for ( int i = 1; i <= mySeqOfSelIO->Length(); ++i ) - Unhighlight( mySeqOfSelIO->Value(i), Standard_False ); - - if ( UpdateVwr ) - UpdateCurrentViewer(); -} - -void AIS2D_InteractiveContext::SetSelectedCurrent() { - -} - -// SAV - just appending object -void AIS2D_InteractiveContext::SetSelected( const Handle(AIS2D_InteractiveObject)& obj, - const Standard_Boolean update ) -{ - mySeqOfSelIO->Append( obj ); - for( Standard_Integer i = 1; i <= obj->Length(); i++ ) - obj->AddSelectPrim( obj->Primitive( i ), i ); -} - -void AIS2D_InteractiveContext::UpdateSelected( const Standard_Boolean UpdateVwr ) { - - if ( !HasOpenedContext() ) { - HighlightSelected(); - } - myLocalContexts(myCurLocalIndex)->UpdateSelected( UpdateVwr ); -} - -void AIS2D_InteractiveContext::AddOrRemoveSelected( - const Handle(AIS2D_InteractiveObject)& anIObj, - const Standard_Boolean UpdateVwr ) { - - if ( !anIObj->HasInteractiveContext() ) anIObj->SetContext(this); - if ( ! HasOpenedContext() ) - AddOrRemoveCurObject( anIObj, UpdateVwr ); - else - myLocalContexts(myCurLocalIndex)->AddOrRemoveSelected( anIObj, UpdateVwr); - -} - -void AIS2D_InteractiveContext::HighlightSelected( const Standard_Boolean UpdateVwr ) { - - if ( !HasOpenedContext() ) { - if ( ! mySeqOfSelIO->IsEmpty() ) - for ( int i = 1; i <= mySeqOfSelIO->Length(); ++i ) - Highlight( mySeqOfSelIO->Value(i), Standard_False ); - } else { - myLocalContexts(myCurLocalIndex)->UnhighlightPicked( UpdateVwr ); - } - if( UpdateVwr ) - UpdateCurrentViewer(); -} - -void AIS2D_InteractiveContext::UnhighlightSelected( const Standard_Boolean UpdateVwr ) { - if ( !HasOpenedContext() ) { - if ( ! mySeqOfSelIO->IsEmpty() ) - for ( int i = 1; i <= mySeqOfSelIO->Length(); ++i ) - Unhighlight( mySeqOfSelIO->Value(i), Standard_False ); - } else { - myLocalContexts(myCurLocalIndex)->UnhighlightPicked( UpdateVwr ); - } - if( UpdateVwr ) - UpdateCurrentViewer(); -} - -void AIS2D_InteractiveContext::ClearSelected( const Standard_Boolean UpdateVwr ) { - if ( !HasOpenedContext() ) - ClearCurrent( UpdateVwr ); - else - myLocalContexts(myCurLocalIndex)->ClearSelected( UpdateVwr ); -} - -AIS2D_DisplayStatus AIS2D_InteractiveContext::DisplayStatus( const Handle(AIS2D_InteractiveObject)& anIObj ) const { - - if ( anIObj.IsNull() ) return AIS2D_DS_None; - - if ( myObjects.IsBound(anIObj)) - return myObjects(anIObj)->GraphicStatus(); - - AIS2D_DataMapIteratorOfDataMapOfLC ItM(myLocalContexts); - for ( ; ItM.More(); ItM.Next() ) - if ( ItM.Value()->IsIn(anIObj) ) - return AIS2D_DS_Temporary; - - return AIS2D_DS_None; - -} - -AIS2D_PToListOfInt AIS2D_InteractiveContext::DisplayedModes( const Handle(AIS2D_InteractiveObject)& anIObj ) const { - return myObjects(anIObj)->DisplayedModes(); -} - -Standard_Boolean AIS2D_InteractiveContext::IsDisplayed( const Handle(AIS2D_InteractiveObject)& anIObj ) const { - - if ( anIObj.IsNull() ) return Standard_False; - - if ( myObjects.IsBound(anIObj) ) - if ( myObjects(anIObj)->GraphicStatus() == AIS2D_DS_Displayed ) - return Standard_True; - - AIS2D_DataMapIteratorOfDataMapOfLC ItM(myLocalContexts); - for ( ; ItM.More(); ItM.Next() ) - if ( ItM.Value()->IsDisplayed(anIObj) ) return Standard_True; - - return Standard_False; - -} - -Standard_Boolean AIS2D_InteractiveContext::IsDisplayed( const Handle(AIS2D_InteractiveObject)& /*anIObj*/, - const Standard_Integer /*aMode*/ ) const { - - return Standard_False; - -} - -Standard_Boolean AIS2D_InteractiveContext::IsHighlighted( const Handle(AIS2D_InteractiveObject)& anIObj ) const { - - if ( anIObj.IsNull() ) return Standard_False; - - if (!HasOpenedContext()){ -#ifdef OCC146 - if (!anIObj->IsHighlighted()) return Standard_False; -#endif - if(!myObjects.IsBound(anIObj)) - return Standard_False; - return myObjects(anIObj)->IsHighlight(); - } - AIS2D_DataMapIteratorOfDataMapOfLC ItM(myLocalContexts); - for (;ItM.More();ItM.Next() ) { - if (ItM.Value()->IsHighlight(anIObj) ) - return Standard_True; - } - return Standard_False; - - -} - -Standard_Boolean AIS2D_InteractiveContext::IsHighlighted( const Handle(AIS2D_InteractiveObject)& anIObj, - Standard_Boolean& /*WithColor*/, - Quantity_NameOfColor& /*theHiCol*/ ) const { - if ( anIObj.IsNull() ) return Standard_False; - - if ( !HasOpenedContext() ) { -#ifdef OCC146 - if (!anIObj->IsHighlighted()) return Standard_False; -#endif - if ( !myObjects.IsBound(anIObj) ) - return Standard_False; - return myObjects(anIObj)->IsHighlight(); - } - AIS2D_DataMapIteratorOfDataMapOfLC ItM(myLocalContexts); - for ( ; ItM.More(); ItM.Next() ) - if ( ItM.Value()->IsHighlight(anIObj) ) - return Standard_True; - - return Standard_False; - -} - -void AIS2D_InteractiveContext::SubIntensityOn( - const Handle(AIS2D_InteractiveObject)& anIObj, - const Standard_Boolean UpdateVwr) { - - Standard_Integer indCol; - if ( !HasOpenedContext() ) { - if ( !myObjects.IsBound(anIObj) ) return; - const Handle(AIS2D_GlobalStatus) GStatus = myObjects(anIObj); - if ( GStatus->IsSubIntensityOn() ) return; - GStatus->SubIntensityOn(); - Standard_Boolean UpdMain(Standard_False),UpdColl(Standard_False); - - for (TColStd_ListIteratorOfListOfInteger It( * GStatus->DisplayedModes() ); It.More(); It.Next() ) { - if ( GStatus->GraphicStatus()==AIS2D_DS_Displayed) { - SetHighlightColor( mySubIntensity ); - HighlightWithColor( anIObj, mySubIntensity ); - UpdMain = Standard_True; - } else if ( GStatus->GraphicStatus()==AIS2D_DS_Erased ) { - indCol = myCollectorVwr->InitializeColor( mySubIntensity ); - myCollectorVwr->View()->SetDefaultOverrideColor( indCol ); - HighlightWithColor(anIObj, mySubIntensity ); - UpdColl=Standard_True; - } - } - if ( UpdateVwr ) { - if ( UpdMain) myMainVwr->Update(); - if ( UpdColl ) myCollectorVwr->Update(); - } - } else { - if ( myObjects.IsBound(anIObj) ) { - const Handle(AIS2D_GlobalStatus)& GStatus = myObjects(anIObj); - GStatus->SubIntensityOn(); - for ( ItL.Initialize( * GStatus->DisplayedModes() ); ItL.More(); ItL.Next() ) { - SetHighlightColor( mySubIntensity ); - HighlightWithColor(anIObj, mySubIntensity ); - } - } else - myLocalContexts(myCurLocalIndex)->SubIntensityOn(anIObj); - - if (UpdateVwr) myMainVwr->Update(); - } -} - -void AIS2D_InteractiveContext::SubIntensityOff( - const Handle(AIS2D_InteractiveObject)& anIObj, - const Standard_Boolean UpdateVwr) { - - if ( !HasOpenedContext() ) { - if ( !myObjects.IsBound(anIObj) ) return; - const Handle(AIS2D_GlobalStatus)& GStatus = myObjects(anIObj); - if ( !GStatus->IsSubIntensityOn() ) return; - GStatus->SubIntensityOff(); - Standard_Boolean UpdMain(Standard_False),UpdColl(Standard_False); - - for ( TColStd_ListIteratorOfListOfInteger It( * GStatus->DisplayedModes() ); It.More() ;It.Next() ) { - if ( GStatus->GraphicStatus() != AIS2D_DS_Erased ) { - Unhighlight( anIObj ); - UpdMain = Standard_True; - } else { - Unhighlight( anIObj ); - UpdColl=Standard_True; - } - } - - Standard_Integer DM,SM; - AIS2D_TypeOfDetection HM; - GetDefModes(anIObj,DM,HM,SM); - if ( IsIOSelected(anIObj) ) - Highlight(anIObj,HM); - - if ( UpdateVwr ) { - if ( UpdMain ) myMainVwr->Update(); - if ( UpdColl ) myCollectorVwr->Update(); - } - } else { - if ( myObjects.IsBound(anIObj) ) { - const Handle(AIS2D_GlobalStatus)& GStatus = myObjects(anIObj); - GStatus->SubIntensityOff(); - for (ItL.Initialize(* GStatus->DisplayedModes());ItL.More();ItL.Next()) - Unhighlight(anIObj); - if (GStatus->IsHighlight()) - Highlight(anIObj); - } else - myLocalContexts(myCurLocalIndex)->SubIntensityOff(anIObj); - if ( IsSelected(anIObj) ) - Highlight(anIObj); - - if ( UpdateVwr) myMainVwr->Update(); - } -} - -Standard_Boolean AIS2D_InteractiveContext::IsInCollector( const Handle(AIS2D_InteractiveObject)& anIObj ) const { - - if ( anIObj.IsNull() ) - return Standard_False; - - if ( myObjects.IsBound(anIObj) ) - return ( myObjects( anIObj)->GraphicStatus() == AIS2D_DS_Erased ); - return Standard_False; -} - -void AIS2D_InteractiveContext::Status( const Handle(AIS2D_InteractiveObject)& anIObj, - TCollection_ExtendedString& aStatus ) const { - - aStatus = ""; - - if ( anIObj.IsNull() ) return ; - if ( myObjects.IsBound(anIObj) ) { - aStatus += "\t ____________________________________________"; - aStatus += "\t| Known at Neutral Point:\n\tDisplayStatus:"; - const Handle(AIS2D_GlobalStatus)& theGStat = myObjects(anIObj); - switch ( theGStat->GraphicStatus() ) { - case AIS2D_DS_Displayed: { - aStatus +="\t| -->Displayed\n"; - break; - } - case AIS2D_DS_Erased: { - aStatus +="\t| -->Erased\n"; - break; - } - case AIS2D_DS_FullErased: { - aStatus +="\t| -->Full Erased\n"; - break; - - } - case AIS2D_DS_Temporary: - case AIS2D_DS_None: - break; - - } - aStatus += "\t| Active Display Modes in the MainViewer :\n"; - for ( ItL.Initialize(*(theGStat->DisplayedModes())); - ItL.More(); ItL.Next() ) { - aStatus += "\t|\t Mode "; - aStatus += TCollection_AsciiString(ItL.Value()); - aStatus+="\n"; - } - if ( IsCurrent(anIObj) ) - aStatus +="\t| Current\n"; - //if ( IsSelected(anIObj) ) -// aStatus +="\t| Selected\n"; - - aStatus += "\t| Active Selection Modes in the MainViewer :\n"; - for ( ItL.Initialize(*(theGStat->SelectionModes() )); - ItL.More(); ItL.Next() ) { - aStatus += "\t\t Mode "; - aStatus += TCollection_AsciiString(ItL.Value()); - aStatus+="\n"; - } - aStatus += "\t ____________________________________________"; - - } - -} - -void AIS2D_InteractiveContext::UpdateCurrentViewer() { - - if ( !myMainVwr.IsNull() ) myMainVwr->UpdateNew(); - -} - -void AIS2D_InteractiveContext::UpdateCollector() { - if ( !myCollectorVwr.IsNull() ) myCollectorVwr->UpdateNew(); -} - -void AIS2D_InteractiveContext::DisplayedObjects (AIS2D_ListOfIO& aListOfIO, - const Standard_Boolean OnlyFromNeutral) const -{ - AIS2D_DataMapIteratorOfDataMapOfIOStatus It( myObjects ); - - if ( !HasOpenedContext() || OnlyFromNeutral ) { - for ( ; It.More(); It.Next() ) - if ( It.Value()->GraphicStatus() == AIS2D_DS_Displayed ) - aListOfIO.Append( It.Key() ); - } else { - TColStd_MapOfTransient theMap; - - for ( ; It.More(); It.Next() ) { - if ( It.Value()->GraphicStatus() == AIS2D_DS_Displayed ) - theMap.Add(It.Key()); - } - - Standard_Integer NbDisp; - for ( AIS2D_DataMapIteratorOfDataMapOfLC it1(myLocalContexts); - it1.More(); it1.Next() ) { - const Handle(AIS2D_LocalContext)& LC = it1.Value(); - NbDisp = LC->DisplayedObjects(theMap); - } - - Handle(AIS2D_InteractiveObject) curIO; - Handle(Standard_Transient) Tr; - for ( TColStd_MapIteratorOfMapOfTransient it2(theMap); it2.More(); it2.Next() ) { - Tr = it2.Key(); - curIO = *((Handle(AIS2D_InteractiveObject)*) &Tr); - aListOfIO.Append(curIO); - } - } -} - -void AIS2D_InteractiveContext::GetDefModes( const Handle(AIS2D_InteractiveObject)& anIObj, - Standard_Integer& DispMode, - AIS2D_TypeOfDetection& HiMode, - Standard_Integer& SelMode) const { - - if ( anIObj.IsNull() ) return ; - - DispMode = anIObj->HasDisplayMode() ? anIObj->DisplayMode() : anIObj->DefaultDisplayMode(); - HiMode = anIObj->HasHighlightMode() ? anIObj->HighlightMode() : anIObj->DefaultHighlightMode(); - SelMode = anIObj->HasSelectionMode() ? anIObj->SelectionMode() : anIObj->DefaultSelectionMode(); - -} - -void AIS2D_InteractiveContext::EraseGlobal( - const Handle(AIS2D_InteractiveObject)& anIObj, - const Standard_Boolean /*UpdateVwr*/, - const Standard_Boolean /*PutInCollector*/) { - - if ( anIObj.IsNull() ) return ; - if ( !myObjects.IsBound( anIObj ) ) return; - -} - - -void AIS2D_InteractiveContext::SetHighlightColor( const Quantity_NameOfColor aCol ) { - - if ( myHighlightColor != aCol ) { - myHighlightColor = aCol; - Standard_Integer anIndex = myMainVwr->InitializeColor(aCol); - myMainVwr->View()->SetDefaultOverrideColor( anIndex ); - } -} - -void AIS2D_InteractiveContext::SetSelectionColor( const Quantity_NameOfColor aCol ) { - - if ( mySelectionColor != aCol ) { - mySelectionColor = aCol; - Standard_Integer anIndex = myMainVwr->InitializeColor(aCol); - myMainVwr->View()->SetDefaultOverrideColor(anIndex); - } -} - -void AIS2D_InteractiveContext::SetSubIntensityColor( const Quantity_NameOfColor aCol ) { - mySubIntensity = aCol; -} - -Standard_Integer AIS2D_InteractiveContext::HighestIndex() const { - - AIS2D_DataMapIteratorOfDataMapOfLC It( myLocalContexts ); - Standard_Integer HiInd = 0; - for ( ; It.More(); It.Next() ) - HiInd = ( It.Key() > HiInd ) ? It.Key() : HiInd; - return HiInd; - -} - -Standard_Integer AIS2D_InteractiveContext::InitializeColor( const Quantity_Color& aColor ) { - -#ifdef IMP140901 - Handle(Aspect_ColorMap) colormap = myMainVwr->ColorMap(); -#else - Handle(Aspect_GenericColorMap) colormap = myMainVwr->ColorMap(); -#endif - Standard_Integer size = colormap->Size(); - Standard_Integer indColor = colormap->AddEntry(aColor); - if( size != colormap->Size() ) { - myMainVwr->SetColorMap( colormap ); - } - return indColor; - -} - -Standard_Integer AIS2D_InteractiveContext::InitializeStyle( const Aspect_TypeOfLine aType ) { - - Handle(Aspect_TypeMap) typemap = myMainVwr->TypeMap(); - Standard_Integer size = typemap->Size(); - Standard_Integer indType = typemap->AddEntry(aType); - if( size != typemap->Size() ) { - myMainVwr->SetTypeMap( typemap ); - } - - return indType; - -} - -Standard_Integer AIS2D_InteractiveContext::InitializeWidth( const Aspect_WidthOfLine aWidth ) { - - Handle(Aspect_WidthMap) widthmap = myMainVwr->WidthMap(); - Standard_Integer size = widthmap->Size(); - Standard_Integer indWidth = widthmap->AddEntry(aWidth); - if( size != widthmap->Size() ) { - myMainVwr->SetWidthMap( widthmap ); - } - - return indWidth; - -} - -Standard_Integer AIS2D_InteractiveContext::InitializeMarker( const Aspect_TypeOfMarker aMark ) { - - Handle(Aspect_MarkMap) markmap = myMainVwr->MarkMap(); - Standard_Integer size = markmap->Size(); - Standard_Integer indMark = markmap->AddEntry(aMark); - if( size != markmap->Size() ) { - myMainVwr->SetMarkMap( markmap ); - } - - return indMark; - -} - -Standard_Integer AIS2D_InteractiveContext::InitializeFont( const Aspect_FontStyle& aFont ) { - - Handle(Aspect_FontMap) fontmap = myMainVwr->FontMap(); - Standard_Integer size = fontmap->Size(); - Standard_Integer indFont = fontmap->AddEntry(aFont); - if( size != fontmap->Size() ) { - myMainVwr->SetFontMap( fontmap ); - } - return indFont; - -} - -void AIS2D_InteractiveContext::DrawObject( const Handle(AIS2D_InteractiveObject)& anIObj, - const Standard_Integer aDispMode ) { - - if ( anIObj->IsKind(STANDARD_TYPE(AIS2D_ProjShape) ) ) { - - Handle(AIS2D_ProjShape) thePS = Handle(AIS2D_ProjShape)::DownCast(anIObj); - Handle(Graphic2d_Line) theLines = thePS->GetPrimitives(); - Handle(Prs2d_AspectLine) theAspLine; - - if ( !anIObj->HasAspect(theLines) ) { - Handle(Prs2d_AspectRoot) theAspRoot = anIObj->Attributes()->FindAspect(Prs2d_AN_LINE); - theAspLine = Handle(Prs2d_AspectLine)::DownCast(theAspRoot); - anIObj->SetAspect( theAspLine, theLines ); - - } else { - theAspLine = Handle(Prs2d_AspectLine)::DownCast( anIObj->GetAspect(theLines) ); - } - - Quantity_Color aColor; - Aspect_TypeOfLine aType; - Aspect_WidthOfLine aWidth; - - theAspLine->ValuesOfLine( aColor, aType, aWidth ); - - Standard_Integer colorInd = theAspLine->ColorIndex(); - Standard_Integer typeInd = theAspLine->TypeIndex(); - Standard_Integer widthInd = theAspLine->WidthIndex(); - - if ( !colorInd ) { - colorInd = InitializeColor( aColor ); - theLines->SetColorIndex( colorInd ); - } - - if ( !typeInd ) { - typeInd = InitializeStyle( aType ); - theLines->SetTypeIndex( typeInd ); - } - - if ( !widthInd ) { - widthInd = InitializeWidth( aWidth ); - theLines->SetWidthIndex( widthInd ); - } - - if ( thePS->IsHLMode() ) { - Handle(Graphic2d_Line) theHLines = thePS->GetHLPrimitives(); - theHLines->SetColorIndex( colorInd ); - theHLines->SetWidthIndex( widthInd ); - Standard_Integer theDashInd = InitializeStyle( Aspect_TOL_DASH ); - theHLines->SetTypeIndex( theDashInd ); - } - - } else { - - Handle(Graphic2d_Primitive) thePrim; - - for ( Standard_Integer i = 1; i <= anIObj->Length(); i++ ) { - thePrim = anIObj->Primitive( i ); - thePrim->SetDisplayMode(aDispMode); - if ( thePrim->IsKind(STANDARD_TYPE(Graphic2d_Line) ) ) { - - Handle(Graphic2d_Line) theLine = Handle(Graphic2d_Line)::DownCast(thePrim); - Handle(Prs2d_AspectLine) theAspLine; - - if ( !anIObj->HasAspect(theLine) ) { - Handle(Prs2d_AspectRoot) theAspRoot = anIObj->Attributes()->FindAspect(Prs2d_AN_LINE); - theAspLine = Handle(Prs2d_AspectLine)::DownCast(theAspRoot); - anIObj->SetAspect( theAspLine, theLine ); - - } else { - theAspLine = Handle(Prs2d_AspectLine)::DownCast( anIObj->GetAspect(theLine) ); - } - - Quantity_Color aColor; - Aspect_TypeOfLine aType; - Aspect_WidthOfLine aWidth; - - Quantity_Color aIntColor; - Graphic2d_TypeOfPolygonFilling aTypeFill; - Standard_Integer aTile; - Standard_Boolean aDrawEdge; - - theAspLine->ValuesOfLine( aColor, aType, aWidth ); - theAspLine->ValuesOfPoly( aIntColor, aTypeFill, aTile, aDrawEdge ); - - Standard_Integer colorInd = theAspLine->ColorIndex(); - Standard_Integer typeInd = theAspLine->TypeIndex(); - Standard_Integer widthInd = theAspLine->WidthIndex(); - Standard_Integer colorIntInd = theAspLine->InterColorIndex(); - - if ( !colorInd ) { - colorInd = InitializeColor( aColor ); - theLine->SetColorIndex( colorInd ); - } - - if ( !typeInd ) { - typeInd = InitializeStyle( aType ); - theLine->SetTypeIndex( typeInd ); - } - - if ( !widthInd ) { - widthInd = InitializeWidth( aWidth ); - theLine->SetWidthIndex( widthInd ); - } - - if ( !colorIntInd ) { - colorIntInd = InitializeColor( aIntColor ); - theLine->SetInteriorColorIndex( colorIntInd ); - } - - theLine->SetTypeOfPolygonFilling( aTypeFill ); - theLine->SetInteriorPattern( aTile ); - theLine->SetDrawEdge( aDrawEdge ); - - if ( theLine->IsKind(STANDARD_TYPE(Prs2d_Point) ) ) { - - Handle(Prs2d_Point) thePnt = Handle(Prs2d_Point)::DownCast(theLine); - thePnt->SetIndex( InitializeMarker( thePnt->Marker() ) ); - } - - } // end if the kind of primitive is Graphic2d_Line - - } // end for exploration of the interactive object - - } // end if IO is AIS2D_ProjShape - -} - -void AIS2D_InteractiveContext::ResetOriginalState(const Standard_Boolean /*updateviewer*/) { - /* - Standard_Boolean upd_main(Standard_False),upd_col(Standard_False); - TColStd_ListIteratorOfListOfInteger itl; - - for (AIS_DataMapIteratorOfDataMapOfIOStatus it(myObjects);it.More();it.Next()){ - const Handle(AIS_InteractiveObject)& iobj = it.Key(); - const Handle(AIS_GlobalStatus)& STAT = it.Value(); - switch(STAT->GraphicStatus()){ - case AIS_DS_Displayed:{ - upd_main = Standard_True; - - // partie display... - for(itl.Initialize(STAT->DisplayedModes());itl.More();itl.Next()) - myMainPM->Display(iobj,itl.Value()); - if(STAT->IsHilighted()){ - if(STAT->HilightColor()!=Quantity_NOC_WHITE) - HilightWithColor(iobj,STAT->HilightColor(),Standard_False); - else - Hilight(iobj,Standard_False); - } - //partie selection - for(itl.Initialize(STAT->SelectionModes());itl.More();itl.Next()){ - if(itl.Value()!=-1) - mgrSelector->Activate(iobj,itl.Value(),myMainSel); - } - break; - } - case AIS_DS_Erased:{ - upd_col = Standard_True; - EraseGlobal(iobj,Standard_False,Standard_True); - break; - } - case AIS_DS_FullErased:{ - EraseGlobal(iobj,Standard_False,Standard_False); - break; - } -#ifndef DEB - default: - break; -#endif - } - } - if(updateviewer){ - if(upd_main) - myMainVwr->Update(); - if(upd_col) - myCollectorVwr->Update(); - }*/ -} - -Standard_Boolean AIS2D_InteractiveContext::AvailableToDetect( const Handle(AIS2D_InteractiveObject)& anIO ) const { -#ifndef OCC146 - if ( anIO->HighlightMode() == AIS2D_TOD_OBJECT) - return ( ! anIO->State() ); -#endif - return Standard_True; -} - -void AIS2D_InteractiveContext::DoDetectObject( const Handle(AIS2D_InteractiveObject)& theIO, - const Handle(Graphic2d_TransientManager)& theDrawer ) { - theIO->ClearSeqDetPrim(); -#ifdef OCC146 - if (!theIO->State()) -#endif - theIO->Unhighlight(); - myCurDetectMode = theIO->HighlightMode(); - switch ( myCurDetectMode ) { - default : - case AIS2D_TOD_OBJECT : - if ( !IsIOSelected( theIO ) ) { - theDrawer->Draw( theIO ); -#ifdef OCC146 - } - { -#endif - if ( !IsIOPicked( theIO ) ) - mySeqOfDetIO->Append( theIO ); - } - break; - case AIS2D_TOD_PRIMITIVE: { - Standard_Integer pLength = theIO->PickList()->Length(); - Handle(Graphic2d_Primitive) thePrim; - - if ( pLength ) { - for ( int i = 1; i <= pLength; i++ ) { - thePrim = theIO->Primitive(theIO->PickList()->Value(i)); - if ( ! thePrim->IsHighlighted() && - ! IsPrimSelected ( theIO, thePrim ) ) { - theDrawer->Draw( thePrim ); -#ifdef OCC146 - } - { -#endif - if ( ! IsPrimPicked( theIO, thePrim ) ) { - theIO->AddDetectPrim( thePrim, 0 ); - if ( !IsIOPicked( theIO ) ) - mySeqOfDetIO->Append( theIO ); - } - } - } - - } else { - thePrim = theIO->Primitive( theIO->PickedIndex() ); - if ( ! thePrim->IsHighlighted() ) { - theDrawer->Draw( thePrim ); -#ifdef OCC146 - } - { -#endif - if ( ! IsPrimPicked( theIO, thePrim ) ) { - theIO->AddDetectPrim( thePrim, 0 ); - if ( !IsIOPicked( theIO ) ) - mySeqOfDetIO->Append( theIO ); - } - } - } - } - break; - case AIS2D_TOD_ELEMENT: { - Standard_Integer theInd, pLength = theIO->PickList()->Length(); - Handle(Graphic2d_Primitive) thePrim; - if ( pLength ) { - for ( int i = 1; i <= pLength; i++ ) { - thePrim = theIO->Primitive(theIO->PickList()->Value(i)); - theInd = thePrim->PickedIndex(); - if ( ! thePrim->IsHighlighted() ) { - - // SAV - begin - const TColStd_MapOfInteger& indices = thePrim->PickedIndices(); - - if ( indices.Extent() ) { - theDrawer->DrawPickedElements( thePrim ); - - TColStd_MapIteratorOfMapOfInteger it( indices ); - theIO->AddDetectPrim( thePrim, it.Key() ); - - if ( !IsIOPicked( theIO ) ) - mySeqOfDetIO->Append( theIO ); - } - else { - - for ( int j = 1; j <= thePrim->NumOfElemIndices(); ++j ) { - theDrawer->DrawElement( thePrim, j ); - if ( ! IsElemPicked( theIO, thePrim, j ) ) { - theIO->AddDetectPrim( thePrim, j ); - if ( !IsIOPicked( theIO ) ) - mySeqOfDetIO->Append( theIO ); - } - } - } - -/* - for ( int j = 1; j <= thePrim->NumOfElemIndices(); ++j ) { - theDrawer->DrawElement( thePrim, j ); - if ( ! IsElemPicked( theIO, thePrim, j ) ) { - theIO->AddDetectPrim( thePrim, j ); - if ( !IsIOPicked( theIO ) ) - mySeqOfDetIO->Append( theIO ); - } - } -*/ - } - /*if ( ! IsElemSelected( theIO, thePrim, theInd ) ) { - theDrawer->DrawElement( thePrim, theInd ); - if ( ! IsElemPicked( theIO, thePrim, theInd ) ) { - theIO->AddDetectPrim( thePrim, theInd ); - if ( ! IsIOPicked( theIO ) ) - mySeqOfDetIO->Append( theIO ); - } - - } - */ - } - } else { - thePrim = theIO->Primitive(theIO->PickedIndex()); - theInd = thePrim->PickedIndex(); -#ifdef BUG - if ( theInd > 0 ) -#else - if ( theInd != 0 ) -#endif -#ifdef OCC146 - { -#endif - if ( ! IsElemSelected( theIO, thePrim, theInd ) ) { - theDrawer->DrawElement( thePrim, theInd ); -#ifdef OCC146 - } - { -#endif - if ( ! IsElemPicked( theIO, thePrim, theInd ) ) { - theIO->AddDetectPrim( thePrim, theInd ); - if ( ! IsIOPicked( theIO ) ) - mySeqOfDetIO->Append( theIO ); - } - } -#ifdef OCC146 - } -#endif - } - } - break; - case AIS2D_TOD_VERTEX: { - Standard_Integer theInd, pLength = theIO->PickList()->Length(); - Handle(Graphic2d_Primitive) thePrim; - if ( pLength ) { - for ( int i = 1; i <= pLength; i++ ) { - thePrim = theIO->Primitive(theIO->PickList()->Value(i)); - theInd = thePrim->PickedIndex(); - if ( ! thePrim->IsHighlighted() ) - for ( int j = 1; j <= thePrim->NumOfVertIndices(); ++j ) { - theDrawer->DrawVertex( thePrim, j ); - if ( ! IsElemPicked( theIO, thePrim, -j ) ) { - theIO->AddDetectPrim( thePrim, -j ); - if ( !IsIOPicked( theIO ) ) - mySeqOfDetIO->Append( theIO ); - } - } - } - /*if ( ! IsElemSelected( theIO, thePrim, theInd ) ) { - theDrawer->DrawVertex( thePrim, -theInd ); - if ( ! IsElemPicked( theIO, thePrim, theInd ) ) { - theIO->AddDetectPrim( thePrim, -theInd ); - if ( ! IsIOPicked( theIO ) ) - mySeqOfDetIO->Append( theIO ); - } - }*/ - - } else { - thePrim = theIO->Primitive(theIO->PickedIndex()); - theInd = thePrim->PickedIndex(); - if ( theInd < 0 ) -#ifdef OCC146 - { -#endif - if ( ! IsElemSelected( theIO, thePrim, theInd ) ) { - theDrawer->DrawVertex( thePrim, -theInd ); -#ifdef OCC146 - } - { -#endif - if ( ! IsElemPicked( theIO, thePrim, theInd ) ) { - theIO->AddDetectPrim( thePrim, theInd ); - if ( !IsIOPicked( theIO ) ) - mySeqOfDetIO->Append( theIO ); - } - } -#ifdef OCC146 - } -#endif - - } - } - break; - } - -} - -Standard_Boolean AIS2D_InteractiveContext::IsIOPicked( const Handle(AIS2D_InteractiveObject)& anIO ) const { - - for ( int i = 1; i <= mySeqOfDetIO->Length(); i++ ) - if ( anIO == mySeqOfDetIO->Value(i) ) - return Standard_True; - return Standard_False; - -} - -Standard_Boolean AIS2D_InteractiveContext::IsIOSelected( const Handle(AIS2D_InteractiveObject)& anIO ) const { - - for ( int i = 1; i <= mySeqOfSelIO->Length(); i++ ) - if ( anIO == mySeqOfSelIO->Value(i) ) - return Standard_True; - return Standard_False; - -} - -Standard_Boolean AIS2D_InteractiveContext::IsPrimSelected( const Handle(AIS2D_InteractiveObject)& anIO, - const Handle(Graphic2d_Primitive)& aPrim ) const { - - Handle(AIS2D_HSequenceOfPrimArchit) theSPA = anIO->GetSelectedSeqPrim(); - - for ( int i = 1; i <= theSPA->Length(); i++ ) - if ( aPrim == theSPA->Value(i)->GetPrimitive() ) - return Standard_True; - return Standard_False; - -} - -Standard_Boolean AIS2D_InteractiveContext::IsPrimPicked( const Handle(AIS2D_InteractiveObject)& anIO, - const Handle(Graphic2d_Primitive)& aPrim ) const { - Handle(AIS2D_HSequenceOfPrimArchit) theSPA = anIO->GetDetectSeqPrim(); - - for ( int i = 1; i <= theSPA->Length(); i++ ) - if ( aPrim == theSPA->Value(i)->GetPrimitive() ) - return Standard_True; - return Standard_False; -} - -Standard_Boolean AIS2D_InteractiveContext::IsElemPicked( const Handle(AIS2D_InteractiveObject)& anIO, - const Handle(Graphic2d_Primitive)& aPrim, - const Standard_Integer ind ) const { - Handle(AIS2D_HSequenceOfPrimArchit) theSPA = anIO->GetDetectSeqPrim(); - for ( int i = 1; i <= theSPA->Length(); i++ ) - if ( aPrim == theSPA->Value(i)->GetPrimitive() && - ind == theSPA->Value(i)->GetIndex() ) - return Standard_True; - return Standard_False; -} - -Standard_Boolean AIS2D_InteractiveContext::IsElemSelected( const Handle(AIS2D_InteractiveObject)& anIO, - const Handle(Graphic2d_Primitive)& aPrim, - const Standard_Integer ind ) const { - Handle(AIS2D_HSequenceOfPrimArchit) theSPA = anIO->GetSelectedSeqPrim(); - for ( int i = 1; i <= theSPA->Length(); i++ ) - if ( aPrim == theSPA->Value(i)->GetPrimitive() && - ind == theSPA->Value(i)->GetIndex() ) - return Standard_True; - return Standard_False; -} - -void AIS2D_InteractiveContext::Highlight( const Handle(AIS2D_InteractiveObject)& anIObj, - const Standard_Boolean updateVwr ) { - if ( anIObj.IsNull() ) return; - - if ( !anIObj->HasInteractiveContext() ) - anIObj->SetContext( this ); - if ( !HasOpenedContext() ) { - if ( !myObjects.IsBound(anIObj) ) return; - Handle(AIS2D_GlobalStatus) aGS = myObjects(anIObj); - - aGS->SetHighlightStatus( Standard_True ); - - switch ( aGS->GraphicStatus() ) { - - case AIS2D_DS_Displayed: { - - Standard_Integer DispMode,SelMode; - AIS2D_TypeOfDetection HiMode; - GetDefModes( anIObj, DispMode, HiMode, SelMode ); - Standard_Integer pInd; - anIObj->Highlight(myMainVwr->InitializeColor( mySelectionColor )); - switch( HiMode ) { - default: - case AIS2D_TOD_OBJECT: - break; - case AIS2D_TOD_PRIMITIVE: - pInd = anIObj->PickedIndex(); - anIObj->Unhighlight(); - break; - case AIS2D_TOD_ELEMENT: - pInd = anIObj->PickedIndex(); - anIObj->Unhighlight(); - break; - case AIS2D_TOD_VERTEX: - pInd = anIObj->PickedIndex(); - anIObj->Unhighlight(); - break; - } //end switch - - if ( updateVwr) myMainVwr->Update(); - - break; - } - case AIS2D_DS_Erased: { - anIObj->Highlight(myCollectorVwr->InitializeColor( mySelectionColor )); - if ( updateVwr ) myCollectorVwr->Update(); - break; - } - case AIS2D_DS_FullErased: - case AIS2D_DS_Temporary: - case AIS2D_DS_None: - break; - } //end switch - } // end if opened context isn't exists - //else - // myLocalContexts(myCurLocalIndex)->Highlight(anIObj); - -} - -void AIS2D_InteractiveContext::HighlightWithColor( const Handle(AIS2D_InteractiveObject)& anIObj, - const Quantity_NameOfColor aCol, - const Standard_Boolean updateVwr ) { - - if ( anIObj.IsNull() ) return; - - if ( !anIObj->HasInteractiveContext() ) anIObj->SetContext(this); - - if ( !HasOpenedContext() ) { - if ( !myObjects.IsBound(anIObj) ) return; - - const Handle(AIS2D_GlobalStatus)& aGS = myObjects(anIObj); - //const TColStd_ListOfInteger& LL = * aGS->DisplayedModes(); - - aGS->SetHighlightStatus (Standard_True); - - switch ( aGS->GraphicStatus() ) { - case AIS2D_DS_Displayed:{ - Standard_Integer DispMode, SelMode; - AIS2D_TypeOfDetection HiMode; - GetDefModes( anIObj, DispMode, HiMode, SelMode ); - Standard_Integer indCol = myMainVwr->InitializeColor( aCol ); - anIObj->Highlight(indCol); - //SetSelectionColor(aCol); - aGS->SetHighlightColor(aCol); - // if ( updateVwr ) myMainVwr->Update(); - break; - } - case AIS2D_DS_Erased: { -#ifdef DEB - Standard_Integer indCol = myCollectorVwr->InitializeColor( aCol ); -#endif - if ( updateVwr) myCollectorVwr->Update(); - break; - } - case AIS2D_DS_FullErased: - case AIS2D_DS_Temporary: - case AIS2D_DS_None: - break; - } - } // else - // myLocalContexts(myCurLocalIndex)->Highlight(anIObj,aCol); - if ( updateVwr) myMainVwr->Update(); - -} - -void AIS2D_InteractiveContext::Unhighlight( const Handle(AIS2D_InteractiveObject)& anIObj, - const Standard_Boolean updateVwr ) { - if ( anIObj.IsNull() ) return; - anIObj->Unhighlight(); - switch ( anIObj->HighlightMode() ) { - default: - case AIS2D_TOD_OBJECT: - break; - case AIS2D_TOD_PRIMITIVE: - if ( !anIObj->Primitive(anIObj->PickedIndex()).IsNull() ) - anIObj->Primitive(anIObj->PickedIndex())->Unhighlight(); - break; - case AIS2D_TOD_ELEMENT: - if ( !anIObj->Primitive(anIObj->PickedIndex()).IsNull() ) - anIObj->Primitive(anIObj->PickedIndex())->Unhighlight(); - break; - case AIS2D_TOD_VERTEX: - if ( !anIObj->Primitive(anIObj->PickedIndex()).IsNull() ) - anIObj->Primitive(anIObj->PickedIndex())->Unhighlight(); - break; - } - if ( updateVwr) myMainVwr->UpdateNew(); -} - -void AIS2D_InteractiveContext::Place( - const Standard_Integer XPix, - const Standard_Integer YPix, - const Handle(V2d_View)& aView, - const Handle(AIS2D_InteractiveObject)& anIO, - const Standard_Boolean isTemporary ) { - - Standard_Real XPS, YPS; - aView->Convert( XPix, YPix, XPS, YPS ); - gp_GTrsf2d theGTrsf; - gp_Trsf2d theTrsf; - theTrsf.SetTranslationPart( gp_Vec2d(gp_Pnt2d(0.,0.), gp_Pnt2d(XPS, YPS) ) ); - theGTrsf.SetTrsf2d( theTrsf ); - anIO->SetTransform( theGTrsf ); - Handle(V2d_Viewer) theViewer = aView->Viewer(); - if ( isTemporary ) { - - Handle(Graphic2d_TransientManager) theDrawer = - Handle(Graphic2d_TransientManager)::DownCast( theViewer->View()->Drawer() ); - Standard_Integer ind = theViewer->InitializeColor(myHighlightColor); - theDrawer->SetOverride( Standard_True ); - theDrawer->SetOverrideColor( ind ); - Display( anIO, Standard_False ); - anIO->Highlight( ind ); - theDrawer->BeginDraw( aView->Driver() ); - theDrawer->Draw( anIO ); - theDrawer->EndDraw(); - theDrawer->SetOverride( Standard_False ); - return; - } - if ( !IsDisplayed( anIO ) ) - Display( anIO ); - else - theViewer->Update(); - -} - -void AIS2D_InteractiveContext::Drag( - const Standard_Integer XPix, - const Standard_Integer YPix, - const Handle(V2d_View)& aView, - const Standard_Boolean isTemporary ) { - - if ( ! mySeqOfSelIO->IsEmpty() ) { - Handle(AIS2D_InteractiveObject) theIO; - for ( int j = 1; j <= mySeqOfSelIO->Length(); ++j ) { - theIO = mySeqOfSelIO->Value(j); - if ( !isTemporary ) { - Unhighlight( theIO, Standard_False ); - theIO->SetState(0); - mySeqOfSelIO->Remove(j); - } - Place( XPix, YPix, aView, theIO, isTemporary ); - } - } -} - -AIS2D_StatusOfDetection AIS2D_InteractiveContext::MoveTo( - const Standard_Integer XPix, - const Standard_Integer YPix, - const Handle(V2d_View)& aView ) { - - RectMoveTo = Standard_False; - if ( HasOpenedContext() && aView->Viewer() != myCollectorVwr ) { - myWasLastMain = Standard_True; - return myLocalContexts(myCurLocalIndex)->MoveTo( XPix, YPix, aView ); - } - Standard_Boolean is_main = Standard_True, UpdVwr = Standard_False; - Handle(V2d_Viewer) theViewer = aView->Viewer(); - - if ( theViewer == myMainVwr ) { - myLastPicked = myLastinMain; - myWasLastMain = Standard_True; - } else if ( theViewer == myCollectorVwr ) { - myLastPicked = myLastinColl; - is_main = Standard_False; - myWasLastMain = Standard_False; - } else - return AIS2D_SOD_Error; - - AIS2D_StatusOfDetection theStat( AIS2D_SOD_Nothing ); - - Handle(Graphic2d_TransientManager) theDrawer = - Handle(Graphic2d_TransientManager)::DownCast( theViewer->View()->Drawer() ); - - Handle(Graphic2d_DisplayList) thePickList = aView->Pick( XPix, YPix, myDetectPrecision); - - if ( ! thePickList->IsEmpty() ) { - - if ( thePickList->Length() == 1 ) { - Handle(Graphic2d_GraphicObject) theGO = thePickList->Value(1); - if ( ! theGO->IsKind(STANDARD_TYPE(AIS2D_InteractiveObject) ) ) - return AIS2D_SOD_Nothing; - Handle(AIS2D_InteractiveObject) theIO = Handle(AIS2D_InteractiveObject)::DownCast(theGO); - if ( IsIOPicked( theIO ) ) - switch ( theIO->HighlightMode() ) { - default: - case AIS2D_TOD_OBJECT: - return AIS2D_SOD_OnlyOneDetected; - break; - case AIS2D_TOD_PRIMITIVE: - if ( IsPrimPicked(theIO, theIO->Primitive(theIO->PickedIndex())) ) - return AIS2D_SOD_OnlyOneDetected; - break; - case AIS2D_TOD_ELEMENT: { - Standard_Integer ind = theIO->PickedIndex(); - if ( IsElemPicked( theIO, theIO->Primitive(ind), theIO->Primitive(ind)->PickedIndex() ) ) - return AIS2D_SOD_OnlyOneDetected; - else if ( ind < 0 ) - myResetDetect= Standard_True; - - } - break; - case AIS2D_TOD_VERTEX: { - Standard_Integer ind = theIO->PickedIndex(); - if ( IsElemPicked( theIO, theIO->Primitive(ind), theIO->Primitive(ind)->PickedIndex() ) ) - return AIS2D_SOD_OnlyOneDetected; - //else if ( ind > 0 ) - // myResetDetect= Standard_True; - - } - break; - - } -#ifdef OCC146 - myResetDetect = Standard_True; -#endif - } - if ( myResetDetect ) { - mySeqOfDetIO->Clear(); - Standard_Integer ind = myMainVwr->InitializeColor(myHighlightColor); - - for ( int i = 1 ; i <= thePickList->Length(); i++ ) { - Handle(Graphic2d_GraphicObject) theGOi = thePickList->Value(i); - if ( theGOi->IsKind(STANDARD_TYPE(AIS2D_InteractiveObject) ) ) { - - myLastPicked = Handle(AIS2D_InteractiveObject)::DownCast( theGOi ); - ( is_main ) ? myLastinMain = myLastPicked : myLastinColl = myLastPicked; - if ( myLastPicked->HasHighlightMode() ) - - if ( AvailableToDetect(myLastPicked) ) { - if ( myLastPicked->HighlightMode() == AIS2D_TOD_OBJECT ) -#ifdef OCC146 - if (!myLastPicked->State()) -#endif - myLastPicked->Highlight( ind ); - theDrawer->SetOverride(Standard_True); - theDrawer->SetOverrideColor(ind); - theDrawer->BeginDraw( aView->Driver() ); - DoDetectObject( myLastPicked, theDrawer ); - theDrawer->EndDraw(); - theDrawer->SetOverride(Standard_False); - - } else theStat = AIS2D_SOD_Selected; - } - } // end for - - myResetDetect= Standard_False; - - } // end if myResetDetect is true - - } else { - - theStat = AIS2D_SOD_Nothing; - theDrawer->RestoreArea( aView->Driver() ); - myResetDetect= Standard_True; - - if ( ! mySeqOfDetIO->IsEmpty() ) { - Handle(AIS2D_InteractiveObject) theIO; - for ( int i = 1; i <= mySeqOfDetIO->Length(); ++i ) { - theIO = mySeqOfDetIO->Value(i); - if ( theIO->HighlightMode() == AIS2D_TOD_ELEMENT || - theIO->HighlightMode() == AIS2D_TOD_VERTEX ) { - theIO->ClearSeqDetPrim(); - } else { - if ( ! theIO->State() ) - theIO->Unhighlight(); - } - theIO->ClearSeqDetPrim(); - } - UpdVwr = Standard_True; - } - ( is_main ) ? myLastinMain.Nullify() : myLastinColl.Nullify(); - mySeqOfDetIO->Clear(); - - } // end if PickList isn't empty - - //if ( !myLastPicked.IsNull() ) myLastPicked->Unhighlight(); - - if ( UpdVwr ) - is_main ? myMainVwr->Update() : myCollectorVwr->Update(); - myLastPicked.Nullify(); - myLastMoveView = aView; - - return theStat; - -} - - -//SAV -AIS2D_StatusOfDetection AIS2D_InteractiveContext -::MoveCircleTo( const Standard_Integer XPix, - const Standard_Integer YPix, - const Standard_Integer Radius, - const Handle(V2d_View)& aView ) -{ - mySeqOfDetIO->Clear(); - - Handle(Graphic2d_DisplayList) thePickList = - aView->PickByCircle( XPix, YPix, Radius ); - - return Detect( thePickList, aView ); -} - - -AIS2D_StatusOfDetection AIS2D_InteractiveContext::MoveTo( - const Standard_Integer Xmin, - const Standard_Integer Ymin, - const Standard_Integer Xmax, - const Standard_Integer Ymax, - const Handle(V2d_View)& aView ) { - - - /*if ( HasOpenedContext() && aView->Viewer() != myCollectorVwr ) { - myWasLastMain = Standard_True; - return myLocalContexts(myCurLocalIndex)->MoveTo( Xmin, Ymin, Xmax, Ymax, aView ); - } - */ - mySeqOfDetIO->Clear(); - - Handle(Graphic2d_DisplayList) thePickList = aView->Pick( Xmin, Ymin, Xmax, Ymax, myPickMode ); - - return Detect( thePickList, aView ); -} - -//SAV -AIS2D_StatusOfDetection AIS2D_InteractiveContext -::Detect( const Handle(Graphic2d_DisplayList)& dList, - const Handle(V2d_View)& aView ) -{ - AIS2D_StatusOfDetection theStat( AIS2D_SOD_Nothing ); - - RectMoveTo = Standard_True; - Handle(V2d_Viewer) theViewer = aView->Viewer(); - Standard_Boolean is_main = ( theViewer == myCollectorVwr ) ? - Standard_False : Standard_True; - if ( is_main ) myWasLastMain = Standard_True; - - Handle(Graphic2d_TransientManager) theDrawer = - Handle(Graphic2d_TransientManager)::DownCast( theViewer->View()->Drawer() ); - - - if ( ! dList->IsEmpty() ) { - Standard_Integer ind = ( is_main ) ? - myMainVwr->InitializeColor(myHighlightColor) : - myCollectorVwr->InitializeColor(myHighlightColor); - Handle(AIS2D_InteractiveObject) theIO; - theDrawer->SetOverride( Standard_True ); - theDrawer->SetOverrideColor( ind ); - theDrawer->BeginDraw( aView->Driver() ); - - for ( int i = 1 ; i <= dList->Length(); i++ ) { - Handle(Graphic2d_GraphicObject) theGOi = dList->Value(i); - if ( theGOi->IsKind(STANDARD_TYPE(AIS2D_InteractiveObject))) { - theIO = Handle(AIS2D_InteractiveObject)::DownCast( theGOi ); - if ( theIO->HasHighlightMode() ) - if ( AvailableToDetect( theIO ) ) { - if ( theIO->HighlightMode() == AIS2D_TOD_OBJECT ) - theIO->Highlight( ind ); - - DoDetectObject( theIO, theDrawer ); - - } else theStat = AIS2D_SOD_Selected; - } - } // end for - theDrawer->EndDraw(); - theDrawer->SetOverride( Standard_False ); - } else { - - theStat = AIS2D_SOD_Nothing; - theDrawer->RestoreArea( aView->Driver() ); - if ( !mySeqOfDetIO->IsEmpty() ) - for ( int i = 1; i<= mySeqOfDetIO->Length(); ++i ) { - mySeqOfDetIO->Value(i)->Unhighlight(); - mySeqOfDetIO->Value(i)->ClearSeqDetPrim(); - } - mySeqOfDetIO->Clear(); - is_main ? myMainVwr->Update() : myCollectorVwr->Update(); - } // end if PickList isn't empty - - - return theStat; -} - -AIS2D_StatusOfPick AIS2D_InteractiveContext::Select( const Standard_Boolean UpdateVwr ) { - - if ( HasOpenedContext() ) - if ( myWasLastMain ) - return myLocalContexts(myCurLocalIndex)->Select(UpdateVwr); - else { - myLocalContexts( myCurLocalIndex )->SetSelected( myLastPicked, UpdateVwr ); - return AIS2D_SOP_OneSelected; - } - - if ( ! mySeqOfDetIO->IsEmpty() ) { - Handle(AIS2D_InteractiveObject) theIO; - Handle(AIS2D_HSequenceOfPrimArchit) thePA; - - switch ( myCurDetectMode ) { - default : - case AIS2D_TOD_OBJECT : { - for ( int i = 1; i <= mySeqOfDetIO->Length(); ++i ) { - theIO = mySeqOfDetIO->Value(i); - if ( ! RectMoveTo ) { - thePA = theIO->GetSelectedSeqPrim(); - if ( ! thePA->IsEmpty() ) { - for ( int j = 1; j <= thePA->Length(); ++j ) - thePA->Value(j)->GetPrimitive()->Unhighlight(); - theIO->ClearSeqSelPrim(); - } - - if ( ! mySeqOfSelIO->IsEmpty() ) - for ( int j = 1; j <= mySeqOfSelIO->Length(); ++j ) { - Unhighlight( mySeqOfSelIO->Value(i), Standard_False ); - mySeqOfSelIO->Value(i)->SetState(0); - mySeqOfSelIO->Remove(i); - } - } - if ( ! theIO->State() ) { - SetCurrentObject( theIO, Standard_False ); - mySeqOfSelIO->Append(theIO); - } - } - theIO->ClearSeqDetPrim(); - } - break; - - case AIS2D_TOD_PRIMITIVE: - { - for ( int i = 1; i <= mySeqOfDetIO->Length(); ++i ) - { - Standard_Integer j; - - theIO = mySeqOfDetIO->Value(i); - theIO->Highlight(myMainVwr->InitializeColor(mySelectionColor)); - theIO->Unhighlight(); - theIO->SetState(1); - - // unselect selected - if ( !RectMoveTo ) - { - - thePA = theIO->GetSelectedSeqPrim(); - for ( j = 1; j <= thePA->Length(); ++j ) - { - thePA->Value(j)->GetPrimitive()->Unhighlight(); - } - theIO->ClearSeqSelPrim(); - - for ( j = 1; j <= mySeqOfSelIO->Length(); ++j ) - { - // by EAV: 12.09.01 - // Unhighlight( mySeqOfSelIO->Value(j), Standard_False ); - mySeqOfSelIO->Value(j)->SetState( 0 ); - mySeqOfSelIO->Remove(j); - } - } - - // select detected - thePA = theIO->GetDetectSeqPrim(); - for ( j = 1; j <= thePA->Length(); ++j ) - { - Handle(Graphic2d_Primitive) thePrim = thePA->Value(j)->GetPrimitive(); - if ( !thePrim ->IsHighlighted() ) { - thePrim->Highlight(); - theIO->AddSelectPrim( thePrim, 0 ); - } - } - if ( ! IsIOSelected( theIO ) ) - mySeqOfSelIO->Append( mySeqOfDetIO->Value(i) ); - - } // end for -#ifndef OCC146 - theIO->ClearSeqDetPrim(); -#endif - } - break; - case AIS2D_TOD_ELEMENT: { - Standard_Integer theInd; - for ( int i = 1; i <= mySeqOfDetIO->Length(); ++i ) { - theIO = mySeqOfDetIO->Value(i); - theIO->Highlight(myMainVwr->InitializeColor(mySelectionColor)); - theIO->Unhighlight(); - theIO->SetState(1); - if ( !RectMoveTo ) { - thePA = theIO->GetSelectedSeqPrim(); - if ( ! thePA->IsEmpty() ) { - for ( int j = 1; j <= thePA->Length(); ++j ) - thePA->Value(j)->GetPrimitive()->Unhighlight(); - theIO->ClearSeqSelPrim(); - } - if ( ! mySeqOfSelIO->IsEmpty() ) - for ( int j = 1; j <= mySeqOfSelIO->Length(); ++j ) { - Unhighlight( mySeqOfSelIO->Value(i), Standard_False ); - mySeqOfSelIO->Value(i)->SetState(0); - mySeqOfSelIO->Remove(i); - } - } - thePA = theIO->GetDetectSeqPrim(); - if ( ! thePA->IsEmpty() ) { - Handle(Graphic2d_Primitive) thePrim; - for ( int j = 1; j <= thePA->Length(); ++j ) { - thePrim = thePA->Value(j)->GetPrimitive(); - theInd = thePA->Value(j)->GetIndex(); - - //SAV - marking that highlighted elements became selected - // fixing regression of element single selection - if ( !thePrim->SetElementsSelected() ) - thePrim->Highlight( theInd ); - else - thePrim->Unhighlight(); - theIO->AddSelectPrim( thePrim, theInd ); - } - } - if ( ! IsIOSelected( theIO ) ) mySeqOfSelIO->Append(mySeqOfDetIO->Value(i)); - } // end for -#ifndef OCC146 - theIO->ClearSeqDetPrim(); -#endif - } - break; - case AIS2D_TOD_VERTEX: { - Standard_Integer theInd; - for ( int i = 1; i <= mySeqOfDetIO->Length(); ++i ) { - theIO = mySeqOfDetIO->Value(i); - theIO->Highlight(myMainVwr->InitializeColor(mySelectionColor)); - theIO->Unhighlight(); - theIO->SetState(1); - if ( !RectMoveTo ) { - thePA = theIO->GetSelectedSeqPrim(); - if ( ! thePA->IsEmpty() ) { - for ( int j = 1; j <= thePA->Length(); ++j ) - thePA->Value(j)->GetPrimitive()->Unhighlight(); - theIO->ClearSeqSelPrim(); - } - if ( ! mySeqOfSelIO->IsEmpty() ) - for ( int j = 1; j <= mySeqOfSelIO->Length(); ++j ) { - Unhighlight( mySeqOfSelIO->Value(i), Standard_False ); - mySeqOfSelIO->Value(i)->SetState(0); - mySeqOfSelIO->Remove(i); - } - } - thePA = theIO->GetDetectSeqPrim(); - if ( ! thePA->IsEmpty() ) { - Handle(Graphic2d_Primitive) thePrim; - for ( int j = 1; j <= thePA->Length(); ++j ) { - thePrim = thePA->Value(j)->GetPrimitive(); - theInd = thePA->Value(j)->GetIndex(); - thePrim->Highlight( theInd ); - theIO->AddSelectPrim( thePrim, theInd ); - } - } - if ( ! IsIOSelected( theIO ) ) mySeqOfSelIO->Append(mySeqOfDetIO->Value(i)); - } // end for -#ifndef OCC146 - theIO->ClearSeqDetPrim(); -#endif - } - break; - } // end switch -#ifndef OCC146 - mySeqOfDetIO->Clear(); -#endif - } else { - - // if sequence of detected objects is empty - if ( ! mySeqOfSelIO->IsEmpty() ) { - switch ( myCurDetectMode ) { - default : - case AIS2D_TOD_OBJECT : { - Handle(AIS2D_InteractiveObject) theIO; - for ( int i = 1; i <= mySeqOfSelIO->Length(); ++i ) { - theIO = mySeqOfSelIO->Value(i); - theIO->Unhighlight(); - theIO->SetState(0); - if ( myObjects.IsBound(theIO) ) - if ( myObjects(theIO)->IsSubIntensityOn() ) - HighlightWithColor( theIO, mySubIntensity, Standard_False ); - } - } - break; - case AIS2D_TOD_PRIMITIVE: { - Handle(AIS2D_InteractiveObject) theIO; - Handle(AIS2D_HSequenceOfPrimArchit) thePA; - for ( int i = 1; i <= mySeqOfSelIO->Length(); ++i ) { - theIO = mySeqOfSelIO->Value(i); - thePA = theIO->GetSelectedSeqPrim(); - theIO->Unhighlight(); - if ( ! thePA->IsEmpty() ) { - for ( int j = 1; j <= thePA->Length(); ++j ) - thePA->Value(j)->GetPrimitive()->Unhighlight(); - theIO->ClearSeqSelPrim(); - } - theIO->SetState(0); - if ( myObjects.IsBound(theIO) ) - if ( myObjects(theIO)->IsSubIntensityOn() ) - HighlightWithColor( theIO, mySubIntensity, Standard_False ); - } - - } - break; - case AIS2D_TOD_ELEMENT: { - Handle(AIS2D_InteractiveObject) theIO; - Handle(AIS2D_HSequenceOfPrimArchit) thePA; - for ( int i = 1; i <= mySeqOfSelIO->Length(); ++i ) { - theIO = mySeqOfSelIO->Value(i); - thePA = theIO->GetSelectedSeqPrim(); - theIO->Unhighlight(); - if ( ! thePA->IsEmpty() ) { - for ( int j = 1; j <= thePA->Length(); ++j ) { - thePA->Value(j)->GetPrimitive()->Unhighlight(); - // SAV - unselecting sub primitives - thePA->Value(j)->GetPrimitive()->ClearSelectedElements(); - } - theIO->ClearSeqSelPrim(); - } - theIO->SetState(0); - if ( myObjects.IsBound(theIO) ) - if ( myObjects(theIO)->IsSubIntensityOn() ) - HighlightWithColor( theIO, mySubIntensity, Standard_False ); - } - } - break; - case AIS2D_TOD_VERTEX: { - Handle(AIS2D_InteractiveObject) theIO; - Handle(AIS2D_HSequenceOfPrimArchit) thePA; - for ( int i = 1; i <= mySeqOfSelIO->Length(); ++i ) { - theIO = mySeqOfSelIO->Value(i); - thePA = theIO->GetSelectedSeqPrim(); - theIO->Unhighlight(); - if ( ! thePA->IsEmpty() ) { - for ( int j = 1; j <= thePA->Length(); ++j ) - thePA->Value(j)->GetPrimitive()->Unhighlight(); - theIO->ClearSeqSelPrim(); - } - theIO->SetState(0); - if ( myObjects.IsBound(theIO) ) - if ( myObjects(theIO)->IsSubIntensityOn() ) - HighlightWithColor( theIO, mySubIntensity, Standard_False ); - } - } - break; - } // end switch - mySeqOfSelIO->Clear(); - } // end if sequence of detected objects isn't empty - - - } - if ( UpdateVwr ) myWasLastMain ? myMainVwr->Update() : UpdateCollector(); - - Standard_Integer NS = mySeqOfSelIO->Length(); - if ( !NS ) return AIS2D_SOP_NothingSelected; - if ( NS == 1 ) return AIS2D_SOP_OneSelected; - - return AIS2D_SOP_SeveralSelected; - -} - -AIS2D_StatusOfPick AIS2D_InteractiveContext::ShiftSelect( const Standard_Boolean UpdateVwr ) -{ - if ( HasOpenedContext() ) { - if ( myWasLastMain ) - return myLocalContexts( myCurLocalIndex )->ShiftSelect( UpdateVwr ); - else { - myLocalContexts( myCurLocalIndex )->AddOrRemoveSelected( myLastPicked, UpdateVwr ); - Standard_Integer NS = mySeqOfSelIO->Length(); - if ( !NS ) return AIS2D_SOP_NothingSelected; - if ( NS == 1 ) return AIS2D_SOP_OneSelected; - return AIS2D_SOP_SeveralSelected; - } - } //end if opened local context exists - - if ( myWasLastMain && !myLastinMain.IsNull() ) - AddOrRemoveCurObject( myLastinMain,UpdateVwr ); - else if ( !myWasLastMain && !myLastinColl.IsNull() ) - AddOrRemoveCurObject( myLastinColl, UpdateVwr ); - - Standard_Integer NS = mySeqOfSelIO->Length(); - if ( NS == 0 ) return AIS2D_SOP_NothingSelected; - if ( NS == 1 ) return AIS2D_SOP_OneSelected; - return AIS2D_SOP_SeveralSelected; - -} - -AIS2D_StatusOfPick AIS2D_InteractiveContext::ShiftSelect( - const Standard_Integer /*XPMin*/, - const Standard_Integer /*YPMin*/, - const Standard_Integer /*XPMax*/, - const Standard_Integer /*YPMax*/, - const Handle(V2d_View)& /*aView*/, - const Standard_Boolean /*UpdateVwr*/ ) -{ -/* - if ( HasOpenedContext() ) - return myLocalContexts( myCurLocalIndex )->ShiftSelect( XPMin, YPMin, XPMax, YPMax, aView, UpdateVwr ); - - UnhighlightCurrent(Standard_False); - // static Handle(StdSelect_ViewerSelector2d) aSelector; - - if ( aView->Viewer() == myMainVwr) { - // aSelector= myMainSelector; - myWasLastMain = Standard_True;} - - else if (aView->Viewer() == myCollectorVwr){ - // aSelector= myCollectorSel; - myWasLastMain = Standard_False;} - else - return AIS2D_SOP_NothingSelected; - aSelector->SetSensitivity( aView->Convert(mySensitivity) ); - aSelector->Pick( XPMin, YPMin, XPMax, YPMax, aView ); - AIS2D_Selection::SetCurrentSelection( myCurrentName.ToCString() ); - for ( aSelector->Init(); aSelector->More(); aSelector->Next() ) { - const Handle(SelectMgr_SelectableObject)& SObj = aSelector->Picked()->Selectable(); - if ( !SObj.IsNull() ) { - AIS2D_SelectStatus SelStat = AIS2D_Selection::Select(SObj); - Standard_Integer mod = (SelStat == AIS2D_SS_Added) ? 1 : 0; - ( * ( (Handle(AIS2D_InteractiveObject)* ) & SObj ) )->SetState(mod); - } - } - - HighlightCurrent( UpdateVwr ); - - Standard_Integer NS = NbCurrents(); - if ( NS == 0 ) return AIS2D_SOP_NothingSelected; - if ( NS == 1 ) return AIS2D_SOP_OneSelected; - return AIS2D_SOP_SeveralSelected; - */ - return AIS2D_SOP_NothingSelected; -} - - Standard_Integer AIS2D_InteractiveContext::NbSelected() const -{ - if ( mySeqOfSelIO->IsEmpty() ) - return 0; - - Standard_Integer nsel = 0; - switch ( myCurDetectMode ) - { - case AIS2D_TOD_ELEMENT: - case AIS2D_TOD_VERTEX: - case AIS2D_TOD_PRIMITIVE: - { - for ( int i = 1; i <= mySeqOfSelIO->Length(); ++i ) - { - Handle( AIS2D_InteractiveObject ) io = mySeqOfSelIO->Value( i ); - if ( !io.IsNull() ) - nsel += io->GetSelectedSeqPrim()->Length(); - } - break; - } - default : - nsel = mySeqOfSelIO->Length(); break; - } - return nsel; -} - - void AIS2D_InteractiveContext::InitSelected() -{ - myCurSelected = 1; - myMaxSelected = NbSelected(); -} - -Standard_Boolean AIS2D_InteractiveContext::MoreSelected() const -{ - return myCurSelected <= myMaxSelected; -} - -void AIS2D_InteractiveContext::NextSelected() -{ - myCurSelected++; -} - -Handle( MMgt_TShared ) AIS2D_InteractiveContext::SelectedObject() const -{ - switch ( myCurDetectMode ) - { - case AIS2D_TOD_ELEMENT: - case AIS2D_TOD_VERTEX: - case AIS2D_TOD_PRIMITIVE: - { - Standard_Integer current = 0; - for ( int i = 1; i <= mySeqOfSelIO->Length(); ++i ) - { - Handle( AIS2D_InteractiveObject ) io = mySeqOfSelIO->Value( i ); - if ( !io.IsNull() ) - { - Standard_Integer l = io->GetSelectedSeqPrim()->Length(); - if ( myCurSelected <= current + l ) - { - return io->GetSelectedSeqPrim()->Value( myCurSelected - current )->GetPrimitive(); - } - current += l; - } - } - break; - } - default: break; - } - return mySeqOfSelIO->Value( myCurSelected ); -} - -// ******************************************************************************* -// Immediate Mode Management -// ******************************************************************************* - -void AIS2D_InteractiveContext::BeginImmediateDraw( const Handle(V2d_View)& aView ) { - - Handle(V2d_Viewer) theViewer = aView->Viewer(); - Handle(Graphic2d_TransientManager) theDrawer = - Handle(Graphic2d_TransientManager)::DownCast( theViewer->View()->Drawer() ); - theDrawer->BeginDraw( aView->Driver() ); - -} - -void AIS2D_InteractiveContext::ImmediateDraw( const Handle(AIS2D_InteractiveObject)& anIObj, - const Handle(V2d_View)& aView ) { - - Handle(V2d_Viewer) theViewer = aView->Viewer(); - Handle(Graphic2d_TransientManager) theDrawer = - Handle(Graphic2d_TransientManager)::DownCast( theViewer->View()->Drawer() ); - theDrawer->Draw( anIObj ); - -} - -void AIS2D_InteractiveContext::EndImmediateDraw( const Handle(V2d_View)& aView ) { - Handle(V2d_Viewer) theViewer = aView->Viewer(); - Handle(Graphic2d_TransientManager) theDrawer = - Handle(Graphic2d_TransientManager)::DownCast( theViewer->View()->Drawer() ); - theDrawer->EndDraw(); -} - -Standard_Boolean AIS2D_InteractiveContext::IsImmediateModeOn(const Handle(V2d_View)& /*aView*/) const { -return Standard_False; -} - -//SAV -void AIS2D_InteractiveContext::SetDetectionMode( const AIS2D_TypeOfDetection mode ) -{ - myCurDetectMode = mode; -} diff --git a/src/AIS2D/AIS2D_InteractiveContext.lxx b/src/AIS2D/AIS2D_InteractiveContext.lxx deleted file mode 100755 index e93e67b812..0000000000 --- a/src/AIS2D/AIS2D_InteractiveContext.lxx +++ /dev/null @@ -1,66 +0,0 @@ -// Copyright (c) 1999-2012 OPEN CASCADE SAS -// -// The content of this file is subject to the Open CASCADE Technology Public -// License Version 6.5 (the "License"). You may not use the content of this file -// except in compliance with the License. Please obtain a copy of the License -// at http://www.opencascade.org and read it completely before using this file. -// -// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its -// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. -// -// The Original Code and all software distributed under the License is -// distributed on an "AS IS" basis, without warranty of any kind, and the -// Initial Developer hereby disclaims all such warranties, including without -// limitation, any warranties of merchantability, fitness for a particular -// purpose or non-infringement. Please see the License for the specific terms -// and conditions governing the rights and limitations under the License. - -inline Handle(V2d_Viewer) AIS2D_InteractiveContext::CurrentViewer() const { - - return myMainVwr; -} - -inline Standard_Boolean AIS2D_InteractiveContext::IsCollectorClosed() const { - return myIsCollClosed; -} - -inline void AIS2D_InteractiveContext::CloseCollector() { - myIsCollClosed = Standard_True; -} - -inline Standard_Boolean AIS2D_InteractiveContext::HasOpenedContext() const { - return myCurLocalIndex != 0; -} - -inline void AIS2D_InteractiveContext::SetPrecision( const Standard_Integer aPrec ) { - myDetectPrecision = aPrec; -} - -inline Standard_Integer AIS2D_InteractiveContext::DetectPrecision() const { - return myDetectPrecision; -} - -inline Quantity_NameOfColor AIS2D_InteractiveContext::HighlightColor() const { - return myHighlightColor; -} - -inline Quantity_NameOfColor AIS2D_InteractiveContext::SelectionColor() const { - return mySelectionColor; -} - - -inline Quantity_NameOfColor AIS2D_InteractiveContext::SubIntensityColor() const { - return mySubIntensity; -} - -inline Standard_Integer AIS2D_InteractiveContext::DisplayMode() const { - return myDisplayMode; -} - -inline Graphic2d_PickMode AIS2D_InteractiveContext::GetPickMode() const { - return myPickMode; -} - -inline void AIS2D_InteractiveContext::SetPickMode(const Graphic2d_PickMode aPickMode ) { - myPickMode = aPickMode; -} diff --git a/src/AIS2D/AIS2D_InteractiveObject.cdl b/src/AIS2D/AIS2D_InteractiveObject.cdl deleted file mode 100755 index 6a3378c8ce..0000000000 --- a/src/AIS2D/AIS2D_InteractiveObject.cdl +++ /dev/null @@ -1,281 +0,0 @@ --- Created on: 2000-04-07 --- Created by: Tanya COOL --- Copyright (c) 2000-2012 OPEN CASCADE SAS --- --- The content of this file is subject to the Open CASCADE Technology Public --- License Version 6.5 (the "License"). You may not use the content of this file --- except in compliance with the License. Please obtain a copy of the License --- at http://www.opencascade.org and read it completely before using this file. --- --- The Initial Developer of the Original Code is Open CASCADE S.A.S., having its --- main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. --- --- The Original Code and all software distributed under the License is --- distributed on an "AS IS" basis, without warranty of any kind, and the --- Initial Developer hereby disclaims all such warranties, including without --- limitation, any warranties of merchantability, fitness for a particular --- purpose or non-infringement. Please see the License for the specific terms --- and conditions governing the rights and limitations under the License. - - -class InteractiveObject from AIS2D inherits GraphicObject from Graphic2d - - ---Purpose: Class Interactive Object defines a class of objects - -- with display and selection services. - -- Using visualization and selection machanisms, - -- interactive objects are used to display datum, curves, - -- shapes, markers, dimensions, etc. Interactive objects - -- also provide links to the interactive context. - -uses - - Primitive from Graphic2d, - TypeOfDetection from AIS2D, - KindOfIO from AIS2D, - InteractiveContext from AIS2D, - Drawer from Prs2d, - AspectRoot from Prs2d, - AspectName from Prs2d, - DataMapOfPrimAspects from AIS2D, - HSequenceOfPrimArchit from AIS2D, - AsciiString from TCollection, - FStream from Aspect, - IFStream from Aspect - -is - - Create returns mutable InteractiveObject from AIS2D; - ---Purpose: Initialize the Interactive Object - - -------------------------------------------------------------------- - ---Category: Methods for attributes management - - Attributes( me ) returns Drawer from Prs2d; - ---C++: inline - ---Level: Public - ---Purpose: Returns the attributes settings - - SetAttributes( me: mutable; aDrawer: Drawer from Prs2d ) is virtual; - ---Level: Public - ---Purpose: Initializes the drawing tool - - UnsetAttributes( me: mutable ) is virtual; - ---Level: Public - ---Purpose: Clears settings provided by the drawing tool - - SetAspect( me: mutable; anAspect: AspectRoot from Prs2d ); - ---Level: Public - ---Purpose: Sets the attributes from Aspect - -- to all primitives appropriate this Aspect. - - SetAspect( me: mutable; anAspect: AspectRoot from Prs2d; - aPrimitive: Primitive from Graphic2d ); - ---Level: Public - ---Purpose: Sets the attributes from Aspect - -- to primitive - -- Method works only for objects are linked - -- with InteractiveContext - - GetAspect( me; aPrimitive: Primitive from Graphic2d ) - returns AspectRoot from Prs2d; - ---Level: Public - ---Purpose: Returns Aspect for primitive - -- Method works only for objects are linked - -- with InteractiveContext - - HasAspect( me; aPrimitive: Primitive from Graphic2d ) - returns Boolean from Standard; - ---Level: Public; - ---Purpose: Returns true if primitive - -- is linked with an aspect - -------------------------------------------------------------------- - ---Category: Link To InteractiveContext - - HasInteractiveContext( me ) returns Boolean from Standard; - ---Level: Public - ---Purpose: Indicates whether the Interactive Object has a pointer - -- to an interactive context. - - GetContext( me ) returns InteractiveContext from AIS2D; - ---Level: Public - ---Purpose: Returns the context pointer to the interactive context. - - SetContext( me:mutable; aCntx : InteractiveContext from AIS2D ) is virtual; - ---Level: Public - ---Purpose: Places a link to . The drawer of AIS2D_InteractiveObject - -- is connected to the Default Drawer Of . - -- That Means that this method has to be redefined if - -- computations depend on drawer values. - - - -------------------------------------------------------------------- - ---Category: Methods for display modes management - - DisplayMode( me ) returns Integer; - ---C++: inline - ---Level: Public - ---Purpose: Indicates the display mode of the Interactive Object - - HasDisplayMode ( me ) returns Boolean from Standard; - ---C++: inline - ---Level: Public - ---Purpose: Returns True if the Interactive Object has - -- a display mode setting. Otherwise, it is - -- displayed in Neutral Point. - - SetDisplayMode( me: mutable; aMode: Integer from Standard ); - ---C++: inline - ---Level: Public - ---Purpose: Allows to provide a setting for an - -- Interactive Object's display mode. - - UnsetDisplayMode( me: mutable ); - ---C++: inline - ---Level: Public - ---Purpose: Removes display mode settings from the Interactive object - - DefaultDisplayMode( me ) returns Integer from Standard is virtual; - ---C++: inline - ---Level: Public - ---Purpose: Returns the default display mode. This method is to be - -- implemented when the main mode is not mode 0. - - AcceptDisplayMode( me; aMode: Integer from Standard ) returns Boolean from Standard is virtual; - ---C++: inline - ---Level: Public - ---Purpose: Returns true if the class of objects accepts the display mode - - -------------------------------------------------------------------- - ---Category: Methods for highlight modes management - - HighlightMode( me ) returns TypeOfDetection from AIS2D; - ---C++: inline - ---Level: Public - ---Purpose: Returns the setting for highlight mode. - - HasHighlightMode( me ) returns Boolean from Standard; - ---C++: inline - ---Level: Public - ---Purpose: Returns true if the Interactive Object is in highlight mode - - SetHighlightMode( me: mutable; aMode: TypeOfDetection from AIS2D ); - ---C++: inline - ---Level: Public - ---Purpose: Allows to provide settings for highlight mode. - - UnsetHighlightMode( me: mutable ); - ---C++: inline - ---Level: Public - ---Purpose: Removes settings for highlight mode - - DefaultHighlightMode( me ) returns TypeOfDetection from AIS2D is virtual; - ---C++: inline - ---Level: Public - ---Purpose: Returns the default highlight mode - - -------------------------------------------------------------------- - ---Category: Methods for selection modes management - -------------------------------------------------------------------- - - SelectionMode( me ) returns Integer from Standard; - ---C++: inline - ---Level: Public - ---Purpose: Indicates the selection mode of the Interactive Object - - HasSelectionMode( me ) returns Boolean from Standard; - ---C++: inline - ---Level: Public - ---Purpose: Allows you to change the selection mode of an Interactive Object - - SetSelectionMode( me: mutable; aMode: Integer from Standard ); - ---C++: inline - ---Level: Public - ---Purpose: Allows to provide a setting for an - -- Interactive Object's selection mode. - - UnsetSelectionMode( me: mutable ); - ---C++: inline - ---Level: Public - ---Purpose: Removes settings for selection mode - - DefaultSelectionMode( me ) returns Integer from Standard is virtual; - ---C++: inline - ---Level: Public - ---Purpose: Returns the default selection mode - - PrimitiveExist( me; aName: AspectName from Prs2d ) - returns Boolean from Standard is private; - ---Level: Internal - - State( me ) returns Integer from Standard; - ---C++: inline - ---Level: Internal - ---Purpose: - - SetState( me: mutable; aState: Integer from Standard ); - ---C++: inline - ---Level: Internal - ---Purpose: - - SelectPrimitive (me : mutable; anIndex: Integer from Standard; - append: Boolean from Standard ); - ---Level: Public - ---Purpose: Selects primitive with index( TOD_PRIMITIVE mode only ) - - AddDetectPrim( me: mutable; aPrim: Primitive from Graphic2d; - anInd: Integer from Standard ) is private; - ---Level: Internal - ---Purpose: - - AddSelectPrim( me: mutable; aPrim: Primitive from Graphic2d; - anInd: Integer from Standard ) is private; - ---Level: Internal - ---Purpose: - - RemoveSelectPrim( me: mutable; aPrim: Primitive from Graphic2d; - anInd: Integer from Standard ) is private; - ---Level: Internal - ---Purpose: - - SetSelSeqPrim( me: mutable; aSeq: HSequenceOfPrimArchit from AIS2D ) is private; - ---Level: Internal - ---Purpose: - - ClearSeqDetPrim( me: mutable ) is private; - ---Level: Internal - ---Purpose: - - ClearSeqSelPrim( me: mutable ) is private; - ---Level: Internal - ---Purpose: - - GetDetectSeqPrim( me ) returns HSequenceOfPrimArchit from AIS2D is private; - ---Level: Internal - ---Purpose: - - GetSelectedSeqPrim( me ) returns HSequenceOfPrimArchit from AIS2D is private; - ---Level: Internal - ---Purpose: - - -------------------------------------------------------------------- - - Save(me; aFStream: in out FStream from Aspect) is virtual; - Retrieve(me; anIFStream: in out IFStream from Aspect) is virtual; - -fields - - myICTX : InteractiveContext from AIS2D; - myDrawer : Drawer from Prs2d is protected; - myDisplayMode : Integer from Standard; - myHighlightMode : TypeOfDetection from AIS2D is protected; - mySelectionMode : Integer from Standard; - myAspects : DataMapOfPrimAspects from AIS2D; - myState : Integer from Standard; - myDetectedPrimSeq : HSequenceOfPrimArchit from AIS2D; - mySelectedPrimSeq : HSequenceOfPrimArchit from AIS2D; - -friends - - class InteractiveContext from AIS2D - -end InteractiveObject; diff --git a/src/AIS2D/AIS2D_InteractiveObject.cxx b/src/AIS2D/AIS2D_InteractiveObject.cxx deleted file mode 100755 index 69caa6429a..0000000000 --- a/src/AIS2D/AIS2D_InteractiveObject.cxx +++ /dev/null @@ -1,482 +0,0 @@ -// Copyright (c) 1999-2012 OPEN CASCADE SAS -// -// The content of this file is subject to the Open CASCADE Technology Public -// License Version 6.5 (the "License"). You may not use the content of this file -// except in compliance with the License. Please obtain a copy of the License -// at http://www.opencascade.org and read it completely before using this file. -// -// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its -// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. -// -// The Original Code and all software distributed under the License is -// distributed on an "AS IS" basis, without warranty of any kind, and the -// Initial Developer hereby disclaims all such warranties, including without -// limitation, any warranties of merchantability, fitness for a particular -// purpose or non-infringement. Please see the License for the specific terms -// and conditions governing the rights and limitations under the License. - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#define NUM_ASPECTROOT 29 - - -AIS2D_InteractiveObject::AIS2D_InteractiveObject() - - : Graphic2d_GraphicObject(), - myDrawer( new Prs2d_Drawer() ), - myHighlightMode( AIS2D_TOD_PRIMITIVE ), - myICTX(), - myDisplayMode( 0 ), - mySelectionMode( 0 ), - myAspects(), - myState( 0 ), - myDetectedPrimSeq( new AIS2D_HSequenceOfPrimArchit() ), - mySelectedPrimSeq( new AIS2D_HSequenceOfPrimArchit() ) - -{ - AIS2D_DataMapOfPrimAspects theAspect(NUM_ASPECTROOT); - myAspects = theAspect; -printf(" $$$ Creates AIS2D_InteractiveObject()\n"); -} - -void AIS2D_InteractiveObject::SetAttributes( const Handle(Prs2d_Drawer)& aDrawer ) { - myDrawer = aDrawer; -} - -void AIS2D_InteractiveObject::UnsetAttributes() { - myDrawer = new Prs2d_Drawer(); -} - -void AIS2D_InteractiveObject::SetAspect( const Handle(Prs2d_AspectRoot)& anAspect ) { - - if ( ! PrimitiveExist(anAspect->GetAspectName()) ) return; - - switch ( anAspect->GetAspectName() ) { - - case Prs2d_AN_LINE: { - - if ( GetContext().IsNull() ) { - myDrawer->SetAspect( anAspect, Prs2d_AN_LINE ); - return; - } - Handle(Prs2d_AspectLine) theAspLine = - Handle(Prs2d_AspectLine)::DownCast( anAspect ); - - Quantity_Color aColor; - Aspect_TypeOfLine aType; - Aspect_WidthOfLine aWidth; - - Quantity_Color aIntColor; - Graphic2d_TypeOfPolygonFilling aTypeFill; - Standard_Integer aTile; - Standard_Boolean aDrawEdge; - - theAspLine->ValuesOfLine( aColor, aType, aWidth ); - theAspLine->ValuesOfPoly( aIntColor, aTypeFill, aTile, aDrawEdge ); - - Standard_Integer colorInd = theAspLine->ColorIndex(); - Standard_Integer typeInd = theAspLine->TypeIndex(); - Standard_Integer widthInd = theAspLine->WidthIndex(); - Standard_Integer colorIntInd = theAspLine->InterColorIndex(); - - if ( !colorInd ) { - colorInd = GetContext()->InitializeColor( aColor ); - theAspLine->SetColorIndex( colorInd ); - } - - if ( !typeInd ) { - typeInd = GetContext()->InitializeStyle( aType ); - theAspLine->SetTypeIndex( typeInd ); - } - - if ( !widthInd ) { - widthInd = GetContext()->InitializeWidth( aWidth ); - theAspLine->SetWidthIndex( widthInd ); - } - - if ( !colorIntInd ) { - colorIntInd = GetContext()->InitializeColor( aIntColor ); - theAspLine->SetIntColorInd( colorIntInd ); - } - - if ( this->IsKind(STANDARD_TYPE(AIS2D_ProjShape) ) ) { - - Handle(AIS2D_ProjShape) thePS = Handle(AIS2D_ProjShape)::DownCast(this); - Handle(Graphic2d_Line) theLines = thePS->GetPrimitives(); - theLines->SetColorIndex( colorInd ); - theLines->SetTypeIndex( typeInd ); - theLines->SetWidthIndex( widthInd ); - - if ( thePS->IsHLMode() ) { - Handle(Graphic2d_Line) theHLines = thePS->GetHLPrimitives(); - theHLines->SetColorIndex( colorInd ); - theHLines->SetWidthIndex( widthInd ); - Standard_Integer theDashInd = GetContext()->InitializeStyle( Aspect_TOL_DASH ); - theHLines->SetTypeIndex( theDashInd ); - } - - - } else - - for ( Standard_Integer i = 1; i <= Length(); i++ ) { - - if ( Primitive(i)->IsKind(STANDARD_TYPE(Graphic2d_Line)) ) { - - Handle(Graphic2d_Line) theLine = - Handle(Graphic2d_Line)::DownCast( Primitive(i) ); - - theLine->SetColorIndex( colorInd ); - theLine->SetTypeIndex( typeInd ); - theLine->SetWidthIndex( widthInd ); - - theLine->SetInteriorColorIndex( colorIntInd ); - theLine->SetTypeOfPolygonFilling( aTypeFill ); - theLine->SetInteriorPattern( aTile ); - theLine->SetDrawEdge( aDrawEdge ); - - if ( !myAspects.IsBound(theLine) ) - myAspects.Bind( theLine, theAspLine ); - else - myAspects( theLine ) = theAspLine; - - } // end if STANDARD_TYPE is Graphic2d_Line - - } // end for - - break; - - } // end case Prs2d_AN_LINE - - case Prs2d_AN_HIDDENLINE: { - } - case Prs2d_AN_TEXT: { - } - case Prs2d_AN_HIDINGPOLY: { - } - case Prs2d_AN_HIDINGTEXT: { - } - case Prs2d_AN_FRAMEDTEXT: { - } - case Prs2d_AN_LAST: { - } - case Prs2d_AN_UNKNOWN: { - } - } - myDrawer->SetAspect( anAspect, anAspect->GetAspectName() ); - if ( !GetContext().IsNull() ) - GetContext()->CurrentViewer()->Update(); - -} - -void AIS2D_InteractiveObject::SetAspect( const Handle(Prs2d_AspectRoot)& anAspect, - const Handle(Graphic2d_Primitive)& aPrim ) { - - if ( ( GetContext().IsNull() ) || ( !IsIn(aPrim) ) ) return; - - switch ( anAspect->GetAspectName() ) { - - case Prs2d_AN_LINE: { - - if ( aPrim->IsKind(STANDARD_TYPE(Graphic2d_Line)) ) { - - Handle(Prs2d_AspectLine) theAspLine = - Handle(Prs2d_AspectLine)::DownCast( anAspect ); - - Quantity_Color aColor; - Aspect_TypeOfLine aType; - Aspect_WidthOfLine aWidth; - - Quantity_Color aIntColor; - Graphic2d_TypeOfPolygonFilling aTypeFill; - Standard_Integer aTile; - Standard_Boolean aDrawEdge; - - theAspLine->ValuesOfLine( aColor, aType, aWidth ); - theAspLine->ValuesOfPoly( aIntColor, aTypeFill, aTile, aDrawEdge ); - - Standard_Integer colorInd = theAspLine->ColorIndex(); - Standard_Integer typeInd = theAspLine->TypeIndex(); - Standard_Integer widthInd = theAspLine->WidthIndex(); - Standard_Integer colorIntInd = theAspLine->InterColorIndex(); - - if ( !colorInd ) { - colorInd = GetContext()->InitializeColor( aColor ); - theAspLine->SetColorIndex( colorInd ); - } - - if ( !typeInd ) { - typeInd = GetContext()->InitializeStyle( aType ); - theAspLine->SetTypeIndex( typeInd ); - } - - if ( !widthInd ) { - widthInd = GetContext()->InitializeWidth( aWidth ); - theAspLine->SetWidthIndex( widthInd ); - } - - if ( !colorIntInd ) { - colorIntInd = GetContext()->InitializeColor( aIntColor ); - theAspLine->SetIntColorInd( colorIntInd ); - } - - Handle(Graphic2d_Line) theLine = Handle(Graphic2d_Line)::DownCast( aPrim ); - - theLine->SetColorIndex( colorInd ); - theLine->SetTypeIndex( typeInd ); - theLine->SetWidthIndex( widthInd ); - - theLine->SetInteriorColorIndex( colorIntInd ); - theLine->SetTypeOfPolygonFilling( aTypeFill ); - theLine->SetInteriorPattern( aTile ); - theLine->SetDrawEdge( aDrawEdge ); - - if ( !myAspects.IsBound(aPrim) ) - myAspects.Bind( theLine, theAspLine ); - else - myAspects( theLine ) = theAspLine; - - } // end if STANDARD_TYPE is Graphic2d_Line - break; - - } // end case Prs2d_AN_LINE - - case Prs2d_AN_HIDDENLINE: { - break; - } - case Prs2d_AN_TEXT: { - break; - } - case Prs2d_AN_HIDINGPOLY: { - break; - } - case Prs2d_AN_HIDINGTEXT: { - break; - } - case Prs2d_AN_FRAMEDTEXT: { - break; - } - case Prs2d_AN_LAST: { - break; - } - case Prs2d_AN_UNKNOWN: { - break; - } - - } // end switch - - myDrawer->SetAspect( anAspect, anAspect->GetAspectName() ); - GetContext()->CurrentViewer()->Update(); - -} - -Handle(Prs2d_AspectRoot) AIS2D_InteractiveObject::GetAspect - ( const Handle(Graphic2d_Primitive)& aPrim ) const { - - return myAspects( aPrim ); -} - -Standard_Boolean AIS2D_InteractiveObject::HasAspect - ( const Handle(Graphic2d_Primitive)& aPrim ) const { - - return myAspects.IsBound( aPrim ); -} - -Standard_Boolean AIS2D_InteractiveObject::HasInteractiveContext() const { - return ( ! myICTX.IsNull() ); -} - -Handle(AIS2D_InteractiveContext) AIS2D_InteractiveObject::GetContext() const { - return myICTX; -} - -void AIS2D_InteractiveObject::SetContext( const Handle(AIS2D_InteractiveContext)& aCtx) { - - myICTX = aCtx; - if ( myDrawer.IsNull() ) - myDrawer = new Prs2d_Drawer; - -} - -void AIS2D_InteractiveObject::SelectPrimitive (const Standard_Integer anIndex, const Standard_Boolean append ) -{ - if ( !append ) - { // unselect all - for ( Standard_Integer i = 1; i <= mySelectedPrimSeq->Length(); i++ ) - mySelectedPrimSeq->Value( i )->GetPrimitive()->Unhighlight(); - mySelectedPrimSeq->Clear(); - SetState( 0 ); - } - // select new primitive - SetPickedIndex( anIndex ); -} - -Standard_Boolean AIS2D_InteractiveObject::PrimitiveExist( const Prs2d_AspectName aName) const { - - Standard_Boolean isFound = Standard_False; - - for ( Standard_Integer i = 1; i <= Length(); i++ ) - - switch ( aName ) { - case Prs2d_AN_LINE: { - if ( Primitive(i)->IsKind(STANDARD_TYPE(Graphic2d_Line)) ) - isFound = Standard_True; - break; - } - case Prs2d_AN_HIDDENLINE: { - break; - } - case Prs2d_AN_TEXT: { - break; - } - case Prs2d_AN_HIDINGPOLY: { - break; - } - case Prs2d_AN_HIDINGTEXT: { - break; - } - case Prs2d_AN_FRAMEDTEXT: { - break; - } - case Prs2d_AN_LAST: { - break; - } - case Prs2d_AN_UNKNOWN: { - break; - } - } // end switch - - - return isFound; -} - -void AIS2D_InteractiveObject::AddDetectPrim ( const Handle(Graphic2d_Primitive)& aPrim, - const Standard_Integer anInd) { - - Handle(AIS2D_PrimitiveArchit) thePA = new AIS2D_PrimitiveArchit( aPrim, anInd ); - myDetectedPrimSeq->Append( thePA ); - -} - -void AIS2D_InteractiveObject::AddSelectPrim ( const Handle(Graphic2d_Primitive)& aPrim, - const Standard_Integer anInd) { - - Handle(AIS2D_PrimitiveArchit) thePA = new AIS2D_PrimitiveArchit( aPrim, anInd ); - mySelectedPrimSeq->Append( thePA ); - -} - -void AIS2D_InteractiveObject::RemoveSelectPrim ( const Handle(Graphic2d_Primitive)& aPrim, - const Standard_Integer anInd) { - - if ( mySelectedPrimSeq->IsEmpty() ) return; - for ( int i = 1; i <= mySelectedPrimSeq->Length(); ++i ) - if ( mySelectedPrimSeq->Value(i)->GetPrimitive() == aPrim && - mySelectedPrimSeq->Value(i)->GetIndex() == anInd ) { - mySelectedPrimSeq->Remove(i); - return; - } -} - -void AIS2D_InteractiveObject::SetSelSeqPrim( const Handle(AIS2D_HSequenceOfPrimArchit)& aSeq ) { - - mySelectedPrimSeq = aSeq; - -} - -void AIS2D_InteractiveObject::ClearSeqDetPrim() { - - myDetectedPrimSeq->Clear(); - -} - -void AIS2D_InteractiveObject::ClearSeqSelPrim() { - - mySelectedPrimSeq->Clear(); - -} - -Handle(AIS2D_HSequenceOfPrimArchit) AIS2D_InteractiveObject::GetDetectSeqPrim() const { - - return myDetectedPrimSeq; - -} - -Handle(AIS2D_HSequenceOfPrimArchit) AIS2D_InteractiveObject::GetSelectedSeqPrim() const { - - return mySelectedPrimSeq; - -} - -void AIS2D_InteractiveObject::Save(Aspect_FStream& aFStream) const -{ - int lnOfPr = Length(); - - *aFStream << "AIS2D_InteractiveObject" << endl; - for (int j = 1; j <= lnOfPr; j++) - { - Handle(Graphic2d_Primitive) thePrm = this->Primitive(j); - thePrm->Save(aFStream); - } -} - -void AIS2D_InteractiveObject::Retrieve(Aspect_IFStream& anIFStream) const -{ - char buf[100]; - anIFStream->getline(buf, 100); - while (! anIFStream->eof()) - { - if (! strcmp(buf, "Graphic2d_Segment")) - { - Graphic2d_Segment::Retrieve(anIFStream, this); - } - else if (! strcmp(buf, "Graphic2d_InfiniteLine")) - { - Graphic2d_InfiniteLine::Retrieve(anIFStream, this); - } - else if (! strcmp(buf, "Graphic2d_Polyline")) - { - Graphic2d_Polyline::Retrieve(anIFStream, this); - } - else if (! strcmp(buf, "Graphic2d_PolylineMarker")) - { - Graphic2d_PolylineMarker::Retrieve(anIFStream, this); - } - else if (! strcmp(buf, "Graphic2d_Circle")) - { - Graphic2d_Circle::Retrieve(anIFStream, this); - } - else if (! strcmp(buf, "Graphic2d_CircleMarker")) - { - Graphic2d_CircleMarker::Retrieve(anIFStream, this); - } - else if (! strcmp(buf, "Graphic2d_Ellips")) - { - Graphic2d_Ellips::Retrieve(anIFStream, this); - } - else if (! strcmp(buf, "Graphic2d_EllipsMarker")) - { - Graphic2d_EllipsMarker::Retrieve(anIFStream, this); - } - else if (! strcmp(buf, "GGraphic2d_Curve")) - { - GGraphic2d_Curve::Retrieve(anIFStream, this); - } - anIFStream->getline(buf, 100); - } -} - diff --git a/src/AIS2D/AIS2D_InteractiveObject.lxx b/src/AIS2D/AIS2D_InteractiveObject.lxx deleted file mode 100755 index ad7c6d2196..0000000000 --- a/src/AIS2D/AIS2D_InteractiveObject.lxx +++ /dev/null @@ -1,92 +0,0 @@ -// Copyright (c) 1999-2012 OPEN CASCADE SAS -// -// The content of this file is subject to the Open CASCADE Technology Public -// License Version 6.5 (the "License"). You may not use the content of this file -// except in compliance with the License. Please obtain a copy of the License -// at http://www.opencascade.org and read it completely before using this file. -// -// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its -// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. -// -// The Original Code and all software distributed under the License is -// distributed on an "AS IS" basis, without warranty of any kind, and the -// Initial Developer hereby disclaims all such warranties, including without -// limitation, any warranties of merchantability, fitness for a particular -// purpose or non-infringement. Please see the License for the specific terms -// and conditions governing the rights and limitations under the License. - -inline Handle(Prs2d_Drawer) AIS2D_InteractiveObject::Attributes() const { - return myDrawer; -} - -inline Standard_Integer AIS2D_InteractiveObject::DisplayMode() const { - return myDisplayMode; -} - -inline Standard_Boolean AIS2D_InteractiveObject::HasDisplayMode() const { - return myDisplayMode != -1; -} - -inline void AIS2D_InteractiveObject::SetDisplayMode( const Standard_Integer aMode ) { - myDisplayMode = aMode; -} - -inline void AIS2D_InteractiveObject::UnsetDisplayMode() { - myDisplayMode = -1; -} - -inline Standard_Integer AIS2D_InteractiveObject::DefaultDisplayMode() const { - return 0; -} - -inline Standard_Boolean AIS2D_InteractiveObject::AcceptDisplayMode( const Standard_Integer /*aMode*/ ) const { - return Standard_True; -} - -inline AIS2D_TypeOfDetection AIS2D_InteractiveObject::HighlightMode() const { - return myHighlightMode; -} - -inline Standard_Boolean AIS2D_InteractiveObject::HasHighlightMode() const { - return myHighlightMode != AIS2D_TOD_NONE; -} - -inline void AIS2D_InteractiveObject::SetHighlightMode( const AIS2D_TypeOfDetection aMode ) { - myHighlightMode = aMode; -} - -inline void AIS2D_InteractiveObject::UnsetHighlightMode() { - myHighlightMode = AIS2D_TOD_NONE; -} - -inline AIS2D_TypeOfDetection AIS2D_InteractiveObject::DefaultHighlightMode() const { - return AIS2D_TOD_PRIMITIVE; -} - -inline Standard_Integer AIS2D_InteractiveObject::SelectionMode() const { - return mySelectionMode; -} - -inline Standard_Boolean AIS2D_InteractiveObject::HasSelectionMode() const { - return mySelectionMode != -1; -} - -inline void AIS2D_InteractiveObject::SetSelectionMode( const Standard_Integer aMode ) { - mySelectionMode = aMode; -} - -inline void AIS2D_InteractiveObject::UnsetSelectionMode() { - mySelectionMode = -1; -} - -inline Standard_Integer AIS2D_InteractiveObject::DefaultSelectionMode() const { - return 0; -} - -inline Standard_Integer AIS2D_InteractiveObject::State() const { - return myState; -} - -inline void AIS2D_InteractiveObject::SetState( const Standard_Integer aState ) { - myState = aState; -} diff --git a/src/AIS2D/AIS2D_LocalContext.cdl b/src/AIS2D/AIS2D_LocalContext.cdl deleted file mode 100755 index 74e8d195a3..0000000000 --- a/src/AIS2D/AIS2D_LocalContext.cdl +++ /dev/null @@ -1,227 +0,0 @@ --- Created by: Tanya COOL --- Copyright (c) 2000-2012 OPEN CASCADE SAS --- --- The content of this file is subject to the Open CASCADE Technology Public --- License Version 6.5 (the "License"). You may not use the content of this file --- except in compliance with the License. Please obtain a copy of the License --- at http://www.opencascade.org and read it completely before using this file. --- --- The Initial Developer of the Original Code is Open CASCADE S.A.S., having its --- main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. --- --- The Original Code and all software distributed under the License is --- distributed on an "AS IS" basis, without warranty of any kind, and the --- Initial Developer hereby disclaims all such warranties, including without --- limitation, any warranties of merchantability, fitness for a particular --- purpose or non-infringement. Please see the License for the specific terms --- and conditions governing the rights and limitations under the License. - - -private class LocalContext from AIS2D inherits TShared from MMgt - - ---Purpose: defines a specific context for selection: One can - -- loads InteractiveObjects with a mode to be - -- activated associate InteractiveObjects with a - -- set of temporary selectable Objects - -- - -uses - - ListOfInteger from TColStd, - SequenceOfInteger from TColStd, - MapOfTransient from TColStd, - NameOfColor from Quantity, - PlaneAngle from Quantity, - Length from Quantity, - GridType from Aspect, - GridDrawMode from Aspect, - View from V2d, - Primitive from Graphic2d, - InteractiveObject from AIS2D, - InteractiveContext from AIS2D, - LocalStatus from AIS2D, - StatusOfPick from AIS2D, - StatusOfDetection from AIS2D, - PToListOfInt from AIS2D, - DataMapOfLocStat from AIS2D, - ClearMode from AIS2D - -is - - Create returns mutable LocalContext from AIS2D; - ---Purpose: Constructor By Default, the displayed objects are - -- automatically loaded. - - Create ( aCtx : InteractiveContext from AIS2D; - anIndex : Integer from Standard; - LoadDisplayed : Boolean from Standard = Standard_True; - AcceptStdModes : Boolean from Standard = Standard_True; - AcceptErase : Boolean from Standard = Standard_False ) - returns mutable LocalContext from AIS2D; - ---Purpose: Constructor - - -- ************************************************************* - -- Editing general Display Services - -- ************************************************************* - - Display( me : mutable; - anIObj : InteractiveObject from AIS2D; - DisplayMode : Integer from Standard = 0; - AllowDecomp : Boolean from Standard = Standard_True; - ActivationMode : Integer from Standard = 0 ) - returns Boolean from Standard; - ---Level: Internal - ---Purpose: - - Load( me : mutable; - anIObj : InteractiveObject from AIS2D; - AllowDecomp : Boolean from Standard = Standard_True; - ActivationMode : Integer from Standard = 0) - returns Boolean from Standard; - ---Level: Internal - ---Purpose: - - Erase( me : mutable; - anIObj : InteractiveObject from AIS2D ) - returns Boolean from Standard; - ---Level: Internal - ---Purpose: - - Remove( me : mutable; - aSelObj : InteractiveObject from AIS2D ) - returns Boolean from Standard; - ---Level: Internal - ---Purpose: - - LoadContextObjects( me: mutable ); - UnloadContextObjects( me: mutable ); - - Terminate( me: mutable ); - ---Level: Internal - ---Purpose: - - Clear( me: mutable; aType: ClearMode from AIS2D = AIS2D_CM_All ); - ---Purpose: according to , clears the different parts of - -- the selector (filters, modeof activation, objects...) - - HighlightPicked( me: mutable; UpdateVwr: Boolean from Standard = Standard_True ) ; - UnhighlightPicked( me: mutable; UpdateVwr: Boolean from Standard = Standard_True ) ; - - UpdateSelected( me : mutable; - UpdateVwr : Boolean from Standard = Standard_True ); - SetSelected( me : mutable; - anIObj : InteractiveObject from AIS2D; - UpdateVwr : Boolean from Standard=Standard_True ); - ---Purpose: useful to update selection with objects coming from - -- Collector or stack - - AddOrRemoveSelected( me : mutable; - anIObj : InteractiveObject from AIS2D; - UpdateVwr : Boolean from Standard = Standard_True ); - ---Purpose: useful to update selection with objects coming from - -- Collector or stack - - --*************************************************************************** - -- Information about Detection - --*************************************************************************** - - IsSelected( me; anIObj: InteractiveObject from AIS2D) returns Boolean from Standard; - SelectedIO( me ) returns InteractiveObject from AIS2D; - - - -- ******************************************************************************* - -- Management Of Temporary Attributes - -- ******************************************************************************* - - SetDisplayPriority( me : mutable; - anIObj : InteractiveObject from AIS2D; - Prior : Integer from Standard); - - DisplayedObjects( me; theMapToFill: in out MapOfTransient from TColStd ) - returns Integer from Standard; - - IsDisplayed( me; anIObj: InteractiveObject from AIS2D) returns Boolean from Standard; - IsDisplayed( me; anIObj: InteractiveObject from AIS2D; - aMode: Integer from Standard) - returns Boolean from Standard; - - Unhighlight( me:mutable; anIObj: InteractiveObject from AIS2D); - IsHighlight( me; anIObj: InteractiveObject from AIS2D) returns Boolean from Standard; - IsHighlight( me; - anIObj : InteractiveObject from AIS2D; - WithColor : out Boolean from Standard; - HiCol : out NameOfColor from Quantity) - returns Boolean from Standard; - - - IsIn( me; anIObj: InteractiveObject from AIS2D) returns Boolean from Standard; - - SubIntensityOn( me: mutable; anIObj: InteractiveObject from AIS2D ); - SubIntensityOff( me: mutable; anIObj: InteractiveObject from AIS2D ); - - --**************************************************************** - -- Graphic Detection and Selection - --**************************************************************** - UnhighLastDetect( me: mutable; aView: View from V2d) returns Boolean from Standard; - MoveTo( me: mutable; Xpix, Ypix: Integer from Standard; aView: View from V2d) - returns StatusOfDetection from AIS2D; - Select( me: mutable; UpdateVwr: Boolean from Standard = Standard_True ) - returns StatusOfPick from AIS2D; - - ShiftSelect( me: mutable; UpdateVwr: Boolean from Standard = Standard_True) - returns StatusOfPick from AIS2D; - - --********************************************************************************** - - --********************************************************************************** - - ClearSelected( me: mutable; UpdateVwr: Boolean from Standard=Standard_True ); - ClearObjects( me:mutable ) is static private; - ClearDetected( me:mutable ) is static private; - - IsValidForSelection( me; anIObj: InteractiveObject from AIS2D) returns Boolean from Standard is static private; - - DrawObject( me: mutable; anObj: InteractiveObject from AIS2D; aDispMode: Integer from Standard ) - is private; - - DetectedIndex(me:mutable) returns Integer from Standard is static private; - Status( me; anObject: InteractiveObject from AIS2D ) - returns any LocalStatus from AIS2D is private; - ---C++: return const& - -fields - - myICTX : InteractiveContext from AIS2D; - myActiveObjects : DataMapOfLocStat from AIS2D; - - myLastPicked : InteractiveObject from AIS2D; - myLastinMain : InteractiveObject from AIS2D; - myLastSelPrim : Primitive from Graphic2d; - myLastPickPrim : Primitive from Graphic2d; - myLastPickElInd : Integer from Standard; - myLastSelElInd : Integer from Standard; - - myLoadDisplayed : Boolean from Standard; - myAcceptStdMode : Boolean from Standard; - myAcceptErase : Boolean from Standard; - - myListOfStdMode : ListOfInteger from TColStd; - - myAutoHighlight : Boolean from Standard; - myLastIndex : Integer from Standard; - myLastGood : Integer from Standard; - - myDetectedSeq : SequenceOfInteger from TColStd; - myCurDetected : Integer from Standard; - myResetDetect : Boolean from Standard; - -friends - - KeepTemporary from InteractiveContext from AIS2D(me:mutable; anIObj:InteractiveObject from AIS2D; WhichMode: Integer from Standard = -1) - -end LocalContext; - - - - - diff --git a/src/AIS2D/AIS2D_LocalContext.cxx b/src/AIS2D/AIS2D_LocalContext.cxx deleted file mode 100755 index 18f287c112..0000000000 --- a/src/AIS2D/AIS2D_LocalContext.cxx +++ /dev/null @@ -1,979 +0,0 @@ -// Copyright (c) 1999-2012 OPEN CASCADE SAS -// -// The content of this file is subject to the Open CASCADE Technology Public -// License Version 6.5 (the "License"). You may not use the content of this file -// except in compliance with the License. Please obtain a copy of the License -// at http://www.opencascade.org and read it completely before using this file. -// -// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its -// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. -// -// The Original Code and all software distributed under the License is -// distributed on an "AS IS" basis, without warranty of any kind, and the -// Initial Developer hereby disclaims all such warranties, including without -// limitation, any warranties of merchantability, fitness for a particular -// purpose or non-infringement. Please see the License for the specific terms -// and conditions governing the rights and limitations under the License. - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -static Standard_Integer GetHiMod(const Handle(AIS2D_InteractiveObject)& anIO) -{ - return anIO->HasHighlightMode() ? anIO->HighlightMode() - : anIO->DefaultHighlightMode(); -} - - -AIS2D_LocalContext::AIS2D_LocalContext() -{ -} - -AIS2D_LocalContext::AIS2D_LocalContext( - const Handle(AIS2D_InteractiveContext)& aCtx, - const Standard_Integer /*Index*/, - const Standard_Boolean LoadDisplayed, - const Standard_Boolean AcceptStdModes, - const Standard_Boolean AcceptEraseOfTemp ): - myICTX( aCtx ), - myLastPicked( new AIS2D_InteractiveObject()), - myLastinMain( new AIS2D_InteractiveObject()), - myLastPickElInd( 0 ), - myLastSelElInd( 0 ), - myLoadDisplayed( LoadDisplayed ), - myAcceptStdMode( AcceptStdModes ), - myAcceptErase( AcceptEraseOfTemp ), - myAutoHighlight( Standard_True ), - myLastIndex( 0 ), - myLastGood( 0 ), - myCurDetected( 0 ), - myResetDetect( Standard_True ) - -{ - if ( myLoadDisplayed ) LoadContextObjects(); -} - - -Standard_Boolean AIS2D_LocalContext::Display( - const Handle( AIS2D_InteractiveObject)& anIObj, - const Standard_Integer WhichMode, - const Standard_Boolean /*AllowDecomp*/, - const Standard_Integer ActivationMode ) { - - if ( myActiveObjects.IsBound(anIObj) ) { - const Handle( AIS2D_LocalStatus )& LStatus = myActiveObjects( anIObj ); - - if ( LStatus->DisplayMode() == -1) { - if ( !anIObj->IsDisplayed() ) - anIObj->Display(); - if ( LStatus->IsTemporary() ) - LStatus->SetDisplayMode( WhichMode ); - } else if ( LStatus->DisplayMode() != WhichMode && LStatus -> IsTemporary() ) { - anIObj->Remove(); - LStatus->SetDisplayMode( WhichMode ); - if ( !anIObj->IsDisplayed() ) - anIObj->Display(); - } - - if ( ActivationMode !=-1 ) { - if ( !LStatus->IsActivated( ActivationMode ) ) { - LStatus->ClearSelectionModes(); - //mySelMgr->Load( anIObj, myMainVS ); - LStatus->AddSelectionMode( ActivationMode ); - //mySelMgr->Activate( anIObj, ActivationMode, myMainVS ); - } - } - } else { - Handle(AIS2D_LocalStatus) LStatus = new AIS2D_LocalStatus(); - - /*if ( anIObj->AcceptDecomposition() && AllowDecomp ) - LStatus->SetDecomposition(Standard_True); - else - LStatus->SetDecomposition(Standard_False); - */ - if( myICTX->DisplayStatus(anIObj) == AIS2D_DS_None || - myICTX->DisplayStatus(anIObj) == AIS2D_DS_Temporary ) - LStatus->SetTemporary(Standard_True); - else - LStatus->SetTemporary(Standard_False); - AIS2D_TypeOfDetection HiMod ; - if( !myICTX->IsDisplayed( anIObj, WhichMode) ) { - LStatus->SetDisplayMode(WhichMode); - if ( ActivationMode != -1 ) - LStatus->AddSelectionMode(ActivationMode); - HiMod = anIObj->HasHighlightMode() ? - anIObj->HighlightMode() : anIObj->DefaultHighlightMode(); - LStatus->SetHighlightMode( HiMod ); - if( !anIObj->IsDisplayed()) { - DrawObject(anIObj,WhichMode); - anIObj->Display(); - } - /*if(ActivationMode!=-1) { - mySelMgr->Load(anIObj,myMainVS); - mySelMgr->Activate(anIObj,ActivationMode,myMainVS); - } */ - } else { - HiMod = anIObj->HasHighlightMode()? anIObj->HighlightMode(): anIObj->DefaultHighlightMode(); - LStatus->SetHighlightMode( HiMod ); - } - myActiveObjects.Bind(anIObj,LStatus); - } - - return Standard_True; - -} - -Standard_Boolean AIS2D_LocalContext::Erase( const Handle(AIS2D_InteractiveObject)& anIObj) { - - if ( !myActiveObjects.IsBound( anIObj ) ) return Standard_False; - - const Handle(AIS2D_LocalStatus)& LStatus = myActiveObjects( anIObj ); - - if ( LStatus->IsSubIntensityOn() ) { - LStatus->SubIntensityOff(); - anIObj->Unhighlight(); - } - - Standard_Boolean stat( Standard_False ); - - if ( LStatus->DisplayMode() != -1 ) { - // if ( IsSelected( anIObj ) ) - // AddOrRemoveSelected( anIObj ); - if ( anIObj->IsHighlighted() ) - anIObj->Unhighlight(); - anIObj->Remove(); - LStatus->SetDisplayMode(-1); - stat = Standard_True; - } - if ( LStatus->IsTemporary() ) - if ( anIObj->IsDisplayed() ) - anIObj->Remove(); - - -/* TColStd_ListIteratorOfListOfInteger It( * LStatus->SelectionModes() ); - for ( ; It.More(); It.Next() ) - mySelMgr->Deactivate( anIObj, It.Value(), myMainVS ); - */ - return stat; -} - -Standard_Boolean AIS2D_LocalContext::Load( - const Handle(AIS2D_InteractiveObject)& anIObj, - const Standard_Boolean /*AllowDecomp*/, - const Standard_Integer ActivationMode ) { - - if ( myActiveObjects.IsBound( anIObj ) ) return Standard_False; - Handle(AIS2D_LocalStatus) LStatus = new AIS2D_LocalStatus(); - - /*if ( anIObj->AcceptDecomposition() && AllowDecomp ) - LStatus->SetDecomposition( Standard_True ); - else - LStatus->SetDecomposition( Standard_False ); - */ - if ( !myICTX->IsDisplayed( anIObj ) ) - LStatus->SetTemporary( Standard_True ); - else - LStatus->SetTemporary( Standard_False ); - LStatus->SetDisplayMode( -1 ); - - //storing information.... - if ( ActivationMode !=-1 ) - LStatus->AddSelectionMode( ActivationMode ); - AIS2D_TypeOfDetection HiMod = anIObj->HasHighlightMode() ? anIObj->HighlightMode() : anIObj->DefaultHighlightMode(); - LStatus->SetHighlightMode( HiMod ); - - /*mySelMgr->Load( anIObj, myMainVS ); - if ( ActivationMode != -1 ) { - mySelMgr->Activate( anIObj, ActivationMode, myMainVS ); - } */ - myActiveObjects.Bind( anIObj, LStatus ); - - return Standard_True; - -} - -Standard_Boolean AIS2D_LocalContext::Remove(const Handle(AIS2D_InteractiveObject)& /*aSelObj*/ ) { - - return Standard_False; -} - -void AIS2D_LocalContext::LoadContextObjects() { - - AIS2D_ListIteratorOfListOfIO It; - if ( myLoadDisplayed ) { - AIS2D_ListOfIO theLOI; - myICTX->DisplayedObjects( theLOI, Standard_True ); - Handle(AIS2D_LocalStatus) LStatus; - for ( It.Initialize(theLOI); It.More(); It.Next() ) { - LStatus = new AIS2D_LocalStatus(); -// LStatus->SetDecomposition((It.Value()->AcceptDecomposition() && myAcceptStdMode)); - LStatus->SetTemporary(Standard_False); - LStatus->SetHighlightMode( It.Value()->HasHighlightMode() ? It.Value()->HighlightMode(): It.Value()->DefaultHighlightMode() ); - - myActiveObjects.Bind(It.Value(),LStatus); - } - } -} - -void AIS2D_LocalContext::UnloadContextObjects() -{} - - -void AIS2D_LocalContext::Terminate() { - - ClearDetected(); - Clear(); - myLastIndex = 0; - - if ( ! myICTX->mySeqOfSelIO->IsEmpty() ) - for ( int i = 1; i <= myICTX->mySeqOfSelIO->Length(); ++i ) - myICTX->mySeqOfSelIO->Value(i)->SetState(0); - - /* - AIS2D_Selection::Select(); - AIS2D_Selection::Remove(mySelName.ToCString());*/ - Handle(V2d_Viewer) Vwr = myICTX->CurrentViewer(); - Handle(V2d_View) curV; - for ( Vwr->InitActiveViews(); Vwr->MoreActiveViews(); Vwr->NextActiveViews() ) { - curV = Vwr->ActiveView(); - } - -} - -void AIS2D_LocalContext::Clear(const AIS2D_ClearMode aType) { - switch (aType){ - case AIS2D_CM_All: - { - ClearObjects(); - break; - } - case AIS2D_CM_Interactive: - ClearObjects(); - break; - case AIS2D_CM_StandardModes: - { - while(!myListOfStdMode.IsEmpty()) - //DeactivateStdMode(AIS2D_Shape::SelectionType(myListOfStdMode.Last())); - break; - } - case AIS2D_CM_TemporaryShapePrs: - ClearDetected(); - } - //UpdateSort(); -} - -Standard_Boolean AIS2D_LocalContext::IsSelected( const Handle(AIS2D_InteractiveObject)& anIObj) const { - - if ( ! myICTX->mySeqOfSelIO->IsEmpty() ) - for ( int i = 1; i <= myICTX->mySeqOfSelIO->Length(); ++i ) - if ( myICTX->mySeqOfSelIO->Value(i) == anIObj ) - return Standard_True; - return Standard_False; -} - -Handle(AIS2D_InteractiveObject) AIS2D_LocalContext::SelectedIO() const { - return myLastPicked; -} - - -AIS2D_StatusOfDetection AIS2D_LocalContext::MoveTo( - const Standard_Integer XPix, - const Standard_Integer YPix, - const Handle(V2d_View)& aView ) { - - if ( aView->Viewer() == myICTX->CurrentViewer() ) { - Standard_Integer Dprecision = myICTX->DetectPrecision(); - Standard_Boolean UpdVwr = Standard_False; - Handle(V2d_Viewer) theViewer = aView->Viewer(); - - AIS2D_StatusOfDetection theStat( AIS2D_SOD_Nothing ); - - Handle(Graphic2d_Primitive) thePrim; - Handle(Graphic2d_TransientManager) theDrawer = - Handle(Graphic2d_TransientManager)::DownCast( theViewer->View()->Drawer() ); - - Handle(Graphic2d_DisplayList) thePickList = aView->Pick( XPix, YPix, Dprecision ); - - if ( thePickList->Length() > 0 ) { - - if ( thePickList->Length() == 1 ) { - Handle(AIS2D_InteractiveObject) theIO = Handle(AIS2D_InteractiveObject)::DownCast(thePickList->Value(1)); - if ( theIO == myLastPicked ) - switch ( theIO->HighlightMode() ) { - default: - case AIS2D_TOD_OBJECT: - return AIS2D_SOD_OnlyOneDetected; - break; - case AIS2D_TOD_PRIMITIVE: - if ( myLastPicked->Primitive(myLastPicked->PickedIndex()) == myLastPickPrim ) - return AIS2D_SOD_OnlyOneDetected; - break; - case AIS2D_TOD_ELEMENT: - if ( ( myLastPicked->Primitive(myLastPicked->PickedIndex()) == myLastPickPrim ) && - ( myLastPicked->Primitive(myLastPicked->PickedIndex())->PickedIndex() == myLastPickElInd ) ) - return AIS2D_SOD_OnlyOneDetected; - break; - case AIS2D_TOD_VERTEX: - if ( ( myLastPicked->Primitive(myLastPicked->PickedIndex()) == myLastPickPrim ) && - ( myLastPicked->Primitive(myLastPicked->PickedIndex())->PickedIndex() == myLastPickElInd ) ) - return AIS2D_SOD_OnlyOneDetected; - break; - - } - } - if ( !myLastPicked.IsNull() ) - if ( !myLastPicked->State() ) { - myLastPicked->Unhighlight(); - UpdVwr = Standard_True; - } // end if the last picked object isn't selected one - - if ( myResetDetect ) { - - theDrawer->SetOverride(Standard_True); - theDrawer->SetOverrideColor( theViewer->InitializeColor(myICTX->HighlightColor()) ); - theDrawer->BeginDraw( aView->Driver() ); - - for ( int i = 1 ; i <= thePickList->Length(); i++ ) { - - myLastPicked = Handle(AIS2D_InteractiveObject)::DownCast( thePickList->Value(i) ); - myLastinMain = myLastPicked; - - - if ( myLastPicked->HasHighlightMode() ) { - - myLastPicked->Highlight(theViewer->InitializeColor(myICTX->HighlightColor())); - switch( myLastPicked->HighlightMode() ) { - default: - case AIS2D_TOD_OBJECT: - if ( myLastPicked->State() != 1 ) { - theDrawer->Draw( myLastPicked ); - } else { - theStat = AIS2D_SOD_Selected; - } - break; - case AIS2D_TOD_PRIMITIVE: - myLastPickPrim = myLastPicked->Primitive(myLastPicked->PickedIndex()); - if ( !myLastPickPrim->IsHighlighted() ) { - theDrawer->Draw(myLastPickPrim); - } else { - theStat = AIS2D_SOD_Selected; - } - break; - case AIS2D_TOD_ELEMENT: { - Standard_Integer pInd = myLastPicked->PickedIndex(); - myLastPickPrim = myLastPicked->Primitive(pInd); - if ( myLastPickPrim != myLastSelPrim || - ( myLastPickPrim == myLastSelPrim && - myLastPickPrim->PickedIndex() != myLastSelElInd ) || - ( !myLastPickPrim->PickedIndex() && - !myLastPickPrim->IsHighlighted() ) ) { - myLastPickElInd = myLastPickPrim->PickedIndex(); - theDrawer->DrawElement(myLastPickPrim,myLastPickElInd); - } else { - theStat = AIS2D_SOD_Selected; - } - break; - } - case AIS2D_TOD_VERTEX: { - myLastPickPrim = myLastPicked->Primitive(myLastPicked->PickedIndex()); - if ( myLastPickPrim != myLastSelPrim || - ( myLastPickPrim == myLastSelPrim && - myLastPickPrim->PickedIndex() != myLastSelElInd ) || - ( !myLastPickPrim->PickedIndex() && - !myLastPickPrim->IsHighlighted() ) ) { - myLastPickElInd = myLastPickPrim->PickedIndex(); - theDrawer->DrawVertex(myLastPickPrim,-myLastPickElInd); - } else { - theStat = AIS2D_SOD_Selected; - } - break; - } - } //end switch - } // end if lastPicked has highlight mode - - } // end for - - theDrawer->EndDraw(); - theDrawer->SetOverride(Standard_False); - myResetDetect= Standard_False; - - } // end if myResetDetect is true - - } else { - - theStat = AIS2D_SOD_Nothing; - theDrawer->RestoreArea( aView->Driver() ); - myResetDetect= Standard_True; - if ( !myLastPicked.IsNull() ) { - if ( myLastPicked->HighlightMode() == AIS2D_TOD_ELEMENT || - myLastPicked->HighlightMode() == AIS2D_TOD_VERTEX ) { - myLastPicked->Highlight(theViewer->InitializeColor( myICTX->SelectionColor() )); - - myLastPicked->Unhighlight(); - UpdVwr = Standard_True; - } else if ( !myLastPicked->State() ) { - myLastPicked->Unhighlight(); - UpdVwr = Standard_True; - } - } - - myLastinMain.Nullify(); - myLastPickPrim.Nullify(); - myLastPickElInd = 0; - - } // end if PickList isn't empty - - //if ( !myLastPicked.IsNull() ) myLastPicked->Unhighlight(); - - if ( UpdVwr ) theViewer->Update(); - - myLastPicked.Nullify(); - //myLastMoveView = aView; - return theStat; - - } else - return AIS2D_SOD_Error; - -} - -AIS2D_StatusOfPick AIS2D_LocalContext::Select( const Standard_Boolean UpdateVwr ) { - - if ( myAutoHighlight ) - UnhighlightPicked( Standard_False ); - - Standard_Integer DI = DetectedIndex(); -// AIS2D_Selection::SetCurrentSelection( mySelName.ToCString() ); -// Standard_Integer NbSel = AIS2D_Selection::Extent(); - Standard_Integer NbSel = myICTX->mySeqOfSelIO->Length(); - if ( DI <= 0 ) { - ClearSelected( UpdateVwr ); - return NbSel == 0 ? AIS2D_SOP_NothingSelected : AIS2D_SOP_Removed; - } - - if ( myAutoHighlight ) - HighlightPicked( UpdateVwr ); - //return ( AIS2D_Selection::Extent() == 1) ? AIS2D_SOP_OneSelected : AIS2D_SOP_SeveralSelected; - return ( myICTX->mySeqOfSelIO->Length() == 1) ? AIS2D_SOP_OneSelected : AIS2D_SOP_SeveralSelected; -} - -AIS2D_StatusOfPick AIS2D_LocalContext::ShiftSelect( const Standard_Boolean /*UpdateVwr*/ ) { - -/* Standard_Integer I = DetectedIndex(); - if ( I > 0 ) { - UnhighlightPicked(Standard_False); - - AIS2D_Selection::SetCurrentSelection(mySelName.ToCString()); - const Handle(SelectMgr_EntityOwner)& EntOwr = myMapOfOwner(I); - Standard_Integer mod = EntOwr->State() == 0 ? 1 : 0; - EntOwr->State(mod); - - AIS2D_Selection::Select(EntOwr); - - if ( myAutoHighlight ) - HighlightPicked(UpdateVwr); - }*/ - return AIS2D_SOP_Error; -} - -void AIS2D_LocalContext::SetDisplayPriority( - const Handle(AIS2D_InteractiveObject)& anIObj, - const Standard_Integer /*Prior*/ ) { - - if ( !myActiveObjects.IsBound(anIObj) ) return; - const Handle(AIS2D_LocalStatus)& LStatus = myActiveObjects(anIObj); - if ( LStatus->DisplayMode() == -1) return; - //myMainPM->SetDisplayPriority(anIObj, LStatus->DisplayMode(),Prior); - //if ( LStatus->IsSubIntensityOn()) - // myMainPM->SetDisplayPriority(anIObj, LStatus->HighlightMode(), Prior); - -} - -Standard_Integer AIS2D_LocalContext::DisplayedObjects(TColStd_MapOfTransient& theMap) const { - - Standard_Integer NbDisp(0); - for ( AIS2D_DataMapIteratorOfDataMapOfLocStat theIt(myActiveObjects); theIt.More(); theIt.Next() ) { - const Handle(AIS2D_InteractiveObject)& SObj = theIt.Key(); - if ( !theMap.Contains(SObj) ) - if ( theIt.Value()->DisplayMode() != -1 ) { - theMap.Add(SObj); - NbDisp++; - } - } - return NbDisp; -} - -Standard_Boolean AIS2D_LocalContext::IsDisplayed(const Handle(AIS2D_InteractiveObject)& anIObj) const { - - if ( !myActiveObjects.IsBound(anIObj) ) - return Standard_False; - return ( myActiveObjects(anIObj)->DisplayMode() != -1 ); -} - -Standard_Boolean AIS2D_LocalContext::IsDisplayed(const Handle(AIS2D_InteractiveObject)& anIObj, - const Standard_Integer aMode) const { - - if (!myActiveObjects.IsBound(anIObj)) return Standard_False; - return (myActiveObjects(anIObj)->DisplayMode()==aMode); -} - -void AIS2D_LocalContext::Unhighlight(const Handle(AIS2D_InteractiveObject)& /*anIObj*/) -{ -} - -Standard_Boolean AIS2D_LocalContext::IsHighlight(const Handle(AIS2D_InteractiveObject)& anIObj) const { - - if ( !myActiveObjects.IsBound(anIObj) ) return Standard_False; - return myActiveObjects( anIObj )->IsSubIntensityOn(); -} - -Standard_Boolean AIS2D_LocalContext::IsHighlight(const Handle(AIS2D_InteractiveObject)& anIObj, - Standard_Boolean& WithColor, - Quantity_NameOfColor& HiCol) const -{ - if(!myActiveObjects.IsBound(anIObj)) return Standard_False; - if( myActiveObjects(anIObj)->IsSubIntensityOn()){ - HiCol = myActiveObjects(anIObj)->HighlightColor(); - if(HiCol==Quantity_NOC_WHITE) - WithColor = Standard_True; - else - WithColor = Standard_False; - return Standard_True; - } - return Standard_False; -} - -void AIS2D_LocalContext::SubIntensityOn(const Handle(AIS2D_InteractiveObject)& anIObj) { - - if ( !myActiveObjects.IsBound(anIObj) ) return; - - const Handle(AIS2D_LocalStatus)& LStatus = myActiveObjects(anIObj); - if ( LStatus->IsTemporary() ) { - Quantity_NameOfColor aCol = myICTX->SubIntensityColor(); - myICTX->HighlightWithColor(anIObj, aCol); - } - LStatus->SubIntensityOn(); -} - -void AIS2D_LocalContext::SubIntensityOff(const Handle(AIS2D_InteractiveObject)& anIObj) { - - if ( !myActiveObjects.IsBound(anIObj) ) return; - - const Handle(AIS2D_LocalStatus)& LStatus = myActiveObjects(anIObj); - - if ( LStatus->IsTemporary()) - myICTX->Unhighlight(anIObj); - LStatus->SubIntensityOff(); -} - -Standard_Boolean AIS2D_LocalContext::IsIn( const Handle(AIS2D_InteractiveObject)& anIObj) const { - return myActiveObjects.IsBound(anIObj); -} - -Standard_Boolean AIS2D_LocalContext::UnhighLastDetect(const Handle(V2d_View)& /*aView*/) { - -// if ( !IsValidIndex(myLastIndex) ) return Standard_False; -/* myMainPM->BeginDraw(); - const Handle(SelectMgr_EntityOwner)& Ownr = myMapOfOwner(myLastIndex); - Standard_Integer HM(0); - if ( Ownr->HasSelectable() ) { - Handle(SelectMgr_SelectableObject) SO = Ownr->Selectable(); - HM = GetHiMod(* ( (Handle(AIS2D_InteractiveObject ) * ) & SO ) ); - } - myMapOfOwner( myLastIndex )->Unhilight( myMainPM, HM ); - myMainPM->EndDraw( aView ); - */ - myLastIndex =0; - return Standard_True; -} - -void AIS2D_LocalContext::DrawObject( const Handle(AIS2D_InteractiveObject)& anIObj, const Standard_Integer /*aDispMode*/ ) { - - if ( anIObj->IsKind(STANDARD_TYPE(AIS2D_ProjShape) ) ) { - - Handle(AIS2D_ProjShape) thePS = Handle(AIS2D_ProjShape)::DownCast(anIObj); - Handle(Graphic2d_Line) theLines = thePS->GetPrimitives(); - Handle(Prs2d_AspectLine) theAspLine; - - if ( !anIObj->HasAspect(theLines) ) { - Handle(Prs2d_AspectRoot) theAspRoot = anIObj->Attributes()->FindAspect(Prs2d_AN_LINE); - theAspLine = Handle(Prs2d_AspectLine)::DownCast(theAspRoot); - anIObj->SetAspect( theAspLine, theLines ); - - } else { - theAspLine = Handle(Prs2d_AspectLine)::DownCast( anIObj->GetAspect(theLines) ); - } - - Quantity_Color aColor; - Aspect_TypeOfLine aType; - Aspect_WidthOfLine aWidth; - - theAspLine->ValuesOfLine( aColor, aType, aWidth ); - - Standard_Integer colorInd = theAspLine->ColorIndex(); - Standard_Integer typeInd = theAspLine->TypeIndex(); - Standard_Integer widthInd = theAspLine->WidthIndex(); - - if ( !colorInd ) { - colorInd = myICTX->InitializeColor( aColor ); - theLines->SetColorIndex( colorInd ); - } - - if ( !typeInd ) { - typeInd = myICTX->InitializeStyle( aType ); - theLines->SetTypeIndex( typeInd ); - } - - if ( !widthInd ) { - widthInd = myICTX->InitializeWidth( aWidth ); - theLines->SetWidthIndex( widthInd ); - } - - if ( thePS->IsHLMode() ) { - Handle(Graphic2d_Line) theHLines = thePS->GetHLPrimitives(); - theHLines->SetColorIndex( colorInd ); - theHLines->SetWidthIndex( widthInd ); - Standard_Integer theDashInd = myICTX->InitializeStyle( Aspect_TOL_DASH ); - theHLines->SetTypeIndex( theDashInd ); - } - - } else { - - Handle(Graphic2d_Primitive) thePrim; - - for ( Standard_Integer i = 1; i <= anIObj->Length(); i++ ) { - thePrim = anIObj->Primitive( i ); - if ( thePrim->IsKind(STANDARD_TYPE(Graphic2d_Line) ) ) { - - Handle(Graphic2d_Line) theLine = Handle(Graphic2d_Line)::DownCast(thePrim); - Handle(Prs2d_AspectLine) theAspLine; - - if ( !anIObj->HasAspect(theLine) ) { - Handle(Prs2d_AspectRoot) theAspRoot = anIObj->Attributes()->FindAspect(Prs2d_AN_LINE); - theAspLine = Handle(Prs2d_AspectLine)::DownCast(theAspRoot); - anIObj->SetAspect( theAspLine, theLine ); - - } else { - theAspLine = Handle(Prs2d_AspectLine)::DownCast( anIObj->GetAspect(theLine) ); - } - - Quantity_Color aColor; - Aspect_TypeOfLine aType; - Aspect_WidthOfLine aWidth; - - Quantity_Color aIntColor; - Graphic2d_TypeOfPolygonFilling aTypeFill; - Standard_Integer aTile; - Standard_Boolean aDrawEdge; - - theAspLine->ValuesOfLine( aColor, aType, aWidth ); - theAspLine->ValuesOfPoly( aIntColor, aTypeFill, aTile, aDrawEdge ); - - Standard_Integer colorInd = theAspLine->ColorIndex(); - Standard_Integer typeInd = theAspLine->TypeIndex(); - Standard_Integer widthInd = theAspLine->WidthIndex(); - Standard_Integer colorIntInd = theAspLine->InterColorIndex(); - - if ( !colorInd ) { - colorInd = myICTX->InitializeColor( aColor ); - theLine->SetColorIndex( colorInd ); - } - - if ( !typeInd ) { - typeInd = myICTX->InitializeStyle( aType ); - theLine->SetTypeIndex( typeInd ); - } - - if ( !widthInd ) { - widthInd = myICTX->InitializeWidth( aWidth ); - theLine->SetWidthIndex( widthInd ); - } - - if ( !colorIntInd ) { - colorIntInd = myICTX->InitializeColor( aIntColor ); - theLine->SetInteriorColorIndex( colorIntInd ); - } - - theLine->SetTypeOfPolygonFilling( aTypeFill ); - theLine->SetInteriorPattern( aTile ); - theLine->SetDrawEdge( aDrawEdge ); - - if ( theLine->IsKind(STANDARD_TYPE(Prs2d_Point) ) ) { - - Handle(Prs2d_Point) thePnt = Handle(Prs2d_Point)::DownCast(theLine); - thePnt->SetIndex( myICTX->InitializeMarker( thePnt->Marker() ) ); - } - - } // end if the kind of primitive is Graphic2d_Line - - } // end for exploration of the interactive object - - } // end if IO is AIS2D_ProjShape - -} - -void AIS2D_LocalContext::ClearObjects() { - - AIS2D_DataMapIteratorOfDataMapOfLocStat It( myActiveObjects ); - for ( ; It.More(); It.Next() ) { - Handle(AIS2D_InteractiveObject) SObj = Handle(AIS2D_InteractiveObject)::DownCast( It.Key() ); - - const Handle(AIS2D_LocalStatus) LStatus = It.Value(); -// TColStd_ListIteratorOfListOfInteger ItL; - - AIS2D_DisplayStatus theDS = myICTX->DisplayStatus( SObj ); - - if ( theDS != AIS2D_DS_Displayed){ - //if ( myMainPM->IsDisplayed( SObj, LStatus->DisplayMode() ) ) { - if ( myICTX->IsDisplayed(SObj) ) { - if ( LStatus->IsSubIntensityOn() && SObj->IsHighlighted() ) - SObj->Unhighlight(); - SObj->Remove(); - } - - if ( LStatus->IsTemporary() ) - SObj->Remove(); - } else { - if ( LStatus->IsSubIntensityOn() ) { - myICTX->SubIntensityOff(Handle(AIS2D_InteractiveObject)::DownCast(SObj) ); } - Standard_Integer DiMo = SObj->HasDisplayMode() ? SObj->DisplayMode() : myICTX->DisplayMode(); - if ( LStatus->DisplayMode() !=-1 && LStatus->DisplayMode() != DiMo) - SObj->Remove(); - } - - } - ClearSelected(); - myActiveObjects.Clear(); - -} - - -void AIS2D_LocalContext::ClearDetected() { - - /*for ( Standard_Integer i = 1; i <= myMapOfOwner.Extent(); i++ ) { - if ( !myMapOfOwner(i).IsNull() ) { - if ( myMapOfOwner(i)->IsHilighted(myMainPM) ) - myMapOfOwner(i)->Unhilight(myMainPM); - else if ( myMapOfOwner(i)->IsHilighted( myICTX->CollectorPrsMgr() ) ) - myMapOfOwner(i)->Unhilight( myICTX->CollectorPrsMgr() ); - else { - const Handle(SelectMgr_SelectableObject)& SO = - myMapOfOwner.FindKey(i)->Selectable(); - if ( myActiveObjects.IsBound(SO) ) { - const Handle(AIS2D_LocalStatus)& LStatus = myActiveObjects(SO); - if ( LStatus->IsTemporary() && - LStatus->DisplayMode() == -1 && - LStatus->SelectionModes()->IsEmpty() ) - - myMapOfOwner(i)->Clear(myMainPM); - - } - } - } - } */ -} - -void AIS2D_LocalContext::ClearSelected(const Standard_Boolean UpdateVwr) { - - UnhighlightPicked(UpdateVwr); - // AIS2D_Selection::SetCurrentSelection(mySelName.ToCString()); - - // Handle(AIS2D_Selection) Sel = AIS2D_Selection::CurrentSelection(); - /*Handle(Standard_Transient) Tr; - Handle(SelectMgr_EntityOwner) EO; - const TColStd_Array1OfTransient& Obj = Sel->Objects()->Array1(); - for ( Standard_Integer i = Obj.Lower(); i <= Sel->NbStored(); i++ ) { - Tr = Obj(i); - if ( !Tr.IsNull() ) - (*((Handle(SelectMgr_EntityOwner)*)&Tr))->State(0); - } */ - //AIS2D_Selection::Select(); - myLastIndex = 0; -} - -void AIS2D_LocalContext::HighlightPicked(const Standard_Boolean /*UpdateVwr*/) { - - /*Standard_Boolean updMain(Standard_False),updColl(Standard_False); - Quantity_NameOfColor SelCol = myICTX->SelectionColor(); - - Handle(AIS2D_Selection) Sel = AIS2D_Selection::Selection(mySelName.ToCString()); - Handle(Standard_Transient) Tr; - Handle(SelectMgr_EntityOwner) Ownr; - Handle(PrsMgr_PresentationManager2d) PM = myMainPM; - - const TColStd_Array1OfTransient& Obj = Sel->Objects()->Array1(); - for ( Standard_Integer i = Obj.Lower(); i <= Sel->NbStored(); i++ ) { - Tr = Obj(i); - if ( !Tr.IsNull() ) { - Ownr = * ( (Handle(SelectMgr_EntityOwner) * ) &Tr ); - Handle(AIS2D_InteractiveObject) IO; - if ( Ownr->HasSelectable() ) - if ( !Ownr->ComesFromDecomposition() ) { - Handle(SelectMgr_SelectableObject) SO = Ownr->Selectable(); - Handle(AIS2D_InteractiveObject) IO = - * ( (Handle(AIS2D_InteractiveObject) * ) &SO ); - if ( myICTX->IsInCollector(IO) ) { - PM = myICTX->CollectorPrsMgr(); - updColl = Standard_True; - } else - updMain = Standard_True; - } else - updMain = Standard_True; - else - updMain = Standard_True; - // endif HasSelectable - Handle(SelectMgr_SelectableObject) SO = Ownr->Selectable(); - Standard_Integer HM = GetHiMod( * ( (Handle(AIS2D_InteractiveObject ) * ) &SO ) ); - // Ownr->HilightWithColor( PM, myICTX->SelectionColor(), HM ); - if ( Ownr->HasSelectable() ) { - Quantity_NameOfColor aCol = myICTX->SelectionColor(); - Standard_Integer indCol = myICTX->CurrentViewer()->InitializeColor( aCol ); - PM->SetHighlightColor( indCol ); - PM->ColorHighlight( SO, indCol, HM ); - } - - } //endif - } //end for - if (UpdateVwr) { - if ( updMain ) myICTX->CurrentViewer()->Update(); - if ( updColl ) myICTX->Collector()->Update(); - } */ -} - -void AIS2D_LocalContext::UnhighlightPicked( const Standard_Boolean /*UpdateVwr*/ ) { - - /*Standard_Boolean updMain(Standard_False), updColl(Standard_False); - Quantity_NameOfColor SelCol = myICTX->SelectionColor(); - - Handle(AIS2D_Selection) Sel = AIS2D_Selection::Selection(mySelName.ToCString()); - Handle(Standard_Transient) Tr; - Handle(SelectMgr_EntityOwner) Ownr; - Handle(PrsMgr_PresentationManager2d) PM = myMainPM; - - const TColStd_Array1OfTransient& Obj = Sel->Objects()->Array1(); - for ( Standard_Integer i = Obj.Lower(); i <= Sel->NbStored(); i++ ) { - Tr = Obj(i); - if ( !Tr.IsNull() ) { - Ownr = * ( (Handle(SelectMgr_EntityOwner) * ) &Tr ); - Standard_Integer HM(0); - if ( Ownr->HasSelectable() ) - if ( !Ownr->ComesFromDecomposition() ) { - Handle(SelectMgr_SelectableObject) SO = Ownr->Selectable(); - Handle(AIS2D_InteractiveObject) IO = - * ( (Handle(AIS2D_InteractiveObject) * ) &SO ); - HM = GetHiMod(IO); - if ( myICTX->IsInCollector(IO) ) { - PM = myICTX->CollectorPrsMgr(); - updColl = Standard_True; - } else - updMain = Standard_True; - } else - updMain = Standard_True; - // endif HasSelectable - Ownr->Unhilight( PM, HM ); - } //end if - } //end for - - if ( UpdateVwr ) { - if ( updMain ) myICTX->CurrentViewer()->Update(); - if ( updColl ) myICTX->Collector()->Update(); - } */ -} - -Standard_Boolean AIS2D_LocalContext::IsValidForSelection(const Handle(AIS2D_InteractiveObject)& /*anIObj*/) const { - - // return myFilter->IsOk(new SelectMgr_EntityOwner(anIObj)); - return Standard_False; -} - -void AIS2D_LocalContext::UpdateSelected(const Standard_Boolean UpdateVwr) { - - UnhighlightPicked(Standard_False); - HighlightPicked(UpdateVwr); -} - -void AIS2D_LocalContext::SetSelected( const Handle(AIS2D_InteractiveObject)& /*anIObj*/, - const Standard_Boolean /*UpdateVwr*/ ) { - - /*if ( !IsValidForSelection(anIObj) ) return; - UnhighlightPicked(Standard_False); - - Handle(AIS2D_Selection) sel = AIS2D_Selection::Selection(mySelName.ToCString()); - Standard_Boolean found(Standard_False); - Handle(Standard_Transient) Tr; - Handle(SelectMgr_EntityOwner) EntOwr = FindSelectedOwnerFromIO(anIObj); - if ( EntOwr.IsNull() ) { - if ( anIObj->HasSelection(0) ) { - const Handle(SelectMgr_Selection)& SIObj = anIObj->Selection(0); - SIObj->Init(); - if ( SIObj->More() ) { - Handle(SelectBasics_EntityOwner) BO = SIObj->Sensitive()->OwnerId(); - EntOwr = *( (Handle(SelectMgr_EntityOwner) * ) & BO ); - } - } - if ( EntOwr.IsNull() ) - EntOwr = new SelectMgr_EntityOwner(anIObj); - } - - ClearSelected(Standard_False); - EntOwr->State(1); - AIS2D_Selection::Select(EntOwr); - HighlightPicked(UpdateVwr); - */ -} - -void AIS2D_LocalContext::AddOrRemoveSelected( - const Handle(AIS2D_InteractiveObject)& /*anIObj*/, - const Standard_Boolean /*UpdateVwr*/) { - - /*if ( !IsValidForSelection(anIObj) ) return; - UnhighlightPicked(Standard_False); - Handle(SelectMgr_EntityOwner) EntOwr; - - EntOwr = FindSelectedOwnerFromIO(anIObj); - if ( !EntOwr.IsNull() ) - EntOwr->State(0); - else { - if ( anIObj->HasSelection(0) ) { - const Handle(SelectMgr_Selection)& SIObj = anIObj->Selection(0); - SIObj->Init(); - if ( SIObj->More() ) { - Handle(SelectBasics_EntityOwner) BO = SIObj->Sensitive()->OwnerId(); - EntOwr = * ( ( Handle(SelectMgr_EntityOwner)* )& BO ); - } - } - if ( EntOwr.IsNull() ) - EntOwr = new SelectMgr_EntityOwner(anIObj); - EntOwr->State(1); - } - - const Handle(AIS2D_Selection)& aSel = AIS2D_Selection::Selection(mySelName.ToCString() ); - if ( !aSel.IsNull() ) - aSel->Select(EntOwr); - HighlightPicked(UpdateVwr); - */ -} - -Standard_Integer AIS2D_LocalContext::DetectedIndex() { - return myLastIndex; -} - -const Handle(AIS2D_LocalStatus)& AIS2D_LocalContext::Status(const Handle(AIS2D_InteractiveObject)& anObject) const { - return myActiveObjects(anObject); -} - diff --git a/src/AIS2D/AIS2D_LocalStatus.cdl b/src/AIS2D/AIS2D_LocalStatus.cdl deleted file mode 100755 index 673fecab52..0000000000 --- a/src/AIS2D/AIS2D_LocalStatus.cdl +++ /dev/null @@ -1,162 +0,0 @@ --- Created by: Tanya COOL --- Copyright (c) 2000-2012 OPEN CASCADE SAS --- --- The content of this file is subject to the Open CASCADE Technology Public --- License Version 6.5 (the "License"). You may not use the content of this file --- except in compliance with the License. Please obtain a copy of the License --- at http://www.opencascade.org and read it completely before using this file. --- --- The Initial Developer of the Original Code is Open CASCADE S.A.S., having its --- main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. --- --- The Original Code and all software distributed under the License is --- distributed on an "AS IS" basis, without warranty of any kind, and the --- Initial Developer hereby disclaims all such warranties, including without --- limitation, any warranties of merchantability, fitness for a particular --- purpose or non-infringement. Please see the License for the specific terms --- and conditions governing the rights and limitations under the License. - - -private class LocalStatus from AIS2D inherits TShared from MMgt - - ---Purpose: Stored Info about temporary objects. - -uses - - ListOfInteger from TColStd, - NameOfColor from Quantity, - PToListOfInt from AIS2D, - TypeOfDetection from AIS2D -is - - Create( isTemporary : Boolean from Standard = Standard_True; - Decompose : Boolean from Standard = Standard_False; - DMode : Integer from Standard = -1; - SMode : Integer from Standard = -1; - HMode : TypeOfDetection from AIS2D = AIS2D_TOD_PRIMITIVE; - SubIntensity : Boolean from Standard = 0; - HighlCol : NameOfColor from Quantity = Quantity_NOC_WHITE ) - returns mutable LocalStatus from AIS2D; - ---Purpose: Initializes the default Local Status - - Decomposed( me ) returns Boolean from Standard; - ---C++: inline - ---Level: Internal - ---Purpose: - - IsTemporary( me ) returns Boolean from Standard; - ---C++: inline - ---Level: Internal - ---Purpose: - - DisplayMode( me ) returns Integer from Standard; - ---C++: inline - ---Level: Internal - ---Purpose: - - SelectionModes( me: mutable ) returns PToListOfInt from AIS2D; - ---C++: inline - ---Level: Internal - ---Purpose: - - IsActivated( me; aSelMode: Integer from Standard ) returns Boolean from Standard; - ---Level: Internal - ---Purpose: - - HighlightMode( me ) returns TypeOfDetection from AIS2D; - ---C++: inline - ---Level: Internal - ---Purpose: - - IsSubIntensityOn( me ) returns Boolean from Standard; - ---C++: inline - ---Level: Internal - ---Purpose: - - HighlightColor( me ) returns NameOfColor from Quantity; - ---C++: inline - ---Level: Internal - ---Purpose: - - IsFirstDisplay( me ) returns Boolean from Standard; - ---C++: inline - ---Level: Internal - ---Purpose: - - SetDecomposition( me:mutable; aStatus: Boolean from Standard); - ---C++: inline - ---Level: Internal - ---Purpose: - - SetTemporary( me:mutable; aStatus: Boolean from Standard); - ---C++: inline - ---Level: Internal - ---Purpose: - - SetDisplayMode( me:mutable; aMode: Integer from Standard); - ---C++: inline - ---Level: Internal - ---Purpose: - - SetFirstDisplay( me:mutable; aStatus: Boolean from Standard) ; - ---C++: inline - ---Level: Internal - ---Purpose: - - AddSelectionMode( me:mutable; aMode: Integer from Standard ); - ---Level: Internal - ---Purpose: - - RemoveSelectionMode( me:mutable; aMode: Integer from Standard ); - ---Level: Internal - ---Purpose: - - ClearSelectionModes( me:mutable ); - ---Level: Internal - ---Purpose: - - IsSelModeIn( me; aMode: Integer from Standard ) returns Boolean from Standard; - ---Level: Internal - ---Purpose: - - SetHighlightMode( me: mutable; aMode: TypeOfDetection from AIS2D ); - ---C++: inline - ---Level: Internal - ---Purpose: - - SetHighlightColor( me: mutable; aHiCol: NameOfColor from Quantity ); - ---C++: inline - ---Level: Internal - ---Purpose: - - SubIntensityOn( me:mutable ); - ---C++: inline - ---Level: Internal - ---Purpose: - - SubIntensityOff( me:mutable ); - ---Level: Internal - ---Purpose: - - SetPreviousState( me:mutable; aStatus: Transient from Standard ); - ---Level: Internal - ---Purpose: - - PreviousState( me ) returns any Transient from Standard; - ---C++: inline - ---Level: Internal - ---Purpose: - -fields - - myDecomposition : Boolean from Standard; - myIsTemporary : Boolean from Standard; - myDMode : Integer from Standard; - myFirstDisplay : Boolean from Standard; - myHMode : TypeOfDetection from AIS2D; - mySModes : ListOfInteger from TColStd; - mySubIntensity : Boolean from Standard; - myHighlCol : NameOfColor from Quantity; - myPrevState : Transient from Standard; - -end LocalStatus; diff --git a/src/AIS2D/AIS2D_LocalStatus.cxx b/src/AIS2D/AIS2D_LocalStatus.cxx deleted file mode 100755 index cf2bee1ee5..0000000000 --- a/src/AIS2D/AIS2D_LocalStatus.cxx +++ /dev/null @@ -1,91 +0,0 @@ -// Copyright (c) 1999-2012 OPEN CASCADE SAS -// -// The content of this file is subject to the Open CASCADE Technology Public -// License Version 6.5 (the "License"). You may not use the content of this file -// except in compliance with the License. Please obtain a copy of the License -// at http://www.opencascade.org and read it completely before using this file. -// -// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its -// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. -// -// The Original Code and all software distributed under the License is -// distributed on an "AS IS" basis, without warranty of any kind, and the -// Initial Developer hereby disclaims all such warranties, including without -// limitation, any warranties of merchantability, fitness for a particular -// purpose or non-infringement. Please see the License for the specific terms -// and conditions governing the rights and limitations under the License. - -#include -#include - -AIS2D_LocalStatus::AIS2D_LocalStatus( const Standard_Boolean isTemporary, - const Standard_Boolean Decompose, - const Standard_Integer DMode, - const Standard_Integer SMode, - const AIS2D_TypeOfDetection HMode, - const Standard_Boolean SubIntensity, - const Quantity_NameOfColor HighlCol ): - - myDecomposition( Decompose ), - myIsTemporary( isTemporary ), - myDMode( DMode ), - myFirstDisplay( Standard_False), - myHMode( HMode ), - mySModes(), - mySubIntensity( SubIntensity ), - myHighlCol( HighlCol ) - -{ - if ( SMode != -1 ) mySModes.Append( SMode ); - -} - -Standard_Boolean AIS2D_LocalStatus::IsActivated(const Standard_Integer aSelMode) const { - - TColStd_ListIteratorOfListOfInteger It( mySModes ); - for ( ; It.More(); It.Next() ) - if ( It.Value() == aSelMode ) - return Standard_True; - return Standard_False; -} - -Standard_Boolean AIS2D_LocalStatus::IsSelModeIn(const Standard_Integer aMode) const { - - TColStd_ListIteratorOfListOfInteger It( mySModes ); - for ( ; It.More(); It.Next() ) - if( It.Value() == aMode ) - return Standard_True; - return Standard_False; -} - - void AIS2D_LocalStatus::AddSelectionMode(const Standard_Integer aMode) { - - if( IsSelModeIn( aMode ) ) return; - - if( aMode != -1 ) - mySModes.Append( aMode ); - else - mySModes.Clear(); -} - -void AIS2D_LocalStatus::RemoveSelectionMode(const Standard_Integer aMode) { - - TColStd_ListIteratorOfListOfInteger It(mySModes); - for ( ; It.More(); It.Next() ) - if ( It.Value() == aMode ) { - mySModes.Remove( It ); - return; - } -} - -void AIS2D_LocalStatus::ClearSelectionModes() { - mySModes.Clear(); -} - -void AIS2D_LocalStatus::SubIntensityOff() { - mySubIntensity = Standard_False; -} - -void AIS2D_LocalStatus::SetPreviousState(const Handle(Standard_Transient)& aStatus) { - myPrevState = aStatus; -} diff --git a/src/AIS2D/AIS2D_LocalStatus.lxx b/src/AIS2D/AIS2D_LocalStatus.lxx deleted file mode 100755 index 9657d4784c..0000000000 --- a/src/AIS2D/AIS2D_LocalStatus.lxx +++ /dev/null @@ -1,82 +0,0 @@ -// Copyright (c) 1999-2012 OPEN CASCADE SAS -// -// The content of this file is subject to the Open CASCADE Technology Public -// License Version 6.5 (the "License"). You may not use the content of this file -// except in compliance with the License. Please obtain a copy of the License -// at http://www.opencascade.org and read it completely before using this file. -// -// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its -// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. -// -// The Original Code and all software distributed under the License is -// distributed on an "AS IS" basis, without warranty of any kind, and the -// Initial Developer hereby disclaims all such warranties, including without -// limitation, any warranties of merchantability, fitness for a particular -// purpose or non-infringement. Please see the License for the specific terms -// and conditions governing the rights and limitations under the License. - -inline Handle(Standard_Transient) AIS2D_LocalStatus::PreviousState() const { - return myPrevState; -} - -inline Standard_Boolean AIS2D_LocalStatus::Decomposed() const { - return myDecomposition; -} - -inline Standard_Boolean AIS2D_LocalStatus::IsTemporary() const { - return myIsTemporary; -} - -inline Standard_Integer AIS2D_LocalStatus::DisplayMode() const { - return myDMode; -} - -inline AIS2D_PToListOfInt AIS2D_LocalStatus::SelectionModes() { - - return &mySModes; -} - -inline AIS2D_TypeOfDetection AIS2D_LocalStatus::HighlightMode() const { - return myHMode; -} - -inline Standard_Boolean AIS2D_LocalStatus::IsSubIntensityOn() const { - return mySubIntensity; -} - -inline Standard_Boolean AIS2D_LocalStatus::IsFirstDisplay() const { - return myFirstDisplay; -} - -inline Quantity_NameOfColor AIS2D_LocalStatus::HighlightColor() const { - return myHighlCol; -} - -inline void AIS2D_LocalStatus::SubIntensityOn() { - mySubIntensity = Standard_True; -} - -inline void AIS2D_LocalStatus::SetDecomposition(const Standard_Boolean aStatus) { - myDecomposition = aStatus; -} - -inline void AIS2D_LocalStatus::SetTemporary(const Standard_Boolean aStatus) { - myIsTemporary = aStatus; -} - -inline void AIS2D_LocalStatus::SetDisplayMode(const Standard_Integer aMode) { - myDMode = aMode; -} - -inline void AIS2D_LocalStatus::SetFirstDisplay(const Standard_Boolean aStatus) { - myFirstDisplay = aStatus; -} - -inline void AIS2D_LocalStatus::SetHighlightMode(const AIS2D_TypeOfDetection aMode) { - myHMode = aMode; -} - -inline void AIS2D_LocalStatus::SetHighlightColor(const Quantity_NameOfColor aHiCol) { - myHighlCol = aHiCol; -} - diff --git a/src/AIS2D/AIS2D_PrimitiveArchit.cdl b/src/AIS2D/AIS2D_PrimitiveArchit.cdl deleted file mode 100755 index 4f43f890f2..0000000000 --- a/src/AIS2D/AIS2D_PrimitiveArchit.cdl +++ /dev/null @@ -1,37 +0,0 @@ --- Created by: TCL --- Copyright (c) 2000-2012 OPEN CASCADE SAS --- --- The content of this file is subject to the Open CASCADE Technology Public --- License Version 6.5 (the "License"). You may not use the content of this file --- except in compliance with the License. Please obtain a copy of the License --- at http://www.opencascade.org and read it completely before using this file. --- --- The Initial Developer of the Original Code is Open CASCADE S.A.S., having its --- main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. --- --- The Original Code and all software distributed under the License is --- distributed on an "AS IS" basis, without warranty of any kind, and the --- Initial Developer hereby disclaims all such warranties, including without --- limitation, any warranties of merchantability, fitness for a particular --- purpose or non-infringement. Please see the License for the specific terms --- and conditions governing the rights and limitations under the License. - - -private class PrimitiveArchit from AIS2D inherits TShared from MMgt - -uses - - Primitive from Graphic2d -is - - Create( aPrim: Primitive from Graphic2d; ind: Integer from Standard ) - returns mutable PrimitiveArchit from AIS2D; - GetPrimitive( me ) returns Primitive from Graphic2d; - GetIndex( me ) returns Integer from Standard; - -fields - - myPrimitive : Primitive from Graphic2d; - myInd : Integer from Standard; - -end PrimitiveArchit; diff --git a/src/AIS2D/AIS2D_PrimitiveArchit.cxx b/src/AIS2D/AIS2D_PrimitiveArchit.cxx deleted file mode 100755 index c7474aca16..0000000000 --- a/src/AIS2D/AIS2D_PrimitiveArchit.cxx +++ /dev/null @@ -1,33 +0,0 @@ -// Copyright (c) 1999-2012 OPEN CASCADE SAS -// -// The content of this file is subject to the Open CASCADE Technology Public -// License Version 6.5 (the "License"). You may not use the content of this file -// except in compliance with the License. Please obtain a copy of the License -// at http://www.opencascade.org and read it completely before using this file. -// -// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its -// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. -// -// The Original Code and all software distributed under the License is -// distributed on an "AS IS" basis, without warranty of any kind, and the -// Initial Developer hereby disclaims all such warranties, including without -// limitation, any warranties of merchantability, fitness for a particular -// purpose or non-infringement. Please see the License for the specific terms -// and conditions governing the rights and limitations under the License. - -#include - -AIS2D_PrimitiveArchit::AIS2D_PrimitiveArchit( const Handle(Graphic2d_Primitive)& aPrim, - const Standard_Integer ind ) : - myPrimitive( aPrim ), - myInd( ind ) -{ -} - -Handle(Graphic2d_Primitive) AIS2D_PrimitiveArchit::GetPrimitive() const { - return myPrimitive; -} - -Standard_Integer AIS2D_PrimitiveArchit::GetIndex() const { - return myInd; -} diff --git a/src/AIS2D/AIS2D_ProjShape.cdl b/src/AIS2D/AIS2D_ProjShape.cdl deleted file mode 100755 index 6b174c155f..0000000000 --- a/src/AIS2D/AIS2D_ProjShape.cdl +++ /dev/null @@ -1,132 +0,0 @@ --- Created by: Tanya COOL --- Copyright (c) 2000-2012 OPEN CASCADE SAS --- --- The content of this file is subject to the Open CASCADE Technology Public --- License Version 6.5 (the "License"). You may not use the content of this file --- except in compliance with the License. Please obtain a copy of the License --- at http://www.opencascade.org and read it completely before using this file. --- --- The Initial Developer of the Original Code is Open CASCADE S.A.S., having its --- main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. --- --- The Original Code and all software distributed under the License is --- distributed on an "AS IS" basis, without warranty of any kind, and the --- Initial Developer hereby disclaims all such warranties, including without --- limitation, any warranties of merchantability, fitness for a particular --- purpose or non-infringement. Please see the License for the specific terms --- and conditions governing the rights and limitations under the License. - - -class ProjShape from AIS2D inherits InteractiveObject from AIS2D - - ---Purpose: Constructs presentable and selectable projection of - -- TopoDS_Shape on the view plane - -uses - - Shape from TopoDS, - Line from Graphic2d, - ListOfShape from TopTools, - Projector from HLRAlgo, - Algo from HLRBRep, - PolyAlgo from HLRBRep, - SetOfSegments from Graphic2d, - SetOfCurves from GGraphic2d - -is - - Create returns mutable ProjShape from AIS2D; - ---Purpose: Initializes the projected shape - - Create( aProjector: Projector from HLRAlgo; - nbIsos: Integer from Standard = 3; - isPolyAlgo: Boolean from Standard = Standard_False; - visHL: Boolean from Standard = Standard_True ) - returns mutable ProjShape from AIS2D; - ---Purpose: Initializes the projected shape with projector , number isolines - - Add( me: mutable; aShape: Shape from TopoDS ); - ---Level: Public - ---Purpose: Adds to the list of projected shapes. - - SetProjector( me: mutable; aProjector: Projector from HLRAlgo ); - ---Level: Public - ---Purpose: sets the projector - - Projector( me ) returns Projector from HLRAlgo; - ---Level: Public - ---Purpose: Indicates the projector - - SetNbIsos( me: mutable; aNbIsos: Integer from Standard ); - ---Level: Internal - ---Purpose: - - SetPolyAlgo( me: mutable; aIsPoly: Boolean from Standard = Standard_False ); - ---Level: Internal - ---Purpose: sets the projection of the shape as a polyhedral - -- simplification of the shape if is True - - SetHLMode( me: mutable; aIsHLM: Boolean from Standard = Standard_True ); - ---Level: Internal - ---Purpose: Sets the hidden line mode if is True - - IsHLMode( me ) returns Boolean from Standard; - ---Level: Public - ---Purpose: Indicates the hidden lines are visible - - GetNbIsos( me ) returns Integer from Standard; - ---Level: Public - ---Purpose: Indicates the number of isolines - - GetIsPoly( me ) returns Boolean from Standard; - ---Level: Public - ---Purpose: Indicates the shape was extracted as Algo or PolyAlgo - - GetPrimitives( me ) returns Line from Graphic2d; - ---Level: Internal - ---Purpose: Returns the set of primitives are included into Shape, - -- except hidden lines - - GetHLPrimitives( me ) returns Line from Graphic2d; - ---Level: Internal - ---Purpose: Returns the set of hidden line primitives are included into Shape - - ShowEdges( me: mutable; - aSharp, aSmooth, aSewn, anOutline, anIsoline: Boolean from Standard = Standard_True ); - ---Level: Public - ---Purpose: Sets the flags for display of all types of edges - - - ---------------------------------------------------------------------------- - ---Category: Private methods - - CreateAlgo( me: mutable ) is private; - CreatePolyAlgo( me: mutable ) is private; - DrawSegments( me: mutable; aShape: Shape from TopoDS; - aSofS: in out SetOfSegments from Graphic2d ) is private; - DrawCurves( me: mutable; aShape: Shape from TopoDS; - aSofC: in out SetOfCurves from GGraphic2d ) is private; - - ComputeShape( me: mutable ) is private; - -fields - - myListOfShape : ListOfShape from TopTools; - myProjector : Projector from HLRAlgo; - myAlgo : Algo from HLRBRep; - myPolyAlgo : PolyAlgo from HLRBRep; - myNbIsos : Integer from Standard; - myIsPolyAlgo : Boolean from Standard; - myIsHiddenLine : Boolean from Standard; - myESharp : Boolean from Standard; - myESmooth : Boolean from Standard; - myESewn : Boolean from Standard; - myEOutline : Boolean from Standard; - myEIsoline : Boolean from Standard; - - mySetOfSegments : SetOfSegments from Graphic2d; - myHSetOfSegments : SetOfSegments from Graphic2d; - mySetOfCurves : SetOfCurves from GGraphic2d; - myHSetOfCurves : SetOfCurves from GGraphic2d; - -end ProjShape; diff --git a/src/AIS2D/AIS2D_ProjShape.cxx b/src/AIS2D/AIS2D_ProjShape.cxx deleted file mode 100755 index 11fce61a66..0000000000 --- a/src/AIS2D/AIS2D_ProjShape.cxx +++ /dev/null @@ -1,341 +0,0 @@ -// Copyright (c) 1999-2012 OPEN CASCADE SAS -// -// The content of this file is subject to the Open CASCADE Technology Public -// License Version 6.5 (the "License"). You may not use the content of this file -// except in compliance with the License. Please obtain a copy of the License -// at http://www.opencascade.org and read it completely before using this file. -// -// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its -// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. -// -// The Original Code and all software distributed under the License is -// distributed on an "AS IS" basis, without warranty of any kind, and the -// Initial Developer hereby disclaims all such warranties, including without -// limitation, any warranties of merchantability, fitness for a particular -// purpose or non-infringement. Please see the License for the specific terms -// and conditions governing the rights and limitations under the License. - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include - -#include - - -AIS2D_ProjShape::AIS2D_ProjShape( ) - : - AIS2D_InteractiveObject(), - - myProjector( HLRAlgo_Projector() ), - myNbIsos( 3 ), - myIsPolyAlgo( Standard_False ), - myIsHiddenLine( Standard_True ), - myESharp( Standard_True ), - myESmooth( Standard_True ), - myESewn( Standard_True ), - myEOutline( Standard_True ), - myEIsoline( Standard_True ) - -{ -} - -AIS2D_ProjShape::AIS2D_ProjShape( const HLRAlgo_Projector& aProjector, - const Standard_Integer nbIsos, - const Standard_Boolean isPolyAlgo, - const Standard_Boolean visHL ) - : - AIS2D_InteractiveObject(), - myProjector( aProjector ), - myNbIsos( nbIsos ), - myIsPolyAlgo( isPolyAlgo ), - myIsHiddenLine( visHL ), - myESharp( Standard_True ), - myESmooth( Standard_True ), - myESewn( Standard_True ), - myEOutline( Standard_True ), - myEIsoline( Standard_True ) - -{ -} - - -void AIS2D_ProjShape::Add( const TopoDS_Shape& aShape ) { - - myListOfShape.Append( aShape ); - myAlgo.Nullify(); - myPolyAlgo.Nullify(); - ComputeShape(); -} - -void AIS2D_ProjShape::ComputeShape() { - - TopoDS_Shape VCompound, Rg1LineVCompound, RgNLineVCompound, - OutLineVCompound, IsoLineVCompound, - HCompound, Rg1LineHCompound, RgNLineHCompound, - OutLineHCompound, IsoLineHCompound; - - if ( myIsPolyAlgo ) { - - if ( myPolyAlgo.IsNull() ) CreatePolyAlgo(); - - HLRBRep_PolyHLRToShape aPolyHLRToShape; - aPolyHLRToShape.Update( myPolyAlgo ); - - mySetOfSegments = new Graphic2d_SetOfSegments( this ); - myHSetOfSegments = new Graphic2d_SetOfSegments( this ); - - if ( myESharp ) { - VCompound = aPolyHLRToShape.VCompound(); - DrawSegments( Rg1LineVCompound, mySetOfSegments ); - } - if ( myESmooth ) { - Rg1LineVCompound = aPolyHLRToShape.Rg1LineVCompound(); - DrawSegments( RgNLineVCompound, mySetOfSegments ); - } - if ( myESewn ) { - RgNLineVCompound = aPolyHLRToShape.RgNLineVCompound(); - DrawSegments( OutLineVCompound, mySetOfSegments ); - } - if ( myEOutline ) { - OutLineVCompound = aPolyHLRToShape.OutLineVCompound(); - DrawSegments( VCompound, mySetOfSegments ); - } - - if ( myIsHiddenLine ) { - if ( myESharp ) { - HCompound = aPolyHLRToShape.HCompound(); - DrawSegments( Rg1LineHCompound, myHSetOfSegments ); - } - if ( myESmooth ) { - Rg1LineHCompound = aPolyHLRToShape.Rg1LineHCompound(); - DrawSegments( RgNLineHCompound, myHSetOfSegments ); - } - if ( myESewn ) { - RgNLineHCompound = aPolyHLRToShape.RgNLineHCompound(); - DrawSegments( OutLineHCompound, myHSetOfSegments ); - } - if ( myEOutline ) { - OutLineHCompound = aPolyHLRToShape.OutLineHCompound(); - DrawSegments( HCompound, myHSetOfSegments ); - } - } // end if is HiddenLine - } else { - - if ( myAlgo.IsNull() ) CreateAlgo(); - - HLRBRep_HLRToShape aHLRToShape( myAlgo ); - - mySetOfCurves = new GGraphic2d_SetOfCurves( this ); - myHSetOfCurves = new GGraphic2d_SetOfCurves( this ); - - if ( myESharp ) { - VCompound = aHLRToShape.VCompound(); - DrawCurves( VCompound, mySetOfCurves ); - } - if ( myESmooth ) { - Rg1LineVCompound = aHLRToShape.Rg1LineVCompound(); - DrawCurves( Rg1LineVCompound, mySetOfCurves ); - } - if ( myESewn ) { - RgNLineVCompound = aHLRToShape.RgNLineVCompound(); - DrawCurves( RgNLineVCompound, mySetOfCurves ); - } - if ( myEOutline ) { - OutLineVCompound = aHLRToShape.OutLineVCompound(); - DrawCurves( OutLineVCompound, mySetOfCurves ); - } - if ( myEIsoline ) { - IsoLineVCompound = aHLRToShape.IsoLineVCompound(); - DrawCurves( IsoLineVCompound, mySetOfCurves ); - } - - if ( myIsHiddenLine ) { - if ( myESharp ) { - HCompound = aHLRToShape.HCompound(); - DrawCurves( HCompound, myHSetOfCurves ); - } - if ( myESmooth ) { - Rg1LineHCompound = aHLRToShape.Rg1LineHCompound(); - DrawCurves( Rg1LineHCompound, myHSetOfCurves ); - } - if ( myESewn ) { - RgNLineHCompound = aHLRToShape.RgNLineHCompound(); - DrawCurves( RgNLineHCompound, myHSetOfCurves ); - } - if ( myEOutline ) { - OutLineHCompound = aHLRToShape.OutLineHCompound(); - DrawCurves( OutLineHCompound, myHSetOfCurves ); - } - if ( myEIsoline ) { - IsoLineHCompound = aHLRToShape.IsoLineHCompound(); - DrawCurves( IsoLineHCompound, myHSetOfCurves ); - } - } //end if is HiddenLine - - } // end if is PolyAlgo - -} - -inline HLRAlgo_Projector AIS2D_ProjShape::Projector() const { - return myProjector; -} - -void AIS2D_ProjShape::SetProjector(const HLRAlgo_Projector& aProjector) { - - myProjector = aProjector; - myAlgo.Nullify(); - myPolyAlgo.Nullify(); - if ( Length() ) { - RemovePrimitives(); - ComputeShape(); - } -} - -void AIS2D_ProjShape::SetNbIsos( const Standard_Integer aNbIsos ) { - - myNbIsos = aNbIsos; - myAlgo.Nullify(); - if ( Length() ) { - RemovePrimitives(); - ComputeShape(); - } -} - -void AIS2D_ProjShape::SetPolyAlgo( const Standard_Boolean aIsPoly ) { - - myIsPolyAlgo = aIsPoly; - if ( Length() ) { - RemovePrimitives(); - ComputeShape(); - } -} - -void AIS2D_ProjShape::SetHLMode( const Standard_Boolean aIsHLM ) { - - myIsHiddenLine = aIsHLM; - if ( Length() ) { - RemovePrimitives(); - ComputeShape(); - } -} - -Standard_Boolean AIS2D_ProjShape::IsHLMode() const { - return myIsHiddenLine; -} - -Standard_Integer AIS2D_ProjShape::GetNbIsos() const { - return myNbIsos; -} - -Standard_Boolean AIS2D_ProjShape::GetIsPoly() const { - return myIsPolyAlgo; -} - -Handle(Graphic2d_Line) AIS2D_ProjShape::GetPrimitives() const { - if ( myIsPolyAlgo ) - return mySetOfSegments; - else - return mySetOfCurves; -} - -Handle(Graphic2d_Line) AIS2D_ProjShape::GetHLPrimitives() const { - if ( myIsPolyAlgo ) - return myHSetOfSegments; - else - return myHSetOfCurves; -} - -void AIS2D_ProjShape::CreateAlgo() { - - myAlgo = new HLRBRep_Algo(); - TopTools_ListIteratorOfListOfShape anIterator( myListOfShape ); - for ( ; anIterator.More(); anIterator.Next() ) - myAlgo->Add( anIterator.Value(), myNbIsos ); - myAlgo->Projector( myProjector ); - myAlgo->Update(); - myAlgo->Hide(); - -} - -void AIS2D_ProjShape::CreatePolyAlgo() { - - myPolyAlgo = new HLRBRep_PolyAlgo(); - TopTools_ListIteratorOfListOfShape anIterator(myListOfShape); - for ( ; anIterator.More(); anIterator.Next() ) - myPolyAlgo->Load( anIterator.Value() ); - myPolyAlgo->Projector( myProjector ); - myPolyAlgo->Update(); -} - -void AIS2D_ProjShape::DrawSegments( const TopoDS_Shape& aShape, - Handle(Graphic2d_SetOfSegments)& aSofS ) { - - if ( aShape.IsNull() ) return; - - TopExp_Explorer theExp( aShape, TopAbs_EDGE ); - while ( theExp.More() ) { - const TopoDS_Edge& CurrentEdge = TopoDS::Edge( theExp.Current() ); - const TopoDS_Vertex& FirstVertex = TopExp::FirstVertex(CurrentEdge); - const TopoDS_Vertex& LastVertex = TopExp::LastVertex(CurrentEdge); - gp_Pnt FirstPoint = BRep_Tool::Pnt(FirstVertex); - gp_Pnt LastPoint = BRep_Tool::Pnt(LastVertex); - aSofS->Add( FirstPoint.X(), FirstPoint.Y(), LastPoint.X(), LastPoint.Y() ); - theExp.Next(); - } - } - -void AIS2D_ProjShape::DrawCurves( const TopoDS_Shape& aShape, - Handle(GGraphic2d_SetOfCurves)& aSofC) { - - if ( aShape.IsNull() ) return; - - TopExp_Explorer theExp( aShape, TopAbs_EDGE ); - Handle(Geom2d_Curve) aCurve; - Handle(Geom_Surface) aSurface; - TopLoc_Location theLoc; - Standard_Real f, l; - while ( theExp.More() ) { - - const TopoDS_Edge& CurrentEdge = TopoDS::Edge( theExp.Current() ); - BRep_Tool::CurveOnSurface( CurrentEdge, aCurve, aSurface, theLoc, f, l ); - Standard_ASSERT (theLoc.IsIdentity(), "Unexpected edge with non-identity location", continue); - Standard_ASSERT (! aCurve.IsNull(), "Null PCurve", continue); - Handle(Geom2d_TrimmedCurve) theCurve = new Geom2d_TrimmedCurve(aCurve,f,l); - aSofC->Add(theCurve); - theExp.Next(); - } -} - -void AIS2D_ProjShape::ShowEdges( const Standard_Boolean aSharp, - const Standard_Boolean aSmooth, - const Standard_Boolean aSewn, - const Standard_Boolean anOutline, - const Standard_Boolean anIsoline ) { - myESharp = aSharp; - myESmooth = aSmooth; - myESewn = aSewn; - myEOutline = anOutline; - myEIsoline = anIsoline; - - if ( Length() ) { - RemovePrimitives(); - ComputeShape(); - } -} diff --git a/src/Aspect/Aspect_Driver.cdl b/src/Aspect/Aspect_Driver.cdl index e64af264d9..0351b9878c 100755 --- a/src/Aspect/Aspect_Driver.cdl +++ b/src/Aspect/Aspect_Driver.cdl @@ -87,8 +87,7 @@ is ---Category: Methods to define the WidthIndexs SetFontMap(me: mutable; - aFontMap: FontMap from Aspect; - useMFT: Boolean from Standard = Standard_True) + aFontMap: FontMap from Aspect) raises DriverError from Aspect is static; ---Category: Methods to define the FontIndexs ---Purpose: @@ -414,8 +413,6 @@ is -- the DWU position . ---Category: Inquire methods - UseMFT ( me ) returns Boolean from Standard is static; - ---Level: Advanced ---Purpose: Returns TRUE when the driver must use MDTV fonts -- instead system fonts. @@ -431,6 +428,5 @@ fields myTypeMapIsDefined: Boolean from Standard; myFontMapIsDefined: Boolean from Standard; myMarkMapIsDefined: Boolean from Standard; - myUseMFT: Boolean from Standard; end Driver from Aspect; diff --git a/src/Aspect/Aspect_Driver.cxx b/src/Aspect/Aspect_Driver.cxx index 52453cea5a..f1b655b186 100755 --- a/src/Aspect/Aspect_Driver.cxx +++ b/src/Aspect/Aspect_Driver.cxx @@ -43,31 +43,9 @@ #include #include -static Standard_Boolean dirMFTisDefined = Standard_False; Aspect_Driver::Aspect_Driver () { - OSD_Environment CSF_MDTVFontDirectory ; - - char *fontdir , *casroot ; - fontdir = getenv("CSF_MDTVFontDirectory" ); - if ( !fontdir) { - casroot = getenv("CASROOT"); - if ( casroot ) { - TCollection_AsciiString CasRootString (casroot); - CasRootString += "/src/FontMFT" ; - CSF_MDTVFontDirectory = OSD_Environment(CasRootString.ToCString()); - } else { - cout << " CASROOT or CSF_MDTVFontDirectory are mandatory to use this fonctionnality " << endl; - Standard_Failure::Raise ( "CSF_MDTVTexturesDirectory and CASROOT not setted " ); - } - } else { - CSF_MDTVFontDirectory = OSD_Environment("CSF_MDTVFontDirectory"); - } - TCollection_AsciiString dir(CSF_MDTVFontDirectory.Value()); - - dirMFTisDefined = (dir.Length() > 0); - myUseMFT = Standard_True; myColorMapIsDefined = Standard_False; myWidthMapIsDefined = Standard_False; myTypeMapIsDefined = Standard_False; @@ -112,10 +90,8 @@ Handle(Aspect_WidthMap) Aspect_Driver::WidthMap () const { return myWidthMap; } -void Aspect_Driver::SetFontMap (const Handle(Aspect_FontMap)& aFontMap, - const Standard_Boolean useMFT) +void Aspect_Driver::SetFontMap (const Handle(Aspect_FontMap)& aFontMap) { - myUseMFT = useMFT; myFontMap = aFontMap; this->InitializeFontMap(aFontMap); myFontMapIsDefined = Standard_True; @@ -138,6 +114,3 @@ Handle(Aspect_MarkMap) Aspect_Driver::MarkMap () const { return myMarkMap; } -Standard_Boolean Aspect_Driver::UseMFT () const { - return myUseMFT & dirMFTisDefined; -} diff --git a/src/CGM/CGM.cdl b/src/CGM/CGM.cdl deleted file mode 100755 index 6cde5bed70..0000000000 --- a/src/CGM/CGM.cdl +++ /dev/null @@ -1,39 +0,0 @@ --- Created on: 1997-06-25 --- Created by: Laurent GARRIGA --- Copyright (c) 1997-1999 Matra Datavision --- Copyright (c) 1999-2012 OPEN CASCADE SAS --- --- The content of this file is subject to the Open CASCADE Technology Public --- License Version 6.5 (the "License"). You may not use the content of this file --- except in compliance with the License. Please obtain a copy of the License --- at http://www.opencascade.org and read it completely before using this file. --- --- The Initial Developer of the Original Code is Open CASCADE S.A.S., having its --- main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. --- --- The Original Code and all software distributed under the License is --- distributed on an "AS IS" basis, without warranty of any kind, and the --- Initial Developer hereby disclaims all such warranties, including without --- limitation, any warranties of merchantability, fitness for a particular --- purpose or non-infringement. Please see the License for the specific terms --- and conditions governing the rights and limitations under the License. - - -package CGM - -uses - Aspect, - PlotMgt, - TCollection, - Quantity, - TShort, - TColStd, - Standard, - TColQuantity - -is - class Driver; - ---Purpose: Creates the CGM driver. - ---Category: Classes - -end CGM; diff --git a/src/CGM/CGM_Driver.cdl b/src/CGM/CGM_Driver.cdl deleted file mode 100755 index 5a0fb4b4bd..0000000000 --- a/src/CGM/CGM_Driver.cdl +++ /dev/null @@ -1,198 +0,0 @@ --- Created on: 1996-09-13 --- Created by: DCB --- Copyright (c) 1996-1999 Matra Datavision --- Copyright (c) 1999-2012 OPEN CASCADE SAS --- --- The content of this file is subject to the Open CASCADE Technology Public --- License Version 6.5 (the "License"). You may not use the content of this file --- except in compliance with the License. Please obtain a copy of the License --- at http://www.opencascade.org and read it completely before using this file. --- --- The Initial Developer of the Original Code is Open CASCADE S.A.S., having its --- main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. --- --- The Original Code and all software distributed under the License is --- distributed on an "AS IS" basis, without warranty of any kind, and the --- Initial Developer hereby disclaims all such warranties, including without --- limitation, any warranties of merchantability, fitness for a particular --- purpose or non-infringement. Please see the License for the specific terms --- and conditions governing the rights and limitations under the License. - - -class Driver from CGM inherits PlotterDriver from PlotMgt - ---Purpose: This class defines a CGM (Computer Graphic Metafile) plotter Driver. - --- All necessary information about methods (purpose, level, category, etc.) - --- can be found in CDL files from the inheritance tree (PlotMgt_PlotterDriver, - --- Aspect_Driver). - -uses - Plotter from PlotMgt, - ExtendedString from TCollection, - ColorMap from Aspect, - TypeMap from Aspect, - WidthMap from Aspect, - TypeOfText from Aspect, - TypeOfColorSpace from Aspect, - PlaneAngle from Quantity, - Length from Quantity, - Factor from Quantity, - Ratio from Quantity, - Array1OfShortReal from TShort - - -is - Create(aPlotter : Plotter from PlotMgt; - aName : CString from Standard; - aDX,aDY : Length from Quantity; - aTypeOfColorSpace : TypeOfColorSpace from Aspect = Aspect_TOCS_RGB) - returns mutable Driver from CGM; - - - Create(aName : CString from Standard; - aDX,aDY : Length from Quantity; - aTypeOfColorSpace : TypeOfColorSpace from Aspect = Aspect_TOCS_RGB) - returns mutable Driver from CGM; - - - BeginFile(me: mutable; - aPlotter : Plotter from PlotMgt; - aDX,aDY : Length from Quantity; - aTypeOfColorSpace : TypeOfColorSpace from Aspect) - is private; - - Close(me: mutable) - is redefined protected; - ---C++: alias ~ - - - BeginDraw (me: mutable) - is redefined; - - - EndDraw (me: mutable; dontFlush: Boolean = Standard_False) - is redefined; - - - --------------------------------------------- - -- Category: Methods to define the attributes - --------------------------------------------- - InitializeColorMap(me: mutable; aColorMap: ColorMap from Aspect) - is redefined protected; - - - InitializeTypeMap(me: mutable; aTypeMap: TypeMap from Aspect) - is redefined protected; - - - InitializeWidthMap(me: mutable; aWidthMap: WidthMap from Aspect) - is virtual protected; - - - ----------------------------------------- - -- Category: Methods to manage the images - ----------------------------------------- - SizeOfImageFile (me; anImageFile: CString from Standard; - aWidth,aHeight: out Integer from Standard) - returns Boolean from Standard is redefined; - - - -------------------------------- - -- Actual set graphic attributes - -------------------------------- - PlotLineAttrib (me: mutable; - ColorIndex: Integer from Standard; - TypeIndex: Integer from Standard; - WidthIndex: Integer from Standard) - is redefined protected; - - - PlotPolyAttrib (me: mutable; - ColorIndex: Integer from Standard; - TileIndex: Integer from Standard; - DrawEdge: Boolean from Standard) - is redefined protected; - - - ----------------------------------------------- - -- Category: Private methods to draw primitives - ----------------------------------------------- - PlotPoint (me : mutable; X, Y: ShortReal from Standard) - returns Boolean from Standard - is redefined protected; - - - PlotSegment (me : mutable; - X1, Y1: ShortReal from Standard; - X2, Y2: ShortReal from Standard) - returns Boolean from Standard - is redefined protected; - - - PlotPolyline (me : mutable; - xArray : Address from Standard; - yArray : Address from Standard; - nPts : Address from Standard; - nParts : Integer from Standard) - returns Boolean from Standard - is redefined protected; - - - PlotPolygon (me : mutable; - xArray : Address from Standard; - yArray : Address from Standard; - nPts : Address from Standard; - nParts : Integer from Standard) - returns Boolean from Standard - is redefined protected; - - - PlotArc (me : mutable; X,Y : ShortReal from Standard; - anXradius,anYradius : ShortReal from Standard; - sAngle: ShortReal from Standard; - oAngle: ShortReal from Standard) - returns Boolean from Standard - is redefined protected; - - - PlotPolyArc (me : mutable; X,Y : ShortReal from Standard; - anXradius,anYradius : ShortReal from Standard; - sAngle: ShortReal from Standard; - oAngle: ShortReal from Standard) - returns Boolean from Standard - is redefined protected; - - - PlotImage (me: mutable; - aX, aY, aWidth: ShortReal from Standard; - aHeight, aScale: ShortReal from Standard; - anImageFile: CString from Standard; - anArrayOfPixels: Address from Standard; - aLineIndex: Integer from Standard = -1) - returns Boolean from Standard - is redefined protected; - - - InitializeDriver (me: mutable; aName: CString from Standard) - is private; - - - WriteData (me: mutable; - aCode: Integer from Standard; - pLongData: Address from Standard; - pFloatData: Address from Standard; - pCharData: Address from Standard) - is private; - - -fields - myBKIndex: Integer from Standard; - myCurrentPage: Integer from Standard; - myFileIsOpened: Boolean from Standard; - myFillIndex: Integer from Standard; - myEdgeColor: Integer from Standard; - myEdgeType: Integer from Standard; - myEdgeWidth: Integer from Standard; - myInteriorStyle: Integer from Standard; - myEdgeVisibility: Integer from Standard; - -end Driver from CGM; diff --git a/src/CGM/CGM_Driver.cxx b/src/CGM/CGM_Driver.cxx deleted file mode 100755 index a012245e7d..0000000000 --- a/src/CGM/CGM_Driver.cxx +++ /dev/null @@ -1,841 +0,0 @@ -// Created on: 1996-09-13 -// Created by: DCB -// Copyright (c) 1996-1999 Matra Datavision -// Copyright (c) 1999-2012 OPEN CASCADE SAS -// -// The content of this file is subject to the Open CASCADE Technology Public -// License Version 6.5 (the "License"). You may not use the content of this file -// except in compliance with the License. Please obtain a copy of the License -// at http://www.opencascade.org and read it completely before using this file. -// -// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its -// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. -// -// The Original Code and all software distributed under the License is -// distributed on an "AS IS" basis, without warranty of any kind, and the -// Initial Developer hereby disclaims all such warranties, including without -// limitation, any warranties of merchantability, fitness for a particular -// purpose or non-infringement. Please see the License for the specific terms -// and conditions governing the rights and limitations under the License. - - -#define xBUG // GG 140699 -// Ascendante compatibillity using OLD driver constructor -// must generates directly a file. - -#define IMP020701 //GG -// Don't creates an external reference named error please ... -// Thanks to SAMTECH - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -static Handle(Image_Image) myImage; - -/////////////////////////////////////////////////////////////////////////*/ -#define TRACE 0 -#define PPI (float)(72.F/(0.0254005F METER)) -#define MAXPARAM 1024 -#define TRANSFORMCOLOR(c) \ - { if (TypeOfCgm == CgmCharEncoding) c = (((c+1) << 2) - 1); } - -#define DRAD (M_PI/180.) -#define DEFPLOTTER "DIRECT_CGM" - -//----------------------------------------------------------------- -// Standard CGM settings. -//----------------------------------------------------------------- -#define CGMVER 1 -#define INTBITS 32 -#define MAXREAL 32767.0000F // Clear text -#define MINREAL -32768.0000F -#define REALBITS 15 // Character encoding -#define REALPLACES -5 -#define REALDEFEXP 0 -#define REALEXP 0 -#define REALFORM 0 // Binary encoding -#define REALWHOLE 15 -#define REALFRACTION 20 - -#define INDEXBITS 8 -#define CLRBITS 16 -#define CLRINDBITS 8 -#define SCALEMOD ABSTRACT -#define SCALFACT 1 -#define IMCOLRPREC 65536 -#define BACKRED 255 -#define BACKGREEN 255 -#define BACKBLUE 255 - -//----------------------------------------------------------------- -// CGM states. -//----------------------------------------------------------------- -typedef enum { - CgmBinary, - CgmCharEncoding, - CgmClearText -} CgmType; - -typedef enum { - mfDesc, - picDesc, - picBody, - imgDraw -} CGMstate; -static CGMstate myState; - -static TColStd_DataMapOfIntegerInteger aTypeIndex; -static CgmType TypeOfCgm; - -//Definition of the C handle who handles the CGM metafile -FILE* cgmo; - -//Those C arrays are the parameters used by the CGM library. -long ptablong[MAXPARAM]; -float ptabreal[MAXPARAM]; -char ptabchar[MAXPARAM]; - -//Declare the array in wich WIDTHS will be put (an internal widthmap). -float* WIDTHMAP = NULL; - -// Error string -#ifndef IMP020701 -char error[1024]; -#endif - -//============================================================= -CGM_Driver::CGM_Driver (const Handle(PlotMgt_Plotter)& aPlotter, - const Standard_CString aName, - const Quantity_Length aDX, - const Quantity_Length aDY, - const Aspect_TypeOfColorSpace aTypeOfColorSpace) - : PlotMgt_PlotterDriver (aPlotter, aName) -{ - BeginFile (aPlotter, aDX, aDY, aTypeOfColorSpace); -} - -//============================================================= -CGM_Driver::CGM_Driver (const Standard_CString aName, - const Quantity_Length aDX, - const Quantity_Length aDY, - const Aspect_TypeOfColorSpace aTypeOfColorSpace) - : PlotMgt_PlotterDriver (aName) -{ - Handle(PlotMgt_Plotter) thePlotter = -#ifdef BUG - new PlotMgt_Plotter(TCollection_AsciiString(DEFPLOTTER)); -#else - new PlotMgt_Plotter(TCollection_AsciiString(DEFPLOTTER),Standard_True); -#endif - BeginFile (thePlotter, aDX, aDY, aTypeOfColorSpace); -} - -//============================================================= -void CGM_Driver::BeginFile (const Handle(PlotMgt_Plotter)& aPlotter, - const Quantity_Length aDX, - const Quantity_Length aDY, - const Aspect_TypeOfColorSpace aTypeOfColorSpace) -{ - SetPlotter (aPlotter); - // Initialization of buffers - memset (ptablong, 0, sizeof(ptablong)); - memset (ptabreal, 0, sizeof(ptabreal)); - memset (ptabchar, 0, sizeof(ptabchar)); - - myWidth = Standard_ShortReal(aDX - 2*myPaperMargin); - myHeight = Standard_ShortReal(aDY - 2*myPaperMargin); - myTypeOfColorSpace = aTypeOfColorSpace; - - // Set the type of CGM file by reading the environment variable "CSF_CGM_Type". - OSD_Environment cgmType = OSD_Environment ( "CSF_CGM_Type" ); - if (cgmType.Value().IsEmpty()) TypeOfCgm = CgmClearText; - else { - if (cgmType.Value().IsEqual("BIN")) { - TypeOfCgm = CgmBinary; - } else if (cgmType.Value().IsEqual("CAR")) { - TypeOfCgm = CgmCharEncoding; - } else if (cgmType.Value().IsEqual("TEX")) { - TypeOfCgm = CgmClearText; - } else TypeOfCgm = CgmClearText; - } - - // Open the CGM metafile - cgmo = OPEN_FILE ((Standard_PCharacter)myFileName.ToCString(), TypeOfCgm + 1); - if (!cgmo) { -#ifdef IMP020701 - char error[1024]; -#endif - sprintf (error, "****** CGM_Driver ERROR, unable to open file '%s'\n", - myFileName.ToCString()); - Aspect_DriverError::Raise(error); - } - // Write the metafile descriptor - myFileIsOpened = Standard_True; - myState = mfDesc; - InitializeDriver (myFileName.ToCString()); -} - -//============================================================= -void CGM_Driver::Close() -{ - if (myFileIsOpened) { - // Declare the end of the CGM metafile - WriteData (ENDMF, ptablong, ptabreal, ptabchar); - // Free memory allocated for WIDTHS - if (WIDTHMAP) - delete[] WIDTHMAP; - // Close the CGM metafile - CLOSE_FILE (); - myFileIsOpened = Standard_False; - } - aTypeIndex.Clear (); -} - -//============================================================= -void CGM_Driver::BeginDraw () -{ - // Create TextManager - myTextManager = new PlotMgt_TextManager(this); - //============================================ - if (myCurrentPage <= 0) myCurrentPage = 1; - else myCurrentPage++; - // Write the picture descriptor in the CGM metafile - myState = picDesc; - // Declare the new image - ptablong[0] = myCurrentPage; - WriteData (BEGPIC, ptablong, ptabreal, ptabchar); - // Set the color selection mode (always index) - old.color_mode = DIRECT; - cur.color_mode = INDEXED; - WriteData (COLRMODE, ptablong, ptabreal, ptabchar); - // Set the scale mode - cur.scale_mode = SCALEMOD; - cur.scale_factor = (float)SCALFACT; - WriteData (SCALEMODE, ptablong, ptabreal, ptabchar); - // Set the method to compute line width - old.linewidth_mode = SCALED; - cur.linewidth_mode = ABS; - WriteData (LINEWIDTHMODE, ptablong, ptabreal, ptabchar); - //Set the method to compute edge width - old.edgewidth_mode = SCALED; - cur.edgewidth_mode = ABS; - WriteData (EDGEWIDTHMODE, ptablong, ptabreal, ptabchar); - // Declare the window in which the picture will be drawn - cur.vdc_extent.a.x.real = (float)0; - cur.vdc_extent.a.y.real = (float)0; - cur.vdc_extent.b.x.real = myWidth; - cur.vdc_extent.b.y.real = myHeight; - WriteData (VDCEXT, ptablong, ptabreal, ptabchar); - // set the background color - cur.back.red = BACKRED; TRANSFORMCOLOR (cur.back.red); - cur.back.green = BACKGREEN; TRANSFORMCOLOR (cur.back.green); - cur.back.blue = BACKBLUE; TRANSFORMCOLOR (cur.back.blue); - WriteData (BACKCOLR, ptablong, ptabreal, ptabchar); - // Declare the body of the picture - WriteData (BEGPICBODY, ptablong, ptabreal, ptabchar); - myState = picBody; - // Write color map in the picture body - InitializeColorMap(ColorMap ()); - // Set clipping rectangle - cur.clip_rect.a.x.real = (float)0; - cur.clip_rect.a.y.real = (float)0; - cur.clip_rect.b.x.real = myWidth; - cur.clip_rect.b.y.real = myHeight; - WriteData (CLIPRECT, ptablong, ptabreal, ptabchar); - // Set clip indicator to ON - cur.clip_ind = ON; - WriteData (CLIP, ptablong, ptabreal, ptabchar); - // Reset default values for line & fill color and type of line - oldatt.line.index = -1; - oldatt.fill.index = -1; - oldatt.edge.index = -1; - oldatt.line_type = -1; - oldatt.edge_type = -1; -} - -//============================================================= -void CGM_Driver::EndDraw (const Standard_Boolean )//dontFlush) -{ - // Close the current picture - WriteData (ENDPIC, ptablong, ptabreal, ptabchar); - myImage.Nullify (); -} - -//============================================================= -void CGM_Driver::InitializeColorMap (const Handle(Aspect_ColorMap)& aColorMap) -{ - // CGM version 1 allows the COLOR MAP setting only in the body of a picture. - if (myState == picBody || myState == imgDraw) { - Standard_Real r,g,b; - Standard_Integer index,cpt,tab=2,Size = aColorMap->Size(); - Aspect_ColorMapEntry entry; - Quantity_Color color; - ptablong[0] = Size; - ptablong[1] = cpt = aColorMap->Entry(1).Index(); - for (Standard_Integer i=1; i<= Size; i++) { - entry = aColorMap->Entry(i); - index = entry.Index(); - color = entry.Color(); - color.Values(r, g, b, Quantity_TOC_RGB); - if (myTypeOfColorSpace != Aspect_TOCS_BlackAndWhite) { - ptablong[tab ] = Standard_Integer(255*r); TRANSFORMCOLOR(ptablong[tab ]); - ptablong[tab+1] = Standard_Integer(255*g); TRANSFORMCOLOR(ptablong[tab+1]); - ptablong[tab+2] = Standard_Integer(255*b); TRANSFORMCOLOR(ptablong[tab+2]); - } else { - ptablong[tab ] = 0; TRANSFORMCOLOR(ptablong[tab ]); - ptablong[tab+1] = 0; TRANSFORMCOLOR(ptablong[tab+1]); - ptablong[tab+2] = 0; TRANSFORMCOLOR(ptablong[tab+2]); - } - tab += 3; - if (cpt != index) - break; - cpt++; - } - // Put backgrount color at the end of ColorMap - ptablong[0]++; - ptablong[tab ] = BACKRED; TRANSFORMCOLOR(ptablong[tab ]); - ptablong[tab+1] = BACKGREEN; TRANSFORMCOLOR(ptablong[tab+1]); - ptablong[tab+2] = BACKBLUE; TRANSFORMCOLOR(ptablong[tab+2]); - myBKIndex = cpt; - // Write ColorMap to the CGM file - WriteData (COLRTABLE, ptablong, ptabreal, ptabchar); - if (myTypeOfColorSpace == Aspect_TOCS_BlackAndWhite) - myTypeOfColorSpace = Aspect_TOCS_RGB; - } -} - -//============================================================= -void CGM_Driver::InitializeTypeMap (const Handle(Aspect_TypeMap)& aTypeMap) -{ -/* -In CGM File: - LINEEDGETYPEDEF - code - LONG [0] - linetype (negative) - LING [1] - repeat length - for (i=0; i < LONG[1]; i++) - REAL [i] - line description element - it's necessary to put all line description elements as integers -*/ -/* - if (CGMstates == picdes) { - Standard_Integer Size = aTypeMap->Size(); - switch (TypeOfCgm) { - case (CgmBinary): - Aspect_DriverError::Raise("CGM BINARY ENCODING not implemented yet"); - break; - case (CgmCharEncoding): - Aspect_DriverError::Raise("CGM CHARACTER ENCODING not implemented yet"); - break; - case (CgmClearText): - for (Standard_Integer i=1; i<= Size; i++) { - fprintf(cgmo, "LINEEDGETYPEDEF"); - const TColQuantity_Array1OfLength& asr = aTypeMap->Entry(i).Type().Values(); - fprintf (cgmo," (%ld), ", -aTypeMap->Entry(i).Index()); - fprintf (cgmo,"%ld", asr.Upper()-asr.Lower()+1); - if ( (asr.Upper()-asr.Lower()+1) > 1 ) { - fprintf(cgmo,","); - } - for (Standard_Integer j = asr.Lower(); j < asr.Upper(); j += 2) { - fprintf(cgmo, "%.*f, %.*f", 5, asr(j+1), 5, asr(j)); - if (j+2 < asr.Upper()) { - fprintf(cgmo,","); - } - } - fprintf(cgmo,";\n"); - } - break; - } - } else { - CGMTypeMap = aTypeMap; - } -*/ - Standard_Integer Size = aTypeMap->Size(), i; - aTypeIndex.Clear(); - for (i = 1; i <= Size; i++) { - Standard_Integer index = aTypeMap->Entry(i).Index(); - if (aTypeMap->Entry(i).Type().Style() == Aspect_TOL_USERDEFINED) - aTypeIndex.Bind (index, 1); - else - aTypeIndex.Bind (index, aTypeMap->Entry(i).Type().Style()+1); - } -} - -//============================================================= -void CGM_Driver::InitializeWidthMap (const Handle(Aspect_WidthMap)& aWidthMap) -{ - Standard_Integer Size = aWidthMap->Size(); - if (WIDTHMAP) - delete[] WIDTHMAP; - WIDTHMAP = new float[Size]; - memset (WIDTHMAP, 0, Size * sizeof(float)); - for (Standard_Integer i=1; i<= Size; i++) { - Standard_Real w = aWidthMap->Entry(i).Width(); - WIDTHMAP[aWidthMap->Entry(i).Index()] = (float)w; - } -} - -//================================================================================= -Standard_Boolean CGM_Driver::SizeOfImageFile (const Standard_CString anImageFile, - Standard_Integer& aWidth, - Standard_Integer& aHeight) const -{ - return AlienImage::LoadImageFile (anImageFile, myImage, aWidth, aHeight); -} - -//============================================================= -// Category: Methods to write attributes -//============================================================= -void CGM_Driver::PlotLineAttrib (const Standard_Integer ColorIndex, - const Standard_Integer TypeIndex, - const Standard_Integer WidthIndex) -{ - // Set color of the line - if (myColorIndex != ColorIndex) { - curatt.line.index = myColorIndex = ColorIndex; - WriteData (LINECOLR, ptablong, ptabreal, ptabchar); - } - // Set type of the line - if (myTypeIndex != TypeIndex) { - curatt.line_type = myTypeIndex = TypeIndex; - WriteData (LINETYPE, ptablong, ptabreal, ptabchar); - } - // Set width of the line - if (myWidthIndex != WidthIndex) { - curatt.line_width.real = WIDTHMAP[(myWidthIndex = WidthIndex)]; - WriteData (LINEWIDTH, ptablong, ptabreal, ptabchar); - } - // Set the color of the edge of polygon - if (myEdgeColor != ColorIndex) { - curatt.edge.index = myEdgeColor = ColorIndex; - WriteData (EDGECOLR, ptablong, ptabreal, ptabchar); - } - // Set the type of the edge of polygon - if (myEdgeType != TypeIndex) { - curatt.edge_type = myEdgeType = TypeIndex; - WriteData (EDGETYPE, ptablong, ptabreal, ptabchar); - } - // Set the width of the edge of polygon - if (myEdgeWidth != WidthIndex) { - curatt.edge_width.real = WIDTHMAP[(myEdgeWidth = WidthIndex)]; - WriteData (EDGEWIDTH, ptablong, ptabreal, ptabchar); - } -} - -//=============================================================================== -void CGM_Driver::PlotPolyAttrib (const Standard_Integer ColorIndex, - const Standard_Integer TileIndex, - const Standard_Boolean DrawEdge) -{ - // Set the edge visibility to the corresponding value - if (myEdgeVisibility != (DrawEdge ? ON : OFF)) { - curatt.edge_vis = myEdgeVisibility = (DrawEdge ? ON : OFF); - WriteData (EDGEVIS, ptablong, ptabreal, ptabchar); - } - // Set the interior style to fill by solid - if (myInteriorStyle != (TileIndex < 0 ? EMPTY : SOLID)) { - curatt.int_style = myInteriorStyle = (TileIndex < 0 ? EMPTY : SOLID); - WriteData (INTSTYLE, ptablong, ptabreal, ptabchar); - } - // Set the fill color for drawing - if (myFillIndex != ColorIndex) { - if (ColorIndex > 0) curatt.fill.index = myFillIndex = ColorIndex; - else curatt.fill.index = myFillIndex = myBKIndex; - WriteData (FILLCOLR, ptablong, ptabreal, ptabchar); - } -} - -//============================================================= -// Category: Methods to draw primitives -//============================================================= - -//============================================================= -Standard_Boolean CGM_Driver::PlotPoint (const Standard_ShortReal X, - const Standard_ShortReal Y) -{ - ptablong[0] = 2; - ptabreal[0] = X; ptabreal[1] = Y; - ptabreal[2] = X + 0.1F; ptabreal[3] = Y + 0.1F; - WriteData (LINE, ptablong, ptabreal, ptabchar); - return Standard_True; -} - -//============================================================= -Standard_Boolean CGM_Driver::PlotSegment (const Standard_ShortReal X1, - const Standard_ShortReal Y1, - const Standard_ShortReal X2, - const Standard_ShortReal Y2) -{ - ptablong[0] = 2; - ptabreal[0] = X1; ptabreal[1] = Y1; - ptabreal[2] = X2; ptabreal[3] = Y2; - WriteData (LINE, ptablong, ptabreal, ptabchar); - return Standard_True; -} - -//============================================================= -#define _XP(idx) ((float*)xArray)[(idx)] -#define _YP(idx) ((float*)yArray)[(idx)] -//============================================================= -Standard_Boolean CGM_Driver::PlotPolyline (const Standard_Address xArray, - const Standard_Address yArray, - const Standard_Address nPts, - const Standard_Integer nParts) -{ - // Multipart drawing can only be used for text drawing - // (called from PlotMgt_TextManager::EndChar() - int Tab, N = 0; - for (int i = 0; i < nParts; i++) { - Tab = 0; - ptablong[0] = ((int*)nPts)[i]; - for (int j = N; j < N + ptablong[0]; j++) { - ptabreal[Tab++] = _XP(j); ptabreal[Tab++] = _YP(j); - } - WriteData (LINE, ptablong, ptabreal, ptabchar); - N += ptablong[0]; - } - return Standard_True; -} - -//============================================================= -Standard_Boolean CGM_Driver::PlotPolygon (const Standard_Address xArray, - const Standard_Address yArray, - const Standard_Address nPts, - const Standard_Integer nParts) -{ - if (nParts == 1) { - int Tab = 0; - ptablong[0] = ((int*)nPts)[0]; - for (int i=0; i < ptablong[0]; i++) { - ptabreal[Tab++] = _XP(i); ptabreal[Tab++] = _YP(i); - } - WriteData (POLYGON, ptablong, ptabreal, ptabchar); - } else { - // This can only be used for text drawing - // (called from PlotMgt_TextManager::EndChar() - int Tab = 0, Vis = 1, N = 0, cpN; - ptablong[0] = 0; - for (int i = 0; i < nParts; i++) { - cpN = ((int*)nPts)[i]; - for (int j = N; j < N + cpN - 1; j++) { - ptabreal[Tab++] = _XP(j); ptabreal[Tab++] = _YP(j); - ptablong[Vis++] = VIS; ptablong[0]++; - } - N += cpN; - ptabreal[Tab++] = _XP(N-1); ptabreal[Tab++] = _YP(N-1); - ptablong[Vis++] = CLOSEVIS; ptablong[0]++; - } - WriteData (POLYGONSET, ptablong, ptabreal, ptabchar); - } - return Standard_True; -} -//============================================================= -#undef _XP -#undef _YP - -//============================================================= -Standard_Boolean CGM_Driver::PlotArc (const Standard_ShortReal Xpos, - const Standard_ShortReal Ypos, - const Standard_ShortReal aXradius, - const Standard_ShortReal aYradius, - const Standard_ShortReal sAngle, - const Standard_ShortReal oAngle) -{ - Standard_ShortReal san = sAngle; - Standard_ShortReal fan = sAngle + oAngle; - if (oAngle >= 2*M_PI) { - PlotPolyAttrib (myLineColorIndex, -1, Standard_True); - if (aXradius == aYradius) { - ptabreal[0] = (float)Xpos; ptabreal[1] = (float)Ypos; - ptabreal[2] = (float)aXradius; - WriteData (CIRCLE, ptablong, ptabreal, ptabchar); - } else { - ptabreal[0] = (float)Xpos; ptabreal[1] = (float)Ypos; - ptabreal[2] = (float)(Xpos + aXradius); ptabreal[3] = (float)Ypos; - ptabreal[4] = (float)Xpos; ptabreal[5] = (float)(Ypos + aYradius); - WriteData (ELLIPSE, ptablong, ptabreal, ptabchar); - } - } else { - if (aXradius == aYradius) { - ptabreal[0] = (float)Xpos; ptabreal[1] = (float)Ypos; - ptabreal[2] = (float)cos(san); ptabreal[3] = (float)sin(san); - ptabreal[4] = (float)cos(fan); ptabreal[5] = (float)sin(fan); - ptabreal[6] = (float)aXradius; - WriteData (ARCCTR, ptablong, ptabreal, ptabchar); - } else { - ptabreal[0] = (float)Xpos; ptabreal[1] = (float)Ypos; - ptabreal[2] = (float)(Xpos + aXradius); ptabreal[3] = (float)Ypos; - ptabreal[4] = (float)Xpos; ptabreal[5] = (float)(Ypos + aYradius); - ptabreal[6] = (float)cos(san); ptabreal[7] = (float)sin(san); - ptabreal[8] = (float)cos(fan); ptabreal[9] = (float)sin(fan); - WriteData (ELLIPARC, ptablong, ptabreal, ptabchar); - } - } - return Standard_True; -} - -//============================================================= -Standard_Boolean CGM_Driver::PlotPolyArc (const Standard_ShortReal Xpos, - const Standard_ShortReal Ypos, - const Standard_ShortReal aXradius, - const Standard_ShortReal aYradius, - const Standard_ShortReal sAngle, - const Standard_ShortReal oAngle) -{ - Standard_ShortReal san = sAngle; - Standard_ShortReal fan = sAngle + oAngle; - if (oAngle >= 2.*M_PI) { - if (aXradius == aYradius) { - ptabreal[0] = (float)Xpos; ptabreal[1] = (float)Ypos; - ptabreal[2] = (float)aXradius; - WriteData (CIRCLE, ptablong, ptabreal, ptabchar); - } else { - ptabreal[0] = (float)Xpos; ptabreal[1] = (float)Ypos; - ptabreal[2] = (float)(Xpos + aXradius); ptabreal[3] = (float)aYradius; - ptabreal[4] = (float)Xpos; ptabreal[5] = (float)(Ypos + aYradius); - WriteData (ELLIPSE, ptablong, ptabreal, ptabchar); - } - } else { - if (aXradius == aYradius) { - ptabreal[0] = (float)Xpos; ptabreal[1] = (float)Ypos; - ptabreal[2] = (float)cos(san); ptabreal[3] = (float)sin(san); - ptabreal[4] = (float)cos(fan); ptabreal[5] = (float)sin(fan); - ptabreal[6] = (float)aXradius; ptablong[8] = 0; - WriteData (ARCCTRCLOSE, ptablong, ptabreal, ptabchar); - } else { - ptabreal[0] = (float)Xpos; ptabreal[1] = (float)Ypos; - ptabreal[2] = (float)(Xpos + aXradius); ptabreal[3] = (float)Ypos; - ptabreal[4] = (float)Xpos; ptabreal[5] = (float)(Ypos + aYradius); - ptabreal[6] = (float)cos(san); ptabreal[7] = (float)sin(san); - ptabreal[8] = (float)(aXradius*cos(fan)); ptabreal[9] = (float)(aYradius*sin(fan)); - ptablong[11] = 0; - WriteData (ELLIPARCCLOSE, ptablong, ptabreal, ptabchar); - } - } - return Standard_True; -} - -//============================================================= -// Private methods -//============================================================= -void CGM_Driver::InitializeDriver (const Standard_CString aName) -{ - //declare the Metafile - strcpy(ptabchar,aName); - WriteData (BEGMF, ptablong, ptabreal, ptabchar); - //Set the CGM's version - ptablong[0] = CGMVER; - WriteData (MFVERSION, ptablong, ptabreal, ptabchar); - //Put in the metafile a string whose content is free - strcpy(ptabchar,"Generated with CGM_Driver from MATRA-DATAVISION"); - WriteData (MFDESC, ptablong, ptabreal, ptabchar); - //Set the element list (always 'DRAWINGPLUS') - ptablong[1]=1; - WriteData (MFELEMLIST, ptablong, ptabreal, ptabchar); - //Set the type of value (integer or real) - cur.vdc_type = REAL; - WriteData (VDCTYPE, ptablong, ptabreal, ptabchar); - //Set the integer precision - cur.int_bits = INTBITS; - WriteData (INTEGERPREC, ptablong, ptabreal, ptabchar); - //Set the real precision - cur.max_real = MAXREAL; // Clear text - cur.min_real = MINREAL; - cur.real_bits = REALBITS; // Character encoding - cur.real_places = REALPLACES; - cur.real_defexp = REALDEFEXP; - cur.real_expald = REALEXP; - curbin.real_type = REALFORM; // Binary encoding - curbin.real_whole = REALWHOLE; - curbin.real_fraction = REALFRACTION; - WriteData (REALPREC, ptablong, ptabreal, ptabchar); - //Set the index precision - cur.index_bits = INDEXBITS; - WriteData (INDEXPREC, ptablong, ptabreal, ptabchar); - //Set the color precision - cur.col_bits = CLRBITS; - WriteData (COLRPREC, ptablong, ptabreal, ptabchar); - //Set the Color Index precision - cur.colind_bits = CLRINDBITS; - WriteData (COLRINDEXPREC, ptablong, ptabreal, ptabchar); - //set the max color index - cur.max_colind = 255; - WriteData (MAXCOLRINDEX, ptablong, ptabreal, ptabchar); - //Set the minimum color and the maximum color - cur.min_rgb.red = cur.min_rgb.green = cur.min_rgb.blue = 0; - cur.max_rgb.red = cur.max_rgb.green = cur.max_rgb.blue = 255; - TRANSFORMCOLOR(cur.max_rgb.red); - TRANSFORMCOLOR(cur.max_rgb.green); - TRANSFORMCOLOR(cur.max_rgb.blue); - WriteData (COLRVALUEEXT, ptablong, ptabreal, ptabchar); - //Set the internal variables - myBKIndex = 0; - myCurrentPage = 0; - myFillIndex = -9; - myEdgeColor = -9; - myEdgeType = -9; - myEdgeWidth = -9; - myInteriorStyle = -9; - myEdgeVisibility = -9; - myImage.Nullify (); -} - -//============================================================= -void CGM_Driver::WriteData (const Standard_Integer aCode, - const Standard_Address pLongData, - const Standard_Address pFloatData, - const Standard_Address pCharData) -{ - short code = (short) aCode; - long* aLong = (long*) pLongData; - float* aFloat = (float*)pFloatData; - char* aChar = (char*) pCharData; - if (code == LINETYPE) { - curatt.line_type = aTypeIndex.Find(curatt.line_type); - } else if (code == EDGETYPE) { - curatt.edge_type = aTypeIndex.Find(curatt.edge_type); - } - switch (TypeOfCgm) { - case (CgmBinary): - CGMObin (cgmo, code, aLong, aFloat, aChar); - break; - case (CgmCharEncoding): - CGMOchar (cgmo, code, aLong, aFloat, aChar); - break; - case (CgmClearText): - CGMOtext (cgmo, code, aLong, aFloat, aChar); - break; - } -} - -//============================================================= -Standard_Boolean CGM_Driver::PlotImage (const Standard_ShortReal aX, - const Standard_ShortReal aY, - const Standard_ShortReal aWidth, - const Standard_ShortReal aHeight, - const Standard_ShortReal aScale, - const Standard_CString anImageFile, - const Standard_Address anArrayOfPixels, - const Standard_Integer aLineIndex) -{ - Aspect_ColorMapEntry anEntry; - Handle(Aspect_GenericColorMap) aColorMap = new Aspect_GenericColorMap; - // We'll create new colormap here and will set it - Standard_Boolean status; - Standard_Integer idx = 0, found = 0, fidx = 0, LowX = 0, LowY = 0; - Standard_Integer width = Standard_Integer(aWidth), - height = Standard_Integer(aHeight); - Standard_Integer x, y; - Standard_Real r, g, b; - Aspect_RGBPixel* g2dp = (Aspect_RGBPixel*) anArrayOfPixels; - Quantity_Color color; - // Load image if necessary - if (anImageFile) { - status = SizeOfImageFile (anImageFile, width, height); - if (status) { - LowX = myImage -> LowerX (); - LowY = myImage -> LowerY (); - } - } else { - status = Standard_True; - } - - // Put image colormap and pixels to the file - if (status) { - Standard_ShortReal wscale, hscale; - wscale = hscale = (float)(aScale * myPixelSize * PPI / 2.F); - // Put image in the file - float a2X = (float)(aX - wscale * width/2.F); - float a2Y = (float)(aY + hscale * (height/2.F - (aLineIndex == -1 ? 0:aLineIndex))); - if (aLineIndex != -1) height = 1; - int cellsSize = sizeof(long)*(width*height + 10); - - Aspect_RGBPixel* pixels = - (Aspect_RGBPixel*) malloc (IMCOLRPREC*sizeof(Aspect_RGBPixel)); - if (pixels == NULL) return Standard_False; - long* cells = (long*) malloc (cellsSize); - if (cells == NULL) { free (pixels); return Standard_False; } - - //Initialize the array - memset (pixels, 0, IMCOLRPREC*sizeof(Aspect_RGBPixel)); - int pixidx = 10; // Pixel description begins with index 10 - // Put cellarray entry data - ptabreal[0] = a2X; ptabreal[1] = a2Y; // P - ptabreal[2] = a2X+(width*wscale); ptabreal[3] = a2Y-(height*hscale); // Q - ptabreal[4] = a2X+(width*wscale); ptabreal[5] = a2Y; // R - cells[0] = width*height; cells[7] = width; - cells[8] = height; - // For all pixels of an Image - for (y=0; y < height; y++) { - for (x=0; x < width; x++) { - // Get pixel of image at (x,y) position - if (anImageFile) { - color = myImage -> PixelColor (x + LowX, y + LowY); - color.Values (r, g, b, Quantity_TOC_RGB); - } else { - r = g2dp -> red; - g = g2dp -> green; - b = g2dp -> blue; - g2dp++; - } - // Try to find the pixel - for (int c = 0; c < idx; c++) { - if (pixels[c].red == r && pixels[c].green == g && pixels[c].blue == b) { - found = 1; - fidx = c; - } - if (found) break; - } - if (!found) { - // It's necessary to add new color to colormap - pixels[idx].red = (float)r; - pixels[idx].green = (float)g; - pixels[idx].blue = (float)b; - color.SetValues (r, g, b, Quantity_TOC_RGB); - anEntry = Aspect_ColorMapEntry (idx, color); - anEntry.SetIndex (idx); - aColorMap->AddEntry (anEntry); - cells[pixidx++] = idx; - idx++; - } else { - cells[pixidx++] = fidx; - } - if (idx > IMCOLRPREC) { - free (pixels); - free (cells); - return Standard_False; - } - found = 0; - } // for (x=0; x < width; x++) - } // for (y=0; y < height; y++) - free (pixels); - // Calculate image color precision - int imcolprec = 0, tmp = 1L; - while (tmp < aColorMap->Size()) { tmp <<= 1L; imcolprec++; } - cells[9] = imcolprec; - // Write image data to file (colormap and image data). - myState = imgDraw; - InitializeColorMap (aColorMap); - WriteData (CELLARRAY, cells, ptabreal, ptabchar); - // Restore old colormap - myState = picBody; - InitializeColorMap (ColorMap ()); - free (cells); - return Standard_True; - } // IF STATUS - return Standard_False; -} diff --git a/src/CGM/FILES b/src/CGM/FILES deleted file mode 100755 index 89c1fea0e0..0000000000 --- a/src/CGM/FILES +++ /dev/null @@ -1,14 +0,0 @@ -cgmlib.hxx -cgmatt.h -cgminit.h -cgmpar.h -cgmtypes.h -cgmelem.h -cgmmach.h -cgmstruc.h -cgmerr.h -cgmout.h -cgmobin.c -cgmotext.c -cgmochar.c -Gestfic.cxx diff --git a/src/CGM/Gestfic.cxx b/src/CGM/Gestfic.cxx deleted file mode 100755 index 00c7b18394..0000000000 --- a/src/CGM/Gestfic.cxx +++ /dev/null @@ -1,65 +0,0 @@ -// Copyright (c) 1999-2012 OPEN CASCADE SAS -// -// The content of this file is subject to the Open CASCADE Technology Public -// License Version 6.5 (the "License"). You may not use the content of this file -// except in compliance with the License. Please obtain a copy of the License -// at http://www.opencascade.org and read it completely before using this file. -// -// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its -// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. -// -// The Original Code and all software distributed under the License is -// distributed on an "AS IS" basis, without warranty of any kind, and the -// Initial Developer hereby disclaims all such warranties, including without -// limitation, any warranties of merchantability, fitness for a particular -// purpose or non-infringement. Please see the License for the specific terms -// and conditions governing the rights and limitations under the License. - -#include -#include - -#ifdef WNT -# include -#endif /* WNT */ - -static FILE* filed; -/***************************************************OPEN_FILE**************/ -FILE* OPEN_FILE (char* f_name, int TypeCgm) -{ - switch (TypeCgm){ - case 1: - case 2: - if ((filed = fopen(f_name,"wb" ))) { -#ifdef WNT - chmod (f_name, S_IREAD | S_IWRITE); -#else - chmod (f_name, 00777); -#endif -/* setbuf (filed, NULL);*/ - } - break; - case 3: - if ((filed = fopen(f_name,"w" ))) { -#ifdef WNT - chmod (f_name, S_IREAD | S_IWRITE); -#else - chmod (f_name, 00777); -#endif -/* setbuf (filed, NULL);*/ - } - break; - } - return filed; -} - -/**************************************************CLOSE_FILE************/ -void CLOSE_FILE () -{ - fclose (filed); -} - -/**************************************************getfd************/ -FILE* getfd () -{ - return filed; -} diff --git a/src/CGM/cgmatt.h b/src/CGM/cgmatt.h deleted file mode 100755 index 5bee983749..0000000000 --- a/src/CGM/cgmatt.h +++ /dev/null @@ -1,177 +0,0 @@ -/* - Copyright (c) 1999-2012 OPEN CASCADE SAS - - The content of this file is subject to the Open CASCADE Technology Public - License Version 6.5 (the "License"). You may not use the content of this file - except in compliance with the License. Please obtain a copy of the License - at http://www.opencascade.org and read it completely before using this file. - - The Initial Developer of the Original Code is Open CASCADE S.A.S., having its - main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. - - The Original Code and all software distributed under the License is - distributed on an "AS IS" basis, without warranty of any kind, and the - Initial Developer hereby disclaims all such warranties, including without - limitation, any warranties of merchantability, fitness for a particular - purpose or non-infringement. Please see the License for the specific terms - and conditions governing the rights and limitations under the License. - -*/ - -/*This file is used to define all attrib structures of the library used to -*/ -/*generate CGM files*/ -#ifndef CGMATT_H -#define CGMATT_H -#ifdef CGMATT_C -#define Extern -#else -#define Extern extern -#endif - - -#include "cgmtypes.h" - -struct sharedatt { - Index auxindex; - RGBcolour aux; - Enum colmode, - transparency; - float xgrain, - ygrain; -}; - -typedef struct sharedatt Sharedatt; - -struct lineatt { - Index type; - float width; - Enum widthmode; - Index colindex; - RGBcolour col; - Sharedatt *shared; -}; - -typedef struct lineatt Lineatt; - -struct markeratt { - Index type; - float size; - Enum sizemode; - Index colindex; - RGBcolour col; - Sharedatt *shared; -}; - -typedef struct markeratt Markeratt; - -struct textatt { - int fontcount; /* environmental variables */ - char **fontlist; - int csetcount; - char **csetlist; - Enum csetannouncer; - - Index fontindex; /* bundleable attributes */ - Enum precision; - float expansion; - float spacing; - Index colindex; - RGBcolour col; - - float height; /* device-independent variables */ - float xup, - yup, - xbase, - ybase; - Enum path; - Enum halign, - valign; - float hcont, - vcont; - Index csindex, - acsindex; - Sharedatt *shared; -}; - -typedef struct textatt Textatt; - -struct fillatt { - Index style; - Index colindex; - RGBcolour col; - Index hatch, - pattern; - Sharedatt *shared; -}; - -typedef struct fillatt Fillatt; - -struct edgeatt { - Index type; - float width; - Enum widthmode; - Index colindex; - RGBcolour col; - Sharedatt *shared; -}; - -typedef struct edgeatt Edgeatt; - -struct linebundle { - Index type; - float width; - Index colindex; - Colourentry col; -}; - -typedef struct linebundle Linebundle; - -struct markerbundle { - Index type; - float size; - Index colindex; - Colourentry col; -}; - -typedef struct markerbundle Markerbundle; - -struct textbundle { - Index font; - Enum precision; - float expansion; - float spacing; - Index colindex; - Colourentry col; -}; - -typedef struct textbundle Textbundle; - -struct fillbundle { - Index style; - Index pattern; - Index hatch; - Index colindex; - Colourentry col; -}; - -typedef struct fillbundle Fillbundle; - -struct edgebundle { - Index type; - float width; - Index colindex; - Colourentry col; -}; - -typedef struct edgebundle Edgebundle; - -Extern void ATTline(); -Extern void ATTmarker(); -Extern void ATTtext(); -Extern void ATTfill(); -Extern void ATTedge(); - -#undef Extern - -#endif /* end of cgmatt.h */ diff --git a/src/CGM/cgmelem.h b/src/CGM/cgmelem.h deleted file mode 100755 index 8b1a6637a3..0000000000 --- a/src/CGM/cgmelem.h +++ /dev/null @@ -1,275 +0,0 @@ -/* - Copyright (c) 1999-2012 OPEN CASCADE SAS - - The content of this file is subject to the Open CASCADE Technology Public - License Version 6.5 (the "License"). You may not use the content of this file - except in compliance with the License. Please obtain a copy of the License - at http://www.opencascade.org and read it completely before using this file. - - The Initial Developer of the Original Code is Open CASCADE S.A.S., having its - main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. - - The Original Code and all software distributed under the License is - distributed on an "AS IS" basis, without warranty of any kind, and the - Initial Developer hereby disclaims all such warranties, including without - limitation, any warranties of merchantability, fitness for a particular - purpose or non-infringement. Please see the License for the specific terms - and conditions governing the rights and limitations under the License. - -*/ - -#ifndef CGMELEM_H -#define CGMELEM_H - -/* Include the files on which this is dependent. */ - -#include "cgmtypes.h" - -#define ASFS 18 - -/* Non-Op */ - -#define NONOP (Code) 0 - -/* Character CGM hex values */ - -#define BEGMF (Code) 0x3020 -#define ENDMF (Code) 0x3021 -#define BEGPIC (Code) 0x3022 -#define BEGPICBODY (Code) 0x3023 -#define ENDPIC (Code) 0x3024 - -/* Metafile Descriptor elements */ - -#define MFVERSION (Code) 0x3120 -#define MFDESC (Code) 0x3121 -#define VDCTYPE (Code) 0x3122 -#define INTEGERPREC (Code) 0x3123 -#define REALPREC (Code) 0x3124 -#define INDEXPREC (Code) 0x3125 -#define COLRPREC (Code) 0x3126 -#define COLRINDEXPREC (Code) 0x3127 -#define MAXCOLRINDEX (Code) 0x3128 -#define COLRVALUEEXT (Code) 0x3129 -#define MFELEMLIST (Code) 0x312A -#define BEGMFDEFAULTS (Code) 0x312B -#define ENDMFDEFAULTS (Code) 0x312C -#define FONTLIST (Code) 0x312D -#define CHARSETLIST (Code) 0x312E -#define CHARCODING (Code) 0x312F - -/* Picture descriptor elements */ - -#define SCALEMODE (Code) 0x3220 -#define COLRMODE (Code) 0x3221 -#define LINEWIDTHMODE (Code) 0x3222 -#define MARKERSIZEMODE (Code) 0x3223 -#define EDGEWIDTHMODE (Code) 0x3224 -#define VDCEXT (Code) 0x3225 -#define BACKCOLR (Code) 0x3226 - -/* Control elements */ - -#define VDCINTEGERPREC (Code) 0x3320 -#define VDCREALPREC (Code) 0x3321 -#define AUXCOLR (Code) 0x3322 -#define TRANSPARENCY (Code) 0x3323 -#define CLIPRECT (Code) 0x3324 -#define CLIP (Code) 0x3325 - -/* Graphics primitives */ - -#define LINE (Code) 0x20 -#define DISJTLINE (Code) 0x21 -#define MARKER (Code) 0x22 -#define TEXT (Code) 0x23 -#define RESTRTEXT (Code) 0x24 -#define APNDTEXT (Code) 0x25 -#define POLYGON (Code) 0x26 -#define POLYGONSET (Code) 0x27 -#define CELLARRAY (Code) 0x28 -#define GDP (Code) 0x29 -#define RECT (Code) 0x2A - -#define CIRCLE (Code) 0x3420 -#define ARC3PT (Code) 0x3421 -#define ARC3PTCLOSE (Code) 0x3422 -#define ARCCTR (Code) 0x3423 -#define ARCCTRCLOSE (Code) 0x3424 -#define ELLIPSE (Code) 0x3425 -#define ELLIPARC (Code) 0x3426 -#define ELLIPARCCLOSE (Code) 0x3427 - -/* Attribute elements */ - -#define LINEINDEX (Code) 0x3520 -#define LINETYPE (Code) 0x3521 -#define LINEWIDTH (Code) 0x3522 -#define LINECOLR (Code) 0x3523 -#define MARKERINDEX (Code) 0x3524 -#define MARKERTYPE (Code) 0x3525 -#define MARKERSIZE (Code) 0x3526 -#define MARKERCOLR (Code) 0x3527 - -#define TEXTINDEX (Code) 0x3530 -#define TEXTFONTINDEX (Code) 0x3531 -#define TEXTPREC (Code) 0x3532 -#define CHAREXPAN (Code) 0x3533 -#define CHARSPACE (Code) 0x3534 -#define TEXTCOLR (Code) 0x3535 -#define CHARHEIGHT (Code) 0x3536 -#define CHARORI (Code) 0x3537 -#define TEXTPATH (Code) 0x3538 -#define TEXTALIGN (Code) 0x3539 -#define CHARSETINDEX (Code) 0x353A -#define ALTCHARSETINDEX (Code) 0x353B - -#define FILLINDEX (Code) 0x3620 -#define INTSTYLE (Code) 0x3621 -#define FILLCOLR (Code) 0x3622 -#define HATCHINDEX (Code) 0x3623 -#define PATINDEX (Code) 0x3624 -#define EDGEINDEX (Code) 0x3625 -#define EDGETYPE (Code) 0x3626 -#define EDGEWIDTH (Code) 0x3627 -#define EDGECOLR (Code) 0x3628 -#define EDGEVIS (Code) 0x3629 -#define FILLREFPT (Code) 0x362A -#define PATTABLE (Code) 0x362B -#define PATSIZE (Code) 0x362C - -#define COLRTABLE (Code) 0x3630 -#define ASF (Code) 0x3631 - -/* Escape Elements */ - -#define ESCAPE (Code) 0x3720 -#define MESSAGE (Code) 0x3721 -#define APPLDATA (Code) 0x3722 - -#define DOMAINRING (Code) 0x3730 - -/* Version 2 Elements - Addendum 1 */ - -#if CGMVERSION > 1 - -#define BEGSEG (Code) 0x3025 -#define ENDSEG (Code) 0x3026 -#define BEGFIG (Code) 0x3027 -#define ENDFIG (Code) 0x3028 - -#define NAMEPREC (Code) 0x3130 -#define MAXVDCEXT (Code) 0x3131 -#define SEGPRIEXT (Code) 0x3132 - -#define DEVVP (Code) 0x3227 -#define DEVVPMODE (Code) 0x3228 -#define DEVVPMAP (Code) 0x3229 -#define LINEREP (Code) 0x322A -#define MARKERREP (Code) 0x322B -#define TEXTREP (Code) 0x322C -#define FILLREP (Code) 0x322D -#define EDGEREP (Code) 0x322E - -#define LINECLIPMODE (Code) 0x3326 - -#define MARKERCLIPMODE (Code) 0x3327 - -#define EDGECLIPMODE (Code) 0x3328 - -#define NEWREGION (Code) 0x3329 -#define SAVEPRIMCONT (Code) 0x332A - -#define RESPRIMCONT (Code) 0x332B - -#define ARCCTRREV (Code) 0x3428 -#define CONNEDGE (Code) 0x3429 - -#define PICKID (Code) 0x3632 - -#define COPYSEG (Code) 0x3820 -#define INHFILTER (Code) 0x3821 -#define CLIPINH (Code) 0x3822 -#define SEGTRANS (Code) 0x3823 -#define SEGHIGHLIGHT (Code) 0x3824 - -#define SEGDISPPRI (Code) 0x3825 -#define SEGPICKPRI (Code) 0x3826 - -/* GKS Annex elements */ - -#define BEGGKSSESSIONMF (Code) 0x3029 -#define BEGGKSSESSION (Code) 0x302A -#define ENDGKSSESSION (Code) 0x302B - -#define WSVP (Code) 0x332C -#define CLEAR (Code) 0x332D -#define UPD (Code) 0x332E -#define DEFERST (Code) 0x332F - -#define DELSEG (Code) 0x3827 -#define RENAMESEG (Code) 0x3828 -#define REDRAWALLSEG (Code) 0x3829 -#define SEGVIS (Code) 0x382A -#define SEGDET (Code) 0x382B - -/* Version 3 Elements - Addendum 3 */ - -#if CGMVERSION > 2 - -#define BEGPROTREGION (Code) 0x302C -#define ENDPROTREGION (Code) 0x302D -#define BEGCOMPOLINE (Code) 0x302E -#define ENDCOMPOLINE (Code) 0x302F -#define BEGCOMPOTEXTPATH (Code) 0x3030 -#define ENDCOMPOTEXTPATH (Code) 0x3031 -#define BEGTILEARRAY (Code) 0x3032 -#define ENDTILEARRAY (Code) 0x3033 - -#define COLRMODEL (Code) 0x3133 -#define COLRCALIB (Code) 0x3134 -#define FONTPROP (Code) 0x3135 -#define GLYPHMAP (Code) 0x3136 -#define SYMBOLLIBLIST (Code) 0x3137 - -#define INTSTYLEMODE (Code) 0x322F -#define LINEEDGETYPEDEF (Code) 0x3230 -#define HATCHSTYLEDEF (Code) 0x3231 -#define GEOPATDEF (Code) 0x3232 - -#define PROTREGION (Code) 0x3330 -#define GENTEXTPATHMODE (Code) 0x3331 -#define MITRELLIMIT (Code) 0x3332 -#define TRANSPCELLCOLR (Code) 0x3333 - -#define HYPERBARC (Code) 0x342A -#define PARABARC (Code) 0x342B -#define NUB (Code) 0x342C -#define NURB (Code) 0x342D -#define POLYBEZIER (Code) 0x342E -#define SYMBOL (Code) 0x342F -#define INCRSYMBOL (Code) 0x342F -#define BITONALTILE (Code) 0x3430 -#define TILE (Code) 0x3431 - -#define LINECAP (Code) 0x3528 -#define LINEJOIN (Code) 0x3529 -#define LINETYPECONT (Code) 0x352A -#define LINETYPEINITOFFSET (Code) 0x352B -#define TEXTSCORETYPE (Code) 0x352C -#define RESTTEXTTYPE (Code) 0x352D -#define INTERPINT (Code) 0x352E -#define EDGECAP (Code) 0x352F -#define EDGEJOIN (Code) 0x362D -#define EDGETYPECONT (Code) 0x362E -#define EDGETYPEINITOFFSET (Code) 0x362F -#define SYMBOLLIBINDEX (Code) 0x3633 -#define SYMBOLCOLR (Code) 0x3634 -#define SYMBOLSIZE (Code) 0x3635 -#define SYMBOLORI (Code) 0x3636 - -#endif /* Version 3 */ - -#endif /* Version 2 */ - -#endif /* end of cgmelem.h */ diff --git a/src/CGM/cgmerr.h b/src/CGM/cgmerr.h deleted file mode 100755 index 0c0da7e802..0000000000 --- a/src/CGM/cgmerr.h +++ /dev/null @@ -1,340 +0,0 @@ -/* - Copyright (c) 1999-2012 OPEN CASCADE SAS - - The content of this file is subject to the Open CASCADE Technology Public - License Version 6.5 (the "License"). You may not use the content of this file - except in compliance with the License. Please obtain a copy of the License - at http://www.opencascade.org and read it completely before using this file. - - The Initial Developer of the Original Code is Open CASCADE S.A.S., having its - main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. - - The Original Code and all software distributed under the License is - distributed on an "AS IS" basis, without warranty of any kind, and the - Initial Developer hereby disclaims all such warranties, including without - limitation, any warranties of merchantability, fitness for a particular - purpose or non-infringement. Please see the License for the specific terms - and conditions governing the rights and limitations under the License. - -*/ - -#ifndef CGMERR_H -#define CGMERR_H - -/* Include the files on which this is dependent. */ - -#include "cgmtypes.h" - -#ifdef CGMERR_C -#define Extern -#else -#define Extern extern -#endif - -#ifdef CGMINIT_H - FILE *cgmerr; -#else - extern FILE *cgmerr; -#endif - -/* Error function call */ -#ifdef PROTO - Extern int CGMerror ( char*, int, Enum, char*); -#else - Extern int CGMerror (); -#endif - -/* Get Error Count */ -#ifdef PROTO - Extern int CGMcounterr ( void ); -#else - Extern int CGMcounterr(); -#endif - -/* Macro to make life a little simpler */ - -#define CGMERROR (void) CGMerror - -/* Error categories */ - -#define WARNING (Enum) 1 -#define ERROR (Enum) 2 -#define FATAL (Enum) 3 - -/* Return Codes - (System Dependent) */ - -#ifndef RC_FILERR -#define RC_FILERR (Index) 28 -#endif -#ifndef RC_FATAL -#define RC_FATAL (Index) 99 -#endif -#define RC_NULL (Index) 0 - -/* Error codes */ - -#define ERR_NOTFOUND -1 -#define ERR_MANYERR 100 -#define ERR_APNDTXT 101 -#define ERR_BIGCELL 102 -#define ERR_BIGEDGES 103 -#define ERR_BIGINTS 104 -#define ERR_BIGPATT 105 -#define ERR_BIGPOINTS 106 -#define ERR_BIGSTR 107 -#define ERR_DIRCELL 108 -#define ERR_DIRPATT 109 -#define ERR_ELEMENT 110 -#define ERR_ENCODING 111 -#define ERR_EOF 112 -#define ERR_FEWPNTS 113 -#define ERR_FONTFILE 114 -#define ERR_INTCHR 115 -#define ERR_INVATT 116 -#define ERR_INVCOLR 117 -#define ERR_INVCONT 118 -#define ERR_INVDELIM 119 -#define ERR_INVELEM 120 -#define ERR_INVENUM 121 -#define ERR_INVESC 122 -#define ERR_INVMFDESC 123 -#define ERR_INVOPCODE 124 -#define ERR_INVOUT 125 -#define ERR_INVPDESC 126 -#define ERR_INVPRIM 127 -#define ERR_MAXCOLR 128 -#define ERR_MENUFONT 129 -#define ERR_MFOPEN 130 -#define ERR_NOBACKSP 131 -#define ERR_NOCLT 132 -#define ERR_NOCODE 133 -#define ERR_NOFONT 134 -#define ERR_NOGDP 135 -#define ERR_NOMEMORY 136 -#define ERR_NOTAPNDTXT 137 -#define ERR_NOTCGM 138 -#define ERR_NOTERM 139 -#define ERR_OPENFILE 140 -#define ERR_PATINDEX 141 -#define ERR_PATTABLE 142 -#define ERR_PICOPEN 143 -#define ERR_REDIRECT 144 -#define ERR_SEEKEOF 145 -#define ERR_VERSION 146 -#define ERR_DIRCOL 147 -#define ERR_HUFFMAN 148 -#define ERR_STATE 149 -#define ERR_NAME2LONG 150 -#define ERR_INVARG 151 -#define ERR_INVASF 152 -#define ERR_RALGKS111 153 -#define ERR_NOENDPIC 154 -#define ERR_NODRIVER 155 -#define ERR_RANDOM 156 -#define ERR_INVOPT 157 -#define ERR_NOFILE 158 -#define ERR_CELL2SMALL 159 -#define ERR_ELMNOTSUP 160 -#define ERR_BADPENDEF 161 -#define ERR_PICLGRPAP 162 -#define ERR_GDIFAIL 163 - -/* General font system messages */ - -#define ERR_NOCSETS 200 -#define ERR_BADCSETS 201 -#define ERR_NOFAMS 202 -#define ERR_BADFAMS 203 -#define ERR_NOFAMSYN 204 -#define ERR_BADFAMSYN 205 -#define ERR_NODSN 206 -#define ERR_BADDSN 207 -#define ERR_CSETRANGE 208 -#define ERR_CSETUNKNOWN 209 -#define ERR_FONTRANGE 210 -#define ERR_METHOD 211 -#define ERR_NOMETHODS 212 -#define ERR_METHRANGE 213 -#define ERR_NOREQFONTS 214 -#define ERR_PACKMISSING 215 -#define ERR_NOFMATCH 216 -#define ERR_NOFSETS 217 -#define ERR_BADFSETS 218 -#define ERR_XSFPERM 219 -#define ERR_XSISOCSETS 220 -#define ERR_XSISOFONTS 221 -#define ERR_XSFAMILY 222 -#define ERR_XSALIAS 223 -#define ERR_XSDESIGN 224 -#define ERR_XSSOURCE 225 -#define ERR_XSSFONTS 226 -#define ERR_XSRFONTS 227 -#define ERR_NOFNTSPACE 228 -#define ERR_XFONTLIST 229 -#define ERR_XOPENDISP 230 - -/* Bezier font system messages */ - -#define ERR_BEZDIR 250 -#define ERR_BEZDBAD 251 -#define ERR_NOFONTS 252 -#define ERR_BEZOPEN 253 -#define ERR_BEZNODEF 254 -#define ERR_DBUNAV 255 -#define ERR_NPCINSTR 256 -#define ERR_FNTNOTSUP 257 -#define ERR_CURVE2BIG 258 -#define ERR_FNTNOTOPEN 259 -#define ERR_COMPZERO 260 -#define ERR_FILCOR 261 - -/* Text and PostScript system messages */ - -#define ERR_NOPROLG 300 -#define ERR_NOALIAS 301 -#define ERR_TXTSYSNFND 302 -#define ERR_2MANYFILES 303 -#define ERR_CHBASEZERO 304 -#define ERR_CHUPZERO 305 - -/* Polygon and Polygon Set messages */ - -#define ERR_NOMEMPSL 400 -#define ERR_BADEDGETAB 401 - -#undef Extern - -#ifdef CGMERR_C - -struct errmessage{ - int number; - Index rc; - char *mess; -}; - -struct errmessage cgmerrs[] = -{ - - ERR_2MANYFILES, RC_FATAL, "Too many metafiles in input file.", - ERR_APNDTXT, RC_NULL, "Append Text in wrong state", - ERR_BADCSETS, RC_NULL, "Character set file corrupt", - ERR_BADDSN, RC_NULL, "Design group file corrupt", - ERR_BADEDGETAB, RC_NULL, "Edge table corrupt", - ERR_BADFAMS, RC_NULL, "Font file corrupt", - ERR_BADFAMSYN, RC_NULL, "Font alias file corrupt", - ERR_BADFSETS, RC_NULL, "Fudge character set definition file corrupt", - ERR_BEZDBAD, RC_NULL, " ", - ERR_DBUNAV, RC_NULL, "Font database unavailable", - ERR_BEZDIR, RC_NULL, " ", - ERR_FILCOR, RC_NULL, "Bezier file corrupt", - ERR_BEZNODEF, RC_NULL, "No defined characters in font", - ERR_NOFONTS, RC_NULL, "No fonts in directory", - ERR_BEZOPEN, RC_NULL, " ", - ERR_BIGCELL, RC_NULL, "Cell Array too big", - ERR_BIGEDGES, RC_NULL, "Too many edges", - ERR_BIGINTS, RC_NULL, "Too many intersections", - ERR_BIGPATT, RC_NULL, "Patterns size too large", - ERR_BIGPOINTS, RC_NULL, "Too many points", - ERR_BIGSTR, RC_NULL, "String too long", - ERR_COMPZERO, RC_NULL, "Both character components are zero", - ERR_CSETRANGE, RC_NULL, "Character set index out of range", - ERR_CSETUNKNOWN, RC_NULL, "Character set index unknown", - ERR_CHBASEZERO, RC_NULL, "Character base vector zero", - ERR_CHUPZERO, RC_NULL, "Character up vector zero", - ERR_CURVE2BIG, RC_NULL, "Expanded curve too big for system", - ERR_DIRCELL, RC_NULL, "Direct Colour Cell arrays not supported", - ERR_DIRCOL, RC_FATAL, "Direct Colour not supported", - ERR_DIRPATT, RC_NULL, "Direct Colour Patterns not supported", - ERR_ELEMENT, RC_NULL, "Unknown Element", - ERR_ENCODING, RC_FATAL, "Unknown CGM encoding", - ERR_EOF, RC_NULL, "End of File reached", - ERR_FEWPNTS, RC_NULL, "Too few points", - ERR_FNTNOTOPEN, RC_NULL, "Font file could not be opened", - ERR_FNTNOTSUP, RC_NULL, "Font not supported", - ERR_FONTFILE, RC_NULL, "Supported fonts file invalid", - ERR_FONTRANGE, RC_NULL, "Font index outside CGM fontlist range", - ERR_GDIFAIL, RC_NULL, "Windows GDI function failed:", - ERR_HUFFMAN, RC_NULL, "Huffman points list not supported", - ERR_INTCHR, RC_NULL, "Invalid character in integer", - ERR_INVARG, RC_NULL, "Invalid argument", - ERR_INVASF, RC_NULL, "Invalid Aspect Source flag", - ERR_INVATT, RC_NULL, "Invalid Attribute", - ERR_INVCOLR, RC_NULL, "Invalid color type", - ERR_INVCONT, RC_NULL, "Invalid Control Element", - ERR_INVDELIM, RC_NULL, "Invalid Delimiter", - ERR_INVELEM, RC_NULL, "Invalid CGM Element", - ERR_INVENUM, RC_NULL, "Invalid Enumerated type", - ERR_INVESC, RC_NULL, "Invalid Escape Element", - ERR_INVMFDESC, RC_NULL, "Invalid Metafile Descriptor Element", - ERR_INVOPCODE, RC_NULL, "Invalid Opcode", - ERR_INVOPT, RC_NULL, "Invalid Option", - ERR_INVOUT, RC_NULL, "Invalid Output Element", - ERR_INVPDESC, RC_NULL, "Invalid Picture Descriptor Element", - ERR_INVPRIM, RC_NULL, "Invalid Graphics Primitive", - ERR_MANYERR, RC_FATAL, "Too many errors", - ERR_MAXCOLR, RC_NULL, "Maximum Colour Index Exceeded,", - ERR_MENUFONT, RC_NULL, "Menu font not supported", - ERR_METHOD, RC_NULL, "Text method outside allowed range", - ERR_METHRANGE, RC_NULL, "Text method outside allowed range", - ERR_MFOPEN, RC_NULL, "Metafile already open", - ERR_NAME2LONG, RC_NULL, "Illegal length in filename", - ERR_NOALIAS, RC_NULL, "No alias found in file alias.psd for font", - ERR_NOBACKSP, RC_NULL, "This input file cannot move backwards", - ERR_NOCLT, RC_NULL, "File is not a clear text metafile" , - ERR_NOCODE, RC_FATAL, "Unknown Output Code", - ERR_NOCSETS, RC_NULL, "Character set file not opened", - ERR_NODRIVER, RC_FATAL, "Output driver not supported", - ERR_NODSN, RC_NULL, "Design group file not opened", - ERR_NOENDPIC, RC_NULL, "Missing ENDPIC", - ERR_NOFAMS, RC_NULL, "Font file not opened", - ERR_NOFAMSYN, RC_NULL, "Font alias file not opened", - ERR_NOFMATCH, RC_NULL, "No trace of requested font found", - ERR_NOFNTSPACE, RC_NULL, "No free memory for font system element", - ERR_NOFONT, RC_NULL, "Unable to obtain fontlist from X server", - ERR_NOFILE, RC_FATAL, "No file name specified", - ERR_CELL2SMALL, RC_NULL, "Cell array cells to small for this device", - ERR_ELMNOTSUP, RC_NULL, "Element not supported", - ERR_BADPENDEF, RC_NULL, "Bad HPGL pen definition", - ERR_PICLGRPAP, RC_FATAL, "Metric picture larger than page", - ERR_NOFSETS, RC_NULL, "Fudge character set definition file not opened", - ERR_NOGDP, RC_NULL, "Unknown GDP", - ERR_NOMEMORY, RC_FATAL, "Out of memory", - ERR_NOMEMPSL, RC_NULL, "Out of memory for Polygon Section List", - ERR_NOMETHODS, RC_NULL, "No text emulation methods supplied", - ERR_NOPROLG, RC_NULL, "PostScript prologue file not found", - ERR_NOREQFONTS, RC_NULL, "Cannot open requestable fonts list", - ERR_NOTAPNDTXT, RC_NULL, "Text not allowed in Append Text State", - ERR_NOTCGM, RC_FATAL, "Not a recognisable CGM", - ERR_NOTERM, RC_NULL, "Terminal address must be specified", - ERR_NPCINSTR, RC_NULL, "Non-printable character in string:", - ERR_OPENFILE, RC_FILERR, "Cannot open file", - ERR_PACKMISSING, RC_NULL, "Fonts specified but not found for package", - ERR_PATINDEX, RC_NULL, "Pattern Index too high", - ERR_PATTABLE, RC_NULL, "Pattern Table Full", - ERR_PICOPEN, RC_NULL, "Picture already open", - ERR_RALGKS111, RC_NULL, "RAL-GKS 1.11 CGM has invalid structure", - ERR_RANDOM, RC_FATAL, "Random frame access structure uninitialised", - ERR_REDIRECT, RC_FILERR, "Redirected input invalid for this encoding", - ERR_SEEKEOF, RC_NULL, "Seeking past end of file", - ERR_STATE, RC_NULL, "Element in wrong CGM state", - ERR_TXTSYSNFND, RC_NULL, "Did not find a valid text system", - ERR_VERSION, RC_FATAL, "Wrong Version number", - ERR_XFONTLIST, RC_NULL, "Inconsistency in X font list string", - ERR_XSALIAS, RC_NULL, "Too many aliases", - ERR_XSDESIGN, RC_NULL, "Too many design codes", - ERR_XSFAMILY, RC_NULL, "Too many type families", - ERR_XSFPERM, RC_NULL, "Too many fonts per implementation method for", - ERR_XSISOCSETS, RC_NULL, "Too many ISO character sets", - ERR_XSISOFONTS, RC_NULL, "Too many ISO fonts", - ERR_XOPENDISP, RC_FATAL, "Cannot open display", - ERR_XSRFONTS, RC_NULL, "Too many requestable fonts", - ERR_XSSFONTS, RC_NULL, "Too many special fonts", - ERR_XSSOURCE, RC_NULL, "Too many source codes", - -/* NOTE: This code must be last */ - - ERR_NOTFOUND, RC_NULL, "Unknown error message" -}; -#endif /* end of CGMERR_C */ - -#endif /* end of cgmerr.h */ diff --git a/src/CGM/cgminit.h b/src/CGM/cgminit.h deleted file mode 100755 index 861c5489de..0000000000 --- a/src/CGM/cgminit.h +++ /dev/null @@ -1,581 +0,0 @@ -/* - Copyright (c) 1999-2012 OPEN CASCADE SAS - - The content of this file is subject to the Open CASCADE Technology Public - License Version 6.5 (the "License"). You may not use the content of this file - except in compliance with the License. Please obtain a copy of the License - at http://www.opencascade.org and read it completely before using this file. - - The Initial Developer of the Original Code is Open CASCADE S.A.S., having its - main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. - - The Original Code and all software distributed under the License is - distributed on an "AS IS" basis, without warranty of any kind, and the - Initial Developer hereby disclaims all such warranties, including without - limitation, any warranties of merchantability, fitness for a particular - purpose or non-infringement. Please see the License for the specific terms - and conditions governing the rights and limitations under the License. - -*/ - -#ifndef CGMINIT_H -#define CGMINIT_H - -/* Include all files on which this is dependent. */ - -#include "cgmmach.h" -#include "cgmtypes.h" -#include "cgmpar.h" -#include "cgmelem.h" -#include "cgmstruc.h" -#include "cgmerr.h" - -/* All default values set within the control program */ -/* with Character encoding defaults */ - - -/* Initialise flags */ - - Enum cgmstate = MF_CLOSED; /* Initial CGM State */ - - Logical cgmterm = FALSE; /* Flag set for input from stdin */ - - Logical cgmEOF = FALSE; /* End of File flag is OFF */ - - Logical cgmfinished = FALSE ; /* Interpreter finished flag */ - -/* Default string start and terminator */ - - Code st_start = 0x1b58, st_term = 0x1b5c; - -/* Driver names */ - -struct cgmdrivers { - char *name; /* Name or abreviation */ - int chrs; /* Minimum number of characters to match */ - Enum type; /* Output driver */ -}; - -/* Arrays for decoding Clear Text elements */ - -const struct commands cgmelement[] = { - -/* Graphics primitives */ - - {0x20, "LINE"}, {0x20, "INCRLINE"}, - {0x21, "DISJTLINE"}, {0x21, "INCRDISJTLINE"}, - {0x22, "MARKER"}, {0x22, "INCRMARKER"}, - {0x23, "TEXT"}, - {0x24, "RESTRTEXT"}, - {0x25, "APNDTEXT"}, - {0x26, "POLYGON"}, {0x26, "INCRPOLYGON"}, - {0x27, "POLYGONSET"}, {0x27, "INCRPOLYGONSET"}, - {0x28, "CELLARRAY"}, - {0x29, "GDP"}, - {0x2A, "RECT"}, - - {0x3420, "CIRCLE"}, - {0x3421, "ARC3PT"}, - {0x3422, "ARC3PTCLOSE"}, - {0x3423, "ARCCTR"}, - {0x3424, "ARCCTRCLOSE"}, - {0x3425, "ELLIPSE"}, - {0x3426, "ELLIPARC"}, - {0x3427, "ELLIPARCCLOSE"}, - -/* Attribute elements */ - - {0x3520, "LINEINDEX"}, - {0x3521, "LINETYPE"}, - {0x3522, "LINEWIDTH"}, - {0x3523, "LINECOLR"}, - {0x3524, "MARKERINDEX"}, - {0x3525, "MARKERTYPE"}, - {0x3526, "MARKERSIZE"}, - {0x3527, "MARKERCOLR"}, - - {0x3530, "TEXTINDEX"}, - {0x3531, "TEXTFONTINDEX"}, - {0x3532, "TEXTPREC"}, - {0x3533, "CHAREXPAN"}, - {0x3534, "CHARSPACE"}, - {0x3535, "TEXTCOLR"}, - {0x3536, "CHARHEIGHT"}, - {0x3537, "CHARORI"}, - {0x3538, "TEXTPATH"}, - {0x3539, "TEXTALIGN"}, - {0x353A, "CHARSETINDEX"}, - {0x353B, "ALTCHARSETINDEX"}, - - {0x3620, "FILLINDEX"}, - {0x3621, "INTSTYLE"}, - {0x3622, "FILLCOLR"}, - {0x3623, "HATCHINDEX"}, - {0x3624, "PATINDEX"}, - {0x3625, "EDGEINDEX"}, - {0x3626, "EDGETYPE"}, - {0x3627, "EDGEWIDTH"}, - {0x3628, "EDGECOLR"}, - {0x3629, "EDGEVIS"}, - - {0x362A, "FILLREFPT"}, - {0x362B, "PATTABLE"}, - {0x362C, "PATSIZE"}, - {0x3630, "COLRTABLE"}, - {0x3631, "ASF"}, - -/* Control elements */ - - {0x3320, "VDCINTEGERPREC"}, - {0x3321, "VDCREALPREC"}, - {0x3322, "AUXCOLR"}, - {0x3323, "TRANSPARENCY"}, - {0x3324, "CLIPRECT"}, - {0x3325, "CLIP"}, - -/* Metafile Control Elements */ - - {0x3020, "BEGMF"}, - {0x3021, "ENDMF"}, - {0x3022, "BEGPIC"}, - {0x3023, "BEGPICBODY"}, - {0x3024, "ENDPIC"}, - -/* Metafile Descriptor elements */ - - {0x3120, "MFVERSION"}, - {0x3121, "MFDESC"}, - {0x3122, "VDCTYPE"}, - {0x3123, "INTEGERPREC"}, - {0x3124, "REALPREC"}, - {0x3125, "INDEXPREC"}, - {0x3126, "COLRPREC"}, - {0x3127, "COLRINDEXPREC"}, - {0x3128, "MAXCOLRINDEX"}, - {0x3129, "COLRVALUEEXT"}, - {0x312A, "MFELEMLIST"}, - {0x312B, "BEGMFDEFAULTS"}, - {0x312C, "ENDMFDEFAULTS"}, - {0x312D, "FONTLIST"}, - {0x312E, "CHARSETLIST"}, - {0x312F, "CHARCODING"}, - -/* Picture descriptor elements */ - - {0x3220, "SCALEMODE"}, - {0x3221, "COLRMODE"}, - {0x3222, "LINEWIDTHMODE"}, - {0x3223, "MARKERSIZEMODE"}, - {0x3224, "EDGEWIDTHMODE"}, - {0x3225, "VDCEXT"}, - {0x3226, "BACKCOLR"}, - -/* Escape Elements */ - - {0x3720, "ESCAPE"}, - {0x3721, "MESSAGE"}, - {0x3722, "APPLDATA"}, - -/* Version 2 element names */ - -#if CGMVERSION > 1 - {0x3025, "BEGSEG"}, - {0x3026, "ENDSEG"}, - {0x3027, "BEGFIG"}, - {0x3028, "ENDFIG"}, - - {0x3029, "BEGGKSSESSIONMF"}, - {0x302A, "BEGGKSSESSION"}, - {0x302B, "ENDGKSSESSION"}, - - {0x3130, "NAMEPREC"}, - {0x3131, "MAXVDCEXT"}, - {0x3132, "SEGPRIEXT"}, - - {0x3227, "DEVVP"}, - {0x3228, "DEVVPMODE"}, - {0x3229, "DEVVPMAP"}, - {0x322A, "LINEREP"}, - {0x322B, "MARKERREP"}, - {0x322C, "TEXTREP"}, - {0x322D, "FILLREP"}, - {0x322E, "EDGEREP"}, - - {0x3326, "LINECLIPMODE"}, - {0x3327, "MARKERCLIPMODE"}, - {0x3328, "EDGECLIPMODE"}, - {0x3329, "NEWREGION"}, - {0x332A, "SAVEPRIMCONT"}, - {0x332B, "RESPRIMCONT"}, - - {0x332C, "WSVP"}, - {0x332D, "CLEAR"}, - {0x332E, "UPD"}, - {0x332F, "DEFERST"}, - - {0x3428, "ARCCTRREV"}, - {0x3429, "CONNEDGE"}, - - {0x3632, "PICKID"}, - - {0x3820, "COPYSEG"}, - {0x3821, "INHFILTER"}, - {0x3822, "CLIPINH"}, - {0x3823, "SEGTRANS"}, - {0x3824, "SEGHIGHLIGHT"}, - {0x3825, "SEGDISPPRI"}, - {0x3826, "SEGPICKPRI"}, - - {0x3827, "DELSEG"}, - {0x3828, "RENAMESEG"}, - {0x3829, "REDRAWALLSEG"}, - {0x382A, "SEGVIS"}, - {0x382B, "SEGDET"}, - -#if CGMVERSION > 2 - - {0x302C, "BEGPROTREGION"}, - {0x302D, "ENDPROTREGION"}, - {0x302E, "BEGCOMPOLINE"}, - {0x302F, "ENDCOMPOLINE"}, - {0x3030, "BEGCOMPOTEXTPATH"}, - {0x3031, "ENDCOMPOTEXTPATH"}, - {0x3032, "BEGTILEARRAY"}, - {0x3033, "ENDTILEARRAY"}, - - {0x3133, "COLRMODEL"}, - {0x3134, "COLRCALIB"}, - {0x3135, "FONTPROP"}, - {0x3136, "GLYPHMAP"}, - {0x3137, "SYMBOLLIBLIST"}, - - {0x322F, "INTSTYLEMODE"}, - {0x3230, "LINEEDGETYPEDEF"}, - {0x3231, "HATCHSTYLEDEF"}, - {0x3232, "GEOPATDEF"}, - - {0x3330, "PROTREGION"}, - {0x3331, "GENTEXTPATHMODE"}, - {0x3332, "MITRELLIMIT"}, - {0x3333, "TRANSPCELLCOLR"}, - - {0x342A, "HYPERBARC"}, - {0x342B, "PARABARC"}, - {0x342C, "NUB"}, - {0x342D, "NURB"}, - {0x342E, "POLYBEZIER"}, - {0x342F, "SYMBOL"}, {0x342F, "INCRSYMBOL"}, - {0x3430, "BITONALTILE"}, - {0x3431, "TILE"}, - - {0x3528, "LINECAP"}, - {0x3529, "LINEJOIN"}, - {0x352A, "LINETYPECONT"}, - {0x352B, "LINETYPEINITOFFSET"}, - {0x352C, "TEXTSCORETYPE"}, - {0x352D, "RESTTEXTTYPE"}, - {0x352E, "INTERPINT"}, - {0x352F, "EDGECAP"}, - {0x362D, "EDGEJOIN"}, - {0x362E, "EDGETYPECONT"}, - {0x362F, "EDGETYPEINITOFFSET"}, - {0x3633, "SYMBOLLIBINDEX"}, - {0x3634, "SYMBOLCOLR"}, - {0x3635, "SYMBOLSIZE"}, - {0x3636, "SYMBOLORI"}, - -#endif -#endif - -/* MFelemlist special names */ - - {0x10, "DRAWINGSET"}, - {0x11, "DRAWINGPLUS"}, -#if CGMVERSION > 1 - {0x12, "VERSION2"}, - {0x13, "EXTDPRIM"}, - {0x14, "VERSION2GKSM"}, -#if CGMVERSION > 2 - {0x15, "VERSION3"}, -#endif -#endif - {EOF, "EOF"} - }; - - -/* Metafile Default settings */ - - const struct char_defaults chardef = { - 10, /* integer prec */ - 10, /* index prec*/ - 20, /* vdc integer prec */ - {10, -10, -10, 1}, /* real precision */ - {10, -10, -10, 1}, /* vdc real precision */ - 6, /* colour prec */ - 10, /* colour index prec */ - {0, 0, 0, 0}, /* minimum colour extent */ - {1, 63, 63, 63}, /* maximum colour extent */ - 0, 1, 1 /* ring parameters for DCC (Huffman codes) */ - }; - struct char_defaults mfchar, mfichar, curichar, curchar, oldchar; - - const struct text_defaults textdef = { - -32767, /* min integer */ - 32767, /* max integer */ - 0, /* min index */ - 127, /* max index */ - -32767.0F, /* min real */ - 32767.0F, /* max real */ - 4, /* digits */ - {-32767, 0.0F}, /* min VDC (int, real) */ - { 32767, 1.0F}, /* max VDC (int, real) */ - 4, /* digits */ - 127, /* colour index*/ - 255, /* colour precision*/ - {0, 0, 0, 0}, /* minimum colour value extent */ - {1, 255, 255, 255} /* maximum colour value extent */ - }; - struct text_defaults mftext, mfitext, curitext, curtext; - - const struct bin_defaults bindef = { - 16, /* integer prec */ - 16, /* index prec */ - 16, /* vdc integer prec */ - 1, /* real type */ - 1, /* vdc type */ - 16, /* real whole */ - 16, /* real fraction */ - 16, /* vdc real whole */ - 16, /* vdc real fraction */ - 8, /* colour prec */ - 8, /* colour index prec */ - {0, 0, 0, 0}, /* minimum colour value extent */ - {1, 255, 255, 255} /* maximum colour value extent */ - }; - struct bin_defaults mfbin, mfibin, curibin, curbin; - - const struct defaults commondef = { - 63, /* max colour index */ - REAL, /* VDC type */ - ON, /* clip indicator */ - ON, /* transparency */ - INDEXED, /* colour mode */ - ABSTRACT, /* scale mode */ - 1.0F, /* scale factor */ - SCALED, /* line width mode */ - SCALED, /* marker size mode */ - SCALED, /* edge width mode */ - {0, 0, 0, 0}, /* background colour */ - {0, 0, 0, 0}, /* auxilary colour (device dependent) */ - {{{0, 0.0F}, {0, 0.0F}}, /* vdc extent - bottom left */ - {{32767, 1.0F}, {32767, 1.0F}}}, /* top right */ - {{{0, 0.0F}, {0, 0.0F}}, /* clip rectangle - bottom left */ - {{32767, 1.0F}, {32767, 1.0F}}}, /* top right */ - -/* set precisions to character defaults */ - 10, /* int prec */ - 10, /* index prec */ - 10, /* vdcint prec */ - 10, /* real prec */ - -10, /* real bits */ - 10, /* vdc prec */ - -10, /* vdc bits */ - 6, /* col_prec */ - 10, /* colind_prec */ - -32767.0F, /* min_real */ - 32767.0F, /* max_real */ - 0.00015F, /* realmin */ - 0.0F, /* min_vdc */ - 1.0F, /* max_vdc */ - 0.00015F, /* vdcmin */ - -10, 1, /* Real default exp and exponent allowed */ - -10, 1, /* VDC default exp and exponent allowed */ - {0, 0, 0, 0}, /* min_rgb */ - {1, 255,255,255}, /* max_rgb */ - FALSE, FALSE /* Colour prec & value extent not yet set */ - }; - -/* also use structure for picture defaults and current settings */ - - struct defaults mf, cur, old; - -/* Hold current attributes seperately */ - - const struct attributes defatt = { - 1, /* line index */ - 1, /* marker index */ - 1, /* text index*/ - 1, /* fill Index */ - 1, /* edge index */ - 1, /* line type */ - 3, /* marker type */ - 1, /* text font */ - 1, /* edge type */ - {33, 1.0F}, /* line width */ - {327, 1.0F}, /* marker size */ - {33, 1.0F}, /* edge width */ - {1, 1,1,1}, /* line colour */ - {1, 1,1,1}, /* marker colour */ - {1, 1,1,1}, /* text colour */ - {1, 1,1,1}, /* fill colour */ - {1, 1,1,1}, /* edge colour */ - 0, /* text prec */ - 0, /* text path */ - 0, /* horiz alignment */ - 0, /* vertical alignment */ - OFF, /* edge vis */ - 1.0F, /* continuous horiz alignment */ - 1.0F, /* continuous vertical alignment */ - 1, /* character set */ - 1, /* alt character set */ - 1.0F, /* character expansion */ - 0.0F, /* character space */ - {{0, 0.0F}, {1, 1.0F}}, /* character up vector*/ - {{1, 1.0F}, {0, 0.0F}}, /* character base vector */ - {327, 0.01F}, /* character height */ - 0, /* interior style */ - 1, /* hatch index */ - 1, /* pattern index */ - {{0, 0.0F}, {0, 0.0F}}, /* fill Reference point */ - {{{0, 0.0F}, {1, 1.0F}}, /* pattern size - height */ - {{1, 1.0F}, {0, 0.0F}}}, /* width */ - {0, 0, 0, /* Aspect source flags - line (all individual) */ - 0, 0, 0, /* marker */ - 0, 0, 0, 0, 0, /* text */ - 0, 0, 0, 0, /* fill */ - 0, 0, 0}, /* edge */ - FALSE, FALSE, FALSE, FALSE, FALSE /* VDC dependent flag settings */ - }; - struct attributes mfatt, curatt, oldatt; - -/* Flags for changes to attributes - initially set to false */ - - struct flags att; - - - -/* Set default values for common flags */ - - Int cgmerrcount = ERROR_MAX; /* USE error count limit by default */ - - Logical cgmralgks = DEFRALGKSGDP; /* Use RAL-GKS GDPs */ - - Logical cgmralbin = FALSE; /* Old version of RALCGM Binary CGM */ - - Logical cgmverbose = DEFVERBOSE; /* Verbose output */ - - Logical cgmquiet = DEFQUIET; /* Quiet output */ - -/* Clear text listing */ - - Logical cgmlist = FALSE; - - -/* Structures for Font list and Character set */ - - struct cgmfont cgmfonts; - struct cgmcset cgmcsets; - -/* Null pointer for function calls - to fool LINT */ - - long *null = NULL; - -/* Default colour table */ - - const RGBcolour GKScol[256] = { - -/* GKS default colours */ - - {0, 0, 0}, /* Background - Black */ - {255, 255, 255}, /* Foreground - White */ - {255, 0, 0}, /* Red */ - {0, 255, 0}, /* Green */ - {0, 0, 255}, /* Blue */ - {255, 255, 0}, /* Yellow */ - {0, 255, 255}, /* Cyan */ - {255, 0, 255}, /* Magenta */ - - /* 8 Grey scales ( White to Black ) */ - - {255, 255, 255}, {177, 177, 177}, {158, 158, 158}, {128, 128, 128}, - {100, 100, 100}, { 78, 78, 78}, { 64, 64, 64}, { 0, 0, 0}, - - /* GKS colour maps from Versatec 16 - 255 */ - - {98, 192, 255}, {139, 122, 255}, { 92, 70, 255}, { 51, 0, 243}, - {28, 0, 133}, { 20, 0, 93}, { 14, 0, 65}, { 11, 0, 56}, - {9, 0, 46}, {128, 138, 255}, { 85, 85, 255}, { 0, 0, 255}, - {0, 0, 168}, { 0, 13, 116}, { 0, 8, 76}, { 0, 8, 68}, - - {122, 139, 255}, { 80, 93, 255}, { 0, 59, 252}, { 0, 39, 168}, - {0, 28, 122}, { 0, 18, 80}, { 0, 16, 70}, { 122, 149, 255}, - {70, 108, 255}, { 0, 83, 230}, { 0, 61, 175}, { 0, 44, 128}, - {0, 29, 85}, { 0, 26, 74}, { 116, 154, 255}, { 59, 118, 255}, - - {0, 97, 219}, { 0, 77, 182}, { 0, 56, 133}, { 0, 37, 89}, - {0, 33, 79}, {110, 159, 255}, { 43, 131, 255}, { 0, 112, 225}, - {0, 92, 186}, { 0, 68, 138}, { 0, 46, 93}, { 0, 40, 80}, - {177, 213, 255}, {104, 173, 255}, { 0, 151, 250}, { 0, 136, 225}, - - {0, 120, 198}, { 0, 89, 147}, { 0, 59, 97}, { 0, 52, 86}, - {0, 43, 70}, { 0, 186, 186}, { 0, 160, 147}, { 0, 142, 129}, - {0, 121, 106}, { 0, 89, 78}, { 0, 62, 55}, { 0, 53, 46}, - {0, 192, 160}, { 0, 160, 123}, { 0, 138, 105}, { 0, 119, 91}, - - {0, 89, 68}, { 0, 59, 44}, { 0, 53, 40}, { 0, 243, 169}, - {0, 192, 134}, { 0, 160, 113}, { 0, 138, 97}, { 0, 118, 83}, - {0, 89, 63}, { 0, 59, 41}, { 0, 51, 36}, { 0, 43, 30}, - {0, 216, 115}, { 0, 175, 113}, { 0, 151, 102}, { 0, 138, 91}, - - {0, 104, 68}, { 0, 70, 46}, { 0, 61, 40}, { 0, 230, 74}, - {0, 189, 110}, { 0, 171, 100}, { 0, 156, 92}, { 0, 116, 69}, - {0, 80, 47}, { 0, 56, 33}, { 105, 238, 0}, { 0, 216, 46}, - {0, 202, 65}, { 0, 189, 71}, { 0, 142, 53}, { 0, 97, 36}, - - {0, 83, 31}, {161, 240, 0}, { 99, 225, 0}, { 120, 219, 0}, - {92, 208, 0}, { 69, 156, 0}, { 46, 104, 0}, { 41, 93, 0}, - {197, 243, 0}, {172, 232, 0}, { 168, 227, 0}, { 160, 219, 0}, - {122, 168, 0}, { 80, 110, 0}, { 70, 97, 0}, { 255, 251, 175}, - - {255, 250, 110}, {255, 249, 70}, { 254, 248, 0}, { 253, 245, 0}, - {189, 183, 0}, {128, 124, 0}, { 113, 110, 0}, { 89, 86, 0}, - {255, 209, 116}, {255, 194, 97}, { 255, 191, 85}, { 255, 177, 65}, - {195, 136, 0}, {133, 92, 0}, { 116, 81, 0}, { 255, 190, 119}, - - {255, 163, 104}, {255, 168, 89}, { 255, 160, 80}, { 195, 113, 0}, - {133, 77, 0}, {116, 67, 0}, { 255, 173, 122}, { 255, 154, 107}, - {255, 142, 89}, {255, 112, 0}, { 195, 86, 0}, { 128, 56, 0}, - {113, 50, 0}, {255, 162, 122}, { 255, 125, 104}, { 255, 100, 65}, - - {247, 80, 0}, {186, 60, 0}, { 122, 39, 0}, { 110, 35, 0}, - {255, 147, 124}, {255, 98, 89}, { 255, 56, 43}, { 238, 44, 0}, - {182, 34, 0}, {122, 22, 0}, { 104, 19, 0}, { 255, 168, 170}, - {255, 122, 128}, {255, 70, 80}, { 250, 0, 38}, { 225, 0, 35}, - - {168, 0, 26}, {110, 0, 17}, { 100, 0, 15}, { 80, 0, 12}, - {255, 122, 147}, {255, 70, 108}, { 247, 0, 83}, { 225, 0, 72}, - {168, 0, 54}, {110, 0, 35}, { 97, 0, 31}, { 255, 166, 197}, - {255, 110, 170}, {255, 43, 150}, { 232, 0, 134}, { 211, 0, 122}, - - {160, 0, 92}, {104, 0, 60}, { 93, 0, 54}, { 76, 0, 44}, - {255, 80, 204}, {227, 0, 189}, { 199, 0, 165}, { 168, 0, 142}, - {122, 0, 104}, { 85, 0, 72}, { 74, 0, 63}, { 255, 70, 225}, - {205, 0, 213}, {175, 0, 175}, { 141, 0, 147}, { 106, 0, 110}, - - {71, 0, 74}, { 62, 0, 65}, { 245, 43, 255}, { 193, 0, 227}, - {153, 0, 195}, {107, 0, 147}, { 80, 0, 110}, { 55, 0, 76}, - {47, 0, 65}, {216, 89, 255}, { 150, 43, 255}, { 118, 0, 216}, - {80, 0, 147}, { 59, 0, 107}, { 38, 0, 70}, { 35, 0, 64}, - - {187, 110, 255}, {122, 59, 255}, { 86, 0, 230}, { 55, 0, 147}, - {38, 0, 100}, { 25, 0, 68}, { 22, 0, 60}, { 177, 177, 177}, - {158, 158, 158}, {128, 128, 128}, { 100, 100, 100}, { 78, 78, 78}, - {0, 0, 0}, { 61, 50, 59}, { 52, 45, 62}, { 36, 61, 59}, - - {127, 118, 109}, { 91, 70, 72}, { 71, 57, 64}, { 79, 62, 64}, - {28, 33, 32}, { 34, 31, 36}, { 31, 0, 22}, { 252, 182, 142}, - {223, 145, 135}, {191, 133, 119}, { 155, 100, 94}, { 137, 94, 90}, - {64, 51, 53}, { 48, 41, 42}, { 255, 148, 116}, { 151, 96, 91} -}; - -#endif /* end of cgminit.h */ diff --git a/src/CGM/cgmlib.hxx b/src/CGM/cgmlib.hxx deleted file mode 100755 index e65e8d8737..0000000000 --- a/src/CGM/cgmlib.hxx +++ /dev/null @@ -1,944 +0,0 @@ -// Copyright (c) 1999-2012 OPEN CASCADE SAS -// -// The content of this file is subject to the Open CASCADE Technology Public -// License Version 6.5 (the "License"). You may not use the content of this file -// except in compliance with the License. Please obtain a copy of the License -// at http://www.opencascade.org and read it completely before using this file. -// -// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its -// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. -// -// The Original Code and all software distributed under the License is -// distributed on an "AS IS" basis, without warranty of any kind, and the -// Initial Developer hereby disclaims all such warranties, including without -// limitation, any warranties of merchantability, fitness for a particular -// purpose or non-infringement. Please see the License for the specific terms -// and conditions governing the rights and limitations under the License. - -#include -#include -#include - -#define ASFS 18 - -typedef short Logical; -typedef long Index; -typedef unsigned short Enum; -typedef short Code; -typedef long Prec; -typedef unsigned long Posint; -typedef float Ptype; -typedef double Mtype; - -/* Define anything that has not been explicitly set **************/ - -#ifndef SignChar -#define SignChar signed char -#endif -#ifndef Int16 -#define Int16 short -#endif -#ifndef Char -#define Char char -#endif -#ifndef Int -#define Int int -#endif -#ifndef Long -#define Long long -#endif -#ifndef Float -#define Float float -#endif -#ifndef Double -#define Double double -#endif - -/* Define real precision structure (character encoding) */ - -struct real_prec { - Prec prec, min, defexp, expald; -}; - -/* CGM element codes for clear text input and output */ -struct colour { - Index index; - Posint red, green, blue; -}; -typedef struct colour Colour; -struct vdc { - long intr; - float real; -}; -typedef struct vdc Vdc; -struct point { - struct vdc x, y; -}; -typedef struct point Cpoint; - -struct rect { - struct point a, b; -}; - -typedef struct { float left, right, top, bot; } Rect; - -struct colourentry { - float red, green, blue; -}; -typedef struct colourentry Colourentry; - -struct commands { - Code code; - const char *string; - }; - -/* Structures for metafile default elements */ - -/* Encoding Specific defaults */ - -struct char_defaults{ - Prec int_prec, index_prec, vdcint_prec; - struct real_prec real, vdc; - Prec col_prec, colind_prec; - struct colour min_rgb, max_rgb; - long ring_angres, ring_int, ring_real; -}; - -struct text_defaults{ - long min_int, max_int, min_index, max_index; - float min_real, max_real; - Prec real_digits; - struct vdc min_vdc, max_vdc; - Prec vdc_digits, colind_prec, col_prec; - struct colour min_rgb, max_rgb; -}; - -struct bin_defaults{ - Prec int_prec, index_prec, vdcint_prec; - Enum real_type, vdc_type; - Prec real_whole, real_fraction, vdc_whole, vdc_fraction; - Prec col_prec, colind_prec; - struct colour min_rgb, max_rgb; -}; - -struct defaults { - -/* Encoding independent defaults */ - - Index max_colind; - Enum vdc_type, transparency, clip_ind; - Enum color_mode, scale_mode; - float scale_factor; - Enum linewidth_mode, markersize_mode, edgewidth_mode; - struct colour back, aux; - struct rect vdc_extent, clip_rect; - -/* Retain encoding defaults for common access */ - - Prec int_bits, /* integer prec in bits */ - index_bits, /* index prec in bits */ - vdcint_bits, /* vdc integer precision in bits */ - real_bits, /* real prec in bits */ - real_places, /* binary bits after decimal place */ - vdc_bits, /* vdc prec in bits */ - vdc_places, /* binary bits after decimal place */ - col_bits, /* colour prec in bits */ - colind_bits; /* colour index prec in bits */ - float min_real, /* min real value */ - max_real, /* max real value */ - realmin, /* smallest real value */ - min_vdc, /* min real vdc value */ - max_vdc, /* max real vdc value */ - vdcmin; /* smallest vdc real value */ - Prec real_defexp, /* Real default exponent */ - real_expald, /* Real exponenet allowed */ - vdc_defexp, /* VDC default exponent */ - vdc_expald; /* VDC exponenet allowed */ - struct colour min_rgb, /* integer values: index/RGB */ - max_rgb; /* integer values: index/RGB */ - Logical colprec_flag, /* Flag to show if colour precision set */ - colval_flag; /* Flag to show if colour value extent set */ - }; - -/* Graphics attributes */ - -struct attributes { - Index line_ind, mark_ind, text_ind, fill_ind, edge_ind; - Index line_type, mark_type, text_font, edge_type; - struct vdc line_width, mark_size, edge_width; - struct colour line, marker, text, fill, edge; - Enum text_prec, text_path, text_halign, text_valign, edge_vis; - float text_hcont, text_vcont; - Index char_set, altchar_set; - float char_exp, char_space; - struct point char_up, char_base; - struct vdc char_height; - Enum int_style; - Index hatch_ind, pat_ind; - struct point fill_ref; - struct rect pat_size; - Enum asf[ASFS]; -/* Flags for VDC dependent defaults */ - Logical linewidth_flag, markersize_flag, edgewidth_flag, - charheight_flag, cliprect_flag; - }; - - -/* Structure for attribute change flags */ - -struct flags { - Logical line_index, line_type, line_width, line_color; - Logical mark_index, mark_type, mark_size, mark_color; - Logical text_index, text_font, text_prec, char_expan, char_space, - text_color, char_height, char_orient, char_set, - altchar_set, text_path, text_align; - Logical fill_index, int_style, hatch_ind, - pat_ind, pat_size, fill_color, fill_ref; - Logical edge_index, edge_type, edge_width, edge_color, edge_vis; -}; - - - -/* Non-Op */ - -#define NONOP (Code) 0 - -/* Character CGM hex values */ - -#define BEGMF (Code) 0x3020 -#define ENDMF (Code) 0x3021 -#define BEGPIC (Code) 0x3022 -#define BEGPICBODY (Code) 0x3023 -#define ENDPIC (Code) 0x3024 - -/* Metafile Descriptor elements */ - -#define MFVERSION (Code) 0x3120 -#define MFDESC (Code) 0x3121 -#define VDCTYPE (Code) 0x3122 -#define INTEGERPREC (Code) 0x3123 -#define REALPREC (Code) 0x3124 -#define INDEXPREC (Code) 0x3125 -#define COLRPREC (Code) 0x3126 -#define COLRINDEXPREC (Code) 0x3127 -#define MAXCOLRINDEX (Code) 0x3128 -#define COLRVALUEEXT (Code) 0x3129 -#define MFELEMLIST (Code) 0x312A -#define BEGMFDEFAULTS (Code) 0x312B -#define ENDMFDEFAULTS (Code) 0x312C -#define FONTLIST (Code) 0x312D -#define CHARSETLIST (Code) 0x312E -#define CHARCODING (Code) 0x312F - -/* Picture descriptor elements */ - -#define SCALEMODE (Code) 0x3220 -#define COLRMODE (Code) 0x3221 -#define LINEWIDTHMODE (Code) 0x3222 -#define MARKERSIZEMODE (Code) 0x3223 -#define EDGEWIDTHMODE (Code) 0x3224 -#define VDCEXT (Code) 0x3225 -#define BACKCOLR (Code) 0x3226 - -/* Control elements */ - -#define VDCINTEGERPREC (Code) 0x3320 -#define VDCREALPREC (Code) 0x3321 -#define AUXCOLR (Code) 0x3322 -#define TRANSPARENCY (Code) 0x3323 -#define CLIPRECT (Code) 0x3324 -#define CLIP (Code) 0x3325 - -/* Graphics primitives */ - -#define LINE (Code) 0x20 -#define DISJTLINE (Code) 0x21 -#define MARKER (Code) 0x22 -#define TEXT (Code) 0x23 -#define RESTRTEXT (Code) 0x24 -#define APNDTEXT (Code) 0x25 -#define POLYGON (Code) 0x26 -#define POLYGONSET (Code) 0x27 -#define CELLARRAY (Code) 0x28 -#define GDP (Code) 0x29 -#define RECT (Code) 0x2A - -#define CIRCLE (Code) 0x3420 -#define ARC3PT (Code) 0x3421 -#define ARC3PTCLOSE (Code) 0x3422 -#define ARCCTR (Code) 0x3423 -#define ARCCTRCLOSE (Code) 0x3424 -#define ELLIPSE (Code) 0x3425 -#define ELLIPARC (Code) 0x3426 -#define ELLIPARCCLOSE (Code) 0x3427 - -/* Attribute elements */ - -#define LINEINDEX (Code) 0x3520 -#define LINETYPE (Code) 0x3521 -#define LINEWIDTH (Code) 0x3522 -#define LINECOLR (Code) 0x3523 -#define MARKERINDEX (Code) 0x3524 -#define MARKERTYPE (Code) 0x3525 -#define MARKERSIZE (Code) 0x3526 -#define MARKERCOLR (Code) 0x3527 - -#define TEXTINDEX (Code) 0x3530 -#define TEXTFONTINDEX (Code) 0x3531 -#define TEXTPREC (Code) 0x3532 -#define CHAREXPAN (Code) 0x3533 -#define CHARSPACE (Code) 0x3534 -#define TEXTCOLR (Code) 0x3535 -#define CHARHEIGHT (Code) 0x3536 -#define CHARORI (Code) 0x3537 -#define TEXTPATH (Code) 0x3538 -#define TEXTALIGN (Code) 0x3539 -#define CHARSETINDEX (Code) 0x353A -#define ALTCHARSETINDEX (Code) 0x353B - -#define FILLINDEX (Code) 0x3620 -#define INTSTYLE (Code) 0x3621 -#define FILLCOLR (Code) 0x3622 -#define HATCHINDEX (Code) 0x3623 -#define PATINDEX (Code) 0x3624 -#define EDGEINDEX (Code) 0x3625 -#define EDGETYPE (Code) 0x3626 -#define EDGEWIDTH (Code) 0x3627 -#define EDGECOLR (Code) 0x3628 -#define EDGEVIS (Code) 0x3629 -#define FILLREFPT (Code) 0x362A -#define PATTABLE (Code) 0x362B -#define PATSIZE (Code) 0x362C - -#define COLRTABLE (Code) 0x3630 -#define ASF (Code) 0x3631 - -/* Escape Elements */ - -#define ESCAPE (Code) 0x3720 -#define MESSAGE (Code) 0x3721 -#define APPLDATA (Code) 0x3722 - -#define DOMAINRING (Code) 0x3730 - -/* Version 2 Elements - Addendum 1 */ - -#if CGMVERSION > 1 - -#define BEGSEG (Code) 0x3025 -#define ENDSEG (Code) 0x3026 -#define BEGFIG (Code) 0x3027 -#define ENDFIG (Code) 0x3028 - -#define NAMEPREC (Code) 0x3130 -#define MAXVDCEXT (Code) 0x3131 -#define SEGPRIEXT (Code) 0x3132 - -#define DEVVP (Code) 0x3227 -#define DEVVPMODE (Code) 0x3228 -#define DEVVPMAP (Code) 0x3229 -#define LINEREP (Code) 0x322A -#define MARKERREP (Code) 0x322B -#define TEXTREP (Code) 0x322C -#define FILLREP (Code) 0x322D -#define EDGEREP (Code) 0x322E - -#define LINECLIPMODE (Code) 0x3326 - -#define MARKERCLIPMODE (Code) 0x3327 - -#define EDGECLIPMODE (Code) 0x3328 - -#define NEWREGION (Code) 0x3329 -#define SAVEPRIMCONT (Code) 0x332A - -#define RESPRIMCONT (Code) 0x332B - -#define ARCCTRREV (Code) 0x3428 -#define CONNEDGE (Code) 0x3429 - -#define PICKID (Code) 0x3632 - -#define COPYSEG (Code) 0x3820 -#define INHFILTER (Code) 0x3821 -#define CLIPINH (Code) 0x3822 -#define SEGTRANS (Code) 0x3823 -#define SEGHIGHLIGHT (Code) 0x3824 - -#define SEGDISPPRI (Code) 0x3825 -#define SEGPICKPRI (Code) 0x3826 - -/* GKS Annex elements */ - -#define BEGGKSSESSIONMF (Code) 0x3029 -#define BEGGKSSESSION (Code) 0x302A -#define ENDGKSSESSION (Code) 0x302B - -#define WSVP (Code) 0x332C -#define CLEAR (Code) 0x332D -#define UPD (Code) 0x332E -#define DEFERST (Code) 0x332F - -#define DELSEG (Code) 0x3827 -#define RENAMESEG (Code) 0x3828 -#define REDRAWALLSEG (Code) 0x3829 -#define SEGVIS (Code) 0x382A -#define SEGDET (Code) 0x382B - -/* Version 3 Elements - Addendum 3 */ - -#if CGMVERSION > 2 - -#define BEGPROTREGION (Code) 0x302C -#define ENDPROTREGION (Code) 0x302D -#define BEGCOMPOLINE (Code) 0x302E -#define ENDCOMPOLINE (Code) 0x302F -#define BEGCOMPOTEXTPATH (Code) 0x3030 -#define ENDCOMPOTEXTPATH (Code) 0x3031 -#define BEGTILEARRAY (Code) 0x3032 -#define ENDTILEARRAY (Code) 0x3033 - -#define COLRMODEL (Code) 0x3133 -#define COLRCALIB (Code) 0x3134 -#define FONTPROP (Code) 0x3135 -#define GLYPHMAP (Code) 0x3136 -#define SYMBOLLIBLIST (Code) 0x3137 - -#define INTSTYLEMODE (Code) 0x322F -#define LINEEDGETYPEDEF (Code) 0x3230 -#define HATCHSTYLEDEF (Code) 0x3231 -#define GEOPATDEF (Code) 0x3232 - -#define PROTREGION (Code) 0x3330 -#define GENTEXTPATHMODE (Code) 0x3331 -#define MITRELLIMIT (Code) 0x3332 -#define TRANSPCELLCOLR (Code) 0x3333 - -#define HYPERBARC (Code) 0x342A -#define PARABARC (Code) 0x342B -#define NUB (Code) 0x342C -#define NURB (Code) 0x342D -#define POLYBEZIER (Code) 0x342E -#define SYMBOL (Code) 0x342F -#define INCRSYMBOL (Code) 0x342F -#define BITONALTILE (Code) 0x3430 -#define TILE (Code) 0x3431 - -#define LINECAP (Code) 0x3528 -#define LINEJOIN (Code) 0x3529 -#define LINETYPECONT (Code) 0x352A -#define LINETYPEINITOFFSET (Code) 0x352B -#define TEXTSCORETYPE (Code) 0x352C -#define RESTTEXTTYPE (Code) 0x352D -#define INTERPINT (Code) 0x352E -#define EDGECAP (Code) 0x352F -#define EDGEJOIN (Code) 0x362D -#define EDGETYPECONT (Code) 0x362E -#define EDGETYPEINITOFFSET (Code) 0x362F -#define SYMBOLLIBINDEX (Code) 0x3633 -#define SYMBOLCOLR (Code) 0x3634 -#define SYMBOLSIZE (Code) 0x3635 -#define SYMBOLORI (Code) 0x3636 - -#endif /* Version 3 */ - -#endif /* Version 2 */ - - - - -/* CGM Statelists */ - -#define MF_CLOSED (Enum) 0 -#define MF_DESC (Enum) 1 -#define MF_ELEMLIST (Enum) 2 -#define MF_DEFAULTS (Enum) 3 -#define PIC_DESC (Enum) 4 -#define PIC_OPEN (Enum) 5 -#define PIC_CLOSED (Enum) 6 -#define TEXT_OPEN (Enum) 7 - -/* CGM Enumerated types */ - -#define INTEGER (Enum) 0 -#define REAL (Enum) 1 - -#define ABSTRACT (Enum) 0 -#define METRIC (Enum) 1 - -#define INDEXED (Enum) 0 -#define DIRECT (Enum) 1 - -#define ABS (Enum) 0 -#define ABSOLUTE (Enum) 0 -#define SCALED (Enum) 1 - -#define INDIV (Enum) 0 -#define INDIVIDUAL (Enum) 0 -#define BUNDLED (Enum) 1 - -#define ALLOWED (Enum) 0 -#define FORBIDDEN (Enum) 1 - -#define OFF (Enum) 0 -#define ON (Enum) 1 - -#define NOACTION (Enum) 0 -#define ACTION (Enum) 1 - -/* Enumerated types for text precision */ -#define STRING (Enum) 0 -#define CHAR (Enum) 1 -#define STROKE (Enum) 2 - -/* Enumerated types for Text Path Values */ -#define P_RIGHT (Enum) 0 -#define P_LEFT (Enum) 1 -#define P_UP (Enum) 2 -#define UP (Enum) 2 -#define P_DOWN (Enum) 3 -#define DOWN (Enum) 3 - -/* Enumerated types for Text's Horziontal Alignment */ -#define NORMHORIZ (Enum) 0 -#define LEFT (Enum) 1 -#define CTR (Enum) 2 -#define RIGHT (Enum) 3 -#define CONTHORIZ (Enum) 4 - -/* Enumerated types for Text's Vertical Alignment */ -#define NORMVERT (Enum) 0 -#define TOP (Enum) 1 -#define CAP (Enum) 2 -#define HALF (Enum) 3 -#define BASE (Enum) 4 -#define BOTTOM (Enum) 5 -#define CONTVERT (Enum) 6 - -/* Final text flag */ -#define NOTFINAL (Enum) 0 -#define FINAL (Enum) 1 - -/* Interior styles */ -#define HOLLOW (Enum) 0 -#define SOLID (Enum) 1 -#define PAT (Enum) 2 -#define PATTERN (Enum) 2 -#define HATCH (Enum) 3 -#define EMPTY (Enum) 4 - -/* Closure types */ -#define PIE (Enum) 0 -#define CHORD (Enum) 1 -#define NOCLOSE (Enum) 2 - -/* Polygon set enumerated types */ - -#define EDGEVISIB (Enum) 1 -#define EDGECLOSE (Enum) 2 - -#define INVIS (Enum) 0 -#define VIS (Enum) 1 -#define CLOSEINVIS (EDGECLOSE + INVIS) -#define CLOSEVIS (EDGECLOSE + VIS) - -/* MF element list extra elements */ -#define DRAWINGSET (Enum) 0 -#define DRAWINGSETPLUS (Enum) 1 -#define VER2 (Enum) 2 -#define EXTPRIM (Enum) 3 -#define VER2GKSM (Enum) 4 - - -/* Character sets enumerated types */ -#define STD94 (Enum) 0 -#define STD96 (Enum) 1 -#define STD94MULTIBYTE (Enum) 2 -#define STD96MULTIBYTE (Enum) 3 -#define COMPLETECODE (Enum) 4 - -/* Character coding announcer enumerated types */ -#define BASIC7BIT (Enum) 0 -#define BASIC8BIT (Enum) 1 -#define EXTD7BIT (Enum) 2 -#define EXTD8BIT (Enum) 3 - -/* ASF settings */ - -#define ALL (Enum) 511 -#define ALLLINE (Enum) 510 -#define ALLMARKER (Enum) 509 -#define ALLTEXT (Enum) 508 -#define ALLFILL (Enum) 507 -#define ALLEDGE (Enum) 506 - -/* New Version 2 Enumerated types */ - -#define FRACTION (Enum) 0 -#define MM (Enum) 1 -#define PHYDEVUNITS (Enum) 2 - -#define FORCED (Enum) 0 -#define NOTFORCED (Enum) 2 - -#define LOCUS (Enum) 0 -#define SHAPE (Enum) 1 -#define LOCUSTHENSHAPE (Enum) 2 - -#define NO (Enum) 0 -#define YES (Enum) 1 - -#define STATELIST (Enum) 0 -#define SEGMENT (Enum) 1 -#define INTERSECTION (Enum) 1 - -#define NORMAL (Enum) 0 -#define HIGHLIGHT (Enum) 1 - -/* Element Group names in addition to normal elements */ - -#define LINEATTR (Enum) 35 -#define MARKERATTR (Enum) 36 -#define TEXTATTR (Enum) 37 -#define CHARATTR (Enum) 38 -#define FILLATTR (Enum) 39 -#define EDGEATTR (Enum) 40 -#define PATATTR (Enum) 41 -#define OUTPUTCTRL (Enum) 42 -#define ALLATTRCTRL (Enum) 44 -#define ALLINH (Enum) 45 -#define LINETYPEASF (Enum) 46 -#define LINEWIDTHASF (Enum) 47 -#define LINECOLRASF (Enum) 48 -#define MARKERTYPEASF (Enum) 49 -#define MARKERSIZEASF (Enum) 50 -#define MARKERCOLRASF (Enum) 51 -#define TEXTFONTINDEXASF (Enum) 52 -#define TEXTPRECASF (Enum) 53 -#define CHAREXPANASF (Enum) 54 -#define CHARSPACEASF (Enum) 55 -#define TEXTCOLRASF (Enum) 56 -#define INTSTYLEASF (Enum) 57 -#define FILLCOLRASF (Enum) 58 -#define HATCHINDEXASF (Enum) 59 -#define PATINDEXASF (Enum) 60 -#define EDGETYPEASF (Enum) 61 -#define EDGEWIDTHASF (Enum) 62 -#define EDGECOLRASF (Enum) 63 - -/* Useful local Parameters for enumerated types */ - -#define VDC (Enum) 0 - -#define MULTIPLE FALSE -#define SINGLE TRUE - -#define NOSET (Enum) 0 -#define SET (Enum) 1 - -#define NOP (Enum) 0 -#define NONE (Enum) 0 -#define ANY (Enum) 0 - -/* Mathematical quantities */ - -#ifndef ZERO -#define ZERO (Int) 0 -#endif - -#define LOG2 0.30103 -#define PARABIT 0x40 - - -/* All default values set within the control program */ -/* with Character encoding defaults */ - - -/* Initialise flags */ - -#ifndef AIX -#define FALSE (Enum) 0 -#define TRUE (Enum) 1 -#endif -/* - Enum cgmstate = MF_CLOSED; Initial CGM State - - Logical cgmterm = FALSE; Flag set for input from stdin - - Logical cgmEOF = FALSE; End of File flag is OFF - - Logical cgmfinished = FALSE ; Interpreter finished flag - - Default string start and terminator - - Code st_start = 0x1b58, st_term = 0x1b5c; - - - Arrays for coding and decoding Clear Text elements */ - -const struct commands cgmelement[] = { - -/* Graphics primitives */ - - {0x20, "LINE"}, {0x20, "INCRLINE"}, - {0x21, "DISJTLINE"}, {0x21, "INCRDISJTLINE"}, - {0x22, "MARKER"}, {0x22, "INCRMARKER"}, - {0x23, "TEXT"}, - {0x24, "RESTRTEXT"}, - {0x25, "APNDTEXT"}, - {0x26, "POLYGON"}, {0x26, "INCRPOLYGON"}, - {0x27, "POLYGONSET"}, {0x27, "INCRPOLYGONSET"}, - {0x28, "CELLARRAY"}, - {0x29, "GDP"}, - {0x2A, "RECT"}, - - {0x3420, "CIRCLE"}, - {0x3421, "ARC3PT"}, - {0x3422, "ARC3PTCLOSE"}, - {0x3423, "ARCCTR"}, - {0x3424, "ARCCTRCLOSE"}, - {0x3425, "ELLIPSE"}, - {0x3426, "ELLIPARC"}, - {0x3427, "ELLIPARCCLOSE"}, - -/* Attribute elements */ - - {0x3520, "LINEINDEX"}, - {0x3521, "LINETYPE"}, - {0x3522, "LINEWIDTH"}, - {0x3523, "LINECOLR"}, - {0x3524, "MARKERINDEX"}, - {0x3525, "MARKERTYPE"}, - {0x3526, "MARKERSIZE"}, - {0x3527, "MARKERCOLR"}, - - {0x3530, "TEXTINDEX"}, - {0x3531, "TEXTFONTINDEX"}, - {0x3532, "TEXTPREC"}, - {0x3533, "CHAREXPAN"}, - {0x3534, "CHARSPACE"}, - {0x3535, "TEXTCOLR"}, - {0x3536, "CHARHEIGHT"}, - {0x3537, "CHARORI"}, - {0x3538, "TEXTPATH"}, - {0x3539, "TEXTALIGN"}, - {0x353A, "CHARSETINDEX"}, - {0x353B, "ALTCHARSETINDEX"}, - - {0x3620, "FILLINDEX"}, - {0x3621, "INTSTYLE"}, - {0x3622, "FILLCOLR"}, - {0x3623, "HATCHINDEX"}, - {0x3624, "PATINDEX"}, - {0x3625, "EDGEINDEX"}, - {0x3626, "EDGETYPE"}, - {0x3627, "EDGEWIDTH"}, - {0x3628, "EDGECOLR"}, - {0x3629, "EDGEVIS"}, - - {0x362A, "FILLREFPT"}, - {0x362B, "PATTABLE"}, - {0x362C, "PATSIZE"}, - {0x3630, "COLRTABLE"}, - {0x3631, "ASF"}, - -/* Control elements */ - - {0x3320, "VDCINTEGERPREC"}, - {0x3321, "VDCREALPREC"}, - {0x3322, "AUXCOLR"}, - {0x3323, "TRANSPARENCY"}, - {0x3324, "CLIPRECT"}, - {0x3325, "CLIP"}, - -/* Metafile Control Elements */ - - {0x3020, "BEGMF"}, - {0x3021, "ENDMF"}, - {0x3022, "BEGPIC"}, - {0x3023, "BEGPICBODY"}, - {0x3024, "ENDPIC"}, - -/* Metafile Descriptor elements */ - - {0x3120, "MFVERSION"}, - {0x3121, "MFDESC"}, - {0x3122, "VDCTYPE"}, - {0x3123, "INTEGERPREC"}, - {0x3124, "REALPREC"}, - {0x3125, "INDEXPREC"}, - {0x3126, "COLRPREC"}, - {0x3127, "COLRINDEXPREC"}, - {0x3128, "MAXCOLRINDEX"}, - {0x3129, "COLRVALUEEXT"}, - {0x312A, "MFELEMLIST"}, - {0x312B, "BEGMFDEFAULTS"}, - {0x312C, "ENDMFDEFAULTS"}, - {0x312D, "FONTLIST"}, - {0x312E, "CHARSETLIST"}, - {0x312F, "CHARCODING"}, - -/* Picture descriptor elements */ - - {0x3220, "SCALEMODE"}, - {0x3221, "COLRMODE"}, - {0x3222, "LINEWIDTHMODE"}, - {0x3223, "MARKERSIZEMODE"}, - {0x3224, "EDGEWIDTHMODE"}, - {0x3225, "VDCEXT"}, - {0x3226, "BACKCOLR"}, - -/* Escape Elements */ - - {0x3720, "ESCAPE"}, - {0x3721, "MESSAGE"}, - {0x3722, "APPLDATA"}, - -/* Version 2 element names */ - -#if CGMVERSION > 1 - {0x3025, "BEGSEG"}, - {0x3026, "ENDSEG"}, - {0x3027, "BEGFIG"}, - {0x3028, "ENDFIG"}, - - {0x3029, "BEGGKSSESSIONMF"}, - {0x302A, "BEGGKSSESSION"}, - {0x302B, "ENDGKSSESSION"}, - - {0x3130, "NAMEPREC"}, - {0x3131, "MAXVDCEXT"}, - {0x3132, "SEGPRIEXT"}, - - {0x3227, "DEVVP"}, - {0x3228, "DEVVPMODE"}, - {0x3229, "DEVVPMAP"}, - {0x322A, "LINEREP"}, - {0x322B, "MARKERREP"}, - {0x322C, "TEXTREP"}, - {0x322D, "FILLREP"}, - {0x322E, "EDGEREP"}, - - {0x3326, "LINECLIPMODE"}, - {0x3327, "MARKERCLIPMODE"}, - {0x3328, "EDGECLIPMODE"}, - {0x3329, "NEWREGION"}, - {0x332A, "SAVEPRIMCONT"}, - {0x332B, "RESPRIMCONT"}, - - {0x332C, "WSVP"}, - {0x332D, "CLEAR"}, - {0x332E, "UPD"}, - {0x332F, "DEFERST"}, - - {0x3428, "ARCCTRREV"}, - {0x3429, "CONNEDGE"}, - - {0x3632, "PICKID"}, - - {0x3820, "COPYSEG"}, - {0x3821, "INHFILTER"}, - {0x3822, "CLIPINH"}, - {0x3823, "SEGTRANS"}, - {0x3824, "SEGHIGHLIGHT"}, - {0x3825, "SEGDISPPRI"}, - {0x3826, "SEGPICKPRI"}, - - {0x3827, "DELSEG"}, - {0x3828, "RENAMESEG"}, - {0x3829, "REDRAWALLSEG"}, - {0x382A, "SEGVIS"}, - {0x382B, "SEGDET"}, - -#if CGMVERSION > 2 - - {0x302C, "BEGPROTREGION"}, - {0x302D, "ENDPROTREGION"}, - {0x302E, "BEGCOMPOLINE"}, - {0x302F, "ENDCOMPOLINE"}, - {0x3030, "BEGCOMPOTEXTPATH"}, - {0x3031, "ENDCOMPOTEXTPATH"}, - {0x3032, "BEGTILEARRAY"}, - {0x3033, "ENDTILEARRAY"}, - - {0x3133, "COLRMODEL"}, - {0x3134, "COLRCALIB"}, - {0x3135, "FONTPROP"}, - {0x3136, "GLYPHMAP"}, - {0x3137, "SYMBOLLIBLIST"}, - - {0x322F, "INTSTYLEMODE"}, - {0x3230, "LINEEDGETYPEDEF"}, - {0x3231, "HATCHSTYLEDEF"}, - {0x3232, "GEOPATDEF"}, - - {0x3330, "PROTREGION"}, - {0x3331, "GENTEXTPATHMODE"}, - {0x3332, "MITRELLIMIT"}, - {0x3333, "TRANSPCELLCOLR"}, - - {0x342A, "HYPERBARC"}, - {0x342B, "PARABARC"}, - {0x342C, "NUB"}, - {0x342D, "NURB"}, - {0x342E, "POLYBEZIER"}, - {0x342F, "SYMBOL"}, {0x342F, "INCRSYMBOL"}, - {0x3430, "BITONALTILE"}, - {0x3431, "TILE"}, - - {0x3528, "LINECAP"}, - {0x3529, "LINEJOIN"}, - {0x352A, "LINETYPECONT"}, - {0x352B, "LINETYPEINITOFFSET"}, - {0x352C, "TEXTSCORETYPE"}, - {0x352D, "RESTTEXTTYPE"}, - {0x352E, "INTERPINT"}, - {0x352F, "EDGECAP"}, - {0x362D, "EDGEJOIN"}, - {0x362E, "EDGETYPECONT"}, - {0x362F, "EDGETYPEINITOFFSET"}, - {0x3633, "SYMBOLLIBINDEX"}, - {0x3634, "SYMBOLCOLR"}, - {0x3635, "SYMBOLSIZE"}, - {0x3636, "SYMBOLORI"}, - -#endif -#endif - -/* MFelemlist special names */ - - {0x10, "DRAWINGSET"}, - {0x11, "DRAWINGPLUS"}, -#if CGMVERSION > 1 - {0x12, "VERSION2"}, - {0x13, "EXTDPRIM"}, - {0x14, "VERSION2GKSM"}, -#if CGMVERSION > 2 - {0x15, "VERSION3"}, -#endif -#endif - {EOF, "EOF"} - }; - -extern "C" { - /* Metafile Default settings */ - extern struct char_defaults mfchar, mfichar, curichar, curchar, oldchar; - extern struct text_defaults mftext, mfitext, curitext, curtext; - extern struct bin_defaults mfbin, mfibin, curibin, curbin; - extern struct defaults mf, cur, old; - extern struct attributes mfatt, curatt, oldatt; - - /* Flags for changes to attributes - initially set to false */ - extern struct flags att; - -/* - FILE* OPEN_FILE(char*,int); - void CLOSE_FILE(); -*/ - void CGMOtext(FILE*,Code, Long*,float*,char*); - void CGMObin (FILE*,Code, Long*,float*,char*); - void CGMOchar (FILE*,Code, Long*,float*,char*); - FILE* getfd(); -} -FILE* OPEN_FILE(char*,int); -void CLOSE_FILE(); diff --git a/src/CGM/cgmmach.h b/src/CGM/cgmmach.h deleted file mode 100755 index 985ada5c83..0000000000 --- a/src/CGM/cgmmach.h +++ /dev/null @@ -1,303 +0,0 @@ -/* - Copyright (c) 1999-2012 OPEN CASCADE SAS - - The content of this file is subject to the Open CASCADE Technology Public - License Version 6.5 (the "License"). You may not use the content of this file - except in compliance with the License. Please obtain a copy of the License - at http://www.opencascade.org and read it completely before using this file. - - The Initial Developer of the Original Code is Open CASCADE S.A.S., having its - main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. - - The Original Code and all software distributed under the License is - distributed on an "AS IS" basis, without warranty of any kind, and the - Initial Developer hereby disclaims all such warranties, including without - limitation, any warranties of merchantability, fitness for a particular - purpose or non-infringement. Please see the License for the specific terms - and conditions governing the rights and limitations under the License. - -*/ - -/* Get local machine id, operating system, compiler and/or library */ -#ifndef CGMMACH_H -#define CGMMACH_H - -/* C Library routines needed in standard include files */ - -#include -#include -#include -#include -#include -#include - -/* Current CGM version */ -#define CGMVERSION 1 - -#define const -#define volatile -#define FREE(x) free ( (char *) x ) - -#ifndef NULL /* Null Pointer */ -#define NULL (int *) 0 -#endif - -/* Define anything that has not been explicitly set **************/ - -#ifndef SignChar -#define SignChar signed char -#endif -#ifndef Int16 -#define Int16 short -#endif -#ifndef Char -#define Char char -#endif -#ifndef Int -#define Int int -#endif -#ifndef Long -#define Long long -#endif -#ifndef Float -#define Float float -#endif -#ifndef Double -#define Double double -#endif - -/* Define macros for some maths routines which may cause problems */ - -#ifndef SQRT -#define SQRT(x) sqrt( (double) (x) ) -#endif -#ifndef FABS -#define FABS(x) fabs( (double) (x) ) -#endif -#ifndef MALLOC -#define MALLOC(n,s) malloc( (size_t) ((n)*(s)) ) -#endif - -/* Define if font system needed */ - -#ifdef XW -#define FONTSYSTEM -#else -#ifdef POSTSCRIPT -#define FONTSYSTEM -#else -#ifdef IGL -#define FONTSYSTEM -#endif -#endif -#endif - - -#ifndef FIXED_BUFFER /* Use variable communications Area by default */ -#define VAR_BUFFER -#endif - -#ifndef ARRAY_MAX /* Maximum Sizes for Interface buffer */ -#define ARRAY_MAX 1024 -#endif - -#ifndef STRING_MAX /* Maximum String length */ -#define STRING_MAX 1024 -#endif - -#ifndef DEFOUT /* Default Standard Output type */ -#define DEFOUT 'T' -#endif - -#ifndef ERROR_MAX /* Maximum Number of errors */ -#define ERROR_MAX 16 -#endif - -#ifndef DEFVERBOSE /* Default Verbose mode flag */ -#define DEFVERBOSE FALSE -#endif - -#ifndef DEFQUIET /* Default quiet output flag */ -#define DEFQUIET FALSE -#endif - -#ifndef DEFMOVIE /* Default Continuous play mode */ -#define DEFMOVIE FALSE -#endif - -#ifndef DEFDOUBLE /* Default Double buffer mode */ -#define DEFDOUBLE FALSE -#endif - -#ifndef DEFFULLSCRN /* Default Full screen mode */ -#define DEFFULLSCRN TRUE -#endif - -#ifndef DEFRALGKSGDP /* RAL-GKS GDPs recognised */ -#define DEFRALGKSGDP FALSE -#endif - -#ifndef LPOINT /* Define default LPOINT commands */ -#define Lpoint Point - -#define LPOINT(p) Lpoint *p -#define BEGINLIST(p) -#define STOREPOINT(p,q) (*p).x = q.x; (*p++).y = q.y -#define STOREVALUE(p,q,r) (*p).x = q; (*p++).y = r -#define CLOSELIST(p) -#define NEWSUBLIST(p) -#define ENDLIST(p) -#endif - -#ifndef MAXFNSIZE /* Maximum font name size */ -#define MAXFNSIZE 40 -#endif - -#ifndef DATADIR /* Directory for font & data files */ -#define DATADIR "" -#endif - -#ifndef FILESEP /* File seperator */ -#define FILESEP "." -#endif - -#ifndef PATHDELIM /* Path seperator */ -#define PATHDELIM '/' -#endif - -#ifndef MAXFLSIZE /* Maximum length of filename - whole tree */ -#define MAXFLSIZE 80 -#endif - -#ifndef NAMELGTH /* Maximum length of filename - name only */ -#define NAMELGTH 8 -#endif - -#ifndef EXTLGTH /* Maximum length of filename - extension */ -#define EXTLGTH 3 -#endif - -#ifndef LFILEDEF /* Maximum length of filename extra data */ -#define LFILEDEF 0 -#endif - -#ifndef F_READ /* Read file mode */ -#define F_READ 'r' -#endif - -#ifndef F_WRITE /* Write file mode */ -#define F_WRITE 'w' -#endif - -#ifndef BUFF_LEN /* CGM output record length */ -#define BUFF_LEN (size_t) 80 -#endif - -#ifndef OBUFF_LEN /* CGM output buffer size */ -#define OBUFF_LEN (size_t) 512 -#endif - -#ifndef NFRAME /* Maximum number of frames */ -#define NFRAME 100 -#endif - -#ifndef NMETA /* Maximum number of metafiles */ -#define NMETA 10 -#endif - -#ifndef MAXPTS /* Maximum storage for fill area processing */ -#define MAXPTS 4096 -#endif - -#ifndef SET_MAX /* Maximum number of Polygon sets ?? */ -#define SET_MAX 50 -#endif - -#ifndef COLOUR_TAB /* Colour table size */ -#define COLOUR_TAB 256 -#endif - -#ifndef COLOUR_BITS /* Number of bit planes */ -#define COLOUR_BITS 8 -#endif - -#ifndef PATT_TAB /* Pattern table size */ -#define PATT_TAB 1024 -#endif - -#ifndef PATTERNS /* Maximum number of Patterns */ -#define PATTERNS 40 -#endif - -#ifndef NPOWER /* No of entries in power-of-two table */ -#define NPOWER 32 -#endif - -#ifndef HASHSIZE /* No of entries in Code hash table */ -#if CGMVERSION == 1 -#define HASHSIZE 280 -#endif -#if CGMVERSION == 2 -#define HASHSIZE 512 -#endif -#if CGMVERSION == 3 -#define HASHSIZE 1024 -#endif -#endif - -#ifndef NULLSTR /* Null string pointer */ -#define NULLSTR (char *) NULL -#endif - -#ifdef DEBUG /* turn on extra debugging in font package */ -#define CSETNAMES -#define DESNAMES -#endif - - /* All the following definitions provide limits for the number - | of values that can be read in by the font utility; they do - | not cause any permanent memory to be allocated, so can be - | set high for safety. - */ - -#ifndef MAXCSET /* maximum number of ISO character sets */ -#define MAXCSET 1000 -#endif - -#ifndef MAXFUDGE /* maximum number of fudge character sets */ -#define MAXFUDGE 25 -#endif - -#ifndef MAXFAMILY /* maximum number of typeface family definitions */ -#define MAXFAMILY 2000 -#endif - -#ifndef MAXALIAS /* maximum number of family aliases */ -#define MAXALIAS 200 -#endif - -#ifndef MAXSFONT /* maximum number of specific fonts */ -#define MAXFONT 2000 -#endif - -#ifndef MAXSOURCE /* maximum number of typeface sources */ -#define MAXSOURCE 100 -#endif - -#ifndef MAXDESIGN /* maximum number of ISO design groups */ -#define MAXDESIGN 200 -#endif - -#ifndef MAXMETHOD /* maximum number of output methods */ -#define MAXMETHOD 5 -#endif - -#ifndef MAXFPERM /* maximum number of fonts per method */ -#define MAXFPERM 1000 -#endif - -#ifndef MAXREQ /* maximum number of fonts per method */ -#define MAXREQ 1000 -#endif - -#endif /* end of cgmmach.h */ diff --git a/src/CGM/cgmobin.c b/src/CGM/cgmobin.c deleted file mode 100755 index d651ac3a9c..0000000000 --- a/src/CGM/cgmobin.c +++ /dev/null @@ -1,1738 +0,0 @@ -/* - Copyright (c) 1999-2012 OPEN CASCADE SAS - - The content of this file is subject to the Open CASCADE Technology Public - License Version 6.5 (the "License"). You may not use the content of this file - except in compliance with the License. Please obtain a copy of the License - at http://www.opencascade.org and read it completely before using this file. - - The Initial Developer of the Original Code is Open CASCADE S.A.S., having its - main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. - - The Original Code and all software distributed under the License is - distributed on an "AS IS" basis, without warranty of any kind, and the - Initial Developer hereby disclaims all such warranties, including without - limitation, any warranties of merchantability, fitness for a particular - purpose or non-infringement. Please see the License for the specific terms - and conditions governing the rights and limitations under the License. - -*/ - -#include -#include "cgmout.h" - -/* File stream name */ - -static FILE *cgmob; - -/* declare internal functions */ -# if (defined __STDC__ && __STDC__) || defined __cplusplus -/* use function prototypes, they are requred for ANSI C and C++ compilers */ -void CGMObin(FILE *stream, Code c, Long *pi, Float *pr, char *str); -/* Main Output Routine */ -static void MOBopcode(Code c, Long len), /* Output an Op code */ - MOBint(Long n, Prec prec, Enum sign), /* Output an Integer */ - MOBreal(Double x, Enum real_type, Enum real_or_vdc), /* Output a real number */ - MOBcolour(struct colour *col, Enum type), /* Output a colour */ - MOBvdc(Int n, Long *pi, Float *pr), /* Output a number of VDCs */ - MOBpointlist(Long n, Long *pi, Float *pr, Enum set), /* Output a Points List */ - MOBclist(register Long num, register Long *col, - Prec mode, Enum type, Prec prec), /* Output a colour list */ - MOBbits(Posint value, Prec prec, Long *bit), /* Output a value to a bit stream */ - MOBstring(char *s), /* Output a string */ - MOBout(Posint hex, Prec bytes), /* Output values to the output buffer */ - MOBcharci(Code c, Int *class, Int *id); /* Convert Op code value to Class and Id */ -#else -void CGMObin(); /* Main Output Routine */ -static void MOBopcode(), /* Output an Op code */ - MOBint(), /* Output an Integer */ - MOBreal(), /* Output a real number */ - MOBcolour(), /* Output a colour */ - MOBvdc(), /* Output a number of VDCs */ - MOBpointlist(), /* Output a Points List */ - MOBclist(), /* Output a colour list */ - MOBbits(), /* Output a value to a bit stream */ - MOBstring(), /* Output a string */ - MOBout(), /* Output values to the output buffer */ - MOBcharci(); /* Convert Op code value to Class and Id */ -#endif -/* Local Parameters */ - -#define ENUMERATED (Prec) 16 - -#define PARTITION (Code) 0xff - -#define UNSIGNED (Enum) 0 -#define SIGNED (Enum) 1 - -#define FLOATING (Enum) 0 -#define FIXED (Enum) 1 - -#define RUNLENGTH (Enum) 0 -#define PACKED (Enum) 1 - -#define BYTE (Prec) 1 -#define WORD (Prec) 2 -#define LONGINT (Prec) 4 - -/* Parameter sizes */ - -#define ENUMSIZE ( (Long) 2 ) -#define INDEXSIZE ( (Long) curbin.index_prec>>3 ) -#define COLINDEXSIZE ( (Long) curbin.colind_prec>>3 ) -#define INTSIZE ( (Long) curbin.int_prec>>3 ) -#define REALSIZE ( (Long) (curbin.real_whole + curbin.real_fraction)>>3 ) -#define VDCSIZE ( (Long) (cur.vdc_type == REAL\ - ? (curbin.vdc_whole + curbin.vdc_fraction)>>3 \ - : curbin.vdcint_prec>>3 ) ) -#define COLOURSIZE ( (Long) (cur.color_mode == DIRECT\ - ? 3*curbin.col_prec>>3 : curbin.colind_prec>>3 ) ) -#define STRINGSIZE(x) ( (Long) (256 * strlen(x) / 255 + 1) ) - -/* Basic Common Output functions */ - -#define PUTBYTE(x) MOBout( (Posint) x, (Prec) 1 ) -#define PUTWORD(x) MOBout( (Posint) x, (Prec) 2 ) -#define PUTINT(x) MOBint( (Long) x, curbin.int_prec, SIGNED ) -#define PUTREAL(x) MOBreal ( (Double)x, curbin.real_type, REAL ) -#define PUTINDEX(x) MOBint( (Long) x, curbin.index_prec, SIGNED ) -#define PUTENUM(x) MOBint( (Long) x, ENUMERATED, SIGNED ) -#define PUTINTVDC(x) MOBint( (Long) x, curbin.vdcint_prec, SIGNED ) -#define PUTREALVDC(x) MOBreal( (Double)x, curbin.vdc_type, VDC ) - -/* Local Variables */ - -static size_t mobblen = BUFF_LEN, /* Normal Output Buffer length */ - mobparmlen, /* Parameter length in bytes */ - mobremainder, /* Bytes left after partition */ - mobdeflen, /* MF Defaults replacement length */ - mobindex = 0; /* Output buffer pointer */ -static char mobstdbuff[BUFF_LEN], /* Normal Output buffer */ - *mobbuff = mobstdbuff, /* Buffer origin */ - *mobdefbuff; /* MF Defaults replacement buffer */ - -/*static char *func="CGMobin", mess[40];*/ -static char mess[40]; - -/********************************************************* CGMObin *****/ -void -CGMObin(FILE *stream, Code c, Long *pi, Float *pr, char *str) -{ - register Long j, n, num; - Code major; - Long parmlen = ZERO; - static Long defindex, saveparmlen; - static Logical first = TRUE, first_pic = TRUE; - Int class, id; - - if ( c == (Code) EOF ) - { - MOBout ( (Posint) 0, (Prec) 0); /* flush output buffer */ - exit(0); - } - - major=c>>8; - num = *pi++; - - switch(major) - { - case 0x00: /* Graphics Primitives */ - - switch(c) - { - case NONOP: /* Ignore Non-Op */ - break; - - case LINE: /* Polyline */ - case DISJTLINE: /* Disjoint Polyline */ - case MARKER: /* Polymarker */ - parmlen = 2*num*VDCSIZE; - if ( first ) MOBopcode(c, parmlen); - else MOBopcode(PARTITION, parmlen); - first = ( parmlen >= ZERO ); - MOBpointlist(num, pi, pr, NOSET); - break; - - case TEXT: /* Text */ - parmlen = 2*VDCSIZE + ENUMSIZE + STRINGSIZE(str); - MOBopcode(c, parmlen); - MOBvdc( (Int)2, pi, pr); - PUTENUM ( num ); - MOBstring(str); - break; - - case RESTRTEXT: /* Restricted Text */ - parmlen = 4*VDCSIZE + ENUMSIZE + STRINGSIZE(str); - MOBopcode(c, parmlen); - MOBvdc( (Int)4, pi, pr); - PUTENUM ( num ); - MOBstring(str); - break; - - case APNDTEXT: /* Append Text */ - parmlen = ENUMSIZE + STRINGSIZE(str); - MOBopcode(c, parmlen); - PUTENUM ( num ); - MOBstring(str); - break; - - case POLYGON: /* Polygon */ - parmlen = 2*num*VDCSIZE; - if ( first ) MOBopcode(c, parmlen); - else MOBopcode(PARTITION, parmlen); - first = ( parmlen >= ZERO ); - MOBpointlist(num, pi, pr, NOSET); - break; - - case POLYGONSET: /* Polygon Set */ - parmlen = num * ( 2*VDCSIZE + ENUMSIZE ); - if ( first ) MOBopcode(c, parmlen); - else MOBopcode(PARTITION, parmlen); - first = ( parmlen >= ZERO ); - MOBpointlist(num, pi, pr, SET); - break; - - case CELLARRAY: /* Cell Array */ - { - register Long *pt = pi, i, k; - Long red, green, blue, nc, ncol; - Long run, packed; - Long last, lastred, lastgreen, lastblue; - static Long nx, ny; - static Prec lprec; - static Enum runlength; - -/* Number of colour cells */ - - nc = abs( num ); - ncol = abs(cur.color_mode == DIRECT ? 3*num : num ); - - if ( first ) - { - -/* set up basic parameter length */ - parmlen = 6*VDCSIZE + 3*INTSIZE + ENUMSIZE; - pt += 6; /* skip 3 points */ - nx = *pt++; /* Number of columns */ - ny = *pt++; /* Number of rows */ - j = *pt++; /* Local precision */ - - if ( j == ZERO || num > 0 ) - { - -/* Find largest colour value if cell within buffer */ - - for ( i = 0, k = 0; i < ncol; i++, pt++ ) - { - if ( *pt > k ) k = *pt; - } - j = 0; - while ( k ) - { - k >>= 1; j++; - } - } - lprec = ( j <= 1 ? 1 - : j <= 2 ? 2 - : j <= 4 ? 4 - : j <= 8 ? 8 - : j <= 16 ? 16 - : j <= 24 ? 24 - : 32 ); - pt = pi + 9; - } - -/* Find number of bytes for both coding methods */ - - run = 0; packed = 0; - for ( j = 0; j < nc; j += nx ) - { - -/* Make sure row starts on a word boundary */ - - if ( packed & 1 ) packed++; - if ( run & 1 ) run++; - -/* Calculate length of packed list in bytes per row */ - - packed += ( (cur.color_mode == DIRECT ? 3*nx : nx) - * lprec + 7 )>>3; - -/* Calculate length of run length in bits */ - - k = 0; - if ( cur.color_mode == INDEXED ) - { - last = -1; - for ( i = 0; i < nx; i++, pt++ ) - { - if ( *pt != last) - { - k += curbin.int_prec + lprec; - last = *pt; - } - } - } - else - { - lastred = -1; lastgreen = -1; lastblue = -1; - for ( i = 0; i < nx; i++ ) - { - red = *pt++; green = *pt++; blue = *pt++; - if ( red != lastred || green != lastgreen - || blue != lastblue ) - { - k += curbin.int_prec + 3*lprec; - lastred = red; - lastgreen = green; - lastblue = blue; - } - } - } - -/* Convert runlength to bytes */ - run += (k + 7) >>3; - } - - if ( first ) - { - -/* Decide which encoding is smallest */ - - if ( run < packed ) - { - runlength = RUNLENGTH; - parmlen += run; - } - else - { - runlength = PACKED; - parmlen += packed; - } - - if ( num < 0 ) parmlen = - parmlen; - MOBopcode(c, parmlen); - - MOBvdc ( (Int)6, pi, pr ); - PUTINT ( nx ); - PUTINT ( ny ); - PUTINT ( lprec ); - - pi += 9; - PUTENUM ( runlength ); - } - else - { - parmlen = ( runlength = RUNLENGTH ? run : packed ); - if ( num < 0 ) parmlen = - parmlen; - MOBopcode(PARTITION, parmlen); - } - - first = ( num >= ZERO ); - -/* Output cell array a row at a time */ - - for ( j = 0; j < nc; j += nx ) - { - MOBclist (nx, pi, cur.color_mode, runlength, lprec); - pi += ( cur.color_mode == DIRECT ? 3*nx : nx ); - } - break; - } - - case GDP: /* Generalised Drawing Primitive */ - parmlen = 2*INTSIZE + 2*num*VDCSIZE + STRINGSIZE(str); - if ( first ) MOBopcode(c, parmlen); - else MOBopcode(PARTITION, parmlen); - first = ( parmlen >= ZERO ); - PUTINT ( *pi ); - PUTINT ( num ); - MOBpointlist(num, pi, pr, NOSET); - MOBstring(str); - break; - - case RECT: /* Rectangle */ - parmlen = 4*VDCSIZE; - MOBopcode(c, parmlen); - MOBvdc( (Int)4, pi, pr); - break; - - default: - (void) sprintf( mess, "(code: 0x%x)", c); - break; - } - break; - - case 0x30: /* Delimiter Elements */ - - switch(c) - { - - case BEGMF: /* Begin Metafile */ - cgmob = stream; - curbin = bindef; - parmlen = STRINGSIZE(str); - MOBopcode(c, parmlen); - MOBstring(str); - break; - - case ENDMF: /* End Metafile */ - MOBopcode(c, (Long)0 ); - break; - - case BEGPIC: /* Begin Picture Descriptor */ - parmlen = STRINGSIZE(str); - MOBopcode(c, parmlen); - MOBstring(str); - if ( first_pic ) - { - first_pic = FALSE; - mfbin = curbin; - } - else - curbin = mfbin; - break; - - case BEGPICBODY: /* Begin Picture Body */ - MOBopcode(c, (Long)0 ); - break; - - case ENDPIC: /* End Picture */ - MOBopcode(c, (Long)0 ); - break; - - default: - (void) sprintf( mess, "(code: 0x%x)", c); - break; - } - break; - - - case 0x31: /* Metafile Descriptor Elements */ - switch(c) - { - case MFVERSION: /* Metafile version */ - parmlen = INTSIZE; - MOBopcode(c, parmlen); - PUTINT ( num ); - break; - - case MFDESC: /* Metafile Description */ - parmlen = STRINGSIZE(str); - MOBopcode(c, parmlen); - MOBstring(str); - break; - - case VDCTYPE: /* VDC Type */ - parmlen = ENUMSIZE; - MOBopcode(c, parmlen); - PUTENUM ( cur.vdc_type ); - break; - - case INTEGERPREC: /* Integer Precision */ - parmlen = INTSIZE; - MOBopcode(c, parmlen); - j = ( cur.int_bits <= 8 ? 8 - : cur.int_bits <= 16 ? 16 - : cur.int_bits <= 24 ? 24 - :32 ); - PUTINT ( j ); - curbin.int_prec = j; - break; - - case REALPREC: /* Real Precision */ - parmlen = ENUMSIZE + 2*INTSIZE; - MOBopcode(c, parmlen); - PUTENUM ( curbin.real_type ); - if ( curbin.real_type == FIXED ) - { /* NB: only 16,16 and 32,32 are permitted */ - curbin.real_whole = - (cur.real_bits > 16 || -cur.real_places > 16 ? 32 : 16); - curbin.real_fraction = curbin.real_whole; - } - PUTINT ( curbin.real_whole ); - PUTINT ( curbin.real_fraction ); - break; - - case INDEXPREC: /* Index Precision */ - parmlen = INTSIZE; - MOBopcode(c, parmlen); - curbin.index_prec = ( cur.index_bits <= 8 ? 8 - : cur.index_bits <= 16 ? 16 - : cur.index_bits <= 24 ? 24 - : 32 ); - PUTINT ( curbin.index_prec ); - break; - - case COLRPREC: /* Colour Precision */ - parmlen = INTSIZE; - MOBopcode(c, parmlen); - curbin.col_prec = ( cur.col_bits <= 8 ? 8 - : cur.col_bits <= 16 ? 16 - : cur.col_bits <= 24 ? 24 - : 32 ); - PUTINT ( curbin.col_prec ); - break; - - case COLRINDEXPREC: /* Colour Index Precision */ - parmlen = INTSIZE; - MOBopcode(c, parmlen); - curbin.colind_prec = ( cur.colind_bits <= 8 ? 8 - : cur.colind_bits <= 16 ? 16 - : cur.colind_bits <= 24 ? 24 - : 32 ); - PUTINT ( curbin.colind_prec ); - break; - - case MAXCOLRINDEX: /* Maximum Colour Index */ - parmlen = COLINDEXSIZE; - MOBopcode(c, parmlen); - MOBint (cur.max_colind, curbin.colind_prec, UNSIGNED); - break; - - case COLRVALUEEXT: /* Colour value extent */ - parmlen = 6 * curbin.col_prec >>3; - MOBopcode(c, parmlen); - curbin.min_rgb.red = cur.min_rgb.red; - curbin.min_rgb.green = cur.min_rgb.green; - curbin.min_rgb.blue = cur.min_rgb.blue; - MOBcolour ( &curbin.min_rgb, DIRECT ); - curbin.max_rgb.red = cur.max_rgb.red; - curbin.max_rgb.green = cur.max_rgb.green; - curbin.max_rgb.blue = cur.max_rgb.blue; - MOBcolour ( &curbin.max_rgb, DIRECT ); - break; - - case MFELEMLIST: /* Metafile element List */ - parmlen = INTSIZE + 2*num*INDEXSIZE; - MOBopcode(c, parmlen); - PUTINT ( num ); - for(n = 0; n < num; n++, pi++) - { - switch ( (Int)*pi ) - { - case 0: - case 1: - class = -1; id = (Int)*pi; - break; - default: - MOBcharci( (Code)*pi, &class, &id); - break; - } - PUTINDEX ( class ); - PUTINDEX ( id ); - } - break; - - case BEGMFDEFAULTS: /* Begin Metafile defaults Replacement */ -/* Save current index value */ - defindex = mobindex; - saveparmlen = mobparmlen; - mobparmlen = 0; -/* Create new buffer */ - mobblen = ARRAY_MAX; - mobbuff = mobdefbuff = (char *) malloc( (size_t)mobblen ); - mobindex = 0; - break; - - case ENDMFDEFAULTS: /* End Metafile defaults Replacement */ -/* reset buffer and index */ - mobbuff = mobstdbuff; - mobdeflen = mobindex; - mobindex = defindex; - mobblen = BUFF_LEN; - mobparmlen = saveparmlen; - MOBopcode(BEGMFDEFAULTS, mobdeflen); - -/* copy defaults buffer to output */ - for ( n = 0; n < (int)mobdeflen; n++ ) - PUTBYTE( mobdefbuff[n] ); - FREE( mobdefbuff ); - break; - - case FONTLIST: /* Font List */ - { - register Long *pt = pi; - - for ( j=0, parmlen=0; j < num; j = *pt++ ) - parmlen += STRINGSIZE( &str[j] ); - MOBopcode(c, parmlen); - for ( j=0, pt = pi; j < num; j = *pt++ ) - MOBstring( &str[j] ); - break; - } - - case CHARSETLIST: /* Character set list */ - { - register Long *pt = pi; - - for ( j=0, parmlen=0; j < num; j = *pt++ ) - { - parmlen += ENUMSIZE + STRINGSIZE(&str[j]); - pt++; - } - MOBopcode(c, parmlen); - for ( j=0, pt = pi; j < num; j = *pt++ ) - { - PUTENUM ( *pt++ ); - MOBstring( &str[j] ); - } - break; - } - - case CHARCODING: /* Character coding Announcer */ - parmlen = ENUMSIZE; - MOBopcode(c, parmlen); - PUTENUM ( num ); - break; - - default: - (void) sprintf( mess, "(code: 0x%x)", c); - break; - } - break; - - case 0x32: /* Picture Descriptor Elements */ - switch(c) - { - case SCALEMODE: /* Scaling Mode */ - parmlen = ENUMSIZE + REALSIZE; - MOBopcode(c, parmlen); - PUTENUM ( cur.scale_mode ); - MOBreal ( (Double)cur.scale_factor, FLOATING, REAL ); - break; - - case COLRMODE: /* Colour Selection Mode */ - parmlen = ENUMSIZE; - MOBopcode(c, parmlen); - PUTENUM ( cur.color_mode ); - break; - - case LINEWIDTHMODE: /* Line width Specification */ - parmlen = ENUMSIZE; - MOBopcode(c, parmlen); - PUTENUM ( cur.linewidth_mode ); - break; - - case MARKERSIZEMODE: /* Marker size Specification */ - parmlen = ENUMSIZE; - MOBopcode(c, parmlen); - PUTENUM ( cur.markersize_mode ); - break; - - case EDGEWIDTHMODE: /* Edge width Specification */ - parmlen = ENUMSIZE; - MOBopcode(c, parmlen); - PUTENUM ( cur.edgewidth_mode ); - break; - - case VDCEXT: /* VDC Extent */ - parmlen = 4*VDCSIZE; - MOBopcode(c, parmlen); - if (cur.vdc_type == REAL) - { - PUTREALVDC ( cur.vdc_extent.a.x.real ); - PUTREALVDC ( cur.vdc_extent.a.y.real ); - PUTREALVDC ( cur.vdc_extent.b.x.real ); - PUTREALVDC ( cur.vdc_extent.b.y.real ); - } - else - { - PUTINTVDC ( cur.vdc_extent.a.x.intr ); - PUTINTVDC ( cur.vdc_extent.a.y.intr ); - PUTINTVDC ( cur.vdc_extent.b.x.intr ); - PUTINTVDC ( cur.vdc_extent.b.y.intr ); - } - break; - - case BACKCOLR: /* Background Colour */ - parmlen = 3 * curbin.col_prec >>3; - MOBopcode(c, parmlen); - MOBcolour( &cur.back, DIRECT ); - break; - - default: - (void) sprintf( mess, "(code: 0x%x)", c); - } - break; - - case 0x33: /* Control Elements */ - switch(c) - { - case VDCINTEGERPREC: /* VDC Integer Precision */ - parmlen = INTSIZE; - MOBopcode(c, parmlen); - curbin.vdcint_prec = ( cur.vdcint_bits <= 8 ? 8 - : cur.int_bits <= 16 ? 16 - : cur.int_bits <= 24 ? 24 - :32 ); - PUTINT ( curbin.vdcint_prec ); - break; - - case VDCREALPREC: /* VDC Real Precision */ - parmlen = ENUMSIZE + 2*INTSIZE; - MOBopcode(c, parmlen); - PUTENUM ( curbin.vdc_type ); - if ( curbin.real_type == FIXED ) - { /* NB: only 16,16 or 32,32 permitted */ - curbin.vdc_whole = - (cur.vdc_bits > 16 || -cur.vdc_places > 16 ? 32 : 16); - curbin.vdc_fraction = curbin.vdc_whole; - } - PUTINT ( curbin.vdc_whole ); - PUTINT ( curbin.vdc_fraction ); - break; - - case AUXCOLR: /* Auxiliary Colour */ - parmlen = COLOURSIZE; - MOBopcode(c, parmlen); - MOBcolour( &cur.aux, cur.color_mode ); - break; - - case TRANSPARENCY: /* Transparency */ - parmlen = ENUMSIZE; - MOBopcode(c, parmlen); - PUTENUM ( cur.transparency ); - break; - - case CLIPRECT: /* Clip Rectangle */ - parmlen = 4*VDCSIZE; - MOBopcode(c, parmlen); - if ( cur.vdc_type == REAL ) - { - PUTREALVDC ( cur.clip_rect.a.x.real ); - PUTREALVDC ( cur.clip_rect.a.y.real ); - PUTREALVDC ( cur.clip_rect.b.x.real ); - PUTREALVDC ( cur.clip_rect.b.y.real ); - } - else - { - PUTINTVDC ( cur.clip_rect.a.x.intr ); - PUTINTVDC ( cur.clip_rect.a.y.intr ); - PUTINTVDC ( cur.clip_rect.b.x.intr ); - PUTINTVDC ( cur.clip_rect.b.y.intr ); - } - break; - - case CLIP: /* Clip Indicator */ - parmlen = ENUMSIZE; - MOBopcode(c, parmlen); - PUTENUM ( cur.clip_ind ); - break; - - default: - (void) sprintf( mess, "(code: 0x%x)", c); - break; - } - break; - - case 0x34: /* Circles and Ellipses */ - switch(c) - { - case CIRCLE: /* Circle */ - parmlen = 3*VDCSIZE; - MOBopcode(c, parmlen); - MOBvdc( (Int)3, pi, pr ); - break; - - case ARC3PT: /* Circular Arc 3 point */ - parmlen = 6*VDCSIZE; - MOBopcode(c, parmlen); - MOBvdc( (Int)6, pi, pr ); - break; - - case ARC3PTCLOSE: /* Circular Arc 3 point close */ - parmlen = 6*VDCSIZE + ENUMSIZE; - MOBopcode(c, parmlen); - MOBvdc( (Int)6, pi, pr ); - PUTENUM ( *(pi+6) ); - break; - - case ARCCTR: /* Circle Arc centre */ - parmlen = 7*VDCSIZE; - MOBopcode(c, parmlen); - MOBvdc( (Int)7, pi, pr ); - break; - - case ARCCTRCLOSE: /* Circle Arc centre close */ - parmlen = 7*VDCSIZE + ENUMSIZE; - MOBopcode(c, parmlen); - MOBvdc( (Int)7, pi, pr ); - PUTENUM ( *(pi+7) ); - break; - - case ELLIPSE: /* Ellipse */ - parmlen = 6*VDCSIZE; - MOBopcode(c, parmlen); - MOBvdc( (Int)6, pi, pr ); - break; - - case ELLIPARC: /* Elliptical Arc */ - parmlen = 10*VDCSIZE; - MOBopcode(c, parmlen); - MOBvdc( (Int)10, pi, pr ); - break; - - case ELLIPARCCLOSE: /* Elliptical Arc close */ - parmlen = 10*VDCSIZE + ENUMSIZE; - MOBopcode(c, parmlen); - MOBvdc( (Int)10, pi, pr ); - PUTENUM ( *(pi+10) ); - break; - - default: - (void) sprintf( mess, "(code: 0x%x)", c); - break; - } - break; - - case 0x35: /* Attributes */ - - switch(c) - { - case LINEINDEX: /* Line Bundle index */ - parmlen = INDEXSIZE; - MOBopcode(c, parmlen); - PUTINDEX ( curatt.line_ind ); - break; - - case LINETYPE: /* Line Type */ - parmlen = INDEXSIZE; - MOBopcode(c, parmlen); - PUTINDEX ( curatt.line_type ); - break; - - case LINEWIDTH: /* Line Width */ - if(cur.linewidth_mode == SCALED) - { - parmlen = REALSIZE; - MOBopcode(c, parmlen); - PUTREAL ( curatt.line_width.real ); - } - else - { - parmlen = VDCSIZE; - MOBopcode(c, parmlen); - if ( cur.vdc_type == REAL ) - PUTREALVDC ( curatt.line_width.real ); - else PUTINTVDC ( curatt.line_width.intr ); - } - break; - - case LINECOLR: /* Line Colour */ - parmlen = COLOURSIZE; - MOBopcode(c, parmlen); - MOBcolour( &curatt.line, cur.color_mode); - break; - - case MARKERINDEX: /* Marker Bundle index */ - parmlen = INDEXSIZE; - MOBopcode(c, parmlen); - PUTINDEX ( curatt.mark_ind ); - break; - - case MARKERTYPE: /* Marker Type */ - parmlen = INDEXSIZE; - MOBopcode(c, parmlen); - PUTINDEX ( curatt.mark_type ); - break; - - case MARKERSIZE: /* Marker Size */ - if(cur.markersize_mode == SCALED) - { - parmlen = REALSIZE; - MOBopcode(c, parmlen); - PUTREAL ( curatt.mark_size.real ); - } - else - { - parmlen = VDCSIZE; - MOBopcode(c, parmlen); - if ( cur.vdc_type == REAL ) - PUTREALVDC ( curatt.mark_size.real ); - else PUTINTVDC ( curatt.mark_size.intr ); - } - break; - - case MARKERCOLR: /* Marker Colour */ - parmlen = COLOURSIZE; - MOBopcode(c, parmlen); - MOBcolour( &curatt.marker, cur.color_mode); - break; - - case TEXTINDEX: /* Text Bundle index */ - parmlen = INDEXSIZE; - MOBopcode(c, parmlen); - PUTINDEX ( curatt.text_ind ); - break; - - case TEXTFONTINDEX: /* Text Font Index */ - parmlen = INDEXSIZE; - MOBopcode(c, parmlen); - PUTINDEX ( curatt.text_font ); - break; - - case TEXTPREC: /* Text Precision */ - parmlen = ENUMSIZE; - MOBopcode(c, parmlen); - PUTENUM ( curatt.text_prec ); - break; - - case CHAREXPAN: /* Character Expansion Factor */ - parmlen = REALSIZE; - MOBopcode(c, parmlen); - PUTREAL ( curatt.char_exp ); - break; - - case CHARSPACE: /* Character Spacing */ - parmlen = REALSIZE; - MOBopcode(c, parmlen); - PUTREAL ( curatt.char_space ); - break; - - case TEXTCOLR: /* Text Colour */ - parmlen = COLOURSIZE; - MOBopcode(c, parmlen); - MOBcolour( &curatt.text, cur.color_mode); - break; - - case CHARHEIGHT: /* Character Height */ - parmlen = VDCSIZE; - MOBopcode(c, parmlen); - if ( cur.vdc_type == REAL ) - PUTREALVDC ( curatt.char_height.real ); - else PUTINTVDC ( curatt.char_height.intr ); - break; - - case CHARORI: /* Character Orientation */ - parmlen = 4*VDCSIZE; - MOBopcode(c, parmlen); - if ( cur.vdc_type == REAL ) - { - PUTREALVDC ( curatt.char_up.x.real ); - PUTREALVDC ( curatt.char_up.y.real ); - PUTREALVDC ( curatt.char_base.x.real ); - PUTREALVDC ( curatt.char_base.y.real ); - } - else - { - PUTINTVDC (curatt.char_up.x.intr ); - PUTINTVDC (curatt.char_up.y.intr ); - PUTINTVDC (curatt.char_base.x.intr ); - PUTINTVDC (curatt.char_base.y.intr ); - } - break; - - case TEXTPATH: /* Text Path */ - parmlen = ENUMSIZE; - MOBopcode(c, parmlen); - PUTENUM ( curatt.text_path ); - break; - - case TEXTALIGN: /* Text Alignment */ - parmlen = 2*ENUMSIZE + 2*REALSIZE; - MOBopcode(c, parmlen); - PUTENUM ( curatt.text_halign ); - PUTENUM ( curatt.text_valign ); - PUTREAL ( curatt.text_hcont ); - PUTREAL ( curatt.text_vcont ); - break; - - case CHARSETINDEX: /* Character Set Index */ - parmlen = INDEXSIZE; - MOBopcode(c, parmlen); - PUTINDEX ( curatt.char_set ); - break; - - case ALTCHARSETINDEX: /* Alt Character Set Index */ - parmlen = INDEXSIZE; - MOBopcode(c, parmlen); - PUTINDEX ( curatt.altchar_set ); - break; - - default: - (void) sprintf( mess, "(code: 0x%x)", c); - break; - } - break; - - case 0x36: /* More Attributes */ - switch(c) - { - case FILLINDEX: /* Fill Bundle index */ - parmlen = INDEXSIZE; - MOBopcode(c, parmlen); - PUTINDEX ( curatt.fill_ind ); - break; - - case INTSTYLE: /* Interior Style */ - parmlen = ENUMSIZE; - MOBopcode(c, parmlen); - PUTENUM ( curatt.int_style ); - break; - - case FILLCOLR: /* Fill Colour */ - parmlen = COLOURSIZE; - MOBopcode(c, parmlen); - MOBcolour( &curatt.fill, cur.color_mode); - break; - - case HATCHINDEX: /* Hatch Index */ - parmlen = INDEXSIZE; - MOBopcode(c, parmlen); - PUTINDEX(curatt.hatch_ind ); - break; - - case PATINDEX: /* Pattern Index */ - parmlen = INDEXSIZE; - MOBopcode(c, parmlen); - PUTINDEX(curatt.pat_ind ); - break; - - case EDGEINDEX: /* Edge Bundle index */ - parmlen = INDEXSIZE; - MOBopcode(c, parmlen); - PUTINDEX(curatt.edge_ind ); - break; - - case EDGETYPE: /* Edge Type */ - parmlen = INDEXSIZE; - MOBopcode(c, parmlen); - PUTINDEX(curatt.edge_type ); - break; - - case EDGEWIDTH: /* Edge Width */ - if(cur.edgewidth_mode == SCALED) - { - parmlen = REALSIZE; - MOBopcode(c, parmlen); - PUTREAL ( curatt.edge_width.real ); - } - else - { - parmlen = VDCSIZE; - MOBopcode(c, parmlen); - if ( cur.vdc_type == REAL ) - PUTREALVDC ( curatt.edge_width.real ); - else PUTINTVDC ( curatt.edge_width.intr ); - } - break; - - case EDGECOLR: /* Edge Colour */ - parmlen = COLOURSIZE; - MOBopcode(c, parmlen); - MOBcolour( &curatt.edge, cur.color_mode); - break; - - case EDGEVIS: /* Edge Visibility */ - parmlen = ENUMSIZE; - MOBopcode(c, parmlen); - PUTENUM ( curatt.edge_vis ); - break; - - case FILLREFPT: /* Fill Reference Point */ - parmlen = 2*VDCSIZE; - MOBopcode(c, parmlen); - if ( cur.vdc_type == REAL ) - { - PUTREALVDC ( curatt.fill_ref.x.real ); - PUTREALVDC ( curatt.fill_ref.y.real ); - } - else - { - PUTINTVDC ( curatt.fill_ref.x.intr ); - PUTINTVDC ( curatt.fill_ref.y.intr ); - } - break; - - case PATTABLE: /* Pattern Table */ - { - register Long *pt = pi, patind, i, k; - Long nx, ny; - Prec lprec; - - parmlen = INDEXSIZE + 3*INTSIZE; - patind = *pt++; - nx = *pt++; - ny = *pt++; - pt++; /* ignore previous local precision */ - -/* Find local precision */ - - n = (cur.color_mode == DIRECT ? 3*num : num ); - for ( i = 0, k = 0; i < n; i++, pt++ ) - { - if ( *pt > k ) k = *pt; - } - j = 0; - while ( k ) - { - k >>= 1; j++; - } - lprec = ( j <= 1 ? 1 - : j <= 2 ? 2 - : j <= 4 ? 4 - : j <= 8 ? 8 - : j <= 16 ? 16 - : j <= 24 ? 24 - : 32 ); - -/* Work out parameter length in bytes */ - - parmlen += ( lprec * (cur.color_mode == DIRECT ? 3*num : num ) - + 7 )>>3; - - MOBopcode(c, parmlen); - - PUTINDEX ( patind ); - PUTINT ( nx ); - PUTINT ( ny ); - PUTINT ( lprec ); - -/* Output whole cell array */ - - MOBclist ( num, pi + 4, cur.color_mode, PACKED, lprec); - break; - } - - case PATSIZE: /* Pattern Size */ - parmlen = 4*VDCSIZE; - MOBopcode(c, parmlen); - if ( cur.vdc_type == REAL ) - { - PUTREALVDC ( curatt.pat_size.a.x.real ); - PUTREALVDC ( curatt.pat_size.a.y.real ); - PUTREALVDC ( curatt.pat_size.b.x.real ); - PUTREALVDC ( curatt.pat_size.b.y.real ); - } - else - { - PUTINTVDC ( curatt.pat_size.a.x.intr ); - PUTINTVDC ( curatt.pat_size.a.y.intr ); - PUTINTVDC ( curatt.pat_size.b.x.intr ); - PUTINTVDC ( curatt.pat_size.b.y.intr ); - } - break; - - case COLRTABLE: /* Colour Table */ - parmlen = COLINDEXSIZE + ((3*num*curbin.col_prec)>>3); - MOBopcode(c, parmlen); - MOBint(*pi++, curbin.colind_prec, UNSIGNED); - for ( j=0; j < num; j++) - { - MOBint(*pi++, curbin.col_prec, UNSIGNED); - MOBint(*pi++, curbin.col_prec, UNSIGNED); - MOBint(*pi++, curbin.col_prec, UNSIGNED); - } - break; - - case ASF: /* Aspect source flags */ - { - Long k, l, *pt=pi; - Int type, value; - Logical asflag[ASFS]; - - for ( j=0; j < ASFS; j++) asflag[j] = FALSE; - for ( j=0; j < num; j++ ) - { - type = *pt++; value = (*pt++) + 1; - if ( type < ASFS ) asflag[type] = value; - else - { - switch ( type ) - { - case 506: /* all edge */ - k = 15; l = 17; break; - case 507: /* all fill */ - k = 11; l = 14; break; - case 508: /* all text */ - k = 6; l = 10; break; - case 509: /* all marker */ - k = 3; l = 5; break; - case 510: /* all line */ - k = 0; l = 2; break; - case 511: /* all */ - k = 0; l = 17; break; - default: /* ignore */ - k = 1; l = 0; break; - } - for ( n = k; n < l; n++ ) asflag[n] = value; - } - } - for ( j=0; j < ASFS; j++) - if ( asflag[j] ) parmlen += 2*ENUMSIZE; - MOBopcode(c, parmlen); - for ( j=0; j < ASFS; j++) - if ( asflag[j] ) - { - PUTENUM ( j ); - PUTENUM ( curatt.asf[j] ); - } - break; - } - - default: - (void) sprintf( mess, "(code: 0x%x)", c); - break; - } - break; - - case 0x37: /* Escape And External Elements */ - switch(c) - { - case ESCAPE: /* Escape */ - parmlen = INTSIZE + STRINGSIZE(str); - MOBopcode(c, parmlen); - PUTINT ( num ); - MOBstring(str); - break; - - case MESSAGE: /* Message */ - parmlen = ENUMSIZE + STRINGSIZE(str); - MOBopcode(c, parmlen); - PUTENUM ( num ); - MOBstring(str); - break; - - case APPLDATA: /* Application Data */ - parmlen = INTSIZE + STRINGSIZE(str); - MOBopcode(c, parmlen); - PUTINT ( num ); - MOBstring(str); - break; - - default: - (void) sprintf( mess, "(code: 0x%x)", c); - break; - } - break; - - default: - (void) sprintf( mess, "(code: 0x%x)", c); - break; - } - return; -} - -/******************************************************** MOBopcode ****/ - -static void -MOBopcode( Code c, Long len ) -{ - Int class, id; - unsigned Long oneword, plen, remainder; - Logical part; - -/* Pad out last element if necessary */ - while ( mobparmlen && mobparmlen < 0x8000 ) PUTBYTE( ZERO ); - - plen = abs(len); - part = (len < 0); - -/* check for parameter length > 32766 */ - - if ( plen > 0x7ffe ) - { - remainder = plen - 0x7ffe; - part = TRUE; - plen = 0x7ffe; - } - else remainder = 0; - - if ( c != PARTITION ) - { - MOBcharci(c, &class, &id); - oneword = (class<<12) + (id<<5) + ( part || (plen > 0x1e) ? 0x1f : plen ); - PUTWORD ( oneword ); - } - -/* Put out parameter length as integer */ - - if ( c == PARTITION || plen > 0x1e ) - { - oneword = ( part ? plen | 0x8000 : plen ); - PUTWORD ( oneword ); - } - - mobparmlen = plen; - mobremainder = remainder; - if (mobparmlen & 1) mobparmlen++; - return; -} - -/******************************************************** MOBcharci ****/ -static void -MOBcharci( Code c, Int *class, Int *id ) -{ -/* Converts Code c to class and Id */ - - Code major = c>>8, minor = c & 0xff; - - *class = -1; *id = 0; - switch ( major ) - { - case 0x00: /* Graphics Primitives */ - if ( minor >= 0x20 && minor <= 0x2A ) - { - *class = 4; *id = minor - 0x20 + 1; - } - else if ( minor == 0 ) *class = ZERO; /* Non-Op */ - break; - - case 0x30: /* Metafile delimiters */ - if ( minor >= 0x20 && minor <= 0x24 ) - { - *class = 0; *id = minor - 0x20 + 1; - } - break; - - case 0x31: /* Metafile Descriptor Elements */ - if ( minor >= 0x20 && minor <= 0x2b ) - { - *class = 1; *id = minor - 0x20 + 1; - } - else if ( minor > 0x2c && minor <= 0x2f ) - { - *class = 1; *id = minor - 0x20; - } - break; - - case 0x32: /* Picture Descriptor Elements */ - if ( minor >= 0x20 && minor <= 0x26 ) - { - *class = 2; *id = minor - 0x20 + 1; - } - break; - - case 0x33: /* Control Elements */ - if ( minor >= 0x20 && minor <= 0x25 ) - { - *class = 3; *id = minor - 0x20 + 1; - } - break; - - case 0x34: /* More Graphics Primitives */ - if ( minor >= 0x20 && minor <= 0x27 ) - { - *class = 4; *id = minor - 0x20 + 12; - } - break; - - case 0x35: /* Attributes */ - if ( minor >= 0x20 && minor <= 0x27 ) - { - *class = 5; *id = minor - 0x20 + 1; - } - else if ( minor >= 0x30 && minor <= 0x3b ) - { - *class = 5; *id = minor - 0x30 + 9; - } - break; - - case 0x36: /* More Attributes */ - if ( minor >= 0x20 && minor <= 0x2c ) - { - *class = 5; *id = minor - 0x20 + 21; - } - else if ( minor >= 0x30 && minor <= 0x31 ) - { - *class = 5; *id = minor - 0x30 + 34; - } - break; - - case 0x37: /* External elements */ - if ( minor == 0x20 ) - { - *class = 6; *id = 1; - } - else if ( minor >= 0x21 && minor <= 0x22 ) - { - *class = 7; *id = minor - 0x20; - } - break; - - default: - break; - } - - if ( *class < 0 ) - { - (void) sprintf( mess, "(code: 0x%x)", c); - *class = 0; - } - - return; -} - -/******************************************************** MOBint *******/ -static void -MOBint( Long n, Prec prec, Enum sign ) -{ -/* - if ( sign == SIGNED && n < 0 ) - n = (-n | (Posint) 1L<<(prec-1)); -*/ - MOBout( (Posint) n, prec>>3 ); - return; -} - -/******************************************************** MOBcolour ****/ -static void -MOBcolour( struct colour *col, Enum type ) -{ - - if ( type == DIRECT ) - { - MOBint( (Long) col->red, curbin.col_prec, UNSIGNED ); - MOBint( (Long) col->green, curbin.col_prec, UNSIGNED ); - MOBint( (Long) col->blue, curbin.col_prec, UNSIGNED ); - } - else - { - MOBint( (Long) col->index, curbin.colind_prec, UNSIGNED ); - } - - return; -} - -/******************************************************** MOBvdc *******/ -static void -MOBvdc( Int n, Long *pi, Float *pr) -{ - Int i; - for ( i = 0; i < n; i++) - { - if ( cur.vdc_type == INTEGER ) - { - PUTINTVDC ( *pi++ ); - } - else - { - PUTREALVDC ( *pr++ ); - } - } - - return; -} - -/******************************************************** MOBpointlist */ -static void -MOBpointlist(Long n, Long *pi, Float *pr, Enum set) -{ - Int i; - for ( i = 0; i < n; i++) - { - if ( cur.vdc_type == INTEGER ) - { - PUTINTVDC ( *pi++ ); - PUTINTVDC ( *pi++ ); - } - else - { - PUTREALVDC ( *pr++ ); - PUTREALVDC ( *pr++ ); - } - if ( set ) PUTENUM ( *pi++ ); - } - - return; -} - -/******************************************************** MOBreal ******/ -static void -MOBreal(Double x, Enum real_type, Enum real_or_vdc ) -{ - Posint whole, exponent, fract, neg; - Prec prec; - Double f; - neg = ( x < 0.0 ) << 15; - - if ( real_type == FIXED ) - { - prec = (real_or_vdc == VDC ? curbin.vdc_whole - : curbin.real_whole); - whole = (Posint)( neg ? -((floor(x))) : x ); - fract = (Posint)( ( neg ? x + (Double)whole : x - (Double)whole ) - * ( 1L<<(prec-2) ) * 4.0 ); - - if ( prec == 32 ) - { - PUTWORD( whole>>16 | neg ); - PUTWORD( whole & (Posint)0xffff ); - PUTWORD( fract>>16 ); - PUTWORD( fract & (Posint)0xffff ); - } - else - { - PUTWORD( whole | neg ); - PUTWORD( fract ); - } - } - else - { -/* IEEE Floating point reals */ - - prec = (real_or_vdc == VDC ? curbin.vdc_whole + curbin.vdc_fraction - : curbin.real_whole + curbin.real_fraction); - prec = (prec == 64 ? 12 : 9); - f = ( neg ? -x : x ); - - if ( f < (Double)(real_or_vdc == VDC ? cur.vdcmin : cur.realmin) ) - { - exponent = ZERO; - fract = ZERO; - } - else - { - -/* check if greater than smallest exponent */ - - exponent = ( prec == 12 ? 1023 : 127 ); - - if ( f <= 1.0 / (Double) (prec-1) ) - { - exponent = ZERO; - } - else - { - while ( f >= 2.0 ) - { - f /= 2.0; - exponent++; - } - while ( f < 1.0 ) - { - f *= 2.0; - exponent--; - } - } - fract = (Long) ( (f - 1.0) * (Double)(1L<<(prec == 12 ? 52 : 23)) ); - } - -#if defined(_LP64) - if ( prec == 12 ) - { - PUTWORD( (exponent<<4) | neg | (fract>>48) ); - PUTWORD( (fract >> 32) & (Posint)0xffff ); - PUTWORD( (fract >> 16) & (Posint)0xffff ); - PUTWORD( fract & (Posint)0xffff ); - } - else -#endif - { - PUTWORD( (exponent<<7) | neg | (fract>>16) ); - PUTWORD( fract & (Posint)0xffff ); - } - } - return; -} - -/******************************************************** MOBstring ****/ -static void -MOBstring( char *s ) -{ -/* Output a text string if CMS translate from EBCDIC to ASCII */ - - register Int i, len, slen = strlen(s); - register char chr; - len = slen; - do - { - PUTBYTE ( len >= 0xff ? 0xff : len ); - len -= 0xff; - } while ( len >= 0 ); - - for (i = 0; i < slen; i++) - { - chr = *s++; - PUTBYTE ( chr ); - } -return; -} - -/******************************************************** MOBclist *****/ -static void -MOBclist( register Long num, register Long *col, - Prec mode, Enum type, Prec prec ) -{ -/* Output a colour list */ - - register Long j, k, n; - Long bits, bytes = 0; - if ( type == RUNLENGTH ) - { - Long run = 1, bit = 0; - - if ( mode == DIRECT ) - { - Posint red, green, blue, lastred, lastgreen, lastblue; - - lastred = (*col++); - lastgreen = (*col++); - lastblue = (*col++); - for ( j = 1; j <= num; j++ ) - { - red = (*col++); green = (*col++); blue = (*col++); - if ( j == num || - red != lastred || green != lastgreen || blue != lastblue ) - { - MOBbits ( run, curbin.int_prec, &bit ); - MOBbits ( lastred, prec, &bit ); - MOBbits ( lastgreen, prec, &bit ); - MOBbits ( lastblue, prec, &bit ); - if ( j == num ) break; - lastred = red; lastgreen = green; lastblue = blue; - run = 1; - } - else run++; - } - } - else /* Indexed runlength */ - { - Long lastcol; - - lastcol = (*col++); - for ( j = 1; j <= num; j++, col++ ) - { - if ( j == num || *col != lastcol ) - { - MOBbits ( run, curbin.int_prec, &bit ); - MOBbits ( lastcol, prec, &bit ); - if ( j == num ) break; - lastcol = *col; - run = 1; - } - else run++; - } - } - -/* make sure list ends on a word boundary */ - - if ( bit ) MOBbits ( (Posint) 0 , (Prec) 16, &bit ); - - } - else /* Packed mode */ - { - n = ( mode == DIRECT ? 3*num : num ); - bytes = ( n*prec + 7 ) >>3; - - for ( j = 0, bits = 0, k = 0; j < n; j++) - { - if ( bits ) k <<= prec; - else k = 0; - k += (*col++); - bits += prec; - - while ( bits >= 8 ) - { - bits -= 8; - PUTBYTE ( (k>>bits) & 0xff ); - } - } - if ( bits > 0 ) PUTBYTE ( k<<(8-bits) ); - -/* Pad buffer if necessary */ - if ( bytes & 1 ) PUTBYTE ( 0 ); - } - return; -} - -/******************************************************** MOBbits ******/ -static void -MOBbits ( Posint value, Prec prec, Long *bit ) -{ -/* Output 'value' as 'prec' bits - using 'word' to hold current value - returns number of bits left in 'bits' */ - - static Posint oneword = 0; - Posint mask = (Posint)0xffffffff; - *bit += prec; - if ( *bit <= 16 ) - { - oneword |= value<<(16 - *bit); - } - else - { - while ( *bit > 16 ) - { - *bit -= 16; -/* k = prec + *bit - 16; */ - oneword |= value>>*bit; - value &= mask>>(32 - *bit); - MOBout ( oneword, WORD ); - oneword = value<<16; - } - oneword = value<<(16 - *bit); - } - return; -} - -/******************************************************** MOBout *******/ -static void -MOBout( Posint hex, Prec bytes ) -{ -/* Output 'hex' as 'bytes' bytes to output file 'cgmob' - which is either the file or MF defaults buffer */ - - register Int /*i,*/ b_len; - b_len = bytes; - mobindex = ZERO; - if ( bytes > 0 ) for( ; bytes ; mobindex++ ) - { - bytes--; - mobbuff[mobindex] = (char)((hex >> (8*bytes) ) & 0xff); - mobparmlen--; - } - fwrite(mobbuff,b_len,(size_t)1,cgmob); -/* -start: - if ( bytes > 0 ) for( ; bytes ; mobindex++ ) - { - if ( mobindex == mobblen ) - { - if ( cgmstate != MF_DEFAULTS ) - { - fwrite(mobbuff,mobblen,(size_t)1,cgmob); - mobindex=ZERO; - } - else - { - mobblen += BUFF_LEN; - mobbuff = (char *)realloc (mobbuff, (size_t)mobblen); - } - } - if ( mobindex == ZERO ) - { - for(i = ZERO; i < mobblen ; i++) mobbuff[i] = '\0'; - } - bytes--; - mobbuff[mobindex] = ( hex>>(8*bytes) ) & 0xff; - mobparmlen--; - } - else - { - fwrite(mobbuff,BUFF_LEN,(size_t)1,cgmob); - mobindex = ZERO; - } - fflush(cgmob); - if ( mobremainder && mobparmlen == 0 ) - { - if ( mobremainder > 0x7ffe ) - { - hex = 0xfffe; - mobremainder -= 0x7ffe; - } - else - { - hex = mobremainder; - mobremainder = 0; - } - mobparmlen = hex & 0x7fff; - bytes = 2; - mobparmlen += 2; - goto start; - } -*/ - return; -} diff --git a/src/CGM/cgmochar.c b/src/CGM/cgmochar.c deleted file mode 100755 index b9d38cc7d2..0000000000 --- a/src/CGM/cgmochar.c +++ /dev/null @@ -1,2269 +0,0 @@ -/* - Copyright (c) 1999-2012 OPEN CASCADE SAS - - The content of this file is subject to the Open CASCADE Technology Public - License Version 6.5 (the "License"). You may not use the content of this file - except in compliance with the License. Please obtain a copy of the License - at http://www.opencascade.org and read it completely before using this file. - - The Initial Developer of the Original Code is Open CASCADE S.A.S., having its - main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. - - The Original Code and all software distributed under the License is - distributed on an "AS IS" basis, without warranty of any kind, and the - Initial Developer hereby disclaims all such warranties, including without - limitation, any warranties of merchantability, fitness for a particular - purpose or non-infringement. Please see the License for the specific terms - and conditions governing the rights and limitations under the License. - -*/ - -#include "cgmout.h" - -/* File stream name */ - -extern char cgmroot[]; -static FILE *cgmoc; - -/* declare void internal functions */ - -# if (defined __STDC__ && __STDC__) || defined __cplusplus -/* use function prototypes, they are requred for ANSI C and C++ compilers */ -/* Main Output driver */ -void CGMOchar(FILE *stream, Code c, Long *pi, Float *pr, char *pc); - /* Check Attributes */ -static void MOCchkatt(Code type), -/* Conditional output of integer */ - MOCcint(Code code, Int n, Long *var1, Long *var2), -/* Conditional output of Enumerated types */ - MOCcenum(Code code, int n, Enum *var1, Enum *var2), -/* Conditional output of a real */ - MOCcreal(Code code, Float *var1, Float *var2, Enum r), -/* Conditional output of a colour */ - MOCccol(Code code, int n, struct colour *var1, struct colour *var2), -/* Conditional output of a rectangle */ - MOCrectc(Code code, struct rect *var1, struct rect *var2), -/* Output n VDCs */ - MOCvdc(int n, Long *pi, Float *pr), -/* Output a points list */ - MOCpoints(Long n, Long *pi, Float *pr, Enum set), -/* Output an attribute */ - MOCattrib(Code code), -/* Output a real */ - MOCreal(Double x, Enum type, Prec *ptlist), -/* Output an Integer */ - MOCinteger(Long intval, Logical present, Logical allowed), -/* Output a colour list */ - MOCcells(register Long n, register Long *pi, Enum mode, Prec prec), -/* Output a text string */ - MOCstring(register char *s), -/* Output a direct colour */ - MOCdircol(Posint r, Posint g, Posint b, Prec prec), -/* Check if default colour prec & value are used */ - MOCcoldef(), -/* Output a character to the buffer */ - MOCout(Code hex); -#else -void CGMOchar(); /* Main Output driver */ -static void MOCchkatt(), /* Check Attributes */ - MOCcint(), /* Conditional output of integer */ - MOCcenum(), /* Conditional output of Enumerated types */ - MOCcreal(), /* Conditional output of a real */ - MOCccol(), /* Conditional output of a colour */ - MOCrectc(), /* Conditional output of a rectangle */ - MOCvdc(), /* Output n VDCs */ - MOCpoints(), /* Output a points list */ - MOCattrib(), /* Output an attribute */ - MOCreal(), /* Output a real */ - MOCinteger(), /* Output an Integer */ - MOCcells(), /* Output a colour list */ - MOCstring(), /* Output a text string */ - MOCdircol(), /* Output a direct colour */ - MOCcoldef(), /* Check if default colour prec & value are used */ - MOCout(); /* Output a character to the buffer */ -#endif - -/* Local Variables */ - -static Long subchars=0; -static char charsub[CHARSUBNUM]; - -/*static char *func="CGMochar", mess[40];*/ -static char mess[40]; - -/* Macros to do common comparisons */ - -#define RDIFF(x,y) ( FABS(x-y) > cur.realmin ) -#define VDIFF(x,y) ( FABS(x-y) > cur.vdcmin ) -#define RADIFF(x) ( FABS(oldatt.x-curatt.x) > cur.realmin ) -#define VADIFF(x) ( FABS(oldatt.x-curatt.x) > cur.vdcmin ) - -#define ACINT(x,y) ( MOCcint(x, (Int)1, &oldatt.y, &curatt.y) ) -#define ACENUM(x,y) ( MOCcenum(x, (Int)1, &oldatt.y, &curatt.y) ) -#define ACREAL(x,y,z) ( MOCcreal(x, &oldatt.y, &curatt.y, z) ) -#define ACCOL(x,y) ( MOCccol(x, (Int)1, &oldatt.y, &curatt.y) ) -#define NEWATTRIB(x) ( oldatt.x = curatt.x ) -#define ATTDIFF(x) ( oldatt.x != curatt.x ) -#define PUTINT(x) ( MOCinteger( (Long) x, FALSE, FALSE) ) -#define PUTREAL(x) ( MOCreal( (Double)(x), REAL, (Prec *) NULL) ) -#define PUTVDC(x) ( MOCreal( (Double)(x), VDC, (Prec *) NULL) ) - -/***************************************************** CGMOchar ********/ - -void -CGMOchar(FILE *stream, Code c, Long *pi, Float *pr, char *pc ) -{ - -/* Character encoding Output. stream is output channel - c is MF element code */ - - static Logical first = TRUE, first_pic = TRUE; - static Prec loc_prec; - static Long pic_num = ZERO; - register Long n, j, num; - Code major; - char pcx[STRING_MAX]; - - if ( c == (Code) EOF ) - { - exit(0); - } - - cgmoc = stream; - major = c>>8; - num = *pi++; - - switch (major) - { - case 0x00: /* Graphics Primitives */ - - switch (c) - { - case NONOP: /* Ignore Non-Op */ - break; - - case LINE: /* Polyline */ - if ( first ) - { - MOCchkatt(LINE); - MOCout(c); - } - first = ( num >= ZERO ); - MOCpoints ( num, pi, pr, NOSET); - break; - - case DISJTLINE: /* Disjoint Polyline */ - if ( first ) - { - MOCchkatt(LINE); - MOCout(c); - } - first = ( num >= ZERO ); - MOCpoints ( num, pi, pr, NOSET); - break; - - case MARKER: /* Polymarker */ - if ( first ) - { - MOCchkatt(MARKER); - MOCout(c); - } - first = ( num >= ZERO ); - MOCpoints ( num, pi, pr, NOSET); - break; - - case TEXT: /* Text */ - MOCchkatt(TEXT); - MOCout(c); - MOCvdc ((Int)2, pi, pr); - PUTINT (num); - MOCstring (pc); - break; - - case RESTRTEXT: /* Restricted Text */ - MOCchkatt(TEXT); - MOCout(c); - MOCvdc( (Int)4, pi, pr); - PUTINT (num); - MOCstring (pc); - break; - - case APNDTEXT: /* Append Text */ - MOCchkatt(TEXT); - MOCout(c); - PUTINT (num); - MOCstring (pc); - break; - - case POLYGON: /* Polygon */ - if ( first ) - { - MOCchkatt(POLYGON); - MOCout(c); - } - first = ( num >= ZERO ); - MOCpoints ( num, pi, pr, NOSET); - break; - - case POLYGONSET: /* Polygon Set */ - if ( first ) - { - MOCchkatt(POLYGON); - MOCout(c); - } - first = ( num >= ZERO ); - MOCpoints ( num, pi, pr, SET); - break; - - case CELLARRAY: /* Cell Array */ - if ( first ) - { - MOCout(c); - MOCvdc( (Int)6, pi, pr); - pi +=6; - PUTINT ( *pi++ ); - PUTINT ( *pi++ ); - loc_prec = *pi++; - if ( num > 0 ) - { - register Long max = ZERO, *ppc = pi; - -/* if within a buffer then find maximum colour */ - - n = ( cur.color_mode == INDEXED ? num - : 3*num ); - for ( j = 0; j < n; j++, ppc++ ) - if ( *ppc > max ) max = *ppc; - for ( loc_prec = 0; max ; max >>= 1, loc_prec++ ) - ; - } - PUTINT ( loc_prec); - } - first = ( num >= ZERO ); - MOCcells ( num, pi, cur.color_mode, loc_prec); - break; - - case GDP: /* Generalised Drawing Primitive */ - if ( *pi == -1 ) MOCchkatt(LINE); /* RAL-GKS arc */ - else MOCchkatt(POLYGON); - MOCout(c); - PUTINT ( *pi++ ); - MOCpoints ( num, pi, pr, ZERO); - MOCstring (pc); - break; - - case RECT: /* Rectangle */ - MOCchkatt(POLYGON); - MOCout(c); - MOCvdc( (Int)4, pi, pr); - break; - - default: - (void) sprintf(mess,"(code: 0x%x)",c); - break; - } - break; - - case 0x30: /* Delimiter Elements */ - - switch (c) - { - - case BEGMF: /* Begin Metafile */ - MOCout (c); - -/* Character Substitution */ - - MOCout ( (Code)0x7e3e); /* Tilde 0x7e */ - - MOCout ( (Code)0x7e40); /* Null 0x00*/ - - MOCout ( (Code)0x7e4a); /* Line feed 0x0a */ - MOCout ( (Code)0x7e4d); /* carriage return 0x0d */ - - MOCout (st_term); - -/* now set up substitution list ( without NULL ) */ - charsub[subchars++] = 0x7e; - charsub[subchars++] = 0x0a; - charsub[subchars++] = 0x0d; - - curchar = chardef; - -/* Set old values to current defaults */ - - old = cur; - oldchar = curchar; - oldatt = curatt; - strcpy(pcx, pc); - if ( strcmp (pcx, "") == 0 ) - strcpy(pcx,"Generated with CGM DRIVER"); - MOCstring (pcx); - break; - - case ENDMF: /* End Metafile */ - MOCout (c); - MOCout( (Code)0 ); /* Starts a new record */ - break; - - case BEGPIC: /* Begin Picture Descriptor */ - if ( first_pic ) - { - MOCcoldef (); - mfchar = curchar; - } - else - curchar = mfchar; /* set current character defaults */ - - first_pic = FALSE; - old = cur; /* reset old settings to MF defaults */ - oldchar = curchar; - oldatt = curatt; - - MOCout( (Code)0 ); /* Start on new record */ - MOCout (c); - - if ( strcmp(pc, "\0") ) MOCstring (pc); - else - { - sprintf(pcx, "Picture %ld", pic_num++); - MOCstring (pcx); - } - break; - - case BEGPICBODY: /* Begin Picture Body */ - MOCout (c); - break; - - case ENDPIC: /* End Picture */ - MOCout (c); - break; - - default: - (void) sprintf(mess,"(code 0x%x)",c); - break; - } - break; - - - case 0x31: /* Metafile Descriptor Elements */ - switch (c) - { - case MFVERSION: /* Metafile version */ - MOCout(c); - PUTINT (num); - break; - - case MFDESC: /* Metafile Description */ - MOCout(c); - - MOCstring ( pc ); - - break; - - case VDCTYPE: /* VDC Type */ - MOCcenum (c, (Int)1, &old.vdc_type, &cur.vdc_type); - break; - - case INTEGERPREC: /* Integer Precision */ - curchar.int_prec = cur.int_bits; - MOCcint (c, (Int)1, &oldchar.int_prec, &curchar.int_prec); - break; - - case REALPREC: /* Real Precision */ - curchar.real.prec = cur.real_bits; - curchar.real.min = cur.real_places; - curchar.real.defexp = cur.real_defexp; - if ( curchar.real.defexp > curchar.real.min ) - curchar.real.defexp = curchar.real.min; - curchar.real.expald = cur.real_expald; - - MOCcint (c, (Int)4, &oldchar.real.prec, &curchar.real.prec); - break; - - case INDEXPREC: /* Index Precision */ - curchar.index_prec = cur.index_bits; - MOCcint(c, (Int)1, &oldchar.index_prec, &curchar.index_prec); - break; - - case COLRPREC: /* Colour Precision */ - curchar.col_prec = cur.col_bits; - MOCcint(c, (Int)1, &oldchar.col_prec, &curchar.col_prec); - break; - - case COLRINDEXPREC: /* Colour Index Precision */ - curchar.colind_prec = cur.colind_bits; - MOCcint(c, (Int)1, &oldchar.colind_prec, &curchar.colind_prec); - break; - - case MAXCOLRINDEX: /* Maximum Colour Index */ - MOCcint(c, (Int)1, &old.max_colind, &cur.max_colind); - break; - - case COLRVALUEEXT: /* Colour value extent */ - MOCcint(COLRPREC, (Int)1, &curchar.col_prec, &cur.col_bits); - curchar.min_rgb = cur.min_rgb; - curchar.max_rgb = cur.max_rgb; - MOCccol ( c, (Int)2, &oldchar.min_rgb, &curchar.min_rgb); - break; - - case MFELEMLIST: /* Metafile element List */ - MOCout(c); - MOCout(st_start); - for (j = ZERO; j < num ; j++, pi++ ) - { - switch ( (Int) *pi ) - { - case 0: - case 1: - PUTINT ( *pi ); - break; - - default: - MOCout( (Code) *pi ); - if ( *pi == BEGMFDEFAULTS ) - MOCout ( ENDMFDEFAULTS ); - break; - } - } - MOCout(st_term); - break; - - case BEGMFDEFAULTS: /* Begin Metafile defaults Replacement*/ - MOCcoldef (); - - case ENDMFDEFAULTS: /* End Metafile defaults Replacement */ - MOCout(c); - break; - - case FONTLIST: /* Font List */ - MOCout(c); - for (j = ZERO ; j < num ; ) - { - MOCstring ( &pc[j] ); - j = *pi++; - } - break; - - case CHARSETLIST: /* Character set list */ - MOCout(c); - for ( j = ZERO; j < num ; ) - { - Int b1, b2; - char c1, chr[2]; - - PUTINT ( *pi++ ); - sscanf( &pc[j], "%1d%c%d", &b1, &c1, &b2); - sprintf( chr, "%c", (b1<<4) + b2); - - MOCstring ( chr ); - j = *pi++; - } - break; - - case CHARCODING: /* Character coding Announcer */ - MOCout(c); - PUTINT (num); - break; - - default: - (void) sprintf(mess,"(code: 0x%x)",c); - break; - } - break; - - case 0x32: /* Picture Descriptor Elements */ - switch (c) - { - case SCALEMODE: /* Scaling Mode */ - if (old.scale_mode != cur.scale_mode || - RDIFF(old.scale_factor, cur.scale_factor) ) - { - MOCout(c); - old.scale_mode = cur.scale_mode; - old.scale_factor = cur.scale_factor; - PUTINT ( cur.scale_mode ); - PUTREAL ( cur.scale_factor ); - } - break; - - case COLRMODE: /* Colour Selection Mode */ - MOCcenum(c, (Int)1, &old.color_mode, &cur.color_mode); - break; - - case LINEWIDTHMODE: /* Line width Specification */ - MOCcenum(c, (Int)1, &old.linewidth_mode, &cur.linewidth_mode); - break; - - case MARKERSIZEMODE: /* Marker size Specification */ - MOCcenum(c, (Int)1, &old.markersize_mode, &cur.markersize_mode); - break; - - case EDGEWIDTHMODE: /* Edge width Specification */ - MOCcenum(c, (Int)1, &old.edgewidth_mode, &cur.edgewidth_mode); - break; - - case VDCEXT: /* VDC Extent */ - MOCrectc(c, &old.vdc_extent, &cur.vdc_extent); - break; - - case BACKCOLR: /* Background Colour */ - MOCout ( c ); - MOCdircol ( cur.back.red, cur.back.green, cur.back.blue, - curchar.col_prec); - break; - - default: - (void) sprintf(mess,"(code: 0x%x)",c); - } - break; - - case 0x33: /* Control Elements */ - switch(c) - { - case VDCINTEGERPREC: /* VDC Integer Precision */ - MOCcint(c, (Int)1, &oldchar.vdcint_prec, &curchar.vdcint_prec); - break; - - case VDCREALPREC: /* VDC Real Precision */ - curchar.vdc.prec = cur.vdc_bits; - curchar.vdc.min = cur.vdc_places; - curchar.vdc.defexp = cur.vdc_defexp; - if ( curchar.vdc.defexp > curchar.vdc.min ) - curchar.vdc.defexp = curchar.vdc.min; - curchar.vdc.expald = cur.vdc_expald; - MOCcint(c, (Int)4, &oldchar.vdc.prec, &curchar.vdc.prec); - break; - - case AUXCOLR: /* Auxiliary Colour */ - if (cur.color_mode == DIRECT) - { - MOCccol(c, (Int)1, &old.aux, &cur.aux); - } - else - { - MOCcint(c, (Int)1, &old.aux.index, &cur.aux.index); - } - break; - - case TRANSPARENCY: /* Transparency */ - MOCcenum(c, (Int)1, &old.transparency, &cur.transparency); - break; - - case CLIPRECT: /* Clip Rectangle */ - MOCrectc(c, &old.clip_rect, &cur.clip_rect); - break; - - case CLIP: /* Clip Indicator */ - MOCcenum(c, (Int)1, &old.clip_ind, &cur.clip_ind); - break; - - default: - (void) sprintf(mess,"(code: 0x%x)",c); - break; - } - break; - - case 0x34: /* Circles and Ellipses */ - switch(c) - { - case CIRCLE: /* Circle */ - MOCchkatt(POLYGON); - MOCout(c); - MOCvdc( (Int)3, pi, pr); - break; - - case ARC3PT: /* Circular Arc 3 point */ - MOCchkatt(LINE); - MOCout(c); - MOCvdc( (Int)6, pi, pr); - break; - - case ARC3PTCLOSE: /* Circular Arc 3 point close */ - MOCchkatt(POLYGON); - MOCout(c); - MOCvdc( (Int)6, pi, pr); - PUTINT (*(pi+6)); - break; - - case ARCCTR: /* Circle Arc centre */ - MOCchkatt(LINE); - MOCout(c); - MOCvdc( (Int)7, pi, pr); - break; - - case ARCCTRCLOSE: /* Circle Arc centre close */ - MOCchkatt(POLYGON); - MOCout(c); - MOCvdc( (Int)7, pi, pr); - PUTINT (*(pi+7)); - break; - - case ELLIPSE: /* Ellipse */ - MOCchkatt(POLYGON); - MOCout(c); - MOCvdc( (Int)6, pi, pr); - break; - - case ELLIPARC: /* Elliptical Arc */ - MOCchkatt(LINE); - MOCout(c); - MOCvdc( (Int)10, pi, pr); - break; - - case ELLIPARCCLOSE: /* Elliptical Arc close*/ - MOCchkatt(POLYGON); - MOCout(c); - MOCvdc( (Int)10, pi, pr); - PUTINT (*(pi+10)); - break; - - default: - (void) sprintf(mess,"(code: 0x%x)",c); - break; - } - break; - - case 0x35: /* Attributes */ - - switch(c) - { - case LINEINDEX: /* Line Bundle index */ - att.line_index = TRUE; - break; - - case LINETYPE: /* Line Type */ - att.line_type = TRUE; - break; - - case LINEWIDTH: /* Line Width */ - att.line_width = TRUE; - break; - - case LINECOLR: /* Line Colour */ - att.line_color = TRUE; - break; - - case MARKERINDEX: /* Marker Bundle index */ - att.mark_index = TRUE; - break; - - case MARKERTYPE: /* Marker Type */ - att.mark_type = TRUE; - break; - - case MARKERSIZE: /* Marker Size */ - att.mark_size = TRUE; - break; - - case MARKERCOLR: /* Marker Colour */ - att.mark_color = TRUE; - break; - - case TEXTINDEX: /* Text Bundle index */ - att.text_index = TRUE; - break; - - case TEXTFONTINDEX: /* Text Font Index */ - att.text_font = TRUE; - break; - - case TEXTPREC: /* Text Precision */ - att.text_prec = TRUE; - break; - - case CHAREXPAN: /* Character Expansion Factor */ - att.char_expan = TRUE; - break; - - case CHARSPACE: /* Character Spacing */ - att.char_space = TRUE; - break; - - case TEXTCOLR: /* Text Colour */ - att.text_color = TRUE; - break; - - case CHARHEIGHT: /* Character Height */ - att.char_height = TRUE; - break; - - case CHARORI: /* Character Orientation */ - att.char_orient = TRUE; - break; - - case TEXTPATH: /* Text Path */ - att.text_path = TRUE; - break; - - case TEXTALIGN: /* Text Alignment */ - att.text_align = TRUE; - break; - - case CHARSETINDEX: /* Character Set Index */ - att.char_set = TRUE; - break; - - case ALTCHARSETINDEX: /* Alt Character Set Index */ - att.altchar_set = TRUE; - break; - - default: - (void) sprintf(mess,"(code: 0x%x)",c); - return; - } - if ( cgmstate == MF_DEFAULTS ) MOCattrib ( c ); - break; - - case 0x36: /* More Attributes */ - switch(c) - { - case FILLINDEX: /* Fill Bundle index */ - att.fill_index = TRUE; - break; - - case INTSTYLE: /* Interior Style */ - att.int_style = TRUE; - break; - - case FILLCOLR: /* Fill Colour */ - att.fill_color = TRUE; - break; - - case HATCHINDEX: /* Hatch Index */ - att.hatch_ind = TRUE; - break; - - case PATINDEX: /* Pattern Index */ - att.pat_ind = TRUE; - break; - - case EDGEINDEX: /* Edge Bundle index */ - att.edge_index = TRUE; - break; - - case EDGETYPE: /* Edge Type */ - att.edge_type = TRUE; - break; - - case EDGEWIDTH: /* Edge Width */ - att.edge_width = TRUE; - break; - - case EDGECOLR: /* Edge Colour */ - att.edge_color = TRUE; - break; - - case EDGEVIS: /* Edge Visibility */ - att.edge_vis = TRUE; - break; - - case FILLREFPT: /* Fill Reference Point */ - att.fill_ref = TRUE; - break; - - case PATSIZE: /* Pattern Size */ - att.pat_size = TRUE; - break; - - case PATTABLE: /* Pattern Table */ - if ( first ) - { - register Long max = ZERO; - MOCout(c); - PUTINT ( *pi++ ); - PUTINT ( *pi++ ); - PUTINT ( *pi++ ); - loc_prec = *pi++; - if ( num > 0 ) - { - long *ppc=pi; -/* if within a buffer then find maximum colour */ - - n = ( cur.color_mode == INDEXED ? num - : 3*num ); - for ( j = 0; j < n; j++, ppc++) - if ( *ppc > max ) max = *ppc; - for ( loc_prec = 0; max ; max >>= 1, loc_prec++ ) - ; - } - PUTINT ( loc_prec); - } - first = ( num >= ZERO ); - MOCcells ( num, pi, cur.color_mode, loc_prec); - return; - - case COLRTABLE: /* Colour Table */ - if ( first ) - { - MOCout(c); - PUTINT ( *pi++ ); - } - first = ( num >= ZERO ); - MOCcells ( num, pi, DIRECT, (Prec) 0); - return; - - case ASF: /* Aspect source flags */ - { - short diff = FALSE, type, value, k, l; - -/* First check if any relevant ASF has changed */ - - for ( n = ZERO; n < ASFS ; n++ ) - { - if ( curatt.asf[n] != oldatt.asf[n] ) diff++; - } - if ( diff ) - { - -/* Output ASFs as they were input - ignoring duplicates */ - - MOCout(c); - for ( n = ZERO; n < num ; n++ ) - { - type = (short) (*pi++); - value = (short) (*pi++); - if ( type < ASFS ) - { - if ( value != oldatt.asf[type] ) - { - PUTINT ( type ); - PUTINT ( value ); - oldatt.asf[type] = value; - } - } - else - { - PUTINT ( type ); - PUTINT ( value ); - switch (type) - { - case 506: /* all edge */ - k = 15; - l = 17; - break; - case 507: /* all fill */ - k = 11; - l = 14; - break; - case 508: /* all text */ - k = 6; - l = 10; - break; - case 509: /* all marker */ - k = 3; - l = 5; - break; - case 510: /* all line */ - k = 0; - l = 2; - break; - case 511: /* all */ - k = 0; - l = 17; - break; - default: /* ignore */ - k = 1; - l = 0; - break; - } - for ( ; k <= l; k++) oldatt.asf[k] = value; - } - } - } - return; - - } - default: - (void) sprintf(mess,"(code: 0x%x)",c); - return; - } - if ( cgmstate == MF_DEFAULTS ) MOCattrib ( c ); - break; - - case 0x37: /* Escape And External Elements */ - switch (c) - { - case ESCAPE: /* Escape */ - MOCout(c); - PUTINT (num); - MOCstring (pc); - break; - - case MESSAGE: /* Message */ - MOCout(c); - PUTINT (num); - MOCstring (pc); - break; - - case APPLDATA: /* Application Data */ - MOCout(c); - PUTINT (num); - MOCstring (pc); - break; - - default: - (void) sprintf(mess,"(code: 0x%x)",c); - break; - } - break; - - default: - (void) sprintf(mess,"(code: 0x%x)",c); - break; - } - - return; -} - -/****************************************************** MOCchkatt ******/ -static void -MOCchkatt ( Code type ) -{ -/* Check 'type' Attributes and send to Output if changed */ - - Logical bundled, indiv; - - switch (type) - { - case LINE: - - bundled = (curatt.asf[0] == BUNDLED - || curatt.asf[1] == BUNDLED - || curatt.asf[2] == BUNDLED ); - indiv = (curatt.asf[0] == INDIVIDUAL - || curatt.asf[1] == INDIVIDUAL - || curatt.asf[2] == INDIVIDUAL ); - - if ( bundled && att.line_index) - { - ACINT(LINEINDEX, line_ind); - att.line_index = FALSE; - } - - if ( indiv && att.line_type) - { - ACINT(LINETYPE, line_type); - att.line_type = FALSE; - } - - if ( indiv && att.line_width ) - { - if (cur.linewidth_mode == SCALED) - { - ACREAL(LINEWIDTH, line_width.real, REAL); - } - else if ( cur.vdc_type == REAL) - { - ACREAL(LINEWIDTH, line_width.real, VDC); - } - else - { - ACINT(LINEWIDTH, line_width.intr); - } - att.line_width = FALSE; - } - - if ( indiv && att.line_color ) - { - if (cur.color_mode == DIRECT) - { - ACCOL (LINECOLR, line ); - } - else - { - ACINT(LINECOLR, line.index); - } - att.line_color = FALSE; - } - break; - - case MARKER: - - bundled = (curatt.asf[3] == BUNDLED - || curatt.asf[4] == BUNDLED - || curatt.asf[5] == BUNDLED ); - indiv = (curatt.asf[3] == INDIVIDUAL - || curatt.asf[4] == INDIVIDUAL - || curatt.asf[5] == INDIVIDUAL ); - - if ( bundled && att.mark_index) - { - ACINT(MARKERINDEX, mark_ind); - att.mark_index = FALSE; - } - - if ( indiv && att.mark_type) - { - ACINT(MARKERTYPE, mark_type); - att.mark_type = FALSE; - } - - if ( indiv && att.mark_size ) - { - if (cur.markersize_mode == SCALED) - { - ACREAL(MARKERSIZE, mark_size.real, REAL ); - } - else if ( cur.vdc_type == REAL) - { - ACREAL(MARKERSIZE, mark_size.real, VDC ); - } - else - { - ACINT(MARKERSIZE, mark_size.intr ); - } - att.mark_size = FALSE; - } - - if ( indiv && att.mark_color ) - { - if (cur.color_mode == DIRECT) - { - ACCOL (MARKERCOLR, marker ); - } - else - { - ACINT(MARKERCOLR, marker.index ); - } - att.mark_color = FALSE; - } - break; - - case TEXT: - - bundled = (curatt.asf[6] == BUNDLED - || curatt.asf[7] == BUNDLED - || curatt.asf[8] == BUNDLED - || curatt.asf[9] == BUNDLED - || curatt.asf[10] == BUNDLED ); - indiv = (curatt.asf[6] == INDIVIDUAL - || curatt.asf[7] == INDIVIDUAL - || curatt.asf[8] == INDIVIDUAL - || curatt.asf[9] == INDIVIDUAL - || curatt.asf[10] == INDIVIDUAL ); - - if ( bundled && att.text_index) - { - ACINT(TEXTINDEX, text_ind); - att.text_index = FALSE; - } - - if ( indiv && att.text_font) - { - ACINT(TEXTFONTINDEX, text_font); - att.text_font = FALSE; - } - - if ( indiv && att.text_prec) - { - ACENUM(TEXTPREC, text_prec); - att.text_prec = FALSE; - } - - if ( indiv && att.char_expan) - { - ACREAL(CHAREXPAN, char_exp, REAL ); - att.char_expan = FALSE; - } - - if ( indiv && att.char_space) - { - ACREAL(CHARSPACE, char_space, REAL ); - att.char_space = FALSE; - } - - if ( indiv && att.text_color ) - { - if (cur.color_mode == DIRECT) - { - ACCOL (TEXTCOLR, text ); - } - else - { - ACINT(TEXTCOLR, text.index ); - } - att.text_color = FALSE; - } - - if ( att.char_height) - { - if (cur.vdc_type == REAL) - { - ACREAL(CHARHEIGHT, char_height.real, VDC ); - } - else - { - ACINT(CHARHEIGHT, char_height.intr ); - } - att.char_height = FALSE; - } - - if ( att.char_orient) - { - if (cur.vdc_type == REAL) - { - if ( VADIFF(char_up.x.real) || VADIFF(char_up.y.real) || - VADIFF(char_base.x.real) || VADIFF(char_base.y.real) ) - { - MOCout(CHARORI); - NEWATTRIB (char_up.x.real); - NEWATTRIB (char_up.y.real); - NEWATTRIB (char_base.x.real); - NEWATTRIB (char_base.y.real); - PUTVDC (curatt.char_up.x.real); - PUTVDC (curatt.char_up.y.real); - PUTVDC (curatt.char_base.x.real); - PUTVDC (curatt.char_base.y.real); - } - } - else - { - if ( ATTDIFF(char_up.x.intr) - || ATTDIFF(char_up.y.intr) - || ATTDIFF(char_base.x.intr) - || ATTDIFF(char_base.y.intr) ) - { - MOCout(CHARORI); - NEWATTRIB (char_up.x.intr); - NEWATTRIB (char_up.y.intr); - NEWATTRIB (char_base.x.intr); - NEWATTRIB (char_base.y.intr); - PUTINT (curatt.char_up.x.intr); - PUTINT (curatt.char_up.y.intr); - PUTINT (curatt.char_base.x.intr); - PUTINT (curatt.char_base.y.intr); - } - } - att.char_orient = FALSE; - } - - if ( att.char_set) - { - ACINT(CHARSETINDEX, char_set ); - att.char_set = FALSE; - } - - if ( att.altchar_set) - { - ACINT(ALTCHARSETINDEX, altchar_set ); - att.altchar_set = FALSE; - } - - if ( att.text_path ) - { - ACENUM(TEXTPATH, text_path ); - att.text_path = FALSE; - } - - if ( att.text_align ) - { - if ( ATTDIFF(text_halign) || ATTDIFF(text_valign) || - RADIFF(text_hcont) || RADIFF(text_vcont) ) - { - MOCout(TEXTALIGN); - NEWATTRIB (text_halign); - NEWATTRIB (text_valign); - PUTINT ( curatt.text_halign); - PUTINT ( curatt.text_valign); - NEWATTRIB (text_hcont); - NEWATTRIB (text_vcont); - PUTREAL( curatt.text_hcont ); - PUTREAL( curatt.text_vcont ); - } - att.text_align = FALSE; - } - break; - - case POLYGON: /* Fill and edge attributes */ - - bundled = (curatt.asf[11] == BUNDLED - || curatt.asf[12] == BUNDLED - || curatt.asf[13] == BUNDLED - || curatt.asf[14] == BUNDLED ); - indiv = (curatt.asf[11] == INDIVIDUAL - || curatt.asf[12] == INDIVIDUAL - || curatt.asf[13] == INDIVIDUAL - || curatt.asf[14] == INDIVIDUAL ); - - if ( bundled && att.fill_index) - { - ACINT(FILLINDEX, fill_ind); - att.fill_index = FALSE; - } - - if ( indiv && att.int_style) - { - ACENUM(INTSTYLE, int_style); - att.int_style = FALSE; - } - - if ( indiv && att.hatch_ind ) - { - ACINT(HATCHINDEX, hatch_ind); - att.hatch_ind = FALSE; - } - - if ( indiv && att.pat_ind ) - { - ACINT(PATINDEX, pat_ind); - att.pat_ind = FALSE; - } - - if ( indiv && att.fill_color ) - { - if (cur.color_mode == DIRECT) - { - ACCOL (FILLCOLR, fill ); - } - else - { - ACINT(FILLCOLR, fill.index ); - } - att.fill_color = FALSE; - } - - if ( att.pat_size) - { - if (cur.vdc_type == REAL) - { - if ( VADIFF(pat_size.a.x.real) || VADIFF(pat_size.a.y.real) || - VADIFF(pat_size.b.x.real) || VADIFF(pat_size.b.y.real) ) - { - MOCout(PATSIZE); - NEWATTRIB (pat_size.a.x.real); - NEWATTRIB (pat_size.a.y.real); - NEWATTRIB (pat_size.b.x.real); - NEWATTRIB (pat_size.b.y.real); - PUTVDC (curatt.pat_size.a.x.real); - PUTVDC (curatt.pat_size.a.y.real); - PUTVDC (curatt.pat_size.b.x.real); - PUTVDC (curatt.pat_size.b.y.real); - } - } - else - { - if ( ATTDIFF(pat_size.a.x.intr) || - ATTDIFF(pat_size.a.y.intr) || - ATTDIFF(pat_size.b.x.intr) || - ATTDIFF(pat_size.b.y.intr) ) - { - MOCout(PATSIZE); - NEWATTRIB (pat_size.a.x.intr); - NEWATTRIB (pat_size.a.y.intr); - NEWATTRIB (pat_size.b.x.intr); - NEWATTRIB (pat_size.b.y.intr); - PUTINT (curatt.pat_size.a.x.intr); - PUTINT (curatt.pat_size.a.y.intr); - PUTINT (curatt.pat_size.b.x.intr); - PUTINT (curatt.pat_size.b.y.intr); - } - } - att.pat_size = FALSE; - } - - /* Edge characteristics */ - - bundled = (curatt.asf[15] == BUNDLED - || curatt.asf[16] == BUNDLED - || curatt.asf[17] == BUNDLED ); - indiv = (curatt.asf[15] == INDIVIDUAL - || curatt.asf[16] == INDIVIDUAL - || curatt.asf[17] == INDIVIDUAL ); - - if ( bundled && att.edge_index) - { - ACINT(EDGEINDEX, edge_ind); - att.edge_index = FALSE; - } - - if ( indiv && att.edge_type) - { - ACINT(EDGETYPE, edge_type); - att.edge_type = FALSE; - } - - if ( indiv && att.edge_width ) - { - if (cur.edgewidth_mode == SCALED) - { - ACREAL(EDGEWIDTH, edge_width.real, REAL ); - } - else if ( cur.vdc_type == REAL) - { - ACREAL(EDGEWIDTH, edge_width.real, VDC ); - } - else - { - ACINT(EDGEWIDTH, edge_width.intr ); - } - att.edge_width = FALSE; - } - - if ( indiv && att.edge_color ) - { - if (cur.color_mode == DIRECT) - { - ACCOL (EDGECOLR, edge ); - } - else - { - ACINT(EDGECOLR, edge.index ); - } - att.edge_color = FALSE; - } - - if ( att.edge_vis) - { - ACENUM(EDGEVIS, edge_vis); - att.edge_vis = FALSE; - } - - break; - - default: - (void) sprintf(mess,"(type: 0x%x)", type); - break; - } - - return; -} - -/****************************************************** MOCattrib ******/ -static void -MOCattrib ( Code code ) -{ -/* Outputs attribute code 'code' */ - - MOCout( code ); - - switch ( code ) - { - case LINEINDEX: /* Line Bundle index */ - PUTINT ( curatt.line_ind ); - break; - - case LINETYPE: /* Line Type */ - PUTINT ( curatt.line_type ); - break; - - case LINEWIDTH: /* Line Width */ - if ( cur.linewidth_mode == SCALED ) - PUTREAL ( curatt.line_width.real ); - else if ( cur.vdc_type == REAL ) - PUTVDC ( curatt.line_width.real ); - else - PUTINT ( curatt.line_width.intr ); - break; - - case LINECOLR: /* Line Colour */ - if ( cur.color_mode == DIRECT ) - MOCdircol ( curatt.line.red, curatt.line.green, - curatt.line.blue, curchar.col_prec ); - else - PUTINT ( curatt.line.index ); - break; - - case MARKERINDEX: /* Marker Bundle index */ - PUTINT ( curatt.mark_ind ); - break; - - case MARKERTYPE: /* Marker Type */ - PUTINT ( curatt.mark_type ); - break; - - case MARKERSIZE: /* Marker Size */ - if ( cur.markersize_mode == SCALED ) - PUTREAL ( curatt.mark_size.real ); - else if ( cur.vdc_type == REAL ) - PUTVDC ( curatt.mark_size.real ); - else - PUTINT ( curatt.mark_size.intr ); - break; - - case MARKERCOLR: /* Marker Colour */ - if ( cur.color_mode == DIRECT ) - MOCdircol ( curatt.marker.red, curatt.marker.green, - curatt.marker.blue, curchar.col_prec ); - else - PUTINT ( curatt.marker.index ); - break; - - case TEXTINDEX: /* Text Bundle index */ - PUTINT ( curatt.text_ind ); - break; - - case TEXTFONTINDEX: /* Text Font Index */ - PUTINT ( curatt.text_font ); - break; - - case TEXTPREC: /* Text Precision */ - PUTINT ( curatt.text_prec ); - break; - - case CHAREXPAN: /* Character Expansion Factor */ - PUTREAL ( curatt.char_exp ); - break; - - case CHARSPACE: /* Character Spacing */ - PUTREAL ( curatt.char_space ); - break; - - case TEXTCOLR: /* Text Colour */ - if ( cur.color_mode == DIRECT ) - MOCdircol ( curatt.text.red, curatt.text.green, - curatt.text.blue, curchar.col_prec ); - else - PUTINT ( curatt.text.index ); - break; - - case CHARHEIGHT: /* Character Height */ - if ( cur.vdc_type == REAL ) - PUTVDC ( curatt.char_height.real ); - else - PUTINT ( curatt.char_height.intr ); - break; - - case CHARORI: /* Character Orientation */ - if ( cur.vdc_type == REAL ) - { - PUTREAL ( curatt.char_up.x.real ); - PUTREAL ( curatt.char_up.y.real ); - PUTREAL ( curatt.char_base.x.real ); - PUTREAL ( curatt.char_base.y.real ); - } - else - { - PUTINT ( curatt.char_up.x.intr ); - PUTINT ( curatt.char_up.y.intr ); - PUTINT ( curatt.char_base.x.intr ); - PUTINT ( curatt.char_base.y.intr ); - } - break; - - case TEXTPATH: /* Text Path */ - PUTINT ( curatt.text_path ); - break; - - case TEXTALIGN: /* Text Alignment */ - PUTINT ( curatt.text_halign ); - PUTINT ( curatt.text_valign ); - PUTREAL ( curatt.text_hcont ); - PUTREAL ( curatt.text_vcont ); - break; - - case CHARSETINDEX: /* Character Set Index */ - PUTINT ( curatt.char_set ); - break; - - case ALTCHARSETINDEX: /* Alt Character Set Index */ - PUTINT ( curatt.altchar_set ); - break; - - case FILLINDEX: /* Fill Bundle index */ - PUTINT ( curatt.fill_ind ); - break; - - case INTSTYLE: /* Interior Style */ - PUTINT ( curatt.int_style ); - break; - - case FILLCOLR: /* Fill Colour */ - if ( cur.color_mode == DIRECT ) - MOCdircol ( curatt.fill.red, curatt.fill.green, - curatt.fill.blue, curchar.col_prec ); - else - PUTINT ( curatt.fill.index ); - break; - - case HATCHINDEX: /* Hatch Index */ - PUTINT ( curatt.hatch_ind ); - break; - - case PATINDEX: /* Pattern Index */ - PUTINT ( curatt.pat_ind ); - break; - - case EDGEINDEX: /* Edge Bundle index */ - PUTINT ( curatt.edge_ind ); - break; - - case EDGETYPE: /* Edge Type */ - PUTINT ( curatt.edge_type ); - break; - - case EDGEWIDTH: /* Edge Width */ - if ( cur.edgewidth_mode == SCALED ) - PUTREAL ( curatt.edge_width.real ); - else if ( cur.vdc_type == REAL ) - PUTVDC ( curatt.edge_width.real ); - else - PUTINT ( curatt.edge_width.intr ); - break; - - case EDGECOLR: /* Edge Colour */ - if ( cur.color_mode == DIRECT ) - MOCdircol ( curatt.edge.red, curatt.edge.green, - curatt.edge.blue, curchar.col_prec ); - else - PUTINT ( curatt.edge.index ); - break; - - case EDGEVIS: /* Edge Visibility */ - PUTINT ( curatt.edge_vis ); - break; - - case FILLREFPT: /* Fill Reference Point */ - if ( cur.vdc_type == REAL ) - { - PUTVDC ( curatt.fill_ref.x.real ); - PUTVDC ( curatt.fill_ref.y.real ); - } - else - { - PUTINT ( curatt.fill_ref.x.intr ); - PUTINT ( curatt.fill_ref.y.intr ); - } - break; - - case PATSIZE: /* Pattern Size */ - if ( cur.vdc_type == REAL ) - { - PUTVDC ( curatt.pat_size.a.x.real ); - PUTVDC ( curatt.pat_size.a.y.real ); - PUTVDC ( curatt.pat_size.b.x.real ); - PUTVDC ( curatt.pat_size.b.y.real ); - } - else - { - PUTINT ( curatt.pat_size.a.x.intr ); - PUTINT ( curatt.pat_size.a.y.intr ); - PUTINT ( curatt.pat_size.b.x.intr ); - PUTINT ( curatt.pat_size.b.y.intr ); - } - break; - - default: - (void) sprintf(mess,"(type: 0x%x)", code); - break; - } - - return; -} - -/****************************************************** MOCcint ********/ -static void -MOCcint ( Code code, Int n, Long *var1, Long *var2) -{ -/* Conditionally outputs 'code' and 'n' integers starting at *var2 - only if at least one is different */ - - register Long i; - register Logical diff = FALSE; - - for (i = ZERO; i < n; i++) - if (var1[i] != var2[i]) diff = TRUE; - if (diff) - { - MOCout(code); - for (i = ZERO ; i < n ; i++) - { - PUTINT ( *var2 ); - *var1++ = *var2++; - } - } - return; -} - -/****************************************************** MOCcenum *******/ -static void -MOCcenum (Code code, int n, Enum *var1, Enum *var2 ) -{ -/* Conditionally outputs 'code' and 'n' short integers starting at *var2 - only if at least one is different */ - - register Long i; - register Logical diff = FALSE; - - for (i = ZERO; i < n; i++) - if (var1[i] != var2[i]) diff = TRUE; - if (diff) - { - MOCout(code); - for (i = ZERO ; i < n ; i++) - { - PUTINT ( *var2 ); - *var1++ = *var2++; - } - } - return; -} - -/****************************************************** MOCcreal *******/ -static void -MOCcreal (Code code, Float *var1, Float *var2, Enum r) -{ -/* Conditionally outputs 'code' and real *var2 if different from *var1 - using precision specified by r */ - - if ( FABS(*var1-*var2) > (r == REAL ? cur.realmin : cur.vdcmin) ) - { - MOCout(code); - MOCreal ((Double)*var2, r, null); - *var1 = *var2; - } - return; -} - -/****************************************************** MOCrectc *******/ -static void -MOCrectc( Code code, struct rect *var1, struct rect *var2 ) -{ -/* Conditionally outputs 'code' and 4 VDCs indicated by *var2 - if different from *var1 using vdc precision */ - - if (cur.vdc_type == INTEGER) - { - if ( (*var1).a.x.intr != (*var2).a.x.intr || - (*var1).a.y.intr != (*var2).a.y.intr || - (*var1).b.x.intr != (*var2).b.x.intr || - (*var1).b.y.intr != (*var2).b.y.intr ) - { - MOCout(code); - (*var1).a.x.intr = (*var2).a.x.intr; - PUTINT ( (*var1).a.x.intr ); - (*var1).a.y.intr = (*var2).a.y.intr; - PUTINT ( (*var1).a.y.intr ); - (*var1).b.x.intr = (*var2).b.x.intr; - PUTINT ( (*var1).b.x.intr ); - (*var1).b.y.intr = (*var2).b.y.intr; - PUTINT ( (*var1).b.y.intr ); - } - } - else - { - if ( VDIFF( (*var1).a.x.real, (*var2).a.x.real ) || - VDIFF( (*var1).a.y.real, (*var2).a.y.real ) || - VDIFF( (*var1).b.x.real, (*var2).b.x.real ) || - VDIFF( (*var1).b.y.real, (*var2).b.y.real ) ) - { - MOCout(code); - (*var1).a.x.real = (*var2).a.x.real; - PUTVDC ( (*var2).a.x.real ); - (*var1).a.y.real = (*var2).a.y.real; - PUTVDC ( (*var2).a.y.real ); - (*var1).b.x.real = (*var2).b.x.real; - PUTVDC ( (*var2).b.x.real ); - (*var1).b.y.real = (*var2).b.y.real; - PUTVDC ( (*var2).b.y.real ); - } - } - return; -} - -/****************************************************** MOCccol ********/ -static void -MOCccol (Code code, int n, struct colour *var1, struct colour *var2) -{ -/* Conditional output 'code' and colour indicated by *var2 - if different from colour *var1 */ - - register int i, j; - register Logical diff = FALSE; - - for (i = j = ZERO; i < n; i++, j++ ) - { - if ( (var1[j].red != var2[j].red) || - (var1[j].green != var2[j].green) || - (var1[j].blue != var2[j].blue) ) diff = TRUE; - } - - if (diff) - { - MOCout(code); - for (i = j = ZERO; i < n; i++, j++) - { - var1[j].red = var2[j].red; - var1[j].green = var2[j].green; - var1[j].blue = var2[j].blue; - MOCdircol (var1[j].red, var1[j].green, var1[j].blue, - curchar.col_prec); - } - } - return; -} - -/****************************************************** MOCvdc *********/ -static void -MOCvdc (int n, Long *pi, Float *pr ) -{ -/* Outputs n VDCs starting at pi/pr */ - - register Long j; - - if (cur.vdc_type == REAL) - for ( j = ZERO; j < n; j++) - PUTVDC( *pr++ ); - else - for ( j = ZERO; j < n; j++) - PUTINT ( *pi++ ); - - return; -} - -/****************************************************** MOCpoints ******/ -static void -MOCpoints(Long n, Long *pi, Float *pr, Enum set ) -{ -/* Outputs n points starting at pi/pr - 'set' indicates if this is a Polygon set */ - - static Logical first = TRUE; - static Long ix, iy; - static Long exp_x, exp_y; - static Float xx, yy; - register Long i; - - if ( first ) - { - exp_x = exp_y = curchar.vdc.defexp; - xx = yy = 0.0F; - ix = iy = ZERO; - } - if ( n >= ZERO ) first = TRUE; - else - { - first = FALSE; - n = -n; - } - - if (cur.vdc_type == REAL) - { - for ( i=0; i < n; i++ ) - { - xx += *pr -= xx; - MOCreal ( (Double)*pr++, VDC, &exp_x); - yy += *pr -= yy; - MOCreal ( (Double)*pr++, VDC, &exp_y); - if (set) PUTINT ( *pi++ ); - } - } - else - { - for ( i=0; i < n; i++ ) - { - ix += *pi -= ix; - PUTINT ( *pi++ ); - iy += *pi -= iy; - PUTINT ( *pi++ ); - if ( set) PUTINT ( *pi++ ); - } - } - return; -} - -/****************************************************** MOCreal ********/ -static void -MOCreal ( Double x, Enum type, Prec *ptlist ) -{ -/* Outputs real value 'x', using type 'type' - pointlist indicates if this is part of a pointslist */ - - register Long def_exp, mantissa, expnt; - register Double y, realmin, prec; - register Logical present = ZERO, expald; - - if ( type == REAL ) - { - def_exp = curchar.real.defexp; - realmin = (Double) cur.realmin; - prec = (Double) ( (1L< 0 ? (1L< 0 ? (1L<0 ? x : -x ); - expnt = ZERO; - - if ( y < realmin ) - { - mantissa = ZERO; - } - else - { - if ( expald ) /* if Exponent allowed */ - { - while (y >= prec) - { - y /= (Double) 2.0; - expnt++; - } - while (y < prec) - { - y *= (Double) 2.0; - expnt--; - } - mantissa = (long)y; - - /* Strip off trailing zeros */ - - while ( mantissa && !(mantissa & 0x01) ) - { - mantissa >>= 1; - expnt++; - } - present = (expnt != def_exp); - } - else - { - while (expnt < def_exp) - { - y /= (Double) 2.0; - expnt++; - } - while (expnt > def_exp) - { - y *= (Double) 2.0; - expnt--; - } - mantissa = (long) y; - } - - if ( x < 0.0 ) mantissa = -mantissa; - } - - MOCinteger ( (Long) mantissa, present, expald); - if (present) PUTINT ( expnt ); - - if ( mantissa && (ptlist != NULL) ) *ptlist = expnt; - - return; -} - -/****************************************************** MOCinteger *****/ -static void -MOCinteger (Long intval, Logical present, Logical allowed) -{ -/* Output an integer 'intval', 'present' indicates if exponent present - and 'allowed' if allowed */ - - register Long ival; - register Long i, j; - Code hex[16]; - - ival = abs(intval); - - /* Strip of bits in 5 bit chunks */ - - for (j = -1; ival > ZERO && j < curchar.int_prec; ival >>= 5) - hex[++j] = 0x60 | (ival & 0x1F); - - /* if zero or top bit set or Exponent follows and bit set - then add another byte */ - - if ( (j < ZERO) | ( hex[j] & (1L<<(4-present)) ) | - ( allowed && (hex[j] & 0x18) ) ) hex[++j] = 0x60; - - if (allowed) hex[j] |= present << 3; /* set exponent present bit */ - hex[j] |= (intval++ < ZERO) << 4; /* set sign on first byte */ - hex[0] &= 0x5F; /* set continuation bit off */ - - /* Reverse bits to buffer */ - for (i = j; i >= ZERO; i--) MOCout( hex [i] ); - - return; -} - -/****************************************************** MOCstring ******/ -static void -MOCstring (register char *s) -{ -/* Output a text string 'string' - if CMS translate from EBCDIC to ASCII */ - - register short c; - - MOCout(st_start); - - while ( (c = *s++) != '\0') - MOCout (c); - - MOCout(st_term); - - return; -} - -/****************************************************** MOCcells *******/ -static void -MOCcells (register Long n, register Long *pi, Enum mode, Prec prec) -{ -/* Output a Colour list of 'n' cells, starting at pi - using local precision 'prec' (if zero use current precision) - and colour mode 'mode' */ - - register Long i, j, k, num; - static Logical first = TRUE; - static Long normal_list, bit_stream, run_length, run_bits, colbytes; - Posint red, green, blue, lastred, lastgreen, lastblue; - Logical more; - Long col, last, run, *pi0 = pi; - - more = (n < 0); - num = ( more ? -n : n); - - if ( first ) - { - Long bytes, cols; - -/* if Prec = 0 the use Current precision */ - if ( !prec ) prec = ( mode == INDEXED ? curchar.colind_prec - : curchar.col_prec ); - colbytes = ( mode == INDEXED ? (prec+5)/6 - : (3*prec+5)/6 ); - - normal_list = bit_stream = ZERO; - run_bits = run_length = ZERO; - -/* Work out shortest method of coding list */ - - if ( mode == INDEXED ) - { - cols = 1; - for ( i = ZERO, last = *pi, run = 1 ; i < num; ) - { -/* make sure last value forces an end */ - - col = ( ++i == num ? -1 : *pi++ ); - - if (col == last) run++; - else - { - -/* Work out bytes for run count */ - - for ( j=run, bytes=1; j > 0x0f; bytes++, j>>=5); - run_length += bytes; - run_bits += bytes; - -/* Work out bytes for normal colour value */ - - for ( j=last, bytes=1; j > 0x0f; bytes++, j>>=5); - run_length += bytes; - run_bits += colbytes; - normal_list += run*bytes; - - run = 1; - last = col; - } - } - } - else /* Direct Colour */ - { - cols = 3; - lastred = *pi++; lastgreen = *pi++; lastblue = *pi++; - for ( i = ZERO, run = 1 ; i < num ; ) - { - red = *pi++ ; green = *pi++ ; blue = *pi++; - - if ( ++i != num && red == lastred && green == lastgreen - && blue == lastblue ) - run++; - else - { - for ( j=run , bytes=1; j > 0x0f; bytes++, j>>=5); - normal_list += run*colbytes; - run_length += bytes + colbytes; - run_bits += colbytes; - - run = 1; - lastred = red; lastgreen = green; lastblue = blue; - } - } - } - -/* work out list lengths */ - bit_stream = (cols * num * prec + 5) / 6; - -/* Work out best coding method */ - if ( mode == INDEXED && run_bits < run_length ) run_length = run_bits; - else run_bits = 0; - - if ( run_length < normal_list && run_length < bit_stream ) - { - run_length = TRUE; normal_list = FALSE; bit_stream = FALSE; - i = ( run_bits ? 0x43 : 0x42 ); - } - else if ( bit_stream < normal_list) - { - run_length = FALSE; normal_list = FALSE; bit_stream = TRUE; - i = 0x41; - } - else - { - run_length = FALSE; normal_list = TRUE; bit_stream = FALSE; - i = 0x40; - } - } - -/* Reset continuation marker */ - - if ( first ) MOCout( (Code) i); - first = ( n >= ZERO ); - pi = pi0; - -/* Now send points to Metafile */ - - if ( run_length ) - { - if ( mode == INDEXED ) - { - for ( i = ZERO, last = *pi, run = 1 ; i < num ; ) - { - pi++; - col = ( ++i == num ? -1 : *pi ); - - if (col == last) run++; - else - { - if ( run_bits ) - { - Code byte; - -/* Run length bitstream */ - for ( j = 0, k = prec-6; j < colbytes; j++, k-=6 ) - { - byte = ( k >= 0 ? (last>>k & 0x3f) | 0x40 - : (last<<(-k) & 0x3f) | 0x40 ); - MOCout( byte ); - } - } - else PUTINT ( last ); - - PUTINT ( run ); - run = 1; - last = col; - } - } - } - else /* DIRECT Colour (Run length) */ - { - lastred = *pi++; lastgreen = *pi++; lastblue = *pi++; - for ( i = ZERO, run = 1 ; i < num ; i++ ) - { - last = TRUE; - red = *pi++; green = *pi++; blue = *pi++; - if ( i != num && red == lastred && green == lastgreen - && blue == lastblue ) - { - last = FALSE; - run++; - } - - if ( last ) - { - MOCdircol(lastred, lastgreen, lastblue, prec); - PUTINT ( run ); - run = 1; - lastred = red; lastgreen = green; lastblue = blue; - } - } - } - } - else if ( normal_list ) - { - if ( mode == INDEXED ) - { - for ( i = ZERO ; i < num ; i++ ) - { - PUTINT ( *pi++ ); - } - } - else - for (i = ZERO; i < num ; i++ ) - { - red = *pi++; green = *pi++; blue = *pi++; - MOCdircol ( red, green, blue, prec ); - } - } - else - { - Code byte; - int bits; - - if ( mode == DIRECT ) num *= 3; - - for (i = ZERO, bits = 6, byte = 0x40 ; i < num ; i++ ) - { - col = *pi++; - for ( j = prec - 1 ; j >= ZERO ; j--) - { - byte |= ((col>>j) & 1) <<--bits; - if ( !bits ) - { - MOCout (byte); - bits = 6; - byte = 0x40; - } - } - } - if ( bits < 6 ) MOCout(byte); - } - return; -} - -/****************************************************** MOCdircol ******/ -static void -MOCdircol ( Posint r, Posint g, Posint b, Prec prec ) -{ -/* Output a direct colour (r, g, b) using precision 'prec' */ - - register Long i; - register Code c; - - if (prec & 0x01) - { - /* odd number of bits */ - - r <<= 1; g <<= 1; b <<= 1; - } - else prec--; - -/* if default colour precision convert to 8 bits */ - if ( ! cur.colprec_flag ) - { - r >>= 2; g >>= 2; b >>= 2; - } - for (i = prec; i > ZERO ; i-- ) - { - c = (short) (0x40 | (((r>>i)&1)<<5) | (((g>>i)&1)<<4) | (((b>>i)&1)<<3)); - i--; - c = (short) (c | (((r>>i)&1)<<2) | (((g>>i)&1)<<1) | ((b>>i)&1)); - MOCout( c ); - } - return; -} - -/****************************************************** MOCcoldef ******/ -static void -MOCcoldef () -{ -/* Check if colour precision or Value extent are not set use defaults */ - - if ( ! cur.colprec_flag && cur.col_bits != curchar.col_prec ) - { - curchar.col_prec = cur.col_bits; - MOCout ( COLRPREC ); - PUTINT ( curchar.col_prec ); - } - if ( ! cur.colval_flag && ( cur.min_rgb.red != curchar.min_rgb.red - || cur.min_rgb.green != curchar.min_rgb.green - || cur.min_rgb.blue != curchar.min_rgb.blue - || cur.max_rgb.red != curchar.max_rgb.red - || cur.max_rgb.green != curchar.max_rgb.green - || cur.max_rgb.blue != curchar.max_rgb.blue )) - { - curchar.min_rgb = cur.min_rgb; - curchar.max_rgb = cur.max_rgb; - MOCout ( COLRVALUEEXT ); - MOCdircol ( curchar.min_rgb.red, - curchar.min_rgb.green, - curchar.min_rgb.blue, - curchar.col_prec ); - MOCdircol ( curchar.max_rgb.red, - curchar.max_rgb.green, - curchar.max_rgb.blue, - curchar.col_prec ); - } - return; -} - -/****************************************************** MOCout *********/ -static void -MOCout ( Code hex ) -{ -/* Add character to buffer and Output if buffer is full */ - - register Int bits, j; - register unsigned char c; - static size_t index = ZERO; - static unsigned char buffer[BUFF_LEN+1]; - - bits = ( (hex & 0xff00) > 0 )*8; - - for (; bits >= 0 ; bits -= 8) - { - c = (hex>>bits) & 0xff; - - if ( c <= 0x20 || c >= 0x7e ) - for ( j = 0; j < subchars; j++) - { - if ( c == charsub[j] ) - { - hex ^= c< 0x20 ? c - 0x40 : c + 0x40); - hex |= c< 0 )*8; - - for (; bits >= 0 ; bits -= 8) - { - c = (hex>>bits) & 0xff; - - if ( c <= 0x20 || c >= 0x7e ) - for ( j = 0; j < subchars; j++) - { - if ( c == charsub[j] ) - { - hex ^= c< 0x20 ? c - 0x40 : c + 0x40); - hex |= c<>8; - num = *pi++; - - switch (major) - { - case 0x00: /* Graphics Primitives */ - switch (c) - { - case NONOP: /* Ignore Non-Op */ - break; - - case LINE: /* Polyline */ - if ( first ) MOTprcode ( LINE ); - MOTpoints ( num, pi, pr, NOSET); - first = ( num >= ZERO ); - break; - - case DISJTLINE: /* Disjoint Polyline */ - if ( first ) MOTprcode ( DISJTLINE ); - MOTpoints ( num, pi, pr, NOSET); - first = ( num >= ZERO ); - break; - - case MARKER: /* Polymarker */ - if ( first ) MOTprcode ( MARKER ); - MOTpoints ( num, pi, pr, NOSET); - first = ( num >= ZERO ); - break; - - case TEXT: /* Text */ - MOTprcode ( TEXT ); - MOTpoints ((Long)1, pi, pr, NOSET); - MOTenum("notfinal/final", (Enum) num); - MOTstring ( str ); - break; - - case RESTRTEXT: /* Restricted Text */ - MOTprcode ( RESTRTEXT ); - MOTvdc ((Int)2, pi, pr); - MOTpoints ((Long)1, pi+2, pr+2, NOSET); - MOTenum("notfinal/final", (Enum) num); - MOTstring ( str ); - break; - - case APNDTEXT: /* Append Text */ - MOTprcode ( APNDTEXT ); - MOTenum("notfinal/final", (Enum) num); - MOTstring ( str ); - break; - - case POLYGON: /* Polygon */ - if ( first ) MOTprcode ( POLYGON ); - MOTpoints ( num, pi, pr, NOSET); - first = ( num >= ZERO ); - break; - - case POLYGONSET: /* Polygon Set */ - if ( first ) MOTprcode ( POLYGONSET ); - MOTpoints ( num, pi, pr, SET); - first = ( num >= ZERO ); - break; - - case CELLARRAY: /* Cell Array */ - if ( first ) - { - MOTprcode ( CELLARRAY ); - MOTpoints ((Long)3, pi, pr, NOSET); - pi += 6; - nx = *pi++; - ny = *pi++; - loc_prec = *pi++; - k = ( loc_prec ? ( 1L<= ZERO ); - if ( ! first ) num = -num; - -/* set decimal places and number of elements per line 'k' */ - - prec = (Prec)((loc_prec ? (Double)loc_prec - : (Double)cur.col_bits )*LOG2) + 1; - if ( prec < 2 ) prec = 2; - if ( cur.color_mode == INDEXED ) k = 80L / (prec+1); - else k = 80L / (3*prec+5); - if ( k > nx ) k = nx; - n = nx; i = k; - - for ( j = ZERO; j < num ; j++ ) - { - if ( j ) /* Check for line skip after first pass */ - { - if ( cur.color_mode == DIRECT ) TEXTOUT ","); -/* Line skip if end of row or row count reached */ - if ( j == n || j == i ) - { - TEXTOUT "\n"); - if ( j == n ) - { - n += nx; i = j + k; -/* Extra line skip if row is Longer than one line */ - if ( nx > k ) TEXTOUT "\n"); - } - else i += k; - } - else TEXTOUT " "); - } - if ( cur.color_mode == INDEXED ) - TEXTOUT "%*ld", (int)prec, *pi++); - else - { - TEXTOUT "%*ld %*ld %*ld", - (int)prec, *pi, (int)prec, *(pi+1), (int)prec, *(pi+2)); - pi += (Long)3; - } - } - if ( ! first ) /* Not finished yet */ - { - TEXTOUT "\n"); - if ( nx > k ) TEXTOUT "\n"); - } - break; - - case GDP: /* Generalised Drawing Primitive */ - MOTprcode ( GDP ); - TEXTOUT " %ld ", *pi++); - MOTpoints (num, pi, pr, ZERO); - MOTstring ( str ); - break; - - case RECT: /* Rectangle */ - MOTprcode ( RECT ); - MOTpoints ((Long)2, pi, pr, ZERO); - break; - - default: - (void) sprintf( mess, "(code: 0x%x)", c); - break; - } - break; - - case 0x30: /* Delimiter Elements */ - switch (c) - { - case BEGMF: /* Begin Metafile */ - MOTprcode ( BEGMF ); - MOTstring ( str ); - curtext = textdef; - break; - - case ENDMF: /* End Metafile */ - MOTprcode ( ENDMF ); - break; - - case BEGPIC: /* Begin Picture Descriptor */ - TEXTOUT "\n"); - MOTprcode ( BEGPIC ); - if ( first_pic ) - { - first_pic = FALSE; - mftext = curtext; /* Set MF defaults */ - } - else - curtext = mftext; /* Set Text picture defaults */ - - TEXTOUT "'Picture Number "); - TEXTOUT "%ld'",*pi); - break; - - case BEGPICBODY: /* Begin Picture Body */ - MOTprcode ( BEGPICBODY ); - break; - - case ENDPIC: /* End Picture */ - MOTprcode ( ENDPIC ); - break; - - default: - (void) sprintf( mess, "(code: 0x%x)", c); - break; - } - - - case 0x31: /* Metafile Descriptor Elements */ - switch (c) - { - case MFVERSION: /* Metafile version */ - MOTprcode ( MFVERSION ); - TEXTOUT " %ld", num); - break; - - case MFDESC: /* Metafile Description */ - MOTprcode ( MFDESC ); - MOTstring ( str ); - break; - - case VDCTYPE: /* VDC Type */ - MOTprcode ( VDCTYPE ); - MOTenum ("integer/real",cur.vdc_type); - break; - - case INTEGERPREC: /* Integer Precision */ - MOTprcode ( INTEGERPREC ); - curtext.max_int = (Long) (1L<< (cur.int_bits - 1)) -1; - curtext.min_int = - curtext.max_int - 1; - TEXTOUT " %ld, %ld", curtext.min_int, curtext.max_int); - break; - - case REALPREC: /* Real Precision */ - MOTprcode ( REALPREC ); - curtext.max_real = cur.max_real; - curtext.min_real = cur.min_real; - curtext.real_digits = (long)(1.0 + - (cur.real_bits - cur.real_places) * LOG2); - rp =4; - TEXTOUT " %.*f, %.*f,", rp, (Double)curtext.min_real, - rp,(Double)curtext.max_real); - TEXTOUT " %ld", curtext.real_digits); - break; - - case INDEXPREC: /* Index Precision */ - MOTprcode ( INDEXPREC ); - curtext.max_index = (Long) (1L<<(cur.index_bits - 1)) -1; - curtext.min_index = -curtext.max_index - 1; - TEXTOUT " %ld, %ld", curtext.min_index, curtext.max_index); - break; - - case COLRPREC: /* Colour Precision */ - MOTprcode ( COLRPREC ); - curtext.col_prec = (Long) (1L< 70 ) - { - TEXTOUT "\n%9s", " "); - k = strlen ( &str[j] ) + 4; - } - MOTstring ( &str[j] ); - j = *pi++; - } - break; - - case CHARSETLIST: /* Character set list */ - MOTprcode ( CHARSETLIST ); - for ( j = ZERO; j < num ; ) - { - MOTenum ( "STD94/STD96/STD94MULTIBYTE/STD96MULTIBYTE/COMPLETECODE", (Enum) *pi++); - MOTstring ( &str[j] ); - j = *pi++; - } - break; - - case CHARCODING: /* Character coding Announcer */ - MOTprcode ( CHARCODING ); - MOTenum ("BASIC7BIT/BASIC8BIT/EXTD7BIT/EXTD8BIT", - (Enum) num); - break; - } - break; - - case 0x32: /* Picture Descriptor Elements */ - switch (c) - { - case SCALEMODE: /* Scaling Mode */ - MOTprcode ( SCALEMODE ); - MOTenum ("abstract/metric", cur.scale_mode); - TEXTOUT ", %.*f", rp, (Double)cur.scale_factor); - break; - - case COLRMODE: /* Colour Selection Mode */ - MOTprcode ( COLRMODE ); - MOTenum ("indexed/direct", cur.color_mode); - break; - - case LINEWIDTHMODE: /* Line width Specification */ - MOTprcode ( LINEWIDTHMODE ); - MOTenum ("abs/scaled", cur.linewidth_mode); - break; - - case MARKERSIZEMODE: /* Marker size Specification */ - MOTprcode ( MARKERSIZEMODE ); - MOTenum ("abs/scaled", cur.markersize_mode); - break; - - case EDGEWIDTHMODE: /* Edge width Specification */ - MOTprcode ( EDGEWIDTHMODE ); - MOTenum ("abs/scaled", cur.edgewidth_mode); - break; - - case VDCEXT: /* VDC Extent */ - MOTprcode ( VDCEXT ); - if (cur.vdc_type == REAL) - TEXTOUT " (%.*f,%.*f) (%.*f,%.*f)", - vp, (double)cur.vdc_extent.a.x.real, - vp, (double)cur.vdc_extent.a.y.real, - vp, (double)cur.vdc_extent.b.x.real, - vp, (double)cur.vdc_extent.b.y.real ); - else - TEXTOUT " (%ld,%ld) (%ld,%ld)", - cur.vdc_extent.a.x.intr, - cur.vdc_extent.a.y.intr, - cur.vdc_extent.b.x.intr, - cur.vdc_extent.b.y.intr ); - break; - - case BACKCOLR: /* Background Colour */ - MOTprcode ( BACKCOLR ); - MOTcol(&cur.back, DIRECT); - break; - - default: - (void) sprintf( mess, "(code: 0x%x)", c); - break; - } - break; - - case 0x33: /* Control Elements */ - switch(c) - { - case VDCINTEGERPREC: /* VDC Integer Precision */ - MOTprcode ( VDCINTEGERPREC ); - curtext.max_vdc.intr = (Long) (1L<<(cur.vdcint_bits - 1)) -1; - curtext.min_vdc.intr = (long) (- curtext.max_vdc.intr - 1); - TEXTOUT " %ld, %ld", (long)curtext.min_vdc.intr, - (long)curtext.max_vdc.intr); - TEXTOUT " %ld", cur.vdcint_bits); - break; - - case VDCREALPREC: /* VDC Real Precision */ - MOTprcode ( VDCREALPREC ); - curtext.max_vdc.real = cur.max_vdc; - curtext.min_vdc.real = cur.min_vdc; - curtext.vdc_digits = (long)(1.0 + (cur.vdc_bits - cur.vdc_places) * LOG2); - vp = (long)( cur.vdc_places < 0 ? 1.0-cur.vdc_places*LOG2 : 0); - TEXTOUT " %.*f, %.*f,", vp, (double)curtext.min_vdc.real, - vp, (double)curtext.max_vdc.real); - TEXTOUT " %ld", curtext.vdc_digits); - TEXTOUT " %ld", cur.vdc_bits); - break; - - case AUXCOLR: /* Auxiliary Colour */ - MOTprcode ( AUXCOLR ); - MOTcol(&cur.aux, cur.color_mode); - break; - - case TRANSPARENCY: /* Transparency */ - MOTprcode ( TRANSPARENCY ); - MOTenum ("off/on", cur.transparency); - break; - - case CLIPRECT: /* Clip Rectangle */ - MOTprcode ( CLIPRECT ); - if (cur.vdc_type == REAL) - TEXTOUT " (%.*f,%.*f) (%.*f,%.*f)", - vp, (double)cur.clip_rect.a.x.real, - vp, (double)cur.clip_rect.a.y.real, - vp, (double)cur.clip_rect.b.x.real, - vp, (double)cur.clip_rect.b.y.real ); - else - TEXTOUT " (%ld,%ld) (%ld,%ld)", - cur.clip_rect.a.x.intr, cur.clip_rect.a.y.intr, - cur.clip_rect.b.x.intr, cur.clip_rect.b.y.intr ); - break; - - case CLIP: /* Clip Indicator */ - MOTprcode ( CLIP ); - MOTenum ("off/on", cur.clip_ind); - break; - - default: - (void) sprintf( mess, "(code: 0x%x)", c); - break; - } - break; - - case 0x34: /* Circles and Ellipses */ - switch(c) - { - case CIRCLE: /* Circle */ - MOTprcode ( CIRCLE ); - MOTpoints ((Long)1, pi, pr, ZERO); - MOTvdc ((Int)1, pi+2, pr+2 ); - break; - - case ARC3PT: /* Circular Arc 3 point */ - MOTprcode ( ARC3PT ); - MOTpoints ((Long)3, pi, pr, ZERO); - break; - - case ARC3PTCLOSE: /* Circular Arc 3 point close */ - MOTprcode ( ARC3PTCLOSE ); - MOTpoints ((Long)3, pi, pr, ZERO); - MOTenum ("pie/chord", (Enum) *(pi+6) ); - break; - - case ARCCTR: /* Circle Arc centre */ - MOTprcode ( ARCCTR ); - MOTpoints ((Long)3, pi, pr, ZERO); - MOTvdc ((Int)1, pi+6, pr+6); - break; - - case ARCCTRCLOSE: /* Circle Arc centre close */ - MOTprcode ( ARCCTRCLOSE ); - MOTpoints ((Long)3, pi, pr, ZERO); - MOTvdc((Int)1, pi+6, pr+6); - MOTenum ("pie/chord", (Enum) *(pi+7) ); - break; - - case ELLIPSE: /* Ellipse */ - MOTprcode ( ELLIPSE ); - MOTpoints ((Long)3, pi, pr, ZERO); - break; - - case ELLIPARC: /* Elliptical Arc */ - MOTprcode ( ELLIPARC ); - MOTpoints ((Long)5, pi, pr, ZERO); - break; - - case ELLIPARCCLOSE: /* Elliptical Arc close*/ - MOTprcode ( ELLIPARCCLOSE ); - MOTpoints ((Long)5, pi, pr, ZERO); - MOTenum ("pie/chord", (Enum) *(pi+10) ); - break; - - default: - (void) sprintf( mess, "(code: 0x%x)", c); - break; - } - break; - - case 0x35: /* Attributes */ - switch(c) - { - case LINEINDEX: /* Line Bundle index */ - MOTprcode ( LINEINDEX ); - TEXTOUT " %ld", curatt.line_ind); - break; - - case LINETYPE: /* Line Type */ - MOTprcode ( LINETYPE ); - TEXTOUT " %ld", curatt.line_type); - break; - - case LINEWIDTH: /* Line Width */ - MOTprcode ( LINEWIDTH ); - if (cur.linewidth_mode == SCALED || cur.vdc_type == REAL) - TEXTOUT " %.*f", rp, (double)curatt.line_width.real); - else - TEXTOUT " %ld", curatt.line_width.intr); - break; - - case LINECOLR: /* Line Colour */ - MOTprcode ( LINECOLR ); - MOTcol(&curatt.line, cur.color_mode); - break; - - case MARKERINDEX: /* Marker Bundle index */ - MOTprcode ( MARKERINDEX ); - TEXTOUT " %ld", curatt.mark_ind); - break; - - case MARKERTYPE: /* Marker Type */ - MOTprcode ( MARKERTYPE ); - TEXTOUT " %ld", curatt.mark_type); - break; - - case MARKERSIZE: /* Marker Size */ - MOTprcode ( MARKERSIZE ); - if (cur.markersize_mode == SCALED || cur.vdc_type == REAL) - TEXTOUT " %.*f", rp, (double)curatt.mark_size.real); - else - TEXTOUT " %ld", curatt.mark_size.intr); - break; - - case MARKERCOLR: /* Marker Colour */ - MOTprcode ( MARKERCOLR ); - MOTcol(&curatt.marker, cur.color_mode); - break; - - case TEXTINDEX: /* Text Bundle index */ - MOTprcode ( TEXTINDEX ); - TEXTOUT " %ld", curatt.text_ind); - break; - - case TEXTFONTINDEX: /* Text Font Index */ - MOTprcode ( TEXTFONTINDEX ); - TEXTOUT " %ld", curatt.text_font); - break; - - case TEXTPREC: /* Text Precision */ - MOTprcode ( TEXTPREC ); - MOTenum ("string/char/stroke", curatt.text_prec); - break; - - case CHAREXPAN: /* Character Expansion Factor */ - MOTprcode ( CHAREXPAN ); - TEXTOUT " %.*f", rp, (double)curatt.char_exp); - break; - - case CHARSPACE: /* Character Spacing */ - MOTprcode ( CHARSPACE ); - TEXTOUT " %.*f", rp, (double)curatt.char_space); - break; - - case TEXTCOLR: /* Text Colour */ - MOTprcode ( TEXTCOLR ); - MOTcol(&curatt.text, cur.color_mode); - break; - - case CHARHEIGHT: /* Character Height */ - MOTprcode ( CHARHEIGHT ); - if ( cur.vdc_type == REAL) - TEXTOUT " %.*f", vp, (double)curatt.char_height.real); - else - TEXTOUT " %ld", curatt.char_height.intr); - break; - - case CHARORI: /* Character Orientation */ - MOTprcode ( CHARORI ); - if (cur.vdc_type == REAL) - TEXTOUT " %.*f %.*f, %.*f %.*f", - vp, (double)curatt.char_up.x.real, - vp, (double)curatt.char_up.y.real, - vp, (double)curatt.char_base.x.real, - vp, (double)curatt.char_base.y.real ); - else - TEXTOUT " %ld %ld, %ld %ld", - curatt.char_up.x.intr, - curatt.char_up.y.intr, - curatt.char_base.x.intr, - curatt.char_base.y.intr ); - break; - - case TEXTPATH: /* Text Path */ - MOTprcode ( TEXTPATH ); - MOTenum ("right/left/up/down", curatt.text_path); - break; - - case TEXTALIGN: /* Text Alignment */ - MOTprcode ( TEXTALIGN ); - MOTenum ("normhoriz/left/ctr/right/conthoriz", - curatt.text_halign); - TEXTOUT ", "); - MOTenum ("normvert/top/cap/half/base/bottom/contvert", - curatt.text_valign); - TEXTOUT ", %.*f, %.*f", rp, (double)curatt.text_hcont, - rp, (double)curatt.text_vcont ); - break; - - case CHARSETINDEX: /* Character Set Index */ - MOTprcode ( CHARSETINDEX ); - TEXTOUT " %ld", curatt.char_set); - break; - - case ALTCHARSETINDEX: /* Alternative Character Set Index */ - MOTprcode ( ALTCHARSETINDEX ); - TEXTOUT " %ld", curatt.altchar_set); - break; - - default: - (void) sprintf( mess, "(code: 0x%x)", c); - break; - } - break; - - case 0x36: /* More Attributes */ - switch(c) - { - case FILLINDEX: /* Fill Bundle index */ - MOTprcode ( FILLINDEX ); - TEXTOUT " %ld", curatt.fill_ind); - break; - - case INTSTYLE: /* Interior Style */ - MOTprcode ( INTSTYLE ); - MOTenum ("hollow/solid/pat/hatch/empty",curatt.int_style); - break; - - case FILLCOLR: /* Fill Colour */ - MOTprcode ( FILLCOLR ); - MOTcol(&curatt.fill, cur.color_mode); - break; - - case HATCHINDEX: /* Hatch Index */ - MOTprcode ( HATCHINDEX ); - TEXTOUT " %ld", curatt.hatch_ind); - break; - - case PATINDEX: /* Pattern Index */ - MOTprcode ( PATINDEX ); - TEXTOUT " %ld", curatt.pat_ind); - break; - - case EDGEINDEX: /* Edge Bundle index */ - MOTprcode ( EDGEINDEX ); - TEXTOUT " %ld", curatt.edge_ind); - break; - - case EDGETYPE: /* Edge Type */ - MOTprcode ( EDGETYPE ); - TEXTOUT " %ld", curatt.edge_type); - break; - - case EDGEWIDTH: /* Edge Width */ - MOTprcode ( EDGEWIDTH ); - if (cur.edgewidth_mode == SCALED || cur.vdc_type == REAL) - TEXTOUT " %.*f", rp, (double)curatt.edge_width.real); - else - TEXTOUT " %ld", curatt.edge_width.intr); - break; - - case EDGECOLR: /* Edge Colour */ - MOTprcode ( EDGECOLR ); - MOTcol(&curatt.edge, cur.color_mode); - break; - - case EDGEVIS: /* Edge Visibility */ - MOTprcode ( EDGEVIS ); - MOTenum ("off/on",curatt.edge_vis); - break; - - case FILLREFPT: /* Fill Reference Point */ - MOTprcode ( FILLREFPT ); - if (cur.vdc_type == REAL) - TEXTOUT " (%.*f,%.*f)", vp, (double)curatt.fill_ref.x.real, - vp, (double)curatt.fill_ref.y.real ); - else - TEXTOUT " (%ld,%ld)", curatt.fill_ref.x.intr, - curatt.fill_ref.y.intr ); - break; - - case PATTABLE: /* Pattern Table */ - if ( first ) - { - MOTprcode ( PATTABLE ); - TEXTOUT " %ld,", *pi++); - nx = *pi++; - ny = *pi++; - loc_prec = *pi++; - TEXTOUT " %ld, %ld, %ld\n", - nx, ny, (1L<<(loc_prec-1)) -1); - } - first = (num >= ZERO ); - if (num < ZERO ) num = -num; - prec = (unsigned long) (loc_prec * LOG2 + 1); - if ( prec < 2 ) prec = 2; - if ( cur.color_mode == INDEXED ) k = 80 / (prec+1); - else k = 80 / (3*prec+5); - if ( k > nx ) k = nx; - n = nx; i = k; - - for (j = ZERO; j < num; j++ ) - { - if ( j ) - { - if ( j == k || j == n ) - { - TEXTOUT ",\n"); - k += i; - if ( j == n ) - { - n += nx; k = j + i; - } - } - else TEXTOUT ", "); - } - if ( cur.color_mode == INDEXED ) - TEXTOUT "%*ld", (int)prec, *pi++); - else - { - TEXTOUT "%*ld %*ld %*ld", - (int)prec, *pi, (int)prec, *(pi+1), (int)prec, *(pi+2)); - pi += 3; - } - } - break; - - case PATSIZE: /* Pattern Size */ - MOTprcode ( PATSIZE ); - if (cur.vdc_type == REAL) - TEXTOUT " %.*f %.*f, %.*f %.*f", - vp, (double)curatt.pat_size.a.x.real, - vp, (double)curatt.pat_size.a.y.real, - vp, (double)curatt.pat_size.b.x.real, - vp, (double)curatt.pat_size.b.y.real ); - else - TEXTOUT " %ld %ld, %ld %ld", - curatt.pat_size.a.x.intr, - curatt.pat_size.a.y.intr, - curatt.pat_size.b.x.intr, - curatt.pat_size.b.y.intr ); - break; - - case COLRTABLE: /* Colour Table */ - MOTprcode ( COLRTABLE ); - TEXTOUT " %ld ", *pi++); - for (j = ZERO; j < num ; j++ ) - { - if (j) TEXTOUT ",\n%*s", indent+12," "); - TEXTOUT " %ld %ld %ld", *pi, *(pi+1), *(pi+2)); - pi += 3; - } - break; - - case ASF: /* Aspect source flags */ - MOTprcode ( ASF ); - for (n = ZERO ; n < num ; n ++ ) - { - if ( n ) TEXTOUT ",\n%*s", indent+3, " "); - if ( *pi < ASFS ) - MOTenum ("linetype/linewidth/linecolr/markertype/markersize/markercolr/textfontindex/textprec/charexp/charspace/textcolr/intstyle/fillcolr/hatchindex/patindex/edgetype/edgewidth/edgecolr", (Enum) *pi++); -/* charexp should be changed to charexpan */ - else - MOTenum ("alledge/allfill/alltext/allmarker/allline/all", - (Enum) (*(pi++) - 506) ); - MOTenum ("indiv/bundled", (Enum) *pi++); - } - break; - - default: - (void) sprintf( mess, "(code: 0x%x)", c); - break; - } - break; - - case 0x37: /* Escape And External Elements */ - switch (c) - { - case ESCAPE: /* Escape */ - MOTprcode ( ESCAPE ); - TEXTOUT " %ld ", num); - MOTstring ( str ); - break; - - case MESSAGE: /* Message */ - MOTprcode ( MESSAGE ); - MOTenum ("noaction /action ", (Enum) num); - MOTstring ( str ); - break; - - case APPLDATA: /* Application Data */ - MOTprcode ( APPLDATA ); - TEXTOUT " %ld ", num); - MOTstring ( str ); - break; - - default: - (void) sprintf( mess, "(code: 0x%x)", c); - break; - } - break; - - default: - (void) sprintf( mess, "(code: 0x%x)", c); - break; - } - if ( first && c != NONOP ) TEXTOUT ";\n"); - return; -} - -/******************************************************* MOTpoints *****/ -static void -MOTpoints (Long n, Long *pi, float *pr, Enum set) -{ -/* Output 'n' points starting at pi/pr - 'set' indicates if this is a POLYGONSET */ - - register Long i, k, no; - register int prec; - -/* Set number of points to print on each line */ - - if (cur.vdc_type == REAL) - { - prec = vp; - no = 80 - 2*(prec + 6*set + 5); - } - else - { - prec = (int) (cur.vdcint_bits*LOG2 + 1); - no = 80 - 2*(prec + 6*set + 3); - } - - n = abs(n); - for (i = 0, k = 10 ; i < n ; i++ ) - { - if ( k > no ) - { - TEXTOUT "\n"); - k = 0; - } - if (cur.vdc_type == REAL) - { - k += fprintf(cgmot, " (%.*f,%.*f)", prec, (double)*pr, - prec, (double)*(pr+1)); - pr += 2; - } - else - { - k += fprintf(cgmot, " (%ld,%ld)", *pi, *(pi+1) ); - pi += 2; - } - if (set) - { - MOTenum("invis/vis/closeinvis/closevis", (Enum) *pi++ ); - k += 10; - } - } - return; -} - -/******************************************************* MOTvdc ********/ -static void -MOTvdc (int n, Long *pi, Float *pr) -{ -/* Output 'n' VDCs strating at pi/pr */ - - register Long j, k, no; - register Prec prec; - - if (cur.vdc_type == REAL) - { - prec = vp; - no = 80 / (prec + 5); - } - else - { - prec = (long) (cur.vdcint_bits*LOG2 + 1); - no = 80 / (prec + 3); - } - - for ( j = 0, k = no ; j < n ; j++ ) - { - if (cur.vdc_type == REAL) - TEXTOUT " %.*f ", (int)prec, (double)*pr++ ); - else - TEXTOUT " %ld ", *pi++ ); - if ( !k-- ) - { - TEXTOUT "\n"); - k = no; - } - } - return; -} - -/******************************************************* MOTcol ********/ -static void -MOTcol (struct colour *c, Enum type) -{ -/* Output colour 'c' depending on Color_mode 'type' */ - - if (type == DIRECT) - TEXTOUT " %ld %ld %ld", c->red, c->green, c->blue); - else - TEXTOUT " %ld", c->index); - - return; -} - -/******************************************************* MOTstring *****/ -static void -MOTstring( char *s ) -{ -/* Output text string 's' - if ' then output '' */ - - register Long i; - - TEXTOUT " '"); - for ( i = ZERO; i < (int)strlen(s); i++ ) - { - TEXTOUT "%c", s[i] ); - if ( s[i] == '\'' ) TEXTOUT "'"); - } - TEXTOUT "'"); - return; -} - -/******************************************************* MOTenum *******/ -static void -MOTenum ( char *s, Enum k ) -{ -/* Output enumerated type 'k' using string 's' - enumerated values are seperated by '/' */ - - register Long i = ZERO, j = ZERO, n = k; - - char s1[16]; - -/* Find nth '/' */ - - while ( n-- ) - { - while ( s[i++] != '/' ) - { - if ( ! s[i] ) /* end of string found */ - { - (void) sprintf( mess, "(type: %d)", k); - i = 0; /* defaults to first value */ - n = 0; /* exit loop */ - } - } - } - -/* Extract string into s1 until next '/' or end of string */ - - while ( (s[i] != '/') && s[i] ) s1[j++] = s[i++]; - s1[j] = '\0'; - -/* Print enumerated value */ -TEXTOUT " %s", s1); -return; -} - -/******************************************************* MOTprcode *****/ -static void -MOTprcode ( Code code ) -{ -/* Output Metafile element name 'code ' */ - - register int i, group, index, upcase = FALSE; - static int pos[16] = { 0, 2, 4, 6, 7, 8, 9, 11, 13, 14, 15, - -1, -1, -1, -1, -1}; - char c[16]; - group = code & 0xfff0; - index = code & 0x000f; - switch ( group ) - { - case LINE: - index = pos[index]; - upcase = TRUE; - break; - case CIRCLE: - index += 16; - upcase = TRUE; - break; - case LINEINDEX: - index += 24; - break; - case TEXTINDEX: - index += 32; - break; - case FILLINDEX: - index += 44; - break; - case COLRTABLE: - index += 57; - break; - case VDCINTEGERPREC: - index += 59; - break; - case BEGMF: - index += 65; - upcase = TRUE; - break; - case MFVERSION: - index += 70; - if ( code == BEGMFDEFAULTS || code == ENDMFDEFAULTS ) upcase = TRUE; - break; - case SCALEMODE: - index += 86; - break; - case ESCAPE: - index += 93; - upcase = TRUE; - break; - default: - index = -1; - break; - } - - if ( index >= 0 && code == cgmelement[index].code ) - { - if ( indent ) TEXTOUT "%*s", indent, " " ); - - strcpy(c, cgmelement[index].string); - - if ( ! upcase ) - for ( i = 0; i < (int)strlen(c); i++) c[i] = tolower( c[i] ); - - TEXTOUT "%s", c ); - return; - } - - (void) sprintf(mess, "(code: %x)", code); - return; -} diff --git a/src/CGM/cgmout.h b/src/CGM/cgmout.h deleted file mode 100755 index 6458c25916..0000000000 --- a/src/CGM/cgmout.h +++ /dev/null @@ -1,75 +0,0 @@ -/* - Copyright (c) 1999-2012 OPEN CASCADE SAS - - The content of this file is subject to the Open CASCADE Technology Public - License Version 6.5 (the "License"). You may not use the content of this file - except in compliance with the License. Please obtain a copy of the License - at http://www.opencascade.org and read it completely before using this file. - - The Initial Developer of the Original Code is Open CASCADE S.A.S., having its - main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. - - The Original Code and all software distributed under the License is - distributed on an "AS IS" basis, without warranty of any kind, and the - Initial Developer hereby disclaims all such warranties, including without - limitation, any warranties of merchantability, fitness for a particular - purpose or non-infringement. Please see the License for the specific terms - and conditions governing the rights and limitations under the License. - -*/ - -#ifndef CGMOUT_H -#define CGMOUT_H - -/* Include all files on which this is dependent. */ - -#include "cgmmach.h" -#include "cgmtypes.h" -#include "cgmstruc.h" - -/* Include file that all modules using this file will use. */ - -#include "cgmatt.h" -#include "cgmerr.h" - -/* external structures needed by driver */ - - extern const struct char_defaults chardef; - extern struct char_defaults mfchar, curchar, oldchar; - extern const struct text_defaults textdef; - extern struct text_defaults mftext, curtext; - extern const struct bin_defaults bindef; - extern struct bin_defaults mfbin, curbin; - extern struct defaults cur, old; - extern struct attributes curatt, oldatt; - - extern struct flags att; - - extern Enum cgmdriver; - extern Enum cgmstate; - - extern long *null; - - extern Code st_start, st_term; - -/* Global variable set as arguments for output control */ - - extern Logical cgmralgks, cgmverbose, cgmquiet, cgmEOF, cgmfinished; - -/* Variables for random frame access */ - - extern long cgmnext, cgmpresent, cgmabort; - -/* Structures for font list and character set list */ - - extern struct cgmfont cgmfonts; - extern struct cgmcset cgmcsets; - -/* Macros for common Maths functions */ - -#define REQUAL(x,y) ( FABS((x)-(y)) <= cur.realmin ) -#define VEQUAL(x,y) ( FABS((x)-(y)) <= cur.vdcmin ) -#define PEQUAL(p,q) ( VEQUAL((p)->x, (q)->x) && VEQUAL((p)->y, (q)->y) ) -#define XPROD(a,b,c,d) ( (b->x - a->x)*(d->y - c->y)\ - - (d->x - c->x)*(b->y - a->y) ) -#endif /* end of cgmout.h */ diff --git a/src/CGM/cgmpar.h b/src/CGM/cgmpar.h deleted file mode 100755 index c74b0efcbd..0000000000 --- a/src/CGM/cgmpar.h +++ /dev/null @@ -1,253 +0,0 @@ -/* - Copyright (c) 1999-2012 OPEN CASCADE SAS - - The content of this file is subject to the Open CASCADE Technology Public - License Version 6.5 (the "License"). You may not use the content of this file - except in compliance with the License. Please obtain a copy of the License - at http://www.opencascade.org and read it completely before using this file. - - The Initial Developer of the Original Code is Open CASCADE S.A.S., having its - main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. - - The Original Code and all software distributed under the License is - distributed on an "AS IS" basis, without warranty of any kind, and the - Initial Developer hereby disclaims all such warranties, including without - limitation, any warranties of merchantability, fitness for a particular - purpose or non-infringement. Please see the License for the specific terms - and conditions governing the rights and limitations under the License. - -*/ - -#ifndef CGMPAR_H -#define CGMPAR_H - -/* Include all files on which this is dependent. */ - -#include "cgmtypes.h" - -/* CGM Encodings */ - -#define CHARACTER (Enum) 2 -#define BINARY (Enum) 3 -#define CLEAR_TEXT (Enum) 4 - -/* CGM profiles allowed */ - -#define PROF_CALS (Enum) 1 -#define PROF_GKS (Enum) 2 -#define PROF_INDEXCOL (Enum) 3 -#define PROF_INTVDC (Enum) 4 - -/* CGM Statelists */ - -#define MF_CLOSED (Enum) 0 -#define MF_DESC (Enum) 1 -#define MF_ELEMLIST (Enum) 2 -#define MF_DEFAULTS (Enum) 3 -#define PIC_DESC (Enum) 4 -#define PIC_OPEN (Enum) 5 -#define PIC_CLOSED (Enum) 6 -#define TEXT_OPEN (Enum) 7 - -#if CGMVERSION > 1 -#define SEG_GLOBAL (Enum) 8 -#define SEG_LOCAL (Enum) 9 -#define FIG_OPEN (Enum) 10 -#endif - -/* CGM Enumerated types */ - -#define INTEGER (Enum) 0 -#define REAL (Enum) 1 - -#define ABSTRACT (Enum) 0 -#define METRIC (Enum) 1 - -#define INDEXED (Enum) 0 -#define DIRECT (Enum) 1 - -#define ABS (Enum) 0 -#define ABSOLUTE (Enum) 0 -#define SCALED (Enum) 1 - -#define INDIV (Enum) 0 -#define INDIVIDUAL (Enum) 0 -#define BUNDLED (Enum) 1 - -#define ALLOWED (Enum) 0 -#define FORBIDDEN (Enum) 1 - -#define OFF (Enum) 0 -#define ON (Enum) 1 - -#define NOACTION (Enum) 0 -#define ACTION (Enum) 1 - -/* Enumerated types for text precision */ -#define STRING (Enum) 0 -#define CHAR (Enum) 1 -#define STROKE (Enum) 2 - -/* Enumerated types for Text Path Values */ -#define P_RIGHT (Enum) 0 -#define P_LEFT (Enum) 1 -#define P_UP (Enum) 2 -#define UP (Enum) 2 -#define P_DOWN (Enum) 3 -#define DOWN (Enum) 3 - -/* Enumerated types for Text's Horziontal Alignment */ -#define NORMHORIZ (Enum) 0 -#define LEFT (Enum) 1 -#define CTR (Enum) 2 -#define RIGHT (Enum) 3 -#define CONTHORIZ (Enum) 4 - -/* Enumerated types for Text's Vertical Alignment */ -#define NORMVERT (Enum) 0 -#define TOP (Enum) 1 -#define CAP (Enum) 2 -#define HALF (Enum) 3 -#define BASE (Enum) 4 -#define BOTTOM (Enum) 5 -#define CONTVERT (Enum) 6 - -/* Final text flag */ -#define NOTFINAL (Enum) 0 -#define FINAL (Enum) 1 - -/* Interior styles */ -#define HOLLOW (Enum) 0 -#define SOLID (Enum) 1 -#define PAT (Enum) 2 -#define PATTERN (Enum) 2 -#define HATCH (Enum) 3 -#define EMPTY (Enum) 4 - -/* Closure types */ -#define PIE (Enum) 0 -#define CHORD (Enum) 1 -#define NOCLOSE (Enum) 2 - -/* Polygon set enumerated types */ - -#define EDGEVISIB (Enum) 1 -#define EDGECLOSE (Enum) 2 - -#define INVIS (Enum) 0 -#define VIS (Enum) 1 -#define CLOSEINVIS (EDGECLOSE + INVIS) -#define CLOSEVIS (EDGECLOSE + VIS) - -/* MF element list extra elements */ -#define DRAWINGSET (Enum) 0 -#define DRAWINGSETPLUS (Enum) 1 -#define VER2 (Enum) 2 -#define EXTPRIM (Enum) 3 -#define VER2GKSM (Enum) 4 - - -/* Character sets enumerated types */ -#define STD94 (Enum) 0 -#define STD96 (Enum) 1 -#define STD94MULTIBYTE (Enum) 2 -#define STD96MULTIBYTE (Enum) 3 -#define COMPLETECODE (Enum) 4 - -/* Character coding announcer enumerated types */ -#define BASIC7BIT (Enum) 0 -#define BASIC8BIT (Enum) 1 -#define EXTD7BIT (Enum) 2 -#define EXTD8BIT (Enum) 3 - -/* ASF settings */ - -#define ALL (Enum) 511 -#define ALLLINE (Enum) 510 -#define ALLMARKER (Enum) 509 -#define ALLTEXT (Enum) 508 -#define ALLFILL (Enum) 507 -#define ALLEDGE (Enum) 506 - -/* New Version 2 Enumerated types */ - -#define FRACTION (Enum) 0 -#define MM (Enum) 1 -#define PHYDEVUNITS (Enum) 2 - -#define FORCED (Enum) 0 -#define NOTFORCED (Enum) 2 - -#define LOCUS (Enum) 0 -#define SHAPE (Enum) 1 -#define LOCUSTHENSHAPE (Enum) 2 - -#define NO (Enum) 0 -#define YES (Enum) 1 - -#define STATELIST (Enum) 0 -#define SEGMENT (Enum) 1 -#define INTERSECTION (Enum) 1 - -#define NORMAL (Enum) 0 -#define HIGHLIGHT (Enum) 1 - -/* Element Group names in addition to normal elements */ - -#define LINEATTR (Enum) 35 -#define MARKERATTR (Enum) 36 -#define TEXTATTR (Enum) 37 -#define CHARATTR (Enum) 38 -#define FILLATTR (Enum) 39 -#define EDGEATTR (Enum) 40 -#define PATATTR (Enum) 41 -#define OUTPUTCTRL (Enum) 42 -#define ALLATTRCTRL (Enum) 44 -#define ALLINH (Enum) 45 -#define LINETYPEASF (Enum) 46 -#define LINEWIDTHASF (Enum) 47 -#define LINECOLRASF (Enum) 48 -#define MARKERTYPEASF (Enum) 49 -#define MARKERSIZEASF (Enum) 50 -#define MARKERCOLRASF (Enum) 51 -#define TEXTFONTINDEXASF (Enum) 52 -#define TEXTPRECASF (Enum) 53 -#define CHAREXPANASF (Enum) 54 -#define CHARSPACEASF (Enum) 55 -#define TEXTCOLRASF (Enum) 56 -#define INTSTYLEASF (Enum) 57 -#define FILLCOLRASF (Enum) 58 -#define HATCHINDEXASF (Enum) 59 -#define PATINDEXASF (Enum) 60 -#define EDGETYPEASF (Enum) 61 -#define EDGEWIDTHASF (Enum) 62 -#define EDGECOLRASF (Enum) 63 - -/* Useful local Parameters for enumerated types */ - -#define VDC (Enum) 0 - -#define MULTIPLE FALSE -#define SINGLE TRUE - -#define NOSET (Enum) 0 -#define SET (Enum) 1 - -#define NOP (Enum) 0 -#define NONE (Enum) 0 -#define ANY (Enum) 0 - -/* Number of character substitutions possible */ - -#define CHARSUBNUM (Int) 34 - -/* Mathematical quantities */ - -#ifndef ZERO -#define ZERO (Int) 0 -#endif - -#define LOG2 0.30103 -#define PARABIT 0x40 - -#endif /* end of cgmpar.h */ diff --git a/src/CGM/cgmstruc.h b/src/CGM/cgmstruc.h deleted file mode 100755 index 7162be493c..0000000000 --- a/src/CGM/cgmstruc.h +++ /dev/null @@ -1,175 +0,0 @@ -/* - Copyright (c) 1999-2012 OPEN CASCADE SAS - - The content of this file is subject to the Open CASCADE Technology Public - License Version 6.5 (the "License"). You may not use the content of this file - except in compliance with the License. Please obtain a copy of the License - at http://www.opencascade.org and read it completely before using this file. - - The Initial Developer of the Original Code is Open CASCADE S.A.S., having its - main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. - - The Original Code and all software distributed under the License is - distributed on an "AS IS" basis, without warranty of any kind, and the - Initial Developer hereby disclaims all such warranties, including without - limitation, any warranties of merchantability, fitness for a particular - purpose or non-infringement. Please see the License for the specific terms - and conditions governing the rights and limitations under the License. - -*/ - -#ifndef CGMSTRUCT_H -#define CGMSTRUCT_H - -/* Include all files on which this is dependent. */ - -#include "cgmtypes.h" -#include "cgmelem.h" -#include "cgmpar.h" - -/* Define real precision structure (character encoding) */ - -struct real_prec { - Prec prec, min, defexp, expald; -}; - -/* CGM element codes for clear text input and output */ - -struct commands { - Code code; - char *string; - }; - -/* Encoding Specific defaults */ - -struct char_defaults{ - Prec int_prec, index_prec, vdcint_prec; - struct real_prec real, vdc; - Prec col_prec, colind_prec; - struct colour min_rgb, max_rgb; - long ring_angres, ring_int, ring_real; -}; - -struct text_defaults{ - long min_int, max_int, min_index, max_index; - float min_real, max_real; - Prec real_digits; - struct vdc min_vdc, max_vdc; - Prec vdc_digits, colind_prec, col_prec; - struct colour min_rgb, max_rgb; -}; - -struct bin_defaults{ - Prec int_prec, index_prec, vdcint_prec; - Enum real_type, vdc_type; - Prec real_whole, real_fraction, vdc_whole, vdc_fraction; - Prec col_prec, colind_prec; - struct colour min_rgb, max_rgb; -}; - -struct defaults { - -/* Encoding independent defaults */ - - Index max_colind; - Enum vdc_type, transparency, clip_ind; - Enum color_mode, scale_mode; - float scale_factor; - Enum linewidth_mode, markersize_mode, edgewidth_mode; - struct colour back, aux; - struct rect vdc_extent, clip_rect; - -/* Retain encoding defaults for common access */ - - Prec int_bits, /* integer prec in bits */ - index_bits, /* index prec in bits */ - vdcint_bits, /* vdc integer precision in bits */ - real_bits, /* real prec in bits */ - real_places, /* binary bits after decimal place */ - vdc_bits, /* vdc prec in bits */ - vdc_places, /* binary bits after decimal place */ - col_bits, /* colour prec in bits */ - colind_bits; /* colour index prec in bits */ - float min_real, /* min real value */ - max_real, /* max real value */ - realmin, /* smallest real value */ - min_vdc, /* min real vdc value */ - max_vdc, /* max real vdc value */ - vdcmin; /* smallest vdc real value */ - Prec real_defexp, /* Real default exponent */ - real_expald, /* Real exponenet allowed */ - vdc_defexp, /* VDC default exponent */ - vdc_expald; /* VDC exponenet allowed */ - struct colour min_rgb, /* integer values: index/RGB */ - max_rgb; /* integer values: index/RGB */ - Logical colprec_flag, /* Flag to show if colour precision set */ - colval_flag; /* Flag to show if colour value extent set */ - }; - -/* Graphics attributes */ - -struct attributes { - Index line_ind, mark_ind, text_ind, fill_ind, edge_ind; - Index line_type, mark_type, text_font, edge_type; - struct vdc line_width, mark_size, edge_width; - struct colour line, marker, text, fill, edge; - Enum text_prec, text_path, text_halign, text_valign, edge_vis; - float text_hcont, text_vcont; - Index char_set, altchar_set; - float char_exp, char_space; - struct point char_up, char_base; - struct vdc char_height; - Enum int_style; - Index hatch_ind, pat_ind; - struct point fill_ref; - struct rect pat_size; - Enum asf[ASFS]; -/* Flags for VDC dependent defaults */ - Logical linewidth_flag, markersize_flag, edgewidth_flag, - charheight_flag, cliprect_flag; - }; - - -/* Structure for attribute change flags */ - -struct flags { - Logical line_index, line_type, line_width, line_color; - Logical mark_index, mark_type, mark_size, mark_color; - Logical text_index, text_font, text_prec, char_expan, char_space, - text_color, char_height, char_orient, char_set, - altchar_set, text_path, text_align; - Logical fill_index, int_style, hatch_ind, - pat_ind, pat_size, fill_color, fill_ref; - Logical edge_index, edge_type, edge_width, edge_color, edge_vis; -}; - -/* structure for random frame searching */ - - struct data_frame - { - fpos_t disk_addr; - char *cur_ptr, *end_ptr; - union { - int meta; - int frame; - } index; - }; - - /* Basic data held about CGM character sets and CGM fonts, as - provided in CGM CHARACTERSETLIST and FONTLIST elements. - */ - -struct cgmfont - - { char **names; - int count; - }; - -struct cgmcset - - { char **names; - int *types; - int count; - }; - -#endif /* end of cgmstruc.h */ diff --git a/src/CGM/cgmtypes.h b/src/CGM/cgmtypes.h deleted file mode 100755 index 0c07dc9f86..0000000000 --- a/src/CGM/cgmtypes.h +++ /dev/null @@ -1,87 +0,0 @@ -/* - Copyright (c) 1999-2012 OPEN CASCADE SAS - - The content of this file is subject to the Open CASCADE Technology Public - License Version 6.5 (the "License"). You may not use the content of this file - except in compliance with the License. Please obtain a copy of the License - at http://www.opencascade.org and read it completely before using this file. - - The Initial Developer of the Original Code is Open CASCADE S.A.S., having its - main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. - - The Original Code and all software distributed under the License is - distributed on an "AS IS" basis, without warranty of any kind, and the - Initial Developer hereby disclaims all such warranties, including without - limitation, any warranties of merchantability, fitness for a particular - purpose or non-infringement. Please see the License for the specific terms - and conditions governing the rights and limitations under the License. - -*/ - -#ifndef CGMTYPES_H -#define CGMTYPES_H - - /* Include the only file on which this is dependent. */ - -#include "cgmmach.h" - -/* CGM Typedefs */ - -typedef short Logical; -typedef long Index; -typedef unsigned short Enum; -typedef Int16 Code; -typedef long Prec; -typedef unsigned long Posint; -typedef float Ptype; -typedef double Mtype; - -/* Structures used by CGM user interface */ - -typedef struct { float x, y; } Point; -typedef struct { float x, y; } Vector; -typedef struct { Posint red, green, blue; } RGBcolour; -struct colour { - Index index; - Posint red, green, blue; -}; -typedef struct colour Colour; - -typedef Index Indexcolour; - -/* Useful Structures for CGM routines */ - -struct vdc { - long intr; - float real; -}; -typedef struct vdc Vdc; - -struct colourentry { - float red, green, blue; -}; -typedef struct colourentry Colourentry; - -typedef double Tmatrix[3][2]; - -struct point { - struct vdc x, y; -}; -typedef struct point Cpoint; - -struct rect { - struct point a, b; -}; - -typedef struct { float left, right, top, bot; } Rect; - - -#ifndef TRUE -#define TRUE ((Logical) 1) -#endif - -#ifndef FALSE -#define FALSE ((Logical) 0) -#endif - -#endif /* end of cgmtypes.h */ diff --git a/src/FontMFT/Courier-Bold.mft b/src/FontMFT/Courier-Bold.mft deleted file mode 100755 index 22458b18d9..0000000000 Binary files a/src/FontMFT/Courier-Bold.mft and /dev/null differ diff --git a/src/FontMFT/Courier-BoldItalic.mft b/src/FontMFT/Courier-BoldItalic.mft deleted file mode 100755 index 7b525ba9d2..0000000000 Binary files a/src/FontMFT/Courier-BoldItalic.mft and /dev/null differ diff --git a/src/FontMFT/Courier-Italic.mft b/src/FontMFT/Courier-Italic.mft deleted file mode 100755 index bfa793c778..0000000000 Binary files a/src/FontMFT/Courier-Italic.mft and /dev/null differ diff --git a/src/FontMFT/Courier-Oblique.mft b/src/FontMFT/Courier-Oblique.mft deleted file mode 100755 index 229b2e3b69..0000000000 Binary files a/src/FontMFT/Courier-Oblique.mft and /dev/null differ diff --git a/src/FontMFT/Courier.mft b/src/FontMFT/Courier.mft deleted file mode 100755 index 79ebdb49c7..0000000000 Binary files a/src/FontMFT/Courier.mft and /dev/null differ diff --git a/src/FontMFT/Defaultfont.mft b/src/FontMFT/Defaultfont.mft deleted file mode 100755 index 79ebdb49c7..0000000000 Binary files a/src/FontMFT/Defaultfont.mft and /dev/null differ diff --git a/src/FontMFT/FILES b/src/FontMFT/FILES deleted file mode 100755 index a74d0ddcfd..0000000000 --- a/src/FontMFT/FILES +++ /dev/null @@ -1,37 +0,0 @@ -default:::Courier-Bold.mft -default:::Courier-BoldItalic.mft -default:::Courier-Italic.mft -default:::Courier-Oblique.mft -default:::Courier.mft -default:::Defaultfont.mft -default:::Helvetica-Bold.mft -default:::Helvetica-BoldOblique.mft -default:::Helvetica-Oblique.mft -default:::Helvetica.mft -default:::Helvetica-Medium.mft -default:::Symbol.mft -default:::TABKJ.mft -default:::TABHZ1.mft -default:::TABHZ2.mft -default:::TABHZ3.mft -default:::TABHZ4.mft -default:::TABHZ5.mft -default:::TABHZ6.mft -default:::TABTXT01.mft -default:::TABTXT02.mft -default:::TABTXT03.mft -default:::TABTXT04.mft -default:::TABTXT05.mft -default:::TABTXT06.mft -default:::TABTXT07.mft -default:::TABTXT08.mft -default:::TABTXT15.mft -default:::Times-Bold.mft -default:::Times-BoldItalic.mft -default:::Times-Italic.mft -default:::Times-Roman.mft -default:::Times.mft -default:::Utopia-Bold.mft -default:::Utopia-BoldItalic.mft -default:::Utopia-Italic.mft -default:::Utopia-Regular.mft diff --git a/src/FontMFT/Helvetica-Bold.mft b/src/FontMFT/Helvetica-Bold.mft deleted file mode 100755 index 2fdcc91736..0000000000 Binary files a/src/FontMFT/Helvetica-Bold.mft and /dev/null differ diff --git a/src/FontMFT/Helvetica-BoldOblique.mft b/src/FontMFT/Helvetica-BoldOblique.mft deleted file mode 100755 index 914876a829..0000000000 Binary files a/src/FontMFT/Helvetica-BoldOblique.mft and /dev/null differ diff --git a/src/FontMFT/Helvetica-Medium.mft b/src/FontMFT/Helvetica-Medium.mft deleted file mode 100755 index 559a4dca54..0000000000 Binary files a/src/FontMFT/Helvetica-Medium.mft and /dev/null differ diff --git a/src/FontMFT/Helvetica-Oblique.mft b/src/FontMFT/Helvetica-Oblique.mft deleted file mode 100755 index 67997dc180..0000000000 Binary files a/src/FontMFT/Helvetica-Oblique.mft and /dev/null differ diff --git a/src/FontMFT/Helvetica.mft b/src/FontMFT/Helvetica.mft deleted file mode 100755 index 559a4dca54..0000000000 Binary files a/src/FontMFT/Helvetica.mft and /dev/null differ diff --git a/src/FontMFT/Symbol.mft b/src/FontMFT/Symbol.mft deleted file mode 100755 index d1f846c7b7..0000000000 Binary files a/src/FontMFT/Symbol.mft and /dev/null differ diff --git a/src/FontMFT/TABHZ1.mft b/src/FontMFT/TABHZ1.mft deleted file mode 100755 index b691ad371e..0000000000 Binary files a/src/FontMFT/TABHZ1.mft and /dev/null differ diff --git a/src/FontMFT/TABHZ2.mft b/src/FontMFT/TABHZ2.mft deleted file mode 100755 index 3599104c72..0000000000 Binary files a/src/FontMFT/TABHZ2.mft and /dev/null differ diff --git a/src/FontMFT/TABHZ3.mft b/src/FontMFT/TABHZ3.mft deleted file mode 100755 index 0c18b5ad9d..0000000000 Binary files a/src/FontMFT/TABHZ3.mft and /dev/null differ diff --git a/src/FontMFT/TABHZ4.mft b/src/FontMFT/TABHZ4.mft deleted file mode 100755 index 491194369e..0000000000 Binary files a/src/FontMFT/TABHZ4.mft and /dev/null differ diff --git a/src/FontMFT/TABHZ5.mft b/src/FontMFT/TABHZ5.mft deleted file mode 100755 index 088ee231b4..0000000000 Binary files a/src/FontMFT/TABHZ5.mft and /dev/null differ diff --git a/src/FontMFT/TABHZ6.mft b/src/FontMFT/TABHZ6.mft deleted file mode 100755 index 4c15064ae9..0000000000 Binary files a/src/FontMFT/TABHZ6.mft and /dev/null differ diff --git a/src/FontMFT/TABKJ.mft b/src/FontMFT/TABKJ.mft deleted file mode 100755 index 809bfb58e9..0000000000 Binary files a/src/FontMFT/TABKJ.mft and /dev/null differ diff --git a/src/FontMFT/TABTXT01.mft b/src/FontMFT/TABTXT01.mft deleted file mode 100755 index b42fbff579..0000000000 Binary files a/src/FontMFT/TABTXT01.mft and /dev/null differ diff --git a/src/FontMFT/TABTXT02.mft b/src/FontMFT/TABTXT02.mft deleted file mode 100755 index 0b5110ad89..0000000000 Binary files a/src/FontMFT/TABTXT02.mft and /dev/null differ diff --git a/src/FontMFT/TABTXT03.mft b/src/FontMFT/TABTXT03.mft deleted file mode 100755 index fea2fd0204..0000000000 Binary files a/src/FontMFT/TABTXT03.mft and /dev/null differ diff --git a/src/FontMFT/TABTXT04.mft b/src/FontMFT/TABTXT04.mft deleted file mode 100755 index 7002b40518..0000000000 Binary files a/src/FontMFT/TABTXT04.mft and /dev/null differ diff --git a/src/FontMFT/TABTXT05.mft b/src/FontMFT/TABTXT05.mft deleted file mode 100755 index db7e3e8bbb..0000000000 Binary files a/src/FontMFT/TABTXT05.mft and /dev/null differ diff --git a/src/FontMFT/TABTXT06.mft b/src/FontMFT/TABTXT06.mft deleted file mode 100755 index dc4455fd6d..0000000000 Binary files a/src/FontMFT/TABTXT06.mft and /dev/null differ diff --git a/src/FontMFT/TABTXT07.mft b/src/FontMFT/TABTXT07.mft deleted file mode 100755 index b6b72b75b7..0000000000 Binary files a/src/FontMFT/TABTXT07.mft and /dev/null differ diff --git a/src/FontMFT/TABTXT08.mft b/src/FontMFT/TABTXT08.mft deleted file mode 100755 index 3e343c1b9c..0000000000 Binary files a/src/FontMFT/TABTXT08.mft and /dev/null differ diff --git a/src/FontMFT/TABTXT15.mft b/src/FontMFT/TABTXT15.mft deleted file mode 100755 index 3c8d11878d..0000000000 Binary files a/src/FontMFT/TABTXT15.mft and /dev/null differ diff --git a/src/FontMFT/Times-Bold.mft b/src/FontMFT/Times-Bold.mft deleted file mode 100755 index ae06000dab..0000000000 Binary files a/src/FontMFT/Times-Bold.mft and /dev/null differ diff --git a/src/FontMFT/Times-BoldItalic.mft b/src/FontMFT/Times-BoldItalic.mft deleted file mode 100755 index 61ba1948cb..0000000000 Binary files a/src/FontMFT/Times-BoldItalic.mft and /dev/null differ diff --git a/src/FontMFT/Times-Italic.mft b/src/FontMFT/Times-Italic.mft deleted file mode 100755 index 0a2b88d000..0000000000 Binary files a/src/FontMFT/Times-Italic.mft and /dev/null differ diff --git a/src/FontMFT/Times-Roman.mft b/src/FontMFT/Times-Roman.mft deleted file mode 100755 index de15d468b9..0000000000 Binary files a/src/FontMFT/Times-Roman.mft and /dev/null differ diff --git a/src/FontMFT/Times.mft b/src/FontMFT/Times.mft deleted file mode 100755 index de15d468b9..0000000000 Binary files a/src/FontMFT/Times.mft and /dev/null differ diff --git a/src/FontMFT/Utopia-Bold.mft b/src/FontMFT/Utopia-Bold.mft deleted file mode 100755 index 5132b7d681..0000000000 Binary files a/src/FontMFT/Utopia-Bold.mft and /dev/null differ diff --git a/src/FontMFT/Utopia-BoldItalic.mft b/src/FontMFT/Utopia-BoldItalic.mft deleted file mode 100755 index c1dfc0d812..0000000000 Binary files a/src/FontMFT/Utopia-BoldItalic.mft and /dev/null differ diff --git a/src/FontMFT/Utopia-Italic.mft b/src/FontMFT/Utopia-Italic.mft deleted file mode 100755 index 6fcd807b6e..0000000000 Binary files a/src/FontMFT/Utopia-Italic.mft and /dev/null differ diff --git a/src/FontMFT/Utopia-Regular.mft b/src/FontMFT/Utopia-Regular.mft deleted file mode 100755 index 6f05855b36..0000000000 Binary files a/src/FontMFT/Utopia-Regular.mft and /dev/null differ diff --git a/src/GGraphic2d/FILES b/src/GGraphic2d/FILES deleted file mode 100755 index d04a7854e6..0000000000 --- a/src/GGraphic2d/FILES +++ /dev/null @@ -1,4 +0,0 @@ -FILES -Graphic2d_Curve.hxx -Graphic2d_CurveDefinitionError.hxx -Graphic2d_SetOfCurves.hxx diff --git a/src/GGraphic2d/GGraphic2d.cdl b/src/GGraphic2d/GGraphic2d.cdl deleted file mode 100755 index 5942fc4a30..0000000000 --- a/src/GGraphic2d/GGraphic2d.cdl +++ /dev/null @@ -1,69 +0,0 @@ --- Created on: 1993-06-22 --- Created by: Jean Louis FRENKEL, Gerard Gras. --- Copyright (c) 1993-1999 Matra Datavision --- Copyright (c) 1999-2012 OPEN CASCADE SAS --- --- The content of this file is subject to the Open CASCADE Technology Public --- License Version 6.5 (the "License"). You may not use the content of this file --- except in compliance with the License. Please obtain a copy of the License --- at http://www.opencascade.org and read it completely before using this file. --- --- The Initial Developer of the Original Code is Open CASCADE S.A.S., having its --- main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. --- --- The Original Code and all software distributed under the License is --- distributed on an "AS IS" basis, without warranty of any kind, and the --- Initial Developer hereby disclaims all such warranties, including without --- limitation, any warranties of merchantability, fitness for a particular --- purpose or non-infringement. Please see the License for the specific terms --- and conditions governing the rights and limitations under the License. - - -package GGraphic2d - - ---Version: - - ---Purpose: This package permits the creation of 2d graphic curves - -- and set of curves in a in a visualiser. - -- It moved from the Graphic2d package to this package - -- since it required services from the UL GEOMETRY - -- - - ---Keywords: Drawer, View, Graphic Object, Primitive, Line, - -- Circle, Polyline, Ellips, Curve, Image, Text, HidingText, - -- FramedText, Paragraph - ---Warning: - ---References: - -uses - Graphic2d, - Aspect, - Geom2d, - Image, - MMgt, - gp, - OSD, - Quantity, - TCollection, - TColStd, - TShort, - TColGeom2d - -is - class Curve ; - ---Category: Set of primitive curves - -- - class SetOfCurves; - ---Category: Set Of Graphic primitives - - - ----------------------- - -- Category: Exceptions - ----------------------- - - - exception CurveDefinitionError inherits OutOfRange; - ---Category: Exceptions - -end GGraphic2d; - diff --git a/src/GGraphic2d/GGraphic2d_Curve.cdl b/src/GGraphic2d/GGraphic2d_Curve.cdl deleted file mode 100755 index 2f2c8be81c..0000000000 --- a/src/GGraphic2d/GGraphic2d_Curve.cdl +++ /dev/null @@ -1,86 +0,0 @@ --- Created on: 1993-07-01 --- Created by: Jean Louis FRENKEL --- Copyright (c) 1993-1999 Matra Datavision --- Copyright (c) 1999-2012 OPEN CASCADE SAS --- --- The content of this file is subject to the Open CASCADE Technology Public --- License Version 6.5 (the "License"). You may not use the content of this file --- except in compliance with the License. Please obtain a copy of the License --- at http://www.opencascade.org and read it completely before using this file. --- --- The Initial Developer of the Original Code is Open CASCADE S.A.S., having its --- main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. --- --- The Original Code and all software distributed under the License is --- distributed on an "AS IS" basis, without warranty of any kind, and the --- Initial Developer hereby disclaims all such warranties, including without --- limitation, any warranties of merchantability, fitness for a particular --- purpose or non-infringement. Please see the License for the specific terms --- and conditions governing the rights and limitations under the License. - --- Modified: TCL G002A, 28-11-00, new method GeomCurve(...) - - -class Curve from GGraphic2d inherits Line from Graphic2d - - ---Version: - - ---Purpose: The primitive Curve - - ---Keywords: Primitive, Curve - ---Warning: - ---References: - -uses - Drawer from Graphic2d, - Curve from Geom2d, - GraphicObject from Graphic2d, - FStream from Aspect, - IFStream from Aspect -is - -------------------------------------- - -- Category: Constructors - -------------------------------------- - - Create (aGraphicObject: GraphicObject from Graphic2d; - aCurve: Curve from Geom2d) - returns mutable Curve from GGraphic2d; - ---Level: Public - ---Purpose: Creates a curve. - ---Category: Constructors - - -------------------------------------- - -- Category: Inquire methods - -------------------------------------- - - GeomCurve( me ) returns Curve from Geom2d; - ---Level: Internal - ---Purpose: returns the geometric curve - - -------------------------------------- - -- Category: Draw and Pick - -------------------------------------- - - Draw (me : mutable; aDrawer: Drawer from Graphic2d) - is static protected; - ---Level: Internal - ---Purpose: Draws the curve . - - Pick (me : mutable; X, Y: ShortReal from Standard; - aPrecision: ShortReal from Standard; - aDrawer: Drawer from Graphic2d) - returns Boolean from Standard is static protected; - ---Level: Internal - ---Purpose: Returns Standard_True if the curve is picked, - -- Standard_False if not. - - ---------------------------------------------------------------- - - Save( me; aFStream: in out FStream from Aspect ) is virtual protected; - Retrieve(myclass; anIFStream: in out IFStream from Aspect; - aGraphicObject: GraphicObject from Graphic2d); - -fields - myCurve: Curve from Geom2d; - -end Curve from GGraphic2d; diff --git a/src/GGraphic2d/GGraphic2d_Curve.cxx b/src/GGraphic2d/GGraphic2d_Curve.cxx deleted file mode 100755 index 1faf7b3fd2..0000000000 --- a/src/GGraphic2d/GGraphic2d_Curve.cxx +++ /dev/null @@ -1,486 +0,0 @@ -// Copyright (c) 1999-2012 OPEN CASCADE SAS -// -// The content of this file is subject to the Open CASCADE Technology Public -// License Version 6.5 (the "License"). You may not use the content of this file -// except in compliance with the License. Please obtain a copy of the License -// at http://www.opencascade.org and read it completely before using this file. -// -// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its -// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. -// -// The Original Code and all software distributed under the License is -// distributed on an "AS IS" basis, without warranty of any kind, and the -// Initial Developer hereby disclaims all such warranties, including without -// limitation, any warranties of merchantability, fitness for a particular -// purpose or non-infringement. Please see the License for the specific terms -// and conditions governing the rights and limitations under the License. - -#define WTO0001 //GG_140596 -// Calcul des min-max faux apres transformation. -// G002 TCL : Drawing of descriptor of BSpline and Bezier curves in display mode 1 - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#define MAXPOINTS 1023 -#define VERTEXMARKER 4 -#define DEFAULTMARKERSIZE 3.0 - -static TShort_Array1OfShortReal Xpoint(1,MAXPOINTS); -static TShort_Array1OfShortReal Ypoint(1,MAXPOINTS); - -GGraphic2d_Curve::GGraphic2d_Curve - (const Handle(Graphic2d_GraphicObject)& aGraphicObject, - const Handle(Geom2d_Curve)& aCurve) - : Graphic2d_Line(aGraphicObject) , myCurve(aCurve) { - - Bnd_Box2d Box; - BndLib_Add2dCurve::Add(Geom2dAdaptor_Curve(aCurve),0.,Box); - Standard_Real aXmin, aYmin, aXmax, aYmax; - Box.Get( aXmin, aYmin, aXmax, aYmax); - myMinX = Standard_ShortReal(aXmin); - myMinY = Standard_ShortReal(aYmin); - myMaxX = Standard_ShortReal(aXmax); - myMaxY = Standard_ShortReal(aYmax); -} - -Handle(Geom2d_Curve) GGraphic2d_Curve::GeomCurve() const { - return myCurve; -} - -void GGraphic2d_Curve::Draw (const Handle(Graphic2d_Drawer)& aDrawer) { - - Standard_Boolean IsIn = Standard_False; - - if (! myGOPtr->IsTransformed ()) - IsIn = aDrawer->IsIn (myMinX,myMaxX,myMinY,myMaxY); - else { - Standard_ShortReal minx, miny, maxx, maxy; -#ifdef WTO0001 - MinMax(minx,maxx,miny,maxy); -#else - gp_GTrsf2d aTrsf = myGOPtr->Transform (); - Standard_Real MINX, MINY, MAXX, MAXY; - - MINX = Standard_Real (myMinX); - MINY = Standard_Real (myMinY); - MAXX = Standard_Real (myMaxX); - MAXY = Standard_Real (myMaxY); - aTrsf.Transforms (MINX, MINY); - aTrsf.Transforms (MAXX, MAXY); - minx = Standard_ShortReal (MINX); - miny = Standard_ShortReal (MINY); - maxx = Standard_ShortReal (MAXX); - maxy = Standard_ShortReal (MAXY); -#endif - IsIn = aDrawer->IsIn (minx,maxx,miny,maxy); - } - - if (IsIn) { - switch ( myDisplayMode ) { - case 0: - default: { - - gp_GTrsf2d aTrsf = myGOPtr->Transform (); - - Standard_ShortReal Def; - Standard_ShortReal Coeff; - Aspect_TypeOfDeflection Type; - aDrawer->DrawPrecision(Def,Coeff,Type); - Standard_Boolean Controll = Standard_True; - if (Type == Aspect_TOD_RELATIVE) - Def = ( Abs(myMaxX-myMinX) + Abs(myMaxY-myMinY) ) * Coeff; - Geom2dAdaptor_Curve GAC(myCurve); - GCPnts_UniformDeflection UD(GAC,Def,Controll); - if (UD.IsDone() ) { - Standard_Integer i,j = 1,nbp = UD.NbPoints(); - gp_Pnt p2; - Standard_Real x,y,z; - - while (nbp > 0) { - Standard_Integer n = Min(MAXPOINTS,nbp); - for (i=1; i<=n; i++) { - p2 = UD.Value(j); j++; - p2.Coord(x,y,z); - Xpoint(i) = Standard_ShortReal( x ); - Ypoint(i) = Standard_ShortReal( y ); - } - - if (myGOPtr->IsTransformed ()) { - Standard_Real A, B; - for (i=1; i<=n; i++) { - A = Standard_Real (Xpoint(i)); - B = Standard_Real (Ypoint(i)); - aTrsf.Transforms (A, B); - Xpoint(i) = Standard_ShortReal (A); - Ypoint(i) = Standard_ShortReal (B); - } - } - DrawLineAttrib(aDrawer); - aDrawer->MapPolylineFromTo(Xpoint,Ypoint,n); - nbp -= MAXPOINTS; --j; - } // end while - } // end UD.IsDone - } // end case 0 - break; - case 1: { - if ( myCurve->IsKind(STANDARD_TYPE(Geom2d_BezierCurve) ) ) { - Handle(Geom2d_BezierCurve) theBC = Handle(Geom2d_BezierCurve)::DownCast(myCurve); - TColgp_Array1OfPnt2d thePnts(1, theBC->NbPoles()); - theBC->Poles(thePnts); - TShort_Array1OfShortReal XDpoint(thePnts.Lower(), thePnts.Upper()); - TShort_Array1OfShortReal YDpoint(thePnts.Lower(), thePnts.Upper()); - int i; - for ( i = thePnts.Lower(); i <= thePnts.Upper(); ++i ) { - XDpoint.SetValue( i, Standard_ShortReal( thePnts(i).X() ) ); - YDpoint.SetValue( i, Standard_ShortReal( thePnts(i).Y() ) ); - } - - if ( myGOPtr->IsTransformed() ) { - gp_GTrsf2d aTrsf = myGOPtr->Transform(); - Standard_Real A, B; - for ( i = XDpoint.Lower(); i <= XDpoint.Upper(); ++i ) { - A = Standard_Real(XDpoint(i)); - B = Standard_Real(YDpoint(i)); - aTrsf.Transforms( A, B ); - XDpoint(i) = Standard_ShortReal( A ); - YDpoint(i) = Standard_ShortReal( B ); - } - } - DrawLineAttrib(aDrawer); - aDrawer->MapPolylineFromTo(XDpoint,YDpoint,thePnts.Length()); - - DrawMarkerAttrib(aDrawer); - for ( i = XDpoint.Lower(); i <= XDpoint.Upper(); ++i ) - aDrawer->MapMarkerFromTo(VERTEXMARKER,XDpoint(i),YDpoint(i), DEFAULTMARKERSIZE,DEFAULTMARKERSIZE,0.0); - - } else if ( myCurve->IsKind(STANDARD_TYPE(Geom2d_BSplineCurve) ) ) { - Handle(Geom2d_BSplineCurve) theBC = Handle(Geom2d_BSplineCurve)::DownCast(myCurve); - TColgp_Array1OfPnt2d thePnts(1, theBC->NbPoles()); - theBC->Poles(thePnts); - TShort_Array1OfShortReal XDpoint(thePnts.Lower(), thePnts.Upper()); - TShort_Array1OfShortReal YDpoint(thePnts.Lower(), thePnts.Upper()); - int i; - for ( i = thePnts.Lower(); i <= thePnts.Upper(); ++i ) { - XDpoint.SetValue( i, Standard_ShortReal( thePnts(i).X() ) ); - YDpoint.SetValue( i, Standard_ShortReal( thePnts(i).Y() ) ); - } - - if ( myGOPtr->IsTransformed() ) { - gp_GTrsf2d aTrsf = myGOPtr->Transform(); - Standard_Real A, B; - for ( i = XDpoint.Lower(); i <= XDpoint.Upper(); ++i ) { - A = Standard_Real(XDpoint(i)); - B = Standard_Real(YDpoint(i)); - aTrsf.Transforms( A, B ); - XDpoint(i) = Standard_ShortReal( A ); - YDpoint(i) = Standard_ShortReal( B ); - } - } - DrawLineAttrib(aDrawer); - aDrawer->MapPolylineFromTo(XDpoint,YDpoint,thePnts.Length()); - DrawMarkerAttrib(aDrawer); - for ( i = XDpoint.Lower(); i <= XDpoint.Upper(); ++i ) - aDrawer->MapMarkerFromTo( VERTEXMARKER, XDpoint(i), YDpoint(i), DEFAULTMARKERSIZE, DEFAULTMARKERSIZE, 0.0 ); - } - - } //end case 1 - - } //end switch - } // end IsIn -} - -Standard_Boolean GGraphic2d_Curve::Pick (const Standard_ShortReal X, - const Standard_ShortReal Y, - const Standard_ShortReal aPrecision, - const Handle(Graphic2d_Drawer)& /*aDrawer*/) - -{ -//Standard_ShortReal SRX = X, SRY = Y; -static Standard_ShortReal SRX , SRY ; -SRX = X; -SRY = Y; - -if (IsInMinMax (X, Y, aPrecision)) { - if (myGOPtr->IsTransformed ()) { -gp_GTrsf2d aTrsf = (myGOPtr->Transform ()).Inverted (); -Standard_Real RX = Standard_Real (SRX), RY = Standard_Real (SRY); - aTrsf.Transforms (RX, RY); - SRX = Standard_ShortReal (RX); SRY = Standard_ShortReal (RY); - } - try { - OCC_CATCH_SIGNALS - Geom2dAPI_ProjectPointOnCurve PC(gp_Pnt2d(SRX, SRY), - myCurve, - myCurve->FirstParameter(), - myCurve->LastParameter()); - if(PC.NbPoints() == 0) { - return Standard_False; - } - else { - gp_Pnt2d P = PC.NearestPoint(); - return (( Abs ( SRX - P.X() ) + Abs ( SRY - P.Y() ) ) < aPrecision); - } - - } - catch(Standard_Failure) - { - return Standard_False; - } -} -return Standard_False; //WNT -} - -void GGraphic2d_Curve::Save(Aspect_FStream& aFStream) const -{ - *aFStream << "GGraphic2d_Curve" << endl; - - if ( myCurve->IsKind(STANDARD_TYPE(Geom2d_Line)) ) - { - Handle(Geom2d_Line) theLine = Handle(Geom2d_Line)::DownCast( myCurve ); - gp_Dir2d tDir = theLine->Direction(); - gp_Pnt2d tPnt = theLine->Location(); - - *aFStream << "Geom2d_Line" << endl; - *aFStream << tPnt.X() << ' ' << tPnt.Y() << endl; - *aFStream << tDir.X() << ' ' << tDir.Y() << endl; - } - else if ( myCurve->IsKind(STANDARD_TYPE(Geom2d_Circle)) ) - { - Handle(Geom2d_Circle) theCirc = Handle(Geom2d_Circle)::DownCast( myCurve ); - gp_Circ2d tCirc = theCirc->Circ2d(); - gp_Ax22d tAx22d = tCirc.Axis(); - gp_Pnt2d tLoc = tAx22d.Location(); - gp_Dir2d tDirX = tAx22d.XDirection(), - tDirY = tAx22d.YDirection(); - - Standard_Real tRad = tCirc.Radius(); - - *aFStream << "Geom2d_Circle" << endl; - *aFStream << tRad << endl; - *aFStream << tLoc.X() << ' ' << tLoc.Y() << endl; - *aFStream << tDirX.X() << ' ' << tDirX.Y() << endl; - *aFStream << tDirY.X() << ' ' << tDirY.Y() << endl; - } - else if ( myCurve->IsKind(STANDARD_TYPE(Geom2d_Parabola)) ) - { - Handle(Geom2d_Parabola) theParab = Handle(Geom2d_Parabola)::DownCast( myCurve ); - gp_Parab2d tParab = theParab->Parab2d(); - gp_Ax22d tAx22d = tParab.Axis(); - gp_Pnt2d tLoc = tAx22d.Location(); - gp_Dir2d tDirX = tAx22d.XDirection(), - tDirY = tAx22d.YDirection(); - - Standard_Real tFocal = theParab->Focal(); - - *aFStream << "Geom2d_Parabola" << endl; - *aFStream << tFocal << endl; - *aFStream << tLoc.X() << ' ' << tLoc.Y() << endl; - *aFStream << tDirX.X() << ' ' << tDirX.Y() << endl; - *aFStream << tDirY.X() << ' ' << tDirY.Y() << endl; - } - else if ( myCurve->IsKind(STANDARD_TYPE(Geom2d_Ellipse)) ) - { - Handle(Geom2d_Ellipse) theEllipse = Handle(Geom2d_Ellipse)::DownCast(myCurve); - gp_Elips2d tElips = theEllipse->Elips2d(); - Standard_Real tMin = tElips.MinorRadius(), - tMaj = tElips.MajorRadius(); - gp_Ax22d tAx22d = tElips.Axis(); - gp_Pnt2d tLoc = tAx22d.Location(); - gp_Dir2d tDirX = tAx22d.XDirection(), - tDirY = tAx22d.YDirection(); - - *aFStream << "Geom2d_Ellipse" << endl; - - *aFStream << tMin << ' ' << tMaj << endl; - *aFStream << tLoc.X() << ' ' << tLoc.Y() << endl; - *aFStream << tDirX.X() << ' ' << tDirX.Y() << endl; - *aFStream << tDirY.X() << ' ' << tDirY.Y() << endl; - } - else if ( myCurve->IsKind(STANDARD_TYPE(Geom2d_Hyperbola)) ) - { - Handle(Geom2d_Hyperbola) theHypr = Handle(Geom2d_Hyperbola)::DownCast(myCurve); - gp_Hypr2d tHypr = theHypr->Hypr2d(); - Standard_Real tMin = tHypr.MinorRadius(), - tMaj = tHypr.MajorRadius(); - gp_Ax22d tAx22d = tHypr.Axis(); - gp_Pnt2d tLoc = tAx22d.Location(); - gp_Dir2d tDirX = tAx22d.XDirection(), - tDirY = tAx22d.YDirection(); - - *aFStream << "Geom2d_Hyperbola" << endl; - - *aFStream << tMin << ' ' << tMaj << endl; - *aFStream << tLoc.X() << ' ' << tLoc.Y() << endl; - *aFStream << tDirX.X() << ' ' << tDirX.Y() << endl; - *aFStream << tDirY.X() << ' ' << tDirY.Y() << endl; - } - else if ( myCurve->IsKind(STANDARD_TYPE(Geom2d_BezierCurve)) ) - { - Handle(Geom2d_BezierCurve) theBC = Handle(Geom2d_BezierCurve)::DownCast(myCurve); - Standard_Integer nbPoles = theBC->NbPoles(); - TColgp_Array1OfPnt2d tpoles( 1, nbPoles ); - theBC->Poles( tpoles ); - *aFStream << "Geom2d_BezierCurve" << endl; - *aFStream << nbPoles << endl; - for ( int i = 1; i <= nbPoles; i++ ) - *aFStream << tpoles(i).X() << ' ' << tpoles(i).Y() << endl; - - } - else if ( myCurve->IsKind(STANDARD_TYPE(Geom2d_BSplineCurve)) ) - { -// Handle(Geom2d_BSplineCurve) theBSC = Handle(Geom2d_BSplineCurve)::DownCast(myCurve); - } - else if ( myCurve->IsKind(STANDARD_TYPE(Geom2d_OffsetCurve)) ) - { -// Handle(Geom2d_OffsetCurve) theOC = Handle(Geom2d_OffsetCurve)::DownCast(myCurve); - } - else if ( myCurve->IsKind(STANDARD_TYPE(Geom2d_TrimmedCurve)) ) - { -// Handle(Geom2d_TrimmedCurve) theTC = Handle(Geom2d_TrimmedCurve)::DownCast(myCurve); - } - Graphic2d_Line::Save(aFStream); -} - -void GGraphic2d_Curve::Retrieve(Aspect_IFStream& anIFStream, - const Handle(Graphic2d_GraphicObject)& aGraphicObject) -{ - char buf[100]; - - anIFStream->getline(buf, 100); - if (! strcmp(buf, "Geom2d_Line")) - { - Standard_Real X, Y, dX, dY; - - *anIFStream >> X >> Y; - *anIFStream >> dX >> dY; - gp_Pnt2d tPnt(X, Y); - gp_Dir2d tDir(dX, dY); - Handle(Geom2d_Line) - theLine = new Geom2d_Line(tPnt, tDir); - Handle(GGraphic2d_Curve) - theGGC = new GGraphic2d_Curve(aGraphicObject, theLine); - ((Handle (Graphic2d_Line))theGGC)->Retrieve(anIFStream); - } - else if (! strcmp(buf, "Geom2d_Circle")) - { - Standard_Real tRad, X, Y, dXX, dXY, dYX, dYY; - - *anIFStream >> tRad; - *anIFStream >> X >> Y; - *anIFStream >> dXX >> dXY; - *anIFStream >> dYX >> dYY; - gp_Pnt2d tPnt(X, Y); - gp_Dir2d tDirX(dXX, dXY); - gp_Dir2d tDirY(dYX, dYY); - gp_Ax22d tAx22d(tPnt, tDirX, tDirY); - Handle(Geom2d_Circle) - tCirc = new Geom2d_Circle(tAx22d, tRad); - Handle(GGraphic2d_Curve) - theGGC = new GGraphic2d_Curve(aGraphicObject, tCirc); - ((Handle (Graphic2d_Line))theGGC)->Retrieve(anIFStream); - } - else if (! strcmp(buf, "Geom2d_Parabola")) - { - Standard_Real tFocal, X, Y, dXX, dXY, dYX, dYY; - - *anIFStream >> tFocal; - *anIFStream >> X >> Y; - *anIFStream >> dXX >> dXY; - *anIFStream >> dYX >> dYY; - gp_Pnt2d tPnt(X, Y); - gp_Dir2d tDirX(dXX, dXY); - gp_Dir2d tDirY(dYX, dYY); - gp_Ax22d tAx22d(tPnt, tDirX, tDirY); - Handle(Geom2d_Parabola) - gp_Parab2d = new Geom2d_Parabola(tAx22d, tFocal); - Handle(GGraphic2d_Curve) - theGGC = new GGraphic2d_Curve(aGraphicObject, gp_Parab2d); - ((Handle (Graphic2d_Line))theGGC)->Retrieve(anIFStream); - } - else if (! strcmp(buf, "Geom2d_Ellipse")) - { - Standard_Real tMin, tMaj, X, Y, dXX, dXY, dYX, dYY; - - *anIFStream >> tMin >> tMaj; - *anIFStream >> X >> Y; - *anIFStream >> dXX >> dXY; - *anIFStream >> dYX >> dYY; - gp_Pnt2d tPnt(X, Y); - gp_Dir2d tDirX(dXX, dXY); - gp_Dir2d tDirY(dYX, dYY); - gp_Ax22d tAx22d(tPnt, tDirX, tDirY); - Handle(Geom2d_Ellipse) - theEllipse = new Geom2d_Ellipse(tAx22d, tMaj, tMin); - Handle(GGraphic2d_Curve) - theGGC = new GGraphic2d_Curve(aGraphicObject, theEllipse); - ((Handle (Graphic2d_Line))theGGC)->Retrieve(anIFStream); - } - else if (! strcmp(buf, "Geom2d_Hyperbola")) - { - Standard_Real tMin, tMaj, X, Y, dXX, dXY, dYX, dYY; - - *anIFStream >> tMin >> tMaj; - *anIFStream >> X >> Y; - *anIFStream >> dXX >> dXY; - *anIFStream >> dYX >> dYY; - gp_Pnt2d tPnt(X, Y); - gp_Dir2d tDirX(dXX, dXY); - gp_Dir2d tDirY(dYX, dYY); - gp_Ax22d tAx22d(tPnt, tDirX, tDirY); - Handle(Geom2d_Hyperbola) - theHypr = new Geom2d_Hyperbola(tAx22d, tMaj, tMin); - Handle(GGraphic2d_Curve) - theGGC = new GGraphic2d_Curve(aGraphicObject, theHypr); - ((Handle (Graphic2d_Line))theGGC)->Retrieve(anIFStream); - } - else if (! strcmp(buf, "Geom2d_BezierCurve")) - { - Standard_Integer numPoles; - Standard_Real X, Y; - - *anIFStream >> numPoles; - TColgp_Array1OfPnt2d listPoles(1, numPoles); - for (Standard_Integer i=1; i<=numPoles; i++) - { - *anIFStream >> X >> Y; - listPoles.SetValue(i, gp_Pnt2d(X, Y)); - } - Handle(Geom2d_BezierCurve) - theBC = new Geom2d_BezierCurve(listPoles); - Handle(GGraphic2d_Curve) - theGGC = new GGraphic2d_Curve(aGraphicObject, theBC); - ((Handle (Graphic2d_Line))theGGC)->Retrieve(anIFStream); - } - else if (! strcmp(buf, "Geom2d_BSplineCurve")) - ; - else if (! strcmp(buf, "Geom2d_OffsetCurve")) - ; - else if (! strcmp(buf, "Geom2d_TrimmedCurve")) - ; - else - {} -} diff --git a/src/GGraphic2d/GGraphic2d_SetOfCurves.cdl b/src/GGraphic2d/GGraphic2d_SetOfCurves.cdl deleted file mode 100755 index 21a9e8d919..0000000000 --- a/src/GGraphic2d/GGraphic2d_SetOfCurves.cdl +++ /dev/null @@ -1,117 +0,0 @@ --- Created on: 1995-09-21 --- Created by: Gerard GRAS --- Copyright (c) 1995-1999 Matra Datavision --- Copyright (c) 1999-2012 OPEN CASCADE SAS --- --- The content of this file is subject to the Open CASCADE Technology Public --- License Version 6.5 (the "License"). You may not use the content of this file --- except in compliance with the License. Please obtain a copy of the License --- at http://www.opencascade.org and read it completely before using this file. --- --- The Initial Developer of the Original Code is Open CASCADE S.A.S., having its --- main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. --- --- The Original Code and all software distributed under the License is --- distributed on an "AS IS" basis, without warranty of any kind, and the --- Initial Developer hereby disclaims all such warranties, including without --- limitation, any warranties of merchantability, fitness for a particular --- purpose or non-infringement. Please see the License for the specific terms --- and conditions governing the rights and limitations under the License. - --- Modified: TCL_G002 adds new draw methods DrawElement(...) and DrawVertex(...) - - -class SetOfCurves from GGraphic2d inherits Line from Graphic2d - - ---Version: - - ---Purpose: The primitive SetOfCurves - - ---Keywords: Primitive, Curve - ---Warning: This primitive must be use as possible for performance - -- improvment but is drawn with a global line attributes - -- for all the set. - -- NOTE: than the method PickedIndex() permits to known - -- the last picked curve in the set. - ---References: - -uses - Drawer from Graphic2d, - GraphicObject from Graphic2d, - SequenceOfCurve from TColGeom2d, - Length from Quantity, - Curve from Geom2d, - SequenceOfShortReal from TShort, - FStream from Aspect - -raises - CurveDefinitionError from GGraphic2d, - OutOfRange from Standard - -is - ------------------------- - -- Category: Constructors - ------------------------- - - Create (aGraphicObject: GraphicObject from Graphic2d) - returns mutable SetOfCurves from GGraphic2d; - ---Level: Public - ---Purpose: Creates an empty set of curves in the graphic - -- object . - ---Category: Constructors - - Add(me : mutable; aCurve: Curve from Geom2d); - ---Level: Public - ---Purpose: Add a curve in the set - ---Category: Update method - - Length(me) returns Integer from Standard; - ---Level: Public - ---Purpose: Returns the number of curves in the set. - ---Category: Inquiry method - - Values(me; aRank: Integer from Standard) returns Curve from Geom2d - ---Level: Public - ---Purpose: Returns the curve of rank from the set. - ---Trigger: Raises OutOfRange if is <1 or >Length() - raises OutOfRange from Standard; - ---Category: Inquiry method - - -------------------------- - -- Category: Draw and Pick - -------------------------- - - Draw (me : mutable; aDrawer: Drawer from Graphic2d) - is static protected; - ---Level: Internal - ---Purpose: Draws the set of curves . - - DrawElement( me : mutable; aDrawer: Drawer from Graphic2d; - anIndex: Integer from Standard) - is redefined protected; - ---Level: Internal - ---Purpose: Draws element of the set . - - DrawVertex( me : mutable; aDrawer: Drawer from Graphic2d; - anIndex: Integer from Standard) - is redefined protected; - ---Level: Internal - ---Purpose: Draws vertex of the set . - - Pick (me : mutable; X, Y: ShortReal from Standard; - aPrecision: ShortReal from Standard; - aDrawer: Drawer from Graphic2d) - returns Boolean from Standard - is static protected; - ---Level: Internal - ---Purpose: Returns Standard_True if one curve of the set - -- is picked, Standard_False if not. - ---Warning: The PickIndex() method returns the rank of the picked - -- curve if any. - - Save( me; aFStream: in out FStream from Aspect ) is virtual protected; - -fields - myCurves: SequenceOfCurve from TColGeom2d; - -end SetOfCurves from GGraphic2d; diff --git a/src/GGraphic2d/GGraphic2d_SetOfCurves.cxx b/src/GGraphic2d/GGraphic2d_SetOfCurves.cxx deleted file mode 100755 index 11eacbaf1a..0000000000 --- a/src/GGraphic2d/GGraphic2d_SetOfCurves.cxx +++ /dev/null @@ -1,478 +0,0 @@ -// Copyright (c) 1999-2012 OPEN CASCADE SAS -// -// The content of this file is subject to the Open CASCADE Technology Public -// License Version 6.5 (the "License"). You may not use the content of this file -// except in compliance with the License. Please obtain a copy of the License -// at http://www.opencascade.org and read it completely before using this file. -// -// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its -// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. -// -// The Original Code and all software distributed under the License is -// distributed on an "AS IS" basis, without warranty of any kind, and the -// Initial Developer hereby disclaims all such warranties, including without -// limitation, any warranties of merchantability, fitness for a particular -// purpose or non-infringement. Please see the License for the specific terms -// and conditions governing the rights and limitations under the License. - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include - -#define G002 -#define VERTEXMARKER 2 -#define DEFAULTMARKERSIZE 3.0 - -GGraphic2d_SetOfCurves::GGraphic2d_SetOfCurves ( - const Handle(Graphic2d_GraphicObject)& aGraphicObject) - - : Graphic2d_Line (aGraphicObject) { - -} - -void GGraphic2d_SetOfCurves::Add (const Handle(Geom2d_Curve) &aCurve) -{ - Bnd_Box2d Box; - BndLib_Add2dCurve::Add(Geom2dAdaptor_Curve(aCurve),0.,Box); - Standard_Real Xmin, Ymin, Xmax, Ymax; - Box.Get( Xmin, Ymin, Xmax, Ymax); - Standard_ShortReal minX = Standard_ShortReal(Xmin); - Standard_ShortReal minY = Standard_ShortReal(Ymin); - Standard_ShortReal maxX = Standard_ShortReal(Xmax); - Standard_ShortReal maxY = Standard_ShortReal(Ymax); - myMinX = Min(myMinX,minX); - myMinY = Min(myMinY,minY); - myMaxX = Max(myMaxX,maxX); - myMaxY = Max(myMaxY,maxY); - - myCurves.Append(aCurve); -} - -Standard_Integer GGraphic2d_SetOfCurves::Length () const { - return myCurves.Length(); -} - -Handle(Geom2d_Curve) GGraphic2d_SetOfCurves::Values(const Standard_Integer aRank) const { - - if( aRank < 1 || aRank > myCurves.Length() ) - Standard_OutOfRange::Raise - ("the curve rank is out of bounds in the set"); - - return myCurves.Value(aRank); -} - -void GGraphic2d_SetOfCurves::Draw (const Handle(Graphic2d_Drawer)& aDrawer) { -//Standard_Integer i,length = myCurves.Length(),bufferize = 1; - Standard_Integer length = myCurves.Length(), bufferize = 1; - Standard_Boolean IsIn = Standard_False; - Standard_ShortReal minX,minY,maxX,maxY; - Standard_Real Xmin,Ymin,Xmax,Ymax; - - if( length <= 0 ) return ; - - gp_GTrsf2d aTrsf = myGOPtr->Transform (); - - if (! myGOPtr->IsTransformed ()) - IsIn = aDrawer->IsIn (myMinX,myMaxX,myMinY,myMaxY); - else { - MinMax(minX,maxX,minY,maxY); - IsIn = aDrawer->IsIn (minX,maxX,minY,maxY); - } - - if ( IsIn ) { - Standard_ShortReal Def; - Standard_ShortReal Coeff; - Aspect_TypeOfDeflection Type; - Standard_Boolean Controll = Standard_True; - Handle(Geom2d_Curve) aCurve; - Standard_Integer i,typeindex = TypeIndex(); - - aDrawer->DrawPrecision(Def,Coeff,Type); - DrawLineAttrib(aDrawer); - for( i=1 ; i<=length ; i++ ) { - aCurve = myCurves.Value(i); - - if (Type == Aspect_TOD_RELATIVE) { - Bnd_Box2d Box; - BndLib_Add2dCurve::Add(Geom2dAdaptor_Curve(aCurve),0.,Box); - Box.Get( Xmin,Ymin,Xmax,Ymax ); - Def = Standard_ShortReal( (Abs(Xmax-Xmin) + Abs(Ymax-Ymin) ) * Coeff); - } - - Geom2dAdaptor_Curve GAC(aCurve); - GCPnts_UniformDeflection UD(GAC,Def,Controll); - if(UD.IsDone()) { - Standard_Integer j,nbp = UD.NbPoints(); - gp_Pnt p2; - Standard_Real x,y,z; - Standard_ShortReal x1=0,y1=0,x2,y2; - for (j=1; j<=nbp; j++) { - p2 = UD.Value(j); - p2.Coord(x,y,z); - if (myGOPtr->IsTransformed ()) { - aTrsf.Transforms(x, y); - } - if( typeindex > 0 ) { - if( j > 1 ) { - if( j < nbp ) bufferize = 0; - else bufferize = -1; - } else { - bufferize = nbp; - } - aDrawer->MapPolylineFromTo( Standard_ShortReal(x), Standard_ShortReal(y), bufferize); - } else { - if( j > 1 ) { - if( (i == length) && (j == nbp) ) bufferize = -1; - x2 = Standard_ShortReal(x); y2 = Standard_ShortReal(y); - aDrawer->MapSegmentFromTo(x1,y1,x2,y2,bufferize); - x1 = x2; y1 = y2; - bufferize = 0; - } else { - x1 = Standard_ShortReal(x); y1 = Standard_ShortReal(y); - } - } - } - } - } - } -} - -#ifdef G002 - -void GGraphic2d_SetOfCurves::DrawElement( const Handle(Graphic2d_Drawer)& aDrawer, - const Standard_Integer anIndex ) { - - Standard_Integer length = myCurves.Length(), bufferize = 1; - Standard_Boolean IsIn = Standard_False; - Standard_ShortReal minX,minY,maxX,maxY; - Standard_Real Xmin,Ymin,Xmax,Ymax; - - if ( length <= 0 ) return ; - - gp_GTrsf2d aTrsf = myGOPtr->Transform (); - - if ( ! myGOPtr->IsTransformed() ) - IsIn = aDrawer->IsIn( myMinX,myMaxX,myMinY,myMaxY ); - else { - MinMax(minX,maxX,minY,maxY); - IsIn = aDrawer->IsIn (minX,maxX,minY,maxY); - } - - if ( IsIn ) { - - if ( anIndex > 0 && anIndex <= length ) { - - Standard_ShortReal Def, Coeff; - Aspect_TypeOfDeflection Type; - Standard_Boolean Controll = Standard_True; - Handle(Geom2d_Curve) aCurve; - Standard_Integer typeindex = TypeIndex(); - - aDrawer->DrawPrecision( Def, Coeff, Type ); - DrawLineAttrib( aDrawer ); - aCurve = myCurves.Value( anIndex ); - - if ( Type == Aspect_TOD_RELATIVE ) { - Bnd_Box2d Box; - BndLib_Add2dCurve::Add(Geom2dAdaptor_Curve(aCurve),0.,Box); - Box.Get( Xmin,Ymin,Xmax,Ymax ); - Def = Standard_ShortReal( (Abs(Xmax-Xmin) + Abs(Ymax-Ymin) ) * Coeff); - } - - Geom2dAdaptor_Curve GAC(aCurve); - GCPnts_UniformDeflection UD(GAC,Def,Controll); - if ( UD.IsDone() ) { - Standard_Integer j,nbp = UD.NbPoints(); - gp_Pnt p2; - Standard_Real x,y,z; - Standard_ShortReal x1=0,y1=0,x2,y2; - for ( j = 1; j <= nbp; j++ ) { - p2 = UD.Value( j ); - p2.Coord( x, y, z ); - if ( myGOPtr->IsTransformed() ) { - aTrsf.Transforms (x, y); - } - if ( typeindex > 0 ) { - if ( j > 1 ) { - bufferize = ( j < nbp ) ? 0 : -1; - } else { - bufferize = nbp; - } - aDrawer->MapPolylineFromTo( Standard_ShortReal(x), Standard_ShortReal(y), bufferize ); - } else { - if ( j > 1 ) { - if ( ( anIndex == length ) && (j == nbp) ) - bufferize = -1; - x2 = Standard_ShortReal(x); y2 = Standard_ShortReal(y); - aDrawer->MapSegmentFromTo( x1, y1, x2, y2, bufferize ); - x1 = x2; y1 = y2; - bufferize = 0; - } else { - x1 = Standard_ShortReal(x); y1 = Standard_ShortReal(y); - } - } - } // end for - } - } - - } // end if IsIn -} - -void GGraphic2d_SetOfCurves::DrawVertex( const Handle(Graphic2d_Drawer)& aDrawer, - const Standard_Integer anIndex ) { - - Standard_Integer length = myCurves.Length(); - Standard_Boolean IsIn = Standard_False; - Standard_ShortReal minX,minY,maxX,maxY; - - if ( length <= 0 ) return ; - - if ( ! myGOPtr->IsTransformed() ) - IsIn = aDrawer->IsIn( myMinX,myMaxX,myMinY,myMaxY ); - else { - MinMax(minX,maxX,minY,maxY); - IsIn = aDrawer->IsIn (minX,maxX,minY,maxY); - } - - if ( IsIn ) { - - if ( anIndex > 0 && anIndex <= 2*length ) { - - DrawMarkerAttrib (aDrawer); - Handle(Geom2d_Curve) aCurve; - Standard_Real theParam; - if ( anIndex <= length ) { - aCurve = myCurves.Value( anIndex ); - theParam = aCurve->FirstParameter(); - } else { - aCurve = myCurves.Value( anIndex - length); - theParam = aCurve->LastParameter(); - } - gp_Pnt2d thePnt = aCurve->Value(theParam); - Standard_ShortReal a = Standard_ShortReal(thePnt.X()), - b = Standard_ShortReal(thePnt.Y()); - if ( myGOPtr->IsTransformed() ) { - gp_GTrsf2d aTrsf = myGOPtr->Transform (); - Standard_Real a1, b1; - a1 = Standard_Real(a); - b1 = Standard_Real(b); - aTrsf.Transforms( a1, b1 ); - a = Standard_ShortReal( a1 ); - b = Standard_ShortReal( b1 ); - } - aDrawer->MapMarkerFromTo( VERTEXMARKER, a, b, - DEFAULTMARKERSIZE,DEFAULTMARKERSIZE,0.0); - } - } // end if IsIn -} - -#endif - -Standard_Boolean GGraphic2d_SetOfCurves::Pick( - const Standard_ShortReal X, - const Standard_ShortReal Y, - const Standard_ShortReal aPrecision, - const Handle(Graphic2d_Drawer)& /*aDrawer*/) { - - Standard_Integer i,length = myCurves.Length(); - //Standard_ShortReal SRX = X, SRY = Y; - static Standard_ShortReal SRX , SRY ; - SRX = X; - SRY = Y; - //Standard_Boolean isPicked = Standard_False; - - if ( (length > 0) && IsInMinMax (X, Y, aPrecision)) { - if (myGOPtr->IsTransformed ()) { - gp_GTrsf2d aTrsf = (myGOPtr->Transform()).Inverted(); - Standard_Real RX = Standard_Real( SRX ), RY = Standard_Real( SRY ); - aTrsf.Transforms( RX, RY ); - SRX = Standard_ShortReal( RX ); SRY = Standard_ShortReal( RY ); - } - try { - OCC_CATCH_SIGNALS - Handle(Geom2d_Curve) aCurve; - for ( i = 1 ; i <= length; i++ ) { - aCurve = myCurves.Value(i); - Standard_Real FParam = aCurve->FirstParameter(), - LParam = aCurve->LastParameter(); - gp_Pnt2d FP = aCurve->Value(FParam), - LP = aCurve->Value(LParam); - Geom2dAPI_ProjectPointOnCurve PC(gp_Pnt2d(SRX, SRY), - aCurve, - FParam, - LParam ); - if ( PC.NbPoints() > 0 ) { - gp_Pnt2d P = PC.NearestPoint(); - -#ifdef G002 - - if ( ( Abs( SRX - P.X() ) + Abs( SRY - P.Y() ) ) < aPrecision ) { - SetPickedIndex( i ); - return Standard_True; - } else if ( Graphic2d_Primitive::IsOn( SRX, SRY, - Standard_ShortReal(FP.X()), Standard_ShortReal(FP.Y()), aPrecision) ) { - SetPickedIndex( -i ); - return Standard_True; - } else if ( Graphic2d_Primitive::IsOn( SRX, SRY, - Standard_ShortReal(LP.X()), Standard_ShortReal(LP.Y()), aPrecision) ) { - SetPickedIndex( -i - length ); - return Standard_True; - } -#else - if ( ( Abs( SRX - P.X() ) + Abs( SRY - P.Y() ) ) < aPrecision ) { - myPickedIndex = i; - return Standard_True; - } -#endif - } // end if NbPoints() > 0 - } // end for - } catch( Standard_Failure ) { - return Standard_False; - } - } - - return Standard_False; - -} - -void GGraphic2d_SetOfCurves::Save(Aspect_FStream& aFStream) const -{ - int i,lngth = Length(); - if ( ! lngth ) return; - - *aFStream << "GGraphic2d_SetOfCurves" << endl; - *aFStream << lngth << endl; - - - Handle(Geom2d_Curve) myCurve; - - for ( i = 1; i <= lngth; i++ ) { - - myCurve = myCurves.Value( i ); - - if ( myCurve->IsKind(STANDARD_TYPE(Geom2d_Line)) ) { - - Handle(Geom2d_Line) theLine = Handle(Geom2d_Line)::DownCast( myCurve ); - gp_Dir2d tDir = theLine->Direction(); - gp_Pnt2d tPnt = theLine->Location(); - - *aFStream << "Geom2d_Line" << endl; - *aFStream << tDir.X() << ' ' << tDir.Y() << endl; - *aFStream << tPnt.X() << ' ' << tPnt.Y() << endl; - - } else if ( myCurve->IsKind(STANDARD_TYPE(Geom2d_Circle)) ) { - - Handle(Geom2d_Circle) theCirc = Handle(Geom2d_Circle)::DownCast( myCurve ); - gp_Circ2d tCirc = theCirc->Circ2d(); - gp_Ax22d tAx22d = tCirc.Axis(); - gp_Pnt2d tLoc = tAx22d.Location(); - gp_Dir2d tDirX = tAx22d.XDirection(), - tDirY = tAx22d.YDirection(); - - Standard_Real tRad = tCirc.Radius(); - - *aFStream << "Geom2d_Circle" << endl; - *aFStream << tLoc.X() << ' ' << tLoc.Y() << endl; - *aFStream << tDirX.X() << ' ' << tDirX.Y() << endl; - *aFStream << tDirY.X() << ' ' << tDirY.Y() << endl; - *aFStream << tRad << endl; - - } else if ( myCurve->IsKind(STANDARD_TYPE(Geom2d_Parabola)) ) { - - Handle(Geom2d_Parabola) theParab = Handle(Geom2d_Parabola)::DownCast( myCurve ); - gp_Parab2d tParab = theParab->Parab2d(); - gp_Ax22d tAx22d = tParab.Axis(); - gp_Pnt2d tLoc = tAx22d.Location(); - gp_Dir2d tDirX = tAx22d.XDirection(), - tDirY = tAx22d.YDirection(); - - Standard_Real tFocal = theParab->Focal(); - - *aFStream << "Geom2d_Parabola" << endl; - *aFStream << tLoc.X() << ' ' << tLoc.Y() << endl; - *aFStream << tDirX.X() << ' ' << tDirX.Y() << endl; - *aFStream << tDirY.X() << ' ' << tDirY.Y() << endl; - *aFStream << tFocal << endl; - - } else if ( myCurve->IsKind(STANDARD_TYPE(Geom2d_Ellipse)) ) { - Handle(Geom2d_Ellipse) theEllipse = Handle(Geom2d_Ellipse)::DownCast(myCurve); - gp_Elips2d tElips = theEllipse->Elips2d(); - Standard_Real tMin = tElips.MinorRadius(), - tMaj = tElips.MajorRadius(); - gp_Ax22d tAx22d = tElips.Axis(); - gp_Pnt2d tLoc = tAx22d.Location(); - gp_Dir2d tDirX = tAx22d.XDirection(), - tDirY = tAx22d.YDirection(); - - *aFStream << "Geom2d_Ellipse" << endl; - - *aFStream << tMin << ' ' << tMaj << endl; - *aFStream << tLoc.X() << ' ' << tLoc.Y() << endl; - *aFStream << tDirX.X() << ' ' << tDirX.Y() << endl; - *aFStream << tDirY.X() << ' ' << tDirY.Y() << endl; - - } else if ( myCurve->IsKind(STANDARD_TYPE(Geom2d_Hyperbola)) ) { - - Handle(Geom2d_Hyperbola) theHypr = Handle(Geom2d_Hyperbola)::DownCast(myCurve); - gp_Hypr2d tHypr = theHypr->Hypr2d(); - Standard_Real tMin = tHypr.MinorRadius(), - tMaj = tHypr.MajorRadius(); - gp_Ax22d tAx22d = tHypr.Axis(); - gp_Pnt2d tLoc = tAx22d.Location(); - gp_Dir2d tDirX = tAx22d.XDirection(), - tDirY = tAx22d.YDirection(); - - *aFStream << "Geom2d_Hyperbola" << endl; - - *aFStream << tMin << ' ' << tMaj << endl; - *aFStream << tLoc.X() << ' ' << tLoc.Y() << endl; - *aFStream << tDirX.X() << ' ' << tDirX.Y() << endl; - *aFStream << tDirY.X() << ' ' << tDirY.Y() << endl; - - } else if ( myCurve->IsKind(STANDARD_TYPE(Geom2d_BezierCurve)) ) { - - Handle(Geom2d_BezierCurve) theBC = Handle(Geom2d_BezierCurve)::DownCast(myCurve); - Standard_Integer nbPoles = theBC->NbPoles(); - TColgp_Array1OfPnt2d tpoles( 1, nbPoles ); - theBC->Poles( tpoles ); - *aFStream << "Geom2d_BezierCurve" << endl; - - for ( Standard_Integer k = 1; k <= nbPoles; k++ ) - *aFStream << tpoles(k).X() << ' ' << tpoles(k).Y() << endl; - - } else if ( myCurve->IsKind(STANDARD_TYPE(Geom2d_BSplineCurve)) ) { - Handle(Geom2d_BSplineCurve) theBSC = Handle(Geom2d_BSplineCurve)::DownCast(myCurve); - - } else if ( myCurve->IsKind(STANDARD_TYPE(Geom2d_OffsetCurve)) ) { - Handle(Geom2d_OffsetCurve) theOC = Handle(Geom2d_OffsetCurve)::DownCast(myCurve); - - } else if ( myCurve->IsKind(STANDARD_TYPE(Geom2d_TrimmedCurve)) ) { - Handle(Geom2d_TrimmedCurve) theTC = Handle(Geom2d_TrimmedCurve)::DownCast(myCurve); - } - - } // end for - Graphic2d_Line::Save(aFStream); -} diff --git a/src/GGraphic2d/Graphic2d_Curve.hxx b/src/GGraphic2d/Graphic2d_Curve.hxx deleted file mode 100755 index 1c992c5df2..0000000000 --- a/src/GGraphic2d/Graphic2d_Curve.hxx +++ /dev/null @@ -1,21 +0,0 @@ -// Copyright (c) 1998-1999 Matra Datavision -// Copyright (c) 1999-2012 OPEN CASCADE SAS -// -// The content of this file is subject to the Open CASCADE Technology Public -// License Version 6.5 (the "License"). You may not use the content of this file -// except in compliance with the License. Please obtain a copy of the License -// at http://www.opencascade.org and read it completely before using this file. -// -// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its -// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. -// -// The Original Code and all software distributed under the License is -// distributed on an "AS IS" basis, without warranty of any kind, and the -// Initial Developer hereby disclaims all such warranties, including without -// limitation, any warranties of merchantability, fitness for a particular -// purpose or non-infringement. Please see the License for the specific terms -// and conditions governing the rights and limitations under the License. - -#include -typedef GGraphic2d_Curve Graphic2d_Curve; -typedef Handle_GGraphic2d_Curve Handle_Graphic2d_Curve ; diff --git a/src/GGraphic2d/Graphic2d_CurveDefinitionError.hxx b/src/GGraphic2d/Graphic2d_CurveDefinitionError.hxx deleted file mode 100755 index cfb75446e0..0000000000 --- a/src/GGraphic2d/Graphic2d_CurveDefinitionError.hxx +++ /dev/null @@ -1,21 +0,0 @@ -// Copyright (c) 1998-1999 Matra Datavision -// Copyright (c) 1999-2012 OPEN CASCADE SAS -// -// The content of this file is subject to the Open CASCADE Technology Public -// License Version 6.5 (the "License"). You may not use the content of this file -// except in compliance with the License. Please obtain a copy of the License -// at http://www.opencascade.org and read it completely before using this file. -// -// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its -// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. -// -// The Original Code and all software distributed under the License is -// distributed on an "AS IS" basis, without warranty of any kind, and the -// Initial Developer hereby disclaims all such warranties, including without -// limitation, any warranties of merchantability, fitness for a particular -// purpose or non-infringement. Please see the License for the specific terms -// and conditions governing the rights and limitations under the License. - -#include -typedef GGraphic2d_CurveDefinitionError Graphic2d_CurveDefinitionError; - diff --git a/src/GGraphic2d/Graphic2d_SetOfCurves.hxx b/src/GGraphic2d/Graphic2d_SetOfCurves.hxx deleted file mode 100755 index 88415bee87..0000000000 --- a/src/GGraphic2d/Graphic2d_SetOfCurves.hxx +++ /dev/null @@ -1,21 +0,0 @@ -// Copyright (c) 1998-1999 Matra Datavision -// Copyright (c) 1999-2012 OPEN CASCADE SAS -// -// The content of this file is subject to the Open CASCADE Technology Public -// License Version 6.5 (the "License"). You may not use the content of this file -// except in compliance with the License. Please obtain a copy of the License -// at http://www.opencascade.org and read it completely before using this file. -// -// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its -// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. -// -// The Original Code and all software distributed under the License is -// distributed on an "AS IS" basis, without warranty of any kind, and the -// Initial Developer hereby disclaims all such warranties, including without -// limitation, any warranties of merchantability, fitness for a particular -// purpose or non-infringement. Please see the License for the specific terms -// and conditions governing the rights and limitations under the License. - -#include -typedef GGraphic2d_SetOfCurves Graphic2d_SetOfCurves; -typedef Handle_GGraphic2d_SetOfCurves Handle_Graphic2d_SetOfCurves ; diff --git a/src/Graphic2d/FILES b/src/Graphic2d/FILES deleted file mode 100755 index f64732bf30..0000000000 --- a/src/Graphic2d/FILES +++ /dev/null @@ -1,8 +0,0 @@ -Graphic2d_Image.pxx -Graphic2d_Primitive.pxx -Graphic2d_GraphicObject.pxx -Graphic2d_CBitFields8.hxx -Graphic2d_CBitFields8.cxx -Graphic2d.edl -Graphic2d_CMPLRS.edl -Graphic2d_WOKSteps.edl diff --git a/src/Graphic2d/Graphic2d.cdl b/src/Graphic2d/Graphic2d.cdl deleted file mode 100755 index 6ba8d164b3..0000000000 --- a/src/Graphic2d/Graphic2d.cdl +++ /dev/null @@ -1,351 +0,0 @@ --- Created on: 1993-06-22 --- Created by: Jean Louis FRENKEL, Gerard Gras. --- Copyright (c) 1993-1999 Matra Datavision --- Copyright (c) 1999-2012 OPEN CASCADE SAS --- --- The content of this file is subject to the Open CASCADE Technology Public --- License Version 6.5 (the "License"). You may not use the content of this file --- except in compliance with the License. Please obtain a copy of the License --- at http://www.opencascade.org and read it completely before using this file. --- --- The Initial Developer of the Original Code is Open CASCADE S.A.S., having its --- main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. --- --- The Original Code and all software distributed under the License is --- distributed on an "AS IS" basis, without warranty of any kind, and the --- Initial Developer hereby disclaims all such warranties, including without --- limitation, any warranties of merchantability, fitness for a particular --- purpose or non-infringement. Please see the License for the specific terms --- and conditions governing the rights and limitations under the License. - - --- Modified: TCL 12-06-00 G002 new enumeration PickMode --- Modified: SAV 16/08/02 new enumeration DisplayStatus - - -package Graphic2d - - ---Version: - - ---Purpose: This package permits the creation of 2d graphic objects - -- in a visualiser. - -- Each object, called GraphicObject, is composed of - -- primitives and is created in a View. - -- Each Primitive is a class and contains attributes. - -- Each Primitive have its own method Draw to draw the - -- primitive. - -- A View manages a set of graphic objects. - -- A Drawer makes conversions. - - ---Keywords: Drawer, View, Graphic Object, Primitive, Line, - -- Circle, Polyline, Ellips, Curve, Image, Text, HidingText, - -- FramedText, Paragraph - ---Warning: - ---References: - -uses - Aspect, - PlotMgt, --- Geom2d, -- disparait a partir de K4 - Image, - MMgt, - gp, - OSD, - Quantity, - TCollection, - TColStd, - TShort - -is - ----------------------- - -- Category: Exceptions - ----------------------- - - exception CircleDefinitionError inherits OutOfRange; - ---Category: Exceptions - - exception EllipsDefinitionError inherits OutOfRange; - ---Category: Exceptions - - exception ImageDefinitionError inherits OutOfRange; - ---Category: Exceptions - - exception InfiniteLineDefinitionError inherits OutOfRange; - ---Category: Exceptions - - exception MarkerDefinitionError inherits OutOfRange; - ---Category: Exceptions - - exception PolylineDefinitionError inherits OutOfRange; - ---Category: Exceptions - - exception SegmentDefinitionError inherits OutOfRange; - ---Category: Exceptions - - exception TextDefinitionError inherits OutOfRange; - ---Category: Exceptions - - exception DrawerDefinitionError inherits OutOfRange; - ---Category: Exceptions - - exception OverrideColorError inherits OutOfRange; - ---Category: Exceptions - - exception DetectionColorError inherits OutOfRange; - ---Category: Exceptions - --- exception CurveDefinitionError inherits OutOfRange; -- disparait a partir de K4 - ---Category: Exceptions - - exception TransientDefinitionError inherits OutOfRange; - ---Category: Exceptions - - --------------------------------- - -- Category: The deferred classes - --------------------------------- - - deferred class Primitive; - ---Purpose: Groups all drawing elements stored in a - -- graphic object. - ---Category: The deferred classes - - deferred class Line; - ---Purpose: Groups all the primitives which behaves like - -- geometrical lines. - -- for example: Polyline, Circle ... - ---Category: The deferred classes - - deferred class VectorialMarker; - ---Purpose: Groups all the primitives which behaves like - -- geometrical marker. - -- for example : EllipsMarker, CircleMarker ... - ---Category: The deferred classes - - ------------------------ - -- Category: The classes - ------------------------ - - class Buffer; - ---Purpose: A Buffer is a list of primitives and/or - -- GraphicObject drawn with one color. - -- This Buffer is used to attach geometry to - -- the cursor in a Aspect_WindowDriver. - - class Drawer; - ---Purpose: Internal class, makes conversions. - - class GraphicObject; - ---Purpose: A GraphicObject is a primitives manager. - - class HidingGraphicObject; - ---Purpose: A HidingGraphicObject is a primitives manager. - - class Vertex; - ---Purpose: Defines a 2D point. - - class View; - ---Purpose: A View is a graphic object manager. - - class ViewMapping; - ---Purpose: Defines a view mapping. - - class TransientManager; - ---Purpose: To draw temporary graphics in a view. - - --------------------------- - -- Category: Imported types - --------------------------- - - imported CBitFields8; - ---Purpose: Defines the C structure - ---Category: Imported types - - --------------------- - -- Category: Pointers - --------------------- - - pointer ViewPtr to View from Graphic2d; - ---Category: Pointers - - pointer GOPtr to GraphicObject from Graphic2d; - ---Category: Pointers - - ------------------------------- - -- Category: Graphic primitives - ------------------------------- - - class Circle; - ---Category: Graphic primitives - --- class Curve; -- disparait a partir de K4 - ---Category: Graphic primitives - - class Ellips; - ---Category: Graphic primitives - - class Image; - ---Category: Graphic primitives - - class ImageFile; - ---Category: Graphic primitives - - class InfiniteLine; - ---Category: Graphic primitives - - class Marker; - ---Category: Graphic primitives - - class Polyline; - ---Category: Graphic primitives - - class Segment; - ---Category: Graphic primitives - - class Text; - ---Category: Graphic primitives - - class HidingText; - ---Category: Graphic primitives - - class FramedText; - ---Category: Graphic primitives - - class Paragraph; - ---Category: Graphic primitives - - class CircleMarker; - ---Category: Graphic primitives - - class PolylineMarker; - ---Category: Graphic primitives - - class EllipsMarker; - ---Category: Graphic primitives - - class SetOfSegments; - ---Category: Set Of Graphic primitives - - class SetOfMarkers; - ---Category: Set Of Graphic primitives - --- class SetOfCurves; -- disparait a partir de K4 - ---Category: Set Of Graphic primitives - - class SetOfPolylines; - ---Category: Set Of Graphic primitives - - --------------------------------- - -- Category: enumerations - --------------------------------- - - enumeration TypeOfPolygonFilling is TOPF_EMPTY, - TOPF_FILLED, - TOPF_PATTERNED - end TypeOfPolygonFilling from Graphic2d; - ---Purpose: - -- Defines whether the polygon is filled or displays an - -- empty background. - -- - The EMPTY syntax defines a polygon - -- transparent background (the frame is visible). - -- - The FILLED syntax creates a regularly filled - -- polygon by using the method - -- SetInteriorColorIndex. - -- - The PATTERNED syntax is not yet implemented. - enumeration TypeOfAlignment is TOA_LEFT, - TOA_CENTER, - TOA_RIGHT, - TOA_TOPLEFT, - TOA_TOPCENTER, - TOA_TOPRIGHT, - TOA_MEDIUMLEFT, - TOA_MEDIUMCENTER, - TOA_MEDIUMRIGHT, - TOA_BOTTOMLEFT, - TOA_BOTTOMCENTER, - TOA_BOTTOMRIGHT - end TypeOfAlignment from Graphic2d; - ---Purpose: - -- These specific points define text alignment with - -- respect to the origin of the text. - enumeration TypeOfComposition is TOC_REPLACE, - TOC_POSTCONCATENATE - end TypeOfComposition; - - enumeration TypeOfFrame is TOF_UNKNOWN, - TOF_RECTANGULAR, - TOF_CIRCULAR - end TypeOfFrame; - - enumeration TypeOfPrimitive is - TOP_UNKNOWN, - TOP_LINE, - TOP_MARKER, - TOP_TEXT, - TOP_IMAGE - end TypeOfPrimitive; - - enumeration PickMode is PM_INCLUDE, - PM_EXCLUDE, - PM_INTERSECT - end PickMode from Graphic2d; - - enumeration DisplayStatus is - DS_DISPLAYED, - DS_ERASED, - DS_REMOVED, - DS_NONE - end DisplayStatus from Graphic2d; - - --------------------------------- - -- Category: Instantiated classes - --------------------------------- - - class SequenceOfBuffer instantiates - Sequence from TCollection (Buffer from Graphic2d); - ---Category: Instantiated classes - - class BufferList instantiates - HSequence from TCollection - (Buffer from Graphic2d, SequenceOfBuffer from Graphic2d); - ---Category: Instantiated classes - - class SequenceOfGraphicObject instantiates - Sequence from TCollection (GraphicObject from Graphic2d); - ---Category: Instantiated classes - - class DisplayList instantiates - HSequence from TCollection - (GraphicObject from Graphic2d, SequenceOfGraphicObject from Graphic2d); - ---Category: Instantiated classes - - class SequenceOfPrimitives instantiates - Sequence from TCollection(Primitive from Graphic2d); - ---Category: Instantiated classes - - class HSequenceOfPrimitives instantiates - HSequence from TCollection - (Primitive from Graphic2d,SequenceOfPrimitives from Graphic2d); - ---Category: Instantiated classes - - class Array1OfVertex instantiates - Array1 from TCollection (Vertex from Graphic2d); - class HArray1OfVertex instantiates - HArray1 from TCollection (Vertex from Graphic2d,Array1OfVertex); - ---Category: Instantiated classes - --- class SequenceOfCurve instantiates -- disparait a partir de K4 --- Sequence from TCollection (Curve from Geom2d); - ---Category: Instantiated classes - - class SequenceOfVertex instantiates - Sequence from TCollection (Vertex from Graphic2d); - ---Category: Instantiated classes - class HSequenceOfVertex instantiates - HSequence from TCollection (Vertex from Graphic2d,SequenceOfVertex); - ---Category: Instantiated classes - - class SequenceOfPolyline instantiates - Sequence from TCollection (HSequenceOfVertex from Graphic2d); - ---Category: Instantiated classes - -end Graphic2d; diff --git a/src/Graphic2d/Graphic2d.edl b/src/Graphic2d/Graphic2d.edl deleted file mode 100755 index 86725bf5e2..0000000000 --- a/src/Graphic2d/Graphic2d.edl +++ /dev/null @@ -1,24 +0,0 @@ --- Created on: 1996-10-03 --- Created by: Jean GAUTIER --- Copyright (c) 1996-1999 Matra Datavision --- Copyright (c) 1999-2012 OPEN CASCADE SAS --- --- The content of this file is subject to the Open CASCADE Technology Public --- License Version 6.5 (the "License"). You may not use the content of this file --- except in compliance with the License. Please obtain a copy of the License --- at http://www.opencascade.org and read it completely before using this file. --- --- The Initial Developer of the Original Code is Open CASCADE S.A.S., having its --- main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. --- --- The Original Code and all software distributed under the License is --- distributed on an "AS IS" basis, without warranty of any kind, and the --- Initial Developer hereby disclaims all such warranties, including without --- limitation, any warranties of merchantability, fitness for a particular --- purpose or non-infringement. Please see the License for the specific terms --- and conditions governing the rights and limitations under the License. - - -@ifnotdefined ( %Graphic2d_EDL) then - @set %Graphic2d_EDL = ""; -@endif; diff --git a/src/Graphic2d/Graphic2d_Buffer.cdl b/src/Graphic2d/Graphic2d_Buffer.cdl deleted file mode 100755 index 4d18a0ecd1..0000000000 --- a/src/Graphic2d/Graphic2d_Buffer.cdl +++ /dev/null @@ -1,392 +0,0 @@ --- Created by: s: CAL, GG --- Copyright (c) 1995-1999 Matra Datavision --- Copyright (c) 1999-2012 OPEN CASCADE SAS --- --- The content of this file is subject to the Open CASCADE Technology Public --- License Version 6.5 (the "License"). You may not use the content of this file --- except in compliance with the License. Please obtain a copy of the License --- at http://www.opencascade.org and read it completely before using this file. --- --- The Initial Developer of the Original Code is Open CASCADE S.A.S., having its --- main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. --- --- The Original Code and all software distributed under the License is --- distributed on an "AS IS" basis, without warranty of any kind, and the --- Initial Developer hereby disclaims all such warranties, including without --- limitation, any warranties of merchantability, fitness for a particular --- purpose or non-infringement. Please see the License for the specific terms --- and conditions governing the rights and limitations under the License. - - - -class Buffer from Graphic2d inherits TShared from MMgt - - ---Purpose: This class constructs a 2D graphic buffer in a view. It - -- manages a set of graphic objects and/or primitives. - -- To draw the buffer, the following elements are required: - -- - the override color - -- - the font - -- - a solid line type - -- - thickness of 1 pixel. - -- With this category , the user can drag the geometry - -- stored in the buffer without changing the fixed - -- background. This mechanism is reserved for the - -- special driver Aspect_WindowDriver: if no other - -- driver has been defined, nothing will be drawn. Both - -- this driver and view mapping are used to draw the buffer. - -- Warning - -- - This class manages dragging only. It does not - -- manage "sketching" or "rubberbanding". For example: - -- - There is no empty constructor for this - -- primitive. Therefore we must create a primitive - -- in a dummy object simply to add this primitive to the buffer. - -- - There is no Buffer->Add (anArrayOfPoints) - -- method. Therefor it is not possible to add - -- shapes to the buffer. - -- - There are no Polyline->ChangeApoint () nor - -- Circle->ChangeRadius () methods. Therefore - -- we must call the primitive's destructor to modify - -- the definition of one primitive in a buffer. - -- - The Graphic2d_Image class is a primitive. For - -- this class, we replace the definition of the image - -- with a rectangle with the same size and the same position. - -- - You can add or remove primitives to the buffer - -- after creating and displaying it again. - - - -uses - PlaneAngle from Quantity, - Factor from Quantity, - Length from Quantity, - - View from Graphic2d, - Drawer from Graphic2d, - ViewPtr from Graphic2d, - Primitive from Graphic2d, - SequenceOfPrimitives from Graphic2d, - GraphicObject from Graphic2d, - SequenceOfGraphicObject from Graphic2d, - ViewMapping from Graphic2d, - WindowDriver from Aspect, - TypeOfDrawMode from Aspect - -is - ------------------------- - -- Category: Constructors - ------------------------- - - Create (aView: View from Graphic2d; - aPivotX, aPivotY: Length from Quantity; - aWidthIndex: Integer from Standard = 0; - aColorIndex: Integer from Standard = 0; - aFontIndex: Integer from Standard = 0; - aDrawMode: TypeOfDrawMode from Aspect = Aspect_TODM_REPLACE) - returns mutable Buffer from Graphic2d; - ---Purpose: Creates an empty graphic buffer in the view . - -- A graphic buffer manages a set of graphic objects - -- and/or primitives. - -- A buffer color and font index can be defined, - -- in place of the default overrideColor or systemFont. - -- When the drawmode is REPLACE the buffer is drawn with - -- the right color and background drawing is used for - -- restoring it at Erase() time. - -- When the drawmode is XOR the buffer is drawn or erase - -- with an optimal color depending of the background color - -- but some side effects can appears depending of - -- background drawing pixels values. - ---Category: Constructors - - ------------------------ - -- Category: Destructors - ------------------------ - - Destroy (me: mutable) - is static; - ---Level: Public - ---Purpose: Deletes the graphic buffer . - ---C++: alias ~ - ---Category: Destructors - - --------------------------------------------------------- - -- Category: Methods to manage the contents of the buffer - --------------------------------------------------------- - - Add (me: mutable; anObject: GraphicObject from Graphic2d) - is static; - ---Level: Public - ---Purpose: Adds the graphic object in the graphic - -- buffer . - ---Category: Methods to manage the contents of the buffer - - Add (me: mutable; aPrimitive: Primitive from Graphic2d) - is static; - ---Level: Public - ---Purpose: Adds the primitive in the graphic - -- buffer . - ---Category: Methods to manage the contents of the buffer - - Remove (me: mutable; anObject: GraphicObject from Graphic2d) - is static; - ---Level: Public - ---Purpose: Removes the object from the graphic - -- buffer . - ---Category: Methods to manage the contents of the buffer - - Remove (me: mutable; aPrimitive: Primitive from Graphic2d) - is static; - ---Level: Public - ---Purpose: Removes the primitive from the graphic - -- buffer . - ---Category: Methods to manage the contents of the buffer - - Clear (me: mutable) - is static; - ---Level: Public - ---Purpose: Clears the graphic buffer . - -- Removes all the primitives from the graphic buffer . - ---Category: Methods to manage the contents of the buffer --- - --------------------------------------------------------- - -- Category: Methods to manage the attributes of the buffer - --------------------------------------------------------- - - SetAttrib(me : mutable; - aWidthIndex: Integer from Standard; - aColorIndex: Integer from Standard; - aFontIndex: Integer from Standard; - aDrawMode: TypeOfDrawMode from Aspect) is static; - ---Level: Public - ---Purpose: Updates the default buffer color with a new - -- color index defines in the user ColorMap. - -- Update the default buffer font with a new - -- font index defines in the user FontMap. - -- Update the default buffer drawmode with - -- REPLACE or XOR . - -- You can specify the width index - -- - -1 draw all lines with the largest width - -- defined in the buffer - -- - 0 draw all lines with the default width - -- defined in the driver (1 pixel) - -- - draw all lines with the specified width - -- - -- You can specify the color index - -- - -1 draw all primitives with the color of - -- the first primitive color defined in the buffer. - -- - 0 draw all primitives with the default color. - -- You can specify the font index - -- - -1 draw all text primitives with the font of - -- the first primitive text defined in the buffer. - -- - 0 draw all text primitives with the default font. - -- Warning: The buffer is redisplayed again if it was posted. - ---Category: Methods to manage the attributes of the buffer - - SetPivot(me : mutable; - aPivotX, aPivotY: Length from Quantity) - is static; - ---Level: Public - ---Purpose: Updates the buffer pivot position. - -- Warning: The buffer is redisplayed again if it was posted. - ---Category: Methods to manage the position of the buffer - - SetPivot(me : mutable) - is static; - ---Level: Public - ---Purpose: Updates the buffer pivot position with the actual position. - ---Category: Methods to manage the position of the buffer - --- - --------------------------------------------------------- - -- Category: Methods to manage the position of the buffer - --------------------------------------------------------- - - Move (me: mutable; - aDeltaX,aDeltaY: Length from Quantity) - is static; - ---Level: Public - ---Purpose: Moves the graphic buffer at the specified - -- position. The new position of the buffer is : - -- ( + , + ) - ---Category: Methods to manage the position of the buffer - - Rotate (me: mutable; - anAngle: PlaneAngle from Quantity) - is static; - ---Level: Public - ---Purpose: Rotates the graphic buffer with the specified - -- absolute counter clockwise angle from the pivot X axis. - ---Category: Methods to manage the position of the buffer - - Scale (me: mutable; - aFactor: Factor from Quantity) - is static; - ---Level: Public - ---Purpose: Scales the graphic buffer with the specified - -- absolute scale factor from the pivot point. - ---Category: Methods to manage the position of the buffer - - ---------------------------- - -- Category: Inquire methods - ---------------------------- - - View (me) - returns mutable View from Graphic2d is static; - ---Level: Public - ---Purpose: Returns the view which manages the graphic buffer . - ---Category: Inquire methods - - IsEmpty (me) - returns Boolean from Standard - is static; - ---Level: Public - ---Purpose: Returns Standard_True if the graphic buffer - -- is empty, Standard_False if not. - ---Category: Inquire methods - - IsIn (me; aPrimitive: Primitive from Graphic2d) - returns Boolean from Standard - is static; - ---Level: Public - ---Purpose: Returns Standard_True if the primitive - -- is in the graphic buffer , Standard_False if not. - ---Category: Inquire methods - - IsIn (me; anObject: GraphicObject from Graphic2d) - returns Boolean from Standard - is static; - ---Level: Public - ---Purpose: Returns Standard_True if the graphic object - -- is in the graphic buffer , Standard_False if not. - ---Category: Inquire methods - - --------------------------------------------- - -- Category: Methods to manage the visibility - --------------------------------------------- - - Post (me: mutable) - is static; - ---Level: Public - ---Purpose: Post the graphic buffer in the current View driver - -- and display it. - -- Warning: The view driver must be defined and of type WindowDriver - -- or nothing is drawn . - ---Category: Methods to manage the visibility - - Post (me: mutable; - aDriver: WindowDriver from Aspect; - aViewMapping: ViewMapping from Graphic2d; - aXPosition, aYPosition: Real from Standard; - aScale: Real from Standard) - is static; - ---Level: Public - ---Purpose: Post the graphic buffer in a View driver and display it. - ---Category: Methods to manage the visibility - - UnPost (me: mutable) - is static; - ---Level: Public - ---Purpose: Unpost the graphic buffer from the view and erase it. - ---Category: Methods to manage the visibility - - IsPosted (me) - returns Boolean from Standard - is static; - ---Level: Public - ---Purpose: Returns Standard_True if the graphic buffer - -- is posted in the view, Standard_False if not. - ---Category: Methods to manage the visibility - - IsPosted (me; - aDriver: WindowDriver from Aspect) - returns Boolean from Standard - is static private; - ---Level: Public - ---Purpose: Returns Standard_True if the graphic buffer - -- is posted in the view with the driver , - -- Standard_False if not. - ---Category: Private methods - - ------------------------------------------------------------- - -- Category: Inquiries to retrieve the position of the buffer - ------------------------------------------------------------- - - Angle (me) - returns PlaneAngle from Quantity is static; - ---Level: Public - ---Purpose: Returns the value of the rotation angle of the - -- graphic buffer . - ---Category: Inquire methods - - Scale (me) - returns Factor from Quantity is static; - ---Level: Public - ---Purpose: Returns the value of the scale factor of the - -- graphic buffer . - ---Category: Inquire methods - - Xpivot (me) - returns Length from Quantity is static; - ---Level: Public - ---Purpose: Returns the actual value of the X pivot point. - -- of the graphic buffer . - ---Category: Inquire methods - - Ypivot (me) - returns Length from Quantity is static; - ---Level: Public - ---Purpose: Returns the actual value of the Y pivot point. - -- of the graphic buffer . - ---Category: Inquire methods - - ---------------------------- - -- Category: Private methods - ---------------------------- - - Draw (me : mutable) is static private; - ---Level: Internal - ---Purpose: Update the internal buffer with new primitives - -- if any and draw it at screen. - ---Category: Private methods - - Erase (me : mutable) is static private; - ---Level: Internal - ---Purpose: Erase the internal buffer from the screen. - ---Category: Private methods - - ReLoad (me : mutable; - ResetPosition: Boolean from Standard = Standard_True) - is static private; - ---Level: Internal - ---Purpose: Erase and Reload the internal graphic buffer before - -- drawing to the current drawer. - -- Keep the actual position if is FALSE. - ---Category: Private methods - - MaxWidth (me; theWidth: out Length from Quantity; - theIndex: out Integer from Standard) - returns Boolean from Standard is static private; - ---Level: Internal - ---Purpose: Returns Standard_True if the buffer contains - -- lines and the maximum width of the lines in the - -- buffer - ---Category: Private methods - -fields - myBufferId: Integer from Standard; - myBufferIsPosted: Boolean from Standard; - myDriver: WindowDriver from Aspect; - myPivotX: ShortReal from Standard; - myPivotY: ShortReal from Standard; - myWidthIndex: Integer from Standard; - myColorIndex: Integer from Standard; - myFontIndex: Integer from Standard; - myDrawMode: TypeOfDrawMode from Aspect; - myPView: ViewPtr from Graphic2d; - myPrimitives: SequenceOfPrimitives from Graphic2d; - myObjects: SequenceOfGraphicObject from Graphic2d; - -friends - - class View from Graphic2d - -end Buffer from Graphic2d; diff --git a/src/Graphic2d/Graphic2d_Buffer.cxx b/src/Graphic2d/Graphic2d_Buffer.cxx deleted file mode 100755 index 5565c2c25d..0000000000 --- a/src/Graphic2d/Graphic2d_Buffer.cxx +++ /dev/null @@ -1,503 +0,0 @@ -// Copyright (c) 1995-1999 Matra Datavision -// Copyright (c) 1999-2012 OPEN CASCADE SAS -// -// The content of this file is subject to the Open CASCADE Technology Public -// License Version 6.5 (the "License"). You may not use the content of this file -// except in compliance with the License. Please obtain a copy of the License -// at http://www.opencascade.org and read it completely before using this file. -// -// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its -// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. -// -// The Original Code and all software distributed under the License is -// distributed on an "AS IS" basis, without warranty of any kind, and the -// Initial Developer hereby disclaims all such warranties, including without -// limitation, any warranties of merchantability, fitness for a particular -// purpose or non-infringement. Please see the License for the specific terms -// and conditions governing the rights and limitations under the License. - -#define PERF //GG_270298 - - -#ifdef WNT -#define PRO19042 //GG_261199 Avoid to have black buffer because the ClearBuffer() method -// clear also the current buffer attributes ! -// Under WNT the buffer contains also the attributes. -#endif - -#define NO_TRACE 1 - -#include - -#include -#include -#include - -#include -#include -#include - -Graphic2d_Buffer::Graphic2d_Buffer (const Handle(Graphic2d_View)& aView, const Quantity_Length aPivotX, const Quantity_Length aPivotY, const Standard_Integer aWidthIndex, const Standard_Integer aColorIndex, const Standard_Integer aFontIndex, const Aspect_TypeOfDrawMode aDrawMode): - myBufferId(0), - myBufferIsPosted (Standard_False), - myPivotX (Standard_ShortReal (aPivotX)), - myPivotY (Standard_ShortReal (aPivotY)), - myWidthIndex (aWidthIndex), - myColorIndex (aColorIndex), - myFontIndex (aFontIndex), - myDrawMode(aDrawMode), - myPView(aView.operator->()) { -} - -void Graphic2d_Buffer::Destroy () { - - if( !myDriver.IsNull() ) { - myDriver->CloseBuffer(myBufferId) ; - } -} - -void Graphic2d_Buffer::Add (const Handle(Graphic2d_GraphicObject)& anObject) { -Standard_Integer i ; - - myObjects.Append(anObject) ; - for( i=1 ; i<=anObject->Length() ; i++ ) { - myPrimitives.Append(anObject->Primitive(i)) ; - } - if( myBufferIsPosted ) { - this->ReLoad(Standard_False) ; - } -} - -void Graphic2d_Buffer::Add (const Handle(Graphic2d_Primitive)& aPrimitive) { - - myPrimitives.Append(aPrimitive) ; - if( myBufferIsPosted ) { - this->ReLoad(Standard_False) ; - } -} - -void Graphic2d_Buffer::Remove (const Handle(Graphic2d_GraphicObject)& anObject) { -Standard_Integer i,j ; - - for( i=1 ; i<=myObjects.Length() ; i++ ) { - if( anObject == myObjects.Value(i) ) break ; - } - - if( i <= myObjects.Length() ) { - myObjects.Remove(i) ; - // not very clever, but who will use Remove (anObject) ? - for( j=1 ; j<=anObject->Length() ; j++ ) { - Remove(anObject->Primitive(j)) ; - } - if( myBufferIsPosted ) { - this->ReLoad(Standard_False) ; - } - } -} - -void Graphic2d_Buffer::Remove (const Handle(Graphic2d_Primitive)& aPrimitive) { -Standard_Integer i ; - - for( i=1 ; i<=myPrimitives.Length() ; i++ ) { - if( aPrimitive == myPrimitives.Value(i) ) break ; - } - - if( i <= myPrimitives.Length() ) { - myPrimitives.Remove(i) ; - if( myBufferIsPosted ) { - this->ReLoad(Standard_False) ; - } - } -} - -void Graphic2d_Buffer::Clear () { -#ifdef TRACE -printf(" Graphic2d_Buffer::Clear()%d,%d\n",myBufferId,myBufferIsPosted); -#endif - - myPrimitives.Clear() ; - myObjects.Clear() ; - if( myBufferIsPosted ) { - myDriver->ClearBuffer(myBufferId); - } -} - -void Graphic2d_Buffer::SetAttrib (const Standard_Integer aWidthIndex, - const Standard_Integer aColorIndex, - const Standard_Integer aFontIndex, - const Aspect_TypeOfDrawMode aDrawMode) { - - if( myColorIndex != aColorIndex || myFontIndex != aFontIndex || - myWidthIndex != aWidthIndex || myDrawMode != aDrawMode ) { - - myWidthIndex = aWidthIndex ; - myColorIndex = aColorIndex ; - myFontIndex = aFontIndex ; - myDrawMode = aDrawMode ; - - if( myBufferIsPosted ) { - this->ReLoad(Standard_False) ; - } - } -} - -void Graphic2d_Buffer::SetPivot () { - - if( !myDriver.IsNull() ) { - Handle(Graphic2d_Drawer) theDrawer = myPView->Drawer() ; - Standard_ShortReal xpivot,ypivot; - - myDriver->PositionOfBuffer(myBufferId,xpivot,ypivot) ; - theDrawer->UnMapFromTo(xpivot,ypivot,myPivotX,myPivotY) ; - } -} - -void Graphic2d_Buffer::SetPivot ( const Quantity_Length aPivotX, const Quantity_Length aPivotY) { - - myPivotX = Standard_ShortReal( aPivotX ); - myPivotY = Standard_ShortReal( aPivotY ); - - if( myBufferIsPosted ) { - this->ReLoad(Standard_False) ; - } -} - -void Graphic2d_Buffer::Move (const Quantity_Length aDeltaX, const Quantity_Length aDeltaY) { - - if( myBufferIsPosted ) { - Handle(Graphic2d_Drawer) theDrawer = myPView->Drawer(); - Standard_ShortReal xpivot, ypivot; - theDrawer->GetMapFromTo(Standard_ShortReal(aDeltaX), - Standard_ShortReal(aDeltaY),xpivot,ypivot); - myDriver->MoveBuffer(myBufferId, xpivot, ypivot); - } -} - -void Graphic2d_Buffer::Rotate (const Quantity_PlaneAngle anAngle) { - - if( myBufferIsPosted ) { - myDriver->RotateBuffer(myBufferId,anAngle) ; - } -} - -void Graphic2d_Buffer::Scale (const Quantity_Factor aFactor) { - - if( myBufferIsPosted ) { - myDriver->ScaleBuffer(myBufferId,aFactor,aFactor) ; - } -} - -Standard_Boolean Graphic2d_Buffer::IsEmpty () const { - - if( !myDriver.IsNull() ) { - return myDriver->BufferIsEmpty(myBufferId) ; - } else { - return Standard_True ; - } -} - -Standard_Boolean Graphic2d_Buffer::IsIn (const Handle(Graphic2d_GraphicObject)& anObject) const { -Standard_Integer i,length = myObjects.Length() ; - - for( i=1 ; i<=length ; i++ ) { - if( anObject == myObjects.Value(i) ) break ; - } - - if( i <= length ) return Standard_True ; - else return Standard_False; -} - -Standard_Boolean Graphic2d_Buffer::IsIn (const Handle(Graphic2d_Primitive)& aPrimitive) const { -Standard_Integer i,length = myPrimitives.Length() ; - - for( i=1 ; i<=length ; i++ ) { - if( aPrimitive == myPrimitives.Value(i) ) break ; - } - - if( i <= length ) return Standard_True ; - else return Standard_False; -} - -void Graphic2d_Buffer::Post () { -Handle(Graphic2d_Drawer) theDrawer = myPView->Drawer() ; -Standard_Boolean reset = Standard_True; -#ifdef TRACE -printf(" Graphic2d_Buffer::Post()%d\n",myBufferIsPosted); -#endif - - if( theDrawer->IsWindowDriver() ) { - if( myBufferIsPosted ) { - reset = Standard_False; - UnPost() ; - } - myDriver = theDrawer->WindowDriver() ; - myBufferIsPosted = Standard_True ; - this->ReLoad(reset) ; - myPView->Add(this); - } -} - -void Graphic2d_Buffer::Post ( const Handle(Aspect_WindowDriver)& aDriver, - const Handle(Graphic2d_ViewMapping)& aViewMapping, - const Standard_Real aXPosition, - const Standard_Real aYPosition, - const Standard_Real aScale) { - -Handle(Graphic2d_Drawer) theDrawer = myPView->Drawer() ; -Standard_Boolean reset = Standard_True; -#ifdef TRACE -printf(" Graphic2d_Buffer::Post(%lx,%lx,%f,%f,%f)%d\n", -aDriver,aViewMapping,aXPosition,aYPosition,aScale,myBufferIsPosted); -#endif - - Standard_Real XCenter, YCenter, Size; - - if( myBufferIsPosted && (aDriver == myDriver) ) { - reset = Standard_False; - UnPost() ; - } - myDriver = aDriver; - aViewMapping->ViewMapping(XCenter, YCenter, Size); - theDrawer->SetDriver(aDriver); - theDrawer->SetValues (XCenter, YCenter, Size, - aXPosition, aYPosition, aScale, aViewMapping->Zoom()); - - myBufferIsPosted = Standard_True ; - this->ReLoad(reset) ; - myPView->Add(this); -} - -void Graphic2d_Buffer::UnPost () { -#ifdef TRACE -printf(" Graphic2d_Buffer::UnPost()%d\n",myBufferIsPosted); -#endif - - if( myBufferIsPosted ) { - this->Erase() ; - myBufferIsPosted = Standard_False ; - myPView->Remove(this); - } -} - -Standard_Boolean Graphic2d_Buffer::IsPosted () const { - - return myBufferIsPosted ; -} - -Standard_Boolean Graphic2d_Buffer::IsPosted ( const Handle(Aspect_WindowDriver)& aDriver) const { - - return (myBufferIsPosted && (aDriver == myDriver)) ; -} - -void Graphic2d_Buffer::Erase () { -#ifdef TRACE -printf(" Graphic2d_Buffer::Erase()%d\n",myBufferIsPosted); -#endif - - if( myBufferIsPosted ) { - myDriver->EraseBuffer(myBufferId) ; - } -} - -void Graphic2d_Buffer::Draw () { -#ifdef TRACE -printf(" Graphic2d_Buffer::Draw()%d\n",myBufferIsPosted); -#endif - - if( myBufferIsPosted ) { - Handle(Graphic2d_Drawer) theDrawer = myPView->Drawer() ; - Standard_Integer i,length = myPrimitives.Length() ; - theDrawer->SetRejection(Standard_False); - myDriver->BeginDraw(Standard_False,myBufferId); - for( i=1 ; i<=length ; i++ ) { - myPrimitives.Value(i)->Draw(theDrawer); - } - myDriver->EndDraw() ; - theDrawer->SetRejection(Standard_True); - } -} - -void Graphic2d_Buffer::ReLoad (const Standard_Boolean ResetPosition) { - -Standard_Boolean theStatus = Standard_False; -Standard_Integer theColorIndex = myColorIndex; -Standard_Integer theWidthIndex = myWidthIndex; -Standard_Integer theFontIndex = myFontIndex; - -#ifdef TRACE -printf(" Graphic2d_Buffer::ReLoad(%d)\n",ResetPosition); -#endif - if( !myDriver.IsNull() ) { - - myBufferId = ::HashCode ((Standard_Address)this, IntegerLast()); - - // Maximum depth of primitive lines - // contained in the buffer is required - if (theWidthIndex < 0) { - Standard_Real theWidthMax; - // There are no primitive lines => thickness by default - if (! MaxWidth (theWidthMax, theWidthIndex)) - theWidthIndex = 0; - } - - // The font of the 1st primitive text from the buffer is required - if( theFontIndex < 0) { - Standard_Integer i; - Handle(Graphic2d_Primitive) agp; - for (i=1; i<=myPrimitives.Length(); i++) { - agp = myPrimitives.Value (i); -#ifdef PERF - if (agp->Family() == Graphic2d_TOP_TEXT) { -#else - if (agp->IsKind (STANDARD_TYPE (Graphic2d_Text))) { -#endif - theFontIndex = - (*(Handle(Graphic2d_Text ) *) &agp)->FontIndex (); - break; - - } - } - if( theFontIndex < 0 ) theFontIndex = 0; - } - - // The color of the 1st primitive from the buffer is required - if( theColorIndex < 0) { - Standard_Integer i; - for (i=1; i<=myPrimitives.Length(); i++) { - theColorIndex = myPrimitives.Value (i)->ColorIndex (); - break; - - } - if( theColorIndex < 0 ) theColorIndex = 0; - } - - Handle(Graphic2d_Drawer) theDrawer = myPView->Drawer() ; - Standard_ShortReal xpivot,ypivot; - - theDrawer->GetMapFromTo(myPivotX,myPivotY,xpivot,ypivot) ; - theStatus = myDriver->OpenBuffer(myBufferId,xpivot,ypivot, - theWidthIndex,theColorIndex,theFontIndex,myDrawMode) ; - - if( theStatus ) { - Standard_ShortReal xpos,ypos; - - myDriver->PositionOfBuffer(myBufferId,xpos,ypos) ; -#ifndef PRO19042 // Under WNT the buffer is cleared at open time - myDriver->ClearBuffer(myBufferId) ; -#endif - this->Draw() ; - if( ResetPosition ) { - myDriver->DrawBuffer(myBufferId); - } else { - myDriver->MoveBuffer(myBufferId,xpos,ypos) ; - } - } - } - - if( !theStatus ) { - myBufferIsPosted = Standard_False ; - } -} - -Standard_Boolean -Graphic2d_Buffer::MaxWidth ( - Quantity_Length& theWidth, Standard_Integer& theIndex) const { -Standard_Boolean Result = Standard_False; - - if( !myDriver.IsNull() ) { - Handle(Aspect_WidthMap) theWidthMap = myDriver->WidthMap (); - Standard_Integer i,size = theWidthMap->Size(), - length = myPrimitives.Length(); - - Quantity_Length WidthCur = 0.; - Standard_Integer IndexCur = 0; - - theWidth = 0.; - theIndex = 0; - - Handle(Graphic2d_Primitive) agp; - for (i=1; i<=length; i++) { - agp = myPrimitives.Value (i); -#ifdef PERF - if (agp->Family() == Graphic2d_TOP_LINE ) { -#else - if (agp->IsKind (STANDARD_TYPE (Graphic2d_Line))) { -#endif - // There are lines in the Buffer - // and not by fracture on the line - Result = Standard_True; - IndexCur = - (*(Handle(Graphic2d_Line) *) &agp)->WidthIndex (); - if ((IndexCur <= 0) || (IndexCur > size)) { - // Case when thicknesses are not precised, IndexCur == 0 - // or there is a really huge problem ! - } - else { - // +1 because in the table there is 1 default entry - // which defines default thickness - WidthCur = (theWidthMap->Entry (IndexCur+1)).Width (); - if (theWidth < WidthCur) { - theWidth = WidthCur; - theIndex = IndexCur; - } - } - } - } - } - return Result; -} - -Handle(Graphic2d_View) Graphic2d_Buffer::View () const { - - return ((Graphic2d_View*) myPView); - -} - -Quantity_PlaneAngle Graphic2d_Buffer::Angle () const { -Quantity_PlaneAngle angle = 0. ; - - if( !myDriver.IsNull() ) { - myDriver->AngleOfBuffer(myBufferId,angle) ; - } - - return angle; -} - -Quantity_Factor Graphic2d_Buffer::Scale () const { -Quantity_Factor xscale = 1. ; -Quantity_Factor yscale = 1. ; - - if( !myDriver.IsNull() ) { - myDriver->ScaleOfBuffer(myBufferId,xscale,yscale) ; - } - - return (xscale+yscale)/2. ; -} - -Quantity_Length Graphic2d_Buffer::Xpivot () const { -Handle(Graphic2d_Drawer) theDrawer = myPView->Drawer() ; -Standard_ShortReal pivotx = myPivotX ; -Standard_ShortReal pivoty = myPivotY ; - - if( !myDriver.IsNull() ) { - Standard_ShortReal xpivot,ypivot ; - myDriver->PositionOfBuffer(myBufferId,xpivot,ypivot) ; - theDrawer->UnMapFromTo(xpivot,ypivot,pivotx,pivoty) ; - } - - return Quantity_Length(pivotx); -} - -Quantity_Length Graphic2d_Buffer::Ypivot() const { -Handle(Graphic2d_Drawer) theDrawer = myPView->Drawer() ; -Standard_ShortReal pivotx = myPivotX ; -Standard_ShortReal pivoty = myPivotY ; - - if( !myDriver.IsNull() ) { - Standard_ShortReal xpivot,ypivot ; - myDriver->PositionOfBuffer(myBufferId,xpivot,ypivot) ; - theDrawer->UnMapFromTo(xpivot,ypivot,pivotx,pivoty) ; - } - - return Quantity_Length(pivoty); -} diff --git a/src/Graphic2d/Graphic2d_CBitFields8.cxx b/src/Graphic2d/Graphic2d_CBitFields8.cxx deleted file mode 100755 index fa84bd2b5a..0000000000 --- a/src/Graphic2d/Graphic2d_CBitFields8.cxx +++ /dev/null @@ -1,27 +0,0 @@ -// Copyright (c) 1995-1999 Matra Datavision -// Copyright (c) 1999-2012 OPEN CASCADE SAS -// -// The content of this file is subject to the Open CASCADE Technology Public -// License Version 6.5 (the "License"). You may not use the content of this file -// except in compliance with the License. Please obtain a copy of the License -// at http://www.opencascade.org and read it completely before using this file. -// -// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its -// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. -// -// The Original Code and all software distributed under the License is -// distributed on an "AS IS" basis, without warranty of any kind, and the -// Initial Developer hereby disclaims all such warranties, including without -// limitation, any warranties of merchantability, fitness for a particular -// purpose or non-infringement. Please see the License for the specific terms -// and conditions governing the rights and limitations under the License. - - -#include - -const Handle(Standard_Type)& STANDARD_TYPE(Graphic2d_CBitFields8) -{ - static Handle(Standard_Type) _atype = - new Standard_Type ("Graphic2d_CBitFields8", sizeof (Graphic2d_CBitFields8)); - return _atype; -} diff --git a/src/Graphic2d/Graphic2d_CBitFields8.hxx b/src/Graphic2d/Graphic2d_CBitFields8.hxx deleted file mode 100755 index 35631885ef..0000000000 --- a/src/Graphic2d/Graphic2d_CBitFields8.hxx +++ /dev/null @@ -1,50 +0,0 @@ -// Copyright (c) 1995-1999 Matra Datavision -// Copyright (c) 1999-2012 OPEN CASCADE SAS -// -// The content of this file is subject to the Open CASCADE Technology Public -// License Version 6.5 (the "License"). You may not use the content of this file -// except in compliance with the License. Please obtain a copy of the License -// at http://www.opencascade.org and read it completely before using this file. -// -// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its -// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. -// -// The Original Code and all software distributed under the License is -// distributed on an "AS IS" basis, without warranty of any kind, and the -// Initial Developer hereby disclaims all such warranties, including without -// limitation, any warranties of merchantability, fitness for a particular -// purpose or non-infringement. Please see the License for the specific terms -// and conditions governing the rights and limitations under the License. - -/*===========================================================================*/ -/*==== Titre: Graphic2d_CBitFields8.hxx */ -/*==== Role : The header file of primitive type "CBitFields8" from Graphic2d */ -/*==== */ -/*==== Implementation: This is a primitive type implemented with typedef */ -/*===========================================================================*/ - -#ifndef _Graphic2d_CBitFields8_HeaderFile -#define _Graphic2d_CBitFields8_HeaderFile - -typedef struct { - - unsigned bool1 :1; - unsigned bool2 :1; - unsigned bool3 :1; - unsigned bool4 :1; - - unsigned bool5 :1; - unsigned bool6 :1; - unsigned bool7 :1; - unsigned bool8 :1; - -} Graphic2d_CBitFields8; - -#if defined(__cplusplus) || defined(c_plusplus) -/*==== Definition de Type ====================================================*/ -#include -const Handle(Standard_Type)& STANDARD_TYPE(Graphic2d_CBitFields8); -/*============================================================================*/ - -#endif -#endif /*Graphic2d_CBitFields8_HeaderFile*/ diff --git a/src/Graphic2d/Graphic2d_CMPLRS.edl b/src/Graphic2d/Graphic2d_CMPLRS.edl deleted file mode 100755 index 71e2293fe8..0000000000 --- a/src/Graphic2d/Graphic2d_CMPLRS.edl +++ /dev/null @@ -1,29 +0,0 @@ --- Created on: 1996-10-03 --- Created by: Jean GAUTIER --- Copyright (c) 1996-1999 Matra Datavision --- Copyright (c) 1999-2012 OPEN CASCADE SAS --- --- The content of this file is subject to the Open CASCADE Technology Public --- License Version 6.5 (the "License"). You may not use the content of this file --- except in compliance with the License. Please obtain a copy of the License --- at http://www.opencascade.org and read it completely before using this file. --- --- The Initial Developer of the Original Code is Open CASCADE S.A.S., having its --- main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. --- --- The Original Code and all software distributed under the License is --- distributed on an "AS IS" basis, without warranty of any kind, and the --- Initial Developer hereby disclaims all such warranties, including without --- limitation, any warranties of merchantability, fitness for a particular --- purpose or non-infringement. Please see the License for the specific terms --- and conditions governing the rights and limitations under the License. - - -@ifnotdefined ( %Graphic2d_CMPLRS_EDL) then - @set %Graphic2d_CMPLRS_EDL = ""; - @uses "CSF.edl"; - - --@uses "Graphic2d.edl"; - @string %CMPLRS_CXX_Options = %CMPLRS_CXX_Options " " %CSF_X11_INCLUDE ; - -@endif; diff --git a/src/Graphic2d/Graphic2d_Circle.cdl b/src/Graphic2d/Graphic2d_Circle.cdl deleted file mode 100755 index e127b09215..0000000000 --- a/src/Graphic2d/Graphic2d_Circle.cdl +++ /dev/null @@ -1,157 +0,0 @@ --- Created on: 1993-06-22 --- Created by: Jean Louis FRENKEL, Gerard GRAS --- Copyright (c) 1993-1999 Matra Datavision --- Copyright (c) 1999-2012 OPEN CASCADE SAS --- --- The content of this file is subject to the Open CASCADE Technology Public --- License Version 6.5 (the "License"). You may not use the content of this file --- except in compliance with the License. Please obtain a copy of the License --- at http://www.opencascade.org and read it completely before using this file. --- --- The Initial Developer of the Original Code is Open CASCADE S.A.S., having its --- main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. --- --- The Original Code and all software distributed under the License is --- distributed on an "AS IS" basis, without warranty of any kind, and the --- Initial Developer hereby disclaims all such warranties, including without --- limitation, any warranties of merchantability, fitness for a particular --- purpose or non-infringement. Please see the License for the specific terms --- and conditions governing the rights and limitations under the License. - - --- Modified: TCL G002, 07-08-00, new inquire methods Center, Radius, FirstAngle, SecondAngle --- new methods SetRadius, SetCenter, SetAngles - - -class Circle from Graphic2d inherits Line from Graphic2d - - ---Purpose: Constructs a primitive Circle - - -uses - Drawer from Graphic2d, - GraphicObject from Graphic2d, - Length from Quantity, - PlaneAngle from Quantity, - FStream from Aspect, - IFStream from Aspect - -raises - CircleDefinitionError from Graphic2d - -is - ------------------------- - -- Category: Constructors - ------------------------- - - Create (aGraphicObject: GraphicObject from Graphic2d; - X, Y: Length from Quantity; - Radius: Length from Quantity) - returns mutable Circle from Graphic2d - ---Level: Public - ---Purpose: Creates a complete circle. - -- The center is , . - -- The radius is . - -- Warning: Raises CircleDefinitionError if the - -- radius is null. - raises CircleDefinitionError from Graphic2d; - - Create (aGraphicObject: GraphicObject from Graphic2d; - X, Y: Length from Quantity; - Radius: Length from Quantity; - Alpha, Beta: PlaneAngle from Quantity) - returns mutable Circle from Graphic2d - ---Level: Public - ---Purpose: Creates an arc. - -- The center is , . - -- The radius is . - -- Angles are measured counterclockwise with 0 radian - -- at 3 o'clock. - -- Warning: Raises CircleDefinitionError if the - -- radius is null. - raises CircleDefinitionError from Graphic2d; - - ---------------------------- - -- Category: Inquire methods - ---------------------------- - - Center( me; X, Y: out Length from Quantity ); - ---Level: Public - ---Purpose: returns the coordinates of center of the circle - - Radius( me ) returns Length from Quantity; - ---Level: Public - ---Purpose: returns the radius of this circle - - FirstAngle( me ) returns PlaneAngle from Quantity; - ---Level: Public - ---Purpose: returns the first angle of the arc - - SecondAngle( me ) returns PlaneAngle from Quantity; - ---Level: Public - ---Purpose: returns the second angle of the arc - - - -------------------------------------------------------- - -- Category: Methods for the definition of the circle's properties - -------------------------------------------------------- - - SetCenter( me: mutable; X, Y: Length from Quantity ); - ---Level: Public - ---Purpose: defines the coordinates of center of the circle - - SetRadius( me: mutable; theR: Length from Quantity ); - ---Level: Public - ---Purpose: defines the radius of this circle - - SetAngles( me: mutable; Alpha, Beta: PlaneAngle from Quantity ); - ---Level: Public - ---Purpose: defines the angles of the arc - - -------------------------- - -- Category: Draw and Pick - -------------------------- - - Draw (me : mutable; aDrawer: Drawer from Graphic2d) - is static protected; - ---Level: Internal - ---Purpose: Draws the circle . - - DrawElement( me : mutable; aDrawer: Drawer from Graphic2d; - anIndex: Integer from Standard) - is redefined protected; - ---Level: Internal - ---Purpose: Draws element of the circle . - - DrawVertex( me : mutable; aDrawer: Drawer from Graphic2d; - anIndex: Integer from Standard) - is redefined protected; - ---Level: Internal - ---Purpose: Draws vertex of the circle . - - Pick (me : mutable; X, Y: ShortReal from Standard; - aPrecision: ShortReal from Standard; - aDrawer: Drawer from Graphic2d) - returns Boolean from Standard is static protected; - ---Level: Internal - ---Purpose: Returns Standard_True if the circle is picked, - -- Standard_False if not. - - DoMinMax( me: mutable ) is private; - - ---------------------------------------------------------------------- - - Save( me; aFStream: in out FStream from Aspect ) is virtual; - Retrieve( myclass; anIFStream: in out IFStream from Aspect; - aGraphicObject: GraphicObject from Graphic2d ); - -fields - - myX: ShortReal from Standard; - myY: ShortReal from Standard; - myRadius: ShortReal from Standard; - myFirstAngle: ShortReal from Standard; - mySecondAngle: ShortReal from Standard; - myisArc: Boolean from Standard; - -end Circle from Graphic2d; diff --git a/src/Graphic2d/Graphic2d_Circle.cxx b/src/Graphic2d/Graphic2d_Circle.cxx deleted file mode 100755 index 966b982c60..0000000000 --- a/src/Graphic2d/Graphic2d_Circle.cxx +++ /dev/null @@ -1,438 +0,0 @@ -// Copyright (c) 1995-1999 Matra Datavision -// Copyright (c) 1999-2012 OPEN CASCADE SAS -// -// The content of this file is subject to the Open CASCADE Technology Public -// License Version 6.5 (the "License"). You may not use the content of this file -// except in compliance with the License. Please obtain a copy of the License -// at http://www.opencascade.org and read it completely before using this file. -// -// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its -// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. -// -// The Original Code and all software distributed under the License is -// distributed on an "AS IS" basis, without warranty of any kind, and the -// Initial Developer hereby disclaims all such warranties, including without -// limitation, any warranties of merchantability, fitness for a particular -// purpose or non-infringement. Please see the License for the specific terms -// and conditions governing the rights and limitations under the License. - - -#define PRO3730 - -#define WTO0006 //GG_221196 -// Ne pas transformer les cercles pleins en arc de cercles -// presque pleins a EPSILON pres car dans ce cas les -// JAP ne peuvent plus tracer leur drapeaux !!! - -#define BUC50076//GG_231097/090298 -// Attention aux transformations de type MIRROR -// car dans ce cas il faut inverser le parcours de l'arc et -// surtout ne pas annuler la translation dans la matrice! - - -#define G002 //Add new DrawElement(), DrawVertex() methods - -#define VERTEXMARKER 2 -#define DEFAULTMARKERSIZE 3.0 -#define MAXPOINTS 1023 - -#include -#include -#include -#include - -#include - -Graphic2d_Circle::Graphic2d_Circle - (const Handle(Graphic2d_GraphicObject)& aGraphicObject, - const Quantity_Length X, const Quantity_Length Y, const Quantity_Length Radius) - : Graphic2d_Line(aGraphicObject) { - - myX = Standard_ShortReal(X); - myY = Standard_ShortReal(Y); - myRadius = Standard_ShortReal(Radius); - - if ( myRadius <= ShortRealEpsilon ()) - Graphic2d_CircleDefinitionError::Raise ("The radius = 0."); - - DoMinMax(); - myFirstAngle = 0.; - mySecondAngle = Standard_ShortReal(2. * M_PI); - myisArc = Standard_False; - myNumOfElem = MAXPOINTS + 1; - myNumOfVert = 3; -} - -Graphic2d_Circle::Graphic2d_Circle - (const Handle(Graphic2d_GraphicObject)& aGraphicObject, - const Quantity_Length X, const Quantity_Length Y, - const Quantity_Length Radius, const Quantity_PlaneAngle Alpha, - const Quantity_PlaneAngle Beta) - : Graphic2d_Line(aGraphicObject) { - - myX = Standard_ShortReal(X); - myY = Standard_ShortReal(Y); - myRadius = Standard_ShortReal(Radius); - myisArc = Standard_True; - if (myRadius <= ShortRealEpsilon ()) - Graphic2d_CircleDefinitionError::Raise ("The radius = 0."); - myNumOfElem = MAXPOINTS + 1; - myNumOfVert = 3; -#ifdef PRO3730 - Standard_ShortReal TwoPI = Standard_ShortReal(2. * M_PI); - myFirstAngle = Standard_ShortReal (Alpha); - mySecondAngle = Standard_ShortReal (Beta); - while( myFirstAngle < 0. ) myFirstAngle += TwoPI; - while( myFirstAngle > 2. * M_PI ) myFirstAngle -= TwoPI; - while( mySecondAngle < 0. ) mySecondAngle += TwoPI; - while( mySecondAngle > 2. * M_PI ) mySecondAngle -= TwoPI; - if( mySecondAngle < myFirstAngle ) mySecondAngle += TwoPI; - if ( (mySecondAngle - myFirstAngle < ShortRealEpsilon()) || - (mySecondAngle - myFirstAngle >= TwoPI) ) { - myFirstAngle = 0.; - mySecondAngle = TwoPI; - DoMinMax(); - } else { - Standard_ShortReal Acur,Xcur,Ycur,Xsav; - myMinX = myMaxX = Standard_ShortReal(Cos(myFirstAngle)); - myMinY = myMaxY = Standard_ShortReal(Sin(myFirstAngle)); - Xcur = Standard_ShortReal(Cos(mySecondAngle)); - Ycur = Standard_ShortReal(Sin(mySecondAngle)); - myMinX = myMinX < Xcur ? myMinX : Xcur; - myMaxX = myMaxX < Xcur ? Xcur : myMaxX; - myMinY = myMinY < Ycur ? myMinY : Ycur; - myMaxY = myMaxY < Ycur ? Ycur : myMaxY; - - for( Acur = 0.,Xcur = 1.,Ycur = 0.; - Acur < mySecondAngle; Acur += Standard_ShortReal(M_PI / 2.) ) { - if( Acur > myFirstAngle ) { - myMinX = ( myMinX < Xcur ? myMinX : Xcur ); - myMaxX = ( myMaxX < Xcur ? Xcur : myMaxX ); - myMinY = ( myMinY < Ycur ? myMinY : Ycur ); - myMaxY = ( myMaxY < Ycur ? Ycur : myMaxY ); - } - Xsav = Xcur ;Xcur = -Ycur; Ycur = Xsav; - } - myMinX = myX + myRadius * myMinX; - myMaxX = myX + myRadius * myMaxX; - myMinY = myY + myRadius * myMinY; - myMaxY = myY + myRadius * myMaxY; - } -#else - DoMinMax(); -#endif -} - -void Graphic2d_Circle :: Center ( Quantity_Length& X,Quantity_Length& Y ) const { - - X = Quantity_Length(myX); - Y = Quantity_Length(myY); -} - -Quantity_Length Graphic2d_Circle :: Radius ( ) const { - - return Quantity_Length(myRadius); -} - -Quantity_PlaneAngle Graphic2d_Circle :: FirstAngle ( ) const { - - return Quantity_PlaneAngle(myFirstAngle); - -} - -Quantity_PlaneAngle Graphic2d_Circle :: SecondAngle ( ) const { - - return Quantity_PlaneAngle(mySecondAngle); - -} - -void Graphic2d_Circle::SetCenter( const Quantity_Length X, - const Quantity_Length Y ) { - myX = Standard_ShortReal( X ); - myY = Standard_ShortReal( Y ); - DoMinMax(); - -} - -void Graphic2d_Circle::SetRadius( const Quantity_Length theR ) { - myRadius = Standard_ShortReal( theR ); - DoMinMax(); -} - -void Graphic2d_Circle::SetAngles( const Quantity_PlaneAngle Alpha, - const Quantity_PlaneAngle Beta ) { - - myFirstAngle = Standard_ShortReal( Alpha ); - mySecondAngle = Standard_ShortReal( Beta ); -} - - -void Graphic2d_Circle::Draw (const Handle(Graphic2d_Drawer)& aDrawer) { - - Standard_Boolean IsIn = Standard_False; - - if (! myGOPtr->IsTransformed ()) - IsIn = aDrawer->IsIn (myMinX,myMaxX,myMinY,myMaxY); - else { - Standard_ShortReal minx, miny, maxx, maxy; - MinMax(minx,maxx,miny,maxy); - IsIn = aDrawer->IsIn (minx,maxx,miny,maxy); - } - - if (IsIn) { - - DrawLineAttrib(aDrawer); - - Standard_ShortReal a, b, c, e, f; - - a = myX; b = myY; c = myRadius; - e = myFirstAngle; f = mySecondAngle; - if (myGOPtr->IsTransformed ()) { - gp_GTrsf2d aTrsf = myGOPtr->Transform (); - Standard_Real A, B; - Standard_Real X0, Y0, X1, Y1, X2, Y2, E, F; - A = Standard_Real (a); B = Standard_Real (b); - E = Standard_Real (e); F = Standard_Real (f); - aTrsf.Transforms (A, B); - a = Standard_ShortReal (A); b = Standard_ShortReal (B); - if( Abs(f-e) < Standard_ShortReal(2. * M_PI) ) { - // To calculate new aperture angles - // the calculation is done on the trigonometric circle - // and in this case the translation is not taken into account - // except for transformations of type Mirror - // with negative determinant. -#ifndef BUC50076 - aTrsf.SetValue (1, 3, 0.0); - aTrsf.SetValue (2, 3, 0.0); -#endif - X1 = Cos (E); Y1 = Sin (E); - X2 = Cos (F); Y2 = Sin (F); - aTrsf.Transforms (X1, Y1); - aTrsf.Transforms (X2, Y2); -#ifdef BUC50076 - X0 = Y0 = 0.; - aTrsf.Transforms (X0, Y0); - X1 -= X0; Y1 -= Y0; - X2 -= X0; Y2 -= Y0; -#endif - c = myRadius * Standard_ShortReal(Sqrt(X1*X1 + Y1*Y1)); - e = Standard_ShortReal(atan2(Y1,X1)); - f = Standard_ShortReal(atan2(Y2,X2)); -#ifdef BUC50076 - if( aTrsf.IsNegative() ) { - Standard_ShortReal t = e; e = f; f = t; - } -#endif - } - } - - if (myTypeOfPolygonFilling == Graphic2d_TOPF_EMPTY) { - aDrawer->MapArcFromTo(a, b, c, e, f); - } else { - aDrawer->MapPolyArcFromTo(a, b, c, e, f); - } - - } -} - -#ifdef G002 - -void Graphic2d_Circle::DrawElement( const Handle(Graphic2d_Drawer)& aDrawer, - const Standard_Integer anIndex) { - - Standard_Boolean IsIn = Standard_False; - - if (! myGOPtr->IsTransformed ()) - IsIn = aDrawer->IsIn (myMinX,myMaxX,myMinY,myMaxY); - else { - Standard_ShortReal minx, miny, maxx, maxy; - MinMax(minx,maxx,miny,maxy); - IsIn = aDrawer->IsIn (minx,maxx,miny,maxy); - } - - if ( IsIn ) { - - DrawLineAttrib(aDrawer); - - if ( anIndex > 0 && anIndex <= MAXPOINTS + 1 ) { - - Standard_ShortReal teta = Abs( mySecondAngle - myFirstAngle ) / MAXPOINTS; - Standard_ShortReal Xp = Standard_ShortReal(myX + myRadius * Cos(myFirstAngle + teta*(anIndex-1))), - Yp = Standard_ShortReal(myY + myRadius * Sin(myFirstAngle + teta*(anIndex-1))); - Standard_Real A, B, C, D; - Standard_ShortReal a = myX, b = myY, c = Xp, d = Yp; - if ( myGOPtr->IsTransformed() ) { - gp_GTrsf2d aTrsf = myGOPtr->Transform (); - A = Standard_Real(a); - B = Standard_Real(b); - C = Standard_Real(c); - D = Standard_Real(d); - aTrsf.Transforms (A, B); - aTrsf.Transforms (C, D); - a = Standard_ShortReal(A); - b = Standard_ShortReal(B); - c = Standard_ShortReal(C); - d = Standard_ShortReal(D); - } - - aDrawer->MapSegmentFromTo( a, b, c, d ); - } - } - -} - -void Graphic2d_Circle::DrawVertex( const Handle(Graphic2d_Drawer)& aDrawer, - const Standard_Integer anIndex) { - - Standard_Boolean IsIn = Standard_False; - - if ( ! myGOPtr->IsTransformed() ) - IsIn = aDrawer->IsIn( myMinX, myMaxX, myMinY, myMaxY ); - else { - Standard_ShortReal minx, miny, maxx, maxy; - MinMax( minx, maxx, miny, maxy ); - IsIn = aDrawer->IsIn( minx, maxx, miny, maxy ); - } - - if ( IsIn ) { - if ( anIndex > 0 && anIndex < 4) { - DrawMarkerAttrib( aDrawer ); - Standard_ShortReal X=0.,Y=0.; - if ( anIndex == 1 ) { - X = myX; Y = myY; - } else if ( anIndex == 2 ) { - X = Standard_ShortReal( myX + myRadius *Cos( myFirstAngle ) ); - Y = Standard_ShortReal( myY + myRadius *Sin( myFirstAngle ) ); - } else if ( anIndex == 3 ) { - X = Standard_ShortReal( myX + myRadius *Cos( mySecondAngle ) ); - Y = Standard_ShortReal( myY + myRadius *Sin( mySecondAngle ) ); - } - if ( myGOPtr->IsTransformed() ) { - gp_GTrsf2d aTrsf = myGOPtr->Transform (); - Standard_Real A, B; - A = Standard_Real( X ); - B = Standard_Real( Y ); - aTrsf.Transforms (A, B); - X = Standard_ShortReal( A ); - Y = Standard_ShortReal( B ); - } - aDrawer->MapMarkerFromTo( VERTEXMARKER, X, Y, - DEFAULTMARKERSIZE,DEFAULTMARKERSIZE, 0.0 ); - } - } // end if IsIn is true -} - -#endif - -Standard_Boolean Graphic2d_Circle::Pick (const Standard_ShortReal X, - const Standard_ShortReal Y, - const Standard_ShortReal aPrecision, - const Handle(Graphic2d_Drawer)& /*aDrawer*/) { - - Standard_Boolean found = Standard_False; - Standard_ShortReal SRX = X, SRY = Y; - - if ( IsInMinMax( X, Y, aPrecision) ) { - if ( myGOPtr->IsTransformed() ) { - gp_GTrsf2d aTrsf = ( myGOPtr->Transform () ).Inverted (); - Standard_Real RX = Standard_Real (SRX), RY = Standard_Real (SRY); - aTrsf.Transforms( RX, RY ); - SRX = Standard_ShortReal( RX ); - SRY = Standard_ShortReal( RY ); - } - #ifdef G002 - if ( Graphic2d_Primitive::IsOn( SRX, SRY, myX, myY, aPrecision) ) { - SetPickedIndex(-1); - return Standard_True; - } else { - if ( myisArc ) { - Standard_ShortReal x1 = Standard_ShortReal(myRadius *Cos( myFirstAngle ) + myX), - y1 = Standard_ShortReal(myRadius *Sin( myFirstAngle ) + myY), - x2 = Standard_ShortReal(myRadius *Cos( mySecondAngle ) + myX), - y2 = Standard_ShortReal(myRadius *Sin( mySecondAngle ) + myY); - - if ( Graphic2d_Primitive::IsOn( SRX, SRY, x1, y1, aPrecision) ) { - SetPickedIndex(-2); - return Standard_True; - } else if ( Graphic2d_Primitive::IsOn( SRX, SRY, x2, y2, aPrecision) ) { - SetPickedIndex(-3); - return Standard_True; - } - } - - Standard_ShortReal alpha = Abs( mySecondAngle - myFirstAngle ); - TShort_Array1OfShortReal Xpoint(1,MAXPOINTS+1); - TShort_Array1OfShortReal Ypoint(1,MAXPOINTS+1); - - Standard_ShortReal teta = alpha / MAXPOINTS; - - for ( Standard_Integer i = 1; i<= MAXPOINTS+1; i++) { - Xpoint(i) = Standard_ShortReal(myX + myRadius * Cos(myFirstAngle + teta*(i-1))); - Ypoint(i) = Standard_ShortReal(myY + myRadius * Sin(myFirstAngle + teta*(i-1))); - if ( Graphic2d_Primitive::IsOn( SRX, SRY, Xpoint(i), Ypoint(i), aPrecision) ) { - SetPickedIndex(i); - return Standard_True; - } - } - if ( myTypeOfPolygonFilling != Graphic2d_TOPF_EMPTY ) - found = Abs( Sqrt((myX - SRX)*(myX - SRX) + (myY - SRY)*(myY - SRY))) - < myRadius; - if ( !found ) - found = Abs( Sqrt( (myX - SRX)*(myX - SRX) + (myY - SRY)*(myY - SRY)) - - myRadius ) < aPrecision; - if ( found ) - SetPickedIndex( 0 ); - } - #else - if ( myTypeOfPolygonFilling != Graphic2d_TOPF_EMPTY ) - found = Abs( Sqrt((myX - SRX)*(myX - SRX) + (myY - SRY)*(myY - SRY))) - < myRadius; - - if ( !found ) - found = Abs( Sqrt( (myX - SRX)*(myX - SRX) + (myY - SRY)*(myY - SRY)) - - myRadius ) < aPrecision; - #endif - } - - return found; -} - -void Graphic2d_Circle::DoMinMax() { - - myMinX = myX - myRadius; myMinY = myY - myRadius; - myMaxX = myX + myRadius; myMaxY = myY + myRadius; - -} - -void Graphic2d_Circle::Save(Aspect_FStream& aFStream) const -{ - *aFStream << "Graphic2d_Circle" << endl; - *aFStream << myX << ' ' << myY << endl; - *aFStream << myRadius << endl; - *aFStream << myisArc << endl; - if (myisArc) - *aFStream << myFirstAngle << ' ' << mySecondAngle << endl; - Graphic2d_Line::Save(aFStream); -} - -void Graphic2d_Circle::Retrieve(Aspect_IFStream& anIFStream, - const Handle(Graphic2d_GraphicObject)& aGraphicObject) -{ - Quantity_Length X, Y, Rad; - Quantity_PlaneAngle Ang1, Ang2; - int isArc; - Handle(Graphic2d_Circle) theCir; - - *anIFStream >> X >> Y; - *anIFStream >> Rad; - *anIFStream >> isArc; - if (isArc) - { - *anIFStream >> Ang1 >> Ang2; - theCir = new Graphic2d_Circle(aGraphicObject, X, Y, Rad, Ang1, Ang2); - } - else - theCir = new Graphic2d_Circle(aGraphicObject, X, Y, Rad); - ((Handle (Graphic2d_Line))theCir)->Retrieve(anIFStream); -} - diff --git a/src/Graphic2d/Graphic2d_CircleMarker.cdl b/src/Graphic2d/Graphic2d_CircleMarker.cdl deleted file mode 100755 index 73ef7c1bcb..0000000000 --- a/src/Graphic2d/Graphic2d_CircleMarker.cdl +++ /dev/null @@ -1,153 +0,0 @@ --- Created on: 1993-06-22 --- Created by: Jean Louis FRENKEL --- Copyright (c) 1993-1999 Matra Datavision --- Copyright (c) 1999-2012 OPEN CASCADE SAS --- --- The content of this file is subject to the Open CASCADE Technology Public --- License Version 6.5 (the "License"). You may not use the content of this file --- except in compliance with the License. Please obtain a copy of the License --- at http://www.opencascade.org and read it completely before using this file. --- --- The Initial Developer of the Original Code is Open CASCADE S.A.S., having its --- main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. --- --- The Original Code and all software distributed under the License is --- distributed on an "AS IS" basis, without warranty of any kind, and the --- Initial Developer hereby disclaims all such warranties, including without --- limitation, any warranties of merchantability, fitness for a particular --- purpose or non-infringement. Please see the License for the specific terms --- and conditions governing the rights and limitations under the License. - - --- Modified: TCL G002A, 28-11-00, new section "inquire methods" - - -class CircleMarker from Graphic2d inherits VectorialMarker from Graphic2d - - ---Purpose: The primitive CircleMarker - -- Every marker takes a reference point as an argument in - -- its constructor. CircleMarker and EllipsMarker take - -- another point as the center and PolylineMarker takes the - -- first point of its list as its origin. - -- The coordinates of the centre or origin point are offsets - -- with respect to the reference point. - - ---Keywords: Primitive, CircleMarker - ---Warning: - ---References: - -uses - Drawer from Graphic2d, - GraphicObject from Graphic2d, - Length from Quantity, - PlaneAngle from Quantity, - FStream from Aspect, - IFStream from Aspect - - -raises - CircleDefinitionError from Graphic2d - -is - ------------------------- - -- Category: Constructors - ------------------------- - - Create( aGraphicObject: GraphicObject from Graphic2d; - aXPosition, aYPosition: Length from Quantity; - X, Y: Length from Quantity; - Radius: Length from Quantity) - returns mutable CircleMarker from Graphic2d - ---Level: Public - ---Purpose: Creates a complete circle. - -- The reference point is , - -- The center is , . - -- The radius is . - -- Warning: Raises CircleDefinitionError if the - -- radius is null. - raises CircleDefinitionError from Graphic2d; - - Create( aGraphicObject: GraphicObject from Graphic2d; - aXPosition, aYPosition: Length from Quantity; - X, Y: Length from Quantity; - Radius: Length from Quantity; - Alpha , Beta: PlaneAngle from Quantity) - returns mutable CircleMarker from Graphic2d - ---Level: Public - ---Purpose: Creates an arc. - -- The reference point is , - -- The center is , . - -- The radius is . - -- Angles are measured counterclockwise with 0 radian - -- at 3 o'clock. - -- Warning: Raises CircleDefinitionError if the - -- radius is null. - raises CircleDefinitionError from Graphic2d; - - - -------------------------- - -- Category: Draw and Pick - -------------------------- - - Draw (me : mutable; aDrawer: Drawer from Graphic2d) - is static protected; - ---Level: Internal - ---Purpose: Draws the circle . - - DrawElement( me : mutable; aDrawer: Drawer from Graphic2d; - anIndex: Integer from Standard) - is redefined protected; - ---Level: Internal - ---Purpose: Draws element of the circle marker . - - DrawVertex( me : mutable; aDrawer: Drawer from Graphic2d; - anIndex: Integer from Standard) - is redefined protected; - ---Level: Internal - ---Purpose: Draws vertex of the circle marker . - - - Pick (me : mutable; X, Y: ShortReal from Standard; - aPrecision: ShortReal from Standard; - aDrawer: Drawer from Graphic2d) - returns Boolean from Standard is static protected; - ---Level: Internal - ---Purpose: Returns Standard_True if the circle is picked, - -- Standard_False if not. - - -------------------------------------- - -- Category: Inquire methods - -------------------------------------- - - Center( me; X, Y: out Length from Quantity ); - ---Level: Public - ---Purpose: returns the coordinates of center of the circle marker - - Radius( me ) returns Length from Quantity; - ---Level: Public - ---Purpose: returns the radius of this circle marker - - FirstAngle( me ) returns PlaneAngle from Quantity; - ---Level: Public - ---Purpose: returns the first angle of the arc marker - - SecondAngle( me ) returns PlaneAngle from Quantity; - ---Level: Public - ---Purpose: returns the second angle of the arc marker - - ---------------------------------------------------------------------- - - Save( me; aFStream: in out FStream from Aspect ) is virtual; - Retrieve( myclass; anIFStream: in out IFStream from Aspect; - aGraphicObject: GraphicObject from Graphic2d ); - -fields - - myX : ShortReal from Standard; - myY : ShortReal from Standard; - myRadius : ShortReal from Standard; - myFirstAngle : ShortReal from Standard; - mySecondAngle : ShortReal from Standard; - myisArc : Boolean from Standard; - -end CircleMarker from Graphic2d; diff --git a/src/Graphic2d/Graphic2d_CircleMarker.cxx b/src/Graphic2d/Graphic2d_CircleMarker.cxx deleted file mode 100755 index bc6c5461c0..0000000000 --- a/src/Graphic2d/Graphic2d_CircleMarker.cxx +++ /dev/null @@ -1,292 +0,0 @@ -// Copyright (c) 1995-1999 Matra Datavision -// Copyright (c) 1999-2012 OPEN CASCADE SAS -// -// The content of this file is subject to the Open CASCADE Technology Public -// License Version 6.5 (the "License"). You may not use the content of this file -// except in compliance with the License. Please obtain a copy of the License -// at http://www.opencascade.org and read it completely before using this file. -// -// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its -// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. -// -// The Original Code and all software distributed under the License is -// distributed on an "AS IS" basis, without warranty of any kind, and the -// Initial Developer hereby disclaims all such warranties, including without -// limitation, any warranties of merchantability, fitness for a particular -// purpose or non-infringement. Please see the License for the specific terms -// and conditions governing the rights and limitations under the License. - -// Modified 23/02/98 : FMN ; Remplacement PI par Standard_PI - -#define G002 //TCL: Add new DrawElement(), DrawVertex() methods - -#define VERTEXMARKER 2 -#define DEFAULTMARKERSIZE 3.0 -#define MAXPOINTS 1023 -#define IMPLEMENTED - -#include -#include -#include - -Graphic2d_CircleMarker::Graphic2d_CircleMarker ( - const Handle(Graphic2d_GraphicObject)& aGraphicObject, - const Quantity_Length aXPosition, - const Quantity_Length aYPosition, - const Quantity_Length X, - const Quantity_Length Y, - const Quantity_Length Radius) - - :Graphic2d_VectorialMarker (aGraphicObject, aXPosition, aYPosition), - myX (Standard_ShortReal (X)), - myY (Standard_ShortReal (Y)), - myRadius (Standard_ShortReal (Radius)), - myFirstAngle (0.0), - mySecondAngle (Standard_ShortReal (2. * M_PI)) { - - if (myRadius <= RealEpsilon ()) - Graphic2d_CircleDefinitionError::Raise ("The radius = 0."); - -#ifdef IMPLEMENTED - myMinX = myX + Standard_ShortReal (aXPosition) - myRadius; - myMinY = myY + Standard_ShortReal (aYPosition) - myRadius; - myMaxX = myX + Standard_ShortReal (aXPosition) + myRadius; - myMaxY = myY + Standard_ShortReal (aYPosition) + myRadius; -#else - myMinX = myX; - myMinY = myY; - myMaxX = myX; - myMaxY = myY; -#endif /* NOT IMPLEMENTED */ - myisArc = Standard_False; - myNumOfElem = MAXPOINTS + 1; - myNumOfVert = 3; -} - -Graphic2d_CircleMarker::Graphic2d_CircleMarker ( - const Handle(Graphic2d_GraphicObject)& aGraphicObject, - const Quantity_Length aXPosition, - const Quantity_Length aYPosition, - const Quantity_Length X, - const Quantity_Length Y, - const Quantity_Length Radius, - const Quantity_PlaneAngle Alpha, - const Quantity_PlaneAngle Beta) - - :Graphic2d_VectorialMarker (aGraphicObject, aXPosition, aYPosition), - myX (Standard_ShortReal (X)), - myY (Standard_ShortReal (Y)), - myRadius (Standard_ShortReal (Radius)), - myFirstAngle (Standard_ShortReal (Alpha)), - mySecondAngle (Standard_ShortReal (Beta)) { - - if (myRadius <= RealEpsilon ()) - Graphic2d_CircleDefinitionError::Raise ("The radius = 0."); - -#ifdef IMPLEMENTED - myMinX = myX + Standard_ShortReal (aXPosition) - myRadius; - myMinY = myY + Standard_ShortReal (aYPosition) - myRadius; - myMaxX = myX + Standard_ShortReal (aXPosition) + myRadius; - myMaxY = myY + Standard_ShortReal (aYPosition) + myRadius; -#else - myMinX = myX; - myMinY = myY; - myMaxX = myX; - myMaxY = myY; -#endif /* NOT IMPLEMENTED */ - myisArc = Standard_True; - myNumOfElem = MAXPOINTS + 1; - myNumOfVert = 3; -} - -void Graphic2d_CircleMarker::Draw (const Handle(Graphic2d_Drawer)& aDrawer) { - - DrawLineAttrib(aDrawer); - - Standard_ShortReal xp,yp; - aDrawer->GetMapFromTo(Standard_ShortReal (XPosition ()), - Standard_ShortReal (YPosition ()),xp,yp); - xp += myX; - yp += myY; - - if (myTypeOfPolygonFilling == Graphic2d_TOPF_EMPTY) { - aDrawer->DrawArc(xp,yp,myRadius,myFirstAngle,mySecondAngle); - } else { - aDrawer->DrawPolyArc(xp,yp,myRadius,myFirstAngle,mySecondAngle); - } - -} - -#ifdef G002 - -void Graphic2d_CircleMarker::DrawElement( const Handle(Graphic2d_Drawer)& aDrawer, - const Standard_Integer anIndex ) { - - - if ( anIndex > 0 && anIndex <= MAXPOINTS + 1 ) { - DrawLineAttrib(aDrawer); - Standard_ShortReal rd = aDrawer->ConvertMapToFrom(myRadius); - Standard_ShortReal x1 = aDrawer->ConvertMapToFrom(myX) + myXPosition; - Standard_ShortReal y1 = aDrawer->ConvertMapToFrom(myY) + myYPosition; - - Standard_ShortReal teta = Abs( mySecondAngle - myFirstAngle ) / MAXPOINTS; - Standard_ShortReal - x2 = Standard_ShortReal(x1 + rd * Cos(myFirstAngle + teta*(anIndex-1))), - y2 = Standard_ShortReal(y1 + rd * Sin(myFirstAngle + teta*(anIndex-1))); - - aDrawer->MapSegmentFromTo( x1, y1, x2, y2 ); - } - -} - -void Graphic2d_CircleMarker::DrawVertex( const Handle(Graphic2d_Drawer)& aDrawer, - const Standard_Integer anIndex) { - - if ( anIndex > 0 && anIndex < 4 ) { - DrawMarkerAttrib( aDrawer ); - Standard_ShortReal x,y; - aDrawer->GetMapFromTo(Standard_ShortReal( XPosition() ), - Standard_ShortReal( YPosition() ), x, y ); - x += myX; - y += myY; - - Standard_Real alpha = ( anIndex == 2 ) ? myFirstAngle : mySecondAngle; - x += Standard_ShortReal( myRadius * Cos( alpha ) ); - y += Standard_ShortReal( myRadius * Sin( alpha ) ); - aDrawer->DrawMarker( VERTEXMARKER, x, y, DEFAULTMARKERSIZE,DEFAULTMARKERSIZE, 0.0 ); - } -} - -#endif - -Standard_Boolean Graphic2d_CircleMarker::Pick (const Standard_ShortReal X, - const Standard_ShortReal Y, - const Standard_ShortReal aPrecision, - const Handle(Graphic2d_Drawer)& aDrawer) { - - Standard_ShortReal SRX = X, SRY = Y; - Standard_ShortReal rd = aDrawer->ConvertMapToFrom(myRadius); - Standard_ShortReal x = aDrawer->ConvertMapToFrom(myX) + myXPosition; - Standard_ShortReal y = aDrawer->ConvertMapToFrom(myY) + myYPosition; - Standard_Boolean found = Standard_False; - - if (myGOPtr->IsTransformed ()) { - gp_GTrsf2d aTrsf = (myGOPtr->Transform ()).Inverted (); - Standard_Real RX = Standard_Real (SRX), RY = Standard_Real (SRY); - aTrsf.Transforms (RX, RY); - SRX = Standard_ShortReal (RX); SRY = Standard_ShortReal (RY); - } - - #ifdef G002 - - if ( Graphic2d_Primitive::IsOn( SRX, SRY, x, y, aPrecision) ) { - SetPickedIndex(-1); - return Standard_True; - } else { - if ( myisArc ) { - Standard_ShortReal x1 = Standard_ShortReal(rd * Cos( myFirstAngle ) + x), - y1 = Standard_ShortReal(rd * Sin( myFirstAngle ) + y), - x2 = Standard_ShortReal(rd * Cos( mySecondAngle ) + x), - y2 = Standard_ShortReal(rd * Sin( mySecondAngle ) + y); - - if ( Graphic2d_Primitive::IsOn( SRX, SRY, x1, y1, aPrecision) ) { - SetPickedIndex(-2); - return Standard_True; - } else if ( Graphic2d_Primitive::IsOn( SRX, SRY, x2, y2, aPrecision) ) { - SetPickedIndex(-3); - return Standard_True; - } - } // end if is Arc - - TShort_Array1OfShortReal Xpoint( 1, MAXPOINTS + 1 ); - TShort_Array1OfShortReal Ypoint( 1, MAXPOINTS + 1 ); - - Standard_ShortReal teta = Abs( mySecondAngle - myFirstAngle ) / MAXPOINTS; - - for ( Standard_Integer i = 1; i <= MAXPOINTS + 1; i++ ) { - Xpoint(i) = Standard_ShortReal(x + rd * Cos( myFirstAngle + teta*(i-1) )); - Ypoint(i) = Standard_ShortReal(y + rd * Sin( myFirstAngle + teta*(i-1) )); - if ( Graphic2d_Primitive::IsOn( SRX, SRY, Xpoint(i), Ypoint(i), aPrecision) ) { - SetPickedIndex(i); - return Standard_True; - } - } - - if ( myTypeOfPolygonFilling != Graphic2d_TOPF_EMPTY ) - found = Abs (Sqrt ((x - SRX)*(x - SRX) + (y - SRY)*(y - SRY))) < rd; - if ( !found ) - found = Abs (Sqrt ((x - SRX)*(x - SRX) + (y - SRY)*(y - SRY)) - rd) < aPrecision; - if ( found ) { - SetPickedIndex( 0 ); - return Standard_True; - } - } - #else - - if ( myTypeOfPolygonFilling != Graphic2d_TOPF_EMPTY ) - found = Abs (Sqrt ((x - SRX)*(x - SRX) + (y - SRY)*(y - SRY))) < rd; - if ( !found ) - found = Abs (Sqrt ((x - SRX)*(x - SRX) + (y - SRY)*(y - SRY)) - rd) < aPrecision; - if ( found ) return Standard_True; - - #endif - - return Standard_False; - -} - -void Graphic2d_CircleMarker::Center( Quantity_Length& X,Quantity_Length& Y ) const { - - X = Quantity_Length( myX ); - Y = Quantity_Length( myY ); -} - -Quantity_Length Graphic2d_CircleMarker::Radius() const { - - return Quantity_Length( myRadius ); -} - -Quantity_PlaneAngle Graphic2d_CircleMarker::FirstAngle() const { - - return Quantity_PlaneAngle( myFirstAngle ); -} - -Quantity_PlaneAngle Graphic2d_CircleMarker::SecondAngle() const { - - return Quantity_PlaneAngle( mySecondAngle ); -} - -void Graphic2d_CircleMarker::Save(Aspect_FStream& aFStream) const -{ - *aFStream << "Graphic2d_CircleMarker" << endl; - *aFStream << myXPosition << ' ' << myYPosition << endl; - *aFStream << myX << ' ' << myY << endl; - *aFStream << myRadius << endl; - *aFStream << myisArc << endl; - if (myisArc) - *aFStream << myFirstAngle << ' ' << mySecondAngle << endl; - Graphic2d_Line::Save(aFStream); -} - -void Graphic2d_CircleMarker::Retrieve(Aspect_IFStream& anIFStream, - const Handle(Graphic2d_GraphicObject)& aGraphicObject) -{ - Quantity_Length XPos, YPos, X, Y, Rad; - Quantity_PlaneAngle Ang1, Ang2; - int isArc; - Handle(Graphic2d_CircleMarker) theCirM; - - *anIFStream >> XPos >> YPos; - *anIFStream >> X >> Y; - *anIFStream >> Rad; - *anIFStream >> isArc; - if (isArc) - { - *anIFStream >> Ang1 >> Ang2; - theCirM = new Graphic2d_CircleMarker(aGraphicObject, XPos, YPos, X, Y, Rad, Ang1, Ang2); - } - else - theCirM = new Graphic2d_CircleMarker(aGraphicObject, XPos, YPos, X, Y, Rad); - ((Handle (Graphic2d_Line))theCirM)->Retrieve(anIFStream); -} - diff --git a/src/Graphic2d/Graphic2d_Drawer.cdl b/src/Graphic2d/Graphic2d_Drawer.cdl deleted file mode 100755 index a6324739e0..0000000000 --- a/src/Graphic2d/Graphic2d_Drawer.cdl +++ /dev/null @@ -1,766 +0,0 @@ --- Created on: 1993-07-08 --- Created by: Jean Louis FRENKEL --- Copyright (c) 1993-1999 Matra Datavision --- Copyright (c) 1999-2012 OPEN CASCADE SAS --- --- The content of this file is subject to the Open CASCADE Technology Public --- License Version 6.5 (the "License"). You may not use the content of this file --- except in compliance with the License. Please obtain a copy of the License --- at http://www.opencascade.org and read it completely before using this file. --- --- The Initial Developer of the Original Code is Open CASCADE S.A.S., having its --- main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. --- --- The Original Code and all software distributed under the License is --- distributed on an "AS IS" basis, without warranty of any kind, and the --- Initial Developer hereby disclaims all such warranties, including without --- limitation, any warranties of merchantability, fitness for a particular --- purpose or non-infringement. Please see the License for the specific terms --- and conditions governing the rights and limitations under the License. - - ---- --- Modified : DCB 22-07-98 --- Reason : Using pointers to drivers instead of handles --- SAV 14/11/01 added MapMarkersFromTo(). operates with arrays. - -class Drawer from Graphic2d inherits Transient from Standard - - ---Version: - - ---Purpose: A Drawer groups all conversion methods. - ---Level: Internal - - ---Keywords: - ---Warning: - ---References: - -uses - ShortReal from Standard, - File from OSD, - Factor from Quantity, - Driver from Aspect, - DriverPtr from Aspect, - WindowDriver from Aspect, - WindowDriverPtr from Aspect, - PlotterDriver from PlotMgt, - PlotterDriverPtr from PlotMgt, - TypeOfDeflection from Aspect, - TypeOfText from Aspect, - Array1OfShortReal from TShort, - ExtendedString from TCollection, - HArray1OfShortReal from TShort - -raises - DrawerDefinitionError from Graphic2d - -is - ------------------------- - -- Category: Constructors - ------------------------- - - Create - returns mutable Drawer from Graphic2d; - ---Level: Internal - ---Purpose: A drawer is : - -- - a driver - -- - a "map from" and a "map to" - -- - attributes - ---Category: Constructors - - ----------------------------------------- - -- Category: Methods to modify the driver - ----------------------------------------- - - SetDriver (me: mutable; aDriver: Driver from Aspect) - is static; - ---Level: Internal - ---Purpose: Associates the driver to the drawer . - ---Category: Methods to modify the driver - - Driver (me) - returns Driver from Aspect - ---Level: Internal - ---Purpose: Returns the associated driver. - -- Warning: Raises DrawerDefinitionError if the - -- associated driver is not defined. - raises DrawerDefinitionError from Graphic2d is static; - - IsWindowDriver (me) - returns Boolean from Standard; - ---Level: Internal - ---Purpose: Returns TRUE if the driver is a window driver. - ---Category: Inquiry method. - - WindowDriver (me) - returns WindowDriver from Aspect - ---Level: Internal - ---Purpose: Returns the associated window driver. - -- Warning: Raises DrawerDefinitionError if the - -- associated driver is not defined or is not a WindowDriver. - raises DrawerDefinitionError from Graphic2d is static; - - IsPlotterDriver (me) - returns Boolean from Standard; - ---Level: Internal - ---Purpose: Returns TRUE if the driver is a plotter driver. - ---Category: Inquiry method. - - PlotterDriver (me) - returns PlotterDriver from PlotMgt - ---Level: Internal - ---Purpose: Returns the associated plotter driver. - -- Warning: Raises DrawerDefinitionError if the - -- associated driver is not defined or is not a PlotterDriver - raises DrawerDefinitionError from Graphic2d is static; - - ---------------------------------------------------- - -- Category: Methods to modify the chordal deviation - ---------------------------------------------------- - - ---------------------------------------------------------- - -- Summary of chordal deviation -- - -- -- - -- Specify a chordal deviation that is smaller than the -- - -- workstation pixel size will not improve the display, -- - -- but will slow the drawing. -- - -- -- - ---------------------------------------------------------- - - SetDrawPrecision (me: mutable; aPrecision: Real from Standard; - aCoefficient: Real from Standard; - aType: TypeOfDeflection from Aspect) - is static; - ---Level: Internal - ---Purpose: Sets the chordal deviation. - -- is the chordal deviation when the type of - -- deflection is Aspect_TOD_ABSOLUTE. - -- is used when when the type of - -- deflection is Aspect_TOD_RELATIVE. - -- TypeOfDeflection is : - -- Aspect_TOD_RELATIVE - -- Aspect_TOD_ABSOLUTE - -- TypeOfDeflection defines if the maximal chordal deviation - -- used when drawing an object is absolute or relative to the - -- size of the object. - -- Warning: Specify a chordal deviation that is smaller than the - -- workstation pixel size will not improve the display, - -- but will slow the drawing. - - DrawPrecision (me; aPrecision: out ShortReal from Standard; - aCoefficient: out ShortReal from Standard; - aType: out TypeOfDeflection from Aspect) - is static; - ---Level: Internal - ---Purpose: Returns the chordal deviation. - - SetTextPrecision (me: mutable; aPrecision: ShortReal from Standard) - is static; - ---Level: Internal - ---Purpose: Sets the Text precision in METER - -- Any text is displayed only if his height is greater than - --the text precision or replaced by a bounding box in the other case. - - TextPrecision (me) returns ShortReal from Standard - is static; - ---Level: Internal - ---Purpose: Returns the Text precision in METER. - - --------------------------------------------- - -- Category: Methods to modify the 2D viewing - --------------------------------------------- - - SetValues (me: mutable; XF, YF, SF, XT, YT, ST, ZF: Real from Standard) - is static; - ---Level: Internal - ---Purpose: Defines the "map from" and the "map to" of the drawer. - -- The "map from" is defined by the viewmapping. - -- The "map to" is defined by the device. - -- example : the X window for a X driver. - - Values (me; XF, YF, SF, XT, YT, ST, ZF: out ShortReal from Standard) - is static; - ---Level: Internal - ---Purpose: Returns the "map from" and the "map to". - - -------------------------------------------- - -- Category: Methods to manage the highlight - -------------------------------------------- - - SetOverride (me: mutable; aValue: Boolean from Standard) - is static; - ---Level: Internal - ---Purpose: Manages the highlight, if the highlight color index - -- is defined (No default value) - ---Category: Methods to manage the highlight - - SetOverrideColor (me: mutable; anIndex: Integer from Standard) - is static; - ---Level: Internal - ---Purpose: Sets the highlight color index. - -- Warning: No default value. - ---Category: Methods to manage the highlight - - SetOffSet (me: mutable; - anOffSet: Integer from Standard) - is static; - ---Level: Internal - ---Purpose: Specifies an offset applied to the original color - -- index when drawing a primitives, those already created - -- and the future one. - -- Warning: To reset the real color of the primitives when drawing - -- then this method is called with = 0. - - --------------------------------------------- - -- Category: Methods to manage the attributes - --------------------------------------------- - - SetLineAttrib (me: mutable; - ColorIndex: Integer from Standard; - TypeIndex: Integer from Standard; - WidthIndex: Integer from Standard) - ---Level: Internal - ---Purpose: Methods to define the Current Line Attributes - -- Warning: Raises DrawerDefinitionError if the - -- associated driver is not defined. - raises DrawerDefinitionError from Graphic2d is virtual; - - SetMarkerAttrib (me: mutable; - ColorIndex: Integer from Standard; - WidthIndex: Integer from Standard; - FillMarker: Boolean from Standard) - ---Level: Internal - ---Purpose: Methods to define the Current Marker Attributes - -- Warning: Raises DrawerDefinitionError if the - -- associated driver is not defined. - raises DrawerDefinitionError from Graphic2d is static; - - SetPolyAttrib (me: mutable; - ColorIndex: Integer from Standard; - TileIndex: Integer from Standard; - DrawEdge: Boolean from Standard) - ---Level: Internal - ---Purpose: Methods to define the Current polygon Attributes - -- Warning: Raises DrawerDefinitionError if the - -- associated driver is not defined. - raises DrawerDefinitionError from Graphic2d is static; - - SetHidingPolyAttrib (me: mutable; - HidingColorIndex: Integer from Standard; - FrameColorIndex: Integer from Standard; - FrameTypeIndex: Integer from Standard; - FrameWidthIndex: Integer from Standard) - ---Level: Internal - ---Purpose: Methods to define the Current hiding polygon Attributes - -- Warning: Raises DrawerDefinitionError if the - -- associated driver is not defined. - raises DrawerDefinitionError from Graphic2d is static; - - SetTextAttrib (me: mutable; - ColorIndex: Integer from Standard; - FontIndex: Integer from Standard; - aSlant: ShortReal from Standard; - aHScale,aWScale: ShortReal from Standard; - isUnderlined: Boolean from Standard) - ---Level: Internal - ---Purpose: Methods to define the Current Text Attributes - -- Warning: Raises DrawerDefinitionError if the - -- associated driver is not defined. - raises DrawerDefinitionError from Graphic2d is static; - - SetHidingTextAttrib (me: mutable; - ColorIndex: Integer from Standard; - HidingColorIndex: Integer from Standard; - FrameColorIndex: Integer from Standard; - FrameWidthIndex: Integer from Standard; - FontIndex: Integer from Standard; - aSlant: ShortReal from Standard; - aHScale,aWScale: ShortReal from Standard; - isUnderlined: Boolean from Standard) - ---Level: Internal - ---Purpose: Methods to define the Current Hiding Text Attributes - -- Warning: Raises DrawerDefinitionError if the - -- associated driver is not defined. - raises DrawerDefinitionError from Graphic2d is static; - - SetFramedTextAttrib (me: mutable; - ColorIndex: Integer from Standard; - FrameColorIndex: Integer from Standard; - FrameWidthIndex: Integer from Standard; - FontIndex: Integer from Standard; - aSlant: ShortReal from Standard; - aHScale,aWScale: ShortReal from Standard; - isUnderlined: Boolean from Standard) - ---Level: Internal - ---Purpose: Methods to define the Current Framed Text Attributes - -- Category: Methods to manage the attributes - -- Warning: Raises DrawerDefinitionError if the - -- associated driver is not defined. - raises DrawerDefinitionError from Graphic2d is static; - - ----------------------------------------- - -- Category: Methods to manage the images - ----------------------------------------- - - IsKnownImage (me: mutable; anImageId: Transient from Standard) - returns Boolean from Standard - ---Level: Internal - ---Purpose: Returns Standard_True if the associated driver - -- have stored the image and Standard_False if not. - -- For example, returns Standard_True if the associated - -- driver is a X Driver. - -- Category: Methods to manage the images - -- Warning: Raises DrawerDefinitionError if the - -- associated driver is not defined. - raises DrawerDefinitionError from Graphic2d is static; - - ClearImage (me: mutable; anImageId: Transient from Standard) - ---Level: Internal - ---Purpose: Clears the image in the associated driver. - -- Category: Methods to manage the images - -- Warning: Raises DrawerDefinitionError if the - -- associated driver is not defined. - raises DrawerDefinitionError from Graphic2d is static; - - DrawImage (me: mutable; anImageId: Transient from Standard; - aX, aY: ShortReal from Standard) - ---Level: Internal - ---Purpose: Draws the image in the associated driver. - -- , is the center of the image. - -- Category: Methods to manage the images - -- Warning: Raises DrawerDefinitionError if the - -- associated driver is not defined. - raises DrawerDefinitionError from Graphic2d is static; - - ClearImageFile (me: mutable; aName: CString from Standard) - ---Level: Internal - ---Purpose: Clears the image file in the associated driver. - -- Category: Methods to manage the images - -- Warning: Raises DrawerDefinitionError if the - -- associated driver is not defined. - raises DrawerDefinitionError from Graphic2d is static; - - DrawImageFile (me: mutable; aName: CString from Standard; - aX, aY: ShortReal from Standard; - aScale: Factor from Quantity) - ---Level: Internal - ---Purpose: Draws the image in the associated driver. - -- , is the center of the image. - -- = (if the image is zoomable) - -- initial scale factor of the image * - -- scale factor of the view. - -- = (if the image is not zoomable) - -- initial scale factor of the image - -- Category: Methods to manage the images - -- Warning: Raises DrawerDefinitionError if the - -- associated driver is not defined. - raises DrawerDefinitionError from Graphic2d is static; - - FillAndDrawImage (me: mutable; anImageId: Transient from Standard; - aX, aY: ShortReal from Standard; - aWidth, aHeight: Integer from Standard; - anArrayOfPixels: Address from Standard) - ---Level: Internal - ---Purpose: Stores a complete image and draws it in the associated - -- driver. - -- , is ???? - -- Category: Methods to manage the images - -- Warning: Raises DrawerDefinitionError if the - -- associated driver is not defined. - raises DrawerDefinitionError from Graphic2d is static; - - FillAndDrawImage (me: mutable; anImageId: Transient from Standard; - aX, aY: ShortReal from Standard; - anIndexOfLine, aWidth, aHeight: Integer from Standard; - anArrayOfPixels: Address from Standard) - ---Level: Internal - ---Purpose: Stores a line of an image and draws it in the associated - -- driver. - -- , is ???? - -- Category: Methods to manage the images - -- Warning: Raises DrawerDefinitionError if the - -- associated driver is not defined. - raises DrawerDefinitionError from Graphic2d is static; - - ---------------------------- - -- Category: Convert methods - ---------------------------- - - GetMapFrom (me; x1, y1: ShortReal from Standard; - x2, y2: out ShortReal from Standard) - is static; - ---Level: Internal - ---Purpose: - -- Category: Convert methods - - GetMapFromTo (me; x1, y1: ShortReal from Standard; - x2, y2: out ShortReal from Standard) - is static; - ---Level: Internal - ---Purpose: - ---Category: Convert methods - - GetTextSize (me; aText: ExtendedString from TCollection; - aWidth,aHeight: out ShortReal from Standard) - returns Boolean from Standard is virtual; - ---Level: Internal - ---Purpose: Get text size in world space with the current text - -- attributes and returns TRUE if the driver is enabled - -- to get the right size (WindowDriver ONLY!). - -- Category: Convert methods - - GetTextSize (me; aText: ExtendedString from TCollection; - aWidth,aHeight,anXoffset,anYoffset: out ShortReal from Standard) - returns Boolean from Standard is static; - ---Level: Internal - ---Purpose: Get text size and offsets - -- in world space with the current text - -- attributes and returns TRUE if the driver is enabled - -- to get the right size (WindowDriver ONLY!). - -- NOTE that the text offsets defines the relative position of the - -- of the text string origin from the lower left corner of the text - -- boundary limits. - -- Warning : SetTextAttrib(...) must be call before. - -- Category: Convert methods - - GetFontSize (me; aHeight,aBheight,aSlant: out ShortReal from Standard) - returns Boolean from Standard is static; - ---Level: Internal - ---Purpose: Get font height,baseline height and slant - -- in world space with the current text - -- attributes and returns TRUE if the driver is enabled - -- to get the right size (WindowDriver ONLY!). - -- Warning : SetTextAttrib(...) must be call before. - -- Category: Convert methods - - GetImageSize (me; aFileName: CString from Standard; - aWidth,aHeight: out ShortReal from Standard) - returns Boolean from Standard is static; - ---Level: Internal - ---Purpose: Get image size in world space - -- and returns TRUE if the driver is enabled - -- to get the right size (WindowDriver ONLY!). - ---Category: Convert methods - - GetImageSize (me; aFileName: CString from Standard; - aWidth,aHeight: out Integer from Standard) - returns Boolean from Standard is static; - ---Level: Internal - ---Purpose: Get image size in pixel space - -- and returns TRUE if the driver is enabled - -- to get the right size (WindowDriver ONLY!). - ---Category: Convert methods - - UnMapFromTo (me; - x1, y1: ShortReal from Standard; - x2, y2: out ShortReal from Standard) - is static; - ---Level: Internal - ---Purpose: - ---Category: Convert methods - - Convert (me; aValue: ShortReal from Standard) - returns ShortReal from Standard - is static; - ---Level: Internal - ---Purpose: - ---Category: Convert methods - - Convert (me; aValue: Integer from Standard) - returns ShortReal from Standard - is static; - ---Level: Internal - ---Purpose: - ---Category: Convert methods - - ConvertMapToFrom (me; x: ShortReal from Standard) - returns ShortReal from Standard - is static; - ---Level: Internal - ---Purpose: - ---Category: Convert methods - - Scale (me) - returns ShortReal from Standard - is static; - ---Level: Internal - ---Purpose: - ---Category: Convert methods - - ------------------------- - -- Category: Draw methods - ------------------------- - - DrawSegment (me : mutable; - x1, y1, x2, y2: ShortReal from Standard) - ---Purpose: Raises DrawerDefinitionError if the - -- associated driver is not defined. - raises DrawerDefinitionError from Graphic2d is static; - ---Level: Internal - ---Category: Draw methods - - DrawPolyline (me : mutable; - aDeltaX, aDeltaY: Real from Standard; - aListX, aListY: Array1OfShortReal from TShort) - ---Purpose: Raises DrawerDefinitionError if the - -- associated driver is not defined. - raises DrawerDefinitionError from Graphic2d is static; - ---Level: Internal - ---Category: Draw methods - - DrawPolygon (me : mutable; - aDeltaX, aDeltaY: Real from Standard; - aListX, aListY: Array1OfShortReal from TShort) - ---Purpose: Raises DrawerDefinitionError if the - -- associated driver is not defined. - raises DrawerDefinitionError from Graphic2d is static; - ---Level: Internal - ---Category: Draw methods - - DrawArc (me : mutable; - aDeltaX, aDeltaY: Real from Standard; - aRadius, angle1, angle2: ShortReal from Standard) - ---Purpose: Raises DrawerDefinitionError if the - -- associated driver is not defined. - raises DrawerDefinitionError from Graphic2d is static; - ---Level: Internal - ---Category: Draw methods - - DrawPolyArc (me : mutable; - aDeltaX, aDeltaY: Real from Standard; - aRadius, angle1, angle2: ShortReal from Standard) - ---Purpose: Raises DrawerDefinitionError if the - -- associated driver is not defined. - raises DrawerDefinitionError from Graphic2d is static; - ---Level: Internal - ---Category: Draw methods - - DrawInfiniteLine (me : mutable; - x, y, dx, dy: ShortReal from Standard) - ---Purpose: Raises DrawerDefinitionError if the - -- associated driver is not defined. - raises DrawerDefinitionError from Graphic2d is static; - ---Level: Internal - ---Category: Draw methods - - DrawMarker (me : mutable; - anindex: Integer from Standard; - x, y, awidth, anheight, angle: ShortReal from Standard) - ---Purpose: Raises DrawerDefinitionError if the - -- associated driver is not defined. - raises DrawerDefinitionError from Graphic2d is static; - ---Level: Internal - ---Category: Draw methods - - DrawText (me : mutable; - aText: ExtendedString from TCollection; - x, y, angle : ShortReal from Standard; - aType: TypeOfText from Aspect) - ---Purpose: Raises DrawerDefinitionError if the - -- associated driver is not defined. - raises DrawerDefinitionError from Graphic2d is static; - ---Level: Internal - ---Category: Draw methods - - DrawPolyText (me : mutable; - aText: ExtendedString from TCollection; - x, y, angle, margin : ShortReal from Standard; - aType: TypeOfText from Aspect) - ---Purpose: Raises DrawerDefinitionError if the - -- associated driver is not defined. - raises DrawerDefinitionError from Graphic2d is static; - ---Level: Internal - ---Category: Draw methods - - DrawFramedText (me : mutable; - aText: ExtendedString from TCollection; - x, y, angle, margin : ShortReal from Standard; - aType: TypeOfText from Aspect) - ---Purpose: Raises DrawerDefinitionError if the - -- associated driver is not defined. - raises DrawerDefinitionError from Graphic2d is static; - ---Level: Internal - ---Category: Draw methods - - ------------------------------------------- - -- Category: Convert methods for primitives - ------------------------------------------- - - MapInfiniteLineFromTo (me : mutable; - x, y, dx, dy: ShortReal from Standard) - ---Purpose: Raises DrawerDefinitionError if the - -- associated driver is not defined. - raises DrawerDefinitionError from Graphic2d is static; - ---Level: Internal - ---Category: Convert methods for primitives - - MapSegmentFromTo (me : mutable; - x1, y1, x2, y2: ShortReal from Standard; - aMode: Integer from Standard = 0) - ---Level: Internal - ---Purpose: RRaises DrawerDefinitionError if the - -- associated driver is not defined. - raises DrawerDefinitionError from Graphic2d is virtual; - ---Category: Convert methods for primitives - - MapMarkerFromTo (me : mutable; - anindex: Integer from Standard; - x, y, awidth, anheight, angle: ShortReal from Standard; - aMode: Integer from Standard = 0) - ---Purpose: Raises DrawerDefinitionError if the - -- associated driver is not defined. - raises DrawerDefinitionError from Graphic2d is static; - ---Level: Internal - ---Category: Convert methods for primitives - - MapMarkersFromTo (me : mutable; - index: Integer from Standard; - x, y : HArray1OfShortReal from TShort; - awidth, anheight, angle: ShortReal from Standard; - aMode: Integer from Standard = 0) - ---Purpose: Raises DrawerDefinitionError if the - -- associated driver is not defined. - raises DrawerDefinitionError from Graphic2d is static; - ---Level: Internal - ---Category: Convert methods for primitives - - - MapPolylineFromTo (me : mutable; - aListX, aListY: Array1OfShortReal from TShort; - aNumber: Integer from Standard = 0) - ---Purpose: Raises DrawerDefinitionError if the - -- associated driver is not defined. - raises DrawerDefinitionError from Graphic2d is static; - ---Level: Internal - ---Category: Convert methods for primitives - - MapPolylineFromTo (me : mutable; - x, y: ShortReal from Standard; - aMode: Integer from Standard = 0) - ---Level: Internal - ---Purpose: Raises DrawerDefinitionError if the - -- associated driver is not defined. - raises DrawerDefinitionError from Graphic2d is static; - ---Category: Convert methods for primitives - - MapPolygonFromTo (me : mutable; - aListX, aListY: Array1OfShortReal from TShort; - aNumber: Integer from Standard = 0) - ---Purpose: Raises DrawerDefinitionError if the - -- associated driver is not defined. - raises DrawerDefinitionError from Graphic2d is static; - ---Level: Internal - ---Category: Convert methods for primitives - - MapPolygonFromTo (me : mutable; - x, y: ShortReal from Standard; - aMode: Integer from Standard = 0) - ---Level: Internal - ---Purpose: Raises DrawerDefinitionError if the - -- associated driver is not defined. - raises DrawerDefinitionError from Graphic2d is static; - ---Category: Convert methods for primitives - - MapTextFromTo (me : mutable; - aText: ExtendedString from TCollection; - x, y, angle, aDeltax, aDeltay: ShortReal from Standard; - aType: TypeOfText from Aspect) - ---Purpose: Raises DrawerDefinitionError if the - -- associated driver is not defined. - raises DrawerDefinitionError from Graphic2d is virtual; - ---Level: Internal - ---Category: Convert methods for primitives - - MapPolyTextFromTo (me : mutable; - aText: ExtendedString from TCollection; - x, y, angle, margin, aDeltax, aDeltay: ShortReal from Standard; - aType: TypeOfText from Aspect) - ---Purpose: Raises DrawerDefinitionError if the - -- associated driver is not defined. - raises DrawerDefinitionError from Graphic2d is static; - ---Level: Internal - ---Category: Convert methods for primitives - - MapFramedTextFromTo (me : mutable; - aText: ExtendedString from TCollection; - x, y, angle, margin, aDeltax, aDeltay: ShortReal from Standard; - aType: TypeOfText from Aspect) - ---Purpose: Raises DrawerDefinitionError if the - -- associated driver is not defined. - raises DrawerDefinitionError from Graphic2d is static; - ---Level: Internal - ---Category: Convert methods for primitives - - MapArcFromTo (me : mutable; - x, y, aRadius, angle1, angle2: ShortReal from Standard; - aMode: Integer from Standard = 0) - ---Purpose: Raises DrawerDefinitionError if the - -- associated driver is not defined. - raises DrawerDefinitionError from Graphic2d is virtual; - ---Level: Internal - ---Category: Convert methods for primitives - - MapPolyArcFromTo (me : mutable; - x, y, aRadius, angle1, angle2: ShortReal from Standard; - aMode: Integer from Standard = 0) - ---Purpose: Raises DrawerDefinitionError if the - -- associated driver is not defined. - raises DrawerDefinitionError from Graphic2d is static; - ---Level: Internal - ---Category: Convert methods for primitives - - ----------------------------- - -- Category: Rejection method - ----------------------------- - - SetRejection (me : mutable; aClipFlag: Boolean from Standard) is static; - ---Level: Internal - ---Purpose: Sets the clipping flag with value. - - IsIn (me; aMinX, aMaxX, aMinY, aMaxY: ShortReal from Standard) - returns Boolean from Standard - is static; - ---Level: Internal - ---Purpose: Returns Standard_True if the given min max intersects - -- with the drawer space. - -- Called by the method Draw of a primitive. - -- IsIn permits the rejection of the primitive only - -- if the Clipping flag is TRUE. - -- When the Clipping flag is FALSE,this method returns - -- always TRUE. - ---Category: Rejection method - -fields - myXF: ShortReal from Standard; - myYF: ShortReal from Standard; - mySF: ShortReal from Standard; - - myXT: ShortReal from Standard; - myYT: ShortReal from Standard; - myST: ShortReal from Standard; - myZF: ShortReal from Standard; - - myDrawPrecision: ShortReal from Standard is protected; - myDeflectionCoefficient: Real from Standard is protected; - myTypeOfDeflection: TypeOfDeflection from Aspect is protected; - myTextPrecision: ShortReal from Standard; - - myOverrideColor: Integer from Standard; - myOverride: Boolean from Standard; - - myOffSet: Integer from Standard; - - -- Space of the drawing area; - mySpaceWidth: ShortReal from Standard is protected; - mySpaceHeight: ShortReal from Standard is protected; - - myDriver: DriverPtr from Aspect is protected; - myDriverIsDefined: Boolean from Standard is protected; - myWDriver: WindowDriverPtr from Aspect is protected; - myPDriver: PlotterDriverPtr from PlotMgt is protected; - myMinMaxIsActivated: Boolean from Standard is protected; - myMinX,myMinY,myMaxX,myMaxY : ShortReal from Standard is protected; - myClippingIsActivated: Boolean from Standard is protected; - -end Drawer from Graphic2d; - diff --git a/src/Graphic2d/Graphic2d_Drawer.cxx b/src/Graphic2d/Graphic2d_Drawer.cxx deleted file mode 100755 index 10a514673e..0000000000 --- a/src/Graphic2d/Graphic2d_Drawer.cxx +++ /dev/null @@ -1,1570 +0,0 @@ -// Created on: 1993-11-22 -// Created by: Stephane CALLEGARI -// Copyright (c) 1993-1999 Matra Datavision -// Copyright (c) 1999-2012 OPEN CASCADE SAS -// -// The content of this file is subject to the Open CASCADE Technology Public -// License Version 6.5 (the "License"). You may not use the content of this file -// except in compliance with the License. Please obtain a copy of the License -// at http://www.opencascade.org and read it completely before using this file. -// -// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its -// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. -// -// The Original Code and all software distributed under the License is -// distributed on an "AS IS" basis, without warranty of any kind, and the -// Initial Developer hereby disclaims all such warranties, including without -// limitation, any warranties of merchantability, fitness for a particular -// purpose or non-infringement. Please see the License for the specific terms -// and conditions governing the rights and limitations under the License. - -#define xTRACE - -// Modified 23/02/98 : FMN ; Remplacement PI par Standard_PI -// Modified 16/03/98 GG -// OPTIMISATION -// Add fields myWDriver and myPDriver initializing correctly -// when the driver is "WindowDriver" or "plotterdriver". -// Avoid call of empty contructors. - -#define CTS17857//GG_200897 -// Allow suppressing clipping on primitives. - -#define CSR_PRO12324 //SYL_030798 -// the Plot of an objet should be a normal - -#define DCB_220798 // DCB -// Using pointers to drivers instead of handles -// Reason : to avoid undesirable incrementation -// of handle's links. - -// Modified 17/12/1998 SYL pour S3604 -// Aspect_PlotterDriver devient PlotMgt_PlotterDriver - -#define BUC60650 //GG 010300 Add protection on scale parameters -// in SetxxxxTextAttrib() methods - -#define OCC402 //SAV added method to map merkers operating with arrays - -#include -#include -#include -#include -#include - -#define MAXPOINTS 1023 - -#ifdef WNT -# include -#endif // WNT - -Graphic2d_Drawer::Graphic2d_Drawer () { - - myOverride = Standard_False; -#ifdef DCB_220798 - myDriver = NULL; - myWDriver = NULL; - myPDriver = NULL; -#else // DCB_220798 - myDriver.Nullify(); - myWDriver.Nullify(); - myPDriver.Nullify(); -#endif // DCB_220798 - myDriverIsDefined = Standard_False; - myMinMaxIsActivated = Standard_False; - myClippingIsActivated = Standard_True; - myMinX = myMinY = ShortRealLast(); - myMaxX = myMaxY = ShortRealFirst(); - - myDrawPrecision = 0.; - myDeflectionCoefficient = 0.; - myTypeOfDeflection = Aspect_TOD_RELATIVE; - myTextPrecision = 0.; - - myOverrideColor = 0; - - myOffSet = 0; - - mySpaceWidth = 1. METER; - mySpaceHeight = 1. METER; - - SetValues (0., 0., 1. METER, 0., 0., 1., 1.); - -} - -void Graphic2d_Drawer::SetDrawPrecision(const Standard_Real aPrecision, - const Standard_Real aCoefficient, - const Aspect_TypeOfDeflection aType) { - - myDrawPrecision = Standard_ShortReal(aPrecision); - myDeflectionCoefficient = aCoefficient; - myTypeOfDeflection = aType; - -} - -void Graphic2d_Drawer::DrawPrecision(Standard_ShortReal& aPrecision, - Standard_ShortReal& aCoefficient, - Aspect_TypeOfDeflection& aType) const { - - aPrecision = myDrawPrecision; - aCoefficient = Standard_ShortReal(myDeflectionCoefficient); - aType = myTypeOfDeflection; - -} - -void Graphic2d_Drawer::SetTextPrecision(const Standard_ShortReal aPrecision) { - - myTextPrecision = aPrecision; - -} - -Standard_ShortReal Graphic2d_Drawer::TextPrecision() const { - - return myTextPrecision; - -} - -void Graphic2d_Drawer::SetDriver(const Handle(Aspect_Driver)& aDriver) { - -Standard_Real w,h; - -#ifdef DCB_220798 - myDriver = aDriver.operator->(); - if( aDriver->IsKind(STANDARD_TYPE(Aspect_WindowDriver)) ) { - myWDriver = (Handle(Aspect_WindowDriver)::DownCast(aDriver)).operator->(); - myPDriver = NULL; - } else { - myWDriver = NULL; - myPDriver = (Handle(PlotMgt_PlotterDriver)::DownCast(aDriver)).operator->(); - } -#else // DCB_220798 - myDriver = aDriver; - myWDriver = Handle(Aspect_WindowDriver)::DownCast(aDriver); - myPDriver = Handle(PlotMgt_PlotterDriver)::DownCast(aDriver); -#endif // DCB_220798 - myDriverIsDefined = Standard_True; - myDriver->WorkSpace(w,h); - mySpaceWidth = Standard_ShortReal(w); - mySpaceHeight = Standard_ShortReal(h); -#ifdef TRACE - cout << "Graphic2d_Drawer::SetDriver() -> IsWindowDriver ? " - << (myWDriver ? "TRUE " : "FALSE ") << flush; - cout << "Graphic2d_Drawer::SetDriver() -> myDriverIsDefined: " - << (myDriverIsDefined ? "TRUE " : "FALSE ") - << (int)myDriverIsDefined << endl << flush; - cout << "Graphic2d_Drawer::SetDriver() -> Space: " - << mySpaceWidth << " x " << mySpaceHeight << endl << flush; -#endif - -} - -Handle(Aspect_Driver) Graphic2d_Drawer::Driver() const { - -// if (! myDriverIsDefined ) -// Graphic2d_DrawerDefinitionError::Raise ("No defined driver"); - - return myDriver; - -} - -Standard_Boolean Graphic2d_Drawer::IsWindowDriver() const { - -#ifdef DCB_220798 - return (myWDriver) ? Standard_True : Standard_False; -#else - return (myWDriver.IsNull()) ? Standard_False : Standard_True; -#endif -} - -Standard_Boolean Graphic2d_Drawer::IsPlotterDriver() const { - -#ifdef DCB_220798 - return (myPDriver) ? Standard_True : Standard_False; -#else - return (myPDriver.IsNull()) ? Standard_False : Standard_True; -#endif -} - -Handle(Aspect_WindowDriver) Graphic2d_Drawer::WindowDriver() const { - - return myWDriver; -} - -Handle(PlotMgt_PlotterDriver) Graphic2d_Drawer::PlotterDriver() const { - - return myPDriver; -} - -void Graphic2d_Drawer::SetValues (const Standard_Real XF, - const Standard_Real YF, - const Standard_Real SF, - const Standard_Real XT, - const Standard_Real YT, - const Standard_Real ST, - const Standard_Real ZF){ - - myXF = Standard_ShortReal(XF); - myYF = Standard_ShortReal(YF); - mySF = Standard_ShortReal(SF>Precision::Confusion()?SF:Precision::Confusion()); - myXT = Standard_ShortReal(XT); - myYT = Standard_ShortReal(YT); - myST = Standard_ShortReal(ST>Precision::Confusion()?ST:Precision::Confusion()); - myZF = Standard_ShortReal(ZF); - -} - -void Graphic2d_Drawer::Values(Standard_ShortReal& XF, - Standard_ShortReal& YF, - Standard_ShortReal& SF, - Standard_ShortReal& XT, - Standard_ShortReal& YT, - Standard_ShortReal& ST, - Standard_ShortReal& ZF) const { - - XF = myXF; - YF = myYF; - SF = mySF; - XT = myXT; - YT = myYT; - ST = myST; - ZF = myZF; - -} - -void Graphic2d_Drawer::SetOverride(const Standard_Boolean aValue) { - - myOverride = aValue; - -} - -void Graphic2d_Drawer::SetOverrideColor(const Standard_Integer anIndex) { - - myOverrideColor = anIndex; - -} - -void Graphic2d_Drawer::SetOffSet(const Standard_Integer anOffSet) { - - myOffSet = anOffSet; - -} - -void Graphic2d_Drawer::GetMapFrom(const Standard_ShortReal x1, - const Standard_ShortReal y1, - Standard_ShortReal& x2, - Standard_ShortReal& y2) const { - - x2 = (x1-myXF)/mySF; - y2 = (y1-myYF)/mySF; - -} - -void Graphic2d_Drawer::GetMapFromTo(const Standard_ShortReal x1, - const Standard_ShortReal y1, - Standard_ShortReal& x2, - Standard_ShortReal& y2) const { - - x2 = myXT + ((x1-myXF)/mySF) *myST; - y2 = myYT + ((y1-myYF)/mySF) *myST; - -} - -Standard_Boolean Graphic2d_Drawer::GetTextSize( - const TCollection_ExtendedString &aText, - Standard_ShortReal &aWidth, - Standard_ShortReal &aHeight) const { - - if( IsWindowDriver() ) { - myWDriver->TextSize(aText,aWidth,aHeight); - aWidth /= Scale(); - aHeight /= Scale(); - return Standard_True; -#ifdef WNT - } else - if ( myDriver -> IsKind ( STANDARD_TYPE( WNT_DDriver ) ) ) { - - Handle( WNT_DDriver ) :: DownCast ( myDriver ) -> TextSize ( aText, aWidth, aHeight ); - aWidth /= Scale (); - aHeight /= Scale (); - return Standard_True; -#endif // WNT - } else { - aWidth = aHeight = 0.; - return Standard_False; - } // end else -} - -Standard_Boolean Graphic2d_Drawer::GetTextSize( - const TCollection_ExtendedString &aText, - Standard_ShortReal &aWidth, - Standard_ShortReal &aHeight, - Standard_ShortReal &anXoffset, - Standard_ShortReal &anYoffset) const { - - if( IsWindowDriver() ) { - myWDriver->TextSize(aText,aWidth,aHeight,anXoffset,anYoffset); - aWidth /= Scale(); - aHeight /= Scale(); - anXoffset /= Scale(); - anYoffset /= Scale(); - return Standard_True; -#ifdef WNT - } else - if ( myDriver -> IsKind ( STANDARD_TYPE( WNT_DDriver ) ) ) { - - Handle( WNT_DDriver ) :: DownCast ( myDriver ) -> TextSize ( aText, aWidth, aHeight ); - aWidth /= Scale (); - aHeight /= Scale (); - return Standard_True; -#endif // WNT - } else { - aWidth = aHeight = anXoffset = anYoffset = 0.; - return Standard_False; - } // end else -} - -Standard_Boolean Graphic2d_Drawer::GetFontSize( - Standard_ShortReal &aHeight, - Standard_ShortReal &aBheight, - Standard_ShortReal &aSlant) const { - - if( IsWindowDriver() ) { - Quantity_PlaneAngle slant; - myWDriver->FontSize(slant,aHeight,aBheight); - aHeight /= Scale(); - aBheight /= Scale(); - aSlant = Standard_ShortReal(slant); - return Standard_True; - } else { - aHeight = aBheight = aSlant = 0.; - return Standard_False; - } -} - -Standard_Boolean Graphic2d_Drawer::GetImageSize( - const Standard_CString aFileName, - Standard_ShortReal &aWidth, - Standard_ShortReal &aHeight) const { - - Standard_Boolean theStatus = Standard_False; - Standard_Integer width,height; - - if( myDriverIsDefined ) { - if(( theStatus = myDriver->SizeOfImageFile(aFileName,width,height))){ - aWidth = Standard_ShortReal(myDriver->Convert(width)/Scale()); - aHeight = Standard_ShortReal(myDriver->Convert(height)/Scale()); - } - } - - if( !theStatus ) { - aWidth = aHeight = 0.; - } - return theStatus; -} - -Standard_Boolean Graphic2d_Drawer::GetImageSize( - const Standard_CString aFileName, - Standard_Integer &aWidth, - Standard_Integer &aHeight) const { -Standard_Boolean theStatus = Standard_False; - - if( myDriverIsDefined ) { - theStatus = myDriver->SizeOfImageFile(aFileName,aWidth,aHeight); - } - - if( !theStatus ) { - aWidth = aHeight = 0; - } - return theStatus; -} - -void Graphic2d_Drawer::MapSegmentFromTo ( - const Standard_ShortReal x1, - const Standard_ShortReal y1, - const Standard_ShortReal x2, - const Standard_ShortReal y2, - const Standard_Integer aMode) { - - if (! myDriverIsDefined) - Graphic2d_DrawerDefinitionError::Raise ("No defined driver"); - - Standard_ShortReal mx1,my1,mx2,my2; - mx1 = myXT + ((x1-myXF)/mySF) *myST; - my1 = myYT + ((y1-myYF)/mySF) *myST; - mx2 = myXT + ((x2-myXF)/mySF) *myST; - my2 = myYT + ((y2-myYF)/mySF) *myST; - - if( aMode > 0 ) myDriver->BeginSegments(); - myDriver->DrawSegment(mx1,my1,mx2,my2); - if( aMode < 0 ) myDriver->ClosePrimitive(); - if( myMinMaxIsActivated ) { - myMinX = Min(mx1,myMinX); myMinX = Min(mx2,myMinX); - myMinY = Min(my1,myMinY); myMinY = Min(my2,myMinY); - myMaxX = Max(mx1,myMaxX); myMaxX = Max(mx2,myMaxX); - myMaxY = Max(my1,myMaxY); myMaxY = Max(my2,myMaxY); - } - -} - -void Graphic2d_Drawer::DrawSegment ( - const Standard_ShortReal x1, - const Standard_ShortReal y1, - const Standard_ShortReal x2, - const Standard_ShortReal y2) { - - if (! myDriverIsDefined) - Graphic2d_DrawerDefinitionError::Raise ("No defined driver"); - - myDriver->DrawSegment(x1,y1,x2,y2); - if( myMinMaxIsActivated ) { - myMinX = Min(x1,myMinX); myMinX = Min(x2,myMinX); - myMinY = Min(y1,myMinY); myMinY = Min(y2,myMinY); - myMaxX = Max(x1,myMaxX); myMaxX = Max(x2,myMaxX); - myMaxY = Max(y1,myMaxY); myMaxY = Max(y2,myMaxY); - } -} - -void Graphic2d_Drawer::DrawText( - const TCollection_ExtendedString& aText, - const Standard_ShortReal x, - const Standard_ShortReal y, - const Standard_ShortReal anAngle, - const Aspect_TypeOfText aType) { - - if (! myDriverIsDefined) - Graphic2d_DrawerDefinitionError::Raise ("No defined driver"); - - Standard_ShortReal mx = x,my = y; - - myDriver->DrawText(aText,mx,my,anAngle,aType); - - if( myMinMaxIsActivated && IsWindowDriver() ) { - Standard_ShortReal width,height,xoffset,yoffset; - myWDriver->TextSize(aText,width,height,xoffset,yoffset); - if( width > 0. && height > 0. ) { - Standard_ShortReal x1,y1,x2,y2,x3,y3,x4,y4; - - if ( !anAngle ) { - Standard_ShortReal cosa = Standard_ShortReal(Cos(anAngle)); - Standard_ShortReal sina = Standard_ShortReal(Sin(anAngle)); - - x1 = mx + XROTATE(xoffset,-yoffset) ; - y1 = my + YROTATE(xoffset,-yoffset) ; - - x2 = mx + XROTATE(xoffset,height-yoffset) ; - y2 = my + YROTATE(xoffset,height-yoffset) ; - - x3 = mx + XROTATE(width+xoffset,height-yoffset) ; - y3 = my + YROTATE(width+xoffset,height-yoffset) ; - - x4 = mx + XROTATE(width+xoffset,-yoffset) ; - y4 = my + YROTATE(width+xoffset,-yoffset) ; - - } else { - x1 = mx+xoffset; y1 = my-yoffset; - x2 = mx+xoffset; y2 = my+height-yoffset; - x3 = mx+width+xoffset; y3 = my+height-yoffset; - x4 = mx+width+xoffset; y4 = my-yoffset; - } - myMinX = Min(x1,myMinX); myMinY = Min(y1,myMinY); - myMaxX = Max(x1,myMaxX); myMaxY = Max(y1,myMaxY); - myMinX = Min(x2,myMinX); myMinY = Min(y2,myMinY); - myMaxX = Max(x2,myMaxX); myMaxY = Max(y2,myMaxY); - myMinX = Min(x3,myMinX); myMinY = Min(y3,myMinY); - myMaxX = Max(x3,myMaxX); myMaxY = Max(y3,myMaxY); - myMinX = Min(x4,myMinX); myMinY = Min(y4,myMinY); - myMaxX = Max(x4,myMaxX); myMaxY = Max(y4,myMaxY); - } - } -} - -void Graphic2d_Drawer::MapTextFromTo( - const TCollection_ExtendedString& aText, - const Standard_ShortReal x, - const Standard_ShortReal y, - const Standard_ShortReal anAngle, - const Standard_ShortReal aDeltax, - const Standard_ShortReal aDeltay, - const Aspect_TypeOfText aType) { - - if (! myDriverIsDefined) - Graphic2d_DrawerDefinitionError::Raise ("No defined driver"); - - Standard_ShortReal mx,my; - mx = myXT + aDeltax + ((x-myXF)/mySF) *myST; - my = myYT + aDeltay + ((y-myYF)/mySF) *myST; - DrawText(aText,mx,my,anAngle,aType); -} - -void Graphic2d_Drawer::DrawPolyText( - const TCollection_ExtendedString& aText, - const Standard_ShortReal x, - const Standard_ShortReal y, - const Standard_ShortReal anAngle, - const Standard_ShortReal aMargin, - const Aspect_TypeOfText aType) { - - if (! myDriverIsDefined) - Graphic2d_DrawerDefinitionError::Raise ("No defined driver"); - - Standard_ShortReal mx = x,my = y; - myDriver->DrawPolyText(aText,mx,my,aMargin,anAngle,aType); - - if( myMinMaxIsActivated && IsWindowDriver() ) { - Standard_ShortReal width,height,xoffset,yoffset; - myWDriver->TextSize(aText,width,height,xoffset,yoffset); - if( width > 0. && height > 0. ) { - Standard_ShortReal x1,y1,x2,y2,x3,y3,x4,y4,dxm,dym; - dxm = dym = height*aMargin; - - if( !anAngle ) { - Standard_ShortReal cosa = Standard_ShortReal(Cos(anAngle)); - Standard_ShortReal sina = Standard_ShortReal(Sin(anAngle)); - - x1 = mx + XROTATE(-dxm+xoffset,-dym-yoffset) ; - y1 = my + YROTATE(-dxm+xoffset,-dym-yoffset) ; - - x2 = mx + XROTATE(-dxm+xoffset,height+dym-yoffset) ; - y2 = my + YROTATE(-dxm+xoffset,height+dym-yoffset) ; - - x3 = mx + XROTATE(width+dxm+xoffset,height+dym-yoffset) ; - y3 = my + YROTATE(width+dxm+xoffset,height+dym-yoffset) ; - - x4 = mx + XROTATE(width+dxm+xoffset,-dym-yoffset) ; - y4 = my + YROTATE(width+dxm+xoffset,-dym-yoffset) ; - - } else { - x1 = mx-dxm+xoffset; y1 = my-dym-yoffset; - x2 = mx-dxm+xoffset; y2 = my+height+dym-yoffset; - x3 = mx+width+dxm+xoffset; y3 = my+height+dym-yoffset; - x4 = mx+width+dxm+xoffset; y4 = my-dym-yoffset; - } - myMinX = Min(x1,myMinX); myMinY = Min(y1,myMinY); - myMaxX = Max(x1,myMaxX); myMaxY = Max(y1,myMaxY); - myMinX = Min(x2,myMinX); myMinY = Min(y2,myMinY); - myMaxX = Max(x2,myMaxX); myMaxY = Max(y2,myMaxY); - myMinX = Min(x3,myMinX); myMinY = Min(y3,myMinY); - myMaxX = Max(x3,myMaxX); myMaxY = Max(y3,myMaxY); - myMinX = Min(x4,myMinX); myMinY = Min(y4,myMinY); - myMaxX = Max(x4,myMaxX); myMaxY = Max(y4,myMaxY); - } - } -} - -void Graphic2d_Drawer::MapPolyTextFromTo( - const TCollection_ExtendedString& aText, - const Standard_ShortReal x, - const Standard_ShortReal y, - const Standard_ShortReal anAngle, - const Standard_ShortReal aMargin, - const Standard_ShortReal aDeltax, - const Standard_ShortReal aDeltay, - const Aspect_TypeOfText aType) { - - if (! myDriverIsDefined) - Graphic2d_DrawerDefinitionError::Raise ("No defined driver"); - - Standard_ShortReal mx,my; - mx = myXT + aDeltax + ((x-myXF)/mySF) *myST; - my = myYT + aDeltay + ((y-myYF)/mySF) *myST; - DrawPolyText(aText,mx,my,anAngle,aMargin,aType); -} - -void Graphic2d_Drawer::DrawFramedText( - const TCollection_ExtendedString& aText, - const Standard_ShortReal x, - const Standard_ShortReal y, - const Standard_ShortReal anAngle, - const Standard_ShortReal aMargin, - const Aspect_TypeOfText aType) { - - DrawPolyText(aText,x,y,anAngle,aMargin,aType); -} - - -void Graphic2d_Drawer::MapFramedTextFromTo( - const TCollection_ExtendedString& aText, - const Standard_ShortReal x, - const Standard_ShortReal y, - const Standard_ShortReal anAngle, - const Standard_ShortReal aMargin, - const Standard_ShortReal aDeltax, - const Standard_ShortReal aDeltay, - const Aspect_TypeOfText aType) { - - if (! myDriverIsDefined) - Graphic2d_DrawerDefinitionError::Raise ("No defined driver"); - - Standard_ShortReal mx,my; - mx = myXT + aDeltax + ((x-myXF)/mySF) *myST; - my = myYT + aDeltay + ((y-myYF)/mySF) *myST; - DrawFramedText(aText,mx,my,anAngle,aMargin,aType); -} - -void Graphic2d_Drawer::UnMapFromTo (const Standard_ShortReal x1, - const Standard_ShortReal y1, - Standard_ShortReal& x2, - Standard_ShortReal& y2) const { - - x2 = ((x1-myXT) /myST) *mySF + myXF; - y2 = ((y1-myYT) /myST) *mySF + myYF; - -} - -void Graphic2d_Drawer::DrawPolyline ( - const Standard_Real aDeltaX, - const Standard_Real aDeltaY, - const TShort_Array1OfShortReal& aListX, - const TShort_Array1OfShortReal& aListY) { - - if (! myDriverIsDefined) - Graphic2d_DrawerDefinitionError::Raise ("No defined driver"); - - Standard_Integer n1 = aListX.Lower(); - Standard_Integer n2 = aListX.Upper(); - Standard_ShortReal X,Y; - - myDriver->BeginPolyline(n2-n1+1); - for (Standard_Integer i=n1 ; i<=n2; i++) { - X = Standard_ShortReal(aDeltaX) + Standard_ShortReal(aListX(i)); - Y = Standard_ShortReal(aDeltaY) + Standard_ShortReal(aListY(i)); - myDriver->DrawPoint(X,Y); - if( myMinMaxIsActivated ) { - myMinX = Min(X,myMinX); - myMinY = Min(Y,myMinY); - myMaxX = Max(X,myMaxX); - myMaxY = Max(Y,myMaxY); - } - } - myDriver->ClosePrimitive(); - -} - -void Graphic2d_Drawer::MapPolylineFromTo ( - const TShort_Array1OfShortReal& aListX, - const TShort_Array1OfShortReal& aListY, - const Standard_Integer Npoint) { - - if (! myDriverIsDefined) - Graphic2d_DrawerDefinitionError::Raise ("No defined driver"); - - Standard_Integer n1 = aListX.Lower(); - Standard_Integer n2 = (Npoint > 0) ? n1+Npoint-1 : aListX.Upper(); - Standard_ShortReal X,Y; - - myDriver->BeginPolyline(n2-n1+1); - for (Standard_Integer i=n1 ; i<=n2; i++) { - X = myXT + ((aListX(i)-myXF)/mySF) *myST; - Y = myYT + ((aListY(i)-myYF)/mySF) *myST; - myDriver->DrawPoint(X,Y); - if( myMinMaxIsActivated ) { - myMinX = Min(X,myMinX); - myMinY = Min(Y,myMinY); - myMaxX = Max(X,myMaxX); - myMaxY = Max(Y,myMaxY); - } - } - myDriver->ClosePrimitive(); - -} - -void Graphic2d_Drawer::MapPolylineFromTo ( - const Standard_ShortReal x, - const Standard_ShortReal y, - const Standard_Integer aMode) { - - if (! myDriverIsDefined) - Graphic2d_DrawerDefinitionError::Raise ("No defined driver"); - - Standard_ShortReal X,Y; - X = myXT + ((x-myXF)/mySF) *myST; - Y = myYT + ((y-myYF)/mySF) *myST; - - if( aMode > 0 ) myDriver->BeginPolyline(aMode); - myDriver->DrawPoint(X,Y); - if( myMinMaxIsActivated ) { - myMinX = Min(X,myMinX); - myMinY = Min(Y,myMinY); - myMaxX = Max(X,myMaxX); - myMaxY = Max(Y,myMaxY); - } - if( aMode < 0 ) myDriver->ClosePrimitive(); -} - -void Graphic2d_Drawer::DrawMarker( - const Standard_Integer anindex, - const Standard_ShortReal x, - const Standard_ShortReal y, - const Standard_ShortReal awidth, - const Standard_ShortReal anheight, - const Standard_ShortReal anAngle) { - if (! myDriverIsDefined) - Graphic2d_DrawerDefinitionError::Raise ("No defined driver"); - - Standard_ShortReal mx = x,my = y; - - if( anindex > 0 && awidth > 0. && anheight > 0. ) { - myDriver->DrawMarker(anindex,mx,my,awidth,anheight,anAngle); - if( myMinMaxIsActivated ) { - Standard_ShortReal d = Standard_ShortReal(Sqrt(awidth*awidth + anheight*anheight)); - myMinX = Min(mx-d,myMinX); - myMinY = Min(my-d,myMinY); - myMaxX = Max(mx+d,myMaxX); - myMaxY = Max(my+d,myMaxY); - } - } else { - myDriver->DrawPoint(mx,my); - if( myMinMaxIsActivated ) { - myMinX = Min(mx,myMinX); - myMinY = Min(my,myMinY); - myMaxX = Max(mx,myMaxX); - myMaxY = Max(my,myMaxY); - } - } -} - -void Graphic2d_Drawer::MapMarkerFromTo( - const Standard_Integer anindex, - const Standard_ShortReal x, - const Standard_ShortReal y, - const Standard_ShortReal awidth, - const Standard_ShortReal anheight, - const Standard_ShortReal anAngle, - const Standard_Integer aMode) { - if (! myDriverIsDefined) - Graphic2d_DrawerDefinitionError::Raise ("No defined driver"); - - Standard_ShortReal mx,my; - mx = myXT + ((x-myXF)/mySF) *myST; - my = myYT + ((y-myYF)/mySF) *myST; - - if( anindex > 0 && awidth > 0. && anheight > 0. ) { - if( aMode > 0 ) myDriver->BeginMarkers(); - myDriver->DrawMarker(anindex,mx,my,awidth,anheight,anAngle); - if( myMinMaxIsActivated ) { - Standard_ShortReal d = Standard_ShortReal(Sqrt(awidth*awidth + anheight*anheight)); - myMinX = Min(mx-d,myMinX); - myMinY = Min(my-d,myMinY); - myMaxX = Max(mx+d,myMaxX); - myMaxY = Max(my+d,myMaxY); - } - } else { - if( aMode > 0 ) myDriver->BeginPoints(); - myDriver->DrawPoint(mx,my); - if( myMinMaxIsActivated ) { - myMinX = Min(mx,myMinX); - myMinY = Min(my,myMinY); - myMaxX = Max(mx,myMaxX); - myMaxY = Max(my,myMaxY); - } - } - if( aMode < 0 ) myDriver->ClosePrimitive(); - -} - -void Graphic2d_Drawer -::MapMarkersFromTo( const Standard_Integer anindex, - const Handle(TShort_HArray1OfShortReal)& x, - const Handle(TShort_HArray1OfShortReal)& y, - const Standard_ShortReal awidth, - const Standard_ShortReal anheight, - const Standard_ShortReal anAngle, - const Standard_Integer aMode) -{ -#ifdef OCC402 - - if (! myDriverIsDefined) - Graphic2d_DrawerDefinitionError::Raise ("No defined driver"); - - if( anindex > 0 && awidth > 0. && anheight > 0. ) { - - Standard_ShortReal mx,my; - myDriver->BeginMarkers(); - - for ( Standard_Integer i = x->Lower(); i <= x->Upper(); i++ ) { - mx = myXT + ( ( x->Value( i ) - myXF ) / mySF ) * myST; - my = myYT + ( ( y->Value( i ) - myYF ) / mySF ) * myST; - myDriver->DrawMarker(anindex,mx,my,awidth,anheight,anAngle); - } - myDriver->ClosePrimitive(); - } -#endif -} - -void Graphic2d_Drawer::DrawPolygon ( - const Standard_Real aDeltaX, - const Standard_Real aDeltaY, - const TShort_Array1OfShortReal& aListX, - const TShort_Array1OfShortReal& aListY) { - - if (! myDriverIsDefined) - Graphic2d_DrawerDefinitionError::Raise ("No defined driver"); - - Standard_Integer n1 = aListX.Lower(); - Standard_Integer n2 = aListX.Upper(); - Standard_ShortReal X,Y; - - myDriver->BeginPolygon(n2-n1+1); - for (Standard_Integer i=n1 ; i<=n2; i++) { - X = Standard_ShortReal(aDeltaX) + Standard_ShortReal(aListX(i)); - Y = Standard_ShortReal(aDeltaY) + Standard_ShortReal(aListY(i)); - myDriver->DrawPoint(X,Y); - if( myMinMaxIsActivated ) { - myMinX = Min(X,myMinX); - myMinY = Min(Y,myMinY); - myMaxX = Max(X,myMaxX); - myMaxY = Max(Y,myMaxY); - } - } - myDriver->ClosePrimitive(); - -} - -void Graphic2d_Drawer::MapPolygonFromTo ( - const TShort_Array1OfShortReal& aListX, - const TShort_Array1OfShortReal& aListY, - const Standard_Integer Npoint) { - - if (! myDriverIsDefined) - Graphic2d_DrawerDefinitionError::Raise ("No defined driver"); - - Standard_Integer n1 = aListX.Lower(); - Standard_Integer n2 = (Npoint > 0) ? n1+Npoint-1 : aListX.Upper(); - Standard_ShortReal X,Y; - - myDriver->BeginPolygon(n2-n1+1); - for (Standard_Integer i=n1 ; i<=n2; i++) { - X = myXT + ((aListX(i)-myXF)/mySF) *myST; - Y = myYT + ((aListY(i)-myYF)/mySF) *myST; - myDriver->DrawPoint(X,Y); - if( myMinMaxIsActivated ) { - myMinX = Min(X,myMinX); - myMinY = Min(Y,myMinY); - myMaxX = Max(X,myMaxX); - myMaxY = Max(Y,myMaxY); - } - } - myDriver->ClosePrimitive(); - -} - -void Graphic2d_Drawer::MapPolygonFromTo ( - const Standard_ShortReal x, - const Standard_ShortReal y, - const Standard_Integer aMode) { - - if (! myDriverIsDefined) - Graphic2d_DrawerDefinitionError::Raise ("No defined driver"); - - Standard_ShortReal X,Y; - X = myXT + ((x-myXF)/mySF) *myST; - Y = myYT + ((y-myYF)/mySF) *myST; - - if( aMode > 0 ) myDriver->BeginPolygon(aMode); - myDriver->DrawPoint(X,Y); - if( myMinMaxIsActivated ) { - myMinX = Min(X,myMinX); - myMinY = Min(Y,myMinY); - myMaxX = Max(X,myMaxX); - myMaxY = Max(Y,myMaxY); - } - if( aMode < 0 ) myDriver->ClosePrimitive(); - -} - -void Graphic2d_Drawer::DrawArc( - const Standard_Real aDeltaX, - const Standard_Real aDeltaY, - const Standard_ShortReal aRadius, - const Standard_ShortReal Angle1, - const Standard_ShortReal Angle2) { - if (! myDriverIsDefined) - Graphic2d_DrawerDefinitionError::Raise ("No defined driver"); - - Standard_ShortReal mx,my,a1,a2,da; - mx = Standard_ShortReal(aDeltaX); - my = Standard_ShortReal(aDeltaY); - a1 = (Angle1 >= 0.) ? Angle1 : Angle1 + Standard_ShortReal(2. * M_PI); - a2 = (Angle2 >= 0.) ? Angle2 : Angle2 + Standard_ShortReal(2. * M_PI); - if( a2 > a1 ) { - da = a2 - a1; - } else if( a2 < a1 ) { - da = Standard_ShortReal(2. * M_PI + a2 - a1); - } else { - a1 = 0.; da = Standard_ShortReal(2. * M_PI); - } - - if( aRadius > 0. ) { // Try to use hardware first - Standard_Boolean status = - myDriver->DrawArc(mx,my,aRadius,aRadius,a1,da); - if( !status ) { // or Emulate - Standard_ShortReal precis = myDrawPrecision; - Standard_ShortReal value; - if( myTypeOfDeflection == Aspect_TOD_RELATIVE) { - precis = Standard_ShortReal(aRadius * myDeflectionCoefficient); - } - if( aRadius > precis ) - value = Standard_ShortReal(Max( 0.0044, Min (0.7854 , 2. * ACos(1.-precis/aRadius)))); - else - value = Standard_ShortReal(0.7854); // = PI/4. - Standard_Integer nbpoints = Min(MAXPOINTS, - Standard_Integer(Abs(da)/value)+2); - Standard_ShortReal teta = da/nbpoints; - Standard_ShortReal cosin = Standard_ShortReal(Cos(teta)); - Standard_ShortReal x1 = Standard_ShortReal(aRadius * Cos(a1)); - Standard_ShortReal y1 = Standard_ShortReal(aRadius * Sin(a1)); - Standard_ShortReal x2 = Standard_ShortReal(aRadius * Cos(a1+teta)); - Standard_ShortReal y2 = Standard_ShortReal(aRadius * Sin(a1+teta)); - Standard_ShortReal x,y; - - nbpoints++; - myDriver->BeginPolyline(nbpoints); - myDriver->DrawPoint(mx+x1,my+y1); - myDriver->DrawPoint(mx+x2,my+y2); - for (Standard_Integer i=3; i<= nbpoints; i++) { - x = 2*x2*cosin - x1; x1 = x2; x2 = x; - y = 2*y2*cosin - y1; y1 = y2; y2 = y; - myDriver->DrawPoint(mx+x,my+y); - } - myDriver->ClosePrimitive(); - } - if( myMinMaxIsActivated ) { - myMinX = Min(mx-aRadius,myMinX); - myMinY = Min(my-aRadius,myMinY); - myMaxX = Max(mx+aRadius,myMaxX); - myMaxY = Max(my+aRadius,myMaxY); - } - } -} - -void Graphic2d_Drawer::MapArcFromTo( - const Standard_ShortReal x, - const Standard_ShortReal y, - const Standard_ShortReal aRadius, - const Standard_ShortReal Angle1, - const Standard_ShortReal Angle2, - const Standard_Integer aMode) { - if (! myDriverIsDefined) - Graphic2d_DrawerDefinitionError::Raise ("No defined driver"); - - Standard_ShortReal mx,my,r; - mx = myXT + ((x-myXF)/mySF) *myST; - my = myYT + ((y-myYF)/mySF) *myST; - r = aRadius/mySF*myST; - - if( aRadius > 0. ) { - DrawArc(mx,my,r,Angle1,Angle2); - if( myMinMaxIsActivated ) { - myMinX = Min(mx-aRadius,myMinX); - myMinY = Min(my-aRadius,myMinY); - myMaxX = Max(mx+aRadius,myMaxX); - myMaxY = Max(my+aRadius,myMaxY); - } - } -} - -void Graphic2d_Drawer::DrawPolyArc( - const Standard_Real aDeltaX, - const Standard_Real aDeltaY, - const Standard_ShortReal aRadius, - const Standard_ShortReal Angle1, - const Standard_ShortReal Angle2) { - if (! myDriverIsDefined) - Graphic2d_DrawerDefinitionError::Raise ("No defined driver"); - - Standard_ShortReal mx,my,a1,a2,da; - mx = Standard_ShortReal(aDeltaX); - my = Standard_ShortReal(aDeltaY); - a1 = (Angle1 >= 0.) ? Angle1 : Angle1 + Standard_ShortReal(2. * M_PI); - a2 = (Angle2 >= 0.) ? Angle2 : Angle2 + Standard_ShortReal(2. * M_PI); - if( a2 > a1 ) { - da = a2 - a1; - } else if( a2 < a1 ) { - da = Standard_ShortReal(2. * M_PI + a2 - a1); - } else { - a1 = 0.; da = Standard_ShortReal(2. * M_PI); - } - - if( aRadius > 0. ) { // Try to use hardware first - Standard_Boolean status = - myDriver->DrawPolyArc(mx,my,aRadius,aRadius,a1,da); - if( !status ) { // or Emulate - Standard_ShortReal precis = myDrawPrecision; - Standard_ShortReal value; - if( myTypeOfDeflection == Aspect_TOD_RELATIVE) { - precis = Standard_ShortReal(aRadius * myDeflectionCoefficient); - } - if( aRadius > precis ) - value = Standard_ShortReal(Max( 0.0044, Min (0.7854 , 2. * ACos(1.-precis/aRadius)))); - else - value = Standard_ShortReal(0.7854); // = PI/4. - Standard_Integer nbpoints = Min(MAXPOINTS, - Standard_Integer(Abs(da)/value)+2); - Standard_ShortReal teta = da/nbpoints; - Standard_ShortReal cosin = Standard_ShortReal(Cos(teta)); - Standard_ShortReal x1 = Standard_ShortReal(aRadius * Cos(a1)); - Standard_ShortReal y1 = Standard_ShortReal(aRadius * Sin(a1)); - Standard_ShortReal x2 = Standard_ShortReal(aRadius * Cos(a1+teta)); - Standard_ShortReal y2 = Standard_ShortReal(aRadius * Sin(a1+teta)); - Standard_ShortReal x,y; - - nbpoints++; - myDriver->BeginPolygon(nbpoints); - myDriver->DrawPoint(mx+x1,my+y1); - myDriver->DrawPoint(mx+x2,my+y2); - for (Standard_Integer i=3; i<= nbpoints; i++) { - x = 2*x2*cosin - x1; x1 = x2; x2 = x; - y = 2*y2*cosin - y1; y1 = y2; y2 = y; - myDriver->DrawPoint(mx+x,my+y); - } - myDriver->ClosePrimitive(); - } - if( myMinMaxIsActivated ) { - myMinX = Min(mx-aRadius,myMinX); - myMinY = Min(my-aRadius,myMinY); - myMaxX = Max(mx+aRadius,myMaxX); - myMaxY = Max(my+aRadius,myMaxY); - } - } -} - -void Graphic2d_Drawer::MapPolyArcFromTo( - const Standard_ShortReal x, - const Standard_ShortReal y, - const Standard_ShortReal aRadius, - const Standard_ShortReal Angle1, - const Standard_ShortReal Angle2, - const Standard_Integer aMode) { - if (! myDriverIsDefined) - Graphic2d_DrawerDefinitionError::Raise ("No defined driver"); - - Standard_ShortReal mx,my,r; - mx = myXT + ((x-myXF)/mySF) *myST; - my = myYT + ((y-myYF)/mySF) *myST; - r = aRadius/mySF*myST; - - if( aRadius > 0. ) { - DrawPolyArc(mx,my,r,Angle1,Angle2); - if( myMinMaxIsActivated ) { - myMinX = Min(mx-aRadius,myMinX); - myMinY = Min(my-aRadius,myMinY); - myMaxX = Max(mx+aRadius,myMaxX); - myMaxY = Max(my+aRadius,myMaxY); - } - } -} - -void Graphic2d_Drawer::SetRejection( const Standard_Boolean aClippingFlag) { - myClippingIsActivated = aClippingFlag; -} - -Standard_Boolean Graphic2d_Drawer::IsIn( - const Standard_ShortReal aMinX, - const Standard_ShortReal aMaxX, - const Standard_ShortReal aMinY, - const Standard_ShortReal aMaxY)const -{ -#ifdef CTS17857 - if( !myClippingIsActivated ) return Standard_True; -#endif - - Standard_ShortReal x,X,y,Y; - - x = myXT + ((aMinX-myXF)/mySF) *myST; - y = myYT + ((aMinY-myYF)/mySF) *myST; - X = myXT + ((aMaxX-myXF)/mySF) *myST; - Y = myYT + ((aMaxY-myYF)/mySF) *myST; - - Standard_Boolean clip = ((x < 0. && X < 0.) || - (x > mySpaceWidth && X > mySpaceWidth) || - (y < 0. && Y < 0.) || - (y > mySpaceHeight && Y > mySpaceHeight)); - -#ifdef TRACE - if( clip ) printf(" *Rejected primitive %f,%f,%f,%f\n", - aMinX,aMinY,aMaxX,aMaxY); -#endif - - return !clip; -} - -void Graphic2d_Drawer::DrawInfiniteLine ( - const Standard_ShortReal x, - const Standard_ShortReal y, - const Standard_ShortReal dx, - const Standard_ShortReal dy) { - - if (! myDriverIsDefined) - Graphic2d_DrawerDefinitionError::Raise ("No defined driver"); - - Standard_ShortReal mx = x,my = y,x1,y1,x2=0,y2=0; - Standard_Boolean status = Standard_True; - - if ( dx == 0. ) { - // Bug with rejection of infinite lines - // if ( my >= 0. && my <= mySpaceHeight ) - x1 = mx; y1 = 0.; x2 = mx; y2 = mySpaceHeight; - } - else if ( dy == 0.) { - // Bug with rejection of infinite lines - // if ( mx >= 0. && mx <= mySpaceWidth ) - x1 = 0.; y1 = my; x2 = mySpaceWidth; y2 = my; - } - else { -// equation of the line: X = mx + lambda * dx -// Y = my + lambda * dy - Standard_ShortReal lambda, lmin=ShortRealLast(),lmax= ShortRealFirst(); - - lambda = -mx/dx; y1 = my + lambda *dy; - if ( y1 >= 0. && y1 <= mySpaceHeight) { - lmin = lmax = lambda;} - - lambda = (mySpaceWidth-mx)/dx; y1 = my + lambda *dy; - if ( y1 >= 0. && y1 <= mySpaceHeight) { - lmin = lambda < lmin ? lambda : lmin; - lmax = lambda > lmax ? lambda : lmax;} - - lambda = -my/dy; x1 = mx + lambda *dx; - if ( x1 >= 0. && x1 <= mySpaceWidth) { - lmin = lambda < lmin ? lambda : lmin; - lmax = lambda > lmax ? lambda : lmax;} - - lambda = (mySpaceHeight-my)/dy; x1 = mx + lambda *dx; - if ( x1 >= 0. && x1 <= mySpaceWidth) { - lmin = lambda < lmin ? lambda : lmin; - lmax = lambda > lmax ? lambda : lmax;} - - if (lmin != ShortRealLast() && lmax != ShortRealFirst() && - lmin < lmax ) { - x1 = mx + lmin *dx; y1 = my + lmin *dy; - x2 = mx + lmax *dx; y2 = my + lmax *dy; - } else status = Standard_False; - } - if( status ) { - myDriver->DrawSegment(x1,y1,x2,y2); - if( myMinMaxIsActivated ) { - myMinX = Min(x1,myMinX); myMinX = Min(x2,myMinX); - myMinY = Min(y1,myMinY); myMinY = Min(y2,myMinY); - myMaxX = Max(x1,myMaxX); myMaxX = Max(x2,myMaxX); - myMaxY = Max(y1,myMaxY); myMaxY = Max(y2,myMaxY); - } - } - -} - -void Graphic2d_Drawer::MapInfiniteLineFromTo ( - const Standard_ShortReal x, - const Standard_ShortReal y, - const Standard_ShortReal dx, - const Standard_ShortReal dy) { - - if (! myDriverIsDefined) - Graphic2d_DrawerDefinitionError::Raise ("No defined driver"); - -// Standard_ShortReal mx,my,x1,y1,x2,y2; - Standard_ShortReal mx,my; -// Standard_Boolean status = Standard_True; - - mx = myXT + ((x-myXF)/mySF) *myST; - my = myYT + ((y-myYF)/mySF) *myST; - DrawInfiniteLine(mx,my,dx,dy); - -} - -void Graphic2d_Drawer::SetLineAttrib(const Standard_Integer ColorIndex, - const Standard_Integer TypeIndex, - const Standard_Integer WidthIndex) { - - if (! myDriverIsDefined) - Graphic2d_DrawerDefinitionError::Raise ("No defined driver"); - -#ifdef CSR_PRO12324 - if(myOverride && !IsPlotterDriver()) -#else - if(myOverride) -#endif - myDriver->SetLineAttrib(myOverrideColor, - TypeIndex,WidthIndex); - else if( ColorIndex > 0 ) - myDriver->SetLineAttrib(ColorIndex+myOffSet, - TypeIndex,WidthIndex); - else myDriver->SetLineAttrib(ColorIndex,TypeIndex,WidthIndex); - -} - -void Graphic2d_Drawer::SetMarkerAttrib(const Standard_Integer ColorIndex, - const Standard_Integer WidthIndex, - const Standard_Boolean FillMarker) { - - if (! myDriverIsDefined) - Graphic2d_DrawerDefinitionError::Raise ("No defined driver"); - -#ifdef CSR_PRO12324 - if(myOverride && !IsPlotterDriver()) -#else - if(myOverride) -#endif - myDriver->SetMarkerAttrib(myOverrideColor, - WidthIndex,FillMarker); - else if( ColorIndex > 0 ) - myDriver->SetMarkerAttrib(ColorIndex+myOffSet, - WidthIndex,FillMarker); - else myDriver->SetMarkerAttrib(ColorIndex, - WidthIndex,FillMarker); - -} - -void Graphic2d_Drawer::SetPolyAttrib(const Standard_Integer ColorIndex, - const Standard_Integer TileIndex, - const Standard_Boolean DrawEdge) { - - if (! myDriverIsDefined) - Graphic2d_DrawerDefinitionError::Raise ("No defined driver"); - -#ifdef CSR_PRO12324 - if(myOverride && !IsPlotterDriver()) -#else - if(myOverride) -#endif - myDriver->SetPolyAttrib(myOverrideColor,TileIndex,DrawEdge); - else if( ColorIndex > 0 ) - myDriver->SetPolyAttrib(ColorIndex+myOffSet,TileIndex,DrawEdge); - else myDriver->SetPolyAttrib(ColorIndex,TileIndex,DrawEdge); - -} - -void Graphic2d_Drawer::SetHidingPolyAttrib( - const Standard_Integer HidingColorIndex, - const Standard_Integer FrameColorIndex, - const Standard_Integer FrameTypeIndex, - const Standard_Integer FrameWidthIndex) { - - if (! myDriverIsDefined) - Graphic2d_DrawerDefinitionError::Raise ("No defined driver"); -#ifdef CSR_PRO12324 - if(myOverride && !IsPlotterDriver()) { -#else - if(myOverride) { -#endif - myDriver->SetLineAttrib(myOverrideColor,FrameTypeIndex,FrameWidthIndex); - if( HidingColorIndex > 0 ) { - myDriver->SetPolyAttrib(HidingColorIndex+myOffSet,0,Standard_True); - } else { - myDriver->SetPolyAttrib(HidingColorIndex,0,Standard_True); - } - } else { - Standard_Boolean DrawEdge = Standard_False; - if( (FrameColorIndex > 0) && (FrameColorIndex != HidingColorIndex) ) { - DrawEdge = Standard_True; - myDriver->SetLineAttrib(FrameColorIndex+myOffSet,FrameTypeIndex,FrameWidthIndex); - } - if( HidingColorIndex > 0 ) { - myDriver->SetPolyAttrib(HidingColorIndex+myOffSet,0,DrawEdge); - } else { - myDriver->SetPolyAttrib(HidingColorIndex,0,DrawEdge); - } - } - -} - -void Graphic2d_Drawer::SetTextAttrib(const Standard_Integer ColorIndex, - const Standard_Integer FontIndex, - const Standard_ShortReal aSlant, - const Standard_ShortReal aHScale, - const Standard_ShortReal aWScale, - const Standard_Boolean isUnderlined) { - - if (! myDriverIsDefined) - Graphic2d_DrawerDefinitionError::Raise ("No defined driver"); - -#ifdef BUC60650 - Standard_ShortReal hscale = (aHScale > 0.) ? aHScale : - (aWScale > 0.) ? aWScale : Standard_ShortReal(1.0); - Standard_ShortReal wscale = (aWScale > 0.) ? aWScale : hscale; -#else - Standard_ShortReal hscale = aHScale; - Standard_ShortReal wscale = aWScale; -#endif - - -#ifdef CSR_PRO12324 - if(myOverride && !IsPlotterDriver()) -#else - if(myOverride) -#endif - myDriver->SetTextAttrib(myOverrideColor,FontIndex, - aSlant,hscale,wscale,isUnderlined); - else if( ColorIndex > 0 ) - myDriver->SetTextAttrib(ColorIndex+myOffSet,FontIndex, - aSlant,hscale,wscale,isUnderlined); - else myDriver->SetTextAttrib(ColorIndex,FontIndex, - aSlant,hscale,wscale,isUnderlined); - -} - -void Graphic2d_Drawer::SetHidingTextAttrib(const Standard_Integer ColorIndex, - const Standard_Integer HidingColorIndex, - const Standard_Integer FrameColorIndex, - const Standard_Integer FrameWidthIndex, - const Standard_Integer FontIndex, - const Standard_ShortReal aSlant, - const Standard_ShortReal aHScale, - const Standard_ShortReal aWScale, - const Standard_Boolean isUnderlined) { - - if (! myDriverIsDefined) - Graphic2d_DrawerDefinitionError::Raise ("No defined driver"); - -#ifdef BUC60650 - Standard_ShortReal hscale = (aHScale > 0.) ? aHScale : - (aWScale > 0.) ? aWScale : Standard_ShortReal(1.0); - Standard_ShortReal wscale = (aWScale > 0.) ? aWScale : hscale; -#else - Standard_ShortReal hscale = aHScale; - Standard_ShortReal wscale = aWScale; -#endif - -#ifdef CSR_PRO12324 - if(myOverride && !IsPlotterDriver()) { -#else - if(myOverride) { -#endif - if( ColorIndex >= 0 ) { - myDriver->SetTextAttrib(myOverrideColor,FontIndex, - aSlant,hscale,wscale,isUnderlined); - } - myDriver->SetLineAttrib(myOverrideColor,0,FrameWidthIndex); - if( HidingColorIndex > 0 ) { - myDriver->SetPolyAttrib(HidingColorIndex+myOffSet,0,Standard_True); - } else { - myDriver->SetPolyAttrib(HidingColorIndex,0,Standard_True); - } - } else { - Standard_Boolean DrawEdge = Standard_False; - if( ColorIndex >= 0 ) { - if( (ColorIndex > 0) && (ColorIndex != HidingColorIndex) ) { - myDriver->SetTextAttrib(ColorIndex+myOffSet,FontIndex, - aSlant,hscale,wscale,isUnderlined); - } else { - myDriver->SetTextAttrib(0,FontIndex, - aSlant,hscale,wscale,isUnderlined); - } - } - if( (FrameColorIndex > 0) && (FrameColorIndex != HidingColorIndex) ) { - DrawEdge = Standard_True; - myDriver->SetLineAttrib(FrameColorIndex+myOffSet,0,FrameWidthIndex); - } - if( HidingColorIndex > 0 ) { - myDriver->SetPolyAttrib(HidingColorIndex+myOffSet,0,DrawEdge); - } else { - myDriver->SetPolyAttrib(HidingColorIndex,0,DrawEdge); - } - } -} - -void Graphic2d_Drawer::SetFramedTextAttrib(const Standard_Integer ColorIndex, - const Standard_Integer FrameColorIndex, - const Standard_Integer FrameWidthIndex, - const Standard_Integer FontIndex, - const Standard_ShortReal aSlant, - const Standard_ShortReal aHScale, - const Standard_ShortReal aWScale, - const Standard_Boolean isUnderlined) { - - if (! myDriverIsDefined) - Graphic2d_DrawerDefinitionError::Raise ("No defined driver"); - -#ifdef BUC60650 - Standard_ShortReal hscale = (aHScale > 0.) ? aHScale : - (aWScale > 0.) ? aWScale : Standard_ShortReal(1.0); - Standard_ShortReal wscale = (aWScale > 0.) ? aWScale : hscale; -#else - Standard_ShortReal hscale = aHScale; - Standard_ShortReal wscale = aWScale; -#endif - -#ifdef CSR_PRO12324 - if(myOverride && !IsPlotterDriver()) { -#else - if(myOverride) { -#endif - if( ColorIndex >= 0 ) { - myDriver->SetTextAttrib(myOverrideColor,FontIndex, - aSlant,hscale,wscale,isUnderlined); - } - myDriver->SetLineAttrib(myOverrideColor,0,FrameWidthIndex); - } else { - if( ColorIndex >= 0 ) { - if( ColorIndex > 0 ) { - myDriver->SetTextAttrib(ColorIndex+myOffSet,FontIndex, - aSlant,hscale,wscale,isUnderlined); - } else { - myDriver->SetTextAttrib(ColorIndex,FontIndex, - aSlant,hscale,wscale,isUnderlined); - } - } - if( FrameColorIndex > 0 ) { - myDriver->SetLineAttrib(FrameColorIndex+myOffSet,0,FrameWidthIndex); - } else if( ColorIndex > 0 ) { - myDriver->SetLineAttrib(ColorIndex+myOffSet,0,FrameWidthIndex); - } else { - myDriver->SetLineAttrib(ColorIndex,0,FrameWidthIndex); - } - } - myDriver->SetPolyAttrib(ColorIndex,-1,Standard_True); -} - -Standard_Boolean Graphic2d_Drawer::IsKnownImage(const Handle(Standard_Transient)& anImageId) { - - if (! myDriverIsDefined) - Graphic2d_DrawerDefinitionError::Raise ("No defined driver"); - - return myDriver->IsKnownImage(anImageId); - -} - -void Graphic2d_Drawer::ClearImage(const Handle(Standard_Transient)& anImageId) { - - if (! myDriverIsDefined) - Graphic2d_DrawerDefinitionError::Raise ("No defined driver"); - - myDriver->ClearImage(anImageId); - -} - -void Graphic2d_Drawer::DrawImage(const Handle(Standard_Transient)& anImageId, - const Standard_ShortReal aX, - const Standard_ShortReal aY) { - - if (! myDriverIsDefined) - Graphic2d_DrawerDefinitionError::Raise ("No defined driver"); - - Standard_ShortReal X,Y; - X = myXT + ((aX-myXF)/mySF) *myST; - Y = myYT + ((aY-myYF)/mySF) *myST; - myDriver->DrawImage(anImageId,X,Y); -} - -void Graphic2d_Drawer::ClearImageFile(const Standard_CString aName) { - - if (! myDriverIsDefined) - Graphic2d_DrawerDefinitionError::Raise ("No defined driver"); - - myDriver->ClearImageFile(aName); - -} - -void Graphic2d_Drawer::DrawImageFile (const Standard_CString aName, - const Standard_ShortReal aX, - const Standard_ShortReal aY, - const Quantity_Factor aScale) { - - if (! myDriverIsDefined) - Graphic2d_DrawerDefinitionError::Raise ("No defined driver"); - - Standard_ShortReal X,Y; - X = myXT + ((aX-myXF)/mySF) *myST; - Y = myYT + ((aY-myYF)/mySF) *myST; - myDriver->DrawImageFile (aName, X, Y, aScale); - if( myMinMaxIsActivated ) { - Standard_ShortReal width,height; - if( GetImageSize(aName,width,height) ) { - Standard_ShortReal x1 = Standard_ShortReal(X-width/2.); - Standard_ShortReal y1 = Standard_ShortReal(Y-height/2.); - Standard_ShortReal x2 = Standard_ShortReal(X+width/2.); - Standard_ShortReal y2 = Standard_ShortReal(Y+height/2.); - myMinX = Min(x1,myMinX); - myMinY = Min(y1,myMinY); - myMaxX = Max(x2,myMaxX); - myMaxY = Max(y2,myMaxY); - } - } - -} - -void Graphic2d_Drawer::FillAndDrawImage(const Handle(Standard_Transient)& anImageId, - const Standard_ShortReal aX, - const Standard_ShortReal aY, - const Standard_Integer aWidth, - const Standard_Integer aHeight, - const Standard_Address anArrayOfPixels) { - - if (! myDriverIsDefined) - Graphic2d_DrawerDefinitionError::Raise ("No defined driver"); - - Standard_ShortReal X,Y; - X = myXT + ((aX-myXF)/mySF) *myST; - Y = myYT + ((aY-myYF)/mySF) *myST; - myDriver->FillAndDrawImage - (anImageId,X,Y,aWidth,aHeight,anArrayOfPixels); - if( myMinMaxIsActivated ) { - Standard_ShortReal width = Convert(aWidth); - Standard_ShortReal height = Convert(aHeight); - Standard_ShortReal x1 = Standard_ShortReal(X-width/2.); - Standard_ShortReal y1 = Standard_ShortReal(Y-height/2.); - Standard_ShortReal x2 = Standard_ShortReal(X+width/2.); - Standard_ShortReal y2 = Standard_ShortReal(Y+height/2.); - myMinX = Min(x1,myMinX); - myMinY = Min(y1,myMinY); - myMaxX = Max(x2,myMaxX); - myMaxY = Max(y2,myMaxY); - } - -} - -void Graphic2d_Drawer::FillAndDrawImage(const Handle(Standard_Transient)& anImageId, - const Standard_ShortReal aX, - const Standard_ShortReal aY, - const Standard_Integer anIndexOfLine, - const Standard_Integer aWidth, - const Standard_Integer aHeight, - const Standard_Address anArrayOfPixels) { - if (! myDriverIsDefined) - Graphic2d_DrawerDefinitionError::Raise ("No defined driver"); - - Standard_ShortReal X,Y; - X = myXT + ((aX-myXF)/mySF) *myST; - Y = myYT + ((aY-myYF)/mySF) *myST; - myDriver->FillAndDrawImage - (anImageId,X,Y,anIndexOfLine,aWidth,aHeight,anArrayOfPixels); - if( myMinMaxIsActivated ) { - Standard_ShortReal width = Convert(aWidth); - Standard_ShortReal height = Convert(aHeight); - Standard_ShortReal x1 = Standard_ShortReal(X-width/2.); - Standard_ShortReal y1 = Standard_ShortReal(Y-height/2.); - Standard_ShortReal x2 = Standard_ShortReal(X+width/2.); - Standard_ShortReal y2 = Standard_ShortReal(Y+height/2.); - myMinX = Min(x1,myMinX); - myMinY = Min(y1,myMinY); - myMaxX = Max(x2,myMaxX); - myMaxY = Max(y2,myMaxY); - } - -} - -Standard_ShortReal Graphic2d_Drawer::Convert(const Standard_ShortReal aValue) const { - - return aValue/mySF * myST; - -} - -Standard_ShortReal Graphic2d_Drawer::Convert(const Standard_Integer aValue) const { -Standard_ShortReal dValue = 0.; - - if( myDriverIsDefined ) { - dValue = Standard_ShortReal(myDriver->Convert(aValue)); - } - return dValue; -} - -Standard_ShortReal Graphic2d_Drawer::Scale() const { - - return myST/mySF; - -} - -Standard_ShortReal Graphic2d_Drawer::ConvertMapToFrom(const Standard_ShortReal x) const { - - return x/myST * mySF; - -} diff --git a/src/Graphic2d/Graphic2d_Ellips.cdl b/src/Graphic2d/Graphic2d_Ellips.cdl deleted file mode 100755 index 4a0ba1d4f6..0000000000 --- a/src/Graphic2d/Graphic2d_Ellips.cdl +++ /dev/null @@ -1,133 +0,0 @@ --- Created on: 1993-06-22 --- Created by: Jean Louis FRENKEL, Gerard GRAS --- Copyright (c) 1993-1999 Matra Datavision --- Copyright (c) 1999-2012 OPEN CASCADE SAS --- --- The content of this file is subject to the Open CASCADE Technology Public --- License Version 6.5 (the "License"). You may not use the content of this file --- except in compliance with the License. Please obtain a copy of the License --- at http://www.opencascade.org and read it completely before using this file. --- --- The Initial Developer of the Original Code is Open CASCADE S.A.S., having its --- main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. --- --- The Original Code and all software distributed under the License is --- distributed on an "AS IS" basis, without warranty of any kind, and the --- Initial Developer hereby disclaims all such warranties, including without --- limitation, any warranties of merchantability, fitness for a particular --- purpose or non-infringement. Please see the License for the specific terms --- and conditions governing the rights and limitations under the License. - - --- Modified: TCL G002A, 28-11-00, new section "inquire methods" - - -class Ellips from Graphic2d inherits Line from Graphic2d - - ---Version: - - ---Purpose: The primitive Ellips - - ---Keywords: Primitive, Ellips - ---Warning: - ---References: - -uses - - Drawer from Graphic2d, - GraphicObject from Graphic2d, - PlaneAngle from Quantity, - Length from Quantity, - FStream from Aspect, - IFStream from Aspect - - -raises - - EllipsDefinitionError from Graphic2d - -is - ------------------------- - -- Category: Constructors - ------------------------- - - Create (aGraphicObject: GraphicObject from Graphic2d; - X, Y: Length from Quantity; - MajorRadius, MinorRadius: Length from Quantity; - anAngle: PlaneAngle from Quantity) - returns mutable Ellips from Graphic2d - ---Level: Public - ---Purpose: Creates an ellipse. - -- The center is , . - -- Angles are measured counterclockwise with 0 radian - -- at 3 o'clock. - ---Category: Constructors - ---Warning: Raises EllipsDefinitionError if the - -- major radius or the minor radius is null. - raises EllipsDefinitionError from Graphic2d; - - -------------------------- - -- Category: Draw and Pick - -------------------------- - - Draw (me : mutable; aDrawer: Drawer from Graphic2d) - is static protected; - ---Level: Internal - ---Purpose: Draws the ellipse . - - DrawElement( me : mutable; aDrawer: Drawer from Graphic2d; - anIndex: Integer from Standard) - is redefined protected; - ---Level: Internal - ---Purpose: Draws element of the circle . - - DrawVertex( me : mutable; aDrawer: Drawer from Graphic2d; - anIndex: Integer from Standard) - is redefined protected; - ---Level: Internal - ---Purpose: Draws vertex of the circle . - - Pick (me : mutable; X, Y: ShortReal from Standard; - aPrecision: ShortReal from Standard; - aDrawer: Drawer from Graphic2d) - returns Boolean from Standard - is static protected; - ---Level: Internal - ---Purpose: Returns Standard_True if the ellipse is picked, - -- Standard_False if not. - - -------------------------------------- - -- Category: Inquire methods - -------------------------------------- - - Center( me; X, Y: out Length from Quantity ); - ---Level: Public - ---Purpose: returns the coordinates of center of the ellipse - - MajorRadius( me ) returns Length from Quantity; - ---Level: Public - ---Purpose: returns the radius of the ellipse - - MinorRadius( me ) returns Length from Quantity; - ---Level: Public - ---Purpose: returns the radius of the ellipse - - Angle( me ) returns PlaneAngle from Quantity; - ---Level: Public - ---Purpose: returns the angle of the ellipse - - ---------------------------------------------------------------------- - - Save( me; aFStream: in out FStream from Aspect ) is virtual; - Retrieve(myclass; anIFStream: in out IFStream from Aspect; - aGraphicObject: GraphicObject from Graphic2d); - -fields - - myX: ShortReal from Standard; - myY: ShortReal from Standard; - myMajorRadius: ShortReal from Standard; - myMinorRadius: ShortReal from Standard; - myAngle: ShortReal from Standard; - -end Ellips from Graphic2d; diff --git a/src/Graphic2d/Graphic2d_Ellips.cxx b/src/Graphic2d/Graphic2d_Ellips.cxx deleted file mode 100755 index d25fbd34da..0000000000 --- a/src/Graphic2d/Graphic2d_Ellips.cxx +++ /dev/null @@ -1,434 +0,0 @@ -// Copyright (c) 1995-1999 Matra Datavision -// Copyright (c) 1999-2012 OPEN CASCADE SAS -// -// The content of this file is subject to the Open CASCADE Technology Public -// License Version 6.5 (the "License"). You may not use the content of this file -// except in compliance with the License. Please obtain a copy of the License -// at http://www.opencascade.org and read it completely before using this file. -// -// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its -// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. -// -// The Original Code and all software distributed under the License is -// distributed on an "AS IS" basis, without warranty of any kind, and the -// Initial Developer hereby disclaims all such warranties, including without -// limitation, any warranties of merchantability, fitness for a particular -// purpose or non-infringement. Please see the License for the specific terms -// and conditions governing the rights and limitations under the License. - -/*===================================================================== - - FUNCTION : - ---------- - Class Graphic2d_Ellips - - TEST : - ------ - - Voir TestG2D/TestG21 - - NOTES: - ---------- - - HISTORY OF MODIFICATIONS : - -------------------------------- - - 27-01-98 : GG ; OPTIMISATION LOADER - Transform global static variables into static locals. - -=====================================================================*/ -#define G002 //Add new DrawElement(), DrawVertex() methods - -#define VERTEXMARKER 2 -#define DEFAULTMARKERSIZE 3.0 - -#include -#include - -#define MAXPOINTS 1023 - -Graphic2d_Ellips::Graphic2d_Ellips - (const Handle(Graphic2d_GraphicObject)& aGraphicObject, - const Quantity_Length X, - const Quantity_Length Y, - const Quantity_Length MajorRadius, - const Quantity_Length MinorRadius, - const Quantity_PlaneAngle anAngle) - : Graphic2d_Line(aGraphicObject) { - - myX = Standard_ShortReal(X); - myY = Standard_ShortReal(Y); - myMajorRadius = Standard_ShortReal(MajorRadius); - myMinorRadius = Standard_ShortReal(MinorRadius); - - if (myMajorRadius <= RealEpsilon ()) - Graphic2d_EllipsDefinitionError::Raise ("The major radius = 0."); - - if (myMinorRadius <= RealEpsilon ()) - Graphic2d_EllipsDefinitionError::Raise ("The minor radius = 0."); - - myAngle =Standard_ShortReal(anAngle); - - // Case of horizontal ellipse - if (Abs (anAngle) <= RealEpsilon ()) { - myMinX = myX - myMajorRadius; - myMaxX = myX + myMajorRadius; - myMinY = myY - myMinorRadius; - myMaxY = myY + myMinorRadius; - } - else { - Standard_ShortReal X1, Y1, X2, Y2; - Standard_Integer nbpoints = 360; // fobenselitmiter - Standard_ShortReal teta = Standard_ShortReal(2 * M_PI / nbpoints); - Standard_ShortReal x1 = Standard_ShortReal(myMajorRadius * Cos (myAngle)); - Standard_ShortReal y1 = Standard_ShortReal(myMajorRadius * Sin (myAngle)); - Standard_ShortReal x2, y2; - Standard_ShortReal costeta = Standard_ShortReal(Cos(teta)); - Standard_ShortReal sinteta = Standard_ShortReal(Sin(teta)); - - x2 = Standard_ShortReal(myMajorRadius * costeta * Cos (myAngle) - - myMinorRadius * sinteta * Sin (myAngle)); - y2 = Standard_ShortReal(myMajorRadius * costeta * Sin (myAngle) + - myMinorRadius * sinteta * Cos (myAngle)); - - X1 = myX + x1; Y1 = myY + y1; - X2 = myX + x2; Y2 = myY + y2; - - myMinX = ( X1 < X2 ? X1 : X2 ); - myMaxX = ( X1 < X2 ? X2 : X1 ); - myMinY = ( Y1 < Y2 ? Y1 : Y2 ); - myMaxY = ( Y1 < Y2 ? Y2 : Y1 ); - - nbpoints++; - for (Standard_Integer i=3; i<= nbpoints; i++) { - X2 = 2*x2*costeta - x1; - Y2 = 2*y2*costeta - y1; - x1 = x2; y1 = y2; x2 = X2; y2 = Y2; - X2 += myX; Y2 += myY; - myMinX = ( myMinX < X2 ? myMinX : X2 ); - myMaxX = ( myMaxX < X2 ? X2 : myMaxX ); - myMinY = ( myMinY < Y2 ? myMinY : Y2 ); - myMaxY = ( myMaxY < Y2 ? Y2 : myMaxY ); - } - } - myNumOfElem = 4; - myNumOfVert = 1; -} - -void Graphic2d_Ellips::Draw (const Handle(Graphic2d_Drawer)& aDrawer) { - -Standard_Boolean IsIn = Standard_False; - - if (! myGOPtr->IsTransformed ()) - IsIn = aDrawer->IsIn (myMinX,myMaxX,myMinY,myMaxY); - else { - Standard_ShortReal minx, miny, maxx, maxy; - MinMax(minx,maxx,miny,maxy); - IsIn = aDrawer->IsIn (minx,maxx,miny,maxy); - } - - if (IsIn) { - static TShort_Array1OfShortReal Xpoint(1,MAXPOINTS+1); - static TShort_Array1OfShortReal Ypoint(1,MAXPOINTS+1); - - DrawLineAttrib(aDrawer); - Standard_ShortReal Def; - Standard_ShortReal Coeff; - Aspect_TypeOfDeflection Type; - aDrawer->DrawPrecision(Def,Coeff,Type); - - if (Type == Aspect_TOD_RELATIVE) Def = myMajorRadius * Coeff; - - Standard_Real val; - if(myMajorRadius > Def) - val = Max( 0.0044 , Min (0.7854 , 2. * ACos(1.-Def/myMajorRadius))); - else - val = 0.7854; // = PI/4. - Standard_Integer nbpoints = Min(MAXPOINTS,Standard_Integer(2 * M_PI / val) + 2); - -// Standard_Integer nbpoints = Max ( 8 ,Standard_Integer ( myMajorRadius / Def)); - Standard_ShortReal teta = Standard_ShortReal(2 * M_PI / nbpoints); - Standard_ShortReal x1 = Standard_ShortReal(myMajorRadius *Cos (myAngle)), - y1 = Standard_ShortReal(myMajorRadius *Sin (myAngle)); - Standard_ShortReal x2,y2; - Standard_ShortReal cosin = Standard_ShortReal(Cos(teta)); - - x2 = Standard_ShortReal(myMajorRadius * Cos(teta) * Cos(myAngle) - - myMinorRadius * Sin(teta) * Sin(myAngle)); - y2 = Standard_ShortReal(myMajorRadius * Cos(teta) * Sin(myAngle) + - myMinorRadius * Sin(teta) * Cos(myAngle)); - - Xpoint(1) = myX + x1; Ypoint(1) = myY + y1; - Xpoint(2) = myX + x2; Ypoint(2) = myY + y2; - - nbpoints++; - for (Standard_Integer i=3; i<= nbpoints; i++) { - Xpoint(i) = 2*x2*cosin - x1; - Ypoint(i) = 2*y2*cosin - y1; - x1 = x2; y1 = y2; x2 = Xpoint(i); y2 = Ypoint(i); - Xpoint(i) += myX; Ypoint(i) += myY; - } - - if ( myGOPtr->IsTransformed() ) { - gp_GTrsf2d aTrsf = myGOPtr->Transform (); - Standard_Real A, B; - for (Standard_Integer j=1; j<= nbpoints; j++) { - A = Standard_Real (Xpoint(j)); - B = Standard_Real (Ypoint(j)); - aTrsf.Transforms (A, B); - Xpoint(j) = Standard_ShortReal (A); - Ypoint(j) = Standard_ShortReal (B); - } - } - - if (myTypeOfPolygonFilling == Graphic2d_TOPF_EMPTY) { - aDrawer->MapPolylineFromTo(Xpoint,Ypoint,nbpoints); - } else { - aDrawer->MapPolygonFromTo(Xpoint,Ypoint,nbpoints); - } - } - -} - -#ifdef G002 - -void Graphic2d_Ellips::DrawElement( const Handle(Graphic2d_Drawer)& aDrawer, - const Standard_Integer anIndex) { - - Standard_Boolean IsIn = Standard_False; - - if (! myGOPtr->IsTransformed ()) - IsIn = aDrawer->IsIn (myMinX,myMaxX,myMinY,myMaxY); - else { - Standard_ShortReal minx, miny, maxx, maxy; - MinMax(minx,maxx,miny,maxy); - IsIn = aDrawer->IsIn (minx,maxx,miny,maxy); - } - - if (IsIn) { - if ( anIndex > 0 && anIndex < 5 ) { - DrawLineAttrib(aDrawer); - Standard_ShortReal Xp=0., Yp=0.; - Standard_ShortReal tSin = Standard_ShortReal(Sin(myAngle)), - tCos = Standard_ShortReal(Cos(myAngle)); - if ( anIndex == 1 ) { - Xp = myX - myMinorRadius * tSin; - Yp = myY + myMinorRadius * tCos; - } else if ( anIndex == 2 ) { - Xp = myX + myMajorRadius * tCos; - Yp = myY + myMajorRadius * tSin; - } else if ( anIndex == 3 ) { - Xp = myX - myMajorRadius * tCos; - Yp = myY - myMajorRadius * tSin; - } else if ( anIndex == 4 ) { - Xp = myX + myMinorRadius * tSin; - Yp = myY - myMinorRadius * tCos; - } - - Standard_Real A, B, C, D; - Standard_ShortReal a = myX, b = myY, c = Xp, d = Yp; - if ( myGOPtr->IsTransformed() ) { - gp_GTrsf2d aTrsf = myGOPtr->Transform (); - A = Standard_Real(a); - B = Standard_Real(b); - C = Standard_Real(c); - D = Standard_Real(d); - aTrsf.Transforms (A, B); - aTrsf.Transforms (C, D); - a = Standard_ShortReal(A); - b = Standard_ShortReal(B); - c = Standard_ShortReal(C); - d = Standard_ShortReal(D); - } - - aDrawer->MapSegmentFromTo( a, b, c, d ); - } - } // end if IsIn - -} - -void Graphic2d_Ellips::DrawVertex( const Handle(Graphic2d_Drawer)& aDrawer, - const Standard_Integer anIndex) { - - Standard_Boolean IsIn = Standard_False; - - if ( ! myGOPtr->IsTransformed() ) - IsIn = aDrawer->IsIn( myMinX, myMaxX, myMinY, myMaxY ); - else { - Standard_ShortReal minx, miny, maxx, maxy; - MinMax( minx, maxx, miny, maxy ); - IsIn = aDrawer->IsIn( minx, maxx, miny, maxy ); - } - if ( IsIn ) { - if ( anIndex == 1 ) { - Standard_ShortReal X,Y; - DrawMarkerAttrib( aDrawer ); - if ( myGOPtr->IsTransformed() ) { - gp_GTrsf2d aTrsf = myGOPtr->Transform (); - Standard_Real A, B; - A = Standard_Real( myX ); - B = Standard_Real( myY ); - aTrsf.Transforms (A, B); - X = Standard_ShortReal( A ); - Y = Standard_ShortReal( B ); - } else { - X = Standard_ShortReal( myX ); - Y = Standard_ShortReal( myY ); - } - aDrawer->MapMarkerFromTo( VERTEXMARKER, X, Y, - DEFAULTMARKERSIZE,DEFAULTMARKERSIZE, 0.0 ); - } - } // end if IsIn is true -} - -#endif - -Standard_Boolean Graphic2d_Ellips::Pick (const Standard_ShortReal X, - const Standard_ShortReal Y, - const Standard_ShortReal aPrecision, - const Handle(Graphic2d_Drawer)& /*aDrawer*/) { - - Standard_ShortReal SRX = X, SRY = Y; - Standard_ShortReal maxRadius = - (myMinorRadius < myMajorRadius ? myMajorRadius : myMinorRadius); - - Standard_Boolean found = Standard_False; - if ( IsInMinMax (X, Y, aPrecision) ) { - if ( myGOPtr->IsTransformed() ) { - gp_GTrsf2d aTrsf = (myGOPtr->Transform ()).Inverted (); - Standard_Real RX = Standard_Real (SRX), RY = Standard_Real (SRY); - aTrsf.Transforms (RX, RY); - SRX = Standard_ShortReal (RX); SRY = Standard_ShortReal (RY); - } - #ifdef G002 - if ( Graphic2d_Primitive::IsOn( SRX, SRY, myX, myY, aPrecision) ) { - SetPickedIndex(-1); - found = Standard_True; - } else { - Standard_ShortReal tSin = Standard_ShortReal(Sin(myAngle)), - tCos = Standard_ShortReal(Cos(myAngle)); - Standard_ShortReal Xp = myX - myMinorRadius * tSin, - Yp = myY + myMinorRadius * tCos; - if ( IsOn( SRX, SRY, myX, myY, Xp, Yp, aPrecision) ) { - SetPickedIndex(1); - return Standard_True; - } else { - Xp = myX + myMajorRadius * tCos; - Yp = myY + myMajorRadius * tSin; - if ( IsOn( SRX, SRY, myX, myY, Xp, Yp, aPrecision) ) { - SetPickedIndex(2); - return Standard_True; - } else { - Xp = myX - myMajorRadius * tCos; - Yp = myY - myMajorRadius * tSin; - if ( IsOn( SRX, SRY, myX, myY, Xp, Yp, aPrecision) ) { - SetPickedIndex(3); - return Standard_True; - } else { - Xp = myX + myMinorRadius * tSin, - Yp = myY - myMinorRadius * tCos; - if ( IsOn( SRX, SRY, myX, myY, Xp, Yp, aPrecision) ) { - SetPickedIndex(4); - return Standard_True; - } - } - } - } - Standard_ShortReal xf1,yf1,xf2,yf2; //Sources. - Standard_ShortReal q = - Standard_ShortReal(Sqrt( Abs( myMajorRadius*myMajorRadius - myMinorRadius*myMinorRadius) )); - - Standard_ShortReal cos = Standard_ShortReal(Cos(myAngle)); - Standard_ShortReal sin = Standard_ShortReal(Sin(myAngle)); - - // Focus 1 and 2 calculated for the ellipse with centre - // at the origin of mark(0,0) - xf1 = q*cos; - yf1 = q*sin; - xf2 = -q*cos; - yf2 = -q*sin; - - Xp = SRX - myX; Yp = SRY - myY; - - Standard_ShortReal d1,d2; - d1 = Standard_ShortReal(Sqrt( (xf1 - Xp) * (xf1 - Xp) + (yf1 - Yp) * (yf1 - Yp))); - d2 = Standard_ShortReal(Sqrt( (xf2 - Xp) * (xf2 - Xp) + (yf2 - Yp) * (yf2 - Yp))); - if ( myTypeOfPolygonFilling != Graphic2d_TOPF_EMPTY ) - found = Abs (d1 + d2) < 2 * maxRadius; - if ( !found ) - found = Abs(d1 + d2 - 2 * maxRadius) < aPrecision; - if ( found ) - SetPickedIndex( 0 ); - } - #else - Standard_ShortReal xf1,yf1,xf2,yf2; //Sourses. - Standard_ShortReal Xp, Yp; - Standard_ShortReal q = - Sqrt( Abs( myMajorRadius*myMajorRadius - myMinorRadius*myMinorRadius) ); - - Standard_ShortReal cos = Cos (myAngle); - Standard_ShortReal sin = Sin (myAngle); - - // Focus 1 and 2 calculated for the ellipse with centre - // at the origin of mark(0,0) - xf1 = q*cos; - yf1 = q*sin; - xf2 = -q*cos; - yf2 = -q*sin; - - Xp = SRX - myX; Yp = SRY - myY; - - Standard_ShortReal d1,d2; - d1 = Sqrt ( (xf1 - Xp) * (xf1 - Xp) + (yf1 - Yp) * (yf1 - Yp)); - d2 = Sqrt ( (xf2 - Xp) * (xf2 - Xp) + (yf2 - Yp) * (yf2 - Yp)); - if ( myTypeOfPolygonFilling != Graphic2d_TOPF_EMPTY ) - found = Abs (d1 + d2) < 2 * maxRadius; - if ( !found ) - found = Abs(d1 + d2 - 2 * maxRadius) < aPrecision; - - #endif - - } // end if it's in MinMax - - return found; -} - -void Graphic2d_Ellips::Center(Quantity_Length& X,Quantity_Length& Y) const { - X = Quantity_Length( myX ); - Y = Quantity_Length( myY ); -} - -Quantity_Length Graphic2d_Ellips::MajorRadius() const { - return Quantity_Length( myMajorRadius ); -} - -Quantity_Length Graphic2d_Ellips::MinorRadius() const { - return Quantity_Length( myMinorRadius ); -} - -Quantity_PlaneAngle Graphic2d_Ellips::Angle() const { - return Quantity_PlaneAngle( myAngle ); -} - -void Graphic2d_Ellips::Save(Aspect_FStream& aFStream) const -{ - *aFStream << "Graphic2d_Ellips" << endl; - *aFStream << myX << ' ' << myY << endl; - *aFStream << myMajorRadius << ' ' << myMinorRadius << endl; - *aFStream << myAngle << endl; - Graphic2d_Line::Save(aFStream); -} - -void Graphic2d_Ellips::Retrieve(Aspect_IFStream& anIFStream, - const Handle(Graphic2d_GraphicObject)& aGraphicObject) -{ - Standard_ShortReal X, Y, radMaj, radMin, Ang; - - *anIFStream >> X >> Y; - *anIFStream >> radMaj >> radMin; - *anIFStream >> Ang; - Handle(Graphic2d_Ellips) - theEll = new Graphic2d_Ellips(aGraphicObject, X, Y, radMaj, radMin, Ang); - ((Handle (Graphic2d_Line))theEll)->Retrieve(anIFStream); -} - diff --git a/src/Graphic2d/Graphic2d_EllipsMarker.cdl b/src/Graphic2d/Graphic2d_EllipsMarker.cdl deleted file mode 100755 index 0e68e337c6..0000000000 --- a/src/Graphic2d/Graphic2d_EllipsMarker.cdl +++ /dev/null @@ -1,139 +0,0 @@ --- Created on: 1993-06-22 --- Created by: Jean Louis FRENKEL, Gerard GRAS --- Copyright (c) 1993-1999 Matra Datavision --- Copyright (c) 1999-2012 OPEN CASCADE SAS --- --- The content of this file is subject to the Open CASCADE Technology Public --- License Version 6.5 (the "License"). You may not use the content of this file --- except in compliance with the License. Please obtain a copy of the License --- at http://www.opencascade.org and read it completely before using this file. --- --- The Initial Developer of the Original Code is Open CASCADE S.A.S., having its --- main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. --- --- The Original Code and all software distributed under the License is --- distributed on an "AS IS" basis, without warranty of any kind, and the --- Initial Developer hereby disclaims all such warranties, including without --- limitation, any warranties of merchantability, fitness for a particular --- purpose or non-infringement. Please see the License for the specific terms --- and conditions governing the rights and limitations under the License. - - --- Modified: TCL G002A, 28-11-00, new section "inquire methods" - - -class EllipsMarker from Graphic2d inherits VectorialMarker from Graphic2d - - ---Version: - - ---Purpose: The primitive EllipsMarker - -- Every marker takes a reference point as an argument in - -- its constructor. CircleMarker and EllipsMarker take - -- another point as the center and PolylineMarker takes the - -- first point of its list as its origin. - -- The coordinates of the centre or origin point are offsets - -- with respect to the reference point. - - ---Keywords: Primitive, EllipsMarker - ---Warning: - ---References: - -uses - - Drawer from Graphic2d, - GraphicObject from Graphic2d, - PlaneAngle from Quantity, - Length from Quantity, - FStream from Aspect, - IFStream from Aspect - - -raises - - EllipsDefinitionError from Graphic2d - -is - ------------------------- - -- Category: Constructors - ------------------------- - - Create (aGraphicObject: GraphicObject from Graphic2d; - aXPosition, aYPosition: Length from Quantity; - X, Y: Length from Quantity; - MajorRadius, MinorRadius: Length from Quantity; - anAngle: PlaneAngle from Quantity) - returns mutable EllipsMarker from Graphic2d - ---Level: Public - ---Purpose: Creates an ellipse marker with a reference point. - -- The reference point is , . - -- The center is , . - -- Angles are measured counterclockwise with 0 radian - -- at 3 o'clock. - -- Warning: Raises EllipsDefinitionError if the - -- major radius or the minor radius is null. - raises EllipsDefinitionError from Graphic2d; - - -------------------------- - -- Category: Draw and Pick - -------------------------- - - Draw (me : mutable; aDrawer: Drawer from Graphic2d) - is static protected; - ---Level: Internal - ---Purpose: Draws the ellipse . - - DrawElement( me : mutable; aDrawer: Drawer from Graphic2d; - anIndex: Integer from Standard) - is redefined protected; - ---Level: Internal - ---Purpose: Draws element of the ellips marker . - - DrawVertex( me : mutable; aDrawer: Drawer from Graphic2d; - anIndex: Integer from Standard) - is redefined protected; - ---Level: Internal - ---Purpose: Draws vertex of the ellips marker . - - Pick (me : mutable; X, Y: ShortReal from Standard; - aPrecision: ShortReal from Standard; - aDrawer: Drawer from Graphic2d) - returns Boolean from Standard is static protected; - ---Level: Internal - ---Purpose: Returns Standard_True if the ellipse is picked, - -- Standard_False if not. - - -------------------------------------- - -- Category: Inquire methods - -------------------------------------- - - Center( me; X, Y: out Length from Quantity ); - ---Level: Public - ---Purpose: returns the coordinates of center - - MajorRadius( me ) returns Length from Quantity; - ---Level: Public - ---Purpose: returns the radius of the ellipse marker - - MinorRadius( me ) returns Length from Quantity; - ---Level: Public - ---Purpose: returns the radius of the ellipse marker - - Angle( me ) returns PlaneAngle from Quantity; - ---Level: Public - ---Purpose: returns the angle of the ellipse - - ---------------------------------------------------------------------- - - Save( me; aFStream: in out FStream from Aspect ) is virtual; - Retrieve(myclass; anIFStream: in out IFStream from Aspect; - aGraphicObject: GraphicObject from Graphic2d); - -fields - - myX : ShortReal from Standard; - myY : ShortReal from Standard; - myMajorRadius : ShortReal from Standard; - myMinorRadius : ShortReal from Standard; - myAngle : ShortReal from Standard; - -end EllipsMarker from Graphic2d; diff --git a/src/Graphic2d/Graphic2d_EllipsMarker.cxx b/src/Graphic2d/Graphic2d_EllipsMarker.cxx deleted file mode 100755 index 88c51fc7e1..0000000000 --- a/src/Graphic2d/Graphic2d_EllipsMarker.cxx +++ /dev/null @@ -1,307 +0,0 @@ -// Copyright (c) 1995-1999 Matra Datavision -// Copyright (c) 1999-2012 OPEN CASCADE SAS -// -// The content of this file is subject to the Open CASCADE Technology Public -// License Version 6.5 (the "License"). You may not use the content of this file -// except in compliance with the License. Please obtain a copy of the License -// at http://www.opencascade.org and read it completely before using this file. -// -// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its -// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. -// -// The Original Code and all software distributed under the License is -// distributed on an "AS IS" basis, without warranty of any kind, and the -// Initial Developer hereby disclaims all such warranties, including without -// limitation, any warranties of merchantability, fitness for a particular -// purpose or non-infringement. Please see the License for the specific terms -// and conditions governing the rights and limitations under the License. - -// Modified 23/02/98 : FMN ; Remplacement PI par Standard_PI - -#define G002 //TCL: Add new DrawElement(), DrawVertex() methods - -#define VERTEXMARKER 2 -#define DEFAULTMARKERSIZE 3.0 -#define MAXPOINTS 1023 -#define IMPLEMENTED - -#include -#include - -#define MAXPOINTS 1023 - -Graphic2d_EllipsMarker::Graphic2d_EllipsMarker ( - const Handle(Graphic2d_GraphicObject)& aGraphicObject, - const Quantity_Length aXPosition, - const Quantity_Length aYPosition, - const Standard_Real X, - const Standard_Real Y, - const Standard_Real MajorRadius, - const Standard_Real MinorRadius, - const Quantity_PlaneAngle anAngle) - - :Graphic2d_VectorialMarker (aGraphicObject, aXPosition, aYPosition), - myX (Standard_ShortReal (X)), - myY (Standard_ShortReal (Y)), - myMajorRadius (Standard_ShortReal (MajorRadius)), - myMinorRadius (Standard_ShortReal (MinorRadius)), - myAngle (Standard_ShortReal(anAngle)) { - - if (myMajorRadius <= RealEpsilon ()) - Graphic2d_EllipsDefinitionError::Raise ("The major radius = 0."); - - if (myMinorRadius <= RealEpsilon ()) - Graphic2d_EllipsDefinitionError::Raise ("The minor radius = 0."); - -#ifdef IMPLEMENTED - myMinX = myX + Standard_ShortReal (aXPosition) - myMajorRadius; - myMinY = myY + Standard_ShortReal (aYPosition) - myMinorRadius; - myMaxX = myX + Standard_ShortReal (aXPosition) + myMajorRadius; - myMaxY = myY + Standard_ShortReal (aYPosition) + myMinorRadius; -#else - myMinX = myX; - myMinY = myY; - myMaxX = myX; - myMaxY = myY; -#endif /* NOT IMPLEMENTED */ - - myNumOfElem = 4; - myNumOfVert = 1; -} - -void Graphic2d_EllipsMarker::Draw (const Handle(Graphic2d_Drawer)& aDrawer) { - - DrawLineAttrib(aDrawer); - - Standard_ShortReal xp,yp; - aDrawer->GetMapFromTo(Standard_ShortReal (XPosition ()), - Standard_ShortReal (YPosition ()),xp,yp); - xp+= myX; - yp+= myY; - - Standard_ShortReal Def; - Standard_ShortReal Coeff; - Aspect_TypeOfDeflection Type; - aDrawer->DrawPrecision(Def,Coeff,Type); - if (Type == Aspect_TOD_RELATIVE) Def = myMajorRadius * Coeff; - - Standard_Real val; - if(myMajorRadius > Def) - val = Max( 0.0044 , Min (0.7854 , 2. * ACos(1.-Def/myMajorRadius))); - else - val = 0.7854; // = PI/4. - Standard_Integer nbpoints = Min(MAXPOINTS,Standard_Integer(2 * M_PI / val)+2); - -// Standard_Integer nbpoints = Max ( 8 ,Standard_Integer ( myMajorRadius / Def)); - Standard_ShortReal teta = Standard_ShortReal(2 * M_PI / nbpoints); - Standard_ShortReal x1 = Standard_ShortReal( myMajorRadius *Cos (myAngle)), - y1 = Standard_ShortReal( myMajorRadius *Sin (myAngle)); - Standard_ShortReal x2,y2; - Standard_ShortReal cosin = Standard_ShortReal( Cos(teta) ); - - x2 = Standard_ShortReal( myMajorRadius * Cos(teta) * Cos(myAngle) - - myMinorRadius * Sin(teta) * Sin(myAngle)); - y2 = Standard_ShortReal( myMajorRadius * Cos(teta) * Sin(myAngle) + - myMinorRadius * Sin(teta) * Cos(myAngle)); - - TShort_Array1OfShortReal X(1,nbpoints+1); - TShort_Array1OfShortReal Y(1,nbpoints+1); - X(1) = x1; Y(1) = y1; X(2) = x2; Y(2) = y2; - for (Standard_Integer i=3; i<= nbpoints+1; i++) { - X(i) = 2*x2*cosin - x1; - Y(i) = 2*y2*cosin - y1; - x1 = x2; y1 = y2; x2 = X(i); y2 = Y(i); - } - - if (myTypeOfPolygonFilling == Graphic2d_TOPF_EMPTY) { - aDrawer->DrawPolyline(xp,yp,X,Y); - } - else { - aDrawer->DrawPolygon(xp,yp,X,Y); - } - -} - -#ifdef G002 - -void Graphic2d_EllipsMarker::DrawElement( const Handle(Graphic2d_Drawer)& aDrawer, - const Standard_Integer anIndex) { - - if ( anIndex > 0 && anIndex < 5) { - DrawLineAttrib(aDrawer); - - Standard_ShortReal xp=0.,yp=0., xpp=0., ypp=0.; - aDrawer->GetMapFromTo( Standard_ShortReal(XPosition() ), - Standard_ShortReal(YPosition() ), xp, yp ); - xp += myX; - yp += myY; - - Standard_ShortReal tSin = Standard_ShortReal( Sin(myAngle) ), - tCos = Standard_ShortReal( Cos(myAngle) ); - if ( anIndex == 1 ) { - xpp = Standard_ShortReal( xp - myMinorRadius * tSin ); - ypp = Standard_ShortReal( yp + myMinorRadius * tCos ); - } else if ( anIndex == 2 ) { - xpp = Standard_ShortReal( xp + myMajorRadius * tCos ); - ypp = Standard_ShortReal( yp + myMajorRadius * tSin ); - } else if ( anIndex == 3 ) { - xpp = Standard_ShortReal( xp - myMajorRadius * tCos ); - ypp = Standard_ShortReal( yp - myMajorRadius * tSin ); - } else if ( anIndex == 4 ) { - xpp = Standard_ShortReal( xp + myMinorRadius * tSin ); - ypp = Standard_ShortReal( yp - myMinorRadius * tCos ); - } - - aDrawer->DrawSegment( xp, yp, xpp, ypp ); - } - -} - -void Graphic2d_EllipsMarker::DrawVertex( const Handle(Graphic2d_Drawer)& aDrawer, - const Standard_Integer anIndex) { - if ( anIndex == 1 ) { - DrawMarkerAttrib( aDrawer ); - Standard_ShortReal x = aDrawer->ConvertMapToFrom(myX) + myXPosition; - Standard_ShortReal y = aDrawer->ConvertMapToFrom(myY) + myYPosition; - aDrawer->MapMarkerFromTo( VERTEXMARKER, x, y, DEFAULTMARKERSIZE,DEFAULTMARKERSIZE, 0.0 ); - } -} - -#endif - -Standard_Boolean Graphic2d_EllipsMarker::Pick (const Standard_ShortReal X, - const Standard_ShortReal Y, - const Standard_ShortReal aPrecision, - const Handle(Graphic2d_Drawer)& aDrawer) -{ - Standard_ShortReal xf1,yf1,xf2,yf2; //Les foyers. - Standard_ShortReal Xp, Yp; - Standard_ShortReal SRX = X, SRY = Y; - - Standard_ShortReal Majord = aDrawer->ConvertMapToFrom(myMajorRadius); - Standard_ShortReal Minord = aDrawer->ConvertMapToFrom(myMinorRadius); - Standard_ShortReal x = aDrawer->ConvertMapToFrom(myX) + myXPosition; - Standard_ShortReal y = aDrawer->ConvertMapToFrom(myY) + myYPosition; - Standard_ShortReal maxord = (Minord < Majord ? Majord : Minord); - Standard_Boolean found = Standard_False; - - Standard_ShortReal q = Standard_ShortReal( - Sqrt(Abs (Majord * Majord - Minord * Minord))); - - Standard_ShortReal cos = Standard_ShortReal( Cos(myAngle) ); - Standard_ShortReal sin = Standard_ShortReal( Sin(myAngle) ); - - //Focus 1 and 2 calcules pour l' ellipse dont le centre - // est ramene a l' origine du repere(0,0) - xf1 = Standard_ShortReal( q * cos ); - yf1 = Standard_ShortReal( q * sin ); - xf2 = Standard_ShortReal( - q * cos ); - yf2 = Standard_ShortReal( - q * sin ); - - if (myGOPtr->IsTransformed ()) { - gp_GTrsf2d aTrsf = (myGOPtr->Transform ()).Inverted (); - Standard_Real RX = Standard_Real (SRX), RY = Standard_Real (SRY); - aTrsf.Transforms (RX, RY); - SRX = Standard_ShortReal (RX); SRY = Standard_ShortReal (RY); - } - - #ifdef G002 - if ( Graphic2d_Primitive::IsOn( SRX, SRY, x, y, aPrecision) ) { - SetPickedIndex(-1); - return Standard_True; - } else { - Standard_ShortReal tSin = Standard_ShortReal( Sin(myAngle) ), - tCos = Standard_ShortReal( Cos(myAngle) ); - Standard_ShortReal xpp = Standard_ShortReal( x - Minord * tSin ), - ypp = Standard_ShortReal( y + Minord * tCos ); - if ( IsOn( SRX, SRY, x, y, xpp, ypp, aPrecision) ) { - SetPickedIndex(1); - return Standard_True; - } else { - xpp = x + Majord * tCos; - ypp = y + Majord * tSin; - if ( IsOn( SRX, SRY, x, y, xpp, ypp, aPrecision) ) { - SetPickedIndex(2); - return Standard_True; - } else { - xpp = x - Majord * tCos; - ypp = y - Majord * tSin; - if ( IsOn( SRX, SRY, x, y, xpp, ypp, aPrecision) ) { - SetPickedIndex(3); - return Standard_True; - } else { - xpp = x + Minord * tSin, - ypp = y - Minord * tCos; - if ( IsOn( SRX, SRY, x, y, xpp, ypp, aPrecision) ) { - SetPickedIndex(4); - return Standard_True; - } - } - } - } - } -#endif - - Xp = SRX - x; Yp = SRY - y; - - Standard_ShortReal d1,d2; - d1 = Standard_ShortReal( - Sqrt( (xf1 - Xp) * (xf1 - Xp) + (yf1 - Yp) * (yf1 - Yp))); - d2 = Standard_ShortReal( - Sqrt( (xf2 - Xp) * (xf2 - Xp) + (yf2 - Yp) * (yf2 - Yp))); - - if (myTypeOfPolygonFilling != Graphic2d_TOPF_EMPTY) - found = Abs (d1 + d2) < 2 * maxord; - if (!found) { - found = Abs (d1 + d2 - 2 * maxord) < aPrecision; - } - - return found; -} - -void Graphic2d_EllipsMarker::Center(Quantity_Length& X,Quantity_Length& Y) const { - - X = Quantity_Length( myX ); - Y = Quantity_Length( myY ); -} - -Quantity_Length Graphic2d_EllipsMarker::MajorRadius() const { - - return Quantity_Length( myMajorRadius ); -} - -Quantity_Length Graphic2d_EllipsMarker::MinorRadius() const { - - return Quantity_Length( myMinorRadius ); -} - -Quantity_PlaneAngle Graphic2d_EllipsMarker::Angle() const { - - return Quantity_PlaneAngle( myAngle ); -} - -void Graphic2d_EllipsMarker::Save(Aspect_FStream& aFStream) const -{ - *aFStream << "Graphic2d_EllipsMarker" << endl; - *aFStream << myXPosition << ' ' << myYPosition << endl; - *aFStream << myX << ' ' << myY << endl; - *aFStream << myMajorRadius << ' ' << myMinorRadius << endl; - *aFStream << myAngle << endl; - Graphic2d_Line::Save(aFStream); -} - -void Graphic2d_EllipsMarker::Retrieve(Aspect_IFStream& anIFStream, - const Handle(Graphic2d_GraphicObject)& aGraphicObject) -{ - Standard_ShortReal XPos, YPos, X, Y, radMaj, radMin, Ang; - - *anIFStream >> XPos >> YPos; - *anIFStream >> X >> Y; - *anIFStream >> radMaj >> radMin; - *anIFStream >> Ang; - Handle(Graphic2d_EllipsMarker) - theEllM = new Graphic2d_EllipsMarker(aGraphicObject, XPos, YPos, X, Y, - radMaj, radMin, Ang); - ((Handle (Graphic2d_Line))theEllM)->Retrieve(anIFStream); -} - diff --git a/src/Graphic2d/Graphic2d_FramedText.cdl b/src/Graphic2d/Graphic2d_FramedText.cdl deleted file mode 100755 index 4a6400a116..0000000000 --- a/src/Graphic2d/Graphic2d_FramedText.cdl +++ /dev/null @@ -1,176 +0,0 @@ --- Created on: 1993-06-22 --- Created by: Jean Louis FRENKEL, Gerard GRAS --- Copyright (c) 1993-1999 Matra Datavision --- Copyright (c) 1999-2012 OPEN CASCADE SAS --- --- The content of this file is subject to the Open CASCADE Technology Public --- License Version 6.5 (the "License"). You may not use the content of this file --- except in compliance with the License. Please obtain a copy of the License --- at http://www.opencascade.org and read it completely before using this file. --- --- The Initial Developer of the Original Code is Open CASCADE S.A.S., having its --- main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. --- --- The Original Code and all software distributed under the License is --- distributed on an "AS IS" basis, without warranty of any kind, and the --- Initial Developer hereby disclaims all such warranties, including without --- limitation, any warranties of merchantability, fitness for a particular --- purpose or non-infringement. Please see the License for the specific terms --- and conditions governing the rights and limitations under the License. - - - - -class FramedText from Graphic2d inherits Text from Graphic2d - - ---Purpose: The class defines the primitive FramedText - -uses - Drawer from Graphic2d, - GraphicObject from Graphic2d, - PlaneAngle from Quantity, - Length from Quantity, - Ratio from Quantity, - Factor from Quantity, - ExtendedString from TCollection, - TypeOfText from Aspect, - FStream from Aspect, - IFStream from Aspect - - -is - ------------------------- - -- Category: Constructors - ------------------------- - - Create (aGraphicObject: GraphicObject from Graphic2d; - aText: ExtendedString from TCollection; - X, Y: Real from Standard; - anAngle: PlaneAngle from Quantity = 0.0; - aMargin: Ratio from Quantity = 0.1; - aType: TypeOfText from Aspect = Aspect_TOT_SOLID; - aScale: Factor from Quantity = 1.0) - returns mutable FramedText from Graphic2d; - ---Level: Public - ---Purpose: Creates a framed text in a graphic object - -- The text is . - -- The reference point is , . - -- The orientation angle is . - -- The margin ratio is ,defines the proportional - -- margin between the text height and the outline frame. - -- The type of text is and must be one of : - -- Aspect_TOT_SOLID, - -- Aspect_TOT_OUTLINE, - -- The scale factor apply to the original font size, - -- Angles are measured counterclockwise with 0 radian - -- at 3 o'clock. - -- - -- Warning: a text can be orientable,slantable,zoomable or outlinable - -- only when this options are enable regardless of the graphic driver. - -- i.e: Xw driver does not,but Xdps or PS driver does. - ---Category: Constructors - - --------------------------------------------------- - -- Category: Methods to modify the class definition - --------------------------------------------------- - - SetFrameColorIndex (me:mutable; anIndex: Integer from Standard = 0) - is static; - ---Level: Public - ---Purpose: Sets the color index for the frame of the text . - -- default color is 0 (the same color that the text). - - SetFrameWidthIndex (me:mutable; anIndex: Integer from Standard = 0) - is static; - ---Level: Public - ---Purpose: Sets the width index for the frame of the text . - -- default width is 0 (1 pixel out line frame is drawn). - - Fit (me:mutable; aWidth,aHeight: Length from Quantity; - Adjust: Boolean from Standard = Standard_True; - Expand: Boolean from Standard = Standard_True) - returns Boolean from Standard is redefined; - ---Level: Public - ---Purpose: Defines the size of the text according to a bounding - -- box. If Adjust corresponds to TRUE, text positioning - -- depends on the text origin and bottom line. The - -- method returns Standard_True if the current Driver is - -- compatible with the text size. - -- Warning - -- Fit computation is executed only if the dimension is > 0. - - Trunc (me:mutable; aWidth: Length from Quantity) - returns Boolean from Standard is redefined; - ---Level: Public - ---Purpose: Trunc the text when the Width of the text is greater - -- that the defined Width Max, - -- and returns Standard_True if the current Driver used is - -- enable to trunc the text size. - - -------------------------- - -- Category: Draw and Pick - -------------------------- - - Draw (me : mutable; aDrawer: Drawer from Graphic2d) - is redefined protected; - ---Level: Internal - ---Purpose: Draws the framed text . - - Pick (me : mutable; X, Y: ShortReal from Standard; - aPrecision: ShortReal from Standard; - aDrawer: Drawer from Graphic2d) - returns Boolean from Standard - is redefined protected; - ---Level: Internal - ---Purpose: Returns Standard_True if the framed text is picked, - -- Standard_False if not. - - ---------------------------- - -- Category: Inquire methods - ---------------------------- - - TextSize (me; aWidth,aHeight,anXoffset,anYoffset: out Length from Quantity) - returns Boolean from Standard is redefined; - ---Level: Public - ---Purpose: Returns Standard_True if the current Driver used is enabled - -- to get the right size and framed text offsets in the - -- world size parameter ,,, - -- depending of the attributes of the text and the current scale - -- of the view. - -- NOTE that the text offsets defines the relative position of the - -- of the text string origin from the lower left corner of the framed text - -- boundary limits. - ---Category: Text management - - Margin (me) returns Ratio from Quantity is static; - ---Level: Public - ---Purpose: Returns the text margin. - - FrameColorIndex (me) returns Integer from Standard is static; - ---Level: Public - ---Purpose: Returns the text frame color index. - - FrameWidthIndex (me) returns Integer from Standard is static; - ---Level: Public - ---Purpose: Returns the text frame width index. - - ---------------------------- - -- Category: Private methods - ---------------------------- - - ComputeMinMax (me : mutable) - returns Boolean from Standard is redefined private; - ---Level: Internal - ---Purpose: Computes the MinMax of the text if possible. - - ---------------------------------------------------------------------- - - Save( me; aFStream: in out FStream from Aspect ) is virtual; --- Retrieve( myclass; anIFStream: in out IFStream from Aspect ); - -fields - myFrameColorIndex: Integer from Standard; - myFrameWidthIndex: Integer from Standard; - myMargin: ShortReal from Standard; - -end FramedText from Graphic2d; diff --git a/src/Graphic2d/Graphic2d_FramedText.cxx b/src/Graphic2d/Graphic2d_FramedText.cxx deleted file mode 100755 index 84909e0884..0000000000 --- a/src/Graphic2d/Graphic2d_FramedText.cxx +++ /dev/null @@ -1,431 +0,0 @@ -// Copyright (c) 1995-1999 Matra Datavision -// Copyright (c) 1999-2012 OPEN CASCADE SAS -// -// The content of this file is subject to the Open CASCADE Technology Public -// License Version 6.5 (the "License"). You may not use the content of this file -// except in compliance with the License. Please obtain a copy of the License -// at http://www.opencascade.org and read it completely before using this file. -// -// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its -// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. -// -// The Original Code and all software distributed under the License is -// distributed on an "AS IS" basis, without warranty of any kind, and the -// Initial Developer hereby disclaims all such warranties, including without -// limitation, any warranties of merchantability, fitness for a particular -// purpose or non-infringement. Please see the License for the specific terms -// and conditions governing the rights and limitations under the License. - -// S3824 10/06/98 : GG ; -// 1) Method "Fit" includes optional argument -// "Expand" allowing to avoid adjusting text width -// when it is less then size of FIT. -// 2) Method "Trunc" allows trunkating the text to the -// exact size. - -#define PRO14304 //GG_160698 - -#define PERF //GG_200898 -// The MinMax are now computed at the right time and no more -// soon an attribute has change -// (see the redefined method ComputeMinMax()). - -#define BUC60583 //GG_300999 Enable to compute correctly a -// Mirror transformation - -#include -#include - -#include - -Graphic2d_FramedText::Graphic2d_FramedText - (const Handle(Graphic2d_GraphicObject)& aGraphicObject, - const TCollection_ExtendedString& aText, - const Standard_Real X, const Standard_Real Y, - const Quantity_PlaneAngle anAngle, - const Quantity_Ratio aMargin, - const Aspect_TypeOfText aType, - const Quantity_Factor aScale) - : Graphic2d_Text (aGraphicObject,aText,X,Y,anAngle,aType,aScale), - myMargin(Standard_ShortReal( aMargin )) { - - SetFrameColorIndex(); - SetFrameWidthIndex(); - -#ifndef PERF - ComputeMinMax(); -#endif -} - -void Graphic2d_FramedText::SetFrameColorIndex (const Standard_Integer anIndex) { - - myFrameColorIndex = anIndex; -} - -void Graphic2d_FramedText::SetFrameWidthIndex (const Standard_Integer anIndex) { - myFrameWidthIndex = anIndex; - -} - -void Graphic2d_FramedText::Draw (const Handle(Graphic2d_Drawer)& aDrawer) { -Standard_Boolean IsIn = Standard_False; -Standard_ShortReal hscale = (myIsZoomable) ? - Standard_ShortReal( myHScale * aDrawer->Scale() ) - : Standard_ShortReal( myHScale ); -Standard_ShortReal wscale = (myIsZoomable) ? - Standard_ShortReal( myWScale * aDrawer->Scale() ) - : Standard_ShortReal( myWScale ); -Standard_ShortReal ox = aDrawer->ConvertMapToFrom(myDeltax); -Standard_ShortReal oy = aDrawer->ConvertMapToFrom(myDeltay); - -#ifdef PERF - if( (myMaxX < myMinX) || (myMaxY < myMinY) ) { - if( !ComputeMinMax() ) return; - } -#else - if( myResetFlag ) { - ComputeMinMax(); - } -#endif - - if (! myGOPtr->IsTransformed ()) { - IsIn = aDrawer->IsIn (myMinX+ox,myMaxX+ox,myMinY+oy,myMaxY+oy); - if (IsIn) { - aDrawer->SetFramedTextAttrib(myColorIndex,myFrameColorIndex, - myFrameWidthIndex,myFontIndex, - mySlant,hscale,wscale,myIsUnderlined); - Standard_ShortReal dx = myDx,dy = myDy; - if( myAngle != 0. ) { - Standard_ShortReal cosa = Standard_ShortReal( Cos(myAngle) ); - Standard_ShortReal sina = Standard_ShortReal( Sin(myAngle) ); - - dx = XROTATE(myDx,myDy) ; - dy = YROTATE(myDx,myDy) ; - } - aDrawer->MapFramedTextFromTo(myText,myX+dx,myY+dy,myAngle,myMargin, - myDeltax,myDeltay,myType); - } - } else { - Standard_ShortReal minx,miny,maxx,maxy; - gp_GTrsf2d aTrsf = myGOPtr->Transform (); - MinMax(minx,maxx,miny,maxy); - IsIn = aDrawer->IsIn (minx+ox,maxx+ox,miny+oy,maxy+oy); - if (IsIn) { - Standard_Real A = Standard_Real (myX); - Standard_Real B = Standard_Real (myY); - Standard_Real C = Standard_Real (myAngle); - Standard_Real cosa = Cos (C); - Standard_Real sina = Sin (C); - aTrsf.Transforms (A, B); - - Standard_ShortReal a = Standard_ShortReal (A); - Standard_ShortReal b = Standard_ShortReal (B); -#ifdef BUC60583 - aTrsf.Transforms (cosa, sina); - A = B = 0.; - aTrsf.Transforms (A, B); - cosa -= A; sina -= B; - if( aTrsf.IsNegative() ) hscale = - hscale; -#else - // To calculate new aperture angles - // the calculation is done on the trigonometric circle - // and taken into account in case of translation. - aTrsf.SetValue (1, 3, 0.0); - aTrsf.SetValue (2, 3, 0.0); - aTrsf.Transforms (cosa, sina); -#endif - Standard_ShortReal angle = Standard_ShortReal (atan2(sina,cosa)); - if( myIsZoomable ) { - hscale *= Standard_ShortReal(Sqrt(cosa*cosa + sina*sina)); - wscale *= Standard_ShortReal (Sqrt(cosa*cosa + sina*sina)); - } - - aDrawer->SetFramedTextAttrib(myColorIndex,myFrameColorIndex, - myFrameWidthIndex,myFontIndex, - mySlant,hscale,wscale,myIsUnderlined); - Standard_ShortReal dx = myDx,dy = myDy; - if( angle != 0. ) { - dx = Standard_ShortReal( XROTATE(myDx,myDy) ); - dy = Standard_ShortReal( YROTATE(myDx,myDy) ); - } - a += dx; b += dy; - aDrawer->MapFramedTextFromTo(myText,a,b,angle,myMargin, - myDeltax,myDeltay,myType); - } - } -} - - -Standard_Boolean Graphic2d_FramedText::Pick (const Standard_ShortReal X, - const Standard_ShortReal Y, - const Standard_ShortReal aPrecision, - const Handle(Graphic2d_Drawer)& aDrawer) -{ -Standard_Boolean theStatus = Standard_False; -Standard_ShortReal width,height,xoffset,yoffset,mwidth,mheight; -Standard_ShortReal hscale = (myIsZoomable) ? - Standard_ShortReal( myHScale * aDrawer->Scale() ) - : Standard_ShortReal( myHScale ); -Standard_ShortReal wscale = (myIsZoomable) ? - Standard_ShortReal( myWScale * aDrawer->Scale() ) - : Standard_ShortReal( myWScale ); - -Standard_ShortReal TX = X, TY = Y; -Standard_ShortReal ox = aDrawer->ConvertMapToFrom(myDeltax); -Standard_ShortReal oy = aDrawer->ConvertMapToFrom(myDeltay); - - if (IsInMinMax (X-ox, Y-oy, aPrecision)) { - if (myGOPtr->IsTransformed ()) { - gp_GTrsf2d aTrsf = (myGOPtr->Transform ()).Inverted (); - Standard_Real RX = Standard_Real (X), RY = Standard_Real (Y); - aTrsf.Transforms (RX, RY); - TX = Standard_ShortReal (RX); TY = Standard_ShortReal (RY); - } - aDrawer->SetTextAttrib(myColorIndex,myFontIndex, - mySlant,hscale,wscale,myIsUnderlined); - if( !aDrawer->GetTextSize(myText,width,height,xoffset,yoffset) ) { - mwidth = mheight = width = height = xoffset = yoffset = 0.; - } else { - mwidth = mheight = height*myMargin; - } - Standard_ShortReal cosa = Standard_ShortReal( Cos(-myAngle) ); - Standard_ShortReal sina = Standard_ShortReal( Sin(-myAngle) ); - Standard_ShortReal dx = TX-(myX+ox+myDx); - Standard_ShortReal dy = TY-(myY+oy+myDy); - Standard_ShortReal x = XROTATE(dx,dy); - Standard_ShortReal y = YROTATE(dx,dy); - - theStatus = (x >= -mwidth + xoffset - aPrecision) - && (x <= width + mwidth + xoffset + aPrecision) - && (y >= - mheight - yoffset - aPrecision) - && (y <= height + mheight - yoffset + aPrecision); - } - - return theStatus; -} - -Standard_Boolean Graphic2d_FramedText::TextSize ( Quantity_Length &aWidth, - Quantity_Length &aHeight, - Quantity_Length &anXoffset, - Quantity_Length &anYoffset) const { -Handle(Graphic2d_Drawer) aDrawer = Drawer(); - - if( !aDrawer.IsNull() && aDrawer->IsWindowDriver() ) { - Standard_ShortReal hscale = (myIsZoomable) ? - Standard_ShortReal( myHScale * aDrawer->Scale() ) - : Standard_ShortReal( myHScale ); - Standard_ShortReal wscale = (myIsZoomable) ? - Standard_ShortReal( myWScale * aDrawer->Scale() ) - : Standard_ShortReal( myWScale ); - Standard_ShortReal width,height,xoffset,yoffset; - aDrawer->SetTextAttrib(myColorIndex,myFontIndex, - mySlant,hscale,wscale,myIsUnderlined); - - aDrawer->GetTextSize(myText,width,height,xoffset,yoffset); - aWidth = width + 2.*height*myMargin; - aHeight = height + 2.*height*myMargin; - anXoffset = xoffset - height*myMargin; - anYoffset = yoffset + height*myMargin; - return Standard_True; - } else { - aWidth = aHeight = anXoffset = anYoffset = 0.; - return Standard_False; - } - -} - -Standard_Integer Graphic2d_FramedText::FrameColorIndex() const { - - return myFrameColorIndex; -} - -Standard_Integer Graphic2d_FramedText::FrameWidthIndex() const { - - return myFrameWidthIndex; -} - -Quantity_Ratio Graphic2d_FramedText::Margin() const { - - return Quantity_Ratio(myMargin); -} - -Standard_Boolean Graphic2d_FramedText::Fit(const Quantity_Length aWidth,const Quantity_Length aHeight,const Standard_Boolean Adjust,const Standard_Boolean Expand) { -Quantity_Length twidth,theight,xoffset,yoffset; -Standard_ShortReal wscale,hscale; -Standard_Boolean status; - - myAdjustFlag = Adjust; - if(( status = TextSize(twidth,theight,xoffset,yoffset) )) { - wscale = Standard_ShortReal( aWidth/twidth ); - if( wscale > 0. ) { - if( Expand || (twidth > aWidth) ) myWScale *= wscale; - } - hscale = Standard_ShortReal( aHeight/theight ); - if( hscale > 0. ) myHScale *= hscale; -#ifdef PERF - myMinX = myMinY = ShortRealLast (); - myMaxX = myMaxY = ShortRealFirst (); -#else - myResetFlag = Standard_True; - ComputeMinMax(); -#endif - } - - return status; -} - -Standard_Boolean Graphic2d_FramedText::Trunc(const Quantity_Length aWidth) { -Quantity_Length twidth,theight,txoffset,tyoffset; -//Standard_ShortReal wscale,hscale; -Standard_Boolean status; - - if(( status = TextSize(twidth,theight,txoffset,tyoffset) )) { - Standard_Integer l = myText.Length(); - while( (l > 1) && (twidth > aWidth) ) { - --l; - myText.Split(l); - TextSize(twidth,theight,txoffset,tyoffset); - } -#ifdef PERF - myMinX = myMinY = ShortRealLast (); - myMaxX = myMaxY = ShortRealFirst (); -#else - myResetFlag = Standard_True; - this->ComputeMinMax(); -#endif - } - - return status; -} - -Standard_Boolean Graphic2d_FramedText::ComputeMinMax() { -Handle(Graphic2d_Drawer) aDrawer = Drawer(); -Standard_Boolean status = Standard_False; - - if( !aDrawer.IsNull() && aDrawer->IsWindowDriver() ) { - Standard_ShortReal hscale = - (myIsZoomable) ? - Standard_ShortReal( myHScale * aDrawer->Scale() ) - : Standard_ShortReal( myHScale ); - Standard_ShortReal wscale = - (myIsZoomable) ? - Standard_ShortReal( myWScale * aDrawer->Scale() ) - : Standard_ShortReal( myWScale ); - Standard_ShortReal width,height,xoffset,yoffset; - aDrawer->SetTextAttrib(myColorIndex,myFontIndex, - mySlant,hscale,wscale,myIsUnderlined); - if(( status = aDrawer->GetTextSize(myText,width,height,xoffset,yoffset) )) { - Standard_ShortReal dxm,dym; -#ifndef PERF - myResetFlag = Standard_False; -#endif - dxm = dym = height*myMargin ; - - switch( myAlignment ) { - case Graphic2d_TOA_LEFT: - myDx = myDy = 0.; - break; - case Graphic2d_TOA_RIGHT: - myDx = -width; myDy = 0.; - break; - case Graphic2d_TOA_CENTER: - myDx = Standard_ShortReal( -width/2. ); myDy = 0.; - break; - case Graphic2d_TOA_TOPLEFT: - myDx = 0.; myDy = yoffset-height; - break; - case Graphic2d_TOA_TOPRIGHT: - myDx = -width; myDy = yoffset-height; - break; - case Graphic2d_TOA_TOPCENTER: - myDx = Standard_ShortReal( -width/2.); myDy = yoffset-height; - break; - case Graphic2d_TOA_MEDIUMLEFT: - myDx = 0.; myDy = Standard_ShortReal( (yoffset-height)/2. ); - break; - case Graphic2d_TOA_MEDIUMRIGHT: - myDx = -width; myDy = Standard_ShortReal( (yoffset-height)/2. ); - break; - case Graphic2d_TOA_MEDIUMCENTER: - myDx = Standard_ShortReal( -width/2.); - myDy = Standard_ShortReal( (yoffset-height)/2. ); - break; - case Graphic2d_TOA_BOTTOMLEFT: - myDx = 0.; myDy = yoffset; - break; - case Graphic2d_TOA_BOTTOMRIGHT: - myDx = -width; myDy = yoffset; - break; - case Graphic2d_TOA_BOTTOMCENTER: - myDx = Standard_ShortReal( -width/2. ); myDy = yoffset; - break; - } - if( myAdjustFlag ) { - myDx += dxm - xoffset; myDy += dym + yoffset; - } - Standard_ShortReal xmin = myDx - dxm + xoffset; - Standard_ShortReal ymin = myDy - dym - yoffset; - Standard_ShortReal xmax = xmin + width + 2*dxm; - Standard_ShortReal ymax = ymin + height + 2*dym; - - myMinX = myMinY = ShortRealLast(); - myMaxX = myMaxY = ShortRealFirst(); - if( myAngle != 0. ) { - Standard_ShortReal cosa = Standard_ShortReal( Cos(myAngle) ); - Standard_ShortReal sina = Standard_ShortReal( Sin(myAngle) ); - Standard_ShortReal dx,dy; - - dx = XROTATE(xmin,ymin) ; - dy = YROTATE(xmin,ymin) ; - myMinX = Min(myMinX,myX+dx) ; - myMinY = Min(myMinY,myY+dy) ; - myMaxX = Max(myMaxX,myX+dx) ; - myMaxY = Max(myMaxY,myY+dy) ; - - dx = XROTATE(xmin,ymax) ; - dy = YROTATE(xmin,ymax) ; - myMinX = Min(myMinX,myX+dx) ; - myMinY = Min(myMinY,myY+dy) ; - myMaxX = Max(myMaxX,myX+dx) ; - myMaxY = Max(myMaxY,myY+dy) ; - - dx = XROTATE(xmax,ymax) ; - dy = YROTATE(xmax,ymax) ; - myMinX = Min(myMinX,myX+dx) ; - myMinY = Min(myMinY,myY+dy) ; - myMaxX = Max(myMaxX,myX+dx) ; - myMaxY = Max(myMaxY,myY+dy) ; - - dx = XROTATE(xmax,ymin) ; - dy = YROTATE(xmax,ymin) ; - myMinX = Min(myMinX,myX+dx) ; - myMinY = Min(myMinY,myY+dy) ; - myMaxX = Max(myMaxX,myX+dx) ; - myMaxY = Max(myMaxY,myY+dy) ; - } else { -#ifdef PRO14304 - myMinX = Min(myMinX,myX+xmin) ; - myMinY = Min(myMinY,myY+ymin) ; - myMaxX = Max(myMaxX,myX+xmax) ; - myMaxY = Max(myMaxY,myY+ymax) ; -#else - myMinX = Min(myMinX,xmin) ; - myMinY = Min(myMinY,ymin) ; - myMaxX = Max(myMaxX,xmax) ; - myMaxY = Max(myMaxY,ymax) ; -#endif - } - } - } -#ifdef PERF - else { - cout << "*Graphic2d_FramedText::ComputeMinMax() returns wrong values*" << endl; - } -#endif - - return status; -} - -void Graphic2d_FramedText::Save(Aspect_FStream& aFStream) const -{ -} diff --git a/src/Graphic2d/Graphic2d_GraphicObject.cdl b/src/Graphic2d/Graphic2d_GraphicObject.cdl deleted file mode 100755 index 6a179075f8..0000000000 --- a/src/Graphic2d/Graphic2d_GraphicObject.cdl +++ /dev/null @@ -1,526 +0,0 @@ --- Created on: 1993-06-22 --- Created by: s: Jean Louis FRENKEL, Gerard GRAS --- Copyright (c) 1993-1999 Matra Datavision --- Copyright (c) 1999-2012 OPEN CASCADE SAS --- --- The content of this file is subject to the Open CASCADE Technology Public --- License Version 6.5 (the "License"). You may not use the content of this file --- except in compliance with the License. Please obtain a copy of the License --- at http://www.opencascade.org and read it completely before using this file. --- --- The Initial Developer of the Original Code is Open CASCADE S.A.S., having its --- main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. --- --- The Original Code and all software distributed under the License is --- distributed on an "AS IS" basis, without warranty of any kind, and the --- Initial Developer hereby disclaims all such warranties, including without --- limitation, any warranties of merchantability, fitness for a particular --- purpose or non-infringement. Please see the License for the specific terms --- and conditions governing the rights and limitations under the License. - - --- Modified: GG 27/04/00 G002 Add empty constructor and --- SetView() method. --- GG 14/04/00 G002 Add SetPickedIndex() method --- TCl : 12-06-00 : G002 : new method Pick( Xmin, Ymin, Xmax, Ymax,...) - --- SAV : 14/11/01 Added PickByCircle() picking by a circle. --- SAV : 16/08/02 Added field to control object status. - -class GraphicObject from Graphic2d inherits TShared from MMgt - - ---Purpose: Creates a 2D graphic object in a view. - -- A graphic object is a primitives manager. - - -uses - ViewPtr from Graphic2d, - Drawer from Graphic2d, - View from Graphic2d, - IndexedMapOfTransient from TColStd, - Primitive from Graphic2d, - CBitFields8 from Graphic2d, - TypeOfComposition from Graphic2d, - Length from Quantity, - GTrsf2d from gp, - PickMode from Graphic2d, - HSequenceOfInteger from TColStd, - DisplayStatus from Graphic2d - -raises - OverrideColorError from Graphic2d, - OutOfRange from Standard - -is - ------------------------- - -- Category: Constructors - ------------------------- - - Create returns mutable GraphicObject from Graphic2d; - ---Level: Public - ---Purpose: Creates an unattached graphic object, - -- the attachment will be realized more later - -- using the method SetView(). - - Create (aView: View from Graphic2d) - returns mutable GraphicObject from Graphic2d; - ---Level: Public - ---Purpose: Creates a graphic object in the view . - -- A graphic object manages a sequence of primitives. - -- By default a graphic object is : - -- - empty. - -- - plottable. - -- - drawable. - -- - pickable. - -- - not displayed. - -- - not highlighted. - -- - a relative drawing priority of 0 - ---Category: Constructors - - ------------------------------------------------- - -- Category: Methods to manage the transformation - ------------------------------------------------- - - SetView( me: mutable; aView: View from Graphic2d ); - ---Level: Public - ---Purpose: Attach the graphic object to this view - - SetTransform (me : mutable; aTrsf : in GTrsf2d from gp; - aType : TypeOfComposition from Graphic2d = Graphic2d_TOC_REPLACE) - is static; - ---Level: Public - ---Purpose: Sets the transformation applied to - -- the primitives according to the composition type. - ---Category: Methods to manage the transformation - - Transform (me) - returns GTrsf2d from gp - is static; - ---Level: Public - ---Purpose: Returns the transformation applied to - -- the primitives. - ---C++: return const & - - IsTransformed (me) - returns Boolean from Standard - is static; - ---Level: Public - ---Purpose: Returns Standard_True if the associated - -- transformation is not the Identity. - - ---------------------------------------- - -- Category: Methods to manage the layer - ---------------------------------------- - - SetLayer (me: mutable; aLayer: Integer from Standard) - is static; - ---Level: Internal - ---Purpose: Modifies the layer of the graphic object . - ---Category: Methods to manage the layer - - Layer (me) - returns Integer from Standard - is static; - ---Level: Internal - ---Purpose: Returns the layer of the graphic object . - ---Category: Methods to manage the layer - - ------------------------------------------------- - -- Category: Methods to manage the drawing priority - ------------------------------------------------- - - SetPriority (me: mutable; aPriority: Integer from Standard) - ---Level: Public - ---Purpose: Modifies the drawing priority of the graphic object . - -- of 0 is the lowest priority. - -- of MaxPriority() is the highest priority. - raises OutOfRange from Standard is static; - ---Trigger: If is < 0 or > MaxPriority() - ---Category: Methods to manage the priority - - Priority (me) - returns Integer from Standard - is static; - ---Level: Public - ---Purpose: Returns the drawing priority of the graphic object - - MaxPriority (me) returns Integer from Standard is virtual; - ---Level: Public - ---Purpose: Returns the max usable relative priority of the - -- "standard" graphic object. - - ------------------------------------------ - -- Category: Methods to manage the plotter - ------------------------------------------ - - EnablePlot (me: mutable) - is static; - ---Level: Internal - ---Purpose: Allows the drawing of graphic object on a plotter. - ---Category: Methods to manage the plotter - - DisablePlot (me: mutable) - is static; - ---Level: Internal - ---Purpose: Forbids the drawing of graphic object on a plotter. - ---Category: Methods to manage the plotter - - IsPlottable (me) - returns Boolean from Standard - is static; - ---Level: Internal - ---Purpose: Returns Standard_True if the graphic object - -- is plottable, Standard_False if not. - ---Category: Methods to manage the plotter - - ------------------------------------------ - -- Category: Methods to manage the drawing - ------------------------------------------ - - EnableDraw (me: mutable) - is static; - ---Level: Public - ---Purpose: Allows the drawing of graphic object . - ---Category: Methods to manage the drawing - - DisableDraw (me: mutable) - is static; - ---Level: Public - ---Purpose: Forbids the drawing of graphic object . - ---Category: Methods to manage the drawing - - IsDrawable (me) - returns Boolean from Standard - is static; - ---Level: Public - ---Purpose: Returns Standard_True if the graphic object - -- is drawable, Standard_False if not. - ---Category: Methods to manage the drawing - - IsIn (me; aPrimitive: Primitive from Graphic2d) - returns Boolean from Standard - is static; - ---Level: Public - ---Purpose: Returns Standard_True if the primitive - -- is in the graphic object , Standard_False if not. - ---Category: Methods to manage the drawing - - RemovePrimitive (me: mutable; aPrimitive: Primitive from Graphic2d) - is static; - ---Level: Public - ---Purpose: Removes the primitive from . - ---Category: Methods to manage the drawing - - RemovePrimitives (me: mutable) - is static; - ---Level: Public - ---Purpose: Removes all the primitives from . - ---Category: Methods to manage the drawing - - Remove (me: mutable) - is static; - ---Level: Public - ---Purpose: Removes from the associated view. - -- If was displayed or highlighted, - -- is removed from the display list of the associated view. - ---Category: Methods to manage the drawing - - ------------------------------------------ - -- Category: Methods to manage the picking - ------------------------------------------ - - EnablePick (me: mutable) - is static; - ---Level: Public - ---Purpose: Allows the picking on the graphic object . - ---Category: Methods to manage the picking - - DisablePick (me: mutable) - is static; - ---Level: Public - ---Purpose: Forbids the picking on the graphic object . - ---Category: Methods to manage the picking - - IsPickable (me) - returns Boolean from Standard - is static; - ---Level: Public - ---Purpose: Returns Standard_True if the graphic object - -- is pickable, Standard_False if not. - ---Category: Methods to manage the picking - - --------------------------------------------- - -- Category: Methods to manage the visibility - --------------------------------------------- - - Display (me: mutable) - is static; - ---Level: Public - ---Purpose: Allows the drawing of the graphic object . - ---Category: Methods to manage the visibility - - Erase (me: mutable) - is static; - ---Level: Public - ---Purpose: Forbids the drawing of the graphic object . - ---Category: Methods to manage the visibility - - IsDisplayed (me) - returns Boolean from Standard - is static; - ---Level: Public - ---Purpose: Returns Standard_True if the graphic object - -- is displayed, Standard_False if not. - ---Category: Methods to manage the visibility - - -------------------------------------------- - -- Category: Methods to manage the highlight - -------------------------------------------- - - Highlight (me: mutable) - ---Level: Public - ---Purpose: Highlights the graphic object with the - -- override color of the view. - ---Category: Methods to manage the highlight - -- Warning: Raises if the default override color of the view - -- has not been defined. - raises OverrideColorError from Graphic2d is static; - - Highlight (me: mutable; aColorIndex: Integer from Standard) - is static; - ---Level: Public - ---Purpose: Highlights the graphic object with the - -- specified color. - ---Category: Methods to manage the highlight - - Unhighlight (me: mutable) - is static; - ---Level: Public - ---Purpose: Suppress the highlight the graphic object . - ---Category: Methods to manage the highlight - - IsHighlighted (me) - returns Boolean from Standard - is static; - ---Level: Public - ---Purpose: Returns Standard_True if the graphic object - -- is highlighted, Standard_False if not. - ---Category: Methods to manage the highlight - - SetOffSet (me: mutable; - anOffSet: Integer from Standard) - is static; - ---Level: Public - ---Purpose: Specifies an offset applied to the original color - -- index when drawing a primitives, those already created - -- and the future one. - -- Warning: To reset the real color of the primitives when drawing - -- then you have to call this method with = 0. - - OffSet (me) - returns Integer from Standard - is static; - ---Level: Public - ---Purpose: Returns the offset applied to the original color - -- index of all primitives in the graphic object . - ---Category: Methods to manage the highlight - - OverrideColor (me) - returns Integer from Standard - is static; - ---Level: Public - ---Purpose: Returns the current overridel color apply to - -- this graphic object. - ---Category: Methods to manage the highlight - - SetOverrideColor(me: mutable; indColor: Integer from Standard ); - ---Level: Public - ---Purpose: Sets the current overridel color apply to - -- this graphic object. - ---Category: Methods to manage the highlight - - - ---------------------- - -- Category: Inquiries - ---------------------- - - Length(me) returns Integer from Standard is static; - ---Level: Public - ---Purpose: Returns the number of primitive of the graphic object. - ---Category: Inquiries - - Primitive(me; aRank: Integer from Standard) - returns mutable Primitive from Graphic2d - ---Level: Public - ---Purpose: Returns the primitive of rank - --from the graphic object. - raises OutOfRange from Standard is static; - ---Trigger: If is < 1 or > Length() - ---Category: Inquiries - - MinMax (me; Minx, Maxx, Miny, Maxy: out Length from Quantity) - returns Boolean from Standard is virtual; - ---Level: Public - ---Purpose: Returns the min max values of . - -- Warning: All markers are ignored. - -- Warning: If is empty or not displayed or - -- contains markers and nothing else - -- returns FALSE and - -- Minx = Miny = RealFirst () - -- Maxx = Maxy = RealLast () - ---Category: Inquiries - - MarkerMinMax (me; - Minx, Maxx, Miny, Maxy: out Length from Quantity) - returns Boolean from Standard is virtual; - ---Level: Public - ---Purpose: Returns the min max values of all markers in . - -- Warning: If is empty or not displayed or without markers - -- returns FALSE and - -- Minx = Miny = RealFirst () - -- Maxx = Maxy = RealLast () - ---Category: Inquiries - - - SetPickedIndex (me : mutable; anIndex: Integer from Standard) - is static protected; - ---Level: Public - ---Purpose: Sets the index of the picked primitive if any. - ---Category: Methods to manage picking - - PickedIndex(me) returns Integer from Standard; - ---Level: Public - ---Purpose: Returns the last picked primitive index in this. - -- Warning: This is available only if the Pick() method has - -- returned Standard_True. - ---Category: Inquiries - - ---------------------------- - -- Category: Private methods - ---------------------------- - - Draw (me: mutable; - aDrawer: Drawer from Graphic2d; - Reset: Boolean from Standard) - is virtual protected; - ---Level: Internal - ---Purpose: Drawn the last Undrawn primitives managed by the - -- graphic object in the drawer . - -- Called by the methods : - -- - Graphic2d_View::TinyUpdate () - ---Category: Private methods - - Draw (me: mutable; - aDrawer: Drawer from Graphic2d; - aPrimitive: Primitive from Graphic2d) - is virtual protected; - ---Level: Internal - ---Purpose: Drawn a primitive managed by the - -- graphic object in the drawer . - -- Called by the method Graphic2d_View::Update (aPrimitive) - ---Category: Private methods - - Redraw (me: mutable; - aDrawer: Drawer from Graphic2d) - is static private; - ---Level: Internal - ---Purpose: Drawn all the primitives managed by the - -- graphic object in the drawer . - -- Called by the method : - -- - Graphic2d_View::Update (aViewMapping, x, y, scale) - ---Category: Private methods - - Pick (me : mutable; X, Y: Real from Standard; - aPrecision: Real from Standard; - aDrawer: Drawer from Graphic2d) - returns Boolean from Standard - is virtual protected; - ---Level: Internal - ---Purpose: Returns Standard_True if the graphic object - -- is picked, Standard_False if not. - -- Called by the method Graphic2d_View::Pick - ---Category: Protected methods - - PickByCircle (me : mutable; X, Y, Radius : Real from Standard; - aDrawer: Drawer from Graphic2d) - returns Boolean from Standard - is virtual protected; - ---Level: Internal - ---Purpose: Returns Standard_True if the graphic object - -- is picked, Standard_False if not. - -- Called by the method Graphic2d_View::PickByCircle - ---Category: Private methods - - Pick( me: mutable; Xmin, Ymin, Xmax, Ymax: Real from Standard; - aDrawer: Drawer from Graphic2d; - aPickMode: PickMode from Graphic2d = Graphic2d_PM_INCLUDE ) - returns Boolean from Standard is virtual protected; - ---Level: Internal - ---Purpose: Returns Standard_True if the primitive is: - -- included in rectangle (), - -- excluded from rectangle (), - -- intersected by rectangle (), - -- defined by Xmin, Ymin, Xmax, Ymax. - -- Standard_False if not. - - PickList( me ) returns HSequenceOfInteger from TColStd; - ---Level: Internal - ---Purpose: Returns the sequence of picked primitives. - - View (me) - returns mutable View from Graphic2d - is static private; - ---Level: Internal - ---Purpose: Returns the view which manages . - -- Called by the constructor of Primitive. - ---Category: Private methods - - AddPrimitive (me: mutable; aPrimitive: Primitive from Graphic2d) - is static private; - ---Level: Internal - ---Purpose: Adds the primitive in . - -- Called by the constructor of Primitive. - ---Category: Private methods - - SetIndex (me: mutable; aPrimitive: Primitive from Graphic2d) - is static private; - ---Level: Internal - ---Purpose: Sets the current index in the GraphicObject - -- to the index of the primitive . - ---Category: Private methods - - IsUpToDate (me) returns Boolean from Standard - is static protected; - ---Level: Internal - ---Purpose: Returns TRUE when the graphic object is - -- up to date at screen; - - BasePriority (me) returns Integer from Standard is virtual private; - ---Level: Public - ---Purpose: Returns the min usable absolute priority of the - -- "standard" graphic object. - -fields - myViewPtr: ViewPtr from Graphic2d; - myPrimitives: IndexedMapOfTransient from TColStd; - myLayer: Integer from Standard; - myTrsf: GTrsf2d from gp; - myCBitFields: CBitFields8 from Graphic2d; - myOverrideColor: Integer from Standard is protected; - myCurrentIndex: Integer from Standard is protected; - myOffSet: Integer from Standard is protected; --- myPickedIndex: Integer from Standard is protected; - myPickedIndex: Integer from Standard; - myIsUpToDate: Boolean from Standard is protected; - myIsTransformed: Boolean from Standard is protected; - myPriority: Integer from Standard; - myPickIndices: HSequenceOfInteger from TColStd; - - myDisplayStatus : DisplayStatus from Graphic2d; - -friends - class Primitive from Graphic2d, - class View from Graphic2d, - class TransientManager from Graphic2d - -end GraphicObject from Graphic2d; diff --git a/src/Graphic2d/Graphic2d_GraphicObject.cxx b/src/Graphic2d/Graphic2d_GraphicObject.cxx deleted file mode 100755 index 2e5499bfa1..0000000000 --- a/src/Graphic2d/Graphic2d_GraphicObject.cxx +++ /dev/null @@ -1,854 +0,0 @@ -// Copyright (c) 1995-1999 Matra Datavision -// Copyright (c) 1999-2012 OPEN CASCADE SAS -// -// The content of this file is subject to the Open CASCADE Technology Public -// License Version 6.5 (the "License"). You may not use the content of this file -// except in compliance with the License. Please obtain a copy of the License -// at http://www.opencascade.org and read it completely before using this file. -// -// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its -// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. -// -// The Original Code and all software distributed under the License is -// distributed on an "AS IS" basis, without warranty of any kind, and the -// Initial Developer hereby disclaims all such warranties, including without -// limitation, any warranties of merchantability, fitness for a particular -// purpose or non-infringement. Please see the License for the specific terms -// and conditions governing the rights and limitations under the License. - -// S3593 //GG_270298 -// Avoid calling IsKind() which is expensive. -// Add field myIsUpToDate informing if the object is updated. -// Add field myIsTransformed informing if the object is transformed. - -#define G002 //GG_140400 -// Add empty constructor and SetView() method. -// Manage highlighting. -// TCL : New method Pick(xmin, ymin, xmax, ymax,...) - -#define OCC197 // jfa 01.03.2002 - -#define OCC154 // jfa 06.03.2002 // to erase instead of removing - -#define OCC402 //SAV 14/11/01 Added PickByCircle(). Draw() was modified to be able -// to draw selected elements of SetOfMarker. - -#define OCC627 //SAV 16/08/02 new flag added to control visual object state - -#include -#include - -#include - -#define BASE_PRIORITY 1 -#define HIGH_PRIORITY 0x7FFFFFFF -#define MAX_PRIORITY 999 - -Graphic2d_GraphicObject::Graphic2d_GraphicObject - (const Handle(Graphic2d_View)& aView) - :myOverrideColor (0), - myCurrentIndex (1), - myOffSet (0), - myIsUpToDate (Standard_False), - myIsTransformed (Standard_False), - myPrimitives (), - myLayer (0), - myTrsf (), - myPickedIndex (0), - myPriority(0) , - myPickIndices(new TColStd_HSequenceOfInteger) { - - Plottable = Standard_True; - Drawable = Standard_True; - Pickable = Standard_True; - myIsDisplayed = Standard_False; - myIsHighlighted = Standard_False; - myViewPtr = aView.operator->(); -#ifdef OCC627 - myDisplayStatus = Graphic2d_DS_NONE; -#endif -} - -Graphic2d_GraphicObject::Graphic2d_GraphicObject() - :myOverrideColor (0), - myCurrentIndex (1), - myOffSet (0), - myIsUpToDate (Standard_False), - myIsTransformed (Standard_False), - myPrimitives (), - myLayer (0), - myTrsf (), - myPickedIndex (0), - myPriority(0) , - myPickIndices(new TColStd_HSequenceOfInteger) { - - Plottable = Standard_True; - Drawable = Standard_True; - Pickable = Standard_True; - myIsDisplayed = Standard_False; - myIsHighlighted = Standard_False; - myViewPtr = NULL; -#ifdef OCC627 - myDisplayStatus = Graphic2d_DS_NONE; -#endif -} - -void Graphic2d_GraphicObject::SetView( const Handle(Graphic2d_View)& aView ) { - - myViewPtr = aView.operator->(); -} - -void Graphic2d_GraphicObject::SetTransform (const gp_GTrsf2d& aTrsf, - const Graphic2d_TypeOfComposition aType) { - - if( aType == Graphic2d_TOC_REPLACE ) { - myTrsf = aTrsf; - } else { - myTrsf = aTrsf.Multiplied(myTrsf); - } - myIsTransformed = (aTrsf.Form() == gp_Identity) ? - Standard_False : Standard_True; -} - -const gp_GTrsf2d& Graphic2d_GraphicObject::Transform () const { - - return myTrsf; - -} - -Standard_Boolean Graphic2d_GraphicObject::IsTransformed () const { - return myIsTransformed; -} - -void Graphic2d_GraphicObject::SetLayer (const Standard_Integer aLayer) { - - myLayer = aLayer; - -} - -Standard_Integer Graphic2d_GraphicObject::Layer () const { - - return myLayer; - -} - -void Graphic2d_GraphicObject::SetPriority (const Standard_Integer aPriority) { - - if( aPriority < 0 || aPriority > MaxPriority() ) { - Standard_OutOfRange::Raise (" Bad priority"); - } - myPriority = aPriority; -} - -Standard_Integer Graphic2d_GraphicObject::Priority () const { - - return myPriority; - -} - -Standard_Integer Graphic2d_GraphicObject::BasePriority () const { - - return BASE_PRIORITY; - -} - -Standard_Integer Graphic2d_GraphicObject::MaxPriority () const { - - return MAX_PRIORITY; - -} - -void Graphic2d_GraphicObject::EnablePlot () { - - Plottable = Standard_True; - -} - -void Graphic2d_GraphicObject::DisablePlot () { - - Plottable = Standard_False; - -} - -Standard_Boolean Graphic2d_GraphicObject::IsPlottable () const { - - return Plottable; - -} - -void Graphic2d_GraphicObject::EnableDraw () { - - Drawable = Standard_True; - -} - -void Graphic2d_GraphicObject::DisableDraw () { - - Drawable = Standard_False; - -} - -Standard_Boolean Graphic2d_GraphicObject::IsDrawable () const { - - return Drawable; - -} - -Standard_Boolean Graphic2d_GraphicObject::IsIn (const Handle(Graphic2d_Primitive) & aPrimitive) const { - return myPrimitives.Contains(aPrimitive); -} - -void Graphic2d_GraphicObject::EnablePick () { - - Pickable = Standard_True; - -} - -void Graphic2d_GraphicObject::DisablePick () { - - Pickable = Standard_False; - -} - -Standard_Boolean Graphic2d_GraphicObject::IsPickable () const { - - return Pickable; - -} - -void Graphic2d_GraphicObject::SetPickedIndex (const Standard_Integer anIndex) { - myPickedIndex = anIndex; -} - -Standard_Integer Graphic2d_GraphicObject::PickedIndex () const { - - return myPickedIndex; -} - -void Graphic2d_GraphicObject::Redraw (const Handle(Graphic2d_Drawer)& aDrawer) { - - myCurrentIndex = 1; - Draw (aDrawer,Standard_True); - -} - -void Graphic2d_GraphicObject::Draw (const Handle(Graphic2d_Drawer)& aDrawer, const Standard_Boolean Reset) { - - if (! Drawable) return; - - if (myIsDisplayed || myIsHighlighted) { -#ifdef G002 - aDrawer->SetOverrideColor (myOverrideColor); -#endif - if (myIsHighlighted) { - aDrawer->SetOverride (Standard_True); -#ifndef G002 - aDrawer->SetOverrideColor (myOverrideColor); -#endif - } else { - aDrawer->SetOffSet (myOffSet); - } - - Standard_Integer Length = myPrimitives.Extent (); - Handle(Graphic2d_Primitive) aPrimitive; - - for (Standard_Integer i=myCurrentIndex; i<=Length; i++) { - aPrimitive = Primitive (i); - // We draw the boundary rectangle of an image - // in a highlighted Graphic2d_GraphicObject - Standard_Boolean TheFlag = myIsHighlighted && - (aPrimitive->Family() == Graphic2d_TOP_IMAGE); - if (TheFlag) { - Standard_Integer ColorIndexSave = aPrimitive->ColorIndex (); - aPrimitive->SetColorIndex (myOverrideColor); - aPrimitive->Draw (aDrawer); - aPrimitive->SetColorIndex (ColorIndexSave); - } else { -#ifdef G002 - if( aPrimitive->IsHighlighted() && !myIsHighlighted ) - { - Handle(TColStd_HSequenceOfInteger) theHSeq = aPrimitive->HighlightIndices(); -#ifdef OCC197 - aPrimitive->Draw (aDrawer); -#endif - for ( Standard_Integer j = 1; j <= theHSeq->Length(); ++j ) - { - Standard_Integer hindex = theHSeq->Value(j); - if( hindex != 0 ) { // Highlight a part of primitive -#ifndef OCC197 -// if we draw a primitive in cycle, it hides its own highlighted parts except the last one - aPrimitive->Draw (aDrawer); -#endif - aDrawer->SetOverride (Standard_True); - if( hindex > 0 ) - aPrimitive->DrawElement (aDrawer,hindex); - else - aPrimitive->DrawVertex (aDrawer,-hindex); - aDrawer->SetOverride (Standard_False); - } else { // Highlight the full primitive - aDrawer->SetOverride (Standard_True); - aPrimitive->Draw (aDrawer); - aDrawer->SetOverride (Standard_False); - } - } // end for - } -#ifdef OCC402 - else - if ( aPrimitive->HasSelectedElements() ) { - aPrimitive->Draw (aDrawer); - aDrawer->SetOverride( Standard_True ); - aPrimitive->DrawSelectedElements( aDrawer ); - aDrawer->SetOverride( Standard_False ); - } -#endif - else -#endif - aPrimitive->Draw (aDrawer); - } - } - - if( Reset ) myCurrentIndex = Length + 1; - myIsUpToDate = Standard_True; - if (myIsHighlighted) { - aDrawer->SetOverride (Standard_False); - } - } - -} - -void Graphic2d_GraphicObject::Draw ( - const Handle(Graphic2d_Drawer)& aDrawer, - const Handle(Graphic2d_Primitive)& aPrimitive) { - - // - // Test deja effectue dans l'appelant - // - // if (! IsIn (aPrimitive)) return; - - if (! Drawable) return; - - if (myIsDisplayed || myIsHighlighted) { -#ifdef G002 - aDrawer->SetOverrideColor (myOverrideColor); -#endif - if (myIsHighlighted) { - aDrawer->SetOverride (Standard_True); -#ifndef G002 - aDrawer->SetOverrideColor (myOverrideColor); -#endif - } else { - aDrawer->SetOffSet (myOffSet); - } - - // We draw the boundary rectangle of an image - // in a highlighted Graphic2d_GraphicObject - Standard_Boolean TheFlag = myIsHighlighted && - (aPrimitive->Family() == Graphic2d_TOP_IMAGE); - if (TheFlag) { - Standard_Integer ColorIndexSave = - aPrimitive->ColorIndex (); - aPrimitive->SetColorIndex (myOverrideColor); - aPrimitive->Draw (aDrawer); - aPrimitive->SetColorIndex (ColorIndexSave); - } else { -#ifdef G002 - if( aPrimitive->IsHighlighted() && !myIsHighlighted ) { - Handle(TColStd_HSequenceOfInteger) theHSeq = aPrimitive->HighlightIndices(); - for ( int i = 1; i <= theHSeq->Length(); ++i ) { - Standard_Integer hindex = theHSeq->Value(i); - if( hindex != 0 ) { // Highlight a part of primitive - aPrimitive->Draw (aDrawer); - aDrawer->SetOverride (Standard_True); - if( hindex > 0 ) - aPrimitive->DrawElement (aDrawer,hindex); - else - aPrimitive->DrawVertex (aDrawer,-hindex); - aDrawer->SetOverride (Standard_False); - } else { // Highlight the full primitive - aDrawer->SetOverride (Standard_True); - aPrimitive->Draw (aDrawer); - aDrawer->SetOverride (Standard_False); - } - } // end for - } else -#endif - aPrimitive->Draw (aDrawer); - } - if (myIsHighlighted) { - aDrawer->SetOverride (Standard_False); - } - } -} - -void Graphic2d_GraphicObject::Display () { - - if (myIsHighlighted) Unhighlight(); -#ifdef OCC627 - if (! myIsDisplayed && ( myDisplayStatus != Graphic2d_DS_ERASED ) ) -#else - if (! myIsDisplayed ) -#endif - myViewPtr->Add (this,myPriority + BasePriority() ); - myIsDisplayed = Standard_True; -#ifdef OCC627 - myDisplayStatus = Graphic2d_DS_DISPLAYED; -#endif -} - -void Graphic2d_GraphicObject::Erase () { - - if (myIsHighlighted) Unhighlight(); -#ifndef OCC154 - if (myIsDisplayed) myViewPtr->Remove (this); -#endif -#ifdef OCC627 - if(myIsDisplayed) - myDisplayStatus = Graphic2d_DS_ERASED; -#endif - myIsDisplayed = Standard_False; - myCurrentIndex = 1; -} - -Standard_Boolean Graphic2d_GraphicObject::IsDisplayed () const { - - return myIsDisplayed; - -} - - -void Graphic2d_GraphicObject::RemovePrimitive (const Handle(Graphic2d_Primitive)& aPrimitive) { - - Standard_Integer Index = myPrimitives.FindIndex(aPrimitive); - if (Index == 0) return; - Standard_Integer Length = myPrimitives.Extent (); - - for (Standard_Integer i=Index+1; i<=Length; i++) - ((Handle(Standard_Transient)&) myPrimitives.FindKey(i-1)) = myPrimitives.FindKey(i); - - myPrimitives.RemoveLast (); - - myCurrentIndex = (myCurrentIndex > Index ? Index : myCurrentIndex); - -#ifdef OK - // - // To retrace whatever is necessary - // Parse the primitives from 1 to Index - // and return l'Index of the first primitive - // with bounding box intersecting the bounding - // box of the removed primitive. - // -Standard_Boolean stop = Standard_False; -Standard_ShortReal sMinx, sMiny, sMaxx, sMaxy; -Standard_ShortReal x, y, X, Y; -Standard_ShortReal RF = ShortRealFirst (); -Standard_ShortReal RL = ShortRealLast (); - - aPrimitive->MinMax (sMinx, sMaxx, sMiny, sMaxy); - for (Standard_Integer i=1; iMinMax (x, X, y, Y); - // - // Infinite lines - // - if ((x == RF) || (X == RL) || (y == RF) || (Y == RL)) { - // infinite horizontal - if (y == Y) stop = (sMiny <= y) && (y <= sMaxy); - // infinite vertical - if (x == X) stop = (sMinx <= x) && (x <= sMaxx); - // infinite diagonal - if ((y != Y) && (x != X)) { - // no interrogation possible - // about the content of the primitive. - stop = Standard_True; - } - } - else { - if ((x<=sMinx) && (sMinx<=X) && - (y<=sMaxy) && (sMaxy<=Y)) stop = Standard_True; - if ((x<=sMinx) && (sMinx<=X) && - (y<=sMiny) && (sMiny<=Y)) stop = Standard_True; - if ((x<=sMaxx) && (sMaxx<=X) && - (y<=sMiny) && (sMiny<=Y)) stop = Standard_True; - if ((x<=sMaxx) && (sMaxx<=X) && - (y<=sMaxy) && (sMaxy<=Y)) stop = Standard_True; - } - if (stop) myCurrentIndex = i; - } -#endif - -} - -void Graphic2d_GraphicObject::RemovePrimitives () { - - myPrimitives.Clear (); - myCurrentIndex = 1; - -} - -void Graphic2d_GraphicObject::Remove () { - -#ifdef OCC627 - if ( myIsDisplayed || myIsHighlighted || - ( myDisplayStatus == Graphic2d_DS_ERASED ) ) -#else - if (myIsDisplayed || myIsHighlighted) -#endif - myViewPtr->Remove (this); - myIsHighlighted = Standard_False; - myIsDisplayed = Standard_False; -#ifdef OCC627 - myDisplayStatus = Graphic2d_DS_REMOVED; -#endif - myCurrentIndex = 1; - -} - -void Graphic2d_GraphicObject::Highlight () { - - if (! myViewPtr->IsDefinedColor ()) - Graphic2d_OverrideColorError::Raise - ("Undefined highlight color index"); - - if (! myIsHighlighted) { - if (! myIsDisplayed ) -#ifdef OCC627 - if ( myDisplayStatus != Graphic2d_DS_ERASED ) -#endif - myViewPtr->Add (this,HIGH_PRIORITY); -#ifdef TEST - else - myViewPtr->Change (this,HIGH_PRIORITY); -#endif - myIsHighlighted = Standard_True; - } - myOverrideColor = myViewPtr->DefaultOverrideColor(); - myCurrentIndex = 1; - -} - -void Graphic2d_GraphicObject::Highlight (const Standard_Integer aColorIndex) { - - if (! myIsHighlighted) { - if (! myIsDisplayed ) -#ifdef OCC627 - if ( myDisplayStatus != Graphic2d_DS_ERASED ) -#endif - myViewPtr->Add (this,HIGH_PRIORITY); -#ifdef TEST - else - myViewPtr->Change (this,HIGH_PRIORITY); -#endif - myIsHighlighted = Standard_True; - } - myOverrideColor = aColorIndex; - myCurrentIndex = 1; - -} - -void Graphic2d_GraphicObject::SetOffSet (const Standard_Integer anOffSet) { - - myOffSet = anOffSet; - myCurrentIndex = 1; - -} - -Standard_Integer Graphic2d_GraphicObject::OffSet () const { - - return myOffSet; - -} - -Standard_Integer Graphic2d_GraphicObject::OverrideColor () const { - - return myOverrideColor; - -} - -void Graphic2d_GraphicObject::SetOverrideColor( const Standard_Integer indColor ) { - - myOverrideColor = indColor; - -} - -void Graphic2d_GraphicObject::Unhighlight () { - - if( myIsHighlighted ) { -#ifdef TEST - if ( myIsDisplayed ) - myViewPtr->Change (this,myPriority + BasePriority() ); - else -#else - if ( !myIsDisplayed ) -#endif - myViewPtr->Remove (this); - myIsHighlighted = Standard_False; - } - myCurrentIndex = 1; - -} - -Standard_Boolean Graphic2d_GraphicObject::IsHighlighted () const { - - return myIsHighlighted; - -} - -Handle(Graphic2d_View) Graphic2d_GraphicObject::View () const { - - return ((Graphic2d_View*) myViewPtr); - -} - -Standard_Boolean Graphic2d_GraphicObject::Pick (const Standard_Real X, const Standard_Real Y, const Standard_Real aPrecision, const Handle(Graphic2d_Drawer)& aDrawer) { - -#ifndef G002 - myPickedIndex = 0; -#else - myPickIndices->Clear(); -#endif - if (Pickable && (myIsDisplayed || myIsHighlighted)) - { - Standard_ShortReal XX = Standard_ShortReal (X); - Standard_ShortReal YY = Standard_ShortReal (Y); - Standard_ShortReal P = Standard_ShortReal (aPrecision); - Standard_Integer i; - Handle(Graphic2d_Primitive) thePrimitive; - Standard_ShortReal Minx, Maxx, Miny, Maxy; - - for( i=1 ; i<=myPrimitives.Extent () ; i++ ) { - thePrimitive = Primitive(i); - thePrimitive->MinMax(Minx, Maxx, Miny, Maxy); - if(XX < Minx || Maxx < XX || YY < Miny || Maxy < YY) - continue; - if( thePrimitive->Pick(XX,YY,P,aDrawer) ) { -#ifdef G002 - SetPickedIndex(i); -#else - myPickedIndex = i; -#endif - return Standard_True; - } - } - return Standard_False; - } - else - return Standard_False; -} - -Standard_Boolean Graphic2d_GraphicObject -::PickByCircle( const Standard_Real X, - const Standard_Real Y, - const Standard_Real Radius, - const Handle(Graphic2d_Drawer)& aDrawer ) -{ -#ifdef OCC402 - - myPickIndices->Clear(); - - if ( Pickable && ( myIsDisplayed || myIsHighlighted ) ) { - Standard_ShortReal XX = Standard_ShortReal( X ); - Standard_ShortReal YY = Standard_ShortReal( Y ); - Standard_ShortReal radius = Standard_ShortReal( Radius ); - Standard_Integer i; - Handle(Graphic2d_Primitive) thePrimitive; - Standard_ShortReal Minx, Maxx, Miny, Maxy; - - for( i=1 ; i<=myPrimitives.Extent() ; i++ ) { - thePrimitive = Primitive( i ); - thePrimitive->MinMax(Minx, Maxx, Miny, Maxy); - if((XX+radius) < Minx || Maxx < (XX-radius) || (YY+radius) < Miny || Maxy < (YY-radius)) - continue; - if( thePrimitive->PickByCircle( XX, YY, radius, aDrawer ) ) - myPickIndices->Append(i); - } - if ( myPickIndices->Length() > 0 ) - return Standard_True; - return Standard_False; - } - else - return Standard_False; -#endif - return Standard_False; -} - -Standard_Boolean Graphic2d_GraphicObject::Pick( const Standard_Real Xmin, - const Standard_Real Ymin, - const Standard_Real Xmax, - const Standard_Real Ymax, - const Handle(Graphic2d_Drawer)& aDrawer, - const Graphic2d_PickMode aPickMode ) { - myPickIndices->Clear(); - - if ( Pickable && (myIsDisplayed || myIsHighlighted) ) { - Standard_ShortReal X1 = Standard_ShortReal( (XminMinMax(Minx, Maxx, Miny, Maxy); - if(X2 < Minx || Maxx < X1 || Y2 < Miny || Maxy < Y1) - continue; - if ( thePrimitive->Pick( X1,Y1,X2, Y2, aDrawer, aPickMode ) ) - myPickIndices->Append(i); - } - if ( myPickIndices->Length() > 0 ) - return Standard_True; - - return Standard_False; - } - else - return Standard_False; - -} - -Handle(TColStd_HSequenceOfInteger) Graphic2d_GraphicObject::PickList() const { - - return myPickIndices; - -} - -void Graphic2d_GraphicObject::AddPrimitive (const Handle(Graphic2d_Primitive)& aPrimitive) { - Standard_Integer ColorIndex = aPrimitive->ColorIndex (); - aPrimitive->SetColorIndex (ColorIndex + myOffSet); - myPrimitives.Add (aPrimitive); - myIsUpToDate = Standard_False; -} - -Standard_Integer Graphic2d_GraphicObject::Length() const { - - return myPrimitives.Extent() ; -} - -Handle(Graphic2d_Primitive) Graphic2d_GraphicObject::Primitive(const Standard_Integer aRank) const { - // modif : EAV , 23-09-01 - static Handle(Graphic2d_Primitive) null; - try { - OCC_CATCH_SIGNALS - return Handle(Graphic2d_Primitive)::DownCast(myPrimitives.FindKey(aRank)) ; - } - catch( Standard_OutOfRange ) { - return null; - } - // modif end -} - -void Graphic2d_GraphicObject::SetIndex (const Handle(Graphic2d_Primitive)& aPrimitive) { - - Standard_Integer Index = myPrimitives.FindIndex(aPrimitive); - - if (Index == 0) return; - myCurrentIndex = (myCurrentIndex > Index ? Index : myCurrentIndex); - -} - -Standard_Boolean Graphic2d_GraphicObject::MinMax (Quantity_Length & Minx, Quantity_Length & Maxx, Quantity_Length & Miny, Quantity_Length & Maxy) const { - - Standard_ShortReal RL, RF, sMinx, sMiny, sMaxx, sMaxy; - Standard_Boolean status = Standard_True; - Handle(Graphic2d_Primitive) thePrimitive = NULL; - - RL = sMinx = sMiny = ShortRealLast (); - RF = sMaxx = sMaxy = ShortRealFirst(); - - if (myIsDisplayed || myIsHighlighted) { - - Standard_Integer Length = myPrimitives.Extent (); - Standard_ShortReal x, y, X, Y; - Standard_Boolean TheFlag; - - for (Standard_Integer i=1; i<=Length; i++) { - thePrimitive = Primitive (i); - TheFlag = - (thePrimitive->Family() == Graphic2d_TOP_MARKER); - if (! TheFlag) { - if( thePrimitive->MinMax (x, X, y, Y) ) { - // Tests for cause of infinite lines - if (x != RF) sMinx = (sMinx < x ? sMinx : x); - if (X != RL) sMaxx = (sMaxx > X ? sMaxx : X); - if (y != RF) sMiny = (sMiny < y ? sMiny : y); - if (Y != RL) sMaxy = (sMaxy > Y ? sMaxy : Y); - } - } - } - } - - // Attention, it is possible that : - // sMinx = sMiny = ShortRealLast (); and - // sMaxx = sMaxy = ShortRealFirst(); - if (sMinx > sMaxx) { - status = Standard_False; - sMinx = ShortRealFirst (); sMaxx = ShortRealLast (); - } - if (sMiny > sMaxy) { - status = Standard_False; - sMiny = ShortRealFirst (); sMaxy = ShortRealLast (); - } - Minx = sMinx; - Miny = sMiny; - Maxx = sMaxx; - Maxy = sMaxy; - - return status; - -} - -Standard_Boolean Graphic2d_GraphicObject::MarkerMinMax (Quantity_Length & Minx, Quantity_Length & Maxx, Quantity_Length & Miny, Quantity_Length & Maxy) const { - - Standard_ShortReal RL, RF, sMinx, sMiny, sMaxx, sMaxy; - Standard_Boolean status = Standard_True; - Handle(Graphic2d_Primitive) thePrimitive = NULL; - - RL = sMinx = sMiny = ShortRealLast (); - RF = sMaxx = sMaxy = ShortRealFirst(); - - if (myIsDisplayed || myIsHighlighted) { - - Standard_Integer Length = myPrimitives.Extent (); - Standard_ShortReal x, y, X, Y; - Standard_Boolean TheFlag; - - for (Standard_Integer i=1; i<=Length; i++) { - thePrimitive = Primitive(i); - TheFlag = - (thePrimitive->Family() == Graphic2d_TOP_MARKER); - if (TheFlag) { - if( thePrimitive->MinMax (x, X, y, Y) ) { - // Tests for cause of infinite lines - if (x != RF) sMinx = (sMinx < x ? sMinx : x); - if (X != RL) sMaxx = (sMaxx > X ? sMaxx : X); - if (y != RF) sMiny = (sMiny < y ? sMiny : y); - if (Y != RL) sMaxy = (sMaxy > Y ? sMaxy : Y); - } - } - } - } - - // Attention, it is possible that : - // sMinx = sMiny = ShortRealLast (); and - // sMaxx = sMaxy = ShortRealFirst(); - if (sMinx > sMaxx) { - status = Standard_False; - sMinx = ShortRealFirst (); sMaxx = ShortRealLast (); - } - if (sMiny > sMaxy) { - status = Standard_False; - sMiny = ShortRealFirst (); sMaxy = ShortRealLast (); - } - Minx = sMinx; - Miny = sMiny; - Maxx = sMaxx; - Maxy = sMaxy; - - return status; -} - -Standard_Boolean Graphic2d_GraphicObject::IsUpToDate() const { - - return myIsUpToDate; -} diff --git a/src/Graphic2d/Graphic2d_GraphicObject.pxx b/src/Graphic2d/Graphic2d_GraphicObject.pxx deleted file mode 100755 index 18bb080298..0000000000 --- a/src/Graphic2d/Graphic2d_GraphicObject.pxx +++ /dev/null @@ -1,33 +0,0 @@ -// Copyright (c) 1995-1999 Matra Datavision -// Copyright (c) 1999-2012 OPEN CASCADE SAS -// -// The content of this file is subject to the Open CASCADE Technology Public -// License Version 6.5 (the "License"). You may not use the content of this file -// except in compliance with the License. Please obtain a copy of the License -// at http://www.opencascade.org and read it completely before using this file. -// -// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its -// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. -// -// The Original Code and all software distributed under the License is -// distributed on an "AS IS" basis, without warranty of any kind, and the -// Initial Developer hereby disclaims all such warranties, including without -// limitation, any warranties of merchantability, fitness for a particular -// purpose or non-infringement. Please see the License for the specific terms -// and conditions governing the rights and limitations under the License. - - -#ifndef GRAPHICOBJECT_PXX_INCLUDED -#define GRAPHICOBJECT_PXX_INCLUDED - -#define Plottable myCBitFields.bool1 -#define Drawable myCBitFields.bool2 -#define Pickable myCBitFields.bool3 -#define myIsDisplayed myCBitFields.bool4 - -#define myIsHighlighted myCBitFields.bool5 -#define myNotUsed1 myCBitFields.bool6 -#define myNotUsed2 myCBitFields.bool7 -#define myNotUsed3 myCBitFields.bool8 - -#endif diff --git a/src/Graphic2d/Graphic2d_HidingGraphicObject.cdl b/src/Graphic2d/Graphic2d_HidingGraphicObject.cdl deleted file mode 100755 index 4a1d8eaf80..0000000000 --- a/src/Graphic2d/Graphic2d_HidingGraphicObject.cdl +++ /dev/null @@ -1,252 +0,0 @@ --- Created on: 1998-02-19 --- Created by: s: Gerard GRAS --- Copyright (c) 1998-1999 Matra Datavision --- Copyright (c) 1999-2012 OPEN CASCADE SAS --- --- The content of this file is subject to the Open CASCADE Technology Public --- License Version 6.5 (the "License"). You may not use the content of this file --- except in compliance with the License. Please obtain a copy of the License --- at http://www.opencascade.org and read it completely before using this file. --- --- The Initial Developer of the Original Code is Open CASCADE S.A.S., having its --- main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. --- --- The Original Code and all software distributed under the License is --- distributed on an "AS IS" basis, without warranty of any kind, and the --- Initial Developer hereby disclaims all such warranties, including without --- limitation, any warranties of merchantability, fitness for a particular --- purpose or non-infringement. Please see the License for the specific terms --- and conditions governing the rights and limitations under the License. - - - -class HidingGraphicObject from Graphic2d inherits GraphicObject from Graphic2d - - ---Version: - - ---Purpose: Creates a 2D hiding graphic object in a view. - -- A graphic object is a primitives manager - -- which hide the others graphic objects - - ---Keywords: - ---Warning: - ---References: - -uses - Drawer from Graphic2d, - View from Graphic2d, - Primitive from Graphic2d, - TypeOfFrame from Graphic2d, - Array1OfVertex from Graphic2d, - HArray1OfVertex from Graphic2d, - Length from Quantity, - GTrsf2d from gp - -raises - OutOfRange from Standard - -is - ------------------------- - -- Category: Constructors - ------------------------- - - Create (aView: View from Graphic2d; - aFrame: Array1OfVertex from Graphic2d) - returns mutable HidingGraphicObject from Graphic2d; - ---Level: Public - ---Purpose: Creates an hiding polygon object in the view - -- This graphic object manages a sequence of primitives. - -- describes the hiding polygon geometry - -- The frame is created with the default attributes : - -- * the hiding color index : 0 (the same as the view) - -- * the frame color index : 1 - -- * the frame line type index : 0 - -- * the frame line thickness index : 0 - -- * the graphic object is : - -- - empty. - -- - plottable. - -- - drawable. - -- - pickable. - -- - not displayed. - -- - not highlighted. - -- - has a relative drawing priority of 0 - ---Category: Constructors - - Create (aView: View from Graphic2d; - aType: TypeOfFrame from Graphic2d = - Graphic2d_TOF_RECTANGULAR; - aMargin1,aMargin2: Length from Quantity = 0.0) - returns mutable HidingGraphicObject from Graphic2d; - ---Level: Public - ---Purpose: Creates an hiding predefined object in the view . - -- the predefined TypeOfFrame must be one of : - -- TOF_RECTANGULAR,TOF_CIRCULAR. - -- the frame position and geometry is computed - -- automaticaly according to the contents of the - -- graphic object and the , parameter. - -- A graphic object manages a sequence of primitives. - -- Warning: The type of frame can be UNKNOWN,in this case the frame is - -- not drawn. - - ----------------------------------------------------- - -- Category: Methods to manage the drawing attributes - ----------------------------------------------------- - - SetFrame (me : mutable; - aFrame: Array1OfVertex from Graphic2d) - is static; - ---Level: Public - ---Purpose: Updates the frame geometry. - - SetFrame (me : mutable; - aFrameType: TypeOfFrame from Graphic2d; - aMargin1,aMargin2: Length from Quantity = 0.0) - is static; - ---Level: Public - ---Purpose: Updates & computes the frame geometry - -- automaticaly according to the contents of the - -- graphic object and the parameter. - -- Warning: The type of frame can be UNKNOWN,in this case the frame is - -- not drawn. - - SetHidingColorIndex (me : mutable; anIndex: Integer from Standard = 0) - is static; - ---Level: Public - ---Purpose: Updates the hiding color index of the background polygon. - - SetFrameColorIndex (me : mutable; anIndex: Integer from Standard = 1) - is static; - ---Level: Public - ---Purpose: Updates the frame color index of the polygon. - - SetFrameTypeIndex (me : mutable; anIndex: Integer from Standard = 0) - is static; - ---Level: Public - ---Purpose: Updates the frame line type index of the polygon. - - SetFrameWidthIndex (me : mutable; anIndex: Integer from Standard = 0) - is static; - ---Level: Public - ---Purpose: Updates the frame line thickness index of the polygon. - - ------------------------------------------------- - -- Category: Methods to manage the drawing priority - ------------------------------------------------- - - MaxPriority (me) returns Integer from Standard is redefined; - ---Level: Public - ---Purpose: Returns the max usable relative priority of the - -- "hiding" graphic object. - - ---------------------- - -- Category: Inquiries - ---------------------- - - FrameMinMax (me; Minx, Maxx, Miny, Maxy: out Length from Quantity) - returns Boolean is static; - ---Level: Public - ---Purpose: Returns the min max values of the frame of . - -- Warning: If is empty - -- returns FALSE - -- and Minx = Miny = RealFirst () - -- Maxx = Maxy = RealLast () - - MinMax (me; Minx, Maxx, Miny, Maxy: out Length from Quantity) - returns Boolean is redefined; - ---Level: Public - ---Purpose: Returns the min max values of including - -- the frame and primitives inside. - -- Warning: If is empty or not displayed - -- returns FALSE - -- and Minx = Miny = RealFirst () - -- Maxx = Maxy = RealLast () - - Frame (me; aFrame: out Array1OfVertex from Graphic2d) - returns TypeOfFrame from Graphic2d is static; - ---Level: Public - ---Purpose: Returns the frame geometry and type of - -- the hiding graphic object. - -- Warning: the frame can be NULL. - - HidingColorIndex (me) - returns Integer from Standard is static; - ---Level: Public - ---Purpose: Returns the hiding color index. - - FrameColorIndex (me) - returns Integer from Standard is static; - ---Level: Public - ---Purpose: Returns the frame color index. - - FrameTypeIndex (me) - returns Integer from Standard is static; - ---Level: Public - ---Purpose: Returns the frame line type index. - - FrameWidthIndex (me) - returns Integer from Standard is static; - ---Level: Public - ---Purpose: Returns the frame line thickness index. - - ---------------------------- - -- Category: Private methods - ---------------------------- - - Draw (me: mutable; - aDrawer: Drawer from Graphic2d; - Reset: Boolean from Standard) - is redefined private; - ---Level: Internal - ---Purpose: Drawn the last Undrawn primitives managed by the - -- graphic object in the drawer . - ---Category: Private methods - - Draw (me: mutable; - aDrawer: Drawer from Graphic2d; - aPrimitive: Primitive from Graphic2d) - is redefined private; - ---Level: Internal - ---Purpose: Drawn a primitive managed by the - -- graphic object in the drawer . - -- Called by the method Graphic2d_View::Update (aPrimitive) - ---Category: Private methods - - Pick (me : mutable; X, Y: Real from Standard; - aPrecision: Real from Standard; - aDrawer: Drawer from Graphic2d) - returns Boolean from Standard - is redefined private; - ---Level: Internal - ---Purpose: Returns Standard_True if the graphic object - -- is picked, Standard_False if not. - -- Called by the method Graphic2d_View::Pick - ---Category: Private methods - - BasePriority (me) returns Integer from Standard is redefined private; - ---Level: Internal - ---Purpose: Returns the min usable absolute priority of the - -- "hiding" graphic object. - - TransformMinMax (me; aTrsf: GTrsf2d from gp; - Minx, Maxx, Miny, Maxy: out Real from Standard) - is static private; - ---Level: Internal - ---Purpose: Returns the transformed min max values of the frame . - -fields - myFrame: HArray1OfVertex from Graphic2d; - myTypeOfFrame: TypeOfFrame from Graphic2d; - myHidingColorIndex: Integer from Standard; - myFrameColorIndex: Integer from Standard; - myFrameTypeIndex: Integer from Standard; - myFrameWidthIndex: Integer from Standard; - myFrameMargin1: Length from Quantity; - myFrameMargin2: Length from Quantity; - myXmin,myYmin: Length from Quantity; - myXmax,myYmax: Length from Quantity; - myIsComputed: Boolean from Standard; - -friends - class View from Graphic2d - -end HidingGraphicObject from Graphic2d; diff --git a/src/Graphic2d/Graphic2d_HidingGraphicObject.cxx b/src/Graphic2d/Graphic2d_HidingGraphicObject.cxx deleted file mode 100755 index 2c305ef4bd..0000000000 --- a/src/Graphic2d/Graphic2d_HidingGraphicObject.cxx +++ /dev/null @@ -1,418 +0,0 @@ -// Copyright (c) 1998-1999 Matra Datavision -// Copyright (c) 1999-2012 OPEN CASCADE SAS -// -// The content of this file is subject to the Open CASCADE Technology Public -// License Version 6.5 (the "License"). You may not use the content of this file -// except in compliance with the License. Please obtain a copy of the License -// at http://www.opencascade.org and read it completely before using this file. -// -// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its -// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. -// -// The Original Code and all software distributed under the License is -// distributed on an "AS IS" basis, without warranty of any kind, and the -// Initial Developer hereby disclaims all such warranties, including without -// limitation, any warranties of merchantability, fitness for a particular -// purpose or non-infringement. Please see the License for the specific terms -// and conditions governing the rights and limitations under the License. - -#define xTRACE - -// S3569 //Gestion des zones cachantes - -#define G002 //GG_140400 -// Manage highlighting. - -#include -#include -#include - -#define BASE_PRIORITY 1000 -#define MAX_PRIORITY 999 -#define MAX_POINTS 1024 - -Graphic2d_HidingGraphicObject::Graphic2d_HidingGraphicObject - (const Handle(Graphic2d_View)& aView, - const Graphic2d_Array1OfVertex& aFrame) : -Graphic2d_GraphicObject(aView) , -myXmin(RealLast()),myYmin(RealLast()),myXmax(RealFirst()),myYmax(RealFirst()) -{ - - SetFrame(aFrame); - SetHidingColorIndex(); - SetFrameColorIndex(); - SetFrameTypeIndex(); - SetFrameWidthIndex(); - -} - -Graphic2d_HidingGraphicObject::Graphic2d_HidingGraphicObject - (const Handle(Graphic2d_View)& aView, - const Graphic2d_TypeOfFrame aType, - const Quantity_Length aMargin1, - const Quantity_Length aMargin2) : -Graphic2d_GraphicObject(aView), -myXmin(RealLast()),myYmin(RealLast()),myXmax(RealFirst()),myYmax(RealFirst()) -{ - - SetFrame(aType,aMargin1,aMargin2); - SetHidingColorIndex(); - SetFrameColorIndex(); - SetFrameTypeIndex(); - SetFrameWidthIndex(); - -} - -void Graphic2d_HidingGraphicObject::SetFrame(const Graphic2d_Array1OfVertex& aFrame) { -static Graphic2d_Vertex v; -Standard_Integer l = aFrame.Length(); -Standard_Real x,y; - - myFrame = new Graphic2d_HArray1OfVertex(1,l); - for( Standard_Integer i=1,j=aFrame.Lower() ; i<=l ; i++,j++) { - v = aFrame.Value(j); v.Coord(x,y); - myXmin = Min(myXmin,x); myYmin = Min(myYmin,y); - myXmax = Max(myXmax,x); myYmax = Max(myYmax,y); - myFrame->SetValue(i,v); - } - myTypeOfFrame = Graphic2d_TOF_UNKNOWN; - myIsComputed = Standard_True; -} - -void Graphic2d_HidingGraphicObject::SetFrame( - const Graphic2d_TypeOfFrame aType, - const Quantity_Length aMargin1, - const Quantity_Length aMargin2) { - myFrame.Nullify(); - myTypeOfFrame = aType; - myFrameMargin1 = aMargin1; - myFrameMargin2 = aMargin2; - if( myTypeOfFrame != Graphic2d_TOF_UNKNOWN ) - myIsComputed = Standard_False; - else myIsComputed = Standard_True; -} - -void Graphic2d_HidingGraphicObject::SetHidingColorIndex(const Standard_Integer anIndex) { - myHidingColorIndex = anIndex; -} - -void Graphic2d_HidingGraphicObject::SetFrameColorIndex(const Standard_Integer anIndex) { - myFrameColorIndex = anIndex; -} - -void Graphic2d_HidingGraphicObject::SetFrameTypeIndex(const Standard_Integer anIndex) { - myFrameTypeIndex = anIndex; -} - -void Graphic2d_HidingGraphicObject::SetFrameWidthIndex(const Standard_Integer anIndex) { - myFrameWidthIndex = anIndex; -} - -Standard_Integer Graphic2d_HidingGraphicObject::BasePriority () const { - - return BASE_PRIORITY; - -} - -Standard_Integer Graphic2d_HidingGraphicObject::MaxPriority () const { - - return MAX_PRIORITY; - -} - -void Graphic2d_HidingGraphicObject::Draw (const Handle(Graphic2d_Drawer)& aDrawer, const Standard_Boolean Reset) { - - if( !IsDrawable() ) return; - - if( !IsDisplayed() && !IsHighlighted() ) return; - - if( !myIsUpToDate || !myIsComputed ) { - static Graphic2d_Vertex v; - myIsComputed = - Graphic2d_GraphicObject::MinMax(myXmin,myXmax,myYmin,myYmax); - - if( myIsComputed ) switch (myTypeOfFrame) { - case Graphic2d_TOF_RECTANGULAR : - myXmin -= myFrameMargin1; myYmin -= myFrameMargin2; - myXmax += myFrameMargin1; myYmax += myFrameMargin2; - if( myFrame.IsNull() || (myFrame->Length() != 4) ) { - myFrame = new Graphic2d_HArray1OfVertex(1,4); - } - v.SetCoord(myXmin,myYmin); - myFrame->SetValue(1,v); - v.SetCoord(myXmin,myYmax); - myFrame->SetValue(2,v); - v.SetCoord(myXmax,myYmax); - myFrame->SetValue(3,v); - v.SetCoord(myXmax,myYmin); - myFrame->SetValue(4,v); - break; - case Graphic2d_TOF_CIRCULAR : - { - Standard_ShortReal precis,coef,radius; - radius = Standard_ShortReal(Sqrt( (myXmax - myXmin) * (myXmax - myXmin) + - (myYmax - myYmin) * (myYmax - myYmin) ) / 2.); - radius += Standard_ShortReal(myFrameMargin1); - Standard_ShortReal x0 = Standard_ShortReal((myXmax + myXmin)/2.); - Standard_ShortReal y0 = Standard_ShortReal((myYmax + myYmin)/2.); - myXmin = x0 - radius; - myYmin = y0 - radius; - myXmax = x0 + radius; - myYmax = y0 + radius; - Aspect_TypeOfDeflection type; - aDrawer->DrawPrecision(precis,coef,type); - if( type == Aspect_TOD_RELATIVE) { - precis = radius * coef; - } - Standard_ShortReal value = Standard_ShortReal(M_PI / 4.); - if( radius > precis ) - value = Standard_ShortReal(Max( 0.0044 , - Min (0.7854 , 2. * ACos(1.-precis/radius)))); - Standard_Integer n = Min(MAX_POINTS, - Standard_Integer(2. * M_PI / value)+2); - Standard_ShortReal da = Standard_ShortReal(2. * M_PI / n); - Standard_ShortReal cosin = Standard_ShortReal(Cos(da)); - Standard_ShortReal x1 = radius; - Standard_ShortReal y1 = 0.; - Standard_ShortReal x2 = radius * cosin; - Standard_ShortReal y2 = Standard_ShortReal(radius * Sin(da)); - Standard_ShortReal x,y; - - if( myFrame.IsNull() || (myFrame->Length() != n) ) { - myFrame = new Graphic2d_HArray1OfVertex(1,n); - } - v.SetCoord(x0+x1,y0+y1); - myFrame->SetValue(1,v); - v.SetCoord(x0+x2,y0+y2); - myFrame->SetValue(2,v); - for (Standard_Integer i=3; i<=n; i++) { - x = Standard_ShortReal(2.*x2*cosin - x1); x1 = x2; x2 = x; - y = Standard_ShortReal(2.*y2*cosin - y1); y1 = y2; y2 = y; - v.SetCoord(x0+x,y0+y); - myFrame->SetValue(i,v); - } - break; - } - default: - break; - } else { - myXmin = myYmin = RealLast(); - myXmax = myYmax = RealFirst(); - } - } - - if( !myFrame.IsNull() && (myXmax > myXmin) && (myYmax > myYmin) ) { - Standard_Real xmin,ymin,xmax,ymax; - Standard_Boolean transform = Standard_False; - gp_GTrsf2d theTrsf; - xmin = myXmin; ymin = myYmin; - xmax = myXmax; ymax = myYmax; - if( IsTransformed() ) { - transform = Standard_True; - theTrsf = Transform(); - TransformMinMax(theTrsf,xmin,xmax,ymin,ymax); - } - - if( aDrawer->IsIn ( - Standard_ShortReal(xmin), Standard_ShortReal(xmax), - Standard_ShortReal(ymin),Standard_ShortReal(ymax)) ) { - if( IsHighlighted() ) { - aDrawer->SetOverride ( Standard_True ); - aDrawer->SetOverrideColor ( myOverrideColor ); - } else { - aDrawer->SetOffSet ( myOffSet ); - } - - aDrawer->SetHidingPolyAttrib (myHidingColorIndex, - myFrameColorIndex,myFrameTypeIndex,myFrameWidthIndex); - - Standard_Real x,y; - Standard_Integer i,l = myFrame->Length(),mode = l; - for( i=1 ; i<=l ; i++ ) { - (myFrame->Value(i)).Coord(x,y); - if( transform ) { - theTrsf.Transforms(x,y); - } - if( i >= l ) mode = -1; -#ifdef TRACE -cout << " Graphic2d_HidingGraphicObject::Draw(" << x << "," << y << "," << mode << endl; -#endif - aDrawer->MapPolygonFromTo(Standard_ShortReal(x), - Standard_ShortReal(y),mode); - mode = 0; - } - } - } - - Graphic2d_GraphicObject::Draw(aDrawer,Reset); -} - -void Graphic2d_HidingGraphicObject::Draw(const Handle_Graphic2d_Drawer& aDrawer, const Handle_Graphic2d_Primitive& aPrim) -{ - Graphic2d_GraphicObject::Draw(aDrawer,aPrim); -} - -Standard_Boolean Graphic2d_HidingGraphicObject::Pick (const Standard_Real X, const Standard_Real Y, const Standard_Real aPrecision, const Handle(Graphic2d_Drawer)& aDrawer) { -Standard_Boolean status = Standard_False; - -#ifndef G002 - myPickedIndex = 0; -#endif - if( IsPickable() && (IsDisplayed() || IsHighlighted()) ) { - - if( myIsComputed ) { - Standard_Real xx = X, yy = Y; - Standard_Real xmin = myXmin - aPrecision; - Standard_Real ymin = myYmin - aPrecision; - Standard_Real xmax = myXmax + aPrecision; - Standard_Real ymax = myYmax + aPrecision; - if( IsTransformed() ) { - gp_GTrsf2d aTrsf = (Transform ()).Inverted (); - aTrsf.Transforms (xx, yy); - } - if( (xx > xmin) && (xx < xmax) && - (yy > ymin) && (yy < ymax) ) { - switch (myTypeOfFrame) { - case Graphic2d_TOF_UNKNOWN : - status = (myFrame.IsNull()) ? Standard_False : Standard_True; - break; - - case Graphic2d_TOF_RECTANGULAR : - status = Standard_True; - break; - - case Graphic2d_TOF_CIRCULAR : - { - Standard_Real x = (xmin + xmax)/2.; - Standard_Real y = (ymin + ymax)/2.; - Standard_Real r = xmax - x; - if( Sqrt ((x - xx)*(x - xx) + (y - yy)*(y - yy)) < r ) - status = Standard_True; - } - break; - } - } - } - - if( !status ) - status = Graphic2d_GraphicObject::Pick(X,Y,aPrecision,aDrawer); -#ifdef G002 - else SetPickedIndex(0); -#endif - } - - return status; -} - -Standard_Boolean Graphic2d_HidingGraphicObject::FrameMinMax (Quantity_Length & Minx, Quantity_Length &Maxx, Quantity_Length & Miny, Quantity_Length & Maxy) const { -Standard_Boolean status = Standard_False; - - if( !myFrame.IsNull() && (myXmax > myXmin) && (myYmax > myYmin) ) { - Standard_Real xmin,ymin,xmax,ymax; - xmin = myXmin; ymin = myYmin; - xmax = myXmax; ymax = myYmax; - if( IsTransformed() ) { - gp_GTrsf2d theTrsf = Transform(); - TransformMinMax(theTrsf,xmin,xmax,ymin,ymax); - } - status = Standard_True; - Minx = xmin; - Miny = ymin; - Maxx = xmax; - Maxy = ymax; - } else { - Minx = RealFirst(); - Miny = RealFirst(); - Maxx = RealLast(); - Maxy = RealLast(); - } - - return status; -} - -Standard_Boolean Graphic2d_HidingGraphicObject::MinMax (Quantity_Length & Minx, Quantity_Length &Maxx, Quantity_Length & Miny, Quantity_Length & Maxy) const { - - Standard_Boolean status = - Graphic2d_GraphicObject::MinMax(Minx,Maxx,Miny,Maxy); - - Standard_Real xmin,ymin,xmax,ymax; - if( this->FrameMinMax(xmin,ymin,xmax,ymax) ) { - if( status ) { - Minx = Min(Minx,xmin); - Miny = Min(Miny,ymin); - Maxx = Min(Maxx,xmax); - Maxy = Min(Maxy,ymax); - } else { - status = Standard_True; - Minx = xmin; - Miny = ymin; - Maxx = xmax; - Maxy = ymax; - } - } - - return status; -} - -Graphic2d_TypeOfFrame Graphic2d_HidingGraphicObject::Frame( Graphic2d_Array1OfVertex& aFrame) const { -//Graphic2d_Vertex v; -//Standard_Real x,y; - - aFrame = myFrame->Array1(); - return myTypeOfFrame; -} - -Standard_Integer Graphic2d_HidingGraphicObject::HidingColorIndex() const { - - return myHidingColorIndex; -} - -Standard_Integer Graphic2d_HidingGraphicObject::FrameColorIndex() const { - - return myFrameColorIndex; -} - -Standard_Integer Graphic2d_HidingGraphicObject::FrameTypeIndex() const { - - return myFrameTypeIndex; -} - -Standard_Integer Graphic2d_HidingGraphicObject::FrameWidthIndex() const { - - return myFrameWidthIndex; -} - -void Graphic2d_HidingGraphicObject::TransformMinMax (const gp_GTrsf2d& aTrsf,Standard_Real & Minx, Standard_Real &Maxx, Standard_Real & Miny, Standard_Real & Maxy) const { - - Standard_Real xx,yy,xmin,ymin,xmax,ymax; - xmin = ymin = RealLast(); - xmax = ymax = RealFirst(); - - xx = Minx; yy = Miny; - aTrsf.Transforms (xx,yy); - xmin = Min(xmin,xx) ; - ymin = Min(ymin,yy); - xmax = Max(xmax,xx) ; - ymax = Max(ymax,yy); - - xx = Minx; yy = Maxy; - aTrsf.Transforms (xx,yy); - xmin = Min(xmin,xx) ; - ymin = Min(ymin,yy); - xmax = Max(xmax,xx) ; - ymax = Max(ymax,yy); - - xx = Maxx; yy = Maxy; - aTrsf.Transforms (xx,yy); - xmin = Min(xmin,xx) ; - ymin = Min(ymin,yy); - xmax = Max(xmax,xx) ; - ymax = Max(ymax,yy); - - xx = Maxx; yy = Miny; - aTrsf.Transforms (xx,yy); - Minx = Min(xmin,xx) ; - Miny = Min(ymin,yy); - Maxx = Max(xmax,xx) ; - Maxy = Max(ymax,yy); -} diff --git a/src/Graphic2d/Graphic2d_HidingText.cdl b/src/Graphic2d/Graphic2d_HidingText.cdl deleted file mode 100755 index 44c0f54562..0000000000 --- a/src/Graphic2d/Graphic2d_HidingText.cdl +++ /dev/null @@ -1,203 +0,0 @@ --- Created on: 1995-06-09 --- Created by: Gerard GRAS --- Copyright (c) 1995-1999 Matra Datavision --- Copyright (c) 1999-2012 OPEN CASCADE SAS --- --- The content of this file is subject to the Open CASCADE Technology Public --- License Version 6.5 (the "License"). You may not use the content of this file --- except in compliance with the License. Please obtain a copy of the License --- at http://www.opencascade.org and read it completely before using this file. --- --- The Initial Developer of the Original Code is Open CASCADE S.A.S., having its --- main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. --- --- The Original Code and all software distributed under the License is --- distributed on an "AS IS" basis, without warranty of any kind, and the --- Initial Developer hereby disclaims all such warranties, including without --- limitation, any warranties of merchantability, fitness for a particular --- purpose or non-infringement. Please see the License for the specific terms --- and conditions governing the rights and limitations under the License. - - - - -class HidingText from Graphic2d inherits Text from Graphic2d - - ---Version: - - ---Purpose: The primitive HidingText - -- is a Text above a surounded hiding polygon. - -- The text foreground color depends of the - -- SetColorIndex() method. - -- The polygon background color of the - -- SetHidingColorIndex() method. - -- The outline frame foreground color and width depends - -- of the SetFrameColorIndex() & SetFrameWidthIndex() methods. - - ---Keywords: Primitive, Text - ---Warning: - ---References: - -uses - - Drawer from Graphic2d, - GraphicObject from Graphic2d, - PlaneAngle from Quantity, - Ratio from Quantity, - Length from Quantity, - Factor from Quantity, - ExtendedString from TCollection, - TypeOfText from Aspect, - FStream from Aspect, - IFStream from Aspect - - -is - ------------------------- - -- Category: Constructors - ------------------------- - - Create (aGraphicObject: GraphicObject from Graphic2d; - aText: ExtendedString from TCollection; - X, Y: Real from Standard; - anAngle: PlaneAngle from Quantity = 0.0; - aMargin: Ratio from Quantity = 0.1; - aType: TypeOfText from Aspect = Aspect_TOT_SOLID; - aScale: Factor from Quantity = 1.0) - returns mutable HidingText from Graphic2d; - ---Level: Public - ---Purpose: Creates a text in a graphic object - -- The text is . - -- The reference point is , . - -- The orientation angle is . - -- The margin ratio is ,defines the proportional - -- margin between the text height and the outline frame. - -- The type of text is and must be one of : - -- Aspect_TOT_SOLID, - -- Aspect_TOT_OUTLINE - -- The scale factor apply to the original font size, - -- Angles are measured counterclockwise with 0 radian - -- at 3 o'clock. - -- Warning: a text can be orientable,slantable,zoomable or outlinable - -- only when this options are enable regardless of the graphic driver. - -- i.e: Xw driver does not,but Xdps or PS driver does. - - --------------------------------------------------- - -- Category: Methods to modify the class definition - --------------------------------------------------- - - SetFrameColorIndex (me:mutable; anIndex: Integer from Standard = 0) - is static; - ---Level: Public - ---Purpose: Sets the color index for the frame of the hiding text . - -- default color is 0 (no out line frame is drawn). - - SetFrameWidthIndex (me:mutable; anIndex: Integer from Standard = 0) - is static; - ---Level: Public - ---Purpose: Sets the width index for the frame of the hiding text . - -- default width is 0 (1 pixel out line frame is drawn). - - SetHidingColorIndex (me:mutable; anIndex: Integer from Standard = 0) - is static; - ---Level: Public - ---Purpose: Sets the interior color index for the frame of the hiding text . - -- default color is 0 (the current view background color). - - Fit (me:mutable; aWidth,aHeight: Length from Quantity; - Adjust: Boolean from Standard = Standard_True; - Expand: Boolean from Standard = Standard_True) - returns Boolean from Standard is redefined; - ---Level: Public - ---Purpose: Compute text size depending of a required bounding box, - -- Adjust the text position depending of the text origine - -- and base line if Adjust is TRUE, - -- Expand the text when the Width is smaller that the - -- Fit Width if "Expand" is TRUE. - -- and returns Standard_True if the current Driver used is - -- enable to fit the text size. - -- Warning: The fit computation is apply only if the corresponding - -- dimension is > 0. - - Trunc (me:mutable; aWidth: Length from Quantity) - returns Boolean from Standard is redefined; - ---Level: Public - ---Purpose: Trunc the text when the Width of the text is greater - -- that the defined Width Max, - -- and returns Standard_True if the current Driver used is - -- enable to trunc the text size. - - -------------------------- - -- Category: Draw and Pick - -------------------------- - - Draw (me : mutable; aDrawer: Drawer from Graphic2d) - is redefined protected; - ---Level: Internal - ---Purpose: Draws the text . - - Pick (me : mutable; X, Y: ShortReal from Standard; - aPrecision: ShortReal from Standard; - aDrawer: Drawer from Graphic2d) - returns Boolean from Standard - is redefined protected; - ---Level: Internal - ---Purpose: Returns Standard_True if the text is picked, - -- Standard_False if not. - - - ---------------------------- - -- Category: Inquire methods - ---------------------------- - - TextSize (me; aWidth,aHeight,anXoffset,anYoffset: out Length from Quantity) - returns Boolean from Standard is redefined; - ---Level: Public - ---Purpose: Returns Standard_True if the current Driver used is enabled - -- to get the right size and hiding text offsets in the - -- world size parameter ,,, - -- depending of the attributes of the text and the current scale - -- of the view. - -- NOTE that the text offsets defines the relative position of the - -- of the text string origin from the lower left corner of the hiding text - -- boundary limits. - ---Category: Text management - - - Margin (me) returns Ratio from Quantity is static; - ---Level: Public - ---Purpose: Returns the text margin. - - HidingColorIndex (me) returns Integer from Standard is static; - ---Level: Public - ---Purpose: Returns the text hiding color index. - - FrameColorIndex (me) returns Integer from Standard is static; - ---Level: Public - ---Purpose: Returns the text frame color index. - - FrameWidthIndex (me) returns Integer from Standard is static; - ---Level: Public - ---Purpose: Returns the text frame width index. - - ---------------------------- - -- Category: Private methods - ---------------------------- - - ComputeMinMax (me : mutable) - returns Boolean from Standard is redefined private; - ---Level: Internal - ---Purpose: Computes the MinMax of the text if possible. - - ---------------------------------------------------------------------- - - Save( me; aFStream: in out FStream from Aspect ) is virtual; --- Retrieve( myclass; anIFStream: in out IFStream from Aspect ); - -fields - myHidingColorIndex: Integer from Standard; - myFrameColorIndex: Integer from Standard; - myFrameWidthIndex: Integer from Standard; - myMargin: ShortReal from Standard; - -end HidingText from Graphic2d; diff --git a/src/Graphic2d/Graphic2d_HidingText.cxx b/src/Graphic2d/Graphic2d_HidingText.cxx deleted file mode 100755 index ce92231b17..0000000000 --- a/src/Graphic2d/Graphic2d_HidingText.cxx +++ /dev/null @@ -1,450 +0,0 @@ -// Copyright (c) 1995-1999 Matra Datavision -// Copyright (c) 1999-2012 OPEN CASCADE SAS -// -// The content of this file is subject to the Open CASCADE Technology Public -// License Version 6.5 (the "License"). You may not use the content of this file -// except in compliance with the License. Please obtain a copy of the License -// at http://www.opencascade.org and read it completely before using this file. -// -// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its -// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. -// -// The Original Code and all software distributed under the License is -// distributed on an "AS IS" basis, without warranty of any kind, and the -// Initial Developer hereby disclaims all such warranties, including without -// limitation, any warranties of merchantability, fitness for a particular -// purpose or non-infringement. Please see the License for the specific terms -// and conditions governing the rights and limitations under the License. - -#define PRO6894 //GG_150197 -// Complete cases of text justification -// S3824 10/06/98 : GG ; -// 1) Method "Fit" includes optional argument -// "Expand" allowing to not adjust the text width -// lorsque celle ci est < a la taille du FIT. -// 2) Method "Trunc" allows truncating the text to the -// indicated size. - -#define PRO14304 //GG_160698 -// Correct calculation error on MINMAX causing -// the text to disappear - -#define PERF //GG_200898 -// The MinMax are now computed at the right time and no more -// soon an attribute has change -// (see the redefined method ComputeMinMax()). - -#define BUC60583 //GG_300999 Enable to compute correctly a -// Mirror transformation - -#include -#include - -#include - -Graphic2d_HidingText::Graphic2d_HidingText - (const Handle(Graphic2d_GraphicObject)& aGraphicObject, - const TCollection_ExtendedString& aText, - const Standard_Real X, const Standard_Real Y, - const Quantity_PlaneAngle anAngle, - const Quantity_Ratio aMargin, - const Aspect_TypeOfText aType, - const Quantity_Factor aScale) - : Graphic2d_Text (aGraphicObject,aText,X,Y,anAngle,aType,aScale), - myMargin( Standard_ShortReal( aMargin ) ) { - - SetHidingColorIndex(); - SetFrameColorIndex(); - SetFrameWidthIndex(); - -#ifndef PERF - ComputeMinMax(); -#endif -} - -void Graphic2d_HidingText::SetHidingColorIndex (const Standard_Integer anIndex) { - - myHidingColorIndex = anIndex; - -} - -void Graphic2d_HidingText::SetFrameColorIndex (const Standard_Integer anIndex) { - - myFrameColorIndex = anIndex; - -} - -void Graphic2d_HidingText::SetFrameWidthIndex (const Standard_Integer anIndex) { - - myFrameWidthIndex = anIndex; - -} - -void Graphic2d_HidingText::Draw (const Handle(Graphic2d_Drawer)& aDrawer) { -Standard_Boolean IsIn = Standard_False; -Standard_ShortReal hscale = (myIsZoomable) ? - Standard_ShortReal( myHScale * aDrawer->Scale() ) - : Standard_ShortReal( myHScale ); -Standard_ShortReal wscale = (myIsZoomable) ? - Standard_ShortReal( myWScale * aDrawer->Scale() ) - : Standard_ShortReal( myWScale ); -Standard_ShortReal ox = aDrawer->ConvertMapToFrom(myDeltax); -Standard_ShortReal oy = aDrawer->ConvertMapToFrom(myDeltay); - -#ifdef PERF - if( (myMaxX < myMinX) || (myMaxY < myMinY) ) { - if( !ComputeMinMax() ) return; - } -#else - if( myResetFlag ) { - ComputeMinMax(); - } -#endif - - if (! myGOPtr->IsTransformed ()) { - IsIn = aDrawer->IsIn (myMinX+ox,myMaxX+ox,myMinY+oy,myMaxY+oy); - if (IsIn) { - aDrawer->SetHidingTextAttrib(myColorIndex,myHidingColorIndex, - myFrameColorIndex,myFrameWidthIndex, - myFontIndex,mySlant,hscale,wscale,myIsUnderlined); - Standard_ShortReal dx = myDx,dy = myDy; - if( myAngle != 0. ) { - Standard_ShortReal cosa = Standard_ShortReal( Cos(myAngle) ); - Standard_ShortReal sina = Standard_ShortReal( Sin(myAngle) ); - - dx = XROTATE(myDx,myDy) ; - dy = YROTATE(myDx,myDy) ; - } - aDrawer->MapPolyTextFromTo(myText,myX+dx,myY+dy,myAngle,myMargin, - myDeltax,myDeltay,myType); - } - } else { - Standard_ShortReal minx,maxx,miny,maxy; - gp_GTrsf2d aTrsf = myGOPtr->Transform (); - MinMax(minx,maxx,miny,maxy); - IsIn = aDrawer->IsIn (minx+ox,maxx+ox,miny+oy,maxy+oy); - if (IsIn) { - Standard_Real A = Standard_Real (myX); - Standard_Real B = Standard_Real (myY); - Standard_Real C = Standard_Real (myAngle); - Standard_Real cosa = Cos (C); - Standard_Real sina = Sin (C); - aTrsf.Transforms (A, B); - Standard_ShortReal a = Standard_ShortReal (A); - Standard_ShortReal b = Standard_ShortReal (B); -#ifdef BUC60583 - aTrsf.Transforms (cosa, sina); - A = B = 0.; - aTrsf.Transforms (A, B); - cosa -= A; sina -= B; - if( aTrsf.IsNegative() ) hscale = - hscale; -#else - // To calculate new aperture angles - // calculation is done on the trigonometric circle - // and in this case translation is taken into account. - aTrsf.SetValue (1, 3, 0.0); - aTrsf.SetValue (2, 3, 0.0); - aTrsf.Transforms (cosa, sina); -#endif - Standard_ShortReal angle = Standard_ShortReal (atan2(sina,cosa)); - - if( myIsZoomable ) { - hscale *= Standard_ShortReal (Sqrt(cosa*cosa + sina*sina)); - wscale *= Standard_ShortReal (Sqrt(cosa*cosa + sina*sina)); - } - aDrawer->SetHidingTextAttrib(myColorIndex,myHidingColorIndex, - myFrameColorIndex,myFrameWidthIndex, - myFontIndex,mySlant,hscale,wscale,myIsUnderlined); - Standard_ShortReal dx = myDx,dy = myDy; - if( angle != 0. ) { - dx = Standard_ShortReal( XROTATE(myDx,myDy) ); - dy = Standard_ShortReal( YROTATE(myDx,myDy) ); - } - a += dx; b += dy; - aDrawer->MapPolyTextFromTo(myText,a,b,angle,myMargin, - myDeltax,myDeltay,myType); - } - } - -} - - -Standard_Boolean Graphic2d_HidingText::Pick (const Standard_ShortReal X, - const Standard_ShortReal Y, - const Standard_ShortReal aPrecision, - const Handle(Graphic2d_Drawer)& aDrawer) -{ - -Standard_Boolean theStatus = Standard_False; -Standard_ShortReal width,height,xoffset,yoffset,mwidth,mheight; -Standard_ShortReal hscale = (myIsZoomable) ? - Standard_ShortReal( myHScale * aDrawer->Scale() ) - : Standard_ShortReal( myHScale ); -Standard_ShortReal wscale = (myIsZoomable) ? - Standard_ShortReal( myWScale * aDrawer->Scale() ) - : Standard_ShortReal( myWScale ); -Standard_ShortReal TX = X, TY = Y; -Standard_ShortReal ox = aDrawer->ConvertMapToFrom(myDeltax); -Standard_ShortReal oy = aDrawer->ConvertMapToFrom(myDeltay); - - if (IsInMinMax (X-ox, Y-oy, aPrecision)) { - if (myGOPtr->IsTransformed ()) { - gp_GTrsf2d aTrsf = (myGOPtr->Transform ()).Inverted (); - Standard_Real RX = Standard_Real (X), RY = Standard_Real (Y); - aTrsf.Transforms (RX, RY); - TX = Standard_ShortReal (RX); TY = Standard_ShortReal (RY); - } - aDrawer->SetTextAttrib(myColorIndex,myFontIndex, - mySlant,hscale,wscale,myIsUnderlined); - if( !aDrawer->GetTextSize(myText,width,height,xoffset,yoffset) ) { - mwidth = mheight = width = height = xoffset = yoffset = 0.; - } else { - mwidth = mheight = height*myMargin; - } - Standard_ShortReal cosa = Standard_ShortReal( Cos(-myAngle) ); - Standard_ShortReal sina = Standard_ShortReal( Sin(-myAngle) ); - Standard_ShortReal dx = TX-(myX+ox+myDx); - Standard_ShortReal dy = TY-(myY+oy+myDy); - Standard_ShortReal x = XROTATE(dx,dy); - Standard_ShortReal y = YROTATE(dx,dy); - - theStatus = (x >= -mwidth + xoffset - aPrecision) - && (x <= width + mwidth + xoffset + aPrecision) - && (y >= - mheight - yoffset - aPrecision) - && (y <= height + mheight - yoffset + aPrecision); - } - - return theStatus; -} - -Standard_Boolean Graphic2d_HidingText::TextSize ( Quantity_Length &aWidth, - Quantity_Length &aHeight, - Quantity_Length &anXoffset, - Quantity_Length &anYoffset) const { -Handle(Graphic2d_Drawer) aDrawer = Drawer(); - - if( !aDrawer.IsNull() && aDrawer->IsWindowDriver() ) { - Standard_ShortReal hscale = (myIsZoomable) ? - Standard_ShortReal( myHScale * aDrawer->Scale() ) - : Standard_ShortReal( myHScale ); - Standard_ShortReal wscale = (myIsZoomable) ? - Standard_ShortReal( myWScale * aDrawer->Scale() ) - : Standard_ShortReal( myWScale ); - Standard_ShortReal width,height,xoffset,yoffset; - aDrawer->SetTextAttrib(myColorIndex,myFontIndex, - mySlant,hscale,wscale,myIsUnderlined); - - aDrawer->GetTextSize(myText,width,height,xoffset,yoffset); - aWidth = width + 2.*height*myMargin; - aHeight = height + 2.*height*myMargin; - anXoffset = xoffset - height*myMargin; - anYoffset = yoffset + height*myMargin; - return Standard_True; - } else { - aWidth = aHeight = anXoffset = anYoffset = 0.; - return Standard_False; - } - -} - -Standard_Integer Graphic2d_HidingText::HidingColorIndex() const { - - return myHidingColorIndex; -} - -Standard_Integer Graphic2d_HidingText::FrameColorIndex() const { - - return myFrameColorIndex; -} - -Standard_Integer Graphic2d_HidingText::FrameWidthIndex() const { - - return myFrameWidthIndex; -} - -Quantity_Ratio Graphic2d_HidingText::Margin() const { - - return Quantity_Ratio(myMargin); -} - -Standard_Boolean Graphic2d_HidingText::Fit(const Quantity_Length aWidth,const Quantity_Length aHeight,const Standard_Boolean Adjust,const Standard_Boolean Expand) { -Quantity_Length twidth,theight,xoffset,yoffset; -Standard_ShortReal wscale,hscale; -Standard_Boolean status; - - myAdjustFlag = Adjust; - if(( status = TextSize(twidth,theight,xoffset,yoffset) )) { - wscale = Standard_ShortReal( aWidth/twidth ); - if( wscale > 0. ) { - if( Expand || (twidth > aWidth) ) myWScale *= wscale; - } - hscale = Standard_ShortReal( aHeight/theight ); - if( hscale > 0. ) myHScale *= hscale; -#ifdef PERF - myMinX = myMinY = ShortRealLast (); - myMaxX = myMaxY = ShortRealFirst (); -#else - myResetFlag = Standard_True; - ComputeMinMax(); -#endif - } - - return status; -} - -Standard_Boolean Graphic2d_HidingText::Trunc(const Quantity_Length aWidth) { -Quantity_Length twidth,theight,txoffset,tyoffset; -//Standard_ShortReal wscale,hscale; -Standard_Boolean status; - - if(( status = TextSize(twidth,theight,txoffset,tyoffset) )) { - Standard_Integer l = myText.Length(); - while( (l > 1) && (twidth > aWidth) ) { - --l; - myText.Split(l); - TextSize(twidth,theight,txoffset,tyoffset); - } -#ifdef PERF - myMinX = myMinY = ShortRealLast (); - myMaxX = myMaxY = ShortRealFirst (); -#else - myResetFlag = Standard_True; - this->ComputeMinMax(); -#endif - } - - return status; -} - -Standard_Boolean Graphic2d_HidingText::ComputeMinMax() { -Handle(Graphic2d_Drawer) aDrawer = Drawer(); -Standard_Boolean status = Standard_False; - - if( !aDrawer.IsNull() && aDrawer->IsWindowDriver() ) { - Standard_ShortReal hscale = - (myIsZoomable) ? - Standard_ShortReal( myHScale * aDrawer->Scale() ) - : Standard_ShortReal( myHScale ); - Standard_ShortReal wscale = - (myIsZoomable) ? - Standard_ShortReal( myWScale * aDrawer->Scale() ) - : Standard_ShortReal( myWScale ); - Standard_ShortReal width,height,xoffset,yoffset; - aDrawer->SetTextAttrib(myColorIndex,myFontIndex, - mySlant,hscale,wscale,myIsUnderlined); - if(( status = aDrawer->GetTextSize(myText,width,height,xoffset,yoffset) )) { - Standard_ShortReal dxm,dym; -#ifndef PERF - myResetFlag = Standard_False; -#endif - dxm = dym = height*myMargin ; - switch( myAlignment ) { - case Graphic2d_TOA_LEFT: - myDx = myDy = 0.; - break; - case Graphic2d_TOA_RIGHT: - myDx = -width; myDy = 0.; - break; - case Graphic2d_TOA_CENTER: - myDx = Standard_ShortReal( -width/2. ); myDy = 0.; - break; -#ifdef PRO6894 - case Graphic2d_TOA_TOPLEFT: - myDx = 0.; myDy = yoffset-height; - break; - case Graphic2d_TOA_TOPRIGHT: - myDx = -width; myDy = yoffset-height; - break; - case Graphic2d_TOA_TOPCENTER: - myDx = Standard_ShortReal( -width/2. ); myDy = yoffset-height; - break; - case Graphic2d_TOA_MEDIUMLEFT: - myDx = 0.; myDy = Standard_ShortReal( (yoffset-height)/2. ); - break; - case Graphic2d_TOA_MEDIUMRIGHT: - myDx = -width; myDy = Standard_ShortReal( (yoffset-height)/2. ); - break; - case Graphic2d_TOA_MEDIUMCENTER: - myDx = Standard_ShortReal( -width/2. ); - myDy = Standard_ShortReal( (yoffset-height)/2. ); - break; - case Graphic2d_TOA_BOTTOMLEFT: - myDx = 0.; myDy = yoffset; - break; - case Graphic2d_TOA_BOTTOMRIGHT: - myDx = -width; myDy = yoffset; - break; - case Graphic2d_TOA_BOTTOMCENTER: - myDx = Standard_ShortReal( -width/2. ); myDy = yoffset; - break; -#endif - } - if( myAdjustFlag ) { - myDx += dxm - xoffset; myDy += dym + yoffset; - } - Standard_ShortReal xmin = myDx - dxm + xoffset; - Standard_ShortReal ymin = myDy - dym - yoffset; - Standard_ShortReal xmax = xmin + width + 2*dxm; - Standard_ShortReal ymax = ymin + height + 2*dym; - - myMinX = myMinY = ShortRealLast(); - myMaxX = myMaxY = ShortRealFirst(); - if( myAngle != 0. ) { - Standard_ShortReal cosa = Standard_ShortReal( Cos(myAngle) ); - Standard_ShortReal sina = Standard_ShortReal( Sin(myAngle) ); - Standard_ShortReal dx,dy; - dx = XROTATE(xmin,ymin) ; - dy = YROTATE(xmin,ymin) ; - myMinX = Min(myMinX,myX+dx) ; - myMinY = Min(myMinY,myY+dy) ; - myMaxX = Max(myMaxX,myX+dx) ; - myMaxY = Max(myMaxY,myY+dy) ; - - dx = XROTATE(xmin,ymin) ; - dy = YROTATE(xmin,ymin) ; - myMinX = Min(myMinX,myX+dx) ; - myMinY = Min(myMinY,myY+dy) ; - myMaxX = Max(myMaxX,myX+dx) ; - myMaxY = Max(myMaxY,myY+dy) ; - - dx = XROTATE(xmax,ymax) ; - dy = YROTATE(xmax,ymax) ; - myMinX = Min(myMinX,myX+dx) ; - myMinY = Min(myMinY,myY+dy) ; - myMaxX = Max(myMaxX,myX+dx) ; - myMaxY = Max(myMaxY,myY+dy) ; - - dx = XROTATE(xmax,ymin) ; - dy = YROTATE(xmax,ymin) ; - myMinX = Min(myMinX,myX+dx) ; - myMinY = Min(myMinY,myY+dy) ; - myMaxX = Max(myMaxX,myX+dx) ; - myMaxY = Max(myMaxY,myY+dy) ; - } else { -#ifdef PRO14304 - myMinX = Min(myMinX,myX+xmin) ; - myMinY = Min(myMinY,myY+ymin) ; - myMaxX = Max(myMaxX,myX+xmax) ; - myMaxY = Max(myMaxY,myY+ymax) ; -#else - myMinX = Min(myMinX,xmin) ; - myMinY = Min(myMinY,ymin) ; - myMaxX = Max(myMaxX,xmax) ; - myMaxY = Max(myMaxY,ymax) ; -#endif - } - } - } -#ifdef PERF - else { - cout << "*Graphic2d_HidingText::ComputeMinMax() returns wrong values*" - << endl; - } -#endif - - return status; -} - -void Graphic2d_HidingText::Save(Aspect_FStream& aFStream) const -{ -} diff --git a/src/Graphic2d/Graphic2d_Image.cdl b/src/Graphic2d/Graphic2d_Image.cdl deleted file mode 100755 index 8602ef67ee..0000000000 --- a/src/Graphic2d/Graphic2d_Image.cdl +++ /dev/null @@ -1,217 +0,0 @@ --- Created on: 1993-06-22 --- Created by: Jean Louis FRENKEL, Gerard GRAS --- Copyright (c) 1993-1999 Matra Datavision --- Copyright (c) 1999-2012 OPEN CASCADE SAS --- --- The content of this file is subject to the Open CASCADE Technology Public --- License Version 6.5 (the "License"). You may not use the content of this file --- except in compliance with the License. Please obtain a copy of the License --- at http://www.opencascade.org and read it completely before using this file. --- --- The Initial Developer of the Original Code is Open CASCADE S.A.S., having its --- main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. --- --- The Original Code and all software distributed under the License is --- distributed on an "AS IS" basis, without warranty of any kind, and the --- Initial Developer hereby disclaims all such warranties, including without --- limitation, any warranties of merchantability, fitness for a particular --- purpose or non-infringement. Please see the License for the specific terms --- and conditions governing the rights and limitations under the License. - - --- Modified: TCL G002A, 28-11-00, new section "inquire methods" - - -class Image from Graphic2d inherits Primitive from Graphic2d - - ---Version: - - ---Purpose: This class defines the primitive Image - - ---Keywords: Primitive, Image - ---Warning: - ---References: - -uses - Drawer from Graphic2d, - Image from Image, - GraphicObject from Graphic2d, - Length from Quantity, - CardinalPoints from Aspect, - FStream from Aspect, - IFStream from Aspect - - -is - ------------------------- - -- Category: Constructors - ------------------------- - - Create (aGraphicObject: GraphicObject from Graphic2d; - anImage: Image from Image; - X, Y: Length from Quantity; - adx: Length from Quantity = 0.0; - ady: Length from Quantity = 0.0; - aTypeOfPlacement: CardinalPoints - from Aspect = Aspect_CP_Center) - returns mutable Image from Graphic2d; - ---Level: Public - ---Purpose: Defines an image with its center location; - -- , defines the position in the space model. - -- , defines an offset in the device space. - -- The image will be placed at this offset - -- according to the type of placement. - -- - -- CardinalPoints values : - -- - CP_North - -- - CP_NorthEast - -- - CP_East - -- - CP_SouthEast - -- - CP_South - -- - CP_SouthWest - -- - CP_West - -- - CP_NorthWest - -- - CP_Center - ---Category: Constructors - - -------------------------- - -- Category: Draw and Pick - -------------------------- - - Draw (me : mutable; aDrawer: Drawer from Graphic2d) - is static protected; - ---Level: Internal - ---Purpose: Draws the image at the required center location - -- defined by the SetCenter method. - - Pick (me : mutable; - X, Y: ShortReal from Standard; - aPrecision: ShortReal from Standard; - aDrawer: Drawer from Graphic2d) - returns Boolean from Standard is static protected; - ---Purpose: Returns Standard_True if the image is picked, - -- Standard_False if not. - - --------------------------------------------------- - -- Category: Methods to modify the class definition - --------------------------------------------------- - - SetCenter (me: mutable; - X, Y: Length from Quantity) - is static; - ---Level: Public - ---Purpose: Modifies the center location of the image . - ---Category: Methods to modify the class definition - - SetOffset (me: mutable; - dx, dy: Length from Quantity) - is static; - ---Level: Public - ---Purpose: Modifies the offset of the image . - ---Category: Methods to modify the class definition - - SetPlacement (me: mutable; aPlacement: CardinalPoints from Aspect) - is static; - ---Level: Public - ---Purpose: Modifies the type of placement of the image . - -- - -- CardinalPoints values : - -- - CP_North - -- - CP_NorthEast - -- - CP_East - -- - CP_SouthEast - -- - CP_South - -- - CP_SouthWest - -- - CP_West - -- - CP_NorthWest - -- - CP_Center - ---Category: Methods to modify the class definition - - Translate (me: mutable; - DX, DY: Length from Quantity) is static; - ---Level: Public - ---Purpose: Modifies the center location of the image - -- by translating it. - ---Category: Methods to modify the class definition - - Clear (me: mutable) is static; - ---Level: Public - ---Purpose: Clear the reference to this image if something - -- inside have changed,Forced the reload of this at Draw() - -- time. - ---Category: Methods to modify the class definition - - ------------------------------------------------------- - -- Category: Methods to manage the filling of the image - ------------------------------------------------------- - - SetSmallSize (myclass; aSize: Integer from Standard); - ---Level: Internal - ---Purpose: Defines the limit between a large image and a - -- small image. - -- Warning: A small image have Height*Width <= SmallSize (). - -- Default 4096 = 64*64 - ---Category: Methods to manage the filling of the image - - SmallSize (myclass) - returns Integer from Standard; - ---Level: Internal - ---Purpose: Returns the limit between a large image and a - -- small image. - -- Warning: A small image have Height*Width <= SmallSize (). - ---Category: Methods to manage the filling of the image - - -------------------------------------- - -- Category: Inquire methods - -------------------------------------- - - Position( me; X, Y: out Length from Quantity ); - ---Level: Public - ---Purpose: returns the position in the space model - - Offset( me; aX, aY: out Length from Quantity ); - ---Level: Public - ---Purpose: returns the offset in the device space - - Placement( me ) returns CardinalPoints from Aspect; - ---Level: Public - ---Purpose: returns the type of placement - - Image( me ) returns Image from Image; - ---Level: Public - ---Purpose: returns the image - - ---------------------------- - -- Category: Private methods - ---------------------------- - - FillAndDraw (me; aDrawer: Drawer from Graphic2d) - is static private; - ---Level: Internal - ---Purpose: Fills the image in the drawer . - ---Category: Private methods - - ComputeCenter (me; - aDrawer: Drawer from Graphic2d; - cx, cy: out ShortReal from Standard) - is static private; - ---Level: Internal - ---Purpose: Evaluates the center of the image in the device space. - -- Called by the methods Graphic2d_Image::Draw, - -- Graphic2d_Image::Pick and Graphic2d_Image::FillAndDraw. - ---Category: Private methods - - ---------------------------------------------------------------------- - - Save( me; aFStream: in out FStream from Aspect ) is virtual; --- Retrieve( me; aIFStream: in out IFStream from AIS2D ) is virtual; - -fields - - myImage: Image from Image; - myX, myY: ShortReal from Standard; - mydx, mydy: ShortReal from Standard; - myPlacement: CardinalPoints from Aspect; - myIsModified: Boolean from Standard; - -end Image from Graphic2d; diff --git a/src/Graphic2d/Graphic2d_Image.cxx b/src/Graphic2d/Graphic2d_Image.cxx deleted file mode 100755 index 9315cd7c4e..0000000000 --- a/src/Graphic2d/Graphic2d_Image.cxx +++ /dev/null @@ -1,373 +0,0 @@ -// Copyright (c) 1995-1999 Matra Datavision -// Copyright (c) 1999-2012 OPEN CASCADE SAS -// -// The content of this file is subject to the Open CASCADE Technology Public -// License Version 6.5 (the "License"). You may not use the content of this file -// except in compliance with the License. Please obtain a copy of the License -// at http://www.opencascade.org and read it completely before using this file. -// -// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its -// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. -// -// The Original Code and all software distributed under the License is -// distributed on an "AS IS" basis, without warranty of any kind, and the -// Initial Developer hereby disclaims all such warranties, including without -// limitation, any warranties of merchantability, fitness for a particular -// purpose or non-infringement. Please see the License for the specific terms -// and conditions governing the rights and limitations under the License. - -#define WTO0001 //GG_140596 - -#define PRO5663 //GG_291196 - -#include -#include -#include -#include -#include -#include - -Graphic2d_Image::Graphic2d_Image (const Handle(Graphic2d_GraphicObject)& aGraphicObject, const Handle(Image_Image)& anImage, const Quantity_Length X, const Quantity_Length Y, const Quantity_Length adx, const Quantity_Length ady, const Aspect_CardinalPoints aTypeOfPlacement) - : Graphic2d_Primitive (aGraphicObject) , - myImage(anImage), - mydx(Standard_ShortReal(adx)), - mydy(Standard_ShortReal(ady)), - myPlacement(aTypeOfPlacement), - myIsModified(Standard_False) { - - SetFamily(Graphic2d_TOP_IMAGE); - SetCenter(X,Y); -#ifndef PRO5663 - myMinX = myX; myMinY = myY; - myMaxX = myX; myMaxY = myY; -#endif -} - -void Graphic2d_Image::Clear () { - - myIsModified = Standard_True; -} - -void Graphic2d_Image::Draw (const Handle(Graphic2d_Drawer)& aDrawer) { - -#ifdef OK -Standard_Boolean IsIn = Standard_False; - if (! myGOPtr->IsTransformed ()) - IsIn = aDrawer->IsIn (myMinX,myMaxX,myMinY,myMaxY); - else { - Standard_ShortReal minx, miny, maxx, maxy; -#ifdef WTO0001 - MinMax(minx,maxx,miny,maxy); -#else -gp_GTrsf2d aTrsf = myGOPtr->Transform (); -Standard_Real MINX, MINY, MAXX, MAXY; - - MINX = Standard_Real (myMinX); - MINY = Standard_Real (myMinY); - MAXX = Standard_Real (myMaxX); - MAXY = Standard_Real (myMaxY); - aTrsf.Transforms (MINX, MINY); - aTrsf.Transforms (MAXX, MAXY); - minx = Standard_ShortReal (MINX); - miny = Standard_ShortReal (MINY); - maxx = Standard_ShortReal (MAXX); - maxy = Standard_ShortReal (MAXY); -#endif - IsIn = aDrawer->IsIn (minx,maxx,miny,maxy); - } -#else -Standard_Boolean IsIn = Standard_True; -#endif - - if (IsIn) { - -Standard_ShortReal a, b; -Standard_Real A, B; - - ComputeCenter (aDrawer, a, b); -#ifdef PRO5663 - if( myMinX == myMaxX ) { - Standard_ShortReal dx = aDrawer->Convert(myImage->Width()); - Standard_ShortReal dy = aDrawer->Convert(myImage->Height()); - Standard_ShortReal width = aDrawer->ConvertMapToFrom(dx); - Standard_ShortReal height = aDrawer->ConvertMapToFrom(dy); - myMinX = a - Standard_ShortReal(width/2.); myMaxX = a + Standard_ShortReal(width/2.); - myMinY = b - Standard_ShortReal(height/2.); myMaxY = b + Standard_ShortReal(height/2.); - } -#endif - if (myGOPtr->IsTransformed ()) { - A = Standard_Real (a); - B = Standard_Real (b); - (myGOPtr->Transform ()).Transforms (A, B); - a = Standard_ShortReal (A); - b = Standard_ShortReal (B); - } - if (myIsModified) { - myIsModified = Standard_False; - aDrawer->ClearImage (myImage); - } - if (aDrawer->IsKnownImage (myImage)) - aDrawer->DrawImage (myImage, a, b); - else - FillAndDraw (aDrawer); - - // In case of GraphicObject Highlighted - // bounding box of the image is traced - if (myGOPtr->IsHighlighted ()) { - -Standard_Integer Width = myImage->Width (); -Standard_Integer Height = myImage->Height (); - // - // - 2 on Width and Height to avoid - // border outside of the image. - // - if (Width > 2) Width -= 2; - if (Height > 2) Height -= 2; -Standard_ShortReal dx = aDrawer->Convert (Width); -Standard_ShortReal dy = aDrawer->Convert (Height); - -Standard_ShortReal width = aDrawer->ConvertMapToFrom (dx); -Standard_ShortReal height = aDrawer->ConvertMapToFrom (dy); - -TShort_Array1OfShortReal TheX (1, 5); -TShort_Array1OfShortReal TheY (1, 5); - - TheX (1) = a - Standard_ShortReal(width / 2.); - TheY (1) = b - Standard_ShortReal(height / 2.); - TheX (2) = a - Standard_ShortReal(width / 2.); - TheY (2) = b + Standard_ShortReal(height / 2.); - TheX (3) = a + Standard_ShortReal(width / 2.); - TheY (3) = b + Standard_ShortReal(height / 2.); - TheX (4) = a + Standard_ShortReal(width / 2.); - TheY (4) = b - Standard_ShortReal(height / 2.); - TheX (5) = a - Standard_ShortReal(width / 2.); - TheY (5) = b - Standard_ShortReal(height / 2.); - - aDrawer->SetLineAttrib (myColorIndex, 0, 0); - aDrawer->MapPolylineFromTo (TheX, TheY); - } - - } -} - -Standard_Boolean Graphic2d_Image::Pick (const Standard_ShortReal X, const Standard_ShortReal Y, const Standard_ShortReal aPrecision,const Handle(Graphic2d_Drawer)& aDrawer) { - -Standard_ShortReal dx = aDrawer->Convert(myImage->Width()); -Standard_ShortReal dy = aDrawer->Convert(myImage->Height()); - -Standard_ShortReal width = aDrawer->ConvertMapToFrom(dx); -Standard_ShortReal height = aDrawer->ConvertMapToFrom(dy); - - Standard_ShortReal a,b; - ComputeCenter(aDrawer,a,b); - -Standard_ShortReal SRX = X, SRY = Y; - - if (myGOPtr->IsTransformed ()) { -gp_GTrsf2d aTrsf = (myGOPtr->Transform ()).Inverted (); -Standard_Real RX = Standard_Real (SRX), RY = Standard_Real (SRY); - aTrsf.Transforms (RX, RY); - SRX = Standard_ShortReal (RX); SRY = Standard_ShortReal (RY); - } - - return - ( SRX >= a - width / 2. - aPrecision - && SRX <= a + width / 2. + aPrecision - - && SRY >= b - height / 2. - aPrecision - && SRY <= b + height / 2. + aPrecision ); - -} - -void Graphic2d_Image::SetCenter (const Quantity_Length X, const Quantity_Length Y) { - - myX = Standard_ShortReal(X); - myY = Standard_ShortReal(Y); -#ifdef PRO5663 - myMinX = myMaxX = myX; - myMinY = myMaxY = myY; -#endif - -} - -void Graphic2d_Image::Translate (const Quantity_Length DX, const Quantity_Length DY) { - - myX = myX + Standard_ShortReal(DX); - myY = myY + Standard_ShortReal(DY); -#ifdef PRO5663 - myMinX = myMaxX = myX; - myMinY = myMaxY = myY; -#endif - -} - -void Graphic2d_Image::SetSmallSize (const Standard_Integer aSize) { - - TheSmallSize = aSize; - -} - -Standard_Integer Graphic2d_Image::SmallSize () { - - return (TheSmallSize); - -} - -// Private methods - -void Graphic2d_Image::FillAndDraw (const Handle(Graphic2d_Drawer)& aDrawer) const { - -Standard_ShortReal a,b; - -Standard_Integer LowerX, LowerY; -Standard_Integer UpperX, UpperY; -Standard_Integer Width, Height; -Aspect_RGBPixel *pixels; - -Standard_Integer indice; -Standard_Integer i, ii; -Standard_Integer j; - -Standard_Real R, G, B; - - ComputeCenter(aDrawer,a,b); - - Width = myImage->Width (); - Height = myImage->Height (); - - LowerX = myImage->LowerX (); - LowerY = myImage->LowerY (); - - UpperX = myImage->UpperX (); - UpperY = myImage->UpperY (); - - if (Height*Width <= Graphic2d_Image::SmallSize ()) { - // Small images are filled at once - pixels = new Aspect_RGBPixel [Height*Width]; - - Quantity_Array1OfColor Array (0, Width-1); - - // Parsing of the image Lines-Columns (Height-Width) - for (i=0, ii=LowerY; ii<=UpperY; i++, ii++) { - myImage->RowColor (ii, Array); - for (j=0; jFillAndDrawImage - (myImage, a, b, Width, Height, - (Standard_Address*) pixels); - - delete [] pixels; - } - else { - // Great images are filled line by line - pixels = new Aspect_RGBPixel [Width]; - - Quantity_Array1OfColor Array (0, Width-1); - - // Parsing of image Lines-Columns (Height-Width) - for (i=0, ii=LowerY; ii<=UpperY; i++, ii++) { - myImage->RowColor (ii, Array); - for (j=0; jFillAndDrawImage - (myImage, a, b, i, Width, Height, - (Standard_Address*) pixels); - } - - delete [] pixels; - } - -} -void Graphic2d_Image::ComputeCenter(const Handle(Graphic2d_Drawer)& aDrawer, - Standard_ShortReal& cx, - Standard_ShortReal& cy) const { - Standard_Integer Width, Height; - Width = myImage->Width (); - Height = myImage->Height (); - Standard_ShortReal dx = aDrawer->Convert(myImage->Width()); - Standard_ShortReal dy = aDrawer->Convert(myImage->Height()); - - Standard_ShortReal width = aDrawer->ConvertMapToFrom(dx); - Standard_ShortReal height = aDrawer->ConvertMapToFrom(dy); - - Standard_ShortReal ox = aDrawer->ConvertMapToFrom(mydx); - Standard_ShortReal oy = aDrawer->ConvertMapToFrom(mydy); - - switch (myPlacement) { - case Aspect_CP_North: { cx = myX + ox ; - cy = myY + oy - Standard_ShortReal(height/2.) ; break; }; - case Aspect_CP_NorthEast: { cx = myX + ox - Standard_ShortReal(width/2.); - cy = myY + oy - Standard_ShortReal(height/2.) ; break; }; - case Aspect_CP_East: { cx = myX + ox - Standard_ShortReal(width/2.); - cy = myY + oy ; break; }; - case Aspect_CP_SouthEast: { cx = myX + ox - Standard_ShortReal(width/2.); - cy = myY + oy + Standard_ShortReal(height/2.) ; break; }; - case Aspect_CP_South: { cx = myX + ox ; - cy = myY + oy + Standard_ShortReal(height/2.) ; break; }; - case Aspect_CP_SouthWest: { cx = myX + ox + Standard_ShortReal(width/2.); - cy = myY + oy + Standard_ShortReal(height/2.) ; break; }; - case Aspect_CP_West: { cx = myX + ox + Standard_ShortReal(width/2.); - cy = myY + oy ; break; }; - case Aspect_CP_NorthWest: { cx = myX + ox + Standard_ShortReal(width/2.); - cy = myY + oy - Standard_ShortReal(height/2.) ; break; }; - case Aspect_CP_Center: { cx = myX + ox; - cy = myY + oy ; break; }; - } -} - -void Graphic2d_Image::SetOffset(const Quantity_Length dx, const Quantity_Length dy) { - - mydx = Standard_ShortReal(dx); - mydy = Standard_ShortReal(dy); -#ifdef PRO5663 - myMinX = myMaxX = myX; - myMinY = myMaxY = myY; -#endif -} - -void Graphic2d_Image::SetPlacement(const Aspect_CardinalPoints aPlacement) { - - myPlacement = aPlacement; -#ifdef PRO5663 - myMinX = myMaxX = myX; - myMinY = myMaxY = myY; -#endif - -} - -void Graphic2d_Image::Position( Quantity_Length& X,Quantity_Length& Y ) const { - - X = Quantity_Length( myX ); - Y = Quantity_Length( myY ); - -} - -void Graphic2d_Image::Offset(Quantity_Length& aX,Quantity_Length& aY) const { - - aX = Quantity_Length( mydx ); - aY = Quantity_Length( mydy ); -} - -Aspect_CardinalPoints Graphic2d_Image::Placement() const { - return myPlacement; -} - -Handle(Image_Image) Graphic2d_Image::Image() const { - return myImage; -} - -void Graphic2d_Image::Save(Aspect_FStream& aFStream) const -{ -} diff --git a/src/Graphic2d/Graphic2d_Image.pxx b/src/Graphic2d/Graphic2d_Image.pxx deleted file mode 100755 index 6d3db620a0..0000000000 --- a/src/Graphic2d/Graphic2d_Image.pxx +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright (c) 1995-1999 Matra Datavision -// Copyright (c) 1999-2012 OPEN CASCADE SAS -// -// The content of this file is subject to the Open CASCADE Technology Public -// License Version 6.5 (the "License"). You may not use the content of this file -// except in compliance with the License. Please obtain a copy of the License -// at http://www.opencascade.org and read it completely before using this file. -// -// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its -// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. -// -// The Original Code and all software distributed under the License is -// distributed on an "AS IS" basis, without warranty of any kind, and the -// Initial Developer hereby disclaims all such warranties, including without -// limitation, any warranties of merchantability, fitness for a particular -// purpose or non-infringement. Please see the License for the specific terms -// and conditions governing the rights and limitations under the License. - - -#ifndef IMAGE_PXX_INCLUDED -#define IMAGE_PXX_INCLUDED - -static Standard_Integer TheSmallSize = 64*64; - -#endif diff --git a/src/Graphic2d/Graphic2d_ImageFile.cdl b/src/Graphic2d/Graphic2d_ImageFile.cdl deleted file mode 100755 index 49e164358d..0000000000 --- a/src/Graphic2d/Graphic2d_ImageFile.cdl +++ /dev/null @@ -1,265 +0,0 @@ --- Created on: 1994-11-21 --- Created by: CAL --- Copyright (c) 1994-1999 Matra Datavision --- Copyright (c) 1999-2012 OPEN CASCADE SAS --- --- The content of this file is subject to the Open CASCADE Technology Public --- License Version 6.5 (the "License"). You may not use the content of this file --- except in compliance with the License. Please obtain a copy of the License --- at http://www.opencascade.org and read it completely before using this file. --- --- The Initial Developer of the Original Code is Open CASCADE S.A.S., having its --- main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. --- --- The Original Code and all software distributed under the License is --- distributed on an "AS IS" basis, without warranty of any kind, and the --- Initial Developer hereby disclaims all such warranties, including without --- limitation, any warranties of merchantability, fitness for a particular --- purpose or non-infringement. Please see the License for the specific terms --- and conditions governing the rights and limitations under the License. - - --- Modified: TCL G002A, 28-11-00, new section "inquire methods" - - -class ImageFile from Graphic2d inherits Primitive from Graphic2d - - ---Version: - - ---Purpose: The primitive ImageFile - - ---Keywords: Primitive, ImageFile - ---Warning: - ---References: - -uses - - File from OSD, - AsciiString from TCollection, - Drawer from Graphic2d, - GraphicObject from Graphic2d, - Factor from Quantity, - Length from Quantity, - CardinalPoints from Aspect, - FStream from Aspect, - IFStream from Aspect - -raises - ImageDefinitionError from Graphic2d - -is - ------------------------- - -- Category: Constructors - ------------------------- - - Create (aGraphicObject: GraphicObject from Graphic2d; - aFile: in out File from OSD; - X, Y: Length from Quantity; - adx: Length from Quantity = 0.0; - ady: Length from Quantity = 0.0; - aTypeOfPlacement: CardinalPoints - from Aspect = Aspect_CP_Center; - aScale: Factor from Quantity = 1.0) - returns mutable ImageFile from Graphic2d - ---Level: Public - ---Purpose: Defines an image with its center location; - -- , defines the position in the space model. - -- , defines an offset in the device space. - -- defines a scale factor applied to the - -- original size of the image. - -- The image will be placed at this offset - -- according to the type of placement. - -- - -- CardinalPoints values : - -- - CP_North - -- - CP_NorthEast - -- - CP_East - -- - CP_SouthEast - -- - CP_South - -- - CP_SouthWest - -- - CP_West - -- - CP_NorthWest - -- - CP_Center - raises ImageDefinitionError; - ---Trigger: - -- If the file don't exist or has a null size. - ---Category: Constructors - - -------------------------- - -- Category: Draw and Pick - -------------------------- - - Draw (me : mutable; aDrawer: Drawer from Graphic2d) - is static protected; - ---Level: Internal - ---Purpose: Draws the image at the required center location - -- defined by the SetCenter method. - ---Category: Draw and Pick - - Pick (me : mutable; - X, Y: ShortReal from Standard; - aPrecision: ShortReal from Standard; - aDrawer: Drawer from Graphic2d) - returns Boolean from Standard - is static protected; - ---Purpose: Returns Standard_True if the image is picked, - -- Standard_False if not. - ---Category: Draw and Pick - - --------------------------------------------------- - -- Category: Methods to modify the class definition - --------------------------------------------------- - - SetCenter (me: mutable; - X, Y: Length from Quantity) - is static; - ---Level: Public - ---Purpose: Modifies the center location of the image . - ---Category: Methods to modify the class definition - - SetOffset (me: mutable; - dx, dy: Length from Quantity) - is static; - ---Level: Public - ---Purpose: Modifies the offset of the image . - ---Category: Methods to modify the class definition - - SetPlacement (me: mutable; aPlacement: CardinalPoints from Aspect) - is static; - ---Level: Public - ---Purpose: Modifies the type of placement of the image . - -- - -- CardinalPoints values : - -- - CP_North - -- - CP_NorthEast - -- - CP_East - -- - CP_SouthEast - -- - CP_South - -- - CP_SouthWest - -- - CP_West - -- - CP_NorthWest - -- - CP_Center - ---Category: Methods to modify the class definition - - Translate (me: mutable; - DX, DY: Length from Quantity) - is static; - ---Level: Public - ---Purpose: Modifies the center location of the image - -- by translating it. - ---Category: Methods to modify the class definition - - SetScale (me: mutable; aScale: Factor from Quantity) is static; - ---Level: Public - ---Purpose: Changes the scale factor of the image. - ---Category: Methods to modify the class definition - - SetZoomable (me: mutable; aFlag: Boolean from Standard = Standard_False) - is static; - ---Level: Public - ---Purpose: The image follows the scale factor of the view - -- if the flag is Standard_True. - ---Category: Zoom management - - Clear (me: mutable) is static; - ---Level: Public - ---Purpose: Clear the reference to this imagefile if something - -- inside have changed,Forced the reload of this at Draw() - -- time. - ---Category: Methods to modify the class definition - - ---------------------------- - -- Category: Zoom management - ---------------------------- - - Scale (me) - returns Factor from Quantity; - ---Level: Internal - ---Purpose: Returns the original scale factor applied to - -- the image . - ---Category: Zoom management - - IsZoomable (me) - returns Boolean from Standard is static; - ---Level: Internal - ---Purpose: Returns Standard_True if the image follows - -- the scale factor of the view. - ---Category: Zoom management - - ---------------------------- - -- Category: Inquire methods - ---------------------------- - - Position( me; X, Y: out Length from Quantity ); - ---Level: Public - ---Purpose: returns the position in the space model - - Offset( me; aX, aY: out Length from Quantity ); - ---Level: Public - ---Purpose: returns the offset in the device space - - Placement( me ) returns CardinalPoints from Aspect; - ---Level: Public - ---Purpose: returns the type of placement - - ImageFile( me ) returns File from OSD; - ---Level: Public - ---Purpose: returns the image file - - - Values (myclass; - aFile: in out File from OSD; - aWidth, aHeight: out Integer from Standard; - aDepth: out Integer from Standard) - returns Boolean from Standard; - ---Level: Internal - ---Purpose: Returns Standard_True, the Image pixel size - -- and the Image planes depth, if the image file : - -- - is not open - -- - exists - -- - have the extension .xwd - -- NOTE that only XWD image file type are recognized. - ---Category: Inquire methods - - ---------------------------- - -- Category: Private methods - ---------------------------- - - ComputeCenterAndSize (me : mutable; - aDrawer: Drawer from Graphic2d; - cx, cy, width, height: out ShortReal from Standard) - returns Boolean from Standard is static private; - ---Level: Internal - ---Purpose: Evaluates the center of the image in the device space. - -- Called by the methods : - -- - Graphic2d_ImageFile::Draw - -- - Graphic2d_ImageFile::Pick - -- - Graphic2d_ImageFile::FillAndDraw - --Returns FALSE if the size cann't gbe evaluated. - ---Category: Private methods - - SwapLong (myclass; - anAddress: Address from Standard; - aNumOfBytes: Integer from Standard); - ---Level: Internal - ---Purpose: Swaps long ints - ---Category: Private methods - - ---------------------------------------------------------------------- - - Save( me; aFStream: in out FStream from Aspect ) is virtual; --- Retrieve( me; aIFStream: in out IFStream from AIS2D ) is virtual; - -fields - - myFile: File from OSD; - myFileName: AsciiString from TCollection; - myX, myY: ShortReal from Standard; - mydx, mydy: ShortReal from Standard; - myWidth, myHeight: Integer from Standard; - myPlacement: CardinalPoints from Aspect; - myIsZoomable: Boolean from Standard; - myScale: ShortReal from Standard; - myIsModified: Boolean from Standard; - -end ImageFile from Graphic2d; diff --git a/src/Graphic2d/Graphic2d_ImageFile.cxx b/src/Graphic2d/Graphic2d_ImageFile.cxx deleted file mode 100755 index 749ada8d44..0000000000 --- a/src/Graphic2d/Graphic2d_ImageFile.cxx +++ /dev/null @@ -1,492 +0,0 @@ -// Copyright (c) 1995-1999 Matra Datavision -// Copyright (c) 1999-2012 OPEN CASCADE SAS -// -// The content of this file is subject to the Open CASCADE Technology Public -// License Version 6.5 (the "License"). You may not use the content of this file -// except in compliance with the License. Please obtain a copy of the License -// at http://www.opencascade.org and read it completely before using this file. -// -// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its -// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. -// -// The Original Code and all software distributed under the License is -// distributed on an "AS IS" basis, without warranty of any kind, and the -// Initial Developer hereby disclaims all such warranties, including without -// limitation, any warranties of merchantability, fitness for a particular -// purpose or non-infringement. Please see the License for the specific terms -// and conditions governing the rights and limitations under the License. - -/*===================================================================== - - FUNCTION : - ---------- - Class Graphic2d_ImageFile - - TEST : - ------ - - See TestG2D/TestG21 - - -=====================================================================*/ - -#define S3593 //GG_100398 - -#define xTRACE - -//#if defined(WNT) || defined(LIN) -#include -//#endif - -#include -#include -#include -#include -#include -#include - -#define SWAPTEST (*(char*)&swaptest) - -static unsigned long swaptest = 1; - -#ifdef S3593 -static Standard_Boolean ImageSize(const Handle(Graphic2d_Drawer) aDrawer, - OSD_File &aFile, - const TCollection_AsciiString& aFileName, - Standard_Integer &aWidth, - Standard_Integer &aHeight) { -Standard_Boolean status = Standard_False; - if( !aDrawer.IsNull() ) { - status = aDrawer->GetImageSize(aFileName.ToCString(),aWidth,aHeight); - } - - if( !status ) { - Standard_Integer depth; - status = Graphic2d_ImageFile::Values(aFile,aWidth,aHeight,depth); - } - - return status; -} -#endif - -Graphic2d_ImageFile::Graphic2d_ImageFile (const Handle(Graphic2d_GraphicObject)& aGraphicObject, OSD_File& aFile, const Quantity_Length X, const Quantity_Length Y, const Quantity_Length adx, const Quantity_Length ady, const Aspect_CardinalPoints aTypeOfPlacement, const Quantity_Factor ascale): - Graphic2d_Primitive (aGraphicObject), - myFile(aFile), - myX(Standard_ShortReal(X)), - myY(Standard_ShortReal(Y)), - mydx(Standard_ShortReal(adx)), - mydy(Standard_ShortReal(ady)), - myPlacement(aTypeOfPlacement), - myIsZoomable(Standard_False), - myScale (Standard_ShortReal(ascale)) -#ifndef S3593 - ,myIsModified(Standard_True) -#endif -{ - - SetFamily(Graphic2d_TOP_IMAGE); - - OSD_Path Path; - myFile.Path (Path); - Path.SystemName (myFileName); - -#ifdef S3593 - Standard_ShortReal Xc,Yc,Width,Height; - if( !ComputeCenterAndSize (Drawer(), Xc, Yc, Width, Height) ) { -#else - myMinX = myX; myMinY = myY; - myMaxX = myX; myMaxY = myY; - - Standard_Integer depth; - if( !Values(aFile,myWidth,myHeight,depth) ) { -#endif - char buff[512]; - sprintf ( buff, "Bad image file: %s\n", myFileName.ToCString () ); - Graphic2d_ImageDefinitionError::Raise (buff); - } -} - -void Graphic2d_ImageFile::Clear() { - -#ifdef S3593 - myMinX = ShortRealLast(); myMinY = ShortRealLast(); - myMaxX = ShortRealFirst(); myMaxY = ShortRealFirst(); - Standard_ShortReal Xc,Yc,Width,Height; - Handle(Graphic2d_Drawer) aDrawer = Drawer(); - if( aDrawer->IsWindowDriver() ) { - aDrawer->ClearImageFile(myFileName.ToCString()); - ComputeCenterAndSize (aDrawer, Xc, Yc, Width, Height); - } -#else - myMinX = myX; myMinY = myY; - myMaxX = myX; myMaxY = myY; - myIsModified = Standard_True; -#endif -} - -void Graphic2d_ImageFile::Draw (const Handle(Graphic2d_Drawer)& aDrawer) { - -Standard_Boolean IsIn = Standard_False; -Standard_ShortReal Xc,Yc,Width,Height; - -#ifdef S3593 - Width = myMaxX - myMinX; Height = myMaxY - myMinY; - Xc = Standard_ShortReal((myMaxX + myMinX)/2.); Yc = Standard_ShortReal((myMaxY + myMinY)/2.); -#else - if( !ComputeCenterAndSize (aDrawer, Xc, Yc, Width, Height) ) return; -#endif - - if (! myGOPtr->IsTransformed ()) - IsIn = aDrawer->IsIn (myMinX,myMaxX,myMinY,myMaxY); - else { - Standard_ShortReal minx, miny, maxx, maxy; - MinMax(minx,maxx,miny,maxy); - IsIn = aDrawer->IsIn (minx,maxx,miny,maxy); - } - - if (IsIn) { -static TShort_Array1OfShortReal TheX (1, 5); -static TShort_Array1OfShortReal TheY (1, 5); - if (myGOPtr->IsTransformed ()) { - Standard_Real A = Standard_Real (Xc); - Standard_Real B = Standard_Real (Yc); - (myGOPtr->Transform ()).Transforms (A, B); - Xc = Standard_ShortReal (A); - Yc = Standard_ShortReal (B); - } - Standard_ShortReal scale = (myIsZoomable) ? Standard_ShortReal(aDrawer->Scale()) : Standard_ShortReal(1.); - aDrawer->DrawImageFile (myFileName.ToCString(), Xc, Yc, scale*myScale); - - // In case of GraphicObject Highlighted - // the bounding box of the image is traced - if (myGOPtr->IsHighlighted ()) { - -#ifdef TRACE - cout << " Scale : " << scale << "\n"; - cout << " Xc : " << Xc << "\n"; - cout << " Yc : " << Yc << "\n"; - cout << " Width : " << Width << "\n"; - cout << " Height : " << Height << "\n"; -#endif - - TheX (1) = Xc - Standard_ShortReal(Width / 2.); - TheY (1) = Yc - Standard_ShortReal(Height / 2.); - TheX (2) = Xc - Standard_ShortReal(Width / 2.); - TheY (2) = Yc + Standard_ShortReal(Height / 2.); - TheX (3) = Xc + Standard_ShortReal(Width / 2.); - TheY (3) = Yc + Standard_ShortReal(Height / 2.); - TheX (4) = Xc + Standard_ShortReal(Width / 2.); - TheY (4) = Yc - Standard_ShortReal(Height / 2.); - TheX (5) = Xc - Standard_ShortReal(Width / 2.); - TheY (5) = Yc - Standard_ShortReal(Height / 2.); - - aDrawer->SetLineAttrib (myColorIndex, 0, 1); - aDrawer->MapPolylineFromTo (TheX, TheY); - } - } else { -#ifdef TRACE - cout << " ImageFile " << this << " is out of the view" << endl; -#endif - } -} - -Standard_Boolean Graphic2d_ImageFile::Pick (const Standard_ShortReal X, const Standard_ShortReal Y, const Standard_ShortReal aPrecision, const Handle(Graphic2d_Drawer)& aDrawer) { - -Standard_ShortReal SRX = X, SRY = Y; -Standard_ShortReal Xc,Yc,Width,Height; -Standard_Boolean theStatus = Standard_False; - - if( ComputeCenterAndSize (aDrawer, Xc, Yc, Width, Height) ) { - - if (myGOPtr->IsTransformed ()) { -gp_GTrsf2d aTrsf = (myGOPtr->Transform ()).Inverted (); -Standard_Real RX = Standard_Real (SRX), RY = Standard_Real (SRY); - aTrsf.Transforms (RX, RY); - SRX = Standard_ShortReal (RX); - SRY = Standard_ShortReal (RY); - } - -Standard_ShortReal MINX = Xc - Standard_ShortReal(Width/2.); -Standard_ShortReal MINY = Yc - Standard_ShortReal(Height/2.); -Standard_ShortReal MAXX = Xc + Standard_ShortReal(Width/2.); -Standard_ShortReal MAXY = Yc + Standard_ShortReal(Height/2.); - - theStatus = - (SRX >= MINX - aPrecision) - && (SRX <= MAXX + aPrecision) - && (SRY >= MINY - aPrecision) - && (SRY <= MAXY + aPrecision) - ; - } - - return theStatus; - -} - -void Graphic2d_ImageFile::SetCenter (const Quantity_Length X, const Quantity_Length Y) { - - myX = Standard_ShortReal(X); - myY = Standard_ShortReal(Y); -#ifdef S3593 - Standard_ShortReal Xc,Yc,Width,Height; - ComputeCenterAndSize (Drawer(), Xc, Yc, Width, Height); -#endif - -} - -void Graphic2d_ImageFile::Translate (const Quantity_Length DX, const Quantity_Length DY) { - - myX += Standard_ShortReal(DX); - myY += Standard_ShortReal(DY); -#ifdef S3593 - Standard_ShortReal Xc,Yc,Width,Height; - ComputeCenterAndSize (Drawer(), Xc, Yc, Width, Height); -#endif - -} - -// Private methods - -Standard_Boolean Graphic2d_ImageFile::ComputeCenterAndSize (const Handle(Graphic2d_Drawer)& aDrawer, Standard_ShortReal& cx, Standard_ShortReal& cy, Standard_ShortReal& Width, Standard_ShortReal& Height) { - -Standard_ShortReal scale = (myIsZoomable) ? Standard_ShortReal(aDrawer->Scale()) : Standard_ShortReal(1.); -Standard_ShortReal ox = aDrawer->ConvertMapToFrom (mydx); -Standard_ShortReal oy = aDrawer->ConvertMapToFrom (mydy); -Standard_ShortReal dx,dy; -//Standard_Integer depth; - -#ifdef S3593 - if( !ImageSize (aDrawer, myFile, myFileName, myWidth, myHeight) ) - return Standard_False; -#else - if( myIsModified ) { - if( !Values(myFile,myWidth,myHeight,depth) ) return Standard_False; - myIsModified = Standard_False; - aDrawer->ClearImageFile(myFileName.ToCString()); - } -#endif - - dx = aDrawer->Convert (myWidth); - dy = aDrawer->Convert (myHeight); - - Width = scale*myScale*aDrawer->ConvertMapToFrom (dx); - Height = scale*myScale*aDrawer->ConvertMapToFrom (dy); - - switch (myPlacement) { - case Aspect_CP_North: - cx = myX + ox; - cy = myY + oy - Standard_ShortReal(Height/2.); - break; - case Aspect_CP_NorthEast: - cx = myX + ox - Standard_ShortReal(Width/2.); - cy = myY + oy - Standard_ShortReal(Height/2.); - break; - case Aspect_CP_East: - cx = myX + ox - Standard_ShortReal(Width/2.); - cy = myY + oy; - break; - case Aspect_CP_SouthEast: - cx = myX + ox - Standard_ShortReal(Width/2.); - cy = myY + oy + Standard_ShortReal(Height/2.); - break; - case Aspect_CP_South: - cx = myX + ox; - cy = myY + oy + Standard_ShortReal(Height/2.); - break; - case Aspect_CP_SouthWest: - cx = myX + ox + Standard_ShortReal(Width/2.); - cy = myY + oy + Standard_ShortReal(Height/2.); - break; - case Aspect_CP_West: - cx = myX + ox + Standard_ShortReal(Width/2.); - cy = myY + oy; - break; - case Aspect_CP_NorthWest: - cx = myX + ox + Standard_ShortReal(Width/2.); - cy = myY + oy - Standard_ShortReal(Height/2.); - break; - case Aspect_CP_Center: - cx = myX + ox; - cy = myY + oy; - break; - } - - myMinX = cx - Standard_ShortReal(Width/2.); - myMinY = cy - Standard_ShortReal(Height/2.); - myMaxX = cx + Standard_ShortReal(Width/2.); - myMaxY = cy + Standard_ShortReal(Height/2.); - - return Standard_True; -} - -void Graphic2d_ImageFile::SetOffset (const Quantity_Length dx, const Quantity_Length dy) { - - mydx = Standard_ShortReal(dx); - mydy = Standard_ShortReal(dy); - myMinX = myMaxX = myX; - myMinY = myMaxY = myY; -} - -void Graphic2d_ImageFile::SetPlacement (const Aspect_CardinalPoints aPlacement) { - - myPlacement = aPlacement; - myMinX = myMaxX = myX; - myMinY = myMaxY = myY; - -} - -Standard_Boolean Graphic2d_ImageFile::IsZoomable () const { - - return myIsZoomable; - -} - -void Graphic2d_ImageFile::SetZoomable (const Standard_Boolean aFlag) { - - myIsZoomable = aFlag; -#ifdef S3593 - Standard_ShortReal Xc,Yc,Width,Height; - ComputeCenterAndSize (Drawer(), Xc, Yc, Width, Height); -#endif - -} - -void Graphic2d_ImageFile::SetScale (const Quantity_Factor aScale) { - - myScale = Standard_ShortReal(aScale); -#ifdef S3593 - Standard_ShortReal Xc,Yc,Width,Height; - ComputeCenterAndSize (Drawer(), Xc, Yc, Width, Height); -#endif - -} - -Quantity_Factor Graphic2d_ImageFile::Scale () const { - - return Quantity_Factor (myScale); - -} - -Standard_Boolean Graphic2d_ImageFile::Values (OSD_File& aFile, Standard_Integer &aWidth, Standard_Integer &aHeight, Standard_Integer &aDepth) { - -Standard_Boolean Result = Standard_False; -Standard_Boolean Reopen = Standard_False; - aWidth = aHeight = aDepth = 0; - if (aFile.IsOpen () && aFile.IsLocked()) { - cout << "Can't analyse a locked file.\n" << flush; - return Result; - } - - if ( aFile.IsOpen () ) { - Reopen =Standard_True; - aFile.Seek (0,OSD_FromBeginning); - } else { -OSD_Protection Protection (OSD_R, OSD_R, OSD_R, OSD_R); - aFile.Open (OSD_ReadOnly, Protection); - if (! aFile.IsOpen ()) { - cout << "Error => Can't open input file as specified.\n" - << "No such file or directory.\n" << flush; - return Result; - } - } - -OSD_Path Path; - aFile.Path (Path); -TCollection_AsciiString ext = Path.Extension (); - - Standard_Boolean XwdImage = (ext == TCollection_AsciiString (".xwd")); - if (! XwdImage) { - cout << "Error => File extension " << ext - << " is not available.\n" << flush; - if( !Reopen ) aFile.Close (); - return Result; - } -XWDFileHeader *pheader; - - pheader = (XWDFileHeader *) malloc (sizeof (XWDFileHeader)); - if (pheader == NULL) { - cout << "Can't malloc XWDFileHeader storage.\n" << flush; - if( !Reopen ) aFile.Close (); - return Result; - } - -Standard_Address addrheader = Standard_Address (pheader); -Standard_Integer sizeheader = Standard_Integer (sizeof (XWDFileHeader)); -Standard_Integer readheader = 0; - - aFile.Read (addrheader, sizeheader, readheader); - if (readheader != sizeheader) { - cout << "Unable to read dump file header.\n" << flush; - if( !Reopen ) aFile.Close (); - return Result; - } - - if (SWAPTEST) - Graphic2d_ImageFile::SwapLong (addrheader, sizeheader); - - aWidth = Standard_Integer (pheader->pixmap_width); - aHeight = Standard_Integer (pheader->pixmap_height); - aDepth = Standard_Integer (pheader->pixmap_depth); - Result = Standard_True; - - /* close the input file */ - if( !Reopen ) aFile.Close (); - -#ifdef TRACE -TCollection_AsciiString aFileName; -Path.SystemName (aFileName); -cout << "Graphic2d_Image_File::Values('" << aFileName << "'," << - aWidth << "," << aHeight << "," << aDepth << ")" << endl; -#endif - return Result; - -} - -void Graphic2d_ImageFile::SwapLong ( - const Standard_Address anAddress, - const Standard_Integer aNumOfBytes) -{ -int n = (int) aNumOfBytes; -char *bp = (char *) anAddress; - -char c; -char *ep = bp + n; -char *sp; - - while (bp < ep) { - sp = bp + 3; - c = *sp; - *sp = *bp; - *bp++ = c; - sp = bp + 1; - c = *sp; - *sp = *bp; - *bp++ = c; - bp += 2; - } -} - -void Graphic2d_ImageFile::Position( Quantity_Length& X,Quantity_Length& Y ) const { - - X = Quantity_Length( myX ); - Y = Quantity_Length( myY ); - -} - -void Graphic2d_ImageFile::Offset(Quantity_Length& aX,Quantity_Length& aY) const { - - aX = Quantity_Length( mydx ); - aY = Quantity_Length( mydy ); -} - -Aspect_CardinalPoints Graphic2d_ImageFile::Placement() const { - return myPlacement; -} - -OSD_File Graphic2d_ImageFile::ImageFile() const { - return myFile; -} - -void Graphic2d_ImageFile::Save(Aspect_FStream& aFStream) const -{ -} diff --git a/src/Graphic2d/Graphic2d_InfiniteLine.cdl b/src/Graphic2d/Graphic2d_InfiniteLine.cdl deleted file mode 100755 index c76c7f7176..0000000000 --- a/src/Graphic2d/Graphic2d_InfiniteLine.cdl +++ /dev/null @@ -1,103 +0,0 @@ --- Created on: 1993-06-22 --- Created by: Jean Louis FRENKEL, Gerard GRAS --- Copyright (c) 1993-1999 Matra Datavision --- Copyright (c) 1999-2012 OPEN CASCADE SAS --- --- The content of this file is subject to the Open CASCADE Technology Public --- License Version 6.5 (the "License"). You may not use the content of this file --- except in compliance with the License. Please obtain a copy of the License --- at http://www.opencascade.org and read it completely before using this file. --- --- The Initial Developer of the Original Code is Open CASCADE S.A.S., having its --- main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. --- --- The Original Code and all software distributed under the License is --- distributed on an "AS IS" basis, without warranty of any kind, and the --- Initial Developer hereby disclaims all such warranties, including without --- limitation, any warranties of merchantability, fitness for a particular --- purpose or non-infringement. Please see the License for the specific terms --- and conditions governing the rights and limitations under the License. - - --- Modified: TCL G002A, 28-11-00, new section "inquire methods" - - -class InfiniteLine from Graphic2d inherits Line from Graphic2d - - ---Version: - - ---Purpose: The primitive InfiniteLine - - ---Keywords: Primitive, InfiniteLine - ---Warning: - ---References: - -uses - Drawer from Graphic2d, - GraphicObject from Graphic2d, - Length from Quantity, - FStream from Aspect, - IFStream from Aspect - - -raises - InfiniteLineDefinitionError from Graphic2d - -is - ------------------------- - -- Category: Constructors - ------------------------- - - Create (aGraphicObject: GraphicObject from Graphic2d; - X, Y, DX, DY: Length from Quantity) - returns mutable InfiniteLine from Graphic2d - ---Level: Public - ---Purpose: Creates an infinite line. - -- The reference point is , . - -- The slope is , . - -- Warning: Raises InfiniteLineDefinitionError if the - -- and are null. - raises InfiniteLineDefinitionError from Graphic2d; - - -------------------------- - -- Category: Draw and Pick - -------------------------- - - Draw (me : mutable; aDrawer: Drawer from Graphic2d) - is static protected; - ---Level: Internal - ---Purpose: Draws the infinite line . - - Pick (me : mutable; X, Y: ShortReal from Standard; - aPrecision: ShortReal from Standard; - aDrawer: Drawer from Graphic2d) - returns Boolean from Standard is static protected; - ---Level: Internal - ---Purpose: Returns Standard_True if the infinite line is picked, - -- Standard_False if not. - - -------------------------------------- - -- Category: Inquire methods - -------------------------------------- - - Reference( me; X, Y: out Length from Quantity ); - ---Level: Public - ---Purpose: returns the coordinates of the reference point - - Slope( me; dX, dY: out Length from Quantity ); - ---Level: Public - ---Purpose: returns the slope , - - ---------------------------------------------------------------------- - - Save( me; aFStream: in out FStream from Aspect ) is virtual; - Retrieve(myclass; anIFStream: in out IFStream from Aspect; - aGraphicObject: GraphicObject from Graphic2d); -fields - - myX: ShortReal from Standard; - myY: ShortReal from Standard; - myDX: ShortReal from Standard; - myDY: ShortReal from Standard; - -end InfiniteLine from Graphic2d; diff --git a/src/Graphic2d/Graphic2d_InfiniteLine.cxx b/src/Graphic2d/Graphic2d_InfiniteLine.cxx deleted file mode 100755 index 488ec856a4..0000000000 --- a/src/Graphic2d/Graphic2d_InfiniteLine.cxx +++ /dev/null @@ -1,140 +0,0 @@ -// Copyright (c) 1995-1999 Matra Datavision -// Copyright (c) 1999-2012 OPEN CASCADE SAS -// -// The content of this file is subject to the Open CASCADE Technology Public -// License Version 6.5 (the "License"). You may not use the content of this file -// except in compliance with the License. Please obtain a copy of the License -// at http://www.opencascade.org and read it completely before using this file. -// -// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its -// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. -// -// The Original Code and all software distributed under the License is -// distributed on an "AS IS" basis, without warranty of any kind, and the -// Initial Developer hereby disclaims all such warranties, including without -// limitation, any warranties of merchantability, fitness for a particular -// purpose or non-infringement. Please see the License for the specific terms -// and conditions governing the rights and limitations under the License. - - -#include - -Graphic2d_InfiniteLine::Graphic2d_InfiniteLine ( - const Handle(Graphic2d_GraphicObject)& aGraphicObject, - const Quantity_Length X, const Quantity_Length Y, - const Quantity_Length DX, const Quantity_Length DY) - - : Graphic2d_Line (aGraphicObject) { - - myX = Standard_ShortReal(X); - myY = Standard_ShortReal(Y); - myDX = Standard_ShortReal(DX); - myDY = Standard_ShortReal(DY); - - //if ((myDX == 0.) && (myDY == 0.)) - if ((Abs (Standard_Real (DX)) <= RealEpsilon ()) && - (Abs (Standard_Real (DY)) <= RealEpsilon ())) - Graphic2d_InfiniteLineDefinitionError::Raise - ("The slope is undefined"); - - //if (myDX != 0.) { - if (Abs (Standard_Real (DX)) > RealEpsilon ()) { - myMinX = ShortRealFirst(); - myMaxX = ShortRealLast(); - } - else - myMinX = myMaxX = myX; - - //if (myDY != 0.) { - if (Abs (Standard_Real (DY)) > RealEpsilon ()) { - myMinY = ShortRealFirst(); - myMaxY = ShortRealLast(); - } - else - myMinY = myMaxY = myY; -} - -void Graphic2d_InfiniteLine::Draw (const Handle(Graphic2d_Drawer)& aDrawer) { - -Standard_ShortReal a, b, c, d; - - DrawLineAttrib (aDrawer); - - a = myX; b = myY; - c = myDX; d = myDY; - - if (myGOPtr->IsTransformed ()) { -gp_GTrsf2d aTrsf = myGOPtr->Transform (); -Standard_Real A, B, C, D; - // Calcul second point de passage - C = Standard_Real (a) + Standard_Real (c); - D = Standard_Real (b) + Standard_Real (d); - // Calcul nouveau point de reference - A = Standard_Real (a); B = Standard_Real (b); - aTrsf.Transforms (A, B); - a = Standard_ShortReal (A); b = Standard_ShortReal (B); - // Calcul nouveau point de passage - aTrsf.Transforms (C, D); - // Calcul nouvelle pente - c = Standard_ShortReal (C - A); - d = Standard_ShortReal (D - B); - } - - aDrawer->MapInfiniteLineFromTo (a, b, c, d); - -} - -Standard_Boolean Graphic2d_InfiniteLine::Pick (const Standard_ShortReal X, - const Standard_ShortReal Y, - const Standard_ShortReal aPrecision, - const Handle(Graphic2d_Drawer)& aDrawer) -{ - Standard_ShortReal SRX = X, SRY = Y; - - if (myGOPtr->IsTransformed ()) { -gp_GTrsf2d aTrsf = (myGOPtr->Transform ()).Inverted (); -Standard_Real RX = Standard_Real (SRX), RY = Standard_Real (SRY); - aTrsf.Transforms (RX, RY); - SRX = Standard_ShortReal (RX); SRY = Standard_ShortReal (RY); - } - - Standard_ShortReal lambda = ( myDX * (SRX-myX) + myDY * (SRY-myY) ) - / ( myDX * myDX + myDY * myDY); - Standard_ShortReal Xproj = myX + lambda * myDX; - Standard_ShortReal Yproj = myY + lambda * myDY; - -// On prend comme norme la somme des valeurs absolues: - - return ( Abs ( SRX - Xproj) + Abs ( SRY - Yproj ) ) < aPrecision; -} - -void Graphic2d_InfiniteLine::Reference(Quantity_Length& X,Quantity_Length& Y) const { - X = Quantity_Length( myX ); - Y = Quantity_Length( myY ); -} - -void Graphic2d_InfiniteLine::Slope(Quantity_Length& dX,Quantity_Length& dY) const { - dX = Quantity_Length( myDX ); - dY = Quantity_Length( myDY ); -} - -void Graphic2d_InfiniteLine::Save(Aspect_FStream& aFStream) const -{ - *aFStream << "Graphic2d_InfiniteLine" << endl; - *aFStream << myX << ' ' << myY << endl; - *aFStream << myDX << ' ' << myDY << endl; - Graphic2d_Line::Save(aFStream); -} - -void Graphic2d_InfiniteLine::Retrieve(Aspect_IFStream& anIFStream, - const Handle(Graphic2d_GraphicObject)& aGraphicObject) -{ - Quantity_Length X, Y, dX, dY; - - *anIFStream >> X >> Y; - *anIFStream >> dX >> dY; - Handle(Graphic2d_InfiniteLine) - theILine = new Graphic2d_InfiniteLine(aGraphicObject, X, Y, dX, dY); - ((Handle (Graphic2d_Line))theILine)->Retrieve(anIFStream); -} - diff --git a/src/Graphic2d/Graphic2d_Line.cdl b/src/Graphic2d/Graphic2d_Line.cdl deleted file mode 100755 index 3d826481d0..0000000000 --- a/src/Graphic2d/Graphic2d_Line.cdl +++ /dev/null @@ -1,207 +0,0 @@ --- Created on: 1993-06-22 --- Created by: Jean Louis FRENKEL, Gerard GRAS --- Copyright (c) 1993-1999 Matra Datavision --- Copyright (c) 1999-2012 OPEN CASCADE SAS --- --- The content of this file is subject to the Open CASCADE Technology Public --- License Version 6.5 (the "License"). You may not use the content of this file --- except in compliance with the License. Please obtain a copy of the License --- at http://www.opencascade.org and read it completely before using this file. --- --- The Initial Developer of the Original Code is Open CASCADE S.A.S., having its --- main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. --- --- The Original Code and all software distributed under the License is --- distributed on an "AS IS" basis, without warranty of any kind, and the --- Initial Developer hereby disclaims all such warranties, including without --- limitation, any warranties of merchantability, fitness for a particular --- purpose or non-infringement. Please see the License for the specific terms --- and conditions governing the rights and limitations under the License. - - - -deferred class Line from Graphic2d inherits Primitive from Graphic2d - - ---Version: - - ---Purpose: Groups all the primitives which behaves like - -- geometrical lines. - -- for example: Polyline, Circle ... - - ---Keywords: Primitive, Line - ---Warning: - ---References: - -uses - GraphicObject from Graphic2d, - Drawer from Graphic2d, - TypeOfPolygonFilling from Graphic2d, - Array1OfShortReal from TShort, - FStream from Aspect, - IFStream from Aspect -is - ------------------------- - -- Category: Constructors - ------------------------- - - Initialize (aGraphicObject: GraphicObject from Graphic2d); - ---Level: Public - ---Purpose: Defines a line with the following default values : - -- - Color Index = 1 (the first user defined color) - -- - Width Index = 0 (default 1 pixel width) - -- - Type Index = 0 (default solid line) - -- - Draw Edge = Standard_True - -- - Type Of Polygon Filling = Graphic2d_TOPF_EMPTY - -- - Pattern Index = 0 (default solid polygon filling) - -- - Interior Color Index = 1 (the first user defined color) - ---Category: Constructors - - ---------------------------------------------- - -- Category: Methods to manage line attributes - ---------------------------------------------- - - SetWidthIndex (me: mutable; anIndex: Integer from Standard) - is static; - ---Level: Public - ---Purpose: Defines the index, in the width map, of the line width. - -- Warning: Note that the index 0 can be undefined as a WidthMapEntry, - -- in this case the default line width of 1 pixel is taken. - ---Category: Methods to manage line attributes - - SetTypeIndex (me: mutable; anIndex: Integer from Standard) - is static; - ---Level: Public - ---Purpose: Defines the index, in the type map, of the line type. - -- Warning: Note that the index 0 can be undefined as a TypeMapEntry, - -- in this case the default line type SOLID is taken. - ---Category: Methods to manage line attributes - - SetInteriorColorIndex (me: mutable; anIndex: Integer from Standard) - is static; - ---Level: Public - ---Purpose: Defines the index, in the color map, of the interior - -- color. - -- Warning: The type of polygon filling must be : - -- Graphic2d_TOPF_FILLED - ---Category: Methods to manage line attributes - - SetDrawEdge (me: mutable; aDraw: Boolean from Standard) - is static; - ---Level: Public - ---Purpose: Defines if the edges are drawn or not. - -- Warning: The type of polygon filling must be : - -- Graphic2d_TOPF_FILLED or - -- Graphic2d_TOPF_PATTERNED - ---Category: Methods to manage line attributes - - SetInteriorPattern (me: mutable; anIndex: Integer from Standard) - is static; - ---Level: Public - ---Purpose: Defines the pattern for closed lines. - -- Warning: The type of polygon filling must be : - -- Graphic2d_TOPF_PATTERNED - ---Category: Methods to manage line attributes - - SetTypeOfPolygonFilling (me: mutable; - aType: TypeOfPolygonFilling from Graphic2d) - is static; - ---Level: Public - ---Purpose: Defines the pattern for closed lines. - -- TypeOfPolygonFilling is : - -- - Graphic2d_TOPF_EMPTY - -- - Graphic2d_TOPF_FILLED - -- - Graphic2d_TOPF_PATTERNED - ---Category: Methods to manage line attributes - - DrawLineAttrib(me; aDrawer: Drawer from Graphic2d) - is static protected; - ---Level: Public - ---Purpose: Sets line attributes and polyline attributes - -- in the drawer . - ---Category: Methods to manage line attributes - - DrawMarkerAttrib(me; aDrawer: Drawer from Graphic2d) - is static protected; - ---Level: Public - ---Purpose: Sets marker attributes -in the drawer . - ---Category: Methods to manage line attributes - - ---------------------------- - -- Category: Inquire methods - ---------------------------- - - InteriorColorIndex (me) - returns Integer from Standard - is static; - ---Level: Public - ---Purpose: Returns the interior color used. - ---Category: Inquire methods - - InteriorPattern (me) - returns Integer from Standard - is static; - ---Level: Public - ---Purpose: Returns the interior pattern used. - ---Category: Inquire methods - - TypeOfPolygonFilling (me) - returns TypeOfPolygonFilling from Graphic2d - is static; - ---Level: Public - ---Purpose: Returns the type of polygon filling used. - ---Category: Inquire methods - - TypeIndex (me) - returns Integer from Standard - is static; - ---Level: Public - ---Purpose: Returns the line type index used. - ---Category: Inquire methods - - WidthIndex (me) - returns Integer from Standard - is static; - ---Level: Public - ---Purpose: Returns the line width index used. - ---Category: Inquire methods - - -------------------------- - -- Category: Class methods - -------------------------- - - IsOn (myclass; - aX, aY, aX1, aY1, aX2, aY2, - aPrecision: ShortReal from Standard) - returns Boolean from Standard - is protected ; - ---Level: Internal - ---Purpose: Returns Standard_True if (, ) belongs to - -- the segment (, ), (, ). - ---Category: Class methods - - IsIn (myclass; aX, aY :ShortReal from Standard ; - X, Y : Array1OfShortReal from TShort; - aPrecision : ShortReal from Standard) - returns Boolean from Standard - is protected; - ---Level: Internal - ---Purpose: Returns Standard_True if (, ) is inside the - -- wire defined by the array and . - ---Category: Class methods - - ---------------------------------------------------------------------- - - Save(me; aFStream: in out FStream from Aspect); - Retrieve(me: mutable; anIFStream: in out IFStream from Aspect); - -fields - myWidthIndex: Integer from Standard; - myTypeIndex: Integer from Standard; - myPatternIndex: Integer from Standard; - myInteriorColorIndex: Integer from Standard; - myTypeOfPolygonFilling: TypeOfPolygonFilling from Graphic2d - is protected; - myDrawEdge: Boolean from Standard - is protected; - -end Line from Graphic2d; diff --git a/src/Graphic2d/Graphic2d_Line.cxx b/src/Graphic2d/Graphic2d_Line.cxx deleted file mode 100755 index de8537b524..0000000000 --- a/src/Graphic2d/Graphic2d_Line.cxx +++ /dev/null @@ -1,232 +0,0 @@ -// Copyright (c) 1995-1999 Matra Datavision -// Copyright (c) 1999-2012 OPEN CASCADE SAS -// -// The content of this file is subject to the Open CASCADE Technology Public -// License Version 6.5 (the "License"). You may not use the content of this file -// except in compliance with the License. Please obtain a copy of the License -// at http://www.opencascade.org and read it completely before using this file. -// -// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its -// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. -// -// The Original Code and all software distributed under the License is -// distributed on an "AS IS" basis, without warranty of any kind, and the -// Initial Developer hereby disclaims all such warranties, including without -// limitation, any warranties of merchantability, fitness for a particular -// purpose or non-infringement. Please see the License for the specific terms -// and conditions governing the rights and limitations under the License. - -// Modified 23/02/98 : FMN ; Remplacement PI par Standard_PI - -// 10/11/98 : GG ; Protection sur methode IsOn() lorsque -// les points sont confondus. - -#define G002 //GG_100500 -// Change IsOn method with a best computation on short segments. - -#include - -Graphic2d_Line::Graphic2d_Line (const Handle(Graphic2d_GraphicObject)& aGraphicObject) - :Graphic2d_Primitive (aGraphicObject), - myTypeOfPolygonFilling (Graphic2d_TOPF_EMPTY), - myDrawEdge (Standard_True), - myWidthIndex (0), - myTypeIndex (0), - myPatternIndex (0), - myInteriorColorIndex (1) { - - SetFamily(Graphic2d_TOP_LINE); -} - -void Graphic2d_Line::SetWidthIndex (const Standard_Integer anIndex) { - - myWidthIndex = anIndex; - ResetIndex (); - -} - -void Graphic2d_Line::SetTypeIndex (const Standard_Integer anIndex) { - - myTypeIndex = anIndex; - ResetIndex (); - -} - -void Graphic2d_Line::SetInteriorColorIndex (const Standard_Integer anIndex) { - - myInteriorColorIndex = anIndex; - ResetIndex (); - -} - -void Graphic2d_Line::SetDrawEdge (const Standard_Boolean aDraw) { - - myDrawEdge = aDraw; - ResetIndex (); - -} - -void Graphic2d_Line::SetInteriorPattern (const Standard_Integer anIndex) { - - myPatternIndex = anIndex; - ResetIndex (); - -} - -void Graphic2d_Line::SetTypeOfPolygonFilling (const Graphic2d_TypeOfPolygonFilling aType) { - - myTypeOfPolygonFilling = aType; - ResetIndex (); - -} - -Standard_Integer Graphic2d_Line::WidthIndex () const { - - return myWidthIndex; - -} - -Standard_Integer Graphic2d_Line::InteriorColorIndex () const { - - return myInteriorColorIndex; - -} - -Standard_Integer Graphic2d_Line::InteriorPattern () const { - - return myPatternIndex; - -} - -Graphic2d_TypeOfPolygonFilling Graphic2d_Line::TypeOfPolygonFilling () const { - - return myTypeOfPolygonFilling; - -} - -Standard_Integer Graphic2d_Line::TypeIndex () const { - - return myTypeIndex; - -} - -void Graphic2d_Line::DrawLineAttrib (const Handle(Graphic2d_Drawer)& aDrawer) - const { - - aDrawer->SetLineAttrib (myColorIndex,myTypeIndex,myWidthIndex); - - switch (myTypeOfPolygonFilling) { - case Graphic2d_TOPF_FILLED: - aDrawer->SetPolyAttrib (myInteriorColorIndex,0,myDrawEdge); - break; - case Graphic2d_TOPF_PATTERNED: - aDrawer->SetPolyAttrib (myInteriorColorIndex, - myPatternIndex,myDrawEdge); - break; - default: break; - } - -} - -void Graphic2d_Line::DrawMarkerAttrib (const Handle(Graphic2d_Drawer)& aDrawer) - const { - -Standard_Boolean filled = (myTypeOfPolygonFilling != Graphic2d_TOPF_EMPTY); - - switch (myTypeOfPolygonFilling) { - case Graphic2d_TOPF_FILLED: - aDrawer->SetPolyAttrib (myInteriorColorIndex,0,Standard_False); - break; - case Graphic2d_TOPF_PATTERNED: - aDrawer->SetPolyAttrib (myInteriorColorIndex,myPatternIndex,Standard_False); - break; - default: break; - } - - aDrawer->SetMarkerAttrib (myColorIndex,myWidthIndex,filled); - -} - -Standard_Boolean Graphic2d_Line::IsIn ( const Standard_ShortReal aX, - const Standard_ShortReal aY, - const TShort_Array1OfShortReal& X, - const TShort_Array1OfShortReal& Y, - const Standard_ShortReal aPrecision) -{ - Standard_Integer i1=0,i2=0,n; - Standard_Real dx1,dy1,dx2,dy2,anglesum=0.,angle; - Standard_Real prosca,provec,norme1,norme2,cosin; - n = X.Length (); - for (Standard_Integer m = 1; m <= n; m++) { - i1++; - i2 = (i1 == n) ? 1 : i1 + 1; - dx1 = X(i1) - aX; dy1 = Y(i1) - aY; - dx2 = X(i2) - aX; dy2 = Y(i2) - aY; - prosca = dx1 * dx2 + dy1 * dy2; - provec = dx1 * dy2 - dx2 * dy1; - norme1 = Sqrt ( dx1 * dx1 + dy1 * dy1 ); - norme2 = Sqrt ( dx2 * dx2 + dy2 * dy2 ); - if ( norme1 <= aPrecision || norme2 <= aPrecision ) return Standard_True; - - cosin = prosca / norme1 / norme2; - if ( cosin >= 1 ) angle = 0.; - else { - if ( cosin <= -1) angle = - M_PI; - else - angle = Sign ( ACos ( cosin ) , provec ); - } - anglesum = anglesum + angle;} - return (Abs (anglesum) > 1.) ; -} - -Standard_Boolean Graphic2d_Line::IsOn ( const Standard_ShortReal aX, - const Standard_ShortReal aY, - const Standard_ShortReal aX1, - const Standard_ShortReal aY1, - const Standard_ShortReal aX2, - const Standard_ShortReal aY2, - const Standard_ShortReal aPrecision) -{ - -Standard_ShortReal DX = aX2 - aX1, DY = aY2 - aY1, dd = DX*DX + DY*DY; - - -#ifdef G002 - if( Sqrt(dd) < aPrecision ) -#else - if( dd < aPrecision ) -#endif - return (Abs (aX - aX1) + Abs (aY - aY1)) < aPrecision; - -Standard_ShortReal lambda = (DX*(aX-aX1) + DY*(aY-aY1)) / dd; - - if ( lambda >= 0. && lambda <= 1. ) { - - // On prend comme norme la somme des valeurs absolues: - Standard_ShortReal Xproj = aX1 + lambda * DX; - Standard_ShortReal Yproj = aY1 + lambda * DY; - return (Abs (aX - Xproj) + Abs (aY - Yproj)) < aPrecision; - - } - else - return Standard_False; -} - -void Graphic2d_Line::Save(Aspect_FStream& aFStream) const -{ - *aFStream << myColorIndex << ' ' << myWidthIndex << endl; - *aFStream << myTypeIndex << ' ' << myPatternIndex << endl; - *aFStream << myInteriorColorIndex << ' ' << myTypeOfPolygonFilling << ' ' << myDrawEdge << endl; -} - -void Graphic2d_Line::Retrieve(Aspect_IFStream& anIFStream) -{ - int topf; - *anIFStream >> myColorIndex >> myWidthIndex; - *anIFStream >> myTypeIndex >> myPatternIndex; - *anIFStream >> myInteriorColorIndex; - *anIFStream >> topf; - myTypeOfPolygonFilling=Graphic2d_TypeOfPolygonFilling(topf); - *anIFStream >> myDrawEdge; -} - diff --git a/src/Graphic2d/Graphic2d_Marker.cdl b/src/Graphic2d/Graphic2d_Marker.cdl deleted file mode 100755 index 8d0fdda381..0000000000 --- a/src/Graphic2d/Graphic2d_Marker.cdl +++ /dev/null @@ -1,136 +0,0 @@ --- Created on: 1995-01-26 --- Created by: CAL --- Copyright (c) 1995-1999 Matra Datavision --- Copyright (c) 1999-2012 OPEN CASCADE SAS --- --- The content of this file is subject to the Open CASCADE Technology Public --- License Version 6.5 (the "License"). You may not use the content of this file --- except in compliance with the License. Please obtain a copy of the License --- at http://www.opencascade.org and read it completely before using this file. --- --- The Initial Developer of the Original Code is Open CASCADE S.A.S., having its --- main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. --- --- The Original Code and all software distributed under the License is --- distributed on an "AS IS" basis, without warranty of any kind, and the --- Initial Developer hereby disclaims all such warranties, including without --- limitation, any warranties of merchantability, fitness for a particular --- purpose or non-infringement. Please see the License for the specific terms --- and conditions governing the rights and limitations under the License. - - --- Modified: TCL G002A, 28-11-00, new section "inquire methods" --- SAV 04/07/02 : DrawVertex() redefined. - - -class Marker from Graphic2d inherits Line from Graphic2d - - ---Version: - - ---Purpose: The primitive Marker - - ---Keywords: Primitive, Marker - ---Warning: - ---References: - -uses - Drawer from Graphic2d, - GraphicObject from Graphic2d, - Length from Quantity, - PlaneAngle from Quantity, - FStream from Aspect, - IFStream from Aspect - - -raises - MarkerDefinitionError from Graphic2d - -is - ------------------------- - -- Category: Constructors - ------------------------- - - Create (aGraphicObject: GraphicObject from Graphic2d; - X, Y: Length from Quantity) - returns mutable Marker from Graphic2d; - ---Level: Public - ---Purpose: Creates a pixel point marker at position , - ---Category: Constructors - - Create (aGraphicObject: GraphicObject from Graphic2d; - anIndex: Integer from Standard; - X, Y: Length from Quantity; - aWidth: Length from Quantity; - anHeight: Length from Quantity; - anAngle: PlaneAngle from Quantity = 0.0) - returns mutable Marker from Graphic2d - ---Level: Public - ---Purpose: Creates the predefined marker index - -- at position , and size ,. - -- Angle is measured counterclockwise with 0 radian - -- at 3 o'clock. - ---Category: Constructors - ---Trigger: Raises MarkerDefinitionError if the - -- marker index is <= 0 or undefined in the MarkMap, - -- or the marker size is null. - raises MarkerDefinitionError from Graphic2d; - - -------------------------- - -- Category: Draw and Pick - -------------------------- - - Draw (me : mutable; aDrawer: Drawer from Graphic2d) - is static protected; - ---Level: Internal - ---Purpose: Draws the marker . - - Pick (me : mutable; X, Y: ShortReal from Standard; - aPrecision: ShortReal from Standard; - aDrawer: Drawer from Graphic2d) - returns Boolean from Standard - is static protected; - ---Level: Internal - ---Purpose: Returns Standard_True if the marker is picked, - -- Standard_False if not. - -- Warning: Checks only if the point , is in the - -- boundary rectangle of - - DrawVertex( me : mutable; aDrawer: Drawer from Graphic2d; - anIndex: Integer from Standard) - is redefined protected; - - -------------------------------------- - -- Category: Inquire methods - -------------------------------------- - - Position( me; X, Y: out Length from Quantity ); - ---Level: Public - ---Purpose: returns the coordinates of the position of the marker - - Size( me; aW, aH: out Length from Quantity ); - ---Level: Public - ---Purpose: returns the width and height of the marker - - Index( me ) returns Integer from Standard; - ---Level: Public - ---Purpose: returns the index of marker in the map of markers - - Angle( me ) returns PlaneAngle from Quantity; - ---Level: Public - ---Purpose: returns the angle of the marker - - ---------------------------------------------------------------------- - - Save( me; aFStream: in out FStream from Aspect ) is virtual; --- Retrieve( me; aIFStream: in out IFStream from AIS2D ) is virtual; - -fields - - myMarkIndex: Integer from Standard; - myX: ShortReal from Standard; - myY: ShortReal from Standard; - myWidth: ShortReal from Standard; - myHeight: ShortReal from Standard; - myAngle: ShortReal from Standard; - -end Marker from Graphic2d; diff --git a/src/Graphic2d/Graphic2d_Marker.cxx b/src/Graphic2d/Graphic2d_Marker.cxx deleted file mode 100755 index 85a756c73a..0000000000 --- a/src/Graphic2d/Graphic2d_Marker.cxx +++ /dev/null @@ -1,167 +0,0 @@ -// Copyright (c) 1995-1999 Matra Datavision -// Copyright (c) 1999-2012 OPEN CASCADE SAS -// -// The content of this file is subject to the Open CASCADE Technology Public -// License Version 6.5 (the "License"). You may not use the content of this file -// except in compliance with the License. Please obtain a copy of the License -// at http://www.opencascade.org and read it completely before using this file. -// -// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its -// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. -// -// The Original Code and all software distributed under the License is -// distributed on an "AS IS" basis, without warranty of any kind, and the -// Initial Developer hereby disclaims all such warranties, including without -// limitation, any warranties of merchantability, fitness for a particular -// purpose or non-infringement. Please see the License for the specific terms -// and conditions governing the rights and limitations under the License. - -#define PRO17334 //GG_050199 -// Ne pas raiser si l'index du marker est NULL - -#define OCC451 // SAV DrawVertex redefined. - -#include -#include -#include - -Graphic2d_Marker::Graphic2d_Marker ( - const Handle(Graphic2d_GraphicObject)& aGraphicObject, - const Quantity_Length X, const Quantity_Length Y) - - :Graphic2d_Line (aGraphicObject), - myMarkIndex (0), - myX (Standard_ShortReal (X)), - myY (Standard_ShortReal (Y)), - myWidth (0.0), - myHeight (0.0), - myAngle (0.0) { - - SetFamily(Graphic2d_TOP_MARKER); - myMinX = myMaxX = myX; myMinY = myMaxY = myY ; - -} - -Graphic2d_Marker::Graphic2d_Marker ( - const Handle(Graphic2d_GraphicObject)& aGraphicObject, - const Standard_Integer anIndex, - const Quantity_Length X, const Quantity_Length Y, - const Quantity_Length aWidth, const Quantity_Length anHeight, - const Quantity_PlaneAngle anAngle) - - :Graphic2d_Line (aGraphicObject), - myMarkIndex (anIndex), - myX (Standard_ShortReal (X)), - myY (Standard_ShortReal (Y)), - myWidth (Standard_ShortReal(aWidth)), - myHeight (Standard_ShortReal(anHeight)), - myAngle (Standard_ShortReal(anAngle)) { - -#ifdef PRO17334 - if( myMarkIndex < 0 ) - Graphic2d_MarkerDefinitionError::Raise - ("The marker index must be >= 0"); - else if( myMarkIndex > 0 ) { -#else - if( myMarkIndex <= 0 ) - Graphic2d_MarkerDefinitionError::Raise - ("The marker index must be > 0"); -#endif - if (myWidth <= 0.0) - Graphic2d_MarkerDefinitionError::Raise ("The width = 0."); - - if (myHeight <= 0.0) - Graphic2d_MarkerDefinitionError::Raise ("The height = 0."); -#ifdef PRO17334 - } else { - myWidth = myHeight = 0.; //POINT marker - } -#endif - - SetFamily(Graphic2d_TOP_MARKER); - myMinX = myX - Standard_ShortReal(myWidth/2.); myMinY = myY - Standard_ShortReal(myHeight/2.); - myMaxX = myX + Standard_ShortReal(myWidth/2.); myMaxY = myY + Standard_ShortReal(myHeight/2.); - -} - - -void Graphic2d_Marker::DrawVertex( const Handle(Graphic2d_Drawer)& aDrawer, - const Standard_Integer anIndex ) -{ -#ifdef OCC451 - Draw( aDrawer ); -#endif -} - -void Graphic2d_Marker::Draw (const Handle(Graphic2d_Drawer)& aDrawer) { - -Standard_Boolean IsIn = Standard_False; - - if (! myGOPtr->IsTransformed ()) - IsIn = aDrawer->IsIn (myMinX,myMaxX,myMinY,myMaxY); - else { - Standard_ShortReal minx, miny, maxx, maxy; - MinMax(minx,maxx,miny,maxy); - IsIn = aDrawer->IsIn (minx,maxx,miny,maxy); - } - - if (IsIn) { - -Standard_ShortReal a, b; - a = myX; b = myY; - - if (myGOPtr->IsTransformed ()) { -gp_GTrsf2d aTrsf = myGOPtr->Transform (); -Standard_Real A, B; - A = Standard_Real (a); B = Standard_Real (b); - aTrsf.Transforms (A, B); - a = Standard_ShortReal (A); b = Standard_ShortReal (B); - } - - DrawMarkerAttrib (aDrawer); - aDrawer->MapMarkerFromTo - (myMarkIndex, a, b, myWidth, myHeight, myAngle); - } - -} - -Standard_Boolean Graphic2d_Marker::Pick ( - const Standard_ShortReal X, - const Standard_ShortReal Y, - const Standard_ShortReal aPrecision, - const Handle(Graphic2d_Drawer)& aDrawer) { - -// return IsInMinMax (X, Y, aPrecision); - if ( IsInMinMax (X, Y, aPrecision) ) { - SetPickedIndex( -1 ); - return Standard_True; - } - else { - SetPickedIndex( 0 ); - return Standard_False; - } -} - -void Graphic2d_Marker::Position(Quantity_Length& X,Quantity_Length& Y) const { - - X = Quantity_Length( myX ); - Y = Quantity_Length( myY ); -} - -void Graphic2d_Marker::Size(Quantity_Length& aW,Quantity_Length& aH) const { - - aW = Quantity_Length( myWidth ); - aH = Quantity_Length( myHeight ); -} - -Standard_Integer Graphic2d_Marker::Index() const { - return myMarkIndex; -} - -Quantity_PlaneAngle Graphic2d_Marker::Angle() const { - return Quantity_PlaneAngle( myAngle ); -} - -void Graphic2d_Marker::Save(Aspect_FStream& aFStream) const -{ -} diff --git a/src/Graphic2d/Graphic2d_Paragraph.cdl b/src/Graphic2d/Graphic2d_Paragraph.cdl deleted file mode 100755 index 86be33f81f..0000000000 --- a/src/Graphic2d/Graphic2d_Paragraph.cdl +++ /dev/null @@ -1,356 +0,0 @@ --- Created on: 1995-06-12 --- Created by: Gerard GRAS --- Copyright (c) 1995-1999 Matra Datavision --- Copyright (c) 1999-2012 OPEN CASCADE SAS --- --- The content of this file is subject to the Open CASCADE Technology Public --- License Version 6.5 (the "License"). You may not use the content of this file --- except in compliance with the License. Please obtain a copy of the License --- at http://www.opencascade.org and read it completely before using this file. --- --- The Initial Developer of the Original Code is Open CASCADE S.A.S., having its --- main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. --- --- The Original Code and all software distributed under the License is --- distributed on an "AS IS" basis, without warranty of any kind, and the --- Initial Developer hereby disclaims all such warranties, including without --- limitation, any warranties of merchantability, fitness for a particular --- purpose or non-infringement. Please see the License for the specific terms --- and conditions governing the rights and limitations under the License. - - --- Update: GG 20/08/98 PERFORMANCE --- Change Update() method by ComputeMinMax() method - - -class Paragraph from Graphic2d inherits Primitive from Graphic2d - - ---Version: - - ---Purpose: The primitive Paragraph - -- contains a row column of editable texts - -- each text can have a different color and font index. - - ---Keywords: Primitive, Paragraph, Text - ---Warning: - ---References: - -uses - Drawer from Graphic2d, - GraphicObject from Graphic2d, - TypeOfAlignment from Graphic2d, - PlaneAngle from Quantity, - Ratio from Quantity, - Factor from Quantity, - Length from Quantity, - ExtendedString from TCollection, - SequenceOfInteger from TColStd, - SequenceOfShortReal from TShort, - SequenceOfExtendedString from TColStd, - CardinalPoints from Aspect, - FStream from Aspect, - IFStream from Aspect - -raises - OutOfRange from Standard - -is - ------------------------- - -- Category: Constructors - ------------------------- - - Create (aGraphicObject: GraphicObject from Graphic2d; - X, Y: Real from Standard; - anAngle: PlaneAngle from Quantity = 0.0; - anOffset: CardinalPoints from Aspect = Aspect_CP_Center; - aScale: Factor from Quantity = 1.0) - returns mutable Paragraph from Graphic2d; - ---Level: Public - ---Purpose: Creates a paragraph in a graphic object - -- The reference point is , . - -- The orientation angle is . - -- The offset position of the reference point is - -- depending of the size of paragraph. - -- The paragraph scale. - -- Angles are measured counterclockwise with 0 radian - -- at 3 o'clock. - -- Warning: a paragraph can be orientable.slantable and zoomable - -- only when this options are enable regardless of the graphic driver. - -- i.e: Xw driver does not,but Xdps or PS driver does. - ---Category: Constructors - - --------------------------------------------------- - -- Category: Methods to modify the class definition - --------------------------------------------------- - - SetSlant (me: mutable; aSlant: PlaneAngle from Quantity = 0.0) - is static; - ---Level: Public - ---Purpose: Sets the slant angle of the paragraph . - ---Category: Paragraph management - - SetSpacing(me: mutable; aSpacing: Ratio from Quantity = 0.5) - is static; - ---Level: Public - ---Purpose: Sets the line spacing ratio for the paragraph . - -- the spacing height between two lines depends of - -- the spacing factor apply on the height of the line currently -- writen. - ---Category: Paragraph management - - SetMargin(me: mutable; aMargin: Length from Quantity = 0.0) - is static; - ---Level: Public - ---Purpose: Sets the fixed margin for the paragraph . - ---Category: Paragraph management - - SetZoomable (me: mutable; aFlag: Boolean from Standard = Standard_False) - is static; - ---Level: Public - ---Purpose: The paragraph follows the scale factor of the view - -- if the flag is Standard_True. - ---Category: Zoom management - - - SetFrameColorIndex (me:mutable; anIndex: Integer from Standard = 0) - is static; - ---Level: Public - ---Purpose: Sets the frame color index for the paragraph . - -- Warning: Note that the paragraph frame is drawn only when index - -- is > 0. - ---Category: Paragraph management - - SetFrameWidthIndex (me:mutable; anIndex: Integer from Standard = 0) - is static; - ---Level: Public - ---Purpose: Sets the width index for the frame of the paragraph . - -- default width is 0 (1 pixel out line frame is drawn). - - SetHidingColorIndex (me:mutable; anIndex: Integer from Standard = 0) - is static; - ---Level: Public - ---Purpose: Sets the hiding color index for the paragraph . - -- Warning: Note that the paragraph background is filled only when index - -- is >= 0. - -- A value of 0 permits to drawn the paragraph background with - -- the current view background color. - ---Category: Paragraph management - - SetCurrentColorIndex (me:mutable; anIndex: Integer from Standard = 1) - is static; - ---Level: Public - ---Purpose: Sets the current color index for the paragraph . - -- Warning: Note that the index 0 can be undefined as a ColorMapEntry, - -- in this case the default color is taken. - ---Category: Paragraph management - - SetCurrentFontIndex (me:mutable; anIndex: Integer from Standard = 0; - aHScale: Length from Quantity = 1.0; - aWScale: Length from Quantity = 1.0) - is static; - ---Level: Public - ---Purpose: Sets the current font index and scales for the paragraph . - -- Warning: Note that the index 0 can be undefined as a FontMapEntry , - -- in this case the default system text font is taken. - ---Category: Paragraph management - - SetCurrentAlignment (me:mutable; anAlignment: TypeOfAlignment from Graphic2d = - Graphic2d_TOA_LEFT) - is static; - ---Level: Public - ---Purpose: Sets the current text alignment for the paragraph . - ---Category: Paragraph management - - SetCurrentUnderline (me:mutable; isUnderlined: Boolean from Standard = - Standard_False) - is static; - ---Level: Public - ---Purpose: Sets the current text underline flag for the paragraph . - ---Category: Paragraph management - - AddText (me: mutable; aText: ExtendedString from TCollection; - aRow: Integer from Standard = 0; - aColumn: Integer from Standard = 0) - is static; - ---Level: Public - ---Purpose: Adds a text at a row-column position in the paragraph - -- with the current Color,Font,Alignment attributes - -- at the position if and are > 0 - -- or at the end of the line if is 0, - -- or at the end of the paragraph if is 0. - ---Category: Paragraph management - - ChangeText (me: mutable; aText: ExtendedString from TCollection; - aRow: Integer from Standard; - aColumn: Integer from Standard) - is static; - ---Level: Public - ---Purpose: Changes a text in the paragraph at a row-column position, - -- don't change the attributes of the text. - -- Warning: May do nothing if the row-column don't exist in the - -- paragraph. - ---Category: Paragraph management - - Clear (me: mutable) is static; - ---Level: Public - ---Purpose: Clear ALL the text in the paragraph . - ---Category: Paragraph management - - -------------------------- - -- Category: Draw and Pick - -------------------------- - - Draw (me : mutable; aDrawer: Drawer from Graphic2d) - is static protected; - ---Level: Internal - ---Purpose: Draws the paragraph . - - Pick (me : mutable; X, Y: ShortReal from Standard; - aPrecision: ShortReal from Standard; - aDrawer: Drawer from Graphic2d) - returns Boolean from Standard - is static protected; - ---Level: Internal - ---Purpose: Returns Standard_True if the paragraph is picked, - -- Standard_False if not. - - - ---------------------------- - -- Category: Inquire methods - ---------------------------- - - IsZoomable (me) - returns Boolean from Standard is static; - ---Level: Internal - ---Purpose: Returns Standard_True if the Paragraph follows - -- the scale factor of the view. - ---Category: Zoom management - - Size (me; aWidth,aHeight: out Length from Quantity) is static; - ---Level: Public - ---Purpose: Returns the size of the paragraph . - ---Category: Paragraph management - - Position (me; X,Y: out Length from Quantity) is static; - ---Level: Public - ---Purpose: Returns the paragraph position. - - Offset (me; Dx,Dy: out Length from Quantity) - returns CardinalPoints from Aspect is static; - ---Level: Public - ---Purpose: Returns the paragraph Offset. - - Angle (me) returns PlaneAngle from Quantity is static; - ---Level: Public - ---Purpose: Returns the paragraph orientation. - - Slant (me) returns PlaneAngle from Quantity is static; - ---Level: Public - ---Purpose: Returns the paragraph slant. - - Spacing (me) returns Ratio from Quantity is static; - ---Level: Public - ---Purpose: Returns the paragraph spacing ratio. - - Margin (me) returns Length from Quantity is static; - ---Level: Public - ---Purpose: Returns the paragraph margin value. - - HidingColorIndex (me) returns Integer from Standard is static; - ---Level: Public - ---Purpose: Returns the paragraph hiding color index. - - FrameColorIndex (me) returns Integer from Standard is static; - ---Level: Public - ---Purpose: Returns the paragraph frame color index. - - FrameWidthIndex (me) returns Integer from Standard is static; - ---Level: Public - ---Purpose: Returns the paragraph frame width index. - - Text( me; aRank: Integer from Standard; - aRow,aColumn: out Integer from Standard; - aColorIndex,aFontIndex: out Integer from Standard; - anAlignment: out TypeOfAlignment from Graphic2d) - returns ExtendedString from TCollection - ---Level: Public - ---Purpose: Returns the text string and attributes of rank . - raises OutOfRange is static; - ---Trigger: if aRank is < 1 or > Length(). - ---Category: Paragraph management - - TextSize (me; aRank: Integer from Standard; - aWidth,aHeight,anXoffset,anYoffset: out Length from Quantity) - returns Boolean from Standard - ---Level: Public - ---Purpose: Returns Standard_True if the current Driver used is enabled - -- to get the right size and offsets in the - -- world size parameter ,,, - -- depending of the attributes of the paragraph text position - -- and the current scale of the view. - -- NOTE that the text offsets defines the relative position of the - -- of the text string origin from the lower left corner of the text - -- boundary limits. - raises OutOfRange is static; - ---Trigger: if aRank is < 1 or > Length(). - ---Category: Paragraph management - - Length (me) returns Integer is static; - ---Level: Public - ---Purpose: Returns the number of Text of the paragraph . - - MaxRow (me) returns Integer is static; - ---Level: Public - ---Purpose: Returns the number of Row of the paragraph . - - MaxColumn (me) returns Integer is static; - ---Level: Public - ---Purpose: Returns the number of Column of the paragraph . - - ---------------------------- - -- Category: Private methods - ---------------------------- - - ComputeMinMax (me : mutable) - returns Boolean from Standard is redefined static; - ---Level: Internal - ---Purpose: Computes the MinMax of the paragraph if possible. - - ---------------------------------------------------------------------- - - Save( me; aFStream: in out FStream from Aspect ) is virtual; --- Retrieve( me; aIFStream: in out IFStream from AIS2D ) is virtual; - -fields - - myX: ShortReal from Standard; - myY: ShortReal from Standard; - myXoffset: ShortReal from Standard; - myYoffset: ShortReal from Standard; - myOffset: CardinalPoints from Aspect; - myWidth: ShortReal from Standard; - myHeight: ShortReal from Standard; - myAngle: ShortReal from Standard; - mySlant: ShortReal from Standard; - mySpacing: ShortReal from Standard; - myMargin: ShortReal from Standard; - myScale: ShortReal from Standard; - myIsZoomable: Boolean from Standard; - myFrameColorIndex: Integer from Standard; - myFrameWidthIndex: Integer from Standard; - myHidingColorIndex: Integer from Standard; - myCurrentColorIndex: Integer from Standard; - myCurrentFontIndex: Integer from Standard; - myCurrentFontHScale: ShortReal from Standard; - myCurrentFontWScale: ShortReal from Standard; - myCurrentAlignment: TypeOfAlignment from Graphic2d; - myCurrentUnderline: Boolean from Standard; - myTextStringList: SequenceOfExtendedString from TColStd; - myTextDescriptorList: SequenceOfInteger from TColStd; - myTextXpositionList: SequenceOfShortReal from TShort; - myTextYpositionList: SequenceOfShortReal from TShort; - myTextFheightList: SequenceOfShortReal from TShort; - myTextFoffsetList: SequenceOfShortReal from TShort; - myTextHScaleList: SequenceOfShortReal from TShort; - myTextWScaleList: SequenceOfShortReal from TShort; - -end Paragraph from Graphic2d; diff --git a/src/Graphic2d/Graphic2d_Paragraph.cxx b/src/Graphic2d/Graphic2d_Paragraph.cxx deleted file mode 100755 index bfe6c155ce..0000000000 --- a/src/Graphic2d/Graphic2d_Paragraph.cxx +++ /dev/null @@ -1,913 +0,0 @@ -// Copyright (c) 1995-1999 Matra Datavision -// Copyright (c) 1999-2012 OPEN CASCADE SAS -// -// The content of this file is subject to the Open CASCADE Technology Public -// License Version 6.5 (the "License"). You may not use the content of this file -// except in compliance with the License. Please obtain a copy of the License -// at http://www.opencascade.org and read it completely before using this file. -// -// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its -// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. -// -// The Original Code and all software distributed under the License is -// distributed on an "AS IS" basis, without warranty of any kind, and the -// Initial Developer hereby disclaims all such warranties, including without -// limitation, any warranties of merchantability, fitness for a particular -// purpose or non-infringement. Please see the License for the specific terms -// and conditions governing the rights and limitations under the License. - -/*===================================================================== - - FONCTION : - ---------- - Classe Graphic2d_Paragraph - - TEST : - ------ - - Voir TestG2D/TestG21 - -=====================================================================*/ - -#define PRO12982 //GG_230498 -// Take into account the underlining in calculation of -// paragraph size. - -#define PRO11004 //GG_051197 -// The contour of the paragraph is not rectangle - -#define PRO11005 //GG_131197 -// Text can't be seen in mode Highlight. - -#define PRO11041 //GG_201197 -// Modification of SetCurrentFont(...,aHScale,aWScale) -// to parameterize the size of the text. - -#define PRO12320//GG_120297 -// Compose texts depending on the summary height of the -// chain of characters. - -#define PERF //GG_200898 -// The MinMax are now computed at the right time and no more -// soon an attribute has change -// (see the redefined method ComputeMinMax()). - -#include -#include -#include - -#include - -#define MAXCOLUMN 16 -#define MAXROW 256 -#define MAXCOLOR 64 -#define MAXFONT 256 -#define MAXALIGNMENT 16 -#define MAXUNDERLINE 2 -#define TEXT_DESCRIPTOR(row,column,color,font,align,underline) \ - ((column) | (row)*MAXCOLUMN | (color)*MAXCOLUMN*MAXROW | \ - (font)*MAXCOLUMN*MAXROW*MAXCOLOR | \ - (align)*MAXCOLUMN*MAXROW*MAXCOLOR*MAXFONT | \ - (underline)*MAXCOLUMN*MAXROW*MAXCOLOR*MAXFONT*MAXALIGNMENT) -#define TEXT_POSITION(descriptor) ((descriptor)&(MAXCOLUMN*MAXROW-1)) -#define TEXT_COLUMN(descriptor) ((descriptor)&(MAXCOLUMN-1)) -#define TEXT_ROW(descriptor) (((descriptor)/MAXCOLUMN)&(MAXROW-1)) -#define TEXT_COLOR(descriptor) (((descriptor)/(MAXCOLUMN*MAXROW))&(MAXCOLOR-1)) -#define TEXT_FONT(descriptor) (((descriptor)/(MAXCOLUMN*MAXROW*MAXCOLOR))&(MAXFONT-1)) -#define TEXT_ALIGNMENT(descriptor) (((descriptor)/(MAXCOLUMN*MAXROW*MAXCOLOR*MAXFONT))&(MAXALIGNMENT-1)) -#define TEXT_UNDERLINE(descriptor) (((descriptor)/(MAXCOLUMN*MAXROW*MAXCOLOR*MAXFONT*MAXALIGNMENT))&(MAXUNDERLINE-1)) - -Graphic2d_Paragraph::Graphic2d_Paragraph - (const Handle(Graphic2d_GraphicObject)& aGraphicObject, - const Standard_Real X, const Standard_Real Y, - const Quantity_PlaneAngle anAngle, - const Aspect_CardinalPoints anOffset, - const Quantity_Factor aScale) - : Graphic2d_Primitive (aGraphicObject), - myX( Standard_ShortReal( X ) ), - myY( Standard_ShortReal( Y ) ), - myXoffset(0.), - myYoffset(0.), - myOffset(anOffset), - myWidth(0.), - myHeight(0.), - myAngle(Standard_ShortReal( anAngle )), - myScale(Standard_ShortReal( aScale )), - myTextStringList(), - myTextDescriptorList(), - myTextXpositionList(), - myTextYpositionList(), - myTextFheightList(), - myTextFoffsetList(), - myTextHScaleList(), - myTextWScaleList() { - - while (myAngle < 0.) myAngle += Standard_ShortReal( 2. * M_PI ); - while (myAngle >= 2. * M_PI) myAngle -= Standard_ShortReal( 2. * M_PI ); - - SetZoomable() ; - SetSlant() ; - SetSpacing() ; - SetMargin() ; - SetFrameColorIndex() ; - SetFrameWidthIndex() ; - SetHidingColorIndex() ; - SetCurrentColorIndex() ; - SetCurrentFontIndex() ; - SetCurrentAlignment() ; - SetCurrentUnderline() ; -} - -void Graphic2d_Paragraph::SetHidingColorIndex (const Standard_Integer anIndex) -{ - - myHidingColorIndex = anIndex; - -} - -void Graphic2d_Paragraph::SetFrameColorIndex (const Standard_Integer anIndex) { - - myFrameColorIndex = anIndex; - -} - -void Graphic2d_Paragraph::SetFrameWidthIndex (const Standard_Integer anIndex) { - - myFrameWidthIndex = anIndex; - -} - -void Graphic2d_Paragraph::SetCurrentColorIndex (const Standard_Integer anIndex) { - - myCurrentColorIndex = anIndex; - -} - -void Graphic2d_Paragraph::SetCurrentFontIndex (const Standard_Integer anIndex,const Quantity_Length aHScale,const Quantity_Length aWScale) { - - myCurrentFontIndex = anIndex; - myCurrentFontHScale = (aHScale > 0.) ? - Standard_ShortReal( aHScale ) : Standard_ShortReal( 1. ); - myCurrentFontWScale = - (aWScale > 0.) ? Standard_ShortReal( aWScale ) : myCurrentFontHScale; - -} - -void Graphic2d_Paragraph::SetCurrentAlignment (const Graphic2d_TypeOfAlignment anAlignment) { - - myCurrentAlignment = anAlignment; -} - -void Graphic2d_Paragraph::SetCurrentUnderline (const Standard_Boolean isUnderlined) { - - myCurrentUnderline = isUnderlined; -} - -void Graphic2d_Paragraph::SetSlant (const Quantity_PlaneAngle aSlant) { - - mySlant = Standard_ShortReal( aSlant ); - while (mySlant < 0.) mySlant += Standard_ShortReal( 2. * M_PI ); - while (mySlant >= 2. * M_PI) mySlant -= Standard_ShortReal( 2. * M_PI ); -} - -void Graphic2d_Paragraph::SetSpacing (const Quantity_Ratio aSpacing) { - - mySpacing = Standard_ShortReal( aSpacing ); -#ifdef PERF - myMinX = myMinY = ShortRealLast (); - myMaxX = myMaxY = ShortRealFirst (); -#else - Update(); -#endif -} - -void Graphic2d_Paragraph::SetMargin (const Quantity_Length aMargin) { - -#ifdef PRO12982 - myMargin = Standard_ShortReal( aMargin * myScale ); -#else - myMargin = Standard_ShortReal( aMargin ); -#endif -#ifdef PERF - myMinX = myMinY = ShortRealLast (); - myMaxX = myMaxY = ShortRealFirst (); -#else - Update(); -#endif -} - -Standard_Boolean Graphic2d_Paragraph::IsZoomable () const { - - return myIsZoomable; - -} - -void Graphic2d_Paragraph::SetZoomable (const Standard_Boolean aFlag) { - - myIsZoomable = aFlag; -#ifdef PERF - myMinX = myMinY = ShortRealLast (); - myMaxX = myMaxY = ShortRealFirst (); -#else - Update(); -#endif -} - -void Graphic2d_Paragraph::AddText (const TCollection_ExtendedString &aText, - const Standard_Integer aRow, - const Standard_Integer aColumn) { -Standard_Integer i,length = myTextDescriptorList.Length() ; -Standard_Integer row = (aRow > 0) ? Min(aRow,MAXROW-1) : MAXROW-1 ; -Standard_Integer column = (aColumn > 0) ? Min(aColumn,MAXCOLUMN-1) : MAXCOLUMN-1 ; -Standard_Integer descriptor = TEXT_DESCRIPTOR(row,column,myCurrentColorIndex, - myCurrentFontIndex,myCurrentAlignment,myCurrentUnderline) ; -Standard_Integer the_position = TEXT_POSITION(descriptor) ; - - for( i=1 ; i<=length ; i++ ) { - Standard_Integer cur_position = - TEXT_POSITION(myTextDescriptorList.Value(i)) ; - if( the_position == cur_position ) { - myTextDescriptorList.SetValue(i,descriptor) ; - myTextStringList.SetValue(i,aText) ; - myTextHScaleList.SetValue(i,myCurrentFontHScale); - myTextWScaleList.SetValue(i,myCurrentFontWScale); - return ; - } - if( the_position < cur_position ) break ; - } - - if( i > length ) { - if( aRow <= 0 || aColumn <= 0 ) { - if( aRow <= 0 ) { - if( length > 0 ) { - row = TEXT_ROW(myTextDescriptorList.Value(length))+1 ; - row = Min(row,MAXROW-1) ; - } else { - row = 1 ; - } - } - if( aColumn <= 0 ) { - if( length > 0 ) { - if( row == TEXT_ROW(myTextDescriptorList.Value(length)) ) { - column = TEXT_COLUMN(myTextDescriptorList.Value(length))+1 ; - column = Min(column,MAXCOLUMN-1) ; - } else { - column = 1; - } - } else { - column = 1 ; - } - } - descriptor = TEXT_DESCRIPTOR(row,column,myCurrentColorIndex, - myCurrentFontIndex,myCurrentAlignment,myCurrentUnderline) ; - } - myTextDescriptorList.Append(descriptor) ; - myTextStringList.Append(aText) ; - myTextXpositionList.Append(0.) ; - myTextYpositionList.Append(0.) ; - myTextFheightList.Append(0.) ; - myTextFoffsetList.Append(0.) ; - myTextHScaleList.Append(myCurrentFontHScale) ; - myTextWScaleList.Append(myCurrentFontWScale) ; - } else { - if( aRow <= 0 || aColumn <= 0 ) { - if( aRow <= 0 ) { - if( i > 1 ) { - row = TEXT_ROW(myTextDescriptorList.Value(i-1))+1 ; - row = Min(row,MAXROW-1) ; - } else { - row = 1 ; - } - } - if( aColumn <= 0 ) { - if( i > 1 ) { - if( row == TEXT_ROW(myTextDescriptorList.Value(i-1)) ) { - column = TEXT_COLUMN(myTextDescriptorList.Value(i-1))+1 ; - column = Min(column,MAXCOLUMN-1) ; - } else { - column = 1; - } - } else { - column = 1 ; - } - } - descriptor = TEXT_DESCRIPTOR(row,column,myCurrentColorIndex, - myCurrentFontIndex,myCurrentAlignment,myCurrentUnderline) ; - } - myTextDescriptorList.InsertBefore(i,descriptor) ; - myTextStringList.InsertBefore(i,aText) ; - myTextXpositionList.InsertBefore(i,0.) ; - myTextYpositionList.InsertBefore(i,0.) ; - myTextFheightList.InsertBefore(i,0.) ; - myTextFoffsetList.InsertBefore(i,0.) ; - myTextHScaleList.InsertBefore(i,myCurrentFontHScale); - myTextWScaleList.InsertBefore(i,myCurrentFontWScale); - } -#ifdef PERF - myMinX = myMinY = ShortRealLast (); - myMaxX = myMaxY = ShortRealFirst (); -#else - Update(); -#endif - -} - -void Graphic2d_Paragraph::ChangeText (const TCollection_ExtendedString &aText, - const Standard_Integer aRow, - const Standard_Integer aColumn) { -Standard_Integer i,length = myTextDescriptorList.Length() ; - -Standard_Integer descriptor = TEXT_DESCRIPTOR(aRow,aColumn,0,0,0,0) ; -Standard_Integer the_position = TEXT_POSITION(descriptor) ; - - for( i=1 ; i<=length ; i++ ) { - Standard_Integer cur_position = - TEXT_POSITION(myTextDescriptorList.Value(i)) ; - if( the_position == cur_position ) { - myTextStringList.SetValue(i,aText) ; -#ifdef PERF - myMinX = myMinY = ShortRealLast (); - myMaxX = myMaxY = ShortRealFirst (); -#else - Update() ; -#endif - return ; - } - } - -} - -void Graphic2d_Paragraph::Clear() { - - myTextDescriptorList.Clear() ; - myTextStringList.Clear() ; - myTextXpositionList.Clear() ; - myTextYpositionList.Clear() ; - myTextFheightList.Clear() ; - myTextFoffsetList.Clear() ; - myTextHScaleList.Clear() ; - myTextWScaleList.Clear() ; -#ifdef PERF - myMinX = myMinY = ShortRealLast (); - myMaxX = myMaxY = ShortRealFirst (); -#else - Update(); -#endif -} - -void Graphic2d_Paragraph::Draw (const Handle(Graphic2d_Drawer)& aDrawer) { -//Standard_Integer descriptor,row = 0 ; -Standard_Integer descriptor ; -TCollection_ExtendedString atext ; -Standard_ShortReal x = 0, y = 0, dx, dy, - sina = Standard_ShortReal( Sin(myAngle) ), - cosa = Standard_ShortReal( Cos(myAngle) ); -//Standard_Integer i,j,lrow,length = myTextDescriptorList.Length() ; -Standard_Integer i,length = myTextDescriptorList.Length() ; -Standard_Boolean IsIn = Standard_False; -Standard_ShortReal hscale,wscale,scale = (myIsZoomable) ? myScale*aDrawer->Scale() : myScale; -#ifdef PRO12982 -Standard_ShortReal rscale = 1.; -#else -Standard_ShortReal rscale = 1./myScale; -#endif - -#ifdef PERF - if( (myMaxX < myMinX) || (myMaxY < myMinY) ) { - if( !ComputeMinMax() ) return; - } -#else - if( myWidth <= 0. ) { - Update(); - } -#endif - -static TShort_Array1OfShortReal theXarray(1,5) ; -static TShort_Array1OfShortReal theYarray(1,5) ; - - // We have to draw frame without drawer's scaling - // because drawer's scale will betaken into consideration - // in MapPolylineFromTo(), MapPolygonFromTo(). - // The same concerns test's position. - if (!myIsZoomable) - rscale = aDrawer->Scale(); - if (! myGOPtr->IsTransformed ()) { - IsIn = aDrawer->IsIn (myMinX,myMaxX,myMinY,myMaxY); - if (IsIn) { - if( myFrameColorIndex > 0 || myHidingColorIndex >= 0 ) { - theXarray.SetValue(1,myX+XROTATE(myXoffset,myYoffset)/rscale) ; - theYarray.SetValue(1,myY+YROTATE(myXoffset,myYoffset)/rscale) ; - theXarray.SetValue(2,myX+XROTATE(myXoffset+myWidth,myYoffset)/rscale) ; - theYarray.SetValue(2,myY+YROTATE(myXoffset+myWidth,myYoffset)/rscale) ; - theXarray.SetValue(3,myX+XROTATE(myXoffset+myWidth,myYoffset-myHeight)/rscale) ; -#ifdef PRO11004 - theYarray.SetValue(3,myY+YROTATE(myXoffset+myWidth,myYoffset-myHeight)/rscale) ; -#else - theYarray.SetValue(3,YROTATE(myXoffset+myWidth,myYoffset-myHeight)/rscale) ; -#endif - theXarray.SetValue(4,myX+XROTATE(myXoffset,myYoffset-myHeight)/rscale) ; - theYarray.SetValue(4,myY+YROTATE(myXoffset,myYoffset-myHeight)/rscale) ; - theXarray.SetValue(5,myX+XROTATE(myXoffset,myYoffset)/rscale) ; - theYarray.SetValue(5,myY+YROTATE(myXoffset,myYoffset)/rscale) ; -#ifdef PRO11005 - if( myHidingColorIndex >= 0 ) { - aDrawer->SetHidingTextAttrib(-1,myHidingColorIndex, - myFrameColorIndex,myFrameWidthIndex, - -1,0.,1.,1.,Standard_False); - aDrawer->MapPolygonFromTo(theXarray, theYarray, 4); - } else { - aDrawer->SetFramedTextAttrib(-1,myFrameColorIndex, - myFrameWidthIndex,-1,0.,1.,1.,Standard_False); - aDrawer->MapPolylineFromTo(theXarray, theYarray, 5); - } -#else - if( myHidingColorIndex >= 0 ) { - aDrawer->SetPolyAttrib(myHidingColorIndex,0,Standard_False) ; - aDrawer->MapPolygonFromTo(theXarray, theYarray, 4); - } - if( myFrameColorIndex > 0 ) { - aDrawer->SetLineAttrib(myFrameColorIndex,0,myFrameWidthIndex) ; - aDrawer->MapPolylineFromTo(theXarray, theYarray, 5); - } -#endif - } - for( i=1 ; i<=length ; i++ ) { - descriptor = myTextDescriptorList.Value(i) ; - atext = myTextStringList.Value(i) ; - dx = myXoffset + myTextXpositionList.Value(i); - dy = myYoffset + myTextYpositionList.Value(i); - x = XROTATE(dx,dy)/rscale ; y = YROTATE(dx,dy)/rscale; - hscale = scale*myTextHScaleList.Value(i); - wscale = scale*myTextWScaleList.Value(i); - aDrawer->SetTextAttrib(TEXT_COLOR(descriptor), - TEXT_FONT(descriptor),mySlant,hscale,wscale, - TEXT_UNDERLINE(descriptor)); - aDrawer->MapTextFromTo(atext,myX+x,myY+y, - myAngle,0.,0.,Aspect_TOT_SOLID); - } - } - } else { - gp_GTrsf2d aTrsf = myGOPtr->Transform (); - Standard_ShortReal minx,miny,maxx,maxy; - MinMax(minx,maxx,miny,maxy); - IsIn = aDrawer->IsIn (minx,maxx,miny,maxy); - if (IsIn) { - Standard_Real A = Standard_Real (myX); - Standard_Real B = Standard_Real (myY); - Standard_Real C = Standard_Real (myAngle); - Standard_Real cosa = Cos (C); - Standard_Real sina = Sin (C); - - aTrsf.Transforms (A, B); - - // To calculate new aperture angles - // the calculation is done on trigonometric circle - // and in this case translation is not taken into account. - aTrsf.SetValue (1, 3, 0.0); - aTrsf.SetValue (2, 3, 0.0); - aTrsf.Transforms (cosa, sina); - - Standard_ShortReal tscale = 1.; - Standard_ShortReal x0 = myXoffset; - Standard_ShortReal y0 = myYoffset; - Standard_ShortReal w = myWidth; - Standard_ShortReal h = myHeight; - C = atan2(sina,cosa); - Standard_ShortReal angle = Standard_ShortReal (C); - if ( myIsZoomable ) { - tscale = Standard_ShortReal( Sqrt(cosa*cosa + sina*sina) ); - scale *= Standard_ShortReal( tscale ); - x0 *= tscale; y0 *= tscale; - w *= tscale; h *= tscale; - } - cosa = Cos(C) ; sina = Sin(C) ; - if( myFrameColorIndex > 0 || myHidingColorIndex >= 0 ) { - dx = Standard_ShortReal( XROTATE(x0,y0)/rscale ); - dy = Standard_ShortReal( YROTATE(x0,y0)/rscale ); - theXarray.SetValue( 1, x + dx ); - theYarray.SetValue( 1, y + dy ); - dx = Standard_ShortReal( XROTATE(x0+w,y0)/rscale ); - dy = Standard_ShortReal( YROTATE(x0+w,y0)/rscale ); - theXarray.SetValue(2,x+dx) ; theYarray.SetValue(2,y+dy) ; - dx = Standard_ShortReal( XROTATE(x0+w,y0-h)/rscale ); - dy = Standard_ShortReal( YROTATE(x0+w,y0-h)/rscale ); - theXarray.SetValue(3,x+dx) ; - theYarray.SetValue(3,y+dy) ; - dx = Standard_ShortReal( XROTATE(x0,y0-h)/rscale ); - dy = Standard_ShortReal( YROTATE(x0,y0-h)/rscale ); - theXarray.SetValue(4,x+dx) ; theYarray.SetValue(4,y+dy) ; - dx = Standard_ShortReal( XROTATE(x0,y0)/rscale ); - dy = Standard_ShortReal( YROTATE(x0,y0)/rscale ); - theXarray.SetValue(5,x+dx) ; theYarray.SetValue(5,y+dy) ; -#ifdef PRO11005 - if( myHidingColorIndex >= 0 ) { - aDrawer->SetHidingTextAttrib(-1,myHidingColorIndex, - myFrameColorIndex,myFrameWidthIndex, - -1,0.,1.,1.,Standard_False); - aDrawer->MapPolygonFromTo(theXarray, theYarray, 4); - } else { - aDrawer->SetFramedTextAttrib(-1,myFrameColorIndex, - myFrameWidthIndex,-1,0.,1.,1.,Standard_False); - aDrawer->MapPolylineFromTo(theXarray, theYarray, 5); - } -#else - if( myHidingColorIndex >= 0 ) { - aDrawer->SetPolyAttrib(myHidingColorIndex,0,Standard_False) ; - aDrawer->MapPolygonFromTo(theXarray, theYarray, 4); - } - if( myFrameColorIndex > 0 ) { - aDrawer->SetLineAttrib(myFrameColorIndex,0,myFrameWidthIndex) ; - aDrawer->MapPolylineFromTo(theXarray, theYarray, 5); - } -#endif - } - Standard_ShortReal tx,ty; - for( i=1 ; i<=length ; i++ ) { - descriptor = myTextDescriptorList.Value(i) ; - atext = myTextStringList.Value(i) ; - dx = x0 + myTextXpositionList.Value(i)*tscale ; - dy = y0 + myTextYpositionList.Value(i)*tscale ; - tx = Standard_ShortReal( XROTATE(dx,dy)/rscale ); - ty = Standard_ShortReal( YROTATE(dx,dy)/rscale ); - hscale = scale*myTextHScaleList.Value(i) ; - wscale = scale*myTextWScaleList.Value(i) ; - aDrawer->SetTextAttrib(TEXT_COLOR(descriptor), - TEXT_FONT(descriptor),mySlant,hscale,wscale, - TEXT_UNDERLINE(descriptor)); - aDrawer->MapTextFromTo(atext,x+tx,y+ty, - angle,0.,0.,Aspect_TOT_SOLID); - } - } - } -} - - -Standard_Boolean Graphic2d_Paragraph::Pick (const Standard_ShortReal X, - const Standard_ShortReal Y, - const Standard_ShortReal aPrecision, - const Handle(Graphic2d_Drawer)& aDrawer) -{ -Standard_Boolean theStatus = Standard_False; -Standard_ShortReal TX = X, TY = Y; - - if (IsInMinMax (X, Y, aPrecision)) { - if (myGOPtr->IsTransformed ()) { - gp_GTrsf2d aTrsf = (myGOPtr->Transform ()).Inverted (); - Standard_Real RX = Standard_Real (X), RY = Standard_Real (Y); - aTrsf.Transforms (RX, RY); - TX = Standard_ShortReal (RX); TY = Standard_ShortReal (RY); - } - - Standard_ShortReal cosa = Standard_ShortReal( Cos(-myAngle) ); - Standard_ShortReal sina = Standard_ShortReal( Sin(-myAngle) ); - Standard_ShortReal dx = TX-myX; - Standard_ShortReal dy = TY-myY; - Standard_ShortReal x = XROTATE(dx,dy); - Standard_ShortReal y = YROTATE(dx,dy); - - theStatus = x >= myXoffset - aPrecision - && x <= myXoffset + myWidth + aPrecision - && y >= -myYoffset - aPrecision - && y <= myHeight -myYoffset + aPrecision; - } - - return theStatus; -} - -void Graphic2d_Paragraph::Size ( Quantity_Length &aWidth, - Quantity_Length &aHeight) const { - aWidth = myWidth; - aHeight = myHeight; - -} - -void Graphic2d_Paragraph::Position( Quantity_Length &X, - Quantity_Length &Y) const { - - X = myX; - Y = myY; -} - -Aspect_CardinalPoints Graphic2d_Paragraph::Offset( Quantity_Length &X, - Quantity_Length &Y) const { - - X = myXoffset; - Y = myYoffset; - - return myOffset; -} - -Quantity_PlaneAngle Graphic2d_Paragraph::Angle() const { - - return myAngle; -} - -Quantity_PlaneAngle Graphic2d_Paragraph::Slant() const { - - return mySlant; -} - -Quantity_PlaneAngle Graphic2d_Paragraph::Spacing() const { - - return mySpacing; -} - -Quantity_PlaneAngle Graphic2d_Paragraph::Margin() const { - - return myMargin; -} - -Standard_Integer Graphic2d_Paragraph::HidingColorIndex() const { - - return myHidingColorIndex; -} - -Standard_Integer Graphic2d_Paragraph::FrameColorIndex() const { - - return myFrameColorIndex; -} - -Standard_Integer Graphic2d_Paragraph::FrameWidthIndex() const { - - return myFrameWidthIndex; -} - -TCollection_ExtendedString Graphic2d_Paragraph::Text( - const Standard_Integer aRank, - Standard_Integer &aRow, - Standard_Integer &aColumn, - Standard_Integer &aColorIndex, - Standard_Integer &aFontIndex, - Graphic2d_TypeOfAlignment &anAlignment) const { - - if( aRank <= 0 || aRank > myTextDescriptorList.Length() ) { - Standard_OutOfRange::Raise ("Bad Text rank"); - } - - Standard_Integer descriptor = myTextDescriptorList.Value(aRank) ; - aRow = TEXT_ROW(descriptor) ; - aColumn = TEXT_COLUMN(descriptor) ; - aColorIndex = TEXT_COLOR(descriptor) ; - aFontIndex = TEXT_FONT(descriptor) ; - anAlignment = Graphic2d_TypeOfAlignment(TEXT_ALIGNMENT(descriptor)) ; - - return myTextStringList.Value(aRank) ; -} - -Standard_Boolean Graphic2d_Paragraph::TextSize ( const Standard_Integer aRank, - Quantity_Length &aWidth, Quantity_Length &aHeight, - Quantity_Length &anXoffset, Quantity_Length &anYoffset) const { - Handle(Graphic2d_Drawer) aDrawer = Drawer(); - - if( aRank <= 0 || aRank > myTextDescriptorList.Length() ) { - Standard_OutOfRange::Raise ("Bad Text rank"); - } - - if( !aDrawer.IsNull() && aDrawer->IsWindowDriver() ) { - Standard_Integer descriptor = myTextDescriptorList.Value(aRank) ; - Standard_ShortReal wscale,hscale,scale = (myIsZoomable) ? - myScale * aDrawer->Scale() : myScale; - Standard_ShortReal width,height,xoffset,yoffset; - TCollection_ExtendedString atext = myTextStringList.Value(aRank) ; - hscale = scale*myTextHScaleList.Value(aRank); - wscale = scale*myTextWScaleList.Value(aRank); - aDrawer->SetTextAttrib(TEXT_COLOR(descriptor),TEXT_FONT(descriptor), - mySlant,hscale,wscale,TEXT_UNDERLINE(descriptor)); - - aDrawer->GetTextSize(atext,width,height,xoffset,yoffset); - aWidth = width; - aHeight = height; - anXoffset = xoffset; - anYoffset = yoffset; - return Standard_True; - } else { - aWidth = aHeight = anXoffset = anYoffset = 0.; - return Standard_False; - } - -} - -Standard_Integer Graphic2d_Paragraph::Length() const { - - return myTextStringList.Length(); -} - -Standard_Integer Graphic2d_Paragraph::MaxRow() const { -Standard_Integer descriptor,i,n; - - for( i=1,n=0 ; i<=myTextDescriptorList.Length() ; i++ ) { - descriptor = myTextDescriptorList.Value(i) ; - n = Max(n,TEXT_ROW(descriptor)) ; - } - - return n; -} - -Standard_Integer Graphic2d_Paragraph::MaxColumn() const { -Standard_Integer descriptor,i,n; - - for( i=1,n=0 ; i<=myTextDescriptorList.Length() ; i++ ) { - descriptor = myTextDescriptorList.Value(i) ; - n = Max(n,TEXT_COLUMN(descriptor)) ; - } - - return n; -} - -#ifdef PERF -Standard_Boolean Graphic2d_Paragraph::ComputeMinMax() { -#else -void Graphic2d_Paragraph::Update() { -#endif -Handle(Graphic2d_Drawer) aDrawer = Drawer(); -Standard_Boolean status = Standard_False; - - if( !aDrawer.IsNull() && aDrawer->IsWindowDriver() ) { - Standard_ShortReal rscale = 1.; - if (!myIsZoomable) - rscale = aDrawer->Scale(); - - Standard_Integer descriptor,row = 0 ; - TCollection_ExtendedString atext ; - Standard_ShortReal x, y, dx, dy, - sina = Standard_ShortReal( Sin(myAngle) ), - cosa = Standard_ShortReal( Cos(myAngle) ); - Standard_Integer i,j,lrow,length = myTextDescriptorList.Length() ; - Standard_ShortReal hscale,wscale,scale = - (myIsZoomable) ? myScale*aDrawer->Scale() : myScale; - Standard_ShortReal twidth = 0.,theight = 0.,txoffset = 0.,tyoffset = 0.; - Standard_ShortReal lwidth = 0.,lheight = 0.,loffset = 0.; - myWidth = myHeight = 0. ; - for( i=1,j=lrow=0 ; i<=length ; i++ ) { // Passe 1, gets texts minmax - descriptor = myTextDescriptorList.Value(i) ; - atext = myTextStringList.Value(i) ; - hscale = scale*myTextHScaleList.Value(i) ; - wscale = scale*myTextWScaleList.Value(i) ; - aDrawer->SetTextAttrib(TEXT_COLOR(descriptor), - TEXT_FONT(descriptor),mySlant,hscale,wscale, - TEXT_UNDERLINE(descriptor)); - if( aDrawer->GetTextSize(atext,twidth,theight,txoffset,tyoffset) ) { -#ifdef PRO12320 - static TCollection_ExtendedString hletter("Hp"); - Standard_ShortReal hwidth,hheight,hxoffset,hyoffset; - if(( status = aDrawer->GetTextSize(hletter,hwidth,hheight, - hxoffset,hyoffset) )) { - theight = Max(hheight-hyoffset,theight-tyoffset); - tyoffset = Max(hyoffset,tyoffset); - } -#else - Standard_ShortReal fheight,fbheight,fslant; - aDrawer->GetFontSize(fheight,fbheight,fslant); - theight = fheight + fbheight; tyoffset = 0.; -#endif //PRO12320 - twidth += txoffset; - myTextXpositionList.SetValue(i,twidth) ; - if( row == TEXT_ROW(descriptor) ) { - lwidth += twidth ; lheight = Max(lheight,theight) ; - loffset = Max(loffset,tyoffset); - } else { - if( j > 0 ) { - if( j > 1 ) lheight += mySpacing*lheight*(row-lrow) ; -#ifndef PRO12982 - lheight -= loffset; -#endif - myTextYpositionList.SetValue(j,lheight) ; - myWidth = Max(myWidth,lwidth) ; - myHeight += lheight ; - } - lwidth = twidth ; lheight = theight ; loffset = tyoffset; - lrow = row ; row = TEXT_ROW(descriptor) ; j = i ; - } - } - } - - if( j > 0 ) { - if( j > 1 ) lheight += mySpacing*lheight*(row-lrow) ; -#ifndef PRO12982 - lheight -= loffset; -#endif - myTextYpositionList.SetValue(j,lheight) ; - myWidth = Max(myWidth,lwidth) ; - myHeight += lheight ; -#ifdef PRO12982 - myHeight += loffset; -#endif - } - myWidth += Standard_ShortReal( 2.*myMargin ); - myHeight += Standard_ShortReal( 2.*myMargin ); - - x = myMargin ; - y = -myMargin ; - row = 0 ; - for( i=1 ; i<=length ; i++ ) { // Passe 2,sets texts position - descriptor = myTextDescriptorList.Value(i) ; - twidth = myTextXpositionList.Value(i) ; - if( row != TEXT_ROW(descriptor) ) { - theight = myTextYpositionList.Value(i) ; - x = myMargin ; y -= theight ; - row = TEXT_ROW(descriptor) ; - } - switch (TEXT_ALIGNMENT(descriptor)) { - case Graphic2d_TOA_TOPLEFT: - case Graphic2d_TOA_MEDIUMLEFT: - case Graphic2d_TOA_BOTTOMLEFT: - case Graphic2d_TOA_LEFT: - break ; - case Graphic2d_TOA_TOPCENTER: - case Graphic2d_TOA_MEDIUMCENTER: - case Graphic2d_TOA_BOTTOMCENTER: - case Graphic2d_TOA_CENTER: - x = Standard_ShortReal( (myWidth-twidth)/2. ); - break ; - case Graphic2d_TOA_TOPRIGHT: - case Graphic2d_TOA_MEDIUMRIGHT: - case Graphic2d_TOA_BOTTOMRIGHT: - case Graphic2d_TOA_RIGHT: - x = myWidth-twidth-myMargin ; - break ; - } - myTextXpositionList.SetValue(i,x*rscale) ; - myTextYpositionList.SetValue(i,y*rscale) ; - x += twidth ; - } - - switch (myOffset) { - case Aspect_CP_North: - myXoffset = Standard_ShortReal( -myWidth/2. ); myYoffset = 0. ; - break ; - case Aspect_CP_NorthEast: - myXoffset = -myWidth ; myYoffset = 0. ; - break ; - case Aspect_CP_East: - myXoffset = -myWidth ; myYoffset = Standard_ShortReal( myHeight/2. ); - break ; - case Aspect_CP_SouthEast: - myXoffset = -myWidth ; myYoffset = myHeight ; - break ; - case Aspect_CP_South: - myXoffset = Standard_ShortReal( -myWidth/2. ); myYoffset = myHeight ; - break ; - case Aspect_CP_SouthWest: - myXoffset = 0. ; myYoffset = myHeight ; - break ; - case Aspect_CP_West: - myXoffset = 0.; myYoffset = Standard_ShortReal( myHeight/2. ); - break ; - case Aspect_CP_NorthWest: - myXoffset = 0. ; myYoffset = 0. ; - break ; - case Aspect_CP_Center: - myXoffset = Standard_ShortReal( -myWidth/2. ); - myYoffset = Standard_ShortReal( myHeight/2. ); - } - - myMinX = myMinY = ShortRealLast(); - myMaxX = myMaxY = ShortRealFirst(); - - dx = XROTATE(myXoffset,myYoffset) ; - dy = YROTATE(myXoffset,myYoffset) ; - myMinX = Min(myMinX,myX+dx) ; - myMinY = Min(myMinY,myY+dy) ; - myMaxX = Max(myMaxX,myX+dx) ; - myMaxY = Max(myMaxY,myY+dy) ; - - dx = XROTATE(myWidth+myXoffset,myYoffset) ; - dy = YROTATE(myWidth+myXoffset,myYoffset) ; - myMinX = Min(myMinX,myX+dx) ; - myMinY = Min(myMinY,myY+dy) ; - myMaxX = Max(myMaxX,myX+dx) ; - myMaxY = Max(myMaxY,myY+dy) ; - - dx = XROTATE(myWidth+myXoffset,-myHeight+myYoffset) ; - dy = YROTATE(myWidth+myXoffset,-myHeight+myYoffset) ; - myMinX = Min(myMinX,myX+dx) ; - myMinY = Min(myMinY,myY+dy) ; - myMaxX = Max(myMaxX,myX+dx) ; - myMaxY = Max(myMaxY,myY+dy) ; - - dx = XROTATE(myXoffset,-myHeight+myYoffset) ; - dy = YROTATE(myXoffset,-myHeight+myYoffset) ; - myMinX = Min(myMinX,myX+dx) ; - myMinY = Min(myMinY,myY+dy) ; - myMaxX = Max(myMaxX,myX+dx) ; - myMaxY = Max(myMaxY,myY+dy) ; - - myXoffset *= rscale; - myYoffset *= rscale; - myWidth *= rscale; - myHeight *= rscale; - } -#ifdef PERF - else { - cout << "*Graphic2d_Paragraph::ComputeMinMax() returns wrong values*" << endl; - } - - return status; -#endif - - -} - -void Graphic2d_Paragraph::Save(Aspect_FStream& aFStream) const -{ -} diff --git a/src/Graphic2d/Graphic2d_Polyline.cdl b/src/Graphic2d/Graphic2d_Polyline.cdl deleted file mode 100755 index 7479b42704..0000000000 --- a/src/Graphic2d/Graphic2d_Polyline.cdl +++ /dev/null @@ -1,137 +0,0 @@ --- Created on: 1993-06-22 --- Created by: Jean Louis FRENKEL, Gerard GRAS --- Copyright (c) 1993-1999 Matra Datavision --- Copyright (c) 1999-2012 OPEN CASCADE SAS --- --- The content of this file is subject to the Open CASCADE Technology Public --- License Version 6.5 (the "License"). You may not use the content of this file --- except in compliance with the License. Please obtain a copy of the License --- at http://www.opencascade.org and read it completely before using this file. --- --- The Initial Developer of the Original Code is Open CASCADE S.A.S., having its --- main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. --- --- The Original Code and all software distributed under the License is --- distributed on an "AS IS" basis, without warranty of any kind, and the --- Initial Developer hereby disclaims all such warranties, including without --- limitation, any warranties of merchantability, fitness for a particular --- purpose or non-infringement. Please see the License for the specific terms --- and conditions governing the rights and limitations under the License. - - - - -class Polyline from Graphic2d inherits Line from Graphic2d - - ---Version: - - ---Purpose: The primitive Polyline - - ---Keywords: Primitive, Polyline - ---Warning: - ---References: - -uses - Length from Quantity, - Drawer from Graphic2d, - Array1OfReal from TColStd, - Array1OfShortReal from TShort, - GraphicObject from Graphic2d, - Array1OfVertex from Graphic2d, - FStream from Aspect, - IFStream from Aspect - - -raises - PolylineDefinitionError from Graphic2d, - OutOfRange from Standard - -is - ------------------------- - -- Category: Constructors - ------------------------- - - Create( aGraphicObject: GraphicObject from Graphic2d; - aListVertex: Array1OfVertex from Graphic2d ) - returns mutable Polyline from Graphic2d - ---Level: Public - ---Purpose: Creates a polyline. - -- Warning: Raises an error if the length of the polyline - -- is less than 2 points. - raises PolylineDefinitionError from Graphic2d; - ---Category: Constructors - - Create (aGraphicObject: GraphicObject from Graphic2d; - aListX: Array1OfReal from TColStd; - aListY: Array1OfReal from TColStd) - returns mutable Polyline from Graphic2d - ---Level: Public - ---Purpose: Creates a polyline. - -- Warning: Raises an error if the length of the polyline - -- is less than 2 points or if length of - -- is not equal to length of . - raises PolylineDefinitionError from Graphic2d; - - ------------------------- - ---Category: Inquire methods - ------------------------- - - Length(me) returns Integer from Standard; - ---Level: Public - ---Purpose: Returns the number of points of the line. - ---Category: Inquiry method - - Values(me; aRank: Integer from Standard; - X,Y: out Length from Quantity) - ---Level: Public - ---Purpose: Returns the point of rank from the line. - ---Trigger: Raises OutOfRange if is <1 or >Length() - raises OutOfRange from Standard; - ---Category: Inquiry method - - -------------------------- - -- Category: Draw and Pick - -------------------------- - - Draw( me : mutable; aDrawer: Drawer from Graphic2d) - is static protected; - ---Level: Internal - ---Purpose: Draws the polyline . - - DrawElement( me : mutable; aDrawer: Drawer from Graphic2d; - anIndex: Integer from Standard) - is redefined protected; - ---Level: Internal - ---Purpose: Draws edge of the polyline . - - DrawVertex( me : mutable; aDrawer: Drawer from Graphic2d; - anIndex: Integer from Standard) - is redefined protected; - ---Level: Internal - ---Purpose: Draws vertex of the polyline . - - Pick( me : mutable; - X, Y: ShortReal from Standard; - aPrecision: ShortReal from Standard; - aDrawer: Drawer from Graphic2d) - returns Boolean from Standard - is static protected; - ---Level: Internal - ---Purpose: Returns Standard_True if the polyline is picked, - -- Standard_False if not. - -- Warning: The method PickIndex() returns the last picked point - -- rank of the line or 0 if picking occurs inside - -- the filled line. - - ---------------------------------------------------------------------- - - Save(me; aFStream: in out FStream from Aspect) is virtual; - Retrieve(myclass; anIFStream: in out IFStream from Aspect; - aGraphicObject: GraphicObject from Graphic2d); - -fields - - myX: Array1OfShortReal from TShort; - myY: Array1OfShortReal from TShort; - -end Polyline from Graphic2d; diff --git a/src/Graphic2d/Graphic2d_Polyline.cxx b/src/Graphic2d/Graphic2d_Polyline.cxx deleted file mode 100755 index 9f20b8f439..0000000000 --- a/src/Graphic2d/Graphic2d_Polyline.cxx +++ /dev/null @@ -1,333 +0,0 @@ -// Copyright (c) 1995-1999 Matra Datavision -// Copyright (c) 1999-2012 OPEN CASCADE SAS -// -// The content of this file is subject to the Open CASCADE Technology Public -// License Version 6.5 (the "License"). You may not use the content of this file -// except in compliance with the License. Please obtain a copy of the License -// at http://www.opencascade.org and read it completely before using this file. -// -// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its -// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. -// -// The Original Code and all software distributed under the License is -// distributed on an "AS IS" basis, without warranty of any kind, and the -// Initial Developer hereby disclaims all such warranties, including without -// limitation, any warranties of merchantability, fitness for a particular -// purpose or non-infringement. Please see the License for the specific terms -// and conditions governing the rights and limitations under the License. - -// WTO0001 GG_140596 -// Calcul des min-max faux apres transformation. - -#define G002 //GG_140400 Use SetPickedIndex() method -// GG_050500 Add new DrawElement(), DrawVertex() methods -// Returns a negative picked index when the point -// is very closed to a polyline point. - -#define VERTEXMARKER 2 -#define DEFAULTMARKERSIZE 3.0 - -#include -#include - -#include - -Graphic2d_Polyline::Graphic2d_Polyline ( - const Handle(Graphic2d_GraphicObject)& aGraphicObject, - const Graphic2d_Array1OfVertex& aListVertex) - - : Graphic2d_Line (aGraphicObject), - myX (1, aListVertex.Length ()), - myY (1, aListVertex.Length ()) { - - if (aListVertex.Length () < 2) - Graphic2d_PolylineDefinitionError::Raise - ("A polyline with a length less than 2 points."); - -Standard_ShortReal X, Y; -Standard_Integer i, j; - - // Recherche des MinMax -Standard_Integer Lower, Upper; - Lower = aListVertex.Lower (); - Upper = aListVertex.Upper (); - - for (j=1, i=Lower; i<=Upper; i++, j++) { - X = Standard_ShortReal(aListVertex (i).X ()); - Y = Standard_ShortReal(aListVertex (i).Y ()); - myX (j) = X; - myY (j) = Y; - if (X > myMaxX) myMaxX = X; - if (X < myMinX) myMinX = X; - if (Y > myMaxY) myMaxY = Y; - if (Y < myMinY) myMinY = Y; - } - - myNumOfElem = myX.Length()-1; - myNumOfVert = myX.Length(); - -} - -Graphic2d_Polyline::Graphic2d_Polyline ( - const Handle(Graphic2d_GraphicObject)& aGraphicObject, - const TColStd_Array1OfReal& aListX, - const TColStd_Array1OfReal& aListY) - - : Graphic2d_Line (aGraphicObject), - myX (1, aListX.Length ()), - myY (1, aListY.Length ()) { - - if (aListX.Length () < 2) - Graphic2d_PolylineDefinitionError::Raise - ("polyline : length < 2."); - - if (aListX.Length () != aListY.Length ()) - Graphic2d_PolylineDefinitionError::Raise - ("polyline : ListX and ListY have different lengths."); - -Standard_ShortReal X, Y; -Standard_Integer i, j; - - // Recherche des MinMax -Standard_Integer Lower, Upper; - Lower = aListX.Lower (); - Upper = aListX.Upper (); - - for (j=1, i=Lower; i<=Upper; i++, j++) { - X = Standard_ShortReal(aListX (i)); - Y = Standard_ShortReal(aListY (i)); - myX (j) = X; - myY (j) = Y; - if (X > myMaxX) myMaxX = X; - if (X < myMinX) myMinX = X; - if (Y > myMaxY) myMaxY = Y; - if (Y < myMinY) myMinY = Y; - } - myNumOfElem = myX.Length()-1; - myNumOfVert = myX.Length(); -} - - -Standard_Integer Graphic2d_Polyline::Length () const { - return myX.Length(); -} - -void Graphic2d_Polyline::Values( const Standard_Integer aRank, - Standard_Real &X,Standard_Real &Y ) const -{ - if( aRank < 1 || aRank > myX.Length() ) - Standard_OutOfRange::Raise - ("the point rank is out of bounds in the line"); - - X = myX(aRank); - Y = myY(aRank); - -} - -void Graphic2d_Polyline::Draw (const Handle(Graphic2d_Drawer)& aDrawer) { - -Standard_Boolean IsIn = Standard_False; - - if (! myGOPtr->IsTransformed ()) - IsIn = aDrawer->IsIn (myMinX,myMaxX,myMinY,myMaxY); - else { - Standard_ShortReal minx, miny, maxx, maxy; - MinMax(minx,maxx,miny,maxy); - IsIn = aDrawer->IsIn (minx,maxx,miny,maxy); - } - - if (IsIn) { - DrawLineAttrib (aDrawer); - - if (myGOPtr->IsTransformed ()) { - Standard_Integer nbpoints = myX.Length (); - TShort_Array1OfShortReal Xpoint (1, nbpoints); - TShort_Array1OfShortReal Ypoint (1, nbpoints); - gp_GTrsf2d aTrsf = myGOPtr->Transform (); - Standard_Real A, B; - for (Standard_Integer j=1; j<= nbpoints; j++) { - A = Standard_Real (myX(j)); - B = Standard_Real (myY(j)); - aTrsf.Transforms (A, B); - Xpoint(j) = Standard_ShortReal (A); - Ypoint(j) = Standard_ShortReal (B); - } - if ( myTypeOfPolygonFilling == Graphic2d_TOPF_EMPTY ) { - aDrawer->MapPolylineFromTo(Xpoint, Ypoint); - } else { - aDrawer->MapPolygonFromTo(Xpoint, Ypoint); - } - } else { - if(myTypeOfPolygonFilling == Graphic2d_TOPF_EMPTY) { - aDrawer->MapPolylineFromTo(myX, myY); - } else { - aDrawer->MapPolygonFromTo(myX, myY); - } - } - } -} - -#ifdef G002 -void Graphic2d_Polyline::DrawElement( const Handle(Graphic2d_Drawer)& aDrawer, - const Standard_Integer anIndex) { -Standard_Boolean IsIn = Standard_False; - - if (! myGOPtr->IsTransformed ()) - IsIn = aDrawer->IsIn (myMinX,myMaxX,myMinY,myMaxY); - else { - Standard_ShortReal minx, miny, maxx, maxy; - MinMax(minx,maxx,miny,maxy); - IsIn = aDrawer->IsIn (minx,maxx,miny,maxy); - } - - Standard_Integer nbpoints = myX.Length (); - if (IsIn ) { - if( anIndex > 0 && anIndex < nbpoints ) { //Draw edge - Standard_ShortReal X1,Y1,X2,Y2; - DrawLineAttrib (aDrawer); - if (myGOPtr->IsTransformed ()) { - gp_GTrsf2d aTrsf = myGOPtr->Transform (); - Standard_Real A, B; - A = Standard_Real (myX(anIndex)); - B = Standard_Real (myY(anIndex)); - aTrsf.Transforms (A, B); - X1 = Standard_ShortReal (A); - Y1 = Standard_ShortReal (B); - A = Standard_Real (myX(anIndex+1)); - B = Standard_Real (myY(anIndex+1)); - aTrsf.Transforms (A, B); - X2 = Standard_ShortReal (A); - Y2 = Standard_ShortReal (B); - } else { - X1 = Standard_ShortReal (myX(anIndex)); - Y1 = Standard_ShortReal (myY(anIndex)); - X2 = Standard_ShortReal (myX(anIndex+1)); - Y2 = Standard_ShortReal (myY(anIndex+1)); - } - aDrawer->MapSegmentFromTo(X1,Y1,X2,Y2); - } - } -} - -void Graphic2d_Polyline::DrawVertex( const Handle(Graphic2d_Drawer)& aDrawer, - const Standard_Integer anIndex) { - Standard_Boolean IsIn = Standard_False; - - if (! myGOPtr->IsTransformed ()) - IsIn = aDrawer->IsIn (myMinX,myMaxX,myMinY,myMaxY); - else { - Standard_ShortReal minx, miny, maxx, maxy; - MinMax(minx,maxx,miny,maxy); - IsIn = aDrawer->IsIn (minx,maxx,miny,maxy); - } - - Standard_Integer nbpoints = myX.Length (); - if (IsIn ) { - if( anIndex > 0 && anIndex <= nbpoints ) { - Standard_ShortReal X,Y; - DrawMarkerAttrib (aDrawer); - if (myGOPtr->IsTransformed ()) { - gp_GTrsf2d aTrsf = myGOPtr->Transform (); - Standard_Real A, B; - A = Standard_Real (myX(anIndex)); - B = Standard_Real (myY(anIndex)); - aTrsf.Transforms (A, B); - X = Standard_ShortReal (A); - Y = Standard_ShortReal (B); - } else { - X = Standard_ShortReal (myX(anIndex)); - Y = Standard_ShortReal (myY(anIndex)); - } - aDrawer->MapMarkerFromTo(VERTEXMARKER,X,Y, - DEFAULTMARKERSIZE,DEFAULTMARKERSIZE,0.0); - } - } -} -#endif - -Standard_Boolean Graphic2d_Polyline::Pick (const Standard_ShortReal X, - const Standard_ShortReal Y, - const Standard_ShortReal aPrecision, - const Handle(Graphic2d_Drawer)& /*aDrawer*/) -{ - - Standard_ShortReal SRX = X, SRY = Y; - - Standard_Integer i; - - Standard_Integer Lower, Upper; - Lower = myX.Lower (); - Upper = myX.Upper (); - - if (IsInMinMax (X, Y, aPrecision)) { - - if (myGOPtr->IsTransformed ()) { - gp_GTrsf2d aTrsf = (myGOPtr->Transform ()).Inverted (); - Standard_Real RX = Standard_Real (SRX), RY = Standard_Real (SRY); - aTrsf.Transforms (RX, RY); - SRX = Standard_ShortReal (RX); SRY = Standard_ShortReal (RY); - } - -#ifdef G002 - for ( i = Lower; i <= Upper; i++ ) { - if( Graphic2d_Primitive::IsOn ( SRX, SRY, myX (i), myY (i), aPrecision) ) { - SetPickedIndex(-i); - return Standard_True; - } else if( (i < Upper) && IsOn (SRX, SRY, myX (i), myY (i), - myX (i+1), myY (i+1), aPrecision) ) { - SetPickedIndex(i); - return Standard_True; - } - } -#else - for (i=Lower; i> numOfVert; - Graphic2d_Array1OfVertex listVertex(1, numOfVert); - for (Standard_Integer i=1; i<=numOfVert; i++) - { - *anIFStream >> X >> Y; - listVertex(i).SetCoord(X, Y); - } - Handle(Graphic2d_Polyline) - thePLin = new Graphic2d_Polyline(aGraphicObject, listVertex); - ((Handle (Graphic2d_Line))thePLin)->Retrieve(anIFStream); -} - diff --git a/src/Graphic2d/Graphic2d_PolylineMarker.cdl b/src/Graphic2d/Graphic2d_PolylineMarker.cdl deleted file mode 100755 index 5ca96f7da6..0000000000 --- a/src/Graphic2d/Graphic2d_PolylineMarker.cdl +++ /dev/null @@ -1,144 +0,0 @@ --- Created on: 1993-06-22 --- Created by: Jean Louis FRENKEL --- Copyright (c) 1993-1999 Matra Datavision --- Copyright (c) 1999-2012 OPEN CASCADE SAS --- --- The content of this file is subject to the Open CASCADE Technology Public --- License Version 6.5 (the "License"). You may not use the content of this file --- except in compliance with the License. Please obtain a copy of the License --- at http://www.opencascade.org and read it completely before using this file. --- --- The Initial Developer of the Original Code is Open CASCADE S.A.S., having its --- main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. --- --- The Original Code and all software distributed under the License is --- distributed on an "AS IS" basis, without warranty of any kind, and the --- Initial Developer hereby disclaims all such warranties, including without --- limitation, any warranties of merchantability, fitness for a particular --- purpose or non-infringement. Please see the License for the specific terms --- and conditions governing the rights and limitations under the License. - - --- Modified: TCL G002A, 28-11-00, new section "inquire methods" - - -class PolylineMarker from Graphic2d inherits VectorialMarker from Graphic2d - - ---Version: - - ---Purpose: The primitive PolylineMarker - -- Every marker takes a reference point as an argument in - -- its constructor. CircleMarker and EllipsMarker take - -- another point as the center and PolylineMarker takes the - -- first point of its list as its origin. - -- The coordinates of the centre or origin point are offsets - -- with respect to the reference point. - - -uses - Drawer from Graphic2d, - Array1OfReal from TColStd, - Array1OfShortReal from TShort, - GraphicObject from Graphic2d, - Array1OfVertex from Graphic2d, - Length from Quantity, - FStream from Aspect, - IFStream from Aspect, - IFStream from Aspect -raises - - PolylineDefinitionError from Graphic2d, - OutOfRange from Standard - -is - ------------------------- - -- Category: Constructors - ------------------------- - - Create (aGraphicObject: GraphicObject from Graphic2d; - aXPosition, aYPosition: Length from Quantity; - aListVertex: Array1OfVertex from Graphic2d) - returns mutable PolylineMarker from Graphic2d - ---Level: Public - ---Purpose: Creates a polyline marker. - -- The reference point is , - -- Warning: Raises an error if the length of the polyline - -- is less than 2 points. - raises PolylineDefinitionError from Graphic2d; - ---Category: Constructors - - Create (aGraphicObject: GraphicObject from Graphic2d; - aXPosition, aYPosition: Length from Quantity; - aListX: Array1OfReal from TColStd; - aListY: Array1OfReal from TColStd) - returns mutable PolylineMarker from Graphic2d - ---Level: Public - ---Purpose: Creates a polyline marker. - -- The reference point is , - -- Warning: Raises an error if the length of the polyline - -- is less than 2 points or if length of - -- is not equal to length of . - raises PolylineDefinitionError from Graphic2d; - ---Category: Constructors - - ------------------------------------- - ---Category: Inquire methods - ------------------------------------- - - Length( me ) returns Integer from Standard; - ---Level: Public - ---Purpose: Returns the number of points of - -- the polyline marker - ---Category: Inquiry method - - Values( me; aRank: Integer from Standard; - X,Y: out Length from Quantity ) - ---Level: Public - ---Purpose: Returns the point of rank - -- from the polyline marker - ---Trigger: Raises OutOfRange if is <1 or >Length() - raises OutOfRange from Standard; - ---Category: Inquiry method - - -------------------------------------- - -- Category: Draw and Pick - -------------------------------------- - - Draw (me : mutable; aDrawer: Drawer from Graphic2d) - is static protected; - ---Level: Internal - ---Purpose: Draws the polyline . - - DrawElement( me : mutable; aDrawer: Drawer from Graphic2d; - anIndex: Integer from Standard) - is redefined protected; - ---Level: Internal - ---Purpose: Draws edge of the polyline marker . - - DrawVertex( me : mutable; aDrawer: Drawer from Graphic2d; - anIndex: Integer from Standard) - is redefined protected; - ---Level: Internal - ---Purpose: Draws vertex of the polyline marker . - - Pick (me : mutable; - X, Y: ShortReal from Standard; - aPrecision: ShortReal from Standard; - aDrawer: Drawer from Graphic2d) - returns Boolean from Standard is static protected; - ---Level: Internal - ---Purpose: Returns Standard_True if the polyline is picked, - -- Standard_False if not. - - ---------------------------------------------------------------------- - - Save( me; aFStream: in out FStream from Aspect ) is virtual; - Retrieve(myclass; anIFStream: in out IFStream from Aspect; - aGraphicObject: GraphicObject from Graphic2d); - -fields - - myX: Array1OfShortReal from TShort; - myY: Array1OfShortReal from TShort; - -end PolylineMarker from Graphic2d; diff --git a/src/Graphic2d/Graphic2d_PolylineMarker.cxx b/src/Graphic2d/Graphic2d_PolylineMarker.cxx deleted file mode 100755 index 027a22927e..0000000000 --- a/src/Graphic2d/Graphic2d_PolylineMarker.cxx +++ /dev/null @@ -1,276 +0,0 @@ -// Copyright (c) 1995-1999 Matra Datavision -// Copyright (c) 1999-2012 OPEN CASCADE SAS -// -// The content of this file is subject to the Open CASCADE Technology Public -// License Version 6.5 (the "License"). You may not use the content of this file -// except in compliance with the License. Please obtain a copy of the License -// at http://www.opencascade.org and read it completely before using this file. -// -// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its -// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. -// -// The Original Code and all software distributed under the License is -// distributed on an "AS IS" basis, without warranty of any kind, and the -// Initial Developer hereby disclaims all such warranties, including without -// limitation, any warranties of merchantability, fitness for a particular -// purpose or non-infringement. Please see the License for the specific terms -// and conditions governing the rights and limitations under the License. - -#include -#include - -#define G002 //TCL : Use SetPickedIndex() method -// TCL : Add new DrawElement(), DrawVertex() methods - -#define VERTEXMARKER 2 -#define DEFAULTMARKERSIZE 3.0 - -Graphic2d_PolylineMarker::Graphic2d_PolylineMarker ( - const Handle(Graphic2d_GraphicObject)& aGraphicObject, - const Standard_Real aXPosition, - const Standard_Real aYPosition, - const Graphic2d_Array1OfVertex& aListVertex) - - : Graphic2d_VectorialMarker (aGraphicObject, aXPosition, aYPosition), - myX (1, aListVertex.Length ()), - myY (1, aListVertex.Length ()) { - - if (aListVertex.Length () < 2) - Graphic2d_PolylineDefinitionError::Raise - ("A polyline with a length less than 2 points."); - - Standard_Integer i, j; - - Standard_Integer Lower = aListVertex.Lower (); - Standard_Integer Upper = aListVertex.Upper (); - - // Recopie de tableaux avec recherche du minmax - myMinX = Standard_ShortReal( aListVertex (Lower).X () ); - myMinY = Standard_ShortReal( aListVertex (Lower).Y () ); - myMaxX = Standard_ShortReal( aListVertex (Lower).X () ); - myMaxY = Standard_ShortReal( aListVertex (Lower).Y () ); - - for (j=1, i=Lower; i<=Upper; i++, j++) { - myX (j) = Standard_ShortReal( aListVertex (i).X () ); - myY (j) = Standard_ShortReal( aListVertex (i).Y () ); - if (myX (j) < myMinX) myMinX = myX (j); - if (myY (j) < myMinY) myMinY = myY (j); - if (myX (j) > myMaxX) myMaxX = myX (j); - if (myY (j) > myMaxY) myMaxY = myY (j); - } - -#ifdef IMPLEMENTED - myMinX += aXPosition; - myMinY += aYPosition; - myMaxX += aXPosition; - myMaxY += aYPosition; -#else -#endif /* NOT IMPLEMENTED */ - - myNumOfElem = myX.Length()-1; - myNumOfVert = myX.Length(); - -} - -Graphic2d_PolylineMarker::Graphic2d_PolylineMarker ( - const Handle(Graphic2d_GraphicObject)& aGraphicObject, - const Standard_Real aXPosition, const Standard_Real aYPosition, - const TColStd_Array1OfReal& aListX, - const TColStd_Array1OfReal& aListY) - - : Graphic2d_VectorialMarker (aGraphicObject,aXPosition,aYPosition), - myX (1, aListX.Length ()), - myY (1, aListY.Length ()) { - - if (aListX.Length () < 2) - Graphic2d_PolylineDefinitionError::Raise - ("polyline : length < 2."); - - if (aListX.Length () != aListY.Length ()) - Graphic2d_PolylineDefinitionError::Raise - ("polyline : ListX and ListY have different lengths."); - - Standard_Integer i, j; - - Standard_Integer Lower = aListX.Lower (); - Standard_Integer Upper = aListX.Upper (); - - // Recopie de tableaux avec recherche du minmax - myMinX = Standard_ShortReal( aListX (Lower) ); - myMinY = Standard_ShortReal( aListY (Lower) ); - myMaxX = Standard_ShortReal( aListX (Lower) ); - myMaxY = Standard_ShortReal( aListY (Lower) ); - - for (j=1, i=Lower; i<=Upper; i++, j++) { - myX (j) = Standard_ShortReal( aListX (i) ); - myY (j) = Standard_ShortReal( aListY (i) ); - if (myX (j) < myMinX) myMinX = myX (j); - if (myY (j) < myMinY) myMinY = myY (j); - if (myX (j) > myMaxX) myMaxX = myX (j); - if (myY (j) > myMaxY) myMaxY = myY (j); - } - -#ifdef IMPLEMENTED - myMinX += aXPosition; - myMinY += aYPosition; - myMaxX += aXPosition; - myMaxY += aYPosition; -#else -#endif /* NOT IMPLEMENTED */ - - myNumOfElem = myX.Length()-1; - myNumOfVert = myX.Length(); - -} - -Standard_Integer Graphic2d_PolylineMarker::Length () const { - return myX.Length(); -} - -void Graphic2d_PolylineMarker::Values( const Standard_Integer aRank, - Standard_Real &X,Standard_Real &Y ) const { - - if ( aRank < 1 || aRank > myX.Length() ) - Standard_OutOfRange::Raise( "The renk of point is out of bounds in the line"); - - X = myX(aRank); - Y = myY(aRank); - -} - -void Graphic2d_PolylineMarker::Draw (const Handle(Graphic2d_Drawer)& aDrawer) { - - Standard_ShortReal xp,yp; - aDrawer->GetMapFromTo(Standard_ShortReal (XPosition ()), - Standard_ShortReal (YPosition ()),xp,yp); - DrawLineAttrib (aDrawer); - if(myTypeOfPolygonFilling == Graphic2d_TOPF_EMPTY) { - aDrawer->DrawPolyline(xp,yp,myX, myY); - } else { - aDrawer->DrawPolygon(xp,yp,myX, myY); - } -} - -#ifdef G002 - -void Graphic2d_PolylineMarker::DrawElement( const Handle(Graphic2d_Drawer)& aDrawer, - const Standard_Integer anIndex) { - - if ( anIndex > 0 && anIndex < myX.Length() ) { - Standard_ShortReal xp, yp; - DrawLineAttrib( aDrawer ); - aDrawer->GetMapFromTo(Standard_ShortReal(XPosition()), - Standard_ShortReal(YPosition()), xp, yp ); - aDrawer->DrawSegment( xp + myX(anIndex), yp + myY(anIndex), - xp + myX(anIndex+1), yp + myY(anIndex+1)); - } - -} - -void Graphic2d_PolylineMarker::DrawVertex( const Handle(Graphic2d_Drawer)& aDrawer, - const Standard_Integer anIndex) { - - if( anIndex > 0 && anIndex <= myX.Length() ) { - Standard_ShortReal xp, yp; - aDrawer->GetMapFromTo(Standard_ShortReal(XPosition()), - Standard_ShortReal(YPosition()), xp, yp ); - DrawMarkerAttrib( aDrawer ); - aDrawer->DrawMarker( VERTEXMARKER, myX(anIndex) + xp, myY(anIndex) + yp, - DEFAULTMARKERSIZE, DEFAULTMARKERSIZE, 0.0 ); - } -} - -#endif - -Standard_Boolean Graphic2d_PolylineMarker::Pick( const Standard_ShortReal X, - const Standard_ShortReal Y, - const Standard_ShortReal aPrecision, - const Handle(Graphic2d_Drawer)& aDrawer) { - - Standard_Integer i, Lower, Upper; - - Standard_ShortReal SRX = X, SRY = Y; - - Lower = myX.Lower(); - Upper = myX.Upper(); - - TShort_Array1OfShortReal x(Lower,Upper); - TShort_Array1OfShortReal y(Lower,Upper); - for ( i = Lower; i <= Upper; i++ ) { - x(i) = aDrawer->ConvertMapToFrom( myX(i) ); - y(i) = aDrawer->ConvertMapToFrom( myY(i) ); - } - - if ( myGOPtr->IsTransformed() ) { - gp_GTrsf2d aTrsf = ( myGOPtr->Transform() ).Inverted(); - Standard_Real RX = Standard_Real( SRX ), RY = Standard_Real( SRY ); - aTrsf.Transforms( RX, RY ); - SRX = Standard_ShortReal( RX ); SRY = Standard_ShortReal( RY ); - } - -#ifdef G002 - - for ( i = Lower; i <= Upper; i++ ) { - if ( Graphic2d_Primitive::IsOn ( SRX, SRY, myXPosition + x(i), myYPosition + y(i), aPrecision ) ) { - SetPickedIndex(-i); - return Standard_True; - } else if ( ( i < Upper ) && IsOn( SRX, SRY, myXPosition + x(i), myYPosition + y(i), - myXPosition + x(i+1), myYPosition + y(i+1), aPrecision ) ) { - SetPickedIndex(i); - return Standard_True; - } - } -#else - - for ( i = Lower; i < Upper; i++ ) { - if ( IsOn( SRX, SRY, myXPosition + x(i), myYPosition + y(i), - myXPosition + x(i+1), myYPosition + y(i+1), aPrecision ) ) { - myPickedIndex = i; - return Standard_True; - } - } -#endif - - if ( myTypeOfPolygonFilling != Graphic2d_TOPF_EMPTY ) - if ( IsIn( SRX - myXPosition, SRY - myYPosition, x, y, aPrecision ) ) { -#ifdef G002 - SetPickedIndex(0); -#else - myPickedIndex = 0; -#endif - return Standard_True; - } - - return Standard_False; - -} -void Graphic2d_PolylineMarker::Save(Aspect_FStream& aFStream) const -{ - *aFStream << "Graphic2d_PolylineMarker" << endl; - *aFStream << myNumOfVert << endl; - *aFStream << myXPosition << ' ' << myYPosition << endl; - for (Standard_Integer i=1; i<=myNumOfVert; i++) - *aFStream << myX(i) << ' ' << myY(i) << endl; - Graphic2d_Line::Save(aFStream); -} - -void Graphic2d_PolylineMarker::Retrieve(Aspect_IFStream& anIFStream, - const Handle(Graphic2d_GraphicObject)& aGraphicObject) -{ - Standard_Integer numOfVert; - Standard_ShortReal XPos, YPos, X, Y; - - *anIFStream >> numOfVert; - *anIFStream >> XPos >> YPos; - Graphic2d_Array1OfVertex listVertex(1, numOfVert); - for (Standard_Integer i=1; i<=numOfVert; i++) - { - *anIFStream >> X >> Y; - listVertex(i).SetCoord(X, Y); - } - Handle(Graphic2d_PolylineMarker) - thePLinM = new Graphic2d_PolylineMarker(aGraphicObject, XPos, YPos, listVertex); - ((Handle (Graphic2d_Line))thePLinM)->Retrieve(anIFStream); -} - - diff --git a/src/Graphic2d/Graphic2d_Primitive.cdl b/src/Graphic2d/Graphic2d_Primitive.cdl deleted file mode 100755 index 4aefe6a930..0000000000 --- a/src/Graphic2d/Graphic2d_Primitive.cdl +++ /dev/null @@ -1,388 +0,0 @@ --- Created on: 1993-06-22 --- Created by: Jean Louis FRENKEL, Gerard GRAS. --- Copyright (c) 1993-1999 Matra Datavision --- Copyright (c) 1999-2012 OPEN CASCADE SAS --- --- The content of this file is subject to the Open CASCADE Technology Public --- License Version 6.5 (the "License"). You may not use the content of this file --- except in compliance with the License. Please obtain a copy of the License --- at http://www.opencascade.org and read it completely before using this file. --- --- The Initial Developer of the Original Code is Open CASCADE S.A.S., having its --- main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. --- --- The Original Code and all software distributed under the License is --- distributed on an "AS IS" basis, without warranty of any kind, and the --- Initial Developer hereby disclaims all such warranties, including without --- limitation, any warranties of merchantability, fitness for a particular --- purpose or non-infringement. Please see the License for the specific terms --- and conditions governing the rights and limitations under the License. - - --- Updated: GG 19/08/98 PERFORMANCE --- A new method ComputeMinMax(...) could be redefined for --- each primitive to recompute the MinMax values at the right time. --- GG 14/04/00 G002 Add SetPickedIndex() method --- Add DrawElement() and DrawVertex() methods --- GG 05/05/00 G002 Add IsOn() method. --- Add Highlight(),Unhilight(),IsHighlighted() --- HighlightIndex() methods. --- TCL : 12-06-00 : G002 : new method Pick( Xmin, Ymin, Xmax, Ymax,...) --- TCL : 07-07-00 : G002 : new method HighlightIndices() --- method HighlightIndex() was removed --- TCL : 25-07-00 : G002 : new methods SetDisplayMode( aMode ) and DisplayMode() - --- SAV : 14/11/01 : Added a set of methods (marked SAV before declaration) --- to provide highlighting/selection --- of SetOfMarkers elements. These methods should be redefined --- for other SetOf<>. --- SAV : 03/07/02 : SetElementsSelected() prototype changed to avoid regression --- during elements single selection. - -deferred class Primitive from Graphic2d inherits TShared from MMgt - - ---Version: - - ---Purpose: Groups all drawing elements which can be stored - -- in a graphic object. - -- Each primitive have a postion in the space model. - -uses - - Buffer from Graphic2d, - GOPtr from Graphic2d, - Drawer from Graphic2d, - GraphicObject from Graphic2d, - TypeOfPrimitive from Graphic2d, - Length from Quantity, - PickMode from Graphic2d, - HSequenceOfInteger from TColStd, --- IFStream from Aspect, - FStream from Aspect, - MapOfInteger from TColStd - -is - ------------------------- - -- Category: Constructors - ------------------------- - - Initialize (aGraphicObject: GraphicObject from Graphic2d); - ---Level: Public - ---Purpose: Creates a primitive in a graphic object . - ---Category: Constructors - - ---------------------------------------------- - -- Category: Methods to manage color attribute - ---------------------------------------------- - - SetColorIndex(me: mutable; anIndex: Integer from Standard) - is static; - ---Level: Public - ---Purpose: Defines the index, in the color map, of the primitive color. - -- Warning: For an image, this method defines the color of the - -- boundary rectangle. - ---Category: Methods to manage color attribute - - ColorIndex (me) - returns Integer from Standard - is static; - ---Level: Public - ---Purpose: Returns the index, in the color map, of the primitive color. - -- Warning: For an image, it is the color of the border. - ---Category: Methods to manage color attribute - - -------------------------- - -- Category: Draw and Pick - -------------------------- - - Draw (me : mutable; aDrawer: Drawer from Graphic2d) - is deferred; - ---Level: Internal - ---Purpose: Draws the primitive . - - DrawElement (me : mutable; aDrawer: Drawer from Graphic2d; - anElement: Integer from Standard) - is virtual protected; - ---Level: Internal - ---Purpose: Draws the element of the primitive . - - ---SAV - DrawPickedElements(me : mutable; aDrawer: Drawer from Graphic2d ) - is virtual protected; - ---Level: Internal - ---Purpose: Draws the all picked elements of the primitive . - - ---SAV - DrawSelectedElements(me : mutable; aDrawer: Drawer from Graphic2d ) - is virtual protected; - ---Level: Internal - ---Purpose: Draws the all picked elements of the primitive . - - ---SAV - SetElementsSelected(me : mutable) returns Boolean from Standard - is virtual; - ---Level: Public - ---Purpose: Declares that previously highlighted elements will be selected ones. - -- Warning: If a descendant redefines this method then it must return ! - - ---SAV - HasSelectedElements(me : mutable) - returns Boolean from Standard is virtual; - ---Level: Public - - ---SAV - ClearSelectedElements(me : mutable) - is virtual; - ---Level: Public - - DrawVertex (me : mutable; aDrawer: Drawer from Graphic2d; - aVertex: Integer from Standard) - is virtual protected; - ---Level: Internal - ---Purpose: Draws the vertex of the primitive . - - Pick (me : mutable; X, Y: ShortReal from Standard; - aPrecision: ShortReal from Standard; - aDrawer: Drawer from Graphic2d) - returns Boolean from Standard - is deferred protected; - ---Level: Internal - ---Purpose: Returns Standard_True if the primitive is picked, - -- Standard_False if not. - - ---SAV - PickByCircle (me : mutable; X, Y, Radius : ShortReal from Standard; - aDrawer: Drawer from Graphic2d; - aPickMode: PickMode from Graphic2d = Graphic2d_PM_INCLUDE ) - returns Boolean from Standard - is virtual protected; - ---Level: Internal - ---Purpose: Returns Standard_True if the primitive is picked, - -- Standard_False if not. - - Pick( me: mutable; Xmin, Ymin, Xmax, Ymax: ShortReal from Standard; - aDrawer: Drawer from Graphic2d; - aPickMode: PickMode from Graphic2d = Graphic2d_PM_INCLUDE ) - returns Boolean from Standard is virtual protected; - ---Level: Internal - ---Purpose: Returns Standard_True if the primitive is: - -- included in rectangle (), - -- excluded from rectangle (), - -- intersected by rectangle (), - -- defined by Xmin, Ymin, Xmax, Ymax. - -- Standard_False if not. - - NumOfElemIndices( me ) returns Integer from Standard - is virtual; - ---Level: Internal - ---Purpose: Returns number of elements of primitive - - NumOfVertIndices( me ) returns Integer from Standard - is virtual; - ---Level: Internal - ---Purpose: Returns number of vertices of primitive - - SetPickedIndex (me : mutable; anIndex: Integer from Standard) - is static protected; - ---Level: Public - ---Purpose: Sets the index of the picked primitive element if any. - ---Category: Methods to manage picking - - PickedIndex (me) returns Integer from Standard is static; - ---Level: Public - ---Purpose: Returns the index of the last picked primitive element. - -- Warning: This is available only if the Pick() method has - -- returned Standard_True. - ---Category: Methods to manage picking - - - ---SAV - PickedIndices(me) returns MapOfInteger from TColStd is static; - ---C++: return const & - - Highlight (me: mutable; - anIndex: Integer from Standard = 0) - is static; - ---Level: Public - ---Purpose: Highlights the primitive or a part of the - -- primitive with the override color of the view. - -- When is 0 all the primitive is highlighted - -- >0 only the requested element is highlighted. - -- <0 only the requested vertex is highlighted. - ---Category: Methods to manage the highlight - - Unhighlight (me: mutable) - is static; - ---Level: Public - ---Purpose: Suppress the highlight on the primitive . - ---Category: Methods to manage the highlight - - IsHighlighted (me) - returns Boolean from Standard - is static; - ---Level: Public - ---Purpose: Returns Standard_True if the primitive - -- is highlighted, Standard_False if not. - ---Category: Methods to manage the highlight - - HighlightIndices(me) returns HSequenceOfInteger from TColStd; - ---Level: Public - ---Purpose: Returns the sequence of highlight indices of the primitive - ---Category: Methods to manage the highlight - - SetDisplayMode( me: mutable; aMode: Integer from Standard ); - ---Level : Public; - ---Purpose : Sets the display mode of primitive - ---Category : Methods to manage the display mode - - DisplayMode( me ) returns Integer from Standard; - ---Level : Public; - ---Purpose : Indicates the display mode of primitive - ---Category : Methods to manage the display mode - - - ---------------------------- - -- Category: Private methods - ---------------------------- - - MinMax (me : mutable; Minx, Maxx, Miny, Maxy: out ShortReal from Standard) - returns Boolean from Standard is static; - ---Level: Internal - ---Purpose: Returns TRUE and the min max values of . - -- or FALSE when the primitive is empty. - -- Called by the method Graphic2d_GraphicObject::MinMax - - ComputeMinMax (me : mutable) - returns Boolean from Standard is virtual protected; - ---Level: Internal - ---Purpose: Computes the MinMax of the primitive if possible. - - IsOn( myclass; - aX1, aY1, aX2, aY2, - aPrecision: ShortReal from Standard) - returns Boolean from Standard is protected ; - ---Level: Internal - ---Purpose: Returns Standard_True if (, ) is closed - -- to the point (, ). - ---Category: Class methods - - IsInMinMax (me : mutable; X, Y: ShortReal from Standard; - aPrecision: ShortReal from Standard) - returns Boolean from Standard; - ---Level: Internal - ---Purpose: Returns Standard_True if the point , is in the - -- rectangle defined by the min max values of . - -- Warning: If is in a transformed GraphicObject then - -- the min max values are transformed. - - Drawer(me) returns mutable Drawer from Graphic2d is protected; - ---Level: Internal - ---Purpose: Returns the attached drawer of the view of this Primitive. - ---Category: Inquiries - - PGraphicObject(me) returns GOPtr from Graphic2d is private; - ---Level: Internal - ---Purpose: Returns the graphic-object back pointer of this Primitive. - ---Category: Inquiries - - ResetIndex (me: mutable) is protected; - ---Level: Internal - ---Purpose: Resets the starting traversal index to this primitive. - - SetFamily (me : mutable; aFamily: TypeOfPrimitive from Graphic2d) - is protected; - ---Level: Internal - ---Purpose: Sets the family of this primitive. - - Family (me) returns TypeOfPrimitive is protected; - ---Level: Internal - ---Purpose: Returns the family of this primitive - - ---------------------------------------------------------------------- - - Save(me; aFStream: in out FStream from Aspect) is deferred; --- Retrieve(me; anIFStream: in out IFStream from Aspect) is deferred; - -fields - - myGOPtr : GOPtr from Graphic2d is protected; - myMinX : ShortReal from Standard is protected; - myMinY : ShortReal from Standard is protected; - myMaxX : ShortReal from Standard is protected; - myMaxY : ShortReal from Standard is protected; - myColorIndex : Integer from Standard is protected; - myPickedIndex : Integer from Standard; - ---SAV - myPickedIndices : MapOfInteger from TColStd is protected; - myTypeOfPrimitive : TypeOfPrimitive from Graphic2d; - mySeqOfHighInd : HSequenceOfInteger from TColStd; - myNumOfElem : Integer from Standard is protected; - myNumOfVert : Integer from Standard is protected; - myDisplayMode : Integer from Standard is protected; - -friends - - class Buffer from Graphic2d, - - Draw from class GraphicObject from Graphic2d - (me: mutable; - aDrawer: Drawer from Graphic2d; - Reset: Boolean from Standard), - - Draw from class GraphicObject from Graphic2d - (me: mutable; - aDrawer: Drawer from Graphic2d; - aPrimitive: Primitive from Graphic2d), - - Pick from class GraphicObject from Graphic2d - (me : mutable; - X, Y: Real from Standard; - aPrecision: Real from Standard; - aDrawer: Drawer from Graphic2d), - - ---SAV - PickByCircle from class GraphicObject from Graphic2d - (me : mutable; - X, Y: Real from Standard; - Radius: Real from Standard; - aDrawer: Drawer from Graphic2d), - - - Pick from class GraphicObject from Graphic2d - ( me : mutable; - Xmin, Ymin, Xmax, Ymax: Real from Standard; - aDrawer: Drawer from Graphic2d; - aPickMode: PickMode from Graphic2d ), - - MinMax from class GraphicObject from Graphic2d - (me; - Minx, Maxx, Miny, Maxy: out Length from Quantity), - - MarkerMinMax from class GraphicObject from Graphic2d - (me; - Minx, Maxx, Miny, Maxy: out Length from Quantity), - - RemovePrimitive from class GraphicObject from Graphic2d - (me: mutable; - aPrimitive: Primitive from Graphic2d), - - Draw from class TransientManager from Graphic2d - (me: mutable; - aPrimitive: Primitive from Graphic2d), - - DrawElement from class TransientManager from Graphic2d - (me: mutable; - aPrimitive: Primitive from Graphic2d; - anIndex: Integer from Standard), - - DrawVertex from class TransientManager from Graphic2d - (me: mutable; - aPrimitive: Primitive from Graphic2d; - anIndex: Integer from Standard), - - ---SAV - DrawPickedElements from class TransientManager from Graphic2d - (me : mutable; - aPrimitive : Primitive from Graphic2d ) - -end Primitive from Graphic2d; diff --git a/src/Graphic2d/Graphic2d_Primitive.cxx b/src/Graphic2d/Graphic2d_Primitive.cxx deleted file mode 100755 index 28af74b57c..0000000000 --- a/src/Graphic2d/Graphic2d_Primitive.cxx +++ /dev/null @@ -1,382 +0,0 @@ -// Copyright (c) 1995-1999 Matra Datavision -// Copyright (c) 1999-2012 OPEN CASCADE SAS -// -// The content of this file is subject to the Open CASCADE Technology Public -// License Version 6.5 (the "License"). You may not use the content of this file -// except in compliance with the License. Please obtain a copy of the License -// at http://www.opencascade.org and read it completely before using this file. -// -// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its -// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. -// -// The Original Code and all software distributed under the License is -// distributed on an "AS IS" basis, without warranty of any kind, and the -// Initial Developer hereby disclaims all such warranties, including without -// limitation, any warranties of merchantability, fitness for a particular -// purpose or non-infringement. Please see the License for the specific terms -// and conditions governing the rights and limitations under the License. - -// ARCH //GG_240298 -// Nouvelle methode privee ResetIndex() qui sert de relais -// a SetIndex() permettant de reinitialiser l'index -// courant d'exploration des primitives. -// //GG_200898 -// Nouvelle methode privee ComputeMinMax() qui peut etre redefinie -// dans chaque primitive de maniere a recalculer les minmax -// au moment ou l'on en a besoin. -// S3593 //GG_270298 -// Nouvelle methodes privees SetFamily() appellee par -// Line(),Marker(),Text(),Image() et Family() -// qui retourne la famille a laquelle appartient la primitive -// Voir son utilisation dans Graphic2d_GraphicObject. -// Optimisation de la methode MinMax qui retourne maintenant -// un BOOLEAN pour signale que la primitive est vide. -// G002 //GG_140400 -// Add SetPickedIndex() method -// Add DrawElement() and DrawVertex() methods -// Add IsOn() method -// Add Highlight(),Unhighlight() IsHighlighted() method. - -#include -#include - -Graphic2d_Primitive::Graphic2d_Primitive (const Handle(Graphic2d_GraphicObject)& aGraphicObject): - myMinX (ShortRealLast ()), - myMinY (ShortRealLast ()), - myMaxX (ShortRealFirst()), - myMaxY (ShortRealFirst()), - myColorIndex (1), - myNumOfElem(0), - myNumOfVert(0), - myDisplayMode(0), - myPickedIndex (0), - myTypeOfPrimitive(Graphic2d_TOP_UNKNOWN) , - mySeqOfHighInd( new TColStd_HSequenceOfInteger() ) { - - myGOPtr = aGraphicObject.operator->(); - aGraphicObject->AddPrimitive (this); - -} - -Standard_Boolean Graphic2d_Primitive::ComputeMinMax () { -// cout << "*Graphic2d_Primitive::ComputeMinMax() must be redefined in the primitive '" << this->DynamicType()->Name() << "'" << endl; - return Standard_False; -} - -Standard_Boolean Graphic2d_Primitive::MinMax (Standard_ShortReal & Minx, Standard_ShortReal & Maxx, Standard_ShortReal & Miny, Standard_ShortReal & Maxy) { -Standard_Boolean status = Standard_True; - - if( (myMaxX < myMinX) || (myMaxY < myMinY) ) { - this->ComputeMinMax(); - } - - if( (myMaxX >= myMinX) && (myMaxY >= myMinY) ) { - if (myGOPtr->IsTransformed () ) { - Standard_Real MINX,MAXX,MINY,MAXY,X,Y; - gp_GTrsf2d aTrsf = myGOPtr->Transform (); - X = myMinX; Y = myMinY; - aTrsf.Transforms (X, Y); - MINX = MAXX = X; MINY = MAXY = Y; - - X = myMaxX; Y = myMaxY; - aTrsf.Transforms (X, Y); - MINX = Min(MINX,X); MINY = Min(MINY,Y); - MAXX = Max(MAXX,X); MAXY = Max(MAXY,Y); - - X = myMinX; Y = myMaxY; - aTrsf.Transforms (X, Y); - MINX = Min(MINX,X); MINY = Min(MINY,Y); - MAXX = Max(MAXX,X); MAXY = Max(MAXY,Y); - - X = myMaxX; Y = myMinY; - aTrsf.Transforms (X, Y); - Minx = Standard_ShortReal(Min(MINX,X)); - Miny = Standard_ShortReal(Min(MINY,Y)); - Maxx = Standard_ShortReal(Max(MAXX,X)); - Maxy = Standard_ShortReal(Max(MAXY,Y)); - } else { - Minx = myMinX; Miny = myMinY; - Maxx = myMaxX; Maxy = myMaxY; - } - } else { - status = Standard_False; - Minx = myMinX; Miny = myMinY; - Maxx = myMaxX; Maxy = myMaxY; - } - - - return status; - -} - -void Graphic2d_Primitive::SetColorIndex (const Standard_Integer anIndex) { - - myColorIndex = anIndex; - ResetIndex(); - -} - -Standard_Integer Graphic2d_Primitive::ColorIndex () const { - - return myColorIndex; - -} - -Standard_Integer Graphic2d_Primitive::PickedIndex () const { - - return myPickedIndex; - -} - -Standard_Integer Graphic2d_Primitive::NumOfElemIndices() const { - return myNumOfElem; -} - -Standard_Integer Graphic2d_Primitive::NumOfVertIndices() const { - return myNumOfVert; -} - -void Graphic2d_Primitive::SetPickedIndex (const Standard_Integer anIndex) { - - myPickedIndex = anIndex; -} - -Standard_Boolean Graphic2d_Primitive::IsOn( const Standard_ShortReal aX1, - const Standard_ShortReal aY1, - const Standard_ShortReal aX2, - const Standard_ShortReal aY2, - const Standard_ShortReal aPrecision) { - - Standard_ShortReal DX = aX2 - aX1, DY = aY2 - aY1, - dd = Standard_ShortReal(Sqrt(DX*DX + DY*DY)); - - return dd < aPrecision; -} - -Standard_Boolean Graphic2d_Primitive::IsInMinMax (const Standard_ShortReal X, - const Standard_ShortReal Y, - const Standard_ShortReal aPrecision) - { -Standard_Boolean Result = Standard_False; - - if( (myMaxX < myMinX) || (myMaxY < myMinY) ) { - this->ComputeMinMax(); - } - - if (! myGOPtr->IsTransformed ()) - Result = - X >= myMinX - aPrecision && - X <= myMaxX + aPrecision && - Y >= myMinY - aPrecision && - Y <= myMaxY + aPrecision; - else { - Standard_ShortReal minx, miny, maxx, maxy; - MinMax(minx,maxx,miny,maxy); - Result = - X >= minx - aPrecision && - X <= maxx + aPrecision && - Y >= miny - aPrecision && - Y <= maxy + aPrecision; - } - - return Result; - -} - -Handle(Graphic2d_Drawer) Graphic2d_Primitive::Drawer() const { - - return myGOPtr->View()->Drawer(); -} - -Graphic2d_GOPtr Graphic2d_Primitive::PGraphicObject() const { - - return myGOPtr; -} - -void Graphic2d_Primitive::ResetIndex() { - - myGOPtr->SetIndex(this); -} - -void Graphic2d_Primitive::SetFamily( const Graphic2d_TypeOfPrimitive aFamily) { - - myTypeOfPrimitive = aFamily; -} - -Graphic2d_TypeOfPrimitive Graphic2d_Primitive::Family() const { - - return myTypeOfPrimitive; -} - -void Graphic2d_Primitive::DrawElement( const Handle(Graphic2d_Drawer)& /*aDrawer*/, - const Standard_Integer /*anElement*/) { - cout << " *** Graphic2d_Primitive::DrawElement() method must be redefined ***" << endl; -} - -//SAV -void Graphic2d_Primitive -::DrawPickedElements( const Handle(Graphic2d_Drawer)& /*aDrawer*/ ) -{ -#ifdef DEB - cout << " *** Graphic2d_Primitive::DrawPickedElements() method must be redefined ***" - << endl; -#endif -} - -// SAV -void Graphic2d_Primitive -::DrawSelectedElements( const Handle(Graphic2d_Drawer)& /*aDrawer*/ ) -{ -#ifdef DEB - cout << " *** Graphic2d_Primitive::DrawSelectedElements() method must be redefined ***" - << endl; -#endif -} - -// SAV -Standard_Boolean Graphic2d_Primitive::SetElementsSelected() -{ - return Standard_False; -} - -// SAV -Standard_Boolean Graphic2d_Primitive::HasSelectedElements() -{ - /* if this method is not redefined we should return false - to achieve the standard behavior of Graphic2d_GraphicObject::Draw() method. - already redefined for SetOfMarkers - */ - return Standard_False; -} - -// SAV -void Graphic2d_Primitive::ClearSelectedElements() -{ - // parent does nothing! redefine please -#ifdef DEB - cout << " *** Graphic2d_Primitive::ClearSelectedElements() method must be redefined ***" - << endl; -#endif -} - -// SAV -Standard_Boolean Graphic2d_Primitive -::PickByCircle( const Standard_ShortReal X, - const Standard_ShortReal Y, - const Standard_ShortReal Radius, - const Handle(Graphic2d_Drawer)& /*aDrawer*/, - const Graphic2d_PickMode aPickMode ) -{ - // parent does nothing! redefine please -#ifdef SAV_DEB - cout << " *** Graphic2d_Primitive::PickByCircle() method must be redefined ***" - << endl; -#endif - return Standard_False; -} - - -void Graphic2d_Primitive::DrawVertex( const Handle(Graphic2d_Drawer)& /*aDrawer*/, - const Standard_Integer /*aVertex*/) { - cout << " *** Graphic2d_Primitive::DrawVertex() method must be redefined ***" << endl; -} - -void Graphic2d_Primitive::Highlight( const Standard_Integer anIndex) { - - mySeqOfHighInd->Append(anIndex); -} - -void Graphic2d_Primitive::Unhighlight () { - if ( ! mySeqOfHighInd->IsEmpty() ) - mySeqOfHighInd->Clear(); -} - -Standard_Boolean Graphic2d_Primitive::IsHighlighted () const { - return ( ! mySeqOfHighInd->IsEmpty() ); -} - -Handle(TColStd_HSequenceOfInteger) Graphic2d_Primitive::HighlightIndices() const { - - return mySeqOfHighInd; -} - -const TColStd_MapOfInteger& Graphic2d_Primitive::PickedIndices() const -{ - return myPickedIndices; -} - - -void Graphic2d_Primitive::SetDisplayMode( const Standard_Integer aMode ) { - - myDisplayMode = aMode; - -} - -Standard_Integer Graphic2d_Primitive::DisplayMode() const { - - return myDisplayMode; -} - -Standard_Boolean Graphic2d_Primitive::Pick( const Standard_ShortReal Xmin, - const Standard_ShortReal Ymin, - const Standard_ShortReal Xmax, - const Standard_ShortReal Ymax, - const Handle(Graphic2d_Drawer)& /*aDrawer*/, - const Graphic2d_PickMode aPickMode ) { - - - Standard_ShortReal X1 = Min( Xmax, Xmin ); - Standard_ShortReal Y1 = Min( Ymax, Ymin ); - Standard_ShortReal X2 = Max( Xmax, Xmin ); - Standard_ShortReal Y2 = Max( Ymax, Ymin ); - - Standard_Boolean Result = Standard_False; - - if ( ( myMaxX < myMinX ) || ( myMaxY < myMinY ) ) - ComputeMinMax(); - Standard_ShortReal minx = myMinX, miny = myMinY, - maxx = myMaxX, maxy = myMaxY; - if ( myGOPtr->IsTransformed() ) - MinMax(minx,maxx,miny,maxy); - switch ( aPickMode ) { - case Graphic2d_PM_INCLUDE: - - Result = - minx >= X1 && - miny >= Y1 && - maxx <= X2 && - maxy <= Y2; - break; - case Graphic2d_PM_EXCLUDE: - - Result = - maxx < X1 || - maxy < Y1 || - minx > X2 || - miny > Y2; - break; - case Graphic2d_PM_INTERSECT: { - - Standard_ShortReal a = Max( minx, X1 ); - Standard_ShortReal b = Max( miny, Y1 ); - Standard_ShortReal c = Min( maxx, X2 ); - Standard_ShortReal d = Min( maxy, Y2 ); - - Result = ( a >= c || d <= b ) ? 0 : 1; - - if ( Result && - ( X1 >= minx && - Y1 >= miny && - X2 <= maxx && - Y2 <= maxy ) ) Result = 0;; - - - } - break; - default: - Result = Standard_False; - } - - return Result; - -} diff --git a/src/Graphic2d/Graphic2d_Primitive.pxx b/src/Graphic2d/Graphic2d_Primitive.pxx deleted file mode 100755 index 0bad015e5b..0000000000 --- a/src/Graphic2d/Graphic2d_Primitive.pxx +++ /dev/null @@ -1,81 +0,0 @@ -// Copyright (c) 1995-1999 Matra Datavision -// Copyright (c) 1999-2012 OPEN CASCADE SAS -// -// The content of this file is subject to the Open CASCADE Technology Public -// License Version 6.5 (the "License"). You may not use the content of this file -// except in compliance with the License. Please obtain a copy of the License -// at http://www.opencascade.org and read it completely before using this file. -// -// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its -// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. -// -// The Original Code and all software distributed under the License is -// distributed on an "AS IS" basis, without warranty of any kind, and the -// Initial Developer hereby disclaims all such warranties, including without -// limitation, any warranties of merchantability, fitness for a particular -// purpose or non-infringement. Please see the License for the specific terms -// and conditions governing the rights and limitations under the License. - - -#ifndef PRIMITIVE_PXX_INCLUDED -#define PRIMITIVE_PXX_INCLUDED - -#define NEW_ANGLE(a) { \ -int quot = (int) (a/(2. * M_PI)); \ - if (Abs(quot) >= 1) a = a - 2. * M_PI * quot; \ -} - -#define REALEPSILON() (0.0001) - -#define VALUE_OF_ANGLE(x,y,z) { \ -double a; \ - if (x > 0.) \ - if (x <= REALEPSILON ()) x = 0.; \ - if (x < 0.) \ - if (-x <= REALEPSILON ()) x = 0.; \ - if (y > 0.) \ - if (y <= REALEPSILON ()) y = 0.; \ - if (y < 0.) \ - if (-y <= REALEPSILON ()) y = 0.; \ - if (x == 0.) { \ - if (y > 0.) z = M_PI / 2.; \ - else z = - M_PI / 2.; \ - } \ - if (y == 0.) { \ - if (x > 0.) z = 0.; \ - else z = M_PI; \ - } \ - if ((x < 0.) && (y > 0.)) { \ - a = acos (x); \ - if ((a >= M_PI / 2.-REALEPSILON ()) && \ - (a <= M_PI + REALEPSILON ())) \ - z = a; \ - else \ - z = - a; \ - } \ - if ((x >= 0.) && (y > 0.)) { \ - a = acos (x); \ - if ((a >= 0.) && \ - (a <= M_PI / 2. + REALEPSILON ())) \ - z = a; \ - else \ - z = - a; \ - } \ - if ((x < 0.) && (y < 0.)) { \ - a = acos (x); \ - z = - a; \ - } \ - if ((x > 0.) && (y < 0.)) { \ - a = acos (x); \ - if ((a >= 0.) && \ - (a <= M_PI / 2. + REALEPSILON ())) \ - z = - a; \ - else \ - z = a; \ - } \ -} - -#define XROTATE(x,y) ((x)*cosa - (y)*sina) -#define YROTATE(x,y) ((y)*cosa + (x)*sina) - -#endif diff --git a/src/Graphic2d/Graphic2d_Segment.cdl b/src/Graphic2d/Graphic2d_Segment.cdl deleted file mode 100755 index 4a856d6adf..0000000000 --- a/src/Graphic2d/Graphic2d_Segment.cdl +++ /dev/null @@ -1,116 +0,0 @@ --- Created on: 1993-06-22 --- Created by: Jean Louis FRENKEL, Gerard GRAS --- Copyright (c) 1993-1999 Matra Datavision --- Copyright (c) 1999-2012 OPEN CASCADE SAS --- --- The content of this file is subject to the Open CASCADE Technology Public --- License Version 6.5 (the "License"). You may not use the content of this file --- except in compliance with the License. Please obtain a copy of the License --- at http://www.opencascade.org and read it completely before using this file. --- --- The Initial Developer of the Original Code is Open CASCADE S.A.S., having its --- main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. --- --- The Original Code and all software distributed under the License is --- distributed on an "AS IS" basis, without warranty of any kind, and the --- Initial Developer hereby disclaims all such warranties, including without --- limitation, any warranties of merchantability, fitness for a particular --- purpose or non-infringement. Please see the License for the specific terms --- and conditions governing the rights and limitations under the License. - - --- Modified: TCL G002, 07-08-00, new inquire methods FirstPoint, SecondPoint - - -class Segment from Graphic2d inherits Line from Graphic2d - - ---Version: - - ---Purpose: The primitive Segment - - ---Keywords: Primitive, Segment - ---Warning: - ---References: - -uses - Drawer from Graphic2d, - GraphicObject from Graphic2d, - Length from Quantity, - FStream from Aspect, - IFStream from Aspect - -raises - SegmentDefinitionError from Graphic2d - -is - ------------------------------------- - -- Category: Constructors - ------------------------------------- - - Create (aGraphicObject: GraphicObject from Graphic2d; - X1, Y1, X2, Y2: Length from Quantity) - returns mutable Segment from Graphic2d - ---Level: Public - ---Purpose: Creates a segment in the graphic object . - -- The first point is , . - -- The second point is , . - -- Warning: Raises SegmentDefinitionError if the - -- first point and the second point are identical. - raises SegmentDefinitionError from Graphic2d; - - ---------------------------------------- - -- Category: Inquire methods - ---------------------------------------- - - FirstPoint( me; X, Y: out Length from Quantity ); - ---Level: Public - ---Purpose: returns the coordinates of the first point of the segment - - SecondPoint( me; X, Y: out Length from Quantity ); - ---Level: Public - ---Purpose: returns the coordinates of the second point of the segment - - -------------------------------------- - -- Category: Draw and Pick - -------------------------------------- - - Draw (me : mutable; aDrawer: Drawer from Graphic2d) - is static protected; - ---Level: Internal - ---Purpose: Draws the segment . - - DrawElement( me : mutable; aDrawer: Drawer from Graphic2d; - anIndex: Integer from Standard) - is redefined protected; - ---Level: Internal - ---Purpose: Draws edge of the segment . - - DrawVertex( me : mutable; aDrawer: Drawer from Graphic2d; - anIndex: Integer from Standard) - is redefined protected; - ---Level: Internal - ---Purpose: Draws vertex of the segment . - - Pick (me : mutable; X, Y: ShortReal from Standard; - aPrecision: ShortReal from Standard; - aDrawer: Drawer from Graphic2d) - returns Boolean from Standard - is static protected; - ---Level: Internal - ---Purpose: Returns Standard_True if the segment is picked, - -- Standard_False if not. - - ---------------------------------------------------------------------- - - Save(me; aFStream: in out FStream from Aspect) is virtual; - Retrieve(myclass; anIFStream: in out IFStream from Aspect; - aGraphicObject: GraphicObject from Graphic2d); - -fields - - myX1: ShortReal from Standard; - myY1: ShortReal from Standard; - myX2: ShortReal from Standard; - myY2: ShortReal from Standard; - -end Segment from Graphic2d; diff --git a/src/Graphic2d/Graphic2d_Segment.cxx b/src/Graphic2d/Graphic2d_Segment.cxx deleted file mode 100755 index d80d53add4..0000000000 --- a/src/Graphic2d/Graphic2d_Segment.cxx +++ /dev/null @@ -1,245 +0,0 @@ -// Copyright (c) 1995-1999 Matra Datavision -// Copyright (c) 1999-2012 OPEN CASCADE SAS -// -// The content of this file is subject to the Open CASCADE Technology Public -// License Version 6.5 (the "License"). You may not use the content of this file -// except in compliance with the License. Please obtain a copy of the License -// at http://www.opencascade.org and read it completely before using this file. -// -// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its -// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. -// -// The Original Code and all software distributed under the License is -// distributed on an "AS IS" basis, without warranty of any kind, and the -// Initial Developer hereby disclaims all such warranties, including without -// limitation, any warranties of merchantability, fitness for a particular -// purpose or non-infringement. Please see the License for the specific terms -// and conditions governing the rights and limitations under the License. - -#define WTO0001 //GG_140596 -// Calcul des min-max faux apres transformation. - -#define G002 //Use SetPickedIndex() method -// Add new DrawElement(), DrawVertex() methods - -#define VERTEXMARKER 2 -#define DEFAULTMARKERSIZE 3.0 - -#include - -Graphic2d_Segment::Graphic2d_Segment ( - const Handle(Graphic2d_GraphicObject)& aGraphicObject, - const Standard_Real X1, const Standard_Real Y1, - const Standard_Real X2, const Standard_Real Y2) - : Graphic2d_Line (aGraphicObject) -{ - myX1 = Standard_ShortReal (X1); - myY1 = Standard_ShortReal (Y1); - myX2 = Standard_ShortReal (X2); - myY2 = Standard_ShortReal (Y2); - - myMinX = (myX1 < myX2 ? myX1 : myX2); - myMinY = (myY1 < myY2 ? myY1 : myY2); - myMaxX = (myX1 > myX2 ? myX1 : myX2); - myMaxY = (myY1 > myY2 ? myY1 : myY2); - myNumOfElem = 1; - myNumOfVert = 2; -} - -void Graphic2d_Segment :: FirstPoint ( Quantity_Length& X,Quantity_Length& Y ) const -{ - X = Standard_Real(myX1); - Y = Standard_Real(myY1); -} - -void Graphic2d_Segment :: SecondPoint ( Quantity_Length& X,Quantity_Length& Y ) const -{ - X = Standard_Real(myX2); - Y = Standard_Real(myY2); -} - -void Graphic2d_Segment::Draw (const Handle(Graphic2d_Drawer)& aDrawer) -{ - - Standard_Boolean IsIn = Standard_False; - - if (! myGOPtr->IsTransformed ()) - IsIn = aDrawer->IsIn (myMinX,myMaxX,myMinY,myMaxY); - else { - Standard_ShortReal minx, miny, maxx, maxy; -#ifdef WTO0001 - MinMax(minx,maxx,miny,maxy); -#else - gp_GTrsf2d aTrsf = myGOPtr->Transform (); - Standard_Real MINX, MINY, MAXX, MAXY; - - MINX = Standard_Real (myMinX); - MINY = Standard_Real (myMinY); - MAXX = Standard_Real (myMaxX); - MAXY = Standard_Real (myMaxY); - aTrsf.Transforms (MINX, MINY); - aTrsf.Transforms (MAXX, MAXY); - minx = Standard_ShortReal (MINX); - miny = Standard_ShortReal (MINY); - maxx = Standard_ShortReal (MAXX); - maxy = Standard_ShortReal (MAXY); -#endif - IsIn = aDrawer->IsIn (minx,maxx,miny,maxy); - } - - if ( IsIn ) { - DrawLineAttrib(aDrawer); - switch ( myDisplayMode ) { - case 0 : - default: { - Standard_ShortReal a = myX1, b = myY1, c = myX2, d = myY2; - - if ( myGOPtr->IsTransformed() ) { - gp_GTrsf2d aTrsf = myGOPtr->Transform (); - Standard_Real A, B, C, D; - A = Standard_Real (a); - B = Standard_Real (b); - C = Standard_Real (c); - D = Standard_Real (d); - aTrsf.Transforms (A, B); - aTrsf.Transforms (C, D); - a = Standard_ShortReal (A); - b = Standard_ShortReal (B); - c = Standard_ShortReal (C); - d = Standard_ShortReal (D); - } - aDrawer->MapSegmentFromTo(a, b, c, d); - } - break; - case 1 : { - Standard_ShortReal minX = myMinX, minY = myMinY, maxX = myMaxX, maxY = myMaxY; - if ( myGOPtr->IsTransformed() ) { - gp_GTrsf2d aTrsf = myGOPtr->Transform (); - Standard_Real A, B, C, D; - A = Standard_Real(minX); - B = Standard_Real(minY); - C = Standard_Real(maxX); - D = Standard_Real(maxY); - aTrsf.Transforms(A, B); - aTrsf.Transforms(C, D); - minX = Standard_ShortReal(A); - minY = Standard_ShortReal(B); - maxX = Standard_ShortReal(C); - maxY = Standard_ShortReal(D); - } - aDrawer->MapSegmentFromTo(minX, minY, minX, maxY); - aDrawer->MapSegmentFromTo(minX, maxY, maxX, maxY ); - aDrawer->MapSegmentFromTo(maxX, maxY, maxX, minY ); - aDrawer->MapSegmentFromTo(maxX, minY, minX, minY ); - } - } // end switch - } // end if IsIn -} - -#ifdef G002 -void Graphic2d_Segment::DrawElement( const Handle(Graphic2d_Drawer)& aDrawer, - const Standard_Integer anIndex) -{ - if ( anIndex == 1 ) - Draw( aDrawer ); -} - -void Graphic2d_Segment::DrawVertex( const Handle(Graphic2d_Drawer)& aDrawer, - const Standard_Integer anIndex) -{ - Standard_Boolean IsIn = Standard_False; - - if (! myGOPtr->IsTransformed ()) - IsIn = aDrawer->IsIn (myMinX,myMaxX,myMinY,myMaxY); - else { - Standard_ShortReal minx, miny, maxx, maxy; - MinMax(minx,maxx,miny,maxy); - IsIn = aDrawer->IsIn (minx,maxx,miny,maxy); - } - if ( IsIn ) { - if ( anIndex == 1 || anIndex == 2 ) { - Standard_ShortReal X,Y; - DrawMarkerAttrib (aDrawer); - if ( myGOPtr->IsTransformed() ) { - gp_GTrsf2d aTrsf = myGOPtr->Transform (); - Standard_Real A, B; - if ( anIndex == 1 ) { - A = Standard_Real(myX1); - B = Standard_Real(myY1); - } else { - A = Standard_Real(myX2); - B = Standard_Real(myY2); - } - aTrsf.Transforms (A, B); - X = Standard_ShortReal(A); - Y = Standard_ShortReal(B); - } else { - if ( anIndex == 1 ) { - X = myX1; - Y = myY1; - } else { - X = myX2; - Y = myY2; - } - } - aDrawer->MapMarkerFromTo(VERTEXMARKER,X,Y, DEFAULTMARKERSIZE,DEFAULTMARKERSIZE,0.0); - } - } -} -#endif - -Standard_Boolean Graphic2d_Segment::Pick( - const Standard_ShortReal X, - const Standard_ShortReal Y, - const Standard_ShortReal aPrecision, - const Handle(Graphic2d_Drawer)& aDrawer) -{ - Standard_ShortReal SRX = X, SRY = Y; - Standard_Boolean Result = Standard_False; - - if ( IsInMinMax( X, Y, aPrecision ) ) { - if ( myGOPtr->IsTransformed() ) { - gp_GTrsf2d aTrsf = (myGOPtr->Transform ()).Inverted (); - Standard_Real RX = Standard_Real( SRX ), RY = Standard_Real( SRY ); - aTrsf.Transforms( RX, RY ); - SRX = Standard_ShortReal( RX ); - SRY = Standard_ShortReal( RY ); - } - #ifdef G002 - if ( Graphic2d_Primitive::IsOn( SRX, SRY, myX1, myY1, aPrecision) ) { - SetPickedIndex(-1); - Result = Standard_True; - } else if ( Graphic2d_Primitive::IsOn( SRX, SRY, myX2, myY2, aPrecision) ) { - SetPickedIndex(-2); - Result = Standard_True; - } else if ( IsOn( SRX, SRY, myX1, myY1, myX2, myY2, aPrecision ) ) { - SetPickedIndex( 1 ); - Result = Standard_True; - } - #else - Result = IsOn( SRX, SRY, myX1, myY1, myX2, myY2, aPrecision ); - #endif - } - return Result; -} - -void Graphic2d_Segment::Save(Aspect_FStream& aFStream) const -{ - *aFStream << "Graphic2d_Segment" << endl; - *aFStream << myX2 << ' ' << myY2 << endl; - *aFStream << myX1 << ' ' << myY1 << endl; - Graphic2d_Line::Save(aFStream); -} - -void Graphic2d_Segment::Retrieve(Aspect_IFStream& anIFStream, - const Handle(Graphic2d_GraphicObject)& aGraphicObject) -{ - Quantity_Length X1, Y1, X2, Y2; - - *anIFStream >> X2 >> Y2; - *anIFStream >> X1 >> Y1; - Handle(Graphic2d_Segment) - theSeg = new Graphic2d_Segment(aGraphicObject, X1, Y1, X2, Y2); - ((Handle (Graphic2d_Line))theSeg)->Retrieve(anIFStream); -} - diff --git a/src/Graphic2d/Graphic2d_SetOfMarkers.cdl b/src/Graphic2d/Graphic2d_SetOfMarkers.cdl deleted file mode 100755 index d5daacd146..0000000000 --- a/src/Graphic2d/Graphic2d_SetOfMarkers.cdl +++ /dev/null @@ -1,232 +0,0 @@ --- Created on: 1993-04-13 --- Created by: Gerard GRAS --- Copyright (c) 1993-1999 Matra Datavision --- Copyright (c) 1999-2012 OPEN CASCADE SAS --- --- The content of this file is subject to the Open CASCADE Technology Public --- License Version 6.5 (the "License"). You may not use the content of this file --- except in compliance with the License. Please obtain a copy of the License --- at http://www.opencascade.org and read it completely before using this file. --- --- The Initial Developer of the Original Code is Open CASCADE S.A.S., having its --- main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. --- --- The Original Code and all software distributed under the License is --- distributed on an "AS IS" basis, without warranty of any kind, and the --- Initial Developer hereby disclaims all such warranties, including without --- limitation, any warranties of merchantability, fitness for a particular --- purpose or non-infringement. Please see the License for the specific terms --- and conditions governing the rights and limitations under the License. - - --- Modified: TCL G002A, 28-11-00, is modified method Values(...) - - -class SetOfMarkers from Graphic2d inherits Line from Graphic2d - - ---Version: - - ---Purpose: The primitive SetOfMarkers - -- Warning: This primitive must be use as possible for performance - -- improvment but is drawn with a global marker attributes - -- for all the set. - -- NOTE: than the method PickedIndex() permits to known - -- the last picked marker in the set. - -- SAV : 14/11/01 : Added a set of methods (marked SAV before declaration) - -- to provide highlighting/selection - -- of SetOfMarkers elements. These methods should be redefined - -- for other SetOf<>. - -- - -- SAV : 23/05/02 : WARNING!!! method PickByCircle performs only detection - -- function. It doesn't cause any visual highlighting. - -uses - - Drawer from Graphic2d, - GraphicObject from Graphic2d, - Length from Quantity, - PlaneAngle from Quantity, - SequenceOfInteger from TColStd, - SequenceOfShortReal from TShort, - FStream from Aspect, - IFStream from Aspect, - PickMode from Graphic2d, - MapOfInteger from TColStd, - HSequenceOfInteger from TColStd, - HArray1OfShortReal from TShort - -raises - MarkerDefinitionError from Graphic2d, - OutOfRange from Standard - -is - ------------------------- - -- Category: Constructors - ------------------------- - - Create (aGraphicObject: GraphicObject from Graphic2d) - returns mutable SetOfMarkers from Graphic2d; - ---Level: Public - ---Purpose: Creates an empty set of markers in the graphic - -- object . - ---Category: Constructors - - Add(me : mutable; X, Y: Length from Quantity); - ---Level: Public - ---Purpose: Add a pixel point marker in the set - ---Category: Update method - - Add(me : mutable; - anIndex: Integer from Standard; - X, Y: Length from Quantity; - aWidth: Length from Quantity; - anHeight: Length from Quantity; - anAngle: PlaneAngle from Quantity = 0.0) - ---Level: Public - ---Purpose: Add a marker of predefined index in the set - -- at position , and size ,. - -- Angle is measured counterclockwise with 0 radian - -- at 3 o'clock. - -- Trigger: Raises MarkerDefinitionError if the - -- marker index is <= 0 or undefined in the MarkMap, - -- or the marker size is <= 0. - raises MarkerDefinitionError from Graphic2d; - ---Category: Update method - - Length(me) returns Integer from Standard; - ---Level: Public - ---Purpose: Returns the number of markers in the set. - ---Category: Inquiry method - - Values( me; - aRank : Integer from Standard; - anIndex : out Integer from Standard; - X, Y : out Length from Quantity; - aW, aH : out Length from Quantity; - anAngle : out PlaneAngle from Quantity ) - ---Level: Public - ---Purpose: Returns the marker type, position, sizes and angle - -- and type from the set at rank . - -- Warning: For the pixel point marker the returned is NULL - -- Trigger: Raises OutOfRange if is <1 or >Length() - raises OutOfRange from Standard; - ---Category: Inquiry method - - -------------------------- - -- Category: Draw and Pick - -------------------------- - - Draw (me : mutable; aDrawer: Drawer from Graphic2d) - is static protected; - ---Level: Internal - ---Purpose: Draws the set of markers . - - DrawElement( me : mutable; aDrawer: Drawer from Graphic2d; - anIndex: Integer from Standard) - is redefined protected; - ---Level: Internal - ---Purpose: Draws element of the set . - - ---SAV - DrawPickedElements(me : mutable; aDrawer: Drawer from Graphic2d ) - is redefined protected; - ---Level: Internal - ---Purpose: Draws the all picked elements of the primitive . - - ---SAV - DrawSelectedElements(me : mutable; aDrawer: Drawer from Graphic2d ) - is redefined protected; - ---Level: Internal - ---Purpose: Draws the all selected elements of the primitive . - - ---SAV - SetElementsSelected(me : mutable) returns Boolean from Standard - is redefined; - ---Level: Public - ---Purpose: Declares that previously highlighted elements will be selected ones. - - ---SAV - HasSelectedElements(me : mutable) - returns Boolean from Standard is redefined; - ---Level: Public - - ---SAV - DrawElements(me : mutable; aDrawer : Drawer from Graphic2d; - x,y : HArray1OfShortReal from TShort) - is private; - ---Level: Internal - - ---SAV - ClearSelectedElements(me : mutable) - is redefined; - ---Level: Public - - ---SAV - GetSelectedElements(me) - returns MapOfInteger from TColStd; - ---C++: return const & - - ---SAV - AddOrRemoveSelected(me : mutable; index : Integer from Standard); - ---Level: Public - ---Purpose: adds/removes marker to/from selection map. - - DrawVertex( me : mutable; aDrawer: Drawer from Graphic2d; - anIndex: Integer from Standard) - is redefined protected; - ---Level: Internal - ---Purpose: Draws vertex of the set . - - Pick (me : mutable; X, Y: ShortReal from Standard; - aPrecision: ShortReal from Standard; - aDrawer: Drawer from Graphic2d) - returns Boolean from Standard - is static protected; - ---Level: Internal - ---Purpose: Returns Standard_True if one marker of the set - -- is picked, Standard_False if not. - -- Warning: The PickIndex() method returns the rank of the picked - -- marker if any. - - ---------------------------------------------------------------------- - - Save( me; aFStream: in out FStream from Aspect ) is virtual; --- Retrieve( me; aIFStream: in out IFStream from AIS2D ) is virtual; - - ---SAV - Pick (me : mutable; X1, Y1, X2, Y2 : ShortReal from Standard; - aDrawer : Drawer from Graphic2d; - aPickMode : PickMode from Graphic2d) - returns Boolean from Standard is redefined protected; - - ---SAV - PickByCircle(me : mutable; x, y, radius : ShortReal from Standard; - aDrawer : Drawer from Graphic2d; - aPickMode : PickMode from Graphic2d) - returns Boolean from Standard is redefined protected; - - ---SAV - SetHighlightedLimit(me:mutable; number : Integer from Standard); - ---Level: Public - ---Purpose: sets limit of number elements to be highlighted. - - ---SAV - SetScaledWidth( me: mutable; width : ShortReal from Standard ); - ---Purpose: Changes myScaledWidth field. As this value used in detection - -- mechanism it should be reset after view transformation. - -fields - - myType: SequenceOfInteger from TColStd; - myX: SequenceOfShortReal from TShort; - myY: SequenceOfShortReal from TShort; - myWidth: SequenceOfShortReal from TShort; - myHeight: SequenceOfShortReal from TShort; - myAngle: SequenceOfShortReal from TShort; - mySelIndices : HSequenceOfInteger from TColStd; - myMapOfSelected : MapOfInteger from TColStd; - myHLimit : Integer from Standard; - mySuppressHigh : Boolean from Standard; - myScaledWidth : Length from Quantity; - -end SetOfMarkers from Graphic2d; diff --git a/src/Graphic2d/Graphic2d_SetOfMarkers.cxx b/src/Graphic2d/Graphic2d_SetOfMarkers.cxx deleted file mode 100755 index 61e94c5fa5..0000000000 --- a/src/Graphic2d/Graphic2d_SetOfMarkers.cxx +++ /dev/null @@ -1,495 +0,0 @@ -// Copyright (c) 1995-1999 Matra Datavision -// Copyright (c) 1999-2012 OPEN CASCADE SAS -// -// The content of this file is subject to the Open CASCADE Technology Public -// License Version 6.5 (the "License"). You may not use the content of this file -// except in compliance with the License. Please obtain a copy of the License -// at http://www.opencascade.org and read it completely before using this file. -// -// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its -// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. -// -// The Original Code and all software distributed under the License is -// distributed on an "AS IS" basis, without warranty of any kind, and the -// Initial Developer hereby disclaims all such warranties, including without -// limitation, any warranties of merchantability, fitness for a particular -// purpose or non-infringement. Please see the License for the specific terms -// and conditions governing the rights and limitations under the License. - -#define G002 //GG_140400 Use SetPickedIndex method -// Add new DrawElement(), DrawVertex() methods - -#define VERTEXMARKER 2 -#define DEFAULTMARKERSIZE 3.0 - -#include - - -//SAV -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#define OCC402 - -Graphic2d_SetOfMarkers -::Graphic2d_SetOfMarkers( const Handle(Graphic2d_GraphicObject)& aGraphicObject ) -: Graphic2d_Line (aGraphicObject), myHLimit( -1 ), mySuppressHigh( Standard_False ) -{ - - SetFamily(Graphic2d_TOP_MARKER); - -} - -void Graphic2d_SetOfMarkers::Add ( const Standard_Real X, const Standard_Real Y) { - - Standard_ShortReal x = Standard_ShortReal( X ); - Standard_ShortReal y = Standard_ShortReal( Y ); - - myMinX = Min(myMinX,x); - myMinY = Min(myMinY,y); - myMaxX = Max(myMaxX,x); - myMaxY = Max(myMaxY,y); - - myType.Append(0); - myX.Append(x); - myY.Append(y); - myWidth.Append(0.); - myHeight.Append(0.); - myAngle.Append(0.); - myScaledWidth = 0.; - -} - -void Graphic2d_SetOfMarkers::Add ( - const Standard_Integer anIndex, - const Standard_Real X, const Standard_Real Y, - const Standard_Real aWidth, const Standard_Real anHeight, - const Quantity_PlaneAngle anAngle) -{ -Standard_ShortReal x = Standard_ShortReal( X ); -Standard_ShortReal y = Standard_ShortReal( Y ); -Standard_ShortReal w = Standard_ShortReal( aWidth ); -Standard_ShortReal h = Standard_ShortReal( anHeight ); -Standard_ShortReal a = Standard_ShortReal( anAngle ); -Standard_ShortReal x1 = Standard_ShortReal( x - w/2. ); -Standard_ShortReal x2 = Standard_ShortReal( x + w/2. ); -Standard_ShortReal y1 = Standard_ShortReal( y - h/2. ); -Standard_ShortReal y2 = Standard_ShortReal( y + h/2. ); - - if( anIndex <= 0 ) - Graphic2d_MarkerDefinitionError::Raise - ("The marker index must be > 0"); - - if (aWidth <= 0.0) - Graphic2d_MarkerDefinitionError::Raise ("The width = 0."); - - if (anHeight <= 0.0) - Graphic2d_MarkerDefinitionError::Raise ("The height = 0."); - - myMinX = Min(myMinX,x1); - myMinY = Min(myMinY,y1); - myMaxX = Max(myMaxX,x2); - myMaxY = Max(myMaxY,y2); - - myType.Append(anIndex); - myX.Append(x); - myY.Append(y); - myWidth.Append(w); - myHeight.Append(h); - myAngle.Append(a); - myScaledWidth = w; -} - -Standard_Integer Graphic2d_SetOfMarkers::Length () const { - return myX.Length(); -} - -void Graphic2d_SetOfMarkers::Values( - const Standard_Integer aRank, - Standard_Integer &anIndex, - Quantity_Length & X, - Quantity_Length & Y, - Quantity_Length & aW, - Quantity_Length & aH, - Quantity_PlaneAngle & anAngle ) const -{ - if( aRank < 1 || aRank > myX.Length() ) - Standard_OutOfRange::Raise - ("the marker rank is out of bounds in the set"); - - anIndex = myType( aRank ); - X = Quantity_Length( myX( aRank ) ); - Y = Quantity_Length( myY( aRank ) ); - aW = Quantity_Length( myWidth( aRank ) ); - aH = Quantity_Length( myHeight( aRank ) ); - anAngle = Quantity_PlaneAngle( myAngle( aRank ) ); -} - -void Graphic2d_SetOfMarkers::Draw (const Handle(Graphic2d_Drawer)& aDrawer) { - - myNumOfElem = Length(); - myNumOfVert = Length(); - Standard_Integer i,l = Length(),bufferize = 0; - - if ( (l > 0) && aDrawer->IsIn (myMinX,myMaxX,myMinY,myMaxY)){ - DrawMarkerAttrib(aDrawer); - - if( l > 2 ) bufferize = 1; - aDrawer->MapMarkerFromTo - (myType(1), myX(1), myY(1), myWidth(1), myHeight(1), - myAngle(1),bufferize); - for( i=2 ; iMapMarkerFromTo - (myType(i), myX(i), myY(i), myWidth(i), myHeight(i), myAngle(i),0); - } - aDrawer->MapMarkerFromTo - (myType(l), myX(l), myY(l), myWidth(l), myHeight(l), - myAngle(l),-bufferize); - } -} - -#ifdef G002 - -void Graphic2d_SetOfMarkers::DrawElement( const Handle(Graphic2d_Drawer)& aDrawer, - const Standard_Integer anIndex) { - Standard_Integer l = Length(), bufferize = 0; - - if ( (l > 0) && aDrawer->IsIn( myMinX,myMaxX,myMinY,myMaxY) ) { - if ( anIndex > 0 && anIndex <= l ) { //Draw element - DrawMarkerAttrib(aDrawer); - if ( l > 2 ) bufferize = 1; - if ( anIndex == 1 ) - aDrawer->MapMarkerFromTo - ( myType(1), myX(1), myY(1), myWidth(1), myHeight(1), - myAngle(1),bufferize ); - else if ( anIndex == l ) - aDrawer->MapMarkerFromTo - (myType(l), myX(l), myY(l), myWidth(l), myHeight(l), - myAngle(l),-bufferize); - else - aDrawer->MapMarkerFromTo - ( myType(anIndex), myX(anIndex), myY(anIndex), myWidth(anIndex), - myHeight(anIndex), myAngle(anIndex),0); - } - } - -} - -void Graphic2d_SetOfMarkers::DrawVertex( const Handle(Graphic2d_Drawer)& /*aDrawer*/, - const Standard_Integer /*anIndex*/) { -} -#endif - -Standard_Boolean Graphic2d_SetOfMarkers::Pick (const Standard_ShortReal X, - const Standard_ShortReal Y, - const Standard_ShortReal aPrecision, - const Handle(Graphic2d_Drawer)& /*aDrawer*/) { - - -#ifdef OCC402 - myPickedIndices.Clear(); -#endif - - Standard_Integer i,l = Length(); - Standard_ShortReal SRX = X, SRY = Y; - - if ( (l > 0) && IsInMinMax (X, Y, aPrecision)) { - - if (myGOPtr->IsTransformed ()) { - gp_GTrsf2d aTrsf = (myGOPtr->Transform ()).Inverted (); - Standard_Real RX = Standard_Real (SRX), RY = Standard_Real (SRY); - aTrsf.Transforms (RX, RY); - SRX = Standard_ShortReal (RX); SRY = Standard_ShortReal (RY); - } - -#ifdef G002 - for ( i = 1; i <= myX.Length(); i++ ) { - if ( Graphic2d_Primitive::IsOn ( SRX, SRY, myX(i), myY(i), aPrecision) ) { - SetPickedIndex(-i); - return Standard_True; - } else if ( (i < myX.Length() ) && - SRX >= myX(i)-aPrecision && - SRX <= myX(i)+aPrecision && - SRY >= myY(i)-aPrecision && - SRY <= myY(i)+aPrecision ) { - SetPickedIndex(i); - return Standard_True; - } - } -#else - - for ( i=1; i<=myX.Length(); i++) { - if (SRX >= myX(i)-aPrecision && - SRX <= myX(i)+aPrecision && - SRY >= myY(i)-aPrecision && - SRY <= myY(i)+aPrecision) { - myPickedIndex = i; - return Standard_True; - } - } - -#endif - - TShort_Array1OfShortReal arr1X( 1, myX.Length() ); - TShort_Array1OfShortReal arr1Y( 1, myY.Length() ); - for ( i = 1; i < myX.Length(); i++ ) { - arr1X.SetValue( i, myX(i) ); - arr1Y.SetValue( i, myY(i) ); - } - - if ( IsIn( SRX, SRY, arr1X, arr1Y, aPrecision ) ) { -#ifdef G002 - SetPickedIndex(0); -#else - myPickedIndex = 0; -#endif - return Standard_True; - } - - return Standard_False; - } //end if it's in MinMax - return Standard_False; -} - -Standard_Boolean Graphic2d_SetOfMarkers::Pick( const Standard_ShortReal X1, - const Standard_ShortReal Y1, - const Standard_ShortReal X2, - const Standard_ShortReal Y2, - const Handle(Graphic2d_Drawer)& drawer, - const Graphic2d_PickMode pMode ) -{ -#ifdef OCC402 - mySuppressHigh = Standard_False; - Standard_ShortReal minX = Min( X2, X1 ), - minY = Min( Y2, Y1 ), - maxX = Max( X2, X1 ), - maxY = Max( Y2, Y1 ); - - - // no check for transformation... - // pick mode - INCLUDE only. - - switch( pMode ) { - - case Graphic2d_PM_INCLUDE : { - - TColStd_MapOfInteger toHighlight; - - for (Standard_Integer i=1; i<=myX.Length(); i++) - if ( myX(i) >= minX && myX(i) <= maxX && - myY(i) >= minY && myY(i) <= maxY ) { - - if ( myMapOfSelected.Extent() && myMapOfSelected.Contains( i ) ) - continue; - if ( myPickedIndices.Contains( i ) ) - myPickedIndices.Remove( i ); - toHighlight.Add( i ); - } - - if ( myPickedIndices.Extent() && drawer->IsWindowDriver() ) { - Handle(Aspect_WindowDriver) theDriver = drawer->WindowDriver(); - theDriver->BeginDraw( Standard_True ); - drawer->SetOverride( Standard_True ); - drawer->SetOverrideColor( ColorIndex() ); - DrawPickedElements( drawer ); - drawer->SetOverride( Standard_False ); - theDriver->EndDraw(); - } - - myPickedIndices = toHighlight; - - if ( myPickedIndices.Extent() ) - return Standard_True; - break; - } - } -#endif - return Standard_False; -} - - -Standard_Boolean Graphic2d_SetOfMarkers -::PickByCircle( const Standard_ShortReal x, - const Standard_ShortReal y, - const Standard_ShortReal radius, - const Handle(Graphic2d_Drawer)& drawer, - const Graphic2d_PickMode pMode ) -{ -#ifdef OCC402 - - mySuppressHigh = Standard_True; - myPickedIndices.Clear(); - - // no check for transformation... - // pick mode - INCLUDE only. - - switch( pMode ) - { - - case Graphic2d_PM_INCLUDE : { - - Standard_Real xdist, ydist; - Standard_Real rad; - for (Standard_Integer i=1; i<=myX.Length(); i++) { - xdist = Abs( myX(i) - x ); - ydist = Abs( myY(i) - y ); - rad = radius - myScaledWidth / 2; - if ( xdist <= rad && ydist <= rad ) - myPickedIndices.Add( i ); - } - - if ( myPickedIndices.Extent() ) - return Standard_True; - break; - } - } -#endif - return Standard_False; -} - - -void Graphic2d_SetOfMarkers::Save(Aspect_FStream& aFStream) const -{ -} - -//SAV -void Graphic2d_SetOfMarkers -::DrawPickedElements( const Handle(Graphic2d_Drawer)& aDrawer ) -{ -#ifdef OCC402 - if ( !mySuppressHigh ) { - Standard_Integer length = myPickedIndices.Extent(); - if ( length ) { - - if ( myHLimit > 0 && length > myHLimit ) - length = myHLimit; - - Handle(TShort_HArray1OfShortReal) x = - new TShort_HArray1OfShortReal( 1, length ); - Handle(TShort_HArray1OfShortReal) y = - new TShort_HArray1OfShortReal( 1, length ); - - TColStd_MapIteratorOfMapOfInteger it( myPickedIndices ); - for ( Standard_Integer i = 1; i <= length; it.Next(), i++ ) { - x->SetValue( i, myX( it.Key() ) ); - y->SetValue( i, myY( it.Key() ) ); - } - - DrawElements( aDrawer, x, y ); - } - } -#endif -} - -//SAV -void Graphic2d_SetOfMarkers -::DrawSelectedElements( const Handle(Graphic2d_Drawer)& aDrawer ) -{ -#ifdef OCC402 - Standard_Integer length = myMapOfSelected.Extent(); - if ( length ) { - Handle(TShort_HArray1OfShortReal) x = - new TShort_HArray1OfShortReal( 1, length ); - Handle(TShort_HArray1OfShortReal) y = - new TShort_HArray1OfShortReal( 1, length ); - TColStd_MapIteratorOfMapOfInteger it( myMapOfSelected ); - Standard_Integer index = 1; - for (; it.More(); it.Next(), index++ ) { - x->SetValue( index, myX( it.Key() ) ); - y->SetValue( index, myY( it.Key() ) ); - } - - DrawElements( aDrawer, x, y ); - //myPickedIndices.Clear(); - } -#endif -} - -//SAV -void Graphic2d_SetOfMarkers -::DrawElements( const Handle(Graphic2d_Drawer)& aDrawer, - const Handle(TShort_HArray1OfShortReal)& x, - const Handle(TShort_HArray1OfShortReal)& y ) -{ -#ifdef OCC402 - DrawMarkerAttrib(aDrawer); - - Standard_Integer type = myType( 1 ); - Standard_ShortReal width = myWidth( 1 ), - height = myHeight( 1 ), - angle = myAngle( 1 ); - aDrawer->MapMarkersFromTo( type, x, y, width, height, angle, 0); -#endif -} - -//SAV -Standard_Boolean Graphic2d_SetOfMarkers::SetElementsSelected() -{ -#ifdef OCC402 - if ( myPickedIndices.Extent() ) { - myMapOfSelected.Clear(); - myMapOfSelected = myPickedIndices; - //myPickedIndices.Clear(); - } -#endif - return Standard_True; -} - -//SAV -Standard_Boolean Graphic2d_SetOfMarkers::HasSelectedElements() -{ -#ifdef OCC402 - return (myMapOfSelected.Extent() > 0); -#endif - return Standard_False; -} - -//SAV -void Graphic2d_SetOfMarkers::ClearSelectedElements() -{ -#ifdef OCC402 - myMapOfSelected.Clear(); -#endif -} - - -//SAV -const TColStd_MapOfInteger& Graphic2d_SetOfMarkers::GetSelectedElements() const -{ - return myMapOfSelected; -} - -//SAV -void Graphic2d_SetOfMarkers::AddOrRemoveSelected(const Standard_Integer index) -{ -#ifdef OCC402 - if ( myMapOfSelected.Contains( index ) ) - myMapOfSelected.Remove( index ); - else - myMapOfSelected.Add( index ); -#endif -} - -//SAV -void Graphic2d_SetOfMarkers::SetHighlightedLimit(const Standard_Integer number) -{ -#ifdef OCC402 - if ( number > 0 ) - myHLimit = number; -#endif -} - -void Graphic2d_SetOfMarkers::SetScaledWidth( const Standard_ShortReal width ) -{ -#ifdef OCC402 - myScaledWidth = width; -#endif -} diff --git a/src/Graphic2d/Graphic2d_SetOfPolylines.cdl b/src/Graphic2d/Graphic2d_SetOfPolylines.cdl deleted file mode 100755 index 2c86674f0a..0000000000 --- a/src/Graphic2d/Graphic2d_SetOfPolylines.cdl +++ /dev/null @@ -1,131 +0,0 @@ --- Created on: 1993-04-13 --- Created by: Gerard GRAS --- Copyright (c) 1993-1999 Matra Datavision --- Copyright (c) 1999-2012 OPEN CASCADE SAS --- --- The content of this file is subject to the Open CASCADE Technology Public --- License Version 6.5 (the "License"). You may not use the content of this file --- except in compliance with the License. Please obtain a copy of the License --- at http://www.opencascade.org and read it completely before using this file. --- --- The Initial Developer of the Original Code is Open CASCADE S.A.S., having its --- main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. --- --- The Original Code and all software distributed under the License is --- distributed on an "AS IS" basis, without warranty of any kind, and the --- Initial Developer hereby disclaims all such warranties, including without --- limitation, any warranties of merchantability, fitness for a particular --- purpose or non-infringement. Please see the License for the specific terms --- and conditions governing the rights and limitations under the License. - - - - -class SetOfPolylines from Graphic2d inherits Line from Graphic2d - - ---Version: - - ---Purpose: The primitive SetOfPolylines - -- Warning: This primitive must be use as possible for to insure - -- that the sets is drawn correctly when the line type or - -- line width attrib is not SOLID and 1 pixel for the set. - -- NOTE: than the method PickedIndex() permits to known - -- the last picked polyline and segment in the set. - ---References: - -uses - Drawer from Graphic2d, - GraphicObject from Graphic2d, - Length from Quantity, - SequenceOfPolyline from Graphic2d, - FStream from Aspect, - IFStream from Aspect - - - -raises - OutOfRange from Standard - -is - ------------------------- - -- Category: Constructors - ------------------------- - - Create (aGraphicObject: GraphicObject from Graphic2d) - returns mutable SetOfPolylines from Graphic2d; - ---Level: Public - ---Purpose: Creates an empty set of polylines in the graphic - -- object . - ---Category: Constructors - - Add(me : mutable; X, Y: Length from Quantity; - NewPolyline: Boolean from Standard = Standard_False); - ---Level: Public - ---Purpose: Add a point in the current polyline of the set - -- or creates a new one when flag is TRUE. - ---Category: Update method - - Add(me : mutable; X1, Y1, X2, Y2: Length from Quantity); - ---Level: Public - ---Purpose: Add a segment in the set to one of polyline - -- which has the last point identical to one of the segment - -- or creates a new polyline in the sets with the 2 segment points. - -- The first point is , . - -- The second point is , . - ---Category: Update method - - Length(me) returns Integer from Standard; - ---Level: Public - ---Purpose: Returns the number of polylines in the set. - ---Category: Inquiry method - - Length(me; aPrank: Integer from Standard) - returns Integer from Standard - ---Level: Public - ---Purpose: Returns the number of points of the polylines - -- of rank . - -- Trigger: Raises OutOfRange if is <1 or >Length() - raises OutOfRange from Standard; - ---Category: Inquiry method - - Values( me; aPrank : Integer from Standard; - aVrank : Integer from Standard; - X,Y : out Length from Quantity) - ---Level: Public - ---Purpose: Returns the point of rank - -- from the polyline of rank . - -- Trigger: Raises OutOfRange if is <1 or >Length() - -- or if is <1 or >Length() - raises OutOfRange from Standard; - ---Category: Inquiry method - - -------------------------- - -- Category: Draw and Pick - -------------------------- - - Draw (me : mutable; aDrawer: Drawer from Graphic2d) - is static protected; - ---Level: Internal - ---Purpose: Draws the set of polylines . - - Pick (me : mutable; X, Y: ShortReal from Standard; - aPrecision: ShortReal from Standard; - aDrawer: Drawer from Graphic2d) - returns Boolean from Standard - is static protected; - ---Level: Internal - ---Purpose: Returns Standard_True if one point of the set - -- is picked, Standard_False if not. - -- Warning: The PickIndex() method returns the rank of the picked - -- polyline point if any under the format : - -- ( << 16) | . - - ---------------------------------------------------------------------- - - Save( me; aFStream: in out FStream from Aspect ) is virtual; --- Retrieve( me; aIFStream: in out IFStream from AIS2D ) is virtual; - -fields - myPolylines: SequenceOfPolyline from Graphic2d; - -end SetOfPolylines from Graphic2d; diff --git a/src/Graphic2d/Graphic2d_SetOfPolylines.cxx b/src/Graphic2d/Graphic2d_SetOfPolylines.cxx deleted file mode 100755 index a8156bc1ca..0000000000 --- a/src/Graphic2d/Graphic2d_SetOfPolylines.cxx +++ /dev/null @@ -1,352 +0,0 @@ -// Copyright (c) 1998-1999 Matra Datavision -// Copyright (c) 1999-2012 OPEN CASCADE SAS -// -// The content of this file is subject to the Open CASCADE Technology Public -// License Version 6.5 (the "License"). You may not use the content of this file -// except in compliance with the License. Please obtain a copy of the License -// at http://www.opencascade.org and read it completely before using this file. -// -// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its -// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. -// -// The Original Code and all software distributed under the License is -// distributed on an "AS IS" basis, without warranty of any kind, and the -// Initial Developer hereby disclaims all such warranties, including without -// limitation, any warranties of merchantability, fitness for a particular -// purpose or non-infringement. Please see the License for the specific terms -// and conditions governing the rights and limitations under the License. - -/*===================================================================== - - FONCTION : - ---------- - Classe Graphic2d_SetOfPolylines - - TEST : - ------ - - Voir TestG2D/TestG21 - - - -=====================================================================*/ - -// PRO13369 //GG_280498 -// MapPolylineFromTo() should be called with exact number of points - -#define G002 //GG_140400 Use SetPickedIndex method - -#include -#include -#include - -Graphic2d_SetOfPolylines::Graphic2d_SetOfPolylines ( - const Handle(Graphic2d_GraphicObject)& aGraphicObject) - - : Graphic2d_Line (aGraphicObject) { - -} - -void Graphic2d_SetOfPolylines::Add( const Standard_Real X, - const Standard_Real Y, - const Standard_Boolean NewPolyline ) { - Standard_Integer n = myPolylines.Length(); - Standard_ShortReal x = Standard_ShortReal( X ), - y = Standard_ShortReal( Y ); - Graphic2d_Vertex V( x, y ); - - if( NewPolyline || (n == 0) ) { - Handle(Graphic2d_HSequenceOfVertex) P = - new Graphic2d_HSequenceOfVertex(); - P->Append(V); - myPolylines.Append(P); - } else { - Handle(Graphic2d_HSequenceOfVertex) P = myPolylines.Last(); - if( !V.IsEqual(P->Value(P->Length())) ) { - P->Append(V); - } - } - - myMinX = Min(myMinX,x); - myMinY = Min(myMinY,y); - myMaxX = Max(myMaxX,x); - myMaxY = Max(myMaxY,y); -} - -void Graphic2d_SetOfPolylines::Add( const Standard_Real X1, - const Standard_Real Y1, - const Standard_Real X2, - const Standard_Real Y2 ) { - - Standard_ShortReal x1 = Standard_ShortReal( X1 ), - y1 = Standard_ShortReal( Y1 ), - x2 = Standard_ShortReal( X2 ), - y2 = Standard_ShortReal( Y2 ); - Graphic2d_Vertex V1( x1, y1 ), - V2( x2, y2 ); - Standard_Integer np = myPolylines.Length(); - - if( !V1.IsEqual(V2) ) { - if( np == 0 ) { - Handle(Graphic2d_HSequenceOfVertex) P = - new Graphic2d_HSequenceOfVertex(); - if( (x1 > x2) || (y1 > y2) ) { - V1.SetCoord(x2,y2); // seg orientation - V2.SetCoord(x1,y1); - } - P->Append(V1); P->Append(V2); - myPolylines.Append(P); - } else { // Try to build a polyline - // Warning,take an aspirine before continue reading... - Handle(Graphic2d_HSequenceOfVertex) P,PP; - Standard_Integer ip,ipp,lv; - for( ip=np ; ip>0 ; ip-- ) { - P = myPolylines.Value(ip);//ref line to check - lv = P->Length(); //number of vertex in the ref line - if( V1.IsEqual(P->Value(lv)) ) { - //first vertex of segment is the same that the last vertex of the - //ref line - if( ip > 1 ) { //Try to concatenate ref line with others - for( ipp=1 ; ippValue(1)) ) { - PP->Prepend(P); // Move the ref line before this - myPolylines.Remove(ip); // and destroy the ref line - ip = -1; break; - } else if( V2.IsEqual(PP->Value(PP->Length())) ) { - P->Reverse(); - PP->Append(P); // Reverse & Move the ref line after this - myPolylines.Remove(ip); // and destroy the ref line - ip = -1; break; - } - } - } - if( ip > 0 ) { - P->Append(V2); // Append new vertex to ref line - ip = -1; - } - } else if( V2.IsEqual(P->Value(lv)) ) { - //second vertex of segment is the same that the last vertex of the - //ref line - if( ip > 1 ) { //Try to concatenate ref line with others - for( ipp=1 ; ippValue(1)) ) { - PP->Prepend(P); // Move the ref line before this - myPolylines.Remove(ip); // and destroy the ref line - ip = -1; break; - } else if( V1.IsEqual(PP->Value(PP->Length())) ) { - P->Reverse(); - PP->Append(P); // Reverse & Move the ref line after this - myPolylines.Remove(ip); // and destroy the ref line - ip = -1; break; - } - } - } - if( ip > 0 ) { - P->Append(V1); // Append new vertex to ref line - ip = -1; - } - } else if( V1.IsEqual(P->Value(1)) ) { - //first vertex of segment is the same that the first vertex of the - //ref line - if( ip > 1 ) { //Try to concatenate ref line with others - for( ipp=1 ; ippValue(PP->Length())) ) { - P->Prepend(PP); // Move this line before the ref line - myPolylines.Remove(ipp); // and destroy this line - ip = -1; break; - } else if( V2.IsEqual(PP->Value(1)) ) { - PP->Reverse(); - P->Prepend(PP); // Reverse & Move this line before the ref line - myPolylines.Remove(ipp); // and destroy this line - ip = -1; break; - } - } - } - if( ip > 0 ) { - P->Prepend(V2); // Prepend new vertex to ref line - ip = -1; - } - } else if( V2.IsEqual(P->Value(1)) ) { - //second vertex of segment is the same that the first vertex of the - //ref line - if( ip > 1 ) { //Try to concatenate ref line with others - for( ipp=1 ; ippValue(PP->Length())) ) { - P->Prepend(PP); // Move this line before the ref line - myPolylines.Remove(ipp); // and destroy this line - ip = -1; break; - } else if( V1.IsEqual(PP->Value(1)) ) { - PP->Reverse(); - P->Prepend(PP); // Reverse & Move this line before the ref line - myPolylines.Remove(ipp); // and destroy this line - ip = -1; break; - } - } - } - if( ip > 0 ) { - P->Prepend(V1); // Append new vertex to ref line - ip = -1; - } - } - } - //create new line - if( ip >= 0 ) { - Handle(Graphic2d_HSequenceOfVertex) P = - new Graphic2d_HSequenceOfVertex(); - if( (x1 > x2) || (y1 > y2) ) { - V1.SetCoord(x2,y2); // seg orientation - V2.SetCoord(x1,y1); - } - P->Append(V1); - P->Append(V2); - myPolylines.Append(P); - } - } - - myMinX = Min(myMinX,Min(x1,x2)); - myMinY = Min(myMinY,Min(y1,y2)); - myMaxX = Max(myMaxX,Max(x1,x2)); - myMaxY = Max(myMaxY,Max(y1,y2)); - } -} - -Standard_Integer Graphic2d_SetOfPolylines::Length () const { - return myPolylines.Length(); -} - -Standard_Integer Graphic2d_SetOfPolylines::Length (const Standard_Integer aPrank) const { - if( aPrank < 1 || aPrank > Length() ) - Standard_OutOfRange::Raise - ("the polyline rank is out of bounds in the set"); - return myPolylines.Value(aPrank)->Length(); -} - -void Graphic2d_SetOfPolylines::Values( const Standard_Integer aPrank, - const Standard_Integer aVrank, - Standard_Real &X, - Standard_Real &Y ) const { - - if( aPrank < 1 || aPrank > Length() ) - Standard_OutOfRange::Raise - ("the polyline rank is out of bounds in the set"); - if( aVrank < 1 || aVrank > Length(aPrank) ) - Standard_OutOfRange::Raise - ("the point rank is out of bounds in the polyline"); - - Graphic2d_Vertex V = myPolylines.Value(aPrank)->Value(aVrank); - X = V.X(); Y = V.Y(); -} - -void Graphic2d_SetOfPolylines::Draw (const Handle(Graphic2d_Drawer)& aDrawer) { -Standard_Integer np = myPolylines.Length(); -Standard_Boolean IsIn = Standard_False,transform = Standard_False; - - if( np <= 0 ) return; - - if (! myGOPtr->IsTransformed ()) - IsIn = aDrawer->IsIn (myMinX,myMaxX,myMinY,myMaxY); - else { - transform = Standard_True; - Standard_ShortReal minx, miny, maxx, maxy; - MinMax(minx,maxx,miny,maxy); - IsIn = aDrawer->IsIn (minx,maxx,miny,maxy); - } - - if ( IsIn ) { - static gp_GTrsf2d theTrsf; - Handle(Graphic2d_HSequenceOfVertex) P; - Standard_Real A, B; - Standard_ShortReal x1,y1,x2,y2; - Standard_Integer ip,lp,iv; - DrawLineAttrib(aDrawer); - if( transform ) theTrsf = myGOPtr->Transform (); - for( ip=1 ; ip<=np ; ip++ ) { - P = myPolylines.Value(ip); - lp = P->Length(); - if( lp > 2 ) { - P->Value(1).Coord(A,B); - if( transform ) theTrsf.Transforms(A,B); - x1 = Standard_ShortReal( A ); - y1 = Standard_ShortReal( B ); - aDrawer->MapPolylineFromTo(x1,y1,lp); - for( iv=2 ; ivValue(iv).Coord(A,B); - if( transform ) theTrsf.Transforms(A,B); - x1 = Standard_ShortReal( A ); - y1 = Standard_ShortReal( B ); - aDrawer->MapPolylineFromTo(x1,y1,0); - } - P->Value(lp).Coord(A,B); - if( transform ) theTrsf.Transforms(A,B); - x1 = Standard_ShortReal( A ); - y1 = Standard_ShortReal( B ); - aDrawer->MapPolylineFromTo(x1,y1,-1); - } else if( lp > 1 ) { - P->Value(1).Coord(A,B); - if( transform ) theTrsf.Transforms(A,B); - x1 = Standard_ShortReal( A ); - y1 = Standard_ShortReal( B ); - P->Value(2).Coord(A,B); - if( transform ) theTrsf.Transforms(A,B); - x2 = Standard_ShortReal( A ); - y2 = Standard_ShortReal( B ); - aDrawer->MapSegmentFromTo(x1,y1,x2,y2); - } - } - } -} - -Standard_Boolean Graphic2d_SetOfPolylines::Pick (const Standard_ShortReal X, - const Standard_ShortReal Y, - const Standard_ShortReal aPrecision, - const Handle(Graphic2d_Drawer)& aDrawer) -{ -Standard_Integer np = myPolylines.Length(); -Standard_ShortReal SRX = X, SRY = Y; - - if ( (np > 0) && IsInMinMax (X, Y, aPrecision)) { - if (myGOPtr->IsTransformed ()) { - gp_GTrsf2d theTrsf((myGOPtr->Transform ()).Inverted ()); - Standard_Real RX = Standard_Real (SRX), RY = Standard_Real (SRY); - theTrsf.Transforms (RX, RY); - SRX = Standard_ShortReal (RX); SRY = Standard_ShortReal (RY); - } - - Handle(Graphic2d_HSequenceOfVertex) P; - Standard_Integer ip,iv=0,lp; - Standard_ShortReal x1,y1,x2,y2; - Standard_Real A,B; - for( ip=1 ; ip<=np ; ip++ ) { - P = myPolylines.Value(ip); - lp = P->Length(); - if( lp > 1 ) { - for( iv=1 ; ivValue(iv).Coord(A,B); - x1 = Standard_ShortReal( A ); - y1 = Standard_ShortReal( B ); - P->Value(iv+1).Coord(A,B); - x2 = Standard_ShortReal( A ); - y2 = Standard_ShortReal( B ); - if (IsOn (SRX, SRY, x1, y1, x2, y2, aPrecision) ) { -#ifdef G002 - SetPickedIndex((ip << 16) | iv); -#else - myPickedIndex = (ip << 16) | iv; -#endif - return Standard_True; - } - } - } - } - return Standard_False; - } - return Standard_False; -} - -void Graphic2d_SetOfPolylines::Save(Aspect_FStream& aFStream) const -{ -} diff --git a/src/Graphic2d/Graphic2d_SetOfSegments.cdl b/src/Graphic2d/Graphic2d_SetOfSegments.cdl deleted file mode 100755 index 541c71edf7..0000000000 --- a/src/Graphic2d/Graphic2d_SetOfSegments.cdl +++ /dev/null @@ -1,132 +0,0 @@ --- Created on: 1993-04-13 --- Created by: Gerard GRAS --- Copyright (c) 1993-1999 Matra Datavision --- Copyright (c) 1999-2012 OPEN CASCADE SAS --- --- The content of this file is subject to the Open CASCADE Technology Public --- License Version 6.5 (the "License"). You may not use the content of this file --- except in compliance with the License. Please obtain a copy of the License --- at http://www.opencascade.org and read it completely before using this file. --- --- The Initial Developer of the Original Code is Open CASCADE S.A.S., having its --- main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. --- --- The Original Code and all software distributed under the License is --- distributed on an "AS IS" basis, without warranty of any kind, and the --- Initial Developer hereby disclaims all such warranties, including without --- limitation, any warranties of merchantability, fitness for a particular --- purpose or non-infringement. Please see the License for the specific terms --- and conditions governing the rights and limitations under the License. - - - - -class SetOfSegments from Graphic2d inherits Line from Graphic2d - - ---Version: - - ---Purpose: The primitive SetOfSegments - -- Warning: This primitive must be use as possible for performance - -- improvment but is drawn with a global line attributes - -- for all the set. - -- But when the set contains a lot of contigous segments - -- with a line attrib different to the default,it's - -- more preferable to use a SetOfPolylines for to insure - -- a better quality. - -- NOTE: than the method PickedIndex() permits to known - -- the last picked segment in the set. - ---References: - -uses - Drawer from Graphic2d, - GraphicObject from Graphic2d, - Length from Quantity, - SequenceOfShortReal from TShort, - FStream from Aspect, - IFStream from Aspect - -raises - SegmentDefinitionError from Graphic2d, - OutOfRange from Standard - -is - ------------------------- - -- Category: Constructors - ------------------------- - - Create (aGraphicObject: GraphicObject from Graphic2d) - returns mutable SetOfSegments from Graphic2d; - ---Level: Public - ---Purpose: Creates an empty set of segments in the graphic - -- object . - ---Category: Constructors - - Add(me : mutable; X1, Y1, X2, Y2: Length from Quantity) - ---Level: Public - ---Purpose: Add a segment in the set - -- The first point is , . - -- The second point is , . - -- Trigger: Raises SegmentDefinitionError if the - -- first point and the second point are identical. - raises SegmentDefinitionError from Graphic2d; - ---Category: Update method - - Length(me) returns Integer from Standard; - ---Level: Public - ---Purpose: Returns the number of segments in the set. - ---Category: Inquiry method - - Values( me; - aRank: Integer from Standard; - X1, Y1, X2, Y2: out Length from Quantity ) - ---Level: Public - ---Purpose: Returns the segment of rank from the set. - -- Trigger: Raises OutOfRange if is <1 or >Length() - raises OutOfRange from Standard; - ---Category: Inquiry method - - -------------------------- - -- Category: Draw and Pick - -------------------------- - - Draw (me : mutable; aDrawer: Drawer from Graphic2d) - is static protected; - ---Level: Internal - ---Purpose: Draws the set of segments . - - DrawElement( me : mutable; aDrawer: Drawer from Graphic2d; - anIndex: Integer from Standard) - is redefined protected; - ---Level: Internal - ---Purpose: Draws element of the set . - - DrawVertex( me : mutable; aDrawer: Drawer from Graphic2d; - anIndex: Integer from Standard) - is redefined protected; - ---Level: Internal - ---Purpose: Draws vertex of the set . - - Pick (me : mutable; X, Y: ShortReal from Standard; - aPrecision: ShortReal from Standard; - aDrawer: Drawer from Graphic2d) - returns Boolean from Standard - is static protected; - ---Level: Internal - ---Purpose: Returns Standard_True if one segment of the set - -- is picked, Standard_False if not. - -- Warning: The PickIndex() method returns the rank of the picked - -- segment if any. - - ---------------------------------------------------------------------- - - Save( me; aFStream: in out FStream from Aspect ) is virtual; --- Retrieve( me; aIFStream: in out IFStream from AIS2D ) is virtual; - -fields - - myX1: SequenceOfShortReal from TShort; - myY1: SequenceOfShortReal from TShort; - myX2: SequenceOfShortReal from TShort; - myY2: SequenceOfShortReal from TShort; - -end SetOfSegments from Graphic2d; diff --git a/src/Graphic2d/Graphic2d_SetOfSegments.cxx b/src/Graphic2d/Graphic2d_SetOfSegments.cxx deleted file mode 100755 index a512ef1bc2..0000000000 --- a/src/Graphic2d/Graphic2d_SetOfSegments.cxx +++ /dev/null @@ -1,326 +0,0 @@ -// Copyright (c) 1995-1999 Matra Datavision -// Copyright (c) 1999-2012 OPEN CASCADE SAS -// -// The content of this file is subject to the Open CASCADE Technology Public -// License Version 6.5 (the "License"). You may not use the content of this file -// except in compliance with the License. Please obtain a copy of the License -// at http://www.opencascade.org and read it completely before using this file. -// -// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its -// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. -// -// The Original Code and all software distributed under the License is -// distributed on an "AS IS" basis, without warranty of any kind, and the -// Initial Developer hereby disclaims all such warranties, including without -// limitation, any warranties of merchantability, fitness for a particular -// purpose or non-infringement. Please see the License for the specific terms -// and conditions governing the rights and limitations under the License. - -/*===================================================================== - - FONCTION : - ---------- - Classe Graphic2d_SetOfSegments - - TEST : - ------ - - Voir TestG2D/TestG21 - - REMARQUES: - ---------- - - HISTORIQUE DES MODIFICATIONS : - -------------------------------- - - 27-01-98 : GG ; OPTIMISATION LOADER - Transformer les variables static globales en static - locales. - -=======================================================================*/ - -#define G002 //GG_140400 Use SetPickedIndex method. - // Add new DrawElement(), DrawVertex() methods - -#define VERTEXMARKER 2 -#define DEFAULTMARKERSIZE 3.0 - - -#include - -#include - -Graphic2d_SetOfSegments::Graphic2d_SetOfSegments ( - const Handle(Graphic2d_GraphicObject)& aGraphicObject) - - : Graphic2d_Line (aGraphicObject) { - -} - -void Graphic2d_SetOfSegments::Add ( - const Standard_Real X1, const Standard_Real Y1, - const Standard_Real X2, const Standard_Real Y2) -{ -Standard_ShortReal x1 = Standard_ShortReal( X1 ); -Standard_ShortReal y1 = Standard_ShortReal( Y1 ); -Standard_ShortReal x2 = Standard_ShortReal( X2 ); -Standard_ShortReal y2 = Standard_ShortReal( Y2 ); - - if ((x1 == x2) && (y1 == y2)) return; - - myMinX = Min(myMinX,Min(x1,x2)); - myMinY = Min(myMinY,Min(y1,y2)); - myMaxX = Max(myMaxX,Max(x1,x2)); - myMaxY = Max(myMaxY,Max(y1,y2)); - - myX1.Append(x1); - myY1.Append(y1); - myX2.Append(x2); - myY2.Append(y2); - -} - -Standard_Integer Graphic2d_SetOfSegments::Length () const { - return myX1.Length(); -} - -void Graphic2d_SetOfSegments::Values (const Standard_Integer aRank, - Standard_Real &X1,Standard_Real &Y1, - Standard_Real &X2,Standard_Real &Y2) const { - - if( aRank < 1 || aRank > myX1.Length() ) - Standard_OutOfRange::Raise - ("the segment rank is out of bounds in the set"); - - X1 = myX1(aRank); - Y1 = myY1(aRank); - X2 = myX2(aRank); - Y2 = myY2(aRank); - -} - -void Graphic2d_SetOfSegments::Draw (const Handle(Graphic2d_Drawer)& aDrawer) { - Standard_Integer i,ns = Length(),bufferize = 0; - Standard_Boolean IsIn = Standard_False,transform = Standard_False; - - if( ns <= 0 ) return; - - if (! myGOPtr->IsTransformed ()) - IsIn = aDrawer->IsIn (myMinX,myMaxX,myMinY,myMaxY); - else { - transform = Standard_True; - Standard_ShortReal minx, miny, maxx, maxy; - MinMax(minx,maxx,miny,maxy); - IsIn = aDrawer->IsIn (minx,maxx,miny,maxy); - } - - if ( IsIn ) { - static gp_GTrsf2d theTrsf; - DrawLineAttrib(aDrawer); - if( transform ) theTrsf = myGOPtr->Transform (); - - if( ns > 2 ) bufferize = 1; - Standard_Real A,B; - Standard_ShortReal x1,y1,x2,y2; - A = myX1(1); B = myY1(1); - if( transform ) theTrsf.Transforms(A,B); - x1 = Standard_ShortReal( A ); - y1 = Standard_ShortReal( B ); - A = myX2(1); B = myY2(1); - if( transform ) theTrsf.Transforms(A,B); - x2 = Standard_ShortReal( A ); - y2 = Standard_ShortReal( B ); - aDrawer->MapSegmentFromTo(x1,y1,x2,y2,bufferize); - for( i=2 ; iMapSegmentFromTo(x1,y1,x2,y2,0); - } - A = myX1(ns); B = myY1(ns); - if( transform ) theTrsf.Transforms(A,B); - x1 = Standard_ShortReal( A ); - y1 = Standard_ShortReal( B ); - A = myX2(ns); B = myY2(ns); - if( transform ) theTrsf.Transforms(A,B); - x2 = Standard_ShortReal( A ); - y2 = Standard_ShortReal( B ); - aDrawer->MapSegmentFromTo(x1,y1,x2,y2,-bufferize); - } - myNumOfElem = ns; - myNumOfVert = 2*ns; -} - -#ifdef G002 - -void Graphic2d_SetOfSegments::DrawElement( const Handle(Graphic2d_Drawer)& aDrawer, - const Standard_Integer anIndex) { - Standard_Integer ns = Length(),bufferize = 0; - Standard_Boolean IsIn = Standard_False,transform = Standard_False; - - if ( ns <= 0 ) return; - - if (! myGOPtr->IsTransformed ()) - IsIn = aDrawer->IsIn (myMinX,myMaxX,myMinY,myMaxY); - else { - transform = Standard_True; - Standard_ShortReal minx, miny, maxx, maxy; - MinMax(minx,maxx,miny,maxy); - IsIn = aDrawer->IsIn (minx,maxx,miny,maxy); - } - - if ( IsIn ) { - if ( anIndex > 0 && anIndex <= ns ) { //Draw element - static gp_GTrsf2d theTrsf; - DrawLineAttrib(aDrawer); - if( transform ) theTrsf = myGOPtr->Transform (); - - if( ns > 2 ) bufferize = 1; - Standard_Real A,B; - Standard_ShortReal x1,y1,x2,y2; - if ( anIndex == 1) { - A = myX1(1); B = myY1(1); - if( transform ) theTrsf.Transforms(A,B); - x1 = Standard_ShortReal( A ); - y1 = Standard_ShortReal( B ); - A = myX2(1); B = myY2(1); - if( transform ) theTrsf.Transforms(A,B); - x2 = Standard_ShortReal( A ); - y2 = Standard_ShortReal( B ); - aDrawer->MapSegmentFromTo(x1,y1,x2,y2,bufferize); - } else if ( anIndex == ns ) { - A = myX1(ns); B = myY1(ns); - if( transform ) theTrsf.Transforms(A,B); - x1 = Standard_ShortReal( A ); - y1 = Standard_ShortReal( B ); - A = myX2(ns); B = myY2(ns); - if( transform ) theTrsf.Transforms(A,B); - x2 = Standard_ShortReal( A ); - y2 = Standard_ShortReal( B ); - aDrawer->MapSegmentFromTo(x1,y1,x2,y2,-bufferize); - } else { - A = myX1(anIndex); B = myY1(anIndex); - if( transform ) theTrsf.Transforms(A,B); - x1 = Standard_ShortReal( A ); - y1 = Standard_ShortReal( B ); - A = myX2(anIndex); B = myY2(anIndex); - if( transform ) theTrsf.Transforms(A,B); - x2 = Standard_ShortReal( A ); - y2 = Standard_ShortReal( B ); - aDrawer->MapSegmentFromTo(x1,y1,x2,y2,0); - } - } - } - -} - -void Graphic2d_SetOfSegments::DrawVertex( const Handle(Graphic2d_Drawer)& aDrawer, - const Standard_Integer anIndex) { - Standard_Boolean IsIn = Standard_False; - - if (! myGOPtr->IsTransformed ()) - IsIn = aDrawer->IsIn (myMinX,myMaxX,myMinY,myMaxY); - else { - Standard_ShortReal minx, miny, maxx, maxy; - MinMax(minx,maxx,miny,maxy); - IsIn = aDrawer->IsIn (minx,maxx,miny,maxy); - } - - Standard_Integer nbpoints = myX1.Length (); - if (IsIn ) { - if( anIndex > 0 && anIndex <= nbpoints ) { - Standard_ShortReal X,Y; - DrawMarkerAttrib (aDrawer); - if (myGOPtr->IsTransformed ()) { - gp_GTrsf2d aTrsf = myGOPtr->Transform (); - Standard_Real A, B; - A = Standard_Real (myX1(anIndex)); - B = Standard_Real (myY1(anIndex)); - aTrsf.Transforms (A, B); - X = Standard_ShortReal (A); - Y = Standard_ShortReal (B); - } else { - X = myX1(anIndex); - Y = myY1(anIndex); - } - aDrawer->MapMarkerFromTo(VERTEXMARKER,X,Y, - DEFAULTMARKERSIZE,DEFAULTMARKERSIZE,0.0); - } else if ( anIndex > 0 && anIndex > nbpoints && anIndex <= 2*nbpoints) { - Standard_ShortReal X,Y; - DrawMarkerAttrib (aDrawer); - - if (myGOPtr->IsTransformed ()) { - gp_GTrsf2d aTrsf = myGOPtr->Transform (); - Standard_Real A, B; - A = Standard_Real (myX2(anIndex-nbpoints)); - B = Standard_Real (myY2(anIndex-nbpoints)); - aTrsf.Transforms (A, B); - X = Standard_ShortReal (A); - Y = Standard_ShortReal (B); - } else { - X = myX2(anIndex-nbpoints); - Y = myY2(anIndex-nbpoints); - } - aDrawer->MapMarkerFromTo(VERTEXMARKER,X,Y, - DEFAULTMARKERSIZE,DEFAULTMARKERSIZE,0.0); - } - } -} -#endif - -Standard_Boolean Graphic2d_SetOfSegments::Pick (const Standard_ShortReal X, - const Standard_ShortReal Y, - const Standard_ShortReal aPrecision, - const Handle(Graphic2d_Drawer)& /*aDrawer*/) { - - Standard_Integer i,ns = Length(); - Standard_ShortReal SRX = X, SRY = Y; - - if ( (ns > 0) && IsInMinMax (X, Y, aPrecision)) { - if (myGOPtr->IsTransformed ()) { - gp_GTrsf2d aTrsf = (myGOPtr->Transform ()).Inverted (); - Standard_Real RX = Standard_Real (SRX), RY = Standard_Real (SRY); - aTrsf.Transforms (RX, RY); - SRX = Standard_ShortReal (RX); SRY = Standard_ShortReal (RY); - } - -#ifdef G002 - for ( i = 1; i <= myX1.Length(); i++ ) { - if ( Graphic2d_Primitive::IsOn( SRX, SRY, myX1(i), myY1(i), aPrecision) ) { - SetPickedIndex(-i); - return Standard_True; - } else if ( Graphic2d_Primitive::IsOn( SRX, SRY, myX2(i), myY2(i), aPrecision) ) { - SetPickedIndex(-ns-i); - return Standard_True; - } else if (IsOn( SRX, SRY, myX1(i), myY1(i), myX2(i), myY2(i), aPrecision) ) { - SetPickedIndex(i); - return Standard_True; - } - } -#else - - for (i=1; i<=myX1.Length(); i++) { - if (IsOn (SRX, SRY, myX1 (i), myY1 (i), - myX2 (i), myY2 (i), aPrecision) ) { - myPickedIndex = i; - return Standard_True; - } - } - -#endif - - return Standard_False; - } else - return Standard_False; - -} - - -void Graphic2d_SetOfSegments::Save(Aspect_FStream& aFStream) const -{ -} diff --git a/src/Graphic2d/Graphic2d_Text.cdl b/src/Graphic2d/Graphic2d_Text.cdl deleted file mode 100755 index 9f2cbe7787..0000000000 --- a/src/Graphic2d/Graphic2d_Text.cdl +++ /dev/null @@ -1,267 +0,0 @@ --- Created on: 1993-06-22 --- Created by: Jean Louis FRENKEL, Gerard GRAS --- Copyright (c) 1993-1999 Matra Datavision --- Copyright (c) 1999-2012 OPEN CASCADE SAS --- --- The content of this file is subject to the Open CASCADE Technology Public --- License Version 6.5 (the "License"). You may not use the content of this file --- except in compliance with the License. Please obtain a copy of the License --- at http://www.opencascade.org and read it completely before using this file. --- --- The Initial Developer of the Original Code is Open CASCADE S.A.S., having its --- main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. --- --- The Original Code and all software distributed under the License is --- distributed on an "AS IS" basis, without warranty of any kind, and the --- Initial Developer hereby disclaims all such warranties, including without --- limitation, any warranties of merchantability, fitness for a particular --- purpose or non-infringement. Please see the License for the specific terms --- and conditions governing the rights and limitations under the License. - - --- Modified: TCL G002A, 28-11-00, new inquire methods GetText() and GetType() - - -class Text from Graphic2d inherits Primitive from Graphic2d - - ---Version: - - ---Purpose: The primitive Text - - ---Keywords: Primitive, Text - ---Warning: - ---References: - -uses - Drawer from Graphic2d, - GraphicObject from Graphic2d, - TypeOfAlignment from Graphic2d, - PlaneAngle from Quantity, - Length from Quantity, - Factor from Quantity, - ExtendedString from TCollection, - TypeOfText from Aspect, - FStream from Aspect, - IFStream from Aspect - - - -is - ------------------------- - -- Category: Constructors - ------------------------- - - Create (aGraphicObject: GraphicObject from Graphic2d; - aText: ExtendedString from TCollection; - X, Y: Real from Standard; - anAngle: PlaneAngle from Quantity = 0.0; - aType: TypeOfText from Aspect = Aspect_TOT_SOLID; - aScale: Factor from Quantity = 1.0) - returns mutable Text from Graphic2d; - ---Level: Public - ---Purpose: Creates a text in a graphic object - -- The text is . - -- The reference point is , . - -- The orientation angle is . - -- The type of text is and must be one of : - -- Aspect_TOT_SOLID, - -- Aspect_TOT_OUTLINE, - -- The scale factor apply to the original font size, - -- Angles are measured counterclockwise with 0 radian - -- at 3 o'clock. - -- Warning: a text can be orientable,slantable,zoomable or outlinable - -- only when this options are enable regardless of the graphic driver. - -- i.e: Xw driver does not,but Xdps or PS driver does. - ---Category: Constructors - - --------------------------------------------------- - -- Category: Methods to modify the class definition - --------------------------------------------------- - - SetFontIndex (me:mutable; anIndex: Integer from Standard = 0) - is static; - ---Level: Public - ---Purpose: Sets the font index for the text . - -- Warning: Note that the index 0 can be undefined as a FontMapEntry, - -- in this case the default system text font is taken. - - SetSlant (me: mutable; aSlant: PlaneAngle from Quantity = 0.0) - is static; - ---Level: Public - ---Purpose: Sets the slant angle of the text . - - SetZoomable (me: mutable; aFlag: Boolean from Standard = Standard_True) - is static; - ---Level: Public - ---Purpose: The text follows the scale factor of the view - -- if the flag is Standard_True. - ---Category: Zoom management - - SetOffset (me: mutable; aDx: Real from Standard = 0.0; - aDy: Real from Standard = 0.0) - is static; - ---Level: Public - ---Purpose: Sets the Device space offset of the text . - - SetUnderline (me: mutable; - isUnderlined: Boolean from Standard = Standard_False) - is static; - ---Level: Public - ---Purpose: Enable/Disable text underline. - - SetAlignment (me:mutable; anAlignment: TypeOfAlignment from Graphic2d = - Graphic2d_TOA_LEFT) - is static; - ---Level: Public - ---Purpose: Sets the text alignment. - - Fit (me:mutable; aWidth,aHeight: Length from Quantity; - Adjust: Boolean from Standard = Standard_True; - Expand: Boolean from Standard = Standard_True) - returns Boolean from Standard is virtual; - ---Level: Public - ---Purpose: Compute text size depending of a required bounding box, - -- Adjust the text position depending of the text origine - -- and base line if "Adjust" is TRUE, - -- Expand the text when the Width is smaller that the - -- Fit Width if "Expand" is TRUE. - -- and returns Standard_True if the current Driver used is - -- enable to fit the text size. - -- Warning: The fit computation is apply only if the corresponding - -- dimension is > 0. - - Trunc (me:mutable; aWidth: Length from Quantity) - returns Boolean from Standard is virtual; - ---Level: Public - ---Purpose: Trunc the text when the Width of the text is greater - -- that the defined Width Max, - -- and returns Standard_True if the current Driver used is - -- enable to trunc the text size. - - -------------------------- - -- Category: Draw and Pick - -------------------------- - - Draw (me : mutable; aDrawer: Drawer from Graphic2d) - is virtual protected; - ---Level: Internal - ---Purpose: Draws the text . - - Pick (me : mutable; X, Y: ShortReal from Standard; - aPrecision: ShortReal from Standard; - aDrawer: Drawer from Graphic2d) - returns Boolean from Standard - is virtual protected; - ---Level: Internal - ---Purpose: Returns Standard_True if the text is picked, - -- Standard_False if not. - - ---------------------------- - -- Category: Inquire methods - ---------------------------- - - IsZoomable (me) - returns Boolean from Standard is static; - ---Level: Public - ---Purpose: Returns Standard_True if the Text follows - -- the scale factor of the view. - ---Category: Zoom management - - IsUnderlined (me) returns Boolean from Standard is static; - ---Level: Public - ---Purpose: Returns Standard_True if the Text is underlined. - - TextSize (me; aWidth,aHeight: out Length from Quantity) - returns Boolean from Standard is static; - ---Level: Public - ---Purpose: Returns Standard_True if the current Driver used is enabled - -- to get the right size in the - -- world size parameter , - -- depending of the attributes of the text and the current scale - -- of the view. - ---Category: Text management - - TextSize (me; aWidth,aHeight,anXoffset,anYoffset: out Length from Quantity) - returns Boolean from Standard is virtual; - ---Level: Public - ---Purpose: Returns Standard_True if the current Driver used is enabled - -- to get the right size and text offsets in the - -- world size parameter ,,, - -- depending of the attributes of the text and the current scale - -- of the view. - -- NOTE that the text offsets defines the relative position of the - -- of the text string origin from the lower left corner of the text - -- boundary limits. - ---Category: Text management - - Position (me; X,Y: out Length from Quantity) is static; - ---Level: Public - ---Purpose: Returns the text position. - - Offset (me; X,Y: out Real from Standard) is static; - ---Level: Public - ---Purpose: Returns the text Offset. - - Slant (me) returns PlaneAngle from Quantity is static; - ---Level: Public - ---Purpose: Returns the text slant. - - Angle (me) returns PlaneAngle from Quantity is static; - ---Level: Public - ---Purpose: Returns the text orientation. - - FontIndex (me) returns Integer from Standard is static; - ---Level: Public - ---Purpose: Returns the text font index. - - Scale (me) returns Factor from Quantity is static; - ---Level: Public - ---Purpose: Returns the text scale. - - Alignment (me) returns TypeOfAlignment from Graphic2d is static; - ---Level: Public - ---Purpose: Returns the text alignment. - - GetText( me ) returns ExtendedString from TCollection; - ---Level: Public - ---Purpose: Returns the text string - - GetType( me ) returns TypeOfText from Aspect; - ---Level: Public - ---Purpose: Returns the type text - - ---------------------------- - -- Category: Private methods - ---------------------------- - - ComputeMinMax (me : mutable) - returns Boolean from Standard is redefined virtual protected; - ---Level: Internal - ---Purpose: Computes the MinMax of the text if possible. - - ---------------------------------------------------------------------- - - Save( me; aFStream: in out FStream from Aspect ) is virtual; --- Retrieve( me; aIFStream: in out IFStream from AIS2D ) is virtual; - -fields - - myFontIndex: Integer from Standard is protected; - - myX,myDx: ShortReal from Standard is protected; - myY,myDy: ShortReal from Standard is protected; - myAngle: ShortReal from Standard is protected; - myType: TypeOfText from Aspect is protected; - myText: ExtendedString from TCollection is protected; - myAdjustFlag: Boolean from Standard is protected; - - myDeltax: ShortReal from Standard is protected; - myDeltay: ShortReal from Standard is protected; - mySlant: ShortReal from Standard is protected; - myIsZoomable: Boolean from Standard is protected; - myIsUnderlined: Boolean from Standard is protected; - myHScale: Factor from Quantity is protected; - myWScale: Factor from Quantity is protected; - myAlignment: TypeOfAlignment from Graphic2d is protected; - -end Text from Graphic2d; diff --git a/src/Graphic2d/Graphic2d_Text.cxx b/src/Graphic2d/Graphic2d_Text.cxx deleted file mode 100755 index ab13ccdaf1..0000000000 --- a/src/Graphic2d/Graphic2d_Text.cxx +++ /dev/null @@ -1,557 +0,0 @@ -// Copyright (c) 1995-1999 Matra Datavision -// Copyright (c) 1999-2012 OPEN CASCADE SAS -// -// The content of this file is subject to the Open CASCADE Technology Public -// License Version 6.5 (the "License"). You may not use the content of this file -// except in compliance with the License. Please obtain a copy of the License -// at http://www.opencascade.org and read it completely before using this file. -// -// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its -// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. -// -// The Original Code and all software distributed under the License is -// distributed on an "AS IS" basis, without warranty of any kind, and the -// Initial Developer hereby disclaims all such warranties, including without -// limitation, any warranties of merchantability, fitness for a particular -// purpose or non-infringement. Please see the License for the specific terms -// and conditions governing the rights and limitations under the License. - - -#define PERF //GG_200898 -// The MinMax are now computed at the right time and no more -// soon an attribute has change -// (see the redefined method ComputeMinMax()). - -#define BUC60583 //GG_300999 Enable to compute correctly a -// Mirror transformation - -#include -#include - -#include - -Graphic2d_Text::Graphic2d_Text - (const Handle(Graphic2d_GraphicObject)& aGraphicObject, - const TCollection_ExtendedString& aText, - const Standard_Real X, const Standard_Real Y, - const Quantity_PlaneAngle anAngle, - const Aspect_TypeOfText aType, - const Quantity_Factor aScale) - : Graphic2d_Primitive (aGraphicObject), - myFontIndex (0), - myX(Standard_ShortReal(X)), - myDx(Standard_ShortReal(0.)), - myY(Standard_ShortReal(Y)), - myDy(Standard_ShortReal(0.)), - myAngle(Standard_ShortReal(anAngle)), - myType(aType), - myText(aText), - myAdjustFlag(Standard_False), - myDeltax(Standard_ShortReal(0.)), myDeltay(Standard_ShortReal(0.)), - mySlant(Standard_ShortReal(0.)), - myIsZoomable(Standard_True), - myIsUnderlined(Standard_False), - myHScale(Standard_ShortReal(aScale)), - myWScale(Standard_ShortReal(aScale)), - myAlignment(Graphic2d_TOA_LEFT) -#ifndef PERF - ,myResetFlag(Standard_True), -#endif -{ - - SetFamily(Graphic2d_TOP_TEXT); - - while (myAngle < 0.) myAngle += Standard_ShortReal(2. * M_PI); - while (myAngle >= 2. * M_PI) myAngle -= Standard_ShortReal(2. * M_PI); - -#ifndef PERF - this->ComputeMinMax(); -#endif - -} - -void Graphic2d_Text::SetFontIndex (const Standard_Integer anIndex) { - - myFontIndex = anIndex; -#ifdef PERF - myMinX = myMinY = ShortRealLast (); - myMaxX = myMaxY = ShortRealFirst (); -#else - myResetFlag = Standard_True; - this->ComputeMinMax(); -#endif - -} - -void Graphic2d_Text::SetSlant (const Quantity_PlaneAngle aSlant) { - - mySlant = Standard_ShortReal(aSlant); - while (mySlant < 0.) mySlant += Standard_ShortReal(2. * M_PI); - while (mySlant >= 2. * M_PI) mySlant -= Standard_ShortReal(2. * M_PI); -#ifdef PERF - myMinX = myMinY = ShortRealLast (); - myMaxX = myMaxY = ShortRealFirst (); -#else - myResetFlag = Standard_True; - this->ComputeMinMax(); -#endif -} - -Standard_Boolean Graphic2d_Text::IsZoomable () const { - - return myIsZoomable; - -} - -Standard_Boolean Graphic2d_Text::IsUnderlined () const { - - return myIsUnderlined; - -} - -void Graphic2d_Text::SetZoomable (const Standard_Boolean aFlag) { - - myIsZoomable = aFlag; -#ifdef PERF - myMinX = myMinY = ShortRealLast (); - myMaxX = myMaxY = ShortRealFirst (); -#else - myResetFlag = Standard_True; - this->ComputeMinMax(); -#endif - -} - -void Graphic2d_Text::SetUnderline (const Standard_Boolean aFlag) { - - myIsUnderlined = aFlag; -#ifdef PERF - myMinX = myMinY = ShortRealLast (); - myMaxX = myMaxY = ShortRealFirst (); -#else - myResetFlag = Standard_True; - this->ComputeMinMax(); -#endif - -} - -void Graphic2d_Text::SetOffset (const Standard_Real aDx, const Standard_Real aDy) { - - myDeltax = Standard_ShortReal(aDx); - myDeltay = Standard_ShortReal(aDy); -#ifdef PERF - myMinX = myMinY = ShortRealLast (); - myMaxX = myMaxY = ShortRealFirst (); -#else - myResetFlag = Standard_True; - this->ComputeMinMax(); -#endif -} - -void Graphic2d_Text::SetAlignment (const Graphic2d_TypeOfAlignment anAlignment) { - - myAlignment = anAlignment; -#ifdef PERF - myMinX = myMinY = ShortRealLast (); - myMaxX = myMaxY = ShortRealFirst (); -#else - myResetFlag = Standard_True; - this->ComputeMinMax(); -#endif -} - -Graphic2d_TypeOfAlignment Graphic2d_Text::Alignment () const { - - return myAlignment; - -} - -void Graphic2d_Text::Draw (const Handle(Graphic2d_Drawer)& aDrawer) { -Standard_Boolean IsIn = Standard_False; -Standard_ShortReal hscale = (myIsZoomable) ? Standard_ShortReal(myHScale * aDrawer->Scale()) : Standard_ShortReal(myHScale); -Standard_ShortReal wscale = (myIsZoomable) ? Standard_ShortReal(myWScale * aDrawer->Scale()) : Standard_ShortReal(myWScale); -Standard_ShortReal ox = aDrawer->ConvertMapToFrom(myDeltax); -Standard_ShortReal oy = aDrawer->ConvertMapToFrom(myDeltay); - -#ifdef PERF - if( (myMaxX < myMinX) || (myMaxY < myMinY) ) { - if( !ComputeMinMax() ) return; - } -#else - if( myResetFlag ) { - ComputeMinMax(); - } -#endif - - if (! myGOPtr->IsTransformed ()) { - IsIn = aDrawer->IsIn (myMinX+ox,myMaxX+ox,myMinY+oy,myMaxY+oy); - if (IsIn) { - aDrawer->SetTextAttrib(myColorIndex,myFontIndex, - mySlant,hscale,wscale,myIsUnderlined); - Standard_ShortReal dx = myDx,dy = myDy; - if( myAngle != 0. ) { - Standard_ShortReal cosa = Standard_ShortReal(Cos(myAngle)); - Standard_ShortReal sina = Standard_ShortReal(Sin(myAngle)); - - dx = XROTATE(myDx,myDy) ; - dy = YROTATE(myDx,myDy) ; - } - aDrawer->MapTextFromTo(myText,myX+dx,myY+dy,myAngle, - myDeltax,myDeltay,myType); - } - } else { - gp_GTrsf2d aTrsf = myGOPtr->Transform (); - Standard_ShortReal minx,miny,maxx,maxy; - MinMax(minx,maxx,miny,maxy); - IsIn = aDrawer->IsIn (minx+ox,maxx+ox,miny+oy,maxy+oy); - if (IsIn) { - Standard_Real A = Standard_Real (myX); - Standard_Real B = Standard_Real (myY); - Standard_Real C = Standard_Real (myAngle); - Standard_Real cosa = Cos (C); - Standard_Real sina = Sin (C); - aTrsf.Transforms (A, B); - Standard_ShortReal a = Standard_ShortReal (A); - Standard_ShortReal b = Standard_ShortReal (B); -#ifdef BUC60583 - aTrsf.Transforms (cosa, sina); - A = B = 0.; - aTrsf.Transforms (A, B); - cosa -= A; sina -= B; - if( aTrsf.IsNegative() ) hscale = - hscale; -#else - // To calculate new aperture angles - // calculation is done on the trigonometric circle - // and in this case translation is not taken into account. - aTrsf.SetValue (1, 3, 0.0); - aTrsf.SetValue (2, 3, 0.0); - aTrsf.Transforms (cosa, sina); -#endif - Standard_ShortReal angle = Standard_ShortReal (atan2(sina,cosa)); - if( myIsZoomable ) { - hscale *= Standard_ShortReal (Sqrt(cosa*cosa + sina*sina)); - wscale *= Standard_ShortReal (Sqrt(cosa*cosa + sina*sina)); - } - - aDrawer->SetTextAttrib(myColorIndex,myFontIndex, - mySlant,hscale,wscale,myIsUnderlined); - Standard_ShortReal dx = myDx,dy = myDy; - if( angle != 0. ) { - dx = Standard_ShortReal(XROTATE(myDx,myDy)); - dy = Standard_ShortReal(YROTATE(myDx,myDy)); - } - a += dx; b += dy; - aDrawer->MapTextFromTo(myText,a,b,angle,myDeltax,myDeltay,myType); - } - } -} - - -Standard_Boolean Graphic2d_Text::Pick (const Standard_ShortReal X, - const Standard_ShortReal Y, - const Standard_ShortReal aPrecision, - const Handle(Graphic2d_Drawer)& aDrawer) -{ -Standard_Boolean theStatus = Standard_False; -Standard_ShortReal width,height,xoffset,yoffset; -Standard_ShortReal hscale = (myIsZoomable) ? Standard_ShortReal(myHScale * aDrawer->Scale()) : Standard_ShortReal(myHScale); -Standard_ShortReal wscale = (myIsZoomable) ? Standard_ShortReal(myWScale * aDrawer->Scale()) : Standard_ShortReal(myWScale); -Standard_ShortReal TX = X, TY = Y; -Standard_ShortReal ox = aDrawer->ConvertMapToFrom(myDeltax); -Standard_ShortReal oy = aDrawer->ConvertMapToFrom(myDeltay); - - if (IsInMinMax (X-ox, Y-oy, aPrecision)) { - if (myGOPtr->IsTransformed ()) { - gp_GTrsf2d aTrsf = (myGOPtr->Transform ()).Inverted (); - Standard_Real RX = Standard_Real (X), RY = Standard_Real (Y); - aTrsf.Transforms (RX, RY); - TX = Standard_ShortReal (RX); TY = Standard_ShortReal (RY); - } - - aDrawer->SetTextAttrib(myColorIndex,myFontIndex, - mySlant,hscale,wscale,myIsUnderlined); - if( !aDrawer->GetTextSize(myText,width,height,xoffset,yoffset) ) { - width = height = xoffset = yoffset = 0.; - } - Standard_ShortReal cosa = Standard_ShortReal(Cos(-myAngle)); - Standard_ShortReal sina = Standard_ShortReal(Sin(-myAngle)); - Standard_ShortReal dx = TX-(myX+ox+myDx); - Standard_ShortReal dy = TY-(myY+oy+myDy); - Standard_ShortReal x = XROTATE(dx,dy); - Standard_ShortReal y = YROTATE(dx,dy); - - theStatus = (x >= -aPrecision + xoffset) - && (x <= width + xoffset + aPrecision) - && (y >= -yoffset - aPrecision) - && (y <= height - yoffset + aPrecision); - } - - return theStatus; -} - -Standard_Boolean Graphic2d_Text::TextSize ( Quantity_Length &aWidth, - Quantity_Length &aHeight) const { -Handle(Graphic2d_Drawer) aDrawer = Drawer(); - - if( !aDrawer.IsNull() && aDrawer->IsWindowDriver() ) { - Standard_ShortReal hscale = (myIsZoomable) ? Standard_ShortReal(myHScale * aDrawer->Scale()) : Standard_ShortReal(myHScale); - Standard_ShortReal wscale = (myIsZoomable) ? Standard_ShortReal(myWScale * aDrawer->Scale()) : Standard_ShortReal(myWScale); - Standard_ShortReal width,height; - aDrawer->SetTextAttrib(myColorIndex,myFontIndex, - mySlant,hscale,wscale,myIsUnderlined); - - aDrawer->GetTextSize(myText,width,height); - aWidth = width; - aHeight = height; - return Standard_True; - } else { - aWidth = aHeight = 0.; - return Standard_False; - } - -} - -Standard_Boolean Graphic2d_Text::TextSize ( Quantity_Length &aWidth, - Quantity_Length &aHeight, - Quantity_Length &anXoffset, - Quantity_Length &anYoffset) const { -Handle(Graphic2d_Drawer) aDrawer = Drawer(); - - if( !aDrawer.IsNull() && aDrawer->IsWindowDriver() ) { - Standard_ShortReal hscale = (myIsZoomable) ? Standard_ShortReal(myHScale * aDrawer->Scale()) : Standard_ShortReal(myHScale); - Standard_ShortReal wscale = (myIsZoomable) ? Standard_ShortReal(myWScale * aDrawer->Scale()) : Standard_ShortReal(myWScale); - Standard_ShortReal width,height,xoffset,yoffset; - aDrawer->SetTextAttrib(myColorIndex,myFontIndex, - mySlant,hscale,wscale,myIsUnderlined); - - aDrawer->GetTextSize(myText,width,height,xoffset,yoffset); - aWidth = width; - aHeight = height; - anXoffset = xoffset; - anYoffset = yoffset; - return Standard_True; - } else { - aWidth = aHeight = anXoffset = anYoffset = 0.; - return Standard_False; - } - -} - -void Graphic2d_Text::Position( Quantity_Length &X, - Quantity_Length &Y) const { -Handle(Graphic2d_Drawer) aDrawer = Drawer(); - - X = myX; - Y = myY; - if( !aDrawer.IsNull() ) { - X += aDrawer->ConvertMapToFrom(myDeltax); - Y += aDrawer->ConvertMapToFrom(myDeltay); - } -} - -void Graphic2d_Text::Offset( Standard_Real &X, - Standard_Real &Y) const { - - X = myDeltax; - Y = myDeltay; -} - -Quantity_PlaneAngle Graphic2d_Text::Slant() const { - - return mySlant; -} - -Quantity_PlaneAngle Graphic2d_Text::Angle() const { - - return myAngle; -} - -Standard_Integer Graphic2d_Text::FontIndex() const { - - return myFontIndex; -} - -Quantity_Factor Graphic2d_Text::Scale() const { - - return myHScale; -} - -Standard_Boolean Graphic2d_Text::Fit(const Quantity_Length aWidth,const Quantity_Length aHeight,const Standard_Boolean Adjust,const Standard_Boolean Expand) { -Quantity_Length twidth,theight,txoffset,tyoffset; -Standard_ShortReal wscale,hscale; -Standard_Boolean status; - - myAdjustFlag = Adjust; - if(( status = TextSize(twidth,theight,txoffset,tyoffset) )) { - wscale = Standard_ShortReal(aWidth/twidth); - if( wscale > 0. ) { - if( Expand || (twidth > aWidth) ) myWScale *= wscale; - } - hscale = Standard_ShortReal(aHeight/theight); - if( hscale > 0. ) myHScale *= hscale; -#ifdef PERF - myMinX = myMinY = ShortRealLast (); - myMaxX = myMaxY = ShortRealFirst (); -#else - myResetFlag = Standard_True; - this->ComputeMinMax(); -#endif - } - - return status; -} - -Standard_Boolean Graphic2d_Text::Trunc(const Quantity_Length aWidth) { -Quantity_Length twidth,theight,txoffset,tyoffset; -//Standard_ShortReal wscale,hscale; -Standard_Boolean status; - - if(( status = TextSize(twidth,theight,txoffset,tyoffset) )) { - Standard_Integer l = myText.Length(); - while( (l > 1) && (twidth > aWidth) ) { - --l; - myText.Split(l); - TextSize(twidth,theight,txoffset,tyoffset); - } -#ifdef PERF - myMinX = myMinY = ShortRealLast (); - myMaxX = myMaxY = ShortRealFirst (); -#else - myResetFlag = Standard_True; - this->ComputeMinMax(); -#endif - } - - return status; -} - -Standard_Boolean Graphic2d_Text::ComputeMinMax() { -Handle(Graphic2d_Drawer) aDrawer = Drawer(); -Standard_Boolean status = Standard_False; - - if( !aDrawer.IsNull() && aDrawer->IsWindowDriver() ) { - Standard_ShortReal hscale = - (myIsZoomable) ? Standard_ShortReal(myHScale * aDrawer->Scale()) : Standard_ShortReal(myHScale); - Standard_ShortReal wscale = - (myIsZoomable) ? Standard_ShortReal(myWScale * aDrawer->Scale()) : Standard_ShortReal(myWScale); - Standard_ShortReal width,height,xoffset,yoffset; - aDrawer->SetTextAttrib(myColorIndex,myFontIndex, - mySlant,hscale,wscale,myIsUnderlined); - if(( status = - aDrawer->GetTextSize(myText,width,height,xoffset,yoffset) )) { -#ifndef PERF - myResetFlag = Standard_False; -#endif - switch( myAlignment ) { - case Graphic2d_TOA_LEFT: - myDx = 0.; myDy = 0.; - break; - case Graphic2d_TOA_RIGHT: - myDx = -width; myDy = 0.; - break; - case Graphic2d_TOA_CENTER: - myDx = Standard_ShortReal(-width/2.); myDy = Standard_ShortReal(0.); - break; - case Graphic2d_TOA_TOPLEFT: - myDx = 0.; myDy = yoffset-height; - break; - case Graphic2d_TOA_TOPRIGHT: - myDx = -width; myDy = yoffset-height; - break; - case Graphic2d_TOA_TOPCENTER: - myDx = Standard_ShortReal(-width/2.); myDy = yoffset-height; - break; - case Graphic2d_TOA_MEDIUMLEFT: - myDx = 0.; myDy = Standard_ShortReal((yoffset-height)/2.); - break; - case Graphic2d_TOA_MEDIUMRIGHT: - myDx = -width; myDy = Standard_ShortReal((yoffset-height)/2.); - break; - case Graphic2d_TOA_MEDIUMCENTER: - myDx = Standard_ShortReal(-width/2.); myDy = Standard_ShortReal((yoffset-height)/2.); - break; - case Graphic2d_TOA_BOTTOMLEFT: - myDx = 0.; myDy = yoffset; - break; - case Graphic2d_TOA_BOTTOMRIGHT: - myDx = -width; myDy = yoffset; - break; - case Graphic2d_TOA_BOTTOMCENTER: - myDx = Standard_ShortReal(-width/2.); myDy = yoffset; - break; - } - if( myAdjustFlag ) { - myDx -= xoffset; myDy += yoffset; - } - Standard_ShortReal xmin = myDx + xoffset; - Standard_ShortReal ymin = myDy - yoffset; - Standard_ShortReal xmax = xmin + width; - Standard_ShortReal ymax = ymin + height; - - myMinX = myMinY = ShortRealLast(); - myMaxX = myMaxY = ShortRealFirst(); - if( myAngle != 0. ) { - Standard_ShortReal cosa = Standard_ShortReal(Cos(myAngle)); - Standard_ShortReal sina = Standard_ShortReal(Sin(myAngle)); - Standard_ShortReal dx,dy ; - - dx = XROTATE(xmin,ymin) ; - dy = YROTATE(xmin,ymin) ; - myMinX = Min(myMinX,myX+dx) ; - myMinY = Min(myMinY,myY+dy) ; - myMaxX = Max(myMaxX,myX+dx) ; - myMaxY = Max(myMaxY,myY+dy) ; - - dx = XROTATE(xmax,ymin) ; - dy = YROTATE(xmax,ymin) ; - myMinX = Min(myMinX,myX+dx) ; - myMinY = Min(myMinY,myY+dy) ; - myMaxX = Max(myMaxX,myX+dx) ; - myMaxY = Max(myMaxY,myY+dy) ; - - dx = XROTATE(xmax,ymax) ; - dy = YROTATE(xmax,ymax) ; - myMinX = Min(myMinX,myX+dx) ; - myMinY = Min(myMinY,myY+dy) ; - myMaxX = Max(myMaxX,myX+dx) ; - myMaxY = Max(myMaxY,myY+dy) ; - - dx = XROTATE(xmin,ymax) ; - dy = YROTATE(xmin,ymax) ; - myMinX = Min(myMinX,myX+dx) ; - myMinY = Min(myMinY,myY+dy) ; - myMaxX = Max(myMaxX,myX+dx) ; - myMaxY = Max(myMaxY,myY+dy) ; - } else { - myMinX = Min(myMinX,myX+xmin) ; - myMinY = Min(myMinY,myY+ymin) ; - myMaxX = Max(myMaxX,myX+xmax) ; - myMaxY = Max(myMaxY,myY+ymax) ; - } - } - } -#ifdef PERF - else { - cout << "*Graphic2d_Text::ComputeMinMax() returns wrong values*" << endl; - } -#endif - - return status; -} - - -TCollection_ExtendedString Graphic2d_Text::GetText() const { - - return myText; -} - -Aspect_TypeOfText Graphic2d_Text::GetType() const { - - return myType; -} - -void Graphic2d_Text::Save(Aspect_FStream& aFStream) const -{ -} - - diff --git a/src/Graphic2d/Graphic2d_TransientManager.cdl b/src/Graphic2d/Graphic2d_TransientManager.cdl deleted file mode 100755 index 24e09a6393..0000000000 --- a/src/Graphic2d/Graphic2d_TransientManager.cdl +++ /dev/null @@ -1,517 +0,0 @@ --- Created on: 1996-05-10 --- Created by: GG --- Copyright (c) 1996-1999 Matra Datavision --- Copyright (c) 1999-2012 OPEN CASCADE SAS --- --- The content of this file is subject to the Open CASCADE Technology Public --- License Version 6.5 (the "License"). You may not use the content of this file --- except in compliance with the License. Please obtain a copy of the License --- at http://www.opencascade.org and read it completely before using this file. --- --- The Initial Developer of the Original Code is Open CASCADE S.A.S., having its --- main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. --- --- The Original Code and all software distributed under the License is --- distributed on an "AS IS" basis, without warranty of any kind, and the --- Initial Developer hereby disclaims all such warranties, including without --- limitation, any warranties of merchantability, fitness for a particular --- purpose or non-infringement. Please see the License for the specific terms --- and conditions governing the rights and limitations under the License. - - --- SAV 14/11/01 Added DrawPickedElements() - highlights picked elements. - -class TransientManager from Graphic2d inherits Drawer from Graphic2d - - ---Version: - - ---Purpose: This class allows to manage transient graphics - -- above one View. - -- A simple way to drawn something very quicly above - -- a complex scene (Hilighting,Sketching,...) - -- All transient graphics will be erased at the - -- next View::Update(),Redraw(). - -- - -- Remember that nothing is stored by this object and - -- graphic library,the application must managed itself - -- exposure,resizing,... - -- - -- The double_buffering must be is activated on the view, - -- the back buffer is preserved and used for restoring - -- the front buffer at begin drawing time. - -- Keywords: TransientManager, Immediate Mode, Line, Polygon - -- Text, Marker - ---Warning: - ---References: - -uses - View from Graphic2d, - ViewPtr from Graphic2d, - GraphicObject from Graphic2d, - Primitive from Graphic2d, - ViewMapping from Graphic2d, - Array1OfVertex from Graphic2d, - TypeOfComposition from Graphic2d, - TypeOfAlignment from Graphic2d, - Length from Quantity, - Factor from Quantity, - Ratio from Quantity, - PlaneAngle from Quantity, - ExtendedString from TCollection, - WindowDriver from Aspect, - TypeOfPrimitive from Aspect, - TypeOfText from Aspect, - GTrsf2d from gp --- Curve from Geom2d -- disparait a partir de K4 - -raises - TransientDefinitionError from Graphic2d - -is - ------------------------- - -- Category: Constructors - ------------------------- - - Create (aView: View from Graphic2d) - returns mutable TransientManager from Graphic2d; - - Create (aView: ViewPtr from Graphic2d) - returns mutable TransientManager from Graphic2d; - ---Level: Public - ---Purpose: Creates a TransientManager associated to the view - ---Category: Constructors - - ------------------------ - -- Category: Destructors - ------------------------ - - Destroy (me : mutable); - ---Level: Public - ---Purpose: Suppress the TransientManager . - ---Category: Destructors - ---C++: alias ~ - - --------------------------------------------------- - -- Category: Methods to modify the class definition - --------------------------------------------------- - - BeginDraw (me : mutable; - aDriver: WindowDriver from Aspect; - ClearBefore: Boolean = Standard_True) - returns Boolean from Standard is static; - ---Level: Public - ---Purpose: Begins any graphics in the view and Driver - -- with the current view attributes in a transient area. - -- Restore the front buffer from the back before - -- if is TRUE. - -- - -- Warning: Returns TRUE if transient backing-store is enabled in - -- the associated view. - -- Returns FALSE ,if nothing works because something - -- is wrong for the transient principle : - -- Immediat mode is not implemented depending of the - -- graphic library used. - -- MBX,PIXMAP double buffering don't works depending of - -- the graphic board and the visual of the window supporting - -- the view. - ---Category: Methods to modify the class definition - - BeginDraw (me : mutable; - aDriver: WindowDriver from Aspect; - aViewMapping: ViewMapping from Graphic2d; - aXPosition, aYPosition: Real from Standard; - aScale: Real from Standard; - ClearBefore: Boolean = Standard_True) - returns Boolean from Standard is static; - ---Level: Public - ---Purpose: Begins any graphics in the view and Driver - -- with the view attributes in a transient area defined - -- by : - -- defines the "map from". - -- , , define the "map to". - -- Restore the front buffer from the back before - -- if is TRUE. - ---Category: Methods to modify the class definition - - EndDraw (me : mutable; - Synchronize: Boolean = Standard_True) is static; - ---Level: Public - ---Purpose: Flush all graphics to the front buffer. - -- Synchronize graphics to the screen if is - -- TRUE (make becarefull to the performances!). - ---Category: Methods to modify the class definition - - Restore (me : mutable; - aDriver: WindowDriver from Aspect) - returns Boolean from Standard is static; - ---Level: Public - ---Purpose: Restore the full transient view, - -- returns TRUE if the transient area has been restored - -- correctly or FALSE if the view has been redrawn. - ---Category: Methods to modify the class definition - - RestoreArea (me : mutable; - aDriver: WindowDriver from Aspect) - returns Boolean from Standard is static; - ---Level: Public - ---Purpose: Restore the last updated transient area, - -- returns TRUE if the transient area has been restored - -- correctly or FALSE if the view has been redrawn. - ---Category: Methods to modify the class definition - - --------------------------------------- - -- Category: Graphic definition methods - --------------------------------------- - - Draw (me : mutable; - aPrimitive : Primitive from Graphic2d) - ---Level: Public - ---Purpose: Drawn the primitive , - -- with the internal primitive attributes. - raises TransientDefinitionError from Graphic2d is static; - ---Trigger: If a Drawing is not opened. - ---Category: Draw methods - - Draw (me : mutable; - aGraphicObject : GraphicObject from Graphic2d) - ---Level: Public - ---Purpose: Drawn the graphic object . - -- with the internal graphic object primitives attributes. - raises TransientDefinitionError from Graphic2d is static; - ---Trigger: If a Drawing is not opened. - ---Category: Draw methods - - DrawElement (me : mutable; - aPrimitive : Primitive from Graphic2d; - anIndex : Integer from Standard) - ---Level: Public - ---Purpose: Drawn the element from the primitive , - -- with the internal primitive attributes. - raises TransientDefinitionError from Graphic2d is static; - ---Trigger: If a Drawing is not opened. - ---Category: Draw methods - - --- SAV - DrawPickedElements(me : mutable; aPrimitive : Primitive from Graphic2d ) - ---Level: Public - ---Purpose: Draws all picked elements. - raises TransientDefinitionError from Graphic2d is static; - ---Trigger: If a Drawing is not opened. - ---Category: Draw methods - - DrawVertex (me : mutable; - aPrimitive : Primitive from Graphic2d; - anIndex : Integer from Standard) - ---Level: Public - ---Purpose: Drawn the vertex from the primitive , - -- with the internal primitive attributes. - raises TransientDefinitionError from Graphic2d is static; - ---Trigger: If a Drawing is not opened. - ---Category: Draw methods - - BeginPrimitive (me : mutable; - aType: TypeOfPrimitive from Aspect; - aSize: Integer from Standard = 0) - ---Level: Public - ---Purpose: Sets the current type of primitive to be opened. - -- After this call, is ready to receive - -- a definition of an incremental primitive - -- such as a polyline or polygon with DrawPoint(), - -- or the definition of a set of primitives such as - -- a segment with DrawSegment() or DrawMarker(). - -- Warning: The max number of element of the primitive can be defined - -- with for optimization. - -- Example: This sequence drawn a polyline square of size 1. - -- myTransientManager->BeginDraw(myDriver) - -- myTransientManager->BeginPrimitive(Aspect_TOP_POLYLINE,5) - -- myTransientManager->DrawPoint(-0.5,-0.5) - -- myTransientManager->DrawPoint(-0.5, 0.5) - -- myTransientManager->DrawPoint( 0.5, 0.5) - -- myTransientManager->DrawPoint( 0.5,-0.5) - -- myTransientManager->DrawPoint(-0.5,-0.5) - -- myTransientManager->ClosePrimitive() - -- myTransientManager->EndDraw() - raises TransientDefinitionError from Graphic2d is static; - ---Trigger: if the primitive type is not UNKNOWN, - -- or if the associated driver is not defined. - ---Category: Draw methods - - ClosePrimitive (me : mutable) - ---Level: Public - ---Purpose: After this call, stops the reception of - -- a definition of a Begin... primitive. - raises TransientDefinitionError from Graphic2d is static; - ---Trigger: if a Begin... primitive is not opened, - -- or if the associated driver is not defined. - ---Category: Draw methods - - DrawSegment (me : mutable; X1, Y1, X2, Y2: Length from Quantity) - ---Level: Public - ---Purpose: Draw a segment. - raises TransientDefinitionError from Graphic2d is static; - ---Trigger: If a Drawing is not opened, - -- or if the opened primitive type is wrong - ---Category: Draw methods - - DrawInfiniteLine (me : mutable; X, Y, Dx, Dy: Length from Quantity) - ---Level: Public - ---Purpose: Draw an infinite line defined by a reference point - -- and a slope - raises TransientDefinitionError from Graphic2d is static; - ---Trigger: If a Drawing is not opened, - -- or if the opened primitive type is wrong. - ---Category: Draw methods - - DrawArc (me : mutable; Xc, Yc, - aRadius: Length from Quantity; - anAngle1: PlaneAngle from Quantity = 0.0; - anAngle2: PlaneAngle from Quantity = 0.0) - ---Level: Public - ---Purpose: Draw a circle arc from the start angle - -- to the ending angle . - -- NOTE that if is equal to - -- a full circle is drawn. - raises TransientDefinitionError from Graphic2d is static; - ---Trigger: If a Drawing is not opened - -- or if the opened primitive type is wrong. - ---Category: Draw methods - - DrawPolyArc (me : mutable; Xc, Yc, aRadius: Length from Quantity; - anAngle1: PlaneAngle from Quantity = 0.0; - anAngle2: PlaneAngle from Quantity = 0.0) - ---Level: Public - ---Purpose: Draw a filled circle arc from the start angle - -- to the ending angle . - -- NOTE that if is equal to - -- a full circle is drawn. - raises TransientDefinitionError from Graphic2d is static; - ---Trigger: If a Drawing is not opened, - -- or if the opened primitive type is wrong. - ---Category: Draw methods - - DrawPoint (me : mutable; X, Y : Length from Quantity) - ---Level: Public - ---Purpose: Draw a marker point. - raises TransientDefinitionError from Graphic2d is static; - ---Trigger: If a Drawing is not opened, - -- or if the opened primitive type is wrong. - ---Category: Draw methods - - DrawMarker (me : mutable; - anIndex: Integer from Standard; - X, Y, aWidth, anHeight: Length from Quantity; - anAngle: PlaneAngle from Quantity = 0.0) - ---Level: Public - ---Purpose: Draw an indexed marker. - raises TransientDefinitionError from Graphic2d is static; - ---Trigger: If a Drawing is not opened, - -- or if the opened primitive type is wrong. - ---Category: Draw methods - - DrawText (me : mutable; aText: ExtendedString from TCollection; - X, Y: Length from Quantity; - anAngle: PlaneAngle from Quantity = 0.0; - aDeltaX : Real from Standard = 0.0; - aDeltaY: Real from Standard = 0.0; - aType: TypeOfText from Aspect = Aspect_TOT_SOLID; - anAlignment: TypeOfAlignment from Graphic2d = Graphic2d_TOA_LEFT) - ---Level: Public - ---Purpose: Draw a text at the position added to - -- the untransformed drawer offset , - -- with an orientation and a type . - raises TransientDefinitionError from Graphic2d is static; - ---Trigger: If a Drawing is not opened, - -- or if the opened primitive type is wrong. - ---Category: Draw methods - - DrawPolyText (me : mutable; aText: ExtendedString from TCollection; - X, Y: Length from Quantity; - anAngle: PlaneAngle from Quantity = 0.0; - aMargin: Ratio from Quantity = 0.1; - aDeltaX : Real from Standard = 0.0; - aDeltaY: Real from Standard = 0.0; - aType: TypeOfText from Aspect = Aspect_TOT_SOLID; - anAlignment: TypeOfAlignment from Graphic2d = Graphic2d_TOA_LEFT) - ---Level: Public - ---Purpose: Draw an hiding text at the position added to - -- the untransformed offset , - -- with an orientation and a type . - -- defined the relative margin factor between - -- the text string and the frame height. - raises TransientDefinitionError from Graphic2d is static; - ---Trigger: If a Drawing is not opened, - -- or if the opened primitive type is wrong. - ---Category: Draw methods - - DrawFramedText (me : mutable; aText: ExtendedString from TCollection; - X, Y: Length from Quantity; - anAngle: PlaneAngle from Quantity = 0.0; - aMargin: Ratio from Quantity = 0.1; - aDeltaX : Real from Standard = 0.0; - aDeltaY: Real from Standard = 0.0; - aType: TypeOfText from Aspect = Aspect_TOT_SOLID; - anAlignment: TypeOfAlignment from Graphic2d = Graphic2d_TOA_LEFT) - ---Level: Public - ---Purpose: Draw a framed text at the position added to - -- the untransformed offset , - -- with an orientation and a type . - -- defined the relative margin factor between - -- the text string and the frame height. - raises TransientDefinitionError from Graphic2d is static; - ---Trigger: If a Drawing is not opened, - -- or if the opened primitive type is wrong. - ---Category: Draw methods - --- DrawCurve (me : mutable; aCurve: Curve from Geom2d) -- disparait a partir de K4 - ---Level: Public - ---Purpose: Draw a curve. - -- raises TransientDefinitionError from Graphic2d is static; - ---Trigger: If a Drawing is not opened, - -- or if the opened primitive type is wrong. - ---Category: Draw methods - - --------------------------------------- - -- Category: Graphic attributes methods - --------------------------------------- - - SetTextAttrib (me: mutable; - ColorIndex: Integer from Standard; - FontIndex: Integer from Standard; - aSlant: PlaneAngle from Quantity = 0.0; - aHScale: Factor from Quantity = 1.0; - aWScale: Factor from Quantity = 1.0; - isUnderlined: Boolean from Standard = Standard_False; - isZoomable: Boolean from Standard = Standard_True) - ---Level: Public - ---Purpose: Methods to define the Current Text Attributes - -- NOTE that ,if isZoomable is TRUE the text size follow - -- the scale factor of the view and the current transformation - -- scale factor. - raises TransientDefinitionError from Graphic2d is static; - ---Trigger: If a Drawing is not opened. - ---Category: graphic attributes methods - - SetHidingTextAttrib (me: mutable; - ColorIndex: Integer from Standard; - HidingColorIndex: Integer from Standard; - FrameColorIndex: Integer from Standard; - FrameWidthIndex: Integer from Standard; - FontIndex: Integer from Standard; - aSlant: PlaneAngle from Quantity = 0.0; - aHScale: Factor from Quantity = 1.0; - aWScale: Factor from Quantity = 1.0; - isUnderlined: Boolean from Standard = Standard_False; - isZoomable: Boolean from Standard = Standard_True) - ---Level: Public - ---Purpose: Methods to define the Current Hiding Text Attributes - -- NOTE that ,if isZoomable is TRUE the text size follow - -- the scale factor of the view and the current transformation - -- scale factor. - raises TransientDefinitionError from Graphic2d is static; - ---Trigger: If a Drawing is not opened. - ---Category: graphic attributes methods - - SetFramedTextAttrib (me: mutable; - ColorIndex: Integer from Standard; - FrameColorIndex: Integer from Standard; - FrameWidthIndex: Integer from Standard; - FontIndex: Integer from Standard; - aSlant: PlaneAngle from Quantity = 0.0; - aHScale: Factor from Quantity = 1.0; - aWScale: Factor from Quantity = 1.0; - isUnderlined: Boolean from Standard = Standard_False; - isZoomable: Boolean from Standard = Standard_True) - ---Level: Public - ---Purpose: Methods to define the Current Framed Text Attributes - -- NOTE that ,if isZoomable is TRUE the text size follow - -- the scale factor of the view and the current transformation - -- scale factor. - raises TransientDefinitionError from Graphic2d is static; - ---Trigger: If a Drawing is not opened. - ---Category: graphic attributes methods - - ---------------------------------------- - -- Category: Geometric attributes methods - ---------------------------------------- - - SetTransform (me : mutable; - aTrsf : in GTrsf2d from gp; - aType : TypeOfComposition from Graphic2d = - Graphic2d_TOC_REPLACE) - ---Level: Public - ---Purpose: Sets the current transformation applied to - -- the primitives. - raises TransientDefinitionError from Graphic2d is static; - ---Trigger: If a Drawing is not opened. - ---Category: geometric attributes methods - - SetMapping(me: mutable; aStatus: Boolean from Standard = Standard_True) - ---Level: Public - ---Purpose: Enable/Disable the mapping conversion between - -- the view and the driver system coordinates. - raises TransientDefinitionError from Graphic2d is static; - ---Trigger: If a Drawing is not opened. - ---Category: geometric attributes methods - - ---------------------------- - -- Category: Inquire methods - ---------------------------- - - MinMax (me; - XMin, YMin : out Length from Quantity; - XMax, YMax : out Length from Quantity) - returns Boolean from Standard is static; - ---Level: Public - ---Purpose: Returns the world coordinates of the boundary box - -- of the Transient graphics actually drawn - -- since BeginDraw() has been call. - -- Warning: If nothing has been drawn then : - -- XMin = YMin = RealFirst (). - -- XMax = YMax = RealLast (). - -- and returns a min-max status to FALSE; - ---Category: Inquire methods - - Transform (me ) returns GTrsf2d from gp is static; - ---Level: Public - ---Purpose: Returns the current transformation. - ---Category: Inquire methods - - ---------------------------- - -- Category: Private methods - ---------------------------- - - Redraw(me : mutable; - aDriver: WindowDriver from Aspect) is static private; - ---Level: Private - ---Purpose: Redraw the view. - ---Category: Private method. - - EnableMinMax(me: mutable; - aStatus: Boolean from Standard = Standard_True ; - Reset: Boolean from Standard = Standard_True) - is static private; - ---Level: Private - ---Purpose: Enable/Disable the min-max computation. - -- and reset the boundary-box if is TRUE. - - MinMax (me; aMinX, aMaxX, aMinY, aMaxY: out Integer from Standard) - returns Boolean from Standard - is static private; - ---Level: Private - ---Purpose: Returns TRUE if the returned pixel space min max - -- boundary box has been computed correctly arround - -- all the primitives drawn in the driver. - -- Warning: the boundary box size cannot be greater that - -- the associated window space size. - -- Returns FALSE if the min-max boundary box is NULL. - -fields - myPView : ViewPtr from Graphic2d; - myTrsf,myCompositeTrsf : GTrsf2d from gp; - myTypeOfComposition : TypeOfComposition from Graphic2d; - myDrawingIsStarted : Boolean from Standard; - myTrsfIsDefined : Boolean from Standard; - myMappingIsEnable : Boolean from Standard; - myTypeOfPrimitive : TypeOfPrimitive from Aspect; - -end TransientManager from Graphic2d; diff --git a/src/Graphic2d/Graphic2d_TransientManager.cxx b/src/Graphic2d/Graphic2d_TransientManager.cxx deleted file mode 100755 index 514161a1c1..0000000000 --- a/src/Graphic2d/Graphic2d_TransientManager.cxx +++ /dev/null @@ -1,1085 +0,0 @@ -// Copyright (c) 1997-1999 Matra Datavision -// Copyright (c) 1999-2012 OPEN CASCADE SAS -// -// The content of this file is subject to the Open CASCADE Technology Public -// License Version 6.5 (the "License"). You may not use the content of this file -// except in compliance with the License. Please obtain a copy of the License -// at http://www.opencascade.org and read it completely before using this file. -// -// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its -// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. -// -// The Original Code and all software distributed under the License is -// distributed on an "AS IS" basis, without warranty of any kind, and the -// Initial Developer hereby disclaims all such warranties, including without -// limitation, any warranties of merchantability, fitness for a particular -// purpose or non-infringement. Please see the License for the specific terms -// and conditions governing the rights and limitations under the License. - -// K4 GG_161297 -// les methodes qui "tirent" GEOMLIGHT disparaissent -// PRO13311 GG_220498 -// Reinitialiser les parametres de vue dans tous les cas -// PRO14041 //GG_150698 -// Reinitialiser la taille de la zone visualisable dans tous -// les cas. - -#define G002 //GG 28/04/00 Add protection on MinMax() methods -// Add perf improvment when the used transient -// 05/05/00 inherits from the current drawer. -// Add DrawElement() DrawVertex() methods. - -#define OCC402 // SAV 14/11/01 Added DrawPickedElements() - highlights picked elements. - -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#define MAXPOINTS 1024 -#define MAXSEGMENTS 1024 - -Graphic2d_TransientManager::Graphic2d_TransientManager ( - const Handle(Graphic2d_View)& aView) : - myPView(aView.operator->()), - myTrsf(),myCompositeTrsf(), - myTypeOfComposition(Graphic2d_TOC_REPLACE), - myDrawingIsStarted(Standard_False), - myTrsfIsDefined(Standard_False), - myMappingIsEnable(Standard_True), - myTypeOfPrimitive(Aspect_TOP_UNKNOWN) -{ -} - -Graphic2d_TransientManager::Graphic2d_TransientManager ( - const Graphic2d_ViewPtr& aView) : - myPView(aView), - myTrsf(),myCompositeTrsf(), - myTypeOfComposition(Graphic2d_TOC_REPLACE), - myDrawingIsStarted(Standard_False), - myTrsfIsDefined(Standard_False), - myMappingIsEnable(Standard_True), - myTypeOfPrimitive(Aspect_TOP_UNKNOWN) -{ -} - -//======================================================================= -Standard_Boolean Graphic2d_TransientManager::BeginDraw( - const Handle(Aspect_WindowDriver)& aDriver, - const Standard_Boolean ClearBefore) { -Standard_Boolean status = Standard_True; -Standard_Boolean reset_minmax = Standard_True; - - if( myDrawingIsStarted ) return Standard_False; - - if( myDriver == aDriver ) { - if( ClearBefore ) { - status = RestoreArea(aDriver); - } else reset_minmax = Standard_False; - } - -#ifdef G002 - Handle(Graphic2d_Drawer) theDrawer = myPView->Drawer(); - Handle(Graphic2d_Drawer) theDrawer1 = this; - if ( theDrawer1 != theDrawer ) -#endif - { - Standard_ShortReal XF, YF, SF, XT, YT, ST, ZF; - theDrawer->Values(XF, YF, SF, XT, YT, ST, ZF); - Graphic2d_Drawer::SetValues(XF, YF, SF, XT, YT, ST, ZF); - - Standard_ShortReal DP, DC; - Aspect_TypeOfDeflection TD; - - theDrawer->DrawPrecision(DP,DC,TD); - Graphic2d_Drawer::SetDrawPrecision(DP,DC,TD); - - Standard_ShortReal TP = theDrawer->TextPrecision(); - Graphic2d_Drawer::SetTextPrecision(TP); - } - - Graphic2d_Drawer::SetDriver(aDriver); - - // Begin new graphics - aDriver->BeginDraw(Standard_False,0); - - this->EnableMinMax(Standard_True,reset_minmax); - - myDrawingIsStarted = Standard_True; - myTrsfIsDefined = Standard_False; - myTypeOfPrimitive = Aspect_TOP_UNKNOWN; - - return status; -} - -//======================================================================= -Standard_Boolean Graphic2d_TransientManager::BeginDraw( - const Handle(Aspect_WindowDriver)& aDriver, - const Handle(Graphic2d_ViewMapping)& aViewMapping, - const Standard_Real aXPosition, - const Standard_Real aYPosition, - const Standard_Real aScale, - const Standard_Boolean ClearBefore) { -Standard_Boolean status = Standard_True; -Standard_Boolean reset_minmax = Standard_True; - - if( myDrawingIsStarted ) return Standard_False; - - if( myDriver == aDriver ) { - if( ClearBefore ) { - status = RestoreArea(aDriver); - } else reset_minmax = Standard_False; - } else { - Graphic2d_Drawer::SetDriver(aDriver); - } - // Set new drawer attributes -#ifdef G002 - Handle(Graphic2d_Drawer) theDrawer = myPView->Drawer(); - Handle(Graphic2d_Drawer) theDrawer1 = this; - if( theDrawer1 != theDrawer ) -#endif - { - Standard_Real XCenter, YCenter, Size; - - aViewMapping->ViewMapping(XCenter, YCenter, Size); - Graphic2d_Drawer::SetValues (XCenter, YCenter, Size, - aXPosition, aYPosition, aScale, aViewMapping->Zoom()); - Standard_ShortReal DP, DC; - Aspect_TypeOfDeflection TD; - - theDrawer->DrawPrecision(DP,DC,TD); - Graphic2d_Drawer::SetDrawPrecision(DP,DC,TD); - - Standard_ShortReal TP = theDrawer->TextPrecision(); - Graphic2d_Drawer::SetTextPrecision(TP); - } - // Begin new graphics - aDriver->BeginDraw(Standard_False,0); - - this->EnableMinMax(Standard_True,reset_minmax); - - myDrawingIsStarted = Standard_True; - myTrsfIsDefined = Standard_False; - myTypeOfPrimitive = Aspect_TOP_UNKNOWN; - - return status; -} - -//======================================================================= -void Graphic2d_TransientManager::EndDraw(const Standard_Boolean Synchronize) { - - if( myDrawingIsStarted ) { - myDriver->EndDraw(Synchronize) ; - myDrawingIsStarted = Standard_False; - this->EnableMinMax(Standard_False,Standard_False); - } -} - -//======================================================================= -Standard_Boolean Graphic2d_TransientManager::Restore( - const Handle(Aspect_WindowDriver)& aDriver) { -Standard_Boolean status = Standard_True; - - if(( status = aDriver->Window()->BackingStore() )) { - // Restore the front view from the back - aDriver->Window()->Restore(); - } else { // Redraw the View - Redraw(aDriver); - } - - return status; -} - -//======================================================================= -Standard_Boolean Graphic2d_TransientManager::RestoreArea( - const Handle(Aspect_WindowDriver)& aDriver) { -Standard_Integer pxmin,pymin,pxmax,pymax; -Standard_Boolean status = Standard_True; - - if( this->MinMax(pxmin,pxmax,pymin,pymax) ) { - if(( status = aDriver->Window()->BackingStore() )) { - // Restore the front view area from the back - aDriver->Window()->RestoreArea((pxmin+pxmax)/2,(pymin+pymax)/2, - pxmax-pxmin+10,pymax-pymin+10); - } else { // Redraw the View - Redraw(aDriver); - } -#ifdef G002 - this->EnableMinMax(Standard_True,Standard_True); -#endif - } - - return status; -} - -//======================================================================= -void Graphic2d_TransientManager::Redraw( - const Handle(Aspect_WindowDriver)& aDriver) { - -Handle(Graphic2d_DisplayList) theDisplayList = myPView->DisplayList(); -Handle(Graphic2d_GraphicObject) theGraphicObject; -Handle(Graphic2d_Drawer) theDrawer = myPView->Drawer(); -Standard_Integer i; - - aDriver->BeginDraw(Standard_True); - aDriver->Window()->Clear(); - for (i=1; i<=theDisplayList->Length(); i++) { - theGraphicObject = theDisplayList->Value(i); - theGraphicObject->Redraw (theDrawer); - } - aDriver->EndDraw(); -} - -//======================================================================= -void Graphic2d_TransientManager::Destroy () { -} - -//======================================================================= -void Graphic2d_TransientManager::Draw ( - const Handle(Graphic2d_Primitive) &aPrimitive) { - - Graphic2d_TransientDefinitionError_Raise_if ( - !myDrawingIsStarted,"Drawing must be started before"); - - Graphic2d_TransientDefinitionError_Raise_if ( - (myTypeOfPrimitive != Aspect_TOP_UNKNOWN),"Bad primitive type"); - - if( myTrsfIsDefined ) { - Handle(Graphic2d_GraphicObject) theGO = - aPrimitive->PGraphicObject(); - gp_GTrsf2d theOldTrsf = theGO->Transform(); - if( theGO->IsTransformed() && // Sets the new transformation - (myTypeOfComposition != Graphic2d_TOC_REPLACE) ) { - gp_GTrsf2d theNewTrsf = myCompositeTrsf.Multiplied(theOldTrsf); - theGO->SetTransform(theNewTrsf); - } else { - theGO->SetTransform(myTrsf); - } - aPrimitive->Draw(this); - theGO->SetTransform(theOldTrsf); // Restore the old - } else { - aPrimitive->Draw(this); - } -} - -//======================================================================= -void Graphic2d_TransientManager::Draw ( - const Handle(Graphic2d_GraphicObject) &aGraphicObject) { - - Graphic2d_TransientDefinitionError_Raise_if ( - !myDrawingIsStarted,"Drawing must be started before"); - - Graphic2d_TransientDefinitionError_Raise_if ( - (myTypeOfPrimitive != Aspect_TOP_UNKNOWN),"Bad primitive type"); - - if( myTrsfIsDefined ) { - gp_GTrsf2d theOldTrsf = aGraphicObject->Transform(); - if( aGraphicObject->IsTransformed() && // Sets the new transformation - (myTypeOfComposition != Graphic2d_TOC_REPLACE) ) { - gp_GTrsf2d theNewTrsf = myCompositeTrsf.Multiplied(theOldTrsf); - aGraphicObject->SetTransform(theNewTrsf); - } else { - aGraphicObject->SetTransform(myTrsf); - } - aGraphicObject->Redraw(this); - aGraphicObject->SetTransform(theOldTrsf); // Restore the old - } else { - aGraphicObject->Redraw(this); - } -} - -#ifdef G002 -//======================================================================= -void Graphic2d_TransientManager::DrawElement ( - const Handle(Graphic2d_Primitive) &aPrimitive, - const Standard_Integer anIndex) { - - Graphic2d_TransientDefinitionError_Raise_if ( - !myDrawingIsStarted,"Drawing must be started before"); - - Graphic2d_TransientDefinitionError_Raise_if ( - (myTypeOfPrimitive != Aspect_TOP_UNKNOWN),"Bad primitive type"); - - if( myTrsfIsDefined ) { - Handle(Graphic2d_GraphicObject) theGO = - aPrimitive->PGraphicObject(); - gp_GTrsf2d theOldTrsf = theGO->Transform(); - if( theGO->IsTransformed() && // Sets the new transformation - (myTypeOfComposition != Graphic2d_TOC_REPLACE) ) { - gp_GTrsf2d theNewTrsf = myCompositeTrsf.Multiplied(theOldTrsf); - theGO->SetTransform(theNewTrsf); - } else { - theGO->SetTransform(myTrsf); - } - aPrimitive->DrawElement(this,anIndex); - theGO->SetTransform(theOldTrsf); // Restore the old - } else { - aPrimitive->DrawElement(this,anIndex); - } -} - - -// SAV -//======================================================================= -void Graphic2d_TransientManager -::DrawPickedElements( const Handle(Graphic2d_Primitive) &aPrimitive ) -{ -#ifdef OCC402 - Graphic2d_TransientDefinitionError_Raise_if( - !myDrawingIsStarted,"Drawing must be started before" ); - - Graphic2d_TransientDefinitionError_Raise_if( - (myTypeOfPrimitive != Aspect_TOP_UNKNOWN),"Bad primitive type"); - - if( myTrsfIsDefined ) { - Handle(Graphic2d_GraphicObject) theGO = - aPrimitive->PGraphicObject(); - gp_GTrsf2d theOldTrsf = theGO->Transform(); - if( theGO->IsTransformed() && // Sets the new transformation - (myTypeOfComposition != Graphic2d_TOC_REPLACE) ) { - gp_GTrsf2d theNewTrsf = myCompositeTrsf.Multiplied(theOldTrsf); - theGO->SetTransform(theNewTrsf); - } else { - theGO->SetTransform(myTrsf); - } - aPrimitive->DrawPickedElements( this ); - theGO->SetTransform(theOldTrsf); // Restore the old - } else { - aPrimitive->DrawPickedElements( this ); - } -#endif -} - -//======================================================================= -void Graphic2d_TransientManager::DrawVertex ( - const Handle(Graphic2d_Primitive) &aPrimitive, - const Standard_Integer anIndex) { - - Graphic2d_TransientDefinitionError_Raise_if ( - !myDrawingIsStarted,"Drawing must be started before"); - - Graphic2d_TransientDefinitionError_Raise_if ( - (myTypeOfPrimitive != Aspect_TOP_UNKNOWN),"Bad primitive type"); - - if( myTrsfIsDefined ) { - Handle(Graphic2d_GraphicObject) theGO = - aPrimitive->PGraphicObject(); - gp_GTrsf2d theOldTrsf = theGO->Transform(); - if( theGO->IsTransformed() && // Sets the new transformation - (myTypeOfComposition != Graphic2d_TOC_REPLACE) ) { - gp_GTrsf2d theNewTrsf = myCompositeTrsf.Multiplied(theOldTrsf); - theGO->SetTransform(theNewTrsf); - } else { - theGO->SetTransform(myTrsf); - } - aPrimitive->DrawVertex(this,anIndex); - theGO->SetTransform(theOldTrsf); // Restore the old - } else { - aPrimitive->DrawVertex(this,anIndex); - } -} -#endif - -//======================================================================= -void Graphic2d_TransientManager::BeginPrimitive ( - const Aspect_TypeOfPrimitive aType, - const Standard_Integer aSize) { - - Graphic2d_TransientDefinitionError_Raise_if ( - !myDrawingIsStarted,"Drawing must be started before"); - - Graphic2d_TransientDefinitionError_Raise_if ( - (myTypeOfPrimitive != Aspect_TOP_UNKNOWN),"A primitive is already open"); - myTypeOfPrimitive = aType; - - switch (myTypeOfPrimitive) { - case Aspect_TOP_UNKNOWN: - break; - case Aspect_TOP_POLYLINE: - myDriver->BeginPolyline((aSize > 0) ? aSize : MAXPOINTS); - break; - case Aspect_TOP_POLYGON: - myDriver->BeginPolygon((aSize > 0) ? aSize : MAXPOINTS); - break; - case Aspect_TOP_SEGMENTS: - myDriver->BeginSegments(); - break; - case Aspect_TOP_ARCS: - myDriver->BeginArcs(); - break; - case Aspect_TOP_POLYARCS: - myDriver->BeginPolyArcs(); - break; - case Aspect_TOP_POINTS: - myDriver->BeginPoints(); - break; - case Aspect_TOP_MARKERS: - myDriver->BeginMarkers(); - break; - } -} - -//======================================================================= -void Graphic2d_TransientManager::ClosePrimitive () { - - Graphic2d_TransientDefinitionError_Raise_if ( - !myDrawingIsStarted,"Drawing must be started before"); - - Graphic2d_TransientDefinitionError_Raise_if ( - (myTypeOfPrimitive == Aspect_TOP_UNKNOWN),"A primitive is not open"); - myDriver->ClosePrimitive(); - - myTypeOfPrimitive = Aspect_TOP_UNKNOWN; -} - -//======================================================================= -void Graphic2d_TransientManager::DrawSegment ( - const Standard_Real X1, - const Standard_Real Y1, - const Standard_Real X2, - const Standard_Real Y2) { - - Graphic2d_TransientDefinitionError_Raise_if ( - !myDrawingIsStarted,"Drawing must be started before"); - - Graphic2d_TransientDefinitionError_Raise_if ( - (myTypeOfPrimitive != Aspect_TOP_UNKNOWN) && - (myTypeOfPrimitive != Aspect_TOP_SEGMENTS),"Bad primitive type"); - - Standard_ShortReal x1 = Standard_ShortReal(X1), - y1 = Standard_ShortReal(Y1), - x2 = Standard_ShortReal(X2), - y2 = Standard_ShortReal(Y2); - if( myTrsfIsDefined ) { - Standard_Real U = x1, V = y1; - myTrsf.Transforms(U,V); - x1 = Standard_ShortReal(U); y1 = Standard_ShortReal(V); - U = x2,V = y2; - myTrsf.Transforms(U,V); - x2 = Standard_ShortReal(U); y2 = Standard_ShortReal(V); - } - if( myMappingIsEnable ) - Graphic2d_Drawer::MapSegmentFromTo(x1,y1,x2,y2); - else - Graphic2d_Drawer::DrawSegment(x1,y1,x2,y2); - -} - -//======================================================================= -void Graphic2d_TransientManager::DrawInfiniteLine ( - const Standard_Real X, - const Standard_Real Y, - const Standard_Real Dx, - const Standard_Real Dy) { - - Graphic2d_TransientDefinitionError_Raise_if ( - !myDrawingIsStarted,"Drawing must be started before"); - - Graphic2d_TransientDefinitionError_Raise_if ( - (myTypeOfPrimitive != Aspect_TOP_UNKNOWN),"Bad primitive type"); - - Standard_ShortReal x = Standard_ShortReal(X), - y = Standard_ShortReal(Y), - dx = Standard_ShortReal(Dx), - dy = Standard_ShortReal(Dy); - if( myTrsfIsDefined ) { - Standard_Real U = x,V = y; - myTrsf.Transforms(U,V); - x = Standard_ShortReal(U); y = Standard_ShortReal(V); - U = dx, V = dy; - myTrsf.Transforms(U,V); - dx = Standard_ShortReal(U) - x; dy = Standard_ShortReal(V) - y; - } - if( myMappingIsEnable ) - Graphic2d_Drawer::MapInfiniteLineFromTo(x,y,dx,dy); - else - Graphic2d_Drawer::DrawInfiniteLine(x,y,dx,dy); -} - -//======================================================================= -void Graphic2d_TransientManager::DrawArc( - const Standard_Real Xc, - const Standard_Real Yc, - const Standard_Real aRadius, - const Standard_Real Angle1, - const Standard_Real Angle2) { - - Graphic2d_TransientDefinitionError_Raise_if ( - !myDrawingIsStarted,"Drawing must be started before"); - - Graphic2d_TransientDefinitionError_Raise_if ( - (myTypeOfPrimitive != Aspect_TOP_UNKNOWN) && - (myTypeOfPrimitive != Aspect_TOP_ARCS),"Bad primitive type"); - - Standard_ShortReal xc = Standard_ShortReal(Xc), - yc = Standard_ShortReal(Yc), - r = Standard_ShortReal(aRadius), - a1 = Standard_ShortReal(Angle1), - a2 = Standard_ShortReal(Angle2); - if( myTrsfIsDefined ) { - Standard_Real U = xc,V = yc; - myTrsf.Transforms(U,V); - xc = Standard_ShortReal(U); yc = Standard_ShortReal(V); - U = r * Cos(a1); V = r * Sin(a1); - myTrsf.Transforms(U,V); U -= Standard_Real(xc); V -= Standard_Real(yc); - r = Standard_ShortReal(Sqrt( U*U + V*V )) ; - Standard_ShortReal a = Standard_ShortReal(atan2(U,V)); - a2 += a - a1; a1 = a; - } - if( myMappingIsEnable ) - Graphic2d_Drawer::MapArcFromTo(xc,yc,r,a1,a2); - else - Graphic2d_Drawer::DrawArc(xc,yc,r,a1,a2); -} - -//======================================================================= -void Graphic2d_TransientManager::DrawPolyArc( - const Standard_Real Xc, - const Standard_Real Yc, - const Standard_Real aRadius, - const Standard_Real Angle1, - const Standard_Real Angle2) { - - Graphic2d_TransientDefinitionError_Raise_if ( - !myDrawingIsStarted,"Drawing must be started before"); - - Graphic2d_TransientDefinitionError_Raise_if ( - (myTypeOfPrimitive != Aspect_TOP_UNKNOWN) && - (myTypeOfPrimitive != Aspect_TOP_POLYARCS),"Bad primitive type"); - - Standard_ShortReal xc = Standard_ShortReal(Xc), - yc = Standard_ShortReal(Yc), - r = Standard_ShortReal(aRadius), - a1 = Standard_ShortReal(Angle1), - a2 = Standard_ShortReal(Angle2); - if( myTrsfIsDefined ) { - Standard_Real U = xc,V = yc; - myTrsf.Transforms(U,V); - xc = Standard_ShortReal(U); yc = Standard_ShortReal(V); - U = r * Cos(a1); V = r * Sin(a1); - myTrsf.Transforms(U,V); U -= Standard_Real(xc); V -= Standard_Real(yc); - r = Standard_ShortReal(Sqrt( U*U + V*V )) ; - Standard_ShortReal a = Standard_ShortReal(atan2(U,V)); - a2 += a - a1; a1 = a; - } - if( myMappingIsEnable ) - Graphic2d_Drawer::MapPolyArcFromTo(xc,yc,r,a1,a2); - else - Graphic2d_Drawer::DrawPolyArc(xc,yc,r,a1,a2); -} - -//======================================================================= -void Graphic2d_TransientManager::DrawPoint ( - const Standard_Real X, const Standard_Real Y) { - - Graphic2d_TransientDefinitionError_Raise_if ( - !myDrawingIsStarted,"Drawing must be started before"); - - Graphic2d_TransientDefinitionError_Raise_if ( - (myTypeOfPrimitive != Aspect_TOP_UNKNOWN) && - (myTypeOfPrimitive != Aspect_TOP_POLYLINE) && - (myTypeOfPrimitive != Aspect_TOP_POLYGON) && - (myTypeOfPrimitive != Aspect_TOP_MARKERS),"Bad primitive type"); - - Standard_ShortReal x = Standard_ShortReal(X), y = Standard_ShortReal(Y); - if( myTrsfIsDefined ) { - Standard_Real U = x,V = y; - myTrsf.Transforms(U,V); - x = Standard_ShortReal(U); y = Standard_ShortReal(V); - } - if( myMappingIsEnable ) - Graphic2d_Drawer::MapMarkerFromTo(0,x,y,0.,0.,0.); - else - Graphic2d_Drawer::DrawMarker(0,x,y,0.,0.,0.); -} - -//======================================================================= -void Graphic2d_TransientManager::DrawMarker( - const Standard_Integer anIndex, - const Standard_Real X, - const Standard_Real Y, - const Standard_Real aWidth, - const Standard_Real anHeight, - const Standard_Real anAngle) { - - Graphic2d_TransientDefinitionError_Raise_if ( - !myDrawingIsStarted,"Drawing must be started before"); - - Graphic2d_TransientDefinitionError_Raise_if ( - (myTypeOfPrimitive != Aspect_TOP_UNKNOWN) && - (myTypeOfPrimitive != Aspect_TOP_MARKERS),"Bad primitive type"); - - Standard_ShortReal x = Standard_ShortReal(X), - y = Standard_ShortReal(Y), - w = Standard_ShortReal(aWidth), - h = Standard_ShortReal(anHeight), - a = Standard_ShortReal(anAngle); - if( myTrsfIsDefined ) { - Standard_Real U = x,V = y; - myTrsf.Transforms(U,V); - x = Standard_ShortReal(U); y = Standard_ShortReal(V); - } - if( myMappingIsEnable ) - Graphic2d_Drawer::MapMarkerFromTo(anIndex,x,y,w,h,a); - else - Graphic2d_Drawer::DrawMarker(anIndex,x,y,w,h,a); -} - -//======================================================================= -void Graphic2d_TransientManager::DrawText( - const TCollection_ExtendedString& aText, - const Standard_Real X, - const Standard_Real Y, - const Standard_Real anAngle, - const Standard_Real aDeltax, - const Standard_Real aDeltay, - const Aspect_TypeOfText aType, - const Graphic2d_TypeOfAlignment anAlignment) { - - Graphic2d_TransientDefinitionError_Raise_if ( - !myDrawingIsStarted,"Drawing must be started before"); - - Graphic2d_TransientDefinitionError_Raise_if ( - (myTypeOfPrimitive != Aspect_TOP_UNKNOWN),"Bad primitive type"); - - Standard_ShortReal x = Standard_ShortReal(X), - y = Standard_ShortReal(Y), - a = Standard_ShortReal(anAngle); - Standard_ShortReal dx = Standard_ShortReal(0.), - dy = Standard_ShortReal(0.), - ox = Standard_ShortReal(aDeltax), - oy = Standard_ShortReal(aDeltay); - - if( anAlignment != Graphic2d_TOA_LEFT ) { - Standard_ShortReal tw,th,txo,tyo; - if( Graphic2d_Drawer::GetTextSize(aText,tw,th,txo,tyo) ) { - switch( anAlignment ) { - case Graphic2d_TOA_LEFT: - dx = Standard_ShortReal(0.); dy = Standard_ShortReal(0.); - break; - case Graphic2d_TOA_RIGHT: - dx = -tw; dy = 0.; - break; - case Graphic2d_TOA_CENTER: - dx = Standard_ShortReal(-tw/2.); dy = 0.; - break; - case Graphic2d_TOA_TOPLEFT: - dx = 0.; dy = tyo-th; - break; - case Graphic2d_TOA_TOPRIGHT: - dx = -tw; dy = tyo-th; - break; - case Graphic2d_TOA_TOPCENTER: - dx = Standard_ShortReal(-tw/2.); dy = Standard_ShortReal(tyo-th); - break; - case Graphic2d_TOA_MEDIUMLEFT: - dx = 0.; dy = Standard_ShortReal((tyo-th)/2.); - break; - case Graphic2d_TOA_MEDIUMRIGHT: - dx = Standard_ShortReal(-tw); dy = Standard_ShortReal((tyo-th)/2.); - break; - case Graphic2d_TOA_MEDIUMCENTER: - dx = Standard_ShortReal(-tw/2.); dy = Standard_ShortReal((tyo-th)/2.); - break; - case Graphic2d_TOA_BOTTOMLEFT: - dx = 0.; dy = tyo; - break; - case Graphic2d_TOA_BOTTOMRIGHT: - dx = -tw; dy = tyo; - break; - case Graphic2d_TOA_BOTTOMCENTER: - dx = Standard_ShortReal(-tw/2.); dy = tyo; - break; - } - } - } - - if( myTrsfIsDefined ) { - Standard_Real U = x,V = y; - myTrsf.Transforms(U,V); - x = Standard_ShortReal(U); y = Standard_ShortReal(V); - U = Cos(a); V = Sin(a); - myTrsf.Transforms(U,V); U -= Standard_Real(x); V -= Standard_Real(y); - a = Standard_ShortReal(atan2(U,V)); - } - if( a != 0. ) { - Standard_ShortReal ax = dx, ay = dy; - Standard_Real cosa = Cos (a); - Standard_Real sina = Sin (a); - dx = Standard_ShortReal(XROTATE(ax,ay)); - dy = Standard_ShortReal(YROTATE(ax,ay)); - } - if( myMappingIsEnable ) - Graphic2d_Drawer::MapTextFromTo(aText,x+dx,y+dy,a,ox,oy,aType); - else - Graphic2d_Drawer::DrawText(aText,x+ox+dx,y+oy+dy,a,aType); -} - -//======================================================================= -void Graphic2d_TransientManager::DrawPolyText( - const TCollection_ExtendedString& aText, - const Standard_Real X, - const Standard_Real Y, - const Standard_Real anAngle, - const Standard_Real aMargin, - const Standard_Real aDeltax, - const Standard_Real aDeltay, - const Aspect_TypeOfText aType, - const Graphic2d_TypeOfAlignment anAlignment) { - - Graphic2d_TransientDefinitionError_Raise_if ( - !myDrawingIsStarted,"Drawing must be started before"); - - Graphic2d_TransientDefinitionError_Raise_if ( - (myTypeOfPrimitive != Aspect_TOP_UNKNOWN),"Bad primitive type"); - - Standard_ShortReal x = Standard_ShortReal(X), y = Standard_ShortReal(Y), - a = Standard_ShortReal(anAngle), m = Standard_ShortReal(aMargin); - Standard_ShortReal dx = 0., dy = 0., ox = Standard_ShortReal(aDeltax), oy = Standard_ShortReal(aDeltay); - - if( anAlignment != Graphic2d_TOA_LEFT ) { - Standard_ShortReal tw,th,txo,tyo; - if( Graphic2d_Drawer::GetTextSize(aText,tw,th,txo,tyo) ) { - switch( anAlignment ) { - case Graphic2d_TOA_LEFT: - dx = 0.; dy = 0.; - break; - case Graphic2d_TOA_RIGHT: - dx = -tw; dy = 0.; - break; - case Graphic2d_TOA_CENTER: - dx = Standard_ShortReal(-tw/2.); dy = 0.; - break; - case Graphic2d_TOA_TOPLEFT: - dx = 0.; dy = tyo-th; - break; - case Graphic2d_TOA_TOPRIGHT: - dx = -tw; dy = tyo-th; - break; - case Graphic2d_TOA_TOPCENTER: - dx = Standard_ShortReal(-tw/2.); dy = tyo-th; - break; - case Graphic2d_TOA_MEDIUMLEFT: - dx = 0.; dy = Standard_ShortReal((tyo-th)/2.); - break; - case Graphic2d_TOA_MEDIUMRIGHT: - dx = -tw; dy = Standard_ShortReal((tyo-th)/2.); - break; - case Graphic2d_TOA_MEDIUMCENTER: - dx = Standard_ShortReal(-tw/2.); dy = Standard_ShortReal((tyo-th)/2.); - break; - case Graphic2d_TOA_BOTTOMLEFT: - dx = 0.; dy = tyo; - break; - case Graphic2d_TOA_BOTTOMRIGHT: - dx = -tw; dy = tyo; - break; - case Graphic2d_TOA_BOTTOMCENTER: - dx = Standard_ShortReal(-tw/2.); dy = tyo; - break; - } - } - } - - if( myTrsfIsDefined ) { - Standard_Real U = x,V = y; - myTrsf.Transforms(U,V); - x = Standard_ShortReal(U); y = Standard_ShortReal(V); - U = Cos(a); V = Sin(a); - myTrsf.Transforms(U,V); U -= Standard_Real(x); V -= Standard_Real(y); - a = Standard_ShortReal(atan2(U,V)); - } - if( a != 0. ) { - Standard_ShortReal ax = dx, ay = dy; - Standard_Real cosa = Cos (a); - Standard_Real sina = Sin (a); - dx = Standard_ShortReal(XROTATE(ax,ay)); - dy = Standard_ShortReal(YROTATE(ax,ay)); - } - if( myMappingIsEnable ) - Graphic2d_Drawer::MapPolyTextFromTo(aText,x+dx,y+dy,a,m,ox,oy,aType); - else - Graphic2d_Drawer::DrawPolyText(aText,x+ox+dx,y+oy+dy,a,m,aType); -} - -//======================================================================= -void Graphic2d_TransientManager::DrawFramedText( - const TCollection_ExtendedString& aText, - const Standard_Real X, - const Standard_Real Y, - const Standard_Real anAngle, - const Standard_Real aMargin, - const Standard_Real aDeltax, - const Standard_Real aDeltay, - const Aspect_TypeOfText aType, - const Graphic2d_TypeOfAlignment anAlignment) { - - Graphic2d_TransientDefinitionError_Raise_if ( - !myDrawingIsStarted,"Drawing must be started before"); - - Graphic2d_TransientDefinitionError_Raise_if ( - (myTypeOfPrimitive != Aspect_TOP_UNKNOWN),"Bad primitive type"); - - Standard_ShortReal x = Standard_ShortReal(X), - y = Standard_ShortReal(Y), - a = Standard_ShortReal(anAngle), - m = Standard_ShortReal(aMargin); - Standard_ShortReal dx = 0., dy = 0., - ox = Standard_ShortReal(aDeltax), oy = Standard_ShortReal(aDeltay); - - if( anAlignment != Graphic2d_TOA_LEFT ) { - Standard_ShortReal tw,th,txo,tyo; - if( Graphic2d_Drawer::GetTextSize(aText,tw,th,txo,tyo) ) { - switch( anAlignment ) { - case Graphic2d_TOA_LEFT: - dx = 0.; dy = 0.; - break; - case Graphic2d_TOA_RIGHT: - dx = -tw; dy = 0.; - break; - case Graphic2d_TOA_CENTER: - dx = Standard_ShortReal(-tw/2.); dy = 0.; - break; - case Graphic2d_TOA_TOPLEFT: - dx = 0.; dy = tyo-th; - break; - case Graphic2d_TOA_TOPRIGHT: - dx = -tw; dy = tyo-th; - break; - case Graphic2d_TOA_TOPCENTER: - dx = Standard_ShortReal(-tw/2.); dy = tyo-th; - break; - case Graphic2d_TOA_MEDIUMLEFT: - dx = 0.; dy = Standard_ShortReal((tyo-th)/2.); - break; - case Graphic2d_TOA_MEDIUMRIGHT: - dx = -tw; dy = Standard_ShortReal((tyo-th)/2.); - break; - case Graphic2d_TOA_MEDIUMCENTER: - dx = Standard_ShortReal(-tw/2.); dy = Standard_ShortReal((tyo-th)/2.); - break; - case Graphic2d_TOA_BOTTOMLEFT: - dx = 0.; dy = tyo; - break; - case Graphic2d_TOA_BOTTOMRIGHT: - dx = -tw; dy = tyo; - break; - case Graphic2d_TOA_BOTTOMCENTER: - dx = Standard_ShortReal(-tw/2.); dy = tyo; - break; - } - } - } - - if( myTrsfIsDefined ) { - Standard_Real U = x,V = y; - myTrsf.Transforms(U,V); - x = Standard_ShortReal(U); y = Standard_ShortReal(V); - U = Cos(a); V = Sin(a); - myTrsf.Transforms(U,V); U -= Standard_Real(x); V -= Standard_Real(y); - a = Standard_ShortReal(atan2(U,V)); - } - if( a != 0. ) { - Standard_ShortReal ax = dx, ay = dy; - Standard_Real cosa = Cos (a); - Standard_Real sina = Sin (a); - dx = Standard_ShortReal(XROTATE(ax,ay)); - dy = Standard_ShortReal(YROTATE(ax,ay)); - } - if( myMappingIsEnable ) - Graphic2d_Drawer::MapFramedTextFromTo(aText,x+dx,y+dy,a,m,ox,oy,aType); - else - Graphic2d_Drawer::DrawFramedText(aText,x+ox+dx,y+oy+dy,a,m,aType); -} - -//======================================================================= -void Graphic2d_TransientManager::SetTextAttrib( - const Standard_Integer ColorIndex, - const Standard_Integer FontIndex, - const Standard_Real aSlant, - const Standard_Real aHScale, - const Standard_Real aWScale, - const Standard_Boolean isUnderlined, - const Standard_Boolean isZoomable) { - - Graphic2d_TransientDefinitionError_Raise_if ( - !myDrawingIsStarted,"Drawing must be started before"); - - Graphic2d_TransientDefinitionError_Raise_if ( - (myTypeOfPrimitive != Aspect_TOP_UNKNOWN),"Bad primitive type"); - - Standard_ShortReal sl = Standard_ShortReal(aSlant), - hsc = (aHScale > 0.) ? Standard_ShortReal(aHScale) : Standard_ShortReal(1.0); - Standard_ShortReal wsc = (aWScale > 0.) ? Standard_ShortReal(aWScale) : hsc; - - if( myTrsfIsDefined ) { - hsc *= Standard_ShortReal((myTrsf(1,1) + myTrsf(2,2))/2.); - wsc *= Standard_ShortReal((myTrsf(1,1) + myTrsf(2,2))/2.); - } - if( isZoomable ) { - hsc *= Graphic2d_Drawer::Scale(); wsc *= Graphic2d_Drawer::Scale(); - } - Graphic2d_Drawer::SetTextAttrib(ColorIndex,FontIndex,sl,hsc,wsc,isUnderlined); - -} - -//======================================================================= -void Graphic2d_TransientManager::SetHidingTextAttrib( - const Standard_Integer ColorIndex, - const Standard_Integer HidingColorIndex, - const Standard_Integer FrameColorIndex, - const Standard_Integer FrameWidthIndex, - const Standard_Integer FontIndex, - const Standard_Real aSlant, - const Standard_Real aHScale, - const Standard_Real aWScale, - const Standard_Boolean isUnderlined, - const Standard_Boolean isZoomable) { - - Graphic2d_TransientDefinitionError_Raise_if ( - !myDrawingIsStarted,"Drawing must be started before"); - - Graphic2d_TransientDefinitionError_Raise_if ( - (myTypeOfPrimitive != Aspect_TOP_UNKNOWN),"Bad primitive type"); - - Standard_ShortReal sl = Standard_ShortReal(aSlant), - hsc = (aHScale > 0.) ? Standard_ShortReal(aHScale) : Standard_ShortReal(1.0); - Standard_ShortReal wsc = (aWScale > 0.) ? Standard_ShortReal(aWScale) : hsc; - if( myTrsfIsDefined ) { - hsc *= Standard_ShortReal((myTrsf(1,1) + myTrsf(2,2))/2.); - wsc *= Standard_ShortReal((myTrsf(1,1) + myTrsf(2,2))/2.); - } - if( isZoomable ) { - hsc *= Graphic2d_Drawer::Scale(); wsc *= Graphic2d_Drawer::Scale(); - } - Graphic2d_Drawer::SetHidingTextAttrib(ColorIndex,HidingColorIndex, - FrameColorIndex,FrameWidthIndex,FontIndex,sl,hsc,wsc,isUnderlined); -} - -//======================================================================= -void Graphic2d_TransientManager::SetFramedTextAttrib( - const Standard_Integer ColorIndex, - const Standard_Integer FrameColorIndex, - const Standard_Integer FrameWidthIndex, - const Standard_Integer FontIndex, - const Standard_Real aSlant, - const Standard_Real aHScale, - const Standard_Real aWScale, - const Standard_Boolean isUnderlined, - const Standard_Boolean isZoomable) { - - Graphic2d_TransientDefinitionError_Raise_if ( - !myDrawingIsStarted,"Drawing must be started before"); - - Graphic2d_TransientDefinitionError_Raise_if ( - (myTypeOfPrimitive != Aspect_TOP_UNKNOWN),"Bad primitive type"); - - Standard_ShortReal sl = Standard_ShortReal(aSlant), hsc = (aHScale > 0.) ? Standard_ShortReal(aHScale) : Standard_ShortReal(1.0); - Standard_ShortReal wsc = (aWScale > 0.) ? Standard_ShortReal(aWScale) : hsc; - if( myTrsfIsDefined ) { - hsc *= Standard_ShortReal((myTrsf(1,1) + myTrsf(2,2))/2.); - wsc *= Standard_ShortReal((myTrsf(1,1) + myTrsf(2,2))/2.); - } - if( isZoomable ) { - hsc *= Graphic2d_Drawer::Scale(); wsc *= Graphic2d_Drawer::Scale(); - } - Graphic2d_Drawer::SetFramedTextAttrib(ColorIndex,FrameColorIndex, - FrameWidthIndex,FontIndex,sl,hsc,wsc,isUnderlined); -} - -//======================================================================= -void Graphic2d_TransientManager::SetTransform ( - const gp_GTrsf2d& aTrsf, - const Graphic2d_TypeOfComposition aType) { - - if( myDrawingIsStarted ) { - Standard_Real re = RealEpsilon (); - if( !myTrsfIsDefined || (aType == Graphic2d_TOC_REPLACE) ) { - myTrsf = aTrsf; - } else { - myTrsf = aTrsf.Multiplied(myTrsf); - } - myTypeOfComposition = aType; - myCompositeTrsf = aTrsf; - myTrsfIsDefined = - (Abs (myCompositeTrsf.Value (1, 1) - 1.0) > re) || - (Abs (myCompositeTrsf.Value (1, 2) - 0.0) > re) || - (Abs (myCompositeTrsf.Value (1, 3) - 0.0) > re) || - (Abs (myCompositeTrsf.Value (2, 1) - 0.0) > re) || - (Abs (myCompositeTrsf.Value (2, 2) - 1.0) > re) || - (Abs (myCompositeTrsf.Value (2, 3) - 0.0) > re); - } else { - Graphic2d_TransientDefinitionError::Raise ("Drawing must be started"); - } -} - -//======================================================================= -void Graphic2d_TransientManager::SetMapping(const Standard_Boolean aStatus) { - - myMappingIsEnable = aStatus; -} - -//======================================================================= -void Graphic2d_TransientManager::EnableMinMax(const Standard_Boolean aStatus, - const Standard_Boolean Reset) { - myMinMaxIsActivated = aStatus; - if( Reset ) { - myMinX = myMinY = ShortRealLast(); - myMaxX = myMaxY = ShortRealFirst(); - } -} - -//======================================================================= -Standard_Boolean Graphic2d_TransientManager::MinMax ( - Standard_Real &XMin, Standard_Real &YMin, - Standard_Real &XMax, Standard_Real &YMax) const { - -#ifdef G002 - if( myMaxX < myMinX || myMaxY < myMinY ) return Standard_False; -#endif - Standard_ShortReal xmin = Max(myMinX,Standard_ShortReal(0.)); - Standard_ShortReal ymin = Max(myMinY,Standard_ShortReal(0.)); - Standard_ShortReal xmax = Min(myMaxX,mySpaceWidth); - Standard_ShortReal ymax = Min(myMaxY,mySpaceHeight); - - if( xmax > xmin && ymax > ymin ) { - Standard_ShortReal uxmin,uymin,uxmax,uymax; - Graphic2d_Drawer::UnMapFromTo(xmin,ymin,uxmin,uymin); - Graphic2d_Drawer::UnMapFromTo(xmax,ymax,uxmax,uymax); - XMin = uxmin; YMin = uymin; XMax = uxmax; YMax = uymax; - return Standard_True; - } else { - XMin = YMin = RealLast(); - XMax = YMax = RealFirst(); - return Standard_False; - } -} - -//======================================================================= -Standard_Boolean Graphic2d_TransientManager::MinMax( - Standard_Integer &aMinX, - Standard_Integer &aMaxX, - Standard_Integer &aMinY, - Standard_Integer &aMaxY)const -{ - if (! myDriverIsDefined) - Graphic2d_TransientDefinitionError::Raise ("No defined driver"); -#ifdef G002 - if( myMaxX < myMinX || myMaxY < myMinY ) return Standard_False; -#endif - - Standard_ShortReal xmin = Max(myMinX,Standard_ShortReal(0.)); - Standard_ShortReal ymin = Max(myMinY,Standard_ShortReal(0.)); - Standard_ShortReal xmax = Min(myMaxX,mySpaceWidth); - Standard_ShortReal ymax = Min(myMaxY,mySpaceHeight); - - myDriver->Convert(xmin,ymin,aMinX,aMaxY); - myDriver->Convert(xmax,ymax,aMaxX,aMinY); - if( aMaxX > aMinX && aMaxY > aMinY ) return Standard_True; - else return Standard_False; -} diff --git a/src/Graphic2d/Graphic2d_VectorialMarker.cdl b/src/Graphic2d/Graphic2d_VectorialMarker.cdl deleted file mode 100755 index 436bcc494b..0000000000 --- a/src/Graphic2d/Graphic2d_VectorialMarker.cdl +++ /dev/null @@ -1,99 +0,0 @@ --- Created on: 1993-06-22 --- Created by: Jean Louis FRENKEL --- Copyright (c) 1993-1999 Matra Datavision --- Copyright (c) 1999-2012 OPEN CASCADE SAS --- --- The content of this file is subject to the Open CASCADE Technology Public --- License Version 6.5 (the "License"). You may not use the content of this file --- except in compliance with the License. Please obtain a copy of the License --- at http://www.opencascade.org and read it completely before using this file. --- --- The Initial Developer of the Original Code is Open CASCADE S.A.S., having its --- main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. --- --- The Original Code and all software distributed under the License is --- distributed on an "AS IS" basis, without warranty of any kind, and the --- Initial Developer hereby disclaims all such warranties, including without --- limitation, any warranties of merchantability, fitness for a particular --- purpose or non-infringement. Please see the License for the specific terms --- and conditions governing the rights and limitations under the License. - - - --- Modified: Jeudi 26 Janvier 1995 --- by: CAL --- The old name of this was Marker. - -deferred class VectorialMarker from Graphic2d inherits Line from Graphic2d - - ---Version: - - ---Purpose: Groups all the primitives which behaves like - -- geometrical marker. - -- for example : EllipsMarker, CircleMarker ... - -- A marker is a primitive which retains its original - -- on-screen size no matter how the view is zoomed. - -- For example, markers are used as symbols of dimension. - -- Every marker takes a reference point as an argument in - -- its constructor. CircleMarker and EllipsMarker take - -- another point as the center and PolylineMarker takes the - -- first point of its list as its origin. - -- The coordinates of the centre or origin point are offsets - -- with respect to the reference point. - - ---Keywords: Primitive, VectorialMarker - ---Warning: - ---References: - -uses - GraphicObject from Graphic2d, - Length from Quantity - -is - ------------------------- - -- Category: Constructors - ------------------------- - - Initialize (aGraphicObject: GraphicObject from Graphic2d; - aXPosition, aYPosition: Length from Quantity); - ---Level: Public - ---Purpose: Creates a marker at , - ---Category: Constructors - - --------------------------------------------------- - -- Category: Methods to modify the class definition - --------------------------------------------------- - - SetPosition (me: mutable; - aXPosition, aYPosition: Length from Quantity) - is static; - ---Level: Public - ---Purpose: Modifies the marker position. - -- Warning: If the associated GraphicObject is transformed - -- the position will be transformed. - ---Category: Methods to modify the class definition - - ---------------------------- - -- Category: Inquire methods - ---------------------------- - - XPosition (me) returns Length from Quantity - is static; - ---Level: Public - ---Purpose: Returns the x position of the marker - -- Warning: If the associated GraphicObject is transformed - -- the returned position is the transformed position. - ---Category: Inquire methods - - YPosition (me) returns Length from Quantity is static; - ---Level: Public - ---Purpose: Returns the y position of the marker - -- Warning: If the associated GraphicObject is transformed - -- the returned position is the transformed position. - ---Category: Inquire methods - -fields - myXPosition: ShortReal from Standard is protected; - myYPosition: ShortReal from Standard is protected; - -end VectorialMarker from Graphic2d; diff --git a/src/Graphic2d/Graphic2d_VectorialMarker.cxx b/src/Graphic2d/Graphic2d_VectorialMarker.cxx deleted file mode 100755 index d7b1f7aa34..0000000000 --- a/src/Graphic2d/Graphic2d_VectorialMarker.cxx +++ /dev/null @@ -1,65 +0,0 @@ -// Copyright (c) 1995-1999 Matra Datavision -// Copyright (c) 1999-2012 OPEN CASCADE SAS -// -// The content of this file is subject to the Open CASCADE Technology Public -// License Version 6.5 (the "License"). You may not use the content of this file -// except in compliance with the License. Please obtain a copy of the License -// at http://www.opencascade.org and read it completely before using this file. -// -// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its -// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. -// -// The Original Code and all software distributed under the License is -// distributed on an "AS IS" basis, without warranty of any kind, and the -// Initial Developer hereby disclaims all such warranties, including without -// limitation, any warranties of merchantability, fitness for a particular -// purpose or non-infringement. Please see the License for the specific terms -// and conditions governing the rights and limitations under the License. - -#include - -Graphic2d_VectorialMarker::Graphic2d_VectorialMarker (const Handle(Graphic2d_GraphicObject)& aGraphicObject, const Quantity_Length aXPosition, const Quantity_Length aYPosition) - - :Graphic2d_Line (aGraphicObject), - myXPosition (Standard_ShortReal (aXPosition)), - myYPosition (Standard_ShortReal (aYPosition)) { - - SetFamily(Graphic2d_TOP_MARKER); -} - -void Graphic2d_VectorialMarker::SetPosition (const Quantity_Length aXPosition, const Quantity_Length aYPosition) { - - myXPosition = Standard_ShortReal (aXPosition); - myYPosition = Standard_ShortReal (aYPosition); - ResetIndex (); - -} - -Quantity_Length Graphic2d_VectorialMarker::XPosition () const { - -Standard_Real X = Standard_Real (myXPosition); -Standard_Real Y = Standard_Real (myYPosition); - - if (myGOPtr->IsTransformed ()) { -gp_GTrsf2d aTrsf = myGOPtr->Transform (); - aTrsf.Transforms (X, Y); - } - - return Quantity_Length (X); - -} - -Quantity_Length Graphic2d_VectorialMarker::YPosition () const { - -Standard_Real X = Standard_Real (myXPosition); -Standard_Real Y = Standard_Real (myYPosition); - - if (myGOPtr->IsTransformed ()) { -gp_GTrsf2d aTrsf = myGOPtr->Transform (); - aTrsf.Transforms (X, Y); - } - - return Quantity_Length (Y); - -} - diff --git a/src/Graphic2d/Graphic2d_Vertex.cdl b/src/Graphic2d/Graphic2d_Vertex.cdl deleted file mode 100755 index 8c0b1efc34..0000000000 --- a/src/Graphic2d/Graphic2d_Vertex.cdl +++ /dev/null @@ -1,126 +0,0 @@ --- Created by: CAL --- Copyright (c) 1993-1999 Matra Datavision --- Copyright (c) 1999-2012 OPEN CASCADE SAS --- --- The content of this file is subject to the Open CASCADE Technology Public --- License Version 6.5 (the "License"). You may not use the content of this file --- except in compliance with the License. Please obtain a copy of the License --- at http://www.opencascade.org and read it completely before using this file. --- --- The Initial Developer of the Original Code is Open CASCADE S.A.S., having its --- main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. --- --- The Original Code and all software distributed under the License is --- distributed on an "AS IS" basis, without warranty of any kind, and the --- Initial Developer hereby disclaims all such warranties, including without --- limitation, any warranties of merchantability, fitness for a particular --- purpose or non-infringement. Please see the License for the specific terms --- and conditions governing the rights and limitations under the License. - - - -class Vertex from Graphic2d - - ---Version: - - ---Purpose: This class allows the creation and update of a - -- 2D point. - - ---Keywords: Vertex, Coordinate, Point - ---Warning: - ---References: - -uses - Drawer from Graphic2d, - Length from Quantity - -is - ------------------------- - -- Category: Constructors - ------------------------- - - Create - returns Vertex from Graphic2d; - ---Level: Public - ---Purpose: Creates a point with 0.0, 0.0 coordinates. - - Create (AX, AY: Real from Standard) - returns Vertex from Graphic2d; - ---Level: Public - ---Purpose: Creates a point with , coordinates. - - Create (AX, AY: ShortReal from Standard) - returns Vertex from Graphic2d; - ---Level: Public - ---Purpose: Creates a point with , coordinates. - - --------------------------------------------------- - -- Category: Methods to modify the class definition - --------------------------------------------------- - - SetCoord (me: in out; - Xnew, Ynew: Length from Quantity) - is static; - ---Level: Public - ---Purpose: Modifies the coordinates of the point . - ---Category: Methods to modify the class definition - - SetXCoord (me: in out; - Xnew: Length from Quantity) - is static; - ---Level: Public - ---Purpose: Modifies the X coordinate of the point . - ---Category: Methods to modify the class definition - - SetYCoord (me: in out; - Ynew: Length from Quantity) - is static; - ---Level: Public - ---Purpose: Modifies the Y coordinate of the point . - ---Category: Methods to modify the class definition - - ---------------------------- - -- Category: Inquire methods - ---------------------------- - - Coord (me; - AX, AY: out Length from Quantity) - is static; - ---Level: Public - ---Purpose: Returns the coordinates of the point . - ---Category: Inquire methods - - X (me) returns Length from Quantity - is static; - ---Level: Public - ---Purpose: Returns the X coordinates of the point . - ---Category: Inquire methods - - Y (me) returns Length from Quantity - is static; - ---Level: Public - ---Purpose: Returns the Y coordinate of the point . - ---Category: Inquire methods - - IsEqual (me ; other : Vertex) returns Boolean - is static; - ---Level: Public - ---Purpose: Test if and are the the same vertex. - ---C++: alias operator == - - -------------------------- - -- Category: Class methods - -------------------------- - - Distance (myclass; - AV1, AV2: Vertex from Graphic2d) - returns Length from Quantity; - ---Level: Public - ---Purpose: Returns the distance between and . - ---Category: Class methods - -fields - myX: ShortReal from Standard; - myY: ShortReal from Standard; - -end Vertex from Graphic2d; diff --git a/src/Graphic2d/Graphic2d_Vertex.cxx b/src/Graphic2d/Graphic2d_Vertex.cxx deleted file mode 100755 index 20914c3275..0000000000 --- a/src/Graphic2d/Graphic2d_Vertex.cxx +++ /dev/null @@ -1,124 +0,0 @@ -// Created by: CAL -// Copyright (c) 1993-1999 Matra Datavision -// Copyright (c) 1999-2012 OPEN CASCADE SAS -// -// The content of this file is subject to the Open CASCADE Technology Public -// License Version 6.5 (the "License"). You may not use the content of this file -// except in compliance with the License. Please obtain a copy of the License -// at http://www.opencascade.org and read it completely before using this file. -// -// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its -// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. -// -// The Original Code and all software distributed under the License is -// distributed on an "AS IS" basis, without warranty of any kind, and the -// Initial Developer hereby disclaims all such warranties, including without -// limitation, any warranties of merchantability, fitness for a particular -// purpose or non-infringement. Please see the License for the specific terms -// and conditions governing the rights and limitations under the License. - - - - -//-Version - -//-Design Declaration des variables specifiques aux points - -//-Warning Un point est defini par ses coordonnees - -//-References - -//-Language C++ 2.0 - -//-Declarations - -// for the class -#include - -//-Aliases - -//-Global data definitions -static Standard_ShortReal epsilon = ShortRealEpsilon(); - -// -- les coordonnees du point -// myX : Standard_ShortReal; -// myY : Standard_ShortReal; - -//-Constructors - -//-Destructors - -//-Methods, in order - -Graphic2d_Vertex::Graphic2d_Vertex () { - - myX = 0.0; - myY = 0.0; - -} - -Graphic2d_Vertex::Graphic2d_Vertex (const Quantity_Length X, const Quantity_Length Y) { - - myX = Standard_ShortReal (X); - myY = Standard_ShortReal (Y); - -} - -Graphic2d_Vertex::Graphic2d_Vertex (const Standard_ShortReal X, const Standard_ShortReal Y) { - - myX = X; - myY = Y; - -} - -void Graphic2d_Vertex::Coord (Quantity_Length& X, Quantity_Length& Y) const { - - X = Quantity_Length (myX); - Y = Quantity_Length (myY); - -} - -Quantity_Length Graphic2d_Vertex::X () const { - - return (Quantity_Length (myX)); - -} - -Quantity_Length Graphic2d_Vertex::Y () const { - - return (Quantity_Length (myY)); - -} - -Standard_Boolean Graphic2d_Vertex::IsEqual(const Graphic2d_Vertex &other) const { - - if( (Abs(myX - other.myX) > epsilon) || - (Abs(myY - other.myY) > epsilon) ) return Standard_False; - else return Standard_True; -} - -void Graphic2d_Vertex::SetCoord (const Quantity_Length Xnew, const Quantity_Length Ynew) { - - myX = Standard_ShortReal (Xnew); - myY = Standard_ShortReal (Ynew); - -} - -void Graphic2d_Vertex::SetXCoord (const Quantity_Length Xnew) { - - myX = Standard_ShortReal (Xnew); - -} - -void Graphic2d_Vertex::SetYCoord (const Quantity_Length Ynew) { - - myY = Standard_ShortReal (Ynew); - -} - -Quantity_Length Graphic2d_Vertex::Distance (const Graphic2d_Vertex& AV1, const Graphic2d_Vertex& AV2) { - - return (sqrt ( (AV1.X () - AV2.X ()) * (AV1.X () - AV2.X ()) - + (AV1.Y () - AV2.Y ()) * (AV1.Y () - AV2.Y ()))); - -} diff --git a/src/Graphic2d/Graphic2d_View.cdl b/src/Graphic2d/Graphic2d_View.cdl deleted file mode 100755 index 00f27861b6..0000000000 --- a/src/Graphic2d/Graphic2d_View.cdl +++ /dev/null @@ -1,502 +0,0 @@ --- Created on: 1993-07-13 --- Created by: Jean Louis FRENKEL --- Copyright (c) 1993-1999 Matra Datavision --- Copyright (c) 1999-2012 OPEN CASCADE SAS --- --- The content of this file is subject to the Open CASCADE Technology Public --- License Version 6.5 (the "License"). You may not use the content of this file --- except in compliance with the License. Please obtain a copy of the License --- at http://www.opencascade.org and read it completely before using this file. --- --- The Initial Developer of the Original Code is Open CASCADE S.A.S., having its --- main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. --- --- The Original Code and all software distributed under the License is --- distributed on an "AS IS" basis, without warranty of any kind, and the --- Initial Developer hereby disclaims all such warranties, including without --- limitation, any warranties of merchantability, fitness for a particular --- purpose or non-infringement. Please see the License for the specific terms --- and conditions governing the rights and limitations under the License. - - - ---- SAV 14/11/01 Added PickByCircle(). - -class View from Graphic2d inherits TShared from MMgt - - ---Version: - - ---Purpose: A View is a graphic object manager. - - ---Keywords: - ---Warning: - ---References: - -uses - Buffer from Graphic2d, - GraphicObject from Graphic2d, - Primitive from Graphic2d, - DisplayList from Graphic2d, - SequenceOfGraphicObject from Graphic2d, - SequenceOfBuffer from Graphic2d, - Drawer from Graphic2d, - ViewMapping from Graphic2d, - TransientManager from Graphic2d, - TypeOfDeflection from Aspect, - Driver from Aspect, - WindowDriver from Aspect, - Length from Quantity, - SequenceOfInteger from TColStd, - PickMode from Graphic2d - -raises - - OverrideColorError from Graphic2d - -is - ------------------------- - -- Category: Constructors - ------------------------- - - Create - returns mutable View from Graphic2d; - ---Level: Public - ---Purpose: Creates a view. - -- A view is a set of graphic objects. - -- The view manages this set. - - --------------------------------------------------- - -- Category: Methods to modify the class definition - --------------------------------------------------- - - Add (me: mutable; - aBuffer: Buffer from Graphic2d) - is static private; - ---Level: Internal - ---Purpose: Adds the grafic buffer in the - -- view . - -- Warning: Called by the constructor of - ---Category: Methods to modify the class definition - - Add (me: mutable; - aGraphicObject: GraphicObject from Graphic2d; - anAltitude: Integer from Standard = 1) - returns Integer is static private; - ---Level: Internal - ---Purpose: Adds the graphic object in the - -- view at the altitude . - -- and returns the rank of the object in the display-list. - -- Warning: Called by the constructor of - ---Category: Methods to modify the class definition - - Change (me: mutable; - aGraphicObject: GraphicObject from Graphic2d; - anAltitude: Integer from Standard) - returns Integer is static private; - ---Level: Internal - ---Purpose: Changes the altitude of - -- the graphic object - -- and returns the updated rank of the object in the display-list. - ---Category: Methods to modify the class definition - - Remove (me: mutable; - aGraphicObject: GraphicObject from Graphic2d) - returns Integer is static private; - ---Level: Internal - ---Purpose: Removes the graphic object from - -- the view . - -- and returns the previous rank of the deleted object in the display-list. - ---Category: Methods to modify the class definition - - Remove (me: mutable; - aBuffer: Buffer from Graphic2d) - is static private; - ---Level: Internal - ---Purpose: Removes the graphic buffer from - -- the view . - ---Category: Methods to modify the class definition - - Remove (me: mutable) - is static; - ---Level: Public - ---Purpose: Removes all the graphic objects from the view . - ---Category: Methods to modify the class definition - - Erase (me: mutable) - is static; - ---Level: Public - ---Purpose: Forbids the drawing of all graphic objects in . - ---Category: Methods to modify the class definition - - Erase (me: mutable; - aGraphicObject: GraphicObject from Graphic2d) - is static private; - ---Level: Public - ---Purpose: Forbids the drawing of the specified graphic object in . - ---Category: Methods to modify the class definition - - Destroy (me: mutable) - is static; - ---Level: Public - ---Purpose: Deletes - ---Category: Methods to modify the class definition - ---C++: alias ~ - - ------------------- - -- Category: Update - ------------------- - - Update (me: mutable; - aDriver: Driver from Aspect; - aViewMapping: ViewMapping from Graphic2d; - aXPosition, aYPosition: Real from Standard; - aScale: Real from Standard; - ClearBefore: Boolean from Standard = Standard_True) - is static; - ---Level: Public - ---Purpose: Fully updates the driver in function of - -- modifications of the graphic objects displayed - -- in the view . - -- defines the "map from". - -- , , define the "map to". - -- The entire window which supporting the view will be - -- cleared before if flag is TRUE. - ---Category: Update - - TinyUpdate (me: mutable; - aDriver: Driver from Aspect; - aViewMapping: ViewMapping from Graphic2d; - aXPosition, aYPosition: Real from Standard; - aScale: Real from Standard; - Reset: Boolean from Standard = Standard_False) - is static; - ---Level: Public - ---Purpose: Partially updates the driver in function of - -- modifications of the graphic objects displayed - -- in the view with the defined mapping parameters - -- and reset the update pointer if is TRUE. - -- Warning: Only the new primitives created since the last Update - -- are drawn. All others primitives are in the fixed - -- background. - ---Category: Update - - Update (me: mutable; - aDriver: Driver from Aspect; - aGraphicObject: GraphicObject from Graphic2d; - aViewMapping: ViewMapping from Graphic2d; - aXPosition, aYPosition: Real from Standard; - aScale: Real from Standard) - is static; - ---Level: Public - ---Purpose: Partially updates the driver with - -- the graphic object in the - -- the view with the defined mapping parameters. - ---Category: Update - - Update (me: mutable; - aDriver: Driver from Aspect; - aPrimitive: Primitive from Graphic2d; - aViewMapping: ViewMapping from Graphic2d; - aXPosition, aYPosition: Real from Standard; - aScale: Real from Standard) - is static; - ---Level: Public - ---Purpose: Partially updates the driver with - -- the primitive in the - -- the view with the defined mapping parameters. - ---Category: Update - - ---------------------------- - -- Category: Inquire methods - ---------------------------- - - DisplayList (me) - returns DisplayList from Graphic2d - is static; - ---Level: Public - ---Purpose: Returns the list of graphic objects displayed in . - ---Category: Inquire methods - - IsIn (me; aGraphicObject: GraphicObject from Graphic2d) - returns Boolean from Standard - is static; - ---Level: Public - ---Purpose: Returns Standard_True if the graphic object - -- is displayed in , - -- Standard_False if not. - ---Category: Inquire methods - - MinMax (me; aList: DisplayList from Graphic2d; - Minx, Maxx, Miny, Maxy: out Length from Quantity) - is static; - ---Level: Public - ---Purpose: Returns the coordinates of the boundary box of all - -- graphic objects referenced in the list . - -- Warning: All markers are ignored. - -- Warning: If is empty or contains markers and nothing else - -- returns Minx = Miny = RealLast () and - -- returns Maxx = Maxy = RealFirst () - ---Category: Inquire methods - - MinMax (me; Minx, Maxx, Miny, Maxy: out Length from Quantity) - is static; - ---Level: Public - ---Purpose: Returns the coordinates of the boundary box of all - -- graphic objects displayed in the view . - -- Warning: All markers are ignored. - -- Warning: If is empty or contains markers and nothing else - -- returns Minx = Miny = RealLast () and - -- returns Maxx = Maxy = RealFirst () - ---Category: Inquire methods - - MarkerMinMax (me; aList: DisplayList from Graphic2d; - Minx, Maxx, Miny, Maxy: out Length from Quantity) - is static; - ---Level: Public - ---Purpose: Returns the coordinates of the boundary box of all - -- markers referenced in the graphic objects referenced - -- in the list . - -- Warning: If is empty or without markers - -- returns Minx = Miny = RealLast () and - -- returns Maxx = Maxy = RealFirst () - ---Category: Inquire methods - - MarkerMinMax (me; Minx, Maxx, Miny, Maxy: out Length from Quantity) - is static; - ---Level: Public - ---Purpose: Returns the coordinates of the boundary box of all - -- markers referenced in the graphic objects displayed - -- in the view . - -- Warning: If is empty or without markers - -- returns Minx = Miny = RealLast () and - -- returns Maxx = Maxy = RealFirst () - ---Category: Inquire methods - - Position (me; - aGraphicObject: GraphicObject from Graphic2d) - returns Integer is static private; - ---Level: Internal - ---Purpose: Returns the rank of - -- the graphic object in the display-list. - ---Category: Inquire methods - - Altitude (me; - aGraphicObject: GraphicObject from Graphic2d) - returns Integer is static private; - ---Level: Internal - ---Purpose: Returns the altitude of - -- the graphic object in the display-list. - ---Category: Inquire methods - - ----------------- - -- Category: Pick - ----------------- - --- Pick (me; aViewMapping: ViewMapping from Graphic2d; - Pick (me : mutable; aViewMapping: ViewMapping from Graphic2d; - X, Y, aPrecision: Real from Standard; - aXPosition, aYPosition: Real from Standard; - aScale: Real from Standard) - returns DisplayList from Graphic2d - is static; - ---Level: Internal - ---Purpose: Returns the list of graphic objects picked. - - ---SAV - PickByCircle(me : mutable; aViewMapping : ViewMapping from Graphic2d; - X, Y, Radius : Real from Standard; - aXPosition, aYPosition : Real from Standard; - aScale: Real from Standard) - returns DisplayList from Graphic2d - is static; - ---Level: Internal - ---Purpose: Returns the list of graphic objects picked. - - - Pick( me: mutable; aViewMapping: ViewMapping from Graphic2d; - Xmin, Ymin, Xmax, Ymax: Real from Standard; - aXPosition, aYPosition: Real from Standard; - aScale: Real from Standard; - aPickMode: PickMode from Graphic2d = Graphic2d_PM_INCLUDE ) - returns DisplayList from Graphic2d; - - ---Level: Internal - ---Purpose: Returns Standard_True if the primitive is: - -- included in rectangle (), - -- excluded from rectangle (), - -- intersected by rectangle (), - -- defined by Xmin, Ymin, Xmax, Ymax. - -- Standard_False if not. - - --------------------------------- - -- Category: Highlight management - --------------------------------- - - DefaultOverrideColor (me) - returns Integer from Standard - ---Level: Public - ---Purpose: Returns the override color index. - ---Category: Highlight management - ---Warning: Raises OverrideColorError if the - -- override color index is not defined. - raises OverrideColorError from Graphic2d is static; - - IsDefinedColor (me) - returns Boolean from Standard - is static; - ---Level: Public - ---Purpose: Returns Standard_True if the override color index - -- is defined, Standard_False if not. - ---Category: Highlight management - - SetDefaultOverrideColor (me: mutable; - anIndex: Integer from Standard) - is static; - ---Level: Public - ---Purpose: Sets the override color index. - ---Category: Highlight management - - ---------------------------------- - -- Category: Deflection Management - ---------------------------------- - - -------------------------------------------------------- - -- Summary of Chordal Deflection -- - -- -- - -- All drawings of curves or circles are made with -- - -- respect to a maximal chordal deflection. -- - -- -- - -- The absolute deflection is given through the -- - -- method: SetDeflection. -- - -- -- - -- The relative deflection is given through the -- - -- method: SetDeflectionCoefficient -- - -- In this case the deflection will be : -- - -- SizeOfObject * DeflectionCoefficient -- - -- -- - -------------------------------------------------------- - - SetTypeOfDeflection (me: mutable; - aTypeOfDeflection: TypeOfDeflection from Aspect = - Aspect_TOD_RELATIVE) - is static; - ---Level: Internal - ---Purpose: by default: TOD_RELATIVE; - -- However, except for the shapes, the drawing will be - -- made using the absolute deflection. - ---Category: Deflection Management - - TypeOfDeflection(me) - returns TypeOfDeflection from Aspect - is static; - ---Level: Internal - ---Purpose: Returns the deflection type. - ---Category: Deflection Management - - SetDeflection (me: mutable; aDeflection: Length from Quantity = 0.001) - is static; - ---Level: Internal - ---Purpose: Sets the absolute deflection value. - ---Category: Deflection Management - - Deflection (me) - returns Real from Standard - is static; - ---Level: Internal - ---Purpose: Returns the absolute deflection value. - ---Category: Deflection Management - - SetDeflectionCoefficient (me: mutable; - aCoefficient: Real from Standard = 0.00033) - is static; - ---Level: Internal - ---Purpose: Sets the relative deflection coefficient. - -- default value = 0.00033 - ---Category: Deflection Management - - DeflectionCoefficient (me) - returns Real from Standard - is static; - ---Level: Internal - ---Purpose: Returns the relative deflection coefficient. - ---Category: Deflection Management - - SetTextPrecision (me: mutable; aPrecision: Real from Standard = 0.0015) - is static; - ---Level: Internal - ---Purpose: Sets the MIN viewable text height precision in Device space, - -- the texts whose the size is < to this precision - -- is drawn at screen with an outlined or filled rectangle. - -- The default text precision value is 0.0015 - ---Category: Text Management - - TextPrecision (me) - returns Real from Standard - is static; - ---Level: Internal - ---Purpose: Returns the text precision. - ---Category: Text Management - - ---------------------------- - -- Category: Convert methods - ---------------------------- - - Convert (me; aViewMapping: ViewMapping from Graphic2d; - aDrawPositionX, aDrawPositionY: Real from Standard; - aXPosition, aYPosition: Real from Standard; - aScale: Real from Standard; - aX, aY: out Real from Standard) - is static; - ---Level: Internal - ---Purpose: ???? - ---Category: Convert methods - - Convert (me; aViewMapping: ViewMapping from Graphic2d; - aScalar: Real from Standard; aScale: Real from Standard) - returns Real from Standard - is static; - ---Level: Internal - ---Purpose: ???? - ---Category: Convert methods - - ---------------------- - -- Category: Inquiries - ---------------------- - - Drawer(me) returns mutable Drawer from Graphic2d is static; - ---Level: Internal - ---Purpose: Returns the attached drawer of this view. - ---Category: Inquiries - -fields - myGraphicObjects: SequenceOfGraphicObject from Graphic2d; - myGraphicAltitudes: SequenceOfInteger from TColStd; - myBuffers: SequenceOfBuffer from Graphic2d; - myPickList: DisplayList from Graphic2d; - - myDefaultOverrideColor: Integer from Standard; - myOverrideColorIsDef: Boolean from Standard; - - myDeflection: Length from Quantity; - myDeflectionCoefficient: Real from Standard; - myTypeOfDeflection: TypeOfDeflection from Aspect; - --- myDrawer: Drawer from Graphic2d; - myDrawer: TransientManager from Graphic2d; - - myXCenter: ShortReal from Standard; - myYCenter: ShortReal from Standard; - mySize: ShortReal from Standard; - myXPosition: ShortReal from Standard; - myYPosition: ShortReal from Standard; - myScale: ShortReal from Standard; - myZoom: ShortReal from Standard; - myTextPrecision:ShortReal from Standard; - -friends - - class GraphicObject from Graphic2d, - class Buffer from Graphic2d, - class Primitive from Graphic2d - -end View from Graphic2d; diff --git a/src/Graphic2d/Graphic2d_View.cxx b/src/Graphic2d/Graphic2d_View.cxx deleted file mode 100755 index d8a7d9808e..0000000000 --- a/src/Graphic2d/Graphic2d_View.cxx +++ /dev/null @@ -1,763 +0,0 @@ -// Created on: 1993-11-22 -// Created by: Stephane CALLEGARI -// Copyright (c) 1993-1999 Matra Datavision -// Copyright (c) 1999-2012 OPEN CASCADE SAS -// -// The content of this file is subject to the Open CASCADE Technology Public -// License Version 6.5 (the "License"). You may not use the content of this file -// except in compliance with the License. Please obtain a copy of the License -// at http://www.opencascade.org and read it completely before using this file. -// -// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its -// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. -// -// The Original Code and all software distributed under the License is -// distributed on an "AS IS" basis, without warranty of any kind, and the -// Initial Developer hereby disclaims all such warranties, including without -// limitation, any warranties of merchantability, fitness for a particular -// purpose or non-infringement. Please see the License for the specific terms -// and conditions governing the rights and limitations under the License. - -// Modified 23/07/98 : DCB ; Remove WNT specific since WNT_DDriver -// inherits from PlotterDriver - -#define xTRACE - -#define CSR_PRO12324 //SYL_030798 -// No plot if object not plottable -// Modified 17/12/1998 SYL pour S3604 -// Aspect_PlotterDriver devient PlotMgt_PlotterDriver - -#define BUC60639 //GG_220300 -// the Remove() method must sets correctly -// all GraphicObjects fields - -#define G002 //GG_180400 -// -> Drawer become a TransientManager for -// open detection and dragging facilities - -#define OCC154 // jfa 06/03/2002 // for correct erasing - -#define OCC402 // SAV 14/11/01 Added PickByCircle(). - -#include -#include -#include -#include -#include -#include -#include - -Graphic2d_View::Graphic2d_View (): - myGraphicObjects (), - myGraphicAltitudes (), - myBuffers (), - myOverrideColorIsDef (Standard_False), - myDeflection (0.001 METER), - myDeflectionCoefficient (1./3000.), - myTypeOfDeflection (Aspect_TOD_RELATIVE), - myXCenter (0.), - myYCenter (0.), - mySize (1. METER), - myXPosition (0.), - myYPosition (0.), - myScale (1.), - myTextPrecision (0.0015 METER) { -#ifdef G002 - myDrawer = new Graphic2d_TransientManager(this); -#else - myDrawer = new Graphic2d_Drawer; -#endif -} - -void Graphic2d_View::Add (const Handle(Graphic2d_Buffer)& aBuffer) { -Standard_Integer i,l = myBuffers.Length (); - - for ( i=1; i<=l ; i++) { - if (myBuffers.Value (i) == aBuffer) break; - } - - if (i > l) myBuffers.Append (aBuffer); -} - -Standard_Integer Graphic2d_View::Add (const Handle(Graphic2d_GraphicObject)& aGraphicObject,const Standard_Integer anAltitude) { -Standard_Integer i,l = myGraphicAltitudes.Length(); - - for( i=l ; i>0 ; --i ) { - if( anAltitude >= myGraphicAltitudes.Value(i) ) break; - } - if( i < l ) { - myGraphicObjects.InsertAfter (i, aGraphicObject); - myGraphicAltitudes.InsertAfter (i, anAltitude); - i++; - } else { - myGraphicObjects.Append (aGraphicObject); - myGraphicAltitudes.Append (anAltitude); - i = l+1; - } - return i; -} - -Standard_Integer Graphic2d_View::Change (const Handle(Graphic2d_GraphicObject)& aGraphicObject,const Standard_Integer anAltitude) { -Standard_Integer i,l = myGraphicObjects.Length (); - - for ( i=1; i<=l ; i++) { - if (myGraphicObjects.Value (i) == aGraphicObject) break; - } - - if ( i > l ) i = 0; - else if( myGraphicAltitudes.Value (i) != anAltitude ) { - myGraphicObjects.Remove (i); - myGraphicAltitudes.Remove (i); - i = 0; - } - - if( i == 0 ) { - i = Add(aGraphicObject,anAltitude); - } - - return i; -} - -void Graphic2d_View::Remove (const Handle(Graphic2d_Buffer)& aBuffer) { -Standard_Integer i,l = myBuffers.Length (); - - for ( i=1; i<=l ; i++) { - if (myBuffers.Value (i) == aBuffer) break; - } - - if (i <= l) myBuffers.Remove (i); -} - -Standard_Integer Graphic2d_View::Remove (const Handle(Graphic2d_GraphicObject)& aGraphicObject) { -Standard_Integer i,l = myGraphicObjects.Length (); - - for ( i=1; i<=l ; i++) { - if (myGraphicObjects.Value (i) == aGraphicObject) break; - } - - if ( i > l ) i = 0; - else { - myGraphicObjects.Remove (i); - myGraphicAltitudes.Remove (i); - } - - return i; -} - -void Graphic2d_View::Destroy () { -Standard_Integer Length = myGraphicObjects.Length(); -Standard_Integer i; - - for (i=1; i<=Length; i++) - myGraphicObjects.Value(i)->RemovePrimitives (); - myGraphicObjects.Clear(); - myGraphicAltitudes.Clear(); -} - -void Graphic2d_View::SetDefaultOverrideColor (const Standard_Integer anIndex) { - - myOverrideColorIsDef = Standard_True; - myDefaultOverrideColor = anIndex; - -} - -Standard_Integer Graphic2d_View::DefaultOverrideColor() const { - - if (! myOverrideColorIsDef) - Graphic2d_OverrideColorError::Raise - ("No defined override color index"); - - return myDefaultOverrideColor; - -} - -Standard_Boolean Graphic2d_View::IsDefinedColor() const { - - return myOverrideColorIsDef; - -} - -void Graphic2d_View::Update (const Handle(Aspect_Driver)& aDriver, - const Handle(Graphic2d_ViewMapping)& aViewMapping, - const Standard_Real aXPosition, - const Standard_Real aYPosition, - const Standard_Real aScale, - const Standard_Boolean ClearBefore) { - -#ifdef TRACE -cout << "Graphic2d_View::Update (Aspect_Driver)\n" << flush; -#endif - -Standard_Integer GOLength = myGraphicObjects.Length(); -Standard_Integer GBLength = myBuffers.Length(); -Standard_Integer i; -Standard_Real XCenter, YCenter, Size; - - aViewMapping->ViewMapping(XCenter, YCenter, Size); - myXCenter = Standard_ShortReal (XCenter); - myYCenter = Standard_ShortReal (YCenter); - mySize = Standard_ShortReal (Size); - myXPosition = Standard_ShortReal (aXPosition); - myYPosition = Standard_ShortReal (aYPosition); - myScale = Standard_ShortReal (aScale); - myZoom = Standard_ShortReal (aViewMapping->Zoom()); - - myDrawer->SetValues (XCenter, YCenter, Size, - aXPosition, aYPosition, myScale, myZoom); - myDrawer->SetDrawPrecision - (myDeflection, myDeflectionCoefficient, myTypeOfDeflection); - myDrawer->SetTextPrecision(myTextPrecision); - myDrawer->SetDriver(aDriver); - - if( aDriver->IsKind(STANDARD_TYPE(Aspect_WindowDriver)) ) { - Handle(Aspect_WindowDriver) theDriver = - *(Handle(Aspect_WindowDriver) *) &aDriver; - theDriver->BeginDraw(Standard_True); - if( ClearBefore ) { - theDriver->Window()->Clear(); - } - for (i=1; i<=GOLength; i++) - myGraphicObjects.Value(i)->Redraw (myDrawer); - aDriver->EndDraw(); - for (i=1; i<=GBLength; i++) { - Handle(Graphic2d_Buffer) theBuffer = myBuffers.Value(i); - if( theBuffer->IsPosted(theDriver) ) { - theBuffer->ReLoad (Standard_True); - } - } - } else if( aDriver->IsKind(STANDARD_TYPE(PlotMgt_PlotterDriver)) ) { - Handle(PlotMgt_PlotterDriver) theDriver = - *(Handle(PlotMgt_PlotterDriver) *) &aDriver; - theDriver->BeginDraw(); - for (i=1; i<=GOLength; i++) -#ifdef CSR_PRO12324 - if( myGraphicObjects.Value(i)->IsPlottable()) -#endif - myGraphicObjects.Value(i)->Redraw (myDrawer); - aDriver->EndDraw(); - } -} - -void Graphic2d_View::TinyUpdate (const Handle(Aspect_Driver)& aDriver, - const Handle(Graphic2d_ViewMapping)& aViewMapping, - const Standard_Real aXPosition, - const Standard_Real aYPosition, - const Standard_Real aScale, - const Standard_Boolean Reset) { - -#ifdef TRACE -cout << "Graphic2d_View::TinyUpdate (Aspect_Driver)\n" << flush; -#endif - -Standard_Integer i,Length = myGraphicObjects.Length (); -Standard_Real XCenter, YCenter, Size; - - aViewMapping->ViewMapping(XCenter, YCenter, Size); - myXCenter = Standard_ShortReal (XCenter); - myYCenter = Standard_ShortReal (YCenter); - mySize = Standard_ShortReal (Size); - myXPosition = Standard_ShortReal (aXPosition); - myYPosition = Standard_ShortReal (aYPosition); - myScale = Standard_ShortReal (aScale); - myZoom = Standard_ShortReal (aViewMapping->Zoom()); - - myDrawer->SetValues (XCenter, YCenter, Size, - aXPosition, aYPosition, myScale, myZoom); - myDrawer->SetDrawPrecision - (myDeflection, myDeflectionCoefficient, myTypeOfDeflection); - myDrawer->SetTextPrecision(myTextPrecision); - myDrawer->SetDriver(aDriver); - - if( aDriver->IsKind(STANDARD_TYPE(Aspect_WindowDriver)) ) { - Handle(Aspect_WindowDriver) theDriver = - *(Handle(Aspect_WindowDriver) *) &aDriver; - theDriver->BeginDraw(Standard_True); - } else if( aDriver->IsKind(STANDARD_TYPE(PlotMgt_PlotterDriver)) ) { - Handle(PlotMgt_PlotterDriver) theDriver = - *(Handle(PlotMgt_PlotterDriver) *) &aDriver; - theDriver->BeginDraw(); - } - for (i=1; i<=Length; i++) -#ifdef CSR_PRO12324 - if( myGraphicObjects.Value(i)->IsPlottable()) -#endif - myGraphicObjects.Value (i)->Draw (myDrawer,Reset); - aDriver->EndDraw (); -} - -void Graphic2d_View::Update (const Handle(Aspect_Driver)& aDriver, const Handle(Graphic2d_GraphicObject)& aGraphicObject, const Handle(Graphic2d_ViewMapping)& aViewMapping, const Standard_Real aXPosition, const Standard_Real aYPosition, const Standard_Real aScale) { - -#ifdef TRACE -cout << "Graphic2d_View::Update (Aspect_Driver, Graphic2d_GraphicObject)\n" << flush; -#endif - - if( IsIn (aGraphicObject) ) { - Standard_Integer i,Length = aGraphicObject->Length (); - Handle(Graphic2d_Primitive) aPrimitive; - Standard_Real XCenter, YCenter, Size; - - aViewMapping->ViewMapping(XCenter, YCenter, Size); - myXCenter = Standard_ShortReal (XCenter); - myYCenter = Standard_ShortReal (YCenter); - mySize = Standard_ShortReal (Size); - myXPosition = Standard_ShortReal (aXPosition); - myYPosition = Standard_ShortReal (aYPosition); - myScale = Standard_ShortReal (aScale); - myZoom = Standard_ShortReal (aViewMapping->Zoom()); - - myDrawer->SetValues (XCenter, YCenter, Size, - aXPosition, aYPosition, myScale, myZoom); - myDrawer->SetDrawPrecision - (myDeflection, myDeflectionCoefficient, myTypeOfDeflection); - myDrawer->SetTextPrecision(myTextPrecision); - myDrawer->SetDriver(aDriver); - - if( aDriver->IsKind(STANDARD_TYPE(Aspect_WindowDriver)) ) { - Handle(Aspect_WindowDriver) theDriver = - *(Handle(Aspect_WindowDriver) *) &aDriver; - theDriver->BeginDraw(Standard_True); - } else if( aDriver->IsKind(STANDARD_TYPE(PlotMgt_PlotterDriver)) ) { - Handle(PlotMgt_PlotterDriver) theDriver = - *(Handle(PlotMgt_PlotterDriver) *) &aDriver; - theDriver->BeginDraw(); - } - for (i=1; i<=Length ; i++) { - aPrimitive = aGraphicObject->Primitive(i); -#ifdef CSR_PRO12324 - if( !aDriver->IsKind(STANDARD_TYPE(Aspect_WindowDriver)) - || aGraphicObject->IsPlottable() ) -#endif - aGraphicObject->Draw (myDrawer, aPrimitive); - } - aDriver->EndDraw (); - } -} - -void Graphic2d_View::Update (const Handle(Aspect_Driver)& aDriver, const Handle(Graphic2d_Primitive)& aPrimitive, const Handle(Graphic2d_ViewMapping)& aViewMapping, const Standard_Real aXPosition, const Standard_Real aYPosition, const Standard_Real aScale) { - -#ifdef TRACE -cout << "Graphic2d_View::Update (Aspect_Driver, Graphic2d_Primitive)\n" << flush; -#endif - -Standard_Integer i,Length = myGraphicObjects.Length (); -Standard_Boolean found = Standard_False; -Standard_Real XCenter, YCenter, Size; - - aViewMapping->ViewMapping(XCenter, YCenter, Size); - myXCenter = Standard_ShortReal (XCenter); - myYCenter = Standard_ShortReal (YCenter); - mySize = Standard_ShortReal (Size); - myXPosition = Standard_ShortReal (aXPosition); - myYPosition = Standard_ShortReal (aYPosition); - myScale = Standard_ShortReal (aScale); - myZoom = Standard_ShortReal (aViewMapping->Zoom()); - - myDrawer->SetValues (XCenter, YCenter, Size, - aXPosition, aYPosition, myScale, myZoom); - myDrawer->SetDrawPrecision - (myDeflection, myDeflectionCoefficient, myTypeOfDeflection); - myDrawer->SetTextPrecision(myTextPrecision); - myDrawer->SetDriver(aDriver); - - if( aDriver->IsKind(STANDARD_TYPE(Aspect_WindowDriver)) ) { - Handle(Aspect_WindowDriver) theDriver = - *(Handle(Aspect_WindowDriver) *) &aDriver; - theDriver->BeginDraw(Standard_True); - } else if( aDriver->IsKind(STANDARD_TYPE(PlotMgt_PlotterDriver)) ) { - Handle(PlotMgt_PlotterDriver) theDriver = - *(Handle(PlotMgt_PlotterDriver) *) &aDriver; - theDriver->BeginDraw(); - } - for (i=1; i<=Length && !found; i++) { - found = myGraphicObjects.Value (i)->IsIn (aPrimitive); - if (found) -#ifdef CSR_PRO12324 - if( !aDriver->IsKind(STANDARD_TYPE(Aspect_WindowDriver)) - || myGraphicObjects.Value (i)->IsPlottable() ) -#endif - myGraphicObjects.Value (i)->Draw (myDrawer, aPrimitive); - } - aDriver->EndDraw (); - -} - -Handle(Graphic2d_DisplayList) Graphic2d_View::DisplayList () const { -Standard_Integer Index; -Standard_Integer Length = myGraphicObjects.Length (); -Handle(Graphic2d_DisplayList) DL = new Graphic2d_DisplayList; - - for (Index=1; Index<=Length; Index++) - DL->Append(myGraphicObjects.Value(Index)); - return DL; -} - -Standard_Boolean Graphic2d_View::IsIn (const Handle(Graphic2d_GraphicObject)& aGraphicObject) const { -Standard_Integer Index = 0; -Standard_Integer Length = myGraphicObjects.Length (); - - for (Standard_Integer i=1; i<=Length && Index==0; i++) - if (myGraphicObjects.Value (i) == aGraphicObject) Index = i; - - return (Index != 0); -} - -void Graphic2d_View::MinMax (Quantity_Length& Minx, Quantity_Length& Maxx, Quantity_Length& Miny, Quantity_Length& Maxy) const { - -Standard_Integer i,Length = myGraphicObjects.Length (); -Quantity_Length x, y, X, Y; -Standard_Real RL, RF; - - RL = Minx = Miny = ShortRealLast (); - RF = Maxx = Maxy = ShortRealFirst (); - - for (i=1; i<=Length; i++) { - myGraphicObjects.Value (i)->MinMax (x, X, y, Y); - // GraphicObject can be empty - if (x > RF) Minx = (Minx < x ? Minx : x); - if (X < RL) Maxx = (Maxx > X ? Maxx : X); - if (y > RF) Miny = (Miny < y ? Miny : y); - if (Y < RL) Maxy = (Maxy > Y ? Maxy : Y); - } - - // Attention, it is possible that : - // Minx = Miny = ShortRealLast (); and - // Maxx = Maxy = ShortRealFirst(); - if (Minx > Maxx) { Minx = RealFirst (); Maxx = RealLast (); } - if (Miny > Maxy) { Miny = RealFirst (); Maxy = RealLast (); } -} - -void Graphic2d_View::MinMax (const Handle(Graphic2d_DisplayList)& aList, Quantity_Length& Minx, Quantity_Length& Maxx, Quantity_Length& Miny, Quantity_Length& Maxy) const { - -Standard_Integer i,Length = aList->Length (); -Quantity_Length x, y, X, Y; -Standard_Real RL, RF; - - RL = Minx = Miny = ShortRealLast (); - RF = Maxx = Maxy = ShortRealFirst (); - - for (i=1; i<=Length; i++) { - if (IsIn (aList->Value(i))) { - (aList->Value(i))->MinMax (x, X, y, Y); - // GraphicObject can be empty - if (x > RF) Minx = (Minx < x ? Minx : x); - if (X < RL) Maxx = (Maxx > X ? Maxx : X); - if (y > RF) Miny = (Miny < y ? Miny : y); - if (Y < RL) Maxy = (Maxy > Y ? Maxy : Y); - } - } - - // Attention, it is possible that : - // Minx = Miny = ShortRealLast (); and - // Maxx = Maxy = ShortRealFirst(); - if (Minx > Maxx) { Minx = RealFirst (); Maxx = RealLast (); } - if (Miny > Maxy) { Miny = RealFirst (); Maxy = RealLast (); } -} - -void Graphic2d_View::MarkerMinMax (Quantity_Length& Minx, Quantity_Length& Maxx, Quantity_Length& Miny, Quantity_Length& Maxy) const { - -Standard_Integer i,Length = myGraphicObjects.Length (); -Quantity_Length x, y, X, Y; -Standard_Real RL, RF; - - RL = Minx = Miny = ShortRealLast (); - RF = Maxx = Maxy = ShortRealFirst (); - - for (i=1; i<=Length; i++) { - myGraphicObjects.Value (i)->MarkerMinMax (x, X, y, Y); - // GraphicObject can be empty - if (x > RF) Minx = (Minx < x ? Minx : x); - if (X < RL) Maxx = (Maxx > X ? Maxx : X); - if (y > RF) Miny = (Miny < y ? Miny : y); - if (Y < RL) Maxy = (Maxy > Y ? Maxy : Y); - } - - // Attention, it is possible that : - // Minx = Miny = ShortRealLast (); and - // Maxx = Maxy = ShortRealFirst(); - if (Minx > Maxx) { Minx = RealFirst (); Maxx = RealLast (); } - if (Miny > Maxy) { Miny = RealFirst (); Maxy = RealLast (); } -} - -void Graphic2d_View::MarkerMinMax (const Handle(Graphic2d_DisplayList)& aList, Quantity_Length& Minx, Quantity_Length& Maxx, Quantity_Length& Miny, Quantity_Length& Maxy) const { - -Standard_Integer i,Length = aList->Length (); -Quantity_Length x, y, X, Y; -Standard_Real RL, RF; - - RL = Minx = Miny = ShortRealLast (); - RF = Maxx = Maxy = ShortRealFirst (); - - for (i=1; i<=Length; i++) { - if (IsIn (aList->Value(i))) { - (aList->Value(i))->MarkerMinMax (x, X, y, Y); - // GraphicObject can be empty - if (x > RF) Minx = (Minx < x ? Minx : x); - if (X < RL) Maxx = (Maxx > X ? Maxx : X); - if (y > RF) Miny = (Miny < y ? Miny : y); - if (Y < RL) Maxy = (Maxy > Y ? Maxy : Y); - } - } - - // Attention, it is possible that : - // Minx = Miny = ShortRealLast (); and - // Maxx = Maxy = ShortRealFirst(); - if (Minx > Maxx) { Minx = RealFirst (); Maxx = RealLast (); } - if (Miny > Maxy) { Miny = RealFirst (); Maxy = RealLast (); } -} - -Standard_Integer Graphic2d_View::Position(const Handle(Graphic2d_GraphicObject)& aGraphicObject) const { -Standard_Integer i,l = myGraphicObjects.Length (); - - for ( i=1; i<=l ; i++) { - if (myGraphicObjects.Value (i) == aGraphicObject) break; - } - - return (i > l) ? 0 : i; -} - -Standard_Integer Graphic2d_View::Altitude(const Handle(Graphic2d_GraphicObject)& aGraphicObject) const { -Standard_Integer i,l = myGraphicObjects.Length (); - - for ( i=1; i<=l ; i++) { - if (myGraphicObjects.Value (i) == aGraphicObject) break; - } - - return (i > l) ? -1 : myGraphicAltitudes.Value(i); -} - -Handle(Graphic2d_DisplayList) Graphic2d_View::Pick - (const Handle(Graphic2d_ViewMapping)& aViewMapping, - const Standard_Real X, - const Standard_Real Y, - const Standard_Real aPrecision, - const Standard_Real aXPosition, - const Standard_Real aYPosition, - const Standard_Real aScale) { - -#ifdef G002 - if( myPickList.IsNull() ) - myPickList = new Graphic2d_DisplayList; - else myPickList->Clear(); -#else -Handle(Graphic2d_DisplayList) DL = new Graphic2d_DisplayList; -#endif -Standard_Integer Length = myGraphicObjects.Length (); -Standard_Integer Index; -Standard_Real XCenter,YCenter,Size,Zoom = aViewMapping->Zoom(); - - aViewMapping->ViewMapping(XCenter,YCenter,Size); - - myDrawer->SetDrawPrecision(myDeflection*Zoom, - myDeflectionCoefficient, - myTypeOfDeflection); - myDrawer->SetValues (XCenter,YCenter,Size, - aXPosition,aYPosition,aScale,Zoom); - for (Index=Length; Index>0; --Index) { - if (myGraphicObjects.Value(Index)->Pick(X,Y,aPrecision,myDrawer)) -#ifdef G002 - myPickList->Append(myGraphicObjects.Value(Index)); -#else - DL->Append(myGraphicObjects.Value(Index)); -#endif - } - -#ifdef G002 - return myPickList; -#else - return DL; -#endif -} - -Handle(Graphic2d_DisplayList) Graphic2d_View -::PickByCircle( const Handle(Graphic2d_ViewMapping)& aViewMapping, - const Standard_Real X, - const Standard_Real Y, - const Standard_Real Radius, - const Standard_Real aXPosition, - const Standard_Real aYPosition, - const Standard_Real aScale) -{ - if( myPickList.IsNull() ) - myPickList = new Graphic2d_DisplayList; - else myPickList->Clear(); - -#ifdef OCC402 - Standard_Integer Length = myGraphicObjects.Length(); - Standard_Integer Index; - Standard_Real XCenter,YCenter,Size,Zoom = aViewMapping->Zoom(); - - aViewMapping->ViewMapping( XCenter, YCenter, Size ); - - myDrawer->SetDrawPrecision( myDeflection*Zoom, - myDeflectionCoefficient, - myTypeOfDeflection ); - myDrawer->SetValues( XCenter, YCenter, Size, - aXPosition, aYPosition, aScale, Zoom ); - for ( Index = Length; Index > 0; --Index ) - if ( myGraphicObjects.Value( Index )->PickByCircle( X, Y, Radius, myDrawer ) ) - myPickList->Append(myGraphicObjects.Value(Index)); -#endif - return myPickList; -} - - -Handle(Graphic2d_DisplayList) Graphic2d_View::Pick - ( const Handle(Graphic2d_ViewMapping)& aViewMapping, - const Standard_Real Xmin, - const Standard_Real Ymin, - const Standard_Real Xmax, - const Standard_Real Ymax, - const Standard_Real aXPosition, - const Standard_Real aYPosition, - const Standard_Real aScale, - const Graphic2d_PickMode aPickMode ) { - -#ifdef G002 - if ( myPickList.IsNull() ) - myPickList = new Graphic2d_DisplayList; - else myPickList->Clear(); -#else - Handle(Graphic2d_DisplayList) DL = new Graphic2d_DisplayList; -#endif - - Standard_Integer Length = myGraphicObjects.Length (); - Standard_Integer Index; - Standard_Real XCenter, YCenter, Size, Zoom = aViewMapping->Zoom(); - - aViewMapping->ViewMapping( XCenter, YCenter, Size ); - - myDrawer->SetDrawPrecision( myDeflection * Zoom, - myDeflectionCoefficient, - myTypeOfDeflection ); - myDrawer->SetValues( XCenter, YCenter, Size, - aXPosition, aYPosition, aScale, Zoom ); - for ( Index = Length; Index > 0; --Index ) { - if ( myGraphicObjects.Value(Index)->Pick( Xmin, Ymin, Xmax, Ymax, - myDrawer, aPickMode ) ) -#ifdef G002 - myPickList->Append(myGraphicObjects.Value(Index)); -#else - DL->Append(myGraphicObjects.Value(Index)); -#endif - } - -#ifdef G002 - return myPickList; -#else - return DL; -#endif -} - -void Graphic2d_View::Erase() { -Standard_Integer Length = myGraphicObjects.Length (); -Standard_Integer Index; - - for (Index=1; Index<=Length; Index++) - //myGraphicObjects.Value(Index)->Erase (); - // CAL le 17/11/97. - // 1 is set as it is required to remove N times the first from the list - // Acytually this list is updated by method below - // called by Graphic2d_GraphicObject::Erase. -#ifdef OCC154 - myGraphicObjects.Value(Index)->Erase(); -#else - myGraphicObjects.Value(1)->Erase (); -#endif -} - -void Graphic2d_View::Erase (const Handle(Graphic2d_GraphicObject)& aGraphicObject) { -Standard_Integer Index = 0; -Standard_Integer Length = myGraphicObjects.Length (); - - for (Standard_Integer i=1; i<=Length && Index==0; i++) - if (myGraphicObjects.Value (i) == aGraphicObject) Index = i; - - if (Index != 0) { - myGraphicObjects.Remove (Index); - myGraphicAltitudes.Remove (Index); - } -} - -void Graphic2d_View::Remove () { -#ifdef BUC60639 - Standard_Integer Length = myGraphicObjects.Length (); - for (Standard_Integer i=1; i<=Length ; i++) - myGraphicObjects.Value (1)->Remove(); -#else - myGraphicObjects.Clear(); - myGraphicAltitudes.Clear(); -#endif -} - -void Graphic2d_View::SetTypeOfDeflection(const Aspect_TypeOfDeflection aType) { - myTypeOfDeflection = aType; -} - -Aspect_TypeOfDeflection Graphic2d_View::TypeOfDeflection() const { - return myTypeOfDeflection; -} - - -void Graphic2d_View::SetDeflection (const Quantity_Length aDeflection) { - - myDeflection = aDeflection; - -} - -Quantity_Length Graphic2d_View::Deflection() const { return myDeflection; } - -void Graphic2d_View::SetDeflectionCoefficient(const Standard_Real aCoefficient) { - myDeflectionCoefficient = aCoefficient; -} - -Standard_Real Graphic2d_View::DeflectionCoefficient () const { - return myDeflectionCoefficient; -} - -void Graphic2d_View::SetTextPrecision (const Standard_Real aPrecision) { - - myTextPrecision = Standard_ShortReal(aPrecision); - -} - -Standard_Real Graphic2d_View::TextPrecision() const { return myTextPrecision; -} - -void Graphic2d_View::Convert(const Handle(Graphic2d_ViewMapping)& aViewMapping, - const Standard_Real aDrawPositionX, - const Standard_Real aDrawPositionY, - const Standard_Real aXPosition, - const Standard_Real aYPosition, - const Standard_Real aScale, - Standard_Real& aX, - Standard_Real& aY) const { - - Standard_Real XCenter,YCenter,Size,Zoom = aViewMapping->Zoom(); - Standard_ShortReal xdraw = Standard_ShortReal(aDrawPositionX); - Standard_ShortReal ydraw = Standard_ShortReal(aDrawPositionY); - Standard_ShortReal xpos,ypos ; - aViewMapping->ViewMapping(XCenter,YCenter,Size); - myDrawer->SetValues (XCenter,YCenter,Size, - aXPosition,aYPosition,aScale,Zoom); - myDrawer->UnMapFromTo(xdraw,ydraw,xpos,ypos); - aX = xpos ; - aY = ypos ; - -} - -Standard_Real Graphic2d_View::Convert( const Handle(Graphic2d_ViewMapping)& aViewMapping, - const Standard_Real aScalar, - const Standard_Real aScale) const { - - Standard_Real XCenter,YCenter,Size; - aViewMapping->ViewMapping(XCenter,YCenter,Size); - return (aScalar / aScale) * Size; - - -} - -Handle(Graphic2d_Drawer) Graphic2d_View::Drawer() const { - - return myDrawer ; -} diff --git a/src/Graphic2d/Graphic2d_ViewMapping.cdl b/src/Graphic2d/Graphic2d_ViewMapping.cdl deleted file mode 100755 index 572689a71a..0000000000 --- a/src/Graphic2d/Graphic2d_ViewMapping.cdl +++ /dev/null @@ -1,133 +0,0 @@ --- Created on: 1993-07-13 --- Created by: Jean Louis FRENKEL --- Copyright (c) 1993-1999 Matra Datavision --- Copyright (c) 1999-2012 OPEN CASCADE SAS --- --- The content of this file is subject to the Open CASCADE Technology Public --- License Version 6.5 (the "License"). You may not use the content of this file --- except in compliance with the License. Please obtain a copy of the License --- at http://www.opencascade.org and read it completely before using this file. --- --- The Initial Developer of the Original Code is Open CASCADE S.A.S., having its --- main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. --- --- The Original Code and all software distributed under the License is --- distributed on an "AS IS" basis, without warranty of any kind, and the --- Initial Developer hereby disclaims all such warranties, including without --- limitation, any warranties of merchantability, fitness for a particular --- purpose or non-infringement. Please see the License for the specific terms --- and conditions governing the rights and limitations under the License. - - - -class ViewMapping from Graphic2d inherits TShared from MMgt - - ---Version: - - ---Purpose: A ViewMapping defines a square region of the model - -- space from an origin point and a size in meters. - -- This square region is called the "map from". - - ---Keywords: - ---Warning: - ---References: - -uses - Length from Quantity, - Factor from Quantity - -is - ------------------------- - -- Category: Constructors - ------------------------- - - Create - returns mutable ViewMapping from Graphic2d; - ---Level: Public - ---Purpose: Creates a view mapping with the following default - -- values : - -- XCenter = 0. - -- YCenter = 0. - -- Size = 1. - ---Category: Constructors - - --------------------------------------------------- - -- Category: Methods to modify the class definition - --------------------------------------------------- - - SetViewMapping (me: mutable; - aXCenter, aYCenter: Length from Quantity; - aSize: Length from Quantity) - is static; - ---Level: Public - ---Purpose: Sets new values for the view mapping . - ---Category: Methods to modify the class definition - - SetCenter (me: mutable; - aXCenter, aYCenter: Length from Quantity) - is static; - ---Level: Public - ---Purpose: Sets new values for the view mapping center. - ---Category: Methods to modify the class definition - - SetSize (me: mutable; - aSize: Length from Quantity) - is static; - ---Level: Public - ---Purpose: Sets new value for the view mapping size. - - SetViewMappingDefault (me: mutable) - is static; - ---Level: Public - ---Purpose: Saves the current mapping which will be the - -- reference value for the reset of the mapping - -- done by the ViewmappingReset method. - ---Category: Methods to modify the class definition - - ViewMappingReset (me: mutable) - is static; - ---Level: Public - ---Purpose: Sets the value of the mapping to be the same as - -- the mapping saved by the SetViewMappingDefault method. - ---Category: Methods to modify the class definition - - ---------------------------- - -- Category: Inquire methods - ---------------------------- - - ViewMapping (me; XCenter, YCenter, Size: out Length from Quantity) - is static; - ---Level: Public - ---Purpose: Returns the current mapping of the view . - ---Category: Inquire methods - - Center (me; XCenter, YCenter: out Length from Quantity) - is static; - ---Level: Public - ---Purpose: Returns the current center of the view . - ---Category: Inquire methods - - ViewMappingDefault (me; - XCenter, YCenter, Size: out Length from Quantity) - is static; - ---Level: Public - ---Purpose: Returns the current reset mapping of the view . - ---Category: Inquire methods - - Zoom (me) - returns Factor from Quantity - is static; - ---Level: Public - ---Purpose: Returns the zoom factor (CurrentSize/InitialSize). - ---Category: Inquire methods - -fields - myXCenter: Length from Quantity; - myYCenter: Length from Quantity; - mySize: Length from Quantity; - - myInitialXCenter: Length from Quantity; - myInitialYCenter: Length from Quantity; - myInitialSize: Length from Quantity; - -end ViewMapping from Graphic2d; diff --git a/src/Graphic2d/Graphic2d_ViewMapping.cxx b/src/Graphic2d/Graphic2d_ViewMapping.cxx deleted file mode 100755 index ea1394c561..0000000000 --- a/src/Graphic2d/Graphic2d_ViewMapping.cxx +++ /dev/null @@ -1,95 +0,0 @@ -// Copyright (c) 1995-1999 Matra Datavision -// Copyright (c) 1999-2012 OPEN CASCADE SAS -// -// The content of this file is subject to the Open CASCADE Technology Public -// License Version 6.5 (the "License"). You may not use the content of this file -// except in compliance with the License. Please obtain a copy of the License -// at http://www.opencascade.org and read it completely before using this file. -// -// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its -// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. -// -// The Original Code and all software distributed under the License is -// distributed on an "AS IS" basis, without warranty of any kind, and the -// Initial Developer hereby disclaims all such warranties, including without -// limitation, any warranties of merchantability, fitness for a particular -// purpose or non-infringement. Please see the License for the specific terms -// and conditions governing the rights and limitations under the License. - -#include -#include - -Graphic2d_ViewMapping::Graphic2d_ViewMapping () -: myXCenter (0.), myYCenter (0.), mySize (1. METER), -myInitialXCenter(0.),myInitialYCenter(0),myInitialSize(1.) { -} - -void Graphic2d_ViewMapping::SetViewMapping (const Quantity_Length aXCenter, const Quantity_Length aYCenter, const Quantity_Length aSize) { - - myXCenter = aXCenter; - myYCenter = aYCenter; - mySize = aSize; - -} - -void Graphic2d_ViewMapping::SetCenter -(const Quantity_Length aXCenter, const Quantity_Length aYCenter) { - - myXCenter = aXCenter; - myYCenter = aYCenter; - -} - -void Graphic2d_ViewMapping::SetSize (const Quantity_Length aSize) { - - mySize = aSize; - -} - -void Graphic2d_ViewMapping::SetViewMappingDefault () { - - myInitialXCenter = myXCenter; - myInitialYCenter = myYCenter; - myInitialSize = mySize; - -} - -void Graphic2d_ViewMapping::ViewMappingDefault (Quantity_Length& XCenter, - Quantity_Length& YCenter, - Quantity_Length& aSize) const { - XCenter = myInitialXCenter; - YCenter = myInitialYCenter; - aSize = myInitialSize; - -} - -void Graphic2d_ViewMapping::ViewMappingReset () { - - myXCenter = myInitialXCenter; - myYCenter = myInitialYCenter; - mySize = myInitialSize; - -} - -void Graphic2d_ViewMapping::ViewMapping - (Quantity_Length& XCenter, - Quantity_Length& YCenter, - Quantity_Length& Size) const { - - XCenter = myXCenter; - YCenter = myYCenter; - Size = mySize; -} -void Graphic2d_ViewMapping::Center - (Quantity_Length& XCenter, - Quantity_Length& YCenter) const { - - XCenter = myXCenter; - YCenter = myYCenter; -} - -Quantity_Factor Graphic2d_ViewMapping::Zoom () const { - - return mySize/myInitialSize; - -} diff --git a/src/Graphic2d/Graphic2d_WOKSteps.edl b/src/Graphic2d/Graphic2d_WOKSteps.edl deleted file mode 100755 index 2b48ae4202..0000000000 --- a/src/Graphic2d/Graphic2d_WOKSteps.edl +++ /dev/null @@ -1,29 +0,0 @@ --- Created by: Stephane Callegari --- Copyright (c) 1998-1999 Matra Datavision --- Copyright (c) 1999-2012 OPEN CASCADE SAS --- --- The content of this file is subject to the Open CASCADE Technology Public --- License Version 6.5 (the "License"). You may not use the content of this file --- except in compliance with the License. Please obtain a copy of the License --- at http://www.opencascade.org and read it completely before using this file. --- --- The Initial Developer of the Original Code is Open CASCADE S.A.S., having its --- main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. --- --- The Original Code and all software distributed under the License is --- distributed on an "AS IS" basis, without warranty of any kind, and the --- Initial Developer hereby disclaims all such warranties, including without --- limitation, any warranties of merchantability, fitness for a particular --- purpose or non-infringement. Please see the License for the specific terms --- and conditions governing the rights and limitations under the License. - - - -@ifnotdefined ( %Graphic2d_WOKSteps_EDL) then - - @set %Graphic2d_WOKSteps_EDL = ""; - - @set %WOKSteps_UseSourceInclude = ""; - -@endif; - diff --git a/src/MFT/FILES b/src/MFT/FILES deleted file mode 100755 index f20d31aa26..0000000000 --- a/src/MFT/FILES +++ /dev/null @@ -1,9 +0,0 @@ -MFT_CommandDescriptor.hxx -MFT_CommandDescriptor.cxx -MFT_FileHandle.hxx -MFT_FileRecord.hxx -MFT_FileRecord.cxx -MFT_FilePosition.hxx -MFT.edl -MFT_CMPLRS.edl -MFT_WOKSteps.edl diff --git a/src/MFT/MFT.cdl b/src/MFT/MFT.cdl deleted file mode 100755 index 08cc69e776..0000000000 --- a/src/MFT/MFT.cdl +++ /dev/null @@ -1,149 +0,0 @@ --- Created on: 1997-03-03 --- Created by: GG --- Copyright (c) 1997-1999 Matra Datavision --- Copyright (c) 1999-2012 OPEN CASCADE SAS --- --- The content of this file is subject to the Open CASCADE Technology Public --- License Version 6.5 (the "License"). You may not use the content of this file --- except in compliance with the License. Please obtain a copy of the License --- at http://www.opencascade.org and read it completely before using this file. --- --- The Initial Developer of the Original Code is Open CASCADE S.A.S., having its --- main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. --- --- The Original Code and all software distributed under the License is --- distributed on an "AS IS" basis, without warranty of any kind, and the --- Initial Developer hereby disclaims all such warranties, including without --- limitation, any warranties of merchantability, fitness for a particular --- purpose or non-infringement. Please see the License for the specific terms --- and conditions governing the rights and limitations under the License. - - -package MFT - - ---Version: - - ---Purpose: This package contains a Meta Font toolkit and utilities. - -- 1) Enable to creates MDTV outline fonts from others specific fonts - -- (i.e: PostScript fonts,Euclid3 fonts,...) - -- 2) Enable to retrieves a string or extended string - -- outline vector list according of the current font and - -- text attribs : - -- (policy,size,slant,orientation and curve precision) - -- 3) Enable to retrieve policy or text attribs - -- (i.e: Foundry,Family,..,font or text size). - - ---Keywords: Font - - ---References: - -uses - - Aspect,TCollection,Quantity,MMgt,OSD,TColStd - -is - - --------------------------- - -- Category: Imported types - --------------------------- - - imported FileRecord; - imported FileHandle; - imported FilePosition; - imported CommandDescriptor; - - -------------------- - -- Category: Classes - -------------------- - - class FontManager; - ---Purpose: Creates a font manager. - -- Enable to reads or writes a MetaFont file. - - class TextManager; - ---Purpose: Facilities to draw a font. - - --------------------------------- - -- Category: Instantiated classes - --------------------------------- - - alias ListOfFontName is SequenceOfAsciiString from TColStd; - - class ListOfFontHandle instantiates - Sequence from TCollection (FileHandle from MFT); - - alias ListOfFontReference is SequenceOfInteger from TColStd; - - ------------------------- - -- Category: Enumerations - ------------------------- - - enumeration TypeOfCommand is - TOC_UNKNOWN, - TOC_HSTEM, -- Declare an horizontal stem zone - TOC_VSTEM, -- Declare a vertical stem zone - TOC_VMOVETO, -- Relative vertical move - TOC_RLINETO, -- Relative segment - TOC_HLINETO, -- Relative horizontal segment - TOC_VLINETO, -- Relative vertical segment - TOC_RRCURVETO, -- Relative curve - TOC_CLOSEPATH, -- Close current path --- TOC_CALLSUBR, -- Call preregistered macro --- Must be extracted by the translator. --- TOC_RETURN, -- Returns from preregistered macro --- Must be extracted by the translator. --- TOC_ESCAPE, -- Skip ???????? - TOC_HSBW, -- Sets the char width horizontal vector & left sidebearing. - TOC_ENDCHAR, -- End char definition - TOC_RMOVETO, -- Relative move - TOC_HMOVETO, -- Relative horizontal move - TOC_VHCURVETO, -- Vertical and Horizontal tangential curve - TOC_HVCURVETO, -- Horizontal and Vertical tangential curve - TOC_DOTSECTION, -- Dot section for special chars (i.e: i,j) - TOC_VSTEM3, -- Declare three vertical stem zone - TOC_HSTEM3, -- Declare three horizontal stem zone - TOC_SEAC, -- Accented char description - TOC_SBW, -- Sets the char width vector & left sidebearing. --- TOC_DIV, -- Divide operation --- Must be extracted by the translator. --- TOC_CALLOTHERSUBR,-- ???????? --- Must be extracted by the translator. --- TOC_POP, -- ???????? --- Must be extracted by the translator. - TOC_SETCURRENTPOINT,-- Sets the current absolute point - TOC_CHARSTRING, -- Char string command (i.e: "/dollar") - TOC_NUMERIC, -- Numeric command - TOC_MINMAX -- Optionnal Char bounding box - end TypeOfCommand ; - ---Purpose: Definition of the MFT font descriptor commands. - -- Warning: Based on Type 1 font descriptor commands. - - enumeration TypeOfValue is - TOV_UNKNOWN, - TOV_INTEGER, - TOV_FLOAT, - TOV_STRING - end TypeOfValue ; - ---Purpose: Definition of the MFT command parameters. - - ----------------------- - -- Category: Exceptions - ----------------------- - - exception FontManagerDefinitionError inherits NoSuchObject from Standard; - - exception FontManagerError inherits TypeMismatch from Standard; - - ---------------------------- - -- Category: Package methods - ---------------------------- - - Convert ( aCommandType: TypeOfCommand from MFT) - returns CString from Standard is private; - ---Purpose: Converts the type of command to string. - - Convert ( aValueType: TypeOfValue from MFT) - returns CString from Standard is private; - ---Purpose: Converts the type of value to string. - -end MFT; diff --git a/src/MFT/MFT.cxx b/src/MFT/MFT.cxx deleted file mode 100755 index d9c7316d41..0000000000 --- a/src/MFT/MFT.cxx +++ /dev/null @@ -1,126 +0,0 @@ -// Created on: 1997-03-12 -// Created by: Gerard GRAS -// Copyright (c) 1997-1999 Matra Datavision -// Copyright (c) 1999-2012 OPEN CASCADE SAS -// -// The content of this file is subject to the Open CASCADE Technology Public -// License Version 6.5 (the "License"). You may not use the content of this file -// except in compliance with the License. Please obtain a copy of the License -// at http://www.opencascade.org and read it completely before using this file. -// -// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its -// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. -// -// The Original Code and all software distributed under the License is -// distributed on an "AS IS" basis, without warranty of any kind, and the -// Initial Developer hereby disclaims all such warranties, including without -// limitation, any warranties of merchantability, fitness for a particular -// purpose or non-infringement. Please see the License for the specific terms -// and conditions governing the rights and limitations under the License. - -#include -#include - -// ============================================================================= -// ---Purpose: Converts a TypeOfCommand to a string -// ============================================================================= - -static TCollection_AsciiString typestring; -Standard_CString MFT::Convert(const MFT_TypeOfCommand aCommandType){ - switch (aCommandType) { - case MFT_TOC_UNKNOWN: - typestring = "UNKNOWN"; - break; - case MFT_TOC_HSTEM: - typestring = "HSTEM"; - break; - case MFT_TOC_VSTEM: - typestring = "VSTEM"; - break; - case MFT_TOC_VMOVETO: - typestring = "VMOVETO"; - break; - case MFT_TOC_RLINETO: - typestring = "RLINETO"; - break; - case MFT_TOC_HLINETO: - typestring = "HLINETO"; - break; - case MFT_TOC_VLINETO: - typestring = "VLINETO"; - break; - case MFT_TOC_RRCURVETO: - typestring = "RRCURVETO"; - break; - case MFT_TOC_CLOSEPATH: - typestring = "CLOSEPATH"; - break; - case MFT_TOC_HSBW: - typestring = "HSBW"; - break; - case MFT_TOC_ENDCHAR: - typestring = "ENDCHAR"; - break; - case MFT_TOC_RMOVETO: - typestring = "RMOVETO"; - break; - case MFT_TOC_HMOVETO: - typestring = "HMOVETO"; - break; - case MFT_TOC_VHCURVETO: - typestring = "VHCURVETO"; - break; - case MFT_TOC_HVCURVETO: - typestring = "HVCURVETO"; - break; - case MFT_TOC_DOTSECTION: - typestring = "DOTSECTION"; - break; - case MFT_TOC_VSTEM3: - typestring = "VSTEM3"; - break; - case MFT_TOC_HSTEM3: - typestring = "HSTEM3"; - break; - case MFT_TOC_SEAC: - typestring = "SEAC"; - break; - case MFT_TOC_SBW: - typestring = "SBW"; - break; - case MFT_TOC_SETCURRENTPOINT: - typestring = "SETCURRENTPOINT"; - break; - case MFT_TOC_CHARSTRING: - typestring = "CHARSTRING"; - break; - case MFT_TOC_NUMERIC: - typestring = "NUMERIC"; - break; - case MFT_TOC_MINMAX: - typestring = "MINMAX"; - break; - } - - return typestring.ToCString(); -} - -static TCollection_AsciiString valuename; -Standard_CString MFT::Convert(const MFT_TypeOfValue aValueType){ - switch (aValueType) { - case MFT_TOV_UNKNOWN: - valuename = "UNKNOWN"; - break; - case MFT_TOV_INTEGER: - valuename = "INTEGER"; - break; - case MFT_TOV_FLOAT: - valuename = "FLOAT"; - break; - case MFT_TOV_STRING: - valuename = "STRING"; - break; - } - - return valuename.ToCString(); -} diff --git a/src/MFT/MFT.edl b/src/MFT/MFT.edl deleted file mode 100755 index 04e1204a88..0000000000 --- a/src/MFT/MFT.edl +++ /dev/null @@ -1,24 +0,0 @@ --- Created on: 1996-10-03 --- Created by: Jean GAUTIER --- Copyright (c) 1996-1999 Matra Datavision --- Copyright (c) 1999-2012 OPEN CASCADE SAS --- --- The content of this file is subject to the Open CASCADE Technology Public --- License Version 6.5 (the "License"). You may not use the content of this file --- except in compliance with the License. Please obtain a copy of the License --- at http://www.opencascade.org and read it completely before using this file. --- --- The Initial Developer of the Original Code is Open CASCADE S.A.S., having its --- main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. --- --- The Original Code and all software distributed under the License is --- distributed on an "AS IS" basis, without warranty of any kind, and the --- Initial Developer hereby disclaims all such warranties, including without --- limitation, any warranties of merchantability, fitness for a particular --- purpose or non-infringement. Please see the License for the specific terms --- and conditions governing the rights and limitations under the License. - - -@ifnotdefined ( %MFT_EDL) then - @set %MFT_EDL = ""; -@endif; diff --git a/src/MFT/MFT_CMPLRS.edl b/src/MFT/MFT_CMPLRS.edl deleted file mode 100755 index 9e207af7b6..0000000000 --- a/src/MFT/MFT_CMPLRS.edl +++ /dev/null @@ -1,53 +0,0 @@ --- Created on: 1996-10-03 --- Created by: Jean GAUTIER --- Copyright (c) 1996-1999 Matra Datavision --- Copyright (c) 1999-2012 OPEN CASCADE SAS --- --- The content of this file is subject to the Open CASCADE Technology Public --- License Version 6.5 (the "License"). You may not use the content of this file --- except in compliance with the License. Please obtain a copy of the License --- at http://www.opencascade.org and read it completely before using this file. --- --- The Initial Developer of the Original Code is Open CASCADE S.A.S., having its --- main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. --- --- The Original Code and all software distributed under the License is --- distributed on an "AS IS" basis, without warranty of any kind, and the --- Initial Developer hereby disclaims all such warranties, including without --- limitation, any warranties of merchantability, fitness for a particular --- purpose or non-infringement. Please see the License for the specific terms --- and conditions governing the rights and limitations under the License. - --- bgn 27-04-98 Portage des fontes MFT sur WNT. - -@ifnotdefined ( %MFT_CMPLRS_EDL) then - @set %MFT_CMPLRS_EDL = ""; - @uses "CSF.edl"; - - --@uses "MFT.edl"; - - @string %CMPLRS_CXX_Options = %CMPLRS_CXX_Options " -DITYPE_REF"; - - -- bgn 27-04-98 - @if ( %Station == "wnt" ) then - @string %CMPLRS_CXX_Options = %CMPLRS_CXX_Options " -D_AFXDLL "; - @endif; - - @if ( %Station == "sun" ) then - @string %CMPLRS_C_Options = %CMPLRS_C_Options " " %CSF_X11_INCLUDE ; - @string %CMPLRS_CXX_Options = %CMPLRS_CXX_Options " " %CSF_X11_INCLUDE ; - @endif; - - @if ( %Station == "sil" ) then - @string %CMPLRS_C_Options = %CMPLRS_C_Options " -ansi"; - @endif; - - @if ( %Station == "ao1" ) then - @string %CMPLRS_C_Options = %CMPLRS_C_Options " -std1"; - @endif; - - @if ( %Station == "hp" ) then - @string %CMPLRS_C_Options = %CMPLRS_C_Options " -I/usr/include/X11R5"; - @string %CMPLRS_C_Options = %CMPLRS_C_Options " -Ac"; - @endif; -@endif; diff --git a/src/MFT/MFT_CommandDescriptor.cxx b/src/MFT/MFT_CommandDescriptor.cxx deleted file mode 100755 index 67c773efd5..0000000000 --- a/src/MFT/MFT_CommandDescriptor.cxx +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright (c) 1999-2012 OPEN CASCADE SAS -// -// The content of this file is subject to the Open CASCADE Technology Public -// License Version 6.5 (the "License"). You may not use the content of this file -// except in compliance with the License. Please obtain a copy of the License -// at http://www.opencascade.org and read it completely before using this file. -// -// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its -// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. -// -// The Original Code and all software distributed under the License is -// distributed on an "AS IS" basis, without warranty of any kind, and the -// Initial Developer hereby disclaims all such warranties, including without -// limitation, any warranties of merchantability, fitness for a particular -// purpose or non-infringement. Please see the License for the specific terms -// and conditions governing the rights and limitations under the License. - -#include - -const Handle_Standard_Type& STANDARD_TYPE(MFT_CommandDescriptor) -{ - static Handle_Standard_Type _aType = new Standard_Type("MFT_CommandDescriptor",sizeof(MFT_CommandDescriptor)); - - return _aType; -} diff --git a/src/MFT/MFT_CommandDescriptor.hxx b/src/MFT/MFT_CommandDescriptor.hxx deleted file mode 100755 index 71c3011b1f..0000000000 --- a/src/MFT/MFT_CommandDescriptor.hxx +++ /dev/null @@ -1,35 +0,0 @@ -// Copyright (c) 1999-2012 OPEN CASCADE SAS -// -// The content of this file is subject to the Open CASCADE Technology Public -// License Version 6.5 (the "License"). You may not use the content of this file -// except in compliance with the License. Please obtain a copy of the License -// at http://www.opencascade.org and read it completely before using this file. -// -// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its -// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. -// -// The Original Code and all software distributed under the License is -// distributed on an "AS IS" basis, without warranty of any kind, and the -// Initial Developer hereby disclaims all such warranties, including without -// limitation, any warranties of merchantability, fitness for a particular -// purpose or non-infringement. Please see the License for the specific terms -// and conditions governing the rights and limitations under the License. - -#ifndef _MFT_CommandDescriptor_HeaderFile -#define _MFT_CommandDescriptor_HeaderFile - -typedef unsigned int MFT_CommandDescriptor; - -#define COMMAND_VALUETYPE(d,n) ((d >> (32 - 2*n)) & 0x3) -#define SET_COMMAND_VALUETYPE(d,n,t) (d |= t << (32 - 2*n)) -#define COMMAND_LENGTH(d) ((d >> 8) & 0xFF) -#define SET_COMMAND_LENGTH(d,l) (d = (d & 0xFFFF00FF) | (l << 8)) -#define COMMAND_TYPE(d) MFT_TypeOfCommand(d & 0xFF) -#define SET_COMMAND_TYPE(d,t) (d = (d & 0xFFFFFF00) | t) - -#ifndef _Standard_Type_HeaderFile -#include -#endif -const Handle(Standard_Type)& STANDARD_TYPE(MFT_CommandDescriptor); - -#endif diff --git a/src/MFT/MFT_FileHandle.hxx b/src/MFT/MFT_FileHandle.hxx deleted file mode 100755 index 4043c370e7..0000000000 --- a/src/MFT/MFT_FileHandle.hxx +++ /dev/null @@ -1,32 +0,0 @@ -// Copyright (c) 1999-2012 OPEN CASCADE SAS -// -// The content of this file is subject to the Open CASCADE Technology Public -// License Version 6.5 (the "License"). You may not use the content of this file -// except in compliance with the License. Please obtain a copy of the License -// at http://www.opencascade.org and read it completely before using this file. -// -// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its -// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. -// -// The Original Code and all software distributed under the License is -// distributed on an "AS IS" basis, without warranty of any kind, and the -// Initial Developer hereby disclaims all such warranties, including without -// limitation, any warranties of merchantability, fitness for a particular -// purpose or non-infringement. Please see the License for the specific terms -// and conditions governing the rights and limitations under the License. - -#ifndef _MFT_FileHandle_HeaderFile -#define _MFT_FileHandle_HeaderFile - -#define MFT_PAGESIZE 4096 - -#include - -typedef Standard_Integer MFT_FileHandle; - -#ifndef _Standard_Type_HeaderFile -#include -#endif -const Handle(Standard_Type)& STANDARD_TYPE(MFT_FileHandle); - -#endif diff --git a/src/MFT/MFT_FilePosition.hxx b/src/MFT/MFT_FilePosition.hxx deleted file mode 100755 index a0fc911c8b..0000000000 --- a/src/MFT/MFT_FilePosition.hxx +++ /dev/null @@ -1,30 +0,0 @@ -// Copyright (c) 1999-2012 OPEN CASCADE SAS -// -// The content of this file is subject to the Open CASCADE Technology Public -// License Version 6.5 (the "License"). You may not use the content of this file -// except in compliance with the License. Please obtain a copy of the License -// at http://www.opencascade.org and read it completely before using this file. -// -// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its -// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. -// -// The Original Code and all software distributed under the License is -// distributed on an "AS IS" basis, without warranty of any kind, and the -// Initial Developer hereby disclaims all such warranties, including without -// limitation, any warranties of merchantability, fitness for a particular -// purpose or non-infringement. Please see the License for the specific terms -// and conditions governing the rights and limitations under the License. - -#ifndef _MFT_FilePosition_HeaderFile -#define _MFT_FilePosition_HeaderFile - -#include - -typedef Standard_Integer MFT_FilePosition; - -#ifndef _Standard_Type_HeaderFile -#include -#endif -const Handle(Standard_Type)& STANDARD_TYPE(MFT_FilePosition); - -#endif diff --git a/src/MFT/MFT_FileRecord.cxx b/src/MFT/MFT_FileRecord.cxx deleted file mode 100755 index bc6ebd9a2e..0000000000 --- a/src/MFT/MFT_FileRecord.cxx +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright (c) 1999-2012 OPEN CASCADE SAS -// -// The content of this file is subject to the Open CASCADE Technology Public -// License Version 6.5 (the "License"). You may not use the content of this file -// except in compliance with the License. Please obtain a copy of the License -// at http://www.opencascade.org and read it completely before using this file. -// -// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its -// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. -// -// The Original Code and all software distributed under the License is -// distributed on an "AS IS" basis, without warranty of any kind, and the -// Initial Developer hereby disclaims all such warranties, including without -// limitation, any warranties of merchantability, fitness for a particular -// purpose or non-infringement. Please see the License for the specific terms -// and conditions governing the rights and limitations under the License. - -#include - -const Handle_Standard_Type& STANDARD_TYPE(MFT_FileRecord) -{ - static Handle_Standard_Type _aType = new Standard_Type("MFT_FileRecord",sizeof(MFT_FileRecord)); - - return _aType; -} diff --git a/src/MFT/MFT_FileRecord.hxx b/src/MFT/MFT_FileRecord.hxx deleted file mode 100755 index c4ef361a50..0000000000 --- a/src/MFT/MFT_FileRecord.hxx +++ /dev/null @@ -1,98 +0,0 @@ -// Copyright (c) 1999-2012 OPEN CASCADE SAS -// -// The content of this file is subject to the Open CASCADE Technology Public -// License Version 6.5 (the "License"). You may not use the content of this file -// except in compliance with the License. Please obtain a copy of the License -// at http://www.opencascade.org and read it completely before using this file. -// -// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its -// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. -// -// The Original Code and all software distributed under the License is -// distributed on an "AS IS" basis, without warranty of any kind, and the -// Initial Developer hereby disclaims all such warranties, including without -// limitation, any warranties of merchantability, fitness for a particular -// purpose or non-infringement. Please see the License for the specific terms -// and conditions governing the rights and limitations under the License. - -#ifndef _MFT_FileRecord_HeaderFile -#define _MFT_FileRecord_HeaderFile -#include -#include -#include - -#define MFT_BLOCKSIZE 512 //Physical record size - -#ifdef WNT -#include -#define MAP_FAILED -1 -#define MMAP(file_addr,mmap_size,fildes)\ - mmap ((off_t)file_addr, (int)mmap_size, (int)fildes) -#define MUNMAP(mmap_addr,mmap_size)\ - munmap ((void*)mmap_addr) -/* -#undef MMAP -#undef MUNMAP -*/ -#endif //WNT - -#if defined ( __hpux ) || defined ( HPUX ) -#include -#define MAP_FAILED -1 -#define MMAP(file_addr,mmap_size,fildes) \ - mmap((caddr_t) 0x80000000,(size_t) mmap_size,PROT_READ, \ - MAP_FILE | MAP_PRIVATE | MAP_VARIABLE,fildes,(off_t) file_addr) -#define MUNMAP(mmap_addr,mmap_size) \ - munmap((caddr_t) mmap_addr,(size_t) mmap_size) -#endif // __hpux - -#if defined ( sun ) || defined ( SOLARIS ) -#include -#define MMAP(file_addr,mmap_size,fildes) \ - mmap((caddr_t) 0x60000000,(size_t) mmap_size,PROT_READ, \ - MAP_PRIVATE,fildes,(off_t) file_addr) -#define MUNMAP(mmap_addr,mmap_size) \ - munmap((caddr_t) mmap_addr,(size_t) mmap_size) -#endif // sun - -#if defined ( sgi ) || defined ( IRIX ) -#include -#define MMAP(file_addr,mmap_size,fildes) \ - mmap((caddr_t) 0x60000000,(size_t) mmap_size,PROT_READ, \ - MAP_PRIVATE,fildes,(off_t) file_addr) -#define MUNMAP(mmap_addr,mmap_size) \ - munmap((caddr_t) mmap_addr,(size_t) mmap_size) -#endif // sgi - -#if defined ( __alpha) || defined ( DECOSF1 ) -#include -#define MMAP(file_addr,mmap_size,fildes) \ - mmap((caddr_t) 0x1000000000,(size_t) mmap_size,PROT_READ, \ - MAP_FILE | MAP_PRIVATE | MAP_VARIABLE,fildes,(off_t) file_addr) -#define MUNMAP(mmap_addr,mmap_size) \ - munmap((caddr_t) mmap_addr,(size_t) mmap_size) -#endif // __alpha - -#ifndef MMAP -// #error *** MMAP is not used on your system by MFT fonts *** -#endif - -typedef struct _MFT_FileRecord { - MFT_FileHandle fileHandle; - MFT_FilePosition beginPosition; //First record position of the section - MFT_FilePosition recordPosition; //Current record position - unsigned int recordSize; //Logical record size - Standard_Boolean update; //TRUE if something have change. - Standard_CString precord; //Process record address. - Standard_CString precordMMAPAddress;//MMAP physical record address - MFT_FilePosition recordMMAPPosition;//MMAP logical record position - long int recordMMAPSize; //MMAP physical record size - Standard_Boolean swap; //TRUE if this record must be swapped -} MFT_FileRecord; - -#ifndef _Standard_Type_HeaderFile -#include -#endif -const Handle(Standard_Type)& STANDARD_TYPE(MFT_FileRecord); - -#endif diff --git a/src/MFT/MFT_FontManager.cdl b/src/MFT/MFT_FontManager.cdl deleted file mode 100755 index 08ba0cee1f..0000000000 --- a/src/MFT/MFT_FontManager.cdl +++ /dev/null @@ -1,731 +0,0 @@ --- Created on: 1997-03-03 --- Created by: Gerard GRAS --- Copyright (c) 1997-1999 Matra Datavision --- Copyright (c) 1999-2012 OPEN CASCADE SAS --- --- The content of this file is subject to the Open CASCADE Technology Public --- License Version 6.5 (the "License"). You may not use the content of this file --- except in compliance with the License. Please obtain a copy of the License --- at http://www.opencascade.org and read it completely before using this file. --- --- The Initial Developer of the Original Code is Open CASCADE S.A.S., having its --- main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. --- --- The Original Code and all software distributed under the License is --- distributed on an "AS IS" basis, without warranty of any kind, and the --- Initial Developer hereby disclaims all such warranties, including without --- limitation, any warranties of merchantability, fitness for a particular --- purpose or non-infringement. Please see the License for the specific terms --- and conditions governing the rights and limitations under the License. - - - -class FontManager from MFT inherits TShared from MMgt - - ---Purpose: This class permits to manage MDTV fonts. - -- Warning: A FontManager is associated to a xxx.mft font file - -- The coordinates of the outline vectors of each character - -- must be given in the space defined by the font bounding box - - -uses - - TextManager from MFT, - TypeOfCommand from MFT, - TypeOfValue from MFT, - CommandDescriptor from MFT, - FileRecord from MFT, - FileHandle from MFT, - FilePosition from MFT, - FontStyle from Aspect, - AsciiString from TCollection, - Length from Quantity, - Factor from Quantity, - PlaneAngle from Quantity, - OpenMode from OSD - -raises - - FontManagerDefinitionError from MFT, - FontManagerError from MFT, - OutOfRange from Standard, - OutOfMemory from Standard, - TypeMismatch from Standard - -is - - ------------------------- - -- Category: Constructors - ------------------------- - - Create (anAliasName: CString from Standard) - returns mutable FontManager from MFT - ---Level: Public - ---Purpose: Gives access to the font associated - -- to the file $CSF_MDTVFontDirectory/.mft - -- in ReadOnly access mode. - -- Warning: If the symbol CSF_MDTVFontDirectory is not defined - -- try to reads or writes in $PWD directory. - -- Example: myFontManager = new MFT_FontManager("Helvetica-Bold") - -- permits to access to the file - -- $CSF_MDTVFontDirectory/"helvetica-bold.mft" - -- Trigger: If the font file don't exist or if the file - -- don't have an MFT signature. - - raises FontManagerDefinitionError from MFT; - - Create (aFont: FontStyle from Aspect; - aFileMode: OpenMode from OSD = OSD_ReadOnly; - isComposite: Boolean from Standard = Standard_False) - returns mutable FontManager from MFT - ---Level: Public - ---Purpose: Gives access to the font associated - -- to the file $CSF_MDTVFontDirectory/.mft - -- with the open mode and the composite - -- flag . - -- Example: The flag must be sets to TRUE for KANJI extended fonts. - -- Warning: If the symbol CSF_MDTVFontDirectory is not defined - -- try to reads or writes in $PWD directory. --- Trigger: If is ReadOnly or ReadWrite and - -- the font file don't exist or if the file - -- don't have an MFT signature. - - raises FontManagerDefinitionError from MFT; - - ------------------------- - -- Category: Destructors - ------------------------- - - Destroy ( me : mutable); - ---Level: Internal - ---Purpose: Save the font file when the open mode is - -- Write or ReadWrite and Close it in all the case. - ---C++: alias ~ - - --------------------------------------------- - -- Category: Methods to updates the .mft files - --------------------------------------------- - - SetFont (me : mutable; - aFont: FontStyle from Aspect) - ---Level: Advanced - ---Purpose: Updates the font name. - -- Trigger: If the font file is not opened - -- in WriteOnly or ReadWrite mode - - raises FontManagerError from MFT; - - SetChar (me: mutable; - aChar: Character from Standard) - ---Level: Advanced - ---Purpose: Defines and Enable the char for writing. --- Trigger: If the font file is not opened - -- in WriteOnly or ReadWrite mode - -- or the char is already defined. - raises FontManagerError from MFT; - - - SetAccentChar (me: mutable; - aChar: Character from Standard) - ---Level: Advanced - ---Purpose: Defines and Enable the accent char for writing. --- Trigger: If the font file is not opened - -- in WriteOnly or ReadWrite mode - -- or the char is already defined. - - raises FontManagerError from MFT; - - SetChar (me: mutable; - aChar: ExtCharacter from Standard) - ---Level: Advanced - ---Purpose: Defines and Enable the char for writing. - -- This char being current for adding command. - -- Warning: The char must have an UNICODE UCS2 encoding. - -- Trigger: If the font file is not opened - -- in WriteOnly or ReadWrite mode - -- or if the font is not a composite font. - - raises FontManagerError from MFT; - - SetEncoding (me: mutable; - aPosition: Integer from Standard; - anEncoding: CString from Standard) - ---Purpose: Changes the default encoding of the char position - -- . - -- Example: SetEncoding(233,"eacute") - -- change the default encoding of the char position 233 - -- from "Oslash" to "eacute". - raises FontManagerError from MFT; - ---Purpose: Trigger - If the font file is not opened - -- in WriteOnly or ReadWrite mode. - -- or if the char encoding is not defined. - - DelChar (me: mutable; - aChar: Character from Standard) - ---Level: Advanced - ---Purpose: Remove the definition of the char - raises FontManagerError from MFT; - ---Purpose: Trigger - If the font file is not opened - -- in WriteOnly or ReadWrite mode. - - DelChar (me: mutable; - aChar: ExtCharacter from Standard) - ---Level: Advanced - ---Purpose: Remove the definition of the char - -- This char being current for adding command. - --Warning: The char must have an UNICODE UCS2 encoding. - raises FontManagerError from MFT; - ---Purpose: Trigger - If the font file is not opened - -- in WriteOnly or ReadWrite mode - -- or if the font is not a composite font. - - AddCommand (me : mutable; - aCommand: TypeOfCommand from MFT) - ---Level: Advanced - ---Purpose: Adds the command of - -- to describe the current char. - -- This command being current for adding parameters if any. - raises FontManagerError from MFT; - ---Purpose Trigger - If the font file is not opened - -- in WriteOnly or ReadWrite mode - -- or if a current char don't have being defined. - -- Warning: the last command of the char descriptor - -- must have a type MFC_TOC_ENDCHAR. - - AddValue (me : mutable; - aValue: Integer from Standard) - ---Level: Advanced - ---Purpose: Adds the integer parameter to fill - -- the current command. - raises FontManagerError from MFT; - ---Purpose: Trigger - If the font file is not opened - -- in WriteOnly or ReadWrite mode - -- or if a current command don't have being defined, - -- or if the number of values is > MaxCommandValues() - - AddValue (me : mutable; - aValue: Real from Standard) - ---Level: Advanced - ---Purpose: Adds the float parameter to fill - -- the current command. - raises FontManagerError from MFT; - ---Purpose: Trigger - If the font file is not opened - -- in WriteOnly or ReadWrite mode - -- or if a current command don't have being defined - -- or if the number of values is > MaxCommandValues() - - AddValue (me : mutable; - aValue: CString from Standard) - ---Level: Advanced - ---Purpose: Adds the string parameter to fill - -- the current command. - raises FontManagerError from MFT; - ---Purpose: Trigger - If the font file is not opened - -- in WriteOnly or ReadWrite mode - -- or if a current command don't have being defined, - -- or if the number of values is > MaxCommandValues() - -- Warning: The max length of a string must be < MaxCommandValues()*4-1 - - SetBoundingBox (me : mutable; - aMinX: Integer from Standard = 0; - aMinY: Integer from Standard = 0; - aMaxX: Integer from Standard = 1000; - aMaxY: Integer from Standard = 1000) - ---Level: Advanced - ---Purpose: Sets the bounding box of the font. - raises FontManagerError from MFT; - ---Purpose: Trigger - If the font file is not opened - -- in WriteOnly or ReadWrite mode - -- or if the bounding box has a wrong value. - -- Warning: The bounding box coordinates default are : - -- 0,0,1000,1000 - - SetFontMatrix (me : mutable; - M1: Real from Standard = 0.001; - M2: Real from Standard = 0.0; - M3: Real from Standard = 0.0; - M4: Real from Standard = 0.001; - M5: Real from Standard = 0.0; - M6: Real from Standard = 0.0) - ---Level: Advanced - ---Purpose: Sets the font matrix. - raises FontManagerError from MFT; - ---Purpose: Trigger - If the font file is not opened - -- in WriteOnly or ReadWrite mode - -- Warning: The font matrix default are : - -- 0.001,0,0,0.001,0,0 - - SetPaintType (me : mutable; - aValue: Integer from Standard = 0) - ---Level: Advanced - ---Purpose: Sets the paint type of the font. - raises FontManagerError from MFT; - ---Purpose: Trigger - If the font file is not opened - -- in WriteOnly or ReadWrite mode - -- or if the value is not a Type 1 font value. - -- Warning: The paint type must be one of Type 1 font - -- value 0 for FILL , 1 for STROKE or 2 for OUTLINE. - - SetFixedPitch (me : mutable; - aFlag: Boolean from Standard = Standard_False) - ---Level: Advanced - ---Purpose: Sets the fixed pitch flag of the font - -- as TRUE if the font must have an fixed char width - -- or FALSE if the font must have a proportionnal char width. - raises FontManagerError from MFT; - ---Purpose: Trigger - If the font file is not opened - -- in WriteOnly or ReadWrite mode - - SetItalicAngle (me : mutable; - anAngle: PlaneAngle from Quantity = 0.0) - ---Level: Advanced - ---Purpose: Sets the italic angle of the font given in RAD - -- clock-wise from vertical. - raises FontManagerError from MFT; - ---Purpose: Trigger - If the font file is not opened - -- in WriteOnly or ReadWrite mode - - ComputeBoundingBox (me: mutable) - ---Level: Advanced - ---Purpose: Computes the bounding box of the font from the - -- min-max of all chars of the font. - -- Warning: this must be call after all characters has been defined. - raises FontManagerError from MFT; - ---Purpose: Trigger - If the font file is not opened - -- in WriteOnly or ReadWrite mode. - - --------------------------------------------------------------- - -- Category: Methods to sets the current interpretor attributes - --------------------------------------------------------------- - - SetFontAttribs (me: mutable; - aWidth,aHeight: Length from Quantity; - aSlant: PlaneAngle from Quantity = 0.0; - aPrecision: Factor from Quantity = 0.02; - aCapsHeight: Boolean from Standard = Standard_False); - ---Level: Public - ---Purpose: Sets the current font attributes. - -- : the maximum width of one character. - -- : the maximum height of one character - -- according to the parameter. - -- : the slant of one character given in RAD - -- clock-wise from vertical. - -- : the relative interpolator precision is - -- the maximum flatness error deflection for the curves. - -- : if TRUE the font height is apply only - -- on the ascent component of the characters; - -- if FALSE the font height is apply both - -- on the ascent and descent components of the characters. - - ---------------------------------------------------------------- - -- Category: Methods to retrieve current attributes informations. - ---------------------------------------------------------------- - - DrawText (me: mutable; - aTextManager: TextManager from MFT; - aString: CString from Standard; - anX,anY: Length from Quantity; - anOrientation: PlaneAngle from Quantity = 0.0); - ---Level: Public - ---Purpose: Drawn an ANSI text - -- : the draw manager to call for each vertex of the string. - -- : the string to interpret - -- , : the position of the text - -- : the orientation angle in RAD from horizontal. - - DrawText (me: mutable; - aTextManager: TextManager from MFT; - aString: ExtString from Standard; - anX,anY: Length from Quantity; - anOrientation: PlaneAngle from Quantity = 0.0) - ---Level: Public - ---Purpose: Drawn an EXTENDED text - -- : the draw manager to call for each vertex of the string. - -- : the string to interpret - -- , : the position of the text - -- : the orientation angle in RAD from horizontal. - raises FontManagerError from MFT; - ---Purpose: Trigger - If the font is not a composite font and - -- the string is not ASCII. - - BoundingBox (me ; - aMinX,aMinY,aMaxX,aMaxY: out Integer from Standard); - ---Level: Advanced - ---Purpose: Retrieves the bounding box of the font. - - CharBoundingBox (me : mutable ; - aPosition: Integer from Standard; - aMinX,aMinY,aMaxX,aMaxY: out Integer from Standard) - ---Level: Advanced - ---Purpose: Retrieves the bounding box of a character. - raises FontManagerError from MFT; - ---Purpose: Trigger - If the position is < 0 or > MaxCharPosition(). - - PaintType (me) - returns Integer from Standard; - ---Level: Advanced - ---Purpose: Retrieves the paint type of the font. - - FixedPitch (me) - returns Boolean from Standard; - ---Level: Advanced - ---Purpose: Retrieves the fixed pitch flag of the font - - ItalicAngle (me) - returns PlaneAngle from Quantity; - ---Level: Advanced - ---Purpose: Retrieves the italic angle of the font - - FontAttribs (me : mutable; - aWidth,aHeight,aDescent: out Length from Quantity; - aSlant: out PlaneAngle from Quantity; - aPrecision: out Factor from Quantity; - aCapsHeight: out Boolean from Standard) - returns CString from Standard; - ---Level: Public - ---Purpose: Runs the interpretor with the current attributes setting - -- (font and text attributes) - -- and returns : - -- The max char width of the font CharSet . - -- The max char height of the font CharSet . - -- The max char descent value below the baseline - -- The slant angle of the font - -- The interpolator precision of the font - -- The caps height flag - -- The FULL font name. - - TextSize (me : mutable; - aString: CString from Standard; - aWidth,anAscent,aLbearing,aDescent: out Length from Quantity); - ---Level: Public - ---Purpose: Runs the interpretor on the ASCII text - -- with the current font attributes setting and returns : - -- The string width . - -- The string ascent . - -- The string left bearing value from the origine - -- The string descent value below the baseline - - TextSize (me : mutable; - aString: ExtString from Standard; - aWidth,anAscent,aLbearing,aDescent: out Length from Quantity) - ---Level: Public - ---Purpose: Runs the interpretor on the EXTENDED text - -- with the current font attributes setting and returns : - -- The string width . - -- The string ascent . - -- The string left bearing value from the origine - -- The string descent value below the baseline - raises FontManagerError from MFT; - ---Purpose: Trigger - If the font is not a composite font and - -- the string is not ASCII. - - CharSize (me : mutable; - aChar: Character from Standard; - aWidth,aLbearing,aRbearing: out Length from Quantity; - anAscent,aDescent: out Length from Quantity) - returns Boolean from Standard; - ---Level: Public - ---Purpose: Runs the interpretor with the current attributes setting - -- (font attributes) - -- and returns : - -- The char width . - -- The char left bearing . - -- The char right bearing . - -- The char ascent . - -- The char descent value below the baseline - -- And returns TRUE if the character is defined. - - CharSize (me : mutable; - aChar: ExtCharacter from Standard; - aWidth,aLbearing,aRbearing: out Length from Quantity; - anAscent,aDescent: out Length from Quantity) - returns Boolean from Standard - ---Level: Public - ---Purpose: Runs the interpretor with the current attributes setting - -- (font attributes) - -- and returns : - -- The extended char width . - -- The extended char left bearing . - -- The extended char right bearing . - -- The extended char ascent . - -- The extended char descent value below the baseline - -- And returns TRUE if the character is defined. - raises FontManagerError from MFT; - ---Purpose: Trigger - If the font is not a composite font and - -- the char is not ASCII. - - ---------------------------- - -- Category: Inquire methods - ---------------------------- - - Font (me) - returns FontStyle from Aspect; - ---Level: Public - ---Purpose: Retrieves the font descriptor of this font - - IsComposite (me) - returns Boolean from Standard; - ---Level: Public - ---Purpose: Returns TRUE if the font is composite. - -- Example: KANJI fonts returns TRUE. - - IsKnown (myclass; - anAliasName: CString from Standard) - returns Boolean from Standard; - ---Purpose: Returns TRUE if the font - -- $CSF_MDTVFontDirectory/.mft does exist. - - Font (myclass; - anAliasName: CString from Standard) - returns FontStyle from Aspect - ---Level: Public - ---Purpose: Retrieves the font descriptor from an existing font - raises FontManagerError from MFT; - ---Purpose: Trigger - If the font does not exist. - - FontNumber (myclass; - aFilter: CString from Standard = "*") - returns Integer from Standard; - ---Level: Public - ---Purpose: Returns the MFT font number available - -- in the directory $CSF_MDTVFontDirectory - -- according to the filter : - -- "-foundry-family-weight-slant-swidth-adstyl-pixelsize-pointsize- - -- resx-resy-spacing-avdWidth-registry-encoding" - -- Examples: number = MFT_FontMAnager::FontNumber("-euclid3"); - -- returns only the euclid3 fonts. - -- number = MFT_FontMAnager::FontNumber( - -- "-*-*-*-*-*-*-*-*-*-*-*-*-japanese"); - -- returns only the japanese fonts. - - Font (myclass; - aRank: Integer from Standard) - returns FontStyle from Aspect - ---Level: Public - ---Purpose: Retrieves the font descriptor of index - -- from the directory $CSF_MDTVFontDirectory - raises OutOfRange from Standard; - ---Purpose: Trigger - If the font rank is < 1 or > FontNumber(). - - MaxCommandValues (myclass) - returns Integer from Standard; - ---Purpose: Returns the max values of any defined command - - Encoding (me: mutable; - aPosition: Integer from Standard) - returns CString from Standard - ---Purpose: Returns the encoding of the char position - -- . - raises FontManagerError from MFT; - ---Purpose: Trigger - If the char is not defined - - Encoding (me: mutable; - anEncoding: CString from Standard) - returns Integer from Standard - ---Purpose: Returns the char position - -- from the encoding . - raises FontManagerError from MFT; - ---Purpose: Trigger - If the char is not defined - - Dump (me : mutable); - ---Level: Public - ---Purpose: Dumps the font descriptor of all characters. - - Dump (me : mutable; aChar: Character from Standard); - ---Level: Public - ---Purpose: Dumps the font descriptor of the character . - - Dump (me : mutable; aChar: ExtCharacter from Standard) - ---Level: Public - ---Purpose: Dumps the font descriptor of the extended character . - raises FontManagerError from MFT; - ---Purpose: Trigger - If the font is not a composite font. - - Save (me : mutable) returns Boolean from Standard; - ---Level: Public - ---Purpose: Saves the entire MFT font in an ASCII format - -- readable by the Restore() method. - -- to the file $CSF_MDTVFontDirectory/.dat - -- And returns TRUE if the file have been saves correctly. - - Restore (myclass; anAliasName: CString from Standard) returns Boolean from Standard; - ---Level: Public - ---Purpose: Restores the entire MFT font - -- from the file $CSF_MDTVFontDirectory/.dat - -- And returns TRUE if the file have been restores correctly. - - UnderlinePosition (me) returns Length from Quantity; - ---Level: Public - ---Purpose: Returns the Underline descent position from the origin - -- of the text according to the current font attributes. - - ---------------------------- - -- Category: Private methods - ---------------------------- - - Open (myclass; - aFileName: AsciiString from TCollection; - aFileMode: OpenMode from OSD) - returns FileHandle from MFT is private; - ---Purpose: Open the file ,load and verify the header - -- and returns a file handle >= 0 - - Close (myclass; aFileHandle: FileHandle from MFT) - returns Boolean from Standard is private; - ---Purpose: Close the file. - -- Returns TRUE if the file was successfully closed. - - Close (me: mutable) - returns Boolean from Standard is private; - ---Purpose: Saves updated records and Close this file. - -- Returns TRUE if the file was successfully closed. - - Read (myclass; aRecord: in out FileRecord from MFT) - returns Boolean from Standard is private; - ---Purpose: Reads a record from the file. - -- Returns TRUE if the file was successfully read. - - Write (myclass; aRecord: in out FileRecord from MFT) - returns Boolean from Standard is private; - ---Purpose: Writes a record to the file. - -- Returns TRUE if the file was successfully written. - - Locate (myclass; aRecord: in out FileRecord from MFT; - aFilePosition: FilePosition from MFT) - returns Address from Standard is private; - ---Purpose: Locates an information from the file record. - -- and returns the info address. - -- Warning: May read or write the current record - -- from/to the file and reload an other record - -- according the file position info. - - Path (myclass; - aFileName: AsciiString from TCollection; - anExtension: CString from Standard = ".mft") - returns CString from Standard is private; - ---Purpose: Computes the full path of the font file name - -- $CSF_MDTVFontDirectory/ - - MaxCharPosition (me) - returns Integer from Standard is private; - ---Purpose: Returns the max position of any defined char - -- in the header of the file according with the - -- type of the font. - - SetTextAttribs (me : mutable; - aString: CString from Standard; - anOrientation: PlaneAngle from Quantity = 0.0) is private; - ---Purpose: Sets the text attributes. - -- : the string to interpret - -- : the orientation angle in RAD from horizontal. - - SetTextAttribs (me : mutable; - aString: ExtString from Standard; - anOrientation: PlaneAngle from Quantity = 0.0) - ---Purpose: Sets the extended text attributes. - -- : the string to interpret - -- : the orientation angle in RAD from horizontal. - raises FontManagerError from MFT is private; - ---Purpose: Trigger - If the font is not a composite font and - -- the string is not ASCII. - - IsDefinedChar (me; - aPosition: Integer from Standard) - returns Boolean from Standard - ---Purpose: Returns TRUE if the char at position is defined - -- in the header of the file. - raises FontManagerError from MFT is private; - ---Purpose: Trigger - If the position is < 0 or > MaxCharPosition(). - - FirstDefinedChar (me) - returns Integer from Standard is private; - ---Purpose: Returns the first defined char position - -- in the header of the file.. - - LastDefinedChar (me) - returns Integer from Standard is private; - ---Purpose: Returns the last defined char position - -- in the header of the file.. - - SetChar (me: mutable; - aPosition: Integer from Standard) is private; - ---Purpose: Enable the char at position for reading. - - DrawChar (me: mutable; - aTextManager: TextManager from MFT; - aPosition: Integer from Standard) - returns Boolean from Standard is private; - ---Purpose: Drawn the char at position - -- with the draw manager . - -- and returns FALSE if the drawing must be ended. - - ComputeBoundingBox (me: mutable; - aPosition: Integer from Standard) is private; - ---Purpose: Computes the bounding box of the char position . - - NextCommand (myclass; aRecord: in out FileRecord from MFT) - returns CommandDescriptor from MFT is private; - ---Purpose: Returns the next command descriptor - -- from the current char (see SetChar()). - -- Warning: the last command of the char descriptor - -- has a type MFC_TOC_ENDCHAR. - - Value(myclass; - aDescriptor: CommandDescriptor from MFT; - aRank: Integer from Standard) - returns TypeOfValue from MFT - ---Purpose: Returns the value type at position - -- from the descriptor command. - raises FontManagerError from MFT is private; - ---Purpose: Trigger - If the position is < 1 or > the command length. - - IValue (myclass; aRecord: in out FileRecord from MFT; - aRank: Integer) - returns Integer from Standard - ---Purpose: Returns the integer parameter at position - -- of the current command. - raises TypeMismatch from Standard is private; - ---Purpose: Trigger --If the position is < 1 or > the command length. - -- or if the value is not an INT value. - - FValue (myclass; aRecord: in out FileRecord from MFT; - aRank: Integer) - returns ShortReal from Standard - ---Purpose: Returns the float parameter at position - -- of the current command. - raises TypeMismatch from Standard is private; - ---Purpose: Trigger - If the position is < 1 or > the command length. - -- or if the value is not a FLOAT value. - - SValue (myclass; aRecord: in out FileRecord from MFT; - aRank: Integer) - returns CString from Standard - ---Purpose: Returns the string parameter at position - -- of the current command. - raises TypeMismatch from Standard is private; - ---Purpose: Trigger - If the position is < 1 or > the command length. - -- or if the value is not a STRING value. - - Dump (me : mutable; aPosition: Integer from Standard) is private; - ---Purpose: Dumps the font descriptor of the character at - -- position . - -fields - - myFileName: AsciiString from TCollection; - myFileMode: OpenMode from OSD; - myFileHandle: FileHandle from MFT; - myIsComposite: Boolean from Standard; - myIsFixedPitch: Boolean from Standard; - myItalicAngle: ShortReal from Standard; - myPaintType: Integer from Standard; - myCharWidth: ShortReal from Standard; - myCharHeight: ShortReal from Standard; - myCharSlant: ShortReal from Standard; - myCharPrecision: ShortReal from Standard; - myCharCapsHeight: Boolean from Standard; - myFileHeader: FileRecord from MFT; - myCharEntries: FileRecord from MFT; - myCommandBuffer: FileRecord from MFT; - -end FontManager from MFT; diff --git a/src/MFT/MFT_FontManager.cxx b/src/MFT/MFT_FontManager.cxx deleted file mode 100755 index 90808b6bc1..0000000000 --- a/src/MFT/MFT_FontManager.cxx +++ /dev/null @@ -1,3718 +0,0 @@ -// Created on: 1997-03-07 -// Created by: Gerard GRAS -// Copyright (c) 1997-1999 Matra Datavision -// Copyright (c) 1999-2012 OPEN CASCADE SAS -// -// The content of this file is subject to the Open CASCADE Technology Public -// License Version 6.5 (the "License"). You may not use the content of this file -// except in compliance with the License. Please obtain a copy of the License -// at http://www.opencascade.org and read it completely before using this file. -// -// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its -// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. -// -// The Original Code and all software distributed under the License is -// distributed on an "AS IS" basis, without warranty of any kind, and the -// Initial Developer hereby disclaims all such warranties, including without -// limitation, any warranties of merchantability, fitness for a particular -// purpose or non-infringement. Please see the License for the specific terms -// and conditions governing the rights and limitations under the License. - -//-- Update: gg 19-01-98 -//-- reason : -// Suppress global static class variables from this class -// LOADER optimisation. -#define S3593 //gg 13-03-98 -//-- reason : -// OPTIMISATION MFT -// -utilisation optimum de MMAP. -// -rendre statique la declaration des types importes. -#define CTS20718 //syl 04-09-98 -// -meilleure precision sur la vectorisation des polices courier ... -#define PRO17604 //GG_210199 -// Avoid to crash at object creation time due to wrong -// sprintf() call -// JR 10.02.100 : OSD_FileIterator files(pathdir,"*.mft"); -// g++(Linux) : no matching function(OSD_Path()(),char[6]) - -// FMN 11-01-99 -//---Comments : -// MFT File format -// --------------- -// An xxx.mft file contains an HEADER of size 512 bytes (first record), -// a CHAR ENTRIES VECTOR of size 512 or 65536 int -// (second record) -// a COMMAND SECTION of size 512 * N (next records) -// according to the MFT_COMMANDBUFFERSIZE parameter. -// The xxx.mft name of the file depends directly of the xxx alias name of the -// font (i.e: Helvetica-Bold.mft) -// Header format (Record 0) -// ############# -// abs byte location component type comments -// ----------------- --------- ---- -------- -// 0 signature uint MFT file signature. -// 4 iscomposite bool True for extended font. -// 8 pentries int Char entries section address -// 12 pcommands int Command section address -// 16 freeSpace int Free space address -// 20 fontBox int array Font bounding box -// 36 paintType int Font paint type -// 40 version int File creation ID -// 44 fixedPitch bool False if proportionnal -// 48 fontMatrix int array Font matrix -// 72 italicAngle int Font Italic Angle -// 76 dummy char array adjustable dummy -// ?? fontName char array Full font name. -// Char entries vector format (Record 1) -// ########################## -// abs byte location component type comments -// ----------------- --------- ---- -------- -// 512 fcommand int array First command descriptor vector address. -// Command section format (record 2 at ....) -// ###################### -// abs byte location component type comments -// ----------------- --------- ---- -------- -// 2100 or 262656 command header bit field First command descriptor -// ... -// EOF End of file Free space address -// Command format -// ############## -// rel byte location component type comments -// ----------------- --------- ---- -------- -// 0 value1_type bit field:2 1:int,2:float,3:string -// 0 value2_type bit field:2 1:int,2:float,3:string -// 0 value3_type bit field:2 1:int,2:float,3:string -// 0 value4_type bit field:2 1:int,2:float,3:string -// 1 value5_type bit field:2 1:int,2:float,3:string -// 1 value6_type bit field:2 1:int,2:float,3:string -// 1 value7_type bit field:2 1:int,2:float,3:string -// 1 value8_type bit field:2 1:int,2:float,3:string -// 2 length bit field:8 max 8 -// 3 type bit field:8 MFT_TypeOfCommand -// 4 value1 card32 int,float or string value -// ... -// 4+4*(N-1) valueN card32 - -#ifdef HAVE_CONFIG_H -# include -#endif - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#ifdef HAVE_UNISTD_H -# include -#endif - -#include -#include - -#ifdef HAVE_SYS_TYPES_H -# include -#endif - -#if defined(HAVE_SYS_STAT_H) || defined(WNT) -# include -#endif - -#include -#include -#include - -// -------------------------------- -// -- Category: Local constants -// -------------------------------- - -#define TRACE 0 -#define TRACE_MMAP 0 -//#define MFT_VERSION 970605 -#define MFT_VERSION 970623 -#define MFT_DUMMYSIZE 180 -#define MFT_MAXFONTNAME 256 -#define MFT_SIGNATURE 0x30c730a3 -#define MFT_MAXASCIICHARENTRIES 256 -#define MFT_MAXSEACCHARENTRIES 256 -#define MFT_MAXEXTENDEDCHARENTRIES 65536 -#define MFT_MAXVALUES 8 -#define MFT_MAXSTACKVALUES 16 - -// -------------------------------- -// -- Category: Local structures -// -------------------------------- - - -#define MFT_COMMANDBUFFERSIZE 512 -typedef struct _MFT_CommandBuffer { - char command[MFT_COMMANDBUFFERSIZE]; -} MFT_CommandBuffer; - -typedef union _MFT_CommandValue { - int i; - float f; - char s[4]; - MFT_CommandDescriptor d; -} MFT_CommandValue; - -typedef struct _MFT_AsciiCharEntries { //First command entries - MFT_FilePosition fcommand[MFT_MAXASCIICHARENTRIES+MFT_MAXSEACCHARENTRIES]; -} MFT_AsciiCharEntries; - -typedef struct _MFT_ExtendedCharEntries { //First command entries - MFT_FilePosition fcommand[MFT_MAXEXTENDEDCHARENTRIES]; -} MFT_ExtendedCharEntries; - -typedef union _MFT_CharEntries { - MFT_AsciiCharEntries ascii; - MFT_ExtendedCharEntries extended; - MFT_FilePosition fcommand[1]; -} MFT_CharEntries; - -typedef struct _MFT_FileHeader { - unsigned int signature; - Standard_Boolean iscomposite; //True if this is an extended font. - MFT_FilePosition pentries; //Starting char entries section address - MFT_FilePosition pcommands; //Starting command section address - MFT_FilePosition freeSpace; //Free space address - Standard_Integer fontBox[4]; //Bounding box of the MAX character size - Standard_Integer paintType; //Font paint type - Standard_Integer version; //File creation ID - Standard_Boolean fixedPitch; //Font proportionnal flag - Standard_Integer fontMatrix[6]; //Font matrix * FTOI - Standard_Integer italicAngle; //Font italic angle - Standard_Character dummy[MFT_DUMMYSIZE]; - Standard_Character fontName[MFT_MAXFONTNAME]; -} MFT_FileHeader; - - -// ----------------------------- -// -- Category: Static variables -// ----------------------------- - -static MFT_ListOfFontName& _theListOfOpenFontName() { -static MFT_ListOfFontName theListOfOpenFontName; - return theListOfOpenFontName; -} -#define theListOfOpenFontName _theListOfOpenFontName() - -static MFT_ListOfFontHandle& _theListOfOpenFontHandle() { -static MFT_ListOfFontHandle theListOfOpenFontHandle; - return theListOfOpenFontHandle; -} -#define theListOfOpenFontHandle _theListOfOpenFontHandle() - -static MFT_ListOfFontReference& _theListOfOpenFontReference() { -static MFT_ListOfFontReference theListOfOpenFontReference; - return theListOfOpenFontReference; -} -#define theListOfOpenFontReference _theListOfOpenFontReference() - -static MFT_ListOfFontName& _theListOfFontName() { -static MFT_ListOfFontName theListOfFontName; - return theListOfFontName; -} -#define theListOfFontName _theListOfFontName() - -static Handle(MFT_TextManager)& _theTextManager() { -static Handle(MFT_TextManager) theTextManager = new MFT_TextManager(); - return theTextManager; -} -#define theTextManager _theTextManager() - -static OSD_Environment& _CSF_MDTVFontDirectory() { -static OSD_Environment CSF_MDTVFontDirectory("CSF_MDTVFontDirectory"); - return CSF_MDTVFontDirectory; -} -#define CSF_MDTVFontDirectory _CSF_MDTVFontDirectory() - -static OSD_Environment& _CSF_MDTVFontPrecision() { -static OSD_Environment CSF_MDTVFontPrecision("CSF_MDTVFontPrecision"); - return CSF_MDTVFontPrecision; -} -#define CSF_MDTVFontPrecision _CSF_MDTVFontPrecision() - -static TCollection_AsciiString& _theAsciiString() { -static TCollection_AsciiString theAsciiString; - return theAsciiString; -} -#define theAsciiString _theAsciiString() - -static TCollection_ExtendedString& _theExtendedString() { -static TCollection_ExtendedString theExtendedString; - return theExtendedString; -} -#define theExtendedString _theExtendedString() - -static Standard_Integer theCharCount = 0; -static Standard_Integer theCharPosition = 0; -static Standard_Integer theStringLength = 0; -static Standard_Boolean theStringIsAscii = Standard_True; -static MFT_CommandDescriptor theCommand; -static MFT_TypeOfValue theValueType = MFT_TOV_UNKNOWN; -static MFT_TypeOfCommand theCommandType = MFT_TOC_UNKNOWN; -static Standard_Integer theCommandLength = 0; -static MFT_FilePosition theFirstCommandPosition,theNextCommandPosition,theCommandPosition; -static Standard_Integer theValueCount = 0; -static Standard_Integer theStackCount = 0; -static Standard_Integer theIStack[MFT_MAXSTACKVALUES]; -static Standard_Real theRStack[MFT_MAXSTACKVALUES]; -static Standard_Integer theIValues[MFT_MAXVALUES]; -static Standard_Real theFValues[MFT_MAXVALUES]; -static Standard_Character theSValues[MFT_MAXVALUES*sizeof(MFT_CommandValue)]; -static Standard_Real theDeltaX,theCharX,theCharY,theOldCharX,theOldCharY; -static Standard_Real theLeftCharX,theLeftCharY,theCharWidth,theCharHeight; -static Standard_Real theStringX,theStringY,theFixedCharWidth; -static Standard_Integer theSeacBaseChar,theSeacAccentChar; -static Standard_Real theSeacAsbValue,theSeacAdxValue,theSeacAdyValue; -static Standard_Real theTanCharSlant; -static Standard_Real theSinCharAngle,theCosCharAngle; -static Standard_Real theFontXRatio,theFontYRatio; -static Standard_Real theCurveT,theCurveX0,theCurveAX,theCurveBX,theCurveCX; -static Standard_Real theCurveDT,theCurveY0,theCurveAY,theCurveBY,theCurveCY; -static Standard_Real theCurvePrecision = 10.0,theCurveFlatness = 1.0; -static Standard_Integer theCurveNT; -static Standard_Boolean theDotSection,theMDTVFontPrecision = Standard_False; -static Standard_Real theOrientation; - -#ifdef MMAP -#ifndef WNT -static long int thePageSize = sysconf(_SC_PAGESIZE); -#else -////////////////////////////// WNT MMAP (MUNMAP) ////////////////////////// -#define STRICT -#ifndef NODRAWTEXT -#define NODRAWTEXT -#endif -#include -#include - -DWORD WNT_PageSize () { SYSTEM_INFO si; GetSystemInfo (&si); - return 32*si.dwPageSize; } -DWORD WNT_AllocGranularity () { SYSTEM_INFO si; GetSystemInfo (&si); - return si.dwAllocationGranularity; } - -static long thePageSize = WNT_PageSize (); -static long theAllocGranularity = WNT_AllocGranularity (); - -/*====================================================*/ -void errstr (char* str, DWORD errcode) -{ - LPVOID lpMsgBuf; - FormatMessage( - FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM, - NULL, errcode, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), - (LPTSTR) &lpMsgBuf, 0, NULL); - cout << str << ":\n" << (char*)lpMsgBuf << endl; - LocalFree (lpMsgBuf); -} - -/*====================================================*/ -static HANDLE hFileMapping = NULL; -LPVOID mmap(off_t file_addr, int mmap_size, int fd) -{ - register LPVOID lpMapAddress = NULL; - register HANDLE hFile = (HANDLE)_get_osfhandle (fd); - register DWORD dwMapStart = (file_addr / theAllocGranularity) * theAllocGranularity; - register DWORD dwMapOffset = (file_addr % theAllocGranularity); - register DWORD dwFileSize = ((long)hFile != -1 ? GetFileSize(hFile,NULL) : 0xFFFFFFFF); - register long dwLength = 0; -// register char strH[10]; -// sprintf (strH, "%05d", (int)hFile); - //////////////////////////////////// -// cout << ">> HANDLE: " << strH << ", " << fd << endl; -// cout << "MMAP (OFF: " << file_addr << ", LEN: " << thePageSize << ", MSTR: " -// << dwMapStart << ", MOFF: " << dwMapOffset << ", SIZE: " << dwFileSize << ");\n"; -// hFile = (HANDLE)_get_osfhandle (fd); - if ((long)hFile != -1) { - hFileMapping = CreateFileMapping (hFile, NULL, PAGE_WRITECOPY, 0, 0, NULL ); - if (hFileMapping == NULL) { - errstr(">>>>> MMAP: CreateMap failed", GetLastError()); - return (LPVOID)MAP_FAILED; - } - if (hFileMapping != NULL && GetLastError() == ERROR_ALREADY_EXISTS) { - errstr(">>>>> MMAP: Map already exist", GetLastError()); - CloseHandle(hFileMapping); - return (LPVOID)MAP_FAILED; - } - dwLength = (file_addr + mmap_size < (long)dwFileSize ? - dwMapOffset + mmap_size : 0/*dwMapOffset+dwFileSize-file_addr*/); -// cout << "LENGTH: " << dwLength << endl; - lpMapAddress = MapViewOfFile (hFileMapping, FILE_MAP_COPY, 0, dwMapStart, dwLength); - if (lpMapAddress == NULL) { - errstr(">>>>> MMAP: MapView failed", GetLastError()); - CloseHandle (hFileMapping); - return (LPVOID)MAP_FAILED; - } - return (LPVOID)((LPSTR)lpMapAddress+dwMapOffset); - } else { - return (LPVOID)MAP_FAILED; - } -} - -/*====================================================*/ -int munmap(LPVOID addr) -{ - if (addr) { - UnmapViewOfFile (addr); - CloseHandle (hFileMapping); - hFileMapping = NULL; - } - return (0); -} - -////////////////////////////// WNT MMAP (MUNMAP) ////////////////////////// -#endif // WNT -#endif - -// ------------------------------ -// -- Category: Inline procedures -// ------------------------------ -// - -#define ROUND(v) Standard_Integer( ((v) > 0.) ? (v)+.5 : (v)-.5 ) - -// To calculate how many points to sample along a path in order to -// approximate it to the desired degree of flatness, we define -// dist((x,y)) = abs(x) + abs(y); -// then the number of points we need is -// N = 1 + sqrt(3/4 * D / flatness), -// where -// D = max(dist((p0 - 2*p1 + p2), (p1 - 2*p2 + p3))). -// -#if 1 -#define SETCURVE(dx10,dy10,dx21,dy21,dx32,dy32) \ - theCurveX0 = theOldCharX = theCharX; \ - theCurveY0 = theOldCharY = theCharY; \ - theCurveCX = 3.0 * dx10; \ - theCurveBX = 3.0 * (dx21 - dx10); \ - theCurveAX = dx32 - 2.0 * dx21 + dx10; \ - theCurveCY = 3.0 * dy10; \ - theCurveBY = 3.0 * (dy21 - dy10); \ - theCurveAY = dy32 - 2.0 * dy21 + dy10; \ - theCurveT = 0.0; \ - { Standard_Real dd,dx0,dy0,dx1,dy1; \ - dx0 = dx21-dx10; dy0 = dy21-dy10; \ - dx1 = dx32-dx21; dy1 = dy32-dy21; \ - dd = Max(Abs(dx0),Abs(dx1)) + Max(Abs(dy0),Abs(dy1)); \ - theCurveNT = 4 + ROUND(Sqrt(3./4. * dd / theCurveFlatness)); \ - theCurveDT = 1.0 / theCurveNT; \ - } -#else -#define SETCURVE(dx10,dy10,dx21,dy21,dx32,dy32) theCurveX0 = theOldCharX = theCharX; theCurveY0 = theOldCharY = theCharY; theCurveCX = 3.0 * dx10; theCurveBX = 3.0 * (dx21 - dx10); theCurveAX = dx32 - 2.0 * dx21 + dx10; theCurveCY = 3.0 * dy10; theCurveBY = 3.0 * (dy21 - dy10); theCurveAY = dy32 - 2.0 * dy21 + dy10; theCurveT = 0.0; { Standard_Real dd,dx0,dy0,dx1,dy1; dx0 = dx21-dx10; dy0 = dy21-dy10; dx1 = dx32-dx21; dy1 = dy32-dy21; dd = Max(Abs(dx0),Abs(dx1)) + Max(Abs(dy0),Abs(dy1)); theCurveNT = 4 + ROUND(Sqrt(3./4. * dd / theCurveFlatness)); theCurveDT = 1.0 / theCurveNT; } -#endif - -#if 1 -#define GETCURVE(T) \ - theCharX = ((theCurveAX * T + theCurveBX) * T + \ - theCurveCX) * T + theCurveX0; \ - theCharY = ((theCurveAY * T + theCurveBY) * T + \ - theCurveCY) * T + theCurveY0; -#else -#define GETCURVE(T) theCharX = ((theCurveAX * T + theCurveBX) * T + theCurveCX) * T + theCurveX0; theCharY = ((theCurveAY * T + theCurveBY) * T + theCurveCY) * T + theCurveY0; -#endif - -#if 1 -#define CHECKCOMMAND(np) \ - if( theCommandLength != np ) { \ - cout << " WARNING on MFT_Vertex : BAD command length " << \ - theCommandLength << "/" << np << " on " << \ - MFT::Convert(theCommandType) << \ - " from char position " << theCharPosition << endl; \ - vazy = Standard_True; \ - break; \ - } -#else -#define CHECKCOMMAND(np) if( theCommandLength != np ) { cout << " WARNING on MFT_Vertex : BAD command length " << theCommandLength << "/" << np << " on " << MFT::Convert(theCommandType) << " from char position " << theCharPosition << endl; vazy = Standard_True; break; } -#endif - -#if 1 -#define IPUSH(value) \ - if( theStackCount < MFT_MAXSTACKVALUES ) { \ - theIStack[theStackCount] = value; theStackCount++; \ - } else { \ - cout << " ERROR in MFT.STACK Overflow" << endl; \ - } -#else -#define IPUSH(value) if( theStackCount < MFT_MAXSTACKVALUES ) { theIStack[theStackCount] = value; theStackCount++; } else { cout << " ERROR in MFT.STACK Overflow" << endl; } -#endif - -#if 1 -#define IPOP(value) \ - if( theStackCount > 0 ) { \ - --theStackCount; value = theIStack[theStackCount]; \ - } else { \ - cout << " ERROR in MFT.STACK Underflow" << endl; \ - } -#else -#define IPOP(value) if( theStackCount > 0 ) { --theStackCount; value = theIStack[theStackCount]; } else { cout << " ERROR in MFT.STACK Underflow" << endl; } -#endif - -#if 1 -#define RPUSH(value) \ - if( theStackCount < MFT_MAXSTACKVALUES ) { \ - theRStack[theStackCount] = value; theStackCount++; \ - } else { \ - cout << " ERROR in MFT.STACK Overflow" << endl; \ - } -#else -#define RPUSH(value) if( theStackCount < MFT_MAXSTACKVALUES ) { theRStack[theStackCount] = value; theStackCount++; } else { cout << " ERROR in MFT.STACK Overflow" << endl; } -#endif - -#if 1 -#define RPOP(value) \ - if( theStackCount > 0 ) { \ - --theStackCount; value = theRStack[theStackCount]; \ - } else { \ - cout << " ERROR in MFT.STACK Underflow" << endl; \ - } -#else -#define RPOP(value) if( theStackCount > 0 ) { --theStackCount; value = theRStack[theStackCount]; } else { cout << " ERROR in MFT.STACK Underflow" << endl; } -#endif - -#if 1 -#define TRANSFORM(X,Y) \ - { Standard_Real x = X * theFontXRatio,y = Y * theFontYRatio; \ - if( myCharSlant != 0. ) x = x + y*theTanCharSlant; \ - if( theOrientation != 0. ) { \ - Standard_Real xx = x,yy = y; \ - x = xx*theCosCharAngle - yy*theSinCharAngle; \ - y = xx*theSinCharAngle + yy*theCosCharAngle; \ - } \ - X = theStringX + x; Y = theStringY + y; \ - } -#else -#define TRANSFORM(X,Y) { Standard_Real x = X * theFontXRatio,y = Y * theFontYRatio; if( myCharSlant != 0. ) x = x + y*theTanCharSlant; if( theOrientation != 0. ) { Standard_Real xx = x,yy = y; x = xx*theCosCharAngle - yy*theSinCharAngle; y = xx*theSinCharAngle + yy*theCosCharAngle; } X = theStringX + x; Y = theStringY + y; } -#endif - -#define FTOI(v) Standard_Integer((v)*1000000.) -#define ITOF(i) (Standard_ShortReal((i))/1000000.F) - -#if 1 -#define SWAPINT(v) \ - { \ - Standard_Character c; \ - Standard_PCharacter s = (Standard_PCharacter)&v; \ - c = s[0]; s[0] = s[3]; s[3] = c; \ - c = s[1]; s[1] = s[2]; s[2] = c; \ - } -#else -#define SWAPINT(v) { Standard_Character c; Standard_PCharacter s = (Standard_PCharacter)&v; c = s[0]; s[0] = s[3]; s[3] = c; c = s[1]; s[1] = s[2]; s[2] = c; } -#endif - -#if 1 -#define SWAPBOOL(v) \ - { \ - Standard_Character c; \ - Standard_PCharacter s = (Standard_PCharacter)&v; \ - c = s[0]; s[0] = s[3]; s[3] = c; \ - c = s[1]; s[1] = s[2]; s[2] = c; \ - } -#else -#define SWAPBOOL(v) { Standard_PCharacter c; Standard_PCharacter s = (Standard_PCharacter)&v; c = s[0]; s[0] = s[3]; s[3] = c; c = s[1]; s[1] = s[2]; s[2] = c; } -#endif - -#if 1 -#define SWAPFLOAT(v) \ - { \ - Standard_Character c; \ - Standard_PCharacter s = (Standard_PCharacter)&v; \ - c = s[0]; s[0] = s[3]; s[3] = c; \ - c = s[1]; s[1] = s[2]; s[2] = c; \ - } -#else -#define SWAPFLOAT(v) { Standard_Character c; Standard_PCharacter s = (Standard_PCharacter)&v; c = s[0]; s[0] = s[3]; s[3] = c; c = s[1]; s[1] = s[2]; s[2] = c; } -#endif - -#if 1 -#define SWAPPOSITION(v) \ - { \ - Standard_Character c; \ - Standard_PCharacter s = (Standard_PCharacter)&v; \ - c = s[0]; s[0] = s[3]; s[3] = c; \ - c = s[1]; s[1] = s[2]; s[2] = c; \ - } -#else -#define SWAPPOSITION(v) { Standard_Character c; Standard_PCharacter s = (Standard_PCharacter)&v; c = s[0]; s[0] = s[3]; s[3] = c; c = s[1]; s[1] = s[2]; s[2] = c; } -#endif - -// -------------------------------- -// -- Category: Fields explanations -// -------------------------------- - -// myFileName: AsciiString from TCollection; -// myFileMode: OpenMode from OSD; -// myFileHandle: Normally >= 0 when the file is open. -// myIsComposite: TRUE if the font contains -// extended chars. -// myIsFixedPitch: FALSE if the font is proportionnal. -// myItalicAngle: angle d'inclinaison des caracteres. -// myPaintType: 0 for filled fonts 2 for stroke fonts -// myCharWidth: Current text attribute -// for retrieve methods. -// myCharHeight: Current text attribute -// for retrieve methods. -// myCharSlant: Current text attribute -// for retrieve methods. -// myCharPrecision: Current text attribute -// for retrieve methods. -// myCharCapsHeight: Current text attribute -// for retrieve methods. -// myFileHeader: Current file header record -// to read or write from/to the file -// myCharEntries: Current char entries record -// to read or write from/to the file -// myCommandBuffer: Current command buffer record -// to read or write from/to the file - - -// -// ------------------------- -// -- Category: Constructors -// ------------------------- -// -// ============================================================================= -// ---Purpose: Gives access to the font associated -// -- to the file $CSF_MDTVFontDirectory/.mft -// -- with the open mode . -// ---Warning: If the symbol CSF_MDTVFontDirectory is not defined -// -- try to reads or writes in $PWD directory. -// ---Example: myFontManager = new MFT_FontManager("Helvetica-Bold") -// -- permits to access to the file -// -- $CSF_MDTVFontDirectory/"helvetica-bold.mft" -// raises FontManagerDefinitionError from MFT; -// ---Trigger: If the font file don't exist or if the file -// -- don't have an MFT signature. -// ============================================================================= - - -MFT_FontManager::MFT_FontManager(const Standard_CString anAliasName) : -myFileName(anAliasName), -myFileMode(OSD_ReadOnly), -myIsFixedPitch(Standard_False), -myItalicAngle(0.F), -myPaintType(0), -#ifdef CTS20718 -myCharWidth(1.F), -myCharHeight(1.F), -myCharSlant(0.F), -myCharPrecision(0.002F), -#else -myCharWidth(1.F), -myCharHeight(1.F), -myCharSlant(0.F), -myCharPrecision(0.05F), -#endif -myCharCapsHeight(Standard_True) -{ - -#if TRACE > 0 - cout << " MFT_FontManager::MFT_FontManager('" << myFileName << "')" << endl; -#endif - - myFileHandle = Open(myFileName,myFileMode); -#ifdef PRO17604 - if( myFileHandle < 0 ) { - char message[512]; - sprintf(message,"BAD MFT font name '%s'",myFileName.ToCString()); - MFT_FontManagerDefinitionError::Raise(message); - } -#else - char message[80]; - sprintf(message,"BAD MFT font name '%s'",myFileName); - MFT_FontManagerDefinitionError_Raise_if(myFileHandle < 0,message); -#endif - - //Retrieves header section. - myFileHeader.fileHandle = myFileHandle; - myFileHeader.beginPosition = myFileHeader.recordPosition = 0; - myFileHeader.recordSize = sizeof(MFT_FileHeader); - myFileHeader.update = Standard_False; - myFileHeader.precord = NULL; - myFileHeader.precordMMAPAddress = NULL; - myFileHeader.recordMMAPSize = 0; - myFileHeader.swap = Standard_False; - myCharEntries.fileHandle = myFileHandle; - myCharEntries.update = Standard_False; - myCharEntries.precord = NULL; - myCharEntries.precordMMAPAddress = NULL; - myCharEntries.recordMMAPSize = 0; - myCharEntries.swap = Standard_False; - myCommandBuffer.fileHandle = myFileHandle; - myCommandBuffer.recordSize = sizeof(MFT_CommandBuffer); - myCommandBuffer.update = Standard_False; - myCommandBuffer.precord = NULL; - myCommandBuffer.precordMMAPAddress = NULL; -#ifdef MMAP - myCommandBuffer.recordMMAPSize = thePageSize; -#endif - myCommandBuffer.swap = Standard_False; - Standard_Boolean status = Read(myFileHeader); - MFT_FontManagerDefinitionError_Raise_if(!status,"HEADER Read error"); - - MFT_FileHeader *pfileheader = (MFT_FileHeader*) myFileHeader.precord; - MFT_FontManagerDefinitionError_Raise_if(!pfileheader,"BAD MFT header"); - if( pfileheader->signature != MFT_SIGNATURE ) { - SWAPINT(pfileheader->signature); - SWAPBOOL(pfileheader->iscomposite); - SWAPPOSITION(pfileheader->pentries); - SWAPPOSITION(pfileheader->pcommands); - SWAPPOSITION(pfileheader->freeSpace); - SWAPINT(pfileheader->fontBox[0]); - SWAPINT(pfileheader->fontBox[1]); - SWAPINT(pfileheader->fontBox[2]); - SWAPINT(pfileheader->fontBox[3]); - SWAPINT(pfileheader->paintType); - SWAPINT(pfileheader->version); - SWAPBOOL(pfileheader->fixedPitch); - SWAPINT(pfileheader->fontMatrix[0]); - SWAPINT(pfileheader->fontMatrix[1]); - SWAPINT(pfileheader->fontMatrix[2]); - SWAPINT(pfileheader->fontMatrix[3]); - SWAPINT(pfileheader->fontMatrix[4]); - SWAPINT(pfileheader->fontMatrix[5]); - SWAPINT(pfileheader->italicAngle); - myFileHeader.swap = Standard_True; - myCharEntries.swap = Standard_True; - myCommandBuffer.swap = Standard_True; - } - MFT_FontManagerDefinitionError_Raise_if( - pfileheader->signature != MFT_SIGNATURE,"BAD MFT signature"); - - //Gets char entries section - myCharEntries.beginPosition = - myCharEntries.recordPosition = pfileheader->pentries; - myIsComposite = pfileheader->iscomposite; - if( myIsComposite ) { - myCharEntries.recordSize = sizeof(MFT_ExtendedCharEntries); - } else { - myCharEntries.recordSize = sizeof(MFT_AsciiCharEntries); - } - myPaintType = pfileheader->paintType; - myIsFixedPitch = pfileheader->fixedPitch; - myItalicAngle = ITOF(pfileheader->italicAngle); - status = Read(myCharEntries); - MFT_FontManagerDefinitionError_Raise_if(!status,"CHAR ENTRIES Read error"); - - MFT_CharEntries *pcharentries = (MFT_CharEntries*) myCharEntries.precord; - MFT_FontManagerDefinitionError_Raise_if( - !pcharentries, "BAD char entries address"); - if( myCharEntries.swap ) { - for( Standard_Integer i=0 ; - i < (int)( myCharEntries.recordSize/sizeof(Standard_Integer) ); i++ ) { - SWAPINT(pcharentries->fcommand[i]); - } - } - - //Fill empty command buffer. - myCommandBuffer.beginPosition = - myCommandBuffer.recordPosition = pfileheader->pcommands; - MFT_FontManagerDefinitionError_Raise_if( - sizeof(MFT_CommandDescriptor) != 4, - "BAD command descriptor implementation"); - - TCollection_AsciiString env(CSF_MDTVFontPrecision.Value()); - if( env.Length() > 0 ) { - Standard_ShortReal flatness,precision; - Standard_Integer n = sscanf(env.ToCString(),"%f %f",&flatness,&precision); - if( n > 0 && flatness > 0. ) { - theMDTVFontPrecision = Standard_True; - theCurveFlatness = flatness; - theCurvePrecision = flatness * 10.; - if( precision > 0. ) theCurvePrecision = precision; - } - if( theMDTVFontPrecision ) { - cout << " CSF_MFTVFontPrecision is " << theCurveFlatness << "," - << theCurvePrecision << endl; - } - } - -#ifdef S3593 - myCommandBuffer.recordMMAPSize = pfileheader->freeSpace; -#endif - -} - -// ============================================================================= -// ---Purpose: Gives access to the font associated -// -- to the file $CSF_MDTVFontDirectory/.mft -// -- with the open mode . -// ---Warning: If the symbol CSF_MDTVFontDirectory is not defined -// -- try to reads or writes in $PWD directory. -// raises FontManagerDefinitionError from MFT; -// ---Trigger: If is ReadOnly or ReadWrite and -// -- the font file don't exist or if the file -// -- don't have an MFT signature. -// ============================================================================= - -MFT_FontManager::MFT_FontManager(const Aspect_FontStyle& aFont, const OSD_OpenMode aFileMode,const Standard_Boolean isComposite) : -myFileName(aFont.AliasName()), -myFileMode(aFileMode), -myIsFixedPitch(Standard_False), -myItalicAngle(0.F), -myPaintType(0), -#ifdef CTS20718 -myCharWidth(1.F), -myCharHeight(1.F), -myCharSlant(0.F), -myCharPrecision(0.002F), -#else -myCharWidth(1.F), -myCharHeight(1.F), -myCharSlant(0.F), -myCharPrecision(0.05F), -#endif -myCharCapsHeight(Standard_True) -{ -#if TRACE > 0 - cout << " MFT_FontManager::MFT_FontManager('" << aFont.AliasName() << - "'," << Standard_Integer(aFileMode) << ")" << endl; -#endif - - myFileHandle = Open(myFileName,myFileMode); -#ifdef PRO17604 - if( myFileHandle < 0 ) { - char message[512]; - sprintf(message,"BAD MFT font name '%s'",myFileName.ToCString()); - MFT_FontManagerDefinitionError::Raise(message); - } -#else - char message[80]; - sprintf(message,"BAD MFT font name '%s'",myFileName); - MFT_FontManagerDefinitionError_Raise_if( myFileHandle < 0,message); -#endif - - MFT_FileHeader *pfileheader = NULL; - MFT_CharEntries *pcharentries = NULL; - - myFileHeader.fileHandle = myFileHandle; - myFileHeader.beginPosition = myFileHeader.recordPosition = 0; - myFileHeader.recordSize = sizeof(MFT_FileHeader); - myFileHeader.update = Standard_False; - myFileHeader.precord = NULL; - myFileHeader.swap = Standard_False; - myFileHeader.precordMMAPAddress = NULL; - myFileHeader.recordMMAPSize = 0; - myCharEntries.fileHandle = myFileHandle; - myCharEntries.update = Standard_False; - myCharEntries.precord = NULL; - myCharEntries.swap = Standard_False; - myCharEntries.precordMMAPAddress = NULL; - myCharEntries.recordMMAPSize = 0; - myCommandBuffer.fileHandle = myFileHandle; - myCommandBuffer.recordSize = sizeof(MFT_CommandBuffer); - myCommandBuffer.update = Standard_False; - myCommandBuffer.precord = NULL; - myCommandBuffer.swap = Standard_False; - myCommandBuffer.precordMMAPAddress = NULL; - myCommandBuffer.recordMMAPSize = 0; - - switch (myFileMode) { - case OSD_ReadOnly: -#ifdef MMAP - myCommandBuffer.recordMMAPSize = thePageSize; -#endif - case OSD_ReadWrite: - { - //Retrieves header section. - Standard_Boolean status = Read(myFileHeader); - MFT_FontManagerDefinitionError_Raise_if(!status,"HEADER Read error"); - - pfileheader = (MFT_FileHeader*) myFileHeader.precord; - MFT_FontManagerDefinitionError_Raise_if(!pfileheader,"BAD MFT header"); - if( pfileheader->signature != MFT_SIGNATURE ) { - SWAPINT(pfileheader->signature); - SWAPBOOL(pfileheader->iscomposite); - SWAPPOSITION(pfileheader->pentries); - SWAPPOSITION(pfileheader->pcommands); - SWAPPOSITION(pfileheader->freeSpace); - SWAPINT(pfileheader->fontBox[0]); - SWAPINT(pfileheader->fontBox[1]); - SWAPINT(pfileheader->fontBox[2]); - SWAPINT(pfileheader->fontBox[3]); - SWAPINT(pfileheader->paintType); - SWAPINT(pfileheader->version); - SWAPBOOL(pfileheader->fixedPitch); - SWAPINT(pfileheader->fontMatrix[0]); - SWAPINT(pfileheader->fontMatrix[1]); - SWAPINT(pfileheader->fontMatrix[2]); - SWAPINT(pfileheader->fontMatrix[3]); - SWAPINT(pfileheader->fontMatrix[4]); - SWAPINT(pfileheader->fontMatrix[5]); - SWAPINT(pfileheader->italicAngle); - myFileHeader.swap = Standard_True; - myCharEntries.swap = Standard_True; - myCommandBuffer.swap = Standard_True; - } - MFT_FontManagerDefinitionError_Raise_if( - pfileheader->signature != MFT_SIGNATURE,"BAD MFT signature"); - - myIsComposite = pfileheader->iscomposite; - //Retrieves char entries section - if( myIsComposite ) { - myCharEntries.recordSize = sizeof(MFT_ExtendedCharEntries); - } else { - myCharEntries.recordSize = sizeof(MFT_AsciiCharEntries); - } - myPaintType = pfileheader->paintType; - myIsFixedPitch = pfileheader->fixedPitch; - myItalicAngle = ITOF(pfileheader->italicAngle); - myCharEntries.beginPosition = - myCharEntries.recordPosition = pfileheader->pentries; - status = Read(myCharEntries); - MFT_FontManagerDefinitionError_Raise_if(!status,"CHAR ENTRIES Read error"); - - pcharentries = (MFT_CharEntries*) myCharEntries.precord; - MFT_FontManagerDefinitionError_Raise_if( - !pcharentries, "BAD char entries address"); - if( myCharEntries.swap ) { - for( Standard_Integer i=0 ; - i < (int)( myCharEntries.recordSize/sizeof(Standard_Integer) ); i++ ) { - SWAPINT(pcharentries->fcommand[i]); - } - } - - //Retrieves command buffer section - myCommandBuffer.beginPosition = - myCommandBuffer.recordPosition = pfileheader->pcommands; -#ifdef S3593 - if( myCommandBuffer.recordMMAPSize > 0 ) - myCommandBuffer.recordMMAPSize = pfileheader->freeSpace; -#endif - } - break; - case OSD_WriteOnly: - { - //Builds file header section - myFileHeader.precord = (Standard_CString) malloc(myFileHeader.recordSize); - pfileheader = (MFT_FileHeader*)myFileHeader.precord; - Standard_OutOfMemory_Raise_if( - !pfileheader,"MEMORY allocation failed"); - Standard_CString pfontname = aFont.FullName(); - Standard_Integer length = Min(MFT_MAXFONTNAME-1,strlen(pfontname)); - - myIsComposite = isComposite; - //Retrieves char entries section - pfileheader->signature = MFT_SIGNATURE; - pfileheader->version = MFT_VERSION; - pfileheader->iscomposite = myIsComposite; - pfileheader->paintType = myPaintType; - pfileheader->fixedPitch = myIsFixedPitch; - pfileheader->fontBox[0] = 0; //XMin font - pfileheader->fontBox[1] = 0; //YMin font - pfileheader->fontBox[2] = 1000; //XMax font - pfileheader->fontBox[3] = 1000; //YMax font - pfileheader->fontMatrix[0] = FTOI(0.001); - pfileheader->fontMatrix[1] = 0; - pfileheader->fontMatrix[2] = 0; - pfileheader->fontMatrix[3] = FTOI(0.001); - pfileheader->fontMatrix[4] = 0; - pfileheader->fontMatrix[5] = 0; - pfileheader->italicAngle = FTOI(myItalicAngle); - for( Standard_Integer i=0 ; i < MFT_DUMMYSIZE ; i++ ) - pfileheader->dummy[i] = (unsigned char)0xFF; - strncpy(pfileheader->fontName,pfontname,length); - pfileheader->fontName[length] = '\0'; - pfileheader->pentries = myFileHeader.recordSize; - - //Builds char entries section - if( myIsComposite ) { - myCharEntries.recordSize = sizeof(MFT_ExtendedCharEntries); - } else { - myCharEntries.recordSize = sizeof(MFT_AsciiCharEntries); - } - myCharEntries.precord = (Standard_CString) calloc(myCharEntries.recordSize,1); - pcharentries = (MFT_CharEntries*) myCharEntries.precord; - Standard_OutOfMemory_Raise_if( - !pcharentries,"MEMORY allocation failed"); - myCharEntries.beginPosition = - myCharEntries.recordPosition = pfileheader->pentries; - myCharEntries.update = Standard_True; - pfileheader->pcommands = - pfileheader->pentries + myCharEntries.recordSize; - pfileheader->freeSpace = pfileheader->pcommands; - myFileHeader.update = Standard_True; - - //Builds command buffer section - myCommandBuffer.beginPosition = - myCommandBuffer.recordPosition = pfileheader->pcommands; - myCommandBuffer.precord = (Standard_CString) malloc(myCommandBuffer.recordSize); - } - break; - } - - TCollection_AsciiString env(CSF_MDTVFontPrecision.Value()); - if( env.Length() > 0 ) { - Standard_ShortReal flatness,precision; - Standard_Integer n = sscanf(env.ToCString(),"%f %f",&flatness,&precision); - if( n > 0 && flatness > 0. ) { - theMDTVFontPrecision = Standard_True; - theCurveFlatness = flatness; - theCurvePrecision = flatness * 10.; - if( precision > 0. ) theCurvePrecision = precision; - } - if( theMDTVFontPrecision ) { - cout << " CSF_MFTVFontPrecision is " << theCurveFlatness << "," - << theCurvePrecision << endl; - } - } -} - -// ------------------------- -// -- Category: Destructors -// ------------------------- - -// ============================================================================= -// ---Purpose: Save the font file when the open mode is -// -- Write or ReadWrite and Close it in all the case. -// ---C++: alias ~ -// ============================================================================= - -void MFT_FontManager::Destroy() -{ -#if TRACE > 0 - cout << " MFT_FontManager::Destroy()" << endl; -#endif - this->Close(); -} - - -// --------------------------------------------- -// -- Category: Methods to updates the .mft files -// --------------------------------------------- - -// ============================================================================= -// ---Purpose: Updates the font name. -// raises FontManagerError from MFT; -// ---Trigger: If the font file is not opened -// -- in WriteOnly or ReadWrite mode -// ============================================================================= - -void MFT_FontManager::SetFont(const Aspect_FontStyle& aFont) -{ - MFT_FontManagerError_Raise_if( - myFileMode == OSD_ReadOnly, - "TRY to updates a ReadOnly file"); - MFT_FileHeader *pfileheader = (MFT_FileHeader*) myFileHeader.precord; - Standard_CString pfontname = aFont.FullName(); - Standard_Integer length = Min(MFT_MAXFONTNAME-1,strlen(pfontname)); - strncpy(pfileheader->fontName,pfontname,length); - pfileheader->fontName[length] = '\0'; - myFileHeader.update = Standard_True; -} - -// ============================================================================= -// ---Purpose: Defines and Enable the char for writing. -// raises FontManagerError from MFT; -// ---Trigger: If the font file is not opened -// -- in WriteOnly or ReadWrite mode -// -- or the char is already defined. -// ============================================================================= - -void MFT_FontManager::SetChar(const Standard_Character aChar) -{ -#if TRACE > 0 - cout << " MFT_FontManager::SetChar('" << aChar << "')" << endl; -#endif - - unsigned int position = aChar & 0xFF; - MFT_FontManagerError_Raise_if( - myFileMode == OSD_ReadOnly, - "TRY to updates a ReadOnly file"); - if( IsDefinedChar(position) ) { - cout << "TRY to updates the existing character" << position << endl; - } - MFT_FileHeader *pfileheader = (MFT_FileHeader*) myFileHeader.precord; - theCharPosition = position; - theFirstCommandPosition = theNextCommandPosition = pfileheader->freeSpace; -} - -// ============================================================================= -// ---Purpose: Defines and Enable the accent char for writing. -// raises FontManagerError from MFT; -// ---Trigger: If the font file is not opened -// -- in WriteOnly or ReadWrite mode -// -- or the char is already defined. -// ============================================================================= - -void MFT_FontManager::SetAccentChar(const Standard_Character aChar) -{ -#if TRACE > 0 - cout << " MFT_FontManager::SetAccentChar('" << aChar << "')" << endl; -#endif - - unsigned int position = MFT_MAXASCIICHARENTRIES + (aChar & 0xFF); - MFT_FontManagerError_Raise_if( - myFileMode == OSD_ReadOnly, - "TRY to updates a ReadOnly file"); - if( IsDefinedChar(position) ) { - cout << "TRY to updates the existing character" << position << endl; - } - MFT_FileHeader *pfileheader = (MFT_FileHeader*) myFileHeader.precord; - theCharPosition = position; - theFirstCommandPosition = theNextCommandPosition = pfileheader->freeSpace; -} - -// ============================================================================= -// ---Purpose: Defines and Enable the char for writing. -// -- This char being current for adding command. -// ---Warning: The char must have an UNICODE UCS2 encoding. -// raises FontManagerError from MFT; -// ---Trigger: If the font file is not opened -// -- in WriteOnly or ReadWrite mode -// -- or if the font is not a composite font. -// ============================================================================= - -void MFT_FontManager::SetChar(const Standard_ExtCharacter aChar) -{ -#if TRACE > 0 - cout << " MFT_FontManager::SetChar('" << aChar << "')" << endl; -#endif - - unsigned int position = aChar & 0xFFFF; - MFT_FontManagerError_Raise_if( - myFileMode == OSD_ReadOnly, - "TRY to updates a ReadOnly file"); - MFT_FontManagerError_Raise_if( !myIsComposite && - (position >= (MFT_MAXASCIICHARENTRIES+MFT_MAXSEACCHARENTRIES)), - "FONT is not composite"); - if( IsDefinedChar(position) ) { - cout << "TRY to updates the existing character" << position << endl; - } - MFT_FileHeader *pfileheader = (MFT_FileHeader*) myFileHeader.precord; - theCharPosition = position; - theFirstCommandPosition = theNextCommandPosition = pfileheader->freeSpace; -} - - -// ============================================================================= -// ---Purpose: Changes the default encoding of the char position -// -- . -// ---Example: SetEncoding(233,"eacute") -// -- change the default encoding of the char position 233 -// -- from "Oslash" to "eacute". -// raises FontManagerError from MFT; -// ---Trigger: If the font file is not opened -// -- in WriteOnly or ReadWrite mode. -// -- or if the char encoding is not defined. -// ============================================================================= - -void MFT_FontManager::SetEncoding(const Standard_Integer aPosition, const Standard_CString anEncoding) -{ -#if TRACE > 0 - cout << " MFT_FontManager::SetEncoding(" << aPosition << ",'" << - anEncoding << "')" << endl; -#endif - - MFT_FontManagerError_Raise_if( - myFileMode == OSD_ReadOnly, - "TRY to updates a ReadOnly file"); - MFT_FontManagerError_Raise_if( - aPosition > this->MaxCharPosition(), - "BAD encoding position"); - - Standard_Integer anEncodingPosition = this->Encoding(anEncoding); - - if( !anEncodingPosition ) { - char message[80]; - sprintf(message," BAD encoding symbol '%s'",anEncoding); - MFT_FontManagerError::Raise(message); - } - - if( aPosition != anEncodingPosition && - anEncodingPosition > MFT_MAXASCIICHARENTRIES ) { - MFT_CharEntries *pcharentries = (MFT_CharEntries*) myCharEntries.precord; - pcharentries->fcommand[aPosition] = - pcharentries->fcommand[anEncodingPosition]; - myCharEntries.update = Standard_True; - } - -} - -// ============================================================================= -// ---Purpose: Remove the definition of the char -// raises FontManagerError from MFT; -// ---Trigger: If the font file is not opened -// -- in WriteOnly or ReadWrite mode. -// ============================================================================= - -void MFT_FontManager::DelChar(const Standard_Character aChar) -{ -#if TRACE > 0 - cout << " MFT_FontManager::DelChar('" << aChar << "')" << endl; -#endif - - unsigned int position = aChar & 0xFFFF; - MFT_FontManagerError_Raise_if( - myFileMode == OSD_ReadOnly, - "TRY to updates a ReadOnly file"); - MFT_FontManagerError_Raise_if( !myIsComposite && - (position >= (MFT_MAXASCIICHARENTRIES+MFT_MAXSEACCHARENTRIES)), - "FONT is not composite"); - MFT_CharEntries *pcharentries = (MFT_CharEntries*) myCharEntries.precord; - pcharentries->fcommand[position] = -Abs(pcharentries->fcommand[position]); - myCharEntries.update = Standard_True; -} - -// ============================================================================= -// ---Purpose: Remove the definition of the char -// -- This char being current for adding command. -// ---Warning: The char must have an UNICODE UCS2 encoding. -// raises FontManagerError from MFT; -// ---Trigger: If the font file is not opened -// -- in WriteOnly or ReadWrite mode -// -- or if the font is not a composite font. -// ============================================================================= - -void MFT_FontManager::DelChar(const Standard_ExtCharacter aChar) -{ -#if TRACE > 0 - cout << " MFT_FontManager::DelChar('" << aChar << "')" << endl; -#endif - - unsigned int position = aChar & 0xFFFF; - MFT_FontManagerError_Raise_if( - myFileMode == OSD_ReadOnly, - "TRY to updates a ReadOnly file"); - MFT_FontManagerError_Raise_if( !myIsComposite, "FONT is not composite"); - MFT_CharEntries *pcharentries = (MFT_CharEntries*) myCharEntries.precord; - pcharentries->fcommand[position] = -Abs(pcharentries->fcommand[position]); - myCharEntries.update = Standard_True; -} - -// ============================================================================= -// ---Purpose: Adds the command -// -- to describe the current char. -// -- This command being current for adding parameters if any. -// raises FontManagerError from MFT; -// ---Trigger: If the font file is not opened -// -- in WriteOnly or ReadWrite mode -// -- or if a current char don't have being defined. -// ---Warning: the last command of the char descriptor -// -- must have a type MFC_TOC_ENDCHAR. -// ============================================================================= - -void MFT_FontManager::AddCommand(const MFT_TypeOfCommand aCommandType) -{ - if( theNextCommandPosition == theFirstCommandPosition && - aCommandType != MFT_TOC_MINMAX) { - // Add a MINMAX command first. - this->AddCommand(MFT_TOC_MINMAX); - this->AddValue(0); - this->AddValue(0); - this->AddValue(0); - this->AddValue(0); - } - -#if TRACE > 0 - cout << " MFT_FontManager::AddCommand(" << MFT::Convert(aCommandType) << ")" << endl; -#endif - - theCommandType = aCommandType; - theCommandPosition = theNextCommandPosition; - Standard_Integer *pcommand = - (Standard_Integer*) Locate(myCommandBuffer,theCommandPosition); - MFT_CommandDescriptor *pdescr = (MFT_CommandDescriptor*) pcommand; - *pcommand = 0; - SET_COMMAND_TYPE(*pdescr,theCommandType); - myCommandBuffer.update = Standard_True; - theNextCommandPosition += sizeof(MFT_CommandDescriptor); - - if( theCommandType == MFT_TOC_ENDCHAR ) { - //Saves char - MFT_CharEntries *pcharentries = (MFT_CharEntries*) myCharEntries.precord; - pcharentries->fcommand[theCharPosition] = theFirstCommandPosition; - myCharEntries.update = Standard_True; - MFT_FileHeader *pfileheader = (MFT_FileHeader*) myFileHeader.precord; - pfileheader->freeSpace = theNextCommandPosition; - myFileHeader.update = Standard_True; - this->ComputeBoundingBox(theCharPosition); - theFirstCommandPosition = 0; - } -} - -// ============================================================================= -// ---Purpose: Adds the integer parameter to fill -// -- the current command. -// raises FontManagerError from MFT; -// ---Trigger: If the font file is not opened -// -- in WriteOnly or ReadWrite mode -// -- or if a current command don't have being defined. -// -- or if the number of values is > MaxCommandValues() -// ============================================================================= - -void MFT_FontManager::AddValue(const Standard_Integer aValue) -{ -#if TRACE > 0 - cout << " MFT_FontManager::AddValue(" << aValue << ")" << endl; -#endif - - MFT_CommandDescriptor *pdescr = - (MFT_CommandDescriptor*) Locate(myCommandBuffer,theCommandPosition); - Standard_Integer length = COMMAND_LENGTH(*pdescr); - if( length < 8 ) { - length++; - SET_COMMAND_LENGTH(*pdescr,length); - SET_COMMAND_VALUETYPE(*pdescr,length,MFT_TOV_INTEGER); - } else { - Standard_OutOfRange::Raise("TOO many command INTEGER values"); - } - myCommandBuffer.update = Standard_True; - Standard_Integer *pvalue = - (Standard_Integer*) Locate(myCommandBuffer,theNextCommandPosition); - if( theCommandType == MFT_TOC_SEAC ) { - if( length > 3 && length < 6 ) { - MFT_CharEntries *pcharentries = - (MFT_CharEntries*) myCharEntries.precord; - //Gets the first command position - // of the base char and Accented Char - if( pcharentries->fcommand[aValue] ) { - *pvalue = -pcharentries->fcommand[aValue]; - } else { - *pvalue = aValue; - } - } else { - *pvalue = aValue; - } - } else { - *pvalue = aValue; - } - myCommandBuffer.update = Standard_True; - theNextCommandPosition += sizeof(MFT_CommandValue); -} - -// ============================================================================= -// ---Purpose: Adds the float parameter to fill -// -- the current command. -// raises FontManagerError from MFT; -// ---Trigger: If the font file is not opened -// -- in WriteOnly or ReadWrite mode -// -- or if a current command don't have being defined. -// -- or if the number of values is > MaxCommandValues() -// ============================================================================= - -void MFT_FontManager::AddValue(const Standard_Real aValue) -{ -#if TRACE > 0 - cout << " MFT_FontManager::AddValue(" << aValue << ")" << endl; -#endif - - MFT_CommandDescriptor *pdescr = - (MFT_CommandDescriptor*) Locate(myCommandBuffer,theCommandPosition); - Standard_Integer length = COMMAND_LENGTH(*pdescr); - if( length < 8 ) { - length++; - SET_COMMAND_LENGTH(*pdescr,length); - SET_COMMAND_VALUETYPE(*pdescr,length,MFT_TOV_FLOAT); - } else { - Standard_OutOfRange::Raise("TOO many command FLOAT values"); - } - myCommandBuffer.update = Standard_True; - Standard_ShortReal *pvalue = - (Standard_ShortReal*) Locate(myCommandBuffer,theNextCommandPosition); - *pvalue = Standard_ShortReal(aValue); - myCommandBuffer.update = Standard_True; - theNextCommandPosition += sizeof(MFT_CommandValue); -} - -// ============================================================================= -// ---Purpose: Adds the string parameter to fill -// -- the current command. -// raises FontManagerError from MFT; -// ---Trigger: If the font file is not opened -// -- in WriteOnly or ReadWrite mode -// -- or if a current command don't have being defined. -// -- or if the number of values is > MaxCommandValues() -// ============================================================================= - -void MFT_FontManager::AddValue(const Standard_CString aValue) -{ - MFT_FontManagerError_Raise_if(!aValue,"BAD string value"); - -#if TRACE > 0 - cout << " MFT_FontManager::AddValue('" << aValue << "')" << endl; -#endif - - Standard_Integer lvalue = strlen(aValue); - Standard_Integer i,nvalue = (lvalue > 0) ? - 1 + (lvalue-1)/sizeof(MFT_CommandValue) : 0; - MFT_CommandDescriptor *pdescr = - (MFT_CommandDescriptor*) Locate(myCommandBuffer,theCommandPosition); - Standard_Integer length = COMMAND_LENGTH(*pdescr); - Standard_OutOfRange_Raise_if( length + nvalue + 1 > MaxCommandValues(), - "TOO many command STRING values"); - for( i=0 ; i 0 - cout << " MFT_FontManager::SetBoundingBox(" << aMinX << "," << - aMinY << "," << aMaxX << "," << aMaxY << ")" << endl; -#endif - - MFT_FontManagerError_Raise_if( - myFileMode == OSD_ReadOnly, - "TRY to updates a ReadOnly file"); - MFT_FontManagerError_Raise_if( - aMinX >= aMaxX || aMinY >= aMaxY, - "BAD font bounding box definition"); - MFT_FileHeader *pfileheader = (MFT_FileHeader*) myFileHeader.precord; - pfileheader->fontBox[0] = aMinX; - pfileheader->fontBox[1] = aMinY; - pfileheader->fontBox[2] = aMaxX; - pfileheader->fontBox[3] = aMaxY; - myFileHeader.update = Standard_True; -} - -// ============================================================================= -// ---Purpose: Sets the font matrix. -// raises FontManagerError from MFT; -// ---Trigger: If the font file is not opened -// -- in WriteOnly or ReadWrite mode -// ---Warning: The font matrix default are : -// -- 0.001,0,0,0.001,0,0 -// ============================================================================= - -void MFT_FontManager::SetFontMatrix(const Standard_Real M1, const Standard_Real M2, const Standard_Real M3, const Standard_Real M4, const Standard_Real M5, const Standard_Real M6) { -#if TRACE > 0 - cout << " MFT_FontManager::SetFontMatrix(" << M1 << "," << - M2 << "," << M3 << "," << M4 << "," << M5 << "," << M6 << ")" << endl; -#endif - - MFT_FontManagerError_Raise_if( - myFileMode == OSD_ReadOnly, - "TRY to updates a ReadOnly file"); - MFT_FileHeader *pfileheader = (MFT_FileHeader*) myFileHeader.precord; - pfileheader->fontMatrix[0] = FTOI(M1); - pfileheader->fontMatrix[1] = FTOI(M2); - pfileheader->fontMatrix[2] = FTOI(M3); - pfileheader->fontMatrix[3] = FTOI(M4); - pfileheader->fontMatrix[4] = FTOI(M5); - pfileheader->fontMatrix[5] = FTOI(M6); - myFileHeader.update = Standard_True; -} - -// ============================================================================= -// ---Purpose: Sets the paint type of the font. -// raises FontManagerError from MFT; -// ---Trigger: If the font file is not opened -// -- in WriteOnly or ReadWrite mode -// -- or if the value is not a Type 1 font value. -// ---Warning: The paint type must be one of Type 1 font -// -- value 0 for FILL or 2 for OUTLINE. -// ============================================================================= - -void MFT_FontManager::SetPaintType(const Standard_Integer aValue) { -#if TRACE > 0 - cout << " MFT_FontManager::SetPaintType(" << aValue << ")" << endl; -#endif - - MFT_FontManagerError_Raise_if( - myFileMode == OSD_ReadOnly, - "TRY to updates a ReadOnly file"); - MFT_FontManagerError_Raise_if( - aValue < 0 || aValue > 2, - "BAD font paint type value"); - myPaintType = aValue; - MFT_FileHeader *pfileheader = (MFT_FileHeader*) myFileHeader.precord; - pfileheader->paintType = myPaintType; - myFileHeader.update = Standard_True; -} - -// ============================================================================= -// ---Purpose: Sets the fixed pitch flag of the font. -// raises FontManagerError from MFT; -// ---Trigger: If the font file is not opened -// -- in WriteOnly or ReadWrite mode -// ============================================================================= - -void MFT_FontManager::SetFixedPitch(const Standard_Boolean aFlag) { -#if TRACE > 0 - cout << " MFT_FontManager::SetFixedPitch(" << aFlag << ")" << endl; -#endif - - MFT_FontManagerError_Raise_if( - myFileMode == OSD_ReadOnly, - "TRY to updates a ReadOnly file"); - myIsFixedPitch = aFlag; - MFT_FileHeader *pfileheader = (MFT_FileHeader*) myFileHeader.precord; - pfileheader->fixedPitch = myIsFixedPitch; - myFileHeader.update = Standard_True; -} - -// ============================================================================= -// ---Level: Advanced -// ---Purpose: Sets the italic angle of the font -// raises FontManagerError from MFT; -// ---Trigger: If the font file is not opened -// -- in WriteOnly or ReadWrite mode -// ============================================================================= - -void MFT_FontManager::SetItalicAngle(const Quantity_PlaneAngle anAngle) { -#if TRACE > 0 - cout << " MFT_FontManager::SetItalicAngle(" << anAngle << ")" << endl; -#endif - - MFT_FontManagerError_Raise_if( - myFileMode == OSD_ReadOnly, - "TRY to updates a ReadOnly file"); - myItalicAngle = Standard_ShortReal( anAngle ); - MFT_FileHeader *pfileheader = (MFT_FileHeader*) myFileHeader.precord; - pfileheader->italicAngle = FTOI(myItalicAngle); - myFileHeader.update = Standard_True; -} - -// ============================================================================= -// ---Purpose: Computes the bounding box of the font from the -// -- min-max of all chars of the font. -// ---Warning: this must be call after all characters has been defined. -// raises FontManagerError from MFT; -// ---Trigger: If the font file is not opened -// -- in WriteOnly or ReadWrite mode. -// ============================================================================= - -void MFT_FontManager::ComputeBoundingBox () -{ - - MFT_FontManagerError_Raise_if( - myFileMode == OSD_ReadOnly, - "TRY to updates a ReadOnly file"); - - theTanCharSlant = 0.; - theFontXRatio = theFontYRatio = 1.; - theOrientation = 0.; - theSinCharAngle = 0.; - theCosCharAngle = 1.; - Standard_Boolean fixedPitch = myIsFixedPitch; - myIsFixedPitch = Standard_False; - - Quantity_Length Fxmin = 0.,Fymin = 0.,Fxmax = 0.,Fymax = 0.; - Quantity_Length Cxmin,Cymin,Cxmax,Cymax; - Standard_Integer i; - for( i=0 ; iMaxCharPosition() ; i++ ) { - if( this->IsDefinedChar(i) ) { - theDeltaX = 0.; - this->DrawChar(theTextManager,i); - theTextManager->MinMax(Cxmin,Cymin,Cxmax,Cymax); - Fxmin = Min(Fxmin,Cxmin); Fymin = Min(Fymin,Cymin); - Fxmax = Max(Fxmax,Cxmax); Fymax = Max(Fymax,Cymax); - } - } - myIsFixedPitch = fixedPitch; - MFT_FileHeader *pfileheader = (MFT_FileHeader*) myFileHeader.precord; - pfileheader->fontBox[0] = Standard_Integer(Fxmin); - pfileheader->fontBox[1] = Standard_Integer(Fymin); - pfileheader->fontBox[2] = Standard_Integer(Fxmax); - pfileheader->fontBox[3] = Standard_Integer(Fymax); - myFileHeader.update = Standard_True; - -#if TRACE > 1 - cout << " MFT_FontManager::ComputeBoundingBox()" << endl; - cout << " is " << Fxmin << "," << Fymin << "," << Fxmax << "," << Fymax << endl; -#endif -} - -// --------------------------------------------------------------- - -// --------------------------------------------------------------- -// -- Category: Methods to sets the current interpretor attributes -// --------------------------------------------------------------- - -// ============================================================================= -// ---Purpose: Sets the current font attributes. -// -- : the maximum width of one character. -// -- : the maximum height of one character -// -- (ascent + descent components of the character). -// -- : the slant of one character given in RAD -// -- from vertical. -// -- : the absolute interpolator precision -// -- (the maximum deflection for the curves). -// ============================================================================= - -void MFT_FontManager::SetFontAttribs(const Quantity_Length aWidth, const Quantity_Length aHeight, const Quantity_PlaneAngle aSlant, const Quantity_Factor aPrecision, const Standard_Boolean aCapsHeight) -{ -#if TRACE > 0 - cout << " MFT_FontManager::SetFontAttribs(" << aWidth << "," << - aHeight << "," << aSlant << "," << aPrecision << ")" << endl; -#endif - - MFT_FileHeader *pfileheader = (MFT_FileHeader*) myFileHeader.precord; - myCharWidth = Standard_ShortReal( aWidth ); - myCharHeight = Standard_ShortReal( aHeight ); - myCharSlant = Standard_ShortReal( aSlant ); - if( pfileheader->version > 280597 ) { - Standard_ShortReal slant = ITOF(pfileheader->italicAngle); - myCharSlant += slant; - } - if( aPrecision > 0. ) myCharPrecision = Standard_ShortReal( aPrecision ); - myCharCapsHeight = aCapsHeight; -} - -// ============================================================================= -// ---Purpose: Sets the text attributes. -// -- : the string to interpret -// -- : the orientation angle in RAD from horizontal. -// ============================================================================= - -void MFT_FontManager::SetTextAttribs(const Standard_CString aString, const Quantity_PlaneAngle anOrientation) -{ -#if TRACE > 0 - cout << " MFT_FontManager::SetTextAttribs('" << aString << "'," << - anOrientation << ")" << endl; -#endif - - MFT_FileHeader *pfileheader = (MFT_FileHeader*) myFileHeader.precord; - theTanCharSlant = Tan(myCharSlant); - theFixedCharWidth = 0.; - if( !theMDTVFontPrecision ) { - theCurveFlatness = myCharPrecision * - pfileheader->fontBox[2]/Max(myCharWidth,myCharHeight); - theCurvePrecision = theCurveFlatness * 10.; -#if TRACE > 0 - cout << " SetTextAttribs(aString,anOrientation): Flatness =" << theCurveFlatness - << " FontBox =" << pfileheader->fontBox[2] - << " Precision =" << theCurvePrecision << endl; -#endif - } - if( myCharCapsHeight ) { - Standard_Integer xmin,ymin,xmax,ymax; - this->CharBoundingBox(Standard_Integer('H'),xmin,ymin,xmax,ymax); - if( ymax > 0 ) { - theFontXRatio = myCharWidth/ymax; - theFontYRatio = myCharHeight/ymax; - if( myIsFixedPitch ) { - theFixedCharWidth = (myCharWidth* - (pfileheader->fontBox[2]+pfileheader->fontBox[0]))/ymax; - } - } else { - theFontXRatio = myCharWidth/pfileheader->fontBox[3]; - theFontYRatio = myCharHeight/pfileheader->fontBox[3]; - if( myIsFixedPitch ) { - theFixedCharWidth = (myCharWidth* - (pfileheader->fontBox[2]+pfileheader->fontBox[0]))/ - pfileheader->fontBox[3]; - } - } - } else { - if( myIsFixedPitch ) { - Standard_Integer hmax = Max(pfileheader->fontBox[2], - pfileheader->fontBox[3]-pfileheader->fontBox[1]); - hmax -= 50; // Ajustement manuel !! - theFontXRatio = myCharWidth/hmax; - theFontYRatio = myCharHeight/hmax; - theFixedCharWidth = (myCharWidth* - (pfileheader->fontBox[2]+pfileheader->fontBox[0]))/hmax; - } else { - theFontXRatio = myCharWidth/pfileheader->fontBox[2]; - theFontYRatio = myCharHeight/pfileheader->fontBox[2]; - } - } - - theAsciiString = aString; - theOrientation = anOrientation; - theCharCount = 0; - theStringLength = theAsciiString.Length(); - theStringIsAscii = Standard_True; - theDeltaX = 0.; - theSinCharAngle = Sin(theOrientation); - theCosCharAngle = Cos(theOrientation); -} - -// ============================================================================= -// ---Purpose: Sets the extended text attributes. -// -- : the string to interpret -// -- : the orientation angle in RAD from horizontal. -// raises FontManagerError from MFT; -// ---Trigger: If the font is not a composite font and -// -- the string is not ASCII. -// ============================================================================= - -void MFT_FontManager::SetTextAttribs(const Standard_ExtString aString, const Quantity_PlaneAngle anOrientation) -{ -TCollection_ExtendedString estring(aString); - - if( estring.IsAscii() ) { - TCollection_AsciiString astring(estring,'?'); - this->SetTextAttribs(astring.ToCString(),anOrientation); - } else { -#if TRACE > 0 - cout << " MFT_FontManager::SetTextAttribs('" << estring << "'," << - anOrientation << ")" << endl; -#endif - MFT_FontManagerError_Raise_if( - !myIsComposite,"FONT is not composite"); - MFT_FileHeader *pfileheader = (MFT_FileHeader*) myFileHeader.precord; - theTanCharSlant = Tan(myCharSlant); - theFixedCharWidth = 0.; - if( !theMDTVFontPrecision ) { - theCurveFlatness = myCharPrecision * - pfileheader->fontBox[2]/Max(myCharWidth,myCharHeight); - theCurvePrecision = theCurveFlatness * 10.; - } - if( myCharCapsHeight ) { - Standard_Integer xmin,ymin,xmax,ymax; - this->CharBoundingBox(Standard_Integer('H')+0xFEE0,xmin,ymin,xmax,ymax); - if( ymax > 0 ) { - theFontXRatio = myCharWidth/ymax; - theFontYRatio = myCharHeight/ymax; - if( myIsFixedPitch ) { - theFixedCharWidth = (myCharWidth* - (pfileheader->fontBox[2]+pfileheader->fontBox[0]))/ymax; - } - } else { - theFontXRatio = myCharWidth/pfileheader->fontBox[3]; - theFontYRatio = myCharHeight/pfileheader->fontBox[3]; - if( myIsFixedPitch ) { - theFixedCharWidth = (myCharWidth* - (pfileheader->fontBox[2]+pfileheader->fontBox[0]))/ - pfileheader->fontBox[3]; - } - } - } else { - if( myIsFixedPitch ) { - Standard_Integer hmax = Max(pfileheader->fontBox[2], - pfileheader->fontBox[3]-pfileheader->fontBox[1]); - theFontXRatio = myCharWidth/hmax; - theFontYRatio = myCharHeight/hmax; - theFixedCharWidth = (myCharWidth* - (pfileheader->fontBox[2]+pfileheader->fontBox[0]))/hmax; - } else { - theFontXRatio = myCharWidth/pfileheader->fontBox[2]; - theFontYRatio = myCharHeight/pfileheader->fontBox[2]; - } - } - - theExtendedString = aString; - theOrientation = anOrientation; - theCharCount = 0; - theStringLength = theExtendedString.Length(); - theStringIsAscii = Standard_False; - theDeltaX = 0; - theSinCharAngle = Sin(theOrientation); - theCosCharAngle = Cos(theOrientation); - } -} - -// ---------------------------------------------------------------- -// -- Category: Methods to retrieve current attributes informations. -// ---------------------------------------------------------------- - -// ============================================================================= -// ---Purpose: Drawn an ANSI text -// -- : the draw manager to call for each vertex of the string. -// -- : the string to interpret -// -- : the orientation angle in RAD from horizontal. -// ============================================================================= - -void MFT_FontManager::DrawText(const Handle(MFT_TextManager)& aTextManager, const Standard_CString aString, const Quantity_Length anX, const Quantity_Length anY, const Quantity_PlaneAngle anOrientation) { -Standard_Boolean vazy; - - this->SetTextAttribs(aString,anOrientation); - - Standard_Integer aPosition; - MFT_FileHeader *pfileheader = (MFT_FileHeader*) myFileHeader.precord; - Quantity_Length Cwidth = theFontXRatio * - (pfileheader->fontBox[2] - pfileheader->fontBox[0]); - Quantity_Length Cheight = theFontYRatio * - (pfileheader->fontBox[3] - pfileheader->fontBox[1]); - Quantity_PlaneAngle Cslant = myCharSlant; - aTextManager->BeginString(anX,anY,anOrientation, - Cwidth,Cheight,Cslant,myPaintType); - while ( theCharCount < theStringLength ) { - aPosition = Standard_Integer((unsigned char)theAsciiString.Value(theCharCount+1)); - vazy = this->DrawChar(aTextManager,aPosition); - theCharCount++; - } - aTextManager->EndString(); -} - -// ============================================================================= -// ---Purpose: Drawn an EXTENDED text -// -- : the draw manager to call for each vertex of the string. -// -- : the string to interpret -// -- : the orientation angle in RAD from horizontal. -// raises FontManagerError from MFT; -// ---Trigger: If the font is not a composite font and -// -- the string is not ASCII. -// ============================================================================= - -void MFT_FontManager::DrawText(const Handle(MFT_TextManager)& aTextManager, const Standard_ExtString aString, const Quantity_Length anX, const Quantity_Length anY, const Quantity_PlaneAngle anOrientation) { -Standard_Boolean vazy; - - this->SetTextAttribs(aString,anOrientation); - - Standard_Integer aPosition; - MFT_FileHeader *pfileheader = (MFT_FileHeader*) myFileHeader.precord; - Quantity_Length Cwidth = theFontXRatio * - (pfileheader->fontBox[2] - pfileheader->fontBox[0]); - Quantity_Length Cheight = theFontYRatio * - (pfileheader->fontBox[3] - pfileheader->fontBox[1]); - Quantity_PlaneAngle Cslant = myCharSlant; - aTextManager->BeginString(anX,anY,anOrientation, - Cwidth,Cheight,Cslant,myPaintType); - while ( theCharCount < theStringLength ) { - if( theStringIsAscii ) - aPosition = Standard_Integer((unsigned char)theAsciiString.Value(theCharCount+1)); - else - aPosition = Standard_Integer((unsigned short)theExtendedString.Value(theCharCount+1)); - vazy = this->DrawChar(aTextManager,aPosition); - theCharCount++; - } - aTextManager->EndString(); -} - -// ============================================================================= -// ---Purpose: Retrieves the bounding box of the font. -// ============================================================================= - -void MFT_FontManager::BoundingBox(Standard_Integer& aMinX, Standard_Integer& aMinY, Standard_Integer& aMaxX, Standard_Integer& aMaxY) const -{ - MFT_FileHeader *pfileheader = (MFT_FileHeader*) myFileHeader.precord; - aMinX = pfileheader->fontBox[0]; - aMinY = pfileheader->fontBox[1]; - aMaxX = pfileheader->fontBox[2]; - aMaxY = pfileheader->fontBox[3]; -} - -// ============================================================================= -// ---Purpose: Retrieves the bounding box of a character. -// raises FontManagerError from MFT; -// ---Trigger: If the position is < 0 or > MaxCharPosition(). -// ============================================================================= - -void MFT_FontManager::CharBoundingBox(const Standard_Integer aPosition,Standard_Integer& aMinX, Standard_Integer& aMinY, Standard_Integer& aMaxX, Standard_Integer& aMaxY) -{ - aMinX = aMaxX = aMinY = aMaxY = 0; - if( this->IsDefinedChar(aPosition) ) { - this->SetChar(aPosition); - theCommand = NextCommand(myCommandBuffer); - if( COMMAND_TYPE(theCommand) == MFT_TOC_MINMAX ) { - aMinX = IValue(myCommandBuffer,1); - aMinY = IValue(myCommandBuffer,2); - aMaxX = IValue(myCommandBuffer,3); - aMaxY = IValue(myCommandBuffer,4); - } - } -} - -// ============================================================================= -// ---Purpose: Retrieves the paint type of the font. -// ============================================================================= - -Standard_Integer MFT_FontManager::PaintType() const -{ - MFT_FileHeader *pfileheader = (MFT_FileHeader*) myFileHeader.precord; - return pfileheader->paintType; -} - -// ============================================================================= -// ---Purpose: Retrieves the fixed pitch flag of the font. -// ============================================================================= - -Standard_Boolean MFT_FontManager::FixedPitch() const -{ - return myIsFixedPitch; -} - -// ============================================================================= -// ---Purpose: Retrieves the fixed italic angle of the font. -// ============================================================================= - -Quantity_PlaneAngle MFT_FontManager::ItalicAngle() const -{ - return Quantity_PlaneAngle(myItalicAngle); -} - -// ============================================================================= -// ---Purpose: Runs the interpretor with the current attributes setting -// -- (font and text attributes) -// -- and returns : -// -- The max char width of the font CharSet . -// -- The max char height of the font CharSet . -// -- The max char descent value below the baseline -// -- The slant angle of the font -// -- The interpolator precision of the font -// -- The caps height flag -// ============================================================================= - -Standard_CString MFT_FontManager::FontAttribs(Quantity_Length& aWidth, Quantity_Length& aHeight, Quantity_Length& aDescent, Quantity_PlaneAngle& aSlant, Quantity_Factor& aPrecision, Standard_Boolean &aCapsHeight) -{ - static TCollection_AsciiString fontname; - MFT_FileHeader *pfileheader = (MFT_FileHeader*) myFileHeader.precord; - fontname = pfileheader->fontName; - this->SetTextAttribs("",0.); - aWidth = theFontXRatio * - (pfileheader->fontBox[2] - pfileheader->fontBox[0]); - aHeight = theFontYRatio * - (pfileheader->fontBox[3] - pfileheader->fontBox[1]); - aDescent = theFontYRatio * pfileheader->fontBox[1]; - aSlant = myCharSlant; - aPrecision = myCharPrecision; - aCapsHeight = myCharCapsHeight; - -#if TRACE > 0 - cout << "'" << fontname << "' = MFT_FontManager::FontAttribs(" << - aWidth << "," << aHeight << "," << aDescent << "," << aSlant << "," << - aPrecision << "," << aCapsHeight << ")" << endl; -#endif - return fontname.ToCString(); -} - -// ============================================================================= -// ---Purpose: Runs the interpretor on the ASCII text -// -- with the current font attributes setting and returns : -// -- The string width . -// -- The string ascent . -// -- The string left bearing value from the origine -// -- The string descent value below the baseline -// ============================================================================= - -void MFT_FontManager::TextSize(const Standard_CString aString, Quantity_Length& aWidth, Quantity_Length& anAscent, Quantity_Length& aLbearing, Quantity_Length& aDescent) -{ - this->DrawText(theTextManager,aString,0.,0.,0.); - - Quantity_Length Xmin,Ymin,Xmax,Ymax; - theTextManager->MinMax(Xmin,Ymin,Xmax,Ymax); - aWidth = Xmax - Xmin; anAscent = Ymax; - aLbearing = Xmin; aDescent = -Ymin; - -#if TRACE > 0 - cout << " MFT_FontManager::TextSize(" << aString << "," << aWidth << "," - << anAscent << "," << aLbearing << "," << aDescent << ")" << endl; -#endif -} - -// ============================================================================= -// ---Purpose: Runs the interpretor on the EXTENDED text -// -- with the current font attributes setting and returns : -// -- The string width . -// -- The string ascent . -// -- The string left bearing value from the origine -// -- The string descent value below the baseline -// raises FontManagerError from MFT; -// ---Trigger: If the font is not a composite font and -// -- the string is not ASCII. -// ============================================================================= - -void MFT_FontManager::TextSize(const Standard_ExtString aString, Quantity_Length& aWidth, Quantity_Length& anAscent, Quantity_Length& aLbearing, Quantity_Length& aDescent) -{ - this->DrawText(theTextManager,aString,0.,0.,0.); - - Quantity_Length Xmin,Ymin,Xmax,Ymax; - theTextManager->MinMax(Xmin,Ymin,Xmax,Ymax); - aWidth = Xmax - Xmin; anAscent = Ymax; - aLbearing = Xmin; aDescent = -Ymin; - -#if TRACE > 0 - cout << " MFT_FontManager::TextSize(" << aString << "," << aWidth << "," - << anAscent << "," << aLbearing << "," << aDescent << ")" << endl; -#endif - -} - -// ============================================================================= -// ---Purpose: Runs the interpretor with the current attributes setting -// -- (font attributes) -// -- and returns : -// -- The char width . -// -- The char left bearing . -// -- The char right bearing . -// -- The char ascent . -// -- The char descent value below the baseline -// -- And returns TRUE if the character is defined. -// ============================================================================= - -Standard_Boolean MFT_FontManager::CharSize(const Standard_Character aChar, Quantity_Length& aWidth, Quantity_Length& aLbearing, Quantity_Length& aRbearing, Quantity_Length& anAscent, Quantity_Length& aDescent) -{ - Standard_Integer aPosition = Standard_Integer(aChar); - Standard_Boolean theStatus = Standard_False; - - if( this->IsDefinedChar(aPosition) ) { - this->SetTextAttribs("",0.); - MFT_FileHeader *pfileheader = (MFT_FileHeader*) myFileHeader.precord; - Quantity_Length Cwidth = theFontXRatio * - (pfileheader->fontBox[2] - pfileheader->fontBox[0]); - Quantity_Length Cheight = theFontYRatio * - (pfileheader->fontBox[3] - pfileheader->fontBox[1]); - Quantity_PlaneAngle Cslant = myCharSlant; - theTextManager->BeginString(0.,0.,0., - Cwidth,Cheight,Cslant,myPaintType); - this->DrawChar(theTextManager,aPosition); - theTextManager->EndString(); - Quantity_Length Xmin,Ymin,Xmax,Ymax; - theTextManager->MinMax(Xmin,Ymin,Xmax,Ymax); - aWidth = Xmax - Xmin; anAscent = Ymax; - aLbearing = Xmin; aDescent = -Ymin; - aRbearing = Xmax; - theStatus = Standard_True; - } -#if TRACE > 0 - cout << theStatus << " = MFT_FontManager::CharSize('" << aChar << - "'," << aWidth << "," << aLbearing << "," << aRbearing << - "," <. -// -- The extended char left bearing . -// -- The extended char right bearing . -// -- The extended char ascent . -// -- The extended char descent value below the baseline -// -- And returns TRUE if the character is defined. -// raises FontManagerError from MFT; -// ---Trigger: If the font is not a composite font and -// -- the char is not ASCII. -// ============================================================================= - -Standard_Boolean MFT_FontManager::CharSize(const Standard_ExtCharacter aChar, Quantity_Length& aWidth, Quantity_Length& aLbearing, Quantity_Length& aRbearing, Quantity_Length& anAscent, Quantity_Length& aDescent) -{ - Standard_Integer aPosition = Standard_Integer(aChar); - MFT_FontManagerError_Raise_if( - !myIsComposite && aPosition > 255, - "FONT is not composite"); - - Standard_Boolean theStatus = Standard_False; - if( this->IsDefinedChar(aPosition) ) { - this->SetTextAttribs("",0.); - MFT_FileHeader *pfileheader = (MFT_FileHeader*) myFileHeader.precord; - Quantity_Length Cwidth = theFontXRatio * - (pfileheader->fontBox[2] - pfileheader->fontBox[0]); - Quantity_Length Cheight = theFontYRatio * - (pfileheader->fontBox[3] - pfileheader->fontBox[1]); - Quantity_PlaneAngle Cslant = myCharSlant; - theTextManager->BeginString(0.,0.,0., - Cwidth,Cheight,Cslant,myPaintType); - this->DrawChar(theTextManager,aPosition); - theTextManager->EndString(); - Quantity_Length Xmin,Ymin,Xmax,Ymax; - theTextManager->MinMax(Xmin,Ymin,Xmax,Ymax); - aWidth = Xmax - Xmin; anAscent = Ymax; - aLbearing = Xmin; aDescent = -Ymin; - aRbearing = Xmax; - theStatus = Standard_True; - } -#if TRACE > 0 - cout << theStatus << " = MFT_FontManager::CharSize('" << aChar << - "'," << aWidth << "," << aLbearing << "," << aRbearing << - "," <fontName); - - return aFont; -} - -// ============================================================================= -// ---Purpose: Returns TRUE if the font is composite. -// ---Example: KANJI fonts returns TRUE. -// ============================================================================= - -Standard_Boolean MFT_FontManager::IsComposite() const -{ - return myIsComposite; -} - -// ============================================================================= -// ---Purpose: Returns TRUE if the font -// -- $CSF_MDTVFontDirectory/.mft exist. -// ============================================================================= - -Standard_Boolean MFT_FontManager::IsKnown(const Standard_CString anAliasName) -{ -Standard_CString path = Path(anAliasName); - - if( access(path,0) != -1 ) return Standard_True; - else return Standard_False; -} - -// ============================================================================= -// ---Purpose: Retrieves the font descriptor from an existing font -// raises FontManagerError from MFT; -// ---Trigger: If the font does not exist. -// ============================================================================= - -Aspect_FontStyle MFT_FontManager::Font(const Standard_CString anAliasName) -{ - OSD_OpenMode aFileMode = OSD_ReadOnly; - MFT_FileHandle handle = Open(anAliasName,aFileMode); -#ifdef PRO17604 - if( handle < 0 ) { - char message[512]; - sprintf(message,"BAD MFT font name '%s'",anAliasName); - MFT_FontManagerError::Raise(message); - } -#else - char message[80]; - sprintf(message,"BAD MFT font name '%s'",anAliasName); - MFT_FontManagerError_Raise_if(handle < 0,message); -#endif - - MFT_FileRecord header; - header.fileHandle = handle; - header.beginPosition = header.recordPosition = 0; - header.recordSize = sizeof(MFT_FileHeader); - header.update = Standard_False; - header.precord = NULL; - header.precordMMAPAddress = NULL; - header.recordMMAPSize = 0; -#ifndef No_Exception - Standard_Boolean status = -#endif - Read(header); - MFT_FontManagerError_Raise_if(!status,"HEADER Read error"); - - MFT_FileHeader *pfileheader = (MFT_FileHeader*) header.precord; - MFT_FontManagerDefinitionError_Raise_if(!pfileheader,"BAD MFT header"); - if( pfileheader->signature != MFT_SIGNATURE ) { - SWAPINT(pfileheader->signature); - } - MFT_FontManagerDefinitionError_Raise_if( - pfileheader->signature != MFT_SIGNATURE,"BAD MFT signature"); - Aspect_FontStyle aFont((Standard_PCharacter)pfileheader->fontName); - free((Standard_Address)header.precord); - Close(handle); - - return aFont; -} - -// ============================================================================= -// ---Purpose: Returns the MFT font number available -// -- in the directory $CSF_MDTVFontDirectory -// -- according to the filter -// ---Examples: number = MFT_FontMAnager::FontNumber("-euclid3"); -// -- returns only the euclid3 fonts. -// -- number = MFT_FontMAnager::FontNumber( -// "-*-*-*-*-*-*-*-*-*-*-*-*-japanese"); -// -- returns only the japanese fonts. -// ============================================================================= - -Standard_Integer MFT_FontManager::FontNumber(const Standard_CString aFilter) -{ -static TCollection_AsciiString astar("*"); -// -// Retrieves all xxx.fmt files -// -//GG090200 BUG OSD_Path pathfile,pathdir(TCollection_AsciiString("")); -//JR OSD_Path pathfile,pathdir(TCollection_AsciiString(Path(""))); - OSD_Path pathfile; - TCollection_AsciiString apathmft = TCollection_AsciiString(Path("")) ; - OSD_Path pathdir = OSD_Path(apathmft); - OSD_FileIterator files(pathdir,"*.mft"); - OSD_File file; - theListOfFontName.Clear(); - if( aFilter && strlen(aFilter) > 0 && strcmp(aFilter,"*") ) { - Aspect_FontStyle filter(aFilter); - TCollection_AsciiString atoken1,atoken2,afilter = filter.FullName(); - Standard_Boolean found; - Standard_Integer i; - while (files.More()) { - file = files.Values(); - file.Path(pathfile); - Aspect_FontStyle font = MFT_FontManager::Font(pathfile.Name().ToCString()); - TCollection_AsciiString afont = font.FullName(); - found = Standard_True; - for( i=2 ; i<=14 ; i++ ) { - atoken1 = afilter.Token("-",i); - if( atoken1 != astar ) { - atoken2 = afont.Token("-",i); - if( atoken1 != atoken2 ) { - found = Standard_False; break; - } - } - } - if( found ) theListOfFontName.Append(pathfile.Name()); - files.Next(); - } - } else { - while (files.More()) { - file = files.Values(); - file.Path(pathfile); - theListOfFontName.Append(pathfile.Name()); - files.Next(); - } - } - - return theListOfFontName.Length(); -} - -// ============================================================================= -// ---Purpose: Retrieves the font descriptor of index -// -- from the directory $CSF_MDTVFontDirectory -// raises OutOfRange from Standard; -// ---Trigger: If the font rank is < 1 or > FontNumber(). -// ============================================================================= - -Aspect_FontStyle MFT_FontManager::Font(const Standard_Integer aRank) -{ - Standard_OutOfRange_Raise_if( - aRank < 1 || aRank > theListOfFontName.Length(),"BAD font rank"); - - TCollection_AsciiString filename = theListOfFontName.Value(aRank); - OSD_OpenMode aFileMode = OSD_ReadOnly; - MFT_FileHandle handle = Open(filename,aFileMode); -#ifdef PRO17604 - if( handle < 0 ) { - char message[512]; - sprintf(message,"BAD MFT font name '%s'",filename.ToCString()); - MFT_FontManagerError::Raise(message); - } -#else - char message[80]; - sprintf(message,"BAD MFT font name '%s'",filename); - MFT_FontManagerError_Raise_if(handle < 0,message); -#endif - - MFT_FileRecord header; - header.fileHandle = handle; - header.beginPosition = header.recordPosition = 0; - header.recordSize = sizeof(MFT_FileHeader); - header.update = Standard_False; - header.precord = NULL; - header.precordMMAPAddress = NULL; - header.recordMMAPSize = 0; -#ifndef No_Exception - Standard_Boolean status = -#endif - Read(header); - MFT_FontManagerError_Raise_if(!status,"HEADER Read error"); - - MFT_FileHeader *pfileheader = (MFT_FileHeader*) header.precord; - MFT_FontManagerDefinitionError_Raise_if(!pfileheader,"BAD MFT header"); - if( pfileheader->signature != MFT_SIGNATURE ) { - SWAPINT(pfileheader->signature); - } - MFT_FontManagerDefinitionError_Raise_if( - pfileheader->signature != MFT_SIGNATURE,"BAD MFT signature"); - Aspect_FontStyle aFont((Standard_PCharacter)pfileheader->fontName); - free((Standard_Address)header.precord); - Close(handle); - - return aFont; -} - -// ============================================================================= -// ---Purpose: Returns the max values of any defined command -// ============================================================================= - -Standard_Integer MFT_FontManager::MaxCommandValues() -{ - return MFT_MAXVALUES; -} - -// ============================================================================= -// ---Purpose: Returns the encoding of the char position -// -- . -// raises FontManagerError from MFT; -// ---Trigger: If the char is not defined -// ============================================================================= - -Standard_CString MFT_FontManager::Encoding(const Standard_Integer aPosition) -{ - MFT_FontManagerError_Raise_if( - !this->IsDefinedChar(aPosition),"CHAR is not defined"); - this->DrawChar(theTextManager,aPosition); - Standard_CString pencoding = theTextManager->Encoding(); - - return pencoding; -} - -// ============================================================================= -// ---Purpose: Returns the char position -// -- from the encoding . -// raises FontManagerError from MFT; -// ---Trigger: If the char is not defined -// ============================================================================= - -Standard_Integer MFT_FontManager::Encoding(const Standard_CString anEncoding) -{ -Standard_Integer i; -Standard_CString pencoding; - - for( i=0 ; iIsDefinedChar(i) ) { - this->DrawChar(theTextManager,i); - pencoding = theTextManager->Encoding(); - if( !strcmp(anEncoding,pencoding) ) return i; - } - } - - return 0; -} - -// ============================================================================= -// ---Purpose: Dumps the font descriptor off all characters. -// ============================================================================= - -void MFT_FontManager::Dump() -{ -MFT_FileHeader *pfileheader = (MFT_FileHeader*)myFileHeader.precord; -Standard_Integer i; - - cout << endl << endl; - cout << ".MFT_FontManager::Dump() :" << endl; - cout << " -----------------------" << endl << endl; - cout << " File version is : " << pfileheader->version << endl; - cout << " File name is : '" << Path(myFileName) << "'" << endl; - cout << " XLFD Font name is : '" << pfileheader->fontName << "'" << endl; - cout << " Char entries section begin at : " << pfileheader->pentries << endl; - cout << " Commands section begin at : " << pfileheader->pcommands << endl; - cout << " Free space address is : " << pfileheader->freeSpace << endl; - cout << " Font bounding box is : (" << pfileheader->fontBox[0] << "," << - pfileheader->fontBox[1] << "," << pfileheader->fontBox[2] << "," << - pfileheader->fontBox[3] << ")" << endl; - if( myIsComposite ) - cout << " The font is COMPOSITE " << endl; - else - cout << " The font is ASCII " << endl; - if( myPaintType > 0 ) - cout << " The font paint type is STROKE" << endl; - else - cout << " The font paint type is FILL" << endl; - if( myIsFixedPitch ) - cout << " The font has a fixed char width" << endl; - else - cout << " The font has a proportionnal char width" << endl; - if( pfileheader->version > 280597 ) { - cout << " The font italic angle is " << myItalicAngle << " rad" << endl; - } - - for( i=0 ; iMaxCharPosition() ; i++ ) { - if( this->IsDefinedChar(i) ) { - if( myIsComposite ) this->Dump(Standard_ExtCharacter(i)); - else if( i < MFT_MAXASCIICHARENTRIES ) this->Dump(Standard_Character(i)); - else { - cout << endl; - cout << " .MFT_FontManager::DumpAccent(" << i << ") :" << endl; - cout << " -----------------------" << endl << endl; - - this->Dump(i); - } - } - } -} - -// ============================================================================= -// ---Purpose: Dumps the font descriptor off the character . -// ============================================================================= - -void MFT_FontManager::Dump(const Standard_Character aChar) -{ -Standard_Integer aPosition((unsigned char)aChar); - - cout << endl; - cout << " .MFT_FontManager::Dump('" << aChar << "/" << - aPosition << "') :" << endl; - cout << " -----------------------" << endl << endl; - - this->Dump(aPosition); -} - -// ============================================================================= -// ---Purpose: Dumps the font descriptor off the extended character . -// raises FontManagerError from MFT; -// ---Trigger: If the font is not a composite font. -// ============================================================================= - -void MFT_FontManager::Dump(const Standard_ExtCharacter aChar) -{ -Standard_Integer aPosition((unsigned short)aChar); - cout << endl; - cout << " .MFT_FontManager::Dump(" << aChar << "/" << - aPosition << ") :" << endl; - cout << " -----------------------" << endl << endl; - - MFT_FontManagerError_Raise_if( - !myIsComposite,"FONT is not composite"); - this->Dump(aPosition); -} - -// ============================================================================= -// ---Purpose: Saves the file in CSF_MDTVFontDirectory/xxxx.dat -// ============================================================================= - -#define MAXENTRIESBYLINE 8 -Standard_Boolean MFT_FontManager::Save() -{ -MFT_FileHeader *pfileheader = (MFT_FileHeader*)myFileHeader.precord; -MFT_CharEntries *pcharentries = (MFT_CharEntries*) myCharEntries.precord; -MFT_CommandValue value; -Standard_CString path = Path(myFileName,".dat"); -Standard_Integer i,j,n,rp; -Standard_Boolean skip = Standard_False; - - FILE *aWFileHandle = fopen(path,"w"); - if( !aWFileHandle ) { - cout << "*MFT_FontManager::Save().cann't open the file : '" << - path << "',returns with errno " << errno << endl; - return Standard_False; - } - - fprintf(aWFileHandle," MFT font comes from '%s'\n",myFileName.ToCString()); - fprintf(aWFileHandle," %d %d %d %d %d %d %d %d %d %d %d\n %s\n", - pfileheader->iscomposite, pfileheader->pentries, - pfileheader->pcommands, pfileheader->freeSpace, - pfileheader->fontBox[0], pfileheader->fontBox[1], - pfileheader->fontBox[2], pfileheader->fontBox[3], - pfileheader->paintType, pfileheader->version, - pfileheader->fixedPitch, pfileheader->fontName); - if( pfileheader->version > 280597 ) { - float A; - A = ITOF(pfileheader->italicAngle); - fprintf(aWFileHandle," %f\n",A); - } - fprintf(aWFileHandle,"#MFT_char_entries_begin_at_position %d\n", - pfileheader->pentries); - for( i=n=0 ; ifcommand[n+j] != 0 ) break; - } - if( j < MAXENTRIESBYLINE ) { - if( skip ) fprintf(aWFileHandle,"*0x%04X/",n); - else fprintf(aWFileHandle," 0x%04X/",n); - skip = Standard_False; - for( j=0 ; jfcommand[n]; - fprintf(aWFileHandle," %8d", rp); n++; - } - fprintf(aWFileHandle,"\n"); - } else { - n += MAXENTRIESBYLINE; skip = Standard_True; - } - } - fprintf(aWFileHandle,"#MFT_commands_begin_at_position %d\n", - pfileheader->pcommands); - MFT_TypeOfValue aValueType; - theNextCommandPosition = pfileheader->pcommands; - do { - theCommand = NextCommand(myCommandBuffer); - rp = theCommandPosition - pfileheader->pcommands; - value.d = theCommand; - fprintf(aWFileHandle," %8d/ '%s' 0x%08x", rp, - MFT::Convert(MFT_TypeOfCommand(COMMAND_TYPE(theCommand))),value.i); - if( COMMAND_LENGTH(theCommand) > 0 ) { - for( i=1 ; i <= Standard_Integer( COMMAND_LENGTH(theCommand) ); i++ ) { - aValueType = Value(theCommand,i); - switch( aValueType ) { - case MFT_TOV_UNKNOWN: - fprintf(aWFileHandle," ????????"); - break; - case MFT_TOV_INTEGER: - fprintf(aWFileHandle," %d",IValue(myCommandBuffer,i)); - break; - case MFT_TOV_FLOAT: - fprintf(aWFileHandle," %f",FValue(myCommandBuffer,i)); - break; - case MFT_TOV_STRING: - fprintf(aWFileHandle," '%s'",SValue(myCommandBuffer,i)); - break; - } - } - } - fprintf(aWFileHandle,"\n"); - } while( theNextCommandPosition < pfileheader->freeSpace ); - fclose(aWFileHandle); - return Standard_True; -} - -// ============================================================================= -// ---Purpose: Restores the file from CSF_MDTVFontDirectory/xxxx.dat -// ============================================================================= - -Standard_Boolean MFT_FontManager::Restore(const Standard_CString anAliasName) -{ -static TCollection_AsciiString svalue; -Standard_CString path = Path(anAliasName,".dat"); -Standard_Integer i,j,n,rp,status; -char skip,astring[128]; - - FILE *aRFileHandle = fopen(path,"r"); - if( !aRFileHandle ) { - cout << "*MFT_FontManager::Restore().cann't open the file : '" << - path << "',returns with errno " << errno << endl; - return Standard_False; - } - OSD_OpenMode aFileMode = OSD_WriteOnly; - MFT_FileHandle aWFileHandle = Open(anAliasName,aFileMode); - if( aWFileHandle < 0 ) { - cout << "*MFT_FontManager::Restore().cann't open the file : '" << - Path(anAliasName) << "',returns with errno " << errno << endl; - fclose(aRFileHandle); - return Standard_False; - } - - MFT_FileRecord aWFileHeader; - aWFileHeader.fileHandle = aWFileHandle; - aWFileHeader.beginPosition = aWFileHeader.recordPosition = 0; - aWFileHeader.recordSize = sizeof(MFT_FileHeader); - aWFileHeader.update = Standard_True; - aWFileHeader.precord = (Standard_CString) malloc(aWFileHeader.recordSize); - aWFileHeader.precordMMAPAddress = NULL; - aWFileHeader.recordMMAPSize = 0; - MFT_FileHeader *pfileheader = (MFT_FileHeader*) aWFileHeader.precord; - if( !pfileheader ) { - cout << "*MFT_FontManager::Restore().BAD header allocation" << endl; - fclose(aRFileHandle); - Close(aWFileHandle); - return Standard_False; - } - - pfileheader->signature = MFT_SIGNATURE; - fscanf(aRFileHandle," MFT font comes from '%s'\n",astring); - fscanf(aRFileHandle," %d %d %d %d %d %d %d %d %d %d %d\n %s\n", - &pfileheader->iscomposite, &pfileheader->pentries, - &pfileheader->pcommands, &pfileheader->freeSpace, - &pfileheader->fontBox[0], &pfileheader->fontBox[1], - &pfileheader->fontBox[2], &pfileheader->fontBox[3], - &pfileheader->paintType, &pfileheader->version, - &pfileheader->fixedPitch, pfileheader->fontName); - if( pfileheader->version > 280597 ) { - float A; - fscanf(aRFileHandle," %f\n",&A); - pfileheader->italicAngle = FTOI(A); - } - Write(aWFileHeader); - - fscanf(aRFileHandle,"#MFT_char_entries_begin_at_position %d\n",&j); - MFT_FileRecord aWCharEntries; - aWCharEntries.fileHandle = aWFileHandle; - aWCharEntries.beginPosition = - aWCharEntries.recordPosition = pfileheader->pentries; - if( pfileheader->iscomposite ) { - aWCharEntries.recordSize = sizeof(MFT_ExtendedCharEntries); - } else { - aWCharEntries.recordSize = sizeof(MFT_AsciiCharEntries); - } - aWCharEntries.update = Standard_True; - aWCharEntries.precord = (Standard_CString) calloc(aWCharEntries.recordSize,1); - aWCharEntries.precordMMAPAddress = NULL; - aWCharEntries.recordMMAPSize = 0; - MFT_CharEntries *pcharentries = (MFT_CharEntries*) aWCharEntries.precord; - if( !pcharentries ) { - cout << "*MFT_FontManager::Restore().BAD char entries allocation" << endl; - fclose(aRFileHandle); - Close(aWFileHandle); - return Standard_False; - } - - for( i=0 ; i < (int)( aWCharEntries.recordSize/sizeof(MFT_FilePosition) ); i++ ) { - pcharentries->fcommand[i] = 0; - } - for( i=n=0 ; i < (int)( aWCharEntries.recordSize/sizeof(MFT_FilePosition) ); i += MAXENTRIESBYLINE ) { - fscanf(aRFileHandle,"%c%s\n",&skip,astring); - if( skip != '#' ) { - sscanf(astring,"0x%X/",&n); - for( j=0 ; jfcommand[n] = rp; n++; - } - fscanf(aRFileHandle,"\n"); - } else break; - } - Write(aWCharEntries); - - if( skip != '#' ) - fscanf(aRFileHandle,"#MFT_commands_begin_at_position %d\n", &j); - else - fscanf(aRFileHandle,"%d\n", &j); - MFT_FileRecord aWCommandBuffer; - aWCommandBuffer.fileHandle = aWFileHandle; - aWCommandBuffer.beginPosition = - aWCommandBuffer.recordPosition = pfileheader->pcommands; - aWCommandBuffer.recordSize = sizeof(MFT_CommandBuffer); - aWCommandBuffer.update = Standard_True; - aWCommandBuffer.precord = (Standard_CString) malloc(aWCommandBuffer.recordSize); - aWCommandBuffer.precordMMAPAddress = NULL; - aWCommandBuffer.recordMMAPSize = 0; - MFT_TypeOfValue aValueType; - MFT_CommandValue value; - Standard_Integer *pcommand; - theNextCommandPosition = pfileheader->pcommands; - while ( - (status = fscanf(aRFileHandle," %d/ '%s 0x%x",&rp,astring,&value.i)) != EOF ) { - theCommand = value.d; - theCommandPosition = pfileheader->pcommands + rp; - pcommand = (Standard_Integer*) Locate(aWCommandBuffer,theCommandPosition); - *pcommand = value.i; aWCommandBuffer.update = Standard_True; - if( COMMAND_LENGTH(theCommand) > 0 ) { - for( i=1 ; i <= (int)( COMMAND_LENGTH(theCommand) ); i++ ) { - aValueType = Value(theCommand,i); - switch( aValueType ) { - case MFT_TOV_UNKNOWN: - fscanf(aRFileHandle," %s",astring); - value.i = 0; - break; - case MFT_TOV_INTEGER: - fscanf(aRFileHandle," %d",&value.i); - break; - case MFT_TOV_FLOAT: - fscanf(aRFileHandle," %f",&value.f); - break; - case MFT_TOV_STRING: - fscanf(aRFileHandle," '%s",astring); - astring[strlen(astring)-1] = '\0'; - strncpy(value.s,astring,4); - break; - } - theCommandPosition += sizeof(MFT_CommandValue); - pcommand = (Standard_Integer*) Locate(aWCommandBuffer,theCommandPosition); - *pcommand = value.i; aWCommandBuffer.update = Standard_True; - } - } - fscanf(aRFileHandle,"\n"); - } - fclose(aRFileHandle); - free((Standard_Address)aWFileHeader.precord); - free((Standard_Address)aWCharEntries.precord); - if( aWCommandBuffer.update ) Write(aWCommandBuffer); - free((Standard_Address)aWCommandBuffer.precord); - Close(aWFileHandle); - - return Standard_True; -} - -// ============================================================================= -// ---Purpose: Returns the Underline descent position from the origin -// -- of the text according to the current font attributes. -// ============================================================================= - -Quantity_Length MFT_FontManager::UnderlinePosition() const -{ - MFT_FileHeader *pfileheader = (MFT_FileHeader*) myFileHeader.precord; - Quantity_Length value = 0.; - - if( pfileheader->fontBox[1] < 0 ) { - if( myCharCapsHeight ) { - value = -0.6 * myCharHeight * pfileheader->fontBox[1] / pfileheader->fontBox[3]; - } else { - value = -0.6 * myCharHeight * pfileheader->fontBox[1] / pfileheader->fontBox[2]; - } - } else { - value = 0.2 * myCharHeight; - } - - return value; -} - -// ---------------------------- -// -- Category: Private methods -// ---------------------------- - -// ============================================================================= -// ---Purpose: Open the file ,load and verify the header -// -- and returns the file handle & file header address -// -- when the file is opened correctly. -// raises OutOfMemory from Standard is private; -// ---Trigger: If header allocation fails -// ============================================================================= - - -MFT_FileHandle MFT_FontManager::Open(const TCollection_AsciiString& aFileName, const OSD_OpenMode aFileMode) -{ -MFT_FileHandle aFileHandle = -1; -TCollection_AsciiString path(Path(aFileName)); - - if( path.Length() > 0 ) { - Standard_Integer i,nfont = theListOfOpenFontName.Length(); - if( nfont > 0 ) { - for( i=1 ; i<=nfont ; i++ ) { - if( path == theListOfOpenFontName.Value(i) ) { - // USE an already opened font - aFileHandle = theListOfOpenFontHandle.Value(i); - Standard_Integer ref = theListOfOpenFontReference.Value(i); - theListOfOpenFontReference.SetValue(i,ref+1); - break; - } - } - } - if( aFileHandle < 0 ) { - switch (aFileMode) { - case OSD_ReadOnly: - aFileHandle = open(path.ToCString(), O_RDONLY -#ifndef WNT - ); -#else - | O_BINARY ); -#endif - break; - - case OSD_WriteOnly: - aFileHandle = open(path.ToCString(), O_CREAT | O_RDWR | O_EXCL -#ifndef WNT - ,S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH); -#else - | O_BINARY, S_IREAD | S_IWRITE); -#endif - break; - - case OSD_ReadWrite: - aFileHandle = open(path.ToCString(),O_RDWR -#ifndef WNT - ); -#else - | O_BINARY); -#endif - } - - if( aFileHandle < 0 ) { - cout << "*IO Error status " << errno << - " in MFT_FontManager::Open('" << path << "'," << - Standard_Integer(aFileMode) << ")" << endl; - } else { - // SAVE the just opened font - theListOfOpenFontName.Append(path); - theListOfOpenFontHandle.Append(aFileHandle); - theListOfOpenFontReference.Append(1); - } - } - } - -#if TRACE > 0 - cout << aFileHandle << " = MFT_FontManager::Open('" << path << - "'," << Standard_Integer(aFileMode) << ")" << endl; -#endif - - return aFileHandle; -} - -// ============================================================================= -// ---Purpose: Close the file -// -- and returns TRUE if the file was successfully closed. -// ============================================================================= - -Standard_Boolean MFT_FontManager::Close(const MFT_FileHandle& aFileHandle) -{ - Standard_Integer i,nfont = theListOfOpenFontHandle.Length(); - Standard_Integer status = 0; - if( nfont > 0 ) { - for( i=1 ; i<=nfont ; i++ ) { - if( aFileHandle == theListOfOpenFontHandle.Value(i) ) { - Standard_Integer ref = theListOfOpenFontReference.Value(i); - if( ref > 1 ) { - theListOfOpenFontReference.SetValue(i,ref-1); - status = -1; - } else { - theListOfOpenFontName.Remove(i); - theListOfOpenFontHandle.Remove(i); - theListOfOpenFontReference.Remove(i); - } - break; - } - } - } - - if( status >= 0 ) { - status = close(aFileHandle); - } - -#if TRACE > 0 - cout << status << " = MFT_FontManager::Close(" << aFileHandle << ")" << endl; -#endif - - return (status >= 0) ? Standard_True : Standard_False; -} - -// ============================================================================= -// ---Purpose: Saves updated records and Close this file -// -- and returns TRUE if the file was successfully closed. -// ============================================================================= - -Standard_Boolean MFT_FontManager::Close() -{ - //Save file - if( myFileHeader.update ) Write(myFileHeader); - if( myCharEntries.update ) Write(myCharEntries); - if( myCommandBuffer.update ) Write(myCommandBuffer); - - //Free memories -#ifdef MUNMAP - if( myFileHeader.recordMMAPSize && myFileHeader.precordMMAPAddress ) { -#if TRACE_MMAP > 0 - printf(" FH_MUNMAP(%lx,%ld)\n", - myFileHeader.precordMMAPAddress,myFileHeader.recordMMAPSize); -#endif - MUNMAP(myFileHeader.precordMMAPAddress,myFileHeader.recordMMAPSize); - } else -#endif - if( myFileHeader.precord ) free((Standard_Address)myFileHeader.precord); - myFileHeader.precord = NULL; - myFileHeader.precordMMAPAddress = NULL; - -#ifdef MUNMAP - if( myCharEntries.recordMMAPSize && myCharEntries.precordMMAPAddress ) { -#if TRACE_MMAP > 0 - printf(" CE_MUNMAP(%lx,%ld)\n", - myCharEntries.precordMMAPAddress,myCharEntries.recordMMAPSize); -#endif - MUNMAP(myCharEntries.precordMMAPAddress,myCharEntries.recordMMAPSize); - } else -#endif - if( myCharEntries.precord ) free((Standard_Address)myCharEntries.precord); - myCharEntries.precord = NULL; - myCharEntries.precordMMAPAddress = NULL; - -#ifdef MUNMAP - if( myCommandBuffer.recordMMAPSize && myCommandBuffer.precordMMAPAddress ) { -#if TRACE_MMAP > 0 - printf(" CB_MUNMAP(%lx,%ld)\n", - myCommandBuffer.precordMMAPAddress,myCommandBuffer.recordMMAPSize); -#endif - MUNMAP(myCommandBuffer.precordMMAPAddress,myCommandBuffer.recordMMAPSize); - } else -#endif - if( myCommandBuffer.precord ) free((Standard_Address)myCommandBuffer.precord); - myCommandBuffer.precord = NULL; - myCommandBuffer.precordMMAPAddress = NULL; - - return Close(myFileHandle); -} - -// ============================================================================= -// ---Purpose: Reads a record from the file. -// -- Returns TRUE if the file was successfully read. -// ============================================================================= - -Standard_Boolean MFT_FontManager::Read(MFT_FileRecord& aRecord) { - -#if TRACE > 1 - cout << "MFT_FontManager::Read(Handle(" << aRecord.fileHandle << - "),Position(" << aRecord.recordPosition << - "),Size(" << aRecord.recordSize << "))" << endl; -#endif - -#ifdef S3593 -# ifdef MMAP - static MFT_FilePosition position,offset; -# else - static MFT_FilePosition position; -# endif -#else -# ifdef MMAP - MFT_FilePosition position,offset; -# else - MFT_FilePosition position; -# endif -#endif - -#ifdef MMAP - if( aRecord.recordMMAPSize ) { - position = (MFT_FilePosition) - (aRecord.recordMMAPSize * (aRecord.recordPosition/ - aRecord.recordMMAPSize)); - offset = aRecord.recordPosition - position; - - if( !aRecord.precordMMAPAddress || - (position != aRecord.recordMMAPPosition) ) { - aRecord.recordMMAPPosition = position; -# ifdef MUNMAP - if( aRecord.precordMMAPAddress ) { -# if TRACE_MMAP > 0 - printf(" MUNMAP(%lx,%ld)\n", - aRecord.precordMMAPAddress,aRecord.recordMMAPSize); -# endif - MUNMAP(aRecord.precordMMAPAddress,aRecord.recordMMAPSize); - } -# endif - aRecord.precordMMAPAddress = - (Standard_CString) MMAP(position,aRecord.recordMMAPSize,aRecord.fileHandle); -# if TRACE_MMAP > 0 - printf(" %lx = MMAP(%d,%ld,%d)\n", aRecord.precordMMAPAddress, - position,aRecord.recordMMAPSize,aRecord.fileHandle); -# endif - if( aRecord.precordMMAPAddress == (Standard_CString)MAP_FAILED ) { - char message[64]; - sprintf(message,"MEMORY mapping failed with errno = %d\n",errno); - Standard_OutOfMemory::Raise(message); - } - } - aRecord.precord = aRecord.precordMMAPAddress + offset; - } else { -#endif - position = (MFT_FilePosition) - lseek(aRecord.fileHandle, (long)aRecord.recordPosition, SEEK_SET); - if( position < 0 ) { - cout << "*IO Error status " << errno << - " in MFT_FontManager::Read(Handle(" << aRecord.fileHandle << - "),Position(" << aRecord.recordPosition << "))" << endl; - return Standard_False; - } - if( aRecord.precord == NULL ) { - aRecord.precord = (Standard_CString) malloc(aRecord.recordSize); - Standard_OutOfMemory_Raise_if( - !aRecord.precord,"MEMORY allocation failed"); - } - Standard_Integer i,length; - Standard_CString precord = aRecord.precord; - for( i=0 ; i < (int) aRecord.recordSize ; - i += MFT_BLOCKSIZE,precord += MFT_BLOCKSIZE) { - length = read(aRecord.fileHandle, (Standard_Address)precord, MFT_BLOCKSIZE); - - if( length == -1 ) { - cout << "*IO Error status " << errno << - " in MFT_FontManager::Read(Handle(" << aRecord.fileHandle << - "),Position(" << aRecord.recordPosition << "),Size(" << - aRecord.recordSize << "))" << endl; - return Standard_False; - } else if( length > 0 && length != MFT_BLOCKSIZE ) { - cout << "*IO warning " << length << - " in MFT_FontManager::Read(Handle(" << aRecord.fileHandle << - "),Position(" << aRecord.recordPosition << "),Size(" << - aRecord.recordSize << "))" << endl; - } - } -#ifdef MMAP - } -#endif - - return Standard_True; -} - -// ============================================================================= -// ---Purpose: Writes a record to the file. -// -- Returns TRUE if the file was successfully written. -// ============================================================================= - -Standard_Boolean MFT_FontManager::Write(MFT_FileRecord& aRecord) { - -#if TRACE > 1 - cout << "MFT_FontManager::Write(Handle(" << aRecord.fileHandle << - "),Position(" << aRecord.recordPosition << - "),Size(" << aRecord.recordSize << "))" << endl; -#endif - -#ifdef S3593 - static MFT_FilePosition position; -#else - MFT_FilePosition position; -#endif - - position = (MFT_FilePosition) - lseek(aRecord.fileHandle,(long)aRecord.recordPosition,SEEK_SET); - if( position < 0 ) { - cout << "*IO Error status " << errno << - " in MFT_FontManager::Write(Handle(" << aRecord.fileHandle << - "),Position(" << aRecord.recordPosition << "))" << endl; - return Standard_False; - } - if( aRecord.precord == NULL ) { - Standard_OutOfMemory_Raise_if( - !aRecord.precord,"UNALLOCATED memory"); - } - Standard_Integer i,length; - Standard_CString precord = aRecord.precord; - for( i=0 ; i < (int) aRecord.recordSize ; - i += MFT_BLOCKSIZE,precord += MFT_BLOCKSIZE ) { - length = write(aRecord.fileHandle,precord,MFT_BLOCKSIZE); - - if( length == -1 ) { - cout << "*IO Error status " << errno << - " in MFT_FontManager::Write(Handle(" << aRecord.fileHandle << - "),Position(" << aRecord.recordPosition << "),Size(" << - aRecord.recordSize << "))" << endl; - return Standard_False; - } else if( length != MFT_BLOCKSIZE ) { - cout << "*IO warning " << length << - " in MFT_FontManager::Write(Handle(" << aRecord.fileHandle << - "),Position(" << aRecord.recordPosition << "),Size(" << - aRecord.recordSize << "))" << endl; - } - } - aRecord.update = Standard_False; - - return Standard_True; -} - -// ============================================================================= -// ---Purpose: Locates an information from the file record. -// -- and returns the info address. -// ---Warning: May read or write the current record -// -- from/to the file and reload an other record -// -- according the file position info. -// ============================================================================= - -Standard_Address MFT_FontManager::Locate(MFT_FileRecord& aRecord, const MFT_FilePosition& aFilePosition) { -Standard_Address aRecordAddress; -#ifdef S3593 -#ifdef MMAP - if( aRecord.precordMMAPAddress && - (aFilePosition < aRecord.recordMMAPSize) ) { - aRecordAddress = (Standard_Address)(aRecord.precordMMAPAddress + aFilePosition); - - return aRecordAddress; - } -#endif -#endif - -#ifdef S3593 - static MFT_FilePosition aRecordNumber; -#else - MFT_FilePosition aRecordNumber; -#endif - - aRecordNumber = (aFilePosition - aRecord.beginPosition)/aRecord.recordSize; - - if( aRecordNumber < 0 ) { - cout << "*MAPPING Error in MFT_FontManager::Locate(Handle(" << - aRecord.fileHandle << "),BeginPosition(" << - aRecord.beginPosition << "),Position(" << - aRecord.recordPosition << "),Size(" << - aRecord.recordSize << ")," << aFilePosition << ")" << endl; - MFT_FontManagerError::Raise("BAD File position"); - } -#ifdef S3593 - static MFT_FilePosition aRecordPosition; -#else - MFT_FilePosition aRecordPosition; -#endif - aRecordPosition = aRecord.beginPosition + - aRecordNumber * aRecord.recordSize; - - if( !aRecord.precord || (aRecordPosition != aRecord.recordPosition) ) { - if( aRecord.update ) Write(aRecord); - aRecord.recordPosition = aRecordPosition; - aRecord.update = Standard_False; - Read(aRecord); - } - - aRecordAddress = (Standard_Address)(aRecord.precord + (aFilePosition - aRecordPosition)); - - return aRecordAddress; -} - -// ============================================================================= -// ---Purpose: Computes the full path of the font file name -// -- $CSF_MDTVFontDirectory/ -// ============================================================================= - -Standard_CString MFT_FontManager::Path(const TCollection_AsciiString& aFileName,const Standard_CString anExtension) -{ -static TCollection_AsciiString pathname; -TCollection_AsciiString dir(CSF_MDTVFontDirectory.Value()); - if( dir.Length() > 0 ) {pathname = dir; pathname += "/";} - else pathname.Clear(); - if( aFileName.Length() > 0 ) { - pathname += aFileName; - if( pathname.SearchFromEnd(anExtension) < 0 ) { - pathname += anExtension; - } - } - - return pathname.ToCString(); -} - -// ============================================================================= -// ---Purpose: Returns the max position of any defined char -// -- in the header of the file according with the -// -- type of the font. -// ============================================================================= - -Standard_Integer MFT_FontManager::MaxCharPosition() const -{ - return myCharEntries.recordSize/sizeof(MFT_FilePosition) - 1; -} - -// ============================================================================= -// ---Purpose: Returns TRUE if the char at position is defined -// -- in the header of the file. -// raises FontManagerError from MFT is private; -// ---Trigger: If the position is < 0 or > MaxCharPosition(). -// ============================================================================= - -Standard_Boolean MFT_FontManager::IsDefinedChar(const Standard_Integer aPosition) const -{ - unsigned int position = aPosition & 0xFFFF; - Standard_OutOfRange_Raise_if( - position > (unsigned int) MaxCharPosition(),"BAD char rank"); - - MFT_CharEntries *pcharentries = (MFT_CharEntries*) myCharEntries.precord; - if( pcharentries->fcommand[position] > 0 ) return Standard_True; - - return Standard_False; -} - -// ============================================================================= -// ---Purpose: Returns the first defined char position -// -- in the header of the file.. -// ============================================================================= - -Standard_Integer MFT_FontManager::FirstDefinedChar() const -{ - MFT_CharEntries *pcharentries = (MFT_CharEntries*) myCharEntries.precord; - Standard_Integer i,n = (myIsComposite) ? - MFT_MAXEXTENDEDCHARENTRIES : MFT_MAXASCIICHARENTRIES; - for( i=0 ; ifcommand[i] > 0 ) return i; - } - return 0; -} - -// ============================================================================= -// ---Purpose: Returns the last defined char position -// -- in the header of the file.. -// ============================================================================= - -Standard_Integer MFT_FontManager::LastDefinedChar() const -{ - MFT_CharEntries *pcharentries = (MFT_CharEntries*) myCharEntries.precord; - Standard_Integer i,n = (myIsComposite) ? - MFT_MAXEXTENDEDCHARENTRIES : MFT_MAXASCIICHARENTRIES; - for( i=n-1 ; i>0 ; --i ) { - if( pcharentries->fcommand[i] > 0 ) return i; - } - return 0; -} - -// ============================================================================= -// ---Purpose: Enable the char of position for reading. -// ============================================================================= - -void MFT_FontManager::SetChar (const Standard_Integer aPosition) -{ - unsigned int position; -#if TRACE > 1 - cout << " MFT_FontManager::SetChar(" << position << ")" << endl; -#endif - MFT_CharEntries *pcharentries = (MFT_CharEntries*) myCharEntries.precord; - if( aPosition < 0 ) { - position = 0; - theFirstCommandPosition = theNextCommandPosition = -aPosition; - } else { - position = aPosition & 0xFFFF; - theFirstCommandPosition = theNextCommandPosition = - pcharentries->fcommand[position]; - } - theCharPosition = position; - if( theFirstCommandPosition > 0 ) return; - - if( myIsComposite ) { - if( position > 0x20 && position <= 0x7F ) { - position += 0xFEE0; // Sets UNICODE ascii char - if( pcharentries->fcommand[position] == 0 ) position = 0x3000; - } else position = 0x3000; // Sets UNICODE BLANK char - } else { - position = 0; // Sets DEFAULT char - } - - theCharPosition = position; - theFirstCommandPosition = theNextCommandPosition = // Sets UNDEF char - pcharentries->fcommand[position]; -} - -// ============================================================================= -// ---Purpose: Drawn the char at position -// -- with the draw manager . -// ============================================================================= - -Standard_Boolean MFT_FontManager::DrawChar (const Handle(MFT_TextManager)& aTextManager, const Standard_Integer aPosition) -{ -#if TRACE > 1 - cout << " MFT_FontManager::DrawChar(" << aPosition << ")" << endl; -#endif - - Standard_Boolean vazy = Standard_True; - Standard_Real X,Y,XX,YY,X1,Y1,X2,Y2,X3,Y3,X4,Y4; - Standard_Integer position = aPosition; - - theDotSection = Standard_False; - - this->SetChar(position); - if( theFirstCommandPosition > 0 ) { - if( !theStackCount ) { - theCharX = theCharY = 0; - theLeftCharX = theLeftCharY = 0; - theCharWidth = theCharHeight = 0; - if( myIsFixedPitch ) { - theStringX = theFixedCharWidth*theCharCount*theCosCharAngle; - theStringY = theFixedCharWidth*theCharCount*theSinCharAngle; - } else { - theStringX = theFontXRatio*theDeltaX*theCosCharAngle; - theStringY = theFontXRatio*theDeltaX*theSinCharAngle; - } - vazy = aTextManager->BeginChar(position,theStringX,theStringY); - } - if( vazy ) do { - theCommand = NextCommand(myCommandBuffer); - theCommandType = COMMAND_TYPE(theCommand); - theCommandLength = COMMAND_LENGTH(theCommand); -#if TRACE > 2 - cout << " MFT_FontManager::DrawChar.'" << - MFT::Convert(theCommandType) << "'("; -#endif - theValueCount = 0; - // GET command values - while ( theValueCount < theCommandLength ) { - theValueType = Value(theCommand,theValueCount+1); -#if TRACE > 2 - cout << "[" << MFT::Convert(theValueType) << " = "; -#endif - switch( theValueType ) { - case MFT_TOV_UNKNOWN: - break; - case MFT_TOV_INTEGER: - theIValues[theValueCount] = IValue(myCommandBuffer,theValueCount+1); - theFValues[theValueCount] = - Standard_Real(theIValues[theValueCount]); -#if TRACE > 2 - cout << theIValues[theValueCount]; -#endif - break; - case MFT_TOV_FLOAT: - theFValues[theValueCount] = FValue(myCommandBuffer,theValueCount+1); - theIValues[theValueCount] = - Standard_Integer(theFValues[theValueCount]); -#if TRACE > 2 - cout << theFValues[theValueCount]; -#endif - break; - case MFT_TOV_STRING: - strcpy(&theSValues[theValueCount*sizeof(MFT_CommandValue)], - SValue(myCommandBuffer,theValueCount+1)) -; -#if TRACE > 2 - cout << theSValues[theValueCount*sizeof(MFT_CommandValue)]; -#endif - break; - } -#if TRACE > 2 - cout << "]"; -#endif - theValueCount++; - } -#if TRACE > 2 - cout << ")" << endl; -#endif - // EXECUTE command - switch (theCommandType) { - case MFT_TOC_UNKNOWN: - break; - case MFT_TOC_HSTEM: //UNIMPLEMENTED - CHECKCOMMAND(2); - break; - case MFT_TOC_VSTEM: //UNIMPLEMENTED - CHECKCOMMAND(2); - break; - case MFT_TOC_VMOVETO: - CHECKCOMMAND(1); - theCharY += theFValues[0]; - X = theCharX; Y = theCharY; TRANSFORM(X,Y); - vazy = aTextManager->Moveto(X,Y); - break; - case MFT_TOC_RLINETO: - CHECKCOMMAND(2); - theCharX += theFValues[0]; - theCharY += theFValues[1]; - X = theCharX; Y = theCharY; TRANSFORM(X,Y); - vazy = aTextManager->Lineto(X,Y); - break; - case MFT_TOC_HLINETO: - CHECKCOMMAND(1); - theCharX += theFValues[0]; - X = theCharX; Y = theCharY; TRANSFORM(X,Y); - vazy = aTextManager->Lineto(X,Y); - break; - case MFT_TOC_VLINETO: - CHECKCOMMAND(1); - theCharY += theFValues[0]; - X = theCharX; Y = theCharY; TRANSFORM(X,Y); - vazy = aTextManager->Lineto(X,Y); - break; - case MFT_TOC_RRCURVETO: - CHECKCOMMAND(6); - X1 = theCharX; Y1 = theCharY; - X2 = X1 + theFValues[0]; Y2 = Y1 + theFValues[1]; - X3 = X2 + theFValues[2]; Y3 = Y2 + theFValues[3]; - XX = X4 = X3 + theFValues[4]; YY = Y4 = Y3 + theFValues[5]; - TRANSFORM(X1,Y1); TRANSFORM(X2,Y2); - TRANSFORM(X3,Y3); TRANSFORM(X4,Y4); - if( !aTextManager->Curveto(X1,Y1,X2,Y2,X3,Y3,X4,Y4) ) { - SETCURVE( theFValues[0],theFValues[1], - theFValues[2],theFValues[3], - theFValues[4],theFValues[5]); - if( theCurveNT < 5 ) { - vazy = aTextManager->Lineto(X2,Y2); - vazy = aTextManager->Lineto(X3,Y3); - } else { - for( theCurveT=theCurveDT ; theCurveT<1. ; - theCurveT+=theCurveDT) { - GETCURVE(theCurveT); - if( ((Abs(theCharX - theOldCharX) + - Abs(theCharY - theOldCharY)) > theCurvePrecision) ) { - X = theCharX; Y = theCharY; TRANSFORM(X,Y); - vazy = aTextManager->Lineto(X,Y); - theOldCharX = theCharX; theOldCharY = theCharY; - } - } - } - vazy = aTextManager->Lineto(X4,Y4); - } - theCharX = XX; theCharY = YY; - break; - case MFT_TOC_CLOSEPATH: - aTextManager->ClosePath(); - break; - case MFT_TOC_HSBW: - CHECKCOMMAND(2); - theLeftCharX = theFValues[0]; - theLeftCharY = 0; - theCharWidth = theFValues[1]; - theCharHeight = 0; - if( !theStackCount ) { - theCharX = theLeftCharX; - theCharY = theLeftCharY; - X = theCharX; Y = theCharY; TRANSFORM(X,Y); - vazy = aTextManager->Moveto(X,Y); - } - break; - case MFT_TOC_ENDCHAR: - break; - case MFT_TOC_RMOVETO: - CHECKCOMMAND(2); - theCharX += theFValues[0]; - theCharY += theFValues[1]; - X = theCharX; Y = theCharY; TRANSFORM(X,Y); - vazy = aTextManager->Moveto(X,Y); - break; - case MFT_TOC_HMOVETO: - CHECKCOMMAND(1); - theCharX += theFValues[0]; - X = theCharX; Y = theCharY; TRANSFORM(X,Y); - vazy = aTextManager->Moveto(X,Y); - break; - case MFT_TOC_VHCURVETO: - CHECKCOMMAND(4); - X1 = theCharX; Y1 = theCharY; - X2 = X1; Y2 = Y1 + theFValues[0]; - X3 = X2 + theFValues[1]; Y3 = Y2 + theFValues[2]; - XX = X4 = X3 + theFValues[3]; YY = Y4 = Y3; - TRANSFORM(X1,Y1); TRANSFORM(X2,Y2); - TRANSFORM(X3,Y3); TRANSFORM(X4,Y4); - if( !aTextManager->Curveto(X1,Y1,X2,Y2,X3,Y3,X4,Y4) ) { - SETCURVE( 0,theFValues[0], - theFValues[1],theFValues[2], - theFValues[3],0); - if( theCurveNT < 5 ) { - vazy = aTextManager->Lineto(X2,Y2); - vazy = aTextManager->Lineto(X3,Y3); - } else { - for( theCurveT=theCurveDT ; theCurveT<1. ; - theCurveT+=theCurveDT) { - GETCURVE(theCurveT); - if( ((Abs(theCharX - theOldCharX) + - Abs(theCharY - theOldCharY)) > theCurvePrecision) ) { - X = theCharX; Y = theCharY; TRANSFORM(X,Y); - vazy = aTextManager->Lineto(X,Y); - theOldCharX = theCharX; theOldCharY = theCharY; - } - } - } - vazy = aTextManager->Lineto(X4,Y4); - } - theCharX = XX; theCharY = YY; - break; - case MFT_TOC_HVCURVETO: - CHECKCOMMAND(4); - X1 = theCharX; Y1 = theCharY; - X2 = X1 + theFValues[0]; Y2 = Y1; - X3 = X2 + theFValues[1]; Y3 = Y2 + theFValues[2]; - XX = X4 = X3; YY = Y4 = Y3 + theFValues[3]; - TRANSFORM(X1,Y1); TRANSFORM(X2,Y2); - TRANSFORM(X3,Y3); TRANSFORM(X4,Y4); - if( !aTextManager->Curveto(X1,Y1,X2,Y2,X3,Y3,X4,Y4) ) { - SETCURVE( theFValues[0],0, - theFValues[1],theFValues[2], - 0,theFValues[3]); - if( theCurveNT < 5 ) { - vazy = aTextManager->Lineto(X2,Y2); - vazy = aTextManager->Lineto(X3,Y3); - } else { - for( theCurveT=theCurveDT ; theCurveT<1. ; - theCurveT+=theCurveDT) { - GETCURVE(theCurveT); - if( ((Abs(theCharX - theOldCharX) + - Abs(theCharY - theOldCharY)) > theCurvePrecision) ) { - X = theCharX; Y = theCharY; TRANSFORM(X,Y); - vazy = aTextManager->Lineto(X,Y); - theOldCharX = theCharX; theOldCharY = theCharY; - } - } - } - vazy = aTextManager->Lineto(X4,Y4); - } - theCharX = XX; theCharY = YY; - break; - case MFT_TOC_DOTSECTION: //UNIMPLEMENTED - theDotSection = !theDotSection; - break; - case MFT_TOC_VSTEM3: //UNIMPLEMENTED - CHECKCOMMAND(6); - break; - case MFT_TOC_HSTEM3: //UNIMPLEMENTED - CHECKCOMMAND(6); - break; - case MFT_TOC_SEAC: - CHECKCOMMAND(5); - theSeacAsbValue = theFValues[0]; - theSeacAdxValue = theFValues[1]; - theSeacAdyValue = theFValues[2]; - theSeacBaseChar = theIValues[3]; - theSeacAccentChar = theIValues[4]; - IPUSH(theFirstCommandPosition); - IPUSH(theNextCommandPosition); - RPUSH(theCharWidth); - this->DrawChar(aTextManager,theSeacBaseChar); - theCharX = theLeftCharX + theSeacAdxValue; - theCharY = theLeftCharY + theSeacAdyValue; - this->DrawChar(aTextManager,theSeacAccentChar); - RPOP(theCharWidth); - IPOP(theNextCommandPosition); - IPOP(theFirstCommandPosition); - break; - case MFT_TOC_SBW: - CHECKCOMMAND(4); - theLeftCharX = theFValues[0]; - theLeftCharY = theFValues[1]; - theCharWidth = theFValues[2]; - theCharHeight = theFValues[3]; - if( !theStackCount ) { - theCharX = theLeftCharX; - theCharY = theLeftCharY; - X = theCharX; Y = theCharY; TRANSFORM(X,Y); - vazy = aTextManager->Moveto(X,Y); - } - break; - case MFT_TOC_SETCURRENTPOINT: - CHECKCOMMAND(2); - theCharX = theFValues[0]; - theCharY = theFValues[1]; - break; - case MFT_TOC_CHARSTRING: - if( theSValues[0] == '/' ) - vazy = aTextManager->SetCharEncoding(&theSValues[1]); - break; - case MFT_TOC_NUMERIC: //UNIMPLEMENTED - break; - case MFT_TOC_MINMAX: - CHECKCOMMAND(4); - theCharWidth = theFValues[2]; - X1 = theFValues[0]; Y1 = theFValues[1]; - X3 = theFValues[2]; Y3 = theFValues[3]; - X2 = X3; Y2 = Y1; - X4 = X1; Y4 = Y3; - TRANSFORM(X1,Y1); TRANSFORM(X2,Y2); - TRANSFORM(X3,Y3); TRANSFORM(X4,Y4); - vazy = aTextManager->SetCharBoundingBox(X1,Y1,X2,Y2,X3,Y3,X4,Y4); - break; - } - - } while ( vazy && (theCommandType != MFT_TOC_ENDCHAR) ); - } - if( !theStackCount ) { - if( theCharWidth > 0. ) theDeltaX += theCharWidth; - else theDeltaX += myCharWidth/theFontXRatio; - theStringX = theFontXRatio*theDeltaX*theCosCharAngle; - theStringY = theFontXRatio*theDeltaX*theSinCharAngle; - vazy = aTextManager->EndChar(theStringX,theStringY); - } - - return vazy; -} - -// ============================================================================= -// ---Purpose: Computes the bounding box of the char position -// ============================================================================= - -void MFT_FontManager::ComputeBoundingBox (const Standard_Integer aPosition) -{ -#if TRACE > 1 - cout << " MFT_FontManager::ComputeBoundingBox(" << aPosition << ")" << endl; -#endif - - theTanCharSlant = 0.; - theFontXRatio = theFontYRatio = 1.; - theOrientation = 0.; - theDeltaX = 0.; - theSinCharAngle = 0.; - theCosCharAngle = 1.; - Standard_Boolean fixedPitch = myIsFixedPitch; - myIsFixedPitch = Standard_False; - - this->DrawChar(theTextManager,aPosition); - myIsFixedPitch = fixedPitch; - - Quantity_Length Xmin,Ymin,Xmax,Ymax; - theTextManager->MinMax(Xmin,Ymin,Xmax,Ymax); - TCollection_AsciiString encoding = theTextManager->Encoding(); - if( encoding == ".notdef" ) { - MFT_CharEntries *pcharentries = (MFT_CharEntries*) myCharEntries.precord; - pcharentries->fcommand[0] = theFirstCommandPosition; - } - - Standard_Integer *pvalue; - theCommandPosition = theFirstCommandPosition + sizeof(MFT_CommandDescriptor); - pvalue = (Standard_Integer*) Locate(myCommandBuffer,theCommandPosition); - *pvalue = Standard_Integer(Xmin); - myCommandBuffer.update = Standard_True; - - theCommandPosition += sizeof(MFT_CommandValue); - pvalue = (Standard_Integer*) Locate(myCommandBuffer,theCommandPosition); - *pvalue = Standard_Integer(Ymin); - myCommandBuffer.update = Standard_True; - - theCommandPosition += sizeof(MFT_CommandValue); - pvalue = (Standard_Integer*) Locate(myCommandBuffer,theCommandPosition); - *pvalue = Standard_Integer(Xmax); - myCommandBuffer.update = Standard_True; - - theCommandPosition += sizeof(MFT_CommandValue); - pvalue = (Standard_Integer*) Locate(myCommandBuffer,theCommandPosition); - *pvalue = Standard_Integer(Ymax); - myCommandBuffer.update = Standard_True; -} - -// ============================================================================= -// ---Purpose: Returns the next command type and length -// -- from the current char (see SetChar()). -// ---Warning: the last command of the char descriptor -// -- has a type MFC_TOC_ENDCHAR. -// ============================================================================= - -MFT_CommandDescriptor MFT_FontManager::NextCommand(MFT_FileRecord& aRecord) -{ -#ifdef S3593 -static MFT_CommandValue value; -#else -MFT_CommandValue value; -#endif - - theCommandPosition = theNextCommandPosition; - value.i = *(Standard_Integer*) Locate(aRecord,theCommandPosition); - if( aRecord.swap ) SWAPINT(value.i); - theNextCommandPosition += sizeof(MFT_CommandDescriptor) + - COMMAND_LENGTH(value.d) * sizeof(MFT_CommandValue); - return value.d; -} - -// ============================================================================= -// ---Purpose: Returns the value type at position -// -- of the current command. -// raises OutOfRange from Standard is private; -// ---Trigger: If the position is < 1 or > the command length. -// ============================================================================= - -MFT_TypeOfValue MFT_FontManager::Value(const MFT_CommandDescriptor& aDescriptor, const Standard_Integer aRank) -{ - -#ifdef S3593 -static MFT_CommandDescriptor d; - - d = aDescriptor; - if( aRank < 1 || aRank > (int)COMMAND_LENGTH(d) ) - Standard_OutOfRange::Raise("BAD command value rank"); - - unsigned int type = COMMAND_VALUETYPE(d,aRank); -#else - Standard_OutOfRange_Raise_if( - aRank < 1 || aRank > COMMAND_LENGTH(aDescriptor), - "BAD command value rank"); - - unsigned int type = COMMAND_VALUETYPE(aDescriptor,aRank); -#endif - - MFT_TypeOfValue aValueType = MFT_TypeOfValue(type); - -#if TRACE > 3 - cout << MFT::Convert(aValueType) << " = MFT_FontManager::Value(" - << aRank << ")" << endl; -#endif - - return aValueType; -} - -// ============================================================================= -// ---Purpose: Returns the integer parameter at position -// -- of the current command. -// raises FontManagerError from MFT is private; -// ---Trigger: If the position is < 1 or > the command length. -// -- or if the value is not an INT value. -// ============================================================================= - -Standard_Integer MFT_FontManager::IValue(MFT_FileRecord& aRecord, const Standard_Integer aRank) -{ -#ifdef S3593 -static MFT_CommandValue value; - - if( Value(theCommand,aRank) != MFT_TOV_INTEGER ) - Standard_TypeMismatch::Raise("BAD command value type"); -#else -MFT_CommandValue value; - - Standard_TypeMismatch_Raise_if( - Value(theCommand,aRank) != MFT_TOV_INTEGER, - "BAD command value type"); -#endif - - value.i = *(Standard_Integer*) - Locate(aRecord,theCommandPosition + - sizeof(MFT_CommandDescriptor) + (aRank-1) * - sizeof(MFT_CommandValue)); - if( aRecord.swap ) SWAPINT(value.i); - return value.i; -} - -// ============================================================================= -// ---Purpose: Returns the float parameter at position -// -- of the current command. -// raises FontManagerError from MFT is private; -// ---Trigger: If the position is < 1 or > the command length. -// -- or if the value is not a FLOAT value. -// ============================================================================= - -Standard_ShortReal MFT_FontManager::FValue(MFT_FileRecord& aRecord,const Standard_Integer aRank) -{ -#ifdef S3593 -static MFT_CommandValue value; - - if( Value(theCommand,aRank) != MFT_TOV_FLOAT ) - Standard_TypeMismatch::Raise("BAD command value type"); -#else -MFT_CommandValue value; - - Standard_TypeMismatch_Raise_if( - Value(theCommand,aRank) != MFT_TOV_FLOAT, - "BAD command value type"); -#endif - - value.i = *(Standard_Integer*) - Locate(aRecord,theCommandPosition + - sizeof(MFT_CommandDescriptor) + (aRank-1) * - sizeof(MFT_CommandValue)); - if( aRecord.swap ) SWAPFLOAT(value.f); - return value.f; -} - -// ============================================================================= -// ---Purpose: Returns the string parameter at position -// -- of the current command. -// raises FontManagerError from MFT is private; -// ---Trigger: If the position is < 1 or > the command length. -// -- or if the value is not a STRING value. -// ============================================================================= - -Standard_CString MFT_FontManager::SValue(MFT_FileRecord& aRecord,const Standard_Integer aRank) -{ -static char svalue[5]; - -#ifdef S3593 -static MFT_CommandValue value; - - if( Value(theCommand,aRank) != MFT_TOV_STRING ) - Standard_TypeMismatch::Raise("BAD command value type"); -#else -MFT_CommandValue value; - - Standard_TypeMismatch_Raise_if( - Value(theCommand,aRank) != MFT_TOV_STRING, - "BAD command value type"); -#endif - - value.i = *(Standard_Integer*) - Locate(aRecord,theCommandPosition + - sizeof(MFT_CommandDescriptor) + (aRank-1) * - sizeof(MFT_CommandValue)); - strncpy(svalue,value.s,4); - svalue[4] = '\0'; - return svalue; -} - -// ============================================================================= -// ---Purpose: Dumps the font descriptor off the character at -// -- position -// ============================================================================= - -void MFT_FontManager::Dump(const Standard_Integer aPosition) -{ - if( this->IsDefinedChar(aPosition) ) { - Standard_Integer i; - MFT_TypeOfValue aValueType; - this->SetChar(aPosition); - do { - theCommand = this->NextCommand(myCommandBuffer); - cout << " >> " << MFT::Convert(MFT_TypeOfCommand(COMMAND_TYPE(theCommand))); - if( COMMAND_LENGTH(theCommand) > 0 ) { - cout << " = "; - for( i=1 ; i <= (int) COMMAND_LENGTH(theCommand) ; i++ ) { - aValueType = Value(theCommand,i); - cout << "[" << MFT::Convert(aValueType) << " : "; - switch( aValueType ) { - case MFT_TOV_UNKNOWN: - cout << "??????"; - break; - case MFT_TOV_INTEGER: - cout << IValue(myCommandBuffer,i); - break; - case MFT_TOV_FLOAT: - cout << FValue(myCommandBuffer,i); - break; - case MFT_TOV_STRING: - cout << "'" << SValue(myCommandBuffer,i) << "'"; - break; - } - if( i < (int)COMMAND_LENGTH(theCommand) ) cout << "],"; - else cout << "]" << endl; - } - } else cout << endl; - } while( COMMAND_TYPE(theCommand) != MFT_TOC_ENDCHAR ); - } else { - cout << " This character is not DEFINED" << endl; - } -} diff --git a/src/MFT/MFT_TextManager.cdl b/src/MFT/MFT_TextManager.cdl deleted file mode 100755 index 7b030ca5a8..0000000000 --- a/src/MFT/MFT_TextManager.cdl +++ /dev/null @@ -1,143 +0,0 @@ --- Created on: 1993-04-29 --- Created by: Gerard GRAS --- Copyright (c) 1993-1999 Matra Datavision --- Copyright (c) 1999-2012 OPEN CASCADE SAS --- --- The content of this file is subject to the Open CASCADE Technology Public --- License Version 6.5 (the "License"). You may not use the content of this file --- except in compliance with the License. Please obtain a copy of the License --- at http://www.opencascade.org and read it completely before using this file. --- --- The Initial Developer of the Original Code is Open CASCADE S.A.S., having its --- main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. --- --- The Original Code and all software distributed under the License is --- distributed on an "AS IS" basis, without warranty of any kind, and the --- Initial Developer hereby disclaims all such warranties, including without --- limitation, any warranties of merchantability, fitness for a particular --- purpose or non-infringement. Please see the License for the specific terms --- and conditions governing the rights and limitations under the License. - - - -class TextManager from MFT inherits TShared from MMgt - ----Purpose: defines the common behaviour of the MFT output driver. --- Warning: Permits to receives draw primitives from the FontManager --- at DrawText(...) time. --- This class must be redefined by the user as an application class --- connected to a user driver. - -uses - FontManager from MFT, - PlaneAngle from Quantity, - Length from Quantity - -is - - - ------------------------- - -- Category: Constructors - ------------------------- - - Create returns TextManager from MFT; - ---Purpose: Does NOTHING - - ------------------------- - -- Category: Draw methods - ------------------------- - - BeginString (me: mutable; - X,Y: Length from Quantity; - anOrientation: PlaneAngle from Quantity; - aWidth,aHeight: Length from Quantity; - aSlant: PlaneAngle from Quantity; - aPaintType: Integer from Standard) is virtual; - ---Purpose: Calls when string drawing is started. - -- with a string aspect : - -- 0 for filled string - -- 1 for stroke string - -- 2 for outline string - -- The origine of the string ,, - -- The orientation of the string , - -- The medium size of the char , - -- The Slant of the char , - - BeginChar (me: mutable; - aCharCode: Integer from Standard; - X,Y: Length from Quantity) - returns Boolean from Standard is virtual; - ---Purpose: Calls when a char drawing is started - -- and give the relative char start position from the beginning - -- of the string. - -- The application can returns FALSE for skipping the char drawing. - - SetCharBoundingBox (me: mutable; - X1,Y1,X2,Y2,X3,Y3,X4,Y4: Length from Quantity) - returns Boolean from Standard is virtual; - ---Purpose: Calls to defines the current char bounding-box with : - -- X1,Y1 : the lower left corner of the box, - -- X2,Y2 : the lower right corner of the box, - -- X3,Y3 : the upper right corner of the box, - -- X4,Y4 : the upper left corner of the box. - -- Warning: the char bounding box is not rectangular when the Slant is != 0. - -- The application can returns FALSE for skipping the char drawing. - - SetCharEncoding (me: mutable; - anEncoding: CString from Standard) - returns Boolean from Standard is virtual; - ---Purpose: Calls to defines the current char encoding. - -- Warning: The application can returns FALSE for skipping the char drawing. - - Moveto (me: mutable; - X,Y: Length from Quantity) - returns Boolean from Standard is virtual; - ---Purpose: Calls to sets the current string position. - -- The application can returns FALSE for skipping the char drawing. - - Lineto (me: mutable; - X,Y: Length from Quantity) - returns Boolean from Standard is virtual; - ---Purpose: Calls to drawn to the current string position. - -- The application can returns FALSE for skipping the char drawing. - Curveto (me: mutable; - X1,Y1,X2,Y2,X3,Y3,X4,Y4: Length from Quantity) - returns Boolean from Standard is virtual; - ---Purpose: Calls to drawn to the current string position. - -- The application can drawn the curve defined by - -- his descriptor P1,P2,P3,P4 or - -- returns FALSE to let the interpretor compute the curve - -- vectors. - - ClosePath (me: mutable) is virtual; - ---Purpose: Calls when a char path drawing is ended - - EndChar (me: mutable; - X,Y: Length from Quantity) - returns Boolean from Standard is virtual; - ---Purpose: Calls when a char drawing is ended - -- and give the relative char ending position from the - -- beginning of the string. - -- The application can returns FALSE for skipping the string - -- drawing. - - EndString (me: mutable ) is virtual; - ---Purpose: Calls when string drawing is ended (Normally the last call). - - ------------------------- - -- Category: Private methods - ------------------------- - - MinMax (myclass; - Xmin,Ymin,Xmax,Ymax: out Length from Quantity) - is private; - ---Purpose: Returns the current drawn string min-max. - - Encoding (myclass) - returns CString from Standard is private; - ---Purpose: Returns the current drawn char encoding. - -friends - class FontManager from MFT - -end TextManager from MFT; diff --git a/src/MFT/MFT_TextManager.cxx b/src/MFT/MFT_TextManager.cxx deleted file mode 100755 index 06f7e64c5a..0000000000 --- a/src/MFT/MFT_TextManager.cxx +++ /dev/null @@ -1,167 +0,0 @@ -// Copyright (c) 1999-2012 OPEN CASCADE SAS -// -// The content of this file is subject to the Open CASCADE Technology Public -// License Version 6.5 (the "License"). You may not use the content of this file -// except in compliance with the License. Please obtain a copy of the License -// at http://www.opencascade.org and read it completely before using this file. -// -// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its -// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. -// -// The Original Code and all software distributed under the License is -// distributed on an "AS IS" basis, without warranty of any kind, and the -// Initial Developer hereby disclaims all such warranties, including without -// limitation, any warranties of merchantability, fitness for a particular -// purpose or non-infringement. Please see the License for the specific terms -// and conditions governing the rights and limitations under the License. - -#define PRO15231 //GG 080998 -// De maniere indirect on corrige le retour -// de SetCharBoundingBox() de maniere a activer -// l'optimisation importante pour myFontManager::TextSize() - -#include -#include -#define TRACE 0 - -static Quantity_Length theXmin,theYmin,theXmax,theYmax; -static Quantity_Length theWidth,theHeight; -static Quantity_PlaneAngle theOrientation,theSlant; -static TCollection_AsciiString theEncoding; -static Standard_Boolean theSkipFlag = Standard_False; - -MFT_TextManager::MFT_TextManager() { -} - -void MFT_TextManager::BeginString( const Quantity_Length X, const Quantity_Length Y, const Quantity_PlaneAngle anOrientation, const Quantity_Length aWidth, const Quantity_Length aHeight, const Quantity_PlaneAngle aSlant, const Standard_Integer aPaintType) { -#if TRACE > 0 - cout << " MFT_TextManager::BeginString(" << - X << "," << Y << "," << anOrientation << "," - << aWidth << "," << aHeight << "," aSlant << "," - << aPaintType << ")" << endl; -#endif - theOrientation = anOrientation; - theSlant = aSlant; - theWidth = aWidth; - theHeight = aHeight; - theXmin = theYmin = theXmax = theYmax = 0.; -} - -Standard_Boolean MFT_TextManager::BeginChar(const Standard_Integer aCharCode, const Standard_Real X, const Standard_Real Y) { -#if TRACE > 0 - cout << " MFT_TextManager::BeginChar(" << aCharCode << "," << - X << "," << Y << ")" << endl; -#endif - theXmin = Min(theXmin,X); theXmax = Max(theXmax,X); - theYmin = Min(theYmin,Y); theYmax = Max(theYmax,Y); - theSkipFlag = Standard_False; - theEncoding.Clear(); - return Standard_True; -} - -Standard_Boolean MFT_TextManager::SetCharBoundingBox(const Quantity_Length X1, const Quantity_Length Y1, const Quantity_Length X2, const Quantity_Length Y2, const Quantity_Length X3, const Quantity_Length Y3, const Quantity_Length X4, const Quantity_Length Y4) { - -#if TRACE > 0 - cout << " MFT_TextManager::SetCharBoundingBox(" << X1 << "," << Y1 << "," << - X2 << "," << Y2 << "," << X3 << "," << Y3 << "," << - X4 << "," << Y4 << ")" << endl; -#endif - - if( theOrientation != 0. ) { //NOT IMPLEMENTED,because not used -#ifdef PRO15231 - theSkipFlag = Standard_False; -#endif - } - if( X2 > X1 ) { - theXmin = Min(theXmin,X1); theXmin = Min(theXmin,X4); - theYmin = Min(theYmin,Y1); theYmax = Max(theYmax,Y3); - theXmax = Max(theXmax,X2); theXmax = Max(theXmax,X3); - theSkipFlag = Standard_True; - } else { - theSkipFlag = Standard_False; - } -#ifdef PRO15231 - return !theSkipFlag; -#else - return Standard_True; -#endif -} - -Standard_Boolean MFT_TextManager::SetCharEncoding(const Standard_CString anEncoding) { - -#if TRACE > 0 - cout << " MFT_TextManager::SetCharEncoding('" << anEncoding << "')" << endl; -#endif - - theEncoding = anEncoding; - - return !theSkipFlag; -} - -Standard_Boolean MFT_TextManager::Moveto(const Quantity_Length X, const Quantity_Length Y) { -#if TRACE > 1 - cout << " MFT_TextManager::Moveto(" << X << "," << Y << ")" << endl; -#endif - theXmin = Min(theXmin,X); theXmax = Max(theXmax,X); - theYmin = Min(theYmin,Y); theYmax = Max(theYmax,Y); - return Standard_True; -} - -Standard_Boolean MFT_TextManager::Lineto(const Quantity_Length X, const Quantity_Length Y) { -#if TRACE > 1 - cout << " MFT_TextManager::Lineto(" << X << "," << Y << ")" << endl; -#endif - theXmin = Min(theXmin,X); theXmax = Max(theXmax,X); - theYmin = Min(theYmin,Y); theYmax = Max(theYmax,Y); - return Standard_True; -} - -Standard_Boolean MFT_TextManager::Curveto(const Quantity_Length X1, const Quantity_Length Y1, const Quantity_Length X2, const Quantity_Length Y2, const Quantity_Length X3, const Quantity_Length Y3, const Quantity_Length X4, const Quantity_Length Y4) { - -#if TRACE > 0 - cout << " MFT_TextManager::Curveto(" << X1 << "," << Y1 << "," << - X2 << "," << Y2 << "," << X3 << "," << Y3 << "," << - X4 << "," << Y4 << ")" << endl; -#endif - - return Standard_False; -} - -void MFT_TextManager::ClosePath() { -#if TRACE > 0 - cout << " MFT_TextManager::ClosePath()" << endl; -#endif -} - -Standard_Boolean MFT_TextManager::EndChar(const Standard_Real X, const Standard_Real Y) { -#if TRACE > 0 - cout << " MFT_TextManager::EndChar(" << X << "," << Y << ")" << endl; -#endif - theXmin = Min(theXmin,X); theXmax = Max(theXmax,X); - theYmin = Min(theYmin,Y); theYmax = Max(theYmax,Y); - return Standard_True; -} - -void MFT_TextManager::EndString() { -#if TRACE > 0 - cout << " MFT_TextManager::EndString()" << endl; -#endif -} - -void MFT_TextManager::MinMax(Quantity_Length& Xmin, Quantity_Length& Ymin, Quantity_Length& Xmax, Quantity_Length& Ymax) { - - Xmin = theXmin; - Ymin = theYmin; - Xmax = theXmax; - Ymax = theYmax; -#if TRACE > 0 - cout << " MFT_TextManager::MinMax(" << theXmin << "," << theYmin << - "," << theXmax << "," << theYmax << ")" << endl; -#endif - theXmin = theYmin = theXmax = theYmax = 0.; -} - -Standard_CString MFT_TextManager::Encoding() { - - return theEncoding.ToCString(); -} diff --git a/src/MFT/MFT_WOKSteps.edl b/src/MFT/MFT_WOKSteps.edl deleted file mode 100755 index 7d09b4004d..0000000000 --- a/src/MFT/MFT_WOKSteps.edl +++ /dev/null @@ -1,24 +0,0 @@ --- Created by: bgn - Creation - 21-04-98 --- Copyright (c) 1999-2012 OPEN CASCADE SAS --- --- The content of this file is subject to the Open CASCADE Technology Public --- License Version 6.5 (the "License"). You may not use the content of this file --- except in compliance with the License. Please obtain a copy of the License --- at http://www.opencascade.org and read it completely before using this file. --- --- The Initial Developer of the Original Code is Open CASCADE S.A.S., having its --- main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. --- --- The Original Code and all software distributed under the License is --- distributed on an "AS IS" basis, without warranty of any kind, and the --- Initial Developer hereby disclaims all such warranties, including without --- limitation, any warranties of merchantability, fitness for a particular --- purpose or non-infringement. Please see the License for the specific terms --- and conditions governing the rights and limitations under the License. - - -@if ( %Station == "wnt" ) then - @set %WOKSteps_UseSourceInclude = ""; -@endif; - - diff --git a/src/OS/Visualization.tcl b/src/OS/Visualization.tcl index a34ff23b5c..c80d34df50 100755 --- a/src/OS/Visualization.tcl +++ b/src/OS/Visualization.tcl @@ -20,7 +20,6 @@ ;# proc Visualization:toolkits { } { return [list TKService \ - TKV2d \ TKV3d \ TKOpenGl \ TKMeshVS \ @@ -33,7 +32,6 @@ proc Visualization:toolkits { } { ;# proc Visualization:ressources { } { return [list \ - [list both r FontMFT {}] \ [list both r Textures {}] \ ] } diff --git a/src/PS/FILES b/src/PS/FILES deleted file mode 100755 index 16f4be4ef6..0000000000 --- a/src/PS/FILES +++ /dev/null @@ -1,2 +0,0 @@ -PS.edl -PS_CMPLRS.edl diff --git a/src/PS/PS.cdl b/src/PS/PS.cdl deleted file mode 100755 index 9fe0c13d48..0000000000 --- a/src/PS/PS.cdl +++ /dev/null @@ -1,37 +0,0 @@ --- Created on: 1994-02-22 --- Created by: Jean Louis FRENKEL --- Copyright (c) 1994-1999 Matra Datavision --- Copyright (c) 1999-2012 OPEN CASCADE SAS --- --- The content of this file is subject to the Open CASCADE Technology Public --- License Version 6.5 (the "License"). You may not use the content of this file --- except in compliance with the License. Please obtain a copy of the License --- at http://www.opencascade.org and read it completely before using this file. --- --- The Initial Developer of the Original Code is Open CASCADE S.A.S., having its --- main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. --- --- The Original Code and all software distributed under the License is --- distributed on an "AS IS" basis, without warranty of any kind, and the --- Initial Developer hereby disclaims all such warranties, including without --- limitation, any warranties of merchantability, fitness for a particular --- purpose or non-infringement. Please see the License for the specific terms --- and conditions governing the rights and limitations under the License. - - -package PS - -uses - Aspect, - PlotMgt, - TCollection, - Quantity, - TShort, - MFT - -is - class Driver; - ---Purpose: Creates the PS driver. - ---Category: Classes - -end PS; diff --git a/src/PS/PS.edl b/src/PS/PS.edl deleted file mode 100755 index 23d154cbf0..0000000000 --- a/src/PS/PS.edl +++ /dev/null @@ -1,24 +0,0 @@ --- Created on: 1996-10-03 --- Created by: Jean GAUTIER --- Copyright (c) 1996-1999 Matra Datavision --- Copyright (c) 1999-2012 OPEN CASCADE SAS --- --- The content of this file is subject to the Open CASCADE Technology Public --- License Version 6.5 (the "License"). You may not use the content of this file --- except in compliance with the License. Please obtain a copy of the License --- at http://www.opencascade.org and read it completely before using this file. --- --- The Initial Developer of the Original Code is Open CASCADE S.A.S., having its --- main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. --- --- The Original Code and all software distributed under the License is --- distributed on an "AS IS" basis, without warranty of any kind, and the --- Initial Developer hereby disclaims all such warranties, including without --- limitation, any warranties of merchantability, fitness for a particular --- purpose or non-infringement. Please see the License for the specific terms --- and conditions governing the rights and limitations under the License. - - -@ifnotdefined ( %PS_EDL) then - @set %PS_EDL = ""; -@endif; diff --git a/src/PS/PS_CMPLRS.edl b/src/PS/PS_CMPLRS.edl deleted file mode 100755 index 553b5a36d1..0000000000 --- a/src/PS/PS_CMPLRS.edl +++ /dev/null @@ -1,42 +0,0 @@ --- Created on: 1996-10-03 --- Created by: Jean GAUTIER --- Copyright (c) 1996-1999 Matra Datavision --- Copyright (c) 1999-2012 OPEN CASCADE SAS --- --- The content of this file is subject to the Open CASCADE Technology Public --- License Version 6.5 (the "License"). You may not use the content of this file --- except in compliance with the License. Please obtain a copy of the License --- at http://www.opencascade.org and read it completely before using this file. --- --- The Initial Developer of the Original Code is Open CASCADE S.A.S., having its --- main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. --- --- The Original Code and all software distributed under the License is --- distributed on an "AS IS" basis, without warranty of any kind, and the --- Initial Developer hereby disclaims all such warranties, including without --- limitation, any warranties of merchantability, fitness for a particular --- purpose or non-infringement. Please see the License for the specific terms --- and conditions governing the rights and limitations under the License. - - -@ifnotdefined ( %PS_CMPLRS_EDL) then - @set %PS_CMPLRS_EDL = ""; - @uses "CSF.edl" ; - - --@uses "PS.edl"; - - @string %CMPLRS_C_Options = %CMPLRS_C_Options " " %CSF_X11_INCLUDE ; - @string %CMPLRS_CXX_Options = %CMPLRS_CXX_Options " " %CSF_X11_INCLUDE ; - - @if ( %Station == "sil" ) then - @string %CMPLRS_C_Options = %CMPLRS_C_Options " -D_NO_PROTO"; - @endif; - - @if ( %Station == "ao1" ) then - @string %CMPLRS_C_Options = %CMPLRS_C_Options " -std1"; - @endif; - - @if ( %Station == "hp" ) then - @string %CMPLRS_C_Options = %CMPLRS_C_Options " -Ac -D_NO_PROTO"; - @endif; -@endif; diff --git a/src/PS/PS_Driver.cdl b/src/PS/PS_Driver.cdl deleted file mode 100755 index 3cba403143..0000000000 --- a/src/PS/PS_Driver.cdl +++ /dev/null @@ -1,291 +0,0 @@ --- Created on: 1994-02-22 --- Created by: Jean Louis FRENKEL --- Copyright (c) 1994-1999 Matra Datavision --- Copyright (c) 1999-2012 OPEN CASCADE SAS --- --- The content of this file is subject to the Open CASCADE Technology Public --- License Version 6.5 (the "License"). You may not use the content of this file --- except in compliance with the License. Please obtain a copy of the License --- at http://www.opencascade.org and read it completely before using this file. --- --- The Initial Developer of the Original Code is Open CASCADE S.A.S., having its --- main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. --- --- The Original Code and all software distributed under the License is --- distributed on an "AS IS" basis, without warranty of any kind, and the --- Initial Developer hereby disclaims all such warranties, including without --- limitation, any warranties of merchantability, fitness for a particular --- purpose or non-infringement. Please see the License for the specific terms --- and conditions governing the rights and limitations under the License. - - -class Driver from PS inherits PlotterDriver from PlotMgt - ---Purpose: This class defines a PS (Adobe PostScript) plotter Driver. - --- All necessary information about methods (purpose, level, category, etc.) - --- can be found in CDL files from the inheritance tree (PlotMgt_PlotterDriver, - --- Aspect_Driver). - - -uses - Plotter from PlotMgt, - TypeOfColorSpace from Aspect, - FormatOfSheetPaper from Aspect, - ExtendedString from TCollection, - AsciiString from TCollection, - ColorMap from Aspect, - TypeMap from Aspect, - WidthMap from Aspect, - FontMap from Aspect, - MarkMap from Aspect, - TypeOfText from Aspect, - TypeOfPrimitive from Aspect, - PlaneAngle from Quantity, - Length from Quantity, - Factor from Quantity, - Ratio from Quantity - - -raises - DriverError from Aspect - - -is - Create(aName: CString from Standard; - aDX,aDY: Length from Quantity; - aTypeOfColorSpace: TypeOfColorSpace from Aspect = Aspect_TOCS_RGB; - aSheetFormat: FormatOfSheetPaper from Aspect = Aspect_FOSP_A4) - returns mutable Driver from PS; - - - Create(aPlotter : Plotter from PlotMgt; - aName: CString from Standard; - aPaperX,aPaperY: Length from Quantity; - aTypeOfColorSpace: TypeOfColorSpace from Aspect = Aspect_TOCS_RGB) - returns mutable Driver from PS; ----Purpose: Constructs a file called aName as the graphic --- plotter file. The parameters of the plotter aPlotter --- are taken into account for defining this plotter file. --- aPaperX,aPaperY defines the size of the --- sheet-paper and the value of aTypeOfColorSpace --- defines the mode for processing colors. - - BeginFile(me: mutable; - aPlotter : Plotter from PlotMgt; - aName: CString from Standard; - aDX,aDY: Length from Quantity; - aTypeOfColorSpace: TypeOfColorSpace from Aspect; - aPaperX,aPaperY: Length from Quantity) - is private; - - BeginDraw (me: mutable) is static; - ----Purpose: --- Begins a new page of graphics in the plotter file called "aName". - EndDraw (me: mutable; dontFlush: Boolean = Standard_False) is static; - - - --------------------------------------------- - -- Category: Methods to define the attributes - --------------------------------------------- - InitializeColorMap(me: mutable; aColorMap: ColorMap from Aspect) - is virtual protected; - - - InitializeTypeMap(me: mutable; aTypeMap: TypeMap from Aspect) - is virtual protected; - - - InitializeWidthMap(me: mutable; aWidthMap: WidthMap from Aspect) - is virtual protected; - - - InitializeFontMap(me: mutable; aFontMap: FontMap from Aspect) - is virtual protected; - - - InitializeMarkMap(me: mutable; aFontMap: MarkMap from Aspect) - is virtual protected; - - - --------------------------------------------- - -- Category: Methods to set the attributes - --------------------------------------------- - SetTextAttrib (me: mutable; - ColorIndex: Integer from Standard; - FontIndex: Integer from Standard) - is redefined; - - - SetTextAttrib (me: mutable; - ColorIndex: Integer from Standard; - FontIndex: Integer from Standard; - aSlant: PlaneAngle from Quantity; - aHScale: Factor from Quantity; - aWScale: Factor from Quantity; - isUnderlined: Boolean from Standard = Standard_False) - is redefined; - - - -------------------------------- - -- Actual set graphic attributes - -------------------------------- - PlotLineAttrib (me: mutable; - ColorIndex: Integer from Standard; - TypeIndex: Integer from Standard; - WidthIndex: Integer from Standard) - is redefined protected; - - - ----------------------------------------- - -- Category: Methods to manage the images - ----------------------------------------- - SizeOfImageFile (me; anImageFile: CString from Standard; - aWidth,aHeight: out Integer from Standard) - returns Boolean from Standard is redefined; - - - ----------------------------------------------- - -- Category: Private methods to draw primitives - ----------------------------------------------- - PlotPoint (me : mutable; X, Y: ShortReal from Standard) - returns Boolean from Standard - is redefined protected; - - - PlotSegment (me : mutable; - X1, Y1: ShortReal from Standard; - X2, Y2: ShortReal from Standard) - returns Boolean from Standard - is redefined protected; - - - PlotPolyline (me : mutable; - xArray : Address from Standard; - yArray : Address from Standard; - nPts : Address from Standard; - nParts : Integer from Standard) - returns Boolean from Standard - is redefined protected; - - - PlotPolygon (me : mutable; - xArray : Address from Standard; - yArray : Address from Standard; - nPts : Address from Standard; - nParts : Integer from Standard) - returns Boolean from Standard - is redefined protected; - - - PlotArc (me : mutable; X,Y : ShortReal from Standard; - anXradius,anYradius : ShortReal from Standard; - sAngle: ShortReal from Standard; - oAngle: ShortReal from Standard) - returns Boolean from Standard - is redefined protected; - - - PlotPolyArc (me : mutable; X,Y : ShortReal from Standard; - anXradius,anYradius : ShortReal from Standard; - sAngle: ShortReal from Standard; - oAngle: ShortReal from Standard) - returns Boolean from Standard - is redefined protected; - - - PlotMarker (me : mutable; - aMarker: Integer from Standard; - Xpos: ShortReal from Standard; - Ypos: ShortReal from Standard; - Width: ShortReal from Standard; - Height: ShortReal from Standard; - Angle: ShortReal from Standard) - returns Boolean from Standard - is redefined protected; - - - PlotText (me : mutable; - aText: ExtendedString from TCollection; - Xpos: ShortReal from Standard; - Ypos: ShortReal from Standard; - anAngle: ShortReal from Standard; - aType: TypeOfText from Aspect) - returns Boolean from Standard - is redefined protected; - - - PlotText (me : mutable; - aText: CString from Standard; - Xpos: ShortReal from Standard; - Ypos: ShortReal from Standard; - anAngle: ShortReal from Standard; - aType: TypeOfText from Aspect) - returns Boolean from Standard - is redefined protected; - - - PlotPolyText (me : mutable; - aText: ExtendedString from TCollection; - Xpos: ShortReal from Standard; - Ypos: ShortReal from Standard; - aMargin: Ratio from Quantity; - anAngle: ShortReal from Standard; - aType: TypeOfText from Aspect) - returns Boolean from Standard - is redefined protected; - - - PlotPolyText (me : mutable; - aText: CString from Standard; - Xpos: ShortReal from Standard; - Ypos: ShortReal from Standard; - aMargin: Ratio from Quantity; - anAngle: ShortReal from Standard; - aType: TypeOfText from Aspect) - returns Boolean from Standard - is redefined protected; - - - PlotImage (me: mutable; - aX, aY, aWidth: ShortReal from Standard; - aHeight, aScale: ShortReal from Standard; - anImageFile: CString from Standard; - anArrayOfPixels: Address from Standard; - aLineIndex: Integer from Standard = -1) - returns Boolean from Standard - is redefined protected; - - - ---------------------------- - -- Category: Inquire methods - ---------------------------- - Convert(me; aShortReal: ShortReal from Standard) - returns ShortReal from Standard is static private; ----Purpose: For this driver --- - returns the DPU (device plotter unit) value --- corresponding to the number of pixels PV, or --- - returns the number of pixels corresponding to the DPU value DV, or --- - returns the DPU coordinates (DX,DY) --- corresponding to the pixel position (PX,PY), or --- - returns the pixel position (PX,PY) corresponding to --- the DPU coordinates (DX,DY). --- The DPU value is specified in millimeters by default. --- Warning --- The pixel size is 325mm/1152 by default and can be --- changed with the SetPixelSize function. - - DrawCurveCapable (me) - returns Boolean from Standard is redefined protected; - - MapX(me; aShortReal: ShortReal from Standard) - returns ShortReal from Standard is redefined private; - - - MapY(me; aShortReal: ShortReal from Standard) - returns ShortReal from Standard is redefined private; - - -fields - myCurrentPage: Integer from Standard; - -end Driver from PS; diff --git a/src/PS/PS_Driver.cxx b/src/PS/PS_Driver.cxx deleted file mode 100755 index e7d4e0233c..0000000000 --- a/src/PS/PS_Driver.cxx +++ /dev/null @@ -1,1281 +0,0 @@ -// Copyright (c) 1995-1999 Matra Datavision -// Copyright (c) 1999-2012 OPEN CASCADE SAS -// -// The content of this file is subject to the Open CASCADE Technology Public -// License Version 6.5 (the "License"). You may not use the content of this file -// except in compliance with the License. Please obtain a copy of the License -// at http://www.opencascade.org and read it completely before using this file. -// -// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its -// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. -// -// The Original Code and all software distributed under the License is -// distributed on an "AS IS" basis, without warranty of any kind, and the -// Initial Developer hereby disclaims all such warranties, including without -// limitation, any warranties of merchantability, fitness for a particular -// purpose or non-infringement. Please see the License for the specific terms -// and conditions governing the rights and limitations under the License. - -#define PRO7689 //GG_300597 -// La hauteur des caracteres avec CapsHeight TRUE doit etre -// relative a la hauteur de la lettre H et non pas -// la hauteur max de la police. - -#define MFT //GG_MFT Etude G1343 -// Utilisation du FontManager MFT permettant de traiter -// les chaines de caracteres EUCLID3 orientees et slantees. - -#define PRO8709 //GG_170697 -// Les textes encadres ou caches ne fonctionnent pas en mode -// NOIR & BLANC - -#define CTS17946//GG_030797/GG_300698 -// En mode NOIR et BLANC,ne pas remplir les polygones. -// dans la couleur du fond. - -#define CTS18150//GG_210797 -// Parametrer le format papier de maniere a reduire -// automatiquement l'echelle lorsque le format du dessin -// est plus grand. - -#define PRO11339 //GG_260398 -// Ne pas arrondir l'epaisseur du trait - -#define JAP60166 //GG_180698 -// Les polygones sont transparents alors qu'il devraient -// etres remplis. -// Traitement des niveaux de gris. - -#define S3602 //SYL_170898 -// Constructeur avec Format du papier en DX,DY ou FOSP -// Prise en compte de la marge papier -//#define PRO15090 //SYL_040998 annulle le 170998 suite a debug de GG (PRO15231) -// Utiliser toujours les polices MFT pour etre sur d'etre wysywig en ettendant de maitriser -// l'echelle -#define PRO15119 //SYL_040998 -// En monochrome, on force les couleurs au noir tout en permettant le -// trace avec le fond blanc => le cache fonctionne - -#define PRO15784 // SYL 19101998 les textes cachants ne doivent pas toujours etre encadres -#define PRO15786 // SYL 19101998 erreur setdash sur osf seulement !! - -#define BUC60766 // GG 300399 -// Ascendante compatibillity using OLD driver constructor -// must generates directly a file. -// Re Enable to draw PostScript string when it's requested - -#define BUC60772 //GG_061100 Round off vectors intersection -// angle during MFT drawing with PostScript driver. - -#define CSR862 // GG_101100 -// Enable to draw full drawing after rotation and auto scaling. - -#define MOVETO "M " -#define RMOVETO "RM " -#define LINETO "L " -#define CURVETO "CT " -#define RLINETO "RL " -#define ARC "A " -#define ARCN "AN " -#define STROKE "ST " -#define FILL "F " -#define SHOW "SH " -#define GSAVE "GS " -#define GRESTORE "GR " -#define ROTATE "R " -#define SCALE "SC " -#define CHARPATH "CHP " -#define CLOSEPATH "CLP " -#define NEWPATH "NP " -#define SHOWHIDINGTEXT "ShowHidingText " -#define SHOWFRAMEDTEXT "ShowFramedText " -#define SHOWUNDERLINEDTEXT "ShowUnderlinedText " -#define FILLRECTANGLE "FillRectangle " -#define DRAWRECTANGLE "DrawRectangle " -#define UNDERLINE "UnderLine " -#define SCALEDRAWING "ScaleDrawing " -#define SCALEFONT "ScaleFont " -static const char* MONTHS [] = { - "January", "February", "March", - "April", "May", "June", "July", - "August", "September", "October", - "November", "December" -}; - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -static Handle(Image_Image) myImage; -#ifdef WNT -#pragma warning (disable : 4244 4018 4101) -#endif - -#define MAXPOINT 1024 -#define DRAD (3.1415927/180.) -#define PPI 72./(0.0254005 METER) -#define IMAGEBUFFERSIZE 48 -#define DEFPLOTTER "DIRECT_PS" - -#define PLOT_PCOLOR(aCol) \ - if (myColorIndex != (aCol)) { \ - myColorIndex = (aCol); \ - if (myColorIndex > 0) \ - (*Cout()) << " C" << myColorIndex << " "; \ - else \ - (*Cout()) << " CB "; \ - } - -//========================================================================== -PS_Driver::PS_Driver(const Handle(PlotMgt_Plotter)& aPlotter, - const Standard_CString aName, - const Quantity_Length aPaperX, - const Quantity_Length aPaperY, - const Aspect_TypeOfColorSpace aTypeOfColorSpace) - : PlotMgt_PlotterDriver (aPlotter, aName, Standard_True) -{ - BeginFile( aPlotter,aName,aPaperX,aPaperY,aTypeOfColorSpace,aPaperX,aPaperY); -} - -//========================================================================== -PS_Driver::PS_Driver(const Standard_CString aName, - const Quantity_Length aDX, - const Quantity_Length aDY, - const Aspect_TypeOfColorSpace aTypeOfColorSpace, - const Aspect_FormatOfSheetPaper aSheetFormat) - : PlotMgt_PlotterDriver (aName, Standard_True) -{ - Quantity_Length thePaperWidth,thePaperHeight; - Aspect::ValuesOfFOSP(aSheetFormat,thePaperWidth,thePaperHeight); -#ifndef BUC60766 - Handle(PlotMgt_Plotter) thePlotter = new PlotMgt_Plotter(TCollection_AsciiString(DEFPLOTTER)); -#else - Handle(PlotMgt_Plotter) thePlotter = new PlotMgt_Plotter(TCollection_AsciiString(DEFPLOTTER),Standard_True); -#endif - SetPlotter (thePlotter); - BeginFile (thePlotter,aName,aDX,aDY,aTypeOfColorSpace,thePaperWidth,thePaperHeight); -} - -//========================================================================== -void PS_Driver::BeginFile(const Handle(PlotMgt_Plotter)& aPlotter, - const Standard_CString aName, - const Quantity_Length aDX, - const Quantity_Length aDY, - const Aspect_TypeOfColorSpace aTypeOfColorSpace, - const Quantity_Length thePaperWidth, - const Quantity_Length thePaperHeight) -{ - OSD_Process P; - Quantity_Date Date = P.SystemDate(); - - myTypeOfColorSpace = aTypeOfColorSpace; - - // define the real workspace, usefull for mapping by the user of the driver - // before sending the objects to plot (V2d_View) - myWidth = Standard_ShortReal(aDX - 2*myPaperMargin); - myHeight = Standard_ShortReal(aDY - 2*myPaperMargin); - - (*Cout()) << "%!PS-Adobe-" << endl; - (*Cout()) << "%%Title: " << aName << endl; - (*Cout()) << "%%Creator: " << P.UserName() << endl; - (*Cout()) << "%%CreationDate: " << MONTHS[Date.Month()-1] << " " - << Date.Day() << " " << Date.Year() << " " << Date.Hour() - << ":" << Date.Minute() << ":" << Date.Second() << endl; - (*Cout()) << "%%BeginProlog" << endl; - (*Cout()) << "%%EndProlog" << endl; - (*Cout()) << "%%BeginSetup" << endl; - (*Cout()) << "/Centimeter {" << PPI CENTIMETER << " mul} def" << endl; - (*Cout()) << "/Inch {72 mul} def" << endl; - (*Cout()) << "/PaperWidth " << TOCENTIMETER(thePaperHeight) << " Centimeter def" << endl; - (*Cout()) << "/PaperHeight " << TOCENTIMETER(thePaperWidth ) << " Centimeter def" << endl; - (*Cout()) << "/PaperMargin " << TOCENTIMETER(myPaperMargin ) << " Centimeter def" << endl; - (*Cout()) << "/PaperRotateIfPossible true def" << endl; - (*Cout()) << "/BD {bind def} bind def" << endl; - (*Cout()) << "/IB " << IMAGEBUFFERSIZE << " string def" << endl; - (*Cout()) << "/" << MOVETO << "{moveto} BD" << endl; - (*Cout()) << "/" << RMOVETO << "{rmoveto} BD" << endl; - (*Cout()) << "/" << LINETO << "{lineto} BD" << endl; - (*Cout()) << "/" << RLINETO << "{rlineto} BD" << endl; - (*Cout()) << "/" << CURVETO << "{curveto} BD" << endl; - (*Cout()) << "/" << ARC << "{arc} BD" << endl; - (*Cout()) << "/" << ARCN << "{arcn} BD" << endl; - (*Cout()) << "/" << STROKE << "{stroke} BD" << endl; - (*Cout()) << "/" << FILL << "{fill} BD" << endl; - (*Cout()) << "/" << SHOW << "{show} BD" << endl; - (*Cout()) << "/" << ROTATE << "{rotate} BD" << endl; - (*Cout()) << "/" << SCALE << "{scale} BD" << endl; - (*Cout()) << "/" << GSAVE << "{gsave} BD" << endl; - (*Cout()) << "/" << GRESTORE << "{grestore} BD" << endl; - (*Cout()) << "/" << CHARPATH << "{charpath} BD" << endl; - (*Cout()) << "/" << CLOSEPATH << "{closepath} BD" << endl; - (*Cout()) << "/" << NEWPATH << "{newpath} BD" << endl; - (*Cout()) << "/" << UNDERLINE << "{" << endl; - (*Cout()) << "% Compute underline position depending of the baseline position" << endl; - (*Cout()) << " /size exch def" << endl; - (*Cout()) << " currentfont /FontBBox known {" << endl; - (*Cout()) << " currentfont /FontBBox get dup" << endl; - (*Cout()) << " 1 get /ymin exch def" << endl; - (*Cout()) << " 3 get /ymax exch def" << endl; - (*Cout()) << " ymin ymax ymin sub div 0.6 mul size mul" << endl; - (*Cout()) << " } { " << endl; - (*Cout()) << " ymax ymin sub 8 div size mul neg" << endl; - (*Cout()) << " } ifelse" << endl; - (*Cout()) << "} bind def" << endl; - (*Cout()) << "/" << FILLRECTANGLE << "{" << endl; - (*Cout()) << " /rxmin exch def % lower-left corner" << endl; - (*Cout()) << " /rymin exch def % lower-left corner" << endl; - (*Cout()) << " /rwidth exch def % rect width" << endl; - (*Cout()) << " /rheight exch def % rect height" << endl; - (*Cout()) << " /orientation exch def % text angle" << endl; - (*Cout()) << " /framedattrib exch def % framed attrib" << endl; - (*Cout()) << " /hidingattrib exch def % hiding background attrib" << endl; - (*Cout()) << " gsave % get text bounding box" << endl; - (*Cout()) << " currentpoint /y exch def /x exch def % get current position" << endl; - (*Cout()) << " orientation rotate % rotate the text" << endl; - (*Cout()) << " hidingattrib cvx exec % draw hiding bounding box" << endl; - (*Cout()) << " rxmin rymin rmoveto 0 rheight rlineto rwidth 0 rlineto" << endl; - (*Cout()) << " 0 rheight neg rlineto rwidth neg 0 rlineto closepath fill" << endl; - (*Cout()) << " x y moveto framedattrib cvx exec % draw framed bounding box" << endl; - (*Cout()) << " rxmin rymin rmoveto 0 rheight rlineto rwidth 0 rlineto" << endl; - (*Cout()) << " 0 rheight neg rlineto rwidth neg 0 rlineto stroke" << endl; - (*Cout()) << " grestore" << endl; - (*Cout()) << "} bind def" << endl; - (*Cout()) << "/" << DRAWRECTANGLE << "{" << endl; - (*Cout()) << " /rxmin exch def % lower-left corner" << endl; - (*Cout()) << " /rymin exch def % lower-left corner" << endl; - (*Cout()) << " /rwidth exch def % rect width" << endl; - (*Cout()) << " /rheight exch def % rect height" << endl; - (*Cout()) << " /orientation exch def % text angle" << endl; - (*Cout()) << " /framedattrib exch def % framed attrib" << endl; - (*Cout()) << " gsave % get text bounding box" << endl; - (*Cout()) << " orientation rotate % rotate the text" << endl; - (*Cout()) << " framedattrib cvx exec % draw framed bounding box" << endl; - (*Cout()) << " rxmin rymin rmoveto 0 rheight rlineto rwidth 0 rlineto" << endl; - (*Cout()) << " 0 rheight neg rlineto rwidth neg 0 rlineto stroke" << endl; - (*Cout()) << " grestore" << endl; - (*Cout()) << "} bind def" << endl; - (*Cout()) << "/" << SHOWHIDINGTEXT << "{" << endl; - (*Cout()) << " /textstring exch def % text to edit" << endl; - (*Cout()) << " /isunderlined exch def % underline text flag" << endl; - (*Cout()) << " /textangle exch def % text angle" << endl; - (*Cout()) << " /textmargin exch def % text margin" << endl; - (*Cout()) << " /textattrib exch def % text attrib" << endl; - (*Cout()) << " /fontsize exch def % font size" << endl; - (*Cout()) << " /hidingattrib exch def % hiding background attrib" << endl; - (*Cout()) << " /framedattrib exch def % framed attrib" << endl; - (*Cout()) << " gsave" << endl; - (*Cout()) << " gsave % get text bounding box" << endl; - (*Cout()) << " 0 0 moveto" << endl; - (*Cout()) << " textstring false charpath pathbbox" << endl; - (*Cout()) << " /tymax exch def /txmax exch def /tymin exch def /txmin exch def" << endl; - (*Cout()) << " grestore" << endl; - - (*Cout()) << " /twidth txmax txmin sub def % set text width" << endl; - (*Cout()) << " /theight tymax tymin sub def % set text height" << endl; - (*Cout()) << " isunderlined { % adjust underline space" << endl; - (*Cout()) << " /umargin fontsize UnderLine def" << endl; - (*Cout()) << " umargin tymin lt {" << endl; - (*Cout()) << " /tymin umargin def" << endl; - (*Cout()) << " /theight tymax tymin sub def" << endl; - (*Cout()) << " } if" << endl; - (*Cout()) << " } if" << endl; - - (*Cout()) << " /hmargin textmargin theight mul def" << endl; - (*Cout()) << " /hxmin txmin hmargin sub def" << endl; - (*Cout()) << " /hymin tymin hmargin sub def" << endl; - (*Cout()) << " /hxmax txmax hmargin add def" << endl; - (*Cout()) << " /hymax tymax hmargin add def" << endl; - (*Cout()) << " /hwidth hxmax hxmin sub def % set hiding width" << endl; - (*Cout()) << " /hheight hymax hymin sub def % set hiding height" << endl; - - (*Cout()) << " hidingattrib framedattrib textangle hheight hwidth hymin hxmin FillRectangle" << endl; - (*Cout()) << " textangle rotate % rotate the text" << endl; - (*Cout()) << " currentpoint /ytext exch def /xtext exch def % get text position" << endl; - (*Cout()) << " textstring textattrib cvx exec % draw text" << endl; - (*Cout()) << " isunderlined {" << endl; - (*Cout()) << " theight 32 div setlinewidth" << endl; - (*Cout()) << " xtext ytext moveto 0 umargin rmoveto twidth 0 rlineto stroke % draw underline" << endl; - (*Cout()) << " } if" << endl; - - (*Cout()) << " grestore" << endl; - (*Cout()) << "} bind def" << endl; - - (*Cout()) << "/" << SHOWFRAMEDTEXT << "{" << endl; - (*Cout()) << " /textstring exch def % text to edit" << endl; - (*Cout()) << " /isunderlined exch def % underline text flag" << endl; - (*Cout()) << " /textangle exch def % text angle" << endl; - (*Cout()) << " /textmargin exch def % text margin" << endl; - (*Cout()) << " /textattrib exch def % text attrib" << endl; - (*Cout()) << " /fontsize exch def % font size" << endl; - (*Cout()) << " /framedattrib exch def % framed attrib" << endl; - (*Cout()) << " gsave" << endl; - (*Cout()) << " gsave % get text bounding box" << endl; - (*Cout()) << " 0 0 moveto" << endl; - (*Cout()) << " textstring false charpath pathbbox" << endl; - (*Cout()) << " /tymax exch def /txmax exch def /tymin exch def /txmin exch def" << endl; - (*Cout()) << " grestore" << endl; - - (*Cout()) << " /twidth txmax txmin sub def % set text width" << endl; - (*Cout()) << " /theight tymax tymin sub def % set text height" << endl; - (*Cout()) << " isunderlined { % adjust underline space" << endl; - (*Cout()) << " /umargin fontsize UnderLine def" << endl; - (*Cout()) << " umargin tymin lt {" << endl; - (*Cout()) << " /tymin umargin def" << endl; - (*Cout()) << " /theight tymax tymin sub def" << endl; - (*Cout()) << " } if" << endl; - (*Cout()) << " } if" << endl; - - (*Cout()) << " /hmargin textmargin theight mul def" << endl; - (*Cout()) << " /hxmin txmin hmargin sub def" << endl; - (*Cout()) << " /hymin tymin hmargin sub def" << endl; - (*Cout()) << " /hxmax txmax hmargin add def" << endl; - (*Cout()) << " /hymax tymax hmargin add def" << endl; - (*Cout()) << " /hwidth hxmax hxmin sub def % set framed width" << endl; - (*Cout()) << " /hheight hymax hymin sub def % set framed height" << endl; - - (*Cout()) << " framedattrib textangle hheight hwidth hymin hxmin DrawRectangle" << endl; - (*Cout()) << " currentpoint /ytext exch def /xtext exch def % get text position" << endl; - (*Cout()) << " textangle rotate % rotate the text" << endl; - (*Cout()) << " textstring textattrib cvx exec % draw text" << endl; - (*Cout()) << " isunderlined {" << endl; - (*Cout()) << " theight 32 div setlinewidth" << endl; - (*Cout()) << " xtext ytext moveto 0 umargin rmoveto twidth 0 rlineto stroke % draw underline" << endl; - (*Cout()) << " } if" << endl; - - (*Cout()) << " grestore" << endl; - (*Cout()) << "} bind def" << endl; - - (*Cout()) << "/" << SHOWUNDERLINEDTEXT << "{" << endl; - (*Cout()) << " /textstring exch def % text to edit" << endl; - (*Cout()) << " /textangle exch def % text angle" << endl; - (*Cout()) << " /textattrib exch def % text attrib" << endl; - (*Cout()) << " /fontsize exch def % font size" << endl; - (*Cout()) << " gsave" << endl; - (*Cout()) << " gsave % get text bounding box" << endl; - (*Cout()) << " 0 0 moveto" << endl; - (*Cout()) << " textstring false charpath pathbbox" << endl; - (*Cout()) << " /tymax exch def /txmax exch def /tymin exch def /txmin exch def" << endl; - (*Cout()) << " grestore" << endl; - - (*Cout()) << " /twidth txmax txmin sub def % set text width" << endl; - (*Cout()) << " /theight tymax tymin sub def % set text height" << endl; - (*Cout()) << " /umargin fontsize UnderLine def" << endl; - - (*Cout()) << " textangle rotate % rotate the text" << endl; - (*Cout()) << " currentpoint /ytext exch def /xtext exch def % get text position" << endl; - (*Cout()) << " theight 32 div setlinewidth" << endl; - (*Cout()) << " textstring textattrib cvx exec % draw text" << endl; - (*Cout()) << " xtext ytext moveto 0 umargin rmoveto twidth 0 rlineto stroke % draw underline" << endl; - - (*Cout()) << " grestore" << endl; - (*Cout()) << "} bind def" << endl; - (*Cout()) << "/" << SCALEFONT << "{" << endl; - (*Cout()) << "% Adjust font scale depending of the baseline position" << endl; - (*Cout()) << " /size exch def" << endl; - (*Cout()) << " /ratio 1. def" << endl; - (*Cout()) << " currentfont /FontBBox known {" << endl; - (*Cout()) << " currentfont /FontBBox get dup" << endl; - (*Cout()) << " 1 get /ymin exch def" << endl; - (*Cout()) << " 3 get /ymax exch def" << endl; - (*Cout()) << " ymax ymin sub ymax div /ratio exch def" << endl; - - (*Cout()) << " 0 0 moveto" << endl; - (*Cout()) << " (H) false charpath pathbbox /hmax exch def" << endl; - (*Cout()) << " 0 0 moveto" << endl; - (*Cout()) << " ($) false charpath pathbbox /dmax exch def" << endl; - (*Cout()) << " ratio hmax mul dmax div /ratio exch def" << endl; - - (*Cout()) << " } if" << endl; - (*Cout()) << " currentfont ratio size mul scalefont setfont" << endl; - (*Cout()) << "} bind def" << endl; - (*Cout()) << "/" << SCALEDRAWING << "{" << endl; - (*Cout()) << "% Adjust drawing size depending of paper size" << endl; - (*Cout()) << " /DrawHeight exch Centimeter def" << endl; - (*Cout()) << " /DrawWidth exch Centimeter def" << endl; - (*Cout()) << " /DrawScale 1 def" << endl; - (*Cout()) << " /NewPaperMargin PaperMargin def" << endl; -#ifdef CSR862 - (*Cout()) << " /NewDrawWidth DrawWidth def" << endl; - (*Cout()) << " /NewDrawHeight DrawHeight def" << endl; -#else - (*Cout()) << " /NewDrawWidth DrawHeight def" << endl; - (*Cout()) << " /NewDrawHeight DrawWidth def" << endl; -#endif - (*Cout()) << " /NewPaperWidth PaperWidth 2 PaperMargin mul sub def" << endl; - (*Cout()) << " /NewPaperHeight PaperHeight 2 PaperMargin mul sub def" << endl; - (*Cout()) << " /Helvetica-BoldOblique findfont 10 scalefont setfont" << endl ; - (*Cout()) << " /Tampon 20 string def" << endl; - (*Cout()) << " DrawWidth DrawHeight gt PaperRotateIfPossible and {" << endl; - (*Cout()) << " NewDrawWidth NewPaperWidth gt {" << endl; - (*Cout()) << " /DrawScale NewPaperWidth NewDrawWidth div def" << endl; - (*Cout()) << " /NewDrawWidth NewDrawWidth DrawScale mul def" << endl; - (*Cout()) << " /NewDrawHeight NewDrawHeight DrawScale mul def" << endl; - (*Cout()) << " } if" << endl; - (*Cout()) << " NewDrawHeight NewPaperHeight gt {" << endl; - (*Cout()) << " /DrawScale NewPaperHeight NewDrawHeight div DrawScale mul def" << endl; - (*Cout()) << " /NewDrawWidth NewDrawWidth DrawScale mul def" << endl; - (*Cout()) << " /NewDrawHeight NewDrawHeight DrawScale mul def" << endl; - (*Cout()) << " } if" << endl; - (*Cout()) << " DrawScale 1. lt {" << endl; - (*Cout()) << " NewPaperMargin 0 M (Scale : ) show DrawScale Tampon cvs show" << endl; - (*Cout()) << " } if" << endl; -#ifdef CSR862 - (*Cout()) << " NewDrawWidth 2 div NewDrawHeight 2 div translate" << endl; -#else - (*Cout()) << " {" << endl; - (*Cout()) << " /NewPaperMargin PaperMargin def" << endl; - (*Cout()) << " /NewPaperWidth PaperWidth def" << endl; - (*Cout()) << " /NewPaperHeight PaperHeight def" << endl; - (*Cout()) << " } ifelse" << endl; -#endif - (*Cout()) << " 90 rotate" << endl; -#ifdef CSR862 - (*Cout()) << " NewDrawHeight neg 2 div NewPaperMargin add NewDrawWidth 2 div NewPaperHeight sub NewPaperMargin sub translate" << endl; -#else - (*Cout()) << " PaperMargin NewDrawWidth PaperMargin add neg translate" << endl; -#endif - (*Cout()) << " }{" << endl; -#ifdef CSR862 - (*Cout()) << " NewDrawWidth NewPaperHeight gt {" << endl; - (*Cout()) << " /DrawScale NewPaperHeight NewDrawWidth div def" << endl; -#else - (*Cout()) << " NewDrawHeight NewPaperHeight gt {" << endl; - (*Cout()) << " /DrawScale NewPaperHeight NewDrawHeight div def" << endl; -#endif - (*Cout()) << " /NewDrawWidth NewDrawWidth DrawScale mul def" << endl; - (*Cout()) << " /NewDrawHeight NewDrawHeight DrawScale mul def" << endl; - (*Cout()) << " } if" << endl; -#ifdef CSR862 - (*Cout()) << " NewDrawHeight NewPaperWidth gt {" << endl; - (*Cout()) << " /DrawScale NewPaperWidth NewDrawHeight div DrawScale mul def" << endl; -#else - (*Cout()) << " NewDrawWidth NewPaperWidth gt {" << endl; - (*Cout()) << " /DrawScale NewPaperWidth NewDrawWidth div DrawScale mul def" << endl; -#endif - (*Cout()) << " /NewDrawWidth NewDrawWidth DrawScale mul def" << endl; - (*Cout()) << " /NewDrawHeight NewDrawHeight DrawScale mul def" << endl; - (*Cout()) << " } if" << endl; - (*Cout()) << " DrawScale 1. lt {" << endl; - (*Cout()) << " NewPaperMargin 0 M (Scale : ) show DrawScale Tampon cvs show" << endl; - (*Cout()) << " } {" << endl; - (*Cout()) << " /NewPaperMargin PaperMargin def" << endl; - (*Cout()) << " /NewPaperWidth PaperWidth def" << endl; - (*Cout()) << " /NewPaperHeight PaperHeight def" << endl; - (*Cout()) << " } ifelse" << endl; - (*Cout()) << " NewPaperMargin NewPaperMargin translate" << endl; - (*Cout()) << " } ifelse" << endl; - (*Cout()) << "% set scale" << endl; - (*Cout()) << " DrawScale DrawScale scale" << endl; - (*Cout()) << "% Draw frame and set clip path" << endl; - (*Cout()) << " 0 0 M 0 DrawHeight L DrawWidth DrawHeight L DrawWidth 0 L 0 0 L ST" << endl; - (*Cout()) << " NP 0 0 M 0 DrawHeight L DrawWidth DrawHeight L DrawWidth 0 L 0 0 L CLP clip NP" << endl; -#ifdef BUC60772 - (*Cout()) << " 2 setlinejoin" << endl; -#endif - (*Cout()) << "} bind def" << endl; - - myCurrentPage = 0; -} - -//========================================================================== -void PS_Driver::BeginDraw () -{ - // Text management - myTextManager = new PlotMgt_TextManager(this); - if (myCurrentPage <= 0) { - (*Cout()) << "%%BeginSetup" << endl; - myCurrentPage = 1; - } - (*Cout()) << "%%Page: " << myCurrentPage << endl; - (*Cout()) << "GS " << TOCENTIMETER(myWidth) << " " - << TOCENTIMETER(myHeight) << " " << SCALEDRAWING << endl; -} - -//========================================================================== -void PS_Driver::EndDraw (const Standard_Boolean dontFlush) -{ - (*Cout ()) << " showpage" << endl; - (*Cout ()) << " GR" << endl; - if (!dontFlush) - (*Cout ()) << flush; - myCurrentPage++; - myImage.Nullify (); -} - -//========================================================================== -void PS_Driver::InitializeColorMap (const Handle(Aspect_ColorMap)& aColorMap) -{ - Standard_Real r,g,b; - Standard_Integer index,Size = aColorMap->Size(); - Aspect_ColorMapEntry entry ; - Quantity_Color color ; - - if (myTypeOfColorSpace == Aspect_TOCS_GreyScale) - (*Cout()) << "/CB {1 setgray} BD" << endl; - else - (*Cout()) << "/CB {1 1 1 setrgbcolor} BD" << endl; - - for (Standard_Integer i=1; i<= Size; i++) { - entry = aColorMap->Entry(i); - index = entry.Index(); - color = entry.Color(); - color.Values (r, g, b, Quantity_TOC_RGB); - if (myTypeOfColorSpace == Aspect_TOCS_GreyScale) - (*Cout()) << "/C" << index << " {" << (r + g + b)/3. << " setgray} BD" << endl; - else if (myTypeOfColorSpace == Aspect_TOCS_BlackAndWhite) - (*Cout()) << "/C" << index << " {0 0 0 setrgbcolor} BD" << endl; - else - (*Cout()) << "/C" << index << " {" << r << " " << g << " " - << b << " setrgbcolor} BD" << endl; - } - if (myTypeOfColorSpace == Aspect_TOCS_BlackAndWhite) - myTypeOfColorSpace = Aspect_TOCS_RGB; -} - -//========================================================================== -void PS_Driver::InitializeTypeMap (const Handle(Aspect_TypeMap)& aTypeMap) -{ - Standard_Integer Size = aTypeMap->Size(); - Aspect_LineStyle aStyle; - for (Standard_Integer i=1; i<= Size; i++) { - (*Cout()) << "/D" << aTypeMap->Entry(i).Index() << " {["; - aStyle = aTypeMap->Entry(i).Type(); - for (Standard_Integer j = aStyle.Values().Lower(); j < aStyle.Values().Upper(); j += 2) - (*Cout()) << Standard_Real(Convert(aStyle.Values().Value(j ))) << " " - << Standard_Real(Convert(aStyle.Values().Value(j+1))) << " "; - (*Cout()) << "] 0 setdash} BD" << endl; - } -} - -//========================================================================== -void PS_Driver::InitializeWidthMap (const Handle(Aspect_WidthMap)& aWidthMap) -{ - Standard_Integer Size = aWidthMap->Size(); - for (Standard_Integer i=1; i<= Size; i++) { - Standard_Real w = aWidthMap->Entry(i).Width() / myPixelSize; - (*Cout()) << "/W" << aWidthMap->Entry(i).Index() << " {" - << w << " setlinewidth} BD" << endl; - } -} - -//========================================================================== -void PS_Driver::InitializeFontMap (const Handle(Aspect_FontMap)& aFontMap) -{ -#ifdef BUC60766 - PlotMgt_PlotterDriver::InitializeFontMap (aFontMap); -#else - if (UseMFT()) { - PlotMgt_PlotterDriver::InitializeFontMap (aFontMap); - } else -#endif - { - Aspect_FontMapEntry entry; - Standard_Integer index, iindex; - - TCollection_AsciiString aname; - Aspect_FontStyle style; - Standard_Boolean theCapsHeight; - Quantity_PlaneAngle theFontSlant; - Quantity_Length theFontSize; - Standard_ShortReal fsize; - - for (index = 1; index <= aFontMap->Size(); index++) { - entry = aFontMap->Entry(index); - iindex = entry.Index(); - style = entry.Type(); - theFontSize = TOMILLIMETER(style.Size()); - theFontSlant = style.Slant(); - aname = style.AliasName(); - theCapsHeight = style.CapsHeight(); - fsize = theFontSize; - if (fsize > 0.0001) - fsize = Convert(fsize); - else fsize = 1.; - - (*Cout()) << "/F" << iindex; - (*Cout()) << " {/scf exch def /mat exch def" << endl; - - if (!aname.Length() || (aname == "Default") || (aname == "Defaultfont")) - aname = "Courier"; - - (*Cout()) << "/" << aname << " findfont mat makefont "; - if (theCapsHeight) (*Cout()) << "setfont scf " << SCALEFONT << "} BD " << endl; - else (*Cout()) << "scf scalefont setfont} BD " << endl; - (*Cout()) << "/FSZ" << iindex << " " << Standard_Real(fsize) << " def" << endl; - } - } -} - -//========================================================================== -void PS_Driver::InitializeMarkMap (const Handle(Aspect_MarkMap)& aMarkMap) -{ - Standard_Integer i,j,n,sl,np,Size = aMarkMap->Size(); - Standard_Real dx,dy,x,y; - Standard_Boolean fl; - - for (i = 1; i <= Size; i++) { - const TShort_Array1OfShortReal& amx = aMarkMap->Entry(i).Style().XValues(); - const TShort_Array1OfShortReal& amy = aMarkMap->Entry(i).Style().YValues(); - const TColStd_Array1OfBoolean& ams = aMarkMap->Entry(i).Style().SValues(); - (*Cout()) << "/MRK" << aMarkMap->Entry(i).Index() << " {" << endl; - x = y = 0.; - sl = amx.Lower(); - np = 0; - fl = Standard_True; - for (n=1, j=sl; j <= amx.Upper(); j++, n++) { - dx = amx(j) - x; - dy = amy(j) - y; - x = amx(j); - y = amy(j); - (*Cout()) << dx << " " << dy << " "; - if (ams(j)) { - if (fl) np++; - (*Cout()) << RLINETO; - } else { - if (np) fl = Standard_False; - else sl = j; - (*Cout()) << RMOVETO; - } - if (!(n % 4)) (*Cout()) << endl; - } - (*Cout()) << "} BD" << endl; - (*Cout()) << "/FRMK" << aMarkMap->Entry(i).Index() << " {" << endl; - if (np > 1) { - x = y = 0.; - for (n=1, j=sl; j <= sl+np; j++, n++) { - dx = amx(j) - x; - dy = amy(j) - y; - x = amx(j); - y = amy(j); - (*Cout()) << dx << " " << dy << " "; - if( ams(j) ) { - (*Cout()) << RLINETO; - } else { - (*Cout()) << RMOVETO; - } - if (!(n % 4)) - (*Cout()) << endl; - } - (*Cout()) << CLOSEPATH; - } - (*Cout()) << "} BD " << endl; - } -} - -//========================================================================== -// Category: Methods to set the attributes -//========================================================================== -void PS_Driver::SetTextAttrib (const Standard_Integer ColorIndex, - const Standard_Integer FontIndex) -{ - PlotMgt_PlotterDriver::SetTextAttrib (ColorIndex, FontIndex); -#ifndef BUC60766 - if (!UseMFT()) -#endif - (*Cout()) << " [1 0 0 1 0 0 ] FSZ" << FontIndex << " F" << FontIndex << " "; -} - -//========================================================================== -void PS_Driver::SetTextAttrib (const Standard_Integer ColorIndex, - const Standard_Integer FontIndex, - const Quantity_PlaneAngle aSlant, - const Quantity_Factor aHScale, - const Standard_Real aWScale, - const Standard_Boolean isUnderlined) -{ - PlotMgt_PlotterDriver::SetTextAttrib ( - ColorIndex, FontIndex, aSlant, aHScale, aWScale, isUnderlined); -#ifndef BUC60766 - if (!UseMFT()) -#endif - (*Cout()) << " [" << myTextWScale << " 0 " << Sin(aSlant)*myTextHScale - << " " << Cos(aSlant)*myTextHScale << " 0 0] FSZ" << FontIndex - << " F" << FontIndex << " "; -} - -//========================================================================== -// Image methods -//========================================================================== -Standard_Boolean PS_Driver::SizeOfImageFile(const Standard_CString anImageFile, - Standard_Integer &aWidth, - Standard_Integer &aHeight) const -{ - return AlienImage::LoadImageFile (anImageFile, myImage, aWidth, aHeight); -} - -//========================================================================== -Standard_Boolean PS_Driver::PlotImage (const Standard_ShortReal aX, - const Standard_ShortReal aY, - const Standard_ShortReal aWidth, - const Standard_ShortReal aHeight, - const Standard_ShortReal aScale, - const Standard_CString anImageFile, - const Standard_Address anArrayOfPixels, - const Standard_Integer aLineIndex) -{ - Standard_Integer LowX = 0, LowY = 0; - Standard_Integer width = Standard_Integer(aWidth), - height = Standard_Integer(aHeight); - Standard_Boolean status; - Aspect_RGBPixel* g2dp = (Aspect_RGBPixel*) anArrayOfPixels; - // Load image if necessary - if (anImageFile) { - status = SizeOfImageFile (anImageFile, width, height); - if (status) { - LowX = myImage -> LowerX (); - LowY = myImage -> LowerY (); - } - } else { - status = Standard_True; - } - // Draw the image - if (status) { - Quantity_Color color; - Standard_Real r, g, b; - Standard_Integer n=0,x,y,red,green,blue; - Standard_ShortReal wscale, hscale; - wscale = hscale = aScale * myPixelSize * PPI; - if (aLineIndex == -1) { - (*Cout()) << " " << GSAVE << MapX(aX) - wscale*width/2. << " " - << MapY(aY) - hscale*height/2.; - } else { - (*Cout()) << " " << GSAVE << MapX(aX) - wscale*width/2. << " " - << MapY(aY) + hscale*(height/2. - aLineIndex); - height = 1; - } - (*Cout()) << " translate " << wscale*width << " " << hscale*height << " scale "; - (*Cout()) << width << " " << height << " 8 [" << width - << " 0 0 " << -height << " 0 " << height - << "] {currentfile IB readhexstring pop} false 3 colorimage " << endl; - Standard_Integer r1, r2, g1, g2, b1, b2; - char hstring[7]; - for (y=0; y < height; y++) { - for (x=n=0; x < width; x++) { - if (anImageFile) { - color = myImage -> PixelColor (x + LowX, y + LowY); - color.Values (r, g, b, Quantity_TOC_RGB); - } else { - r = g2dp -> red; - g = g2dp -> green; - b = g2dp -> blue; - g2dp++; - } - red = (int)(r * 255.); - green = (int)(g * 255.); - blue = (int)(b * 255.); - - if (anImageFile) { - r1 = (red >> 4) & 0xF; r2 = red & 0xF; - g1 = (green >> 4) & 0xF; g2 = green & 0xF; - b1 = (blue >> 4) & 0xF; b2 = blue & 0xF; - } else { - r1 = red >> 4; r2 = red & 0xF; - g1 = green >> 4; g2 = green & 0xF; - b1 = blue >> 4; b2 = blue & 0xF; - } - sprintf(hstring, "%X%X%X%X%X%X", r1, r2, g1, g2, b1, b2); - (*Cout()) << hstring; - n += 3; - if (n >= IMAGEBUFFERSIZE) { - n = 0; - (*Cout()) << endl; - } - } - } - if (n > 0) { - while (n < IMAGEBUFFERSIZE) { - (*Cout()) << "00"; n++; - } - } - (*Cout()) << endl; - (*Cout()) << " " << GRESTORE << endl; - return Standard_True; - } - return Standard_False; -} - -//============================================================= -// Category: Methods to write attributes -//============================================================= -void PS_Driver::PlotLineAttrib (const Standard_Integer ColorIndex, - const Standard_Integer TypeIndex, - const Standard_Integer WidthIndex) -{ - if ((myColorIndex != ColorIndex) && - (myTypeOfColorSpace != Aspect_TOCS_BlackAndWhite)) { - myColorIndex = ColorIndex; - (*Cout()) << " C" << myColorIndex << " "; - } - if (myTypeIndex != TypeIndex) { - myTypeIndex = TypeIndex; - (*Cout()) << " D" << myTypeIndex << " "; - } - if (myWidthIndex != WidthIndex) { - myWidthIndex = WidthIndex; - (*Cout()) << " W" << myWidthIndex << " "; - } -} - -//============================================================= -// Category: Methods to draw primitives -//============================================================= - -//============================================================= -Standard_Boolean PS_Driver::PlotPoint (const Standard_ShortReal X, - const Standard_ShortReal Y) -{ - (*Cout()) << X << " " << Y << " " << MOVETO << " " - << X << " " << Y << " " << LINETO << " " - << STROKE << endl; - return Standard_True; -} - -//============================================================= -Standard_Boolean PS_Driver::PlotSegment (const Standard_ShortReal X1, - const Standard_ShortReal Y1, - const Standard_ShortReal X2, - const Standard_ShortReal Y2) -{ - (*Cout()) << X1 << " " << Y1 << " " << MOVETO << " " - << X2 << " " << Y2 << " " << LINETO << " " - << STROKE << endl; - return Standard_True; -} - -//============================================================= -#define _XP(idx) ((float*)xArray)[(idx)] -#define _YP(idx) ((float*)yArray)[(idx)] -//============================================================= -Standard_Boolean PS_Driver::PlotPolyline (const Standard_Address xArray, - const Standard_Address yArray, - const Standard_Address nPts, - const Standard_Integer nParts) -{ - // Multipart drawing can only be used for text drawing - // (called from PlotMgt_TextManager::EndChar () - int N, cpN, i, j; - for (N = 0, i = 0; i < nParts; i++) { - cpN = ((int*)nPts)[i]; - (*Cout()) << _XP(N) << " " << _YP(N) << " " << MOVETO; - for (j = N + 1; j < N + cpN; j++) - (*Cout()) << _XP(j) << " " << _YP(j) << " " << LINETO; - (*Cout()) << " " << STROKE << endl; - N += cpN; - } - return Standard_True; -} - -//============================================================= -Standard_Boolean PS_Driver::PlotPolygon (const Standard_Address xArray, - const Standard_Address yArray, - const Standard_Address nPts, - const Standard_Integer nParts) -{ - Standard_Integer i; - if (nParts == 1) { - if (myPolyTileIndex >= 0) { - PLOT_PCOLOR (myPolyColorIndex); - (*Cout()) << _XP(0) << " " << _YP(0) << " " << MOVETO; - for (i = 1; i < ((int*)nPts)[0]; i++) - (*Cout()) << _XP(i) << " " << _YP(i) << " " << LINETO; - (*Cout()) << CLOSEPATH << FILL << endl; - - if (myPolyEdgeFlag) { -POLYLN1: - PlotLineAttrib (myLineColorIndex, myLineTypeIndex, myLineWidthIndex); - PlotPolyline (xArray, yArray, nPts, nParts); - } - } else - goto POLYLN1; - } else { - // This can only be used for text drawing - // (called from PlotMgt_TextManager::EndChar () - PLOT_PCOLOR (myPolyColorIndex); - int N, cpN, j; - for (N = 0, i = 0; i < nParts; i++) { - cpN = ((int*)nPts)[i]; - (*Cout()) << _XP(N) << " " << _YP(N) << " " << MOVETO; - for (j = N + 1; j < N + cpN; j++) - (*Cout()) << _XP(j) << " " << _YP(j) << " " << LINETO; - (*Cout()) << CLOSEPATH << endl; - N += cpN; - } - if (myPolyTileIndex == -1) (*Cout()) << STROKE << endl; - else (*Cout()) << FILL << endl; - } - return Standard_True; -} -//============================================================= -#undef _XP -#undef _YP - -//============================================================= -Standard_Boolean PS_Driver::PlotArc (const Standard_ShortReal Xpos, - const Standard_ShortReal Ypos, - const Standard_ShortReal aXradius, - const Standard_ShortReal aYradius, - const Standard_ShortReal sAngle, - const Standard_ShortReal oAngle) -{ - Standard_Real san = sAngle; - Standard_Real fan = sAngle + oAngle; - - if (Abs(aXradius-aYradius) <= 1.) { - (*Cout()) << Xpos + aXradius*Cos(san) << " " - << Ypos + aYradius*Sin(san) << " " << MOVETO; - (*Cout()) << GSAVE << Xpos << " " << Ypos << " " << aXradius << " "; - - if (Abs(fan)-Abs(san) >= 2.*M_PI) { - (*Cout()) << " 0 360 " << ARC << STROKE << GRESTORE << endl; - } else { - Standard_Real a1 = san/DRAD; - Standard_Real a2 = fan/DRAD; - (*Cout()) << a1 << " " << a2 << " " << ARC << STROKE << GRESTORE << endl; - } - return Standard_True; - } - return Standard_False; -} - -//============================================================= -Standard_Boolean PS_Driver::PlotPolyArc (const Standard_ShortReal Xpos, - const Standard_ShortReal Ypos, - const Standard_ShortReal aXradius, - const Standard_ShortReal aYradius, - const Standard_ShortReal sAngle, - const Standard_ShortReal oAngle) -{ - Standard_Real san = sAngle; - Standard_Real fan = sAngle + oAngle; - - if (Abs(aXradius-aYradius) <= 1.) { - PLOT_PCOLOR (myPolyColorIndex); - if (Abs(oAngle) < 2.*M_PI) - (*Cout()) << Xpos << " " << Ypos << " " << MOVETO; - else - (*Cout()) << Xpos + aXradius*Cos(san) << " " - << Ypos + aXradius*Sin(san) << " " << MOVETO; - (*Cout()) << GSAVE << Xpos << " " << Ypos << " " << aXradius << " "; - - if (Abs(fan) - Abs(san) >= 2.*M_PI) { - (*Cout()) << " 0 360 " << ARC << FILL << GRESTORE << endl; - } else { - Standard_Real a1 = san/DRAD; - Standard_Real a2 = fan/DRAD; - (*Cout()) << a1 << " " << a2 << " " << ARC << FILL << GRESTORE << endl; - } - if (myPolyEdgeFlag) { - PlotLineAttrib (myLineColorIndex, myLineTypeIndex, myLineWidthIndex); - return PlotArc (Xpos, Ypos, aXradius, aYradius, sAngle, oAngle); - } - return Standard_True; - } - return Standard_False; -} - -//============================================================= -Standard_Boolean PS_Driver::PlotMarker (const Standard_Integer aMarker, - const Standard_ShortReal Xpos, - const Standard_ShortReal Ypos, - const Standard_ShortReal Width, - const Standard_ShortReal Height, - const Standard_ShortReal Angle) -{ - Standard_Real w = Convert(Width/2.); - Standard_Real h = Convert(Height/2.); - Standard_Real a = Angle/DRAD; - - if (aMarker >= 0 && w > 0. && h > 0.) { - while (a > 360.) a -= 360.; - while (a < -360.) a += 360.; - if (myMarkerFillFlag) { - PlotLineAttrib (myPolyColorIndex, myLineTypeIndex, myLineWidthIndex); - (*Cout()) << GSAVE << Xpos << " " << Ypos << " " << MOVETO; - if (Angle != 0.) - (*Cout()) << a << " " << ROTATE; - (*Cout()) << w << " " << h << " " << SCALE << "FRMK" - << aMarker << " " << FILL << GRESTORE << endl; - } - - PlotLineAttrib (myMarkerColorIndex, 0, myMarkerWidthIndex); - (*Cout()) << GSAVE << Xpos << " " << Ypos << " " << MOVETO; - if (Angle != 0.) - (*Cout()) << a << " " << ROTATE; - (*Cout()) << w << " " << h << " " << SCALE << " MRK" << aMarker << " " - << 1./w << " " << 1./h << " " << SCALE << STROKE << GRESTORE << endl; - } else { - DrawPoint (Xpos,Ypos); - } - return Standard_True; -} - -//============================================================= -Standard_Boolean PS_Driver::PlotText (const TCollection_ExtendedString& aText, - const Standard_ShortReal Xpos, - const Standard_ShortReal Ypos, - const Standard_ShortReal Angle, - const Aspect_TypeOfText aType) -{ - if( aText.IsAscii() ) { - TCollection_AsciiString atext(aText,'?'); - PlotText(atext.ToCString(),Xpos,Ypos,Angle,aType); - } else { -#ifdef BUC60766 - return Standard_False; // Use MFT fonts -#else - Standard_CString ptext = Aspect::ToCString(aText); - Standard_Real a = Angle/DRAD; - Standard_Integer i,h1,h2; - char hstring[3]; - while (a > 360.) a -= 360.; - while (a < -360.) a += 360.; - PLOT_PCOLOR (myTextColorIndex); - if (myTextIsUnderlined) { - (*Cout()) << MapX(Xpos) << " " << MapY(Ypos) << " " << MOVETO; - (*Cout()) << "FSZ" << myFontIndex << " " << myTextHScale << " mul ("; - (*Cout()) << "C" << myTextColorIndex; - if (aType == Aspect_TOT_OUTLINE) (*Cout()) << " true " << CHARPATH << STROKE << ") "; - else (*Cout()) << " " << SHOW << ") "; - (*Cout()) << a << "<"; - for (i=0; i> 4) & 0xF; h2 = ptext[i] & 0xF; - sprintf(hstring,"%X%X",h1,h2); - (*Cout()) << hstring; - } - (*Cout()) << "> " << SHOWUNDERLINEDTEXT << endl; - } else { - if (Angle == 0.) (*Cout()) << MapX(Xpos) << " " << MapY(Ypos) << " " << MOVETO; - else (*Cout()) << GSAVE << MapX(Xpos) << " " << MapY(Ypos) << " " << MOVETO - << a << " " << ROTATE; - (*Cout()) << "<"; - for (i=0; i> 4) & 0xF; h2 = ptext[i] & 0xF; - sprintf(hstring,"%X%X",h1,h2); - (*Cout()) << hstring; - } - (*Cout()) << "> "; - if (aType == Aspect_TOT_OUTLINE) (*Cout()) << "true " << CHARPATH << STROKE; - else (*Cout()) << SHOW; - if (Angle == 0.) (*Cout()) << endl; - else (*Cout()) << GRESTORE << endl; - } - return Standard_True; -#endif - } - return Standard_False; -} - -//============================================================= -Standard_Boolean PS_Driver::PlotText (const Standard_CString aText, - const Standard_ShortReal Xpos, - const Standard_ShortReal Ypos, - const Standard_ShortReal Angle, - const Aspect_TypeOfText aType) -{ -#ifdef BUC60766 - { - Standard_Real a = Angle/DRAD; - while (a > 360.) a -= 360.; - while (a < -360.) a += 360.; - PLOT_PCOLOR (myTextColorIndex); - if (myTextIsUnderlined) { - (*Cout()) << MapX(Xpos) << " " << MapY(Ypos) << " " << MOVETO; - (*Cout()) << "FSZ" << myFontIndex << " " << myTextHScale << " mul ("; - (*Cout()) << "C" << myTextColorIndex; - if (aType == Aspect_TOT_OUTLINE) (*Cout()) << " true " << CHARPATH << STROKE << ") "; - else (*Cout()) << " " << SHOW << ") "; - (*Cout()) << a << " (" << aText << ") " << SHOWUNDERLINEDTEXT << endl; - } else { - if (Angle == 0.) (*Cout()) << MapX(Xpos) << " " << MapY(Ypos) << " " << MOVETO; - else (*Cout()) << GSAVE << MapX(Xpos) << " " << MapY(Ypos) << " " << MOVETO - << a << " " << ROTATE; - (*Cout()) << "(" << aText << ") "; - if (aType == Aspect_TOT_OUTLINE) (*Cout()) << "true " << CHARPATH << STROKE; - else (*Cout()) << SHOW; - if (Angle == 0.) (*Cout()) << endl; - else (*Cout()) << GRESTORE << endl; - } - return Standard_True; - } -#else - return Standard_False; -#endif -} - -//============================================================= -Standard_Boolean PS_Driver::PlotPolyText (const TCollection_ExtendedString& aText, - const Standard_ShortReal Xpos, - const Standard_ShortReal Ypos, - const Quantity_Factor aMargin, - const Standard_ShortReal Angle, - const Aspect_TypeOfText aType) -{ - if( aText.IsAscii() ) { - TCollection_AsciiString atext(aText,'?'); - PlotPolyText(atext.ToCString(),Xpos,Ypos,aMargin,Angle,aType); - } else { -#ifdef BUC60766 - return Standard_False; -#else - Standard_Real a = Angle/DRAD; - while( a > 360. ) a -= 360.; - while( a < -360. ) a += 360.; - (*Cout()) << MapX(Xpos) << " " << MapY(Ypos) << " " << MOVETO; - { - Standard_CString ptext = Aspect::ToCString(aText); - Standard_Integer i,h1,h2; - char hstring[3]; - if( myTypeOfColorSpace != Aspect_TOCS_BlackAndWhite ) { - if( myLineColorIndex > 0 && myPolyEdgeFlag) { - (*Cout()) << "(C" << myLineColorIndex; - } else { - (*Cout()) << "(CB"; - } - (*Cout()) << " W" << myLineWidthIndex << ")"; - if( myPolyTileIndex >= 0 ) { - if( myPolyColorIndex > 0 ) { - (*Cout()) << "(C" << myPolyColorIndex << ")"; - } else { - (*Cout()) << "(CB)"; - } - } - (*Cout()) << " FSZ" << myFontIndex << " " << myTextHScale << " mul "; - if( myTextColorIndex > 0 ) { - (*Cout()) << "(C" << myTextColorIndex; - } else { - (*Cout()) << "(CB"; - } - } else { - if( myPolyTileIndex >= 0 ) { - (*Cout()) << "(W" << myLineWidthIndex << ") ()"; - } else { - (*Cout()) << "(W" << myLineWidthIndex << ")"; - } - (*Cout()) << " FSZ" << myFontIndex << " " << myTextHScale << " mul ("; - } - if( aType == Aspect_TOT_OUTLINE ) { - (*Cout()) << " true " << CHARPATH << STROKE << ") "; - } else { - (*Cout()) << " " << SHOW << ") "; - } - (*Cout()) << aMargin << " " << a; - if( myTextIsUnderlined ) (*Cout()) << " true <"; - else (*Cout()) << " false <"; - for( i=0 ; i> 4) & 0xF; h2 = ptext[i] & 0xF; - sprintf(hstring,"%X%X",h1,h2); - (*Cout()) << hstring; - } - if( myPolyTileIndex >= 0 && myTypeOfColorSpace != Aspect_TOCS_BlackAndWhite ) { - (*Cout()) << "> " << SHOWHIDINGTEXT << endl; - } else { - (*Cout()) << "> " << SHOWFRAMEDTEXT << endl; - } - } - return Standard_True; -#endif - } - return Standard_False; -} - -//============================================================= -Standard_Boolean PS_Driver::PlotPolyText (const Standard_CString aText, - const Standard_ShortReal Xpos, - const Standard_ShortReal Ypos, - const Quantity_Factor aMargin, - const Standard_ShortReal Angle, - const Aspect_TypeOfText aType) -{ -#ifdef BUC60766 - Standard_Real a = Angle/DRAD; - while( a > 360. ) a -= 360.; - while( a < -360. ) a += 360.; - (*Cout()) << MapX(Xpos) << " " << MapY(Ypos) << " " << MOVETO; - { - if( myTypeOfColorSpace != Aspect_TOCS_BlackAndWhite ) { - if( myLineColorIndex > 0 && myPolyEdgeFlag) { - (*Cout()) << "(C" << myLineColorIndex; - } else { - (*Cout()) << "(CB"; - } - (*Cout()) << " W" << myLineWidthIndex << ")"; - if( myPolyTileIndex >= 0 ) { - if( myPolyColorIndex > 0 ) { - (*Cout()) << "(C" << myPolyColorIndex << ")"; - } else { - (*Cout()) << "(CB)"; - } - } - (*Cout()) << " FSZ" << myFontIndex << " " << myTextHScale << " mul "; - if( myTextColorIndex > 0 ) { - (*Cout()) << "(C" << myTextColorIndex; - } else { - (*Cout()) << "(CB"; - } - } else { - if( myPolyTileIndex >= 0 ) { - (*Cout()) << "(W" << myLineWidthIndex << ") ()"; - } else { - (*Cout()) << "(W" << myLineWidthIndex << ")"; - } - (*Cout()) << " FSZ" << myFontIndex << " " << myTextHScale << " mul ("; - } - if( aType == Aspect_TOT_OUTLINE ) { - (*Cout()) << " true " << CHARPATH << STROKE << ") "; - } else { - (*Cout()) << " " << SHOW << ") "; - } - (*Cout()) << aMargin << " " << a; - if( myTextIsUnderlined ) (*Cout()) << " true"; - else (*Cout()) << " false"; - if( myPolyTileIndex >= 0 && myTypeOfColorSpace != Aspect_TOCS_BlackAndWhite ) { - (*Cout()) << " (" << aText << ") " << SHOWHIDINGTEXT << endl; - } else { - (*Cout()) << " (" << aText << ") " << SHOWFRAMEDTEXT << endl; - } - } - return Standard_True; -#else - return Standard_False; -#endif -} - -//============================================================= -Standard_ShortReal PS_Driver::Convert(const Standard_ShortReal aShortreal) const -{ - return aShortreal * PPI; -} - -//=============================================================================== -Standard_Boolean PS_Driver::DrawCurveCapable () const -{ - return Standard_False; -} - -//============================================================= -Standard_ShortReal PS_Driver::MapX (const Standard_ShortReal aShortreal) const -{ - return aShortreal * PPI; -} - -//============================================================= -Standard_ShortReal PS_Driver::MapY (const Standard_ShortReal aShortreal) const -{ - return aShortreal * PPI; -} diff --git a/src/PlotMgt/FILES b/src/PlotMgt/FILES deleted file mode 100755 index ecfee3a890..0000000000 --- a/src/PlotMgt/FILES +++ /dev/null @@ -1,7 +0,0 @@ -PlotMgt_fill.hxx -PlotMgt_fillpolyarc.cxx -PlotMgt_fillpolygon.cxx -PlotMgt_PlotterTools.hxx -PlotMgt_PlotterTools.cxx -PlotMgt_Plotter_1.cxx -PlotMgt_Plotter_2.cxx diff --git a/src/PlotMgt/PlotMgt.cdl b/src/PlotMgt/PlotMgt.cdl deleted file mode 100755 index 3a692e43a5..0000000000 --- a/src/PlotMgt/PlotMgt.cdl +++ /dev/null @@ -1,220 +0,0 @@ --- Created on: 1998-11-25 --- Created by: DCB --- Copyright (c) 1998-1999 Matra Datavision --- Copyright (c) 1999-2012 OPEN CASCADE SAS --- --- The content of this file is subject to the Open CASCADE Technology Public --- License Version 6.5 (the "License"). You may not use the content of this file --- except in compliance with the License. Please obtain a copy of the License --- at http://www.opencascade.org and read it completely before using this file. --- --- The Initial Developer of the Original Code is Open CASCADE S.A.S., having its --- main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. --- --- The Original Code and all software distributed under the License is --- distributed on an "AS IS" basis, without warranty of any kind, and the --- Initial Developer hereby disclaims all such warranties, including without --- limitation, any warranties of merchantability, fitness for a particular --- purpose or non-infringement. Please see the License for the specific terms --- and conditions governing the rights and limitations under the License. - - -package PlotMgt - -uses - Aspect, - MFT, - Quantity, - TCollection, - TColStd, - TShort, - OSD, - MMgt - -is - ------------------------------ - -- Category: Pointers - ------------------------------ - pointer PlotterDriverPtr to PlotterDriver from PlotMgt; - - ------------------------------ - -- Category: Exceptions - ------------------------------ - exception PlotterDefinitionError inherits OutOfRange from Standard; - ---Category: The exceptions - - exception PlotterAccessError inherits OutOfRange from Standard; - ---Category: The exceptions - - -------------------- - -- Category: Classes - -------------------- - class ImageDriver; - ---Purpose: - - class PlotterParameter; - ---Purpose: Defines any plotter parameter and determines its behavior. - ---Category: Classes - - class Plotter; - ---Purpose: Defines a Plotter (sequence of plotter parameters and some - -- methods to operate with). This class must be used to access - -- plotter parameters. - ---Category: Classes - - deferred class PlotterDriver; - ---Purpose: - - private class TextManager; - ---Purpose: - - ------------------------- - -- Category: Enumerations - ------------------------- - - enumeration TypeOfOrigin is - TOO_CENTER, - TOO_BOTTOMLEFT, - TOO_BOTTOMRIGHT, - TOO_TOPLEFT, - TOO_TOPRIGHT - end; - - enumeration TypeOfQuality is - TOQ_DRAFT, - TOQ_NORMAL, - TOQ_HIGH, - TOQ_BEST - end; - - enumeration ImageFormat is - IF_DISABLE, - IF_ENABLE, - IF_XWD, - IF_BMP, - IF_GIF - end; - - enumeration TypeOfPlotterParameter is - TOPP_Undefined, - TOPP_Boolean, - TOPP_Integer, - TOPP_Real, - TOPP_String, - TOPP_ListString - end; - - enumeration PlottingType is - PT_RASTER, - PT_PENEMULATOR - end; - - enumeration PaperFormat is - PF_USERDEFINED, -- (00.00 x 00.00) - PF_A0, -- (84.10 x 118.9) - PF_A1, -- (59.40 x 84.10) - PF_A2, -- (42.00 x 59.40) - PF_A3, -- (29.70 x 42.00) - PF_A4, -- (21.00 x 29.70) - PF_A5, -- (14.80 x 21.00) - PF_LETTER, -- (21.59 x 27.94) - PF_LEGAL, -- (21.59 x 35.56) - PF_STATEMENT, -- (13.97 x 21.59) - PF_EXCLUSIVE, -- (18.41 x 26.67) - PF_FOLIO, -- (21.59 x 33.02) - PF_QUARTO, -- (21.50 x 27.50) - PF_ENVELOPE, -- (11.00 x 23.00) - PF_MONARCH -- (09.84 x 19.04) - end; - - --------------------------------- - -- Category: Instantiated classes - --------------------------------- - private class ListOfPlotterParameter instantiates - Sequence from TCollection (PlotterParameter from PlotMgt); - - private class HListOfPlotterParameter instantiates - HSequence from TCollection (PlotterParameter from PlotMgt, - ListOfPlotterParameter from PlotMgt); - - class ListOfMFTFonts instantiates - Array1 from TCollection (FontManager from MFT); - - class HListOfMFTFonts instantiates - HArray1 from TCollection (FontManager from MFT, ListOfMFTFonts); - - --------------------------------- - -- Category: Package methods - --------------------------------- - DeviceList - returns HSequenceOfAsciiString from TColStd; - ---Purpose: - - TypeFromString ( - aTypeString : in out AsciiString from TCollection - ) returns TypeOfPlotterParameter from PlotMgt; - ---Purpose: - - StringFromType ( - aType : TypeOfPlotterParameter from PlotMgt - ) returns AsciiString from TCollection; - ---Purpose: - - OriginFromString ( - anOriginString : in out AsciiString from TCollection - ) returns TypeOfOrigin from PlotMgt; - ---Purpose: - - StringFromOrigin ( - anOrigin : TypeOfOrigin from PlotMgt - ) returns AsciiString from TCollection; - ---Purpose: - - QualityFromString ( - aQualityString : in out AsciiString from TCollection - ) returns TypeOfQuality from PlotMgt; - ---Purpose: - - StringFromQuality ( - aQuality : TypeOfQuality from PlotMgt - ) returns AsciiString from TCollection; - ---Purpose: - - ImageFormatFromString ( - anImageFormatString : in out AsciiString from TCollection - ) returns ImageFormat from PlotMgt; - ---Purpose: - - StringFromImageFormat ( - anImageFormat : ImageFormat from PlotMgt - ) returns AsciiString from TCollection; - ---Purpose: - - PlottingTypeFromString ( - aPlottingTypeString : in out AsciiString from TCollection - ) returns PlottingType from PlotMgt; - ---Purpose: - - StringFromPlottingType ( - aPlottingType : PlottingType from PlotMgt - ) returns AsciiString from TCollection; - ---Purpose: - - PaperFormatFromString ( - aPaperFormatString : in out AsciiString from TCollection - ) returns PaperFormat from PlotMgt; - ---Purpose: - - StringFromPaperFormat ( - aPaperFormat : PaperFormat from PlotMgt - ) returns AsciiString from TCollection; - ---Purpose: - - PaperSize ( - aFormat : in out AsciiString from TCollection; - aWidth : out Real from Standard; - aLength : out Real from Standard - ); - ---Purpose: - -end PlotMgt; diff --git a/src/PlotMgt/PlotMgt.cxx b/src/PlotMgt/PlotMgt.cxx deleted file mode 100755 index 98898381d3..0000000000 --- a/src/PlotMgt/PlotMgt.cxx +++ /dev/null @@ -1,314 +0,0 @@ -// Created on: 1999-01-22 -// Created by: DCB -// Copyright (c) 1999 Matra Datavision -// Copyright (c) 1999-2012 OPEN CASCADE SAS -// -// The content of this file is subject to the Open CASCADE Technology Public -// License Version 6.5 (the "License"). You may not use the content of this file -// except in compliance with the License. Please obtain a copy of the License -// at http://www.opencascade.org and read it completely before using this file. -// -// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its -// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. -// -// The Original Code and all software distributed under the License is -// distributed on an "AS IS" basis, without warranty of any kind, and the -// Initial Developer hereby disclaims all such warranties, including without -// limitation, any warranties of merchantability, fitness for a particular -// purpose or non-infringement. Please see the License for the specific terms -// and conditions governing the rights and limitations under the License. - - -#ifdef WNT -# include -# pragma comment(lib, "winspool.lib") -# pragma comment(lib, "user32.lib" ) -# include -#endif // WNT - -#include - -#include - -//============================================================================== -static int __NumberOfTypes = PlotMgt_TOPP_ListString + 1; -static int __NumberOfOrigins = PlotMgt_TOO_TOPRIGHT + 1; -static int __NumberOfQualities = PlotMgt_TOQ_BEST + 1; -static int __NumberOfImageFormats = PlotMgt_IF_GIF + 1; -static int __NumberOfPlottingTypes = PlotMgt_PT_PENEMULATOR + 1; -static int __NumberOfPaperFormats = PlotMgt_PF_MONARCH + 1; - -static TCollection_AsciiString aTypeStr; -static TCollection_AsciiString anOriginStr; -static TCollection_AsciiString aQualityStr; -static TCollection_AsciiString anImageFormatStr; -static TCollection_AsciiString aPlottingTypeStr; -static TCollection_AsciiString aPaperFormatStr; - -static const char* __TypeOfParameter[] = { - "undefined", "boolean", - "integer", "real", - "string", "list_string" -}; - -static const char* __TypeOfOrigin [] = { - "Center", "Bottom left", - "Bottom right", "Top left", - "Top right" -}; - -static const char* __TypeOfQuality [] = { - "Draft", "Normal", - "High", "Best" -}; - -static const char* __ImageFormat [] = { - "DISABLE", "ENABLE", - "XWD", "BMP", - "GIF" -}; - -static const char* __PlottingType [] = { - "Raster", "PenEmulator" -}; - -static const char* __PaperFormats [] = { - "UserDefined", "A0", "A1", "A2", "A3", - "A4", "A5", "Letter", "Legal", "Statement", - "Executive", "Folio", "Quarto", "Envelope", "Monarch" -}; - -//============================================================================== -#ifdef WNT -static BOOL IsWindows95 () { - OSVERSIONINFO os; - os.dwOSVersionInfoSize = sizeof ( OSVERSIONINFO ); - GetVersionEx (&os); - return (os.dwPlatformId == VER_PLATFORM_WIN32_WINDOWS); -} -#endif - -//============================================================================== -Handle(TColStd_HSequenceOfAsciiString) PlotMgt::DeviceList () -{ - Handle(TColStd_HSequenceOfAsciiString) aList = new TColStd_HSequenceOfAsciiString (); -#ifdef WNT - char buff[ MAX_PATH ]; - DWORD dwLen, dwLenRet; - TCollection_AsciiString dev, defDev; - buff[ dwLen = - GetProfileString ( "Windows", "Device", ",,,", buff, MAX_PATH ) ] = '\x00'; - defDev = TCollection_AsciiString ( buff ); - defDev = defDev.Token ( ",", 1 ); - dwLen = 0; - if (IsWindows95()) { - ///////////////////////// W95 //////////////////////////// - PRINTER_INFO_5* ppi = NULL; - if (!EnumPrinters (PRINTER_ENUM_LOCAL, NULL, 5, NULL, 0, &dwLen, &dwLenRet)) { - if (GetLastError () == ERROR_INSUFFICIENT_BUFFER) { - ppi = ( PRINTER_INFO_5* )HeapAlloc (GetProcessHeap (), HEAP_GENERATE_EXCEPTIONS, dwLen); - EnumPrinters (PRINTER_ENUM_LOCAL, NULL, 5, ( LPBYTE )ppi, dwLen, &dwLen, &dwLenRet); - } else { - wsprintf (buff, "PlotMgt::DeviceList -> Could not obtain device list (%d)", GetLastError ()); - Standard_ProgramError :: Raise ( buff ); - dwLenRet = 0; - } // end else - } - for (dwLen = 0; dwLen < dwLenRet; ++ dwLen) { - dev = TCollection_AsciiString ( ppi[ dwLen ].pPrinterName ); - if (dev.IsEqual (defDev)) aList -> Prepend ( dev ); - else aList -> Append ( dev ); - } // end for - if (ppi != NULL) - HeapFree (GetProcessHeap (), 0, ( LPVOID )ppi); - } else { - ///////////////////////// WNT //////////////////////////// - PRINTER_INFO_4* ppi = NULL; - if (!EnumPrinters (PRINTER_ENUM_LOCAL | PRINTER_ENUM_CONNECTIONS, - NULL, 4, NULL, 0, &dwLen, &dwLenRet)) { - if (GetLastError () == ERROR_INSUFFICIENT_BUFFER) { - ppi = ( PRINTER_INFO_4* )HeapAlloc (GetProcessHeap (), HEAP_GENERATE_EXCEPTIONS, dwLen); - EnumPrinters (PRINTER_ENUM_LOCAL | PRINTER_ENUM_CONNECTIONS, - NULL, 4, ( LPBYTE )ppi, dwLen, &dwLen, &dwLenRet); - } else { - wsprintf (buff, "PlotMgt::DeviceList -> Could not obtain device list (%d)", GetLastError () ); - Standard_ProgramError :: Raise ( buff ); - dwLenRet = 0; - } // end else - } - for (dwLen = 0; dwLen < dwLenRet; ++ dwLen) { - dev = TCollection_AsciiString ( ppi[ dwLen ].pPrinterName ); - if (dev.IsEqual (defDev)) aList -> Prepend ( dev ); - else aList -> Append ( dev ); - } // end for - if (ppi != NULL) - HeapFree (GetProcessHeap (), 0, ( LPVOID )ppi); - } // WINNT -#else - const char *cmd = "lpstat -v"; - char buf[BUFSIZ]; - FILE *ptr; - if ((ptr = popen(cmd, "r")) != NULL) { - while (fgets(buf, BUFSIZ, ptr) != NULL) - aList -> Append (buf); - pclose (ptr); - } -#endif // WNT - return aList; -} - -//============================================================================== -PlotMgt_TypeOfPlotterParameter PlotMgt::TypeFromString ( - TCollection_AsciiString& aTypeString) -{ - aTypeString.LowerCase (); - aTypeString.LeftAdjust (); - aTypeString.RightAdjust (); - for (int i = 0; i < __NumberOfTypes; i++) - if (aTypeString.IsEqual(__TypeOfParameter[i])) - return PlotMgt_TypeOfPlotterParameter(i); - return PlotMgt_TOPP_Undefined; -} - -//============================================================================== -TCollection_AsciiString PlotMgt::StringFromType ( - const PlotMgt_TypeOfPlotterParameter aType) -{ - aTypeStr = TCollection_AsciiString (__TypeOfParameter [(int)aType]); - return aTypeStr; -} - -//============================================================================== -PlotMgt_TypeOfOrigin PlotMgt::OriginFromString ( - TCollection_AsciiString& anOriginString) -{ - anOriginString.LeftAdjust (); - anOriginString.RightAdjust (); - for (int i = 0; i < __NumberOfOrigins; i++) - if (anOriginString.IsEqual(__TypeOfOrigin[i])) - return PlotMgt_TypeOfOrigin(i); - return PlotMgt_TOO_CENTER; -} - -//============================================================================== -TCollection_AsciiString PlotMgt::StringFromOrigin ( - const PlotMgt_TypeOfOrigin anOrigin) -{ - anOriginStr = TCollection_AsciiString (__TypeOfOrigin [(int)anOrigin]); - return anOriginStr; -} - -//============================================================================== -PlotMgt_TypeOfQuality PlotMgt::QualityFromString ( - TCollection_AsciiString& aQualityString) -{ - aQualityString.LeftAdjust (); - aQualityString.RightAdjust (); - for (int i = 0; i < __NumberOfQualities; i++) - if (aQualityString.IsEqual(__TypeOfQuality[i])) - return PlotMgt_TypeOfQuality(i); - return PlotMgt_TOQ_DRAFT; -} - -//============================================================================== -TCollection_AsciiString PlotMgt::StringFromQuality ( - const PlotMgt_TypeOfQuality aQuality) -{ - aQualityStr = TCollection_AsciiString (__TypeOfQuality [(int)aQuality]); - return aQualityStr; -} - -//============================================================================== -PlotMgt_ImageFormat PlotMgt::ImageFormatFromString ( - TCollection_AsciiString& anImageFormatString) -{ - anImageFormatString.LeftAdjust (); - anImageFormatString.RightAdjust (); - for (int i = 0; i < __NumberOfImageFormats; i++) - if (anImageFormatString.IsEqual(__ImageFormat[i])) - return PlotMgt_ImageFormat(i); - return PlotMgt_IF_DISABLE; -} - -//============================================================================== -TCollection_AsciiString PlotMgt::StringFromImageFormat ( - const PlotMgt_ImageFormat anImageFormat) -{ - anImageFormatStr = TCollection_AsciiString (__ImageFormat [(int)anImageFormat]); - return anImageFormatStr; -} - -//============================================================================== -PlotMgt_PlottingType PlotMgt::PlottingTypeFromString ( - TCollection_AsciiString& aPlottingTypeString) -{ - aPlottingTypeString.LeftAdjust (); - aPlottingTypeString.RightAdjust (); - for (int i = 0; i < __NumberOfPlottingTypes; i++) - if (aPlottingTypeString.IsEqual(__PlottingType[i])) - return PlotMgt_PlottingType(i); - return PlotMgt_PT_RASTER; -} - -//============================================================================== -TCollection_AsciiString PlotMgt::StringFromPlottingType ( - const PlotMgt_PlottingType aPlottingType) -{ - aPlottingTypeStr = TCollection_AsciiString (__PlottingType [(int)aPlottingType]); - return aPlottingTypeStr; -} - -//============================================================================== -//============================================================================== -//============================================================================== -static Standard_Real aPaperWidths [] = { - // UserDefined - 00.00, - // A0, A1, A2, A3, A4, A5 - 84.10, 59.40, 42.00, 29.70, 21.00, 14.80, - // Letter, Legal, Statement, Executive, Folio, Quarto - 21.59, 21.59, 13.97, 18.41, 21.59, 21.50, - // Envelope, Monarch - 11.00, 09.84 -}; - -static Standard_Real aPaperLengths [] = { - // UserDefined - 00.00, - // A0, A1, A2, A3, A4, A5 - 118.9, 84.10, 59.40, 42.00, 29.70, 21.00, - // Letter, Legal, Statement, Executive, Folio, Quarto - 27.94, 35.56, 21.59, 26.67, 33.02, 27.50, - // Envelope, Monarch - 23.00, 19.04 -}; - -//============================================================================== -PlotMgt_PaperFormat PlotMgt::PaperFormatFromString ( - TCollection_AsciiString& aPaperFormatString) -{ - aPaperFormatString.LeftAdjust (); - aPaperFormatString.RightAdjust (); - for (int i = 0; i < __NumberOfPaperFormats; i++) - if (aPaperFormatString.IsEqual(__PaperFormats[i])) - return PlotMgt_PaperFormat(i); - return PlotMgt_PF_A4; -} - -//============================================================================== -TCollection_AsciiString PlotMgt::StringFromPaperFormat ( - const PlotMgt_PaperFormat aPaperFormat) -{ - aPaperFormatStr = TCollection_AsciiString (__PaperFormats [(int)aPaperFormat]); - return aPaperFormatStr; -} - -//============================================================================== -void PlotMgt::PaperSize (TCollection_AsciiString& aFormat, - Standard_Real& aWidth, - Standard_Real& aLength) -{ - PlotMgt_PaperFormat aFmt = PlotMgt::PaperFormatFromString (aFormat); - aWidth = aPaperWidths [(int)aFmt]; - aLength = aPaperLengths [(int)aFmt]; -} diff --git a/src/PlotMgt/PlotMgt_ImageDriver.cdl b/src/PlotMgt/PlotMgt_ImageDriver.cdl deleted file mode 100755 index ca4da6e0a2..0000000000 --- a/src/PlotMgt/PlotMgt_ImageDriver.cdl +++ /dev/null @@ -1,39 +0,0 @@ --- Created on: 1998-11-25 --- Created by: DCB --- Copyright (c) 1998-1999 Matra Datavision --- Copyright (c) 1999-2012 OPEN CASCADE SAS --- --- The content of this file is subject to the Open CASCADE Technology Public --- License Version 6.5 (the "License"). You may not use the content of this file --- except in compliance with the License. Please obtain a copy of the License --- at http://www.opencascade.org and read it completely before using this file. --- --- The Initial Developer of the Original Code is Open CASCADE S.A.S., having its --- main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. --- --- The Original Code and all software distributed under the License is --- distributed on an "AS IS" basis, without warranty of any kind, and the --- Initial Developer hereby disclaims all such warranties, including without --- limitation, any warranties of merchantability, fitness for a particular --- purpose or non-infringement. Please see the License for the specific terms --- and conditions governing the rights and limitations under the License. - - -class ImageDriver from PlotMgt inherits PlotterDriver from PlotMgt - -uses - Plotter from PlotMgt - -is - Create(aPlotter : Plotter from PlotMgt; - aName : CString from Standard) - returns mutable ImageDriver from PlotMgt; - - Create(aName : CString from Standard) - returns mutable ImageDriver from PlotMgt; - - BeginDraw (me: mutable) is static; - - EndDraw (me: mutable; dontFlush: Boolean = Standard_False) is static; - -end ImageDriver from PlotMgt; diff --git a/src/PlotMgt/PlotMgt_ImageDriver.cxx b/src/PlotMgt/PlotMgt_ImageDriver.cxx deleted file mode 100755 index d59d5bd61c..0000000000 --- a/src/PlotMgt/PlotMgt_ImageDriver.cxx +++ /dev/null @@ -1,49 +0,0 @@ -// Created on: 1998-11-25 -// Created by: DCB -// Copyright (c) 1998-1999 Matra Datavision -// Copyright (c) 1999-2012 OPEN CASCADE SAS -// -// The content of this file is subject to the Open CASCADE Technology Public -// License Version 6.5 (the "License"). You may not use the content of this file -// except in compliance with the License. Please obtain a copy of the License -// at http://www.opencascade.org and read it completely before using this file. -// -// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its -// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. -// -// The Original Code and all software distributed under the License is -// distributed on an "AS IS" basis, without warranty of any kind, and the -// Initial Developer hereby disclaims all such warranties, including without -// limitation, any warranties of merchantability, fitness for a particular -// purpose or non-infringement. Please see the License for the specific terms -// and conditions governing the rights and limitations under the License. - - -#include - -//============================================================= -/*ARGSUSED*/ -PlotMgt_ImageDriver::PlotMgt_ImageDriver (const Handle(PlotMgt_Plotter)& aPlotter, - const Standard_CString aName) - : PlotMgt_PlotterDriver (aPlotter, aName) -{ -} - -//============================================================= -/*ARGSUSED*/ -PlotMgt_ImageDriver::PlotMgt_ImageDriver (const Standard_CString aName) - : PlotMgt_PlotterDriver (aName) -{ -} - -//============================================================= -/*ARGSUSED*/ -void PlotMgt_ImageDriver::BeginDraw () -{ -} - -//============================================================= -/*ARGSUSED*/ -void PlotMgt_ImageDriver::EndDraw (const Standard_Boolean /*dontFlush*/) -{ -} diff --git a/src/PlotMgt/PlotMgt_Plotter.cdl b/src/PlotMgt/PlotMgt_Plotter.cdl deleted file mode 100755 index 54343baee8..0000000000 --- a/src/PlotMgt/PlotMgt_Plotter.cdl +++ /dev/null @@ -1,431 +0,0 @@ --- Created by: DCB --- Copyright (c) 1998-1999 Matra Datavision --- Copyright (c) 1999-2012 OPEN CASCADE SAS --- --- The content of this file is subject to the Open CASCADE Technology Public --- License Version 6.5 (the "License"). You may not use the content of this file --- except in compliance with the License. Please obtain a copy of the License --- at http://www.opencascade.org and read it completely before using this file. --- --- The Initial Developer of the Original Code is Open CASCADE S.A.S., having its --- main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. --- --- The Original Code and all software distributed under the License is --- distributed on an "AS IS" basis, without warranty of any kind, and the --- Initial Developer hereby disclaims all such warranties, including without --- limitation, any warranties of merchantability, fitness for a particular --- purpose or non-infringement. Please see the License for the specific terms --- and conditions governing the rights and limitations under the License. - - -class Plotter from PlotMgt inherits TShared from MMgt - -uses - PlotterParameter from PlotMgt, - TypeOfPlotterParameter from PlotMgt, - HListOfPlotterParameter from PlotMgt, - TypeOfOrigin from PlotMgt, - TypeOfQuality from PlotMgt, - ImageFormat from PlotMgt, - PlottingType from PlotMgt, - PaperFormat from PlotMgt, - ColorMap from Aspect, - GenericColorMap from Aspect, - WidthMap from Aspect, - TypeMap from Aspect, - FontMap from Aspect, - HSequenceOfAsciiString from TColStd, - HSequenceOfInteger from TColStd, - AsciiString from TCollection - -is - ------------------------- - -- Category: Constructors - ------------------------- - Create ( - theName : AsciiString from TCollection; - fDirectDevice : Boolean from Standard = Standard_False - -- This is a WNT specific parameter which indicates - -- that the parameters is the name of a plotter - -- instaled on WNT System. - ) returns mutable Plotter from PlotMgt; - ---Purpose: Create class instance - - ---------------------------- - -- Category: Public methods - ---------------------------- - CheckConfig (me: mutable; theViewIs2D : Boolean from Standard) - returns Boolean from Standard; - ---Purpose: Checks if the plotter configured properly. - - ------------------------------ - -- Category: Load/save plotter - ------------------------------ - Load ( me: mutable ) - returns Boolean from Standard; - ---Purpose: - - SavePlotter ( me: mutable ) - returns Boolean from Standard is private; - ---Purpose: - - Save ( me: mutable ) - returns Boolean from Standard; - ---Purpose: - - SaveAs ( me: mutable; aNewName: AsciiString from TCollection ) - returns Boolean from Standard; - ---Purpose: - - NeedToBeSaved ( me ) - returns Boolean from Standard; - ---Purpose: - - -------------------------------------- - -- Category: Static & internal methods - -------------------------------------- - ListPlotters ( myclass; - anActiveOnly : Boolean from Standard = Standard_True - ) returns HSequenceOfAsciiString from TColStd; - ---Purpose: Returns list of active plotters (and inactive if - -- = Standared_False). - - Dump ( me: mutable ); - ---Purpose: - - ReadParametersFromFile ( me : mutable; - aFileName : AsciiString from TCollection; - fChangeState : Boolean from Standard - ) returns Boolean from Standard is private; - ---Purpose: - - --------------------------------------------------- - --------------------------------------------------- - --------------------------------------------------- - --------------------------------------------------- - --------------------------------------------------- - --------------------------------------------------- - -- Category: Inquire methods - --------------------------------------------------- - NumberOfParameters ( me: mutable ) - returns Integer from Standard; - ---Purpose: - - Parameter ( me: mutable; anIndex: Integer from Standard ) - returns PlotterParameter from PlotMgt; - ---Purpose: - ---C++: return const & - - FindParameter ( me: mutable; aName : AsciiString from TCollection ) - returns Integer from Standard is private; - ---Purpose: - - GetStringValue ( me: mutable; - aParam : CString from Standard; - aValue : out AsciiString from TCollection - ) is private; - ---Purpose: - - GetBooleanValue ( me: mutable; - aParam : CString from Standard - ) returns Boolean from Standard is private; - ---Purpose: - - GetIntegerValue ( me: mutable; - aParam : CString from Standard - ) returns Integer from Standard is private; - ---Purpose: - - GetRealValue ( me: mutable; - aParam : CString from Standard - ) returns Real from Standard is private; - ---Purpose: - - GetListValue ( me: mutable; - aParam : CString from Standard; - aList : out HSequenceOfAsciiString from TColStd - ) is private; - ---Purpose: - - GetIntTable ( me: mutable; - aParam : CString from Standard; - aTable : out HSequenceOfInteger from TColStd - ) is private; - ---Purpose: - - ---------------------- STRING VALUES ------------------------ - Name ( me: mutable ) returns AsciiString from TCollection; - Model ( me: mutable ) returns AsciiString from TCollection; - Title ( me: mutable ) returns AsciiString from TCollection; - FileExtension ( me: mutable ) returns AsciiString from TCollection; - PrintCommand ( me: mutable ) returns AsciiString from TCollection; - BeforePrintCommand ( me: mutable ) returns AsciiString from TCollection; - AfterPrintCommand ( me: mutable ) returns AsciiString from TCollection; - Comments ( me: mutable ) returns AsciiString from TCollection; - BackDraw ( me: mutable ) returns AsciiString from TCollection; - ColorMapping ( me: mutable ) returns AsciiString from TCollection; - OutputFormat ( me: mutable ) returns AsciiString from TCollection; - DriverType ( me: mutable ) returns AsciiString from TCollection; - - ---------------------- BOOLEAN VALUES ------------------------ - MirrorPlot ( me: mutable ) returns Boolean from Standard; - MultiSheet ( me: mutable ) returns Boolean from Standard; - FramePlot ( me: mutable ) returns Boolean from Standard; - - PlotTitle ( me: mutable ) returns Boolean from Standard; - PlotComments ( me: mutable ) returns Boolean from Standard; - PlotBackDraw ( me: mutable ) returns Boolean from Standard; - - PlotterColor ( me: mutable ) returns Boolean from Standard; - EndOfPlotDriven ( me: mutable ) returns Boolean from Standard; - DryTimeDriven ( me: mutable ) returns Boolean from Standard; - PaperFeedDriven ( me: mutable ) returns Boolean from Standard; - MirrorDriven ( me: mutable ) returns Boolean from Standard; - CheckSumDriven ( me: mutable ) returns Boolean from Standard; - MediaSaverDriven ( me: mutable ) returns Boolean from Standard; - QualityDriven ( me: mutable ) returns Boolean from Standard; - CopyDriven ( me: mutable ) returns Boolean from Standard; - PaperCutDriven ( me: mutable ) returns Boolean from Standard; - RotateDriven ( me: mutable ) returns Boolean from Standard; - - CircleDriven ( me: mutable ) returns Boolean from Standard; - EllipseDriven ( me: mutable ) returns Boolean from Standard; - CurveDriven ( me: mutable ) returns Boolean from Standard; - TextDriven ( me: mutable ) returns Boolean from Standard; - MarkerDriven ( me: mutable ) returns Boolean from Standard; - RectangleDriven ( me: mutable ) returns Boolean from Standard; - FillDriven ( me: mutable ) returns Boolean from Standard; - PlottingColor ( me: mutable ) returns Boolean from Standard; - - ---------------------- LIST VALUES --------------------------- - ListOfPaperFormats ( me: mutable ) returns HSequenceOfAsciiString from TColStd; - ListOfOrigins ( me: mutable ) returns HSequenceOfAsciiString from TColStd; - ListOfQualities ( me: mutable ) returns HSequenceOfAsciiString from TColStd; - ListOfImageFormats ( me: mutable ) returns HSequenceOfAsciiString from TColStd; - ListOfColorMappings ( me: mutable ) returns HSequenceOfAsciiString from TColStd; - ListOfOutputFormats ( me: mutable ) returns HSequenceOfAsciiString from TColStd; - ListOfDriverTypes ( me: mutable ) returns HSequenceOfAsciiString from TColStd; - - ---------------------- REAL VALUES --------------------------- - PaperWidth ( me: mutable ) returns Real from Standard; - PaperLength ( me: mutable ) returns Real from Standard; - PaperSize ( me: mutable; aWidth, aLength : out Real from Standard ); - HardMargins ( me: mutable; - aLeft, aTop, aRight, aBottom : out Real from Standard ); - Margins ( me: mutable; - aLeft, aTop, aRight, aBottom : out Real from Standard ); - HardMappings ( me: mutable; - aWOffset, aWScale : out Real from Standard; - anLOffset, anLScale : out Real from Standard ); - SpaceDrawing ( me: mutable ) returns Real from Standard; - PhysicalStep ( me: mutable ) returns Real from Standard; - MinWidthOfLine ( me: mutable ) returns Real from Standard; - WidthMaxGap ( me: mutable ) returns Real from Standard; - LineTypeMaxGap ( me: mutable ) returns Real from Standard; - Resolution ( me: mutable ) returns Real from Standard; - ColorResolution ( me: mutable ) returns Real from Standard; - FillWidth ( me: mutable ) returns Real from Standard; - - ---------------------- INTEGER VALUES ------------------------ - MediaSaverDelay ( me: mutable ) returns Integer from Standard; - NumberOfCopies ( me: mutable ) returns Integer from Standard; - DryTime ( me: mutable ) returns Integer from Standard; - EndOfPlotTimer ( me: mutable ) returns Integer from Standard; - MaxColors ( me: mutable ) returns Integer from Standard; - MaxPatterns ( me: mutable ) returns Integer from Standard; - ColorMaxGap ( me: mutable ) returns Integer from Standard; - LinearDensity ( me: mutable ) returns Integer from Standard; - StylusNumber ( me: mutable ) returns Integer from Standard; - PenMaxNumber ( me: mutable ) returns Integer from Standard; - NumberInCarrousel ( me: mutable ) returns Integer from Standard; - - ---------------------- ENUM VALUES --------------------------- - Origin ( me: mutable ) returns TypeOfOrigin from PlotMgt; - Quality ( me: mutable ) returns TypeOfQuality from PlotMgt; - ImageFormat ( me: mutable ) returns ImageFormat from PlotMgt; - PlottingType ( me: mutable ) returns PlottingType from PlotMgt; - PaperFormat ( me: mutable ) returns PaperFormat from PlotMgt; - - ----------------------- MAP VALUES --------------------------- - PenColorIndex ( me: mutable ) returns HSequenceOfInteger from TColStd; - PenWidthIndex ( me: mutable ) returns HSequenceOfInteger from TColStd; - PenTypeIndex ( me: mutable ) returns HSequenceOfInteger from TColStd; - ColorMap ( me: mutable ) returns ColorMap from Aspect; - WidthMap ( me: mutable ) returns WidthMap from Aspect; - TypeMap ( me: mutable ) returns TypeMap from Aspect; - FontMap ( me: mutable ) returns FontMap from Aspect; - AllFonts ( me: mutable ) returns FontMap from Aspect; - - --------------------------------------------------- - --------------------------------------------------- - --------------------------------------------------- - --------------------------------------------------- - --------------------------------------------------- - --------------------------------------------------- - -- Category: Methods to change plotter's definition - --------------------------------------------------- - SetStringValue ( me: mutable; - aParam : CString from Standard; - anOldValue : out AsciiString from TCollection; - aNewValue : AsciiString from TCollection - ) is private; - ---Purpose: - - SetBooleanValue ( me: mutable; - aParam : CString from Standard; - aValue : Boolean from Standard - ) is private; - ---Purpose: - - SetIntegerValue ( me: mutable; - aParam : CString from Standard; - aValue : Integer from Standard - ) is private; - ---Purpose: - - SetRealValue ( me: mutable; - aParam : CString from Standard; - aValue : Real from Standard - ) is private; - ---Purpose: - - SetIntTable ( me: mutable; - aParam : CString from Standard; - aTable : HSequenceOfInteger from TColStd - ) is private; - ---Purpose: - - -------------------- SET STRING VALUES ----------------------- - SetModel ( me: mutable; aValue: AsciiString from TCollection ); - SetTitle ( me: mutable; aValue: AsciiString from TCollection ); - SetFileExtension ( me: mutable; aValue: AsciiString from TCollection ); - SetPrintCommand ( me: mutable; aValue: AsciiString from TCollection ); - SetBeforePrintCommand ( me: mutable; aValue: AsciiString from TCollection ); - SetAfterPrintCommand ( me: mutable; aValue: AsciiString from TCollection ); - SetComments ( me: mutable; aValue: AsciiString from TCollection ); - SetBackDraw ( me: mutable; aValue: AsciiString from TCollection ); - SetPaperFormat ( me: mutable; aValue: AsciiString from TCollection ); - SetColorMapping ( me: mutable; aValue: AsciiString from TCollection ); - SetOutputFormat ( me: mutable; aValue: AsciiString from TCollection ); - SetDriverType ( me: mutable; aValue: AsciiString from TCollection ); - - -------------------- SET BOOLEAN VALUES ---------------------- - SetMirrorPlot ( me: mutable; aValue: Boolean from Standard ); - SetMultiSheet ( me: mutable; aValue: Boolean from Standard ); - SetFramePlot ( me: mutable; aValue: Boolean from Standard ); - - SetPlotTitle ( me: mutable; aValue: Boolean from Standard ); - SetPlotComments ( me: mutable; aValue: Boolean from Standard ); - SetPlotBackDraw ( me: mutable; aValue: Boolean from Standard ); - - SetPlotterColor ( me: mutable; aValue: Boolean from Standard ); - SetEndOfPlotDriven ( me: mutable; aValue: Boolean from Standard ); - SetDryTimeDriven ( me: mutable; aValue: Boolean from Standard ); - SetPaperFeedDriven ( me: mutable; aValue: Boolean from Standard ); - SetMirrorDriven ( me: mutable; aValue: Boolean from Standard ); - SetCheckSumDriven ( me: mutable; aValue: Boolean from Standard ); - SetMediaSaverDriven ( me: mutable; aValue: Boolean from Standard ); - SetQualityDriven ( me: mutable; aValue: Boolean from Standard ); - SetCopyDriven ( me: mutable; aValue: Boolean from Standard ); - SetPaperCutDriven ( me: mutable; aValue: Boolean from Standard ); - SetRotateDriven ( me: mutable; aValue: Boolean from Standard ); - - SetCircleDriven ( me: mutable; aValue: Boolean from Standard ); - SetEllipseDriven ( me: mutable; aValue: Boolean from Standard ); - SetCurveDriven ( me: mutable; aValue: Boolean from Standard ); - SetTextDriven ( me: mutable; aValue: Boolean from Standard ); - SetMarkerDriven ( me: mutable; aValue: Boolean from Standard ); - SetRectangleDriven ( me: mutable; aValue: Boolean from Standard ); - SetFillDriven ( me: mutable; aValue: Boolean from Standard ); - SetPlottingColor ( me: mutable; aValue: Boolean from Standard ); - - ---------------------- SET REAL VALUES ----------------------- - SetPaperWidth ( me: mutable; aValue: Real from Standard ); - SetPaperLength ( me: mutable; aValue: Real from Standard ); - SetPaperSize ( me: mutable; aWidth, aLength : Real from Standard ); - SetHardMargins ( me: mutable; - aLeft, aTop, aRight, aBottom : Real from Standard ); - SetMargins ( me: mutable; - aLeft, aTop, aRight, aBottom : Real from Standard ); - SetHardMappings ( me: mutable; - aWOffset, aWScale : Real from Standard; - anLOffset, anLScale : Real from Standard ); - SetSpaceDrawing ( me: mutable; aValue: Real from Standard ); - SetPhysicalStep ( me: mutable; aValue: Real from Standard ); - SetMinWidthOfLine ( me: mutable; aValue: Real from Standard ); - SetWidthMaxGap ( me: mutable; aValue: Real from Standard ); - SetLineTypeMaxGap ( me: mutable; aValue: Real from Standard ); - SetResolution ( me: mutable; aValue: Real from Standard ); - SetColorResolution ( me: mutable; aValue: Real from Standard ); - SetFillWidth ( me: mutable; aValue: Real from Standard ); - - -------------------- SET INTEGER VALUES ---------------------- - SetMediaSaverDelay ( me: mutable; aValue: Integer from Standard ); - SetNumberOfCopies ( me: mutable; aValue: Integer from Standard ); - SetDryTime ( me: mutable; aValue: Integer from Standard ); - SetEndOfPlotTimer ( me: mutable; aValue: Integer from Standard ); - SetMaxColors ( me: mutable; aValue: Integer from Standard ); - SetMaxPatterns ( me: mutable; aValue: Integer from Standard ); - SetColorMaxGap ( me: mutable; aValue: Integer from Standard ); - SetLinearDensity ( me: mutable; aValue: Integer from Standard ); - SetStylusNumber ( me: mutable; aValue: Integer from Standard ); - SetPenMaxNumber ( me: mutable; aValue: Integer from Standard ); - SetNumberInCarrousel ( me: mutable; aValue: Integer from Standard ); - - ---------------------- SET ENUM VALUES ----------------------- - SetOrigin ( me: mutable; anOrigin : TypeOfOrigin from PlotMgt ); - SetQuality ( me: mutable; aQuality : TypeOfQuality from PlotMgt ); - SetImageFormat ( me: mutable; anImageFormat : ImageFormat from PlotMgt ); - SetPlottingType ( me: mutable; aPlottingType : PlottingType from PlotMgt ); - SetPaperFormat ( me: mutable; aPaperFormat : PaperFormat from PlotMgt ); - - ----------------------- MAP VALUES --------------------------- - SetPenColorIndex ( me: mutable; aTable: HSequenceOfInteger from TColStd ); - SetPenWidthIndex ( me: mutable; aTable: HSequenceOfInteger from TColStd ); - SetPenTypeIndex ( me: mutable; aTable: HSequenceOfInteger from TColStd ); - SetColorMap ( me: mutable; aColorMap : ColorMap from Aspect ); - SetWidthMap ( me: mutable; aWidthMap : WidthMap from Aspect ); - SetTypeMap ( me: mutable; aTypeMap : TypeMap from Aspect ); - SetFontMap ( me: mutable; aFontMap : FontMap from Aspect ); - -fields - myName : AsciiString from TCollection; - myModelName : AsciiString from TCollection; - mySystemName : AsciiString from TCollection; - myModelSystemName : AsciiString from TCollection; - myDirectDevice : Boolean from Standard; - myIsLoaded : Boolean from Standard; - myParameters : HListOfPlotterParameter from PlotMgt; - -- Strings for all 'string' parameters - myConfigVer : AsciiString from TCollection; - myModel : AsciiString from TCollection; - myTitle : AsciiString from TCollection; - myExtension : AsciiString from TCollection; - myBeforeCommand : AsciiString from TCollection; - myAfterCommand : AsciiString from TCollection; - myPrintCommand : AsciiString from TCollection; - myComments : AsciiString from TCollection; - myBackDraw : AsciiString from TCollection; - myColorMapping : AsciiString from TCollection; - myOutputFormat : AsciiString from TCollection; - myDriverType : AsciiString from TCollection; - -- Lists for all 'list_string' parameters - myListOfPaperFormats : HSequenceOfAsciiString from TColStd; - myListOfOrigins : HSequenceOfAsciiString from TColStd; - myListOfQualities : HSequenceOfAsciiString from TColStd; - myListOfImageFormats : HSequenceOfAsciiString from TColStd; - myListOfColorMappings : HSequenceOfAsciiString from TColStd; - myListOfOutputFormats : HSequenceOfAsciiString from TColStd; - myListOfDriverTypes : HSequenceOfAsciiString from TColStd; - -- ColorMap, WidthMap, TypeMap, FontMap, PenIndexTables - myPenColorIndex : HSequenceOfInteger from TColStd; - myPenWidthIndex : HSequenceOfInteger from TColStd; - myPenTypeIndex : HSequenceOfInteger from TColStd; - - myColorMap : GenericColorMap from Aspect; - myWidthMap : WidthMap from Aspect; - myTypeMap : TypeMap from Aspect; - myFontMap : FontMap from Aspect; - myAllFonts : FontMap from Aspect; - -end Plotter from PlotMgt; diff --git a/src/PlotMgt/PlotMgt_Plotter.cxx b/src/PlotMgt/PlotMgt_Plotter.cxx deleted file mode 100755 index b5b84de9d0..0000000000 --- a/src/PlotMgt/PlotMgt_Plotter.cxx +++ /dev/null @@ -1,597 +0,0 @@ -// Created by: DCB -// Copyright (c) 1998-1999 Matra Datavision -// Copyright (c) 1999-2012 OPEN CASCADE SAS -// -// The content of this file is subject to the Open CASCADE Technology Public -// License Version 6.5 (the "License"). You may not use the content of this file -// except in compliance with the License. Please obtain a copy of the License -// at http://www.opencascade.org and read it completely before using this file. -// -// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its -// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. -// -// The Original Code and all software distributed under the License is -// distributed on an "AS IS" basis, without warranty of any kind, and the -// Initial Developer hereby disclaims all such warranties, including without -// limitation, any warranties of merchantability, fitness for a particular -// purpose or non-infringement. Please see the License for the specific terms -// and conditions governing the rights and limitations under the License. - -// Contains Load()/Save() and all concerned methods - -#define BUC60766 //GG_140699/041000 -// Enable to use Direct drivers when required -// using or not the plotter parameters definition -// sets by DIRPLOT symbol for compatibillty only. - -#define TRACE 0 -#define MAX_LINE_LEN 1024 - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -//=============== Static definitions ==================== -static OSD_Environment& _DIRPLOT() { - static OSD_Environment DIRPLOT("DIRPLOT"); - return DIRPLOT; -} -#define DIRPLOT _DIRPLOT() - -static OSD_Environment& _DIRPARPLO() { - static OSD_Environment DIRPARPLO("DIRPARPLO"); - return DIRPARPLO; -} -#define DIRPARPLO _DIRPARPLO() - -#define INIT_VALUES() \ - myConfigVer = ""; \ - myModel = ""; \ - myTitle = ""; \ - myExtension = ""; \ - myBeforeCommand = ""; \ - myAfterCommand = ""; \ - myPrintCommand = ""; \ - myComments = ""; \ - myBackDraw = ""; \ - myColorMapping = ""; \ - myOutputFormat = ""; \ - myDriverType = ""; \ - myListOfPaperFormats.Nullify (); \ - myListOfOrigins.Nullify (); \ - myListOfQualities.Nullify (); \ - myListOfImageFormats.Nullify (); \ - myListOfColorMappings.Nullify (); \ - myListOfOutputFormats.Nullify (); \ - myListOfDriverTypes.Nullify (); \ - myPenColorIndex.Nullify (); \ - myPenWidthIndex.Nullify (); \ - myPenTypeIndex.Nullify (); \ - myColorMap.Nullify(); \ - myWidthMap.Nullify(); \ - myTypeMap.Nullify(); \ - myFontMap.Nullify(); \ - myAllFonts.Nullify(); - -#define RAISE_FILE_EXIST_ERROR(fExist,aName) \ -if (!(fExist)) { \ - anErrorString = "PlotMgt_Plotter::PlotMgt_Plotter ERROR => File '"; \ - anErrorString += aName; \ - anErrorString += "' not found in DIRPLOT='"; \ - anErrorString += DIRPLOT.Value (); \ - anErrorString += "' and in DIRPARPLO='"; \ - anErrorString += DIRPARPLO.Value (); \ - anErrorString += "'."; \ - cout << anErrorString.ToCString() << endl; \ -} -//GG PlotMgt_PlotterDefinitionError::Raise (anErrorString.ToCString()); - -#define STRING_TRIM(aString) \ - aString.LeftAdjust(); \ - aString.RightAdjust(); - -static TCollection_AsciiString aReturnValue; -static TCollection_AsciiString anEmptyString; -static TCollection_AsciiString anErrorString; - -//============================================================================== -static Standard_Boolean FILE_EXISTS (const TCollection_AsciiString& aName, - Standard_CString anExt, - TCollection_AsciiString& aFullName) -{ - OSD_Path aFullPath; - OSD_File aFile1 = OSD_File ( OSD_Path ( DIRPLOT.Value() + "/" + aName + anExt ) ); - OSD_File aFile2 = OSD_File ( OSD_Path ( DIRPARPLO.Value() + "/" + aName + anExt ) ); - if (aFile1.Exists ()) { - aFile1.Path (aFullPath); - aFullPath.SystemName (aFullName); - return Standard_True; - } - if (aFile2.Exists ()) { - aFile2.Path (aFullPath); - aFullPath.SystemName (aFullName); - return Standard_True; - } - aFullName = ""; - return Standard_False; -} - -//============================================================================== -// PlotMgt_Plotter::PlotMgt_Plotter -//============================================================================== -PlotMgt_Plotter::PlotMgt_Plotter (const TCollection_AsciiString& theName, - const Standard_Boolean fDirectDevice) -{ - TCollection_AsciiString aName = theName, aModel = "NEW_MODEL"; - aName.UpperCase (); - aModel.UpperCase (); -#ifdef BUC60766 - myDirectDevice = fDirectDevice; -#else -#ifndef WNT - myDirectDevice = Standard_False; -#else - myDirectDevice = fDirectDevice; -#endif -#endif //BUC60766 - myName = aName; - myModelName = aModel; -#ifndef BUC60766 - if (!myDirectDevice) -#endif - { - Standard_Boolean isModelExists = FILE_EXISTS(myModelName,".pmc",myModelSystemName); - Standard_Boolean isFileExists = FILE_EXISTS(myName,".plc",mySystemName) || - FILE_EXISTS(myName,".plc_off",mySystemName); - RAISE_FILE_EXIST_ERROR(isModelExists,myModelName); - RAISE_FILE_EXIST_ERROR(isFileExists,myName); - } - INIT_VALUES(); - myParameters = new PlotMgt_HListOfPlotterParameter (); - myIsLoaded = Load (); -} - -//============================================================================== -Standard_Boolean PlotMgt_Plotter::Load () -{ - Standard_Boolean fRetVal1 = Standard_True, - fRetVal2 = Standard_True; -#ifndef BUC60766 - if (!myDirectDevice) -#endif - { - myParameters -> Clear (); - // Read parameters from file - fRetVal1 = ReadParametersFromFile (myModelSystemName, Standard_False); - if (fRetVal1) { - // PAR file contains all possible FontMap items - // We have to remember them in myAllFonts fontmap -// myAllFonts = this -> FontMap (); -// myFontMap.Nullify (); - // Further, we read PLO file - fRetVal2 = ReadParametersFromFile (mySystemName, Standard_True); - } - } - return (fRetVal1 && fRetVal2); -} - -//============================================================================ -Standard_Boolean PlotMgt_Plotter::NeedToBeSaved () const -{ -#ifndef BUC60766 - if (!myDirectDevice) -#endif - { - Standard_Integer i, n = myParameters -> Length (); -// Standard_Boolean fSave = Standard_False;; - // Check if we need to save - for (i = 1; i <= n; i++) { - if (myParameters -> Value(i) -> NeedToBeSaved()) - return Standard_True; - } - } - return Standard_False; -} - -//============================================================================== -Standard_Boolean PlotMgt_Plotter::SavePlotter () -{ - Standard_Integer i, n = myParameters -> Length (); - // Create new file and save plotter to it - TCollection_AsciiString aLine; - OSD_File aFile = OSD_File (mySystemName); - OSD_Protection aProtection; - Standard_Boolean fSave; - // Create new file (or empty old one) - aFile.Build (OSD_WriteOnly, aProtection); - // Build and put starting comments - aLine = "! This is a '"; aLine += myName; aLine += "' plotter file\n"; - aFile.Write (aLine, aLine.Length ()); - fSave = !aFile.Failed (); - // Write all parameters - for (i = 1; i <= n && fSave; i++) - fSave = myParameters -> Value(i) -> Save (aFile); - // Build and put comments at the end - if (fSave) { - aLine = "! End of '"; aLine += myName; aLine += "' plotter file\n"; - aFile.Write (aLine, aLine.Length ()); - } - // Close file - aFile.Close (); - return (fSave && !aFile.Failed ()); -} - -//============================================================================== -Standard_Boolean PlotMgt_Plotter::Save () -{ - // Save if necessary - if (NeedToBeSaved ()) { - // Rename old file - OSD_Path anOldPath (mySystemName); - anOldPath.SetExtension (".plc_old"); - OSD_File anOldFile = OSD_File (mySystemName); - anOldFile.Move (anOldPath); - // Save plotter to the name. - return SavePlotter (); - } - return Standard_False; -} - -//============================================================================== -Standard_Boolean PlotMgt_Plotter::SaveAs (const TCollection_AsciiString& aNewName) -{ - // Save if necessary - if (NeedToBeSaved ()) { - // Set new name (system name) for the plotter - myName = aNewName; - myName.UpperCase (); - mySystemName = DIRPARPLO.Value () + "/" + myName + ".plc"; - // Save plotter to the new name. - return SavePlotter (); - } - return Standard_False; -} - -//============================================================================== -Standard_Boolean PlotMgt_Plotter::CheckConfig (const Standard_Boolean /*theViewIs2D*/) -{ -/* - if (!myIsLoaded) - return Standard_False; - - TCollection_AsciiString aModel = Model (); - TCollection_AsciiString aOutFormat = OutputFormat (); - PlotMgt_ImageFormat anImgFormat = ImageFormat (); - if (aModel.IsEqual("direct_hpgl2")) { // HPGL2_Driver - // direct_hpgl2, dhpgl2, {ENABLE | DISABLE(2D)} - return Standard_True; - } else if (aModel.IsEqual("direct_ps")) { // PS_Driver - // direct_ps, DPS, {ENABLE | DISABLE(2D)} - if (!aOutFormat.IsEqual("DPS") || - (anImgFormat != PlotMgt_IF_DISABLE && anImgFormat != PlotMgt_IF_ENABLE)) - { - BAD_PLOTTER_MSG(); - return Standard_False; - } - if (anImgFormat == PlotMgt_IF_DISABLE && !theViewIs2D) - { - BAD_PLOTTER_MSG(); - return Standard_False; - } - } else if (aModel.IsEqual("direct_cgm")) { // CGM_Driver - // direct_cgm, DCGM, {ENABLE | DISABLE(2D)} - if (!aOutFormat.IsEqual("DCGM") || - (anImgFormat != PlotMgt_IF_DISABLE && anImgFormat != PlotMgt_IF_ENABLE)) - { - BAD_PLOTTER_MSG(); - return Standard_False; - } - if (anImgFormat == PlotMgt_IF_DISABLE && !theViewIs2D) - { - BAD_PLOTTER_MSG(); - return Standard_False; - } - } else if (aModel.IsEqual("hp")) { // E3Plot_Driver - // hp, hpgl, DISABLE(2D) - if (!aOutFormat.IsEqual("hpgl") || anImgFormat != PlotMgt_IF_DISABLE || - !theViewIs2D) - { - BAD_PLOTTER_MSG(); - return Standard_False; - } - } else if (aModel.IsEqual("direct_img")) { // ScreenCopy_Driver - // direct_img, DISABLE, {XWD | BMP | GIF} - if (!aOutFormat.IsEqual("DISABLE") || - (anImgFormat != PlotMgt_IF_XWD && anImgFormat != PlotMgt_IF_BMP && - anImgFormat != PlotMgt_IF_GIF)) - { - BAD_PLOTTER_MSG(); - return Standard_False; - } - } - // Default - if (!theViewIs2D && anImgFormat == PlotMgt_IF_DISABLE) - return Standard_False; - return Standard_True; -*/ - return Standard_True; -} - -//============================================================================== -// List all plotters (.plc and ,plc_off files ) in DIRPARPLO and DIRPLOT -// directories (if specified). -//============================================================================== -Handle(TColStd_HSequenceOfAsciiString) PlotMgt_Plotter::ListPlotters ( - const Standard_Boolean anActiveOnly) -{ - Handle(TColStd_HSequenceOfAsciiString) aListOfPlotters = - new TColStd_HSequenceOfAsciiString (); - OSD_Path aDirPlotPath = DIRPLOT.Value (), - aDirParPloPath = DIRPARPLO.Value (); - OSD_FileIterator actDirPlot (aDirPlotPath, "*.plc" ), - actDirParPlo (aDirParPloPath, "*.plc" ), - inactDirPlot (aDirPlotPath, "*.plc_off"), - inactDirParPlo (aDirParPloPath, "*.plc_off"); - // Firstly list plotters in DIRPARPLO - FillListByIterator (aListOfPlotters, actDirParPlo, ".plc"); - if (!anActiveOnly) - FillListByIterator (aListOfPlotters, inactDirParPlo, ".plc_off"); - // Second step : list plotters in DIRPLOT, skip plotters found in DIRPARPLO - FillListByIterator (aListOfPlotters, actDirPlot, ".plc", Standard_True); - if (!anActiveOnly) - FillListByIterator (aListOfPlotters, inactDirPlot, ".plc_off", Standard_True); - return aListOfPlotters; -} - -//============================================================================== -Standard_Integer PlotMgt_Plotter::FindParameter (const TCollection_AsciiString& aName) -{ - Standard_Integer i, n = NumberOfParameters (); - for (i = 1; i <= n; i++) { - if (myParameters -> Value(i) -> Name().IsEqual(aName) || - myParameters -> Value(i) -> OldName().IsEqual(aName)) - return i; - } - return 0; -} - -//============================================================================== -void PlotMgt_Plotter::Dump () -{ - cout << "Plotter '" << Name() << "' dump:\n" << flush; - cout << "=================================================\n" << flush; - Standard_Integer n = NumberOfParameters (); - for (Standard_Integer i = 1; i <= n; i++) - myParameters -> Value (i) -> Dump (); - cout << "=================================================\n" << flush; - cout << "End of dump plotter '" << Name() << "'\n" << flush; -} - -//============================================================================== -Standard_Boolean PlotMgt_Plotter::ReadParametersFromFile ( - const TCollection_AsciiString& aFileName, - const Standard_Boolean fChangeState) -{ - OSD_File aFile = OSD_File (OSD_Path (aFileName)); - OSD_Protection aProtection (OSD_R, OSD_R, OSD_R, OSD_R); - Standard_Integer nBytes, idx, n, i; -// Standard_CString aSeparator = ":"; -// Standard_CString aDelimiter = "."; - TCollection_AsciiString aLine; - TCollection_AsciiString aParam; - TCollection_AsciiString aParamName; - TCollection_AsciiString aParamDef; - TCollection_AsciiString aValue; - TCollection_AsciiString aDescLine; - Handle(PlotMgt_PlotterParameter) aParameter; - aParameter.Nullify (); - if (!aFile.Exists ()) { -// cout << "PlotMgt_Plotter::ReadParametersFromFile() -> '" << aFileName -// << "' could not be found." << endl << flush; - return Standard_False; - } - aFile.Open (OSD_ReadOnly, aProtection); - while (!aFile.IsAtEnd ()) { - aFile.ReadLine (aLine, MAX_LINE_LEN, nBytes); - // Remove all spaces at the begin and end of line - STRING_TRIM(aLine); - if (aLine.IsEmpty ()) - continue; - // If the line is a comment, skip it - if (aLine.Value(1) == '!') - continue; - // Parse the line to : - if (aLine.Search (":") == -1) { - cout << "See line '" << aLine << "'. There is error in it (':' not found)." << endl << flush; - continue; - } - aParam = aLine.Token (":", 1); - aLine.Remove (1, aParam.Length() + 1); // ':' also - aValue = aLine; - STRING_TRIM(aParam); - STRING_TRIM(aValue); - idx = aParam.Search ("."); - if (idx == -1) { - // contains only parameter name - aParamName = aParam; - aParamDef = ""; - } else { - // is ., where is one of the: - // "Type", "Values", "Dialog", "Length". - aParamName = aParam.Token (".", 1); - aParamDef = aParam.Token (".", 2); - STRING_TRIM(aParamName); - STRING_TRIM(aParamDef); - aParamDef.Prepend (TCollection_AsciiString (".")); - } - if ((idx = FindParameter(aParamName))) { - aParameter = myParameters -> Value (idx); - } else { - aParameter = new PlotMgt_PlotterParameter (aParamName); - myParameters -> Append (aParameter); - } - // is false, if we read PAR file and is true if - // we read PLO file. - aParameter -> SetState (fChangeState); - // Check if it's a '.Type' - if (aParamDef.IsEqual (_TYPE_SIGN)) { - aParameter -> SetType (PlotMgt::TypeFromString(aValue)); - } else { - aLine = aParamName; - if (aParamDef != ".") - aLine += aParamDef; - aLine += _DELIM_SIGN; - aLine += aValue; - aParameter -> Description () -> Append (aLine); - } - } - aFile.Close (); - // Normalize parameters - if (fChangeState) { - n = NumberOfParameters (); - for (i = 1; i <= n; i++) - myParameters -> Value (i) -> Normalize (); - } - return Standard_True; -} - -//============================================================================== -//============================================================================== -//============================================================================== -void PlotMgt_Plotter::GetStringValue (const Standard_CString aParam, - TCollection_AsciiString& aValue) -{ - Standard_Integer anIndex = FindParameter (aParam); - if (anIndex >= 1 && anIndex <= NumberOfParameters ()) - myParameters -> Value (anIndex) -> SValue (aValue); -} - -//============================================================================== -Standard_Boolean PlotMgt_Plotter::GetBooleanValue (const Standard_CString aParam) -{ - Standard_Integer anIndex = FindParameter (aParam); - if (anIndex >= 1 && anIndex <= NumberOfParameters ()) - return myParameters -> Value (anIndex) -> BValue (); - return Standard_False; -} - -//============================================================================== -Standard_Integer PlotMgt_Plotter::GetIntegerValue (const Standard_CString aParam) -{ - Standard_Integer anIndex = FindParameter (aParam); - if (anIndex >= 1 && anIndex <= NumberOfParameters ()) - return myParameters -> Value (anIndex) -> IValue (); - return 0; -} - -//============================================================================== -Standard_Real PlotMgt_Plotter::GetRealValue (const Standard_CString aParam) -{ - Standard_Integer anIndex = FindParameter (aParam); - if (anIndex >= 1 && anIndex <= NumberOfParameters ()) - return myParameters -> Value (anIndex) -> RValue (); - return 0.0; -} - -//============================================================================== -void PlotMgt_Plotter::GetListValue (const Standard_CString aParam, - Handle(TColStd_HSequenceOfAsciiString)& aList) -{ - Standard_Integer anIndex = FindParameter (aParam); - if (anIndex >= 1 && anIndex <= NumberOfParameters ()) - myParameters -> Value (anIndex) -> LValues (aList); -} - -//============================================================================== -void PlotMgt_Plotter::GetIntTable (const Standard_CString aParam, - Handle(TColStd_HSequenceOfInteger)& aTable) -{ - TCollection_AsciiString aLine; - Handle(TColStd_HSequenceOfAsciiString) aMap; - aMap.Nullify (); - aTable = new TColStd_HSequenceOfInteger (); - Standard_Integer i = FindParameter (aParam), n; - if (i >= 1 && i <= NumberOfParameters ()) - aMap = myParameters -> Value (i) -> MValue (); - if (!aMap.IsNull()) { - n = aMap -> Length (); - for (i = 1; i <= n; i++) { - aLine = aMap -> Value (i); - aLine.RemoveAll (' '); - aTable -> Append ( - (!aLine.IsEmpty () && aLine.IsIntegerValue ()) ? - aLine.IntegerValue () : 1); - } - } -} - -//============================================================================== -//============================================================================== -//============================================================================== -void PlotMgt_Plotter::SetStringValue (const Standard_CString aParam, - TCollection_AsciiString& anOldValue, - const TCollection_AsciiString& aNewValue) -{ - if (anOldValue != aNewValue) { - anOldValue = aNewValue; - Standard_Integer anIndex = FindParameter (aParam); - if (anIndex >= 1 && anIndex <= NumberOfParameters ()) - myParameters -> Value (anIndex) -> SetSValue (aNewValue); - } -} - -//============================================================================== -void PlotMgt_Plotter::SetBooleanValue (const Standard_CString aParam, - const Standard_Boolean aValue) -{ - Standard_Integer anIndex = FindParameter (aParam); - if (anIndex >= 1 && anIndex <= NumberOfParameters ()) { - if (myParameters -> Value (anIndex) -> BValue () != aValue) - myParameters -> Value (anIndex) -> SetBValue (aValue); - } -} - -//============================================================================== -void PlotMgt_Plotter::SetIntegerValue (const Standard_CString aParam, - const Standard_Integer aValue) -{ - Standard_Integer anIndex = FindParameter (aParam); - if (anIndex >= 1 && anIndex <= NumberOfParameters ()) { - if (myParameters -> Value (anIndex) -> IValue () != aValue) - myParameters -> Value (anIndex) -> SetIValue (aValue); - } -} - -//============================================================================== -void PlotMgt_Plotter::SetRealValue (const Standard_CString aParam, - const Standard_Real aValue) -{ - Standard_Integer anIndex = FindParameter (aParam); - if (anIndex >= 1 && anIndex <= NumberOfParameters ()) { - if (myParameters -> Value (anIndex) -> RValue () != aValue) - myParameters -> Value (anIndex) -> SetRValue (aValue); - } -} - -//============================================================================== -void PlotMgt_Plotter::SetIntTable (const Standard_CString aParam, - const Handle(TColStd_HSequenceOfInteger)& aTable) -{ - Standard_Integer anIndex = 0; - Standard_Integer i, n ; - anIndex = FindParameter (aParam) ; - n = aTable -> Length (); - if (anIndex >= 1 && anIndex <= NumberOfParameters ()) { - Handle(TColStd_HSequenceOfAsciiString) aMap = new TColStd_HSequenceOfAsciiString (); - for (i = 1; i <= n; i++) - aMap -> Append (aTable -> Value (i)); - myParameters -> Value (anIndex) -> SetMValue (aMap); - } -} diff --git a/src/PlotMgt/PlotMgt_PlotterDriver.cdl b/src/PlotMgt/PlotMgt_PlotterDriver.cdl deleted file mode 100755 index 733dd10dd6..0000000000 --- a/src/PlotMgt/PlotMgt_PlotterDriver.cdl +++ /dev/null @@ -1,790 +0,0 @@ --- Created on: 1998-11-25 --- Created by: DCB --- Copyright (c) 1998-1999 Matra Datavision --- Copyright (c) 1999-2012 OPEN CASCADE SAS --- --- The content of this file is subject to the Open CASCADE Technology Public --- License Version 6.5 (the "License"). You may not use the content of this file --- except in compliance with the License. Please obtain a copy of the License --- at http://www.opencascade.org and read it completely before using this file. --- --- The Initial Developer of the Original Code is Open CASCADE S.A.S., having its --- main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. --- --- The Original Code and all software distributed under the License is --- distributed on an "AS IS" basis, without warranty of any kind, and the --- Initial Developer hereby disclaims all such warranties, including without --- limitation, any warranties of merchantability, fitness for a particular --- purpose or non-infringement. Please see the License for the specific terms --- and conditions governing the rights and limitations under the License. - --- Updated: GG 03/10/00 BUC60766 The Close() method can be used for freeing --- the opened file and must be declared accessible by any client. - -deferred class PlotterDriver from PlotMgt inherits Driver from Aspect - -uses - PlaneAngle from Quantity, - Factor from Quantity, - Ratio from Quantity, - Length from Quantity, - ColorMap from Aspect, - TypeMap from Aspect, - WidthMap from Aspect, - MarkMap from Aspect, - FontMap from Aspect, - ExtendedString from TCollection, - TypeOfText from Aspect, - TypeOfColorSpace from Aspect, - TypeOfPrimitive from Aspect, - PlotMode from Aspect, - FStream from Aspect, - Plotter from PlotMgt, - HListOfMFTFonts from PlotMgt, - HArray1OfShortReal from TShort, - TextManager from PlotMgt, - AsciiString from TCollection, - Array1OfShortReal from TShort - - -is - Initialize (aPlotter : Plotter from PlotMgt; - aFileName : CString from Standard; - fCreateFile : Boolean from Standard = Standard_False); - ---Level: Private - - Initialize (aFileName : CString from Standard; - fCreateFile : Boolean from Standard = Standard_False); - ---Level: Private - - BeginDraw (me: mutable) - is deferred; - ---Level: Public - ---Purpose: Begins a new page of graphics in the plotter file name. - - Close (me: mutable) --- is virtual protected; - is virtual; - ---C++: alias ~ - ---Level: Internal - - Spool (me : mutable; - aPlotMode : PlotMode from Aspect = Aspect_PM_FILEONLY; - aReserved1 : CString from Standard = NULL; - aReserved2 : Boolean from Standard = Standard_False) - returns Boolean from Standard - is virtual; - ---Purpose: - ---Level: Public - - ---------------------------------------------------------- - -- Category: Methods to create the attributes which the - -- driver can manage itself - ---------------------------------------------------------- - CreateDriverColorMap (me: mutable) - is virtual protected; - ---Category: Methods to define standard ColorIndexs - ---Level: Private - - CreateDriverTypeMap (me: mutable) - is virtual protected; - ---Category: Methods to define standard TypeIndexs - ---Level: Private - - CreateDriverWidthMap (me: mutable) - is virtual protected; - ---Category: Methods to define standard WidthIndexs - ---Level: Private - - CreateDriverMarkMap (me: mutable) - is virtual protected; - ---Category: Methods to define standard MarkIndexs - ---Level: Private - - --------------------------------------------- - -- Category: Methods to define the attributes - --------------------------------------------- - InitializeColorMap (me: mutable; aColorMap: ColorMap from Aspect) - is virtual protected; - ---Category: Methods to define the ColorIndexs - ---Level: Private - - InitializeTypeMap (me: mutable; aTypeMap: TypeMap from Aspect) - is virtual protected; - ---Category: Methods to define the TypeIndexs - ---Level: Private - - InitializeWidthMap (me: mutable; aWidthMap: WidthMap from Aspect) - is virtual protected; - ---Category: Methods to define the WidthIndexs - ---Level: Private - - InitializeFontMap (me: mutable; aFontMap: FontMap from Aspect) - is virtual protected; - ---Category: Methods to define the FontIndexs - ---Level: Private - - InitializeMarkMap (me: mutable; aFontMap: MarkMap from Aspect) - is virtual protected; - ---Category: Methods to define the MarkIndexs - ---Level: Private - - ------------------------------------ - -- Methods to set graphic attributes - ------------------------------------ - SetLineAttrib (me: mutable; - ColorIndex: Integer from Standard; - TypeIndex: Integer from Standard; - WidthIndex: Integer from Standard) - is virtual; - ---Category: Methods to define the Current Line Attibutes - ---Level: Public - - SetTextAttrib (me: mutable; - ColorIndex: Integer from Standard; - FontIndex: Integer from Standard) - is virtual; - ---Category: Methods to define the Current Text Attributes - ---Level: Public - - SetTextAttrib (me: mutable; - ColorIndex: Integer from Standard; - FontIndex: Integer from Standard; - aSlant: PlaneAngle from Quantity; - aHScale: Factor from Quantity; - aWScale: Factor from Quantity; - isUnderlined: Boolean from Standard = Standard_False) - is virtual; - ---Category: Methods to define the Current Extended Text Attributes - ---Level: Public - - SetPolyAttrib (me: mutable; - ColorIndex: Integer from Standard; - TileIndex: Integer from Standard; - DrawEdge: Boolean from Standard = Standard_False) - is virtual; - ---Category: Methods to set the poly attributes - ---Level: Public - - SetMarkerAttrib (me: mutable; - ColorIndex: Integer from Standard; - WidthIndex: Integer from Standard; - FillMarker: Boolean from Standard = Standard_False) - is virtual; - ---Category: Methods to define the Current Marker Attributes - ---Level: Public - - SetPixelSize (me: mutable ; aSize: Real from Standard) - is static; - ---Purpose: - ---Level: Public - - SetPlotter (me: mutable; aPlotter: Plotter from PlotMgt) - is static protected; - ---Purpose: Set the plotter to be used by Spool() method. - -- Fail if Plotter is already defined - ---Level: Public - - -------------------------------- - -- Actual set graphic attributes - -------------------------------- - PlotLineAttrib (me: mutable; - ColorIndex: Integer from Standard; - TypeIndex: Integer from Standard; - WidthIndex: Integer from Standard) - is virtual protected; - ---Purpose: retrieve current line attributes - ---Level: Private - - PlotPolyAttrib (me: mutable; - ColorIndex: Integer from Standard; - TileIndex: Integer from Standard; - DrawEdge: Boolean from Standard) - is virtual protected; - ---Purpose: retrieve current poly attributes - ---Level: Private - - ------------------------------------------------- - -- Incremental methods to draw graphic primitives - ------------------------------------------------- - BeginPolyline (me : mutable; aNumber : Integer) - is virtual; - ---Purpose: Begin an incremental polyline primitive of of points . - -- Warning: Points must be added by the the DrawPoint() method. - ---Level: Public - - BeginPolygon (me : mutable; aNumber : Integer) - is virtual; - ---Purpose: Begin an incremental polygon primitive of of points . - -- Warning: Points must be added by the the DrawPoint() method. - ---Level: Public - - BeginSegments (me : mutable) - is virtual; - ---Purpose: Begin a set of segments. - -- Warning: Segments must be added by the DrawSegment() method. - ---Level: Public - - BeginArcs (me : mutable) - is virtual; - ---Purpose: Begin a set of circles or ellipses. - -- Warning: Arcs must be added by the DrawArc() methods. - ---Level: Public - - BeginPolyArcs (me : mutable) - is virtual; - ---Purpose: Begin a set of polygon circles or ellipses. - -- Warning: Arcs must be added by the DrawPolyArc() methods. - ---Level: Public - - BeginMarkers (me : mutable) - is virtual; - ---Purpose: Begin a set of markers. - -- Warning: Markers must be added by the DrawMarker() method. - ---Level: Public - - BeginPoints (me : mutable) - is virtual; - ---Purpose: Begin a set of points. - -- Warning: Points must be added by the DrawPoint() method. - ---Level: Public - - ClosePrimitive (me : mutable) - is virtual; - ---Purpose: Close the last Begining primitive - ---Level: Public - - ----------------------------------------- - -- Category: Methods to manage the images - ----------------------------------------- - IsKnownImage(me: mutable; anImage: Transient from Standard) - returns Boolean from Standard is virtual; - ---Purpose: - ---Level: Public - - SizeOfImageFile (me; anImageFile: CString from Standard; - aWidth,aHeight: out Integer from Standard) - returns Boolean from Standard is virtual; - ---Purpose: Returns Standard_True and the Image Size in PIXEL - -- if the image file exist and can be computed by the driver, - ---Category: Methods to manage the images - ---Level: Public - - ClearImage (me: mutable; anImageId: Transient from Standard) - is virtual; - ---Purpose: - ---Level: Public - - ClearImageFile (me: mutable; anImageFile: CString from Standard) - is virtual; - ---Purpose: Clears the image associated with the image file . - ---Category: Methods to manage the images - ---Level: Public - - DrawImage (me: mutable; anImageId: Transient from Standard; - aX, aY: ShortReal from Standard) - is virtual; - ---Purpose: Draws the image in . - -- , is the center of the image. - -- Image center must be defined in DPU space. - ---Category: Methods to manage the images - ---Level: Public - - DrawImageFile (me: mutable; anImageFile: CString from Standard; - aX, aY: ShortReal from Standard; - aScale: Factor from Quantity = 1.0) - is virtual; - ---Purpose: Draws the image file in . - -- , is the center of the image. - -- Image center must be defined in DPU space. - ---Category: Methods to manage the images - ---Level: Public - - FillAndDrawImage (me: mutable; anImageId: Transient from Standard; - aX, aY: ShortReal from Standard; - aWidth, aHeight: Integer from Standard; - anArrayOfPixels: Address from Standard) - is virtual; - ---Purpose: Draw a complete image . - -- Image size must be defined in DPU space> - ---Category: Methods to manage the images - ---Level: Public - - - FillAndDrawImage (me: mutable; anImageId: Transient from Standard; - aX, aY: ShortReal from Standard; - anIndexOfLine, aWidth, aHeight: Integer from Standard; - anArrayOfPixels: Address from Standard) - is virtual; - ---Purpose: Fills a line of the Image . - ---Category: Methods to manage the images - ---Level: Public - - ------------------------------------- - -- Methods to draw graphic primitives - ------------------------------------- - DrawPoint (me : mutable; X, Y: ShortReal from Standard) - is static; - ---Purpose: Draws a 1 PIXEL point depending of the SetMarkerAttrib() - --color attribute or add a point depending of the incremental BeginXxxxxx() - --primitive used. - ---Category: Methods to draw primitives - ---Level: Public - - - DrawSegment (me : mutable; - X1, Y1: ShortReal from Standard; - X2, Y2: ShortReal from Standard) - is static; - ---Purpose: Draw a segment depending of the SetLineAttrib() attributes. - ---Category: Methods to draw primitives - ---Level: Public - - - DrawRectangle (me : mutable; aX,aY : ShortReal from Standard; - aDX,aDY : ShortReal from Standard) - is static; - ---Purpose: Draw a rectangle. aX,aY is start point - -- aDX , aDY are horizontal and vertical dimensions - ---Level: Public - - - DrawPolyline (me : mutable; - aListX, aListY: Array1OfShortReal from TShort) - is static; - ---Purpose: Draw a polyline depending of the SetLineAttrib() attributes. - ---Category: Methods to draw primitives - ---Level: Public - - - DrawPolygon (me : mutable; - aListX, aListY: Array1OfShortReal from TShort) - is static; - ---Purpose: Draw a polygon depending of the SetPolyAttrib() attributes. - ---Category: Methods to draw primitives - ---Level: Public - - - DrawArc (me : mutable; X,Y : ShortReal from Standard; - anXradius,anYradius : ShortReal from Standard; - aStartAngle: ShortReal from Standard = 0.0; - anOpenAngle: ShortReal from Standard = 6.283185) - returns Boolean from Standard - is static; - ---Purpose: Draws an Ellipsoid arc of center and Radius - -- of relative angle from - --the base angle and depending of the SetLineAttrib() attributes. - -- Warning: Returns FALSE if the hardware can't drawing this - --primitive properly,application must to simulate it. - ---Category: Methods to draw primitives - ---Level: - - - DrawPolyArc (me : mutable; X,Y : ShortReal from Standard; - anXradius,anYradius : ShortReal from Standard; - aStartAngle: ShortReal from Standard = 0.0; - anOpenAngle: ShortReal from Standard = 6.283185) - returns Boolean from Standard - is static; - ---Purpose: Draws an filled Ellipsoid arc of center and Radius - -- of relative angle from - --the base angle and depending of the SetPolyAttrib() attributes. - -- Warning: Returns FALSE if the hardware can't drawing this - --primitive properly,application must to simulate it. - ---Category: Methods to draw primitives - ---Level: Public - - - DrawMarker (me : mutable; - aMarker: Integer from Standard; - Xpos: ShortReal from Standard; - Ypos: ShortReal from Standard; - Width: ShortReal from Standard; - Height: ShortReal from Standard; - Angle: ShortReal from Standard = 0.0) - is static; - ---Purpose: Draws the marker - --depending of the SetMarkerAttrib() attributes. - -- Warning: Coordinates and sizes must be defined in DWU space. - -- Angle must be defined in RADIAN. - -- A one pixel marker is drawn when aMarker index is undefined. - ---Category: Methods to draw primitives - ---Level: Public - - - DrawText (me : mutable; - aText: ExtendedString from TCollection; - Xpos: ShortReal from Standard; - Ypos: ShortReal from Standard; - anAngle: ShortReal from Standard = 0.0; - aType: TypeOfText from Aspect = Aspect_TOT_SOLID) - is static; - ---Purpose: Draws a text depending of the SetTextAttrib() attributes. - -- Warning: Coordinates must be defined in DWU space. - ---Category: Methods to draw primitives - ---Level: Public - - - DrawText (me : mutable; - aText: CString from Standard; - Xpos: ShortReal from Standard; - Ypos: ShortReal from Standard; - anAngle: ShortReal from Standard = 0.0; - aType: TypeOfText from Aspect = Aspect_TOT_SOLID) - is static; - ---Purpose: Draws a text depending of the SetTextAttrib() attributes. - -- Warning: Coordinates must be defined in DWU space. - ---Category: Methods to draw primitives - ---Level: Public - - - DrawPolyText (me : mutable; - aText: ExtendedString from TCollection; - Xpos: ShortReal from Standard; - Ypos: ShortReal from Standard; - aMargin: Ratio from Quantity = 0.1; - anAngle: ShortReal from Standard = 0.0; - aType: TypeOfText from Aspect = Aspect_TOT_SOLID) - is static; - ---Purpose: Draws an framed text depending of the - -- SetTextAttrib() and SetPolyAttrib() attributes. - -- Warning: Coordinates must be defined in DWU space. - -- defines the ratio of the space between the - -- polygon borders and the bounding box of the text and - -- depending of the height of the text. - ---Category: Methods to draw primitives - ---Level: Public - - - DrawPolyText (me : mutable; - aText: CString from Standard; - Xpos: ShortReal from Standard; - Ypos: ShortReal from Standard; - aMargin: Ratio from Quantity = 0.1; - anAngle: ShortReal from Standard = 0.0; - aType: TypeOfText from Aspect = Aspect_TOT_SOLID) - is static; - ---Purpose: Draws an framed text depending of the - -- SetTextAttrib() and SetPolyAttrib() attributes. - -- Warning: Coordinates must be defined in DWU space. - -- defines the ratio of the space between the - -- polygon borders and the bounding box of the text and - -- depending of the height of the text. - ---Category: Methods to draw primitives - ---Level: Public - - - -------------------------------------------------- - -- Private plot methods to draw graphic primitives - -------------------------------------------------- - PlotPoint (me : mutable; X, Y: ShortReal from Standard) - returns Boolean from Standard - is virtual protected; - ---Purpose: - ---Category: - ---Level: Private - - - PlotSegment (me : mutable; - X1, Y1: ShortReal from Standard; - X2, Y2: ShortReal from Standard) - returns Boolean from Standard - is virtual protected; - ---Purpose: - ---Category: - ---Level: Private - - - PlotRectangle (me : mutable; aX,aY : ShortReal from Standard; - aDX,aDY : ShortReal from Standard; - aAngle: ShortReal from Standard = 0.0) - returns Boolean - is virtual protected; - ---Purpose: - ---Category: - ---Level: Private - - - PlotPolyline (me : mutable; - xArray : Address from Standard; - yArray : Address from Standard; - nPts : Address from Standard; - nParts : Integer from Standard) - returns Boolean from Standard - is virtual protected; - ---Purpose: - ---Category: - ---Level: Private - - - PlotPolygon (me : mutable; - xArray : Address from Standard; - yArray : Address from Standard; - nPts : Address from Standard; - nParts : Integer from Standard) - returns Boolean from Standard - is virtual protected; - ---Purpose: - ---Category: - ---Level: Private - - - PlotArc (me : mutable; X,Y : ShortReal from Standard; - anXradius,anYradius : ShortReal from Standard; - sAngle: ShortReal from Standard; - oAngle: ShortReal from Standard) - returns Boolean from Standard - is virtual protected; - ---Purpose: - ---Category: - ---Level: Private - - - PlotPolyArc (me : mutable; X,Y : ShortReal from Standard; - anXradius,anYradius : ShortReal from Standard; - sAngle: ShortReal from Standard; - oAngle: ShortReal from Standard) - returns Boolean from Standard - is virtual protected; - ---Purpose: - ---Category: - ---Level: Private - - - PlotMarker (me : mutable; - aMarker: Integer from Standard; - Xpos: ShortReal from Standard; - Ypos: ShortReal from Standard; - Width: ShortReal from Standard; - Height: ShortReal from Standard; - Angle: ShortReal from Standard) - returns Boolean from Standard - is virtual protected; - ---Purpose: - ---Category: - ---Level: Private - - - PlotText (me : mutable; - aText: ExtendedString from TCollection; - Xpos: ShortReal from Standard; - Ypos: ShortReal from Standard; - anAngle: ShortReal from Standard; - aType: TypeOfText from Aspect) - returns Boolean from Standard - is virtual protected; - ---Purpose: - ---Category: - ---Level: Private - - - PlotText (me : mutable; - aText: CString from Standard; - Xpos: ShortReal from Standard; - Ypos: ShortReal from Standard; - anAngle: ShortReal from Standard; - aType: TypeOfText from Aspect) - returns Boolean from Standard - is virtual protected; - ---Purpose: - ---Category: - ---Level: Private - - - PlotPolyText (me : mutable; - aText: ExtendedString from TCollection; - Xpos: ShortReal from Standard; - Ypos: ShortReal from Standard; - aMargin: Ratio from Quantity; - anAngle: ShortReal from Standard; - aType: TypeOfText from Aspect) - returns Boolean from Standard - is virtual protected; - ---Purpose: - ---Category: - ---Level: Private - - - PlotPolyText (me : mutable; - aText: CString from Standard; - Xpos: ShortReal from Standard; - Ypos: ShortReal from Standard; - aMargin: Ratio from Quantity; - anAngle: ShortReal from Standard; - aType: TypeOfText from Aspect) - returns Boolean from Standard - is virtual protected; - ---Purpose: - ---Category: - ---Level: Private - - - PlotImage (me: mutable; - aX, aY, aWidth: ShortReal from Standard; - aHeight, aScale: ShortReal from Standard; - anImageFile: CString from Standard; - anArrayOfPixels: Address from Standard; - aLineIndex: Integer from Standard = -1) - returns Boolean from Standard - is virtual protected; - ---Purpose: - ---Category: - ---Level: Private - - - ---------------------------------------------------- - --- Inquire methods - ---------------------------------------------------- - Plotter (me) - returns Plotter from PlotMgt; - ---Purpose: - ---Category: Inquire methods - ---Level: Public - - Cout (me) - returns FStream from Aspect - is static protected; - ---Purpose: - ---Category: Inquire methods - ---Level: Public - - PlotFileName (me) - returns AsciiString from TCollection; - ---Purpose: - ---Category: Inquire methods - ---Level: Public - - DrawingName (me) - returns AsciiString from TCollection; - ---Purpose: - ---Category: Inquire methods - ---Level: Public - - SpoolDirectory (me) - returns AsciiString from TCollection; - ---Purpose: - ---Category: Inquire methods - ---Level: Public - - WorkSpace (me ; Width,Height : out Length from Quantity) - is redefined; - ---Purpose: Returns the Available WorkSpace in DWU coordinates - ---Category: Inquire methods - ---Level: Public - - Convert (me; PV : Integer from Standard) - returns Length from Quantity is redefined virtual; - ---Purpose: Returns the DWU value depending of the PIXEL value. - ---Category: Inquire methods - ---Level: Public - - Convert (me; DV : Length from Quantity) - returns Integer from Standard is redefined virtual; - ---Purpose: Returns the PIXEL value depending of the DWU value. - ---Category: Inquire methods - ---Level: Public - - Convert (me; PX, PY : Integer from Standard; - DX, DY : out Length from Quantity) is redefined virtual; - ---Purpose: Returns the DWU position depending of the PIXEL position. - ---Category: Inquire methods - ---Level: Public - - Convert (me; DX, DY : Length from Quantity; - PX, PY : out Integer from Standard) is redefined virtual; - ---Purpose: Returns the PIXEL position depending of the DWU position . - ---Category: Inquire methods - ---Level: Public - - LineAttrib (me; ColorIndex, TypeIndex, WidthIndex : out Integer from Standard); - ---Purpose: - ---Category: Inquire methods - ---Level: Public - - PolyAttrib (me; ColorIndex, TileIndex : out Integer from Standard; - EdgeFlag : out Boolean from Standard); - ---Purpose: - ---Category: Inquire methods - ---Level: Public - - DrawCurveCapable (me) - returns Boolean from Standard is virtual protected; - ---Purpose: Should be called from PlotMgt_TextManager::Curveto() - --- method to check if the driver is capable to draw curves. - ---Category: Inquire methods - ---Level: Private - - MapX(me; aShortReal: ShortReal from Standard) - returns ShortReal from Standard is virtual private; - ---Purpose: - ---Category: Inquire methods - ---Level: Private - - MapY(me; aShortReal: ShortReal from Standard) - returns ShortReal from Standard is virtual private; - ---Purpose: - ---Category: Inquire methods - ---Level: Private - -fields - myFStream : FStream from Aspect; - myPixelSize : Real from Standard is protected; - myDrawingName : AsciiString from TCollection is protected; - myFileName : AsciiString from TCollection is protected; - myPlotter : Plotter from PlotMgt; - myPlotterIsDefined : Boolean from Standard; - - ----- Draw attibutes - myWidth : ShortReal from Standard is protected; - myHeight : ShortReal from Standard is protected; - myPaperMargin : ShortReal from Standard is protected; - myTypeOfColorSpace : TypeOfColorSpace from Aspect is protected; - - ----- Actual attributes (written in the file) - myColorIndex : Integer from Standard is protected; - myTypeIndex : Integer from Standard is protected; - myWidthIndex : Integer from Standard is protected; - myFontIndex : Integer from Standard is protected; - - ----- Graphic attributes (set by SetXXX methods) - myLineColorIndex : Integer from Standard is protected; - myLineTypeIndex : Integer from Standard is protected; - myLineWidthIndex : Integer from Standard is protected; - - myPolyColorIndex : Integer from Standard is protected; - myPolyTileIndex : Integer from Standard is protected; - myPolyEdgeFlag : Boolean from Standard is protected; - - myMarkerColorIndex : Integer from Standard is protected; - myMarkerWidthIndex : Integer from Standard is protected; - myMarkerFillFlag : Boolean from Standard is protected; - - myTextColorIndex : Integer from Standard is protected; - myTextFontIndex : Integer from Standard is protected; - myTextHScale : Real from Standard is protected; - myTextWScale : Real from Standard is protected; - myTextSlant : Real from Standard is protected; - myTextMinHeight : Real from Standard is protected; - myTextIsUnderlined : Boolean from Standard is protected; - myCapsHeight : Boolean from Standard is protected; - - ----- Interal attributes and parameters - myPrimitiveType : TypeOfPrimitive from Aspect is protected; - myPrimitiveLength : Integer from Standard is protected; - myPrimitiveX : Array1OfShortReal from TShort is protected; - myPrimitiveY : Array1OfShortReal from TShort is protected; - - myMFTFonts : HListOfMFTFonts from PlotMgt is protected; - myMFTSizes : HArray1OfShortReal from TShort is protected; - myTextManager : TextManager from PlotMgt is protected; - - ----- Private attributes, supported by the driver - myDriverColorMap : ColorMap from Aspect is protected; - myDriverTypeMap : TypeMap from Aspect is protected; - myDriverWidthMap : WidthMap from Aspect is protected; - myDriverMarkMap : MarkMap from Aspect is protected; - -friends - class TextManager from PlotMgt - -end PlotterDriver from PlotMgt; diff --git a/src/PlotMgt/PlotMgt_PlotterDriver.cxx b/src/PlotMgt/PlotMgt_PlotterDriver.cxx deleted file mode 100755 index 8545af31e2..0000000000 --- a/src/PlotMgt/PlotMgt_PlotterDriver.cxx +++ /dev/null @@ -1,1395 +0,0 @@ -// Created by: SYL & DCB -// Copyright (c) 1993-1999 Matra Datavision -// Copyright (c) 1999-2012 OPEN CASCADE SAS -// -// The content of this file is subject to the Open CASCADE Technology Public -// License Version 6.5 (the "License"). You may not use the content of this file -// except in compliance with the License. Please obtain a copy of the License -// at http://www.opencascade.org and read it completely before using this file. -// -// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its -// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. -// -// The Original Code and all software distributed under the License is -// distributed on an "AS IS" basis, without warranty of any kind, and the -// Initial Developer hereby disclaims all such warranties, including without -// limitation, any warranties of merchantability, fitness for a particular -// purpose or non-infringement. Please see the License for the specific terms -// and conditions governing the rights and limitations under the License. - - -#define BUC60766 //GG 041000 -// The plotter filename must be preserved when it contains -// a directory definition for compatibillity. - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#define xTRACE 1 -//#define DEBUG_KEEP -#define MAXPOINT 1024 -#define PPI 72./(0.0254005 METER) -#define ERROR_NO_PLOTTER "PlotMgt_PlotterDriver::Plotter() --> No plotter defined." - -#ifdef WNT -# pragma warning (disable : 4244 4305) -# ifdef DrawText -# undef DrawText -# endif -#endif - -//=============================================================================== -static OSD_Environment& _DIRPLOTDEF() { - static OSD_Environment DIRPLOTDEF("DIRPLOTDEF"); - return DIRPLOTDEF; -} -#define DIRPLOTDEF _DIRPLOTDEF() - -//=============================================================================== -#define SET_SPOOL_NAME(aFileName) { \ - TCollection_AsciiString FileName = DIRPLOTDEF.Value(); \ - myFileName = aFileName; \ - if (!FileName.IsEmpty()) { \ - myDrawingName = aFileName; \ - Standard_Character aChar = FileName.Value(FileName.Length()); \ - if ( (aChar != '\\') && (aChar != '/') ) FileName += "/"; \ - FileName += myFileName; \ - myFileName = FileName; \ - } else { \ - myFileName = "./"; \ - myFileName += aFileName; \ - } \ - } -//=============================================================================== -#define INIT_GRAPHIC_ATTRIB() \ - myLineColorIndex = 0; \ - myLineTypeIndex = 0; \ - myLineWidthIndex = 0; \ - myPolyColorIndex = 0; \ - myPolyTileIndex = 0; \ - myPolyEdgeFlag = Standard_False; \ - myMarkerColorIndex = 0; \ - myMarkerWidthIndex = 0; \ - myMarkerFillFlag = Standard_False; \ - myTextColorIndex = 0; \ - myTextFontIndex = 0; \ - myTextSlant = 0.0F; \ - myTextHScale = 1.0; \ - myTextWScale = 1.0; \ - myCapsHeight = Standard_False; \ - myTextIsUnderlined = Standard_False; \ - myColorIndex = -1; \ - myTypeIndex = -1; \ - myWidthIndex = -1; \ - myFontIndex = -1; \ - myPaperMargin = 8.; - -//=============================================================================== -PlotMgt_PlotterDriver::PlotMgt_PlotterDriver (const Handle(PlotMgt_Plotter)& aPlotter, - const Standard_CString aFileName, - const Standard_Boolean fCreateFile) - : myPixelSize (0.325 METER / 1152), - myPrimitiveType (Aspect_TOP_UNKNOWN), - myPrimitiveLength (0), - myPrimitiveX (1, MAXPOINT), - myPrimitiveY (1, MAXPOINT), - myPlotterIsDefined (Standard_True) -{ -#ifdef BUC60766 - myFileName = aFileName; - myDrawingName = aFileName; - if( myFileName.Search("/") <= 0 && myFileName.Search("\\") <= 0 ) -#endif - SET_SPOOL_NAME (aFileName); - INIT_GRAPHIC_ATTRIB (); - if (fCreateFile) { - myFStream = new ofstream; - myFStream->open(myFileName.ToCString(),ios::out); -#ifdef BUC60766 - if( !myFStream->rdbuf()->is_open() ) { - cout << "*PlotMgt_PlotterDriver Failed on opening the file '" << myFileName << "'" < 0 - cout << "PlotMgt_PlotterDriver::PlotMgt_PlotterDriver('" - << aPlotter->Name() << "','" << aFileName << "') : myFileName '" << myFileName << "'" << endl; -#endif - myPlotter = aPlotter; -} - -//=============================================================================== -PlotMgt_PlotterDriver::PlotMgt_PlotterDriver (const Standard_CString aFileName, - const Standard_Boolean fCreateFile) - : myPixelSize (0.325 METER / 1152), - myPrimitiveType (Aspect_TOP_UNKNOWN), - myPrimitiveLength (0), - myPrimitiveX (1, MAXPOINT), - myPrimitiveY (1, MAXPOINT), - myPlotterIsDefined (Standard_False) -{ -#ifdef BUC60766 - myFileName = aFileName; - myDrawingName = aFileName; - if( myFileName.Search("/") <= 0 && myFileName.Search("\\") <= 0 ) -#endif - SET_SPOOL_NAME (aFileName); - INIT_GRAPHIC_ATTRIB (); - if (fCreateFile) { - myFStream = new ofstream; - myFStream->open(myFileName.ToCString(),ios::out); -#ifdef BUC60766 - if( !myFStream->rdbuf()->is_open() ) { - cout << "*PlotMgt_PlotterDriver Failed on opening the file '" << myFileName << "'" < 0 - cout << "PlotMgt_PlotterDriver::PlotMgt_PlotterDriver('" << aFileName - << "') : myFileName '" << myFileName << "'" << endl; -#endif - myPlotter.Nullify (); -} - -//=============================================================================== -void PlotMgt_PlotterDriver::Close () -{ - if (myFStream) - myFStream->close(); -#ifdef BUC60766 - myFStream = NULL; -#endif -#if TRACE > 0 - cout << "Aspect_PlotterDriver::Close()" << endl << flush; -#endif -} - -//=============================================================================== -void PlotMgt_PlotterDriver::SetPixelSize (const Standard_Real aPixelSize) -{ - myPixelSize = aPixelSize; -} - -//=============================================================================== -void PlotMgt_PlotterDriver::SetPlotter (const Handle(PlotMgt_Plotter)& aPlotter) -{ - if (myPlotterIsDefined) { - if (myPlotter->Name() != aPlotter->Name()) { - Aspect_DriverError_Raise_if(Standard_True, "PlotMgt_PlotterDriver::SetPlotter -> Plotter already defined."); - } - } - myPlotterIsDefined = Standard_True; - myPlotter = aPlotter; -} - -//=============================================================================== -Aspect_FStream PlotMgt_PlotterDriver::Cout () const -{ - return myFStream; -} - -//=============================================================================== -TCollection_AsciiString PlotMgt_PlotterDriver::PlotFileName () const -{ - return myFileName; -} - -//=============================================================================== -TCollection_AsciiString PlotMgt_PlotterDriver::DrawingName () const -{ - return myDrawingName; -} -//=============================================================================== -TCollection_AsciiString PlotMgt_PlotterDriver::SpoolDirectory () const -{ - TCollection_AsciiString aRes = DIRPLOTDEF.Value(); - if (!aRes.IsEmpty()) { - Standard_Character aChar = aRes.Value(aRes.Length()); - if ( (aChar != '\\') && (aChar != '/') ) - aRes += "/"; - } else { - aRes = "./"; - } - return aRes; -} - -//=============================================================================== -Handle(PlotMgt_Plotter) PlotMgt_PlotterDriver::Plotter () const -{ - Aspect_DriverError_Raise_if(!myPlotterIsDefined, ERROR_NO_PLOTTER); - return myPlotter; -} - -//=============================================================================== -Standard_Boolean PlotMgt_PlotterDriver::Spool (const Aspect_PlotMode aPlotMode, - const Standard_CString /*aReserved1*/, - const Standard_Boolean /*aReserved2*/) -{ - Standard_Boolean Done = Standard_True; - Close(); - TCollection_AsciiString beforeCommand = Plotter() -> BeforePrintCommand (); - TCollection_AsciiString afterCommand = Plotter() -> AfterPrintCommand (); - TCollection_AsciiString printCommand = Plotter() -> PrintCommand (); - - if (!afterCommand.IsEmpty() || - (aPlotMode != Aspect_PM_FILEONLY && !printCommand.IsEmpty())) { - TCollection_AsciiString theCmdFileName; - OSD_Path aCmdPath (myFileName); -#ifdef WNT - aCmdPath.SetExtension (".cmd"); -#else - aCmdPath.SetExtension (".csh"); -#endif // WNT - aCmdPath.SystemName (theCmdFileName); - Aspect_FStream cmdFStream = new ofstream; - cmdFStream -> open (theCmdFileName.ToCString(), ios::out); -#ifdef WNT - *cmdFStream << "set DESSNOM=" << myFileName << endl; - *cmdFStream << "set Plot_FileName=" << myFileName << endl; - *cmdFStream << "set Plot_PlotterName=" << myPlotter->Name() << endl; -#else - *cmdFStream << "#!/bin/csh" << endl; - *cmdFStream << "setenv DESSNOM " << myFileName << endl; - *cmdFStream << "setenv Plot_FileName " << myFileName << endl; - *cmdFStream << "setenv Plot_PlotterName " << myPlotter->Name() << endl; -#endif // WNT - - Standard_Integer theNumber = myPlotter->NumberOfParameters(); - Standard_Integer i; - TCollection_AsciiString theName; -// Standard_Integer theType; - TCollection_AsciiString theValue; -// Standard_Boolean theStatusOfGet; - *cmdFStream << endl << flush; - for (i = 1; i <= theNumber; i++) { - Handle(PlotMgt_PlotterParameter) aParameter = Plotter() -> Parameter (i); - aParameter -> PutCommandInfo (cmdFStream); - } - *cmdFStream << endl << flush; - - if (!afterCommand.IsEmpty()) - *cmdFStream << endl << afterCommand << endl; - if (aPlotMode != Aspect_PM_FILEONLY) { - if (!printCommand.IsEmpty()) - *cmdFStream << endl << printCommand << endl; - } -#ifndef WNT - *cmdFStream << "rm " << theCmdFileName.ToCString() << endl; -#else - *cmdFStream << "del " << theCmdFileName.ToCString() << endl; -#endif // WNT - *cmdFStream << "exit" << endl << flush; - cmdFStream -> close(); - - TCollection_AsciiString theCmd; -#ifdef WNT - Standard_Integer theStatus = 0; -#else - theCmd = "chmod 755 "; - theCmd += theCmdFileName; - Standard_Integer theStatus = system (theCmd.ToCString()); -#endif // WNT - if (theStatus == 0) { - theCmd = theCmdFileName; -// theStatus = system (theCmd.ToCString()); - if (theStatus != 0) - Done = Standard_False; - } else - Done = Standard_False; - } - return Done; -} - -//=============================================================================== -void PlotMgt_PlotterDriver::CreateDriverColorMap () -{ -} - -//=============================================================================== -void PlotMgt_PlotterDriver::CreateDriverTypeMap () -{ -} - -//=============================================================================== -void PlotMgt_PlotterDriver::CreateDriverWidthMap () -{ -} - -//=============================================================================== -void PlotMgt_PlotterDriver::CreateDriverMarkMap () -{ -} - -//=============================================================================== -void PlotMgt_PlotterDriver::InitializeColorMap (const Handle(Aspect_ColorMap)& /*aColorMap*/) -{ -} - -//=============================================================================== -void PlotMgt_PlotterDriver::InitializeTypeMap (const Handle(Aspect_TypeMap)& /*aTypeMap*/) -{ -} - -//=============================================================================== -void PlotMgt_PlotterDriver::InitializeWidthMap (const Handle(Aspect_WidthMap)& /*aWidthMap*/) -{ -} - -//=============================================================================== -void PlotMgt_PlotterDriver::InitializeFontMap (const Handle(Aspect_FontMap)& aFontMap) -{ - if (!UseMFT()) - return; - Aspect_FontMapEntry entry; - Standard_Integer index,iindex,minindex=IntegerLast(),maxindex= -minindex; - - for( index=1; index<=aFontMap->Size(); index++ ) { - entry = aFontMap->Entry(index); - maxindex = Max(maxindex, entry.Index()); - minindex = Min(minindex, entry.Index()); - } - Handle(MFT_FontManager) dummy; - dummy.Nullify (); - myMFTFonts = new PlotMgt_HListOfMFTFonts(minindex, maxindex, dummy); - myMFTSizes = new TShort_HArray1OfShortReal(minindex, maxindex, 0.); - - TCollection_AsciiString aname; - Aspect_FontStyle style; - Standard_Boolean theCapsHeight; - Quantity_PlaneAngle theFontSlant; - Quantity_Length theFontSize; - Standard_Real fsize; - - for (index=1; index <= aFontMap->Size(); index++) { - entry = aFontMap->Entry(index); - iindex = entry.Index(); - style = entry.Type(); - theFontSize = TOMILLIMETER(style.Size()); - theFontSlant = style.Slant(); - aname = style.AliasName(); - theCapsHeight = style.CapsHeight(); - fsize = theFontSize; - if (fsize > 0.0001) fsize = Convert(fsize); - else fsize = 1.; - Standard_Boolean found = MFT_FontManager::IsKnown(aname.ToCString()); - if (found) { - found = Standard_False; - Handle(MFT_FontManager) theFontManager; - Aspect_FontStyle fstyle = MFT_FontManager::Font(aname.ToCString()); - for (Standard_Integer i = minindex; i <= maxindex; i++) { - theFontManager = myMFTFonts->Value(i); - if (!theFontManager.IsNull()) { - if (fstyle == theFontManager->Font()) { - found = Standard_True; - break; - } - } - } - if (!found) { - theFontManager = new MFT_FontManager(aname.ToCString()); - } - theFontManager->SetFontAttribs (theFontSize,theFontSize, - theFontSlant,0.,theCapsHeight); - myMFTFonts->SetValue (iindex, theFontManager); - if (theCapsHeight) - myMFTSizes->SetValue (iindex, Standard_ShortReal(-theFontSize)); - else - myMFTSizes->SetValue (iindex, Standard_ShortReal(theFontSize)); - } else { - Handle(MFT_FontManager) theFontManager; - if (MFT_FontManager::IsKnown("Defaultfont")) { - theFontManager = new MFT_FontManager ("Defaultfont"); - } else { - for (int j=1; j <= aFontMap->Size(); j++) { - if (MFT_FontManager::IsKnown(aFontMap->Entry(j).Type().AliasName())) { - cout << "--->>> PlotterDriver: First found font is : '" - << aFontMap->Entry(j).Type().AliasName() << "'" << endl << flush; - theFontManager = new MFT_FontManager (aFontMap->Entry(j).Type().AliasName()); - break; - } - } - } - if (!theFontManager.IsNull()) { - myMFTFonts->SetValue (iindex, theFontManager); - if (theCapsHeight) - myMFTSizes->SetValue (iindex, Standard_ShortReal(-theFontSize)); - else - myMFTSizes->SetValue (iindex, Standard_ShortReal(theFontSize)); - } - } - } -} - -//=============================================================================== -void PlotMgt_PlotterDriver::InitializeMarkMap (const Handle(Aspect_MarkMap)& /*aMarkMap*/) -{ -} - -//=============================================================================== -void PlotMgt_PlotterDriver::SetLineAttrib (const Standard_Integer ColorIndex, - const Standard_Integer TypeIndex, - const Standard_Integer WidthIndex) -{ - myLineColorIndex = ColorIndex; - myLineTypeIndex = TypeIndex; - myLineWidthIndex = WidthIndex; -} - -//=============================================================================== -void PlotMgt_PlotterDriver::SetTextAttrib (const Standard_Integer ColorIndex, - const Standard_Integer FontIndex) -{ - SetTextAttrib (ColorIndex, FontIndex, 0., 1., 1.); -} - -//=============================================================================== -void PlotMgt_PlotterDriver::SetTextAttrib (const Standard_Integer ColorIndex, - const Standard_Integer FontIndex, - const Quantity_PlaneAngle aSlant, - const Quantity_Factor aHScale, - const Quantity_Factor aWScale, - const Standard_Boolean isUnderlined) -{ - myTextColorIndex = ColorIndex; - myTextFontIndex = FontIndex; - myTextIsUnderlined = isUnderlined; - if (FontIndex != myFontIndex || aSlant != myTextSlant || - aHScale != myTextHScale || aWScale != myTextWScale) { - myFontIndex = FontIndex; - myTextSlant = aSlant; - myTextHScale = aHScale; - myTextWScale = (aWScale > 0.) ? aWScale : aHScale; - if (UseMFT()) { - Handle(MFT_FontManager) theFontManager - = myMFTFonts->Value(myFontIndex); - if (!theFontManager.IsNull()) { - Quantity_Length theTextSize = myMFTSizes->Value(myFontIndex); - Quantity_Length theTextWidth = myTextWScale * Abs(theTextSize); - Quantity_Length theTextHeight = myTextHScale * Abs(theTextSize); - Quantity_PlaneAngle theTextSlant = myTextSlant; - Standard_Boolean theCapsHeight = - (theTextSize > 0.) ? Standard_False : Standard_True; - theFontManager->SetFontAttribs (theTextWidth, theTextHeight, - theTextSlant, 0., theCapsHeight); - } - } - } -} - -//=============================================================================== -void PlotMgt_PlotterDriver::SetPolyAttrib (const Standard_Integer ColorIndex, - const Standard_Integer TileIndex, - const Standard_Boolean DrawEdge) -{ - myPolyColorIndex = ColorIndex; - myPolyTileIndex = TileIndex; - myPolyEdgeFlag = DrawEdge; -} - -//=============================================================================== -void PlotMgt_PlotterDriver::SetMarkerAttrib (const Standard_Integer ColorIndex, - const Standard_Integer WidthIndex, - const Standard_Boolean FillMarker) -{ - myMarkerColorIndex = ColorIndex; - myMarkerWidthIndex = WidthIndex; - myMarkerFillFlag = FillMarker; -} - -//=============================================================================== -void PlotMgt_PlotterDriver::PlotLineAttrib (const Standard_Integer /*ColorIndex*/, - const Standard_Integer /*TypeIndex*/, - const Standard_Integer /*WidthIndex*/) -{ -} - -//=============================================================================== -void PlotMgt_PlotterDriver::PlotPolyAttrib (const Standard_Integer /*ColorIndex*/, - const Standard_Integer /*TileIndex*/, - const Standard_Boolean /*DrawEdge*/) -{ -} - -//=============================================================================== -//=============================================================================== -//=============================================================================== -//=============================================================================== -//=============================================================================== -//=============================================================================== -//=============================================================================== -//=============================================================================== - -//=============================================================================== -void PlotMgt_PlotterDriver::DrawPoint (const Standard_ShortReal X, - const Standard_ShortReal Y) -{ - switch (myPrimitiveType) { - case Aspect_TOP_POLYLINE: - case Aspect_TOP_POLYGON: - if (myPrimitiveLength < MAXPOINT) { - myPrimitiveLength++; - myPrimitiveX(myPrimitiveLength) = X; - myPrimitiveY(myPrimitiveLength) = Y; - } - break; - default: - PlotLineAttrib (myLineColorIndex, myLineTypeIndex, myLineWidthIndex); - PlotPoint (MapX(X), MapY(Y)); - break; - } -} - -//=============================================================================== -void PlotMgt_PlotterDriver::DrawSegment (const Standard_ShortReal X1, - const Standard_ShortReal Y1, - const Standard_ShortReal X2, - const Standard_ShortReal Y2) -{ - PlotLineAttrib (myLineColorIndex, myLineTypeIndex, myLineWidthIndex); - PlotSegment (MapX(X1), MapY(Y1), MapX(X2), MapY(Y2)); -} - -//=============================================================================== -void PlotMgt_PlotterDriver::DrawRectangle (const Standard_ShortReal aX, - const Standard_ShortReal aY, - const Standard_ShortReal aDX, - const Standard_ShortReal aDY) -{ - Standard_Boolean Done = Standard_False; - if (myPlotter->RectangleDriven()) { - PlotLineAttrib (myLineColorIndex, myLineTypeIndex, myLineWidthIndex); - Done = PlotRectangle (MapX(aX), MapY(aY), MapX(aDX), MapY(aDY), 0.0); - } - - if (!Done) { - BeginPolyline (5); - DrawPoint (aX, aY); - DrawPoint (aX, aY + aDY); - DrawPoint (aX + aDX, aY + aDY); - DrawPoint (aX + aDX, aY); - DrawPoint (aX, aY); - ClosePrimitive (); - } -} - -//=============================================================================== -void PlotMgt_PlotterDriver::DrawPolyline (const TShort_Array1OfShortReal& aListX, - const TShort_Array1OfShortReal& aListY) -{ - static float xarray[MAXPOINT], yarray[MAXPOINT]; - Standard_Integer u = aListX.Upper(), l = aListX.Lower(), n = aListX.Length(); - if (n != aListY.Length ()) - Aspect_DriverError::Raise ("PlotMgt_PlotterDriver::DrawPolyline() -> 2 different lengths."); - if (n > MAXPOINT) - Aspect_DriverError::Raise ("PlotMgt_PlotterDriver::DrawPolyline() -> Array is too long."); - if (n > 1) { - for (Standard_Integer i=l; i<=u; i++) { - xarray[i-l] = MapX(aListX(i)); - yarray[i-l] = MapY(aListY(i)); - } - PlotLineAttrib (myLineColorIndex, myLineTypeIndex, myLineWidthIndex); - PlotPolyline (xarray, yarray, &n, 1); - } -} - -//=============================================================================== -void PlotMgt_PlotterDriver::DrawPolygon (const TShort_Array1OfShortReal& aListX, - const TShort_Array1OfShortReal& aListY) -{ - static float xarray[MAXPOINT+1], yarray[MAXPOINT+1]; - Standard_Integer u = aListX.Upper(), l = aListX.Lower(), n = aListX.Length(); - if (n != aListY.Length ()) - Aspect_DriverError::Raise ("PlotMgt_PlotterDriver::DrawPolygon() -> 2 different lengths."); - if (n > MAXPOINT) - Aspect_DriverError::Raise ("PlotMgt_PlotterDriver::DrawPolygon() -> Array is too long."); - if (n > 1) { - for (Standard_Integer i=l; i<=u; i++) { - xarray[i-l] = MapX(aListX(i)); - yarray[i-l] = MapY(aListY(i)); - } - if ((xarray[l] != xarray[u]) || (yarray[l] != yarray[u])) { - xarray[n] = xarray[0]; yarray[n] = yarray[0]; n++; - } - PlotLineAttrib (myLineColorIndex, myLineTypeIndex, myLineWidthIndex); - PlotPolyAttrib (myPolyColorIndex, myPolyTileIndex, myPolyEdgeFlag); - PlotPolygon (xarray, yarray, &n, 1); - } -} - -//=============================================================================== -Standard_Boolean PlotMgt_PlotterDriver::DrawArc (const Standard_ShortReal X, - const Standard_ShortReal Y, - const Standard_ShortReal anXradius, - const Standard_ShortReal anYradius, - const Standard_ShortReal aStartAngle, - const Standard_ShortReal anOpenAngle) -{ - Standard_Boolean Done = Standard_False; - float san, oan; - if (anOpenAngle == 0.F || anOpenAngle > 2*M_PI) { - san = 0.F; oan = 2.*M_PI; - } else if (anOpenAngle < 0.F) { - san = 2.*M_PI + aStartAngle + anOpenAngle; - oan = -anOpenAngle; - } else { - san = aStartAngle; oan = anOpenAngle; - } - - if ( ((anXradius == anYradius) && myPlotter->CircleDriven ()) || - ((anXradius != anYradius) && myPlotter->EllipseDriven()) ) { - PlotLineAttrib (myLineColorIndex, myLineTypeIndex, myLineWidthIndex); - Done = PlotArc (MapX(X), MapX(Y), MapX(anXradius), MapY(anYradius), san, oan); - } - - if (!Done) { - Standard_ShortReal precis = FROMCENTIMETER(myPlotter->Resolution()); - Standard_ShortReal value; - Standard_ShortReal aRadius = Max (anXradius, anYradius); - if (aRadius > precis) - value = Max (0.0044, Min (0.7854, 2. * ACos(1.-precis/aRadius))); - else - value = M_PI/4.; - Standard_Integer nbpoints = Min(MAXPOINT, - Standard_Integer(Abs(oan)/value)+2); - - nbpoints = 10; - float pX, pY, alpha; - BeginPolyline (nbpoints); - for (int i=0; i <= nbpoints; i++) { - alpha = san + (oan*i)/nbpoints; - pX = float(X + anXradius*Cos(alpha)); - pY = float(Y + anYradius*Sin(alpha)); - DrawPoint (pX, pY); - } - ClosePrimitive (); - Done = Standard_True; - } - return Done; -} - -//=============================================================================== -Standard_Boolean PlotMgt_PlotterDriver::DrawPolyArc (const Standard_ShortReal X, - const Standard_ShortReal Y, - const Standard_ShortReal anXradius, - const Standard_ShortReal anYradius, - const Standard_ShortReal aStartAngle, - const Standard_ShortReal anOpenAngle) -{ - Standard_Boolean Done = Standard_False; - float san, oan; - if (anOpenAngle == 0.F || anOpenAngle > 2*M_PI) { - san = 0.F; oan = 2.*M_PI; - } else if (anOpenAngle < 0.F) { - san = 2.*M_PI + aStartAngle + anOpenAngle; - oan = -anOpenAngle; - } else { - san = aStartAngle; oan = anOpenAngle; - } - - if ( ((anXradius == anYradius) && myPlotter->CircleDriven ()) || - ((anXradius != anYradius) && myPlotter->EllipseDriven()) ) { - PlotLineAttrib (myLineColorIndex, myLineTypeIndex, myLineWidthIndex); - PlotPolyAttrib (myPolyColorIndex, myPolyTileIndex, myPolyEdgeFlag); - Done = PlotPolyArc (MapX(X), MapY(Y), MapX(anXradius), MapY(anYradius), san, oan); - } - - if (!Done) { - Standard_ShortReal precis = FROMCENTIMETER(myPlotter->Resolution()); - Standard_ShortReal value; - Standard_ShortReal aRadius = Max (anXradius, anYradius); - if (aRadius > precis) - value = Max (0.0044, Min (0.7854, 2. * ACos(1.-precis/aRadius))); - else - value = M_PI/4.; - Standard_Integer nbpoints = Min(MAXPOINT, - Standard_Integer(Abs(oan)/value)+2); - - nbpoints = 10; - float pX, pY, alpha; - BeginPolygon (nbpoints+1); - DrawPoint (X, Y); - for (int i=0; i <= nbpoints; i++) { - alpha = san + (oan*i)/nbpoints; - pX = float(X + anXradius*Cos(alpha)); - pY = float(Y + anYradius*Sin(alpha)); - DrawPoint (pX, pY); - } - ClosePrimitive (); - Done = Standard_True; - } - return Done; -} - -//=============================================================================== -void PlotMgt_PlotterDriver::DrawMarker (const Standard_Integer aMarker, - const Standard_ShortReal Xpos, - const Standard_ShortReal Ypos, - const Standard_ShortReal Width, - const Standard_ShortReal Height, - const Standard_ShortReal Angle) -{ - Standard_Boolean Done = Standard_False; - if (myPlotter->MarkerDriven()) - Done = PlotMarker (aMarker, MapX(Xpos), MapY(Ypos), Width, Height, Angle); - - if (!Done) { - if (aMarker >= 0 && Width > 0. && Height > 0.) { - // Declare the arrays to put in the marker points. - - const TShort_Array1OfShortReal& amx = - MarkMap ()->Entry(aMarker+1).Style().XValues(); - const TShort_Array1OfShortReal& amy = - MarkMap ()->Entry(aMarker+1).Style().YValues(); - const TColStd_Array1OfBoolean& ams = - MarkMap ()->Entry(aMarker+1).Style().SValues(); - Standard_Integer i, sl, su; - Standard_ShortReal Ca = (float)Cos((3 * M_PI) / 2 + Angle), - Sa = (float)Sin((3 * M_PI) / 2 + Angle); - Standard_ShortReal dx, dy, Cx, Cy; - - // Remember the old attributes - Standard_Integer lci, lti, lwi, pci, pti; - Standard_Boolean pef; - LineAttrib (lci, lti, lwi); - PolyAttrib (pci, pti, pef); - // Set new line params - SetLineAttrib (myMarkerColorIndex, 0, myMarkerWidthIndex); - SetPolyAttrib (myPolyColorIndex, 0, Standard_True); - - // Actual drawing - sl = amx.Lower(); su = amx.Upper(); - for (i=sl; i <= su; i++) { - Cx = amx(i)*Width/2.F; - Cy = amy(i)*Height/2.F; - if (!ams(i)) { - dx = Xpos+((Ca*Cx)+(Sa*Cy)); - dy = Ypos+((Sa*Cx)-(Ca*Cy)); - ClosePrimitive (); - if (myMarkerFillFlag) BeginPolygon (su); - else BeginPolyline (su); - DrawPoint (dx, dy); - } else { - dx = Xpos+((Ca*Cx)+(Sa*Cy)); - dy = Ypos+((Sa*Cx)-(Ca*Cy)); - DrawPoint (dx, dy); - } - } - ClosePrimitive (); - // Restore old attributes - SetLineAttrib (lci, lti, lwi); - SetPolyAttrib (pci, pti, pef); - } else { - DrawPoint (Xpos, Ypos); - } - } -} - -//=============================================================================== -//=============================================================================== -//=============================================================================== -//=============================================================================== -//=============================================================================== -//=============================================================================== -//=============================================================================== -#define TRANSFORM(X,Y,rX,rY) \ -{ \ - Standard_Real x = X,y = Y; \ - X = (float)(rX + x*Ca - y*Sa); \ - Y = (float)(rY + x*Sa + y*Ca); \ -} - -#define DRAW_TEXT_FRAME(aText) \ - Standard_Real underlinePosition = \ - (myTextIsUnderlined) ? theFontManager->UnderlinePosition() : 0.; \ - Quantity_Length theWidth = 0.,theAscent = 0., \ - theLbearing = 0.,theDescent = 0.; \ - theFontManager->TextSize (aText, theWidth, theAscent, \ - theLbearing, theDescent); \ - theDescent = Max(theDescent, underlinePosition); \ - TShort_Array1OfShortReal Xp (1,4), Yp (1,4); \ - Standard_ShortReal rwidth = theWidth; \ - Standard_ShortReal rheight = theAscent + theDescent; \ - Standard_ShortReal rxmin = theLbearing; \ - Standard_ShortReal rymin = -theDescent; \ - Standard_ShortReal marge = rheight * aMargin; \ - rwidth += 2.F*marge; rheight += 2.F*marge; \ - rxmin -= marge; rymin -= marge; \ - Standard_ShortReal X1, Y1, X2, Y2, X3, Y3, X4, Y4; \ - X1 = rxmin; Y1 = rymin; \ - X2 = rxmin + rwidth; Y2 = rymin; \ - X3 = rxmin + rwidth; Y3 = rymin + rheight; \ - X4 = rxmin; Y4 = rymin + rheight; \ - TRANSFORM (X1, Y1, Xpos, Ypos); \ - TRANSFORM (X2, Y2, Xpos, Ypos); \ - TRANSFORM (X3, Y3, Xpos, Ypos); \ - TRANSFORM (X4, Y4, Xpos, Ypos); \ - Xp.SetValue (1, X1); Yp.SetValue (1, Y1); \ - Xp.SetValue (2, X2); Yp.SetValue (2, Y2); \ - Xp.SetValue (3, X3); Yp.SetValue (3, Y3); \ - Xp.SetValue (4, X4); Yp.SetValue (4, Y4); \ - DrawPolygon (Xp, Yp); - -//=============================================================================== -void PlotMgt_PlotterDriver::DrawText (const TCollection_ExtendedString& aText, - const Standard_ShortReal Xpos, - const Standard_ShortReal Ypos, - const Standard_ShortReal anAngle, - const Aspect_TypeOfText aType) -{ - if (aText.Length() > 0) { - if (aText.IsAscii()) { - TCollection_AsciiString atext(aText,'?'); - DrawText (atext.ToCString(), Xpos, Ypos, anAngle, aType); - } else { - Standard_Boolean Done = Standard_False; -#ifdef BUC60766 - if (myPlotter->TextDriven()) -#else - if (myPlotter->TextDriven() == (unsigned int ) -1) -#endif - Done = PlotText (aText, Xpos, Ypos, anAngle, aType); - - if (!Done && UseMFT()) { - Handle(MFT_FontManager) theFontManager = myMFTFonts->Value(myFontIndex); - if (!theFontManager.IsNull()) { - if (!aText.IsAscii() && !theFontManager->IsComposite()) { - cout << "***ERROR***PlotMgt_PlotterDriver::DrawExtText.UNABLE to draw" - << " an extended text with an ANSI font" << endl << flush; - return; - } - Standard_Real underlinePosition = - (myTextIsUnderlined) ? theFontManager->UnderlinePosition() : 0.; - myTextManager->SetTextAttribs (myTextColorIndex, aType, underlinePosition); - theFontManager->DrawText (myTextManager, aText.ToExtString(), - Quantity_Length(Xpos), Quantity_Length(Ypos), - Quantity_PlaneAngle(anAngle)); - } - } // MFT - } // Ascii - } // Length > 0 -} - -//=============================================================================== -void PlotMgt_PlotterDriver::DrawText (const Standard_CString aText, - const Standard_ShortReal Xpos, - const Standard_ShortReal Ypos, - const Standard_ShortReal anAngle, - const Aspect_TypeOfText aType) -{ - if (strlen(aText) > 0) { - Standard_Boolean Done = Standard_False; -#ifdef BUC60766 - if (myPlotter->TextDriven()) -#else - if (myPlotter->TextDriven() == (unsigned int ) -1) -#endif - Done = PlotText (aText, Xpos, Ypos, anAngle, aType); - - if (!Done && UseMFT()) { - Handle(MFT_FontManager) theFontManager = myMFTFonts->Value(myFontIndex); - if (!theFontManager.IsNull()) { - Standard_Real underlinePosition = - (myTextIsUnderlined) ? theFontManager->UnderlinePosition() : 0.; - myTextManager->SetTextAttribs (myTextColorIndex, aType, underlinePosition); - theFontManager->DrawText (myTextManager, aText, - Quantity_Length(Xpos), Quantity_Length(Ypos), - Quantity_PlaneAngle(anAngle)); - } - } // MFT - } // Length > 0 -} - -//=============================================================================== -void PlotMgt_PlotterDriver::DrawPolyText (const TCollection_ExtendedString& aText, - const Standard_ShortReal Xpos, - const Standard_ShortReal Ypos, - const Quantity_Ratio aMargin, - const Standard_ShortReal anAngle, - const Aspect_TypeOfText aType) -{ - if (aText.Length() > 0) { - if (aText.IsAscii()) { - TCollection_AsciiString atext(aText,'?'); - DrawPolyText (atext.ToCString(), Xpos, Ypos, aMargin, anAngle, aType); - } else { - Standard_Boolean Done = Standard_False; -#ifdef BUC60766 - if (myPlotter->TextDriven()) -#else - if (myPlotter->TextDriven() == (unsigned int ) -1) -#endif - { - PlotPolyAttrib (myPolyColorIndex, myPolyTileIndex, myPolyEdgeFlag); - Done = PlotPolyText(aText, Xpos, Ypos, aMargin, anAngle, aType); - } - - if (!Done && UseMFT()) { - Standard_ShortReal Ca = Cos(anAngle), Sa = Sin(anAngle); -// Standard_ShortReal Tsl = Tan(myTextSlant); - Handle(MFT_FontManager) theFontManager = myMFTFonts->Value(myFontIndex); - if (!theFontManager.IsNull()) { - if (!theFontManager->IsComposite()) { - cout << "***PlotMgt_PlotterDriver::DrawPolyExtText.UNABLE to draw" - << " an extended text with an ANSI font" << endl << flush; - return; - } - DRAW_TEXT_FRAME (aText.ToExtString()); - myTextManager->SetTextAttribs (myTextColorIndex, aType, underlinePosition); - theFontManager->DrawText (myTextManager, aText.ToExtString(), - Quantity_Length(Xpos), Quantity_Length(Ypos), - Quantity_PlaneAngle(anAngle)); - } - } // MFT - } // Ascii - } // aText.Length() > 0 -} - -//=============================================================================== -void PlotMgt_PlotterDriver::DrawPolyText (const Standard_CString aText, - const Standard_ShortReal Xpos, - const Standard_ShortReal Ypos, - const Quantity_Ratio aMargin, - const Standard_ShortReal anAngle, - const Aspect_TypeOfText aType) -{ - if (strlen(aText) > 0) { - Standard_Boolean Done = Standard_False; -#ifdef BUC60766 - if (myPlotter->TextDriven()) -#else - if (myPlotter->TextDriven() == (unsigned int ) -1) -#endif - { - PlotPolyAttrib (myPolyColorIndex, myPolyTileIndex, myPolyEdgeFlag); - Done = PlotPolyText(aText, Xpos, Ypos, aMargin, anAngle, aType); - } - - if (!Done && UseMFT()) { - Standard_ShortReal Ca = Cos(anAngle), - Sa = Sin(anAngle); - Handle(MFT_FontManager) theFontManager = myMFTFonts->Value(myFontIndex); - if (!theFontManager.IsNull()) { - DRAW_TEXT_FRAME (aText); - myTextManager->SetTextAttribs (myTextColorIndex, aType, underlinePosition); - theFontManager->DrawText (myTextManager, aText, - Quantity_Length(Xpos), Quantity_Length(Ypos), - Quantity_PlaneAngle(anAngle)); - } - } // MFT - } // strlen(aText) > 0 -} - -//=============================================================================== -//=============================================================================== -//=============================================================================== -//=============================================================================== -//=============================================================================== -//=============================================================================== -//=============================================================================== -//=============================================================================== -//=============================================================================== - -//=============================================================================== -Standard_Boolean PlotMgt_PlotterDriver::PlotPoint (const Standard_ShortReal /*X*/, - const Standard_ShortReal /*Y*/) -{ - return Standard_False; -} - -//=============================================================================== -Standard_Boolean PlotMgt_PlotterDriver::PlotSegment (const Standard_ShortReal /*X1*/, - const Standard_ShortReal /*Y1*/, - const Standard_ShortReal /*X2*/, - const Standard_ShortReal /*Y2*/) -{ - return Standard_False; -} - -//=============================================================================== -Standard_Boolean PlotMgt_PlotterDriver::PlotRectangle (const Standard_ShortReal /*aX*/, - const Standard_ShortReal /*aY*/, - const Standard_ShortReal /*aDX*/, - const Standard_ShortReal /*aDY*/, - const Standard_ShortReal /*aAngle*/) -{ - return Standard_False; -} - -//=============================================================================== -Standard_Boolean PlotMgt_PlotterDriver::PlotPolyline (const Standard_Address /*xArray*/, - const Standard_Address /*yArray*/, - const Standard_Address /*nPts*/, - const Standard_Integer /*nParts*/) -{ - return Standard_False; -} - -//=============================================================================== -Standard_Boolean PlotMgt_PlotterDriver::PlotPolygon (const Standard_Address /*xArray*/, - const Standard_Address /*yArray*/, - const Standard_Address /*nPts*/, - const Standard_Integer /*nParts*/) -{ - return Standard_False; -} - -//=============================================================================== -Standard_Boolean PlotMgt_PlotterDriver::PlotArc (const Standard_ShortReal /*X*/, - const Standard_ShortReal /*Y*/, - const Standard_ShortReal /*anXradius*/, - const Standard_ShortReal /*anYradius*/, - const Standard_ShortReal /*sAngle*/, - const Standard_ShortReal /*oAngle*/) -{ - return Standard_False; -} - -//=============================================================================== -Standard_Boolean PlotMgt_PlotterDriver::PlotPolyArc (const Standard_ShortReal /*X*/, - const Standard_ShortReal /*Y*/, - const Standard_ShortReal /*anXradius*/, - const Standard_ShortReal /*anYradius*/, - const Standard_ShortReal /*sAngle*/, - const Standard_ShortReal /*oAngle*/) -{ - return Standard_False; -} - -//=============================================================================== -Standard_Boolean PlotMgt_PlotterDriver::PlotMarker (const Standard_Integer /*aMarker*/, - const Standard_ShortReal /*Xpos*/, - const Standard_ShortReal /*Ypos*/, - const Standard_ShortReal /*Width*/, - const Standard_ShortReal /*Height*/, - const Standard_ShortReal /*Angle*/) -{ - return Standard_False; -} - -//=============================================================================== -Standard_Boolean PlotMgt_PlotterDriver::PlotText (const TCollection_ExtendedString& /*aText*/, - const Standard_ShortReal /*Xpos*/, - const Standard_ShortReal /*Ypos*/, - const Standard_ShortReal /*anAngle*/, - const Aspect_TypeOfText /*aType*/) -{ - return Standard_False; -} - -//=============================================================================== -Standard_Boolean PlotMgt_PlotterDriver::PlotText (const Standard_CString /*aText*/, - const Standard_ShortReal /*Xpos*/, - const Standard_ShortReal /*Ypos*/, - const Standard_ShortReal /*anAngle*/, - const Aspect_TypeOfText /*aType*/) -{ - return Standard_False; -} - -//=============================================================================== -Standard_Boolean PlotMgt_PlotterDriver::PlotPolyText (const TCollection_ExtendedString& /*aText*/, - const Standard_ShortReal /*Xpos*/, - const Standard_ShortReal /*Ypos*/, - const Quantity_Ratio /*aMargin*/, - const Standard_ShortReal /*anAngle*/, - const Aspect_TypeOfText /*aType*/) -{ - return Standard_False; -} - -//=============================================================================== -Standard_Boolean PlotMgt_PlotterDriver::PlotPolyText (const Standard_CString /*aText*/, - const Standard_ShortReal /*Xpos*/, - const Standard_ShortReal /*Ypos*/, - const Quantity_Ratio /*aMargin*/, - const Standard_ShortReal /*anAngle*/, - const Aspect_TypeOfText /*aType*/) -{ - return Standard_False; -} - -//=============================================================================== -//=============================================================================== -//=============================================================================== -//=============================================================================== -//=============================================================================== -//=============================================================================== -//=============================================================================== -//=============================================================================== -//=============================================================================== -void PlotMgt_PlotterDriver::BeginPolyline (const Standard_Integer aNumber) -{ - if (myPrimitiveType != Aspect_TOP_UNKNOWN) ClosePrimitive (); - if (aNumber <= 0) return; - myPrimitiveType = Aspect_TOP_POLYLINE; - myPrimitiveLength = 0; -} - -//=============================================================================== -void PlotMgt_PlotterDriver::BeginPolygon (const Standard_Integer aNumber) -{ - if (myPrimitiveType != Aspect_TOP_UNKNOWN) ClosePrimitive(); - if (aNumber <= 0) return; - myPrimitiveType = Aspect_TOP_POLYGON; - myPrimitiveLength = 0; -} - -//=============================================================================== -void PlotMgt_PlotterDriver::BeginSegments () -{ - if (myPrimitiveType != Aspect_TOP_UNKNOWN) ClosePrimitive(); - myPrimitiveType = Aspect_TOP_SEGMENTS; - myPrimitiveLength = 0; -} - -//=============================================================================== -void PlotMgt_PlotterDriver::BeginArcs () -{ - if (myPrimitiveType != Aspect_TOP_UNKNOWN) ClosePrimitive(); - myPrimitiveType = Aspect_TOP_ARCS; - myPrimitiveLength = 0; -} - -//=============================================================================== -void PlotMgt_PlotterDriver::BeginPolyArcs () -{ - if (myPrimitiveType != Aspect_TOP_UNKNOWN) ClosePrimitive(); - myPrimitiveType = Aspect_TOP_POLYARCS; - myPrimitiveLength = 0; -} - -//=============================================================================== -void PlotMgt_PlotterDriver::BeginMarkers () -{ - if (myPrimitiveType != Aspect_TOP_UNKNOWN) ClosePrimitive(); - myPrimitiveType = Aspect_TOP_MARKERS; - myPrimitiveLength = 0; -} - -//=============================================================================== -void PlotMgt_PlotterDriver::BeginPoints () -{ - if (myPrimitiveType != Aspect_TOP_UNKNOWN) ClosePrimitive(); - myPrimitiveType = Aspect_TOP_POINTS; - myPrimitiveLength = 0; -} - -//=============================================================================== -void PlotMgt_PlotterDriver::ClosePrimitive () -{ - switch (myPrimitiveType) { - case Aspect_TOP_POLYLINE: - if (myPrimitiveLength > 0) { - TShort_Array1OfShortReal Xpoint(myPrimitiveX(1),1,myPrimitiveLength); - TShort_Array1OfShortReal Ypoint(myPrimitiveY(1),1,myPrimitiveLength); - myPrimitiveLength = 0; - DrawPolyline (Xpoint,Ypoint); - } - break; - case Aspect_TOP_POLYGON: - if (myPrimitiveLength > 0) { - TShort_Array1OfShortReal Xpoint(myPrimitiveX(1),1,myPrimitiveLength); - TShort_Array1OfShortReal Ypoint(myPrimitiveY(1),1,myPrimitiveLength); - myPrimitiveLength = 0; - DrawPolygon (Xpoint,Ypoint); - } - break; - case Aspect_TOP_SEGMENTS: - case Aspect_TOP_ARCS: - case Aspect_TOP_POLYARCS: - case Aspect_TOP_MARKERS: - case Aspect_TOP_POINTS: - break; - default: - myPrimitiveType = Aspect_TOP_UNKNOWN; - } - myPrimitiveType = Aspect_TOP_UNKNOWN; -} - -//=============================================================================== -//=============================================================================== -//=============================================================================== -//=============================================================================== -//=============================================================================== -//=============================================================================== -//=============================================================================== -//=============================================================================== - -//=============================================================================== -Standard_Boolean PlotMgt_PlotterDriver::IsKnownImage (const Handle(Standard_Transient)& /*anImage*/) -{ - return Standard_False; -} - -//=============================================================================== -void PlotMgt_PlotterDriver::ClearImage (const Handle(Standard_Transient)& /*anImage*/) -{ -} - -//=============================================================================== -void PlotMgt_PlotterDriver::ClearImageFile (const Standard_CString /*anImageFile*/) -{ -} - -//=============================================================================== -void PlotMgt_PlotterDriver::DrawImage (const Handle(Standard_Transient)& /*anImage*/, - const Standard_ShortReal /*aX*/, - const Standard_ShortReal /*aY*/) -{ -} - -//=============================================================================== -Standard_Boolean PlotMgt_PlotterDriver::SizeOfImageFile (const Standard_CString /*anImageFile*/, - Standard_Integer &aWidth, - Standard_Integer &aHeight) const -{ - aWidth = aHeight = 0; - return Standard_False; -} - -//=============================================================================== -void PlotMgt_PlotterDriver::DrawImageFile (const Standard_CString anImageFile, - const Standard_ShortReal aX, - const Standard_ShortReal aY, - const Quantity_Factor aScale) -{ - PlotImage (aX, aY, 0.0F, 0.0F, (float)aScale, anImageFile, NULL); -} - -//=============================================================================== -void PlotMgt_PlotterDriver::FillAndDrawImage (const Handle(Standard_Transient)& /*anImage*/, - const Standard_ShortReal aX, - const Standard_ShortReal aY, - const Standard_Integer aWidth, - const Standard_Integer aHeight, - const Standard_Address anArrayOfPixels) -{ - PlotImage (aX, aY, (float)aWidth, (float)aHeight, 1.0F, - NULL, anArrayOfPixels); -} - -//=============================================================================== -void PlotMgt_PlotterDriver::FillAndDrawImage (const Handle(Standard_Transient)& /*anImage*/, - const Standard_ShortReal aX, - const Standard_ShortReal aY, - const Standard_Integer anIndexOfLine, - const Standard_Integer aWidth, - const Standard_Integer aHeight, - const Standard_Address anArrayOfPixels) -{ - PlotImage (aX, aY, (float)aWidth, (float)aHeight, 1.0F, - NULL, anArrayOfPixels, anIndexOfLine); -} - -//=============================================================================== -Standard_Boolean PlotMgt_PlotterDriver::PlotImage (const Standard_ShortReal /*aX*/, - const Standard_ShortReal /*aY*/, - const Standard_ShortReal /*aWidth*/, - const Standard_ShortReal /*aHeight*/, - const Standard_ShortReal /*aScale*/, - const Standard_CString /*anImageFile*/, - const Standard_Address /*anArrayOfPixels*/, - const Standard_Integer /*aLineIndex*/) -{ - return Standard_False; -} - -//=============================================================================== -//=============================================================================== -//=============================================================================== -//=============================================================================== -//=============================================================================== -//=============================================================================== -//=============================================================================== -//=============================================================================== - -//=============================================================================== -void PlotMgt_PlotterDriver::LineAttrib (Standard_Integer& ColorIndex, - Standard_Integer& TypeIndex, - Standard_Integer& WidthIndex) const -{ - ColorIndex = myLineColorIndex; - TypeIndex = myLineTypeIndex; - WidthIndex = myLineWidthIndex; -} - -//=============================================================================== -void PlotMgt_PlotterDriver::PolyAttrib (Standard_Integer& ColorIndex, - Standard_Integer& TileIndex, - Standard_Boolean& EdgeFlag) const -{ - ColorIndex = myPolyColorIndex; - TileIndex = myPolyTileIndex; - EdgeFlag = myPolyEdgeFlag; -} - -//=============================================================================== -void PlotMgt_PlotterDriver::WorkSpace (Quantity_Length& Width, - Quantity_Length& Height) const -{ - Width = Quantity_Length (myWidth); - Height = Quantity_Length (myHeight); -} - -//=============================================================================== -Standard_Boolean PlotMgt_PlotterDriver::DrawCurveCapable () const -{ - return Standard_False; -} - -//=============================================================================== -Standard_ShortReal PlotMgt_PlotterDriver::MapX (const Standard_ShortReal aShortreal) const -{ - return aShortreal; -} - -//=============================================================================== -Standard_ShortReal PlotMgt_PlotterDriver::MapY (const Standard_ShortReal aShortreal) const -{ - return aShortreal; -} - -//=============================================================================== -Quantity_Length PlotMgt_PlotterDriver::Convert (const Standard_Integer PV) const -{ - return Quantity_Length (PV * myPixelSize); -} - -//=============================================================================== -Standard_Integer PlotMgt_PlotterDriver::Convert (const Quantity_Length DV) const -{ - return Standard_Integer (DV/myPixelSize); -} - -//=============================================================================== -void PlotMgt_PlotterDriver::Convert (const Standard_Integer PX, - const Standard_Integer PY, - Quantity_Length& DX, - Quantity_Length& DY) const -{ - DX = PX * myPixelSize; - DY = PY * myPixelSize; -} - -//=============================================================================== -void PlotMgt_PlotterDriver::Convert (const Quantity_Length DX, - const Quantity_Length DY, - Standard_Integer& PX, - Standard_Integer& PY) const -{ - PX = (Standard_Integer )( DX / myPixelSize); - PY = (Standard_Integer )( DY / myPixelSize); -} diff --git a/src/PlotMgt/PlotMgt_PlotterParameter.cdl b/src/PlotMgt/PlotMgt_PlotterParameter.cdl deleted file mode 100755 index c5a6bd1e02..0000000000 --- a/src/PlotMgt/PlotMgt_PlotterParameter.cdl +++ /dev/null @@ -1,158 +0,0 @@ --- Created by: DCB --- Copyright (c) 1998-1999 Matra Datavision --- Copyright (c) 1999-2012 OPEN CASCADE SAS --- --- The content of this file is subject to the Open CASCADE Technology Public --- License Version 6.5 (the "License"). You may not use the content of this file --- except in compliance with the License. Please obtain a copy of the License --- at http://www.opencascade.org and read it completely before using this file. --- --- The Initial Developer of the Original Code is Open CASCADE S.A.S., having its --- main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. --- --- The Original Code and all software distributed under the License is --- distributed on an "AS IS" basis, without warranty of any kind, and the --- Initial Developer hereby disclaims all such warranties, including without --- limitation, any warranties of merchantability, fitness for a particular --- purpose or non-infringement. Please see the License for the specific terms --- and conditions governing the rights and limitations under the License. - - -class PlotterParameter from PlotMgt inherits TShared from MMgt - -uses - FStream from Aspect, - Plotter from PlotMgt, - TypeOfPlotterParameter from PlotMgt, - HSequenceOfAsciiString from TColStd, - AsciiString from TCollection, - File from OSD - -is - ------------------------- - -- Category: Constructors - ------------------------- - Create ( - aName : AsciiString from TCollection - ) returns mutable PlotterParameter from PlotMgt; - ---Purpose: Create the class instance WITH undefined TYPE - - ----------------------------------------------- - -- Category: Methods to change class definition - ----------------------------------------------- - Save (me: mutable; aFile: in out File from OSD) - returns Boolean from Standard; - ---Purpose: - - SetState (me: mutable; aState: Boolean from Standard); - ---Purpose: - - SetType (me: mutable; aType: TypeOfPlotterParameter from PlotMgt); - ---Purpose: - - ProcessParamVal (me: mutable; - aParamSign : CString from Standard; - aFlag : Integer from Standard; - aValue : out AsciiString from TCollection - ) is private; - - CheckListValue (me: mutable - ) returns Boolean from Standard is private; - ---Purpose: - - Normalize (me: mutable) - is protected; - ---Purpose: - - ---------------------------- - -- Category: Inquire methods - ---------------------------- - SValue (me; aValue: out AsciiString from TCollection); - ---Purpose: - - BValue (me) - returns Boolean from Standard; - ---Purpose: - - IValue (me) - returns Integer from Standard; - ---Purpose: - - RValue (me) - returns Real from Standard; - ---Purpose: - - LValues (me; aList: out HSequenceOfAsciiString from TColStd); - ---Purpose: - - MValue (me - ) returns HSequenceOfAsciiString from TColStd; - ---Purpose: - - Name (me) - returns AsciiString from TCollection; - ---Purpose: - - OldName (me) - returns AsciiString from TCollection; - ---Purpose: - - Description (me : mutable) - returns HSequenceOfAsciiString from TColStd - is protected; - ---Purpose: - ---C++: return & - - NeedToBeSaved (me) - returns Boolean from Standard; - ---Purpose: - - Dump (me); - ---Purpose: - - PutCommandInfo (me; outStream: FStream from Aspect); - ---Purpose: Used to put parameter's information in a cmd file - -- used in PlotterDriver's Spool method. - - ---------------------------------------- - -- Category: Methods to modify parameter - ---------------------------------------- - SetSValue (me: mutable; aValue: AsciiString from TCollection); - ---Purpose: - - SetBValue (me: mutable; aValue: Boolean from Standard); - ---Purpose: - - SetIValue (me: mutable; aValue: Integer from Standard); - ---Purpose: - - SetRValue (me: mutable; aValue: Real from Standard); - ---Purpose: - - SetMValue (me: mutable; aMap: HSequenceOfAsciiString from TColStd); - ---Purpose: - -fields - myName : AsciiString from TCollection; - myOldName : AsciiString from TCollection; - myType : TypeOfPlotterParameter from PlotMgt; - myIndex : Integer from Standard; - myState : Boolean from Standard; - myConfigState : Boolean from Standard; - myIsModified : Boolean from Standard; - -------------------------------------------------------- - myFlags : Integer from Standard; - myDialog : AsciiString from TCollection; - myMinValue : AsciiString from TCollection; - myMaxValue : AsciiString from TCollection; - myValues : AsciiString from TCollection; - myDefValue : AsciiString from TCollection; - myMapLength : Integer from Standard; - myMap : HSequenceOfAsciiString from TColStd; - - myDescription : HSequenceOfAsciiString from TColStd; - -friends - class Plotter from PlotMgt - -end PlotterParameter from PlotMgt; diff --git a/src/PlotMgt/PlotMgt_PlotterParameter.cxx b/src/PlotMgt/PlotMgt_PlotterParameter.cxx deleted file mode 100755 index 150fd18cb3..0000000000 --- a/src/PlotMgt/PlotMgt_PlotterParameter.cxx +++ /dev/null @@ -1,614 +0,0 @@ -// Created by: DCB -// Copyright (c) 1998-1999 Matra Datavision -// Copyright (c) 1999-2012 OPEN CASCADE SAS -// -// The content of this file is subject to the Open CASCADE Technology Public -// License Version 6.5 (the "License"). You may not use the content of this file -// except in compliance with the License. Please obtain a copy of the License -// at http://www.opencascade.org and read it completely before using this file. -// -// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its -// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. -// -// The Original Code and all software distributed under the License is -// distributed on an "AS IS" basis, without warranty of any kind, and the -// Initial Developer hereby disclaims all such warranties, including without -// limitation, any warranties of merchantability, fitness for a particular -// purpose or non-infringement. Please see the License for the specific terms -// and conditions governing the rights and limitations under the License. - - -#include -#include -#include - -// Removes str at index and puts it before -#define SWAP_STR(idx1,idx2) \ -{ \ - TCollection_AsciiString str; \ - str = myDescription -> Value(idx2); \ - myDescription -> Remove (idx2); \ - myDescription -> InsertBefore (idx1, str); \ -} - -#define STRING_TRIM(aString) \ - aString.LeftAdjust(); \ - aString.RightAdjust(); - -#define FLAG_DIALOG 0x00000001 -#define FLAG_MINVAL 0x00000002 -#define FLAG_MAXVAL 0x00000004 -#define FLAG_VALUES 0x00000008 -#define FLAG_LENGTH 0x00000010 -#define FLAG_DEFVAL 0x00000020 -#define FLAG_NTYPE 0x00000040 - -//============================================================================ -PlotMgt_PlotterParameter::PlotMgt_PlotterParameter (const TCollection_AsciiString& aName) -{ - myName = aName; - myOldName = ""; - myType = PlotMgt_TOPP_Undefined; - myIndex = -1; - myState = Standard_False; - myConfigState = Standard_False; - myIsModified = Standard_False; - //-------------------------------------------------------------- - myFlags = 0; - myDialog = ""; - myMinValue = ""; - myMaxValue = ""; - myValues = ""; - myDefValue = ""; - myMapLength = 0; - myMap = new TColStd_HSequenceOfAsciiString (); - myDescription = new TColStd_HSequenceOfAsciiString (); - //---- Find parameter's index in __PossibleParameters array ---- - Standard_Integer i = 0; - while (__PossibleParameters[i]._new_name != NULL) { - if ( myName == __PossibleParameters[i]._new_name || - (__PossibleParameters[i]._old_name && myName == __PossibleParameters[i]._old_name)) - { - if (__PossibleParameters[i]._old_name) - myOldName = __PossibleParameters[i]._old_name; - myName = __PossibleParameters[i]._new_name; - myIndex = i; - break; - } - i++; - } - if (myIndex == -1) { - cout << "PlotMgt_PlotterParameter WARNING: Unknown parameter'" - << myName << "'\n" << flush; - return; - } -} - -//============================================================================ -#define PUT_INFO(aSign,aValue) { \ - sprintf(aBuffer,"%s%s%s%s\n", myName.ToCString(), (aSign), \ - _DELIM_SIGN, aValue.ToCString()); \ - aLine += aBuffer; } - -//============================================================================ -Standard_Boolean PlotMgt_PlotterParameter::Save (OSD_File& aFile) -{ - char aBuffer [1024]; - TCollection_AsciiString aLine = ""; - if (NeedToBeSaved ()) { - //----------------------------------------------------- - if (!myOldName.IsEmpty ()) { - sprintf (aBuffer, "! %s (%s) parameter\n", myName.ToCString(), - myOldName.ToCString()); - aLine += aBuffer; - } - //------------ Write Type info ------------------------ - if (myFlags & FLAG_NTYPE ) PUT_INFO(_TYPE_SIGN, PlotMgt::StringFromType (myType)); - //------------ Write dialog info ---------------------- - if (myFlags & FLAG_DIALOG) PUT_INFO(_DIALOG_SIGN, myDialog); - //------------ Write minval info ---------------------- - if (myFlags & FLAG_MINVAL) PUT_INFO(_MINVAL_SIGN, myMinValue); - //------------ Write maxval info ---------------------- - if (myFlags & FLAG_MAXVAL) PUT_INFO(_MAXVAL_SIGN, myMaxValue); - //------------ Write values info ---------------------- - if (myFlags & FLAG_VALUES) PUT_INFO(_VALUES_SIGN, myValues); - //------------ Write defavl info ---------------------- - if (myFlags & FLAG_DEFVAL) PUT_INFO("", myDefValue); - //------------ Write map info ------------------------- - if (myFlags & FLAG_LENGTH && myMapLength && !myMap.IsNull()) { - Standard_Integer i, n = myMap -> Length(); - aLine += myName; aLine += _LENGTH_SIGN; - aLine += _DELIM_SIGN; aLine += TCollection_AsciiString (myMapLength); - aLine += "\n"; - for (i = 1; i <= n; i++) - PUT_INFO("", myMap -> Value (i)); - } - //------------ Append one new line -------------------- - aLine += "\n"; - aFile.Write (aLine, aLine.Length ()); - return (!aFile.Failed ()); - } - return Standard_True; -} - -//============================================================================ -void PlotMgt_PlotterParameter::SetType (const PlotMgt_TypeOfPlotterParameter aType) -{ - myType = aType; -} - -//============================================================================ -void PlotMgt_PlotterParameter::SetState (const Standard_Boolean aState) -{ - myState = aState; -} - -//============================================================================ -TCollection_AsciiString PlotMgt_PlotterParameter::Name () const -{ - return myName; -} - -//============================================================================ -TCollection_AsciiString PlotMgt_PlotterParameter::OldName () const -{ - return myOldName; -} - -//============================================================================ -Handle(TColStd_HSequenceOfAsciiString)& PlotMgt_PlotterParameter::Description () -{ - return myDescription; -} - -//============================================================================ -Standard_Boolean PlotMgt_PlotterParameter::NeedToBeSaved () const -{ - return (myConfigState && (myType != _T_UNK) && (myIsModified || myState)); -} - -//============================================================================ -void PlotMgt_PlotterParameter::Dump () const -{ - if (!myState || (myType == _T_UNK) || - !myConfigState || !myIsModified) - return; - - cout << "!++++++++++++++++++++++++++++++++++++++++++++" << endl << flush; - cout << "! " << myName << " "; - if (!myOldName.IsEmpty()) - cout << "(" << myOldName << ") "; - cout << "parameter" << endl << flush; - cout << myName << _TYPE_SIGN << _DELIM_SIGN - << PlotMgt::StringFromType (myType) << endl << flush; - if (myFlags & FLAG_DIALOG) - cout << myName << _DIALOG_SIGN << _DELIM_SIGN << myDialog << endl << flush; - if (myFlags & FLAG_MINVAL) - cout << myName << _MINVAL_SIGN << _DELIM_SIGN << myMinValue << endl << flush; - if (myFlags & FLAG_MAXVAL) - cout << myName << _MAXVAL_SIGN << _DELIM_SIGN << myMaxValue << endl << flush; - if (myFlags & FLAG_VALUES && (myType == _T_LSTR)) - cout << myName << _VALUES_SIGN << _DELIM_SIGN << myValues << endl << flush; - if (myFlags & FLAG_DEFVAL) - cout << myName << _DELIM_SIGN << myDefValue << endl << flush; - if (myFlags & FLAG_LENGTH && myMapLength) { - cout << myName << _LENGTH_SIGN << _DELIM_SIGN << myMapLength << endl << flush; - Standard_Integer i, n = myMap -> Length(); - for (i = 1; i <= n; i++) - cout << myName << _DELIM_SIGN << myMap -> Value (i) << endl << flush; - } - cout << "!++++++++++++++++++++++++++++++++++++++++++++" << endl << flush; - cout << endl << flush; -} - -//============================================================================ -void PlotMgt_PlotterParameter::PutCommandInfo (const Aspect_FStream& outStream) const -{ -#ifdef WNT - TCollection_AsciiString _setenv_ ("set Plot_"); - TCollection_AsciiString _comment_ ("REM ######### "); - TCollection_AsciiString _delim_ (" = "); -#else - TCollection_AsciiString _setenv_ ("setenv Plot_"); - TCollection_AsciiString _comment_ ("############# "); - TCollection_AsciiString _delim_ (" "); -#endif // WNT - *outStream << _comment_ << "Parameter '" << myName << "' of type '" - << PlotMgt::StringFromType (myType) << "'" << endl; - - if (myFlags & FLAG_DEFVAL) - *outStream << _setenv_ << myName << _delim_ << "'" << myDefValue << "'" << endl; - - if (myFlags & FLAG_LENGTH && myMapLength) { - *outStream << _setenv_ << myName << "_Length" << _delim_ << myMapLength << endl; - Standard_Integer i, n = myMap -> Length(); - for (i = 1; i <= n; i++) - *outStream << _setenv_ << myName << "_" << i << _delim_ << myMap -> Value (i) << endl; - } -} - -//============================================================================ -Standard_Boolean PlotMgt_PlotterParameter::CheckListValue () -{ - if (!(myFlags & FLAG_VALUES)) { - cout << "PlotMgt_PlotterParameter WARNING: Parameter '" << myName - << "' has type 'list_string', but does not have [.Values] " - << "descriptor" << endl << flush; - return Standard_False; - } - TCollection_AsciiString aValues = myValues, aToken, newValues; - Standard_Boolean commaFound, defValFound = Standard_False; - Standard_Integer idx, res; - STRING_TRIM(myDefValue); - STRING_TRIM(myValues); - if (myValues.IsEmpty()) { - if (!myDefValue.IsEmpty()) { - cout << "PlotMgt_PlotterParameter WARNING: Parameter '" << myName - << "' has type 'list_string', but [.Values] descriptor " - << "is empty. Defaulting to '" << myDefValue << "'" << endl << flush; - myValues = myDefValue; - return Standard_True; - } else { - cout << "PlotMgt_PlotterParameter WARNING: Parameter '" << myName - << "' has type 'list_string', but [.Values] descriptor " - << "and default values are empty." << endl << flush; - return Standard_False; - } - } - do { - idx = aValues.Search (","); - commaFound = (idx != -1); - if (commaFound) { - aToken = aValues.Token (",", 1); - res = aValues.Search (aToken); - if (res != 1) - aValues.Remove (1, res - 1); - aValues.Remove (1, aToken.Length() + 1); - } else { - aToken = aValues; - } - STRING_TRIM(aToken); - // Still trying to find default value - if (!defValFound) - defValFound = (aToken == myDefValue); - // Append new values with a token - if (!aToken.IsEmpty()) - newValues += aToken; - if (commaFound && !aToken.IsEmpty()) - newValues += ","; - } while (commaFound); - // Check the default value - if (!defValFound) { - cout << "PlotMgt_PlotterParameter WARNING: Parameter '" << myName - << "' has type 'list_string'. "; - if (myFlags & FLAG_DEFVAL) - cout << "But the default value '" << myDefValue << "' is not found. "; - else - cout << "But does not have default value. "; - cout << "Defaulting to the first from the list." << endl << flush; - idx = newValues.Search (","); - if (idx != -1) myDefValue = newValues.Token (",", 1); - else myDefValue = newValues; - myFlags |= FLAG_DEFVAL; - } - // Use new values as default - myValues = newValues; - return Standard_True; -} - -//============================================================================ -void PlotMgt_PlotterParameter::ProcessParamVal ( - const Standard_CString aParamSign, - const Standard_Integer aFlag, - TCollection_AsciiString& aValue) -{ - Standard_Integer i, n = myDescription -> Length (); - Standard_Boolean fFound = Standard_False; - TCollection_AsciiString searchStr = myName, aLine; -//JR/Hp - searchStr += (Standard_CString ) (aParamSign ? aParamSign : ""); -// searchStr += (aParamSign ? aParamSign : ""); - searchStr += _DELIM_SIGN; - - aValue = ""; - for (i = n; i >= 1; i--) { - aLine = myDescription -> Value(i); - Standard_Integer res = aLine.Search(searchStr); - if (res != -1) { - aLine.Remove (1, searchStr.Length()); - STRING_TRIM(aLine); - myFlags |= aFlag; - aValue = aLine; - fFound = Standard_True; - // Remove all other strings - Standard_Integer j = 1; - while (j <= n) { - if (myDescription -> Value(j).Search(searchStr) != -1) { - myDescription -> Remove (j); - n--; - } else j++; - } - break; - } - } -} - -//============================================================================ -void PlotMgt_PlotterParameter::Normalize () -{ - Standard_Integer n, i; - TCollection_AsciiString aMapLen; - // Quit if the parameter is not found in __PossibleParameters - if (myIndex == -1) - goto _CLEAR_AND_EXIT; - // Check parameter's type in __PossibleParameters array - if (myType == _T_UNK || myType != __PossibleParameters[myIndex]._type) { - cout << "PlotMgt_PlotterParameter WARNING: Incorrect type of '" - << myName << "' parameter : '" - << PlotMgt::StringFromType (myType) << "' instead of '" - << PlotMgt::StringFromType (__PossibleParameters[myIndex]._type) - << "'. Using right TYPE.\n" << flush; - myType = __PossibleParameters[myIndex]._type; - myFlags |= FLAG_NTYPE; - } - // Change old names to new ones (if any) - if (!myOldName.IsEmpty ()) { - n = myDescription -> Length (); - TCollection_AsciiString aLine; - for (i = 1; i <= n; i++) { - aLine = myDescription -> Value (i); - Standard_Integer res = aLine.Search (myOldName); - if (res != -1) { - aLine.Remove (1, myOldName.Length()); - aLine.Insert (1, myName); - myDescription -> SetValue (i, aLine); - } - } - } - // Normalize parameter (build all necessary values) - ProcessParamVal (_DIALOG_SIGN, FLAG_DIALOG, myDialog); - ProcessParamVal (_MINVAL_SIGN, FLAG_MINVAL, myMinValue); - ProcessParamVal (_MAXVAL_SIGN, FLAG_MAXVAL, myMaxValue); - ProcessParamVal (_VALUES_SIGN, FLAG_VALUES, myValues); - ProcessParamVal (_LENGTH_SIGN, FLAG_LENGTH, aMapLen); - if ((myFlags & FLAG_LENGTH) && aMapLen.IsIntegerValue()) - myMapLength = aMapLen.IntegerValue(); - switch (myType) { - case _T_INT: - case _T_REAL: - case _T_BOOL: - case _T_STR: { - if (!__PossibleParameters[myIndex]._ismap) { - ProcessParamVal (NULL, FLAG_DEFVAL, myDefValue); - } else { - n = myDescription -> Length (); - // There must me at least of default values - if (myMapLength > n || myMapLength == 0) { - cout << "PlotMgt_PlotterParameter WARNING: Bad Map description: present " - << "only " << n << " instead of " << myMapLength << " values in '" - << myName << "'" << endl; - goto _CLEAR_AND_EXIT; - } - // Put lines from the end of description - for (i = n - myMapLength + 1; i <= n; i++) - myMap -> Append (myDescription -> Value (i)); - myFlags &= ~FLAG_DEFVAL; - // Leave only map values - TCollection_AsciiString remStr = (myName + _DELIM_SIGN), aLine; - n = myMap -> Length (); - for (i = 1; i <= n; i++) { - aLine = myMap -> Value (i); - if (aLine.Search(remStr) != -1) { - aLine.Remove (1, remStr.Length()); - myMap -> SetValue (i, aLine); - } - } - } - } break; - case _T_LSTR: { - ProcessParamVal (NULL, FLAG_DEFVAL, myDefValue); - } break; - default: - break ; - } - // Check the configuration - if (myFlags & FLAG_DEFVAL && myDefValue.IsEmpty()) - myFlags &= ~FLAG_DEFVAL; - if (myFlags & FLAG_DEFVAL && (myType == _T_INT)) { - if (!myDefValue.IsIntegerValue()) { - myDefValue = ""; - myFlags &= ~FLAG_DEFVAL; - } - } - if (myFlags & FLAG_DEFVAL && (myType == _T_REAL)) { - if (!myDefValue.IsRealValue()) { - myDefValue = ""; - myFlags &= ~FLAG_DEFVAL; - } - } - if (myFlags & FLAG_DEFVAL && (myType == _T_BOOL)) { - STRING_TRIM(myDefValue); - myDefValue.LowerCase (); - if (myDefValue.IsEmpty ()) - myFlags &= ~FLAG_DEFVAL; - } - if (myType == _T_LSTR && !CheckListValue ()) - goto _CLEAR_AND_EXIT; - // Indicate that parameter is configured properly - myConfigState = Standard_True; -_CLEAR_AND_EXIT: - //Dump (); - // We do not need it anymore - myDescription->Clear (); - myDescription.Nullify(); -} - -//============================================================================ -//============================================================================ -//============================================================================ -#define GET_BAD_TYPE_INFO(aGetType) \ - cout << "PlotMgt_PlotterParameter ---> WARNING : '" << myName \ - << "' of type '" << PlotMgt::StringFromType (myType) \ - << "' requested about " << aGetType << " value" \ - << endl << flush; - -#define GET_EMPTY_VALUE_INFO(aValue) \ - cout << "PlotMgt_PlotterParameter ---> WARNING : '" << myName \ - << "' of type '" << PlotMgt::StringFromType (myType) \ - << "' has no default value." \ - << "Defaulting to " << aValue << "." << endl << flush; - -//============================================================================ -void PlotMgt_PlotterParameter::SValue (TCollection_AsciiString& aValue) const -{ - aValue = ""; - if ((myType == _T_STR) || (myType == _T_LSTR)) { - if (myFlags & FLAG_DEFVAL && !myDefValue.IsEmpty()) { - aValue = myDefValue; - } else - GET_EMPTY_VALUE_INFO("empty string"); - } else - GET_BAD_TYPE_INFO("STRING"); -} - -//============================================================================ -Standard_Boolean PlotMgt_PlotterParameter::BValue () const -{ - if (myType == _T_BOOL) { - if (myFlags & FLAG_DEFVAL && !myDefValue.IsEmpty()) { - if (myDefValue.IsEqual("true") || - myDefValue.IsIntegerValue() && myDefValue.IntegerValue()) - return Standard_True; - } else - GET_EMPTY_VALUE_INFO("FALSE"); - } else - GET_BAD_TYPE_INFO("BOOLEAN"); - return Standard_False; -} - -//============================================================================ -Standard_Integer PlotMgt_PlotterParameter::IValue () const -{ - if (myType == _T_INT) { - if (myFlags & FLAG_DEFVAL) { - return myDefValue.IntegerValue (); - } else - GET_EMPTY_VALUE_INFO("0"); - } else - GET_BAD_TYPE_INFO("INTEGER"); - return 0; -} - -//============================================================================ -Standard_Real PlotMgt_PlotterParameter::RValue () const -{ - if (myType == _T_REAL) { - if (myFlags & FLAG_DEFVAL) { - return myDefValue.RealValue (); - } else - GET_EMPTY_VALUE_INFO("0.0"); - } else - GET_BAD_TYPE_INFO("REAL"); - return 0.0; -} - -//============================================================================ -void PlotMgt_PlotterParameter::LValues (Handle(TColStd_HSequenceOfAsciiString)& aList) const -{ - if (!aList.IsNull ()) { - aList->Clear (); - aList.Nullify (); - } - aList = new TColStd_HSequenceOfAsciiString (); - if (myType != _T_LSTR) { - GET_BAD_TYPE_INFO("LIST_STRING"); - return; - } - TCollection_AsciiString aToken, aValues = myValues; - Standard_Boolean commaFound; - Standard_Integer idx; - do { - idx = aValues.Search (","); - commaFound = (idx != -1); - if (commaFound) { - aToken = aValues.Token (",", 1); - aValues.Remove (1, aToken.Length() + 1); - } else { - aToken = aValues; - } - aList -> Append (aToken); - } while (commaFound); -} - -//============================================================================ -Handle(TColStd_HSequenceOfAsciiString) PlotMgt_PlotterParameter::MValue () const -{ - if (!(myFlags & FLAG_LENGTH && myMapLength)) - GET_BAD_TYPE_INFO("MAP_VALUE"); - return myMap; -} - -//============================================================================ -//============================================================================ -//============================================================================ -#define SET_VALUE() \ - myDefValue = aValue; \ - myFlags = FLAG_DEFVAL; \ - myIsModified = Standard_True; -// myFlags != FLAG_DEFVAL; - -#define SET_BAD_TYPE_INFO(aSetType) \ -{ \ - cout << "PlotMgt_PlotterParameter ---> WARNING : '" << myName \ - << "' of type '" << PlotMgt::StringFromType (myType) \ - << "' requested to set " << aSetType << " value" \ - << endl << flush; \ - return; \ -} - -//============================================================================ -void PlotMgt_PlotterParameter::SetSValue (const TCollection_AsciiString& aValue) -{ - if (myType != _T_STR && myType != _T_LSTR) - SET_BAD_TYPE_INFO("STRING"); - SET_VALUE(); -} - -//============================================================================ -void PlotMgt_PlotterParameter::SetBValue (const Standard_Boolean aValue) -{ - if (myType != _T_BOOL) - SET_BAD_TYPE_INFO("BOOL"); -//JR/Hp - myDefValue = (Standard_CString ) (aValue ? "true" : "false"); -// myDefValue = (aValue ? "true" : "false"); -// myFlags != FLAG_DEFVAL; - myFlags = FLAG_DEFVAL; - myIsModified = Standard_True; -} - -//============================================================================ -void PlotMgt_PlotterParameter::SetIValue (const Standard_Integer aValue) -{ - if (myType != _T_INT) - SET_BAD_TYPE_INFO("INTEGER"); - SET_VALUE(); -} - -//============================================================================ -void PlotMgt_PlotterParameter::SetRValue (const Standard_Real aValue) -{ - if (myType != _T_REAL) - SET_BAD_TYPE_INFO("REAL"); - SET_VALUE(); -} - -//============================================================================ -void PlotMgt_PlotterParameter::SetMValue (const Handle(TColStd_HSequenceOfAsciiString)& aMap) -{ - if (!(myFlags & FLAG_LENGTH && myMapLength)) - SET_BAD_TYPE_INFO("MAP_VALUE"); - myMap = aMap; - myMapLength = myMap -> Length (); - myIsModified = Standard_True; -} diff --git a/src/PlotMgt/PlotMgt_PlotterTools.cxx b/src/PlotMgt/PlotMgt_PlotterTools.cxx deleted file mode 100755 index 8f7f78e1a3..0000000000 --- a/src/PlotMgt/PlotMgt_PlotterTools.cxx +++ /dev/null @@ -1,210 +0,0 @@ -// Copyright (c) 1999-2012 OPEN CASCADE SAS -// -// The content of this file is subject to the Open CASCADE Technology Public -// License Version 6.5 (the "License"). You may not use the content of this file -// except in compliance with the License. Please obtain a copy of the License -// at http://www.opencascade.org and read it completely before using this file. -// -// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its -// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. -// -// The Original Code and all software distributed under the License is -// distributed on an "AS IS" basis, without warranty of any kind, and the -// Initial Developer hereby disclaims all such warranties, including without -// limitation, any warranties of merchantability, fitness for a particular -// purpose or non-infringement. Please see the License for the specific terms -// and conditions governing the rights and limitations under the License. - -#include -#include -#include -#include - -//============================================================================== -ParameterDesc __PossibleParameters [] = { - { PLOT_CONFIGVER, NULL, _T_STR, 0 }, - { PLOT_MODEL, "PLOTPAR", _T_STR, 0 }, - { PLOT_TITLE, "PLOTTIT", _T_STR, 0 }, - { PLOT_EXTENSION, "PLOTUNI", _T_STR, 0 }, - { PLOT_BACKDRAW, NULL, _T_STR, 0 }, - { PLOT_COMMENTS, NULL, _T_STR, 0 }, - { PLOT_COLORMAPRGB, NULL, _T_STR, 1 }, - { PLOT_LINETYPEMAP, NULL, _T_STR, 1 }, - { PLOT_FONTMAP, NULL, _T_STR, 1 }, - { PLOT_BEFORECMD, NULL, _T_STR, 0 }, - { PLOT_AFTERCMD, NULL, _T_STR, 0 }, - { PLOT_PRINTCMD, NULL, _T_STR, 0 }, - - { PLOT_DIALOGUNIT, NULL, _T_LSTR, 0 }, - { PLOT_OUTFORMAT, "PLOTFMT", _T_LSTR, 0 }, - { PLOT_IMGFORMAT, "IMAGFMT", _T_LSTR, 0 }, - { PLOT_DRVTYPE, "PLOTDRV", _T_LSTR, 0 }, - { PLOT_PAPERFORMAT, NULL, _T_LSTR, 0 }, - { PLOT_ORIENTATION, NULL, _T_LSTR, 0 }, - { PLOT_QUALITY, NULL, _T_LSTR, 0 }, - { PLOT_PAPERFEED, NULL, _T_LSTR, 0 }, - { PLOT_ORIGIN, "PLOTORI", _T_LSTR, 0 }, - { PLOT_COLORMAPPING, NULL, _T_LSTR, 0 }, - { PLOT_PLOTTINGTYPE, "PLOTTYP", _T_LSTR, 0 }, - { PLOT_ROTATION, NULL, _T_LSTR, 0 }, - - { PLOT_SETBKWHITE, NULL, _T_BOOL, 0 }, - { PLOT_MIRRORDRIVEN, NULL, _T_BOOL, 0 }, - { PLOT_MIRRORING, NULL, _T_BOOL, 0 }, - { PLOT_QUALITYDRIVEN, NULL, _T_BOOL, 0 }, - { PLOT_COPYDRIVEN, NULL, _T_BOOL, 0 }, - { PLOT_FEEDDRIVEN, "PLOTAUT", _T_BOOL, 0 }, - { PLOT_CUTDRIVEN, "PLOTCUT", _T_BOOL, 0 }, - { PLOT_PLOTTINGCOLOR, NULL, _T_BOOL, 0 }, - { PLOT_PLOTTERCOLOR, "PLOTCOL", _T_BOOL, 0 }, - { PLOT_CIRCLEDRIVEN, "PLOTCIR", _T_BOOL, 0 }, - { PLOT_ELLIPSEDRIVEN, "PLOTELL", _T_BOOL, 0 }, - { PLOT_CURVEDRIVEN, "PLOTCUR", _T_BOOL, 0 }, - { PLOT_TEXTDRIVEN, "PLOTTEX", _T_BOOL, 0 }, - { PLOT_MARKERDRIVEN, NULL, _T_BOOL, 0 }, - { PLOT_RECTANGLEDRIVEN, NULL, _T_BOOL, 0 }, - { PLOT_FILLDRIVEN, NULL, _T_BOOL, 0 }, - { PLOT_CHECKSUMDRIVEN, "PLOTCHK", _T_BOOL, 0 }, - { PLOT_MEDIASAVDRIVEN, NULL, _T_BOOL, 0 }, - { PLOT_ENDOFPLOTDRIVEN, NULL, _T_BOOL, 0 }, - { PLOT_DRYTIMEDRIVEN, NULL, _T_BOOL, 0 }, - { PLOT_ROTATEDRIVEN, NULL, _T_BOOL, 0 }, - { PLOT_FRAME, NULL, _T_BOOL, 0 }, - { PLOT_FRAMEAROUNDIMG, NULL, _T_BOOL, 0 }, - { PLOT_MULTISHEET, NULL, _T_BOOL, 0 }, - { PLOT_PLOTCOMMENT, NULL, _T_BOOL, 0 }, - { PLOT_PLOTTITLE, NULL, _T_BOOL, 0 }, - { PLOT_PLOTBACKDRAW, NULL, _T_BOOL, 0 }, - - { PLOT_MINLEFTMARGIN, NULL, _T_REAL, 0 }, - { PLOT_MINBOTTOMMARGIN, NULL, _T_REAL, 0 }, - { PLOT_MINTOPMARGIN, NULL, _T_REAL, 0 }, - { PLOT_MINRIGHTMARGIN, NULL, _T_REAL, 0 }, - { PLOT_LEFTMARGIN, "PLOTDEX", _T_REAL, 0 }, - { PLOT_BOTTOMMARGIN, "PLOTDEY", _T_REAL, 0 }, - { PLOT_TOPMARGIN, NULL, _T_REAL, 0 }, - { PLOT_RIGHTMARGIN, NULL, _T_REAL, 0 }, - { PLOT_WIDTHOFFSET, NULL, _T_REAL, 0 }, - { PLOT_WIDTHSCALE, NULL, _T_REAL, 0 }, - { PLOT_LENGTHOFFSET, NULL, _T_REAL, 0 }, - { PLOT_LENGTHSCALE, NULL, _T_REAL, 0 }, - { PLOT_PLOTTINGGAP, "PLOTDIF", _T_REAL, 0 }, - { PLOT_WIDTHMAP, NULL, _T_REAL, 1 }, - { PLOT_WIDTHMAXGAP, NULL, _T_REAL, 0 }, - { PLOT_LINETYPEMAXGAP, NULL, _T_REAL, 0 }, - { PLOT_RESOLUTION, "PLOTRES", _T_REAL, 0 }, - { PLOT_COLORRESOLUTION, NULL, _T_REAL, 0 }, - { PLOT_PHYSICALSTEP, NULL, _T_REAL, 0 }, - { PLOT_MINWIDTHOFLINE, NULL, _T_REAL, 0 }, - { PLOT_PAPERWIDTH, "PLOTWID", _T_REAL, 0 }, - { PLOT_PAPERLENGTH, "PLOTLEN", _T_REAL, 0 }, - { PLOT_FILLWIDTH, NULL, _T_REAL, 0 }, - - { PLOT_MAXCOLORS, NULL, _T_INT, 0 }, - { PLOT_MAXPATTERMS, NULL, _T_INT, 0 }, - { PLOT_COLORMAXGAP, NULL, _T_INT, 0 }, - { PLOT_STYLUSNUMBER, "PLOTSTY", _T_INT, 0 }, - { PLOT_DENSITY, "PLOTNIB", _T_INT, 0 }, - { PLOT_MAXPENS, "PLOTMXP", _T_INT, 0 }, - { PLOT_MOUNTEDPENS, "PLOTNBP", _T_INT, 0 }, - { PLOT_PENSINDEXWIDTH, NULL, _T_INT, 1 }, - { PLOT_PENSINDEXCOLOR, NULL, _T_INT, 1 }, - { PLOT_PENSINDEXTYPE, NULL, _T_INT, 1 }, - { PLOT_MEDIASAVTIME, NULL, _T_INT, 0 }, - { PLOT_ENDOFPLOTTIMER, NULL, _T_INT, 0 }, - { PLOT_DRYTIME, NULL, _T_INT, 0 }, - { PLOT_COPIES, NULL, _T_INT, 0 }, - - { NULL, NULL, _T_UNK, 0 } -}; - -//============================================================================== -static TCollection_AsciiString anErrorMsg; - -//============================================================================== -Standard_CString PARAM_BAD_VALUE1 (const Standard_CString aMethodName) { - anErrorMsg = "PlotMgt_Plotter::SetParameter (must be > 0) from "; - anErrorMsg += aMethodName; - anErrorMsg += " ()"; - return anErrorMsg.ToCString (); -} - -//============================================================================== -Standard_CString PARAM_BAD_VALUE2 (const Standard_CString aMethodName) { - anErrorMsg = "PlotMgt_Plotter::SetParameter (must be -1 or 0) from "; - anErrorMsg += aMethodName; - anErrorMsg += " ()"; - return anErrorMsg.ToCString (); -} - -//============================================================================== -char* trim (char* buffer) -{ - char *first=NULL, *last=NULL; - first = strchr ( buffer, ':' ) + 1; - while ( *first == ' ' ) first++; - last = first + strlen(first) - 1; - if ( *last == '\n' ) { last--; *(last+1) = '\0'; } - while ( *last == ' ' ) { last--; *(last+1) = '\0'; } - return first; -} - -//============================================================================== -// Finds item in the sequence and returns if item -// exists in the list. Otherwise returns 0. -//============================================================================== -Standard_Integer ItemIndex (Handle(TColStd_HSequenceOfAsciiString)& aList, - const TCollection_AsciiString& anItem, - const Standard_Integer nStartIndex) -{ - if (aList.IsNull()) - return 0; - Standard_Integer i, theLength = aList->Length (); - if ((nStartIndex < 1) || (nStartIndex > theLength)) - return 0; - for (i = nStartIndex; i <= theLength; i++) - if ( anItem.IsEqual(aList->Value(i).ToCString()) ) - return i; - return 0; -} - -//============================================================================== -// Fill the list by using file iterator -//============================================================================== -#define SORT_LIST -void FillListByIterator (Handle(TColStd_HSequenceOfAsciiString)& aList, - OSD_FileIterator& anIterator, - Standard_CString aNeedExtension, - // If plotter already exist in the list do not use it. - const Standard_Boolean aCheckExisted) -{ - Standard_Boolean anAddInList; - OSD_File aFile; - OSD_Path aPath; - TCollection_AsciiString aName; - while (anIterator.More ()) { - aFile = anIterator.Values (); - aFile.Path (aPath); - aName = aPath.Name (); - anAddInList = ( !aCheckExisted || - (aCheckExisted && !ItemIndex(aList, aName)) ); - if (aNeedExtension!=NULL) - anAddInList = (anAddInList && (aPath.Extension() == aNeedExtension)); - anAddInList = (anAddInList && !aName.IsEmpty()); - if (anAddInList) -#ifdef SORT_LIST - { - Standard_Integer i = 1, n = aList->Length(); - if (n != 0) { - while ( i < n && (aList->Value(i) < aName) ) i++; - if (i == n) aList->Append(aName); - else aList->InsertBefore(i, aName); - } else aList->Append(aName); - } -#else - aList->Append(aName); -#endif - anIterator.Next(); - } -} -#undef SORT_LIST diff --git a/src/PlotMgt/PlotMgt_PlotterTools.hxx b/src/PlotMgt/PlotMgt_PlotterTools.hxx deleted file mode 100755 index de82efe195..0000000000 --- a/src/PlotMgt/PlotMgt_PlotterTools.hxx +++ /dev/null @@ -1,204 +0,0 @@ -// Copyright (c) 1999-2012 OPEN CASCADE SAS -// -// The content of this file is subject to the Open CASCADE Technology Public -// License Version 6.5 (the "License"). You may not use the content of this file -// except in compliance with the License. Please obtain a copy of the License -// at http://www.opencascade.org and read it completely before using this file. -// -// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its -// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. -// -// The Original Code and all software distributed under the License is -// distributed on an "AS IS" basis, without warranty of any kind, and the -// Initial Developer hereby disclaims all such warranties, including without -// limitation, any warranties of merchantability, fitness for a particular -// purpose or non-infringement. Please see the License for the specific terms -// and conditions governing the rights and limitations under the License. - -#ifndef PLOTMGT_PLOTTERTOOLS -#define PLOTMGT_PLOTTERTOOLS - -#include - -#include -#include -#include -#include -#include -#include -#include -#ifndef WNT -# include -# include -#else -# define STRICT -# include -# pragma comment (lib,"GDI32.LIB") -#endif // WNT - -#define _T_UNK PlotMgt_TOPP_Undefined -#define _T_INT PlotMgt_TOPP_Integer -#define _T_REAL PlotMgt_TOPP_Real -#define _T_BOOL PlotMgt_TOPP_Boolean -#define _T_STR PlotMgt_TOPP_String -#define _T_LSTR PlotMgt_TOPP_ListString - -#define _TYPE_SIGN ".Type" -#define _DIALOG_SIGN ".Dialog" -#define _MINVAL_SIGN ".Min" -#define _MAXVAL_SIGN ".Max" -#define _VALUES_SIGN ".Values" -#define _LENGTH_SIGN ".Length" -#define _DELIM_SIGN " : " - -typedef struct _ParameterDesc { - Standard_CString _new_name; - Standard_CString _old_name; - PlotMgt_TypeOfPlotterParameter _type; - Standard_Integer _ismap; -} ParameterDesc; - -extern ParameterDesc __PossibleParameters[]; - -//============================================================================== -#define PLOT_CONFIGVER "ConfigurationVersion" -#define PLOT_DIALOGUNIT "DialogUnit" -#define PLOT_MODEL "Model" -#define PLOT_OUTFORMAT "OutputFormat" -#define PLOT_IMGFORMAT "ImageFormat" -#define PLOT_SETBKWHITE "SetBackgroundInWhite" -#define PLOT_TITLE "Title" -#define PLOT_DRVTYPE "DriverType" -#define PLOT_EXTENSION "Extension" -#define PLOT_PAPERFORMAT "PaperFormat" -#define PLOT_ORIENTATION "PlottingOrientation" -#define PLOT_MIRRORDRIVEN "MirroringDriven" -#define PLOT_MIRRORING "PlottingMirroring" -#define PLOT_PAPERWIDTH "PaperWidth" -#define PLOT_PAPERLENGTH "PaperLength" -#define PLOT_QUALITYDRIVEN "QualityDriven" -#define PLOT_QUALITY "Quality" -#define PLOT_COPYDRIVEN "CopyDriven" -#define PLOT_FEEDDRIVEN "PaperFeedDriven" -#define PLOT_PAPERFEED "PaperFeed" -#define PLOT_CUTDRIVEN "PaperCutDriven" -#define PLOT_ORIGIN "Origin" -#define PLOT_MINLEFTMARGIN "MinLeftMargin" -#define PLOT_MINBOTTOMMARGIN "MinBottomMargin" -#define PLOT_MINTOPMARGIN "MinTopMargin" -#define PLOT_MINRIGHTMARGIN "MinRightMargin" -#define PLOT_LEFTMARGIN "LeftMargin" -#define PLOT_BOTTOMMARGIN "BottomMargin" -#define PLOT_TOPMARGIN "TopMargin" -#define PLOT_RIGHTMARGIN "RightMargin" -#define PLOT_PLOTTINGGAP "PlottingGap" -#define PLOT_PLOTTERCOLOR "PlotterColor" -#define PLOT_MAXCOLORS "MaxColors" -#define PLOT_PLOTTINGCOLOR "PlottingColor" -#define PLOT_COLORMAPPING "ColorMapping" -#define PLOT_MAXPATTERMS "MaxPatterns" -#define PLOT_COLORMAPRGB "ColorMapRGB" -#define PLOT_COLORMAXGAP "ColorMaxGap" -#define PLOT_WIDTHMAP "WidthMap" -#define PLOT_WIDTHMAXGAP "WidthMaxGap" -#define PLOT_LINETYPEMAP "LineTypeMap" -#define PLOT_LINETYPEMAXGAP "LineTypeMaxGap" -#define PLOT_RESOLUTION "Resolution" -#define PLOT_COLORRESOLUTION "ColorResolution" -#define PLOT_CIRCLEDRIVEN "CircleDriven" -#define PLOT_ELLIPSEDRIVEN "EllipseDriven" -#define PLOT_CURVEDRIVEN "CurveDriven" -#define PLOT_TEXTDRIVEN "TextDriven" -#define PLOT_MARKERDRIVEN "MarkerDriven" -#define PLOT_RECTANGLEDRIVEN "RectangleDriven" -#define PLOT_FILLDRIVEN "FillDriven" -#define PLOT_FONTMAP "FontMap" -#define PLOT_PLOTTINGTYPE "PlottingType" -#define PLOT_STYLUSNUMBER "StylusNumber" -#define PLOT_DENSITY "LinearDensity" -#define PLOT_MAXPENS "MaxPens" -#define PLOT_MOUNTEDPENS "MountedPens" -#define PLOT_PENSINDEXWIDTH "PensIndexWidth" -#define PLOT_PENSINDEXCOLOR "PensIndexColor" -#define PLOT_PENSINDEXTYPE "PensIndexLineType" -#define PLOT_CHECKSUMDRIVEN "ChecksumDriven" -#define PLOT_BEFORECMD "CommandBeforeDriver" -#define PLOT_AFTERCMD "CommandAfterDriver" -#define PLOT_PRINTCMD "CommandToPrint" -#define PLOT_MEDIASAVDRIVEN "MediaSaverDriven" -#define PLOT_MEDIASAVTIME "MediaSaverTimeOut" -#define PLOT_ENDOFPLOTDRIVEN "EndOfPlotTimerDriven" -#define PLOT_ENDOFPLOTTIMER "EndOfPlotTimer" -#define PLOT_DRYTIMEDRIVEN "DryTimeDriven" -#define PLOT_DRYTIME "DryTime" -#define PLOT_PHYSICALSTEP "PhysicalStep" -#define PLOT_MINWIDTHOFLINE "MinWidthOfLine" -#define PLOT_COPIES "PlottingCopie" -#define PLOT_ROTATEDRIVEN "RotationDriven" -#define PLOT_ROTATION "PlottingRotation" -#define PLOT_FRAME "PlottingFrame" -#define PLOT_FRAMEAROUNDIMG "FrameAroundImage" -#define PLOT_MULTISHEET "PlottingMultiSheet" -#define PLOT_PLOTCOMMENT "PlottingComment" -#define PLOT_COMMENTS "Comment" -#define PLOT_PLOTTITLE "PlottingTitle" -#define PLOT_PLOTBACKDRAW "PlottingBackDraw" -#define PLOT_BACKDRAW "BackgroundDrawing" -#define PLOT_WIDTHOFFSET "WidthOffset" -#define PLOT_WIDTHSCALE "WidthScale" -#define PLOT_LENGTHOFFSET "LengthOffset" -#define PLOT_LENGTHSCALE "LengthScale" -#define PLOT_FILLWIDTH "FillWidth" - -//============================================================================== -#ifdef WNT - #define GET_WNT_DEVICE_SIZE() \ - HDC hdc; \ - if (!lstrcmpi (myName.ToCString(), "DISPLAY")) \ - hdc = CreateDC ("DISPLAY", NULL, NULL, NULL); \ - else \ - hdc = CreateDC ("WINSPOOL", myName.ToCString(), NULL, NULL); \ - if (hdc != NULL) { \ - myWidth = ((Standard_Real)GetDeviceCaps (hdc, HORZSIZE) / 10.); \ - myLength = ((Standard_Real)GetDeviceCaps (hdc, VERTSIZE) / 10.); \ - DeleteDC (hdc); \ - } -#else - #define GET_WNT_DEVICE_SIZE() { myWidth = 0.0; myLength = 0.0; } -#endif - -//============================================================================== -#define TRIM_RIGHT(aBuffer) \ - { \ - int aPos = strlen (aBuffer); \ - while ( ((aBuffer[aPos-1] == '\n') || \ - (aBuffer[aPos-1] == ' ' )) && \ - aPos ) \ - aPos--; \ - aBuffer [aPos] = '\0'; \ - } - - -//============================================================================== -#define BAD_VALUE1(theVal) (theVal <= 0) - -#define BAD_VALUE2(theVal) ((theVal != 0) && (theVal != -1)) - -#define BAD_PLOTTER_MSG() \ - cout << "Plotter ignored : BAD CONFIG ('" << aModel << "','" \ - << aOutFormat << "'," << anImgFormat << ")\n" << flush; - -//============================================================================== -Standard_CString PARAM_BAD_VALUE1 (const Standard_CString aMethodName); -Standard_CString PARAM_BAD_VALUE2 (const Standard_CString aMethodName); -char* trim (char* buffer); -Standard_Integer ItemIndex (Handle(TColStd_HSequenceOfAsciiString)&, - const TCollection_AsciiString&, - const Standard_Integer nStartIndex = 1); -void FillListByIterator (Handle(TColStd_HSequenceOfAsciiString)& aList, - OSD_FileIterator& anIterator, - Standard_CString aNeedExtension, - // If plotter already exist in the list do not use it. - const Standard_Boolean aCheckExisted = Standard_False); - -#endif // PLOTMGT_PLOTTERTOOLS diff --git a/src/PlotMgt/PlotMgt_Plotter_1.cxx b/src/PlotMgt/PlotMgt_Plotter_1.cxx deleted file mode 100755 index 2da8d70f9e..0000000000 --- a/src/PlotMgt/PlotMgt_Plotter_1.cxx +++ /dev/null @@ -1,765 +0,0 @@ -// Created by: DCB -// Copyright (c) 1999 Matra Datavision -// Copyright (c) 1999-2012 OPEN CASCADE SAS -// -// The content of this file is subject to the Open CASCADE Technology Public -// License Version 6.5 (the "License"). You may not use the content of this file -// except in compliance with the License. Please obtain a copy of the License -// at http://www.opencascade.org and read it completely before using this file. -// -// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its -// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. -// -// The Original Code and all software distributed under the License is -// distributed on an "AS IS" basis, without warranty of any kind, and the -// Initial Developer hereby disclaims all such warranties, including without -// limitation, any warranties of merchantability, fitness for a particular -// purpose or non-infringement. Please see the License for the specific terms -// and conditions governing the rights and limitations under the License. - -// Contains all plotter's Inquire methods - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -//============================================================================== -Standard_Integer PlotMgt_Plotter::NumberOfParameters () -{ - return myParameters -> Length (); -} - -//============================================================================== -const Handle(PlotMgt_PlotterParameter)& PlotMgt_Plotter::Parameter (const Standard_Integer anIndex) -{ - PlotMgt_PlotterAccessError_Raise_if ((anIndex < 1) || (anIndex > myParameters -> Length ()), - "PlotMgt_Plotter::Parameter() : index is out of range."); - return myParameters -> Value (anIndex); -} - -//============================================================================== -TCollection_AsciiString PlotMgt_Plotter::Name () -{ - return myName; -} - -//============================================================================== -TCollection_AsciiString PlotMgt_Plotter::Model () -{ -// if (myModel.IsEmpty()) GetStringValue (PLOT_MODEL, myModel); - if (myModel.IsEmpty()) GetStringValue (PLOT_DRVTYPE, myModel); - return myModel; -} - -//============================================================================== -TCollection_AsciiString PlotMgt_Plotter::Title () -{ - if (myTitle.IsEmpty()) GetStringValue (PLOT_TITLE, myTitle); - return myTitle; -} - -//============================================================================== -TCollection_AsciiString PlotMgt_Plotter::FileExtension () -{ - if (myExtension.IsEmpty()) GetStringValue (PLOT_EXTENSION, myExtension); - return myExtension; -} - -//============================================================================== -TCollection_AsciiString PlotMgt_Plotter::PrintCommand () -{ - if (myPrintCommand.IsEmpty()) GetStringValue (PLOT_PRINTCMD, myPrintCommand); - return myPrintCommand; -} - -//============================================================================== -TCollection_AsciiString PlotMgt_Plotter::BeforePrintCommand () -{ - if (myBeforeCommand.IsEmpty()) GetStringValue (PLOT_BEFORECMD, myBeforeCommand); - return myBeforeCommand; -} - -//============================================================================== -TCollection_AsciiString PlotMgt_Plotter::AfterPrintCommand () -{ - if (myAfterCommand.IsEmpty()) GetStringValue (PLOT_AFTERCMD, myAfterCommand); - return myAfterCommand; -} - -//============================================================================== -TCollection_AsciiString PlotMgt_Plotter::Comments () -{ - if (myComments.IsEmpty()) GetStringValue (PLOT_COMMENTS, myComments); - return myComments; -} - -//============================================================================== -TCollection_AsciiString PlotMgt_Plotter::BackDraw () -{ - if (myBackDraw.IsEmpty()) GetStringValue (PLOT_BACKDRAW, myBackDraw); - return myBackDraw; -} - -//============================================================================== -TCollection_AsciiString PlotMgt_Plotter::ColorMapping () -{ - if (myColorMapping.IsEmpty()) GetStringValue (PLOT_COLORMAPPING, myColorMapping); - return myColorMapping; -} - -//============================================================================== -TCollection_AsciiString PlotMgt_Plotter::OutputFormat () -{ - if (myOutputFormat.IsEmpty()) GetStringValue (PLOT_OUTFORMAT, myOutputFormat); - return myOutputFormat; -} - -//============================================================================== -TCollection_AsciiString PlotMgt_Plotter::DriverType () -{ - if (myDriverType.IsEmpty()) GetStringValue (PLOT_DRVTYPE, myDriverType); - return myDriverType; -} - -//============================================================================== -//============================================================================== -//============================================================================== -//============================================================================== -//============================================================================== -//============================================================================== -//============================================================================== -//============================================================================== -//============================================================================== -Handle(TColStd_HSequenceOfAsciiString) PlotMgt_Plotter::ListOfPaperFormats () -{ - if (myListOfPaperFormats.IsNull ()) - GetListValue (PLOT_PAPERFORMAT, myListOfPaperFormats); - return myListOfPaperFormats; -} - -//============================================================================== -Handle(TColStd_HSequenceOfAsciiString) PlotMgt_Plotter::ListOfOrigins () -{ - if (myListOfOrigins.IsNull ()) - GetListValue (PLOT_ORIGIN, myListOfOrigins); - return myListOfOrigins; -} - -//============================================================================== -Handle(TColStd_HSequenceOfAsciiString) PlotMgt_Plotter::ListOfQualities () -{ - if (myListOfQualities.IsNull ()) - GetListValue (PLOT_QUALITY, myListOfQualities); - return myListOfQualities; -} - -//============================================================================== -Handle(TColStd_HSequenceOfAsciiString) PlotMgt_Plotter::ListOfImageFormats () -{ - if (myListOfImageFormats.IsNull ()) - GetListValue (PLOT_IMGFORMAT, myListOfImageFormats); - return myListOfImageFormats; -} - -//============================================================================== -Handle(TColStd_HSequenceOfAsciiString) PlotMgt_Plotter::ListOfColorMappings () -{ - if (myListOfColorMappings.IsNull ()) - GetListValue (PLOT_COLORMAPPING, myListOfColorMappings); - return myListOfColorMappings; -} - -//============================================================================== -Handle(TColStd_HSequenceOfAsciiString) PlotMgt_Plotter::ListOfOutputFormats () -{ - if (myListOfOutputFormats.IsNull ()) - GetListValue (PLOT_OUTFORMAT, myListOfOutputFormats); - return myListOfOutputFormats; -} - -//============================================================================== -Handle(TColStd_HSequenceOfAsciiString) PlotMgt_Plotter::ListOfDriverTypes () -{ - if (myListOfDriverTypes.IsNull ()) - GetListValue (PLOT_DRVTYPE, myListOfDriverTypes); - return myListOfDriverTypes; -} - -//============================================================================== -//============================================================================== -//============================================================================== -//============================================================================== -//============================================================================== -//============================================================================== -//============================================================================== -//============================================================================== -//============================================================================== -Standard_Boolean PlotMgt_Plotter::MirrorPlot () -{ - return GetBooleanValue (PLOT_MIRRORING); -} - -//============================================================================== -Standard_Boolean PlotMgt_Plotter::MultiSheet () -{ - return GetBooleanValue (PLOT_MULTISHEET); -} - -//============================================================================== -Standard_Boolean PlotMgt_Plotter::FramePlot () -{ - return GetBooleanValue (PLOT_FRAME); -} - - - -//============================================================================== -Standard_Boolean PlotMgt_Plotter::PlotTitle () -{ - return GetBooleanValue (PLOT_PLOTTITLE); -} - -//============================================================================== -Standard_Boolean PlotMgt_Plotter::PlotComments () -{ - return GetBooleanValue (PLOT_PLOTCOMMENT); -} - -//============================================================================== -Standard_Boolean PlotMgt_Plotter::PlotBackDraw () -{ - return GetBooleanValue (PLOT_PLOTBACKDRAW); -} - - - -//============================================================================== -Standard_Boolean PlotMgt_Plotter::PlotterColor () -{ - return GetBooleanValue (PLOT_PLOTTERCOLOR); -} - -//============================================================================== -Standard_Boolean PlotMgt_Plotter::EndOfPlotDriven () -{ - return GetBooleanValue (PLOT_ENDOFPLOTDRIVEN); -} - -//============================================================================== -Standard_Boolean PlotMgt_Plotter::DryTimeDriven () -{ - return GetBooleanValue (PLOT_DRYTIMEDRIVEN); -} - -//============================================================================== -Standard_Boolean PlotMgt_Plotter::PaperFeedDriven () -{ - return GetBooleanValue (PLOT_FEEDDRIVEN); -} - -//============================================================================== -Standard_Boolean PlotMgt_Plotter::MirrorDriven () -{ - return GetBooleanValue (PLOT_MIRRORDRIVEN); -} - -//============================================================================== -Standard_Boolean PlotMgt_Plotter::CheckSumDriven () -{ - return GetBooleanValue (PLOT_CHECKSUMDRIVEN); -} - -//============================================================================== -Standard_Boolean PlotMgt_Plotter::MediaSaverDriven () -{ - return GetBooleanValue (PLOT_MEDIASAVDRIVEN); -} - -//============================================================================== -Standard_Boolean PlotMgt_Plotter::QualityDriven () -{ - return GetBooleanValue (PLOT_QUALITYDRIVEN); -} - -//============================================================================== -Standard_Boolean PlotMgt_Plotter::CopyDriven () -{ - return GetBooleanValue (PLOT_COPYDRIVEN); -} - -//============================================================================== -Standard_Boolean PlotMgt_Plotter::PaperCutDriven () -{ - return GetBooleanValue (PLOT_CUTDRIVEN); -} - -//============================================================================== -Standard_Boolean PlotMgt_Plotter::RotateDriven () -{ - return GetBooleanValue (PLOT_ROTATEDRIVEN); -} - - - -//============================================================================== -Standard_Boolean PlotMgt_Plotter::CircleDriven () -{ - return GetBooleanValue (PLOT_CIRCLEDRIVEN); -} - -//============================================================================== -Standard_Boolean PlotMgt_Plotter::EllipseDriven () -{ - return GetBooleanValue (PLOT_ELLIPSEDRIVEN); -} - -//============================================================================== -Standard_Boolean PlotMgt_Plotter::CurveDriven () -{ - return GetBooleanValue (PLOT_CURVEDRIVEN); -} - -//============================================================================== -Standard_Boolean PlotMgt_Plotter::TextDriven () -{ - return GetBooleanValue (PLOT_TEXTDRIVEN); -} - -//============================================================================== -Standard_Boolean PlotMgt_Plotter::MarkerDriven () -{ - return GetBooleanValue (PLOT_MARKERDRIVEN); -} - -//============================================================================== -Standard_Boolean PlotMgt_Plotter::RectangleDriven () -{ - return GetBooleanValue (PLOT_RECTANGLEDRIVEN); -} - -//============================================================================== -Standard_Boolean PlotMgt_Plotter::FillDriven () -{ - return GetBooleanValue (PLOT_FILLDRIVEN); -} - -//============================================================================== -Standard_Boolean PlotMgt_Plotter::PlottingColor () -{ - return GetBooleanValue (PLOT_PLOTTINGCOLOR); -} - -//============================================================================== -//============================================================================== -//============================================================================== -//============================================================================== -//============================================================================== -//============================================================================== -//============================================================================== -//============================================================================== -Standard_Real PlotMgt_Plotter::PaperWidth () -{ - return GetRealValue (PLOT_PAPERWIDTH); -} - -//============================================================================== -Standard_Real PlotMgt_Plotter::PaperLength () -{ - return GetRealValue (PLOT_PAPERLENGTH); -} - -//============================================================================== -void PlotMgt_Plotter::PaperSize (Standard_Real& aWidth, - Standard_Real& aLength) -{ - aWidth = PaperWidth (); - aLength = PaperLength (); -} - -//============================================================================== -void PlotMgt_Plotter::HardMargins (Standard_Real& aLeft, - Standard_Real& aTop, - Standard_Real& aRight, - Standard_Real& aBottom) -{ - aTop = GetRealValue (PLOT_MINTOPMARGIN ); - aLeft = GetRealValue (PLOT_MINLEFTMARGIN ); - aRight = GetRealValue (PLOT_MINRIGHTMARGIN ); - aBottom = GetRealValue (PLOT_MINBOTTOMMARGIN); -} - -//============================================================================== -void PlotMgt_Plotter::Margins (Standard_Real& aLeft, - Standard_Real& aTop, - Standard_Real& aRight, - Standard_Real& aBottom) -{ - aTop = GetRealValue (PLOT_TOPMARGIN ); - aLeft = GetRealValue (PLOT_LEFTMARGIN ); - aRight = GetRealValue (PLOT_RIGHTMARGIN ); - aBottom = GetRealValue (PLOT_BOTTOMMARGIN); -} - -//============================================================================== -void PlotMgt_Plotter::HardMappings (Standard_Real& aWOffset, - Standard_Real& aWScale, - Standard_Real& anLOffset, - Standard_Real& anLScale) -{ - aWOffset = GetRealValue (PLOT_WIDTHOFFSET ); - aWScale = GetRealValue (PLOT_WIDTHSCALE ); - anLOffset = GetRealValue (PLOT_LENGTHOFFSET); - anLScale = GetRealValue (PLOT_LENGTHSCALE ); -} - -//============================================================================== -Standard_Real PlotMgt_Plotter::SpaceDrawing () -{ - return GetRealValue (PLOT_PLOTTINGGAP); -} - -//============================================================================== -Standard_Real PlotMgt_Plotter::PhysicalStep () -{ - return GetRealValue (PLOT_PHYSICALSTEP); -} - -//============================================================================== -Standard_Real PlotMgt_Plotter::MinWidthOfLine () -{ - return GetRealValue (PLOT_MINWIDTHOFLINE); -} - -//============================================================================== -Standard_Real PlotMgt_Plotter::WidthMaxGap () -{ - return GetRealValue (PLOT_WIDTHMAXGAP); -} - -//============================================================================== -Standard_Real PlotMgt_Plotter::LineTypeMaxGap () -{ - return GetRealValue (PLOT_LINETYPEMAXGAP); -} - -//============================================================================== -Standard_Real PlotMgt_Plotter::Resolution () -{ - return GetRealValue (PLOT_RESOLUTION); -} - -//============================================================================== -Standard_Real PlotMgt_Plotter::ColorResolution () -{ - return GetRealValue (PLOT_COLORRESOLUTION); -} - -//============================================================================== -Standard_Real PlotMgt_Plotter::FillWidth () -{ - return GetRealValue (PLOT_FILLWIDTH); -} - -//============================================================================== -//============================================================================== -//============================================================================== -//============================================================================== -//============================================================================== -//============================================================================== -//============================================================================== -//============================================================================== -Standard_Integer PlotMgt_Plotter::MediaSaverDelay () -{ - return GetIntegerValue (PLOT_MEDIASAVTIME); -} - -//============================================================================== -Standard_Integer PlotMgt_Plotter::NumberOfCopies () -{ - return GetIntegerValue (PLOT_COPIES); -} - -//============================================================================== -Standard_Integer PlotMgt_Plotter::DryTime () -{ - return GetIntegerValue (PLOT_DRYTIME); -} - -//============================================================================== -Standard_Integer PlotMgt_Plotter::EndOfPlotTimer () -{ - return GetIntegerValue (PLOT_ENDOFPLOTTIMER); -} - -//============================================================================== -Standard_Integer PlotMgt_Plotter::MaxColors () -{ - return GetIntegerValue (PLOT_MAXCOLORS); -} - -//============================================================================== -Standard_Integer PlotMgt_Plotter::MaxPatterns () -{ - return GetIntegerValue (PLOT_MAXPATTERMS); -} - -//============================================================================== -Standard_Integer PlotMgt_Plotter::ColorMaxGap () -{ - return GetIntegerValue (PLOT_COLORMAXGAP); -} - -//============================================================================== -Standard_Integer PlotMgt_Plotter::LinearDensity () -{ - return GetIntegerValue (PLOT_DENSITY); -} - -//============================================================================== -Standard_Integer PlotMgt_Plotter::StylusNumber () -{ - return GetIntegerValue (PLOT_STYLUSNUMBER); -} - -//============================================================================== -Standard_Integer PlotMgt_Plotter::PenMaxNumber () -{ - return GetIntegerValue (PLOT_MAXPENS); -} - -//============================================================================== -Standard_Integer PlotMgt_Plotter::NumberInCarrousel () -{ - return GetIntegerValue (PLOT_MOUNTEDPENS); -} - -//============================================================================== -//============================================================================== -//============================================================================== -//============================================================================== -//============================================================================== -//============================================================================== -//============================================================================== -//============================================================================== -PlotMgt_TypeOfOrigin PlotMgt_Plotter::Origin () -{ - TCollection_AsciiString anOrigin; - GetStringValue (PLOT_ORIGIN, anOrigin); - return PlotMgt::OriginFromString (anOrigin); -} - -//============================================================================== -PlotMgt_TypeOfQuality PlotMgt_Plotter::Quality () -{ - TCollection_AsciiString aQuality; - GetStringValue (PLOT_QUALITY, aQuality); - return PlotMgt::QualityFromString (aQuality); -} - -//============================================================================== -PlotMgt_ImageFormat PlotMgt_Plotter::ImageFormat () -{ - TCollection_AsciiString anImageFormat; - GetStringValue (PLOT_IMGFORMAT, anImageFormat); - return PlotMgt::ImageFormatFromString (anImageFormat); -} - -//============================================================================== -PlotMgt_PlottingType PlotMgt_Plotter::PlottingType () -{ - TCollection_AsciiString aPlottingType; - GetStringValue (PLOT_PLOTTINGTYPE, aPlottingType); - return PlotMgt::PlottingTypeFromString (aPlottingType); -} - -//============================================================================== -PlotMgt_PaperFormat PlotMgt_Plotter::PaperFormat () -{ - TCollection_AsciiString aPaperFormat; - GetStringValue (PLOT_PAPERFORMAT, aPaperFormat); - return PlotMgt::PaperFormatFromString (aPaperFormat); -} - -//============================================================================== -//============================================================================== -//============================================================================== -//============================================================================== -//============================================================================== -//============================================================================== -//============================================================================== - -//============================================================================== -Handle(TColStd_HSequenceOfInteger) PlotMgt_Plotter::PenColorIndex () -{ - if (myPenColorIndex.IsNull ()) - GetIntTable (PLOT_PENSINDEXCOLOR, myPenColorIndex); - return myPenColorIndex; -} - -//============================================================================== -Handle(TColStd_HSequenceOfInteger) PlotMgt_Plotter::PenWidthIndex () -{ - if (myPenWidthIndex.IsNull ()) - GetIntTable (PLOT_PENSINDEXWIDTH, myPenWidthIndex); - return myPenWidthIndex; -} - -//============================================================================== -Handle(TColStd_HSequenceOfInteger) PlotMgt_Plotter::PenTypeIndex () -{ - if (myPenTypeIndex.IsNull ()) - GetIntTable (PLOT_PENSINDEXTYPE, myPenTypeIndex); - return myPenTypeIndex; -} - -//============================================================================== -Handle(Aspect_ColorMap) PlotMgt_Plotter::ColorMap () -{ - Handle(TColStd_HSequenceOfAsciiString) aMap; - aMap.Nullify (); - if (myColorMap.IsNull ()) { - TCollection_AsciiString aLine, R, G, B; - Quantity_Color aColor; - Aspect_ColorMapEntry anEntry; - Standard_Integer i = FindParameter (PLOT_COLORMAPRGB), n; - if (i >= 1 && i <= NumberOfParameters ()) - aMap = myParameters -> Value (i) -> MValue (); - myColorMap = new Aspect_GenericColorMap (); - if (!aMap.IsNull()) { - n = aMap -> Length (); - for (i = 1; i <= n; i++) { - aLine = aMap -> Value (i); - aLine.RemoveAll ('\"'); - R = aLine.Token (" ", 1); - G = aLine.Token (" ", 2); - B = aLine.Token (" ", 3); - if (R.IsEmpty() || !R.IsRealValue()) R = TCollection_AsciiString (0.0); - if (G.IsEmpty() || !G.IsRealValue()) G = TCollection_AsciiString (0.0); - if (B.IsEmpty() || !B.IsRealValue()) B = TCollection_AsciiString (0.0); - aColor = Quantity_Color (R.RealValue(), G.RealValue(), B.RealValue(), Quantity_TOC_RGB); - anEntry.SetValue (i-1, aColor); - myColorMap -> AddEntry (anEntry); - } - } - } - return myColorMap; -} - -//============================================================================== -Handle(Aspect_WidthMap) PlotMgt_Plotter::WidthMap () -{ - Handle(TColStd_HSequenceOfAsciiString) aMap; - aMap.Nullify (); - if (myWidthMap.IsNull ()) { - TCollection_AsciiString aW; - Aspect_WidthMapEntry anEntry; - myWidthMap = new Aspect_WidthMap (); - Standard_Integer i = FindParameter (PLOT_WIDTHMAP), n; - if (i >= 1 && i <= NumberOfParameters ()) - aMap = myParameters -> Value (i) -> MValue (); - if (!aMap.IsNull()) { - n = aMap -> Length (); - for (i = 1; i <= n; i++) { - aW = aMap -> Value (i); - aW.RemoveAll (' '); - if (!aW.IsEmpty () && aW.IsRealValue()) { - anEntry.SetValue (i-1, aW.RealValue () * 10.); // To MM - myWidthMap -> AddEntry (anEntry); - } - } - } - } - return myWidthMap; -} - -//============================================================================== -Handle(Aspect_TypeMap) PlotMgt_Plotter::TypeMap () -{ - Handle(TColStd_HSequenceOfAsciiString) aMap; - aMap.Nullify (); - if (myTypeMap.IsNull ()) { - TCollection_AsciiString aLine, aValue; - Aspect_LineStyle aStyle; - Aspect_TypeMapEntry anEntry; - myTypeMap = new Aspect_TypeMap (); - Standard_Integer i = FindParameter (PLOT_LINETYPEMAP), n, p, j; - if (i >= 1 && i <= NumberOfParameters ()) - aMap = myParameters -> Value (i) -> MValue (); - if (!aMap.IsNull()) { - n = aMap -> Length (); - for (i = 1; i <= n; i++) { - aLine = aMap -> Value (i); - aLine.RemoveAll ('\"'); - // Count of elements in line style - p = 0; - do { - aValue = aLine.Token (" ", p+1); - if (!aValue.IsEmpty ()) - p++; - } while (!aValue.IsEmpty ()); - // If there are some elements - if (p > 1) { - TColQuantity_Array1OfLength aValues (1, p); - for (j = 1; j <= p; j++) { - aValue = aLine.Token (" ", j); - aValues.SetValue (j, aValue.RealValue ()); - } - aStyle.SetValues (aValues); - } else { // else add solid line - aStyle = Aspect_LineStyle (Aspect_TOL_SOLID); - } - anEntry.SetValue (i-1, aStyle); - myTypeMap -> AddEntry (anEntry); - } - } - } - return myTypeMap; -} - -//============================================================================== -Handle(Aspect_FontMap) PlotMgt_Plotter::FontMap () -{ - Handle(TColStd_HSequenceOfAsciiString) aMap; - aMap.Nullify (); - if (myFontMap.IsNull ()) { - TCollection_AsciiString aLine; - Aspect_FontStyle aStyle; - Aspect_FontMapEntry anEntry; - myFontMap = new Aspect_FontMap (); - Standard_Integer i = FindParameter (PLOT_FONTMAP), n; - if (i >= 1 && i <= NumberOfParameters ()) - aMap = myParameters -> Value (i) -> MValue (); - if (!aMap.IsNull()) { - n = aMap -> Length (); - for (i = 1; i <= n; i++) { - aLine = aMap -> Value (i); - aStyle.SetValues (aLine.ToCString ()); - anEntry.SetValue (i-1, aStyle); - myFontMap -> AddEntry (anEntry); - } - } - } - return myFontMap; -} - -//============================================================================== -Handle(Aspect_FontMap) PlotMgt_Plotter::AllFonts () -{ - if (myAllFonts.IsNull ()) - myAllFonts = new Aspect_FontMap (); - return myAllFonts; -} diff --git a/src/PlotMgt/PlotMgt_Plotter_2.cxx b/src/PlotMgt/PlotMgt_Plotter_2.cxx deleted file mode 100755 index ffa98a682d..0000000000 --- a/src/PlotMgt/PlotMgt_Plotter_2.cxx +++ /dev/null @@ -1,605 +0,0 @@ -// Created by: DCB -// Copyright (c) 1999 Matra Datavision -// Copyright (c) 1999-2012 OPEN CASCADE SAS -// -// The content of this file is subject to the Open CASCADE Technology Public -// License Version 6.5 (the "License"). You may not use the content of this file -// except in compliance with the License. Please obtain a copy of the License -// at http://www.opencascade.org and read it completely before using this file. -// -// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its -// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. -// -// The Original Code and all software distributed under the License is -// distributed on an "AS IS" basis, without warranty of any kind, and the -// Initial Developer hereby disclaims all such warranties, including without -// limitation, any warranties of merchantability, fitness for a particular -// purpose or non-infringement. Please see the License for the specific terms -// and conditions governing the rights and limitations under the License. - -// Contains all plotter's SetXXX methods - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -//============================================================================== -void PlotMgt_Plotter::SetModel (const TCollection_AsciiString& aValue) -{ - SetStringValue (PLOT_DRVTYPE, myModel, aValue); -} - -//============================================================================== -void PlotMgt_Plotter::SetTitle (const TCollection_AsciiString& aValue) -{ - SetStringValue (PLOT_TITLE, myTitle, aValue); -} - -//============================================================================== -void PlotMgt_Plotter::SetFileExtension (const TCollection_AsciiString& aValue) -{ - SetStringValue (PLOT_EXTENSION, myExtension, aValue); -} - -//============================================================================== -void PlotMgt_Plotter::SetPrintCommand (const TCollection_AsciiString& aValue) -{ - SetStringValue (PLOT_PRINTCMD, myPrintCommand, aValue); -} - -//============================================================================== -void PlotMgt_Plotter::SetBeforePrintCommand (const TCollection_AsciiString& aValue) -{ - SetStringValue (PLOT_BEFORECMD, myBeforeCommand, aValue); -} - -//============================================================================== -void PlotMgt_Plotter::SetAfterPrintCommand (const TCollection_AsciiString& aValue) -{ - SetStringValue (PLOT_AFTERCMD, myAfterCommand, aValue); -} - -//============================================================================== -void PlotMgt_Plotter::SetComments (const TCollection_AsciiString& aValue) -{ - SetStringValue (PLOT_COMMENTS, myComments, aValue); -} - -//============================================================================== -void PlotMgt_Plotter::SetBackDraw (const TCollection_AsciiString& aValue) -{ - SetStringValue (PLOT_BACKDRAW, myBackDraw, aValue); -} - -//============================================================================== -void PlotMgt_Plotter::SetColorMapping (const TCollection_AsciiString& aValue) -{ - SetStringValue (PLOT_COLORMAPPING, myColorMapping, aValue); -} - -//============================================================================== -void PlotMgt_Plotter::SetOutputFormat (const TCollection_AsciiString& aValue) -{ - SetStringValue (PLOT_OUTFORMAT, myOutputFormat, aValue); -} - -//============================================================================== -void PlotMgt_Plotter::SetDriverType (const TCollection_AsciiString& aValue) -{ - SetStringValue (PLOT_DRVTYPE, myDriverType, aValue); -} - -//============================================================================== -//============================================================================== -//============================================================================== -//============================================================================== -//============================================================================== -//============================================================================== -//============================================================================== -//============================================================================== -//============================================================================== -void PlotMgt_Plotter::SetMirrorPlot (const Standard_Boolean aValue) -{ - SetBooleanValue (PLOT_MIRRORING, aValue); -} - -//============================================================================== -void PlotMgt_Plotter::SetMultiSheet (const Standard_Boolean aValue) -{ - SetBooleanValue (PLOT_MULTISHEET, aValue); -} - -//============================================================================== -void PlotMgt_Plotter::SetFramePlot (const Standard_Boolean aValue) -{ - SetBooleanValue (PLOT_FRAME, aValue); -} - - - -//============================================================================== -void PlotMgt_Plotter::SetPlotTitle (const Standard_Boolean aValue) -{ - SetBooleanValue (PLOT_PLOTTITLE, aValue); -} - -//============================================================================== -void PlotMgt_Plotter::SetPlotComments (const Standard_Boolean aValue) -{ - SetBooleanValue (PLOT_PLOTCOMMENT, aValue); -} - -//============================================================================== -void PlotMgt_Plotter::SetPlotBackDraw (const Standard_Boolean aValue) -{ - SetBooleanValue (PLOT_PLOTBACKDRAW, aValue); -} - - - -//============================================================================== -void PlotMgt_Plotter::SetPlotterColor (const Standard_Boolean aValue) -{ - SetBooleanValue (PLOT_PLOTTERCOLOR, aValue); -} - -//============================================================================== -void PlotMgt_Plotter::SetEndOfPlotDriven (const Standard_Boolean aValue) -{ - SetBooleanValue (PLOT_ENDOFPLOTDRIVEN, aValue); -} - -//============================================================================== -void PlotMgt_Plotter::SetDryTimeDriven (const Standard_Boolean aValue) -{ - SetBooleanValue (PLOT_DRYTIMEDRIVEN, aValue); -} - -//============================================================================== -void PlotMgt_Plotter::SetPaperFeedDriven (const Standard_Boolean aValue) -{ - SetBooleanValue (PLOT_FEEDDRIVEN, aValue); -} - -//============================================================================== -void PlotMgt_Plotter::SetMirrorDriven (const Standard_Boolean aValue) -{ - SetBooleanValue (PLOT_MIRRORDRIVEN, aValue); -} - -//============================================================================== -void PlotMgt_Plotter::SetCheckSumDriven (const Standard_Boolean aValue) -{ - SetBooleanValue (PLOT_CHECKSUMDRIVEN, aValue); -} - -//============================================================================== -void PlotMgt_Plotter::SetMediaSaverDriven (const Standard_Boolean aValue) -{ - SetBooleanValue (PLOT_MEDIASAVDRIVEN, aValue); -} - -//============================================================================== -void PlotMgt_Plotter::SetQualityDriven (const Standard_Boolean aValue) -{ - SetBooleanValue (PLOT_QUALITYDRIVEN, aValue); -} - -//============================================================================== -void PlotMgt_Plotter::SetCopyDriven (const Standard_Boolean aValue) -{ - SetBooleanValue (PLOT_COPYDRIVEN, aValue); -} - -//============================================================================== -void PlotMgt_Plotter::SetPaperCutDriven (const Standard_Boolean aValue) -{ - SetBooleanValue (PLOT_CUTDRIVEN, aValue); -} - -//============================================================================== -void PlotMgt_Plotter::SetRotateDriven (const Standard_Boolean aValue) -{ - SetBooleanValue (PLOT_ROTATEDRIVEN, aValue); -} - - - -//============================================================================== -void PlotMgt_Plotter::SetCircleDriven (const Standard_Boolean aValue) -{ - SetBooleanValue (PLOT_CIRCLEDRIVEN, aValue); -} - -//============================================================================== -void PlotMgt_Plotter::SetEllipseDriven (const Standard_Boolean aValue) -{ - SetBooleanValue (PLOT_ELLIPSEDRIVEN, aValue); -} - -//============================================================================== -void PlotMgt_Plotter::SetCurveDriven (const Standard_Boolean aValue) -{ - SetBooleanValue (PLOT_CURVEDRIVEN, aValue); -} - -//============================================================================== -void PlotMgt_Plotter::SetTextDriven (const Standard_Boolean aValue) -{ - SetBooleanValue (PLOT_TEXTDRIVEN, aValue); -} - -//============================================================================== -void PlotMgt_Plotter::SetMarkerDriven (const Standard_Boolean aValue) -{ - SetBooleanValue (PLOT_MARKERDRIVEN, aValue); -} - -//============================================================================== -void PlotMgt_Plotter::SetRectangleDriven (const Standard_Boolean aValue) -{ - SetBooleanValue (PLOT_RECTANGLEDRIVEN, aValue); -} - -//============================================================================== -void PlotMgt_Plotter::SetFillDriven (const Standard_Boolean aValue) -{ - SetBooleanValue (PLOT_FILLDRIVEN, aValue); -} - -//============================================================================== -void PlotMgt_Plotter::SetPlottingColor (const Standard_Boolean aValue) -{ - SetBooleanValue (PLOT_PLOTTINGCOLOR, aValue); -} - - -//============================================================================== -//============================================================================== -//============================================================================== -//============================================================================== -//============================================================================== -//============================================================================== -//============================================================================== -//============================================================================== -void PlotMgt_Plotter::SetPaperWidth (const Standard_Real aValue) -{ - SetRealValue (PLOT_PAPERWIDTH, aValue); -} - -//============================================================================== -void PlotMgt_Plotter::SetPaperLength (const Standard_Real aValue) -{ - SetRealValue (PLOT_PAPERLENGTH, aValue); -} - -//============================================================================== -void PlotMgt_Plotter::SetPaperSize (const Standard_Real aWidth, - const Standard_Real aLength) -{ - SetPaperWidth (aWidth); - SetPaperLength (aLength); -} - -//============================================================================== -void PlotMgt_Plotter::SetHardMargins (const Standard_Real aLeft, - const Standard_Real aTop, - const Standard_Real aRight, - const Standard_Real aBottom) -{ - SetRealValue (PLOT_MINTOPMARGIN, aTop); - SetRealValue (PLOT_MINLEFTMARGIN, aLeft); - SetRealValue (PLOT_MINRIGHTMARGIN, aRight); - SetRealValue (PLOT_MINBOTTOMMARGIN, aBottom); -} - -//============================================================================== -void PlotMgt_Plotter::SetMargins (const Standard_Real aLeft, - const Standard_Real aTop, - const Standard_Real aRight, - const Standard_Real aBottom) -{ - SetRealValue (PLOT_TOPMARGIN, aTop); - SetRealValue (PLOT_LEFTMARGIN, aLeft); - SetRealValue (PLOT_RIGHTMARGIN, aRight); - SetRealValue (PLOT_BOTTOMMARGIN, aBottom); -} - -//============================================================================== -void PlotMgt_Plotter::SetHardMappings (const Standard_Real aWOffset, - const Standard_Real aWScale, - const Standard_Real anLOffset, - const Standard_Real anLScale) -{ - SetRealValue (PLOT_WIDTHOFFSET, aWOffset); - SetRealValue (PLOT_WIDTHSCALE, aWScale); - SetRealValue (PLOT_LENGTHOFFSET, anLOffset); - SetRealValue (PLOT_LENGTHSCALE, anLScale); -} - -//============================================================================== -void PlotMgt_Plotter::SetSpaceDrawing (const Standard_Real aValue) -{ - SetRealValue (PLOT_PLOTTINGGAP, aValue); -} - -//============================================================================== -void PlotMgt_Plotter::SetPhysicalStep (const Standard_Real aValue) -{ - SetRealValue (PLOT_PHYSICALSTEP, aValue); -} - -//============================================================================== -void PlotMgt_Plotter::SetMinWidthOfLine (const Standard_Real aValue) -{ - SetRealValue (PLOT_MINWIDTHOFLINE, aValue); -} - -//============================================================================== -void PlotMgt_Plotter::SetWidthMaxGap (const Standard_Real aValue) -{ - SetRealValue (PLOT_WIDTHMAXGAP, aValue); -} - -//============================================================================== -void PlotMgt_Plotter::SetLineTypeMaxGap (const Standard_Real aValue) -{ - SetRealValue (PLOT_LINETYPEMAXGAP, aValue); -} - -//============================================================================== -void PlotMgt_Plotter::SetResolution (const Standard_Real aValue) -{ - SetRealValue (PLOT_RESOLUTION, aValue); -} - -//============================================================================== -void PlotMgt_Plotter::SetColorResolution (const Standard_Real aValue) -{ - SetRealValue (PLOT_COLORRESOLUTION, aValue); -} - -//============================================================================== -void PlotMgt_Plotter::SetFillWidth (const Standard_Real aValue) -{ - SetRealValue (PLOT_FILLWIDTH, aValue); -} - -//============================================================================== -//============================================================================== -//============================================================================== -//============================================================================== -//============================================================================== -//============================================================================== -//============================================================================== -//============================================================================== -void PlotMgt_Plotter::SetMediaSaverDelay (const Standard_Integer aValue) -{ - SetIntegerValue (PLOT_MEDIASAVTIME, aValue); -} - -//============================================================================== -void PlotMgt_Plotter::SetNumberOfCopies (const Standard_Integer aValue) -{ - SetIntegerValue (PLOT_COPIES, aValue); -} - -//============================================================================== -void PlotMgt_Plotter::SetDryTime (const Standard_Integer aValue) -{ - SetIntegerValue (PLOT_DRYTIME, aValue); -} - -//============================================================================== -void PlotMgt_Plotter::SetEndOfPlotTimer (const Standard_Integer aValue) -{ - SetIntegerValue (PLOT_ENDOFPLOTTIMER, aValue); -} - -//============================================================================== -void PlotMgt_Plotter::SetMaxColors (const Standard_Integer aValue) -{ - SetIntegerValue (PLOT_MAXCOLORS, aValue); -} - -//============================================================================== -void PlotMgt_Plotter::SetMaxPatterns (const Standard_Integer aValue) -{ - SetIntegerValue (PLOT_MAXPATTERMS, aValue); -} - -//============================================================================== -void PlotMgt_Plotter::SetColorMaxGap (const Standard_Integer aValue) -{ - SetIntegerValue (PLOT_COLORMAXGAP, aValue); -} - -//============================================================================== -void PlotMgt_Plotter::SetLinearDensity (const Standard_Integer aValue) -{ - SetIntegerValue (PLOT_DENSITY, aValue); -} - -//============================================================================== -void PlotMgt_Plotter::SetStylusNumber (const Standard_Integer aValue) -{ - SetIntegerValue (PLOT_STYLUSNUMBER, aValue); -} - -//============================================================================== -void PlotMgt_Plotter::SetPenMaxNumber (const Standard_Integer aValue) -{ - SetIntegerValue (PLOT_MAXPENS, aValue); -} - -//============================================================================== -void PlotMgt_Plotter::SetNumberInCarrousel (const Standard_Integer aValue) -{ - SetIntegerValue (PLOT_MOUNTEDPENS, aValue); -} - -//============================================================================== -//============================================================================== -//============================================================================== -//============================================================================== -//============================================================================== -//============================================================================== -//============================================================================== -//============================================================================== -void PlotMgt_Plotter::SetOrigin (const PlotMgt_TypeOfOrigin anOrigin) -{ - TCollection_AsciiString oldVal; - GetStringValue (PLOT_ORIGIN, oldVal); - SetStringValue (PLOT_ORIGIN, oldVal, PlotMgt::StringFromOrigin (anOrigin)); -} - -//============================================================================== -void PlotMgt_Plotter::SetQuality (const PlotMgt_TypeOfQuality aQuality) -{ - TCollection_AsciiString oldVal; - GetStringValue (PLOT_QUALITY, oldVal); - SetStringValue (PLOT_QUALITY, oldVal, PlotMgt::StringFromQuality (aQuality)); -} - -//============================================================================== -void PlotMgt_Plotter::SetImageFormat (const PlotMgt_ImageFormat anImageFormat) -{ - TCollection_AsciiString oldVal; - GetStringValue (PLOT_IMGFORMAT, oldVal); - SetStringValue (PLOT_IMGFORMAT, oldVal, PlotMgt::StringFromImageFormat (anImageFormat)); -} - -//============================================================================== -void PlotMgt_Plotter::SetPlottingType (const PlotMgt_PlottingType aPlottingType) -{ - TCollection_AsciiString oldVal; - GetStringValue (PLOT_PLOTTINGTYPE, oldVal); - SetStringValue (PLOT_PLOTTINGTYPE, oldVal, PlotMgt::StringFromPlottingType (aPlottingType)); -} - -//============================================================================== -void PlotMgt_Plotter::SetPaperFormat (const PlotMgt_PaperFormat aPaperFormat) -{ - TCollection_AsciiString oldVal; - GetStringValue (PLOT_PAPERFORMAT, oldVal); - SetStringValue (PLOT_PAPERFORMAT, oldVal, PlotMgt::StringFromPaperFormat (aPaperFormat)); -} - -//============================================================================== -//============================================================================== -//============================================================================== -//============================================================================== -//============================================================================== -//============================================================================== -//============================================================================== -void PlotMgt_Plotter::SetPenColorIndex (const Handle(TColStd_HSequenceOfInteger)& aTable) -{ - SetIntTable (PLOT_PENSINDEXCOLOR, aTable); - myPenColorIndex = aTable -> ShallowCopy (); -} - -//============================================================================== -void PlotMgt_Plotter::SetPenWidthIndex (const Handle(TColStd_HSequenceOfInteger)& aTable) -{ - SetIntTable (PLOT_PENSINDEXWIDTH, aTable); - myPenWidthIndex = aTable -> ShallowCopy (); -} - -//============================================================================== -void PlotMgt_Plotter::SetPenTypeIndex (const Handle(TColStd_HSequenceOfInteger)& aTable) -{ - SetIntTable (PLOT_PENSINDEXTYPE, aTable); - myPenTypeIndex = aTable -> ShallowCopy (); -} - -//============================================================================== -void PlotMgt_Plotter::SetColorMap (const Handle(Aspect_ColorMap)& aColorMap) -{ - Handle(TColStd_HSequenceOfAsciiString) aMap = new TColStd_HSequenceOfAsciiString (); - Standard_Integer j, i = FindParameter (PLOT_COLORMAPRGB), n = aColorMap -> Size (); - if (i >= 1 && i <= NumberOfParameters ()) { - TCollection_AsciiString aLine; - Quantity_Color aColor; - Standard_Real r, g, b; - for (j = 1; j <= n; j++) { - aColor = aColorMap -> Entry (j).Color (); - aColor.Values (r, g, b, Quantity_TOC_RGB); - aLine = "\""; - aLine += TCollection_AsciiString (r); aLine += " "; - aLine += TCollection_AsciiString (g); aLine += " "; - aLine += TCollection_AsciiString (b); aLine += "\""; - aMap -> Append (aLine); - } - myParameters -> Value (i) -> SetMValue (aMap); - myColorMap = Handle(Aspect_GenericColorMap)::DownCast(aColorMap); - } -} - -//============================================================================== -void PlotMgt_Plotter::SetWidthMap (const Handle(Aspect_WidthMap)& aWidthMap) -{ - Handle(TColStd_HSequenceOfAsciiString) aMap = new TColStd_HSequenceOfAsciiString (); - Standard_Integer j, i = FindParameter (PLOT_WIDTHMAP), n = aWidthMap -> Size (); - if (i >= 1 && i <= NumberOfParameters ()) { - TCollection_AsciiString aLine; - for (j = 1; j <= n; j++) { - aLine = TCollection_AsciiString (aWidthMap -> Entry(j).Width()); - aMap -> Append (aLine); - } - myParameters -> Value (i) -> SetMValue (aMap); - myWidthMap = aWidthMap; - } -} - -//============================================================================== -void PlotMgt_Plotter::SetTypeMap (const Handle(Aspect_TypeMap)& aTypeMap) -{ - Handle(TColStd_HSequenceOfAsciiString) aMap = new TColStd_HSequenceOfAsciiString (); - Standard_Integer j, i = FindParameter (PLOT_LINETYPEMAP), n = aTypeMap -> Size (); - if (i >= 1 && i <= NumberOfParameters ()) { - TCollection_AsciiString aLine; - for (j = 1; j <= n; j++) { - Aspect_LineStyle aStyle = aTypeMap -> Entry(j).Type(); - Standard_Integer low = aStyle.Values().Lower (), up = aStyle.Values().Upper (); - aLine = "\""; - for (i = low; i <= up; i++) { - aLine += TCollection_AsciiString (aStyle.Values().Value (i)); - if (i != up) aLine += " "; - else aLine += "\""; - } - aMap -> Append (aLine); - } - myParameters -> Value (i) -> SetMValue (aMap); - myTypeMap = aTypeMap; - } -} - -//============================================================================== -void PlotMgt_Plotter::SetFontMap (const Handle(Aspect_FontMap)& aFontMap) -{ - Handle(TColStd_HSequenceOfAsciiString) aMap = new TColStd_HSequenceOfAsciiString (); - Standard_Integer j, i = FindParameter (PLOT_FONTMAP), n = aFontMap -> Size (); - if (i >= 1 && i <= NumberOfParameters ()) { - TCollection_AsciiString aLine; - for (j = 1; j <= n; j++) { - aLine = aFontMap -> Entry(j).Type().AliasName(); - aMap -> Append (aLine); - } - myParameters -> Value (i) -> SetMValue (aMap); - myFontMap = aFontMap; - } -} diff --git a/src/PlotMgt/PlotMgt_TextManager.cdl b/src/PlotMgt/PlotMgt_TextManager.cdl deleted file mode 100755 index 76ebbe01b2..0000000000 --- a/src/PlotMgt/PlotMgt_TextManager.cdl +++ /dev/null @@ -1,125 +0,0 @@ --- Created by: DCB --- Copyright (c) 1993-1999 Matra Datavision --- Copyright (c) 1999-2012 OPEN CASCADE SAS --- --- The content of this file is subject to the Open CASCADE Technology Public --- License Version 6.5 (the "License"). You may not use the content of this file --- except in compliance with the License. Please obtain a copy of the License --- at http://www.opencascade.org and read it completely before using this file. --- --- The Initial Developer of the Original Code is Open CASCADE S.A.S., having its --- main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. --- --- The Original Code and all software distributed under the License is --- distributed on an "AS IS" basis, without warranty of any kind, and the --- Initial Developer hereby disclaims all such warranties, including without --- limitation, any warranties of merchantability, fitness for a particular --- purpose or non-infringement. Please see the License for the specific terms --- and conditions governing the rights and limitations under the License. - - -private class TextManager from PlotMgt inherits TextManager from MFT - -uses - Length from Quantity, - PlaneAngle from Quantity, - TypeOfText from Aspect, - PlotterDriver from PlotMgt, - PlotterDriverPtr from PlotMgt - -is - ------------------------- - -- Category: Constructors - ------------------------- - Create (aDriver : PlotterDriver from PlotMgt) - returns mutable TextManager from PlotMgt; - - ------------------------- - -- Category: Draw methods - ------------------------- - BeginString (me: mutable; - X,Y: Length from Quantity; - anOrientation: PlaneAngle from Quantity; - aWidth,aHeight: Length from Quantity; - aSlant: PlaneAngle from Quantity; - aPaintType: Integer from Standard) is redefined; - ---Purpose: Calls when string drawing is started. - -- with a string aspect : - -- 0 for filled string - -- 1 for stroke string - -- 2 for outline string - -- The origine of the string ,, - -- The orientation of the string , - -- The medium size of the char , - -- The Slant of the char , - - BeginChar (me: mutable; - aCharCode: Integer from Standard; - X,Y: Length from Quantity) - returns Boolean from Standard is redefined; - ---Purpose: Calls when a char drawing is started - -- and give the current string position for this char. - -- and give the relative char position from the beginning - -- of the string. - --The application can returns FALSE for skipping the char drawing. - - SetCharBoundingBox (me: mutable; - X1,Y1,X2,Y2,X3,Y3,X4,Y4: Length from Quantity) - returns Boolean from Standard is redefined; - ---Purpose: Calls to defines the current char bounding-box. - -- The application can returns FALSE for ending the char drawing. - - SetCharEncoding (me: mutable; - anEncoding: CString from Standard) - returns Boolean from Standard is redefined; - ---Purpose: Calls to defines the current char encoding. - -- Warning: The application can returns FALSE for skipping the char drawing. - - Moveto (me: mutable; X,Y: Length from Quantity) - returns Boolean from Standard is redefined; - ---Purpose: Calls to sets the current string position. - -- The application can returns FALSE for ending the char drawing. - - Lineto (me: mutable; X,Y: Length from Quantity) - returns Boolean from Standard is redefined; - ---Purpose: Calls to drawn to the current string position. - -- The application can returns FALSE for ending the char drawing. - - Curveto (me: mutable; X1,Y1,X2,Y2,X3,Y3,X4,Y4: Length from Quantity) - returns Boolean from Standard is redefined; - ---Purpose: Calls to drawn to the current string position. - -- The application can drawn the curve defined by - -- his descriptor P1,P2,P3,P4 or - -- returns FALSE to let the interpretor compute the curve - -- vectors. - - ClosePath (me: mutable) is redefined; - ---Purpose: Calls when a char path drawing is ended - - EndChar (me: mutable; X,Y: Length from Quantity) - returns Boolean from Standard is redefined; - ---Purpose: Calls when a char drawing is ended - -- and give the relative char ending position from the - -- beginning of the string. - -- The application can returns FALSE for skipping the string - -- drawing. - - EndString (me: mutable ) is redefined; - ---Purpose: Calls when string drawing is ended (Normally the last call). - - -- Category: Private methods - ------------------------- - SetTextAttribs (me: mutable; - aTextColor: Integer from Standard; - aTypeOfText: TypeOfText from Aspect; - anUnderlinePosition: Length from Quantity = 0.0) - is private; - ---Purpose: Sets the current attribs of the text. - -fields - myDriver : PlotterDriverPtr from PlotMgt; - -friends - class PlotterDriver from PlotMgt - -end TextManager from PlotMgt; diff --git a/src/PlotMgt/PlotMgt_TextManager.cxx b/src/PlotMgt/PlotMgt_TextManager.cxx deleted file mode 100755 index cf75a36871..0000000000 --- a/src/PlotMgt/PlotMgt_TextManager.cxx +++ /dev/null @@ -1,296 +0,0 @@ -// Created by: DCB -// Copyright (c) 1993-1999 Matra Datavision -// Copyright (c) 1999-2012 OPEN CASCADE SAS -// -// The content of this file is subject to the Open CASCADE Technology Public -// License Version 6.5 (the "License"). You may not use the content of this file -// except in compliance with the License. Please obtain a copy of the License -// at http://www.opencascade.org and read it completely before using this file. -// -// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its -// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. -// -// The Original Code and all software distributed under the License is -// distributed on an "AS IS" basis, without warranty of any kind, and the -// Initial Developer hereby disclaims all such warranties, including without -// limitation, any warranties of merchantability, fitness for a particular -// purpose or non-infringement. Please see the License for the specific terms -// and conditions governing the rights and limitations under the License. - - -#include -#include - -#ifdef WNT -#pragma warning (disable : 4244) -#endif - -//#define TRACE -#define MAXPATHPOINTS 800 -#define MAXCHARPATHS 20 -#define MAXCHARPOINTS MAXPATHPOINTS*MAXCHARPATHS - -#define CONVERT(v) (v)*72./(0.0254005 METER) - -#define TRANSFORM(X,Y) \ - { Standard_Real x = (X), y = (Y); \ - X = x*theCosAngle - y*theSinAngle; \ - Y = x*theSinAngle + y*theCosAngle; \ - } - -#define ADD_POINT(X,Y,aX,aY) \ - { theXPath[thePoint] = myDriver->MapX((X)+(aX)); \ - theYPath[thePoint] = myDriver->MapY((Y)+(aY)); \ - thePoint++; \ - } - -//static Standard_Integer thePaintType, theNchar, theNpoly, theNpath; -static Standard_Integer thePaintType, theNchar; -static Standard_ShortReal theX, theY, thePX, thePY; -static Standard_ShortReal theXmin, theXmax, theSinAngle, theCosAngle; -static Standard_Real theOrientation, theSlant, theWidth, theHeight; -static Standard_Integer theTextColor; -static Standard_Integer theTypeOfText; -static Quantity_Length theUnderlinePos; -static Standard_ShortReal theXPath [MAXCHARPOINTS]; -static Standard_ShortReal theYPath [MAXCHARPOINTS]; -static Standard_Integer theCPath [MAXCHARPATHS ]; -static Standard_Integer thePoint = 0; -static Standard_Integer thePathCount = 0; -// Driver's graphic attributes -static Standard_Integer lci, lti, lwi, pci, pti; -static Standard_Boolean pef; - -//========================================================== -PlotMgt_TextManager::PlotMgt_TextManager (const Handle(PlotMgt_PlotterDriver)& aDriver) -{ - myDriver = aDriver.operator->(); - theTypeOfText = Aspect_TOT_OUTLINE; - theUnderlinePos = 0.; - theTextColor = 0; -} - -//========================================================== -Standard_Boolean PlotMgt_TextManager::SetCharBoundingBox (const Quantity_Length X1, - const Quantity_Length Y1, - const Quantity_Length X2, - const Quantity_Length Y2, - const Quantity_Length X3, - const Quantity_Length Y3, - const Quantity_Length X4, - const Quantity_Length Y4) -{ -#ifdef TRACE - cout << " PlotMgt_TextManager::SetCharBoundingBox(" << X1 << "," << Y1 - << "," << X2 << "," << Y2 << "," << X3 << "," << Y3 << "," << X4 - << "," << Y4 << ")" << endl << flush; -#endif - if (theUnderlinePos > 0.) { - if (!theNchar) - theXmin = Standard_ShortReal (X1); - theXmax = Sqrt(X2*X2 + Y2*Y2); - } - return Standard_True; -} - -//========================================================== -Standard_Boolean PlotMgt_TextManager::SetCharEncoding (const Standard_CString anEncoding) -{ -#ifdef TRACE - cout << " PlotMgt_TextManager::SetCharEncoding('" << anEncoding << "')" << endl; -#endif - return Standard_True; -} - -//========================================================== -void PlotMgt_TextManager::BeginString (const Quantity_Length X, - const Quantity_Length Y, - const Quantity_PlaneAngle anOrientation, - const Quantity_Length aWidth, - const Quantity_Length aHeight, - const Quantity_PlaneAngle aSlant, - const Standard_Integer aPaintType) -{ -#ifdef TRACE - cout << " PlotMgt_TextManager::BeginString(" << X << "," << Y - << "," << anOrientation << "," << aWidth << "," << aHeight - << "," << aSlant << "," << aPaintType << ")" << endl; -#endif - thePaintType = aPaintType; - theOrientation = (float) anOrientation; - // Force to OUTLINE if required - if (!thePaintType && (theTypeOfText == Aspect_TOT_OUTLINE)) - thePaintType = 2; - theX = X; theY = Y; - theXmin = theXmax = 0.; - theNchar = 0; - theSlant = aSlant; - theWidth = aWidth; - theHeight = aHeight; - // Remember the old attributes and set new ones - myDriver -> LineAttrib (lci, lti, lwi); - myDriver -> PolyAttrib (pci, pti, pef); - myDriver -> SetLineAttrib (theTextColor, 0, 0); - myDriver -> SetPolyAttrib (theTextColor, - (theTypeOfText == Aspect_TOT_OUTLINE ? -1 : 0), Standard_False); - // Force plotting of graphic attributes at the begin of a string - myDriver -> PlotLineAttrib (theTextColor, 0, 0); - myDriver -> PlotPolyAttrib (theTextColor, - (theTypeOfText == Aspect_TOT_OUTLINE ? -1 : 0), Standard_False); -} - -//========================================================== -Standard_Boolean PlotMgt_TextManager::BeginChar (const Standard_Integer aCharCode, - const Quantity_Length X, - const Quantity_Length Y) -{ -#ifdef TRACE - cout << " PlotMgt_TextManager::BeginChar(" << aCharCode << "," - << X << "," << Y << ")" << endl << flush; -#endif - thePoint = 0; - thePathCount = 0; - theCPath[0] = 0; - thePX = X; - thePY = Y; - return Standard_True; -} - -//========================================================== -Standard_Boolean PlotMgt_TextManager::Moveto (const Quantity_Length X, - const Quantity_Length Y) -{ -#ifdef TRACE - cout << " PlotMgt_TextManager::Moveto(" << X << "," << Y << ")" << endl << flush; -#endif - if (theCPath[thePathCount] > 1) - thePathCount++; - else if (theCPath[thePathCount] > 0) - --thePoint; - theCPath[thePathCount] = 1; - thePX = X; thePY = Y; - ADD_POINT (theX, theY, X, Y); - return Standard_True; -} - -//========================================================== -Standard_Boolean PlotMgt_TextManager::Lineto (const Quantity_Length X, - const Quantity_Length Y) -{ -#ifdef TRACE - cout << " PlotMgt_TextManager::Lineto(" << X << "," << Y << ")" << endl << flush; -#endif - theCPath[thePathCount]++; - ADD_POINT (theX, theY, X, Y); - return Standard_True; -} - -//========================================================== -Standard_Boolean PlotMgt_TextManager::Curveto (const Quantity_Length X1, - const Quantity_Length Y1, - const Quantity_Length X2, - const Quantity_Length Y2, - const Quantity_Length X3, - const Quantity_Length Y3, - const Quantity_Length X4, - const Quantity_Length Y4) -{ -#ifdef TRACE - cout << " PlotMgt_TextManager::Curveto(" << X1 << "," << Y1 << "," - << X2 << "," << Y2 << "," << X3 << "," << Y3 << "," << X4 - << "," << Y4 << ")" << endl << flush; -#endif - if (myDriver -> DrawCurveCapable()) { - if (theCPath[thePathCount] > 0) - thePathCount++; - theCPath[thePathCount] = -1; - ADD_POINT (theX, theY, X2, Y2); - ADD_POINT (theX, theY, X3, Y3); - ADD_POINT (theX, theY, X4, Y4); - thePathCount++; - theCPath[thePathCount] = 0; - return Standard_True; - } - return Standard_False; -} - -//========================================================== -void PlotMgt_TextManager::ClosePath () -{ -#ifdef TRACE - cout << " PlotMgt_TextManager::ClosePath()" << endl << flush; -#endif - if (thePaintType == 2) - Lineto (thePX, thePY); - thePathCount++; - theCPath[thePathCount] = 0; -} - -//========================================================== -Standard_Boolean PlotMgt_TextManager::EndChar (const Quantity_Length X, - const Quantity_Length Y) -{ -#ifdef TRACE - cout << "PlotMgt_TextManager::EndChar(" << X << "," << Y << ")\n" - << "Paths: " << thePathCount << ", PaintType: " << thePaintType << endl << flush; - for (int j = 0; j < thePathCount; j++) - cout << "Path[" << j << "] is: " << theCPath[j] << endl << flush; -#endif - int N = 0, i; - theNchar++; - switch (thePaintType) { - /////////////////////////////////////////// Euclid3 font - case 1: - for (i = 0; i <= thePathCount; i++) { - myDriver -> PlotPolyline (&theXPath[N], &theYPath[N], &theCPath[i], 1); - N += theCPath [i]; - } - break; - /////////////////////////////////////////// Outlined font - case 2: - myDriver -> PlotPolyline (theXPath, theYPath, theCPath, thePathCount); - break; - /////////////////////////////////////////// Solid font - default: - myDriver -> PlotPolygon (theXPath, theYPath, theCPath, thePathCount); - break; - } - thePathCount = 0; - memset (theCPath, 0, sizeof(theCPath)); - return Standard_True; -} - -//========================================================== -void PlotMgt_TextManager::EndString () -{ -#ifdef TRACE - cout << " PlotMgt_TextManager::EndString()" << endl << flush; -#endif - if (theUnderlinePos > 0.) { - Standard_ShortReal theX1 = theXmin; - Standard_ShortReal theY1 = (float)-theUnderlinePos; - Standard_ShortReal theX2 = theXmax; - Standard_ShortReal theY2 = theY1; - theSinAngle = (float)Sin(theOrientation); - theCosAngle = (float)Cos(theOrientation); - TRANSFORM(theX1, theY1); - TRANSFORM(theX2, theY2); - myDriver -> PlotSegment ( - myDriver->MapX(theX+theX1), myDriver->MapY(theY+theY1), - myDriver->MapX(theX+theX2), myDriver->MapY(theY+theY2) - ); - } - // Restore old attributes - myDriver -> SetLineAttrib (lci, lti, lwi); - myDriver -> SetPolyAttrib (pci, pti, pef); -} - -//========================================================== -void PlotMgt_TextManager::SetTextAttribs (const Standard_Integer aTextColor, - const Aspect_TypeOfText aTypeOfText, - const Quantity_Length anUnderlinePosition) -{ - theTextColor = aTextColor; - theTypeOfText = aTypeOfText; - theUnderlinePos = anUnderlinePosition; -} diff --git a/src/PlotMgt/PlotMgt_fill.hxx b/src/PlotMgt/PlotMgt_fill.hxx deleted file mode 100755 index fb46126c70..0000000000 --- a/src/PlotMgt/PlotMgt_fill.hxx +++ /dev/null @@ -1,75 +0,0 @@ -// Copyright (c) 1999-2012 OPEN CASCADE SAS -// -// The content of this file is subject to the Open CASCADE Technology Public -// License Version 6.5 (the "License"). You may not use the content of this file -// except in compliance with the License. Please obtain a copy of the License -// at http://www.opencascade.org and read it completely before using this file. -// -// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its -// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. -// -// The Original Code and all software distributed under the License is -// distributed on an "AS IS" basis, without warranty of any kind, and the -// Initial Developer hereby disclaims all such warranties, including without -// limitation, any warranties of merchantability, fitness for a particular -// purpose or non-infringement. Please see the License for the specific terms -// and conditions governing the rights and limitations under the License. - -#ifndef PLOTMGT_FILL_HEADER -#define PLOTMGT_FILL_HEADER - -//---------------------------------------------------- -struct mpo_one_line -{ - double X1, X2, X3, X4; - double Y1, Y2, Y3, Y4; - int type; // =0 then *---* *---* - // =1 then * *--* * - // =2 then *-------* * - // =3 then * *-----* - // =4 then * * - // =5 then *----------* -}; - -//!!!!!!!!!!!!!!!!!!! POLYARCS -// X, Y -- coordinates of ellipse -// a, b -- radiuses of ellipse -// alpha -- start angle of fill, beta -- add angle of filling -// gamma -- rotation angle of filling (non-dependent of delta) -// delta -- rotation angle of ellipse -// step -- filling step -int __InitFillArc(double X, double Y, double a, double b, double alpha, - double beta, double gamma, double delta, double step); - -// Get another line of fill -// n -- number of line -// data -- structure for retrieving coordinates of points -// data->n -- number of lines = {0, 1, 2} -// data->n = 1 line is (data->X1, data->Y1, data->X2, data->Y2) -// data->n = 2 line is (data->X1, data->Y1, data->X2, data->Y2) -// and (data->X3, data->Y3, data->X4, data->Y4) -int __GetLineOfFilledArc(int n, mpo_one_line &data); - -//Ending job with filler -void __DoneFillArc(void); - -//!!!!!!!!!!!!!!!!!!! POLYGONS -// double *X, *Y - coordinates of a points of a polygon -// n = count of points -// Point(X[0],Y[0]) = Point(X[n-1],Y[n-1]) (if no return 0) -// step - step of filling -// gamma -- angle of rotating filling -// Returns 0 if failts -// else return number of lines -int __InitFillPolygon(double* X, double* Y, int n, double step, double gamma = 0.); - -// Input: n = n-th point 0 <= n < number_of_lines -// Output: coordinates of a lines -// N - number of lines -// (X[2*i],Y[2*i+1]) - the i-th line , 0 <= i < N -// Return 0 if error -int __GetLineOfFilledPolygon (int n, int &N, double* &X, double* &Y); - -void __DoneFillPolygon(void); // Use it if you need - -#endif // PLOTMGT_FILL_HEADER diff --git a/src/PlotMgt/PlotMgt_fillpolyarc.cxx b/src/PlotMgt/PlotMgt_fillpolyarc.cxx deleted file mode 100755 index dc490db49f..0000000000 --- a/src/PlotMgt/PlotMgt_fillpolyarc.cxx +++ /dev/null @@ -1,307 +0,0 @@ -// Created on: 1997-05-21 -// Created by: Prihodyko Michael -// Copyright (c) 1997-1999 Matra Datavision -// Copyright (c) 1999-2012 OPEN CASCADE SAS -// -// The content of this file is subject to the Open CASCADE Technology Public -// License Version 6.5 (the "License"). You may not use the content of this file -// except in compliance with the License. Please obtain a copy of the License -// at http://www.opencascade.org and read it completely before using this file. -// -// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its -// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. -// -// The Original Code and all software distributed under the License is -// distributed on an "AS IS" basis, without warranty of any kind, and the -// Initial Developer hereby disclaims all such warranties, including without -// limitation, any warranties of merchantability, fitness for a particular -// purpose or non-infringement. Please see the License for the specific terms -// and conditions governing the rights and limitations under the License. - -// Modified by mpo, Tue Jul 8 15:31:23 1997 -// Modified 23/02/98 : FMN ; Remplacement PI par Standard_PI - - -/////////////////////////////////////////////////////////////////////////////////////// -///////////////////////////////// EXAMPLE OF USE ////////////////////////////////////// -/////////////////////////////////////////////////////////////////////////////////////// -/* - mpo_one_line aLine; - // Drawing filled arc - Standard_Integer n = __InitFillArc (X, Y, anXradius, anYradius, aStartAngle, anOpenAngle, - 0.0, 0.0, 0.2*(myHeight/myWidth)); - for (Standard_Integer i = 1; i <= n; i++) { - __GetLineOfFilledArc (i, aLine); - DrawSegment (aLine.X1, aLine.Y1, aLine.X2, aLine.Y2); - if (aLine.type == 2) - DrawSegment (aLine.X3, aLine.Y3, aLine.X4, aLine.Y4); - } - __DoneFillArc (); -*/ - -//-------------------------------------------------------- -#include -#include -#ifndef __MATH_WNT_H -# include -#endif /* __MATH_WNT_H */ -#include -#include -#define maxDouble ((double)1.E+30) -//-------------------------------------------------------- - -/* -// Description: -// fill sectorof arc with rotated lines and -// arc can be rotated too... - -// Some about algorithm: -// rotate everything so, that lines become horizontal and then -// seek points of intersection between each line and sector and -// then rotate it in other way - -// Some about using it: -// Call __InitFillArc() to initialize computations -// Using __GetLineOfFilledArc() you can get each line of filling -// Call of __DoneFillArc() will free all allocated memory and will end your computations - -// Initialize sector filling -// X, Y -- coordinates of ellipse -// a, b -- radiuses of ellipse -// alpha -- start angle of fill, beta -- add angle of filling -// gamma -- rotation angle of filling (non-dependent of delta) -// delta -- rotation angle of ellipse -// step -- filling step -int __InitFillArc(double X, double Y, double a, double b, double alpha, - double beta, double gamma, double delta, double step); - -// Get another line of fill -// n -- number of line -// data -- structure for retrieving coordinates of points -// data->n -- number of lines = {0, 1, 2} -// if data->n = 1 line is (data->X1, data->Y1, data->X2, data->Y2) -// if data->n = 2 line is (data->X1, data->Y1, data->X2, data->Y2) and -// (data->X3, data->Y3, data->X4, data->Y4) -int __GetLineOfFilledArc(int n, mpo_one_line &data); - -// Finish all job -void __DoneFillArc(void); -*/ - -//----------------------------- Implementation ----------------------- - -int mpo_count; -int mpo_start; -mpo_one_line *mpo_lines; - -//Truncate double number -double ftrunc(double a) -{ - a = floor(a); - if (a<0) a++; - return a; -} - -//trigon functs -double fsin(double a) -{ - return sin(a); -} -double fcos(double a) -{ - return cos(a); -} -double ftan(double a) -{ - return tan(a); -} -double fatan2(double a, double b) -{ - return atan2(a, b); -} -double fsqrt(double a) -{ - return sqrt(a); -} - -// Determine is angle a is between b and b+c (c>0) -int mpo_inside(double a, double b, double c) -{ - while (b<0) {b += 2*M_PI;}; b -= 2*M_PI*ftrunc(b/(2*M_PI)); - c -= 2*M_PI*ftrunc(c/(2*M_PI)); - while (a<0) {a+=2*M_PI;}; a -= 2*M_PI*ftrunc(a/(2*M_PI)); -// while(c<0) {c+=2*M_PI;}; c-=2*M_PI*ftrunc(c/(2*M_PI)); - if ((a > b) && (a < b+c)) return 1; - else if ((2*M_PI+a > b) && (2*M_PI+a < b+c)) return 1; - return 0; -} - -int __InitFillArc(double X, double Y, double a, double b, double alpha, - double beta, double gamma, double delta, double step) -{ - int i ; - alpha -= 2*M_PI*ftrunc(alpha/(2*M_PI)); beta -= 2*M_PI*ftrunc(beta/(2*M_PI)); - if (beta < 0.0) - { - alpha += beta; beta = -beta; - } - delta -= gamma; alpha -= gamma; - - double C1 = b*b*fcos(delta)*fcos(delta) + a*a*fsin(delta)*fsin(delta); - double C3 = b*b*fsin(delta)*fsin(delta) + a*a*fcos(delta)*fcos(delta); - double C2 = fsin(delta)*fcos(delta)*(b*b - a*a); -// cout << "C1 = " << C1 << "; C2 = " << C2 << "; C3 = " << C3 << endl << flush; - double Ys = a*b/fsqrt(C3 - C2*C2/C1)-0.5*step; - int size = int( ftrunc(2*Ys/step) + 1 ); -// cout << "Ysize = " << Ys << endl << flush; -// cout << "Size = " << size << endl << flush; -// cout << "Alpha = " << alpha*180/M_PI << endl << flush; -// cout << "Beta = " << beta*180/M_PI << endl << flush; - mpo_lines = (mpo_one_line*)malloc(sizeof(mpo_one_line)*size); - for ( i = 0; i < size; i++) - { - double Yt = Ys - i*step; - (mpo_lines+i)->X1 = (-C2*Yt - fsqrt(C2*C2*Yt*Yt - C1*(C3*Yt*Yt - a*a*b*b)))/C1; - (mpo_lines+i)->X2 = (-C2*Yt + fsqrt(C2*C2*Yt*Yt - C1*(C3*Yt*Yt - a*a*b*b)))/C1; -// cout << "alpha = " << alpha*180/M_PI << " alpha+beta = " << (alpha+beta)*180/M_PI << endl << flush; -// cout << "" << fatan2(Yt, (mpo_lines+i)->X2)*180/M_PI << " type " << (mpo_lines+i)->type << endl << flush;; -// cout << "Xleft = " << (mpo_lines+i)->X1 << " Xright = " << (mpo_lines+i)->X2 << endl << flush; -// cout << "C2*C2 - C1*(C3*Yt*Yt - a*a*b*b) = " << C2*C2 - C1*(C3*Yt*Yt - a*a*b*b) << endl << flush; -// cout << "C1*(C3*Yt*Yt - a*a*b*b) = " << C1*(C3*Yt*Yt - a*a*b*b) << endl << flush; -// cout << "C2*C2 = " << C2*C2 << endl << flush; - if (Yt > 0.0) - { - if (fsin(alpha) <= 0.0) (mpo_lines+i)->X3 = maxDouble; - else (mpo_lines+i)->X3 = Yt/ftan(alpha); - if (fsin(alpha+beta) <= 0.0) (mpo_lines+i)->X4 = maxDouble; - else (mpo_lines+i)->X4 = Yt/ftan(alpha+beta); - if (((mpo_lines+i)->X3 > (mpo_lines+i)->X2) || ((mpo_lines+i)->X3 < (mpo_lines+i)->X1)) - (mpo_lines+i)->X3 = maxDouble; - if (((mpo_lines+i)->X4 > (mpo_lines+i)->X2) || ((mpo_lines+i)->X4 < (mpo_lines+i)->X1)) - (mpo_lines+i)->X4 = maxDouble; - if (((mpo_lines+i)->X3 != maxDouble)&&((mpo_lines+i)->X4 != maxDouble)) - if ((mpo_lines+i)->X3 <= (mpo_lines+i)->X4) (mpo_lines+i)->type = 0; - else - { - (mpo_lines+i)->type = 1; - double tmp = (mpo_lines+i)->X3; (mpo_lines+i)->X3 = (mpo_lines+i)->X4; (mpo_lines+i)->X4 = tmp; - } - else if ((mpo_lines+i)->X3 != maxDouble) - { - (mpo_lines+i)->type = 2; (mpo_lines+i)->X4 = (mpo_lines+i)->X3; - } - else if ((mpo_lines+i)->X4 != maxDouble) - { - (mpo_lines+i)->type = 3; (mpo_lines+i)->X3 = (mpo_lines+i)->X4; - } - else if (mpo_inside(fatan2((double)Yt,(double)((mpo_lines+i)->X2)), alpha, beta)) - (mpo_lines+i)->type = 5; - else (mpo_lines+i)->type = 4; - } - else if (Yt <= 0.0) //!!!!! - { - if (fsin(alpha) >= 0.0) (mpo_lines+i)->X3 = maxDouble; - else (mpo_lines+i)->X3 = Yt/ftan(alpha); - if (fsin(alpha+beta) >= 0.0) (mpo_lines+i)->X4 = maxDouble; - else (mpo_lines+i)->X4 = Yt/ftan(alpha+beta); - if (((mpo_lines+i)->X3 > (mpo_lines+i)->X2) || ((mpo_lines+i)->X3 < (mpo_lines+i)->X1)) - (mpo_lines+i)->X3 = maxDouble; - if (((mpo_lines+i)->X4 > (mpo_lines+i)->X2) || ((mpo_lines+i)->X4 < (mpo_lines+i)->X1)) - (mpo_lines+i)->X4 = maxDouble; - if (((mpo_lines+i)->X3 != maxDouble)&&((mpo_lines+i)->X4 != maxDouble)) - if ((mpo_lines+i)->X3 >= (mpo_lines+i)->X4) - { - (mpo_lines+i)->type = 0; - double tmp = (mpo_lines+i)->X3; (mpo_lines+i)->X3 = (mpo_lines+i)->X4; (mpo_lines+i)->X4 = tmp; - } - else (mpo_lines+i)->type = 1; - else if ((mpo_lines+i)->X3 != maxDouble) (mpo_lines+i)->type = 3; - else if ((mpo_lines+i)->X4 != maxDouble) (mpo_lines+i)->type = 2; - else if (mpo_inside(fatan2((double)Yt, (double)((mpo_lines+i)->X2)), alpha, beta)) - (mpo_lines+i)->type = 5; - else (mpo_lines+i)->type = 4; - } - else; -// cout << "Xlm = " << (mpo_lines+i)->X3 << " Xrm = " << (mpo_lines+i)->X4 << endl << flush; -// cout << "------------ i = " << i << endl << flush; - } - mpo_start = 0; mpo_count = 0; - while (((mpo_lines+mpo_start)->type == 4)&&(mpo_start < size)) mpo_start++; - while (((mpo_lines+mpo_start+mpo_count)->type != 4)&&((mpo_start+mpo_count < size))) mpo_count++; -// cout << "start = " << mpo_start << " count = " << mpo_count << endl << flush; - for (i = mpo_start; i < mpo_count+mpo_start; i++) - { - double Yt = Ys - i*step; - (mpo_lines+i)->Y1 = (mpo_lines+i)->X1*fsin(gamma) + Yt*fcos(gamma) + Y; - (mpo_lines+i)->X1 = (mpo_lines+i)->X1*fcos(gamma) - Yt*fsin(gamma) + X; - (mpo_lines+i)->Y2 = (mpo_lines+i)->X2*fsin(gamma) + Yt*fcos(gamma) + Y; - (mpo_lines+i)->X2 = (mpo_lines+i)->X2*fcos(gamma) - Yt*fsin(gamma) + X; - (mpo_lines+i)->Y3 = (mpo_lines+i)->X3*fsin(gamma) + Yt*fcos(gamma) + Y; - (mpo_lines+i)->X3 = (mpo_lines+i)->X3*fcos(gamma) - Yt*fsin(gamma) + X; - (mpo_lines+i)->Y4 = (mpo_lines+i)->X4*fsin(gamma) + Yt*fcos(gamma) + Y; - (mpo_lines+i)->X4 = (mpo_lines+i)->X4*fcos(gamma) - Yt*fsin(gamma) + X; - } - return mpo_count; -} - -// Get another line of fill -// n -- number of line -// data -- structure for retrieving coordinates of points -// data->n -- number of lines = {0, 1, 2} -// data->n = 1 line is (data->X1, data->Y1, data->X2, data->Y2) -// data->n = 2 line is (data->X1, data->Y1, data->X2, data->Y2) and (data->X3, data->Y3, data->X4, data->Y4) -int __GetLineOfFilledArc(int n, mpo_one_line &data) -{ - if (n > mpo_count) return 0; n--; n += mpo_start; - switch((mpo_lines+n)->type) { - case 0: - data.type = 2; - data.X1 = (mpo_lines+n)->X1; - data.Y1 = (mpo_lines+n)->Y1; - data.X2 = (mpo_lines+n)->X3; - data.Y2 = (mpo_lines+n)->Y3; - data.X3 = (mpo_lines+n)->X4; - data.Y3 = (mpo_lines+n)->Y4; - data.X4 = (mpo_lines+n)->X2; - data.Y4 = (mpo_lines+n)->Y2; - break; - case 1: - data.type = 1; - data.X1 = (mpo_lines+n)->X3; - data.Y1 = (mpo_lines+n)->Y3; - data.X2 = (mpo_lines+n)->X4; - data.Y2 = (mpo_lines+n)->Y4; - break; - case 2: - data.type = 1; - data.X1 = (mpo_lines+n)->X1; - data.Y1 = (mpo_lines+n)->Y1; - data.X2 = (mpo_lines+n)->X4; - data.Y2 = (mpo_lines+n)->Y4; - break; - case 3: - data.type = 1; - data.X1 = (mpo_lines+n)->X3; - data.Y1 = (mpo_lines+n)->Y3; - data.X2 = (mpo_lines+n)->X2; - data.Y2 = (mpo_lines+n)->Y2; - break; - case 4: - cout << "??????????????????" << endl << flush; // doesn't exist - break; - case 5: - data.type = 1; - data.X1 = (mpo_lines+n)->X1; - data.Y1 = (mpo_lines+n)->Y1; - data.X2 = (mpo_lines+n)->X2; - data.Y2 = (mpo_lines+n)->Y2; - break; - } - return 1; -} - -//Ending job with filler -void __DoneFillArc(void) -{ - free(mpo_lines); -} diff --git a/src/PlotMgt/PlotMgt_fillpolygon.cxx b/src/PlotMgt/PlotMgt_fillpolygon.cxx deleted file mode 100755 index 1dffbc946c..0000000000 --- a/src/PlotMgt/PlotMgt_fillpolygon.cxx +++ /dev/null @@ -1,254 +0,0 @@ -// Created on: 1997-06-12 -// Created by: Prihodyko Michael -// Copyright (c) 1997-1999 Matra Datavision -// Copyright (c) 1999-2012 OPEN CASCADE SAS -// -// The content of this file is subject to the Open CASCADE Technology Public -// License Version 6.5 (the "License"). You may not use the content of this file -// except in compliance with the License. Please obtain a copy of the License -// at http://www.opencascade.org and read it completely before using this file. -// -// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its -// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. -// -// The Original Code and all software distributed under the License is -// distributed on an "AS IS" basis, without warranty of any kind, and the -// Initial Developer hereby disclaims all such warranties, including without -// limitation, any warranties of merchantability, fitness for a particular -// purpose or non-infringement. Please see the License for the specific terms -// and conditions governing the rights and limitations under the License. - -// Modified by mpo, Tue Jul 8 15:45:06 1997 - -/* -// Description: -// Fill closed polygon with rotated lines - -// Some about algorithm: -// rotate everything so that lines become horizontal, -// seek intersections of each line with each side of polygon -// then sort this array and each two points describe one part of line -// when doing it some special cases need to be resolved -// And then rotate it all in other direction - -// Some about using it: -// With InitFillPolygon() intitialize computations -// Using GetLineOfFilledPolygon() you can get each line of filling -// Call of DoneFillPolygon() will free all allocated memory and will end your computations - -// double *X, *Y - coordinates of a points of a polygon -// n = count of points -// Point(X[0],Y[0]) = Point(X[n-1],Y[n-1]) (if no return 0) -// step - step of filling -// gamma -- angle of rotating filling -// Returns 0 if failts -// else return number of lines -int __InitFillPolygon(double* X, double* Y, int n, double step = 1, double gamma = 0); - -// Input: n = n-th point 0 <= n < number_of_lines -// Output: coordinates of a lines -// N - number of lines -// (X[2*i],Y[2*i+1]) - the i-th line , 0 <= i < N -// Return 0 if error -int __GetLineOfFilledPolygon (int n, int &N, double* &X, double* &Y); - -// Done job and free allocated memory -void __DoneFillPolygon(void); -*/ - -/////////////////////////////////////////////////////////////////////////////////////// -///////////////////////////////// EXAMPLE OF USE ////////////////////////////////////// -/////////////////////////////////////////////////////////////////////////////////////// -/* - Standard_Integer count; - static double Xx[1024], Yy[1024]; - // Fill Xx and Yy by the points - ... - // Filling of polygon by lines - count = __InitFillPolygon(Xx, Yy, n, 0.25); - for (Standard_Integer j = 0; j < count; j++) { - Standard_Integer N; - double *Xxx, *Yyy; - if (__GetLineOfFilledPolygon(j, N, Xxx, Yyy)) - for (int k = 0; k < N; k += 2) - DrawSegment(Xxx[k], Yyy[k], Xxx[k+1], Yyy[k+1]); - } - if (count) __DoneFillPolygon(); -*/ - -//------------------ Implementation ----------------------- -#include -#include -#include -#include - -double mpo_Xmin, mpo_Xmax, mpo_Ymin, mpo_Ymax; // BBox for polygon -double mpo_step; // step of filling -int mpo_size; // number of lines of filling (levels) -double **mpo_Xs, **mpo_Ys; // pointer to array of arrays -int *mpo_sizes; // mpo_sizes[i] number of points on level i -double *Xpts, *Ypts; //internal service - -// -int mpo_sign(double a) -{ - if (a>0) return 1; - else if (a == 0) return 0; - else return -1; -} - -// -int mpo_next_sign(int j, int n) -{ - j++; - while (mpo_sign(Ypts[j+1] - Ypts[j]) == 0) - if (j == n - 1) j = 0; - else j++; -// cout << mpo_sign(Ypts[j+1] - Ypts[j]) << "\t" << j << endl << flush; - return mpo_sign(Ypts[j+1] - Ypts[j]); -} - -// -double mpo_min(double a, double b) -{ - if (a > b) return b; - else return a; -} - -// -double mpo_max(double a, double b) -{ - if (a > b) return a; - else return b; -} - -int __InitFillPolygon(double* X, double* Y, int n, double step, double gamma) -{ - int i ; - int j ; - // checking - if ((n < 2) || (X[0] != X[n-1]) || (Y[0] != Y[n-1])) return 0; - mpo_step = step; - - // create local variables - Xpts = (double*)malloc(sizeof(double)*(n+1)); - Ypts = (double*)malloc(sizeof(double)*(n+1)); - for ( i = 0; i < n; i++) Xpts[i] = X[i], Ypts[i] = Y[i]; - Xpts[n] = X[1]; Ypts[n] = Y[1]; - - // rotate on gamma... - for (i = 0; i < n; i++) - { - double Yt = Ypts[i], Xt = Xpts[i]; - Xpts[i] = Xt*cos(gamma) + Yt*sin(gamma); - Ypts[i] = -Xt*sin(gamma) + Yt*cos(gamma); - } - - // allocating variables - mpo_Xmin = mpo_Xmax = Xpts[0]; - mpo_Ymin = mpo_Ymax = Ypts[0]; - for (i = 1; i < n; i++) - { - if (mpo_Xmin > Xpts[i]) mpo_Xmin = Xpts[i]; - if (mpo_Xmax < Xpts[i]) mpo_Xmax = Xpts[i]; - if (mpo_Ymin > Ypts[i]) mpo_Ymin = Ypts[i]; - if (mpo_Ymax < Ypts[i]) mpo_Ymax = Ypts[i]; - } - mpo_size = int( floor((mpo_Ymax - mpo_Ymin)/step) ); - mpo_Xs = (double **)malloc(sizeof(double)*mpo_size); - mpo_Ys = (double **)malloc(sizeof(double)*mpo_size); - mpo_sizes = (int *)malloc(sizeof(int)*mpo_size); - for (i = 0; i < mpo_size; i++) - { - int k = 0; - double level = mpo_Ymax - step*i; - for ( j = 0; j < n-1; j++) - if (Ypts[j] - Ypts[j+1] != 0) - { - if (((level > mpo_min(Ypts[j], Ypts[j+1])) && (level < mpo_max(Ypts[j], Ypts[j+1]))) - || (level == Ypts[j])) k++; - if (level == Ypts[j+1]) - if (mpo_sign(Ypts[j] - Ypts[j+1]) == mpo_next_sign(j, n)) k++; - else; - else; - } - mpo_Xs[i] = (double *)malloc(sizeof(double)*k); - mpo_Ys[i] = (double *)malloc(sizeof(double)*k); - for (j = 0; j < k; j++) mpo_Ys[i][j] = level; - mpo_sizes[i] = k; - } - - // evaluating variables - for (i = 0; i < mpo_size; i++) - { - int k = 0; - double level = mpo_Ymax - step*i; - for ( j = 0; j < n-1; j++) - if (Ypts[j] - Ypts[j+1] != 0) - { - if (((level > mpo_min(Ypts[j], Ypts[j+1])) && (level < mpo_max(Ypts[j], Ypts[j+1]))) - || (level == Ypts[j])) - { - if (Ypts[j+1] - Ypts[j] == 0) mpo_Xs[i][k] = Xpts[j]; - else mpo_Xs[i][k] = Xpts[j] + (Xpts[j+1] - Xpts[j])*(level - Ypts[j])/(Ypts[j+1] - Ypts[j]); - k++; - } - if (level == Ypts[j+1]) - if (mpo_sign(Ypts[j] - Ypts[j+1]) == mpo_next_sign(j, n)) - { - mpo_Xs[i][k] = Xpts[j+1]; k++; - } - else; - else; - } - - if (k != mpo_sizes[i]) - { - cout << "Number mismatch: k = " << k << "\tsizes[i] = " << mpo_sizes[i] << endl << flush; - free(Xpts); free(Ypts); - return 0; - } - } - - // sorting - for (int m = 0; m < mpo_size; m++) - for (i = 0; i < mpo_sizes[m]-1; i++) - for ( j = 0; j < mpo_sizes[m]-1; j++) - if (mpo_Xs[m][j] > mpo_Xs[m][j+1]) - { - double tmp; - tmp = mpo_Xs[m][j+1]; mpo_Xs[m][j+1] = mpo_Xs[m][j]; mpo_Xs[m][j] = tmp; - tmp = mpo_Ys[m][j+1]; mpo_Ys[m][j+1] = mpo_Ys[m][j]; mpo_Ys[m][j] = tmp; - } - - // rotate on -gamma - for (i = 0; i < mpo_size; i++) - for ( j = 0; j < mpo_sizes[i]; j++) - { - double Yt = mpo_Ys[i][j], Xt = mpo_Xs[i][j]; - mpo_Xs[i][j] = Xt*cos(gamma) - Yt*sin(gamma); - mpo_Ys[i][j] = Xt*sin(gamma) + Yt*cos(gamma); - } - - // end - free(Xpts); free(Ypts); - return mpo_size; -} - -int __GetLineOfFilledPolygon (int n, int &N, double* &X, double* &Y) -{ -// cout << "GetLineOfFilledPolygon -- n = " << n << endl << flush; - if ((n < 0) || (n >= mpo_size)) return 0; - N = mpo_sizes[n]; - X = mpo_Xs[n]; Y = mpo_Ys[n]; - return 1; -} - -void __DoneFillPolygon(void) -{ - for (int i = 0; i < mpo_size; i++) - { - free(mpo_Xs[i]); free(mpo_Ys[i]); - } - free(mpo_sizes); -} diff --git a/src/Prs2d/Prs2d.cdl b/src/Prs2d/Prs2d.cdl deleted file mode 100755 index 120777e85d..0000000000 --- a/src/Prs2d/Prs2d.cdl +++ /dev/null @@ -1,209 +0,0 @@ --- Created by: Tanya COOL --- Copyright (c) 2000-2012 OPEN CASCADE SAS --- --- The content of this file is subject to the Open CASCADE Technology Public --- License Version 6.5 (the "License"). You may not use the content of this file --- except in compliance with the License. Please obtain a copy of the License --- at http://www.opencascade.org and read it completely before using this file. --- --- The Initial Developer of the Original Code is Open CASCADE S.A.S., having its --- main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. --- --- The Original Code and all software distributed under the License is --- distributed on an "AS IS" basis, without warranty of any kind, and the --- Initial Developer hereby disclaims all such warranties, including without --- limitation, any warranties of merchantability, fitness for a particular --- purpose or non-infringement. Please see the License for the specific terms --- and conditions governing the rights and limitations under the License. - - -package Prs2d - - ---Purpose: package provides the graphic attribute manager Drawer, - -- the set of aspect classes for storing hte session attributes - -- and default attributes for the objects. - -uses - - Graphic2d, - Aspect, - Quantity, - TShort, - Standard, - gp, - Geom2d, - TCollection, - TColgp, - TColStd, - TopoDS, - GCPnts -is - enumeration AspectName is - - AN_UNKNOWN, - AN_LINE, - AN_HIDDENLINE, - AN_TEXT, - AN_HIDINGPOLY, - AN_HIDINGTEXT, - AN_FRAMEDTEXT, - - -- For new aspect types - AN_LAST - - end AspectName; - - enumeration TypeOf2DObject is - - TOO_UNKNOWN, - TOO_ANGLE, - TOO_ARROW, - TOO_CURVE, - TOO_DATUM, - TOO_DIAMETER, - TOO_ELLIPSERADIUS, - TOO_EQUALDISTANCE, - TOO_LENGTH - - end TypeOf2DObject; - - enumeration ArrowSide is - - AS_NONE, - AS_FIRSTAR, - AS_LASTAR, - AS_BOTHAR, - AS_FIRSTPT, - AS_LASTPT, - AS_BOTHPT, - AS_FIRSTAR_LASTPT, - AS_FIRSTPT_LASTAR - - end ArrowSide; - - enumeration TypeOfArrow is - - TOA_OPENED, - TOA_CLOSED, - TOA_FILLED - - end TypeOfArrow; - - enumeration TypeOfDist is - - TOD_AUTOMATIC, - TOD_OBLIQUE, - TOD_HORIZONTAL, - TOD_VERTICAL - - end TypeOfDist; - - enumeration TypeOfAxis is - - TOAX_Unknown, - TOAX_XAxis, - TOAX_YAxis - - end TypeOfAxis; - - enumeration TypeOfTolerance is - - TOT_TAPER, - TOT_SYMTOTAL, - TOT_SYMCIRCULAR, - TOT_SYMMETRY, - TOT_CONCENTRIC, - TOT_POSITION, - TOT_ANGULARITY, - TOT_PERPENDIC, - TOT_PARALLELISM, - TOT_SURFACEPROF, - TOT_LINEPROF, - TOT_CYLINDRIC, - TOT_CIRCULARITY, - TOT_FLATNESS, - TOT_STRAIGHTNESS, - TOT_NONE - - end TypeOfTolerance; - - enumeration TypeOfSymbol is - - TOS_NONE, - TOS_DIAMETER, - - - TOS_LAST - - end TypeOfSymbol; - - enumeration TypeOfRadius is - - TOR_STANDARD, - TOR_CENTER, - TOR_REVARROW, - TOR_CENTREV, - TOR_NONE - - end TypeOfRadius; - - exception SymbolDefinitionError inherits OutOfRange; - - deferred class AspectRoot; - - -- Standard aspects - - class AspectLine; - class AspectText; - - class AspectHidingPoly; - class AspectHidingText; - class AspectFramedText; - - -- Standard primitives - - class Point; - class Axis; - class Arrow; - - -- Dimensions - - deferred class Dimension; - class Angle; - class Length; - class Radius; - class Diameter; - class Repere; - - class RadiusIndep; - - class ToleranceFrame; - - deferred class Tolerance; - - class Straightness; - class Flatness; - class Circularity; - class Cylindric; - class LineProfile; - class SurfProfile; - class Parallelism; - class Perpendicular; - class Angularity; - class Position; - class Concentric; - class Symmetry; - class SymTotal; - class SymCircular; - class Taper; - - class DrawSymbol; - - class Drawer; - - class DataMapOfAspectRoot instantiates DataMap from TCollection - ( Integer from Standard, - AspectRoot from Prs2d, - MapIntegerHasher from TColStd ); - -end Prs2d; diff --git a/src/Prs2d/Prs2d_Angle.cdl b/src/Prs2d/Prs2d_Angle.cdl deleted file mode 100755 index 9dc0ca432f..0000000000 --- a/src/Prs2d/Prs2d_Angle.cdl +++ /dev/null @@ -1,118 +0,0 @@ --- Created by: Tanya COOL --- Copyright (c) 2000-2012 OPEN CASCADE SAS --- --- The content of this file is subject to the Open CASCADE Technology Public --- License Version 6.5 (the "License"). You may not use the content of this file --- except in compliance with the License. Please obtain a copy of the License --- at http://www.opencascade.org and read it completely before using this file. --- --- The Initial Developer of the Original Code is Open CASCADE S.A.S., having its --- main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. --- --- The Original Code and all software distributed under the License is --- distributed on an "AS IS" basis, without warranty of any kind, and the --- Initial Developer hereby disclaims all such warranties, including without --- limitation, any warranties of merchantability, fitness for a particular --- purpose or non-infringement. Please see the License for the specific terms --- and conditions governing the rights and limitations under the License. - - -class Angle from Prs2d inherits Dimension from Prs2d - - ---Purpose: Constructs the primitive Angle - -uses - - Drawer from Graphic2d, - GraphicObject from Graphic2d, - Pnt2d from gp, - Length from Quantity, - ExtendedString from TCollection, - ArrowSide from Prs2d, - TypeOfArrow from Prs2d, - FStream from Aspect - -raises - - CircleDefinitionError from Graphic2d - -is - Create( aGraphicObject: GraphicObject from Graphic2d; - anAttachPnt1 : Pnt2d from gp; - anAttachPnt2 : Pnt2d from gp; - anAttachPnt3 : Pnt2d from gp; - aRadius : Length from Quantity; - aText : ExtendedString from TCollection; - aTxtScale : Real from Standard = 3.0; - anArrAngle : Real from Standard = 15.0; - anArrLength : Real from Standard = 10.0; - anArrType : TypeOfArrow from Prs2d = Prs2d_TOA_OPENED; - anArrow : ArrowSide from Prs2d = Prs2d_AS_BOTHAR; - IsReverseArrow: Boolean from Standard = Standard_False ) - - returns mutable Angle from Prs2d; - - ---Purpose: create an angle: - -- between the line defined by the points - -- anAttachtPnt1 and anAttachPnt2 and - -- the line defined by the points - -- anAttachPnt1 and anAttachPnt3 - -- Radius of this angle is the distance - -- between and points. - -- in degree - - -------------------------------------- - -- Category: Inquire methods - -------------------------------------- - - Values( me; aPnt1, aPnt2, aPnt3: out Pnt2d from gp; - aRad: out Length from Quantity ); - ---Level: Internal - ---Purpose: allows to get the properties of the angle - - CalcTxtPos(me:mutable; theFromAbs: Boolean - from Standard=Standard_False) - ---C++: inline - is redefined protected; - - -------------------------------------- - -- Category: Draw and Pick - -------------------------------------- - - Draw( me : mutable; aDrawer: Drawer from Graphic2d ) - is static protected; - ---Level: Internal - ---Purpose: Draws the angle . - - DrawElement( me : mutable; aDrawer: Drawer from Graphic2d; - anIndex: Integer from Standard) - is redefined protected; - ---Level: Internal - ---Purpose: Draws element of the angle . - - DrawVertex( me : mutable; aDrawer: Drawer from Graphic2d; - anIndex: Integer from Standard) - is redefined protected; - ---Level: Internal - ---Purpose: Draws vertex of the angle . - - Pick( me : mutable; X, Y: ShortReal from Standard; - aPrecision: ShortReal from Standard; - aDrawer: Drawer from Graphic2d) - returns Boolean from Standard - is static protected; - ---Level: Internal - ---Purpose: Returns Standard_True if the angle is picked, - -- Standard_False if not. - - Save( me; aFStream: in out FStream from Aspect ) is virtual; - -fields - - myCentX : ShortReal from Standard; - myCentY : ShortReal from Standard; - myRad : ShortReal from Standard; - myFAngle : ShortReal from Standard; - mySAngle : ShortReal from Standard; - -end Angle from Prs2d; diff --git a/src/Prs2d/Prs2d_Angle.cxx b/src/Prs2d/Prs2d_Angle.cxx deleted file mode 100755 index 85c1b33933..0000000000 --- a/src/Prs2d/Prs2d_Angle.cxx +++ /dev/null @@ -1,678 +0,0 @@ -// Copyright (c) 1999-2012 OPEN CASCADE SAS -// -// The content of this file is subject to the Open CASCADE Technology Public -// License Version 6.5 (the "License"). You may not use the content of this file -// except in compliance with the License. Please obtain a copy of the License -// at http://www.opencascade.org and read it completely before using this file. -// -// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its -// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. -// -// The Original Code and all software distributed under the License is -// distributed on an "AS IS" basis, without warranty of any kind, and the -// Initial Developer hereby disclaims all such warranties, including without -// limitation, any warranties of merchantability, fitness for a particular -// purpose or non-infringement. Please see the License for the specific terms -// and conditions governing the rights and limitations under the License. - -#include -#include - -#define VERTEXMARKER 2 -#define DEFAULTMARKERSIZE 3.0 -#define XROTATE(x,y) ((x)*cosa - (y)*sina) -#define YROTATE(x,y) ((y)*cosa + (x)*sina) -#define ADDPIX 7 - -Prs2d_Angle::Prs2d_Angle( const Handle(Graphic2d_GraphicObject)& aGO, - const gp_Pnt2d& anAttachPnt1, - const gp_Pnt2d& anAttachPnt2, - const gp_Pnt2d& anAttachPnt3, - const Quantity_Length aRadius, - const TCollection_ExtendedString& aText, - const Standard_Real aTxtScale, - const Standard_Real anArrAngle, - const Standard_Real anArrLength, - const Prs2d_TypeOfArrow anArrType, - const Prs2d_ArrowSide anArrow, - const Standard_Boolean IsRevArrow ) - - : Prs2d_Dimension( aGO, aText, aTxtScale, anArrAngle, - anArrLength, anArrType, anArrow, IsRevArrow ), - myCentX( Standard_ShortReal( anAttachPnt1.X() ) ), - myCentY( Standard_ShortReal( anAttachPnt1.Y() ) ), - myRad( Standard_ShortReal( aRadius ) ) -{ - - SetSymbolCode( 176 ); - gp_Vec2d V1( anAttachPnt1, anAttachPnt2 ); - gp_Vec2d V2( anAttachPnt1, anAttachPnt3 ); - gp_Vec2d VX( 1., 0. ); - myFAngle = Standard_ShortReal( VX.Angle(V1) ); - mySAngle = Standard_ShortReal( VX.Angle(V2) ); - - //myRad = Standard_ShortReal(anAttachPnt1.Distance( anOffsetPoint )); - if ( myRad <= ShortRealEpsilon ()) - Graphic2d_CircleDefinitionError::Raise ("The radius = 0." ); - - Standard_ShortReal TwoPI = Standard_ShortReal(2. * M_PI); - while( myFAngle < 0. ) myFAngle += TwoPI; - while( myFAngle > 2. * M_PI ) myFAngle -= TwoPI; - while( mySAngle < 0. ) mySAngle += TwoPI; - while( mySAngle > 2. * M_PI ) mySAngle -= TwoPI; - if ( mySAngle < myFAngle ) mySAngle += TwoPI; - - if ( ( mySAngle - myFAngle < ShortRealEpsilon() ) || - ( mySAngle - myFAngle >= TwoPI ) ) { - myFAngle = 0.; - mySAngle = TwoPI; - myMinX = myCentX - myRad; - myMinY = myCentY - myRad; - myMaxX = myCentX + myRad; - myMaxY = myCentY + myRad; - } else { - Standard_ShortReal Acur,Xcur,Ycur,Xsav; - myMinX = myMaxX = Standard_ShortReal(Cos(myFAngle)); - myMinY = myMaxY = Standard_ShortReal(Sin(myFAngle)); - Xcur = Standard_ShortReal(Cos(mySAngle)); - Ycur = Standard_ShortReal(Sin(mySAngle)); - myMinX = myMinX < Xcur ? myMinX : Xcur; - myMinY = myMinY < Ycur ? myMinY : Ycur; - myMaxX = myMaxX > Xcur ? myMaxX : Xcur; - myMaxY = myMaxY > Ycur ? myMaxY : Ycur; - - for ( Acur = 0., Xcur = 1., Ycur = 0.; - Acur < mySAngle; Acur += Standard_ShortReal(M_PI / 2.)) { - if ( Acur > myFAngle ) { - myMinX = ( myMinX < Xcur ? myMinX : Xcur ); - myMaxX = ( myMaxX < Xcur ? Xcur : myMaxX ); - myMinY = ( myMinY < Ycur ? myMinY : Ycur ); - myMaxY = ( myMaxY < Ycur ? Ycur : myMaxY ); - } - Xsav = Xcur; Xcur = -Ycur; Ycur = Xsav; - } - myMinX = myCentX + myRad * myMinX; - myMaxX = myCentX + myRad * myMaxX; - myMinY = myCentY + myRad * myMinY; - myMaxY = myCentY + myRad * myMaxY; - } - - // Arrows - - Standard_Real ArrAngle = M_PI/180.*anArrAngle; - - gp_Pnt2d theOrigine(0.,0.); - gp_Pnt2d P1, P2, P3; - gp_Vec2d VDir; - Standard_Real theAngle; - - if ( ( myArrow == Prs2d_AS_FIRSTAR ) || ( myArrow == Prs2d_AS_BOTHAR ) ) { - P1 = gp_Pnt2d( myCentX + myRad * Cos(myFAngle), - myCentY + myRad * Sin(myFAngle) ); - - P2 = gp_Pnt2d( anArrLength, anArrLength*Tan( ArrAngle/2. ) ); - P3 = gp_Pnt2d( anArrLength, -anArrLength*Tan( ArrAngle/2. ) ); - - VDir = V1.Rotated(M_PI/2); - theAngle = VX.Angle( VDir ); - P2.Rotate( theOrigine, theAngle ); - P3.Rotate( theOrigine, theAngle ); - - P2.Translate( gp_Vec2d( theOrigine, P1 ) ); - P3.Translate( gp_Vec2d( theOrigine, P1 ) ); - - myXVert1(1) = Standard_ShortReal( P2.X() ); - myYVert1(1) = Standard_ShortReal( P2.Y() ); - myXVert1(2) = Standard_ShortReal( P1.X() ); - myYVert1(2) = Standard_ShortReal( P1.Y() ); - myXVert1(3) = Standard_ShortReal( P3.X() ); - myYVert1(3) = Standard_ShortReal( P3.Y() ); - - for ( Standard_Integer i = 1; i <= 3; i++ ) { - if ( myXVert1(i) < myMinX ) myMinX = myXVert1(i); - if ( myYVert1(i) < myMinY ) myMinY = myYVert1(i); - if ( myXVert1(i) > myMaxX ) myMaxX = myXVert1(i); - if ( myYVert1(i) > myMaxY ) myMaxY = myYVert1(i); - - } - } // end if myArrow is FIRSTAR or BOTHAR - - if ( ( myArrow == Prs2d_AS_LASTAR ) || ( myArrow == Prs2d_AS_BOTHAR ) ){ - P1 = gp_Pnt2d ( myCentX + myRad * Cos(mySAngle), - myCentY + myRad * Sin(mySAngle) ); - - P2 = gp_Pnt2d( anArrLength, anArrLength*Tan( ArrAngle/2. ) ); - P3 = gp_Pnt2d( anArrLength, -anArrLength*Tan( ArrAngle/2. ) ); - - VDir = V2.Rotated(-M_PI/2); - theAngle = VX.Angle( VDir ); - - P2.Rotate( theOrigine, theAngle ); - P3.Rotate( theOrigine, theAngle ); - - P2.Translate( gp_Vec2d( theOrigine, P1 ) ); - P3.Translate( gp_Vec2d( theOrigine, P1 ) ); - - myXVert2(1) = Standard_ShortReal( P2.X() ); - myYVert2(1) = Standard_ShortReal( P2.Y() ); - myXVert2(2) = Standard_ShortReal( P1.X() ); - myYVert2(2) = Standard_ShortReal( P1.Y() ); - myXVert2(3) = Standard_ShortReal( P3.X() ); - myYVert2(3) = Standard_ShortReal( P3.Y() ); - - for ( Standard_Integer i = 1; i <= 3; i++ ) { - if ( myXVert2(i) < myMinX ) myMinX = myXVert2(i); - if ( myYVert2(i) < myMinY ) myMinY = myYVert2(i); - if ( myXVert2(i) > myMaxX ) myMaxX = myXVert2(i); - if ( myYVert2(i) > myMaxY ) myMaxY = myYVert2(i); - - } - } // end if myArrow is FIRSTAR or BOTHAR - - myNumOfElem = 4; - myNumOfVert = 3; - -} - -void Prs2d_Angle::Values( gp_Pnt2d & aPnt1, - gp_Pnt2d & aPnt2, - gp_Pnt2d & aPnt3, - Quantity_Length & aRad ) const { - - aPnt1.SetCoord( myCentX, myCentY ); - gp_Vec2d VX( myRad, 0. ), V2, V3; - V2 = VX.Rotated( myFAngle ); - aPnt2 = aPnt1.Translated( V2 ); - V3 = VX.Rotated( mySAngle ); - aPnt3 = aPnt1.Translated( V3 ); - aRad = myRad; -} - -void Prs2d_Angle::Draw( const Handle(Graphic2d_Drawer)& aDrawer ) { - - Standard_Boolean IsIn = Standard_False; - - if ( !myGOPtr->IsTransformed() ) - IsIn = aDrawer->IsIn( myMinX, myMaxX, myMinY, myMaxY ); - else { - Standard_ShortReal minx, miny, maxx, maxy; - MinMax( minx, maxx, miny, maxy ); - IsIn = aDrawer->IsIn( minx, maxx, miny, maxy ); - } - - if ( IsIn ) { - - DrawLineAttrib(aDrawer); - Standard_ShortReal theScale = Standard_ShortReal(myTextScale*aDrawer->Scale()); - aDrawer->SetTextAttrib( myColorIndex, myTextFont, 0.0, theScale, theScale, Standard_False ); - - // Text - /*Standard_ShortReal dxx = aDrawer->Convert(ADDPIX); - gp_Pnt2d P1 = gp_Pnt2d( myCentX + ( dxx + myRad ) * Cos(myFAngle), - myCentY + ( dxx + myRad ) * Sin(myFAngle) ); - - gp_Pnt2d P2 = gp_Pnt2d( myCentX + ( dxx + myRad ) * Cos(mySAngle), - myCentY + ( dxx + myRad ) * Sin(mySAngle) ); - - - gp_Pnt2d theCent(myCentX, myCentY); - gp_Vec2d V1( theCent, P1), V2( theCent, P2), VX(1., 0.); - Standard_Real delta = V1.Angle(V2); - gp_Vec2d textV1 = V1.Rotated( delta/2 ); - Standard_Real theAngle = VX.Angle(textV1); - gp_Pnt2d pntText = theCent.Translated(textV1); - Standard_Real txtX, txtY; - pntText.Coord(txtX, txtY); - Standard_ShortReal txtAngle = Standard_ShortReal( theAngle + 3*M_PI/2); - - Standard_ShortReal ws, hs; - aDrawer->GetTextSize( myText, ws, hs ); - Standard_Real theSmbX, theSmbY; - Standard_ShortReal ddd = aDrawer->Convert(2); - gp_Vec2d theVec = VX.Rotated( txtAngle ); - theVec *= ( ws + ddd ); - gp_Pnt2d pntSymb = pntText.Translated( theVec ); - pntSymb.Coord( theSmbX, theSmbY );*/ //correct by enk Fri Nov 29 15:17 2002 - - ///////////////////////////////////////// - Standard_ShortReal txtAngle=Standard_ShortReal(myAbsAngle); - Standard_Real theSmbX,theSmbY; - theSmbX=myAbsX; - theSmbY=myAbsY; - ///////////////////////////////////////// - Standard_ShortReal a = myCentX, b = myCentY, c = myRad, e = myFAngle, f = mySAngle, - t1 = Standard_ShortReal(myAbsX), t2 = Standard_ShortReal(myAbsY), - ts1 = Standard_ShortReal(theSmbX), ts2 = Standard_ShortReal(theSmbY); - - TShort_Array1OfShortReal Xpoint1( 1, 3 ), Ypoint1( 1, 3 ), - Xpoint2( 1, 3 ), Ypoint2( 1, 3 ); - - if ( myGOPtr->IsTransformed () ) { - - gp_GTrsf2d aTrsf = myGOPtr->Transform (); - - if ( ( myArrow == Prs2d_AS_FIRSTAR ) || ( myArrow == Prs2d_AS_BOTHAR ) ){ - - Standard_Real a1, b1; - for ( Standard_Integer j = 1; j <= 3; j++ ) { - a1 = Standard_Real( myXVert1(j) ); - b1 = Standard_Real( myYVert1(j) ); - aTrsf.Transforms (a1, b1); - Xpoint1(j) = Standard_ShortReal(a1); - Ypoint1(j) = Standard_ShortReal(b1); - } - } // end if myArrow is FIRSTAR ot BOTHAR - - if ( ( myArrow == Prs2d_AS_LASTAR ) || ( myArrow == Prs2d_AS_BOTHAR ) ) { - - Standard_Real c1, d1; - - for ( Standard_Integer j = 1; j <= 3; j++ ) { - c1 = Standard_Real( myXVert2(j) ); - d1 = Standard_Real( myYVert2(j) ); - aTrsf.Transforms (c1, d1); - Xpoint2(j) = Standard_ShortReal(c1); - Ypoint2(j) = Standard_ShortReal(d1); - } - } // end if myArrow is LASTAR ot BOTHAR - - Standard_Real A, B, E, F, - X0, Y0, X1, Y1, X2, Y2, T1, T2; - A = Standard_Real( a ); - B = Standard_Real( b ); - E = Standard_Real( e ); - F = Standard_Real( f ); - T1 = Standard_Real( t1 ); - T2 = Standard_Real( t2); - aTrsf.Transforms( A, B ); - aTrsf.Transforms( T1, T2 ); - a = Standard_ShortReal( A ); - b = Standard_ShortReal( B ); - t1 = Standard_ShortReal( T1 ); - t2 = Standard_ShortReal( T2 ); - A = Standard_Real( ts1 ); - B = Standard_Real( ts2 ); - aTrsf.Transforms( A, B ); - ts1 = Standard_ShortReal( A ); - ts2 = Standard_ShortReal( B ); - - if ( Abs(f-e) < Standard_ShortReal(2. * M_PI) ) { - aTrsf.SetValue( 1, 3, 0.0 ); - aTrsf.SetValue( 2, 3, 0.0 ); - - X1 = Cos(E); - Y1 = Sin(E ); - X2 = Cos(F); - Y2 = Sin(F ); - aTrsf.Transforms( X1, Y1 ); - aTrsf.Transforms( X2, Y2 ); - X0 = Y0 = 0.; - aTrsf.Transforms( X0, Y0 ); - X1 -= X0; - Y1 -= Y0; - X2 -= X0; - Y2 -= Y0; - c = myRad * Standard_ShortReal( Sqrt(X1*X1 + Y1*Y1) ); - e = Standard_ShortReal( atan2(Y1,X1) ); - f = Standard_ShortReal( atan2(Y2,X2) ); - if ( aTrsf.IsNegative() ) { - Standard_ShortReal t = e; e = f; f = t; - } - } // end if Abs(f-e) < 2PI - } else { - - if ( ( myArrow == Prs2d_AS_FIRSTAR ) || ( myArrow == Prs2d_AS_BOTHAR ) ){ - Xpoint1.Assign( myXVert1 ); - Ypoint1.Assign( myYVert1 ); - } - if ( ( myArrow == Prs2d_AS_LASTAR ) || ( myArrow == Prs2d_AS_BOTHAR ) ) { - Xpoint2.Assign( myXVert2 ); - Ypoint2.Assign( myYVert2 ); - } - - } // end if GO is transformed - - aDrawer->MapArcFromTo( a, b, c, e, f ); - aDrawer->MapTextFromTo( myText, t1, t2, txtAngle, 0., 0., Aspect_TOT_SOLID ); - - if ( myIsSymbol ) { - aDrawer->SetTextAttrib( myColorIndex, mySymbFont, 0, Standard_ShortReal(myTextScale*aDrawer->Scale()), - Standard_ShortReal(myTextScale*aDrawer->Scale()), Standard_False ); -// TCollection_ExtendedString txtSymb( char( SymbolCode() ) ); - Standard_Character code = SymbolCode(); - TCollection_ExtendedString txtSymb( code ); - Standard_ShortReal dx=0.,dy=0.; - aDrawer->MapTextFromTo( txtSymb, ts1, ts2, txtAngle, dx, dy, Aspect_TOT_SOLID ); - } - - - if ( ( myArrow == Prs2d_AS_FIRSTAR ) || ( myArrow == Prs2d_AS_BOTHAR ) ){ - if ( myArrType == Prs2d_TOA_CLOSED || myArrType == Prs2d_TOA_FILLED ) { - aDrawer->MapPolygonFromTo( Xpoint1, Ypoint1 ); - } else { - aDrawer->MapPolylineFromTo( Xpoint1, Ypoint1 ); - } - } - - if ( ( myArrow == Prs2d_AS_LASTAR ) || ( myArrow == Prs2d_AS_BOTHAR ) ){ - if ( myArrType == Prs2d_TOA_CLOSED || myArrType == Prs2d_TOA_FILLED ) { - aDrawer->MapPolygonFromTo( Xpoint2, Ypoint2 ); - } else { - aDrawer->MapPolylineFromTo( Xpoint2, Ypoint2 ); - } - } - - } // end if IsIn is true -} - -void Prs2d_Angle::DrawElement( const Handle(Graphic2d_Drawer)& aDrawer, - const Standard_Integer anIndex) { - Standard_Boolean IsIn = Standard_False; - - if ( ! myGOPtr->IsTransformed() ) - IsIn = aDrawer->IsIn( myMinX, myMaxX, myMinY, myMaxY ); - else { - Standard_ShortReal minx, miny, maxx, maxy; - MinMax( minx, maxx, miny, maxy ); - IsIn = aDrawer->IsIn( minx, maxx, miny, maxy ); - } - - if ( IsIn ) { - - DrawLineAttrib( aDrawer ); - // aDrawer->SetTextAttrib( myColorIndex, myTextFont, 0, myTextScale*aDrawer->Scale(), - // myTextScale*aDrawer->Scale(), Standard_False ); - - // Text - /* - Standard_ShortReal dxx = aDrawer->Convert(ADDPIX); - gp_Pnt2d P1 = gp_Pnt2d( myCentX + ( dxx + myRad ) * Cos(myFAngle), - myCentY + ( dxx + myRad ) * Sin(myFAngle) ); - - gp_Pnt2d P2 = gp_Pnt2d( myCentX + ( dxx + myRad ) * Cos(mySAngle), - myCentY + ( dxx + myRad ) * Sin(mySAngle) ); - - - gp_Pnt2d theCent(myCentX, myCentY); - gp_Vec2d V1( theCent, P1), V2( theCent, P2), VX(1, 0); - Standard_Real delta = V1.Angle(V2); - gp_Vec2d textV1 = V1.Rotated( delta/2 ); - Standard_Real theAngle = VX.Angle(textV1); - gp_Pnt2d pntText = theCent.Translated(textV1); - Standard_Real txtX, txtY; - pntText.Coord(txtX, txtY); - Standard_ShortReal txtAngle = Standard_ShortReal( theAngle + 3*M_PI/2);*/ - //correct by enk Mon Dec 2 11:39 2002 - - - ///////////////////////////////////////// - Standard_ShortReal txtAngle=Standard_ShortReal(myAbsAngle); - Standard_Real theSmbX,theSmbY; - theSmbX=myAbsX; - theSmbY=myAbsY; - ///////////////////////////////////////// - Standard_ShortReal a = myCentX, b = myCentY, c = myRad, e = myFAngle, - f = mySAngle,t1 = Standard_ShortReal( myAbsX ), - t2 = Standard_ShortReal( myAbsY ); - TShort_Array1OfShortReal Xpoint( 1, 3 ), Ypoint( 1, 3 ); - - if ( anIndex == 1 ) { - Xpoint.Assign( myXVert1 ); - Ypoint.Assign( myYVert1 ); - } else if ( anIndex == 2 ) { - Xpoint.Assign( myXVert2 ); - Ypoint.Assign( myYVert2 ); - } - - if ( myGOPtr->IsTransformed () ) { - gp_GTrsf2d aTrsf = myGOPtr->Transform (); - Standard_Real a1, b1; - - if ( anIndex == 1 ) { - for ( Standard_Integer j = 1; j <= 3; j++ ) { - a1 = Standard_Real( Xpoint(j) ); - b1 = Standard_Real( Xpoint(j) ); - aTrsf.Transforms( a1, b1 ); - Xpoint(j) = Standard_ShortReal( a1 ); - Ypoint(j) = Standard_ShortReal( b1 ); - } - } else if ( anIndex == 2 ) { - - for ( Standard_Integer j = 1; j <= 3; j++ ) { - a1 = Standard_Real( Xpoint(j) ); - b1 = Standard_Real( Xpoint(j) ); - aTrsf.Transforms( a1, b1 ); - Xpoint(j) = Standard_ShortReal( a1 ); - Ypoint(j) = Standard_ShortReal( b1 ); - } - } else if ( anIndex == 4 ) { - - Standard_Real A, B, E, F, - X0, Y0, X1, Y1, X2, Y2; - A = Standard_Real( a ); - B = Standard_Real( b ); - E = Standard_Real( e ); - F = Standard_Real( f ); - aTrsf.Transforms( A, B ); - a = Standard_ShortReal( A ); - b = Standard_ShortReal( B ); - - if ( Abs(f-e) < Standard_ShortReal(2. * M_PI) ) { - aTrsf.SetValue( 1, 3, 0.0 ); - aTrsf.SetValue( 2, 3, 0.0 ); - X1 = Cos(E); - Y1 = Sin(E ); - X2 = Cos(F); - Y2 = Sin(F ); - aTrsf.Transforms( X1, Y1 ); - aTrsf.Transforms( X2, Y2 ); - X0 = Y0 = 0.; - aTrsf.Transforms( X0, Y0 ); - X1 -= X0; - Y1 -= Y0; - X2 -= X0; - Y2 -= Y0; - c = myRad * Standard_ShortReal( Sqrt(X1*X1 + Y1*Y1) ); - e = Standard_ShortReal( atan2(Y1,X1) ); - f = Standard_ShortReal( atan2(Y2,X2) ); - if ( aTrsf.IsNegative() ) { - Standard_ShortReal t = e; e = f; f = t; - } - } // end if Abs(f-e) < 2PI - - } else if ( anIndex == 3 ) { - a1 = Standard_Real( t1 ); - b1 = Standard_Real( t2); - aTrsf.Transforms( a1, b1 ); - t1 = Standard_ShortReal( a1 ); - t2 = Standard_ShortReal( b1); - } - } - - if ( anIndex == 1 || anIndex == 2 ) - if ( myArrType == Prs2d_TOA_CLOSED || myArrType == Prs2d_TOA_FILLED ) { - aDrawer->MapPolygonFromTo( Xpoint, Ypoint ); - } else { - aDrawer->MapPolylineFromTo( Xpoint, Ypoint ); - } - else if ( anIndex == 4 ) - aDrawer->MapArcFromTo( a, b, c, e, f ); - else if ( anIndex == 3 ) - aDrawer->MapTextFromTo( myText, t1, t2, txtAngle, 0., 0., Aspect_TOT_SOLID ); - - } // end if IsIn is true - -} - -void Prs2d_Angle::DrawVertex (const Handle(Graphic2d_Drawer)& aDrawer, - const Standard_Integer anIndex) { - - Standard_Boolean IsIn = Standard_False; - - if ( ! myGOPtr->IsTransformed() ) - IsIn = aDrawer->IsIn( myMinX, myMaxX, myMinY, myMaxY ); - else { - Standard_ShortReal minx, miny, maxx, maxy; - MinMax( minx, maxx, miny, maxy ); - IsIn = aDrawer->IsIn( minx, maxx, miny, maxy ); - } - - if ( IsIn ) { - if ( anIndex > 0 && anIndex < 4 ) { - DrawMarkerAttrib( aDrawer ); - Standard_ShortReal X=0.,Y=0.; - if ( anIndex == 1 ) { - X = myCentX; Y = myCentY; - } else if ( anIndex == 2 ) { - X = Standard_ShortReal(myCentX + myRad *Cos( myFAngle )); - Y = Standard_ShortReal(myCentY + myRad *Sin( myFAngle )); - } else if ( anIndex == 3 ) { - X = Standard_ShortReal( myCentX + myRad *Cos( mySAngle ) ); - Y = Standard_ShortReal( myCentY + myRad *Sin( mySAngle ) ); - } - if ( myGOPtr->IsTransformed() ) { - gp_GTrsf2d aTrsf = myGOPtr->Transform (); - Standard_Real A, B; - A = Standard_Real( X ); - B = Standard_Real( Y ); - aTrsf.Transforms (A, B); - X = Standard_ShortReal( A ); - Y = Standard_ShortReal( B ); - } - aDrawer->MapMarkerFromTo( VERTEXMARKER, X, Y, - DEFAULTMARKERSIZE,DEFAULTMARKERSIZE, 0.0 ); - } - } // end if IsIn is true - -} - -Standard_Boolean Prs2d_Angle::Pick( const Standard_ShortReal X, - const Standard_ShortReal Y, - const Standard_ShortReal aPrecision, - const Handle(Graphic2d_Drawer)& aDrawer) { - - Standard_Boolean Result = Standard_False; - Standard_ShortReal SRX = X, SRY = Y; - - if ( IsInMinMax( X, Y, aPrecision ) ) { - - if ( myGOPtr->IsTransformed() ) { - gp_GTrsf2d aTrsf = ( myGOPtr->Transform() ).Inverted (); - Standard_Real RX = Standard_Real( SRX ), RY = Standard_Real( SRY ); - aTrsf.Transforms( RX, RY ); - SRX = Standard_ShortReal( RX ); - SRY = Standard_ShortReal( RY ); - } - Standard_ShortReal x1 = Standard_ShortReal(myRad *Cos( myFAngle ) + myCentX), - y1 = Standard_ShortReal(myRad *Sin( myFAngle ) + myCentY), - x2 = Standard_ShortReal(myRad *Cos( mySAngle ) + myCentX), - y2 = Standard_ShortReal(myRad *Sin( mySAngle ) + myCentY); - - - if ( Graphic2d_Primitive::IsOn( SRX, SRY, myCentX, myCentY, aPrecision ) ) { - SetPickedIndex(-1); - return Standard_True; - } else if ( Graphic2d_Primitive::IsOn( SRX, SRY, x1, y1, aPrecision ) ) { - SetPickedIndex(-2); - return Standard_True; - } else if ( Graphic2d_Primitive::IsOn( SRX, SRY, x2, y2, aPrecision ) ) { - SetPickedIndex(-3); - return Standard_True; - } - - if ( ( myArrow == Prs2d_AS_FIRSTAR ) || ( myArrow == Prs2d_AS_BOTHAR ) ) { - for ( Standard_Integer i = 1; i < 3 ; i++) - if ( IsOn( SRX, SRY, myXVert1(i), myYVert1(i), myXVert1(i+1), myYVert1( i+1 ), aPrecision ) ) { - SetPickedIndex(1); - return Standard_True; - } - - if ( myArrType == Prs2d_TOA_CLOSED || myArrType == Prs2d_TOA_FILLED ) - if ( IsIn( SRX, SRY, myXVert1, myYVert1, aPrecision ) ) { - SetPickedIndex(1); - return Standard_True; - } - } // end if myArrow == FIRSTAR or BOTHAR - - if ( ( myArrow == Prs2d_AS_LASTAR ) || ( myArrow == Prs2d_AS_BOTHAR ) ){ - for ( Standard_Integer i = 1; i < 3 ; i++) - if ( IsOn( SRX, SRY, myXVert2(i), myYVert2(i), myXVert2(i+1), myYVert2( i+1 ), aPrecision ) ) { - SetPickedIndex(2); - return Standard_True; - } - - if ( myArrType == Prs2d_TOA_CLOSED || myArrType == Prs2d_TOA_FILLED ) - if ( IsIn( SRX, SRY, myXVert2, myYVert2, aPrecision ) ) { - SetPickedIndex(2); - return Standard_True; - } - } // end if myArrow == LASTAR or BOTHAR - - Standard_ShortReal width,height,xoffset,yoffset; - Standard_ShortReal hscale = Standard_ShortReal(myTextScale*aDrawer->Scale()), - wscale = Standard_ShortReal(myTextScale*aDrawer->Scale()); - Standard_ShortReal TX = X, TY = Y; - - aDrawer->SetTextAttrib( myColorIndex, myTextFont, 0, hscale, wscale, Standard_False ); - if ( !aDrawer->GetTextSize( myText, width, height, xoffset, yoffset ) ) { - width = height = xoffset = yoffset = 0.; - } - // Text - /*Standard_ShortReal dxx = aDrawer->Convert(ADDPIX); - gp_Pnt2d P1 = gp_Pnt2d( myCentX + ( dxx + myRad ) * Cos(myFAngle), - myCentY + ( dxx + myRad ) * Sin(myFAngle) ); - - gp_Pnt2d P2 = gp_Pnt2d( myCentX + ( dxx + myRad ) * Cos(mySAngle), - myCentY + ( dxx + myRad ) * Sin(mySAngle) ); - - - gp_Pnt2d theCent(myCentX, myCentY); - gp_Vec2d V1( theCent, P1), V2( theCent, P2), VX(1, 0); - Standard_Real delta = V1.Angle(V2); - gp_Vec2d textV1 = V1.Rotated( delta/2 ); - Standard_Real theAngle = VX.Angle(textV1); - gp_Pnt2d pntText = theCent.Translated(textV1); - Standard_Real txtX, txtY; - pntText.Coord(txtX, txtY); - Standard_ShortReal txtAngle = Standard_ShortReal( theAngle + 3*M_PI/2);*/ - //correct by enk Mon Dec 2 11:41 2002 - - ///////////////////////////////////////// - Standard_Real txtX,txtY,txtA; - txtX=myAbsX; - txtY=myAbsY; - txtA=myAbsAngle; - Standard_ShortReal txtAngle=Standard_ShortReal(txtA); - ///////////////////////////////////////// - - Standard_ShortReal cosa = Standard_ShortReal(Cos( -txtAngle )), - sina = Standard_ShortReal(Sin( -txtAngle )), - dx = TX - Standard_ShortReal(txtX), - dy = TY - Standard_ShortReal(txtY), - x = XROTATE(dx,dy), - y = YROTATE(dx,dy); - - Result = (x >= -aPrecision + xoffset) - && (x <= width + xoffset + aPrecision) - && (y >= -yoffset - aPrecision) - && (y <= height - yoffset + aPrecision); - - if ( Result ) { - SetPickedIndex(3); - return Standard_True; - } - - if ( Abs( Sqrt( (myCentX - SRX)*(myCentX - SRX) + - (myCentY - SRY)*(myCentY - SRY) ) - myRad ) < aPrecision ) { - SetPickedIndex(4); - return Standard_True; - } - - } // end if IsInMinMax is true - - return Standard_False; -} - -void Prs2d_Angle::Save(Aspect_FStream& aFStream) const -{ -} diff --git a/src/Prs2d/Prs2d_Angle.lxx b/src/Prs2d/Prs2d_Angle.lxx deleted file mode 100755 index 1b148f5133..0000000000 --- a/src/Prs2d/Prs2d_Angle.lxx +++ /dev/null @@ -1,49 +0,0 @@ -// Copyright (c) 1999-2012 OPEN CASCADE SAS -// -// The content of this file is subject to the Open CASCADE Technology Public -// License Version 6.5 (the "License"). You may not use the content of this file -// except in compliance with the License. Please obtain a copy of the License -// at http://www.opencascade.org and read it completely before using this file. -// -// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its -// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. -// -// The Original Code and all software distributed under the License is -// distributed on an "AS IS" basis, without warranty of any kind, and the -// Initial Developer hereby disclaims all such warranties, including without -// limitation, any warranties of merchantability, fitness for a particular -// purpose or non-infringement. Please see the License for the specific terms -// and conditions governing the rights and limitations under the License. - -inline void Prs2d_Angle::CalcTxtPos(const Standard_Boolean theFromAbs) { - - if (!theFromAbs) { - - gp_Pnt2d P1 = gp_Pnt2d( myCentX + ( myRad ) * Cos(myFAngle), - myCentY + ( myRad ) * Sin(myFAngle) ); - - gp_Pnt2d P2 = gp_Pnt2d( myCentX + ( myRad ) * Cos(mySAngle), - myCentY + ( myRad ) * Sin(mySAngle) ); - - - gp_Pnt2d theCent(myCentX, myCentY); - gp_Vec2d V1( theCent, P1), V2( theCent, P2), VX(1., 0.), theVecI, theVecJ; - Standard_Real delta = V1.Angle(V2); - gp_Vec2d textV1 = V1.Rotated( delta/2 ); - - theVecJ = textV1/myRad; - theVecI = textV1.Rotated(-M_PI/2.)/myRad; - - - gp_Pnt2d pntText = - ((theCent.Translated(textV1)).Translated(theVecI*myTextPosH)).Translated(theVecJ*myTextPosV); - - Standard_ShortReal txtAngle = - Standard_ShortReal(VX.Angle(theVecI.Rotated(myTextAngle))); - - myAbsAngle=txtAngle; - myAbsX=pntText.X(); - myAbsY=pntText.Y(); - } - -} diff --git a/src/Prs2d/Prs2d_Angularity.cdl b/src/Prs2d/Prs2d_Angularity.cdl deleted file mode 100755 index 0578a13c8e..0000000000 --- a/src/Prs2d/Prs2d_Angularity.cdl +++ /dev/null @@ -1,54 +0,0 @@ --- Created by: TCL --- Copyright (c) 2000-2012 OPEN CASCADE SAS --- --- The content of this file is subject to the Open CASCADE Technology Public --- License Version 6.5 (the "License"). You may not use the content of this file --- except in compliance with the License. Please obtain a copy of the License --- at http://www.opencascade.org and read it completely before using this file. --- --- The Initial Developer of the Original Code is Open CASCADE S.A.S., having its --- main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. --- --- The Original Code and all software distributed under the License is --- distributed on an "AS IS" basis, without warranty of any kind, and the --- Initial Developer hereby disclaims all such warranties, including without --- limitation, any warranties of merchantability, fitness for a particular --- purpose or non-infringement. Please see the License for the specific terms --- and conditions governing the rights and limitations under the License. - - -class Angularity from Prs2d inherits Tolerance from Prs2d - -uses - - GraphicObject from Graphic2d, - Drawer from Graphic2d, - Length from Quantity, - FStream from Aspect - -is - ------------------------- - -- Category: Constructors - ------------------------- - - Create( aGO : GraphicObject from Graphic2d; - aX, aY : Real from Standard; - aLength : Real from Standard = 3.0; - anAngle : Real from Standard = 0.0 ); - ---Level: Public - ---Purpose: Creates a tolerance Angularity with the center at , ; - -- length of this is ; - -- reference point is , - ---Category: Constructor - - -------------------------- - -- Category: Draw and Pick - -------------------------- - - Draw( me : mutable; aDrawer: Drawer from Graphic2d ) is static protected; - ---Level: Internal - ---Purpose: Draws the Angularity . - - Save( me; aFStream: in out FStream from Aspect ) is virtual; - -end Angularity from Prs2d; diff --git a/src/Prs2d/Prs2d_Angularity.cxx b/src/Prs2d/Prs2d_Angularity.cxx deleted file mode 100755 index 6ddc220fb7..0000000000 --- a/src/Prs2d/Prs2d_Angularity.cxx +++ /dev/null @@ -1,94 +0,0 @@ -// Copyright (c) 1999-2012 OPEN CASCADE SAS -// -// The content of this file is subject to the Open CASCADE Technology Public -// License Version 6.5 (the "License"). You may not use the content of this file -// except in compliance with the License. Please obtain a copy of the License -// at http://www.opencascade.org and read it completely before using this file. -// -// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its -// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. -// -// The Original Code and all software distributed under the License is -// distributed on an "AS IS" basis, without warranty of any kind, and the -// Initial Developer hereby disclaims all such warranties, including without -// limitation, any warranties of merchantability, fitness for a particular -// purpose or non-infringement. Please see the License for the specific terms -// and conditions governing the rights and limitations under the License. - -#include - -Prs2d_Angularity::Prs2d_Angularity( const Handle(Graphic2d_GraphicObject)& aGO, - const Standard_Real aX, - const Standard_Real aY, - const Standard_Real aLength, - const Standard_Real anAngle ) - - : Prs2d_Tolerance( aGO, aX, aY, aLength, anAngle ) -{ - -} - -void Prs2d_Angularity::Draw( const Handle(Graphic2d_Drawer)& aDrawer ) { - - Standard_Boolean IsIn = Standard_False; - - if ( !myGOPtr->IsTransformed() ) - IsIn = aDrawer->IsIn( myMinX, myMaxX, myMinY, myMaxY ); - else { - Standard_ShortReal minx, miny, maxx, maxy; - MinMax( minx, maxx, miny, maxy ); - IsIn = aDrawer->IsIn( minx, maxx, miny, maxy ); - } - - if ( IsIn ) { - - DrawLineAttrib( aDrawer ); - Standard_ShortReal X1 = Standard_ShortReal( myX - myLength/2 ), - Y1 = Standard_ShortReal( myY - myLength/2 ), - X2 = Standard_ShortReal( myX + myLength/2 ), - Y2 = Y1, - X3 = Standard_ShortReal( X1 + myLength * Cos( M_PI / 4 ) ), - Y3 = Standard_ShortReal( myY + myLength/2 ); - - gp_Pnt2d P1( X1, Y1 ), - P2( X2, Y2 ), - P3( X3, Y3 ), - PR( myX, myY ); - P1.Rotate( PR, myAngle ); - P2.Rotate( PR, myAngle ); - P3.Rotate( PR, myAngle ); - - X1 = Standard_ShortReal( P1.X() ); - Y1 = Standard_ShortReal( P1.Y() ); - X2 = Standard_ShortReal( P2.X() ); - Y2 = Standard_ShortReal( P2.Y() ); - X3 = Standard_ShortReal( P3.X() ); - Y3 = Standard_ShortReal( P3.Y() ); - - if ( myGOPtr->IsTransformed () ) { - gp_GTrsf2d aTrsf = myGOPtr->Transform (); - Standard_Real a1, b1; - a1 = X1; - b1 = Y1; - aTrsf.Transforms( a1, b1 ); - X1 = Standard_ShortReal( a1 ); - Y1 = Standard_ShortReal( b1 ); - a1 = X2; - b1 = Y2; - aTrsf.Transforms( a1, b1 ); - X2 = Standard_ShortReal( a1 ); - Y2 = Standard_ShortReal( b1 ); - a1 = X3; - b1 = Y3; - aTrsf.Transforms( a1, b1 ); - X3 = Standard_ShortReal( a1 ); - Y3 = Standard_ShortReal( b1 ); - } - aDrawer->MapSegmentFromTo( X1, Y1, X2, Y2 ); - aDrawer->MapSegmentFromTo( X1, Y1, X3, Y3 ); - } -} - -void Prs2d_Angularity::Save(Aspect_FStream& aFStream) const -{ -} diff --git a/src/Prs2d/Prs2d_Arrow.cdl b/src/Prs2d/Prs2d_Arrow.cdl deleted file mode 100755 index 988b41d073..0000000000 --- a/src/Prs2d/Prs2d_Arrow.cdl +++ /dev/null @@ -1,102 +0,0 @@ --- Created by: Tanya COOL --- Copyright (c) 2000-2012 OPEN CASCADE SAS --- --- The content of this file is subject to the Open CASCADE Technology Public --- License Version 6.5 (the "License"). You may not use the content of this file --- except in compliance with the License. Please obtain a copy of the License --- at http://www.opencascade.org and read it completely before using this file. --- --- The Initial Developer of the Original Code is Open CASCADE S.A.S., having its --- main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. --- --- The Original Code and all software distributed under the License is --- distributed on an "AS IS" basis, without warranty of any kind, and the --- Initial Developer hereby disclaims all such warranties, including without --- limitation, any warranties of merchantability, fitness for a particular --- purpose or non-infringement. Please see the License for the specific terms --- and conditions governing the rights and limitations under the License. - - -class Arrow from Prs2d inherits Line from Graphic2d - - ---Purpose: Constructs the primitive arrow - -uses - - Drawer from Graphic2d, - GraphicObject from Graphic2d, - Length from Quantity, - Array1OfShortReal from TShort, - ExtendedString from TCollection, - Ax2d from gp, - TypeOfArrow from Prs2d, - FStream from Aspect, - HArray1OfPnt2d from TColgp - -is - Create( aGraphicObject: GraphicObject from Graphic2d; - Location : Ax2d from gp; - OpenAngle : Real from Standard = 5.0; - Length : Real from Standard = 5.0; - theType : TypeOfArrow from Prs2d = Prs2d_TOA_CLOSED ) - - returns mutable Arrow from Prs2d; - - ---Purpose: create an arrow: - -- "Location" gives the location and direction, - -- "OpenAngle" gives the opening angle (in radians), - -- "Length" gives the length. - - ---------------------------------- - ---Category: Draw and Pick - ---------------------------------- - - Draw( me : mutable; aDrawer: Drawer from Graphic2d ) - is static protected; - ---Level: Internal - ---Purpose: Draws the arrow . - - DrawElement( me : mutable; aDrawer: Drawer from Graphic2d; - anIndex: Integer from Standard) - is redefined protected; - ---Level: Internal - ---Purpose: Draws element of the arrow . - - DrawVertex( me : mutable; aDrawer: Drawer from Graphic2d; - anIndex: Integer from Standard) - is redefined protected; - ---Level: Internal - ---Purpose: Draws vertex of the arrow . - - ArrayOfPnt2d( me ; withTrsf: Boolean from Standard = Standard_False) returns HArray1OfPnt2d from TColgp; - ---Level: Public - ---C++: return const - - TypeOfArrow( me ) returns TypeOfArrow from Prs2d; - ---Level: Public - ---Purpose: Returns type of arrow - -- Type is: - -- TOA_OPENED, - -- TOA_CLOSED, - -- TOA_FILLED - - - Pick (me : mutable; X, Y: ShortReal from Standard; - aPrecision: ShortReal from Standard; - aDrawer: Drawer from Graphic2d) - returns Boolean from Standard - is static protected; - ---Level: Internal - ---Purpose: Returns Standard_True if the arrow is picked, - -- Standard_False if not. - - Save( me; aFStream: in out FStream from Aspect ) is virtual; - - -fields - - myXVert : Array1OfShortReal from TShort; - myYVert : Array1OfShortReal from TShort; - myTypeOfArrow : TypeOfArrow from Prs2d; - -end Arrow from Prs2d; diff --git a/src/Prs2d/Prs2d_Arrow.cxx b/src/Prs2d/Prs2d_Arrow.cxx deleted file mode 100755 index 49890aab89..0000000000 --- a/src/Prs2d/Prs2d_Arrow.cxx +++ /dev/null @@ -1,284 +0,0 @@ -// Copyright (c) 1999-2012 OPEN CASCADE SAS -// -// The content of this file is subject to the Open CASCADE Technology Public -// License Version 6.5 (the "License"). You may not use the content of this file -// except in compliance with the License. Please obtain a copy of the License -// at http://www.opencascade.org and read it completely before using this file. -// -// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its -// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. -// -// The Original Code and all software distributed under the License is -// distributed on an "AS IS" basis, without warranty of any kind, and the -// Initial Developer hereby disclaims all such warranties, including without -// limitation, any warranties of merchantability, fitness for a particular -// purpose or non-infringement. Please see the License for the specific terms -// and conditions governing the rights and limitations under the License. - -#include -#include - -#define VERTEXMARKER 2 -#define DEFAULTMARKERSIZE 3.0 - -Prs2d_Arrow::Prs2d_Arrow( const Handle(Graphic2d_GraphicObject)& aGraphicObject, - const gp_Ax2d & aLocation, - const Standard_Real anAngle, - const Standard_Real aLength, - const Prs2d_TypeOfArrow theType ) - - : Graphic2d_Line (aGraphicObject), - myXVert( 1, 3 ), - myYVert( 1, 3 ), - myTypeOfArrow( theType ) -{ - - gp_Pnt2d theOrigine(0.,0.); - gp_Pnt2d P1( aLocation.Location() ); - gp_Dir2d AxeX( 1., 0. ); - Standard_Real theAngle = AxeX.Angle( aLocation.Direction() ); - theAngle += M_PI; - gp_Pnt2d P2( aLength, aLength*Tan( anAngle/2. ) ); - gp_Pnt2d P3( aLength, -aLength*Tan( anAngle/2. ) ); - P2.Rotate( theOrigine, theAngle ); - P3.Rotate( theOrigine, theAngle ); - P2.Translate( gp_Vec2d( theOrigine, P1 ) ); - P3.Translate( gp_Vec2d( theOrigine, P1 ) ); - - myXVert(1) = Standard_ShortReal( P2.X() ); - myYVert(1) = Standard_ShortReal( P2.Y() ); - myXVert(2) = Standard_ShortReal( P1.X() ); - myYVert(2) = Standard_ShortReal( P1.Y() ); - myXVert(3) = Standard_ShortReal( P3.X() ); - myYVert(3) = Standard_ShortReal( P3.Y() ); - - for ( Standard_Integer i = 1; i <= 3; i++ ) { - - if ( myXVert(i) < myMinX ) myMinX = myXVert(i); - if ( myYVert(i) < myMinY ) myMinY = myYVert(i); - if ( myXVert(i) > myMaxX ) myMaxX = myXVert(i); - if ( myYVert(i) > myMaxY ) myMaxY = myYVert(i); - - } - -} - -void Prs2d_Arrow::Draw( const Handle(Graphic2d_Drawer)& aDrawer ) { - - Standard_Boolean IsIn = Standard_False; - - if ( !myGOPtr->IsTransformed() ) - IsIn = aDrawer->IsIn( myMinX, myMaxX, myMinY, myMaxY ); - else { - Standard_ShortReal minx, miny, maxx, maxy; - MinMax( minx, maxx, miny, maxy ); - gp_GTrsf2d aTrsf = myGOPtr->Transform(); - Standard_Real MINX, MINY, MAXX, MAXY; - MINX = Standard_Real( myMinX ); - MINY = Standard_Real( myMinY ); - MAXX = Standard_Real( myMaxX ); - MAXY = Standard_Real( myMaxY ); - aTrsf.Transforms( MINX, MINY ); - aTrsf.Transforms( MAXX, MAXY ); - minx = Standard_ShortReal( MINX ); - miny = Standard_ShortReal( MINY ); - maxx = Standard_ShortReal( MAXX ); - maxy = Standard_ShortReal( MAXY ); - IsIn = aDrawer->IsIn (minx,maxx,miny,maxy); - } - - if ( IsIn ) { - DrawLineAttrib(aDrawer); - TShort_Array1OfShortReal Xpoint( 1, 3 ); - TShort_Array1OfShortReal Ypoint( 1, 3 ); - - if ( myGOPtr->IsTransformed () ) { - gp_GTrsf2d aTrsf = myGOPtr->Transform (); - Standard_Real a, b; - for ( Standard_Integer j = 1; j <= 3; j++ ) { - a = Standard_Real( myXVert(j) ); - b = Standard_Real( myYVert(j) ); - aTrsf.Transforms (a, b); - Xpoint(j) = Standard_ShortReal (a); - Ypoint(j) = Standard_ShortReal (b); - } - - } - else { - Xpoint.Assign( myXVert ); - Ypoint.Assign( myYVert ); - - } - - if( myTypeOfArrow == Prs2d_TOA_CLOSED || - myTypeOfArrow == Prs2d_TOA_FILLED ) - aDrawer->MapPolygonFromTo( Xpoint, Ypoint); - else - aDrawer->MapPolylineFromTo(Xpoint, Ypoint); - - } - -} - -void Prs2d_Arrow::DrawElement( const Handle(Graphic2d_Drawer)& aDrawer, - const Standard_Integer anIndex) { - - Standard_Boolean IsIn = Standard_False; - - if ( ! myGOPtr->IsTransformed () ) - IsIn = aDrawer->IsIn( myMinX, myMaxX, myMinY, myMaxY ); - else { - Standard_ShortReal minx, miny, maxx, maxy; - MinMax( minx, maxx, miny, maxy ); - IsIn = aDrawer->IsIn( minx, maxx, miny, maxy ); - } - - Standard_Integer nbpoints = myXVert.Length(); - if ( IsIn ) { - if( anIndex > 0 ) { - Standard_ShortReal X1 = myXVert(anIndex) , Y1 = myYVert(anIndex), - X2, Y2; - if ( anIndex < nbpoints ) { - X2 = myXVert(anIndex + 1); - Y2 = myYVert(anIndex + 1); - } else if ( anIndex == nbpoints ) { - X2 = myXVert(myXVert.Lower()); - Y2 = myYVert(myXVert.Lower()); - } else return; - DrawLineAttrib( aDrawer ); - if ( myGOPtr->IsTransformed() ) { - gp_GTrsf2d aTrsf = myGOPtr->Transform(); - Standard_Real A, B; - A = Standard_Real( X1 ); - B = Standard_Real( Y1 ); - aTrsf.Transforms( A, B ); - X1 = Standard_ShortReal( A ); - Y1 = Standard_ShortReal( B ); - A = Standard_Real( X2 ); - B = Standard_Real( Y2 ); - aTrsf.Transforms( A, B ); - X2 = Standard_ShortReal( A ); - Y2 = Standard_ShortReal( B ); - } // end if is transformed - aDrawer->MapSegmentFromTo( X1, Y1, X2, Y2 ); - } - } // end if is in - -} - -void Prs2d_Arrow::DrawVertex( const Handle(Graphic2d_Drawer)& aDrawer, - const Standard_Integer anIndex ) { - - Standard_Boolean IsIn = Standard_False; - - if ( ! myGOPtr->IsTransformed() ) - IsIn = aDrawer->IsIn( myMinX, myMaxX, myMinY, myMaxY ); - else { - Standard_ShortReal minx, miny, maxx, maxy; - MinMax( minx, maxx, miny, maxy ); - IsIn = aDrawer->IsIn( minx, maxx, miny, maxy ); - } - - Standard_Integer nbpoints = myXVert.Length(); - if ( IsIn ) { - if ( anIndex > 0 && anIndex <= nbpoints ) { - Standard_ShortReal X,Y; - DrawMarkerAttrib( aDrawer ); - if ( myGOPtr->IsTransformed() ) { - gp_GTrsf2d aTrsf = myGOPtr->Transform (); - Standard_Real A, B; - A = Standard_Real( myXVert(anIndex) ); - B = Standard_Real( myYVert(anIndex) ); - aTrsf.Transforms( A, B ); - X = Standard_ShortReal( A ); - Y = Standard_ShortReal( B ); - } else { - X = Standard_ShortReal( myXVert(anIndex) ); - Y = Standard_ShortReal( myYVert(anIndex) ); - } - aDrawer->MapMarkerFromTo( VERTEXMARKER, X, Y, - DEFAULTMARKERSIZE, DEFAULTMARKERSIZE, 0.0); - } - } - -} - -Standard_Boolean Prs2d_Arrow::Pick( const Standard_ShortReal X, - const Standard_ShortReal Y, - const Standard_ShortReal aPrecision, - const Handle(Graphic2d_Drawer)& /*aDrawer*/ ) { - - Standard_ShortReal SRX = X, SRY = Y; - Standard_Integer i, theLow = myXVert.Lower(), theUp = myXVert.Upper();; - - if ( IsInMinMax( X, Y, aPrecision ) ) { - if ( myGOPtr->IsTransformed() ) { - gp_GTrsf2d aTrsf = ( myGOPtr->Transform() ).Inverted(); - Standard_Real RX = Standard_Real( SRX ), - RY = Standard_Real( SRY ); - aTrsf.Transforms( RX, RY ); - SRX = Standard_ShortReal( RX ); - SRY = Standard_ShortReal( RY ); - } - - - for ( i = theLow; i <= theUp; i++ ) { - if ( Graphic2d_Primitive::IsOn( SRX, SRY, myXVert(i), myYVert(i), aPrecision) ) { - SetPickedIndex(-i); - return Standard_True; - } else if ( (i < theUp) && IsOn( SRX, SRY, myXVert(i), myYVert(i), - myXVert(i+1), myYVert(i+1), aPrecision ) ) { - SetPickedIndex(i); - return Standard_True; - } - } - - if ( myTypeOfArrow == Prs2d_TOA_CLOSED || - myTypeOfArrow == Prs2d_TOA_FILLED ) - if ( IsOn( SRX, SRY, myXVert(theUp), myYVert(theUp), - myXVert(theLow), myYVert(theLow), aPrecision ) ) { - SetPickedIndex( theUp ); - return Standard_True; - } - - if ( IsIn( SRX, SRY, myXVert, myYVert, aPrecision ) ) { - SetPickedIndex(0); - return Standard_True; - } - - return Standard_False; - - } else - return Standard_False; - -} - -void Prs2d_Arrow::Save(Aspect_FStream& aFStream) const -{ -} - -Prs2d_TypeOfArrow Prs2d_Arrow::TypeOfArrow( ) const -{ - return myTypeOfArrow; -} - -const Handle(TColgp_HArray1OfPnt2d) Prs2d_Arrow::ArrayOfPnt2d( const Standard_Boolean withTrsf ) const -{ - Handle(TColgp_HArray1OfPnt2d) point = new TColgp_HArray1OfPnt2d( 1, 3 ); - - Standard_Boolean isTrsf = ( myGOPtr->IsTransformed() && withTrsf ); - gp_GTrsf2d aTrsf = myGOPtr->Transform(); - Standard_Real a, b; - for ( Standard_Integer j = 1; j <= 3; j++ ) { - if( isTrsf ) - { - a = Standard_Real( myXVert(j) ); - b = Standard_Real( myYVert(j) ); - aTrsf.Transforms (a, b); - point->SetValue( j, gp_Pnt2d(a, b) ); - } - else - point->SetValue( j, gp_Pnt2d( myXVert(j), myYVert(j) ) ); - } - return point; -} diff --git a/src/Prs2d/Prs2d_AspectFramedText.cdl b/src/Prs2d/Prs2d_AspectFramedText.cdl deleted file mode 100755 index e4d06138f9..0000000000 --- a/src/Prs2d/Prs2d_AspectFramedText.cdl +++ /dev/null @@ -1,70 +0,0 @@ --- Created by: Tanya COOL --- Copyright (c) 2000-2012 OPEN CASCADE SAS --- --- The content of this file is subject to the Open CASCADE Technology Public --- License Version 6.5 (the "License"). You may not use the content of this file --- except in compliance with the License. Please obtain a copy of the License --- at http://www.opencascade.org and read it completely before using this file. --- --- The Initial Developer of the Original Code is Open CASCADE S.A.S., having its --- main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. --- --- The Original Code and all software distributed under the License is --- distributed on an "AS IS" basis, without warranty of any kind, and the --- Initial Developer hereby disclaims all such warranties, including without --- limitation, any warranties of merchantability, fitness for a particular --- purpose or non-infringement. Please see the License for the specific terms --- and conditions governing the rights and limitations under the License. - - -class AspectFramedText from Prs2d inherits AspectRoot from Prs2d - ----Purpose: defines the attributes when drawing a framed text Presentation. - -uses - - NameOfColor from Quantity, - WidthOfLine from Aspect, - TypeOfFont from Aspect - -is - - Create( ColorInd: NameOfColor from Quantity; - FrameColorInd: NameOfColor from Quantity; - FrameWidthInd: WidthOfLine from Aspect; - FontInd: TypeOfFont from Aspect; - aSlant: ShortReal from Standard; - aHScale,aWScale: ShortReal from Standard; - isUnderlined: Boolean from Standard ) - returns mutable AspectFramedText from Prs2d; - - SetColorOfText( me: mutable; aColor: NameOfColor from Quantity); - SetFrameColor ( me: mutable; aFrameColor: NameOfColor from Quantity); - SetFrameWidth ( me: mutable; aFrameWidth: WidthOfLine from Aspect); - SetFontOfText ( me: mutable; aFont: TypeOfFont from Aspect); - SetSlant ( me: mutable; aSlant: ShortReal from Standard); - SetHScale ( me: mutable; aHScale: ShortReal from Standard); - SetWScale ( me: mutable; aWScale: ShortReal from Standard); - SetUnderlined ( me: mutable; anIsUnderlined:Boolean from Standard); - - Values( me; - aColorInd: out NameOfColor from Quantity; - aFrameColorInd: out NameOfColor from Quantity; - aFrameWidthInd: out WidthOfLine from Aspect; - aFontInd: out TypeOfFont from Aspect; - aSlant: out ShortReal from Standard; - aHScale,aWScale: out ShortReal from Standard; - isUnderlined: out Boolean from Standard ); - -fields - - myColor : NameOfColor from Quantity; - myFrameColor : NameOfColor from Quantity; - myFont : TypeOfFont from Aspect; - myFrameWidth : WidthOfLine from Aspect; - mySlant : ShortReal from Standard; - myHScale : ShortReal from Standard; - myWScale : ShortReal from Standard; - myIsUnderlined : Boolean from Standard; - -end AspectFramedText from Prs2d; diff --git a/src/Prs2d/Prs2d_AspectFramedText.cxx b/src/Prs2d/Prs2d_AspectFramedText.cxx deleted file mode 100755 index e703eec7e0..0000000000 --- a/src/Prs2d/Prs2d_AspectFramedText.cxx +++ /dev/null @@ -1,104 +0,0 @@ -// Copyright (c) 1999-2012 OPEN CASCADE SAS -// -// The content of this file is subject to the Open CASCADE Technology Public -// License Version 6.5 (the "License"). You may not use the content of this file -// except in compliance with the License. Please obtain a copy of the License -// at http://www.opencascade.org and read it completely before using this file. -// -// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its -// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. -// -// The Original Code and all software distributed under the License is -// distributed on an "AS IS" basis, without warranty of any kind, and the -// Initial Developer hereby disclaims all such warranties, including without -// limitation, any warranties of merchantability, fitness for a particular -// purpose or non-infringement. Please see the License for the specific terms -// and conditions governing the rights and limitations under the License. - -#include - -Prs2d_AspectFramedText::Prs2d_AspectFramedText - ( const Quantity_NameOfColor ColorInd, - const Quantity_NameOfColor FrameColorInd, - const Aspect_WidthOfLine FrameWidthInd, - const Aspect_TypeOfFont FontInd, - const Standard_ShortReal aSlant, - const Standard_ShortReal aHScale, - const Standard_ShortReal aWScale, - const Standard_Boolean isUnderlined ): - - Prs2d_AspectRoot( Prs2d_AN_FRAMEDTEXT ), - myColor( ColorInd ), - myFrameColor( FrameColorInd ), - myFont( FontInd ), - myFrameWidth( FrameWidthInd ), - mySlant( aSlant ), - myHScale( aHScale ), - myWScale( aWScale ), - myIsUnderlined( isUnderlined ) { - - } - - void Prs2d_AspectFramedText::SetColorOfText(const Quantity_NameOfColor aColor) { - - myColor = aColor; - - } - - void Prs2d_AspectFramedText::SetFontOfText(const Aspect_TypeOfFont aFont) { - - myFont = aFont; - - } - - void Prs2d_AspectFramedText::SetSlant(const Standard_ShortReal aSlant) { - - mySlant = aSlant; - } - - void Prs2d_AspectFramedText::SetHScale(const Standard_ShortReal aHScale) { - - myHScale = aHScale; - } - - void Prs2d_AspectFramedText::SetWScale(const Standard_ShortReal aWScale) { - - myWScale = aWScale; - } - - void Prs2d_AspectFramedText::SetUnderlined(const Standard_Boolean anIsUnderlined) { - - myIsUnderlined = anIsUnderlined; - } - - void Prs2d_AspectFramedText::SetFrameColor(const Quantity_NameOfColor aFrameColor) { - - myFrameColor = aFrameColor; - } - - void Prs2d_AspectFramedText::SetFrameWidth(const Aspect_WidthOfLine aFrameWidth) { - - myFrameWidth = aFrameWidth; - - } - - void Prs2d_AspectFramedText::Values(Quantity_NameOfColor& aColorInd, - Quantity_NameOfColor& aFrameColorInd, - Aspect_WidthOfLine& aFrameWidthInd, - Aspect_TypeOfFont& aFontInd, - Standard_ShortReal& aSlant, - Standard_ShortReal& aHScale, - Standard_ShortReal& aWScale, - Standard_Boolean& isUnderlined) const { - - aFontInd = myFont; - aColorInd = myColor; - aSlant = mySlant; - aHScale = myHScale; - aWScale = myWScale; - isUnderlined = myIsUnderlined; - aFrameWidthInd = myFrameWidth; - aFrameColorInd = myFrameColor; - - - } diff --git a/src/Prs2d/Prs2d_AspectHidingPoly.cdl b/src/Prs2d/Prs2d_AspectHidingPoly.cdl deleted file mode 100755 index e4fcfdae37..0000000000 --- a/src/Prs2d/Prs2d_AspectHidingPoly.cdl +++ /dev/null @@ -1,56 +0,0 @@ --- Created by: Tanya COOL --- Copyright (c) 2000-2012 OPEN CASCADE SAS --- --- The content of this file is subject to the Open CASCADE Technology Public --- License Version 6.5 (the "License"). You may not use the content of this file --- except in compliance with the License. Please obtain a copy of the License --- at http://www.opencascade.org and read it completely before using this file. --- --- The Initial Developer of the Original Code is Open CASCADE S.A.S., having its --- main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. --- --- The Original Code and all software distributed under the License is --- distributed on an "AS IS" basis, without warranty of any kind, and the --- Initial Developer hereby disclaims all such warranties, including without --- limitation, any warranties of merchantability, fitness for a particular --- purpose or non-infringement. Please see the License for the specific terms --- and conditions governing the rights and limitations under the License. - - -class AspectHidingPoly from Prs2d inherits AspectRoot from Prs2d - - ---Purpose: defines the attributes when drawing a hiding - -- polyhedral simplification Presentation. -uses - - NameOfColor from Quantity, - TypeOfLine from Aspect, - WidthOfLine from Aspect - -is - - Create ( HidingColorInd: NameOfColor from Quantity; - FrameColorInd: NameOfColor from Quantity; - FrameTypeInd: TypeOfLine from Aspect; - FrameWidthInd: WidthOfLine from Aspect) - returns mutable AspectHidingPoly from Prs2d; - - SetHidingColor (me: mutable; aColorInd: NameOfColor from Quantity ) is static; - SetFrameColor (me: mutable; aFrameColorInd: NameOfColor from Quantity ) is static; - SetFrameType (me: mutable; aFrameTypeInd: TypeOfLine from Aspect) is static; - SetFrameWidth (me: mutable; aFrameWidthInd: WidthOfLine from Aspect ) is static; - - Values( me; - HidingColorInd: out NameOfColor from Quantity; - FrameColorInd: out NameOfColor from Quantity; - FrameTypeInd: out TypeOfLine from Aspect; - FrameWidthInd: out WidthOfLine from Aspect ); - - fields - - myHidingColorInd: NameOfColor from Quantity; - myFrameColorInd: NameOfColor from Quantity; - myFrameTypeInd: TypeOfLine from Aspect; - myFrameWidthInd: WidthOfLine from Aspect; - -end AspectHidingPoly from Prs2d; diff --git a/src/Prs2d/Prs2d_AspectHidingPoly.cxx b/src/Prs2d/Prs2d_AspectHidingPoly.cxx deleted file mode 100755 index a778e32cc7..0000000000 --- a/src/Prs2d/Prs2d_AspectHidingPoly.cxx +++ /dev/null @@ -1,63 +0,0 @@ -// Copyright (c) 1999-2012 OPEN CASCADE SAS -// -// The content of this file is subject to the Open CASCADE Technology Public -// License Version 6.5 (the "License"). You may not use the content of this file -// except in compliance with the License. Please obtain a copy of the License -// at http://www.opencascade.org and read it completely before using this file. -// -// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its -// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. -// -// The Original Code and all software distributed under the License is -// distributed on an "AS IS" basis, without warranty of any kind, and the -// Initial Developer hereby disclaims all such warranties, including without -// limitation, any warranties of merchantability, fitness for a particular -// purpose or non-infringement. Please see the License for the specific terms -// and conditions governing the rights and limitations under the License. - -#include - -Prs2d_AspectHidingPoly::Prs2d_AspectHidingPoly - ( const Quantity_NameOfColor HidingColorInd, - const Quantity_NameOfColor FrameColorInd, - const Aspect_TypeOfLine FrameTypeInd, - const Aspect_WidthOfLine FrameWidthInd ): - - Prs2d_AspectRoot( Prs2d_AN_HIDINGPOLY ), - myHidingColorInd( HidingColorInd ), - myFrameColorInd( FrameColorInd ), - myFrameTypeInd( FrameTypeInd ), - myFrameWidthInd( FrameWidthInd ) { -} - - void Prs2d_AspectHidingPoly::SetHidingColor( const Quantity_NameOfColor aColorInd ) { - - myHidingColorInd = aColorInd; - } - - void Prs2d_AspectHidingPoly::SetFrameColor( const Quantity_NameOfColor aFrameColorInd ) { - - myFrameColorInd = aFrameColorInd; - } - - void Prs2d_AspectHidingPoly::SetFrameType( const Aspect_TypeOfLine aFrameTypeInd ) { - - myFrameTypeInd = aFrameTypeInd; - } - - void Prs2d_AspectHidingPoly::SetFrameWidth( const Aspect_WidthOfLine aFrameWidthInd ) { - - myFrameWidthInd = aFrameWidthInd; - } - - void Prs2d_AspectHidingPoly::Values( Quantity_NameOfColor& HidingColorInd, - Quantity_NameOfColor& FrameColorInd, - Aspect_TypeOfLine & FrameTypeInd, - Aspect_WidthOfLine & FrameWidthInd ) const { - HidingColorInd = myHidingColorInd; - FrameColorInd = myFrameColorInd; - FrameTypeInd = myFrameTypeInd; - FrameWidthInd = myFrameWidthInd; - } - - diff --git a/src/Prs2d/Prs2d_AspectHidingText.cdl b/src/Prs2d/Prs2d_AspectHidingText.cdl deleted file mode 100755 index fa7d05d98a..0000000000 --- a/src/Prs2d/Prs2d_AspectHidingText.cdl +++ /dev/null @@ -1,77 +0,0 @@ --- Created by: Tanya COOL --- Copyright (c) 2000-2012 OPEN CASCADE SAS --- --- The content of this file is subject to the Open CASCADE Technology Public --- License Version 6.5 (the "License"). You may not use the content of this file --- except in compliance with the License. Please obtain a copy of the License --- at http://www.opencascade.org and read it completely before using this file. --- --- The Initial Developer of the Original Code is Open CASCADE S.A.S., having its --- main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. --- --- The Original Code and all software distributed under the License is --- distributed on an "AS IS" basis, without warranty of any kind, and the --- Initial Developer hereby disclaims all such warranties, including without --- limitation, any warranties of merchantability, fitness for a particular --- purpose or non-infringement. Please see the License for the specific terms --- and conditions governing the rights and limitations under the License. - - -class AspectHidingText from Prs2d inherits AspectRoot from Prs2d - - ---Purpose: defines the attributes when drawing a hiding text - -uses - - NameOfColor from Quantity, - TypeOfFont from Aspect, - WidthOfLine from Aspect - - -is - - Create ( ColorInd: NameOfColor from Quantity; - HidingColorInd: NameOfColor from Quantity; - FrameColorInd: NameOfColor from Quantity; - FrameWidthInd: WidthOfLine from Aspect; - FontInd: TypeOfFont from Aspect; - aSlantInd: ShortReal from Standard; - aHScaleInd: ShortReal from Standard; - aWScaleInd: ShortReal from Standard; - isUnderlined: Boolean from Standard) - returns mutable AspectHidingText from Prs2d; - - SetColorOfText ( me: mutable; aColorInd: NameOfColor from Quantity); - SetHidingColorOfText( me: mutable; aHidColorInd: NameOfColor from Quantity); - SetFrameColorOfText ( me: mutable; aFrameColorInd: NameOfColor from Quantity); - SetFrameWidthOfText ( me: mutable; aFrameWidthInd: WidthOfLine from Aspect); - SetFontOfText ( me: mutable; aFontInd: TypeOfFont from Aspect); - SetSlant ( me: mutable; aSlantInd: ShortReal from Standard); - SetHScale ( me: mutable; aHScaleInd: ShortReal from Standard); - SetWScale ( me: mutable; aWScaleInd: ShortReal from Standard); - SetUnderlined ( me: mutable; anIsUnderline: Boolean from Standard); - - Values( me; - ColorInd: out NameOfColor from Quantity; - HidingColorInd: out NameOfColor from Quantity; - FrameColorInd: out NameOfColor from Quantity; - FrameWidthInd: out WidthOfLine from Aspect; - FontInd: out TypeOfFont from Aspect; - aSlantInd: out ShortReal from Standard; - aHScaleInd: out ShortReal from Standard; - aWScaleInd: out ShortReal from Standard; - isUnderlined: out Boolean from Standard ); - -fields - - myFontInd : TypeOfFont from Aspect; - myColorInd : NameOfColor from Quantity; - HidingColorInd : NameOfColor from Quantity; - FrameColorInd : NameOfColor from Quantity; - FrameWidthInd : WidthOfLine from Aspect; - mySlantInd : ShortReal from Standard; - myHScaleInd : ShortReal from Standard; - myWScaleInd : ShortReal from Standard; - myIsUnderlined : Boolean from Standard; - -end AspectHidingText from Prs2d; diff --git a/src/Prs2d/Prs2d_AspectHidingText.cxx b/src/Prs2d/Prs2d_AspectHidingText.cxx deleted file mode 100755 index 9edf80ad13..0000000000 --- a/src/Prs2d/Prs2d_AspectHidingText.cxx +++ /dev/null @@ -1,106 +0,0 @@ -// Copyright (c) 1999-2012 OPEN CASCADE SAS -// -// The content of this file is subject to the Open CASCADE Technology Public -// License Version 6.5 (the "License"). You may not use the content of this file -// except in compliance with the License. Please obtain a copy of the License -// at http://www.opencascade.org and read it completely before using this file. -// -// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its -// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. -// -// The Original Code and all software distributed under the License is -// distributed on an "AS IS" basis, without warranty of any kind, and the -// Initial Developer hereby disclaims all such warranties, including without -// limitation, any warranties of merchantability, fitness for a particular -// purpose or non-infringement. Please see the License for the specific terms -// and conditions governing the rights and limitations under the License. - -#include - -Prs2d_AspectHidingText::Prs2d_AspectHidingText - ( const Quantity_NameOfColor ColorInd, - const Quantity_NameOfColor HidingColorInd, - const Quantity_NameOfColor FrameColorInd, - const Aspect_WidthOfLine FrameWidthInd, - const Aspect_TypeOfFont FontInd, - const Standard_ShortReal aSlantInd, - const Standard_ShortReal aHScaleInd, - const Standard_ShortReal aWScaleInd, - const Standard_Boolean isUnderlined ): - Prs2d_AspectRoot( Prs2d_AN_HIDINGTEXT ), - myFontInd( FontInd ), - myColorInd( ColorInd ), - HidingColorInd( HidingColorInd ), - FrameColorInd( FrameColorInd ), - FrameWidthInd( FrameWidthInd ), - mySlantInd( aSlantInd ), - myHScaleInd( aHScaleInd ), - myWScaleInd( aWScaleInd ), - myIsUnderlined( isUnderlined ) -{ -} - - void Prs2d_AspectHidingText::SetColorOfText(const Quantity_NameOfColor aColorInd) { - - myColorInd = aColorInd; - } - - void Prs2d_AspectHidingText::SetFontOfText(const Aspect_TypeOfFont aFontInd) { - - myFontInd = aFontInd; - } - - void Prs2d_AspectHidingText::SetSlant(const Standard_ShortReal aSlantInd) { - - mySlantInd = aSlantInd; - } - - void Prs2d_AspectHidingText::SetHScale(const Standard_ShortReal aHScaleInd) { - - myHScaleInd = aHScaleInd; - } - - void Prs2d_AspectHidingText::SetWScale(const Standard_ShortReal aWScaleInd) { - - myWScaleInd = aWScaleInd; - } - - void Prs2d_AspectHidingText::SetUnderlined(const Standard_Boolean anIsUnderline) { - - myIsUnderlined = anIsUnderline; - } - - void Prs2d_AspectHidingText::SetHidingColorOfText(const Quantity_NameOfColor aHidColorInd) { - - HidingColorInd = aHidColorInd; -} - - void Prs2d_AspectHidingText::SetFrameColorOfText(const Quantity_NameOfColor aFrameColorInd) { - - FrameColorInd = aFrameColorInd; - } - - void Prs2d_AspectHidingText::SetFrameWidthOfText(const Aspect_WidthOfLine aFrameWidthInd) { - - FrameWidthInd = aFrameWidthInd; - } - - void Prs2d_AspectHidingText::Values(Quantity_NameOfColor& ColorInd, - Quantity_NameOfColor& HidingColorInd, - Quantity_NameOfColor& FrameColorInd, - Aspect_WidthOfLine& FrameWidthInd, - Aspect_TypeOfFont& FontInd, - Standard_ShortReal& aSlantInd, - Standard_ShortReal& aHScaleInd, - Standard_ShortReal& aWScaleInd, - Standard_Boolean& isUnderlined) const{ - FontInd = myFontInd; - ColorInd = myColorInd; - aSlantInd = mySlantInd; - aHScaleInd = myHScaleInd; - aWScaleInd = myWScaleInd; - isUnderlined = myIsUnderlined; - HidingColorInd = HidingColorInd; - FrameColorInd = FrameColorInd; - FrameWidthInd = FrameWidthInd; - } diff --git a/src/Prs2d/Prs2d_AspectLine.cdl b/src/Prs2d/Prs2d_AspectLine.cdl deleted file mode 100755 index d2eaefdf8e..0000000000 --- a/src/Prs2d/Prs2d_AspectLine.cdl +++ /dev/null @@ -1,159 +0,0 @@ --- Created by: Tanya COOL --- Copyright (c) 2000-2012 OPEN CASCADE SAS --- --- The content of this file is subject to the Open CASCADE Technology Public --- License Version 6.5 (the "License"). You may not use the content of this file --- except in compliance with the License. Please obtain a copy of the License --- at http://www.opencascade.org and read it completely before using this file. --- --- The Initial Developer of the Original Code is Open CASCADE S.A.S., having its --- main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. --- --- The Original Code and all software distributed under the License is --- distributed on an "AS IS" basis, without warranty of any kind, and the --- Initial Developer hereby disclaims all such warranties, including without --- limitation, any warranties of merchantability, fitness for a particular --- purpose or non-infringement. Please see the License for the specific terms --- and conditions governing the rights and limitations under the License. - - -class AspectLine from Prs2d inherits AspectRoot from Prs2d - - ---Purpose: defines the attributes when drawing a line presentation - -uses - - Color from Quantity, - NameOfColor from Quantity, - TypeOfLine from Aspect, - WidthOfLine from Aspect, - TypeOfPolygonFilling from Graphic2d - -is - - Create returns mutable AspectLine from Prs2d; - ---Purpose: default constructor - - Create( aColor : NameOfColor from Quantity; - aType : TypeOfLine from Aspect; - aWidth : WidthOfLine from Aspect; - aInterColor : NameOfColor from Quantity = Quantity_NOC_YELLOW; - aTypeFill : TypeOfPolygonFilling from Graphic2d = Graphic2d_TOPF_EMPTY; - aTiled : Integer from Standard = 0; - aDrawEdge : Boolean from Standard = Standard_True ) - returns mutable AspectLine from Prs2d; - ---Purpose: Initializes the AspectLine defined values - - Create( aColor : Color from Quantity; - aType : TypeOfLine from Aspect; - aWidth : WidthOfLine from Aspect; - aInterColor : Color from Quantity; - aTypeFill : TypeOfPolygonFilling from Graphic2d = Graphic2d_TOPF_EMPTY; - aTileInd : Integer from Standard = 0; - aDrawEdge : Boolean from Standard = Standard_True) - returns mutable AspectLine from Prs2d; - ---Purpose: Initializes the AspectLine defined values - - --------------------------------------------------------------------- - ---Category: Modifications of the class properties - - SetColor( me: mutable; aColor: NameOfColor from Quantity ); - ---Level: Public - ---Purpose: Modifies the Aspect by redefining a color - - SetColor( me: mutable; aColor: Color from Quantity ); - ---Level: Public - ---Purpose: Modifies the Aspect by redefining a color - - SetType( me: mutable; aType: TypeOfLine from Aspect ); - ---Level: Public - ---Purpose: Modifies the Aspect by redefining a type of line - - SetWidth( me: mutable; aWidth: WidthOfLine from Aspect ); - ---Level: Public - ---Purpose: Modifies the Aspect by redefining a width of line - - SetInterColor( me: mutable; aColor: NameOfColor from Quantity ); - ---Level: Public - ---Purpose: Modifies the Aspect by redefining a interior color - - SetInterColor( me: mutable; aColor: Color from Quantity ); - ---Level: Public - ---Purpose: Modifies the Aspect by redefining a interior color - - SetTypeOfFill( me: mutable; aType: TypeOfPolygonFilling from Graphic2d ); - ---Level: Public - ---Purpose: Modifies the Aspect Polygon by redefining its type of polygon filling - - SetTile( me: mutable; aTile: Integer from Standard); - ---Level: Public - ---Purpose: Sets the tile of the Aspect Polygon - - SetDrawEdge( me: mutable; aDrawEdge: Boolean from Standard); - ---Level: Public - ---Purpose: Sets the flag - - - ValuesOfLine( me; - aColor: out Color from Quantity; - aType: out TypeOfLine from Aspect; - aWidth: out WidthOfLine from Aspect); - ---Level: Public - ---Purpose: Return the current values of this line - - ValuesOfPoly( me; - aColor : out Color from Quantity; - aTypeFill: out TypeOfPolygonFilling from Graphic2d; - aTile : out Integer from Standard; - aDrawEdge: out Boolean from Standard ); - ---Level: Public - ---Purpose: Returns the current values of this closed line - - ColorIndex( me ) returns Integer from Standard; - ---Level: Internal - ---Purpose: Returns current color index according to the color aspect - - TypeIndex( me ) returns Integer from Standard; - ---Level: Internal - ---Purpose: Returns current type index according to the type aspect - - WidthIndex( me ) returns Integer from Standard; - ---Level: Internal - ---Purpose: Returns current width index according to the width aspect - - InterColorIndex( me ) returns Integer from Standard; - ---Level: Internal - ---Purpose: Returns current color index according to the color aspect - - SetColorIndex( me: mutable; anInd: Integer from Standard ); - ---Level: Internal - ---Purpose: Sets current color index according to the color aspect - - SetTypeIndex( me: mutable; anInd: Integer from Standard ); - ---Level: Internal - ---Purpose: Sets current type index according to the type aspect - - SetWidthIndex( me: mutable; anInd: Integer from Standard ); - ---Level: Internal - ---Purpose: Sets current width index according to the width aspect - - SetIntColorInd( me: mutable; anInd: Integer from Standard ); - ---Level: Internal - ---Purpose: Sets current color index according to the color aspect - -fields - - myColor : Color from Quantity; - myType : TypeOfLine from Aspect; - myWidth : WidthOfLine from Aspect; - myInterColor : Color from Quantity; - myFillType : TypeOfPolygonFilling from Graphic2d; - myTile : Integer from Standard; - myDrawEdge : Boolean from Standard; - - myColorIndex : Integer from Standard; - myTypeIndex : Integer from Standard; - myWidthIndex : Integer from Standard; - myIntColorInd : Integer from Standard; - -end AspectLine from Prs2d; diff --git a/src/Prs2d/Prs2d_AspectLine.cxx b/src/Prs2d/Prs2d_AspectLine.cxx deleted file mode 100755 index 5c9a7e2b37..0000000000 --- a/src/Prs2d/Prs2d_AspectLine.cxx +++ /dev/null @@ -1,204 +0,0 @@ -// Copyright (c) 1999-2012 OPEN CASCADE SAS -// -// The content of this file is subject to the Open CASCADE Technology Public -// License Version 6.5 (the "License"). You may not use the content of this file -// except in compliance with the License. Please obtain a copy of the License -// at http://www.opencascade.org and read it completely before using this file. -// -// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its -// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. -// -// The Original Code and all software distributed under the License is -// distributed on an "AS IS" basis, without warranty of any kind, and the -// Initial Developer hereby disclaims all such warranties, including without -// limitation, any warranties of merchantability, fitness for a particular -// purpose or non-infringement. Please see the License for the specific terms -// and conditions governing the rights and limitations under the License. - -#include -#include -#include -#include -#include - -Prs2d_AspectLine::Prs2d_AspectLine() - : - Prs2d_AspectRoot( Prs2d_AN_LINE ), - - myColor( Quantity_Color(Quantity_NOC_YELLOW) ), - myType( Aspect_TOL_SOLID ), - myWidth( Aspect_WOL_THIN ), - myInterColor( Quantity_Color(Quantity_NOC_YELLOW) ), - myFillType( Graphic2d_TOPF_EMPTY ), - myTile( 0 ), - myDrawEdge( Standard_True ), - myColorIndex( 0 ), - myTypeIndex( 0 ), - myWidthIndex( 0 ), - myIntColorInd( 0 ) - -{ -} - -Prs2d_AspectLine::Prs2d_AspectLine( - const Quantity_NameOfColor aColor, - const Aspect_TypeOfLine aType, - const Aspect_WidthOfLine aWidth, - const Quantity_NameOfColor aIntColor, - const Graphic2d_TypeOfPolygonFilling aTypeFill, - const Standard_Integer aTile, - const Standard_Boolean aDrawEdge ) - : - Prs2d_AspectRoot( Prs2d_AN_LINE ), - - myColor( Quantity_Color(aColor) ), - myType( aType ), - myWidth( aWidth ), - myInterColor( Quantity_Color(aIntColor) ), - myFillType( aTypeFill ), - myTile( aTile ), - myDrawEdge( aDrawEdge ), - myColorIndex( 0 ), - myTypeIndex( 0 ), - myWidthIndex( 0 ), - myIntColorInd( 0 ) -{ -} - -Prs2d_AspectLine::Prs2d_AspectLine( - const Quantity_Color& aColor, - const Aspect_TypeOfLine aType, - const Aspect_WidthOfLine aWidth, - const Quantity_Color& aIntColor, - const Graphic2d_TypeOfPolygonFilling aTypeFill, - const Standard_Integer aTile, - const Standard_Boolean aDrawEdge ) - : - Prs2d_AspectRoot( Prs2d_AN_LINE ), - - myColor( aColor ), - myType( aType ), - myWidth( aWidth ), - myInterColor( aIntColor ), - myFillType( aTypeFill ), - myTile( aTile ), - myDrawEdge( aDrawEdge ), - myColorIndex(0), - myTypeIndex(0), - myWidthIndex(0), - myIntColorInd( 0 ) -{ -} - -void Prs2d_AspectLine::SetColor(const Quantity_NameOfColor aColor) { - - SetColor( Quantity_Color(aColor) ); -} - -void Prs2d_AspectLine::SetColor(const Quantity_Color& aColor) { - - if ( myColor != aColor ) { - myColor = aColor; - myColorIndex = 0; - } -} - -void Prs2d_AspectLine::SetType(const Aspect_TypeOfLine aType) { - - if ( myType != aType ) { - myType = aType; - myTypeIndex = 0; - } -} - -void Prs2d_AspectLine::SetWidth(const Aspect_WidthOfLine aWidth) { - - if ( myWidth != aWidth ) { - myWidth = aWidth; - myWidthIndex = 0; - } -} - -void Prs2d_AspectLine::SetInterColor(const Quantity_NameOfColor aColor) { - - SetInterColor( Quantity_Color(aColor) ); -} - -void Prs2d_AspectLine::SetInterColor(const Quantity_Color& aColor) { - - if ( myInterColor != aColor ) { - myInterColor = aColor; - myIntColorInd = 0; - } -} - -void Prs2d_AspectLine::SetTypeOfFill( const Graphic2d_TypeOfPolygonFilling aType ) { - myFillType = aType; -} - -void Prs2d_AspectLine::SetTile( const Standard_Integer aTile ) { - myTile = aTile; -} - -void Prs2d_AspectLine::SetDrawEdge( const Standard_Boolean aDrawEdge ) { - myDrawEdge = aDrawEdge; -} - -void Prs2d_AspectLine::ValuesOfLine( Quantity_Color& aColor, - Aspect_TypeOfLine& aType, - Aspect_WidthOfLine& aWidth) const{ - aColor = myColor; - aType = myType; - aWidth = myWidth; - -} - -void Prs2d_AspectLine::ValuesOfPoly( Quantity_Color& aColor, - Graphic2d_TypeOfPolygonFilling& aType, - Standard_Integer& aTile, - Standard_Boolean& aDrawEdge ) const { - aColor = myInterColor; - aType = myFillType; - aTile = myTile; - aDrawEdge = myDrawEdge; -} - -Standard_Integer Prs2d_AspectLine::ColorIndex() const { - - return myColorIndex; -} - -Standard_Integer Prs2d_AspectLine::TypeIndex() const { - - return myTypeIndex; -} - -Standard_Integer Prs2d_AspectLine::WidthIndex() const { - - return myWidthIndex; -} - -Standard_Integer Prs2d_AspectLine::InterColorIndex() const { - - return myIntColorInd; -} - -void Prs2d_AspectLine::SetColorIndex( const Standard_Integer anInd ) { - - myColorIndex = anInd; -} - -void Prs2d_AspectLine::SetTypeIndex( const Standard_Integer anInd ) { - - myTypeIndex = anInd; -} - -void Prs2d_AspectLine::SetWidthIndex( const Standard_Integer anInd ) { - - myWidthIndex = anInd; -} - -void Prs2d_AspectLine::SetIntColorInd( const Standard_Integer anInd ) { - - myIntColorInd = anInd; -} diff --git a/src/Prs2d/Prs2d_AspectRoot.cdl b/src/Prs2d/Prs2d_AspectRoot.cdl deleted file mode 100755 index 6118df35b1..0000000000 --- a/src/Prs2d/Prs2d_AspectRoot.cdl +++ /dev/null @@ -1,42 +0,0 @@ --- Created by: Tanya COOL --- Copyright (c) 2000-2012 OPEN CASCADE SAS --- --- The content of this file is subject to the Open CASCADE Technology Public --- License Version 6.5 (the "License"). You may not use the content of this file --- except in compliance with the License. Please obtain a copy of the License --- at http://www.opencascade.org and read it completely before using this file. --- --- The Initial Developer of the Original Code is Open CASCADE S.A.S., having its --- main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. --- --- The Original Code and all software distributed under the License is --- distributed on an "AS IS" basis, without warranty of any kind, and the --- Initial Developer hereby disclaims all such warranties, including without --- limitation, any warranties of merchantability, fitness for a particular --- purpose or non-infringement. Please see the License for the specific terms --- and conditions governing the rights and limitations under the License. - - -deferred class AspectRoot from Prs2d inherits TShared from MMgt - ----Purpose: Abstract class, the root class for aspect classes - -uses - - AspectName from Prs2d - -is - - Initialize( anAspectName: AspectName from Prs2d = Prs2d_AN_UNKNOWN ); - ---Level: Internal - ---Purpose: Initializes the Aspect class having name - - GetAspectName( me ) returns AspectName from Prs2d; - ---Level: Internal - ---Purpose: Returns the Aspect Name of the Aspect class - -fields - - myAspectName: AspectName from Prs2d; - -end AspectRoot; diff --git a/src/Prs2d/Prs2d_AspectRoot.cxx b/src/Prs2d/Prs2d_AspectRoot.cxx deleted file mode 100755 index 2197e5b3a9..0000000000 --- a/src/Prs2d/Prs2d_AspectRoot.cxx +++ /dev/null @@ -1,26 +0,0 @@ -// Copyright (c) 1999-2012 OPEN CASCADE SAS -// -// The content of this file is subject to the Open CASCADE Technology Public -// License Version 6.5 (the "License"). You may not use the content of this file -// except in compliance with the License. Please obtain a copy of the License -// at http://www.opencascade.org and read it completely before using this file. -// -// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its -// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. -// -// The Original Code and all software distributed under the License is -// distributed on an "AS IS" basis, without warranty of any kind, and the -// Initial Developer hereby disclaims all such warranties, including without -// limitation, any warranties of merchantability, fitness for a particular -// purpose or non-infringement. Please see the License for the specific terms -// and conditions governing the rights and limitations under the License. - -#include -#include - -Prs2d_AspectRoot::Prs2d_AspectRoot( const Prs2d_AspectName anAspectName ): - myAspectName( anAspectName ) {} - -Prs2d_AspectName Prs2d_AspectRoot::GetAspectName() const -{ return myAspectName; } - diff --git a/src/Prs2d/Prs2d_AspectText.cdl b/src/Prs2d/Prs2d_AspectText.cdl deleted file mode 100755 index 0ca516222e..0000000000 --- a/src/Prs2d/Prs2d_AspectText.cdl +++ /dev/null @@ -1,124 +0,0 @@ --- Created by: Tanya COOL --- Copyright (c) 2000-2012 OPEN CASCADE SAS --- --- The content of this file is subject to the Open CASCADE Technology Public --- License Version 6.5 (the "License"). You may not use the content of this file --- except in compliance with the License. Please obtain a copy of the License --- at http://www.opencascade.org and read it completely before using this file. --- --- The Initial Developer of the Original Code is Open CASCADE S.A.S., having its --- main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. --- --- The Original Code and all software distributed under the License is --- distributed on an "AS IS" basis, without warranty of any kind, and the --- Initial Developer hereby disclaims all such warranties, including without --- limitation, any warranties of merchantability, fitness for a particular --- purpose or non-infringement. Please see the License for the specific terms --- and conditions governing the rights and limitations under the License. - - -class AspectText from Prs2d inherits AspectRoot from Prs2d - ----Purpose: defines the attributes when drawing a text presentation - -uses - - NameOfColor from Quantity, - Length from Quantity, - Color from Quantity, - PlaneAngle from Quantity, - TypeOfText from Aspect, - TypeOfFont from Aspect, - FontStyle from Aspect - -is - Create( aColor : NameOfColor from Quantity = Quantity_NOC_YELLOW; - aFont : CString from Standard = "TABTXT03"; - anHeight : Length from Quantity = 3.0; - aType : TypeOfText from Aspect = Aspect_TOT_SOLID; - isUnderlined : Boolean from Standard = Standard_False) - returns mutable AspectText from Prs2d; - ---Purpose: constructor using basic aspect types. - - Create( aColor : Color from Quantity; - aFont : FontStyle from Aspect; - aType : TypeOfText from Aspect = Aspect_TOT_SOLID; - isUnderlined : Boolean from Standard = Standard_False) - returns mutable AspectText from Prs2d; - ---Purpose: constructor using advanced aspect types. - - SetColor( me: mutable; aColor : NameOfColor from Quantity ); - ---Level: Public - ---Purpose: Change the color aspect with a predefined color. - - SetColor( me: mutable; aColor : Color from Quantity ); - ---Level: Public - ---Purpose: Change the color aspect. - - SetFont ( me: mutable; aFont : FontStyle from Aspect ); - ---Level: Public - ---Purpose: Change the font style aspect - - SetFont ( me: mutable; aFont : TypeOfFont from Aspect ); - ---Level: Public - ---Purpose: Change the font style aspect with a new font type but - -- preserve all other parameters. - - SetRelativeSlant( me: mutable; aSlant : PlaneAngle from Quantity ); - ---Level: Public - ---Purpose: Change the font style aspect with a new font slant - -- added to the font original slant but preserve all other parameters. - - SetHeight( me: mutable; anHeight : Length from Quantity; - isCapsHeight : Boolean from Standard ); - ---Level: Public - ---Purpose: Change the font style aspect with a new font height - -- and CapsHeight indicator but preserve all other parameters. - - SetType ( me : mutable; aType : TypeOfText from Aspect ); - ---Level: Public - ---Purpose: Change the char type aspect of bolded fonts. - - SetUnderlined ( me: mutable; anIsUnderline : Boolean from Standard ); - ---Level: Public - ---Purpose: Enable / Disable the underlined char aspect. - - Values( me; - aColor : out Color from Quantity; - aFont : out FontStyle from Aspect; - aSlant : out PlaneAngle from Quantity; - aType : out TypeOfText from Aspect; - isUnderlined: out Boolean from Standard - ); - ---Level: Public - ---Purpose: Returns the current parameters of this text aspect. - - FontIndex( me ) returns Integer from Standard; - ---Level: Internal - ---Purpose: Returns the current font index according to the font style aspect - - ColorIndex( me ) returns Integer from Standard; - ---Level: Internal - ---Purpose: Returns the current color index according to the color aspect - - SetFontIndex( me: mutable; anInd: Integer from Standard ); - ---Level: Internal - ---Purpose: Sets the current color index according to the color aspect - - SetColorIndex( me: mutable; anInd: Integer from Standard ); - ---Level: Internal - ---Purpose: Sets the current color index according to the color aspect - - -fields - - myColor : Color from Quantity; - myFont : FontStyle from Aspect; - myRelativeSlant : PlaneAngle from Quantity; - myType : TypeOfText from Aspect; - myIsUnderlined : Boolean from Standard; - - myFontIndex : Integer from Standard; - myColorIndex : Integer from Standard; - -end AspectText from Prs2d; diff --git a/src/Prs2d/Prs2d_AspectText.cxx b/src/Prs2d/Prs2d_AspectText.cxx deleted file mode 100755 index a8a199b357..0000000000 --- a/src/Prs2d/Prs2d_AspectText.cxx +++ /dev/null @@ -1,141 +0,0 @@ -// Copyright (c) 1999-2012 OPEN CASCADE SAS -// -// The content of this file is subject to the Open CASCADE Technology Public -// License Version 6.5 (the "License"). You may not use the content of this file -// except in compliance with the License. Please obtain a copy of the License -// at http://www.opencascade.org and read it completely before using this file. -// -// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its -// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. -// -// The Original Code and all software distributed under the License is -// distributed on an "AS IS" basis, without warranty of any kind, and the -// Initial Developer hereby disclaims all such warranties, including without -// limitation, any warranties of merchantability, fitness for a particular -// purpose or non-infringement. Please see the License for the specific terms -// and conditions governing the rights and limitations under the License. - -#include -#include -#include -#include - -Prs2d_AspectText::Prs2d_AspectText( const Quantity_NameOfColor aColor, - const Standard_CString aFont, - const Quantity_Length aSize, - const Aspect_TypeOfText aType, - const Standard_Boolean isUnderlined ) - : - Prs2d_AspectRoot( Prs2d_AN_TEXT ), - myColor( aColor ), - myFont( aFont, aSize ), - myRelativeSlant(0.), - myType( aType ), - myIsUnderlined( isUnderlined ), - myFontIndex( 0 ), - myColorIndex( 0 ) -{ } - -Prs2d_AspectText::Prs2d_AspectText( const Quantity_Color& aColor, - const Aspect_FontStyle& aFont, - const Aspect_TypeOfText aType, - const Standard_Boolean isUnderlined) - : - Prs2d_AspectRoot( Prs2d_AN_TEXT ), - myColor( aColor ), - myFont( aFont ), - myRelativeSlant(0.), - myType( aType ), - myIsUnderlined( isUnderlined ), - myFontIndex( 0 ), - myColorIndex( 0 ) -{ } - -void Prs2d_AspectText::SetColor( const Quantity_NameOfColor aColor ) { - - SetColor(Quantity_Color(aColor)); -} - -void Prs2d_AspectText::SetColor( const Quantity_Color& aColor ) { - - if( myColor != aColor ) { - myColor = aColor; - myColorIndex = 0; - } -} - -void Prs2d_AspectText::SetFont( const Aspect_TypeOfFont aFont ) { - - if( myFont.Style() != aFont ) { - myFont = Aspect_FontStyle(aFont,myFont.Size(), - myFont.Slant(),myFont.CapsHeight()); - myFontIndex = 0; - } -} - -void Prs2d_AspectText::SetFont( const Aspect_FontStyle& aFont ) { - - if( myFont != aFont ) { - myFont = aFont; - myFontIndex = 0; - } -} - -void Prs2d_AspectText::SetRelativeSlant( const Quantity_PlaneAngle aSlant ) { - - myRelativeSlant = aSlant; -} - -void Prs2d_AspectText::SetHeight( const Quantity_Length anHeight, - const Standard_Boolean isCapsHeight ) { - - if( myFont.Size() != anHeight || myFont.CapsHeight() != isCapsHeight ) { - myFont = Aspect_FontStyle(myFont.Style(),anHeight, - myFont.Slant(),isCapsHeight); - myFontIndex = 0; - } -} - -void Prs2d_AspectText::SetType( const Aspect_TypeOfText aType ) { - myType = aType; -} - -void Prs2d_AspectText::SetUnderlined( const Standard_Boolean anIsUnderline ) { - myIsUnderlined = anIsUnderline; -} - -void Prs2d_AspectText::Values( Quantity_Color& aColor, - Aspect_FontStyle& aFont, - Quantity_PlaneAngle& aSlant, - Aspect_TypeOfText& aType, - Standard_Boolean& isUnderlined) const { - aColor = myColor; - aFont = myFont; - aSlant = myRelativeSlant + myFont.Slant(); - aType = myType; - isUnderlined = myIsUnderlined; -} - -Standard_Integer Prs2d_AspectText :: FontIndex ( ) const { - - return myFontIndex; -} // end Standard_Integer Prs2d_AspectText :: FontIndex - -Standard_Integer Prs2d_AspectText :: ColorIndex ( ) const { - - return myColorIndex; - -} // end Standard_Integer Prs2d_AspectText :: ColorIndex - -void Prs2d_AspectText :: SetFontIndex ( const Standard_Integer anInd ) { - - myFontIndex = anInd; - -} // end void Prs2d_AspectText :: SetFontIndex - -void Prs2d_AspectText :: SetColorIndex ( const Standard_Integer anInd ) { - - myColorIndex = anInd; - -} // end void Prs2d_AspectText :: SetColorIndex - diff --git a/src/Prs2d/Prs2d_Axis.cdl b/src/Prs2d/Prs2d_Axis.cdl deleted file mode 100755 index 1e326ca7b7..0000000000 --- a/src/Prs2d/Prs2d_Axis.cdl +++ /dev/null @@ -1,141 +0,0 @@ --- Created by: Tanya COOL --- Copyright (c) 2000-2012 OPEN CASCADE SAS --- --- The content of this file is subject to the Open CASCADE Technology Public --- License Version 6.5 (the "License"). You may not use the content of this file --- except in compliance with the License. Please obtain a copy of the License --- at http://www.opencascade.org and read it completely before using this file. --- --- The Initial Developer of the Original Code is Open CASCADE S.A.S., having its --- main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. --- --- The Original Code and all software distributed under the License is --- distributed on an "AS IS" basis, without warranty of any kind, and the --- Initial Developer hereby disclaims all such warranties, including without --- limitation, any warranties of merchantability, fitness for a particular --- purpose or non-infringement. Please see the License for the specific terms --- and conditions governing the rights and limitations under the License. - - -class Axis from Prs2d inherits Line from Graphic2d - - ---Purpose: Constructs the primitive Axis - -uses - - Drawer from Graphic2d, - GraphicObject from Graphic2d, - Ax2d from gp, - Ax22d from gp, - Lin2d from gp, - TypeOfAxis from Prs2d, - TypeOfArrow from Prs2d, - Array1OfShortReal from TShort, - FStream from Aspect, - HArray1OfPnt2d from TColgp - -is - Create( aGraphicObject: GraphicObject from Graphic2d; - anAx : Ax22d from gp; - aLength : Real from Standard; - anArrAngle : Real from Standard = 30.0; - anArrLength : Real from Standard = 30.0; - anArrType : TypeOfArrow from Prs2d = Prs2d_TOA_OPENED; - aTxtScale : Real from Standard = 10.0 ) - returns mutable Axis from Prs2d; - - ---Purpose: Initializes the axis 2 position - - - Create( aGraphicObject: GraphicObject from Graphic2d; - anAx : Ax2d from gp; - aLength : Real from Standard; - anArrAngle : Real from Standard = 30.0; - anArrLength : Real from Standard = 30.0; - anArrType : TypeOfArrow from Prs2d = Prs2d_TOA_OPENED; - aTxtScale : Real from Standard = 10.0 ) - returns mutable Axis from Prs2d; - - ---Purpose: Initializes the axis position . - - Create( aGraphicObject: GraphicObject from Graphic2d; - aLine : Lin2d from gp; - aLength : Real from Standard; - anArrAngle : Real from Standard = 30.0; - anArrLength : Real from Standard = 30.0; - anArrType : TypeOfArrow from Prs2d = Prs2d_TOA_OPENED; - aTxtScale : Real from Standard = 10.0 ) - returns mutable Axis from Prs2d; - - ---Purpose: Initializes the line - - ------------------------------------------------- - -- Category: Draw and Pick - ------------------------------------------------- - - Draw( me : mutable; aDrawer: Drawer from Graphic2d ) is static protected; - ---Level: Internal - ---Purpose: Draws the axis . - - DrawElement( me : mutable; aDrawer: Drawer from Graphic2d; - anIndex: Integer from Standard) - is redefined protected; - ---Level: Internal - ---Purpose: Draws element of the axis . - - DrawVertex( me : mutable; aDrawer: Drawer from Graphic2d; - anIndex: Integer from Standard) - is redefined protected; - ---Level: Internal - ---Purpose: Draws vertex of the axis . - - TypeOfArrow( me ) returns TypeOfArrow from Prs2d; - ---Level: Public - ---Purpose: Returns type of arrow - -- Type is: - -- TOA_OPENED, - -- TOA_CLOSED, - -- TOA_FILLED - - ArrayOfPnt2d( me ) returns HArray1OfPnt2d from TColgp; - ---Level: Public - ---C++: return const - - ArrayOfXArrowPnt2d( me ) returns HArray1OfPnt2d from TColgp; - ---Level: Public - ---C++: return const - - ArrayOfYArrowPnt2d( me ) returns HArray1OfPnt2d from TColgp; - ---Level: Public - ---C++: return const - - TextScale( me ) returns Real from Standard; - ---Level: Public - - Pick( me : mutable; X, Y: ShortReal from Standard; - aPrecision: ShortReal from Standard; - aDrawer: Drawer from Graphic2d ) - returns Boolean from Standard is static protected; - ---Level: Internal - ---Purpose: Returns Standard_True if the axis is picked, - -- Standard_False if not. - - Save( me; aFStream: in out FStream from Aspect ) is virtual; - -fields - - myX0 : ShortReal from Standard; - myY0 : ShortReal from Standard; - myX1 : ShortReal from Standard; - myY1 : ShortReal from Standard; - myX2 : ShortReal from Standard; - myY2 : ShortReal from Standard; - myXVertX : Array1OfShortReal from TShort; - myYVertX : Array1OfShortReal from TShort; - myXVertY : Array1OfShortReal from TShort; - myYVertY : Array1OfShortReal from TShort; - myArrType : TypeOfArrow from Prs2d; - myisXY : Boolean from Standard; - myTextScale : Real from Standard; - -end Axis from Prs2d; diff --git a/src/Prs2d/Prs2d_Axis.cxx b/src/Prs2d/Prs2d_Axis.cxx deleted file mode 100755 index dd4953bb41..0000000000 --- a/src/Prs2d/Prs2d_Axis.cxx +++ /dev/null @@ -1,734 +0,0 @@ -// Copyright (c) 1999-2012 OPEN CASCADE SAS -// -// The content of this file is subject to the Open CASCADE Technology Public -// License Version 6.5 (the "License"). You may not use the content of this file -// except in compliance with the License. Please obtain a copy of the License -// at http://www.opencascade.org and read it completely before using this file. -// -// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its -// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. -// -// The Original Code and all software distributed under the License is -// distributed on an "AS IS" basis, without warranty of any kind, and the -// Initial Developer hereby disclaims all such warranties, including without -// limitation, any warranties of merchantability, fitness for a particular -// purpose or non-infringement. Please see the License for the specific terms -// and conditions governing the rights and limitations under the License. - -#include -#include - -#define VERTEXMARKER 2 -#define DEFAULTMARKERSIZE 3.0 -#define XROTATE(x,y) ((x)*cosa - (y)*sina) -#define YROTATE(x,y) ((y)*cosa + (x)*sina) -#define ADDPIX 17 - -Prs2d_Axis::Prs2d_Axis( const Handle(Graphic2d_GraphicObject)& aGO, - const gp_Ax22d& anAx, - const Standard_Real aLength, - const Standard_Real anArrAngle, - const Standard_Real anArrLength, - const Prs2d_TypeOfArrow anArrType, - const Standard_Real aTxtScale ) - : - Graphic2d_Line( aGO ), - myXVertX( 1, 3 ), - myYVertX( 1, 3 ), - myXVertY( 1, 3 ), - myYVertY( 1, 3 ), - myArrType( anArrType ), - myisXY( Standard_True ), - myTextScale( aTxtScale ) - -{ - Standard_Real X0, Y0, X1, Y1, X2, Y2; - - anAx.Location().Coord( X0, Y0 ); - anAx.XDirection().Coord( X1, Y1 ); - anAx.YDirection().Coord( X2, Y2 ); - - X1 = X0 + X1 * aLength; - Y1 = Y0 + Y1 * aLength; - X2 = X0 + X2 * aLength; - Y2 = Y0 + Y2 * aLength; - - myX0 = Standard_ShortReal( X0 ); - myY0 = Standard_ShortReal( Y0 ); - myX1 = Standard_ShortReal( X1 ); - myY1 = Standard_ShortReal( Y1 ); - myX2 = Standard_ShortReal( X2 ); - myY2 = Standard_ShortReal( Y2 ); - - myMinX = myX0; - myMinY = myY0; - myMaxX = myX0; - myMaxY = myY0; - - if ( myX1 < myMinX ) myMinX = myX1; - if ( myY1 < myMinY ) myMinY = myY1; - if ( myX1 > myMaxX ) myMaxX = myX1; - if ( myY1 > myMaxY ) myMaxY = myY1; - - if ( myX2 < myMinX ) myMinX = myX2; - if ( myY2 < myMinY ) myMinY = myY2; - if ( myX2 > myMaxX ) myMaxX = myX2; - if ( myY2 > myMaxY ) myMaxY = myY2; - - Standard_Real ArrAngle = M_PI/180.*anArrAngle, theAngle; - gp_Pnt2d theOrigine( 0., 0.), P1, P2, P3; - gp_Vec2d VX( 1., 0. ), VDir; - - P1 = gp_Pnt2d( X1, Y1 ); - P2 = gp_Pnt2d( anArrLength, anArrLength*Tan( ArrAngle/2. ) ); - P3 = gp_Pnt2d( anArrLength, -anArrLength*Tan( ArrAngle/2. ) ); - - VDir = gp_Vec2d( gp_Pnt2d( X1, Y1 ), gp_Pnt2d( X0, Y0 ) ); - theAngle = VX.Angle( VDir ); - - P2.Rotate( theOrigine, theAngle ); - P3.Rotate( theOrigine, theAngle ); - - P2.Translate( gp_Vec2d( theOrigine, P1 ) ); - P3.Translate( gp_Vec2d( theOrigine, P1 ) ); - - myXVertX(1) = Standard_ShortReal( P2.X() ); - myYVertX(1) = Standard_ShortReal( P2.Y() ); - myXVertX(2) = Standard_ShortReal( P1.X() ); - myYVertX(2) = Standard_ShortReal( P1.Y() ); - myXVertX(3) = Standard_ShortReal( P3.X() ); - myYVertX(3) = Standard_ShortReal( P3.Y() ); - - Standard_Integer i; - for ( i = 1; i <= 3; i++ ) { - if ( myXVertX(i) < myMinX ) myMinX = myXVertX(i); - if ( myYVertX(i) < myMinY ) myMinY = myYVertX(i); - if ( myXVertX(i) > myMaxX ) myMaxX = myXVertX(i); - if ( myYVertX(i) > myMaxY ) myMaxY = myYVertX(i); - } - - P1 = gp_Pnt2d( X2, Y2 );; - P2 = gp_Pnt2d( anArrLength, anArrLength*Tan( ArrAngle/2. ) ); - P3 = gp_Pnt2d( anArrLength, -anArrLength*Tan( ArrAngle/2. ) ); - - VDir = gp_Vec2d( gp_Pnt2d( X2, Y2 ), gp_Pnt2d( X0, Y0 ) ); - theAngle = VX.Angle( VDir ); - - P2.Rotate( theOrigine, theAngle ); - P3.Rotate( theOrigine, theAngle ); - - P2.Translate( gp_Vec2d( theOrigine, P1 ) ); - P3.Translate( gp_Vec2d( theOrigine, P1 ) ); - - myXVertY(1) = Standard_ShortReal( P2.X() ); - myYVertY(1) = Standard_ShortReal( P2.Y() ); - myXVertY(2) = Standard_ShortReal( P1.X() ); - myYVertY(2) = Standard_ShortReal( P1.Y() ); - myXVertY(3) = Standard_ShortReal( P3.X() ); - myYVertY(3) = Standard_ShortReal( P3.Y() ); - - for ( i = 1; i <= 3; i++ ) { - - if ( myXVertY(i) < myMinX ) myMinX = myXVertY(i); - if ( myYVertY(i) < myMinY ) myMinY = myYVertY(i); - if ( myXVertY(i) > myMaxX ) myMaxX = myXVertY(i); - if ( myYVertY(i) > myMaxY ) myMaxY = myYVertY(i); - - } - - myNumOfElem = 6; - myNumOfVert = 3; - -} - -Prs2d_Axis::Prs2d_Axis( const Handle(Graphic2d_GraphicObject)& aGO, - const gp_Ax2d& anAx, - const Standard_Real aLength, - const Standard_Real anArrAngle, - const Standard_Real anArrLength, - const Prs2d_TypeOfArrow anArrType, - const Standard_Real aTxtScale ) - : - Graphic2d_Line( aGO ), - - myX2( 0. ), - myY2( 0. ), - myXVertX( 1, 3 ), - myYVertX( 1, 3 ), - myXVertY( 1, 3 ), - myYVertY( 1, 3 ), - myArrType( anArrType ), - myisXY( Standard_False ), - myTextScale( aTxtScale ) -{ - Standard_Real X0, Y0, X1, Y1; - - anAx.Location().Coord( X0, Y0 ); - anAx.Direction().Coord( X1, Y1 ); - - X1 = X0 + X1 * aLength; - Y1 = Y0 + Y1 * aLength; - - myX0 = Standard_ShortReal( X0 ); - myY0 = Standard_ShortReal( Y0 ); - myX1 = Standard_ShortReal( X1 ); - myY1 = Standard_ShortReal( Y1 ); - - myMinX = myX0; - myMinY = myY0; - myMaxX = myX0; - myMaxY = myY0; - - if ( myX1 < myMinX ) myMinX = myX1; - if ( myY1 < myMinY ) myMinY = myY1; - if ( myX1 > myMaxX ) myMaxX = myX1; - if ( myY1 > myMaxY ) myMaxY = myY1; - - Standard_Real ArrAngle = M_PI/180.*anArrAngle, theAngle; - gp_Pnt2d theOrigine( 0., 0.), P1, P2, P3; - gp_Vec2d VX( 1., 0. ), VDir; - - P1 = gp_Pnt2d( X0, Y0 ); - P2 = gp_Pnt2d( anArrLength, anArrLength*Tan( ArrAngle/2. ) ); - P3 = gp_Pnt2d( anArrLength, -anArrLength*Tan( ArrAngle/2. ) ); - - VDir = gp_Vec2d( gp_Pnt2d( X1, Y1 ), gp_Pnt2d( X0, Y0 ) ); - theAngle = VX.Angle( VDir ); - - P2.Rotate( theOrigine, theAngle ); - P3.Rotate( theOrigine, theAngle ); - - P2.Translate( gp_Vec2d( theOrigine, P1 ) ); - P3.Translate( gp_Vec2d( theOrigine, P1 ) ); - - myXVertX(1) = Standard_ShortReal( P2.X() ); - myYVertX(1) = Standard_ShortReal( P2.Y() ); - myXVertX(2) = Standard_ShortReal( P1.X() ); - myYVertX(2) = Standard_ShortReal( P1.Y() ); - myXVertX(3) = Standard_ShortReal( P3.X() ); - myYVertX(3) = Standard_ShortReal( P3.Y() ); - - for ( Standard_Integer i = 1; i <= 3; i++ ) { - if ( myXVertX(i) < myMinX ) myMinX = myXVertX(i); - if ( myYVertX(i) < myMinY ) myMinY = myYVertX(i); - if ( myXVertX(i) > myMaxX ) myMaxX = myXVertX(i); - if ( myYVertX(i) > myMaxY ) myMaxY = myYVertX(i); - } - myNumOfElem = 6; - myNumOfVert = 3; - -} - -Prs2d_Axis::Prs2d_Axis( const Handle(Graphic2d_GraphicObject)& aGO, - const gp_Lin2d& aLine, - const Standard_Real aLength, - const Standard_Real anArrAngle, - const Standard_Real anArrLength, - const Prs2d_TypeOfArrow anArrType, - const Standard_Real aTxtScale ) - : - Graphic2d_Line( aGO ), - - myX2( 0. ), - myY2( 0. ), - myXVertX( 1, 3 ), - myYVertX( 1, 3 ), - myXVertY( 1, 3 ), - myYVertY( 1, 3 ), - myArrType( anArrType ), - myisXY( Standard_False ), - myTextScale( aTxtScale ) - -{ - Standard_Real X0, Y0, X1, Y1; - - aLine.Location().Coord( X0, Y0 ); - aLine.Direction().Coord( X1, Y1 ); - - X1 = X0 + X1 * aLength; - Y1 = Y0 + Y1 * aLength; - - myX0 = Standard_ShortReal( X0 ); - myY0 = Standard_ShortReal( Y0 ); - myX1 = Standard_ShortReal( X1 ); - myY1 = Standard_ShortReal( Y1 ); - - myMinX = myX0; - myMinY = myY0; - myMaxX = myX0; - myMaxY = myY0; - - if ( myX1 < myMinX ) myMinX = myX1; - if ( myY1 < myMinY ) myMinY = myY1; - if ( myX1 > myMaxX ) myMaxX = myX1; - if ( myY1 > myMaxY ) myMaxY = myY1; - - Standard_Real ArrAngle = M_PI/180.*anArrAngle, theAngle; - gp_Pnt2d theOrigine( 0., 0.), P1, P2, P3; - gp_Vec2d VX( 1., 0. ), VDir; - - P1 = gp_Pnt2d( X1, Y1 ); - P2 = gp_Pnt2d( anArrLength, anArrLength*Tan( ArrAngle/2. ) ); - P3 = gp_Pnt2d( anArrLength, -anArrLength*Tan( ArrAngle/2. ) ); - - VDir = gp_Vec2d( gp_Pnt2d( X1, Y1 ), gp_Pnt2d( X0, Y0 ) ); - theAngle = VX.Angle( VDir ); - - P2.Rotate( theOrigine, theAngle ); - P3.Rotate( theOrigine, theAngle ); - - P2.Translate( gp_Vec2d( theOrigine, P1 ) ); - P3.Translate( gp_Vec2d( theOrigine, P1 ) ); - - myXVertX(1) = Standard_ShortReal( P2.X() ); - myYVertX(1) = Standard_ShortReal( P2.Y() ); - myXVertX(2) = Standard_ShortReal( P1.X() ); - myYVertX(2) = Standard_ShortReal( P1.Y() ); - myXVertX(3) = Standard_ShortReal( P3.X() ); - myYVertX(3) = Standard_ShortReal( P3.Y() ); - - for ( Standard_Integer i = 1; i <= 3; i++ ) { - if ( myXVertX(i) < myMinX ) myMinX = myXVertX(i); - if ( myYVertX(i) < myMinY ) myMinY = myYVertX(i); - if ( myXVertX(i) > myMaxX ) myMaxX = myXVertX(i); - if ( myYVertX(i) > myMaxY ) myMaxY = myYVertX(i); - } - myNumOfElem = 6; - myNumOfVert = 3; - -} - -void Prs2d_Axis::Draw( const Handle(Graphic2d_Drawer)& aDrawer ) { - - Standard_Boolean IsIn = Standard_False; - - TCollection_ExtendedString txtX("X"); - TCollection_ExtendedString txtY("Y"); - - if ( !myGOPtr->IsTransformed() ) - IsIn = aDrawer->IsIn( myMinX, myMaxX, myMinY, myMaxY ); - else { - Standard_ShortReal minx, miny, maxx, maxy; - MinMax( minx, maxx, miny, maxy ); - IsIn = aDrawer->IsIn( minx, maxx, miny, maxy ); - } - - if ( IsIn ) { - - DrawLineAttrib( aDrawer ); - Standard_ShortReal dxx = aDrawer->Convert(17); - aDrawer->SetTextAttrib( myColorIndex, 0, 0, Standard_ShortReal(myTextScale*aDrawer->Scale()), - Standard_ShortReal(myTextScale*aDrawer->Scale()), Standard_False ); - Standard_ShortReal a = myX0, b = myY0, - c = myX1, d = myY1, - e = myX2, f = myY2, - t1 = myX1, t2 = myY1 + dxx, - tt1 = myX2 + dxx, tt2 = myY2; - TShort_Array1OfShortReal XpointX( 1, 3 ), YpointX( 1, 3 ), - XpointY( 1, 3 ), YpointY( 1, 3 ); - - if ( myGOPtr->IsTransformed () ) { - gp_GTrsf2d aTrsf = myGOPtr->Transform (); - Standard_Real a1, b1, a2, b2; - for ( Standard_Integer j = 1; j <= 3; j++ ) { - a1 = myXVertX(j); - b1 = myYVertX(j); - aTrsf.Transforms(a1, b1); - XpointX(j) = Standard_ShortReal(a1); - YpointX(j) = Standard_ShortReal(b1); - if ( myisXY ) { - a2 = myXVertY(j); - b2 = myYVertY(j); - aTrsf.Transforms( a2, b2 ); - XpointY(j) = Standard_ShortReal(a2); - YpointY(j) = Standard_ShortReal(b2); - } - } - - Standard_Real A, B, C, D, T1, T2; - A = a; - B = b; - C = c; - D = d; - T1 = t1; - T2 = t2; - aTrsf.Transforms( A, B ); - aTrsf.Transforms( C, D ); - aTrsf.Transforms( T1, T2 ); - a = Standard_ShortReal(A); - b = Standard_ShortReal(B); - c = Standard_ShortReal(C); - d = Standard_ShortReal(D); - t1 = Standard_ShortReal(T1); - t2 = Standard_ShortReal(T2); - - if ( myisXY ) { - Standard_Real E, F, TT1, TT2; - E = e; - F = f; - TT1 = tt1; - TT2 = tt2; - aTrsf.Transforms( E, F ); - aTrsf.Transforms( TT1, TT2 ); - e = Standard_ShortReal(E); - f = Standard_ShortReal(F); - tt1 = Standard_ShortReal(TT1); - tt2 = Standard_ShortReal(TT2); - } - } else { - XpointX.Assign( myXVertX ); - YpointX.Assign( myYVertX ); - if ( myisXY ) { - XpointY.Assign( myXVertY ); - YpointY.Assign( myYVertY ); - } - } // end if GO is transformed - - aDrawer->MapSegmentFromTo( a, b, c, d ); - aDrawer->MapTextFromTo( txtX, t1, t2, 0., 0., 0., Aspect_TOT_SOLID ); - - if ( myArrType == Prs2d_TOA_CLOSED || myArrType == Prs2d_TOA_FILLED ) - aDrawer->MapPolygonFromTo( XpointX, YpointX ); - else - aDrawer->MapPolylineFromTo( XpointX, YpointX ); - - if ( myisXY ) { - aDrawer->MapSegmentFromTo( a, b, e, f ); - aDrawer->MapTextFromTo( txtY, tt1, tt2, 0., 0., 0., Aspect_TOT_SOLID ); - if ( myArrType == Prs2d_TOA_CLOSED || myArrType == Prs2d_TOA_FILLED ) - aDrawer->MapPolygonFromTo( XpointY, YpointY ); - else - aDrawer->MapPolylineFromTo( XpointY, YpointY ); - - } - } // end if IsIn is true - -} - -void Prs2d_Axis::DrawElement( const Handle(Graphic2d_Drawer)& aDrawer, - const Standard_Integer anIndex) { - - Standard_Boolean IsIn = Standard_False; - - if ( ! myGOPtr->IsTransformed() ) - IsIn = aDrawer->IsIn( myMinX, myMaxX, myMinY, myMaxY ); - else { - Standard_ShortReal minx, miny, maxx, maxy; - MinMax( minx, maxx, miny, maxy ); - IsIn = aDrawer->IsIn( minx, maxx, miny, maxy ); - } - - if ( IsIn ) { - - DrawLineAttrib( aDrawer ); - // aDrawer->SetTextAttrib( myColorIndex, 0, 0, myTextScale*aDrawer->Scale(), - // myTextScale*aDrawer->Scale(), Standard_False ); - Standard_ShortReal dxx = aDrawer->Convert(17); - Standard_ShortReal a = myX0, b = myY0, - c = myX1, d = myY1, - e = myX2, f = myY2, - t1 = myX1, t2 = myY1 + dxx, - tt1 = myX2 + dxx, tt2 = myY2; - TShort_Array1OfShortReal Xpoint( 1, 3 ), Ypoint( 1, 3 ); - - if ( anIndex == 1 ) { - Xpoint.Assign( myXVertX ); - Ypoint.Assign( myYVertX ); - } else if ( anIndex == 2 ) { - Xpoint.Assign( myXVertY ); - Ypoint.Assign( myYVertY ); - } - - if ( myGOPtr->IsTransformed () ) { - gp_GTrsf2d aTrsf = myGOPtr->Transform (); - Standard_Real a1, b1, c1, d1, e1, f1, at1, at2, att1, att2; - - if ( anIndex == 1 ) { - for ( Standard_Integer j = 1; j <= 3; j++ ) { - a1 = Standard_Real( Xpoint(j) ); - b1 = Standard_Real( Xpoint(j) ); - aTrsf.Transforms( a1, b1 ); - Xpoint(j) = Standard_ShortReal( a1 ); - Ypoint(j) = Standard_ShortReal( b1 ); - } - } else if ( anIndex == 2 ) { - - for ( Standard_Integer j = 1; j <= 3; j++ ) { - a1 = Standard_Real( Xpoint(j) ); - b1 = Standard_Real( Xpoint(j) ); - aTrsf.Transforms( a1, b1 ); - Xpoint(j) = Standard_ShortReal( a1 ); - Ypoint(j) = Standard_ShortReal( b1 ); - } - } else if ( anIndex == 5 ) { - - a1 = Standard_Real( a ); - b1 = Standard_Real( b ); - c1 = Standard_Real( c ); - d1 = Standard_Real( d ); - aTrsf.Transforms( a1, b1 ); - aTrsf.Transforms( c1, d1 ); - a = Standard_ShortReal( a1 ); - b = Standard_ShortReal( b1 ); - c = Standard_ShortReal( c1 ); - d = Standard_ShortReal( d1 ); - - } else if ( anIndex == 6 ) { - a1 = Standard_Real( a ); - b1 = Standard_Real( b ); - e1 = Standard_Real( e ); - f1 = Standard_Real( f ); - aTrsf.Transforms( a1, b1 ); - aTrsf.Transforms( e1, f1 ); - a = Standard_ShortReal( a1 ); - b = Standard_ShortReal( b1); - e = Standard_ShortReal( e1 ); - f = Standard_ShortReal( f1); - - } else if ( anIndex == 3 ) { - c1 = Standard_Real( c ); - d1 = Standard_Real( d ); - at1 = Standard_Real( t1 ); - at2 = Standard_Real( t2 ); - aTrsf.Transforms( c1, d1 ); - aTrsf.Transforms( at1, at2 ); - c = Standard_ShortReal( c1 ); - d = Standard_ShortReal( d1); - t1 = Standard_ShortReal( at1 ); - t2 = Standard_ShortReal( at2); - - } else if ( anIndex == 4 ) { - e1 = Standard_Real( e ); - f1 = Standard_Real( f ); - att1 = Standard_Real( tt1 ); - att2 = Standard_Real( tt2 ); - aTrsf.Transforms( e1, f1 ); - aTrsf.Transforms( att1, att2 ); - e = Standard_ShortReal( e1 ); - f = Standard_ShortReal( f1); - tt1 = Standard_ShortReal( att1 ); - tt2 = Standard_ShortReal( att2); - - } - - } - - if ( anIndex == 1 || anIndex == 2 ) - if ( myArrType == Prs2d_TOA_CLOSED || myArrType == Prs2d_TOA_FILLED ) { - aDrawer->MapPolygonFromTo( Xpoint, Ypoint ); - } else { - aDrawer->MapPolylineFromTo( Xpoint, Ypoint ); - } - else if ( anIndex == 5 ) - aDrawer->MapSegmentFromTo( a, b, c, d ); - else if ( anIndex == 6 ) - aDrawer->MapSegmentFromTo( a, b, e, f ); - else if ( anIndex == 3 ) { - TCollection_ExtendedString txtX("X"); - aDrawer->MapTextFromTo( txtX, t1, t2, 0., 0., 0., Aspect_TOT_SOLID ); - } else if ( anIndex == 4 ) { - TCollection_ExtendedString txtY("Y"); - aDrawer->MapTextFromTo( txtY, tt1, tt2, 0., 0., 0., Aspect_TOT_SOLID ); - } - } // end if IsIn is true - -} - -void Prs2d_Axis::DrawVertex (const Handle(Graphic2d_Drawer)& aDrawer, - const Standard_Integer anIndex) { - - Standard_Boolean IsIn = Standard_False; - - if ( ! myGOPtr->IsTransformed() ) - IsIn = aDrawer->IsIn( myMinX, myMaxX, myMinY, myMaxY ); - else { - Standard_ShortReal minx, miny, maxx, maxy; - MinMax( minx, maxx, miny, maxy ); - IsIn = aDrawer->IsIn( minx, maxx, miny, maxy ); - } - if ( IsIn ) { - if ( anIndex == 1 || anIndex == 2 || anIndex == 3 ) { - Standard_ShortReal X=0., Y=0.; - if ( anIndex == 1 ) { - X = myX0; Y = myY0; - } else if ( anIndex == 2 ) { - X = myX1; Y = myY1; - } else if ( anIndex == 3 ) { - X = myX2; Y = myY2; - } - - DrawMarkerAttrib( aDrawer ); - if ( myGOPtr->IsTransformed() ) { - gp_GTrsf2d aTrsf = myGOPtr->Transform(); - Standard_Real A = Standard_Real( X ), B = Standard_Real( Y ); - aTrsf.Transforms( A, B ); - X = Standard_ShortReal( A ); - Y = Standard_ShortReal( B ); - } - aDrawer->MapMarkerFromTo(VERTEXMARKER,X,Y, DEFAULTMARKERSIZE,DEFAULTMARKERSIZE,0.0); - } - } -} - -Standard_Boolean Prs2d_Axis::Pick( const Standard_ShortReal X, - const Standard_ShortReal Y, - const Standard_ShortReal aPrecision, - const Handle(Graphic2d_Drawer)& aDrawer ) { - Standard_ShortReal SRX = X, SRY = Y; - Standard_Boolean Result = Standard_False; - - if ( IsInMinMax (X, Y, aPrecision) ) { - if ( myGOPtr->IsTransformed () ) { - gp_GTrsf2d aTrsf = ( myGOPtr->Transform() ).Inverted(); - Standard_Real RX = Standard_Real(SRX), RY = Standard_Real(SRY); - aTrsf.Transforms( RX, RY ); - SRX = Standard_ShortReal( RX ); - SRY = Standard_ShortReal( RY ); - } - - if ( Graphic2d_Primitive::IsOn( SRX, SRY, myX0, myY0, aPrecision ) ) { - SetPickedIndex(-1); - return Standard_True; - } else if ( Graphic2d_Primitive::IsOn( SRX, SRY, myX1, myY1, aPrecision ) ) { - SetPickedIndex(-2); - return Standard_True; - } else if ( Graphic2d_Primitive::IsOn( SRX, SRY, myX2, myY2, aPrecision ) ) { - SetPickedIndex(-3); - return Standard_True; - } - - for ( Standard_Integer i = 1; i < 3 ; i++) { - if ( IsOn( SRX, SRY, myXVertX(i), myYVertX(i), myXVertX(i+1), myYVertX( i+1 ), aPrecision ) ) { - SetPickedIndex(1); - return Standard_True; - } - if ( myisXY ) - if ( IsOn( SRX, SRY, myXVertY(i), myYVertY(i), myXVertY(i+1), myYVertY( i+1 ), aPrecision ) ) { - SetPickedIndex(2); - return Standard_True; - } - - } // end for - - if ( myArrType == Prs2d_TOA_CLOSED || myArrType == Prs2d_TOA_FILLED ) - if ( IsIn( SRX, SRY, myXVertX, myYVertX, aPrecision ) ) { - SetPickedIndex(1); - return Standard_True; - } - - if ( myisXY ) - if ( myArrType == Prs2d_TOA_CLOSED || myArrType == Prs2d_TOA_FILLED ) - if ( IsIn( SRX, SRY, myXVertY, myYVertY, aPrecision ) ) { - SetPickedIndex(2); - return Standard_True; - } - Standard_ShortReal width,height,xoffset,yoffset; - Standard_ShortReal hscale = Standard_ShortReal(myTextScale*aDrawer->Scale()), - wscale = Standard_ShortReal(myTextScale*aDrawer->Scale()); - Standard_ShortReal TX = X, TY = Y; - - aDrawer->SetTextAttrib( myColorIndex, 0, 0, hscale, wscale, Standard_False ); - TCollection_ExtendedString txt("X"); - if ( !aDrawer->GetTextSize( txt, width, height, xoffset, yoffset ) ) { - width = height = xoffset = yoffset = 0.; - } - Standard_ShortReal dxx = aDrawer->Convert(ADDPIX); - Standard_ShortReal cosa = Standard_ShortReal(Cos( 0. )), - sina = Standard_ShortReal(Sin( 0. )), - dx = TX- myX1, - dy = TY- myY1 - dxx, - x = XROTATE(dx,dy), - y = YROTATE(dx,dy); - - Result = (x >= -aPrecision + xoffset) - && (x <= width + xoffset + aPrecision) - && (y >= -yoffset - aPrecision) - && (y <= height - yoffset + aPrecision); - - if ( Result ) { - SetPickedIndex(3); - return Standard_True; - } - txt = TCollection_ExtendedString("Y"); - if ( !aDrawer->GetTextSize( txt, width, height, xoffset, yoffset ) ) { - width = height = xoffset = yoffset = 0.; - } - - dx = TX - myX2 - dxx; - dy = TY - myY2, - x = XROTATE(dx,dy), - y = YROTATE(dx,dy); - - Result = (x >= -aPrecision + xoffset) - && (x <= width + xoffset + aPrecision) - && (y >= -yoffset - aPrecision) - && (y <= height - yoffset + aPrecision); - - if ( Result ) { - SetPickedIndex( 4 ); - return Standard_True; - } - - if ( IsOn( SRX, SRY, myX0, myY0, myX1, myY1, aPrecision ) ) { - SetPickedIndex(5); - return Standard_True; - } - if ( myisXY ) - if ( IsOn( SRX, SRY, myX0, myY0, myX2, myY2, aPrecision ) ) { - SetPickedIndex(6); - return Standard_True; - } - - }// end if IsInMinMax is true - - return Standard_False; - -} - -void Prs2d_Axis::Save(Aspect_FStream& aFStream) const -{ -} - -Prs2d_TypeOfArrow Prs2d_Axis::TypeOfArrow( ) const -{ - return myArrType; -} - -const Handle(TColgp_HArray1OfPnt2d) Prs2d_Axis::ArrayOfPnt2d( ) const -{ - Handle(TColgp_HArray1OfPnt2d) points = new TColgp_HArray1OfPnt2d( 1, 3 ); - - points->SetValue( 1, gp_Pnt2d( myX1, myY1 ) ); - points->SetValue( 2, gp_Pnt2d( myX0, myY0 ) ); - points->SetValue( 3, gp_Pnt2d( myX2, myY2 ) ); - return points; -} - -const Handle(TColgp_HArray1OfPnt2d) Prs2d_Axis::ArrayOfXArrowPnt2d( ) const -{ - Handle(TColgp_HArray1OfPnt2d) points = new TColgp_HArray1OfPnt2d( 1, 3 ); - - for ( Standard_Integer i = 1; i <= 3; i++ ) - { - points->SetValue( i, gp_Pnt2d( myXVertX(i), myYVertX(i) ) ); - } - return points; -} - -const Handle(TColgp_HArray1OfPnt2d) Prs2d_Axis::ArrayOfYArrowPnt2d( ) const -{ - Handle(TColgp_HArray1OfPnt2d) points = new TColgp_HArray1OfPnt2d( 1, 3 ); - - for ( Standard_Integer i = 1; i <= 3; i++ ) - { - points->SetValue( i, gp_Pnt2d( myXVertY(i), myYVertY(i) ) ); - } - return points; -} - -Standard_Real Prs2d_Axis::TextScale( ) const -{ - return myTextScale; -} - - diff --git a/src/Prs2d/Prs2d_Circularity.cdl b/src/Prs2d/Prs2d_Circularity.cdl deleted file mode 100755 index 84486f5cb6..0000000000 --- a/src/Prs2d/Prs2d_Circularity.cdl +++ /dev/null @@ -1,54 +0,0 @@ --- Created by: TCL --- Copyright (c) 2000-2012 OPEN CASCADE SAS --- --- The content of this file is subject to the Open CASCADE Technology Public --- License Version 6.5 (the "License"). You may not use the content of this file --- except in compliance with the License. Please obtain a copy of the License --- at http://www.opencascade.org and read it completely before using this file. --- --- The Initial Developer of the Original Code is Open CASCADE S.A.S., having its --- main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. --- --- The Original Code and all software distributed under the License is --- distributed on an "AS IS" basis, without warranty of any kind, and the --- Initial Developer hereby disclaims all such warranties, including without --- limitation, any warranties of merchantability, fitness for a particular --- purpose or non-infringement. Please see the License for the specific terms --- and conditions governing the rights and limitations under the License. - - -class Circularity from Prs2d inherits Tolerance from Prs2d - -uses - - GraphicObject from Graphic2d, - Drawer from Graphic2d, - Length from Quantity, - FStream from Aspect - -is - ------------------------- - -- Category: Constructors - ------------------------- - - Create( aGO : GraphicObject from Graphic2d; - aX, aY : Real from Standard; - aLength : Real from Standard = 3.0; - anAngle : Real from Standard = 0.0 ); - ---Level: Public - ---Purpose: Creates a tolerance Circularity with the center at , ; - -- length of this is ; - -- reference point is , - ---Category: Constructor - - -------------------------- - -- Category: Draw and Pick - -------------------------- - - Draw( me : mutable; aDrawer: Drawer from Graphic2d ) is static protected; - ---Level: Internal - ---Purpose: Draws the Circularity . - - Save( me; aFStream: in out FStream from Aspect ) is virtual; - -end Circularity from Prs2d; diff --git a/src/Prs2d/Prs2d_Circularity.cxx b/src/Prs2d/Prs2d_Circularity.cxx deleted file mode 100755 index 8604015ccc..0000000000 --- a/src/Prs2d/Prs2d_Circularity.cxx +++ /dev/null @@ -1,68 +0,0 @@ -// Copyright (c) 1999-2012 OPEN CASCADE SAS -// -// The content of this file is subject to the Open CASCADE Technology Public -// License Version 6.5 (the "License"). You may not use the content of this file -// except in compliance with the License. Please obtain a copy of the License -// at http://www.opencascade.org and read it completely before using this file. -// -// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its -// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. -// -// The Original Code and all software distributed under the License is -// distributed on an "AS IS" basis, without warranty of any kind, and the -// Initial Developer hereby disclaims all such warranties, including without -// limitation, any warranties of merchantability, fitness for a particular -// purpose or non-infringement. Please see the License for the specific terms -// and conditions governing the rights and limitations under the License. - -#include - -Prs2d_Circularity::Prs2d_Circularity( const Handle(Graphic2d_GraphicObject)& aGO, - const Standard_Real aX, - const Standard_Real aY, - const Standard_Real aLength, - const Standard_Real anAngle ) - - : Prs2d_Tolerance( aGO, aX, aY, aLength, anAngle ) -{ -} - -void Prs2d_Circularity::Draw( const Handle(Graphic2d_Drawer)& aDrawer ) { - - Standard_Boolean IsIn = Standard_False; - - if ( !myGOPtr->IsTransformed() ) - IsIn = aDrawer->IsIn( myMinX, myMaxX, myMinY, myMaxY ); - else { - Standard_ShortReal minx, miny, maxx, maxy; - MinMax( minx, maxx, miny, maxy ); - IsIn = aDrawer->IsIn( minx, maxx, miny, maxy ); - } - - if ( IsIn ) { - - DrawLineAttrib( aDrawer ); - Standard_ShortReal X1 = Standard_ShortReal( myX ), - Y1 = Standard_ShortReal( myY ); - gp_Pnt2d P1( X1, Y1 ), - PR( myX, myY ); - P1.Rotate( PR, myAngle ); - X1 = Standard_ShortReal( P1.X() ); - Y1 = Standard_ShortReal( P1.Y() ); - - if ( myGOPtr->IsTransformed () ) { - gp_GTrsf2d aTrsf = myGOPtr->Transform (); - Standard_Real a1, b1; - a1 = X1; - b1 = Y1; - aTrsf.Transforms( a1, b1 ); - X1 = Standard_ShortReal( a1 ); - Y1 = Standard_ShortReal( b1 ); - } - aDrawer->MapArcFromTo( X1, Y1, myLength/2, 0.0, Standard_ShortReal( 2. * M_PI ) ); - } -} - -void Prs2d_Circularity::Save(Aspect_FStream& aFStream) const -{ -} diff --git a/src/Prs2d/Prs2d_Concentric.cdl b/src/Prs2d/Prs2d_Concentric.cdl deleted file mode 100755 index ee2bf1a38f..0000000000 --- a/src/Prs2d/Prs2d_Concentric.cdl +++ /dev/null @@ -1,54 +0,0 @@ --- Created by: TCL --- Copyright (c) 2000-2012 OPEN CASCADE SAS --- --- The content of this file is subject to the Open CASCADE Technology Public --- License Version 6.5 (the "License"). You may not use the content of this file --- except in compliance with the License. Please obtain a copy of the License --- at http://www.opencascade.org and read it completely before using this file. --- --- The Initial Developer of the Original Code is Open CASCADE S.A.S., having its --- main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. --- --- The Original Code and all software distributed under the License is --- distributed on an "AS IS" basis, without warranty of any kind, and the --- Initial Developer hereby disclaims all such warranties, including without --- limitation, any warranties of merchantability, fitness for a particular --- purpose or non-infringement. Please see the License for the specific terms --- and conditions governing the rights and limitations under the License. - - -class Concentric from Prs2d inherits Tolerance from Prs2d - -uses - - GraphicObject from Graphic2d, - Drawer from Graphic2d, - Length from Quantity, - FStream from Aspect - -is - ------------------------- - -- Category: Constructors - ------------------------- - - Create( aGO : GraphicObject from Graphic2d; - aX, aY : Real from Standard; - aLength : Real from Standard = 3.0; - anAngle : Real from Standard = 0.0 ); - ---Level: Public - ---Purpose: Creates a tolerance Concentric with the center at , ; - -- length of this is ; - -- reference point is , - ---Category: Constructor - - -------------------------- - -- Category: Draw and Pick - -------------------------- - - Draw( me : mutable; aDrawer: Drawer from Graphic2d ) is static protected; - ---Level: Internal - ---Purpose: Draws the Concentric . - - Save( me; aFStream: in out FStream from Aspect ) is virtual; - -end Concentric from Prs2d; diff --git a/src/Prs2d/Prs2d_Concentric.cxx b/src/Prs2d/Prs2d_Concentric.cxx deleted file mode 100755 index b3f58facc2..0000000000 --- a/src/Prs2d/Prs2d_Concentric.cxx +++ /dev/null @@ -1,70 +0,0 @@ -// Copyright (c) 1999-2012 OPEN CASCADE SAS -// -// The content of this file is subject to the Open CASCADE Technology Public -// License Version 6.5 (the "License"). You may not use the content of this file -// except in compliance with the License. Please obtain a copy of the License -// at http://www.opencascade.org and read it completely before using this file. -// -// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its -// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. -// -// The Original Code and all software distributed under the License is -// distributed on an "AS IS" basis, without warranty of any kind, and the -// Initial Developer hereby disclaims all such warranties, including without -// limitation, any warranties of merchantability, fitness for a particular -// purpose or non-infringement. Please see the License for the specific terms -// and conditions governing the rights and limitations under the License. - -#include - -Prs2d_Concentric::Prs2d_Concentric( const Handle(Graphic2d_GraphicObject)& aGO, - const Standard_Real aX, - const Standard_Real aY, - const Standard_Real aLength, - const Standard_Real anAngle ) - - : Prs2d_Tolerance( aGO, aX, aY, aLength, anAngle ) -{ -} - -void Prs2d_Concentric::Draw( const Handle(Graphic2d_Drawer)& aDrawer ) { - - Standard_Boolean IsIn = Standard_False; - - if ( !myGOPtr->IsTransformed() ) - IsIn = aDrawer->IsIn( myMinX, myMaxX, myMinY, myMaxY ); - else { - Standard_ShortReal minx, miny, maxx, maxy; - MinMax( minx, maxx, miny, maxy ); - IsIn = aDrawer->IsIn( minx, maxx, miny, maxy ); - } - - if ( IsIn ) { - - DrawLineAttrib( aDrawer ); - Standard_ShortReal X1 = Standard_ShortReal( myX ), - Y1 = Standard_ShortReal( myY ); - gp_Pnt2d P1( X1, Y1 ), - PR( myX, myY ); - P1.Rotate( PR, myAngle ); - X1 = Standard_ShortReal( P1.X() ); - Y1 = Standard_ShortReal( P1.Y() ); - - if ( myGOPtr->IsTransformed () ) { - gp_GTrsf2d aTrsf = myGOPtr->Transform (); - Standard_Real a1, b1; - a1 = X1; - b1 = Y1; - aTrsf.Transforms( a1, b1 ); - X1 = Standard_ShortReal( a1 ); - Y1 = Standard_ShortReal( b1 ); - } - aDrawer->MapArcFromTo( X1, Y1, myLength/2, 0.0, Standard_ShortReal( 2. * M_PI ) ); - aDrawer->MapArcFromTo( X1, Y1, myLength/3, 0.0, Standard_ShortReal( 2. * M_PI ) ); - } - -} - -void Prs2d_Concentric::Save(Aspect_FStream& aFStream) const -{ -} diff --git a/src/Prs2d/Prs2d_Cylindric.cdl b/src/Prs2d/Prs2d_Cylindric.cdl deleted file mode 100755 index 4c10e3ce5b..0000000000 --- a/src/Prs2d/Prs2d_Cylindric.cdl +++ /dev/null @@ -1,54 +0,0 @@ --- Created by: TCL --- Copyright (c) 2000-2012 OPEN CASCADE SAS --- --- The content of this file is subject to the Open CASCADE Technology Public --- License Version 6.5 (the "License"). You may not use the content of this file --- except in compliance with the License. Please obtain a copy of the License --- at http://www.opencascade.org and read it completely before using this file. --- --- The Initial Developer of the Original Code is Open CASCADE S.A.S., having its --- main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. --- --- The Original Code and all software distributed under the License is --- distributed on an "AS IS" basis, without warranty of any kind, and the --- Initial Developer hereby disclaims all such warranties, including without --- limitation, any warranties of merchantability, fitness for a particular --- purpose or non-infringement. Please see the License for the specific terms --- and conditions governing the rights and limitations under the License. - - -class Cylindric from Prs2d inherits Tolerance from Prs2d - -uses - - GraphicObject from Graphic2d, - Drawer from Graphic2d, - Length from Quantity, - FStream from Aspect - -is - ------------------------- - -- Category: Constructors - ------------------------- - - Create( aGO : GraphicObject from Graphic2d; - aX, aY : Real from Standard; - aLength : Real from Standard = 3.0; - anAngle : Real from Standard = 0.0 ); - ---Level: Public - ---Purpose: Creates a tolerance Cylindric with the center at , ; - -- length of this is ; - -- reference point is , - ---Category: Constructor - - -------------------------- - -- Category: Draw and Pick - -------------------------- - - Draw( me : mutable; aDrawer: Drawer from Graphic2d ) is static protected; - ---Level: Internal - ---Purpose: Draws the Cylindric . - - Save( me; aFStream: in out FStream from Aspect ) is virtual; - -end Cylindric from Prs2d; diff --git a/src/Prs2d/Prs2d_Cylindric.cxx b/src/Prs2d/Prs2d_Cylindric.cxx deleted file mode 100755 index 06f535fca3..0000000000 --- a/src/Prs2d/Prs2d_Cylindric.cxx +++ /dev/null @@ -1,120 +0,0 @@ -// Copyright (c) 1999-2012 OPEN CASCADE SAS -// -// The content of this file is subject to the Open CASCADE Technology Public -// License Version 6.5 (the "License"). You may not use the content of this file -// except in compliance with the License. Please obtain a copy of the License -// at http://www.opencascade.org and read it completely before using this file. -// -// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its -// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. -// -// The Original Code and all software distributed under the License is -// distributed on an "AS IS" basis, without warranty of any kind, and the -// Initial Developer hereby disclaims all such warranties, including without -// limitation, any warranties of merchantability, fitness for a particular -// purpose or non-infringement. Please see the License for the specific terms -// and conditions governing the rights and limitations under the License. - -#include - -Prs2d_Cylindric::Prs2d_Cylindric( const Handle(Graphic2d_GraphicObject)& aGO, - const Standard_Real aX, - const Standard_Real aY, - const Standard_Real aLength, - const Standard_Real anAngle ) - - : Prs2d_Tolerance( aGO, aX, aY, aLength, anAngle ) -{ -} - -void Prs2d_Cylindric::Draw( const Handle(Graphic2d_Drawer)& aDrawer ) { - - Standard_Boolean IsIn = Standard_False; - - if ( !myGOPtr->IsTransformed() ) - IsIn = aDrawer->IsIn( myMinX, myMaxX, myMinY, myMaxY ); - else { - Standard_ShortReal minx, miny, maxx, maxy; - MinMax( minx, maxx, miny, maxy ); - IsIn = aDrawer->IsIn( minx, maxx, miny, maxy ); - } - - if ( IsIn ) { - DrawLineAttrib( aDrawer ); - - Standard_ShortReal X1 = Standard_ShortReal( myX - myLength/2 ), - Y1 = Standard_ShortReal( myY - myLength/2 ), - X4 = Standard_ShortReal( myX + myLength/2 ), - Y4 = Y1, - X2 = Standard_ShortReal( X1 + myLength/2 ), - Y2 = Standard_ShortReal( myY + myLength/2 ), - - X3 = Standard_ShortReal( X4 + myLength/2 ), - Y3 = Y2; - gp_Pnt2d thePnt1( X1, Y1); - gp_Vec2d theVec( thePnt1, gp_Pnt2d( X3, Y3 ) ); - theVec /= 2; - thePnt1.Translate( theVec ); - Standard_ShortReal theRad = Standard_ShortReal( myLength/2*Sin(M_PI / 3) ); - Standard_ShortReal Xc = Standard_ShortReal(thePnt1.X()), - Yc = Standard_ShortReal(thePnt1.Y()); - - gp_Pnt2d P1( X1, Y1 ), - P2( X2, Y2 ), - P3( X3, Y3 ), - P4( X4, Y4 ), - PC( Xc, Yc ), - PR( myX, myY ); - P1.Rotate( PR, myAngle ); - P2.Rotate( PR, myAngle ); - P3.Rotate( PR, myAngle ); - P4.Rotate( PR, myAngle ); - PC.Rotate( PR, myAngle ); - X1 = Standard_ShortReal( P1.X() ); - Y1 = Standard_ShortReal( P1.Y() ); - X2 = Standard_ShortReal( P2.X() ); - Y2 = Standard_ShortReal( P2.Y() ); - X3 = Standard_ShortReal( P3.X() ); - Y3 = Standard_ShortReal( P3.Y() ); - X4 = Standard_ShortReal( P4.X() ); - Y4 = Standard_ShortReal( P4.Y() ); - Xc = Standard_ShortReal( PC.X() ); - Yc = Standard_ShortReal( PC.Y() ); - if ( myGOPtr->IsTransformed () ) { - gp_GTrsf2d aTrsf = myGOPtr->Transform (); - Standard_Real a1, b1; - a1 = X1; - b1 = Y1; - aTrsf.Transforms( a1, b1 ); - X1 = Standard_ShortReal( a1 ); - Y1 = Standard_ShortReal( b1 ); - a1 = X2; - b1 = Y2; - aTrsf.Transforms( a1, b1 ); - X2 = Standard_ShortReal( a1 ); - Y2 = Standard_ShortReal( b1 ); - a1 = X3; - b1 = Y3; - aTrsf.Transforms( a1, b1 ); - X3 = Standard_ShortReal( a1 ); - Y3 = Standard_ShortReal( b1 ); - a1 = X4; - b1 = Y4; - aTrsf.Transforms( a1, b1 ); - X4 = Standard_ShortReal( a1 ); - Y4 = Standard_ShortReal( b1 ); - a1 = Xc; - b1 = Yc; - aTrsf.Transforms( a1, b1 ); - Xc = Standard_ShortReal( a1 ); - Yc = Standard_ShortReal( b1 ); - } - aDrawer->MapSegmentFromTo( X1, Y1, X2, Y2 ); - aDrawer->MapSegmentFromTo( X4, Y4, X3, Y3 ); - aDrawer->MapArcFromTo( Xc, Yc, theRad, 0.0, Standard_ShortReal( 2. * M_PI ) ); - } -} - -void Prs2d_Cylindric::Save(Aspect_FStream& aFStream) const -{ -} diff --git a/src/Prs2d/Prs2d_Diameter.cdl b/src/Prs2d/Prs2d_Diameter.cdl deleted file mode 100755 index f36a49b4f2..0000000000 --- a/src/Prs2d/Prs2d_Diameter.cdl +++ /dev/null @@ -1,118 +0,0 @@ --- Created by: Tanya COOL --- Copyright (c) 2000-2012 OPEN CASCADE SAS --- --- The content of this file is subject to the Open CASCADE Technology Public --- License Version 6.5 (the "License"). You may not use the content of this file --- except in compliance with the License. Please obtain a copy of the License --- at http://www.opencascade.org and read it completely before using this file. --- --- The Initial Developer of the Original Code is Open CASCADE S.A.S., having its --- main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. --- --- The Original Code and all software distributed under the License is --- distributed on an "AS IS" basis, without warranty of any kind, and the --- Initial Developer hereby disclaims all such warranties, including without --- limitation, any warranties of merchantability, fitness for a particular --- purpose or non-infringement. Please see the License for the specific terms --- and conditions governing the rights and limitations under the License. - - -class Diameter from Prs2d inherits Dimension from Prs2d - - ---Purpose: Constructs the primitive Radius - -uses - - Drawer from Graphic2d, - GraphicObject from Graphic2d, - Pnt2d from gp, - Circ2d from gp, - ExtendedString from TCollection, - ArrowSide from Prs2d, - TypeOfDist from Prs2d, - TypeOfArrow from Prs2d, - FStream from Aspect - -raises - - ConstructionError from Standard - -is - Create( aGraphicObject: GraphicObject from Graphic2d; - anAttachPnt : Pnt2d from gp; - aCircle : Circ2d from gp; - aText : ExtendedString from TCollection; - aTxtScale : Real from Standard = 10.0; - anArrAngle : Real from Standard = 20.0; - anArrLength : Real from Standard = 25.0; - anArrType : TypeOfArrow from Prs2d = Prs2d_TOA_OPENED; - anArrow : ArrowSide from Prs2d = Prs2d_AS_BOTHAR; - IsReverseArrow: Boolean from Standard = Standard_False ) - - returns mutable Diameter from Prs2d; - - ---Purpose: Creates the radius of the circle passing through - -- the point - - -------------------------------------- - -- Category: Inquire methods - -------------------------------------- - - Values( me; anAttPnt: out Pnt2d from gp; - aCirc: out Circ2d from gp ); - ---Level: Internal - ---Purpose: allows to get the properties of the diameter - - -------------------------- - -- Category: Draw and Pick - -------------------------- - - Draw( me : mutable; aDrawer: Drawer from Graphic2d ) - is static protected; - ---Level: Internal - ---Purpose: Draws the angle . - - DrawElement( me : mutable; aDrawer: Drawer from Graphic2d; - anIndex: Integer from Standard) - is redefined protected; - ---Level: Internal - ---Purpose: Draws element of the diameter . - - DrawVertex( me : mutable; aDrawer: Drawer from Graphic2d; - anIndex: Integer from Standard) - is redefined protected; - ---Level: Internal - ---Purpose: Draws vertex of the diameter . - - Pick( me : mutable; X, Y: ShortReal from Standard; - aPrecision: ShortReal from Standard; - aDrawer: Drawer from Graphic2d) - returns Boolean from Standard - is static protected; - ---Level: Internal - ---Purpose: Returns Standard_True if the diameter is picked, - -- Standard_False if not. - - Save( me; aFStream: in out FStream from Aspect ) is virtual; - - - CalcTxtPos(me:mutable; theFromAbs: - Boolean from Standard=Standard_False) - ---C++: inline - is redefined protected; - -fields - - myX1 : ShortReal from Standard; - myY1 : ShortReal from Standard; - myX2 : ShortReal from Standard; - myY2 : ShortReal from Standard; - myPnt : Pnt2d from gp; - myCirc : Circ2d from gp; ---enk fields. Coordinates of appendix. - myAppX1 : ShortReal from Standard; - myAppY1 : ShortReal from Standard; - myAppX2 : ShortReal from Standard; - myAppY2 : ShortReal from Standard; - myInside : Boolean from Standard; -end Diameter from Prs2d; diff --git a/src/Prs2d/Prs2d_Diameter.cxx b/src/Prs2d/Prs2d_Diameter.cxx deleted file mode 100755 index 174988149d..0000000000 --- a/src/Prs2d/Prs2d_Diameter.cxx +++ /dev/null @@ -1,674 +0,0 @@ -// Copyright (c) 1999-2012 OPEN CASCADE SAS -// -// The content of this file is subject to the Open CASCADE Technology Public -// License Version 6.5 (the "License"). You may not use the content of this file -// except in compliance with the License. Please obtain a copy of the License -// at http://www.opencascade.org and read it completely before using this file. -// -// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its -// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. -// -// The Original Code and all software distributed under the License is -// distributed on an "AS IS" basis, without warranty of any kind, and the -// Initial Developer hereby disclaims all such warranties, including without -// limitation, any warranties of merchantability, fitness for a particular -// purpose or non-infringement. Please see the License for the specific terms -// and conditions governing the rights and limitations under the License. - -#include -#include - -#define VERTEXMARKER 2 -#define DEFAULTMARKERSIZE 3.0 -#define XROTATE(x,y) ((x)*cosa - (y)*sina) -#define YROTATE(x,y) ((y)*cosa + (x)*sina) -#define ADDPIX 17 -#define APPENDIXLEN 4 - -Prs2d_Diameter::Prs2d_Diameter( const Handle(Graphic2d_GraphicObject)& aGO, - const gp_Pnt2d & anAttachPnt, - const gp_Circ2d & aCircle, - const TCollection_ExtendedString & aText, - const Standard_Real aTxtScale, - const Standard_Real anArrAngle, - const Standard_Real anArrLength, - const Prs2d_TypeOfArrow anArrType, - const Prs2d_ArrowSide anArrow, - const Standard_Boolean IsRevArrow ) - - : Prs2d_Dimension( aGO, aText, aTxtScale, anArrAngle, - anArrLength, anArrType, anArrow, IsRevArrow ), - myPnt( anAttachPnt ), - myCirc( aCircle ) - -{ - gp_Pnt2d aPnt1 = anAttachPnt, aPnt2 = aCircle.Location(); - Standard_Real U = ElCLib::Parameter( aCircle, aPnt1 ); - - gp_Pnt2d PTonCirc = ElCLib::Value( U, aCircle ); - - gp_Vec2d theVec( PTonCirc, aPnt2 ); - Standard_Real theDist = aPnt2.Distance( aPnt1 ), - theRad = aCircle.Radius(); - Standard_Boolean inside = Standard_False; - myInside=Standard_False; - - if ( theDist < theRad ) { - aPnt1 = PTonCirc; - theDist = theRad; - inside = Standard_True; - myInside = Standard_True; - } - - gp_Vec2d VX( 1., 0. ), VDir; - - theVec.Normalize(); - theVec *= ( theDist + theRad ); - aPnt2 = aPnt1.Translated( theVec ); - - gp_Pnt2d tP1 = aPnt1, tP2 = aPnt2; - - if ( IsRevArrow ) { - theVec.Normalize(); - theVec *= ( 1.3 * myArrowLen ); - tP1.Translate( -theVec ); - tP2.Translate( theVec ); - } - - Standard_Real X1, Y1, X2, Y2; - tP1.Coord( X1, Y1 ); - tP2.Coord( X2, Y2 ); - - myX1 = Standard_ShortReal( X1 ); - myY1 = Standard_ShortReal( Y1 ); - myX2 = Standard_ShortReal( X2 ); - myY2 = Standard_ShortReal( Y2 ); - myMinX = myX1; - myMinY = myY1; - myMaxX = myX1; - myMaxY = myY1; - -// bound of appendix -// enk code - if (!myInside) { - myAppX1 = Standard_ShortReal(X1); - myAppY1 = Standard_ShortReal(Y1); - myAppX2 = Standard_ShortReal(X1); - myAppY2 = Standard_ShortReal(Y1); - if (myX1>=myX2) - myAppX2=Standard_ShortReal( myAppX2+(theDist+theRad)/APPENDIXLEN ); - else - myAppX2=Standard_ShortReal( myAppX2-(theDist+theRad)/APPENDIXLEN ); - - if ( myAppX2 < myMinX ) myMinX = myAppX2; - if ( myAppY2 < myMinY ) myMinY = myAppY2; - if ( myAppX2 > myMaxX ) myMaxX = myAppX2; - if ( myAppY2 > myMaxY ) myMaxY = myAppY2; - - Standard_ShortReal tmpX=myAppX1; - - if (tmpX>myAppX2) - { - myAppX1=myAppX2; - myAppX2=tmpX; - } - - } - // end enk code - -// boun of text -// enk code - Standard_ShortReal theTxtX1,theTxtY1,theTxtX2,theTxtY2; - Standard_ShortReal theTxtX3,theTxtY3,theTxtX4,theTxtY4; - Standard_Integer theTxtNum=aText.Length(); - Standard_Real theTxtLen=theTxtNum*myTextScale; - - theTxtX1 = myAbsX; - theTxtY1 = myAbsY; - theTxtX2 = theTxtX1+theTxtLen*cos(myAbsAngle); - theTxtY2 = theTxtY1+theTxtLen*sin(myAbsAngle); - theTxtX3 = theTxtX1-myTextScale*sin(myAbsAngle); - theTxtY3 = theTxtY1+myTextScale*cos(myAbsAngle); - theTxtX4 = theTxtX3+theTxtLen*cos(myAbsAngle); - theTxtY4 = theTxtY3+theTxtLen*sin(myAbsAngle); - - if (theTxtX1 < myMinX) myMinX = theTxtX1; - if (theTxtY1 < myMinY) myMinY = theTxtY1; - if (theTxtX1 > myMaxX) myMaxX = theTxtX1; - if (theTxtY1 > myMaxY) myMaxY = theTxtY1; - - if (theTxtX2 < myMinX) myMinX = theTxtX2; - if (theTxtY2 < myMinY) myMinY = theTxtY2; - if (theTxtX2 > myMaxX) myMaxX = theTxtX2; - if (theTxtY2 > myMaxY) myMaxY = theTxtY2; - - if (theTxtX3 < myMinX) myMinX = theTxtX3; - if (theTxtY3 < myMinY) myMinY = theTxtY3; - if (theTxtX3 > myMaxX) myMaxX = theTxtX3; - if (theTxtY3 > myMaxY) myMaxY = theTxtY3; - - if (theTxtX4 < myMinX) myMinX = theTxtX4; - if (theTxtY4 < myMinY) myMinY = theTxtY4; - if (theTxtX4 > myMaxX) myMaxX = theTxtX4; - if (theTxtY4 > myMaxY) myMaxY = theTxtY4; -// end enk code - if ( myX2 < myMinX ) myMinX = myX2; - if ( myY2 < myMinY ) myMinY = myY2; - if ( myX2 > myMaxX ) myMaxX = myX2; - if ( myY2 > myMaxY ) myMaxY = myY2; - - Standard_Real ArrAngle = M_PI/180.* anArrAngle, theAngle; - gp_Pnt2d theOrigine( 0., 0.), P1, P2, P3; - - if ( ( myArrow == Prs2d_AS_FIRSTAR ) || ( myArrow == Prs2d_AS_BOTHAR ) ) { - // enk code - gp_Vec2d theTmpVec(aPnt1,PTonCirc); - gp_Pnt2d theTmpPnt=aPnt1.Translated(theTmpVec); - P1=theTmpPnt; - // end enk code - // P1 = aPnt1; - - P2 = gp_Pnt2d( anArrLength, anArrLength*Tan( ArrAngle/2. ) ); - P3 = gp_Pnt2d( anArrLength, -anArrLength*Tan( ArrAngle/2. ) ); - - VDir = gp_Vec2d( aPnt1, aPnt2 ); - if ( IsRevArrow ) VDir.Reverse(); - - theAngle = VX.Angle( VDir ); - - P2.Rotate( theOrigine, theAngle ); - P3.Rotate( theOrigine, theAngle ); - - P2.Translate( gp_Vec2d( theOrigine, P1 ) ); - P3.Translate( gp_Vec2d( theOrigine, P1 ) ); - - myXVert1(1) = Standard_ShortReal( P2.X() ); - myYVert1(1) = Standard_ShortReal( P2.Y() ); - myXVert1(2) = Standard_ShortReal( P1.X() ); - myYVert1(2) = Standard_ShortReal( P1.Y() ); - myXVert1(3) = Standard_ShortReal( P3.X() ); - myYVert1(3) = Standard_ShortReal( P3.Y() ); - - for ( Standard_Integer i = 1; i <= 3; i++ ) { - if ( myXVert1(i) < myMinX ) myMinX = myXVert1(i); - if ( myYVert1(i) < myMinY ) myMinY = myYVert1(i); - if ( myXVert1(i) > myMaxX ) myMaxX = myXVert1(i); - if ( myYVert1(i) > myMaxY ) myMaxY = myYVert1(i); - - } - } // end if myArrow is FIRSTAR or BOTHAR - - if ( ( myArrow == Prs2d_AS_LASTAR ) || ( myArrow == Prs2d_AS_BOTHAR ) ){ - P1 = aPnt2; - P2 = gp_Pnt2d( anArrLength, anArrLength * Tan( ArrAngle/2. ) ); - P3 = gp_Pnt2d( anArrLength, -anArrLength * Tan( ArrAngle/2. ) ); - - VDir = gp_Vec2d( aPnt2, aPnt1 ); - if ( IsRevArrow ) VDir.Reverse(); - - theAngle = VX.Angle( VDir ); - - P2.Rotate( theOrigine, theAngle ); - P3.Rotate( theOrigine, theAngle ); - - P2.Translate( gp_Vec2d( theOrigine, P1 ) ); - P3.Translate( gp_Vec2d( theOrigine, P1 ) ); - - myXVert2(1) = Standard_ShortReal( P2.X() ); - myYVert2(1) = Standard_ShortReal( P2.Y() ); - myXVert2(2) = Standard_ShortReal( P1.X() ); - myYVert2(2) = Standard_ShortReal( P1.Y() ); - myXVert2(3) = Standard_ShortReal( P3.X() ); - myYVert2(3) = Standard_ShortReal( P3.Y() ); - - for ( Standard_Integer i = 1; i <= 3; i++ ) { - - if ( myXVert2(i) < myMinX ) myMinX = myXVert2(i); - if ( myYVert2(i) < myMinY ) myMinY = myYVert2(i); - if ( myXVert2(i) > myMaxX ) myMaxX = myXVert2(i); - if ( myYVert2(i) > myMaxY ) myMaxY = myYVert2(i); - - } - } // end if myArrow is FIRSTAR or BOTHAR - - myNumOfElem = 5; - if (myInside) - myNumOfElem = 4; - myNumOfVert = 2; - -} - -void Prs2d_Diameter::Values( gp_Pnt2d& anAttPnt,gp_Circ2d& aCirc ) const { - anAttPnt = myPnt; - aCirc = myCirc; -} - -void Prs2d_Diameter::Draw( const Handle(Graphic2d_Drawer)& aDrawer ) { - - Standard_Boolean IsIn = Standard_False; - - if (! myGOPtr->IsTransformed ()) - IsIn = aDrawer->IsIn (myMinX,myMaxX,myMinY,myMaxY); - else { - Standard_ShortReal minx, miny, maxx, maxy; - MinMax(minx,maxx,miny,maxy); - IsIn = aDrawer->IsIn (minx,maxx,miny,maxy); - } - - if ( IsIn ) { - - DrawLineAttrib( aDrawer ); - aDrawer->SetTextAttrib( myColorIndex, myTextFont, 0, Standard_ShortReal(myTextScale*aDrawer->Scale()), - Standard_ShortReal(myTextScale*aDrawer->Scale()), Standard_False ); - - /*Standard_ShortReal dxx = aDrawer->Convert(ADDPIX); - gp_Pnt2d thePnt1(myX1,myY1+dxx), thePnt2(myX2,myY2+dxx); - gp_Vec2d VX( 1., 0. ), theVec(thePnt2, thePnt1); - Standard_Real theTxtAngle = VX.Angle( theVec ); - gp_Pnt2d pntText; - if ( theTxtAngle >= 0 && theTxtAngle <= M_PI/2 ) - pntText = thePnt2.Translated( (myArrowLen+dxx)*theVec/(thePnt1.Distance(thePnt2)) ); - else if ( theTxtAngle > M_PI/2 && theTxtAngle <= M_PI ) { - pntText = thePnt1.Translated( (myArrowLen+dxx)*theVec.Reversed()/(thePnt1.Distance(thePnt2)) ); - theTxtAngle = VX.Angle( theVec.Reversed() ); - } else if ( theTxtAngle >= -M_PI/2 && theTxtAngle < 0 ) - pntText = thePnt2.Translated( (myArrowLen+dxx)*theVec/(thePnt1.Distance(thePnt2)) ); - else if ( theTxtAngle >= -M_PI && theTxtAngle < -M_PI/2 ) { - pntText = thePnt1.Translated( (myArrowLen+dxx)*theVec.Reversed()/(thePnt1.Distance(thePnt2)) ); - theTxtAngle = VX.Angle( theVec.Reversed() ); - } - Standard_Real theTxtX, theTxtY; - pntText.Coord( theTxtX, theTxtY );*/ //correct by enk Mon Dec 2 11:53 2002 - - ////////////////////////////////////////////////// - Standard_Real theTxtX, theTxtY,theTxtAngle; - gp_Pnt2d thePnt1(myX1,myY1), thePnt2(myX2,myY2); - gp_Vec2d VX(1.,0.), theVec(thePnt2,thePnt1); - theVec.Rotate(myTextAngle); - theTxtX=myAbsX; - theTxtY=myAbsY; - theTxtAngle=myAbsAngle; - gp_Pnt2d pntText(theTxtX,theTxtY); - ////////////////////////////////////////////////// - - Standard_ShortReal a = myX1, b = myY1, c = myX2, d = myY2, - t1 = Standard_ShortReal(theTxtX), t2 = Standard_ShortReal(theTxtY); - - TShort_Array1OfShortReal Xpoint1( 1, 3 ), Ypoint1( 1, 3 ), - Xpoint2( 1, 3 ), Ypoint2( 1, 3 ); - - - if ( myGOPtr->IsTransformed () ) { - gp_GTrsf2d aTrsf = myGOPtr->Transform (); - - if ( ( myArrow == Prs2d_AS_FIRSTAR ) || ( myArrow == Prs2d_AS_BOTHAR ) ){ - - Standard_Real a1, b1; - for ( Standard_Integer j = 1; j <= 3; j++ ) { - a1 = Standard_Real( myXVert1(j) ); - b1 = Standard_Real( myYVert1(j) ); - aTrsf.Transforms (a1, b1); - Xpoint1(j) = Standard_ShortReal(a1); - Ypoint1(j) = Standard_ShortReal(b1); - } - } // end if myArrow is FIRSTAR ot BOTHAR - - if ( ( myArrow == Prs2d_AS_LASTAR ) || ( myArrow == Prs2d_AS_BOTHAR ) ) { - - Standard_Real c1, d1; - - for ( Standard_Integer j = 1; j <= 3; j++ ) { - c1 = Standard_Real( myXVert2(j) ); - d1 = Standard_Real( myYVert2(j) ); - aTrsf.Transforms (c1, d1); - Xpoint2(j) = Standard_ShortReal(c1); - Ypoint2(j) = Standard_ShortReal(d1); - } - } // end if myArrow is LASTAR ot BOTHAR - - Standard_Real A, B, C, D, T1, T2; - A = Standard_Real( a ); - B = Standard_Real( b ); - C = Standard_Real( c ); - D = Standard_Real( d ); - T1 = Standard_Real( t1 ); - T2= Standard_Real( t2); - aTrsf.Transforms( A, B ); - aTrsf.Transforms( C, D ); - aTrsf.Transforms( T1, T2 ); - a = Standard_ShortReal( A ); - b = Standard_ShortReal( B ); - c = Standard_ShortReal( C ); - d = Standard_ShortReal( D ); - t1 = Standard_ShortReal( T1 ); - t2 = Standard_ShortReal( T2 ); - - } else { - - if ( ( myArrow == Prs2d_AS_FIRSTAR ) || ( myArrow == Prs2d_AS_BOTHAR ) ){ - Xpoint1.Assign( myXVert1 ); - Ypoint1.Assign( myYVert1 ); - } - if ( ( myArrow == Prs2d_AS_LASTAR ) || ( myArrow == Prs2d_AS_BOTHAR ) ) { - Xpoint2.Assign( myXVert2 ); - Ypoint2.Assign( myYVert2 ); - } - - } // end if GO is transformed - -// drawing diameter dimension - aDrawer->MapSegmentFromTo( a, b, c, d); -// enk code - if (!myInside) - aDrawer->MapSegmentFromTo(myAppX1,myAppY1,myAppX2,myAppY2); -// end enk code - - aDrawer->MapTextFromTo( myText, t1, t2, Standard_ShortReal(theTxtAngle), 0., 0., Aspect_TOT_SOLID ); - - if ( ( myArrow == Prs2d_AS_FIRSTAR ) || ( myArrow == Prs2d_AS_BOTHAR ) ){ - if ( myArrType == Prs2d_TOA_CLOSED || myArrType == Prs2d_TOA_FILLED ) { - aDrawer->MapPolygonFromTo( Xpoint1, Ypoint1 ); - } else { - aDrawer->MapPolylineFromTo( Xpoint1, Ypoint1 ); - } - } - - if ( ( myArrow == Prs2d_AS_LASTAR ) || ( myArrow == Prs2d_AS_BOTHAR ) ){ - if ( myArrType == Prs2d_TOA_CLOSED || myArrType == Prs2d_TOA_FILLED ) { - aDrawer->MapPolygonFromTo( Xpoint2, Ypoint2 ); - } else { - aDrawer->MapPolylineFromTo( Xpoint2, Ypoint2 ); - } - } - - - } // end if IsIn is true - -} - -void Prs2d_Diameter::DrawElement( const Handle(Graphic2d_Drawer)& aDrawer, - const Standard_Integer anIndex ) { - Standard_Boolean IsIn = Standard_False; - - if ( ! myGOPtr->IsTransformed() ) - IsIn = aDrawer->IsIn( myMinX, myMaxX, myMinY, myMaxY ); - else { - Standard_ShortReal minx, miny, maxx, maxy; - MinMax( minx, maxx, miny, maxy ); - IsIn = aDrawer->IsIn( minx, maxx, miny, maxy ); - } - - if ( IsIn ) { - - DrawLineAttrib( aDrawer ); - /*Standard_ShortReal dxx = aDrawer->Convert(ADDPIX); - gp_Pnt2d thePnt1(myX1,myY1+dxx), thePnt2(myX2,myY2+dxx); - gp_Vec2d VX( 1., 0. ), theVec(thePnt2, thePnt1); - Standard_Real theTxtAngle = VX.Angle( theVec ); - gp_Pnt2d pntText; - if ( theTxtAngle >= 0 && theTxtAngle <= M_PI/2 ) - pntText = thePnt2.Translated( (myArrowLen+dxx)*theVec/(thePnt1.Distance(thePnt2)) ); - else if ( theTxtAngle > M_PI/2 && theTxtAngle <= M_PI ) { - pntText = thePnt1.Translated( (myArrowLen+dxx)*theVec.Reversed()/(thePnt1.Distance(thePnt2)) ); - theTxtAngle = VX.Angle( theVec.Reversed() ); - } else if ( theTxtAngle >= -M_PI/2 && theTxtAngle < 0 ) - pntText = thePnt2.Translated( (myArrowLen+dxx)*theVec/(thePnt1.Distance(thePnt2)) ); - else if ( theTxtAngle >= -M_PI && theTxtAngle < -M_PI/2 ) { - pntText = thePnt1.Translated( (myArrowLen+dxx)*theVec.Reversed()/(thePnt1.Distance(thePnt2)) ); - theTxtAngle = VX.Angle( theVec.Reversed() ); - } - Standard_Real theTxtX, theTxtY; - pntText.Coord( theTxtX, theTxtY );*/ // correct by enk - - ////////////////////////////////////////////////// - Standard_Real theTxtX, theTxtY,theTxtAngle; - gp_Pnt2d thePnt1(myX1,myY1), thePnt2(myX2,myY2); - gp_Vec2d VX(1.,0.), theVec(thePnt2,thePnt1); - theVec.Rotate(myTextAngle); - theTxtX=myAbsX; - theTxtY=myAbsY; - theTxtAngle=myAbsAngle; - gp_Pnt2d pntText(theTxtX,theTxtY); - ////////////////////////////////////////////////// - - Standard_ShortReal a = myX1, b = myY1, c = myX2, d = myY2, - t1 = Standard_ShortReal(theTxtX), t2 = Standard_ShortReal(theTxtX); - TShort_Array1OfShortReal Xpoint( 1, 3 ), Ypoint( 1, 3 ); - - if ( anIndex == 1 ) { - Xpoint.Assign( myXVert1 ); - Ypoint.Assign( myYVert1 ); - } else if ( anIndex == 2 ) { - Xpoint.Assign( myXVert2 ); - Ypoint.Assign( myYVert2 ); - } - - if ( myGOPtr->IsTransformed () ) { - gp_GTrsf2d aTrsf = myGOPtr->Transform (); - Standard_Real a1, b1, c1, d1; - - if ( anIndex == 1 ) { - for ( Standard_Integer j = 1; j <= 3; j++ ) { - a1 = Standard_Real( Xpoint(j) ); - b1 = Standard_Real( Xpoint(j) ); - aTrsf.Transforms( a1, b1 ); - Xpoint(j) = Standard_ShortReal( a1 ); - Ypoint(j) = Standard_ShortReal( b1 ); - } - } else if ( anIndex == 2 ) { - - for ( Standard_Integer j = 1; j <= 3; j++ ) { - a1 = Standard_Real( Xpoint(j) ); - b1 = Standard_Real( Xpoint(j) ); - aTrsf.Transforms( a1, b1 ); - Xpoint(j) = Standard_ShortReal( a1 ); - Ypoint(j) = Standard_ShortReal( b1 ); - } - } else if ( anIndex == 4 ) { - - a1 = Standard_Real( a ); - b1 = Standard_Real( b ); - c1 = Standard_Real( c ); - d1 = Standard_Real( d ); - aTrsf.Transforms( a1, b1 ); - aTrsf.Transforms( c1, d1 ); - a = Standard_ShortReal( a1 ); - b = Standard_ShortReal( b1 ); - c = Standard_ShortReal( c1 ); - d = Standard_ShortReal( d1 ); - - } - else if ( anIndex == 3 ) - { - a1 = Standard_Real( t1 ); - b1 = Standard_Real( t2); - aTrsf.Transforms( a1, b1 ); - t1 = Standard_ShortReal( a1 ); - t2 = Standard_ShortReal( b1); - } - } - - if ( anIndex == 1 || anIndex == 2 ) - if ( myArrType == Prs2d_TOA_CLOSED || myArrType == Prs2d_TOA_FILLED ) { - aDrawer->MapPolygonFromTo( Xpoint, Ypoint ); - } else { - aDrawer->MapPolylineFromTo( Xpoint, Ypoint ); - } - - else if ( anIndex == 4) - aDrawer->MapSegmentFromTo( a, b, c, d ); - else if ( anIndex == 3 ) - aDrawer->MapTextFromTo( myText, t1, t2, Standard_ShortReal(theTxtAngle), 0., 0., Aspect_TOT_SOLID ); - else if ( !myInside && anIndex == 5) - { - aDrawer->MapSegmentFromTo(myAppX1,myAppY1,myAppX2,myAppY2); - } - - } // end if IsIn is true - - -} - -void Prs2d_Diameter::DrawVertex( const Handle(Graphic2d_Drawer)& aDrawer, - const Standard_Integer anIndex ) { - - Standard_Boolean IsIn = Standard_False; - - if ( ! myGOPtr->IsTransformed() ) - IsIn = aDrawer->IsIn( myMinX, myMaxX, myMinY, myMaxY ); - else { - Standard_ShortReal minx, miny, maxx, maxy; - MinMax( minx, maxx, miny, maxy ); - IsIn = aDrawer->IsIn( minx, maxx, miny, maxy ); - } - if ( IsIn ) { - if ( anIndex == 1 || anIndex == 2 ) { - Standard_ShortReal X=0., Y=0.; - if ( anIndex == 1 ) { - X = myX1; Y = myY1; - } else if ( anIndex == 2 ) { - X = myX2; Y = myY2; - } - DrawMarkerAttrib( aDrawer ); - if ( myGOPtr->IsTransformed() ) { - gp_GTrsf2d aTrsf = myGOPtr->Transform(); - Standard_Real A = Standard_Real( X ), B = Standard_Real( Y ); - aTrsf.Transforms( A, B ); - X = Standard_ShortReal( A ); - Y = Standard_ShortReal( B ); - } - aDrawer->MapMarkerFromTo(VERTEXMARKER,X,Y, DEFAULTMARKERSIZE,DEFAULTMARKERSIZE,0.0); - } - } - -} - -Standard_Boolean Prs2d_Diameter::Pick( const Standard_ShortReal X, - const Standard_ShortReal Y, - const Standard_ShortReal aPrecision, - const Handle(Graphic2d_Drawer)& aDrawer ) { - - Standard_ShortReal SRX = X, SRY = Y; - Standard_Boolean Result = Standard_False; - - if ( IsInMinMax (X, Y, aPrecision) ) { - if ( myGOPtr->IsTransformed () ) { - gp_GTrsf2d aTrsf = ( myGOPtr->Transform() ).Inverted(); - Standard_Real RX = Standard_Real(SRX), RY = Standard_Real(SRY); - aTrsf.Transforms(RX, RY); - SRX = Standard_ShortReal(RX); - SRY = Standard_ShortReal(RY); - } - - if ( Graphic2d_Primitive::IsOn( SRX, SRY, myX1, myY1, aPrecision ) ) { - SetPickedIndex(-1); - return Standard_True; - } else if ( Graphic2d_Primitive::IsOn( SRX, SRY, myX2, myY2, aPrecision ) ) { - SetPickedIndex(-2); - return Standard_True; - } - - if ( ( myArrow == Prs2d_AS_FIRSTAR ) || ( myArrow == Prs2d_AS_BOTHAR ) ) { - for ( Standard_Integer i = 1; i < 3 ; i++) - if ( IsOn( SRX, SRY, myXVert1(i), myYVert1(i), myXVert1(i+1), myYVert1( i+1 ), aPrecision ) ) { - SetPickedIndex(1); - return Standard_True; - } - - if ( myArrType == Prs2d_TOA_CLOSED || myArrType == Prs2d_TOA_FILLED ) - if ( IsIn( SRX, SRY, myXVert1, myYVert1, aPrecision ) ) { - SetPickedIndex(1); - return Standard_True; - } - } // end if myArrow == FIRSTAR or BOTHAR - - if ( ( myArrow == Prs2d_AS_LASTAR ) || ( myArrow == Prs2d_AS_BOTHAR ) ){ - for ( Standard_Integer i = 1; i < 3 ; i++) - if ( IsOn( SRX, SRY, myXVert2(i), myYVert2(i), myXVert2(i+1), myYVert2( i+1 ), aPrecision ) ) { - SetPickedIndex(2); - return Standard_True; - } - - if ( myArrType == Prs2d_TOA_CLOSED || myArrType == Prs2d_TOA_FILLED ) - if ( IsIn( SRX, SRY, myXVert2, myYVert2, aPrecision ) ) { - SetPickedIndex(2); - return Standard_True; - } - } // end if myArrow == LASTAR or BOTHAR - - Standard_ShortReal width,height,xoffset,yoffset; - Standard_ShortReal hscale = Standard_ShortReal(myTextScale*aDrawer->Scale()), - wscale = Standard_ShortReal(myTextScale*aDrawer->Scale()); - Standard_ShortReal TX = X, TY = Y; - - aDrawer->SetTextAttrib( myColorIndex, myTextFont, 0, hscale, wscale, Standard_False ); - if ( !aDrawer->GetTextSize( myText, width, height, xoffset, yoffset ) ) { - width = height = xoffset = yoffset = 0.; - } - /*Standard_ShortReal dxx = aDrawer->Convert(ADDPIX); - gp_Pnt2d thePnt1(myX1,myY1+dxx), thePnt2(myX2,myY2+dxx); - gp_Vec2d VX( 1., 0. ), theVec(thePnt2, thePnt1); - Standard_Real theTxtAngle = VX.Angle( theVec ); - gp_Pnt2d pntText; - if ( theTxtAngle >= 0 && theTxtAngle <= M_PI/2 ) - pntText = thePnt2.Translated( (myArrowLen+dxx)*theVec/(thePnt1.Distance(thePnt2)) ); - else if ( theTxtAngle > M_PI/2 && theTxtAngle <= M_PI ) { - pntText = thePnt1.Translated( (myArrowLen+dxx)*theVec.Reversed()/(thePnt1.Distance(thePnt2)) ); - theTxtAngle = VX.Angle( theVec.Reversed() ); - } else if ( theTxtAngle >= -M_PI/2 && theTxtAngle < 0 ) - pntText = thePnt2.Translated( (myArrowLen+dxx)*theVec/(thePnt1.Distance(thePnt2)) ); - else if ( theTxtAngle >= -M_PI && theTxtAngle < -M_PI/2 ) { - pntText = thePnt1.Translated( (myArrowLen+dxx)*theVec.Reversed()/(thePnt1.Distance(thePnt2)) ); - theTxtAngle = VX.Angle( theVec.Reversed() ); - } - Standard_Real theTxtX, theTxtY; - pntText.Coord( theTxtX, theTxtY );*/ //correct by enk - ////////////////////////////////////////////////// - Standard_Real theTxtX, theTxtY,theTxtAngle; - gp_Pnt2d thePnt1(myX1,myY1), thePnt2(myX2,myY2); - gp_Vec2d VX(1.,0.), theVec(thePnt2,thePnt1); - theVec.Rotate(myTextAngle); - theTxtX=myAbsX; - theTxtY=myAbsY; - theTxtAngle=myAbsAngle; - gp_Pnt2d pntText(theTxtX,theTxtY); - ////////////////////////////////////////////////// - - Standard_ShortReal cosa = Standard_ShortReal(Cos( -theTxtAngle )), - sina = Standard_ShortReal(Sin( -theTxtAngle )), - dx = TX - Standard_ShortReal(theTxtX), - dy = TY - Standard_ShortReal(theTxtY), - x = Standard_ShortReal(XROTATE(dx,dy)), - y = Standard_ShortReal(YROTATE(dx,dy)); - - Result = (x >= -aPrecision + xoffset) - && (x <= width + xoffset + aPrecision) - && (y >= -yoffset - aPrecision) - && (y <= height - yoffset + aPrecision); - - if ( Result ) { - SetPickedIndex(3); - return Standard_True; - } - - if ( IsOn( SRX, SRY, myX1, myY1, myX2, myY2, aPrecision ) ) { - SetPickedIndex( 4 ); - return Standard_True; - } - - if (! myInside) - if (IsOn( SRX, SRY, myAppX1, myAppY1, myAppX2, myAppY2, aPrecision )) - { - SetPickedIndex(5); - return Standard_True; - } - -}// end if IsInMinMax is true - - return Standard_False; - -} - -void Prs2d_Diameter::Save(Aspect_FStream& aFStream) const -{ -} diff --git a/src/Prs2d/Prs2d_Diameter.lxx b/src/Prs2d/Prs2d_Diameter.lxx deleted file mode 100755 index 44256b4cf3..0000000000 --- a/src/Prs2d/Prs2d_Diameter.lxx +++ /dev/null @@ -1,67 +0,0 @@ -// Copyright (c) 1999-2012 OPEN CASCADE SAS -// -// The content of this file is subject to the Open CASCADE Technology Public -// License Version 6.5 (the "License"). You may not use the content of this file -// except in compliance with the License. Please obtain a copy of the License -// at http://www.opencascade.org and read it completely before using this file. -// -// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its -// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. -// -// The Original Code and all software distributed under the License is -// distributed on an "AS IS" basis, without warranty of any kind, and the -// Initial Developer hereby disclaims all such warranties, including without -// limitation, any warranties of merchantability, fitness for a particular -// purpose or non-infringement. Please see the License for the specific terms -// and conditions governing the rights and limitations under the License. - -inline void Prs2d_Diameter::CalcTxtPos(const Standard_Boolean theFromAbs) { - - if (!theFromAbs) { - - gp_Pnt2d thePnt1(myAppX1,myAppY1), thePnt2(myAppX2,myAppY2); - - if (myInside) - { - thePnt1.SetCoord(myX1,myY1); - thePnt2.SetCoord(myX2,myY2); - } - - gp_Vec2d VX( 1., 0. ), theVecI,theVecJ,theVec(thePnt2,thePnt1); - Standard_Real theDist=thePnt1.Distance(thePnt2); - - theVec.Normalized(); - - theVecI = theVec.Reversed()*myTextPosH/theDist; - theVecJ = theVec.Reversed().Rotated(M_PI/2)*myTextPosV/theDist; - - theVec.Rotate(-myTextAngle); - - thePnt2.Translate(theVecI); - thePnt2.Translate(theVecJ); - thePnt1.Translate(theVecI); - thePnt1.Translate(theVecJ); - - Standard_Real theTxtAngle = VX.Angle( theVec ); - gp_Pnt2d pntText; - - - if ( theTxtAngle >= 0 && theTxtAngle <= M_PI/2 ) - pntText = thePnt2.Translated(theVec/theDist); - else if ( theTxtAngle > M_PI/2 && theTxtAngle <= M_PI ) { - pntText = thePnt1.Translated(theVec.Reversed()/theDist) ; - theTxtAngle = VX.Angle( theVec.Reversed() ); - } else if ( theTxtAngle >= -M_PI/2 && theTxtAngle < 0 ) - pntText = thePnt2.Translated(theVec/theDist); - else if ( theTxtAngle >= -M_PI && theTxtAngle < -M_PI/2 ) { - pntText = thePnt1.Translated(theVec.Reversed()/theDist); - theTxtAngle = VX.Angle( theVec.Reversed() ); - } - - myAbsAngle=theTxtAngle; - myAbsX=pntText.X(); - myAbsY=pntText.Y(); - - - } -} diff --git a/src/Prs2d/Prs2d_Dimension.cdl b/src/Prs2d/Prs2d_Dimension.cdl deleted file mode 100755 index f33d8a9c1f..0000000000 --- a/src/Prs2d/Prs2d_Dimension.cdl +++ /dev/null @@ -1,261 +0,0 @@ --- Created by: Tanya COOL --- Copyright (c) 2000-2012 OPEN CASCADE SAS --- --- The content of this file is subject to the Open CASCADE Technology Public --- License Version 6.5 (the "License"). You may not use the content of this file --- except in compliance with the License. Please obtain a copy of the License --- at http://www.opencascade.org and read it completely before using this file. --- --- The Initial Developer of the Original Code is Open CASCADE S.A.S., having its --- main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. --- --- The Original Code and all software distributed under the License is --- distributed on an "AS IS" basis, without warranty of any kind, and the --- Initial Developer hereby disclaims all such warranties, including without --- limitation, any warranties of merchantability, fitness for a particular --- purpose or non-infringement. Please see the License for the specific terms --- and conditions governing the rights and limitations under the License. - - -deferred class Dimension from Prs2d inherits Line from Graphic2d - - ---Purpose: Groups all dimensions - -uses - - Drawer from Graphic2d, - GraphicObject from Graphic2d, - Pnt2d from gp, - ExtendedString from TCollection, - ArrowSide from Prs2d, - TypeOfArrow from Prs2d, - Array1OfShortReal from TShort, - HArray1OfPnt2d from TColgp - -raises - - CircleDefinitionError from Graphic2d - -is - Initialize( aGO : GraphicObject from Graphic2d; - aText : ExtendedString from TCollection; - aTxtScale : Real from Standard; - anArrAngle : Real from Standard; - anArrLength : Real from Standard; - anArrType : TypeOfArrow from Prs2d; - anArrow : ArrowSide from Prs2d; - IsRevArrow : Boolean from Standard ) - - returns mutable Dimension from Prs2d; - - ---Purpose: creates a dimension - - ----------------------------------------------------- - -- Category: Modification of the properties - ----------------------------------------------------- - - SetText( me: mutable; aText: ExtendedString from TCollection ); - ---C++: inline - ---Level: Public - ---Purpose: Sets the text to this dimension - - SetTextScale( me: mutable; aTS: Real from Standard ); - ---C++: inline - ---Level: Public - ---Purpose: Sets the scale of text to this dimension - - SetTextFont( me: mutable; aTF: Integer from Standard ); - ---C++: inline - ---Level: Public - ---Purpose: Sets the index of the font of this text to this dimension - - SetFontOfSymb( me: mutable; aFS: Integer from Standard ); - ---C++: inline - ---Level: Public - ---Purpose: Sets the index of the font of the symbol to this dimension - - SetArrowType( me: mutable; anArrT: TypeOfArrow from Prs2d ); - ---C++: inline - ---Level: Public - ---Purpose: Sets the type of arrows to this dimension - - SetArrowSides( me: mutable; anArrS: ArrowSide from Prs2d); - ---C++: inline - ---Level: Public - ---Purpose: Sets the number of arrows to this dimension - - DrawSymbol( me: mutable; isDraw: Boolean from Standard ); - ---C++: inline - ---Level: Public - ---Purpose: Sets the flag for drawing additional symbol - - SetSymbolCode( me: mutable; aCode: Integer from Standard ); - ---C++: inline - ---Level: Public - ---Purpose: Sets the ASCII code of the symbol - - CalcTxtPos(me:mutable; theFromAbs: - Boolean from Standard=Standard_False) is deferred protected; - - SetTextAbsPos(me:mutable; Xp,Yp: Real from Standard ) - ---C++: inline - ---Level: Public - ---Purpose: Sets the CalcTxtPos(Standard_True) - -- myAbsX=Xp - -- myAbsY=Yp - - is static; - - SetTextAbsAngle(me:mutable; Ap: Real from Standard) - ---C++: inline - ---Level: Public - ---Purpose: Sets the CalcTxtPos(Standard_True) - -- myAbsAngle=Ap - is static; - - SetTextRelPos(me:mutable; Xp,Yp: Real from Standard ) - ---C++: inline - ---Level: Public - ---Purpose: Sets the CalcTxtPos(Standard_False) - -- myAbsX=Xp - -- myAbsY=Yp - is static; - - SetTextRelAngle(me:mutable; Ap: Real from Standard ) - ---C++: inline - ---Level: Public - ---Purpose: Sets the CalcTxtPos(Standard_False) - -- myAbsAngle=Ap - is static; - - ----------------------------------------------------- - -- Category: Inquire methods - ----------------------------------------------------- - - Text( me ) returns ExtendedString from TCollection; - ---C++: inline - ---Level: Public - ---Purpose: Returns text of this dimension - - TextAbsX(me) returns Real from Standard; - ---C++: inline - ---Level: Public - ---Purpose: Returns X - coordinat of text in absolute axis - -- add by enk Wed Dec 11 10:34 2002 - - TextAbsY(me) returns Real from Standard; - ---C++: inline - ---Level: Public - ---Purpose: Returns Y - coordinat of text in absolute axis - -- add by enk Wed Dec 11 10:34 2002 - - TextAbsAngle(me) returns Real from Standard; - ---C++: inline - ---Level: Public - ---Purpose: Returns angle of text in absolute axis - -- add by enk Wed Dec 11 10:34 2002 - - TextRelH(me) returns Real from Standard; - ---C++: inline - ---Level: Public - ---Purpose: Returns the horizontal position of text - --Add by enk Mon Nov 25 09:43 - - TextRelV(me) returns Real from Standard; - ---C++: inline - ---Level: Public - ---Purpose: Returns the vertical position of text - --Add by enk Mon Nov 25 09:43 - - TextRelAngle(me) returns Real from Standard; - ---C++: inline - ---Level: Public - ---Purpose: Returns the angle of text - --Add by enk Mon Nov 25 09:43 - - TextScale( me ) returns Real from Standard ; - ---C++: inline - ---Level: Public - ---Purpose: Returns the scale of text of this dimension - - TextFont( me ) returns Integer from Standard; - ---C++: inline - ---Level: Public - ---Purpose: Returns the index of the font of this text of this dimension - - FontOfSymb( me ) returns Integer from Standard; - ---C++: inline - ---Level: Public - ---Purpose: Returns the index of the font of the symbol of this dimension - - ArrowType( me ) returns TypeOfArrow from Prs2d; - ---C++: inline - ---Level: Public - ---Purpose: Indicates the type of arrows of this dimension - - ArrowSides( me ) returns ArrowSide from Prs2d; - ---C++: inline - ---Level: Public - ---Purpose: Indicates the number of arrows of this dimension - - ArrowAngle( me ) returns Real from Standard; - ---C++: inline - ---Level: Public - ---Purpose: Indicates the angle of arrow of this dimension - - ArrowLength( me ) returns Real from Standard; - ---C++: inline - ---Level: Public - ---Purpose: Indicates the length of arrow of this dimension - - ArrowIsReversed( me ) returns Boolean from Standard; - ---C++: inline - ---Level: Public - ---Purpose: Return true if arrows are reversed, false - in otherwise - - IsDrawSymbol( me ) returns Boolean from Standard; - ---C++: inline - ---Level: Public - ---Purpose: Return true if symbol is drawn, false - in otherwise - - SymbolCode( me ) returns Integer from Standard; - ---C++: inline - ---Level: Public - ---Purpose: Return ASCII code of the symbol - - ArrayOfFirstArrowPnt( me ) returns HArray1OfPnt2d from TColgp; - ---Level: Public - ---C++: return const - - ArrayOfSecondArrowPnt( me ) returns HArray1OfPnt2d from TColgp; - ---Level: Public - ---C++: return const - -fields - - myText : ExtendedString from TCollection is protected; - myTextScale : Real from Standard is protected; - - myTextPosH : Real from Standard is protected;---------------------------------- - myTextPosV : Real from Standard is protected;--Add by enk Fri Nov 22 17:55 2002 - myTextAngle : Real from Standard is protected;---------------------------------- - myAbsX : Real from Standard is protected;---------------------------------- - myAbsY : Real from Standard is protected;--Add by enk Fri Dec 6 11:30 2002 - myAbsAngle : Real from Standard is protected;---------------------------------- - - - myTextFont : Integer from Standard is protected; - mySymbFont : Integer from Standard is protected; - myXVert1 : Array1OfShortReal from TShort is protected; - myYVert1 : Array1OfShortReal from TShort is protected; - myXVert2 : Array1OfShortReal from TShort is protected; - myYVert2 : Array1OfShortReal from TShort is protected; - myArrType : TypeOfArrow from Prs2d is protected; - myArrow : ArrowSide from Prs2d is protected; - myArrowAng : Real from Standard is protected; - myArrowLen : Real from Standard is protected; - myIsRevArr : Boolean from Standard is protected; - myIsSymbol : Boolean from Standard is protected; - mySymbCode : Integer from Standard is protected; - -end Dimension from Prs2d; diff --git a/src/Prs2d/Prs2d_Dimension.cxx b/src/Prs2d/Prs2d_Dimension.cxx deleted file mode 100755 index 5cc82c4913..0000000000 --- a/src/Prs2d/Prs2d_Dimension.cxx +++ /dev/null @@ -1,76 +0,0 @@ -// Copyright (c) 1999-2012 OPEN CASCADE SAS -// -// The content of this file is subject to the Open CASCADE Technology Public -// License Version 6.5 (the "License"). You may not use the content of this file -// except in compliance with the License. Please obtain a copy of the License -// at http://www.opencascade.org and read it completely before using this file. -// -// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its -// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. -// -// The Original Code and all software distributed under the License is -// distributed on an "AS IS" basis, without warranty of any kind, and the -// Initial Developer hereby disclaims all such warranties, including without -// limitation, any warranties of merchantability, fitness for a particular -// purpose or non-infringement. Please see the License for the specific terms -// and conditions governing the rights and limitations under the License. - -#include - -Prs2d_Dimension::Prs2d_Dimension( const Handle(Graphic2d_GraphicObject)& aGO, - const TCollection_ExtendedString& aText, - const Standard_Real aTxtScale, - const Standard_Real anArrAngle, - const Standard_Real anArrLength, - const Prs2d_TypeOfArrow anArrType, - const Prs2d_ArrowSide anArrow, - const Standard_Boolean IsRevArrow ) - : Graphic2d_Line( aGO ), - myText( aText ), - myTextScale( aTxtScale ), - myTextFont( 0 ), - myTextPosH( 0 ), - myTextPosV( 0 ), - myTextAngle( 0 ), - myAbsX( 0 ), - myAbsY( 0 ), - myAbsAngle( 0 ), - mySymbFont( 0 ), - myXVert1( 1, 3 ), - myYVert1( 1, 3 ), - myXVert2( 1, 3 ), - myYVert2( 1, 3 ), - myArrType( anArrType ), - myArrow( anArrow ), - myArrowAng( anArrAngle ), - myArrowLen( anArrLength ), - myIsRevArr( IsRevArrow ), - myIsSymbol( Standard_False ), - mySymbCode( 248 ) - -{ -} - -const Handle(TColgp_HArray1OfPnt2d) Prs2d_Dimension::ArrayOfFirstArrowPnt( ) const -{ - Handle(TColgp_HArray1OfPnt2d) points = new TColgp_HArray1OfPnt2d( 1, 3 ); - - for ( Standard_Integer i = 1; i <= 3; i++ ) - { - points->SetValue( i, gp_Pnt2d( myXVert1(i), myYVert1(i) ) ); - } - return points; -} - -const Handle(TColgp_HArray1OfPnt2d) Prs2d_Dimension::ArrayOfSecondArrowPnt( ) const -{ - Handle(TColgp_HArray1OfPnt2d) points = new TColgp_HArray1OfPnt2d( 1, 3 ); - - for ( Standard_Integer i = 1; i <= 3; i++ ) - { - points->SetValue( i, gp_Pnt2d( myXVert2(i), myYVert2(i) ) ); - } - return points; -} - - diff --git a/src/Prs2d/Prs2d_Dimension.lxx b/src/Prs2d/Prs2d_Dimension.lxx deleted file mode 100755 index 6db0f91581..0000000000 --- a/src/Prs2d/Prs2d_Dimension.lxx +++ /dev/null @@ -1,171 +0,0 @@ -// Copyright (c) 1999-2012 OPEN CASCADE SAS -// -// The content of this file is subject to the Open CASCADE Technology Public -// License Version 6.5 (the "License"). You may not use the content of this file -// except in compliance with the License. Please obtain a copy of the License -// at http://www.opencascade.org and read it completely before using this file. -// -// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its -// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. -// -// The Original Code and all software distributed under the License is -// distributed on an "AS IS" basis, without warranty of any kind, and the -// Initial Developer hereby disclaims all such warranties, including without -// limitation, any warranties of merchantability, fitness for a particular -// purpose or non-infringement. Please see the License for the specific terms -// and conditions governing the rights and limitations under the License. - -inline void Prs2d_Dimension::SetText(const TCollection_ExtendedString& aText) -{ - myText = aText; -} - -inline void Prs2d_Dimension::SetTextScale(const Standard_Real aTS) -{ - myTextScale = aTS; -} - -inline void Prs2d_Dimension::SetTextFont(const Standard_Integer aTF) -{ - myTextFont = aTF; -} - -inline void Prs2d_Dimension::SetFontOfSymb(const Standard_Integer aFS) -{ - mySymbFont = aFS; -} - -inline void Prs2d_Dimension::SetArrowType(const Prs2d_TypeOfArrow anArrT) -{ - myArrType = anArrT; -} - -inline void Prs2d_Dimension::SetArrowSides(const Prs2d_ArrowSide anArrS) -{ - myArrow = anArrS; -} - -inline void Prs2d_Dimension::DrawSymbol(const Standard_Boolean isDraw ) -{ - myIsSymbol = isDraw; -} - -inline void Prs2d_Dimension::SetSymbolCode( const Standard_Integer aCode ) -{ - mySymbCode = aCode; -} - -inline void Prs2d_Dimension::SetTextAbsAngle(const Standard_Real Ap) -{ - myAbsAngle=Ap; - CalcTxtPos(Standard_True); -} - -inline void Prs2d_Dimension::SetTextAbsPos(const Standard_Real Xp, - const Standard_Real Yp) -{ - myAbsX=Xp; - myAbsY=Yp; - CalcTxtPos(Standard_True); -} - -inline void Prs2d_Dimension::SetTextRelPos(const Standard_Real Xp, - const Standard_Real Yp) -{ - myTextPosH=Xp; - myTextPosV=Yp; - CalcTxtPos(); -} - -inline void Prs2d_Dimension::SetTextRelAngle(const Standard_Real Ap) -{ - myTextAngle=Ap; - CalcTxtPos(); -} - -inline TCollection_ExtendedString Prs2d_Dimension::Text() const -{ - return myText; -} - -inline Standard_Real Prs2d_Dimension::TextRelH() const -{ - return myTextPosH; -} - -inline Standard_Real Prs2d_Dimension::TextRelV() const -{ - return myTextPosV; -} - -inline Standard_Real Prs2d_Dimension::TextRelAngle() const -{ - return myTextAngle; -} - - -inline Standard_Real Prs2d_Dimension::TextAbsAngle() const -{ - return myAbsAngle; -} - -inline Standard_Real Prs2d_Dimension::TextAbsX() const -{ - return myAbsX; -} - -inline Standard_Real Prs2d_Dimension::TextAbsY() const -{ - return myAbsY; -} - -inline Standard_Real Prs2d_Dimension::TextScale() const -{ - return myTextScale; -} - -inline Standard_Integer Prs2d_Dimension::TextFont() const -{ - return myTextFont; -} - -inline Standard_Integer Prs2d_Dimension::FontOfSymb() const -{ - return mySymbFont; -} - -inline Prs2d_TypeOfArrow Prs2d_Dimension::ArrowType() const -{ - return myArrType; -} - -inline Prs2d_ArrowSide Prs2d_Dimension::ArrowSides() const -{ - return myArrow; -} - -inline Standard_Real Prs2d_Dimension::ArrowAngle() const -{ - return myArrowAng; -} - -inline Standard_Real Prs2d_Dimension::ArrowLength() const -{ - return myArrowLen; -} - -inline Standard_Boolean Prs2d_Dimension::ArrowIsReversed() const -{ - return myIsRevArr; -} - -inline Standard_Boolean Prs2d_Dimension::IsDrawSymbol() const -{ - return myIsSymbol; -} - -inline Standard_Integer Prs2d_Dimension::SymbolCode() const -{ - return mySymbCode; -} - diff --git a/src/Prs2d/Prs2d_DrawSymbol.cdl b/src/Prs2d/Prs2d_DrawSymbol.cdl deleted file mode 100755 index 395e8ba64f..0000000000 --- a/src/Prs2d/Prs2d_DrawSymbol.cdl +++ /dev/null @@ -1,88 +0,0 @@ --- Created by: TCL --- Copyright (c) 2000-2012 OPEN CASCADE SAS --- --- The content of this file is subject to the Open CASCADE Technology Public --- License Version 6.5 (the "License"). You may not use the content of this file --- except in compliance with the License. Please obtain a copy of the License --- at http://www.opencascade.org and read it completely before using this file. --- --- The Initial Developer of the Original Code is Open CASCADE S.A.S., having its --- main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. --- --- The Original Code and all software distributed under the License is --- distributed on an "AS IS" basis, without warranty of any kind, and the --- Initial Developer hereby disclaims all such warranties, including without --- limitation, any warranties of merchantability, fitness for a particular --- purpose or non-infringement. Please see the License for the specific terms --- and conditions governing the rights and limitations under the License. - - - -class DrawSymbol from Prs2d inherits Line from Graphic2d - - ---Purpose: The primitive symbol for drawing - -uses - - Drawer from Graphic2d, - GraphicObject from Graphic2d, - TypeOfSymbol from Prs2d, - FStream from Aspect - -raises - - SymbolDefinitionError from Prs2d - -is - ------------------------- - -- Category: Constructor - ------------------------- - - Create( aGO : GraphicObject from Graphic2d; - aSymbType : TypeOfSymbol from Prs2d; - aX, aY : Real from Standard; - aWidth : Real from Standard = 10.0; - aHeight : Real from Standard = 10.0; - anAngle : Real from Standard = 0.0 ) - returns mutable DrawSymbol from Prs2d - raises SymbolDefinitionError from Prs2d; - - ---Level: Public - ---Purpose: Creates the predefined marker index - -- at position , and size ,. - ---Category: Constructor - ---Purpose: Trigger - Raises SymbolDefinitionError if the - -- symbol type isn't defined, - -- or the symbol size < aWidth, aHeight > is null. - - ---------------------------------------------------- - -- Category: Draw and Pick - ---------------------------------------------------- - - Draw( me: mutable; aDrawer: Drawer from Graphic2d ) is static protected; - ---Level: Internal - ---Purpose: Draws the symbol . - - Pick( me : mutable; - X, Y : ShortReal from Standard; - aPrecision : ShortReal from Standard; - aDrawer : Drawer from Graphic2d ) returns Boolean from Standard - is static protected; - ---Level: Internal - ---Purpose: Returns Standard_True if the symbol is picked, - -- Standard_False if not. - -- Warning: Checks only if the point , is in the - -- boundary rectangle of - - Save( me; aFStream: in out FStream from Aspect ) is virtual; - -fields - - myTypeSymb : TypeOfSymbol from Prs2d; - myX : ShortReal from Standard; - myY : ShortReal from Standard; - myWidth : ShortReal from Standard; - myHeight : ShortReal from Standard; - myAngle : ShortReal from Standard; - -end Marker from Graphic2d; diff --git a/src/Prs2d/Prs2d_DrawSymbol.cxx b/src/Prs2d/Prs2d_DrawSymbol.cxx deleted file mode 100755 index 77dbf6d013..0000000000 --- a/src/Prs2d/Prs2d_DrawSymbol.cxx +++ /dev/null @@ -1,122 +0,0 @@ -// Copyright (c) 1999-2012 OPEN CASCADE SAS -// -// The content of this file is subject to the Open CASCADE Technology Public -// License Version 6.5 (the "License"). You may not use the content of this file -// except in compliance with the License. Please obtain a copy of the License -// at http://www.opencascade.org and read it completely before using this file. -// -// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its -// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. -// -// The Original Code and all software distributed under the License is -// distributed on an "AS IS" basis, without warranty of any kind, and the -// Initial Developer hereby disclaims all such warranties, including without -// limitation, any warranties of merchantability, fitness for a particular -// purpose or non-infringement. Please see the License for the specific terms -// and conditions governing the rights and limitations under the License. - -#include - -Prs2d_DrawSymbol::Prs2d_DrawSymbol( const Handle(Graphic2d_GraphicObject)& aGO, - const Prs2d_TypeOfSymbol aSymbType, - const Standard_Real aX, - const Standard_Real aY, - const Standard_Real aWidth, - const Standard_Real aHeight, - const Standard_Real anAngle ) - : Graphic2d_Line( aGO ), - myTypeSymb( aSymbType ), - myX( Standard_ShortReal( aX ) ), - myY( Standard_ShortReal( aY ) ), - myWidth( Standard_ShortReal( aWidth ) ), - myHeight( Standard_ShortReal( aHeight ) ), - myAngle( Standard_ShortReal( anAngle ) ) - -{ - if ( myTypeSymb > Prs2d_TOS_LAST && myTypeSymb < Prs2d_TOS_NONE ) - Prs2d_SymbolDefinitionError::Raise - ( "The symbol must be from Prs2d_TypeOfSymbol enumeration" ); - - if ( myWidth <= 0.0 ) - Prs2d_SymbolDefinitionError::Raise( "The width = 0." ); - - if ( myHeight <= 0.0 ) - Prs2d_SymbolDefinitionError::Raise( "The height = 0." ); - - myMinX = myX - Standard_ShortReal( myWidth / 2. ); - myMinY = myY - Standard_ShortReal( myHeight / 2. ); - myMaxX = myX + Standard_ShortReal( myWidth / 2. ); - myMaxY = myY + Standard_ShortReal( myHeight / 2. ); - -} - -void Prs2d_DrawSymbol::Draw( const Handle(Graphic2d_Drawer)& aDrawer ) { - - Standard_Boolean IsIn = Standard_False; - - if ( ! myGOPtr->IsTransformed() ) - IsIn = aDrawer->IsIn( myMinX, myMaxX, myMinY, myMaxY ); - else { - Standard_ShortReal minx, miny, maxx, maxy; - MinMax( minx, maxx, miny, maxy ); - IsIn = aDrawer->IsIn( minx, maxx, miny, maxy ); - } - - - if ( IsIn ) { - - switch ( myTypeSymb ) { - case Prs2d_TOS_DIAMETER: { - Standard_ShortReal theRad = ( myWidth < myHeight) ? myWidth : myHeight; - gp_Pnt2d theCent( myX, myY ); - gp_Vec2d theVec( theCent, gp_Pnt2d( myX + 13 * theRad/ 10, myY ) ); - theVec.Rotate( M_PI / 4 ); - gp_Pnt2d P1 = theCent.Translated( theVec ); - gp_Pnt2d P2 = theCent.Translated( theVec.Reversed() ); - - P1.Rotate( theCent, myAngle ); - P2.Rotate( theCent, myAngle ); - - Standard_ShortReal a = myX, b = myY, - c = Standard_ShortReal( P1.X() ), - d = Standard_ShortReal( P1.Y() ), - e = Standard_ShortReal( P2.X() ), - f = Standard_ShortReal( P2.Y() ); - - if ( myGOPtr->IsTransformed() ) { - gp_GTrsf2d aTrsf = myGOPtr->Transform(); - Standard_Real A1, B1; - A1 = Standard_Real( a ); B1 = Standard_Real( b ); - aTrsf.Transforms( A1, B1 ); - a = Standard_ShortReal( A1 ); b = Standard_ShortReal( B1 ); - A1 = Standard_Real( c ); B1 = Standard_Real( d ); - aTrsf.Transforms( A1, B1 ); - c = Standard_ShortReal( A1 ); d = Standard_ShortReal( B1 ); - A1 = Standard_Real( e ); B1 = Standard_Real( f ); - aTrsf.Transforms( A1, B1 ); - e = Standard_ShortReal( A1 ); f = Standard_ShortReal( B1 ); - } - - DrawLineAttrib( aDrawer ); - aDrawer->MapArcFromTo( a, b, theRad, 0., Standard_ShortReal( 2 * M_PI ) ); - aDrawer->MapSegmentFromTo( c, d, e, f ); - - }// end TOS_DIAMETER - break; - default: - break; - } // end switch - } -} - -Standard_Boolean Prs2d_DrawSymbol::Pick( const Standard_ShortReal /*X*/, - const Standard_ShortReal /*Y*/, - const Standard_ShortReal /*aPrecision*/, - const Handle(Graphic2d_Drawer)& /*aDrawer*/ ) { - - return Standard_False; -} - -void Prs2d_DrawSymbol::Save(Aspect_FStream& aFStream) const -{ -} diff --git a/src/Prs2d/Prs2d_Drawer.cdl b/src/Prs2d/Prs2d_Drawer.cdl deleted file mode 100755 index c8f0dbc7be..0000000000 --- a/src/Prs2d/Prs2d_Drawer.cdl +++ /dev/null @@ -1,76 +0,0 @@ --- Created by: Tanya COOL --- Copyright (c) 2000-2012 OPEN CASCADE SAS --- --- The content of this file is subject to the Open CASCADE Technology Public --- License Version 6.5 (the "License"). You may not use the content of this file --- except in compliance with the License. Please obtain a copy of the License --- at http://www.opencascade.org and read it completely before using this file. --- --- The Initial Developer of the Original Code is Open CASCADE S.A.S., having its --- main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. --- --- The Original Code and all software distributed under the License is --- distributed on an "AS IS" basis, without warranty of any kind, and the --- Initial Developer hereby disclaims all such warranties, including without --- limitation, any warranties of merchantability, fitness for a particular --- purpose or non-infringement. Please see the License for the specific terms --- and conditions governing the rights and limitations under the License. - - -class Drawer from Prs2d inherits TShared from MMgt - - --- Purpose: Graphic attributes management - -- Qualifies how the presentation algorithms compute - -- the presentation of a specific kind of object. - -- This includes for example color, width and type - -- of lines... - -uses - - NameOfColor from Quantity, - TypeOf2DObject from Prs2d, - AspectRoot from Prs2d, - AspectName from Prs2d, - DataMapOfAspectRoot from Prs2d - -is - Create returns mutable Drawer from Prs2d; - ---Purpose: Initializes graphic attribute manager - - FindAspect( me; anAspectName: AspectName from Prs2d ) - returns AspectRoot from Prs2d is virtual; - ---Level: Public - ---Purpose: Returns a link with Prs2d_Drawer AspectName, - -- which provides settings for object "anAspectName" - -- used to display "anAspectName" - - SetAspect( me: mutable; - anAspectRoot: AspectRoot from Prs2d; - anAspectName: AspectName from Prs2d ); - ---Level: Public - ---Purpose: Sets the Aspect of the Drawer - - InitAspectRootMap( me: mutable ) is private; - ---Level: Internal - ---Purpose: Initializes Aspect classes data map - - --****************************************************** - - SetMaxParameterValue( me: mutable; Value: Real from Standard ) is virtual; - ---Level: Public - ---Purpose: defines the maximum value allowed for the first and last - -- parameters of an infinite line. - -- Default value: 500000. - - MaxParameterValue( me ) returns Real from Standard is virtual; - ---Level: Public - ---Purpose: Indicates the maximum value allowed for the first and last - -- parameters of an infinite line. - - -fields - - myDataMapAspectRoot: DataMapOfAspectRoot from Prs2d is protected; - myMaxParameterValue: Real from Standard is protected; - -end Drawer; diff --git a/src/Prs2d/Prs2d_Drawer.cxx b/src/Prs2d/Prs2d_Drawer.cxx deleted file mode 100755 index eb8fec9343..0000000000 --- a/src/Prs2d/Prs2d_Drawer.cxx +++ /dev/null @@ -1,94 +0,0 @@ -// Copyright (c) 1999-2012 OPEN CASCADE SAS -// -// The content of this file is subject to the Open CASCADE Technology Public -// License Version 6.5 (the "License"). You may not use the content of this file -// except in compliance with the License. Please obtain a copy of the License -// at http://www.opencascade.org and read it completely before using this file. -// -// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its -// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. -// -// The Original Code and all software distributed under the License is -// distributed on an "AS IS" basis, without warranty of any kind, and the -// Initial Developer hereby disclaims all such warranties, including without -// limitation, any warranties of merchantability, fitness for a particular -// purpose or non-infringement. Please see the License for the specific terms -// and conditions governing the rights and limitations under the License. - -#include - -#include - -#include -#include - -#include -#include -#include - -#include -#include -#include -#include -#include - - -#define NUM_ASPECTROOT 29 - -Prs2d_Drawer::Prs2d_Drawer() - - : - myMaxParameterValue( 500000. ) - -{ - - Prs2d_DataMapOfAspectRoot aDataMapAspectRoot(NUM_ASPECTROOT); - myDataMapAspectRoot = aDataMapAspectRoot; - - InitAspectRootMap(); - -} - -Handle(Prs2d_AspectRoot) Prs2d_Drawer::FindAspect( const Prs2d_AspectName anAspectName ) const { - - return myDataMapAspectRoot(anAspectName); - -} - -void Prs2d_Drawer::SetAspect( const Handle(Prs2d_AspectRoot)& anAspectRoot, - const Prs2d_AspectName anAspectName) { - - myDataMapAspectRoot( anAspectName ) = anAspectRoot; -} - -void Prs2d_Drawer::InitAspectRootMap() { - - Handle(Prs2d_AspectLine) myLineAspect = new Prs2d_AspectLine(); - myDataMapAspectRoot.Bind( Prs2d_AN_LINE, myLineAspect ); - - Handle(Prs2d_AspectText) myTextAspect = new Prs2d_AspectText(); - myDataMapAspectRoot.Bind( Prs2d_AN_TEXT, myTextAspect ); - - Handle(Prs2d_AspectHidingPoly) myHidingPolyAspect = new Prs2d_AspectHidingPoly - (Quantity_NOC_BLACK, Quantity_NOC_WHITE, Aspect_TOL_SOLID, Aspect_WOL_THIN); - myDataMapAspectRoot.Bind( Prs2d_AN_HIDINGPOLY, myHidingPolyAspect ); - - Handle(Prs2d_AspectHidingText) myHidingTextAspect = new Prs2d_AspectHidingText - (Quantity_NOC_YELLOW, Quantity_NOC_BLACK, Quantity_NOC_WHITE, - Aspect_WOL_THIN,Aspect_TOF_DEFAULT, 0.0, 1.0, 1.0, Standard_False); - myDataMapAspectRoot.Bind( Prs2d_AN_HIDINGTEXT, myHidingTextAspect ); - - Handle(Prs2d_AspectFramedText) myFramedTextAspect = new Prs2d_AspectFramedText - (Quantity_NOC_BLACK, Quantity_NOC_WHITE, Aspect_WOL_THIN, Aspect_TOF_DEFAULT, - 0.0, 1.0, 1.0, Standard_False ); - myDataMapAspectRoot.Bind( Prs2d_AN_FRAMEDTEXT, myFramedTextAspect ); - -} - -void Prs2d_Drawer::SetMaxParameterValue ( const Standard_Real Value ) { - myMaxParameterValue = Value; -} - -Standard_Real Prs2d_Drawer::MaxParameterValue () const { - return myMaxParameterValue; -} diff --git a/src/Prs2d/Prs2d_Flatness.cdl b/src/Prs2d/Prs2d_Flatness.cdl deleted file mode 100755 index 1f71f877bf..0000000000 --- a/src/Prs2d/Prs2d_Flatness.cdl +++ /dev/null @@ -1,54 +0,0 @@ --- Created by: TCL --- Copyright (c) 2000-2012 OPEN CASCADE SAS --- --- The content of this file is subject to the Open CASCADE Technology Public --- License Version 6.5 (the "License"). You may not use the content of this file --- except in compliance with the License. Please obtain a copy of the License --- at http://www.opencascade.org and read it completely before using this file. --- --- The Initial Developer of the Original Code is Open CASCADE S.A.S., having its --- main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. --- --- The Original Code and all software distributed under the License is --- distributed on an "AS IS" basis, without warranty of any kind, and the --- Initial Developer hereby disclaims all such warranties, including without --- limitation, any warranties of merchantability, fitness for a particular --- purpose or non-infringement. Please see the License for the specific terms --- and conditions governing the rights and limitations under the License. - - -class Flatness from Prs2d inherits Tolerance from Prs2d - -uses - - GraphicObject from Graphic2d, - Drawer from Graphic2d, - Length from Quantity, - FStream from Aspect - -is - ------------------------- - -- Category: Constructors - ------------------------- - - Create( aGO : GraphicObject from Graphic2d; - aX, aY : Real from Standard; - aLength : Real from Standard = 3.0; - anAngle : Real from Standard = 0.0 ); - ---Level: Public - ---Purpose: Creates a tolerance Flatness with the center at , ; - -- length of this is ; - -- reference point is , - ---Category: Constructor - - -------------------------- - -- Category: Draw and Pick - -------------------------- - - Draw( me : mutable; aDrawer: Drawer from Graphic2d ) is static protected; - ---Level: Internal - ---Purpose: Draws the Flatness . - - Save( me; aFStream: in out FStream from Aspect ) is virtual; - -end Flatness from Prs2d; diff --git a/src/Prs2d/Prs2d_Flatness.cxx b/src/Prs2d/Prs2d_Flatness.cxx deleted file mode 100755 index dfeed06c4e..0000000000 --- a/src/Prs2d/Prs2d_Flatness.cxx +++ /dev/null @@ -1,104 +0,0 @@ -// Copyright (c) 1999-2012 OPEN CASCADE SAS -// -// The content of this file is subject to the Open CASCADE Technology Public -// License Version 6.5 (the "License"). You may not use the content of this file -// except in compliance with the License. Please obtain a copy of the License -// at http://www.opencascade.org and read it completely before using this file. -// -// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its -// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. -// -// The Original Code and all software distributed under the License is -// distributed on an "AS IS" basis, without warranty of any kind, and the -// Initial Developer hereby disclaims all such warranties, including without -// limitation, any warranties of merchantability, fitness for a particular -// purpose or non-infringement. Please see the License for the specific terms -// and conditions governing the rights and limitations under the License. - -#include - -Prs2d_Flatness::Prs2d_Flatness( const Handle(Graphic2d_GraphicObject)& aGO, - const Standard_Real aX, - const Standard_Real aY, - const Standard_Real aLength, - const Standard_Real anAngle ) - - : Prs2d_Tolerance( aGO, aX, aY, aLength, anAngle ) -{ -} - -void Prs2d_Flatness::Draw( const Handle(Graphic2d_Drawer)& aDrawer ) { - - Standard_Boolean IsIn = Standard_False; - - if ( !myGOPtr->IsTransformed() ) - IsIn = aDrawer->IsIn( myMinX, myMaxX, myMinY, myMaxY ); - else { - Standard_ShortReal minx, miny, maxx, maxy; - MinMax( minx, maxx, miny, maxy ); - IsIn = aDrawer->IsIn( minx, maxx, miny, maxy ); - } - - if ( IsIn ) { - DrawLineAttrib( aDrawer ); - Standard_ShortReal X1 = myX - myLength/2, - Y1 = myY - myLength/2, - X4 = myX + myLength/2, - Y4 = Y1, - X2 = X1 + myLength/2, - Y2 = myY + myLength/2, - X3 = X4 + myLength/2, - Y3 = Y2; - gp_Pnt2d P1( X1, Y1 ), - P2( X2, Y2 ), - P3( X3, Y3 ), - P4( X4, Y4 ), - PR( myX, myY ); - P1.Rotate( PR, myAngle ); - P2.Rotate( PR, myAngle ); - P3.Rotate( PR, myAngle ); - P4.Rotate( PR, myAngle ); - - X1 = Standard_ShortReal( P1.X() ); - Y1 = Standard_ShortReal( P1.Y() ); - X2 = Standard_ShortReal( P2.X() ); - Y2 = Standard_ShortReal( P2.Y() ); - X3 = Standard_ShortReal( P3.X() ); - Y3 = Standard_ShortReal( P3.Y() ); - X4 = Standard_ShortReal( P4.X() ); - Y4 = Standard_ShortReal( P4.Y() ); - - if ( myGOPtr->IsTransformed () ) { - gp_GTrsf2d aTrsf = myGOPtr->Transform (); - Standard_Real a1, b1; - a1 = X1; - b1 = Y1; - aTrsf.Transforms( a1, b1 ); - X1 = Standard_ShortReal( a1 ); - Y1 = Standard_ShortReal( b1 ); - a1 = X2; - b1 = Y2; - aTrsf.Transforms( a1, b1 ); - X2 = Standard_ShortReal( a1 ); - Y2 = Standard_ShortReal( b1 ); - a1 = X3; - b1 = Y3; - aTrsf.Transforms( a1, b1 ); - X3 = Standard_ShortReal( a1 ); - Y3 = Standard_ShortReal( b1 ); - a1 = X4; - b1 = Y4; - aTrsf.Transforms( a1, b1 ); - X4 = Standard_ShortReal( a1 ); - Y4 = Standard_ShortReal( b1 ); - } - aDrawer->MapSegmentFromTo( X1, Y1, X2, Y2 ); - aDrawer->MapSegmentFromTo( X2, Y2, X3, Y3 ); - aDrawer->MapSegmentFromTo( X3, Y3, X4, Y4 ); - aDrawer->MapSegmentFromTo( X4, Y4, X1, Y1 ); - } -} - -void Prs2d_Flatness::Save(Aspect_FStream& aFStream) const -{ -} diff --git a/src/Prs2d/Prs2d_Length.cdl b/src/Prs2d/Prs2d_Length.cdl deleted file mode 100755 index 25d309b3d5..0000000000 --- a/src/Prs2d/Prs2d_Length.cdl +++ /dev/null @@ -1,173 +0,0 @@ --- Created by: Tanya COOL --- Copyright (c) 2000-2012 OPEN CASCADE SAS --- --- The content of this file is subject to the Open CASCADE Technology Public --- License Version 6.5 (the "License"). You may not use the content of this file --- except in compliance with the License. Please obtain a copy of the License --- at http://www.opencascade.org and read it completely before using this file. --- --- The Initial Developer of the Original Code is Open CASCADE S.A.S., having its --- main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. --- --- The Original Code and all software distributed under the License is --- distributed on an "AS IS" basis, without warranty of any kind, and the --- Initial Developer hereby disclaims all such warranties, including without --- limitation, any warranties of merchantability, fitness for a particular --- purpose or non-infringement. Please see the License for the specific terms --- and conditions governing the rights and limitations under the License. - - -class Length from Prs2d inherits Dimension from Prs2d - - ---Purpose: Constructs the primitive Length - -uses - - Drawer from Graphic2d, - GraphicObject from Graphic2d, - Pnt2d from gp, - Lin2d from gp, - ExtendedString from TCollection, - ArrowSide from Prs2d, - TypeOfDist from Prs2d, - TypeOfArrow from Prs2d, - FStream from Aspect - -is - Create( aGraphicObject: GraphicObject from Graphic2d; - anAttachPnt1 : Pnt2d from gp; - anAttachPnt2 : Pnt2d from gp; - aText : ExtendedString from TCollection; - aTxtScale : Real from Standard = 5.0; - aLength : Real from Standard = 0.0; - aTypeDist : TypeOfDist from Prs2d = Prs2d_TOD_AUTOMATIC; - anArrAngle : Real from Standard = 20.0; - anArrLength : Real from Standard = 25.0; - anArrType : TypeOfArrow from Prs2d = Prs2d_TOA_OPENED; - anArrow : ArrowSide from Prs2d = Prs2d_AS_BOTHAR; - IsReverseArrow: Boolean from Standard = Standard_False ) - - returns mutable Length from Prs2d; - - ---Purpose: Initializes the length dimension between points - -- anAttachPnt1 and anAttachPnt2. - -- aLength is length of the attach lines - -- aTypeDist defines the orientation of the displayed length: - -- AIS2D_TOD_AUTOMATIC - -- AIS2D_TOD_OBLIQUE - -- AIS2D_TOD_HORIZONTAL - -- AIS2D_TOD_VERTICAL - -- anArrow defines the number of arrows (one, two or none) - - Create( aGraphicObject: GraphicObject from Graphic2d; - anAttachPnt : Pnt2d from gp; - anAttachLin : Lin2d from gp; - aText : ExtendedString from TCollection; - aTxtScale : Real from Standard = 10.0; - aLenAttachLin : Real from Standard = 0.0; - anArrAngle : Real from Standard = 20.0; - anArrLength : Real from Standard = 25.0; - anArrType : TypeOfArrow from Prs2d = Prs2d_TOA_OPENED; - anArrow : ArrowSide from Prs2d = Prs2d_AS_BOTHAR; - IsReverseArrow: Boolean from Standard = Standard_False ) - - returns mutable Length from Prs2d; - - ---Purpose: Initializes the length dimension between point - -- anAttachPnt1 and line defined anAttachLin. - -- aLenAttachLin is length of the attach lines - - Create( aGraphicObject: GraphicObject from Graphic2d; - anAttachLin1 : Lin2d from gp; - anAttachLin2 : Lin2d from gp; - aText : ExtendedString from TCollection; - aTxtScale : Real from Standard = 10.0; - aLenAttachLin : Real from Standard = 0.0; - anArrAngle : Real from Standard = 20.0; - anArrLength : Real from Standard = 25.0; - anArrType : TypeOfArrow from Prs2d = Prs2d_TOA_OPENED; - anArrow : ArrowSide from Prs2d = Prs2d_AS_BOTHAR; - IsReverseArrow: Boolean from Standard = Standard_False ) - - returns mutable Length from Prs2d; - - ---Purpose: Initializes the length dimension between line - -- anAttachLin1 and line defined anAttachLin2. - -- aLenAttachLin is length of the attach lines - - -------------------------- - -- Category: Draw and Pick - -------------------------- - - Draw( me : mutable; aDrawer: Drawer from Graphic2d ) is static protected; - ---Level: Internal - ---Purpose: Draws the length . - - DrawElement( me : mutable; aDrawer: Drawer from Graphic2d; - anIndex: Integer from Standard) is redefined protected; - ---Level: Internal - ---Purpose: Draws element of the length . - - DrawVertex( me : mutable; aDrawer: Drawer from Graphic2d; - anIndex: Integer from Standard) is redefined protected; - ---Level: Internal - ---Purpose: Draws vertex of the length . - - Pick( me : mutable; X, Y: ShortReal from Standard; - aPrecision: ShortReal from Standard; - aDrawer: Drawer from Graphic2d) returns Boolean from Standard - is static protected; - ---Level: Internal - ---Purpose: Returns Standard_True if the length is picked, - -- Standard_False if not. - - GetPntProject( me: mutable; aLength: Real from Standard ) is private; - ComputeArrows( me: mutable; isnotPoints: Boolean from Standard ) is private; - - -------------------------------------------- - -- Category: Modification of the properties - -------------------------------------------- - - SetAttachLinLength( me: mutable; aLength: Real from Standard ); - ---Level: Public - ---Purpose: Sets the length of attachment lines - - Save( me; aFStream: in out FStream from Aspect ) is virtual; - - CalcTxtPos(me:mutable; theFromAbs: - Boolean from Standard=Standard_False) - ---C++: inline - is redefined protected; - - LineCoord( me ; aFirstPnt, aSecondPnt: in out Pnt2d from gp ); - ---Level: Internal - ---Purpose: returns coordinates of points, which are begining - -- and end of arrow - - CallOutCoord( me ; aFirstPnt, aSecondPnt: in out Pnt2d from gp ); - ---Level: Internal - ---Purpose: returns coordinates of points, which are begining - -- and end of arrow - - TypeOfDist(me) returns TypeOfDist; - ---Level: Internal - - -fields - - myX1 : ShortReal from Standard; - myY1 : ShortReal from Standard; - myX2 : ShortReal from Standard; - myY2 : ShortReal from Standard; - myAX1 : ShortReal from Standard; - myAY1 : ShortReal from Standard; - myAX2 : ShortReal from Standard; - myAY2 : ShortReal from Standard; - myTypeDist : TypeOfDist from Prs2d; - myXT1 : ShortReal from Standard; - myYT1 : ShortReal from Standard; - myXT2 : ShortReal from Standard; - myYT2 : ShortReal from Standard; - -end Length from Prs2d; - diff --git a/src/Prs2d/Prs2d_Length.cxx b/src/Prs2d/Prs2d_Length.cxx deleted file mode 100755 index 8cc1f690da..0000000000 --- a/src/Prs2d/Prs2d_Length.cxx +++ /dev/null @@ -1,943 +0,0 @@ -// Copyright (c) 1999-2012 OPEN CASCADE SAS -// -// The content of this file is subject to the Open CASCADE Technology Public -// License Version 6.5 (the "License"). You may not use the content of this file -// except in compliance with the License. Please obtain a copy of the License -// at http://www.opencascade.org and read it completely before using this file. -// -// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its -// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. -// -// The Original Code and all software distributed under the License is -// distributed on an "AS IS" basis, without warranty of any kind, and the -// Initial Developer hereby disclaims all such warranties, including without -// limitation, any warranties of merchantability, fitness for a particular -// purpose or non-infringement. Please see the License for the specific terms -// and conditions governing the rights and limitations under the License. - -#include -#include -#include - -#define VERTEXMARKER 2 -#define DEFAULTMARKERSIZE 3.0 -#define XROTATE(x,y) ((x)*cosa - (y)*sina) -#define YROTATE(x,y) ((y)*cosa + (x)*sina) -#define ADDPIX 17 - -Prs2d_Length::Prs2d_Length( const Handle(Graphic2d_GraphicObject)& aGO, - const gp_Pnt2d& anAttachPnt1, - const gp_Pnt2d& anAttachPnt2, - const TCollection_ExtendedString& aText, - const Standard_Real aTxtScale, - const Standard_Real aLength, - const Prs2d_TypeOfDist aTypeDist, - const Standard_Real anArrAngle, - const Standard_Real anArrLength, - const Prs2d_TypeOfArrow anArrType, - const Prs2d_ArrowSide anArrow, - const Standard_Boolean IsRevArrow ) - - : Prs2d_Dimension( aGO, aText, aTxtScale, anArrAngle, - anArrLength, anArrType, anArrow, IsRevArrow ), - - myTypeDist( aTypeDist ) - -{ - SetSymbolCode( 198 ); - myAX1 = Standard_ShortReal( anAttachPnt1.X() ); - myAY1 = Standard_ShortReal( anAttachPnt1.Y() ); - myAX2 = Standard_ShortReal( anAttachPnt2.X() ); - myAY2 = Standard_ShortReal( anAttachPnt2.Y() ); - GetPntProject( aLength ); - ComputeArrows( Standard_False ); - -} - -Prs2d_Length::Prs2d_Length( const Handle(Graphic2d_GraphicObject)& aGO, - const gp_Pnt2d& anAttachPnt, - const gp_Lin2d& anAttachLin, - const TCollection_ExtendedString& aText, - const Standard_Real aTxtScale, - const Standard_Real /*aLenAttachLin*/, - const Standard_Real anArrAngle, - const Standard_Real anArrLength, - const Prs2d_TypeOfArrow anArrType, - const Prs2d_ArrowSide anArrow, - const Standard_Boolean IsRevArrow ) - - : Prs2d_Dimension( aGO, aText, aTxtScale, anArrAngle, - anArrLength, anArrType, anArrow, IsRevArrow ), - - myTypeDist( Prs2d_TOD_AUTOMATIC ) - -{ - SetSymbolCode( 198 ); - gp_Pnt2d aPntProj1 = anAttachPnt, aPntProj2; - Handle(Geom2d_Line) theLine = new Geom2d_Line( anAttachLin ); - Geom2dAPI_ProjectPointOnCurve theProj( aPntProj1, theLine ); - aPntProj2 = theProj.Point(1); - - myX1 = Standard_ShortReal( aPntProj1.X() ); - myY1 = Standard_ShortReal( aPntProj1.Y() ); - myX2 = Standard_ShortReal( aPntProj2.X() ); - myY2 = Standard_ShortReal( aPntProj2.Y() ); - - myAX1 = myX1; - myAY1 = myY1; - myAX2 = myX2; - myAY2 = myY2; - - myMinX = myX1; - myMinY = myY1; - myMaxX = myX1; - myMaxY = myY1; - - if ( myX2 < myMinX ) myMinX = myX2; - if ( myY2 < myMinY ) myMinY = myY2; - if ( myX2 > myMaxX ) myMaxX = myX2; - if ( myY2 > myMaxY ) myMaxY = myY2; - - ComputeArrows( Standard_True ); -} - -Prs2d_Length::Prs2d_Length( const Handle(Graphic2d_GraphicObject)& aGO, - const gp_Lin2d& anAttachLin1, - const gp_Lin2d& anAttachLin2, - const TCollection_ExtendedString& aText, - const Standard_Real aTxtScale, - const Standard_Real /*aLenAttachLin*/, - const Standard_Real anArrAngle, - const Standard_Real anArrLength, - const Prs2d_TypeOfArrow anArrType, - const Prs2d_ArrowSide anArrow, - const Standard_Boolean IsRevArrow ) - : Prs2d_Dimension( aGO, aText, aTxtScale, anArrAngle, - anArrLength, anArrType, anArrow, IsRevArrow ), - - myTypeDist( Prs2d_TOD_AUTOMATIC ) - -{ - SetSymbolCode( 198 ); - gp_Pnt2d aPntProj1, aPntProj2; - aPntProj1 = anAttachLin1.Location(); - Handle(Geom2d_Line) theLine = new Geom2d_Line( anAttachLin2 ); - Geom2dAPI_ProjectPointOnCurve theProj( aPntProj1, theLine ); - aPntProj2 = theProj.Point(1); - - myX1 = Standard_ShortReal( aPntProj1.X() ); - myY1 = Standard_ShortReal( aPntProj1.Y() ); - myX2 = Standard_ShortReal( aPntProj2.X() ); - myY2 = Standard_ShortReal( aPntProj2.Y() ); - - myAX1 = myX1; - myAY1 = myY1; - myAX2 = myX2; - myAY2 = myY2; - - myMinX = myX1; - myMinY = myY1; - myMaxX = myX1; - myMaxY = myY1; - - if ( myX2 < myMinX ) myMinX = myX2; - if ( myY2 < myMinY ) myMinY = myY2; - if ( myX2 > myMaxX ) myMaxX = myX2; - if ( myY2 > myMaxY ) myMaxY = myY2; - - ComputeArrows( Standard_True ); - -} - -void Prs2d_Length::Draw( const Handle(Graphic2d_Drawer)& aDrawer ) -{ - Standard_Boolean IsIn = Standard_False; - - if ( ! myGOPtr->IsTransformed() ) - IsIn = aDrawer->IsIn( myMinX,myMaxX,myMinY,myMaxY ); - else - { - Standard_ShortReal minx, miny, maxx, maxy; - MinMax(minx,maxx,miny,maxy); - IsIn = aDrawer->IsIn( minx,maxx,miny,maxy ); - } - - if ( IsIn ) - { - - DrawLineAttrib(aDrawer); -// enk code get absolute coordinates for text - Standard_Real theTxtX, theTxtY,theTxtAngle; - gp_Pnt2d thePnt1(myX1,myY1), thePnt2(myX2,myY2); - gp_Vec2d VX(1.,0.), theVec(thePnt2,thePnt1); - theVec.Rotate(myTextAngle); - theTxtX=myAbsX; - theTxtY=myAbsY; - theTxtAngle=myAbsAngle; - gp_Pnt2d pntText(theTxtX,theTxtY); - Standard_Real theSmbX = 0., theSmbY = 0.; -// end enk code - if ( myIsSymbol ) - { - aDrawer->SetTextAttrib( myColorIndex, mySymbFont, 0, - Standard_ShortReal(myTextScale*aDrawer->Scale()), - Standard_ShortReal(myTextScale*aDrawer->Scale()), - Standard_False ); - Standard_Character code = SymbolCode(); - TCollection_ExtendedString txtSymb( code ); - pntText.Coord( theSmbX, theSmbY ); - Standard_ShortReal ws, hs; - aDrawer->GetTextSize( txtSymb, ws, hs ); - - Standard_ShortReal ddd = aDrawer->Convert(2); - theVec = VX.Rotated( theTxtAngle ); - theVec *= ( ws + ddd ); - gp_Pnt2d pntSymb = pntText.Translated( theVec ); - pntSymb.Coord( theTxtX, theTxtY ); - } else - { - pntText.Coord( theTxtX, theTxtY ); - } - - Standard_ShortReal a = myX1 , b = myY1 , c = myX2 , d = myY2; - Standard_ShortReal a1 = myAX1, b1 = myAY1, c1 = myAX2, d1 = myAY2, - t1 = Standard_ShortReal(theTxtX), - t2 = Standard_ShortReal(theTxtY), - ts1 = Standard_ShortReal(theSmbX), - ts2 = Standard_ShortReal(theSmbY); - - Standard_ShortReal at = myXT1, bt = myYT1, ct = myXT2, dt = myYT2; - - TShort_Array1OfShortReal Xpoint1( 1, 3 ), Ypoint1( 1, 3 ), - Xpoint2( 1, 3 ), Ypoint2( 1, 3 ); - - if ( myGOPtr->IsTransformed() ) - { - gp_GTrsf2d aTrsf = myGOPtr->Transform(); - Standard_Real AT, BT; - - if ( ( myArrow == Prs2d_AS_FIRSTAR ) || ( myArrow == Prs2d_AS_BOTHAR ) ) - { - for ( Standard_Integer j = 1; j <= 3; j++ ) - { - AT = Standard_Real( myXVert1(j) ); - BT = Standard_Real( myYVert1(j) ); - aTrsf.Transforms( AT, BT ); - Xpoint1(j) = Standard_ShortReal( AT ); - Ypoint1(j) = Standard_ShortReal( BT ); - } - } // end if myArrow is FIRSTAR ot BOTHAR - - if ( ( myArrow == Prs2d_AS_LASTAR ) || ( myArrow == Prs2d_AS_BOTHAR ) ) - { - for ( Standard_Integer j = 1; j <= 3; j++ ) - { - AT = Standard_Real( myXVert2(j) ); - BT = Standard_Real( myYVert2(j) ); - aTrsf.Transforms( AT, BT ); - Xpoint2(j) = Standard_ShortReal( AT ); - Ypoint2(j) = Standard_ShortReal( BT ); - } - } // end if myArrow is LASTAR ot BOTHAR - - AT = Standard_Real( a ); - BT = Standard_Real( b ); - aTrsf.Transforms( AT, BT ); - a = Standard_ShortReal( AT ); - b = Standard_ShortReal( BT ); - - AT = Standard_Real( c ); - BT = Standard_Real( d ); - aTrsf.Transforms( AT, BT ); - c = Standard_ShortReal( AT ); - d = Standard_ShortReal( BT ); - - AT = Standard_Real( t1 ); - BT = Standard_Real( t2 ); - aTrsf.Transforms( AT, BT ); - t1 = Standard_ShortReal( AT ); - t2 = Standard_ShortReal( BT ); - - AT = Standard_Real( a1 ); - BT = Standard_Real( b1 ); - aTrsf.Transforms( AT, BT ); - a1 = Standard_ShortReal( AT ); - b1 = Standard_ShortReal( BT ); - - AT = Standard_Real( c1 ); - BT = Standard_Real( d1 ); - aTrsf.Transforms( AT, BT ); - - c1 = Standard_ShortReal( AT ); - d1 = Standard_ShortReal( BT ); - - AT = Standard_Real( ts1 ); - BT = Standard_Real( ts2 ); - aTrsf.Transforms( AT, BT ); - ts1 = Standard_ShortReal( AT ); - ts2 = Standard_ShortReal( BT ); - - if ( ArrowIsReversed() ) - { - AT = Standard_Real( at ); - BT = Standard_Real( bt ); - aTrsf.Transforms( AT, BT ); - at = Standard_ShortReal( AT ); - bt = Standard_ShortReal( BT ); - - AT = Standard_Real( ct ); - BT = Standard_Real( dt ); - aTrsf.Transforms( AT, BT ); - ct = Standard_ShortReal( AT ); - dt = Standard_ShortReal( BT ); - } - } else - { - if ( ( myArrow == Prs2d_AS_FIRSTAR ) || ( myArrow == Prs2d_AS_BOTHAR ) ) - { - Xpoint1.Assign( myXVert1 ); - Ypoint1.Assign( myYVert1 ); - } - if ( ( myArrow == Prs2d_AS_LASTAR ) || ( myArrow == Prs2d_AS_BOTHAR ) ) - { - Xpoint2.Assign( myXVert2 ); - Ypoint2.Assign( myYVert2 ); - } - } // end if GO is transformed - - if ( ArrowIsReversed() ) - aDrawer->MapSegmentFromTo( at, bt, ct, dt ); - else - aDrawer->MapSegmentFromTo( a, b, c, d ); - - // Drawing auxiliary lines which connect a model and a dimension - // begin enk code. Auxiliary lines which connect to model with same tolerance - if (!((a==a1 && b==b1)||(c==c1 && d==d1))) - { - gp_Pnt2d aAuxLinePnt1( a, b) , aAuxLinePnt2( a1, b1); - gp_Pnt2d aAuxLinePnt3( c, d) , aAuxLinePnt4( c1, d1); - gp_Vec2d aAuxVec(aAuxLinePnt2,aAuxLinePnt1); - Standard_ShortReal dxx = aDrawer->Convert(ADDPIX); - aAuxVec.Normalize(); - - aAuxVec*=dxx; - - aAuxLinePnt1.Translate(aAuxVec); - aAuxLinePnt2.Translate(aAuxVec); - aAuxLinePnt3.Translate(aAuxVec); - aAuxLinePnt4.Translate(aAuxVec); - - a =Standard_ShortReal(aAuxLinePnt1.X()); - b =Standard_ShortReal(aAuxLinePnt1.Y()); - a1=Standard_ShortReal(aAuxLinePnt2.X()); - b1=Standard_ShortReal(aAuxLinePnt2.Y()); - c =Standard_ShortReal(aAuxLinePnt3.X()); - d =Standard_ShortReal(aAuxLinePnt3.Y()); - c1=Standard_ShortReal(aAuxLinePnt4.X()); - d1=Standard_ShortReal(aAuxLinePnt4.Y()); - } - //end enk code - - aDrawer->MapSegmentFromTo( a, b, a1, b1 ); - aDrawer->MapSegmentFromTo( c, d, c1, d1 ); - - if ( myIsSymbol ) - { - Standard_Character code = SymbolCode(); - TCollection_ExtendedString txtSymb( code ); - aDrawer->MapTextFromTo( txtSymb, ts1, ts2,Standard_ShortReal(theTxtAngle), - 0., 0., Aspect_TOT_SOLID ); - } - aDrawer->SetTextAttrib( myColorIndex, myTextFont, 0, - Standard_ShortReal(myTextScale*aDrawer->Scale()), - Standard_ShortReal(myTextScale*aDrawer->Scale()), - Standard_False ); - aDrawer->MapTextFromTo( myText, t1, t2, Standard_ShortReal(theTxtAngle), - 0., 0., Aspect_TOT_SOLID ); - -// Drawing arrows - if ( ( myArrow == Prs2d_AS_FIRSTAR ) || ( myArrow == Prs2d_AS_BOTHAR ) ) - { - if ( myArrType == Prs2d_TOA_CLOSED || myArrType == Prs2d_TOA_FILLED ) - { - aDrawer->MapPolygonFromTo( Xpoint1, Ypoint1 ); - } else - { - aDrawer->MapPolylineFromTo( Xpoint1, Ypoint1 ); - } - } - - if ( ( myArrow == Prs2d_AS_LASTAR ) || ( myArrow == Prs2d_AS_BOTHAR ) ) - { - if ( myArrType == Prs2d_TOA_CLOSED || myArrType == Prs2d_TOA_FILLED ) - { - aDrawer->MapPolygonFromTo( Xpoint2, Ypoint2 ); - } else - { - aDrawer->MapPolylineFromTo( Xpoint2, Ypoint2 ); - } - } - - } // end if IsIn is true - -} - -void Prs2d_Length::DrawElement( const Handle(Graphic2d_Drawer)& aDrawer, - const Standard_Integer anIndex ) -{ - Standard_Boolean IsIn = Standard_False; - - if ( ! myGOPtr->IsTransformed() ) - IsIn = aDrawer->IsIn( myMinX, myMaxX, myMinY, myMaxY ); - else - { - Standard_ShortReal minx, miny, maxx, maxy; - MinMax( minx, maxx, miny, maxy ); - IsIn = aDrawer->IsIn( minx, maxx, miny, maxy ); - } - - if ( IsIn ) - { - DrawLineAttrib( aDrawer ); -// begin enk code text location - Standard_Real theTxtX, theTxtY,theTxtAngle; - gp_Pnt2d thePnt1(myX1,myY1), thePnt2(myX2,myY2); - gp_Vec2d VX(1.,0.), theVec(thePnt2,thePnt1); - theVec.Rotate(myTextAngle); - theTxtX=myAbsX; - theTxtY=myAbsY; - theTxtAngle=myAbsAngle; - gp_Pnt2d pntText(theTxtX,theTxtY); -// end enk code - Standard_ShortReal a = myX1, b = myY1, c = myX2, d = myY2, - t1 = Standard_ShortReal(theTxtX), - t2 = Standard_ShortReal(theTxtY), - aa1 = myAX1, ba1 = myAY1, aa2 = myAX2, ba2 = myAY2; - TShort_Array1OfShortReal Xpoint( 1, 3 ), Ypoint( 1, 3 ); - - if ( anIndex == 1 ) - { - Xpoint.Assign( myXVert1 ); - Ypoint.Assign( myYVert1 ); - } else if ( anIndex == 2 ) - { - Xpoint.Assign( myXVert2 ); - Ypoint.Assign( myYVert2 ); - } - - if ( myGOPtr->IsTransformed () ) - { - gp_GTrsf2d aTrsf = myGOPtr->Transform (); - Standard_Real a1, b1, c1, d1, aa11, ba11, aa21, ba21; - - if ( anIndex == 1 ) - { - for ( Standard_Integer j = 1; j <= 3; j++ ) - { - a1 = Standard_Real( Xpoint(j) ); - b1 = Standard_Real( Xpoint(j) ); - aTrsf.Transforms( a1, b1 ); - Xpoint(j) = Standard_ShortReal( a1 ); - Ypoint(j) = Standard_ShortReal( b1 ); - } - } else if ( anIndex == 2 ) - { - for ( Standard_Integer j = 1; j <= 3; j++ ) - { - a1 = Standard_Real( Xpoint(j) ); - b1 = Standard_Real( Xpoint(j) ); - aTrsf.Transforms( a1, b1 ); - Xpoint(j) = Standard_ShortReal( a1 ); - Ypoint(j) = Standard_ShortReal( b1 ); - } - } else if ( anIndex == 4 ) - { - a1 = Standard_Real( a ); - b1 = Standard_Real( b ); - c1 = Standard_Real( c ); - d1 = Standard_Real( d ); - aTrsf.Transforms( a1, b1 ); - aTrsf.Transforms( c1, d1 ); - a = Standard_ShortReal( a1 ); - b = Standard_ShortReal( b1 ); - c = Standard_ShortReal( c1 ); - d = Standard_ShortReal( d1 ); - } else if ( anIndex == 3 ) - { - a1 = Standard_Real( t1 ); - b1 = Standard_Real( t2); - aTrsf.Transforms( a1, b1 ); - t1 = Standard_ShortReal( a1 ); - t2 = Standard_ShortReal( b1); - } else if ( anIndex == 5 ) - { - aa11 = Standard_Real( aa1 ); - ba11 = Standard_Real( ba1 ); - aTrsf.Transforms( aa11, ba11 ); - aa1 = Standard_ShortReal( aa11 ); - ba1 = Standard_ShortReal( ba11 ); - - } else if ( anIndex == 6 ) - { - aa21 = Standard_Real( aa2 ); - ba21 = Standard_Real( ba2 ); - aTrsf.Transforms( aa21, ba21 ); - aa2 = Standard_ShortReal( aa21 ); - ba2 = Standard_ShortReal( ba21 ); - } - } - - if ( anIndex == 1 || anIndex == 2 ) - if ( myArrType == Prs2d_TOA_CLOSED || myArrType == Prs2d_TOA_FILLED ) - { - aDrawer->MapPolygonFromTo( Xpoint, Ypoint ); - } else - { - aDrawer->MapPolylineFromTo( Xpoint, Ypoint ); - } - else if ( anIndex == 4 ) - aDrawer->MapSegmentFromTo( a, b, c, d ); - else if ( anIndex == 3 ) - aDrawer->MapTextFromTo( myText, t1, t2, Standard_ShortReal(theTxtAngle), - 0., 0., Aspect_TOT_SOLID ); - else if ( anIndex == 5 ) - aDrawer->MapSegmentFromTo( a, b, aa1, ba1 ); - else if ( anIndex == 6 ) - aDrawer->MapSegmentFromTo( c, d, aa2, ba2 ); - - } // end if IsIn is true - -} - -void Prs2d_Length::DrawVertex( const Handle(Graphic2d_Drawer)& aDrawer, - const Standard_Integer anIndex ) -{ - Standard_Boolean IsIn = Standard_False; - - if ( ! myGOPtr->IsTransformed() ) - IsIn = aDrawer->IsIn( myMinX, myMaxX, myMinY, myMaxY ); - else - { - Standard_ShortReal minx, miny, maxx, maxy; - MinMax( minx, maxx, miny, maxy ); - IsIn = aDrawer->IsIn( minx, maxx, miny, maxy ); - } - if ( IsIn ) - { - if ( anIndex == 1 || anIndex == 2 ) - { - Standard_ShortReal X=0., Y=0.; - if ( anIndex == 1 ) - { - X = myX1; Y = myY1; - } else if ( anIndex == 2 ) - { - X = myX2; Y = myY2; - } - DrawMarkerAttrib( aDrawer ); - if ( myGOPtr->IsTransformed() ) - { - gp_GTrsf2d aTrsf = myGOPtr->Transform(); - Standard_Real A = Standard_Real( X ), B = Standard_Real( Y ); - aTrsf.Transforms( A, B ); - X = Standard_ShortReal( A ); - Y = Standard_ShortReal( B ); - } - aDrawer->MapMarkerFromTo(VERTEXMARKER,X,Y, DEFAULTMARKERSIZE, - DEFAULTMARKERSIZE,0.0); - } - } -} - -Standard_Boolean Prs2d_Length::Pick( const Standard_ShortReal X, - const Standard_ShortReal Y, - const Standard_ShortReal aPrecision, - const Handle(Graphic2d_Drawer)& aDrawer ) -{ - Standard_ShortReal SRX = X, SRY = Y; - Standard_Boolean Result = Standard_False; - - if (IsInMinMax (X, Y, aPrecision) ) - { - if ( myGOPtr->IsTransformed () ) - { - gp_GTrsf2d aTrsf = ( myGOPtr->Transform() ).Inverted(); - Standard_Real RX = Standard_Real(SRX), RY = Standard_Real(SRY); - aTrsf.Transforms(RX, RY); - SRX = Standard_ShortReal(RX); - SRY = Standard_ShortReal(RY); - } - - if ( Graphic2d_Primitive::IsOn( SRX, SRY, myX1, myY1, aPrecision ) ) - { - SetPickedIndex(-1); - return Standard_True; - } else if ( Graphic2d_Primitive::IsOn( SRX, SRY, myX2, myY2, aPrecision ) ) - { - SetPickedIndex(-2); - return Standard_True; - } - - if ( ( myArrow == Prs2d_AS_FIRSTAR ) || ( myArrow == Prs2d_AS_BOTHAR ) ) - { - for ( Standard_Integer i = 1; i < 3 ; i++) - if ( IsOn( SRX, SRY, myXVert1(i), myYVert1(i), - myXVert1(i+1), myYVert1( i+1 ), aPrecision ) ) - { - SetPickedIndex(1); - return Standard_True; - } - - if ( myArrType == Prs2d_TOA_CLOSED || myArrType == Prs2d_TOA_FILLED ) - if ( IsIn( SRX, SRY, myXVert1, myYVert1, aPrecision ) ) - { - SetPickedIndex(1); - return Standard_True; - } - } // end if myArrow == FIRSTAR or BOTHAR - - if ( ( myArrow == Prs2d_AS_LASTAR ) || ( myArrow == Prs2d_AS_BOTHAR ) ) - { - for ( Standard_Integer i = 1; i < 3 ; i++) - if ( IsOn( SRX, SRY, myXVert2(i), myYVert2(i), - myXVert2(i+1), myYVert2( i+1 ), aPrecision ) ) - { - SetPickedIndex(2); - return Standard_True; - } - - if ( myArrType == Prs2d_TOA_CLOSED || myArrType == Prs2d_TOA_FILLED ) - if ( IsIn( SRX, SRY, myXVert2, myYVert2, aPrecision ) ) - { - SetPickedIndex(2); - return Standard_True; - } - } // end if myArrow == LASTAR or BOTHAR - - Standard_ShortReal width,height,xoffset,yoffset; - Standard_ShortReal hscale = Standard_ShortReal(myTextScale*aDrawer->Scale()), - wscale = Standard_ShortReal(myTextScale*aDrawer->Scale()); - Standard_ShortReal TX = X, TY = Y; - - aDrawer->SetTextAttrib( myColorIndex, myTextFont, 0, hscale, wscale, - Standard_False ); - if ( !aDrawer->GetTextSize( myText, width, height, xoffset, yoffset ) ) - { - width = height = xoffset = yoffset = 0.; - } -// begin enk code text location - Standard_Real theTxtX, theTxtY,theTxtAngle; - gp_Pnt2d thePnt1(myX1,myY1), thePnt2(myX2,myY2); - gp_Vec2d VX(1.,0.), theVec(thePnt2,thePnt1); - theVec.Rotate(myTextAngle); - theTxtX=myAbsX; - theTxtY=myAbsY; - theTxtAngle=myAbsAngle; - gp_Pnt2d pntText(theTxtX,theTxtY); -// end enk code - Standard_ShortReal cosa = Standard_ShortReal(Cos( -theTxtAngle )), - sina = Standard_ShortReal(Sin( -theTxtAngle )), - dx = TX-Standard_ShortReal(theTxtX), - dy = TY-Standard_ShortReal(theTxtY), - x = XROTATE(dx,dy), - y = YROTATE(dx,dy); - - Result = (x >= -aPrecision + xoffset) - && (x <= width + xoffset + aPrecision) - && (y >= -yoffset - aPrecision) - && (y <= height - yoffset + aPrecision); - - if ( Result ) - { - SetPickedIndex(3); - return Standard_True; - } -// begin enk code auxiality lines - Standard_ShortReal a,b,c,d,a1,b1,c1,d1; - a = myX1; - b = myY1; - a1= myAX1; - b1= myAY1; - c = myX2; - d = myY2; - c1= myAX2; - d1= myAY2; - if (!((a==a1 && b==b1)||(c==c1 && d==d1))) - { - gp_Pnt2d aAuxLinePnt1( myX1, myY1) , aAuxLinePnt2( myAX1, myAY1); - gp_Pnt2d aAuxLinePnt3( myX2, myY2) , aAuxLinePnt4( myAX2, myAY2); - gp_Vec2d aAuxVec(aAuxLinePnt2,aAuxLinePnt1); - Standard_ShortReal dxx = aDrawer->Convert(ADDPIX); - - aAuxVec.Normalize(); - aAuxVec*=dxx; - aAuxLinePnt1.Translate(aAuxVec); - aAuxLinePnt2.Translate(aAuxVec); - aAuxLinePnt3.Translate(aAuxVec); - aAuxLinePnt4.Translate(aAuxVec); - - a =Standard_ShortReal(aAuxLinePnt1.X()); - b =Standard_ShortReal(aAuxLinePnt1.Y()); - a1=Standard_ShortReal(aAuxLinePnt2.X()); - b1=Standard_ShortReal(aAuxLinePnt2.Y()); - c =Standard_ShortReal(aAuxLinePnt3.X()); - d =Standard_ShortReal(aAuxLinePnt3.Y()); - c1=Standard_ShortReal(aAuxLinePnt4.X()); - d1=Standard_ShortReal(aAuxLinePnt4.Y()); - } - // end enk code - - if ( IsOn( SRX, SRY, myX1, myY1, myX2, myY2, aPrecision ) ) - { - SetPickedIndex( 4 ); - return Standard_True; - } else if ( IsOn( SRX, SRY, a, b, a1, b1, aPrecision ) ) - { - SetPickedIndex( 5 ); - return Standard_True; - } else if ( IsOn( SRX, SRY, c, d, c1, d1, aPrecision ) ) - { - SetPickedIndex( 6 ); - return Standard_True; - } - } - return Standard_False; -} - -void Prs2d_Length::GetPntProject( const Standard_Real aLength ) -{ - - gp_Pnt2d myPntAttach1( myAX1, myAY1 ), myPntAttach2( myAX2, myAY2 ); - gp_Pnt2d aPntProj1, aPntProj2, MinMaxPnt = myPntAttach1; - - switch ( myTypeDist ) - { - case Prs2d_TOD_HORIZONTAL: - { - if ( aLength < 0 ) - { - if ( MinMaxPnt.Y() > myPntAttach2.Y() ) - { - myPntAttach1 = myPntAttach2; - myPntAttach2 = MinMaxPnt; - } - } else - { - if ( MinMaxPnt.Y() < myPntAttach2.Y() ) - { - myPntAttach1 = myPntAttach2; - myPntAttach2 = MinMaxPnt; - } - } - aPntProj1 = gp_Pnt2d( myPntAttach1.X(), myPntAttach1.Y() + aLength ); - Handle(Geom2d_Line) theLine = new Geom2d_Line( aPntProj1, - gp_Dir2d( aPntProj1.X(), 0. ) ); - Geom2dAPI_ProjectPointOnCurve theProj( myPntAttach2, theLine ); - aPntProj2 = theProj.Point(1); - - break; - } - - case Prs2d_TOD_VERTICAL: - { - if ( aLength < 0 ) - { - if ( MinMaxPnt.X() > myPntAttach2.X() ) - { - myPntAttach1 = myPntAttach2; - myPntAttach2 = MinMaxPnt; - } - } else - { - if ( MinMaxPnt.X() < myPntAttach2.X() ) - { - myPntAttach1 = myPntAttach2; - myPntAttach2 = MinMaxPnt; - } - } - aPntProj1 = gp_Pnt2d( myPntAttach1.X() + aLength , myPntAttach1.Y()); - Handle(Geom2d_Line) theLine = new Geom2d_Line( aPntProj1, - gp_Dir2d( 0., aPntProj1.Y() ) ); - Geom2dAPI_ProjectPointOnCurve theProj( myPntAttach2, theLine ); - aPntProj2 = theProj.Point(1); - break; - } - -/* case Prs2d_TOD_OBLIQUE: - { - gp_Vec2d DirLin1( myPntAttach1, myPntAttach2 ); - gp_Vec2d DirLin2 = DirLin1.Reversed(); - DirLin1.Normalize(); - DirLin2.Normalize(); - DirLin1 *= aLength; - DirLin2 *= aLength; - DirLin1.Rotate( M_PI/2. ); - DirLin2.Rotate( -M_PI/2. ); - aPntProj1 = myPntAttach1.Translated( DirLin1 ); - aPntProj2 = myPntAttach2.Translated( DirLin2 );; - break; - } */ // commented by enk - - case Prs2d_TOD_AUTOMATIC: - case Prs2d_TOD_OBLIQUE: - default: - { - gp_Vec2d DirLin1( myPntAttach1, myPntAttach2 ); - gp_Vec2d DirLin2 = DirLin1.Reversed(); - DirLin1.Normalize(); - DirLin2.Normalize(); - DirLin1 *= aLength; - DirLin2 *= aLength; - DirLin1.Rotate( M_PI/2. ); - DirLin2.Rotate( -M_PI/2. ); - aPntProj1 = myPntAttach1.Translated( DirLin1 ); - aPntProj2 = myPntAttach2.Translated( DirLin2 );; - break; - } - } // end switch TypeOfDist - - myAX1 = Standard_ShortReal( myPntAttach1.X() ); - myAY1 = Standard_ShortReal( myPntAttach1.Y() ); - myAX2 = Standard_ShortReal( myPntAttach2.X() ); - myAY2 = Standard_ShortReal( myPntAttach2.Y() ); - myX1 = Standard_ShortReal( aPntProj1.X() ); - myY1 = Standard_ShortReal( aPntProj1.Y() ); - myX2 = Standard_ShortReal( aPntProj2.X() ); - myY2 = Standard_ShortReal( aPntProj2.Y() ); - - myMinX = Min( myX1, myX2 ); - myMinY = Min( myY1, myY2 ); - myMaxX = Max( myX1, myX2 ); - myMaxY = Max( myY1, myY2 ); - - if ( myAX1 < myMinX ) myMinX = myAX1; - if ( myAY1 < myMinY ) myMinY = myAY1; - if ( myAX1 > myMaxX ) myMaxX = myAX1; - if ( myAY1 > myMaxY ) myMaxY = myAY1; - - if ( myAX2 < myMinX ) myMinX = myAX2; - if ( myAY2 < myMinY ) myMinY = myAY2; - if ( myAX2 > myMaxX ) myMaxX = myAX2; - if ( myAY2 > myMaxY ) myMaxY = myAY2; - -} - -void Prs2d_Length::ComputeArrows( const Standard_Boolean /*isnotPoints*/ ) -{ - - Standard_Real ArrAngle = M_PI/180. * ArrowAngle(), theAngle; - gp_Pnt2d aPnt1( myX1, myY1 ), aPnt2( myX2, myY2 ); - gp_Pnt2d theOrigine( 0., 0.), P1, P2, P3; - gp_Vec2d VX( 1., 0. ), VDir; - - myXT1 = myX1; - myYT1 = myY1; - myXT2 = myX2; - myYT2 = myY2; - - if ( ArrowIsReversed() ) - { - gp_Pnt2d tP1 = aPnt1, tP2 = aPnt2; - gp_Vec2d tVD( aPnt1, aPnt2 ); - tVD.Normalize(); - tVD *= ( 1.3 * myArrowLen ); - tP1.Translate( -tVD ); - tP2.Translate( tVD ); - Standard_Real X1, Y1, X2, Y2; - tP1.Coord( X1, Y1 ); - tP2.Coord( X2, Y2 ); - - myXT1 = Standard_ShortReal( X1 ); - myYT1 = Standard_ShortReal( Y1 ); - myXT2 = Standard_ShortReal( X2 ); - myYT2 = Standard_ShortReal( Y2 ); - } - - if ( ( myArrow == Prs2d_AS_FIRSTAR ) || ( myArrow == Prs2d_AS_BOTHAR ) ) - { - P1 = aPnt1; - P2 = gp_Pnt2d( myArrowLen, myArrowLen*Tan( ArrAngle/2. ) ); - P3 = gp_Pnt2d( myArrowLen, -myArrowLen*Tan( ArrAngle/2. ) ); - VDir = gp_Vec2d( aPnt1, aPnt2 ); - if ( ArrowIsReversed() ) VDir.Reverse(); - theAngle = VX.Angle( VDir ); - P2.Rotate( theOrigine, theAngle ); - P3.Rotate( theOrigine, theAngle ); - P2.Translate( gp_Vec2d( theOrigine, P1 ) ); - P3.Translate( gp_Vec2d( theOrigine, P1 ) ); - - myXVert1(1) = Standard_ShortReal( P2.X() ); - myYVert1(1) = Standard_ShortReal( P2.Y() ); - myXVert1(2) = Standard_ShortReal( P1.X() ); - myYVert1(2) = Standard_ShortReal( P1.Y() ); - myXVert1(3) = Standard_ShortReal( P3.X() ); - myYVert1(3) = Standard_ShortReal( P3.Y() ); - - for ( Standard_Integer i = 1; i <= 3; i++ ) - { - if ( myXVert1(i) < myMinX ) myMinX = myXVert1(i); - if ( myYVert1(i) < myMinY ) myMinY = myYVert1(i); - if ( myXVert1(i) > myMaxX ) myMaxX = myXVert1(i); - if ( myYVert1(i) > myMaxY ) myMaxY = myYVert1(i); - } - } // end if myArrow is FIRSTAR or BOTHAR - - if ( ( myArrow == Prs2d_AS_LASTAR ) || ( myArrow == Prs2d_AS_BOTHAR ) ) - { - P1 = aPnt2; - P2 = gp_Pnt2d( myArrowLen, myArrowLen * Tan( ArrAngle/2. ) ); - P3 = gp_Pnt2d( myArrowLen, -myArrowLen * Tan( ArrAngle/2. ) ); - VDir = gp_Vec2d( aPnt2, aPnt1 ); - if ( ArrowIsReversed() ) VDir.Reverse(); - theAngle = VX.Angle( VDir ); - P2.Rotate( theOrigine, theAngle ); - P3.Rotate( theOrigine, theAngle ); - P2.Translate( gp_Vec2d( theOrigine, P1 ) ); - P3.Translate( gp_Vec2d( theOrigine, P1 ) ); - - myXVert2(1) = Standard_ShortReal( P2.X() ); - myYVert2(1) = Standard_ShortReal( P2.Y() ); - myXVert2(2) = Standard_ShortReal( P1.X() ); - myYVert2(2) = Standard_ShortReal( P1.Y() ); - myXVert2(3) = Standard_ShortReal( P3.X() ); - myYVert2(3) = Standard_ShortReal( P3.Y() ); - - for ( Standard_Integer i = 1; i <= 3; i++ ) - { - if ( myXVert2(i) < myMinX ) myMinX = myXVert2(i); - if ( myYVert2(i) < myMinY ) myMinY = myYVert2(i); - if ( myXVert2(i) > myMaxX ) myMaxX = myXVert2(i); - if ( myYVert2(i) > myMaxY ) myMaxY = myYVert2(i); - } - } // end if myArrow is FIRSTAR or BOTHAR - - myNumOfElem = 6; - myNumOfVert = 2; -} - -void Prs2d_Length::SetAttachLinLength( const Standard_Real aLength ) -{ - GetPntProject(aLength); - ComputeArrows( Standard_False ); -} - -void Prs2d_Length::Save(Aspect_FStream& aFStream) const -{ -} - -void Prs2d_Length::LineCoord( gp_Pnt2d& aFirstPnt, gp_Pnt2d& aSecondPnt ) const -{ - aFirstPnt = gp_Pnt2d( myXT1, myYT1 ); - aSecondPnt = gp_Pnt2d( myXT2, myYT2 ); -} - -void Prs2d_Length::CallOutCoord( gp_Pnt2d& aFirstPnt, gp_Pnt2d& aSecondPnt ) const -{ - aFirstPnt = gp_Pnt2d( myAX1, myAY1 ); - aSecondPnt = gp_Pnt2d( myAX2, myAY2 ); -} - -Prs2d_TypeOfDist Prs2d_Length::TypeOfDist() const -{ - return myTypeDist; -} diff --git a/src/Prs2d/Prs2d_Length.lxx b/src/Prs2d/Prs2d_Length.lxx deleted file mode 100755 index 212728464e..0000000000 --- a/src/Prs2d/Prs2d_Length.lxx +++ /dev/null @@ -1,58 +0,0 @@ -// Copyright (c) 1999-2012 OPEN CASCADE SAS -// -// The content of this file is subject to the Open CASCADE Technology Public -// License Version 6.5 (the "License"). You may not use the content of this file -// except in compliance with the License. Please obtain a copy of the License -// at http://www.opencascade.org and read it completely before using this file. -// -// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its -// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. -// -// The Original Code and all software distributed under the License is -// distributed on an "AS IS" basis, without warranty of any kind, and the -// Initial Developer hereby disclaims all such warranties, including without -// limitation, any warranties of merchantability, fitness for a particular -// purpose or non-infringement. Please see the License for the specific terms -// and conditions governing the rights and limitations under the License. - -inline void Prs2d_Length::CalcTxtPos(const Standard_Boolean theFromAbs) { - - if (!theFromAbs) - { - - gp_Pnt2d thePnt1(myX1,myY1), thePnt2(myX2,myY2),theOrigine,theTmp; - if ( (myX1==myX2 && myY1>myY2 ) || (myX1>myX2) ) - { - theTmp = thePnt1; - thePnt1 = thePnt2; - thePnt2 = theTmp; - } - gp_Vec2d VX( 1., 0. ), theVecI,theVecJ,theVec(thePnt1,thePnt2),tmpVec; - Standard_Real coeff=21.5/12;// this coefficient from font symbol size - Standard_Real theTextLen=myText.Length()*myTextScale*coeff; - Standard_Real theDist=thePnt1.Distance(thePnt2); - - theVec.Normalize(); - - theVecI = theVec*(theDist/2-theTextLen/2+myTextPosH); - tmpVec = theVec*(theDist/2+myTextPosH); - theVecJ = theVec.Rotated(M_PI/2)*myTextPosV; - - theOrigine=thePnt1; - theOrigine.Translate(tmpVec); - theOrigine.Translate(theVecJ); - - theVec.Rotate(myTextAngle); - - thePnt1.Translate(theVecI); - thePnt1.Translate(theVecJ); - thePnt1.Rotate(theOrigine, myTextAngle); - - Standard_Real theTxtAngle = VX.Angle( theVec ); - gp_Pnt2d pntText=thePnt1; - - myAbsAngle=theTxtAngle; - myAbsX=pntText.X(); - myAbsY=pntText.Y(); - } -} diff --git a/src/Prs2d/Prs2d_LineProfile.cdl b/src/Prs2d/Prs2d_LineProfile.cdl deleted file mode 100755 index f1adb74fb5..0000000000 --- a/src/Prs2d/Prs2d_LineProfile.cdl +++ /dev/null @@ -1,54 +0,0 @@ --- Created by: TCL --- Copyright (c) 2000-2012 OPEN CASCADE SAS --- --- The content of this file is subject to the Open CASCADE Technology Public --- License Version 6.5 (the "License"). You may not use the content of this file --- except in compliance with the License. Please obtain a copy of the License --- at http://www.opencascade.org and read it completely before using this file. --- --- The Initial Developer of the Original Code is Open CASCADE S.A.S., having its --- main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. --- --- The Original Code and all software distributed under the License is --- distributed on an "AS IS" basis, without warranty of any kind, and the --- Initial Developer hereby disclaims all such warranties, including without --- limitation, any warranties of merchantability, fitness for a particular --- purpose or non-infringement. Please see the License for the specific terms --- and conditions governing the rights and limitations under the License. - - -class LineProfile from Prs2d inherits Tolerance from Prs2d - -uses - - GraphicObject from Graphic2d, - Drawer from Graphic2d, - Length from Quantity, - FStream from Aspect - -is - ------------------------- - -- Category: Constructors - ------------------------- - - Create( aGO : GraphicObject from Graphic2d; - aX, aY : Real from Standard; - aLength : Real from Standard = 3.0; - anAngle : Real from Standard = 0.0 ); - ---Level: Public - ---Purpose: Creates a tolerance LineProfile with the center at , ; - -- length of this is ; - -- reference point is , - ---Category: Constructor - - -------------------------- - -- Category: Draw and Pick - -------------------------- - - Draw( me : mutable; aDrawer: Drawer from Graphic2d ) is static protected; - ---Level: Internal - ---Purpose: Draws the LineProfile . - - Save( me; aFStream: in out FStream from Aspect ) is virtual; - -end LineProfile from Prs2d; diff --git a/src/Prs2d/Prs2d_LineProfile.cxx b/src/Prs2d/Prs2d_LineProfile.cxx deleted file mode 100755 index 5a7f5ec82e..0000000000 --- a/src/Prs2d/Prs2d_LineProfile.cxx +++ /dev/null @@ -1,70 +0,0 @@ -// Copyright (c) 1999-2012 OPEN CASCADE SAS -// -// The content of this file is subject to the Open CASCADE Technology Public -// License Version 6.5 (the "License"). You may not use the content of this file -// except in compliance with the License. Please obtain a copy of the License -// at http://www.opencascade.org and read it completely before using this file. -// -// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its -// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. -// -// The Original Code and all software distributed under the License is -// distributed on an "AS IS" basis, without warranty of any kind, and the -// Initial Developer hereby disclaims all such warranties, including without -// limitation, any warranties of merchantability, fitness for a particular -// purpose or non-infringement. Please see the License for the specific terms -// and conditions governing the rights and limitations under the License. - -#include - -Prs2d_LineProfile::Prs2d_LineProfile( const Handle(Graphic2d_GraphicObject)& aGO, - const Standard_Real aX, - const Standard_Real aY, - const Standard_Real aLength, - const Standard_Real anAngle ) - - : Prs2d_Tolerance( aGO,aX, aY, aLength, anAngle ) -{ -} - -void Prs2d_LineProfile::Draw( const Handle(Graphic2d_Drawer)& aDrawer ) { - - Standard_Boolean IsIn = Standard_False; - - if ( !myGOPtr->IsTransformed() ) - IsIn = aDrawer->IsIn( myMinX, myMaxX, myMinY, myMaxY ); - else { - Standard_ShortReal minx, miny, maxx, maxy; - MinMax( minx, maxx, miny, maxy ); - IsIn = aDrawer->IsIn( minx, maxx, miny, maxy ); - } - - if ( IsIn ) { - DrawLineAttrib( aDrawer ); - Standard_ShortReal X1 = myX, - Y1 = myY - myLength/4; - - gp_Pnt2d P1( X1, Y1 ), - PR( myX, myY ); - P1.Rotate( PR, myAngle ); - - X1 = Standard_ShortReal( P1.X() ); - Y1 = Standard_ShortReal( P1.Y() ); - - if ( myGOPtr->IsTransformed () ) { - gp_GTrsf2d aTrsf = myGOPtr->Transform (); - Standard_Real a1, b1; - a1 = X1; - b1 = Y1; - aTrsf.Transforms( a1, b1 ); - X1 = Standard_ShortReal( a1 ); - Y1 = Standard_ShortReal( b1 ); - } - - aDrawer->MapArcFromTo( X1, Y1, myLength/2, myAngle, Standard_ShortReal( M_PI + myAngle ) ); - } -} - -void Prs2d_LineProfile::Save(Aspect_FStream& aFStream) const -{ -} diff --git a/src/Prs2d/Prs2d_Parallelism.cdl b/src/Prs2d/Prs2d_Parallelism.cdl deleted file mode 100755 index 597d052e0c..0000000000 --- a/src/Prs2d/Prs2d_Parallelism.cdl +++ /dev/null @@ -1,54 +0,0 @@ --- Created by: TCL --- Copyright (c) 2000-2012 OPEN CASCADE SAS --- --- The content of this file is subject to the Open CASCADE Technology Public --- License Version 6.5 (the "License"). You may not use the content of this file --- except in compliance with the License. Please obtain a copy of the License --- at http://www.opencascade.org and read it completely before using this file. --- --- The Initial Developer of the Original Code is Open CASCADE S.A.S., having its --- main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. --- --- The Original Code and all software distributed under the License is --- distributed on an "AS IS" basis, without warranty of any kind, and the --- Initial Developer hereby disclaims all such warranties, including without --- limitation, any warranties of merchantability, fitness for a particular --- purpose or non-infringement. Please see the License for the specific terms --- and conditions governing the rights and limitations under the License. - - -class Parallelism from Prs2d inherits Tolerance from Prs2d - -uses - - GraphicObject from Graphic2d, - Drawer from Graphic2d, - Length from Quantity, - FStream from Aspect - -is - ------------------------- - -- Category: Constructors - ------------------------- - - Create( aGO : GraphicObject from Graphic2d; - aX, aY : Real from Standard; - aLength : Real from Standard = 3.0; - anAngle : Real from Standard = 0.0 ); - ---Level: Public - ---Purpose: Creates a tolerance Parallelism with the center at , ; - -- length of this is ; - -- reference point is , - ---Category: Constructor - - -------------------------- - -- Category: Draw and Pick - -------------------------- - - Draw( me : mutable; aDrawer: Drawer from Graphic2d ) is static protected; - ---Level: Internal - ---Purpose: Draws the Parallelism . - - Save( me; aFStream: in out FStream from Aspect ) is virtual; - -end Parallelism from Prs2d; diff --git a/src/Prs2d/Prs2d_Parallelism.cxx b/src/Prs2d/Prs2d_Parallelism.cxx deleted file mode 100755 index 4cc3857f57..0000000000 --- a/src/Prs2d/Prs2d_Parallelism.cxx +++ /dev/null @@ -1,105 +0,0 @@ -// Copyright (c) 1999-2012 OPEN CASCADE SAS -// -// The content of this file is subject to the Open CASCADE Technology Public -// License Version 6.5 (the "License"). You may not use the content of this file -// except in compliance with the License. Please obtain a copy of the License -// at http://www.opencascade.org and read it completely before using this file. -// -// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its -// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. -// -// The Original Code and all software distributed under the License is -// distributed on an "AS IS" basis, without warranty of any kind, and the -// Initial Developer hereby disclaims all such warranties, including without -// limitation, any warranties of merchantability, fitness for a particular -// purpose or non-infringement. Please see the License for the specific terms -// and conditions governing the rights and limitations under the License. - -#include - -Prs2d_Parallelism::Prs2d_Parallelism( const Handle(Graphic2d_GraphicObject)& aGO, - const Standard_Real aX, - const Standard_Real aY, - const Standard_Real aLength, - const Standard_Real anAngle ) - - : Prs2d_Tolerance( aGO, aX, aY, aLength, anAngle ) -{ -} - -void Prs2d_Parallelism::Draw( const Handle(Graphic2d_Drawer)& aDrawer ) { - - Standard_Boolean IsIn = Standard_False; - - if ( !myGOPtr->IsTransformed() ) - IsIn = aDrawer->IsIn( myMinX, myMaxX, myMinY, myMaxY ); - else { - Standard_ShortReal minx, miny, maxx, maxy; - MinMax( minx, maxx, miny, maxy ); - IsIn = aDrawer->IsIn( minx, maxx, miny, maxy ); - } - - if ( IsIn ) { - DrawLineAttrib( aDrawer ); - - Standard_ShortReal X1 = myX - myLength/2, - Y1 = myY - myLength/2, - X2 = Standard_ShortReal( X1 + myLength * Cos( M_PI / 4 ) ), - Y2 = myY + myLength/2, - X3 = Standard_ShortReal(myX + myLength* Cos( M_PI / 4 ) ), - Y3 = Y2, - X4 = myX, - Y4 = Y1; - - gp_Pnt2d P1( X1, Y1 ), - P2( X2, Y2 ), - P3( X3, Y3 ), - P4( X4, Y4 ), - PR( myX, myY ); - P1.Rotate( PR, myAngle ); - P2.Rotate( PR, myAngle ); - P3.Rotate( PR, myAngle ); - P4.Rotate( PR, myAngle ); - - X1 = Standard_ShortReal( P1.X() ); - Y1 = Standard_ShortReal( P1.Y() ); - X2 = Standard_ShortReal( P2.X() ); - Y2 = Standard_ShortReal( P2.Y() ); - X3 = Standard_ShortReal( P3.X() ); - Y3 = Standard_ShortReal( P3.Y() ); - X4 = Standard_ShortReal( P4.X() ); - Y4 = Standard_ShortReal( P4.Y() ); - - if ( myGOPtr->IsTransformed () ) { - gp_GTrsf2d aTrsf = myGOPtr->Transform (); - Standard_Real a1, b1; - a1 = X1; - b1 = Y1; - aTrsf.Transforms( a1, b1 ); - X1 = Standard_ShortReal( a1 ); - Y1 = Standard_ShortReal( b1 ); - a1 = X2; - b1 = Y2; - aTrsf.Transforms( a1, b1 ); - X2 = Standard_ShortReal( a1 ); - Y2 = Standard_ShortReal( b1 ); - a1 = X3; - b1 = Y3; - aTrsf.Transforms( a1, b1 ); - X3 = Standard_ShortReal( a1 ); - Y3 = Standard_ShortReal( b1 ); - a1 = X4; - b1 = Y4; - aTrsf.Transforms( a1, b1 ); - X4 = Standard_ShortReal( a1 ); - Y4 = Standard_ShortReal( b1 ); - } - aDrawer->MapSegmentFromTo( X1, Y1, X2, Y2 ); - aDrawer->MapSegmentFromTo( X4, Y4, X3, Y3 ); - } - -} - -void Prs2d_Parallelism::Save(Aspect_FStream& aFStream) const -{ -} diff --git a/src/Prs2d/Prs2d_Perpendicular.cdl b/src/Prs2d/Prs2d_Perpendicular.cdl deleted file mode 100755 index 2cdda2da40..0000000000 --- a/src/Prs2d/Prs2d_Perpendicular.cdl +++ /dev/null @@ -1,54 +0,0 @@ --- Created by: TCL --- Copyright (c) 2000-2012 OPEN CASCADE SAS --- --- The content of this file is subject to the Open CASCADE Technology Public --- License Version 6.5 (the "License"). You may not use the content of this file --- except in compliance with the License. Please obtain a copy of the License --- at http://www.opencascade.org and read it completely before using this file. --- --- The Initial Developer of the Original Code is Open CASCADE S.A.S., having its --- main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. --- --- The Original Code and all software distributed under the License is --- distributed on an "AS IS" basis, without warranty of any kind, and the --- Initial Developer hereby disclaims all such warranties, including without --- limitation, any warranties of merchantability, fitness for a particular --- purpose or non-infringement. Please see the License for the specific terms --- and conditions governing the rights and limitations under the License. - - -class Perpendicular from Prs2d inherits Tolerance from Prs2d - -uses - - GraphicObject from Graphic2d, - Drawer from Graphic2d, - Length from Quantity, - FStream from Aspect - -is - ------------------------- - -- Category: Constructors - ------------------------- - - Create( aGO : GraphicObject from Graphic2d; - aX, aY : Real from Standard; - aLength : Real from Standard = 3.0; - anAngle : Real from Standard = 0.0 ); - ---Level: Public - ---Purpose: Creates a tolerance Perpendicular with the center at , ; - -- length of this is ; - -- reference point is , - ---Category: Constructor - - -------------------------- - -- Category: Draw and Pick - -------------------------- - - Draw( me : mutable; aDrawer: Drawer from Graphic2d ) is static protected; - ---Level: Internal - ---Purpose: Draws the Perpendicular . - - Save( me; aFStream: in out FStream from Aspect ) is virtual; - -end Perpendicular from Prs2d; diff --git a/src/Prs2d/Prs2d_Perpendicular.cxx b/src/Prs2d/Prs2d_Perpendicular.cxx deleted file mode 100755 index 5b202d412f..0000000000 --- a/src/Prs2d/Prs2d_Perpendicular.cxx +++ /dev/null @@ -1,100 +0,0 @@ -// Copyright (c) 1999-2012 OPEN CASCADE SAS -// -// The content of this file is subject to the Open CASCADE Technology Public -// License Version 6.5 (the "License"). You may not use the content of this file -// except in compliance with the License. Please obtain a copy of the License -// at http://www.opencascade.org and read it completely before using this file. -// -// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its -// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. -// -// The Original Code and all software distributed under the License is -// distributed on an "AS IS" basis, without warranty of any kind, and the -// Initial Developer hereby disclaims all such warranties, including without -// limitation, any warranties of merchantability, fitness for a particular -// purpose or non-infringement. Please see the License for the specific terms -// and conditions governing the rights and limitations under the License. - -#include - -Prs2d_Perpendicular::Prs2d_Perpendicular( const Handle(Graphic2d_GraphicObject)& aGO, - const Standard_Real aX, - const Standard_Real aY, - const Standard_Real aLength, - const Standard_Real anAngle ) - - : Prs2d_Tolerance( aGO, aX, aY, aLength, anAngle ) -{ -} - -void Prs2d_Perpendicular::Draw( const Handle(Graphic2d_Drawer)& aDrawer ) { - - Standard_Boolean IsIn = Standard_False; - - if ( !myGOPtr->IsTransformed() ) - IsIn = aDrawer->IsIn( myMinX, myMaxX, myMinY, myMaxY ); - else { - Standard_ShortReal minx, miny, maxx, maxy; - MinMax( minx, maxx, miny, maxy ); - IsIn = aDrawer->IsIn( minx, maxx, miny, maxy ); - } - - if ( IsIn ) { - Standard_ShortReal X1 = myX, - Y1 = myY - myLength/4, - X2 = myX, - Y2 = myY + myLength/2, - X3 = myX - myLength/2, - Y3 = Y1, - X4 = myX + myLength/2, - Y4 = Y1; - gp_Pnt2d P1( X1, Y1 ), - P2( X2, Y2 ), - P3( X3, Y3 ), - P4( X4, Y4 ), - PR( myX, myY ); - P1.Rotate( PR, myAngle ); - P2.Rotate( PR, myAngle ); - P3.Rotate( PR, myAngle ); - P4.Rotate( PR, myAngle ); - X1 = Standard_ShortReal( P1.X() ); - Y1 = Standard_ShortReal( P1.Y() ); - X2 = Standard_ShortReal( P2.X() ); - Y2 = Standard_ShortReal( P2.Y() ); - X3 = Standard_ShortReal( P3.X() ); - Y3 = Standard_ShortReal( P3.Y() ); - X4 = Standard_ShortReal( P4.X() ); - Y4 = Standard_ShortReal( P4.Y() ); - if ( myGOPtr->IsTransformed () ) { - gp_GTrsf2d aTrsf = myGOPtr->Transform (); - Standard_Real a1, b1; - a1 = X1; - b1 = Y1; - aTrsf.Transforms( a1, b1 ); - X1 = Standard_ShortReal( a1 ); - Y1 = Standard_ShortReal( b1 ); - a1 = X2; - b1 = Y2; - aTrsf.Transforms( a1, b1 ); - X2 = Standard_ShortReal( a1 ); - Y2 = Standard_ShortReal( b1 ); - a1 = X3; - b1 = Y3; - aTrsf.Transforms( a1, b1 ); - X3 = Standard_ShortReal( a1 ); - Y3 = Standard_ShortReal( b1 ); - a1 = X4; - b1 = Y4; - aTrsf.Transforms( a1, b1 ); - X4 = Standard_ShortReal( a1 ); - Y4 = Standard_ShortReal( b1 ); - } - aDrawer->MapSegmentFromTo( X1, Y1, X2, Y2 ); - aDrawer->MapSegmentFromTo( X4, Y4, X3, Y3 ); - } - -} - -void Prs2d_Perpendicular::Save(Aspect_FStream& aFStream) const -{ -} diff --git a/src/Prs2d/Prs2d_Point.cdl b/src/Prs2d/Prs2d_Point.cdl deleted file mode 100755 index 6400c2484d..0000000000 --- a/src/Prs2d/Prs2d_Point.cdl +++ /dev/null @@ -1,113 +0,0 @@ --- Created by: Tanya COOL --- Copyright (c) 2000-2012 OPEN CASCADE SAS --- --- The content of this file is subject to the Open CASCADE Technology Public --- License Version 6.5 (the "License"). You may not use the content of this file --- except in compliance with the License. Please obtain a copy of the License --- at http://www.opencascade.org and read it completely before using this file. --- --- The Initial Developer of the Original Code is Open CASCADE S.A.S., having its --- main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. --- --- The Original Code and all software distributed under the License is --- distributed on an "AS IS" basis, without warranty of any kind, and the --- Initial Developer hereby disclaims all such warranties, including without --- limitation, any warranties of merchantability, fitness for a particular --- purpose or non-infringement. Please see the License for the specific terms --- and conditions governing the rights and limitations under the License. - - -class Point from Prs2d inherits Line from Graphic2d - - ---Purpose: Constructs presentable and selectable Point. - -- It's displayed as a definite type Marker from - -- Aspect_TypeOfMarker - -uses - - Pnt2d from gp, - PlaneAngle from Quantity, - Length from Quantity, - GraphicObject from Graphic2d, - Drawer from Graphic2d, - TypeOfMarker from Aspect, - FStream from Aspect - -is - - Create( aGO : GraphicObject from Graphic2d; - aPnt : Pnt2d from gp; - aTOM : TypeOfMarker from Aspect; - aWSize : Length from Quantity = 2.0; - aHSize : Length from Quantity = 2.0; - anAngle : PlaneAngle from Quantity = 0.0 ) - returns mutable Point from Prs2d; - ---Purpose: Initializes the Point defined - - -------------------------- - -- Category: Draw and Pick - -------------------------- - - Draw( me : mutable; aDrawer: Drawer from Graphic2d ) - is static protected; - ---Level: Internal - ---Purpose: Draws the angle . - - DrawElement( me : mutable; aDrawer: Drawer from Graphic2d; - anIndex: Integer from Standard) - is redefined protected; - ---Level: Internal - ---Purpose: Draws element of the point . - - DrawVertex( me : mutable; aDrawer: Drawer from Graphic2d; - anIndex: Integer from Standard) - is redefined protected; - ---Level: Internal - ---Purpose: Draws vertex of the point . - - Pick( me: mutable; X, Y : ShortReal from Standard; - aPrecision: ShortReal from Standard; - aDrawer : Drawer from Graphic2d) - returns Boolean from Standard is static protected; - ---Level: Internal - ---Purpose: Returns Standard_True if the point is picked, - -- Standard_False if not. - - --------------------------------------------------------------------- - ---Category: Modifications of the class properties - - SetPoint( me: mutable; aPnt: Pnt2d from gp ); - ---Level: Public - ---Purpose: Modifies the Point by redefining location - - SetMarker( me: mutable; aTOM: TypeOfMarker from Aspect ); - ---Level: Public - ---Purpose: Modifies the Point by redefining type of marker - - SetIndex( me: mutable; anInd: Integer from Standard ); - ---Level: Internal - ---Purpose: Sets the map index of the marker - - --------------------------------------------------------------------- - ---Category: Inquire methods - - Point( me ) returns Pnt2d from gp; - ---Level: Public - ---Purpose: Returns the location of the Point - - Marker( me ) returns TypeOfMarker from Aspect; - ---Level: Public - ---Purpose: Returns the type of marker of the Point - - Save( me; aFStream: in out FStream from Aspect ) is virtual; - -fields - - myPoint : Pnt2d from gp; - myTOM : TypeOfMarker from Aspect; - myIndMark : Integer from Standard; - myWSize : Length from Quantity; - myHSize : Length from Quantity; - myAngle : PlaneAngle from Quantity; - -end Point; diff --git a/src/Prs2d/Prs2d_Point.cxx b/src/Prs2d/Prs2d_Point.cxx deleted file mode 100755 index d48075018c..0000000000 --- a/src/Prs2d/Prs2d_Point.cxx +++ /dev/null @@ -1,121 +0,0 @@ -// Copyright (c) 1999-2012 OPEN CASCADE SAS -// -// The content of this file is subject to the Open CASCADE Technology Public -// License Version 6.5 (the "License"). You may not use the content of this file -// except in compliance with the License. Please obtain a copy of the License -// at http://www.opencascade.org and read it completely before using this file. -// -// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its -// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. -// -// The Original Code and all software distributed under the License is -// distributed on an "AS IS" basis, without warranty of any kind, and the -// Initial Developer hereby disclaims all such warranties, including without -// limitation, any warranties of merchantability, fitness for a particular -// purpose or non-infringement. Please see the License for the specific terms -// and conditions governing the rights and limitations under the License. - -#include - -Prs2d_Point::Prs2d_Point( const Handle(Graphic2d_GraphicObject)& aGO, - const gp_Pnt2d& aPnt, - const Aspect_TypeOfMarker aTOM, - const Quantity_Length aWSize, - const Quantity_Length aHSize, - const Quantity_PlaneAngle anAngle ) - - : Graphic2d_Line( aGO ), - myPoint( aPnt ), - myTOM( aTOM ), - myIndMark( 0 ), - myWSize( aWSize ), - myHSize( aHSize ), - myAngle( anAngle ) -{ - - if ( ( myWSize <= 0.0 ) || ( myHSize <= 0.0 ) ) - myWSize = myHSize = 0.0; - - myMinX = Standard_ShortReal(myPoint.X() - myWSize/2.); - myMinY = Standard_ShortReal(myPoint.Y() - myHSize/2.); - myMaxX = Standard_ShortReal(myPoint.X() + myWSize/2.); - myMaxY = Standard_ShortReal(myPoint.Y() + myHSize/2.); - -} - -void Prs2d_Point::Draw( const Handle(Graphic2d_Drawer)& aDrawer ) { - - Standard_Boolean IsIn = Standard_False; - - if ( !myGOPtr->IsTransformed() ) - IsIn = aDrawer->IsIn( myMinX, myMaxX, myMinY, myMaxY ); - else { - Standard_ShortReal minx, miny, maxx, maxy; - MinMax( minx, maxx, miny, maxy ); - IsIn = aDrawer->IsIn( minx, maxx, miny, maxy ); - } - - if ( IsIn ) { - - Standard_ShortReal a = Standard_ShortReal(myPoint.X()); - Standard_ShortReal b = Standard_ShortReal(myPoint.Y()); - - if ( myGOPtr->IsTransformed() ) { - - gp_GTrsf2d aTrsf = myGOPtr->Transform(); - Standard_Real A = Standard_Real( a ); - Standard_Real B = Standard_Real( b ); - aTrsf.Transforms( A, B ); - a = Standard_ShortReal( A ); - b = Standard_ShortReal( B ); - } - - DrawMarkerAttrib( aDrawer ); - aDrawer->MapMarkerFromTo( myIndMark, a, b, Standard_ShortReal(myWSize), - Standard_ShortReal(myHSize), Standard_ShortReal(myAngle) ); - } - -} - -void Prs2d_Point::DrawElement( const Handle(Graphic2d_Drawer)& /*ADrawer*/, - const Standard_Integer /*anIndex*/ ) { - -} - -void Prs2d_Point::DrawVertex( const Handle(Graphic2d_Drawer)& /*aDrawer*/, - const Standard_Integer /*anIndex*/ ) { - -} - -Standard_Boolean Prs2d_Point::Pick( const Standard_ShortReal X, - const Standard_ShortReal Y, - const Standard_ShortReal aPrecision, - const Handle(Graphic2d_Drawer)& /*aDrawer*/ ) { - - return IsInMinMax( X, Y, aPrecision ); - -} - -void Prs2d_Point::SetPoint( const gp_Pnt2d& aPnt ) { - myPoint = aPnt; -} - -void Prs2d_Point::SetMarker( const Aspect_TypeOfMarker aTOM ) { - myTOM = aTOM; -} - -void Prs2d_Point::SetIndex( const Standard_Integer anInd ) { - myIndMark = anInd; -} - -gp_Pnt2d Prs2d_Point::Point() const { - return myPoint; -} - -Aspect_TypeOfMarker Prs2d_Point::Marker() const { - return myTOM; -} - -void Prs2d_Point::Save(Aspect_FStream& aFStream) const -{ -} diff --git a/src/Prs2d/Prs2d_Position.cdl b/src/Prs2d/Prs2d_Position.cdl deleted file mode 100755 index 8d67a194c8..0000000000 --- a/src/Prs2d/Prs2d_Position.cdl +++ /dev/null @@ -1,54 +0,0 @@ --- Created by: TCL --- Copyright (c) 2000-2012 OPEN CASCADE SAS --- --- The content of this file is subject to the Open CASCADE Technology Public --- License Version 6.5 (the "License"). You may not use the content of this file --- except in compliance with the License. Please obtain a copy of the License --- at http://www.opencascade.org and read it completely before using this file. --- --- The Initial Developer of the Original Code is Open CASCADE S.A.S., having its --- main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. --- --- The Original Code and all software distributed under the License is --- distributed on an "AS IS" basis, without warranty of any kind, and the --- Initial Developer hereby disclaims all such warranties, including without --- limitation, any warranties of merchantability, fitness for a particular --- purpose or non-infringement. Please see the License for the specific terms --- and conditions governing the rights and limitations under the License. - - -class Position from Prs2d inherits Tolerance from Prs2d - -uses - - GraphicObject from Graphic2d, - Drawer from Graphic2d, - Length from Quantity, - FStream from Aspect - -is - ------------------------- - -- Category: Constructors - ------------------------- - - Create( aGO : GraphicObject from Graphic2d; - aX, aY : Real from Standard; - aLength : Real from Standard = 3.0; - anAngle : Real from Standard = 0.0 ); - ---Level: Public - ---Purpose: Creates a tolerance Position with the center at , ; - -- length of this is ; - -- reference point is , - ---Category: Constructor - - -------------------------- - -- Category: Draw and Pick - -------------------------- - - Draw( me : mutable; aDrawer: Drawer from Graphic2d ) is static protected; - ---Level: Internal - ---Purpose: Draws the Position . - - Save( me; aFStream: in out FStream from Aspect ) is virtual; - -end Position from Prs2d; diff --git a/src/Prs2d/Prs2d_Position.cxx b/src/Prs2d/Prs2d_Position.cxx deleted file mode 100755 index 7f3785e385..0000000000 --- a/src/Prs2d/Prs2d_Position.cxx +++ /dev/null @@ -1,115 +0,0 @@ -// Copyright (c) 1999-2012 OPEN CASCADE SAS -// -// The content of this file is subject to the Open CASCADE Technology Public -// License Version 6.5 (the "License"). You may not use the content of this file -// except in compliance with the License. Please obtain a copy of the License -// at http://www.opencascade.org and read it completely before using this file. -// -// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its -// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. -// -// The Original Code and all software distributed under the License is -// distributed on an "AS IS" basis, without warranty of any kind, and the -// Initial Developer hereby disclaims all such warranties, including without -// limitation, any warranties of merchantability, fitness for a particular -// purpose or non-infringement. Please see the License for the specific terms -// and conditions governing the rights and limitations under the License. - -#include - -Prs2d_Position::Prs2d_Position( const Handle(Graphic2d_GraphicObject)& aGO, - const Standard_Real aX, - const Standard_Real aY, - const Standard_Real aLength, - const Standard_Real anAngle ) - - : Prs2d_Tolerance( aGO, aX, aY, aLength, anAngle ) -{ -} - -void Prs2d_Position::Draw( const Handle(Graphic2d_Drawer)& aDrawer ) { - - Standard_Boolean IsIn = Standard_False; - - if ( !myGOPtr->IsTransformed() ) - IsIn = aDrawer->IsIn( myMinX, myMaxX, myMinY, myMaxY ); - else { - Standard_ShortReal minx, miny, maxx, maxy; - MinMax( minx, maxx, miny, maxy ); - IsIn = aDrawer->IsIn( minx, maxx, miny, maxy ); - } - - if ( IsIn ) { - DrawLineAttrib( aDrawer ); - Standard_ShortReal X1 = myX, - Y1 = myY - 2 * myLength/3, - X2 = myX, - Y2 = myY + 2 * myLength/3, - X3 = myX - 2 * myLength/3, - Y3 = myY, - X4 = myX + 2 * myLength/3, - Y4 = myY, - Xc = myX, - Yc = myY; - - gp_Pnt2d P1( X1, Y1 ), - P2( X2, Y2 ), - P3( X3, Y3 ), - P4( X4, Y4 ), - PC( Xc, Yc ), - PR( myX, myY ); - P1.Rotate( PR, myAngle ); - P2.Rotate( PR, myAngle ); - P3.Rotate( PR, myAngle ); - P4.Rotate( PR, myAngle ); - PC.Rotate( PR, myAngle ); - - X1 = Standard_ShortReal( P1.X() ); - Y1 = Standard_ShortReal( P1.Y() ); - X2 = Standard_ShortReal( P2.X() ); - Y2 = Standard_ShortReal( P2.Y() ); - X3 = Standard_ShortReal( P3.X() ); - Y3 = Standard_ShortReal( P3.Y() ); - X4 = Standard_ShortReal( P4.X() ); - Y4 = Standard_ShortReal( P4.Y() ); - Xc = Standard_ShortReal( PC.X() ); - Yc = Standard_ShortReal( PC.Y() ); - - if ( myGOPtr->IsTransformed () ) { - gp_GTrsf2d aTrsf = myGOPtr->Transform (); - Standard_Real a1, b1; - a1 = X1; - b1 = Y1; - aTrsf.Transforms( a1, b1 ); - X1 = Standard_ShortReal( a1 ); - Y1 = Standard_ShortReal( b1 ); - a1 = X2; - b1 = Y2; - aTrsf.Transforms( a1, b1 ); - X2 = Standard_ShortReal( a1 ); - Y2 = Standard_ShortReal( b1 ); - a1 = X3; - b1 = Y3; - aTrsf.Transforms( a1, b1 ); - X3 = Standard_ShortReal( a1 ); - Y3 = Standard_ShortReal( b1 ); - a1 = X4; - b1 = Y4; - aTrsf.Transforms( a1, b1 ); - X4 = Standard_ShortReal( a1 ); - Y4 = Standard_ShortReal( b1 ); - a1 = Xc; - b1 = Yc; - aTrsf.Transforms( a1, b1 ); - Xc = Standard_ShortReal( a1 ); - Yc = Standard_ShortReal( b1 ); - } - aDrawer->MapSegmentFromTo( X1, Y1, X2, Y2 ); - aDrawer->MapSegmentFromTo( X4, Y4, X3, Y3 ); - aDrawer->MapArcFromTo( Xc, Yc, myLength/2, 0.0, Standard_ShortReal( 2. * M_PI ) ); - } -} - -void Prs2d_Position::Save(Aspect_FStream& aFStream) const -{ -} diff --git a/src/Prs2d/Prs2d_Radius.cdl b/src/Prs2d/Prs2d_Radius.cdl deleted file mode 100755 index 36147308d5..0000000000 --- a/src/Prs2d/Prs2d_Radius.cdl +++ /dev/null @@ -1,111 +0,0 @@ --- Created by: Tanya COOL --- Copyright (c) 2000-2012 OPEN CASCADE SAS --- --- The content of this file is subject to the Open CASCADE Technology Public --- License Version 6.5 (the "License"). You may not use the content of this file --- except in compliance with the License. Please obtain a copy of the License --- at http://www.opencascade.org and read it completely before using this file. --- --- The Initial Developer of the Original Code is Open CASCADE S.A.S., having its --- main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. --- --- The Original Code and all software distributed under the License is --- distributed on an "AS IS" basis, without warranty of any kind, and the --- Initial Developer hereby disclaims all such warranties, including without --- limitation, any warranties of merchantability, fitness for a particular --- purpose or non-infringement. Please see the License for the specific terms --- and conditions governing the rights and limitations under the License. - - -class Radius from Prs2d inherits Dimension from Prs2d - - ---Purpose: Constructs the primitive Radius - -uses - - Drawer from Graphic2d, - GraphicObject from Graphic2d, - Pnt2d from gp, - Circ2d from gp, - ExtendedString from TCollection, - ArrowSide from Prs2d, - TypeOfDist from Prs2d, - TypeOfArrow from Prs2d, - FStream from Aspect - -raises - - ConstructionError from Standard - -is - Create( aGraphicObject: GraphicObject from Graphic2d; - anAttachPnt : Pnt2d from gp; - aCircle : Circ2d from gp; - aText : ExtendedString from TCollection; - aTxtScale : Real from Standard = 10.0; - anArrAngle : Real from Standard = 20.0; - anArrLength : Real from Standard = 25.0; - anArrType : TypeOfArrow from Prs2d = Prs2d_TOA_OPENED; - anArrow : ArrowSide from Prs2d = Prs2d_AS_BOTHAR; - IsReverseArrow: Boolean from Standard = Standard_False ) - returns mutable Radius from Prs2d; - - ---Purpose: Creates the radius of the circle passing through - -- the point - - -------------------------------------- - -- Category: Inquire methods - -------------------------------------- - - Values( me; anAttPnt: out Pnt2d from gp; - aCirc: out Circ2d from gp ); - ---Level: Internal - ---Purpose: allows to get the properties of the diameter - - -------------------------- - -- Category: Draw and Pick - -------------------------- - - Draw( me : mutable; aDrawer: Drawer from Graphic2d ) - is static protected; - ---Level: Internal - ---Purpose: Draws the angle . - - DrawElement( me : mutable; aDrawer: Drawer from Graphic2d; - anIndex: Integer from Standard) - is redefined protected; - ---Level: Internal - ---Purpose: Draws element of the radius . - - DrawVertex( me : mutable; aDrawer: Drawer from Graphic2d; - anIndex: Integer from Standard) - is redefined protected; - ---Level: Internal - ---Purpose: Draws vertex of the radius . - - Pick( me : mutable; X, Y: ShortReal from Standard; - aPrecision: ShortReal from Standard; - aDrawer: Drawer from Graphic2d) - returns Boolean from Standard - is static protected; - ---Level: Internal - ---Purpose: Returns Standard_True if the radius is picked, - -- Standard_False if not. - - Save( me; aFStream: in out FStream from Aspect ) is virtual; - - CalcTxtPos(me:mutable; theFromAbs: - Boolean from Standard=Standard_False) - ---C++: inline - is redefined protected; - -fields - - myX1 : ShortReal from Standard; - myY1 : ShortReal from Standard; - myX2 : ShortReal from Standard; - myY2 : ShortReal from Standard; - myPnt : Pnt2d from gp; - myCirc : Circ2d from gp; - -end Radius from Prs2d; diff --git a/src/Prs2d/Prs2d_Radius.cxx b/src/Prs2d/Prs2d_Radius.cxx deleted file mode 100755 index 758f176551..0000000000 --- a/src/Prs2d/Prs2d_Radius.cxx +++ /dev/null @@ -1,574 +0,0 @@ -// Copyright (c) 1999-2012 OPEN CASCADE SAS -// -// The content of this file is subject to the Open CASCADE Technology Public -// License Version 6.5 (the "License"). You may not use the content of this file -// except in compliance with the License. Please obtain a copy of the License -// at http://www.opencascade.org and read it completely before using this file. -// -// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its -// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. -// -// The Original Code and all software distributed under the License is -// distributed on an "AS IS" basis, without warranty of any kind, and the -// Initial Developer hereby disclaims all such warranties, including without -// limitation, any warranties of merchantability, fitness for a particular -// purpose or non-infringement. Please see the License for the specific terms -// and conditions governing the rights and limitations under the License. - -#include -#include - -#define VERTEXMARKER 2 -#define DEFAULTMARKERSIZE 3.0 -#define XROTATE(x,y) ((x)*cosa - (y)*sina) -#define YROTATE(x,y) ((y)*cosa + (x)*sina) -#define ADDPIX 17 - -Prs2d_Radius::Prs2d_Radius( const Handle(Graphic2d_GraphicObject) & aGO, - const gp_Pnt2d & anAttachPnt, - const gp_Circ2d & aCircle, - const TCollection_ExtendedString & aText, - const Standard_Real aTxtScale, - const Standard_Real anArrAngle, - const Standard_Real anArrLength, - const Prs2d_TypeOfArrow anArrType, - const Prs2d_ArrowSide anArrow, - const Standard_Boolean IsRevArrow ) - - : Prs2d_Dimension( aGO, aText, aTxtScale, anArrAngle, - anArrLength, anArrType, anArrow, IsRevArrow ), - - myPnt( anAttachPnt ), - myCirc( aCircle ) - -{ - SetSymbolCode( 198 ); - gp_Pnt2d aPnt1 = anAttachPnt, aPnt2 = aCircle.Location(); - Standard_Real U = ElCLib::Parameter( aCircle, aPnt1 ); - gp_Pnt2d PTonCirc = ElCLib::Value( U, aCircle ); - -// gp_Vec2d theVec( PTonCirc, aPnt2 ); - Standard_Real theDist = aPnt2.Distance( aPnt1 ); - Standard_Real theRad = aCircle.Radius(); - Standard_Boolean inside = Standard_False; - - if ( theDist < theRad ) { - aPnt1 = PTonCirc; - theDist = theRad; - inside = Standard_True; - } - - Standard_Real X1, Y1, X2, Y2; - aPnt1.Coord( X1, Y1 ); - aPnt2.Coord( X2, Y2 ); - - myX1 = Standard_ShortReal( X1 ); - myY1 = Standard_ShortReal( Y1 ); - myX2 = Standard_ShortReal( X2 ); - myY2 = Standard_ShortReal( Y2 ); - - myMinX = myX1; - myMinY = myY1; - myMaxX = myX1; - myMaxY = myY1; - - if ( myX2 < myMinX ) myMinX = myX2; - if ( myY2 < myMinY ) myMinY = myY2; - if ( myX2 > myMaxX ) myMaxX = myX2; - if ( myY2 > myMaxY ) myMaxY = myY2; - - Standard_Real ArrAngle = M_PI/180.* anArrAngle, theAngle; - gp_Pnt2d theOrigine( 0., 0. ), P1, P2, P3; - gp_Vec2d VX( 1., 0. ), VDir; - - if ( ( myArrow == Prs2d_AS_FIRSTAR ) || ( myArrow == Prs2d_AS_BOTHAR ) ) { - P1 = aPnt1; - - P2 = gp_Pnt2d( anArrLength, anArrLength*Tan( ArrAngle/2. ) ); - P3 = gp_Pnt2d( anArrLength, -anArrLength*Tan( ArrAngle/2. ) ); - - VDir = gp_Vec2d( aPnt1, aPnt2 ); - if ( IsRevArrow ) VDir.Reverse(); - - theAngle = VX.Angle( VDir ); - - P2.Rotate( theOrigine, theAngle ); - P3.Rotate( theOrigine, theAngle ); - - P2.Translate( gp_Vec2d( theOrigine, P1 ) ); - P3.Translate( gp_Vec2d( theOrigine, P1 ) ); - - myXVert1(1) = Standard_ShortReal( P2.X() ); - myYVert1(1) = Standard_ShortReal( P2.Y() ); - myXVert1(2) = Standard_ShortReal( P1.X() ); - myYVert1(2) = Standard_ShortReal( P1.Y() ); - myXVert1(3) = Standard_ShortReal( P3.X() ); - myYVert1(3) = Standard_ShortReal( P3.Y() ); - - for ( Standard_Integer i = 1; i <= 3; i++ ) { - - if ( myXVert1(i) < myMinX ) myMinX = myXVert1(i); - if ( myYVert1(i) < myMinY ) myMinY = myYVert1(i); - if ( myXVert1(i) > myMaxX ) myMaxX = myXVert1(i); - if ( myYVert1(i) > myMaxY ) myMaxY = myYVert1(i); - - } - } // end if myArrow is FIRSTAR or BOTHAR - - if ( ( myArrow == Prs2d_AS_LASTAR ) || ( myArrow == Prs2d_AS_BOTHAR ) ){ - P1 = aPnt2; - - P2 = gp_Pnt2d( anArrLength, anArrLength*Tan( ArrAngle/2. ) ); - P3 = gp_Pnt2d( anArrLength, -anArrLength*Tan( ArrAngle/2. ) ); - - VDir = gp_Vec2d( aPnt2, aPnt1 ); - if ( IsRevArrow ) VDir.Reverse(); - - theAngle = VX.Angle( VDir ); - - P2.Rotate( theOrigine, theAngle ); - P3.Rotate( theOrigine, theAngle ); - - P2.Translate( gp_Vec2d( theOrigine, P1 ) ); - P3.Translate( gp_Vec2d( theOrigine, P1 ) ); - - myXVert2(1) = Standard_ShortReal( P2.X() ); - myYVert2(1) = Standard_ShortReal( P2.Y() ); - myXVert2(2) = Standard_ShortReal( P1.X() ); - myYVert2(2) = Standard_ShortReal( P1.Y() ); - myXVert2(3) = Standard_ShortReal( P3.X() ); - myYVert2(3) = Standard_ShortReal( P3.Y() ); - - for ( Standard_Integer i = 1; i <= 3; i++ ) { - if ( myXVert2(i) < myMinX ) myMinX = myXVert2(i); - if ( myYVert2(i) < myMinY ) myMinY = myYVert2(i); - if ( myXVert2(i) > myMaxX ) myMaxX = myXVert2(i); - if ( myYVert2(i) > myMaxY ) myMaxY = myYVert2(i); - - } - } // end if myArrow is FIRSTAR or BOTHAR - myNumOfElem = 4; - myNumOfVert = 2; - -} - -void Prs2d_Radius::Values( gp_Pnt2d& anAttPnt,gp_Circ2d& aCirc ) const { - anAttPnt = myPnt; - aCirc = myCirc; -} - -void Prs2d_Radius::Draw( const Handle(Graphic2d_Drawer)& aDrawer ) { - - Standard_Boolean IsIn = Standard_False; - - if (! myGOPtr->IsTransformed ()) - IsIn = aDrawer->IsIn (myMinX,myMaxX,myMinY,myMaxY); - else { - Standard_ShortReal minx, miny, maxx, maxy; - MinMax(minx,maxx,miny,maxy); - IsIn = aDrawer->IsIn (minx,maxx,miny,maxy); - } - - if ( IsIn ) { - - DrawLineAttrib( aDrawer ); - - Standard_ShortReal d1 = aDrawer->Convert(ADDPIX); - gp_Pnt2d thePnt1(myX1,myY1+d1), thePnt2(myX2,myY2+d1); - gp_Vec2d VX( 1., 0. ), theVec(thePnt2, thePnt1); - Standard_Real theTxtAngle = VX.Angle( theVec ); - gp_Pnt2d pntText; - if ( theTxtAngle >= 0 && theTxtAngle <= M_PI/2 ) - pntText = thePnt2.Translated( (myArrowLen+d1)*theVec/(thePnt1.Distance(thePnt2)) ); - else if ( theTxtAngle > M_PI/2 && theTxtAngle <= M_PI ) { - pntText = thePnt1.Translated( (myArrowLen+d1)*theVec.Reversed()/(thePnt1.Distance(thePnt2)) ); - theTxtAngle = VX.Angle( theVec.Reversed() ); - } else if ( theTxtAngle >= -M_PI/2 && theTxtAngle < 0 ) - pntText = thePnt2.Translated( (myArrowLen+d1)*theVec/(thePnt1.Distance(thePnt2)) ); - else if ( theTxtAngle >= -M_PI && theTxtAngle < -M_PI/2 ) { - pntText = thePnt1.Translated( (myArrowLen+d1)*theVec.Reversed()/(thePnt1.Distance(thePnt2)) ); - theTxtAngle = VX.Angle( theVec.Reversed() ); - } - - Standard_Real theTxtX, theTxtY; - Standard_Real theSmbX = 0., theSmbY = 0.; - - if ( myIsSymbol ) { - aDrawer->SetTextAttrib( myColorIndex, mySymbFont, 0, Standard_ShortReal(myTextScale*aDrawer->Scale()), - Standard_ShortReal(myTextScale*aDrawer->Scale()), Standard_False ); -// TCollection_ExtendedString txtSymb( char( SymbolCode() ) ); - Standard_Character code = SymbolCode(); - TCollection_ExtendedString txtSymb( code ); - pntText.Coord( theSmbX, theSmbY ); - Standard_ShortReal ws=0., hs=0.; - aDrawer->GetTextSize( txtSymb, ws, hs ); - Standard_ShortReal ddd = aDrawer->Convert(2); - theVec = VX.Rotated( theTxtAngle ); - theVec *= ( ws + ddd ); - gp_Pnt2d pntSymb = pntText.Translated( theVec ); - pntSymb.Coord( theTxtX, theTxtY ); - } else { - pntText.Coord( theTxtX, theTxtY ); - } - - Standard_ShortReal a = myX1, b = myY1, c = myX2, d = myY2, - t1 = Standard_ShortReal(theTxtX), t2 = Standard_ShortReal(theTxtY), - ts1 = Standard_ShortReal(theSmbX), ts2 = Standard_ShortReal(theSmbY); - - TShort_Array1OfShortReal Xpoint1( 1, 3 ), Ypoint1( 1, 3 ), - Xpoint2( 1, 3 ), Ypoint2( 1, 3 ); - - - if ( myGOPtr->IsTransformed () ) { - gp_GTrsf2d aTrsf = myGOPtr->Transform (); - - if ( ( myArrow == Prs2d_AS_FIRSTAR ) || ( myArrow == Prs2d_AS_BOTHAR ) ){ - - Standard_Real a1, b1; - for ( Standard_Integer j = 1; j <= 3; j++ ) { - a1 = Standard_Real( myXVert1(j) ); - b1 = Standard_Real( myYVert1(j) ); - aTrsf.Transforms (a1, b1); - Xpoint1(j) = Standard_ShortReal(a1); - Ypoint1(j) = Standard_ShortReal(b1); - } - } // end if myArrow is FIRSTAR ot BOTHAR - - if ( ( myArrow == Prs2d_AS_LASTAR ) || ( myArrow == Prs2d_AS_BOTHAR ) ) { - - Standard_Real ac1,ad1; - - for ( Standard_Integer j = 1; j <= 3; j++ ) { - ac1 = Standard_Real( myXVert2(j) ); - ad1 = Standard_Real( myYVert2(j) ); - aTrsf.Transforms (ac1, ad1); - Xpoint2(j) = Standard_ShortReal(ac1); - Ypoint2(j) = Standard_ShortReal(ad1); - } - } // end if myArrow is LASTAR ot BOTHAR - - Standard_Real A, B; - A = Standard_Real( a ); - B = Standard_Real( b ); - aTrsf.Transforms( A, B ); - a = Standard_ShortReal( A ); - b = Standard_ShortReal( B ); - A = Standard_Real( c ); - B = Standard_Real( d ); - aTrsf.Transforms( A, B ); - c = Standard_ShortReal( A ); - d = Standard_ShortReal( B ); - A = Standard_Real( t1 ); - B = Standard_Real( t2); - aTrsf.Transforms( A, B ); - t1 = Standard_ShortReal( A ); - t2 = Standard_ShortReal( B ); - A = Standard_Real( ts1 ); - B = Standard_Real( ts2 ); - aTrsf.Transforms( A, B ); - ts1 = Standard_ShortReal( A ); - ts2 = Standard_ShortReal( B ); - - } else { - - if ( ( myArrow == Prs2d_AS_FIRSTAR ) || ( myArrow == Prs2d_AS_BOTHAR ) ){ - Xpoint1.Assign( myXVert1 ); - Ypoint1.Assign( myYVert1 ); - } - if ( ( myArrow == Prs2d_AS_LASTAR ) || ( myArrow == Prs2d_AS_BOTHAR ) ) { - Xpoint2.Assign( myXVert2 ); - Ypoint2.Assign( myYVert2 ); - } - - } // end if GO is transformed - - aDrawer->MapSegmentFromTo( a, b, c, d ); - - if ( myIsSymbol ) { -// TCollection_ExtendedString txtSymb( char( SymbolCode() ) ); - Standard_Character code = SymbolCode(); - TCollection_ExtendedString txtSymb( code ); - Standard_ShortReal dx=0.,dy=0.; - aDrawer->MapTextFromTo( txtSymb, ts1, ts2, Standard_ShortReal(theTxtAngle), dx, dy, Aspect_TOT_SOLID ); - - } - - aDrawer->SetTextAttrib( myColorIndex, myTextFont, 0, Standard_ShortReal(myTextScale*aDrawer->Scale()), - Standard_ShortReal(myTextScale*aDrawer->Scale()), Standard_False ); - - aDrawer->MapTextFromTo( myText, t1, t2, Standard_ShortReal(theTxtAngle), 0., 0., Aspect_TOT_SOLID ); - - if ( ( myArrow == Prs2d_AS_FIRSTAR ) || ( myArrow == Prs2d_AS_BOTHAR ) ){ - if ( myArrType == Prs2d_TOA_CLOSED || myArrType == Prs2d_TOA_FILLED ) { - aDrawer->MapPolygonFromTo( Xpoint1, Ypoint1 ); - } else { - aDrawer->MapPolylineFromTo( Xpoint1, Ypoint1 ); - } - } - - if ( ( myArrow == Prs2d_AS_LASTAR ) || ( myArrow == Prs2d_AS_BOTHAR ) ){ - if ( myArrType == Prs2d_TOA_CLOSED || myArrType == Prs2d_TOA_FILLED ) { - aDrawer->MapPolygonFromTo( Xpoint2, Ypoint2 ); - } else { - aDrawer->MapPolylineFromTo( Xpoint2, Ypoint2 ); - } - } - - - } // end if IsIn is true - -} - -void Prs2d_Radius::DrawElement( const Handle(Graphic2d_Drawer)& aDrawer, - const Standard_Integer anIndex ) { - - Standard_Boolean IsIn = Standard_False; - - if ( ! myGOPtr->IsTransformed() ) - IsIn = aDrawer->IsIn( myMinX, myMaxX, myMinY, myMaxY ); - else { - Standard_ShortReal minx, miny, maxx, maxy; - MinMax( minx, maxx, miny, maxy ); - IsIn = aDrawer->IsIn( minx, maxx, miny, maxy ); - } - - if ( IsIn ) { - - DrawLineAttrib( aDrawer ); - // aDrawer->SetTextAttrib( myColorIndex, myTextFont, 0, myTextScale*aDrawer->Scale(), - // myTextScale*aDrawer->Scale(), Standard_False ); - - Standard_ShortReal d1 = aDrawer->Convert(ADDPIX); - gp_Pnt2d thePnt1(myX1,myY1+d1), thePnt2(myX2,myY2+d1); - gp_Vec2d VX( 1., 0. ), theVec(thePnt2, thePnt1); - Standard_Real theTxtAngle = VX.Angle( theVec ); - gp_Pnt2d pntText; - if ( theTxtAngle >= 0 && theTxtAngle <= M_PI/2 ) - pntText = thePnt2.Translated( (myArrowLen+d1)*theVec/(thePnt1.Distance(thePnt2)) ); - else if ( theTxtAngle > M_PI/2 && theTxtAngle <= M_PI ) { - pntText = thePnt1.Translated( (myArrowLen+d1)*theVec.Reversed()/(thePnt1.Distance(thePnt2)) ); - theTxtAngle = VX.Angle( theVec.Reversed() ); - } else if ( theTxtAngle >= -M_PI/2 && theTxtAngle < 0 ) - pntText = thePnt2.Translated( (myArrowLen+d1)*theVec/(thePnt1.Distance(thePnt2)) ); - else if ( theTxtAngle >= -M_PI && theTxtAngle < -M_PI/2 ) { - pntText = thePnt1.Translated( (myArrowLen+d1)*theVec.Reversed()/(thePnt1.Distance(thePnt2)) ); - theTxtAngle = VX.Angle( theVec.Reversed() ); - } - Standard_Real theTxtX, theTxtY; - pntText.Coord( theTxtX, theTxtY ); - - Standard_ShortReal a = myX1, b = myY1, c = myX2, d = myY2, - t1 = Standard_ShortReal(theTxtX), t2 = Standard_ShortReal(theTxtY); - TShort_Array1OfShortReal Xpoint( 1, 3 ), Ypoint( 1, 3 ); - - if ( anIndex == 1 ) { - Xpoint.Assign( myXVert1 ); - Ypoint.Assign( myYVert1 ); - } else if ( anIndex == 2 ) { - Xpoint.Assign( myXVert2 ); - Ypoint.Assign( myYVert2 ); - } - - if ( myGOPtr->IsTransformed () ) { - gp_GTrsf2d aTrsf = myGOPtr->Transform (); - Standard_Real a1, b1, c1, ad1; - - if ( anIndex == 1 ) { - for ( Standard_Integer j = 1; j <= 3; j++ ) { - a1 = Standard_Real( Xpoint(j) ); - b1 = Standard_Real( Xpoint(j) ); - aTrsf.Transforms( a1, b1 ); - Xpoint(j) = Standard_ShortReal( a1 ); - Ypoint(j) = Standard_ShortReal( b1 ); - } - } else if ( anIndex == 2 ) { - - for ( Standard_Integer j = 1; j <= 3; j++ ) { - a1 = Standard_Real( Xpoint(j) ); - b1 = Standard_Real( Xpoint(j) ); - aTrsf.Transforms( a1, b1 ); - Xpoint(j) = Standard_ShortReal( a1 ); - Ypoint(j) = Standard_ShortReal( b1 ); - } - } else if ( anIndex == 4 ) { - - a1 = Standard_Real( a ); - b1 = Standard_Real( b ); - c1 = Standard_Real( c ); - ad1 = Standard_Real( d ); - aTrsf.Transforms( a1, b1 ); - aTrsf.Transforms( c1, ad1 ); - a = Standard_ShortReal( a1 ); - b = Standard_ShortReal( b1 ); - c = Standard_ShortReal( c1 ); - d = Standard_ShortReal( ad1 ); - - } else if ( anIndex == 3 ) { - a1 = Standard_Real( t1 ); - b1 = Standard_Real( t2); - aTrsf.Transforms( a1, b1 ); - t1 = Standard_ShortReal( a1 ); - t2 = Standard_ShortReal( b1); - } - } - - if ( anIndex == 1 || anIndex == 2 ) - if ( myArrType == Prs2d_TOA_CLOSED || myArrType == Prs2d_TOA_FILLED ) { - aDrawer->MapPolygonFromTo( Xpoint, Ypoint ); - } else { - aDrawer->MapPolylineFromTo( Xpoint, Ypoint ); - } - else if ( anIndex == 4 ) - aDrawer->MapSegmentFromTo( a, b, c, d ); - else if ( anIndex == 3 ) - aDrawer->MapTextFromTo( myText, t1, t2, Standard_ShortReal(theTxtAngle), 0., 0., Aspect_TOT_SOLID ); - - } // end if IsIn is true - -} - -void Prs2d_Radius::DrawVertex( const Handle(Graphic2d_Drawer)& aDrawer, - const Standard_Integer anIndex ) { - - Standard_Boolean IsIn = Standard_False; - - if ( ! myGOPtr->IsTransformed() ) - IsIn = aDrawer->IsIn( myMinX, myMaxX, myMinY, myMaxY ); - else { - Standard_ShortReal minx, miny, maxx, maxy; - MinMax( minx, maxx, miny, maxy ); - IsIn = aDrawer->IsIn( minx, maxx, miny, maxy ); - } - if ( IsIn ) { - if ( anIndex == 1 || anIndex == 2 ) { - Standard_ShortReal X=0., Y=0.; - if ( anIndex == 1 ) { - X = myX1; Y = myY1; - } else if ( anIndex == 2 ) { - X = myX2; Y = myY2; - } - DrawMarkerAttrib( aDrawer ); - if ( myGOPtr->IsTransformed() ) { - gp_GTrsf2d aTrsf = myGOPtr->Transform(); - Standard_Real A = Standard_Real( X ), B = Standard_Real( Y ); - aTrsf.Transforms( A, B ); - X = Standard_ShortReal( A ); - Y = Standard_ShortReal( B ); - } - aDrawer->MapMarkerFromTo(VERTEXMARKER,X,Y, DEFAULTMARKERSIZE,DEFAULTMARKERSIZE,0.0); - } - } -} - -Standard_Boolean Prs2d_Radius::Pick( const Standard_ShortReal X, - const Standard_ShortReal Y, - const Standard_ShortReal aPrecision, - const Handle(Graphic2d_Drawer)& aDrawer ) { - - Standard_ShortReal SRX = X, SRY = Y; - Standard_Boolean Result = Standard_False; - - if ( IsInMinMax( X, Y, aPrecision ) ) { - if ( myGOPtr->IsTransformed () ) { - gp_GTrsf2d aTrsf = ( myGOPtr->Transform() ).Inverted(); - Standard_Real RX = Standard_Real(SRX), RY = Standard_Real(SRY); - aTrsf.Transforms(RX, RY); - SRX = Standard_ShortReal(RX); - SRY = Standard_ShortReal(RY); - } - - if ( Graphic2d_Primitive::IsOn( SRX, SRY, myX1, myY1, aPrecision ) ) { - SetPickedIndex(-1); - return Standard_True; - } else if ( Graphic2d_Primitive::IsOn( SRX, SRY, myX2, myY2, aPrecision ) ) { - SetPickedIndex(-2); - return Standard_True; - } - - if ( ( myArrow == Prs2d_AS_FIRSTAR ) || ( myArrow == Prs2d_AS_BOTHAR ) ) { - for ( Standard_Integer i = 1; i < 3 ; i++) - if ( IsOn( SRX, SRY, myXVert1(i), myYVert1(i), myXVert1(i+1), myYVert1( i+1 ), aPrecision ) ) { - SetPickedIndex(1); - return Standard_True; - } - - if ( myArrType == Prs2d_TOA_CLOSED || myArrType == Prs2d_TOA_FILLED ) - if ( IsIn( SRX, SRY, myXVert1, myYVert1, aPrecision ) ) { - SetPickedIndex(1); - return Standard_True; - } - } // end if myArrow == FIRSTAR or BOTHAR - - if ( ( myArrow == Prs2d_AS_LASTAR ) || ( myArrow == Prs2d_AS_BOTHAR ) ){ - for ( Standard_Integer i = 1; i < 3 ; i++) - if ( IsOn( SRX, SRY, myXVert2(i), myYVert2(i), myXVert2(i+1), myYVert2( i+1 ), aPrecision ) ) { - SetPickedIndex(2); - return Standard_True; - } - - if ( myArrType == Prs2d_TOA_CLOSED || myArrType == Prs2d_TOA_FILLED ) - if ( IsIn( SRX, SRY, myXVert2, myYVert2, aPrecision ) ) { - SetPickedIndex(2); - return Standard_True; - } - } // end if myArrow == LASTAR or BOTHAR - - Standard_ShortReal width,height,xoffset,yoffset; - Standard_ShortReal hscale = Standard_ShortReal(myTextScale*aDrawer->Scale()), - wscale = Standard_ShortReal(myTextScale*aDrawer->Scale()); - Standard_ShortReal TX = X, TY = Y; - - aDrawer->SetTextAttrib( myColorIndex, myTextFont, 0, hscale, wscale, Standard_False ); - if ( !aDrawer->GetTextSize( myText, width, height, xoffset, yoffset ) ) { - width = height = xoffset = yoffset = 0.; - } - Standard_ShortReal d1 = aDrawer->Convert(ADDPIX); - gp_Pnt2d thePnt1(myX1,myY1+d1), thePnt2(myX2,myY2+d1); - gp_Vec2d VX( 1., 0. ), theVec(thePnt2, thePnt1); - Standard_Real theTxtAngle = VX.Angle( theVec ); - gp_Pnt2d pntText; - if ( theTxtAngle >= 0 && theTxtAngle <= M_PI/2 ) - pntText = thePnt2.Translated( (myArrowLen+d1)*theVec/(thePnt1.Distance(thePnt2)) ); - else if ( theTxtAngle > M_PI/2 && theTxtAngle <= M_PI ) { - pntText = thePnt1.Translated( (myArrowLen+d1)*theVec.Reversed()/(thePnt1.Distance(thePnt2)) ); - theTxtAngle = VX.Angle( theVec.Reversed() ); - } else if ( theTxtAngle >= -M_PI/2 && theTxtAngle < 0 ) - pntText = thePnt2.Translated( (myArrowLen+d1)*theVec/(thePnt1.Distance(thePnt2)) ); - else if ( theTxtAngle >= -M_PI && theTxtAngle < -M_PI/2 ) { - pntText = thePnt1.Translated( (myArrowLen+d1)*theVec.Reversed()/(thePnt1.Distance(thePnt2)) ); - theTxtAngle = VX.Angle( theVec.Reversed() ); - } - Standard_Real theTxtX, theTxtY; - pntText.Coord( theTxtX, theTxtY ); - - Standard_ShortReal cosa = Standard_ShortReal(Cos( -theTxtAngle )), - sina = Standard_ShortReal(Sin( -theTxtAngle )), - dx = TX-Standard_ShortReal(theTxtX), - dy = TY-Standard_ShortReal(theTxtY), - x = Standard_ShortReal(XROTATE(dx,dy)), - y = Standard_ShortReal(YROTATE(dx,dy)); - - Result = (x >= -aPrecision + xoffset) - && (x <= width + xoffset + aPrecision) - && (y >= -yoffset - aPrecision) - && (y <= height - yoffset + aPrecision); - - if ( Result ) { - SetPickedIndex(3); - return Standard_True; - } - - if ( IsOn( SRX, SRY, myX1, myY1, myX2, myY2, aPrecision ) ) { - SetPickedIndex( 4 ); - return Standard_True; - } - - }// end if IsInMinMax is true - - return Standard_False; - -} - -void Prs2d_Radius::Save(Aspect_FStream& aFStream) const -{ -} diff --git a/src/Prs2d/Prs2d_Radius.lxx b/src/Prs2d/Prs2d_Radius.lxx deleted file mode 100755 index 63ccc2e42d..0000000000 --- a/src/Prs2d/Prs2d_Radius.lxx +++ /dev/null @@ -1,19 +0,0 @@ -// Copyright (c) 1999-2012 OPEN CASCADE SAS -// -// The content of this file is subject to the Open CASCADE Technology Public -// License Version 6.5 (the "License"). You may not use the content of this file -// except in compliance with the License. Please obtain a copy of the License -// at http://www.opencascade.org and read it completely before using this file. -// -// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its -// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. -// -// The Original Code and all software distributed under the License is -// distributed on an "AS IS" basis, without warranty of any kind, and the -// Initial Developer hereby disclaims all such warranties, including without -// limitation, any warranties of merchantability, fitness for a particular -// purpose or non-infringement. Please see the License for the specific terms -// and conditions governing the rights and limitations under the License. - -inline void Prs2d_Radius::CalcTxtPos(const Standard_Boolean theFromAbs) { -} diff --git a/src/Prs2d/Prs2d_RadiusIndep.cdl b/src/Prs2d/Prs2d_RadiusIndep.cdl deleted file mode 100755 index 7e0bc740e0..0000000000 --- a/src/Prs2d/Prs2d_RadiusIndep.cdl +++ /dev/null @@ -1,170 +0,0 @@ --- Created by: Tanya COOL --- Copyright (c) 2000-2012 OPEN CASCADE SAS --- --- The content of this file is subject to the Open CASCADE Technology Public --- License Version 6.5 (the "License"). You may not use the content of this file --- except in compliance with the License. Please obtain a copy of the License --- at http://www.opencascade.org and read it completely before using this file. --- --- The Initial Developer of the Original Code is Open CASCADE S.A.S., having its --- main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. --- --- The Original Code and all software distributed under the License is --- distributed on an "AS IS" basis, without warranty of any kind, and the --- Initial Developer hereby disclaims all such warranties, including without --- limitation, any warranties of merchantability, fitness for a particular --- purpose or non-infringement. Please see the License for the specific terms --- and conditions governing the rights and limitations under the License. - - -class RadiusIndep from Prs2d inherits Line from Graphic2d - - ---Purpose: Constructs the primitive Radius - -uses - - Drawer from Graphic2d, - GraphicObject from Graphic2d, - Pnt2d from gp, - ExtendedString from TCollection, - TypeOfRadius from Prs2d, - Arrow from Prs2d, - Array1OfShortReal from TShort, - FStream from Aspect - -raises - - ConstructionError from Standard - -is - Create( aGO : GraphicObject from Graphic2d; - anAttachPnt : Pnt2d from gp; - aCenter : Pnt2d from gp; - aRad : Real from Standard; - aText : ExtendedString from TCollection; - aLength : Real from Standard = 10.0; - aTypeRad : TypeOfRadius from Prs2d = Prs2d_TOR_STANDARD; - aTxtScale : Real from Standard = 1.0) - - returns mutable RadiusIndep from Prs2d; - - ---Purpose: Creates the radius of the circle passing through - -- the point on the circle - - ---------------------------------------------------- - -- Category: Draw and Pick - ---------------------------------------------------- - - Draw( me : mutable; aDrawer: Drawer from Graphic2d ) - is static protected; - ---Level: Internal - ---Purpose: Draws the angle . - - DrawElement( me : mutable; aDrawer: Drawer from Graphic2d; - anIndex: Integer from Standard) - is redefined protected; - ---Level: Internal - ---Purpose: Draws element of the radius . - - DrawVertex( me : mutable; aDrawer: Drawer from Graphic2d; - anIndex: Integer from Standard) - is redefined protected; - ---Level: Internal - ---Purpose: Draws vertex of the radius . - - Pick( me : mutable; X, Y: ShortReal from Standard; - aPrecision: ShortReal from Standard; - aDrawer: Drawer from Graphic2d) - returns Boolean from Standard - is static protected; - ---Level: Internal - ---Purpose: Returns Standard_True if the radius is picked, - -- Standard_False if not. - - -------------------------------------- - -- Category: Inquire methods - -------------------------------------- - - Values( me; - anAttPnt, aCenter: out Pnt2d from gp; - aRad : out Real from Standard; - aText : out ExtendedString from TCollection; - aLength : out Real from Standard; - aTypeRad : out TypeOfRadius from Prs2d; - aTxtScale : out Real from Standard ); - - ---Level: Internal - ---Purpose: allows to get the properties of the radius - - - -------------------------------------------- - -- Category: Modification of the properties - -------------------------------------------- - - SetText( me: mutable; aTxt: ExtendedString from TCollection ); - ---Level: Public - ---Purpose: Defines the text - - SetTextScale( me: mutable; aTxtScale: Real from Standard ); - ---Level: Public - ---Purpose: Defines the scale factor of text - - SetTextFont( me: mutable; aTF: Integer from Standard ); - ---Level: Public - ---Purpose: Sets the index of the font of this text to this dimension - - SetFontOfSymb( me: mutable; aFS: Integer from Standard ); - ---Level: Public - ---Purpose: Sets the index of the font of the symbol to this dimension - - DrawSymbol( me: mutable; isDraw: Boolean from Standard ); - ---Level: Public - ---Purpose: Sets the flag for drawing additional symbol - - SetSymbolCode( me: mutable; aCode: Integer from Standard ); - ---Level: Public - ---Purpose: Sets the ASCII code of the symbol - - TextFont( me ) returns Integer from Standard; - ---Level: Public - ---Purpose: Returns the index of the font of this text of this dimension - - FontOfSymb( me ) returns Integer from Standard; - ---Level: Public - ---Purpose: Returns the index of the font of the symbol of this dimension - - IsDrawSymbol( me ) returns Boolean from Standard; - ---Level: Public - ---Purpose: Return true if symbol is drawn, false - in otherwise - - SymbolCode( me ) returns Integer from Standard; - ---Level: Public - ---Purpose: Return ASCII code of the symbol - - Save( me; aFStream: in out FStream from Aspect ) is virtual; - -fields - - myX1 : ShortReal from Standard; - myY1 : ShortReal from Standard; - myX2 : ShortReal from Standard; - myY2 : ShortReal from Standard; - myTextScale : ShortReal from Standard; - myText : ExtendedString from TCollection; - myTextX : ShortReal from Standard; - myTextY : ShortReal from Standard; - myTextAng : ShortReal from Standard; - myInside : Boolean from Standard; - myXVert : Array1OfShortReal from TShort; - myYVert : Array1OfShortReal from TShort; - myIsSymbol : Boolean from Standard; - mySymbCode : Integer from Standard; - myTextFont : Integer from Standard; - mySymbFont : Integer from Standard; - myAttPnt : Pnt2d from gp; - myCenter : Pnt2d from gp; - myRadius : Real from Standard; - myLength : Real from Standard; - myRadType : TypeOfRadius from Prs2d; - -end RadiusIndep from Prs2d; diff --git a/src/Prs2d/Prs2d_RadiusIndep.cxx b/src/Prs2d/Prs2d_RadiusIndep.cxx deleted file mode 100755 index 68be8814d6..0000000000 --- a/src/Prs2d/Prs2d_RadiusIndep.cxx +++ /dev/null @@ -1,369 +0,0 @@ -// Copyright (c) 1999-2012 OPEN CASCADE SAS -// -// The content of this file is subject to the Open CASCADE Technology Public -// License Version 6.5 (the "License"). You may not use the content of this file -// except in compliance with the License. Please obtain a copy of the License -// at http://www.opencascade.org and read it completely before using this file. -// -// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its -// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. -// -// The Original Code and all software distributed under the License is -// distributed on an "AS IS" basis, without warranty of any kind, and the -// Initial Developer hereby disclaims all such warranties, including without -// limitation, any warranties of merchantability, fitness for a particular -// purpose or non-infringement. Please see the License for the specific terms -// and conditions governing the rights and limitations under the License. - -#include - -#define VERTEXMARKER 2 -#define DEFAULTMARKERSIZE 3.0 - -Prs2d_RadiusIndep::Prs2d_RadiusIndep( const Handle(Graphic2d_GraphicObject) & aGO, - const gp_Pnt2d & anAttachPnt, - const gp_Pnt2d & aCenter, - const Standard_Real aRad, - const TCollection_ExtendedString & aText, - const Standard_Real aLength, - const Prs2d_TypeOfRadius aTypeRad, - const Standard_Real aTxtScale ) - - : Graphic2d_Line( aGO ), - - myX1( Standard_ShortReal( anAttachPnt.X() ) ), - myY1( Standard_ShortReal( anAttachPnt.Y() ) ), - myX2( Standard_ShortReal( aCenter.X() ) ), - myY2( Standard_ShortReal( aCenter.Y() ) ), - myTextScale( Standard_ShortReal( aTxtScale ) ), - myText( aText ), - myXVert( 1, 3 ), - myYVert( 1, 3 ), - myIsSymbol( Standard_False ), - mySymbCode( 198 ), - myTextFont( 0 ), - mySymbFont( 0 ), - myAttPnt( anAttachPnt ), - myCenter( aCenter ), - myRadius( aRad ), - myLength( aLength ), - myRadType( aTypeRad ) - -{ - gp_Vec2d theVec1( gp_Pnt2d( myX2, myY2 ), gp_Pnt2d( myX1, myY1 ) ); - gp_Vec2d theUnVec( 1., 0. ); - myTextAng = Standard_ShortReal( theUnVec.Angle( theVec1 ) ); - Standard_Real theLen = sqrt( (myX2-myX1)*(myX2-myX1) + (myY2-myY1)*(myY2-myY1) ); - gp_Vec2d VecAdd = theVec1.Normalized(); - theVec1.Normalize(); - theVec1 *= ( theLen + aLength ); - gp_Pnt2d P1 = aCenter.Translated( theVec1 ); - myTextX = Standard_ShortReal( P1.X() ); - myTextY = Standard_ShortReal( P1.Y() ); - gp_Pnt2d PArr( myX1, myY1 ); - - if ( ( theLen + aLength ) > theLen ) - myInside = Standard_False; - else - myInside = Standard_True; - - switch( aTypeRad ) { - default: - case Prs2d_TOR_STANDARD : { - - myX2 = Standard_ShortReal( P1.X() ); - myY2 = Standard_ShortReal( P1.Y() ); - if ( ( theLen + aLength ) > theLen ) { - theVec1.Reverse(); - } - } - break; - case Prs2d_TOR_CENTER : { - - if ( aLength > 0.0 ) { - myX1 = Standard_ShortReal( P1.X() ); - myY1 = Standard_ShortReal( P1.Y() ); - theVec1.Reverse(); - } - } - break; - case Prs2d_TOR_REVARROW : { - - myX2 = Standard_ShortReal( P1.X() ); - myY2 = Standard_ShortReal( P1.Y() ); - if ( ( theLen + aLength ) <= theLen ) - theVec1.Reverse(); - else - VecAdd.Reverse(); - Standard_Real Dt = sqrt( ( myX2 - myX1 )*( myX2 - myX1 ) + ( myY2 - myY1 )*( myY2 - myY1 ) ); - VecAdd *= Dt/2; - gp_Pnt2d PTmpn = PArr.Translated( VecAdd ); - myX1 = Standard_ShortReal( PTmpn.X() ); - myY1 = Standard_ShortReal( PTmpn.Y() ); - } - - break; - case Prs2d_TOR_CENTREV : { - - if ( aLength > 0.0 ) { - myX1 = Standard_ShortReal( P1.X() ); - myY1 = Standard_ShortReal( P1.Y() ); - } else { - theVec1.Reverse(); - Standard_Real Dt = sqrt( ( myX2 - myX1 )*( myX2 - myX1 ) + ( myY2 - myY1 )*( myY2 - myY1 ) ); - VecAdd *= Dt/2; - gp_Pnt2d PTmpn = PArr.Translated( VecAdd ); - myX1 = Standard_ShortReal( PTmpn.X() ); - myY1 = Standard_ShortReal( PTmpn.Y() ); - } - } - break; - } // end switch - - myMinX = myX1; - myMinY = myY1; - myMaxX = myX1; - myMaxY = myY1; - - if ( myX2 < myMinX ) myMinX = myX2; - if ( myY2 < myMinY ) myMinY = myY2; - if ( myX2 > myMaxX ) myMaxX = myX2; - if ( myY2 > myMaxY ) myMaxY = myY2; - - Standard_Real ArrANG = M_PI / 6., theArrLN = aRad/5., theANG; - gp_Pnt2d theOrig( 0., 0. ), P2, P3; - gp_Vec2d VX( 1., 0. ); - - P2 = gp_Pnt2d( theArrLN, theArrLN*Tan( ArrANG/2. ) ); - P3 = gp_Pnt2d( theArrLN, -theArrLN*Tan( ArrANG/2. ) ); - theVec1.Reverse(); - theANG = VX.Angle( theVec1 ); - P2.Rotate( theOrig, theANG ); - P3.Rotate( theOrig, theANG ); - - P2.Translate( gp_Vec2d( theOrig, PArr ) ); - P3.Translate( gp_Vec2d( theOrig, PArr ) ); - - myXVert(1) = Standard_ShortReal( P2.X() ); - myYVert(1) = Standard_ShortReal( P2.Y() ); - myXVert(2) = Standard_ShortReal( PArr.X() ); - myYVert(2) = Standard_ShortReal( PArr.Y() ); - myXVert(3) = Standard_ShortReal( P3.X() ); - myYVert(3) = Standard_ShortReal( P3.Y() ); - - for ( Standard_Integer i = 1; i <= 3; i++ ) { - - if ( myXVert(i) < myMinX ) myMinX = myXVert(i); - if ( myYVert(i) < myMinY ) myMinY = myYVert(i); - if ( myXVert(i) > myMaxX ) myMaxX = myXVert(i); - if ( myYVert(i) > myMaxY ) myMaxY = myYVert(i); - - } -} - -void Prs2d_RadiusIndep::Values(gp_Pnt2d& anAttPnt, - gp_Pnt2d& aCenter, - Standard_Real& aRad, - TCollection_ExtendedString& aText, - Standard_Real& aLength, - Prs2d_TypeOfRadius& aTypeRad, - Standard_Real& aTxtScale) const { - - anAttPnt = myAttPnt; - aCenter = myCenter; - aRad = myRadius; - aText = myText; - aLength = myLength; - aTypeRad = myRadType; - aTxtScale = myTextScale; -} - -void Prs2d_RadiusIndep::Draw( const Handle(Graphic2d_Drawer)& aDrawer ) { - - Standard_Boolean IsIn = Standard_False; - - if ( ! myGOPtr->IsTransformed() ) - IsIn = aDrawer->IsIn (myMinX,myMaxX,myMinY,myMaxY); - else { - Standard_ShortReal minx, miny, maxx, maxy; - MinMax(minx,maxx,miny,maxy); - IsIn = aDrawer->IsIn (minx,maxx,miny,maxy); - } - - if ( IsIn ) { - - DrawLineAttrib(aDrawer); - aDrawer->SetTextAttrib( myColorIndex, myTextFont, 0, Standard_ShortReal( myTextScale*aDrawer->Scale() ), - Standard_ShortReal( myTextScale*aDrawer->Scale()), Standard_False ); - - Standard_ShortReal aWidth, aHeight; - aDrawer->GetTextSize( myText, aWidth, aHeight ); - Standard_ShortReal Xt = myTextX, Yt = myTextY; - if ( !myInside ) { - gp_Pnt2d P1( myX1, myY1 ), P2( myX2, myY2 ), - PT( myTextX, myTextY ), PTMP; - ( PT.IsEqual( P1, 0. ) ) - ? PTMP.SetCoord( P2.X(), P2.Y() ) - : PTMP.SetCoord( P1.X(), P1.Y() ); - gp_Vec2d theVec1( PT, PTMP ); - theVec1.Normalize(); - theVec1 *= aWidth; - gp_Pnt2d PTT = PT.Translated( theVec1 ); - Xt = Standard_ShortReal( PTT.X() ); - Yt = Standard_ShortReal( PTT.Y() ); - } - - Standard_Real theSmbX = 0., theSmbY = 0.; - - if ( myIsSymbol ) { - aDrawer->SetTextAttrib( myColorIndex, mySymbFont, 0, Standard_ShortReal(myTextScale*aDrawer->Scale()), - Standard_ShortReal(myTextScale*aDrawer->Scale()), Standard_False ); - TCollection_ExtendedString txtSymb = TCollection_ExtendedString( char( mySymbCode ) ); - theSmbX = Xt; theSmbY = Yt; - gp_Pnt2d pntText( Xt, Yt ); - Standard_ShortReal ws, hs; - aDrawer->GetTextSize( txtSymb, ws, hs ); - Standard_ShortReal ddd = aDrawer->Convert(2); - gp_Vec2d VX( 1., 0. ), theVec; - theVec = VX.Rotated( myTextAng ); - theVec *= ( ws + ddd ); - gp_Pnt2d pntSymb = pntText.Translated( theVec ); - Standard_Real txtX, txtY; - pntSymb.Coord( txtX, txtY ); - Xt = Standard_ShortReal( txtX ); - Yt = Standard_ShortReal( txtY ); - } - - Standard_ShortReal a = myX1, b = myY1, - c = myX2, d = myY2, - e = Xt, f = Yt, - w = 0., h = Standard_ShortReal( aHeight/5 ), - ts1 = Standard_ShortReal( theSmbX ), - ts2 = Standard_ShortReal( theSmbY ); - - TShort_Array1OfShortReal Xpoint( 1, 3 ), Ypoint( 1, 3 ); - Xpoint.Assign( myXVert ); - Ypoint.Assign( myYVert ); - - if ( myGOPtr->IsTransformed() ) { - - gp_GTrsf2d aTrsf = myGOPtr->Transform(); - Standard_Real A1, B1; - A1 = Standard_Real( a ); B1 = Standard_Real( b ); - aTrsf.Transforms( A1, B1 ); - a = Standard_ShortReal( A1 ); b = Standard_ShortReal( B1 ); - A1 = Standard_Real( c ); B1 = Standard_Real( d ); - aTrsf.Transforms( A1, B1 ); - c = Standard_ShortReal( A1 ); d = Standard_ShortReal( B1 ); - A1 = Standard_Real( e ); B1 = Standard_Real( f ); - aTrsf.Transforms( A1, B1 ); - e = Standard_ShortReal( A1 ); f = Standard_ShortReal( B1 ); - A1 = Standard_Real( w ); B1 = Standard_Real( h ); - aTrsf.Transforms( A1, B1 ); - w = Standard_ShortReal( A1 ); h = Standard_ShortReal( B1 ); - A1 = Standard_Real( ts1 ); B1 = Standard_Real( ts2 ); - aTrsf.Transforms( A1, B1 ); - ts1 = Standard_ShortReal( A1 ); ts2 = Standard_ShortReal( B1 ); - - for ( int j = 1; j <= 3; j++ ) { - A1 = Standard_Real( myXVert(j) ); - B1 = Standard_Real( myYVert(j) ); - aTrsf.Transforms( A1, B1 ); - Xpoint(j) = Standard_ShortReal(A1); - Ypoint(j) = Standard_ShortReal(B1); - } - - } - - DrawLineAttrib( aDrawer ); - aDrawer->MapSegmentFromTo( a, b, c, d ); - aDrawer->MapPolygonFromTo( Xpoint, Ypoint); - if ( myIsSymbol ) { - aDrawer->SetTextAttrib( myColorIndex, mySymbFont, 0, Standard_ShortReal(myTextScale*aDrawer->Scale()), - Standard_ShortReal(myTextScale*aDrawer->Scale()), Standard_False ); - TCollection_ExtendedString txtSymb = TCollection_ExtendedString( char( mySymbCode ) ); - aDrawer->MapTextFromTo( txtSymb, ts1, ts2, myTextAng, 0., 0., Aspect_TOT_SOLID ); - } - - aDrawer->SetTextAttrib( myColorIndex, myTextFont, 0, Standard_ShortReal( myTextScale*aDrawer->Scale() ), - Standard_ShortReal( myTextScale*aDrawer->Scale()), Standard_False ); - - aDrawer->MapTextFromTo( myText, e, f, myTextAng, 0., 0., Aspect_TOT_SOLID ); - - } -} - -void Prs2d_RadiusIndep::DrawElement( const Handle(Graphic2d_Drawer)& /*aDrawer*/, - const Standard_Integer /*anIndex*/ ) { - -} - -void Prs2d_RadiusIndep::DrawVertex( const Handle(Graphic2d_Drawer)& /*aDrawer*/, - const Standard_Integer /*anIndex*/ ) { -} - -Standard_Boolean Prs2d_RadiusIndep::Pick( const Standard_ShortReal X, - const Standard_ShortReal Y, - const Standard_ShortReal aPrecision, - const Handle(Graphic2d_Drawer)& /*aDrawer*/) { - Standard_ShortReal SRX = X, SRY = Y; - Standard_Boolean Result = Standard_False; - - if ( IsInMinMax( X, Y, aPrecision ) ) { - if ( myGOPtr->IsTransformed () ) { - gp_GTrsf2d aTrsf = ( myGOPtr->Transform() ).Inverted(); - Standard_Real RX = Standard_Real(SRX), RY = Standard_Real(SRY); - aTrsf.Transforms(RX, RY); - SRX = Standard_ShortReal(RX); - SRY = Standard_ShortReal(RY); - } - Result = IsOn( SRX, SRY, myX1, myY1, myX2, myY2, aPrecision ); - } - return Result; - -} - -void Prs2d_RadiusIndep::SetTextScale( const Standard_Real aTxtScale ) { - myTextScale = Standard_ShortReal( aTxtScale ); -} - -void Prs2d_RadiusIndep::SetText( const TCollection_ExtendedString & aText ) { - myText = aText; -} - -void Prs2d_RadiusIndep::DrawSymbol(const Standard_Boolean isDraw ) { - myIsSymbol = isDraw; -} - -void Prs2d_RadiusIndep::SetSymbolCode( const Standard_Integer aCode ) { - mySymbCode = aCode; -} - -void Prs2d_RadiusIndep::SetTextFont(const Standard_Integer aTF) { - myTextFont = aTF; -} - -void Prs2d_RadiusIndep::SetFontOfSymb(const Standard_Integer aFS) { - mySymbFont = aFS; -} - -Standard_Boolean Prs2d_RadiusIndep::IsDrawSymbol() const { - return myIsSymbol; -} - -Standard_Integer Prs2d_RadiusIndep::SymbolCode() const { - return mySymbCode; - -} - -Standard_Integer Prs2d_RadiusIndep::TextFont() const { - return myTextFont; -} - -Standard_Integer Prs2d_RadiusIndep::FontOfSymb() const { - return mySymbFont; -} - -void Prs2d_RadiusIndep::Save(Aspect_FStream& aFStream) const -{ -} diff --git a/src/Prs2d/Prs2d_Repere.cdl b/src/Prs2d/Prs2d_Repere.cdl deleted file mode 100755 index ca2306b1ad..0000000000 --- a/src/Prs2d/Prs2d_Repere.cdl +++ /dev/null @@ -1,95 +0,0 @@ --- Created by: Tanya COOL --- Copyright (c) 2000-2012 OPEN CASCADE SAS --- --- The content of this file is subject to the Open CASCADE Technology Public --- License Version 6.5 (the "License"). You may not use the content of this file --- except in compliance with the License. Please obtain a copy of the License --- at http://www.opencascade.org and read it completely before using this file. --- --- The Initial Developer of the Original Code is Open CASCADE S.A.S., having its --- main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. --- --- The Original Code and all software distributed under the License is --- distributed on an "AS IS" basis, without warranty of any kind, and the --- Initial Developer hereby disclaims all such warranties, including without --- limitation, any warranties of merchantability, fitness for a particular --- purpose or non-infringement. Please see the License for the specific terms --- and conditions governing the rights and limitations under the License. - - -class Repere from Prs2d inherits Dimension from Prs2d - - ---Purpose: Constructs the repere - -uses - - Drawer from Graphic2d, - GraphicObject from Graphic2d, - Pnt2d from gp, - ExtendedString from TCollection, - Array1OfShortReal from TShort, - ArrowSide from Prs2d, - TypeOfArrow from Prs2d, - FStream from Aspect - -is - Create( aGO : GraphicObject from Graphic2d; - aPnt1 : Pnt2d from gp; - aPnt2 : Pnt2d from gp; - aLenBase : Real from Standard; - aText : ExtendedString from TCollection; - aTxtScale : Real from Standard = 1.0; - aDrawArrow : Boolean from Standard = Standard_False; - anArrAngle : Real from Standard = 10.0; - anArrLength : Real from Standard = 10.0; - anArrType : TypeOfArrow from Prs2d = Prs2d_TOA_OPENED; - anArrow : ArrowSide from Prs2d = Prs2d_AS_BOTHAR; - IsRevArrow : Boolean from Standard = Standard_False ) - - returns mutable Repere from Prs2d; - ---Level: Public - ---Purpose: Creates repere - - ------------------------------------------------- - -- Category: Draw and Pick - ------------------------------------------------- - - Draw( me : mutable; aDrawer: Drawer from Graphic2d ) is static protected; - ---Level: Internal - ---Purpose: Draws the repere . - - DrawElement( me : mutable; aDrawer: Drawer from Graphic2d; - anIndex: Integer from Standard) - is redefined protected; - ---Level: Internal - ---Purpose: - - DrawVertex( me : mutable; aDrawer: Drawer from Graphic2d; - anIndex: Integer from Standard) - is redefined protected; - ---Level: Internal - ---Purpose: - - Pick( me : mutable; X, Y: ShortReal from Standard; - aPrecision: ShortReal from Standard; - aDrawer: Drawer from Graphic2d ) - returns Boolean from Standard is static protected; - ---Level: Internal - ---Purpose: Returns Standard_True if the repere is picked, - -- Standard_False if not. - - Save( me; aFStream: in out FStream from Aspect ) is virtual; - - CalcTxtPos(me:mutable; theFromAbs: - Boolean from Standard) - ---C++: inline - is redefined protected; - -fields - - myXVert : Array1OfShortReal from TShort; - myYVert : Array1OfShortReal from TShort; - myObtuse : Boolean from Standard; - myDrawArrow : Boolean from Standard; - -end Repere from Prs2d; diff --git a/src/Prs2d/Prs2d_Repere.cxx b/src/Prs2d/Prs2d_Repere.cxx deleted file mode 100755 index 64a28305c4..0000000000 --- a/src/Prs2d/Prs2d_Repere.cxx +++ /dev/null @@ -1,257 +0,0 @@ -// Copyright (c) 1999-2012 OPEN CASCADE SAS -// -// The content of this file is subject to the Open CASCADE Technology Public -// License Version 6.5 (the "License"). You may not use the content of this file -// except in compliance with the License. Please obtain a copy of the License -// at http://www.opencascade.org and read it completely before using this file. -// -// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its -// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. -// -// The Original Code and all software distributed under the License is -// distributed on an "AS IS" basis, without warranty of any kind, and the -// Initial Developer hereby disclaims all such warranties, including without -// limitation, any warranties of merchantability, fitness for a particular -// purpose or non-infringement. Please see the License for the specific terms -// and conditions governing the rights and limitations under the License. - -#include -#define ADDPIX 7 - -Prs2d_Repere::Prs2d_Repere( const Handle(Graphic2d_GraphicObject)& aGO, - const gp_Pnt2d& aPnt1, - const gp_Pnt2d& aPnt2, - const Standard_Real aLenBase, - const TCollection_ExtendedString& aText, - const Standard_Real aTxtScale, - const Standard_Boolean aDrawArrow, - const Standard_Real anArrAngle, - const Standard_Real anArrLength, - const Prs2d_TypeOfArrow anArrType, - const Prs2d_ArrowSide anArrow, - const Standard_Boolean IsRevArrow ) - - : Prs2d_Dimension( aGO, aText, aTxtScale, anArrAngle, - anArrLength, anArrType, anArrow, IsRevArrow ), - myXVert( 1, 3 ), - myYVert( 1, 3 ), - myObtuse( Standard_False ), - myDrawArrow( aDrawArrow ) -{ - - SetSymbolCode( 198 ); - myXVert(1) = Standard_ShortReal( aPnt1.X() ); - myXVert(2) = Standard_ShortReal( aPnt2.X() ); - myYVert(1) = Standard_ShortReal( aPnt1.Y() ); - myYVert(2) = Standard_ShortReal( aPnt2.Y() ); - - gp_Vec2d theVec( aPnt2, aPnt1 ); - gp_Vec2d theVecX( 1., 0. ); - Standard_Real theAng = theVecX.Angle(theVec); - Standard_Real nX = aPnt2.X(); -// Standard_Boolean isObtuse = Standard_False; - Standard_Integer i; - - if ( myDrawArrow ) { - - gp_Pnt2d theOrig( 0., 0. ), P1, P2, P3; - gp_Vec2d VX( 1., 0. ), VDir( aPnt1, aPnt2 ); - Standard_Real alpha = M_PI - anArrAngle; - P1 = aPnt1; - P2 = gp_Pnt2d( anArrLength, anArrLength*Tan( alpha/2. ) ); - P3 = gp_Pnt2d( anArrLength, -anArrLength*Tan( alpha/2. ) ); - if ( IsRevArrow ) VDir.Reverse(); - - Standard_Real theAngle = VX.Angle( VDir ); - - P2.Rotate( theOrig, theAngle ); - P3.Rotate( theOrig, theAngle ); - - P2.Translate( gp_Vec2d( theOrig, P1 ) ); - P3.Translate( gp_Vec2d( theOrig, P1 ) ); - - myXVert1(1) = Standard_ShortReal( P2.X() ); - myYVert1(1) = Standard_ShortReal( P2.Y() ); - myXVert1(2) = Standard_ShortReal( P1.X() ); - myYVert1(2) = Standard_ShortReal( P1.Y() ); - myXVert1(3) = Standard_ShortReal( P3.X() ); - myYVert1(3) = Standard_ShortReal( P3.Y() ); - - for ( i = 1; i <= 3; i++ ) { - - if ( myXVert1(i) < myMinX ) myMinX = myXVert1(i); - if ( myYVert1(i) < myMinY ) myMinY = myYVert1(i); - if ( myXVert1(i) > myMaxX ) myMaxX = myXVert1(i); - if ( myYVert1(i) > myMaxY ) myMaxY = myYVert1(i); - - } - - } - - if ( theAng >= 0. && theAng < M_PI/2) { - nX -= aLenBase; - } else if ( theAng >= M_PI/2 && theAng <= M_PI ) { - nX += aLenBase; - myObtuse = Standard_True; - } else if ( theAng >= -M_PI && theAng < -M_PI/2) { - nX += aLenBase; - myObtuse = Standard_True; - } else if ( theAng >= -M_PI/2 && theAng < 0. ) - nX -= aLenBase; - - myXVert(3) = Standard_ShortReal( nX ); - myYVert(3) = Standard_ShortReal( aPnt2.Y() ); - - for ( i = 1; i <= 3; i++ ) { - if ( myXVert(i) < myMinX ) myMinX = myXVert(i); - if ( myYVert(i) < myMinY ) myMinY = myYVert(i); - if ( myXVert(i) > myMaxX ) myMaxX = myXVert(i); - if ( myYVert(i) > myMaxY ) myMaxY = myYVert(i); - } - -} - -void Prs2d_Repere::Draw(const Handle(Graphic2d_Drawer)& aDrawer) { - - Standard_Boolean IsIn = Standard_False; - - if ( ! myGOPtr->IsTransformed() ) - IsIn = aDrawer->IsIn (myMinX,myMaxX,myMinY,myMaxY); - else { - Standard_ShortReal minx, miny, maxx, maxy; - MinMax(minx,maxx,miny,maxy); - IsIn = aDrawer->IsIn (minx,maxx,miny,maxy); - } - - if ( IsIn ) { - - DrawLineAttrib(aDrawer); - - Standard_ShortReal dxx = aDrawer->Convert(ADDPIX); - Standard_ShortReal t1 = Standard_ShortReal( myXVert(3) + dxx ), - t2 = Standard_ShortReal( myYVert(3) + dxx ); - if ( myObtuse ) { - t1 = Standard_ShortReal( myXVert(2) + dxx ); - t2 = Standard_ShortReal( myYVert(2) + dxx ); - } - Standard_Real theSmbX = t1, theSmbY = t2; - - if ( myIsSymbol ) { - aDrawer->SetTextAttrib( myColorIndex, mySymbFont, 0, Standard_ShortReal(myTextScale*aDrawer->Scale()), - Standard_ShortReal(myTextScale*aDrawer->Scale()), Standard_False ); -// TCollection_ExtendedString txtSymb( char( SymbolCode() ) ); - Standard_Character code = SymbolCode(); - TCollection_ExtendedString txtSymb( code ); - Standard_ShortReal ws=0., hs=0.; - aDrawer->GetTextSize( txtSymb, ws, hs ); - Standard_ShortReal ddd = aDrawer->Convert( 2 ); - t1 += ( ws + ddd ); - } - Standard_ShortReal ts1 = Standard_ShortReal( theSmbX ), - ts2 = Standard_ShortReal( theSmbY ); - - TShort_Array1OfShortReal Xpoint( 1, 3 ), Ypoint( 1, 3 ), - Xpoint1( 1, 3 ), Ypoint1( 1, 3 ); - - if ( myGOPtr->IsTransformed() ) { - - gp_GTrsf2d aTrsf = myGOPtr->Transform (); - Standard_Real a, b; - for ( Standard_Integer j = 1; j <= 3; j++ ) { - a = Standard_Real( myXVert(j) ); - b = Standard_Real( myYVert(j) ); - aTrsf.Transforms( a, b ); - Xpoint(j) = Standard_ShortReal( a ); - Ypoint(j) = Standard_ShortReal( b ); - } - a = Standard_Real( t1 ); - b = Standard_Real( t2 ); - aTrsf.Transforms( a, b ); - t1 = Standard_ShortReal( a ); - t2 = Standard_ShortReal( b ); - a = Standard_Real( ts1 ); - b = Standard_Real( ts2 ); - aTrsf.Transforms( a, b ); - ts1 = Standard_ShortReal( a ); - ts2 = Standard_ShortReal( b ); - if ( myDrawArrow ) { - for ( Standard_Integer i = 1; i <= 3; i++ ) { - a = Standard_Real( myXVert1(i) ); - b = Standard_Real( myYVert1(i) ); - aTrsf.Transforms(a, b); - Xpoint1(i) = Standard_ShortReal(a); - Ypoint1(i) = Standard_ShortReal(b); - } - } - } else { - Xpoint.Assign( myXVert ); - Ypoint.Assign( myYVert ); - if ( myDrawArrow ) { - Xpoint1.Assign( myXVert1 ); - Ypoint1.Assign( myYVert1 ); - } - } - - aDrawer->MapPolylineFromTo( Xpoint, Ypoint ); - - if ( myIsSymbol ) { -// TCollection_ExtendedString txtSymb( char( SymbolCode() ) ); - Standard_Character code = SymbolCode(); - TCollection_ExtendedString txtSymb( code ); - Standard_ShortReal angle=0.,dx=0.,dy=0.; - aDrawer->MapTextFromTo( txtSymb, ts1, ts2, angle, dx, dy, Aspect_TOT_SOLID); - } - aDrawer->SetTextAttrib( myColorIndex, myTextFont, 0, Standard_ShortReal(myTextScale*aDrawer->Scale()), - Standard_ShortReal(myTextScale*aDrawer->Scale()), Standard_False ); - - aDrawer->MapTextFromTo( myText, t1, t2, 0., 0., 0., Aspect_TOT_SOLID ); - - if ( myDrawArrow ) { - if ( myArrType == Prs2d_TOA_CLOSED || myArrType == Prs2d_TOA_FILLED ) { - aDrawer->MapPolygonFromTo( Xpoint1, Ypoint1 ); - } else { - aDrawer->MapPolylineFromTo( Xpoint1, Ypoint1 ); - } - } - } -} - -void Prs2d_Repere::DrawElement( const Handle(Graphic2d_Drawer)& /*aDrawer*/, - const Standard_Integer /*anIndex*/ ) { -} - -void Prs2d_Repere::DrawVertex( const Handle(Graphic2d_Drawer)& /*aDrawer*/, - const Standard_Integer /*anIndex*/ ) { -} - -Standard_Boolean Prs2d_Repere::Pick( const Standard_ShortReal X, - const Standard_ShortReal Y, - const Standard_ShortReal aPrecision, - const Handle(Graphic2d_Drawer)& /*aDrawer*/ ) { - - Standard_ShortReal SRX = X, SRY = Y; - - Standard_Integer Lower = myXVert.Lower(), Upper = myXVert.Upper(); - - if ( IsInMinMax( X, Y, aPrecision ) ) { - - if ( myGOPtr->IsTransformed() ) { - gp_GTrsf2d aTrsf = (myGOPtr->Transform ()).Inverted (); - Standard_Real RX = Standard_Real (SRX), RY = Standard_Real (SRY); - aTrsf.Transforms (RX, RY); - SRX = Standard_ShortReal (RX); SRY = Standard_ShortReal (RY); - } - for ( int i = Lower; i < Upper; i++ ) - if ( IsOn( SRX, SRY, myXVert (i), myYVert(i), - myXVert( i + 1 ), myYVert( i + 1 ), aPrecision ) ) - return Standard_True; - - - } - - return Standard_False; -} - -void Prs2d_Repere::Save(Aspect_FStream& aFStream) const -{ -} diff --git a/src/Prs2d/Prs2d_Repere.lxx b/src/Prs2d/Prs2d_Repere.lxx deleted file mode 100755 index cb2173cf52..0000000000 --- a/src/Prs2d/Prs2d_Repere.lxx +++ /dev/null @@ -1,20 +0,0 @@ -// Copyright (c) 1999-2012 OPEN CASCADE SAS -// -// The content of this file is subject to the Open CASCADE Technology Public -// License Version 6.5 (the "License"). You may not use the content of this file -// except in compliance with the License. Please obtain a copy of the License -// at http://www.opencascade.org and read it completely before using this file. -// -// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its -// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. -// -// The Original Code and all software distributed under the License is -// distributed on an "AS IS" basis, without warranty of any kind, and the -// Initial Developer hereby disclaims all such warranties, including without -// limitation, any warranties of merchantability, fitness for a particular -// purpose or non-infringement. Please see the License for the specific terms -// and conditions governing the rights and limitations under the License. - -inline void Prs2d_Repere::CalcTxtPos(const Standard_Boolean theFromAbs) { - -} diff --git a/src/Prs2d/Prs2d_Straightness.cdl b/src/Prs2d/Prs2d_Straightness.cdl deleted file mode 100755 index ebf458b511..0000000000 --- a/src/Prs2d/Prs2d_Straightness.cdl +++ /dev/null @@ -1,54 +0,0 @@ --- Created by: TCL --- Copyright (c) 2000-2012 OPEN CASCADE SAS --- --- The content of this file is subject to the Open CASCADE Technology Public --- License Version 6.5 (the "License"). You may not use the content of this file --- except in compliance with the License. Please obtain a copy of the License --- at http://www.opencascade.org and read it completely before using this file. --- --- The Initial Developer of the Original Code is Open CASCADE S.A.S., having its --- main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. --- --- The Original Code and all software distributed under the License is --- distributed on an "AS IS" basis, without warranty of any kind, and the --- Initial Developer hereby disclaims all such warranties, including without --- limitation, any warranties of merchantability, fitness for a particular --- purpose or non-infringement. Please see the License for the specific terms --- and conditions governing the rights and limitations under the License. - - -class Straightness from Prs2d inherits Tolerance from Prs2d - -uses - - GraphicObject from Graphic2d, - Drawer from Graphic2d, - Length from Quantity, - FStream from Aspect - -is - ------------------------- - -- Category: Constructors - ------------------------- - - Create( aGO : GraphicObject from Graphic2d; - aX, aY : Real from Standard; - aLength : Real from Standard = 3.0; - anAngle : Real from Standard = 0.0 ); - ---Level: Public - ---Purpose: Creates a tolerance straightness with the center at , ; - -- length of this is ; - -- reference point is , - ---Category: Constructor - - -------------------------- - -- Category: Draw and Pick - -------------------------- - - Draw( me : mutable; aDrawer: Drawer from Graphic2d ) is static protected; - ---Level: Internal - ---Purpose: Draws the straightness . - - Save( me; aFStream: in out FStream from Aspect ) is virtual; - -end Straightness from Prs2d; diff --git a/src/Prs2d/Prs2d_Straightness.cxx b/src/Prs2d/Prs2d_Straightness.cxx deleted file mode 100755 index ffe5bff0a9..0000000000 --- a/src/Prs2d/Prs2d_Straightness.cxx +++ /dev/null @@ -1,80 +0,0 @@ -// Copyright (c) 1999-2012 OPEN CASCADE SAS -// -// The content of this file is subject to the Open CASCADE Technology Public -// License Version 6.5 (the "License"). You may not use the content of this file -// except in compliance with the License. Please obtain a copy of the License -// at http://www.opencascade.org and read it completely before using this file. -// -// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its -// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. -// -// The Original Code and all software distributed under the License is -// distributed on an "AS IS" basis, without warranty of any kind, and the -// Initial Developer hereby disclaims all such warranties, including without -// limitation, any warranties of merchantability, fitness for a particular -// purpose or non-infringement. Please see the License for the specific terms -// and conditions governing the rights and limitations under the License. - -#include - -Prs2d_Straightness::Prs2d_Straightness( const Handle(Graphic2d_GraphicObject)& aGO, - const Standard_Real aX, - const Standard_Real aY, - const Standard_Real aLength, - const Standard_Real anAngle ) - - : Prs2d_Tolerance( aGO, aX, aY, aLength, anAngle ) -{ -} - -void Prs2d_Straightness::Draw( const Handle(Graphic2d_Drawer)& aDrawer ) { - - Standard_Boolean IsIn = Standard_False; - - if ( !myGOPtr->IsTransformed() ) - IsIn = aDrawer->IsIn( myMinX, myMaxX, myMinY, myMaxY ); - else { - Standard_ShortReal minx, miny, maxx, maxy; - MinMax( minx, maxx, miny, maxy ); - IsIn = aDrawer->IsIn( minx, maxx, miny, maxy ); - } - - if ( IsIn ) { - DrawLineAttrib( aDrawer ); - Standard_ShortReal X1 = Standard_ShortReal( myX - myLength/2 ), - Y1 = Standard_ShortReal( myY ), - X2 = Standard_ShortReal( myX + myLength/2 ), - Y2 = Standard_ShortReal( myY ); - - gp_Pnt2d P1( X1, Y1 ), - P2( X2, Y2 ), - PR( myX, myY ); - P1.Rotate( PR, myAngle ); - P2.Rotate( PR, myAngle ); - - X1 = Standard_ShortReal( P1.X() ); - Y1 = Standard_ShortReal( P1.Y() ); - X2 = Standard_ShortReal( P2.X() ); - Y2 = Standard_ShortReal( P2.Y() ); - - if ( myGOPtr->IsTransformed () ) { - gp_GTrsf2d aTrsf = myGOPtr->Transform (); - Standard_Real a1, b1; - a1 = X1; - b1 = Y1; - aTrsf.Transforms( a1, b1 ); - X1 = Standard_ShortReal( a1 ); - Y1 = Standard_ShortReal( b1 ); - a1 = X2; - b1 = Y2; - aTrsf.Transforms( a1, b1 ); - X2 = Standard_ShortReal( a1 ); - Y2 = Standard_ShortReal( b1 ); - } - aDrawer->MapSegmentFromTo( X1, Y1, X2, Y2 ); - } -} - -void Prs2d_Straightness::Save(Aspect_FStream& aFStream) const -{ -} diff --git a/src/Prs2d/Prs2d_SurfProfile.cdl b/src/Prs2d/Prs2d_SurfProfile.cdl deleted file mode 100755 index d00d915ced..0000000000 --- a/src/Prs2d/Prs2d_SurfProfile.cdl +++ /dev/null @@ -1,54 +0,0 @@ --- Created by: TCL --- Copyright (c) 2000-2012 OPEN CASCADE SAS --- --- The content of this file is subject to the Open CASCADE Technology Public --- License Version 6.5 (the "License"). You may not use the content of this file --- except in compliance with the License. Please obtain a copy of the License --- at http://www.opencascade.org and read it completely before using this file. --- --- The Initial Developer of the Original Code is Open CASCADE S.A.S., having its --- main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. --- --- The Original Code and all software distributed under the License is --- distributed on an "AS IS" basis, without warranty of any kind, and the --- Initial Developer hereby disclaims all such warranties, including without --- limitation, any warranties of merchantability, fitness for a particular --- purpose or non-infringement. Please see the License for the specific terms --- and conditions governing the rights and limitations under the License. - - -class SurfProfile from Prs2d inherits Tolerance from Prs2d - -uses - - GraphicObject from Graphic2d, - Drawer from Graphic2d, - Length from Quantity, - FStream from Aspect - -is - ------------------------- - -- Category: Constructors - ------------------------- - - Create( aGO : GraphicObject from Graphic2d; - aX, aY : Real from Standard; - aLength : Real from Standard = 3.0; - anAngle : Real from Standard = 0.0 ); - ---Level: Public - ---Purpose: Creates a tolerance SurfProfile with the center at , ; - -- length of this is ; - -- reference point is , - ---Category: Constructor - - -------------------------- - -- Category: Draw and Pick - -------------------------- - - Draw( me : mutable; aDrawer: Drawer from Graphic2d ) is static protected; - ---Level: Internal - ---Purpose: Draws the SurfProfile . - - Save( me; aFStream: in out FStream from Aspect ) is virtual; - -end SurfProfile from Prs2d; diff --git a/src/Prs2d/Prs2d_SurfProfile.cxx b/src/Prs2d/Prs2d_SurfProfile.cxx deleted file mode 100755 index 5ce6b91097..0000000000 --- a/src/Prs2d/Prs2d_SurfProfile.cxx +++ /dev/null @@ -1,92 +0,0 @@ -// Copyright (c) 1999-2012 OPEN CASCADE SAS -// -// The content of this file is subject to the Open CASCADE Technology Public -// License Version 6.5 (the "License"). You may not use the content of this file -// except in compliance with the License. Please obtain a copy of the License -// at http://www.opencascade.org and read it completely before using this file. -// -// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its -// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. -// -// The Original Code and all software distributed under the License is -// distributed on an "AS IS" basis, without warranty of any kind, and the -// Initial Developer hereby disclaims all such warranties, including without -// limitation, any warranties of merchantability, fitness for a particular -// purpose or non-infringement. Please see the License for the specific terms -// and conditions governing the rights and limitations under the License. - -#include - -Prs2d_SurfProfile::Prs2d_SurfProfile( const Handle(Graphic2d_GraphicObject)& aGO, - const Standard_Real aX, - const Standard_Real aY, - const Standard_Real aLength, - const Standard_Real anAngle ) - - : Prs2d_Tolerance( aGO, aX, aY, aLength, anAngle ) -{ -} - -void Prs2d_SurfProfile::Draw( const Handle(Graphic2d_Drawer)& aDrawer ) { - - Standard_Boolean IsIn = Standard_False; - - if ( !myGOPtr->IsTransformed() ) - IsIn = aDrawer->IsIn( myMinX, myMaxX, myMinY, myMaxY ); - else { - Standard_ShortReal minx, miny, maxx, maxy; - MinMax( minx, maxx, miny, maxy ); - IsIn = aDrawer->IsIn( minx, maxx, miny, maxy ); - } - - if ( IsIn ) { - - DrawLineAttrib( aDrawer ); - Standard_ShortReal X1 = Standard_ShortReal( myX - myLength/2 ), - Y1 = Standard_ShortReal( myY - myLength/4 ), - X2 = Standard_ShortReal( myX + myLength/2 ), - Y2 = Standard_ShortReal( myY - myLength/4 ), - Xc = Standard_ShortReal( myX ), - Yc = Y2; - gp_Pnt2d P1( X1, Y1 ), - P2( X2, Y2 ), - PC( Xc, Yc ), - PR( myX, myY ); - P1.Rotate( PR, myAngle ); - P2.Rotate( PR, myAngle ); - PC.Rotate( PR, myAngle ); - - X1 = Standard_ShortReal( P1.X() ); - Y1 = Standard_ShortReal( P1.Y() ); - X2 = Standard_ShortReal( P2.X() ); - Y2 = Standard_ShortReal( P2.Y() ); - Xc = Standard_ShortReal( PC.X() ); - Yc = Standard_ShortReal( PC.Y() ); - - if ( myGOPtr->IsTransformed () ) { - gp_GTrsf2d aTrsf = myGOPtr->Transform (); - Standard_Real a1, b1; - a1 = X1; - b1 = Y1; - aTrsf.Transforms( a1, b1 ); - X1 = Standard_ShortReal( a1 ); - Y1 = Standard_ShortReal( b1 ); - a1 = X2; - b1 = Y2; - aTrsf.Transforms( a1, b1 ); - X2 = Standard_ShortReal( a1 ); - Y2 = Standard_ShortReal( b1 ); - a1 = Xc; - b1 = Yc; - aTrsf.Transforms( a1, b1 ); - Xc = Standard_ShortReal( a1 ); - Yc = Standard_ShortReal( b1 ); - } - aDrawer->MapSegmentFromTo( X1, Y1, X2, Y2 ); - aDrawer->MapArcFromTo( Xc, Yc, myLength/2, myAngle, Standard_ShortReal( M_PI + myAngle ) ); - } -} - -void Prs2d_SurfProfile::Save(Aspect_FStream& aFStream) const -{ -} diff --git a/src/Prs2d/Prs2d_SymCircular.cdl b/src/Prs2d/Prs2d_SymCircular.cdl deleted file mode 100755 index bd2ce61349..0000000000 --- a/src/Prs2d/Prs2d_SymCircular.cdl +++ /dev/null @@ -1,54 +0,0 @@ --- Created by: TCL --- Copyright (c) 2000-2012 OPEN CASCADE SAS --- --- The content of this file is subject to the Open CASCADE Technology Public --- License Version 6.5 (the "License"). You may not use the content of this file --- except in compliance with the License. Please obtain a copy of the License --- at http://www.opencascade.org and read it completely before using this file. --- --- The Initial Developer of the Original Code is Open CASCADE S.A.S., having its --- main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. --- --- The Original Code and all software distributed under the License is --- distributed on an "AS IS" basis, without warranty of any kind, and the --- Initial Developer hereby disclaims all such warranties, including without --- limitation, any warranties of merchantability, fitness for a particular --- purpose or non-infringement. Please see the License for the specific terms --- and conditions governing the rights and limitations under the License. - - -class SymCircular from Prs2d inherits Tolerance from Prs2d - -uses - - GraphicObject from Graphic2d, - Drawer from Graphic2d, - Length from Quantity, - FStream from Aspect - -is - ------------------------- - -- Category: Constructors - ------------------------- - - Create( aGO : GraphicObject from Graphic2d; - aX, aY : Real from Standard; - aLength : Real from Standard = 3.0; - anAngle : Real from Standard = 0.0 ); - ---Level: Public - ---Purpose: Creates a tolerance SymCircular with the center at , ; - -- length of this is ; - -- reference point is , - ---Category: Constructor - - -------------------------- - -- Category: Draw and Pick - -------------------------- - - Draw( me : mutable; aDrawer: Drawer from Graphic2d ) is static protected; - ---Level: Internal - ---Purpose: Draws the SymCircular . - - Save( me; aFStream: in out FStream from Aspect ) is virtual; - -end SymCircular from Prs2d; diff --git a/src/Prs2d/Prs2d_SymCircular.cxx b/src/Prs2d/Prs2d_SymCircular.cxx deleted file mode 100755 index 423fd03bb8..0000000000 --- a/src/Prs2d/Prs2d_SymCircular.cxx +++ /dev/null @@ -1,119 +0,0 @@ -// Copyright (c) 1999-2012 OPEN CASCADE SAS -// -// The content of this file is subject to the Open CASCADE Technology Public -// License Version 6.5 (the "License"). You may not use the content of this file -// except in compliance with the License. Please obtain a copy of the License -// at http://www.opencascade.org and read it completely before using this file. -// -// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its -// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. -// -// The Original Code and all software distributed under the License is -// distributed on an "AS IS" basis, without warranty of any kind, and the -// Initial Developer hereby disclaims all such warranties, including without -// limitation, any warranties of merchantability, fitness for a particular -// purpose or non-infringement. Please see the License for the specific terms -// and conditions governing the rights and limitations under the License. - -#include - -Prs2d_SymCircular::Prs2d_SymCircular( const Handle(Graphic2d_GraphicObject)& aGO, - const Standard_Real aX, - const Standard_Real aY, - const Standard_Real aLength, - const Standard_Real anAngle ) - - : Prs2d_Tolerance( aGO, aX, aY, aLength, anAngle ) -{ -} - -void Prs2d_SymCircular::Draw( const Handle(Graphic2d_Drawer)& aDrawer ) { - - Standard_Boolean IsIn = Standard_False; - - if ( !myGOPtr->IsTransformed() ) - IsIn = aDrawer->IsIn( myMinX, myMaxX, myMinY, myMaxY ); - else { - Standard_ShortReal minx, miny, maxx, maxy; - MinMax( minx, maxx, miny, maxy ); - IsIn = aDrawer->IsIn( minx, maxx, miny, maxy ); - } - - if ( IsIn ) { - DrawLineAttrib( aDrawer ); - const Standard_Real alpha = M_PI / 12; - - Standard_ShortReal X1 = myX - myLength/2, - Y1 = myY - myLength/2, - X2 = Standard_ShortReal(X1 + myLength * Cos( M_PI / 4 ) ), - Y2 = myY + myLength/2; - - - gp_Pnt2d P1( X2, Y2 ); - gp_Vec2d V1( P1, gp_Pnt2d(X1, Y1) ); - gp_Vec2d V2 = V1.Rotated( alpha ); - gp_Vec2d V3 = V1.Rotated( -alpha ); - V2 /= 2; - V3 /= 2; - gp_Pnt2d P2 = P1.Translated( V2 ), - P3 = P1.Translated( V3 ); - - Standard_ShortReal X3 = Standard_ShortReal( P2.X() ), - Y3 = Standard_ShortReal( P2.Y() ), - X4 = Standard_ShortReal( P3.X() ), - Y4 = Standard_ShortReal( P3.Y() ); - - gp_Pnt2d PP1( X1, Y1 ), - PP2( X2, Y2 ), - PP3( X3, Y3 ), - PP4( X4, Y4 ), - PPR( myX, myY ); - PP1.Rotate( PPR, myAngle ); - PP2.Rotate( PPR, myAngle ); - PP3.Rotate( PPR, myAngle ); - PP4.Rotate( PPR, myAngle ); - - X1 = Standard_ShortReal( PP1.X() ); - Y1 = Standard_ShortReal( PP1.Y() ); - X2 = Standard_ShortReal( PP2.X() ); - Y2 = Standard_ShortReal( PP2.Y() ); - X3 = Standard_ShortReal( PP3.X() ); - Y3 = Standard_ShortReal( PP3.Y() ); - X4 = Standard_ShortReal( PP4.X() ); - Y4 = Standard_ShortReal( PP4.Y() ); - - if ( myGOPtr->IsTransformed () ) { - gp_GTrsf2d aTrsf = myGOPtr->Transform (); - Standard_Real a1, b1; - a1 = X1; - b1 = Y1; - aTrsf.Transforms( a1, b1 ); - X1 = Standard_ShortReal( a1 ); - Y1 = Standard_ShortReal( b1 ); - a1 = X2; - b1 = Y2; - aTrsf.Transforms( a1, b1 ); - X2 = Standard_ShortReal( a1 ); - Y2 = Standard_ShortReal( b1 ); - a1 = X3; - b1 = Y3; - aTrsf.Transforms( a1, b1 ); - X3 = Standard_ShortReal( a1 ); - Y3 = Standard_ShortReal( b1 ); - a1 = X4; - b1 = Y4; - aTrsf.Transforms( a1, b1 ); - X4 = Standard_ShortReal( a1 ); - Y4 = Standard_ShortReal( b1 ); - } - aDrawer->MapSegmentFromTo( X1, Y1, X2, Y2 ); - aDrawer->MapSegmentFromTo( X2, Y2, X3, Y3 ); - aDrawer->MapSegmentFromTo( X2, Y2, X4, Y4 ); - aDrawer->MapSegmentFromTo( X4, Y4, X3, Y3 ); - } - -} - -void Prs2d_SymCircular::Save(Aspect_FStream& aFStream) const -{ -} diff --git a/src/Prs2d/Prs2d_SymTotal.cdl b/src/Prs2d/Prs2d_SymTotal.cdl deleted file mode 100755 index cd1dd3bed8..0000000000 --- a/src/Prs2d/Prs2d_SymTotal.cdl +++ /dev/null @@ -1,54 +0,0 @@ --- Created by: TCL --- Copyright (c) 2000-2012 OPEN CASCADE SAS --- --- The content of this file is subject to the Open CASCADE Technology Public --- License Version 6.5 (the "License"). You may not use the content of this file --- except in compliance with the License. Please obtain a copy of the License --- at http://www.opencascade.org and read it completely before using this file. --- --- The Initial Developer of the Original Code is Open CASCADE S.A.S., having its --- main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. --- --- The Original Code and all software distributed under the License is --- distributed on an "AS IS" basis, without warranty of any kind, and the --- Initial Developer hereby disclaims all such warranties, including without --- limitation, any warranties of merchantability, fitness for a particular --- purpose or non-infringement. Please see the License for the specific terms --- and conditions governing the rights and limitations under the License. - - -class SymTotal from Prs2d inherits Tolerance from Prs2d - -uses - - GraphicObject from Graphic2d, - Drawer from Graphic2d, - Length from Quantity, - FStream from Aspect - -is - ------------------------- - -- Category: Constructors - ------------------------- - - Create( aGO : GraphicObject from Graphic2d; - aX, aY : Real from Standard; - aLength : Real from Standard = 3.0; - anAngle : Real from Standard = 0.0 ); - ---Level: Public - ---Purpose: Creates a tolerance SymTotal with the center at , ; - -- length of this is ; - -- reference point is , - ---Category: Constructor - - -------------------------- - -- Category: Draw and Pick - -------------------------- - - Draw( me : mutable; aDrawer: Drawer from Graphic2d ) is static protected; - ---Level: Internal - ---Purpose: Draws the SymTotal . - - Save( me; aFStream: in out FStream from Aspect ) is virtual; - -end SymTotal from Prs2d; diff --git a/src/Prs2d/Prs2d_SymTotal.cxx b/src/Prs2d/Prs2d_SymTotal.cxx deleted file mode 100755 index 1805349f27..0000000000 --- a/src/Prs2d/Prs2d_SymTotal.cxx +++ /dev/null @@ -1,181 +0,0 @@ -// Copyright (c) 1999-2012 OPEN CASCADE SAS -// -// The content of this file is subject to the Open CASCADE Technology Public -// License Version 6.5 (the "License"). You may not use the content of this file -// except in compliance with the License. Please obtain a copy of the License -// at http://www.opencascade.org and read it completely before using this file. -// -// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its -// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. -// -// The Original Code and all software distributed under the License is -// distributed on an "AS IS" basis, without warranty of any kind, and the -// Initial Developer hereby disclaims all such warranties, including without -// limitation, any warranties of merchantability, fitness for a particular -// purpose or non-infringement. Please see the License for the specific terms -// and conditions governing the rights and limitations under the License. - -#include - -Prs2d_SymTotal::Prs2d_SymTotal( const Handle(Graphic2d_GraphicObject)& aGO, - const Standard_Real aX, - const Standard_Real aY, - const Standard_Real aLength, - const Standard_Real anAngle ) - - : Prs2d_Tolerance( aGO, aX, aY, aLength, anAngle ) -{ -} - -void Prs2d_SymTotal::Draw( const Handle(Graphic2d_Drawer)& aDrawer ) { - - Standard_Boolean IsIn = Standard_False; - - if ( !myGOPtr->IsTransformed() ) - IsIn = aDrawer->IsIn( myMinX, myMaxX, myMinY, myMaxY ); - else { - Standard_ShortReal minx, miny, maxx, maxy; - MinMax( minx, maxx, miny, maxy ); - IsIn = aDrawer->IsIn( minx, maxx, miny, maxy ); - } - - if ( IsIn ) { - DrawLineAttrib( aDrawer ); - const Standard_Real alpha = M_PI / 12; - - Standard_ShortReal X1 = myX - myLength/2, - Y1 = myY - myLength/2, - X2 = Standard_ShortReal(X1 + myLength * Cos( M_PI / 4 ) ), - Y2 = myY + myLength/2, - - X5 = myX, - Y5 = myY - myLength/2, - X6 = Standard_ShortReal(X5 + myLength * Cos( M_PI / 4 ) ), - Y6 = myY + myLength/2; - - gp_Pnt2d P1( X2, Y2 ); - gp_Vec2d V1( P1, gp_Pnt2d(X1, Y1) ); - gp_Vec2d V2 = V1.Rotated( alpha ); - gp_Vec2d V3 = V1.Rotated( -alpha ); - V2 /= 2; - V3 /= 2; - gp_Pnt2d P2 = P1.Translated( V2 ), - P3 = P1.Translated( V3 ); - - gp_Pnt2d P4( X6, Y6 ); - gp_Vec2d V4( P4, gp_Pnt2d( X5, Y5 ) ); - gp_Vec2d V5 = V4.Rotated( alpha ); - gp_Vec2d V6 = V4.Rotated( -alpha ); - V5 /= 2; - V6 /= 2; - gp_Pnt2d P5 = P4.Translated( V5 ), - P6 = P4.Translated( V6 ); - - - Standard_ShortReal X3 = Standard_ShortReal( P2.X() ), - Y3 = Standard_ShortReal( P2.Y() ), - X4 = Standard_ShortReal( P3.X() ), - Y4 = Standard_ShortReal( P3.Y() ), - X7 = Standard_ShortReal( P5.X() ), - Y7 = Standard_ShortReal( P5.Y() ), - X8 = Standard_ShortReal( P6.X() ), - Y8 = Standard_ShortReal( P6.Y() ); - - - gp_Pnt2d PP1( X1, Y1 ), - PP2( X2, Y2 ), - PP3( X3, Y3 ), - PP4( X4, Y4 ), - PP5( X5, Y5 ), - PP6( X6, Y6 ), - PP7( X7, Y7 ), - PP8( X8, Y8 ), - PPR( myX, myY ); - PP1.Rotate( PPR, myAngle ); - PP2.Rotate( PPR, myAngle ); - PP3.Rotate( PPR, myAngle ); - PP4.Rotate( PPR, myAngle ); - PP5.Rotate( PPR, myAngle ); - PP6.Rotate( PPR, myAngle ); - PP7.Rotate( PPR, myAngle ); - PP8.Rotate( PPR, myAngle ); - - X1 = Standard_ShortReal( PP1.X() ); - Y1 = Standard_ShortReal( PP1.Y() ); - X2 = Standard_ShortReal( PP2.X() ); - Y2 = Standard_ShortReal( PP2.Y() ); - X3 = Standard_ShortReal( PP3.X() ); - Y3 = Standard_ShortReal( PP3.Y() ); - X4 = Standard_ShortReal( PP4.X() ); - Y4 = Standard_ShortReal( PP4.Y() ); - X5 = Standard_ShortReal( PP5.X() ); - Y5 = Standard_ShortReal( PP5.Y() ); - X6 = Standard_ShortReal( PP6.X() ); - Y6 = Standard_ShortReal( PP6.Y() ); - X7 = Standard_ShortReal( PP7.X() ); - Y7 = Standard_ShortReal( PP7.Y() ); - X8 = Standard_ShortReal( PP8.X() ); - Y8 = Standard_ShortReal( PP8.Y() ); - - - if ( myGOPtr->IsTransformed () ) { - gp_GTrsf2d aTrsf = myGOPtr->Transform (); - Standard_Real a1, b1; - a1 = X1; - b1 = Y1; - aTrsf.Transforms( a1, b1 ); - X1 = Standard_ShortReal( a1 ); - Y1 = Standard_ShortReal( b1 ); - a1 = X2; - b1 = Y2; - aTrsf.Transforms( a1, b1 ); - X2 = Standard_ShortReal( a1 ); - Y2 = Standard_ShortReal( b1 ); - a1 = X3; - b1 = Y3; - aTrsf.Transforms( a1, b1 ); - X3 = Standard_ShortReal( a1 ); - Y3 = Standard_ShortReal( b1 ); - a1 = X4; - b1 = Y4; - aTrsf.Transforms( a1, b1 ); - X4 = Standard_ShortReal( a1 ); - Y4 = Standard_ShortReal( b1 ); - a1 = X5; - b1 = Y5; - aTrsf.Transforms( a1, b1 ); - X5 = Standard_ShortReal( a1 ); - Y5 = Standard_ShortReal( b1 ); - a1 = X6; - b1 = Y6; - aTrsf.Transforms( a1, b1 ); - X6 = Standard_ShortReal( a1 ); - Y6 = Standard_ShortReal( b1 ); - a1 = X7; - b1 = Y7; - aTrsf.Transforms( a1, b1 ); - X7 = Standard_ShortReal( a1 ); - Y7 = Standard_ShortReal( b1 ); - a1 = X8; - b1 = Y8; - aTrsf.Transforms( a1, b1 ); - X8 = Standard_ShortReal( a1 ); - Y8 = Standard_ShortReal( b1 ); - } - aDrawer->MapSegmentFromTo( X1, Y1, X2, Y2 ); - aDrawer->MapSegmentFromTo( X2, Y2, X3, Y3 ); - aDrawer->MapSegmentFromTo( X2, Y2, X4, Y4 ); - aDrawer->MapSegmentFromTo( X4, Y4, X3, Y3 ); - - aDrawer->MapSegmentFromTo( X5, Y5, X6, Y6 ); - aDrawer->MapSegmentFromTo( X6, Y6, X7, Y7 ); - aDrawer->MapSegmentFromTo( X6, Y6, X8, Y8 ); - aDrawer->MapSegmentFromTo( X8, Y8, X7, Y7 ); - - aDrawer->MapSegmentFromTo( X1, Y1, X5, Y5 ); - } -} - -void Prs2d_SymTotal::Save(Aspect_FStream& aFStream) const -{ -} diff --git a/src/Prs2d/Prs2d_Symmetry.cdl b/src/Prs2d/Prs2d_Symmetry.cdl deleted file mode 100755 index c63a6fdaee..0000000000 --- a/src/Prs2d/Prs2d_Symmetry.cdl +++ /dev/null @@ -1,54 +0,0 @@ --- Created by: TCL --- Copyright (c) 2000-2012 OPEN CASCADE SAS --- --- The content of this file is subject to the Open CASCADE Technology Public --- License Version 6.5 (the "License"). You may not use the content of this file --- except in compliance with the License. Please obtain a copy of the License --- at http://www.opencascade.org and read it completely before using this file. --- --- The Initial Developer of the Original Code is Open CASCADE S.A.S., having its --- main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. --- --- The Original Code and all software distributed under the License is --- distributed on an "AS IS" basis, without warranty of any kind, and the --- Initial Developer hereby disclaims all such warranties, including without --- limitation, any warranties of merchantability, fitness for a particular --- purpose or non-infringement. Please see the License for the specific terms --- and conditions governing the rights and limitations under the License. - - -class Symmetry from Prs2d inherits Tolerance from Prs2d - -uses - - GraphicObject from Graphic2d, - Drawer from Graphic2d, - Length from Quantity, - FStream from Aspect - -is - ------------------------- - -- Category: Constructors - ------------------------- - - Create( aGO : GraphicObject from Graphic2d; - aX, aY : Real from Standard; - aLength : Real from Standard = 3.0; - anAngle : Real from Standard = 0.0 ); - ---Level: Public - ---Purpose: Creates a tolerance Symmetry with the center at , ; - -- length of this is ; - -- reference point is , - ---Category: Constructor - - -------------------------- - -- Category: Draw and Pick - -------------------------- - - Draw( me : mutable; aDrawer: Drawer from Graphic2d ) is static protected; - ---Level: Internal - ---Purpose: Draws the Symmetry . - - Save( me; aFStream: in out FStream from Aspect ) is virtual; - -end Symmetry from Prs2d; diff --git a/src/Prs2d/Prs2d_Symmetry.cxx b/src/Prs2d/Prs2d_Symmetry.cxx deleted file mode 100755 index 35c2aae6bb..0000000000 --- a/src/Prs2d/Prs2d_Symmetry.cxx +++ /dev/null @@ -1,127 +0,0 @@ -// Copyright (c) 1999-2012 OPEN CASCADE SAS -// -// The content of this file is subject to the Open CASCADE Technology Public -// License Version 6.5 (the "License"). You may not use the content of this file -// except in compliance with the License. Please obtain a copy of the License -// at http://www.opencascade.org and read it completely before using this file. -// -// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its -// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. -// -// The Original Code and all software distributed under the License is -// distributed on an "AS IS" basis, without warranty of any kind, and the -// Initial Developer hereby disclaims all such warranties, including without -// limitation, any warranties of merchantability, fitness for a particular -// purpose or non-infringement. Please see the License for the specific terms -// and conditions governing the rights and limitations under the License. - -#include - -Prs2d_Symmetry::Prs2d_Symmetry( const Handle(Graphic2d_GraphicObject)& aGO, - const Standard_Real aX, - const Standard_Real aY, - const Standard_Real aLength, - const Standard_Real anAngle ) - - : Prs2d_Tolerance( aGO, aX, aY, aLength, anAngle ) -{ -} - -void Prs2d_Symmetry::Draw( const Handle(Graphic2d_Drawer)& aDrawer ) { - - Standard_Boolean IsIn = Standard_False; - - if ( !myGOPtr->IsTransformed() ) - IsIn = aDrawer->IsIn( myMinX, myMaxX, myMinY, myMaxY ); - else { - Standard_ShortReal minx, miny, maxx, maxy; - MinMax( minx, maxx, miny, maxy ); - IsIn = aDrawer->IsIn( minx, maxx, miny, maxy ); - } - - if ( IsIn ) { - DrawLineAttrib( aDrawer ); - Standard_ShortReal X1 = myX - myLength/2, - Y1 = myY, - X2 = myX + myLength/2, - Y2 = myY, - X3 = myX - myLength/3, - Y3 = myY - myLength/3, - X4 = myX + myLength/3, - Y4 = Y3, - X5 = X3, - Y5 = myY + myLength/3, - X6 = X4, - Y6 = Y5; - - gp_Pnt2d PP1( X1, Y1 ), - PP2( X2, Y2 ), - PP3( X3, Y3 ), - PP4( X4, Y4 ), - PP5( X5, Y5 ), - PP6( X6, Y6 ), - PPR( myX, myY ); - PP1.Rotate( PPR, myAngle ); - PP2.Rotate( PPR, myAngle ); - PP3.Rotate( PPR, myAngle ); - PP4.Rotate( PPR, myAngle ); - PP5.Rotate( PPR, myAngle ); - PP6.Rotate( PPR, myAngle ); - - X1 = Standard_ShortReal( PP1.X() ); - Y1 = Standard_ShortReal( PP1.Y() ); - X2 = Standard_ShortReal( PP2.X() ); - Y2 = Standard_ShortReal( PP2.Y() ); - X3 = Standard_ShortReal( PP3.X() ); - Y3 = Standard_ShortReal( PP3.Y() ); - X4 = Standard_ShortReal( PP4.X() ); - Y4 = Standard_ShortReal( PP4.Y() ); - X5 = Standard_ShortReal( PP5.X() ); - Y5 = Standard_ShortReal( PP5.Y() ); - X6 = Standard_ShortReal( PP6.X() ); - Y6 = Standard_ShortReal( PP6.Y() ); - - if ( myGOPtr->IsTransformed () ) { - gp_GTrsf2d aTrsf = myGOPtr->Transform (); - Standard_Real a1, b1; - a1 = X1; - b1 = Y1; - aTrsf.Transforms( a1, b1 ); - X1 = Standard_ShortReal( a1 ); - Y1 = Standard_ShortReal( b1 ); - a1 = X2; - b1 = Y2; - aTrsf.Transforms( a1, b1 ); - X2 = Standard_ShortReal( a1 ); - Y2 = Standard_ShortReal( b1 ); - a1 = X3; - b1 = Y3; - aTrsf.Transforms( a1, b1 ); - X3 = Standard_ShortReal( a1 ); - Y3 = Standard_ShortReal( b1 ); - a1 = X4; - b1 = Y4; - aTrsf.Transforms( a1, b1 ); - X4 = Standard_ShortReal( a1 ); - Y4 = Standard_ShortReal( b1 ); - a1 = X5; - b1 = Y5; - aTrsf.Transforms( a1, b1 ); - X5 = Standard_ShortReal( a1 ); - Y5 = Standard_ShortReal( b1 ); - a1 = X6; - b1 = Y6; - aTrsf.Transforms( a1, b1 ); - X6 = Standard_ShortReal( a1 ); - Y6 = Standard_ShortReal( b1 ); - } - aDrawer->MapSegmentFromTo( X1, Y1, X2, Y2 ); - aDrawer->MapSegmentFromTo( X3, Y3, X4, Y4 ); - aDrawer->MapSegmentFromTo( X5, Y5, X6, Y6 ); - } - -} - -void Prs2d_Symmetry::Save(Aspect_FStream& aFStream) const -{ -} diff --git a/src/Prs2d/Prs2d_Taper.cdl b/src/Prs2d/Prs2d_Taper.cdl deleted file mode 100755 index f66f746006..0000000000 --- a/src/Prs2d/Prs2d_Taper.cdl +++ /dev/null @@ -1,54 +0,0 @@ --- Created by: TCL --- Copyright (c) 2000-2012 OPEN CASCADE SAS --- --- The content of this file is subject to the Open CASCADE Technology Public --- License Version 6.5 (the "License"). You may not use the content of this file --- except in compliance with the License. Please obtain a copy of the License --- at http://www.opencascade.org and read it completely before using this file. --- --- The Initial Developer of the Original Code is Open CASCADE S.A.S., having its --- main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. --- --- The Original Code and all software distributed under the License is --- distributed on an "AS IS" basis, without warranty of any kind, and the --- Initial Developer hereby disclaims all such warranties, including without --- limitation, any warranties of merchantability, fitness for a particular --- purpose or non-infringement. Please see the License for the specific terms --- and conditions governing the rights and limitations under the License. - - -class Taper from Prs2d inherits Tolerance from Prs2d - -uses - - GraphicObject from Graphic2d, - Drawer from Graphic2d, - Length from Quantity, - FStream from Aspect - -is - ------------------------- - -- Category: Constructors - ------------------------- - - Create( aGO : GraphicObject from Graphic2d; - aX, aY : Real from Standard; - aLength : Real from Standard = 3.0; - anAngle : Real from Standard = 0.0 ); - ---Level: Public - ---Purpose: Creates a tolerance Taper with the center at , ; - -- length of this is ; - -- reference point is , - ---Category: Constructor - - -------------------------- - -- Category: Draw and Pick - -------------------------- - - Draw( me : mutable; aDrawer: Drawer from Graphic2d ) is static protected; - ---Level: Internal - ---Purpose: Draws the Taper . - - Save( me; aFStream: in out FStream from Aspect ) is virtual; - -end Taper from Prs2d; diff --git a/src/Prs2d/Prs2d_Taper.cxx b/src/Prs2d/Prs2d_Taper.cxx deleted file mode 100755 index bd615c7fd8..0000000000 --- a/src/Prs2d/Prs2d_Taper.cxx +++ /dev/null @@ -1,120 +0,0 @@ -// Copyright (c) 1999-2012 OPEN CASCADE SAS -// -// The content of this file is subject to the Open CASCADE Technology Public -// License Version 6.5 (the "License"). You may not use the content of this file -// except in compliance with the License. Please obtain a copy of the License -// at http://www.opencascade.org and read it completely before using this file. -// -// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its -// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. -// -// The Original Code and all software distributed under the License is -// distributed on an "AS IS" basis, without warranty of any kind, and the -// Initial Developer hereby disclaims all such warranties, including without -// limitation, any warranties of merchantability, fitness for a particular -// purpose or non-infringement. Please see the License for the specific terms -// and conditions governing the rights and limitations under the License. - -#include - -Prs2d_Taper::Prs2d_Taper( const Handle(Graphic2d_GraphicObject)& aGO, - const Standard_Real aX, - const Standard_Real aY, - const Standard_Real aLength, - const Standard_Real anAngle ) - - : Prs2d_Tolerance( aGO, aX, aY, aLength, anAngle ) -{ - myMinX = Standard_ShortReal( myX - myLength/5 ); - myMinY = Standard_ShortReal( myY - myLength/2 ); - myMaxX = Standard_ShortReal( myX + myLength/5 ); - myMaxY = Standard_ShortReal( myY + myLength/2 ); -} - -void Prs2d_Taper::Draw( const Handle(Graphic2d_Drawer)& aDrawer ) { - - Standard_Boolean IsIn = Standard_False; - - if ( !myGOPtr->IsTransformed() ) - IsIn = aDrawer->IsIn( myMinX, myMaxX, myMinY, myMaxY ); - else { - Standard_ShortReal minx, miny, maxx, maxy; - MinMax( minx, maxx, miny, maxy ); - IsIn = aDrawer->IsIn( minx, maxx, miny, maxy ); - } - - if ( IsIn ) { - DrawLineAttrib( aDrawer ); - const Standard_Real alpha = M_PI / 10; - - Standard_ShortReal X1 = myX - myLength/2, - Y1 = myY, - X2 = myX + myLength/2, - Y2 = myY; - - gp_Pnt2d P1( X2, Y2 ); - gp_Vec2d V1( P1, gp_Pnt2d( X1, Y1 ) ); - gp_Vec2d V2 = V1.Rotated( alpha ); - gp_Vec2d V3 = V1.Rotated( -alpha ); - V2 *= 0.88; - V3 *= 0.88; - gp_Pnt2d P2 = P1.Translated( V2 ), - P3 = P1.Translated( V3 ); - - Standard_ShortReal X3 = Standard_ShortReal( P2.X() ), - Y3 = Standard_ShortReal( P2.Y() ), - X4 = Standard_ShortReal( P3.X() ), - Y4 = Standard_ShortReal( P3.Y() ); - gp_Pnt2d PP1( X1, Y1 ), - PP2( X2, Y2 ), - PP3( X3, Y3 ), - PP4( X4, Y4 ), - PPR( myX, myY ); - PP1.Rotate( PPR, myAngle ); - PP2.Rotate( PPR, myAngle ); - PP3.Rotate( PPR, myAngle ); - PP4.Rotate( PPR, myAngle ); - - X1 = Standard_ShortReal( PP1.X() ); - Y1 = Standard_ShortReal( PP1.Y() ); - X2 = Standard_ShortReal( PP2.X() ); - Y2 = Standard_ShortReal( PP2.Y() ); - X3 = Standard_ShortReal( PP3.X() ); - Y3 = Standard_ShortReal( PP3.Y() ); - X4 = Standard_ShortReal( PP4.X() ); - Y4 = Standard_ShortReal( PP4.Y() ); - - if ( myGOPtr->IsTransformed () ) { - gp_GTrsf2d aTrsf = myGOPtr->Transform (); - Standard_Real a1, b1; - a1 = X1; - b1 = Y1; - aTrsf.Transforms( a1, b1 ); - X1 = Standard_ShortReal( a1 ); - Y1 = Standard_ShortReal( b1 ); - a1 = X2; - b1 = Y2; - aTrsf.Transforms( a1, b1 ); - X2 = Standard_ShortReal( a1 ); - Y2 = Standard_ShortReal( b1 ); - a1 = X3; - b1 = Y3; - aTrsf.Transforms( a1, b1 ); - X3 = Standard_ShortReal( a1 ); - Y3 = Standard_ShortReal( b1 ); - a1 = X4; - b1 = Y4; - aTrsf.Transforms( a1, b1 ); - X4 = Standard_ShortReal( a1 ); - Y4 = Standard_ShortReal( b1 ); - } - aDrawer->MapSegmentFromTo( X1, Y1, X2, Y2 ); - aDrawer->MapSegmentFromTo( X2, Y2, X3, Y3 ); - aDrawer->MapSegmentFromTo( X3, Y3, X4, Y4 ); - aDrawer->MapSegmentFromTo( X4, Y4, X2, Y2 ); - } -} - -void Prs2d_Taper::Save(Aspect_FStream& aFStream) const -{ -} diff --git a/src/Prs2d/Prs2d_Tolerance.cdl b/src/Prs2d/Prs2d_Tolerance.cdl deleted file mode 100755 index e1b4c44320..0000000000 --- a/src/Prs2d/Prs2d_Tolerance.cdl +++ /dev/null @@ -1,69 +0,0 @@ --- Created by: TCL --- Copyright (c) 2000-2012 OPEN CASCADE SAS --- --- The content of this file is subject to the Open CASCADE Technology Public --- License Version 6.5 (the "License"). You may not use the content of this file --- except in compliance with the License. Please obtain a copy of the License --- at http://www.opencascade.org and read it completely before using this file. --- --- The Initial Developer of the Original Code is Open CASCADE S.A.S., having its --- main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. --- --- The Original Code and all software distributed under the License is --- distributed on an "AS IS" basis, without warranty of any kind, and the --- Initial Developer hereby disclaims all such warranties, including without --- limitation, any warranties of merchantability, fitness for a particular --- purpose or non-infringement. Please see the License for the specific terms --- and conditions governing the rights and limitations under the License. - - -deferred class Tolerance from Prs2d inherits Line from Graphic2d - - ---Purpose: Groups all the tolerances - -uses - - GraphicObject from Graphic2d, - Drawer from Graphic2d, - Length from Quantity - -is - - Initialize( aGO : GraphicObject from Graphic2d; - aX, aY : Real from Standard; - aLength : Real from Standard; - anAngle : Real from Standard ); - ---Level: Public - ---Purpose: Creates a tolerance with the center in the point (, ); - -- reference point is , - ---Category: Constructor - - SetCoord( me: mutable; aX, aY: Real from Standard ); - ---Level: Public - ---Purpose: Changes the coordinates of this tolerance - - SetSize( me: mutable; aLen: Real from Standard ); - ---Level: Public - ---Purpose: Defines the size of this one - - Pick( me : mutable; X, Y: ShortReal from Standard; - aPrecision: ShortReal from Standard; - aDrawer: Drawer from Graphic2d ) - returns Boolean from Standard is protected; - ---Level: Internal - ---Purpose: Returns Standard_True if the Tolerance is picked, - -- Standard_False if not. - - -fields - - myX : ShortReal from Standard is protected; - myY : ShortReal from Standard is protected; - myLength : ShortReal from Standard is protected; - myAngle : ShortReal from Standard is protected; - -friends - - class ToleranceFrame from Prs2d - -end Tolerance from Prs2d; diff --git a/src/Prs2d/Prs2d_Tolerance.cxx b/src/Prs2d/Prs2d_Tolerance.cxx deleted file mode 100755 index 29fefc0e70..0000000000 --- a/src/Prs2d/Prs2d_Tolerance.cxx +++ /dev/null @@ -1,64 +0,0 @@ -// Copyright (c) 1999-2012 OPEN CASCADE SAS -// -// The content of this file is subject to the Open CASCADE Technology Public -// License Version 6.5 (the "License"). You may not use the content of this file -// except in compliance with the License. Please obtain a copy of the License -// at http://www.opencascade.org and read it completely before using this file. -// -// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its -// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. -// -// The Original Code and all software distributed under the License is -// distributed on an "AS IS" basis, without warranty of any kind, and the -// Initial Developer hereby disclaims all such warranties, including without -// limitation, any warranties of merchantability, fitness for a particular -// purpose or non-infringement. Please see the License for the specific terms -// and conditions governing the rights and limitations under the License. - -#include - -Prs2d_Tolerance::Prs2d_Tolerance( const Handle(Graphic2d_GraphicObject)& aGO, - const Standard_Real aX, - const Standard_Real aY, - const Standard_Real aLength, - const Standard_Real anAngle ) - : Graphic2d_Line( aGO ), - myX( Standard_ShortReal( aX ) ), - myY( Standard_ShortReal( aY ) ), - myLength( Standard_ShortReal( aLength ) ), - myAngle( Standard_ShortReal( anAngle ) ) -{ - gp_Pnt2d P1( myX - myLength/2, myY - myLength/2); - gp_Pnt2d P2( myX + myLength/2, myY + myLength/2); - gp_Pnt2d PR( myX, myY ); - P1.Rotate( PR, myAngle ); - P2.Rotate( PR, myAngle ); - - myMinX = Standard_ShortReal( P1.X() ); - myMinY = Standard_ShortReal( P1.Y() ); - myMaxX = Standard_ShortReal( P2.X() ); - myMaxY = Standard_ShortReal( P2.Y() ); - -} - -void Prs2d_Tolerance::SetCoord( const Standard_Real aX, - const Standard_Real aY ) { - - myX = Standard_ShortReal( aX ); - myY = Standard_ShortReal( aY ); -} - -void Prs2d_Tolerance::SetSize( const Standard_Real aLen ) { - - myLength = Standard_ShortReal( aLen ); - -} - -Standard_Boolean Prs2d_Tolerance::Pick( const Standard_ShortReal X, - const Standard_ShortReal Y, - const Standard_ShortReal aPrecision, - const Handle(Graphic2d_Drawer)& /*aDrawer*/ ) { - if ( IsInMinMax( X, Y, aPrecision ) ) - return Standard_True; - return Standard_False; -} diff --git a/src/Prs2d/Prs2d_ToleranceFrame.cdl b/src/Prs2d/Prs2d_ToleranceFrame.cdl deleted file mode 100755 index 45d5ff1d12..0000000000 --- a/src/Prs2d/Prs2d_ToleranceFrame.cdl +++ /dev/null @@ -1,133 +0,0 @@ --- Created by: TCL --- Copyright (c) 2000-2012 OPEN CASCADE SAS --- --- The content of this file is subject to the Open CASCADE Technology Public --- License Version 6.5 (the "License"). You may not use the content of this file --- except in compliance with the License. Please obtain a copy of the License --- at http://www.opencascade.org and read it completely before using this file. --- --- The Initial Developer of the Original Code is Open CASCADE S.A.S., having its --- main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. --- --- The Original Code and all software distributed under the License is --- distributed on an "AS IS" basis, without warranty of any kind, and the --- Initial Developer hereby disclaims all such warranties, including without --- limitation, any warranties of merchantability, fitness for a particular --- purpose or non-infringement. Please see the License for the specific terms --- and conditions governing the rights and limitations under the License. - - -class ToleranceFrame from Prs2d inherits Line from Graphic2d - -uses - - GraphicObject from Graphic2d, - Drawer from Graphic2d, - Length from Quantity, - ExtendedString from TCollection, - TypeOfTolerance from Prs2d, - Tolerance from Prs2d, - Array1OfShortReal from TShort, - FStream from Aspect, - Pnt2d from gp, - HArray1OfPnt2d from TColgp -is - ------------------------- - -- Category: Constructors - ------------------------- - - Create( aGO : GraphicObject from Graphic2d; - aX, aY : Length from Quantity; - aHeight : Length from Quantity; - aTolType : TypeOfTolerance from Prs2d = Prs2d_TOT_NONE; - aTolTxt : CString from Standard = ""; - aTxt1 : CString from Standard = ""; - aTxt2 : CString from Standard = ""; - anAngle : Real from Standard = 0.0; - aScale : Real from Standard = 1.0 ); - - ---Level: Public - ---Purpose: Creates a frame with a type of tolerance , - -- tolerance , the reference point is , , - the center of left vertical edge of this frame - ---Category: Constructor - - -------------------------- - -- Category: Draw and Pick - -------------------------- - - Draw( me : mutable; aDrawer: Drawer from Graphic2d ) - is static protected; - ---Level: Internal - ---Purpose: Draws the angle . - - Pick( me : mutable; X, Y: ShortReal from Standard; - aPrecision: ShortReal from Standard; - aDrawer: Drawer from Graphic2d) - returns Boolean from Standard - is static protected; - ---Level: Internal - ---Purpose: Returns Standard_True if the tolerance frame is picked, - -- Standard_False if not. - - SetHeight( me: mutable; aHSize: Real from Standard ); - ---Level: Public - ---Purpose: Defines the height of the frame - - Height( me ) returns Real from Standard; - ---Level: Public - ---Purpose: Indicates the current height of the frame - - --------------------------------------------------- - - Save( me; aFStream: in out FStream from Aspect ) is virtual; - - ArrayOfPnt2d( me ) returns HArray1OfPnt2d from TColgp; - ---Level: Public - ---C++: return const - ---Purpose: Returns array of 2d points, which produce frame for tolerance - -- Size of array == 4 - - SetTolText( me: mutable; aText: CString from Standard ); - ---Level: Public - ---Purpose: Sets the text to this tolerance - - SetText1( me: mutable; aText: CString from Standard ); - ---Level: Public - - SetText2( me: mutable; aText: CString from Standard ); - ---Level: Public - - - TolText( me ) returns ExtendedString from TCollection; - ---Level: Public - ---Purpose: Returns text and array, which contain points of cell - -- which separates the text from other parameters - - Text1( me ) returns ExtendedString from TCollection; - ---Level: Public - - Text2( me ) returns ExtendedString from TCollection; - ---Level: Public - - TextScale( me ) returns Real from Standard; - ---Level: Public - - -fields - - myX : ShortReal from Standard; - myY : ShortReal from Standard; - myTolTxt : ExtendedString from TCollection; - myTxt1 : ExtendedString from TCollection; - myTxt2 : ExtendedString from TCollection; - myHeight : ShortReal from Standard; - myAngle : ShortReal from Standard; - myScale : ShortReal from Standard; - myHTol : Tolerance from Prs2d; - - myXVert : Array1OfShortReal from TShort; - myYVert : Array1OfShortReal from TShort; - - -end ToleranceFrame from Prs2d; diff --git a/src/Prs2d/Prs2d_ToleranceFrame.cxx b/src/Prs2d/Prs2d_ToleranceFrame.cxx deleted file mode 100755 index 15b383ad56..0000000000 --- a/src/Prs2d/Prs2d_ToleranceFrame.cxx +++ /dev/null @@ -1,422 +0,0 @@ -// Copyright (c) 1999-2012 OPEN CASCADE SAS -// -// The content of this file is subject to the Open CASCADE Technology Public -// License Version 6.5 (the "License"). You may not use the content of this file -// except in compliance with the License. Please obtain a copy of the License -// at http://www.opencascade.org and read it completely before using this file. -// -// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its -// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. -// -// The Original Code and all software distributed under the License is -// distributed on an "AS IS" basis, without warranty of any kind, and the -// Initial Developer hereby disclaims all such warranties, including without -// limitation, any warranties of merchantability, fitness for a particular -// purpose or non-infringement. Please see the License for the specific terms -// and conditions governing the rights and limitations under the License. - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -Prs2d_ToleranceFrame::Prs2d_ToleranceFrame( const Handle(Graphic2d_GraphicObject)& aGO, - const Quantity_Length aX, - const Quantity_Length aY, - const Quantity_Length aHeight, - const Prs2d_TypeOfTolerance aTolType, - const Standard_CString aTolTxt, - const Standard_CString aTxt1, - const Standard_CString aTxt2, - const Standard_Real anAngle, - const Standard_Real aScale ) - - : Graphic2d_Line( aGO ), - - myX( Standard_ShortReal( aX ) ), - myY( Standard_ShortReal( aY ) ), - myTolTxt( TCollection_ExtendedString(aTolTxt) ), - myTxt1( TCollection_ExtendedString(aTxt1) ), - myTxt2( TCollection_ExtendedString(aTxt2) ), - myHeight( Standard_ShortReal( aHeight ) ), - myAngle( Standard_ShortReal( anAngle ) ), - myScale( Standard_ShortReal( aScale ) ), - myXVert( 1, 4 ), - myYVert( 1, 4 ) - -{ - - gp_Pnt2d PntP( myX, myY ); - gp_Vec2d theV1( gp_Pnt2d( myX, myY - myHeight/2 ), PntP ); - theV1.Rotate( myAngle ); - theV1.Reverse(); - gp_Pnt2d Pnt0 = PntP.Translated( theV1 ); - gp_Vec2d theVecG( Pnt0, gp_Pnt2d( Pnt0.X() + 1.0, Pnt0.Y() ) ); - theVecG.Rotate( myAngle ); - gp_Vec2d theVecV = theVecG.Rotated( M_PI / 2 ); - theVecG.Normalize(); - theVecV.Normalize(); - - gp_Pnt2d Pnt1 = Pnt0.Translated( theVecV * myHeight ); - myXVert(1) = Standard_ShortReal( Pnt0.X() ); - myYVert(1) = Standard_ShortReal( Pnt0.Y() ); - myXVert(2) = Standard_ShortReal( Pnt1.X() ); - myYVert(2) = Standard_ShortReal( Pnt1.Y() ); - gp_Pnt2d Pnt2 = Pnt0.Translated( theVecG * myHeight ); - myXVert(4) = Standard_ShortReal( Pnt2.X() ); - myYVert(4) = Standard_ShortReal( Pnt2.Y() ); - Pnt2 = Pnt1.Translated( theVecG * myHeight ); - myXVert(3) = Standard_ShortReal( Pnt2.X() ); - myYVert(3) = Standard_ShortReal( Pnt2.Y() ); - - myMinX = myX; - myMinY = myY; - myMaxX = myX; - myMaxY = myY; - - for ( Standard_Integer i = 1; i <= 4; i++ ) { - if ( myXVert(i) < myMinX ) myMinX = myXVert(i); - if ( myYVert(i) < myMinY ) myMinY = myYVert(i); - if ( myXVert(i) > myMaxX ) myMaxX = myXVert(i); - if ( myYVert(i) > myMaxY ) myMaxY = myYVert(i); - } - - gp_Vec2d VecTol( PntP, gp_Pnt2d( myX + myHeight/2, myY ) ); - VecTol.Rotate( myAngle ); - PntP.Translate( VecTol ); - Standard_Real xTTol = PntP.X(), - yTTol = PntP.Y(), - theSz1 = myHeight * 2/5, - theSz2 = myHeight * 3/5; - - switch ( aTolType ) { - case Prs2d_TOT_TAPER: - myHTol = new Prs2d_Taper( aGO, xTTol, yTTol, theSz2, myAngle ); - break; - case Prs2d_TOT_SYMTOTAL: - myHTol = new Prs2d_SymTotal( aGO, xTTol, yTTol, theSz2, myAngle ); - break; - case Prs2d_TOT_SYMCIRCULAR: - myHTol = new Prs2d_SymCircular( aGO, xTTol, yTTol, theSz2, myAngle ); - break; - case Prs2d_TOT_SYMMETRY: - myHTol = new Prs2d_Symmetry( aGO, xTTol, yTTol, theSz2, myAngle ); - break; - case Prs2d_TOT_CONCENTRIC: - myHTol = new Prs2d_Concentric( aGO, xTTol, yTTol, theSz2, myAngle ); - break; - case Prs2d_TOT_POSITION: - myHTol = new Prs2d_Position( aGO, xTTol, yTTol, theSz2, myAngle ); - break; - case Prs2d_TOT_ANGULARITY: - myHTol = new Prs2d_Angularity( aGO, xTTol, yTTol, theSz2, myAngle ); - break; - case Prs2d_TOT_PERPENDIC: - myHTol = new Prs2d_Perpendicular( aGO, xTTol, yTTol, theSz2, myAngle ); - break; - case Prs2d_TOT_PARALLELISM: - myHTol = new Prs2d_Parallelism( aGO, xTTol, yTTol, theSz1, myAngle ); - break; - case Prs2d_TOT_SURFACEPROF: - myHTol = new Prs2d_SurfProfile( aGO, xTTol, yTTol, theSz2, myAngle ); - break; - case Prs2d_TOT_LINEPROF: - myHTol = new Prs2d_LineProfile( aGO, xTTol, yTTol, theSz2, myAngle ); - break; - case Prs2d_TOT_CYLINDRIC: - myHTol = new Prs2d_Cylindric( aGO, xTTol, yTTol, theSz1, myAngle ); - break; - case Prs2d_TOT_CIRCULARITY: - myHTol = new Prs2d_Circularity( aGO, xTTol, yTTol, theSz2, myAngle ); - break; - case Prs2d_TOT_FLATNESS: - myHTol = new Prs2d_Flatness( aGO, xTTol, yTTol, theSz1, myAngle ); - break; - case Prs2d_TOT_STRAIGHTNESS: - myHTol = new Prs2d_Straightness( aGO, xTTol, yTTol, theSz2, myAngle ); - break; - case Prs2d_TOT_NONE: - default: - break; - - } -} - -void Prs2d_ToleranceFrame::Draw( const Handle(Graphic2d_Drawer)& aDrawer ) { - - Standard_Boolean IsIn = Standard_False; - - if ( ! myGOPtr->IsTransformed() ) - IsIn = aDrawer->IsIn( myMinX, myMaxX, myMinY,myMaxY ); - else { - Standard_ShortReal minx, miny, maxx, maxy; - MinMax(minx,maxx,miny,maxy); - IsIn = aDrawer->IsIn( minx, maxx, miny, maxy ); - } - - if ( IsIn ) { - - DrawLineAttrib( aDrawer ); - - gp_GTrsf2d aTrsf; - Standard_Real a1, b1; - - TShort_Array1OfShortReal Xpoint( 1, 4 ), Ypoint( 1, 4 ); - Xpoint.Assign( myXVert ); - Ypoint.Assign( myYVert ); - - if ( myGOPtr->IsTransformed() ) { - aTrsf = myGOPtr->Transform (); - for ( Standard_Integer j = 1; j <= 4; j++ ) { - a1 = Standard_Real( Xpoint(j) ); - b1 = Standard_Real( Ypoint(j) ); - aTrsf.Transforms( a1, b1 ); - Xpoint(j) = Standard_ShortReal( a1 ); - Ypoint(j) = Standard_ShortReal( b1 ); - } - } - aDrawer->MapPolygonFromTo( Xpoint, Ypoint ); - - //------------additional text's cells - - if ( myTolTxt.Length() || myTxt1.Length() || myTxt2.Length() ) { - gp_Pnt2d PntP( myX, myY ); - gp_Vec2d theV1( gp_Pnt2d( myX, myY - myHeight/2 ), PntP ); - theV1.Rotate( myAngle ); - theV1.Reverse(); - gp_Pnt2d Pnt0 = PntP.Translated( theV1 ), - PntT = PntP.Translated( theV1 / 2 ); - gp_Vec2d theVecT( PntT, gp_Pnt2d( PntT.X() + 1.0, PntT.Y() ) ); - theVecT.Rotate( myAngle ); - theVecT.Normalize(); - gp_Vec2d theVecG( Pnt0, gp_Pnt2d( Pnt0.X() + 1.0, Pnt0.Y() ) ); - theVecG.Rotate( myAngle ); - gp_Vec2d theVecV = theVecG.Rotated( M_PI / 2 ); - theVecG.Normalize(); - theVecV.Normalize(); - - gp_Pnt2d Pnt1 = Pnt0.Translated( theVecV * myHeight ); - gp_Pnt2d Pnt2 = Pnt0.Translated( theVecG * myHeight ); - - const Standard_ShortReal offS = Standard_ShortReal( 5 ); - aDrawer->SetTextAttrib( myColorIndex, 0, 0, Standard_ShortReal(myScale*aDrawer->Scale()), - Standard_ShortReal(myScale*aDrawer->Scale()), Standard_False ); - - Standard_ShortReal tVecSize = myHeight; - Standard_ShortReal ws = 0.0, hs; - gp_Pnt2d tmpPntTxt; - Standard_ShortReal X1=0., Y1=0., X2=0., Y2=0., X3, Y3, X4, Y4; - if ( myTolTxt.Length() ) { - tVecSize += offS; - tmpPntTxt = PntT.Translated( theVecT * tVecSize ); - X1 = Standard_ShortReal( tmpPntTxt.X() ); - Y1 = Standard_ShortReal( tmpPntTxt.Y() ); - if ( myGOPtr->IsTransformed () ) { - aTrsf = myGOPtr->Transform(); - a1 = Standard_Real( X1 ); - b1 = Standard_Real( Y1 ); - aTrsf.Transforms( a1, b1 ); - X1 = Standard_ShortReal( a1 ); Y1 = Standard_ShortReal( b1 ); - } - aDrawer->MapTextFromTo( myTolTxt, X1, Y1, myAngle, 0.0, 0.0, Aspect_TOT_SOLID ); - aDrawer->GetTextSize( myTolTxt, ws, hs ); - tVecSize += ws + offS; - - Pnt2 = Pnt0.Translated( theVecG * tVecSize ); - X1 = Standard_ShortReal( Pnt2.X() ); - Y1 = Standard_ShortReal( Pnt2.Y() ); - Pnt2 = Pnt1.Translated( theVecG * tVecSize ); - X2 = Standard_ShortReal( Pnt2.X() ); - Y2 = Standard_ShortReal( Pnt2.Y() ); - if ( myGOPtr->IsTransformed () ) { - aTrsf = myGOPtr->Transform(); - a1 = Standard_Real( X1 ); - b1 = Standard_Real( Y1 ); - aTrsf.Transforms( a1, b1 ); - X1 = Standard_ShortReal( a1 ); Y1 = Standard_ShortReal( b1 ); - a1 = Standard_Real( X2 ); - b1 = Standard_Real( Y2 ); - aTrsf.Transforms( a1, b1 ); - X2 = Standard_ShortReal( a1 ); Y2 = Standard_ShortReal( b1 ); - } - aDrawer->MapSegmentFromTo( X1, Y1, X2, Y2 ); - } - - if ( myTxt1.Length() ) { - tVecSize += offS; - tmpPntTxt = PntT.Translated( theVecT * tVecSize ); - X1 = Standard_ShortReal( tmpPntTxt.X() ); Y1 = Standard_ShortReal( tmpPntTxt.Y() ); - if ( myGOPtr->IsTransformed () ) { - aTrsf = myGOPtr->Transform(); - a1 = Standard_Real( X1 ); - b1 = Standard_Real( Y1 ); - aTrsf.Transforms( a1, b1 ); - X1 = Standard_ShortReal( a1 ); Y1 = Standard_ShortReal( b1 ); - } - aDrawer->MapTextFromTo( myTxt1, X1, Y1, myAngle, 0., 0.,Aspect_TOT_SOLID ); - aDrawer->GetTextSize( myTxt1, ws, hs ); - tVecSize += ws + offS; - - Pnt2 = Pnt0.Translated( theVecG * tVecSize ); - X1 = Standard_ShortReal( Pnt2.X() ); - Y1 = Standard_ShortReal( Pnt2.Y() ); - Pnt2 = Pnt1.Translated( theVecG * tVecSize ); - X2 = Standard_ShortReal( Pnt2.X() ); - Y2 = Standard_ShortReal( Pnt2.Y() ); - if ( myGOPtr->IsTransformed () ) { - aTrsf = myGOPtr->Transform(); - a1 = Standard_Real( X1 ); - b1 = Standard_Real( Y1 ); - aTrsf.Transforms( a1, b1 ); - X1 = Standard_ShortReal( a1 ); Y1 = Standard_ShortReal( b1 ); - a1 = Standard_Real( X2 ); - b1 = Standard_Real( Y2 ); - aTrsf.Transforms( a1, b1 ); - X2 = Standard_ShortReal( a1 ); Y2 = Standard_ShortReal( b1 ); - } - aDrawer->MapSegmentFromTo( X1, Y1, X2, Y2 ); - } - - if ( myTxt2.Length() ) { - tVecSize += offS; - tmpPntTxt = PntT.Translated( theVecT * tVecSize ); - X1 = Standard_ShortReal( tmpPntTxt.X() ); Y1 = Standard_ShortReal( tmpPntTxt.Y() ); - if ( myGOPtr->IsTransformed () ) { - aTrsf = myGOPtr->Transform(); - a1 = Standard_Real( X1 ); - b1 = Standard_Real( Y1 ); - aTrsf.Transforms( a1, b1 ); - X1 = Standard_ShortReal( a1 ); Y1 = Standard_ShortReal( b1 ); - } - aDrawer->MapTextFromTo( myTxt2, X1, Y1, myAngle, 0., 0., Aspect_TOT_SOLID ); - aDrawer->GetTextSize( myTxt2, ws, hs ); - tVecSize += ws + offS; - - Pnt2 = Pnt0.Translated( theVecG * tVecSize ); - X1 = Standard_ShortReal( Pnt2.X() ); - Y1 = Standard_ShortReal( Pnt2.Y() ); - Pnt2 = Pnt1.Translated( theVecG * tVecSize ); - X2 = Standard_ShortReal( Pnt2.X() ); - Y2 = Standard_ShortReal( Pnt2.Y() ); - if ( myGOPtr->IsTransformed () ) { - aTrsf = myGOPtr->Transform(); - a1 = Standard_Real( X1 ); - b1 = Standard_Real( Y1 ); - aTrsf.Transforms( a1, b1 ); - X1 = Standard_ShortReal( a1 ); Y1 = Standard_ShortReal( b1 ); - a1 = Standard_Real( X2 ); - b1 = Standard_Real( Y2 ); - aTrsf.Transforms( a1, b1 ); - X2 = Standard_ShortReal( a1 ); Y2 = Standard_ShortReal( b1 ); - } - aDrawer->MapSegmentFromTo( X1, Y1, X2, Y2 ); - } - - X3 = Standard_ShortReal( Pnt0.X() ); - Y3 = Standard_ShortReal( Pnt0.Y() ); - X4 = Standard_ShortReal( Pnt1.X() ); - Y4 = Standard_ShortReal( Pnt1.Y() ); - if ( myGOPtr->IsTransformed () ) { - aTrsf = myGOPtr->Transform(); - a1 = Standard_Real( X3 ); - b1 = Standard_Real( Y3 ); - aTrsf.Transforms( a1, b1 ); - X3 = Standard_ShortReal( a1 ); Y3 = Standard_ShortReal( b1 ); - a1 = Standard_Real( X4 ); - b1 = Standard_Real( Y4 ); - aTrsf.Transforms( a1, b1 ); - X4 = Standard_ShortReal( a1 ); Y4 = Standard_ShortReal( b1 ); - } - aDrawer->MapSegmentFromTo( X1, Y1, X3, Y3 ); - aDrawer->MapSegmentFromTo( X2, Y2, X4, Y4 ); - - } // end if one of text strings isn't empty - } // end if IsIn - - if ( ! myHTol.IsNull() ) - myHTol->Draw( aDrawer ); - -} - -Standard_Boolean Prs2d_ToleranceFrame::Pick( - const Standard_ShortReal X, - const Standard_ShortReal Y, - const Standard_ShortReal aPrecision, - const Handle(Graphic2d_Drawer)& /*aDrawer*/ ) { - if ( IsInMinMax( X, Y, aPrecision ) ) - return Standard_True; - return Standard_False; -} - -void Prs2d_ToleranceFrame::SetHeight( const Standard_Real aHSize ) { - - myHeight = Standard_ShortReal( aHSize ); -} - -Standard_Real Prs2d_ToleranceFrame::Height() const { - - return myHeight; -} - -void Prs2d_ToleranceFrame::Save(Aspect_FStream& aFStream) const -{ -} - -const Handle(TColgp_HArray1OfPnt2d) Prs2d_ToleranceFrame::ArrayOfPnt2d( ) const -{ - Handle(TColgp_HArray1OfPnt2d) points = new TColgp_HArray1OfPnt2d( 1, 4 ); - - for ( Standard_Integer i = 1; i <= 4; i++ ) - { - points->SetValue( i, gp_Pnt2d( myXVert(i), myYVert(i) ) ); - } - return points; -} - -void Prs2d_ToleranceFrame::SetTolText( const Standard_CString aTolTxt ) -{ - myTolTxt = TCollection_ExtendedString(aTolTxt); -} - -void Prs2d_ToleranceFrame::SetText1( const Standard_CString aTxt1 ) -{ - myTxt1 = TCollection_ExtendedString(aTxt1); -} - -void Prs2d_ToleranceFrame::SetText2( const Standard_CString aTxt2 ) -{ - myTxt2 = TCollection_ExtendedString(aTxt2); -} - -TCollection_ExtendedString Prs2d_ToleranceFrame::TolText( ) const -{ - return myTolTxt; -} - -TCollection_ExtendedString Prs2d_ToleranceFrame::Text1() const -{ - return myTxt1; -} - -TCollection_ExtendedString Prs2d_ToleranceFrame::Text2() const -{ - return myTxt2; -} - -Standard_Real Prs2d_ToleranceFrame::TextScale( ) const -{ - return myScale; -} diff --git a/src/PrsMgr/PrsMgr.cdl b/src/PrsMgr/PrsMgr.cdl index baaf279d59..5276cfbdb2 100755 --- a/src/PrsMgr/PrsMgr.cdl +++ b/src/PrsMgr/PrsMgr.cdl @@ -37,7 +37,6 @@ package PrsMgr uses MMgt,TCollection, - Graphic2d, TopLoc, Prs3d,Graphic3d, Quantity,Geom, @@ -63,11 +62,9 @@ is deferred class Presentation; deferred class PresentableObject; - class PresentationManager2d; class PresentationManager3d; class Prs; - class Presentation2d; class Presentation3d; class ModedPresentation; diff --git a/src/PrsMgr/PrsMgr_PresentableObject.cdl b/src/PrsMgr/PrsMgr_PresentableObject.cdl index a35ec9eed6..50c27813ab 100755 --- a/src/PrsMgr/PrsMgr_PresentableObject.cdl +++ b/src/PrsMgr/PrsMgr_PresentableObject.cdl @@ -35,7 +35,7 @@ deferred class PresentableObject from PrsMgr inherits TShared from MMgt - ---Purpose: A framework to supply the Graphic2d or Graphic3d + ---Purpose: A framework to supply the Graphic3d -- structure of the object to be presented. On the first -- display request, this structure is created by calling the -- appropriate algorithm and retaining this frameworkfor @@ -54,10 +54,8 @@ deferred class PresentableObject from PrsMgr inherits TShared from MMgt uses Presentation from PrsMgr, Presentation from Prs3d, - GraphicObject from Graphic2d, Presentations from PrsMgr, PresentationManager from PrsMgr, - PresentationManager2d from PrsMgr, PresentationManager3d from PrsMgr, TypeOfPresentation3d from PrsMgr, DataStructureManager from Graphic3d, @@ -80,19 +78,6 @@ is ---Category: deferred methods. -- - Compute(me:mutable; - aPresentationManager: PresentationManager2d from PrsMgr; - aPresentation: mutable GraphicObject from Graphic2d; - aMode: Integer from Standard = 0) - ---Purpose: Calculates the 2D view aPresentation and its - -- updates. The latter are managed by aPresentationManager. - -- aPresentableObject has the display mode aMode; - -- this has the default value of 0, that is, the wireframe display mode. - -- Note that this syntax is not used in AIS as that - -- package only concerns 3D display. - - raises NotImplemented from Standard - is virtual protected; Compute(me:mutable; aPresentationManager: PresentationManager3d from PrsMgr; diff --git a/src/PrsMgr/PrsMgr_PresentableObject.cxx b/src/PrsMgr/PrsMgr_PresentableObject.cxx index 6a5c3e2d20..bbcc1a5aa1 100755 --- a/src/PrsMgr/PrsMgr_PresentableObject.cxx +++ b/src/PrsMgr/PrsMgr_PresentableObject.cxx @@ -24,7 +24,6 @@ #include #include -#include #include #include #include @@ -55,10 +54,7 @@ PrsMgr_PresentableObject::PrsMgr_PresentableObject(const PrsMgr_TypeOfPresentati void PrsMgr_PresentableObject::Fill(const Handle(PrsMgr_PresentationManager)& aPresentationManager, const Handle(PrsMgr_Presentation)& aPresentation, const Standard_Integer aMode) { - if (aPresentation->DynamicType() == STANDARD_TYPE(PrsMgr_Presentation2d)) { - Compute(((Handle(PrsMgr_PresentationManager2d)&)aPresentationManager),((Handle(PrsMgr_Presentation2d)&)aPresentation)->Presentation(),aMode); - } - else if (aPresentation->DynamicType() == STANDARD_TYPE(PrsMgr_Presentation3d)) { + if (aPresentation->DynamicType() == STANDARD_TYPE(PrsMgr_Presentation3d)) { Compute(((Handle(PrsMgr_PresentationManager3d)&)aPresentationManager),((Handle(PrsMgr_Presentation3d)&)aPresentation)->Presentation(),aMode); UpdateLocation(((Handle(PrsMgr_Presentation3d)&)aPresentation)->Presentation()); Handle(Graphic3d_Structure) aStruct = Handle(Graphic3d_Structure)::DownCast( ((Handle(PrsMgr_Presentation3d)&)aPresentation)->Presentation() ); @@ -68,16 +64,7 @@ void PrsMgr_PresentableObject::Fill(const Handle(PrsMgr_PresentationManager)& aP } } -//======================================================================= -//function : Compute -//purpose : -//======================================================================= -void PrsMgr_PresentableObject::Compute(const Handle(PrsMgr_PresentationManager2d)& /*aPresentationManager*/, - const Handle(Graphic2d_GraphicObject)& /*aPresentation*/, - const Standard_Integer /*aMode*/) -{ - Standard_NotImplemented::Raise("cannot compute in a 2d visualizer"); -} + //======================================================================= //function : Compute //purpose : diff --git a/src/PrsMgr/PrsMgr_Presentation2d.cdl b/src/PrsMgr/PrsMgr_Presentation2d.cdl deleted file mode 100755 index 56c0c84bae..0000000000 --- a/src/PrsMgr/PrsMgr_Presentation2d.cdl +++ /dev/null @@ -1,129 +0,0 @@ --- Created on: 1993-10-21 --- Created by: Jean-Louis FRENKEL --- Copyright (c) 1993-1999 Matra Datavision --- Copyright (c) 1999-2012 OPEN CASCADE SAS --- --- The content of this file is subject to the Open CASCADE Technology Public --- License Version 6.5 (the "License"). You may not use the content of this file --- except in compliance with the License. Please obtain a copy of the License --- at http://www.opencascade.org and read it completely before using this file. --- --- The Initial Developer of the Original Code is Open CASCADE S.A.S., having its --- main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. --- --- The Original Code and all software distributed under the License is --- distributed on an "AS IS" basis, without warranty of any kind, and the --- Initial Developer hereby disclaims all such warranties, including without --- limitation, any warranties of merchantability, fitness for a particular --- purpose or non-infringement. Please see the License for the specific terms --- and conditions governing the rights and limitations under the License. - ---Modified by rob Dec-16-97 - - - -class Presentation2d from PrsMgr inherits Presentation from PrsMgr - - ---Purpose: A framework to manage 2D displays, graphic entities - -- and their updates. Plotters, Highlights, Minima - -- maxima, immediate display. - -uses - GraphicObject from Graphic2d, - PresentationManager2d from PrsMgr, - KindOfPrs from PrsMgr -is - Create(aPresentationManager2d: PresentationManager2d from PrsMgr) - returns mutable Presentation2d from PrsMgr - is private; - ---Purpose: Creates a framework to manage displays and graphic - -- entities with the 2D view aStructureManager. - - KindOfPresentation(me) returns KindOfPrs from PrsMgr is redefined static; - - Destroy(me: mutable) is redefined; - ---Level: Public - ---Purpose: Destructor. - ---C++: alias ~ - - Display(me: mutable) is redefined static private; - - Erase(me) is redefined static private; - - Highlight(me: mutable) is redefined static private; - - Unhighlight (me) is redefined static private; - - IsDisplayed(me) returns Boolean from Standard - is redefined static private; - - IsHighlighted(me) returns Boolean from Standard - is redefined static private; - - DisplayPriority(me) returns Integer from Standard - is redefined static private; - - SetDisplayPriority(me:mutable;aNewPrior:Integer from Standard) - is redefined static private; - - SetZLayer ( me : mutable; - theLayerId : Integer from Standard ) - is redefined static private; - ---Purpose: Set Z layer ID for the presentation - - GetZLayer ( me ) - returns Integer from Standard is redefined static private; - ---Purpose: Get Z layer ID for the presentation - - Clear(me:mutable) - ---Purpose: removes the whole content of the presentation. - - is redefined; - - Highlight(me; anIndex: Integer from Standard) - is static private; - - ---Category: 2d specialized methods. - - EnablePlot (me) - ---Purpose: Allows the drawing on a plotter of the graphic object - -- aPresentableObject with the display mode aMode. - is static private; - - DisablePlot (me) - ---Purpose: Forbids the drawing on a plotter of the graphic object - -- aPresentableObject with the display mode aMode. - is static private; - - IsPlottable (me) - returns Boolean from Standard - ---Purpose: Returns true if the graphic object aPresentableObject - -- with the display mode aMode can be plotted. - is static private; - - SetOffset (me: mutable;anOffset: Integer from Standard) - is static ; - ---Purpose: Specifies an Offset applied to the original color - -- index of all primitives in the graphic object . - -- Warning: To reset the real color of the primitives - -- you have to call this method with = 0. - - Offset (me) returns Integer from Standard - is static ; - ---Level: Public - ---Purpose: Returns the Offset applied to the original color - -- index of all primitives in the graphic object . - ---Category: Methods to manage the highlight - - Presentation (me) returns mutable GraphicObject from Graphic2d - is static ; - -fields - - myStructure: GraphicObject from Graphic2d; - -friends - class PresentationManager2d from PrsMgr, - class PresentableObject from PrsMgr - -end Presentation2d from PrsMgr; diff --git a/src/PrsMgr/PrsMgr_Presentation2d.cxx b/src/PrsMgr/PrsMgr_Presentation2d.cxx deleted file mode 100755 index cf1076ffef..0000000000 --- a/src/PrsMgr/PrsMgr_Presentation2d.cxx +++ /dev/null @@ -1,115 +0,0 @@ -// Created on: 1993-10-21 -// Created by: Jean-Louis FRENKEL -// Copyright (c) 1993-1999 Matra Datavision -// Copyright (c) 1999-2012 OPEN CASCADE SAS -// -// The content of this file is subject to the Open CASCADE Technology Public -// License Version 6.5 (the "License"). You may not use the content of this file -// except in compliance with the License. Please obtain a copy of the License -// at http://www.opencascade.org and read it completely before using this file. -// -// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its -// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. -// -// The Original Code and all software distributed under the License is -// distributed on an "AS IS" basis, without warranty of any kind, and the -// Initial Developer hereby disclaims all such warranties, including without -// limitation, any warranties of merchantability, fitness for a particular -// purpose or non-infringement. Please see the License for the specific terms -// and conditions governing the rights and limitations under the License. - -// Modified by rob 09-oct-96 - - -#include -#include - -PrsMgr_Presentation2d::PrsMgr_Presentation2d(const Handle(PrsMgr_PresentationManager2d)& aPresentationManager) -:PrsMgr_Presentation(aPresentationManager), myStructure(new Graphic2d_GraphicObject(aPresentationManager->StructureManager())) {} - -PrsMgr_KindOfPrs PrsMgr_Presentation2d::KindOfPresentation() const -{return PrsMgr_KOP_2D;} - -void PrsMgr_Presentation2d::Display (){ - myStructure->Display();} - -void PrsMgr_Presentation2d::Erase () const { - myStructure->Erase();} - -void PrsMgr_Presentation2d::Highlight () { - myStructure->Highlight();} - -void PrsMgr_Presentation2d::Unhighlight () const { - myStructure->Unhighlight();} - -void PrsMgr_Presentation2d::Highlight(const Standard_Integer anIndex) const{ - myStructure->Highlight(anIndex);} - -Standard_Boolean PrsMgr_Presentation2d::IsDisplayed () const { - return myStructure->IsDisplayed(); -} - -Standard_Boolean PrsMgr_Presentation2d::IsHighlighted () const { - return myStructure->IsHighlighted(); -} - - -Standard_Integer PrsMgr_Presentation2d::DisplayPriority() const { -return -1; -} - -void PrsMgr_Presentation2d::SetDisplayPriority(const Standard_Integer TheNewPrior) -{ - // peut etre Raise ? -} - - - - -void PrsMgr_Presentation2d::EnablePlot () const { - myStructure->EnablePlot(); -} - -void PrsMgr_Presentation2d::DisablePlot () const { - myStructure->DisablePlot(); -} - -Standard_Boolean PrsMgr_Presentation2d::IsPlottable () const { - return myStructure->IsPlottable(); -} - -void PrsMgr_Presentation2d::Clear () { - myStructure->RemovePrimitives(); -} - -Handle(Graphic2d_GraphicObject) PrsMgr_Presentation2d::Presentation() const { - return myStructure; -} -void PrsMgr_Presentation2d::SetOffset(const Standard_Integer anOffset) { - myStructure->SetOffSet(anOffset);} - -Standard_Integer PrsMgr_Presentation2d::Offset () const { - return myStructure->OffSet();} - - -void PrsMgr_Presentation2d::Destroy () { -} - -//======================================================================= -//function : SetZLayer -//purpose : -//======================================================================= - -void PrsMgr_Presentation2d::SetZLayer (Standard_Integer theLayer) -{ -} - -//======================================================================= -//function : GetZLayer -//purpose : -//======================================================================= - -Standard_Integer PrsMgr_Presentation2d::GetZLayer () const -{ - return 0; -} diff --git a/src/PrsMgr/PrsMgr_PresentationManager2d.cdl b/src/PrsMgr/PrsMgr_PresentationManager2d.cdl deleted file mode 100755 index 242c4539f0..0000000000 --- a/src/PrsMgr/PrsMgr_PresentationManager2d.cdl +++ /dev/null @@ -1,177 +0,0 @@ --- Created on: 1993-10-21 --- Created by: Jean-Louis FRENKEL --- Copyright (c) 1993-1999 Matra Datavision --- Copyright (c) 1999-2012 OPEN CASCADE SAS --- --- The content of this file is subject to the Open CASCADE Technology Public --- License Version 6.5 (the "License"). You may not use the content of this file --- except in compliance with the License. Please obtain a copy of the License --- at http://www.opencascade.org and read it completely before using this file. --- --- The Initial Developer of the Original Code is Open CASCADE S.A.S., having its --- main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. --- --- The Original Code and all software distributed under the License is --- distributed on an "AS IS" basis, without warranty of any kind, and the --- Initial Developer hereby disclaims all such warranties, including without --- limitation, any warranties of merchantability, fitness for a particular --- purpose or non-infringement. Please see the License for the specific terms --- and conditions governing the rights and limitations under the License. - --- Modified by rob Aug 20 98 : --- new Methods : Is3D() , AddToImmediateList (GO) --- BeginDraw redefined --- new field : myGOList --- => allows users to store independant Graphic --- Objects, which will be displayed in immediate mode --- when EndDraw is applied - - -class PresentationManager2d from PrsMgr inherits PresentationManager from PrsMgr - - ---Purpose: A framework to manage 2D displays, graphic entities - -- and their updates. Plotters, Highlights, Minima - -- maxima, immediate display (of transient graphic data???]. - -uses - ListOfTransient from TColStd, - View from Graphic2d, - TransientManager from Graphic2d, - PresentableObject from PrsMgr, - Presentation from PrsMgr, - Presentation2d from PrsMgr, - DisplayList from Graphic2d, - GraphicObject from Graphic2d, - Buffer from Graphic2d, - View from Viewer - -is - - Create(aStructureManager: View from Graphic2d) - returns mutable PresentationManager2d from PrsMgr; - ---Purpose: Creates a framework to manage displays and graphic - -- entities with the 2D view aStructureManager. - - Is3D(me) returns Boolean from Standard is redefined static; - - ColorHighlight(me: mutable; - aPresentableObject: mutable PresentableObject from PrsMgr; - anIndex: Integer from Standard; - aMode: Integer from Standard = 0) - is static; - ---Purpose: Highlights the graphic object aPresentableObject in - -- color by the color index anIndex. aPresentableObject - -- has the display mode aMode. - - EnablePlot (me: mutable; - aPresentableObject: mutable PresentableObject from PrsMgr; - aMode: Integer from Standard = 0) - is static; - ---Purpose: Allows the drawing on a plotter of the graphic object - -- aPresentableObject with the display mode aMode. - - DisablePlot (me: mutable; - aPresentableObject: mutable PresentableObject from PrsMgr; - aMode: Integer from Standard = 0) - ---Purpose: Forbids the drawing on a plotter of the graphic object - -- aPresentableObject with the display mode aMode. - is static; - - IsPlottable (me; - aPresentableObject: mutable PresentableObject from PrsMgr; - aMode: Integer from Standard = 0) - returns Boolean from Standard - ---Level: Public - ---Purpose: Returns Standard_True if the graphic object - -- is plottable, Standard_False if not. - ---Category: Methods to manage the plotter - is static; - - SetOffset (me: mutable; - aPresentableObject: mutable PresentableObject from PrsMgr; - anOffset: Integer from Standard; - aMode: Integer from Standard = 0) - is static; - ---Level: Public - ---Purpose: Specifies an Offset applied to the original color - -- index of all primitives in the graphic object . - -- Warning: To reset the real color of the primitives - -- you have to call this method with = 0. - ---Category: Methods to manage the highlight - - Offset (me; - aPresentableObject: mutable PresentableObject from PrsMgr; - aMode: Integer from Standard = 0) - returns Integer from Standard - is static; - ---Level: Public - ---Purpose: Returns the Offset applied to the original color - -- index of all primitives in the graphic object . - ---Category: Methods to manage the highlight - - - InitMinMax(me: mutable) - ---Purpose: Initializes a list of 2D objects for which minima and - -- maxima will be calculated. - is static; - - AddMinMax(me: mutable; aPresentableObject: PresentableObject from PrsMgr; - aMode: Integer from Standard = 0) - ---Purpose: Appends the graphic object aPresentableObject with - -- the display mode aMode to the list of objects for - -- which minima and maxima will be calculated. - is static; - - MinMax(me; MinX,MaxX,MinY,MaxY: out Real from Standard) - ---Purpose: Returns the minima and maxima for all the graphic - -- objects listed by the AddMinMax function. - is static; - - SetHighlightColor(me:mutable; anIndex: Integer from Standard) - is static; - --- Purpose: Sets the highlight color index anIndex. - - StructureManager(me) returns mutable View from Graphic2d - is static; - ---Purpose: Returns the structure manager. - - - - BeginDraw(me:mutable) is redefined static; - - AddToImmediateList(me:mutable;aGO:GraphicObject from Graphic2d); - - EndDraw(me: mutable; aView: View from Viewer; DoubleBuffer: Boolean from Standard = Standard_False) - is redefined static; - ---Purpose: Allows rapid drawing of the view aView by avoiding - -- an update of the whole background. If DoubleBuffer is true, the background is drawn. - - - Dump (me: mutable; - aBuffer: Buffer from Graphic2d; - aPresentableObject: PresentableObject from PrsMgr; - aMode: Integer from Standard = 0) is static; - ---Level: Public - ---Purpose: Dumps the Graphic Primitives of the PresentatbleObject in the buffer - - - CastPresentation(me; aPresentableObject: mutable PresentableObject from PrsMgr; - aMode: Integer from Standard = 0) - returns mutable Presentation2d from PrsMgr - is static; - - newPresentation(me: mutable; aPresentableObject: PresentableObject from PrsMgr) - returns mutable Presentation from PrsMgr - ---Level: Internal - ---Purpose: Creates a new presentation in the presentation manager. - is redefined static; - - - -fields - - myStructureManager: View from Graphic2d; - MinMaxList: DisplayList from Graphic2d; - myTM : TransientManager from Graphic2d; - myGOList : ListOfTransient from TColStd; -end PresentationManager2d from PrsMgr; diff --git a/src/PrsMgr/PrsMgr_PresentationManager2d.cxx b/src/PrsMgr/PrsMgr_PresentationManager2d.cxx deleted file mode 100755 index a2a32b0b18..0000000000 --- a/src/PrsMgr/PrsMgr_PresentationManager2d.cxx +++ /dev/null @@ -1,167 +0,0 @@ -// Copyright (c) 1998-1999 Matra Datavision -// Copyright (c) 1999-2012 OPEN CASCADE SAS -// -// The content of this file is subject to the Open CASCADE Technology Public -// License Version 6.5 (the "License"). You may not use the content of this file -// except in compliance with the License. Please obtain a copy of the License -// at http://www.opencascade.org and read it completely before using this file. -// -// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its -// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. -// -// The Original Code and all software distributed under the License is -// distributed on an "AS IS" basis, without warranty of any kind, and the -// Initial Developer hereby disclaims all such warranties, including without -// limitation, any warranties of merchantability, fitness for a particular -// purpose or non-infringement. Please see the License for the specific terms -// and conditions governing the rights and limitations under the License. - -#define G002 // TCL 040500 The Transientmanager has changed -// to avoid unavailable cyclic dependency under WNT. - -#include -#include -#include -#include -#include -#include - - - -PrsMgr_PresentationManager2d::PrsMgr_PresentationManager2d (const Handle(Graphic2d_View)& aStructureManager):myStructureManager(aStructureManager) { -#ifdef G002 - myTM = new Graphic2d_TransientManager(myStructureManager.operator -> ()); -#else - myTM = new Graphic2d_TransientManager(myStructureManager); -#endif - myTM->SetOverrideColor(32); - myTM->SetMapping(Standard_True); -} - - -Standard_Boolean PrsMgr_PresentationManager2d::Is3D() const -{return Standard_False;} - -void PrsMgr_PresentationManager2d::ColorHighlight(const Handle(PrsMgr_PresentableObject)& aPresentableObject, const Standard_Integer aColor, const Standard_Integer aMode) { - if (!HasPresentation(aPresentableObject,aMode)){ - AddPresentation(aPresentableObject,aMode); - } - CastPresentation(aPresentableObject,aMode)->Highlight(aColor); - - // immediate mode -// Add(aPresentableObject,aMode); -} - -void PrsMgr_PresentationManager2d::EnablePlot(const Handle(PrsMgr_PresentableObject)& aPresentableObject, const Standard_Integer aMode) { - CastPresentation(aPresentableObject,aMode)->EnablePlot(); -} - -void PrsMgr_PresentationManager2d::DisablePlot(const Handle(PrsMgr_PresentableObject)& aPresentableObject, const Standard_Integer aMode) { - CastPresentation(aPresentableObject,aMode)->DisablePlot(); -} - -Standard_Boolean PrsMgr_PresentationManager2d::IsPlottable(const Handle(PrsMgr_PresentableObject)& aPresentableObject, const Standard_Integer aMode) const { - return CastPresentation(aPresentableObject,aMode)->IsPlottable(); -} - -void PrsMgr_PresentationManager2d::SetHighlightColor(const Standard_Integer anIndex) { - myStructureManager->SetDefaultOverrideColor(anIndex); -} - -Handle(PrsMgr_Presentation) PrsMgr_PresentationManager2d::newPresentation(const Handle(PrsMgr_PresentableObject) & aPresentableObject) { - return new PrsMgr_Presentation2d(this); -} - -Handle(Graphic2d_View) PrsMgr_PresentationManager2d::StructureManager () const { - return myStructureManager; -} - - -void PrsMgr_PresentationManager2d::Dump - (const Handle(Graphic2d_Buffer)& aBuffer, - const Handle(PrsMgr_PresentableObject)& aPresentableObject, - const Standard_Integer aMode) { - if (!HasPresentation(aPresentableObject,aMode)){ - AddPresentation(aPresentableObject,aMode); - } - aBuffer->Add(CastPresentation(aPresentableObject,aMode)->Presentation()); - - } - -Handle(PrsMgr_Presentation2d) PrsMgr_PresentationManager2d::CastPresentation(const Handle(PrsMgr_PresentableObject)& aPresentableObject, const Standard_Integer aMode) const { - return Handle(PrsMgr_Presentation2d)::DownCast(Presentation(aPresentableObject,aMode)); -} -void PrsMgr_PresentationManager2d::InitMinMax() { - MinMaxList = new Graphic2d_DisplayList; -} -void PrsMgr_PresentationManager2d::AddMinMax(const Handle(PrsMgr_PresentableObject)& aPresentableObject, const Standard_Integer aMode) { - - if (HasPresentation(aPresentableObject,aMode)){ - MinMaxList->Append(CastPresentation(aPresentableObject,aMode)->Presentation());} -} - - -void PrsMgr_PresentationManager2d::MinMax(Standard_Real& MinX, - Standard_Real& MaxX, - Standard_Real& MinY, - Standard_Real& MaxY) const { - - myStructureManager->MinMax(MinMaxList,MinX,MaxX,MinY,MaxY); -} -void PrsMgr_PresentationManager2d::SetOffset(const Handle(PrsMgr_PresentableObject)& aPresentableObject, const Standard_Integer anOffset,const Standard_Integer aMode) { - if (HasPresentation(aPresentableObject,aMode)){ - CastPresentation(aPresentableObject,aMode)->SetOffset(anOffset); - } - - // immediate mode -// Add(aPresentableObject,aMode); -} - -Standard_Integer PrsMgr_PresentationManager2d::Offset(const Handle(PrsMgr_PresentableObject)& aPresentableObject,const Standard_Integer aMode) const{ - return CastPresentation(aPresentableObject,aMode)->Offset();} - - - -//======================================================================= -//function : BeginDraw -//purpose : -//======================================================================= -void PrsMgr_PresentationManager2d::BeginDraw() -{ - PrsMgr_PresentationManager::BeginDraw(); - myGOList.Clear(); -} - -//======================================================================= -//function : AddToImmediateList -//purpose : -//======================================================================= -void PrsMgr_PresentationManager2d::AddToImmediateList(const Handle(Graphic2d_GraphicObject)& GO) -{myGOList.Append(GO);} - -//======================================================================= -//function : EndDraw -//purpose : -//======================================================================= - -void PrsMgr_PresentationManager2d::EndDraw(const Handle(Viewer_View)& aView, const Standard_Boolean DoubleBuffer) { - Handle(V2d_View) aV2d = Handle(V2d_View)::DownCast(aView); - myTM->BeginDraw(Handle(Aspect_WindowDriver)::DownCast(aV2d->Driver()),Standard_True); - - TColStd_ListIteratorOfListOfTransient it(myImmediateList); - while (it.More()) { - Handle(Graphic2d_GraphicObject) aGO = Handle(PrsMgr_Presentation2d)::DownCast(it.Value())->Presentation(); - if (!aGO.IsNull()) myTM->Draw(aGO); - it.Next(); - } - - Handle(Standard_Transient) Tr; - for(it.Initialize(myGOList);it.More();it.Next()){ - Tr =it.Value(); - myTM->Draw(*((Handle(Graphic2d_GraphicObject)*)&Tr)); - } - - myTM->EndDraw(Standard_True); - myImmediateMode = Standard_False; -} - diff --git a/src/QABugs/QABugs_11.cxx b/src/QABugs/QABugs_11.cxx index abfd74bdaa..d1ed2872bd 100755 --- a/src/QABugs/QABugs_11.cxx +++ b/src/QABugs/QABugs_11.cxx @@ -1478,50 +1478,6 @@ static Standard_Integer OCC525(Draw_Interpretor& di, Standard_Integer /*argc*/, return 0; } -#include -#include - -#include -#include -#include -#include - -#if ! defined(WNT) -extern Viewer2dTest_DoubleMapOfInteractiveAndName& GetMapOfAIS2D(); -#else -Standard_EXPORT Viewer2dTest_DoubleMapOfInteractiveAndName& GetMapOfAIS2D(); -#endif - -//======================================================================= -//function : OCC543 -//purpose : -//======================================================================= -static Standard_Integer OCC543 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv) -{ - Handle(AIS2D_InteractiveContext) aContext = Viewer2dTest::GetAIS2DContext(); - if(aContext.IsNull()) { - di << "ERROR: Use 'v2dinit' command before " << argv[0] << "\n"; - return -1; - } - if(argc != 2){ - di<<"Usage : " << argv[0] << " name\n"; - return -1; - } - Handle(V2d_View) V = Viewer2dTest::CurrentView(); - - TCollection_AsciiString name = argv[1]; - - if (!GetMapOfAIS2D().IsBound2(name)) { -// di << "There is not an object with name " << name.ToCString() << "\n"; -// return -1; - } - - Handle(AIS2D_InteractiveObject) aShape = GetMapOfAIS2D().Find2(name); - Standard_Integer PickedIndex = aShape->PickedIndex(); - di << "PickedIndex = " << PickedIndex << "\n"; - return 0; -} - #include #include #include @@ -1658,34 +1614,6 @@ static Standard_Integer OCC578 (Draw_Interpretor& di, Standard_Integer argc, con return 0; } -#include -#include - -//======================================================================= -//function : OCC627 -//purpose : -//======================================================================= -static Standard_Integer OCC627 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv) -{ - Handle(AIS2D_InteractiveContext) aContext = Viewer2dTest::GetAIS2DContext(); - if(aContext.IsNull()) { - di << "ERROR: Use 'v2dinit' command before " << argv[0] << "\n"; - return -1; - } - if(argc != 1){ - di<<"Usage : " << argv[0] << "\n"; - return -1; - } - - Handle(V2d_View) V = Viewer2dTest::CurrentView(); - Handle(Graphic2d_View) View = V->View(); - Handle(Graphic2d_DisplayList) DisplayList = View->DisplayList(); - Standard_Integer Length = DisplayList->Length(); - di << "Length = " << Length << "\n"; - - return 0; -} - #include //======================================================================= //function : OCC669 @@ -5511,10 +5439,8 @@ void QABugs::Commands_11(Draw_Interpretor& theCommands) { theCommands.Add("OCC369", "OCC369 Shape", __FILE__, OCC369, group); theCommands.Add("OCC524", "OCC524 LowerVector UpperVector InitialValueVector LowerRowMatrix UpperRowMatrix LowerColMatrix UpperColMatrix InitialValueMatrix", __FILE__, OCC524, group); theCommands.Add("OCC525", "OCC525", __FILE__, OCC525, group); - theCommands.Add("OCC543", "OCC543 name", __FILE__, OCC543, group); //theCommands.Add("OCC578", "OCC578 shape1 shape2 shape3", __FILE__, OCC578, group); theCommands.Add("OCC578", "OCC578 shape1 shape2 shape3 [BRepAlgoAPI/BRepAlgo = 1/0]", __FILE__, OCC578, group); - theCommands.Add("OCC627", "OCC627", __FILE__, OCC627, group); theCommands.Add("OCC669", "OCC669 GUID", __FILE__, OCC669, group); theCommands.Add("OCC738_ShapeRef", "OCC738_ShapeRef", __FILE__, OCC738_ShapeRef, group); theCommands.Add("OCC738_Assembly", "OCC738_Assembly", __FILE__, OCC738_Assembly, group); diff --git a/src/QABugs/QABugs_17.cxx b/src/QABugs/QABugs_17.cxx index 7bcd44cbb2..04b03479f7 100755 --- a/src/QABugs/QABugs_17.cxx +++ b/src/QABugs/QABugs_17.cxx @@ -18,11 +18,6 @@ // and conditions governing the rights and limitations under the License. -#if defined(WOKC40) -#define V2D -#define Viewer2dTest QAViewer2dTest -#endif - #include #include @@ -78,36 +73,10 @@ #include #include #include - #include - -#if defined(WOKC40) -#include -#include -#else -#include -#include -#endif - #include #include -#include -#include #include - -#if ! defined(WNT) -#if defined(WOKC40) -extern QAViewer2dTest_DoubleMapOfInteractiveAndName& GetMapOfAIS2D(); -#else -extern Viewer2dTest_DoubleMapOfInteractiveAndName& GetMapOfAIS2D(); -#endif -#else -Standard_EXPORT Viewer2dTest_DoubleMapOfInteractiveAndName& GetMapOfAIS2D(); -#endif - -#include -#include - #include static Standard_Integer BUC60842 (Draw_Interpretor& di, Standard_Integer /*argc*/,const char ** /*argv*/) @@ -777,82 +746,6 @@ static Standard_Integer OCC189 (Draw_Interpretor& di, Standard_Integer /*argc*/ return 0; } -static Standard_Integer OCC389 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv) -{ - if (argc < 3) - { - di<<"Usage: " << argv[0] << " name shape1 [shape2] ..."<<"\n"; - return 1; - } - - //if (Viewer2dTest::CurrentView().IsNull()) - //{ - // cout << "2D AIS Viewer Initialization ..." << endl; - // Viewer2dTest::ViewerInit(); - // cout << "Done" << endl; - //} - - di<<"Begin!"<<"\n"; - Handle(AIS2D_InteractiveContext) aContext = Viewer2dTest::GetAIS2DContext(); - di<<"Check InteractiveContext"<<"\n"; - - if(aContext.IsNull()) { - di << "use 'v2dinit' command before " << argv[0] << "\n"; - return 1; - } - - di<<"CloseLocalContext"<<"\n"; - aContext->CloseLocalContext(); - - di<<"OpenLocalContext"<<"\n"; - aContext->OpenLocalContext(); - - TCollection_AsciiString name(argv[1]); - - di<<"Found name"<<"\n"; - Standard_Boolean IsBound = GetMapOfAIS2D().IsBound2(name); - if (IsBound) - { - di<<"Already displayed"<<"\n"; - } - else // Create the AIS2D_ProjShape from a name - { - di<<"Create the AIS2D_ProjShape from a name; (1)"<<"\n"; - Prs3d_Projector aPrs3dProjector(Standard_False, 1, -1.0,0.2,0.3, 0.0, 0.0, 0.0, -0.0,0.0,1.0); - di<<"Create the AIS2D_ProjShape from a name; (2)"<<"\n"; - HLRAlgo_Projector aProjector = aPrs3dProjector.Projector(); - di<<"Create the AIS2D_ProjShape from a name; (3)"<<"\n"; - Handle(AIS2D_ProjShape) shp_2d = - new AIS2D_ProjShape(aProjector, 0, Standard_False, Standard_True); - di<<"Create the AIS2D_ProjShape from a name; (4)"<<"\n"; - - Standard_Integer i; - Standard_Boolean isValid = Standard_False; - for (i = 2; i < argc; i++) - { - di<<"i="<< i-1 <<"\n"; - TopoDS_Shape aShape = DBRep::Get(argv[i]); - if (!aShape.IsNull()) - { - shp_2d->Add( aShape ); - di<<"Added shape: "<Display(shp_2d, 1, 1, Standard_True); - - GetMapOfAIS2D().Bind(shp_2d, name); - } - } - - aContext->UpdateCurrentViewer(); - return 0; -} - #include #include //======================================================================= @@ -1530,297 +1423,6 @@ static Standard_Integer OCC1174_2 (Draw_Interpretor& di, Standard_Integer argc, return 0; } -#include -#include -#include -#include -//======================================================================= -// OCC672: -// OCC672_Length -// OCC672_Angle -// OCC672_Diameter -// OCC672_ShortLength -//======================================================================= - -static Standard_Integer OCC672_Length (Draw_Interpretor& di, Standard_Integer n,const char ** argv) -{ - if (n != 17) { - di << " wrong parameters !\n"; - di << "must be : OCC672_Length x1 y1 x2 y2 str scale_text length_dist angle_arrow length_arrow x3 y3 x4 y4 TxtAngle TxtPosH TxtPosV\n"; - return 1; - } - - Standard_Real x1=atof(argv[1]); - Standard_Real y1=atof(argv[2]); - Standard_Real x2=atof(argv[3]); - Standard_Real y2=atof(argv[4]); - Standard_Real x3=atof(argv[10]); - Standard_Real y3=atof(argv[11]); - Standard_Real x4=atof(argv[12]); - Standard_Real y4=atof(argv[13]); - Standard_Real txtAngle=atof(argv[14]); - Standard_Real txtPosH=atof(argv[15]); - Standard_Real txtPosV=atof(argv[16]); - - di<<"Begin!\n"; - Handle(AIS2D_InteractiveContext) aContext = Viewer2dTest::GetAIS2DContext(); - di<<"Check InteractiveContext\n"; - - if(aContext.IsNull()) { - di << "use 'v2dinit' command before " << argv[0] << "\n"; - return 1; - } - - di<<"CloseLocalContext\n"; - aContext->CloseLocalContext(); - - di<<"OpenLocalContext\n"; - aContext->OpenLocalContext(); - //step0 end - Handle(AIS2D_InteractiveObject) aIO10 = new AIS2D_InteractiveObject(); - Handle(Graphic2d_Segment) theSegmA, theSegmB, theSegmC, theSegmD; - - theSegmA = new Graphic2d_Segment( aIO10, x1, y1, x2, y2 ); - theSegmB = new Graphic2d_Segment( aIO10, x2, y2, x3, y3 ); - theSegmC = new Graphic2d_Segment( aIO10, x3, y3, x4, y4 ); - theSegmD = new Graphic2d_Segment( aIO10, x4, y4, x1, y1 ); - - aContext->Display( aIO10, Standard_True ); - - Handle(Prs2d_Length) length = new Prs2d_Length(aIO10, gp_Pnt2d(x1, y1), gp_Pnt2d(x2, y2), argv[5], - atof(argv[6]), atof(argv[7]), Prs2d_TOD_AUTOMATIC, - atof(argv[8]), atof(argv[9]), Prs2d_TOA_FILLED, - Prs2d_AS_BOTHAR); - - length->SetTextRelPos(txtPosH,txtPosV); - length->SetTextRelAngle(txtAngle); - - Handle(Prs2d_AspectLine) theAspect = new Prs2d_AspectLine(Quantity_NOC_WHITE, - Aspect_TOL_SOLID, Aspect_WOL_THIN); - aIO10->SetAspect( theAspect, length); - aContext->Display( aIO10, Standard_True ); - - Handle(Prs2d_Length) lengthB = new Prs2d_Length(aIO10, gp_Pnt2d(x2, y2), gp_Pnt2d(x3, y3), argv[5], - atof(argv[6]), atof(argv[7]), Prs2d_TOD_AUTOMATIC, - atof(argv[8]), atof(argv[9]), Prs2d_TOA_FILLED, - Prs2d_AS_BOTHAR); - - lengthB->SetTextRelPos(txtPosH,txtPosV); - lengthB->SetTextRelAngle(txtAngle); - - aIO10->SetAspect( theAspect, lengthB); - aContext->Display( aIO10, Standard_True ); - - Handle(Prs2d_Length) lengthC = new Prs2d_Length(aIO10, gp_Pnt2d(x3, y3), gp_Pnt2d(x4, y4), argv[5], - atof(argv[6]), atof(argv[7]), Prs2d_TOD_AUTOMATIC, - atof(argv[8]), atof(argv[9]), Prs2d_TOA_FILLED, - Prs2d_AS_BOTHAR); - - lengthC->SetTextRelPos(txtPosH,txtPosV); - lengthC->SetTextRelAngle(txtAngle); - - aIO10->SetAspect( theAspect, lengthC); - aContext->Display( aIO10, Standard_True ); - - Handle(Prs2d_Length) lengthD = new Prs2d_Length(aIO10, gp_Pnt2d(x4, y4), gp_Pnt2d(x1, y1), argv[5], - atof(argv[6]), atof(argv[7]), Prs2d_TOD_AUTOMATIC, - atof(argv[8]), atof(argv[9]), Prs2d_TOA_FILLED, - Prs2d_AS_BOTHAR); - - lengthD->SetTextRelPos(txtPosH,txtPosV); - lengthD->SetTextRelAngle(txtAngle); - - aIO10->SetAspect( theAspect, lengthD); - aContext->Display( aIO10, Standard_True ); - return 0; -} - -#include -static Standard_Integer OCC672_Angle (Draw_Interpretor& di, Standard_Integer n,const char ** argv) -{ - if (n != 15) { - di << "Wrong parameters !\n"; - di << "must be : OCC672_Angle x1 y1 x2 y2 x3 y3 aRadius aText aTxtScale anArrAngle anArrLength txtAngle txtPosH txtPosV \n"; - return 1; - } - - Standard_Real x1=atof(argv[1]); - Standard_Real y1=atof(argv[2]); - Standard_Real x2=atof(argv[3]); - Standard_Real y2=atof(argv[4]); - Standard_Real x3=atof(argv[5]); - Standard_Real y3=atof(argv[6]); - Standard_Real aRadius=atof(argv[7]); - Standard_Real aTxtScale=atof(argv[9]); - Standard_Real anArrAngle=atof(argv[10]); - Standard_Real anArrLength=atof(argv[11]); - Standard_Real txtAngle=atof(argv[12]); - Standard_Real txtPosH=atof(argv[13]); - Standard_Real txtPosV=atof(argv[14]); - - di<<"Begin!\n"; - Handle(AIS2D_InteractiveContext) aContext = Viewer2dTest::GetAIS2DContext(); - di<<"Check InteractiveContext\n"; - - if(aContext.IsNull()) { - di << "use 'v2dinit' command before " << argv[0] << "\n"; - return 1; - } - - di<<"CloseLocalContext\n"; - aContext->CloseLocalContext(); - - di<<"OpenLocalContext\n"; - aContext->OpenLocalContext(); - - Handle(AIS2D_InteractiveObject) aIO10 = new AIS2D_InteractiveObject(); - Handle(Graphic2d_Segment) theSegmA, theSegmB; - theSegmA = new Graphic2d_Segment( aIO10, x1, y1, x2, y2 ); - theSegmB = new Graphic2d_Segment( aIO10, x1, y1, x3, y3 ); - aContext->Display( aIO10, Standard_True ); - - Handle(Prs2d_Angle) angle = new Prs2d_Angle(aIO10, gp_Pnt2d(x1, y1), gp_Pnt2d(x2, y2),gp_Pnt2d(x3,y3), - aRadius,argv[8],aTxtScale,anArrAngle,anArrLength,Prs2d_TOA_FILLED, - Prs2d_AS_BOTHAR); - - angle->SetTextRelPos(txtPosH,txtPosV); - angle->SetTextAbsAngle(txtAngle); - - aContext->Display( aIO10, Standard_True ); - return 0; -} - -#include -#include -#include -#include -static Standard_Integer OCC672_Diameter (Draw_Interpretor& di, Standard_Integer n,const char ** argv) -{ - if (n != 13) { - di << "Wrong parameters !\n"; - di << "must be : OCC672_Diameter x1 y1 cx cy radius aText aTxtScale anArrAngle anArrLength txtAngle txtPosH txtPosV\n"; - return 1; - } - - Standard_Real x1=atof(argv[1]); - Standard_Real y1=atof(argv[2]); - Standard_Real cx=atof(argv[3]); //coordinats for circle - Standard_Real cy=atof(argv[4]); // - Standard_Real radius=atof(argv[5]);//radius for circle - Standard_Real aTxtScale=atof(argv[7]); - Standard_Real anArrAngle=atof(argv[8]); - Standard_Real anArrLength=atof(argv[9]); - - Standard_Real txtAngle=atof(argv[10]); - Standard_Real txtPosH=atof(argv[11]); - Standard_Real txtPosV=atof(argv[12]); - - - di<<"Begin!\n"; - Handle(AIS2D_InteractiveContext) aContext = Viewer2dTest::GetAIS2DContext(); - di<<"Check InteractiveContext\n"; - - if(aContext.IsNull()) { - di << "use 'v2dinit' command before " << argv[0] << "\n"; - return 1; - } - - di<<"CloseLocalContext\n"; - aContext->CloseLocalContext(); - - di<<"OpenLocalContext\n"; - aContext->OpenLocalContext(); - Handle(AIS2D_InteractiveObject) aIO10 = new AIS2D_InteractiveObject(); - - Handle (Graphic2d_Circle) HCirc; - HCirc= new Graphic2d_Circle(aIO10,cx,cy,radius); - - gp_Dir2d myDir2d(1,0); - gp_Pnt2d myPnt2d(cx,cy); - gp_Ax2d myAx2d(myPnt2d,myDir2d); - gp_Circ2d myCirc(myAx2d,radius); - - Handle(Prs2d_Diameter) diameter = new Prs2d_Diameter(aIO10, gp_Pnt2d(x1, y1),myCirc, - argv[6],aTxtScale,anArrAngle,anArrLength, - Prs2d_TOA_FILLED, - Prs2d_AS_BOTHAR,Standard_True); - - diameter->SetTextRelPos(txtPosH,txtPosV); - - diameter->SetTextAbsAngle(txtAngle); - - aContext->Display( aIO10, Standard_True ); - - return 0; -} - -#include -static Standard_Integer OCC672_ShortLength (Draw_Interpretor& di, Standard_Integer n,const char ** argv) -{ - if (n != 17) { - di << " wrong parameters !\n"; - di << "must be : OCC672_ShortLength x1 y1 x2 y2 str scale_text length_dist angle_arrow length_arrow x3 y3 x4 y4 TxtAngle TxtPosH TxtPosV\n"; - return 1; - } - - Standard_Real x1=atof(argv[1]); - Standard_Real y1=atof(argv[2]); - Standard_Real x2=atof(argv[3]); - Standard_Real y2=atof(argv[4]); - Standard_Real x3=atof(argv[10]); - Standard_Real y3=atof(argv[11]); - Standard_Real x4=atof(argv[12]); - Standard_Real y4=atof(argv[13]); - Standard_Real txtAngle=atof(argv[14]); - Standard_Real txtPosH=atof(argv[15]); - Standard_Real txtPosV=atof(argv[16]); - - - di<<"Begin!\n"; - Handle(AIS2D_InteractiveContext) aContext = Viewer2dTest::GetAIS2DContext(); - di<<"Check InteractiveContext\n"; - - if(aContext.IsNull()) { - di << "use 'v2dinit' command before " << argv[0] << "\n"; - return 1; - } - - di<<"CloseLocalContext\n"; - aContext->CloseLocalContext(); - - di<<"OpenLocalContext\n"; - aContext->OpenLocalContext(); - - Handle(AIS2D_InteractiveObject) aIO10 = new AIS2D_InteractiveObject(); - Handle(Graphic2d_Segment) theSegmA, theSegmB, theSegmC, theSegmD; - theSegmB = new Graphic2d_Segment( aIO10, x2, y2, x3, y3 ); - theSegmD = new Graphic2d_Segment( aIO10, x4, y4, x1, y1 ); - - aContext->Display( aIO10, Standard_True ); - - gp_Pnt2d p3(x3,y3),p2(x2,y2),p1(x1,y1); - gp_Vec2d theVec(p3,p2); - gp_Dir2d theDir(theVec); - gp_Lin2d theLin1(p1,theDir); - gp_Lin2d theLin2(p3,theDir); - - Handle(Prs2d_Length) length = new Prs2d_Length(aIO10, p1, theLin2, argv[5], - atof(argv[6]), 5.0, 20.0, 5., - Prs2d_TOA_CLOSED,Prs2d_AS_BOTHAR, - Standard_True); - - - Handle(Prs2d_AspectLine) theAspect = new Prs2d_AspectLine(Quantity_NOC_WHITE, - Aspect_TOL_SOLID, Aspect_WOL_THIN); - length->SetTextRelPos(txtPosH,txtPosV); - length->SetTextRelAngle(txtAngle); - - aIO10->SetAspect( theAspect, length); - aContext->Display( aIO10, Standard_True ); - - return 0; -} - #include #include //======================================================================= @@ -2173,84 +1775,6 @@ static Standard_Integer OCC1642 (Draw_Interpretor& di, Standard_Integer argc, co return 0; } -Standard_Integer OCC17480(Draw_Interpretor& di, Standard_Integer n, const char ** a) -{ - if ( n < 2 ) { - cout << "Usage: OCC17480 basic_shape " <Display(ais_pipe); - - if(!aContext_2d.IsNull()) - aContext_2d->EraseAll(Standard_True); - - gp_Ax3 ax3(gp_Pnt(0, 0, 0), gp_Dir(0, 0, 1), gp_Dir(0, 1, 0)); - gp_Pln plane(ax3); - gp_Ax2 ax2 = ax3.Ax2(); - - HLRAlgo_Projector aProjector = HLRAlgo_Projector(ax2); - Handle_AIS2D_ProjShape myDisplayableShape = - new AIS2D_ProjShape(aProjector, 0, mode, Standard_True); - - myDisplayableShape->Add( brep_pipe ); - - di << "\n Total number of primitives : " << myDisplayableShape->Length(); - - Handle(Graphic2d_Line) mySectProjLines = myDisplayableShape->GetPrimitives(); - Handle(Graphic2d_Line) mySectProjLinesHLR = myDisplayableShape->GetHLPrimitives(); - - Handle_Standard_Type sty = mySectProjLines->DynamicType(); - Handle_Standard_Type sty1 = mySectProjLinesHLR->DynamicType(); - - di << "\n Class Name = " << (char*)sty->Name(); - di << "\n HLR Class Name = " << (char*)sty1->Name(); - di << "\n mySectProjLines.IsNull = " << (Standard_Integer) mySectProjLines.IsNull(); - di << "\n mySectProjLinesHLR.IsNull = " << (Standard_Integer) mySectProjLinesHLR.IsNull(); - - Handle(GGraphic2d_SetOfCurves) setCurves; - Handle(Graphic2d_SetOfSegments) setSegments; - - if(mySectProjLines->IsKind(STANDARD_TYPE(GGraphic2d_SetOfCurves))) - { - setCurves = Handle(GGraphic2d_SetOfCurves)::DownCast(mySectProjLines); - di << "\n Number of Curves in set = " << setCurves->Length(); - } - if(mySectProjLines->IsKind(STANDARD_TYPE(Graphic2d_SetOfSegments))) - { - setSegments = Handle(Graphic2d_SetOfSegments)::DownCast(mySectProjLines); - di << "\n Number of Curves in set = " << setSegments->Length(); - } - - Handle(GGraphic2d_SetOfCurves) setCurvesHLR; - Handle(Graphic2d_SetOfSegments) setSegmentsHLR; - - if(mySectProjLinesHLR->IsKind(STANDARD_TYPE(GGraphic2d_SetOfCurves))) - { - setCurvesHLR = Handle(GGraphic2d_SetOfCurves)::DownCast(mySectProjLinesHLR); - di << "\n HLR Number of Curves in set = " << setCurvesHLR->Length(); - } - if(mySectProjLinesHLR->IsKind(STANDARD_TYPE(Graphic2d_SetOfSegments))) - { - setSegmentsHLR = Handle(Graphic2d_SetOfSegments)::DownCast(mySectProjLinesHLR); - di << "\n HLR Number of Curves in set = " << setSegmentsHLR->Length(); - } - - aContext_2d->Display( myDisplayableShape,Standard_True ); - return 0; -} - void QABugs::Commands_17(Draw_Interpretor& theCommands) { const char *group = "QABugs"; @@ -2266,8 +1790,6 @@ void QABugs::Commands_17(Draw_Interpretor& theCommands) { theCommands.Add ("OCC232", "OCC232", __FILE__, OCC232 , group); theCommands.Add ("OCC138LC", "OCC138LC", __FILE__, OCC138LC, group); theCommands.Add ("OCC189", "OCC189", __FILE__, OCC189, group); - theCommands.Add ("OCC389", "OCC389 name shape1 [shape2] ...", __FILE__, OCC389, group); - theCommands.Add ("OCC566", "OCC566 shape [ xmin ymin zmin xmax ymax zmax] ; print bounding box", __FILE__, OCC566, group); theCommands.Add ("OCC570", "OCC570 result", __FILE__, OCC570, group); @@ -2294,11 +1816,6 @@ void QABugs::Commands_17(Draw_Interpretor& theCommands) { theCommands.Add ("OCC1174_1", "OCC1174_1 shape", __FILE__, OCC1174_1, group); theCommands.Add ("OCC1174_2", "OCC1174_2 shape", __FILE__, OCC1174_2, group); - theCommands.Add("OCC672_Length"," OCC672_Length x1 y1 x2 y2 str scale_text length_dist angle_arrow length_arrow x3 y3 x4 y4 textAngle textPosH textPosV",__FILE__,OCC672_Length,group); - theCommands.Add("OCC672_Angle","OCC672_Angle x1 y1 x2 y2 x3 y3 aRadius aText aTxtScale anArrAngle anArrLength txtAngle txtPosH txtPosV",__FILE__,OCC672_Angle,group); - theCommands.Add("OCC672_Diameter","OCC672_Diameter x1 y1 cx cy radius aText aTxtScale anArrAngle anArrLength txtAngle txtPosH txtPosV",__FILE__,OCC672_Diameter,group); - theCommands.Add("OCC672_ShortLength","",__FILE__,OCC672_ShortLength,group); - theCommands.Add ("OCCN1", "OCCN1 angle fuse(1 for boss / 0 for slot) length", __FILE__, OCCN1, group); theCommands.Add ("OCCN2", "OCCN2", __FILE__, OCCN2, group); @@ -2306,7 +1823,5 @@ void QABugs::Commands_17(Draw_Interpretor& theCommands) { theCommands.Add ("OCC1642", "OCC1642 FinalWare FinalFace InitWare InitFace shape FixReorder FixDegenerated FixConnected FixSelfIntersection", __FILE__, OCC1642, group); - theCommands.Add ("OCC17480", "OCC17480 Shape", __FILE__, OCC17480, group); - return; } diff --git a/src/QABugs/QABugs_18.cxx b/src/QABugs/QABugs_18.cxx index db0a3f76c6..6fd759ab00 100755 --- a/src/QABugs/QABugs_18.cxx +++ b/src/QABugs/QABugs_18.cxx @@ -18,11 +18,6 @@ // and conditions governing the rights and limitations under the License. -#if defined(WOKC40) -#define V2D -#define Viewer2dTest QAViewer2dTest -#endif - #include #include @@ -48,20 +43,6 @@ #include #include - -#if defined(WOKC40) -#include -#else -#include -#endif - -#include -#include -#include -#include -#include -#include - #include #include #include @@ -94,7 +75,6 @@ static Quantity_NameOfColor GetColorFromName( const char *name, Standard_Boolean return ret; } - static Standard_Integer BUC60851 (Draw_Interpretor& di, Standard_Integer /*argc*/, const char ** /*argv*/) { Handle(AIS_InteractiveContext) context= ViewerTest_Tool::MakeContext ("buc60851"); @@ -179,68 +159,6 @@ static Standard_Integer OCC181 (Draw_Interpretor& di, Standard_Integer argc, con return 0; } -static Standard_Integer OCC402bug (Draw_Interpretor& di, Standard_Integer argc, const char ** argv) -{ - Handle(AIS2D_InteractiveContext) aContext = Viewer2dTest::GetAIS2DContext(); - if(aContext.IsNull()) { - di << "ERROR: Use 'v2dinit' command before " << argv[0] << "\n"; - return 1; - } - - if ( !(argc == 7 || argc == 8) ) { - di << "ERROR : Usage : " << argv[0] << " IndexMarker>0 TypeOfDetection=0/1/2/3/4 X Y Width Height [Angle=0.0]" << "\n"; - return 1; - } - - Standard_Integer IndexMarker = atoi(argv[1]); - if (IndexMarker <= 0) { - di << "ERROR : IndexMarker>0" << "\n"; - return 1; - } - - Standard_Integer TypeOfDetectionInteger = atoi(argv[2]); - AIS2D_TypeOfDetection TypeOfDetection; - switch (TypeOfDetectionInteger) { - case 0: - case 1: - case 2: - case 3: - case 4: - TypeOfDetection = (AIS2D_TypeOfDetection) TypeOfDetectionInteger; - break; - default: - di << "ERROR : TypeOfDetection=0/1/2/3/4" << "\n"; - return 1; - } - - Quantity_Length X = atof(argv[3]); - Quantity_Length Y = atof(argv[4]); - Quantity_Length Width = atof(argv[5]); - Quantity_Length Height = atof(argv[6]); - Quantity_PlaneAngle PlaneAngle; - if ( argc == 7) { - PlaneAngle = 0.0; - } else { - PlaneAngle = atof(argv[7]); - } - - Handle(V2d_View) View = Viewer2dTest::CurrentView(); - //Handle(V2d_Viewer) aViewer = ViewerTest::GetViewerFromContext(); - - Handle(AIS2D_InteractiveObject) obj = new AIS2D_InteractiveObject(); - Handle(Graphic2d_SetOfMarkers) markers = new Graphic2d_SetOfMarkers( obj ); - - markers->Add(IndexMarker, X, Y, Width, Height, PlaneAngle); - - aContext->Display( obj, Standard_False ); - obj->SetHighlightMode( TypeOfDetection ); - //aContext->SetDetectionMode( TypeOfDetection ); - - View->Fitall(); - - return 0; -} - static Standard_Real delta_percent (Standard_Real a, Standard_Real b) { Standard_Real result; @@ -367,67 +285,6 @@ static Standard_Integer OCC71bug (Draw_Interpretor& di, Standard_Integer /*argc* return 0; } -static Standard_Integer OCC403bug (Draw_Interpretor& di, Standard_Integer argc, const char ** argv) -{ - Handle(AIS2D_InteractiveContext) aContext = Viewer2dTest::GetAIS2DContext(); - if(aContext.IsNull()) { - di << "ERROR: Use 'v2dinit' command before " << argv[0] << "\n"; - return 1; - } - - if ( argc != 3) { - di << "ERROR : Usage : " << argv[0] << " ColorName1 ColorName2" << "\n"; - return 1; - } - - Standard_Boolean Found; - Quantity_NameOfColor NameOfColor1 = GetColorFromName(argv[1] ,Found); - if ( !Found ) { - di << "ERROR: " << argv[1] << " - color not found" << "\n"; - return 1; - } - Quantity_NameOfColor NameOfColor2 = GetColorFromName(argv[2] ,Found); - if ( !Found ) { - di << "ERROR: " << argv[2] << " - color not found" << "\n"; - return 1; - } - - Quantity_Color Color1(NameOfColor1); - Quantity_Color Color2(NameOfColor2); - - Handle(V2d_View) View = Viewer2dTest::CurrentView(); - Handle(V2d_Viewer) Viewer = View->Viewer(); - Viewer->SetGridColor(Color1, Color2); - - return 0; -} - -static Standard_Integer OCC404bug (Draw_Interpretor& di, Standard_Integer argc, const char ** argv) -{ - Handle(AIS2D_InteractiveContext) aContext = Viewer2dTest::GetAIS2DContext(); - if(aContext.IsNull()) { - di << "ERROR: Use 'v2dinit' command before " << argv[0] << "\n"; - return 1; - } - if ( argc != 4) { - di << "ERROR : Usage : " << argv[0] << " R G B" << "\n"; - return 1; - } - - Quantity_Parameter R1 = (Quantity_Parameter) atof(argv[1]); - Quantity_Parameter R2 = (Quantity_Parameter) atof(argv[2]); - Quantity_Parameter R3 = (Quantity_Parameter) atof(argv[3]); - - Quantity_Color Color; - Color.SetValues(R1, R2, R3, Quantity_TOC_RGB); - - Handle(V2d_View) View = Viewer2dTest::CurrentView(); - View->SetBackground(Color); - View->Update(); - - return 0; -} - void QABugs::Commands_18(Draw_Interpretor& theCommands) { const char *group = "QABugs"; @@ -435,11 +292,8 @@ void QABugs::Commands_18(Draw_Interpretor& theCommands) { theCommands.Add("OCC216", "OCC216", __FILE__, OCC216, group); theCommands.Add("OCC267", "OCC267 DOC path", __FILE__, OCC267, group); theCommands.Add("OCC181", "OCC181 FileName path1 path2 verbose=0/1", __FILE__, OCC181, group); - theCommands.Add("OCC402", "OCC402 TypeOfDetection=0/1/2/3/4 X Y Width Height [Angle=0.0]", __FILE__, OCC402bug, group); theCommands.Add("OCC367", "OCC367 shape step goodX goodY goodZ percent_tolerance", __FILE__, OCC367, group); theCommands.Add("OCC71", "OCC71", __FILE__, OCC71bug, group); - theCommands.Add("OCC403", "OCC403 ColorName1 ColorName2", __FILE__, OCC403bug, group); - theCommands.Add("OCC404", "OCC404 R G B; Set Background Color", __FILE__, OCC404bug, group); return; } diff --git a/src/QADraw/QADraw.cxx b/src/QADraw/QADraw.cxx index 8d27f07c3a..5c26bd66d0 100755 --- a/src/QADraw/QADraw.cxx +++ b/src/QADraw/QADraw.cxx @@ -40,10 +40,6 @@ #include #include -#include -#include -#include - #if ! defined(WNT) #include //#include @@ -348,78 +344,78 @@ static Standard_Integer QAAISGetPixelColor (Draw_Interpretor& theDi, Standard_Integer theArgsNb, const char** theArgs) { - if (theArgsNb != 3 && theArgsNb != 6) - { - theDi << "Usage : " << theArgs[0] << " coordinate_X coordinate_Y [color_R color_G color_B]" << "\n"; - return 1; // TCL_ERROR - } - - Handle(V3d_View) aView3d = ViewerTest::CurrentView(); - if (aView3d.IsNull()) - { - theDi << "You must initialize AISViewer before this command.\n"; - return 1; // TCL_ERROR - } - - const Handle(Aspect_Window) anAISWindow = aView3d->Window(); - Standard_Integer aWindowSizeX = 0; - Standard_Integer aWindowSizeY = 0; - anAISWindow->Size (aWindowSizeX, aWindowSizeY); - - Standard_Integer anArgIter = 1; - const Standard_Integer aPickCoordX = atoi (theArgs[anArgIter++]); - const Standard_Integer aPickCoordY = atoi (theArgs[anArgIter++]); - const Standard_Integer aRadius = (theArgsNb == 3) ? 0 : 1; - - Image_ColorRGBF aColorInput = {{ 0.0f, 0.0f, 0.0f }}; - if (theArgsNb == 6) - { - aColorInput.r() = (Standard_ShortReal )atof (theArgs[anArgIter++]); - aColorInput.g() = (Standard_ShortReal )atof (theArgs[anArgIter++]); - aColorInput.b() = (Standard_ShortReal )atof (theArgs[anArgIter++]); - } - - Image_PixMap anImage; - aView3d->ToPixMap (anImage, aWindowSizeX, aWindowSizeY); - const Handle(TColStd_HSequenceOfReal) aSeq = GetColorOfPixel (anImage, aPickCoordX, aPickCoordY, aRadius); - cout << "Length = " << aSeq->Length() << endl; - - Image_ColorRGBF aColorPicked = {{ 0.0f, 0.0f, 0.0f }}; - Standard_Boolean isNotEqual = Standard_True; - for (Standard_Integer i = 1; i <= aSeq->Length(); i += 3) - { - aColorPicked.r() = (Standard_ShortReal )aSeq->Value (i + 0); - aColorPicked.g() = (Standard_ShortReal )aSeq->Value (i + 1); - aColorPicked.b() = (Standard_ShortReal )aSeq->Value (i + 2); - - if (theArgsNb == 3 || - ((Abs (aColorPicked.r() - aColorInput.r()) <= Precision::Confusion()) - && (Abs (aColorPicked.g() - aColorInput.g()) <= Precision::Confusion()) - && (Abs (aColorPicked.b() - aColorInput.b()) <= Precision::Confusion()))) - { - isNotEqual = Standard_False; - break; - } - } - - theDi << "RED : " << aColorPicked.r() << " " - << "GREEN : " << aColorPicked.g() << " " - << "BLUE : " << aColorPicked.b() << "\n"; - - if (theArgsNb == 6) - { - theDi << "User color: \n" - << "RED : " << aColorInput.r() << " " - << "GREEN : " << aColorInput.g() << " " - << "BLUE : " << aColorInput.b() << "\n"; - } - - if (isNotEqual) - { - theDi << "Faulty : colors are not equal.\n"; - return 1; // TCL_ERROR - } - return 0; + if (theArgsNb != 3 && theArgsNb != 6) + { + theDi << "Usage : " << theArgs[0] << " coordinate_X coordinate_Y [color_R color_G color_B]" << "\n"; + return 1; // TCL_ERROR + } + + Handle(V3d_View) aView3d = ViewerTest::CurrentView(); + if (aView3d.IsNull()) + { + theDi << "You must initialize AISViewer before this command.\n"; + return 1; // TCL_ERROR + } + + const Handle(Aspect_Window) anAISWindow = aView3d->Window(); + Standard_Integer aWindowSizeX = 0; + Standard_Integer aWindowSizeY = 0; + anAISWindow->Size (aWindowSizeX, aWindowSizeY); + + Standard_Integer anArgIter = 1; + const Standard_Integer aPickCoordX = atoi (theArgs[anArgIter++]); + const Standard_Integer aPickCoordY = atoi (theArgs[anArgIter++]); + const Standard_Integer aRadius = (theArgsNb == 3) ? 0 : 1; + + Image_ColorRGBF aColorInput = {{ 0.0f, 0.0f, 0.0f }}; + if (theArgsNb == 6) + { + aColorInput.r() = (Standard_ShortReal )atof (theArgs[anArgIter++]); + aColorInput.g() = (Standard_ShortReal )atof (theArgs[anArgIter++]); + aColorInput.b() = (Standard_ShortReal )atof (theArgs[anArgIter++]); + } + + Image_PixMap anImage; + aView3d->ToPixMap (anImage, aWindowSizeX, aWindowSizeY); + const Handle(TColStd_HSequenceOfReal) aSeq = GetColorOfPixel (anImage, aPickCoordX, aPickCoordY, aRadius); + cout << "Length = " << aSeq->Length() << endl; + + Image_ColorRGBF aColorPicked = {{ 0.0f, 0.0f, 0.0f }}; + Standard_Boolean isNotEqual = Standard_True; + for (Standard_Integer i = 1; i <= aSeq->Length(); i += 3) + { + aColorPicked.r() = (Standard_ShortReal )aSeq->Value (i + 0); + aColorPicked.g() = (Standard_ShortReal )aSeq->Value (i + 1); + aColorPicked.b() = (Standard_ShortReal )aSeq->Value (i + 2); + + if (theArgsNb == 3 || + ((Abs (aColorPicked.r() - aColorInput.r()) <= Precision::Confusion()) + && (Abs (aColorPicked.g() - aColorInput.g()) <= Precision::Confusion()) + && (Abs (aColorPicked.b() - aColorInput.b()) <= Precision::Confusion()))) + { + isNotEqual = Standard_False; + break; + } + } + + theDi << "RED : " << aColorPicked.r() << " " + << "GREEN : " << aColorPicked.g() << " " + << "BLUE : " << aColorPicked.b() << "\n"; + + if (theArgsNb == 6) + { + theDi << "User color: \n" + << "RED : " << aColorInput.r() << " " + << "GREEN : " << aColorInput.g() << " " + << "BLUE : " << aColorInput.b() << "\n"; + } + + if (isNotEqual) + { + theDi << "Faulty : colors are not equal.\n"; + return 1; // TCL_ERROR + } + return 0; } #if ! defined(WNT) @@ -435,26 +431,26 @@ Standard_EXPORT int ViewerMainLoop2d (Standard_Integer argc, const char ** argv) static Standard_Integer QAAISGetMousePoint (Draw_Interpretor& di, Standard_Integer argc, const char ** argv) { - if ( argc != 1 ) { - di << "Usage : " << argv[0] << "\n"; - return 1; - } - Handle (V3d_View) QAAISView = ViewerTest::CurrentView (); - if ( QAAISView.IsNull () ) { - di << "You must initialize AISViewer before this command." << "\n"; - return 1; - } - Standard_Integer QAAISMouseCoordinateX = 0; - Standard_Integer QAAISMouseCoordinateY = 0; - Standard_Integer argccc = 5; - const char *bufff[] = { "A", "B", "C", "D", "E" }; - const char **argvvv = (const char **) bufff; - while ( ViewerMainLoop (argccc, argvvv) ) { - ViewerTest::GetMousePosition (QAAISMouseCoordinateX, QAAISMouseCoordinateY); - } - ViewerTest::GetMousePosition (QAAISMouseCoordinateX, QAAISMouseCoordinateY); - di << "X-coordinate: " << QAAISMouseCoordinateX << "; Y-coordinate: " << QAAISMouseCoordinateY << "\n"; - return 0; + if ( argc != 1 ) { + di << "Usage : " << argv[0] << "\n"; + return 1; + } + Handle (V3d_View) QAAISView = ViewerTest::CurrentView (); + if ( QAAISView.IsNull () ) { + di << "You must initialize AISViewer before this command." << "\n"; + return 1; + } + Standard_Integer QAAISMouseCoordinateX = 0; + Standard_Integer QAAISMouseCoordinateY = 0; + Standard_Integer argccc = 5; + const char *bufff[] = { "A", "B", "C", "D", "E" }; + const char **argvvv = (const char **) bufff; + while ( ViewerMainLoop (argccc, argvvv) ) { + ViewerTest::GetMousePosition (QAAISMouseCoordinateX, QAAISMouseCoordinateY); + } + ViewerTest::GetMousePosition (QAAISMouseCoordinateX, QAAISMouseCoordinateY); + di << "X-coordinate: " << QAAISMouseCoordinateX << "; Y-coordinate: " << QAAISMouseCoordinateY << "\n"; + return 0; } static Standard_Integer QAAISGetColorCoord (Draw_Interpretor& di, Standard_Integer argc, const char ** argv) @@ -479,16 +475,6 @@ static Standard_Integer QAAISGetColorCoord (Draw_Interpretor& di, Standard_Integ is3d = 1; } - if(argc == 2 && !strcmp(argv[1],"2d")) { - Handle(V2d_View) V = Viewer2dTest::CurrentView(); - if (V.IsNull()) { - di << "You must initialize AIS 2D Viewer before this command." << "\n"; - return 1; - } - QAAISWindow = Handle(Xw_Window)::DownCast (V->Driver()->Window()); - is3d = 0; - } - Standard_Integer QAAIS_WindowSize_X = 0; Standard_Integer QAAIS_WindowSize_Y = 0; QAAISWindow->Size(QAAIS_WindowSize_X, QAAIS_WindowSize_Y); @@ -529,11 +515,6 @@ static Standard_Integer QAAISGetColorCoord (Draw_Interpretor& di, Standard_Integ Handle (V3d_View) QAAIS_MainView = ViewerTest::CurrentView(); QAAIS_MainView->ToPixMap (anImage, QAAIS_WindowSize_X, QAAIS_WindowSize_Y); } - else - { - Viewer2dTest::GetMousePosition (QAAIS_MousePoint_X, QAAIS_MousePoint_Y); - QAAISWindow->ToPixMap (anImage); - } aSeq = GetColorOfPixel (anImage, QAAIS_MousePoint_X, QAAIS_MousePoint_Y, 0); QAAIS_ColorRED = aSeq->Value(1); @@ -556,349 +537,6 @@ static Standard_Integer QAAISGetColorCoord (Draw_Interpretor& di, Standard_Integ //============================================================================== // VIEWER GLOBALs //============================================================================== -#if ! defined(WNT) -extern int V2dPickGrid (Draw_Interpretor& , Standard_Integer argc, const char ** argv); -#else -Standard_EXPORT int V2dPickGrid (Draw_Interpretor& , Standard_Integer argc, const char ** argv); -#endif -//============================================================================== -//function : V2dSetHighlightMode -//purpose : QAv2dSetHighlightMode mode -//============================================================================== -static int V2dSetHighlightMode (Draw_Interpretor& di, Standard_Integer argc, const char ** argv) -{ - if (argc != 2) - { - di << "Usage: QAv2dSetHighlightMode mode" << "\n"; - return 1; - } - - Viewer2dTest::StandardModeActivation(atoi(argv[1])); - return 0; -} - -//#ifndef WNT -//============================================================================== -//function : QAAISGetPixelColor2d -//purpose : QAAISGetPixelColor2d coord_X coord_Y Red Green Blue -//============================================================================== - -static int QAAISGetPixelColor2d (Draw_Interpretor& di, Standard_Integer argc, const char ** argv) -{ - if (argc != 6 && argc != 3) - { - di << "Args: coord_X coord_Y [Red Green Blue]" << "\n"; - return 1; - } - - Handle(V2d_View) V = Viewer2dTest::CurrentView(); - if (V.IsNull()) - { - di << "You must initialize AIS 2D Viewer before this command." << "\n"; - return 1; - } - - // Get Color - #if (defined(_WIN32) || defined(__WIN32__)) - Handle(WNT_Window) QAAISWindow = Handle(WNT_Window)::DownCast (V->Driver()->Window()); - #else - Handle(Xw_Window) QAAISWindow = Handle(Xw_Window )::DownCast (V->Driver()->Window()); - #endif - - Standard_ShortReal aCoordinateX = atoi(argv[1]); - Standard_ShortReal aCoordinateY = atoi(argv[2]); - - // Get Color - Standard_ShortReal aColorRED_V = 0; - Standard_ShortReal aColorGRN_V = 0; - Standard_ShortReal aColorBLU_V = 0; - - if ( argc == 6 ) { - aColorRED_V = atof (argv [3]); - aColorGRN_V = atof (argv [4]); - aColorBLU_V = atof (argv [5]); - - di << "Begin aColorRED_User = " << aColorRED_V << "\n"; - di << "Begin aColorGRN_User = " << aColorGRN_V << "\n"; - di << "Begin aColorBLU_User = " << aColorBLU_V << "\n"; - } - - Standard_Integer aRadius = 1; - if ( argc == 3 ) { - aRadius=0; - } - - Image_PixMap anImage; - QAAISWindow->ToPixMap (anImage); - Handle(TColStd_HSequenceOfReal) aSeq = GetColorOfPixel (anImage, aCoordinateX, aCoordinateY, aRadius); - - Standard_Boolean IsNotEqual = Standard_True; - Standard_Integer i; - for(i=1; i<=aSeq->Length();i+=3) { - // mkv 29.04.03 - Standard_ShortReal aColorRED_R = (((Standard_ShortReal) ((Standard_Integer) (aSeq->Value(i+0) * 1000000))) / 1000000.); - Standard_ShortReal aColorGRN_R = (((Standard_ShortReal) ((Standard_Integer) (aSeq->Value(i+1) * 1000000))) / 1000000.); - Standard_ShortReal aColorBLU_R = (((Standard_ShortReal) ((Standard_Integer) (aSeq->Value(i+2) * 1000000))) / 1000000.); - // mkv 29.04.03 - - if ( argc == 3 ) { - di << "RED : " << aColorRED_R << " GREEN : " << aColorGRN_R << " BLUE : " << aColorBLU_R << "\n"; - IsNotEqual = Standard_False; - break; - } - - if ( aColorRED_R == aColorRED_V - && aColorGRN_R == aColorGRN_V - && aColorBLU_R == aColorBLU_V - ) { - IsNotEqual = Standard_False; - break; - } - } - if (IsNotEqual) { - di << "Faulty : colors are not equal." << "\n"; - return 1; - } - return 0; -} -//#endif // !WNT - -//============================================================================== -//function : QAMoveTo2d -//purpose : QAMoveTo2d x y -//============================================================================== -static int QAMoveTo2d (Draw_Interpretor& di, int argc, const char ** argv) -{ - if (argc != 3) - { - di << "Usage : " << argv[0] << " x y" << "\n"; - return -1; - } - - Handle(AIS2D_InteractiveContext) myAIScontext = Viewer2dTest::GetAIS2DContext(); - if (myAIScontext.IsNull()) - { - di << "use 'v2dinit' command before " << argv[0] << "\n"; - return -1; - } - Viewer2dTest::CurrentEventManager()->MoveTo - (atoi(argv[1]), atoi(argv[2]), Viewer2dTest::CurrentView()); - return 0; -} - -//============================================================================== -//function : QASelect2d -//purpose : QASelect2d x y -//============================================================================== -static int QASelect2d (Draw_Interpretor& di, int argc, const char ** argv) -{ - if (argc != 3) - { - di << "Usage : " << argv[0] << " x y" << "\n"; - return -1; - } - - Handle(AIS2D_InteractiveContext) myAIScontext = Viewer2dTest::GetAIS2DContext(); - if (myAIScontext.IsNull()) - { - di << "use 'v2dinit' command before " << argv[0] << "\n"; - return -1; - } - Viewer2dTest::CurrentEventManager()->MoveTo - (atoi(argv[1]), atoi(argv[2]), Viewer2dTest::CurrentView()); - Viewer2dTest::CurrentEventManager()->Select(); - return 0; -} - -//============================================================================== -//function : QAShiftSelect2d -//purpose : QAShiftSelect2d x y -//============================================================================== -static int QAShiftSelect2d (Draw_Interpretor& di, int argc, const char ** argv) -{ - if (argc != 3) - { - di << "Usage : " << argv[0] << " x y" << "\n"; - return -1; - } - - Handle(AIS2D_InteractiveContext) myAIScontext = Viewer2dTest::GetAIS2DContext(); - if (myAIScontext.IsNull()) - { - di << "use 'v2dinit' command before " << argv[0] << "\n"; - return -1; - } - Viewer2dTest::CurrentEventManager()->MoveTo - (atoi(argv[1]), atoi(argv[2]), Viewer2dTest::CurrentView()); - Viewer2dTest::CurrentEventManager()->ShiftSelect(); - return 0; -} - -//============================================================================== -//function : V2dZoom -//purpose : QAv2dzoom zoom_factor -//============================================================================== -static int V2dZoom (Draw_Interpretor& di, int argc, const char ** argv) -{ - if (argc != 2) - { - di << "Usage : " << argv[0] << " zoom_factor" << "\n"; - return -1; - } - - Handle(AIS2D_InteractiveContext) myAIScontext = Viewer2dTest::GetAIS2DContext(); - if (myAIScontext.IsNull()) - { - di << "use 'v2dinit' command before " << argv[0] << "\n"; - return -1; - } - Viewer2dTest::CurrentView()->Zoom(atof(argv[1])); - return 0; -} - -//============================================================================== -//function : V2dPan -//purpose : QAv2dpan dx dy -//============================================================================== -static int V2dPan (Draw_Interpretor& di, int argc, const char ** argv) -{ - if (argc != 3) - { - di << "Usage : " << argv[0] << " dx dy" << "\n"; - return -1; - } - - Handle(AIS2D_InteractiveContext) myAIScontext = Viewer2dTest::GetAIS2DContext(); - if (myAIScontext.IsNull()) - { - di << "use 'v2dinit' command before " << argv[0] << "\n"; - return -1; - } - Viewer2dTest::CurrentView()->Pan(atoi(argv[1]), atoi(argv[2])); - return 0; -} - -//============================================================================== -//function : V2dGetViewCharac -//purpose : v2dGetViewCharac -//============================================================================== -static int V2dGetViewCharac (Draw_Interpretor& di, int si, const char ** /*sc*/) -{ - if (si != 1) - { - di << "Use - v2dGetViewCharac" << "\n"; - return 1; - } - - Handle(V2d_View) V = Viewer2dTest::CurrentView(); - if (V.IsNull()) - { - di << "You must initialize AIS 2D Viewer before this command." << "\n"; - return 1; - } - -// Quantity_Factor aViewScale = V->Scale(); - - Standard_Real aCenterCoordX = 0.0; - Standard_Real aCenterCoordY = 0.0; - V->Center(aCenterCoordX, aCenterCoordY); - - Standard_Real aViewProjX = 0.0; - Standard_Real aViewProjY = 0.0; - Standard_Real aViewProjZ = 0.0; -// V->Proj(aViewProjX, aViewProjY, aViewProjZ); - - Standard_Real aViewUpX = 0.0; - Standard_Real aViewUpY = 0.0; - Standard_Real aViewUpZ = 0.0; -// V->Up(aViewUpX, aViewUpY, aViewUpZ); - - Standard_Real aViewAtX = 0.0; - Standard_Real aViewAtY = 0.0; - Standard_Real aViewAtZ = 0.0; -// V->At(aViewAtX, aViewAtY, aViewAtZ); - -// cout << "Scale of current view: " << aViewScale << endl; -// cout << "Center on X : "<< aViewCenterCoordX << "; on Y: " << aViewCenterCoordY << endl; -// cout << "Proj on X : " << aViewProjX << "; on Y: " << aViewProjY << "; on Z: " << aViewProjZ << endl; -// cout << "Up on X : " << aViewUpX << "; on Y: " << aViewUpY << "; on Z: " << aViewUpZ << endl; -// cout << "At on X : " << aViewAtX << "; on Y: " << aViewAtY << "; on Z: " << aViewAtZ << endl; - -// cout << aViewScale << " " << aViewCenterCoordX << " " << aViewCenterCoordY << " "; - di << aViewProjX << " " << aViewProjY << " " << aViewProjZ << " "; - di << aViewUpX << " " << aViewUpY << " " << aViewUpZ << " "; - di << aViewAtX << " " << aViewAtY << " " << aViewAtZ << "\n"; - return 0; -} - -//============================================================================== -//function : V2dSetViewCharac -//purpose : v2dSetViewCharac -//============================================================================== -static int V2dSetViewCharac (Draw_Interpretor& di, int si, const char ** sc) -{ - if (si != 13) - { - di << "Use - v2dSetViewCharac scale center(X Y) proj(X Y Z) up(X Y Z) at(X Y Z)" << "\n"; - return 1; - } - - Handle(V2d_View) V = Viewer2dTest::CurrentView(); - if (V.IsNull()) - { - di << "You must initialize AIS 2D Viewer before this command." << "\n"; - return 1; - } - - Quantity_Factor aViewScale = atof(sc[1]); - - Standard_Real aViewCenterCoordX = atof(sc[2]); - Standard_Real aViewCenterCoordY = atof(sc[3]); - - Standard_Real aViewProjX = atof(sc[4]); - Standard_Real aViewProjY = atof(sc[5]); - Standard_Real aViewProjZ = atof(sc[6]); - - Standard_Real aViewUpX = atof(sc[7]); - Standard_Real aViewUpY = atof(sc[8]); - Standard_Real aViewUpZ = atof(sc[9]); - - Standard_Real aViewAtX = atof(sc[10]); - Standard_Real aViewAtY = atof(sc[11]); - Standard_Real aViewAtZ = atof(sc[12]); - -// V->SetScale(aViewScale); -// V->SetCenter(aViewCenterCoordX, aViewCenterCoordY); -// V->SetAt(aViewAtX, aViewAtY, aViewAtZ); -// V->SetProj(aViewProjX, aViewProjY, aViewProjZ); -// V->SetUp(aViewUpX, aViewUpY, aViewUpZ); -// V->SetProj(aViewProjX, aViewProjY, aViewProjZ); - return 0; -} - -//======================================================================= -//function : QAxwd_2d -//purpose : -//======================================================================= -static int QAxwd_2d (Draw_Interpretor& di, int argc, const char ** argv) -{ - if (argc != 2) - { - di << "Usage : " << argv[0] << " filename" << "\n"; - return -1; - } - - Handle(AIS2D_InteractiveContext) myAIScontext = Viewer2dTest::GetAIS2DContext(); - if (myAIScontext.IsNull()) - { - di << "use 'v2dinit' command before " << argv[0] << "\n"; - return -1; - } - Handle(V2d_View) V = Viewer2dTest::CurrentView(); - V->Dump(argv[1]); - return 0; -} - #ifndef WNT extern Draw_Viewer dout; extern Display* Draw_WindowDisplay; @@ -908,27 +546,6 @@ Standard_IMPORT Draw_Viewer dout; #endif //======================================================================= -//function : QA2dGetIndexes -//purpose : -//======================================================================= -static int QA2dGetIndexes (Draw_Interpretor& di, int /*argc*/, const char ** argv) -{ - Handle(AIS2D_InteractiveContext) myAIScontext = Viewer2dTest::GetAIS2DContext(); - if (myAIScontext.IsNull()) - { - di << "use 'v2dinit' command before " << argv[0] << "\n"; - return -1; - } - Handle(Aspect_WindowDriver) aWindowDriver = Viewer2dTest::CurrentView()->Driver(); - - Standard_Integer aFontMin, aFontMax, aColorMin, aColorMax; - aWindowDriver->FontBoundIndexs(aFontMin, aFontMax); - di << "Available font indexes are " << aFontMin << " - " << aFontMax << "\n"; - aWindowDriver->ColorBoundIndexs(aColorMin, aColorMax); - di << "Available color indexes are " << aColorMin << " - " << aColorMax << "\n"; - return 0; -} - #if ! defined(WNT) extern ViewerTest_DoubleMapOfInteractiveAndName& GetMapOfAIS(); extern Handle(AIS_InteractiveContext)& TheAISContext(); @@ -1006,70 +623,9 @@ static int VTrihedronOrigins(Draw_Interpretor& di, return 0; } -#include -#include -#include -#include -#include -#include - -#if ! defined(WNT) -extern Viewer2dTest_DoubleMapOfInteractiveAndName& GetMapOfAIS2D(); -#else -Standard_EXPORT Viewer2dTest_DoubleMapOfInteractiveAndName& GetMapOfAIS2D(); -#endif - -//======================================================================= -//function : QAv2dcircle -//purpose : -//======================================================================= -static Standard_Integer QAv2dcircle (Draw_Interpretor& di, Standard_Integer argc, const char ** argv) -{ - Handle(AIS2D_InteractiveContext) aContext = Viewer2dTest::GetAIS2DContext(); - if(aContext.IsNull()) { - di << "ERROR: Use 'v2dinit' command before " << argv[0] << "\n"; - return -1; - } - if(argc < 7){ - di<<"Usage : " << argv[0] << " CircleName X Y Radius Alpha Beta [Color_index]\n"; - return -1; - } - Handle(V2d_View) V = Viewer2dTest::CurrentView(); - - TCollection_AsciiString name = argv[1]; - Standard_Real x = atof(argv[2]); - Standard_Real y = atof(argv[3]); - Standard_Real radius = atof(argv[4]); - Standard_Real alpha = atof(argv[5]); - Standard_Real beta = atof(argv[6]); - - if (GetMapOfAIS2D().IsBound2(name)) { - di << "There is already an object with name " << name.ToCString() << "\n"; - return -1; - } - Handle(AIS2D_InteractiveObject) aisobj = new AIS2D_InteractiveObject(); - aisobj->SetView(V->View()); - Handle(Graphic2d_Circle) circle = new Graphic2d_Circle(aisobj,x,y,radius,alpha,beta); - if(argc > 7){ - Standard_Integer color_index = atoi(argv[7]); - circle->SetTypeOfPolygonFilling(Graphic2d_TOPF_FILLED); - circle->SetInteriorColorIndex(color_index); - } - GetMapOfAIS2D().Bind(aisobj, name); - aisobj->Display(); - V->Viewer()->Update(); - return 0; -} - #include #include -#ifndef WNT -extern Draw_Viewer dout; -#else -Standard_IMPORT Draw_Viewer dout; -#endif - static Standard_Integer ViewId(const Standard_CString a) { Standard_Integer id = atoi(a); @@ -1130,66 +686,6 @@ static Standard_Integer QArename(Draw_Interpretor& di, Standard_Integer n, const //} //#endif -static int QASelect2dRectangle (Draw_Interpretor& di, int argc, const char ** argv) -{ - if (argc != 5) - { - di << "Usage : " << argv[0] << " x1 y1 x2 y2" << "\n"; - return -1; - } - - Handle(AIS2D_InteractiveContext) myAIScontext = Viewer2dTest::GetAIS2DContext(); - if (myAIScontext.IsNull()) - { - di << "use 'v2dinit' command before " << argv[0] << "\n"; - return -1; - } - - Standard_Integer x1 = atoi(argv[1]); - Standard_Integer y1 = atoi(argv[2]); - Standard_Integer x2 = atoi(argv[3]); - Standard_Integer y2 = atoi(argv[4]); - - Handle(Viewer2dTest_EventManager) aCurrentEventManager = Viewer2dTest::CurrentEventManager(); - Handle(V2d_View) aCurrentView = Viewer2dTest::CurrentView(); - - aCurrentEventManager->MoveTo(x1,y1,aCurrentView); - aCurrentEventManager->Select(x1,y1,x2,y2,aCurrentView); - aCurrentEventManager->MoveTo(x2,y2,aCurrentView); - - return 0; -} - -static int QAShiftSelect2dRectangle (Draw_Interpretor& di, int argc, const char ** argv) -{ - if (argc != 5) - { - di << "Usage : " << argv[0] << " x1 y1 x2 y2" << "\n"; - return -1; - } - - Handle(AIS2D_InteractiveContext) myAIScontext = Viewer2dTest::GetAIS2DContext(); - if (myAIScontext.IsNull()) - { - di << "use 'v2dinit' command before " << argv[0] << "\n"; - return -1; - } - - Standard_Integer x1 = atoi(argv[1]); - Standard_Integer y1 = atoi(argv[2]); - Standard_Integer x2 = atoi(argv[3]); - Standard_Integer y2 = atoi(argv[4]); - - Handle(Viewer2dTest_EventManager) aCurrentEventManager = Viewer2dTest::CurrentEventManager(); - Handle(V2d_View) aCurrentView = Viewer2dTest::CurrentView(); - - aCurrentEventManager->MoveTo(x1,y1,aCurrentView); - aCurrentEventManager->ShiftSelect(x1,y1,x2,y2,aCurrentView); - aCurrentEventManager->MoveTo(x2,y2,aCurrentView); - - return 0; -} - void QADraw::CommonCommands(Draw_Interpretor& theCommands) { ios::sync_with_stdio(); @@ -1208,52 +704,12 @@ void QADraw::CommonCommands(Draw_Interpretor& theCommands) theCommands.Add("QAGetPixelColor", "QAGetPixelColor coordinate_X coordinate_Y [color_R color_G color_B]", __FILE__,QAAISGetPixelColor, group); theCommands.Add("QAGetMousePoint", "QAGetMousePoint", __FILE__,QAAISGetMousePoint, group); theCommands.Add("QAGetColorCoord", "QAGetColorCoord [3d|2d]", __FILE__,QAAISGetColorCoord, group); -//#ifndef WNT - theCommands.Add("QAAISGetPixelColor2d", - "QAAISGetPixelColor2d coord_X coord_Y [Red Green Blue] : Check a color of pixel", - __FILE__, QAAISGetPixelColor2d, group); -//#endif - - theCommands.Add("v2dgetgrid", - "v2dgetgrid coord_X coord_Y [grid_X grid_Y] : Get/print coordinates of a grid point near to (coord_X, coord_Y)", - __FILE__, V2dPickGrid, group); - - theCommands.Add("QAv2dzoom", - "QAv2dzoom zoom_factor : Set Scale Factor", - __FILE__, V2dZoom, group); - - theCommands.Add("QAv2dpan", - "QAv2dpan dx dy : script analog of Ctrl+MB2", - __FILE__, V2dPan, group); - -// theCommands.Add("QAGetViewCharac2d", -// "QAGetViewCharac2d - dumps viewer characteristics", -// V2dGetViewCharac, group); - -// theCommands.Add("QASetViewCharac2d", -// "QASetViewCharac2d scale center(X Y) proj(X Y Z) up(X Y Z) at(X Y Z)", -// V2dSetViewCharac, group); - - theCommands.Add("QAMoveTo2d", "QAMoveTo2d x y", __FILE__, QAMoveTo2d, group); - theCommands.Add("QASelect2d", "QASelect2d x y", __FILE__, QASelect2d, group); - theCommands.Add("QAShiftSelect2d", "QAShiftSelect2d x y", __FILE__, QAShiftSelect2d, group); - theCommands.Add("QAv2dSetHighlightMode", - "QAv2dSetHighlightMode mode", __FILE__, V2dSetHighlightMode, group); - theCommands.Add("QAxwd_2d", "QAxwd_2d filename", __FILE__, QAxwd_2d, group); - theCommands.Add("QA2dGetIndexes", "QA2dGetIndexes", __FILE__, QA2dGetIndexes, group); - theCommands.Add("vtri_orig", "vtri_orig : vtri_orig trihedron_name - draws axis origin lines", __FILE__,VTrihedronOrigins,group); - theCommands.Add("QAv2dcircle", "QAv2dcircle CircleName X Y Radius Alpha Beta [Color_index]", __FILE__, QAv2dcircle, group); // adding commands "rename" leads to the fact that QA commands doesn't work properly OCC23410, use function "renamevar" // theCommands.Add("rename","rename name1 toname1 name2 toname2 ...",__FILE__,QArename,group); -//#if defined(V2D) -// theCommands.Add ("QANbSelected2d", "QANbSelected2d", __FILE__, QANbSelected2d, group); -//#endif - theCommands.Add("QASelect2dRectangle","QASelect2dRectangle x1 y1 x2 y2",__FILE__,QASelect2dRectangle,group); - theCommands.Add("QAShiftSelect2dRectangle","QAShiftSelect2dRectangle x1 y1 x2 y2",__FILE__,QAShiftSelect2dRectangle,group); } /* extern "C" int Tkqadraw_Init(Tcl_Interp *); diff --git a/src/QADraw/QADraw_Additional.cxx b/src/QADraw/QADraw_Additional.cxx index 87d0aa1051..9a0b37e1ee 100755 --- a/src/QADraw/QADraw_Additional.cxx +++ b/src/QADraw/QADraw_Additional.cxx @@ -27,10 +27,6 @@ //#else #include //#endif - -#if defined(WOKC40) -#include -#endif #include void QADraw::AdditionalCommands(Draw_Interpretor& theCommands) @@ -43,10 +39,6 @@ void QADraw::AdditionalCommands(Draw_Interpretor& theCommands) //#else QANewDBRepNaming::AllCommands(theCommands); //#endif - -#if defined(WOKC40) - QAViewer2dTest::Commands(theCommands); -#endif QANCollection::Commands(theCommands); return; diff --git a/src/QAViewer2dTest/FILES b/src/QAViewer2dTest/FILES deleted file mode 100755 index ff83f419a4..0000000000 --- a/src/QAViewer2dTest/FILES +++ /dev/null @@ -1,5 +0,0 @@ -QAViewer2dTest_CMPLRS.edl -QAViewer2dTest_GeneralCommands.cxx -QAViewer2dTest_ViewerCommands.cxx -QAViewer2dTest_DisplayCommands.cxx -QAViewer2dTest_ObjectCommands.cxx diff --git a/src/QAViewer2dTest/QAViewer2dTest.cdl b/src/QAViewer2dTest/QAViewer2dTest.cdl deleted file mode 100755 index f37c851a0c..0000000000 --- a/src/QAViewer2dTest/QAViewer2dTest.cdl +++ /dev/null @@ -1,45 +0,0 @@ --- Copyright (c) 1999-2012 OPEN CASCADE SAS --- --- The content of this file is subject to the Open CASCADE Technology Public --- License Version 6.5 (the "License"). You may not use the content of this file --- except in compliance with the License. Please obtain a copy of the License --- at http://www.opencascade.org and read it completely before using this file. --- --- The Initial Developer of the Original Code is Open CASCADE S.A.S., having its --- main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. --- --- The Original Code and all software distributed under the License is --- distributed on an "AS IS" basis, without warranty of any kind, and the --- Initial Developer hereby disclaims all such warranties, including without --- limitation, any warranties of merchantability, fitness for a particular --- purpose or non-infringement. Please see the License for the specific terms --- and conditions governing the rights and limitations under the License. - - -package QAViewer2dTest - - ---Purpose: - -uses - Draw, - TCollection, - TColStd, - TopAbs, - TopTools, - TopoDS, - V2d, - AIS, - Graphic2d - -is - - ---Category: Draw Commands - - Commands (theCommands : in out Interpretor from Draw); - MyCommands (theCommands : in out Interpretor from Draw); -- My Own Com-s - GeneralCommands (theCommands :in out Interpretor from Draw); - ViewerCommands (theCommands :in out Interpretor from Draw); - DisplayCommands (theCommands : in out Interpretor from Draw); - ObjectCommands (theCommands :in out Interpretor from Draw); - -end; diff --git a/src/QAViewer2dTest/QAViewer2dTest.cxx b/src/QAViewer2dTest/QAViewer2dTest.cxx deleted file mode 100755 index 151e7d11d7..0000000000 --- a/src/QAViewer2dTest/QAViewer2dTest.cxx +++ /dev/null @@ -1,595 +0,0 @@ -// Copyright (c) 1999-2012 OPEN CASCADE SAS -// -// The content of this file is subject to the Open CASCADE Technology Public -// License Version 6.5 (the "License"). You may not use the content of this file -// except in compliance with the License. Please obtain a copy of the License -// at http://www.opencascade.org and read it completely before using this file. -// -// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its -// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. -// -// The Original Code and all software distributed under the License is -// distributed on an "AS IS" basis, without warranty of any kind, and the -// Initial Developer hereby disclaims all such warranties, including without -// limitation, any warranties of merchantability, fitness for a particular -// purpose or non-infringement. Please see the License for the specific terms -// and conditions governing the rights and limitations under the License. - -#if defined(WOKC40) - -#include -#include -#include -#include - -#include - -#include -#include -#include - -#include -#include -#include - -#include - -#include -#include -#include - -extern int ViewerMainLoop2d (Standard_Integer argc, char** argv); - -TopoDS_Shape GetShapeFromName2d (char* name); - -static TColStd_ListOfTransient theEventMgrs2d; - -//============================================================================== -// VIEWER OBJECT MANAGEMENT GLOBAL VARIABLES -//============================================================================== -QAViewer2dTest_DoubleMapOfInteractiveAndName& GetMapOfAIS2D() -{ - static QAViewer2dTest_DoubleMapOfInteractiveAndName TheMap; - return TheMap; -} - -static void VwrTst_InitEventMgr2d (const Handle(AIS2D_InteractiveContext)& Ctx) -{ - theEventMgrs2d.Clear(); - theEventMgrs2d.Prepend(new QAViewer2dTest_EventManager(Ctx)); -} - -static Handle(V2d_View)& a2DView() -{ - static Handle(V2d_View) Viou; - return Viou; -} - -Handle(AIS2D_InteractiveContext)& TheAIS2DContext() -{ - static Handle(AIS2D_InteractiveContext) aContext; - return aContext; -} - -Handle(V2d_View) QAViewer2dTest::CurrentView() -{ - return a2DView(); -} - -void QAViewer2dTest::CurrentView (const Handle(V2d_View)& V) -{ - a2DView() = V; -} - -Handle(AIS2D_InteractiveContext) QAViewer2dTest::GetAIS2DContext() -{ - return TheAIS2DContext(); -} - -Handle(V2d_Viewer) QAViewer2dTest::GetViewerFromContext() -{ - return TheAIS2DContext()->CurrentViewer(); -} - -Handle(V2d_Viewer) QAViewer2dTest::GetCollectorFromContext() -{ - return TheAIS2DContext()->CurrentViewer(); -} - -void QAViewer2dTest::SetAIS2DContext (const Handle(AIS2D_InteractiveContext)& aCtx) -{ - TheAIS2DContext() = aCtx; - QAViewer2dTest::ResetEventManager(); -} - -void QAViewer2dTest::SetEventManager (const Handle(QAViewer2dTest_EventManager)& EM) -{ - theEventMgrs2d.Prepend(EM); -} - -void QAViewer2dTest::UnsetEventManager() -{ - theEventMgrs2d.RemoveFirst(); -} - -void QAViewer2dTest::ResetEventManager() -{ - VwrTst_InitEventMgr2d(QAViewer2dTest::GetAIS2DContext()); -} - -//============================================================================== -//function : CurrentEventManager -//purpose : -//============================================================================== -Handle(QAViewer2dTest_EventManager) QAViewer2dTest::CurrentEventManager() -{ - Handle(QAViewer2dTest_EventManager) EM; - if(theEventMgrs2d.IsEmpty()) return EM; - Handle(Standard_Transient) Tr = theEventMgrs2d.First(); - EM = *((Handle(QAViewer2dTest_EventManager)*)&Tr); - return EM; -} - -//============================================================================== -//function : Clear -//purpose : Remove all the object from the viewer -//============================================================================== -void QAViewer2dTest::Clear() -{ - if (!QAViewer2dTest::CurrentView().IsNull()) - { - TheAIS2DContext()->CloseLocalContext(); - QAViewer2dTest_DoubleMapIteratorOfDoubleMapOfInteractiveAndName it (GetMapOfAIS2D()); - while (it.More()) - { - cout << "Remove " << it.Key2() << endl; -// TheAIS2DContext()->Remove(it.Key1(), Standard_False); - TheAIS2DContext()->Erase(it.Key1(), Standard_False, Standard_False); - it.Next(); - } - TheAIS2DContext()->UpdateCurrentViewer(); - GetMapOfAIS2D().Clear(); - } -} - -//============================================================================== -//function : StandardModeActivation -//purpose : Activate a selection mode, vertex, edge, wire ..., in a local -// Context -//============================================================================== -void QAViewer2dTest::StandardModeActivation (const Standard_Integer mode) -{ - Handle(AIS2D_InteractiveContext) aContext = QAViewer2dTest::GetAIS2DContext(); - aContext->SetPickMode(Graphic2d_PM_INTERSECT); - - char *cmode = "?????????"; - - switch ((AIS2D_TypeOfDetection)mode) - { - case AIS2D_TOD_OBJECT: cmode = "OBJECT"; break; - case AIS2D_TOD_PRIMITIVE: cmode = "PRIMITIVE"; break; - case AIS2D_TOD_ELEMENT: cmode = "ELEMENT"; break; - case AIS2D_TOD_VERTEX: cmode = "VERTEX"; break; - case AIS2D_TOD_NONE: cmode = "NONE"; break; - } - - // Activate - QAViewer2dTest_DoubleMapIteratorOfDoubleMapOfInteractiveAndName it (GetMapOfAIS2D()); - while (it.More()) - { - Handle(AIS2D_InteractiveObject) ashape = it.Key1(); - ashape->SetContext(aContext); -// ashape->SetSelectionMode(mode); - ashape->SetHighlightMode((AIS2D_TypeOfDetection)mode); - it.Next(); - } -// aContext->ActivateStandardMode(AIS2D_ProjShape::SelectionType(mode)); - cout << "Mode " << cmode << " ON" << endl; -} - -//======================================================================= -//function : PickObjects -//purpose : -//======================================================================= -Standard_Boolean QAViewer2dTest::PickObjects (Handle(TColStd_HArray1OfTransient)& arr, - const AIS_KindOfInteractive TheType, - const Standard_Integer /*TheSignature*/, - const Standard_Integer MaxPick) -{ - Handle(AIS2D_InteractiveObject) IO; - Standard_Integer curindex = (TheType == AIS_KOI_None) ? 0 : TheAIS2DContext()->OpenLocalContext(); - - // step 1: prepare the data - if (curindex != 0) - { -// Handle(AIS2D_SignatureFilter) F1 = new AIS2D_SignatureFilter(TheType,TheSignature); -// TheAIS2DContext()->AddFilter(F1); - } - - // step 2 : wait for the selection... -// Standard_Boolean IsGood (Standard_False); -// Standard_Integer NbPick(0); - Standard_Boolean NbPickGood (0), NbToReach (arr->Length()); - Standard_Integer NbPickFail(0); - Standard_Integer argccc = 5; - char *bufff[] = { "A", "B", "C","D", "E" }; - char **argvvv = (char **) bufff; - - while (NbPickGood < NbToReach && NbPickFail <= MaxPick) - { - while (ViewerMainLoop2d(argccc,argvvv)) {} -/* Standard_Integer NbStored = TheAIS2DContext()->NbSelected(); - if((unsigned int ) NbStored != NbPickGood) - NbPickGood= NbStored; - else - NbPickFail++; - cout<<"NbPicked = "<= NbToReach) return Standard_False; - - /* - Standard_Integer i(0); - for(TheAIS2DContext()->InitSelected(); - TheAIS2DContext()->MoreSelected(); - TheAIS2DContext()->NextSelected()){ - i++; - Handle(AIS2D_InteractiveObject) IO = TheAIS2DContext()->SelectedInteractive(); - arr->SetValue(i,IO); - }*/ - - if (curindex > 0) TheAIS2DContext()->CloseLocalContext(curindex); - return Standard_True; -} - -//======================================================================= -//function : PickObject -//purpose : -//======================================================================= -/*Handle(AIS2D_InteractiveObject) QAViewer2dTest::PickObject - (const AIS2D_KindOfInteractive TheType, - const Standard_Integer TheSignature, - const Standard_Integer MaxPick) -{ - Handle(AIS2D_InteractiveObject) IO; - Standard_Integer curindex = (TheType == AIS2D_KOI_None) ? 0 : TheAIS2DContext()->OpenLocalContext(); - - // step 1: prepare the data - - if(curindex !=0){ - Handle(AIS2D_SignatureFilter) F1 = new AIS2D_SignatureFilter(TheType,TheSignature); - TheAIS2DContext()->AddFilter(F1); - } - - // step 2 : wait for the selection... - Standard_Boolean IsGood (Standard_False); - Standard_Integer NbPick(0); - Standard_Integer argccc = 5; - char *bufff[] = { "VPick", "X", "VPickY","VPickZ", "VPickShape" }; - char **argvvv = bufff; - - - while(!IsGood && NbPick<= MaxPick){ - while(ViewerMainLoop2d(argccc,argvvv)){} - IsGood = (TheAIS2DContext()->NbSelected()>0) ; - NbPick++; - cout<<"Nb Pick :"<InitSelected(); - IO = TheAIS2DContext()->SelectedInteractive(); - } - - if(curindex!=0) - TheAIS2DContext()->CloseLocalContext(curindex); - return IO; -}*/ - -//======================================================================= -//function : PickShape -//purpose : First Activate the rightmode + Put Filters to be able to -// pick objets that are of type ... -//======================================================================= -TopoDS_Shape QAViewer2dTest::PickShape (const TopAbs_ShapeEnum /*TheType*/, - const Standard_Integer MaxPick) -{ - // step 1: prepare the data - Standard_Integer curindex = TheAIS2DContext()->OpenLocalContext(); - TopoDS_Shape result; - -/* if(TheType==TopAbs_SHAPE) - { - Handle(AIS2D_TypeFilter) F1 = new AIS2D_TypeFilter(AIS2D_KOI_Shape); - TheAIS2DContext()->AddFilter(F1); - } - else - { - Handle(StdSelect_ShapeTypeFilter) TF = new StdSelect_ShapeTypeFilter(TheType); - TheAIS2DContext()->AddFilter(TF); - TheAIS2DContext()->ActivateStandardMode(TheType); - }*/ - - // step 2 : wait for the selection... - Standard_Boolean NoShape (Standard_True); - Standard_Integer NbPick (0); - Standard_Integer argccc = 5; - char *bufff[] = { "VPick", "X", "VPickY","VPickZ", "VPickShape" }; - char **argvvv = (char **) bufff; - - while (NoShape && NbPick <= MaxPick) - { - while (ViewerMainLoop2d(argccc,argvvv)) {} -// NoShape = (TheAIS2DContext()->NbSelected() == 0); - NbPick++; - cout << "Nb Pick :" << NbPick << endl; - } - - // step3 get result. - if (!NoShape) - { -/* TheAIS2DContext()->InitSelected(); - if (TheAIS2DContext()->HasSelectedShape()) - result = TheAIS2DContext()->SelectedShape(); - else - { - Handle(AIS2D_InteractiveObject) IO = TheAIS2DContext()->SelectedInteractive(); - result = (*((Handle(AIS2D_ProjShape)*) &IO))->Shape(); - }*/ - } - - if (curindex > 0) TheAIS2DContext()->CloseLocalContext(curindex); - return result; -} - -//======================================================================= -//function : PickShapes -//purpose : -//======================================================================= -Standard_Boolean QAViewer2dTest::PickShapes (const TopAbs_ShapeEnum /*TheType*/, - Handle(TopTools_HArray1OfShape)& thearr, - const Standard_Integer /*MaxPick*/) -{ - Standard_Integer Taille = thearr->Length(); - if (Taille > 1) - cout << " WARNING : Pick with Shift+ MB1 for Selection of more than 1 object" << endl; - - // step 1: prepare the data - Standard_Integer curindex = TheAIS2DContext()->OpenLocalContext(); -/* if (TheType == TopAbs_SHAPE) - { - Handle(AIS2D_TypeFilter) F1 = new AIS2D_TypeFilter(AIS2D_KOI_Shape); - TheAIS2DContext()->AddFilter(F1); - } - else - { - Handle(StdSelect_ShapeTypeFilter) TF = new StdSelect_ShapeTypeFilter(TheType); - TheAIS2DContext()->AddFilter(TF); - TheAIS2DContext()->ActivateStandardMode(TheType); - }*/ - - // step 2 : wait for the selection... - Standard_Boolean NbToReach (thearr->Length()); - Standard_Integer NbPickFail (0); - /* - Standard_Boolean NbPickGood (0) ; - Standard_Integer argccc = 5; - char *bufff[] = { "A", "B", "C","D", "E" }; - char **argvvv = bufff; - - while (NbPickGood < NbToReach && NbPickFail <= MaxPick) - { - while (ViewerMainLoop2d(argccc,argvvv)) {} - Standard_Integer NbStored = TheAIS2DContext()->NbSelected(); - if ((unsigned int ) NbStored != NbPickGood) - NbPickGood = NbStored; - else - NbPickFail++; - cout<<"NbPicked = "<= NbToReach) return Standard_False; - - /* - Standard_Integer i(0); - for (TheAIS2DContext()->InitSelected(); - TheAIS2DContext()->MoreSelected(); - TheAIS2DContext()->NextSelected()) - { - i++; - if(TheAIS2DContext()->HasSelectedShape()) - thearr->SetValue(i,TheAIS2DContext()->SelectedShape()); - else - { - Handle(AIS2D_InteractiveObject) IO = TheAIS2DContext()->SelectedInteractive(); - thearr->SetValue(i,(*((Handle(AIS2D_ProjShape)*) &IO))->Shape()); - } - }*/ - - TheAIS2DContext()->CloseLocalContext(curindex); - return Standard_True; -} - -//===================================================================== -//========================= for testing Draft and Rib ================= -//===================================================================== -#include -#include -#include -#include -#include -#include -#include -#include -#if defined(BRepAlgoAPI_def01) -#include -#else -#include -#endif - -//======================================================================= -//function : IsValid2d -//purpose : -//======================================================================= -static Standard_Boolean IsValid2d (const TopTools_ListOfShape& theArgs, - const TopoDS_Shape& theResult, - const Standard_Boolean closedSolid, - const Standard_Boolean GeomCtrl) -{ - OSD_Environment check ("DONT_SWITCH_IS_VALID") ; - TCollection_AsciiString checkValid = check.Value(); - Standard_Boolean ToCheck = Standard_True; - if (!checkValid.IsEmpty()) { -#ifdef DEB - cout <<"DONT_SWITCH_IS_VALID positionnee a :"< 4) { // == 5 - rev = atoi(argv[5]); - Rev = (rev)? Standard_True : Standard_False; - } - - TopoDS_Face face2 = TopoDS::Face(Plane); -// if (!AIS2D::GetPlaneFromFace(face2, aPln, aSurf, aSurfType, Offset)) -// { -// cout << "TEST : Can't find plane" << endl; -// return 1; -// } - - aDir = aPln.Axis().Direction(); - if (!aPln.Direct()) - aDir.Reverse(); - if (Plane.Orientation() == TopAbs_REVERSED) - aDir.Reverse(); - di << "TEST : gp::Resolution() = " << gp::Resolution() << "\n"; - - BRepOffsetAPI_DraftAngle Draft (Solid); - - if(Abs(anAngle)< Precision::Angular()) { - di << "TEST : NULL angle" << "\n"; - return 1;} - - if(Rev) anAngle = - anAngle; - Draft.Add (Face, aDir, anAngle, aPln); - Draft.Build (); - if (!Draft.IsDone()) { - di << "TEST : Draft Not DONE " << "\n"; - return 1; - } - TopTools_ListOfShape Larg; - Larg.Append(Solid); - if (!IsValid2d(Larg,Draft.Shape(),Standard_True,Standard_False)) - { - di << "TEST : DesignAlgo returns Not valid" << "\n"; - return 1; - } - - Handle(AIS2D_InteractiveContext) Ctx = QAViewer2dTest::GetAIS2DContext(); - Handle(AIS2D_ProjShape) ais = new AIS2D_ProjShape(); - ais->Add(Draft.Shape()); - - if (!ais.IsNull()) - { -// ais->SetColor(DEFAULT_COLOR); -// ais->SetMaterial(DEFAULT_MATERIAL); - // Display the AIS2D_ProjShape without redraw - Ctx->Display(ais, Standard_False); - - char *Name = "draft1"; - Standard_Boolean IsBound = GetMapOfAIS2D().IsBound2(Name); - if (IsBound) - { - Handle(AIS2D_InteractiveObject) an_object = GetMapOfAIS2D().Find2(Name); -// Ctx->Remove(an_object, Standard_True); - GetMapOfAIS2D().UnBind2(Name); - } - GetMapOfAIS2D().Bind(ais, Name); - } - Ctx->Display(ais, Standard_True); - return 0; -} - -//============================================================================ -// MyCommands -//============================================================================ -void QAViewer2dTest::MyCommands (Draw_Interpretor& theCommands) -{ - DrawTrSurf::BasicCommands(theCommands); - char* group = "2D AIS Viewer - Check Features Operations commands"; - - theCommands.Add("Draft2d", - "Draft2d Solid Face Plane Angle Reverse", - __FILE__, TDraft2d, group); //Draft_Modification -} - -//============================================================================ -// All 2D AIS Viewer Commands -//============================================================================ -void QAViewer2dTest::Commands (Draw_Interpretor& theCommands) -{ - QAViewer2dTest::GeneralCommands(theCommands); - QAViewer2dTest::ViewerCommands (theCommands); - QAViewer2dTest::DisplayCommands(theCommands); - QAViewer2dTest::ObjectCommands (theCommands); -} -#endif diff --git a/src/QAViewer2dTest/QAViewer2dTest_CMPLRS.edl b/src/QAViewer2dTest/QAViewer2dTest_CMPLRS.edl deleted file mode 100755 index 5ad52476c5..0000000000 --- a/src/QAViewer2dTest/QAViewer2dTest_CMPLRS.edl +++ /dev/null @@ -1,25 +0,0 @@ --- Copyright (c) 1999-2012 OPEN CASCADE SAS --- --- The content of this file is subject to the Open CASCADE Technology Public --- License Version 6.5 (the "License"). You may not use the content of this file --- except in compliance with the License. Please obtain a copy of the License --- at http://www.opencascade.org and read it completely before using this file. --- --- The Initial Developer of the Original Code is Open CASCADE S.A.S., having its --- main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. --- --- The Original Code and all software distributed under the License is --- distributed on an "AS IS" basis, without warranty of any kind, and the --- Initial Developer hereby disclaims all such warranties, including without --- limitation, any warranties of merchantability, fitness for a particular --- purpose or non-infringement. Please see the License for the specific terms --- and conditions governing the rights and limitations under the License. - -@ifnotdefined ( %QAViewer2dTest_CMPLRS ) then -@set %QAViewer2dTest_CMPLRS = ""; - - @uses "CSF.edl" ; - - @string %CMPLRS_CXX_Options += " " %CSF_TCL_INCLUDE; - -@endif; diff --git a/src/QAViewer2dTest/QAViewer2dTest_DisplayCommands.cxx b/src/QAViewer2dTest/QAViewer2dTest_DisplayCommands.cxx deleted file mode 100755 index 63ad38d34d..0000000000 --- a/src/QAViewer2dTest/QAViewer2dTest_DisplayCommands.cxx +++ /dev/null @@ -1,1519 +0,0 @@ -// Created on: 2002-01-22 -// Created by: Julia DOROVSKIKH -// Copyright (c) 2002-2012 OPEN CASCADE SAS -// -// The content of this file is subject to the Open CASCADE Technology Public -// License Version 6.5 (the "License"). You may not use the content of this file -// except in compliance with the License. Please obtain a copy of the License -// at http://www.opencascade.org and read it completely before using this file. -// -// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its -// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. -// -// The Original Code and all software distributed under the License is -// distributed on an "AS IS" basis, without warranty of any kind, and the -// Initial Developer hereby disclaims all such warranties, including without -// limitation, any warranties of merchantability, fitness for a particular -// purpose or non-infringement. Please see the License for the specific terms -// and conditions governing the rights and limitations under the License. - -#if defined(WOKC40) - -#include - -#include -#include -#include - -#include - -#include - -#include -#include - -#include -#include - -#include - -#include -#include -#include - -#include - -#include - -#include - -#include -#include - -#include -#include - -#include -#include -#include - -#include - -#define OCC190 // jfa 04/03/2002 // for vertices load -#define OCC154 // jfa 06/03/2002 // for correct erasing - -#define DEFAULT_COLOR Quantity_NOC_GOLDENROD -#define DEFAULT_MATERIAL Graphic3d_NOM_BRASS - -QAViewer2dTest_DoubleMapOfInteractiveAndName& GetMapOfAIS2D(); -Handle(AIS2D_InteractiveContext)& TheAIS2DContext(); -TopoDS_Shape GetShapeFromName2d (char* name); - -//============================================================================== -//function : GetAIS2DShapeFromName -//purpose : Compute an AIS2D_ProjShape from a draw variable or a file name -//============================================================================== -Handle(AIS2D_InteractiveObject) GetAIS2DShapeFromName - (char* name, gp_Ax2 anAx2 = gp::XOY()) -{ - Handle(AIS2D_InteractiveObject) retsh; - - if (GetMapOfAIS2D().IsBound2(name)) - { - Handle(AIS2D_InteractiveObject) IO = GetMapOfAIS2D().Find2(name); -// if(IO->Type() == AIS2D_KOI_Shape) -// if (IO->Signature() == 0){ -// retsh = *((Handle(AIS2D_ProjShape)*)&IO); -// } -// else - cout << "an Object which is not an AIS2D_ProjShape already has this name!!!" << endl; - return retsh; - } - - TopoDS_Shape S = GetShapeFromName2d(name); - if (!S.IsNull()) - { -#ifdef OCC190 - if (S.ShapeType() == TopAbs_VERTEX) - { - TopoDS_Vertex aVert = TopoDS::Vertex(S); - gp_Pnt aPnt = BRep_Tool::Pnt(aVert); - - gp_Trsf aTrsf; - gp_Ax3 aToSystem (anAx2); - aTrsf.SetTransformation(aToSystem); - aPnt.Transform(aTrsf); - - Handle(V2d_View) V = QAViewer2dTest::CurrentView(); - retsh = new AIS2D_InteractiveObject(); - retsh->SetView(V->View()); - -#define VERTEXMARKER 2 -#define DEFAULTMARKERSIZE 3.0 - - Handle(Graphic2d_Marker) vertex = new Graphic2d_Marker - (retsh, VERTEXMARKER, aPnt.X(), aPnt.Y(), DEFAULTMARKERSIZE, DEFAULTMARKERSIZE, 0.0); - } - else -#endif - { - HLRAlgo_Projector aProjector (anAx2); - Handle(AIS2D_ProjShape) retprsh = new AIS2D_ProjShape(aProjector); - retprsh->Add(S); - retsh = retprsh; - } - } - return retsh; -} - -//======================================================================= -//function : GetColorFromName2d -//purpose : get the Quantity_NameOfColor from a string -//======================================================================= -static Quantity_NameOfColor GetColorFromName2d (char *name) -{ - Quantity_NameOfColor ret = DEFAULT_COLOR; - - Standard_Boolean Found = Standard_False; - Standard_CString colstring; - for (Standard_Integer i = 0; i <= 514 && !Found; i++) - { - colstring = Quantity_Color::StringName(Quantity_NameOfColor(i)); - if (!strcasecmp(name,colstring)) - { - ret = (Quantity_NameOfColor)i; - Found = Standard_True; - } - } - - return ret; -} -#if 0 -//======================================================================= -//function : GetMaterialFromName2d -//purpose : get the Graphic3d_NameOfMaterial from a string -//======================================================================= -static Graphic3d_NameOfMaterial GetMaterialFromName2d (char *name) -{ - Graphic3d_NameOfMaterial mat = DEFAULT_MATERIAL; - - if ( !strcasecmp(name,"BRASS" ) ) mat = Graphic3d_NOM_BRASS; - else if ( !strcasecmp(name,"BRONZE" ) ) mat = Graphic3d_NOM_BRONZE; - else if ( !strcasecmp(name,"COPPER" ) ) mat = Graphic3d_NOM_COPPER; - else if ( !strcasecmp(name,"GOLD" ) ) mat = Graphic3d_NOM_GOLD; - else if ( !strcasecmp(name,"PEWTER" ) ) mat = Graphic3d_NOM_PEWTER; - else if ( !strcasecmp(name,"SILVER" ) ) mat = Graphic3d_NOM_SILVER; - else if ( !strcasecmp(name,"STEEL" ) ) mat = Graphic3d_NOM_STEEL; - else if ( !strcasecmp(name,"METALIZED" ) ) mat = Graphic3d_NOM_METALIZED; - else if ( !strcasecmp(name,"STONE" ) ) mat = Graphic3d_NOM_STONE; - else if ( !strcasecmp(name,"CHROME" ) ) mat = Graphic3d_NOM_CHROME; - else if ( !strcasecmp(name,"ALUMINIUM" ) ) mat = Graphic3d_NOM_ALUMINIUM; - else if ( !strcasecmp(name,"STONE" ) ) mat = Graphic3d_NOM_STONE; - else if ( !strcasecmp(name,"NEON_PHC" ) ) mat = Graphic3d_NOM_NEON_PHC; - else if ( !strcasecmp(name,"NEON_GNC" ) ) mat = Graphic3d_NOM_NEON_GNC; - else if ( !strcasecmp(name,"PLASTER" ) ) mat = Graphic3d_NOM_PLASTER; - else if ( !strcasecmp(name,"SHINY_PLASTIC" ) ) mat = Graphic3d_NOM_SHINY_PLASTIC; - else if ( !strcasecmp(name,"SATIN" ) ) mat = Graphic3d_NOM_SATIN; - else if ( !strcasecmp(name,"PLASTIC" ) ) mat = Graphic3d_NOM_PLASTIC; - else if ( !strcasecmp(name,"OBSIDIAN" ) ) mat = Graphic3d_NOM_OBSIDIAN; - else if ( !strcasecmp(name,"JADE" ) ) mat = Graphic3d_NOM_JADE; - -#ifdef DEB - cout << " materiau" << name <<" "<ShiftSelect(); - else EM->Select(); - - const Handle(AIS2D_InteractiveContext) aContext = EM->Context(); - - if (!aContext->HasOpenedContext()) - { -// aContext->InitCurrent(); -/* while ( aContext->MoreCurrent() ) { - Handle(AIS2D_InteractiveObject) aisPickedShape = - Handle(AIS2D_InteractiveObject)::DownCast(aContext->Current()); - - const char *name = (GetMapOfAIS2D().IsBound1(aisPickedShape))? - GetMapOfAIS2D().Find1(aisPickedShape).ToCString() : - "????"; - Handle(AIS2D_ProjShape) TheRealSh = Handle(AIS2D_ProjShape)::DownCast(aisPickedShape); - if(!TheRealSh.IsNull()){ - cout << "Current is " << name - << " (" << GetTypeNameFromShape2d(TheRealSh->Shape()) - << ")" << endl; - } - ret = aisPickedShape; - if(!TheRealSh.IsNull()){ - if ( pick && argc > 4 ) { - DBRep::Set(argv[4], TheRealSh->Shape()); - } - } - aContext->NextCurrent(); - }*/ - } - else - { - // A LocalContext is opened, the use xxxxSelected() - // to select an object and its SubShape -/* aContext->InitSelected(); - while ( aContext->MoreSelected() ) { - if ( !aContext->HasSelectedShape() ) { - } - else { - TopoDS_Shape PickedShape = aContext->SelectedShape(); - if ( pick && argc > 5 ) { - DBRep::Set(argv[5], PickedShape); - } - } - - if ( aContext->Interactive().IsNull() ) { - cout << "??? (No InteractiveObject selected)" << endl; - } - else { - Handle(AIS2D_InteractiveObject) aisPicked = - Handle(AIS2D_InteractiveObject)::DownCast(aContext->Interactive()); - ret = aisPicked; - Handle(AIS2D_ProjShape) aisPickedShape = Handle(AIS2D_ProjShape)::DownCast(aisPicked); - - // Get back its name - const char *name = ( GetMapOfAIS2D().IsBound1(aisPicked) )? - GetMapOfAIS2D().Find1(aisPicked).ToCString() : - "????"; - - if(!aisPickedShape.IsNull()){ - if ( pick && argc > 4 ) { - // Create a draw variable to store the wohole shape - // for vpick command - DBRep::Set(argv[4], aisPickedShape->Shape()); - } - - cout << name << " (" << GetTypeNameFromShape2d(aisPickedShape->Shape()) - << ")" << endl ; - } - } - // Goto the next selected object - aContext->NextSelected(); - }*/ - } - return ret; -} - -//============================================================================== -//function : Displays,Erase... -//purpose : -//Draw arg : -//============================================================================== -static int VwrTst_DispErase2d (const Handle(AIS2D_InteractiveObject)& IO, - const Standard_Integer Mode, - const Standard_Integer TypeOfOperation, - const Standard_Boolean Upd) -{ - Handle(AIS2D_InteractiveContext) Ctx = QAViewer2dTest::GetAIS2DContext(); - - switch (TypeOfOperation) - { - case 1: - Ctx->Display(IO,Mode,Upd); - break; - case 2: - Ctx->Erase(IO,Mode,Upd); - break; - case 3: -// if(IO.IsNull()) -// Ctx->SetDisplayMode((AIS2D_DisplayMode)Mode,Upd); -// else -// Ctx->SetDisplayMode(IO,Mode,Upd); - break; - case 4: -// if(IO.IsNull()) -// Ctx->SetDisplayMode(0,Upd); -// else -// Ctx->UnsetDisplayMode(IO,Upd); - break; - } - - return 0; -} - -#if 0 -//======================================================================= -//function :V2dDispMode -//purpose : -//======================================================================= -static int V2dDispMode (Draw_Interpretor& , Standard_Integer argc, char** argv) -{ - TCollection_AsciiString name; - if (argc > 3) return 1; - - // display others presentations - Standard_Integer TypeOfOperation = (strcasecmp(argv[0],"v2ddispmode") == 0)? 1: - (strcasecmp(argv[0],"v2derasemode") == 0) ? 2 : - (strcasecmp(argv[0],"v2dsetdispmode") == 0) ? 3 : - (strcasecmp(argv[0],"v2dunsetdispmode") == 0) ? 4 : -1; - - Handle(AIS2D_InteractiveContext) Ctx = QAViewer2dTest::GetAIS2DContext(); - - //unset displaymode.. comportement particulier... - if (TypeOfOperation == 4) - { - if (argc == 1) - { -/* if(Ctx->NbCurrents()==0 || - Ctx->NbSelected()==0){ - Handle(AIS2D_InteractiveObject) IO; - VwrTst_DispErase2d(IO,-1,4,Standard_False); - } - else if(!Ctx->HasOpenedContext()){ - for(Ctx->InitCurrent();Ctx->MoreCurrent();Ctx->NextCurrent()) - VwrTst_DispErase2d(Ctx->Current(),-1,4,Standard_False); - } - else{ - for(Ctx->InitSelected();Ctx->MoreSelected();Ctx->NextSelected()) - VwrTst_DispErase2d(Ctx->Interactive(),-1,4,Standard_False);}*/ - Ctx->UpdateCurrentViewer(); - } - else - { - Handle(AIS2D_InteractiveObject) IO; - name = argv[1]; - if (GetMapOfAIS2D().IsBound2(name)) - { - IO = GetMapOfAIS2D().Find2(name); - VwrTst_DispErase2d(IO,-1,4,Standard_True); - } - } - } - else if (argc == 2) - { -// Standard_Integer Dmode = atoi(argv[1]); -// if(Ctx->NbCurrents()==0 && TypeOfOperation==3){ -// Handle(AIS2D_InteractiveObject) IO; -// VwrTst_DispErase2d(IO,Dmode,TypeOfOperation,Standard_True); -// } - if (!Ctx->HasOpenedContext()) - { - // set/unset display mode sur le Contexte... -// for(Ctx->InitCurrent();Ctx->MoreCurrent();Ctx->NextCurrent()){ -// VwrTst_DispErase2d(Ctx->Current(),Dmode,TypeOfOperation,Standard_False); -// } - Ctx->UpdateCurrentViewer(); - } - else - { -// for(Ctx->InitSelected();Ctx->MoreSelected();Ctx->NextSelected()) -// Ctx->Display(Ctx->Interactive(),Dmode); - } - } - else - { - Handle(AIS2D_InteractiveObject) IO; - name = argv[1]; - if (GetMapOfAIS2D().IsBound2(name)) - IO = GetMapOfAIS2D().Find2(name); - VwrTst_DispErase2d(IO,atoi(argv[2]),TypeOfOperation,Standard_True); - } - - return 0; -} -#endif - -//============================================================================== -//function : V2dSetBGColor -//purpose : v2dsetbgcolor colorname : change background color -//============================================================================== -static int V2dSetBGColor (Draw_Interpretor& di, Standard_Integer argc, char** argv) -{ - if (argc != 2) - { - di << "Usage : v2dsetbgcolor colorname" << "\n"; - return 1; - } - Handle(V2d_View) V = QAViewer2dTest::CurrentView(); - if (V.IsNull()) return 1; - - V->SetBackground(GetColorFromName2d(argv[1])); - V->Viewer()->Update(); - return 0; -} - -//============================================================================== -//function : V2dColor -//purpose : change the color of a selected or named or displayed shape -//Draw arg : v2dsetcolor [name] color -//============================================================================== -static int V2dSetUnsetColor (Handle(AIS2D_InteractiveObject) theShape, - Standard_Boolean HaveToSet, - Quantity_NameOfColor theColor = Quantity_NOC_WHITE) -{ - theShape->SetContext(TheAIS2DContext()); - - Handle(Graphic2d_Primitive) aPrim; - Handle(Prs2d_AspectRoot) anAspect; - Standard_Integer i = 1, n = theShape->Length(); - for (; i <= n; i++) - { - aPrim = theShape->Primitive(i); - if (theShape->HasAspect(aPrim)) - { - anAspect = theShape->GetAspect(aPrim); - if (anAspect->GetAspectName() == Prs2d_AN_LINE) break; - else anAspect = NULL; - } - } - - if (HaveToSet) - { - if (anAspect.IsNull()) - { - theShape->SetAspect - (new Prs2d_AspectLine(theColor, Aspect_TOL_SOLID, Aspect_WOL_THIN, - theColor, Graphic2d_TOPF_FILLED)); - } - else - { - Handle(Prs2d_AspectLine) anAspectLine = Handle(Prs2d_AspectLine)::DownCast(anAspect); - anAspectLine->SetTypeOfFill(Graphic2d_TOPF_FILLED); - anAspectLine->SetColor(theColor); - anAspectLine->SetInterColor(theColor); - theShape->SetAspect(anAspect); - } - } - else // unset color - { - Handle(Prs2d_AspectLine) anAspectLine; - if ( !anAspect.IsNull() ) - anAspectLine = Handle(Prs2d_AspectLine)::DownCast(anAspect); - else - anAspectLine = new Prs2d_AspectLine(); - - anAspectLine->SetTypeOfFill(Graphic2d_TOPF_EMPTY); - if (theShape->IsKind(STANDARD_TYPE(AIS2D_ProjShape))) - { - anAspectLine->SetColor(Quantity_NOC_YELLOW); - anAspectLine->SetInterColor(Quantity_NOC_YELLOW); - } - else - { - anAspectLine->SetColor(Quantity_NOC_WHITE); - anAspectLine->SetInterColor(Quantity_NOC_WHITE); - } - theShape->SetAspect( anAspectLine ); - } - - return 0; -} - -static int V2dColor (Draw_Interpretor& di, Standard_Integer argc, char** argv) -{ - Standard_Boolean ThereIsArgument = Standard_False; - Standard_Boolean HaveToSet = Standard_False; - - if (strcasecmp(argv[0],"v2dsetcolor") == 0) HaveToSet = Standard_True; - - Quantity_NameOfColor aColor = Quantity_NOC_BLACK; - if (HaveToSet) - { - if (argc < 2 || argc > 3) - { - di << "Usage: v2dsetcolor [name] color" << "\n"; - return 1; - } - if (argc == 3) - { - ThereIsArgument = Standard_True; - aColor = GetColorFromName2d(argv[2]); - } - else - { - aColor = GetColorFromName2d(argv[1]); - } - } - else - { - if (argc > 2) - { - di << "Usage: v2dunsetcolor [name]" << "\n"; - return 1; - } - if (argc == 2) ThereIsArgument = Standard_True; - } - - if (QAViewer2dTest::CurrentView().IsNull()) return -1; - TheAIS2DContext()->CloseLocalContext(); - - if (ThereIsArgument) - { - TCollection_AsciiString name = argv[1]; - - if (GetMapOfAIS2D().IsBound2(name)) - { - Handle(AIS2D_InteractiveObject) aShape = GetMapOfAIS2D().Find2(name); - V2dSetUnsetColor(aShape, HaveToSet, aColor); - } - } - else - { - Standard_Boolean hasCurrent = Standard_False; - QAViewer2dTest_DoubleMapIteratorOfDoubleMapOfInteractiveAndName it (GetMapOfAIS2D()); - for (; it.More() && !hasCurrent; it.Next()) - { - if (TheAIS2DContext()->IsCurrent(it.Key1())) hasCurrent = Standard_True; - } - for (it.Reset(); it.More(); it.Next()) - { - Handle(AIS2D_InteractiveObject) aShape = it.Key1(); - if ((hasCurrent && TheAIS2DContext()->IsCurrent(aShape)) || !hasCurrent) - { - V2dSetUnsetColor(aShape, HaveToSet, aColor); - } - } -// TheAIS2DContext()->UpdateCurrentViewer(); - } - return 0; -} - -#if 0 -//============================================================================== -//function : V2dTransparency -//purpose : change the transparency of a selected or named or displayed shape -//Draw arg : v2dsettransp [name] TransparencyCoeficient -//============================================================================== -static int V2dTransparency (Draw_Interpretor& di, Standard_Integer argc, char** argv) -{ - Standard_Boolean ThereIsArgument; - Standard_Boolean HaveToSet; - - if (strcasecmp(argv[0], "v2dsettransp") == 0) - HaveToSet = Standard_True; - else - HaveToSet = Standard_False; - - if (HaveToSet) - { - if (argc < 2 || argc > 3) - { - di << "Usage: v2dsettransp [name] color" << "\n"; - return 1; - } - if (argc == 2) ThereIsArgument = Standard_False; - else ThereIsArgument = Standard_True; - } - else - { - if (argc > 2) - { - di << "Usage: v2dunsettransp [name]" << "\n"; - return 1; - } - if (argc == 2) ThereIsArgument = Standard_True; - else ThereIsArgument = Standard_False; - } - - if (QAViewer2dTest::CurrentView().IsNull()) return -1; - TheAIS2DContext()->CloseLocalContext(); - - if (ThereIsArgument) - { - TCollection_AsciiString name = argv[1]; - if (GetMapOfAIS2D().IsBound2(name)) - { - Handle(AIS2D_InteractiveObject) ashape = GetMapOfAIS2D().Find2(name); -// if(HaveToSet) -// TheAIS2DContext()->SetTransparency(ashape,atof(argv[2]) ); -// else -// TheAIS2DContext()->UnsetTransparency(ashape); - } - } - else - { -// if (TheAIS2DContext()->NbCurrents() > 0) - { -/* for (TheAIS2DContext()->InitCurrent(); TheAIS2DContext()->MoreCurrent(); - TheAIS2DContext()->NextCurrent()) - { - Handle(AIS2D_InteractiveObject) ashape = TheAIS2DContext()->Current(); - if (HaveToSet) - { - TheAIS2DContext()->SetTransparency(ashape, atof(argv[1]), Standard_False); - } - else - TheAIS2DContext()->UnsetTransparency(ashape, Standard_False); - }*/ - - TheAIS2DContext()->UpdateCurrentViewer(); - } -// else // shape not defined (neither current, nor named) - { - QAViewer2dTest_DoubleMapIteratorOfDoubleMapOfInteractiveAndName it (GetMapOfAIS2D()); - while (it.More()) - { - Handle(AIS2D_InteractiveObject) ashape = it.Key1(); -// if(HaveToSet) -// TheAIS2DContext()->SetTransparency(ashape,atof(argv[1]),Standard_False); -// else -// TheAIS2DContext()->UnsetTransparency(ashape,Standard_False); - it.Next(); - } - TheAIS2DContext()->UpdateCurrentViewer(); - } - } - return 0; -} -#endif - -#if 0 -//============================================================================== -//function : V2dMaterial -//purpose : change the Material of a selected or named or displayed shape -//Draw arg : v2dmaterial [Name] Material -//============================================================================== -static int V2dMaterial (Draw_Interpretor& di, Standard_Integer argc, char** argv) -{ - Standard_Boolean ThereIsName; - Standard_Boolean HaveToSet; - - if (strcasecmp(argv[0], "v2dsetmaterial") == 0) HaveToSet = Standard_True; - else HaveToSet = Standard_False; - - if (HaveToSet) - { - if (argc < 2 || argc > 3) - { - di << "Usage: v2dsetmaterial [name] material" << "\n"; - return 1; - } - if (argc == 2) ThereIsName = Standard_False; - else ThereIsName = Standard_True; - } - else - { - if (argc > 2) - { - di << "Usage: v2dunsetmaterial [name]" << "\n"; - return 1; - } - if (argc == 2) ThereIsName = Standard_True; - else ThereIsName = Standard_False; - } - - if (QAViewer2dTest::CurrentView().IsNull()) return -1; - TheAIS2DContext()->CloseLocalContext(); - - if (ThereIsName) - { - TCollection_AsciiString name = argv[1]; - if (GetMapOfAIS2D().IsBound2(name)) - { - Handle(AIS2D_InteractiveObject) ashape = GetMapOfAIS2D().Find2(name); - if (HaveToSet) - { -// TheAIS2DContext()->SetMaterial (ashape,GetMaterialFromName2d (argv[2]) ); - } - else - { -// TheAIS2DContext()->UnsetMaterial(ashape); - } - } - } - else - { -// if (TheAIS2DContext()->NbCurrents() > 0) - { -/* for (TheAIS2DContext()->InitCurrent(); TheAIS2DContext()->MoreCurrent(); - TheAIS2DContext()->NextCurrent()) - { - Handle(AIS2D_InteractiveObject) ashape = TheAIS2DContext()->Current(); - if (HaveToSet) - { - TheAIS2DContext()->SetMaterial(ashape, GetMaterialFromName2d(argv[1]), Standard_False); - } - else - TheAIS2DContext()->UnsetMaterial(ashape, Standard_False); - }*/ - TheAIS2DContext()->UpdateCurrentViewer(); - } -// else // shape not defined (neither current, nor named) - { - QAViewer2dTest_DoubleMapIteratorOfDoubleMapOfInteractiveAndName it (GetMapOfAIS2D()); - while (it.More()) - { - Handle(AIS2D_InteractiveObject) ashape = it.Key1(); - -// if (HaveToSet) -// TheAIS2DContext()->SetMaterial(ashape,GetMaterialFromName2d(argv[1]),Standard_False); -// else TheAIS2DContext()->UnsetMaterial(ashape,Standard_False); - it.Next(); - } - TheAIS2DContext()->UpdateCurrentViewer(); - } - } - return 0; -} -#endif - -//============================================================================== -//function : V2dWidth -//purpose : change the width of the edges of a selected or named or displayed shape -//Draw arg : v2dsetwidth [Name] WidthEnum(THIN MEDIUM THICK VERYTHICK) -//============================================================================== -static int V2dSetUnsetWidth (Handle(AIS2D_InteractiveObject) theShape, - Standard_Boolean HaveToSet, - Aspect_WidthOfLine theWOL = Aspect_WOL_THIN) -{ - theShape->SetContext(TheAIS2DContext()); - - Handle(Graphic2d_Primitive) aPrim; - Handle(Prs2d_AspectRoot) anAspect; - Standard_Integer i = 1, n = theShape->Length(); - for (; i <= n; i++) - { - aPrim = theShape->Primitive(i); - if (theShape->HasAspect(aPrim)) - { - anAspect = theShape->GetAspect(aPrim); - if (anAspect->GetAspectName() == Prs2d_AN_LINE) break; - else anAspect = NULL; - } - } - - if (HaveToSet) - { - if (anAspect.IsNull()) - { - Quantity_NameOfColor aColor; - if (theShape->IsKind(STANDARD_TYPE(AIS2D_ProjShape))) - { - aColor = Quantity_NOC_YELLOW; - } - else - { - aColor = Quantity_NOC_WHITE; - } - anAspect = new Prs2d_AspectLine(aColor, Aspect_TOL_SOLID, theWOL, - aColor, Graphic2d_TOPF_EMPTY); - } - else - { - Handle(Prs2d_AspectLine) anAspectLine = Handle(Prs2d_AspectLine)::DownCast(anAspect); - anAspectLine->SetWidth(theWOL); - } - - theShape->SetAspect(anAspect); - } - else // unset width - { - if (!anAspect.IsNull()) - { - Handle(Prs2d_AspectLine) anAspectLine = Handle(Prs2d_AspectLine)::DownCast(anAspect); - anAspectLine->SetWidth(Aspect_WOL_THIN); -// anAspectLine->SetWidthIndex(0); - theShape->SetAspect(anAspect); - } - } - - return 0; -} - -static int V2dWidth (Draw_Interpretor& di, Standard_Integer argc, char** argv) -{ - Standard_Boolean ThereIsArgument = Standard_False; - Standard_Boolean HaveToSet = Standard_False; - - if (strcasecmp(argv[0], "v2dsetwidth") == 0) HaveToSet = Standard_True; - - char* aStr; - if (HaveToSet) - { - if (argc < 2 || argc > 3) - { - di << "Usage: v2dsetwidth [name] width" << "\n"; - return 1; - } - if (argc == 3) - { - ThereIsArgument = Standard_True; - aStr = argv[2]; - } - else - { - aStr = argv[1]; - } - } - else - { - if ( argc > 2 ) - { - di << "Usage: v2dunsetwidth [name]" << "\n"; - return 1; - } - if (argc == 2) ThereIsArgument = Standard_True; - } - - if (QAViewer2dTest::CurrentView().IsNull()) return -1; - TheAIS2DContext()->CloseLocalContext(); - - Aspect_WidthOfLine aWOL = Aspect_WOL_THIN; - if (HaveToSet) - { - if (strcmp(aStr, "THIN" ) == 0) aWOL = Aspect_WOL_THIN; - else if (strcmp(aStr, "MEDIUM" ) == 0) aWOL = Aspect_WOL_MEDIUM; - else if (strcmp(aStr, "THICK" ) == 0) aWOL = Aspect_WOL_THICK; - else if (strcmp(aStr, "VERYTHICK") == 0) aWOL = Aspect_WOL_VERYTHICK; - else aWOL = Aspect_WOL_USERDEFINED; - } - - if (ThereIsArgument) - { - TCollection_AsciiString name = argv[1]; - - if (GetMapOfAIS2D().IsBound2(name)) - { - Handle(AIS2D_InteractiveObject) aShape = GetMapOfAIS2D().Find2(name); - V2dSetUnsetWidth(aShape, HaveToSet, aWOL); - } - } - else - { - Standard_Boolean hasCurrent = Standard_False; - QAViewer2dTest_DoubleMapIteratorOfDoubleMapOfInteractiveAndName it (GetMapOfAIS2D()); - for (; it.More() && !hasCurrent; it.Next()) - { - if (TheAIS2DContext()->IsCurrent(it.Key1())) hasCurrent = Standard_True; - } - for (it.Reset(); it.More(); it.Next()) - { - Handle(AIS2D_InteractiveObject) aShape = it.Key1(); - if ((hasCurrent && TheAIS2DContext()->IsCurrent(aShape)) || !hasCurrent) - { - V2dSetUnsetWidth(aShape, HaveToSet, aWOL); - } - } -// TheAIS2DContext()->UpdateCurrentViewer(); - } - return 0; -} - -//============================================================================== -//function : V2dDisplay -//purpose : Display an object from its name -//Draw arg : v2ddisplay name [projection (Origin(x y z) Normal(dx dy dz) DX(dx dy dz)] -//============================================================================== -static int V2dDisplay (Draw_Interpretor& di, Standard_Integer argc, char** argv) -{ - // Verification des arguments - if (argc != 2 && argc != 11) - { - di << "Usage: v2ddisplay name [x y z dx dy dz dx1 dy1 dz1]" << "\n"; - return 1; - } - - if (QAViewer2dTest::CurrentView().IsNull()) - { - di << "2D AIS Viewer Initialization ..." << "\n"; - QAViewer2dTest::ViewerInit(); - di << "Done" << "\n"; - } - - TCollection_AsciiString name; - TheAIS2DContext()->CloseLocalContext(); - - name = argv[1]; - gp_Ax2 anAx2 = gp::XOY(); - if (argc == 11) - { - Standard_Real x = atof(argv[2]); - Standard_Real y = atof(argv[3]); - Standard_Real z = atof(argv[4]); - - Standard_Real dx = atof(argv[5]); - Standard_Real dy = atof(argv[6]); - Standard_Real dz = atof(argv[7]); - - Standard_Real dx1 = atof(argv[8]); - Standard_Real dy1 = atof(argv[9]); - Standard_Real dz1 = atof(argv[10]); - - gp_Pnt anOrigin (x, y, z); - gp_Dir aNormal (dx, dy, dz); - gp_Dir aDX (dx1, dy1, dz1); - anAx2 = gp_Ax2(anOrigin, aNormal, aDX); - } - - Standard_Boolean IsBound = GetMapOfAIS2D().IsBound2(name); - Standard_Boolean IsDatum = Standard_False; - Handle(AIS2D_InteractiveObject) aShape; - if (IsBound) - { - aShape = GetMapOfAIS2D().Find2(name); -// if (aShape->Type() == AIS2D_KOI_Datum) - { - IsDatum = Standard_True; - TheAIS2DContext()->Display(aShape, Standard_False); -#ifdef OCC154 - TheAIS2DContext()->HighlightCurrent(); -#endif - } - if (!IsDatum) - { - di << "Display " << name << "\n"; - // Get the Shape from a name - TopoDS_Shape NewShape = GetShapeFromName2d(name.ToCString()); - - // Update the Shape in the AIS2D_ProjShape - Handle(AIS2D_ProjShape) TheRealSh = Handle(AIS2D_ProjShape)::DownCast(aShape); -// if(!TheRealSh.IsNull()) TheRealSh->Set(NewShape); - TheAIS2DContext()->Redisplay(aShape, Standard_False); - TheAIS2DContext()->Display(aShape, Standard_False); - } - aShape.Nullify(); - } - else // Create the AIS2D_ProjShape from a name - { - aShape = GetAIS2DShapeFromName(name.ToCString(), anAx2); - if (!aShape.IsNull()) - { - GetMapOfAIS2D().Bind(aShape, name); - TheAIS2DContext()->Display(aShape, Standard_False); - } - } - - // Update the screen and redraw the view - TheAIS2DContext()->UpdateCurrentViewer(); - return 0; -} - -//============================================================================== -//function : V2dDonly -//purpose : Display only a selected or named object -// if there is no selected or named object s, the whole viewer is erased -//Draw arg : vdonly [name1] ... [name n] -//============================================================================== -static int V2dDonly (Draw_Interpretor& , Standard_Integer argc, char** argv) -{ - if (QAViewer2dTest::CurrentView().IsNull()) return 1; - - Standard_Boolean ThereIsArgument = argc > 1; - - if (TheAIS2DContext()->HasOpenedContext()) TheAIS2DContext()->CloseLocalContext(); - - if (ThereIsArgument) - { - TheAIS2DContext()->EraseAll(Standard_True, Standard_False); - - for (int i = 1; i < argc; i++) - { - TCollection_AsciiString name = argv[i]; - Standard_Boolean IsBound = GetMapOfAIS2D().IsBound2(name); - if (IsBound) - { - Handle(AIS2D_InteractiveObject) aShape = GetMapOfAIS2D().Find2(name); - TheAIS2DContext()->Display(aShape, Standard_False); - } - } - TheAIS2DContext()->CurrentViewer()->Update(); - } - else - { - Standard_Boolean ThereIsCurrent = Standard_True/*= TheAIS2DContext()->NbCurrents() > 0*/; - if (ThereIsCurrent) - { - QAViewer2dTest_DoubleMapIteratorOfDoubleMapOfInteractiveAndName it (GetMapOfAIS2D()); - while (it.More()) - { - Handle(AIS2D_InteractiveObject) aShape = it.Key1(); - if (!TheAIS2DContext()->IsCurrent(aShape)) - TheAIS2DContext()->Erase(aShape, Standard_False); - it.Next(); - } - TheAIS2DContext()->CurrentViewer()->Update(); - } - } - - return 0; -} - -//============================================================================== -//function : V2dErase -//purpose : Erase some selected or named objects. -// If there is no selected or named objects, does nothing -//Draw arg : v2derase [name1] ... [name n] -//============================================================================== -static int V2dErase (Draw_Interpretor& , Standard_Integer argc, char** argv) -{ - if (QAViewer2dTest::CurrentView().IsNull()) return 1; - - if (TheAIS2DContext()->HasOpenedContext()) TheAIS2DContext()->CloseLocalContext(); - - if (argc > 1) // has arguments - { - for (int i = 1; i < argc; i++) - { - TCollection_AsciiString name = argv[i]; - Standard_Boolean IsBound = GetMapOfAIS2D().IsBound2(name); - if (IsBound) - { - Handle(AIS2D_InteractiveObject) aShape = GetMapOfAIS2D().Find2(name); - TheAIS2DContext()->Erase(aShape, Standard_False); - } - } -// TheAIS2DContext()->UpdateCurrentViewer(); - TheAIS2DContext()->CurrentViewer()->Update(); - } - else - { - QAViewer2dTest_DoubleMapIteratorOfDoubleMapOfInteractiveAndName it (GetMapOfAIS2D()); - while (it.More()) - { - Handle(AIS2D_InteractiveObject) aShape = it.Key1(); - if (TheAIS2DContext()->IsCurrent(aShape)) - TheAIS2DContext()->Erase(aShape, Standard_False); - it.Next(); - } -// TheAIS2DContext()->UpdateCurrentViewer(); - TheAIS2DContext()->CurrentViewer()->Update(); - } - - return 0; -} - -//============================================================================== -//function : V2dEraseAll -//purpose : Erase all the objects displayed in the viewer -//Draw arg : v2deraseall -//============================================================================== -static int V2dEraseAll (Draw_Interpretor& di, Standard_Integer argc, char** ) -{ - if (argc > 1) - { - di << "Usage: v2deraseall" << "\n"; - return 1; - } - - if (QAViewer2dTest::CurrentView().IsNull()) - { - di << " Error: v2dinit hasn't been called." << "\n"; - return 1; - } - - TheAIS2DContext()->CloseAllContext(Standard_False); - - // EraseAll(Standard_True, Standard_True); - TheAIS2DContext()->EraseAll(); - return 0; -} - -//============================================================================== -//function : V2dDisplayAll -//purpose : Display all the objects of the Map -//Draw arg : v2ddisplayall -//============================================================================== -static int V2dDisplayAll (Draw_Interpretor& di, Standard_Integer argc, char** argv) -{ - if (QAViewer2dTest::CurrentView().IsNull()) return 1; - - if (argc > 1) - { - di << argv[0] << " Syntaxe error" << "\n"; - return 1; - } - TheAIS2DContext()->CloseLocalContext(); - QAViewer2dTest_DoubleMapIteratorOfDoubleMapOfInteractiveAndName it (GetMapOfAIS2D()); -// while (it.More()) -// { -// Handle(AIS2D_InteractiveObject) aShape = it.Key1(); -// TheAIS2DContext()->Erase(aShape,Standard_False); -// it.Next(); -// } -// it.Reset(); - while (it.More()) - { - Handle(AIS2D_InteractiveObject) aShape = it.Key1(); - TheAIS2DContext()->Display(aShape, Standard_False); - it.Next(); - } -#ifdef OCC154 - TheAIS2DContext()->HighlightCurrent(); -#endif - TheAIS2DContext()->UpdateCurrentViewer(); -// TheAIS2DContext()->DisplayAll(); - return 0; -} - -//============================================================================== -//function : VTexture -//purpose : -//Draw arg : -//============================================================================== -/* -Standard_Integer VTexture (Draw_Interpretor& di,Standard_Integer argc, Standard_Character** argv ) -{ - Standard_Integer command = (strcasecmp(argv[0],"vtexture")==0)? 1: - (strcasecmp(argv[0],"vtexscale")==0) ? 2 : - (strcasecmp(argv[0],"vtexorigin")==0) ? 3 : - (strcasecmp(argv[0],"vtexrepeat")==0) ? 4 : - (strcasecmp(argv[0],"vtexdefault")==0) ? 5 : -1; - - Handle(AIS2D_InteractiveContext) myAIS2DContext = QAViewer2dTest::GetAIS2DContext(); - if(myAIS2DContext.IsNull()) - { - cerr << "use 'vinit' command before " << argv[0] << endl; - return 0; - } - - Handle(AIS2D_InteractiveObject) TheAisIO; - Handle(AIS2D_TexturedShape) myShape; - Standard_Integer myPreviousMode = 0; - - if (!argv[1]) - { - cout << argv[0] <<" syntax error - Type 'help vtex'"<SetSurfaceDetail(V2d_TEX_ALL); - - if (GetMapOfAIS2D().IsBound2(name)) - TheAisIO = GetMapOfAIS2D().Find2(name); - else - { - cout <<"shape "<IsKind(STANDARD_TYPE(AIS2D_TexturedShape)) && !TheAisIO.IsNull()) - { - myShape = Handle(AIS2D_TexturedShape)::DownCast(TheAisIO); - myPreviousMode = myShape->DisplayMode() ; - } - else - { - myAIS2DContext->Erase(TheAisIO,Standard_False); - myShape = new AIS2D_TexturedShape (DBRep::Get(argv[1])); - GetMapOfAIS2D().UnBind1(TheAisIO); - GetMapOfAIS2D().UnBind2(name); - GetMapOfAIS2D().Bind(myShape, name); - } - switch (command) - { - case 1: // vtexture : we only map a texture on the shape - if(argc<=1) - { - cerr << argv[0] <<" syntax error - Type 'help vtex'" << endl; - return 0; - } - if (argv[2]) - { - if(strcasecmp(argv[2],"?")==0) - { - TCollection_AsciiString monPath = GetEnvir2d(); - - cout<<"\n Files in current directory : \n"<SetTextureFileName(argv[2]); - } - else - { - cout <<"Texture mapping disabled \n \ - To enable it, use 'vtexture NameOfShape NameOfTexture' \n"<SetDisplayMode(myShape,1,Standard_False); - if (myPreviousMode == 3 ) - myAIS2DContext->RecomputePrsOnly(myShape); - myAIS2DContext->Display(myShape, Standard_True); - return 0; - } - break; - - case 2: // vtexscale : we change the scaling factor of the texture - - if(argc<2) - { - cerr << argv[0] <<" syntax error - Type 'help vtex'" << endl; - return 0; - } - - myShape->SetTextureScale (( argv[2] ? Standard_True : Standard_False ), - ( argv[2] ? atof(argv[2]) : 1.0 ), - ( argv[2] ? atof(argv[argc-1]) : 1.0 ) ); - break; - - case 3: // vtexorigin : we change the origin of the texture on the shape - if(argc<2) - { - cerr << argv[0] <<" syntax error - Type 'help vtex'" << endl; - return 0; - } - myShape->SetTextureOrigin (( argv[2] ? Standard_True : Standard_False ), - ( argv[2] ? atof(argv[2]) : 0.0 ), - ( argv[2] ? atof(argv[argc-1]) : 0.0 )); - break; - - case 4: // vtexrepeat : we change the number of occurences of the texture on the shape - if(argc<2) - { - cerr << argv[0] <<" syntax error - Type 'help vtex'" << endl; - return 0; - } - if (argv[2]) - { - cout <<"Texture repeat enabled"<SetTextureRepeat(Standard_True, atof(argv[2]), atof(argv[argc-1]) ); - } - else - { - cout <<"Texture repeat disabled"<SetTextureRepeat(Standard_False); - } - break; - - case 5: // vtexdefault : default texture mapping - // ScaleU = ScaleV = 100.0 - // URepeat = VRepeat = 1.0 - // Uorigin = VOrigin = 0.0 - - if(argc<2) - { - cerr << argv[0] <<" syntax error - Type 'help vtex'" << endl; - return 0; - } - myShape->SetTextureRepeat(Standard_False); - myShape->SetTextureOrigin(Standard_False); - myShape->SetTextureScale (Standard_False); - break; - } - - if ((myShape->DisplayMode() == 3) || (myPreviousMode == 3 )) - myAIS2DContext->RecomputePrsOnly(myShape); - else - { - myAIS2DContext->SetDisplayMode(myShape,3,Standard_False); - myAIS2DContext->Display(myShape, Standard_True); - myAIS2DContext->Update(myShape,Standard_True); - } - return 1; -} -*/ - -#if 0 -//============================================================================== -//function : V2dShading -//purpose : Sharpen or roughten the quality of the shading -//Draw arg : vshading ShapeName 0.1->0.00001 1 deg-> 30 deg -//============================================================================== -static int V2dShading (Draw_Interpretor& ,Standard_Integer argc, char** argv) -{ - Standard_Boolean HaveToSet; -// Standard_Real myDevAngle; - Standard_Real myDevCoef; - Handle(AIS2D_InteractiveObject) TheAisIO; - - // Verifications - if (!strcasecmp(argv[0],"vsetshading")) HaveToSet = Standard_True; - else HaveToSet = Standard_False; - TheAIS2DContext()->CloseLocalContext(); - - if (argc < 3) - { - myDevCoef = 0.0008; - } - else - { - myDevCoef = atof(argv[2]); - } - - TCollection_AsciiString name = argv[1]; - if (GetMapOfAIS2D().IsBound2(name)) TheAisIO = GetMapOfAIS2D().Find2(name); - else - { - TheAisIO = GetAIS2DShapeFromName(name.ToCString()); - } - - if (HaveToSet) - { -// TheAIS2DContext()->SetDeviationCoefficient(TheAisIO,myDevCoef,Standard_True); - } - else - { -// TheAIS2DContext()->SetDeviationCoefficient(TheAisIO,0.0008,Standard_True); - } - - TheAIS2DContext()->Redisplay(TheAisIO); - return 0; -} -#endif - -//======================================================================= -//function : VEraseType -//purpose : -//======================================================================= -/*static int VEraseType (Draw_Interpretor& , Standard_Integer argc, char** argv) -{ - if (argc!=2) return 1; - - AIS2D_KindOfInteractive TheType; - Standard_Integer TheSign(-1); - GetTypeAndSignfromString2d(argv[1],TheType,TheSign); - - AIS2D_ListOfInteractive LIO; - - // en attendant l'amelioration ais pour les dimensions... - // - Standard_Integer dimension_status(-1); - if(TheType==AIS2D_KOI_Relation){ - dimension_status = TheSign ==1 ? 1 : 0; - TheSign=-1; - } - - TheAIS2DContext()->DisplayedObjects(TheType,TheSign,LIO); - Handle(AIS2D_InteractiveObject) curio; - for(AIS2D_ListIteratorOfListOfInteractive it(LIO);it.More();it.Next()){ - curio = it.Value(); - - if(dimension_status == -1) - TheAIS2DContext()->Erase(curio,Standard_False); - else { - AIS2D_KindOfDimension KOD = (*((Handle(AIS2D_Relation)*)&curio))->KindOfDimension(); - if ((dimension_status==0 && KOD == AIS2D_KOD_NONE)|| - (dimension_status==1 && KOD != AIS2D_KOD_NONE)) - TheAIS2DContext()->Erase(curio,Standard_False); - } - } - TheAIS2DContext()->UpdateCurrentViewer(); - return 0; -}*/ - -//======================================================================= -//function : V2dDisplayType -//purpose : -//======================================================================= -/*static int V2dDisplayType (Draw_Interpretor& , Standard_Integer argc, char** argv) -{ - if (argc!=2) return 1; - - AIS2D_KindOfInteractive TheType; - Standard_Integer TheSign(-1); - GetTypeAndSignfromString2d(argv[1],TheType,TheSign); - - // en attendant l'amelioration ais pour les dimensions... - // - Standard_Integer dimension_status(-1); - if(TheType==AIS2D_KOI_Relation){ - dimension_status = TheSign ==1 ? 1 : 0; - TheSign=-1; - } - - AIS2D_ListOfInteractive LIO; - TheAIS2DContext()->ObjectsInside(LIO,TheType,TheSign); - Handle(AIS2D_InteractiveObject) curio; - for(AIS2D_ListIteratorOfListOfInteractive it(LIO);it.More();it.Next()){ - curio = it.Value(); - if(dimension_status == -1) - TheAIS2DContext()->Display(curio,Standard_False); - else { - AIS2D_KindOfDimension KOD = (*((Handle(AIS2D_Relation)*)&curio))->KindOfDimension(); - if ((dimension_status==0 && KOD == AIS2D_KOD_NONE)|| - (dimension_status==1 && KOD != AIS2D_KOD_NONE)) - TheAIS2DContext()->Display(curio,Standard_False); - } - - } - - TheAIS2DContext()->UpdateCurrentViewer(); - return 0; -}*/ - -//============================================================================== -//function : QAViewer2dTest::Commands -//purpose : Add all the viewer command in the Draw_Interpretor -//============================================================================== -void QAViewer2dTest::DisplayCommands (Draw_Interpretor& theCommands) -{ - char *group = "2D AIS Viewer - Display Commands"; - - theCommands.Add("v2ddisplay", - "v2ddisplay name [projection(Origin(x y z) Normal(dx dy dz) DX(dx dy dz)]", - __FILE__, V2dDisplay, group); - - theCommands.Add("v2derase", - "v2derase [name1] ... [name n]", - __FILE__, V2dErase, group); - - theCommands.Add("v2ddonly", - "v2ddonly [name1] ... [name n]", - __FILE__, V2dDonly, group); - - theCommands.Add("v2ddisplayall", - "v2ddisplayall", - __FILE__, V2dDisplayAll, group); - - theCommands.Add("v2deraseall", - "v2deraseall", - __FILE__, V2dEraseAll, group); - -// theCommands.Add("v2derasetype", -// "v2derasetype : erase all the displayed objects of one given kind (see vtypes)", -// __FILE__, V2dEraseType, group); - -// theCommands.Add("v2ddisplaytype", -// "v2ddisplaytype : display all the objects of one given kind (see vtypes) which are stored the AIS2DContext", -// __FILE__, V2dDisplayType, group); - -/* - theCommands.Add("v2ddisplaymode", - "v2ddispmode [name] mode(1,2,..) : no name -> on selected objects", - __FILE__, V2dDispMode, group); - - theCommands.Add("v2derasemode", - "v2derasemode [name] mode(1,2,..) : no name -> on selected objects", - __FILE__, V2dDispMode, group); - - theCommands.Add("v2dsetdispmode", - "v2dsetdispmode [name] mode(1,2,..) : no name -> on selected objects", - __FILE__, V2dDispMode, group); - - theCommands.Add("v2dunsetdispmode", - "v2dunsetdispmode [name] mode(1,2,..) : no name -> on selected objects", - __FILE__, V2dDispMode, group); -*/ - theCommands.Add("v2dsetcolor", - "v2dsetcolor [name of shape] ColorName", - __FILE__, V2dColor, group); - - theCommands.Add("v2dunsetcolor", - "v2dunsetcolor [name of shape]", - __FILE__, V2dColor, group); - - theCommands.Add("v2dsetbgcolor", - "v2dsetbgcolor colorname : Change background color", - __FILE__, V2dSetBGColor, group); - - /* - theCommands.Add("v2dsettransparency", - "v2dsettransparency [name of shape] TransparencyCoef(0 -> 1)", - __FILE__, V2dTransparency, group); - - theCommands.Add("v2dunsettransparency", - "v2dunsettransparency [name of shape]", - __FILE__, V2dTransparency, group); - - theCommands.Add("v2dsetmaterial", - "v2dsetmaterial [name of shape] MaterialName", - __FILE__, V2dMaterial, group); - - theCommands.Add("v2dunsetmaterial", - "v2dunsetmaterial [name of shape]", - __FILE__, V2dMaterial, group); -*/ - theCommands.Add("v2dsetwidth", - "v2dsetwidth [name_of_shape] width(THIN, MEDIUM, THICK, VERYTHICK)", - __FILE__, V2dWidth, group); - - theCommands.Add("v2dunsetwidth", - "v2dunsetwidth [name of shape]", - __FILE__, V2dWidth, group); -/* - theCommands.Add("v2dsetshading", - "v2dsetshading name Quality(default=0.0008)", - __FILE__, V2dShading, group); - - theCommands.Add("v2dunsetshading", - "v2dunsetshading name", - __FILE__, V2dShading, group); -*/ -/* theCommands.Add("v2dtexture", - "'v2dtexture NameOfShape TextureFile' \n \ - or 'vtexture NameOfShape' if you want to disable texture mapping \n \ - or 'vtexture NameOfShape ?' to list available textures\n \ - or 'vtexture NameOfShape IdOfTexture' (0<=IdOfTexture<=20)' to use predefined textures\n", - __FILE__, VTexture, group);*/ -} -#endif diff --git a/src/QAViewer2dTest/QAViewer2dTest_GeneralCommands.cxx b/src/QAViewer2dTest/QAViewer2dTest_GeneralCommands.cxx deleted file mode 100755 index 9d349b2ef9..0000000000 --- a/src/QAViewer2dTest/QAViewer2dTest_GeneralCommands.cxx +++ /dev/null @@ -1,1323 +0,0 @@ -// Created on: 2002-01-22 -// Created by: Julia DOROVSKIKH -// Copyright (c) 2002-2012 OPEN CASCADE SAS -// -// The content of this file is subject to the Open CASCADE Technology Public -// License Version 6.5 (the "License"). You may not use the content of this file -// except in compliance with the License. Please obtain a copy of the License -// at http://www.opencascade.org and read it completely before using this file. -// -// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its -// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. -// -// The Original Code and all software distributed under the License is -// distributed on an "AS IS" basis, without warranty of any kind, and the -// Initial Developer hereby disclaims all such warranties, including without -// limitation, any warranties of merchantability, fitness for a particular -// purpose or non-infringement. Please see the License for the specific terms -// and conditions governing the rights and limitations under the License. - -#if defined(WOKC40) - -#include - -#include -#include - -#include -#include - -#include - -#include -#include -#include - -#include -#include -#include - -#include - -#include -#include -#include -#include - -#include -#include - -#include -#include - -QAViewer2dTest_DoubleMapOfInteractiveAndName& GetMapOfAIS2D(); -Handle(AIS2D_InteractiveContext)& TheAIS2DContext(); - -//======================================================================= -//function : GetTypeNames2d -//purpose : -//======================================================================= -static char** GetTypeNames2d () -{ - static char* names[14] = {"Point","Axis","Trihedron","PlaneTrihedron", "Line","Circle","Plane", - "Shape","ConnectedShape","MultiConn.Shape", - "ConnectedInter.","MultiConn.", - "Constraint","Dimension"}; - static char** ThePointer = names; - return ThePointer; -} - -//======================================================================= -//function : GetTypeAndSignfromString2d -//purpose : -//======================================================================= -/*void GetTypeAndSignfromString2d (char* name, AIS_KindOfInteractive& TheType, - Standard_Integer& TheSign) -{ - char ** thefullnames = GetTypeNames2d(); - Standard_Integer index(-1); - - for (Standard_Integer i = 0; i <= 13 && index == -1; i++) - if (!strcasecmp(name, thefullnames[i])) - index = i; - - if (index == -1) - { - TheType = AIS_KOI_None; - TheSign = -1; - return; - } - - if (index <= 6) - { - TheType = AIS_KOI_Datum; - TheSign = index+1; - } - else if (index <= 9) - { - TheType = AIS_KOI_Shape; - TheSign = index-7; - } - else if (index <= 11) - { - TheType = AIS_KOI_Object; - TheSign = index-10; - } - else - { - TheType = AIS_KOI_Relation; - TheSign = index-12; - } -}*/ - -//======================================================================= -//function : Get Context and active view.. -//purpose : -//======================================================================= -void GetCtxAndView2d (Handle(AIS2D_InteractiveContext)& Ctx, - Handle(V2d_View)& Viou) -{ - Ctx = QAViewer2dTest::GetAIS2DContext(); - const Handle(V2d_Viewer)& Vwr = Ctx->CurrentViewer(); - Vwr->InitActiveViews(); - if (Vwr->MoreActiveViews()) - Viou = Vwr->ActiveView(); -} - -//============================================================================== -//function : GetShapeFromName2d -//purpose : Compute an Shape from a draw variable or a file name -//============================================================================== -TopoDS_Shape GetShapeFromName2d (char* name) -{ - TopoDS_Shape S = DBRep::Get(name); - - if (S.IsNull()) - { - BRep_Builder aBuilder; - BRepTools::Read( S, name, aBuilder); - } - - return S; -} -/* -//============================================================================== -//function : V2dDispAreas -//purpose : Redraw the view -//Draw arg : No args -//============================================================================== -static int V2dDispAreas (Draw_Interpretor& ,Standard_Integer , char** ) -{ - Handle(AIS2D_InteractiveContext) Ctx; - Handle(V2d_View) Viou; - GetCtxAndView2d(Ctx,Viou); -// Ctx->DisplayActiveAreas(Viou); - return 0; -} - -//============================================================================== -//function : V2dClearAreas -//purpose : Redraw the view -//Draw arg : No args -//============================================================================== -static int V2dClearAreas (Draw_Interpretor& ,Standard_Integer , char** ) -{ - Handle(AIS2D_InteractiveContext) Ctx; - Handle(V2d_View) Viou; - GetCtxAndView2d(Ctx,Viou); -// Ctx->ClearActiveAreas(Viou); - return 0; -} - -//============================================================================== -//function : V2dDispSensi -//purpose : -//Draw arg : No args -//============================================================================== -static int V2dDispSensi (Draw_Interpretor& ,Standard_Integer , char** ) -{ - Handle(AIS2D_InteractiveContext) Ctx; - Handle(V2d_View) Viou; - GetCtxAndView2d(Ctx,Viou); -// Ctx->DisplayActiveSensitive(Viou); - return 0; - -} - -//============================================================================== -//function : V2dClearSensi -//purpose : -//Draw arg : No args -//============================================================================== -static int V2dClearSensi (Draw_Interpretor& ,Standard_Integer , char** ) -{ - Handle(AIS2D_InteractiveContext) Ctx; - Handle(V2d_View) Viou; - GetCtxAndView2d(Ctx,Viou); -// Ctx->ClearActiveSensitive(Viou); - return 0; -} -*/ -//============================================================================== -//function : V2dDebug -//purpose : To list the displayed object with their attributes -//Draw arg : No args -//============================================================================== -static int V2dDebug (Draw_Interpretor& di, Standard_Integer , char** ) -{ - if (!QAViewer2dTest::CurrentView().IsNull()) - { - di << "List of object in the viewer :" << "\n"; - - QAViewer2dTest_DoubleMapIteratorOfDoubleMapOfInteractiveAndName it (GetMapOfAIS2D()); - - while (it.More()) - { - di << "\t" << it.Key2() << "\n"; - it.Next(); - } - } - - return 0; -} - -//======================================================================= -//function :V2dSubInt -//purpose : -//======================================================================= -/*static int V2dSubInt (Draw_Interpretor& , Standard_Integer argc, char** argv) -{ - if (argc == 1) return 1; - Standard_Integer On = atoi(argv[1]); - const Handle(AIS2D_InteractiveContext)& Ctx = QAViewer2dTest::GetAIS2DContext(); - - if (argc == 2) - { - if (!Ctx->HasOpenedContext()) - { - cout << "sub intensite "; - if (On == 1) cout << "On"; - else cout << "Off"; -// cout<<"pour "<NbCurrents()<<" objets"<InitCurrent();Ctx->MoreCurrent();Ctx->NextCurrent()) - { - if(On==1){ - Ctx->SubIntensityOn(Ctx->Current(),Standard_False);} - else{ - cout <<"passage dans off"<SubIntensityOff(Ctx->Current(),Standard_False); - } - } - } - else - { - for(Ctx->InitSelected();Ctx->MoreSelected();Ctx->NextSelected()){ - if(On==1){ - Ctx->SubIntensityOn(Ctx->Interactive(),Standard_False);} - else{ - Ctx->SubIntensityOff(Ctx->Interactive(),Standard_False);} - } - } - Ctx->UpdateCurrentViewer(); - } - else - { - Handle(AIS2D_InteractiveObject) IO; - TCollection_AsciiString name = argv[2]; - if (GetMapOfAIS2D().IsBound2(name)) - { - IO = GetMapOfAIS2D().Find2(name); - if (On == 1) Ctx->SubIntensityOn(IO); - else Ctx->SubIntensityOff(IO); - } - else return 1; - } - return 0; -}*/ - -//======================================================================= -//function : v2doffsetvlad -//purpose : check BUG PRO16483 -//======================================================================= -Standard_Integer v2doffsetvlad (Draw_Interpretor& , Standard_Integer , char** a) -{ - TopTools_ListOfShape ClosingFaces; - - TopoDS_Shape S = GetShapeFromName2d(a[1]); - ClosingFaces.Append(GetShapeFromName2d(a[2])); - Standard_Real offset = -Abs(atof(a[3])); - - TopoDS_Shape Result = BRepOffsetAPI_MakeThickSolid (S, ClosingFaces, offset, 1.e-05, - BRepOffset_Skin, Standard_True, - Standard_False, GeomAbs_Arc); - - Handle(AIS2D_InteractiveContext) Ctx = QAViewer2dTest::GetAIS2DContext(); - Handle(AIS2D_ProjShape) ais = new AIS2D_ProjShape(); - ais->Add(Result); - Ctx->Display(ais); - -// DBRep::Set("vlad", ais->Shape()); - - return 0; -} - -//======================================================================= -//function : v2doffsetvlad2 -//purpose : check BUG PRO16483 -//======================================================================= -Standard_Integer v2doffsetvlad2 (Draw_Interpretor& , Standard_Integer , char** a) -{ - TopTools_ListOfShape ClosingFaces; - - TopoDS_Shape S = GetShapeFromName2d(a[1]); - ClosingFaces.Append(GetShapeFromName2d(a[2])); - ClosingFaces.Append(GetShapeFromName2d(a[3])); - Standard_Real offset = -Abs(atof(a[4])); - - TopoDS_Shape Result = BRepOffsetAPI_MakeThickSolid (S, ClosingFaces, offset, 1.e-05, - BRepOffset_Skin, Standard_True, - Standard_False, GeomAbs_Arc); - - Handle(AIS2D_InteractiveContext) Ctx = QAViewer2dTest::GetAIS2DContext(); - Handle(AIS2D_ProjShape) ais = new AIS2D_ProjShape(); - ais->Add(Result); - Ctx->Display(ais); - -// DBRep::Set("vlad", ais->Shape()); - - return 0; -} - -//======================================================================= -//function : v2doffsetvlad3 -//purpose : check BUG PRO16483 -//======================================================================= -Standard_Integer v2doffsetvlad3 (Draw_Interpretor& , Standard_Integer , char** a) -{ - TopTools_ListOfShape ClosingFaces; - - TopoDS_Shape S = GetShapeFromName2d(a[1]); - ClosingFaces.Append(GetShapeFromName2d(a[2])); - ClosingFaces.Append(GetShapeFromName2d(a[3])); - ClosingFaces.Append(GetShapeFromName2d(a[4])); - Standard_Real offset = -Abs(atof(a[5])); - - TopoDS_Shape Result = BRepOffsetAPI_MakeThickSolid (S, ClosingFaces, offset, 1.e-05, - BRepOffset_Skin, Standard_True, - Standard_False, GeomAbs_Arc); - - Handle(AIS2D_InteractiveContext) Ctx = QAViewer2dTest::GetAIS2DContext(); - Handle(AIS2D_ProjShape) ais = new AIS2D_ProjShape(); - ais->Add(Result); - Ctx->Display(ais); - -// DBRep::Set("vlad", ais->Shape()); - - return 0; -} - -//======================================================================= -//function : v2dvlad -//purpose : -//======================================================================= -Standard_Integer v2dvlad (Draw_Interpretor& , Standard_Integer , char** a) -{ - ifstream s(a[1]); - BRep_Builder builder; - TopoDS_Shape shape; - BRepTools::Read(shape, s, builder); - DBRep::Set(a[1], shape); - Handle(AIS2D_InteractiveContext) Ctx = QAViewer2dTest::GetAIS2DContext(); - Handle(AIS2D_ProjShape) ais = new AIS2D_ProjShape(); - ais->Add(shape); - Ctx->Display(ais); - - return 0; -} - -//============================================================================== -//function : GetTypeNameFromShape2d -//purpose : get the shape type as a string from a shape -//============================================================================== -static char *GetTypeNameFromShape2d (const TopoDS_Shape& aShape) -{ - char *ret = "????"; - - if (aShape.IsNull()) ret = "Null Shape"; - - switch (aShape.ShapeType()) - { - case TopAbs_COMPOUND : ret = "COMPOUND" ; break; - case TopAbs_COMPSOLID : ret = "COMPSOLID" ; break; - case TopAbs_SOLID : ret = "SOLID" ; break; - case TopAbs_SHELL : ret = "SHELL" ; break; - case TopAbs_FACE : ret = "FACE" ; break; - case TopAbs_WIRE : ret = "WIRE" ; break; - case TopAbs_EDGE : ret = "EDGE" ; break; - case TopAbs_VERTEX : ret = "VERTEX" ; break; - case TopAbs_SHAPE : ret = "SHAPE" ; break; - } - return ret; -} - -//============================================================================== -//function : GetEnvir2d -//purpose : -//============================================================================== -/*static TCollection_AsciiString GetEnvir2d () -{ - static Standard_Boolean IsDefined = Standard_False ; - static TCollection_AsciiString VarName; - if (!IsDefined) - { - char *envir, *casroot ; - envir = getenv("CSF_MDTVTexturesDirectory") ; - - Standard_Boolean HasDefinition = Standard_False ; - if (!envir) - { - casroot = getenv("CASROOT"); - if (casroot) - { - VarName = TCollection_AsciiString (casroot); - VarName += "/src/Textures"; - HasDefinition = Standard_True; - } - } - else - { - VarName = TCollection_AsciiString(envir); - HasDefinition = Standard_True; - } - - if (HasDefinition) - { - OSD_Path aPath (VarName); - OSD_Directory aDir (aPath); - if (aDir.Exists()) - { - TCollection_AsciiString aTexture = VarName + "/2d_MatraDatavision.rgb"; - OSD_File TextureFile (aTexture); - if (!TextureFile.Exists()) - { - cout << " CSF_MDTVTexturesDirectory or CASROOT not correctly setted " << endl; - cout << " not all files are found in : "<CloseLocalContext(); - - Standard_Real Step = 4*M_PI/180; - Standard_Real Angle = 0; - - Handle(AIS2D_InteractiveObject) aIO; - aIO = GetMapOfAIS2D().Find2(argv[1]); - Handle(AIS2D_ProjShape) aShape = Handle(AIS2D_ProjShape)::DownCast(aIO); - - myTimer.Start(); - - if (atoi(argv[3]) == 1) - { - cout << " Primitives sensibles OFF" << endl; -// TheAIS2DContext()->Deactivate(aIO); - } - else - { - cout << " Primitives sensibles ON" << endl; - } - // Movement par transformation - if (atoi(argv[2]) == 1) - { - cout << " Calcul par Transformation" << endl; - for (Standard_Real myAngle = 0; Angle < 10*2*M_PI; myAngle++) - { - Angle = Step*myAngle; - gp_Trsf myTransfo; - myTransfo.SetRotation(gp_Ax1(gp_Pnt(0,0,0), gp_Dir(0,0,1)), Angle); -// TheAIS2DContext()->SetLocation(aShape,myTransfo); - TheAIS2DContext()->UpdateCurrentViewer(); - } - } - else - { - cout << " Calcul par Locations" << endl; - gp_Trsf myAngleTrsf; - myAngleTrsf.SetRotation(gp_Ax1(gp_Pnt(0,0,0), gp_Dir(0,0,1)), Step); - TopLoc_Location myDeltaAngle (myAngleTrsf); - TopLoc_Location myTrueLoc; - - for (Standard_Real myAngle = 0; Angle < 10*2*M_PI; myAngle++) - { - Angle = Step*myAngle; - myTrueLoc = myTrueLoc*myDeltaAngle; -// TheAIS2DContext()->SetLocation(aShape, myTrueLoc); - TheAIS2DContext()->UpdateCurrentViewer(); - } - } - if (atoi(argv[3]) == 1) - { - // On reactive la selection des primitives sensibles -// TheAIS2DContext()->Activate(aIO,0); - } -// QAViewer2dTest::CurrentView()->Redraw(); - myTimer.Stop(); - cout << " Temps ecoule " << endl; - myTimer.Show(); - return 0; -}*/ - -//================================================================================== -// Function : V2dAnimation -//================================================================================== -/*static int V2dAnimation (Draw_Interpretor& , Standard_Integer , char** ) -{ - Standard_Real thread = 4; - Standard_Real angleA = 0; - Standard_Real angleB; - Standard_Real X; - gp_Ax1 Ax1 (gp_Pnt(0,0,0), gp_Vec(0,0,1)); - - BRep_Builder B; - TopoDS_Shape CrankArm; - TopoDS_Shape CylinderHead; - TopoDS_Shape Propeller; - TopoDS_Shape EngineBlock; - - BRepTools::Read(CrankArm,"/dp_26/Indus/ege/assemblage/CrankArm.rle",B); - BRepTools::Read(CylinderHead,"/dp_26/Indus/ege/assemblage/CylinderHead.rle",B); - BRepTools::Read(Propeller,"/dp_26/Indus/ege/assemblage/Propeller.rle",B); - BRepTools::Read(EngineBlock,"/dp_26/Indus/ege/assemblage/EngineBlock.rle",B); - - if (CrankArm.IsNull() || CylinderHead.IsNull() || Propeller.IsNull() || EngineBlock.IsNull()) - { - cout << " Syntaxe error:loading failure." << endl; - } - - OSD_Timer myTimer; - myTimer.Start(); - - Handle(AIS2D_ProjShape) myAisCylinderHead = new AIS2D_ProjShape(); - Handle(AIS2D_ProjShape) myAisEngineBlock = new AIS2D_ProjShape(); - Handle(AIS2D_ProjShape) myAisCrankArm = new AIS2D_ProjShape(); - Handle(AIS2D_ProjShape) myAisPropeller = new AIS2D_ProjShape(); - - myAisCylinderHead->Add(CylinderHead); - myAisCylinderHead->Add(EngineBlock); - myAisCylinderHead->Add(CrankArm); - myAisCylinderHead->Add(Propeller); - - GetMapOfAIS2D().Bind(myAisCylinderHead,"a"); - GetMapOfAIS2D().Bind(myAisEngineBlock,"b"); - GetMapOfAIS2D().Bind(myAisCrankArm,"c"); - GetMapOfAIS2D().Bind(myAisPropeller,"d"); - -// TheAIS2DContext()->SetColor(myAisCylinderHead, Quantity_NOC_INDIANRED); -// TheAIS2DContext()->SetColor(myAisEngineBlock , Quantity_NOC_RED); -// TheAIS2DContext()->SetColor(myAisPropeller , Quantity_NOC_GREEN); - - TheAIS2DContext()->Display(myAisCylinderHead,Standard_False); - TheAIS2DContext()->Display(myAisEngineBlock,Standard_False ); - TheAIS2DContext()->Display(myAisCrankArm,Standard_False ); - TheAIS2DContext()->Display(myAisPropeller,Standard_False); - -// TheAIS2DContext()->Deactivate(myAisCylinderHead); -// TheAIS2DContext()->Deactivate(myAisEngineBlock ); -// TheAIS2DContext()->Deactivate(myAisCrankArm ); -// TheAIS2DContext()->Deactivate(myAisPropeller ); - - // Boucle de mouvement - for (Standard_Real myAngle = 0; angleA < 2*M_PI*10.175; myAngle++) - { - angleA = thread*myAngle*M_PI/180; - X = Sin(angleA)*3/8; - angleB = atan(X / Sqrt(-X * X + 1)); -// Standard_Real decal(25*0.6); - - //Build a transformation on the display - gp_Trsf aPropellerTrsf; - aPropellerTrsf.SetRotation(Ax1,angleA); -// TheAIS2DContext()->SetLocation(myAisPropeller,aPropellerTrsf); - -// gp_Ax3 base(gp_Pnt(3*decal*(1-Cos(angleA)),-3*decal*Sin(angleA),0),gp_Vec(0,0,1),gp_Vec(1,0,0)); -// gp_Trsf aCrankArmTrsf; -// aCrankArmTrsf.SetTransformation( base.Rotated(gp_Ax1(gp_Pnt(3*decal,0,0),gp_Dir(0,0,1)),angleB)); -// TheAIS2DContext()->SetLocation(myAisCrankArm,aCrankArmTrsf); - - TheAIS2DContext()->UpdateCurrentViewer(); - } - - TopoDS_Shape myNewCrankArm; //=myAisCrankArm ->Shape().Located(myAisCrankArm ->Location()); - TopoDS_Shape myNewPropeller; //=myAisPropeller->Shape().Located(myAisPropeller->Location()); - -// myAisCrankArm ->ResetLocation(); -// myAisPropeller->ResetLocation(); - -// myAisCrankArm ->Set(myNewCrankArm ); -// myAisPropeller->Set(myNewPropeller); - -// TheAIS2DContext()->Activate(myAisCylinderHead,0); -// TheAIS2DContext()->Activate(myAisEngineBlock,0 ); -// TheAIS2DContext()->Activate(myAisCrankArm ,0 ); -// TheAIS2DContext()->Activate(myAisPropeller ,0 ); - - myTimer.Stop(); - myTimer.Show(); - myTimer.Start(); - - TheAIS2DContext()->Redisplay(myAisCrankArm ,Standard_False); - TheAIS2DContext()->Redisplay(myAisPropeller,Standard_False); - - TheAIS2DContext()->UpdateCurrentViewer(); -// QAViewer2dTest::CurrentView()->Redraw(); - - myTimer.Stop(); - myTimer.Show(); - - return 0; -}*/ - -//============================================================================== -//function : HaveMode2d -//use : V2dActivatedModes -//============================================================================== -/*Standard_Boolean HaveMode2d (const Handle(AIS2D_InteractiveObject)& TheAisIO, const Standard_Integer mode) -{ -// TColStd_ListOfInteger List; -// TheAIS2DContext()->ActivatedModes (TheAisIO,List); -// TColStd_ListIteratorOfListOfInteger it; - Standard_Boolean Found=Standard_False; -// for (it.Initialize(List); it.More()&&!Found; it.Next() ){ -// if (it.Value()==mode ) Found=Standard_True; -// } - return Found; -}*/ - -//============================================================================== -//function : V2dActivatedMode -//purpose : permet d'attribuer a chacune des shapes un mode d'activation -// (edges,vertex...)qui lui est propre et le mode de selection standard. -// La fonction s'applique aux shapes selectionnees(current ou selected dans le viewer) -// Dans le cas ou on veut psser la shape en argument, la fonction n'autorise -// qu'un nom et qu'un mode. -//Draw arg : vsetam [ShapeName] mode(0,1,2,3,4,5,6,7) -//============================================================================== -//#include -/* -static int V2dActivatedMode (Draw_Interpretor& ,Standard_Integer argc,char** argv) -{ - Standard_Boolean HaveToSet; - Standard_Boolean ThereIsName = Standard_False ; - - if (!QAViewer2dTest::CurrentView().IsNull()) - { - if (!strcasecmp(argv[0],"vsetam")) HaveToSet = Standard_True; - else HaveToSet = Standard_False; - - // verification des arguments - if (HaveToSet) { - if (argc<2||argc>3) { cout<<" Syntaxe error"<1) {cout<<" Syntaxe error"<CloseLocalContext(); - } - - } - - - // IL n'y a aps de nom de shape passe en argument - if (HaveToSet && !ThereIsName){ - Standard_Integer aMode=atoi(argv [1]); - - char *cmode="???"; - - switch (aMode) { - case 0: cmode = "Shape"; break; - case 1: cmode = "Vertex"; break; - case 2: cmode = "Edge"; break; - case 3: cmode = "Wire"; break; - case 4: cmode = "Face"; break; - case 5: cmode = "Shell"; break; - case 6: cmode = "Solid"; break; - case 7: cmode = "Compound"; break; - } - - if( !TheAIS2DContext()->HasOpenedContext() ) { - // il n'y a pas de Context local d'ouvert - // on en ouvre un et on charge toutes les shapes displayees - // on load tous les objets displayees et on Activate les objets de la liste - AIS2D_ListOfInteractive ListOfIO; - // on sauve dans une AIS2DListOfInteractive tous les objets currents - if (TheAIS2DContext()->NbCurrents()>0 ){ - TheAIS2DContext()->UnhilightCurrents(Standard_False); - - for (TheAIS2DContext()->InitCurrent(); TheAIS2DContext()->MoreCurrent(); TheAIS2DContext()->NextCurrent() ){ - ListOfIO.Append(TheAIS2DContext()->Current() ); - - } - } - - TheAIS2DContext()->OpenLocalContext(Standard_False); - QAViewer2dTest_DoubleMapIteratorOfDoubleMapOfInteractiveAndName it (GetMapOfAIS2D()); - while(it.More()){ - Handle(AIS2D_InteractiveObject) aIO=it.Key1(); - TheAIS2DContext()->Load(aIO,0,Standard_False); - it.Next(); - } - // traitement des objets qui etaient currents dans le Contexte global - if (!ListOfIO.IsEmpty() ) { - // il y avait des objets currents - AIS2D_ListIteratorOfListOfInteractive iter; - for (iter.Initialize(ListOfIO); iter.More() ; iter.Next() ) { - Handle(AIS2D_InteractiveObject) aIO=iter.Value(); - TheAIS2DContext()->Activate(aIO,aMode); - cout<<" Mode: "<Activate(aIO,aMode); - it.Next(); - } - } - - } - - else { - // un Context local est deja ouvert - // Traitement des objets du Context local - if (TheAIS2DContext()->NbSelected()>0 ){ - TheAIS2DContext()->UnhilightSelected(Standard_False); - // il y a des objets selected,on les parcourt - for (TheAIS2DContext()->InitSelected(); TheAIS2DContext()->MoreSelected(); TheAIS2DContext()->NextSelected() ){ - Handle(AIS2D_InteractiveObject) aIO=TheAIS2DContext()->Interactive(); - - - if (HaveMode2d(aIO,aMode) ) { - cout<<" Mode: "<Deactivate(aIO,aMode); - } - else{ - cout<<" Mode: "<Activate(aIO,aMode); - } - - } - } - else{ - // il n'y a pas d'objets selected - // tous les objets diplayes sont traites - QAViewer2dTest_DoubleMapIteratorOfDoubleMapOfInteractiveAndName it (GetMapOfAIS2D()); - while(it.More()){ - Handle(AIS2D_InteractiveObject) aIO=it.Key1(); - if (HaveMode2d(aIO,aMode) ) { - cout<<" Mode: "<Deactivate(aIO,aMode); - } - else{ - cout<<" Mode: "<Activate(aIO,aMode); - } - it.Next(); - } - - } - } - } - else if (HaveToSet && ThereIsName){ - Standard_Integer aMode=atoi(argv [2]); - Handle(AIS2D_InteractiveObject) aIO=GetMapOfAIS2D().Find2(argv[1]); - - char *cmode="???"; - - switch (aMode) { - case 0: cmode = "Shape"; break; - case 1: cmode = "Vertex"; break; - case 2: cmode = "Edge"; break; - case 3: cmode = "Wire"; break; - case 4: cmode = "Face"; break; - case 5: cmode = "Shell"; break; - case 6: cmode = "Solid"; break; - case 7: cmode = "Compound"; break; - } - - if( !TheAIS2DContext()->HasOpenedContext() ) { - TheAIS2DContext()->OpenLocalContext(Standard_False); - // On charge tous les objets de la map - QAViewer2dTest_DoubleMapIteratorOfDoubleMapOfInteractiveAndName it (GetMapOfAIS2D()); - while(it.More()){ - Handle(AIS2D_InteractiveObject) aShape=it.Key1(); - TheAIS2DContext()->Load(aShape,0,Standard_False); - it.Next(); - } - TheAIS2DContext()->Activate(aIO,aMode); - cout<<" Mode: "<Deactivate(aIO,aMode); - } - else{ - cout<<" Mode: "<Activate(aIO,aMode); - } - } - - } - } - return 0; - -} -*/ - -//============================================================================== -//function : v2dtoto -//============================================================================== -#include -/*static int V2dToto (Draw_Interpretor& , Standard_Integer argc, char** ) -{ - cout << " Fonction toto" << endl; - Tcl_Interp *interp; - int code; - if (argc > 1) - { - cout << " Syntaxe error" << endl; - return 0; - } - interp = Tcl_CreateInterp(); - code = Tcl_EvalFile(interp,"/adv_12/DESIGN/k4dev/ege/work/test.tcl"); - //code= Tcl_Eval(interp,riri) - cout << *interp->result << endl; - return 0; -}*/ - -//============================================================================== -// function : WhoAmI -// user : vState -//============================================================================== -/*void WhoAmI (const Handle(AIS2D_InteractiveObject )& theShape ) { - - // AIS2D_Datum - if (theShape->Type()==AIS2D_KOI_Datum) { - if (theShape->Signature()==3 ) { cout<<" AIS2D_Trihedron"; } - else if (theShape->Signature()==2 ) { cout<<" AIS2D_Axis"; } - else if (theShape->Signature()==6 ) { cout<<" AIS2D_Circle"; } - else if (theShape->Signature()==5 ) { cout<<" AIS2D_Line"; } - else if (theShape->Signature()==7 ) { cout<<" AIS2D_Plane"; } - else if (theShape->Signature()==1 ) { cout<<" AIS2D_Point"; } - else if (theShape->Signature()==4 ) { cout<<" AIS2D_PlaneTrihedron"; } - } - // AIS2D_ProjShape - else if (theShape->Type()==AIS2D_KOI_Shape && theShape->Signature()==0 ) { cout<<" AIS2D_ProjShape"; } - // AIS2D_Dimentions et AIS2D_Relations - else if (theShape->Type()==AIS2D_KOI_Relation) { - Handle(AIS2D_Relation) TheShape= ((*(Handle(AIS2D_Relation)*)&theShape)); - - if (TheShape->KindOfDimension()==AIS2D_KOD_PLANEANGLE) {cout<<" AIS2D_AngleDimension";} - else if (TheShape->KindOfDimension()==AIS2D_KOD_LENGTH ) {cout<<" AIS2D_Chamf2/3dDimension/AIS2D_LengthDimension "; } - else if (TheShape->KindOfDimension()==AIS2D_KOD_DIAMETER ) {cout<<" AIS2D_DiameterDimension ";} - else if (TheShape->KindOfDimension()==AIS2D_KOD_ELLIPSERADIUS ) {cout<<" AIS2D_EllipseRadiusDimension ";} - //else if (TheShape->KindOfDimension()==AIS2D_KOD_FILLETRADIUS ) {cout<<" AIS2D_FilletRadiusDimension "<KindOfDimension()==AIS2D_KOD_OFFSET ) {cout<<" AIS2D_OffsetDimension ";} - else if (TheShape->KindOfDimension()==AIS2D_KOD_RADIUS ) {cout<<" AIS2D_RadiusDimension ";} - // AIS2D no repertorie. - else {cout<<" Type Unknown.";} - } -}*/ - -//============================================================================== -//function : V2dState -//purpose : -//Draw arg : v2dstate [nameA] ... [nameN] -//============================================================================== -/*static int V2dState (Draw_Interpretor& , Standard_Integer argc, char** argv) -{ - Standard_Boolean ThereIsCurrent = Standard_False; - Standard_Boolean ThereIsArguments = Standard_False; - TheAIS2DContext()->CloseAllContext(); - if (argc >= 2 ) - { - ThereIsArguments = Standard_True; - } -// if (TheAIS2DContext()->NbCurrents()>0 ) { -// ThereIsCurrent=Standard_True; -// } - - if (ThereIsArguments) - { - for (int cpt = 1; cpt < argc; cpt++) - { - // Verification que lq piece est bien bindee. - if (GetMapOfAIS2D().IsBound2(argv[cpt])) - { - Handle(AIS2D_InteractiveObject) theShape = GetMapOfAIS2D().Find2(argv[cpt]); - cout << argv[cpt]; -// WhoAmI(theShape); - if (TheAIS2DContext()->IsDisplayed(theShape)) - { - cout << " Displayed" << endl; - } - else - { - cout << " Not Displayed" << endl; - } - } - else - { - cout << "vstate error: Shape " << cpt << " doesn't exist;" << endl; - return 1; - } - } - } - else if (ThereIsCurrent) - { - for (TheAIS2DContext() -> InitCurrent() ; TheAIS2DContext() -> MoreCurrent() ; TheAIS2DContext() ->NextCurrent() ) - { - Handle(AIS2D_InteractiveObject) theShape=TheAIS2DContext()->Current(); - cout<IsDisplayed(theShape) ) { - cout<<" Displayed"<IsDisplayed(theShape)) - { - cout << " Displayed" << endl; - } - else - { - cout << " Not Displayed" << endl; - } - it.Next(); - } - } - - return 0; -}*/ - -//======================================================================= -//function : V2dPickShape -//purpose : -//======================================================================= -/*static int V2dPickShape (Draw_Interpretor& , Standard_Integer argc, char** argv) -{ - TopoDS_Shape PickSh; - TopAbs_ShapeEnum theType = TopAbs_COMPOUND; - - if (argc == 1) theType = TopAbs_SHAPE; - else - { - if (!strcasecmp(argv[1],"V" )) theType = TopAbs_VERTEX; - else if (!strcasecmp(argv[1],"E" )) theType = TopAbs_EDGE; - else if (!strcasecmp(argv[1],"W" )) theType = TopAbs_WIRE; - else if (!strcasecmp(argv[1],"F" )) theType = TopAbs_FACE; - else if (!strcasecmp(argv[1],"SHAPE" )) theType = TopAbs_SHAPE; - else if (!strcasecmp(argv[1],"SHELL" )) theType = TopAbs_SHELL; - else if (!strcasecmp(argv[1],"SOLID" )) theType = TopAbs_SOLID; - } - - static Standard_Integer nbOfSub[8] = {0,0,0,0,0,0,0,0}; - static TCollection_AsciiString nameType[8] = {"COMPS","SOL","SHE","F","W","E","V","SHAP"}; - - TCollection_AsciiString name; - - Standard_Integer NbToPick = argc>2 ? argc-2 : 1; - if (NbToPick == 1) - { - PickSh = QAViewer2dTest::PickShape(theType); - - if (PickSh.IsNull()) return 1; - if (argc > 2) - { - name += argv[2]; - } - else - { - if (!PickSh.IsNull()) - { - nbOfSub[Standard_Integer(theType)]++; - name += "Picked_"; - name += nameType[Standard_Integer(theType)]; - TCollection_AsciiString indxstring(nbOfSub[Standard_Integer(theType)]); - name +="_"; - name+=indxstring; - } - } - // si on avait une petite methode pour voir si la shape - // est deja dans la Double map, ca eviterait de creer.... - DBRep::Set(name.ToCString(),PickSh); - - Handle(AIS2D_ProjShape) newsh = new AIS2D_ProjShape(); - newsh->Add(PickSh); - GetMapOfAIS2D().Bind(newsh, name); - TheAIS2DContext()->Display(newsh); - cout << "Nom de la shape pickee : " << name << endl; - } - - // Plusieurs objets a picker, vite vite vite.... - // - else - { - Standard_Boolean autonaming = !strcasecmp(argv[2],"."); - Handle(TopTools_HArray1OfShape) arr = new TopTools_HArray1OfShape(1,NbToPick); - if (QAViewer2dTest::PickShapes(theType,arr)) - { - for (Standard_Integer i = 1; i <= NbToPick; i++) - { - PickSh = arr->Value(i); - if (!PickSh.IsNull()) - { - if (autonaming) - { - nbOfSub[Standard_Integer(theType)]++; - name.Clear(); - name += "Picked_"; - name += nameType[Standard_Integer(theType)]; - TCollection_AsciiString indxstring (nbOfSub[Standard_Integer(theType)]); - name +="_"; - name+=indxstring; - } - } - else - name = argv[1+i]; - - DBRep::Set(name.ToCString(),PickSh); - Handle(AIS2D_ProjShape) newsh = new AIS2D_ProjShape(); - newsh->Add(PickSh); - GetMapOfAIS2D().Bind(newsh, name); - cout << "display of picke shape #" << i << " - nom : " << name << endl; - TheAIS2DContext()->Display(newsh); - } - } - } - - return 0; -}*/ - -//======================================================================= -//function : V2dIOTypes -//purpose : list of known objects -//======================================================================= -/*static int V2dIOTypes (Draw_Interpretor& , Standard_Integer , char** ) -{ - // 1234567890 12345678901234567 123456789 - TCollection_AsciiString Colum [3] = {"Standard Types","Type Of Object","Signature"}; - TCollection_AsciiString BlankLine(64, '_'); - Standard_Integer i; - - cout << "/n" << BlankLine << endl; - - for (i = 0; i <= 2; i++) Colum[i].Center(20,' '); - for (i = 0; i <= 2; i++) cout << "|" << Colum[i]; - cout << "|" << endl; - - cout << BlankLine << endl; - - // TCollection_AsciiString thetypes[5]={"Datum","Shape","Object","Relation","None"}; - char ** names = GetTypeNames2d(); - - TCollection_AsciiString curstring; - TCollection_AsciiString curcolum[3]; - - // les objets de type Datum.. - curcolum[1] += "Datum"; - for (i = 0; i <= 6; i++) - { - curcolum[0].Clear(); - curcolum[0] += names[i]; - - curcolum[2].Clear(); - curcolum[2]+=TCollection_AsciiString(i+1); - - for (Standard_Integer j = 0; j <= 2; j++) - { - curcolum[j].Center(20,' '); - cout << "|" << curcolum[j]; - } - cout << "|" << endl; - } - cout << BlankLine << endl; - - // les objets de type shape - curcolum[1].Clear(); - curcolum[1] += "Shape"; - curcolum[1].Center(20,' '); - - for (i = 0; i <= 2; i++) - { - curcolum[0].Clear(); - curcolum[0] += names[7+i]; - curcolum[2].Clear(); - curcolum[2] += TCollection_AsciiString(i); - - for (Standard_Integer j = 0; j <= 2; j++) - { - curcolum[j].Center(20,' '); - cout << "|" << curcolum[j]; - } - cout << "|" << endl; - } - cout << BlankLine << endl; - // les IO de type objet... - curcolum[1].Clear(); - curcolum[1] += "Object"; - curcolum[1].Center(20,' '); - for (i = 0;i <= 1; i++) - { - curcolum[0].Clear(); - curcolum[0] += names[10+i]; - curcolum[2].Clear(); - curcolum[2] += TCollection_AsciiString(i); - - for (Standard_Integer j = 0; j <= 2; j++) - { - curcolum[j].Center(20,' '); - cout << "|" << curcolum[j]; - } - cout << "|" << endl; - } - cout << BlankLine << endl; - - // les contraintes et dimensions. - // pour l'instant on separe juste contraintes et dimensions... - // plus tard, on detaillera toutes les sortes... - curcolum[1].Clear(); - curcolum[1] += "Relation"; - curcolum[1].Center(20,' '); - for (i = 0; i <= 1; i++) - { - curcolum[0].Clear(); - curcolum[0] += names[12+i]; - curcolum[2].Clear(); - curcolum[2] += TCollection_AsciiString(i); - - for (Standard_Integer j = 0; j <= 2; j++) - { - curcolum[j].Center(20,' '); - cout << "|" << curcolum[j]; - } - cout << "|" << endl; - } - cout << BlankLine << endl; - - return 0; -}*/ - -//======================================================================= -//function : v2dr -//purpose : reading of the shape -//======================================================================= -/*static Standard_Integer v2dr (Draw_Interpretor& , Standard_Integer , char** a) -{ - ifstream s (a[1]); - BRep_Builder builder; - TopoDS_Shape shape; - BRepTools::Read(shape, s, builder); - DBRep::Set(a[1], shape); - Handle(AIS2D_InteractiveContext) Ctx = QAViewer2dTest::GetAIS2DContext(); - Handle(AIS2D_ProjShape) ais = new AIS2D_ProjShape(); - ais->Add(shape); - Ctx->Display(ais); - return 0; -}*/ - -//============================================================================== -//function : QAViewer2dTest::GeneralCommands -//purpose : Add all the general commands in the Draw_Interpretor -//============================================================================== -void QAViewer2dTest::GeneralCommands (Draw_Interpretor& theCommands) -{ - char *group = "2D AIS Viewer"; - - theCommands.Add("v2ddir", - "v2ddir - list interactive objects", - __FILE__, V2dDebug, group); - -/* theCommands.Add("v2dsub", - "v2dsub 0/1(off/on) [obj] : Subintensity(on/off) of selected objects", - __FILE__, V2dSubInt, group); - - theCommands.Add("v2dardis", - "v2dardis : Display active areas", - __FILE__, V2dDispAreas, group); - - theCommands.Add("v2darera", - "v2darera : Erase active areas", - __FILE__, V2dClearAreas, group); - - theCommands.Add("v2dsensdis", - "v2dsensdis : display active entities", - __FILE__, V2dDispSensi, group); - - theCommands.Add("v2dsensera", - "v2dsensera : erase active entities", - __FILE__, V2dClearSensi, group); - - theCommands.Add("v2dperf", - "v2dperf ShapeName 1/0(Transfo/Location) 1/0(Primitives sensibles ON/OFF)", - __FILE__, V2dPerf, group); - - theCommands.Add("v2danimation", - "v2danimation", - __FILE__, V2dAnimation, group); -*/ -/*theCommands.Add("v2dtexscale", - "'v2dtexscale NameOfShape ScaleU ScaleV' \n \ - or 'vtexscale NameOfShape ScaleUV' \n \ - or 'vtexscale NameOfShape' to disable scaling\n", - __FILE__,VTexture,group); - - theCommands.Add("v2dtexorigin", - "'v2dtexorigin NameOfShape UOrigin VOrigin' \n \ - or 'vtexorigin NameOfShape UVOrigin' \n \ - or 'vtexorigin NameOfShape' to disable origin positioning\n", - __FILE__,VTexture,group); - - theCommands.Add("v2dtexrepeat", - "'v2dtexrepeat NameOfShape URepeat VRepeat' \n \ - or 'vtexrepeat NameOfShape UVRepeat \n \ - or 'vtexrepeat NameOfShape' to disable texture repeat \n ", - VTexture,group); - - theCommands.Add("v2dtexdefault", - "'v2dtexdefault NameOfShape' to set texture mapping default parameters \n", - VTexture,group);*/ - -// theCommands.Add("v2dsetam", -// "v2dsetActivatedModes: vsetam mode(1->7)", -// __FILE__,VActivatedMode,group); - -// theCommands.Add("v2dunsetam", -// "v2dunsetActivatedModes: vunsetam", -// __FILE__,VActivatedMode,group); - -/* theCommands.Add("v2dtoto", - "v2dtoto", - __FILE__, V2dToto, group); - - theCommands.Add("v2dstate", - "vstate [Name1] ... [NameN] : No arg, select currents; no currrent select all", - __FILE__,V2dState,group); - - theCommands.Add("v2dpickshapes", - "v2dpickshape subtype(VERTEX,EDGE,WIRE,FACE,SHELL,SOLID) [name1 or .] [name2 or .] [name n or .]", - __FILE__, V2dPickShape, group); - - theCommands.Add("v2dtypes", - "v2dtypes : list of known types and signatures in AIS2D - To be Used in vpickobject command for selection with filters", - V2dIOTypes,group); - - theCommands.Add("v2dr", - "v2dr : reading of the shape", - __FILE__, v2dr, group); - - theCommands.Add("v2doffsetvlad", - "v2doffsetvlad shape offsettedface offsetvalue", - __FILE__, v2doffsetvlad, group); - - theCommands.Add("v2doffsetvlad2", - "v2doffsetvlad2 shape offsettedface1 offsettedface2 offsetvalue", - __FILE__, v2doffsetvlad2, group); - - theCommands.Add("v2doffsetvlad3", - "v2doffsetvlad3 shape offsettedface1 offsettedface2 offsettedface3 offsetvalue", - __FILE__, v2doffsetvlad3, group); - - theCommands.Add("v2dvlad", - "v2dvlad shape", - __FILE__, v2dvlad, group);*/ -} -#endif diff --git a/src/QAViewer2dTest/QAViewer2dTest_ObjectCommands.cxx b/src/QAViewer2dTest/QAViewer2dTest_ObjectCommands.cxx deleted file mode 100755 index 47d05940cb..0000000000 --- a/src/QAViewer2dTest/QAViewer2dTest_ObjectCommands.cxx +++ /dev/null @@ -1,1609 +0,0 @@ -// Copyright (c) 1999-2012 OPEN CASCADE SAS -// -// The content of this file is subject to the Open CASCADE Technology Public -// License Version 6.5 (the "License"). You may not use the content of this file -// except in compliance with the License. Please obtain a copy of the License -// at http://www.opencascade.org and read it completely before using this file. -// -// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its -// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. -// -// The Original Code and all software distributed under the License is -// distributed on an "AS IS" basis, without warranty of any kind, and the -// Initial Developer hereby disclaims all such warranties, including without -// limitation, any warranties of merchantability, fitness for a particular -// purpose or non-infringement. Please see the License for the specific terms -// and conditions governing the rights and limitations under the License. - -#if defined(WOKC40) - -//=============================================== -// AIS2D Objects Creation : Datums (axis,trihedrons,lines,planes) -//=============================================== - -#ifdef HAVE_CONFIG_H -# include -#endif - -#include - -#include - -#include - -#include -#include -#include -#include - -#include -#include -#include - -#include -#include -#include - -#include -#include -#include - -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include - -#include - -#include -#include - -#include -#include - -#include -#include - -#include -#include -#include -#include -#include - -#include -#include - -#include - -extern QAViewer2dTest_DoubleMapOfInteractiveAndName& GetMapOfAIS2D(); -Standard_IMPORT int ViewerMainLoop2d (Standard_Integer argc, char** argv); -extern Handle(AIS2D_InteractiveContext)& TheAIS2DContext(); - -//============================================================================== -//function : SelectShape2d -//purpose : -//============================================================================== -TopoDS_Shape SelectShape2d (int theSelType) -{ - TopoDS_Shape ShapeA; - -// if (theSelType != 5) -// TheAIS2DContext()->ActivateStandardMode(AIS2D_ProjShape::SelectionType(theSelType)); - - switch (theSelType) - { - case 1: - cout << " Select a vertex ..." << endl; - break; - case 2: - cout << " Select an edge ..." << endl; - break; - case 4: - cout << " Select a face ..." << endl; - break; - case 5: // user defined text - break; - default: - cout << " Incorrect selection mode" << endl; - break; - } - - Standard_Integer argcc = 5; - char *buff[] = { "VPick", "X", "VPickY","VPickZ", "VPickShape" }; - char **argvv = (char **) buff; - while (ViewerMainLoop2d(argcc, argvv)) {} - -/* for (TheAIS2DContext()->InitSelected(); - TheAIS2DContext()->MoreSelected(); - TheAIS2DContext()->NextSelected()) - { - ShapeA = TheAIS2DContext()->SelectedShape(); - }*/ - -// if (theSelType != 5) -// TheAIS2DContext()->DeactivateStandardMode(AIS2D_ProjShape::SelectionType(theSelType)); - - return ShapeA; -} -#if 0 -//============================================================================== -//function : V2dTrihedron2D -//purpose : Create a plane with a 2D trihedron from a faceselection -//Draw arg : v2dtri2d name -//============================================================================== -static int V2dTrihedron2D (Draw_Interpretor& , Standard_Integer argc, char** argv) -{ - if (argc != 2) - { - cout << argv[0] << " wrong arguments number" << endl; - return 1; - } - - // Declarations - Standard_Integer myCurrentIndex; - - // Fermeture des contextes - TheAIS2DContext()->CloseAllContext(); - - // Ouverture d'un contexte local et recuperation de son index. - TheAIS2DContext()->OpenLocalContext(); - myCurrentIndex = TheAIS2DContext()->IndexOfCurrentLocal(); - - TopoDS_Shape ShapeB = SelectShape2d(4); // Face - TopoDS_Face FaceB = TopoDS::Face(ShapeB); - - // Construction du Plane - // recuperation des edges des faces. - TopExp_Explorer FaceExpB (FaceB, TopAbs_EDGE); - - TopoDS_Edge EdgeB = TopoDS::Edge(FaceExpB.Current()); - - // declarations - gp_Pnt A,B,C; - - // si il y a plusieurs edges - if (FaceExpB.More()) - { - FaceExpB.Next(); - TopoDS_Edge EdgeC = TopoDS::Edge(FaceExpB.Current()); - BRepAdaptor_Curve theCurveB (EdgeB); - BRepAdaptor_Curve theCurveC (EdgeC); - A = theCurveC.Value(0.1); - B = theCurveC.Value(0.9); - C = theCurveB.Value(0.5); - } - else - { - // FaceB a 1 unique edge courbe - BRepAdaptor_Curve theCurveB (EdgeB); - A = theCurveB.Value(0.1); - B = theCurveB.Value(0.9); - C = theCurveB.Value(0.5); - } - // Construction du Geom_Plane - GC_MakePlane MkPlane (A,B,C); - Handle(Geom_Plane) theGeomPlane = MkPlane.Value(); - - // Construction de l'AIS2D_PlaneTrihedron -// Handle(AIS2D_PlaneTrihedron) theAIS2DPlaneTri = new AIS2D_PlaneTrihedron(theGeomPlane); - - // Fermeture du contexte local. - TheAIS2DContext()->CloseLocalContext(myCurrentIndex); - - // on le display & bind -// TheAIS2DContext()->Display(theAIS2DPlaneTri); -// GetMapOfAIS2D().Bind(theAIS2DPlaneTri, argv[1]); - - return 0; -} -#endif - -//============================================================================== -//function : V2dTrihedron -//purpose : Create a trihedron. If no arguments are set, the default -// trihedron (Oxyz) is created. -//Draw arg : vtrihedron name [Xo] [Yo] [Zo] [Zu] [Zv] [Zw] [Xu] [Xv] [Xw] -//============================================================================== -/*static int V2dTrihedron (Draw_Interpretor& , Standard_Integer argc, char** argv) -{ - // Verification des arguments - if (argc < 2 || argc > 11) - { - cout << argv[0] << " Syntaxe error" << endl; - return 1; - } - - TCollection_AsciiString name = argv[1]; - - if (argc > 5 && argc != 11) - { - cout << argv[0] << " Syntaxe error" << endl; - return 1; - } - - Standard_Real coord[9] = {0.,0.,0.,0.,0.,1.,1.,0.,0.}; - if (argc > 2) - { - Standard_Integer i; - for (i = 0; i <= 2; i++) - coord[i] = atof(argv[2+i]); - - if (argc > 5) - { - for (i = 0; i <= 2; i++) - { - coord[3+i] = atof(argv[6+i]); - coord[6+i] = atof(argv[8+i]); - } - } - } - gp_Pnt ThePoint (coord[0],coord[1],coord[2]); - gp_Dir TheZVector (coord[3],coord[4],coord[5]); - gp_Dir TheXVector (coord[6],coord[7],coord[8]); - - if (!TheZVector.IsNormal(TheXVector,M_PI/180)) - { - cout << argv[0] << " VectorX is not normal to VectorZ" << endl; - return 1; - } - - Handle(Geom_Axis2Placement) OrigineAndAxii = new Geom_Axis2Placement(ThePoint,TheZVector,TheXVector); - - // Creation du triedre - Handle(AIS2D_Trihedron) aShape = new AIS2D_Trihedron(OrigineAndAxii); - GetMapOfAIS2D().Bind(aShape,name); - TheAIS2DContext()->Display(aShape); - - return 0; -}*/ -#if 0 -//============================================================================== -//function : V2dSize -//purpose : Change the size of a named or selected trihedron -// if no name : it affects the trihedrons witch are selected otherwise nothing is donne -// if no value, the value is set at 100 by default -//Draw arg : v2dsize [name] [size] -//============================================================================== -static int V2dSize (Draw_Interpretor& , Standard_Integer argc, char** argv) -{ - Standard_Boolean ThereIsName; - Standard_Real value; - // Quantity_NameOfColor col = Quantity_NOC_BLACK; - - if (argc > 3) - { - cout << argv[0] << " Syntaxe error" << endl; - return 1; - } - - if (argc == 1) - { - ThereIsName = Standard_False; - value = 100; - } - else if (argc == 2) - { - ThereIsName = Standard_False; - value = atof(argv[1]); - } - else - { - ThereIsName = Standard_True; - value = atof(argv[2]); - } - - if (TheAIS2DContext()->HasOpenedContext()) TheAIS2DContext()->CloseLocalContext(); - - if (!ThereIsName) - { -// if (TheAIS2DContext()->NbCurrents() <= 0) return -1; - QAViewer2dTest_DoubleMapIteratorOfDoubleMapOfInteractiveAndName it (GetMapOfAIS2D()); - - while (it.More()) - { - Handle(AIS2D_InteractiveObject) aShape = it.Key1(); - - if (TheAIS2DContext()->IsCurrent(aShape)) - { -/* if (aShape->Type() == AIS2D_KOI_Datum && aShape->Signature() == 3) - { - if (aShape->HasColor()) - { - hascol = Standard_True; - col = aShape->Color(); - } - else hascol = Standard_False; - - Handle(AIS2D_Trihedron) aTrihedron = *(Handle(AIS2D_Trihedron)*) &aShape; - - aTrihedron->SetSize(value); - - if (hascol) aTrihedron->SetColor(col); - else aTrihedron->UnsetColor(); - - // The trihedron hasn't be errased from the map - // so you just have to redisplay it - TheAIS2DContext()->Redisplay(aTrihedron, Standard_False); - }*/ - } - it.Next(); - } - TheAIS2DContext()->UpdateCurrentViewer(); - } - else - { - TCollection_AsciiString name = argv[1]; - - if (GetMapOfAIS2D().IsBound2(name)) - { - Handle(AIS2D_InteractiveObject) aShape = GetMapOfAIS2D().Find2(name); - -/* if (aShape->Type() == AIS2D_KOI_Datum && aShape->Signature() == 3) - { - if (aShape->HasColor()) - { - hascol = Standard_True; - col = aShape->Color(); - } - else hascol = Standard_False; - - // On downcast aShape de AIS2D_InteractiveObject a AIS2D_Trihedron - // pour lui appliquer la methode SetSize() - Handle(AIS2D_Trihedron) aTrihedron = *(Handle(AIS2D_Trihedron)*) &aShape; - - aTrihedron->SetSize(value); - - if (hascol) aTrihedron->SetColor(col); - else aTrihedron->UnsetColor(); - - // The trihedron hasn't be errased from the map - // so you just have to redisplay it - TheAIS2DContext()->Redisplay(aTrihedron, Standard_False); - - TheAIS2DContext()->UpdateCurrentViewer(); - }*/ - } - } - return 0; -} -#endif - -//============================================================================== -//function : V2dPlaneTrihedron -//purpose : Create a plane from a trihedron selection. If no arguments are set, the default -//Draw arg : v2dplanetri name -//============================================================================== -/*static int V2dPlaneTrihedron (Draw_Interpretor& , Standard_Integer argc, char** argv) -{ - if (argc != 2) - { - cout << argv[0] << " error" << endl; - return 1; - } - - Standard_Integer myCurrentIndex; - TheAIS2DContext()->CloseAllContexts(); - TheAIS2DContext()->OpenLocalContext(Standard_False); - myCurrentIndex = TheAIS2DContext()->IndexOfCurrentLocal(); - - QAViewer2dTest_DoubleMapIteratorOfDoubleMapOfInteractiveAndName it (GetMapOfAIS2D()); - while (it.More()) - { - Handle(AIS2D_InteractiveObject) ShapeA = it.Key1(); - if (ShapeA->Type() == AIS2D_KOI_Datum && ShapeA->Signature() == 3) - { - Handle(AIS2D_Trihedron) TrihedronA = ((*(Handle(AIS2D_Trihedron)*)&ShapeA)); - TheAIS2DContext()->Load(TrihedronA,0,Standard_False); - TheAIS2DContext()->Activate(TrihedronA,3); - } - it.Next(); - } - - cout<<" Select a plane."<InitSelected(); - TheAIS2DContext()->MoreSelected(); TheAIS2DContext()->NextSelected()) - { - theIOB = TheAIS2DContext()->Interactive(); - } - Handle(AIS2D_Plane) PlaneB = ((*(Handle(AIS2D_Plane)*)&theIOB)); - - TheAIS2DContext()->CloseLocalContext(myCurrentIndex); - - // Construction de l'AIS2D_Plane - //gp_Pnt A,B,C; - //Handle(Geom_Plane) theGeomPlane; - //PlaneB->PlaneAttributes(theGeomPlane,A,B,C); - //Handle(AIS2D_PlaneTrihedron) theAIS2DPlaneTri= new AIS2D_PlaneTrihedron(theGeomPlane ); - - // on le display & bind - TheAIS2DContext()->Display(PlaneB); - GetMapOfAIS2D().Bind(PlaneB, argv[1]); - - return 0; -}*/ - -//============================================================================== -// Fonction First click 2de click -// -// v2daxis vertex vertex -// edge None -// v2daxispara edge vertex -// v2daxisortho edge Vertex -// v2daxisinter Face Face -//============================================================================== - -//============================================================================== -//function : V2dAxisBuilder -//purpose : -//Draw arg : v2daxis AxisName Xa Ya Xb Yb -//============================================================================== -static int V2dAxisBuilder (Draw_Interpretor& , Standard_Integer argc, char** argv) -{ - Standard_Boolean HasArg; - TCollection_AsciiString name; - Standard_Integer MyCurrentIndex; - - if (argc < 2 || argc > 6) - { - cout << " Syntaxe error" << endl; - return 1; - } - if (argc == 6) HasArg = Standard_True; - else HasArg = Standard_False; - - name = argv[1]; - TheAIS2DContext()->CloseAllContext(); - - Handle(V2d_View) V = QAViewer2dTest::CurrentView(); - - if (HasArg) - { - Standard_Real coord [4]; - for (Standard_Integer i = 0; i <= 3; i++) - { - coord[i] = atof(argv[2+i]); - } -// gp_Pnt2d p1 (coord[0],coord[1]); -// gp_Pnt2d p2 (coord[2],coord[3]); - - Handle(Graphic2d_GraphicObject) obj = - new Graphic2d_GraphicObject(V->View()); - - Handle(Graphic2d_InfiniteLine) line = new Graphic2d_InfiniteLine - (obj, coord[0], coord[1], coord[2] - coord[0], coord[3] - coord[1]); - - obj->Display(); - V->Viewer()->Update(); -// gp_Vec2d myVect (p1, p2); -// Handle(Geom2d_Line) myLine = new Geom2d_Line(p1, myVect); -// Handle(AIS2D_Axis) TheAxis = new AIS2D_Axis(myLine); -// GetMapOfAIS2D().Bind(TheAxis,name); -// TheAIS2DContext()->Display(TheAxis); - } - else - { - // fonction vaxis - // Purpose: Teste le constructeur AIS2D_Axis::AIS2D_Axis (x:Axis1Placement from Geom) - if (!strcasecmp(argv[0], "v2daxis")) - { - TheAIS2DContext()->OpenLocalContext(); - MyCurrentIndex = TheAIS2DContext()->IndexOfCurrentLocal(); - - // Active le mode edge et le mode vertex -// TheAIS2DContext()->ActivateStandardMode(AIS2D_ProjShape::SelectionType(1)); -// TheAIS2DContext()->ActivateStandardMode(AIS2D_ProjShape::SelectionType(2)); - cout << " Select an edge or a vertex." << endl; - - TopoDS_Shape ShapeA = SelectShape2d(5); - - if (ShapeA.ShapeType() == TopAbs_VERTEX) - { -// TheAIS2DContext()->DeactivateStandardMode(AIS2D_ProjShape::SelectionType(2)); - cout << " Select a different vertex." << endl; - - TopoDS_Shape ShapeB; - do - { - ShapeB = SelectShape2d(5); - } while (ShapeB.IsSame(ShapeA)); - - TheAIS2DContext()->CloseLocalContext(MyCurrentIndex); - - // Construction de l'axe - gp_Pnt A = BRep_Tool::Pnt(TopoDS::Vertex(ShapeA)); - gp_Pnt B = BRep_Tool::Pnt(TopoDS::Vertex(ShapeB)); - gp_Vec aV (A,B); - gp_Dir D (aV); - Handle(Geom_Axis1Placement) OrigineAndVect = new Geom_Axis1Placement(A,D); -// Handle(AIS2D_Axis) TheAxis = new AIS2D_Axis(OrigineAndVect); -// GetMapOfAIS2D().Bind(TheAxis,name); -// TheAIS2DContext()->Display(TheAxis); - } - else - { - // Un unique edge (ShapeA) a ete picke - // Fermeture du context local - TheAIS2DContext()->CloseLocalContext(MyCurrentIndex); - // Constuction de l'axe - TopoDS_Edge ed = TopoDS::Edge(ShapeA); - TopoDS_Vertex Va,Vb; - TopExp::Vertices(ed,Va,Vb ); - gp_Pnt A = BRep_Tool::Pnt(Va); - gp_Pnt B = BRep_Tool::Pnt(Vb); - gp_Vec aV (A,B); - gp_Dir D (aV); - Handle(Geom_Axis1Placement) OrigineAndVect = new Geom_Axis1Placement(A,D); -// Handle(AIS2D_Axis) TheAxis = new AIS2D_Axis(OrigineAndVect); -// GetMapOfAIS2D().Bind(TheAxis,name); -// TheAIS2DContext()->Display(TheAxis); - } - } - - // Fonction axispara - // Purpose: Teste le constructeur AIS2D_Axis::AIS2D_Axis(x: Axis2Placement from Geom, y: TypeOfAxis from AIS2D) - else if (!strcasecmp(argv[0], "v2daxispara")) - { - TheAIS2DContext()->OpenLocalContext(); - MyCurrentIndex = TheAIS2DContext()->IndexOfCurrentLocal(); - - TopoDS_Shape ShapeA = SelectShape2d(2); // Edge - TopoDS_Shape ShapeB = SelectShape2d(1); // Vertex - - // Fermeture du context local - TheAIS2DContext()->CloseLocalContext(MyCurrentIndex); - - // Construction de l'axe - TopoDS_Edge ed = TopoDS::Edge(ShapeA); - gp_Pnt B = BRep_Tool::Pnt(TopoDS::Vertex(ShapeB)); - TopoDS_Vertex Va,Vc; - TopExp::Vertices(ed,Va,Vc); - gp_Pnt A = BRep_Tool::Pnt(Va); - gp_Pnt C = BRep_Tool::Pnt(Vc); - gp_Vec aV (A,C); - gp_Dir D (aV); - Handle(Geom_Axis1Placement) OrigineAndVect = new Geom_Axis1Placement(B,D); -// Handle(AIS2D_Axis) TheAxis = new AIS2D_Axis(OrigineAndVect); -// GetMapOfAIS2D().Bind(TheAxis,name); -// TheAIS2DContext()->Display(TheAxis); - } - else // Fonction axisortho - { - TheAIS2DContext()->OpenLocalContext(); - MyCurrentIndex = TheAIS2DContext()->IndexOfCurrentLocal(); - - TopoDS_Shape ShapeA = SelectShape2d(2); // Edge - TopoDS_Shape ShapeB = SelectShape2d(1); // Vertex - - // Fermeture du context local - TheAIS2DContext()->CloseLocalContext(MyCurrentIndex); - - // Construction de l'axe - TopoDS_Edge ed = TopoDS::Edge(ShapeA); - gp_Pnt B = BRep_Tool::Pnt(TopoDS::Vertex(ShapeB)); - TopoDS_Vertex Va,Vc; - TopExp::Vertices(ed,Va,Vc); - gp_Pnt A = BRep_Tool::Pnt(Va); - gp_Pnt C = BRep_Tool::Pnt(Vc); - gp_Pnt E (A.Y()+A.Z()-C.Y()-C.Z(), C.X()-A.X(), C.X()-A.X()); - // W = AE est un vecteur orthogonal a AC - gp_Vec aV (A,E); - gp_Dir D (aV); - Handle(Geom_Axis1Placement) OrigineAndVect = new Geom_Axis1Placement(B,D); -// Handle(AIS2D_Axis) TheAxis = new AIS2D_Axis(OrigineAndVect); -// GetMapOfAIS2D().Bind(TheAxis,name); -// TheAIS2DContext()->Display(TheAxis); - } - } - - return 0; -} - -//============================================================================== -// Fonction First click Result -// -// vpoint vertex AIS2D_Point=Vertex -// edge AIS2D_Point=Middle of the edge -//============================================================================== - -#if 0 -//============================================================================== -//function : V2dPointBuilder -//purpose : Build an AIS2D_Point from coordinates or with a selected vertex or edge -//Draw arg : v2dpoint PoinName [Xa] [Ya] -//============================================================================== -static int V2dPointBuilder (Draw_Interpretor& , Standard_Integer argc, char** argv) -{ - // Declarations - Standard_Boolean HasArg; - TCollection_AsciiString name; - Standard_Integer myCurrentIndex; - - // Verification - if (argc < 2 || argc > 4 ) - { - cout << " Syntaxe error" << endl; - return 1; - } - if (argc == 4) HasArg = Standard_True; - else HasArg = Standard_False; - - name = argv[1]; - // Fermeture des contextes - TheAIS2DContext()->CloseAllContext(); - - // Il y a des arguments: teste l'unique constructeur AIS2D_Pnt::AIS2D_Pnt(Point from Geom) - if (HasArg) - { - Standard_Real thecoord[3]; - for (Standard_Integer i = 0; i <= 2; i++) thecoord[i] = atof(argv[2+i]); - Handle(Geom2d_CartesianPoint) myGeomPoint = new Geom2d_CartesianPoint(thecoord[0],thecoord[1]); -// Handle(AIS2D_Point) myAIS2DPoint = new AIS2D_Point(myGeomPoint); -// GetMapOfAIS2D().Bind(myAIS2DPoint, name); -// TheAIS2DContext()->Display(myAIS2DPoint); - } - else // Il n'a pas d'arguments - { - TheAIS2DContext()->OpenLocalContext(); - myCurrentIndex = TheAIS2DContext()->IndexOfCurrentLocal(); - -// TheAIS2DContext()->ActivateStandardMode (AIS2D_ProjShape::SelectionType(1)); -// TheAIS2DContext()->ActivateStandardMode (AIS2D_ProjShape::SelectionType(2)); - cout << " Select a vertex or an edge (build the middle)" << endl; - TopoDS_Shape ShapeA = SelectShape2d(5); - - if (ShapeA.ShapeType() == TopAbs_VERTEX) - { - TheAIS2DContext()->CloseLocalContext(myCurrentIndex); - - // Construction du point - gp_Pnt A = BRep_Tool::Pnt(TopoDS::Vertex(ShapeA)); - Handle(Geom_CartesianPoint) myGeomPoint = new Geom_CartesianPoint(A); -// Handle(AIS2D_Point) myAIS2DPoint = new AIS2D_Point(myGeomPoint); -// GetMapOfAIS2D().Bind(myAIS2DPoint,name); -// TheAIS2DContext()->Display(myAIS2DPoint); - } - else - { - // Un Edge a ete selectionne - // Fermeture du context local - TheAIS2DContext()->CloseLocalContext(myCurrentIndex); - - // Construction du point milieu de l'edge - TopoDS_Edge myEdge = TopoDS::Edge(ShapeA); - TopoDS_Vertex myVertexA,myVertexB; - TopExp::Vertices (myEdge, myVertexA, myVertexB); - gp_Pnt A = BRep_Tool::Pnt(myVertexA); - gp_Pnt B = BRep_Tool::Pnt(myVertexB); - - Handle(Geom_CartesianPoint) myGeomPointM = - new Geom_CartesianPoint((A.X()+B.X())/2, (A.Y()+B.Y())/2, (A.Z()+B.Z())/2); -// Handle(AIS2D_Point) myAIS2DPointM = new AIS2D_Point(myGeomPointM); -// GetMapOfAIS2D().Bind(myAIS2DPointM, name); -// TheAIS2DContext()->Display(myAIS2DPointM); - } - } - - return 0; -} -#endif - -//============================================================================== -// Fonction 1st click 2de click 3de click -// v2dplane Vertex Vertex Vertex -// Vertex Edge -// Edge Vertex -// Face -// v2dplanepara Face Vertex -// Vertex Face -// v2dplaneortho Face Edge -// Edge Face -//============================================================================== - -//============================================================================== -//function : V2dPlaneBuilder -//purpose : Build an AIS2D_Plane from selected entities or Named AIs components -//Draw arg : v2dplane PlaneName [AxisName] [PointName] -// [PointName] [PointName] [PointName] -// [PlaneName] [PointName] -//============================================================================== -/*#include -#include -#include -#include -#include -static int V2dPlaneBuilder (Draw_Interpretor& , Standard_Integer argc, char** argv) -{ - Standard_Boolean HasArg; - TCollection_AsciiString name; - Standard_Integer myCurrentIndex; - - if (argc < 2 || argc > 5) - { - cout << " Syntaxe error" << endl; - return 1; - } - - if (argc == 5 || argc == 4) HasArg = Standard_True; - else HasArg = Standard_False; - - name = argv[1]; - TheAIS2DContext()->CloseAllContexts(); - - if (HasArg) - { - if (!GetMapOfAIS2D().IsBound2(argv[2])) - { - cout << "v2dplane: error 1st name doesn't exist in the GetMapOfAIS2D()." << endl; - return 1; - } - Handle(AIS2D_InteractiveObject) theShapeA = GetMapOfAIS2D().Find2(argv[2]); - - if (theShapeA->Type() == AIS2D_KOI_Datum && theShapeA->Signature() == 1) - { - if (argc < 5 || !GetMapOfAIS2D().IsBound2(argv[3])) - { - cout << "v2dplane: error 2de name doesn't exist in the GetMapOfAIS2D()." << endl; - return 1; - } - Handle(AIS2D_InteractiveObject) theShapeB = GetMapOfAIS2D().Find2(argv[3]); - if (!(theShapeB->Type() == AIS2D_KOI_Datum && theShapeB->Signature() == 1)) - { - cout << "v2dplane: error 2de object is expected to be an AIS2D_Point. " << endl; - return 1; - } - if (!GetMapOfAIS2D().IsBound2(argv[4])) - { - cout << "v2dplane: error 3de name doesn't exist in the GetMapOfAIS2D()." << endl; - return 1; - } - Handle(AIS2D_InteractiveObject) theShapeC = GetMapOfAIS2D().Find2(argv[4]); - if (!(theShapeC->Type() == AIS2D_KOI_Datum && theShapeC->Signature() == 1)) - { - cout << "v2dplane: error 3de object is expected to be an AIS2D_Point. " << endl; - return 1; - } - - Handle(AIS2D_Point) theAIS2DPointA = *(Handle(AIS2D_Point)*)& theShapeA; - Handle(AIS2D_Point) theAIS2DPointB = *(Handle(AIS2D_Point)*)& theShapeB; - Handle(AIS2D_Point) theAIS2DPointC = *(Handle(AIS2D_Point)*)& theShapeC; - - Handle(Geom_Point) myGeomPointA = theAIS2DPointA->Component(); - Handle(Geom_CartesianPoint) myCartPointA = *((Handle(Geom_CartesianPoint)*)& myGeomPointA); - - Handle(Geom_Point) myGeomPointB = theAIS2DPointB->Component(); - Handle(Geom_CartesianPoint) myCartPointB= *((Handle(Geom_CartesianPoint)*)& theAIS2DPointB); - - Handle(Geom_Point) myGeomPointBC = theAIS2DPointC->Component(); - Handle(Geom_CartesianPoint) myCartPointC = *((Handle(Geom_CartesianPoint)*)& theAIS2DPointC); - - if (myCartPointB->X() == myCartPointA->X() && - myCartPointB->Y() == myCartPointA->Y() && myCartPointB->Z() == myCartPointA->Z()) - { - // B=A - cout << "v2dplane error: same points" << endl; - return 1; - } - if (myCartPointC->X() == myCartPointA->X() && - myCartPointC->Y() == myCartPointA->Y() && myCartPointC->Z() == myCartPointA->Z()) - { - // C=A - cout << "v2dplane error: same points" << endl; - return 1; - } - if (myCartPointC->X() == myCartPointB->X() && - myCartPointC->Y() == myCartPointB->Y() && myCartPointC->Z() == myCartPointB->Z()) - { - // C=B - cout << "v2dplane error: same points" << endl; - return 1; - } - - gp_Pnt A = myCartPointA->Pnt(); - gp_Pnt B = myCartPointB->Pnt(); - gp_Pnt C = myCartPointC->Pnt(); - - // Construction de l'AIS2D_Plane - GC_MakePlane MkPlane (A,B,C); - Handle(Geom_Plane) myGeomPlane = MkPlane.Value(); - Handle(AIS2D_Plane) myAIS2DPlane = new AIS2D_Plane(myGeomPlane); - GetMapOfAIS2D().Bind(myAIS2DPlane, name); - TheAIS2DContext()->Display(myAIS2DPlane); - } - - else if (theShapeA->Type() == AIS2D_KOI_Datum && theShapeA->Signature() == 2) - { - if (argc != 4 || !GetMapOfAIS2D().IsBound2(argv[3])) - { - cout << "v2dplane: error 2de name doesn't exist in the GetMapOfAIS2D()." << endl; - return 1; - } - Handle(AIS2D_InteractiveObject) theShapeB = GetMapOfAIS2D().Find2(argv[3]); - if (!(theShapeB->Type() == AIS2D_KOI_Datum && theShapeB->Signature() == 1)) - { - cout << "v2dplane: error 2de object is expected to be an AIS2D_Point." << endl; - return 1; - } - - Handle(AIS2D_Axis) theAIS2DAxisA = *(Handle(AIS2D_Axis)*)& theShapeA; - Handle(AIS2D_Point) theAIS2DPointB = *(Handle(AIS2D_Point)*)& theShapeB; - - Handle(Geom_Line) myGeomLineA = theAIS2DAxisA->Component(); - Handle(Geom_Point) myGeomPointB = theAIS2DPointB->Component(); - - gp_Ax1 myAxis = myGeomLineA->Position(); - Handle(Geom_CartesianPoint) myCartPointB = *(Handle(Geom_CartesianPoint)*)& myGeomPointB; - - gp_Dir D = myAxis.Direction(); - gp_Pnt B = myCartPointB->Pnt(); - - // Construction de l'AIS2D_Plane - Handle(Geom_Plane) myGeomPlane = new Geom_Plane(B,D); - Handle(AIS2D_Plane) myAIS2DPlane = new AIS2D_Plane(myGeomPlane,B); - GetMapOfAIS2D().Bind(myAIS2DPlane, name); - TheAIS2DContext()->Display(myAIS2DPlane); - } - else if (theShapeA->Type() == AIS2D_KOI_Datum && theShapeA->Signature() == 7) - { - if (argc != 4 || !GetMapOfAIS2D().IsBound2(argv[3])) - { - cout << "vplane: error 2de name doesn't exist in the GetMapOfAIS2D()." << endl; - return 1; - } - Handle(AIS2D_InteractiveObject) theShapeB = GetMapOfAIS2D().Find2(argv[3]); - if (!(theShapeB->Type() == AIS2D_KOI_Datum && theShapeB->Signature() == 1)) - { - cout << "vplane: error 2de object is expected to be an AIS2D_Point." << endl; - return 1; - } - - Handle(AIS2D_Plane) theAIS2DPlaneA = *(Handle(AIS2D_Plane)*)& theShapeA; - Handle(AIS2D_Point) theAIS2DPointB = *(Handle(AIS2D_Point)*)& theShapeB; - - Handle(Geom_Plane) theNewGeomPlane = theAIS2DPlaneA->Component(); - Handle(Geom_Point) myGeomPointB = theAIS2DPointB->Component(); - - Handle(Geom_CartesianPoint) myCartPointB = *(Handle(Geom_CartesianPoint)*)& myGeomPointB; - gp_Pnt B = myCartPointB->Pnt(); - - // Construction de l'AIS2D_Plane - Handle(AIS2D_Plane) myAIS2DPlane = new AIS2D_Plane(theNewGeomPlane,B); - GetMapOfAIS2D().Bind(myAIS2DPlane, name); - TheAIS2DContext()->Display(myAIS2DPlane); - } - else - { - cout << "v2dplane: error 1st object is not an AIS2D." << endl; - return 1; - } - } - else - { - if (!strcasecmp(argv[0] ,"v2dplane")) - { - TheAIS2DContext()->OpenLocalContext(); - myCurrentIndex = TheAIS2DContext()->IndexOfCurrentLocal(); - - TheAIS2DContext()->ActivateStandardMode(AIS2D_ProjShape::SelectionType(1)); - TheAIS2DContext()->ActivateStandardMode(AIS2D_ProjShape::SelectionType(2)); - cout << "Select a vertex, a face or an edge." << endl; - ShapeA = SelectShape2d(5); // User-defined mode - TheAIS2DContext()->ActivateStandardMode(AIS2D_ProjShape::SelectionType(4)); - - if (ShapeA.ShapeType() == TopAbs_VERTEX) - { - TheAIS2DContext()->DeactivateStandardMode(AIS2D_ProjShape::SelectionType(4)); - cout << " Select an edge or a different vertex." << endl; - TopoDS_Shape ShapeB = SelectShape2d(5); - - if (ShapeB.ShapeType() == TopAbs_VERTEX) - { - if (ShapeB.IsSame(ShapeA)) - { - cout << " v2dplane: error, same points selected" << endl; - return 1; - } - TheAIS2DContext()->DeactivateStandardMode(AIS2D_ProjShape::SelectionType(2)); - cout<<" Select a different vertex."<CloseLocalContext(myCurrentIndex); - - // Construction du plane - gp_Pnt A = BRep_Tool::Pnt(TopoDS::Vertex(ShapeA)); - gp_Pnt B = BRep_Tool::Pnt(TopoDS::Vertex(ShapeB)); - gp_Pnt C = BRep_Tool::Pnt(TopoDS::Vertex(ShapeC)); - GC_MakePlane MkPlane (A,B,C); - Handle(Geom_Plane) theGeomPlane = MkPlane.Value(); - Handle(AIS2D_Plane) myAIS2DPlane = new AIS2D_Plane(theGeomPlane); - GetMapOfAIS2D().Bind(myAIS2DPlane, name); - TheAIS2DContext()->Display(myAIS2DPlane); - } - else // ShapeB est un edge - { - TopoDS_Edge EdgeB = TopoDS::Edge(ShapeB); - TopoDS_Vertex VertA = TopoDS::Vertex(ShapeA); - - BRepExtrema_ExtPC OrthoProj (VertA, EdgeB); - if (OrthoProj.Value(1) < 0.001) - { - cout << " v2dplane: error point is on the edge." << endl; - return 1; - } - else - { - TheAIS2DContext()->CloseLocalContext(myCurrentIndex); - // Construction du plane - gp_Pnt A = BRep_Tool::Pnt(VertA); - TopoDS_Vertex VBa, VBb; - TopExp::Vertices(EdgeB, VBa, VBb); - gp_Pnt Ba = BRep_Tool::Pnt(VBa); - gp_Pnt Bb = BRep_Tool::Pnt(VBb); - GC_MakePlane MkPlane (A,Ba,Bb); - Handle(Geom_Plane) theGeomPlane = MkPlane.Value(); - Handle(AIS2D_Plane) myAIS2DPlane = new AIS2D_Plane(theGeomPlane); - GetMapOfAIS2D().Bind(myAIS2DPlane, name); - TheAIS2DContext()->Display(myAIS2DPlane); - } - } - } - else if (ShapeA.ShapeType() == TopAbs_EDGE) - { - TheAIS2DContext()->DeactivateStandardMode(AIS2D_ProjShape::SelectionType(4)); - TheAIS2DContext()->DeactivateStandardMode(AIS2D_ProjShape::SelectionType(2)); - cout << " Select a vertex that don't belong to the edge." << endl; - TopoDS_Shape ShapeB = SelectShape2d(5); - - TopoDS_Edge EdgeA = TopoDS::Edge(ShapeA); - TopoDS_Vertex VertB = TopoDS::Vertex(ShapeB); - - BRepExtrema_ExtPC OrthoProj (VertB,EdgeA); - if (OrthoProj.Value(1) < 0.001) - { - cout << " v2dplane: error point is on the edge." << endl; - return 1; - } - else - { - TheAIS2DContext()->CloseLocalContext(myCurrentIndex); - // Construction du plane - gp_Pnt B = BRep_Tool::Pnt(VertB); - TopoDS_Vertex VAa, VAb; - TopExp::Vertices(EdgeA, VAa, VAb); - gp_Pnt Aa = BRep_Tool::Pnt(VAa); - gp_Pnt Ab = BRep_Tool::Pnt(VAb); - GC_MakePlane MkPlane (B,Aa,Ab); - Handle(Geom_Plane) theGeomPlane = MkPlane.Value(); - Handle(AIS2D_Plane) myAIS2DPlane = new AIS2D_Plane(theGeomPlane); - GetMapOfAIS2D().Bind(myAIS2DPlane, name); - TheAIS2DContext()->Display(myAIS2DPlane); - } - } - else // ShapeA est une Face - { - TheAIS2DContext()->CloseLocalContext(myCurrentIndex); - // Construction du plane - TopoDS_Face myFace = TopoDS::Face(ShapeA); - BRepAdaptor_Surface mySurface (myFace, Standard_False); - if (mySurface.GetType() == GeomAbs_Plane) - { - gp_Pln myPlane = mySurface.Plane(); - Handle(Geom_Plane) theGeomPlane = new Geom_Plane(myPlane); - Handle(AIS2D_Plane) myAIS2DPlane = new AIS2D_Plane(theGeomPlane); - GetMapOfAIS2D().Bind(myAIS2DPlane, name); - TheAIS2DContext()->Display(myAIS2DPlane); - } - else - { - cout << " v2dplane: error" << endl; - return 1; - } - } - } - else if (!strcasecmp(argv[0], "v2dplanepara")) - { - TheAIS2DContext()->OpenLocalContext(); - myCurrentIndex = TheAIS2DContext()->IndexOfCurrentLocal(); - - TheAIS2DContext()->ActivateStandardMode(AIS2D_ProjShape::SelectionType(1)); - TheAIS2DContext()->ActivateStandardMode(AIS2D_ProjShape::SelectionType(4)); - cout << " Select a vertex or a face." << endl; - TopoDS_Shape ShapeA = SelectShape2d(5); - - if (ShapeA.ShapeType() == TopAbs_VERTEX) - { - TheAIS2DContext()->DeactivateStandardMode(AIS2D_ProjShape::SelectionType(1)); - cout<<" Select a face."<CloseLocalContext(myCurrentIndex); - - // Construction du plane - gp_Pnt A = BRep_Tool::Pnt(TopoDS::Vertex(ShapeA)); - - TopoDS_Face myFace = TopoDS::Face(ShapeB); - BRepAdaptor_Surface mySurface (myFace, Standard_False); - if (mySurface.GetType() == GeomAbs_Plane) - { - gp_Pln myPlane = mySurface.Plane(); - myPlane.SetLocation(A); - Handle(Geom_Plane) theGeomPlane = new Geom_Plane(myPlane); - Handle(AIS2D_Plane) myAIS2DPlane = new AIS2D_Plane(theGeomPlane, A); - GetMapOfAIS2D().Bind(myAIS2DPlane, name); - TheAIS2DContext()->Display(myAIS2DPlane); - } - else - { - cout << " vplane: error" << endl; - return 1; - } - } - else - { - TheAIS2DContext()->DeactivateStandardMode(AIS2D_ProjShape::SelectionType(4)); - cout<<" Select a vertex."<CloseLocalContext(myCurrentIndex); - - // Construction du plane - gp_Pnt B = BRep_Tool::Pnt(TopoDS::Vertex(ShapeB ) ); - - TopoDS_Face myFace = TopoDS::Face(ShapeA); - BRepAdaptor_Surface mySurface (myFace, Standard_False); - if (mySurface.GetType() == GeomAbs_Plane) - { - gp_Pln myPlane = mySurface.Plane(); - myPlane.SetLocation(B); - Handle(Geom_Plane) theGeomPlane = new Geom_Plane(myPlane); - Handle(AIS2D_Plane) myAIS2DPlane = new AIS2D_Plane(theGeomPlane, B); - GetMapOfAIS2D().Bind(myAIS2DPlane, name); - TheAIS2DContext()->Display(myAIS2DPlane); - } - else - { - cout << " v2dplane: error" << endl; - return 1; - } - } - } - else // Fonction v2dplaneortho - { - TheAIS2DContext()->OpenLocalContext(); - myCurrentIndex = TheAIS2DContext()->IndexOfCurrentLocal(); - - TheAIS2DContext()->ActivateStandardMode(AIS2D_ProjShape::SelectionType(2)); - TheAIS2DContext()->ActivateStandardMode(AIS2D_ProjShape::SelectionType(4)); - cout << " Select a face and an edge coplanar." << endl; - TopoDS_Shape ShapeA = SelectShape2d(5); - - if (ShapeA.ShapeType() == TopAbs_EDGE) - { - // ShapeA est un edge, on desactive le mode edge... - TheAIS2DContext()->DeactivateStandardMode(AIS2D_ProjShape::SelectionType(2)); - cout<<" Select a face."<CloseLocalContext(myCurrentIndex); - - // Construction du plane - TopoDS_Edge EdgeA = TopoDS::Edge(ShapeA); - TopoDS_Vertex VAa, VAb; - - TopExp::Vertices(EdgeA, VAa, VAb); - gp_Pnt Aa = BRep_Tool::Pnt(VAa); - gp_Pnt Ab = BRep_Tool::Pnt(VAb); - gp_Vec ab (Aa,Ab); - - gp_Dir Dab (ab); - // Creation de mon axe de rotation - gp_Ax1 myRotAxis (Aa,Dab); - - TopoDS_Face myFace = TopoDS::Face(ShapeB); - BRepExtrema_ExtPF myHauteurA (VAa, myFace); - BRepExtrema_ExtPF myHauteurB (VAb, myFace); - if (fabs(myHauteurA.Value(1) - myHauteurB.Value(1) ) > 0.1) - { - cout << " v2dplaneOrtho error: l'edge n'est pas parallele a la face." << endl; - return 1; - } - BRepAdaptor_Surface mySurface (myFace, Standard_False); - if (mySurface.GetType() == GeomAbs_Plane) - { - gp_Pln myPlane = mySurface.Plane(); - myPlane.Rotate(myRotAxis, M_PI/2); - - Handle(Geom_Plane) theGeomPlane = new Geom_Plane(myPlane); - gp_Pnt theMiddle ((Aa.X()+Ab.X())/2, (Aa.Y()+Ab.Y())/2, (Aa.Z()+Ab.Z())/2); - Handle(AIS2D_Plane) myAIS2DPlane = new AIS2D_Plane(theGeomPlane, theMiddle); - GetMapOfAIS2D().Bind(myAIS2DPlane, name); - TheAIS2DContext()->Display(myAIS2DPlane); - - } - else - { - cout << " v2dplaneOrtho: error" << endl; - return 1; - } - } - else - { - TheAIS2DContext()->DeactivateStandardMode(AIS2D_ProjShape::SelectionType(4)); - cout << " Select an edge." << endl; - TopoDS_Shape ShapeB = SelectShape2d(5); - - // Fermeture du context local - TheAIS2DContext()->CloseLocalContext(myCurrentIndex); - - // Construction du plane - TopoDS_Edge EdgeB = TopoDS::Edge(ShapeB); - TopoDS_Vertex VBa, VBb; - TopExp::Vertices(EdgeB, VBa, VBb); - gp_Pnt Ba = BRep_Tool::Pnt(VBa); - gp_Pnt Bb = BRep_Tool::Pnt(VBb); - gp_Vec ab (Ba,Bb); - gp_Dir Dab (ab); - // Creation de mon axe de rotation - gp_Ax1 myRotAxis (Ba,Dab); - - TopoDS_Face myFace = TopoDS::Face(ShapeA); - BRepExtrema_ExtPF myHauteurA (VBa, myFace); - BRepExtrema_ExtPF myHauteurB (VBb, myFace); - - if (fabs(myHauteurA.Value(1) - myHauteurB.Value(1) ) > 0.1) - { - cout << " v2dplaneOrtho error: l'edge n'est pas parallele a la face." << endl; - return 1; - } - BRepAdaptor_Surface mySurface (myFace, Standard_False); - if (mySurface.GetType() == GeomAbs_Plane) - { - gp_Pln myPlane = mySurface.Plane(); - myPlane.Rotate(myRotAxis, M_PI/2); - Handle(Geom_Plane) theGeomPlane = new Geom_Plane(myPlane); - gp_Pnt theMiddle ((Ba.X()+Bb.X())/2, (Ba.Y()+Bb.Y())/2, (Ba.Z()+Bb.Z())/2); - Handle(AIS2D_Plane) myAIS2DPlane = new AIS2D_Plane(theGeomPlane, theMiddle); - GetMapOfAIS2D().Bind(myAIS2DPlane, name); - TheAIS2DContext()->Display(myAIS2DPlane); - } - else - { - cout << " v2dplaneOrtho: error" << endl; - return 1; - } - } - } - } - - return 0; -}*/ - -//============================================================================== -// Fonction vline -// --------------- Uniquement par parametre. Pas de selection dans le viewer. -//============================================================================== - -//============================================================================== -//function : V2dLineBuilder -//purpose : Build a Graphic2d_Line -//Draw arg : v2dline LineName [AIS2D_PointName] [AIS2D_PointName] -// [Xa] [Ya] [Za] [Xb] [Yb] [Zb] -//============================================================================== -/*static int V2dLineBuilder(Draw_Interpretor& , Standard_Integer argc, char** argv) -{ - Standard_Integer myCurrentIndex; - if (argc != 4 && argc != 8 && argc != 2) - { - cout << "vline error: number of arguments not correct " << endl; - return 1; - } - TheAIS2DContext()->CloseAllContext(); - - // On recupere les parametres - Handle(AIS2D_InteractiveObject) theShapeA; - Handle(AIS2D_InteractiveObject) theShapeB; - - // Parametres: AIS2D_Point AIS2D_Point - if (argc == 4) - { - theShapeA = GetMapOfAIS2D().Find2(argv[2] ); - if (theShapeA->Type() == AIS2D_KOI_Datum && theShapeA->Signature() == 1) - { - theShapeB = GetMapOfAIS2D().Find2(argv[3]); - if (!(theShapeB->Type() == AIS2D_KOI_Datum && theShapeB->Signature() == 1)) - { - cout << "v2dline error: wrong type of 2de argument." << endl; - return 1; - } - } - else - { - cout << "v2dline error: wrong type of 1st argument." << endl; - return 1; - } - - Handle(AIS2D_Point) theAIS2DPointA = *(Handle(AIS2D_Point)*)& theShapeA; - Handle(AIS2D_Point) theAIS2DPointB = *(Handle(AIS2D_Point)*)& theShapeB; - - Handle(Geom_Point) myGeomPointBA = theAIS2DPointA->Component(); - Handle(Geom_CartesianPoint) myCartPointA = *((Handle(Geom_CartesianPoint)*)& myGeomPointBA); - - Handle(Geom_Point) myGeomPointB = theAIS2DPointB->Component(); - Handle(Geom_CartesianPoint) myCartPointB = *((Handle(Geom_CartesianPoint)*)& myGeomPointB); - - if (myCartPointB->X() == myCartPointA->X() && - myCartPointB->Y() == myCartPointA->Y() && myCartPointB->Z() == myCartPointA->Z()) - { - // B=A - cout << "v2dline error: same points" << endl; - return 1; - } - Handle(AIS2D_Line) theAIS2DLine = new AIS2D_Line(myCartPointA, myCartPointB); - GetMapOfAIS2D().Bind(theAIS2DLine, argv[1]); - TheAIS2DContext()->Display(theAIS2DLine); - } - else if (argc == 8) // Parametres 6 Reals - { - Standard_Real coord[6]; - for (Standard_Integer i = 0; i <= 2; i++) - { - coord[i] = atof(argv[2+i]); - coord[i+3] = atof(argv[5+i]); - } - - Handle(Geom_CartesianPoint) myCartPointA = new Geom_CartesianPoint(coord[0],coord[1],coord[2]); - Handle(Geom_CartesianPoint) myCartPointB = new Geom_CartesianPoint(coord[3],coord[4],coord[5]); - - Handle(AIS2D_Line) theAIS2DLine = new AIS2D_Line(myCartPointA, myCartPointB); - GetMapOfAIS2D().Bind(theAIS2DLine, argv[1]); - TheAIS2DContext()->Display(theAIS2DLine); - } - else - { - TheAIS2DContext()->OpenLocalContext(); - myCurrentIndex = TheAIS2DContext()->IndexOfCurrentLocal(); - - // Active le mode Vertex. - TopoDS_Shape ShapeA = SelectShape2d(1); - - if (ShapeA.ShapeType() == TopAbs_VERTEX) - { -// TheAIS2DContext()->ActivateStandardMode(AIS2D_ProjShape::SelectionType(1)); - cout << " Select a different vertex." << endl; - - TopoDS_Shape ShapeB; - do - { - ShapeB = SelectShape2d(5); - } while (ShapeB.IsSame(ShapeA)); - - TheAIS2DContext()->CloseLocalContext(myCurrentIndex); - - // Construction de la line - gp_Pnt A = BRep_Tool::Pnt(TopoDS::Vertex(ShapeA)); - gp_Pnt B = BRep_Tool::Pnt(TopoDS::Vertex(ShapeB)); - - Handle(Geom_CartesianPoint) myCartPointA = new Geom_CartesianPoint(A); - Handle(Geom_CartesianPoint) myCartPointB = new Geom_CartesianPoint(B); - - Handle(AIS2D_Line) theAIS2DLine = new AIS2D_Line(myCartPointA, myCartPointB); - GetMapOfAIS2D().Bind(theAIS2DLine, argv[1]); - TheAIS2DContext()->Display(theAIS2DLine); - } - else - { - cout << "v2dline error." << endl; - } - } - - return 0; -}*/ - -//============================================================================== -//function : V2dCircleBuilder -//purpose : Build an Graphic2d_Circle -//Draw arg : v2dcircle CircleName X Y Radius [Color_index] -//============================================================================== -static int V2dCircleBuilder (Draw_Interpretor& , Standard_Integer argc, char** argv) -{ - Standard_Integer myCurrentIndex; - // verification of the arguments - if (argc < 2) - { - cout << "Usage: v2dcircle CircleName X Y Radius [Color_index]" << endl; - return 1; - } - TheAIS2DContext()->CloseAllContext(); - Handle(V2d_View) V = QAViewer2dTest::CurrentView(); - - TCollection_AsciiString name = argv[1]; - - if (argc >= 5) - { -// Handle(AIS2D_InteractiveObject) theShapeA; -// Handle(AIS2D_InteractiveObject) theShapeB; -// theShapeA=GetMapOfAIS2D().Find2(argv[2]); -// theShapeB=GetMapOfAIS2D().Find2(argv[3]); - - // Arguments: AIS2D_Point AIS2D_Point AIS2D_Point - // ======================================== -/* if (theShapeA->Type() == AIS2D_KOI_Datum && theShapeA->Signature() == 1) - { - if (theShapeB->Type() != AIS2D_KOI_Datum || theShapeB->Signature() != 1) - { - cout<<"vcircle error: 2de argument is unexpected to be a point."<Type()!=AIS2D_KOI_Datum || theShapeC->Signature()!=1 ) { - cout<<"vcircle error: 3de argument is unexpected to be a point."<Component(); - Handle(Geom_CartesianPoint) myCartPointA = *((Handle(Geom_CartesianPoint)*)& myGeomPointA); - - Handle(Geom_Point ) myGeomPointB = theAIS2DPointB->Component(); - Handle(Geom_CartesianPoint ) myCartPointB= *((Handle(Geom_CartesianPoint)*)& theAIS2DPointB); - - Handle(Geom_Point ) myGeomPointBC= theAIS2DPointC->Component(); - Handle(Geom_CartesianPoint ) myCartPointC= *((Handle(Geom_CartesianPoint)*)& theAIS2DPointC); - - // Test A=B - if (myCartPointA->X()==myCartPointB->X() && myCartPointA->Y()==myCartPointB->Y() && myCartPointA->Z()==myCartPointB->Z() ) { - cout<<"vcircle error: Same points."<X()==myCartPointC->X() && myCartPointA->Y()==myCartPointC->Y() && myCartPointA->Z()==myCartPointC->Z() ) { - cout<<"vcircle error: Same points."<X()==myCartPointC->X() && myCartPointB->Y()==myCartPointC->Y() && myCartPointB->Z()==myCartPointC->Z() ) { - cout<<"vcircle error: Same points."<Pnt(),myCartPointB->Pnt(),myCartPointC->Pnt() ); - Handle (Geom_Circle) theGeomCircle=Cir.Value(); - Handle(AIS2D_Circle) theAIS2DCircle=new AIS2D_Circle(theGeomCircle ); - GetMapOfAIS2D().Bind(theAIS2DCircle,argv[1] ); - TheAIS2DContext()->Display(theAIS2DCircle ); - - } - // Arguments: ASI_Plane AIS2D_Point Real - // =================================== - else if (theShapeA->Type()==AIS2D_KOI_Datum && theShapeA->Signature()==7 ) { - if (theShapeB->Type()!=AIS2D_KOI_Datum || theShapeB->Signature()!=1 ) { - cout<<"vcircle error: 2de element is a unexpected to be a point."<=0 - if (atof(argv[4])<=0 ) {cout<<"vcircle error: the radius must be >=0."<Component() ); - Handle(Geom_Plane ) myGeomPlane= theAIS2DPlane->Component(); - Handle(Geom_Point ) myGeomPointB = theAIS2DPointB->Component(); - Handle(Geom_CartesianPoint ) myCartPointB= *((Handle(Geom_CartesianPoint)*)& theAIS2DPointB); -// Handle(Geom_CartesianPoint ) myCartPointB= *(Handle(Geom_CartesianPoint)*)& (theAIS2DPointB->Component() ); - - //Handle(Geom_Axis2Placement) OrigineAndAxii=myGeomPlane->Axis(); - gp_Pln mygpPlane = myGeomPlane->Pln(); - gp_Ax1 thegpAxe = mygpPlane.Axis(); - gp_Dir theDir = thegpAxe.Direction(); - gp_Pnt theCenter=myCartPointB->Pnt(); - Standard_Real TheR = atof(argv[4]); - GC_MakeCircle Cir=GC_MakeCircle (theCenter, theDir ,TheR); - Handle (Geom_Circle) theGeomCircle=Cir.Value(); - Handle(AIS2D_Circle) theAIS2DCircle=new AIS2D_Circle(theGeomCircle ); - GetMapOfAIS2D().Bind(theAIS2DCircle,argv[1] ); - TheAIS2DContext()->Display(theAIS2DCircle ); - } - else // Error - { - cout << "v2dcircle error: !st argument is a unexpected type." << endl; - return 1; - } -*/ - //Draw arg : v2dcircle CircleName X Y Radius [Color_index] - if (GetMapOfAIS2D().IsBound2(name)) - { - cout << "There is already an object with name " << name << endl; - return -1; - } - Handle(AIS2D_InteractiveObject) aisobj = new AIS2D_InteractiveObject(); - aisobj->SetView(V->View()); -// Handle(Graphic2d_GraphicObject) obj = -// new Graphic2d_GraphicObject(V->View()); - - Handle(Graphic2d_Circle) circle = new Graphic2d_Circle - (aisobj, atof(argv[2]), atof(argv[3]), atof(argv[4])); - - if (argc > 5) - { - circle->SetTypeOfPolygonFilling(Graphic2d_TOPF_FILLED); - circle->SetInteriorColorIndex(atoi(argv[5])); - } - -// obj->Display(); - GetMapOfAIS2D().Bind(aisobj, name); -// TheAIS2DContext()->Display(aisobj, Standard_False); - aisobj->Display(); - - V->Viewer()->Update(); - } - else - { - TheAIS2DContext()->OpenLocalContext(); - myCurrentIndex = TheAIS2DContext()->IndexOfCurrentLocal(); - - // Active le mode Vertex et face. -// TheAIS2DContext()->ActivateStandardMode(AIS2D_ProjShape::SelectionType(1)); -// TheAIS2DContext()->ActivateStandardMode(AIS2D_ProjShape::SelectionType(4)); - cout << " Select a vertex or a face." << endl; - TopoDS_Shape ShapeA = SelectShape2d(5); - - if (ShapeA.ShapeType() == TopAbs_VERTEX) - { -// TheAIS2DContext()->DeactivateStandardMode(AIS2D_ProjShape::SelectionType(4)); - cout << " Select a different vertex." << endl; - - TopoDS_Shape ShapeB; - do - { - ShapeB = SelectShape2d(5); - } while (ShapeB.IsSame(ShapeA)); - - // Selection de ShapeC - cout << " Select the last vertex." << endl; - TopoDS_Shape ShapeC; - do - { - ShapeC = SelectShape2d(5); - } while (ShapeC.IsSame(ShapeA) || ShapeC.IsSame(ShapeB)); - - TheAIS2DContext()->CloseLocalContext(myCurrentIndex); - - // Construction du cercle -/* - gp_Pnt A = BRep_Tool::Pnt(TopoDS::Vertex(ShapeA)); - gp_Pnt B = BRep_Tool::Pnt(TopoDS::Vertex(ShapeB)); - gp_Pnt C = BRep_Tool::Pnt(TopoDS::Vertex(ShapeC)); - - GC_MakeCircle Cir = GC_MakeCircle(A,B,C); - Handle(Geom_Circle) theGeomCircle = Cir.Value(); - Handle(AIS2D_Circle) theAIS2DCircle = new AIS2D_Circle(theGeomCircle); - GetMapOfAIS2D().Bind(theAIS2DCircle,argv[1]); - TheAIS2DContext()->Display(theAIS2DCircle);*/ - } - // ShapeA est une face. - else - { - cout << " Select a vertex (in your face)." << endl; -// TheAIS2DContext()->DeactivateStandardMode(AIS2D_ProjShape::SelectionType(4)); - TopoDS_Shape ShapeB = SelectShape2d(5); - - Standard_Integer theRad; - do - { - cout << " Enter the value of the radius:" << endl; - cin >> theRad; - } while (theRad <= 0); - - TheAIS2DContext()->CloseLocalContext(myCurrentIndex); - - // Construction du cercle. - - // On recupere la normale au Plane. tag -/* TopoDS_Face myFace = TopoDS::Face(ShapeA); - BRepAdaptor_Surface mySurface (myFace, Standard_False); - gp_Pln myPlane = mySurface.Plane(); - Handle(Geom_Plane) theGeomPlane = new Geom_Plane (myPlane ); - gp_Pln mygpPlane = theGeomPlane->Pln(); - gp_Ax1 thegpAxe = mygpPlane.Axis(); - gp_Dir theDir = thegpAxe.Direction(); - - // On recupere le centre. - gp_Pnt theCenter = BRep_Tool::Pnt(TopoDS::Vertex(ShapeB)); - - // On construit l'AIS2D_Circle - GC_MakeCircle Cir = GC_MakeCircle(theCenter, theDir ,theRad); - Handle(Geom_Circle) theGeomCircle = Cir.Value(); - Handle(AIS2D_Circle) theAIS2DCircle = new AIS2D_Circle(theGeomCircle); - GetMapOfAIS2D().Bind(theAIS2DCircle,argv[1] ; - TheAIS2DContext()->Display(theAIS2DCircle);*/ - } - } - - return 0; -} - -//======================================================================= -//function : ObjectCommands -//purpose : -//======================================================================= -void QAViewer2dTest::ObjectCommands (Draw_Interpretor& theCommands) -{ - char *group = "2D AIS Viewer - Primitives Creation"; - -// theCommands.Add("v2dtrihedron", -// "v2dtrihedron name [Xo] [Yo] [Zo] [Zu] [Zv] [Zw] [Xu] [Xv] [Xw]", -// __FILE__,V2dTrihedron,group); - -/* theCommands.Add("v2dtri2d", - "v2dtri2d Name (Selection in the viewer only)", - __FILE__, V2dTrihedron2D, group); - -// theCommands.Add("v2dplanetri", -// "v2dplanetri Name (Selection in the viewer only)", -// __FILE__, V2dPlaneTrihedron, group); - - theCommands.Add("v2dsize", - "v2dsize [name(Default=Current)] [size(Default=100)] ", - __FILE__, V2dSize, group); -*/ - theCommands.Add("v2daxis", - "v2daxis nom [Xa] [Ya] [Xb] [Yb]", - __FILE__, V2dAxisBuilder, group); - -/* theCommands.Add("v2daxispara", - "v2daxispara nom ", - __FILE__, V2dAxisBuilder, group); - - theCommands.Add("v2daxisortho", - "v2daxisotho nom ", - __FILE__, V2dAxisBuilder, group); - - theCommands.Add("v2dpoint", - "v2dpoint PointName [Xa] [Ya]", - __FILE__, V2dPointBuilder, group); -*/ -/* theCommands.Add("v2dplane", - "v2dplane PlaneName [AxisName/PlaneName/PointName] [PointName/PointName/PointName] [Nothing/Nothing/PointName] ", - __FILE__,V2dPlaneBuilder,group); - - theCommands.Add("v2dplanepara", - "v2dplanepara PlaneName ", - __FILE__,V2dPlaneBuilder,group); - - theCommands.Add("v2dplaneortho", - "v2dplaneortho PlaneName ", - __FILE__,V2dPlaneBuilder,group); -*/ -// theCommands.Add("v2dline", -// "v2dline LineName [Xa/PointName] [Ya/PointName] [Xb] [Yb]", -// __FILE__,V2dLineBuilder,group); - - theCommands.Add("v2dcircle", - "v2dcircle CircleName X Y Radius [color_index]", - __FILE__, V2dCircleBuilder, group); -} -#endif diff --git a/src/QAViewer2dTest/QAViewer2dTest_ViewerCommands.cxx b/src/QAViewer2dTest/QAViewer2dTest_ViewerCommands.cxx deleted file mode 100755 index df6c2334b2..0000000000 --- a/src/QAViewer2dTest/QAViewer2dTest_ViewerCommands.cxx +++ /dev/null @@ -1,1512 +0,0 @@ -// Copyright (c) 1999-2012 OPEN CASCADE SAS -// -// The content of this file is subject to the Open CASCADE Technology Public -// License Version 6.5 (the "License"). You may not use the content of this file -// except in compliance with the License. Please obtain a copy of the License -// at http://www.opencascade.org and read it completely before using this file. -// -// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its -// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. -// -// The Original Code and all software distributed under the License is -// distributed on an "AS IS" basis, without warranty of any kind, and the -// Initial Developer hereby disclaims all such warranties, including without -// limitation, any warranties of merchantability, fitness for a particular -// purpose or non-infringement. Please see the License for the specific terms -// and conditions governing the rights and limitations under the License. - -#if defined(WOKC40) - -#define OCC198 // jfa 06/03/2002 // to prevent exception on bad font index -#define OCC199 // jfa 06/03/2002 // to prevent exception on bad color index - -#include - -#include -#include - -#include - -#include -#include - -#ifndef WNT - -#include -#include -#include -#include -#include -#include - -#else - -#include -#include -#include -#include - -#include - -#endif - -#include -#include - -#include - -#include - -//============================================================================== -// VIEWER GLOBALs -//============================================================================== -Standard_EXPORT int ViewerMainLoop2d (Standard_Integer , char** argv); - -#ifdef WNT -static Handle(Graphic3d_WNTGraphicDevice)& GetG2dDevice() -{ - static Handle(Graphic3d_WNTGraphicDevice) GD; - return GD; -} - -static Handle(WNT_Window)& VT_GetWindow2d() -{ - static Handle(WNT_Window) WNTWin; - return WNTWin; -} - -#else -static Handle(Graphic3d_GraphicDevice)& GetG2dDevice() -{ - static Handle(Graphic3d_GraphicDevice) GD; - return GD; -} - -static Handle(Xw_Window)& VT_GetWindow2d() -{ - static Handle(Xw_Window) XWWin; - return XWWin; -} - -static Display* display2d; - -static void VProcessEvents2d (ClientData, int); -#endif - -#define ZCLIPWIDTH 1. - -static QAViewer2dTest_DataMapOfText myMapOfText; - -static void OSWindowSetup2d(); - -//============================================================================== -// EVENT GLOBAL VARIABLES -//============================================================================== -static int Start_Rot = 0; -static int ZClipIsOn = 0; -static int X_Motion = 0, Y_Motion = 0; // Current cursor position -static int X_ButtonPress = 0, Y_ButtonPress = 0; // Last ButtonPress position -//============================================================================== - -#ifdef WNT -static LRESULT WINAPI Viewer2dWindowProc (HWND hwnd, UINT uMsg, - WPARAM wParam, LPARAM lParam); -#endif - -//============================================================================== -//function : ViewerInit -//purpose : Create the window viewer and initialize all the global variable -//============================================================================== -void QAViewer2dTest::ViewerInit() -{ - static int first = 1; - - if (first) - { - Handle(Aspect_WindowDriver) aWindowDriver; - -#ifdef WNT - // Create the Graphic device - if (GetG2dDevice().IsNull()) - GetG2dDevice() = new Graphic3d_WNTGraphicDevice(); - - // Create window - if (VT_GetWindow2d().IsNull()) - { - Handle(WNT_GraphicDevice) g_Device = new WNT_GraphicDevice(); - - Handle(WNT_WClass) WC = new WNT_WClass - ("GW3D_Class", Viewer2dWindowProc, CS_VREDRAW | CS_HREDRAW, - 0, 0, LoadCursor(NULL, IDC_ARROW)); - VT_GetWindow2d() = new WNT_Window - (g_Device,"Test2d", WC, WS_OVERLAPPEDWINDOW,0.,0.20,0.40,0.40,Quantity_NOC_BLACK); - VT_GetWindow2d()->Map(); - } - - // Create window driver - aWindowDriver = new WNT_WDriver(VT_GetWindow2d()); -#else - // Create the Graphic device - if (GetG2dDevice().IsNull()) - GetG2dDevice() = new Graphic3d_GraphicDevice(getenv("DISPLAY"),Xw_TOM_READONLY); - - // Create window - if (VT_GetWindow2d().IsNull()) - { - VT_GetWindow2d() = new Xw_Window(GetG2dDevice(), "Test2d", - 0.,0.60,0.40,0.40, - Xw_WQ_3DQUALITY, Quantity_NOC_BLACK); - } - - // Create window driver - aWindowDriver = new Xw_Driver(VT_GetWindow2d()); -#endif - - Handle(V2d_Viewer) a3DViewer,a3DCollector; - // Create Viewer and View - a3DViewer = new V2d_Viewer(GetG2dDevice(),Standard_ExtString("Visu3D")); - a3DCollector = new V2d_Viewer(GetG2dDevice(),Standard_ExtString("Collector")); -// a3DViewer->SetDefaultBackgroundColor(Quantity_NOC_BLACK); -// a3DCollector->SetDefaultBackgroundColor(Quantity_NOC_STEELBLUE); - - if (QAViewer2dTest::CurrentView().IsNull()) - { -// VT_GetWindow2d()->SetBackground(Quantity_NOC_MATRAGRAY); - Handle(V2d_View) V = new V2d_View(aWindowDriver, a3DViewer); - QAViewer2dTest::CurrentView(V); - } - Handle(V2d_View) a3DViewCol = new V2d_View(aWindowDriver, a3DCollector); - - // AIS2D setup - if (QAViewer2dTest::GetAIS2DContext().IsNull()) - { - Handle(AIS2D_InteractiveContext) C = new AIS2D_InteractiveContext(a3DViewer,a3DCollector); - QAViewer2dTest::SetAIS2DContext(C); - } - - // Setup for X11 or NT - OSWindowSetup2d(); - - // Viewer and View creation - -// a3DViewer->SetDefaultBackgroundColor(Quantity_NOC_BLACK); - - Handle(V2d_View) V = QAViewer2dTest::CurrentView(); - -// V->SetDegenerateModeOn(); -// V->SetWindow(VT_GetWindow2d()); - -// V->SetZClippingDepth(0.5); -// V->SetZClippingWidth(ZCLIPWIDTH/2.); - -// a3DViewer->SetDefaultLights(); -// a3DViewer->SetLightOn(); - -#ifndef WNT -#if TCL_MAJOR_VERSION < 8 && !defined(DECOSF1) - Tk_CreateFileHandler((void*)ConnectionNumber(display2d), - TK_READABLE, VProcessEvents2d, (ClientData) VT_GetWindow2d()->XWindow()); -#else - Tk_CreateFileHandler(ConnectionNumber(display2d), - TK_READABLE, VProcessEvents2d, (ClientData) VT_GetWindow2d()->XWindow()); -#endif -#endif - - first = 0; - } -} - -//============================================================================== -//function : V2dinit -//purpose : Create the window viewer and initialize all the global variable -// Use Tk_CreateFileHandler on UNIX to cath the X11 Viewer event -//============================================================================== -static int V2dInit (Draw_Interpretor& , Standard_Integer , char** ) -{ - QAViewer2dTest::ViewerInit(); - return 0; -} - -//============================================================================== -//function : ProcessKeyPress2d -//purpose : Handle KeyPress event from a CString -//============================================================================== -static void ProcessKeyPress2d (char *buf_ret) -{ - // Letters - if (!strcasecmp(buf_ret, "R")) - { - // Reset - QAViewer2dTest::CurrentView()->Reset(); - } - else if (!strcasecmp(buf_ret, "F")) - { - // FitAll - QAViewer2dTest::CurrentView()->Fitall(); - } - else if (!strcasecmp(buf_ret, "H")) - { - // HLR - cout << "HLR" << endl; -// QAViewer2dTest::CurrentView()->SetDegenerateModeOff(); - } - else if (!strcasecmp(buf_ret, "S")) - { - // SHADING - cout << "passage en mode 1 (shading pour les shapes)" << endl; -// QAViewer2dTest::CurrentView()->SetDegenerateModeOn(); - Handle(AIS2D_InteractiveContext) Ctx = QAViewer2dTest::GetAIS2DContext(); -// if (Ctx->NbCurrents() == 0 || Ctx->NbSelected() == 0) -// Ctx->SetDisplayMode(AIS2D_Shaded); -// else - { - if (Ctx->HasOpenedContext()) - { -// for(Ctx->InitSelected();Ctx->MoreSelected();Ctx->NextSelected()) -// Ctx->SetDisplayMode(Ctx->Interactive(), 1, Standard_False); - } - else - { -// for(Ctx->InitCurrent();Ctx->MoreCurrent();Ctx->NextCurrent()) -// Ctx->SetDisplayMode(Ctx->Current(), 1, Standard_False); - } - Ctx->UpdateCurrentViewer(); - } - } - else if (!strcasecmp(buf_ret, "U")) - { - // Unset display mode - cout << "passage au mode par defaut" << endl; -// QAViewer2dTest::CurrentView()->SetDegenerateModeOn(); - Handle(AIS2D_InteractiveContext) Ctx = QAViewer2dTest::GetAIS2DContext(); -// if (Ctx->NbCurrents() == 0 || Ctx->NbSelected() == 0) -// Ctx->SetDisplayMode(AIS2D_WireFrame); -// else - { - if(Ctx->HasOpenedContext()) - { -// for (Ctx->InitSelected(); Ctx->MoreSelected(); Ctx->NextSelected()) -// Ctx->UnsetDisplayMode(Ctx->Interactive(), Standard_False); - } - else - { -// for (Ctx->InitCurrent(); Ctx->MoreCurrent(); Ctx->NextCurrent()) -// Ctx->UnsetDisplayMode(Ctx->Current(), Standard_False); - } - Ctx->UpdateCurrentViewer(); - } - } - else if (!strcasecmp(buf_ret, "W")) - { - // WIREFRAME - cout << "passage en mode 0 (filaire pour les shapes)" << endl; -// QAViewer2dTest::CurrentView()->SetDegenerateModeOn(); - Handle(AIS2D_InteractiveContext) Ctx = QAViewer2dTest::GetAIS2DContext(); -// if (Ctx->NbCurrents() == 0 || Ctx->NbSelected() == 0) -// Ctx->SetDisplayMode(AIS2D_WireFrame); -// else - { - if (Ctx->HasOpenedContext()) - { -// for (Ctx->InitSelected(); Ctx->MoreSelected(); Ctx->NextSelected()) -// Ctx->SetDisplayMode(Ctx->Interactive(), 0, Standard_False); - } - else - { -// for (Ctx->InitCurrent(); Ctx->MoreCurrent(); Ctx->NextCurrent()) -// Ctx->SetDisplayMode(Ctx->Current(), 0, Standard_False); - } - Ctx->UpdateCurrentViewer(); - } - } - else if (!strcasecmp(buf_ret, "D")) - { - // Delete selected - cout << "Delete selected object - not yet implemented" << endl; - QAViewer2dTest::CurrentView()->Reset(); - } - else if (!strcasecmp(buf_ret, "Z")) - { - // ZCLIP - if (ZClipIsOn) - { - cout << "ZClipping OFF" << endl; - ZClipIsOn = 0; - -// QAViewer2dTest::CurrentView()->SetZClippingType(V2d_OFF); -// QAViewer2dTest::CurrentView()->Redraw(); - } - else - { - cout << "ZClipping ON" << endl; - ZClipIsOn = 1; - -// QAViewer2dTest::CurrentView()->SetZClippingType(V2d_FRONT); -// QAViewer2dTest::CurrentView()->Redraw(); - } - } - else if (!strcasecmp(buf_ret, ",")) - { -// QAViewer2dTest::GetAIS2DContext()->HilightNextDetected(QAViewer2dTest::CurrentView()); - } - else if (!strcasecmp(buf_ret, ".")) - { -// QAViewer2dTest::GetAIS2DContext()->HilightPreviousDetected(QAViewer2dTest::CurrentView()); - } - else // Number - { - Standard_Integer Num = atoi(buf_ret); - if (Num >= 0 && Num <= 7) - QAViewer2dTest::StandardModeActivation(Num); - } -} - -//============================================================================== -//function : ProcessExpose2d -//purpose : Redraw the View on an Expose Event -//============================================================================== -static void ProcessExpose2d() -{ - QAViewer2dTest::CurrentView()->Viewer()->Update(); -// QAViewer2dTest::CurrentView()->Redraw(); -} - -//============================================================================== -//function : ProcessConfigure2d -//purpose : Resize the View on an Configure Event -//============================================================================== -static void ProcessConfigure2d() -{ - Handle(V2d_View) V = QAViewer2dTest::CurrentView(); - V->MustBeResized(V2d_TOWRE_ENLARGE_OBJECTS); - V->Update(); -// V->Redraw(); - V->Viewer()->Update(); -} - -//============================================================================== -//function : V2dPickGrid -//purpose : v2dpickgrid : get coordinates of a grid point near to MB1 click -//============================================================================== -static int V2dHitGrid (int argc, Standard_Integer anX, Standard_Integer anY, - char* xxname = 0, char* yyname = 0) -{ - if (argc != 1 && argc != 3 && argc != 5) - { - cout << "Usage : V2dHitGrid [mouse_X mouse_Y [grid_X grid_Y]]" << endl; - return 1; - } - - Handle(V2d_View) V = QAViewer2dTest::CurrentView(); - if (V.IsNull()) return 1; - - if (V->Viewer()->IsActive()) // about the grid - { -// if (argc == 1) -// { -// cout << "Mouse cursor position: X = " << anX << " Y = " << anY << endl; -// } - - Quantity_Length xx, yy; - V->Hit(anX, anY, xx, yy); - - Standard_Integer xw, yw; - V->Convert(xx, yy, xw, yw); - printf("Window coords of Grid Point: X = %d Y = %d\n", xw, yw); - - if (argc < 5) - { - printf("Grid Point: X = %.6g Y = %.6g\n", xx, yy); - } - else - { - char szbuf[32]; - sprintf(szbuf, "%.6g", xx); - Draw::Set(xxname, szbuf); - sprintf(szbuf, "%.6g", yy); - Draw::Set(yyname, szbuf); - } - } - return 0; -} - -int V2dPickGrid (Draw_Interpretor& , Standard_Integer argc, char** argv) -{ - if (argc != 1 && argc != 3 && argc != 5) - { - cout << "Usage : v2dpickgrid (MB1 in the viewer)" << endl; - cout << "Usage : v2dgetgrid mouse_X mouse_Y [grid_X grid_Y]" << endl; - return 1; - } - - if (argc > 1) - { - if (argc > 3) - { - char *xxname, *yyname; - xxname = argv[3]; - yyname = argv[4]; - V2dHitGrid(argc, atoi(argv[1]), atoi(argv[2]), xxname, yyname); - } - else - { - V2dHitGrid(argc, atoi(argv[1]), atoi(argv[2])); - } - } - else - { - while (ViewerMainLoop2d (argc, argv)) {} - } - - return 0; -} - -//============================================================================== -//function : ProcessButton1Press2d -//purpose : Picking -//============================================================================== -static Standard_Boolean ProcessButton1Press2d - (Standard_Integer , char** argv, Standard_Boolean pick, Standard_Boolean shift) -{ - if (pick) - { - cout << "Window X = " << X_ButtonPress << " Window Y = " << Y_ButtonPress << endl; - if (strlen(argv[0]) > 7) // v2dpickgrid - { - V2dHitGrid(1, X_ButtonPress, Y_ButtonPress); - } - else - { - Handle(V2d_View) V = QAViewer2dTest::CurrentView(); - if (V.IsNull()) return 1; - Quantity_Length xx, yy; - V->Convert(X_ButtonPress, Y_ButtonPress, xx, yy); - printf("Coord system X = %.6g Y = %.6g\n", xx, yy); - } - } - - Handle(QAViewer2dTest_EventManager) EM = QAViewer2dTest::CurrentEventManager(); - if (shift) EM->ShiftSelect(); - else EM->Select(); - - pick = 0; - return pick; -} - -//============================================================================== -//function : ProcessButton3Press2d -//purpose : Start Rotation -//============================================================================== -static void ProcessButton3Press2d() -{ - // Start rotation - Start_Rot = 1; -// QAViewer2dTest::CurrentView()->SetDegenerateModeOn(); -// QAViewer2dTest::CurrentView()->StartRotation(X_ButtonPress, Y_ButtonPress); -} - -//============================================================================== -//function : ProcessButtonRelease2d -//purpose : End Rotation -//============================================================================== -static void ProcessButtonRelease2d() -{ - // End rotation - Start_Rot = 0; -// QAViewer2dTest::CurrentView()->SetDegenerateModeOff(); -} - -//============================================================================== -//function : ProcessZClipMotion2d -//purpose : Zoom -//============================================================================== -void ProcessZClipMotion2d() -{ - Handle(V2d_View) a3DView = QAViewer2dTest::CurrentView(); - if (Abs(X_Motion - X_ButtonPress) > 2) - { - static Standard_Real CurZPos = 0.; -// Quantity_Length VDX, VDY; - -// a3DView->Size(VDX,VDY); - -#ifdef DEB -// Standard_Real VDZ = -#endif -// a3DView->ZSize(); - - Quantity_Length dx = a3DView->Convert(X_Motion - X_ButtonPress); - - // Front = Depth + width/2. - Standard_Real D = 0.5; -// Standard_Real W = 0.1; - - CurZPos += (dx); - - D += CurZPos; - -// a3DView->SetZClippingType(V2d_OFF); -// a3DView->SetZClippingDepth(D); -// a3DView->SetZClippingWidth(W); -// a3DView->SetZClippingType(V2d_FRONT); - -// a3DView->Redraw(); - - X_ButtonPress = X_Motion; - Y_ButtonPress = Y_Motion; - } -} - -//============================================================================== -//function : ProcessControlButton1Motion2d -//purpose : Zoom on Ctrl+MB1 -//============================================================================== -static void ProcessControlButton1Motion2d() -{ - QAViewer2dTest::CurrentView()->Zoom(X_ButtonPress, Y_ButtonPress, X_Motion, Y_Motion); - - X_ButtonPress = X_Motion; - Y_ButtonPress = Y_Motion; -} - -//============================================================================== -//function : ProcessControlButton2Motion2d -//purpose : Pan on Ctrl+MB2 -//============================================================================== -static void ProcessControlButton2Motion2d() -{ - QAViewer2dTest::CurrentView()->Pan(X_Motion - X_ButtonPress, Y_ButtonPress - Y_Motion); - - X_ButtonPress = X_Motion; - Y_ButtonPress = Y_Motion; -} - -//============================================================================== -//function : ProcessControlButton3Motion2d -//purpose : Rotation on Ctrl+MB3 -//============================================================================== -static void ProcessControlButton3Motion2d() -{ -// if (Start_Rot) QAViewer2dTest::CurrentView()->Rotation(X_Motion, Y_Motion); -} - -//============================================================================== -//function : ProcessMotion2d -//purpose : pre-hilights detected objects at mouse position -//============================================================================== -static void ProcessMotion2d() -{ - Handle(QAViewer2dTest_EventManager) EM = QAViewer2dTest::CurrentEventManager(); - Handle(V2d_View) V = QAViewer2dTest::CurrentView(); - EM->MoveTo(X_Motion, Y_Motion, V); -} - -//============================================================================== -//function : ProcessGridMotion2d -//purpose : pre-hilights grid point near mouse position -//============================================================================== -static void ProcessGridMotion2d() -{ - Handle(V2d_View) V = QAViewer2dTest::CurrentView(); - - static Standard_Boolean LastIsGridActiveStatus = Standard_True; - if (V->Viewer()->IsActive()) // about the grid - { - V->ShowHit(X_Motion, Y_Motion); - LastIsGridActiveStatus = Standard_True; - } - if (!V->Viewer()->IsActive() && LastIsGridActiveStatus) // about the grid - { - V->EraseHit(); - LastIsGridActiveStatus = Standard_False; - } -} - -//============================================================================== -//function : GetMousePosition -//purpose : -//============================================================================== -void QAViewer2dTest::GetMousePosition (Standard_Integer& Xpix, Standard_Integer& Ypix) -{ - Xpix = X_Motion; - Ypix = Y_Motion; -} - -//============================================================================== -//function : V2dHelp -//purpose : Dsiplay help on viewer Keyboead and mouse commands -//Draw arg : No args -//============================================================================== -/*static int V2dHelp (Draw_Interpretor& , Standard_Integer , char** ) -{ - cout << "Q : Quit the application" << endl; - cout << "=========================" << endl; - cout << "F : FitAll" << endl; - cout << "R : ResetView" << endl; - cout << "=========================" << endl; - cout << "Selection mode " << endl; - cout << "0 : OBJECT" << endl; - cout << "1 : PRIMITIVE" << endl; - cout << "2 : ELEMENT" << endl; - cout << "3 : VERTEX" << endl; - cout << "4 : NONE" << endl; - cout << "==========================" << endl; - cout << "D : Remove Selected Object" << endl; - cout << "==========================" << endl; - - return 0; -}*/ - -#ifdef WNT - -static LRESULT WINAPI Viewer2dWindowProc (HWND hwnd, UINT Msg, - WPARAM wParam, LPARAM lParam ) -{ - static Standard_Boolean Ppick = 0; - static Standard_Integer Pargc = 0; - static char** Pargv = NULL; - - static int Up = 1; - - if (!QAViewer2dTest::CurrentView().IsNull()) - { - PAINTSTRUCT ps; - - switch (Msg) - { - case WM_PAINT: - BeginPaint(hwnd, &ps); - EndPaint(hwnd, &ps); - ProcessExpose2d(); - break; - - case WM_SIZE: - ProcessConfigure2d(); - break; - - case WM_KEYDOWN: - char c[2]; - c[0] = (char) wParam; - c[1] = '\0'; - ProcessKeyPress2d(c); - break; - - case WM_LBUTTONUP: - case WM_MBUTTONUP: - case WM_RBUTTONUP: - Up = 1; - ProcessButtonRelease2d(); - break; - - case WM_LBUTTONDOWN: - case WM_MBUTTONDOWN: - case WM_RBUTTONDOWN: - { - WPARAM fwKeys = wParam; - - Up = 0; - - X_ButtonPress = LOWORD(lParam); - Y_ButtonPress = HIWORD(lParam); - - if (Msg == WM_LBUTTONDOWN && !(fwKeys & MK_CONTROL)) - { - Ppick = ProcessButton1Press2d(Pargc, Pargv, Ppick, (fwKeys & MK_SHIFT)); - } - else if (Msg == WM_RBUTTONDOWN) - { - // Start rotation - ProcessButton3Press2d(); - } - } - break; - - case WM_MOUSEMOVE: - { - WPARAM fwKeys = wParam; - X_Motion = LOWORD(lParam); - Y_Motion = HIWORD(lParam); - - if (Up && fwKeys & (MK_LBUTTON|MK_MBUTTON|MK_RBUTTON)) - { - Up = 0; - X_ButtonPress = LOWORD(lParam); - Y_ButtonPress = HIWORD(lParam); - - if (fwKeys & MK_RBUTTON) - { - // Start rotation - ProcessButton3Press2d(); - } - } - - if (fwKeys & MK_CONTROL) - { - if (fwKeys & MK_LBUTTON) - { - ProcessControlButton1Motion2d(); - } - else if (fwKeys & MK_MBUTTON || ((fwKeys&MK_LBUTTON) && (fwKeys&MK_RBUTTON))) - { - ProcessControlButton2Motion2d(); - } - else if (fwKeys & MK_RBUTTON) - { - ProcessControlButton3Motion2d(); - } - } - else if (fwKeys & MK_SHIFT) - { - if (fwKeys & MK_MBUTTON || ((fwKeys&MK_LBUTTON) && (fwKeys&MK_RBUTTON))) - { - ProcessZClipMotion2d(); - } - } - else - { - ProcessMotion2d(); - } - } - break; - - default: - return(DefWindowProc(hwnd, Msg, wParam, lParam)); - } - return 0L; - } - - return DefWindowProc(hwnd, Msg, wParam, lParam); -} - -//============================================================================== -//function : ViewerMainLoop2d -//purpose : Get a Event on the view and dispatch it -//============================================================================== -static int ViewerMainLoop2d (Standard_Integer argc, char** argv) -{ - cout << "No yet implemented on WNT" << endl; - static Standard_Boolean Ppick = 0; - static Standard_Integer Pargc = 0; - static char** Pargv = NULL; - - Ppick = (argc > 0)? -1 : 0; - Pargc = argc; - Pargv = argv; - - if (Ppick) - { - MSG msg; - msg.wParam = 1; - - cout << "Start picking" << endl; - - while (Ppick == -1) - { - // Wait for a ProcessButton1Press2d() to toggle pick to 1 or 0 - if (GetMessage(&msg, NULL, 0, 0)) - { - TranslateMessage(&msg); - DispatchMessage(&msg); - } - } - - cout << "Picking done" << endl; - } - - return Ppick; -} - -#else - -//============================================================================== -//function : ViewerMainLoop2d -//purpose : Get a Event on the view and dispatch it -//============================================================================== -int ViewerMainLoop2d (Standard_Integer argc, char** argv) -{ - Standard_Boolean pick = argc > 0; - - // X11 Event loop - static XEvent report; - - XNextEvent(display2d, &report); - - switch (report.type) - { - case Expose: - ProcessExpose2d(); - break; - case ConfigureNotify: - ProcessConfigure2d(); - break; - case KeyPress: - { - KeySym ks_ret; - char buf_ret[11]; - int ret_len; - XComposeStatus status_in_out; - - ret_len = XLookupString((XKeyEvent *)&report, (char *) buf_ret, - 10, &ks_ret, &status_in_out); - - buf_ret[ret_len] = '\0'; - if (ret_len) ProcessKeyPress2d(buf_ret); - } - break; - case ButtonPress: - { - X_ButtonPress = report.xbutton.x; - Y_ButtonPress = report.xbutton.y; - - if (report.xbutton.button == Button1 && - !(report.xbutton.state & ControlMask)) - { - pick = ProcessButton1Press2d(argc, argv, pick, - (report.xbutton.state & ShiftMask)); - } - else if (report.xbutton.button == Button3) - { - // Start rotation - ProcessButton3Press2d(); - } - } - break; - case ButtonRelease: - ProcessButtonRelease2d(); - break; - case MotionNotify: - { - X_Motion = report.xmotion.x; - Y_Motion = report.xmotion.y; - - // remove all the ButtonMotionMask - while (XCheckMaskEvent(display2d, ButtonMotionMask, &report)) {} - - if (ZClipIsOn && report.xmotion.state & ShiftMask) - { - if (Abs(X_Motion - X_ButtonPress) > 2) - { - Quantity_Length VDX = 0.0, VDY = 0.0; - -// QAViewer2dTest::CurrentView()->Size(VDX,VDY); - Standard_Real VDZ =0 ; -// VDZ = QAViewer2dTest::CurrentView()->ZSize(); - - printf("%f,%f,%f\n", VDX, VDY, VDZ); - - Quantity_Length dx = 0 ; - dx = QAViewer2dTest::CurrentView()->Convert(X_Motion - X_ButtonPress); - - cout << dx << endl; - - dx = dx / VDX * VDZ; - - cout << dx << endl; - - // Front = Depth + width/2. - //QAViewer2dTest::CurrentView()->SetZClippingDepth(dx); - //QAViewer2dTest::CurrentView()->SetZClippingWidth(0.); - -// QAViewer2dTest::CurrentView()->Redraw(); - } - } - - if (report.xmotion.state & ControlMask) - { - if (report.xmotion.state & Button1Mask) - { - ProcessControlButton1Motion2d(); - } - else if (report.xmotion.state & Button2Mask) - { - ProcessControlButton2Motion2d(); - } - else if (report.xmotion.state & Button3Mask) - { - ProcessControlButton3Motion2d(); - } - } - else - { - if (pick && strlen(argv[0]) > 7) // v2dpickgrid - ProcessGridMotion2d(); - else - ProcessMotion2d(); - } - } - break; - } - - return pick; -} - -//============================================================================== -//function : VProcessEvents2d -//purpose : call by Tk_CreateFileHandler() to be able to manage the -// event in the Viewer window -//============================================================================== -static void VProcessEvents2d (ClientData, int) -{ - // test for X Event - while (XPending(display2d)) - { - ViewerMainLoop2d(0, NULL); - } -} -#endif - -//============================================================================== -//function : OSWindowSetup2d -//purpose : Setup for the X11 window to be able to cath the event -//============================================================================== -static void OSWindowSetup2d() -{ -#ifndef WNT - // X11 - Window window = VT_GetWindow2d()->XWindow(); - - Standard_Address theDisplay = GetG2dDevice()->XDisplay(); - display2d = (Display * ) theDisplay; - - XSynchronize(display2d, 1); - - VT_GetWindow2d()->Map(); - - // X11 : For keyboard on SUN - XWMHints wmhints; - wmhints.flags = InputHint; - wmhints.input = 1; - - XSetWMHints( display2d, window, &wmhints); - - XSelectInput(display2d, window, - ExposureMask | StructureNotifyMask | KeyPressMask | ButtonPressMask | - PointerMotionMask | - Button1MotionMask | Button2MotionMask | Button3MotionMask); - - XSynchronize(display2d, 0); - -#else - // WNT -#endif - -} - -//============================================================================== -//function : InitQAViewer2dTest -//purpose : initialisation de toutes les variables static de QAViewer2dTest (dp) -//============================================================================== -void QAViewer2dTest_InitQAViewer2dTest (const Handle(AIS2D_InteractiveContext)& context) -{ - Handle(V2d_Viewer) viewer = context->CurrentViewer(); - QAViewer2dTest::SetAIS2DContext(context); - viewer->InitActiveViews(); - Handle(V2d_View) view = viewer->ActiveView(); - if (viewer->MoreActiveViews()) QAViewer2dTest::CurrentView(view); - QAViewer2dTest::ResetEventManager(); - Handle(Aspect_GraphicDevice) device = viewer->Device(); - Handle(Aspect_WindowDriver) aWDr = view->Driver(); - Handle(Aspect_Window) window = aWDr->Window(); -#ifndef WNT - // X11 - VT_GetWindow2d() = Handle(Xw_Window)::DownCast(window); - GetG2dDevice() = Handle(Graphic3d_GraphicDevice)::DownCast(device); - OSWindowSetup2d(); - static int first = 1; - if (first) - { -#if TCL_MAJOR_VERSION < 8 && !defined(DECOSF1) - Tk_CreateFileHandler((void*)ConnectionNumber(display2d), - TK_READABLE, VProcessEvents2d, (ClientData) 0); -#else - Tk_CreateFileHandler(ConnectionNumber(display2d), - TK_READABLE, VProcessEvents2d, (ClientData) 0); -#endif - first = 0; - } -#endif -} - -//============================================================================== -//function : V2dFit -//purpose : Fitall, no DRAW arguments -//Draw arg : No args -//============================================================================== -static int V2dFit (Draw_Interpretor& , Standard_Integer , char** ) -{ - Handle(V2d_View) V = QAViewer2dTest::CurrentView(); - if (!V.IsNull()) V->Fitall(); - return 0; -} - -//============================================================================== -//function : V2dRepaint -//purpose : refresh viewer -//Draw arg : No args -//============================================================================== -static int V2dRepaint (Draw_Interpretor& , Standard_Integer , char** ) -{ - Handle(V2d_View) V = QAViewer2dTest::CurrentView(); - if (!V.IsNull()) -// V->Redraw(); - V->Viewer()->Update(); - return 0; -} - -//============================================================================== -//function : V2dClear -//purpose : Remove all the object from the viewer -//Draw arg : No args -//============================================================================== -static int V2dClear (Draw_Interpretor& , Standard_Integer , char** ) -{ - Handle(V2d_View) V = QAViewer2dTest::CurrentView(); - if (V.IsNull()) return 1; - - QAViewer2dTest::Clear(); - V->Viewer()->Update(); - return 0; -} - -//============================================================================== -//function : V2dPick -//purpose : v2dpick - print mouse coords and color -//============================================================================== -static int V2dPick (Draw_Interpretor& , Standard_Integer argc, char** argv) -{ - if (argc != 1) - { - cout << "Usage: v2dpick (MB1 in the viewer)" << endl; - return 1; - } - if (QAViewer2dTest::CurrentView().IsNull()) return 1; - - while (ViewerMainLoop2d (argc, argv)) {} - - return 0; -} - -//============================================================================== -//function : V2dSetBG -//purpose : v2dsetbg imagefile [filltype] : load image as background -//============================================================================== -static int V2dSetBG (Draw_Interpretor& , Standard_Integer argc, char** argv) -{ - if (argc < 2 || argc > 3) - { - cout << "Usage : v2dsetbg imagefile [filltype]" << endl; - return 1; - } - if (QAViewer2dTest::CurrentView().IsNull()) return 1; - - Aspect_FillMethod aFillType = Aspect_FM_CENTERED; - if (argc == 3) - { - char* szType = argv[2]; - if (strcmp(szType, "NONE" ) == 0) aFillType = Aspect_FM_NONE; - else if (strcmp(szType, "CENTERED") == 0) aFillType = Aspect_FM_CENTERED; - else if (strcmp(szType, "TILED" ) == 0) aFillType = Aspect_FM_TILED; - else if (strcmp(szType, "STRETCH" ) == 0) aFillType = Aspect_FM_STRETCH; - else - { - cout << "Wrong fill type : " << szType << endl; - cout << "Must be one of CENTERED, TILED, STRETCH, NONE" << endl; - return -1; - } - } - - QAViewer2dTest::CurrentView()->SetBackground(argv[1], aFillType); - QAViewer2dTest::CurrentView()->Viewer()->Update(); - - return 0; -} - -//============================================================================== -//function : V2dGrid -//purpose : v2dgrid [type [Origin(X Y) XStep/RadiusStep YStep/DivisionNb RotationAngle] [drawmode]] : load grid -// : v2drmgrid : unload grid -//============================================================================== -static int V2dGrid (Draw_Interpretor& , Standard_Integer argc, char** argv) -{ - if (QAViewer2dTest::CurrentView().IsNull()) return 1; - Handle(V2d_Viewer) aViewer = QAViewer2dTest::CurrentView()->Viewer(); - - char* szName = argv[0]; - if (strcmp(szName, "v2drmgrid") == 0) - { - if (argc > 1) - { - cout << "Usage : v2drmgrid" << endl; - return 1; - } - - aViewer->DeactivateGrid(); - return 0; - } - - // v2dgrid. Args nb may be 1,2,3,7,8 - if (argc < 1 || argc > 8 || (argc < 7 && argc > 3)) - { - cout << "Usage : v2dgrid [type [Origin(X Y) XStep/RadiusStep YStep/DivisionNb RotationAngle] [drawmode]]" << endl; - return 1; - } - - Aspect_GridType aGridT = Aspect_GT_Rectangular; - Aspect_GridDrawMode aDrawM = Aspect_GDM_Lines; - - if (argc > 1) - { - char* szType = argv[1]; - if (strcmp(szType, "Rect") == 0) aGridT = Aspect_GT_Rectangular; - else if (strcmp(szType, "Circ") == 0) aGridT = Aspect_GT_Circular; - else - { - cout << "Wrong grid type : " << szType << endl; - cout << "Must be Rect or Circ" << endl; - return -1; - } - - if (argc == 3 || argc == 8) - { - char* szMode = (argc == 3) ? argv[2] : argv[7]; - if (strcmp(szMode, "Lines" ) == 0) aDrawM = Aspect_GDM_Lines; - else if (strcmp(szMode, "Points") == 0) aDrawM = Aspect_GDM_Points; - else if (strcmp(szMode, "None" ) == 0) aDrawM = Aspect_GDM_None; - else - { - cout << "Wrong grid draw mode : " << szMode << endl; - cout << "Must be Lines or Points, or None" << endl; - return -1; - } - } - } - - aViewer->ActivateGrid(aGridT, aDrawM); - - if (argc > 3) - { - Quantity_Length aXOrigin = atof(argv[2]); - Quantity_Length aYOrigin = atof(argv[3]); - Quantity_PlaneAngle aRotationAngle = atof(argv[6]); - - if (aGridT == Aspect_GT_Rectangular) - { - Quantity_Length aXStep = atof(argv[4]); - Quantity_Length aYStep = atof(argv[5]); - aViewer->SetRectangularGridValues - (aXOrigin, aYOrigin, aXStep, aYStep, aRotationAngle); - } - else - { - Quantity_Length aRadiusStep = atof(argv[4]); - Standard_Integer aDivisionNumber = atoi(argv[5]); - aViewer->SetCircularGridValues - (aXOrigin, aYOrigin, aRadiusStep, aDivisionNumber, aRotationAngle); - } - } - - return 0; -} - -//============================================================================== -//function : V2dPSOut -//purpose : v2dpsout imagefile [Scale TypeOfColorSpace] [Width Height XCenter YCenter] : PostScript Output -//============================================================================== -static int V2dPSOut (Draw_Interpretor& , Standard_Integer argc, char** argv) -{ - if (argc < 2 || argc > 8) - { - cout << "Usage : v2dpsout imagefile [Scale TypeOfColorSpace] [Width Height XCenter YCenter]" << endl; - return 1; - } - - Handle(V2d_View) V = QAViewer2dTest::CurrentView(); - if (V.IsNull()) return 1; - - Quantity_Factor aScale = 1.0; - Aspect_TypeOfColorSpace aColorType = Aspect_TOCS_RGB; - - Quantity_Length aWidth = 100.0, aHeight = 100.0; - - Quantity_Length aXCenter, aYCenter; - V->Center(aXCenter, aYCenter); - - if (argc > 2) - { - aScale = atof(argv[2]); - - if (argc > 3) - { - char* szType = argv[3]; - if (strcmp(szType, "RGB") == 0) aColorType = Aspect_TOCS_RGB; - else if (strcmp(szType, "BlackAndWhite") == 0) aColorType = Aspect_TOCS_BlackAndWhite; - else if (strcmp(szType, "GreyScale") == 0) aColorType = Aspect_TOCS_GreyScale; - else - { - cout << "Wrong color space type : " << szType << endl; - cout << "Must be one of RGB, BlackAndWhite, GreyScale" << endl; - return -1; - } - - if (argc == 8) - { - aWidth = atof(argv[4]); - aHeight = atof(argv[5]); - aXCenter = atof(argv[6]); - aYCenter = atof(argv[7]); - } - else // take current window size - { -#ifndef WNT - Handle(Aspect_Window) anAspWindow = V->Driver()->Window(); - Handle(Xw_Window) anXWindow = Handle(Xw_Window)::DownCast(anAspWindow); - anXWindow->Size(aWidth, aHeight); -#endif - } - } - } - - QAViewer2dTest::CurrentView()->PostScriptOutput - (argv[1], aWidth, aHeight, aXCenter, aYCenter, aScale, aColorType); - - return 0; -} - -//============================================================================== -//function : V2dPlot -//purpose : v2dplot format imagefile [Scale TypeOfColorSpace] [Width Height XCenter YCenter] -//============================================================================== -/*static int V2dPlot (Draw_Interpretor& , Standard_Integer argc, char** argv) -{ - if (argc < 3 || argc > 9) - { - cout << "Args: format imagefile [Scale TypeOfColorSpace] [Width Height XCenter YCenter]" << endl; - return 1; - } - if (QAViewer2dTest::CurrentView().IsNull()) return 1; - - Quantity_Factor aScale = 1.0; - Aspect_TypeOfColorSpace aColorType = Aspect_TOCS_RGB; - - Quantity_Length aWidth = 100.0, aHeight = 100.0; - - Quantity_Length aXCenter, aYCenter; - QAViewer2dTest::CurrentView()->Center(aXCenter, aYCenter); - - if (argc > 3) - { - aScale = atof(argv[3]); - - if (argc > 4) - { - char* szType = argv[4]; - if (strcmp(szType, "RGB") == 0) aColorType = Aspect_TOCS_RGB; - else if (strcmp(szType, "BlackAndWhite") == 0) aColorType = Aspect_TOCS_BlackAndWhite; - else if (strcmp(szType, "GreyScale") == 0) aColorType = Aspect_TOCS_GreyScale; - else - { - cout << "Wrong color space type : " << szType << endl; - cout << "Must be one of RGB, BlackAndWhite, GreyScale" << endl; - return -1; - } - - if (argc == 9) - { - aWidth = atof(argv[5]); - aHeight = atof(argv[6]); - aXCenter = atof(argv[7]); - aYCenter = atof(argv[8]); - } - } - } - - char* szFormat = argv[1]; - if (strcmp(szFormat, "PS") == 0) - { - Handle(PS_Driver) aPSDriver = new PS_Driver(argv[2], aWidth, aHeight, aColorType); - QAViewer2dTest::CurrentView()->Plot(aPSDriver, aXCenter, aYCenter, aScale); - } - else if (strcmp(szFormat, "") == 0) - { - Handle(PS_Driver) aPSDriver = new PS_Driver(argv[2], aWidth, aHeight, aColorType); - QAViewer2dTest::CurrentView()->Plot(aPSDriver, aXCenter, aYCenter, aScale); - } - else if (strcmp(szFormat, "") == 0) - { - } - else - { - } - - return 0; -}*/ - -//======================================================================= -//function : V2dTextColor -//purpose : v2dsettextcolor text_name color_index -//======================================================================= -static int V2dTextColor (Draw_Interpretor& , int argc, char** argv) -{ - if (argc != 3) - { - cerr << "Usage : v2dsettextcolor text_name color_index" << endl; - return -1; - } - - //////////////////TCollection_AsciiString aName (argv[1]); - TCollection_ExtendedString ExtendedString (argv[1]); - Standard_ExtString aName = ExtendedString.ToExtString(); - - if (!myMapOfText.IsBound(aName)) - { - cout << "No such text object: " << aName << endl; - return -1; - } - - int aColInd = atoi(argv[2]); - -#ifdef OCC199 - // check color index - Standard_Integer aColMin, aColMax; - QAViewer2dTest::CurrentView()->Driver()->ColorBoundIndexs(aColMin, aColMax); - if (aColInd < aColMin || aColMax < aColInd) - { - cout << "Color index must be between " << aColMin << " and " << aColMax << endl; - return -1; - } -#endif - - myMapOfText(aName)->SetColorIndex(aColInd); - QAViewer2dTest::CurrentView()->Viewer()->Update(); - return 0; -} - -//======================================================================= -//function : V2dText -//purpose : v2dtext text_str position(x y) [angle scale font] -//======================================================================= -static int V2dText (Draw_Interpretor& , int argc, char** argv) -{ - if (argc != 4 && argc != 7) - { - cerr << "Usage : v2dtext text_str position(x y) [angle scale font]" << endl; - return -1; - } - - Handle(AIS2D_InteractiveContext) myAIScontext = QAViewer2dTest::GetAIS2DContext(); - if (myAIScontext.IsNull()) - { - cerr << "use 'v2dinit' command before " << argv[0] << endl; - return -1; - } - myAIScontext->SetPickMode(Graphic2d_PM_INTERSECT); - Handle(V2d_View) V = QAViewer2dTest::CurrentView(); - - Handle(Graphic2d_GraphicObject) obj = - new Graphic2d_GraphicObject(V->View()); - - Quantity_PlaneAngle anAngle = 0.0; - Quantity_Factor aScale = 1.0; - Standard_Integer aFontIn = 0; - - if (argc > 4) - { - anAngle = atof(argv[4]); - aScale = atof(argv[5]); - aFontIn = atoi(argv[6]); - -#ifdef OCC198 - // check font index - Standard_Integer aFontMin, aFontMax; - QAViewer2dTest::CurrentView()->Driver()->FontBoundIndexs(aFontMin, aFontMax); - if (aFontIn < aFontMin || aFontMax < aFontIn) - { - cout << "Font index must be between " << aFontMin << " and " << aFontMax << endl; - return -1; - } -#endif - } - - Handle(Graphic2d_Text) text = - new Graphic2d_Text(obj, TCollection_ExtendedString(argv[1]), - atof(argv[2]), atof(argv[3]), anAngle, - Aspect_TOT_SOLID, aScale); - text->SetFontIndex(aFontIn); - - obj->Display(); - V->Fitall(); - - int i = myMapOfText.Extent(); - - TCollection_AsciiString aTxtName ("text_"); - aTxtName += TCollection_AsciiString(i); - - //////////////////myMapOfText.Bind(aTxtName, text); - TCollection_ExtendedString ExtendedString (aTxtName); - Standard_ExtString ExtString_aTxtName = ExtendedString.ToExtString(); - myMapOfText.Bind(ExtString_aTxtName, text); - - cout << "Text " << aTxtName << " created" << endl; - return 0; -} - -//======================================================================= -//function : ViewerCommands -//purpose : -//======================================================================= -void QAViewer2dTest::ViewerCommands(Draw_Interpretor& theCommands) -{ - char *group = "2D AIS Viewer - Viewer Commands"; - - theCommands.Add("v2dinit", - "v2dinit : Create the Viewer window", - __FILE__, V2dInit, group); - - theCommands.Add("v2dsetbg", - "v2dsetbg imagefile [filltype] : Load image as background", - __FILE__, V2dSetBG, group); - - theCommands.Add("v2dgrid", - "v2dgrid [type [Origin(X Y) XStep/RadiusStep YStep/DivisionNb RotationAngle(in radians)] [drawmode]] : Load grid", - __FILE__, V2dGrid, group); - - theCommands.Add("v2drmgrid", - "v2drmgrid : Unload grid", - __FILE__, V2dGrid, group); - -// theCommands.Add("v2dplot", -// "v2dplot format filename : Dump in file in certain format", -// __FILE__, V2dPlot, group); - - theCommands.Add("v2dpsout", - "v2dpsout imagefile [Scale TypeOfColorSpace] [Width Height XCenter YCenter] : PostScript Output", - __FILE__, V2dPSOut, group); - - theCommands.Add("v2dpick", - "v2dpick (MB1 in the viewer) : Print pixel coords and color", - __FILE__, V2dPick, group); - - theCommands.Add("v2dpickgrid", - "v2dpickgrid (MB1 in the viewer) : Print coordinates of a grid point near to MB1 click", - __FILE__, V2dPickGrid, group); - - theCommands.Add("v2dfit", - "v2dfit or : Fit all shapes", - __FILE__, V2dFit, group); - - theCommands.Add("v2drepaint", - "v2drepaint : Force redraw", - __FILE__, V2dRepaint, group); - - theCommands.Add("v2dclear", - "v2dclear : Clear the viewer", - __FILE__, V2dClear, group); - - theCommands.Add("v2dtext", "v2dtext text_str position(x y) [angle scale font]", V2dText, group); - theCommands.Add("v2dsettextcolor", "v2dsettextcolor text_name color_index", V2dTextColor, group); - -// theCommands.Add("v2dhelp", -// "v2dhelp : Display help on the viewer commands", -// __FILE__, V2dHelp, group); -} -#endif diff --git a/src/Select2D/Select2D.cdl b/src/Select2D/Select2D.cdl deleted file mode 100755 index 82520b65a7..0000000000 --- a/src/Select2D/Select2D.cdl +++ /dev/null @@ -1,69 +0,0 @@ --- Created on: 1995-01-26 --- Created by: Mister rmi --- Copyright (c) 1995-1999 Matra Datavision --- Copyright (c) 1999-2012 OPEN CASCADE SAS --- --- The content of this file is subject to the Open CASCADE Technology Public --- License Version 6.5 (the "License"). You may not use the content of this file --- except in compliance with the License. Please obtain a copy of the License --- at http://www.opencascade.org and read it completely before using this file. --- --- The Initial Developer of the Original Code is Open CASCADE S.A.S., having its --- main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. --- --- The Original Code and all software distributed under the License is --- distributed on an "AS IS" basis, without warranty of any kind, and the --- Initial Developer hereby disclaims all such warranties, including without --- limitation, any warranties of merchantability, fitness for a particular --- purpose or non-infringement. Please see the License for the specific terms --- and conditions governing the rights and limitations under the License. - - - - -package Select2D - - ---Purpose: Dynamic Selection Tools; - -- description of sensitive primitives for 3D Objects - -- - - -uses - gp, - Bnd, - SelectBasics, - TColgp, - MMgt -is - - - enumeration TypeOfSelection is TOS_BOUNDARY,TOS_INTERIOR - end TypeOfSelection; - ---Purpose: for closed geometries (Circle ,Ellipse) - -- one can use the same sensitive entity to represent - -- a face or a boundary ... - - - deferred class SensitiveEntity; - - - class SensitivePoint; - - class SensitiveSegment; - - class SensitiveCircle; - - class SensitiveArc; - - class SensitiveBox; - - - - deferred class Projector; - -end Select2D; - - - - - diff --git a/src/Select2D/Select2D_Projector.cdl b/src/Select2D/Select2D_Projector.cdl deleted file mode 100755 index ae7b394b70..0000000000 --- a/src/Select2D/Select2D_Projector.cdl +++ /dev/null @@ -1,45 +0,0 @@ --- Created on: 1995-04-21 --- Created by: Robert COUBLANC --- Copyright (c) 1995-1999 Matra Datavision --- Copyright (c) 1999-2012 OPEN CASCADE SAS --- --- The content of this file is subject to the Open CASCADE Technology Public --- License Version 6.5 (the "License"). You may not use the content of this file --- except in compliance with the License. Please obtain a copy of the License --- at http://www.opencascade.org and read it completely before using this file. --- --- The Initial Developer of the Original Code is Open CASCADE S.A.S., having its --- main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. --- --- The Original Code and all software distributed under the License is --- distributed on an "AS IS" basis, without warranty of any kind, and the --- Initial Developer hereby disclaims all such warranties, including without --- limitation, any warranties of merchantability, fitness for a particular --- purpose or non-infringement. Please see the License for the specific terms --- and conditions governing the rights and limitations under the License. - - - - -deferred class Projector from Select2D inherits TShared from MMgt - - ---Purpose: An abstract framework to define a projector. - -- StdSelect_TextProjector2d inherits this framework - -- and provides a projector for texts. - -uses - Pnt2d from gp, - Trsf2d from gp - -is - Initialize; - - Convert (me;aPointIn : Pnt2d from gp; - aPointOut : out Pnt2d from gp) is deferred; - -fields - - mytrsf : Trsf2d from gp is protected; - - -end Projector; diff --git a/src/Select2D/Select2D_Projector.cxx b/src/Select2D/Select2D_Projector.cxx deleted file mode 100755 index b16389502a..0000000000 --- a/src/Select2D/Select2D_Projector.cxx +++ /dev/null @@ -1,27 +0,0 @@ -// Created on: 1995-04-21 -// Created by: Robert COUBLANC -// Copyright (c) 1995-1999 Matra Datavision -// Copyright (c) 1999-2012 OPEN CASCADE SAS -// -// The content of this file is subject to the Open CASCADE Technology Public -// License Version 6.5 (the "License"). You may not use the content of this file -// except in compliance with the License. Please obtain a copy of the License -// at http://www.opencascade.org and read it completely before using this file. -// -// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its -// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. -// -// The Original Code and all software distributed under the License is -// distributed on an "AS IS" basis, without warranty of any kind, and the -// Initial Developer hereby disclaims all such warranties, including without -// limitation, any warranties of merchantability, fitness for a particular -// purpose or non-infringement. Please see the License for the specific terms -// and conditions governing the rights and limitations under the License. - - - -#include - - -Select2D_Projector::Select2D_Projector() -{} diff --git a/src/Select2D/Select2D_SensitiveArc.cdl b/src/Select2D/Select2D_SensitiveArc.cdl deleted file mode 100755 index 80b4408151..0000000000 --- a/src/Select2D/Select2D_SensitiveArc.cdl +++ /dev/null @@ -1,82 +0,0 @@ --- Created on: 1995-05-23 --- Created by: Robert COUBLANC --- Copyright (c) 1995-1999 Matra Datavision --- Copyright (c) 1999-2012 OPEN CASCADE SAS --- --- The content of this file is subject to the Open CASCADE Technology Public --- License Version 6.5 (the "License"). You may not use the content of this file --- except in compliance with the License. Please obtain a copy of the License --- at http://www.opencascade.org and read it completely before using this file. --- --- The Initial Developer of the Original Code is Open CASCADE S.A.S., having its --- main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. --- --- The Original Code and all software distributed under the License is --- distributed on an "AS IS" basis, without warranty of any kind, and the --- Initial Developer hereby disclaims all such warranties, including without --- limitation, any warranties of merchantability, fitness for a particular --- purpose or non-infringement. Please see the License for the specific terms --- and conditions governing the rights and limitations under the License. - - - - -class SensitiveArc from Select2D -inherits SensitiveEntity from Select2D - - ---Purpose: sensitive Areas for an Arc Of Circle - -- One gives Radius and center,and limits. - -- or a geometric circle. - -uses - Ax2d from gp, - EntityOwner from SelectBasics, - ListOfBox2d from SelectBasics - -is - Create (OwnerId : EntityOwner from SelectBasics; - OriginAxis : Ax2d from gp; - Angle : Real from Standard; - Radius : Real from Standard; - MaxPoints : Integer=9) - returns mutable SensitiveArc ; - ---Level: Public - ---Purpose: Constructs a 2D sensitive arc object defined by the - -- owner OwnerId, the axis of origin OriginAxis, the - -- angle Angle, the radius Radius, and the maximum - -- number of points MaxPoints. - -- - -- _. - -- \ angle /| - -- \_____/ - -- \ / direction - -- \ / - -- * - - Areas (me:mutable ; aresul : in out ListOfBox2d from SelectBasics) is static; - ---Level: Public - ---Purpose: returns the sensitive areas for a circle... - - Matches (me : mutable ; - X,Y : Real from Standard; - aTol: Real from Standard; - DMin: out Real from Standard) - returns Boolean is static; - ---Purpose: returns true if the minimum distance DMin - -- between the postion x,y and the circle is less than aTol.. - - - Matches (me :mutable; - XMin,YMin,XMax,YMax : Real from Standard; - aTol: Real from Standard) - returns Boolean - is static; - -fields - - myradius : Real; - myax2d : Ax2d from gp; - myangle : Real; - mynbpt : Integer; -end SensitiveArc; - diff --git a/src/Select2D/Select2D_SensitiveArc.cxx b/src/Select2D/Select2D_SensitiveArc.cxx deleted file mode 100755 index a679d5f19a..0000000000 --- a/src/Select2D/Select2D_SensitiveArc.cxx +++ /dev/null @@ -1,126 +0,0 @@ -// Created on: 1995-05-23 -// Created by: Robert COUBLANC -// Copyright (c) 1995-1999 Matra Datavision -// Copyright (c) 1999-2012 OPEN CASCADE SAS -// -// The content of this file is subject to the Open CASCADE Technology Public -// License Version 6.5 (the "License"). You may not use the content of this file -// except in compliance with the License. Please obtain a copy of the License -// at http://www.opencascade.org and read it completely before using this file. -// -// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its -// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. -// -// The Original Code and all software distributed under the License is -// distributed on an "AS IS" basis, without warranty of any kind, and the -// Initial Developer hereby disclaims all such warranties, including without -// limitation, any warranties of merchantability, fitness for a particular -// purpose or non-infringement. Please see the License for the specific terms -// and conditions governing the rights and limitations under the License. - - - - -#include -#include -#include -#include -#include -//#include <.hxx> -//#include <.hxx> -//#include <.hxx> - - -//================================================== -// Function: Constructor -// Purpose : -//================================================== - -Select2D_SensitiveArc:: -Select2D_SensitiveArc(const Handle(SelectBasics_EntityOwner)& OwnerId, - const gp_Ax2d& OriginAxis, - const Standard_Real Angle, - const Standard_Real Radius, - const Standard_Integer NbPoints): -Select2D_SensitiveEntity(OwnerId), -myradius(Radius), -myax2d( OriginAxis), -myangle(Angle), -mynbpt(NbPoints) - -{ - if(myangle<=Precision::Confusion()) myangle=2*M_PI; -} - - -//===================================================== -// Function : Areas -// Purpose : -//===================================================== - -void Select2D_SensitiveArc:: -Areas (SelectBasics_ListOfBox2d& boxes) -{ - Bnd_Box2d abox; - Standard_Real deteta =myangle/mynbpt; - - - gp_Pnt2d P1 = myax2d.Location().Translated(gp_Vec2d(myax2d.Direction())*myradius); - - abox.Set(P1); - for(Standard_Integer i=1;i<=mynbpt;i++){ - abox.Add(P1.Rotated(myax2d.Location(),deteta*i));} - boxes.Append(abox); -} - - -//===================================================== -// Function : Matches -// Purpose : -//===================================================== -Standard_Boolean Select2D_SensitiveArc:: -Matches (const Standard_Real X, - const Standard_Real Y, - const Standard_Real aTol, - Standard_Real& DMin) -{ - Standard_Real TheTol = HasOwnTolerance()? myOwnTolerance : aTol; - - gp_Pnt2d Pick(X,Y); - Standard_Real Angle = (gp_Dir2d(gp_Vec2d(myax2d.Location(),Pick))).Angle(myax2d.Direction()); - if(Angle<0 && Angle>myangle) return Standard_False; - else - { - DMin =myax2d.Location().Distance(Pick); - if (DMin>myradius-TheTol&&DMin<=myradius+TheTol) return Standard_True; - } - return Standard_False; -} - -Standard_Boolean Select2D_SensitiveArc:: -Matches (const Standard_Real XMin, - const Standard_Real YMin, - const Standard_Real XMax, - const Standard_Real YMax, - const Standard_Real aTol) -{ - Standard_Real TheTol = HasOwnTolerance()? myOwnTolerance : aTol; - if(mynbpt<1) return Standard_True; //to avoid problems... - - Standard_Real deteta = myangle/mynbpt; - Bnd_Box2d BoundBox; - BoundBox.Update(XMin-TheTol,YMin-TheTol,XMax+TheTol,YMax+TheTol); - gp_Pnt2d ExtPt = myax2d.Location().Translated(gp_Vec2d(myax2d.Direction())*myradius); - - if(BoundBox.IsOut(ExtPt)) return Standard_False; - - for (Standard_Integer I=1;I<=mynbpt;I++) - { - if(BoundBox.IsOut(ExtPt.Rotated(myax2d.Location(),deteta*I))) return Standard_False; - } - return Standard_True; -} - - - - diff --git a/src/Select2D/Select2D_SensitiveBox.cdl b/src/Select2D/Select2D_SensitiveBox.cdl deleted file mode 100755 index fc223381db..0000000000 --- a/src/Select2D/Select2D_SensitiveBox.cdl +++ /dev/null @@ -1,86 +0,0 @@ --- Created on: 1995-01-31 --- Created by: Mister rmi --- Copyright (c) 1995-1999 Matra Datavision --- Copyright (c) 1999-2012 OPEN CASCADE SAS --- --- The content of this file is subject to the Open CASCADE Technology Public --- License Version 6.5 (the "License"). You may not use the content of this file --- except in compliance with the License. Please obtain a copy of the License --- at http://www.opencascade.org and read it completely before using this file. --- --- The Initial Developer of the Original Code is Open CASCADE S.A.S., having its --- main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. --- --- The Original Code and all software distributed under the License is --- distributed on an "AS IS" basis, without warranty of any kind, and the --- Initial Developer hereby disclaims all such warranties, including without --- limitation, any warranties of merchantability, fitness for a particular --- purpose or non-infringement. Please see the License for the specific terms --- and conditions governing the rights and limitations under the License. - - - -class SensitiveBox from Select2D -inherits SensitiveEntity from Select2D - - ---Purpose: defines a Sensitive Box (inside or boundary) - -uses - Pnt2d from gp, - Box2d from Bnd, - ListOfBox2d from SelectBasics, - EntityOwner from SelectBasics, - TypeOfSelection - -is - Create (OwnerId : EntityOwner from SelectBasics; - Center : Pnt2d from gp; - Height,Width : Real from Standard; - Type : TypeOfSelection = Select2D_TOS_INTERIOR) - returns mutable SensitiveBox; - ---Purpose: Constructs a sensitive box object defined by the - -- owner OwnerId, the center point Center, the height - -- Height, the width Width, and the selection type Type. - -- Type can be: - -- - interior - -- - boundary. - - Create (OwnerId : EntityOwner from SelectBasics; - Xmin,YMin,XMax,YMax : Real; - Type : TypeOfSelection = Select2D_TOS_INTERIOR) - returns mutable SensitiveBox; - - ---Purpose: Constructs a sensitive box object defined by the - -- owner OwnerId, the coordinates Xmin, YMin, XMax, - -- YMax, and the selection type Type. - -- Xmin, YMin define the minimum point in the lower left - -- hand corner of the box, and XMax, YMax define the - -- maximum point in the upper right hand corner of the box. - -- Type can be: - -- - interior - -- - boundary. - - Areas (me:mutable ; aresul : in out ListOfBox2d from SelectBasics) is static; - - - Matches (me : mutable; - X,Y : Real from Standard; - aTol : Real from Standard; - DMin : out Real from Standard) - returns Boolean is static; - - - Matches (me :mutable; - XMin,YMin,XMax,YMax : Real from Standard; - aTol: Real from Standard) - returns Boolean - is static; - - -fields - - mybox : Box2d from Bnd; - mytype : TypeOfSelection; - - -end SensitiveBox; diff --git a/src/Select2D/Select2D_SensitiveBox.cxx b/src/Select2D/Select2D_SensitiveBox.cxx deleted file mode 100755 index ff483ad39a..0000000000 --- a/src/Select2D/Select2D_SensitiveBox.cxx +++ /dev/null @@ -1,119 +0,0 @@ -// Created on: 1995-01-31 -// Created by: Mister rmi -// Copyright (c) 1995-1999 Matra Datavision -// Copyright (c) 1999-2012 OPEN CASCADE SAS -// -// The content of this file is subject to the Open CASCADE Technology Public -// License Version 6.5 (the "License"). You may not use the content of this file -// except in compliance with the License. Please obtain a copy of the License -// at http://www.opencascade.org and read it completely before using this file. -// -// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its -// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. -// -// The Original Code and all software distributed under the License is -// distributed on an "AS IS" basis, without warranty of any kind, and the -// Initial Developer hereby disclaims all such warranties, including without -// limitation, any warranties of merchantability, fitness for a particular -// purpose or non-infringement. Please see the License for the specific terms -// and conditions governing the rights and limitations under the License. - - -#include -#include - -//============================================================= -// Function : Constructor -// Purpose : -//============================================================= - - -Select2D_SensitiveBox:: -Select2D_SensitiveBox (const Handle(SelectBasics_EntityOwner)& OwnerId, - const gp_Pnt2d& Center, - const Standard_Real Height, - const Standard_Real Width, - const Select2D_TypeOfSelection Type): -Select2D_SensitiveEntity(OwnerId), -mytype(Type) -{ - mybox.Set(Center.Translated(gp_Vec2d(Width/2.,Height/2.))); - mybox.Add(Center.Translated(gp_Vec2d(-Width/2.,-Height/2.))); -} - - -Select2D_SensitiveBox:: -Select2D_SensitiveBox (const Handle(SelectBasics_EntityOwner)& OwnerId, - const Standard_Real XMin, - const Standard_Real YMin, - const Standard_Real XMax, - const Standard_Real YMax, - const Select2D_TypeOfSelection Type): -Select2D_SensitiveEntity(OwnerId), -mytype(Type) -{ - mybox.Update(XMin,YMin,XMax,YMax); -} -//============================================================= -// Function : Areas -// Purpose : -//============================================================= - - -void Select2D_SensitiveBox::Areas (SelectBasics_ListOfBox2d& boxes) -{ - boxes.Append(mybox); -} - -//============================================================= -// Function : Matches -// Purpose : -//============================================================= - - -Standard_Boolean Select2D_SensitiveBox:: -Matches (const Standard_Real X, - const Standard_Real Y, - const Standard_Real aTol, - Standard_Real& DMin) -{ - Standard_Real TheTol = HasOwnTolerance()? myOwnTolerance : aTol; - - Bnd_Box2d TmpBox; - TmpBox.Add(mybox); - TmpBox.Enlarge(TheTol); - DMin=0.; - - gp_Pnt2d PickPoint(X,Y); - //Standard_Boolean Status = Standard_False; - - switch(mytype) { - case Select2D_TOS_INTERIOR: - { - if(!TmpBox.IsOut(PickPoint)) return Standard_True; - } - case Select2D_TOS_BOUNDARY: - { - TmpBox.Enlarge(TheTol); - if(mybox.IsOut(PickPoint)&& - !TmpBox.IsOut(PickPoint)) return Standard_True; - } - } - return Standard_False; -} - - -Standard_Boolean Select2D_SensitiveBox:: -Matches (const Standard_Real XMin, - const Standard_Real YMin, - const Standard_Real XMax, - const Standard_Real YMax, - const Standard_Real aTol) -{ - Standard_Real TheTol = HasOwnTolerance()? myOwnTolerance : aTol; - - Bnd_Box2d BoundBox; - BoundBox.Update(XMin-TheTol,YMin-TheTol,XMax+TheTol,YMax+TheTol); - if(BoundBox.IsOut(mybox)) return Standard_False; - return Standard_True; -} diff --git a/src/Select2D/Select2D_SensitiveCircle.cdl b/src/Select2D/Select2D_SensitiveCircle.cdl deleted file mode 100755 index f6ec16a21c..0000000000 --- a/src/Select2D/Select2D_SensitiveCircle.cdl +++ /dev/null @@ -1,86 +0,0 @@ --- Created on: 1995-01-30 --- Created by: Mister rmi --- Copyright (c) 1995-1999 Matra Datavision --- Copyright (c) 1999-2012 OPEN CASCADE SAS --- --- The content of this file is subject to the Open CASCADE Technology Public --- License Version 6.5 (the "License"). You may not use the content of this file --- except in compliance with the License. Please obtain a copy of the License --- at http://www.opencascade.org and read it completely before using this file. --- --- The Initial Developer of the Original Code is Open CASCADE S.A.S., having its --- main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. --- --- The Original Code and all software distributed under the License is --- distributed on an "AS IS" basis, without warranty of any kind, and the --- Initial Developer hereby disclaims all such warranties, including without --- limitation, any warranties of merchantability, fitness for a particular --- purpose or non-infringement. Please see the License for the specific terms --- and conditions governing the rights and limitations under the License. - - - - -class SensitiveCircle from Select2D -inherits SensitiveEntity from Select2D - - ---Purpose: A framework to define sensitive Areas for a Circle - -- Radius and center, or a geometric circle is given. - -uses - - Circ2d from gp, - TypeOfSelection, - EntityOwner from SelectBasics, - ListOfBox2d from SelectBasics -is - - Create (OwnerId : EntityOwner from SelectBasics; - TheCirc : Circ2d from gp; - TheType : TypeOfSelection = Select2D_TOS_BOUNDARY) - returns mutable SensitiveCircle ; - --- Purpose: Constructs a sensitive circle object defined by the - -- owner OwnerId, the circle Circle, and the selection type Type. - -- Type can be: - -- - interior - -- - boundary. - - Areas (me:mutable ; aresul : in out ListOfBox2d from SelectBasics) is static; - ---Level: Public - ---Purpose: returns the sensitive areas for a circle... - - Matches (me : mutable ; - X,Y : Real from Standard; - aTol: Real from Standard; - DMin: out Real from Standard) - returns Boolean is static; - ---Purpose: Returns true if the minimum distance DMin - -- between the postion x,y and the circle is less than aTol.. - - Matches (me :mutable; - XMin,YMin,XMax,YMax : Real from Standard; - aTol: Real from Standard) - returns Boolean - is static; - - - - Circle(me) returns Circ2d from gp; - ---Purpose: Returns the circle used at the time of construction of this object. - ---C++: inline - ---C++: return const& - - SetTypeOfSelection(me:mutable;aType : TypeOfSelection); - ---Purpose: Sets the selection type. - ---C++: inline - - Selection(me:mutable) returns TypeOfSelection from Select2D; - ---Purpose: Returns the selection type used at the time of construction of this object. - ---C++: inline - -fields - - myCirc : Circ2d from gp; - mytype : TypeOfSelection; - -end SensitiveCircle; diff --git a/src/Select2D/Select2D_SensitiveCircle.cxx b/src/Select2D/Select2D_SensitiveCircle.cxx deleted file mode 100755 index 05d74e9691..0000000000 --- a/src/Select2D/Select2D_SensitiveCircle.cxx +++ /dev/null @@ -1,105 +0,0 @@ -// Created on: 1995-01-30 -// Created by: Mister rmi -// Copyright (c) 1995-1999 Matra Datavision -// Copyright (c) 1999-2012 OPEN CASCADE SAS -// -// The content of this file is subject to the Open CASCADE Technology Public -// License Version 6.5 (the "License"). You may not use the content of this file -// except in compliance with the License. Please obtain a copy of the License -// at http://www.opencascade.org and read it completely before using this file. -// -// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its -// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. -// -// The Original Code and all software distributed under the License is -// distributed on an "AS IS" basis, without warranty of any kind, and the -// Initial Developer hereby disclaims all such warranties, including without -// limitation, any warranties of merchantability, fitness for a particular -// purpose or non-infringement. Please see the License for the specific terms -// and conditions governing the rights and limitations under the License. - - - -#include -#include -#include - -//===================================================== -// Function : Create -// Purpose :Constructor -//===================================================== - - -Select2D_SensitiveCircle:: -Select2D_SensitiveCircle(const Handle(SelectBasics_EntityOwner)& OwnerId, - const gp_Circ2d& aCirc, - const Select2D_TypeOfSelection atype): -Select2D_SensitiveEntity(OwnerId), -myCirc(aCirc), -mytype(atype){} - - -//===================================================== -// Function : Areas -// Purpose : -//===================================================== - -void Select2D_SensitiveCircle:: -Areas (SelectBasics_ListOfBox2d& boxes) -{ - Bnd_Box2d abox; - BndLib::Add(myCirc,myCirc.Radius()/100.,abox); - boxes.Append(abox); -} - - -//===================================================== -// Function : Matches -// Purpose : -//===================================================== -Standard_Boolean Select2D_SensitiveCircle:: -Matches (const Standard_Real X, - const Standard_Real Y, - const Standard_Real aTol, - Standard_Real& DMin) -{ - Standard_Real TheTol = HasOwnTolerance()? myOwnTolerance : aTol; - - switch(mytype){ - case Select2D_TOS_INTERIOR: - { - if(myCirc.Contains(gp_Pnt2d(X,Y),TheTol) ) - {DMin=0.; - return Standard_True;} - else - {DMin=myCirc.Distance(gp_Pnt2d(X,Y));} - } - case Select2D_TOS_BOUNDARY: - { - DMin = myCirc.Distance(gp_Pnt2d(X,Y)); - if(DMin<= TheTol) return Standard_True; - - } - } - return Standard_False; -} - -Standard_Boolean Select2D_SensitiveCircle:: -Matches (const Standard_Real XMin, - const Standard_Real YMin, - const Standard_Real XMax, - const Standard_Real YMax, - const Standard_Real aTol) -{ - Standard_Real TheTol = HasOwnTolerance()? myOwnTolerance : aTol; - - Bnd_Box2d abox, BoundBox; - BoundBox.Update(XMin-TheTol,YMin-TheTol,XMax+TheTol,YMax+TheTol); - BndLib::Add(myCirc,myCirc.Radius()/100.,abox); - - if(BoundBox.IsOut(abox)) return Standard_False; - return Standard_True; -} - - - diff --git a/src/Select2D/Select2D_SensitiveCircle.lxx b/src/Select2D/Select2D_SensitiveCircle.lxx deleted file mode 100755 index 56072c1dab..0000000000 --- a/src/Select2D/Select2D_SensitiveCircle.lxx +++ /dev/null @@ -1,34 +0,0 @@ -// Created on: 1995-01-31 -// Created by: Mister rmi -// Copyright (c) 1995-1999 Matra Datavision -// Copyright (c) 1999-2012 OPEN CASCADE SAS -// -// The content of this file is subject to the Open CASCADE Technology Public -// License Version 6.5 (the "License"). You may not use the content of this file -// except in compliance with the License. Please obtain a copy of the License -// at http://www.opencascade.org and read it completely before using this file. -// -// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its -// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. -// -// The Original Code and all software distributed under the License is -// distributed on an "AS IS" basis, without warranty of any kind, and the -// Initial Developer hereby disclaims all such warranties, including without -// limitation, any warranties of merchantability, fitness for a particular -// purpose or non-infringement. Please see the License for the specific terms -// and conditions governing the rights and limitations under the License. - - - - -inline const gp_Circ2d& -Select2D_SensitiveCircle::Circle() -const {return myCirc;} - -inline void Select2D_SensitiveCircle:: -SetTypeOfSelection(const Select2D_TypeOfSelection theType) -{mytype = theType;} - -inline Select2D_TypeOfSelection -Select2D_SensitiveCircle::Selection() -{return mytype;} diff --git a/src/Select2D/Select2D_SensitiveEntity.cdl b/src/Select2D/Select2D_SensitiveEntity.cdl deleted file mode 100755 index 6e28d0ae0c..0000000000 --- a/src/Select2D/Select2D_SensitiveEntity.cdl +++ /dev/null @@ -1,90 +0,0 @@ --- Created on: 1995-03-10 --- Created by: Mister rmi --- Copyright (c) 1995-1999 Matra Datavision --- Copyright (c) 1999-2012 OPEN CASCADE SAS --- --- The content of this file is subject to the Open CASCADE Technology Public --- License Version 6.5 (the "License"). You may not use the content of this file --- except in compliance with the License. Please obtain a copy of the License --- at http://www.opencascade.org and read it completely before using this file. --- --- The Initial Developer of the Original Code is Open CASCADE S.A.S., having its --- main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. --- --- The Original Code and all software distributed under the License is --- distributed on an "AS IS" basis, without warranty of any kind, and the --- Initial Developer hereby disclaims all such warranties, including without --- limitation, any warranties of merchantability, fitness for a particular --- purpose or non-infringement. Please see the License for the specific terms --- and conditions governing the rights and limitations under the License. - --- Modified by rob (18/10/96) : add methods to store a constant sensitivity - - - -deferred class SensitiveEntity from Select2D inherits SensitiveEntity from SelectBasics - - ---Purpose: A framework to define what all sensitive 2D entities have in common. - -- This framework can be used to create new 2D sensitive entities. - -uses - EntityOwner from SelectBasics, - Array1OfPnt2d from TColgp, - Box2d from Bnd, - Projector from Select2D - -raises - NotImplemented from Standard - -is - - Initialize(anOwnerId: EntityOwner from SelectBasics); - - NeedsConversion (me) returns Boolean is virtual; - ---Purpose: returns Standard_False unless if redefined... - ---Level: Public - ---C++: inline - - Convert(me:mutable;aProjector: Projector from Select2D) is virtual; - ---Purpose: Processes the projection of the sensitive primitives in - -- the active view. This must be performed before the selection action. - -- This function must be implemented in daughter classes. - - MaxBoxes(me) returns Integer is virtual; - ---Purpose: Returns the maximum number of boxes. - - - SetOwnTolerance(me:mutable; aValue : Real from Standard) ; - ---Purpose: Sets and stores a tolerance value in the argument - -- aTol of the function Matches inherited from SelectBasics_SensitiveEntity. - - UnsetOwnTolerance(me:mutable); - ---Purpose: Removes the in the argument aTol of the function - -- Matches inherited from SelectBasics_SensitiveEntity. - - HasOwnTolerance(me) returns Boolean from Standard; - ---Purpose: Returns true if the entity has a setting for the - -- argument aTol of the function Matches inherited - -- from SelectBasics_SensitiveEntity. - - - OwnTolerance(me) returns Real from Standard; - ---Purpose: Returns the tolerance value in the argument aTol of - -- the function Matches inherited from SelectBasics_SensitiveEntity. - - Is3D(me) returns Boolean from Standard is redefined static; - --- Purpose: Returns true if this object can provide 3D information. - - Matches (me :mutable; - Polyline:Array1OfPnt2d from TColgp; - aBox:Box2d from Bnd; - aTol: Real from Standard) - returns Boolean from Standard is redefined virtual; - ---Purpose: Free contur selection for 2d is not defined - - -fields - - myOwnTolerance : Real from Standard is protected; - -end SensitiveEntity; diff --git a/src/Select2D/Select2D_SensitiveEntity.cxx b/src/Select2D/Select2D_SensitiveEntity.cxx deleted file mode 100755 index a6b2cfc15a..0000000000 --- a/src/Select2D/Select2D_SensitiveEntity.cxx +++ /dev/null @@ -1,46 +0,0 @@ -// Created on: 1995-03-10 -// Created by: Mister rmi -// Copyright (c) 1995-1999 Matra Datavision -// Copyright (c) 1999-2012 OPEN CASCADE SAS -// -// The content of this file is subject to the Open CASCADE Technology Public -// License Version 6.5 (the "License"). You may not use the content of this file -// except in compliance with the License. Please obtain a copy of the License -// at http://www.opencascade.org and read it completely before using this file. -// -// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its -// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. -// -// The Original Code and all software distributed under the License is -// distributed on an "AS IS" basis, without warranty of any kind, and the -// Initial Developer hereby disclaims all such warranties, including without -// limitation, any warranties of merchantability, fitness for a particular -// purpose or non-infringement. Please see the License for the specific terms -// and conditions governing the rights and limitations under the License. - - - - -#include - -Select2D_SensitiveEntity:: -Select2D_SensitiveEntity(const Handle(SelectBasics_EntityOwner)& anOwner): -SelectBasics_SensitiveEntity(anOwner),myOwnTolerance(-1.) -{} - - -void Select2D_SensitiveEntity::Convert(const Handle(Select2D_Projector)& aProj) -{ - Standard_NotImplemented::Raise("cannot convert the 2D sensitiveEntity"); -} - -Standard_Boolean Select2D_SensitiveEntity::Is3D() const -{return Standard_False;} - - -Standard_Boolean Select2D_SensitiveEntity::Matches(const TColgp_Array1OfPnt2d& aPoly, - const Bnd_Box2d& aBox, - const Standard_Real aTol) -{ - return Standard_False; -} diff --git a/src/Select2D/Select2D_SensitiveEntity.lxx b/src/Select2D/Select2D_SensitiveEntity.lxx deleted file mode 100755 index 0395e0e1d1..0000000000 --- a/src/Select2D/Select2D_SensitiveEntity.lxx +++ /dev/null @@ -1,38 +0,0 @@ -// Created on: 1995-03-10 -// Created by: Mister rmi -// Copyright (c) 1995-1999 Matra Datavision -// Copyright (c) 1999-2012 OPEN CASCADE SAS -// -// The content of this file is subject to the Open CASCADE Technology Public -// License Version 6.5 (the "License"). You may not use the content of this file -// except in compliance with the License. Please obtain a copy of the License -// at http://www.opencascade.org and read it completely before using this file. -// -// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its -// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. -// -// The Original Code and all software distributed under the License is -// distributed on an "AS IS" basis, without warranty of any kind, and the -// Initial Developer hereby disclaims all such warranties, including without -// limitation, any warranties of merchantability, fitness for a particular -// purpose or non-infringement. Please see the License for the specific terms -// and conditions governing the rights and limitations under the License. - - -inline Standard_Boolean Select2D_SensitiveEntity::NeedsConversion () -const {return Standard_False;} - -inline Standard_Integer Select2D_SensitiveEntity::MaxBoxes () -const {return 1;} - -inline void Select2D_SensitiveEntity::SetOwnTolerance(const Standard_Real aVal) -{myOwnTolerance = aVal;} - -inline void Select2D_SensitiveEntity::UnsetOwnTolerance() -{myOwnTolerance = -1.;} - -inline Standard_Boolean Select2D_SensitiveEntity::HasOwnTolerance()const -{return (myOwnTolerance>0.) ;} - -inline Standard_Real Select2D_SensitiveEntity::OwnTolerance() const -{return myOwnTolerance;} diff --git a/src/Select2D/Select2D_SensitivePoint.cdl b/src/Select2D/Select2D_SensitivePoint.cdl deleted file mode 100755 index 4fe4969c67..0000000000 --- a/src/Select2D/Select2D_SensitivePoint.cdl +++ /dev/null @@ -1,86 +0,0 @@ --- Created on: 1995-01-26 --- Created by: Mister rmi --- Copyright (c) 1995-1999 Matra Datavision --- Copyright (c) 1999-2012 OPEN CASCADE SAS --- --- The content of this file is subject to the Open CASCADE Technology Public --- License Version 6.5 (the "License"). You may not use the content of this file --- except in compliance with the License. Please obtain a copy of the License --- at http://www.opencascade.org and read it completely before using this file. --- --- The Initial Developer of the Original Code is Open CASCADE S.A.S., having its --- main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. --- --- The Original Code and all software distributed under the License is --- distributed on an "AS IS" basis, without warranty of any kind, and the --- Initial Developer hereby disclaims all such warranties, including without --- limitation, any warranties of merchantability, fitness for a particular --- purpose or non-infringement. Please see the License for the specific terms --- and conditions governing the rights and limitations under the License. - - - - -class SensitivePoint from Select2D inherits SensitiveEntity from Select2D - - ---Purpose: A framework to define sensitive 2D points. - -uses - Integer from Standard, - Pnt2d from gp, - EntityOwner from SelectBasics, - ListOfBox2d from SelectBasics - -is - - - Create (OwnerId : EntityOwner from SelectBasics; - Location : Pnt2d from gp; - InitSensitivity : Real = 0) - returns mutable SensitivePoint from Select2D; - ---Purpose: Constructs the sensitive point object defined by the - -- owner OwnerId, the point Location and the sensitivity InitSensitivity. - -- InitSensitivity allows choice of dimensions in the - -- selectable box around the sensitive point. It is - -- initialized with a null value, and is given a working one by Set. - - - Set(me:mutable; aSensitivity:Real) is static; - ---Purpose: Sets the sensitivity aSensitivity for sensitive - -- primitives to find owners of points. - - Areas (me:mutable ; aresul : in out ListOfBox2d from SelectBasics) is static; - ---Level: Public - ---Purpose: Returns the 2Dbox around the point (this box) has to be enlarged (sensitivity = 0) - - - Location(me) returns Pnt2d from gp; - ---Level: Public - ---C++: inline - ---C++: return const& - ---Purpose: returns the original point. - - - - Matches (me : mutable ; - X,Y : Real from Standard; - aTol : Real from Standard; - DMin : out Real from Standard) - returns Boolean - is static; - ---Purpose: if distance between P - - Matches (me :mutable; - XMin,YMin,XMax,YMax : Real from Standard; - aTol: Real from Standard) - returns Boolean - is static; - - -fields - - mylocation : Pnt2d from gp; - mysensitivity : Real; - -end SensitivePoint; - diff --git a/src/Select2D/Select2D_SensitivePoint.cxx b/src/Select2D/Select2D_SensitivePoint.cxx deleted file mode 100755 index a864952cc8..0000000000 --- a/src/Select2D/Select2D_SensitivePoint.cxx +++ /dev/null @@ -1,90 +0,0 @@ -// Created on: 1995-01-26 -// Created by: Mister rmi -// Copyright (c) 1995-1999 Matra Datavision -// Copyright (c) 1999-2012 OPEN CASCADE SAS -// -// The content of this file is subject to the Open CASCADE Technology Public -// License Version 6.5 (the "License"). You may not use the content of this file -// except in compliance with the License. Please obtain a copy of the License -// at http://www.opencascade.org and read it completely before using this file. -// -// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its -// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. -// -// The Original Code and all software distributed under the License is -// distributed on an "AS IS" basis, without warranty of any kind, and the -// Initial Developer hereby disclaims all such warranties, including without -// limitation, any warranties of merchantability, fitness for a particular -// purpose or non-infringement. Please see the License for the specific terms -// and conditions governing the rights and limitations under the License. - - -#include -#include -#include -#include - -//================================== -//function : Constructor -//purpose : -//================================== - -Select2D_SensitivePoint:: -Select2D_SensitivePoint(const Handle(SelectBasics_EntityOwner)& OwnerId, - const gp_Pnt2d& Location, - const Standard_Real InitSensitivity): -Select2D_SensitiveEntity(OwnerId), -mylocation(Location), -mysensitivity(InitSensitivity) -{} - - -//================================== -//function : Areas -//purpose : -//================================== - -void Select2D_SensitivePoint:: -Areas (SelectBasics_ListOfBox2d& boxes) -{ Bnd_Box2d abox; - abox.Set(mylocation); - abox.Enlarge(mysensitivity); - boxes.Append(abox); -} - -//================================== -//function : Matches -//purpose : -//================================== - - -Standard_Boolean Select2D_SensitivePoint:: -Matches (const Standard_Real X, - const Standard_Real Y, - const Standard_Real aTol, - Standard_Real& MinDist) -{ - Standard_Real TheTol = HasOwnTolerance()? myOwnTolerance : aTol; - MinDist = mylocation.Distance(gp_Pnt2d(X,Y)); - if(MinDist<=TheTol+mysensitivity) return Standard_True; - return Standard_False; -} - -Standard_Boolean Select2D_SensitivePoint:: -Matches (const Standard_Real XMin, - const Standard_Real YMin, - const Standard_Real XMax, - const Standard_Real YMax, - const Standard_Real aTol) -{//distance point-Line.... - Standard_Real MinDist = gp_Lin2d(gp_Pnt2d(XMin,YMin), - gp_Vec2d(gp_Pnt2d(XMin,YMin), - gp_Pnt2d(XMax,YMax)) - ).Distance(mylocation); - - return (MinDist<=aTol+mysensitivity); -} - - - - diff --git a/src/Select2D/Select2D_SensitivePoint.lxx b/src/Select2D/Select2D_SensitivePoint.lxx deleted file mode 100755 index 5a1cff21c6..0000000000 --- a/src/Select2D/Select2D_SensitivePoint.lxx +++ /dev/null @@ -1,31 +0,0 @@ -// Created on: 1995-01-26 -// Created by: Mister rmi -// Copyright (c) 1995-1999 Matra Datavision -// Copyright (c) 1999-2012 OPEN CASCADE SAS -// -// The content of this file is subject to the Open CASCADE Technology Public -// License Version 6.5 (the "License"). You may not use the content of this file -// except in compliance with the License. Please obtain a copy of the License -// at http://www.opencascade.org and read it completely before using this file. -// -// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its -// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. -// -// The Original Code and all software distributed under the License is -// distributed on an "AS IS" basis, without warranty of any kind, and the -// Initial Developer hereby disclaims all such warranties, including without -// limitation, any warranties of merchantability, fitness for a particular -// purpose or non-infringement. Please see the License for the specific terms -// and conditions governing the rights and limitations under the License. - - - -inline const gp_Pnt2d& Select2D_SensitivePoint:: -Location() const {return mylocation;} - - -inline void Select2D_SensitivePoint:: -Set(const Standard_Real aSensitivity) -{mysensitivity = aSensitivity;} - - diff --git a/src/Select2D/Select2D_SensitiveSegment.cdl b/src/Select2D/Select2D_SensitiveSegment.cdl deleted file mode 100755 index f86604e9f4..0000000000 --- a/src/Select2D/Select2D_SensitiveSegment.cdl +++ /dev/null @@ -1,106 +0,0 @@ --- Created on: 1995-01-26 --- Created by: Mister rmi --- Copyright (c) 1995-1999 Matra Datavision --- Copyright (c) 1999-2012 OPEN CASCADE SAS --- --- The content of this file is subject to the Open CASCADE Technology Public --- License Version 6.5 (the "License"). You may not use the content of this file --- except in compliance with the License. Please obtain a copy of the License --- at http://www.opencascade.org and read it completely before using this file. --- --- The Initial Developer of the Original Code is Open CASCADE S.A.S., having its --- main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. --- --- The Original Code and all software distributed under the License is --- distributed on an "AS IS" basis, without warranty of any kind, and the --- Initial Developer hereby disclaims all such warranties, including without --- limitation, any warranties of merchantability, fitness for a particular --- purpose or non-infringement. Please see the License for the specific terms --- and conditions governing the rights and limitations under the License. - - - -class SensitiveSegment from Select2D -inherits SensitiveEntity from Select2D - - - ---Purpose: A framework to define sensitive areas along a line segment. - -uses - Pnt2d from gp, - EntityOwner from SelectBasics, - ListOfBox2d from SelectBasics - -is - - - Create (OwnerId : EntityOwner from SelectBasics; - FirstP,LastP : Pnt2d from gp; - MaxRect : Integer = 3) - returns mutable SensitiveSegment; - ---Purpose: Constructs the sensitive line segment object defined - -- by the owner OwnerId, the 2D starting and ending - -- points FirstPoint and LastPoint and the maximum - -- number of sensitive bounding boxes MaxRect. - -- The parameters can be modified using the functions provided. - - Set (me:mutable; MaxRect : Integer) is static; - ---Purpose: Sets the maximum number of 2D sensitive bounding boxes - MaxRect. - - - - StartPoint (me : mutable ; aPt : Pnt2d from gp) is static; - ---Level: Public - ---C++: inline - ---Purpose: changes the start Point of the Segment; - - - - EndPoint (me : mutable ; aPt : Pnt2d from gp) is static; - ---Level: Public - ---C++: inline - ---Purpose: changes the end point of the segment - - - StartPoint (me) returns Pnt2d from gp; - ---Level: Public - ---Purpose: gives the 3D start Point of the Segment - ---C++: return const& - ---C++: inline - - - EndPoint(me) returns Pnt2d from gp; - ---Level: Public - ---Purpose: Returnes the 3D start Point of the Segment - ---C++: return const& - ---C++: inline - - - Areas (me:mutable;aSeq : in out ListOfBox2d from SelectBasics) is static; - - - Matches (me : mutable; - X,Y : Real from Standard; - aTol : Real from Standard; - DMin : out Real from Standard) - returns Boolean is static; - - Matches (me :mutable; - XMin,YMin,XMax,YMax : Real from Standard; - aTol: Real from Standard) - returns Boolean - is static; - - - MaxBoxes(me) returns Integer is redefined static; - ---Level: Public - ---Purpose: Returns the max number of sensitive aeas describing the sensitive segment - ---C++: inline - -fields - - mymaxrect : Integer; - mystart : Pnt2d from gp; - myend : Pnt2d from gp; - -end SensitiveSegment; diff --git a/src/Select2D/Select2D_SensitiveSegment.cxx b/src/Select2D/Select2D_SensitiveSegment.cxx deleted file mode 100755 index 004a87b488..0000000000 --- a/src/Select2D/Select2D_SensitiveSegment.cxx +++ /dev/null @@ -1,133 +0,0 @@ -// Created on: 1995-01-26 -// Created by: Mister rmi -// Copyright (c) 1995-1999 Matra Datavision -// Copyright (c) 1999-2012 OPEN CASCADE SAS -// -// The content of this file is subject to the Open CASCADE Technology Public -// License Version 6.5 (the "License"). You may not use the content of this file -// except in compliance with the License. Please obtain a copy of the License -// at http://www.opencascade.org and read it completely before using this file. -// -// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its -// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. -// -// The Original Code and all software distributed under the License is -// distributed on an "AS IS" basis, without warranty of any kind, and the -// Initial Developer hereby disclaims all such warranties, including without -// limitation, any warranties of merchantability, fitness for a particular -// purpose or non-infringement. Please see the License for the specific terms -// and conditions governing the rights and limitations under the License. - - -#include -#include -#include -#include -#include -#include -#include - -//===================================================== -// Function : Create -// Purpose :Constructor -//===================================================== - - -Select2D_SensitiveSegment:: -Select2D_SensitiveSegment(const Handle(SelectBasics_EntityOwner)& OwnerId, - const gp_Pnt2d& FirstP, - const gp_Pnt2d& LastP, - const Standard_Integer MaxRect): -Select2D_SensitiveEntity(OwnerId), -mymaxrect(MaxRect), -mystart(FirstP), -myend(LastP) -{} - - -//===================================================== -// Function : Areas -// Purpose : -//===================================================== -void Select2D_SensitiveSegment:: -Areas(SelectBasics_ListOfBox2d& boxes) -{ - // look for the angle with X axis if x % pi/4 one box - //gp_Dir2d dy (0.,1.); - - gp_Vec2d MyVec(mystart,myend),VAxx(gp_Dir2d(0.,1.)); - - - Standard_Real theangle = (VAxx.Angle(MyVec)); - theangle = Abs(theangle); - if(theangle>=M_PI/2.) theangle-=M_PI/2; - - - if(theangle>=M_PI/12. && theangle <=5*M_PI/12.) - { - TColgp_Array1OfPnt2d BoxPoint (1,mymaxrect+1); - BoxPoint (1) = mystart;BoxPoint(mymaxrect+1)=myend; - gp_Vec2d Vtr = MyVec/mymaxrect; -// for (Standard_Integer i=2;i<=mymaxrect;i++) - Standard_Integer i; - for ( i=2;i<=mymaxrect;i++) - {BoxPoint (i) = BoxPoint (i-1).Translated(Vtr);} - for (i=2;i<=mymaxrect+1;i++) - { Bnd_Box2d curbox; - curbox.Set(BoxPoint(i-1)); - curbox.Add(BoxPoint(i)); - boxes.Append(curbox); - } - } - else - { - Bnd_Box2d curbox; - curbox.Set(mystart); - curbox.Add(myend); - boxes.Append(curbox); - } -} - - -//===================================================== -// Function :Matches -// Purpose : -//===================================================== - Standard_Boolean Select2D_SensitiveSegment:: -Matches(const Standard_Real X, - const Standard_Real Y, - const Standard_Real aTol, - Standard_Real& DMin) -{ -// gp_Pnt2d pickpoint(X,Y); -// gp_Vec2d V(mystart,myend); -// gp_Lin2d Lin(mystart,V); - Standard_Real TheTol = HasOwnTolerance()? myOwnTolerance : aTol; - DMin=0.0; - if(mystart.Distance(myend)<=TheTol) DMin = Min(mystart.Distance(gp_Pnt2d(X,Y)), - myend.Distance(gp_Pnt2d(X,Y))); - else - DMin =Abs (gp_Lin2d(mystart,gp_Vec2d(mystart,myend)).Distance(gp_Pnt2d(X,Y))); - - if(DMin<=TheTol) return Standard_True; - - return Standard_False; - -} - -Standard_Boolean Select2D_SensitiveSegment:: -Matches (const Standard_Real XMin, - const Standard_Real YMin, - const Standard_Real XMax, - const Standard_Real YMax, - const Standard_Real aTol) -{ - Standard_Real TheTol = HasOwnTolerance()? myOwnTolerance : aTol; - - Bnd_Box2d BoundBox; - BoundBox.Update(XMin-TheTol,YMin-TheTol,XMax+TheTol,YMax+TheTol); - - if (BoundBox.IsOut(mystart)||BoundBox.IsOut(myend)) return Standard_False; - return Standard_True; -} - diff --git a/src/Select2D/Select2D_SensitiveSegment.lxx b/src/Select2D/Select2D_SensitiveSegment.lxx deleted file mode 100755 index b3b15ff3d6..0000000000 --- a/src/Select2D/Select2D_SensitiveSegment.lxx +++ /dev/null @@ -1,44 +0,0 @@ -// Created on: 1995-01-30 -// Created by: Mister rmi -// Copyright (c) 1995-1999 Matra Datavision -// Copyright (c) 1999-2012 OPEN CASCADE SAS -// -// The content of this file is subject to the Open CASCADE Technology Public -// License Version 6.5 (the "License"). You may not use the content of this file -// except in compliance with the License. Please obtain a copy of the License -// at http://www.opencascade.org and read it completely before using this file. -// -// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its -// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. -// -// The Original Code and all software distributed under the License is -// distributed on an "AS IS" basis, without warranty of any kind, and the -// Initial Developer hereby disclaims all such warranties, including without -// limitation, any warranties of merchantability, fitness for a particular -// purpose or non-infringement. Please see the License for the specific terms -// and conditions governing the rights and limitations under the License. - - - - -inline void Select2D_SensitiveSegment::Set( const Standard_Integer nbrect) -{mymaxrect =nbrect;} - -inline void Select2D_SensitiveSegment:: -StartPoint (const gp_Pnt2d& aPt) {mystart = aPt;} - - -inline const gp_Pnt2d& Select2D_SensitiveSegment:: -StartPoint() const {return mystart;} - -inline void Select2D_SensitiveSegment:: -EndPoint(const gp_Pnt2d& aPt) {myend = aPt;} - - -inline const gp_Pnt2d& Select2D_SensitiveSegment:: -EndPoint() const {return myend;} - -inline Standard_Integer Select2D_SensitiveSegment:: -MaxBoxes() const {return mymaxrect;} - - diff --git a/src/StdSelect/StdSelect.cdl b/src/StdSelect/StdSelect.cdl index fcbf263c2b..d73b7a32cc 100755 --- a/src/StdSelect/StdSelect.cdl +++ b/src/StdSelect/StdSelect.cdl @@ -55,12 +55,9 @@ uses TColStd, gp, Select3D, - Select2D, - Graphic2d, Graphic3d,Visual3d, Quantity, Prs3d, - V2d, V3d, PrsMgr, SelectBasics, @@ -101,12 +98,6 @@ is ---Purpose: Viewer Selector for a view from V3d -- Accepts Only Sensitive Entities inheriting Select3D entities... - class ViewerSelector2d; - ---Purpose: Viewer Selector for a view from V2d - -- Accepts Only Sensitive Entities inheriting Select2D entities... - - - class BRepSelectionTool; @@ -132,9 +123,6 @@ is - class SensitiveText2d; - class TextProjector2d; - ---Category: Shape Filters diff --git a/src/StdSelect/StdSelect_SensitiveText2d.cdl b/src/StdSelect/StdSelect_SensitiveText2d.cdl deleted file mode 100755 index c070ee417f..0000000000 --- a/src/StdSelect/StdSelect_SensitiveText2d.cdl +++ /dev/null @@ -1,95 +0,0 @@ --- Created by: Robert COUBLANC --- Copyright (c) 1995-1999 Matra Datavision --- Copyright (c) 1999-2012 OPEN CASCADE SAS --- --- The content of this file is subject to the Open CASCADE Technology Public --- License Version 6.5 (the "License"). You may not use the content of this file --- except in compliance with the License. Please obtain a copy of the License --- at http://www.opencascade.org and read it completely before using this file. --- --- The Initial Developer of the Original Code is Open CASCADE S.A.S., having its --- main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. --- --- The Original Code and all software distributed under the License is --- distributed on an "AS IS" basis, without warranty of any kind, and the --- Initial Developer hereby disclaims all such warranties, including without --- limitation, any warranties of merchantability, fitness for a particular --- purpose or non-infringement. Please see the License for the specific terms --- and conditions governing the rights and limitations under the License. - - - - -class SensitiveText2d from StdSelect inherits SensitiveEntity from -Select2D - - ---Purpose: A framework to define a sensitive text entity for 2D views. - -uses - ExtendedString from TCollection, - EntityOwner from SelectBasics, - ListOfBox2d from SelectBasics, - Projector from Select2D, - Array1OfPnt2d from TColgp, - Box2d from Bnd - -is - - Create(anOwnerId : EntityOwner from SelectBasics; - aString : ExtendedString from TCollection; - XPox,YPos : Real from Standard; - Angle : Real = 0; - aFontIndex: Integer = -1) - returns mutable SensitiveText2d from StdSelect; - ---Purpose: Constructs a sensitive 2D text object defined by the - -- owner anOwnerId, the string aString, the point - -- defined by the parameters XPos and YPos, the angle - -- Angle and the font index aFontIndex. - - NeedsConversion (me) returns Boolean is redefined static; - ---Purpose: returns Standard_True - ---Level: Public - ---C++: inline - - Convert(me:mutable; aTextProj : Projector from Select2D) is redefined virtual; - ---Purpose: gets the size of the text in the 2d view - ---Level: Public - - - Areas(me:mutable; aresult : in out ListOfBox2d from SelectBasics) is redefined static; - ---Level: Public - ---Purpose: to be implemented specifically by each type of - -- sensitive primitive . - -- - - Matches (me :mutable; - X,Y : Real from Standard; - aTol: Real from Standard; - DMin: out Real from Standard) - returns Boolean - is redefined static; - - Matches (me :mutable; - XMin,YMin,XMax,YMax : Real from Standard; - aTol: Real from Standard) - returns Boolean - is redefined static; - - Matches (me :mutable; - Polyline:Array1OfPnt2d from TColgp; - aBox:Box2d from Bnd; - aTol: Real from Standard) - returns Boolean - is redefined static; - -fields - - mytext : ExtendedString from TCollection; - myxpos : Real; - myypos : Real; - myangle: Real; - myfont : Integer; - - myinitbox: Box2d from Bnd; --box before rotation... - -end SensitiveText2d; diff --git a/src/StdSelect/StdSelect_SensitiveText2d.cxx b/src/StdSelect/StdSelect_SensitiveText2d.cxx deleted file mode 100755 index 086744940e..0000000000 --- a/src/StdSelect/StdSelect_SensitiveText2d.cxx +++ /dev/null @@ -1,91 +0,0 @@ -// Created on: 1995-04-21 -// Created by: Robert COUBLANC -// Copyright (c) 1995-1999 Matra Datavision -// Copyright (c) 1999-2012 OPEN CASCADE SAS -// -// The content of this file is subject to the Open CASCADE Technology Public -// License Version 6.5 (the "License"). You may not use the content of this file -// except in compliance with the License. Please obtain a copy of the License -// at http://www.opencascade.org and read it completely before using this file. -// -// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its -// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. -// -// The Original Code and all software distributed under the License is -// distributed on an "AS IS" basis, without warranty of any kind, and the -// Initial Developer hereby disclaims all such warranties, including without -// limitation, any warranties of merchantability, fitness for a particular -// purpose or non-infringement. Please see the License for the specific terms -// and conditions governing the rights and limitations under the License. - - - -#include -#include -#include - - -StdSelect_SensitiveText2d:: -StdSelect_SensitiveText2d (const Handle(SelectBasics_EntityOwner)& anOwnerId, - const TCollection_ExtendedString& aString, - const Standard_Real XPos, - const Standard_Real YPos, - const Standard_Real Angle, - const Standard_Integer aFontIndex): -Select2D_SensitiveEntity(anOwnerId), -mytext(aString), -myxpos(XPos), -myypos(YPos), -myangle(Angle), -myfont(aFontIndex) {} - - - -void StdSelect_SensitiveText2d::Convert(const Handle(Select2D_Projector)& aPrj) -{ - if(!(Handle(StdSelect_TextProjector2d)::DownCast(aPrj)).IsNull()) - { - gp_Pnt2d FirstP,LastP; - Handle(StdSelect_TextProjector2d)::DownCast(aPrj) - ->Convert(mytext,myxpos,myypos,FirstP,LastP,myfont); - myinitbox.Set(FirstP); - myinitbox.Add(LastP); - } -} - -void StdSelect_SensitiveText2d::Areas(SelectBasics_ListOfBox2d& aresult) -{ - if(myangle==0.) aresult.Append(myinitbox); - else { - gp_Trsf2d T; T.SetRotation(gp_Pnt2d(myxpos,myypos),myangle); - aresult.Append(myinitbox.Transformed(T)); - } -} - -Standard_Boolean StdSelect_SensitiveText2d::Matches(const Standard_Real X, - const Standard_Real Y, - const Standard_Real aTol, - Standard_Real& DMin) -{ - return Standard_True; -} - -Standard_Boolean StdSelect_SensitiveText2d::Matches - (const Standard_Real XMin, - const Standard_Real YMin, - const Standard_Real XMax, - const Standard_Real YMax, - const Standard_Real aTol) { - - return Standard_True; - - } - -Standard_Boolean StdSelect_SensitiveText2d::Matches - (const TColgp_Array1OfPnt2d& aPoly, - const Bnd_Box2d& aBox, - const Standard_Real aTol) { - - return Standard_True; - - } diff --git a/src/StdSelect/StdSelect_SensitiveText2d.lxx b/src/StdSelect/StdSelect_SensitiveText2d.lxx deleted file mode 100755 index 54dda55956..0000000000 --- a/src/StdSelect/StdSelect_SensitiveText2d.lxx +++ /dev/null @@ -1,28 +0,0 @@ -// Created on: 1995-04-21 -// Created by: Robert COUBLANC -// Copyright (c) 1995-1999 Matra Datavision -// Copyright (c) 1999-2012 OPEN CASCADE SAS -// -// The content of this file is subject to the Open CASCADE Technology Public -// License Version 6.5 (the "License"). You may not use the content of this file -// except in compliance with the License. Please obtain a copy of the License -// at http://www.opencascade.org and read it completely before using this file. -// -// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its -// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. -// -// The Original Code and all software distributed under the License is -// distributed on an "AS IS" basis, without warranty of any kind, and the -// Initial Developer hereby disclaims all such warranties, including without -// limitation, any warranties of merchantability, fitness for a particular -// purpose or non-infringement. Please see the License for the specific terms -// and conditions governing the rights and limitations under the License. - - - -inline Standard_Boolean StdSelect_SensitiveText2d::NeedsConversion() const -{ - return Standard_True; -} - - diff --git a/src/StdSelect/StdSelect_Shape.cdl b/src/StdSelect/StdSelect_Shape.cdl index 59ef9fd5dd..379b93f7aa 100755 --- a/src/StdSelect/StdSelect_Shape.cdl +++ b/src/StdSelect/StdSelect_Shape.cdl @@ -27,8 +27,6 @@ private class Shape from StdSelect inherits PresentableObject from PrsMgr uses Projector from Prs3d, Transformation from Geom, - PresentationManager2d from PrsMgr, - GraphicObject from Graphic2d, Shape from TopoDS, PresentationManager3d from PrsMgr, Presentation from Prs3d @@ -47,11 +45,6 @@ is aPresentation: mutable Presentation from Prs3d) is redefined static private; - Compute(me:mutable; - aPresentationManager: PresentationManager2d from PrsMgr; - aPresentation: mutable GraphicObject from Graphic2d; - aMode: Integer from Standard = 0) - is redefined static private; Compute(me : mutable; aProjector : Projector from Prs3d; diff --git a/src/StdSelect/StdSelect_Shape.cxx b/src/StdSelect/StdSelect_Shape.cxx index 7f41178a70..044cf2db8d 100755 --- a/src/StdSelect/StdSelect_Shape.cxx +++ b/src/StdSelect/StdSelect_Shape.cxx @@ -72,12 +72,6 @@ void StdSelect_Shape::Compute(const Handle_Prs3d_Projector& aProjector , PrsMgr_PresentableObject::Compute(aProjector,aGeomTrans,aPresentation); } -void StdSelect_Shape::Compute(const Handle_PrsMgr_PresentationManager2d& aPrsMgr, - const Handle_Graphic2d_GraphicObject& aGO, - const int anInt) -{ - PrsMgr_PresentableObject::Compute(aPrsMgr,aGO,anInt); -} void StdSelect_Shape::Compute(const Handle_Prs3d_Projector& aProjector, const Handle_Prs3d_Presentation& aPresentation) diff --git a/src/StdSelect/StdSelect_TextProjector2d.cdl b/src/StdSelect/StdSelect_TextProjector2d.cdl deleted file mode 100755 index 4b3fd2d226..0000000000 --- a/src/StdSelect/StdSelect_TextProjector2d.cdl +++ /dev/null @@ -1,73 +0,0 @@ --- Created on: 1995-04-21 --- Created by: Robert COUBLANC --- Copyright (c) 1995-1999 Matra Datavision --- Copyright (c) 1999-2012 OPEN CASCADE SAS --- --- The content of this file is subject to the Open CASCADE Technology Public --- License Version 6.5 (the "License"). You may not use the content of this file --- except in compliance with the License. Please obtain a copy of the License --- at http://www.opencascade.org and read it completely before using this file. --- --- The Initial Developer of the Original Code is Open CASCADE S.A.S., having its --- main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. --- --- The Original Code and all software distributed under the License is --- distributed on an "AS IS" basis, without warranty of any kind, and the --- Initial Developer hereby disclaims all such warranties, including without --- limitation, any warranties of merchantability, fitness for a particular --- purpose or non-infringement. Please see the License for the specific terms --- and conditions governing the rights and limitations under the License. - - - - -class TextProjector2d from StdSelect inherits Projector from Select2D - - ---Purpose: A projector framework specific to texts in 2D views. - -- For a string of text, an insertion point and a font, it - -- calculates the minimum and maximum points of the text box in the view. - -uses - View from V2d, - Trsf2d from gp, - Pnt2d from gp, - ExtendedString from TCollection - -is - - Create(aView: View from V2d) returns mutable TextProjector2d; - ---Purpose: Constructs a 2D text projector framework defined by the 2D view aView. - - Set(me:mutable; aView:View from V2d) is static; - ---Purpose: Sets the view aView. - ---C++: inline - - - Set(me:mutable;atrsf:Trsf2d from gp)is static; - ---Purpose: Sets the transformation atrsf. - -- This transformation is applied to the attachment point - -- of the text, and takes the size and length of the text - -- into account to give the upper right hand point of the text box. - ---C++: inline - - - Convert(me;aPointIn : Pnt2d from gp; - aPointOut : out Pnt2d from gp) is redefined virtual; - ---Level: Public - ---Purpose: applies the stored trsf to aPointIn to get aPointOut - - - Convert(me;aText: ExtendedString from TCollection; - XPos,YPos: Real; - MinPoint,MaxPoint: out Pnt2d from gp; - afont : Integer=-1) is virtual; - ---Level: Public - ---Purpose:XPos,YPos is the AttachPoint for the text.First, the stored Trsf is - -- applied to this point, then we get the size and length of text to - -- give the upper point - -fields - - myview : View from V2d; --to be replaced by a pointer... - -end TextProjector2d; diff --git a/src/StdSelect/StdSelect_TextProjector2d.cxx b/src/StdSelect/StdSelect_TextProjector2d.cxx deleted file mode 100755 index 2e2eb98709..0000000000 --- a/src/StdSelect/StdSelect_TextProjector2d.cxx +++ /dev/null @@ -1,73 +0,0 @@ -// Created on: 1995-04-21 -// Created by: Robert COUBLANC -// Copyright (c) 1995-1999 Matra Datavision -// Copyright (c) 1999-2012 OPEN CASCADE SAS -// -// The content of this file is subject to the Open CASCADE Technology Public -// License Version 6.5 (the "License"). You may not use the content of this file -// except in compliance with the License. Please obtain a copy of the License -// at http://www.opencascade.org and read it completely before using this file. -// -// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its -// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. -// -// The Original Code and all software distributed under the License is -// distributed on an "AS IS" basis, without warranty of any kind, and the -// Initial Developer hereby disclaims all such warranties, including without -// limitation, any warranties of merchantability, fitness for a particular -// purpose or non-infringement. Please see the License for the specific terms -// and conditions governing the rights and limitations under the License. - - - -#include -#include - - -//================================================== -// Function: -// Purpose : -//================================================== - -StdSelect_TextProjector2d:: -StdSelect_TextProjector2d(const Handle(V2d_View)& aView): -myview(aView) -{ -} - -//================================================== -// Function: -// Purpose : -//================================================== - -void StdSelect_TextProjector2d:: -Convert(const gp_Pnt2d& aPointIn, gp_Pnt2d& aPointOut) const -{ - aPointOut = aPointIn.Transformed(mytrsf); -} - -//================================================== -// Function: -// Purpose : -//================================================== - -void StdSelect_TextProjector2d -::Convert(const TCollection_ExtendedString& aText, - const Standard_Real XPos, - const Standard_Real YPos, - gp_Pnt2d& MinPoint, - gp_Pnt2d& MaxPoint, - const Standard_Integer afont) const -{ - Standard_ShortReal myL,myH; - MinPoint = gp_Pnt2d(XPos,YPos).Transformed(mytrsf); - myview->Driver()->TextSize(aText,myL,myH,afont); - Standard_Real myWinL=myview->Convert(myL); - Standard_Real myWinH=myview->Convert(myH); - - MaxPoint.SetCoord(XPos+myWinL,YPos+myWinH); - MaxPoint.Transform(mytrsf); -} - - - diff --git a/src/StdSelect/StdSelect_TextProjector2d.lxx b/src/StdSelect/StdSelect_TextProjector2d.lxx deleted file mode 100755 index 572ea71999..0000000000 --- a/src/StdSelect/StdSelect_TextProjector2d.lxx +++ /dev/null @@ -1,31 +0,0 @@ -// Created on: 1995-05-02 -// Created by: Robert COUBLANC -// Copyright (c) 1995-1999 Matra Datavision -// Copyright (c) 1999-2012 OPEN CASCADE SAS -// -// The content of this file is subject to the Open CASCADE Technology Public -// License Version 6.5 (the "License"). You may not use the content of this file -// except in compliance with the License. Please obtain a copy of the License -// at http://www.opencascade.org and read it completely before using this file. -// -// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its -// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. -// -// The Original Code and all software distributed under the License is -// distributed on an "AS IS" basis, without warranty of any kind, and the -// Initial Developer hereby disclaims all such warranties, including without -// limitation, any warranties of merchantability, fitness for a particular -// purpose or non-infringement. Please see the License for the specific terms -// and conditions governing the rights and limitations under the License. - - -inline void StdSelect_TextProjector2d::Set(const Handle(V2d_View)& aView) -{ - myview = aView; -} - - inline void StdSelect_TextProjector2d::Set(const gp_Trsf2d& atrsf) -{ - mytrsf = atrsf; -} - diff --git a/src/StdSelect/StdSelect_ViewerSelector2d.cdl b/src/StdSelect/StdSelect_ViewerSelector2d.cdl deleted file mode 100755 index 5dc64d36a7..0000000000 --- a/src/StdSelect/StdSelect_ViewerSelector2d.cdl +++ /dev/null @@ -1,93 +0,0 @@ --- Created on: 1995-02-23 --- Created by: Mister rmi --- Copyright (c) 1995-1999 Matra Datavision --- Copyright (c) 1999-2012 OPEN CASCADE SAS --- --- The content of this file is subject to the Open CASCADE Technology Public --- License Version 6.5 (the "License"). You may not use the content of this file --- except in compliance with the License. Please obtain a copy of the License --- at http://www.opencascade.org and read it completely before using this file. --- --- The Initial Developer of the Original Code is Open CASCADE S.A.S., having its --- main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. --- --- The Original Code and all software distributed under the License is --- distributed on an "AS IS" basis, without warranty of any kind, and the --- Initial Developer hereby disclaims all such warranties, including without --- limitation, any warranties of merchantability, fitness for a particular --- purpose or non-infringement. Please see the License for the specific terms --- and conditions governing the rights and limitations under the License. - - - -class ViewerSelector2d from StdSelect inherits ViewerSelector from SelectMgr - - ---Purpose: A viewer selection framework. - -- The objects defined in this framework can be passed to a selection manager. - -uses - - View from V2d, - Projector from Select2D, - Selection from SelectMgr, - GraphicObject from Graphic2d - -is - - Create returns mutable ViewerSelector2d from StdSelect; - - --- Purpose: Constructs an empty viewer selection framework. - - Create (aProjector: Projector from Select2D) - returns mutable ViewerSelector2d from StdSelect; - ---Purpose: Constructs the viewer selection framework defined by - -- the projector aProjector. - - Set(me:mutable; aSensitivity : Integer) is static; - ---Level: Public - ---Purpose: Sets a pixel tolerance for the selection. - -- will be converted for picking in a view. - - - Set(me:mutable; aProjector: Projector from Select2D) is static; - ---Purpose: Sets the new projector aProjector. - - Convert(me:mutable;aSelection:mutable Selection from SelectMgr) - is redefined static; - - Pick (me : mutable;XPix,YPix:Integer; - aView : View from V2d) is static; - ---Purpose: Returns the pixel coordinates of the mouse Xpix, Ypix - -- in the view aView. - - Pick (me:mutable;XPMin,YPMin,XPMax,YPMax:Integer;aView:View from V2d) is static; - ---Purpose: Returns the minimum and maximum pixel coordinates - -- XPMin, YPMin and XPMax, YPMax defining a 2D area in the view aView. - - - - Projector (me) returns any Projector from Select2D; - ---Purpose: Returns the projector which defines this framework. - ---C++: inline - - - DisplayAreas (me:mutable;aView:View from V2d) is static; - ---Purpose: Displays the active areas in the given view; - - - - ClearAreas(me:mutable) is static; - ---Purpose: Clear the displayed sensitive areas from this framework.. - - - -fields - - myprj : Projector from Select2D; - mypixtol : Integer; - - mygo : GraphicObject from Graphic2d; - -end ViewerSelector2d; - - diff --git a/src/StdSelect/StdSelect_ViewerSelector2d.cxx b/src/StdSelect/StdSelect_ViewerSelector2d.cxx deleted file mode 100755 index d494bbcd38..0000000000 --- a/src/StdSelect/StdSelect_ViewerSelector2d.cxx +++ /dev/null @@ -1,173 +0,0 @@ -// Created on: 1995-02-23 -// Created by: Mister rmi -// Copyright (c) 1995-1999 Matra Datavision -// Copyright (c) 1999-2012 OPEN CASCADE SAS -// -// The content of this file is subject to the Open CASCADE Technology Public -// License Version 6.5 (the "License"). You may not use the content of this file -// except in compliance with the License. Please obtain a copy of the License -// at http://www.opencascade.org and read it completely before using this file. -// -// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its -// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. -// -// The Original Code and all software distributed under the License is -// distributed on an "AS IS" basis, without warranty of any kind, and the -// Initial Developer hereby disclaims all such warranties, including without -// limitation, any warranties of merchantability, fitness for a particular -// purpose or non-infringement. Please see the License for the specific terms -// and conditions governing the rights and limitations under the License. - - - - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -//================================================== -// Function: -// Purpose : -//================================================== - -StdSelect_ViewerSelector2d::StdSelect_ViewerSelector2d(): -mypixtol(2) -{} - -StdSelect_ViewerSelector2d::StdSelect_ViewerSelector2d(const Handle(Select2D_Projector)& aPrj): -myprj(aPrj), -mypixtol(2) -{} - -//================================================== -// Function: Set -// Purpose : -//================================================== - -void StdSelect_ViewerSelector2d::Set(const Standard_Integer apixtol) -{mypixtol = apixtol; - tosort = Standard_True; -} - -//================================================== -// Function: Set -// Purpose : -//================================================== - -void StdSelect_ViewerSelector2d::Set(const Handle(Select2D_Projector)& aPrj) -{myprj = aPrj; - UpdateConversion(); -} - -//================================================== -// Function: Convert -// Purpose : -//================================================== - -void StdSelect_ViewerSelector2d::Convert(const Handle(SelectMgr_Selection)& aSel) -{ - for(aSel->Init();aSel->More();aSel->Next()) - { - if(aSel->Sensitive()->NeedsConversion()) - Handle(Select2D_SensitiveEntity):: - DownCast(aSel->Sensitive())->Convert(myprj); - } - tosort = Standard_True; -} - - -void StdSelect_ViewerSelector2d::Pick(const Standard_Integer XPix, - const Standard_Integer YPix, - const Handle(V2d_View)& aViou) -{ - Standard_Real Xr,Yr; - aViou->Convert(XPix,YPix,Xr,Yr); - InitSelect(Xr,Yr); -} - - - -void StdSelect_ViewerSelector2d::Pick(const Standard_Integer XPMin, - const Standard_Integer YPMin, - const Standard_Integer XPMax, - const Standard_Integer YPMax, - const Handle(V2d_View)& aViou) -{ - if(mypixtol!=0) mytolerance = aViou->Convert(mypixtol); - Standard_Real X1,Y1,X2,Y2; - aViou->Convert(XPMin,YPMin,X1,Y1); - aViou->Convert(XPMax,YPMax,X2,Y2); - InitSelect(Min(X1,X2), - Min(Y1,Y2), - Max(X1,X2), - Max(Y1,Y2)); -} - -//================================================== -// Function: DisplayAreas -// Purpose : -//================================================== -void StdSelect_ViewerSelector2d:: -DisplayAreas(const Handle(V2d_View)& aViou) -{ - mygo = new Graphic2d_GraphicObject(aViou->View()); - - Graphic2d_Array1OfVertex Av1 (1,5); - SelectMgr_DataMapIteratorOfDataMapOfIntegerSensitive It(myentities); - SelectBasics_ListOfBox2d BoxList; - Standard_Real xmin,ymin,xmax,ymax; - Handle(Graphic2d_Polyline) pol; - - for(;It.More();It.Next()) - { - It.Value()->Areas(BoxList); - // DEN - SelectBasics_ListIteratorOfListOfBox2d anIterator(BoxList); - for (;anIterator.More();anIterator.Next()) - { - anIterator.Value().Get(xmin,ymin,xmax,ymax); - - // FIN DEN - // BY DEN BoxList.Last().Get(xmin,ymin,xmax,ymax); - // construction des vertex graphiques - Av1.SetValue(1,Graphic2d_Vertex(xmin-mytolerance,ymin-mytolerance)); - Av1.SetValue(2,Graphic2d_Vertex(xmax+mytolerance,ymin-mytolerance)); - Av1.SetValue(3,Graphic2d_Vertex(xmax+mytolerance,ymax+mytolerance)); - Av1.SetValue(4,Graphic2d_Vertex(xmin-mytolerance,ymax+mytolerance)); - Av1.SetValue(5,Graphic2d_Vertex(xmin-mytolerance,ymin-mytolerance)); - - pol = new Graphic2d_Polyline(mygo,Av1); - pol ->SetColorIndex(4); //vert - pol->SetTypeIndex(2); - // DEN - } - // FIN DEN - } - mygo->Display(); - aViou->Update(); - -} - -//================================================ -// function : ClearAreas -// purpose : -//================================================ - -void StdSelect_ViewerSelector2d::ClearAreas () -{ - if (mygo.IsNull()) return; - mygo->RemovePrimitives(); - mygo->Display(); - mygo->Remove(); -} - - diff --git a/src/StdSelect/StdSelect_ViewerSelector2d.lxx b/src/StdSelect/StdSelect_ViewerSelector2d.lxx deleted file mode 100755 index ec24480b9f..0000000000 --- a/src/StdSelect/StdSelect_ViewerSelector2d.lxx +++ /dev/null @@ -1,21 +0,0 @@ -// Copyright (c) 1997-1999 Matra Datavision -// Copyright (c) 1999-2012 OPEN CASCADE SAS -// -// The content of this file is subject to the Open CASCADE Technology Public -// License Version 6.5 (the "License"). You may not use the content of this file -// except in compliance with the License. Please obtain a copy of the License -// at http://www.opencascade.org and read it completely before using this file. -// -// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its -// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. -// -// The Original Code and all software distributed under the License is -// distributed on an "AS IS" basis, without warranty of any kind, and the -// Initial Developer hereby disclaims all such warranties, including without -// limitation, any warranties of merchantability, fitness for a particular -// purpose or non-infringement. Please see the License for the specific terms -// and conditions governing the rights and limitations under the License. - -inline Handle(Select2D_Projector) StdSelect_ViewerSelector2d -::Projector () const -{return myprj;} diff --git a/src/TKCAF/EXTERNLIB b/src/TKCAF/EXTERNLIB index 3fb4b53bf7..e1cae0b332 100755 --- a/src/TKCAF/EXTERNLIB +++ b/src/TKCAF/EXTERNLIB @@ -6,7 +6,6 @@ TKMath TKService TKG2d TKG3d -TKV2d TKCDF TKLCAF TKV3d diff --git a/src/TKDCAF/EXTERNLIB b/src/TKDCAF/EXTERNLIB index 8af54990b9..f368834083 100755 --- a/src/TKDCAF/EXTERNLIB +++ b/src/TKDCAF/EXTERNLIB @@ -11,7 +11,6 @@ TKV3d TKNIS TKService TKLCAF -TKV2d TKFillet TKTopAlgo TKPrim diff --git a/src/TKMeshVS/EXTERNLIB b/src/TKMeshVS/EXTERNLIB index 2ee3e9621d..c9eebc5d24 100644 --- a/src/TKMeshVS/EXTERNLIB +++ b/src/TKMeshVS/EXTERNLIB @@ -3,5 +3,4 @@ TKMath TKService TKernel TKG3d -TKV2d TKG2d diff --git a/src/TKPCAF/EXTERNLIB b/src/TKPCAF/EXTERNLIB index bb1d537f1e..26e986d08e 100755 --- a/src/TKPCAF/EXTERNLIB +++ b/src/TKPCAF/EXTERNLIB @@ -7,7 +7,6 @@ TKG2d TKV3d TKService TKG3d -TKV2d TKPShape TKCAF TKLCAF diff --git a/src/TKQADraw/EXTERNLIB b/src/TKQADraw/EXTERNLIB index c5691ef16d..56f81e02a3 100755 --- a/src/TKQADraw/EXTERNLIB +++ b/src/TKQADraw/EXTERNLIB @@ -10,7 +10,6 @@ TKV3d TKGeomBase TKG3d TKViewerTest -TKV2d TKCDF TKDCAF TKLCAF diff --git a/src/TKService/PACKAGES b/src/TKService/PACKAGES index 4cdc1f2097..fe1881a4a6 100755 --- a/src/TKService/PACKAGES +++ b/src/TKService/PACKAGES @@ -3,12 +3,8 @@ InterfaceGraphic SelectBasics Viewer Xw -MFT -PS -CGM AlienImage Image -PlotMgt ImageUtility WNT Cocoa diff --git a/src/TKTopTest/EXTERNLIB b/src/TKTopTest/EXTERNLIB index 46755c61bb..18ed2658ea 100644 --- a/src/TKTopTest/EXTERNLIB +++ b/src/TKTopTest/EXTERNLIB @@ -12,7 +12,6 @@ TKGeomBase TKMesh TKService TKV3d -TKV2d TKFillet TKPrim TKBool diff --git a/src/TKV2d/EXTERNLIB b/src/TKV2d/EXTERNLIB deleted file mode 100755 index 2f5e6a0e40..0000000000 --- a/src/TKV2d/EXTERNLIB +++ /dev/null @@ -1,10 +0,0 @@ -TKernel -TKMath -TKGeomBase -TKG2d -TKGeomAlgo -TKBRep -TKHLR -TKTopAlgo -TKG3d -TKService diff --git a/src/TKV2d/FILES b/src/TKV2d/FILES deleted file mode 100755 index c999897bf1..0000000000 --- a/src/TKV2d/FILES +++ /dev/null @@ -1,2 +0,0 @@ -PACKAGES -EXTERNLIB diff --git a/src/TKV2d/PACKAGES b/src/TKV2d/PACKAGES deleted file mode 100755 index a3995c3c41..0000000000 --- a/src/TKV2d/PACKAGES +++ /dev/null @@ -1,6 +0,0 @@ -V2d -Graphic2d -Select2D -Prs2d -AIS2D -GGraphic2d diff --git a/src/TKV3d/EXTERNLIB b/src/TKV3d/EXTERNLIB index bfa3942b5e..a0787ed5e2 100755 --- a/src/TKV3d/EXTERNLIB +++ b/src/TKV3d/EXTERNLIB @@ -8,7 +8,6 @@ TKG3d TKGeomBase TKMesh TKGeomAlgo -TKV2d TKHLR CSF_user32 CSF_gdi32 diff --git a/src/TKViewerTest/EXTERNLIB b/src/TKViewerTest/EXTERNLIB index d610db899b..baa7e6a2d0 100755 --- a/src/TKViewerTest/EXTERNLIB +++ b/src/TKViewerTest/EXTERNLIB @@ -16,7 +16,6 @@ TKG3d TKOffset TKVoxel TKMesh -TKV2d TKV3d TKDraw TKOpenGl diff --git a/src/TKViewerTest/PACKAGES b/src/TKViewerTest/PACKAGES index d93fe3dcb9..6d361bb0ee 100755 --- a/src/TKViewerTest/PACKAGES +++ b/src/TKViewerTest/PACKAGES @@ -1,2 +1 @@ -Viewer2dTest ViewerTest diff --git a/src/TKVoxel/EXTERNLIB b/src/TKVoxel/EXTERNLIB index 52ffa27390..0a06c3417c 100644 --- a/src/TKVoxel/EXTERNLIB +++ b/src/TKVoxel/EXTERNLIB @@ -7,5 +7,4 @@ TKGeomBase TKG2d TKTopAlgo TKG3d -TKV2d TKMesh diff --git a/src/TKXCAF/EXTERNLIB b/src/TKXCAF/EXTERNLIB index f9cf7e03d1..a82c32bc9d 100755 --- a/src/TKXCAF/EXTERNLIB +++ b/src/TKXCAF/EXTERNLIB @@ -8,5 +8,4 @@ TKV3d TKCDF TKLCAF TKG3d -TKV2d TKCAF diff --git a/src/TKXSDRAW/EXTERNLIB b/src/TKXSDRAW/EXTERNLIB index ecab276224..9292c46148 100755 --- a/src/TKXSDRAW/EXTERNLIB +++ b/src/TKXSDRAW/EXTERNLIB @@ -8,7 +8,6 @@ TKXSBase TKMeshVS TKG3d TKViewerTest -TKV2d TKG2d TKSTEPBase TKTopAlgo diff --git a/src/V2d/V2d.cdl b/src/V2d/V2d.cdl deleted file mode 100755 index 39e8aee7c3..0000000000 --- a/src/V2d/V2d.cdl +++ /dev/null @@ -1,71 +0,0 @@ --- Created on: 1993-07-06 --- Created by: Jean Louis FRENKEL --- Copyright (c) 1993-1999 Matra Datavision --- Copyright (c) 1999-2012 OPEN CASCADE SAS --- --- The content of this file is subject to the Open CASCADE Technology Public --- License Version 6.5 (the "License"). You may not use the content of this file --- except in compliance with the License. Please obtain a copy of the License --- at http://www.opencascade.org and read it completely before using this file. --- --- The Initial Developer of the Original Code is Open CASCADE S.A.S., having its --- main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. --- --- The Original Code and all software distributed under the License is --- distributed on an "AS IS" basis, without warranty of any kind, and the --- Initial Developer hereby disclaims all such warranties, including without --- limitation, any warranties of merchantability, fitness for a particular --- purpose or non-infringement. Please see the License for the specific terms --- and conditions governing the rights and limitations under the License. - --- Modified: stt: 25-02-98: S3558 ajout ViewStdAdapter --- stt: 08-04-98: suppr ViewStdAdapter - - -package V2d ----Purpose: this package furnishes the services needed to build a --- 2d mono-view visualizer on a windowing system. -uses - - Quantity, - Graphic2d, - Aspect, - PlotMgt, - MMgt, - TCollection, - TColStd, - Viewer - -is - - class Viewer; - private pointer ViewerPointer to Viewer from V2d; - - class View; - ---Purpose: allows the creation of a view in a window driver. - --- describes all the commands available for a view. - -- - - class DefaultMap; - ---Purpose: furnishes default color, font, and width map. - - enumeration TypeOfWindowResizingEffect is TOWRE_ENLARGE_SPACE, - TOWRE_ENLARGE_OBJECTS - ---Purpose: determines the desired type of effect after the resizing - -- of a window. - end TypeOfWindowResizingEffect; - - ---Purpose: drawing of the grid. - - private class BackgroundGraphicObject; - - private class RectangularGrid; - private class CircularGrid; - - private class CircularGraphicGrid; - private class RectangularGraphicGrid; - - Draw(aViewer: Viewer from V2d); - ---Purpose: Test - -end V2d; diff --git a/src/V2d/V2d.cxx b/src/V2d/V2d.cxx deleted file mode 100755 index 8d0aeee97d..0000000000 --- a/src/V2d/V2d.cxx +++ /dev/null @@ -1,421 +0,0 @@ -// Copyright (c) 1999-2012 OPEN CASCADE SAS -// -// The content of this file is subject to the Open CASCADE Technology Public -// License Version 6.5 (the "License"). You may not use the content of this file -// except in compliance with the License. Please obtain a copy of the License -// at http://www.opencascade.org and read it completely before using this file. -// -// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its -// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. -// -// The Original Code and all software distributed under the License is -// distributed on an "AS IS" basis, without warranty of any kind, and the -// Initial Developer hereby disclaims all such warranties, including without -// limitation, any warranties of merchantability, fitness for a particular -// purpose or non-infringement. Please see the License for the specific terms -// and conditions governing the rights and limitations under the License. - -// Modified 10/04/98 : FMN ; Ajout include stdio.h pour WNT -#define PRO12324 // 03/07/98 : SYL ; bascule echo/pas echo pour test affichage et plotter - -#define TEST_IMAGE -#define TEST_PARAGRAPH - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#ifdef TEST_IMAGE -# include -# include -# include -# include -# include -#endif // TEST_IMAGE - -#ifdef TEST_PARAGRAPH -# include -# include -#endif // TEST_PARAGRAPH - -#define TRACE - -static char alphabet[]="abcdefghijklmnopqrstuvwzyz {}[]|`~!@#$%^&*()-_=+;:',<.>/?ABCDEFGHIJKLMNOPQRSTUVWXYZ 0123456789"; -static Standard_Boolean jeveuxecho = Standard_False; -static Standard_Boolean TestImage = Standard_False; -static Standard_Boolean TestPara = Standard_False; - -void V2d::Draw(const Handle(V2d_Viewer)& aViewer) -{ - Standard_Character txt[255]; - Handle_Graphic2d_ViewMapping aViewMapping; - Handle(Graphic2d_GraphicObject) go = new Graphic2d_GraphicObject(aViewer->View()); - -#ifdef TEST_IMAGE - OSD_Environment envImg ("CSF_V2D_TESTIMAGE"); - OSD_File File; - if (!envImg.Value().IsEmpty ()) { - OSD_Protection Protection (OSD_R, OSD_R, OSD_R, OSD_R); - OSD_Path Path = OSD_Path (TCollection_AsciiString (envImg.Value ()), OSD_Default); - File.SetPath (Path); - File.Open (OSD_ReadOnly, Protection); - if (File.IsOpen ()) { - File.Close (); - TestImage = Standard_True; - } - } - - if (TestImage) { - Handle(Graphic2d_ImageFile) myImageFile; - // Add non-zoomable image to GO - myImageFile = new Graphic2d_ImageFile (go, File, -0.1 METER, -0.1 METER); - myImageFile -> SetZoomable (Standard_False); - myImageFile -> SetColorIndex (3); - - // Add zoomable image to GO - myImageFile = new Graphic2d_ImageFile (go, File, 0.1 METER, 0.1 METER); - myImageFile -> SetZoomable (Standard_True); - - // Add some circles - Standard_Integer col = 1; -// Standard_Integer i,j; - Standard_Integer i; - Standard_Real ray = .10 METER; - for (i = 1; i<=20; i++) { - Handle(Graphic2d_Circle) c = new Graphic2d_Circle(go,0. METER,0. METER,ray); - c->SetColorIndex(col); - if (i>5) - c->SetTypeOfPolygonFilling(Graphic2d_TOPF_EMPTY); - else if (i>10) - c->SetTypeOfPolygonFilling(Graphic2d_TOPF_FILLED); - else if (i>15) - c->SetTypeOfPolygonFilling(Graphic2d_TOPF_PATTERNED); - ray -= 0.005 METER ; - col = col < 10 ? col + 1 : 1; - } - - } -#endif // TEST_IMAGE - -#ifdef TEST_PARAGRAPH - OSD_Environment envPara ("CSF_V2D_PZOOM"); - TestPara = (!envPara.Value ().IsEmpty()); - if (!TestImage && TestPara) { - Handle(Graphic2d_Paragraph) myParagraph; - Handle(Graphic2d_HidingText) myHText; - // Texts to add - TCollection_ExtendedString zText ("Zoomable Hiding Text"); - TCollection_ExtendedString nzText ("Non-Zoomable Hiding Text"); - TCollection_ExtendedString pstr1z ("Zoom Caracteres"); - TCollection_ExtendedString pstr1nz ("Non-Zoom Caracteres"); - TCollection_ExtendedString pstr21 ("Si vous ne goutez point ces"); - TCollection_ExtendedString pstr22 ("je m'en etonne"); - TCollection_ExtendedString pstr3 ("Mais si vous les goutez,je m'en etonne de meme"); - TCollection_ExtendedString pstr4 ("La BRUYERE"); - - // Add non-zoomable paragraph in GO - myParagraph = - new Graphic2d_Paragraph (go, 0. METER, 0. METER, 0.0, Aspect_CP_NorthEast, 0.7); - myParagraph -> SetFrameColorIndex (3); - myParagraph -> SetFrameWidthIndex (8); - myParagraph -> SetCurrentColorIndex (5); - myParagraph -> SetHidingColorIndex (9); - myParagraph -> SetZoomable (Standard_False); - - myParagraph -> SetCurrentFontIndex (13); - myParagraph -> SetCurrentAlignment (Graphic2d_TOA_CENTER); - myParagraph -> SetCurrentUnderline (Standard_True); - myParagraph -> AddText(pstr1nz, 1); - - myParagraph -> SetCurrentFontIndex (18); - myParagraph -> SetCurrentAlignment (Graphic2d_TOA_LEFT); - myParagraph -> SetCurrentUnderline (Standard_False); - myParagraph -> AddText(pstr21, 2); - - myParagraph -> SetCurrentFontIndex (23); - myParagraph -> SetCurrentAlignment (Graphic2d_TOA_RIGHT); - myParagraph -> SetCurrentUnderline (Standard_True); - myParagraph -> AddText(pstr22, 3); - - myParagraph -> SetCurrentFontIndex (27); - myParagraph -> SetCurrentAlignment (Graphic2d_TOA_LEFT); - myParagraph -> SetCurrentUnderline (Standard_False); - myParagraph -> AddText(pstr3, 4); - - myParagraph -> SetCurrentFontIndex (2); - myParagraph -> SetCurrentAlignment (Graphic2d_TOA_RIGHT); - myParagraph -> SetCurrentUnderline (Standard_True); - myParagraph -> AddText(pstr4, 5); - - // Add zoomable paragraph in GO - myParagraph = - new Graphic2d_Paragraph (go, 0. METER, 0. METER, 0.0, Aspect_CP_SouthWest, 3.5); - myParagraph -> SetFrameColorIndex (3); - myParagraph -> SetFrameWidthIndex (8); - myParagraph -> SetCurrentColorIndex (5); - myParagraph -> SetZoomable (Standard_True); - - myParagraph -> SetCurrentFontIndex (13); - myParagraph -> SetCurrentAlignment (Graphic2d_TOA_CENTER); - myParagraph -> SetCurrentUnderline (Standard_True); - myParagraph -> AddText(pstr1z, 1); - - myParagraph -> SetCurrentFontIndex (18); - myParagraph -> SetCurrentAlignment (Graphic2d_TOA_LEFT); - myParagraph -> SetCurrentUnderline (Standard_False); - myParagraph -> AddText(pstr21, 2); - - myParagraph -> SetCurrentFontIndex (23); - myParagraph -> SetCurrentAlignment (Graphic2d_TOA_RIGHT); - myParagraph -> SetCurrentUnderline (Standard_True); - myParagraph -> AddText(pstr22, 3); - - myParagraph -> SetCurrentFontIndex (27); - myParagraph -> SetCurrentAlignment (Graphic2d_TOA_LEFT); - myParagraph -> SetCurrentUnderline (Standard_False); - myParagraph -> AddText(pstr3, 4); - - myParagraph -> SetCurrentFontIndex (2); - myParagraph -> SetCurrentAlignment (Graphic2d_TOA_RIGHT); - myParagraph -> SetCurrentUnderline (Standard_True); - myParagraph -> AddText(pstr4, 5); - - // Add zoomable hiding text to GO - myHText = new Graphic2d_HidingText (go, zText, - -0.25 METER, 0.25 METER, 0.0, 0.5, Aspect_TOT_SOLID, 10.); - myHText -> SetFrameWidthIndex (8); - myHText -> SetFrameColorIndex (1); - myHText -> SetHidingColorIndex (8); - myHText -> SetColorIndex (5); - myHText -> SetZoomable (Standard_True); - - // Add non-zoomable hiding text to GO - myHText = new Graphic2d_HidingText (go, nzText, - 0.25 METER, -0.25 METER, 0.0, 0.5, Aspect_TOT_SOLID, 2.); - myHText -> SetFrameWidthIndex (8); - myHText -> SetFrameColorIndex (1); - myHText -> SetHidingColorIndex (10); - myHText -> SetColorIndex (5); - myHText -> SetZoomable (Standard_False); - - // Add some circles - Standard_Integer col = 1; -// Standard_Integer i,j; - Standard_Integer i; - Standard_Real ray = .10 METER; - for (i = 1; i<=20; i++) { - Handle(Graphic2d_Circle) c = new Graphic2d_Circle (go, 0. METER, 0. METER, ray); - c -> SetColorIndex(col); - ray -= 0.005 METER; - col = col < 12 ? col + 1 : 1; - } - - // Add some markers - Handle(Graphic2d_Marker) M; - Standard_ShortReal pos = -0.15 METER; - for (i = 1; i <= 12; i++) { - M = new Graphic2d_Marker(go, i, pos, pos, 0.005 METER,0.005 METER); - M -> SetColorIndex (i); - pos -= 0.02 METER; - } - } -#endif // TEST_PARAGRAPH - - if (!TestImage && !TestPara) { -#ifdef PRO12324 - // couleur de l' echo - Handle(Graphic2d_View) myGraphicView = aViewer->View(); - myGraphicView->SetDefaultOverrideColor((Standard_Integer) 1); -#endif - Handle(Aspect_FontMap) theFontMap = aViewer->FontMap(); - Standard_Real ray; - Standard_Real post; - Standard_Real slant = 0.5; - Standard_Integer col = 1; - Standard_Integer typ ; - Standard_Integer wid ; - Standard_Integer i,j; - Handle(Graphic2d_Text) T; - Handle(Graphic2d_FramedText) TF; - Handle(Graphic2d_HidingText) TH; - Handle(Graphic2d_Segment) s; - // Circles -#ifdef TRACE - cout << "Circle " << endl; -#endif - ray = .10 METER; - for ( i = 1; i<=20; i++) { - // cout << "ray=" << ray << " col=" << col << endl; - Handle(Graphic2d_Circle) c = new Graphic2d_Circle(go,0. METER,0. METER,ray); - c->SetColorIndex(col); - if(i>5) - c->SetTypeOfPolygonFilling(Graphic2d_TOPF_EMPTY); - else if (i>10) - c->SetTypeOfPolygonFilling(Graphic2d_TOPF_FILLED); - else if (i>15) - c->SetTypeOfPolygonFilling(Graphic2d_TOPF_PATTERNED); - ray -= 0.005 METER ; - col = col < 10 ? col + 1 : 1; - } - - // Lines - Standard_Real pos; - col = 1; - typ = 1; - wid = 1; - pos = 0.1 METER ; -#ifdef TRACE - cout << "Lines " << endl; -#endif - for ( i = 1; i<=8; i++) { - // Handle(Graphic2d_InfiniteLine) l = new Graphic2d_InfiniteLine(go, 0.0 METER, pos , pos , pos); - // l->SetColorIndex(col); - - s = new Graphic2d_Segment(go, -0.6 METER, pos , -0.25 METER , pos); - s->SetColorIndex(col); - s->SetTypeIndex(typ); - s->SetWidthIndex(wid); - post = pos; - for ( j = 0; j<10; j++) { - s = new Graphic2d_Segment(go, -0.25 METER, post , -0.20 METER , post); - s->SetColorIndex(col); - s->SetWidthIndex(1); - post -= 0.002 METER; - } - pos -= 0.02 METER ; - col = col < 8 ? col + 1 : 1; - typ = typ < 4 ? typ + 1 : 1; - wid = wid < 8 ? wid + 1 : 1; - } - - // Markers -#ifdef TRACE - cout << "Markers " << endl; -#endif - Handle(Graphic2d_Marker) M ; - pos = 0.2 METER; - for ( i = 1; i<=13; i++) { - M = new Graphic2d_Marker(go,i, - -.25 METER ,pos, - 0.005 METER,0.005 METER); - M->SetColorIndex(2); - pos -= 0.02 METER; - } - - //Handle(TCollection_ExtendedString) txt = new TCollection_ExtendedString(alphabet); - - // Texts -#ifdef TRACE - cout << "Texts " << endl; -#endif - Standard_Integer nb = 30; - col = 1; - pos = 0.60 METER; - post = (0.05 + nb * 0.02) METER; - // traits verticaux tous les 10 mm - Standard_Real posh; - for ( i = 1; i<=40; i++) { - posh = (-0.15 + (i-1) * 0.01) METER; - s = new Graphic2d_Segment(go, posh , pos , posh , pos-post); - s->SetColorIndex(2); - s->SetTypeIndex(1); - s->SetWidthIndex(1); - } - - Aspect_FontMapEntry entry; - TCollection_AsciiString aname; - Aspect_FontStyle style; - Standard_Integer iindex; - nb = theFontMap->Size(); - for ( i = 1; i<=nb; i++) { - // FontName - entry = theFontMap->Entry(i) ; - iindex = entry.Index() ; - style = entry.Type(); - aname = style.AliasName(); - sprintf(txt,"Text Pol %d:%s:%s",iindex,aname.ToCString(),alphabet); - T = new Graphic2d_Text(go, - TCollection_ExtendedString(txt), - -0.15 METER, pos, 0.); - T->SetFontIndex(iindex); - T->SetColorIndex(col); - // Trait horizontal - s = new Graphic2d_Segment(go, -0.2 METER, pos , 0.5 METER , pos); - s->SetColorIndex(2); - s->SetTypeIndex(1); - s->SetWidthIndex(1); - - sprintf(txt,"Hiding Text Pol %d:%s",iindex,alphabet); - TH = new Graphic2d_HidingText(go, - TCollection_ExtendedString(txt), - -0.15 METER, pos - post, - 0. , 0.1 ,Aspect_TOT_SOLID); - TH->SetFontIndex(iindex); - TH->SetColorIndex(col); - if( i>8 && i<15 ){ - TH->SetFrameColorIndex(col); - } - // Frame + Underline + Slant - sprintf(txt,"FramedText Pol %d",iindex); - TF = new Graphic2d_FramedText(go, - TCollection_ExtendedString(txt), - -0.6 METER, pos , - slant , 0.1 ,Aspect_TOT_SOLID); - TF->SetFontIndex(iindex); - TF->SetUnderline(Standard_True); - TF->SetColorIndex(col); - - M = new Graphic2d_Marker(go,2, - -0.6 METER ,pos, - 0.005 METER,0.005 METER); - M->SetColorIndex(2); - - pos -= 0.02 METER; - col = col < 8 ? col + 1 : 1; - } - i=1; - sprintf(txt,"Texte non zoom Pol %d",i); - T = new Graphic2d_Text(go, - TCollection_ExtendedString(txt), - -0.3 METER, -0.22 METER , - 0. METER); - T->SetColorIndex(2); - T->SetFontIndex(i); - T->SetZoomable(Standard_False); - } - -#ifdef PRO12324 - // bascule echo/pas echo - if(jeveuxecho){ - cout << "---- V2d ------ Highlight " << endl ; - go->Highlight( (Standard_Integer) 1); - jeveuxecho = Standard_False; - }else{ - cout << "---- V2d ------ Display" << endl ; - go->Display(); - jeveuxecho = Standard_True; - } -#else - go->Display(); -#endif - - aViewer->Update(); -} diff --git a/src/V2d/V2d_BackgroundGraphicObject.cdl b/src/V2d/V2d_BackgroundGraphicObject.cdl deleted file mode 100755 index 459f20243b..0000000000 --- a/src/V2d/V2d_BackgroundGraphicObject.cdl +++ /dev/null @@ -1,68 +0,0 @@ --- Created on: 1998-02-19 --- Created by: s: Gerard GRAS --- Copyright (c) 1998-1999 Matra Datavision --- Copyright (c) 1999-2012 OPEN CASCADE SAS --- --- The content of this file is subject to the Open CASCADE Technology Public --- License Version 6.5 (the "License"). You may not use the content of this file --- except in compliance with the License. Please obtain a copy of the License --- at http://www.opencascade.org and read it completely before using this file. --- --- The Initial Developer of the Original Code is Open CASCADE S.A.S., having its --- main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. --- --- The Original Code and all software distributed under the License is --- distributed on an "AS IS" basis, without warranty of any kind, and the --- Initial Developer hereby disclaims all such warranties, including without --- limitation, any warranties of merchantability, fitness for a particular --- purpose or non-infringement. Please see the License for the specific terms --- and conditions governing the rights and limitations under the License. - - - -private class BackgroundGraphicObject from V2d inherits GraphicObject from Graphic2d - - ---Version: - - ---Purpose: Creates a 2D background graphic object in a view. - -- A graphic object is a primitives manager - -- which drawn before all the others graphic objects - - ---Keywords: - ---Warning: - ---References: - -uses - View from Graphic2d - -is - ------------------------- - -- Category: Constructors - ------------------------- - - Create (aView: View from Graphic2d) - returns mutable BackgroundGraphicObject from V2d; - ---Level: Public - ---Purpose: Creates a graphic object in the view . - -- A graphic object manages a sequence of primitives. - ---Category: Constructors - - ------------------------------------------------- - -- Category: Methods to manage the drawing priority - ------------------------------------------------- - - MaxPriority (me) returns Integer from Standard is redefined; - ---Level: Public - ---Purpose: Returns the max usable relative priority of the - -- "hiding" graphic object. - - ---------------------------- - -- Category: Private methods - ---------------------------- - - BasePriority (me) returns Integer from Standard is redefined private; - ---Level: Internal - ---Purpose: Returns the min usable absolute priority of the - -- "hiding" graphic object. - -end BackgroundGraphicObject from V2d; diff --git a/src/V2d/V2d_BackgroundGraphicObject.cxx b/src/V2d/V2d_BackgroundGraphicObject.cxx deleted file mode 100755 index 6e04d0be21..0000000000 --- a/src/V2d/V2d_BackgroundGraphicObject.cxx +++ /dev/null @@ -1,41 +0,0 @@ -// Copyright (c) 1999-2012 OPEN CASCADE SAS -// -// The content of this file is subject to the Open CASCADE Technology Public -// License Version 6.5 (the "License"). You may not use the content of this file -// except in compliance with the License. Please obtain a copy of the License -// at http://www.opencascade.org and read it completely before using this file. -// -// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its -// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. -// -// The Original Code and all software distributed under the License is -// distributed on an "AS IS" basis, without warranty of any kind, and the -// Initial Developer hereby disclaims all such warranties, including without -// limitation, any warranties of merchantability, fitness for a particular -// purpose or non-infringement. Please see the License for the specific terms -// and conditions governing the rights and limitations under the License. - -#define PRO9581 //GG_270298 -// Creer la grille dans un objet graphique a l'altitude 0 -// de facon a etre tracee en premier. - -#include - -#define BASE_PRIORITY 0 -#define MAX_PRIORITY 0 - -V2d_BackgroundGraphicObject::V2d_BackgroundGraphicObject - (const Handle(Graphic2d_View)& aView) : Graphic2d_GraphicObject(aView) { -} - -Standard_Integer V2d_BackgroundGraphicObject::BasePriority () const { - - return BASE_PRIORITY; - -} - -Standard_Integer V2d_BackgroundGraphicObject::MaxPriority () const { - - return MAX_PRIORITY; - -} diff --git a/src/V2d/V2d_CircularGraphicGrid.cdl b/src/V2d/V2d_CircularGraphicGrid.cdl deleted file mode 100755 index 654b8bccc7..0000000000 --- a/src/V2d/V2d_CircularGraphicGrid.cdl +++ /dev/null @@ -1,67 +0,0 @@ --- Created on: 1995-03-17 --- Created by: Mister rmi --- Copyright (c) 1995-1999 Matra Datavision --- Copyright (c) 1999-2012 OPEN CASCADE SAS --- --- The content of this file is subject to the Open CASCADE Technology Public --- License Version 6.5 (the "License"). You may not use the content of this file --- except in compliance with the License. Please obtain a copy of the License --- at http://www.opencascade.org and read it completely before using this file. --- --- The Initial Developer of the Original Code is Open CASCADE S.A.S., having its --- main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. --- --- The Original Code and all software distributed under the License is --- distributed on an "AS IS" basis, without warranty of any kind, and the --- Initial Developer hereby disclaims all such warranties, including without --- limitation, any warranties of merchantability, fitness for a particular --- purpose or non-infringement. Please see the License for the specific terms --- and conditions governing the rights and limitations under the License. - - -private class CircularGraphicGrid from V2d inherits Primitive from Graphic2d - - -uses - Drawer from Graphic2d, - GraphicObject from Graphic2d, - Length from Quantity, - GridDrawMode from Aspect, - FStream from Aspect -is - Create (aGraphicObject: GraphicObject from Graphic2d; - X, Y, alpha, step: Real from Standard; - aDivision: Integer from Standard; - PointsColorIndex: Integer from Standard) - returns mutable CircularGraphicGrid from V2d; - - SetDrawMode(me: mutable; aDrawMode: GridDrawMode from Aspect) - is static; - - Draw (me: mutable; aDrawer: Drawer from Graphic2d) - is redefined static protected; - ---Level: Internal - ---Purpose: Draws the grid - - Pick (me: mutable; X, Y: ShortReal from Standard; - aPrecision: ShortReal from Standard; - aDrawer: Drawer from Graphic2d) - returns Boolean from Standard is redefined static protected; - ---Level: Internal - ---Purpose: Returns Standard_True if the infinite line is picked, - -- Standard_False if not. - - DrawCircle(me; aDrawer: Drawer from Graphic2d; - xc,yc,r: ShortReal from Standard; - DrawPoints: Boolean from Standard) - is static private; - - Save( me; aFStream: in out FStream from Aspect ) is virtual; - -fields - OX,OY,angle,Step: ShortReal from Standard; - Division: Integer from Standard; - DrawMode: GridDrawMode from Aspect; - myPointsColorIndex: Integer from Standard; -end CircularGraphicGrid from V2d; - diff --git a/src/V2d/V2d_CircularGraphicGrid.cxx b/src/V2d/V2d_CircularGraphicGrid.cxx deleted file mode 100755 index 300928adc0..0000000000 --- a/src/V2d/V2d_CircularGraphicGrid.cxx +++ /dev/null @@ -1,200 +0,0 @@ -// Copyright (c) 1999-2012 OPEN CASCADE SAS -// -// The content of this file is subject to the Open CASCADE Technology Public -// License Version 6.5 (the "License"). You may not use the content of this file -// except in compliance with the License. Please obtain a copy of the License -// at http://www.opencascade.org and read it completely before using this file. -// -// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its -// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. -// -// The Original Code and all software distributed under the License is -// distributed on an "AS IS" basis, without warranty of any kind, and the -// Initial Developer hereby disclaims all such warranties, including without -// limitation, any warranties of merchantability, fitness for a particular -// purpose or non-infringement. Please see the License for the specific terms -// and conditions governing the rights and limitations under the License. - -// Modified 23/02/98 : FMN ; Remplacement PI par Standard_PI -#define PRO10288 //GG 240398/090798 (PRO13334) -// Permettre un pas de rayon < 2 MM - -#define OCC192 // jfa 27/02/2002 -// for right display of rotated grid - -#include -#include - -V2d_CircularGraphicGrid::V2d_CircularGraphicGrid( - const Handle(Graphic2d_GraphicObject)& aGraphicObject, - const Standard_Real X, - const Standard_Real Y, - const Standard_Real alpha, - const Standard_Real step, - const Standard_Integer aDivision, - const Standard_Integer PointsColorIndex) - -:Graphic2d_Primitive(aGraphicObject), -OX((Standard_ShortReal)X), -OY((Standard_ShortReal)Y), -angle((Standard_ShortReal)alpha), -Step((Standard_ShortReal)step), -Division(aDivision), -DrawMode(Aspect_GDM_Lines), -myPointsColorIndex(PointsColorIndex) -{ - -} - -void V2d_CircularGraphicGrid::Draw(const Handle(Graphic2d_Drawer)& aDrawer){ - - Standard_ShortReal XF, YF, SF, XT, YT, STANDARD, ZF; - aDrawer->Values (XF, YF, SF, XT, YT, STANDARD, ZF); - Standard_Real w,h; - aDrawer->Driver()->WorkSpace(w,h); - Standard_ShortReal Coef = - (Standard_ShortReal) ((w < h) ? w/Sqrt( w*w + h*h) : h/Sqrt( w*w + h*h)) ; - - - Standard_Real d = Sqrt ( (OX-XF) * (OX-XF) + (OY-YF) * (OY-YF) ); - Standard_Integer n1,n; - Standard_Real thestep = Step; - if(d <= SF/Coef) { - n1 = 1; - n = (Standard_Integer )( ((Abs (OX-XF) > Abs (OY-YF) ? Abs (OX-XF) :Abs (OY-YF)) + SF /Coef)/thestep +1); - } - else { - n1 = (Standard_Integer )( (d - SF/Coef) /thestep); - n = Standard_Integer ( SF / thestep/Coef ) *2 + 1; - } -#ifdef PRO10288 - while ( n > 200) { -#else - while ( n > 100) { -#endif - thestep = thestep * 10.; - if(d <= SF/Coef) { - n1 = 1; - n = (Standard_Integer )( ((Abs (OX-XF) > Abs (OY-YF) ? Abs (OX-XF) :Abs (OY-YF)) + SF /Coef)/thestep +1); - } - else { - n1 = (Standard_Integer )( (d - SF/Coef) /thestep); - n = Standard_Integer ( SF / thestep/Coef ) *2 + 1; - } - } -// cout << "XF=" << XF << " YF =" << YF << " SF=" << SF -// << " n1 = " << n1 << " n= " << n << endl << flush; - Standard_ShortReal xc = Standard_ShortReal(OX); - Standard_ShortReal yc = Standard_ShortReal(OY); - Standard_ShortReal ds = Standard_ShortReal(thestep); - Standard_ShortReal s= Standard_ShortReal(n1)*ds; - switch (DrawMode){ - case Aspect_GDM_Points: { - aDrawer->SetMarkerAttrib (myPointsColorIndex,0,0); - aDrawer->MapMarkerFromTo(0,xc,yc,Standard_ShortReal(0.001),Standard_ShortReal(0.001),0.); - for (Standard_Integer k=1; k<=n; k++) { - DrawCircle(aDrawer,xc,yc,s,Standard_True); - s+=ds; - } - break; - } - case Aspect_GDM_Lines: - default: - { - aDrawer->SetLineAttrib (myColorIndex,0,0); - for (Standard_Integer i=1; i<=n; i++) { - DrawCircle(aDrawer,xc,yc,s,Standard_False); - s+=ds; - } - Standard_Real a = M_PI / Standard_Real(Division); - for (Standard_Integer j=1; j<= Division; j++) { - aDrawer->MapInfiniteLineFromTo(OX,OY , - Standard_ShortReal(Cos(angle+Standard_Real(j)*a)), - Standard_ShortReal(Sin(angle+Standard_Real(j)*a))); - } - } - } -} - -Standard_Boolean V2d_CircularGraphicGrid::Pick(const Standard_ShortReal X, - const Standard_ShortReal Y, - const Standard_ShortReal aPrecision, - const Handle(Graphic2d_Drawer)& aDrawer) { -return Standard_False; -} -void V2d_CircularGraphicGrid::SetDrawMode (const Aspect_GridDrawMode aDrawMode) { - DrawMode = aDrawMode; -} - -void V2d_CircularGraphicGrid::DrawCircle - (const Handle(Graphic2d_Drawer)& aDrawer, - const Standard_ShortReal myX, - const Standard_ShortReal myY, - const Standard_ShortReal myRadius, - const Standard_Boolean DrawPoints) const { - - Standard_ShortReal Def; - Standard_ShortReal Coeff; - Aspect_TypeOfDeflection Type; - aDrawer->DrawPrecision(Def,Coeff,Type); - Standard_Real val; - if(myRadius > Def) - val = Max( 0.0044 , Min (0.7854 , 2. * ACos(1.-Def/myRadius))); - else - val = 0.7854; // = PI / 4. - Standard_Integer nbpoints; - if(DrawPoints) { - nbpoints = Division *2; - } - else { - nbpoints = Standard_Integer(Abs (2 * M_PI) / val) + 2; - } - - Standard_ShortReal teta = Standard_ShortReal(Abs(2 * M_PI) / nbpoints); - Standard_ShortReal x1 = myRadius; - Standard_ShortReal y1 = 0; - Standard_ShortReal x2,y2,x3,y3; - Standard_ShortReal cosin = Standard_ShortReal(Cos(teta)); - x2 = Standard_ShortReal(myRadius * Cos(teta)); - y2 = Standard_ShortReal(myRadius * Sin(teta)); - -#ifdef OCC192 - Standard_ShortReal x_alpha, y_alpha; - Standard_ShortReal cos_alpha = Cos(angle), sin_alpha = Sin(angle); -#endif - if(DrawPoints) { -#ifdef OCC192 - x_alpha = x1*cos_alpha - y1*sin_alpha; // rotate on radians - y_alpha = x1*sin_alpha + y1*cos_alpha; // - aDrawer->MapMarkerFromTo(0,x_alpha+myX,y_alpha+myY,Standard_ShortReal(0.001),Standard_ShortReal(0.001),0.); -#else - aDrawer->MapMarkerFromTo(0,x1+myX,y1+myY,Standard_ShortReal(0.001),Standard_ShortReal(0.001),0.); - aDrawer->MapMarkerFromTo(0,x2+myX,y2+myY,Standard_ShortReal(0.001),Standard_ShortReal(0.001),0.); -#endif - } - else { - aDrawer->MapSegmentFromTo(x1+myX,y1+myY,x2+myX,y2+myY); - } - for (Standard_Integer i = 3; i <= nbpoints+1; i++) { - x3 = 2*x2*cosin - x1; - y3 = 2*y2*cosin - y1; - if(DrawPoints) { -#ifdef OCC192 - x_alpha = x2*cos_alpha - y2*sin_alpha; - y_alpha = x2*sin_alpha + y2*cos_alpha; - aDrawer->MapMarkerFromTo(0,x_alpha+myX,y_alpha+myY,Standard_ShortReal(0.001),Standard_ShortReal(0.001),0.); -#else - aDrawer->MapMarkerFromTo(0,x2+myX,y2+myY,Standard_ShortReal(0.001),Standard_ShortReal(0.001),0.); -#endif - } - else { - aDrawer->MapSegmentFromTo(x2+myX,y2+myY,x3+myX,y3+myY); - } - x1 = x2; y1 = y2; x2 = x3; y2 = y3; - } - } - -void V2d_CircularGraphicGrid::Save(Aspect_FStream& aFStream) const -{ -} - diff --git a/src/V2d/V2d_CircularGrid.cdl b/src/V2d/V2d_CircularGrid.cdl deleted file mode 100755 index 98d3f50faf..0000000000 --- a/src/V2d/V2d_CircularGrid.cdl +++ /dev/null @@ -1,63 +0,0 @@ --- Created on: 1995-03-17 --- Created by: Mister rmi --- Copyright (c) 1995-1999 Matra Datavision --- Copyright (c) 1999-2012 OPEN CASCADE SAS --- --- The content of this file is subject to the Open CASCADE Technology Public --- License Version 6.5 (the "License"). You may not use the content of this file --- except in compliance with the License. Please obtain a copy of the License --- at http://www.opencascade.org and read it completely before using this file. --- --- The Initial Developer of the Original Code is Open CASCADE S.A.S., having its --- main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. --- --- The Original Code and all software distributed under the License is --- distributed on an "AS IS" basis, without warranty of any kind, and the --- Initial Developer hereby disclaims all such warranties, including without --- limitation, any warranties of merchantability, fitness for a particular --- purpose or non-infringement. Please see the License for the specific terms --- and conditions governing the rights and limitations under the License. - --- Modification: DCB 14-07-98 --- SetColorIndices() method has been added to avoid exception --- after V2d_Viewer::SetColorMap() call. - -private class CircularGrid from V2d inherits CircularGrid from Aspect - -uses - ViewerPointer from V2d, - View from V2d, - GraphicObject from Graphic2d, - CircularGraphicGrid from V2d, - NameOfColor from Quantity -is - Create(aViewer: ViewerPointer from V2d; - aColorIndex1: Integer from Standard; - aColorIndex2: Integer from Standard) - returns mutable CircularGrid from V2d; - - SetColorIndices (me: mutable; - aColorIndex1: Integer from Standard; - aColorIndex2: Integer from Standard); - - Display(me: mutable) - is redefined static; - - Erase(me) - is redefined static; - - IsDisplayed(me) - returns Boolean from Standard - is redefined static; - - UpdateDisplay(me:mutable) - is redefined static protected; - -fields - myViewer: ViewerPointer from V2d; - myGraphicObject: GraphicObject from Graphic2d; - myColorIndex1: Integer from Standard; - myColorIndex2: Integer from Standard; - myGrid: CircularGraphicGrid from V2d; - -end CircularGrid from V2d; diff --git a/src/V2d/V2d_CircularGrid.cxx b/src/V2d/V2d_CircularGrid.cxx deleted file mode 100755 index 89f594cd4c..0000000000 --- a/src/V2d/V2d_CircularGrid.cxx +++ /dev/null @@ -1,82 +0,0 @@ -// Copyright (c) 1999-2012 OPEN CASCADE SAS -// -// The content of this file is subject to the Open CASCADE Technology Public -// License Version 6.5 (the "License"). You may not use the content of this file -// except in compliance with the License. Please obtain a copy of the License -// at http://www.opencascade.org and read it completely before using this file. -// -// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its -// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. -// -// The Original Code and all software distributed under the License is -// distributed on an "AS IS" basis, without warranty of any kind, and the -// Initial Developer hereby disclaims all such warranties, including without -// limitation, any warranties of merchantability, fitness for a particular -// purpose or non-infringement. Please see the License for the specific terms -// and conditions governing the rights and limitations under the License. - -#define PRO9581 //GG_270298 -// Creer la grille dans un objet graphique a l'altitude 0 -// de facon a etre tracee en premier. - -// Update 14/07/98 : DCB : PRO10988 SetColorIndices() method - -#include -#ifdef PRO9581 -#include -#else -#include -#endif -#include - -V2d_CircularGrid::V2d_CircularGrid(const V2d_ViewerPointer& aViewer, - const Standard_Integer aColorIndex1, - const Standard_Integer aColorIndex2) - : Aspect_CircularGrid(1.,8), - myViewer(aViewer), -#ifdef PRO9581 - myGraphicObject(new V2d_BackgroundGraphicObject(aViewer->View())), -#else - myGraphicObject(new Graphic2d_GraphicObject(aViewer->View())), -#endif - myColorIndex1(aColorIndex1), - myColorIndex2(aColorIndex2) -{ - Standard_Real l=100.; - Standard_Integer n = (Standard_Integer)log10(l); - Standard_Real step = Pow(10.,Standard_Real(n))/10.; - SetRadiusStep(step); - Init(); -} - -void V2d_CircularGrid::SetColorIndices (const Standard_Integer aColorIndex1, - const Standard_Integer aColorIndex2) -{ - myColorIndex1 = aColorIndex1; - myColorIndex2 = aColorIndex2; -} - -void V2d_CircularGrid::Display() -{ - myGraphicObject->Display(); -} - -void V2d_CircularGrid::Erase() const -{ - myGraphicObject->Erase(); -} - -void V2d_CircularGrid::UpdateDisplay() -{ - myGraphicObject->RemovePrimitives(); - myGrid = new V2d_CircularGraphicGrid - (myGraphicObject, - XOrigin(),YOrigin(),RotationAngle(),RadiusStep(),DivisionNumber(),myColorIndex2); - myGrid->SetColorIndex(myColorIndex1); - myGrid->SetDrawMode(DrawMode()); -} - -Standard_Boolean V2d_CircularGrid::IsDisplayed () const -{ - return myGraphicObject->IsDisplayed(); -} diff --git a/src/V2d/V2d_DefaultMap.cdl b/src/V2d/V2d_DefaultMap.cdl deleted file mode 100755 index d0f48b9656..0000000000 --- a/src/V2d/V2d_DefaultMap.cdl +++ /dev/null @@ -1,62 +0,0 @@ --- Created on: 1995-02-10 --- Created by: Mister rmi --- Copyright (c) 1995-1999 Matra Datavision --- Copyright (c) 1999-2012 OPEN CASCADE SAS --- --- The content of this file is subject to the Open CASCADE Technology Public --- License Version 6.5 (the "License"). You may not use the content of this file --- except in compliance with the License. Please obtain a copy of the License --- at http://www.opencascade.org and read it completely before using this file. --- --- The Initial Developer of the Original Code is Open CASCADE S.A.S., having its --- main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. --- --- The Original Code and all software distributed under the License is --- distributed on an "AS IS" basis, without warranty of any kind, and the --- Initial Developer hereby disclaims all such warranties, including without --- limitation, any warranties of merchantability, fitness for a particular --- purpose or non-infringement. Please see the License for the specific terms --- and conditions governing the rights and limitations under the License. - - -class DefaultMap from V2d - - ---Purpose: Modifies class definition. - -uses - GenericColorMap, TypeMap, WidthMap, FontMap, MarkMap from Aspect -is - - ColorMap(myclass) - ---Purpose: Returns a indexed color map with the following color - -- White, black, red, green, blue1 , yellow, sienna, orange2 - -- lightgray,lightseagreen,gray60,gray70. The index are 1 to 12. - returns GenericColorMap from Aspect; - - - TypeMap(myclass) - ---Purpose: Returns a indexed type map with the following line types - -- SOLID, DASH, DOT, DOTDASH. The index are 1 to 4. - returns TypeMap from Aspect; - - WidthMap(myclass) - ---Purpose: Returns a indexed width map with the following width - -- 0.0001, 0.0006, 0.001, 0.003. The index are 1 to 4. - returns WidthMap from Aspect; - - FontMap(myclass) - ---Purpose: Returns a indexed font map with the following font - -- "Courier-Bold" 0.01 0.0 - -- "Helvetica-Bold" 0.01 0.2 - -- "-adobe-helvetica-medium-r-normal--12-120-75-75-p-67-iso8859-1" 0.003 0.0 - -- The index are 1 to 2. - returns FontMap from Aspect; - - - MarkMap(myclass) - ---Purpose: Returns a indexed font map with the following width - -- Point,Plus,Star,O,X,O_Point,O_Plus,O_STAR,O_X - -- BALL,RING1,RING2,RING3 - returns MarkMap from Aspect; - -end DefaultMap from V2d; diff --git a/src/V2d/V2d_DefaultMap.cxx b/src/V2d/V2d_DefaultMap.cxx deleted file mode 100755 index 86fb074beb..0000000000 --- a/src/V2d/V2d_DefaultMap.cxx +++ /dev/null @@ -1,197 +0,0 @@ -// Copyright (c) 1999-2012 OPEN CASCADE SAS -// -// The content of this file is subject to the Open CASCADE Technology Public -// License Version 6.5 (the "License"). You may not use the content of this file -// except in compliance with the License. Please obtain a copy of the License -// at http://www.opencascade.org and read it completely before using this file. -// -// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its -// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. -// -// The Original Code and all software distributed under the License is -// distributed on an "AS IS" basis, without warranty of any kind, and the -// Initial Developer hereby disclaims all such warranties, including without -// limitation, any warranties of merchantability, fitness for a particular -// purpose or non-infringement. Please see the License for the specific terms -// and conditions governing the rights and limitations under the License. - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -static Handle(Aspect_GenericColorMap) V2dDMGCM; -static Handle(Aspect_TypeMap) V2dDMTM; -static Handle(Aspect_WidthMap) V2dDMWM; -static Handle(Aspect_FontMap) V2dDMFM; -static Handle(Aspect_MarkMap) V2dDMMM; - -Handle(Aspect_GenericColorMap) V2d_DefaultMap::ColorMap () { - if (V2dDMGCM.IsNull()) { - Standard_Integer nbcol=12; - TColStd_Array1OfInteger a(1,nbcol); - a( 1) = (Standard_Integer) Quantity_NOC_WHITE; - a( 2) = (Standard_Integer) Quantity_NOC_BLACK; - a( 3) = (Standard_Integer) Quantity_NOC_RED; - a( 4) = (Standard_Integer) Quantity_NOC_GREEN; - a( 5) = (Standard_Integer) Quantity_NOC_BLUE1; - a( 6) = (Standard_Integer) Quantity_NOC_YELLOW; - a( 7) = (Standard_Integer) Quantity_NOC_SIENNA; - a( 8) = (Standard_Integer) Quantity_NOC_ORANGE2; - a( 9) = (Standard_Integer) Quantity_NOC_LIGHTGRAY; - a(10) = (Standard_Integer) Quantity_NOC_LIGHTSEAGREEN; - a(11) = (Standard_Integer) Quantity_NOC_GRAY50; - a(12) = (Standard_Integer) Quantity_NOC_GRAY70; - - V2dDMGCM = new Aspect_GenericColorMap(); - Aspect_ColorMapEntry e; - for (Standard_Integer i = 1; i <= nbcol; i++) { -//JR/Hp - Standard_Integer iq = a(i) ; - e.SetValue(i,Quantity_Color( (Quantity_NameOfColor) iq )); -// e.SetValue(i,Quantity_Color((Quantity_NameOfColor) a(i))); - V2dDMGCM->AddEntry(e); - } - } - - return V2dDMGCM; - -} - - -Handle(Aspect_TypeMap) V2d_DefaultMap::TypeMap() { - if(V2dDMTM.IsNull()) { - V2dDMTM = new Aspect_TypeMap(); - V2dDMTM->AddEntry(Aspect_TypeMapEntry(1, Aspect_LineStyle(Aspect_TOL_SOLID))); - V2dDMTM->AddEntry(Aspect_TypeMapEntry(2, Aspect_LineStyle(Aspect_TOL_DASH))); - V2dDMTM->AddEntry(Aspect_TypeMapEntry(3, Aspect_LineStyle(Aspect_TOL_DOT))); - V2dDMTM->AddEntry(Aspect_TypeMapEntry(4, Aspect_LineStyle(Aspect_TOL_DOTDASH))); - } - return V2dDMTM; -} - -Handle(Aspect_WidthMap) V2d_DefaultMap::WidthMap() { - if(V2dDMWM.IsNull()) { - V2dDMWM = new Aspect_WidthMap(); - V2dDMWM->AddEntry(Aspect_WidthMapEntry(1,0.00013 METER)); - V2dDMWM->AddEntry(Aspect_WidthMapEntry(2,0.00018 METER)); - V2dDMWM->AddEntry(Aspect_WidthMapEntry(3,0.00025 METER)); - V2dDMWM->AddEntry(Aspect_WidthMapEntry(4,0.00035 METER)); - V2dDMWM->AddEntry(Aspect_WidthMapEntry(5,0.00050 METER)); - V2dDMWM->AddEntry(Aspect_WidthMapEntry(6,0.00070 METER)); - V2dDMWM->AddEntry(Aspect_WidthMapEntry(7,0.00100 METER)); - V2dDMWM->AddEntry(Aspect_WidthMapEntry(8,0.00140 METER)); - } - return V2dDMWM; -} - -Handle(Aspect_FontMap) V2d_DefaultMap::FontMap() { - if(V2dDMFM.IsNull()) { - V2dDMFM = new Aspect_FontMap(); - - V2dDMFM->AddEntry(Aspect_FontMapEntry(1,Aspect_FontStyle("TABTXT01",0.01 METER,0.0,Standard_True))); - - - V2dDMFM->AddEntry(Aspect_FontMapEntry(2,Aspect_FontStyle("TABTXT02",0.01 METER,0.0,Standard_True))); - - V2dDMFM->AddEntry(Aspect_FontMapEntry(3,Aspect_FontStyle("TABTXT03",0.01 METER,0.0,Standard_True))); - - V2dDMFM->AddEntry(Aspect_FontMapEntry(4,Aspect_FontStyle("TABTXT04",0.01 METER,0.0,Standard_True))); - - V2dDMFM->AddEntry(Aspect_FontMapEntry(5,Aspect_FontStyle("TABTXT05",0.01 METER,0.0,Standard_True))); - - V2dDMFM->AddEntry(Aspect_FontMapEntry(6,Aspect_FontStyle("TABTXT06",0.01 METER,0.0,Standard_True))); - V2dDMFM->AddEntry(Aspect_FontMapEntry(7,Aspect_FontStyle("TABTXT07",0.01 METER,0.0,Standard_True))); - V2dDMFM->AddEntry(Aspect_FontMapEntry(8,Aspect_FontStyle("TABTXT08",0.01 METER,0.0,Standard_True))); - V2dDMFM->AddEntry(Aspect_FontMapEntry(9,Aspect_FontStyle("TABTXT15",0.01 METER,0.0,Standard_True))); - V2dDMFM->AddEntry(Aspect_FontMapEntry - (10,Aspect_FontStyle("Defaultfont",0.01 METER,0.0,Standard_False))); - V2dDMFM->AddEntry(Aspect_FontMapEntry - (11,Aspect_FontStyle("Symbol",0.01 METER,0.0,Standard_False))); - - V2dDMFM->AddEntry(Aspect_FontMapEntry - (12,Aspect_FontStyle("Courier",0.01 METER,0.0,Standard_False))); - V2dDMFM->AddEntry(Aspect_FontMapEntry - (13,Aspect_FontStyle("Courier-Bold",0.01 METER,0.0,Standard_False))); - V2dDMFM->AddEntry(Aspect_FontMapEntry - (14,Aspect_FontStyle("Courier-Italic",0.01 METER,0.0,Standard_False))); - V2dDMFM->AddEntry(Aspect_FontMapEntry - (15,Aspect_FontStyle("Courier-BoldItalic",0.01 METER,0.0,Standard_False))); - V2dDMFM->AddEntry(Aspect_FontMapEntry - (16,Aspect_FontStyle("Courier-Oblique",0.01 METER,0.0,Standard_False))); - V2dDMFM->AddEntry(Aspect_FontMapEntry - (17,Aspect_FontStyle("Helvetica",0.01 METER,0.0,Standard_False))); - V2dDMFM->AddEntry(Aspect_FontMapEntry - (18,Aspect_FontStyle("Helvetica-Bold",0.01 METER,0.0,Standard_False))); - - V2dDMFM->AddEntry(Aspect_FontMapEntry - (19,Aspect_FontStyle("Helvetica-Oblique",0.01 METER,0.0,Standard_False))); - V2dDMFM->AddEntry(Aspect_FontMapEntry - (20,Aspect_FontStyle("Helvetica-BoldOblique",0.01 METER,0.0,Standard_False))); - V2dDMFM->AddEntry(Aspect_FontMapEntry - (21,Aspect_FontStyle("Helvetica-Medium",0.01 METER,0.0,Standard_False))); - V2dDMFM->AddEntry(Aspect_FontMapEntry - (22,Aspect_FontStyle("Times",0.01 METER,0.0,Standard_False))); - V2dDMFM->AddEntry(Aspect_FontMapEntry - (23,Aspect_FontStyle("Times-Bold",0.01 METER,0.0,Standard_False))); - V2dDMFM->AddEntry(Aspect_FontMapEntry - (24,Aspect_FontStyle("Times-Italic",0.01 METER,0.0,Standard_False))); - V2dDMFM->AddEntry(Aspect_FontMapEntry - (25,Aspect_FontStyle("Times-BoldItalic",0.01 METER,0.0,Standard_False))); - V2dDMFM->AddEntry(Aspect_FontMapEntry - (26,Aspect_FontStyle("Times-Roman",0.01 METER,0.0,Standard_False))); - - V2dDMFM->AddEntry(Aspect_FontMapEntry - (27,Aspect_FontStyle("Utopia-Bold",0.01 METER,0.0,Standard_False))); - V2dDMFM->AddEntry(Aspect_FontMapEntry - (28,Aspect_FontStyle("Utopia-Italic",0.01 METER,0.0,Standard_False))); - V2dDMFM->AddEntry(Aspect_FontMapEntry - (29,Aspect_FontStyle("Utopia-BoldItalic",0.01 METER,0.0,Standard_False))); - V2dDMFM->AddEntry(Aspect_FontMapEntry - (30,Aspect_FontStyle("Utopia-Regular",0.01 METER,0.0,Standard_False))); - //V2dDMFM->AddEntry(Aspect_FontMapEntry(10,Aspect_FontStyle("-adobe-helvetica-medium-r-normal--12-120-75-75-p-67-iso8859-1" ,0.003 METER,0.0,Standard_False))); - - } - return V2dDMFM; -} - -Handle(Aspect_MarkMap) V2d_DefaultMap::MarkMap() { - if(V2dDMMM.IsNull()) { - V2dDMMM = new Aspect_MarkMap(); - V2dDMMM->AddEntry(Aspect_MarkMapEntry( 1, Aspect_MarkerStyle(Aspect_TOM_POINT))); - V2dDMMM->AddEntry(Aspect_MarkMapEntry( 2, Aspect_MarkerStyle(Aspect_TOM_PLUS))); - V2dDMMM->AddEntry(Aspect_MarkMapEntry( 3, Aspect_MarkerStyle(Aspect_TOM_STAR))); - V2dDMMM->AddEntry(Aspect_MarkMapEntry( 4, Aspect_MarkerStyle(Aspect_TOM_O))); - V2dDMMM->AddEntry(Aspect_MarkMapEntry( 5, Aspect_MarkerStyle(Aspect_TOM_X))); - V2dDMMM->AddEntry(Aspect_MarkMapEntry( 6, Aspect_MarkerStyle(Aspect_TOM_O_POINT))); - V2dDMMM->AddEntry(Aspect_MarkMapEntry( 7, Aspect_MarkerStyle(Aspect_TOM_O_PLUS))); - V2dDMMM->AddEntry(Aspect_MarkMapEntry( 8, Aspect_MarkerStyle(Aspect_TOM_O_STAR))); - V2dDMMM->AddEntry(Aspect_MarkMapEntry( 9, Aspect_MarkerStyle(Aspect_TOM_O_X))); - V2dDMMM->AddEntry(Aspect_MarkMapEntry(10, Aspect_MarkerStyle(Aspect_TOM_BALL))); - V2dDMMM->AddEntry(Aspect_MarkMapEntry(11, Aspect_MarkerStyle(Aspect_TOM_RING1))); - V2dDMMM->AddEntry(Aspect_MarkMapEntry(12, Aspect_MarkerStyle(Aspect_TOM_RING2))); - V2dDMMM->AddEntry(Aspect_MarkMapEntry(13, Aspect_MarkerStyle(Aspect_TOM_RING3))); - TColStd_Array1OfReal X(1,5); - TColStd_Array1OfReal Y(1,5); - TColStd_Array1OfBoolean B(1,5); - X(1) = 0.; Y(1) = 0. ; B(1) = Standard_False; - X(2) = 1.; Y(2) = 0. ; B(2) = Standard_True; - X(3) = 0.7; Y(3) = 0.2 ; B(3) = Standard_True; - X(4) = 1.; Y(4) = 0. ; B(4) = Standard_False; - X(5) = 0.7; Y(5) = -0.2; B(5) = Standard_True; - V2dDMMM->AddEntry(Aspect_MarkMapEntry(14,Aspect_MarkerStyle(X,Y,B))); - - } - return V2dDMMM; -} diff --git a/src/V2d/V2d_RectangularGraphicGrid.cdl b/src/V2d/V2d_RectangularGraphicGrid.cdl deleted file mode 100755 index 9ada68c347..0000000000 --- a/src/V2d/V2d_RectangularGraphicGrid.cdl +++ /dev/null @@ -1,70 +0,0 @@ --- Created on: 1995-03-03 --- Created by: Jean-Louis Frenkel --- Copyright (c) 1995-1999 Matra Datavision --- Copyright (c) 1999-2012 OPEN CASCADE SAS --- --- The content of this file is subject to the Open CASCADE Technology Public --- License Version 6.5 (the "License"). You may not use the content of this file --- except in compliance with the License. Please obtain a copy of the License --- at http://www.opencascade.org and read it completely before using this file. --- --- The Initial Developer of the Original Code is Open CASCADE S.A.S., having its --- main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. --- --- The Original Code and all software distributed under the License is --- distributed on an "AS IS" basis, without warranty of any kind, and the --- Initial Developer hereby disclaims all such warranties, including without --- limitation, any warranties of merchantability, fitness for a particular --- purpose or non-infringement. Please see the License for the specific terms --- and conditions governing the rights and limitations under the License. - - -private class RectangularGraphicGrid from V2d inherits Primitive from Graphic2d - - -uses - Drawer from Graphic2d, - GraphicObject from Graphic2d, - Length from Quantity, - GridDrawMode from Aspect, - FStream from Aspect -is - - Create (aGraphicObject: GraphicObject from Graphic2d; - X, Y, alpha, beta, xo ,yo: Real from Standard; - aTenthColorIndex: Integer from Standard) - returns mutable RectangularGraphicGrid from V2d; - - SetDrawMode(me: mutable; aDrawMode: GridDrawMode from Aspect) - is static; - - Draw (me: mutable; aDrawer: Drawer from Graphic2d) - is redefined static protected; - ---Level: Internal - ---Purpose: Draws the grid - - Pick (me: mutable; X, Y: ShortReal from Standard; - aPrecision: ShortReal from Standard; - aDrawer: Drawer from Graphic2d) - returns Boolean from Standard is redefined static protected; - ---Level: Internal - ---Purpose: Returns Standard_True if the infinite line is picked, - -- Standard_False if not. - - DrawNetwork(me; aDrawer: Drawer from Graphic2d; - alpha,step:ShortReal from Standard; - xfrom,yfrom, sizefrom: ShortReal from Standard ) - is static private; - - DrawPoints(me; aDrawer: Drawer from Graphic2d; - xfrom,yfrom, sizefrom: ShortReal from Standard ) - is static private; - - Save( me; aFStream: in out FStream from Aspect ) is virtual; - -fields - StepX, StepY,a1,a2,OX,OY: ShortReal from Standard; - DrawMode: GridDrawMode from Aspect; - myTenthColorIndex: Integer from Standard; -end RectangularGraphicGrid from V2d; - diff --git a/src/V2d/V2d_RectangularGraphicGrid.cxx b/src/V2d/V2d_RectangularGraphicGrid.cxx deleted file mode 100755 index 38a606e302..0000000000 --- a/src/V2d/V2d_RectangularGraphicGrid.cxx +++ /dev/null @@ -1,257 +0,0 @@ -// Copyright (c) 1999-2012 OPEN CASCADE SAS -// -// The content of this file is subject to the Open CASCADE Technology Public -// License Version 6.5 (the "License"). You may not use the content of this file -// except in compliance with the License. Please obtain a copy of the License -// at http://www.opencascade.org and read it completely before using this file. -// -// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its -// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. -// -// The Original Code and all software distributed under the License is -// distributed on an "AS IS" basis, without warranty of any kind, and the -// Initial Developer hereby disclaims all such warranties, including without -// limitation, any warranties of merchantability, fitness for a particular -// purpose or non-infringement. Please see the License for the specific terms -// and conditions governing the rights and limitations under the License. - -#define BUC60639 //GG 15/03/00 Avoid to compute view minmax -// including grid origin marker. -// // Sets correctly the grid origin marker size. - -#define OCC194 //jfa 28/02/2002 -// Fill all the viewer area with rotated rectangular grid - -#include -#include - -#ifdef BUC60639 -#define MTHICK 6 -#define MINDEX 4 -#endif - -//======================================================================= -//function : V2d_RectangularGraphicGrid -//purpose : -//======================================================================= - -V2d_RectangularGraphicGrid::V2d_RectangularGraphicGrid( - const Handle(Graphic2d_GraphicObject)& aGraphicObject, - const Standard_Real X, - const Standard_Real Y, - const Standard_Real alpha, - const Standard_Real beta, - const Standard_Real xo, - const Standard_Real yo, - const Standard_Integer aTenthColorIndex) -:Graphic2d_Primitive(aGraphicObject),StepX((Standard_ShortReal)(X)), StepY((Standard_ShortReal)(Y)), - a1((Standard_ShortReal)(alpha)),a2((Standard_ShortReal)(beta)), - OX((Standard_ShortReal)(xo)),OY((Standard_ShortReal)(yo)), - DrawMode(Aspect_GDM_Lines),myTenthColorIndex(aTenthColorIndex){ - -} - -//======================================================================= -//function : Draw -//purpose : -//======================================================================= - -void V2d_RectangularGraphicGrid::Draw(const Handle(Graphic2d_Drawer)& aDrawer) { - - Standard_ShortReal XF, YF, SF, XT, YT, STANDARD, ZF; - aDrawer->Values (XF, YF, SF, XT, YT, STANDARD, ZF); -// - Standard_Real w,h; aDrawer->Driver()->WorkSpace(w,h); -// cout << "Work space: " << w << "," << h << endl; - Standard_ShortReal Coef = Standard_ShortReal( (w > h) ? (w/h) : h/w); -#ifdef OCC194 - if (Abs(a1) > 0.0) - { - Standard_ShortReal alpha = a1 - ((Standard_Integer)(a1/1.57))*1.57; - alpha = alpha - 1.57/2.0; - Coef = Abs(Coef * 1.41 * Cos(alpha)); - } -#endif - - switch (DrawMode){ - case Aspect_GDM_Points: - aDrawer->SetMarkerAttrib (myTenthColorIndex,0,0); - DrawPoints(aDrawer,XF,YF,SF * Coef); - break; - case Aspect_GDM_Lines: - default: - aDrawer->SetLineAttrib (myColorIndex,0,0); - DrawNetwork(aDrawer,a1,StepX,XF,YF,SF * Coef); - DrawNetwork(aDrawer,a2,StepY,XF,YF,SF * Coef); - } -#ifdef BUC60639 - aDrawer->SetMarkerAttrib(myTenthColorIndex,MTHICK,Standard_False); - aDrawer->MapMarkerFromTo (MINDEX, OX, OY, (Standard_ShortReal)(StepX/2.), (Standard_ShortReal)(StepY/2.), 0.0); -#endif -} - -//======================================================================= -//function : Pick -//purpose : -//======================================================================= - -Standard_Boolean V2d_RectangularGraphicGrid::Pick(const Standard_ShortReal , - const Standard_ShortReal , - const Standard_ShortReal , - const Handle(Graphic2d_Drawer)& ) -{ - return Standard_False; -} - -//======================================================================= -//function : DrawNetwork -//purpose : -//======================================================================= - -void V2d_RectangularGraphicGrid::DrawNetwork(const Handle(Graphic2d_Drawer)& aDrawer, - const Standard_ShortReal alpha, - const Standard_ShortReal step, - const Standard_ShortReal XF, - const Standard_ShortReal YF, - const Standard_ShortReal SF) const -{ - - Standard_Real thestep = step; -#ifdef OCC194 - Standard_Integer n = Standard_Integer ( SF * 2 / thestep ) + 1; -#else - Standard_Integer n = Standard_Integer ( SF / thestep ) * 2 + 1; -#endif - -//+zov Fixing CTS17856 -// cerr << "V2d...Grid::DrawNetwork: step = " << step << " alpha" << alpha << " n = " << n << endl << flush; -//-zov - - -//+zov Fixing CTS17856 -// Standard_ShortReal c = cos(alpha); -// Standard_ShortReal s = sin(alpha); - Standard_ShortReal s = Standard_ShortReal(cos(alpha)); - Standard_ShortReal c = Standard_ShortReal(-sin(alpha)); -//-zov - - Standard_ShortReal d = Abs(s*(XF-OX) - c*(YF-OY)); - Standard_Integer n1 = (Standard_Integer )( (d + SF) / thestep); - - Standard_ShortReal decalx,decaly; - - Standard_ShortReal deltax = (Standard_ShortReal) ( thestep * s ); - Standard_ShortReal deltay = (Standard_ShortReal) (- thestep * c ); - - Standard_Boolean neg = s*(XF-OX) - c*(YF-OY) < 0 ? Standard_True - : Standard_False; - if ( neg ) { - decalx = (Standard_ShortReal) (OX - n1 * thestep * s ); - decaly = (Standard_ShortReal) (OY + n1 * thestep * c ); - deltax = (Standard_ShortReal) ( thestep * s ); - deltay = (Standard_ShortReal) (- thestep * c ); - } - else { - decalx = (Standard_ShortReal) (OX + n1 * thestep * s ); - decaly = (Standard_ShortReal) (OY - n1 * thestep * c ); - deltax = (Standard_ShortReal) (- thestep * s ); - deltay = (Standard_ShortReal) ( thestep * c ); - } - - Standard_Integer p = Modulus( n1 , 10); - for (Standard_Integer i = 1; i <= n ; i++) { - if( p == 0){ - aDrawer->SetLineAttrib(myTenthColorIndex,0,0); - aDrawer->MapInfiniteLineFromTo(decalx ,decaly ,c,s); - aDrawer->SetLineAttrib(myColorIndex,0,0); - } - else - if (n < 300)aDrawer->MapInfiniteLineFromTo(decalx ,decaly ,c,s); - - p = p >= 1 ? p-1: 9; - decalx += deltax; - decaly += deltay; - } -} - -//======================================================================= -//function : DrawPoints -//purpose : -//======================================================================= - -void V2d_RectangularGraphicGrid::DrawPoints(const Handle(Graphic2d_Drawer)& aDrawer, - const Standard_ShortReal XF, - const Standard_ShortReal YF, - const Standard_ShortReal SF) const -{ - Standard_ShortReal sx = StepX; - Standard_ShortReal sy = StepY; - Standard_Integer n = Standard_Integer(SF/Min(sx,sy)) * 2 + 1; - - -//+zov Fixing CTS17856 -// Standard_ShortReal sin1 = Standard_ShortReal(Sin(a1)); -// Standard_ShortReal cos1 = Standard_ShortReal(Cos(a1)); -// Standard_ShortReal sin2 = Standard_ShortReal(Sin(a2)); -// Standard_ShortReal cos2 = Standard_ShortReal(Cos(a2)); - - Standard_ShortReal cos1 = -Standard_ShortReal(Sin(a1)); - Standard_ShortReal sin1 = Standard_ShortReal(Cos(a1)); - Standard_ShortReal cos2 = -Standard_ShortReal(Sin(a2)); - Standard_ShortReal sin2 = Standard_ShortReal(Cos(a2)); -// well it's somewhat silly to call cos sinus and vice versa but -// it is the simplest way to patch a hole. I mean CTS17856. (zov) -//-zov - - Standard_ShortReal c1 = OX * sin1 - OY * cos1; - Standard_ShortReal c2 = OX * sin2 - OY * cos2; - Standard_ShortReal D1 = sin1 * XF - cos1 * YF - c1; - Standard_ShortReal D2 = sin2 * XF - cos2 * YF - c2; - Standard_Integer n1 = Standard_Integer ( Abs(D1)/sx + 0.5); - Standard_Integer n2 = Standard_Integer ( Abs(D2)/sy + 0.5); - Standard_ShortReal offset1 = (Standard_ShortReal) (c1 + Standard_ShortReal(n1) * Sign (sx , D1)); - Standard_ShortReal offset2 = (Standard_ShortReal) (c2 + Standard_ShortReal(n2) * Sign (sy , D2)); - Standard_ShortReal Delta = sin1*cos2 - cos1*sin2; - Standard_ShortReal gridX = ( offset1*cos2 - offset2*cos1) /Delta; - Standard_ShortReal gridY = ( offset1*sin2 - offset2*sin1) /Delta; - Standard_ShortReal v1x = sx * cos2; - Standard_ShortReal v1y = sx * sin2; - Standard_ShortReal v2x = sy * cos1; - Standard_ShortReal v2y = sy * sin1; - - Standard_ShortReal debx = gridX - n/2 * v1x - n/2 * v2x; - Standard_ShortReal deby = gridY - n/2 * v1y - n/2 * v2y; - Standard_ShortReal ax; - Standard_ShortReal ay; - for (Standard_Integer i=1; i<=n ; i++) { - ax = debx; - ay = deby; - for (Standard_Integer j=1; j<=n ; j++) { - aDrawer->MapMarkerFromTo(0,ax,ay,Standard_ShortReal(0.001),Standard_ShortReal(0.001),0.); - ax += v1x; - ay += v1y; - } - debx += v2x; - deby += v2y; - } -} - -//======================================================================= -//function : SetDrawMode -//purpose : -//======================================================================= - -void V2d_RectangularGraphicGrid::SetDrawMode (const Aspect_GridDrawMode aDrawMode) -{ - DrawMode = aDrawMode; -} - -//======================================================================= -//function : Save -//purpose : -//======================================================================= - -void V2d_RectangularGraphicGrid::Save(Aspect_FStream& /*aFStream*/) const -{ -} - diff --git a/src/V2d/V2d_RectangularGrid.cdl b/src/V2d/V2d_RectangularGrid.cdl deleted file mode 100755 index a090791f57..0000000000 --- a/src/V2d/V2d_RectangularGrid.cdl +++ /dev/null @@ -1,64 +0,0 @@ --- Created on: 1995-03-08 --- Created by: Jean-Louis Frenkel --- Copyright (c) 1995-1999 Matra Datavision --- Copyright (c) 1999-2012 OPEN CASCADE SAS --- --- The content of this file is subject to the Open CASCADE Technology Public --- License Version 6.5 (the "License"). You may not use the content of this file --- except in compliance with the License. Please obtain a copy of the License --- at http://www.opencascade.org and read it completely before using this file. --- --- The Initial Developer of the Original Code is Open CASCADE S.A.S., having its --- main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. --- --- The Original Code and all software distributed under the License is --- distributed on an "AS IS" basis, without warranty of any kind, and the --- Initial Developer hereby disclaims all such warranties, including without --- limitation, any warranties of merchantability, fitness for a particular --- purpose or non-infringement. Please see the License for the specific terms --- and conditions governing the rights and limitations under the License. - --- Modification: DCB 14-07-98 --- SetColorIndices() method has been added to avoid exception --- after V2d_Viewer::SetColorMap() call. - -private class RectangularGrid from V2d -inherits RectangularGrid from Aspect - -uses - ViewerPointer from V2d, - GraphicObject from Graphic2d, - RectangularGraphicGrid from V2d, - NameOfColor from Quantity - -is - Create(aViewer: ViewerPointer from V2d; - aColorIndex1: Integer from Standard; - aColorIndex2: Integer from Standard) - returns mutable RectangularGrid from V2d; - - SetColorIndices (me: mutable; - aColorIndex1: Integer from Standard; - aColorIndex2: Integer from Standard); - - Display(me: mutable) - is redefined static; - - Erase(me) - is redefined static; - - IsDisplayed(me) - returns Boolean from Standard - is redefined static; - - UpdateDisplay(me:mutable) - is redefined static protected; - -fields - myViewer: ViewerPointer from V2d; - myGraphicObject: GraphicObject from Graphic2d; - myColorIndex1: Integer from Standard; - myColorIndex2: Integer from Standard; - myGrid: RectangularGraphicGrid from V2d; - -end RectangularGrid from V2d; diff --git a/src/V2d/V2d_RectangularGrid.cxx b/src/V2d/V2d_RectangularGrid.cxx deleted file mode 100755 index 22380d7cf1..0000000000 --- a/src/V2d/V2d_RectangularGrid.cxx +++ /dev/null @@ -1,96 +0,0 @@ -// Copyright (c) 1999-2012 OPEN CASCADE SAS -// -// The content of this file is subject to the Open CASCADE Technology Public -// License Version 6.5 (the "License"). You may not use the content of this file -// except in compliance with the License. Please obtain a copy of the License -// at http://www.opencascade.org and read it completely before using this file. -// -// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its -// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. -// -// The Original Code and all software distributed under the License is -// distributed on an "AS IS" basis, without warranty of any kind, and the -// Initial Developer hereby disclaims all such warranties, including without -// limitation, any warranties of merchantability, fitness for a particular -// purpose or non-infringement. Please see the License for the specific terms -// and conditions governing the rights and limitations under the License. - -// Modified 23/02/98 : FMN ; Remplacement PI par Standard_PI - -#define PRO9581 //GG_270298 -// Creer la grille dans un objet graphique a l'altitude 0 -// de facon a etre tracee en premier. - -// Update 14/07/98 : DCB : PRO10988 SetColorIndices() method - -#define BUC60639 //GG 15/03/00 -// -> Avoid to compute view minmax including grid origin marker. - -#include -#ifdef PRO9581 -#include -#else -#include -#endif -#include -#include - -V2d_RectangularGrid::V2d_RectangularGrid(const V2d_ViewerPointer& aViewer, - const Standard_Integer aColorIndex1, - const Standard_Integer aColorIndex2) - : Aspect_RectangularGrid(1.,1.), - myViewer(aViewer), -#ifdef PRO9581 - myGraphicObject(new V2d_BackgroundGraphicObject(aViewer->View())), -#else - myGraphicObject(new Graphic2d_GraphicObject(aViewer->View())), -#endif - myColorIndex1(aColorIndex1), - myColorIndex2(aColorIndex2) -{ - Standard_Real l = 100; - Standard_Integer n = (Standard_Integer)log10(l); - Standard_Real step = Pow(10.,Standard_Real(n))/10.; - SetXStep(step); - SetYStep(step); - Init(); -} - -void V2d_RectangularGrid::SetColorIndices (const Standard_Integer aColorIndex1, - const Standard_Integer aColorIndex2) -{ - myColorIndex1 = aColorIndex1; - myColorIndex2 = aColorIndex2; -} - -void V2d_RectangularGrid::Display() -{ - myGraphicObject->Display(); -} - -void V2d_RectangularGrid::Erase() const -{ - myGraphicObject->Erase(); -} - -void V2d_RectangularGrid::UpdateDisplay() -{ - myGraphicObject->RemovePrimitives(); - myGrid = new V2d_RectangularGraphicGrid - (myGraphicObject, - XStep(),YStep(),FirstAngle()+RotationAngle(),SecondAngle()+RotationAngle() + M_PI / 2.,XOrigin(),YOrigin(),myColorIndex2); - myGrid->SetColorIndex(myColorIndex1); - myGrid->SetDrawMode(DrawMode()); -#ifndef BUC60639 //See V2d_RectangularGraphicGrid - Handle(Graphic2d_Marker) MK1 = new Graphic2d_Marker(myGraphicObject,14,XOrigin(),YOrigin(),0.01,0.01,FirstAngle()+RotationAngle()); - Handle(Graphic2d_Marker) MK2 = new Graphic2d_Marker(myGraphicObject,14,XOrigin(),YOrigin(),0.01,0.01,SecondAngle()+RotationAngle() + M_PI / 2.); - MK1->SetColorIndex(myColorIndex2); - MK2->SetColorIndex(myColorIndex2); -#endif - -} - -Standard_Boolean V2d_RectangularGrid::IsDisplayed () const -{ - return myGraphicObject->IsDisplayed(); -} diff --git a/src/V2d/V2d_View.cdl b/src/V2d/V2d_View.cdl deleted file mode 100755 index 5cb19022c0..0000000000 --- a/src/V2d/V2d_View.cdl +++ /dev/null @@ -1,465 +0,0 @@ --- Created on: 1993-07-06 --- Created by: Jean Louis FRENKEL --- Copyright (c) 1993-1999 Matra Datavision --- Copyright (c) 1999-2012 OPEN CASCADE SAS --- --- The content of this file is subject to the Open CASCADE Technology Public --- License Version 6.5 (the "License"). You may not use the content of this file --- except in compliance with the License. Please obtain a copy of the License --- at http://www.opencascade.org and read it completely before using this file. --- --- The Initial Developer of the Original Code is Open CASCADE S.A.S., having its --- main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. --- --- The Original Code and all software distributed under the License is --- distributed on an "AS IS" basis, without warranty of any kind, and the --- Initial Developer hereby disclaims all such warranties, including without --- limitation, any warranties of merchantability, fitness for a particular --- purpose or non-infringement. Please see the License for the specific terms --- and conditions governing the rights and limitations under the License. - --- Modified: EUG - 13/11/97 -> ???????? Plotter management --- FMN - 06/01/98 -> BUC60065 --- stt: 25-02-98: S3558 ajout IfManageStandardEvent --- stt: 08-04-98: suppr IfManageStandardEvent --- dcb/syl : OCT-98 : ScreenCopy() method. --- TCL - 12-06-00 -> Pick( Xmin, Ymin, Xmax, Ymax ) method --- G002 : TCL - 03-10-00 -> new methods for setting up a background --- SAV 14/11/01 Added PickByCircle() --- SAV 24/11/01 setting background by Quantity_Color object. --- SAV 16/07/02 Added Color( Quantity_Color ) to retrieve background via RGB - - - -class View from V2d inherits View from Viewer - - ---Purpose: Defines the application object view for the 2D Viewer, - -- V2d_Viewer. The functions in this framework manage - -- the origin and the size of the scene displayed in the view (zoom, panning, etc.). - -uses - - Viewer from V2d, - TypeOfWindowResizingEffect from V2d, - ViewerPointer from V2d, - DisplayList from Graphic2d, - ViewMapping from Graphic2d, - View from Graphic2d, - GraphicObject from Graphic2d, - PickMode from Graphic2d, - Buffer from Graphic2d, - Length from Quantity, - Ratio from Quantity, - Factor from Quantity, - WindowDriver from Aspect, - FillMethod from Aspect, - TypeOfColorSpace from Aspect, - PlotterDriver from PlotMgt, - NameOfColor from Quantity, - Color from Quantity - -raises - BadValue from Viewer -is - Create( aWindowDriver: WindowDriver from Aspect; - aViewer: Viewer from V2d; - aXCenter: Length from Quantity = 0; - aYCenter: Length from Quantity = 0; - aSize: Length from Quantity = 1000) - returns mutable View from V2d; - ---Purpose: Creates a view which represents a portion of the user space. - -- This portion is defined by the point (aXCenter,aYCenter) - -- which will be represent at the center of the window and by aSize. - -- aWindowDriver defines a window and a driver. - - SetDefaultPosition(me: mutable;aXCenter: Length from Quantity = 0; - aYCenter: Length from Quantity = 0; - aSize: Length from Quantity = 1000) - ---Purpose: Defines the default position aXCenter, aYCenter and - -- the size aSize used in the Reset function. - is static; - - Fitall (me: mutable) - ---Purpose: Automatic Zoom-Panning. Objects visible in the view are - -- visualised so as to occupy the maximum amount of space - -- while respecting the initial height/width ratio. - -- Updates the view. The resulting space also takes into account a default - -- margin that can be modified with SetFitallRatio. The view is updated. - is static; - - WindowFit(me: mutable; aX1,aY1,aX2,aY2: Integer from Standard) - ---Purpose: The point of the graphic view corresponding to the - -- middle of the window aX1,aY1,aX2,aY2 (in pixel coordinates) - -- comes to the center of the window. - -- Updates the view - raises BadValue from Viewer - ---Purpose: Warning! raises BadValue from Viewer if aX1 = aX2 or aY1 = aY2; - is redefined static; - - - Fit(me: mutable; aX1,aY1,aX2,aY2: Length from Quantity;UseMinimum: Boolean from Standard = Standard_True) - ---Purpose: The point of the graphic view corresponding to the - -- middle of the window aX1,aY1,aX2,aY2 (in user coordinates) - -- comes to the center of the window. - -- If UseMinimum is true the smallest dimension of the rectangle - -- will be zoom to occupy the view. If not the greatest dimension wiil be used. - -- Updates the view - raises BadValue from Viewer - ---Purpose: Warning! raises BadValue from Viewer if aX1 = aX2 or aY1 = aY2; - is static; - - SetFitallRatio (me: mutable; aRatio: Ratio from Quantity) - ---Purpose: Sets the 10 mm default margin aRatio which is taken - -- into account by the Fitall function. - -- Exceptions - -- Viewer_BadValue if aRatio is less than 0 or greater than or equal to 1. - raises BadValue from Viewer - is static; - - Zoom (me:mutable; Zoom: Factor from Quantity) - ---Purpose: Increases the size of the portion of user-space - -- by a factor of Zoom and updates the view. - raises BadValue from Viewer - ---Purpose: Warning! raises BadValue from Viewer if aRatio <= 0. - is static; - - Zoom (me:mutable; aX1,aY1,aX2,aY2: Integer from Standard; - aCoefficient:Ratio from Quantity = 0.005 ) - ---Purpose: Increases the size of the portion of user-space by - -- a zoom factor which is calculated from the two - -- screen points aX1, aY1 and aX2, aY2 so that Z = 1/(1 + C x D) where: - -- - C is the coefficient aCoefficient and - -- - D is the distance between the two points aX1,aY1 and aX2,aY2. - is static; - - Zoom (me:mutable; aX, aY: Integer from Standard; - aCoefficient:Ratio from Quantity = 0.005 ) - ---Purpose: Increases the size of the portion of user-space by - -- a zoom factor which is calculated from the current - -- point aX,aY and the screen center. The default factor is 0.005. - is static; - - Magnify(me: mutable; anOriginView: View from V2d; - X1,Y1,X2,Y2: Integer from Standard) - ---Purpose: Defines the default view mapping from two screen - -- points in a previous view anOriginView. The view is updated. - is static; - - Translate (me:mutable; dx,dy: Length from Quantity) - ---Purpose: Translates the dx,dy center of the objects space. - is static; - - Place (me: mutable; x,y: Integer from Standard; - aZoomFactor: Factor from Quantity = 1) - ---Purpose: places the point of the view corresponding - -- at the pixel position x,y at the center of the window - -- and updates the view. - is redefined static; - - ScreenPlace (me:mutable; x,y: Length from Quantity; - aZoomFactor: Factor from Quantity = 1) - ---Purpose: Places the center of the object's space in the center - -- of the window according to the zoom factor. The view is updated. - is static; - - Pan (me:mutable; dx,dy: Integer from Standard) - - ---Purpose: Translates the center of the object's space and - -- updates the view. The translation is specified in screen coordinates. - is static; - - Convert (me; V: Integer from Standard) returns Length from Quantity - ---Purpose: Converts a screen value into the view space value V. - is static; - - Convert (me; X, Y: Integer from Standard; - ViewX, ViewY: out Length from Quantity) - ---Purpose: Converts the screen space coordinates X, Y into the - -- view space coordinates ViewX, ViewY. - is static; - - Convert (me; ViewX, ViewY: Length from Quantity; - X, Y: out Integer from Standard) - ---Purpose: Converts the view space coordinates ViewX, ViewY - -- into the screen space coordinates X, Y. - is static; - - Convert (me; aDriverSize: Length from Quantity) - ---Purpose: returns a view size from a driver size. - returns Length from Quantity - is static; - - Reset (me: mutable) - ---Purpose: Resets the viewmapping of the view and updates the view. - is static; - - Previous(me: mutable) - ---Purpose: switches the view to its previous viewmapping - -- and updates the view. - is static; - - DisableStorePrevious(me: mutable) - ---Purpose: Disables the Previous function in this framework. - is static; - - EnableStorePrevious(me: mutable) - ---Purpose: Enables the Previous function in this framework. - is static; - - Update(me) - ---Purpose: Clears the window and redraws all primitives. - is redefined static; - - - UpdateNew(me) - ---Purpose: draws the objects created since the last update. - is static; - - RestoreArea ( me ; - Xc, Yc : Integer from Standard ; - Width, Height : Integer from Standard ) - ---Purpose: Restores The Window Area defined by his center - --- and PIXEL size from the BackingStored Window - -- Warning - -- This function only works if the window is double-buffered. - is static; - - Restore(me) - ---Purpose: Restores the full window area from the backing stored window. - -- Warning - -- This function only works if the window is double-buffered. - is static; - - Dump(me) - ---Purpose: - is static; - - Dump( me; aFileName: CString from Standard ); - ---Purpose: - - --- Pick(me; X,Y, aPrecision: Integer from Standard) - Pick(me : mutable; X,Y, aPrecision: Integer from Standard) - returns DisplayList from Graphic2d - ---Purpose: From the X, Y coordinates, returns the list of picked - -- graphic objects within the precision value aPrecision. - is static; - - PickByCircle(me : mutable; X, Y, Radius: Integer from Standard) - returns DisplayList from Graphic2d - ---Purpose: - is static; - - Pick( me: mutable; Xmin, Ymin, Xmax, Ymax: Integer from Standard; - aPickMode: PickMode from Graphic2d = Graphic2d_PM_INCLUDE ) - returns DisplayList from Graphic2d; - ---Purpose: Returns the list of the picked graphic objects. - - Erase( me: mutable ) - ---Purpose: Removes all the graphic objects from the view. - is static; - - MustBeResized(me: mutable; anEffect: TypeOfWindowResizingEffect from V2d) - ---Purpose: indicates that the window in which the view is drawn has been resized - -- and updates the view. - is static; - - HasBeenMoved(me: mutable) - ---Purpose: Indicates whether the window associated with the - -- view has been moved or not. - is static; - - Plot(me; aPlotterDriver: PlotterDriver from PlotMgt; - aXCenter: Length from Quantity; - aYCenter: Length from Quantity; - aScale: Factor from Quantity=1.0) - is static; - ---Purpose: Plots the view to a plotter aPlotterDriver centered - -- through aXCenter, aYCenter with the plotting scale aScale. - - Plot(me; aPlotterDriver: PlotterDriver from PlotMgt; - aScale: Factor from Quantity=1.0) - is static; - ---Purpose: plot a view as on screen. - -- Note: if is zero then plots exactly what is on the screen - - PlotScreen(me; aPlotterDriver: PlotterDriver from PlotMgt) - ---Purpose:Plots the view to a plotter according to the current - -- size and center of the view. - is static; - - ScreenCopy (me: mutable; - aPlotterDriver : PlotterDriver from PlotMgt; - fWhiteBackground : Boolean from Standard = Standard_True; - aScale : Factor from Quantity = 1.0 - ) is static; - ---Purpose: dump the view - - PostScriptOutput(me; aFile: CString from Standard; - aWidth, aHeight: Length from Quantity; - aXCenter, aYCenter: Length from Quantity; - aScale: Factor from Quantity; - aTypeOfColorSpace: TypeOfColorSpace from Aspect) - ---Purpose: - -- Plots the view to the PostScript file aFile according to - -- a paper format specified by the arguments aWidth, - -- aHeight, aXCenter, aYCenter with the scale aScale. - is static; - - ScreenPostScriptOutput(me; aFile: CString from Standard; - aWidth, aHeight: Length from Quantity; - aTypeOfColorSpace: TypeOfColorSpace from Aspect) - ---Purpose: Plots the view to the PostScript file aFile according to - -- the paper format specified by the arguments aWidth, - -- aHeight. This is done by keeping the same view size and center. - is static; - - Hit(me; X,Y: Integer from Standard; - gx,gy: out Length from Quantity) - ---Purpose: From the X,Y point, returns the nearest point gx,gy - -- on the grid. - is static; - - ShowHit(me: mutable; X,Y: Integer from Standard) - ---Purpose: shows the point matching the grid. - -- if the hit has already been shown, it is first erased. - -- Does not update the view. - is static; - - - EraseHit(me: mutable) - ---Purpose: erases the hit point and updates the view. - is static; - - SetDefaultHighlightColor(me: mutable; aColorIndex: Integer from Standard) - is static; - ---Purpose: Defines the default override color of objects or - -- primitives using Highlight() methods. - - SetDeflection(me: mutable; aDeflection: Length from Quantity) - ---Purpose: Updates the drawing precision factor aDeflection for - -- curves and circles. - is static; - ----Category: inquire methods --- - Deflection(me) returns Length from Quantity - is static; - - ---Purpose: Returns the current deflection coefficient. - - View (me) returns mutable View from Graphic2d - ---Purpose: Returns the associated Grahic2d view with this view. - is static; - - Viewer (me) returns mutable Viewer from V2d - ---Purpose: Returns the parent viewer of this view. - is static; - - Driver(me) returns mutable WindowDriver from Aspect - ---Purpose: Returns the window driver handle associated with this view. - is static; - - Zoom(me) returns Factor from Quantity - ---Purpose: returns the current zoom factor of the view. - is static; - - Center(me; aX, aY: out Length from Quantity) - ---Purpose: returns the current point of the user space - -- being at the center of the view. - is static; - ---Category: private methods: - - Size(me) returns Length from Quantity - is static; - - ---Purpose: Returns the current size of the view. - - Color(me) returns NameOfColor from Quantity - ---Purpose: returns the background color of the view. - is static; - - Color(me; color : out Color from Quantity) - ---Purpose: returns the background color of the view. - is static; - - Scroll(me: mutable; XCenter,YCenter,DX,DY: out Integer from Standard) - is static; - - StoreCurrent(me: mutable) - ---Purpose: - is static private; - - MapToCenter(me: mutable) - ---Purpose: - is static private; - - DefaultHighlightColor(me) - returns Integer from Standard is static; - ---Purpose: Returns the default override color of objects or - -- primitives using Highlight() methods. - -- Warning: Returns -1 when the color index is not defined. - ----Category: compatibility. - - Fit(me: mutable; aX1,aY1,aX2,aY2: Integer from Standard) - ---Purpose: idem than WindowFit - is static; - -------------------------------------------------------------------------- ----Category: Methods to modify the background of this view -------------------------------------------------------------------------- - - SetBackground( me: mutable; aNameColor: NameOfColor from Quantity ); - ---Level: Public - ---Purpose: Defines the color of view's background - - SetBackground( me: mutable; color: Color from Quantity ); - ---Level: Public - ---Purpose: Defines the color of view's background - - SetBackground( me: mutable; - aNameFile: CString from Standard; - aMethod: FillMethod from Aspect = Aspect_FM_CENTERED ) - returns Boolean from Standard; - ---Level: Public - ---Purpose: Loads the view background from an image file - -- defined with a supported format XWD,GIF or BMP - -- and returns TRUE if the operation is successfull. - --------------------------------------------------------------------------- - -fields - - myWindowDriver: WindowDriver from Aspect; - myViewer: ViewerPointer from V2d; - myFitallRatio: Real from Standard; - myDeflection: Real from Standard; - myViewMapping: ViewMapping from Graphic2d; - --- MapTo definition: - - myXPosition: Real from Standard; - myYPosition: Real from Standard; - myScale: Real from Standard; - --- Previous Position: - - myPreviousX: Real from Standard; - myPreviousY: Real from Standard; - myPreviousSize: Real from Standard; - myPreviousXPosition: Real from Standard; - myPreviousYPosition: Real from Standard; - myPreviousScale: Real from Standard; - myEnablePrevious: Boolean from Standard; - myHitPoint: GraphicObject from Graphic2d; - myHitBuf: Buffer from Graphic2d; --- Current window size: - - myWidth: Real from Standard; - myHeight: Real from Standard; - --- scrolling managment. - pxmin,pymin,pxmax,pymax: Real from Standard; - -end View from V2d; diff --git a/src/V2d/V2d_View.cxx b/src/V2d/V2d_View.cxx deleted file mode 100755 index ac1ce8e5e6..0000000000 --- a/src/V2d/V2d_View.cxx +++ /dev/null @@ -1,1015 +0,0 @@ -// Copyright (c) 1999-2012 OPEN CASCADE SAS -// -// The content of this file is subject to the Open CASCADE Technology Public -// License Version 6.5 (the "License"). You may not use the content of this file -// except in compliance with the License. Please obtain a copy of the License -// at http://www.opencascade.org and read it completely before using this file. -// -// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its -// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. -// -// The Original Code and all software distributed under the License is -// distributed on an "AS IS" basis, without warranty of any kind, and the -// Initial Developer hereby disclaims all such warranties, including without -// limitation, any warranties of merchantability, fitness for a particular -// purpose or non-infringement. Please see the License for the specific terms -// and conditions governing the rights and limitations under the License. - -/*********************************************************************** - - FUNCTION : - ---------- - Classe V2d_View : - - HISTORY OF MODIFICATIONS : - -------------------------------- - 00-09-92 : GG ; Creation. - 13-11-97 : EUG ; ???????? New method Plot(...) - 06-01-98 : FMN ; BUC60065 - 20-02-98 : STT ; S3558 - 08-04-98 : STT ; suppr. S3558 - 24-03-98 : GG ; ?????? UseMFT() - 26-03-98 : GG ; BUC60049 Add conversion method - View space -> Window pixel space - 04-05-98 : GG ; PS driver PS is also usable under WNT - 21-07-98 : DCB/SYL: Remove useless calls to SetXXXMap() methods - in PlotScreen (). - OCT-98 : DCB/SYL : ScreenCopy() method. - 12-06-00 : TCL : new method Pick( Xmin, Ymin, Xmax, Ymax ) - 03-10-00 : TCL : new methods SetBackground(...) - 14-11-01 : SAV : Added PickByCircle(). - 24-11-01 : SAV : SetBackground(...) overloaded. - - NOTES : - ----------- - -************************************************************************/ - -#define TRACE 0 - -#define PRO16111 //GG_021198 -// Correction of method Fitall() that was wrong if -// the window height was superior to the width - -#define BUC60611 //VTN_291198 -// Re change Fitall() computation method - -#define IMP130300 //GG OPTIMIZATION The V2d_View::UpdateNew() method MUST use -// Graphic2d_View::TinyUpdate() and no more Update() - -#define JAP60249 //GG_131098 -// Plots the view accordingly with the requested view center - -#define IMP250500 //GG Update() the view after creation -// the driver of the view must be known before -// any minmax computation. - -#define OCC540 //SAV Add Color( Quantity_Color& ) to retrieve background via RGB - -/*----------------------------------------------------------------------*/ -/* - * Includes - */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -// S3603 - ScreenCopy () -#include -#include -#include -#include -#include -#include - -//OCC186 -#include -#include -//OCC186 - -V2d_View::V2d_View(const Handle(Aspect_WindowDriver)& aWindowDriver, - const Handle(V2d_Viewer)& aViewer, - const Standard_Real aXCenter, - const Standard_Real aYCenter, - const Standard_Real aSize) - -: myWindowDriver(aWindowDriver) , - myViewer(aViewer.operator->()), - myFitallRatio (0.01) , - myHitPoint(new Graphic2d_GraphicObject(aViewer->View())), - myHitBuf(new Graphic2d_Buffer(aViewer->View(),0.,0.)) -{ - - myViewMapping = new Graphic2d_ViewMapping; - myViewMapping->SetViewMapping(aXCenter,aYCenter,aSize); - myViewMapping->SetViewMappingDefault(); - myWindowDriver->WorkSpace(myWidth,myHeight); - this->MapToCenter(); - myEnablePrevious = Standard_True; - this->StoreCurrent(); - myDeflection = 0.0001 METER; // 10th of millimeter at the screen. - - aWindowDriver->SetColorMap(aViewer->ColorMap()); - aWindowDriver->SetWidthMap(aViewer->WidthMap()); - aWindowDriver->SetTypeMap (aViewer->TypeMap()); - aWindowDriver->SetFontMap (aViewer->FontMap(),aViewer->UseMFT()); - aWindowDriver->SetMarkMap (aViewer->MarkMap()); - aViewer->AddView(this); -#ifdef IMP250500 - Update(); -#endif -} -void V2d_View::SetDefaultPosition(const Standard_Real aXCenter, - const Standard_Real aYCenter, - const Standard_Real aSize) { - - myViewMapping->SetViewMapping(aXCenter,aYCenter,aSize); - myViewMapping->SetViewMappingDefault(); - this->MapToCenter(); - this->StoreCurrent(); -} -void V2d_View::Fitall() { - - this->StoreCurrent(); - this->MapToCenter(); - - Quantity_Ratio rat = myWindowDriver->Window()->Ratio(); - - Quantity_Length XVMin,YVMin,XVMax,YVMax; - myViewer->View()->MinMax(XVMin,XVMax,YVMin,YVMax); - if(XVMin < ShortRealFirst() + 1. || YVMin < ShortRealFirst() + 1.) { - XVMin = ShortRealLast(); YVMin = ShortRealLast(); // Minmax are crossed, as - XVMax = ShortRealFirst();YVMax = ShortRealFirst(); // CAL does not do it!!!!!!!!!!!! - } - - Quantity_Length XMMin,YMMin,XMMax,YMMax; - myViewer->View()->MarkerMinMax(XMMin,XMMax,YMMin,YMMax); - if(XMMin < ShortRealFirst() + 1. || YMMin < ShortRealFirst() + 1.) { - XMMin = ShortRealLast(); YMMin = ShortRealLast(); // Minmax are crossed, because - XMMax = ShortRealFirst();YMMax = ShortRealFirst(); // CAL does not do it !!!!!!!!!!!! - } - - Quantity_Length XMin = Min(XVMin,XMMin),YMin= Min(YVMin,YMMin), - XMax = Max(XVMax,XMMax),YMax= Max(YVMax,YMMax); - - Quantity_Length Xold,Yold,Sizeold; - myViewMapping->ViewMapping(Xold,Yold,Sizeold); - -#ifdef PRO16111 - Quantity_Length Xnew = Xold,Ynew = Yold,Sizenew = Sizeold; - Quantity_Length Dxnew = Sizeold, Dynew = Sizeold; - if( XMax > XMin ) { - Dxnew = XMax - XMin; - Xnew = (XMax+XMin)/2.; - } - if( YMax > YMin ) { - Dynew = YMax - YMin; - Ynew = (YMax+YMin)/2.; - } - if( rat >= 1. ) { -#ifdef BUC60611 - if( Dxnew >= Dynew*rat ) Sizenew = Dxnew/2./rat; -#else - if( Dxnew >= Dynew ) Sizenew = Dxnew/2./rat; -#endif - else Sizenew = Dynew/2.; - } else { -#ifdef BUC60611 - if( Dynew >= Dxnew/rat ) Sizenew = Dynew/2.*rat; - else Sizenew = Dxnew/2; -#else - if( Dxnew >= Dynew ) Sizenew = Dxnew/2.; - else Sizenew = Dynew/2.*rat; -#endif - } - Sizenew += Sizenew * myFitallRatio; -#else - Quantity_Length Xnew,Ynew,Sizenew; - if ( XMin < XMax ) { - Xnew = (XMax+XMin)/2.; - Sizenew = (XMax-XMin)/(1. - myFitallRatio)/2./rat; - } - else { - Xnew = Xold; - Sizenew = Sizeold; - } - - if ( YMin < YMax ) { - Ynew = (YMax+YMin)/2.; - Sizenew = Max ( Sizenew , (YMax-YMin)/(1. - myFitallRatio)/2.); - } - else { - Ynew = Yold; - Sizenew = Max ( Sizenew , Sizeold); - } -#endif - - myViewMapping->SetViewMapping( Xnew ,Ynew , Sizenew); - ImmediateUpdate(); -} - -void V2d_View::WindowFit(const Standard_Integer aX1, - const Standard_Integer aY1, - const Standard_Integer aX2, - const Standard_Integer aY2) { - Fit(aX1,aY1,aX2,aY2); -} - -void V2d_View::Fit(const Standard_Integer aX1, - const Standard_Integer aY1, - const Standard_Integer aX2, - const Standard_Integer aY2) { - - if( aX1 != aX2 && aY1 != aY2 ) { - this->MapToCenter(); - Standard_Real x1,y1,x2,y2,xx1,yy1,xx2,yy2; - myWindowDriver->Convert(aX1,aY1,xx1,yy1); - myWindowDriver->Convert(aX2,aY2,xx2,yy2); - myViewer->View()->Convert(myViewMapping,xx1,yy1,myXPosition,myYPosition,myScale,x1,y1); - myViewer->View()->Convert(myViewMapping,xx2,yy2,myXPosition,myYPosition,myScale,x2,y2); - Fit(x1,y1,x2,y2,Standard_False); - } -} -void V2d_View::Fit(const Quantity_Length aX1, - const Quantity_Length aY1, - const Quantity_Length aX2, - const Quantity_Length aY2, - const Standard_Boolean UseMinimum) { - - Viewer_BadValue_Raise_if( aX1 == aX2 || aY1 == aY2 ,"coordinates are confused"); - this->StoreCurrent(); - Quantity_Ratio rat = myWindowDriver->Window()->Ratio(); - Quantity_Length XCenter, YCenter, Size; - XCenter = (aX1+aX2)/2.; YCenter = (aY1+aY2)/2.; - if (UseMinimum) - Size = Abs(aX2-aX1)/rat < Abs(aY2-aY1) ? Abs(aX2-aX1)/rat : Abs(aY2-aY1); - else - Size = Abs(aX2-aX1)/rat > Abs(aY2-aY1) ? Abs(aX2-aX1)/rat : Abs(aY2-aY1); - - myViewMapping->SetViewMapping(XCenter,YCenter,Size/2.); -//OCC186 - try { - ImmediateUpdate(); - } - catch (Standard_NumericError) { - cout << "Exception caught during view Fit. " << endl; - } -//OCC186 -} - -void V2d_View::SetFitallRatio (const Standard_Real aRatio) { - - Viewer_BadValue_Raise_if( aRatio < 0 || aRatio >=1 , - "ratio must be more than 0. and less than 1."); - myFitallRatio = aRatio; - -} -void V2d_View::Zoom (const Standard_Real Zoom) { - Viewer_BadValue_Raise_if(Zoom <= 0., "Zoom coefficient must be greater than 0."); - this->StoreCurrent(); - Quantity_Length XCenter, YCenter, Size; - - myViewMapping->ViewMapping(XCenter, YCenter, Size); - myViewMapping->SetViewMapping(XCenter,YCenter,Size/Zoom); - -//OCC186 - try { - ImmediateUpdate(); - } - catch (Standard_NumericError) { - cout << "Exception caught during zooming! Zooming factor is too big." << endl; - } -//OCC186 -} - -void V2d_View::Zoom (const Standard_Integer aX1, - const Standard_Integer aY1, - const Standard_Integer aX2, - const Standard_Integer aY2, - const Quantity_Ratio aCoefficient) { - Standard_Real D = Abs(aX1-aX2) >= Abs(aY1-aY2) ? aX1-aX2 : aY2-aY1; - this->Zoom ( D > 0 ? ( 1. /(1. + aCoefficient * Abs(D))) - : (1. + aCoefficient * Abs(D))); -} - -void V2d_View::Zoom (const Standard_Integer aX, - const Standard_Integer aY, - const Quantity_Ratio aCoefficient) { - - Standard_Integer Width, Height; - myWindowDriver->Window()->Size(Width, Height); - this->Zoom(Width/2,Height/2,aX,aY,aCoefficient); -} -void V2d_View::Magnify(const Handle(V2d_View)& anOriginView, - const Standard_Integer X1, - const Standard_Integer Y1, - const Standard_Integer X2, - const Standard_Integer Y2) { - Standard_Real x1,y1,x2,y2; - anOriginView->Convert(X1,Y1,x1,y1); - anOriginView->Convert(X2,Y2,x2,y2); - myViewMapping->SetViewMapping((x1+x2)/2.,(y1+y2)/2.,Max(x2-x1,y2-y1)/2.); - myViewMapping->SetViewMappingDefault(); -//OCC186 - try { - ImmediateUpdate(); - } - catch (Standard_NumericError) { - cout << "Exception caught during view Magnify. " << endl; - } -//OCC186 -} - -void V2d_View::Translate (const Quantity_Length dx, const Quantity_Length dy) { - - this->StoreCurrent(); - - Quantity_Length XCenter, YCenter; - myViewMapping->Center(XCenter, YCenter); - myViewMapping->SetCenter(XCenter+dx,YCenter+dy); - -} - -void V2d_View::Place (const Standard_Integer x, const Standard_Integer y, - const Quantity_Length aZoomFactor) { - Quantity_Length xx,yy; - this->Convert(x,y,xx,yy); - this->ScreenPlace(xx,yy,aZoomFactor); -} -void V2d_View::ScreenPlace (const Quantity_Length x, const Quantity_Length y, - const Quantity_Factor aZoomFactor) { - - this->StoreCurrent(); - myViewMapping->SetCenter(x,y); - Zoom(aZoomFactor/Zoom()); -} -void V2d_View::Pan (const Standard_Integer dx, const Standard_Integer dy) { - - Standard_Real x,y; - x = myWindowDriver->Convert(dx); - y = myWindowDriver->Convert(dy); - Standard_Real xx,yy; - xx = myViewer->View()->Convert(myViewMapping,x,myScale); - yy = myViewer->View()->Convert(myViewMapping,y,myScale); - this->Translate(-xx,-yy); - ImmediateUpdate(); -} - -Quantity_Length V2d_View::Convert(const Standard_Integer V) const { - - return myViewer->View()->Convert(myViewMapping,myWindowDriver->Convert(V),myScale); -} - -void V2d_View::Convert (const Standard_Integer X, const Standard_Integer Y, - Quantity_Length& ViewX, Quantity_Length& ViewY) - const { - - Standard_Real xx,yy; - myWindowDriver->Convert(X,Y,xx,yy); - myViewer->View()->Convert(myViewMapping,xx,yy,myXPosition,myYPosition,myScale, - ViewX,ViewY); -} - -void V2d_View::Convert (const Quantity_Length ViewX, const Quantity_Length ViewY, Standard_Integer& X, Standard_Integer &Y) - const { - - Standard_Real XCenter,YCenter,Size; - myViewMapping->ViewMapping(XCenter,YCenter,Size); - Standard_Real x = myXPosition + ((ViewX-XCenter)/Size) *myScale; - Standard_Real y = myYPosition + ((ViewY-YCenter)/Size) *myScale; - myWindowDriver->Convert(x,y,X,Y); -} - -Quantity_Length V2d_View::Convert(const Quantity_Length DriverSize) const { - Quantity_Length X,Y,S; - myViewMapping->ViewMapping(X,Y,S); - return DriverSize / myScale * S; -} - -void V2d_View::Reset () { - - this->StoreCurrent(); - this->MapToCenter(); - myViewMapping->ViewMappingReset(); - ImmediateUpdate(); -} - -Handle(Graphic2d_View) V2d_View::View () const {return myViewer->View();} - -Handle(V2d_Viewer) V2d_View::Viewer () const {return myViewer;} - -Handle(Aspect_WindowDriver) V2d_View::Driver() const {return myWindowDriver;} - -void V2d_View::Update() const { - -//Augustin myWindowDriver->Window()->Clear(); -// EraseHit(); - Quantity_Length XCenter, YCenter, Size; - myViewer->View()->SetTypeOfDeflection(Aspect_TOD_ABSOLUTE); - myViewMapping->ViewMapping(XCenter, YCenter, Size); - myViewer->View()->SetDeflection(myDeflection*Size/myScale); - myViewer->View()->Update(myWindowDriver,myViewMapping,myXPosition,myYPosition,myScale);} - -void V2d_View::UpdateNew() const { - -#ifdef IMP130300 - myViewer->View()->TinyUpdate(myWindowDriver,myViewMapping,myXPosition,myYPosition,myScale,Standard_True); -#else - myViewer->View()->Update(myWindowDriver,myViewMapping,myXPosition,myYPosition,myScale,Standard_False); -#endif -} -void V2d_View::Restore() const { - - if(myWindowDriver->Window()->BackingStore()) - myWindowDriver->Window()->Restore(); - else - this->Update(); - } - -void V2d_View::RestoreArea (const Standard_Integer Xc, - const Standard_Integer Yc, - const Standard_Integer Width, - const Standard_Integer Height) const { - - if(myWindowDriver->Window()->BackingStore()) - myWindowDriver->Window()->RestoreArea(Xc,Yc,Width,Height); - else - this->Update(); - } - -void V2d_View::Dump() const { - //myView->Update(new V2d_DumpDriver); -} - -void V2d_View::Dump( const Standard_CString aFileName) const { - myWindowDriver->Window()->Dump(aFileName); -} - -Handle(Graphic2d_DisplayList) V2d_View::Pick ( - const Standard_Integer X, - const Standard_Integer Y, - const Standard_Integer aPrecision) { - - Standard_Real x,y,xx,yy,prec; - myWindowDriver->Convert(X,Y,xx,yy); - prec = myViewer->View()->Convert(myViewMapping, - myWindowDriver->Convert(aPrecision), - myScale); - myViewer->View()->Convert(myViewMapping,xx,yy,myXPosition,myYPosition,myScale,x,y); - return myViewer->View()->Pick(myViewMapping,x,y,prec,myXPosition,myYPosition,myScale); -} - -//SAV -Handle(Graphic2d_DisplayList) V2d_View::PickByCircle( const Standard_Integer X, - const Standard_Integer Y, - const Standard_Integer Radius ) -{ - Standard_Real x, y, xx, yy, radius; - myWindowDriver->Convert(X,Y,xx,yy); - radius = myViewer->View()->Convert( myViewMapping, - myWindowDriver->Convert( Radius ), - myScale ); - myViewer->View()->Convert( myViewMapping, - xx,yy, myXPosition, myYPosition, myScale, x, y ); - return myViewer->View()->PickByCircle( myViewMapping, x, y, radius, - myXPosition, myYPosition, myScale ); -} - -Handle(Graphic2d_DisplayList) V2d_View::Pick ( - const Standard_Integer Xmin, - const Standard_Integer Ymin, - const Standard_Integer Xmax, - const Standard_Integer Ymax, - const Graphic2d_PickMode aPickMode ) { - - Standard_Real x1, y1, xx1, yy1, x2, y2, xx2, yy2; - myWindowDriver->Convert( Xmin, Ymin, xx1, yy1 ); - myWindowDriver->Convert( Xmax, Ymax, xx2, yy2 ); - - myViewer->View()->Convert( myViewMapping, xx1, yy1, myXPosition, myYPosition, myScale, x1, y1 ); - myViewer->View()->Convert( myViewMapping, xx2, yy2, myXPosition, myYPosition, myScale, x2, y2 ); - - return myViewer->View()->Pick( myViewMapping, x1, y1, x2, y2, myXPosition, myYPosition, myScale, aPickMode ); -} - -void V2d_View::Erase () { - myViewer->View()->Erase(); -} - -void V2d_View::HasBeenMoved() { - - myWindowDriver->ResizeSpace(); -} - -void V2d_View::MustBeResized(const V2d_TypeOfWindowResizingEffect anEffect) { - - Standard_Real OldWidth = myWidth, OldHeight = myHeight; - Aspect_TypeOfResize TOR = myWindowDriver->ResizeSpace(); - myWindowDriver->WorkSpace(myWidth,myHeight); - - switch (anEffect) { - - case V2d_TOWRE_ENLARGE_SPACE: { - switch (TOR) { - case Aspect_TOR_UNKNOWN : break; - case Aspect_TOR_NO_BORDER : break; - case Aspect_TOR_TOP_BORDER : break; - case Aspect_TOR_RIGHT_BORDER : break; - case Aspect_TOR_BOTTOM_BORDER : - myYPosition = myHeight - OldHeight + myYPosition; - break; - case Aspect_TOR_LEFT_BORDER : - myXPosition = myWidth - OldWidth + myXPosition; - break; - case Aspect_TOR_TOP_AND_RIGHT_BORDER : break; - case Aspect_TOR_RIGHT_AND_BOTTOM_BORDER : - myYPosition = myHeight - OldHeight + myYPosition; - break; - case Aspect_TOR_BOTTOM_AND_LEFT_BORDER : - myXPosition = myWidth - OldWidth + myXPosition; - myYPosition = myHeight - OldHeight + myYPosition; - break; - case Aspect_TOR_LEFT_AND_TOP_BORDER: - myXPosition = myWidth - OldWidth + myXPosition; - break; - } - break; - } - case V2d_TOWRE_ENLARGE_OBJECTS:{ - - this->MapToCenter(); - break; - } - } - this->StoreCurrent(); - ImmediateUpdate(); -} - -void V2d_View::SetDefaultHighlightColor(const Standard_Integer aColorIndex) { - - myViewer->View()->SetDefaultOverrideColor(aColorIndex); - -} - -#define SCREENCOPY_FILENAME "screencopy2d.gif" -#define NO_HILIGHT 0xFFFFFF -void V2d_View::ScreenCopy (const Handle(PlotMgt_PlotterDriver)& aPlotterDriver, - const Standard_Boolean fWhiteBackground, - const Quantity_Factor aPlotScale) -{ - int i ; - TCollection_AsciiString aFileToDump; - Quantity_Factor aScale; - Quantity_Length thePixel; - Quantity_Parameter theWWidth, theWHeight; - Quantity_Parameter thePWidth, thePHeight; - Quantity_Length aViewX, aViewY, aViewSize; - aPlotterDriver -> WorkSpace (thePWidth, thePHeight); - myWindowDriver -> WorkSpace (theWWidth, theWHeight); - myViewMapping -> ViewMapping (aViewX, aViewY, aViewSize); - thePixel = myWindowDriver -> Convert (1); - - if (theWWidth * theWHeight != 0.) { - if (aPlotScale == 0.) { - aScale = Min (thePWidth / theWWidth, thePHeight / theWHeight); - } else { - aScale = aPlotScale; - aScale *= (aViewSize / theWWidth); - } - Quantity_Length aPlotX, aPlotY; - aPlotX = theWWidth /2. * aScale; - aPlotY = theWHeight /2. * aScale; - - // Set default maps (color, type, etc.) for plotter driver - aPlotterDriver -> SetColorMap ( new Aspect_GenericColorMap () ); - aPlotterDriver -> SetTypeMap ( new Aspect_TypeMap () ); - aPlotterDriver -> SetWidthMap ( new Aspect_WidthMap () ); - aPlotterDriver -> SetFontMap ( new Aspect_FontMap () ); - aPlotterDriver -> SetMarkMap ( new Aspect_MarkMap () ); - myViewer -> View() -> SetTypeOfDeflection (Aspect_TOD_ABSOLUTE); - myViewer -> View() -> SetDeflection (myDeflection); - - // Set backgroung to white, unihiglight if any - Handle(TColStd_HSequenceOfInteger) theColors; - Handle(Graphic2d_DisplayList) theDisplayList; - Aspect_Background theBack = myWindowDriver->Window()->Background(); - if (fWhiteBackground) - myWindowDriver -> Window() -> SetBackground (Quantity_NOC_WHITE); - theDisplayList = myViewer -> View() -> DisplayList(); - theColors = new TColStd_HSequenceOfInteger (); - for ( i = 1; i <= theDisplayList -> Length(); i++) { - if (theDisplayList -> Value(i) -> IsHighlighted()) { - theColors -> Append (theDisplayList -> Value(i) -> OverrideColor()); - theDisplayList -> Value(i) -> Display(); - } else { - theColors -> Append (NO_HILIGHT); - } - } - Update (); - - // Dump the view - if (aPlotterDriver->IsKind(STANDARD_TYPE(PlotMgt_ImageDriver))) { - aFileToDump = aPlotterDriver->PlotFileName(); - } else { - aFileToDump = aPlotterDriver->SpoolDirectory(); - aFileToDump += SCREENCOPY_FILENAME; - } - myWindowDriver -> Window() -> Dump (aFileToDump.ToCString()); - - // Return background and highlight if any - for (i = 1; i <= theDisplayList -> Length(); i++) - if (theColors -> Value(i) != NO_HILIGHT) - theDisplayList -> Value(i) -> Highlight(theColors -> Value(i)); - if (fWhiteBackground) - myWindowDriver -> Window() -> SetBackground (theBack); - Update (); - - // Draw imagefile by plotter driver - aPlotterDriver -> SetPixelSize (thePixel); - aPlotterDriver -> BeginDraw (); - aPlotterDriver -> DrawImageFile ( - aFileToDump.ToCString(), (float)aPlotX, (float)aPlotY, aScale); - aPlotterDriver -> EndDraw (); - } -} -#undef NO_HILIGHT -#undef SCREENCOPY_FILENAME - -void V2d_View::Plot(const Handle(PlotMgt_PlotterDriver)& aPlotterDriver, - const Quantity_Length aXCenter, - const Quantity_Length aYCenter, - const Quantity_Factor aPlotScale) const -{ - Quantity_Length PaperWidth,PaperHeight; - - aPlotterDriver->SetColorMap(myWindowDriver->ColorMap()); - aPlotterDriver->SetTypeMap(myWindowDriver->TypeMap()); - aPlotterDriver->SetWidthMap(myWindowDriver->WidthMap()); - aPlotterDriver->SetFontMap(myWindowDriver->FontMap(),myWindowDriver->UseMFT()); - aPlotterDriver->SetMarkMap(myWindowDriver->MarkMap()); - myViewer->View()->SetTypeOfDeflection(Aspect_TOD_ABSOLUTE); - myViewer->View()->SetDeflection(myDeflection); - - aPlotterDriver->WorkSpace (PaperWidth,PaperHeight); - // size of the map to force set the required size - Quantity_Length aViewX , aViewY , aViewSize; - myViewMapping -> ViewMapping ( aViewX, aViewY, aViewSize ); - Quantity_Factor aScale = aViewSize * aPlotScale; - - Quantity_Length aPlotX , aPlotY; -#ifdef JAP60249 -//printf(" V2d_View::Plot(%f,%f,%f,%f,%f,%f,%f)\n",PaperWidth,PaperHeight,aXCenter,aYCenter,aPlotScale,aViewSize,aScale); - Handle(Graphic2d_ViewMapping) myPlotMapping = new Graphic2d_ViewMapping; - myPlotMapping->SetViewMapping(aXCenter,aYCenter,aViewSize); - aPlotX = /*aPlotScale * */PaperWidth/2.; - aPlotY = /*aPlotScale * */PaperHeight/2.; - myViewer->View()->Update(aPlotterDriver,myPlotMapping,aPlotX,aPlotY,aScale); -#else - // to place the bottom view to the left of the list and not in the middle - if (myWidth < myHeight ){ - aPlotX = aViewSize*aPlotScale; - aPlotY = aPlotX*myHeight/myWidth; - if (PaperWidth > PaperHeight) - aPlotX *= 2.; - } else { - aPlotY = aViewSize*aPlotScale; - aPlotX = aPlotY*myWidth/myHeight; - if (PaperWidth < PaperHeight) - aPlotY *= 2.; - } - - myViewer->View()->Update(aPlotterDriver,myViewMapping,aPlotX,aPlotY,aScale); -#endif - -#if TRACE > 0 - // info size paper - cout << "V2d_View::Plot(Driver,centre X,Y,scale):CenterX" << aViewX << " Y " << aViewY << " Size=" << aViewSize - << " ViewPosX=" << myXPosition << " ViewPosY=" << myYPosition - << " VueX=" << myWidth << " VueY=" << myHeight - << " PlotX=" << PaperWidth << " PlotY=" << PaperHeight - << " PlotScale=" << aPlotScale - << " PosX=" << aPlotX << " Posy=" << aPlotY << " Scale " << aScale - << endl ; -#endif -} - -void V2d_View :: Plot ( - const Handle( PlotMgt_PlotterDriver )& aDriver, - const Quantity_Factor aScale - ) const { -#if TRACE > 0 - cout << "V2d_View::Plot(driver,scale) scale=" << aScale << endl ; -#endif - Plot( aDriver, (Quantity_Length) 0., (Quantity_Length) 0., aScale); -} - -void V2d_View::PostScriptOutput(const Standard_CString aFile, - const Quantity_Length aWidth, - const Quantity_Length aHeight, - const Quantity_Length aXCenter, - const Quantity_Length aYCenter, - const Quantity_Factor aScale, - const Aspect_TypeOfColorSpace aTypeOfColorSpace) - const { - Handle(PS_Driver) aPSDriver = new PS_Driver(aFile,aWidth,aHeight,aTypeOfColorSpace); -// if(aTypeOfColorSpace != PS_TOCS_BlackAndWhite) -// aPSDriver->SetColorMap(myWindowDriver->ColorMap()); - Plot(aPSDriver,aXCenter,aYCenter,aScale); -} - -void V2d_View::PlotScreen(const Handle(PlotMgt_PlotterDriver)& aPlotterDriver) const { - - // recuperate size paper - Quantity_Length PaperWidth,PaperHeight; - aPlotterDriver->WorkSpace(PaperWidth,PaperHeight); - - // Determination size to fit all in the paper - Quantity_Length aViewX , aViewY , aViewSize; - Quantity_Length aViewSizeX , aViewSizeY; - Quantity_Length aPlotX , aPlotY; - Standard_Real aPlotScale; - myViewMapping -> ViewMapping ( aViewX, aViewY, aViewSize ); - if (myWidth < myHeight ){ - aViewSizeX = aViewSize; - aViewSizeY = aViewSizeX*myHeight/myWidth; - }else { - aViewSizeY = aViewSize; - aViewSizeX = aViewSizeY*myWidth/myHeight; - } - aPlotX = PaperWidth /2./aViewSizeX; - aPlotY = PaperHeight/2./aViewSizeY; - aPlotScale = (aPlotX < aPlotY ? aPlotX : aPlotY ); - - Quantity_Length aXCenter, aYCenter; - this->Center(aXCenter, aYCenter); - -#if TRACE > 0 - cout << "V2d_View::PlotScreen(Driver):Centre X=" << aViewX << " Y=" << aViewY << " Size=" << aViewSize - << " SizeX=" << aViewSizeX << " Y=" << aViewSizeY - << " PlotX=" << PaperWidth << " Y=" << PaperHeight - << " PlotScaleX=" << aPlotX << " Y=" << aPlotY - << " => PlotScale=" << aPlotScale - << endl ; -#endif - - this->Plot(aPlotterDriver,aXCenter,aYCenter,aPlotScale); - -} - -void V2d_View::ScreenPostScriptOutput(const Standard_CString aFile, - const Quantity_Length aWidth, - const Quantity_Length aHeight, - const Aspect_TypeOfColorSpace aTypeOfColorSpace) - const { - Handle(PS_Driver) aPSDriver = new PS_Driver(aFile,aWidth,aHeight,aTypeOfColorSpace); -// if(aTypeOfColorSpace != PS_TOCS_BlackAndWhite) -// aPSDriver->SetColorMap(myWindowDriver->ColorMap()); - PlotScreen(aPSDriver); -} - - -void V2d_View::StoreCurrent () { - - if(myEnablePrevious) { - - myViewMapping->ViewMapping(myPreviousX,myPreviousY,myPreviousSize); - myPreviousXPosition = myXPosition; - myPreviousYPosition = myYPosition; - myPreviousScale = myScale; - } - -} -void V2d_View::Previous () { - - if(myEnablePrevious) { - Standard_Real x,y,s,a,b,c; - x = myPreviousX; - y = myPreviousY; - s = myPreviousSize; - a = myPreviousXPosition; - b = myPreviousYPosition; - c = myPreviousScale; - this->StoreCurrent(); - myViewMapping->SetViewMapping(x,y,s); - myXPosition = a; - myYPosition = b; - myScale = c; - } - ImmediateUpdate(); -} -void V2d_View::SetDeflection (const Quantity_Length aDeflection) { - - myDeflection = aDeflection; - -} - -Quantity_Length V2d_View::Deflection() const { - - return myDeflection; -} - -void V2d_View::EnableStorePrevious () {myEnablePrevious = Standard_True;} - -void V2d_View::DisableStorePrevious () { - -this->StoreCurrent(); -myEnablePrevious = Standard_False;} - - -void V2d_View::MapToCenter () { - - myXPosition = myWidth /2.; - myYPosition = myHeight /2.; - myScale = ( (myWidthZoom(); -} - -void V2d_View::Center (Quantity_Length& aX, Quantity_Length& aY) const { - myViewMapping->Center(aX,aY); -} - -Quantity_Length V2d_View::Size() const { - Quantity_Length XCenter, YCenter, Size; - myViewMapping->ViewMapping(XCenter, YCenter, Size); - return Size; -} - -Quantity_NameOfColor V2d_View::Color () const { - return myWindowDriver->Window()->Background().Color().Name(); -} - -void V2d_View::Color( Quantity_Color& color ) const -{ -#ifdef OCC540 - color.Assign( myWindowDriver->Window()->Background().Color() ); -#endif -} - -void V2d_View::Hit(const Standard_Integer X, - const Standard_Integer Y, - Quantity_Length& gx, - Quantity_Length& gy) const { - - Standard_Real rx,ry; - Convert(X,Y,rx,ry); - myViewer->Hit(rx,ry,gx,gy); -} - -void V2d_View::ShowHit(const Standard_Integer X, - const Standard_Integer Y) { - Standard_Real rx,ry,gx,gy; - Convert(X,Y,rx,ry); - myViewer->Hit(rx,ry,gx,gy); - - myHitPoint->RemovePrimitives(); - Handle(Graphic2d_Marker) - M = new Graphic2d_Marker(myHitPoint, - myViewer->HitPointMarkerIndex(), - gx,gy, - 0.002 METER,0.002 METER); - M->SetColorIndex(myViewer->HitPointColor()); - - - Standard_Real HitTextX,HitTextY; - myViewer->View()->Convert(myViewMapping,0.,0.,myXPosition,myYPosition,myScale,HitTextX,HitTextY); - Handle(Graphic2d_Text) - T1 = new Graphic2d_Text(myHitPoint, - TCollection_ExtendedString(gx), - HitTextX,HitTextY,0.); - T1->SetColorIndex(myViewer->CoordinatesColor()); - T1->SetOffset(0. METER,0.005 METER); - T1->SetZoomable(Standard_False); //BUC50093 - Handle(Graphic2d_Text) - T2 = new Graphic2d_Text(myHitPoint, - TCollection_ExtendedString(gy), - HitTextX,HitTextY,0.); - T2->SetColorIndex(myViewer->CoordinatesColor()); - T2->SetZoomable(Standard_False); //BUC50093 -//if(myHitPoint->IsDisplayed()) myHitPoint->Erase(); -//myHitPoint->Display(); - if(myHitBuf->IsPosted()) myHitBuf->UnPost(); - myHitBuf->Clear(); - myHitBuf->Add(myHitPoint); - myHitBuf->Post(); -} - -void V2d_View::EraseHit() { -// if(myHitPoint->IsDisplayed()) myHitPoint->Erase(); - if(myHitBuf->IsPosted()) myHitBuf->UnPost(); -} -void V2d_View::Scroll(Standard_Integer& dxc, Standard_Integer& dyc, - Standard_Integer& lx, Standard_Integer& ly) { - - - Standard_Boolean Case = lx > 0 ? Standard_True: Standard_False; //war -// Case = Standard_false: there are only markers at the position 0,0; -// Case = Standard_True: works properly only if there is nothing but geometry. - - lx = Abs(lx); // war - - Quantity_Length XCenter, YCenter, Size; - myViewMapping->ViewMapping(XCenter, YCenter, Size); - - - Convert( - dxc , - dyc ,pxmin,pymax); - Convert( - dxc + lx, - dyc + ly ,pxmax,pymin); - - - Quantity_Length XMin,YMin,XMax,YMax; - myViewer->View()->MinMax(XMin,XMax,YMin,YMax); - - dxc = 0; - dyc = 0; - - if(XMin <= XMax && YMin <= YMax) { // empty view - -// warning !!! - if(!Case) { - XMin = XMin / myScale * Size; - XMax = XMax / myScale * Size; - YMin = YMin / myScale * Size; - YMax = YMax / myScale * Size; - } -// end war - - Standard_Boolean t = Standard_False; - - if (XMin < pxmin) { - Standard_Real dx = XMin - pxmin; - Translate(dx,0); - Standard_Real ddx = dx /Size * myScale; - dxc = myWindowDriver->Convert(ddx); - t = Standard_True; - } - else - XMin = pxmin; - - if (YMax > pymax) { - Standard_Real dy = YMax - pymax; - Translate(0,dy); - Standard_Real ddy = dy /Size * myScale; - dyc = myWindowDriver->Convert(ddy); - t = Standard_True; - } - else - YMax = pymax; - - if (XMax < pxmax) XMax = pxmax; - if (YMin > pymin) YMin = pymin; - - if(t) ImmediateUpdate(); - - Standard_Real a = (XMax - XMin)/Size * myScale; - Standard_Real b = (YMax - YMin)/Size * myScale; - - - lx = myWindowDriver->Convert(a); - ly = myWindowDriver->Convert(b); - } -} - - -Standard_Integer V2d_View::DefaultHighlightColor() const { -Standard_Integer index = - (myViewer->View()->IsDefinedColor()) ? - myViewer->View()->DefaultOverrideColor() : -1; - - return index; -} - -void V2d_View::SetBackground(const Quantity_NameOfColor aNameColor) { - - myWindowDriver->Window()->SetBackground( aNameColor ); -} - -Standard_Boolean V2d_View::SetBackground( const Standard_CString aNameFile, - const Aspect_FillMethod aMethod ) { - - return myWindowDriver->Window()->SetBackground(aNameFile,aMethod); - -} - -void V2d_View::SetBackground( const Quantity_Color& color ) -{ - myWindowDriver->Window()->SetBackground( color ); -} diff --git a/src/V2d/V2d_Viewer.cdl b/src/V2d/V2d_Viewer.cdl deleted file mode 100755 index 6b73f9fef9..0000000000 --- a/src/V2d/V2d_Viewer.cdl +++ /dev/null @@ -1,250 +0,0 @@ --- Created on: 1995-03-31 --- Created by: Jean-Louis Krenkel --- Copyright (c) 1995-1999 Matra Datavision --- Copyright (c) 1999-2012 OPEN CASCADE SAS --- --- The content of this file is subject to the Open CASCADE Technology Public --- License Version 6.5 (the "License"). You may not use the content of this file --- except in compliance with the License. Please obtain a copy of the License --- at http://www.opencascade.org and read it completely before using this file. --- --- The Initial Developer of the Original Code is Open CASCADE S.A.S., having its --- main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. --- --- The Original Code and all software distributed under the License is --- distributed on an "AS IS" basis, without warranty of any kind, and the --- Initial Developer hereby disclaims all such warranties, including without --- limitation, any warranties of merchantability, fitness for a particular --- purpose or non-infringement. Please see the License for the specific terms --- and conditions governing the rights and limitations under the License. - --- Update: Thu Mar 24 16:05:00 1998 --- Adds parameter in the SetFontMap() method --- and adds the new method UseMFT() --- for using MDTV fonts instead system fonts. - - -class Viewer from V2d inherits Viewer from Viewer ----Purpose: --- This class defines a 2D viewer which manages one --- 2D view at least and the attributes of this view (ex: ColorMap, etc.). -uses - ColorMap,TypeMap,WidthMap,FontMap,MarkMap from Aspect, - GraphicDevice from Aspect, - ExtendedString,AsciiString from TCollection, - View from V2d, - View from Graphic2d, - RectangularGrid from V2d,CircularGrid from V2d, - Grid from Aspect, - GridType from Aspect,GridDrawMode from Aspect, - NameOfColor from Quantity,Length from Quantity, - Color from Quantity, - PlaneAngle from Quantity, - ListOfTransient from TColStd, - ListIteratorOfListOfTransient from TColStd -is - - Create(aGraphicDevice: GraphicDevice from Aspect; - aName: ExtString from Standard; - aDomain: CString from Standard = "") - returns mutable Viewer from V2d; ----Purpose: --- Constructs a viewer object defined by the graphic --- device aGraphicDevice that determines the screen --- attributes, a default view and the name aName. - - Create(aGraphicDevice: GraphicDevice from Aspect; - aView: View from Graphic2d; - aName: ExtString from Standard; - aDomain: CString from Standard = "") - returns mutable Viewer from V2d; ----Purpose: --- Constructs a viewer object defined by the graphic --- device aGraphicDevice that determines the screen --- attributes, the first view aView and the name aName. - - AddView(me: mutable; aView: View from V2d) - is static; ----Purpose: Adds another 2D view to the viewer. - RemoveView(me: mutable; aView: View from V2d) - is static; ----Purpose: Removes the view aView from the viewer. - Update(me: mutable) - is redefined static; ----Purpose: Updates the display of all views of the viewer. - UpdateNew(me: mutable) - is static; ----Purpose: Updates the most recent changes in all the active views of the viewer. - SetColorMap(me: mutable; aColorMap: ColorMap from Aspect) - is static; ----Purpose: --- Replaces the default color map of the viewer with the --- new color map aColorMap. - SetTypeMap(me: mutable; aTypeMap: TypeMap from Aspect) - is static; ----Purpose: --- Replaces the default type map of the viewer with the --- new type map aTypeMap. - SetWidthMap(me: mutable; aWidthMap: WidthMap from Aspect) - is static; ----Purpose: --- Replaces the default width map of the viewer with the --- new width map aWidthMap. - SetFontMap(me: mutable; aFontMap: FontMap from Aspect; - useMFT: Boolean from Standard = Standard_True) - is static; ----Purpose: --- Replaces the default font map of the viewer with the --- new font map aFontMap. When useMFT is equal to --- Standard_True, MDTV fonts are used instead of system fonts. - SetMarkMap(me: mutable; aMarkMap: MarkMap from Aspect) - is static; ----Purpose: --- Replaces the default mark map of the viewer with the --- new mark map aMarkMap. - ColorMap(me) returns ColorMap from Aspect - is static; - --- Purpose: Returns the active color map of the viewer. - TypeMap(me) returns TypeMap from Aspect - is static; ---- Purpose: Returns the active type map of the viewer. - WidthMap(me) returns WidthMap from Aspect - is static; ----Purpose: Returns the active width map of the viewer. - FontMap(me) returns FontMap from Aspect - is static; ----Purpose: Returns the active font map for the viewer. - MarkMap(me) returns MarkMap from Aspect - is static; ----Purpose: Returns the active mark map of the viewer. - UseMFT ( me ) returns Boolean from Standard - is static; ----Purpose: Returns True when the viewer uses MFT fonts --- instead of system fonts. - View(me) returns View from Graphic2d; - ---Purpose: Returns the first view of the viewer. - InitializeColor(me: mutable; aColor: NameOfColor from Quantity) - ---Purpose: Creates a color in the color map of the driver if - -- the color does not yes exist. - -- Returns the index of the color in the modified color map. - returns Integer from Standard; - - InitActiveViews(me: mutable) - ---Purpose: initializes an iteration on the active views. - is static; - - MoreActiveViews (me) - returns Boolean from Standard - ---Purpose: returns true if there are more active view(s) to return. - is static; - - NextActiveViews (me: mutable) - ---Purpose : Go to the next active view - -- (if there is not, ActiveView will raise an exception) - is static; - - ActiveView(me) - returns mutable View from V2d is static; - - ---Purpose: --- Returns the current view from the activated views. - - IsEmpty(me) returns Boolean from Standard; - ----Purpose: --- Returns True when no more secondary views exist in the viewer. - Grid(me) returns mutable Grid from Aspect - is static private; - - GridType(me) returns GridType from Aspect - ---Purpose: returns the current grid type. - is static; - - Hit(me; X,Y: Length from Quantity; - gx,gy: out Length from Quantity) - ---Purpose: returns the point (gx,gy) according to the grid. - is static; - - ActivateGrid(me: mutable; aGridType: GridType from Aspect; - aGridDrawMode: GridDrawMode from Aspect) - is static; - - DeactivateGrid(me: mutable) - is static; - - IsActive(me) - returns Boolean from Standard - is static; ----Purpose: Returns True when a grid is active in the viewer. - RectangularGridValues(me; - XOrigin, YOrigin, XStep, YStep: out Length from Quantity; - RotationAngle: out PlaneAngle from Quantity) - is static; ----Purpose: Returns the parameters of the current rectangular grid. - SetRectangularGridValues(me: mutable; - XOrigin, YOrigin, XStep, YStep: Length from Quantity; - RotationAngle: PlaneAngle from Quantity) - is static; - ---Purpose: --- Sets the rectangular grid: --- - XOrigin, YOrigin define the point of origin of the grid, --- - XStep defines the interval between two vertical lines, --- - YStep defines the interval between two horizontal lines, --- - RotationAngle defines the rotation angle of the grid. - - CircularGridValues(me; - XOrigin, YOrigin, RadiusStep: out Length from Quantity; - DivisionNumber: out Integer from Standard; - RotationAngle: out PlaneAngle from Quantity) - is static; ----Purpose: Returns the parameters of the current circular grid. - SetCircularGridValues(me: mutable; - XOrigin, YOrigin, RadiusStep: Length from Quantity; - DivisionNumber: Integer from Standard; - RotationAngle: PlaneAngle from Quantity) - is static; ----Purpose: --- Sets the circular grid: --- - XOrigin, YOrigin specify the origin of the grid, --- - RadiusStep defines the interval between two circles, --- - DivisionNumber determines the section number of half a circle, --- - RotationAngle defines the rotation angle of the grid. - - SetGridColor(me: mutable; color1, color2 : Color from Quantity) - is static; - - HitPointMarkerIndex(me) returns Integer from Standard - is static private; - - HitPointColor(me) returns Integer from Standard - is static private; - - CoordinatesColor(me) returns Integer from Standard - is static private; - - Init(me:mutable) - is static private; - - - -fields - - myColorMap: ColorMap from Aspect; - myTypeMap: TypeMap from Aspect; - myWidthMap: WidthMap from Aspect; - myFontMap: FontMap from Aspect; - myMarkMap: MarkMap from Aspect; - myGraphicView: View from Graphic2d; - myViews: ListOfTransient from TColStd; - myViewsIterator:ListIteratorOfListOfTransient from TColStd; - - myRGrid: RectangularGrid from V2d; - myCGrid: CircularGrid from V2d; - myHitPointMarkerIndex: Integer from Standard; - myHitPointColorIndex: Integer from Standard; - myCoordinatesColorIndex: Integer from Standard; - myGridType: GridType from Aspect; - myUseMFT: Boolean from Standard; -friends - class View from V2d -end Viewer from V2d; diff --git a/src/V2d/V2d_Viewer.cxx b/src/V2d/V2d_Viewer.cxx deleted file mode 100755 index 4d926cc876..0000000000 --- a/src/V2d/V2d_Viewer.cxx +++ /dev/null @@ -1,462 +0,0 @@ -// Copyright (c) 1999-2012 OPEN CASCADE SAS -// -// The content of this file is subject to the Open CASCADE Technology Public -// License Version 6.5 (the "License"). You may not use the content of this file -// except in compliance with the License. Please obtain a copy of the License -// at http://www.opencascade.org and read it completely before using this file. -// -// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its -// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. -// -// The Original Code and all software distributed under the License is -// distributed on an "AS IS" basis, without warranty of any kind, and the -// Initial Developer hereby disclaims all such warranties, including without -// limitation, any warranties of merchantability, fitness for a particular -// purpose or non-infringement. Please see the License for the specific terms -// and conditions governing the rights and limitations under the License. - -//Updates: -// GG 24/03/98 Add useMFT parameter to SetFontMap method. -// GG 07/07/98 BUC60258 Add SetMarkMap() method - -#define PRO10988 //DCB Resets grid color indices after colormap change - -#define IMP080300 //GG -// -> Optimize the SetColorMap() and InitializeColor() methods -// Review the 14/09/01 to avoid regression -// See new deferred method in Aspect_ColorMap - -#include -#include -#include -#include -#include -#include -#include -#include - -/*=================================================================*/ -V2d_Viewer::V2d_Viewer(const Handle(Aspect_GraphicDevice)& aGraphicDevice, - const Standard_ExtString aName, - const Standard_CString aDomain) -:Viewer_Viewer(aGraphicDevice,aName,aDomain,1), -myColorMap(V2d_DefaultMap::ColorMap()), -myTypeMap(V2d_DefaultMap::TypeMap()), -myWidthMap(V2d_DefaultMap::WidthMap()), -myFontMap(V2d_DefaultMap::FontMap()), -myMarkMap(V2d_DefaultMap::MarkMap()), -myGraphicView(new Graphic2d_View()), -myViews(), -myViewsIterator(), -myRGrid(), -myCGrid() -{ - Init(); -} - -/*=================================================================*/ -V2d_Viewer::V2d_Viewer(const Handle(Aspect_GraphicDevice)& aGraphicDevice, - const Handle(Graphic2d_View)& aView, - const Standard_ExtString aName, - const Standard_CString aDomain) -:Viewer_Viewer(aGraphicDevice,aName,aDomain,1), -myColorMap(V2d_DefaultMap::ColorMap()), -myTypeMap(V2d_DefaultMap::TypeMap()), -myWidthMap(V2d_DefaultMap::WidthMap()), -myFontMap(V2d_DefaultMap::FontMap()), -myMarkMap(V2d_DefaultMap::MarkMap()), -myGraphicView(aView), -myViews(), -myViewsIterator(), -myRGrid(), -myCGrid() -{ - Init(); -} - -/*=================================================================*/ -void V2d_Viewer::Init() { - myHitPointMarkerIndex = 1; - myHitPointColorIndex = 0; - Standard_Integer i1 = InitializeColor(Quantity_NOC_GRAY50); - Standard_Integer i2 = InitializeColor(Quantity_NOC_GRAY70); - myHitPointColorIndex = InitializeColor(Quantity_NOC_WHITE); - myCoordinatesColorIndex = myHitPointColorIndex ; - myGridType = Aspect_GT_Rectangular; - - myUseMFT = Standard_True; -#ifdef PRO10988 - if( myRGrid.IsNull() ) myRGrid = new V2d_RectangularGrid(this,i1,i2); - else myRGrid -> SetColorIndices (i1, i2); - if( myCGrid.IsNull() ) myCGrid = new V2d_CircularGrid(this,i1,i2); - else myCGrid -> SetColorIndices (i1, i2); -#else - myRGrid = new V2d_RectangularGrid(this,i1,i2); - myCGrid = new V2d_CircularGrid(this,i1,i2); -#endif -} - - -/*=================================================================*/ -void V2d_Viewer::AddView(const Handle(V2d_View)& aView) { - myViews.Append(aView); - IncrCount(); -} - -/*=================================================================*/ -void V2d_Viewer::RemoveView(const Handle(V2d_View)& aView) { - - myViewsIterator.Initialize(myViews); - while(myViewsIterator.More()) - if(aView == myViewsIterator.Value()) { - myViews.Remove(myViewsIterator);} - else - myViewsIterator.Next(); -} - -/*=================================================================*/ -void V2d_Viewer::SetColorMap(const Handle(Aspect_ColorMap)& aColorMap) { - myColorMap = aColorMap; -#ifdef PRO10988 - // Need to call to redefine myColorIndex1 and myColorIndex2, - // which may not be available in new colormap. -#ifdef IMP080300 - if( myColorMap != aColorMap ) Init (); -#else - Init(); -#endif - // We need to pass myColorMap in the views because - // it could be changed in Init() method by InitializeColor(). - for (InitActiveViews();MoreActiveViews();NextActiveViews()) { - ActiveView()->Driver()->SetColorMap(myColorMap); - } -#else - for (InitActiveViews();MoreActiveViews();NextActiveViews()) { - ActiveView()->Driver()->SetColorMap(aColorMap); - } -#endif -} - -/*=================================================================*/ -Handle(Aspect_ColorMap) V2d_Viewer::ColorMap() const { - return myColorMap; -} - -/*=================================================================*/ -void V2d_Viewer::SetTypeMap(const Handle(Aspect_TypeMap)& aTypeMap) { - myTypeMap = aTypeMap; - for (InitActiveViews();MoreActiveViews();NextActiveViews()) { - ActiveView()->Driver()->SetTypeMap(aTypeMap); - } -} - -/*=================================================================*/ -Handle(Aspect_TypeMap) V2d_Viewer::TypeMap() const { - return myTypeMap; -} - -/*=================================================================*/ -void V2d_Viewer::SetWidthMap(const Handle(Aspect_WidthMap)& aWidthMap) { - myWidthMap = aWidthMap; - for (InitActiveViews();MoreActiveViews();NextActiveViews()) { - ActiveView()->Driver()->SetWidthMap(aWidthMap); - } -} - -/*=================================================================*/ -Handle(Aspect_WidthMap) V2d_Viewer::WidthMap() const { - return myWidthMap; -} - -/*=================================================================*/ -void V2d_Viewer::SetFontMap(const Handle(Aspect_FontMap)& aFontMap, - const Standard_Boolean useMFT) { - myFontMap = aFontMap; - for (InitActiveViews();MoreActiveViews();NextActiveViews()) { - ActiveView()->Driver()->SetFontMap(aFontMap,useMFT); - } -} - -/*=================================================================*/ -void V2d_Viewer::SetMarkMap(const Handle(Aspect_MarkMap)& aMarkMap) { - myMarkMap = aMarkMap; - for (InitActiveViews();MoreActiveViews();NextActiveViews()) { - ActiveView()->Driver()->SetMarkMap(aMarkMap); - } -} - -/*=================================================================*/ -Handle(Aspect_FontMap) V2d_Viewer::FontMap() const { - return myFontMap; -} - -/*=================================================================*/ -Handle(Aspect_MarkMap) V2d_Viewer::MarkMap() const { - return myMarkMap; -} - -/*=================================================================*/ -Handle(Graphic2d_View) V2d_Viewer::View () const { - return myGraphicView; -} - -/*=================================================================*/ -Standard_Boolean V2d_Viewer::UseMFT() const { - return myUseMFT; -} - -/*=================================================================*/ -void V2d_Viewer::Update() { - for (InitActiveViews();MoreActiveViews();NextActiveViews()){ - ActiveView()->Update(); - } -} - -/*=================================================================*/ -void V2d_Viewer::UpdateNew() { - for (InitActiveViews();MoreActiveViews();NextActiveViews()){ - ActiveView()->UpdateNew(); - } -} - -/*=================================================================*/ -Standard_Integer V2d_Viewer::InitializeColor (const Quantity_NameOfColor aColor) { - Standard_Integer Size = myColorMap->Size(); - Quantity_Color color(aColor); -#ifdef IMP080300 - Standard_Integer index = myColorMap->AddEntry(color); - if( Size != myColorMap->Size() ) { - for (InitActiveViews();MoreActiveViews();NextActiveViews()){ - ActiveView()->Driver()->SetColorMap(myColorMap); - } - } -#else // ??? why this gazworks ??? - Standard_Integer i,index=0; - for ( i=1; i<= Size; i++) { - if(myColorMap->Entry(i).Color().IsEqual(color)) - index=myColorMap->Entry(i).Index(); - } - if (index == 0) { - Handle(Aspect_GenericColorMap) map = new Aspect_GenericColorMap; - for (i=1; i<= Size; i++) { - map->AddEntry(myColorMap->Entry(i)); - } -// finding a free index. - TColStd_MapOfInteger M; - for ( i=1; i<= Size; i++) { - M.Add(myColorMap->Entry(i).Index()); - } -#ifndef PRO10988 - index = Size + 1; -#endif - i=1; - while (index == 0) { - if(!M.Contains(i)) index =i; - i++; - } - map->AddEntry(Aspect_ColorMapEntry(index,color)); - for (InitActiveViews();MoreActiveViews();NextActiveViews()){ - ActiveView()->Driver()->SetColorMap(map); - } - myColorMap = map; - } -#endif - return index; -} - -/*=================================================================*/ -void V2d_Viewer::InitActiveViews() { -myViewsIterator.Initialize(myViews); -} - -/*=================================================================*/ -Standard_Boolean V2d_Viewer::MoreActiveViews () const { - return myViewsIterator.More(); -} - -/*=================================================================*/ -void V2d_Viewer::NextActiveViews () { - myViewsIterator.Next(); -} - -/*=================================================================*/ -Handle(V2d_View) V2d_Viewer::ActiveView() const { - return (Handle(V2d_View)&)(myViewsIterator.Value()); -} - -/*=================================================================*/ -Handle(Aspect_Grid) V2d_Viewer::Grid () const { -Handle(Aspect_Grid) grid; - - switch (myGridType) { - case Aspect_GT_Circular: - grid = myCGrid; - break; - case Aspect_GT_Rectangular: - default: - grid = myRGrid; - } - return grid; -} - -/*=================================================================*/ -void V2d_Viewer::ActivateGrid(const Aspect_GridType aType, - const Aspect_GridDrawMode aMode){ - - Grid()->Erase(); - myGridType = aType; - Grid()->SetDrawMode(aMode); - Grid()->Display(); - Grid()->Activate(); - Update(); -} - -/*=================================================================*/ -void V2d_Viewer::DeactivateGrid() { - Grid()->Erase(); - Grid()->Deactivate(); - Update(); -} - -/*=================================================================*/ -Standard_Boolean V2d_Viewer::IsActive () const { - return Grid()->IsActive(); -} - -/*=================================================================*/ -void V2d_Viewer::RectangularGridValues -(Quantity_Length& theXOrigin, - Quantity_Length& theYOrigin, - Quantity_Length& theXStep, - Quantity_Length& theYStep, - Quantity_PlaneAngle& theRotationAngle) const { - - theXOrigin = myRGrid->XOrigin(); - theYOrigin = myRGrid->YOrigin(); - theXStep = myRGrid->XStep(); - theYStep = myRGrid->YStep(); - theRotationAngle = myRGrid->RotationAngle(); -} - -/*=================================================================*/ -void V2d_Viewer::SetRectangularGridValues -(const Quantity_Length theXOrigin, - const Quantity_Length theYOrigin, - const Quantity_Length theXStep, - const Quantity_Length theYStep, - const Quantity_PlaneAngle theRotationAngle) { - - myRGrid->SetXOrigin(theXOrigin); - myRGrid->SetYOrigin(theYOrigin); - myRGrid->SetXStep(theXStep); - myRGrid->SetYStep(theYStep); - myRGrid->SetRotationAngle(theRotationAngle); - Update(); -} - -/*=================================================================*/ -void V2d_Viewer::CircularGridValues -(Quantity_Length& theXOrigin, - Quantity_Length& theYOrigin, - Quantity_Length& theRadiusStep, - Standard_Integer& theDivisionNumber, - Quantity_PlaneAngle& theRotationAngle) const { - - theXOrigin = myCGrid->XOrigin(); - theYOrigin = myCGrid->YOrigin(); - theRadiusStep = myCGrid->RadiusStep(); - theDivisionNumber = myCGrid->DivisionNumber(); - theRotationAngle = myCGrid->RotationAngle(); -} - -/*=================================================================*/ -void V2d_Viewer::SetCircularGridValues -(const Quantity_Length theXOrigin, - const Quantity_Length theYOrigin, - const Quantity_Length theRadiusStep, - const Standard_Integer theDivisionNumber, - const Quantity_PlaneAngle theRotationAngle) { - - myCGrid->SetXOrigin(theXOrigin); - myCGrid->SetYOrigin(theYOrigin); - myCGrid->SetRadiusStep(theRadiusStep); - myCGrid->SetDivisionNumber(theDivisionNumber); - myCGrid->SetRotationAngle(theRotationAngle); - Update(); -} - -/*=================================================================*/ -Standard_Integer V2d_Viewer::HitPointColor() const { - return myHitPointColorIndex; -} - -/*=================================================================*/ -Standard_Integer V2d_Viewer::CoordinatesColor() const { - return myCoordinatesColorIndex; -} - -/*=================================================================*/ -Standard_Integer V2d_Viewer::HitPointMarkerIndex() const { - return myHitPointMarkerIndex; -} - -/*=================================================================*/ -void V2d_Viewer::Hit(const Quantity_Length rx, - const Quantity_Length ry, - Quantity_Length& gx, - Quantity_Length& gy) const { - - Grid()->Hit(rx,ry,gx,gy); -} - -/*=================================================================*/ -Aspect_GridType V2d_Viewer::GridType() const { - return myGridType; -} - -/*=================================================================*/ -Standard_Boolean V2d_Viewer::IsEmpty() const { - - return myViews.IsEmpty(); -} - -//SAV -void V2d_Viewer::SetGridColor( const Quantity_Color& color1, - const Quantity_Color& color2 ) -{ - Standard_Integer i1 = InitializeColor( color1.Name() ); - Standard_Integer i2 = InitializeColor( color2.Name() ); - - Standard_Boolean restart = IsActive(); - if ( restart ) { - DeactivateGrid(); - Grid()->Erase(); - } - - Quantity_Length xOrigin, yOrigin, xStep, yStep; - Quantity_PlaneAngle angle; - Standard_Integer theDivisionNumber; - Aspect_GridDrawMode gMode = myRGrid->DrawMode(); - - RectangularGridValues( xOrigin, yOrigin, xStep, yStep, angle ); - myRGrid.Nullify(); - if ( myRGrid.IsNull() ) { - myRGrid = new V2d_RectangularGrid( this, i1, i2 ); - myRGrid->SetDrawMode( gMode ); - SetRectangularGridValues( xOrigin, yOrigin, xStep, yStep, angle ); - } - - gMode = myCGrid->DrawMode(); - CircularGridValues( xOrigin, yOrigin, xStep, theDivisionNumber, angle ); - myCGrid.Nullify(); - if ( myCGrid.IsNull() ) { - myCGrid = new V2d_CircularGrid( this, i1, i2 ); - myCGrid->SetDrawMode( gMode ); - SetCircularGridValues( xOrigin, yOrigin, xStep, theDivisionNumber, angle ); - } - if ( restart ) { - Grid()->Display(); - Grid()->Activate(); - Update(); - } -} diff --git a/src/V3d/V3d.cdl b/src/V3d/V3d.cdl index f805b9bd02..a775d557e1 100755 --- a/src/V3d/V3d.cdl +++ b/src/V3d/V3d.cdl @@ -55,7 +55,6 @@ uses TCollection, Quantity, Aspect, - PlotMgt, Image, gp, OSD, diff --git a/src/V3d/V3d_View.cdl b/src/V3d/V3d_View.cdl index f96274e58d..146ae8d991 100755 --- a/src/V3d/V3d_View.cdl +++ b/src/V3d/V3d_View.cdl @@ -128,7 +128,6 @@ uses BufferType from Graphic3d, Background from Aspect, GradientBackground from Aspect, - PlotterDriver from PlotMgt, TypeOfColor from Quantity, NameOfColor from Quantity, Color from Quantity, @@ -1585,13 +1584,6 @@ is -- if is Standard_True, the animation mode -- is activated. - ScreenCopy (me : mutable; - aPlotterDriver : PlotterDriver from PlotMgt; - fWhiteBackground : Boolean from Standard = Standard_True; - aScale : Factor from Quantity = 1.0 - ) is static; - ---Purpose: dump the view - Dump ( me: mutable; theFile : CString from Standard; theBufferType : BufferType from Graphic3d = Graphic3d_BT_RGB ) diff --git a/src/V3d/V3d_View.cxx b/src/V3d/V3d_View.cxx index 1d417c38c0..fb1e92a326 100755 --- a/src/V3d/V3d_View.cxx +++ b/src/V3d/V3d_View.cxx @@ -177,13 +177,7 @@ To solve the problem (for lack of a better solution) I make 2 passes. #include #include #include -#include #include -#ifdef WNT -# include -#else -# include -#endif #ifdef G003 # define V3d_FLAG_ANIMATION 0x00000001 @@ -3302,94 +3296,6 @@ Standard_Real V3d_View::Tumble (const Standard_Integer NbImages, const Standard_ return NbImages/CPUtime; } -#define SCREENCOPY_FILENAME "screencopy3d.gif" -void V3d_View::ScreenCopy (const Handle(PlotMgt_PlotterDriver)& aPlotterDriver, - const Standard_Boolean fWhiteBackground, - const Quantity_Factor aPlotScale) -{ - TCollection_AsciiString aFileToDump; - Handle(Aspect_WindowDriver) aWindowDriver = -#ifdef WNT - new WNT_WDriver (Handle(WNT_Window)::DownCast(MyWindow)); -#else - new Xw_Driver (Handle(Xw_Window)::DownCast(MyWindow)); -#endif // WNT - Quantity_Factor aScale; - Quantity_Length thePixel; - Quantity_Parameter theWWidth, theWHeight; - Quantity_Parameter thePWidth, thePHeight; - aPlotterDriver -> WorkSpace (thePWidth, thePHeight); - aWindowDriver -> WorkSpace (theWWidth, theWHeight); - thePixel = aWindowDriver -> Convert (1); - - if (theWWidth * theWHeight != 0.) { - if (aPlotScale == 0.) { - aScale = Min (thePWidth / theWWidth, thePHeight / theWHeight); - } else { - // To be changed !!!!!!!!!!!!!!! - aScale = Min (thePWidth / theWWidth, thePHeight / theWHeight); - } - - // Set default maps (color, type, etc) for plotter driver - aPlotterDriver -> SetColorMap ( new Aspect_GenericColorMap () ); - aPlotterDriver -> SetTypeMap ( new Aspect_TypeMap () ); - aPlotterDriver -> SetWidthMap ( new Aspect_WidthMap () ); - aPlotterDriver -> SetFontMap ( new Aspect_FontMap () ); - aPlotterDriver -> SetMarkMap ( new Aspect_MarkMap () ); - - // Set backgroung to white, unihiglight if any - Quantity_Parameter theRed, theGreen, theBlue; - Handle(TColStd_HSequenceOfInteger) theFlags; - Graphic3d_MapOfStructure theStructures; - BackgroundColor (Quantity_TOC_RGB, theRed, theGreen, theBlue); - if (fWhiteBackground) - SetBackgroundColor (Quantity_NOC_WHITE); - MyView -> DisplayedStructures (theStructures); - theFlags = new TColStd_HSequenceOfInteger (); - Graphic3d_MapIteratorOfMapOfStructure Iterator (theStructures); - while (Iterator.More ()) { - Handle(Graphic3d_Structure) aStructure = Iterator.Key(); - if (aStructure -> IsHighlighted()) { - theFlags -> Append (1); - aStructure -> UnHighlight (); - } else { - theFlags -> Append (0); - } - Iterator.Next (); - } - Redraw (); - - // Dump the view - if (aPlotterDriver->IsKind(STANDARD_TYPE(PlotMgt_ImageDriver))) { - aFileToDump = aPlotterDriver->PlotFileName(); - } else { - aFileToDump = aPlotterDriver->SpoolDirectory(); - aFileToDump += SCREENCOPY_FILENAME; - } - MyWindow -> Dump (aFileToDump.ToCString()); - - Standard_Integer theCurStruct = 1; - Iterator = Graphic3d_MapIteratorOfMapOfStructure (theStructures); - while (Iterator.More ()) { - if (theFlags -> Value(theCurStruct)) - Iterator.Key() -> Highlight (Aspect_TOHM_COLOR); - Iterator.Next (); - theCurStruct++; - } - if (fWhiteBackground) - SetBackgroundColor (Quantity_TOC_RGB, theRed, theGreen, theBlue); - Redraw (); - - // Draw imagefile by plotter driver - aPlotterDriver -> SetPixelSize (thePixel); - aPlotterDriver -> BeginDraw (); - aPlotterDriver -> DrawImageFile ( - aFileToDump.ToCString(), (float)(thePWidth / 2.), (float)(thePHeight / 2.), aScale); - aPlotterDriver -> EndDraw (); - } -} -#undef SCREENCOPY_FILENAME - #include #include diff --git a/src/Viewer2dTest/FILES b/src/Viewer2dTest/FILES deleted file mode 100755 index c837bab410..0000000000 --- a/src/Viewer2dTest/FILES +++ /dev/null @@ -1,5 +0,0 @@ -Viewer2dTest_CMPLRS.edl -Viewer2dTest_GeneralCommands.cxx -Viewer2dTest_ViewerCommands.cxx -Viewer2dTest_DisplayCommands.cxx -Viewer2dTest_ObjectCommands.cxx diff --git a/src/Viewer2dTest/Viewer2dTest.cdl b/src/Viewer2dTest/Viewer2dTest.cdl deleted file mode 100755 index 5b91181612..0000000000 --- a/src/Viewer2dTest/Viewer2dTest.cdl +++ /dev/null @@ -1,142 +0,0 @@ --- Copyright (c) 1999-2012 OPEN CASCADE SAS --- --- The content of this file is subject to the Open CASCADE Technology Public --- License Version 6.5 (the "License"). You may not use the content of this file --- except in compliance with the License. Please obtain a copy of the License --- at http://www.opencascade.org and read it completely before using this file. --- --- The Initial Developer of the Original Code is Open CASCADE S.A.S., having its --- main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. --- --- The Original Code and all software distributed under the License is --- distributed on an "AS IS" basis, without warranty of any kind, and the --- Initial Developer hereby disclaims all such warranties, including without --- limitation, any warranties of merchantability, fitness for a particular --- purpose or non-infringement. Please see the License for the specific terms --- and conditions governing the rights and limitations under the License. - - -package Viewer2dTest - - ---Purpose: - -uses - Draw, - TCollection, - TColStd, - TopAbs, - TopTools, - TopoDS, - V2d, - AIS2D, - AIS, - Graphic2d - -is - - class EventManager; - ---Purpose: used to manage mouse event (move,select,shiftselect) - -- By default the events are transmitted to interactive context. - - class DoubleMapOfInteractiveAndName instantiates DoubleMap - from TCollection (InteractiveObject from AIS2D, - AsciiString from TCollection, - MapTransientHasher from TColStd, - AsciiString from TCollection); - - class DataMapOfText instantiates DataMap - from TCollection (AsciiString from TCollection, - Text from Graphic2d, - AsciiString from TCollection); - - ---Category: Create the viewer.... - - ViewerInit ( thePxLeft, thePxTop : Integer from Standard = 0; - thePxWidth, thePxHeight : Integer from Standard = 0); - ---Purpose: - -- implemented in Viewer2dTest_ViewerCommands.cxx - - - ---Category: Selection in the viewer.... - - PickShape (aType : ShapeEnum from TopAbs; - MaxPick : Integer from Standard = 5) returns Shape from TopoDS; - ---Purpose: waits until a shape of type is picked in the AIS2D Viewer and returns it. - -- if == TopAbs_Shape, any shape can be picked... - -- MaxPick is the Max number before exiting, if no pick is successfull - - PickShapes (aType : ShapeEnum from TopAbs; - thepicked : in out HArray1OfShape from TopTools; - MaxPick : Integer from Standard = 5) - returns Boolean from Standard; - ---Purpose: wait until the array is filled with picked shapes. - -- returns True if the array is filled. - -- exit if number of unsuccesfull picks = - - PickObject(Type : KindOfInteractive from AIS = AIS_KOI_None; - Signature : Integer from Standard = -1; - MaxPick : Integer from Standard = 5) - returns InteractiveObject from AIS2D; - ---Purpose: waits until an interactive object of a given Type - -- and signature is picked (defaut values authorize - -- selection of any Interactive Object) - -- exit if number of unsuccesfull picks = - - PickObjects(thepicked : in out HArray1OfTransient from TColStd; - Type : KindOfInteractive from AIS = AIS_KOI_None; - Signature : Integer from Standard = -1; - MaxPick : Integer from Standard = 5) - returns Boolean from Standard; - ---Purpose: selection of several interactive objects. Number is given - -- by the size of - -- exit if number of unsuccesfull picks = - - - GetMousePosition(xpix,ypix: out Integer from Standard); - - GetViewerFromContext returns Viewer from V2d; - - GetCollectorFromContext returns Viewer from V2d; - - GetAIS2DContext returns InteractiveContext from AIS2D; - - SetAIS2DContext (aContext: InteractiveContext from AIS2D); - - CurrentView returns View from V2d; - - CurrentView (aViou:View from V2d); - - Clear ; - - ---Category: Change behaviour on move,select,... events. - - SetEventManager (aMgr:EventManager from Viewer2dTest); - ---Purpose: puts as current eventmanager (the - -- move,select,...will be applied to - - UnsetEventManager; - ---Purpose: removes the last EventManager from the list. - - ResetEventManager; - ---Purpose: clear the list of EventManagers and - -- sets the default EventManager as current - - CurrentEventManager returns EventManager from Viewer2dTest; - - - ---Category: privateMethods... - - RemoveSelected; - - StandardModeActivation (Mode : Integer from Standard); - - ---Category: Draw Commands - - Commands (theCommands : in out Interpretor from Draw); - MyCommands (theCommands : in out Interpretor from Draw); -- My Own Com-s - GeneralCommands (theCommands :in out Interpretor from Draw); - ViewerCommands (theCommands :in out Interpretor from Draw); - DisplayCommands (theCommands : in out Interpretor from Draw); - ObjectCommands (theCommands :in out Interpretor from Draw); - -end; diff --git a/src/Viewer2dTest/Viewer2dTest.cxx b/src/Viewer2dTest/Viewer2dTest.cxx deleted file mode 100755 index 30d5e43a04..0000000000 --- a/src/Viewer2dTest/Viewer2dTest.cxx +++ /dev/null @@ -1,580 +0,0 @@ -// Copyright (c) 1999-2012 OPEN CASCADE SAS -// -// The content of this file is subject to the Open CASCADE Technology Public -// License Version 6.5 (the "License"). You may not use the content of this file -// except in compliance with the License. Please obtain a copy of the License -// at http://www.opencascade.org and read it completely before using this file. -// -// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its -// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. -// -// The Original Code and all software distributed under the License is -// distributed on an "AS IS" basis, without warranty of any kind, and the -// Initial Developer hereby disclaims all such warranties, including without -// limitation, any warranties of merchantability, fitness for a particular -// purpose or non-infringement. Please see the License for the specific terms -// and conditions governing the rights and limitations under the License. - - -#include -#include -#include -#include - -#include - -#include -#include -#include - -#include -#include -#include - -#include - -#include -#include -#include - -extern int ViewerMainLoop2d (Standard_Integer argc, const char** argv); - -TopoDS_Shape GetShapeFromName2d (const char* name); - -static TColStd_ListOfTransient theEventMgrs2d; - -//============================================================================== -// VIEWER OBJECT MANAGEMENT GLOBAL VARIABLES -//============================================================================== -Standard_EXPORT Viewer2dTest_DoubleMapOfInteractiveAndName& GetMapOfAIS2D() -{ - static Viewer2dTest_DoubleMapOfInteractiveAndName TheMap; - return TheMap; -} - -static void VwrTst_InitEventMgr2d (const Handle(AIS2D_InteractiveContext)& Ctx) -{ - theEventMgrs2d.Clear(); - theEventMgrs2d.Prepend(new Viewer2dTest_EventManager(Ctx)); -} - -static Handle(V2d_View)& a2DView() -{ - static Handle(V2d_View) Viou; - return Viou; -} - -Standard_EXPORT Handle(AIS2D_InteractiveContext)& TheAIS2DContext() -{ - static Handle(AIS2D_InteractiveContext) aContext; - return aContext; -} - -Handle(V2d_View) Viewer2dTest::CurrentView() -{ - return a2DView(); -} - -void Viewer2dTest::CurrentView (const Handle(V2d_View)& V) -{ - a2DView() = V; -} - -Handle(AIS2D_InteractiveContext) Viewer2dTest::GetAIS2DContext() -{ - return TheAIS2DContext(); -} - -Handle(V2d_Viewer) Viewer2dTest::GetViewerFromContext() -{ - return TheAIS2DContext()->CurrentViewer(); -} - -Handle(V2d_Viewer) Viewer2dTest::GetCollectorFromContext() -{ - return TheAIS2DContext()->CurrentViewer(); -} - -void Viewer2dTest::SetAIS2DContext (const Handle(AIS2D_InteractiveContext)& aCtx) -{ - TheAIS2DContext() = aCtx; - Viewer2dTest::ResetEventManager(); -} - -void Viewer2dTest::SetEventManager (const Handle(Viewer2dTest_EventManager)& EM) -{ - theEventMgrs2d.Prepend(EM); -} - -void Viewer2dTest::UnsetEventManager() -{ - theEventMgrs2d.RemoveFirst(); -} - -void Viewer2dTest::ResetEventManager() -{ - VwrTst_InitEventMgr2d(Viewer2dTest::GetAIS2DContext()); -} - -//============================================================================== -//function : CurrentEventManager -//purpose : -//============================================================================== -Handle(Viewer2dTest_EventManager) Viewer2dTest::CurrentEventManager() -{ - Handle(Viewer2dTest_EventManager) EM; - if(theEventMgrs2d.IsEmpty()) return EM; - Handle(Standard_Transient) Tr = theEventMgrs2d.First(); - EM = *((Handle(Viewer2dTest_EventManager)*)&Tr); - return EM; -} - -//============================================================================== -//function : Clear -//purpose : Remove all the object from the viewer -//============================================================================== -void Viewer2dTest::Clear() -{ - if (!Viewer2dTest::CurrentView().IsNull()) - { - TheAIS2DContext()->CloseLocalContext(); - Viewer2dTest_DoubleMapIteratorOfDoubleMapOfInteractiveAndName it (GetMapOfAIS2D()); - while (it.More()) - { - cout << "Remove " << it.Key2() << endl; -// TheAIS2DContext()->Remove(it.Key1(), Standard_False); - TheAIS2DContext()->Erase(it.Key1(), Standard_False, Standard_False); - it.Next(); - } - TheAIS2DContext()->UpdateCurrentViewer(); - GetMapOfAIS2D().Clear(); - } -} - -//============================================================================== -//function : StandardModeActivation -//purpose : Activate a selection mode, vertex, edge, wire ..., in a local -// Context -//============================================================================== -void Viewer2dTest::StandardModeActivation (const Standard_Integer mode) -{ - Handle(AIS2D_InteractiveContext) aContext = Viewer2dTest::GetAIS2DContext(); - aContext->SetPickMode(Graphic2d_PM_INTERSECT); - - const char* cmode = "??????????"; - - switch ((AIS2D_TypeOfDetection)mode) - { - case AIS2D_TOD_OBJECT: cmode = "OBJECT"; break; - case AIS2D_TOD_PRIMITIVE: cmode = "PRIMITIVE"; break; - case AIS2D_TOD_ELEMENT: cmode = "ELEMENT"; break; - case AIS2D_TOD_VERTEX: cmode = "VERTEX"; break; - case AIS2D_TOD_NONE: cmode = "NONE"; break; - } - - // Activate - Viewer2dTest_DoubleMapIteratorOfDoubleMapOfInteractiveAndName it (GetMapOfAIS2D()); - while (it.More()) - { - Handle(AIS2D_InteractiveObject) ashape = it.Key1(); - ashape->SetContext(aContext); -// ashape->SetSelectionMode(mode); - ashape->SetHighlightMode((AIS2D_TypeOfDetection)mode); - it.Next(); - } -// aContext->ActivateStandardMode(AIS2D_ProjShape::SelectionType(mode)); - cout << "Mode " << cmode << " ON" << endl; -} - -//======================================================================= -//function : PickObjects -//purpose : -//======================================================================= -Standard_Boolean Viewer2dTest::PickObjects (Handle(TColStd_HArray1OfTransient)& arr, - const AIS_KindOfInteractive TheType, - const Standard_Integer /*TheSignature*/, - const Standard_Integer MaxPick) -{ - Handle(AIS2D_InteractiveObject) IO; - Standard_Integer curindex = (TheType == AIS_KOI_None) ? 0 : TheAIS2DContext()->OpenLocalContext(); - - // step 1: prepare the data - if (curindex != 0) - { -// Handle(AIS2D_SignatureFilter) F1 = new AIS2D_SignatureFilter(TheType,TheSignature); -// TheAIS2DContext()->AddFilter(F1); - } - - // step 2 : wait for the selection... -// Standard_Boolean IsGood (Standard_False); -// Standard_Integer NbPick(0); - Standard_Boolean NbPickGood (0), NbToReach (arr->Length()); - Standard_Integer NbPickFail(0); - Standard_Integer argccc = 5; - const char *bufff[] = { "A", "B", "C","D", "E" }; - const char **argvvv = (const char **) bufff; - - while (NbPickGood < NbToReach && NbPickFail <= MaxPick) - { - while (ViewerMainLoop2d(argccc,argvvv)) {} -/* Standard_Integer NbStored = TheAIS2DContext()->NbSelected(); - if((unsigned int ) NbStored != NbPickGood) - NbPickGood= NbStored; - else - NbPickFail++; - cout<<"NbPicked = "<= NbToReach) return Standard_False; - - /* - Standard_Integer i(0); - for(TheAIS2DContext()->InitSelected(); - TheAIS2DContext()->MoreSelected(); - TheAIS2DContext()->NextSelected()){ - i++; - Handle(AIS2D_InteractiveObject) IO = TheAIS2DContext()->SelectedInteractive(); - arr->SetValue(i,IO); - }*/ - - if (curindex > 0) TheAIS2DContext()->CloseLocalContext(curindex); - return Standard_True; -} - -//======================================================================= -//function : PickObject -//purpose : -//======================================================================= -/*Handle(AIS2D_InteractiveObject) Viewer2dTest::PickObject - (const AIS2D_KindOfInteractive TheType, - const Standard_Integer TheSignature, - const Standard_Integer MaxPick) -{ - Handle(AIS2D_InteractiveObject) IO; - Standard_Integer curindex = (TheType == AIS2D_KOI_None) ? 0 : TheAIS2DContext()->OpenLocalContext(); - - // step 1: prepare the data - - if(curindex !=0){ - Handle(AIS2D_SignatureFilter) F1 = new AIS2D_SignatureFilter(TheType,TheSignature); - TheAIS2DContext()->AddFilter(F1); - } - - // step 2 : wait for the selection... - Standard_Boolean IsGood (Standard_False); - Standard_Integer NbPick(0); - Standard_Integer argccc = 5; - char *bufff[] = { "VPick", "X", "VPickY","VPickZ", "VPickShape" }; - char **argvvv = bufff; - - - while(!IsGood && NbPick<= MaxPick){ - while(ViewerMainLoop2d(argccc,argvvv)){} - IsGood = (TheAIS2DContext()->NbSelected()>0) ; - NbPick++; - cout<<"Nb Pick :"<InitSelected(); - IO = TheAIS2DContext()->SelectedInteractive(); - } - - if(curindex!=0) - TheAIS2DContext()->CloseLocalContext(curindex); - return IO; -}*/ - -//======================================================================= -//function : PickShape -//purpose : First Activate the rightmode + Put Filters to be able to -// pick objets that are of type ... -//======================================================================= -TopoDS_Shape Viewer2dTest::PickShape (const TopAbs_ShapeEnum /*TheType*/, - const Standard_Integer MaxPick) -{ - // step 1: prepare the data - Standard_Integer curindex = TheAIS2DContext()->OpenLocalContext(); - TopoDS_Shape result; - -/* if(TheType==TopAbs_SHAPE) - { - Handle(AIS2D_TypeFilter) F1 = new AIS2D_TypeFilter(AIS2D_KOI_Shape); - TheAIS2DContext()->AddFilter(F1); - } - else - { - Handle(StdSelect_ShapeTypeFilter) TF = new StdSelect_ShapeTypeFilter(TheType); - TheAIS2DContext()->AddFilter(TF); - TheAIS2DContext()->ActivateStandardMode(TheType); - }*/ - - // step 2 : wait for the selection... - Standard_Boolean NoShape (Standard_True); - Standard_Integer NbPick (0); - Standard_Integer argccc = 5; - const char *bufff[] = { "VPick", "X", "VPickY","VPickZ", "VPickShape" }; - const char **argvvv = (const char **) bufff; - - while (NoShape && NbPick <= MaxPick) - { - while (ViewerMainLoop2d(argccc,argvvv)) {} -// NoShape = (TheAIS2DContext()->NbSelected() == 0); - NbPick++; - cout << "Nb Pick :" << NbPick << endl; - } - - // step3 get result. - if (!NoShape) - { -/* TheAIS2DContext()->InitSelected(); - if (TheAIS2DContext()->HasSelectedShape()) - result = TheAIS2DContext()->SelectedShape(); - else - { - Handle(AIS2D_InteractiveObject) IO = TheAIS2DContext()->SelectedInteractive(); - result = (*((Handle(AIS2D_ProjShape)*) &IO))->Shape(); - }*/ - } - - if (curindex > 0) TheAIS2DContext()->CloseLocalContext(curindex); - return result; -} - -//======================================================================= -//function : PickShapes -//purpose : -//======================================================================= -Standard_Boolean Viewer2dTest::PickShapes (const TopAbs_ShapeEnum /*TheType*/, - Handle(TopTools_HArray1OfShape)& thearr, - const Standard_Integer /*MaxPick*/) -{ - Standard_Integer Taille = thearr->Length(); - if (Taille > 1) - cout << " WARNING : Pick with Shift+ MB1 for Selection of more than 1 object" << endl; - - // step 1: prepare the data - Standard_Integer curindex = TheAIS2DContext()->OpenLocalContext(); -/* if (TheType == TopAbs_SHAPE) - { - Handle(AIS2D_TypeFilter) F1 = new AIS2D_TypeFilter(AIS2D_KOI_Shape); - TheAIS2DContext()->AddFilter(F1); - } - else - { - Handle(StdSelect_ShapeTypeFilter) TF = new StdSelect_ShapeTypeFilter(TheType); - TheAIS2DContext()->AddFilter(TF); - TheAIS2DContext()->ActivateStandardMode(TheType); - }*/ - - // step 2 : wait for the selection... - Standard_Boolean NbToReach (thearr->Length()); - Standard_Integer NbPickFail (0); - /* - Standard_Boolean NbPickGood (0) ; - Standard_Integer argccc = 5; - char *bufff[] = { "A", "B", "C","D", "E" }; - char **argvvv = bufff; - - while (NbPickGood < NbToReach && NbPickFail <= MaxPick) - { - while (ViewerMainLoop2d(argccc,argvvv)) {} - Standard_Integer NbStored = TheAIS2DContext()->NbSelected(); - if ((unsigned int ) NbStored != NbPickGood) - NbPickGood = NbStored; - else - NbPickFail++; - cout<<"NbPicked = "<= NbToReach) return Standard_False; - - /* - Standard_Integer i(0); - for (TheAIS2DContext()->InitSelected(); - TheAIS2DContext()->MoreSelected(); - TheAIS2DContext()->NextSelected()) - { - i++; - if(TheAIS2DContext()->HasSelectedShape()) - thearr->SetValue(i,TheAIS2DContext()->SelectedShape()); - else - { - Handle(AIS2D_InteractiveObject) IO = TheAIS2DContext()->SelectedInteractive(); - thearr->SetValue(i,(*((Handle(AIS2D_ProjShape)*) &IO))->Shape()); - } - }*/ - - TheAIS2DContext()->CloseLocalContext(curindex); - return Standard_True; -} - -//===================================================================== -//========================= for testing Draft and Rib ================= -//===================================================================== -#include -#include -#include -#include -#include -#include -#include -#include -#include - -//======================================================================= -//function : IsValid2d -//purpose : -//======================================================================= -static Standard_Boolean IsValid2d (const TopTools_ListOfShape& theArgs, - const TopoDS_Shape& theResult, - const Standard_Boolean closedSolid, - const Standard_Boolean GeomCtrl) -{ - OSD_Environment check ("DONT_SWITCH_IS_VALID") ; - TCollection_AsciiString checkValid = check.Value(); - Standard_Boolean ToCheck = Standard_True; - if (!checkValid.IsEmpty()) { -#ifdef DEB - cout <<"DONT_SWITCH_IS_VALID positionnee a :"< 4) { // == 5 - rev = atoi(argv[5]); - Rev = (rev)? Standard_True : Standard_False; - } - - TopoDS_Face face2 = TopoDS::Face(Plane); -// if (!AIS2D::GetPlaneFromFace(face2, aPln, aSurf, aSurfType, Offset)) -// { -// cout << "TEST : Can't find plane" << endl; -// return 1; -// } - - aDir = aPln.Axis().Direction(); - if (!aPln.Direct()) - aDir.Reverse(); - if (Plane.Orientation() == TopAbs_REVERSED) - aDir.Reverse(); - cout << "TEST : gp::Resolution() = " << gp::Resolution() << endl; - - BRepOffsetAPI_DraftAngle Draft (Solid); - - if(Abs(anAngle)< Precision::Angular()) { - cout << "TEST : NULL angle" << endl; - return 1;} - - if(Rev) anAngle = - anAngle; - Draft.Add (Face, aDir, anAngle, aPln); - Draft.Build (); - if (!Draft.IsDone()) { - cout << "TEST : Draft Not DONE " << endl; - return 1; - } - TopTools_ListOfShape Larg; - Larg.Append(Solid); - if (!IsValid2d(Larg,Draft.Shape(),Standard_True,Standard_False)) - { - cout << "TEST : DesignAlgo returns Not valid" << endl; - return 1; - } - - Handle(AIS2D_InteractiveContext) Ctx = Viewer2dTest::GetAIS2DContext(); - Handle(AIS2D_ProjShape) ais = new AIS2D_ProjShape(); - ais->Add(Draft.Shape()); - - if (!ais.IsNull()) - { -// ais->SetColor(DEFAULT_COLOR); -// ais->SetMaterial(DEFAULT_MATERIAL); - // Display the AIS2D_ProjShape without redraw - Ctx->Display(ais, Standard_False); - - const char *Name = "draft1"; - Standard_Boolean IsBound = GetMapOfAIS2D().IsBound2(Name); - if (IsBound) - { - Handle(AIS2D_InteractiveObject) an_object = GetMapOfAIS2D().Find2(Name); -// Ctx->Remove(an_object, Standard_True); - GetMapOfAIS2D().UnBind2(Name); - } - GetMapOfAIS2D().Bind(ais, Name); - } - Ctx->Display(ais, Standard_True); - return 0; -} - -//============================================================================ -// MyCommands -//============================================================================ -void Viewer2dTest::MyCommands (Draw_Interpretor& theCommands) -{ - DrawTrSurf::BasicCommands(theCommands); - const char* group = "2D AIS Viewer - Check Features Operations commands"; - - theCommands.Add("Draft2d", - "Draft2d Solid Face Plane Angle Reverse", - __FILE__, TDraft2d, group); //Draft_Modification -} - -//============================================================================ -// All 2D AIS Viewer Commands -//============================================================================ -void Viewer2dTest::Commands (Draw_Interpretor& theCommands) -{ - Viewer2dTest::GeneralCommands(theCommands); - Viewer2dTest::ViewerCommands (theCommands); - Viewer2dTest::DisplayCommands(theCommands); - Viewer2dTest::ObjectCommands (theCommands); -} diff --git a/src/Viewer2dTest/Viewer2dTest_CMPLRS.edl b/src/Viewer2dTest/Viewer2dTest_CMPLRS.edl deleted file mode 100755 index a962f5ff61..0000000000 --- a/src/Viewer2dTest/Viewer2dTest_CMPLRS.edl +++ /dev/null @@ -1,25 +0,0 @@ --- Copyright (c) 1999-2012 OPEN CASCADE SAS --- --- The content of this file is subject to the Open CASCADE Technology Public --- License Version 6.5 (the "License"). You may not use the content of this file --- except in compliance with the License. Please obtain a copy of the License --- at http://www.opencascade.org and read it completely before using this file. --- --- The Initial Developer of the Original Code is Open CASCADE S.A.S., having its --- main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. --- --- The Original Code and all software distributed under the License is --- distributed on an "AS IS" basis, without warranty of any kind, and the --- Initial Developer hereby disclaims all such warranties, including without --- limitation, any warranties of merchantability, fitness for a particular --- purpose or non-infringement. Please see the License for the specific terms --- and conditions governing the rights and limitations under the License. - -@ifnotdefined ( %Viewer2dTest_CMPLRS ) then -@set %Viewer2dTest_CMPLRS = ""; - - @uses "CSF.edl" ; - - @string %CMPLRS_CXX_Options += " " %CSF_TCL_INCLUDE; - -@endif; diff --git a/src/Viewer2dTest/Viewer2dTest_DisplayCommands.cxx b/src/Viewer2dTest/Viewer2dTest_DisplayCommands.cxx deleted file mode 100755 index 1cc9716c76..0000000000 --- a/src/Viewer2dTest/Viewer2dTest_DisplayCommands.cxx +++ /dev/null @@ -1,2774 +0,0 @@ -// Created on: 2002-01-22 -// Created by: Julia DOROVSKIKH -// Copyright (c) 2002-2012 OPEN CASCADE SAS -// -// The content of this file is subject to the Open CASCADE Technology Public -// License Version 6.5 (the "License"). You may not use the content of this file -// except in compliance with the License. Please obtain a copy of the License -// at http://www.opencascade.org and read it completely before using this file. -// -// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its -// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. -// -// The Original Code and all software distributed under the License is -// distributed on an "AS IS" basis, without warranty of any kind, and the -// Initial Developer hereby disclaims all such warranties, including without -// limitation, any warranties of merchantability, fitness for a particular -// purpose or non-infringement. Please see the License for the specific terms -// and conditions governing the rights and limitations under the License. - - -#include - -#include -#include -#include - -#include - -#include - -#include -#include - -#include -#include - -#include - -#include -#include -#include - -#include - -#include - -#include - -#include -#include - -#include -#include - -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#define OCC190 // jfa 04/03/2002 // for vertices load -#define OCC154 // jfa 06/03/2002 // for correct erasing - -#define DEFAULT_COLOR Quantity_NOC_GOLDENROD -#define DEFAULT_MATERIAL Graphic3d_NOM_BRASS - -Viewer2dTest_DoubleMapOfInteractiveAndName& GetMapOfAIS2D(); -Handle(AIS2D_InteractiveContext)& TheAIS2DContext(); -TopoDS_Shape GetShapeFromName2d (const char* name); - -//============================================================================== -//function : GetAIS2DShapeFromName -//purpose : Compute an AIS2D_ProjShape from a draw variable or a file name -//============================================================================== -Handle(AIS2D_InteractiveObject) GetAIS2DShapeFromName - (const char* name, gp_Ax2 anAx2 = gp::XOY()) -{ - Handle(AIS2D_InteractiveObject) retsh; - - if (GetMapOfAIS2D().IsBound2(name)) - { - Handle(AIS2D_InteractiveObject) IO = GetMapOfAIS2D().Find2(name); -// if(IO->Type() == AIS2D_KOI_Shape) -// if (IO->Signature() == 0){ -// retsh = *((Handle(AIS2D_ProjShape)*)&IO); -// } -// else - cout << "an Object which is not an AIS2D_ProjShape already has this name!!!" << endl; - return retsh; - } - - TopoDS_Shape S = GetShapeFromName2d(name); - if (!S.IsNull()) - { -#ifdef OCC190 - if (S.ShapeType() == TopAbs_VERTEX) - { - TopoDS_Vertex aVert = TopoDS::Vertex(S); - gp_Pnt aPnt = BRep_Tool::Pnt(aVert); - - gp_Trsf aTrsf; - gp_Ax3 aToSystem (anAx2); - aTrsf.SetTransformation(aToSystem); - aPnt.Transform(aTrsf); - - Handle(V2d_View) V = Viewer2dTest::CurrentView(); - retsh = new AIS2D_InteractiveObject(); - retsh->SetView(V->View()); - -#define VERTEXMARKER 2 -#define DEFAULTMARKERSIZE 3.0 - - Handle(Graphic2d_Marker) vertex = new Graphic2d_Marker - (retsh, VERTEXMARKER, aPnt.X(), aPnt.Y(), DEFAULTMARKERSIZE, DEFAULTMARKERSIZE, 0.0); - } - else -#endif - { - HLRAlgo_Projector aProjector (anAx2); - Handle(AIS2D_ProjShape) retprsh = new AIS2D_ProjShape(aProjector); - retprsh->Add(S); - retsh = retprsh; - } - } - return retsh; -} - -//======================================================================= -//function : GetColorFromName2d -//purpose : get the Quantity_NameOfColor from a string -//======================================================================= -static Quantity_NameOfColor GetColorFromName2d (const char *name) -{ - Quantity_NameOfColor ret = DEFAULT_COLOR; - - Standard_Boolean Found = Standard_False; - Standard_CString colstring; - for (Standard_Integer i = 0; i <= 514 && !Found; i++) - { - colstring = Quantity_Color::StringName(Quantity_NameOfColor(i)); - if (!strcasecmp(name,colstring)) - { - ret = (Quantity_NameOfColor)i; - Found = Standard_True; - } - } - - return ret; -} -#if 0 -//======================================================================= -//function : GetMaterialFromName2d -//purpose : get the Graphic3d_NameOfMaterial from a string -//======================================================================= -static Graphic3d_NameOfMaterial GetMaterialFromName2d (const char *name) -{ - Graphic3d_NameOfMaterial mat = DEFAULT_MATERIAL; - - if ( !strcasecmp(name,"BRASS" ) ) mat = Graphic3d_NOM_BRASS; - else if ( !strcasecmp(name,"BRONZE" ) ) mat = Graphic3d_NOM_BRONZE; - else if ( !strcasecmp(name,"COPPER" ) ) mat = Graphic3d_NOM_COPPER; - else if ( !strcasecmp(name,"GOLD" ) ) mat = Graphic3d_NOM_GOLD; - else if ( !strcasecmp(name,"PEWTER" ) ) mat = Graphic3d_NOM_PEWTER; - else if ( !strcasecmp(name,"SILVER" ) ) mat = Graphic3d_NOM_SILVER; - else if ( !strcasecmp(name,"STEEL" ) ) mat = Graphic3d_NOM_STEEL; - else if ( !strcasecmp(name,"METALIZED" ) ) mat = Graphic3d_NOM_METALIZED; - else if ( !strcasecmp(name,"STONE" ) ) mat = Graphic3d_NOM_STONE; - else if ( !strcasecmp(name,"CHROME" ) ) mat = Graphic3d_NOM_CHROME; - else if ( !strcasecmp(name,"ALUMINIUM" ) ) mat = Graphic3d_NOM_ALUMINIUM; - else if ( !strcasecmp(name,"STONE" ) ) mat = Graphic3d_NOM_STONE; - else if ( !strcasecmp(name,"NEON_PHC" ) ) mat = Graphic3d_NOM_NEON_PHC; - else if ( !strcasecmp(name,"NEON_GNC" ) ) mat = Graphic3d_NOM_NEON_GNC; - else if ( !strcasecmp(name,"PLASTER" ) ) mat = Graphic3d_NOM_PLASTER; - else if ( !strcasecmp(name,"SHINY_PLASTIC" ) ) mat = Graphic3d_NOM_SHINY_PLASTIC; - else if ( !strcasecmp(name,"SATIN" ) ) mat = Graphic3d_NOM_SATIN; - else if ( !strcasecmp(name,"PLASTIC" ) ) mat = Graphic3d_NOM_PLASTIC; - else if ( !strcasecmp(name,"OBSIDIAN" ) ) mat = Graphic3d_NOM_OBSIDIAN; - else if ( !strcasecmp(name,"JADE" ) ) mat = Graphic3d_NOM_JADE; - -#ifdef DEB - cout << " materiau" << name <<" "<ShiftSelect(); - else EM->Select(); - - const Handle(AIS2D_InteractiveContext) aContext = EM->Context(); - - if (!aContext->HasOpenedContext()) - { -// aContext->InitCurrent(); -/* while ( aContext->MoreCurrent() ) { - Handle(AIS2D_InteractiveObject) aisPickedShape = - Handle(AIS2D_InteractiveObject)::DownCast(aContext->Current()); - - const char *name = (GetMapOfAIS2D().IsBound1(aisPickedShape))? - GetMapOfAIS2D().Find1(aisPickedShape).ToCString() : - "????"; - Handle(AIS2D_ProjShape) TheRealSh = Handle(AIS2D_ProjShape)::DownCast(aisPickedShape); - if(!TheRealSh.IsNull()){ - cout << "Current is " << name - << " (" << GetTypeNameFromShape2d(TheRealSh->Shape()) - << ")" << endl; - } - ret = aisPickedShape; - if(!TheRealSh.IsNull()){ - if ( pick && argc > 4 ) { - DBRep::Set(argv[4], TheRealSh->Shape()); - } - } - aContext->NextCurrent(); - }*/ - } - else - { - // A LocalContext is opened, the use xxxxSelected() - // to select an object and its SubShape -/* aContext->InitSelected(); - while ( aContext->MoreSelected() ) { - if ( !aContext->HasSelectedShape() ) { - } - else { - TopoDS_Shape PickedShape = aContext->SelectedShape(); - if ( pick && argc > 5 ) { - DBRep::Set(argv[5], PickedShape); - } - } - - if ( aContext->Interactive().IsNull() ) { - cout << "??? (No InteractiveObject selected)" << endl; - } - else { - Handle(AIS2D_InteractiveObject) aisPicked = - Handle(AIS2D_InteractiveObject)::DownCast(aContext->Interactive()); - ret = aisPicked; - Handle(AIS2D_ProjShape) aisPickedShape = Handle(AIS2D_ProjShape)::DownCast(aisPicked); - - // Get back its name - const char *name = ( GetMapOfAIS2D().IsBound1(aisPicked) )? - GetMapOfAIS2D().Find1(aisPicked).ToCString() : - "????"; - - if(!aisPickedShape.IsNull()){ - if ( pick && argc > 4 ) { - // Create a draw variable to store the wohole shape - // for vpick command - DBRep::Set(argv[4], aisPickedShape->Shape()); - } - - cout << name << " (" << GetTypeNameFromShape2d(aisPickedShape->Shape()) - << ")" << endl ; - } - } - // Goto the next selected object - aContext->NextSelected(); - }*/ - } - return ret; -} - -//============================================================================== -//function : Displays,Erase... -//purpose : -//Draw arg : -//============================================================================== -static int VwrTst_DispErase2d (const Handle(AIS2D_InteractiveObject)& IO, - const Standard_Integer Mode, - const Standard_Integer TypeOfOperation, - const Standard_Boolean Upd) -{ - Handle(AIS2D_InteractiveContext) Ctx = Viewer2dTest::GetAIS2DContext(); - - switch (TypeOfOperation) - { - case 1: - Ctx->Display(IO,Mode,Upd); - break; - case 2: - Ctx->Erase(IO,Mode,Upd); - break; - case 3: -// if(IO.IsNull()) -// Ctx->SetDisplayMode((AIS2D_DisplayMode)Mode,Upd); -// else -// Ctx->SetDisplayMode(IO,Mode,Upd); - break; - case 4: -// if(IO.IsNull()) -// Ctx->SetDisplayMode(0,Upd); -// else -// Ctx->UnsetDisplayMode(IO,Upd); - break; - } - - return 0; -} - -#if 0 -//======================================================================= -//function :V2dDispMode -//purpose : -//======================================================================= -static int V2dDispMode (Draw_Interpretor& , Standard_Integer argc, const char** argv) -{ - TCollection_AsciiString name; - if (argc > 3) return 1; - - // display others presentations - Standard_Integer TypeOfOperation = (strcasecmp(argv[0],"v2ddispmode") == 0)? 1: - (strcasecmp(argv[0],"v2derasemode") == 0) ? 2 : - (strcasecmp(argv[0],"v2dsetdispmode") == 0) ? 3 : - (strcasecmp(argv[0],"v2dunsetdispmode") == 0) ? 4 : -1; - - Handle(AIS2D_InteractiveContext) Ctx = Viewer2dTest::GetAIS2DContext(); - - //unset displaymode.. comportement particulier... - if (TypeOfOperation == 4) - { - if (argc == 1) - { -/* if(Ctx->NbCurrents()==0 || - Ctx->NbSelected()==0){ - Handle(AIS2D_InteractiveObject) IO; - VwrTst_DispErase2d(IO,-1,4,Standard_False); - } - else if(!Ctx->HasOpenedContext()){ - for(Ctx->InitCurrent();Ctx->MoreCurrent();Ctx->NextCurrent()) - VwrTst_DispErase2d(Ctx->Current(),-1,4,Standard_False); - } - else{ - for(Ctx->InitSelected();Ctx->MoreSelected();Ctx->NextSelected()) - VwrTst_DispErase2d(Ctx->Interactive(),-1,4,Standard_False);}*/ - Ctx->UpdateCurrentViewer(); - } - else - { - Handle(AIS2D_InteractiveObject) IO; - name = argv[1]; - if (GetMapOfAIS2D().IsBound2(name)) - { - IO = GetMapOfAIS2D().Find2(name); - VwrTst_DispErase2d(IO,-1,4,Standard_True); - } - } - } - else if (argc == 2) - { -// Standard_Integer Dmode = atoi(argv[1]); -// if(Ctx->NbCurrents()==0 && TypeOfOperation==3){ -// Handle(AIS2D_InteractiveObject) IO; -// VwrTst_DispErase2d(IO,Dmode,TypeOfOperation,Standard_True); -// } - if (!Ctx->HasOpenedContext()) - { - // set/unset display mode sur le Contexte... -// for(Ctx->InitCurrent();Ctx->MoreCurrent();Ctx->NextCurrent()){ -// VwrTst_DispErase2d(Ctx->Current(),Dmode,TypeOfOperation,Standard_False); -// } - Ctx->UpdateCurrentViewer(); - } - else - { -// for(Ctx->InitSelected();Ctx->MoreSelected();Ctx->NextSelected()) -// Ctx->Display(Ctx->Interactive(),Dmode); - } - } - else - { - Handle(AIS2D_InteractiveObject) IO; - name = argv[1]; - if (GetMapOfAIS2D().IsBound2(name)) - IO = GetMapOfAIS2D().Find2(name); - VwrTst_DispErase2d(IO,atoi(argv[2]),TypeOfOperation,Standard_True); - } - - return 0; -} -#endif - -//============================================================================== -//function : V2dSetBGColor -//purpose : v2dsetbgcolor colorname : change background color -//============================================================================== -static int V2dSetBGColor (Draw_Interpretor& , Standard_Integer argc, const char** argv) -{ - if (argc != 2) - { - cout << "Usage : v2dsetbgcolor colorname" << endl; - return 1; - } - Handle(V2d_View) V = Viewer2dTest::CurrentView(); - if (V.IsNull()) return 1; - - V->SetBackground(GetColorFromName2d(argv[1])); - V->Viewer()->Update(); - return 0; -} - -//============================================================================== -//function : V2dColor -//purpose : change the color of a selected or named or displayed shape -//Draw arg : v2dsetcolor [name] color -//============================================================================== -static int V2dSetUnsetColor (Handle(AIS2D_InteractiveObject) theShape, - Standard_Boolean HaveToSet, - Quantity_NameOfColor theColor = Quantity_NOC_WHITE) -{ - theShape->SetContext(TheAIS2DContext()); - - Handle(Graphic2d_Primitive) aPrim; - Handle(Prs2d_AspectRoot) anAspect; - Standard_Integer i = 1, n = theShape->Length(); - for (; i <= n; i++) - { - aPrim = theShape->Primitive(i); - if (theShape->HasAspect(aPrim)) - { - anAspect = theShape->GetAspect(aPrim); - if (anAspect->GetAspectName() == Prs2d_AN_LINE) break; - else anAspect = NULL; - } - } - - if (HaveToSet) - { - if (anAspect.IsNull()) - { - theShape->SetAspect - (new Prs2d_AspectLine(theColor, Aspect_TOL_SOLID, Aspect_WOL_THIN, - theColor, Graphic2d_TOPF_FILLED)); - } - else - { - Handle(Prs2d_AspectLine) anAspectLine = Handle(Prs2d_AspectLine)::DownCast(anAspect); - anAspectLine->SetTypeOfFill(Graphic2d_TOPF_FILLED); - anAspectLine->SetColor(theColor); - anAspectLine->SetInterColor(theColor); - theShape->SetAspect(anAspect); - } - } - else // unset color - { - Handle(Prs2d_AspectLine) anAspectLine; - if ( !anAspect.IsNull() ) - anAspectLine = Handle(Prs2d_AspectLine)::DownCast(anAspect); - else - anAspectLine = new Prs2d_AspectLine(); - - anAspectLine->SetTypeOfFill(Graphic2d_TOPF_EMPTY); - if (theShape->IsKind(STANDARD_TYPE(AIS2D_ProjShape))) - { - anAspectLine->SetColor(Quantity_NOC_YELLOW); - anAspectLine->SetInterColor(Quantity_NOC_YELLOW); - } - else - { - anAspectLine->SetColor(Quantity_NOC_WHITE); - anAspectLine->SetInterColor(Quantity_NOC_WHITE); - } - theShape->SetAspect( anAspectLine ); - } - - return 0; -} - -static int V2dColor (Draw_Interpretor& , Standard_Integer argc, const char** argv) -{ - Standard_Boolean ThereIsArgument = Standard_False; - Standard_Boolean HaveToSet = Standard_False; - - if (strcasecmp(argv[0],"v2dsetcolor") == 0) HaveToSet = Standard_True; - - Quantity_NameOfColor aColor = Quantity_NOC_BLACK; - if (HaveToSet) - { - if (argc < 2 || argc > 3) - { - cout << "Usage: v2dsetcolor [name] color" << endl; - return 1; - } - if (argc == 3) - { - ThereIsArgument = Standard_True; - aColor = GetColorFromName2d(argv[2]); - } - else - { - aColor = GetColorFromName2d(argv[1]); - } - } - else - { - if (argc > 2) - { - cout << "Usage: v2dunsetcolor [name]" << endl; - return 1; - } - if (argc == 2) ThereIsArgument = Standard_True; - } - - if (Viewer2dTest::CurrentView().IsNull()) return -1; - TheAIS2DContext()->CloseLocalContext(); - - if (ThereIsArgument) - { - TCollection_AsciiString name = argv[1]; - - if (GetMapOfAIS2D().IsBound2(name)) - { - Handle(AIS2D_InteractiveObject) aShape = GetMapOfAIS2D().Find2(name); - V2dSetUnsetColor(aShape, HaveToSet, aColor); - } - } - else - { - Standard_Boolean hasCurrent = Standard_False; - Viewer2dTest_DoubleMapIteratorOfDoubleMapOfInteractiveAndName it (GetMapOfAIS2D()); - for (; it.More() && !hasCurrent; it.Next()) - { - if (TheAIS2DContext()->IsCurrent(it.Key1())) hasCurrent = Standard_True; - } - for (it.Reset(); it.More(); it.Next()) - { - Handle(AIS2D_InteractiveObject) aShape = it.Key1(); - if ((hasCurrent && TheAIS2DContext()->IsCurrent(aShape)) || !hasCurrent) - { - V2dSetUnsetColor(aShape, HaveToSet, aColor); - } - } -// TheAIS2DContext()->UpdateCurrentViewer(); - } - return 0; -} - -#if 0 -//============================================================================== -//function : V2dTransparency -//purpose : change the transparency of a selected or named or displayed shape -//Draw arg : v2dsettransp [name] TransparencyCoeficient -//============================================================================== -static int V2dTransparency (Draw_Interpretor& , Standard_Integer argc, const char** argv) -{ - Standard_Boolean ThereIsArgument; - Standard_Boolean HaveToSet; - - if (strcasecmp(argv[0], "v2dsettransp") == 0) - HaveToSet = Standard_True; - else - HaveToSet = Standard_False; - - if (HaveToSet) - { - if (argc < 2 || argc > 3) - { - cout << "Usage: v2dsettransp [name] color" << endl; - return 1; - } - if (argc == 2) ThereIsArgument = Standard_False; - else ThereIsArgument = Standard_True; - } - else - { - if (argc > 2) - { - cout << "Usage: v2dunsettransp [name]" << endl; - return 1; - } - if (argc == 2) ThereIsArgument = Standard_True; - else ThereIsArgument = Standard_False; - } - - if (Viewer2dTest::CurrentView().IsNull()) return -1; - TheAIS2DContext()->CloseLocalContext(); - - if (ThereIsArgument) - { - TCollection_AsciiString name = argv[1]; - if (GetMapOfAIS2D().IsBound2(name)) - { - Handle(AIS2D_InteractiveObject) ashape = GetMapOfAIS2D().Find2(name); -// if(HaveToSet) -// TheAIS2DContext()->SetTransparency(ashape,atof(argv[2]) ); -// else -// TheAIS2DContext()->UnsetTransparency(ashape); - } - } - else - { -// if (TheAIS2DContext()->NbCurrents() > 0) - { -/* for (TheAIS2DContext()->InitCurrent(); TheAIS2DContext()->MoreCurrent(); - TheAIS2DContext()->NextCurrent()) - { - Handle(AIS2D_InteractiveObject) ashape = TheAIS2DContext()->Current(); - if (HaveToSet) - { - TheAIS2DContext()->SetTransparency(ashape, atof(argv[1]), Standard_False); - } - else - TheAIS2DContext()->UnsetTransparency(ashape, Standard_False); - }*/ - - TheAIS2DContext()->UpdateCurrentViewer(); - } -// else // shape not defined (neither current, nor named) - { - Viewer2dTest_DoubleMapIteratorOfDoubleMapOfInteractiveAndName it (GetMapOfAIS2D()); - while (it.More()) - { - Handle(AIS2D_InteractiveObject) ashape = it.Key1(); -// if(HaveToSet) -// TheAIS2DContext()->SetTransparency(ashape,atof(argv[1]),Standard_False); -// else -// TheAIS2DContext()->UnsetTransparency(ashape,Standard_False); - it.Next(); - } - TheAIS2DContext()->UpdateCurrentViewer(); - } - } - return 0; -} -#endif - -#if 0 -//============================================================================== -//function : V2dMaterial -//purpose : change the Material of a selected or named or displayed shape -//Draw arg : v2dmaterial [Name] Material -//============================================================================== -static int V2dMaterial (Draw_Interpretor& , Standard_Integer argc, const char** argv) -{ - Standard_Boolean ThereIsName; - Standard_Boolean HaveToSet; - - if (strcasecmp(argv[0], "v2dsetmaterial") == 0) HaveToSet = Standard_True; - else HaveToSet = Standard_False; - - if (HaveToSet) - { - if (argc < 2 || argc > 3) - { - cout << "Usage: v2dsetmaterial [name] material" << endl; - return 1; - } - if (argc == 2) ThereIsName = Standard_False; - else ThereIsName = Standard_True; - } - else - { - if (argc > 2) - { - cout << "Usage: v2dunsetmaterial [name]" << endl; - return 1; - } - if (argc == 2) ThereIsName = Standard_True; - else ThereIsName = Standard_False; - } - - if (Viewer2dTest::CurrentView().IsNull()) return -1; - TheAIS2DContext()->CloseLocalContext(); - - if (ThereIsName) - { - TCollection_AsciiString name = argv[1]; - if (GetMapOfAIS2D().IsBound2(name)) - { - Handle(AIS2D_InteractiveObject) ashape = GetMapOfAIS2D().Find2(name); - if (HaveToSet) - { -// TheAIS2DContext()->SetMaterial (ashape,GetMaterialFromName2d (argv[2]) ); - } - else - { -// TheAIS2DContext()->UnsetMaterial(ashape); - } - } - } - else - { -// if (TheAIS2DContext()->NbCurrents() > 0) - { -/* for (TheAIS2DContext()->InitCurrent(); TheAIS2DContext()->MoreCurrent(); - TheAIS2DContext()->NextCurrent()) - { - Handle(AIS2D_InteractiveObject) ashape = TheAIS2DContext()->Current(); - if (HaveToSet) - { - TheAIS2DContext()->SetMaterial(ashape, GetMaterialFromName2d(argv[1]), Standard_False); - } - else - TheAIS2DContext()->UnsetMaterial(ashape, Standard_False); - }*/ - TheAIS2DContext()->UpdateCurrentViewer(); - } -// else // shape not defined (neither current, nor named) - { - Viewer2dTest_DoubleMapIteratorOfDoubleMapOfInteractiveAndName it (GetMapOfAIS2D()); - while (it.More()) - { - Handle(AIS2D_InteractiveObject) ashape = it.Key1(); - -// if (HaveToSet) -// TheAIS2DContext()->SetMaterial(ashape,GetMaterialFromName2d(argv[1]),Standard_False); -// else TheAIS2DContext()->UnsetMaterial(ashape,Standard_False); - it.Next(); - } - TheAIS2DContext()->UpdateCurrentViewer(); - } - } - return 0; -} -#endif - -//============================================================================== -//function : V2dWidth -//purpose : change the width of the edges of a selected or named or displayed shape -//Draw arg : v2dsetwidth [Name] WidthEnum(THIN MEDIUM THICK VERYTHICK) -//============================================================================== -static int V2dSetUnsetWidth (Handle(AIS2D_InteractiveObject) theShape, - Standard_Boolean HaveToSet, - Aspect_WidthOfLine theWOL = Aspect_WOL_THIN) -{ - theShape->SetContext(TheAIS2DContext()); - - Handle(Graphic2d_Primitive) aPrim; - Handle(Prs2d_AspectRoot) anAspect; - Standard_Integer i = 1, n = theShape->Length(); - for (; i <= n; i++) - { - aPrim = theShape->Primitive(i); - if (theShape->HasAspect(aPrim)) - { - anAspect = theShape->GetAspect(aPrim); - if (anAspect->GetAspectName() == Prs2d_AN_LINE) break; - else anAspect = NULL; - } - } - - if (HaveToSet) - { - if (anAspect.IsNull()) - { - Quantity_NameOfColor aColor; - if (theShape->IsKind(STANDARD_TYPE(AIS2D_ProjShape))) - { - aColor = Quantity_NOC_YELLOW; - } - else - { - aColor = Quantity_NOC_WHITE; - } - anAspect = new Prs2d_AspectLine(aColor, Aspect_TOL_SOLID, theWOL, - aColor, Graphic2d_TOPF_EMPTY); - } - else - { - Handle(Prs2d_AspectLine) anAspectLine = Handle(Prs2d_AspectLine)::DownCast(anAspect); - anAspectLine->SetWidth(theWOL); - } - - theShape->SetAspect(anAspect); - } - else // unset width - { - if (!anAspect.IsNull()) - { - Handle(Prs2d_AspectLine) anAspectLine = Handle(Prs2d_AspectLine)::DownCast(anAspect); - anAspectLine->SetWidth(Aspect_WOL_THIN); -// anAspectLine->SetWidthIndex(0); - theShape->SetAspect(anAspect); - } - } - - return 0; -} - -static int V2dWidth (Draw_Interpretor& , Standard_Integer argc, const char** argv) -{ - Standard_Boolean ThereIsArgument = Standard_False; - Standard_Boolean HaveToSet = Standard_False; - - if (strcasecmp(argv[0], "v2dsetwidth") == 0) HaveToSet = Standard_True; - - const char* aStr; - if (HaveToSet) - { - if (argc < 2 || argc > 3) - { - cout << "Usage: v2dsetwidth [name] width" << endl; - return 1; - } - if (argc == 3) - { - ThereIsArgument = Standard_True; - aStr = argv[2]; - } - else - { - aStr = argv[1]; - } - } - else - { - if ( argc > 2 ) - { - cout << "Usage: v2dunsetwidth [name]" << endl; - return 1; - } - if (argc == 2) ThereIsArgument = Standard_True; - } - - if (Viewer2dTest::CurrentView().IsNull()) return -1; - TheAIS2DContext()->CloseLocalContext(); - - Aspect_WidthOfLine aWOL = Aspect_WOL_THIN; - if (HaveToSet) - { - if (strcmp(aStr, "THIN" ) == 0) aWOL = Aspect_WOL_THIN; - else if (strcmp(aStr, "MEDIUM" ) == 0) aWOL = Aspect_WOL_MEDIUM; - else if (strcmp(aStr, "THICK" ) == 0) aWOL = Aspect_WOL_THICK; - else if (strcmp(aStr, "VERYTHICK") == 0) aWOL = Aspect_WOL_VERYTHICK; - else aWOL = Aspect_WOL_USERDEFINED; - } - - if (ThereIsArgument) - { - TCollection_AsciiString name = argv[1]; - - if (GetMapOfAIS2D().IsBound2(name)) - { - Handle(AIS2D_InteractiveObject) aShape = GetMapOfAIS2D().Find2(name); - V2dSetUnsetWidth(aShape, HaveToSet, aWOL); - } - } - else - { - Standard_Boolean hasCurrent = Standard_False; - Viewer2dTest_DoubleMapIteratorOfDoubleMapOfInteractiveAndName it (GetMapOfAIS2D()); - for (; it.More() && !hasCurrent; it.Next()) - { - if (TheAIS2DContext()->IsCurrent(it.Key1())) hasCurrent = Standard_True; - } - for (it.Reset(); it.More(); it.Next()) - { - Handle(AIS2D_InteractiveObject) aShape = it.Key1(); - if ((hasCurrent && TheAIS2DContext()->IsCurrent(aShape)) || !hasCurrent) - { - V2dSetUnsetWidth(aShape, HaveToSet, aWOL); - } - } -// TheAIS2DContext()->UpdateCurrentViewer(); - } - return 0; -} - -//============================================================================== -//function : V2dDisplay -//purpose : Display an object from its name -//Draw arg : v2ddisplay name [projection (Origin(x y z) Normal(dx dy dz) DX(dx dy dz)] -//============================================================================== -static int V2dDisplay (Draw_Interpretor& , Standard_Integer argc, const char** argv) -{ - // Verification des arguments - if (argc != 2 && argc != 11) - { - cout << "Usage: v2ddisplay name [x y z dx dy dz dx1 dy1 dz1]" << endl; - return 1; - } - - if (Viewer2dTest::CurrentView().IsNull()) - { - cout << "2D AIS Viewer Initialization ..." << endl; - Viewer2dTest::ViewerInit(); - cout << "Done" << endl; - } - - TCollection_AsciiString name; - TheAIS2DContext()->CloseLocalContext(); - - name = argv[1]; - gp_Ax2 anAx2 = gp::XOY(); - if (argc == 11) - { - Standard_Real x = atof(argv[2]); - Standard_Real y = atof(argv[3]); - Standard_Real z = atof(argv[4]); - - Standard_Real dx = atof(argv[5]); - Standard_Real dy = atof(argv[6]); - Standard_Real dz = atof(argv[7]); - - Standard_Real dx1 = atof(argv[8]); - Standard_Real dy1 = atof(argv[9]); - Standard_Real dz1 = atof(argv[10]); - - gp_Pnt anOrigin (x, y, z); - gp_Dir aNormal (dx, dy, dz); - gp_Dir aDX (dx1, dy1, dz1); - anAx2 = gp_Ax2(anOrigin, aNormal, aDX); - } - - Standard_Boolean IsBound = GetMapOfAIS2D().IsBound2(name); - Standard_Boolean IsDatum = Standard_False; - Handle(AIS2D_InteractiveObject) aShape; - if (IsBound) - { - aShape = GetMapOfAIS2D().Find2(name); -// if (aShape->Type() == AIS2D_KOI_Datum) - { - IsDatum = Standard_True; - TheAIS2DContext()->Display(aShape, Standard_False); -#ifdef OCC154 - TheAIS2DContext()->HighlightCurrent(); -#endif - } - if (!IsDatum) - { - cout << "Display " << name << endl; - // Get the Shape from a name - TopoDS_Shape NewShape = GetShapeFromName2d((const char *)name.ToCString()); - - // Update the Shape in the AIS2D_ProjShape - Handle(AIS2D_ProjShape) TheRealSh = Handle(AIS2D_ProjShape)::DownCast(aShape); -// if(!TheRealSh.IsNull()) TheRealSh->Set(NewShape); - TheAIS2DContext()->Redisplay(aShape, Standard_False); - TheAIS2DContext()->Display(aShape, Standard_False); - } - aShape.Nullify(); - } - else // Create the AIS2D_ProjShape from a name - { - aShape = GetAIS2DShapeFromName((const char *)name.ToCString(), anAx2); - if (!aShape.IsNull()) - { - GetMapOfAIS2D().Bind(aShape, name); - TheAIS2DContext()->Display(aShape, Standard_False); - } - } - - // Update the screen and redraw the view - TheAIS2DContext()->UpdateCurrentViewer(); - return 0; -} - -//============================================================================== -//function : V2dDonly -//purpose : Display only a selected or named object -// if there is no selected or named object s, the whole viewer is erased -//Draw arg : vdonly [name1] ... [name n] -//============================================================================== -static int V2dDonly (Draw_Interpretor& , Standard_Integer argc, const char** argv) -{ - if (Viewer2dTest::CurrentView().IsNull()) return 1; - - Standard_Boolean ThereIsArgument = argc > 1; - - if (TheAIS2DContext()->HasOpenedContext()) TheAIS2DContext()->CloseLocalContext(); - - if (ThereIsArgument) - { - TheAIS2DContext()->EraseAll(Standard_True, Standard_False); - - for (int i = 1; i < argc; i++) - { - TCollection_AsciiString name = argv[i]; - Standard_Boolean IsBound = GetMapOfAIS2D().IsBound2(name); - if (IsBound) - { - Handle(AIS2D_InteractiveObject) aShape = GetMapOfAIS2D().Find2(name); - TheAIS2DContext()->Display(aShape, Standard_False); - } - } - TheAIS2DContext()->CurrentViewer()->Update(); - } - else - { - Standard_Boolean ThereIsCurrent = Standard_True/*= TheAIS2DContext()->NbCurrents() > 0*/; - if (ThereIsCurrent) - { - Viewer2dTest_DoubleMapIteratorOfDoubleMapOfInteractiveAndName it (GetMapOfAIS2D()); - while (it.More()) - { - Handle(AIS2D_InteractiveObject) aShape = it.Key1(); - if (!TheAIS2DContext()->IsCurrent(aShape)) - TheAIS2DContext()->Erase(aShape, Standard_False); - it.Next(); - } - TheAIS2DContext()->CurrentViewer()->Update(); - } - } - - return 0; -} - -//============================================================================== -//function : V2dErase -//purpose : Erase some selected or named objects. -// If there is no selected or named objects, does nothing -//Draw arg : v2derase [name1] ... [name n] -//============================================================================== -static int V2dErase (Draw_Interpretor& , Standard_Integer argc, const char** argv) -{ - if (Viewer2dTest::CurrentView().IsNull()) return 1; - - if (TheAIS2DContext()->HasOpenedContext()) TheAIS2DContext()->CloseLocalContext(); - - if (argc > 1) // has arguments - { - for (int i = 1; i < argc; i++) - { - TCollection_AsciiString name = argv[i]; - Standard_Boolean IsBound = GetMapOfAIS2D().IsBound2(name); - if (IsBound) - { - Handle(AIS2D_InteractiveObject) aShape = GetMapOfAIS2D().Find2(name); - TheAIS2DContext()->Erase(aShape, Standard_False); - } - } -// TheAIS2DContext()->UpdateCurrentViewer(); - TheAIS2DContext()->CurrentViewer()->Update(); - } - else - { - Viewer2dTest_DoubleMapIteratorOfDoubleMapOfInteractiveAndName it (GetMapOfAIS2D()); - while (it.More()) - { - Handle(AIS2D_InteractiveObject) aShape = it.Key1(); - if (TheAIS2DContext()->IsCurrent(aShape)) - TheAIS2DContext()->Erase(aShape, Standard_False); - it.Next(); - } -// TheAIS2DContext()->UpdateCurrentViewer(); - TheAIS2DContext()->CurrentViewer()->Update(); - } - - return 0; -} - -//============================================================================== -//function : V2dEraseAll -//purpose : Erase all the objects displayed in the viewer -//Draw arg : v2deraseall -//============================================================================== -static int V2dEraseAll (Draw_Interpretor& , Standard_Integer argc, const char** ) -{ - if (argc > 1) - { - cout << "Usage: v2deraseall" << endl; - return 1; - } - - if (Viewer2dTest::CurrentView().IsNull()) - { - cout << " Error: v2dinit hasn't been called." << endl; - return 1; - } - - TheAIS2DContext()->CloseAllContext(Standard_False); - - // EraseAll(Standard_True, Standard_True); - TheAIS2DContext()->EraseAll(); - return 0; -} - -//============================================================================== -//function : V2dDisplayAll -//purpose : Display all the objects of the Map -//Draw arg : v2ddisplayall -//============================================================================== -static int V2dDisplayAll (Draw_Interpretor& , Standard_Integer argc, const char** argv) -{ - if (Viewer2dTest::CurrentView().IsNull()) return 1; - - if (argc > 1) - { - cout << argv[0] << " Syntaxe error" << endl; - return 1; - } - TheAIS2DContext()->CloseLocalContext(); - Viewer2dTest_DoubleMapIteratorOfDoubleMapOfInteractiveAndName it (GetMapOfAIS2D()); -// while (it.More()) -// { -// Handle(AIS2D_InteractiveObject) aShape = it.Key1(); -// TheAIS2DContext()->Erase(aShape,Standard_False); -// it.Next(); -// } -// it.Reset(); - while (it.More()) - { - Handle(AIS2D_InteractiveObject) aShape = it.Key1(); - TheAIS2DContext()->Display(aShape, Standard_False); - it.Next(); - } -#ifdef OCC154 - TheAIS2DContext()->HighlightCurrent(); -#endif - TheAIS2DContext()->UpdateCurrentViewer(); -// TheAIS2DContext()->DisplayAll(); - return 0; -} - -//============================================================================== -//function : VTexture -//purpose : -//Draw arg : -//============================================================================== -/* -Standard_Integer VTexture (Draw_Interpretor& di,Standard_Integer argc, Standard_Character** argv ) -{ - Standard_Integer command = (strcasecmp(argv[0],"vtexture")==0)? 1: - (strcasecmp(argv[0],"vtexscale")==0) ? 2 : - (strcasecmp(argv[0],"vtexorigin")==0) ? 3 : - (strcasecmp(argv[0],"vtexrepeat")==0) ? 4 : - (strcasecmp(argv[0],"vtexdefault")==0) ? 5 : -1; - - Handle(AIS2D_InteractiveContext) myAIS2DContext = Viewer2dTest::GetAIS2DContext(); - if(myAIS2DContext.IsNull()) - { - cerr << "use 'vinit' command before " << argv[0] << endl; - return 0; - } - - Handle(AIS2D_InteractiveObject) TheAisIO; - Handle(AIS2D_TexturedShape) myShape; - Standard_Integer myPreviousMode = 0; - - if (!argv[1]) - { - cout << argv[0] <<" syntax error - Type 'help vtex'"<SetSurfaceDetail(V2d_TEX_ALL); - - if (GetMapOfAIS2D().IsBound2(name)) - TheAisIO = GetMapOfAIS2D().Find2(name); - else - { - cout <<"shape "<IsKind(STANDARD_TYPE(AIS2D_TexturedShape)) && !TheAisIO.IsNull()) - { - myShape = Handle(AIS2D_TexturedShape)::DownCast(TheAisIO); - myPreviousMode = myShape->DisplayMode() ; - } - else - { - myAIS2DContext->Erase(TheAisIO,Standard_False); - myShape = new AIS2D_TexturedShape (DBRep::Get(argv[1])); - GetMapOfAIS2D().UnBind1(TheAisIO); - GetMapOfAIS2D().UnBind2(name); - GetMapOfAIS2D().Bind(myShape, name); - } - switch (command) - { - case 1: // vtexture : we only map a texture on the shape - if(argc<=1) - { - cerr << argv[0] <<" syntax error - Type 'help vtex'" << endl; - return 0; - } - if (argv[2]) - { - if(strcasecmp(argv[2],"?")==0) - { - TCollection_AsciiString monPath = GetEnvir2d(); - - cout<<"\n Files in current directory : \n"<SetTextureFileName(argv[2]); - } - else - { - cout <<"Texture mapping disabled \n \ - To enable it, use 'vtexture NameOfShape NameOfTexture' \n"<SetDisplayMode(myShape,1,Standard_False); - if (myPreviousMode == 3 ) - myAIS2DContext->RecomputePrsOnly(myShape); - myAIS2DContext->Display(myShape, Standard_True); - return 0; - } - break; - - case 2: // vtexscale : we change the scaling factor of the texture - - if(argc<2) - { - cerr << argv[0] <<" syntax error - Type 'help vtex'" << endl; - return 0; - } - - myShape->SetTextureScale (( argv[2] ? Standard_True : Standard_False ), - ( argv[2] ? atof(argv[2]) : 1.0 ), - ( argv[2] ? atof(argv[argc-1]) : 1.0 ) ); - break; - - case 3: // vtexorigin : we change the origin of the texture on the shape - if(argc<2) - { - cerr << argv[0] <<" syntax error - Type 'help vtex'" << endl; - return 0; - } - myShape->SetTextureOrigin (( argv[2] ? Standard_True : Standard_False ), - ( argv[2] ? atof(argv[2]) : 0.0 ), - ( argv[2] ? atof(argv[argc-1]) : 0.0 )); - break; - - case 4: // vtexrepeat : we change the number of occurences of the texture on the shape - if(argc<2) - { - cerr << argv[0] <<" syntax error - Type 'help vtex'" << endl; - return 0; - } - if (argv[2]) - { - cout <<"Texture repeat enabled"<SetTextureRepeat(Standard_True, atof(argv[2]), atof(argv[argc-1]) ); - } - else - { - cout <<"Texture repeat disabled"<SetTextureRepeat(Standard_False); - } - break; - - case 5: // vtexdefault : default texture mapping - // ScaleU = ScaleV = 100.0 - // URepeat = VRepeat = 1.0 - // Uorigin = VOrigin = 0.0 - - if(argc<2) - { - cerr << argv[0] <<" syntax error - Type 'help vtex'" << endl; - return 0; - } - myShape->SetTextureRepeat(Standard_False); - myShape->SetTextureOrigin(Standard_False); - myShape->SetTextureScale (Standard_False); - break; - } - - if ((myShape->DisplayMode() == 3) || (myPreviousMode == 3 )) - myAIS2DContext->RecomputePrsOnly(myShape); - else - { - myAIS2DContext->SetDisplayMode(myShape,3,Standard_False); - myAIS2DContext->Display(myShape, Standard_True); - myAIS2DContext->Update(myShape,Standard_True); - } - return 1; -} -*/ - -#if 0 -//============================================================================== -//function : V2dShading -//purpose : Sharpen or roughten the quality of the shading -//Draw arg : vshading ShapeName 0.1->0.00001 1 deg-> 30 deg -//============================================================================== -static int V2dShading (Draw_Interpretor& ,Standard_Integer argc, const char** argv) -{ - Standard_Boolean HaveToSet; -// Standard_Real myDevAngle; - Standard_Real myDevCoef; - Handle(AIS2D_InteractiveObject) TheAisIO; - - // Verifications - if (!strcasecmp(argv[0],"vsetshading")) HaveToSet = Standard_True; - else HaveToSet = Standard_False; - TheAIS2DContext()->CloseLocalContext(); - - if (argc < 3) - { - myDevCoef = 0.0008; - } - else - { - myDevCoef = atof(argv[2]); - } - - TCollection_AsciiString name = argv[1]; - if (GetMapOfAIS2D().IsBound2(name)) TheAisIO = GetMapOfAIS2D().Find2(name); - else - { - TheAisIO = GetAIS2DShapeFromName(name.ToCString()); - } - - if (HaveToSet) - { -// TheAIS2DContext()->SetDeviationCoefficient(TheAisIO,myDevCoef,Standard_True); - } - else - { -// TheAIS2DContext()->SetDeviationCoefficient(TheAisIO,0.0008,Standard_True); - } - - TheAIS2DContext()->Redisplay(TheAisIO); - return 0; -} -#endif - -//======================================================================= -//function : VEraseType -//purpose : -//======================================================================= -/*static int VEraseType (Draw_Interpretor& , Standard_Integer argc, const char** argv) -{ - if (argc!=2) return 1; - - AIS2D_KindOfInteractive TheType; - Standard_Integer TheSign(-1); - GetTypeAndSignfromString2d(argv[1],TheType,TheSign); - - AIS2D_ListOfInteractive LIO; - - // en attendant l'amelioration ais pour les dimensions... - // - Standard_Integer dimension_status(-1); - if(TheType==AIS2D_KOI_Relation){ - dimension_status = TheSign ==1 ? 1 : 0; - TheSign=-1; - } - - TheAIS2DContext()->DisplayedObjects(TheType,TheSign,LIO); - Handle(AIS2D_InteractiveObject) curio; - for(AIS2D_ListIteratorOfListOfInteractive it(LIO);it.More();it.Next()){ - curio = it.Value(); - - if(dimension_status == -1) - TheAIS2DContext()->Erase(curio,Standard_False); - else { - AIS2D_KindOfDimension KOD = (*((Handle(AIS2D_Relation)*)&curio))->KindOfDimension(); - if ((dimension_status==0 && KOD == AIS2D_KOD_NONE)|| - (dimension_status==1 && KOD != AIS2D_KOD_NONE)) - TheAIS2DContext()->Erase(curio,Standard_False); - } - } - TheAIS2DContext()->UpdateCurrentViewer(); - return 0; -}*/ - -//======================================================================= -//function : V2dDisplayType -//purpose : -//======================================================================= -/*static int V2dDisplayType (Draw_Interpretor& , Standard_Integer argc, const char** argv) -{ - if (argc!=2) return 1; - - AIS2D_KindOfInteractive TheType; - Standard_Integer TheSign(-1); - GetTypeAndSignfromString2d(argv[1],TheType,TheSign); - - // en attendant l'amelioration ais pour les dimensions... - // - Standard_Integer dimension_status(-1); - if(TheType==AIS2D_KOI_Relation){ - dimension_status = TheSign ==1 ? 1 : 0; - TheSign=-1; - } - - AIS2D_ListOfInteractive LIO; - TheAIS2DContext()->ObjectsInside(LIO,TheType,TheSign); - Handle(AIS2D_InteractiveObject) curio; - for(AIS2D_ListIteratorOfListOfInteractive it(LIO);it.More();it.Next()){ - curio = it.Value(); - if(dimension_status == -1) - TheAIS2DContext()->Display(curio,Standard_False); - else { - AIS2D_KindOfDimension KOD = (*((Handle(AIS2D_Relation)*)&curio))->KindOfDimension(); - if ((dimension_status==0 && KOD == AIS2D_KOD_NONE)|| - (dimension_status==1 && KOD != AIS2D_KOD_NONE)) - TheAIS2DContext()->Display(curio,Standard_False); - } - - } - - TheAIS2DContext()->UpdateCurrentViewer(); - return 0; -}*/ - - -//Additional commands - - //======================================================================= -//function : GetMaterialFromName2d -//purpose : get the Graphic3d_NameOfMaterial from a string -//======================================================================= -static Aspect_TypeOfLine GetLineTypeFromName2d (const char *name) -{ - - Aspect_TypeOfLine aLT = Aspect_TOL_SOLID; - if ( !strcasecmp(name,"DASH" ) ) aLT = Aspect_TOL_DASH; - else if ( !strcasecmp(name,"DOT" ) ) aLT = Aspect_TOL_DOT; - else if ( !strcasecmp(name,"DOTDASH" ) ) aLT = Aspect_TOL_DOTDASH; - return aLT; -} - - -//============================================================================== -//function : V2dTypeofLine -//purpose : change the line type of a selected or named or displayed shape -//Draw arg : v2dsetlinetype [name] type -//============================================================================== - -static int V2dSetUnsetTypeOfLine (Handle(AIS2D_InteractiveObject) theShape, - Standard_Boolean HaveToSet, - Aspect_TypeOfLine theType = Aspect_TOL_SOLID) -{ - theShape->SetContext(TheAIS2DContext()); - - Handle(Graphic2d_Primitive) aPrim; - Handle(Prs2d_AspectRoot) anAspect; - //get all primitives - Standard_Integer i = 1, n = theShape->Length(); - for (; i <= n; i++) - { - aPrim = theShape->Primitive(i); - if (theShape->HasAspect(aPrim)) - { - anAspect = theShape->GetAspect(aPrim); - if (anAspect->GetAspectName() == Prs2d_AN_LINE) break; - else anAspect = NULL; - } - } - - if (HaveToSet) - { - if (anAspect.IsNull()) - { - theShape->SetAspect - (new Prs2d_AspectLine(Quantity_NOC_YELLOW, theType, Aspect_WOL_THIN, - Quantity_NOC_YELLOW, Graphic2d_TOPF_FILLED)); - } - else - { - Handle(Prs2d_AspectLine) anAspectLine = Handle(Prs2d_AspectLine)::DownCast(anAspect); - anAspectLine->SetTypeOfFill(Graphic2d_TOPF_FILLED); - anAspectLine->SetType( theType ); - theShape->SetAspect(anAspect); - } - } - else // unset type line - { - Handle(Prs2d_AspectLine) anAspectLine; - if ( !anAspect.IsNull() ) - anAspectLine = Handle(Prs2d_AspectLine)::DownCast(anAspect); - else - anAspectLine = new Prs2d_AspectLine(); - - anAspectLine->SetTypeOfFill(Graphic2d_TOPF_EMPTY); - anAspectLine->SetType(Aspect_TOL_SOLID); - theShape->SetAspect( anAspectLine ); - } - - return 0; -} - -static int V2dTypeOfLine (Draw_Interpretor& , Standard_Integer argc, const char** argv) -{ - Standard_Boolean ThereIsArgument = Standard_False; - Standard_Boolean HaveToSet = Standard_False; - - if (strcasecmp(argv[0],"v2dsetlinetype") == 0) HaveToSet = Standard_True; - - Aspect_TypeOfLine aType = Aspect_TOL_SOLID; - //Quantity_NameOfColor aColor = Quantity_NOC_BLACK; - if (HaveToSet) - { - if (argc < 2 || argc > 3) - { - cout << "Usage: v2dsetlinetype [name] type" << endl; - return 1; - } - if (argc == 3) - { - ThereIsArgument = Standard_True; - aType = GetLineTypeFromName2d(argv[2]); - } - else - { - aType = GetLineTypeFromName2d(argv[1]); - } - } - else - { - if (argc > 2) - { - cout << "Usage: v2dunsetlinetype [name]" << endl; - return 1; - } - if (argc == 2) ThereIsArgument = Standard_True; - } - - if (Viewer2dTest::CurrentView().IsNull()) return -1; - TheAIS2DContext()->CloseLocalContext(); - - if (ThereIsArgument) - { - TCollection_AsciiString name = argv[1]; - - if (GetMapOfAIS2D().IsBound2(name)) - { - Handle(AIS2D_InteractiveObject) aShape = GetMapOfAIS2D().Find2(name); - V2dSetUnsetTypeOfLine(aShape, HaveToSet, aType); - } - } - else - { - Standard_Boolean hasCurrent = Standard_False; - Viewer2dTest_DoubleMapIteratorOfDoubleMapOfInteractiveAndName it (GetMapOfAIS2D()); - for (; it.More() && !hasCurrent; it.Next()) - { - if (TheAIS2DContext()->IsCurrent(it.Key1())) hasCurrent = Standard_True; - } - for (it.Reset(); it.More(); it.Next()) - { - Handle(AIS2D_InteractiveObject) aShape = it.Key1(); - if ((hasCurrent && TheAIS2DContext()->IsCurrent(aShape)) || !hasCurrent) - { - V2dSetUnsetTypeOfLine(aShape, HaveToSet, aType); - } - } - } - return 0; -} - - -static int drawPoint (Draw_Interpretor& , Standard_Integer argc, const char** argv) -{ - if( argc < 1 ) { - cout << argv[0] << " Syntaxe error" << endl; - return 1; - } - - if (Viewer2dTest::CurrentView().IsNull()) { - cout << "2D AIS Viewer Initialization ..." << endl; - Viewer2dTest::ViewerInit(); - cout << "Done" << endl; - } - - Standard_Real x = 24., y = 24.; - if( argc >= 2 ) - x = atof( argv[1] ); - if( argc >= 3 ) - y = atof( argv[2] ); - - Handle(AIS2D_InteractiveObject) aIO = new AIS2D_InteractiveObject(); - Handle_Prs2d_Point origin = new Prs2d_Point(aIO, gp_Pnt2d( x, y ), - Aspect_TypeOfMarker(argc >= 4 ? atoi(argv[3]) : Aspect_TOM_PLUS), 2, 2, 0); - TheAIS2DContext()->Display(aIO, Standard_True); - return 0; -} -static int drawAxis (Draw_Interpretor& , Standard_Integer argc, const char** argv) -{ - if( argc < 1 ) { - cout << argv[0] << " Syntaxe error" << endl; - return 1; - } - - if (Viewer2dTest::CurrentView().IsNull()) { - cout << "2D AIS Viewer Initialization ..." << endl; - Viewer2dTest::ViewerInit(); - cout << "Done" << endl; - } - Handle(AIS2D_InteractiveObject) aIO = new AIS2D_InteractiveObject(); - - Standard_Real loc_x = 24., loc_y = 84.; - if( argc >= 2 ) - loc_x = atof( argv[1] ); - if( argc >= 3 ) - loc_y = atof( argv[2] ); - gp_Pnt2d location(loc_x, loc_y); - - Standard_Real dir_x = 0., dir_y = 1.; - if( argc >= 4 ) - dir_x = atof( argv[3] ); - if( argc >= 5 ) - dir_y = atof( argv[4] ); - gp_Dir2d direction(dir_x, dir_y); - - gp_Dir2d refdirection(0.0, 1.0); - gp_Ax22d axis(location, direction, refdirection); - Handle_Prs2d_Axis axis2 = new Prs2d_Axis(aIO, axis, 48, 24.0, 24.0, Prs2d_TOA_OPENED, 10.0); - TheAIS2DContext()->Display(aIO, Standard_True); - return 0; -} - -static int drawLine (Draw_Interpretor& , Standard_Integer argc, const char** argv) -{ - if( argc < 1 ) { - cout << argv[0] << " Syntaxe error" << endl; - return 1; - } - - if (Viewer2dTest::CurrentView().IsNull()) { - cout << "2D AIS Viewer Initialization ..." << endl; - Viewer2dTest::ViewerInit(); - cout << "Done" << endl; - } - Standard_Real x1 = -11., y1 = -250., d1 = 100., d2 = 200.; - - if( argc >= 2 ) - x1 = atof( argv[1] ); - if( argc >= 3 ) - y1 = atof( argv[2] ); - if( argc >= 4 ) - d1 = atof( argv[3] ); - if( argc == 5 ) - d2 = atof( argv[4] ); - - Handle(AIS2D_InteractiveObject) aIO = new AIS2D_InteractiveObject(); - gp_Pnt2d FirstPt(x1, y1); - gp_Dir2d direction(d1, d2); - Handle_Geom2d_Line line = new Geom2d_Line(FirstPt, direction); - Handle(GGraphic2d_Curve) grCurve = new GGraphic2d_Curve(aIO, line); - - TheAIS2DContext()->Display(aIO, Standard_True ); - - return 0; -} -static int drawSegment (Draw_Interpretor& , Standard_Integer argc, const char** argv) -{ - if( argc < 1 ) { - cout << argv[0] << " Syntaxe error" << endl; - return 1; - } - - if (Viewer2dTest::CurrentView().IsNull()) { - cout << "2D AIS Viewer Initialization ..." << endl; - Viewer2dTest::ViewerInit(); - cout << "Done" << endl; - } - - Standard_Real x1 = 0., y1 = 20., x2 = 100., y2 = 200.; - - if( argc >= 2 ) - x1 = atof( argv[1] ); - if( argc >= 3 ) - y1 = atof( argv[2] ); - if( argc >= 4 ) - x2 = atof( argv[3] ); - if( argc == 5 ) - y2 = atof( argv[4] ); - - Handle(AIS2D_InteractiveObject) aIO = new AIS2D_InteractiveObject(); - Handle(Graphic2d_Segment) theSegment = new Graphic2d_Segment( aIO, x1, y1, x2, y2 ); - TheAIS2DContext()->Display(aIO, Standard_True); - return 0; -} - -static int drawArrowLine (Draw_Interpretor& , Standard_Integer argc, const char** argv) -{ - if( argc < 1 ) { - cout << argv[0] << " Syntaxe error" << endl; - return 1; - } - - if (Viewer2dTest::CurrentView().IsNull()) { - cout << "2D AIS Viewer Initialization ..." << endl; - Viewer2dTest::ViewerInit(); - cout << "Done" << endl; - } - - Standard_Real x1 = 24, y1 = 24, x2 = 420, y2 = 420; - - if( argc >= 3 ) - x1 = atof( argv[2] ); - if( argc >= 4 ) - y1 = atof( argv[3] ); - if( argc >= 5 ) - x2 = atof( argv[4] ); - if( argc == 6 ) - y2 = atof( argv[5] ); - - - Handle(AIS2D_InteractiveObject) aIO = new AIS2D_InteractiveObject(); - gp_Pnt2d FirstPt(x1, y1); - gp_Pnt2d LastPt(x2, y2); - double arrow_angle = 24; - double arrow_length = FirstPt.Distance(LastPt)/10.; - int arrow_type = 1; - - gp_Ax2d ax; - ax = gp_Ax2d(FirstPt, gp_Dir2d(gp_Vec2d(LastPt, FirstPt))); - - Handle(Prs2d_Arrow) h_arrow; - h_arrow = new Prs2d_Arrow(aIO, ax, arrow_angle, arrow_length, Prs2d_TypeOfArrow(arrow_type)); - - GCE2d_MakeSegment segment(FirstPt, LastPt); - Handle(Geom2d_TrimmedCurve) trCur = segment.Value(); - Handle(GGraphic2d_Curve) grCurve = new GGraphic2d_Curve(aIO, trCur); - - GetMapOfAIS2D().Bind(aIO, argv[1]); - TheAIS2DContext()->Display(aIO, Standard_True ); - TheAIS2DContext()->UpdateCurrentViewer(); - return 0; -} - - -static int draw2DText (Draw_Interpretor& , Standard_Integer argc, const char** argv) -{ - - if( argc < 2 ) { - cout << argv[0] << " Syntaxe error" << endl; - return 1; - } - - if (Viewer2dTest::CurrentView().IsNull()) { - cout << "2D AIS Viewer Initialization ..." << endl; - Viewer2dTest::ViewerInit(); - cout << "Done" << endl; - } - - Standard_Real x1 = 24, y1 = 24; - Quantity_PlaneAngle anAngle = 0.0; - Quantity_Factor aScale = 1.0; - Standard_Boolean isUnderline = Standard_False; - - if( argc >= 4 ) - x1 = atof( argv[3] ); - if( argc >= 5 ) - y1 = atof( argv[4] ); - if( argc >= 6 ) - anAngle = atof( argv[5] ); - if( argc >= 7 ) - aScale = atof( argv[6] ); - if( argc >= 8 ) - isUnderline = atoi( argv[7] ); - - - - Handle(AIS2D_InteractiveObject) aIO = new AIS2D_InteractiveObject(); - TCollection_ExtendedString aString(argv[2]); - Handle(Graphic2d_Text) aText = new Graphic2d_Text(aIO,aString,x1,y1, anAngle, Aspect_TOT_SOLID, aScale); - aText->SetUnderline(isUnderline); - - Handle(Prs2d_AspectText) aspect = new Prs2d_AspectText(); - aspect->SetFont(Aspect_TOF_HELVETICA); - aspect->SetColor(Quantity_NOC_WHITE); - aIO->SetAspect(aspect); - - Standard_Integer color_index = 2; - aText->SetColorIndex(color_index); - - - GetMapOfAIS2D().Bind(aIO, argv[1]); - TheAIS2DContext()->Display(aIO, Standard_True ); - TheAIS2DContext()->UpdateCurrentViewer(); - return 0; -} - -static int drawToleanceFrame( Draw_Interpretor& , Standard_Integer argc, const char** argv ) -{ - if( argc < 1 ) - { - cout << argv[0] << " Syntaxe error" << endl; - return 1; - } - - if (Viewer2dTest::CurrentView().IsNull()) - { - cout << "2D AIS Viewer Initialization ..." << endl; - Viewer2dTest::ViewerInit(); - cout << "Done" << endl; - } - - Handle(AIS2D_InteractiveObject) aIO = new AIS2D_InteractiveObject(); - Standard_Real aX = 24, aY = 48; - Standard_Real height = 24; - - if( argc >= 2 ) - height = atof( argv[1] ); - - if( argc >= 3 ) - aX = atof( argv[2] ); - if( argc >= 4 ) - aX = atof( argv[3] ); - - gp_Pnt2d location(aX, aY); - - int tol_type = 10; - if( argc >= 5 ) - tol_type = atoi( argv[4] ); - - double angle = 0.0; - double text_scale = 10.0; - - Handle(Prs2d_ToleranceFrame) symbol; - symbol = new Prs2d_ToleranceFrame( aIO, location.X(), location.Y(), height, - Prs2d_TypeOfTolerance(tol_type), "B", "-0.01", " A", angle, text_scale); - - TheAIS2DContext()->Display(aIO, Standard_True ); - TheAIS2DContext()->UpdateCurrentViewer(); - return 0; -} - -static int drawArc( Draw_Interpretor& , Standard_Integer argc, const char** argv ) -{ - if( argc < 1 ) - { - cout << argv[0] << " Syntaxe error" << endl; - return 1; - } - - if (Viewer2dTest::CurrentView().IsNull()) - { - cout << "2D AIS Viewer Initialization ..." << endl; - Viewer2dTest::ViewerInit(); - cout << "Done" << endl; - } - - Handle(AIS2D_InteractiveObject) aIO = new AIS2D_InteractiveObject(); - - Standard_Real x1 = 0., y1 = 0., x2 = 24., y2 = 24., x3 = 12., y3 = 48.; - - if( argc >= 2 ) - x1 = atof( argv[1] ); - if( argc >= 3 ) - y1 = atof( argv[2] ); - if( argc >= 4 ) - x2 = atof( argv[3] ); - if( argc >= 5 ) - y2 = atof( argv[4] ); - if( argc >= 6) - x3= atof( argv[5] ); - if( argc >= 7 ) - y3 = atof( argv[6] ); - - gp_Pnt2d point1(x1, y1); - gp_Pnt2d point2(x2, y2); - gp_Pnt2d point3(x3, y3); - - GCE2d_MakeArcOfCircle arc(point1, point2, point3); - Handle_Geom2d_TrimmedCurve trCur = arc.Value(); - - Handle_GGraphic2d_Curve grCurve = new GGraphic2d_Curve(aIO, trCur); - TheAIS2DContext()->Display(aIO, Standard_True); - return 0; -} - -static int drawFinishSymbol( Draw_Interpretor& , Standard_Integer argc, const char** argv ) -{ - if( argc < 1 ) - { - cout << argv[0] << " Syntaxe error" << endl; - return 1; - } - - if (Viewer2dTest::CurrentView().IsNull()) - { - cout << "2D AIS Viewer Initialization ..." << endl; - Viewer2dTest::ViewerInit(); - cout << "Done" << endl; - } - - gp_Pnt2d location(48, 84); - double length = 10; - double angle = 0; - - Handle(AIS2D_InteractiveObject) aIO = new AIS2D_InteractiveObject(); - - Handle(Graphic2d_Polyline) symbol; - Handle(Graphic2d_Text) text; - - gp_Pnt2d startPoint(location.X() + length/4, location.Y() + length/2); - gp_Pnt2d leftTopPoint(location.X() - length/4, location.Y() + length/2); - gp_Pnt2d btCenPoint(location.X(), location.Y()); - gp_Pnt2d rightTopPoint(location.X() + length/2, location.Y() + length); - - gp_Trsf2d trsf; - trsf.SetRotation(location, angle*M_PI/180); - - startPoint.Transform(trsf); - leftTopPoint.Transform(trsf); - btCenPoint.Transform(trsf); - rightTopPoint.Transform(trsf); - - Graphic2d_Array1OfVertex vertex_arr(1, 4); - vertex_arr.SetValue( 1, Graphic2d_Vertex(startPoint.X(), startPoint.Y())); - vertex_arr.SetValue( 2, Graphic2d_Vertex(leftTopPoint.X(), leftTopPoint.Y())); - vertex_arr.SetValue( 3, Graphic2d_Vertex(btCenPoint.X(), btCenPoint.Y())); - vertex_arr.SetValue( 4, Graphic2d_Vertex(rightTopPoint.X(), rightTopPoint.Y())); - - symbol = new Graphic2d_Polyline(aIO, vertex_arr); - TheAIS2DContext()->Display(aIO, Standard_True); - return 0; -} -static int drawBezierCurve( Draw_Interpretor& , Standard_Integer argc, const char** argv ) -{ - if( argc < 1 ) - { - cout << argv[0] << " Syntaxe error" << endl; - return 1; - } - - if (Viewer2dTest::CurrentView().IsNull()) - { - cout << "2D AIS Viewer Initialization ..." << endl; - Viewer2dTest::ViewerInit(); - cout << "Done" << endl; - } - - Handle(AIS2D_InteractiveObject) aIO = new AIS2D_InteractiveObject(); - - TColgp_Array1OfPnt2d ptarr(1, 5); - gp_Pnt2d p1(24, 24); - gp_Pnt2d p2(-48, 42); - gp_Pnt2d p3(80, 82); - gp_Pnt2d p4(240, -24); - gp_Pnt2d p5(-24, -84); - - ptarr.SetValue( 1, p1); - ptarr.SetValue( 2, p2); - ptarr.SetValue( 3, p3); - ptarr.SetValue( 4, p4); - ptarr.SetValue( 5, p5); - - Handle(Geom2d_BezierCurve) bezierCurve = - new Geom2d_BezierCurve(ptarr); - Handle_GGraphic2d_Curve grCurve = new GGraphic2d_Curve(aIO, bezierCurve); - TheAIS2DContext()->Display(aIO, Standard_True); - return 0; -} - - -static int draw2DCurve( Draw_Interpretor& , Standard_Integer argc, const char** argv ) -{ - if( argc < 1 ) - { - cout << argv[0] << " Syntaxe error" << endl; - return 1; - } - - if (Viewer2dTest::CurrentView().IsNull()) - { - cout << "2D AIS Viewer Initialization ..." << endl; - Viewer2dTest::ViewerInit(); - cout << "Done" << endl; - } - - Handle(AIS2D_InteractiveObject) aIO = new AIS2D_InteractiveObject(); - Handle(Geom2d_Curve) aCurve = DrawTrSurf::GetCurve2d(argv[2]); - Handle(GGraphic2d_Curve) grCurve = new GGraphic2d_Curve(aIO, aCurve); - - GetMapOfAIS2D().Bind(aIO, argv[1]); - TheAIS2DContext()->Display(aIO, Standard_True); - TheAIS2DContext()->UpdateCurrentViewer(); - return 0; -} - -static int v2dtransform( Draw_Interpretor& , Standard_Integer argc, const char** argv ) -{ - if( argc < 7 ) - { - cout << argv[0] << " Syntaxe error" << endl; - return 1; - } - - if (Viewer2dTest::CurrentView().IsNull()) - { - cout << "2D AIS Viewer Initialization ..." << endl; - Viewer2dTest::ViewerInit(); - cout << "Done" << endl; - } - - if(!GetMapOfAIS2D().IsBound2(argv[1])) { - cout<<"Object not found"<SetTransform(gp_GTrsf2d(aTrans)); - TheAIS2DContext()->UpdateCurrentViewer(); - return 0; -} - -static int v2dsetstyle( Draw_Interpretor& , Standard_Integer argc, const char** argv ) -{ - if( argc < 3 ) - { - cout << argv[0] << " Syntaxe error" << endl; - return 1; - } - - if (Viewer2dTest::CurrentView().IsNull()) - { - cout << "2D AIS Viewer Initialization ..." << endl; - Viewer2dTest::ViewerInit(); - cout << "Done" << endl; - } - - if(!GetMapOfAIS2D().IsBound2(argv[1])) { - cout<<"Object not found"<Primitive(1); - if(aIO->HasAspect(grPrim)) { - Handle(Prs2d_AspectRoot) aspRoot = aIO->GetAspect(grPrim); - if(!aspRoot.IsNull() && aspRoot->GetAspectName() == Prs2d_AN_LINE) { - Handle(Prs2d_AspectLine) aspLine = Handle(Prs2d_AspectLine)::DownCast(aspRoot); - aspLine->SetType(Aspect_TypeOfLine(atoi(argv[2]))); - } - } - - TheAIS2DContext()->UpdateCurrentViewer(); - return 0; -} - - - -static int v2dtest1 (Draw_Interpretor& , Standard_Integer argc, const char** argv) -{ - - if (Viewer2dTest::CurrentView().IsNull()) - { - cout << "2D AIS Viewer Initialization ..." << endl; - Viewer2dTest::ViewerInit(); - cout << "Done" << endl; - } - - Handle(AIS2D_InteractiveObject) aIO = new AIS2D_InteractiveObject(); - - gp_Pnt2d firstPoint ( 911.84, 851.86); - gp_Pnt2d newPoint (947.78, 847.375); - - Handle(Prs2d_Length) theLength; - theLength = new Prs2d_Length( aIO, firstPoint, newPoint," -0.2", 3, 2, - Prs2d_TypeOfDist(Prs2d_TOD_AUTOMATIC), - 20, 5, Prs2d_TypeOfArrow(Prs2d_TOA_FILLED), - Prs2d_ArrowSide(Prs2d_AS_BOTHAR), Standard_True); - - TheAIS2DContext()->Display(aIO, Standard_True ); - - - aIO = new AIS2D_InteractiveObject(); - gp_Pnt2d pt1 ( 209.30, 1405.29 ); - gp_Pnt2d pt2 ( 409.3, 1396.79); - gp_Pnt2d pt3 (209.3, 1205.278); - - - Handle(Prs2d_Angle) theAngle; - theAngle = new Prs2d_Angle( aIO, pt1, pt2, pt3,100," ", 3, 20, 6, Prs2d_TypeOfArrow(Prs2d_TOA_FILLED), - Prs2d_ArrowSide(Prs2d_AS_BOTHAR), Standard_False); - - TheAIS2DContext()->Display(aIO, Standard_True ); - - TheAIS2DContext()->UpdateCurrentViewer(); - return 0; -} - -static int v2dtable (Draw_Interpretor& , Standard_Integer argc, const char** argv) -{ - - if( argc < 6 ) { - cout << argv[0] << " Syntaxe error" << endl; - return 1; - } - - if (Viewer2dTest::CurrentView().IsNull()) { - cout << "2D AIS Viewer Initialization ..." << endl; - Viewer2dTest::ViewerInit(); - cout << "Done" << endl; - } - - Standard_Real x1 = 24, y1 = 24; - Standard_Integer numberOfColumn = 1, numberOfRows = 1; - - if( argc >= 3 ) - x1 = atof( argv[2] ); - if( argc >= 4 ) - y1 = atof( argv[3] ); - if( argc >= 5 ) - numberOfColumn = atoi( argv[4] ); - if( argc >= 6 ) - numberOfRows = atoi( argv[5] ); - - Handle(AIS2D_InteractiveObject) aisObj = new AIS2D_InteractiveObject(); - - Handle(GGraphic2d_SetOfCurves) setOfCurve = new GGraphic2d_SetOfCurves(aisObj); - - gp_Pnt2d location(x1,y1); - Standard_Real columnWidth = 100; - Standard_Real rowHeight = 10; - Standard_Integer i; - - Handle(Geom2d_Curve) trCur; - - for( i=0; i<=numberOfColumn; ++i) { - GCE2d_MakeSegment segment( gp_Pnt2d(location.X() + (columnWidth * i), location.Y()), - gp_Pnt2d(location.X() + (columnWidth * i), location.Y() + (rowHeight * numberOfRows)) ); - - trCur = segment.Value(); - setOfCurve->Add(trCur); - } - - for( i=0; i<=numberOfRows; ++i) { - GCE2d_MakeSegment segment1( gp_Pnt2d(location.X(), location.Y() + (rowHeight * i)), - gp_Pnt2d(location.X() + (numberOfColumn * columnWidth), location.Y() + (rowHeight * i)) ); - trCur = segment1.Value(); - setOfCurve->Add(trCur); - } - - Handle(Graphic2d_Text) text; - Standard_Real locationX = (location.X() + (columnWidth / 2)); - Standard_Real locationY = (location.Y() + (rowHeight / 2)); - Handle(Prs2d_Point) point; - - Standard_Real text_scale = 2.0; - - for(Standard_Integer j=0, k=0; jDisplay(aisObj, Standard_True ); - TheAIS2DContext()->UpdateCurrentViewer(); - return 0; -} - - - -static int drawEllipse( Draw_Interpretor& , Standard_Integer argc, const char** argv ) -{ - if( argc < 1 ) - { - cout << argv[0] << " Syntaxe error" << endl; - return 1; - } - - if (Viewer2dTest::CurrentView().IsNull()) - { - cout << "2D AIS Viewer Initialization ..." << endl; - Viewer2dTest::ViewerInit(); - cout << "Done" << endl; - } - - Handle(AIS2D_InteractiveObject) aIO = new AIS2D_InteractiveObject(); - Handle(Geom2d_Ellipse) ellipse ; - gp_Ax2d axis(gp_Pnt2d(24, 42), gp_Dir2d(1, 0)); - ellipse = new Geom2d_Ellipse(axis, 420, 240, Standard_True); - Handle_GGraphic2d_Curve grCurve = new GGraphic2d_Curve(aIO, ellipse); - TheAIS2DContext()->Display(aIO, Standard_True); - return 0; -} - -static int drawLengthDim( Draw_Interpretor& , Standard_Integer argc, const char** argv ) -{ - if( argc < 1 ) - { - cout << argv[0] << " Syntaxe error" << endl; - return 1; - } - - - int distance_type = 0; - if (argc >= 2) { - distance_type = atoi(argv[1]); - } - - if (Viewer2dTest::CurrentView().IsNull()) - { - cout << "2D AIS Viewer Initialization ..." << endl; - Viewer2dTest::ViewerInit(); - cout << "Done" << endl; - } - - gp_Pnt2d FirstPt(0, 0); - gp_Pnt2d LastPt(240, 240); - - double text_scale = 5; - double length = 100; - double arrow_angle = 24; - double arrow_length = 24; - int arrow_type = 2; - int arrow_side = 3; - Standard_Boolean isReverse = Standard_True; - - double distance = FirstPt.Distance(LastPt); - - char str_[10]; - sprintf(str_, "%.2f", distance); - - TCollection_ExtendedString str(str_); - - Handle(Prs2d_Length) theLength; - Handle(AIS2D_InteractiveObject) aIO = new AIS2D_InteractiveObject(); - - theLength = - new Prs2d_Length(aIO, FirstPt, LastPt, - str, text_scale, length, Prs2d_TypeOfDist(distance_type), - arrow_angle, arrow_length, Prs2d_TypeOfArrow(arrow_type), - Prs2d_ArrowSide(arrow_side), isReverse); - - theLength->SetTextRelPos(.5, .5); - - TheAIS2DContext()->Display(aIO, Standard_True); - TheAIS2DContext()->UpdateCurrentViewer(); - return 0; -} - -static int drawLengthDim1( Draw_Interpretor& , Standard_Integer argc, const char** argv ) -{ - if( argc < 1 ) - { - cout << argv[0] << " Syntaxe error" << endl; - return 1; - } - - if (Viewer2dTest::CurrentView().IsNull()) - { - cout << "2D AIS Viewer Initialization ..." << endl; - Viewer2dTest::ViewerInit(); - cout << "Done" << endl; - } - - gp_Pnt2d FirstPt(0, 0); - gp_Pnt2d LastPt(2, 2); - - gp_Lin2d aL1(FirstPt,gp_Dir2d(0,1)); - gp_Lin2d aL2(LastPt,gp_Dir2d(0,1)); - - double text_scale = 15; - double length = 0; - //int distance_type = 0; - //double arrow_angle = 24; - //double arrow_length = 24; - //int arrow_type = 2; - //int arrow_side = 3; - - double distance = FirstPt.Distance(LastPt); - - char str_[10]; - sprintf(str_, "%.2f", distance); - - TCollection_ExtendedString str(str_); - - Handle(Prs2d_Length) theLength; - Handle(AIS2D_InteractiveObject) aIO = new AIS2D_InteractiveObject(); - - - theLength = - new Prs2d_Length(aIO, aL1, aL2, - str, text_scale, length); -// theLength = -// new Prs2d_Length(aIO, aL1, aL2, -// str, text_scale, length, arrow_angle,arrow_length, -// Prs2d_TypeOfDist(distance_type), -// Prs2d_TypeOfArrow(arrow_type), -// Prs2d_ArrowSide(arrow_side), Standard_False); - - theLength->SetTextRelPos(.5, .5); - - TheAIS2DContext()->Display(aIO, Standard_True); - TheAIS2DContext()->UpdateCurrentViewer(); - return 0; -} - - - -static int drawAngleDim( Draw_Interpretor& , Standard_Integer argc, const char** argv ) -{ - if( argc < 1 ) - { - cout << argv[0] << " Syntaxe error" << endl; - return 1; - } - Standard_Boolean isReverse = Standard_False; - - if( argc >= 1 ) - isReverse = atoi(argv[1]); - - if (Viewer2dTest::CurrentView().IsNull()) - { - cout << "2D AIS Viewer Initialization ..." << endl; - Viewer2dTest::ViewerInit(); - cout << "Done" << endl; - } - - gp_Pnt2d anAp1(0, 0); - gp_Pnt2d anAp2(240, 240); - gp_Pnt2d anAp3(0, 240); - - Quantity_Length aRadius = 100; - TCollection_ExtendedString aText("Rad = 10%"); - - Handle(Prs2d_Angle) theAngle; - Handle(AIS2D_InteractiveObject) aIO = new AIS2D_InteractiveObject(); - - if(isReverse) { - theAngle = new Prs2d_Angle(aIO, anAp1, anAp3, anAp2, aRadius, aText,1,10.,5.,Prs2d_TypeOfArrow(1),Prs2d_ArrowSide(2),isReverse); - } - else { - theAngle = - new Prs2d_Angle(aIO, anAp1, anAp2, anAp3, aRadius, aText,1,10.,5.,Prs2d_TypeOfArrow(1),Prs2d_ArrowSide(2),isReverse); - } - - theAngle->SetTextRelPos(.5, .5); - - TheAIS2DContext()->Display(aIO, Standard_True); - TheAIS2DContext()->UpdateCurrentViewer(); - return 0; -} - -static int drawRadiusDim( Draw_Interpretor& , Standard_Integer argc, const char** argv ) -{ - if( argc < 1 ) - { - cout << argv[0] << " Syntaxe error" << endl; - return 1; - } - Standard_Boolean isReverse = Standard_False; - - if( argc >= 2 ) - isReverse = atoi(argv[1]); - - if (Viewer2dTest::CurrentView().IsNull()) - { - cout << "2D AIS Viewer Initialization ..." << endl; - Viewer2dTest::ViewerInit(); - cout << "Done" << endl; - } - - gp_Pnt2d anAp1(0, 0); - gp_Pnt2d anAp2(240, 240); - gp_Circ2d aCirc(gp_Ax2d(anAp2,gp_Dir2d(0,1)),100.); - - TCollection_ExtendedString aText("Rad = 10%"); - - Handle(Prs2d_Radius) theRadius; - Handle(AIS2D_InteractiveObject) aIO = new AIS2D_InteractiveObject(); - - theRadius = new Prs2d_Radius(aIO, anAp1, aCirc, aText,1,10.,5.,Prs2d_TypeOfArrow(1),Prs2d_AS_BOTHAR,isReverse); - theRadius->SetTextRelPos(.5, .5); - - TheAIS2DContext()->Display(aIO, Standard_True); - TheAIS2DContext()->UpdateCurrentViewer(); - return 0; -} - - -static int drawSymbDim( Draw_Interpretor& , Standard_Integer argc, const char** argv ) -{ - if( argc < 1 ) - { - cout << argv[0] << " Syntaxe error" << endl; - return 1; - } - - if (Viewer2dTest::CurrentView().IsNull()) - { - cout << "2D AIS Viewer Initialization ..." << endl; - Viewer2dTest::ViewerInit(); - cout << "Done" << endl; - } - - gp_Pnt2d anAp1(0, 0); - gp_Pnt2d anAp2(240, 240); - gp_Circ2d aCirc(gp_Ax2d(anAp2,gp_Dir2d(0,1)),100.); - - TCollection_ExtendedString aText("Rad = 10%"); - - Handle(AIS2D_InteractiveObject) aIO = new AIS2D_InteractiveObject(); - Handle(Prs2d_Circularity) symbol; - - Standard_Real length = 100; - Standard_Real angle = 270; - symbol = new Prs2d_Circularity( aIO, anAp2.X(), anAp2.Y(), length, angle); - - - TheAIS2DContext()->Display(aIO, Standard_True); - - aIO = new AIS2D_InteractiveObject(); - Handle(Prs2d_Parallelism) symbol1; - symbol1 = new Prs2d_Parallelism( aIO, anAp2.X()+10, anAp2.Y()+10, length, angle); - TheAIS2DContext()->Display(aIO, Standard_True); - - TheAIS2DContext()->UpdateCurrentViewer(); - return 0; -} - - -static int drawDiameter( Draw_Interpretor& , Standard_Integer argc, const char** argv ) -{ - if( argc < 2 ) - { - cout << argv[0] << " Syntaxe error" << endl; - return 1; - } - - if (Viewer2dTest::CurrentView().IsNull()) - { - cout << "2D AIS Viewer Initialization ..." << endl; - Viewer2dTest::ViewerInit(); - cout << "Done" << endl; - } - - Standard_Real aRadius = 240.; - aRadius = atof( argv[1] ); - - Standard_Real aX = 0., aY = 0.; - - if( argc >= 3 ) - aX = atof( argv[2] ); - if( argc >= 4 ) - aY = atof( argv[3] ); - - gp_Pnt2d cirLoc( aX, aY ); - - Handle(AIS2D_InteractiveObject) aIO = new AIS2D_InteractiveObject(); - gp_Dir2d xdir(1.0,0.0); - gp_Dir2d ydir(0.0,1.0); - gp_Ax22d ax2d(cirLoc, xdir, ydir); - - - gp_Pnt2d attachPt(cirLoc.X()+aRadius, cirLoc.Y()); - gp_Trsf2d trsf; - trsf.SetRotation(cirLoc, (3.142/180)*-60); - attachPt.Transform(trsf); - gp_Circ2d aCircle(ax2d, aRadius); - Handle(Graphic2d_Circle) theCircle = new Graphic2d_Circle( aIO, 0., 0.,aRadius); - Handle(Prs2d_Diameter) theDiam = - new Prs2d_Diameter(aIO, attachPt, aCircle, TCollection_ExtendedString( aRadius*2. ), - 24.0, 24.0, 24.0, Prs2d_TOA_CLOSED, Prs2d_AS_BOTHAR, Standard_False); - theDiam->DrawSymbol(Standard_True); - theDiam->SetSymbolCode(233); - - TheAIS2DContext()->Display(aIO, Standard_True); - TheAIS2DContext()->UpdateCurrentViewer(); - - return 0; -} - -static int NbAllObjects (Draw_Interpretor& , Standard_Integer argc, const char** argv) -{ - if (argc > 1) { - cout << argv[0] << " Syntaxe error" << endl; - return 1; - } - - if (Viewer2dTest::CurrentView().IsNull()) return 1; - - AIS2D_ListOfIO aListObj; - TheAIS2DContext()->DisplayedObjects( aListObj ); - int aNb = aListObj.Extent(); - - cout << " Number all objects = " << aNb << endl; - return 0; -} - - - -//============================================================================== -//function : Viewer2dTest::Commands -//purpose : Add all the viewer command in the Draw_Interpretor -//============================================================================== -void Viewer2dTest::DisplayCommands (Draw_Interpretor& theCommands) -{ - const char *group = "2D AIS Viewer - Display Commands"; - - theCommands.Add("v2ddisplay", - "v2ddisplay name [projection(Origin(x y z) Normal(dx dy dz) DX(dx dy dz)]", - __FILE__, V2dDisplay, group); - - theCommands.Add("v2derase", - "v2derase [name1] ... [name n]", - __FILE__, V2dErase, group); - - theCommands.Add("v2ddonly", - "v2ddonly [name1] ... [name n]", - __FILE__, V2dDonly, group); - - theCommands.Add("v2ddisplayall", - "v2ddisplayall", - __FILE__, V2dDisplayAll, group); - - theCommands.Add("v2deraseall", - "v2deraseall", - __FILE__, V2dEraseAll, group); - -// theCommands.Add("v2derasetype", -// "v2derasetype : erase all the displayed objects of one given kind (see vtypes)", -// __FILE__, V2dEraseType, group); - -// theCommands.Add("v2ddisplaytype", -// "v2ddisplaytype : display all the objects of one given kind (see vtypes) which are stored the AIS2DContext", -// __FILE__, V2dDisplayType, group); - -/* - theCommands.Add("v2ddisplaymode", - "v2ddispmode [name] mode(1,2,..) : no name -> on selected objects", - __FILE__, V2dDispMode, group); - - theCommands.Add("v2derasemode", - "v2derasemode [name] mode(1,2,..) : no name -> on selected objects", - __FILE__, V2dDispMode, group); - - theCommands.Add("v2dsetdispmode", - "v2dsetdispmode [name] mode(1,2,..) : no name -> on selected objects", - __FILE__, V2dDispMode, group); - - theCommands.Add("v2dunsetdispmode", - "v2dunsetdispmode [name] mode(1,2,..) : no name -> on selected objects", - __FILE__, V2dDispMode, group); -*/ - theCommands.Add("v2dsetcolor", - "v2dsetcolor [name of shape] ColorName", - __FILE__, V2dColor, group); - - theCommands.Add("v2dunsetcolor", - "v2dunsetcolor [name of shape]", - __FILE__, V2dColor, group); - - theCommands.Add("v2dsetbgcolor", - "v2dsetbgcolor colorname : Change background color", - __FILE__, V2dSetBGColor, group); - - /* - theCommands.Add("v2dsettransparency", - "v2dsettransparency [name of shape] TransparencyCoef(0 -> 1)", - __FILE__, V2dTransparency, group); - - theCommands.Add("v2dunsettransparency", - "v2dunsettransparency [name of shape]", - __FILE__, V2dTransparency, group); - - theCommands.Add("v2dsetmaterial", - "v2dsetmaterial [name of shape] MaterialName", - __FILE__, V2dMaterial, group); - - theCommands.Add("v2dunsetmaterial", - "v2dunsetmaterial [name of shape]", - __FILE__, V2dMaterial, group); -*/ - theCommands.Add("v2dsetwidth", - "v2dsetwidth [name_of_shape] width(THIN, MEDIUM, THICK, VERYTHICK)", - __FILE__, V2dWidth, group); - - theCommands.Add("v2dunsetwidth", - "v2dunsetwidth [name of shape]", - __FILE__, V2dWidth, group); -/* - theCommands.Add("v2dsetshading", - "v2dsetshading name Quality(default=0.0008)", - __FILE__, V2dShading, group); - - theCommands.Add("v2dunsetshading", - "v2dunsetshading name", - __FILE__, V2dShading, group); -*/ -/* theCommands.Add("v2dtexture", - "'v2dtexture NameOfShape TextureFile' \n \ - or 'vtexture NameOfShape' if you want to disable texture mapping \n \ - or 'vtexture NameOfShape ?' to list available textures\n \ - or 'vtexture NameOfShape IdOfTexture' (0<=IdOfTexture<=20)' to use predefined textures\n", - __FILE__, VTexture, group);*/ - - //Additional commands for primitives - theCommands.Add("v2dsetlinetype", - "v2dsetlinetype [name of shape] LineType(SOLID, DASH, DOT, DOTDASH )", - __FILE__, V2dTypeOfLine, group); - - theCommands.Add("v2dunsetlinetype", - "v2dunsetlinetype [name of shape]", - __FILE__, V2dTypeOfLine, group); - - - theCommands.Add("v2dpoint", - "v2dpoint [x y marker_type( 0(TOM_POINT),\n \ - 1(TOM_PLUS),\n \ - 2(TOM_STAR),\n \ - 3(TOM_O),\n \ - 4(TOM_X),\n \ - 5(TOM_O_POINT),\n \ - 6(TOM_O_PLUS),\n \ - 7(TOM_O_STAR),\n \ - 8(TOM_O_X) )]", - __FILE__, drawPoint, group); - - theCommands.Add("v2ddrawaxis", - "v2ddrawaxis[loc_x loc_y dir_x dir_y]", - __FILE__, drawAxis, group); - - theCommands.Add("v2dline", - "v2dline [ x y dir_x dir_y ]", - __FILE__, drawLine, group); - - theCommands.Add("v2dsegment", - "v2dsegment [ x1 y1 x2 y2 ]", - __FILE__, drawSegment, group); - - theCommands.Add("v2darrow", - "v2ddrawArrowLine name [ x1 y1 x2 y2 ]", - __FILE__, drawArrowLine, group); - - theCommands.Add("v2ddrawArc", - "v2ddrawArc [ x1 y1 x2 y2 x3 y3]", - __FILE__, drawArc, group); - - theCommands.Add("v2dFinishSymbol", - "v2dFinishSymbol", - __FILE__, drawFinishSymbol, group); - - theCommands.Add("v2dBezierCurve", - "v2dBezierCurve", - __FILE__, drawBezierCurve, group); - - theCommands.Add("v2dEllipse", - "v2dEllipse", - __FILE__, drawEllipse, group); - - theCommands.Add("v2daistext", - "v2daistext atextname text_str x1 y1 [angle scale]", - __FILE__, draw2DText, group); - - theCommands.Add("v2dtoleranceframe", - "v2dtoleranceframe [ height loc_x loc_y tol_type( 0(Prs2d_TOT_TAPER),\n \ - 1(Prs2d_TOT_SYMTOTAL),\n \ - 2(Prs2d_TOT_SYMCIRCULAR),\n \ - 3(Prs2d_TOT_SYMMETRY),\n \ - 4(Prs2d_TOT_CONCENTRIC),\n \ - 5(Prs2d_TOT_POSITION),\n \ - 6(Prs2d_TOT_ANGULARITY),\n \ - 7(Prs2d_TOT_PERPENDIC),\n \ - 8(Prs2d_TOT_PARALLELISM),\n \ - 9(Prs2d_TOT_SURFACEPROF),\n \ - 10(Prs2d_TOT_LINEPROF),\n \ - 11(Prs2d_TOT_CYLINDRIC),\n \ - 12(Prs2d_TOT_CIRCULARITY),\n \ - 13(Prs2d_TOT_FLATNESS),\n \ - 14(Prs2d_TOT_STRAIGHTNESS) )]", - __FILE__, drawToleanceFrame, group); - - theCommands.Add("v2dlengthdim", - "v2dlengthdim ", - __FILE__, drawLengthDim, group); - - theCommands.Add("v2dangledim", - "v2dangledim", - __FILE__, drawAngleDim, group); - - theCommands.Add("v2dradiusdim", - "v2dradiusdim", - __FILE__, drawRadiusDim, group); - - theCommands.Add("v2dsymbols", - "v2dsymbols", - __FILE__, drawSymbDim, group); - - - - theCommands.Add("v2dlen1", - "v2dlengthdim ", - __FILE__, drawLengthDim1, group); - - - theCommands.Add("v2ddiameter", - "v2ddiameter radius [ circle_x_coord circle_y_coord ]", - __FILE__, drawDiameter, group); - - theCommands.Add("v2dcurve", - "v2dcurve name name", - __FILE__,draw2DCurve, group); - - theCommands.Add("v2dtransform", - "v2dtransform name a11 a12 a21 a22 s1 s2", - __FILE__, v2dtransform, group); - - theCommands.Add("v2dtable", - "v2dtable name xSt ySt nbR nbC", - __FILE__, v2dtable, group); - - theCommands.Add("v2dsetsyle", - "v2dsetsyle name style", - __FILE__, v2dsetstyle, group); - - theCommands.Add("v2dtest1", - "v2dtest1", - __FILE__, v2dtest1, group); - - - theCommands.Add("v2dcount", - "v2dcount", - __FILE__, NbAllObjects, group); -} - diff --git a/src/Viewer2dTest/Viewer2dTest_EventManager.cdl b/src/Viewer2dTest/Viewer2dTest_EventManager.cdl deleted file mode 100755 index 04772824aa..0000000000 --- a/src/Viewer2dTest/Viewer2dTest_EventManager.cdl +++ /dev/null @@ -1,49 +0,0 @@ --- Copyright (c) 1999-2012 OPEN CASCADE SAS --- --- The content of this file is subject to the Open CASCADE Technology Public --- License Version 6.5 (the "License"). You may not use the content of this file --- except in compliance with the License. Please obtain a copy of the License --- at http://www.opencascade.org and read it completely before using this file. --- --- The Initial Developer of the Original Code is Open CASCADE S.A.S., having its --- main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. --- --- The Original Code and all software distributed under the License is --- distributed on an "AS IS" basis, without warranty of any kind, and the --- Initial Developer hereby disclaims all such warranties, including without --- limitation, any warranties of merchantability, fitness for a particular --- purpose or non-infringement. Please see the License for the specific terms --- and conditions governing the rights and limitations under the License. - - -class EventManager from Viewer2dTest inherits TShared from MMgt - - ---Purpose: - -uses - View from V2d, - InteractiveContext from AIS2D - -is - - Create(aCtx:InteractiveContext from AIS2D) - returns mutable EventManager from Viewer2dTest; - - MoveTo(me:mutable; xpix,ypix:Integer;aView:View from V2d) is virtual; - - Select(me:mutable) is virtual; - - ShiftSelect(me:mutable) is virtual; - - Select(me:mutable;xmin,ymin,xmax,ymax:Integer;aView:View from V2d) is virtual; - - ShiftSelect(me:mutable;xmin,ymin,xmax,ymax:Integer;aView:View from V2d) is virtual; - - Context(me) returns InteractiveContext from AIS2D; - ---C++: return const& - -fields - - myCtx : InteractiveContext from AIS2D; - -end EventManager; diff --git a/src/Viewer2dTest/Viewer2dTest_EventManager.cxx b/src/Viewer2dTest/Viewer2dTest_EventManager.cxx deleted file mode 100755 index 59e1544dd7..0000000000 --- a/src/Viewer2dTest/Viewer2dTest_EventManager.cxx +++ /dev/null @@ -1,71 +0,0 @@ -// Copyright (c) 1999-2012 OPEN CASCADE SAS -// -// The content of this file is subject to the Open CASCADE Technology Public -// License Version 6.5 (the "License"). You may not use the content of this file -// except in compliance with the License. Please obtain a copy of the License -// at http://www.opencascade.org and read it completely before using this file. -// -// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its -// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. -// -// The Original Code and all software distributed under the License is -// distributed on an "AS IS" basis, without warranty of any kind, and the -// Initial Developer hereby disclaims all such warranties, including without -// limitation, any warranties of merchantability, fitness for a particular -// purpose or non-infringement. Please see the License for the specific terms -// and conditions governing the rights and limitations under the License. - - -#include -#include - -Viewer2dTest_EventManager::Viewer2dTest_EventManager (const Handle(AIS2D_InteractiveContext)& Ctx) - : myCtx(Ctx) -{ -} - -const Handle(AIS2D_InteractiveContext)& Viewer2dTest_EventManager::Context() const -{ - return myCtx; -} - -void Viewer2dTest_EventManager::MoveTo(const Standard_Integer XPix, - const Standard_Integer YPix, - const Handle(V2d_View)& aView) -{ - if (!myCtx.IsNull()) - myCtx->MoveTo(XPix,YPix,aView); -} - -void Viewer2dTest_EventManager::Select(const Standard_Integer /*XPMin*/, - const Standard_Integer /*YPMin*/, - const Standard_Integer /*XPMax*/, - const Standard_Integer /*YPMax*/, - const Handle(V2d_View)& /*aView*/) -{ - cout << "Selection by rectangle is not yet implemented" << endl; -// if (!myCtx.IsNull()) -// myCtx->Select(XPMin,YPMin,XPMax,YPMax,aView); -} - -void Viewer2dTest_EventManager::ShiftSelect(const Standard_Integer XPMin, - const Standard_Integer YPMin, - const Standard_Integer XPMax, - const Standard_Integer YPMax, - const Handle(V2d_View)& aView) -{ - if (!myCtx.IsNull()) - myCtx->ShiftSelect(XPMin,YPMin,XPMax,YPMax,aView,Standard_True); -} - -void Viewer2dTest_EventManager::Select() -{ - if (!myCtx.IsNull()) - myCtx->Select(); -} - -void Viewer2dTest_EventManager::ShiftSelect() -{ - if (!myCtx.IsNull()) - myCtx->ShiftSelect(Standard_True); -} diff --git a/src/Viewer2dTest/Viewer2dTest_GeneralCommands.cxx b/src/Viewer2dTest/Viewer2dTest_GeneralCommands.cxx deleted file mode 100755 index a1898f957f..0000000000 --- a/src/Viewer2dTest/Viewer2dTest_GeneralCommands.cxx +++ /dev/null @@ -1,1206 +0,0 @@ -// Created on: 2002-01-22 -// Created by: Julia DOROVSKIKH -// Copyright (c) 2002-2012 OPEN CASCADE SAS -// -// The content of this file is subject to the Open CASCADE Technology Public -// License Version 6.5 (the "License"). You may not use the content of this file -// except in compliance with the License. Please obtain a copy of the License -// at http://www.opencascade.org and read it completely before using this file. -// -// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its -// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. -// -// The Original Code and all software distributed under the License is -// distributed on an "AS IS" basis, without warranty of any kind, and the -// Initial Developer hereby disclaims all such warranties, including without -// limitation, any warranties of merchantability, fitness for a particular -// purpose or non-infringement. Please see the License for the specific terms -// and conditions governing the rights and limitations under the License. - - -#include - -#include -#include - -#include -#include -#include - -//#include - -#include -//#include -//#include - -#include -#include -//#include - -//#include - -//#include -//#include -//#include -//#include - -//#include -//#include - -//#include -//#include - -Viewer2dTest_DoubleMapOfInteractiveAndName& GetMapOfAIS2D(); -//Handle(AIS2D_InteractiveContext)& TheAIS2DContext(); - -//======================================================================= -//function : GetTypeNames2d -//purpose : -//======================================================================= -//static char** GetTypeNames2d () -//{ -// static char* names[14] = {"Point","Axis","Trihedron","PlaneTrihedron", "Line","Circle","Plane", -// "Shape","ConnectedShape","MultiConn.Shape", -// "ConnectedInter.","MultiConn.", -// "Constraint","Dimension"}; -// static char** ThePointer = names; -// return ThePointer; -//} - -//======================================================================= -//function : GetTypeAndSignfromString2d -//purpose : -//======================================================================= -/*void GetTypeAndSignfromString2d (char* name, AIS_KindOfInteractive& TheType, - Standard_Integer& TheSign) -{ - char ** thefullnames = GetTypeNames2d(); - Standard_Integer index(-1); - - for (Standard_Integer i = 0; i <= 13 && index == -1; i++) - if (!strcasecmp(name, thefullnames[i])) - index = i; - - if (index == -1) - { - TheType = AIS_KOI_None; - TheSign = -1; - return; - } - - if (index <= 6) - { - TheType = AIS_KOI_Datum; - TheSign = index+1; - } - else if (index <= 9) - { - TheType = AIS_KOI_Shape; - TheSign = index-7; - } - else if (index <= 11) - { - TheType = AIS_KOI_Object; - TheSign = index-10; - } - else - { - TheType = AIS_KOI_Relation; - TheSign = index-12; - } -}*/ - -//======================================================================= -//function : Get Context and active view.. -//purpose : -//======================================================================= -//void GetCtxAndView2d (Handle(AIS2D_InteractiveContext)& Ctx, -// Handle(V2d_View)& Viou) -//{ -// Ctx = Viewer2dTest::GetAIS2DContext(); -// const Handle(V2d_Viewer)& Vwr = Ctx->CurrentViewer(); -// Vwr->InitActiveViews(); -// if (Vwr->MoreActiveViews()) -// Viou = Vwr->ActiveView(); -//} - -//============================================================================== -//function : GetShapeFromName2d -//purpose : Compute an Shape from a draw variable or a file name -//============================================================================== -TopoDS_Shape GetShapeFromName2d (const char* name) -{ - TopoDS_Shape S = DBRep::Get(name); - - if (S.IsNull()) - { - BRep_Builder aBuilder; - BRepTools::Read( S, name, aBuilder); - } - - return S; -} -/* -//============================================================================== -//function : V2dDispAreas -//purpose : Redraw the view -//Draw arg : No args -//============================================================================== -static int V2dDispAreas (Draw_Interpretor& ,Standard_Integer , const char** ) -{ - Handle(AIS2D_InteractiveContext) Ctx; - Handle(V2d_View) Viou; - GetCtxAndView2d(Ctx,Viou); -// Ctx->DisplayActiveAreas(Viou); - return 0; -} - -//============================================================================== -//function : V2dClearAreas -//purpose : Redraw the view -//Draw arg : No args -//============================================================================== -static int V2dClearAreas (Draw_Interpretor& ,Standard_Integer , const char** ) -{ - Handle(AIS2D_InteractiveContext) Ctx; - Handle(V2d_View) Viou; - GetCtxAndView2d(Ctx,Viou); -// Ctx->ClearActiveAreas(Viou); - return 0; -} - -//============================================================================== -//function : V2dDispSensi -//purpose : -//Draw arg : No args -//============================================================================== -static int V2dDispSensi (Draw_Interpretor& ,Standard_Integer , const char** ) -{ - Handle(AIS2D_InteractiveContext) Ctx; - Handle(V2d_View) Viou; - GetCtxAndView2d(Ctx,Viou); -// Ctx->DisplayActiveSensitive(Viou); - return 0; - -} - -//============================================================================== -//function : V2dClearSensi -//purpose : -//Draw arg : No args -//============================================================================== -static int V2dClearSensi (Draw_Interpretor& ,Standard_Integer , const char** ) -{ - Handle(AIS2D_InteractiveContext) Ctx; - Handle(V2d_View) Viou; - GetCtxAndView2d(Ctx,Viou); -// Ctx->ClearActiveSensitive(Viou); - return 0; -} -*/ -//============================================================================== -//function : V2dDebug -//purpose : To list the displayed object with their attributes -//Draw arg : No args -//============================================================================== -static int V2dDebug (Draw_Interpretor& di, Standard_Integer , const char** ) -{ - if (!Viewer2dTest::CurrentView().IsNull()) - { - di << "List of object in the viewer :" << "\n"; - - Viewer2dTest_DoubleMapIteratorOfDoubleMapOfInteractiveAndName it (GetMapOfAIS2D()); - - while (it.More()) - { - di << "\t" << it.Key2().ToCString() << "\n"; - it.Next(); - } - } - - return 0; -} - -//======================================================================= -//function :V2dSubInt -//purpose : -//======================================================================= -/*static int V2dSubInt (Draw_Interpretor& , Standard_Integer argc, const char** argv) -{ - if (argc == 1) return 1; - Standard_Integer On = atoi(argv[1]); - const Handle(AIS2D_InteractiveContext)& Ctx = Viewer2dTest::GetAIS2DContext(); - - if (argc == 2) - { - if (!Ctx->HasOpenedContext()) - { - cout << "sub intensite "; - if (On == 1) cout << "On"; - else cout << "Off"; -// cout<<"pour "<NbCurrents()<<" objets"<InitCurrent();Ctx->MoreCurrent();Ctx->NextCurrent()) - { - if(On==1){ - Ctx->SubIntensityOn(Ctx->Current(),Standard_False);} - else{ - cout <<"passage dans off"<SubIntensityOff(Ctx->Current(),Standard_False); - } - } - } - else - { - for(Ctx->InitSelected();Ctx->MoreSelected();Ctx->NextSelected()){ - if(On==1){ - Ctx->SubIntensityOn(Ctx->Interactive(),Standard_False);} - else{ - Ctx->SubIntensityOff(Ctx->Interactive(),Standard_False);} - } - } - Ctx->UpdateCurrentViewer(); - } - else - { - Handle(AIS2D_InteractiveObject) IO; - TCollection_AsciiString name = argv[2]; - if (GetMapOfAIS2D().IsBound2(name)) - { - IO = GetMapOfAIS2D().Find2(name); - if (On == 1) Ctx->SubIntensityOn(IO); - else Ctx->SubIntensityOff(IO); - } - else return 1; - } - return 0; -}*/ - -//============================================================================== -//function : GetTypeNameFromShape2d -//purpose : get the shape type as a string from a shape -//============================================================================== -//static char *GetTypeNameFromShape2d (const TopoDS_Shape& aShape) -//{ -// char *ret = "????"; -// -// if (aShape.IsNull()) ret = "Null Shape"; -// -// switch (aShape.ShapeType()) -// { -// case TopAbs_COMPOUND : ret = "COMPOUND" ; break; -// case TopAbs_COMPSOLID : ret = "COMPSOLID" ; break; -// case TopAbs_SOLID : ret = "SOLID" ; break; -// case TopAbs_SHELL : ret = "SHELL" ; break; -// case TopAbs_FACE : ret = "FACE" ; break; -// case TopAbs_WIRE : ret = "WIRE" ; break; -// case TopAbs_EDGE : ret = "EDGE" ; break; -// case TopAbs_VERTEX : ret = "VERTEX" ; break; -// case TopAbs_SHAPE : ret = "SHAPE" ; break; -// } -// return ret; -//} - -//============================================================================== -//function : GetEnvir2d -//purpose : -//============================================================================== -/*static TCollection_AsciiString GetEnvir2d () -{ - static Standard_Boolean IsDefined = Standard_False ; - static TCollection_AsciiString VarName; - if (!IsDefined) - { - char *envir, *casroot ; - envir = getenv("CSF_MDTVTexturesDirectory") ; - - Standard_Boolean HasDefinition = Standard_False ; - if (!envir) - { - casroot = getenv("CASROOT"); - if (casroot) - { - VarName = TCollection_AsciiString (casroot); - VarName += "/src/Textures"; - HasDefinition = Standard_True; - } - } - else - { - VarName = TCollection_AsciiString(envir); - HasDefinition = Standard_True; - } - - if (HasDefinition) - { - OSD_Path aPath (VarName); - OSD_Directory aDir (aPath); - if (aDir.Exists()) - { - TCollection_AsciiString aTexture = VarName + "/2d_MatraDatavision.rgb"; - OSD_File TextureFile (aTexture); - if (!TextureFile.Exists()) - { - cout << " CSF_MDTVTexturesDirectory or CASROOT not correctly setted " << endl; - cout << " not all files are found in : "<CloseLocalContext(); - - Standard_Real Step = 4*M_PI/180; - Standard_Real Angle = 0; - - Handle(AIS2D_InteractiveObject) aIO; - aIO = GetMapOfAIS2D().Find2(argv[1]); - Handle(AIS2D_ProjShape) aShape = Handle(AIS2D_ProjShape)::DownCast(aIO); - - myTimer.Start(); - - if (atoi(argv[3]) == 1) - { - cout << " Primitives sensibles OFF" << endl; -// TheAIS2DContext()->Deactivate(aIO); - } - else - { - cout << " Primitives sensibles ON" << endl; - } - // Movement par transformation - if (atoi(argv[2]) == 1) - { - cout << " Calcul par Transformation" << endl; - for (Standard_Real myAngle = 0; Angle < 10*2*M_PI; myAngle++) - { - Angle = Step*myAngle; - gp_Trsf myTransfo; - myTransfo.SetRotation(gp_Ax1(gp_Pnt(0,0,0), gp_Dir(0,0,1)), Angle); -// TheAIS2DContext()->SetLocation(aShape,myTransfo); - TheAIS2DContext()->UpdateCurrentViewer(); - } - } - else - { - cout << " Calcul par Locations" << endl; - gp_Trsf myAngleTrsf; - myAngleTrsf.SetRotation(gp_Ax1(gp_Pnt(0,0,0), gp_Dir(0,0,1)), Step); - TopLoc_Location myDeltaAngle (myAngleTrsf); - TopLoc_Location myTrueLoc; - - for (Standard_Real myAngle = 0; Angle < 10*2*M_PI; myAngle++) - { - Angle = Step*myAngle; - myTrueLoc = myTrueLoc*myDeltaAngle; -// TheAIS2DContext()->SetLocation(aShape, myTrueLoc); - TheAIS2DContext()->UpdateCurrentViewer(); - } - } - if (atoi(argv[3]) == 1) - { - // On reactive la selection des primitives sensibles -// TheAIS2DContext()->Activate(aIO,0); - } -// Viewer2dTest::CurrentView()->Redraw(); - myTimer.Stop(); - cout << " Temps ecoule " << endl; - myTimer.Show(); - return 0; -}*/ - -//================================================================================== -// Function : V2dAnimation -//================================================================================== -/*static int V2dAnimation (Draw_Interpretor& , Standard_Integer , const char** ) -{ - Standard_Real thread = 4; - Standard_Real angleA = 0; - Standard_Real angleB; - Standard_Real X; - gp_Ax1 Ax1 (gp_Pnt(0,0,0), gp_Vec(0,0,1)); - - BRep_Builder B; - TopoDS_Shape CrankArm; - TopoDS_Shape CylinderHead; - TopoDS_Shape Propeller; - TopoDS_Shape EngineBlock; - - BRepTools::Read(CrankArm,"/dp_26/Indus/ege/assemblage/CrankArm.rle",B); - BRepTools::Read(CylinderHead,"/dp_26/Indus/ege/assemblage/CylinderHead.rle",B); - BRepTools::Read(Propeller,"/dp_26/Indus/ege/assemblage/Propeller.rle",B); - BRepTools::Read(EngineBlock,"/dp_26/Indus/ege/assemblage/EngineBlock.rle",B); - - if (CrankArm.IsNull() || CylinderHead.IsNull() || Propeller.IsNull() || EngineBlock.IsNull()) - { - cout << " Syntaxe error:loading failure." << endl; - } - - OSD_Timer myTimer; - myTimer.Start(); - - Handle(AIS2D_ProjShape) myAisCylinderHead = new AIS2D_ProjShape(); - Handle(AIS2D_ProjShape) myAisEngineBlock = new AIS2D_ProjShape(); - Handle(AIS2D_ProjShape) myAisCrankArm = new AIS2D_ProjShape(); - Handle(AIS2D_ProjShape) myAisPropeller = new AIS2D_ProjShape(); - - myAisCylinderHead->Add(CylinderHead); - myAisCylinderHead->Add(EngineBlock); - myAisCylinderHead->Add(CrankArm); - myAisCylinderHead->Add(Propeller); - - GetMapOfAIS2D().Bind(myAisCylinderHead,"a"); - GetMapOfAIS2D().Bind(myAisEngineBlock,"b"); - GetMapOfAIS2D().Bind(myAisCrankArm,"c"); - GetMapOfAIS2D().Bind(myAisPropeller,"d"); - -// TheAIS2DContext()->SetColor(myAisCylinderHead, Quantity_NOC_INDIANRED); -// TheAIS2DContext()->SetColor(myAisEngineBlock , Quantity_NOC_RED); -// TheAIS2DContext()->SetColor(myAisPropeller , Quantity_NOC_GREEN); - - TheAIS2DContext()->Display(myAisCylinderHead,Standard_False); - TheAIS2DContext()->Display(myAisEngineBlock,Standard_False ); - TheAIS2DContext()->Display(myAisCrankArm,Standard_False ); - TheAIS2DContext()->Display(myAisPropeller,Standard_False); - -// TheAIS2DContext()->Deactivate(myAisCylinderHead); -// TheAIS2DContext()->Deactivate(myAisEngineBlock ); -// TheAIS2DContext()->Deactivate(myAisCrankArm ); -// TheAIS2DContext()->Deactivate(myAisPropeller ); - - // Boucle de mouvement - for (Standard_Real myAngle = 0; angleA < 2*M_PI*10.175; myAngle++) - { - angleA = thread*myAngle*M_PI/180; - X = Sin(angleA)*3/8; - angleB = atan(X / Sqrt(-X * X + 1)); -// Standard_Real decal(25*0.6); - - //Build a transformation on the display - gp_Trsf aPropellerTrsf; - aPropellerTrsf.SetRotation(Ax1,angleA); -// TheAIS2DContext()->SetLocation(myAisPropeller,aPropellerTrsf); - -// gp_Ax3 base(gp_Pnt(3*decal*(1-Cos(angleA)),-3*decal*Sin(angleA),0),gp_Vec(0,0,1),gp_Vec(1,0,0)); -// gp_Trsf aCrankArmTrsf; -// aCrankArmTrsf.SetTransformation( base.Rotated(gp_Ax1(gp_Pnt(3*decal,0,0),gp_Dir(0,0,1)),angleB)); -// TheAIS2DContext()->SetLocation(myAisCrankArm,aCrankArmTrsf); - - TheAIS2DContext()->UpdateCurrentViewer(); - } - - TopoDS_Shape myNewCrankArm; //=myAisCrankArm ->Shape().Located(myAisCrankArm ->Location()); - TopoDS_Shape myNewPropeller; //=myAisPropeller->Shape().Located(myAisPropeller->Location()); - -// myAisCrankArm ->ResetLocation(); -// myAisPropeller->ResetLocation(); - -// myAisCrankArm ->Set(myNewCrankArm ); -// myAisPropeller->Set(myNewPropeller); - -// TheAIS2DContext()->Activate(myAisCylinderHead,0); -// TheAIS2DContext()->Activate(myAisEngineBlock,0 ); -// TheAIS2DContext()->Activate(myAisCrankArm ,0 ); -// TheAIS2DContext()->Activate(myAisPropeller ,0 ); - - myTimer.Stop(); - myTimer.Show(); - myTimer.Start(); - - TheAIS2DContext()->Redisplay(myAisCrankArm ,Standard_False); - TheAIS2DContext()->Redisplay(myAisPropeller,Standard_False); - - TheAIS2DContext()->UpdateCurrentViewer(); -// Viewer2dTest::CurrentView()->Redraw(); - - myTimer.Stop(); - myTimer.Show(); - - return 0; -}*/ - -//============================================================================== -//function : HaveMode2d -//use : V2dActivatedModes -//============================================================================== -/*Standard_Boolean HaveMode2d (const Handle(AIS2D_InteractiveObject)& TheAisIO, const Standard_Integer mode) -{ -// TColStd_ListOfInteger List; -// TheAIS2DContext()->ActivatedModes (TheAisIO,List); -// TColStd_ListIteratorOfListOfInteger it; - Standard_Boolean Found=Standard_False; -// for (it.Initialize(List); it.More()&&!Found; it.Next() ){ -// if (it.Value()==mode ) Found=Standard_True; -// } - return Found; -}*/ - -//============================================================================== -//function : V2dActivatedMode -//purpose : permet d'attribuer a chacune des shapes un mode d'activation -// (edges,vertex...)qui lui est propre et le mode de selection standard. -// La fonction s'applique aux shapes selectionnees(current ou selected dans le viewer) -// Dans le cas ou on veut psser la shape en argument, la fonction n'autorise -// qu'un nom et qu'un mode. -//Draw arg : vsetam [ShapeName] mode(0,1,2,3,4,5,6,7) -//============================================================================== -//#include -/* -static int V2dActivatedMode (Draw_Interpretor& ,Standard_Integer argc,const char** argv) -{ - Standard_Boolean HaveToSet; - Standard_Boolean ThereIsName = Standard_False ; - - if (!Viewer2dTest::CurrentView().IsNull()) - { - if (!strcasecmp(argv[0],"vsetam")) HaveToSet = Standard_True; - else HaveToSet = Standard_False; - - // verification des arguments - if (HaveToSet) { - if (argc<2||argc>3) { cout<<" Syntaxe error"<1) {cout<<" Syntaxe error"<CloseLocalContext(); - } - - } - - - // IL n'y a aps de nom de shape passe en argument - if (HaveToSet && !ThereIsName){ - Standard_Integer aMode=atoi(argv [1]); - - char *cmode="???"; - - switch (aMode) { - case 0: cmode = "Shape"; break; - case 1: cmode = "Vertex"; break; - case 2: cmode = "Edge"; break; - case 3: cmode = "Wire"; break; - case 4: cmode = "Face"; break; - case 5: cmode = "Shell"; break; - case 6: cmode = "Solid"; break; - case 7: cmode = "Compound"; break; - } - - if( !TheAIS2DContext()->HasOpenedContext() ) { - // il n'y a pas de Context local d'ouvert - // on en ouvre un et on charge toutes les shapes displayees - // on load tous les objets displayees et on Activate les objets de la liste - AIS2D_ListOfInteractive ListOfIO; - // on sauve dans une AIS2DListOfInteractive tous les objets currents - if (TheAIS2DContext()->NbCurrents()>0 ){ - TheAIS2DContext()->UnhilightCurrents(Standard_False); - - for (TheAIS2DContext()->InitCurrent(); TheAIS2DContext()->MoreCurrent(); TheAIS2DContext()->NextCurrent() ){ - ListOfIO.Append(TheAIS2DContext()->Current() ); - - } - } - - TheAIS2DContext()->OpenLocalContext(Standard_False); - Viewer2dTest_DoubleMapIteratorOfDoubleMapOfInteractiveAndName it (GetMapOfAIS2D()); - while(it.More()){ - Handle(AIS2D_InteractiveObject) aIO=it.Key1(); - TheAIS2DContext()->Load(aIO,0,Standard_False); - it.Next(); - } - // traitement des objets qui etaient currents dans le Contexte global - if (!ListOfIO.IsEmpty() ) { - // il y avait des objets currents - AIS2D_ListIteratorOfListOfInteractive iter; - for (iter.Initialize(ListOfIO); iter.More() ; iter.Next() ) { - Handle(AIS2D_InteractiveObject) aIO=iter.Value(); - TheAIS2DContext()->Activate(aIO,aMode); - cout<<" Mode: "<Activate(aIO,aMode); - it.Next(); - } - } - - } - - else { - // un Context local est deja ouvert - // Traitement des objets du Context local - if (TheAIS2DContext()->NbSelected()>0 ){ - TheAIS2DContext()->UnhilightSelected(Standard_False); - // il y a des objets selected,on les parcourt - for (TheAIS2DContext()->InitSelected(); TheAIS2DContext()->MoreSelected(); TheAIS2DContext()->NextSelected() ){ - Handle(AIS2D_InteractiveObject) aIO=TheAIS2DContext()->Interactive(); - - - if (HaveMode2d(aIO,aMode) ) { - cout<<" Mode: "<Deactivate(aIO,aMode); - } - else{ - cout<<" Mode: "<Activate(aIO,aMode); - } - - } - } - else{ - // il n'y a pas d'objets selected - // tous les objets diplayes sont traites - Viewer2dTest_DoubleMapIteratorOfDoubleMapOfInteractiveAndName it (GetMapOfAIS2D()); - while(it.More()){ - Handle(AIS2D_InteractiveObject) aIO=it.Key1(); - if (HaveMode2d(aIO,aMode) ) { - cout<<" Mode: "<Deactivate(aIO,aMode); - } - else{ - cout<<" Mode: "<Activate(aIO,aMode); - } - it.Next(); - } - - } - } - } - else if (HaveToSet && ThereIsName){ - Standard_Integer aMode=atoi(argv [2]); - Handle(AIS2D_InteractiveObject) aIO=GetMapOfAIS2D().Find2(argv[1]); - - char *cmode="???"; - - switch (aMode) { - case 0: cmode = "Shape"; break; - case 1: cmode = "Vertex"; break; - case 2: cmode = "Edge"; break; - case 3: cmode = "Wire"; break; - case 4: cmode = "Face"; break; - case 5: cmode = "Shell"; break; - case 6: cmode = "Solid"; break; - case 7: cmode = "Compound"; break; - } - - if( !TheAIS2DContext()->HasOpenedContext() ) { - TheAIS2DContext()->OpenLocalContext(Standard_False); - // On charge tous les objets de la map - Viewer2dTest_DoubleMapIteratorOfDoubleMapOfInteractiveAndName it (GetMapOfAIS2D()); - while(it.More()){ - Handle(AIS2D_InteractiveObject) aShape=it.Key1(); - TheAIS2DContext()->Load(aShape,0,Standard_False); - it.Next(); - } - TheAIS2DContext()->Activate(aIO,aMode); - cout<<" Mode: "<Deactivate(aIO,aMode); - } - else{ - cout<<" Mode: "<Activate(aIO,aMode); - } - } - - } - } - return 0; - -} -*/ - -//============================================================================== -//function : v2dtoto -//============================================================================== -//#include -//static int V2dToto (Draw_Interpretor& , Standard_Integer argc, const char** ) -//{ -// cout << " Fonction toto" << endl; -// Tcl_Interp *interp; -// int code; -// if (argc > 1) -// { -// cout << " Syntaxe error" << endl; -// return 0; -// } -// interp = Tcl_CreateInterp(); -// code = Tcl_EvalFile(interp,"/adv_12/DESIGN/k4dev/ege/work/test.tcl"); - //code= Tcl_Eval(interp,riri) -// cout << *interp->result << endl; -// return 0; -//} - -//============================================================================== -// function : WhoAmI -// user : vState -//============================================================================== -/*void WhoAmI (const Handle(AIS2D_InteractiveObject )& theShape ) { - - // AIS2D_Datum - if (theShape->Type()==AIS2D_KOI_Datum) { - if (theShape->Signature()==3 ) { cout<<" AIS2D_Trihedron"; } - else if (theShape->Signature()==2 ) { cout<<" AIS2D_Axis"; } - else if (theShape->Signature()==6 ) { cout<<" AIS2D_Circle"; } - else if (theShape->Signature()==5 ) { cout<<" AIS2D_Line"; } - else if (theShape->Signature()==7 ) { cout<<" AIS2D_Plane"; } - else if (theShape->Signature()==1 ) { cout<<" AIS2D_Point"; } - else if (theShape->Signature()==4 ) { cout<<" AIS2D_PlaneTrihedron"; } - } - // AIS2D_ProjShape - else if (theShape->Type()==AIS2D_KOI_Shape && theShape->Signature()==0 ) { cout<<" AIS2D_ProjShape"; } - // AIS2D_Dimentions et AIS2D_Relations - else if (theShape->Type()==AIS2D_KOI_Relation) { - Handle(AIS2D_Relation) TheShape= ((*(Handle(AIS2D_Relation)*)&theShape)); - - if (TheShape->KindOfDimension()==AIS2D_KOD_PLANEANGLE) {cout<<" AIS2D_AngleDimension";} - else if (TheShape->KindOfDimension()==AIS2D_KOD_LENGTH ) {cout<<" AIS2D_Chamf2/3dDimension/AIS2D_LengthDimension "; } - else if (TheShape->KindOfDimension()==AIS2D_KOD_DIAMETER ) {cout<<" AIS2D_DiameterDimension ";} - else if (TheShape->KindOfDimension()==AIS2D_KOD_ELLIPSERADIUS ) {cout<<" AIS2D_EllipseRadiusDimension ";} - //else if (TheShape->KindOfDimension()==AIS2D_KOD_FILLETRADIUS ) {cout<<" AIS2D_FilletRadiusDimension "<KindOfDimension()==AIS2D_KOD_OFFSET ) {cout<<" AIS2D_OffsetDimension ";} - else if (TheShape->KindOfDimension()==AIS2D_KOD_RADIUS ) {cout<<" AIS2D_RadiusDimension ";} - // AIS2D no repertorie. - else {cout<<" Type Unknown.";} - } -}*/ - -//============================================================================== -//function : V2dState -//purpose : -//Draw arg : v2dstate [nameA] ... [nameN] -//============================================================================== -/*static int V2dState (Draw_Interpretor& , Standard_Integer argc, const char** argv) -{ - Standard_Boolean ThereIsCurrent = Standard_False; - Standard_Boolean ThereIsArguments = Standard_False; - TheAIS2DContext()->CloseAllContext(); - if (argc >= 2 ) - { - ThereIsArguments = Standard_True; - } -// if (TheAIS2DContext()->NbCurrents()>0 ) { -// ThereIsCurrent=Standard_True; -// } - - if (ThereIsArguments) - { - for (int cpt = 1; cpt < argc; cpt++) - { - // Verification que lq piece est bien bindee. - if (GetMapOfAIS2D().IsBound2(argv[cpt])) - { - Handle(AIS2D_InteractiveObject) theShape = GetMapOfAIS2D().Find2(argv[cpt]); - cout << argv[cpt]; -// WhoAmI(theShape); - if (TheAIS2DContext()->IsDisplayed(theShape)) - { - cout << " Displayed" << endl; - } - else - { - cout << " Not Displayed" << endl; - } - } - else - { - cout << "vstate error: Shape " << cpt << " doesn't exist;" << endl; - return 1; - } - } - } - else if (ThereIsCurrent) - { - for (TheAIS2DContext() -> InitCurrent() ; TheAIS2DContext() -> MoreCurrent() ; TheAIS2DContext() ->NextCurrent() ) - { - Handle(AIS2D_InteractiveObject) theShape=TheAIS2DContext()->Current(); - cout<IsDisplayed(theShape) ) { - cout<<" Displayed"<IsDisplayed(theShape)) - { - cout << " Displayed" << endl; - } - else - { - cout << " Not Displayed" << endl; - } - it.Next(); - } - } - - return 0; -}*/ - -//======================================================================= -//function : V2dPickShape -//purpose : -//======================================================================= -/*static int V2dPickShape (Draw_Interpretor& , Standard_Integer argc, const char** argv) -{ - TopoDS_Shape PickSh; - TopAbs_ShapeEnum theType = TopAbs_COMPOUND; - - if (argc == 1) theType = TopAbs_SHAPE; - else - { - if (!strcasecmp(argv[1],"V" )) theType = TopAbs_VERTEX; - else if (!strcasecmp(argv[1],"E" )) theType = TopAbs_EDGE; - else if (!strcasecmp(argv[1],"W" )) theType = TopAbs_WIRE; - else if (!strcasecmp(argv[1],"F" )) theType = TopAbs_FACE; - else if (!strcasecmp(argv[1],"SHAPE" )) theType = TopAbs_SHAPE; - else if (!strcasecmp(argv[1],"SHELL" )) theType = TopAbs_SHELL; - else if (!strcasecmp(argv[1],"SOLID" )) theType = TopAbs_SOLID; - } - - static Standard_Integer nbOfSub[8] = {0,0,0,0,0,0,0,0}; - static TCollection_AsciiString nameType[8] = {"COMPS","SOL","SHE","F","W","E","V","SHAP"}; - - TCollection_AsciiString name; - - Standard_Integer NbToPick = argc>2 ? argc-2 : 1; - if (NbToPick == 1) - { - PickSh = Viewer2dTest::PickShape(theType); - - if (PickSh.IsNull()) return 1; - if (argc > 2) - { - name += argv[2]; - } - else - { - if (!PickSh.IsNull()) - { - nbOfSub[Standard_Integer(theType)]++; - name += "Picked_"; - name += nameType[Standard_Integer(theType)]; - TCollection_AsciiString indxstring(nbOfSub[Standard_Integer(theType)]); - name +="_"; - name+=indxstring; - } - } - // si on avait une petite methode pour voir si la shape - // est deja dans la Double map, ca eviterait de creer.... - DBRep::Set(name.ToCString(),PickSh); - - Handle(AIS2D_ProjShape) newsh = new AIS2D_ProjShape(); - newsh->Add(PickSh); - GetMapOfAIS2D().Bind(newsh, name); - TheAIS2DContext()->Display(newsh); - cout << "Nom de la shape pickee : " << name << endl; - } - - // Plusieurs objets a picker, vite vite vite.... - // - else - { - Standard_Boolean autonaming = !strcasecmp(argv[2],"."); - Handle(TopTools_HArray1OfShape) arr = new TopTools_HArray1OfShape(1,NbToPick); - if (Viewer2dTest::PickShapes(theType,arr)) - { - for (Standard_Integer i = 1; i <= NbToPick; i++) - { - PickSh = arr->Value(i); - if (!PickSh.IsNull()) - { - if (autonaming) - { - nbOfSub[Standard_Integer(theType)]++; - name.Clear(); - name += "Picked_"; - name += nameType[Standard_Integer(theType)]; - TCollection_AsciiString indxstring (nbOfSub[Standard_Integer(theType)]); - name +="_"; - name+=indxstring; - } - } - else - name = argv[1+i]; - - DBRep::Set(name.ToCString(),PickSh); - Handle(AIS2D_ProjShape) newsh = new AIS2D_ProjShape(); - newsh->Add(PickSh); - GetMapOfAIS2D().Bind(newsh, name); - cout << "display of picke shape #" << i << " - nom : " << name << endl; - TheAIS2DContext()->Display(newsh); - } - } - } - - return 0; -}*/ - -//======================================================================= -//function : V2dIOTypes -//purpose : list of known objects -//======================================================================= -/*static int V2dIOTypes (Draw_Interpretor& , Standard_Integer , const char** ) -{ - // 1234567890 12345678901234567 123456789 - TCollection_AsciiString Colum [3] = {"Standard Types","Type Of Object","Signature"}; - TCollection_AsciiString BlankLine(64, '_'); - Standard_Integer i; - - cout << "/n" << BlankLine << endl; - - for (i = 0; i <= 2; i++) Colum[i].Center(20,' '); - for (i = 0; i <= 2; i++) cout << "|" << Colum[i]; - cout << "|" << endl; - - cout << BlankLine << endl; - - // TCollection_AsciiString thetypes[5]={"Datum","Shape","Object","Relation","None"}; - char ** names = GetTypeNames2d(); - - TCollection_AsciiString curstring; - TCollection_AsciiString curcolum[3]; - - // les objets de type Datum.. - curcolum[1] += "Datum"; - for (i = 0; i <= 6; i++) - { - curcolum[0].Clear(); - curcolum[0] += names[i]; - - curcolum[2].Clear(); - curcolum[2]+=TCollection_AsciiString(i+1); - - for (Standard_Integer j = 0; j <= 2; j++) - { - curcolum[j].Center(20,' '); - cout << "|" << curcolum[j]; - } - cout << "|" << endl; - } - cout << BlankLine << endl; - - // les objets de type shape - curcolum[1].Clear(); - curcolum[1] += "Shape"; - curcolum[1].Center(20,' '); - - for (i = 0; i <= 2; i++) - { - curcolum[0].Clear(); - curcolum[0] += names[7+i]; - curcolum[2].Clear(); - curcolum[2] += TCollection_AsciiString(i); - - for (Standard_Integer j = 0; j <= 2; j++) - { - curcolum[j].Center(20,' '); - cout << "|" << curcolum[j]; - } - cout << "|" << endl; - } - cout << BlankLine << endl; - // les IO de type objet... - curcolum[1].Clear(); - curcolum[1] += "Object"; - curcolum[1].Center(20,' '); - for (i = 0;i <= 1; i++) - { - curcolum[0].Clear(); - curcolum[0] += names[10+i]; - curcolum[2].Clear(); - curcolum[2] += TCollection_AsciiString(i); - - for (Standard_Integer j = 0; j <= 2; j++) - { - curcolum[j].Center(20,' '); - cout << "|" << curcolum[j]; - } - cout << "|" << endl; - } - cout << BlankLine << endl; - - // les contraintes et dimensions. - // pour l'instant on separe juste contraintes et dimensions... - // plus tard, on detaillera toutes les sortes... - curcolum[1].Clear(); - curcolum[1] += "Relation"; - curcolum[1].Center(20,' '); - for (i = 0; i <= 1; i++) - { - curcolum[0].Clear(); - curcolum[0] += names[12+i]; - curcolum[2].Clear(); - curcolum[2] += TCollection_AsciiString(i); - - for (Standard_Integer j = 0; j <= 2; j++) - { - curcolum[j].Center(20,' '); - cout << "|" << curcolum[j]; - } - cout << "|" << endl; - } - cout << BlankLine << endl; - - return 0; -}*/ - -//======================================================================= -//function : v2dr -//purpose : reading of the shape -//======================================================================= -/*static Standard_Integer v2dr (Draw_Interpretor& , Standard_Integer , const char** a) -{ - ifstream s (a[1]); - BRep_Builder builder; - TopoDS_Shape shape; - BRepTools::Read(shape, s, builder); - DBRep::Set(a[1], shape); - Handle(AIS2D_InteractiveContext) Ctx = Viewer2dTest::GetAIS2DContext(); - Handle(AIS2D_ProjShape) ais = new AIS2D_ProjShape(); - ais->Add(shape); - Ctx->Display(ais); - return 0; -}*/ - -//============================================================================== -//function : Viewer2dTest::GeneralCommands -//purpose : Add all the general commands in the Draw_Interpretor -//============================================================================== -void Viewer2dTest::GeneralCommands (Draw_Interpretor& theCommands) -{ - const char *group = "2D AIS Viewer"; - - theCommands.Add("v2ddir", - "v2ddir - list interactive objects", - __FILE__, V2dDebug, group); - -/* theCommands.Add("v2dsub", - "v2dsub 0/1(off/on) [obj] : Subintensity(on/off) of selected objects", - __FILE__, V2dSubInt, group); - - theCommands.Add("v2dardis", - "v2dardis : Display active areas", - __FILE__, V2dDispAreas, group); - - theCommands.Add("v2darera", - "v2darera : Erase active areas", - __FILE__, V2dClearAreas, group); - - theCommands.Add("v2dsensdis", - "v2dsensdis : display active entities", - __FILE__, V2dDispSensi, group); - - theCommands.Add("v2dsensera", - "v2dsensera : erase active entities", - __FILE__, V2dClearSensi, group); - - theCommands.Add("v2dperf", - "v2dperf ShapeName 1/0(Transfo/Location) 1/0(Primitives sensibles ON/OFF)", - __FILE__, V2dPerf, group); - - theCommands.Add("v2danimation", - "v2danimation", - __FILE__, V2dAnimation, group); -*/ -/*theCommands.Add("v2dtexscale", - "'v2dtexscale NameOfShape ScaleU ScaleV' \n \ - or 'vtexscale NameOfShape ScaleUV' \n \ - or 'vtexscale NameOfShape' to disable scaling\n", - __FILE__,VTexture,group); - - theCommands.Add("v2dtexorigin", - "'v2dtexorigin NameOfShape UOrigin VOrigin' \n \ - or 'vtexorigin NameOfShape UVOrigin' \n \ - or 'vtexorigin NameOfShape' to disable origin positioning\n", - __FILE__,VTexture,group); - - theCommands.Add("v2dtexrepeat", - "'v2dtexrepeat NameOfShape URepeat VRepeat' \n \ - or 'vtexrepeat NameOfShape UVRepeat \n \ - or 'vtexrepeat NameOfShape' to disable texture repeat \n ", - VTexture,group); - - theCommands.Add("v2dtexdefault", - "'v2dtexdefault NameOfShape' to set texture mapping default parameters \n", - VTexture,group);*/ - -// theCommands.Add("v2dsetam", -// "v2dsetActivatedModes: vsetam mode(1->7)", -// __FILE__,VActivatedMode,group); - -// theCommands.Add("v2dunsetam", -// "v2dunsetActivatedModes: vunsetam", -// __FILE__,VActivatedMode,group); - -/* theCommands.Add("v2dtoto", - "v2dtoto", - __FILE__, V2dToto, group); - - theCommands.Add("v2dstate", - "vstate [Name1] ... [NameN] : No arg, select currents; no currrent select all", - __FILE__,V2dState,group); - - theCommands.Add("v2dpickshapes", - "v2dpickshape subtype(VERTEX,EDGE,WIRE,FACE,SHELL,SOLID) [name1 or .] [name2 or .] [name n or .]", - __FILE__, V2dPickShape, group); - - theCommands.Add("v2dtypes", - "v2dtypes : list of known types and signatures in AIS2D - To be Used in vpickobject command for selection with filters", - V2dIOTypes,group); - - theCommands.Add("v2dr", - "v2dr : reading of the shape", - __FILE__, v2dr, group);*/ -} diff --git a/src/Viewer2dTest/Viewer2dTest_ObjectCommands.cxx b/src/Viewer2dTest/Viewer2dTest_ObjectCommands.cxx deleted file mode 100755 index 21909cb875..0000000000 --- a/src/Viewer2dTest/Viewer2dTest_ObjectCommands.cxx +++ /dev/null @@ -1,1607 +0,0 @@ -// Copyright (c) 1999-2012 OPEN CASCADE SAS -// -// The content of this file is subject to the Open CASCADE Technology Public -// License Version 6.5 (the "License"). You may not use the content of this file -// except in compliance with the License. Please obtain a copy of the License -// at http://www.opencascade.org and read it completely before using this file. -// -// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its -// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. -// -// The Original Code and all software distributed under the License is -// distributed on an "AS IS" basis, without warranty of any kind, and the -// Initial Developer hereby disclaims all such warranties, including without -// limitation, any warranties of merchantability, fitness for a particular -// purpose or non-infringement. Please see the License for the specific terms -// and conditions governing the rights and limitations under the License. - - -//=============================================== -// AIS2D Objects Creation : Datums (axis,trihedrons,lines,planes) -//=============================================== - -#ifdef HAVE_CONFIG_H -# include -#endif - -#include - -#include - -#include - -#include -#include -#include -#include - -#include -#include -#include - -#include -#include -#include - -#include -#include -#include - -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include - -#include - -#include -#include - -#include -#include - -#include -#include - -#include -#include -#include -#include -#include - -#include -#include - -#include - -extern Viewer2dTest_DoubleMapOfInteractiveAndName& GetMapOfAIS2D(); -Standard_IMPORT int ViewerMainLoop2d (Standard_Integer argc, const char** argv); -extern Handle(AIS2D_InteractiveContext)& TheAIS2DContext(); - -//============================================================================== -//function : SelectShape2d -//purpose : -//============================================================================== -TopoDS_Shape SelectShape2d (int theSelType) -{ - TopoDS_Shape ShapeA; - -// if (theSelType != 5) -// TheAIS2DContext()->ActivateStandardMode(AIS2D_ProjShape::SelectionType(theSelType)); - - switch (theSelType) - { - case 1: - cout << " Select a vertex ..." << endl; - break; - case 2: - cout << " Select an edge ..." << endl; - break; - case 4: - cout << " Select a face ..." << endl; - break; - case 5: // user defined text - break; - default: - cout << " Incorrect selection mode" << endl; - break; - } - - Standard_Integer argcc = 5; - const char *buff[] = { "VPick", "X", "VPickY","VPickZ", "VPickShape" }; - const char **argvv = (const char **) buff; - while (ViewerMainLoop2d(argcc, argvv)) {} - -/* for (TheAIS2DContext()->InitSelected(); - TheAIS2DContext()->MoreSelected(); - TheAIS2DContext()->NextSelected()) - { - ShapeA = TheAIS2DContext()->SelectedShape(); - }*/ - -// if (theSelType != 5) -// TheAIS2DContext()->DeactivateStandardMode(AIS2D_ProjShape::SelectionType(theSelType)); - - return ShapeA; -} -#if 0 -//============================================================================== -//function : V2dTrihedron2D -//purpose : Create a plane with a 2D trihedron from a faceselection -//Draw arg : v2dtri2d name -//============================================================================== -static int V2dTrihedron2D (Draw_Interpretor& , Standard_Integer argc, const char** argv) -{ - if (argc != 2) - { - cout << argv[0] << " wrong arguments number" << endl; - return 1; - } - - // Declarations - Standard_Integer myCurrentIndex; - - // Fermeture des contextes - TheAIS2DContext()->CloseAllContext(); - - // Ouverture d'un contexte local et recuperation de son index. - TheAIS2DContext()->OpenLocalContext(); - myCurrentIndex = TheAIS2DContext()->IndexOfCurrentLocal(); - - TopoDS_Shape ShapeB = SelectShape2d(4); // Face - TopoDS_Face FaceB = TopoDS::Face(ShapeB); - - // Construction du Plane - // recuperation des edges des faces. - TopExp_Explorer FaceExpB (FaceB, TopAbs_EDGE); - - TopoDS_Edge EdgeB = TopoDS::Edge(FaceExpB.Current()); - - // declarations - gp_Pnt A,B,C; - - // si il y a plusieurs edges - if (FaceExpB.More()) - { - FaceExpB.Next(); - TopoDS_Edge EdgeC = TopoDS::Edge(FaceExpB.Current()); - BRepAdaptor_Curve theCurveB (EdgeB); - BRepAdaptor_Curve theCurveC (EdgeC); - A = theCurveC.Value(0.1); - B = theCurveC.Value(0.9); - C = theCurveB.Value(0.5); - } - else - { - // FaceB a 1 unique edge courbe - BRepAdaptor_Curve theCurveB (EdgeB); - A = theCurveB.Value(0.1); - B = theCurveB.Value(0.9); - C = theCurveB.Value(0.5); - } - // Construction du Geom_Plane - GC_MakePlane MkPlane (A,B,C); - Handle(Geom_Plane) theGeomPlane = MkPlane.Value(); - - // Construction de l'AIS2D_PlaneTrihedron -// Handle(AIS2D_PlaneTrihedron) theAIS2DPlaneTri = new AIS2D_PlaneTrihedron(theGeomPlane); - - // Fermeture du contexte local. - TheAIS2DContext()->CloseLocalContext(myCurrentIndex); - - // on le display & bind -// TheAIS2DContext()->Display(theAIS2DPlaneTri); -// GetMapOfAIS2D().Bind(theAIS2DPlaneTri, argv[1]); - - return 0; -} -#endif - -//============================================================================== -//function : V2dTrihedron -//purpose : Create a trihedron. If no arguments are set, the default -// trihedron (Oxyz) is created. -//Draw arg : vtrihedron name [Xo] [Yo] [Zo] [Zu] [Zv] [Zw] [Xu] [Xv] [Xw] -//============================================================================== -/*static int V2dTrihedron (Draw_Interpretor& , Standard_Integer argc, const char** argv) -{ - // Verification des arguments - if (argc < 2 || argc > 11) - { - cout << argv[0] << " Syntaxe error" << endl; - return 1; - } - - TCollection_AsciiString name = argv[1]; - - if (argc > 5 && argc != 11) - { - cout << argv[0] << " Syntaxe error" << endl; - return 1; - } - - Standard_Real coord[9] = {0.,0.,0.,0.,0.,1.,1.,0.,0.}; - if (argc > 2) - { - Standard_Integer i; - for (i = 0; i <= 2; i++) - coord[i] = atof(argv[2+i]); - - if (argc > 5) - { - for (i = 0; i <= 2; i++) - { - coord[3+i] = atof(argv[6+i]); - coord[6+i] = atof(argv[8+i]); - } - } - } - gp_Pnt ThePoint (coord[0],coord[1],coord[2]); - gp_Dir TheZVector (coord[3],coord[4],coord[5]); - gp_Dir TheXVector (coord[6],coord[7],coord[8]); - - if (!TheZVector.IsNormal(TheXVector,M_PI/180)) - { - cout << argv[0] << " VectorX is not normal to VectorZ" << endl; - return 1; - } - - Handle(Geom_Axis2Placement) OrigineAndAxii = new Geom_Axis2Placement(ThePoint,TheZVector,TheXVector); - - // Creation du triedre - Handle(AIS2D_Trihedron) aShape = new AIS2D_Trihedron(OrigineAndAxii); - GetMapOfAIS2D().Bind(aShape,name); - TheAIS2DContext()->Display(aShape); - - return 0; -}*/ -#if 0 -//============================================================================== -//function : V2dSize -//purpose : Change the size of a named or selected trihedron -// if no name : it affects the trihedrons witch are selected otherwise nothing is donne -// if no value, the value is set at 100 by default -//Draw arg : v2dsize [name] [size] -//============================================================================== -static int V2dSize (Draw_Interpretor& , Standard_Integer argc, const char** argv) -{ - Standard_Boolean ThereIsName; - Standard_Real value; - // Quantity_NameOfColor col = Quantity_NOC_BLACK; - - if (argc > 3) - { - cout << argv[0] << " Syntaxe error" << endl; - return 1; - } - - if (argc == 1) - { - ThereIsName = Standard_False; - value = 100; - } - else if (argc == 2) - { - ThereIsName = Standard_False; - value = atof(argv[1]); - } - else - { - ThereIsName = Standard_True; - value = atof(argv[2]); - } - - if (TheAIS2DContext()->HasOpenedContext()) TheAIS2DContext()->CloseLocalContext(); - - if (!ThereIsName) - { -// if (TheAIS2DContext()->NbCurrents() <= 0) return -1; - Viewer2dTest_DoubleMapIteratorOfDoubleMapOfInteractiveAndName it (GetMapOfAIS2D()); - - while (it.More()) - { - Handle(AIS2D_InteractiveObject) aShape = it.Key1(); - - if (TheAIS2DContext()->IsCurrent(aShape)) - { -/* if (aShape->Type() == AIS2D_KOI_Datum && aShape->Signature() == 3) - { - if (aShape->HasColor()) - { - hascol = Standard_True; - col = aShape->Color(); - } - else hascol = Standard_False; - - Handle(AIS2D_Trihedron) aTrihedron = *(Handle(AIS2D_Trihedron)*) &aShape; - - aTrihedron->SetSize(value); - - if (hascol) aTrihedron->SetColor(col); - else aTrihedron->UnsetColor(); - - // The trihedron hasn't be errased from the map - // so you just have to redisplay it - TheAIS2DContext()->Redisplay(aTrihedron, Standard_False); - }*/ - } - it.Next(); - } - TheAIS2DContext()->UpdateCurrentViewer(); - } - else - { - TCollection_AsciiString name = argv[1]; - - if (GetMapOfAIS2D().IsBound2(name)) - { - Handle(AIS2D_InteractiveObject) aShape = GetMapOfAIS2D().Find2(name); - -/* if (aShape->Type() == AIS2D_KOI_Datum && aShape->Signature() == 3) - { - if (aShape->HasColor()) - { - hascol = Standard_True; - col = aShape->Color(); - } - else hascol = Standard_False; - - // On downcast aShape de AIS2D_InteractiveObject a AIS2D_Trihedron - // pour lui appliquer la methode SetSize() - Handle(AIS2D_Trihedron) aTrihedron = *(Handle(AIS2D_Trihedron)*) &aShape; - - aTrihedron->SetSize(value); - - if (hascol) aTrihedron->SetColor(col); - else aTrihedron->UnsetColor(); - - // The trihedron hasn't be errased from the map - // so you just have to redisplay it - TheAIS2DContext()->Redisplay(aTrihedron, Standard_False); - - TheAIS2DContext()->UpdateCurrentViewer(); - }*/ - } - } - return 0; -} -#endif - -//============================================================================== -//function : V2dPlaneTrihedron -//purpose : Create a plane from a trihedron selection. If no arguments are set, the default -//Draw arg : v2dplanetri name -//============================================================================== -/*static int V2dPlaneTrihedron (Draw_Interpretor& , Standard_Integer argc, const char** argv) -{ - if (argc != 2) - { - cout << argv[0] << " error" << endl; - return 1; - } - - Standard_Integer myCurrentIndex; - TheAIS2DContext()->CloseAllContexts(); - TheAIS2DContext()->OpenLocalContext(Standard_False); - myCurrentIndex = TheAIS2DContext()->IndexOfCurrentLocal(); - - Viewer2dTest_DoubleMapIteratorOfDoubleMapOfInteractiveAndName it (GetMapOfAIS2D()); - while (it.More()) - { - Handle(AIS2D_InteractiveObject) ShapeA = it.Key1(); - if (ShapeA->Type() == AIS2D_KOI_Datum && ShapeA->Signature() == 3) - { - Handle(AIS2D_Trihedron) TrihedronA = ((*(Handle(AIS2D_Trihedron)*)&ShapeA)); - TheAIS2DContext()->Load(TrihedronA,0,Standard_False); - TheAIS2DContext()->Activate(TrihedronA,3); - } - it.Next(); - } - - cout<<" Select a plane."<InitSelected(); - TheAIS2DContext()->MoreSelected(); TheAIS2DContext()->NextSelected()) - { - theIOB = TheAIS2DContext()->Interactive(); - } - Handle(AIS2D_Plane) PlaneB = ((*(Handle(AIS2D_Plane)*)&theIOB)); - - TheAIS2DContext()->CloseLocalContext(myCurrentIndex); - - // Construction de l'AIS2D_Plane - //gp_Pnt A,B,C; - //Handle(Geom_Plane) theGeomPlane; - //PlaneB->PlaneAttributes(theGeomPlane,A,B,C); - //Handle(AIS2D_PlaneTrihedron) theAIS2DPlaneTri= new AIS2D_PlaneTrihedron(theGeomPlane ); - - // on le display & bind - TheAIS2DContext()->Display(PlaneB); - GetMapOfAIS2D().Bind(PlaneB, argv[1]); - - return 0; -}*/ - -//============================================================================== -// Fonction First click 2de click -// -// v2daxis vertex vertex -// edge None -// v2daxispara edge vertex -// v2daxisortho edge Vertex -// v2daxisinter Face Face -//============================================================================== - -//============================================================================== -//function : V2dAxisBuilder -//purpose : -//Draw arg : v2daxis AxisName Xa Ya Xb Yb -//============================================================================== -static int V2dAxisBuilder (Draw_Interpretor& , Standard_Integer argc, const char** argv) -{ - Standard_Boolean HasArg; - TCollection_AsciiString name; - Standard_Integer MyCurrentIndex; - - if (argc < 2 || argc > 6) - { - cout << " Syntaxe error" << endl; - return 1; - } - if (argc == 6) HasArg = Standard_True; - else HasArg = Standard_False; - - name = argv[1]; - TheAIS2DContext()->CloseAllContext(); - - Handle(V2d_View) V = Viewer2dTest::CurrentView(); - - if (HasArg) - { - Standard_Real coord [4]; - for (Standard_Integer i = 0; i <= 3; i++) - { - coord[i] = atof(argv[2+i]); - } -// gp_Pnt2d p1 (coord[0],coord[1]); -// gp_Pnt2d p2 (coord[2],coord[3]); - - Handle(Graphic2d_GraphicObject) obj = - new Graphic2d_GraphicObject(V->View()); - - Handle(Graphic2d_InfiniteLine) line = new Graphic2d_InfiniteLine - (obj, coord[0], coord[1], coord[2] - coord[0], coord[3] - coord[1]); - - obj->Display(); - V->Viewer()->Update(); -// gp_Vec2d myVect (p1, p2); -// Handle(Geom2d_Line) myLine = new Geom2d_Line(p1, myVect); -// Handle(AIS2D_Axis) TheAxis = new AIS2D_Axis(myLine); -// GetMapOfAIS2D().Bind(TheAxis,name); -// TheAIS2DContext()->Display(TheAxis); - } - else - { - // fonction vaxis - // Purpose: Teste le constructeur AIS2D_Axis::AIS2D_Axis (x:Axis1Placement from Geom) - if (!strcasecmp(argv[0], "v2daxis")) - { - TheAIS2DContext()->OpenLocalContext(); - MyCurrentIndex = TheAIS2DContext()->IndexOfCurrentLocal(); - - // Active le mode edge et le mode vertex -// TheAIS2DContext()->ActivateStandardMode(AIS2D_ProjShape::SelectionType(1)); -// TheAIS2DContext()->ActivateStandardMode(AIS2D_ProjShape::SelectionType(2)); - cout << " Select an edge or a vertex." << endl; - - TopoDS_Shape ShapeA = SelectShape2d(5); - - if (ShapeA.ShapeType() == TopAbs_VERTEX) - { -// TheAIS2DContext()->DeactivateStandardMode(AIS2D_ProjShape::SelectionType(2)); - cout << " Select a different vertex." << endl; - - TopoDS_Shape ShapeB; - do - { - ShapeB = SelectShape2d(5); - } while (ShapeB.IsSame(ShapeA)); - - TheAIS2DContext()->CloseLocalContext(MyCurrentIndex); - - // Construction de l'axe - gp_Pnt A = BRep_Tool::Pnt(TopoDS::Vertex(ShapeA)); - gp_Pnt B = BRep_Tool::Pnt(TopoDS::Vertex(ShapeB)); - gp_Vec aV (A,B); - gp_Dir D (aV); - Handle(Geom_Axis1Placement) OrigineAndVect = new Geom_Axis1Placement(A,D); -// Handle(AIS2D_Axis) TheAxis = new AIS2D_Axis(OrigineAndVect); -// GetMapOfAIS2D().Bind(TheAxis,name); -// TheAIS2DContext()->Display(TheAxis); - } - else - { - // Un unique edge (ShapeA) a ete picke - // Fermeture du context local - TheAIS2DContext()->CloseLocalContext(MyCurrentIndex); - // Constuction de l'axe - TopoDS_Edge ed = TopoDS::Edge(ShapeA); - TopoDS_Vertex Va,Vb; - TopExp::Vertices(ed,Va,Vb ); - gp_Pnt A = BRep_Tool::Pnt(Va); - gp_Pnt B = BRep_Tool::Pnt(Vb); - gp_Vec aV (A,B); - gp_Dir D (aV); - Handle(Geom_Axis1Placement) OrigineAndVect = new Geom_Axis1Placement(A,D); -// Handle(AIS2D_Axis) TheAxis = new AIS2D_Axis(OrigineAndVect); -// GetMapOfAIS2D().Bind(TheAxis,name); -// TheAIS2DContext()->Display(TheAxis); - } - } - - // Fonction axispara - // Purpose: Teste le constructeur AIS2D_Axis::AIS2D_Axis(x: Axis2Placement from Geom, y: TypeOfAxis from AIS2D) - else if (!strcasecmp(argv[0], "v2daxispara")) - { - TheAIS2DContext()->OpenLocalContext(); - MyCurrentIndex = TheAIS2DContext()->IndexOfCurrentLocal(); - - TopoDS_Shape ShapeA = SelectShape2d(2); // Edge - TopoDS_Shape ShapeB = SelectShape2d(1); // Vertex - - // Fermeture du context local - TheAIS2DContext()->CloseLocalContext(MyCurrentIndex); - - // Construction de l'axe - TopoDS_Edge ed = TopoDS::Edge(ShapeA); - gp_Pnt B = BRep_Tool::Pnt(TopoDS::Vertex(ShapeB)); - TopoDS_Vertex Va,Vc; - TopExp::Vertices(ed,Va,Vc); - gp_Pnt A = BRep_Tool::Pnt(Va); - gp_Pnt C = BRep_Tool::Pnt(Vc); - gp_Vec aV (A,C); - gp_Dir D (aV); - Handle(Geom_Axis1Placement) OrigineAndVect = new Geom_Axis1Placement(B,D); -// Handle(AIS2D_Axis) TheAxis = new AIS2D_Axis(OrigineAndVect); -// GetMapOfAIS2D().Bind(TheAxis,name); -// TheAIS2DContext()->Display(TheAxis); - } - else // Fonction axisortho - { - TheAIS2DContext()->OpenLocalContext(); - MyCurrentIndex = TheAIS2DContext()->IndexOfCurrentLocal(); - - TopoDS_Shape ShapeA = SelectShape2d(2); // Edge - TopoDS_Shape ShapeB = SelectShape2d(1); // Vertex - - // Fermeture du context local - TheAIS2DContext()->CloseLocalContext(MyCurrentIndex); - - // Construction de l'axe - TopoDS_Edge ed = TopoDS::Edge(ShapeA); - gp_Pnt B = BRep_Tool::Pnt(TopoDS::Vertex(ShapeB)); - TopoDS_Vertex Va,Vc; - TopExp::Vertices(ed,Va,Vc); - gp_Pnt A = BRep_Tool::Pnt(Va); - gp_Pnt C = BRep_Tool::Pnt(Vc); - gp_Pnt E (A.Y()+A.Z()-C.Y()-C.Z(), C.X()-A.X(), C.X()-A.X()); - // W = AE est un vecteur orthogonal a AC - gp_Vec aV (A,E); - gp_Dir D (aV); - Handle(Geom_Axis1Placement) OrigineAndVect = new Geom_Axis1Placement(B,D); -// Handle(AIS2D_Axis) TheAxis = new AIS2D_Axis(OrigineAndVect); -// GetMapOfAIS2D().Bind(TheAxis,name); -// TheAIS2DContext()->Display(TheAxis); - } - } - - return 0; -} - -//============================================================================== -// Fonction First click Result -// -// vpoint vertex AIS2D_Point=Vertex -// edge AIS2D_Point=Middle of the edge -//============================================================================== - -#if 0 -//============================================================================== -//function : V2dPointBuilder -//purpose : Build an AIS2D_Point from coordinates or with a selected vertex or edge -//Draw arg : v2dpoint PoinName [Xa] [Ya] -//============================================================================== -static int V2dPointBuilder (Draw_Interpretor& , Standard_Integer argc, const char** argv) -{ - // Declarations - Standard_Boolean HasArg; - TCollection_AsciiString name; - Standard_Integer myCurrentIndex; - - // Verification - if (argc < 2 || argc > 4 ) - { - cout << " Syntaxe error" << endl; - return 1; - } - if (argc == 4) HasArg = Standard_True; - else HasArg = Standard_False; - - name = argv[1]; - // Fermeture des contextes - TheAIS2DContext()->CloseAllContext(); - - // Il y a des arguments: teste l'unique constructeur AIS2D_Pnt::AIS2D_Pnt(Point from Geom) - if (HasArg) - { - Standard_Real thecoord[3]; - for (Standard_Integer i = 0; i <= 2; i++) thecoord[i] = atof(argv[2+i]); - Handle(Geom2d_CartesianPoint) myGeomPoint = new Geom2d_CartesianPoint(thecoord[0],thecoord[1]); -// Handle(AIS2D_Point) myAIS2DPoint = new AIS2D_Point(myGeomPoint); -// GetMapOfAIS2D().Bind(myAIS2DPoint, name); -// TheAIS2DContext()->Display(myAIS2DPoint); - } - else // Il n'a pas d'arguments - { - TheAIS2DContext()->OpenLocalContext(); - myCurrentIndex = TheAIS2DContext()->IndexOfCurrentLocal(); - -// TheAIS2DContext()->ActivateStandardMode (AIS2D_ProjShape::SelectionType(1)); -// TheAIS2DContext()->ActivateStandardMode (AIS2D_ProjShape::SelectionType(2)); - cout << " Select a vertex or an edge (build the middle)" << endl; - TopoDS_Shape ShapeA = SelectShape2d(5); - - if (ShapeA.ShapeType() == TopAbs_VERTEX) - { - TheAIS2DContext()->CloseLocalContext(myCurrentIndex); - - // Construction du point - gp_Pnt A = BRep_Tool::Pnt(TopoDS::Vertex(ShapeA)); - Handle(Geom_CartesianPoint) myGeomPoint = new Geom_CartesianPoint(A); -// Handle(AIS2D_Point) myAIS2DPoint = new AIS2D_Point(myGeomPoint); -// GetMapOfAIS2D().Bind(myAIS2DPoint,name); -// TheAIS2DContext()->Display(myAIS2DPoint); - } - else - { - // Un Edge a ete selectionne - // Fermeture du context local - TheAIS2DContext()->CloseLocalContext(myCurrentIndex); - - // Construction du point milieu de l'edge - TopoDS_Edge myEdge = TopoDS::Edge(ShapeA); - TopoDS_Vertex myVertexA,myVertexB; - TopExp::Vertices (myEdge, myVertexA, myVertexB); - gp_Pnt A = BRep_Tool::Pnt(myVertexA); - gp_Pnt B = BRep_Tool::Pnt(myVertexB); - - Handle(Geom_CartesianPoint) myGeomPointM = - new Geom_CartesianPoint((A.X()+B.X())/2, (A.Y()+B.Y())/2, (A.Z()+B.Z())/2); -// Handle(AIS2D_Point) myAIS2DPointM = new AIS2D_Point(myGeomPointM); -// GetMapOfAIS2D().Bind(myAIS2DPointM, name); -// TheAIS2DContext()->Display(myAIS2DPointM); - } - } - - return 0; -} -#endif - -//============================================================================== -// Fonction 1st click 2de click 3de click -// v2dplane Vertex Vertex Vertex -// Vertex Edge -// Edge Vertex -// Face -// v2dplanepara Face Vertex -// Vertex Face -// v2dplaneortho Face Edge -// Edge Face -//============================================================================== - -//============================================================================== -//function : V2dPlaneBuilder -//purpose : Build an AIS2D_Plane from selected entities or Named AIs components -//Draw arg : v2dplane PlaneName [AxisName] [PointName] -// [PointName] [PointName] [PointName] -// [PlaneName] [PointName] -//============================================================================== -/*#include -#include -#include -#include -#include -static int V2dPlaneBuilder (Draw_Interpretor& , Standard_Integer argc, const char** argv) -{ - Standard_Boolean HasArg; - TCollection_AsciiString name; - Standard_Integer myCurrentIndex; - - if (argc < 2 || argc > 5) - { - cout << " Syntaxe error" << endl; - return 1; - } - - if (argc == 5 || argc == 4) HasArg = Standard_True; - else HasArg = Standard_False; - - name = argv[1]; - TheAIS2DContext()->CloseAllContexts(); - - if (HasArg) - { - if (!GetMapOfAIS2D().IsBound2(argv[2])) - { - cout << "v2dplane: error 1st name doesn't exist in the GetMapOfAIS2D()." << endl; - return 1; - } - Handle(AIS2D_InteractiveObject) theShapeA = GetMapOfAIS2D().Find2(argv[2]); - - if (theShapeA->Type() == AIS2D_KOI_Datum && theShapeA->Signature() == 1) - { - if (argc < 5 || !GetMapOfAIS2D().IsBound2(argv[3])) - { - cout << "v2dplane: error 2de name doesn't exist in the GetMapOfAIS2D()." << endl; - return 1; - } - Handle(AIS2D_InteractiveObject) theShapeB = GetMapOfAIS2D().Find2(argv[3]); - if (!(theShapeB->Type() == AIS2D_KOI_Datum && theShapeB->Signature() == 1)) - { - cout << "v2dplane: error 2de object is expected to be an AIS2D_Point. " << endl; - return 1; - } - if (!GetMapOfAIS2D().IsBound2(argv[4])) - { - cout << "v2dplane: error 3de name doesn't exist in the GetMapOfAIS2D()." << endl; - return 1; - } - Handle(AIS2D_InteractiveObject) theShapeC = GetMapOfAIS2D().Find2(argv[4]); - if (!(theShapeC->Type() == AIS2D_KOI_Datum && theShapeC->Signature() == 1)) - { - cout << "v2dplane: error 3de object is expected to be an AIS2D_Point. " << endl; - return 1; - } - - Handle(AIS2D_Point) theAIS2DPointA = *(Handle(AIS2D_Point)*)& theShapeA; - Handle(AIS2D_Point) theAIS2DPointB = *(Handle(AIS2D_Point)*)& theShapeB; - Handle(AIS2D_Point) theAIS2DPointC = *(Handle(AIS2D_Point)*)& theShapeC; - - Handle(Geom_Point) myGeomPointA = theAIS2DPointA->Component(); - Handle(Geom_CartesianPoint) myCartPointA = *((Handle(Geom_CartesianPoint)*)& myGeomPointA); - - Handle(Geom_Point) myGeomPointB = theAIS2DPointB->Component(); - Handle(Geom_CartesianPoint) myCartPointB= *((Handle(Geom_CartesianPoint)*)& theAIS2DPointB); - - Handle(Geom_Point) myGeomPointBC = theAIS2DPointC->Component(); - Handle(Geom_CartesianPoint) myCartPointC = *((Handle(Geom_CartesianPoint)*)& theAIS2DPointC); - - if (myCartPointB->X() == myCartPointA->X() && - myCartPointB->Y() == myCartPointA->Y() && myCartPointB->Z() == myCartPointA->Z()) - { - // B=A - cout << "v2dplane error: same points" << endl; - return 1; - } - if (myCartPointC->X() == myCartPointA->X() && - myCartPointC->Y() == myCartPointA->Y() && myCartPointC->Z() == myCartPointA->Z()) - { - // C=A - cout << "v2dplane error: same points" << endl; - return 1; - } - if (myCartPointC->X() == myCartPointB->X() && - myCartPointC->Y() == myCartPointB->Y() && myCartPointC->Z() == myCartPointB->Z()) - { - // C=B - cout << "v2dplane error: same points" << endl; - return 1; - } - - gp_Pnt A = myCartPointA->Pnt(); - gp_Pnt B = myCartPointB->Pnt(); - gp_Pnt C = myCartPointC->Pnt(); - - // Construction de l'AIS2D_Plane - GC_MakePlane MkPlane (A,B,C); - Handle(Geom_Plane) myGeomPlane = MkPlane.Value(); - Handle(AIS2D_Plane) myAIS2DPlane = new AIS2D_Plane(myGeomPlane); - GetMapOfAIS2D().Bind(myAIS2DPlane, name); - TheAIS2DContext()->Display(myAIS2DPlane); - } - - else if (theShapeA->Type() == AIS2D_KOI_Datum && theShapeA->Signature() == 2) - { - if (argc != 4 || !GetMapOfAIS2D().IsBound2(argv[3])) - { - cout << "v2dplane: error 2de name doesn't exist in the GetMapOfAIS2D()." << endl; - return 1; - } - Handle(AIS2D_InteractiveObject) theShapeB = GetMapOfAIS2D().Find2(argv[3]); - if (!(theShapeB->Type() == AIS2D_KOI_Datum && theShapeB->Signature() == 1)) - { - cout << "v2dplane: error 2de object is expected to be an AIS2D_Point." << endl; - return 1; - } - - Handle(AIS2D_Axis) theAIS2DAxisA = *(Handle(AIS2D_Axis)*)& theShapeA; - Handle(AIS2D_Point) theAIS2DPointB = *(Handle(AIS2D_Point)*)& theShapeB; - - Handle(Geom_Line) myGeomLineA = theAIS2DAxisA->Component(); - Handle(Geom_Point) myGeomPointB = theAIS2DPointB->Component(); - - gp_Ax1 myAxis = myGeomLineA->Position(); - Handle(Geom_CartesianPoint) myCartPointB = *(Handle(Geom_CartesianPoint)*)& myGeomPointB; - - gp_Dir D = myAxis.Direction(); - gp_Pnt B = myCartPointB->Pnt(); - - // Construction de l'AIS2D_Plane - Handle(Geom_Plane) myGeomPlane = new Geom_Plane(B,D); - Handle(AIS2D_Plane) myAIS2DPlane = new AIS2D_Plane(myGeomPlane,B); - GetMapOfAIS2D().Bind(myAIS2DPlane, name); - TheAIS2DContext()->Display(myAIS2DPlane); - } - else if (theShapeA->Type() == AIS2D_KOI_Datum && theShapeA->Signature() == 7) - { - if (argc != 4 || !GetMapOfAIS2D().IsBound2(argv[3])) - { - cout << "vplane: error 2de name doesn't exist in the GetMapOfAIS2D()." << endl; - return 1; - } - Handle(AIS2D_InteractiveObject) theShapeB = GetMapOfAIS2D().Find2(argv[3]); - if (!(theShapeB->Type() == AIS2D_KOI_Datum && theShapeB->Signature() == 1)) - { - cout << "vplane: error 2de object is expected to be an AIS2D_Point." << endl; - return 1; - } - - Handle(AIS2D_Plane) theAIS2DPlaneA = *(Handle(AIS2D_Plane)*)& theShapeA; - Handle(AIS2D_Point) theAIS2DPointB = *(Handle(AIS2D_Point)*)& theShapeB; - - Handle(Geom_Plane) theNewGeomPlane = theAIS2DPlaneA->Component(); - Handle(Geom_Point) myGeomPointB = theAIS2DPointB->Component(); - - Handle(Geom_CartesianPoint) myCartPointB = *(Handle(Geom_CartesianPoint)*)& myGeomPointB; - gp_Pnt B = myCartPointB->Pnt(); - - // Construction de l'AIS2D_Plane - Handle(AIS2D_Plane) myAIS2DPlane = new AIS2D_Plane(theNewGeomPlane,B); - GetMapOfAIS2D().Bind(myAIS2DPlane, name); - TheAIS2DContext()->Display(myAIS2DPlane); - } - else - { - cout << "v2dplane: error 1st object is not an AIS2D." << endl; - return 1; - } - } - else - { - if (!strcasecmp(argv[0] ,"v2dplane")) - { - TheAIS2DContext()->OpenLocalContext(); - myCurrentIndex = TheAIS2DContext()->IndexOfCurrentLocal(); - - TheAIS2DContext()->ActivateStandardMode(AIS2D_ProjShape::SelectionType(1)); - TheAIS2DContext()->ActivateStandardMode(AIS2D_ProjShape::SelectionType(2)); - cout << "Select a vertex, a face or an edge." << endl; - ShapeA = SelectShape2d(5); // User-defined mode - TheAIS2DContext()->ActivateStandardMode(AIS2D_ProjShape::SelectionType(4)); - - if (ShapeA.ShapeType() == TopAbs_VERTEX) - { - TheAIS2DContext()->DeactivateStandardMode(AIS2D_ProjShape::SelectionType(4)); - cout << " Select an edge or a different vertex." << endl; - TopoDS_Shape ShapeB = SelectShape2d(5); - - if (ShapeB.ShapeType() == TopAbs_VERTEX) - { - if (ShapeB.IsSame(ShapeA)) - { - cout << " v2dplane: error, same points selected" << endl; - return 1; - } - TheAIS2DContext()->DeactivateStandardMode(AIS2D_ProjShape::SelectionType(2)); - cout<<" Select a different vertex."<CloseLocalContext(myCurrentIndex); - - // Construction du plane - gp_Pnt A = BRep_Tool::Pnt(TopoDS::Vertex(ShapeA)); - gp_Pnt B = BRep_Tool::Pnt(TopoDS::Vertex(ShapeB)); - gp_Pnt C = BRep_Tool::Pnt(TopoDS::Vertex(ShapeC)); - GC_MakePlane MkPlane (A,B,C); - Handle(Geom_Plane) theGeomPlane = MkPlane.Value(); - Handle(AIS2D_Plane) myAIS2DPlane = new AIS2D_Plane(theGeomPlane); - GetMapOfAIS2D().Bind(myAIS2DPlane, name); - TheAIS2DContext()->Display(myAIS2DPlane); - } - else // ShapeB est un edge - { - TopoDS_Edge EdgeB = TopoDS::Edge(ShapeB); - TopoDS_Vertex VertA = TopoDS::Vertex(ShapeA); - - BRepExtrema_ExtPC OrthoProj (VertA, EdgeB); - if (OrthoProj.Value(1) < 0.001) - { - cout << " v2dplane: error point is on the edge." << endl; - return 1; - } - else - { - TheAIS2DContext()->CloseLocalContext(myCurrentIndex); - // Construction du plane - gp_Pnt A = BRep_Tool::Pnt(VertA); - TopoDS_Vertex VBa, VBb; - TopExp::Vertices(EdgeB, VBa, VBb); - gp_Pnt Ba = BRep_Tool::Pnt(VBa); - gp_Pnt Bb = BRep_Tool::Pnt(VBb); - GC_MakePlane MkPlane (A,Ba,Bb); - Handle(Geom_Plane) theGeomPlane = MkPlane.Value(); - Handle(AIS2D_Plane) myAIS2DPlane = new AIS2D_Plane(theGeomPlane); - GetMapOfAIS2D().Bind(myAIS2DPlane, name); - TheAIS2DContext()->Display(myAIS2DPlane); - } - } - } - else if (ShapeA.ShapeType() == TopAbs_EDGE) - { - TheAIS2DContext()->DeactivateStandardMode(AIS2D_ProjShape::SelectionType(4)); - TheAIS2DContext()->DeactivateStandardMode(AIS2D_ProjShape::SelectionType(2)); - cout << " Select a vertex that don't belong to the edge." << endl; - TopoDS_Shape ShapeB = SelectShape2d(5); - - TopoDS_Edge EdgeA = TopoDS::Edge(ShapeA); - TopoDS_Vertex VertB = TopoDS::Vertex(ShapeB); - - BRepExtrema_ExtPC OrthoProj (VertB,EdgeA); - if (OrthoProj.Value(1) < 0.001) - { - cout << " v2dplane: error point is on the edge." << endl; - return 1; - } - else - { - TheAIS2DContext()->CloseLocalContext(myCurrentIndex); - // Construction du plane - gp_Pnt B = BRep_Tool::Pnt(VertB); - TopoDS_Vertex VAa, VAb; - TopExp::Vertices(EdgeA, VAa, VAb); - gp_Pnt Aa = BRep_Tool::Pnt(VAa); - gp_Pnt Ab = BRep_Tool::Pnt(VAb); - GC_MakePlane MkPlane (B,Aa,Ab); - Handle(Geom_Plane) theGeomPlane = MkPlane.Value(); - Handle(AIS2D_Plane) myAIS2DPlane = new AIS2D_Plane(theGeomPlane); - GetMapOfAIS2D().Bind(myAIS2DPlane, name); - TheAIS2DContext()->Display(myAIS2DPlane); - } - } - else // ShapeA est une Face - { - TheAIS2DContext()->CloseLocalContext(myCurrentIndex); - // Construction du plane - TopoDS_Face myFace = TopoDS::Face(ShapeA); - BRepAdaptor_Surface mySurface (myFace, Standard_False); - if (mySurface.GetType() == GeomAbs_Plane) - { - gp_Pln myPlane = mySurface.Plane(); - Handle(Geom_Plane) theGeomPlane = new Geom_Plane(myPlane); - Handle(AIS2D_Plane) myAIS2DPlane = new AIS2D_Plane(theGeomPlane); - GetMapOfAIS2D().Bind(myAIS2DPlane, name); - TheAIS2DContext()->Display(myAIS2DPlane); - } - else - { - cout << " v2dplane: error" << endl; - return 1; - } - } - } - else if (!strcasecmp(argv[0], "v2dplanepara")) - { - TheAIS2DContext()->OpenLocalContext(); - myCurrentIndex = TheAIS2DContext()->IndexOfCurrentLocal(); - - TheAIS2DContext()->ActivateStandardMode(AIS2D_ProjShape::SelectionType(1)); - TheAIS2DContext()->ActivateStandardMode(AIS2D_ProjShape::SelectionType(4)); - cout << " Select a vertex or a face." << endl; - TopoDS_Shape ShapeA = SelectShape2d(5); - - if (ShapeA.ShapeType() == TopAbs_VERTEX) - { - TheAIS2DContext()->DeactivateStandardMode(AIS2D_ProjShape::SelectionType(1)); - cout<<" Select a face."<CloseLocalContext(myCurrentIndex); - - // Construction du plane - gp_Pnt A = BRep_Tool::Pnt(TopoDS::Vertex(ShapeA)); - - TopoDS_Face myFace = TopoDS::Face(ShapeB); - BRepAdaptor_Surface mySurface (myFace, Standard_False); - if (mySurface.GetType() == GeomAbs_Plane) - { - gp_Pln myPlane = mySurface.Plane(); - myPlane.SetLocation(A); - Handle(Geom_Plane) theGeomPlane = new Geom_Plane(myPlane); - Handle(AIS2D_Plane) myAIS2DPlane = new AIS2D_Plane(theGeomPlane, A); - GetMapOfAIS2D().Bind(myAIS2DPlane, name); - TheAIS2DContext()->Display(myAIS2DPlane); - } - else - { - cout << " vplane: error" << endl; - return 1; - } - } - else - { - TheAIS2DContext()->DeactivateStandardMode(AIS2D_ProjShape::SelectionType(4)); - cout<<" Select a vertex."<CloseLocalContext(myCurrentIndex); - - // Construction du plane - gp_Pnt B = BRep_Tool::Pnt(TopoDS::Vertex(ShapeB ) ); - - TopoDS_Face myFace = TopoDS::Face(ShapeA); - BRepAdaptor_Surface mySurface (myFace, Standard_False); - if (mySurface.GetType() == GeomAbs_Plane) - { - gp_Pln myPlane = mySurface.Plane(); - myPlane.SetLocation(B); - Handle(Geom_Plane) theGeomPlane = new Geom_Plane(myPlane); - Handle(AIS2D_Plane) myAIS2DPlane = new AIS2D_Plane(theGeomPlane, B); - GetMapOfAIS2D().Bind(myAIS2DPlane, name); - TheAIS2DContext()->Display(myAIS2DPlane); - } - else - { - cout << " v2dplane: error" << endl; - return 1; - } - } - } - else // Fonction v2dplaneortho - { - TheAIS2DContext()->OpenLocalContext(); - myCurrentIndex = TheAIS2DContext()->IndexOfCurrentLocal(); - - TheAIS2DContext()->ActivateStandardMode(AIS2D_ProjShape::SelectionType(2)); - TheAIS2DContext()->ActivateStandardMode(AIS2D_ProjShape::SelectionType(4)); - cout << " Select a face and an edge coplanar." << endl; - TopoDS_Shape ShapeA = SelectShape2d(5); - - if (ShapeA.ShapeType() == TopAbs_EDGE) - { - // ShapeA est un edge, on desactive le mode edge... - TheAIS2DContext()->DeactivateStandardMode(AIS2D_ProjShape::SelectionType(2)); - cout<<" Select a face."<CloseLocalContext(myCurrentIndex); - - // Construction du plane - TopoDS_Edge EdgeA = TopoDS::Edge(ShapeA); - TopoDS_Vertex VAa, VAb; - - TopExp::Vertices(EdgeA, VAa, VAb); - gp_Pnt Aa = BRep_Tool::Pnt(VAa); - gp_Pnt Ab = BRep_Tool::Pnt(VAb); - gp_Vec ab (Aa,Ab); - - gp_Dir Dab (ab); - // Creation de mon axe de rotation - gp_Ax1 myRotAxis (Aa,Dab); - - TopoDS_Face myFace = TopoDS::Face(ShapeB); - BRepExtrema_ExtPF myHauteurA (VAa, myFace); - BRepExtrema_ExtPF myHauteurB (VAb, myFace); - if (fabs(myHauteurA.Value(1) - myHauteurB.Value(1) ) > 0.1) - { - cout << " v2dplaneOrtho error: l'edge n'est pas parallele a la face." << endl; - return 1; - } - BRepAdaptor_Surface mySurface (myFace, Standard_False); - if (mySurface.GetType() == GeomAbs_Plane) - { - gp_Pln myPlane = mySurface.Plane(); - myPlane.Rotate(myRotAxis, M_PI/2); - - Handle(Geom_Plane) theGeomPlane = new Geom_Plane(myPlane); - gp_Pnt theMiddle ((Aa.X()+Ab.X())/2, (Aa.Y()+Ab.Y())/2, (Aa.Z()+Ab.Z())/2); - Handle(AIS2D_Plane) myAIS2DPlane = new AIS2D_Plane(theGeomPlane, theMiddle); - GetMapOfAIS2D().Bind(myAIS2DPlane, name); - TheAIS2DContext()->Display(myAIS2DPlane); - - } - else - { - cout << " v2dplaneOrtho: error" << endl; - return 1; - } - } - else - { - TheAIS2DContext()->DeactivateStandardMode(AIS2D_ProjShape::SelectionType(4)); - cout << " Select an edge." << endl; - TopoDS_Shape ShapeB = SelectShape2d(5); - - // Fermeture du context local - TheAIS2DContext()->CloseLocalContext(myCurrentIndex); - - // Construction du plane - TopoDS_Edge EdgeB = TopoDS::Edge(ShapeB); - TopoDS_Vertex VBa, VBb; - TopExp::Vertices(EdgeB, VBa, VBb); - gp_Pnt Ba = BRep_Tool::Pnt(VBa); - gp_Pnt Bb = BRep_Tool::Pnt(VBb); - gp_Vec ab (Ba,Bb); - gp_Dir Dab (ab); - // Creation de mon axe de rotation - gp_Ax1 myRotAxis (Ba,Dab); - - TopoDS_Face myFace = TopoDS::Face(ShapeA); - BRepExtrema_ExtPF myHauteurA (VBa, myFace); - BRepExtrema_ExtPF myHauteurB (VBb, myFace); - - if (fabs(myHauteurA.Value(1) - myHauteurB.Value(1) ) > 0.1) - { - cout << " v2dplaneOrtho error: l'edge n'est pas parallele a la face." << endl; - return 1; - } - BRepAdaptor_Surface mySurface (myFace, Standard_False); - if (mySurface.GetType() == GeomAbs_Plane) - { - gp_Pln myPlane = mySurface.Plane(); - myPlane.Rotate(myRotAxis, M_PI/2); - Handle(Geom_Plane) theGeomPlane = new Geom_Plane(myPlane); - gp_Pnt theMiddle ((Ba.X()+Bb.X())/2, (Ba.Y()+Bb.Y())/2, (Ba.Z()+Bb.Z())/2); - Handle(AIS2D_Plane) myAIS2DPlane = new AIS2D_Plane(theGeomPlane, theMiddle); - GetMapOfAIS2D().Bind(myAIS2DPlane, name); - TheAIS2DContext()->Display(myAIS2DPlane); - } - else - { - cout << " v2dplaneOrtho: error" << endl; - return 1; - } - } - } - } - - return 0; -}*/ - -//============================================================================== -// Fonction vline -// --------------- Uniquement par parametre. Pas de selection dans le viewer. -//============================================================================== - -//============================================================================== -//function : V2dLineBuilder -//purpose : Build a Graphic2d_Line -//Draw arg : v2dline LineName [AIS2D_PointName] [AIS2D_PointName] -// [Xa] [Ya] [Za] [Xb] [Yb] [Zb] -//============================================================================== -/*static int V2dLineBuilder(Draw_Interpretor& , Standard_Integer argc, const char** argv) -{ - Standard_Integer myCurrentIndex; - if (argc != 4 && argc != 8 && argc != 2) - { - cout << "vline error: number of arguments not correct " << endl; - return 1; - } - TheAIS2DContext()->CloseAllContext(); - - // On recupere les parametres - Handle(AIS2D_InteractiveObject) theShapeA; - Handle(AIS2D_InteractiveObject) theShapeB; - - // Parametres: AIS2D_Point AIS2D_Point - if (argc == 4) - { - theShapeA = GetMapOfAIS2D().Find2(argv[2] ); - if (theShapeA->Type() == AIS2D_KOI_Datum && theShapeA->Signature() == 1) - { - theShapeB = GetMapOfAIS2D().Find2(argv[3]); - if (!(theShapeB->Type() == AIS2D_KOI_Datum && theShapeB->Signature() == 1)) - { - cout << "v2dline error: wrong type of 2de argument." << endl; - return 1; - } - } - else - { - cout << "v2dline error: wrong type of 1st argument." << endl; - return 1; - } - - Handle(AIS2D_Point) theAIS2DPointA = *(Handle(AIS2D_Point)*)& theShapeA; - Handle(AIS2D_Point) theAIS2DPointB = *(Handle(AIS2D_Point)*)& theShapeB; - - Handle(Geom_Point) myGeomPointBA = theAIS2DPointA->Component(); - Handle(Geom_CartesianPoint) myCartPointA = *((Handle(Geom_CartesianPoint)*)& myGeomPointBA); - - Handle(Geom_Point) myGeomPointB = theAIS2DPointB->Component(); - Handle(Geom_CartesianPoint) myCartPointB = *((Handle(Geom_CartesianPoint)*)& myGeomPointB); - - if (myCartPointB->X() == myCartPointA->X() && - myCartPointB->Y() == myCartPointA->Y() && myCartPointB->Z() == myCartPointA->Z()) - { - // B=A - cout << "v2dline error: same points" << endl; - return 1; - } - Handle(AIS2D_Line) theAIS2DLine = new AIS2D_Line(myCartPointA, myCartPointB); - GetMapOfAIS2D().Bind(theAIS2DLine, argv[1]); - TheAIS2DContext()->Display(theAIS2DLine); - } - else if (argc == 8) // Parametres 6 Reals - { - Standard_Real coord[6]; - for (Standard_Integer i = 0; i <= 2; i++) - { - coord[i] = atof(argv[2+i]); - coord[i+3] = atof(argv[5+i]); - } - - Handle(Geom_CartesianPoint) myCartPointA = new Geom_CartesianPoint(coord[0],coord[1],coord[2]); - Handle(Geom_CartesianPoint) myCartPointB = new Geom_CartesianPoint(coord[3],coord[4],coord[5]); - - Handle(AIS2D_Line) theAIS2DLine = new AIS2D_Line(myCartPointA, myCartPointB); - GetMapOfAIS2D().Bind(theAIS2DLine, argv[1]); - TheAIS2DContext()->Display(theAIS2DLine); - } - else - { - TheAIS2DContext()->OpenLocalContext(); - myCurrentIndex = TheAIS2DContext()->IndexOfCurrentLocal(); - - // Active le mode Vertex. - TopoDS_Shape ShapeA = SelectShape2d(1); - - if (ShapeA.ShapeType() == TopAbs_VERTEX) - { -// TheAIS2DContext()->ActivateStandardMode(AIS2D_ProjShape::SelectionType(1)); - cout << " Select a different vertex." << endl; - - TopoDS_Shape ShapeB; - do - { - ShapeB = SelectShape2d(5); - } while (ShapeB.IsSame(ShapeA)); - - TheAIS2DContext()->CloseLocalContext(myCurrentIndex); - - // Construction de la line - gp_Pnt A = BRep_Tool::Pnt(TopoDS::Vertex(ShapeA)); - gp_Pnt B = BRep_Tool::Pnt(TopoDS::Vertex(ShapeB)); - - Handle(Geom_CartesianPoint) myCartPointA = new Geom_CartesianPoint(A); - Handle(Geom_CartesianPoint) myCartPointB = new Geom_CartesianPoint(B); - - Handle(AIS2D_Line) theAIS2DLine = new AIS2D_Line(myCartPointA, myCartPointB); - GetMapOfAIS2D().Bind(theAIS2DLine, argv[1]); - TheAIS2DContext()->Display(theAIS2DLine); - } - else - { - cout << "v2dline error." << endl; - } - } - - return 0; -}*/ - -//============================================================================== -//function : V2dCircleBuilder -//purpose : Build an Graphic2d_Circle -//Draw arg : v2dcircle CircleName X Y Radius [Color_index] -//============================================================================== -static int V2dCircleBuilder (Draw_Interpretor& , Standard_Integer argc, const char** argv) -{ - Standard_Integer myCurrentIndex; - // verification of the arguments - if (argc < 2) - { - cout << "Usage: v2dcircle CircleName X Y Radius [Color_index]" << endl; - return 1; - } - TheAIS2DContext()->CloseAllContext(); - Handle(V2d_View) V = Viewer2dTest::CurrentView(); - - TCollection_AsciiString name = argv[1]; - - if (argc >= 5) - { -// Handle(AIS2D_InteractiveObject) theShapeA; -// Handle(AIS2D_InteractiveObject) theShapeB; -// theShapeA=GetMapOfAIS2D().Find2(argv[2]); -// theShapeB=GetMapOfAIS2D().Find2(argv[3]); - - // Arguments: AIS2D_Point AIS2D_Point AIS2D_Point - // ======================================== -/* if (theShapeA->Type() == AIS2D_KOI_Datum && theShapeA->Signature() == 1) - { - if (theShapeB->Type() != AIS2D_KOI_Datum || theShapeB->Signature() != 1) - { - cout<<"vcircle error: 2de argument is unexpected to be a point."<Type()!=AIS2D_KOI_Datum || theShapeC->Signature()!=1 ) { - cout<<"vcircle error: 3de argument is unexpected to be a point."<Component(); - Handle(Geom_CartesianPoint) myCartPointA = *((Handle(Geom_CartesianPoint)*)& myGeomPointA); - - Handle(Geom_Point ) myGeomPointB = theAIS2DPointB->Component(); - Handle(Geom_CartesianPoint ) myCartPointB= *((Handle(Geom_CartesianPoint)*)& theAIS2DPointB); - - Handle(Geom_Point ) myGeomPointBC= theAIS2DPointC->Component(); - Handle(Geom_CartesianPoint ) myCartPointC= *((Handle(Geom_CartesianPoint)*)& theAIS2DPointC); - - // Test A=B - if (myCartPointA->X()==myCartPointB->X() && myCartPointA->Y()==myCartPointB->Y() && myCartPointA->Z()==myCartPointB->Z() ) { - cout<<"vcircle error: Same points."<X()==myCartPointC->X() && myCartPointA->Y()==myCartPointC->Y() && myCartPointA->Z()==myCartPointC->Z() ) { - cout<<"vcircle error: Same points."<X()==myCartPointC->X() && myCartPointB->Y()==myCartPointC->Y() && myCartPointB->Z()==myCartPointC->Z() ) { - cout<<"vcircle error: Same points."<Pnt(),myCartPointB->Pnt(),myCartPointC->Pnt() ); - Handle (Geom_Circle) theGeomCircle=Cir.Value(); - Handle(AIS2D_Circle) theAIS2DCircle=new AIS2D_Circle(theGeomCircle ); - GetMapOfAIS2D().Bind(theAIS2DCircle,argv[1] ); - TheAIS2DContext()->Display(theAIS2DCircle ); - - } - // Arguments: ASI_Plane AIS2D_Point Real - // =================================== - else if (theShapeA->Type()==AIS2D_KOI_Datum && theShapeA->Signature()==7 ) { - if (theShapeB->Type()!=AIS2D_KOI_Datum || theShapeB->Signature()!=1 ) { - cout<<"vcircle error: 2de element is a unexpected to be a point."<=0 - if (atof(argv[4])<=0 ) {cout<<"vcircle error: the radius must be >=0."<Component() ); - Handle(Geom_Plane ) myGeomPlane= theAIS2DPlane->Component(); - Handle(Geom_Point ) myGeomPointB = theAIS2DPointB->Component(); - Handle(Geom_CartesianPoint ) myCartPointB= *((Handle(Geom_CartesianPoint)*)& theAIS2DPointB); -// Handle(Geom_CartesianPoint ) myCartPointB= *(Handle(Geom_CartesianPoint)*)& (theAIS2DPointB->Component() ); - - //Handle(Geom_Axis2Placement) OrigineAndAxii=myGeomPlane->Axis(); - gp_Pln mygpPlane = myGeomPlane->Pln(); - gp_Ax1 thegpAxe = mygpPlane.Axis(); - gp_Dir theDir = thegpAxe.Direction(); - gp_Pnt theCenter=myCartPointB->Pnt(); - Standard_Real TheR = atof(argv[4]); - GC_MakeCircle Cir=GC_MakeCircle (theCenter, theDir ,TheR); - Handle (Geom_Circle) theGeomCircle=Cir.Value(); - Handle(AIS2D_Circle) theAIS2DCircle=new AIS2D_Circle(theGeomCircle ); - GetMapOfAIS2D().Bind(theAIS2DCircle,argv[1] ); - TheAIS2DContext()->Display(theAIS2DCircle ); - } - else // Error - { - cout << "v2dcircle error: !st argument is a unexpected type." << endl; - return 1; - } -*/ - //Draw arg : v2dcircle CircleName X Y Radius [Color_index] - if (GetMapOfAIS2D().IsBound2(name)) - { - cout << "There is already an object with name " << name << endl; - return -1; - } - Handle(AIS2D_InteractiveObject) aisobj = new AIS2D_InteractiveObject(); - aisobj->SetView(V->View()); -// Handle(Graphic2d_GraphicObject) obj = -// new Graphic2d_GraphicObject(V->View()); - - Handle(Graphic2d_Circle) circle = new Graphic2d_Circle - (aisobj, atof(argv[2]), atof(argv[3]), atof(argv[4])); - - if (argc > 5) - { - circle->SetTypeOfPolygonFilling(Graphic2d_TOPF_FILLED); - circle->SetInteriorColorIndex(atoi(argv[5])); - } - -// obj->Display(); - GetMapOfAIS2D().Bind(aisobj, name); -// TheAIS2DContext()->Display(aisobj, Standard_False); - aisobj->Display(); - - V->Viewer()->Update(); - } - else - { - TheAIS2DContext()->OpenLocalContext(); - myCurrentIndex = TheAIS2DContext()->IndexOfCurrentLocal(); - - // Active le mode Vertex et face. -// TheAIS2DContext()->ActivateStandardMode(AIS2D_ProjShape::SelectionType(1)); -// TheAIS2DContext()->ActivateStandardMode(AIS2D_ProjShape::SelectionType(4)); - cout << " Select a vertex or a face." << endl; - TopoDS_Shape ShapeA = SelectShape2d(5); - - if (ShapeA.ShapeType() == TopAbs_VERTEX) - { -// TheAIS2DContext()->DeactivateStandardMode(AIS2D_ProjShape::SelectionType(4)); - cout << " Select a different vertex." << endl; - - TopoDS_Shape ShapeB; - do - { - ShapeB = SelectShape2d(5); - } while (ShapeB.IsSame(ShapeA)); - - // Selection de ShapeC - cout << " Select the last vertex." << endl; - TopoDS_Shape ShapeC; - do - { - ShapeC = SelectShape2d(5); - } while (ShapeC.IsSame(ShapeA) || ShapeC.IsSame(ShapeB)); - - TheAIS2DContext()->CloseLocalContext(myCurrentIndex); - - // Construction du cercle -/* - gp_Pnt A = BRep_Tool::Pnt(TopoDS::Vertex(ShapeA)); - gp_Pnt B = BRep_Tool::Pnt(TopoDS::Vertex(ShapeB)); - gp_Pnt C = BRep_Tool::Pnt(TopoDS::Vertex(ShapeC)); - - GC_MakeCircle Cir = GC_MakeCircle(A,B,C); - Handle(Geom_Circle) theGeomCircle = Cir.Value(); - Handle(AIS2D_Circle) theAIS2DCircle = new AIS2D_Circle(theGeomCircle); - GetMapOfAIS2D().Bind(theAIS2DCircle,argv[1]); - TheAIS2DContext()->Display(theAIS2DCircle);*/ - } - // ShapeA est une face. - else - { - cout << " Select a vertex (in your face)." << endl; -// TheAIS2DContext()->DeactivateStandardMode(AIS2D_ProjShape::SelectionType(4)); - TopoDS_Shape ShapeB = SelectShape2d(5); - - Standard_Integer theRad; - do - { - cout << " Enter the value of the radius:" << endl; - cin >> theRad; - } while (theRad <= 0); - - TheAIS2DContext()->CloseLocalContext(myCurrentIndex); - - // Construction du cercle. - - // On recupere la normale au Plane. tag -/* TopoDS_Face myFace = TopoDS::Face(ShapeA); - BRepAdaptor_Surface mySurface (myFace, Standard_False); - gp_Pln myPlane = mySurface.Plane(); - Handle(Geom_Plane) theGeomPlane = new Geom_Plane (myPlane ); - gp_Pln mygpPlane = theGeomPlane->Pln(); - gp_Ax1 thegpAxe = mygpPlane.Axis(); - gp_Dir theDir = thegpAxe.Direction(); - - // On recupere le centre. - gp_Pnt theCenter = BRep_Tool::Pnt(TopoDS::Vertex(ShapeB)); - - // On construit l'AIS2D_Circle - GC_MakeCircle Cir = GC_MakeCircle(theCenter, theDir ,theRad); - Handle(Geom_Circle) theGeomCircle = Cir.Value(); - Handle(AIS2D_Circle) theAIS2DCircle = new AIS2D_Circle(theGeomCircle); - GetMapOfAIS2D().Bind(theAIS2DCircle,argv[1] ; - TheAIS2DContext()->Display(theAIS2DCircle);*/ - } - } - - return 0; -} - -//======================================================================= -//function : ObjectCommands -//purpose : -//======================================================================= -void Viewer2dTest::ObjectCommands (Draw_Interpretor& theCommands) -{ - const char *group = "2D AIS Viewer - Primitives Creation"; - -// theCommands.Add("v2dtrihedron", -// "v2dtrihedron name [Xo] [Yo] [Zo] [Zu] [Zv] [Zw] [Xu] [Xv] [Xw]", -// __FILE__,V2dTrihedron,group); - -/* theCommands.Add("v2dtri2d", - "v2dtri2d Name (Selection in the viewer only)", - __FILE__, V2dTrihedron2D, group); - -// theCommands.Add("v2dplanetri", -// "v2dplanetri Name (Selection in the viewer only)", -// __FILE__, V2dPlaneTrihedron, group); - - theCommands.Add("v2dsize", - "v2dsize [name(Default=Current)] [size(Default=100)] ", - __FILE__, V2dSize, group); -*/ - theCommands.Add("v2daxis", - "v2daxis nom [Xa] [Ya] [Xb] [Yb]", - __FILE__, V2dAxisBuilder, group); - -/* theCommands.Add("v2daxispara", - "v2daxispara nom ", - __FILE__, V2dAxisBuilder, group); - - theCommands.Add("v2daxisortho", - "v2daxisotho nom ", - __FILE__, V2dAxisBuilder, group); - - theCommands.Add("v2dpoint", - "v2dpoint PointName [Xa] [Ya]", - __FILE__, V2dPointBuilder, group); -*/ -/* theCommands.Add("v2dplane", - "v2dplane PlaneName [AxisName/PlaneName/PointName] [PointName/PointName/PointName] [Nothing/Nothing/PointName] ", - __FILE__,V2dPlaneBuilder,group); - - theCommands.Add("v2dplanepara", - "v2dplanepara PlaneName ", - __FILE__,V2dPlaneBuilder,group); - - theCommands.Add("v2dplaneortho", - "v2dplaneortho PlaneName ", - __FILE__,V2dPlaneBuilder,group); -*/ -// theCommands.Add("v2dline", -// "v2dline LineName [Xa/PointName] [Ya/PointName] [Xb] [Yb]", -// __FILE__,V2dLineBuilder,group); - - theCommands.Add("v2dcircle", - "v2dcircle CircleName X Y Radius [color_index]", - __FILE__, V2dCircleBuilder, group); -} diff --git a/src/Viewer2dTest/Viewer2dTest_ViewerCommands.cxx b/src/Viewer2dTest/Viewer2dTest_ViewerCommands.cxx deleted file mode 100755 index be677a2164..0000000000 --- a/src/Viewer2dTest/Viewer2dTest_ViewerCommands.cxx +++ /dev/null @@ -1,1591 +0,0 @@ -// Copyright (c) 1999-2012 OPEN CASCADE SAS -// -// The content of this file is subject to the Open CASCADE Technology Public -// License Version 6.5 (the "License"). You may not use the content of this file -// except in compliance with the License. Please obtain a copy of the License -// at http://www.opencascade.org and read it completely before using this file. -// -// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its -// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. -// -// The Original Code and all software distributed under the License is -// distributed on an "AS IS" basis, without warranty of any kind, and the -// Initial Developer hereby disclaims all such warranties, including without -// limitation, any warranties of merchantability, fitness for a particular -// purpose or non-infringement. Please see the License for the specific terms -// and conditions governing the rights and limitations under the License. - - -#define OCC198 // jfa 06/03/2002 // to prevent exception on bad font index -#define OCC199 // jfa 06/03/2002 // to prevent exception on bad color index - -#ifdef WNT -#include -#endif - -#include -#include -#include - -#include - -#include -#include - -#ifndef WNT - -#include -#include -#include -#include -#include -#include - -#else - -#include -#include -#include -#include - -#include - -#endif - -#include -#include - -#include - -#include - -//============================================================================== -// VIEWER GLOBALs -//============================================================================== - -Standard_IMPORT Standard_Boolean Draw_VirtualWindows; - -Standard_EXPORT int ViewerMainLoop2d (Standard_Integer , const char** argv); - -#ifdef WNT -static Handle(Graphic3d_WNTGraphicDevice)& GetG2dDevice() -{ - static Handle(Graphic3d_WNTGraphicDevice) GD; - return GD; -} - -static Handle(WNT_Window)& VT_GetWindow2d() -{ - static Handle(WNT_Window) WNTWin; - return WNTWin; -} - -#else -static Handle(Graphic3d_GraphicDevice)& GetG2dDevice() -{ - static Handle(Graphic3d_GraphicDevice) GD; - return GD; -} - -static Handle(Xw_Window)& VT_GetWindow2d() -{ - static Handle(Xw_Window) XWWin; - return XWWin; -} - -static Display* display2d; - -static void VProcessEvents2d (ClientData, int); -#endif - -#define ZCLIPWIDTH 1. - -static Viewer2dTest_DataMapOfText myMapOfText; - -static void OSWindowSetup2d(); - -//============================================================================== -// EVENT GLOBAL VARIABLES -//============================================================================== -static int Start_Rot = 0; -static int ZClipIsOn = 0; -static int X_Motion = 0, Y_Motion = 0; // Current cursor position -static int X_ButtonPress = 0, Y_ButtonPress = 0; // Last ButtonPress position -//============================================================================== - -#ifdef WNT -static LRESULT WINAPI Viewer2dWindowProc (HWND hwnd, UINT uMsg, - WPARAM wParam, LPARAM lParam); -#endif - -//============================================================================== -//function : WClass -//purpose : -//============================================================================== -static Handle(MMgt_TShared)& WClass() -{ - static Handle(MMgt_TShared) theWClass; -#ifdef WNT - if (theWClass.IsNull()) { - theWClass = new WNT_WClass ("GW2D_Class", Viewer2dWindowProc, - CS_VREDRAW | CS_HREDRAW, 0, 0, - ::LoadCursor (NULL, IDC_ARROW)); - } -#endif - return theWClass; -} - -//============================================================================== -//function : ViewerInit -//purpose : Create the window viewer and initialize all the global variable -//============================================================================== -void Viewer2dTest::ViewerInit (const Standard_Integer thePxLeft, const Standard_Integer thePxTop, - const Standard_Integer thePxWidth, const Standard_Integer thePxHeight) -{ - static Standard_Boolean isFirst = Standard_True; - - Standard_Integer aPxLeft = 0; - Standard_Integer aPxTop = 50; - Standard_Integer aPxWidth = 409; - Standard_Integer aPxHeight = 409; - if (thePxWidth != 0 && thePxHeight != 0) - { - aPxLeft = thePxLeft; - aPxTop = thePxTop; - aPxWidth = thePxWidth; - aPxHeight = thePxHeight; - } - - if (isFirst) - { - Handle(Aspect_WindowDriver) aWindowDriver; - -#ifdef WNT - // Create the Graphic device - if (GetG2dDevice().IsNull()) - GetG2dDevice() = new Graphic3d_WNTGraphicDevice(); - - // Create window - if (VT_GetWindow2d().IsNull()) - { - Handle(WNT_GraphicDevice) g_Device = new WNT_GraphicDevice(); - - VT_GetWindow2d() = new WNT_Window (g_Device, "Test2d", - Handle(WNT_WClass)::DownCast (WClass()), - WS_OVERLAPPEDWINDOW, - aPxLeft, aPxTop, - aPxWidth, aPxHeight, - Quantity_NOC_BLACK); - VT_GetWindow2d()->SetVirtual (Draw_VirtualWindows); - // force drawing into offscreen bitmap - VT_GetWindow2d()->SetDoubleBuffer (Standard_True); - } - - // Create window driver - aWindowDriver = new WNT_WDriver(VT_GetWindow2d()); -#else - // Create the Graphic device - if (GetG2dDevice().IsNull()) - GetG2dDevice() = new Graphic3d_GraphicDevice (getenv("DISPLAY"), Xw_TOM_READONLY); - - // Create window - if (VT_GetWindow2d().IsNull()) - { - VT_GetWindow2d() = new Xw_Window (GetG2dDevice(), "Test2d", - aPxLeft, aPxTop, - aPxWidth, aPxHeight, - Xw_WQ_3DQUALITY, - Quantity_NOC_BLACK); - VT_GetWindow2d()->SetVirtual (Draw_VirtualWindows); - // force drawing into offscreen bitmap - VT_GetWindow2d()->SetDoubleBuffer (Standard_True); - } - - // Create window driver - aWindowDriver = new Xw_Driver(VT_GetWindow2d()); -#endif - TCollection_ExtendedString NameOfWindow("Visu3D"); - Handle(V2d_Viewer) a3DViewer,a3DCollector; - // Create Viewer and View - a3DViewer = new V2d_Viewer(GetG2dDevice(), NameOfWindow.ToExtString()); - NameOfWindow = TCollection_ExtendedString("Collector"); - a3DCollector = new V2d_Viewer(GetG2dDevice(), NameOfWindow.ToExtString()); -// a3DViewer->SetDefaultBackgroundColor(Quantity_NOC_BLACK); -// a3DCollector->SetDefaultBackgroundColor(Quantity_NOC_STEELBLUE); - - if (Viewer2dTest::CurrentView().IsNull()) - { -// VT_GetWindow2d()->SetBackground(Quantity_NOC_MATRAGRAY); - Handle(V2d_View) V = new V2d_View(aWindowDriver, a3DViewer); - Viewer2dTest::CurrentView(V); - } - Handle(V2d_View) a3DViewCol = new V2d_View(aWindowDriver, a3DCollector); - - // AIS2D setup - if (Viewer2dTest::GetAIS2DContext().IsNull()) - { - Handle(AIS2D_InteractiveContext) C = new AIS2D_InteractiveContext(a3DViewer,a3DCollector); - Viewer2dTest::SetAIS2DContext(C); - } - - // Setup for X11 or NT - OSWindowSetup2d(); - - // Viewer and View creation - -// a3DViewer->SetDefaultBackgroundColor(Quantity_NOC_BLACK); - - Handle(V2d_View) V = Viewer2dTest::CurrentView(); - -// V->SetDegenerateModeOn(); -// V->SetWindow(VT_GetWindow2d()); - -// V->SetZClippingDepth(0.5); -// V->SetZClippingWidth(ZCLIPWIDTH/2.); - -// a3DViewer->SetDefaultLights(); -// a3DViewer->SetLightOn(); - -#ifndef WNT -#if TCL_MAJOR_VERSION < 8 - Tk_CreateFileHandler((void*)ConnectionNumber(display2d), - TK_READABLE, VProcessEvents2d, (ClientData) VT_GetWindow2d()->XWindow()); -#else - Tk_CreateFileHandler(ConnectionNumber(display2d), - TK_READABLE, VProcessEvents2d, (ClientData) VT_GetWindow2d()->XWindow()); -#endif -#endif - - isFirst = Standard_False; - } - VT_GetWindow2d()->Map(); -} - -//============================================================================== -//function : V2dinit -//purpose : Create the window viewer and initialize all the global variable -// Use Tk_CreateFileHandler on UNIX to cath the X11 Viewer event -//============================================================================== -static int V2dInit (Draw_Interpretor& , Standard_Integer argc, const char** argv) -{ - Standard_Integer aPxLeft = (argc > 1) ? atoi (argv[1]) : 0; - Standard_Integer aPxTop = (argc > 2) ? atoi (argv[2]) : 0; - Standard_Integer aPxWidth = (argc > 3) ? atoi (argv[3]) : 0; - Standard_Integer aPxHeight = (argc > 4) ? atoi (argv[4]) : 0; - Viewer2dTest::ViewerInit (aPxLeft, aPxTop, aPxWidth, aPxHeight); - return 0; -} - -//============================================================================== -//function : ProcessKeyPress2d -//purpose : Handle KeyPress event from a CString -//============================================================================== -static void ProcessKeyPress2d (char *buf_ret) -{ - // Letters - if (!strcasecmp(buf_ret, "R")) - { - // Reset - Viewer2dTest::CurrentView()->Reset(); - } - else if (!strcasecmp(buf_ret, "F")) - { - // FitAll - Viewer2dTest::CurrentView()->Fitall(); - } - else if (!strcasecmp(buf_ret, "H")) - { - // HLR - cout << "HLR" << endl; -// Viewer2dTest::CurrentView()->SetDegenerateModeOff(); - } - else if (!strcasecmp(buf_ret, "S")) - { - // SHADING - cout << "passage en mode 1 (shading pour les shapes)" << endl; -// Viewer2dTest::CurrentView()->SetDegenerateModeOn(); - Handle(AIS2D_InteractiveContext) Ctx = Viewer2dTest::GetAIS2DContext(); -// if (Ctx->NbCurrents() == 0 || Ctx->NbSelected() == 0) -// Ctx->SetDisplayMode(AIS2D_Shaded); -// else - { - if (Ctx->HasOpenedContext()) - { -// for(Ctx->InitSelected();Ctx->MoreSelected();Ctx->NextSelected()) -// Ctx->SetDisplayMode(Ctx->Interactive(), 1, Standard_False); - } - else - { -// for(Ctx->InitCurrent();Ctx->MoreCurrent();Ctx->NextCurrent()) -// Ctx->SetDisplayMode(Ctx->Current(), 1, Standard_False); - } - Ctx->UpdateCurrentViewer(); - } - } - else if (!strcasecmp(buf_ret, "U")) - { - // Unset display mode - cout << "passage au mode par defaut" << endl; -// Viewer2dTest::CurrentView()->SetDegenerateModeOn(); - Handle(AIS2D_InteractiveContext) Ctx = Viewer2dTest::GetAIS2DContext(); -// if (Ctx->NbCurrents() == 0 || Ctx->NbSelected() == 0) -// Ctx->SetDisplayMode(AIS2D_WireFrame); -// else - { - if(Ctx->HasOpenedContext()) - { -// for (Ctx->InitSelected(); Ctx->MoreSelected(); Ctx->NextSelected()) -// Ctx->UnsetDisplayMode(Ctx->Interactive(), Standard_False); - } - else - { -// for (Ctx->InitCurrent(); Ctx->MoreCurrent(); Ctx->NextCurrent()) -// Ctx->UnsetDisplayMode(Ctx->Current(), Standard_False); - } - Ctx->UpdateCurrentViewer(); - } - } - else if (!strcasecmp(buf_ret, "W")) - { - // WIREFRAME - cout << "passage en mode 0 (filaire pour les shapes)" << endl; -// Viewer2dTest::CurrentView()->SetDegenerateModeOn(); - Handle(AIS2D_InteractiveContext) Ctx = Viewer2dTest::GetAIS2DContext(); -// if (Ctx->NbCurrents() == 0 || Ctx->NbSelected() == 0) -// Ctx->SetDisplayMode(AIS2D_WireFrame); -// else - { - if (Ctx->HasOpenedContext()) - { -// for (Ctx->InitSelected(); Ctx->MoreSelected(); Ctx->NextSelected()) -// Ctx->SetDisplayMode(Ctx->Interactive(), 0, Standard_False); - } - else - { -// for (Ctx->InitCurrent(); Ctx->MoreCurrent(); Ctx->NextCurrent()) -// Ctx->SetDisplayMode(Ctx->Current(), 0, Standard_False); - } - Ctx->UpdateCurrentViewer(); - } - } - else if (!strcasecmp(buf_ret, "D")) - { - // Delete selected - cout << "Delete selected object - not yet implemented" << endl; - Viewer2dTest::CurrentView()->Reset(); - } - else if (!strcasecmp(buf_ret, "Z")) - { - // ZCLIP - if (ZClipIsOn) - { - cout << "ZClipping OFF" << endl; - ZClipIsOn = 0; - -// Viewer2dTest::CurrentView()->SetZClippingType(V2d_OFF); -// Viewer2dTest::CurrentView()->Redraw(); - } - else - { - cout << "ZClipping ON" << endl; - ZClipIsOn = 1; - -// Viewer2dTest::CurrentView()->SetZClippingType(V2d_FRONT); -// Viewer2dTest::CurrentView()->Redraw(); - } - } - else if (!strcasecmp(buf_ret, ",")) - { -// Viewer2dTest::GetAIS2DContext()->HilightNextDetected(Viewer2dTest::CurrentView()); - } - else if (!strcasecmp(buf_ret, ".")) - { -// Viewer2dTest::GetAIS2DContext()->HilightPreviousDetected(Viewer2dTest::CurrentView()); - } - else // Number - { - Standard_Integer Num = atoi(buf_ret); - if (Num >= 0 && Num <= 7) - Viewer2dTest::StandardModeActivation(Num); - } -} - -//============================================================================== -//function : ProcessExpose2d -//purpose : Redraw the View on an Expose Event -//============================================================================== -static void ProcessExpose2d() -{ - Viewer2dTest::CurrentView()->Viewer()->Update(); -// Viewer2dTest::CurrentView()->Redraw(); -} - -//============================================================================== -//function : ProcessConfigure2d -//purpose : Resize the View on an Configure Event -//============================================================================== -static void ProcessConfigure2d() -{ - Handle(V2d_View) V = Viewer2dTest::CurrentView(); - V->MustBeResized(V2d_TOWRE_ENLARGE_OBJECTS); - V->Update(); -// V->Redraw(); - V->Viewer()->Update(); -} - -//============================================================================== -//function : V2dPickGrid -//purpose : v2dpickgrid : get coordinates of a grid point near to MB1 click -//============================================================================== -static int V2dHitGrid (int argc, Standard_Integer anX, Standard_Integer anY, - const char* xxname = 0, const char* yyname = 0) -{ - if (argc != 1 && argc != 3 && argc != 5) - { - cout << "Usage : V2dHitGrid [mouse_X mouse_Y [grid_X grid_Y]]" << endl; - return 1; - } - - Handle(V2d_View) V = Viewer2dTest::CurrentView(); - if (V.IsNull()) return 1; - - if (V->Viewer()->IsActive()) // about the grid - { -// if (argc == 1) -// { -// cout << "Mouse cursor position: X = " << anX << " Y = " << anY << endl; -// } - - Quantity_Length xx, yy; - V->Hit(anX, anY, xx, yy); - - Standard_Integer xw, yw; - V->Convert(xx, yy, xw, yw); - printf("Window coords of Grid Point: X = %d Y = %d\n", xw, yw); - - if (argc < 5) - { - printf("Grid Point: X = %.6g Y = %.6g\n", xx, yy); - } - else - { - char szbuf[32]; - sprintf(szbuf, "%.6g", xx); - Draw::Set(xxname, szbuf); - sprintf(szbuf, "%.6g", yy); - Draw::Set(yyname, szbuf); - } - } - return 0; -} - -Standard_EXPORT int V2dPickGrid (Draw_Interpretor& , Standard_Integer argc, const char** argv) -{ - if (argc != 1 && argc != 3 && argc != 5) - { - cout << "Usage : v2dpickgrid (MB1 in the viewer)" << endl; - cout << "Usage : v2dgetgrid mouse_X mouse_Y [grid_X grid_Y]" << endl; - return 1; - } - - if (argc > 1) - { - if (argc > 3) - { - const char *xxname, *yyname; - xxname = argv[3]; - yyname = argv[4]; - V2dHitGrid(argc, atoi(argv[1]), atoi(argv[2]), xxname, yyname); - } - else - { - V2dHitGrid(argc, atoi(argv[1]), atoi(argv[2])); - } - } - else - { - while (ViewerMainLoop2d (argc, argv)) {} - } - - return 0; -} - -//============================================================================== -//function : ProcessButton1Press2d -//purpose : Picking -//============================================================================== -static Standard_Boolean ProcessButton1Press2d - (Standard_Integer , const char** argv, Standard_Boolean pick, Standard_Boolean shift) -{ - if (pick) - { - cout << "Window X = " << X_ButtonPress << " Window Y = " << Y_ButtonPress << endl; - if (strlen(argv[0]) > 7) // v2dpickgrid - { - V2dHitGrid(1, X_ButtonPress, Y_ButtonPress); - } - else - { - Handle(V2d_View) V = Viewer2dTest::CurrentView(); - if (V.IsNull()) return 1; - Quantity_Length xx, yy; - V->Convert(X_ButtonPress, Y_ButtonPress, xx, yy); - printf("Coord system X = %.6g Y = %.6g\n", xx, yy); - } - } - - Handle(Viewer2dTest_EventManager) EM = Viewer2dTest::CurrentEventManager(); - if (shift) EM->ShiftSelect(); - else EM->Select(); - - pick = 0; - return pick; -} - -//============================================================================== -//function : ProcessButton3Press2d -//purpose : Start Rotation -//============================================================================== -static void ProcessButton3Press2d() -{ - // Start rotation - Start_Rot = 1; -// Viewer2dTest::CurrentView()->SetDegenerateModeOn(); -// Viewer2dTest::CurrentView()->StartRotation(X_ButtonPress, Y_ButtonPress); -} - -//============================================================================== -//function : ProcessButtonRelease2d -//purpose : End Rotation -//============================================================================== -static void ProcessButtonRelease2d() -{ - // End rotation - Start_Rot = 0; -// Viewer2dTest::CurrentView()->SetDegenerateModeOff(); -} - -//============================================================================== -//function : ProcessZClipMotion2d -//purpose : Zoom -//============================================================================== -void ProcessZClipMotion2d() -{ - Handle(V2d_View) a3DView = Viewer2dTest::CurrentView(); - if (Abs(X_Motion - X_ButtonPress) > 2) - { - static Standard_Real CurZPos = 0.; -// Quantity_Length VDX, VDY; - -// a3DView->Size(VDX,VDY); - -#ifdef DEB -// Standard_Real VDZ = -#endif -// a3DView->ZSize(); - - Quantity_Length dx = a3DView->Convert(X_Motion - X_ButtonPress); - - // Front = Depth + width/2. - Standard_Real D = 0.5; -// Standard_Real W = 0.1; - - CurZPos += (dx); - - D += CurZPos; - -// a3DView->SetZClippingType(V2d_OFF); -// a3DView->SetZClippingDepth(D); -// a3DView->SetZClippingWidth(W); -// a3DView->SetZClippingType(V2d_FRONT); - -// a3DView->Redraw(); - - X_ButtonPress = X_Motion; - Y_ButtonPress = Y_Motion; - } -} - -//============================================================================== -//function : ProcessControlButton1Motion2d -//purpose : Zoom on Ctrl+MB1 -//============================================================================== -static void ProcessControlButton1Motion2d() -{ - Viewer2dTest::CurrentView()->Zoom(X_ButtonPress, Y_ButtonPress, X_Motion, Y_Motion); - - X_ButtonPress = X_Motion; - Y_ButtonPress = Y_Motion; -} - -//============================================================================== -//function : ProcessControlButton2Motion2d -//purpose : Pan on Ctrl+MB2 -//============================================================================== -static void ProcessControlButton2Motion2d() -{ - Viewer2dTest::CurrentView()->Pan(X_Motion - X_ButtonPress, Y_ButtonPress - Y_Motion); - - X_ButtonPress = X_Motion; - Y_ButtonPress = Y_Motion; -} - -//============================================================================== -//function : ProcessControlButton3Motion2d -//purpose : Rotation on Ctrl+MB3 -//============================================================================== -static void ProcessControlButton3Motion2d() -{ -// if (Start_Rot) Viewer2dTest::CurrentView()->Rotation(X_Motion, Y_Motion); -} - -//============================================================================== -//function : ProcessMotion2d -//purpose : pre-hilights detected objects at mouse position -//============================================================================== -static void ProcessMotion2d() -{ - Handle(Viewer2dTest_EventManager) EM = Viewer2dTest::CurrentEventManager(); - Handle(V2d_View) V = Viewer2dTest::CurrentView(); - EM->MoveTo(X_Motion, Y_Motion, V); -} - -//============================================================================== -//function : ProcessGridMotion2d -//purpose : pre-hilights grid point near mouse position -//============================================================================== -static void ProcessGridMotion2d() -{ - Handle(V2d_View) V = Viewer2dTest::CurrentView(); - - static Standard_Boolean LastIsGridActiveStatus = Standard_True; - if (V->Viewer()->IsActive()) // about the grid - { - V->ShowHit(X_Motion, Y_Motion); - LastIsGridActiveStatus = Standard_True; - } - if (!V->Viewer()->IsActive() && LastIsGridActiveStatus) // about the grid - { - V->EraseHit(); - LastIsGridActiveStatus = Standard_False; - } -} - -//============================================================================== -//function : GetMousePosition -//purpose : -//============================================================================== -void Viewer2dTest::GetMousePosition (Standard_Integer& Xpix, Standard_Integer& Ypix) -{ - Xpix = X_Motion; - Ypix = Y_Motion; -} - -//============================================================================== -//function : V2dHelp -//purpose : Dsiplay help on viewer Keyboead and mouse commands -//Draw arg : No args -//============================================================================== -/*static int V2dHelp (Draw_Interpretor& , Standard_Integer , const char** ) -{ - cout << "Q : Quit the application" << endl; - cout << "=========================" << endl; - cout << "F : FitAll" << endl; - cout << "R : ResetView" << endl; - cout << "=========================" << endl; - cout << "Selection mode " << endl; - cout << "0 : OBJECT" << endl; - cout << "1 : PRIMITIVE" << endl; - cout << "2 : ELEMENT" << endl; - cout << "3 : VERTEX" << endl; - cout << "4 : NONE" << endl; - cout << "==========================" << endl; - cout << "D : Remove Selected Object" << endl; - cout << "==========================" << endl; - - return 0; -}*/ - -#ifdef WNT - -static LRESULT WINAPI Viewer2dWindowProc (HWND hwnd, UINT Msg, - WPARAM wParam, LPARAM lParam ) -{ - static Standard_Boolean Ppick = 0; - static Standard_Integer Pargc = 0; - static const char** Pargv = NULL; - - static int Up = 1; - - if (!Viewer2dTest::CurrentView().IsNull()) - { - PAINTSTRUCT ps; - - switch (Msg) - { - case WM_CLOSE: - // do not destroy the window - just hide it! - VT_GetWindow2d()->Unmap(); - return 0; - case WM_PAINT: - BeginPaint(hwnd, &ps); - EndPaint(hwnd, &ps); - ProcessExpose2d(); - break; - - case WM_SIZE: - ProcessConfigure2d(); - break; - - case WM_KEYDOWN: - char c[2]; - c[0] = (char) wParam; - c[1] = '\0'; - ProcessKeyPress2d(c); - break; - - case WM_LBUTTONUP: - case WM_MBUTTONUP: - case WM_RBUTTONUP: - Up = 1; - ProcessButtonRelease2d(); - break; - - case WM_LBUTTONDOWN: - case WM_MBUTTONDOWN: - case WM_RBUTTONDOWN: - { - WPARAM fwKeys = wParam; - - Up = 0; - - X_ButtonPress = LOWORD(lParam); - Y_ButtonPress = HIWORD(lParam); - - if (Msg == WM_LBUTTONDOWN && !(fwKeys & MK_CONTROL)) - { - Ppick = ProcessButton1Press2d(Pargc, Pargv, Ppick, (fwKeys & MK_SHIFT)); - } - else if (Msg == WM_RBUTTONDOWN) - { - // Start rotation - ProcessButton3Press2d(); - } - } - break; - - case WM_MOUSEMOVE: - { - WPARAM fwKeys = wParam; - X_Motion = LOWORD(lParam); - Y_Motion = HIWORD(lParam); - - if (Up && fwKeys & (MK_LBUTTON|MK_MBUTTON|MK_RBUTTON)) - { - Up = 0; - X_ButtonPress = LOWORD(lParam); - Y_ButtonPress = HIWORD(lParam); - - if (fwKeys & MK_RBUTTON) - { - // Start rotation - ProcessButton3Press2d(); - } - } - - if (fwKeys & MK_CONTROL) - { - if (fwKeys & MK_LBUTTON) - { - ProcessControlButton1Motion2d(); - } - else if (fwKeys & MK_MBUTTON || ((fwKeys&MK_LBUTTON) && (fwKeys&MK_RBUTTON))) - { - ProcessControlButton2Motion2d(); - } - else if (fwKeys & MK_RBUTTON) - { - ProcessControlButton3Motion2d(); - } - } - else if (fwKeys & MK_SHIFT) - { - if (fwKeys & MK_MBUTTON || ((fwKeys&MK_LBUTTON) && (fwKeys&MK_RBUTTON))) - { - ProcessZClipMotion2d(); - } - } - else - { - ProcessMotion2d(); - } - } - break; - - default: - return(DefWindowProc(hwnd, Msg, wParam, lParam)); - } - return 0L; - } - - return DefWindowProc(hwnd, Msg, wParam, lParam); -} - -//============================================================================== -//function : ViewerMainLoop2d -//purpose : Get a Event on the view and dispatch it -//============================================================================== -static int ViewerMainLoop2d (Standard_Integer argc, const char** argv) -{ - cout << "No yet implemented on WNT" << endl; - static Standard_Boolean Ppick = 0; - static Standard_Integer Pargc = 0; - static const char** Pargv = NULL; - - Ppick = (argc > 0)? -1 : 0; - Pargc = argc; - Pargv = argv; - - if (Ppick) - { - MSG msg; - msg.wParam = 1; - - cout << "Start picking" << endl; - - while (Ppick == -1) - { - // Wait for a ProcessButton1Press2d() to toggle pick to 1 or 0 - if (GetMessage(&msg, NULL, 0, 0)) - { - TranslateMessage(&msg); - DispatchMessage(&msg); - } - } - - cout << "Picking done" << endl; - } - - return Ppick; -} - -#else - -//============================================================================== -//function : ViewerMainLoop2d -//purpose : Get a Event on the view and dispatch it -//============================================================================== -int ViewerMainLoop2d (Standard_Integer argc, const char** argv) -{ - Standard_Boolean pick = argc > 0; - - // X11 Event loop - static XEvent report; - - XNextEvent(display2d, &report); - - switch (report.type) - { - case Expose: - ProcessExpose2d(); - break; - case ConfigureNotify: - ProcessConfigure2d(); - break; - case KeyPress: - { - KeySym ks_ret; - char buf_ret[11]; - int ret_len; - XComposeStatus status_in_out; - - ret_len = XLookupString((XKeyEvent *)&report, (char *) buf_ret, - 10, &ks_ret, &status_in_out); - - buf_ret[ret_len] = '\0'; - if (ret_len) ProcessKeyPress2d(buf_ret); - } - break; - case ButtonPress: - { - X_ButtonPress = report.xbutton.x; - Y_ButtonPress = report.xbutton.y; - - if (report.xbutton.button == Button1 && - !(report.xbutton.state & ControlMask)) - { - pick = ProcessButton1Press2d(argc, argv, pick, - (report.xbutton.state & ShiftMask)); - } - else if (report.xbutton.button == Button3) - { - // Start rotation - ProcessButton3Press2d(); - } - } - break; - case ButtonRelease: - ProcessButtonRelease2d(); - break; - case MotionNotify: - { - X_Motion = report.xmotion.x; - Y_Motion = report.xmotion.y; - - // remove all the ButtonMotionMask - while (XCheckMaskEvent(display2d, ButtonMotionMask, &report)) {} - - if (ZClipIsOn && report.xmotion.state & ShiftMask) - { - if (Abs(X_Motion - X_ButtonPress) > 2) - { - Quantity_Length VDX = 0.0, VDY = 0.0; - -// Viewer2dTest::CurrentView()->Size(VDX,VDY); - Standard_Real VDZ =0 ; -// VDZ = Viewer2dTest::CurrentView()->ZSize(); - - printf("%f,%f,%f\n", VDX, VDY, VDZ); - - Quantity_Length dx = 0 ; - dx = Viewer2dTest::CurrentView()->Convert(X_Motion - X_ButtonPress); - - cout << dx << endl; - - dx = dx / VDX * VDZ; - - cout << dx << endl; - - // Front = Depth + width/2. - //Viewer2dTest::CurrentView()->SetZClippingDepth(dx); - //Viewer2dTest::CurrentView()->SetZClippingWidth(0.); - -// Viewer2dTest::CurrentView()->Redraw(); - } - } - - if (report.xmotion.state & ControlMask) - { - if (report.xmotion.state & Button1Mask) - { - ProcessControlButton1Motion2d(); - } - else if (report.xmotion.state & Button2Mask) - { - ProcessControlButton2Motion2d(); - } - else if (report.xmotion.state & Button3Mask) - { - ProcessControlButton3Motion2d(); - } - } - else - { - if (pick && strlen(argv[0]) > 7) // v2dpickgrid - ProcessGridMotion2d(); - else - ProcessMotion2d(); - } - } - break; - } - - return pick; -} - -//============================================================================== -//function : VProcessEvents2d -//purpose : call by Tk_CreateFileHandler() to be able to manage the -// event in the Viewer window -//============================================================================== -static void VProcessEvents2d (ClientData, int) -{ - // test for X Event - while (XPending(display2d)) - { - ViewerMainLoop2d(0, NULL); - } -} -#endif - -//============================================================================== -//function : OSWindowSetup2d -//purpose : Setup for the X11 window to be able to cath the event -//============================================================================== -static void OSWindowSetup2d() -{ -#ifndef WNT - // X11 - Window window = VT_GetWindow2d()->XWindow(); - - Standard_Address theDisplay = GetG2dDevice()->XDisplay(); - display2d = (Display * ) theDisplay; - - XSynchronize(display2d, 1); - - VT_GetWindow2d()->Map(); - - // X11 : For keyboard on SUN - XWMHints wmhints; - wmhints.flags = InputHint; - wmhints.input = 1; - - XSetWMHints( display2d, window, &wmhints); - - XSelectInput(display2d, window, - ExposureMask | StructureNotifyMask | KeyPressMask | ButtonPressMask | - PointerMotionMask | - Button1MotionMask | Button2MotionMask | Button3MotionMask); - - XSynchronize(display2d, 0); - -#else - // WNT -#endif - -} - -//============================================================================== -//function : InitViewer2dTest -//purpose : initialisation de toutes les variables static de Viewer2dTest (dp) -//============================================================================== -void Viewer2dTest_InitViewer2dTest (const Handle(AIS2D_InteractiveContext)& context) -{ - Handle(V2d_Viewer) viewer = context->CurrentViewer(); - Viewer2dTest::SetAIS2DContext(context); - viewer->InitActiveViews(); - Handle(V2d_View) view = viewer->ActiveView(); - if (viewer->MoreActiveViews()) Viewer2dTest::CurrentView(view); - Viewer2dTest::ResetEventManager(); - Handle(Aspect_GraphicDevice) device = viewer->Device(); - Handle(Aspect_WindowDriver) aWDr = view->Driver(); - Handle(Aspect_Window) window = aWDr->Window(); -#ifndef WNT - // X11 - VT_GetWindow2d() = Handle(Xw_Window)::DownCast(window); - GetG2dDevice() = Handle(Graphic3d_GraphicDevice)::DownCast(device); - OSWindowSetup2d(); - static int first = 1; - if (first) - { -#if TCL_MAJOR_VERSION < 8 - Tk_CreateFileHandler((void*)ConnectionNumber(display2d), - TK_READABLE, VProcessEvents2d, (ClientData) 0); -#else - Tk_CreateFileHandler(ConnectionNumber(display2d), - TK_READABLE, VProcessEvents2d, (ClientData) 0); -#endif - first = 0; - } -#endif -} - -//============================================================================== -//function : V2dFit -//purpose : Fitall, no DRAW arguments -//Draw arg : No args -//============================================================================== -static int V2dFit (Draw_Interpretor& , Standard_Integer , const char** ) -{ - Handle(V2d_View) V = Viewer2dTest::CurrentView(); - if (!V.IsNull()) V->Fitall(); - return 0; -} - -//============================================================================== -//function : V2dRepaint -//purpose : refresh viewer -//Draw arg : No args -//============================================================================== -static int V2dRepaint (Draw_Interpretor& , Standard_Integer , const char** ) -{ - Handle(V2d_View) V = Viewer2dTest::CurrentView(); - if (!V.IsNull()) -// V->Redraw(); - V->Viewer()->Update(); - return 0; -} - -//============================================================================== -//function : V2dClear -//purpose : Remove all the object from the viewer -//Draw arg : No args -//============================================================================== -static int V2dClear (Draw_Interpretor& , Standard_Integer , const char** ) -{ - Handle(V2d_View) V = Viewer2dTest::CurrentView(); - if (V.IsNull()) return 1; - - Viewer2dTest::Clear(); - V->Viewer()->Update(); - return 0; -} - -//============================================================================== -//function : V2dPick -//purpose : v2dpick - print mouse coords and color -//============================================================================== -static int V2dPick (Draw_Interpretor& , Standard_Integer argc, const char** argv) -{ - if (argc != 1) - { - cout << "Usage: v2dpick (MB1 in the viewer)" << endl; - return 1; - } - if (Viewer2dTest::CurrentView().IsNull()) return 1; - - while (ViewerMainLoop2d (argc, argv)) {} - - return 0; -} - -//============================================================================== -//function : V2dSetBG -//purpose : v2dsetbg imagefile [filltype] : load image as background -//============================================================================== -static int V2dSetBG (Draw_Interpretor& di, Standard_Integer argc, const char** argv) -{ - if (argc < 2 || argc > 3) - { - di << "Usage : v2dsetbg imagefile [filltype]" << "\n"; - return 1; - } - if (Viewer2dTest::CurrentView().IsNull()) return 1; - - Aspect_FillMethod aFillType = Aspect_FM_CENTERED; - if (argc == 3) - { - const char* szType = argv[2]; - if (strcmp(szType, "NONE" ) == 0) aFillType = Aspect_FM_NONE; - else if (strcmp(szType, "CENTERED") == 0) aFillType = Aspect_FM_CENTERED; - else if (strcmp(szType, "TILED" ) == 0) aFillType = Aspect_FM_TILED; - else if (strcmp(szType, "STRETCH" ) == 0) aFillType = Aspect_FM_STRETCH; - else - { - di << "Wrong fill type : " << szType << "\n"; - di << "Must be one of CENTERED, TILED, STRETCH, NONE" << "\n"; - return -1; - } - } - - Viewer2dTest::CurrentView()->SetBackground(argv[1], aFillType); - Viewer2dTest::CurrentView()->Viewer()->Update(); - - return 0; -} - -//============================================================================== -//function : V2dGrid -//purpose : v2dgrid [type [Origin(X Y) XStep/RadiusStep YStep/DivisionNb RotationAngle] [drawmode]] : load grid -// : v2drmgrid : unload grid -//============================================================================== -static int V2dGrid (Draw_Interpretor& di, Standard_Integer argc, const char** argv) -{ - if (Viewer2dTest::CurrentView().IsNull()) return 1; - Handle(V2d_Viewer) aViewer = Viewer2dTest::CurrentView()->Viewer(); - - const char* szName = argv[0]; - if (strcmp(szName, "v2drmgrid") == 0) - { - if (argc > 1) - { - di << "Usage : v2drmgrid" << "\n"; - return 1; - } - - aViewer->DeactivateGrid(); - return 0; - } - - // v2dgrid. Args nb may be 1,2,3,7,8 - if (argc < 1 || argc > 8 || (argc < 7 && argc > 3)) - { - di << "Usage : v2dgrid [type [Origin(X Y) XStep/RadiusStep YStep/DivisionNb RotationAngle] [drawmode]]" << "\n"; - return 1; - } - - Aspect_GridType aGridT = Aspect_GT_Rectangular; - Aspect_GridDrawMode aDrawM = Aspect_GDM_Lines; - - if (argc > 1) - { - const char* szType = argv[1]; - if (strcmp(szType, "Rect") == 0) aGridT = Aspect_GT_Rectangular; - else if (strcmp(szType, "Circ") == 0) aGridT = Aspect_GT_Circular; - else - { - di << "Wrong grid type : " << szType << "\n"; - di << "Must be Rect or Circ" << "\n"; - return -1; - } - - if (argc == 3 || argc == 8) - { - const char* szMode = (argc == 3) ? argv[2] : argv[7]; - if (strcmp(szMode, "Lines" ) == 0) aDrawM = Aspect_GDM_Lines; - else if (strcmp(szMode, "Points") == 0) aDrawM = Aspect_GDM_Points; - else if (strcmp(szMode, "None" ) == 0) aDrawM = Aspect_GDM_None; - else - { - di << "Wrong grid draw mode : " << szMode << "\n"; - di << "Must be Lines or Points, or None" << "\n"; - return -1; - } - } - } - - aViewer->ActivateGrid(aGridT, aDrawM); - - if (argc > 3) - { - Quantity_Length aXOrigin = atof(argv[2]); - Quantity_Length aYOrigin = atof(argv[3]); - Quantity_PlaneAngle aRotationAngle = atof(argv[6]); - - if (aGridT == Aspect_GT_Rectangular) - { - Quantity_Length aXStep = atof(argv[4]); - Quantity_Length aYStep = atof(argv[5]); - aViewer->SetRectangularGridValues - (aXOrigin, aYOrigin, aXStep, aYStep, aRotationAngle); - } - else - { - Quantity_Length aRadiusStep = atof(argv[4]); - Standard_Integer aDivisionNumber = atoi(argv[5]); - aViewer->SetCircularGridValues - (aXOrigin, aYOrigin, aRadiusStep, aDivisionNumber, aRotationAngle); - } - } - - return 0; -} - -//============================================================================== -//function : V2dPSOut -//purpose : v2dpsout imagefile [Scale TypeOfColorSpace] [Width Height XCenter YCenter] : PostScript Output -//============================================================================== -static int V2dPSOut (Draw_Interpretor& di, Standard_Integer argc, const char** argv) -{ - if (argc < 2 || argc > 8) - { - di << "Usage : v2dpsout imagefile [Scale TypeOfColorSpace] [Width Height XCenter YCenter]" << "\n"; - return 1; - } - - Handle(V2d_View) V = Viewer2dTest::CurrentView(); - if (V.IsNull()) return 1; - - Quantity_Factor aScale = 1.0; - Aspect_TypeOfColorSpace aColorType = Aspect_TOCS_RGB; - - Quantity_Length aWidth = 100.0, aHeight = 100.0; - - Quantity_Length aXCenter, aYCenter; - V->Center(aXCenter, aYCenter); - - if (argc > 2) - { - aScale = atof(argv[2]); - - if (argc > 3) - { - const char* szType = argv[3]; - if (strcmp(szType, "RGB") == 0) aColorType = Aspect_TOCS_RGB; - else if (strcmp(szType, "BlackAndWhite") == 0) aColorType = Aspect_TOCS_BlackAndWhite; - else if (strcmp(szType, "GreyScale") == 0) aColorType = Aspect_TOCS_GreyScale; - else - { - di << "Wrong color space type : " << szType << "\n"; - di << "Must be one of RGB, BlackAndWhite, GreyScale" << "\n"; - return -1; - } - - if (argc == 8) - { - aWidth = atof(argv[4]); - aHeight = atof(argv[5]); - aXCenter = atof(argv[6]); - aYCenter = atof(argv[7]); - } - else // take current window size - { -#ifndef WNT - Handle(Aspect_Window) anAspWindow = V->Driver()->Window(); - Handle(Xw_Window) anXWindow = Handle(Xw_Window)::DownCast(anAspWindow); - anXWindow->Size(aWidth, aHeight); -#endif - } - } - } - - Viewer2dTest::CurrentView()->PostScriptOutput - (argv[1], aWidth, aHeight, aXCenter, aYCenter, aScale, aColorType); - - return 0; -} - -//============================================================================== -//function : V2dPlot -//purpose : v2dplot format imagefile [Scale TypeOfColorSpace] [Width Height XCenter YCenter] -//============================================================================== -/*static int V2dPlot (Draw_Interpretor& , Standard_Integer argc, const char** argv) -{ - if (argc < 3 || argc > 9) - { - cout << "Args: format imagefile [Scale TypeOfColorSpace] [Width Height XCenter YCenter]" << endl; - return 1; - } - if (Viewer2dTest::CurrentView().IsNull()) return 1; - - Quantity_Factor aScale = 1.0; - Aspect_TypeOfColorSpace aColorType = Aspect_TOCS_RGB; - - Quantity_Length aWidth = 100.0, aHeight = 100.0; - - Quantity_Length aXCenter, aYCenter; - Viewer2dTest::CurrentView()->Center(aXCenter, aYCenter); - - if (argc > 3) - { - aScale = atof(argv[3]); - - if (argc > 4) - { - char* szType = argv[4]; - if (strcmp(szType, "RGB") == 0) aColorType = Aspect_TOCS_RGB; - else if (strcmp(szType, "BlackAndWhite") == 0) aColorType = Aspect_TOCS_BlackAndWhite; - else if (strcmp(szType, "GreyScale") == 0) aColorType = Aspect_TOCS_GreyScale; - else - { - cout << "Wrong color space type : " << szType << endl; - cout << "Must be one of RGB, BlackAndWhite, GreyScale" << endl; - return -1; - } - - if (argc == 9) - { - aWidth = atof(argv[5]); - aHeight = atof(argv[6]); - aXCenter = atof(argv[7]); - aYCenter = atof(argv[8]); - } - } - } - - char* szFormat = argv[1]; - if (strcmp(szFormat, "PS") == 0) - { - Handle(PS_Driver) aPSDriver = new PS_Driver(argv[2], aWidth, aHeight, aColorType); - Viewer2dTest::CurrentView()->Plot(aPSDriver, aXCenter, aYCenter, aScale); - } - else if (strcmp(szFormat, "") == 0) - { - Handle(PS_Driver) aPSDriver = new PS_Driver(argv[2], aWidth, aHeight, aColorType); - Viewer2dTest::CurrentView()->Plot(aPSDriver, aXCenter, aYCenter, aScale); - } - else if (strcmp(szFormat, "") == 0) - { - } - else - { - } - - return 0; -}*/ - -//======================================================================= -//function : V2dTextColor -//purpose : v2dsettextcolor text_name color_index -//======================================================================= -static int V2dTextColor (Draw_Interpretor& di, int argc, const char** argv) -{ - if (argc != 3) - { - di << "Usage : v2dsettextcolor text_name color_index" << "\n"; - return -1; - } - - TCollection_AsciiString aName (argv[1]); - - if (!myMapOfText.IsBound(aName)) - { - di << "No such text object: " << aName.ToCString() << "\n"; - return -1; - } - - int aColInd = atoi(argv[2]); - -#ifdef OCC199 - // check color index - Standard_Integer aColMin, aColMax; - Viewer2dTest::CurrentView()->Driver()->ColorBoundIndexs(aColMin, aColMax); - if (aColInd < aColMin || aColMax < aColInd) - { - di << "Color index must be between " << aColMin << " and " << aColMax << "\n"; - return -1; - } -#endif - - myMapOfText(aName)->SetColorIndex(aColInd); - Viewer2dTest::CurrentView()->Viewer()->Update(); - return 0; -} - -//======================================================================= -//function : V2dText -//purpose : v2dtext text_str position(x y) [angle scale font] -//======================================================================= -static int V2dText (Draw_Interpretor& di, int argc, const char** argv) -{ - if (argc != 4 && argc != 7) - { - di << "Usage : v2dtext text_str position(x y) [angle scale font]" << "\n"; - return -1; - } - - Handle(AIS2D_InteractiveContext) myAIScontext = Viewer2dTest::GetAIS2DContext(); - if (myAIScontext.IsNull()) - { - di << "use 'v2dinit' command before " << argv[0] << "\n"; - return -1; - } - myAIScontext->SetPickMode(Graphic2d_PM_INTERSECT); - Handle(V2d_View) V = Viewer2dTest::CurrentView(); - - Handle(Graphic2d_GraphicObject) obj = - new Graphic2d_GraphicObject(V->View()); - - Quantity_PlaneAngle anAngle = 0.0; - Quantity_Factor aScale = 1.0; - Standard_Integer aFontIn = 0; - - if (argc > 4) - { - anAngle = atof(argv[4]); - aScale = atof(argv[5]); - aFontIn = atoi(argv[6]); - -#ifdef OCC198 - // check font index - Standard_Integer aFontMin, aFontMax; - Viewer2dTest::CurrentView()->Driver()->FontBoundIndexs(aFontMin, aFontMax); - if (aFontIn < aFontMin || aFontMax < aFontIn) - { - di << "Font index must be between " << aFontMin << " and " << aFontMax << "\n"; - return -1; - } -#endif - } - - Handle(Graphic2d_Text) text = - new Graphic2d_Text(obj, TCollection_ExtendedString(argv[1]), - atof(argv[2]), atof(argv[3]), anAngle, - Aspect_TOT_SOLID, aScale); - text->SetFontIndex(aFontIn); - - obj->Display(); - V->Fitall(); - - int i = myMapOfText.Extent(); - - TCollection_AsciiString aTxtName ("text_"); - aTxtName += TCollection_AsciiString(i); - - myMapOfText.Bind(aTxtName, text); - di << "Text " << aTxtName.ToCString() << " created" << "\n"; - return 0; -} - -//============================================================================== -//function : V2Dump -//purpose : To dump the active view snapshot to the image file -//Draw arg : Picture file name with extension corresponding to desired format -//============================================================================== -static Standard_Integer V2dDump (Draw_Interpretor& di, Standard_Integer argc, const char** argv) -{ - if (argc < 2) - { - di << "Use: " << argv[0] << " .{png|bmp|jpg|gif}\n"; - return 1; - } - - Handle(AIS2D_InteractiveContext) IC = Viewer2dTest::GetAIS2DContext(); - Handle(V2d_View) view = Viewer2dTest::CurrentView(); - if (view.IsNull()) - { - di << "Cannot find an active viewer/view\n"; - return 1; - } -#ifdef WNT - Handle(WNT_Window) aWindow = Handle(WNT_Window)::DownCast (view->Driver()->Window()); -#else - Handle(Xw_Window) aWindow = Handle(Xw_Window)::DownCast (view->Driver()->Window()); -#endif - aWindow->Dump (argv[1]); - return 0; -} - -//======================================================================= -//function : ViewerCommands -//purpose : -//======================================================================= -void Viewer2dTest::ViewerCommands(Draw_Interpretor& theCommands) -{ - const char *group = "2D AIS Viewer - Viewer Commands"; - - theCommands.Add("v2dinit", - "v2dinit : v2dinit [leftPx topPx widthPx heightPx] : Create the Viewer window", - __FILE__, V2dInit, group); - - theCommands.Add("v2dsetbg", - "v2dsetbg imagefile [filltype] : Load image as background", - __FILE__, V2dSetBG, group); - - theCommands.Add("v2dgrid", - "v2dgrid [type [Origin(X Y) XStep/RadiusStep YStep/DivisionNb RotationAngle(in radians)] [drawmode]] : Load grid", - __FILE__, V2dGrid, group); - - theCommands.Add("v2drmgrid", - "v2drmgrid : Unload grid", - __FILE__, V2dGrid, group); - -// theCommands.Add("v2dplot", -// "v2dplot format filename : Dump in file in certain format", -// __FILE__, V2dPlot, group); - - theCommands.Add("v2ddump", - ".{png|bmp|jpg|gif}\n\t\t: Dump contents of viewer window to PNG, BMP, JPEG or GIF file", - __FILE__, V2dDump, group); - - theCommands.Add("v2dpsout", - "v2dpsout imagefile [Scale TypeOfColorSpace] [Width Height XCenter YCenter] : PostScript Output", - __FILE__, V2dPSOut, group); - - theCommands.Add("v2dpick", - "v2dpick (MB1 in the viewer) : Print pixel coords and color", - __FILE__, V2dPick, group); - - theCommands.Add("v2dpickgrid", - "v2dpickgrid (MB1 in the viewer) : Print coordinates of a grid point near to MB1 click", - __FILE__, V2dPickGrid, group); - - theCommands.Add("v2dfit", - "v2dfit or : Fit all shapes", - __FILE__, V2dFit, group); - - theCommands.Add("v2drepaint", - "v2drepaint : Force redraw", - __FILE__, V2dRepaint, group); - - theCommands.Add("v2dclear", - "v2dclear : Clear the viewer", - __FILE__, V2dClear, group); - - theCommands.Add("v2dtext", "v2dtext text_str position(x y) [angle scale font]", V2dText, group); - theCommands.Add("v2dsettextcolor", "v2dsettextcolor text_name color_index", V2dTextColor, group); - -// theCommands.Add("v2dhelp", -// "v2dhelp : Display help on the viewer commands", -// __FILE__, V2dHelp, group); -} diff --git a/src/ViewerTest/ViewerTest.cxx b/src/ViewerTest/ViewerTest.cxx index c560ff72b6..c5f70b7f53 100755 --- a/src/ViewerTest/ViewerTest.cxx +++ b/src/ViewerTest/ViewerTest.cxx @@ -70,7 +70,6 @@ #include #include #include -#include // avoid warnings on 'extern "C"' functions returning C++ classes #ifdef WNT @@ -3234,16 +3233,13 @@ static Standard_Integer vr(Draw_Interpretor& , Standard_Integer , const char** a return 0; } //============================================================================ -#include #include #include -#include -#include #include Standard_Integer hlrtest(Draw_Interpretor&, Standard_Integer n, const char** a) { - Handle(AIS2D_InteractiveContext) aContext2D = Viewer2dTest::GetAIS2DContext(); + /*Handle(AIS2D_InteractiveContext) aContext2D = Viewer2dTest::GetAIS2DContext(); ///////////////////// TopoDS_Shape aShape = DBRep::Get(a[1]); aContext2D->EraseAll(Standard_True); @@ -3295,7 +3291,7 @@ Standard_Integer hlrtest(Draw_Interpretor&, Standard_Integer n, const char** aContext2D->Display( myDisplayableShape,Standard_True ); - aContext2D->UpdateCurrentViewer(); + aContext2D->UpdateCurrentViewer();*/ return 0; } @@ -3303,7 +3299,7 @@ Standard_Integer hlrtest(Draw_Interpretor&, Standard_Integer n, const char** Standard_Integer phlrtest(Draw_Interpretor&, Standard_Integer n, const char** a) { - Handle(AIS2D_InteractiveContext) aContext2D = Viewer2dTest::GetAIS2DContext(); + /*Handle(AIS2D_InteractiveContext) aContext2D = Viewer2dTest::GetAIS2DContext(); ///////////////////// TopoDS_Shape aShape = DBRep::Get(a[1]); aContext2D->EraseAll(Standard_True); @@ -3355,7 +3351,7 @@ Standard_Integer phlrtest(Draw_Interpretor&, Standard_Integer n, const char* aContext2D->Display( myDisplayableShape,Standard_True ); - aContext2D->UpdateCurrentViewer(); + aContext2D->UpdateCurrentViewer();*/ return 0; } @@ -3734,9 +3730,9 @@ void ViewerTest::MyCommands( Draw_Interpretor& theCommands) void ViewerTest::Factory(Draw_Interpretor& theDI) { // definition of Viewer Command - ViewerTest::Commands(theDI); - ViewerTest::AviCommands(theDI); - Viewer2dTest::Commands(theDI); + ViewerTest::Commands(theDI); + ViewerTest::AviCommands(theDI); + #ifdef DEB theDI << "Draw Plugin : OCC V2d & V3d commands are loaded" << "\n"; #endif diff --git a/src/ViewerTest/ViewerTest_ObjectCommands.cxx b/src/ViewerTest/ViewerTest_ObjectCommands.cxx index 0af0617f48..a6586d3031 100755 --- a/src/ViewerTest/ViewerTest_ObjectCommands.cxx +++ b/src/ViewerTest/ViewerTest_ObjectCommands.cxx @@ -2256,7 +2256,6 @@ static int VCircleBuilder(Draw_Interpretor& di, Standard_Integer argc, const cha #include #include #include -#include #include #include #include diff --git a/src/WNT/FILES b/src/WNT/FILES index 56399c0f20..e08046637e 100755 --- a/src/WNT/FILES +++ b/src/WNT/FILES @@ -11,7 +11,6 @@ WNT_ColorRef.hxx WNT_Dword.hxx WNT_LogFont.hxx WNT_Long.hxx -WNT_MFTDraw.hxx WNT_Uint.hxx WNT.h WNT_Bitmap.h @@ -26,7 +25,6 @@ WNT_IconBox_1.cxx WNT_ImageProcessor.cxx WNT_LogFont.cxx WNT_Long.cxx -WNT_MFTDraw.cxx WNT_Uint.cxx WNT_WindowData.cxx WNT_WndProc.cxx diff --git a/src/WNT/WNT.cdl b/src/WNT/WNT.cdl index 0942dd6367..d7bc2f2e69 100755 --- a/src/WNT/WNT.cdl +++ b/src/WNT/WNT.cdl @@ -29,14 +29,12 @@ package WNT Aspect, Image, - PlotMgt, Quantity, TCollection, TColStd, TShort, MMgt, - OSD, - MFT + OSD is @@ -49,9 +47,6 @@ package WNT exception ClassDefinitionError inherits ConstructionError; ---Category: Exceptions - exception FontMapEntryDefinitionError inherits ConstructionError; - ---Category: Exceptions - -------------------- -- Category: Classes @@ -62,14 +57,6 @@ package WNT ---Purpose: Creates the graphic device associated with DISPLAY. ---Category: Classes - class WDriver; - ---Purpose: Creates the window driver. - ---Category: Classes - - class DDriver; - ---Purpose: Creates the device driver ( for printing/plotting ) - ---Category: Classes - class Window; ---Purpose: Creates the Window drawable. ---Category: Classes @@ -82,11 +69,6 @@ package WNT ---Purpose: Creates the Icon Box window. ---Category: Classes - class FontMapEntry; - ---Purpose: Defines correspondence between FontMapEntry from - -- Aspect and Windows NT font handle. - ---Category: Classes - class ImageManager; ---Purpose: Creates and manages images and/or icons. ---Category: Classes @@ -99,11 +81,6 @@ package WNT ---Purpose: Defines the class ---Category: Classes - class TextManager; - ---Purpose: Defines the class for text drawing with MFT - ---Category: Classes - - --------------------------- -- Category: Enumerations --------------------------- @@ -170,25 +147,7 @@ package WNT class HColorTable instantiates HArray1 from TCollection ( ColorRef from WNT, ColorTable from WNT ); - class FontTable instantiates - Array1 from TCollection ( FontMapEntry from WNT ); - - class HFontTable instantiates - HArray1 from TCollection ( - FontMapEntry from WNT, - FontTable from WNT - ); - class SequenceOfImage instantiates Sequence from TCollection ( Image from WNT ); - --------------------------------- - -- Changes for MFT Text drawing - --------------------------------- - class ListOfMFTFonts instantiates - Array1 from TCollection (FontManager from MFT); - - class HListOfMFTFonts instantiates - HArray1 from TCollection (FontManager from MFT, ListOfMFTFonts); - end WNT; diff --git a/src/WNT/WNT_DDriver.cdl b/src/WNT/WNT_DDriver.cdl deleted file mode 100755 index fde27e799f..0000000000 --- a/src/WNT/WNT_DDriver.cdl +++ /dev/null @@ -1,580 +0,0 @@ --- Created on: 1997-03-17 --- Created by: EugenyPLOTNIKOV --- Copyright (c) 1997-1999 Matra Datavision --- Copyright (c) 1999-2012 OPEN CASCADE SAS --- --- The content of this file is subject to the Open CASCADE Technology Public --- License Version 6.5 (the "License"). You may not use the content of this file --- except in compliance with the License. Please obtain a copy of the License --- at http://www.opencascade.org and read it completely before using this file. --- --- The Initial Developer of the Original Code is Open CASCADE S.A.S., having its --- main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. --- --- The Original Code and all software distributed under the License is --- distributed on an "AS IS" basis, without warranty of any kind, and the --- Initial Developer hereby disclaims all such warranties, including without --- limitation, any warranties of merchantability, fitness for a particular --- purpose or non-infringement. Please see the License for the specific terms --- and conditions governing the rights and limitations under the License. - --- Modified: MAR-98, MAY-98 (DCB) --- OCT-98 (DCB) - see CXX file for details - -class DDriver from WNT inherits PlotterDriver from PlotMgt - - ---Purpose: Defines the device-independent Windows NT driver. - -- After graphics output enhanced metafile will be created. - -- It is possible to play this file on device several times - -- by Spool () method. - -uses - Handle from Aspect, - HColorTable from WNT, - HFontTable from WNT, - HArray1OfInteger from TColStd, - GraphicDevice from WNT, - OrientationType from WNT, - TypeOfText from Aspect, - ColorMap from Aspect, - TypeMap from Aspect, - WidthMap from Aspect, - FontMap from Aspect, - MarkMap from Aspect, - PlotMode from Aspect, - PlaneAngle from Quantity, - Factor from Quantity, - Ratio from Quantity, - Length from Quantity, - Array1OfShortReal from TShort, - ExtendedString from TCollection, - AsciiString from TCollection, - HAsciiString from TCollection, - HSequenceOfAsciiString from TColStd, - FontManager from MFT, - HListOfMFTFonts from WNT, - HArray1OfShortReal from TShort, - TextManager from WNT - -raises - - DriverDefinitionError from Aspect, - DriverError from Aspect - -is - - Create ( - aDeviceName : CString from Standard; - aFileName : CString from Standard; - anOrientation : OrientationType from WNT = WNT_OT_LANDSCAPE; - aScale : Factor from Quantity = 1.0; - aCopies : Integer from Standard = 1 - ) returns mutable DDriver from WNT - raises DriverDefinitionError from Aspect; - ---Purpose: Constructs a device driver framework defined by the - -- string aDeviceName, the path specified as an - -- argument for OSD_Path, the type of orientation - -- anOrientation, the scale aScale, the number of copies - -- aCopies and the flag aPrintFlag. - - Create ( - aFileName : CString from Standard; - aCopies : Integer from Standard = 1 - ) returns mutable DDriver from WNT; - ---Purpose: - -- Creates the class object. An empty path is authorized - -- and in this case, a temporary enhanced metafile is - -- created. You can delete this file by using the EndDraw function. - -- Warning - OSD_Path corresponds to an ASCII string. - -- Exceptions - -- Aspect_DriverDefinitionError if the driver could not be defined. - - Close(me: mutable) - is redefined; - ---C++: alias ~ - - BeginDraw ( me : mutable ) - is redefined; - ---Purpose: Begins a new picture of graphics in the enhanced metafile - - EndDraw ( me : mutable; fSynchronize: Boolean = Standard_False ) - is redefined; - ---Purpose: Flushes all graphics, closes enhanced metafile. - - Spool (me : mutable; - aPlotMode : PlotMode from Aspect = Aspect_PM_FILEONLY; - aDeviceName : CString from Standard = NULL; - anOriginalSize : Boolean from Standard = Standard_False - ) returns Boolean from Standard - raises DriverError from Aspect is redefined; - ---Purpose: Spools the driver onto a printer spool. - -- Stretches the picture so that it fits into the device - -- workspace if the Boolean anOriginalSize is False - -- and the workspace dimensions of the original - -- device differ from those of the current device. This - -- flag is ignored if aDeviceName is NULL. - -- Warning - -- If aDeviceName is NULL, then the driver should be - -- created with the first constructor. Otherwise, use - -- the second constructor to create a class object. - -- Exceptions - -- Aspect_DriverError if the driver is not correctly defined. - - --------------------------------------------- - -- Category: Methods to define the attributes - --------------------------------------------- - - SetLineAttrib ( - me : mutable; - ColorIndex : Integer from Standard; - TypeIndex : Integer from Standard; - WidthIndex : Integer from Standard - ) raises DriverError from Aspect is redefined; - ---Purpose: Defines the Current Line Attibutes - - SetTextAttrib ( - me : mutable; - ColorIndex : Integer from Standard; - FontIndex : Integer from Standard - ) raises DriverError from Aspect is redefined; - ---Purpose: Defines the Current Text Attributes - - SetTextAttrib ( - me: mutable; - ColorIndex : Integer from Standard; - FontIndex : Integer from Standard; - aSlant : PlaneAngle from Quantity; - aHScale : Factor from Quantity; - aWScale : Factor from Quantity; - isUnderlined : Boolean from Standard = Standard_False - ) raises DriverError from Aspect is redefined; - ---Purpose: Defines the Current Extended Text Attributes - - SetPolyAttrib ( - me : mutable; - ColorIndex : Integer from Standard; - TileIndex : Integer from Standard; - DrawEdge : Boolean from Standard = Standard_False - ) raises DriverError from Aspect is redefined; - ---Purpose: Sets the poly attributes - - SetMarkerAttrib ( - me : mutable; - ColorIndex : Integer from Standard; - WidthIndex : Integer from Standard; - FillMarker : Boolean from Standard = Standard_False - ) raises DriverError from Aspect is redefined; - ---Purpose: Defines the Current Marker Attributes - - - --------------------------- - -- Category: Images methods - --------------------------- - - IsKnownImage ( - me : mutable; - anImage : Transient from Standard - ) returns Boolean from Standard is redefined; - - SizeOfImageFile ( - me; - anImageFile : CString from Standard; - aWidth, aHeight : out Integer from Standard - ) returns Boolean from Standard is redefined; - - ClearImage ( - me : mutable; - anImageId : Transient from Standard - ) raises DriverError from Aspect is redefined; - - ClearImageFile ( - me : mutable; - anImageFile : CString from Standard - ) raises DriverError from Aspect is redefined; - - DrawImage ( - me : mutable; - anImageId : Transient from Standard; - aX, aY : ShortReal from Standard - ) raises DriverError from Aspect is redefined; - - - --------------------------------------- - -- Category: Methods to draw primitives - --------------------------------------- - DrawImageFile ( - me : mutable; - anImageFile : CString from Standard; - aX, aY : ShortReal from Standard; - aScale : Factor from Quantity = 1.0 - ) raises DriverError from Aspect is redefined; - - FillAndDrawImage ( - me : mutable; - anImageId : Transient from Standard; - aX, aY : ShortReal from Standard; - aWidth, aHeight : Integer from Standard; - anArrayOfPixels : Address from Standard - ) raises DriverError from Aspect is redefined; - ---Purpose: Fills a complete Image . - - FillAndDrawImage ( - me : mutable; - anImageId : Transient from Standard; - aX, aY : ShortReal from Standard; - anIndexOfLine, aWidth, aHeight : Integer from Standard; - anArrayOfPixels : Address from Standard - ) raises DriverError from Aspect is redefined; - ---Purpose: Fills a line of the Image . - -- Warning: 0 <= anIndexOfLine < aHeight - -- anIndexOfLine = 0 must be the first call - - PlotPolyline (me : mutable; - xArray : Address from Standard; - yArray : Address from Standard; - nPts : Address from Standard; - nParts : Integer from Standard - ) returns Boolean from Standard - is redefined protected; - ---Purpose: Draws a polyline depending of the SetLineAttrib() attributes. - - PlotPolygon (me : mutable; - xArray : Address from Standard; - yArray : Address from Standard; - nPts : Address from Standard; - nParts : Integer from Standard - ) returns Boolean from Standard - is redefined protected; - ---Purpose: Draws a polygon depending of the SetPolyAttrib() attributes. - - PlotSegment ( - me : mutable; - X1, Y1 : ShortReal from Standard; - X2, Y2 : ShortReal from Standard - ) returns Boolean from Standard - is redefined protected; - ---Purpose: Draws a segment depending of the SetLineAttrib() attributes. - - PlotText ( - me : mutable; - aText : ExtendedString from TCollection; - Xpos : ShortReal from Standard; - Ypos : ShortReal from Standard; - anAngle : ShortReal from Standard = 0.0; - aType : TypeOfText from Aspect = Aspect_TOT_SOLID - ) returns Boolean from Standard - is redefined protected; - ---Purpose: Draws a text depending of the SetTextAttrib() attributes. - -- Warning: Coordinates must be defined in DWU space. - - PlotText ( - me : mutable; - aText : CString from Standard; - Xpos : ShortReal from Standard; - Ypos : ShortReal from Standard; - anAngle : ShortReal from Standard = 0.0; - aType : TypeOfText from Aspect = Aspect_TOT_SOLID - ) returns Boolean from Standard - is redefined protected; - ---Purpose: Draws a text depending of the SetTextAttrib() attributes. - -- Warning: Coordinates must be defined in DWU space. - - PlotPolyText ( - me : mutable; - aText : ExtendedString from TCollection; - Xpos : ShortReal from Standard; - Ypos : ShortReal from Standard; - aMarge : Ratio from Quantity = 0.1; - anAngle : ShortReal from Standard = 0.0; - aType : TypeOfText from Aspect = Aspect_TOT_SOLID - ) returns Boolean from Standard - is redefined protected; - ---Purpose: Draws an framed text depending of the - -- SetTextAttrib() and SetPolyAttrib() attributes. - -- Warning: Coordinates must be defined in DWU space. - -- defines the ratio of the space between the - -- polygon borders and the bounding box of the text and - -- depending of the height of the text. - - PlotPolyText ( - me : mutable; - aText : CString from Standard; - Xpos : ShortReal from Standard; - Ypos : ShortReal from Standard; - aMarge : Ratio from Quantity = 0.1; - anAngle : ShortReal from Standard = 0.0; - aType : TypeOfText from Aspect = Aspect_TOT_SOLID - ) returns Boolean from Standard - is redefined protected; - ---Purpose: Draws an framed text depending of the - -- SetTextAttrib() and SetPolyAttrib() attributes. - -- Warning: Coordinates must be defined in DWU space. - -- defines the ratio of the space between the - -- polygon borders and the bounding box of the text and - -- depending of the height of the text. - - PlotPoint ( me : mutable; X, Y : ShortReal from Standard ) - returns Boolean from Standard - is redefined protected; - ---Purpose: Draws a 1 PIXEL point depending of the SetMarkerAttrib() - -- color attribute or add a point depending of the incremental BeginXxxxxx() - -- primitive used. - - PlotMarker ( - me : mutable; - aMarker : Integer from Standard; - Xpos : ShortReal from Standard; - Ypos : ShortReal from Standard; - Width : ShortReal from Standard; - Height : ShortReal from Standard; - Angle : ShortReal from Standard = 0.0 - ) returns Boolean from Standard - is redefined protected; - ---Purpose: Draws the prevously defined marker - -- depending of the SetMarkerAttrib() attributes. - -- Warning: Coordinates and sizes must be defined in DWU space. - -- Angle must be defined in RADIAN. - -- A one pixel marker is drawn when aMarker index is undefined - - PlotArc ( - me : mutable; - X, Y : ShortReal from Standard; - anXradius, anYradius : ShortReal from Standard; - aStartAngle : ShortReal from Standard = 0.0; - anOpenAngle : ShortReal from Standard = 6.283185 - ) returns Boolean from Standard - is redefined protected; - ---Purpose: Draws an Ellipsoid arc of center and Radius - -- of relative angle from - -- the base angle and depending of the SetLineAttrib() attributes - - PlotPolyArc ( - me : mutable; - X, Y : ShortReal from Standard; - anXradius, anYradius : ShortReal from Standard; - aStartAngle : ShortReal from Standard = 0.0; - anOpenAngle : ShortReal from Standard = 6.283185 - ) returns Boolean from Standard - is redefined protected; - ---Purpose: Draws an filled Ellipsoid arc of center and Radius - -- of relative angle from - -- the base angle and depending of the SetPolyAttrib() attributes. - - BeginPolyline ( me : mutable; aNumber : Integer ) is static; - ---Purpose: Begin an incremental polyline primitive of of points - -- Warning: Points must be added by the the DrawPoint() method. - - BeginPolygon ( me : mutable; aNumber : Integer ) - is redefined; - ---Purpose: Begin an incremental polygon primitive of of points - -- Warning: Points must be added by the the DrawPoint() method. - - BeginSegments ( me : mutable ) - is redefined; - ---Purpose: Begin a set of segments . - -- Warning: Segments must be added by the DrawSegment() method - - BeginArcs ( me : mutable ) - is redefined; - ---Purpose: Begin a set of circles or ellips . - -- Warning: Arcs must be added by the DrawArc() methods - - BeginPolyArcs ( me : mutable ) - is redefined; - ---Purpose: Begin a set of polygon circles or ellips - -- Warning: Arcs must be added by the DrawPolyArc() methods - - BeginMarkers ( me : mutable ) - is redefined; - ---Level: Public - ---Purpose: Begin a set of markers . - -- Warning: Markers must be added by the DrawMarker() method - - BeginPoints ( me : mutable ) - is redefined; - ---Level: Public - ---Purpose: Begin a set of points . - -- Warning: Points must be added by the DrawPoint() method - - ClosePrimitive ( me : mutable ) raises DriverError from Aspect is static; - ---Purpose: Close the last Begining primitive - - --------------------------------------------- - -- Category: Methods to define the attributes - --------------------------------------------- - InitializeColorMap(me: mutable; aColorMap: ColorMap from Aspect) - raises DriverError from Aspect is redefined protected; - ---Category: Methods to define the ColorIndexs - - InitializeTypeMap(me: mutable; aTypeMap: TypeMap from Aspect) - raises DriverError from Aspect is redefined protected; - ---Category: Methods to define the TypeIndexs - - InitializeWidthMap(me: mutable; aWidthMap: WidthMap from Aspect) - raises DriverError from Aspect is redefined protected; - ---Category: Methods to define the WidthIndexs - - InitializeFontMap(me: mutable; aFontMap: FontMap from Aspect) - raises DriverError from Aspect is redefined protected; - ---Category: Methods to define the FontIndexs - - InitializeMarkMap(me: mutable; aFontMap: MarkMap from Aspect) - raises DriverError from Aspect is redefined protected; - ---Category: Methods to define the MarkIndexs - - - ---------------------------- - -- Category: Inquire methods - ---------------------------- - - - WorkSpace ( me ; Width,Heigth : out Length from Quantity ) is static; - ---Purpose: Returns the Available WorkSpace in DWU coordinates - - Convert ( me ; PV : Integer from Standard ) returns Length from Quantity is static; - ---Purpose: Returns the DWU value depending of - -- the PIXEL value. - - Convert ( me ; DV : Length from Quantity ) returns Integer from Standard is static; - ---Purpose: Returns the PIXEL value depending of the DWU value. - - Convert ( - me; - PX, PY : Integer from Standard; - DX, DY : out Length from Quantity - ) is static; - ---Purpose: Returns the DWU position depending of the PIXEL position . - - Convert ( - me; - DX, DY : Length from Quantity; - PX, PY : out Integer from Standard - ) is static; - ---Purpose: Returns the PIXEL position depending of the DWU position - - TextSize ( - me; - aText : ExtendedString from TCollection; - aWidth, aHeight : out ShortReal from Standard; - aFontIndex : Integer from Standard = -1 - ) is static; - ---Purpose: Returns the TEXT size in DWU space depending - -- of the required FontIndex if aFontIndex is >= 0 - -- or the current FontIndex if < 0 (default). - - TextSize ( - me; - aText : ExtendedString from TCollection; - aWidth, aHeight, anXoffset, anYoffset : out ShortReal from Standard; - aFontIndex: Integer from Standard = -1 - ) is static; - ---Purpose: Returns the TEXT size and offsets - -- in DWU space depending - -- of the required FontIndex if aFontIndex is >= 0 - -- or the current FontIndex if < 0 (default). - - TextSize ( - me; - aText : CString from Standard; - aWidth, aHeight, anXoffset, anYoffset : out ShortReal from Standard; - aFontIndex : Integer from Standard = -1 - ) is static; - ---Purpose: Returns the TEXT size in DWU space depending - -- of the required FontIndex if aFontIndex is >= 0 - -- or the current FontIndex if < 0 (default). - - HDC ( me ) returns Handle from Aspect is static; - ---Purpose: Returns device context handle - - ClientRect ( me; aWidth, aHeigth : out Integer from Standard ) is static; - ---Purpose: Returns dimensions of the device - - GraphicDevice ( me ) returns GraphicDevice from WNT is static; - ---Purpose: Returns graphic device - - DeviceList ( myclass ) - returns HSequenceOfAsciiString from TColStd - raises DriverError from Aspect; - ---Purpose: Returns list of available graphic devices. - -- First element is default device - - DeviceSize (myclass; - aDevice : AsciiString from TCollection; - aWidth, aHeight: out Real from Standard); - ---Purpose: Returns size of a specified device. - - EMFDim ( - me : mutable; - aWidth : out Integer from Standard; - aHeight : out Integer from Standard; - aSwap : out Integer from Standard - ) returns Real from Standard; - ---Purpose: returns dimensions, in .01 millimeter units, - -- of a rectangle that surrounds the picture stored - -- in the metafile ( parameters & ). - -- value idicates whether rotate operation - -- (portrait/landscape) was performed or not. Valid - -- values are: <0> - no rotation - -- <1> - do rotation - -- <2> - could not determine - -- Returns ratio between & . - -- Warning: returns <-1> in case of error - - ProcessColorIndex ( me; ColorIndex : Integer from Standard ) - returns Integer from Standard is private; - - ProcessWidthIndex ( me; WidthIndex : Integer from Standard ) - returns Length from Quantity is private; - - ProcessTypeIndex ( me; TypeIndex : Integer from Standard ) - returns Integer from Standard is private; - - DoSpool ( me; - anOriginalSize : Boolean from Standard; - aPlotMode : PlotMode from Aspect = Aspect_PM_NPLOTTER - ) returns Boolean from Standard is private; - ---Purpose: Internal methods - - TextManager (me: mutable) - returns TextManager from WNT; - ---C++: return const & - ---Category: Inquire methods - - MFT_Font (me: mutable; anIndex: Integer) - returns FontManager from MFT; - ---C++: return const & - ---Category: Inquire methods - - MFT_Size (me: mutable; anIndex: Integer) - returns ShortReal; - ---Category: Inquire methods - -fields - myRect : Address from Standard; - myPrnName : AsciiString from TCollection; -- Name of .PRN file - myEmfName : AsciiString from TCollection; -- Name of .EMF file - myAllocators, - myAllocator : Address from Standard; - myPixelToUnit : Real from Standard; - myImageName : HAsciiString from TCollection; - myDevice : GraphicDevice from WNT; - myHDC : Handle from Aspect; - myHDCMeta : Handle from Aspect; - myHMetaFile : Handle from Aspect; - myImage : Handle from Aspect; - myOrientation : OrientationType from WNT; - myScale : Factor from Quantity; - myFlags : Integer from Standard; - myNCopies : Integer from Standard; - - myColors : HColorTable from WNT; - myFonts : HFontTable from WNT; - myTypeIdxs : HArray1OfInteger from TColStd; - myWidthIdxs : HArray1OfInteger from TColStd; - myMarkerIdxs : HArray1OfInteger from TColStd; - - myMFTFonts : HListOfMFTFonts from WNT; - myMFTSizes : HArray1OfShortReal from TShort; - myNTextManager : TextManager from WNT; - -end DDriver from WNT; diff --git a/src/WNT/WNT_DDriver.cxx b/src/WNT/WNT_DDriver.cxx deleted file mode 100755 index cd8f3bf308..0000000000 --- a/src/WNT/WNT_DDriver.cxx +++ /dev/null @@ -1,2090 +0,0 @@ -// Created on: 1997-03-17 -// Created by: EugenyPLOTNIKOV -// Copyright (c) 1997-1999 Matra Datavision -// Copyright (c) 1999-2012 OPEN CASCADE SAS -// -// The content of this file is subject to the Open CASCADE Technology Public -// License Version 6.5 (the "License"). You may not use the content of this file -// except in compliance with the License. Please obtain a copy of the License -// at http://www.opencascade.org and read it completely before using this file. -// -// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its -// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. -// -// The Original Code and all software distributed under the License is -// distributed on an "AS IS" basis, without warranty of any kind, and the -// Initial Developer hereby disclaims all such warranties, including without -// limitation, any warranties of merchantability, fitness for a particular -// purpose or non-infringement. Please see the License for the specific terms -// and conditions governing the rights and limitations under the License. - -// Modified: MAR-98 MAY-98 (EUG & DCB) - study S3553 -// DCB: 15-05-98 Changing the parent of WNT_DDriver from Aspect_Driver -// to Aspect_PlotterDriver -// DCB: SEP-98 Avoid memory crash when color indices do not follow -// each other or do not begin with '1' -// DCB: OCT-98 Changing the implementation of the constructors to -// the standard for plotter drivers (constructor takes -// the file name as a Standard_CString). -// Changing the implementation of _dd_fill_buff() to fill -// the EMF file description according to documentation: -// - see CreateEnhMetaFile() API. -// It is possible now to create two files: EMF and PRN. - -// include windows.h first to have all definitions available -#include - -#define MFT // S3553 study - -#define PRO17334 //GG_060199 -// SetXxxAttrib() must raise when index is wrong -// Idem for DrawMarker() - -#define PRO17381 //GG_080199 -// Protection : Do nothing when NULL string is found in TextSize - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include - -#pragma comment( lib, "winspool.lib" ) -#pragma comment( lib, "advapi32.lib" ) - -#define FLAG_DISPLAY 0x00000001 -#define FLAG_DELETE 0x00000002 -#define FLAG_DIRTY 0x00000004 -#define FLAG_BANDW 0x00000008 -#define FLAG_ROTATE 0x00000010 -#define FLAG_WINDOW 0x00000040 -#define FLAG_BITMAP 0x00000080 - -#define CSF_SIGNATURE 0x43465343 // CSFC -#define MAX_DESC_LEN 128 - -/*====================== MFT ====================*/ -#ifdef MFT -#include -#include "WNT_MFTDraw.hxx" -#endif -/*====================== MFT ====================*/ - -typedef struct _m_param { - Aspect_MarkerStyle* s; - int w; - int h; - } MPARAM, *PMPARAM; - -typedef struct _Pixel2D { - float r; - float g; - float b; - } PIXEL2D, *PPIXEL2D; -typedef struct _reg_key { - HKEY hKey; - LPTSTR keyPath; - } REG_KEY; -typedef struct _csf_sign { - DWORD dwSign; - DWORD dwLen; - DWORD fRotate; - } CSF_SIGN, *PCSF_SIGN; - -extern double W32_TextFactor; -static PW32_Allocator __fastcall _FindAllocator ( Standard_Address, Standard_Integer ); -static char* __fastcall _ConvertU2F ( const TCollection_ExtendedString& ); -static void WINAPI _SetPoint ( int, int, int, LPPOINT, int*, void* ); - -HBITMAP LoadImageFromFile ( Handle( WNT_GraphicDevice )&, char*, HDC = NULL ); -static void __fastcall _dd_fill_buff ( char* ); -static int __fastcall _dd_dev_size ( HDC, int ); - -static int CALLBACK _dd_enum_proc ( - HDC, HANDLETABLE FAR*, CONST ENHMETARECORD FAR*, - int, LPARAM - ); - -static Standard_ShortReal s_xOff, s_yOff; -static BOOL s_fUnicode; - -#define A ( ( PW32_Allocator )myAllocator ) - -//===================================================================== -WNT_DDriver::WNT_DDriver(const Standard_CString aDeviceName, - const Standard_CString aFileName, - const WNT_OrientationType anOrientation, - const Quantity_Factor aScale, - const Standard_Integer aCopies) - : PlotMgt_PlotterDriver (aFileName), - myFlags (0), myOrientation (anOrientation), - myScale (aScale), myNCopies (aCopies), myHDC (NULL) -{ - if (!lstrcmpi (aDeviceName, "DISPLAY" )) { - myHDC = CreateDC ( "DISPLAY", NULL, NULL, NULL ); - myFlags |= FLAG_DISPLAY; - } else if ( *aDeviceName == '\x01'&& !IsBadReadPtr(aDeviceName+1, sizeof(::HDC))) { - CopyMemory ( &myHDC, aDeviceName + 1, sizeof ( ::HDC ) ); - myFlags |= FLAG_BITMAP; - } else if ( *aDeviceName != '\x00' ) { - myHDC = CreateDC ( "WINSPOOL", aDeviceName, NULL, NULL ); - } else if ( !IsBadReadPtr ( aDeviceName + 1, sizeof ( HWND ) ) ) { - HWND hwnd; - CopyMemory ( &hwnd, aDeviceName + 1, sizeof ( HWND ) ); - myHDC = GetDC ( hwnd ); - myFlags |= FLAG_WINDOW; - } // end else - - if (myHDC == NULL) - Aspect_DriverDefinitionError :: Raise ( "Invalid device name" ); - - myDevice = new WNT_GraphicDevice ( Standard_False, myHDC ); - myRect = new RECT; - - if (myDevice -> NumColors () == 2) - myFlags |= FLAG_BANDW; - - ZeroMemory (myRect, sizeof (RECT)); - - int w, h; - double dw, dh; - RECT r; - OSD_Path path (myFileName); - TCollection_AsciiString ext = path.Extension (); - - if (path.Name() != "" && ext == "") - path.SetExtension (".PRN"); - path.SystemName (ext); - - myDevice -> DisplaySize ( w, h ); - myDevice -> DisplaySize ( dw, dh ); - myPixelToUnit = ( dw / w + dh / h ) / 2.0; - - ((PRECT)myRect)->right = w; - ((PRECT)myRect)->bottom = h; - r.left = 0; - r.top = 0; - r.right = _dd_dev_size ( ( ::HDC )myHDC, HORZSIZE ) * 100; - r.bottom = _dd_dev_size ( ( ::HDC )myHDC, VERTSIZE ) * 100; - - switch ( myOrientation ) { - case WNT_OT_PORTRAIT: - if ( w > h ) - doRotate: - myFlags |= FLAG_ROTATE; - break; - case WNT_OT_LANDSCAPE: - if ( w < h ) goto doRotate; - break; - } // end switch - - char buffer[ MAX_DESC_LEN ]; - ZeroMemory ( buffer, sizeof ( buffer ) ); - _dd_fill_buff (buffer); - -/* - if (ext.IsEmpty ()) { - myFlags |= FLAG_DELETE; - ext = _dd_temp_name (); - } // end if -*/ - // Set name for PRN file - myPrnName = ext; - // Set name for EMF file - path.SetExtension (".EMF"); - path.SystemName (ext ); - myEmfName = ext; - // Create EMF file - if ((myHDCMeta = CreateEnhMetaFile ( - ( ::HDC )myHDC, myEmfName.ToCString (), &r, buffer ) - ) == NULL ) - Aspect_DriverError :: Raise ( "Could not create enhanced metafile" ); - - myImage = NULL; - myImageName = new TCollection_HAsciiString ( "" ); - myAllocators = myAllocator = ( *W32_GetAllocator ) ( 0, NULL ); -} - -//===================================================================== -WNT_DDriver::WNT_DDriver(const Standard_CString aFileName, - const Standard_Integer aCopies) - : PlotMgt_PlotterDriver (aFileName) -{ - myAllocator = NULL; - myAllocators = NULL; - myImage = NULL; - myHDC = NULL; - myRect = NULL; - myHMetaFile = NULL; - myNCopies = aCopies; - // Set filenames - OSD_Path path (myFileName); - if (path.Extension () == "") - path.SetExtension (".PRN"); - path.SystemName (myPrnName); - path.SetExtension (".EMF"); - path.SystemName (myEmfName); -} - -//===================================================================== -void WNT_DDriver::Close () -{ - if ( myHDC != NULL && !( myFlags & FLAG_BITMAP ) ) - ( myFlags & FLAG_WINDOW ) ? - ReleaseDC ( WindowFromDC ( ( ::HDC )myHDC ), ( ::HDC )myHDC ) : - DeleteDC ( ( ::HDC )myHDC ); - if ( myRect != NULL ) - delete ( PRECT )myRect; - if ( myImage != NULL ) - DeleteObject ( myImage ); - if ( myHMetaFile != NULL ) - DeleteEnhMetaFile ( ( HENHMETAFILE )myHMetaFile ); - if (myAllocators != NULL) { - do { - myAllocator = ( ( PW32_Allocator )myAllocators ) -> myNext; - delete ( PW32_Allocator )myAllocators; - myAllocators = ( PW32_Allocator )myAllocator; - } while ( myAllocators != NULL ); - } - // Set value to NULL - myHDC = NULL; - myRect = NULL; - myImage = NULL; - myHMetaFile = NULL; -/* - // Delete enhanced metafile - if (GetFileAttributes(myEmfName.ToCString ()) != 0xFFFFFFFF) - DeleteFile ( myEmfName.ToCString () ); -*/ -} - -//===================================================================== -void WNT_DDriver::BeginDraw() -{ - // Text management - myNTextManager = new WNT_TextManager (myPixelToUnit); - - PW32_Allocator a = _FindAllocator (myAllocators, 0); - if (a != NULL) { - a -> ClearBlocks (); - a -> myFlags |= W32F_START; - a -> myFlags |= W32F_DVDRV; - a -> myFlags &= ~W32F_DBUFF; - - if (myFlags & FLAG_DIRTY) { - RECT r = { 0, 0, 0, 0 }; - char buffer[ MAX_DESC_LEN ]; - - r.right = _dd_dev_size ( ( ::HDC )myHDC, HORZSIZE ) * 100; - r.bottom = _dd_dev_size ( ( ::HDC )myHDC, VERTSIZE ) * 100; - - ZeroMemory ( buffer, sizeof ( buffer ) ); - _dd_fill_buff ( buffer ); - DeleteEnhMetaFile ( (HENHMETAFILE)myHMetaFile ); - - if (/*myFlags & FLAG_DELETE && */ - GetFileAttributes(myEmfName.ToCString ()) != 0xFFFFFFFF) - DeleteFile ( myEmfName.ToCString () ); - - myHDCMeta = CreateEnhMetaFile ((::HDC)myHDC, myEmfName.ToCString (), &r, buffer); - if ( myImage != NULL ) { - DeleteObject ( myImage ); - myImage = NULL; - } - myImageName = new TCollection_HAsciiString (""); - } else myFlags |= FLAG_DIRTY; - - Quantity_Length width, height; - WorkSpace (width, height); - if (myFlags & FLAG_ROTATE) { - a -> myAngle = M_PI / 2; - a -> myPivot.x = Convert (height / 2); - a -> myPivot.y = Convert (width / 2); - a -> myMove.x = - a -> myMove.y = (int)((a->myPivot.x - a->myPivot.y) * myScale); - } else { - a -> myMove.x = (int)Convert((width / 2) * (1 - myScale)); - a -> myMove.y = (int)Convert((height / 2) * (1 - myScale)); - } - - a -> myScaleX = a -> myScaleY = myScale; - } - - CSF_SIGN cs = { - CSF_SIGNATURE, sizeof ( CSF_SIGN ), myFlags & FLAG_ROTATE ? 'T' : 'F' - }; - - GdiComment ( - ( ::HDC )myHDCMeta, sizeof ( CSF_SIGN ), ( CONST BYTE* )&cs - ); -} - -//===================================================================== -void WNT_DDriver::EndDraw(const Standard_Boolean fSynchronize) -{ - ((PW32_Allocator)myAllocator) -> myFlags &= ~W32F_START; - PW32_Allocator a = _FindAllocator (myAllocators, 0); - if (a != NULL) { - SIZE sz; - HPALETTE hpo = NULL; - - if (myDevice -> IsPaletteDevice ()) - hpo = SelectPalette ((::HDC) myHDCMeta, - (HPALETTE)myDevice->HPalette (), FALSE); - - sz.cx = ((PRECT)myRect)->right; - sz.cy = ((PRECT)myRect)->bottom; - a -> Play ( (::HDC) myHDCMeta, &sz ); - if (myFlags & FLAG_DISPLAY) - a -> Play ((::HDC) myHDC, &sz); - - if (hpo != NULL) - SelectPalette((::HDC) myHDCMeta, hpo, FALSE); - a -> myFlags |= W32F_DRAWN; - myHMetaFile = CloseEnhMetaFile ( ( ::HDC )myHDCMeta ); - } -/* - if (( myFlags & FLAG_PRINT ) || aPrintFlag) - DoSpool (Standard_False); - if (myFlags & FLAG_DELETE && myHMetaFile != NULL) { - TCollection_AsciiString fName; - myPath.SystemName ( fName ); - DeleteEnhMetaFile ( ( HENHMETAFILE )myHMetaFile ); - myHMetaFile = NULL; - if (GetFileAttributes (fName.ToCString ()) != 0xFFFFFFFF) - DeleteFile ( fName.ToCString () ); - } // end if -*/ -} - -//===================================================================== -Standard_Boolean WNT_DDriver::Spool(const Aspect_PlotMode aPlotMode, - const Standard_CString aDeviceName, - const Standard_Boolean anOriginalSize) -{ - Standard_Boolean fOrigSize = anOriginalSize; - if ( aDeviceName != NULL ) { - if ( myHDC != NULL ) Close (); - if ( !lstrcmpi ( aDeviceName, "DISPLAY" ) ) { - myHDC = CreateDC ( "DISPLAY", NULL, NULL, NULL ); - myFlags |= FLAG_DISPLAY; - } else if ( *aDeviceName == '\x01'&& !IsBadReadPtr(aDeviceName+1, sizeof(::HDC))) { - CopyMemory ( &myHDC, aDeviceName + 1, sizeof ( ::HDC ) ); - myFlags |= FLAG_BITMAP; - } else if ( *aDeviceName != '\x00' ) { - myHDC = CreateDC ( "WINSPOOL", aDeviceName, NULL, NULL ); - } else if ( !IsBadReadPtr ( aDeviceName + 1, sizeof ( HWND ) ) ) { - HWND hwnd; - CopyMemory ( &hwnd, aDeviceName + 1, sizeof ( HWND ) ); - myHDC = GetDC ( hwnd ); - myFlags |= FLAG_WINDOW; - } // end else - - if ( myHDC == NULL ) - return Standard_False; - myDevice = new WNT_GraphicDevice ( Standard_False, myHDC ); - myRect = new RECT; - ZeroMemory ( myRect, sizeof ( RECT ) ); - int w, h; - myDevice -> DisplaySize ( w, h ); - ( ( PRECT )myRect ) -> right = w; - ( ( PRECT )myRect ) -> bottom = h; - if ((myHMetaFile = GetEnhMetaFile (myEmfName.ToCString ())) == NULL) - return Standard_False; - } else fOrigSize = Standard_False; - Standard_Boolean fSpoolRes1 = DoSpool ( fOrigSize, aPlotMode ); - Standard_Boolean fSpoolRes2 = (aPlotMode == Aspect_PM_FILEONLY ? - Standard_True : - DoSpool ( fOrigSize, Aspect_PM_FILEONLY ) - ); - return (fSpoolRes1 & fSpoolRes2); -} - -//===================================================================== -Standard_Boolean WNT_DDriver::DoSpool - (const Standard_Boolean anOriginalSize, - const Aspect_PlotMode aPlotMode) const -{ - Standard_Integer i; - UINT n; - char buffer[ MAX_DESC_LEN ]; - DOCINFO di; - PLOGPALETTE pLogPal; - HPALETTE hPal; - Standard_Boolean retVal = Standard_True; - - if (GetEnhMetaFileDescription ((HENHMETAFILE )myHMetaFile, MAX_DESC_LEN, buffer) - == GDI_ERROR) - return Standard_False; - if (!(myFlags & (FLAG_DISPLAY|FLAG_WINDOW|FLAG_BITMAP))) { - di.cbSize = sizeof (DOCINFO); - di.lpszDocName = buffer; - if (aPlotMode == Aspect_PM_FILEONLY) - di.lpszOutput = myPrnName.ToCString (); - else - di.lpszOutput = NULL; - i = 0; - if ( StartDoc ( ( ::HDC )myHDC, &di ) <= 0 ) - return Standard_False; - nextPage: - if ( StartPage ( ( ::HDC )myHDC ) <= 0 ) - return Standard_False; - } // end if - n = GetEnhMetaFilePaletteEntries ( ( HENHMETAFILE )myHMetaFile, 0, NULL ); - if ( n && n != GDI_ERROR ) { - pLogPal = ( PLOGPALETTE )new char[ sizeof ( DWORD ) + sizeof ( PALETTEENTRY ) * n ]; - pLogPal -> palVersion = 0x300; - pLogPal -> palNumEntries = ( WORD )n; - GetEnhMetaFilePaletteEntries ( - ( HENHMETAFILE )myHMetaFile, n, - ( PPALETTEENTRY )( ( ( PBYTE )pLogPal ) + 8 ) - ); - hPal = CreatePalette ( pLogPal ); - delete [] ( char* )pLogPal; - SelectPalette ( ( ::HDC )myHDC, hPal, FALSE ); - RealizePalette ( ( ::HDC )myHDC ); - } // end if - if (anOriginalSize) { - float pX, pY, mmX, mmY; - ENHMETAHEADER emh; - ZeroMemory ( &emh, sizeof ( ENHMETAHEADER ) ); - emh.nSize = sizeof ( ENHMETAHEADER ); - if ( GetEnhMetaFileHeader ( - ( HENHMETAFILE )myHMetaFile, sizeof ( ENHMETAHEADER ), &emh) - == 0 - ) goto spoolError; - pX = ( float )_dd_dev_size ( ( ::HDC )myHDC, HORZRES ); - pY = ( float )_dd_dev_size ( ( ::HDC )myHDC, VERTRES ); - mmX = ( float )_dd_dev_size ( ( ::HDC )myHDC, HORZSIZE ); - mmY = ( float )_dd_dev_size ( ( ::HDC )myHDC, VERTSIZE ); - *( ( PLONG )( &( ( LPRECT )myRect ) -> top ) ) = - ( LONG )( ( float )( emh.rclFrame.top ) * pY / ( mmY * 100.0F ) ); - *( ( PLONG )( &( ( LPRECT )myRect ) -> left ) ) = - ( LONG )( ( float )( emh.rclFrame.left ) * pX / ( mmX * 100.0F ) ); - *( ( PLONG )( &( ( LPRECT )myRect ) -> right ) ) = - ( LONG )( ( float )( emh.rclFrame.right ) * pX / ( mmX * 100.0F ) ); - *( ( PLONG )( &( ( LPRECT )myRect ) -> bottom ) ) = - ( LONG )( ( float )( emh.rclFrame.bottom ) * pY / ( mmY * 100.0F ) ); - } // end if - if (!PlayEnhMetaFile ((::HDC)myHDC, (HENHMETAFILE)myHMetaFile, (LPRECT)myRect)) -spoolError: - retVal = Standard_False; - - if (n && n != GDI_ERROR) - DeleteObject ( hPal ); - - if (!( myFlags & (FLAG_DISPLAY|FLAG_WINDOW|FLAG_BITMAP))) { - if (EndPage ( ( ::HDC )myHDC ) <= 0) - retVal = Standard_False; - if (++i < myNCopies && retVal) - goto nextPage; - if (EndDoc ( ( ::HDC )myHDC ) <= 0) - retVal = Standard_False; - } // end if - return retVal; -} - -//===================================================================== -void WNT_DDriver::SetLineAttrib(const Standard_Integer ColorIndex, - const Standard_Integer TypeIndex, - const Standard_Integer WidthIndex) -{ -#ifdef PRO17334 - if (myColors.IsNull() || - ColorIndex < myColors->Lower() || ColorIndex > myColors->Upper()) - Aspect_DriverError::Raise ("Bad Color Index"); - if (myTypeIdxs.IsNull() || - TypeIndex < myTypeIdxs->Lower() || TypeIndex > myTypeIdxs->Upper()) - Aspect_DriverError::Raise ("Bad Type Index"); - if (myWidthIdxs.IsNull() || - WidthIndex < myWidthIdxs->Lower() || WidthIndex > myWidthIdxs->Upper()) - Aspect_DriverError::Raise ("Bad Width Index"); - - Aspect_LineStyle Entry = TypeMap () -> Entry ( myTypeIdxs -> Value(TypeIndex) ).Type (); -#else - Standard_Integer theIndex = TypeIndex; - if (TypeIndex < myTypeIdxs->Lower() || TypeIndex > myTypeIdxs->Upper()) - theIndex = myTypeIdxs->Lower(); - - Aspect_LineStyle Entry = TypeMap () -> Entry ( myTypeIdxs -> Value(theIndex) ).Type (); -#endif - Standard_Integer type = ((Entry.Style() == Aspect_TOL_SOLID) ? 0 : PS_USERSTYLE); - double width = ( double )ProcessWidthIndex ( WidthIndex ); - Standard_Boolean fUser = ( type & PS_USERSTYLE ); - LOGBRUSH lb = { BS_SOLID, ProcessColorIndex ( ColorIndex ), 0 }; - if ( fUser ) { - Standard_Integer Lower = Entry.Values ().Lower (); - Standard_Integer Count = Entry.Values ().Length (); - PDWORD dwStyle = ( PDWORD )HeapAlloc ( - GetProcessHeap (), - HEAP_GENERATE_EXCEPTIONS, - Count * sizeof ( DWORD ) - ); - for ( Standard_Integer i = 0; i < Count; ++i ) { - dwStyle[ i ] = DWORD ( Entry.Values ().Value ( i + Lower ) / myPixelToUnit + 0.5 ); - if ( dwStyle[ i ] == 0.0 ) dwStyle[ i ] = 1; - } // end for - A -> LineAttrib ( DWORD( width + 0.5 ), &lb, Count, dwStyle ); - HeapFree ( GetProcessHeap (), 0, ( LPVOID )dwStyle ); - } else A -> LineAttrib ( DWORD( width + 0.5 ), &lb ); -} - -//===================================================================== -void WNT_DDriver::SetTextAttrib(const Standard_Integer ColorIndex, - const Standard_Integer FontIndex) -{ - SetTextAttrib ( ColorIndex, FontIndex, 0.0, 1.0, 0.0,Standard_False ); -} - -//===================================================================== -void WNT_DDriver::SetTextAttrib(const Standard_Integer ColorIndex, - const Standard_Integer FontIndex, - const Quantity_PlaneAngle aSlant, - const Quantity_Factor aHScale, - const Quantity_Factor aWScale, - const Standard_Boolean isUnderlined) -{ -#ifdef PRO17334 - if (myColors.IsNull() || - ColorIndex < myColors->Lower() || ColorIndex > myColors->Upper()) - Aspect_DriverError::Raise ("Bad Color Index"); - if (myFonts.IsNull() || - FontIndex < myFonts->Lower() || FontIndex > myFonts->Upper()) - Aspect_DriverError::Raise ("Bad Font Index"); -#endif - - HFONT hFont; - LOGFONT lf; - BOOL fFree = FALSE; - Handle( WNT_FontMapEntry ) fmEntry = myFonts -> Value ( FontIndex ); -/*====================== MFT ====================*/ -#ifdef MFT - if ( UseMFT() ) { - //============== Set some font attributes ============= - Handle(MFT_FontManager) theFontManager = MFT_Font(FontIndex); - Standard_ShortReal theTextSize = MFT_Size(FontIndex); - theFontManager->SetFontAttribs ( - Abs(theTextSize)*(aWScale > 0.0 ? aWScale : aHScale)*A->myScaleX, - Abs(theTextSize)*aHScale *A->myScaleY, - aSlant, 0., ((theTextSize > 0.) ? Standard_False : Standard_True) - ); - A -> TextAttrib ( - (HFONT)FontIndex, ProcessColorIndex ( ColorIndex ), aSlant, - aHScale, - ( aWScale > 0.0 ? aWScale : aHScale ), - isUnderlined, Standard_False, Standard_True - ); - } else { -#endif -/*====================== MFT ====================*/ - GetObject ( - hFont = ( HFONT )fmEntry-> HFont (), - sizeof ( LOGFONT ), &lf - ); - if ( isUnderlined && !lf.lfUnderline ) { - FONT_DATA fd = { TRUE }; - hFont = ( HFONT )fmEntry -> SetAttrib ( faUnderlined, &fd ); - fFree = TRUE; - } // end if - A -> TextAttrib ( - hFont, ProcessColorIndex ( ColorIndex ), aSlant, - aHScale / W32_TextFactor, - ( aWScale > 0.0 ? aWScale : aHScale ) / W32_TextFactor, - isUnderlined, fFree - ); -/*====================== MFT ====================*/ -#ifdef MFT - } -#endif -/*====================== MFT ====================*/ -} - -//===================================================================== -void WNT_DDriver::SetPolyAttrib(const Standard_Integer ColorIndex, - const Standard_Integer TileIndex, - const Standard_Boolean DrawEdge) -{ -#ifdef PRO17334 - if (myColors.IsNull() || - ColorIndex < myColors->Lower() || ColorIndex > myColors->Upper()) - Aspect_DriverError::Raise ("Bad Color Index"); -#endif - LOGBRUSH lb = { TileIndex < 0 ? BS_NULL : BS_SOLID, ProcessColorIndex ( ColorIndex ), 0 }; - A -> PolyAttrib ( &lb, DrawEdge ); -} - -//===================================================================== -void WNT_DDriver::SetMarkerAttrib(const Standard_Integer ColorIndex, - const Standard_Integer WidthIndex, - const Standard_Boolean FillMarker) -{ -#ifdef PRO17334 - if (myColors.IsNull() || - ColorIndex < myColors->Lower() || ColorIndex > myColors->Upper()) - Aspect_DriverError::Raise ("Bad Color Index"); - if (myWidthIdxs.IsNull() || - WidthIndex < myWidthIdxs->Lower() || WidthIndex > myWidthIdxs->Upper()) - Aspect_DriverError::Raise ("Bad EdgeWidth Index"); -#endif - A -> MarkerAttrib ( - ProcessColorIndex ( ColorIndex ), - DWORD( ProcessWidthIndex ( WidthIndex ) + 0.5 ), - FillMarker - ); -} - -//===================================================================== -Standard_Boolean WNT_DDriver::IsKnownImage - (const Handle(Standard_Transient)& anImage) -{ - return Standard_False; -} - -//===================================================================== -Standard_Boolean WNT_DDriver::SizeOfImageFile - (const Standard_CString anImageFile, - Standard_Integer& aWidth, - Standard_Integer& aHeight) const -{ -#ifndef BUG //Sets the size to 0 when the image file is not found. - aWidth = 0; aHeight = 0; -#endif - - Handle( TCollection_HAsciiString ) iName = myImageName; - Handle( WNT_GraphicDevice ) gDev = myDevice; - if ( myImage == NULL || iName -> String () != anImageFile ) { - *( ( Aspect_Handle* )&myImage ) = - LoadImageFromFile ( gDev, (Standard_PCharacter)anImageFile, ( ::HDC )myHDCMeta ); - if ( myImage == NULL ) return Standard_False; - iName -> Clear (); - iName -> AssignCat ( anImageFile ); - } // end if - BITMAP bmp; - GetObject ( ( HBITMAP )myImage, sizeof ( BITMAP ), &bmp ); - aWidth = bmp.bmWidth; - aHeight = bmp.bmHeight; - return Standard_True; -} - -//===================================================================== -void WNT_DDriver::ClearImage(const Handle(Standard_Transient)& anImageId) -{ - if (myImage != NULL) { - DeleteObject ( myImage ); - myImage = NULL; - myImageName -> Clear (); - } // end if -} - -//===================================================================== -void WNT_DDriver::ClearImageFile(const Standard_CString anImageFile) -{ - if ( myImage != NULL && myImageName -> String () == anImageFile ) - ClearImage ( Handle( Standard_Transient ) () ); -} - -//===================================================================== -void WNT_DDriver::DrawImage(const Handle(Standard_Transient)& anImageId, - const Standard_ShortReal aX, - const Standard_ShortReal aY) -{ - if (myImage != NULL) { - PW32_Bitmap pwbmp = ( PW32_Bitmap )HeapAlloc ( - GetProcessHeap (), HEAP_GENERATE_EXCEPTIONS, sizeof ( W32_Bitmap ) - ); - pwbmp -> nUsed = 0; - pwbmp -> hBmp = (HBITMAP)myImage; - A -> Image ( P( aX ), P( aY ), pwbmp, 1.0 * Convert(myPixelSize) ); - } -} - -//===================================================================== -void WNT_DDriver::DrawImageFile(const Standard_CString anImageFile, - const Standard_ShortReal aX, - const Standard_ShortReal aY, - const Quantity_Factor aScale) -{ - int Width, Height; - if (SizeOfImageFile ( anImageFile, Width, Height )) { - PW32_Bitmap pwbmp = ( PW32_Bitmap )HeapAlloc ( - GetProcessHeap (), HEAP_GENERATE_EXCEPTIONS, sizeof ( W32_Bitmap ) - ); - pwbmp -> nUsed = 0; - pwbmp -> hBmp = ( HBITMAP )myImage; - A -> Image ( P( aX ), P( aY ), pwbmp, aScale * Convert(myPixelSize) ); - } -} - -//===================================================================== -void WNT_DDriver::FillAndDrawImage - (const Handle(Standard_Transient)& anImageId, - const Standard_ShortReal aX, - const Standard_ShortReal aY, - const Standard_Integer aWidth, - const Standard_Integer aHeight, - const Standard_Address anArrayOfPixels) -{ - int Width, Height; - ::HDC hdcMem; - HBITMAP hbo; - HPALETTE hpo = NULL; - Quantity_Color color; - PPIXEL2D p = ( PPIXEL2D )anArrayOfPixels; - - if ( !SizeOfImageFile (myImageName->ToCString(), Width, Height) || - Width != aWidth || - Height != aHeight) { - Width = aWidth; - Height = aHeight; - ClearImage ( anImageId ); - myImage = CreateCompatibleBitmap ((::HDC)myHDCMeta, Width, Height); - } // end if - hdcMem = CreateCompatibleDC ( (::HDC)myHDCMeta ); - - if ( myDevice -> IsPaletteDevice () ) - hpo = SelectPalette (hdcMem, (HPALETTE)myDevice->HPalette (), FALSE); - - if (Width > 0 && Height > 0) { - hbo = ( HBITMAP )SelectObject (hdcMem, ( HBITMAP )myImage); - for ( int i = 0; i < Height; ++i ) - for ( int j = 0; j < Width; ++j, ++p ) { - color.SetValues ( p->r, p->g, p->b, Quantity_TOC_RGB ); - SetPixel (hdcMem, j, i, myDevice->SetColor(color)); - } // end for - SelectObject ( hdcMem, hbo ); - } // end if - - if ( hpo != NULL ) SelectPalette ( hdcMem, hpo, FALSE ); - - DeleteDC ( hdcMem ); - DrawImage ( anImageId, aX, aY ); -} - -//===================================================================== -void WNT_DDriver::FillAndDrawImage - (const Handle(Standard_Transient)& anImageId, - const Standard_ShortReal aX, - const Standard_ShortReal aY, - const Standard_Integer anIndexOfLine, - const Standard_Integer aWidth, - const Standard_Integer aHeight, - const Standard_Address anArrayOfPixels) -{ - int Width, Height; - ::HDC hdcMem; - HBITMAP hbo; - HPALETTE hpo = NULL; - Quantity_Color color; - PPIXEL2D p = ( PPIXEL2D )anArrayOfPixels; - - if ( !SizeOfImageFile (myImageName->ToCString(), Width, Height) || - Width != aWidth || - Height != aHeight) { - Width = aWidth; - Height = aHeight; - ClearImage ( anImageId ); - myImage = CreateCompatibleBitmap ((::HDC)myHDCMeta, Width, Height); - } // end if - hdcMem = CreateCompatibleDC ( (::HDC)myHDCMeta ); - - if ( myDevice -> IsPaletteDevice () ) - hpo = SelectPalette (hdcMem, (HPALETTE)myDevice->HPalette (), FALSE); - - if (Width > 0 && Height > 0) { - hbo = ( HBITMAP )SelectObject (hdcMem, ( HBITMAP )myImage); - for ( int j = 0; j < Width; ++j, ++p ) { - color.SetValues ( p->r, p->g, p->b, Quantity_TOC_RGB ); - SetPixel (hdcMem, j, anIndexOfLine, myDevice->SetColor(color)); - } // end for - SelectObject ( hdcMem, hbo ); - } // end if - - if ( hpo != NULL ) SelectPalette ( hdcMem, hpo, FALSE ); - - DeleteDC ( hdcMem ); - if (anIndexOfLine == Height - 1) - DrawImage ( anImageId, aX, aY ); -} - -//===================================================================== -Standard_Boolean WNT_DDriver::PlotPolyline(const Standard_Address xArray, - const Standard_Address yArray, - const Standard_Address nPts, - const Standard_Integer nParts) -{ -/* - Standard_Integer nPts = aListX.Length (); - Standard_Integer lX = aListX.Lower (); - Standard_Integer lY = aListY.Lower (); - if ( A -> myPrimitive != zzNone ) - ClosePrimitive (); - W32_PolygonNote* p = ( W32_PolygonNote* )( A -> Polyline ( nPts ) ); - for ( Standard_Integer i = 0; i < nPts; ++i ) - p -> Add ( - P( aListX.Value ( lX + i ) ), - P( aListY.Value ( lY + i ) ) - ); -*/ - return Standard_True; -} - -//===================================================================== -Standard_Boolean WNT_DDriver::PlotPolygon(const Standard_Address xArray, - const Standard_Address yArray, - const Standard_Address nPts, - const Standard_Integer nParts) -{ -/* - Standard_Integer nPts = aListX.Length (); - if ( nPts != aListY.Length () ) - Aspect_DriverError :: Raise ( "DrawPolygon: incorrect argument" ); - if ( nPts > 0 ) { - Standard_Integer lX = aListX.Lower (); - Standard_Integer lY = aListY.Lower (); - if ( A -> myPrimitive != zzNone ) - ClosePrimitive (); - W32_PolygonNote* p = ( W32_PolygonNote* )( A -> Polygon ( nPts ) ); - for ( Standard_Integer i = 0; i < nPts; ++i ) - p -> Add ( - P( aListX.Value ( lX + i ) ), - P( aListY.Value ( lY + i ) ) - ); - } // end if -*/ - return Standard_True; -} - -//===================================================================== -Standard_Boolean WNT_DDriver::PlotSegment(const Standard_ShortReal X1, - const Standard_ShortReal Y1, - const Standard_ShortReal X2, - const Standard_ShortReal Y2) -{ - A -> Line ( P( X1 ), P( Y1 ), P( X2 ), P( Y2 ) ); - return Standard_True; -} - -//===================================================================== -Standard_Boolean WNT_DDriver::PlotText(const TCollection_ExtendedString& aText, - const Standard_ShortReal Xpos, - const Standard_ShortReal Ypos, - const Standard_ShortReal anAngle, - const Aspect_TypeOfText aType) -{ -/*====================== MFT ====================*/ -#ifdef MFT - if ( UseMFT() ) { -/* - MFT_DRAWTEXT dt = { - myAllocator, this, myPixelToUnit, - Xpos, Ypos, anAngle, 0., (int)aType, - FALSE, TRUE, aText.Length(), NULL - }; - CopyMemory (dt.theText, aText.ToExtString(), - aText.Length()*sizeof(short)); - A -> FunCall ( _Do_MFTDrawText_, sizeof(MFT_DRAWTEXT), - PW32_FCALLPARAM(&dt) ); -*/ - } else { -#endif -/*====================== MFT ====================*/ - char* str = _ConvertU2F ( aText ); - A -> Text ( - P( Xpos ), P( Ypos ), - anAngle, str, FALSE, - ( aType == Aspect_TOT_SOLID ) ? FALSE : TRUE - ); - HeapFree ( GetProcessHeap (), 0, str ); -/*====================== MFT ====================*/ -#ifdef MFT - } -#endif -/*====================== MFT ====================*/ - return Standard_True; -} - -//===================================================================== -Standard_Boolean WNT_DDriver :: PlotText ( - const Standard_CString Text, - const Standard_ShortReal Xpos, - const Standard_ShortReal Ypos, - const Standard_ShortReal anAngle, - const Aspect_TypeOfText aType - ) -{ -/*====================== MFT ====================*/ -#ifdef MFT - if ( UseMFT() ) { -/* - MFT_DRAWTEXT dt = { - myAllocator, this, myPixelToUnit, - Xpos, Ypos, anAngle, 0., (int)aType, - FALSE, FALSE, lstrlen(Text), NULL - }; - CopyMemory (dt.theText, Text, lstrlen(Text)); - A -> FunCall ( _Do_MFTDrawText_, sizeof(MFT_DRAWTEXT), - PW32_FCALLPARAM(&dt) ); -*/ - } else -#endif -/*====================== MFT ====================*/ - A -> Text ( - P( Xpos ), P( Ypos ), - anAngle, (Standard_PCharacter)Text, FALSE, - ( aType == Aspect_TOT_SOLID ) ? FALSE : TRUE - ); - return Standard_True; -} - -//===================================================================== -Standard_Boolean WNT_DDriver::PlotPolyText(const TCollection_ExtendedString& aText, - const Standard_ShortReal Xpos, - const Standard_ShortReal Ypos, - const Quantity_Ratio aMarge, - const Standard_ShortReal anAngle, - const Aspect_TypeOfText aType) -{ -/*====================== MFT ====================*/ -#ifdef MFT - if ( UseMFT() ) { -/* - MFT_DRAWTEXT dt = { - myAllocator, this, myPixelToUnit, - Xpos, Ypos, anAngle, aMarge, (int)aType, - TRUE, TRUE, aText.Length(), NULL - }; - CopyMemory (dt.theText, aText.ToExtString(), - aText.Length()*sizeof(short)); - A -> FunCall ( _Do_MFTDrawText_, sizeof(MFT_DRAWTEXT), - PW32_FCALLPARAM(&dt) ); -*/ - } else { -#endif -/*====================== MFT ====================*/ - char* str = _ConvertU2F ( aText ); - A -> Polytext ( - P( Xpos ), P( Ypos ), - anAngle, aMarge, str, FALSE, - ( aType == Aspect_TOT_SOLID ) ? FALSE : TRUE - ); - HeapFree ( GetProcessHeap (), 0, str ); -/*====================== MFT ====================*/ -#ifdef MFT - } -#endif -/*====================== MFT ====================*/ - return Standard_True; -} - -//===================================================================== -Standard_Boolean WNT_DDriver :: PlotPolyText ( - const Standard_CString aText, - const Standard_ShortReal Xpos, - const Standard_ShortReal Ypos, - const Quantity_Ratio aMarge, - const Standard_ShortReal anAngle, - const Aspect_TypeOfText aType - ) -{ -/*====================== MFT ====================*/ -#ifdef MFT - if ( UseMFT() ) { -/* - MFT_DRAWTEXT dt = { - myAllocator, this, myPixelToUnit, - Xpos, Ypos, anAngle, aMarge, (int)aType, - TRUE, FALSE, lstrlen(aText), NULL - }; - CopyMemory (dt.theText, aText, lstrlen(aText)); - A -> FunCall ( _Do_MFTDrawText_, sizeof(MFT_DRAWTEXT), - PW32_FCALLPARAM(&dt) ); -*/ - } else -#endif -/*====================== MFT ====================*/ - A -> Polytext ( - P( Xpos ), P( Ypos ), - anAngle, aMarge, (Standard_PCharacter)aText, FALSE, - ( aType == Aspect_TOT_SOLID ) ? FALSE : TRUE - ); - return Standard_True; -} - -//===================================================================== -Standard_Boolean WNT_DDriver::PlotPoint(const Standard_ShortReal X, - const Standard_ShortReal Y) -{ - switch ( A -> myPrimitive ) { - case zzPolygon: - ( ( W32_PolygonNote* )( A -> myNote ) ) -> Add ( P( X ), P( Y ) ); - break; - case zzPolyline: - ( ( W32_PolylineNote* )( A -> myNote ) ) -> Add ( P( X ), P( Y ) ); - break; - default: - A -> Point ( P( X ), P( Y ) ); - } // end switch - return Standard_True; -} - -//===================================================================== -Standard_Boolean WNT_DDriver::PlotMarker(const Standard_Integer aMarker, - const Standard_ShortReal Xpos, - const Standard_ShortReal Ypos, - const Standard_ShortReal Width, - const Standard_ShortReal Height, - const Standard_ShortReal Angle) -{ - if ( A -> myPrimitive != zzNone && A -> myPrimitive != zzMarker ) - ClosePrimitive (); - - int aWidth = P( Width ); - int aHeight = P( Height ); - Standard_Integer theIndex = -1; -#ifdef PRO17334 - if (!myMarkerIdxs.IsNull() && - (aMarker >= myMarkerIdxs->Lower() && aMarker <= myMarkerIdxs->Upper())) - theIndex = myMarkerIdxs->Value(aMarker); - if (theIndex < 0) Aspect_DriverError::Raise ("Bad Marker Index"); - - if (aWidth && aHeight && (aMarker > 0)) { -#else - if (aMarker >= myMarkerIdxs->Lower() || aMarker <= myMarkerIdxs->Upper()) - theIndex = myMarkerIdxs->Value(aMarker); - - if (aWidth && aHeight && (theIndex >= 0)) { -#endif - A -> BeginMarker ( P( Xpos ), P( Ypos ), aWidth, aHeight, Angle ); - Aspect_MarkerStyle Style = MarkMap () -> Entry ( theIndex ).Style (); - int MarkerSize = Style.Length (); - int DrawCount = 0; - int PrevPoint = 0; - int i = 2; - MPARAM mp = { &Style, aWidth, aHeight }; - for (; i <= MarkerSize; ++i ) { - if ( Style.SValues ().Value ( i ) ) { - if ( Style.SValues ().Value ( i - 1 ) ) - ++DrawCount; - else { - PrevPoint = i - 1; - DrawCount = 2; - } // end else - } else { - if ( Style.SValues().Value ( i - 1 ) ) { - if ( ( Style.XValues ().Value ( i ) == - Style.XValues ().Value ( PrevPoint ) ) && - ( Style.YValues ().Value ( i ) == - Style.YValues ().Value ( PrevPoint ) ) - ) - A -> PolyMarker2 ( DrawCount, &_SetPoint, PrevPoint, &mp ); - else - A -> PolyMarker1 ( DrawCount, &_SetPoint, PrevPoint, &mp ); - } // end if - DrawCount = 0; - } // end else - } // end for - --i; - if ( DrawCount ) { - if ( ( Style.XValues ().Value ( i ) == - Style.XValues ().Value ( PrevPoint ) ) && - ( Style.YValues ().Value ( i ) == - Style.YValues ().Value ( PrevPoint ) ) - ) - A -> PolyMarker2 ( DrawCount, &_SetPoint, PrevPoint, &mp ); - else - A -> PolyMarker1 ( DrawCount, &_SetPoint, PrevPoint, &mp ); - } // end if - A -> EndMarker (); - } else A -> MarkerPoint ( P( Xpos ), P( Ypos ) ); - return Standard_True; -} - -//===================================================================== -Standard_Boolean WNT_DDriver::PlotArc(const Standard_ShortReal X, - const Standard_ShortReal Y, - const Standard_ShortReal anXradius, - const Standard_ShortReal anYradius, - const Standard_ShortReal aStartAngle, - const Standard_ShortReal anOpenAngle) -{ - if ( A -> myPrimitive != zzNone && A -> myPrimitive != zzArc ) - ClosePrimitive (); - if ( anOpenAngle >= 6.28318 ) - A -> Ellipse ( P( X ), P( Y ), P( anXradius ), P( anYradius ) ); - else - A -> Arc ( - P( X ), P( Y ), P( anXradius ), P( anYradius ), - aStartAngle, anOpenAngle - ); - return Standard_True; -} - -//===================================================================== -Standard_Boolean WNT_DDriver::PlotPolyArc(const Standard_ShortReal X, - const Standard_ShortReal Y, - const Standard_ShortReal anXradius, - const Standard_ShortReal anYradius, - const Standard_ShortReal aStartAngle, - const Standard_ShortReal anOpenAngle) -{ - if ( A -> myPrimitive != zzNone && A -> myPrimitive != zzPolySector ) - ClosePrimitive (); - if ( anOpenAngle >= 6.28318 ) - A -> PolyEllipse ( P( X ), P( Y ), P( anXradius ), P( anYradius ) ); - else - A -> PolySector ( - P( X ), P( Y ), P( anXradius ), P( anYradius ), - aStartAngle, anOpenAngle - ); - return Standard_True; -} - -//===================================================================== -void WNT_DDriver::BeginPolyline(const Standard_Integer aNumber) -{ - A -> myPrimitive = zzPolyline; - A -> myNote = A -> Polyline ( aNumber ); -} - -//===================================================================== -void WNT_DDriver::BeginPolygon(const Standard_Integer aNumber) -{ - A -> myPrimitive = zzPolygon; - A -> myNote = A -> Polygon ( aNumber ); -} - -//===================================================================== -void WNT_DDriver::BeginSegments() -{ - A -> myPrimitive = zzLine; - A -> myNote = NULL; -} - -//===================================================================== -void WNT_DDriver::BeginArcs() -{ - A -> myPrimitive = zzArc; - A -> myNote = NULL; -} - -//===================================================================== -void WNT_DDriver::BeginPolyArcs() -{ - A -> myPrimitive = zzPolySector; - A -> myNote = NULL; -} - -//===================================================================== -void WNT_DDriver::BeginMarkers() -{ - A -> myPrimitive = zzMarker; - A -> myNote = NULL; -} - -//===================================================================== -void WNT_DDriver::BeginPoints() -{ - A -> myPrimitive = zzPoint; - A -> myNote = NULL; -} - -//===================================================================== -void WNT_DDriver::ClosePrimitive() -{ - A -> myPrimitive = zzNone; - A -> myNote = NULL; -} - -//===================================================================== -void WNT_DDriver::InitializeColorMap(const Handle(Aspect_ColorMap)& aColorMap) -{ - Aspect_ColorMapEntry entry; - Standard_Integer i, minindex = IntegerLast(), maxindex = -minindex; - for (i = 1; i <= aColorMap->Size (); i++) { - entry = aColorMap->Entry (i); - maxindex = Max(maxindex, entry.Index ()); - minindex = Min(minindex, entry.Index ()); - } - - if (myColors.IsNull () || myColors -> Length () != aColorMap -> Size ()) - myColors = new WNT_HColorTable ( minindex, maxindex, (WNT_ColorRef)0x00000000 ); - myDevice -> MapColors ( aColorMap, myColors ); -} - -//===================================================================== -void WNT_DDriver::InitializeTypeMap(const Handle(Aspect_TypeMap)& aTypeMap) -{ - Aspect_TypeMapEntry entry; - Standard_Integer i, minindex = IntegerLast(), maxindex = -minindex; - for (i = 1; i <= aTypeMap->Size (); i++) { - entry = aTypeMap->Entry (i); - maxindex = Max(maxindex, entry.Index ()); - minindex = Min(minindex, entry.Index ()); - } - - myTypeIdxs = new TColStd_HArray1OfInteger (minindex, maxindex, 1); - for (i = 1; i <= aTypeMap->Size (); i++) { - entry = aTypeMap->Entry (i); - myTypeIdxs -> SetValue (entry.Index(), i); - } -} - -//===================================================================== -void WNT_DDriver::InitializeWidthMap(const Handle(Aspect_WidthMap)& aWidthMap) -{ - Aspect_WidthMapEntry entry; - Standard_Integer i, minindex = IntegerLast(), maxindex = -minindex; - for (i = 1; i <= aWidthMap->Size (); i++) { - entry = aWidthMap->Entry (i); - maxindex = Max(maxindex, entry.Index ()); - minindex = Min(minindex, entry.Index ()); - } - - myWidthIdxs = new TColStd_HArray1OfInteger (minindex, maxindex, 1); - for (i = 1; i <= aWidthMap->Size (); i++) { - entry = aWidthMap->Entry (i); - myWidthIdxs -> SetValue (entry.Index(), i); - } -} - -//===================================================================== -void WNT_DDriver::InitializeFontMap(const Handle(Aspect_FontMap)& aFontMap) -{ - Aspect_FontStyle fontStyle; - Handle( WNT_FontMapEntry ) fmEntry; - Standard_Character left[ 260 ], right[ 250 ]; - Standard_PCharacter pSize; - Standard_Integer height, mapSize = aFontMap -> Size (); - Standard_Integer i; - HFONT hfo = - SelectFont((::HDC)myHDC, GetStockObject(DEFAULT_GUI_FONT)); -/*====================== MFT ====================*/ -#ifdef MFT - Aspect_FontMapEntry entry; - Aspect_FontStyle style; - Quantity_Length size; - Quantity_PlaneAngle slant; - TCollection_AsciiString aname; - if ( UseMFT() ) { - Handle(MFT_FontManager) theFontManager; - myMFTFonts = new WNT_HListOfMFTFonts (0, mapSize, theFontManager); - myMFTSizes = new TShort_HArray1OfShortReal (0, mapSize, 0.F); - } -#endif -/*====================== MFT ====================*/ - myFonts = new WNT_HFontTable ( 0, mapSize - 1 ); - for ( i = 0; i < mapSize; ++i ) { -/*====================== MFT ====================*/ -#ifdef MFT - if ( UseMFT() ) { - entry = aFontMap->Entry(i+1); - style = entry.Type (); - size = (Quantity_Length) TOMILLIMETER (style.Size()); - slant = style.Slant (); - if (style.CapsHeight()) size = -size; - aname = style.AliasName (); - Standard_Boolean found = MFT_FontManager::IsKnown (aname.ToCString()); - if (!found) { - cout << " WNT_DDriver::SetFontMap can't find the MFT font name '" - << aname << "', using 'Defaultfont'" << endl << flush; - aname = TCollection_AsciiString("Defaultfont"); - found = Standard_True; - } - if (found) { - Handle(MFT_FontManager) theFontManager; - Aspect_FontStyle theStyle = MFT_FontManager::Font (aname.ToCString()); - found = Standard_False; - for (int k = 0; k < mapSize; k++) { - theFontManager = myMFTFonts -> Value (k); - if (!theFontManager.IsNull()) { - if (theStyle == theFontManager->Font()) { - found = Standard_True; - break; - } - } - } - if (!found) - theFontManager = new MFT_FontManager (aname.ToCString()); - theFontManager->SetFontAttribs ( - Abs(size), Abs(size), slant, 0., Standard_Boolean(size < 0.) - ); - myMFTFonts->SetValue (i, theFontManager); - myMFTSizes->SetValue (i, (Standard_ShortReal)size); - } - } - if (UseMFT() && !myMFTFonts->Value(i).IsNull()) - continue; -#endif -/*====================== MFT ====================*/ - fontStyle = aFontMap -> Entry ( i + 1 ).Type (); - height = Standard_Integer ( fontStyle.Size () / myPixelToUnit ); - lstrcpyA ( right,"-*-*-*-*-*-*-*-*-*-*-*-*-" ); - switch ( fontStyle.Style () ) { - - case Aspect_TOF_HELVETICA: - - lstrcatA ( right,"Arial" ); - - break; - - case Aspect_TOF_DEFAULT: - case Aspect_TOF_COURIER: - - lstrcatA ( right, "Courier New" ); - - break; - - case Aspect_TOF_TIMES: - - lstrcatA ( right,"Times New Roman" ); - - break; - - case Aspect_TOF_USERDEFINED: - - lstrcpyA ( left, fontStyle.Value () ); - - if ( strchr ( fontStyle.Value (), '-' ) ) { - - height = atol ( pSize = strtok ( left, "-" ) ); - - if ( height == 0 ) - - height = Standard_Integer ( atof ( pSize ) / myPixelToUnit ); - - if ( height == 0 ) - - height = Standard_Integer ( fontStyle.Size () / myPixelToUnit ); - - pSize = left + lstrlenA ( left ); - *pSize = '-'; - lstrcpyA ( right, pSize ); - - } else lstrcatA ( right,left ); - - } // end switch - - height = Standard_Integer ( height * W32_TextFactor ); - ltoa ( height, left, 10 ); - lstrcatA ( left, right ); - - fmEntry = new WNT_FontMapEntry ( left ); - - if ( fontStyle.CapsHeight () ) { - - double r; - TEXTMETRIC tm; - - SelectFont( (::HDC)myHDC, fmEntry -> HFont () ); - - GetTextMetrics ( (::HDC)myHDCMeta, &tm ); - - r = tm.tmAscent * tm.tmHeight / ( tm.tmAscent - tm.tmInternalLeading ); - lstrcpy ( right, strchr ( left, '-' ) ); - ltoa ( LONG( r + 0.5 ), left, 10 ); - lstrcatA ( left, right ); - - fmEntry = new WNT_FontMapEntry ( left ); - - } // end if - - myFonts -> SetValue ( i, fmEntry ); - - } // end for - - SelectFont( (::HDC)myHDC, hfo ); -} - -//===================================================================== -void WNT_DDriver::InitializeMarkMap(const Handle(Aspect_MarkMap)& aMarkMap) -{ - Aspect_MarkMapEntry entry; - Standard_Integer i, minindex = IntegerLast(), maxindex = -minindex; - for (i = 1; i <= aMarkMap->Size (); i++) { - entry = aMarkMap->Entry (i); - maxindex = Max(maxindex, entry.Index ()); - minindex = Min(minindex, entry.Index ()); - } - - myMarkerIdxs = new TColStd_HArray1OfInteger (minindex, maxindex, -1); - for (i = 1; i <= aMarkMap->Size (); i++) { - entry = aMarkMap->Entry (i); - myMarkerIdxs -> SetValue (entry.Index(), i); - } -} - -//===================================================================== -void WNT_DDriver::WorkSpace(Quantity_Length& Width, - Quantity_Length& Heigth) const -{ - Width = U ( ((PRECT)myRect) -> right ); - Heigth = U ( ((PRECT)myRect) -> bottom); - - if ( myFlags & FLAG_ROTATE ) { - Quantity_Length tlen; - tlen = Heigth; - Heigth = Width; - Width = tlen; - } // end if -} - -//===================================================================== -Quantity_Length WNT_DDriver::Convert(const Standard_Integer PV) const -{ - return U( PV ); -} - -//===================================================================== -Standard_Integer WNT_DDriver::Convert(const Quantity_Length DV) const -{ - return P( DV ); -} - -//===================================================================== -void WNT_DDriver::Convert(const Standard_Integer PX, - const Standard_Integer PY, - Quantity_Length& DX, - Quantity_Length& DY) const -{ - DX = U( PX ); - DY = U( ((PRECT)myRect)->bottom - PY ); -} - -//===================================================================== -void WNT_DDriver::Convert(const Quantity_Length DX, - const Quantity_Length DY, - Standard_Integer& PX, - Standard_Integer& PY) const -{ - PX = P( DX ); - PY = P( DY ); -} - -//===================================================================== -void WNT_DDriver::TextSize(const TCollection_ExtendedString& aText, - Standard_ShortReal& aWidth, - Standard_ShortReal& aHeight, - const Standard_Integer aFontIndex) const -{ -#ifdef PRO17381 - if (aText.Length() <= 0) { - aWidth = aHeight = 0.; - return; - } -#endif - -#ifdef MFT - if ( UseMFT() ) { - Standard_ShortReal xoffset, yoffset; - TextSize (aText, aWidth, aHeight, xoffset, yoffset, aFontIndex); - } else { -#endif - char* str = _ConvertU2F ( aText ); - TextSize ( str, aWidth, aHeight, aFontIndex ); - HeapFree ( GetProcessHeap (), 0, str ); -#ifdef MFT - } -#endif -} - -//===================================================================== -void WNT_DDriver::TextSize(const TCollection_ExtendedString& aText, - Standard_ShortReal& aWidth, - Standard_ShortReal& aHeight, - Standard_ShortReal& anXoffset, - Standard_ShortReal& anYoffset, - const Standard_Integer aFontIndex) const -{ -#ifdef PRO17381 - if (aText.Length() <= 0) { - aWidth = aHeight = 0.; - return; - } -#endif - -#ifdef MFT - if ( UseMFT() ) { - Standard_Integer aFont = (aFontIndex < 0 ? - (int)A->myTextFont : aFontIndex); - Handle(MFT_FontManager) theFontManager = - ((WNT_DDriver *const)(this))->MFT_Font(aFont); - Standard_Real theWidth = 0.,theAscent = 0., - theLbearing = 0.,theDescent = 0.; - if (aText.IsAscii()) { - TCollection_AsciiString ascii (aText,'?'); - theFontManager->TextSize(ascii.ToCString(), theWidth, - theAscent, theLbearing, theDescent); - } else if (theFontManager->IsComposite()) { - theFontManager->TextSize(aText.ToExtString(), theWidth, - theAscent, theLbearing, theDescent); - } - theDescent = Max( - theDescent, (A->myFlags & W32F_TULIN ? - theFontManager->UnderlinePosition() : 0.)); - aWidth = Standard_ShortReal (theWidth ); - aHeight = Standard_ShortReal (theAscent + theDescent); - anXoffset = Standard_ShortReal (theLbearing ); - anYoffset = Standard_ShortReal (theDescent ); - } else { -#endif - char* str = ( char* )_ConvertU2F ( aText ); - HFONT hfo; - SIZE sz; - TEXTMETRIC tm; - int len; - double tanVal = tan ( A -> myTextSlant ); - hfo = SelectFont( - (::HDC)myHDC, - aFontIndex < 0 ? A -> myTextFont : ( HFONT )myFonts -> Value ( aFontIndex ) -> HFont () - ); - GetTextExtentPoint32A ( - (::HDC)myHDC, str, len = lstrlenA ( str ), &sz - ); - GetTextMetrics ( (::HDC)myHDC, &tm ); - sz.cy -= tm.tmInternalLeading; - aWidth = Standard_ShortReal ( U( sz.cx * A -> myTextHScale ) ); - aHeight = Standard_ShortReal ( U( sz.cy * A -> myTextVScale ) ); - aWidth += Standard_ShortReal ( tanVal * aHeight ); - anXoffset = Standard_ShortReal ( 0.0 ); - anYoffset = Standard_ShortReal ( 0.0 ); - SelectFont( (::HDC)myHDC, hfo ); - HeapFree ( GetProcessHeap (), 0, str ); -#ifdef MFT - } -#endif -} - -//===================================================================== -void WNT_DDriver::TextSize(const Standard_CString aText, - Standard_ShortReal& aWidth, - Standard_ShortReal& aHeight, - Standard_ShortReal& anXoffset, - Standard_ShortReal& anYoffset, - const Standard_Integer aFontIndex) const -{ -#ifdef PRO17381 - if (!aText || (strlen(aText) <= 0)) { - aWidth = aHeight = anXoffset = anYoffset = 0.; - return; - } -#endif - -#ifdef MFT - if ( UseMFT() ) { - TCollection_ExtendedString extText (aText); - TextSize (extText, aWidth, aHeight, anXoffset, anYoffset, aFontIndex); - } else { -#endif - HFONT hfo; - SIZE sz; - hfo = SelectFont( - (::HDC)myHDC, - aFontIndex < 0 ? A -> myTextFont : ( HFONT )myFonts -> Value ( aFontIndex ) -> HFont () - ); - GetTextExtentPoint32A ( - (::HDC)myHDC, aText, lstrlenA ( aText ), &sz - ); - aWidth = Standard_ShortReal ( U( sz.cx ) * A -> myTextHScale ); - aHeight = Standard_ShortReal ( U( sz.cy ) * A -> myTextVScale ); - aWidth = Standard_ShortReal ( aWidth + tan ( A -> myTextSlant ) * aHeight ); - SelectFont( (::HDC)myHDC, hfo ); -#ifdef MFT - } -#endif -} - -//===================================================================== -Aspect_Handle WNT_DDriver::HDC() const -{ - return myHDCMeta; -} - -//===================================================================== -void WNT_DDriver::ClientRect(Standard_Integer& aWidth, - Standard_Integer& aHeigth) const -{ - aWidth = ( ( PRECT )myRect ) -> right; - aHeigth = ( ( PRECT )myRect ) -> bottom; -} - -//===================================================================== -Handle(WNT_GraphicDevice) WNT_DDriver::GraphicDevice() const -{ - return myDevice; -} - -//===================================================================== -static BOOL IsWindows95 () { - OSVERSIONINFO os; - os.dwOSVersionInfoSize = sizeof ( OSVERSIONINFO ); - GetVersionEx (&os); - return (os.dwPlatformId == VER_PLATFORM_WIN32_WINDOWS); -} - -//===================================================================== -Handle(TColStd_HSequenceOfAsciiString) WNT_DDriver::DeviceList() -{ - char buff[ MAX_PATH ]; - DWORD dwLen, dwLenRet; - TCollection_AsciiString dev, defDev; - Handle( TColStd_HSequenceOfAsciiString ) retVal = - new TColStd_HSequenceOfAsciiString (); - buff[ dwLen = - GetProfileString ( "Windows", "Device", ",,,", buff, MAX_PATH ) ] = '\x00'; - defDev = TCollection_AsciiString ( buff ); - defDev = defDev.Token ( ",", 1 ); - dwLen = 0; - if (IsWindows95()) { - ///////////////////////// W95 //////////////////////////// - PRINTER_INFO_5* ppi = NULL; - if (!EnumPrinters ( - PRINTER_ENUM_LOCAL, - NULL, 5, NULL, 0, &dwLen, &dwLenRet - )) - { - if (GetLastError () == ERROR_INSUFFICIENT_BUFFER) - { - ppi = ( PRINTER_INFO_5* )HeapAlloc ( GetProcessHeap (), HEAP_GENERATE_EXCEPTIONS, dwLen ); - EnumPrinters ( - PRINTER_ENUM_LOCAL, - NULL, 5, ( LPBYTE )ppi, dwLen, &dwLen, &dwLenRet - ); - } else { - wsprintf ( buff, "W95_DDriver::Could not obtain device list (%d)", GetLastError () ); -// Aspect_DriverError :: Raise ( buff ); - dwLenRet = 0; - } // end else - } - for (dwLen = 0; dwLen < dwLenRet; ++ dwLen) { - dev = TCollection_AsciiString ( ppi[ dwLen ].pPrinterName ); - if ( dev.IsEqual (defDev) ) - retVal -> Prepend ( dev ); - else - retVal -> Append ( dev ); - } // end for -// retVal -> Append (TCollection_AsciiString ( "DISPLAY" )); - if (ppi != NULL) - HeapFree ( GetProcessHeap (), 0, ( LPVOID )ppi ); - } else { - ///////////////////////// WNT //////////////////////////// - PRINTER_INFO_4* ppi = NULL; - if (!EnumPrinters ( - PRINTER_ENUM_LOCAL | PRINTER_ENUM_CONNECTIONS, - NULL, 4, NULL, 0, &dwLen, &dwLenRet - )) - { - if (GetLastError () == ERROR_INSUFFICIENT_BUFFER) - { - ppi = ( PRINTER_INFO_4* )HeapAlloc ( GetProcessHeap (), HEAP_GENERATE_EXCEPTIONS, dwLen ); - EnumPrinters ( - PRINTER_ENUM_LOCAL | PRINTER_ENUM_CONNECTIONS, - NULL, 4, ( LPBYTE )ppi, dwLen, &dwLen, &dwLenRet - ); - } else { - wsprintf ( buff, "WNT_DDriver::Could not obtain device list (%d)", GetLastError () ); -// Aspect_DriverError :: Raise ( buff ); - dwLenRet = 0; - } // end else - } - for (dwLen = 0; dwLen < dwLenRet; ++ dwLen) { - dev = TCollection_AsciiString ( ppi[ dwLen ].pPrinterName ); - if ( dev.IsEqual (defDev) ) - retVal -> Prepend ( dev ); - else - retVal -> Append ( dev ); - } // end for -// retVal -> Append (TCollection_AsciiString ( "DISPLAY" )); - if (ppi != NULL) - HeapFree ( GetProcessHeap (), 0, ( LPVOID )ppi ); - } // WINNT - return retVal; -} - -//===================================================================== -void WNT_DDriver::DeviceSize(const TCollection_AsciiString& aDevice, - Standard_Real& aWidth, - Standard_Real& aHeight) -{ - ::HDC hdc; - aWidth = aHeight = 0.0; - - if (!lstrcmpi (aDevice.ToCString(), "DISPLAY")) - hdc = CreateDC ("DISPLAY", NULL, NULL, NULL); - else - hdc = CreateDC ("WINSPOOL", aDevice.ToCString(), NULL, NULL); - if (hdc != NULL) { - aWidth = ((Standard_Real)_dd_dev_size (hdc, HORZSIZE) / 10.); - aHeight = ((Standard_Real)_dd_dev_size (hdc, VERTSIZE) / 10.); - DeleteDC (hdc); - } -} - -//===================================================================== -Standard_Real WNT_DDriver :: EMFDim ( - Standard_Integer& aWidth, - Standard_Integer& aHeight, - Standard_Integer& aSwap - ) { - - ENHMETAHEADER emh; - Standard_Real retVal = -1.0; - - aWidth = aHeight = -1; - aSwap = 2; - - if ( myHMetaFile == NULL ) { - - TCollection_AsciiString fName; - - if ( ( myHMetaFile = GetEnhMetaFile ( myFileName.ToCString () ) ) == NULL ) - - goto ret; - - } // end if - - if ( GetEnhMetaFileHeader ( - ( HENHMETAFILE )myHMetaFile, sizeof ( ENHMETAHEADER ), &emh - ) == 0 - ) goto ret; - - aWidth = emh.rclFrame.right - emh.rclFrame.left; - aHeight = emh.rclFrame.bottom - emh.rclFrame.top; - - retVal = Standard_Real ( aWidth ) / Standard_Real ( aHeight ); - - { // begin block - - ::HDC hdc = GetDC ( NULL ); - DWORD d ='U'; - RECT r = { 0, 0, GetDeviceCaps ( hdc, HORZRES ), GetDeviceCaps ( hdc, VERTRES ) }; - - EnumEnhMetaFile ( - hdc, ( HENHMETAFILE )myHMetaFile, &_dd_enum_proc, &d, &r - ); - - switch ( d ) { - - case 'T': - - aSwap = 1; - - break; - - case 'F': - - aSwap = 0; - - break; - - } // end switch - - ReleaseDC ( NULL, hdc ); - - } // end block -ret: - return retVal; - -} // end WNT_DDriver :: EMFDim - -//===================================================================== -Standard_Integer WNT_DDriver::ProcessColorIndex - (const Standard_Integer ColorIndex) const -{ - if ( ( A -> myFlags & W32F_MONO ) && - ( !( A -> myFlags & W32F_MINIT ) || ColorIndex <= 0 ) - ) - return A -> myPointColor; - if ( myColors.IsNull () ) - return ( Standard_Integer )RGB( 0, 0, 0 ); - if (ColorIndex <= 0) { - LOGBRUSH lb; - GetObject ( GetStockObject ( NULL_BRUSH ), sizeof ( LOGBRUSH ), &lb ); - return lb.lbColor; - } else { - if (myFlags & FLAG_BANDW) - return 0; - if (ColorIndex < myColors->Lower() || ColorIndex > myColors->Upper()) - return myColors -> Value ( myColors->Lower() ); - return myColors -> Value ( ColorIndex ); - } -} - -//===================================================================== -Quantity_Length WNT_DDriver::ProcessWidthIndex - (const Standard_Integer WidthIndex) const -{ - Standard_Integer theIndex = WidthIndex; - if (WidthIndex < myWidthIdxs->Lower() || WidthIndex > myWidthIdxs->Upper()) - theIndex = myWidthIdxs->Lower(); - - Aspect_WidthMapEntry Entry = WidthMap () -> Entry ( myWidthIdxs -> Value(theIndex) ); - return ( Entry.Type () == Aspect_WOL_THIN ) ? - ( Quantity_Length )0.0 : Entry.Width () / myPixelToUnit; -} - -//===================================================================== -Standard_Integer WNT_DDriver::ProcessTypeIndex - (const Standard_Integer TypeIndex) const -{ - return (TypeMap()->Entry(TypeIndex+1).Type().Style() == Aspect_TOL_SOLID) ? - 0 : PS_USERSTYLE; -} - -//===================================================================== -const Handle(WNT_TextManager)& WNT_DDriver :: TextManager () -{ - return (myNTextManager); -} - -//===================================================================== -const Handle(MFT_FontManager)& WNT_DDriver :: MFT_Font - (const Standard_Integer anIndex) -{ - return myMFTFonts->Value(anIndex); -} - -//===================================================================== -Standard_ShortReal WNT_DDriver :: MFT_Size - (const Standard_Integer anIndex) -{ - return myMFTSizes->Value(anIndex); -} - -//===================================================================== -//===================================================================== -//===================================================================== -static void WINAPI _SetPoint ( int s, int m, int set, LPPOINT p, int* n, void* param ) { - - PMPARAM pmp = ( PMPARAM )param; - - *n = 0; - - for ( int i = 0; i < m; ++i, ++( *n ), ++s ) { - - p[ i ].x = LONG ( pmp -> s -> XValues ().Value ( s ) * pmp -> w / 2.0 + 0.5 ); - p[ i ].y = LONG ( pmp -> s -> YValues ().Value ( s ) * pmp -> h / 2.0 + 0.5 ); - - } // end for - -} // end _SetPoint - -static PW32_Allocator __fastcall _FindAllocator ( Standard_Address p, Standard_Integer id ) { - - while ( p != NULL && ( ( PW32_Allocator )p ) -> myID != id ) - - p = ( ( PW32_Allocator )p ) -> myNext; - - return ( PW32_Allocator )p; - -} // end _FindAllocator - -static char* __fastcall _ConvertU2F ( const TCollection_ExtendedString& str ) { - - char* retVal; - Standard_Integer szBuff = ( str.Length () << 2 ); - - retVal = ( char* )HeapAlloc ( - GetProcessHeap (), HEAP_GENERATE_EXCEPTIONS, - szBuff - ); - - while ( !Resource_Unicode :: ConvertUnicodeToFormat ( str, retVal, szBuff ) ) { - - szBuff <<= 1; - retVal = ( char* )HeapReAlloc ( - GetProcessHeap (), HEAP_GENERATE_EXCEPTIONS, - retVal, szBuff - ); - - } // end while - - return retVal; - -} // end _ConvertU2F - -static void __fastcall _dd_fill_buff ( char* buffer ) { - - time_t t; - struct tm* lt; - char* p; - DWORD dwSize = 32; - - lstrcpy ( buffer, "CAS.CADE driver <" ); - - GetUserName ( &buffer[ lstrlen ( buffer ) ], &dwSize ); - - lstrcat ( buffer, "@" ); - - dwSize = 24; - GetComputerName ( &buffer[ lstrlen ( buffer ) ], &dwSize ); - - lstrcat ( buffer, ">" ); - - t = time ( NULL ); - lt = localtime ( &t ); - p = asctime ( lt ); - CopyMemory ( - &buffer[ lstrlen ( buffer ) + 1 ], p, lstrlen ( p ) - 1 - ); - -} // end _dd_fill_buff - -static int __fastcall _dd_dev_size ( HDC hdc, int index ) { - - int retVal = -1; - HWND hwnd = WindowFromDC ( hdc ); - - if ( hwnd != NULL ) { - - HDC hdcDisplay = GetDC ( NULL ); - RECT r; - - GetClientRect ( hwnd, &r ); - - switch ( index ) { - - case HORZRES: - - retVal = r.right; - - break; - - case VERTRES: - - retVal = r.bottom; - - break; - - case HORZSIZE: - - retVal = GetDeviceCaps ( hdcDisplay, HORZSIZE ) * r.right / - GetDeviceCaps ( hdcDisplay, HORZRES ); - - break; - - case VERTSIZE: - - retVal = GetDeviceCaps ( hdcDisplay, VERTSIZE ) * r.bottom / - GetDeviceCaps ( hdcDisplay, VERTRES ); - - break; - - } // end switch - - ReleaseDC ( NULL, hdcDisplay ); - - } else retVal = GetDeviceCaps ( hdc, index ); - - return retVal; - -} // end _dd_dev_size - -static int CALLBACK _dd_enum_proc ( - HDC hDC, - HANDLETABLE FAR* lpHTable, - CONST ENHMETARECORD FAR* lpEMFR, - int nObj, - LPARAM lpData - ) { - - int retVal = 1; - - if ( lpEMFR -> iType == EMR_GDICOMMENT && - lpEMFR -> dParm[ 0 ] == sizeof ( CSF_SIGN ) && - lpEMFR -> dParm[ 1 ] == CSF_SIGNATURE - ) { - - *( ( DWORD* )lpData ) = lpEMFR -> dParm[ 3 ]; - retVal = 0; - - } // end if - - return retVal; - -} // end _dd_enum_proc - -/* -static TCollection_AsciiString _dd_temp_name ( void ) { - - HKEY hKey; - TCHAR tmpPath[ MAX_PATH ]; - BOOL fOK = FALSE; - REG_KEY regKey[ 2 ] = { - - { HKEY_LOCAL_MACHINE, - TEXT( "SYSTEM\\CurrentControlSet\\Control\\Session Manager\\Environment" ) - }, - { HKEY_USERS, - TEXT( ".DEFAULT\\Environment" ) - } - - }; - - for ( int i = 0; i < 2; ++i ) { - - if ( RegOpenKeyEx ( - regKey[ i ].hKey, regKey[ i ].keyPath, 0, KEY_QUERY_VALUE, &hKey - ) == ERROR_SUCCESS - ) { - - DWORD dwType; - DWORD dwSize = 0; - - if ( RegQueryValueEx ( - hKey, TEXT( "TEMP" ), NULL, &dwType, NULL, &dwSize - ) == ERROR_SUCCESS - ) { - - LPTSTR kVal = ( LPTSTR )HeapAlloc ( - GetProcessHeap (), HEAP_ZERO_MEMORY | HEAP_GENERATE_EXCEPTIONS, - dwSize + sizeof ( TCHAR ) - ); - - RegQueryValueEx ( hKey, TEXT( "TEMP" ), NULL, &dwType, ( LPBYTE )kVal, &dwSize ); - - if ( dwType == REG_EXPAND_SZ ) - - ExpandEnvironmentStrings ( kVal, tmpPath, MAX_PATH ); - - else - - lstrcpy ( tmpPath, kVal ); - - HeapFree ( GetProcessHeap (), 0, ( LPVOID )kVal ); - fOK = TRUE; - - } // end if - - RegCloseKey ( hKey ); - - } // end if - - if ( fOK ) break; - - } // end for - - if ( !fOK ) lstrcpy ( tmpPath, TEXT( "./" ) ); - - GetTempFileName ( tmpPath, "CSF", 0, tmpPath ); - - return tmpPath; - -} // end _dd_temp_name -*/ diff --git a/src/WNT/WNT_FontMapEntry.cdl b/src/WNT/WNT_FontMapEntry.cdl deleted file mode 100755 index 89c95ee8d0..0000000000 --- a/src/WNT/WNT_FontMapEntry.cdl +++ /dev/null @@ -1,143 +0,0 @@ --- Created on: 1996-01-29 --- Created by: PLOTNIKOV Eugeny --- Copyright (c) 1996-1999 Matra Datavision --- Copyright (c) 1999-2012 OPEN CASCADE SAS --- --- The content of this file is subject to the Open CASCADE Technology Public --- License Version 6.5 (the "License"). You may not use the content of this file --- except in compliance with the License. Please obtain a copy of the License --- at http://www.opencascade.org and read it completely before using this file. --- --- The Initial Developer of the Original Code is Open CASCADE S.A.S., having its --- main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. --- --- The Original Code and all software distributed under the License is --- distributed on an "AS IS" basis, without warranty of any kind, and the --- Initial Developer hereby disclaims all such warranties, including without --- limitation, any warranties of merchantability, fitness for a particular --- purpose or non-infringement. Please see the License for the specific terms --- and conditions governing the rights and limitations under the License. - - - -class FontMapEntry from WNT inherits TShared from MMgt - - ---Purpose: Defines correspondence between FontMapEntry from - -- Aspect and Windows NT font handle. Also, provides - -- some optimizations due to rotation, italics & underlining - -- of fonts. Each font can be reffered by its name which - -- is a character string. The format of the string takes - -- after format of font name of X window system but there - -- are some differences. The font name string format is: - -- "h-w-e-o-wgt-i-u-so-cs-op-cp-q-pf-face". - -- ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ - -- | | | | | | | | | | | | | | - -- | | | | | | | | | | | | | +- name of the typeface - -- | | | | | | | | | | | | | (Courier, Arial ...) - -- | | | | | | | | | | | | +- pitch and family - -- | | | | | | | | | | | +- quality - -- | | | | | | | | | | +- clip precision - -- | | | | | | | | | +- out precision - -- | | | | | | | | +- character set - -- | | | | | | | +- strike out - -- | | | | | | +- underline - -- | | | | | +- italic - -- | | | | +- weight - -- | | | +- orientation - -- | | +- escapement - -- | +- width - -- +- height - -- Wildcarding is allowed by specifying '*' sign. This means - -- a default value for parameter. - -- Example: "13-8-*-*-400-*-*-*-255-1-2-*-25-courier". - -- For more detail information see Microsoft Windows manual. - -- Warning: Windows can output rotated text only if the selected for - -- drawing font is True Type. - uses - - Handle from Aspect, - LogFont from WNT, - Dword from WNT, - Factor from Quantity, - PlaneAngle from Quantity - - raises - - FontMapEntryDefinitionError from WNT - - is - - Create ( aFontName : CString from Standard ) - returns mutable FontMapEntry from WNT - ---Purpose: Creates a class and loads font. - -- Warning: Windows finds the real font that most closely matches - -- the request. In doing so, it uses a - -- "font-mapping-algorythm". So it is possible that loaded - -- font differs from font in the request. - -- Trigger: Raises if font loading failed. - raises FontMapEntryDefinitionError from WNT; - - Destroy ( me : mutable ) is virtual; - ---Level: Public - ---Purpose: Destroys all ressources attached to the FontMapEntry - ---C++: alias ~ - - HFont ( me ) returns Handle from Aspect; - ---Level: Public - ---Purpose: Returns handle of the font. - - SetAttrib ( - me : mutable; - aFlags : Dword from WNT; - aData : Address from Standard; - aRepl : Boolean from Standard = Standard_False - ) returns Handle from Aspect is static; - ---Level: Internal - ---Purpose: Sets certain attributes ( italics etc. ) for font. - -- Warning: If is True then creates a new handle for font. - -- In this case calling routine MUST DELETE THE FONT ITSELF - -- WHEN THE FONT BECOME NO LONGER NEEDED. - - SetSlant ( me : mutable; aSlant : PlaneAngle from Quantity ) - returns PlaneAngle from Quantity is static; - ---Level: Internal - ---Purpose: Sets the font's slant and returns a previous one. - ---C++: inline - - SetScale ( me : mutable; aScale : Factor from Quantity ) - returns Factor from Quantity is static; - ---Level: Internal - ---Purpose: Sets the font's scale and returns a previous one. - ---C++: inline - - Slant ( me ) - returns PlaneAngle from Quantity is static; - ---Level: Internal - ---Purpose: Returns value of the font's slant. - ---C++: inline - - Scale ( me ) - returns Factor from Quantity is static; - ---Level: Internal - ---Purpose: Returns value of the font's scale. - ---C++: inline - - LogFont ( me ) - returns Address from Standard is static; - ---Level: Internal - ---Purpose: Returns pointer to LogFont structure. - ---C++: inline - - fields - - myLogFont : LogFont from WNT is protected; - myHandle : Handle from Aspect is protected; - myScale : Factor from Quantity is protected; - mySlant : PlaneAngle from Quantity is protected; - - friends - - class WDriver from WNT, - class DDriver from WNT - -end FontMapEntry; diff --git a/src/WNT/WNT_FontMapEntry.cxx b/src/WNT/WNT_FontMapEntry.cxx deleted file mode 100755 index 06430a5a99..0000000000 --- a/src/WNT/WNT_FontMapEntry.cxx +++ /dev/null @@ -1,181 +0,0 @@ -// Copyright (c) 1996-1999 Matra Datavision -// Copyright (c) 1999-2012 OPEN CASCADE SAS -// -// The content of this file is subject to the Open CASCADE Technology Public -// License Version 6.5 (the "License"). You may not use the content of this file -// except in compliance with the License. Please obtain a copy of the License -// at http://www.opencascade.org and read it completely before using this file. -// -// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its -// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. -// -// The Original Code and all software distributed under the License is -// distributed on an "AS IS" basis, without warranty of any kind, and the -// Initial Developer hereby disclaims all such warranties, including without -// limitation, any warranties of merchantability, fitness for a particular -// purpose or non-infringement. Please see the License for the specific terms -// and conditions governing the rights and limitations under the License. - -#include - -#include - -#include -#include - -// character for field separator -#define FS "-" -// character for default value -#define DV "*" - -WNT_FontMapEntry :: WNT_FontMapEntry ( const Standard_CString aFontName ) -{ - Standard_Size i; - char* p; - - char* fName = new char[ strlen ( aFontName ) + 1 ]; - - strcpy ( fName, aFontName ); - ZeroMemory ( &myLogFont, sizeof ( WNT_LogFont ) ); - - myLogFont.lfCharSet = DEFAULT_CHARSET; - myLogFont.lfOutPrecision = OUT_DEFAULT_PRECIS; - myLogFont.lfClipPrecision = CLIP_DEFAULT_PRECIS; - myLogFont.lfPitchAndFamily = DEFAULT_PITCH | FF_DONTCARE; - myLogFont.lfQuality = PROOF_QUALITY; - - p = strtok ( fName, FS ); - if ( p && strcmp ( p, DV ) ) - myLogFont.lfHeight = atol ( p ); - - p = strtok ( NULL, FS ); - if ( p && strcmp ( p, DV ) ) - myLogFont.lfWidth = atol ( p ); - - p = strtok ( NULL, FS ); - if ( p && strcmp ( p, DV ) ) - myLogFont.lfEscapement = atol ( p ); - - p = strtok ( NULL, FS ); - if ( p && strcmp ( p, DV ) ) - myLogFont.lfOrientation = atol ( p ); - - p = strtok ( NULL, FS ); - if ( p && strcmp ( p, DV ) ) - myLogFont.lfWeight = atol ( p ); - - p = strtok ( NULL, FS ); - if ( p && strcmp ( p, DV ) ) - myLogFont.lfItalic = ( BYTE )atoi ( p ); - - p = strtok ( NULL, FS ); - if ( p && strcmp ( p, DV ) ) - myLogFont.lfUnderline = ( BYTE )atoi ( p ); - - p = strtok ( NULL, FS ); - if ( p && strcmp ( p, DV ) ) - myLogFont.lfStrikeOut = ( BYTE )atoi ( p ); - - p = strtok ( NULL, FS ); - if ( p && strcmp ( p, DV ) ) - myLogFont.lfCharSet = ( BYTE )atoi ( p ); - - p = strtok ( NULL, FS ); - if ( p && strcmp ( p, DV ) ) - myLogFont.lfOutPrecision = ( BYTE )atoi ( p ); - - p = strtok ( NULL, FS ); - if ( p && strcmp ( p, DV ) ) - myLogFont.lfClipPrecision = ( BYTE )atoi ( p ); - - p = strtok ( NULL, FS ); - if ( p && strcmp ( p, DV ) ) - myLogFont.lfQuality = ( BYTE )atoi ( p ); - - p = strtok ( NULL, FS ); - if ( p && strcmp ( p, DV ) ) - myLogFont.lfPitchAndFamily = ( BYTE )atoi ( p ); - - p = strtok ( NULL, FS ); - if ( p && strcmp ( p, DV ) ) { - i = strlen ( p ); - strncpy ( myLogFont.lfFaceName, p, ( i < LF_FACESIZE ) ? i : LF_FACESIZE ); - } // end if - - myLogFont.lfOutPrecision |= OUT_TT_ONLY_PRECIS; - myHandle = CreateFontIndirect ( &myLogFont ); - delete [] fName; - if ( !myHandle ) - WNT_FontMapEntryDefinitionError :: Raise ( "Unable to load font" ); -} // end constructor - -void WNT_FontMapEntry :: Destroy () { - - DeleteObject ( myHandle ); - -} // end WNT_FontMapEntry :: Destroy - -Aspect_Handle WNT_FontMapEntry :: HFont () const { - - return myHandle; - -} // WNT_FontMapEntry :: HFont - -Aspect_Handle WNT_FontMapEntry :: SetAttrib ( - const WNT_Dword& aFlags, - const Standard_Address aData, - const Standard_Boolean aRepl - ) { - - HFONT hFont; - LOGFONT lf = myLogFont; - FONT_DATA* fd = ( FONT_DATA* )aData; - - if ( aFlags & faUnderlined ) - - lf.lfUnderline = fd -> fdUnderlined; - - if ( aFlags & faItalic ) - - lf.lfItalic = fd -> fdItalic; - - if ( aFlags & faStrikeOut ) - - lf.lfStrikeOut = fd -> fdStrikeOut; - - if ( aFlags & faBold ) - - lf.lfWeight = fd -> fdBold; - - if ( aFlags & faHeight ) - - lf.lfHeight = fd -> fdHeight; - - if ( aFlags & faAngle ) { - - lf.lfEscapement = fd -> fdOrientation; - lf.lfOrientation = fd -> fdOrientation; - - } // end if - - if ( aFlags & faWidth ) - - lf.lfWidth = fd -> fdWidth; - - if ( aFlags & faSlant ) - - lf.lfOrientation -= ( fd -> fdSlant * 10 ); - - hFont = CreateFontIndirect ( &lf ); - - if ( hFont != NULL && aRepl ) { - - DeleteObject ( myHandle ); - myHandle = hFont; - myLogFont = lf; - - } // end if - - return hFont; - -} // WNT_FontMapEntry :: SetAttrib diff --git a/src/WNT/WNT_FontMapEntry.lxx b/src/WNT/WNT_FontMapEntry.lxx deleted file mode 100755 index 4b11835a90..0000000000 --- a/src/WNT/WNT_FontMapEntry.lxx +++ /dev/null @@ -1,58 +0,0 @@ -// Copyright (c) 1996-1999 Matra Datavision -// Copyright (c) 1999-2012 OPEN CASCADE SAS -// -// The content of this file is subject to the Open CASCADE Technology Public -// License Version 6.5 (the "License"). You may not use the content of this file -// except in compliance with the License. Please obtain a copy of the License -// at http://www.opencascade.org and read it completely before using this file. -// -// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its -// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. -// -// The Original Code and all software distributed under the License is -// distributed on an "AS IS" basis, without warranty of any kind, and the -// Initial Developer hereby disclaims all such warranties, including without -// limitation, any warranties of merchantability, fitness for a particular -// purpose or non-infringement. Please see the License for the specific terms -// and conditions governing the rights and limitations under the License. - -inline Quantity_PlaneAngle WNT_FontMapEntry :: SetSlant ( - const Quantity_PlaneAngle aSlant - ) { - Quantity_PlaneAngle tmp = mySlant; - - mySlant = aSlant; - - return tmp; - -} // end WNT_FontMapEntry :: SetSlant - -inline Quantity_Factor WNT_FontMapEntry :: SetScale ( - const Quantity_Factor aScale - ) { - - Quantity_Factor tmp = myScale; - - myScale = aScale; - - return tmp; - -} // end WNT_FontMapEntry :: SetScale - -inline Quantity_PlaneAngle WNT_FontMapEntry :: Slant () const { - - return mySlant; - -} // end WNT_FontMapEntry :: Slant - -inline Quantity_Factor WNT_FontMapEntry :: Scale () const { - - return myScale; - -} // end WNT_FontMapEntry :: Scale - -inline Standard_Address WNT_FontMapEntry :: LogFont () const { - - return ( void* )&myLogFont; - -} // end WNT_FontMapEntry :: LogFont diff --git a/src/WNT/WNT_ImageManager.cdl b/src/WNT/WNT_ImageManager.cdl index cb7c9676a2..bc72fc3f6b 100755 --- a/src/WNT/WNT_ImageManager.cdl +++ b/src/WNT/WNT_ImageManager.cdl @@ -173,7 +173,6 @@ class ImageManager from WNT inherits TShared from MMgt friends - class WDriver from WNT, class Window from WNT end ImageManager; diff --git a/src/WNT/WNT_MFTDraw.cxx b/src/WNT/WNT_MFTDraw.cxx deleted file mode 100755 index 19357ffe1e..0000000000 --- a/src/WNT/WNT_MFTDraw.cxx +++ /dev/null @@ -1,242 +0,0 @@ -// Created by: CHABROVSKY Dmitry -// Copyright (c) 1998-1999 Matra Datavision -// Copyright (c) 1999-2012 OPEN CASCADE SAS -// -// The content of this file is subject to the Open CASCADE Technology Public -// License Version 6.5 (the "License"). You may not use the content of this file -// except in compliance with the License. Please obtain a copy of the License -// at http://www.opencascade.org and read it completely before using this file. -// -// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its -// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. -// -// The Original Code and all software distributed under the License is -// distributed on an "AS IS" basis, without warranty of any kind, and the -// Initial Developer hereby disclaims all such warranties, including without -// limitation, any warranties of merchantability, fitness for a particular -// purpose or non-infringement. Please see the License for the specific terms -// and conditions governing the rights and limitations under the License. - - -#define MFT // Study S3553 - -#ifdef MFT - -#define STRICT -#include -#include -#include "WNT_MFTDraw.hxx" -#include "W32_Allocator.hxx" -#include "W95_Allocator.hxx" -#include "WNT_Allocator.hxx" -#include -#include -#include - -#ifdef DrawText -# undef DrawText -#endif // DrawText - -#include -#include - -#define ROUNDL( d ) ( ( long )( ( d ) + ( ( d ) > 0 ? 0.5 : -0.5 ) ) ) -#define TRANSFORM(i,X,Y,f95) \ - { \ - Standard_Real x = (X),y = (Y); \ - pts[(i)].x = P( ROUNDL((double)myPT.x + x*Ca - y*Sa) );\ - if (f95) pts[(i)].y = sz.cy - P( ROUNDL((double)myPT.y + x*Sa + y*Ca) );\ - else pts[(i)].y = P( ROUNDL((double)myPT.y + x*Sa + y*Ca) );\ - } -#define SET_DRAW_DATA(aData,aDC,aSZ) \ - { aData.theHDC = aDC; \ - aData.theDevWidth = aSZ.cx; \ - aData.theDevHeight = aSZ.cy; } - -void __cdecl _Do_MFTDrawText_ (PW32_FCALLPARAM lpParam) -{ - // Declare all needed variables - PMFT_DRAWTEXT lpDraw = (PMFT_DRAWTEXT) lpParam; - PW32_Allocator lpW32 = (PW32_Allocator) lpDraw->theParam.pAllocator; - WNT_WDriver* lpWDrv = (WNT_WDriver*) lpDraw->theParam.pDriver; - WNT_DDriver* lpDDrv = (WNT_DDriver*) lpDraw->theParam.pDriver; - int aFont = (int)lpW32->myTextFont; - double myPixelToUnit = lpDraw->theP2U; - XFORM xf; - HDC MY_HDC; - HPEN hTextPen, hOldPen, hPolyPen; - HBRUSH hTextBrush, hOldBrush, hPolyBrush; - float Ca = (float)Cos(lpW32->myAngle), - Sa = (float)Sin(lpW32->myAngle); - SIZE sz; - // Starting point to draw - POINT myPT = { - ROUNDL( - float( - Ca*lpW32->myScaleX * (lpDraw->theXPos - float( U(lpW32->myPivot.x)) ) - - Sa*lpW32->myScaleY * (lpDraw->theYPos - float( U(lpW32->myPivot.y)) ) + - float( U( (lpW32->myPivot.x + lpW32->myMove.x) ) ) - ) - ), - ROUNDL( - float( - Sa*lpW32->myScaleX * (lpDraw->theXPos - float( U(lpW32->myPivot.x)) ) + - Ca*lpW32->myScaleY * (lpDraw->theYPos - float( U(lpW32->myPivot.y)) ) + - float( U( (lpW32->myPivot.y + lpW32->myMove.y) ) ) - ) - ) - }; - double uPos; - Handle(WNT_TextManager) theTextManager; - Handle(MFT_FontManager) theFontManager; - Standard_ShortReal theTextSize; - //============ Use driver to get some data ============ - if (lpW32->myFlags & W32F_DVDRV) { -// theTextManager = lpDDrv->TextManager (); -// theFontManager = lpDDrv->MFT_Font (aFont); -// theTextSize = lpDDrv->MFT_Size (aFont); - } else { - theTextManager = lpWDrv->TextManager (); - theFontManager = lpWDrv->MFT_Font (aFont); - theTextSize = lpWDrv->MFT_Size (aFont); - } - //============== Set FontManager and TextManager attributes ============= - theFontManager->SetFontAttribs ( - Abs(theTextSize)*lpW32->myTextHScale*lpW32->myScaleX, - Abs(theTextSize)*lpW32->myTextVScale*lpW32->myScaleY, - lpW32->myTextSlant, 0., - ((theTextSize > 0.) ? Standard_False : Standard_True) - ); - uPos = (lpW32->myFlags & W32F_TULIN ? - theFontManager->UnderlinePosition() : 0.); - theTextManager->SetTextAttribs ( - 0, Aspect_TypeOfText(lpDraw->theTextType), uPos - ); - //=============== Calculate UpdateRect ================ - Ca = (float)Cos(lpDraw->theAngle + lpW32->myAngle); - Sa = (float)Sin(lpDraw->theAngle + lpW32->myAngle); - Standard_ShortReal theHeight, theWidth, theXoffset, theYoffset; - if (lpW32->myFlags & W32F_DVDRV) { - if (!lpDraw->isTextWide) - lpDDrv->TextSize ((char*)lpDraw->theText, theWidth, theHeight, theXoffset, - theYoffset, aFont); - else - lpDDrv->TextSize ((short*)lpDraw->theText, theWidth, theHeight, theXoffset, - theYoffset, aFont); - } else { - if (!lpDraw->isTextWide) - lpWDrv->TextSize ((char*)lpDraw->theText, theWidth, theHeight, theXoffset, - theYoffset, aFont); - else - lpWDrv->TextSize ((short*)lpDraw->theText, theWidth, theHeight, theXoffset, - theYoffset, aFont); - } - //================= Get some attributes =============== - int uWidth = P(theHeight/32.); - MFT_TEXTMAN_DATA aData = { 0, TRUE, 0, 0, uWidth, lpW32->myFlags & W32F_MONO }; - if (lpW32->myFlags & W32F_WIN95) { - // Get necessary attributes from WIN95 Allocator - PW95_Allocator lpW95 = (PW95_Allocator)lpW32; - lpW95->myHDC.Extent(&sz); - MY_HDC = lpW95->myHDC.Hdc (); - SET_DRAW_DATA (aData, MY_HDC, sz); - theTextManager->SetDrawAttribs ( (Standard_Address)&aData ); - hTextPen = CreatePen ( PS_SOLID, 1, lpW95->myTextColor ); - hTextBrush = CreateSolidBrush ( lpW95->myTextColor ); - hPolyPen = ((lpW32->myFlags & W32F_POUTL) ? - CreatePen (PS_SOLID, lpW95->myLinePenWidth, - lpW95->myLineBrush.lbColor): - (HPEN) GetStockObject (NULL_PEN)); - hPolyBrush = ((lpW32->myFlags & W32F_NOFIL) ? - (HBRUSH) GetStockObject (NULL_BRUSH): - CreateBrushIndirect (&lpW95->myPolyBrush)); - } else { - // Get necessary attributes from WINNT Allocator - PWNT_Allocator lpWNT = (PWNT_Allocator)lpW32; - lpWNT->GetExtent(&sz); - MY_HDC = lpWNT->myHDC; - aData.theWin95 = FALSE; - SET_DRAW_DATA (aData, MY_HDC, sz); - theTextManager->SetDrawAttribs ( (Standard_Address)&aData ); - GetWorldTransform ( MY_HDC, &xf ); - ModifyWorldTransform ( MY_HDC, NULL, MWT_IDENTITY ); - hTextPen = lpWNT->myTextPen; - hTextBrush = lpWNT->myTextBrush; - hPolyPen = ((lpW32->myFlags & W32F_POUTL) ? - lpWNT->myLinePen : - (HPEN) GetStockObject (NULL_PEN) ); - hPolyBrush = ((lpW32->myFlags & W32F_NOFIL) ? - (HBRUSH) GetStockObject (NULL_BRUSH): - lpWNT->myPolyBrush); - } - //////////////////////////////////////////////////////// - Standard_ShortReal marge = - Standard_ShortReal(theHeight * lpDraw->theMargin); - theWidth += 2.F*marge; theHeight += 2.F*marge; - theXoffset -= marge; theYoffset += marge; - //////////////////////////////////////////////////////// - BOOL fWin95 = lpW32->myFlags & W32F_WIN95; - POINT pts[4]; - TRANSFORM (0, theXoffset, - theYoffset, fWin95); - TRANSFORM (1, theXoffset + theWidth, - theYoffset, fWin95); - TRANSFORM (2, theXoffset + theWidth, theHeight - theYoffset, fWin95); - TRANSFORM (3, theXoffset, theHeight - theYoffset, fWin95); - //============ Draw POLYGON around the text =========== - if (lpDraw->isTextPoly) { - hOldPen = SelectPen (MY_HDC, hPolyPen ); - hOldBrush = SelectBrush (MY_HDC, hPolyBrush); - Polygon (MY_HDC, pts, 4); - SelectBrush (MY_HDC, hOldBrush); - SelectPen (MY_HDC, hOldPen ); - } - //================= Draw text itself ================== - hOldPen = SelectPen (MY_HDC, hTextPen); - hOldBrush = SelectBrush (MY_HDC, hTextBrush); - if (lpDraw->isTextWide) { - theFontManager->DrawText ( - theTextManager, (short*)lpDraw->theText, - myPT.x, myPT.y, (lpDraw->theAngle + lpW32->myAngle) - ); - } else { - theFontManager->DrawText ( - theTextManager, (char*)lpDraw->theText, - myPT.x, myPT.y, (lpDraw->theAngle + lpW32->myAngle) - ); - } - SelectBrush (MY_HDC, hOldBrush); - SelectPen (MY_HDC, hOldPen ); - //========= Register points as an UpdatedRect ========= - if (lpW32->myFlags & W32F_WIN95) { - PW95_Allocator lpW95 = (PW95_Allocator)lpW32; - lpW95->myHDC.Register ( pts, 4 ); - DeletePen ( hTextPen ); - DeleteBrush ( hTextBrush ); - DeletePen ( hPolyPen ); - DeleteBrush ( hPolyBrush ); - } else { - PWNT_Allocator lpWNT = (PWNT_Allocator)lpW32; - lpWNT->Register ( pts, 4 ); - SetWorldTransform ( MY_HDC, &xf ); - } - //===================================================== -/* - TCollection_ExtendedString extText; - if (lpDraw->isTextWide) { - extText = TCollection_ExtendedString((short*)lpDraw->theText); - } else { - extText = TCollection_AsciiString ((char*) lpDraw->theText); - } - cout << "DRAW_TEXT: " << (int)lpW32->myTextFont << ", " - << lpDraw->theXPos << ", " << lpDraw->theYPos << "), A=" - << lpDraw->theAngle << ", M=" << lpDraw->theMargin << ", T=" - << lpDraw->theTextType << "," - << (lpDraw->isTextPoly ? "'Poly'" : "'Simple'") << "," - << (lpDraw->isTextWide ? "'WCHAR'" : "'CHAR'") - << ", L=" << lpDraw->theTextLength << ", ('" << extText - << "'), SZ: " << theTextSize << ", VS=" << lpW32->myTextVScale - << ", HS=" << lpW32->myTextHScale << ", SL=" << lpW32->myTextSlant - << endl << flush; -*/ -} - -#endif // MFT diff --git a/src/WNT/WNT_MFTDraw.hxx b/src/WNT/WNT_MFTDraw.hxx deleted file mode 100755 index 2a57b03edb..0000000000 --- a/src/WNT/WNT_MFTDraw.hxx +++ /dev/null @@ -1,56 +0,0 @@ -// Created by: CHABROVSKY Dmitry -// Copyright (c) 1998-1999 Matra Datavision -// Copyright (c) 1999-2012 OPEN CASCADE SAS -// -// The content of this file is subject to the Open CASCADE Technology Public -// License Version 6.5 (the "License"). You may not use the content of this file -// except in compliance with the License. Please obtain a copy of the License -// at http://www.opencascade.org and read it completely before using this file. -// -// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its -// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. -// -// The Original Code and all software distributed under the License is -// distributed on an "AS IS" basis, without warranty of any kind, and the -// Initial Developer hereby disclaims all such warranties, including without -// limitation, any warranties of merchantability, fitness for a particular -// purpose or non-infringement. Please see the License for the specific terms -// and conditions governing the rights and limitations under the License. - - -#ifdef MFT - -#ifndef _WNT_MFT_DRAW_HEADER_ -#define _WNT_MFT_DRAW_HEADER_ - -#define MAXCHARS 2048 -#include "W32_Allocator.hxx" - -typedef struct _MFT_DRAWTEXT { - W32_FCALLPARAM theParam; - double theP2U; - float theXPos; - float theYPos; - float theAngle; - double theMargin; - int theTextType; - BOOL isTextPoly; - BOOL isTextWide; - int theTextLength; - short theText[MAXCHARS]; -} MFT_DRAWTEXT, *PMFT_DRAWTEXT; - -typedef struct _MFT_TEXTMAN_DATA { - HDC theHDC; - BOOL theWin95; - int theDevWidth; - int theDevHeight; - int theUWidth; - BOOL theMonoBuffer; -} MFT_TEXTMAN_DATA, *PMFT_TEXTMAN_DATA; - -extern void __cdecl _Do_MFTDrawText_ (PW32_FCALLPARAM lpParam); - -#endif // _WNT_MFT_DRAW_HEADER_ - -#endif // MFT diff --git a/src/WNT/WNT_TextManager.cdl b/src/WNT/WNT_TextManager.cdl deleted file mode 100755 index 18c7954eb5..0000000000 --- a/src/WNT/WNT_TextManager.cdl +++ /dev/null @@ -1,135 +0,0 @@ --- Created by: CHABROVSKY Dmitry --- Copyright (c) 1998-1999 Matra Datavision --- Copyright (c) 1999-2012 OPEN CASCADE SAS --- --- The content of this file is subject to the Open CASCADE Technology Public --- License Version 6.5 (the "License"). You may not use the content of this file --- except in compliance with the License. Please obtain a copy of the License --- at http://www.opencascade.org and read it completely before using this file. --- --- The Initial Developer of the Original Code is Open CASCADE S.A.S., having its --- main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. --- --- The Original Code and all software distributed under the License is --- distributed on an "AS IS" basis, without warranty of any kind, and the --- Initial Developer hereby disclaims all such warranties, including without --- limitation, any warranties of merchantability, fitness for a particular --- purpose or non-infringement. Please see the License for the specific terms --- and conditions governing the rights and limitations under the License. - - -class TextManager from WNT inherits TextManager from MFT - -uses - Length from Quantity, - PlaneAngle from Quantity, - TypeOfText from Aspect - -is - ------------------------- - -- Category: Constructors - ------------------------- - Create (aPixelToUnit: Real from Standard) - returns mutable TextManager from WNT; - - ------------------------- - -- Category: Draw methods - ------------------------- - BeginString (me: mutable; - X,Y: Length from Quantity; - anOrientation: PlaneAngle from Quantity; - aWidth,aHeight: Length from Quantity; - aSlant: PlaneAngle from Quantity; - aPaintType: Integer from Standard) - is redefined; - ---Purpose: Calls when string drawing is started. - -- with a string aspect : - -- 0 for filled string - -- 1 for stroke string - -- 2 for outline string - -- The origine of the string ,, - -- The orientation of the string , - -- The medium size of the char , - -- The Slant of the char , - - BeginChar (me: mutable; - aCharCode: Integer from Standard; - X,Y: Length from Quantity) - returns Boolean from Standard is redefined; - ---Purpose: Calls when a char drawing is started - -- and give the current string position for this char. - -- and give the relative char position from the beginning - -- of the string. - -- The application can returns FALSE for skipping the char drawing. - - SetCharBoundingBox (me: mutable; - X1,Y1,X2,Y2,X3,Y3,X4,Y4: Length from Quantity) - returns Boolean from Standard is redefined; - ---Purpose: Calls to defines the current char bounding-box. - -- The application can returns FALSE for ending the char drawing. - - SetCharEncoding (me: mutable; - anEncoding: CString from Standard) - returns Boolean from Standard is redefined; - ---Purpose: Calls to defines the current char encoding. - -- Warning: The application can returns FALSE for skipping the char drawing. - - Moveto (me: mutable; X,Y: Length from Quantity) - returns Boolean from Standard is redefined; - ---Purpose: Calls to sets the current string position. - -- The application can returns FALSE for ending the char drawing. - - Lineto (me: mutable; X,Y: Length from Quantity) - returns Boolean from Standard is redefined; - ---Purpose: Calls to drawn to the current string position. - -- The application can returns FALSE for ending the char drawing. - - Curveto (me: mutable; X1,Y1,X2,Y2,X3,Y3,X4,Y4: Length from Quantity) - returns Boolean from Standard is redefined; - ---Purpose: Calls to drawn to the current string position. - -- The application can drawn the curve defined by - -- his descriptor P1,P2,P3,P4 or - -- returns FALSE to let the interpretor compute the curve - -- vectors. - - ClosePath (me: mutable) - is redefined; - ---Purpose: Calls when a char path drawing is ended - - EndChar (me: mutable; X,Y: Length from Quantity) - returns Boolean from Standard is redefined; - ---Purpose: Calls when a char drawing is ended - -- and give the relative char ending position from the - -- beginning of the string. - -- The application can returns FALSE for skipping the string - -- drawing. - - EndString (me: mutable) - is redefined; - ---Purpose: Calls when string drawing is ended (Normally the last call). - - SetDrawAttribs (me: mutable; aDrawData: Address from Standard); - ---Purpose: Called when starting to draw the string - - ------------------------- - -- Category: Private methods - ------------------------- - SetTextAttribs (me: mutable ; - aTextColor: Integer from Standard; - aTypeOfText: TypeOfText from Aspect; - anUnderlinePosition: Length from Quantity = 0.0); - ---Purpose: Sets the current attribs of the text. - -fields - myPixelToUnit: Real from Standard; - myDevContext: Integer from Standard; - myWin95: Boolean from Standard; - myDevWidth: Integer from Standard; - myDevHeight: Integer from Standard; - myUWidth: Integer from Standard; - myMonoBuf: Integer from Standard; - -friends - class WDriver from WNT - -end TextManager from WNT; diff --git a/src/WNT/WNT_TextManager.cxx b/src/WNT/WNT_TextManager.cxx deleted file mode 100755 index b730cca2ec..0000000000 --- a/src/WNT/WNT_TextManager.cxx +++ /dev/null @@ -1,281 +0,0 @@ -// Created by: CHABROVSKY Dmitry -// Copyright (c) 1998-1999 Matra Datavision -// Copyright (c) 1999-2012 OPEN CASCADE SAS -// -// The content of this file is subject to the Open CASCADE Technology Public -// License Version 6.5 (the "License"). You may not use the content of this file -// except in compliance with the License. Please obtain a copy of the License -// at http://www.opencascade.org and read it completely before using this file. -// -// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its -// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. -// -// The Original Code and all software distributed under the License is -// distributed on an "AS IS" basis, without warranty of any kind, and the -// Initial Developer hereby disclaims all such warranties, including without -// limitation, any warranties of merchantability, fitness for a particular -// purpose or non-infringement. Please see the License for the specific terms -// and conditions governing the rights and limitations under the License. - - -// include windows.h first to have all definitions available -#include - -#define MFT - -#include -#include -#include - -#define CHAR_DESC_LEN 30000 -#define MY_HDC (HDC)myDevContext -#define U2P(v) LONG( (v)/myPixelToUnit + 0.5 ) -#define TRANSFORM(X,Y) \ -{ Standard_Real x = X,y = Y; \ - X = Standard_ShortReal(x*theCosAngle - y*theSinAngle); \ - Y = Standard_ShortReal(x*theSinAngle + y*theCosAngle); \ - } - -enum TypeOfPoint { - TOP_MOVETO, TOP_LINETO, TOP_CURVETO -}; - -static Standard_Integer thePaintType; -static Standard_Integer theTextColor; -static Aspect_TypeOfText theTypeOfText; -static Standard_ShortReal theUnderlinePosition; -static Standard_ShortReal theXmin,theXmax; -static Standard_Integer theNchar; -static Standard_Real theSinAngle,theCosAngle; -static Standard_Real theOrientation; -//////////////// Character description /////////////// -static int myStrLen = 0; -static POINT myStrDesc [CHAR_DESC_LEN]; -static TypeOfPoint myStrInfo [CHAR_DESC_LEN]; -static double myBX, myBY; -static double myCX, myCY; -static int myCharWidth; -static int myCharHeight; -static BOOL myCharInside; - -#define ADD_POINT(X,Y,aType) \ - myStrDesc[myStrLen].x = U2P( (X)+myBX ); \ - myStrDesc[myStrLen].y = ( myWin95 ? myDevHeight - U2P((Y)+myBY) : U2P((Y)+myBY) ); \ - myStrInfo[myStrLen] = aType; myStrLen++; - -#define CHECK_INSIDE(x,y) \ - if (!myCharInside) \ - if (myWin95) { \ - if ((x > -myCharWidth && x < (myDevWidth /*+ myCharWidth*/ )) && \ - (y > -myCharHeight && y < (myDevHeight + myCharHeight))) \ - myCharInside = TRUE; \ - } else { \ - if ((x > -myCharWidth && x < (myDevWidth /*+ myCharWidth */)) && \ - (y > -myCharHeight && y < (myDevHeight /*+ myCharHeight*/))) \ - myCharInside = TRUE; \ - } - -#define CUR_X() myStrDesc[myStrLen-1].x -#define CUR_Y() myStrDesc[myStrLen-1].y - -/*==================================================================*/ -WNT_TextManager::WNT_TextManager(const Standard_Real aPixelToUnit) -{ - myPixelToUnit = aPixelToUnit; - myDevContext = 0; - myDevHeight = 0; - // Clear the memory for STRING description - ZeroMemory (myStrDesc, sizeof(myStrDesc)); - ZeroMemory (myStrInfo, sizeof(myStrInfo)); - myStrLen = 0; -} - -/*==================================================================*/ -void WNT_TextManager::BeginString(const Quantity_Length X, - const Quantity_Length Y, - const Quantity_PlaneAngle anOrientation, - const Quantity_Length aWidth, - const Quantity_Length aHeight, - const Quantity_PlaneAngle aSlant, - const Standard_Integer aPaintType) -{ - myStrLen = 0; - myCharWidth = U2P(aWidth ); - myCharHeight = U2P(aHeight); - - thePaintType = aPaintType; - theOrientation = anOrientation; - myBX = X; - myBY = Y; - theNchar = 0; - theXmin = theXmax = 0.F; - if (!thePaintType) { - if ((aHeight < (6. MILLIMETER)) || - (theTypeOfText == Aspect_TOT_OUTLINE)) - thePaintType = 2; - } -} - -/*==================================================================*/ -Standard_Boolean WNT_TextManager::BeginChar(const Standard_Integer aCharCode, - const Standard_Real X, - const Standard_Real Y) -{ - myCharInside = FALSE; - return Standard_True; -} - -/*==================================================================*/ -Standard_Boolean WNT_TextManager::SetCharBoundingBox(const Quantity_Length X1, - const Quantity_Length Y1, - const Quantity_Length X2, - const Quantity_Length Y2, - const Quantity_Length X3, - const Quantity_Length Y3, - const Quantity_Length X4, - const Quantity_Length Y4) -{ - if (theUnderlinePosition > 0.) { - if (!theNchar) - theXmin = Standard_ShortReal (X1); - theXmax = Standard_ShortReal (Sqrt(X2*X2 + Y2*Y2)); - } - return Standard_True; -} - -/*==================================================================*/ -Standard_Boolean WNT_TextManager::SetCharEncoding(const Standard_CString anEncoding) -{ - return Standard_True; -} - -/*==================================================================*/ -Standard_Boolean WNT_TextManager::Moveto(const Standard_Real X, - const Standard_Real Y) -{ - ADD_POINT (X,Y,TOP_MOVETO); - myCX = X; myCY = Y; - CHECK_INSIDE (CUR_X(),CUR_Y()); - if (!myCharInside) - myStrLen--; - return myCharInside; -} - -/*==================================================================*/ -Standard_Boolean WNT_TextManager::Lineto(const Standard_Real X, - const Standard_Real Y) -{ - ADD_POINT (X,Y,TOP_LINETO); - CHECK_INSIDE (CUR_X(),CUR_Y()); - if (!myCharInside) - myStrLen--; - return myCharInside; -} - -/*==================================================================*/ -Standard_Boolean WNT_TextManager::Curveto(const Quantity_Length X1, - const Quantity_Length Y1, - const Quantity_Length X2, - const Quantity_Length Y2, - const Quantity_Length X3, - const Quantity_Length Y3, - const Quantity_Length X4, - const Quantity_Length Y4) -{ - ADD_POINT (X2,Y2,TOP_CURVETO); - ADD_POINT (X3,Y3,TOP_CURVETO); - ADD_POINT (X4,Y4,TOP_CURVETO); - return Standard_True; -} - -/*==================================================================*/ -void WNT_TextManager::ClosePath() -{ - ADD_POINT (myCX,myCY,TOP_LINETO); - CHECK_INSIDE (CUR_X(),CUR_Y()); - if (!myCharInside) - myStrLen--; -} - -/*==================================================================*/ -Standard_Boolean WNT_TextManager::EndChar(const Standard_Real X, - const Standard_Real Y) -{ - theNchar++; - return Standard_True; -} - -/*==================================================================*/ -void WNT_TextManager::EndString() -{ - static int i, j; - - // Draw text string - i = 0; - BeginPath (MY_HDC); - do { - switch (myStrInfo[i]) { - case TOP_MOVETO: - MoveToEx (MY_HDC, myStrDesc[i].x, myStrDesc[i].y, NULL); - break; - case TOP_LINETO: - j = i+1; - while ((myStrInfo[j] == TOP_LINETO) && (j < myStrLen)) - j++; - PolylineTo (MY_HDC, &myStrDesc[i], j-i); - i = j-1; - break; - case TOP_CURVETO: - PolyBezierTo (MY_HDC, &myStrDesc[i], 3); - i += 2; - break; - default: - break; - } - } while (++i < myStrLen); - EndPath (MY_HDC); - if (thePaintType == 0 && !myMonoBuf) FillPath (MY_HDC); - else StrokePath (MY_HDC); - - // Draw underline if necessary - if (theUnderlinePosition > 0.) { - Standard_ShortReal theX1 = theXmin; - Standard_ShortReal theY1 = -theUnderlinePosition; - Standard_ShortReal theX2 = theXmax; - Standard_ShortReal theY2 = theY1; - theSinAngle = Sin (theOrientation); - theCosAngle = Cos (theOrientation); - TRANSFORM (theX1, theY1); - TRANSFORM (theX2, theY2); - // Draw UNDERLINE - if (myWin95) { - MoveToEx (MY_HDC, U2P(theX1 + myBX), myDevHeight - U2P(theY1 + myBY), NULL); - LineTo (MY_HDC, U2P(theX2 + myBX), myDevHeight - U2P(theY2 + myBY) ); - } else { - MoveToEx (MY_HDC, U2P(theX1 + myBX), U2P(theY1 + myBY), NULL); - LineTo (MY_HDC, U2P(theX2 + myBX), U2P(theY2 + myBY) ); - } - } -} - -/*==================================================================*/ -void WNT_TextManager::SetTextAttribs(const Standard_Integer aTextColor, - const Aspect_TypeOfText aTypeOfText, - const Quantity_Length anUnderlinePosition) -{ - theTextColor = aTextColor; - theTypeOfText = aTypeOfText; - theUnderlinePosition = (Standard_ShortReal)anUnderlinePosition; -} - -/*==================================================================*/ -void WNT_TextManager::SetDrawAttribs(const Standard_Address aDrawData) -{ - PMFT_TEXTMAN_DATA aData = (PMFT_TEXTMAN_DATA)aDrawData; - myDevContext = (int)aData->theHDC; - myWin95 = aData->theWin95; - myDevWidth = aData->theDevWidth; - myDevHeight = aData->theDevHeight; - myUWidth = aData->theUWidth; - myMonoBuf = aData->theMonoBuffer; -} diff --git a/src/WNT/WNT_WDriver.cdl b/src/WNT/WNT_WDriver.cdl deleted file mode 100755 index 58546b1815..0000000000 --- a/src/WNT/WNT_WDriver.cdl +++ /dev/null @@ -1,976 +0,0 @@ --- Created on: 1996-01-25 --- Created by: s: LAVNIKOV Alexey & PLOTNIKOV Eugeny --- Copyright (c) 1996-1999 Matra Datavision --- Copyright (c) 1999-2012 OPEN CASCADE SAS --- --- The content of this file is subject to the Open CASCADE Technology Public --- License Version 6.5 (the "License"). You may not use the content of this file --- except in compliance with the License. Please obtain a copy of the License --- at http://www.opencascade.org and read it completely before using this file. --- --- The Initial Developer of the Original Code is Open CASCADE S.A.S., having its --- main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. --- --- The Original Code and all software distributed under the License is --- distributed on an "AS IS" basis, without warranty of any kind, and the --- Initial Developer hereby disclaims all such warranties, including without --- limitation, any warranties of merchantability, fitness for a particular --- purpose or non-infringement. Please see the License for the specific terms --- and conditions governing the rights and limitations under the License. - - -class WDriver from WNT inherits WindowDriver from Aspect - - ---Purpose: This class defines Windows NT window driver - - uses - - ExtendedString from TCollection, - Length from Quantity, - Factor from Quantity, - Ratio from Quantity, - PlaneAngle from Quantity, - Array1OfShortReal from TShort, - TypeOfResize from Aspect, - TypeOfDrawMode from Aspect, - TypeOfText from Aspect, - ColorMap from Aspect, - TypeMap from Aspect, - WidthMap from Aspect, - FontMap from Aspect, - MarkMap from Aspect, - Window from WNT, - HColorTable from WNT, - HFontTable from WNT, - HArray1OfInteger from TColStd, - FontMapEntry from WNT, - - FontManager from MFT, - HListOfMFTFonts from WNT, - HArray1OfShortReal from TShort, - TextManager from WNT - - raises - - DriverDefinitionError from Aspect, - DriverError from Aspect - - is - - Create ( aWindow : Window from WNT ) - returns mutable WDriver from WNT - raises DriverDefinitionError from Aspect; - ---Level: Public - ---Purpose: Creates Windows NT window driver associated - -- with the Windows NT window - - - Destroy ( me : mutable ) - raises DriverError from Aspect is virtual; - ---Level: Public - ---Purpose: Destroy the Driver - ---Category: Methods to modify the class definition - ---C++: alias ~ - - SelectBuffer( me; aRetainBuffer: Integer from Standard) returns Address from Standard; - ---Level: Public - ---Purpose: Selects RetainBuffer for output - ---Category: Methods to manage buffers - - - BeginDraw ( - me : mutable; - aDoubleBuffer : Boolean = Standard_True; - aRetainBuffer : Integer = 0 - ) - ---Purpose: Begin graphics and drawn directly to the Window or Pixmap if - -- is 0 or in the retain buffer if > 0. - raises DriverError from Aspect is virtual; - ---Trigger: Raises if the retain buffer is not open. - -- call BufferIsOpen() method before. - - EndDraw ( me : mutable; aSynchronize : Boolean = Standard_False ) is virtual; - ---Level: Public - ---Purpose: Called by the method Graphic2d_View::Update, this - -- method manages the buffer flushing and Wait after up to date - -- display when Synchronize is TRUE. - ---Category: Methods to modify the class definition - - ResizeSpace ( me: mutable ) - returns TypeOfResize from Aspect - ---Level: Public - ---Purpose: Resizes the WorkSpace depending of the Window size - -- MUST be call after a Resize or Move WindowDriver Event - -- Returns the TypeOfResize gravity mode. - -- Trigger: Raises if the type of resizing is unknown. - raises DriverError from Aspect is virtual; - ---Category: Methods to modify the class definition - - - --------------------------------------------- - -- Category: Methods to set the attributes - --------------------------------------------- - - - SetHighlightColor ( me; aColorIdx : Integer from Standard ) - returns Boolean from Standard is static; - ---Level: Public - ---Purpose: Sets the highlight color for the drawing. Returns False - -- if the graphic device does not support palette mechanism. - - SetDrawMode ( - me : mutable; - aMode : TypeOfDrawMode from Aspect - ) - is virtual; - ---Level: Public - ---Purpose: Change the current drawing mode of the Driver - -- TODM_REPLACE : the primitive is drawn with his defined color. - -- TODM_ERASE : the primitive is erased from the window. - -- TODM_XOR : the primitive is xored to the window. - -- TODM_XORLIGHT: the primitive is xored depending of the current - -- highlight and background colors. - - SetLineAttrib ( - me : mutable; - ColorIndex : Integer from Standard; - TypeIndex : Integer from Standard; - WidthIndex : Integer from Standard - ) - ---Level: Public - ---Purpose: Sets the line attributes. - -- Category: Methods to set the line attributes - -- Trigger: Raises if one of the index is out of range. - raises DriverError from Aspect is virtual; - - SetTextAttrib ( - me : mutable; - ColorIndex : Integer from Standard; - FontIndex : Integer from Standard - ) - ---Level: Public - ---Purpose: Sets the text attributes. - -- Category: Methods to set the text attributes - -- Trigger: Raises if one of the index is out of range. - raises DriverError from Aspect is virtual; - - SetTextAttrib ( - me : mutable; - ColorIndex : Integer from Standard; - FontIndex : Integer from Standard; - aSlant : PlaneAngle from Quantity; - aHScale : Factor from Quantity; - aWScale : Factor from Quantity; - isUnderlined : Boolean from Standard = Standard_False - ) - ---Level: Public - ---Purpose: Sets the Extended text attributes. - -- Category: Methods to set the text attributes - -- Trigger: Raises if one of the index is out of range. - raises DriverError from Aspect is virtual; - - SetPolyAttrib ( - me : mutable; - ColorIndex : Integer from Standard; - TileIndex : Integer from Standard; - DrawEdgeFlag : Boolean from Standard = Standard_False - ) - ---Level: Public - ---Purpose: Sets the polygon attributes. - -- Warning: - -- is the background poly color index. - -- is the background poly fill rule index. - -- If is TRUE the edge of the poly is drawn with the - -- current line attributes. - -- Category: Methods to set the poly attributes - -- Trigger: Raises if one of the index is out of range. - raises DriverError from Aspect is virtual; - - SetPolyAttrib ( - me : mutable; - ColorIndex : Integer from Standard; - TileIndex : Integer from Standard; - PolygonMode : Integer from Standard; - DrawEdgeFlag : Boolean from Standard = Standard_False - ) - ---Level: Public - ---Purpose: Sets the polygon attributes. - -- Warning: - -- way to fill consecutive lines - -- Category: Methods to set the poly attributes - -- Trigger: Raises if one of the index is out of range. - raises DriverError from Aspect; - - SetMarkerAttrib ( - me : mutable; - ColorIndex : Integer from Standard; - EdgeWidthIndex : Integer from Standard; - FillMarker : Boolean from Standard = Standard_False - ) - ---Level: Public - ---Purpose: Sets the marker attributes. - -- Warning: - -- is the edge or fill marker color index. - -- is the edge marker thickness index. - -- If is TRUE the marker is filled on the first set - -- of consecutive drawn points. - -- Trigger: Raises if one of the index is out of range. - raises DriverError from Aspect is virtual; - - - ----------------------------------------- - -- Category: Methods to manage the images - ----------------------------------------- - - IsKnownImage ( me : mutable; anImage : Transient from Standard ) - returns Boolean from Standard is virtual; - ---Level: Public - ---Purpose: Returns Standard_True if the associated driver - -- have stored the image and Standard_False if not. - - SizeOfImageFile ( - me; - anImageFile : CString from Standard; - aWidth,aHeight : out Integer from Standard - ) - returns Boolean from Standard is virtual; - ---Level: Public - ---Purpose: Returns Standard_True and the Image Size in PIXEL - -- if the image file exist and can be computed by the driver, - -- NOTE that only XWD and DIB image file type are recognized - -- today. - - ClearImage ( - me : mutable; - anImageId : Transient from Standard - ) - is virtual; - ---Level: Public - ---Purpose: Clears the image in . - - ClearImageFile ( - me : mutable; - anImageFile : CString from Standard - ) - is virtual; - ---Level: Public - ---Purpose: Clears the image associated with the image file. - - DrawImage ( - me : mutable; - anImageId : Transient from Standard; - aX, aY : ShortReal from Standard - ) - ---Level: Public - ---Purpose: Draws the image in . - -- , is the center of the image. - -- Image center must be defined in DWU space. - raises DriverError from Aspect is virtual; - ---Trigger: If the anImageId is not found - - DrawImageFile ( - me : mutable; - anImageFile : CString from Standard; - aX, aY : ShortReal from Standard; - aScale : Factor from Quantity = 1.0 - ) - ---Level: Public - ---Purpose: Draws the image file in . - -- , is the center of the image. - -- the scale factor which is apply on this image - -- Image center must be defined in DWU space. - -- anImageFile must be defined with the full pathname - -- of the form dev:\path\name.ext or $DIR\name.ext - -- with DIR defined in a setenv variable. - raises DriverError from Aspect is virtual; - ---Trigger: If the anImageFile is not found - -- or the Image type is neither XWD nor DIB. - - FillAndDrawImage ( - me : mutable; - anImageId : Transient from Standard; - aX, aY : ShortReal from Standard; - Width, Height : Integer from Standard; - anArrayOfPixels : Address from Standard - ) - ---Level: Public - ---Purpose: Stores a complete image and draws it in . - -- Image size must be defined in DWU space> - -- Trigger: Raises if the creation of the image failed. - raises DriverError from Aspect is virtual; - - FillAndDrawImage ( - me : mutable; - anImageId : Transient from Standard; - aX, aY : ShortReal from Standard; - anIndexOfLine, Width, Height : Integer from Standard; - anArrayOfPixels : Address from Standard - ) - ---Level: Advanced - ---Purpose: Stores a line of an image and draws it in . - -- Warning: 0<= anIndexOfLine < aHeight - -- anIndexOfLine = 0 must be the first call - -- Trigger: Raises if the creation of the image failed. - raises DriverError from Aspect is virtual; - - - --------------------------------------- - -- Category: Methods to draw primitives - --------------------------------------- - - - DrawPolyline ( - me : mutable; - ListX : Array1OfShortReal from TShort; - ListY : Array1OfShortReal from TShort - ) - ---Level: Public - ---Purpose: Draws the polyline depending of SetLineAttrib() attributes. - -- Warning: Coordinates must be defined in DWU space. - -- Trigger: Raises if Polyline has too many points (> 1024) - -- Raises if the length of is not equal to - -- the length of . - raises DriverError from Aspect is virtual; - - DrawPolygon ( - me : mutable; - ListX : Array1OfShortReal from TShort; - ListY : Array1OfShortReal from TShort - ) - ---Level: Public - ---Purpose: Draws the polygone depending of SetPolyAttrib() attributes. - -- Warning: Coordinates must be defined in DWU space. - -- Trigger: Raises if Polygone has too many points (> 1024) - -- Raises if the length of is not equal to - -- the length of . - raises DriverError from Aspect is virtual; - - DrawSegment ( - me : mutable; - X1, Y1 : ShortReal from Standard; - X2, Y2 : ShortReal from Standard - ) - ---Level: Public - ---Purpose: Draws the segment depending of SetLineAttrib() attributes. - -- Warning: Coordinates must be defined in DWU space. - raises DriverError from Aspect is virtual; - - DrawText ( - me : mutable; - Text : ExtendedString from TCollection; - Xpos, Ypos : ShortReal from Standard; - anAngle : ShortReal from Standard = 0.0; - aType : TypeOfText from Aspect = Aspect_TOT_SOLID - ) - ---Level: Public - ---Purpose: Draws the text depending of SetTextAttrib() attributes. - -- Warning: Coordinates must be defined in DWU space. - -- Trigger: Raises if Text has too many chars (> 1024) - raises DriverError from Aspect is virtual; - - DrawText ( - me : mutable; - Text : CString from Standard; - Xpos, Ypos : ShortReal from Standard; - anAngle : ShortReal from Standard = 0.0; - aType : TypeOfText from Aspect = Aspect_TOT_SOLID - ) - ---Level : Public - ---Purpose: Draws the text depending of SetTextAttrib() attributes. - -- Warning: Coordinates must be defined in DWU space. - -- Angle must be defined in RADIAN. - -- Trigger: Raises if Text has too many chars (> 1024) - raises DriverError from Aspect is virtual; - - DrawPolyText ( - me : mutable; - aText : ExtendedString from TCollection; - Xpos : ShortReal from Standard; - Ypos : ShortReal from Standard; - aMarge : Ratio from Quantity = 0.1; - anAngle : ShortReal from Standard = 0.0; - aType : TypeOfText from Aspect = Aspect_TOT_SOLID - ) - ---Level: Public - ---Purpose: Draws an framed text depending of the - -- SetTextAttrib() and SetPolyAttrib() attributes. - -- Warning: Coordinates must be defined in DWU space. - -- defines the ratio of the space between the - -- polygon borders and the bounding box of the text and - -- depending of the height of the text. - -- Trigger: Raises if Text has too many chars (> 1024) - -- or 1. - raises DriverError from Aspect is virtual; - - DrawPolyText ( - me : mutable; - aText : CString from Standard; - Xpos : ShortReal from Standard; - Ypos : ShortReal from Standard; - aMarge : Ratio from Quantity = 0.1; - anAngle : ShortReal from Standard = 0.0; - aType : TypeOfText from Aspect = Aspect_TOT_SOLID - ) - ---Level: Public - ---Purpose: Draws an framed text depending of the - -- SetTextAttrib() and SetPolyAttrib() attributes. - -- Warning: Coordinates must be defined in DWU space. - -- defines the ratio of the space between the - -- polygon borders and the bounding box of the text and - -- depending of the height of the text. - -- Trigger: Raises if Text has too many chars (> 1024) - -- or 1. - raises DriverError from Aspect is virtual; - - DrawPoint ( me : mutable; X, Y : ShortReal from Standard ) - ---Level: Public - ---Purpose: Draws a 1 PIXEL point depending of the SetMarkerAttrib() - -- color attribute or add a point depending of the incremental - -- BeginXxxxxx() primitive used. - raises DriverError from Aspect is virtual; - - DrawMarker ( - me : mutable; - aMarker : Integer from Standard; - Xpos, Ypos : ShortReal from Standard; - Width, Height : ShortReal from Standard; - Angle : ShortReal from Standard = 0.0 - ) - ---Level: Public - ---Purpose: Draws the previously defined marker depending of - -- the SetMarkerAttrib() attributes. - -- Warning: Coordinates and sizes must be defined in DWU space. - -- Angle must be defined in RADIAN. - -- A one pixel marker is drawn when aMarker index is undefined. - raises DriverError from Aspect is virtual; - - DrawArc ( - me : mutable; - X, Y : ShortReal from Standard; - aXradius, aYradius : ShortReal from Standard; - aStartAngle : ShortReal from Standard = 0.0; - anOpenAngle : ShortReal from Standard = 6.283185 - ) - returns Boolean - ---Level: Public - ---Purpose: Draws an Ellipsoid arc of center and Radius - -- of relative angle from - -- the base angle - -- Warning: Returns FALSE if the hardware can't drawing this - -- primitive properly,application must to simulate it. - -- Trigger: Raises if one of is <= 0. - raises DriverError from Aspect is virtual; - - DrawPolyArc ( - me : mutable; - X, Y : ShortReal from Standard; - anXradius, anYradius : ShortReal from Standard; - aStartAngle : ShortReal from Standard = 0.0; - anOpenAngle : ShortReal from Standard = 6.283185 - ) - returns Boolean - ---Level: Public - ---Purpose: Draws an filled Ellipsoid arc of center and Radius - -- of relative angle from - -- the base angle and depending of the - -- SetPolyAttrib() attributes. - -- Warning: Returns FALSE if the hardware can't drawing this - -- primitive properly,application must to simulate it. - -- Trigger: Raises if one of is <= 0. - raises DriverError from Aspect is virtual; - - BeginPolyline ( me : mutable; aNumber : Integer ) is virtual; - ---Level: Public - ---Purpose: Begin a polyline primitive of of points. - -- Warning: Points must be added by the DrawPoint() method. - - BeginPolygon ( me : mutable; aNumber : Integer ) is virtual; - ---Level: Public - ---Purpose: Begin a polygon primitive of of points . - -- Warning: Points must be added by the DrawPoint() method. - - BeginSegments ( me : mutable ) is virtual; - ---Level: Public - ---Purpose: Begin a set of segments . - -- Warning: Segments must be added by DrawSegment() method. - - BeginArcs ( me : mutable ) is virtual; - ---Level: Public - ---Purpose: Begin a set of circles or ellips . - -- Warning: Arcs must be added by the DrawArc() method. - - BeginPolyArcs ( me : mutable ) is virtual; - ---Level: Public - ---Purpose: Begin a set of polygon circles or ellips . - -- Warning: Arcs must be added by the DrawPolyArc() method. - - BeginMarkers ( me : mutable ) is virtual; - ---Level: Public - ---Purpose: Begin a set of markers . - -- Warning: Markers must be added by the DrawMarker() method. - - BeginPoints ( me : mutable ) is virtual; - ---Level: Public - ---Purpose: Begin a set of points . - -- Warning: Points must be added by the DrawPoint() method. - - ClosePrimitive ( me : mutable ) - ---Level: Public - ---Purpose: Close the last Begining primitive - -- Trigger: Raises if no primitive have been opened by BeginXxxxxx(). - raises DriverError from Aspect is virtual; - - - --------------------------------------------- - -- Category: Methods to define the attributes - --------------------------------------------- - - - InitializeColorMap ( - me : mutable; - Colormap : ColorMap from Aspect - ) - ---Level: Public - ---Purpose: Defines the color map. - -- Level: Public - -- Trigger: Raises if the definition failed. - raises DriverError from Aspect is virtual protected; - ---Category: Methods to define the color indices. - - InitializeTypeMap ( - me : mutable; - Typemap : TypeMap from Aspect - ) - ---Purpose: Defines the line type map. - -- Level: Public - -- Trigger: Raises if the definition failed. - raises DriverError from Aspect is virtual protected; - ---Category: Methods to define the type of line indices. - - InitializeWidthMap ( - me : mutable; - Widthmap : WidthMap from Aspect - ) - ---Purpose: Defines the width line map. - -- Level: Public - -- Trigger: Raises if the definition failed. - raises DriverError from Aspect is virtual protected; - ---Category: Methods to define the width of line indices. - - InitializeFontMap ( - me : mutable; - Fontmap : FontMap from Aspect - ) - ---Purpose: Defines the font map. - -- Level: Public - -- Trigger: Raises if the definition failed. - raises DriverError from Aspect is virtual protected; - ---Category: Methods to define the font indices. - - InitializeMarkMap ( - me : mutable; - Markmap : MarkMap from Aspect - ) - ---Purpose: Defines the mark map. - -- Level: Public - -- Trigger: Raises if the definition failed. - raises DriverError from Aspect is virtual protected; - ---Category: Methods to define the marker indices. - - - ------------------------------------------------------------- - -- Category: Methods to define or edit a buffer of primitives - ------------------------------------------------------------- - InternalOpenBuffer ( - me : mutable; - aRetainBuffer : Integer; - aMono : Boolean; - aPivotX : ShortReal; - aPivotY : ShortReal; - aColorIndex : Integer; - aWidthIndex : Integer; - aTypeIndex : Integer; - aFontIndex : Integer; - aDrawMode : TypeOfDrawMode = Aspect_TODM_REPLACE - ) - returns Address is private; - - OpenBuffer ( - me : mutable; - aRetainBuffer : Integer; - aPivotX : ShortReal = 0.0; - aPivotY : ShortReal = 0.0; - aWidthIndex : Integer = 0; - aColorIndex : Integer = 0; - aFontIndex : Integer = 0; - aDrawMode : TypeOfDrawMode = Aspect_TODM_REPLACE - ) - returns Boolean is virtual; - ---Purpose: Allocate the retain buffer , - -- Defines the DWU coordinates of the pivot point for all primitives - -- contains inside. - -- Defines the buffer color and font index : - -- the default color is the highlight color of the colormap. - -- the default font is the default system font of the fontmap. - -- The other attributes are fixed : - -- line type is Solid, - -- line width is 1 Pixel, - -- polygon fill mode is Solid, - -- Returns TRUE if the buffer is allocated and enabled for drawing. - - OpenColorBuffer ( - me : mutable; - aRetainBuffer : Integer; - aPivotX : ShortReal = 0.0; - aPivotY : ShortReal = 0.0; - aWidthIndex : Integer = 0; - aColorIndex : Integer = 0; - aFontIndex : Integer = 0; - aDrawMode : TypeOfDrawMode = Aspect_TODM_REPLACE - ) - returns Boolean; - ---Purpose: Allocate the retain buffer , - -- Defines the DWU coordinates of the pivot point for all primitives - -- contains inside. - -- Defines the buffer color and font index : - -- the default color is the highlight color of the colormap. - -- the default font is the default system font of the fontmap. - -- the default line type, - -- the default line width, - -- the default polygon fill mode, - -- Returns TRUE if the buffer is allocated and enabled for drawing. - - - CloseBuffer ( - me ; - aRetainBuffer: Integer - ) - ---Purpose: Clear & Deallocate the retain buffer . - raises DriverError from Aspect is virtual; - ---Trigger: Raises if the retain buffer is not opened. - -- call BufferIsOpen() method before. - - ClearBuffer ( - me; - aRetainBuffer: Integer - ) - ---Purpose: Erase & Clear ALL primitives retains in the buffer . - raises DriverError from Aspect is virtual; - ---Trigger: Raises if the retain buffer is not opened. - -- call BufferIsOpen() method before. - - DrawBuffer ( me; aRetainBuffer : Integer ) - ---Purpose: Draw ALL primitives retains in the buffer . - -- Warning: Note that the aspect of a retain buffer drawing is - -- mono-colored with the current buffer Attributes and - -- Depending of the DoubleBuffer state flag at the BeginDraw() buffer time, - -- when DB is TRUE,an XOR method is use for drawing and erasing buffers in the - -- same way.In this case,some color side effect can occurs depending of the - -- traversal primitive colors and the supported hardware. - -- when DB is FALSE and the background drawing has been generated with - -- DB at TRUE,no color side effect occurs because the DB is used for restoring - -- the drawing context at EraseBuffer() time,this is more powerfull for the - -- drawing quality excepted for large buffers (flicking) . - raises DriverError from Aspect is virtual; - ---Trigger: Raises if the retain buffer is not opened. - -- call BufferIsOpen() method before. - - EraseBuffer ( me; aRetainBuffer : Integer ) - ---Purpose: Erase ALL primitives retains in the buffer . - raises DriverError from Aspect is virtual; - ---Trigger: Raises if the retain buffer is not opened. - -- call BufferIsOpen() method before. - - MoveBuffer ( - me; - aRetainBuffer : Integer; - aPivotX : ShortReal = 0.0; - aPivotY : ShortReal = 0.0 - ) - ---Purpose: Erase , Translate and reDraw ALL primitives retains in the buffer - -- . - -- are the new DWU attached point absolute coordinates - -- of the buffer pivot point. - raises DriverError from Aspect is virtual; - ---Trigger: Raises if the retain buffer is not opened - -- call BufferIsOpen() method before. - - ScaleBuffer ( - me; - aRetainBuffer : Integer; - aScaleX : Factor = 1.0; - aScaleY : Factor = 1.0 - ) - ---Purpose: Erase , Scale the buffer from the Pivot point and reDraw ALL primitives - -- retains in the buffer . - -- are the absolute scale factors apply on the two axis. - -- Warning: Note that the scalling of some primitives can provided some bad - -- smoothing side effect (i.e: Circles,...) - raises DriverError from Aspect is virtual; - ---Trigger: Raises if the retain buffer is not opened or - --one of factor is <= 0. - -- call BufferIsOpen() method before. - - RotateBuffer ( - me; - aRetainBuffer : Integer; - anAngle : PlaneAngle = 0.0 - ) - ---Purpose: Erase , Rotate the buffer from the Pivot point and reDraw ALL primitives - -- retains in the buffer . - -- is the absolute counter-clockwise rotation angle from the - -- Horizontal axis. - raises DriverError from Aspect is virtual; - ---Trigger: Raises if the retain buffer is not opened. - -- call BufferIsOpen() method before. - - - ---------------------------- - -- Category: Inquire methods - ---------------------------- - - WorkSpace ( me; Width, Heigth : out Length from Quantity ) is virtual; - ---Level: Public - ---Purpose: Returns the Available WorkSpace in DWU coordinates - - Convert ( me; PV : Integer from Standard ) - returns Length from Quantity is virtual; - ---Level: Public - ---Purpose: Returns the DWU value depending of - -- the PIXEL value. - - Convert ( me; DV : Length from Quantity ) - returns Integer from Standard is virtual; - ---Level: Public - ---Purpose: Returns the PIXEL value depending of - -- the DWU value. - - Convert ( - me; - PX, PY : Integer from Standard; - DX, DY : out Length from Quantity - ) - is virtual; - ---Level: Public - ---Purpose: Returns the DWU position depending of - -- the PIXEL position . - - Convert ( - me; - DX, DY : Length from Quantity; - PX, PY : out Integer from Standard - ) - is virtual; - ---Level: Public - ---Purpose: Returns the PIXEL position depending of - -- the DWU position . - - ProcessColorIndex( me; ColorIndex : Integer) returns Integer from Standard is private; - - ProcessWidthIndex( me; WidthIndex : Integer) returns Length from Quantity is private; - - ProcessTypeIndex ( me; TypeIndex : Integer) returns Integer from Standard is private; - - BufferIsOpen ( me; aRetainBuffer : Integer ) - returns Boolean is virtual; - ---Purpose: Returns TRUE if the retain buffer is enabled - --for drawing. - - BufferIsEmpty ( me; aRetainBuffer : Integer ) - returns Boolean is virtual; - ---Purpose: Returns TRUE if the retain buffer has not been opened or empty. - --- Returns FALSE if a lot of primitives have been stored inside - -- because a BeginDraw(..,) has been done previously. - - BufferIsDrawn ( me; aRetainBuffer : Integer ) - returns Boolean is virtual; - ---Purpose: Returns TRUE if the retain buffer s actually displayed at screen. - - AngleOfBuffer ( me; aRetainBuffer : Integer; anAngle: out PlaneAngle ) - ---Purpose: Returns the current buffer rotate angle from the X axis. - raises DriverError from Aspect is virtual; - ---Trigger: Raises if the retain buffer is not opened. - -- call BufferIsOpen() method before. - - ScaleOfBuffer ( me; aRetainBuffer : Integer; aScaleX,aScaleY : out Factor ) - ---Purpose: Returns the current buffer scale factors. - raises DriverError from Aspect is virtual; - ---Trigger: Raises if the retain buffer is not opened. - -- call BufferIsOpen() method before. - - PositionOfBuffer ( - me; - aRetainBuffer : Integer; - aPivotX, aPivotY : out ShortReal - ) - ---Purpose: Returns the current buffer position. - raises DriverError from Aspect is virtual; - ---Trigger: Raises if the retain buffer is not opened. - -- call BufferIsOpen() method before. - - TextSize ( - me; - aText : ExtendedString from TCollection; - aWidth, aHeight : out ShortReal from Standard; - aFontIndex : Integer from Standard = -1 - ) - ---Level: Public - ---Purpose: Returns the TEXT size in DWU space depending - -- of the required FontIndex if aFontIndex is >= 0 - -- or the current FontIndex if < 0 (default). - -- Trigger: Raises if font is not defined. - raises DriverError from Aspect is virtual; - ---Category: Inquire methods - - TextSize ( - me; - aText : ExtendedString from TCollection; - aWidth, aHeight, anXoffset, anYoffset : out ShortReal from Standard; - aFontIndex: Integer from Standard = -1) - ---Level: Public - ---Purpose: Returns the TEXT size and offsets - -- in DWU space depending - -- of the required FontIndex if aFontIndex is >= 0 - -- or the current FontIndex if < 0 (default). - -- Trigger: Raises if font is not defined. - raises DriverError from Aspect is virtual; - ---Category: Inquire methods - - TextSize ( - me; - aText : CString from Standard; - aWidth, aHeight, - anXoffset, anYoffset : out ShortReal from Standard; - aFontIndex : Integer from Standard = -1 - ) - ---Level: Public - ---Purpose: Returns the TEXT size in DWU space depending - -- of the required FontIndex if aFontIndex is >= 0 - -- or the current FontIndex if < 0 (default). - -- Trigger: Raises if font is not defined. - raises DriverError from Aspect is virtual; - ---Category: Inquire methods - - FontSize ( - me; - aSlant : out PlaneAngle from Quantity; - aSize,aBheight : out ShortReal from Standard; - aFontIndex : Integer from Standard = -1 - ) - returns CString from Standard - ---Level: Public - ---Purpose: Returns the font string,slant,size and - -- baseline height in DWU space depending - -- of the required FontIndex if aFontIndex is >= 0 - -- or the current FontIndex if < 0 (default). - -- Trigger: Raises if font is not defined. - raises DriverError from Aspect is virtual; - ---Category: Inquire methods - - ColorBoundIndexs(me; aMinIndex,aMaxIndex : out Integer from Standard) - is redefined; - ---Level: Advanced - ---Purpose: - -- Returns the min and max driver virtual color indexs. - ---Category: Inquire methods - - LocalColorIndex(me; anIndex : Integer from Standard) - returns Integer from Standard is redefined; - ---Level: Advanced - ---Purpose: - -- Returns the local colormap hardware index from a virtual driver color - -- index or returns -1 if the index is not defined. - ---Category: Inquire methods - - FontBoundIndexs(me; aMinIndex,aMaxIndex : out Integer from Standard) - is redefined; - ---Level: Advanced - ---Purpose: - -- Returns the min and max driver virtual font indexs. - ---Category: Inquire methods - - LocalFontIndex(me; anIndex : Integer from Standard) - returns Integer from Standard is redefined; - ---Level: Advanced - ---Purpose: - -- Returns the associated fontmap hardware index from a virtual driver font - -- index or returns -1 if the index is not defined. - ---Category: Inquire methods - - TypeBoundIndexs(me; aMinIndex,aMaxIndex : out Integer from Standard) - is redefined; - ---Level: Advanced - ---Purpose: - -- Returns the min and max driver virtual type indexs. - ---Category: Inquire methods - - LocalTypeIndex(me; anIndex : Integer from Standard) - returns Integer from Standard is redefined; - ---Level: Advanced - ---Purpose: - -- Returns the associated typemap hardware index from a virtual driver type - -- index or returns -1 if the index is not defined. - ---Category: Inquire methods - - WidthBoundIndexs(me; aMinIndex,aMaxIndex : out Integer from Standard) - is redefined; - ---Level: Advanced - ---Purpose: - -- Returns the min and max driver virtual width indexs. - ---Category: Inquire methods - - LocalWidthIndex(me; anIndex : Integer from Standard) - returns Integer from Standard is redefined; - ---Level: Advanced - ---Purpose: - -- Returns the associated widthmap hardware index from a virtual driver width - -- index or returns -1 if the index is not defined. - ---Category: Inquire methods - - MarkBoundIndexs(me; aMinIndex,aMaxIndex : out Integer from Standard) - is redefined; - ---Level: Advanced - ---Purpose: - -- Returns the min and max driver virtual marker indexs. - ---Category: Inquire methods - - LocalMarkIndex(me; anIndex : Integer from Standard) - returns Integer from Standard is redefined; - ---Level: Advanced - ---Purpose: - -- Returns the local markmap hardware index from a virtual driver marker - -- index or returns -1 if the index is not defined. - ---Category: Inquire methods - - TextManager (me: mutable) - returns TextManager from WNT; - ---C++: return const & - ---Category: Inquire methods - - MFT_Font (me: mutable; anIndex: Integer) - returns FontManager from MFT; - ---C++: return const & - ---Category: Inquire methods - - MFT_Size (me: mutable; anIndex: Integer) - returns ShortReal; - ---Category: Inquire methods - -fields - - myAllocators, - myAllocator : Address from Standard; - myWNTWindow : Window from WNT; - myPixelToUnit : Real from Standard; - - myColors : HColorTable from WNT; - myFonts : HFontTable from WNT; - myTypeIdxs : HArray1OfInteger from TColStd; - myWidthIdxs : HArray1OfInteger from TColStd; - myMarkerIdxs : HArray1OfInteger from TColStd; - - myMFTFonts : HListOfMFTFonts from WNT; - myMFTSizes : HArray1OfShortReal from TShort; - myTextManager : TextManager from WNT; - -end WDriver; diff --git a/src/WNT/WNT_WDriver.cxx b/src/WNT/WNT_WDriver.cxx deleted file mode 100755 index 55c459a6db..0000000000 --- a/src/WNT/WNT_WDriver.cxx +++ /dev/null @@ -1,2187 +0,0 @@ -// Created on: 1997-03-17 -// Created by: EugenyPLOTNIKOV -// Copyright (c) 1997-1999 Matra Datavision -// Copyright (c) 1999-2012 OPEN CASCADE SAS -// -// The content of this file is subject to the Open CASCADE Technology Public -// License Version 6.5 (the "License"). You may not use the content of this file -// except in compliance with the License. Please obtain a copy of the License -// at http://www.opencascade.org and read it completely before using this file. -// -// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its -// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. -// -// The Original Code and all software distributed under the License is -// distributed on an "AS IS" basis, without warranty of any kind, and the -// Initial Developer hereby disclaims all such warranties, including without -// limitation, any warranties of merchantability, fitness for a particular -// purpose or non-infringement. Please see the License for the specific terms -// and conditions governing the rights and limitations under the License. - -// Modified: MAR-98 (DCB) MFT -// DCB: SEP-98 Avoid memory crash when color indices do not follow -// each other or do not begin with '1' - -// include windows.h first to have all definitions available -#include - -#define MFT // Study S3553 - -#define PRO17334 //GG_060199 -// SetXxxAttrib() must raise when index is wrong -// Idem for DrawMarker() - -#define PRO17381 //GG_080199 -// Protection : Do nothing when NULL string is found in TextSize - -#define PRO19042 //GG_261199 -// Don't clear buffer at begin draw .If not this clear -// the current buffer attribs and the resulting buffer is black - -#include - -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include - -#include - -#include "W32_Allocator.hxx" - -#define A ( ( PW32_Allocator )myAllocator ) -#define SA ( !( A -> myFlags & W32F_MONO ) || \ -( ( A -> myFlags & W32F_MONO ) && ( A -> myFlags & W32F_MINIT ) ) \ - ) - -/*====================== MFT ====================*/ -#ifdef MFT -#include -#include "WNT_MFTDraw.hxx" -#endif -/*====================== MFT ====================*/ - -typedef struct _m_param { - - Aspect_MarkerStyle* s; - int w; - int h; - - } MPARAM, *PMPARAM; - -typedef struct { - - float r; - float g; - float b; - - } PIXEL2D, *PPIXEL2D; - -extern double W32_TextFactor; -static PW32_Allocator __fastcall _FindAllocator ( Standard_Address, Standard_Integer ); -static int __fastcall _GetROP2 ( Aspect_TypeOfDrawMode ); -static char* __fastcall _ConvertU2F ( const TCollection_ExtendedString& ); - -static void WINAPI _SetPoint ( int, int, int, LPPOINT, int*, void* ); - -WNT_WDriver :: WNT_WDriver ( const Handle( WNT_Window )& aWindow ) : - Aspect_WindowDriver ( aWindow ) { - - WINDOW_DATA* wd; - Standard_Integer pXSize, pYSize; - Quantity_Length dXSize, dYSize; - - Handle( WNT_GraphicDevice ) gDev = Handle ( WNT_GraphicDevice ) :: - DownCast ( MyWindow -> GraphicDevice () ); - - gDev -> DisplaySize ( pXSize, pYSize ); - gDev -> DisplaySize ( dXSize, dYSize ); - - myWNTWindow = Handle( WNT_Window ) :: DownCast ( MyWindow ); - myPixelToUnit = ( dXSize / pXSize + dYSize / pYSize ) / 2.0; - myAllocators = myAllocator = ( *W32_GetAllocator ) ( 0, NULL ); - MyDrawMode = Aspect_TODM_REPLACE; - -/*====================== MFT ====================*/ -#ifdef MFT - myTextManager = new WNT_TextManager (myPixelToUnit); -#endif -/*====================== MFT ====================*/ - - wd = (WINDOW_DATA* )GetWindowLongPtr ((HWND )aWindow->HWindow(), GWLP_USERDATA); - wd->WNT_WDriver_Ptr = (void* )this; - -} // end constructor - -void WNT_WDriver :: Destroy () { - - do { - - myAllocator = ( ( PW32_Allocator )myAllocators ) -> myNext; - - delete ( PW32_Allocator )myAllocators; - - myAllocators = ( PW32_Allocator )myAllocator; - - } while ( myAllocators != NULL ); - -} // end WNT_WDriver :: Destroy - -Standard_Address WNT_WDriver :: SelectBuffer ( - const Standard_Integer aRetainBuffer - ) const { - - PW32_Allocator a = _FindAllocator ( myAllocators, aRetainBuffer ); - - if ( a != NULL ) *( ( Standard_Address* )&myAllocator ) = ( Standard_Address )a; - - return myAllocator; - -} // end WNT_WDriver :: SelectBuffer - -void WNT_WDriver :: BeginDraw ( - const Standard_Boolean aDoubleBuffer, - const Standard_Integer aRetainBuffer - ) { - - PW32_Allocator a = _FindAllocator ( myAllocators, aRetainBuffer ); - - if ( a != NULL ) { - - if ( aDoubleBuffer ) { - - MyWindow -> SetDoubleBuffer ( aDoubleBuffer ); - a -> myFlags |= W32F_DBUFF; - - } else a -> myFlags &= ~W32F_DBUFF; - -#ifdef PRO19042 - if( !aRetainBuffer ) -#endif - a -> ClearBlocks (); - a -> myFlags |= W32F_START; - a -> myFlags &= ~W32F_DVDRV; - - SelectBuffer ( aRetainBuffer ); - - } // end if - -} // end WNT_WDriver :: BeginDraw - -void WNT_WDriver :: EndDraw ( const Standard_Boolean aSynchronize ) { - - ( ( PW32_Allocator )myAllocator ) -> myFlags &= ~W32F_START; - - DrawBuffer ( ( ( PW32_Allocator )myAllocator ) -> myID ); - -} // end WNT_WDriver :: EndDraw - -Aspect_TypeOfResize WNT_WDriver :: ResizeSpace () { - - return myWNTWindow -> DoResize (); - -} // end WNT_WDriver :: ResizeSpace - -Standard_Boolean WNT_WDriver :: SetHighlightColor ( - const Standard_Integer aColorIdx - ) const { - - Handle( WNT_GraphicDevice ) gDev = Handle( WNT_GraphicDevice ) :: - DownCast ( MyWindow -> GraphicDevice () ); - - gDev -> SetColor ( - ColorMap () -> Entry ( aColorIdx + 1 ).Color (), Standard_True - ); - - return Standard_True; - -} // end WNT_WDriver :: SetHighlightColor - -void WNT_WDriver :: SetDrawMode ( const Aspect_TypeOfDrawMode aMode ) { - - MyDrawMode = aMode; - -} // end WNT_WDriver :: SetDrawMode - -void WNT_WDriver :: SetLineAttrib ( - const Standard_Integer ColorIndex, - const Standard_Integer TypeIndex, - const Standard_Integer WidthIndex - ) -{ -#ifdef PRO17334 - if( myColors.IsNull() || - ColorIndex < myColors->Lower() || ColorIndex > myColors->Upper() ) - Aspect_DriverError::Raise ("Bad Color Index") ; - if( myTypeIdxs.IsNull() || - TypeIndex < myTypeIdxs->Lower() || TypeIndex > myTypeIdxs->Upper() ) - Aspect_DriverError::Raise ("Bad Type Index") ; - if( myWidthIdxs.IsNull() || - WidthIndex < myWidthIdxs->Lower() || WidthIndex > myWidthIdxs->Upper() ) - Aspect_DriverError::Raise ("Bad Width Index") ; - - Aspect_LineStyle Entry = TypeMap () -> Entry ( myTypeIdxs -> Value(TypeIndex) ).Type (); -#else - Standard_Integer theIndex = TypeIndex; - if (TypeIndex < myTypeIdxs->Lower() || TypeIndex > myTypeIdxs->Upper()) - theIndex = myTypeIdxs->Lower(); - - Aspect_LineStyle Entry = TypeMap () -> Entry ( myTypeIdxs -> Value(theIndex) ).Type (); -#endif - Standard_Integer type = ((Entry.Style() == Aspect_TOL_SOLID) ? 0 : PS_USERSTYLE); - double width = ( double )ProcessWidthIndex ( WidthIndex ); - Standard_Boolean fUser = ( type & PS_USERSTYLE ); - LOGBRUSH lb = { BS_SOLID, ProcessColorIndex ( ColorIndex ), 0 }; - if ( fUser ) { - Standard_Integer Lower = Entry.Values ().Lower (); - Standard_Integer Count = Entry.Values ().Length (); - PDWORD dwStyle = ( PDWORD )HeapAlloc ( - GetProcessHeap (), - HEAP_GENERATE_EXCEPTIONS, - Count * sizeof ( DWORD ) - ); - for ( Standard_Integer i = 0; i < Count; ++i ) { - dwStyle[ i ] = DWORD ( Entry.Values ().Value ( i + Lower ) / myPixelToUnit + 0.5 ); - if ( dwStyle[ i ] == 0.0 ) dwStyle[ i ] = 1; - } // end for - A -> LineAttrib ( DWORD( width + 0.5 ), &lb, Count, dwStyle ); - HeapFree ( GetProcessHeap (), 0, ( LPVOID )dwStyle ); - } else A -> LineAttrib ( DWORD( width + 0.5 ), &lb ); -} // end WNT_WDriver :: SetLineAttrib - -void WNT_WDriver :: SetTextAttrib ( - const Standard_Integer ColorIndex, - const Standard_Integer FontIndex - ) -{ - SetTextAttrib ( ColorIndex, FontIndex, 0.0, 1.0, 0.0,Standard_False ); -} // end WNT_WDriver :: SetTextAttrib - -void WNT_WDriver :: SetTextAttrib ( - const Standard_Integer ColorIndex, - const Standard_Integer FontIndex, - const Quantity_PlaneAngle aSlant, - const Quantity_Factor aHScale, - const Quantity_Factor aWScale, - const Standard_Boolean isUnderlined - ) -{ -#ifdef PRO17334 - if( myColors.IsNull() || - ColorIndex < myColors->Lower() || ColorIndex > myColors->Upper() ) - Aspect_DriverError::Raise ("Bad Color Index") ; - if( myFonts.IsNull() || - FontIndex < myFonts->Lower() || FontIndex > myFonts->Upper() ) - Aspect_DriverError::Raise ("Bad Font Index") ; -#endif - HFONT hFont; - LOGFONT lf; - BOOL fFree = FALSE; - Handle( WNT_FontMapEntry ) fmEntry = myFonts -> Value ( FontIndex ); - /*====================== MFT ====================*/ -#ifdef MFT - if ( UseMFT() ) { - //============== Set some font attributes ============= - Handle(MFT_FontManager) theFontManager = MFT_Font(FontIndex); - Standard_ShortReal theTextSize = MFT_Size(FontIndex); - theFontManager->SetFontAttribs ( - Abs(theTextSize)*(aWScale > 0.0 ? aWScale : aHScale)*A->myScaleX, - Abs(theTextSize)*aHScale *A->myScaleY, - aSlant, 0., ((theTextSize > 0.) ? Standard_False : Standard_True) - ); - A -> TextAttrib ( - (HFONT)FontIndex, ProcessColorIndex ( ColorIndex ), aSlant, - aHScale, ( aWScale > 0.0 ? aWScale : aHScale ), - isUnderlined, Standard_False, Standard_True - ); - } else { -#endif - /*====================== MFT ====================*/ - GetObject ( - hFont = ( HFONT )fmEntry-> HFont (), - sizeof ( LOGFONT ), &lf - ); - - if ( isUnderlined && !lf.lfUnderline ) { - FONT_DATA fd = { TRUE }; - hFont = ( HFONT )fmEntry -> SetAttrib ( faUnderlined, &fd ); - fFree = TRUE; - } // end if - - A -> TextAttrib ( - hFont, ProcessColorIndex ( ColorIndex ), aSlant, - aHScale / W32_TextFactor, - ( aWScale > 0.0 ? aWScale : aHScale ) / W32_TextFactor, - isUnderlined, fFree - ); -#if 0 - char* str = (isUnderlined ? "UNDERLINED" : "GOD DAMN "); - HDC hdc = GetDC ( ( HWND )myWNTWindow -> HWindow () ); - HFONT hf = SelectFont ( hdc, hFont ); - SetTextColor ( hdc, RGB (133, 211, 66) ); - SetBkColor ( hdc, RGB (0, 0, 0) ); - Rectangle ( hdc, 0, 0, 1220, 220 ); - SetBkMode ( hdc, OPAQUE ); - TextOut ( hdc, 0, 0, str, lstrlen(str) ); - SelectFont ( hdc, hf ); - ReleaseDC ( ( HWND )myWNTWindow -> HWindow (), hdc ); - MessageBox ( ( HWND )myWNTWindow -> HWindow (), str, "Son of a BITCH", MB_OK ); -#endif - /*====================== MFT ====================*/ -#ifdef MFT - } -#endif - /*====================== MFT ====================*/ -} // end WNT_WDriver :: SetTextAttrib - -void WNT_WDriver :: SetPolyAttrib ( - const Standard_Integer ColorIndex, - const Standard_Integer TileIndex, - const Standard_Boolean DrawEdgeFlag - ) -{ -#ifdef PRO17334 - if( myColors.IsNull() || - ColorIndex < myColors->Lower() || ColorIndex > myColors->Upper() ) - Aspect_DriverError::Raise ("Bad Color Index") ; -#endif - if ( !SA ) return; - LOGBRUSH lb = { TileIndex < 0 ? BS_NULL : BS_SOLID, ProcessColorIndex ( ColorIndex ), 0 }; - A -> PolyAttrib ( &lb, DrawEdgeFlag ); -} // end WNT_WDriver :: SetPolyAttrib - -void WNT_WDriver :: SetPolyAttrib ( - const Standard_Integer ColorIndex, - const Standard_Integer TileIndex, - const Standard_Integer PolygonMode, - const Standard_Boolean DrawEdgeFlag - ) -{ -#ifdef PRO17334 - if( myColors.IsNull() || - ColorIndex < myColors->Lower() || ColorIndex > myColors->Upper() ) - Aspect_DriverError::Raise ("Bad Color Index") ; -#endif - if ( !SA ) return; - LOGBRUSH lb = { BS_SOLID, ProcessColorIndex ( ColorIndex ), 0 }; - A -> PolyAttrib ( &lb, DrawEdgeFlag, PolygonMode ); -} // end WNT_WDriver :: SetPolyAttrib - -void WNT_WDriver :: SetMarkerAttrib ( - const Standard_Integer ColorIndex, - const Standard_Integer EdgeWidthIndex, - const Standard_Boolean FillMarker - ) -{ -#ifdef PRO17334 - if( myColors.IsNull() || - ColorIndex < myColors->Lower() || ColorIndex > myColors->Upper() ) - Aspect_DriverError::Raise ("Bad Color Index") ; - if( myWidthIdxs.IsNull() || - EdgeWidthIndex < myWidthIdxs->Lower() || EdgeWidthIndex > myWidthIdxs->Upper() ) - Aspect_DriverError::Raise ("Bad EdgeWidth Index") ; -#endif - if ( SA ) - A -> MarkerAttrib ( - ProcessColorIndex ( ColorIndex ), - DWORD( ProcessWidthIndex ( EdgeWidthIndex ) + 0.5 ), - FillMarker - ); -} // end WNT_WDriver :: SetMarkerAttrib - -Standard_Boolean WNT_WDriver :: IsKnownImage ( - const Handle( Standard_Transient )& anImage - ) -{ - return myWNTWindow -> myImages -> Index ( ::HashCode (anImage, IntegerLast()) - ) ? Standard_True : Standard_False; -} // end WNT_WDriver :: IsKnownImage - -Standard_Boolean WNT_WDriver :: SizeOfImageFile ( - const Standard_CString anImageFile, - Standard_Integer& aWidth, - Standard_Integer& aHeight - ) const { -#ifndef BUG //Sets the size to 0 when the image file is not found. - aWidth = 0; aHeight = 0; -#endif - - Standard_Integer i = myWNTWindow -> myImages -> Load ( anImageFile ); - - if ( i ) myWNTWindow -> myImages -> Dim ( i, aWidth, aHeight ); - - return i ? Standard_True : Standard_False; - -} // end WNT_WDriver :: SizeOfImageFile - -void WNT_WDriver :: ClearImage ( const Handle( Standard_Transient )& anImageId ) { - - Standard_Integer i = myWNTWindow -> myImages -> Index ( - ::HashCode (anImageId, IntegerLast()) - ); - - if ( i ) myWNTWindow -> myImages -> Discard ( i ); - -} // end WNT_WDriver :: ClearImage - -void WNT_WDriver :: ClearImageFile ( const Standard_CString anImageFile ) { - - Standard_Integer i = myWNTWindow -> myImages -> Load ( anImageFile ); - - if ( i ) myWNTWindow -> myImages -> Discard ( i ); - -} // end WNT_WDriver :: ClearImageFile - -void WNT_WDriver :: DrawImage ( - const Handle( Standard_Transient )& anImageId, - const Standard_ShortReal aX, - const Standard_ShortReal aY - ) { - - Standard_Integer i = myWNTWindow -> myImages -> Index ( - ::HashCode (anImageId, IntegerLast()) - ); - - if ( i ) A -> Image ( - P( aX ), P( aY ), - ( PW32_Bitmap )myWNTWindow -> myImages -> Image ( i ) -> Image () - ); - -} // end WNT_WDriver :: DrawImage - -void WNT_WDriver :: DrawImageFile ( - const Standard_CString anImageFile, - const Standard_ShortReal aX, - const Standard_ShortReal aY, - const Quantity_Factor aScale - ) { - - int i = myWNTWindow -> myImages -> Load ( anImageFile ); - - if ( i ) { - - PW32_Bitmap pBmp; - - if (aScale != 1.0) { - - pBmp = ( PW32_Bitmap )HeapAlloc ( - GetProcessHeap (), - HEAP_GENERATE_EXCEPTIONS, - sizeof ( W32_Bitmap ) - ); - pBmp -> hBmp = ( HBITMAP )myWNTWindow -> myImages -> Scale ( i, aScale, aScale ); - pBmp -> nUsed = 0; - - } else - - pBmp = ( PW32_Bitmap )myWNTWindow -> myImages -> Image ( i ) -> Image (); - - A -> Image ( P( aX ), P( aY ), pBmp ); - - } // end if - -} // end WNT_WDriver :: DrawImageFile - -void WNT_WDriver :: FillAndDrawImage ( - const Handle(Standard_Transient)& anImageId, - const Standard_ShortReal aX, - const Standard_ShortReal aY, - const Standard_Integer Width, - const Standard_Integer Height, - const Standard_Address anArrayOfPixels - ) { - - HDC hdc, hdcMem; - HBITMAP hbo; - HPALETTE hpo = NULL; - Standard_Integer i, h; - Quantity_Color color; - PPIXEL2D p = ( PPIXEL2D )anArrayOfPixels; - Handle( WNT_GraphicDevice ) gDev = Handle( WNT_GraphicDevice ) :: - DownCast ( MyWindow -> GraphicDevice () ); - - hdc = GetDC ( ( HWND )myWNTWindow -> HWindow () ); - hdcMem = CreateCompatibleDC ( hdc ); - - if ( gDev -> IsPaletteDevice () ) - - hpo = SelectPalette ( hdcMem, ( HPALETTE )gDev -> HPalette (), FALSE ); - - i = myWNTWindow -> myImages -> Index ( - h = ::HashCode (anImageId, IntegerLast()) - ); - - if ( i == 0 ) i = myWNTWindow -> myImages -> Open ( hdc, Width, Height, h ); - - if ( Width > 0 && Height > 0 ) { - - Standard_Integer iX, iY; - Standard_Real sX, sY; - - myWNTWindow -> myImages -> Dim ( i, iX, iY ); - - if ( iX != Width || iY != Height ) { - - sX = Width / ( Standard_Real )iX; - sY = Height / ( Standard_Real )iY; - - myWNTWindow -> myImages -> Scale ( i, sX, sY, Standard_True ); - - } // end if - - hbo = SelectBitmap( - hdcMem, ( HBITMAP )myWNTWindow -> myImages -> ImageHandle ( i ) - ); - - for ( int i = 0; i < Height; ++i ) - - for ( int j = 0; j < Width; ++j, ++p ) { - - color.SetValues ( p -> r, p -> g, p -> b, Quantity_TOC_RGB ); - SetPixel ( hdcMem, j, i, gDev -> SetColor ( color ) ); - - } // end for - - SelectBitmap( hdcMem, hbo ); - - } // end if - - if ( hpo != NULL ) SelectPalette ( hdcMem, hpo, FALSE ); - - DeleteDC ( hdcMem ); - ReleaseDC ( ( HWND )myWNTWindow -> HWindow (), hdc ); - - DrawImage ( anImageId, aX, aY ); - -} // end WNT_WDriver :: FillAndDrawImage - -void WNT_WDriver :: FillAndDrawImage ( - const Handle( Standard_Transient )& anImageId, - const Standard_ShortReal aX, - const Standard_ShortReal aY, - const Standard_Integer anIndexOfLine, - const Standard_Integer Width, - const Standard_Integer Height, - const Standard_Address anArrayOfPixels - ) { - - HDC hdc, hdcMem; - HBITMAP hbo; - HPALETTE hpo = NULL; - Standard_Integer i, h; - Quantity_Color color; - PPIXEL2D p = ( PPIXEL2D )anArrayOfPixels; - Handle( WNT_GraphicDevice ) gDev = Handle( WNT_GraphicDevice ) :: - DownCast ( MyWindow -> GraphicDevice () ); - - hdc = GetDC ( ( HWND )myWNTWindow -> HWindow () ); - hdcMem = CreateCompatibleDC ( hdc ); - - if ( gDev -> IsPaletteDevice () ) - - hpo = SelectPalette ( hdcMem, ( HPALETTE )gDev -> HPalette (), FALSE ); - - i = myWNTWindow -> myImages -> Index ( - h = ::HashCode (anImageId, IntegerLast()) - ); - - if ( i == 0 ) i = myWNTWindow -> myImages -> Open ( hdc, Width, Height, h ); - - if ( Width > 0 && Height > 0 ) { - - Standard_Integer iX, iY; - Standard_Real sX, sY; - - myWNTWindow -> myImages -> Dim ( i, iX, iY ); - - if ( iX != Width || iY != Height ) { - - sX = Width / ( Standard_Real )iX; - sY = Height / ( Standard_Real )iY; - - myWNTWindow -> myImages -> Scale ( i, sX, sY, Standard_True ); - - } // end if - - hbo = SelectBitmap( - hdcMem, ( HBITMAP )myWNTWindow -> myImages -> ImageHandle ( i ) - ); - - for ( int j = 0; j < Width; ++j, ++p ) { - - color.SetValues ( p -> r, p -> g, p -> b, Quantity_TOC_RGB ); - SetPixel ( hdcMem, j, anIndexOfLine, gDev -> SetColor ( color ) ); - - } // end for - - SelectBitmap( hdcMem, hbo ); - - } // end if - - if ( hpo != NULL ) SelectPalette ( hdcMem, hpo, FALSE ); - - DeleteDC ( hdcMem ); - ReleaseDC ( ( HWND )myWNTWindow -> HWindow (), hdc ); - - if ( anIndexOfLine == Height - 1 ) DrawImage ( anImageId, aX, aY ); - -} // end WNT_WDriver :: FillAndDrawImage - -void WNT_WDriver :: DrawPolyline ( - const TShort_Array1OfShortReal& ListX, - const TShort_Array1OfShortReal& ListY - ) { - - Standard_Integer nPts = ListX.Length (); - - if ( nPts != ListY.Length () ) - - Aspect_DriverError :: Raise ( "DrawPolyline: incorrect argument" ); - - if ( nPts > 0 ) { - - Standard_Integer lX = ListX.Lower (); - Standard_Integer lY = ListY.Lower (); - - if ( A -> myPrimitive != zzNone ) ClosePrimitive (); - - W32_PolygonNote* p = ( W32_PolygonNote* )( A -> Polyline ( nPts ) ); - - for ( Standard_Integer i = 0; i < nPts; ++i ) - - p -> Add ( - P( ListX.Value ( lX + i ) ), - P( ListY.Value ( lY + i ) ) - ); - - } // end if - -} // end WNT_WDriver :: DrawPolyline - -void WNT_WDriver :: DrawPolygon ( - const TShort_Array1OfShortReal& ListX, - const TShort_Array1OfShortReal& ListY - ) { - - Standard_Integer nPts = ListX.Length (); - - if ( nPts != ListY.Length () ) - - Aspect_DriverError :: Raise ( "DrawPolygon: incorrect argument" ); - - if ( nPts > 0 ) { - - Standard_Integer lX = ListX.Lower (); - Standard_Integer lY = ListY.Lower (); - - if ( A -> myPrimitive != zzNone ) ClosePrimitive (); - - W32_PolygonNote* p = ( W32_PolygonNote* )( A -> Polygon ( nPts ) ); - - for ( Standard_Integer i = 0; i < nPts; ++i ) - - p -> Add ( - P( ListX.Value ( lX + i ) ), - P( ListY.Value ( lY + i ) ) - ); - - } // end if - -} // end WNT_WDriver :: DrawPolygon - -void WNT_WDriver :: DrawSegment ( - const Standard_ShortReal X1, - const Standard_ShortReal Y1, - const Standard_ShortReal X2, - const Standard_ShortReal Y2 - ) { - - A -> Line ( P( X1 ), P( Y1 ), P( X2 ), P( Y2 ) ); - -} // end WNT_WDriver :: DrawSegment - - -void WNT_WDriver :: DrawText ( - const TCollection_ExtendedString& Text, - const Standard_ShortReal Xpos, - const Standard_ShortReal Ypos, - const Standard_ShortReal anAngle, - const Aspect_TypeOfText aType - ) -{ -/*====================== MFT ====================*/ -#ifdef MFT - if ( UseMFT() ) { - MFT_DRAWTEXT dt = { - myAllocator, this, myPixelToUnit, - Xpos, Ypos, anAngle, 0., (int)aType, - FALSE, TRUE, Text.Length(), NULL - }; - CopyMemory (dt.theText, Text.ToExtString(), - Text.Length()*sizeof(short)); - A -> FunCall ( _Do_MFTDrawText_, sizeof(MFT_DRAWTEXT), - PW32_FCALLPARAM(&dt) ); - } else { -#endif -/*====================== MFT ====================*/ - char* str = _ConvertU2F ( Text ); - A -> Text ( - P( Xpos ), P( Ypos ), - anAngle, str, FALSE, - ( aType == Aspect_TOT_SOLID ) ? FALSE : TRUE - ); - HeapFree ( GetProcessHeap (), 0, str ); -/*====================== MFT ====================*/ -#ifdef MFT - } -#endif -/*====================== MFT ====================*/ -} // end WNT_WDriver :: DrawText - - -void WNT_WDriver :: DrawText ( - const Standard_CString Text, - const Standard_ShortReal Xpos, - const Standard_ShortReal Ypos, - const Standard_ShortReal anAngle, - const Aspect_TypeOfText aType - ) -{ -/*====================== MFT ====================*/ -#ifdef MFT - if ( UseMFT() ) { - MFT_DRAWTEXT dt = { - myAllocator, this, myPixelToUnit, - Xpos, Ypos, anAngle, 0., (int)aType, - FALSE, FALSE, lstrlen(Text), NULL - }; - CopyMemory (dt.theText, Text, lstrlen(Text)); - A -> FunCall ( _Do_MFTDrawText_, sizeof(MFT_DRAWTEXT), - PW32_FCALLPARAM(&dt) ); - } else -#endif -/*====================== MFT ====================*/ - A -> Text ( - P( Xpos ), P( Ypos ), anAngle, (Standard_Address)Text, FALSE, - ( aType == Aspect_TOT_SOLID ) ? FALSE : TRUE - ); -} // end WNT_WDriver :: DrawText - -void WNT_WDriver :: DrawPolyText ( - const TCollection_ExtendedString& aText, - const Standard_ShortReal Xpos, - const Standard_ShortReal Ypos, - const Quantity_Ratio aMarge, - const Standard_ShortReal anAngle, - const Aspect_TypeOfText aType - ) -{ -/*====================== MFT ====================*/ -#ifdef MFT - if ( UseMFT() ) { - MFT_DRAWTEXT dt = { - myAllocator, this, myPixelToUnit, - Xpos, Ypos, anAngle, aMarge, (int)aType, - TRUE, TRUE, aText.Length(), NULL - }; - CopyMemory (dt.theText, aText.ToExtString(), - aText.Length()*sizeof(short)); - A -> FunCall ( _Do_MFTDrawText_, sizeof(MFT_DRAWTEXT), - PW32_FCALLPARAM(&dt) ); - } else { -#endif -/*====================== MFT ====================*/ - char* str = _ConvertU2F ( aText ); - A -> Polytext ( - P( Xpos ), P( Ypos ), anAngle, aMarge, str, FALSE, - ( aType == Aspect_TOT_SOLID ) ? FALSE : TRUE - ); - HeapFree ( GetProcessHeap (), 0, str ); -/*====================== MFT ====================*/ -#ifdef MFT - } -#endif -/*====================== MFT ====================*/ -} // end WNT_WDriver :: DrawPolyText - -void WNT_WDriver :: DrawPolyText ( - const Standard_CString aText, - const Standard_ShortReal Xpos, - const Standard_ShortReal Ypos, - const Quantity_Ratio aMarge, - const Standard_ShortReal anAngle, - const Aspect_TypeOfText aType - ) -{ -/*====================== MFT ====================*/ -#ifdef MFT - if ( UseMFT() ) { - MFT_DRAWTEXT dt = { - myAllocator, this, myPixelToUnit, - Xpos, Ypos, anAngle, aMarge, (int)aType, - TRUE, FALSE, lstrlen(aText), NULL - }; - CopyMemory (dt.theText, aText, lstrlen(aText)); - A -> FunCall ( _Do_MFTDrawText_, sizeof(MFT_DRAWTEXT), - PW32_FCALLPARAM(&dt) ); - } else -#endif -/*====================== MFT ====================*/ - A -> Polytext ( - P( Xpos ), P( Ypos ), anAngle, aMarge, (Standard_Address)aText, FALSE, - ( aType == Aspect_TOT_SOLID ) ? FALSE : TRUE - ); - -} // end WNT_WDriver :: DrawPolyText - -void WNT_WDriver :: DrawPoint ( - const Standard_ShortReal X, - const Standard_ShortReal Y - ) -{ - switch ( A -> myPrimitive ) { - case zzPolygon: - ( ( W32_PolygonNote* )( A -> myNote ) ) -> Add ( P( X ), P( Y ) ); - break; - case zzPolyline: - ( ( W32_PolylineNote* )( A -> myNote ) ) -> Add ( P( X ), P( Y ) ); - break; - default: - A -> Point ( P( X ), P( Y ) ); - } // end switch -} // end WNT_WDriver :: DrawPoint - -void WNT_WDriver :: DrawMarker ( - const Standard_Integer aMarker, - const Standard_ShortReal Xpos, - const Standard_ShortReal Ypos, - const Standard_ShortReal Width, - const Standard_ShortReal Height, - const Standard_ShortReal Angle - ) { - - if ( A -> myPrimitive != zzNone && A -> myPrimitive != zzMarker ) ClosePrimitive (); - - int aWidth = P( Width ); - int aHeight = P( Height ); - - Standard_Integer theIndex = -1; -#ifdef PRO17334 - if( !myMarkerIdxs.IsNull() && - (aMarker >= myMarkerIdxs->Lower() && aMarker <= myMarkerIdxs->Upper()) ) - theIndex = myMarkerIdxs->Value(aMarker); - if( theIndex < 0 ) Aspect_DriverError::Raise ("Bad Marker Index") ; - - if ( aWidth && aHeight && (aMarker > 0) ) { -#else - if (aMarker >= myMarkerIdxs->Lower() || aMarker <= myMarkerIdxs->Upper()) - theIndex = myMarkerIdxs->Value(aMarker); - - if ( aWidth && aHeight && (theIndex >= 0) ) { -#endif - - - A -> BeginMarker ( P( Xpos ), P( Ypos ), aWidth, aHeight, Angle ); - - Aspect_MarkerStyle Style = MarkMap () -> Entry ( theIndex ).Style (); - - int MarkerSize = Style.Length (); - int DrawCount = 0; - int PrevPoint = 0; - int i; - MPARAM mp = { &Style, aWidth, aHeight }; - - for ( i = 2; i <= MarkerSize; ++i ) { - - if ( Style.SValues ().Value ( i ) ) { - - if ( Style.SValues ().Value ( i - 1 ) ) - - ++DrawCount; - - else { - - PrevPoint = i - 1; - DrawCount = 2; - - } // end else - - } else { - - if ( Style.SValues().Value ( i - 1 ) ) { - - if ( ( Style.XValues ().Value ( i ) == Style.XValues ().Value ( PrevPoint ) ) && - ( Style.YValues ().Value ( i ) == Style.YValues ().Value ( PrevPoint ) ) - ) - - A -> PolyMarker2 ( DrawCount, &_SetPoint, PrevPoint, &mp ); - - else - - A -> PolyMarker1 ( DrawCount, &_SetPoint, PrevPoint, &mp ); - - } // end if - - DrawCount = 0; - - } // end else - - } // end for - - --i; - - if ( DrawCount ) { - - if ( ( Style.XValues ().Value ( i ) == Style.XValues ().Value ( PrevPoint ) ) && - ( Style.YValues ().Value ( i ) == Style.YValues ().Value ( PrevPoint ) ) - ) - - A -> PolyMarker2 ( DrawCount, &_SetPoint, PrevPoint, &mp ); - - else - - A -> PolyMarker1 ( DrawCount, &_SetPoint, PrevPoint, &mp ); - - } // end if - - A -> EndMarker (); - - } else A -> MarkerPoint ( P( Xpos ), P( Ypos ) ); - -} // end WNT_WDriver :: DrawMarker - -Standard_Boolean WNT_WDriver :: DrawArc ( - const Standard_ShortReal X, - const Standard_ShortReal Y, - const Standard_ShortReal aXradius, - const Standard_ShortReal aYradius, - const Standard_ShortReal aStartAngle, - const Standard_ShortReal anOpenAngle - ) { - - if ( A -> myPrimitive != zzNone && A -> myPrimitive != zzArc ) - - ClosePrimitive (); - - if ( anOpenAngle >= 6.28318 ) - - A -> Ellipse ( P( X ), P( Y ), P( aXradius ), P( aYradius ) ); - - else - - A -> Arc ( - P( X ), P( Y ), P( aXradius ), P( aYradius ), - aStartAngle, anOpenAngle - ); - - return Standard_True; - -} // end WNT_WDriver :: DrawArc - -Standard_Boolean WNT_WDriver :: DrawPolyArc ( - const Standard_ShortReal X, - const Standard_ShortReal Y, - const Standard_ShortReal anXradius, - const Standard_ShortReal anYradius, - const Standard_ShortReal aStartAngle, - const Standard_ShortReal anOpenAngle - - ) { - - if ( A -> myPrimitive != zzNone && A -> myPrimitive != zzPolySector ) - - ClosePrimitive (); - - if ( anOpenAngle >= 6.28318 ) - - A -> PolyEllipse ( P( X ), P( Y ), P( anXradius ), P( anYradius ) ); - - else - - A -> PolySector ( - P( X ), P( Y ), P( anXradius ), P( anYradius ), - aStartAngle, anOpenAngle - ); - - return Standard_True; - -} // end WNT_WDriver :: DrawPolyArc - -void WNT_WDriver :: BeginPolyline ( const Standard_Integer aNumber ) { - - A -> myPrimitive = zzPolyline; - A -> myNote = A -> Polyline ( aNumber ); - -} // end WNT_WDriver :: BeginPolyline - -void WNT_WDriver :: BeginPolygon ( const Standard_Integer aNumber ) { - - A -> myPrimitive = zzPolygon; - A -> myNote = A -> Polygon ( aNumber ); - -} // end WNT_WDriver :: BeginPolygon - -void WNT_WDriver :: BeginSegments () { - - A -> myPrimitive = zzLine; - A -> myNote = NULL; - -} // end WNT_WDriver :: BeginSegments - -void WNT_WDriver :: BeginArcs () { - - A -> myPrimitive = zzArc; - A -> myNote = NULL; - -} // end WNT_WDriver :: BeginArcs - -void WNT_WDriver :: BeginPolyArcs () { - - A -> myPrimitive = zzPolySector; - A -> myNote = NULL; - -} // end WNT_WDriver :: BeginPolyArcs - -void WNT_WDriver :: BeginMarkers () { - - A -> myPrimitive = zzMarker; - A -> myNote = NULL; - -} // end WNT_WDriver :: BeginMarkers - -void WNT_WDriver :: BeginPoints () { - - A -> myPrimitive = zzPoint; - A -> myNote = NULL; - -} // end WNT_WDriver :: BeginPoints - -void WNT_WDriver :: ClosePrimitive () { - - A -> myPrimitive = zzNone; - A -> myNote = NULL; - -} // end WNT_WDriver :: ClosePrimitive - -void WNT_WDriver :: InitializeColorMap ( const Handle( Aspect_ColorMap) & Colormap ) -{ - Handle( WNT_GraphicDevice ) gDev = Handle( WNT_GraphicDevice ) :: - DownCast ( MyWindow -> GraphicDevice () ); - - Aspect_ColorMapEntry entry; - Standard_Integer i, minindex = IntegerLast(), maxindex = -minindex; - for (i = 1; i <= Colormap->Size (); i++) { - entry = Colormap->Entry (i); - maxindex = Max(maxindex, entry.Index ()); - minindex = Min(minindex, entry.Index ()); - } - - if ( myColors.IsNull () || myColors -> Length () != Colormap -> Size () ) - myColors = new WNT_HColorTable ( minindex, maxindex, (WNT_ColorRef)0x00000000 ); - - gDev -> MapColors ( Colormap, myColors ); -} // end WNT_WDriver :: InitializeColorMap - -void WNT_WDriver :: InitializeTypeMap ( const Handle( Aspect_TypeMap )& Typemap ) -{ - Aspect_TypeMapEntry entry; - Standard_Integer i, minindex = IntegerLast(), maxindex = -minindex; - for (i = 1; i <= Typemap->Size (); i++) { - entry = Typemap->Entry (i); - maxindex = Max(maxindex, entry.Index ()); - minindex = Min(minindex, entry.Index ()); - } - - myTypeIdxs = new TColStd_HArray1OfInteger (minindex, maxindex, 1); - for (i = 1; i <= Typemap->Size (); i++) { - entry = Typemap->Entry (i); - myTypeIdxs -> SetValue (entry.Index(), i); - } -} // end WNT_WDriver :: InitializeTypeMap - -void WNT_WDriver :: InitializeWidthMap ( const Handle( Aspect_WidthMap )& Widthmap ) -{ - Aspect_WidthMapEntry entry; - Standard_Integer i, minindex = IntegerLast(), maxindex = -minindex; - for (i = 1; i <= Widthmap->Size (); i++) { - entry = Widthmap->Entry (i); - maxindex = Max(maxindex, entry.Index ()); - minindex = Min(minindex, entry.Index ()); - } - - myWidthIdxs = new TColStd_HArray1OfInteger (minindex, maxindex, 1); - for (i = 1; i <= Widthmap->Size (); i++) { - entry = Widthmap->Entry (i); - myWidthIdxs -> SetValue (entry.Index(), i); - } -} // end WNT_WDriver :: InitializeWidthMap - -void WNT_WDriver :: InitializeFontMap ( const Handle( Aspect_FontMap )& Fontmap ) -{ - Aspect_FontStyle fontStyle; - Handle( WNT_FontMapEntry ) fmEntry; - Standard_Character left[ 260 ], right[ 250 ]; - Standard_PCharacter pSize; - Standard_Integer height, mapSize = Fontmap -> Size (); - HDC hdc = GetDC ( ( HWND )myWNTWindow -> HWindow () ); - HFONT hfo = SelectFont( hdc, GetStockObject ( DEFAULT_GUI_FONT ) ); - Standard_Integer i; -/*====================== MFT ====================*/ -#ifdef MFT - Aspect_FontMapEntry entry; - Aspect_FontStyle style; - Quantity_Length size; - Quantity_PlaneAngle slant; - TCollection_AsciiString aname; - if ( UseMFT() ) { - Handle(MFT_FontManager) theFontManager; - myMFTFonts = new WNT_HListOfMFTFonts (0, mapSize, theFontManager); - myMFTSizes = new TShort_HArray1OfShortReal (0, mapSize, 0.F); - } -#endif -/*====================== MFT ====================*/ - myFonts = new WNT_HFontTable ( 0, mapSize - 1 ); - for ( i = 0; i < mapSize; ++i ) { -/*====================== MFT ====================*/ -#ifdef MFT - if ( UseMFT() ) { - entry = Fontmap->Entry(i+1); - style = entry.Type (); - size = (Quantity_Length) TOMILLIMETER (style.Size()); - slant = style.Slant (); - if (style.CapsHeight()) size = -size; - aname = style.AliasName (); - Standard_Boolean found = MFT_FontManager::IsKnown (aname.ToCString()); - if (!found) { - cout << " WNT_WDriver::SetFontMap can't find the MFT font name '" - << aname << "', using 'Defaultfont'" << endl << flush; - aname = TCollection_AsciiString("Defaultfont"); - found = Standard_True; - } - if (found) { - Handle(MFT_FontManager) theFontManager; - Aspect_FontStyle theStyle = MFT_FontManager::Font (aname.ToCString()); - found = Standard_False; - for (int k = 0; k < mapSize; k++) { - theFontManager = myMFTFonts -> Value (k); - if (!theFontManager.IsNull()) { - if (theStyle == theFontManager->Font()) { - found = Standard_True; - break; - } - } - } - if (!found) - theFontManager = new MFT_FontManager (aname.ToCString()); - theFontManager->SetFontAttribs ( - Abs(size), Abs(size), slant, 0., Standard_Boolean(size < 0.) - ); - myMFTFonts->SetValue (i, theFontManager); - myMFTSizes->SetValue (i, (Standard_ShortReal)size); - } - } - if ( UseMFT() && !myMFTFonts->Value(i).IsNull()) - continue; -#endif -/*====================== MFT ====================*/ - fontStyle = Fontmap -> Entry ( i + 1 ).Type (); - height = Standard_Integer ( fontStyle.Size () / myPixelToUnit ); - lstrcpyA ( right,"-*-*-*-*-*-*-*-*-*-*-*-*-" ); - switch ( fontStyle.Style () ) { - case Aspect_TOF_HELVETICA: - lstrcatA ( right,"Arial" ); - break; - case Aspect_TOF_DEFAULT: - case Aspect_TOF_COURIER: - lstrcatA ( right, "Courier New" ); - break; - case Aspect_TOF_TIMES: - lstrcatA ( right,"Times New Roman" ); - break; - case Aspect_TOF_USERDEFINED: - lstrcpyA ( left, fontStyle.Value () ); - if ( strchr ( fontStyle.Value (), '-' ) ) { - height = atol ( pSize = strtok ( left, "-" ) ); - if ( height == 0 ) - height = Standard_Integer ( atof ( pSize ) / myPixelToUnit ); - if ( height == 0 ) - height = Standard_Integer ( fontStyle.Size () / myPixelToUnit ); - pSize = left + lstrlenA ( left ); - *pSize = '-'; - lstrcpyA ( right, pSize ); - } else lstrcatA ( right,left ); - } // end switch - height = Standard_Integer ( height * W32_TextFactor ); - ltoa ( height, left, 10 ); - lstrcatA ( left, right ); - fmEntry = new WNT_FontMapEntry ( left ); - if ( fontStyle.CapsHeight () ) { - double r; - TEXTMETRIC tm; - SelectFont( hdc, fmEntry -> HFont () ); - GetTextMetrics ( hdc, &tm ); - r = tm.tmAscent * tm.tmHeight / ( tm.tmAscent - tm.tmInternalLeading ); - lstrcpy ( right, strchr ( left, '-' ) ); - ltoa ( LONG( r + 0.5 ), left, 10 ); - lstrcatA ( left, right ); - fmEntry = new WNT_FontMapEntry ( left ); - } // end if - myFonts -> SetValue ( i, fmEntry ); - } // end for - SelectFont( hdc, hfo ); - ReleaseDC ( ( HWND )myWNTWindow -> HWindow (), hdc ); -} // end WNT_WDriver :: InitializeFontMap - -void WNT_WDriver :: InitializeMarkMap ( const Handle( Aspect_MarkMap )& Markmap ) -{ - Aspect_MarkMapEntry entry; - Standard_Integer i, minindex = IntegerLast(), maxindex = -minindex; - for (i = 1; i <= Markmap->Size (); i++) { - entry = Markmap->Entry (i); - maxindex = Max(maxindex, entry.Index ()); - minindex = Min(minindex, entry.Index ()); - } - - myMarkerIdxs = new TColStd_HArray1OfInteger (minindex, maxindex, -1); - for (i = 1; i <= Markmap->Size (); i++) { - entry = Markmap->Entry (i); - myMarkerIdxs -> SetValue (entry.Index(), i); - } -} // end WNT_WDriver :: InitializeMarkMap - -Standard_Address WNT_WDriver :: InternalOpenBuffer ( - const Standard_Integer aRetainBuffer, - const Standard_Boolean aMono, - const Standard_ShortReal aPivotX, - const Standard_ShortReal aPivotY, - const Standard_Integer aColorIndex, - const Standard_Integer aWidthIndex, - const Standard_Integer aTypeIndex, - const Standard_Integer aFontIndex, - const Aspect_TypeOfDrawMode aDrawMode - ) { - - PW32_Allocator aNew = NULL; - - MyDrawMode = aDrawMode; - aNew = _FindAllocator ( myAllocators, aRetainBuffer ); - - if ( aNew != NULL ) - - ClearBuffer ( aRetainBuffer ); - - else aNew = ( *W32_GetAllocator ) ( - aRetainBuffer, ( PW32_Allocator )myAllocators - ); - - aNew -> myPivot.x = P( aPivotX ); - aNew -> myPivot.y = P( aPivotY ); - - if ( aRetainBuffer ) { - - Standard_Address aSave = myAllocator; - myAllocator = ( Standard_Address )aNew; - - A -> myFlags |= ( W32F_MONO | W32F_MINIT ); - SetLineAttrib ( aColorIndex, aTypeIndex, aWidthIndex ); - SetTextAttrib ( aColorIndex, aFontIndex ); - SetPolyAttrib ( aColorIndex, -1, Standard_True ); - SetMarkerAttrib ( aColorIndex, aWidthIndex, Standard_False ); - A -> myFlags &= ~W32F_MINIT; - - myAllocator = aSave; - - } else A -> myFlags &= ~W32F_MONO; - - return aNew; - -} // end WNT_WDriver :: InternalOpenBuffer - -Standard_Boolean WNT_WDriver :: OpenBuffer ( - const Standard_Integer aRetainBuffer, - const Standard_ShortReal aPivotX, - const Standard_ShortReal aPivotY, - const Standard_Integer aWidthIndex, - const Standard_Integer aColorIndex, - const Standard_Integer aFontIndex, - const Aspect_TypeOfDrawMode aDrawMode - ) { - return ( Standard_Boolean )InternalOpenBuffer ( - aRetainBuffer, Standard_True, - aPivotX, aPivotY, aColorIndex, aWidthIndex, - 0, aFontIndex, aDrawMode - ); - -} // end WNT_WDriver :: OpenBuffer - -Standard_Boolean WNT_WDriver :: OpenColorBuffer ( - const Standard_Integer aRetainBuffer, - const Standard_ShortReal aPivotX, - const Standard_ShortReal aPivotY, - const Standard_Integer aWidthIndex, - const Standard_Integer aColorIndex, - const Standard_Integer aFontIndex, - const Aspect_TypeOfDrawMode aDrawMode - ) { - - return ( Standard_Boolean )InternalOpenBuffer ( - aRetainBuffer, Standard_False, - aPivotX, aPivotY, aColorIndex, aWidthIndex, - 0, aFontIndex, aDrawMode - ); - -} // end WNT_WDriver :: OpenColorBuffer - -void WNT_WDriver :: CloseBuffer ( const Standard_Integer aRetainBuffer ) const { - - if ( aRetainBuffer ) { - - PW32_Allocator a = _FindAllocator ( myAllocators, aRetainBuffer ); - - if ( a != NULL ) { - - PW32_Allocator b = ( PW32_Allocator )myAllocators; - - while ( b -> myNext != a ) b = b -> myNext; - - if ( a -> myFlags & W32F_DRAWN ) EraseBuffer ( aRetainBuffer ); - - b -> myNext = a -> myNext; - - delete a; - - } // end if - - SelectBuffer ( 0 ); - - } // end if - -} // end WNT_WDriver :: CloseBuffer - -void WNT_WDriver :: ClearBuffer ( const Standard_Integer aRetainBuffer ) const { - - PW32_Allocator a = _FindAllocator ( myAllocators, aRetainBuffer ); - - if ( a != NULL ) { - - if ( a -> myFlags & W32F_DRAWN ) EraseBuffer ( aRetainBuffer ); - - a -> ClearBlocks (); - - } // end if - -} // end WNT_WDriver :: ClearBuffer - -void WNT_WDriver :: DrawBuffer ( const Standard_Integer aRetainBuffer ) const { - - PW32_Allocator a = _FindAllocator ( myAllocators, aRetainBuffer ); - - if ( a != NULL ) { - - RECT r; - SIZE sz; - HPALETTE hpo = NULL; - HDC hdc = GetDC ( ( HWND )myWNTWindow -> HWindow () ); - - Handle( WNT_GraphicDevice ) gDev = Handle ( WNT_GraphicDevice ) :: - DownCast ( MyWindow -> GraphicDevice () ); - - if ( gDev -> IsPaletteDevice () ) - - hpo = SelectPalette ( hdc, ( HPALETTE )gDev -> HPalette (), FALSE ); - - GetClientRect ( ( HWND )myWNTWindow -> HWindow (), &r ); - sz.cx = r.right; - sz.cy = r.bottom; - - if ( a -> myFlags & W32F_DBUFF ) { - HDC hdcMem = CreateCompatibleDC ( hdc ); - HBITMAP hbo = SelectBitmap( hdcMem, ( HBITMAP )myWNTWindow -> HPixmap () ); - HPALETTE hpo; - - if ( gDev -> IsPaletteDevice () ) - - hpo = SelectPalette ( hdcMem, ( HPALETTE )gDev -> HPalette (), FALSE ); - - SetROP2 ( hdcMem, _GetROP2 ( MyDrawMode ) ); - - a -> Play ( hdcMem, &sz ); - - BitBlt ( - hdc, r.left, r.top, r.right + 1, r.bottom + 1, - hdcMem, r.left, r.top, SRCCOPY - ); - - if ( gDev -> IsPaletteDevice () ) SelectPalette ( hdcMem, hpo, FALSE ); - - SelectBitmap( hdcMem, hbo ); - DeleteDC ( hdcMem ); - } else { - SetROP2 ( hdc, _GetROP2 ( MyDrawMode ) ); - a -> Play ( hdc, &sz ); - } // end else - - if ( hpo != NULL ) SelectPalette( hdc, hpo, FALSE ); - - ReleaseDC ( ( HWND )myWNTWindow -> HWindow (), hdc ); - - a -> myFlags |= W32F_DRAWN; - - } // end if - -} // end WNT_WDriver :: DrawBuffer - -void WNT_WDriver :: EraseBuffer ( const Standard_Integer aRetainBuffer ) const { - - PW32_Allocator a = _FindAllocator ( myAllocators, aRetainBuffer ); - - if ( a != NULL && ( a -> myFlags & W32F_DRAWN ) ) { - - RECT r; - - a -> URect ( &r ); - - if ( !IsRectEmpty ( &r ) ) { - - if ( a -> myID != 0 ) { - - if ( MyWindow -> BackingStore () ) - - MyWindow -> RestoreArea ( - ( r.left + r.right ) / 2, ( r.top + r.bottom ) / 2, - r.right - r.left + 2, r.bottom - r.top + 2 - ); - - else if ( ( ( PW32_Allocator )myAllocators ) -> myFlags & W32F_DRAWN ) - - DrawBuffer ( 0 ); - - else -clear: - MyWindow -> ClearArea ( - ( r.left + r.right ) / 2, ( r.top + r.bottom ) / 2, - r.right - r.left + 2, r.bottom - r.top + 2 - ); - - } else goto clear; - - } // end if - - a -> myFlags &= ~W32F_DRAWN; - - } // end if - -} // end WNT_WDriver :: EraseBuffer - -void WNT_WDriver :: MoveBuffer ( - const Standard_Integer aRetainBuffer, - const Standard_ShortReal aPivotX, - const Standard_ShortReal aPivotY - ) const { - - PW32_Allocator a = _FindAllocator ( myAllocators, aRetainBuffer ); - - if ( a != NULL ) { - - BOOL fDrawn = a -> myFlags & W32F_DRAWN; - - if ( fDrawn ) EraseBuffer ( aRetainBuffer ); - - a -> myMove.x = P( aPivotX ) - a -> myPivot.x; - a -> myMove.y = P( aPivotY ) - a -> myPivot.y; - - if ( fDrawn ) DrawBuffer ( aRetainBuffer ); - - } // end if - -} // end WNT_WDriver :: MoveBuffer - -void WNT_WDriver :: ScaleBuffer ( - const Standard_Integer aRetainBuffer, - const Quantity_Factor aScaleX, - const Quantity_Factor aScaleY - ) const { - - PW32_Allocator a = _FindAllocator ( myAllocators, aRetainBuffer ); - - if ( a != NULL ) { - - BOOL fDrawn = a -> myFlags & W32F_DRAWN; - - if ( fDrawn ) EraseBuffer ( aRetainBuffer ); - - a -> myScaleX = aScaleX; - a -> myScaleY = aScaleY; - - if ( fDrawn ) DrawBuffer ( aRetainBuffer ); - - } // end if - -} // end WNT_WDriver :: ScaleBuffer - -void WNT_WDriver :: RotateBuffer ( - const Standard_Integer aRetainBuffer, - const Quantity_PlaneAngle anAngle - ) const { - - PW32_Allocator a = _FindAllocator ( myAllocators, aRetainBuffer ); - - if ( a != NULL ) { - - BOOL fDrawn = a -> myFlags & W32F_DRAWN; - - if ( fDrawn ) EraseBuffer ( aRetainBuffer ); - - a -> myAngle = anAngle; - - if ( fDrawn ) DrawBuffer ( aRetainBuffer ); - - } // end if - -} // end WNT_WDriver :: RotateBuffer - -void WNT_WDriver :: WorkSpace ( Quantity_Length& Width, Quantity_Length& Heigth ) const { - - RECT r; - - GetClientRect ( ( HWND )( myWNTWindow -> HWindow () ), &r ); - - Width = U( r.right ); - Heigth = U( r.bottom ); - -} // end WNT_WDriver :: WorkSpace - -Quantity_Length WNT_WDriver :: Convert ( const Standard_Integer PV ) const { - - return U( PV ); - -} // end WNT_WDriver :: Convert - -Standard_Integer WNT_WDriver :: Convert ( const Quantity_Length DV ) const { - - return P( DV ); - -} // end WNT_WDriver :: Convert - -void WNT_WDriver :: Convert ( - const Standard_Integer PX, - const Standard_Integer PY, - Quantity_Length& DX, - Quantity_Length& DY - ) const { - - RECT r; - GetClientRect ( ( HWND )myWNTWindow -> HWindow (), &r ); - - DX = U( PX ); - DY = U( r.bottom - PY ); - -} // end WNT_WDriver :: Convert - -void WNT_WDriver :: Convert ( - const Quantity_Length DX, - const Quantity_Length DY, - Standard_Integer& PX, - Standard_Integer& PY - ) const { - - RECT r; - GetClientRect ( ( HWND )myWNTWindow -> HWindow (), &r ); - - PX = P( DX ); - PY = r.bottom - P( DY ); - -} // end WNT_WDriver :: Convert - -Standard_Integer WNT_WDriver :: ProcessColorIndex ( - const Standard_Integer ColorIndex - ) const { - - if ( !SA ) return A -> myPointColor; - - if ( myColors.IsNull () ) return ( Standard_Integer )RGB( 0, 0, 0 ); - - Handle( WNT_GraphicDevice ) gDev = Handle( WNT_GraphicDevice ) :: - DownCast ( MyWindow -> GraphicDevice () ); - - if ( ColorIndex <= 0 ) { - - if ((A -> myFlags & W32F_MONO) && (A -> myFlags & W32F_MINIT)) { - return RGB(255, 255, 255); - } else { - LOGBRUSH lb; - GetObject ( myWNTWindow -> HBackground(), sizeof ( LOGBRUSH ), &lb ); - return lb.lbColor; - } - - } else - - switch ( MyDrawMode ) { - - default : - case Aspect_TODM_REPLACE : - - if (ColorIndex < myColors->Lower() || ColorIndex > myColors->Upper()) - return myColors -> Value ( myColors->Lower() ); - return myColors -> Value ( ColorIndex ); - - case Aspect_TODM_ERASE : - - return gDev -> SetColor ( MyWindow -> Background ().Color () ); - - case Aspect_TODM_XORLIGHT : - case Aspect_TODM_XOR : - - return gDev -> HighlightColor (); - - } // end switch - -} // end WNT_WDriver :: ProcessColorIndex - -Quantity_Length WNT_WDriver :: ProcessWidthIndex ( - const Standard_Integer WidthIndex - ) const -{ - Standard_Integer theIndex = WidthIndex; - if (WidthIndex < myWidthIdxs->Lower() || WidthIndex > myWidthIdxs->Upper()) - theIndex = myWidthIdxs->Lower(); - - Aspect_WidthMapEntry Entry = WidthMap () -> Entry ( myWidthIdxs -> Value(theIndex) ); - return ( Entry.Type () == Aspect_WOL_THIN ) ? - ( Quantity_Length )0.0 : Entry.Width () / myPixelToUnit; -} // end WNT_WDriver :: ProcessWidthIndex - -Standard_Integer WNT_WDriver :: ProcessTypeIndex ( - const Standard_Integer TypeIndex - ) const{ - - return ( TypeMap () -> Entry ( TypeIndex + 1 ).Type ().Style () == Aspect_TOL_SOLID ) ? - 0 : PS_USERSTYLE; - -} // end WNT_WDriver :: ProcessTypeIndex - -Standard_Boolean WNT_WDriver :: BufferIsOpen ( - const Standard_Integer aRetainBuffer - ) const { - - return ( _FindAllocator ( myAllocators, aRetainBuffer) != NULL ? - Standard_True : Standard_False - ); - -} // end WNT_WDriver :: BufferIsOpen - -Standard_Boolean WNT_WDriver :: BufferIsEmpty ( - const Standard_Integer aRetainBuffer - ) const { - - PW32_Allocator a = _FindAllocator ( myAllocators, aRetainBuffer ); - - if ( a != NULL ) - - return ( a -> myFlags & W32F_EMPTY ) ? Standard_True : Standard_False; - - return Standard_True; - -} // end WNT_WDriver :: BufferIsEmpty - -Standard_Boolean WNT_WDriver :: BufferIsDrawn ( - const Standard_Integer aRetainBuffer - ) const { - - PW32_Allocator a = _FindAllocator ( myAllocators, aRetainBuffer ); - - if ( a != NULL ) - - return ( a -> myFlags & W32F_DRAWN ) ? Standard_True : Standard_False; - - return Standard_False; - -} // end WNT_WDriver :: BufferIsDrawn - -void WNT_WDriver :: AngleOfBuffer ( - const Standard_Integer aRetainBuffer, - Quantity_PlaneAngle& anAngle - ) const { - - PW32_Allocator a = _FindAllocator ( myAllocators, aRetainBuffer ); - - if ( a != NULL ) anAngle = a -> myAngle; - -} // end WNT_WDriver :: AngleOfBuffer - -void WNT_WDriver :: ScaleOfBuffer ( - const Standard_Integer aRetainBuffer, - Quantity_Factor& aScaleX, - Quantity_Factor& aScaleY - ) const { - - PW32_Allocator a = _FindAllocator ( myAllocators, aRetainBuffer ); - - if ( a != NULL ) { - - aScaleX = a -> myScaleX; - aScaleY = a -> myScaleY; - - } // end if - -} // end WNT_WDriver :: ScaleOfBuffer - -void WNT_WDriver :: PositionOfBuffer ( - const Standard_Integer aRetainBuffer, - Standard_ShortReal& aPivotX, - Standard_ShortReal& aPivotY - ) const { - - PW32_Allocator a = _FindAllocator ( myAllocators, aRetainBuffer ); - - if ( a != NULL ) { - - aPivotX = Standard_ShortReal ( U( a -> myPivot.x + a -> myMove.x ) ); - aPivotY = Standard_ShortReal ( U( a -> myPivot.y + a -> myMove.y ) ); - - } // end if - -} // end WNT_WDriver :: PositionOfBuffer - -void WNT_WDriver :: TextSize ( - const TCollection_ExtendedString& aText, - Standard_ShortReal& aWidth, - Standard_ShortReal& aHeight, - const Standard_Integer aFontIndex - ) const { -#ifdef PRO17381 -if( aText.Length() <= 0 ) { - aWidth = aHeight = 0.; - return; -} -#endif - - Standard_ShortReal xoffset, yoffset; -/*====================== MFT ====================*/ -#ifdef MFT - if ( UseMFT() ) - TextSize (aText, aWidth, aHeight, xoffset, yoffset, aFontIndex); - else { -#endif -/*====================== MFT ====================*/ - - char* str = _ConvertU2F ( aText ); - - TextSize ( str, aWidth, aHeight, xoffset, yoffset, aFontIndex ); - - HeapFree ( GetProcessHeap (), 0, str ); - -/*====================== MFT ====================*/ -#ifdef MFT - } -#endif -/*====================== MFT ====================*/ -} // end WNT_WDriver :: TextSize - -void WNT_WDriver :: TextSize ( - const TCollection_ExtendedString& aText, - Standard_ShortReal& aWidth, - Standard_ShortReal& aHeight, - Standard_ShortReal& anXoffset, - Standard_ShortReal& anYoffset, - const Standard_Integer aFontIndex - ) const { -#ifdef PRO17381 -if( aText.Length() <= 0 ) { - aWidth = aHeight = anXoffset = anYoffset = 0.; - return; -} -#endif - -/*====================== MFT ====================*/ -#ifdef MFT - if ( UseMFT() ) { - Standard_Integer aFont = (aFontIndex < 0 ? - (int)A->myTextFont : aFontIndex); - Handle(MFT_FontManager) theFontManager = - ((WNT_WDriver *const)(this))->MFT_Font(aFont); - Standard_Real theWidth = 0.,theAscent = 0., - theLbearing = 0.,theDescent = 0.; - if (aText.IsAscii()) { - TCollection_AsciiString ascii (aText,'?'); - theFontManager->TextSize(ascii.ToCString(), theWidth, - theAscent, theLbearing, theDescent); - } else if (theFontManager->IsComposite()) { - theFontManager->TextSize(aText.ToExtString(), theWidth, - theAscent, theLbearing, theDescent); - } - theDescent = Max( - theDescent, (A->myFlags & W32F_TULIN ? - theFontManager->UnderlinePosition() : 0.)); - aWidth = Standard_ShortReal (theWidth ); - aHeight = Standard_ShortReal (theAscent + theDescent); - anXoffset = Standard_ShortReal (theLbearing ); - anYoffset = Standard_ShortReal (theDescent ); - } else { -#endif - char* str = ( char* )_ConvertU2F ( aText ); - - HDC hdc; - HFONT hfo; - SIZE sz; - int xo; - - hdc = GetDC ( ( HWND )myWNTWindow -> HWindow () ); - hfo = SelectFont( - hdc, - aFontIndex < 0 ? A -> myTextFont : ( HFONT )myFonts -> Value ( aFontIndex ) -> HFont () - ); - - xo = A -> TextSize ( hdc, str, &sz ); - aWidth = Standard_ShortReal ( U( sz.cx ) ); - aHeight = Standard_ShortReal ( U( sz.cy ) ); - - anXoffset = Standard_ShortReal ( U( xo ) ); - anYoffset = Standard_ShortReal ( 0.0 ); - - SelectFont( hdc, hfo ); - ReleaseDC ( ( HWND )myWNTWindow -> HWindow (), hdc ); - - HeapFree ( GetProcessHeap (), 0, str ); - -/*====================== MFT ====================*/ -#ifdef MFT - } -#endif -/*====================== MFT ====================*/ -} // end WNT_WDriver :: TextSize - -void WNT_WDriver :: TextSize ( - const Standard_CString aText, - Standard_ShortReal& aWidth, - Standard_ShortReal& aHeight, - Standard_ShortReal& anXoffset, - Standard_ShortReal& anYoffset, - const Standard_Integer aFontIndex - ) const { -#ifdef PRO17381 -if( !aText || (strlen(aText) <= 0) ) { - aWidth = aHeight = anXoffset = anYoffset = 0.; - return; -} -#endif - -/*====================== MFT ====================*/ -#ifdef MFT - if ( UseMFT() ) { - TCollection_ExtendedString extText (aText); - TextSize (extText, aWidth, aHeight, anXoffset, anYoffset, aFontIndex); - } else { -#endif -/*====================== MFT ====================*/ - HDC hdc; - HFONT hfo; - SIZE sz; - int xo; - - hdc = GetDC ( ( HWND )myWNTWindow -> HWindow () ); - hfo = SelectFont( - hdc, - aFontIndex < 0 ? A -> myTextFont : ( HFONT )myFonts -> Value ( aFontIndex ) -> HFont () - ); - - xo = A -> TextSize ( hdc, (Standard_PCharacter)aText, &sz ); - aWidth = Standard_ShortReal ( U( sz.cx ) ); - aHeight = Standard_ShortReal ( U( sz.cy ) ); - - anXoffset = Standard_ShortReal ( U( xo ) ); - anYoffset = Standard_ShortReal ( 0.0 ); - - SelectFont( hdc, hfo ); - ReleaseDC ( ( HWND )myWNTWindow -> HWindow (), hdc ); -/*====================== MFT ====================*/ -#ifdef MFT - } -#endif -/*====================== MFT ====================*/ -} // end WNT_WDriver :: TextSize - -Standard_CString WNT_WDriver :: FontSize ( - Quantity_PlaneAngle& aSlant, - Standard_ShortReal& aSize, - Standard_ShortReal& aBheight, - const Standard_Integer aFontIndex - ) const { - -/*====================== MFT ====================*/ -#ifdef MFT - if ( UseMFT() ) { - Standard_CString fstring; - Standard_Integer aFont = (aFontIndex < 0 ? - (int)A->myTextFont : aFontIndex); - Handle(MFT_FontManager) theFontManager = - myMFTFonts->Value (aFont); - Quantity_Length theWidth, theHeight, theDescent; - Quantity_PlaneAngle theSlant; - Quantity_Factor thePrecision; - Standard_Boolean theCapsHeight; - fstring = theFontManager->FontAttribs ( - theWidth, theHeight, theDescent, theSlant, thePrecision, theCapsHeight - ); - aSize = (Standard_ShortReal)theHeight; - aBheight = (Standard_ShortReal)theDescent; - aSlant = theSlant; - return fstring; - } else { -#endif -/*====================== MFT ====================*/ - if (aFontIndex < 0) - aSize = Standard_ShortReal ( U(myFonts->Value(0)->myLogFont.lfHeight) ); - else - aSize = Standard_ShortReal ( U(myFonts->Value(aFontIndex)->myLogFont.lfHeight) ); - aSize = Standard_ShortReal ( aSize / W32_TextFactor ); - aSlant = aFontIndex < 0 ? A -> myTextSlant : 0.0; - aBheight = 0.0F; - - return aFontIndex < 0 ? "" : myFonts->Value(aFontIndex)->myLogFont.lfFaceName; -/*====================== MFT ====================*/ -#ifdef MFT - } -#endif -/*====================== MFT ====================*/ -} // end WNT_WDriver :: FontSize - -void WNT_WDriver :: ColorBoundIndexs ( - Standard_Integer& aMinIndex, - Standard_Integer& aMaxIndex - ) const { - - if ( myColors.IsNull () ) { - - aMinIndex = - aMaxIndex = 0; - - } else { - - aMinIndex = 1; - aMaxIndex = myColors -> Length (); - - } // end else - -} // end WNT_WDriver :: ColorBoundIndexs - -Standard_Integer WNT_WDriver :: LocalColorIndex ( - const Standard_Integer anIndex - ) const { - - return ( anIndex < 1 || anIndex > myColors -> Length () ) ? -1 : anIndex; - -} // end WNT_WDriver :: LocalColorIndex - -void WNT_WDriver :: FontBoundIndexs ( - Standard_Integer& aMinIndex, - Standard_Integer& aMaxIndex - ) const { - - if ( myFonts.IsNull () ) { - - aMinIndex = - aMaxIndex = 0; - - } else { - - aMinIndex = 1; - aMaxIndex = myFonts -> Length (); - - } // end else - -} // end WNT_WDriver :: FontBoundIndexs - -Standard_Integer WNT_WDriver :: LocalFontIndex ( - const Standard_Integer anIndex - ) const { - - return ( anIndex < 1 || anIndex > myFonts -> Length () ) ? -1 : anIndex; - -} // end WNT_WDriver :: LocalFontIndex - -void WNT_WDriver :: TypeBoundIndexs ( - Standard_Integer& aMinIndex, - Standard_Integer& aMaxIndex - ) const { - - if ( TypeMap ().IsNull () ) { - - aMinIndex = - aMaxIndex = 0; - - } else { - - aMinIndex = 1; - aMaxIndex = TypeMap () -> Size (); - - } // end else - -} // end WNT_WDriver :: TypeBoundIndexs - -Standard_Integer WNT_WDriver :: LocalTypeIndex ( - const Standard_Integer anIndex - ) const { - - return ( anIndex < 1 || anIndex > TypeMap () -> Size () ) ? -1 : anIndex; - -} // end WNT_WDriver :: LocalTypeIndex - -void WNT_WDriver :: WidthBoundIndexs ( - Standard_Integer& aMinIndex, - Standard_Integer& aMaxIndex - ) const { - - if ( WidthMap ().IsNull () ) { - - aMinIndex = - aMaxIndex = 0; - - } else { - - aMinIndex = 1; - aMaxIndex = WidthMap () -> Size (); - - } // end else - -} // end WNT_WDriver :: WidthBoundIndexs - -Standard_Integer WNT_WDriver :: LocalWidthIndex ( - const Standard_Integer anIndex - ) const { - - return ( anIndex < 1 || anIndex > WidthMap () -> Size () ) ? -1 : anIndex; - -} // end WNT_WDriver :: LocalWidthIndex - -void WNT_WDriver :: MarkBoundIndexs ( - Standard_Integer& aMinIndex, - Standard_Integer& aMaxIndex - ) const { - - if ( MarkMap ().IsNull () ) { - - aMinIndex = - aMaxIndex = 0; - - } else { - - aMinIndex = 1; - aMaxIndex = MarkMap () -> Size (); - - } // end else - -} // end WNT_WDriver :: MarkBoundIndexs - -Standard_Integer WNT_WDriver :: LocalMarkIndex ( - const Standard_Integer anIndex - ) const { - - return ( anIndex < 1 || anIndex > MarkMap () -> Size () ) ? -1 : anIndex; - -} // end WNT_WDriver :: LocalMarkIndex - -const Handle(WNT_TextManager)& WNT_WDriver :: TextManager () -{ - return (myTextManager); -} // end WNT_WDriver :: TextManager - -const Handle(MFT_FontManager)& WNT_WDriver :: MFT_Font - (const Standard_Integer anIndex) -{ - return myMFTFonts->Value(anIndex); -} // end WNT_WDriver :: MFT_FontList - -Standard_ShortReal WNT_WDriver :: MFT_Size - (const Standard_Integer anIndex) -{ - return myMFTSizes->Value(anIndex); -} // end WNT_WDriver :: MFT_SizeList - -static PW32_Allocator __fastcall _FindAllocator ( Standard_Address p, Standard_Integer id ) { - - while ( p != NULL && ( ( PW32_Allocator )p ) -> myID != id ) - - p = ( ( PW32_Allocator )p ) -> myNext; - - return ( PW32_Allocator )p; - -} // end _FindAllocator - -static int __fastcall _GetROP2 ( Aspect_TypeOfDrawMode tdm ) { - - int retVal; - - switch ( tdm ) { - - case Aspect_TODM_ERASE: - case Aspect_TODM_REPLACE: - default: - - retVal = R2_COPYPEN; - - break; - - case Aspect_TODM_XOR: - case Aspect_TODM_XORLIGHT: - - retVal = R2_XORPEN; - - break; - - } // end switch - - return retVal; - -} // end _GetROP2 - -static void WINAPI _SetPoint ( int s, int m, int set, LPPOINT p, int* n, void* param ) { - - PMPARAM pmp = ( PMPARAM )param; - - *n = 0; - - for ( int i = 0; i < m; ++i, ++( *n ), ++s ) { - - p[ i ].x = LONG ( pmp -> s -> XValues ().Value ( s ) * pmp -> w / 2.0 + 0.5 ); - p[ i ].y = LONG ( pmp -> s -> YValues ().Value ( s ) * pmp -> h / 2.0 + 0.5 ); - - } // end for - -} // end _SetPoint - -static char* __fastcall _ConvertU2F ( const TCollection_ExtendedString& str ) { - - char* retVal; - Standard_Integer szBuff = ( str.Length () << 2 ); - - retVal = ( char* )HeapAlloc ( - GetProcessHeap (), HEAP_GENERATE_EXCEPTIONS, - szBuff - ); - - while ( !Resource_Unicode :: ConvertUnicodeToFormat ( str, retVal, szBuff ) ) { - - szBuff <<= 1; - retVal = ( char* )HeapReAlloc ( - GetProcessHeap (), HEAP_GENERATE_EXCEPTIONS, - retVal, szBuff - ); - - } // end while - - return retVal; - -} // end _ConvertU2F diff --git a/src/WNT/WNT_Window.cdl b/src/WNT/WNT_Window.cdl index 21a5cfe4c9..7c018591dd 100755 --- a/src/WNT/WNT_Window.cdl +++ b/src/WNT/WNT_Window.cdl @@ -590,7 +590,6 @@ class Window from WNT inherits Window from Aspect friends - class WDriver from WNT, class IconBox from WNT end Window; diff --git a/src/Xw/Xw.cdl b/src/Xw/Xw.cdl index 7c93708584..0c2efbedbd 100755 --- a/src/Xw/Xw.cdl +++ b/src/Xw/Xw.cdl @@ -38,8 +38,7 @@ uses Quantity, Image, TColQuantity, - MFT, - TColStd + TColStd is @@ -47,11 +46,6 @@ is -- Category: Classes -------------------- - class Driver; - ---Purpose: Creates the X driver. - -- Activates the c routines of the X interface. - ---Category: Classes - class Window; ---Purpose: Creates the X Window drawable. ---Category: Classes @@ -84,10 +78,6 @@ is ---Purpose: Creates the X Icon Box ---Category: Classes - class TextManager; - ---Purpose: Creates a text manager for MFT fonts. - ---Category: Classes - ------------------------- -- Category: Enumerations ------------------------- @@ -123,15 +113,6 @@ is end TypeOfMapping from Xw; ---Purpose: Definition of the colormap type - --------------------------------- - -- Category: Instantiated classes - --------------------------------- - - class ListOfMFTFonts instantiates - Array1 from TCollection (FontManager from MFT); - class HListOfMFTFonts instantiates - HArray1 from TCollection (FontManager from MFT, ListOfMFTFonts); - ----------------------------- -- Category: Trace management ----------------------------- diff --git a/src/Xw/Xw_Driver.cdl b/src/Xw/Xw_Driver.cdl deleted file mode 100755 index 11ce69f88b..0000000000 --- a/src/Xw/Xw_Driver.cdl +++ /dev/null @@ -1,858 +0,0 @@ --- Created on: 1993-07-01 --- Created by: Gerard GRAS --- Copyright (c) 1993-1999 Matra Datavision --- Copyright (c) 1999-2012 OPEN CASCADE SAS --- --- The content of this file is subject to the Open CASCADE Technology Public --- License Version 6.5 (the "License"). You may not use the content of this file --- except in compliance with the License. Please obtain a copy of the License --- at http://www.opencascade.org and read it completely before using this file. --- --- The Initial Developer of the Original Code is Open CASCADE S.A.S., having its --- main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. --- --- The Original Code and all software distributed under the License is --- distributed on an "AS IS" basis, without warranty of any kind, and the --- Initial Developer hereby disclaims all such warranties, including without --- limitation, any warranties of merchantability, fitness for a particular --- purpose or non-infringement. Please see the License for the specific terms --- and conditions governing the rights and limitations under the License. - - - -class Driver from Xw inherits WindowDriver from Aspect - - ---Version: - - ---Purpose: This class defines a X window Driver. - -- Warning: A Driver is associated with one window and lets you - -- draw any primitives with any attributes you choose - -- inside that window. All Values and coordinates are - -- defined in Device Window Unit (DWU) space, which is - -- the Normalized Floating Pixel space limited by the size - -- of the window. The Maps Driver must be initialized - -- with Aspect_Driver::SetXXXXMap(aMap) where XXXX - -- may correspond to Color, Mark, Type, Width and Font. - - ---References: - -uses - - ExtendedString from TCollection, - Length from Quantity, - Factor from Quantity, - Ratio from Quantity, - PlaneAngle from Quantity, - Array1OfShortReal from TShort, - TypeOfResize from Aspect, - TypeOfDrawMode from Aspect, - TypeOfText from Aspect, - TypeOfPrimitive from Aspect, - ColorMap from Aspect, - TypeMap from Aspect, - WidthMap from Aspect, - FontMap from Aspect, - MarkMap from Aspect, - TypeOfVisual from Xw, - Window from Xw, - HArray1OfInteger from TColStd, - HListOfMFTFonts from Xw, - HArray1OfShortReal from TShort, - TextManager from Xw - -raises - - DriverDefinitionError from Aspect, - DriverError from Aspect - -is - - ------------------------- - -- Category: Constructors - ------------------------- - - Create (aWindow: Window from Xw) - returns mutable Driver from Xw - raises DriverDefinitionError from Aspect; - ---Level: Public - ---Purpose: Creates the X Window Driver associated to the X window - -- . - -- Default values : - -- - DrawMode : TODM_REPLACE - - --------------------------------------------------- - -- Category: Methods to modify the class definition - --------------------------------------------------- - - BeginDraw (me: mutable; - DoubleBuffer: Boolean = Standard_True; - aRetainBuffer: Integer = 0) - ---Level: Public - ---Purpose: Begin graphics and drawn directly to the Window or Pixmap if - -- is 0 or in the retain buffer if > 0. - raises DriverError from Aspect is virtual; - ---Trigger: Raises if the retain buffer is not open. - -- call BufferIsOpen() method before. - ---Category: Methods to modify the class definition - - EndDraw (me: mutable; Synchronize: Boolean = Standard_False) is virtual; - ---Level: Public - ---Purpose: Called by the method Graphic2d_View::Update, this - -- method manages the buffer flushing and Wait after up to date - -- display when Synchronize is TRUE. - ---Category: Methods to modify the class definition - - - ResizeSpace (me : mutable) - returns TypeOfResize from Aspect - ---Level: Public - ---Purpose: Resizes the WorkSpace depending of the Window size - -- MUST be call after a Resize or Move WindowDriver Event - -- Returns the TypeOfResize gravity mode . - -- Trigger: Raises if the type of resizing is unknown. - raises DriverError from Aspect is virtual; - ---Category: Methods to modify the class definition - - --------------------------------------------- - -- Category: Methods to define the attributes - --------------------------------------------- - - InitializeColorMap (me: mutable; - Colormap: ColorMap from Aspect) - ---Level: Public - ---Purpose: Defines the color map. - -- Level: Public - -- Trigger: Raises if the definition failed. - raises DriverError from Aspect is virtual protected; - ---Category: Methods to define the color indices. - - InitializeTypeMap (me: mutable; - Typemap: TypeMap from Aspect) - ---Purpose: Defines the line type map. - -- Level: Public - -- Trigger: Raises if the definition failed. - raises DriverError from Aspect is virtual protected; - ---Category: Methods to define the type of line indices. - - InitializeWidthMap (me: mutable; - Widthmap: WidthMap from Aspect) - ---Purpose: Defines the width line map. - -- Level: Public - -- Trigger: Raises if the definition failed. - raises DriverError from Aspect is virtual protected; - ---Category: Methods to define the width of line indices. - - InitializeFontMap (me: mutable; - Fontmap: FontMap from Aspect) - ---Purpose: Defines the font map. - -- Level: Public - -- Trigger: Raises if the definition failed. - raises DriverError from Aspect is virtual protected; - ---Category: Methods to define the font indices. - - InitializeMarkMap (me: mutable; - Markmap: MarkMap from Aspect) - ---Purpose: Defines the mark map. - -- Level: Public - -- Trigger: Raises if the definition failed. - raises DriverError from Aspect is virtual protected; - ---Category: Methods to define the marker indices. - - --------------------------------------------- - -- Category: Methods to set the attributes - --------------------------------------------- - - SetDrawMode (me:mutable; aMode: TypeOfDrawMode from Aspect) is virtual; - ---Level: Advanced - ---Purpose: Defines the draw mode for all primitives drawing. - -- TypeOfDrawMode is - -- TODM_REPLACE - -- TODM_ERASE - -- TODM_XOR - -- TODM_XORLIGHT - - SetLineAttrib (me: mutable; - ColorIndex: Integer from Standard; - TypeIndex: Integer from Standard; - WidthIndex: Integer from Standard) - ---Level: Public - ---Purpose: Sets the line attributes. - -- Category: Methods to set the line attributes - -- Trigger: Raises if one of the index is out of range. - raises DriverError from Aspect is virtual; - - SetTextAttrib (me: mutable; - ColorIndex: Integer from Standard; - FontIndex: Integer from Standard) - ---Level: Public - ---Purpose: Sets the text attributes. - -- Category: Methods to set the text attributes - -- Trigger: Raises if one of the index is out of range. - raises DriverError from Aspect is virtual; - - SetTextAttrib (me: mutable; - ColorIndex: Integer from Standard; - FontIndex: Integer from Standard; - aSlant: PlaneAngle from Quantity; - aHScale: Factor from Quantity; - aWScale: Factor from Quantity; - isUnderlined: Boolean from Standard = Standard_False) - ---Level: Public - ---Purpose: Sets the Extended text attributes. - -- Category: Methods to set the text attributes - -- Trigger: Raises if one of the index is out of range. - raises DriverError from Aspect is virtual; - - SetPolyAttrib (me: mutable; - ColorIndex: Integer from Standard; - TileIndex: Integer from Standard; - DrawEdgeFlag: Boolean from Standard = Standard_False) - ---Level: Public - ---Purpose: Sets the polygon attributes. - -- Warning: - -- is the background poly color index. - -- is the background poly fill rule index. - -- If is TRUE the edge of the poly is drawn with the - -- current line attributes. - -- Category: Methods to set the poly attributes - -- Trigger: Raises if one of the index is out of range. - raises DriverError from Aspect is virtual; - - SetMarkerAttrib (me: mutable; - ColorIndex: Integer from Standard; - EdgeWidthIndex: Integer from Standard; - FillMarker: Boolean from Standard = Standard_False) - ---Level: Public - ---Purpose: Sets the marker attributes. - -- Warning: - -- is the edge or fill marker color index. - -- is the edge marker thickness index. - -- If is TRUE the marker is filled on the first set - -- of consecutive drawn points. - -- Category: Methods to set the marker attributes - -- Trigger: Raises if one of the index is out of range. - raises DriverError from Aspect is virtual; - - ----------------------------------------- - -- Category: Methods to manage the images - ----------------------------------------- - - IsKnownImage (me: mutable; anImage: Transient from Standard) - returns Boolean from Standard is virtual; - ---Level: Public - ---Purpose: Returns Standard_True if the associated driver - -- have stored the image and Standard_False if not. - ---Category: Methods to manage the images - - SizeOfImageFile (me; anImageFile: CString from Standard; - aWidth,aHeight: out Integer from Standard) - returns Boolean from Standard is virtual; - ---Level: Public - ---Purpose: Returns Standard_True and the Image Size in PIXEL - -- if the image file exist and can be computed by the driver, - -- NOTE that only XWD image file type are recognized today. - ---Category: Methods to manage the images - - ClearImage (me: mutable; anImageId: Transient from Standard) is virtual; - ---Level: Public - ---Purpose: Clears the image in . - ---Category: Methods to manage the images - - ClearImageFile (me: mutable; anImageFile: CString from Standard) - is virtual; - ---Level: Public - ---Purpose: Clears the image associated with the image file . - ---Category: Methods to manage the images - - DrawImage (me: mutable; anImageId: Transient from Standard; - aX, aY: ShortReal from Standard) - ---Level: Public - ---Purpose: Draws the image in . - -- , is the center of the image. - -- Image center must be defined in DWU space. - raises DriverError from Aspect is virtual; - ---Trigger: If the anImageId is not found - ---Category: Methods to manage the images - - DrawImageFile (me: mutable; anImageFile: CString from Standard; - aX, aY: ShortReal from Standard; - aScale: Factor from Quantity = 1.0) - ---Level: Public - ---Purpose: Draws the image file in . - -- , is the center of the image. - -- the scale factor which is apply on this image - -- Image center must be defined in DWU space. - -- anImageFile must be defined with the full pathname - -- of the form /..../xxxxx.ext or $DIR/xxxxxx.ext - -- with DIR defined in a setenv variable. - -- xxxxxx the image file name. - -- ext the image file extension. - raises DriverError from Aspect is virtual; - ---Trigger: If the anImageFile is not found - -- or the Image type is not an XWD. - ---Category: Methods to manage the images - - FillAndDrawImage (me: mutable; anImageId: Transient from Standard; - aX, aY: ShortReal from Standard; - Width, Height: Integer from Standard; - anArrayOfPixels: Address from Standard) - ---Level: Public - ---Purpose: Stores a complete image and draws it in . - -- Image size must be defined in DWU space> - -- Category: Methods to manage the images - -- Trigger: Raises if the creation of the image failed. - raises DriverError from Aspect is virtual; - - FillAndDrawImage (me: mutable; anImageId: Transient from Standard; - aX, aY: ShortReal from Standard; - anIndexOfLine, Width, Height: Integer from Standard; - anArrayOfPixels: Address from Standard) - ---Level: Advanced - ---Purpose: Stores a line of an image and draws it in . - -- Warning: 0<= anIndexOfLine < aHeight - -- anIndexOfLine = 0 must be the first call - -- Category: Methods to manage the images - -- Trigger: Raises if the creation of the image failed. - raises DriverError from Aspect is virtual; - - --------------------------------------- - -- Category: Methods to draw primitives - --------------------------------------- - - DrawPolyline (me : mutable; - ListX: Array1OfShortReal from TShort; - ListY: Array1OfShortReal from TShort) - ---Level: Public - ---Purpose: Draws the polyline depending of SetLineAttrib() attributes. - -- Warning: Coordinates must be defined in DWU space. - -- Trigger: Raises if Polyline has too many points (> 1024) - -- Raises if the length of is not equal to - -- the length of . - raises DriverError from Aspect is virtual; - ---Category: Methods to draw primitives - - DrawPolygon (me : mutable; - ListX: Array1OfShortReal from TShort; - ListY: Array1OfShortReal from TShort) - ---Level: Public - ---Purpose: Draws the polygone depending of SetPolyAttrib() attributes. - -- Warning: Coordinates must be defined in DWU space. - -- Trigger: Raises if Polygone has too many points (> 1024) - -- Raises if the length of is not equal to - -- the length of . - raises DriverError from Aspect is virtual; - ---Category: Methods to draw primitives - - DrawSegment (me : mutable; - X1, Y1: ShortReal from Standard; - X2, Y2: ShortReal from Standard) - ---Level: Public - ---Purpose: Draws the segment depending of SetLineAttrib() attributes. - -- Warning: Coordinates must be defined in DWU space. - raises DriverError from Aspect is virtual; - ---Category: Methods to draw primitives - - DrawText (me : mutable; - Text: ExtendedString from TCollection; - Xpos, Ypos: ShortReal from Standard; - anAngle: ShortReal from Standard = 0.0; - aType: TypeOfText from Aspect = Aspect_TOT_SOLID) - ---Level: Public - ---Purpose: Draws the text depending of SetTextAttrib() attributes. - -- Category: Methods to draw primitives - -- Warning: Coordinates must be defined in DWU space. - -- Trigger: Raises if Text has too many chars (> 1024) - raises DriverError from Aspect is virtual; - - DrawText (me : mutable; - Text: CString from Standard; - Xpos, Ypos: ShortReal from Standard; - anAngle: ShortReal from Standard = 0.0; - aType: TypeOfText from Aspect = Aspect_TOT_SOLID) - ---Level: Public - ---Purpose: Draws the text depending of SetTextAttrib() attributes. - -- Category: Methods to draw primitives - -- Warning: Coordinates must be defined in DWU space. - -- Angle must be defined in RADIAN. - -- Trigger: Raises if Text has too many chars (> 1024) - raises DriverError from Aspect is virtual; - - DrawPolyText (me : mutable; - aText: ExtendedString from TCollection; - Xpos: ShortReal from Standard; - Ypos: ShortReal from Standard; - aMarge: Ratio from Quantity = 0.1; - anAngle: ShortReal from Standard = 0.0; - aType: TypeOfText from Aspect = Aspect_TOT_SOLID) - ---Level: Public - ---Purpose: Draws an framed text depending of the - -- SetTextAttrib() and SetPolyAttrib() attributes. - -- Warning: Coordinates must be defined in DWU space. - -- defines the ratio of the space between the - -- polygon borders and the bounding box of the text and - -- depending of the height of the text. - raises DriverError from Aspect is virtual; - ---Trigger: Raises if Text has too many chars (> 1024) - -- or 1. - ---Category: Methods to draw primitives - - DrawPolyText (me : mutable; - aText: CString from Standard; - Xpos: ShortReal from Standard; - Ypos: ShortReal from Standard; - aMarge: Ratio from Quantity = 0.1; - anAngle: ShortReal from Standard = 0.0; - aType: TypeOfText from Aspect = Aspect_TOT_SOLID) - ---Level: Public - ---Purpose: Draws an framed text depending of the - -- SetTextAttrib() and SetPolyAttrib() attributes. - -- Warning: Coordinates must be defined in DWU space. - -- defines the ratio of the space between the - -- polygon borders and the bounding box of the text and - -- depending of the height of the text. - raises DriverError from Aspect is virtual; - ---Trigger: Raises if Text has too many chars (> 1024) - -- or 1. - ---Category: Methods to draw primitives - - DrawPoint (me : mutable; X, Y: ShortReal from Standard) - ---Level: Public - ---Purpose: Draws a 1 PIXEL point depending of the SetMarkerAttrib() - --color attribute or add a point depending of the incremental - --BeginXxxxxx() primitive used. - raises DriverError from Aspect is virtual; - ---Category: Methods to draw primitives - - DrawMarker (me : mutable; - aMarker: Integer from Standard; - Xpos, Ypos: ShortReal from Standard; - Width,Height: ShortReal from Standard; - Angle: ShortReal from Standard = 0.0) - ---Level: Public - ---Purpose: Draws the previously defined marker depending of - -- the SetMarkerAttrib() attributes. - -- Warning: Coordinates and sizes must be defined in DWU space. - -- Angle must be defined in RADIAN. - -- A one pixel marker is drawn when aMarker index is undefined. - raises DriverError from Aspect is virtual; - ---Category: Methods to draw primitives - - DrawArc (me : mutable; X,Y : ShortReal from Standard; - aXradius,aYradius : ShortReal from Standard; - aStartAngle: ShortReal from Standard = 0.0; - anOpenAngle: ShortReal from Standard = 6.283185) - returns Boolean - ---Level: Public - ---Purpose: Draws an Ellipsoid arc of center and Radius - -- of relative angle from - -- the base angle - -- Warning: Returns FALSE if the hardware can't drawing this - -- primitive properly,application must to simulate it. - raises DriverError from Aspect is virtual; - ---Trigger: Raises if one of is <= 0. - - DrawPolyArc (me : mutable; X,Y : ShortReal from Standard; - anXradius,anYradius : ShortReal from Standard; - aStartAngle: ShortReal from Standard = 0.0; - anOpenAngle: ShortReal from Standard = 6.283185) - returns Boolean - ---Level: Public - ---Purpose: Draws an filled Ellipsoid arc of center and Radius - -- of relative angle from - -- the base angle and depending of the SetPolyAttrib() - -- attributes. - -- Warning: Returns FALSE if the hardware can't drawing this - -- primitive properly,application must to simulate it. - raises DriverError from Aspect is virtual; - ---Trigger: Raises if one of is <= 0. - - BeginPolyline (me : mutable; aNumber : Integer) is virtual; - ---Level: Public - ---Purpose: Begin a polyline primitive of of points . - -- Warning: Points must be added by the DrawPoint() method. - - BeginPolygon (me : mutable; aNumber : Integer) is virtual; - ---Level: Public - ---Purpose: Begin a polygon primitive of of points . - -- Warning: Points must be added by the DrawPoint() method. - - BeginSegments (me : mutable) is virtual; - ---Level: Public - ---Purpose: Begin a set of segments . - -- Warning: Segments must be added by DrawSegment() method. - - BeginArcs (me : mutable) is virtual; - ---Level: Public - ---Purpose: Begin a set of circles or ellips . - -- Warning: Arcs must be added by the DrawArc() method. - - BeginPolyArcs (me : mutable) is virtual; - ---Level: Public - ---Purpose: Begin a set of polygon circles or ellips . - -- Warning: Arcs must be added by the DrawPolyArc() method. - - BeginMarkers (me : mutable) is virtual; - ---Level: Public - ---Purpose: Begin a set of markers . - -- Warning: Markers must be added by the DrawMarker() method. - - BeginPoints (me : mutable) is virtual; - ---Level: Public - ---Purpose: Begin a set of points . - -- Warning: Points must be added by the DrawPoint() method. - - ClosePrimitive (me : mutable) - ---Level: Public - ---Purpose: Close the last Begining primitive - raises DriverError from Aspect is virtual; - ---Trigger: Raises if no primitive have been opened by BeginXxxxxx(). - - --------------------------------------- - -- Category: Methods to Manage buffers - --------------------------------------- - - OpenBuffer (me : mutable; aRetainBuffer: Integer; - aPivotX: ShortReal = 0.0; - aPivotY: ShortReal = 0.0; - aWidthIndex: Integer = 0; - aColorIndex: Integer = 0; - aFontIndex: Integer = 0; - aDrawMode: TypeOfDrawMode = Aspect_TODM_REPLACE) - returns Boolean is virtual; - ---Purpose: Allocate the retain buffer , - -- Defines the DWU coordinates of the pivot point for all primitives - -- contains inside. - -- Defines the buffer color, line width and font index : - -- the default color is the highlight color of the colormap. - -- the default font is the default system font of the fontmap. - -- The other attributes are fixed : - -- line type is Solid, - -- line width is 1 Pixel, - -- polygon fill mode is Solid, - -- Warning: The number of allocated buffers is limited,it's - -- recommended to close unused buffers some time! - -- The TypeOfDrawMode REPLACE is enabled only if the - -- background drawing has been drawn with the DoubleBuffer - -- flag set to ENABLE at the last BeginDraw time. - -- The TypeOfDrawMode XOR is enabled in any case. - -- The other TypeOfDrawMode are not authorized. - -- Returns TRUE if the buffer is allocated and enabled for drawing. - - CloseBuffer (me; aRetainBuffer: Integer) - ---Purpose: Clear & Deallocate the retain buffer . - raises DriverError from Aspect is virtual; - ---Trigger: Raises if the retain buffer is not opened. - -- call BufferIsOpen() method before. - - ClearBuffer (me; aRetainBuffer: Integer) - ---Purpose: Erase & Clear ALL primitives retains in the buffer . - raises DriverError from Aspect is virtual; - ---Trigger: Raises if the retain buffer is not opened. - -- call BufferIsOpen() method before. - - DrawBuffer (me; aRetainBuffer: Integer) - ---Purpose: Draw ALL primitives retains in the buffer . - -- Warning: Note that the aspect of a retain buffer drawing is mono-colored - -- with the current buffer attributes and - -- depending of the DoubleBuffer state flag at the BeginDraw() buffer time, - -- when DB is TRUE,an XOR method is use for drawing and erasing buffers in the - -- same way.In this case,some color side effect can occurs depending of the - -- traversal primitive colors and the supported hardware. - -- when DB is FALSE and the background drawing has been generated with - -- DB at TRUE,no color side effect occurs because the DB is used for restoring - -- the drawing context at EraseBuffer() time,this is more powerfull for the - -- drawing quality excepted for large buffers (flicking) . - raises DriverError from Aspect is virtual; - ---Trigger: Raises if the retain buffer is not opened. - -- call BufferIsOpen() method before. - - EraseBuffer (me; aRetainBuffer: Integer) - ---Purpose: Erase ALL primitives retains in the buffer . - raises DriverError from Aspect is virtual; - ---Trigger: Raises if the retain buffer is not opened. - -- call BufferIsOpen() method before. - - MoveBuffer (me; aRetainBuffer: Integer; - aPivotX: ShortReal = 0.0; - aPivotY: ShortReal = 0.0) - ---Purpose: Erase , Translate and reDraw ALL primitives retains in the buffer - --. - -- are the new DWU attached point absolute coordinates - --of the buffer pivot point. - raises DriverError from Aspect is virtual; - ---Trigger: Raises if the retain buffer is not opened. - -- call BufferIsOpen() method before. - - ScaleBuffer (me; aRetainBuffer: Integer; aScaleX: Factor = 1.0; - aScaleY: Factor = 1.0) - ---Purpose: Erase , Scale the buffer from the Pivot point and reDraw ALL primitives - --retains in the buffer . - -- The transformation is relative since the creation time of the buffer. - -- are the relative scale factors apply on the two axis. - -- Warning: Note that the scalling of some primitives can provided some bad - --smoothing side effect (i.e: Circles,...) - raises DriverError from Aspect is virtual; - ---Trigger: Raises if the retain buffer is not opened or - --one of factor is <= 0. - -- call BufferIsOpen() method before. - - RotateBuffer (me; aRetainBuffer: Integer; anAngle: PlaneAngle = 0.0) - ---Purpose: Erase , Rotate the buffer from the Pivot point and reDraw ALL primitives - -- retains in the buffer . - -- The transformation is relative since the creation time of the buffer. - -- is the relative counter-clockwise rotation angle from the - -- Horizontal axis. - raises DriverError from Aspect is virtual; - ---Trigger: Raises if the retain buffer is not opened. - -- call BufferIsOpen() method before. - - ---------------------------- - -- Category: Inquire methods - ---------------------------- - - WorkSpace (me; Width, Heigth: out Length from Quantity) is virtual; - ---Level: Public - ---Purpose: Returns the Available WorkSpace in DWU coordinates - -- Category: Inquire methods - - TextSize (me; aText: ExtendedString from TCollection; - aWidth, aHeight: out ShortReal from Standard; - aFontIndex: Integer from Standard = -1) - raises DriverError from Aspect is virtual; - ---Level: Public - ---Purpose: Returns the TEXT size in DWU space depending - -- of the required FontIndex if aFontIndex is >= 0 - -- or the current FontIndex if < 0 (default). - ---Category: Inquire methods - - TextSize (me; aText: ExtendedString from TCollection; - aWidth, aHeight, anXoffset, anYoffset: out ShortReal from Standard; - aFontIndex: Integer from Standard = -1) - raises DriverError from Aspect is virtual; - ---Level: Public - ---Purpose: Returns the extended TEXT size and offsets - -- in DWU space depending - -- of the required FontIndex if aFontIndex is >= 0 - -- or the current FontIndex if < 0 (default). - -- NOTE that the text offsets defines the relative position of the - -- of the text string origin from the lower left corner of the text - -- boundary limits. - ---Category: Inquire methods - - TextSize (me; aText: CString from Standard; - aWidth, aHeight, anXoffset, anYoffset: out ShortReal from Standard; - aFontIndex: Integer from Standard = -1) - raises DriverError from Aspect is virtual; - ---Level: Public - ---Purpose: Returns the ascii TEXT size and offsets - -- in DWU space depending - -- of the required FontIndex if aFontIndex is >= 0 - -- or the current FontIndex if < 0 (default). - -- NOTE that the text offsets defines the relative position of the - -- of the text string origin from the lower left corner of the text - -- boundary limits. - ---Category: Inquire methods - - FontSize (me; aSlant: out PlaneAngle from Quantity; - aSize,aBheight: out ShortReal from Standard; - aFontIndex: Integer from Standard = -1) - returns CString from Standard - ---Trigger: Raises if font is not defined. - raises DriverError from Aspect is virtual; - ---Level: Public - ---Purpose: Returns the font string,slant,size and - -- baseline height in DWU space depending - -- of the required FontIndex if aFontIndex is >= 0 - -- or the current FontIndex if < 0 (default). - ---Category: Inquire methods - - Convert (me; PV: Integer from Standard) - returns Length from Quantity is virtual; - ---Level: Public - ---Purpose: Returns the DWU value depending of - -- the PIXEL value. - ---Category: Inquire methods - - Convert (me; DV: Length from Quantity) - returns Integer from Standard is virtual; - ---Level: Public - ---Purpose: Returns the PIXEL value depending of - -- the DWU value. - ---Category: Inquire methods - - Convert (me; PX, PY: Integer from Standard; - DX, DY: out Length from Quantity) is virtual; - ---Level: Public - ---Purpose: Returns the DWU position depending of - -- the PIXEL position . - ---Category: Inquire methods - - Convert (me; DX, DY: Length from Quantity; - PX, PY: out Integer from Standard) is virtual; - ---Level: Public - ---Purpose: Returns the PIXEL position depending of - -- the DWU position . - ---Category: Inquire methods - - BufferIsOpen(me; aRetainBuffer : Integer) returns Boolean is virtual; - ---Purpose: Returns TRUE if the retain buffer is enabled - --for drawing. - - BufferIsEmpty(me; aRetainBuffer : Integer) returns Boolean is virtual; - ---Purpose: Returns TRUE if the retain buffer has not been opened or empty. - --- Returns FALSE if a lot of primitives have been stored inside - -- because a BeginDraw(..,) has been done previously. - - BufferIsDrawn(me; aRetainBuffer : Integer) returns Boolean is virtual; - ---Purpose: Returns TRUE if the retain buffer s actually displayed at screen. - - AngleOfBuffer(me; aRetainBuffer : Integer; anAngle: out PlaneAngle) - ---Purpose: Returns the current buffer rotate angle from the X axis. - raises DriverError from Aspect is virtual; - ---Trigger: Raises if the retain buffer is not opened. - -- call BufferIsOpen() method before. - - ScaleOfBuffer(me; aRetainBuffer : Integer; aScaleX,aScaleY: out Factor) - ---Purpose: Returns the current buffer scale factors. - raises DriverError from Aspect is virtual; - ---Trigger: Raises if the retain buffer is not opened. - -- call BufferIsOpen() method before. - - PositionOfBuffer(me; aRetainBuffer : Integer; aPivotX,aPivotY: out ShortReal ) - ---Purpose: Returns the current buffer position. - raises DriverError from Aspect is virtual; - ---Trigger: Raises if the retain buffer is not opened. - -- call BufferIsOpen() method before. - - ColorBoundIndexs(me; aMinIndex,aMaxIndex : out Integer from Standard) - is virtual; - ---Level: Advanced - ---Purpose: - -- Returns the min and max driver virtual color indexs. - ---Category: Inquire methods - - LocalColorIndex(me; anIndex : Integer from Standard) - returns Integer from Standard is virtual; - ---Level: Advanced - ---Purpose: - -- Returns the local colormap hardware index from a virtual driver color - -- index or returns -1 if the index is not defined. - ---Category: Inquire methods - - FontBoundIndexs(me; aMinIndex,aMaxIndex : out Integer from Standard) - is virtual; - ---Level: Advanced - ---Purpose: - -- Returns the min and max driver virtual font indexs. - ---Category: Inquire methods - - LocalFontIndex(me; anIndex : Integer from Standard) - returns Integer from Standard is virtual; - ---Level: Advanced - ---Purpose: - -- Returns the associated fontmap hardware index from a virtual driver font - -- index or returns -1 if the index is not defined. - ---Category: Inquire methods - - TypeBoundIndexs(me; aMinIndex,aMaxIndex : out Integer from Standard) - is virtual; - ---Level: Advanced - ---Purpose: - -- Returns the min and max driver virtual type indexs. - ---Category: Inquire methods - - LocalTypeIndex(me; anIndex : Integer from Standard) - returns Integer from Standard is virtual; - ---Level: Advanced - ---Purpose: - -- Returns the associated typemap hardware index from a virtual driver type - -- index or returns -1 if the index is not defined. - ---Category: Inquire methods - - WidthBoundIndexs(me; aMinIndex,aMaxIndex : out Integer from Standard) - is virtual; - ---Level: Advanced - ---Purpose: - -- Returns the min and max driver virtual width indexs. - ---Category: Inquire methods - - LocalWidthIndex(me; anIndex : Integer from Standard) - returns Integer from Standard is virtual; - ---Level: Advanced - ---Purpose: - -- Returns the associated widthmap hardware index from a virtual driver width - -- index or returns -1 if the index is not defined. - ---Category: Inquire methods - - MarkBoundIndexs(me; aMinIndex,aMaxIndex : out Integer from Standard) - is virtual; - ---Level: Advanced - ---Purpose: - -- Returns the min and max driver virtual marker indexs. - ---Category: Inquire methods - - LocalMarkIndex(me; anIndex : Integer from Standard) - returns Integer from Standard is virtual; - ---Level: Advanced - ---Purpose: - -- Returns the local markmap hardware index from a virtual driver marker -- index or returns -1 if the index is not defined. - ---Category: Inquire methods - - ---------------------------- - -- Category: Private methods - ---------------------------- - - PrintError(myclass) is protected; - ---Purpose: Print last error or raise depending of the error gravity. - - DrawRectangle(me; Xpos,Ypos,Angle,Xoffset,Yoffset,Width,Height: - ShortReal from Standard) is private; - ---Purpose: Draw an oriented rectangle - - FillRectangle(me; Xpos,Ypos,Angle,Xoffset,Yoffset,Width,Height: - ShortReal from Standard) is private; - ---Purpose: Draw an oriented fill rectangle - -fields - - MyVisualClass: TypeOfVisual from Xw is protected; - MyExtendedDrawable: Address from Standard is protected; - MyExtendedColorMap: Address from Standard is protected; - MyExtendedTypeMap: Address from Standard is protected; - MyExtendedWidthMap: Address from Standard is protected; - MyExtendedFontMap: Address from Standard is protected; - MyExtendedMarkMap: Address from Standard is protected; - MyImage: Address from Standard is protected; - - MyLineColor: Integer from Standard is protected; - MyLineType: Integer from Standard is protected; - MyLineWidth: Integer from Standard is protected; - MyPolyColor: Integer from Standard is protected; - MyPolyType: Integer from Standard is protected; - MyPolyTile: Integer from Standard is protected; - MyTextColor: Integer from Standard is protected; - MyTextFont: Integer from Standard is protected; - MyTextType: Integer from Standard is protected; - MyTextHScale: Real from Standard is protected; - MyTextWScale: Real from Standard is protected; - MyTextHSize: Real from Standard is protected; - MyTextWSize: Real from Standard is protected; - MyTextSlant: Real from Standard is protected; - MyTextMinHeight: Real from Standard is protected; - MyTextIsUnderlined: Boolean from Standard is protected; - MyMarkerColor: Integer from Standard is protected; - MyMarkerType: Boolean from Standard is protected; - MyMarkerWidth: Integer from Standard is protected; - - MyColorIndexs: HArray1OfInteger from TColStd is protected; - MyTypeIndexs: HArray1OfInteger from TColStd is protected; - MyWidthIndexs: HArray1OfInteger from TColStd is protected; - MyFontIndexs: HArray1OfInteger from TColStd is protected; - MyMarkerIndexs: HArray1OfInteger from TColStd is protected; - - MyPrimitiveType: TypeOfPrimitive from Aspect is protected; - MyMFTFonts: HListOfMFTFonts from Xw is protected; - MyMFTSizes: HArray1OfShortReal from TShort is protected; - MyTextManager: TextManager from Xw is protected; - -end Driver from Xw; diff --git a/src/Xw/Xw_Driver.cxx b/src/Xw/Xw_Driver.cxx deleted file mode 100755 index 880ad8f3a6..0000000000 --- a/src/Xw/Xw_Driver.cxx +++ /dev/null @@ -1,1908 +0,0 @@ -// Copyright (c) 1995-1999 Matra Datavision -// Copyright (c) 1999-2012 OPEN CASCADE SAS -// -// The content of this file is subject to the Open CASCADE Technology Public -// License Version 6.5 (the "License"). You may not use the content of this file -// except in compliance with the License. Please obtain a copy of the License -// at http://www.opencascade.org and read it completely before using this file. -// -// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its -// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. -// -// The Original Code and all software distributed under the License is -// distributed on an "AS IS" basis, without warranty of any kind, and the -// Initial Developer hereby disclaims all such warranties, including without -// limitation, any warranties of merchantability, fitness for a particular -// purpose or non-infringement. Please see the License for the specific terms -// and conditions governing the rights and limitations under the License. - -/*********************************************************************** - - FONCTION : - ---------- - Classe Xw_Driver : - - HISTORIQUE DES MODIFICATIONS : - -------------------------------- - - 30-01-98 : GG ; SPEC_MFT - L'utilisation des polices MFT devient parametrable a travers - la methode Aspect_Driver::UseMFT(). - Le symbol CSF_USE_MFT n'est donc plus reconnu. - -***********************************************************************/ - -#define PRO5676 //GG_020197 -// Donner la possibillite d'exprimer la taille -// par rapport a la hauteur totale du caractere ou par -// rapport a la hauteur "ascent" situee au dessus de la -// ligne de base. -// (CapsHeight flag) - -#define CTS50024 //GG_090997 -// Attention avec les nouvelles machines SGI, -// le pitch vertical n'est pas identique au pitch horizontal. - -#define MFT //GG_220497 Etude G1343 -// Utilisation du FontManager MFT permettant de traiter -// les chaines de caracteres orientees et slantees. -// - -#define OPTIM1 //GG_180997 -// Optimisation du SKETCHER : -// remplacer les appels Xw_get_window_position() par -// Xw_get_window_size() qui est plus optimum. - - -#define PRO12934 //GG_060598 -// Eviter de "raiser" lorsqu'une erreur est detectee. -// - -#define PRO17334 //GG_050199 -// Raiser dans DrawMarker() lorsque l'index est hors limites - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -// Routines C a declarer en extern -//extern "C" { -#include -//} -typedef struct { float r, g, b; } GRAPHIC2D_PIXEL; - -//-Static data definitions - -static XW_STATUS status ; - -static Standard_ShortReal theSinAngle,theCosAngle; -#define TRANSFORM(X,Y) \ - { Standard_Real x = X,y = Y; \ - X = x*theCosAngle - y*theSinAngle; \ - Y = x*theSinAngle + y*theCosAngle; \ - } - -//============================================================================ -//==== HashCode : Returns a HashCode CString -//============================================================================ -inline Standard_Integer HashCode (const Standard_CString Value) -{ -Standard_Integer i,n,aHashCode = 0; -union { - char charPtr[80]; - int intPtr[20]; -} u; - - n = strlen(Value); - - if( n > 0 ) { - if( n < 80 ) { - n = (n+3)/4; - u.intPtr[n-1] = 0; - strcpy(u.charPtr,Value); - } else { - n = 20; - strncpy(u.charPtr,Value,80); - } - - for( i=0 ; i 2 ) Aspect_DriverError::Raise (ErrorMessag) ; - else Xw_print_error() ; -#endif - -} - -// Category: Constructors - -Xw_Driver::Xw_Driver (const Handle(Xw_Window)& aWindow) -: Aspect_WindowDriver(aWindow) { - - MyColorIndexs.Nullify() ; - MyTypeIndexs.Nullify() ; - MyWidthIndexs.Nullify() ; - MyFontIndexs.Nullify() ; - MyMarkerIndexs.Nullify() ; - - MyVisualClass = aWindow->VisualClass() ; - MyExtendedDrawable = aWindow->ExtendedWindow() ; - MyExtendedColorMap = aWindow->ExtendedColorMap() ; - MyExtendedTypeMap = aWindow->ExtendedTypeMap() ; - MyExtendedWidthMap = aWindow->ExtendedWidthMap() ; - MyExtendedFontMap = aWindow->ExtendedFontMap() ; - MyExtendedMarkMap = aWindow->ExtendedMarkMap() ; - MyImage = NULL; - MyDrawMode = Aspect_TODM_ERASE ; - MyPrimitiveType = Aspect_TOP_UNKNOWN ; - MyRetainBuffer = 0 ; -#ifdef MFT - MyTextManager = new Xw_TextManager(MyExtendedDrawable,MyExtendedWidthMap); -#endif - SetDrawMode(Aspect_TODM_REPLACE) ; -} - -// Category: Methods to modify the class definition - -void Xw_Driver::BeginDraw ( const Standard_Boolean DBmode, - const Standard_Integer aRetainBuffer ) { - - status = Xw_set_double_buffer(MyExtendedDrawable, - (XW_DOUBLEBUFFERMODE)DBmode) ; - - if( !status ) PrintError() ; - - status = Xw_set_buffer(MyExtendedDrawable,aRetainBuffer) ; - if( status ) { - MyRetainBuffer = aRetainBuffer ; - } else { - PrintError() ; - } -} - -void Xw_Driver::EndDraw (const Standard_Boolean Synchronize) { - - if( MyRetainBuffer != 0 ) { - MyRetainBuffer = 0 ; - status = Xw_set_buffer(MyExtendedDrawable,0) ; - // Reset attribs after filling buffer - Aspect_TypeOfDrawMode mode = MyDrawMode; - MyDrawMode = Aspect_TypeOfDrawMode(mode + 1); - SetDrawMode(mode); - } else { - status = Xw_flush (MyExtendedDrawable,Synchronize); - } - if( !status ) PrintError() ; -} - -Standard_Boolean Xw_Driver::OpenBuffer (const Standard_Integer aRetainBuffer, - const Standard_ShortReal aPivotX, - const Standard_ShortReal aPivotY, - const Standard_Integer WidthIndex, - const Standard_Integer ColorIndex, - const Standard_Integer FontIndex, - const Aspect_TypeOfDrawMode DrawMode) { -Standard_Integer theWidth = 0 ; -Standard_Integer theColor = 0 ; -Standard_Integer theFont = 0 ; -Standard_ShortReal xpivot = aPivotX ; -Standard_ShortReal ypivot = aPivotY ; -XW_DRAWMODE theDrawMode = (XW_DRAWMODE)DrawMode; - - if( !MyWidthIndexs.IsNull() ) { - if( WidthIndex > 0 && WidthIndex >= MyWidthIndexs->Lower() && - WidthIndex <= MyWidthIndexs->Upper() ) { - theWidth = MyWidthIndexs->Value(WidthIndex) ; - } - } - if( !MyColorIndexs.IsNull() ) { - if( ColorIndex > 0 && ColorIndex >= MyColorIndexs->Lower() && - ColorIndex <= MyColorIndexs->Upper() ) { - theColor = MyColorIndexs->Value(ColorIndex) ; - } - } - if( !MyFontIndexs.IsNull() ) { - if( FontIndex > 0 && FontIndex >= MyFontIndexs->Lower() && - FontIndex <= MyFontIndexs->Upper() ) { - theFont = MyFontIndexs->Value(FontIndex) ; - } - } - - status = Xw_open_buffer(MyExtendedDrawable,aRetainBuffer, - xpivot,ypivot,theWidth,theColor,theFont,theDrawMode) ; - - if( !status ) PrintError() ; - - return status; -} - -void Xw_Driver::CloseBuffer (const Standard_Integer aRetainBuffer) const { - - status = Xw_close_buffer(MyExtendedDrawable,aRetainBuffer) ; - - if( !status ) PrintError() ; -} - -void Xw_Driver::ClearBuffer (const Standard_Integer aRetainBuffer) const { - - status = Xw_clear_buffer(MyExtendedDrawable,aRetainBuffer) ; - - if( !status ) PrintError() ; -} - -void Xw_Driver::DrawBuffer (const Standard_Integer aRetainBuffer) const { - - status = Xw_draw_buffer(MyExtendedDrawable,aRetainBuffer) ; - - if( !status ) PrintError() ; -} - -void Xw_Driver::EraseBuffer (const Standard_Integer aRetainBuffer) const { - - status = Xw_erase_buffer(MyExtendedDrawable,aRetainBuffer) ; - - if( !status ) PrintError() ; -} - -void Xw_Driver::MoveBuffer (const Standard_Integer aRetainBuffer, - const Standard_ShortReal aPivotX, - const Standard_ShortReal aPivotY) const { -Standard_ShortReal xpivot = aPivotX ; -Standard_ShortReal ypivot = aPivotY ; - - status = Xw_move_buffer(MyExtendedDrawable,aRetainBuffer, - xpivot,ypivot) ; - - if( !status ) PrintError() ; -} - -void Xw_Driver::ScaleBuffer (const Standard_Integer aRetainBuffer, - const Quantity_Factor aScaleX, - const Quantity_Factor aScaleY) const { -Standard_ShortReal scalex = aScaleX; -Standard_ShortReal scaley = aScaleY; - - status = Xw_scale_buffer(MyExtendedDrawable,aRetainBuffer,scalex,scaley) ; - - if( !status ) PrintError() ; -} - -void Xw_Driver::RotateBuffer (const Standard_Integer aRetainBuffer, - const Quantity_PlaneAngle anAngle) const { -Standard_ShortReal angle = anAngle; - - status = Xw_rotate_buffer(MyExtendedDrawable,aRetainBuffer,angle) ; - - if( !status ) PrintError() ; -} - -Standard_Boolean Xw_Driver::BufferIsOpen (const Standard_Integer aRetainBuffer) const { -Standard_Integer isopen,isdrawn,isempty; - - status = Xw_get_buffer_status(MyExtendedDrawable,aRetainBuffer, - &isopen,&isdrawn,&isempty) ; - - return (isopen != 0 ? Standard_True : Standard_False); -} - -Standard_Boolean Xw_Driver::BufferIsEmpty (const Standard_Integer aRetainBuffer) const { -Standard_Integer isopen,isdrawn,isempty; - - status = Xw_get_buffer_status(MyExtendedDrawable,aRetainBuffer, - &isopen,&isdrawn,&isempty) ; - if( !status ) PrintError() ; - - return (isempty != 0 ? Standard_True : Standard_False); -} - -Standard_Boolean Xw_Driver::BufferIsDrawn (const Standard_Integer aRetainBuffer) const { -Standard_Integer isopen,isdrawn,isempty; - - status = Xw_get_buffer_status(MyExtendedDrawable,aRetainBuffer, - &isopen,&isdrawn,&isempty) ; - if( !status ) PrintError() ; - - return (isdrawn != 0 ? Standard_True : Standard_False); -} - -void Xw_Driver::SetDrawMode (const Aspect_TypeOfDrawMode aMode) { - - if( MyDrawMode != aMode ) { - MyDrawMode = aMode; - MyLineColor = -1 ; - MyLineType = -1 ; - MyLineWidth = -1 ; - MyPolyColor = -1 ; - MyPolyType = Standard_False ; - MyPolyTile = 0 ; - MyTextColor = -1 ; - MyTextType = 0 ; - MyTextFont = -1 ; - MyTextHScale = 1. ; - MyTextWScale = 1. ; - MyTextSlant = 0. ; - MyTextIsUnderlined = Standard_False; - MyMarkerColor = -1 ; - MyMarkerType = Standard_False ; - MyMarkerWidth = -1 ; - } -} - -Aspect_TypeOfResize Xw_Driver::ResizeSpace () { -XW_RESIZETYPE mode = Xw_resize_window(MyExtendedDrawable) ; - - if ( Window()->HBackground() ) - status = Xw_update_background_image( MyExtendedDrawable ); - if( mode == XW_TOR_UNKNOWN ) PrintError() ; - - if( mode != XW_NO_BORDER ) { - MyTextColor = -1 ; - } - - return (Aspect_TypeOfResize(mode)) ; -} - -// Category: Methods to define the attributes - -void Xw_Driver::InitializeColorMap (const Handle(Aspect_ColorMap)& Colormap) { -Aspect_ColorMapEntry entry ; -Quantity_Color color ; -Standard_Integer index,iindex,oindex,minindex=IntegerLast(),maxindex= -minindex; -Standard_Real red,green,blue ; -int hindex ; - - if( !Xw_isdefine_colormap(MyExtendedColorMap) ) PrintError() ; - - for( index=1 ; index<=Colormap->Size() ; index++ ) { - entry = Colormap->Entry(index) ; - maxindex = Max(maxindex,entry.Index()) ; - minindex = Min(minindex,entry.Index()) ; - } - - MyColorIndexs = new TColStd_HArray1OfInteger(minindex,maxindex,-1) ; - - for( index=1 ; index<=Colormap->Size() ; index++ ) { - entry = Colormap->Entry(index) ; - iindex = entry.Index() ; - color = entry.Color() ; - color.Values(red,green,blue,Quantity_TOC_RGB) ; - status = Xw_get_color_index(MyExtendedColorMap,(float)red, - (float)green, - (float)blue, - &hindex) ; - oindex = hindex ; - MyColorIndexs->SetValue(iindex,oindex) ; - } -} - -void Xw_Driver::InitializeTypeMap (const Handle(Aspect_TypeMap)& Typemap) { -Aspect_TypeMapEntry entry ; -Aspect_LineStyle style ; -Aspect_TypeOfLine type ; -Standard_Integer index,iindex,oindex,minindex=IntegerLast(),maxindex= -minindex; -Standard_Integer i ; -int hindex,length ; -float *vstyle ; - - if( !Xw_isdefine_typemap(MyExtendedTypeMap) ) PrintError() ; - - for( index=1 ; index<=Typemap->Size() ; index++ ) { - entry = Typemap->Entry(index) ; - maxindex = Max(maxindex,entry.Index()) ; - minindex = Min(minindex,entry.Index()) ; - } - - MyTypeIndexs = new TColStd_HArray1OfInteger(minindex,maxindex,-1) ; - - for( index=1 ; index<=Typemap->Size() ; index++ ) { - entry = Typemap->Entry(index) ; - iindex = entry.Index() ; - style = entry.Type() ; - type = style.Style() ; - length = (int) style.Length() ; - if( type != Aspect_TOL_SOLID ) { - const TColQuantity_Array1OfLength& values(style.Values()) ; - TShort_Array1OfShortReal - svalues(values.Lower(),values.Length()) ; - for( i=values.Lower() ; i<=values.Upper() ; i++ ) - svalues(i) = TOMILLIMETER(Standard_ShortReal(values(i))) ; - - vstyle = (float*) &svalues.Value(values.Lower()) ; - status = Xw_get_type_index(MyExtendedTypeMap,vstyle,length, - &hindex) ; - oindex = hindex ; - } else oindex = 0 ; - MyTypeIndexs->SetValue(iindex,oindex) ; - } -} - -void Xw_Driver::InitializeWidthMap (const Handle(Aspect_WidthMap)& Widthmap) { -Aspect_WidthMapEntry entry ; -Standard_Integer index,iindex,oindex,minindex=IntegerLast(),maxindex= -minindex; -int hindex ; -float width ; - - if( !Xw_isdefine_widthmap(MyExtendedWidthMap) ) PrintError() ; - - for( index=1 ; index<=Widthmap->Size() ; index++ ) { - entry = Widthmap->Entry(index) ; - maxindex = Max(maxindex,entry.Index()) ; - minindex = Min(minindex,entry.Index()) ; - } - - MyWidthIndexs = new TColStd_HArray1OfInteger(minindex,maxindex,-1) ; - - for( index=1 ; index<=Widthmap->Size() ; index++ ) { - entry = Widthmap->Entry(index) ; - iindex = entry.Index() ; - width = (float) TOMILLIMETER(entry.Width()) ; - status = Xw_get_width_index(MyExtendedWidthMap,width,&hindex) ; - oindex = hindex ; - MyWidthIndexs->SetValue(iindex,oindex) ; - } -} - -void Xw_Driver::InitializeFontMap (const Handle(Aspect_FontMap)& Fontmap) { -Aspect_FontMapEntry entry ; -Aspect_FontStyle style ; -Standard_Integer index,iindex,oindex,minindex=IntegerLast(),maxindex= -minindex; -int hindex ; -float size,slant ; -//char env[64]; - - if( !Xw_isdefine_fontmap(MyExtendedFontMap) ) PrintError() ; - - for( index=1 ; index<=Fontmap->Size() ; index++ ) { - entry = Fontmap->Entry(index) ; - maxindex = Max(maxindex,entry.Index()) ; - minindex = Min(minindex,entry.Index()) ; - } - -#ifdef MFT - if( UseMFT() ) { - MyMFTFonts = new Xw_HListOfMFTFonts(minindex,maxindex,NULL) ; - MyMFTSizes = new TShort_HArray1OfShortReal(minindex,maxindex,0.) ; - } -#endif - - MyFontIndexs = new TColStd_HArray1OfInteger(minindex,maxindex,-1) ; - - for( index=1 ; index<=Fontmap->Size() ; index++ ) { - entry = Fontmap->Entry(index) ; - iindex = entry.Index() ; - style = entry.Type() ; - size = (float) TOMILLIMETER(style.Size()) ; - slant = style.Slant() ; -#ifdef PRO5676 - if( style.CapsHeight() ) size = -size; -#endif -#ifdef MFT - if( UseMFT() ) { - TCollection_AsciiString aname(style.AliasName()); - Standard_Boolean found = MFT_FontManager::IsKnown(aname.ToCString()); - if( !found ) { - cout << " Xw_Driver::SetFontMap.cann't found the MFT fontname '" - << aname << "',using 'Defaultfont'" << endl; - aname = "Defaultfont"; found = Standard_True; - } - if( found ) { - Handle(MFT_FontManager) theFontManager; - Aspect_FontStyle fstyle = MFT_FontManager::Font(aname.ToCString()); - found = Standard_False; - for( Standard_Integer i=minindex ; i<=maxindex ; i++ ) { - theFontManager = MyMFTFonts->Value(i); - if( !theFontManager.IsNull() ) { - if( fstyle == theFontManager->Font() ) { - found = Standard_True; - break; - } - } - } - if( !found ) { - theFontManager = new MFT_FontManager(aname.ToCString()); - } - Quantity_Length theFontSize = Abs(size); - Quantity_PlaneAngle theFontSlant = slant; - Standard_Boolean theCapsHeight = - (size < 0.) ? Standard_True : Standard_False; - theFontManager->SetFontAttribs(theFontSize,theFontSize, - theFontSlant,0.,theCapsHeight); - MyFontIndexs->SetValue(iindex,-1) ; - MyMFTFonts->SetValue(iindex,theFontManager); - MyMFTSizes->SetValue(iindex,size); - continue; - } - } -#endif - TCollection_AsciiString aname(style.FullName()) ; - status = Xw_get_font_index(MyExtendedFontMap, - size, - (Standard_PCharacter)aname.ToCString(), - &hindex) ; - oindex = hindex ; - MyFontIndexs->SetValue(iindex,oindex) ; - } -} - -void Xw_Driver::InitializeMarkMap (const Handle(Aspect_MarkMap)& Markmap) { -Aspect_MarkMapEntry entry ; -Aspect_MarkerStyle style ; -Aspect_TypeOfMarker type ; -Standard_Integer index,iindex,oindex,minindex=IntegerLast(),maxindex= -minindex; -int hindex,length ; - - if( !Xw_isdefine_markmap(MyExtendedMarkMap) ) PrintError() ; - - for( index=1 ; index<=Markmap->Size() ; index++ ) { - entry = Markmap->Entry(index) ; - maxindex = Max(maxindex,entry.Index()) ; - minindex = Min(minindex,entry.Index()) ; - } - - MyMarkerIndexs = new TColStd_HArray1OfInteger(minindex,maxindex,-1) ; - - for( index=1 ; index<=Markmap->Size() ; index++ ) { - entry = Markmap->Entry(index) ; - iindex = entry.Index() ; - style = entry.Style() ; - type = style.Type() ; - length = style.Length() ; - const TColStd_Array1OfBoolean& spoint(style.SValues()); - const TShort_Array1OfShortReal& xpoint(style.XValues()); - const TShort_Array1OfShortReal& ypoint(style.YValues()); - int *S = (int*) &spoint.Value(spoint.Lower()); - float *X = (float*) &xpoint.Value(xpoint.Lower()); - float *Y = (float*) &ypoint.Value(ypoint.Lower()); - status = Xw_get_marker_index(MyExtendedMarkMap,length, - S,X,Y,&hindex) ; - oindex = hindex ; - MyMarkerIndexs->SetValue(iindex,oindex) ; - } -} - -void Xw_Driver::SetLineAttrib (const Standard_Integer ColorIndex, const Standard_Integer TypeIndex, const Standard_Integer WidthIndex) { -Standard_Boolean setattrib = Standard_False; - - if( MyLineColor != ColorIndex ) { - setattrib = Standard_True; - if( !MyColorIndexs.IsNull() ) { - if( ColorIndex < MyColorIndexs->Lower() || - ColorIndex > MyColorIndexs->Upper() ) { - MyLineColor = MyColorIndexs->Lower(); - Aspect_DriverError::Raise ("Bad Color Index") ; - } else MyLineColor = ColorIndex; - } else MyLineColor = -1; - } - if( MyLineType != TypeIndex ) { - setattrib = Standard_True; - if( !MyTypeIndexs.IsNull() ) { - if( TypeIndex < MyTypeIndexs->Lower() || - TypeIndex > MyTypeIndexs->Upper() ) { - MyLineType = MyTypeIndexs->Lower(); - Aspect_DriverError::Raise ("Bad Type Index") ; - } else MyLineType = TypeIndex; - } else MyLineType = -1; - } - if( MyLineWidth != WidthIndex ) { - setattrib = Standard_True; - if( !MyWidthIndexs.IsNull() ) { - if( WidthIndex < MyWidthIndexs->Lower() || - WidthIndex > MyWidthIndexs->Upper() ) { - MyLineWidth = MyWidthIndexs->Lower(); - Aspect_DriverError::Raise ("Bad Width Index") ; - } else MyLineWidth = WidthIndex; - } else MyLineWidth = -1; - } - - if( setattrib ) { - Standard_Integer color ; - Standard_Integer type = (MyLineType < 0) ? 0 : - MyTypeIndexs->Value(MyLineType) ; - Standard_Integer width = (MyLineWidth < 0) ? 0 : - MyWidthIndexs->Value(MyLineWidth) ; - - if( MyLineColor > 0 ) { - color = MyColorIndexs->Value(MyLineColor) ; - } else { - status = Xw_get_background_index(MyExtendedDrawable,&color) ; - } - XW_ATTRIB attrib = Xw_set_line_attrib (MyExtendedDrawable,color,type,width, - XW_DRAWMODE (MyDrawMode)); - if( !attrib ) PrintError() ; - } - -} - -void Xw_Driver::SetPolyAttrib (const Standard_Integer ColorIndex, const Standard_Integer TileIndex, const Standard_Boolean DrawEdge) { -Standard_Boolean setattrib = Standard_False; - - if( MyPolyColor != ColorIndex ) { - setattrib = Standard_True; - if( !MyColorIndexs.IsNull() ) { - if( (TileIndex >= 0) && (ColorIndex < MyColorIndexs->Lower() || - ColorIndex > MyColorIndexs->Upper()) ) { - MyPolyColor = MyColorIndexs->Lower(); - Aspect_DriverError::Raise ("Bad Color Index") ; - } else MyPolyColor = ColorIndex; - } else MyPolyColor = -1; - } - if( MyPolyTile != TileIndex ) { - setattrib = Standard_True; - MyPolyTile = TileIndex; - } - if( MyPolyType != (int ) DrawEdge ) { - setattrib = Standard_True; - MyPolyType = DrawEdge; - } - - if( setattrib ) { - Standard_Integer color ; - Standard_Integer type = MyPolyType ; - Standard_Integer tile = MyPolyTile ; - - if( MyPolyColor > 0 ) { - color = MyColorIndexs->Value(MyPolyColor) ; - } else { - status = Xw_get_background_index(MyExtendedDrawable,&color) ; - } - XW_ATTRIB attrib = Xw_set_poly_attrib (MyExtendedDrawable,color,type,tile, - XW_DRAWMODE (MyDrawMode)); - if( !attrib ) PrintError() ; - } - -} - -void Xw_Driver::SetTextAttrib (const Standard_Integer ColorIndex, const Standard_Integer FontIndex) { -Standard_Boolean setattrib = Standard_False; - - if( MyTextColor != ColorIndex ) { - setattrib = Standard_True; - if( !MyColorIndexs.IsNull() ) { - if( ColorIndex < MyColorIndexs->Lower() || - ColorIndex > MyColorIndexs->Upper() ) { - MyTextColor = MyColorIndexs->Lower(); - Aspect_DriverError::Raise ("Bad Color Index") ; - } else MyTextColor = ColorIndex; - } else MyTextColor = -1; - } - if( MyTextFont != FontIndex ) { - setattrib = Standard_True; - if( !MyFontIndexs.IsNull() ) { - if( FontIndex < MyFontIndexs->Lower() || - FontIndex > MyFontIndexs->Upper() ) { - MyTextFont = MyFontIndexs->Lower(); - Aspect_DriverError::Raise ("Bad Font Index") ; - } else MyTextFont = FontIndex; - } else MyTextFont = -1; - } - if( MyTextType != 0 ) { - setattrib = Standard_True; - MyTextType = 0; - } - - if( MyTextHScale != 1. || MyTextWScale != 1. ) { - setattrib = Standard_True; - MyTextHScale = MyTextWScale = 1.; - } - - if( setattrib ) { - Standard_Integer color ; - Standard_Integer type = MyTextType; - Standard_Integer font = (MyTextFont < 0) ? 0 : - MyFontIndexs->Value(MyTextFont) ; - - if( MyTextColor > 0 ) { - color = MyColorIndexs->Value(MyTextColor) ; - } else { - status = Xw_get_background_index(MyExtendedDrawable,&color) ; - } -#ifdef MFT - if( font < 0 ) { - Handle(MFT_FontManager) theFontManager = - MyMFTFonts->Value(MyTextFont); - Quantity_Length theTextSize = MyMFTSizes->Value(MyTextFont); - MyTextWSize = MyTextHSize = Abs(theTextSize); - Quantity_PlaneAngle theTextSlant = 0.; - Quantity_Factor thePrecision = 0.; //Set default - Standard_Boolean theCapsHeight = - (theTextSize > 0.) ? Standard_False : Standard_True; - theFontManager->SetFontAttribs(MyTextWSize,MyTextHSize, - theTextSlant,thePrecision,theCapsHeight); - return; - } -#endif - XW_ATTRIB attrib = Xw_set_text_attrib (MyExtendedDrawable, - color,type,font,XW_DRAWMODE (MyDrawMode)); - - if( !attrib ) PrintError() ; - } - -} - -void Xw_Driver::SetTextAttrib (const Standard_Integer ColorIndex, const Standard_Integer FontIndex, const Quantity_PlaneAngle aSlant, const Quantity_Factor aHScale, const Quantity_Factor aWScale,const Standard_Boolean isUnderlined) { -Standard_Boolean setattrib = Standard_False; - - if( MyTextColor != ColorIndex ) { - setattrib = Standard_True; - if( !MyColorIndexs.IsNull() ) { - if( ColorIndex < MyColorIndexs->Lower() || - ColorIndex > MyColorIndexs->Upper() ) { - MyTextColor = MyColorIndexs->Lower(); - Aspect_DriverError::Raise ("Bad Color Index") ; - } else MyTextColor = ColorIndex; - } else MyTextColor = -1; - } - if( MyTextFont != FontIndex ) { - setattrib = Standard_True; - if( !MyFontIndexs.IsNull() ) { - if( FontIndex < MyFontIndexs->Lower() || - FontIndex > MyFontIndexs->Upper() ) { - MyTextFont = MyFontIndexs->Lower(); - Aspect_DriverError::Raise ("Bad Font Index") ; - } else MyTextFont = FontIndex; - } else MyTextFont = -1; - } - if( MyTextType != 1 || (MyTextSlant != aSlant) || - (MyTextHScale != aHScale) || (MyTextWScale != aWScale) ) { - setattrib = Standard_True; - MyTextType = 1; - MyTextSlant = aSlant; - MyTextHScale = aHScale; - MyTextWScale = (aWScale > 0.) ? aWScale : aHScale; - } - - if( MyTextIsUnderlined != isUnderlined ) { - setattrib = Standard_True; - MyTextIsUnderlined = isUnderlined; - } - - if( setattrib ) { - Standard_Integer color ; - Standard_Integer font = (MyTextFont < 0) ? 0 : - MyFontIndexs->Value(MyTextFont) ; - XW_EXTENDEDTEXT attributes ; - attributes.type = XW_EXTENDEDTEXT_UNDERLINE; - attributes.xscale = MyTextWScale; - attributes.yscale = MyTextHScale; - attributes.slant = MyTextSlant; - attributes.width = attributes.height = 0.; - attributes.spacing = 0.; - attributes.isUnderlined = MyTextIsUnderlined; - if( MyTextSlant != 0. ) attributes.type |= XW_EXTENDEDTEXT_SLANT; - if( MyTextWScale > 0. ) { - attributes.type |= XW_EXTENDEDTEXT_XSCALE; - } - if( MyTextHScale > 0. ) { - attributes.type |= XW_EXTENDEDTEXT_YSCALE; - } - if( MyTextColor > 0 ) { - color = MyColorIndexs->Value(MyTextColor) ; - } else { - status = Xw_get_background_index(MyExtendedDrawable,&color) ; - } -#ifdef MFT - if( font < 0 ) { - Handle(MFT_FontManager) theFontManager = - MyMFTFonts->Value(MyTextFont); - Quantity_Length theTextSize = MyMFTSizes->Value(MyTextFont); - MyTextWSize = MyTextWScale * Abs(theTextSize); - MyTextHSize = MyTextHScale * Abs(theTextSize); - Quantity_PlaneAngle theTextSlant = MyTextSlant; - Quantity_Factor thePrecision = 0.; //Set default - Standard_Boolean theCapsHeight = - (theTextSize > 0.) ? Standard_False : Standard_True; - theFontManager->SetFontAttribs(MyTextWSize,MyTextHSize, - theTextSlant,thePrecision,theCapsHeight); - return; - } -#endif - XW_ATTRIB attrib = Xw_set_extended_text_attrib (MyExtendedDrawable, - color,font,XW_DRAWMODE (MyDrawMode),&attributes); - - if( !attrib ) PrintError() ; - } -} - -void Xw_Driver::SetMarkerAttrib (const Standard_Integer ColorIndex, const Standard_Integer WidthIndex, const Standard_Boolean FillMarker) { -Standard_Boolean setattrib = Standard_False; - - if( MyMarkerColor != ColorIndex ) { - setattrib = Standard_True; - if( !MyColorIndexs.IsNull() ) { - if( ColorIndex < MyColorIndexs->Lower() || - ColorIndex > MyColorIndexs->Upper() ) { - MyMarkerColor = MyColorIndexs->Lower(); - Aspect_DriverError::Raise ("Bad Color Index") ; - } else MyMarkerColor = ColorIndex; - } else MyMarkerColor = -1; - } - if( MyMarkerWidth != WidthIndex ) { - setattrib = Standard_True; - if( !MyWidthIndexs.IsNull() ) { - if( WidthIndex < MyWidthIndexs->Lower() || - WidthIndex > MyWidthIndexs->Upper() ) { - MyMarkerWidth = MyWidthIndexs->Lower(); - Aspect_DriverError::Raise ("Bad Width Index") ; - } else MyMarkerWidth = WidthIndex; - } else MyMarkerWidth = -1; - } - if( MyMarkerType != FillMarker ) { - setattrib = Standard_True; - MyMarkerType = FillMarker; - } - - if( setattrib ) { - Standard_Integer color ; - Standard_Integer type = MyMarkerType; - Standard_Integer width = (MyMarkerWidth < 0) ? 0 : - MyWidthIndexs->Value(MyMarkerWidth) ; - - if( MyMarkerColor > 0 ) { - color = MyColorIndexs->Value(MyMarkerColor) ; - } else { - status = Xw_get_background_index(MyExtendedDrawable,&color) ; - } - XW_ATTRIB attrib = Xw_set_marker_attrib (MyExtendedDrawable,color,type,width, - XW_DRAWMODE (MyDrawMode)); - - if( !attrib ) PrintError() ; - } -} - -// Category: Methods to manage images - -Standard_Boolean Xw_Driver::IsKnownImage(const Handle(Standard_Transient)& anImage) { - - MyImage = Xw_get_image_handle( MyExtendedDrawable, - (void*)(::HashCode (anImage, IntegerLast())) ) ; - - if( MyImage ) return (Standard_True) ; - else return Standard_False; -} - -Standard_Boolean Xw_Driver::SizeOfImageFile(const Standard_CString anImageFile, - Standard_Integer &aWidth, - Standard_Integer &aHeight) const { -Standard_Integer hashcode = ::HashCode(anImageFile) ; -XW_EXT_IMAGEDATA *pimage; -int width,height,depth; -float zoom; - - status = XW_ERROR; - pimage = Xw_get_image_handle( MyExtendedDrawable,(void*)hashcode ) ; - if( !pimage ) { - pimage = Xw_load_image(MyExtendedDrawable, - (void*)hashcode, - (Standard_PCharacter)anImageFile ); - } - - if( pimage ) { - status = Xw_get_image_info(pimage,&zoom,&width,&height,&depth); - aWidth = width; - aHeight = height; - } - - return status; -} - -void Xw_Driver::ClearImage (const Handle(Standard_Transient)& anImage) { - - MyImage = Xw_get_image_handle( MyExtendedDrawable, - (void*) (::HashCode (anImage, IntegerLast())) ) ; - - if( MyImage ) { - status = Xw_close_image (MyImage); - MyImage = NULL; - } -} - -void Xw_Driver::ClearImageFile (const Standard_CString anImageFile) { -Standard_Integer hashcode = ::HashCode(anImageFile) ; -XW_EXT_IMAGEDATA *pimage; - - pimage = Xw_get_image_handle( MyExtendedDrawable,(void*)hashcode ) ; - - if( pimage ) { - status = Xw_close_image (pimage); - } -} - -void Xw_Driver::DrawImage (const Handle(Standard_Transient)& anImage, const Standard_ShortReal aX, const Standard_ShortReal aY) { - - MyImage = Xw_get_image_handle( MyExtendedDrawable, - (void*) (::HashCode (anImage, IntegerLast())) ) ; - - if( MyImage ) { - status = Xw_draw_image (MyExtendedDrawable, MyImage, aX, aY); - } -} - -void Xw_Driver::DrawImageFile (const Standard_CString anImageFile, - const Standard_ShortReal aX, - const Standard_ShortReal aY, - const Quantity_Factor aScale) -{ - XW_EXT_IMAGEDATA *pimage; - Standard_Integer hashcode = ::HashCode(anImageFile); - - pimage = Xw_get_image_handle( MyExtendedDrawable,(void*)hashcode ); - if (!pimage) { - pimage = Xw_load_image(MyExtendedDrawable, - (void*)(hashcode), - (Standard_PCharacter)anImageFile ); - } - - if (pimage && aScale > 0.) { - float zoom = aScale; - status = Xw_zoom_image (pimage,zoom); - } - - if (status == XW_SUCCESS && pimage) { - status = Xw_draw_image (MyExtendedDrawable, pimage, aX, aY); - } else if (pimage) { - status = Xw_draw_zoomed_image (MyExtendedDrawable, pimage, aX, aY, aScale); - if (status != XW_SUCCESS) - PrintError(); - } else PrintError (); -} - -void Xw_Driver::FillAndDrawImage (const Handle(Standard_Transient)& anImage, const Standard_ShortReal aX, const Standard_ShortReal aY, const Standard_Integer aWidth, const Standard_Integer aHeight, const Standard_Address anArrayOfPixels) { -float oldr, oldg, oldb; -int oldi = 0, oldj = 0, oldindex; -int num; - -// Image 614x614 : -// temps CPU avec Standard_Integer < 20 secondes -// temps CPU avec register < 19 secondes -Standard_Integer i, j; - -GRAPHIC2D_PIXEL *pixels; -GRAPHIC2D_PIXEL pixel; - - if ((aWidth > 0) && (aHeight > 0)) { - if( !MyImage ) { - MyImage = Xw_open_image (MyExtendedDrawable, - (void*) (::HashCode (anImage, IntegerLast())), - int (aWidth),int (aHeight)); - } - if( !MyImage ) { - PrintError() ; - } else { - switch (MyVisualClass) { - case (Xw_TOV_STATICGRAY) : - break; - case (Xw_TOV_GRAYSCALE) : - break; - case (Xw_TOV_STATICCOLOR) : - break; - case (Xw_TOV_PSEUDOCOLOR) : - pixels = (GRAPHIC2D_PIXEL *) anArrayOfPixels; - - for (i=0; iDrawImage (anImage, aX, aY); - break; - case (Xw_TOV_TRUECOLOR) : - pixels = (GRAPHIC2D_PIXEL *) anArrayOfPixels; - - for (i=0; iDrawImage (anImage, aX, aY); - break; - case (Xw_TOV_DIRECTCOLOR) : - case (Xw_TOV_DEFAULT) : - case (Xw_TOV_PREFERRED_TRUECOLOR) : - case (Xw_TOV_PREFERRED_PSEUDOCOLOR) : - case (Xw_TOV_PREFERRED_OVERLAY) : - case (Xw_TOV_OVERLAY) : - // Cas impossible, mais plus de warning C++ : - // switch ( Xw_TypeOfVisual ) with 6 cases - // ( 9 enumerators) - break; - } - - } - } -} - -void Xw_Driver::FillAndDrawImage (const Handle(Standard_Transient)& anImage, const Standard_ShortReal aX, const Standard_ShortReal aY, const Standard_Integer anIndexOfLine, const Standard_Integer aWidth, const Standard_Integer aHeight, const Standard_Address anArrayOfPixels) { -float oldr, oldg, oldb; -int oldi = 0, oldj = 0, oldindex; -int num; - -// Image 614x614 : -// temps CPU avec Standard_Integer < 21 secondes -// temps CPU avec register < 20 secondes -Standard_Integer j; - -GRAPHIC2D_PIXEL *pixels; -GRAPHIC2D_PIXEL pixel; - - if ((anIndexOfLine < 0) || (anIndexOfLine >= aHeight)) - Aspect_DriverError::Raise ("Bad Index in Xw_Driver::FillImage"); - - // Debut d'image - if ((aWidth > 0) && (aHeight > 0) && (anIndexOfLine == 0)) { - if( !MyImage ) { - MyImage = Xw_open_image (MyExtendedDrawable, - (void*) (::HashCode (anImage, IntegerLast())), - int (aWidth),int (aHeight)); - } - } - if ((aWidth > 0) && (aHeight > 0) && (anIndexOfLine >= 0)) { - if( !MyImage ) { - PrintError() ; - } - else { - switch (MyVisualClass) { - case (Xw_TOV_STATICGRAY) : - break; - case (Xw_TOV_GRAYSCALE) : - break; - case (Xw_TOV_STATICCOLOR) : - break; - case (Xw_TOV_PSEUDOCOLOR) : - pixels = (GRAPHIC2D_PIXEL *) anArrayOfPixels; - - oldr = oldg = oldb = -1.0; - oldi = int (anIndexOfLine); - oldindex = -1; - num = 0; - - for (j=0; jDrawImage (anImage, aX, aY); - break; - case (Xw_TOV_TRUECOLOR) : - pixels = (GRAPHIC2D_PIXEL *) anArrayOfPixels; - - oldr = oldg = oldb = -1.0; - oldi = int (anIndexOfLine); - num = 0; - - for (j=0; jDrawImage (anImage, aX, aY); - break; - case (Xw_TOV_DIRECTCOLOR) : - case (Xw_TOV_DEFAULT) : - case (Xw_TOV_PREFERRED_PSEUDOCOLOR) : - case (Xw_TOV_PREFERRED_TRUECOLOR) : - case (Xw_TOV_PREFERRED_OVERLAY) : - case (Xw_TOV_OVERLAY) : - // Cas impossible, mais plus de warning C++ : - // switch ( Xw_TypeOfVisual ) with 6 cases - // ( 9 enumerators) - break; - } - - } - } -} - -// Category: Methods to draw primitives - -void Xw_Driver::DrawPolygon (const TShort_Array1OfShortReal& aListX, const TShort_Array1OfShortReal& aListY) { -int npoint = (int)aListX.Length () ; -float *X = (float*) &aListX.Value(aListX.Lower()) ; -float *Y = (float*) &aListY.Value(aListY.Lower()) ; - - if( npoint != (int)aListY.Length () ) - Aspect_DriverError::Raise ("2 differents lengths!") ; - - if( npoint > 0 ) { - status = Xw_draw_poly(MyExtendedDrawable,npoint,X,Y) ; - if( !status ) PrintError() ; - } -} - -void Xw_Driver::DrawPolyline (const TShort_Array1OfShortReal& aListX, const TShort_Array1OfShortReal& aListY) { -int npoint = (int)aListX.Length () ; -float *X = (float*) &aListX.Value(aListX.Lower()) ; -float *Y = (float*) &aListY.Value(aListY.Lower()) ; - - if( npoint != (int)aListY.Length () ) - Aspect_DriverError::Raise ("2 differents lengths!") ; - - if( npoint > 0 ) { - status = Xw_draw_line(MyExtendedDrawable,npoint,X,Y) ; - if( !status ) PrintError() ; - } -} - -void Xw_Driver::DrawSegment (const Standard_ShortReal X1, const Standard_ShortReal Y1, const Standard_ShortReal X2, const Standard_ShortReal Y2) { - - status = Xw_draw_segment (MyExtendedDrawable, X1, Y1, X2, Y2); - - if( !status ) PrintError() ; - -} - -void Xw_Driver::DrawText (const TCollection_ExtendedString& aText, const Standard_ShortReal Xpos, const Standard_ShortReal Ypos, const Standard_ShortReal Angle , const Aspect_TypeOfText aType) { - - if( aText.Length() > 0 ) { -#ifdef MFT - Standard_Integer font = (MyTextFont < 0) ? 0 : - MyFontIndexs->Value(MyTextFont) ; - if( font < 0 ) { - Handle(MFT_FontManager) theFontManager = - MyMFTFonts->Value(MyTextFont); - if( !aText.IsAscii() && !theFontManager->IsComposite() ) { - cout << "*ERROR*Xw_Driver::DrawText.UNABLE to draw an extended text with an ANSI font" << endl; - return; - } - Standard_Real underlinePosition = - (MyTextIsUnderlined) ? theFontManager->UnderlinePosition() : 0.; - Standard_Integer theTextColor; - if( MyTextColor > 0 ) { - theTextColor = MyColorIndexs->Value(MyTextColor) ; - } else { - Xw_get_background_index(MyExtendedDrawable,&theTextColor) ; - } - Aspect_TypeOfText theTextType = aType; - MyTextManager->SetTextAttribs(theTextColor,theTextType,underlinePosition); - theFontManager->DrawText(MyTextManager,aText.ToExtString(), - Quantity_Length(Xpos),Quantity_Length(Ypos), - Quantity_PlaneAngle(Angle)); - } else -#endif - if( aText.IsAscii() ) { - TCollection_AsciiString atext(aText,'?'); - status = Xw_draw_text (MyExtendedDrawable, - Xpos, - Ypos, - (Standard_PCharacter)atext.ToCString (), - Angle, - (int)aType); - } else status = XW_ERROR ; /*Must be Implemented more later*/ - - if( !status ) PrintError() ; - } -} - -void Xw_Driver::DrawText (const Standard_CString aText, const Standard_ShortReal Xpos, const Standard_ShortReal Ypos, const Standard_ShortReal Angle , const Aspect_TypeOfText aType) { - - if( strlen(aText) > 0 ) { - TCollection_ExtendedString etext(aText); - this->DrawText(etext,Xpos,Ypos,Angle,aType); - } -} - -void Xw_Driver::DrawPolyText (const TCollection_ExtendedString& aText, const Standard_ShortReal Xpos, const Standard_ShortReal Ypos, const Quantity_Factor aMarge, const Standard_ShortReal Angle , const Aspect_TypeOfText aType) { -Standard_ShortReal marge = aMarge ; - - if( aText.Length() > 0 ) { -#ifdef MFT - Standard_Integer font = (MyTextFont < 0) ? 0 : - MyFontIndexs->Value(MyTextFont) ; - if( font < 0 ) { - Handle(MFT_FontManager) theFontManager = - MyMFTFonts->Value(MyTextFont); - if( !aText.IsAscii() && !theFontManager->IsComposite() ) { - cout << "*ERROR*Xw_Driver::DrawPolyText.UNABLE to draw an extended text with an ANSI font" << endl; - return; - } - Standard_Real underlinePosition = - (MyTextIsUnderlined) ? theFontManager->UnderlinePosition() : 0.; - Standard_ShortReal width,height,xoffset,yoffset,marge; - this->TextSize(aText,width,height,xoffset,yoffset,MyTextFont) ; - if( underlinePosition > yoffset ) yoffset = underlinePosition; - marge = height * aMarge; - xoffset -= marge; - yoffset += marge; - width += 2.*marge; - height += 2.*marge; - if( MyPolyTile < 0 ) { - this->DrawRectangle(Xpos,Ypos,Angle,xoffset,yoffset,width,height); - } else { - this->FillRectangle(Xpos,Ypos,Angle,xoffset,yoffset,width,height); - } - Standard_Integer theTextColor; - if( (MyTextColor > 0) && ((MyTextColor != MyPolyColor) || - (MyPolyTile < 0)) ) { - theTextColor = MyColorIndexs->Value(MyTextColor) ; - } else { - Xw_get_background_index(MyExtendedDrawable,&theTextColor) ; - } - Aspect_TypeOfText theTextType = aType; - MyTextManager->SetTextAttribs(theTextColor,theTextType,underlinePosition); - theFontManager->DrawText(MyTextManager,aText.ToExtString(), - Quantity_Length(Xpos),Quantity_Length(Ypos), - Quantity_PlaneAngle(Angle)); - } else -#endif - if( aText.IsAscii() ) { - TCollection_AsciiString atext(aText,'?'); - status = Xw_draw_polytext (MyExtendedDrawable, - Xpos, - Ypos, - (Standard_PCharacter)atext.ToCString (), - Angle, - marge, - (int)aType); - } else status = XW_ERROR ; /*Must be Implemented more later*/ - - if( !status ) PrintError() ; - } -} - -void Xw_Driver::DrawPolyText (const Standard_CString aText, const Standard_ShortReal Xpos, const Standard_ShortReal Ypos, const Quantity_Factor aMarge, const Standard_ShortReal Angle , const Aspect_TypeOfText aType) { -//Standard_ShortReal marge = aMarge ; - - if( strlen(aText) > 0 ) { - TCollection_ExtendedString etext(aText); - DrawPolyText(etext,Xpos,Ypos,aMarge,Angle,aType); - } -} - -void Xw_Driver::DrawMarker (const Standard_Integer aMarker, const Standard_ShortReal Xpos, const Standard_ShortReal Ypos, const Standard_ShortReal Width, const Standard_ShortReal Height, const Standard_ShortReal Angle ) { -int marker = -1; -float width = TOMILLIMETER(Width); -float height = TOMILLIMETER(Height); - - if( !MyMarkerIndexs.IsNull() ) { - if( aMarker >= MyMarkerIndexs->Lower() - && aMarker <= MyMarkerIndexs->Upper() ) { - marker = MyMarkerIndexs->Value(aMarker); - } - } - -#ifdef PRO17334 - if( aMarker < 0 ) - Aspect_DriverError::Raise ("Bad Marker Index") ; - if( aMarker > 0 ) { -#else - if( aMarker >= 0 ) { -#endif - status = Xw_draw_marker (MyExtendedDrawable, marker, Xpos, Ypos, - width, height, Angle) ; - } else { - status = Xw_draw_point (MyExtendedDrawable, Xpos, Ypos) ; - } - - if( !status ) PrintError() ; -} - -Standard_Boolean Xw_Driver::DrawArc (const Standard_ShortReal Xpos, const Standard_ShortReal Ypos, const Standard_ShortReal aXradius, const Standard_ShortReal aYradius, const Standard_ShortReal aStartAngle, const Standard_ShortReal aOpenAngle) { - - status = Xw_draw_arc(MyExtendedDrawable, Xpos, Ypos, - aXradius, aYradius, aStartAngle, aOpenAngle); - if( !status ) PrintError() ; - - return status; -} - -Standard_Boolean Xw_Driver::DrawPolyArc (const Standard_ShortReal Xpos, const Standard_ShortReal Ypos, const Standard_ShortReal aXradius, const Standard_ShortReal aYradius, const Standard_ShortReal aStartAngle, const Standard_ShortReal aOpenAngle) { - - status = Xw_draw_polyarc(MyExtendedDrawable, Xpos, Ypos, - aXradius, aYradius, aStartAngle, aOpenAngle); - if( !status ) PrintError() ; - - return status; -} - -void Xw_Driver::BeginPolyline (const Standard_Integer aNumber) { - - if( MyPrimitiveType != Aspect_TOP_UNKNOWN ) ClosePrimitive(); - - if( aNumber < 0 ) return; - - status = Xw_begin_line (MyExtendedDrawable, aNumber) ; - if( status ) { - MyPrimitiveType = Aspect_TOP_POLYLINE; - } else { - PrintError() ; - } -} - -void Xw_Driver::BeginPolygon (const Standard_Integer aNumber) { - - if( MyPrimitiveType != Aspect_TOP_UNKNOWN ) ClosePrimitive(); - - if( aNumber < 0 ) return; - - status = Xw_begin_poly (MyExtendedDrawable, aNumber, 0) ; - if( status ) { - MyPrimitiveType = Aspect_TOP_POLYGON; - } else { - PrintError() ; - } -} - -void Xw_Driver::BeginSegments () { - - if( MyPrimitiveType != Aspect_TOP_UNKNOWN ) ClosePrimitive(); - - status = Xw_begin_segments (MyExtendedDrawable, 0) ; - if( status ) { - MyPrimitiveType = Aspect_TOP_SEGMENTS; - } else { - PrintError() ; - } -} - -void Xw_Driver::BeginArcs () { - - if( MyPrimitiveType != Aspect_TOP_UNKNOWN ) ClosePrimitive(); - - status = Xw_begin_arcs (MyExtendedDrawable, 0) ; - if( status ) { - MyPrimitiveType = Aspect_TOP_ARCS; - } else { - PrintError() ; - } -} - -void Xw_Driver::BeginPolyArcs () { - - if( MyPrimitiveType != Aspect_TOP_UNKNOWN ) ClosePrimitive(); - - status = Xw_begin_polyarcs (MyExtendedDrawable, 0) ; - if( status ) { - MyPrimitiveType = Aspect_TOP_POLYARCS; - } else { - PrintError() ; - } -} - -void Xw_Driver::BeginMarkers () { - - if( MyPrimitiveType != Aspect_TOP_UNKNOWN ) ClosePrimitive(); - - status = Xw_begin_markers (MyExtendedDrawable, 0) ; - if( status ) { - MyPrimitiveType = Aspect_TOP_MARKERS; - } else { - PrintError() ; - } -} - -void Xw_Driver::BeginPoints () { - - if( MyPrimitiveType != Aspect_TOP_UNKNOWN ) ClosePrimitive(); - - status = Xw_begin_points (MyExtendedDrawable, 0) ; - if( status ) { - MyPrimitiveType = Aspect_TOP_POINTS; - } else { - PrintError() ; - } -} - -void Xw_Driver::DrawPoint (const Standard_ShortReal X, const Standard_ShortReal Y) { - switch( MyPrimitiveType ) { - case Aspect_TOP_POLYLINE: - status = Xw_line_point (MyExtendedDrawable, X, Y) ; - break; - case Aspect_TOP_POLYGON: - status = Xw_poly_point (MyExtendedDrawable, X, Y) ; - break; - default: - status = Xw_draw_point (MyExtendedDrawable, X, Y) ; - } - - if( !status ) { - PrintError() ; - } -} - -void Xw_Driver::ClosePrimitive () { - - switch( MyPrimitiveType ) { - case Aspect_TOP_POLYLINE: - status = Xw_close_line (MyExtendedDrawable) ; - break; - case Aspect_TOP_POLYGON: - status = Xw_close_poly (MyExtendedDrawable) ; - break; - case Aspect_TOP_SEGMENTS: - status = Xw_close_segments (MyExtendedDrawable) ; - break; - case Aspect_TOP_ARCS: - status = Xw_close_arcs (MyExtendedDrawable) ; - break; - case Aspect_TOP_POLYARCS: - status = Xw_close_polyarcs (MyExtendedDrawable) ; - break; - case Aspect_TOP_MARKERS: - status = Xw_close_markers (MyExtendedDrawable) ; - break; - case Aspect_TOP_POINTS: - status = Xw_close_points (MyExtendedDrawable) ; - break; - default: - MyPrimitiveType = Aspect_TOP_UNKNOWN; - } - MyPrimitiveType = Aspect_TOP_UNKNOWN; - if( !status ) PrintError() ; -} - -void Xw_Driver::WorkSpace ( Quantity_Length &Width, Quantity_Length &Height ) const { - -#ifdef OPTIM1 -int width,height ; - status = Xw_get_window_size(MyExtendedDrawable,&width,&height) ; - - if( !status ) { - Xw_print_error() ; - } -#else -XW_WINDOWSTATE state ; -int xc,yc,width,height ; - - state = Xw_get_window_position(MyExtendedDrawable, - &xc,&yc,&width,&height) ; - - if( state == XW_WS_UNKNOWN ) { - Xw_print_error() ; - } -#endif - -#ifdef CTS50024 - float x,y ; - status = Xw_get_window_pixelcoord(MyExtendedDrawable, - width,0,&x,&y) ; - if( !status ) { - PrintError() ; - } - - Width = Quantity_Length(x); Height = Quantity_Length(y); -#else - Width = Xw_get_window_pixelvalue(MyExtendedDrawable,width) ; - Height = Xw_get_window_pixelvalue(MyExtendedDrawable,height) ; -#endif -} - -Quantity_Length Xw_Driver::Convert (const Standard_Integer Pv) const { -Standard_ShortReal Dv ; - - Dv = Xw_get_window_pixelvalue(MyExtendedDrawable,(int)Pv) ; - - return Quantity_Length(Dv) ; -} - -void Xw_Driver::Convert (const Standard_Integer Px, const Standard_Integer Py, Quantity_Length &Dx, Quantity_Length &Dy ) const { -float x,y ; - - status = Xw_get_window_pixelcoord(MyExtendedDrawable, - (int)Px,(int)Py,&x,&y) ; - - if( !status ) { - PrintError() ; - } - - Dx = Quantity_Length(x) ; Dy = Quantity_Length(y) ; -} - -Standard_Integer Xw_Driver::Convert (const Quantity_Length Dv) const { -Standard_Integer Pv ; - - Pv = Xw_get_pixel_windowvalue(MyExtendedDrawable,(float)Dv) ; - - return (Pv) ; -} - -void Xw_Driver::Convert (const Quantity_Length Dx, const Quantity_Length Dy, Standard_Integer &Px, Standard_Integer &Py ) const { -int x,y ; - - status = Xw_get_pixel_windowcoord(MyExtendedDrawable, - (float)Dx,(float)Dy,&x,&y) ; - - if( !status ) { - PrintError() ; - } - - Px = x ; Py = y ; -} - -void Xw_Driver::TextSize (const TCollection_ExtendedString& aText, Standard_ShortReal& Width, Standard_ShortReal& Height, const Standard_Integer aFontIndex ) const { -Standard_ShortReal xoffset,yoffset; - - this->TextSize(aText,Width,Height,xoffset,yoffset,aFontIndex) ; -} - -void Xw_Driver::TextSize (const TCollection_ExtendedString& aText, Standard_ShortReal& Width, Standard_ShortReal& Height, Standard_ShortReal& Xoffset, Standard_ShortReal& Yoffset, const Standard_Integer aFontIndex ) const { - -Standard_Integer theFont = (aFontIndex >= 0 ) ? aFontIndex : MyTextFont ; - - if( !MyFontIndexs.IsNull() ) { - if( theFont < MyFontIndexs->Lower() || - theFont > MyFontIndexs->Upper() ) { - Aspect_DriverError::Raise ("Bad Font Index") ; - } - } - Standard_Integer font = (theFont < 0) ? 0 : - MyFontIndexs->Value(theFont) ; -#ifdef MFT - if( font < 0 ) { - Handle(MFT_FontManager) theFontManager = - MyMFTFonts->Value(theFont); - Quantity_Length theWidth = 0.,theAscent = 0.,theLbearing = 0.,theDescent = 0.; - if( aText.IsAscii() ) { - TCollection_AsciiString atext(aText,'?'); - theFontManager->TextSize(atext.ToCString(), - theWidth,theAscent,theLbearing,theDescent); - } else if( theFontManager->IsComposite() ) { - theFontManager->TextSize(aText.ToExtString(), - theWidth,theAscent,theLbearing,theDescent); - } else { -// cout << "*ERROR*Xw_Driver::TextSize(...).Try to gets extended text size with an ANSI font" << endl; - } - if( MyTextIsUnderlined ) { - Quantity_Length theUnderlinePosition = - theFontManager->UnderlinePosition(); - theDescent = Max(theDescent,theUnderlinePosition); - } - Width = theWidth; - Height = theAscent + theDescent; - Xoffset = theLbearing; - Yoffset = theDescent; - return; - } -#endif - if (aText.IsAscii ()) { - TCollection_AsciiString atext(aText,'?'); - status = Xw_get_text_size (MyExtendedDrawable, - font, - (Standard_PCharacter)atext.ToCString(), - &Width, - &Height, - &Xoffset, - &Yoffset) ; - if( !status ) PrintError() ; - } else { /*Must be Implemented more later*/ - Width = Height = Xoffset = Yoffset = 0.; - } -} - -void Xw_Driver::TextSize (const Standard_CString aText, Standard_ShortReal& Width, Standard_ShortReal& Height, Standard_ShortReal& Xoffset, Standard_ShortReal& Yoffset, const Standard_Integer aFontIndex) const { -//Standard_Integer theFont = (aFontIndex >= 0 ) ? aFontIndex : MyTextFont ; - - TCollection_ExtendedString etext(aText); - this->TextSize(etext,Width,Height,Xoffset,Yoffset,aFontIndex); -} - -Standard_CString Xw_Driver::FontSize (Quantity_PlaneAngle &aSlant, Standard_ShortReal &aSize, Standard_ShortReal &aBheight, const Standard_Integer aFontIndex) const { -Standard_Integer theFont = (aFontIndex >= 0 ) ? aFontIndex : MyTextFont ; -Standard_CString fstring; -float size,bheight; - - if( !MyFontIndexs.IsNull() ) { - if( theFont < MyFontIndexs->Lower() || - theFont > MyFontIndexs->Upper() ) { - return NULL ; - } - } - Standard_Integer font = (theFont < 0) ? 0 : - MyFontIndexs->Value(theFont) ; -#ifdef MFT - if( font < 0 ) { - Handle(MFT_FontManager) theFontManager = - MyMFTFonts->Value(theFont); - Quantity_Length theWidth,theHeight,theDescent; - Quantity_PlaneAngle theSlant; - Quantity_Factor thePrecision; - Standard_Boolean theCapsHeight; - fstring = theFontManager->FontAttribs( - theWidth,theHeight,theDescent,theSlant,thePrecision,theCapsHeight); - aSize = theHeight; - aBheight = theDescent; - aSlant = theSlant; - return fstring; - } -#endif - fstring = Xw_get_font (MyExtendedFontMap,font,&size,&bheight); - if( !fstring ) PrintError() ; - - aSlant = 0.; // To be implemented - aSize = FROMMILLIMETER(size); - aBheight = FROMMILLIMETER(bheight); - return fstring; - -} - -void Xw_Driver::AngleOfBuffer(const Standard_Integer aRetainBuffer,Quantity_PlaneAngle &anAngle) const { -Standard_ShortReal xpivot,ypivot,xscale,yscale,angle ; - - status = Xw_get_buffer_info(MyExtendedDrawable,aRetainBuffer, - &xpivot,&ypivot,&xscale,&yscale,&angle) ; - - anAngle = angle ; -} - -void Xw_Driver::ScaleOfBuffer(const Standard_Integer aRetainBuffer,Quantity_Factor &aScaleX,Quantity_Factor &aScaleY) const { -Standard_ShortReal xpivot,ypivot,xscale,yscale,angle ; - - status = Xw_get_buffer_info(MyExtendedDrawable,aRetainBuffer, - &xpivot,&ypivot,&xscale,&yscale,&angle) ; - - aScaleX = xscale ; - aScaleY = yscale ; -} - -void Xw_Driver::PositionOfBuffer(const Standard_Integer aRetainBuffer,Standard_ShortReal &aPivotX,Standard_ShortReal &aPivotY) const { -Standard_ShortReal xpivot,ypivot,xscale,yscale,angle ; - - status = Xw_get_buffer_info(MyExtendedDrawable,aRetainBuffer, - &xpivot,&ypivot,&xscale,&yscale,&angle) ; - - aPivotX = xpivot ; - aPivotY = ypivot ; -} - -void Xw_Driver::ColorBoundIndexs(Standard_Integer &aMinIndex, Standard_Integer &aMaxIndex) const { - - if( MyColorIndexs.IsNull() ) { - aMinIndex = aMaxIndex = 0; - } else { - aMinIndex = MyColorIndexs->Lower() ; - aMaxIndex = MyColorIndexs->Upper() ; - } -} - -Standard_Integer Xw_Driver::LocalColorIndex(const Standard_Integer anIndex) const { - - if( (anIndex < MyColorIndexs->Lower()) || - (anIndex > MyColorIndexs->Upper()) ) return (-1); - - return MyColorIndexs->Value(anIndex); -} - -void Xw_Driver::FontBoundIndexs(Standard_Integer &aMinIndex, Standard_Integer &aMaxIndex) const { - - if( MyFontIndexs.IsNull() ) { - aMinIndex = aMaxIndex = 0; - } else { - aMinIndex = MyFontIndexs->Lower() ; - aMaxIndex = MyFontIndexs->Upper() ; - } -} - -Standard_Integer Xw_Driver::LocalFontIndex(const Standard_Integer anIndex) const { - - if( (anIndex < MyFontIndexs->Lower()) || - (anIndex > MyFontIndexs->Upper()) ) return (-1); - - return MyFontIndexs->Value(anIndex); -} - -void Xw_Driver::TypeBoundIndexs(Standard_Integer &aMinIndex, Standard_Integer &aMaxIndex) const { - - if( MyTypeIndexs.IsNull() ) { - aMinIndex = aMaxIndex = 0; - } else { - aMinIndex = MyTypeIndexs->Lower() ; - aMaxIndex = MyTypeIndexs->Upper() ; - } -} - -Standard_Integer Xw_Driver::LocalTypeIndex(const Standard_Integer anIndex) const { - - if( (anIndex < MyTypeIndexs->Lower()) || - (anIndex > MyTypeIndexs->Upper()) ) return (-1); - - return MyTypeIndexs->Value(anIndex); -} - -void Xw_Driver::WidthBoundIndexs(Standard_Integer &aMinIndex, Standard_Integer &aMaxIndex) const { - - if( MyWidthIndexs.IsNull() ) { - aMinIndex = aMaxIndex = 0; - } else { - aMinIndex = MyWidthIndexs->Lower() ; - aMaxIndex = MyWidthIndexs->Upper() ; - } -} - -Standard_Integer Xw_Driver::LocalWidthIndex(const Standard_Integer anIndex) const { - - if( (anIndex < MyWidthIndexs->Lower()) || - (anIndex > MyWidthIndexs->Upper()) ) return (-1); - - return MyWidthIndexs->Value(anIndex); -} - -void Xw_Driver::MarkBoundIndexs(Standard_Integer &aMinIndex, Standard_Integer &aMaxIndex) const { - - if( MyMarkerIndexs.IsNull() ) { - aMinIndex = aMaxIndex = 0; - } else { - aMinIndex = MyMarkerIndexs->Lower() ; - aMaxIndex = MyMarkerIndexs->Upper() ; - } -} - -Standard_Integer Xw_Driver::LocalMarkIndex(const Standard_Integer anIndex) const { - - if( (anIndex < MyMarkerIndexs->Lower()) || - (anIndex > MyMarkerIndexs->Upper()) ) return (-1); - - return MyMarkerIndexs->Value(anIndex); -} - -void Xw_Driver::DrawRectangle(const Standard_ShortReal Xpos, const Standard_ShortReal Ypos, const Standard_ShortReal Angle, const Standard_ShortReal Xoffset, const Standard_ShortReal Yoffset, const Standard_ShortReal Width, const Standard_ShortReal Height) const { -Standard_ShortReal xpoly,ypoly; - - theSinAngle = Sin(Angle); - theCosAngle = Cos(Angle); - Xw_begin_line(MyExtendedDrawable,5); - xpoly = Xoffset; - ypoly = -Yoffset; - TRANSFORM(xpoly,ypoly); - Xw_line_point(MyExtendedDrawable,Xpos + xpoly, Ypos + ypoly); - xpoly = Xoffset + Width; - ypoly = -Yoffset; - TRANSFORM(xpoly,ypoly); - Xw_line_point(MyExtendedDrawable,Xpos + xpoly, Ypos + ypoly); - xpoly = Xoffset + Width; - ypoly = Height - Yoffset; - TRANSFORM(xpoly,ypoly); - Xw_line_point(MyExtendedDrawable,Xpos + xpoly, Ypos + ypoly); - xpoly = Xoffset; - ypoly = Height - Yoffset; - TRANSFORM(xpoly,ypoly); - Xw_line_point(MyExtendedDrawable,Xpos + xpoly, Ypos + ypoly); - xpoly = Xoffset; - ypoly = -Yoffset; - TRANSFORM(xpoly,ypoly); - Xw_line_point(MyExtendedDrawable,Xpos + xpoly, Ypos + ypoly); - Xw_close_line(MyExtendedDrawable); -} - -void Xw_Driver::FillRectangle(const Standard_ShortReal Xpos, const Standard_ShortReal Ypos, const Standard_ShortReal Angle, const Standard_ShortReal Xoffset, const Standard_ShortReal Yoffset, const Standard_ShortReal Width, const Standard_ShortReal Height) const { -Standard_ShortReal xpoly,ypoly; - - theSinAngle = Sin(Angle); - theCosAngle = Cos(Angle); - Xw_begin_poly(MyExtendedDrawable,4,0); - xpoly = Xoffset; - ypoly = -Yoffset; - TRANSFORM(xpoly,ypoly); - Xw_poly_point(MyExtendedDrawable,Xpos + xpoly, Ypos + ypoly); - xpoly = Xoffset + Width; - ypoly = -Yoffset; - TRANSFORM(xpoly,ypoly); - Xw_poly_point(MyExtendedDrawable,Xpos + xpoly, Ypos + ypoly); - xpoly = Xoffset + Width; - ypoly = Height - Yoffset; - TRANSFORM(xpoly,ypoly); - Xw_poly_point(MyExtendedDrawable,Xpos + xpoly, Ypos + ypoly); - xpoly = Xoffset; - ypoly = Height - Yoffset; - TRANSFORM(xpoly,ypoly); - Xw_poly_point(MyExtendedDrawable,Xpos + xpoly, Ypos + ypoly); - Xw_close_poly(MyExtendedDrawable); -} diff --git a/src/Xw/Xw_TextManager.cdl b/src/Xw/Xw_TextManager.cdl deleted file mode 100755 index 4483a3780a..0000000000 --- a/src/Xw/Xw_TextManager.cdl +++ /dev/null @@ -1,143 +0,0 @@ --- Created on: 1993-04-29 --- Created by: Gerard GRAS --- Copyright (c) 1993-1999 Matra Datavision --- Copyright (c) 1999-2012 OPEN CASCADE SAS --- --- The content of this file is subject to the Open CASCADE Technology Public --- License Version 6.5 (the "License"). You may not use the content of this file --- except in compliance with the License. Please obtain a copy of the License --- at http://www.opencascade.org and read it completely before using this file. --- --- The Initial Developer of the Original Code is Open CASCADE S.A.S., having its --- main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. --- --- The Original Code and all software distributed under the License is --- distributed on an "AS IS" basis, without warranty of any kind, and the --- Initial Developer hereby disclaims all such warranties, including without --- limitation, any warranties of merchantability, fitness for a particular --- purpose or non-infringement. Please see the License for the specific terms --- and conditions governing the rights and limitations under the License. - - - -class TextManager from Xw inherits TextManager from MFT - ----Purpose: defines the common behaviour of the Xw output driver. --- Warning: Permits to receives draw primitives from the FontManager --- at DrawText(...) time. --- This class must be redefined by the user as an application class. - -uses - Length from Quantity, - PlaneAngle from Quantity, - TypeOfText from Aspect - -is - - - ------------------------- - -- Category: Constructors - ------------------------- - - Create (aDrawable : Address from Standard; - aWidthMap : Address from Standard) - returns mutable TextManager from Xw; - ---Purpose: Does NOTHING - - ------------------------- - -- Category: Draw methods - ------------------------- - - BeginString (me: mutable; - X,Y: Length from Quantity; - anOrientation: PlaneAngle from Quantity; - aWidth,aHeight: Length from Quantity; - aSlant: PlaneAngle from Quantity; - aPaintType: Integer from Standard) is redefined; - ---Purpose: Calls when string drawing is started. - -- with a string aspect : - -- 0 for filled string - -- 1 for stroke string - -- 2 for outline string - -- The origine of the string ,, - -- The orientation of the string , - -- The medium size of the char , - -- The Slant of the char , - - BeginChar (me: mutable; - aCharCode: Integer from Standard; - X,Y: Length from Quantity) - returns Boolean from Standard is redefined; - ---Purpose: Calls when a char drawing is started - -- and give the current string position for this char. - -- and give the relative char position from the beginning - -- of the string. - -- The application can returns FALSE for skipping the char drawing. - - SetCharBoundingBox (me: mutable; - X1,Y1,X2,Y2,X3,Y3,X4,Y4: Length from Quantity) - returns Boolean from Standard is redefined; - ---Purpose: Calls to defines the current char bounding-box. - -- The application can returns FALSE for ending the char drawing. - - SetCharEncoding (me: mutable; - anEncoding: CString from Standard) - returns Boolean from Standard is redefined; - ---Purpose: Calls to defines the current char encoding. - -- Warning: The application can returns FALSE for skipping the char drawing. - - Moveto (me: mutable; - X,Y: Length from Quantity) - returns Boolean from Standard is redefined; - ---Purpose: Calls to sets the current string position. - -- The application can returns FALSE for ending the char drawing. - - Lineto (me: mutable; - X,Y: Length from Quantity) - returns Boolean from Standard is redefined; - ---Purpose: Calls to drawn to the current string position. - -- The application can returns FALSE for ending the char drawing. - - Curveto (me: mutable; - X1,Y1,X2,Y2,X3,Y3,X4,Y4: Length from Quantity) - returns Boolean from Standard is redefined; - ---Purpose: Calls to drawn to the current string position. - -- The application can drawn the curve defined by - -- his descriptor P1,P2,P3,P4 or - -- returns FALSE to let the interpretor compute the curve - -- vectors. - - ClosePath (me: mutable) is redefined; - ---Purpose: Calls when a char path drawing is ended - - EndChar (me: mutable; - X,Y: Length from Quantity) - returns Boolean from Standard is redefined; - ---Purpose: Calls when a char drawing is ended - -- and give the relative char ending position from the - -- beginning of the string. - -- The application can returns FALSE for skipping the string - -- drawing. - - - EndString (me: mutable ) is redefined; - ---Purpose: Calls when string drawing is ended (Normally the last call). - - ------------------------- - -- Category: Private methods - ------------------------- - - SetTextAttribs (me: mutable ; - aTextColor: Integer from Standard; - aTypeOfText: TypeOfText from Aspect; - anUnderlinePosition: Length from Quantity = 0.0) - is private; - ---Purpose: Sets the current attribs of the text. -fields - myDrawable: Address from Standard; - myWidthMap: Address from Standard; - -friends - class Driver from Xw - -end TextManager from Xw; diff --git a/src/Xw/Xw_TextManager.cxx b/src/Xw/Xw_TextManager.cxx deleted file mode 100755 index 2c447c7943..0000000000 --- a/src/Xw/Xw_TextManager.cxx +++ /dev/null @@ -1,310 +0,0 @@ -// Copyright (c) 1999-2012 OPEN CASCADE SAS -// -// The content of this file is subject to the Open CASCADE Technology Public -// License Version 6.5 (the "License"). You may not use the content of this file -// except in compliance with the License. Please obtain a copy of the License -// at http://www.opencascade.org and read it completely before using this file. -// -// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its -// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. -// -// The Original Code and all software distributed under the License is -// distributed on an "AS IS" basis, without warranty of any kind, and the -// Initial Developer hereby disclaims all such warranties, including without -// limitation, any warranties of merchantability, fitness for a particular -// purpose or non-infringement. Please see the License for the specific terms -// and conditions governing the rights and limitations under the License. - -#define S3593 //GG_130398 -// OPTIMISATION MFT -#define PRO14351//GG_180698 -// OPTIMISATION MFT - -#include -#include -#define TRACE 0 - -#define MAXCHARPOINTS 512 -#define MAXCHARPATHS 8 -#define TRANSFORM(X,Y) \ -{ Standard_Real x = X,y = Y; \ - X = x*theCosAngle - y*theSinAngle; \ - Y = x*theSinAngle + y*theCosAngle; \ - } - -// Routines C a declarer en extern -//extern "C" { -#include -//} - -static XW_ATTRIB thePolyCode,theLineCode; -static Standard_Integer thePaintType,theNchar,theNpoly,theNpath; -static Standard_Integer theTextColor,theLineColor,theLineType,theLineWidth; -static Standard_Integer thePolyColor,thePolyType,thePolyTile; -static XW_DRAWMODE theLineMode,thePolyMode; -static Aspect_TypeOfText theTypeOfText; -static Standard_ShortReal theUnderlinePosition; -static Standard_ShortReal theX,theY,thePX,thePY; -static Standard_ShortReal theXmin,theXmax,theSinAngle,theCosAngle; -static Standard_ShortReal theSlant,theWidth,theHeight; -static Standard_Real theOrientation; -static Standard_Boolean theClippingFlag; - -Xw_TextManager::Xw_TextManager(const Standard_Address aDrawable, const Standard_Address aWidthMap) : myDrawable(aDrawable),myWidthMap(aWidthMap) { -} - -void Xw_TextManager::BeginString( const Quantity_Length X, const Quantity_Length Y, const Quantity_PlaneAngle anOrientation, const Quantity_Length aWidth, const Quantity_Length aHeight, const Quantity_PlaneAngle aSlant, const Standard_Integer aPaintType) { -#if TRACE > 0 - cout << " Xw_TextManager::BeginString(" << - X << "," << Y << "," << anOrientation << "," - << aWidth << "," << aHeight << "," aSlant << "," - << aPaintType << ")" << endl; -#endif - - thePaintType = aPaintType; - theOrientation = anOrientation; - theX = X; theY = Y; - theXmin = theXmax = 0.; - theNchar = 0; - theSlant = aSlant; - theWidth = aWidth; - theHeight = aHeight; - theNpoly = theNpath = 0; - -#ifdef S3593 - // Set clipping off - theClippingFlag = Xw_get_clipping(myDrawable); - Xw_set_clipping(myDrawable,Standard_False); -#endif - // Save line attribs - thePolyCode = Xw_get_poly_attrib(myDrawable, - &thePolyColor,&thePolyType,&thePolyTile,&thePolyMode); - theLineCode = Xw_get_line_attrib(myDrawable, - &theLineColor,&theLineType,&theLineWidth,&theLineMode); - - Standard_ShortReal thickness = theHeight/32.; - Standard_Integer windex; - Xw_get_width_index(myWidthMap,thickness,&windex) ; - // Force to OUTLINE if required - if( !thePaintType ) { - if( (theHeight < (4. MILLIMETER)) || - (theTypeOfText == Aspect_TOT_OUTLINE) ) thePaintType = 2; - } - // Sets the MFT text attribs - switch (thePaintType) { - case 0: - Xw_set_poly_attrib(myDrawable, - theTextColor,Standard_False,0,XW_REPLACE); - Xw_set_line_attrib(myDrawable, - theTextColor,0,windex,XW_REPLACE); - break; - case 2: - Xw_set_poly_attrib(myDrawable, - theTextColor,Standard_True,-1,XW_REPLACE); - Xw_set_line_attrib(myDrawable, - theTextColor,0,windex,XW_REPLACE); - break; - case 1: - Xw_set_line_attrib(myDrawable, - theTextColor,0,windex,XW_REPLACE); -#ifndef PRO14351 - Xw_begin_segments(myDrawable, 0); -#endif - break; - } - -} - -Standard_Boolean Xw_TextManager::BeginChar(const Standard_Integer aCharCode, const Standard_Real X, const Standard_Real Y) { -#if TRACE > 0 - cout << " Xw_TextManager::BeginChar(" << aCharCode << "," << - X << "," << Y << ")" << endl; -#endif - - thePX = X; thePY = Y; -#ifndef PRO14351 - if( thePaintType != 1 ) -#endif - theNpoly = theNpath = 0; - return Standard_True; -} - -Standard_Boolean Xw_TextManager::SetCharBoundingBox(const Quantity_Length X1, const Quantity_Length Y1, const Quantity_Length X2, const Quantity_Length Y2, const Quantity_Length X3, const Quantity_Length Y3, const Quantity_Length X4, const Quantity_Length Y4) { - -#if TRACE > 0 - cout << " Xw_TextManager::SetCharBoundingBox(" << X1 << "," << Y1 << "," << - X2 << "," << Y2 << "," << X3 << "," << Y3 << "," << - X4 << "," << Y4 << ")" << endl; -#endif - - if( theUnderlinePosition > 0. ) { - if( !theNchar ) { - theXmin = Standard_ShortReal (X1); - } - theXmax = Sqrt(X2*X2 + Y2*Y2); - } - return Standard_True; -} - -Standard_Boolean Xw_TextManager::SetCharEncoding(const Standard_CString anEncoding) { - -#if TRACE > 0 - cout << " Xw_TextManager::SetCharEncoding('" << anEncoding << "')" << endl; -#endif - - return Standard_True; -} - -Standard_Boolean Xw_TextManager::Moveto(const Standard_Real X, const Standard_Real Y) { -#if TRACE > 1 - cout << " Xw_TextManager::Moveto(" << X << "," << Y << ")" << endl; -#endif - -#ifndef PRO14351 - if( thePaintType != 1 ) -#endif - this->ClosePath(); - thePX = X; thePY = Y; - - return Standard_True; -} - -Standard_Boolean Xw_TextManager::Lineto(const Standard_Real X, const Standard_Real Y) { -#if TRACE > 1 - cout << " Xw_TextManager::Lineto(" << X << "," << Y << ")" << endl; -#endif - switch (thePaintType) { - case 0: - case 2: - if( theNpoly == 0 ) { - Xw_begin_poly(myDrawable,MAXCHARPOINTS,MAXCHARPATHS); - } - if( theNpath == 0 ) { - Xw_poly_point(myDrawable, theX+thePX, theY+thePY); - } - Xw_poly_point(myDrawable, theX+Standard_ShortReal(X), - theY+Standard_ShortReal(Y)); - theNpath++; theNpoly++; - break; - case 1: -#ifndef PRO14351 - Xw_draw_segment(myDrawable, theX+thePX, theY+thePY, - theX+Standard_ShortReal(X), - theY+Standard_ShortReal(Y)); -#else - if( theNpoly == 0 ) { - Xw_begin_line(myDrawable,MAXCHARPOINTS); - Xw_line_point(myDrawable, theX+thePX, theY+thePY); - } - Xw_line_point(myDrawable, theX+Standard_ShortReal(X), - theY+Standard_ShortReal(Y)); -#endif - thePX = X; thePY = Y; - theNpoly++; - } - - return Standard_True; -} - -Standard_Boolean Xw_TextManager::Curveto(const Quantity_Length X1, const Quantity_Length Y1, const Quantity_Length X2, const Quantity_Length Y2, const Quantity_Length X3, const Quantity_Length Y3, const Quantity_Length X4, const Quantity_Length Y4) { - -#if TRACE > 0 - cout << " Xw_TextManager::Curveto(" << X1 << "," << Y1 << "," << - X2 << "," << Y2 << "," << X3 << "," << Y3 << "," << - X4 << "," << Y4 << ")" << endl; -#endif - - return Standard_False; -} - -void Xw_TextManager::ClosePath() { -#if TRACE > 0 - cout << " Xw_TextManager::ClosePath()" << endl; -#endif - switch (thePaintType) { - case 0: - case 2: - if( theNpath > 0 ) Xw_close_path(myDrawable); - theNpath = 0; - break; - case 1: -#ifdef PRO14351 - if( theNpoly > 0 ) Xw_close_line(myDrawable); - theNpoly = 0; -#endif - break; - } -} - -Standard_Boolean Xw_TextManager::EndChar(const Standard_Real X, const Standard_Real Y) { -#if TRACE > 0 - cout << " Xw_TextManager::EndChar(" << X << "," << Y << ")" << endl; -#endif - switch (thePaintType) { - case 0: - case 2: - Xw_close_poly(myDrawable); - break; - case 1: -#ifdef PRO14351 - Xw_close_line(myDrawable); - theNpoly = theNpath = 0; -#endif - break; - } - theNchar++; - - return Standard_True; -} - -void Xw_TextManager::EndString() { -#if TRACE > 0 - cout << " Xw_TextManager::EndString()" << endl; -#endif - - if( theUnderlinePosition > 0. ) { - Standard_ShortReal theX1 = theXmin; - Standard_ShortReal theY1 = -theUnderlinePosition; - Standard_ShortReal theX2 = theXmax; - Standard_ShortReal theY2 = theY1; - theSinAngle = Sin(theOrientation); - theCosAngle = Cos(theOrientation); - TRANSFORM(theX1,theY1); - TRANSFORM(theX2,theY2); -#ifndef PRO14351 - Xw_draw_segment(myDrawable, theX+theX1, theY+theY1, - theX+theX2, theY+theY2); -#else - Xw_begin_line(myDrawable,2); - Xw_line_point(myDrawable, theX+theX1, theY+theY1); - Xw_line_point(myDrawable, theX+theX2, theY+theY2); - Xw_close_line(myDrawable); -#endif - } - // Restore line attribs - switch (thePaintType) { - case 0: - case 2: - if( thePolyCode != ~0 ) Xw_set_poly_attrib(myDrawable, - thePolyColor,thePolyType,thePolyTile,thePolyMode); - case 1: -#ifndef PRO14351 - Xw_close_segments(myDrawable); - theNpoly = 0; -#endif - if( theLineCode != ~0 ) Xw_set_line_attrib(myDrawable, - theLineColor,theLineType,theLineWidth,theLineMode); - break; - } -#ifdef S3593 - // Restore clipping - Xw_set_clipping(myDrawable,theClippingFlag); -#endif -} - -void Xw_TextManager::SetTextAttribs( const Standard_Integer aTextColor, const Aspect_TypeOfText aTypeOfText, const Quantity_Length anUnderlinePosition) { - - theTextColor = aTextColor; - theTypeOfText = aTypeOfText; - theUnderlinePosition = anUnderlinePosition; -} diff --git a/src/Xw/Xw_Window.cdl b/src/Xw/Xw_Window.cdl index 7f3043bf89..e01f2d7843 100755 --- a/src/Xw/Xw_Window.cdl +++ b/src/Xw/Xw_Window.cdl @@ -676,7 +676,6 @@ fields friends - class Driver from Xw, class IconBox from Xw end Window ; diff --git a/tests/bugs/end b/tests/bugs/end index e3527d926f..859cb0086e 100755 --- a/tests/bugs/end +++ b/tests/bugs/end @@ -154,10 +154,6 @@ if { [info exist only_screen] } { vdump $imagedir/${test_image}.png } -if { [info exist only_screen2d] } { - v2ddump $imagedir/${test_image}.png -} - if { [info exist only_screen_axo] } { xwd $imagedir/${test_image}.png } diff --git a/tests/bugs/vis/buc60747 b/tests/bugs/vis/buc60747 deleted file mode 100755 index a45d4529d7..0000000000 --- a/tests/bugs/vis/buc60747 +++ /dev/null @@ -1,25 +0,0 @@ -puts "===========" -puts "BUC60747" -puts "BUC60611" -puts "BUC60639" -puts "===========" -puts "==================================" -puts "It takes visual check for this BUG" -puts "==================================" - -v2dinit -pcone c_o 15 0 50 360 -v2ddisplay c_o -v2dfit - -set x_coord 37 -set y_coord 287 -set color2d 1 - -checkcolor $x_coord $y_coord 1 1 0 - -if {$stat != 1} { - puts "Error : function V2DFIT works wrongly" -} - -set only_screen2d 1 diff --git a/tests/bugs/vis/bug153 b/tests/bugs/vis/bug153 deleted file mode 100755 index 1bd40ee629..0000000000 --- a/tests/bugs/vis/bug153 +++ /dev/null @@ -1,18 +0,0 @@ -puts "========================" -puts "OCC153" -puts "========================" - -########################################## -####### Draw command v2dsetbg hangs up the application -########################################## - -v2dinit -set j 1 -repeat 23 { - if [catch { v2dsetbg [locate_data_file OCC153.gif] } res] { - puts [format "%s ) Faulty OCC153: here is problem with v2dsetbg command" $j] - } else { - puts [format "%s ) : OCC153 OK" $j] - } - incr j - } diff --git a/tests/bugs/vis/bug154_1 b/tests/bugs/vis/bug154_1 deleted file mode 100755 index 7446630a42..0000000000 --- a/tests/bugs/vis/bug154_1 +++ /dev/null @@ -1,39 +0,0 @@ -puts "========" -puts "OCC154" -puts "========" -puts "" -############################################################## -##puts "Checking of functions V2DERASEALL and V2DDISPLAYALL " -##puts "(visual checking for this case is desirable)" -############################################################## -v2dinit - -box b 1 1 1 -box b1 10 10 10 1 1 1 -v2ddisplay b -v2ddisplay b1 -v2dfit - -v2deraseall - -set x_coord 370 -set y_coord 37 -set color2d 1 - -checkcolor $x_coord $y_coord 0 0 0 - -if { $stat != 1 } { - puts "Error : Object was not erased" -} - -v2ddisplayall - -checkcolor $x_coord $y_coord 1 1 0 - -if { $stat != 1 } { - puts "Error : Object was not displayed" -} - -set only_screen2d 1 - - diff --git a/tests/bugs/vis/bug154_2 b/tests/bugs/vis/bug154_2 deleted file mode 100755 index 1f9b99f63b..0000000000 --- a/tests/bugs/vis/bug154_2 +++ /dev/null @@ -1,32 +0,0 @@ -puts "========" -puts "OCC154" -puts "========" -puts "" -##################################################### -##puts "Checking of function V2DERASE " -##puts "(visual checking for this case is desirable)" -##################################################### - -v2dinit - -box b 1 1 1 -v2ddisplay b -box b1 10 10 10 1 1 1 -v2ddisplay b1 -v2dfit - -v2derase b1 - -set x_coord 370 -set y_coord 37 -set color2d 1 - -checkcolor $x_coord $y_coord 0 0 0 - -if { $stat != 1 } { - puts "Object was not erased" -} - -set only_screen2d 1 - - diff --git a/tests/bugs/vis/bug155_1 b/tests/bugs/vis/bug155_1 deleted file mode 100755 index 731a0cb2bd..0000000000 --- a/tests/bugs/vis/bug155_1 +++ /dev/null @@ -1,29 +0,0 @@ -puts "========" -puts "OCC155" -puts "OCC190" -puts "========" -puts "" -##################################### -##puts "Creating of Vertexes 2D" -##puts "(visual checking for this case is desirable)" -##################################### -v2dinit - -vertex v_v 0 0 0 -vertex v_v1 100 100 0 -v2ddisplay v_v -v2ddisplay v_v1 -v2dfit - -set x_coord 405 -set y_coord 7 -set color2d 1 - -checkcolor $x_coord $y_coord 1 1 0 - -if { $stat != 1 } { - puts "Error : Vertexes 2D were NOT LOADED properly" -} - -set only_screen2d 1 - diff --git a/tests/bugs/vis/bug155_2 b/tests/bugs/vis/bug155_2 deleted file mode 100755 index 0d7c9b1c68..0000000000 --- a/tests/bugs/vis/bug155_2 +++ /dev/null @@ -1,28 +0,0 @@ -puts "========" -puts "OCC155" -puts "OCC191" -puts "========" -puts "" -##################################### -##puts "Creating of pCone 2D" -##puts "(visual checking for this case is desirable)" -##################################### - -v2dinit - -pcone c_o 15 0 50 360 -v2ddisplay c_o -v2dfit - -set x_coord 338 -set y_coord 77 -set color2d 1 - -checkcolor $x_coord $y_coord 1 1 0 - -if { $stat != 1 } { - puts "Error : pCone 2D was NOT LOADED properly into viewer" -} - -set only_screen2d 1 - diff --git a/tests/bugs/vis/bug155_3 b/tests/bugs/vis/bug155_3 deleted file mode 100755 index d39023f923..0000000000 --- a/tests/bugs/vis/bug155_3 +++ /dev/null @@ -1,27 +0,0 @@ -puts "========" -puts "OCC155" -puts "========" -puts "" -################################################### -##puts "Creating of pCylinder 2D" -##puts "(visual checking for this case is desirable)" -################################################### - -v2dinit - -pcylinder c_y 5 10 -v2ddisplay c_y -v2dfit - -set x_coord 338 -set y_coord 75 -set color2d 1 - -checkcolor $x_coord $y_coord 1 1 0 - -if { $stat != 1 } { - puts "Error : pCylinder 2D was NOT LOADED properly into viewer" -} - -set only_screen2d 1 - diff --git a/tests/bugs/vis/bug193 b/tests/bugs/vis/bug193 deleted file mode 100755 index 080dbb338f..0000000000 --- a/tests/bugs/vis/bug193 +++ /dev/null @@ -1,33 +0,0 @@ -puts "========" -puts "OCC193" -puts "========" -puts "" -################################################## -##puts "Selection of NODE of ROTATED 2D Circular Grid WITH Lines" -##puts "(visual checking for this case is desirable)" -################################################## - -v2dinit -v2dgrid Circ 500 500 250 12 30 Lines - -set Position_X -667.802 -set Position_Y -441.402 - -set x_coord 67 -set y_coord 295 -set color2d 1 - -checkcolor $x_coord $y_coord 0.49 0.49 0.49 - -if { $stat != 1 } { - puts "Error : Objects was not displayed" -} - -v2dpickgrid 67 295 x_ch y_ch - -if { ${x_ch} != ${Position_X} || ${y_ch} != ${Position_Y} } { - puts "Error : Function v2dpickgrid works wrongly" -} - -set only_screen2d 1 - diff --git a/tests/bugs/vis/bug194_1 b/tests/bugs/vis/bug194_1 deleted file mode 100755 index 505afeb81f..0000000000 --- a/tests/bugs/vis/bug194_1 +++ /dev/null @@ -1,25 +0,0 @@ - -puts "========" -puts "OCC194" -puts "(case 1)" -puts "========" -puts "" -############################################### -##puts "Creating of 2D Rectangular ROTATED Grid WITH Lines" -##puts "(visual checking for this case is desirable)" -############################################### - -v2dinit -v2dgrid Rect 500 500 200 200 45 Lines - -set x_coord 25 -set y_coord 361 -set color2d 1 - -checkcolor $x_coord $y_coord 0.49 0.49 0.49 - -if { $stat != 1 } { - puts "Error : 2D Rectangular ROTATED Grid WITH Lines was NOT CREATED properly" -} - -set only_screen2d 1 diff --git a/tests/bugs/vis/bug194_2 b/tests/bugs/vis/bug194_2 deleted file mode 100755 index e5b0bd6ad6..0000000000 --- a/tests/bugs/vis/bug194_2 +++ /dev/null @@ -1,25 +0,0 @@ -puts "========" -puts "OCC194" -puts "(case 2)" -puts "========" -puts "" -############################################### -##puts "Creating of 2D Rectangular ROTATED Grid WITHOUT Lines" -##puts "(visual checking for this case is desirable)" -############################################### - -v2dinit -v2dgrid Rect 500 500 200 200 45 Points - -set x_coord 20 -set y_coord 21 -set color2d 1 - -checkcolor $x_coord $y_coord 0.7 0.7 0.7 - -if { $stat != 1 } { - puts "Error : 2D Rectangular ROTATED Grid WITHOUT Lines was NOT CREATED properly" -} - -set only_screen2d 1 - diff --git a/tests/bugs/vis/bug195 b/tests/bugs/vis/bug195 deleted file mode 100755 index a7327c101f..0000000000 --- a/tests/bugs/vis/bug195 +++ /dev/null @@ -1,38 +0,0 @@ - -puts "========" -puts "OCC195" -puts "========" -puts "" -###################################################### -##puts "Scaling of text font number 23" -##puts "(visual checking for this case is desirable)" -###################################################### - -v2dinit - -set Angle 0 -set Font_ind 23 -set k 0 -set i 0 -repeat 5 { - set Position_X [expr $i*20] - set Position_Y [expr $i*20] - set k [expr $k+.5] - set Scale $k - v2dtext Scale_[string range $k 0 2] $Position_X $Position_Y $Angle $Scale $Font_ind - puts "=======> Scale Factor = [string range $k 0 2] Position_X= $Position_Y Position_Y= $Position_Y" - puts " " - incr i -} - -set x_coord 190 -set y_coord 105 -set color2d 1 - -checkcolor $x_coord $y_coord 1 1 1 - -if { $stat != 1 } { - puts "Error : Scaling of text font number 23 was NOT MADE properly" -} - -set only_screen2d 1 diff --git a/tests/bugs/vis/bug196 b/tests/bugs/vis/bug196 deleted file mode 100755 index 6f24dc952f..0000000000 --- a/tests/bugs/vis/bug196 +++ /dev/null @@ -1,38 +0,0 @@ -puts "========" -puts "OCC196" -puts "========" -puts "" -################################################ -##puts "Rotation of text font number 23" -##puts "(visual checking for this case is desirable)" -################################################ - -v2dinit - -set Scale 1 -set Font_ind 23 -set k -.2 -set j 0 -repeat 10 { - set Position_X [expr $j*15] - set Position_Y [expr $j*-15] - set k [expr $k+.2] - set Angle $k - v2dtext Angle_[string range $k 0 2] $Position_X $Position_Y $Angle $Scale $Font_ind - puts "=======> Angle = [string range $k 0 4] Position_X= $Position_Y Position_Y= $Position_Y" - puts " " - incr j -} - -set x_coord 336 -set y_coord 347 -set color2d 1 - -checkcolor $x_coord $y_coord 1 1 1 - -if { $stat != 1 } { - puts "Error : Rotation of text font number 23 was NOT MADE properly" -} - -set only_screen2d 1 - diff --git a/tests/bugs/vis/bug198_1 b/tests/bugs/vis/bug198_1 deleted file mode 100755 index c698e44771..0000000000 --- a/tests/bugs/vis/bug198_1 +++ /dev/null @@ -1,36 +0,0 @@ -puts "========" -puts "OCC198" -puts "========" -puts "" -####################################################### -##puts "Changing of index of text fonts" -####################################################### - -v2dinit - -set mistake 0 -set Angle 0 -set Scale 1 -set k -1 -set j 0 -repeat 10 { - set i 0 - repeat 4 { - set Position_X [expr $i*70] - set Position_Y [expr $j*15] - set k [expr $k+1] - if [catch {Font_ind $k } ] { - set mistake 1 - } - incr i - } - incr j -} - -if {$mistake == 0} { - puts "Faulty : Changing of text fonts was NOT MADE properly" -} else { - puts "Changing of text fonts was made properly" -} - -set only_screen2d 1 diff --git a/tests/bugs/vis/bug198_2 b/tests/bugs/vis/bug198_2 deleted file mode 100755 index 6e42601d7c..0000000000 --- a/tests/bugs/vis/bug198_2 +++ /dev/null @@ -1,39 +0,0 @@ -puts "========" -puts "OCC198" -puts "========" -puts "" -####################################################### -##puts "Choosing of the font index color for font number 23" -####################################################### - -v2dinit - -v2dsetbgcolor BLUE3 -set Angle 0 -set Font_ind 23 -set Scale 1 -set k -1 -set j 0 -repeat 5 { - set i 0 - repeat 4 { - set Position_X [expr $i*50] - set Position_Y [expr $j*20] - set k [expr $k+1] - if [catch {v2dsettextcolor $a $k} ] { - set mistake 1 - } - incr i - } - incr j -} - -if {$mistake == 0} { - puts "Faulty : Changing of text index color was NOT MADE properly" -} else { - puts "Changing of text index color was made properly" -} - -set only_screen2d 1 - - diff --git a/tests/bugs/vis/bug200 b/tests/bugs/vis/bug200 deleted file mode 100644 index 48ae1c6eac..0000000000 --- a/tests/bugs/vis/bug200 +++ /dev/null @@ -1,23 +0,0 @@ -puts "========" -puts "OCC200" -puts "========" -puts "" - -####################################################### -##puts "2D Viewer. Changing of background color from BLACK to R (R is missing color name)" -##puts "(visual checking for this case is desirable)" -####################################################### - -set mistake 0 -v2dinit -if [catch {v2dsetbgcolor R} ] { - set mistake 1 -} - -if {$mistake != 0} { - puts "Faulty : Changing of backgroundcolor was NOT MADE properly" -} else { - puts "Changing of backgroundcolor was made properly" -} - -set only_screen2d 1 diff --git a/tests/bugs/vis/bug224 b/tests/bugs/vis/bug224 deleted file mode 100755 index 9a0f0df22b..0000000000 --- a/tests/bugs/vis/bug224 +++ /dev/null @@ -1,38 +0,0 @@ -puts "========================" -puts " OCC224 " -puts "========================" -puts "" -################################################# -##puts "Checking of function V2DUNSETWIDTH for shapes " -##puts "(visual checking for this case is desirable)" -################################################# - -v2dinit - -psphere s_p 100 360 -set mistake1 0 -v2ddisplay s_p 0 0 0 1 1 1 1 0 0 -v2dfit -v2dsetwidth s_p VERYTHICK - -set x_coord 393 -set y_coord 210 -set color2d 1 - -checkcolor $x_coord $y_coord 1 1 0 - -if { $stat != 1 } { - puts "Error : New widht was NOT assigned" -} - -v2dunsetwidth s_p - -checkcolor $x_coord $y_coord 0 0 0 - -if { $stat != 1 } { - puts "Error : Function V2DUNSETWIDTH for shapes does NOT WORK properly" -} - -set only_screen2d 1 - - diff --git a/tests/bugs/vis/bug225 b/tests/bugs/vis/bug225 deleted file mode 100755 index 34cac283db..0000000000 --- a/tests/bugs/vis/bug225 +++ /dev/null @@ -1,30 +0,0 @@ -puts "========================" -puts " OCC225 " -puts "========================" -puts "" -################################################# -##puts "Checking of function V2DUNSETCOLOR for BOX " -##puts "(visual checking for this case is desirable)" -################################################# - -v2dinit - -box b_b 10 15 20 -v2ddisplay b_b 0 0 0 1 1 1 1 0 0 -v2dfit -v2dsetcolor b_b BLUE3 -wait 5 -v2dunsetcolor b_b - -set x_coord 22 -set y_coord 230 -set color2d 1 - -checkcolor $x_coord $y_coord 1 1 0 - -if { $stat != 1 } { - puts "Error : function V2DUNSETCOLOR for BOX 2D does NOT WORK properly" -} - -set only_screen2d 1 - diff --git a/tests/bugs/vis/bug38 b/tests/bugs/vis/bug38 deleted file mode 100644 index 318c83ad46..0000000000 --- a/tests/bugs/vis/bug38 +++ /dev/null @@ -1,20 +0,0 @@ -puts "========" -puts "OCC38" -puts "========" - -set GAMMA_CORRECTION 0.5 -set env(Xw_SET_GAMMA_CORRECTION) ${GAMMA_CORRECTION} - -v2dinit - -set Xw_SET_GAMMA_CORRECTION [expr 1. / ${GAMMA_CORRECTION}] - -OCC404 0.7 0.7 0.7 - -set x_coord 10 -set y_coord 10 -set color2d 1 -checkcolor $x_coord $y_coord 0.6 0.6 0.6 - -set only_screen2d 1 - diff --git a/tests/bugs/vis/bug389 b/tests/bugs/vis/bug389 deleted file mode 100644 index adc4181bd2..0000000000 --- a/tests/bugs/vis/bug389 +++ /dev/null @@ -1,20 +0,0 @@ -puts "================" -puts "OCC389" -puts "================" -puts "" - -v2dinit - -box b 10 10 10 - -if [catch { OCC389 proj b } res] { - puts "OCC389: Error" - puts "${res}" -} else { - puts "OCC389: OK" -} - -v2ddisplay proj -v2dfit -set only_screen2d 1 - diff --git a/tests/bugs/vis/bug402 b/tests/bugs/vis/bug402 deleted file mode 100644 index 9e0d2bd691..0000000000 --- a/tests/bugs/vis/bug402 +++ /dev/null @@ -1,25 +0,0 @@ -puts "========" -puts "OCC402" -puts "========" - -v2dinit - -set IndexMarker 1 -set TypeOfDetection 0 -set X 10 -set Y 10 -set Width 3 -set Height 3 -set Angle 0 - -for {set i 1} {${i} <= 14} {incr i} { - OCC402 ${IndexMarker} ${TypeOfDetection} ${X} ${Y} ${Width} ${Height} ${Angle} - incr X 10 - incr Y 10 - incr IndexMarker 1 -} - -puts "There are 14 markers in the viewer" -puts "Visual checking is required !!!!" - -set only_screen2d 1 diff --git a/tests/bugs/vis/bug403 b/tests/bugs/vis/bug403 deleted file mode 100644 index 4377b77915..0000000000 --- a/tests/bugs/vis/bug403 +++ /dev/null @@ -1,35 +0,0 @@ -puts "========" -puts "OCC403" -puts "========" - -v2dinit -v2dgrid Rect 0 0 10 10 0 Lines - -OCC403 RED GREEN - -puts "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" -puts "Visual control: background is RED" -puts "Visual control: major grid lines are GREEN" -puts "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" -puts "" - -set x_coord 175 -set y_coord 155 -set color2d 1 -checkcolor $x_coord $y_coord 1 0 0 - -if {$stat != 1} { - puts "Faulty OCC403: background has NOT RED color" -} else { - puts "OCC403 OK: background is RED" -} - -set x_coord 122 -set y_coord 105 -checkcolor $x_coord $y_coord 0 1 0 - -if {$stat != 1} { - puts "Faulty OCC403: major grid lines have NOT GREEN color" -} - -set only_screen2d 1 diff --git a/tests/bugs/vis/bug404 b/tests/bugs/vis/bug404 deleted file mode 100644 index f7077a8ed8..0000000000 --- a/tests/bugs/vis/bug404 +++ /dev/null @@ -1,65 +0,0 @@ -puts "========" -puts "OCC404" -puts "========" - -v2dinit - -# -### RED -# -set R1 1 -set G1 0 -set B1 0 - -OCC404 ${R1} ${G1} ${B1} - -set x_coord 10 -set y_coord 10 -set color2d 1 -checkcolor $x_coord $y_coord 1 0 0 - -if { $stat != 1 } { - puts "OCC404: Get background color ERROR (case 1)" -} - - -# -### GREEN -# - -set R1 0 -set G1 1 -set B1 0 - -OCC404 ${R1} ${G1} ${B1} - -set x_coord 10 -set y_coord 10 -set color2d 1 -checkcolor $x_coord $y_coord 0 1 0 - -if { $stat != 1 } { - puts "OCC404: Get background color ERROR (case 2)" -} - - -# -### BLUE -# - -set R1 0 -set G1 0 -set B1 1 - -OCC404 ${R1} ${G1} ${B1} - -set x_coord 10 -set y_coord 10 -set color2d 1 -checkcolor $x_coord $y_coord 0 0 1 - -if { $stat != 1 } { - puts "OCC404: Get background color ERROR (case 2)" -} - -set only_screen2d 1 diff --git a/tests/bugs/vis/bug627 b/tests/bugs/vis/bug627 deleted file mode 100644 index 4674e5ab9d..0000000000 --- a/tests/bugs/vis/bug627 +++ /dev/null @@ -1,27 +0,0 @@ -puts "========" -puts "OCC627" -puts "========" - -v2dinit -v2dcircle circle 0 0 5 -v2dfit - -set i 10 -for {set j 1} {${j} <= ${i}} {incr j} { - v2derase circle - v2ddisplay circle -} - -set k [lindex [OCC627] 2] - -if {${k} != 1} { - puts "Sequence length = ${k}" - puts "OCC627: Error" -} - -set only_screen2d 1 - - - - - diff --git a/tests/bugs/vis/bug672_1 b/tests/bugs/vis/bug672_1 deleted file mode 100755 index e6785169fb..0000000000 --- a/tests/bugs/vis/bug672_1 +++ /dev/null @@ -1,40 +0,0 @@ -puts "===========" -puts "OCC672 " -puts "===========" -######################################################################################## -# Wrong visualization of 2d dimentions -# The following list of problems: -# 1) The length dimension value should always be aligned to the middle of -# the dimension line -# 2) The angular dimension value should always be aligned to the middle of -# the dimension line -# 3) All dimension values (text) must be aligned horizontally or vertically only. -# 4) All dimension lines must be bound with properly sized arrows. -######################################################################################## -puts "Test Length" -puts "===========" - -set x1 0 -set y1 -50 -set x2 400 -set y2 0 -set x3 400 -set y3 200 -set x4 0 -set y4 200 -set str "(center)" -set scale_text 4.0 -set length_dist -21.0 -set angle 30.0 -set ll 5.0 -set txtAngle 0. -set txtPosH 0. -set txtPosV 3. - -v2dinit - -OCC672_Length $x1 $y1 $x2 $y2 $str $scale_text $length_dist $angle $ll $x3 $y3 $x4 $y4 $txtAngle $txtPosH $txtPosV - -v2dfit - -set only_screen2d 1 diff --git a/tests/bugs/vis/bug672_2 b/tests/bugs/vis/bug672_2 deleted file mode 100755 index ff19cb0d3c..0000000000 --- a/tests/bugs/vis/bug672_2 +++ /dev/null @@ -1,40 +0,0 @@ -puts "===========" -puts "OCC672 " -puts "===========" -######################################################################################## -# Wrong visualization of 2d dimentions -# The following list of problems: -# 1) The length dimension value should always be aligned to the middle of -# the dimension line -# 2) The angular dimension value should always be aligned to the middle of -# the dimension line -# 3) All dimension values (text) must be aligned horizontally or vertically only. -# 4) All dimension lines must be bound with properly sized arrows. -######################################################################################## -puts "Test Angle " -puts "===========" - -set x1 0 -set y1 0 -set x2 -200 -set y2 100 -set x3 -200 -set y3 0 - -set TH -7. -set TV 35. -set txtAngle 0. - -set aText "ANGLE" -set aTxtScale 4.0 -set aRadius 150 -set anArrAngle 30 -set anArrLength 10.0 - -v2dinit - -OCC672_Angle $x1 $y1 $x2 $y2 $x3 $y3 $aRadius $aText $aTxtScale $anArrAngle $anArrLength $txtAngle $TH $TV - -v2dfit - -set only_screen2d 1 diff --git a/tests/bugs/vis/bug672_3 b/tests/bugs/vis/bug672_3 deleted file mode 100755 index 27f5fb136b..0000000000 --- a/tests/bugs/vis/bug672_3 +++ /dev/null @@ -1,37 +0,0 @@ -puts "===========" -puts "OCC672 " -puts "===========" -######################################################################################## -# Wrong visualization of 2d dimentions -# The following list of problems: -# 1) The length dimension value should always be aligned to the middle of -# the dimension line -# 2) The angular dimension value should always be aligned to the middle of -# the dimension line -# 3) All dimension values (text) must be aligned horizontally or vertically only. -# 4) All dimension lines must be bound with properly sized arrows. -######################################################################################## -puts "Test Diameter " -puts "===========" - -set x1 -100 -set y1 -100 -set cx 0 -set cy 0 -set radius 50 -set aText "10-E6" -set aTxtScale 4.0 -set anArrAngle 30 -set anArrLength 20.0 -set txtAngle 0. -set txtPosH 5. -set txtPosV 3. - - -v2dinit - -OCC672_Diameter $x1 $y1 $cx $cy $radius $aText $aTxtScale $anArrAngle $anArrLength $txtAngle $txtPosH $txtPosV - -v2dfit - -set only_screen2d 1 diff --git a/tests/bugs/vis/bug672_4 b/tests/bugs/vis/bug672_4 deleted file mode 100755 index 088f1fdd54..0000000000 --- a/tests/bugs/vis/bug672_4 +++ /dev/null @@ -1,40 +0,0 @@ -puts "===========" -puts "OCC672 " -puts "===========" -######################################################################################## -# Wrong visualization of 2d dimentions -# The following list of problems: -# 1) The length dimension value should always be aligned to the middle of -# the dimension line -# 2) The angular dimension value should always be aligned to the middle of -# the dimension line -# 3) All dimension values (text) must be aligned horizontally or vertically only. -# 4) All dimension lines must be bound with properly sized arrows. -######################################################################################## -puts "Test Short_Length" -puts "===========" - -set x1 330 -set y1 -30 -set x2 100 -set y2 100 -set x3 200 -set y3 -100 -set x4 330 -set y4 -30 -set str "(center)" -set scale_text 4. -set length_dist -10.0 -set angle 30.0 -set ll 5.0 -set txtAngle 0. -set txtPosH 0. -set txtPosV 3. - -v2dinit - -OCC672_ShortLength $x1 $y1 $x2 $y2 $str $scale_text $length_dist $angle $ll $x3 $y3 $x4 $y4 $txtAngle $txtPosH $txtPosV - -v2dfit - -set only_screen2d 1