From 0d1b52780bb7c4d9c3eca5ce6258ec3dd859b55f Mon Sep 17 00:00:00 2001 From: nds Date: Sat, 9 Nov 2019 07:12:06 +0300 Subject: [PATCH] 0030268: Inspectors - improvements in VInspector plugin # Dump for OCCT objects --- src/Bnd/Bnd_Box.cxx | 9 + src/Bnd/Bnd_Box.hxx | 3 + src/Bnd/Bnd_OBB.cxx | 9 + src/Bnd/Bnd_OBB.hxx | 3 + src/Graphic3d/Graphic3d_CStructure.cxx | 18 ++ src/Graphic3d/Graphic3d_Camera.cxx | 38 ++++ src/Graphic3d/Graphic3d_Camera.hxx | 3 + src/Graphic3d/Graphic3d_Layer.cxx | 38 ++++ src/Graphic3d/Graphic3d_Layer.hxx | 3 + src/Graphic3d/Graphic3d_ZLayerSettings.hxx | 26 +++ src/Prs3d/Prs3d_Drawer.cxx | 199 +++++++++--------- src/Standard/Standard_Dump.cxx | 29 ++- src/Standard/Standard_Dump.hxx | 28 ++- src/StdSelect/StdSelect_Shape.cxx | 2 + src/V3d/V3d_Viewer.cxx | 11 + src/V3d/V3d_Viewer.hxx | 3 + src/gp/gp_Ax1.cxx | 17 +- src/gp/gp_Ax1.hxx | 2 + src/gp/gp_Ax3.cxx | 32 ++- src/gp/gp_Ax3.hxx | 2 + src/gp/gp_Dir.cxx | 8 +- src/gp/gp_Dir.hxx | 3 + src/gp/gp_Pnt.cxx | 7 +- src/gp/gp_Pnt.hxx | 2 + src/gp/gp_XYZ.cxx | 24 +-- src/gp/gp_XYZ.hxx | 2 +- tools/Convert/Convert_Tools.cxx | 60 ++++++ tools/Convert/Convert_Tools.hxx | 10 + tools/MessageModel/MessageModel_Actions.cxx | 14 ++ tools/MessageView/MessageView_Window.cxx | 97 ++------- tools/MessageView/MessageView_Window.hxx | 4 +- tools/TInspectorEXE/TInspectorEXE.cxx | 8 +- tools/TKTInspectorAPI/EXTERNLIB | 1 + tools/TreeModel/TreeModel_ItemBase.cxx | 23 ++ tools/TreeModel/TreeModel_ItemBase.hxx | 7 + tools/TreeModel/TreeModel_ItemProperties.cxx | 5 + tools/TreeModel/TreeModel_ItemStream.cxx | 1 - tools/TreeModel/TreeModel_ItemStream.hxx | 4 - .../VInspector_ItemGraphic3dCamera.cxx | 15 ++ .../VInspector_ItemGraphic3dCamera.hxx | 4 + .../VInspector/VInspector_ItemPrs3dDrawer.cxx | 14 ++ .../VInspector/VInspector_ItemPrs3dDrawer.hxx | 4 + tools/VInspector/VInspector_ItemV3dViewer.cxx | 13 ++ tools/VInspector/VInspector_ItemV3dViewer.hxx | 4 + tools/VInspector/VInspector_Window.cxx | 3 +- tools/View/View_DisplayPreview.cxx | 54 ++++- tools/View/View_DisplayPreview.hxx | 1 + tools/View/View_PreviewParameters.cxx | 6 +- tools/View/View_ToolBar.cxx | 10 + tools/View/View_ToolBar.hxx | 4 + 50 files changed, 642 insertions(+), 245 deletions(-) diff --git a/src/Bnd/Bnd_Box.cxx b/src/Bnd/Bnd_Box.cxx index 2942963a73..2236b00693 100644 --- a/src/Bnd/Bnd_Box.cxx +++ b/src/Bnd/Bnd_Box.cxx @@ -985,3 +985,12 @@ void Bnd_Box::DumpJson (Standard_OStream& theOStream, const Standard_Integer) co OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, Gap); OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, Flags); } + +//======================================================================= +//function : InitJson +//purpose : +//======================================================================= +Standard_Boolean Bnd_Box::InitJson (const Standard_SStream& theSStream, Standard_Integer& theStreamPos) +{ + return Standard_False; +} diff --git a/src/Bnd/Bnd_Box.hxx b/src/Bnd/Bnd_Box.hxx index 4d220df02a..bac2a2c848 100644 --- a/src/Bnd/Bnd_Box.hxx +++ b/src/Bnd/Bnd_Box.hxx @@ -305,6 +305,9 @@ public: //! Dumps the content of me into the stream Standard_EXPORT void DumpJson (Standard_OStream& theOStream, const Standard_Integer theDepth = -1) const; + //! Inits the content of me into the stream + Standard_EXPORT Standard_Boolean InitJson (const Standard_SStream& theSStream, Standard_Integer& theStreamPos); + protected: //! Bit flags. diff --git a/src/Bnd/Bnd_OBB.cxx b/src/Bnd/Bnd_OBB.cxx index b3b9ebb677..0f6794c363 100644 --- a/src/Bnd/Bnd_OBB.cxx +++ b/src/Bnd/Bnd_OBB.cxx @@ -1041,3 +1041,12 @@ void Bnd_OBB::DumpJson (Standard_OStream& theOStream, const Standard_Integer the OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, myHDims[2]); OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, myIsAABox); } + +//======================================================================= +//function : InitJson +//purpose : +//======================================================================= +Standard_Boolean Bnd_OBB::InitJson (const Standard_SStream& theSStream, Standard_Integer& theStreamPos) +{ + return Standard_False; +} diff --git a/src/Bnd/Bnd_OBB.hxx b/src/Bnd/Bnd_OBB.hxx index 7844eaecfd..eec2808d14 100644 --- a/src/Bnd/Bnd_OBB.hxx +++ b/src/Bnd/Bnd_OBB.hxx @@ -285,6 +285,9 @@ public: //! Dumps the content of me into the stream Standard_EXPORT void DumpJson (Standard_OStream& theOStream, const Standard_Integer theDepth = -1) const; + //! Inits the content of me into the stream + Standard_EXPORT Standard_Boolean InitJson (const Standard_SStream& theSStream, Standard_Integer& theStreamPos); + protected: void ProcessOnePoint(const gp_Pnt& theP) diff --git a/src/Graphic3d/Graphic3d_CStructure.cxx b/src/Graphic3d/Graphic3d_CStructure.cxx index 85a2d5f5d9..9372ff32b0 100644 --- a/src/Graphic3d/Graphic3d_CStructure.cxx +++ b/src/Graphic3d/Graphic3d_CStructure.cxx @@ -60,6 +60,24 @@ void Graphic3d_CStructure::DumpJson (Standard_OStream& theOStream, const Standar OCCT_DUMP_FIELD_VALUES_DUMPED (theOStream, theDepth, aGroup.get()); } + OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, Id); + OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, myZLayer); + OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, Priority); + OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, PreviousPriority); + OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, ContainsFacet); + + //OCCT_DUMP_FIELD_VALUES_DUMPED (theOStream, theDepth, &ViewAffinity); + + OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, IsInfinite); + OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, stick); + OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, highlight); + OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, visible); + + OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, HLRValidation); + OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, IsForHighlight); + OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, IsMutable); + OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, Is2dText); + OCCT_DUMP_FIELD_VALUES_DUMPED (theOStream, theDepth, &myBndBox); OCCT_DUMP_FIELD_VALUES_DUMPED (theOStream, theDepth, myTrsf.get()); diff --git a/src/Graphic3d/Graphic3d_Camera.cxx b/src/Graphic3d/Graphic3d_Camera.cxx index 916d08048b..2877dfe23d 100644 --- a/src/Graphic3d/Graphic3d_Camera.cxx +++ b/src/Graphic3d/Graphic3d_Camera.cxx @@ -1546,3 +1546,41 @@ void Graphic3d_Camera::FrustumPoints (NCollection_Array1& thePo aTmpPnt = anInvWorldView * aLeftBottomFar; thePoints.SetValue (FrustumVert_LeftBottomFar, aTmpPnt.xyz() / aTmpPnt.w()); } + +//======================================================================= +//function : DumpJson +//purpose : +//======================================================================= +void Graphic3d_Camera::DumpJson (Standard_OStream& theOStream, const Standard_Integer theDepth) const +{ + OCCT_DUMP_CLASS_BEGIN (theOStream, Graphic3d_Camera); + + OCCT_DUMP_FIELD_VALUES_DUMPED (theOStream, theDepth, &myUp); + OCCT_DUMP_FIELD_VALUES_DUMPED (theOStream, theDepth, &myDirection); + OCCT_DUMP_FIELD_VALUES_DUMPED (theOStream, theDepth, &myEye); + + OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, myDistance); + + /*gp_XYZ myAxialScale; //!< World axial scale. + + Projection myProjType; //!< Projection type used for rendering. + Standard_Real myFOVy; //!< Field Of View in y axis. + Standard_Real myFOVyTan; //!< Field Of View as Tan(DTR_HALF * myFOVy) + Standard_Real myZNear; //!< Distance to near clipping plane. + Standard_Real myZFar; //!< Distance to far clipping plane. + Standard_Real myAspect; //!< Width to height display ratio. + + Standard_Real myScale; //!< Specifies parallel scale for orthographic projection. + Standard_Real myZFocus; //!< Stereographic focus value. + FocusType myZFocusType; //!< Stereographic focus definition type. + + Standard_Real myIOD; //!< Intraocular distance value. + IODType myIODType; //!< Intraocular distance definition type. + + Graphic3d_CameraTile myTile;//!< Tile defining sub-area for drawing + + mutable TransformMatrices myMatricesD; + mutable TransformMatrices myMatricesF; + + mutable Graphic3d_WorldViewProjState myWorldViewProjState;*/ +} diff --git a/src/Graphic3d/Graphic3d_Camera.hxx b/src/Graphic3d/Graphic3d_Camera.hxx index 62fc9f77d8..ce07f2d8b6 100644 --- a/src/Graphic3d/Graphic3d_Camera.hxx +++ b/src/Graphic3d/Graphic3d_Camera.hxx @@ -552,6 +552,9 @@ public: //! The matrix will be updated on request. Standard_EXPORT void InvalidateOrientation(); + //! Dumps the content of me into the stream + Standard_EXPORT void DumpJson (Standard_OStream& theOStream, const Standard_Integer theDepth = -1) const; + //! @name Managing projection and orientation cache private: diff --git a/src/Graphic3d/Graphic3d_Layer.cxx b/src/Graphic3d/Graphic3d_Layer.cxx index 70a4eaf439..3859b60aad 100644 --- a/src/Graphic3d/Graphic3d_Layer.cxx +++ b/src/Graphic3d/Graphic3d_Layer.cxx @@ -626,3 +626,41 @@ void Graphic3d_Layer::SetLayerSettings (const Graphic3d_ZLayerSettings& theSetti } } } + +// ======================================================================= +// function : DumpJson +// purpose : +// ======================================================================= +void Graphic3d_Layer::DumpJson (Standard_OStream& theOStream, const Standard_Integer theDepth) const +{ + OCCT_DUMP_CLASS_BEGIN (theOStream, Graphic3d_Layer); + + OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, myLayerId); + OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, myNbStructures); + OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, myNbStructuresNotCulled); + + const Standard_Integer aNbPriorities = myArray.Length(); + for (Standard_Integer aPriorityIter = 0; aPriorityIter < aNbPriorities; ++aPriorityIter) + { + const Graphic3d_IndexedMapOfStructure& aStructures = myArray (aPriorityIter); + for (Graphic3d_IndexedMapOfStructure::Iterator aStructIter (aStructures); aStructIter.More(); aStructIter.Next()) + { + const Graphic3d_CStructure* aStructure = aStructIter.Value(); + OCCT_DUMP_FIELD_VALUE_POINTER (theOStream, aStructure); + } + } + + OCCT_DUMP_FIELD_VALUES_DUMPED (theOStream, theDepth, &myLayerSettings); + + //mutable Graphic3d_BvhCStructureSet myBVHPrimitives; + //mutable Graphic3d_BvhCStructureSetTrsfPers myBVHPrimitivesTrsfPers; + //mutable NCollection_IndexedMap myAlwaysRenderedMap; + + OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, myBVHIsLeftChildQueuedFirst); + OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, myIsBVHPrimitivesNeedsReset); + OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, myIsBoundingBoxNeedsReset[0]); + OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, myIsBoundingBoxNeedsReset[1]); + + OCCT_DUMP_FIELD_VALUES_DUMPED (theOStream, theDepth, &myBoundingBox[0]); + OCCT_DUMP_FIELD_VALUES_DUMPED (theOStream, theDepth, &myBoundingBox[1]); +} diff --git a/src/Graphic3d/Graphic3d_Layer.hxx b/src/Graphic3d/Graphic3d_Layer.hxx index 820113e13f..0954d24706 100644 --- a/src/Graphic3d/Graphic3d_Layer.hxx +++ b/src/Graphic3d/Graphic3d_Layer.hxx @@ -144,6 +144,9 @@ public: //! Returns indexed map of always rendered structures. const NCollection_IndexedMap& NonCullableStructures() const { return myAlwaysRenderedMap; } + //! Dumps the content of me into the stream + Standard_EXPORT void DumpJson (Standard_OStream& theOStream, const Standard_Integer theDepth = -1) const; + protected: //! Updates BVH trees if their state has been invalidated. diff --git a/src/Graphic3d/Graphic3d_ZLayerSettings.hxx b/src/Graphic3d/Graphic3d_ZLayerSettings.hxx index b61c0a3070..408afc0b9a 100644 --- a/src/Graphic3d/Graphic3d_ZLayerSettings.hxx +++ b/src/Graphic3d/Graphic3d_ZLayerSettings.hxx @@ -19,6 +19,7 @@ #include #include #include +#include #include enum Graphic3d_ZLayerSetting @@ -208,6 +209,31 @@ struct Graphic3d_ZLayerSettings myPolygonOffset.Units =-1.0f; } + //! Dumps the content of me into the stream + Standard_EXPORT void DumpJson (Standard_OStream& theOStream, const Standard_Integer theDepth = -1) const + { + OCCT_DUMP_CLASS_BEGIN (theOStream, Graphic3d_ZLayerSettings); + + OCCT_DUMP_FIELD_VALUE_STRING (theOStream, myName); + //OCCT_DUMP_FIELD_VALUES_DUMPED (theOStream, theDepth, myLights.get()); + OCCT_DUMP_FIELD_VALUES_DUMPED (theOStream, theDepth, myOriginTrsf.get()); + OCCT_DUMP_FIELD_VALUES_DUMPED (theOStream, theDepth, &myOrigin); + + OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, myCullingDistance); + OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, myCullingSize); + + OCCT_DUMP_FIELD_VALUES_DUMPED (theOStream, theDepth, &myPolygonOffset); + + OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, myIsImmediate); + OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, myToRaytrace); + OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, myUseEnvironmentTexture); + OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, myToEnableDepthTest); + OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, myToEnableDepthWrite); + OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, myToClearDepth); + OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, myToRenderInDepthPrepass); + + } + protected: TCollection_AsciiString myName; //!< user-provided name diff --git a/src/Prs3d/Prs3d_Drawer.cxx b/src/Prs3d/Prs3d_Drawer.cxx index 8af632626e..59da3959f1 100644 --- a/src/Prs3d/Prs3d_Drawer.cxx +++ b/src/Prs3d/Prs3d_Drawer.cxx @@ -1442,103 +1442,110 @@ bool Prs3d_Drawer::SetShadingModel (Graphic3d_TypeOfShadingModel theModel, void Prs3d_Drawer::DumpJson (Standard_OStream& theOStream, const Standard_Integer theDepth) const { OCCT_DUMP_CLASS_BEGIN (theOStream, Prs3d_Drawer); - OCCT_DUMP_FIELD_VALUES_DUMPED (theOStream, theDepth, myShadingAspect.get()); - //Handle(Prs3d_Drawer) myLink; - /* - Standard_Boolean myHasOwnNbPoints; - Standard_Real myMaximalParameterValue; - Standard_Boolean myHasOwnMaximalParameterValue; - Standard_Real myChordialDeviation; - Standard_Boolean myHasOwnChordialDeviation; - Aspect_TypeOfDeflection myTypeOfDeflection; - Standard_Boolean myHasOwnTypeOfDeflection; - Prs3d_TypeOfHLR myTypeOfHLR; - Standard_Real myDeviationCoefficient; - Standard_Real myPreviousDeviationCoefficient; - Standard_Boolean myHasOwnDeviationCoefficient; - Standard_Real myHLRDeviationCoefficient; - Standard_Boolean myHasOwnHLRDeviationCoefficient; - Standard_Real myPreviousHLRDeviationCoefficient; - Standard_Real myDeviationAngle; - Standard_Boolean myHasOwnDeviationAngle; - Standard_Real myPreviousDeviationAngle; - Standard_Real myHLRAngle; - Standard_Boolean myHasOwnHLRDeviationAngle; - Standard_Real myPreviousHLRDeviationAngle; - Standard_Boolean myIsoOnPlane; - Standard_Boolean myHasOwnIsoOnPlane; - Standard_Boolean myIsoOnTriangulation; - Standard_Boolean myHasOwnIsoOnTriangulation; - Standard_Boolean myIsAutoTriangulated; - Standard_Boolean myHasOwnIsAutoTriangulated;*/ - - /*Handle(Prs3d_IsoAspect) myUIsoAspect; - Standard_Boolean myHasOwnUIsoAspect; - Handle(Prs3d_IsoAspect) myVIsoAspect; - Standard_Boolean myHasOwnVIsoAspect; - Handle(Prs3d_LineAspect) myWireAspect; - Standard_Boolean myHasOwnWireAspect; - Standard_Boolean myWireDraw; - Standard_Boolean myHasOwnWireDraw; - Handle(Prs3d_PointAspect) myPointAspect; - Standard_Boolean myHasOwnPointAspect; - Handle(Prs3d_LineAspect) myLineAspect; - Standard_Boolean myHasOwnLineAspect; - */ - - OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, myHasOwnTextAspect); - if (!myTextAspect.IsNull()) - OCCT_DUMP_FIELD_VALUES_DUMPED (theOStream, theDepth, myTextAspect.get()); - - //Handle(Prs3d_ShadingAspect) myShadingAspect; - //Standard_Boolean myHasOwnShadingAspect; - - /*Handle(Prs3d_PlaneAspect) myPlaneAspect; - Standard_Boolean myHasOwnPlaneAspect; - Handle(Prs3d_LineAspect) mySeenLineAspect; - Standard_Boolean myHasOwnSeenLineAspect; - Handle(Prs3d_ArrowAspect) myArrowAspect; - Standard_Boolean myHasOwnArrowAspect; - Standard_Boolean myLineArrowDraw; - Standard_Boolean myHasOwnLineArrowDraw; - Handle(Prs3d_LineAspect) myHiddenLineAspect; - Standard_Boolean myHasOwnHiddenLineAspect; - Standard_Boolean myDrawHiddenLine; - Standard_Boolean myHasOwnDrawHiddenLine; - Handle(Prs3d_LineAspect) myVectorAspect; - Standard_Boolean myHasOwnVectorAspect; - Prs3d_VertexDrawMode myVertexDrawMode; - Handle(Prs3d_DatumAspect) myDatumAspect; - Standard_Boolean myHasOwnDatumAspect; - Handle(Prs3d_LineAspect) mySectionAspect; - Standard_Boolean myHasOwnSectionAspect; - - Handle(Prs3d_LineAspect) myFreeBoundaryAspect; - Standard_Boolean myHasOwnFreeBoundaryAspect; - Standard_Boolean myFreeBoundaryDraw; - Standard_Boolean myHasOwnFreeBoundaryDraw; - Handle(Prs3d_LineAspect) myUnFreeBoundaryAspect; - Standard_Boolean myHasOwnUnFreeBoundaryAspect; - Standard_Boolean myUnFreeBoundaryDraw; - Standard_Boolean myHasOwnUnFreeBoundaryDraw; - Handle(Prs3d_LineAspect) myFaceBoundaryAspect; - Standard_Integer myFaceBoundaryUpperContinuity; //!< the most edge continuity class (GeomAbs_Shape) to be included to face boundaries presentation, or -1 if undefined - Standard_Boolean myHasOwnFaceBoundaryAspect; - Standard_Boolean myFaceBoundaryDraw; - Standard_Boolean myHasOwnFaceBoundaryDraw; - - Handle(Prs3d_DimensionAspect) myDimensionAspect; - Standard_Boolean myHasOwnDimensionAspect; - Prs3d_DimensionUnits myDimensionModelUnits; - Standard_Boolean myHasOwnDimLengthModelUnits; - Standard_Boolean myHasOwnDimAngleModelUnits; - Prs3d_DimensionUnits myDimensionDisplayUnits; - Standard_Boolean myHasOwnDimLengthDisplayUnits; - Standard_Boolean myHasOwnDimAngleDisplayUnits; - */ + OCCT_DUMP_FIELD_VALUE_POINTER (theOStream, myLink.get()); + + OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, myHasOwnNbPoints); + OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, myMaximalParameterValue); + OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, myHasOwnMaximalParameterValue); + OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, myChordialDeviation); + OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, myHasOwnChordialDeviation); + OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, myTypeOfDeflection); + OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, myHasOwnTypeOfDeflection); + OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, myTypeOfHLR); + OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, myDeviationCoefficient); + OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, myPreviousDeviationCoefficient); + OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, myHasOwnDeviationCoefficient); + OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, myHLRDeviationCoefficient); + OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, myHasOwnHLRDeviationCoefficient); + OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, myPreviousHLRDeviationCoefficient); + OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, myDeviationAngle); + OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, myHasOwnDeviationAngle); + OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, myPreviousDeviationAngle); + OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, myHLRAngle); + OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, myHasOwnHLRDeviationAngle); + OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, myPreviousHLRDeviationAngle); + OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, myIsoOnPlane); + OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, myHasOwnIsoOnPlane); + OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, myIsoOnTriangulation); + OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, myHasOwnIsoOnTriangulation); + OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, myIsAutoTriangulated); + OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, myHasOwnIsAutoTriangulated); + + //OCCT_DUMP_FIELD_VALUES_DUMPED (theOStream, theDepth, myUIsoAspect.get()); + OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, myHasOwnUIsoAspect); + + //OCCT_DUMP_FIELD_VALUES_DUMPED (theOStream, theDepth, myVIsoAspect.get()); + OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, myHasOwnVIsoAspect); + + //OCCT_DUMP_FIELD_VALUES_DUMPED (theOStream, theDepth, myWireAspect.get()); + OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, myHasOwnWireAspect); + OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, myWireDraw); + OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, myHasOwnWireDraw); + + //OCCT_DUMP_FIELD_VALUES_DUMPED (theOStream, theDepth, myPointAspect.get()); + OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, myHasOwnPointAspect); + + //OCCT_DUMP_FIELD_VALUES_DUMPED (theOStream, theDepth, myLineAspect.get()); + OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, myHasOwnLineAspect); + + //OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, myHasOwnTextAspect); + OCCT_DUMP_FIELD_VALUES_DUMPED (theOStream, theDepth, myTextAspect.get()); + + OCCT_DUMP_FIELD_VALUES_DUMPED (theOStream, theDepth, myShadingAspect.get()); + OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, myHasOwnShadingAspect); + + //OCCT_DUMP_FIELD_VALUES_DUMPED (theOStream, theDepth, myPlaneAspect.get()); + OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, myHasOwnPlaneAspect); + + //OCCT_DUMP_FIELD_VALUES_DUMPED (theOStream, theDepth, mySeenLineAspect.get()); + OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, myHasOwnSeenLineAspect); + + //OCCT_DUMP_FIELD_VALUES_DUMPED (theOStream, theDepth, myArrowAspect.get()); + OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, myHasOwnArrowAspect); + OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, myLineArrowDraw); + OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, myHasOwnLineArrowDraw); + + //OCCT_DUMP_FIELD_VALUES_DUMPED (theOStream, theDepth, myHiddenLineAspect.get()); + OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, myHasOwnHiddenLineAspect); + OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, myDrawHiddenLine); + OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, myHasOwnDrawHiddenLine); + + //OCCT_DUMP_FIELD_VALUES_DUMPED (theOStream, theDepth, myVectorAspect.get()); + OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, myHasOwnVectorAspect); + OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, myVertexDrawMode); + + //OCCT_DUMP_FIELD_VALUES_DUMPED (theOStream, theDepth, myDatumAspect.get()); + OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, myHasOwnDatumAspect); + + //OCCT_DUMP_FIELD_VALUES_DUMPED (theOStream, theDepth, mySectionAspect.get()); + OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, myHasOwnSectionAspect); + + //OCCT_DUMP_FIELD_VALUES_DUMPED (theOStream, theDepth, myFreeBoundaryAspect.get()); + OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, myHasOwnFreeBoundaryAspect); + OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, myFreeBoundaryDraw); + OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, myHasOwnFreeBoundaryDraw); + + //OCCT_DUMP_FIELD_VALUES_DUMPED (theOStream, theDepth, myUnFreeBoundaryAspect.get()); + OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, myHasOwnUnFreeBoundaryAspect); + OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, myUnFreeBoundaryDraw); + OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, myHasOwnUnFreeBoundaryDraw); + + //OCCT_DUMP_FIELD_VALUES_DUMPED (theOStream, theDepth, myFaceBoundaryAspect.get()); + OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, myFaceBoundaryUpperContinuity); + OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, myHasOwnFaceBoundaryAspect); + OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, myFaceBoundaryDraw); + OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, myHasOwnFaceBoundaryDraw); + + //OCCT_DUMP_FIELD_VALUES_DUMPED (theOStream, theDepth, myDimensionAspect.get()); + OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, myHasOwnDimensionAspect); + //OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, myDimensionModelUnits); + OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, myHasOwnDimLengthModelUnits); + OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, myHasOwnDimAngleModelUnits); + //OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, myDimensionDisplayUnits); + OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, myHasOwnDimLengthDisplayUnits); + OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, myHasOwnDimAngleDisplayUnits); OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, myHasOwnFillCappingAspect); - if (!myFillCappingAspect.IsNull()) - OCCT_DUMP_FIELD_VALUES_DUMPED (theOStream, theDepth, myFillCappingAspect.get()); + //OCCT_DUMP_FIELD_VALUES_DUMPED (theOStream, theDepth, myFillCappingAspect.get()); } diff --git a/src/Standard/Standard_Dump.cxx b/src/Standard/Standard_Dump.cxx index 4a36e19b8f..f1a0bfdc92 100644 --- a/src/Standard/Standard_Dump.cxx +++ b/src/Standard/Standard_Dump.cxx @@ -43,7 +43,7 @@ void Standard_Dump::AddValuesSeparator (Standard_OStream& theOStream) Standard_SStream aStream; aStream << theOStream.rdbuf(); TCollection_AsciiString aStreamStr = Standard_Dump::Text (aStream); - if (!aStreamStr.EndsWith ("{")) + if (!aStreamStr.IsEmpty() && !aStreamStr.EndsWith ("{")) theOStream << ", "; } @@ -104,9 +104,17 @@ Standard_Boolean Standard_Dump::ProcessStreamName (const Standard_SStream& theSt TCollection_AsciiString aText = Text (theStream); if (aText.IsEmpty()) return Standard_False; - TCollection_AsciiString aSubText = aText.SubString (theStreamPos, aText.Length()); - TCollection_AsciiString aKeyName = theName + JsonKeyToString (Standard_JsonKey_SeparatorKeyToValue); + TCollection_AsciiString aSubText = aText.SubString (theStreamPos, aText.Length()); + if (aSubText.StartsWith (JsonKeyToString (Standard_JsonKey_SeparatorValueToValue))) + { + theStreamPos += JsonKeyLength (Standard_JsonKey_SeparatorValueToValue); + aSubText = aText.SubString (theStreamPos, aText.Length()); + } + TCollection_AsciiString aKeyName = TCollection_AsciiString (JsonKeyToString (Standard_JsonKey_Quote)) + + theName + + TCollection_AsciiString (JsonKeyToString (Standard_JsonKey_Quote)) + + JsonKeyToString (Standard_JsonKey_SeparatorKeyToValue); Standard_Boolean aResult = aSubText.StartsWith (aKeyName); if (aResult) theStreamPos += aKeyName.Length(); @@ -122,14 +130,15 @@ Standard_Boolean Standard_Dump::InitRealValues (const Standard_SStream& theStrea Standard_Integer& theStreamPos, int theCount, ...) { - Standard_Integer aStreamPos = theStreamPos + JsonKeyLength (Standard_JsonKey_OpenContainer) + 1; + Standard_Integer aStreamPos = theStreamPos + JsonKeyLength (Standard_JsonKey_OpenContainer); TCollection_AsciiString aText = Text (theStream); TCollection_AsciiString aSubText = aText.SubString (aStreamPos, aText.Length()); - Standard_Integer aClosePos = aSubText.Location (JsonKeyToString (Standard_JsonKey_CloseContainer), aStreamPos, aSubText.Length()); va_list vl; va_start(vl, theCount); + aStreamPos = 1; + Standard_Integer aClosePos = aSubText.Location (JsonKeyToString (Standard_JsonKey_CloseContainer), aStreamPos, aSubText.Length()); for(int i = 0; i < theCount; ++i) { //if (i < theCount -1) @@ -142,13 +151,15 @@ Standard_Boolean Standard_Dump::InitRealValues (const Standard_SStream& theStrea if (!aValueText.IsRealValue()) return Standard_False; - va_arg(vl, Standard_Real) = aValueText.RealValue(); + Standard_Real aVal = aValueText.RealValue(); + *(va_arg(vl, Standard_Real*)) = aValueText.RealValue(); - aStreamPos = aNextPos + 1; + aStreamPos = aNextPos + JsonKeyLength (Standard_JsonKey_SeparatorValueToValue); //theOStream << va_arg(vl, Standard_Real); } va_end(vl); - + aClosePos = aText.Location (JsonKeyToString (Standard_JsonKey_CloseContainer), theStreamPos, aText.Length()); + theStreamPos = aClosePos + JsonKeyLength (Standard_JsonKey_CloseContainer); return Standard_True; } @@ -461,7 +472,7 @@ Standard_Boolean Standard_Dump::splitKeyToValue (const TCollection_AsciiString& Standard_Integer aCloseIndex2 = nextClosePosition (theStreamStr, aStartIndex, Standard_JsonKey_None, Standard_JsonKey_SeparatorValueToValue) - 1; aCloseIndex = aCloseIndex1 < aCloseIndex2 ? aCloseIndex1 : aCloseIndex2; - aSplitValue = theStreamStr.SubString (aStartIndex, aCloseIndex); + aSplitValue = aStartIndex <= aCloseIndex ? theStreamStr.SubString (aStartIndex, aCloseIndex) : ""; theNextIndex = aCloseIndex + 1; } break; diff --git a/src/Standard/Standard_Dump.hxx b/src/Standard/Standard_Dump.hxx index c4f46ef4f0..52dfbae3f2 100644 --- a/src/Standard/Standard_Dump.hxx +++ b/src/Standard/Standard_Dump.hxx @@ -33,7 +33,7 @@ class Standard_DumpSentry; //! It creates "key": { result of dump of the field } //! - OCCT_DUMP_FIELD_VALUES_NUMERICAL. Use it for unlimited list of fields of C++ double type. //! It creates massive of values [value_1, value_2, ...] -//! - OCCT_DUMP_FIELD_VALUES_STRING. Use it for unlimited list of fields of TCollection_AsciiString types. +//! - OCCT_DUMP_FIELD_VALUES_STRING. Use it for unlimited list of fields of TCollection_AsciiString types.F //! It creates massive of values ["value_1", "value_2", ...] //! - OCCT_DUMP_BASE_CLASS. Use if Dump implementation of the class is virtual, to perform ClassName::Dump() of the parent class, //! expected parameter is the parent class name. @@ -90,16 +90,27 @@ class Standard_DumpSentry; //! Depth = -1 is the default value, dump here is unlimited. #define OCCT_DUMP_FIELD_VALUES_DUMPED(theOStream, theDepth, theField) \ { \ - if (theDepth != 0) \ + if (theDepth != 0 && (theField) != NULL) \ { \ Standard_SStream aFieldStream; \ - if ((theField) != NULL) \ - (theField)->DumpJson (aFieldStream, theDepth - 1); \ + (theField)->DumpJson (aFieldStream, theDepth - 1); \ const char* aName = Standard_Dump::DumpFieldToName (#theField); \ Standard_Dump::DumpKeyToClass (theOStream, aName, Standard_Dump::Text (aFieldStream)); \ } \ } +//! @def OCCT_INIT_FIELD_VALUES_DUMPED +//! Append into output value: "Name": { field dumped values } +//! It computes Dump of the fields. The expected field is a pointer. +//! Use this macro for fields of the dumped class which has own Dump implementation. +//! The macros is recursive. Recursion is stopped when the depth value becomes equal to zero. +//! Depth = -1 is the default value, dump here is unlimited. +#define OCCT_INIT_FIELD_VALUES_DUMPED(theSStream, theStreamPos, theField) \ +{ \ + if ((theField) == NULL || !(theField)->InitJson (theSStream, theStreamPos)) \ + return Standard_False; \ +} + //! @def OCCT_DUMP_FIELD_VALUES_NUMERICAL //! Append real values into output values in an order: [value_1, value_2, ...] //! It computes Dump of the parent. The expected field is a parent class name to call ClassName::Dump. @@ -143,21 +154,24 @@ class Standard_DumpSentry; //! It's possible to use it without necessity of OCCT_DUMP_CLASS_BEGIN call, but pay attention that it should be only one row in the object dump. #define OCCT_DUMP_VECTOR_CLASS(theOStream, theName, theCount, ...) \ { \ + Standard_Dump::AddValuesSeparator (theOStream); \ theOStream << "\"" << OCCT_CLASS_NAME(theName) << "\": ["; \ Standard_Dump::DumpRealValues (theOStream, theCount, __VA_ARGS__);\ theOStream << "]"; \ } -//! @def OCCT_DUMP_VECTOR_CLASS +//! @def OCCT_INIT_VECTOR_CLASS //! Append vector values into output value: "Name": [value_1, value_2, ...] //! This macro is intended to have only one row for dumped object in Json. //! It's possible to use it without necessity of OCCT_DUMP_CLASS_BEGIN call, but pay attention that it should be only one row in the object dump. #define OCCT_INIT_VECTOR_CLASS(theOStream, theName, theStreamPos, theCount, ...) \ { \ - if (!Standard_Dump::ProcessStreamName (theOStream, OCCT_CLASS_NAME(theName), theStreamPos)) \ + Standard_Integer aStreamPos = theStreamPos; \ + if (!Standard_Dump::ProcessStreamName (theOStream, OCCT_CLASS_NAME(theName), aStreamPos)) \ return Standard_False; \ - if (!Standard_Dump::InitRealValues (theOStream, theStreamPos, theCount, __VA_ARGS__)) \ + if (!Standard_Dump::InitRealValues (theOStream, aStreamPos, theCount, __VA_ARGS__)) \ return Standard_False; \ + theStreamPos = aStreamPos; \ } //! @brief Simple sentry class providing convenient interface to dump. diff --git a/src/StdSelect/StdSelect_Shape.cxx b/src/StdSelect/StdSelect_Shape.cxx index 0a94438e63..d92d449927 100644 --- a/src/StdSelect/StdSelect_Shape.cxx +++ b/src/StdSelect/StdSelect_Shape.cxx @@ -76,5 +76,7 @@ void StdSelect_Shape::DumpJson (Standard_OStream& theOStream, const Standard_Int { OCCT_DUMP_CLASS_BEGIN (theOStream, StdSelect_Shape); + OCCT_DUMP_BASE_CLASS (theOStream, theDepth, PrsMgr_PresentableObject); + OCCT_DUMP_FIELD_VALUES_DUMPED (theOStream, theDepth, &mysh); } diff --git a/src/V3d/V3d_Viewer.cxx b/src/V3d/V3d_Viewer.cxx index 951df3752d..9b3d663909 100644 --- a/src/V3d/V3d_Viewer.cxx +++ b/src/V3d/V3d_Viewer.cxx @@ -573,3 +573,14 @@ void V3d_Viewer::DisplayPrivilegedPlane (const Standard_Boolean theOnOff, const myPlaneStructure->Display(); } + +//======================================================================= +//function : DumpJson +//purpose : +//======================================================================= +void V3d_Viewer::DumpJson (Standard_OStream& theOStream, const Standard_Integer theDepth) const +{ + OCCT_DUMP_CLASS_BEGIN (theOStream, V3d_Viewer); + + OCCT_DUMP_FIELD_VALUES_DUMPED (theOStream, theDepth, &myPrivilegedPlane); +} diff --git a/src/V3d/V3d_Viewer.hxx b/src/V3d/V3d_Viewer.hxx index 51e2db182f..8f62a1bdb5 100644 --- a/src/V3d/V3d_Viewer.hxx +++ b/src/V3d/V3d_Viewer.hxx @@ -480,6 +480,9 @@ public: //! @name deprecated methods aColor.Values (theV1, theV2, theV3, theType) ; } + //! Dumps the content of me into the stream + Standard_EXPORT virtual void DumpJson (Standard_OStream& theOStream, const Standard_Integer theDepth = -1) const; + private: //! Returns the default background colour. diff --git a/src/gp/gp_Ax1.cxx b/src/gp/gp_Ax1.cxx index af08f0b87d..5c0c7a22d4 100644 --- a/src/gp/gp_Ax1.cxx +++ b/src/gp/gp_Ax1.cxx @@ -86,8 +86,19 @@ gp_Ax1 gp_Ax1::Mirrored (const gp_Ax2& A2) const return A1; } -void gp_Ax1::DumpJson (Standard_OStream& theOStream, const Standard_Integer theDepth) const +void gp_Ax1::DumpJson (Standard_OStream& theOStream, const Standard_Integer) const { - OCCT_DUMP_FIELD_VALUES_DUMPED (theOStream, theDepth, &loc); - OCCT_DUMP_FIELD_VALUES_DUMPED (theOStream, theDepth, &vdir); + OCCT_DUMP_VECTOR_CLASS (theOStream, Location, 3, loc.X(), loc.Y(), loc.Z()) + OCCT_DUMP_VECTOR_CLASS (theOStream, Direction, 3, vdir.X(), vdir.Y(), vdir.Z()) +} + +Standard_Boolean gp_Ax1::InitJson (const Standard_SStream& theSStream, Standard_Integer& theStreamPos) +{ + gp_XYZ& anXYZLoc = loc.ChangeCoord(); + OCCT_INIT_VECTOR_CLASS (theSStream, Location, theStreamPos, 3, &anXYZLoc.ChangeCoord (1), &anXYZLoc.ChangeCoord (2), &anXYZLoc.ChangeCoord (3)) + gp_XYZ aDir; + OCCT_INIT_VECTOR_CLASS (theSStream, Direction, theStreamPos, 3, &aDir.ChangeCoord (1), &aDir.ChangeCoord (2), &aDir.ChangeCoord (3)) + SetDirection (aDir); + + return Standard_True; } diff --git a/src/gp/gp_Ax1.hxx b/src/gp/gp_Ax1.hxx index be14617419..30ebcd3a62 100644 --- a/src/gp/gp_Ax1.hxx +++ b/src/gp/gp_Ax1.hxx @@ -208,6 +208,8 @@ public: //! Dumps the content of me into the stream Standard_EXPORT virtual void DumpJson (Standard_OStream& theOStream, const Standard_Integer theDepth = -1) const; + //! Inits the content of me into the stream + Standard_EXPORT Standard_Boolean InitJson (const Standard_SStream& theSStream, Standard_Integer& theStreamPos); protected: diff --git a/src/gp/gp_Ax3.cxx b/src/gp/gp_Ax3.cxx index 7ae671a26a..874f0704e9 100644 --- a/src/gp/gp_Ax3.cxx +++ b/src/gp/gp_Ax3.cxx @@ -107,9 +107,33 @@ gp_Ax3 gp_Ax3::Mirrored(const gp_Ax2& A2)const } -void gp_Ax3::DumpJson (Standard_OStream& theOStream, const Standard_Integer theDepth) const +void gp_Ax3::DumpJson (Standard_OStream& theOStream, const Standard_Integer) const { - OCCT_DUMP_FIELD_VALUES_DUMPED (theOStream, theDepth, &axis); - OCCT_DUMP_FIELD_VALUES_DUMPED (theOStream, theDepth, &vydir); - OCCT_DUMP_FIELD_VALUES_DUMPED (theOStream, theDepth, &vxdir); + OCCT_DUMP_VECTOR_CLASS (theOStream, Location, 3, Location().X(), Location().Y(), Location().Z()) + OCCT_DUMP_VECTOR_CLASS (theOStream, Direction, 3, Direction().X(), Direction().Y(), Direction().Z()) + + OCCT_DUMP_VECTOR_CLASS (theOStream, XDirection, 3, XDirection().X(), XDirection().Y(), XDirection().Z()) + OCCT_DUMP_VECTOR_CLASS (theOStream, YDirection, 3, YDirection().X(), YDirection().Y(), YDirection().Z()) +} + +Standard_Boolean gp_Ax3::InitJson (const Standard_SStream& theSStream, Standard_Integer& theStreamPos) +{ + gp_XYZ anXYZLoc; + OCCT_INIT_VECTOR_CLASS (theSStream, Location, theStreamPos, 3, &anXYZLoc.ChangeCoord (1), &anXYZLoc.ChangeCoord (2), &anXYZLoc.ChangeCoord (3)) + SetLocation (anXYZLoc); + + gp_XYZ aDir; + OCCT_INIT_VECTOR_CLASS (theSStream, Direction, theStreamPos, 3, &aDir.ChangeCoord (1), &aDir.ChangeCoord (2), &aDir.ChangeCoord (3)) + gp_XYZ aXDir; + OCCT_INIT_VECTOR_CLASS (theSStream, XDirection, theStreamPos, 3, &aXDir.ChangeCoord (1), &aXDir.ChangeCoord (2), &aXDir.ChangeCoord (3)) + gp_XYZ anYDir; + OCCT_INIT_VECTOR_CLASS (theSStream, YDirection, theStreamPos, 3, &anYDir.ChangeCoord (1), &anYDir.ChangeCoord (2), &anYDir.ChangeCoord (3)) + + SetXDirection (aXDir); + SetYDirection (anYDir); + + if (!Direction().IsEqual (aDir, Precision::Confusion())) + return Standard_False; + + return Standard_True; } diff --git a/src/gp/gp_Ax3.hxx b/src/gp/gp_Ax3.hxx index 49268f3eb1..60756a67d7 100644 --- a/src/gp/gp_Ax3.hxx +++ b/src/gp/gp_Ax3.hxx @@ -293,6 +293,8 @@ public: //! Dumps the content of me into the stream Standard_EXPORT virtual void DumpJson (Standard_OStream& theOStream, const Standard_Integer theDepth = -1) const; + //! Inits the content of me into the stream + Standard_EXPORT Standard_Boolean InitJson (const Standard_SStream& theSStream, Standard_Integer& theStreamPos); protected: diff --git a/src/gp/gp_Dir.cxx b/src/gp/gp_Dir.cxx index a6c679ccc9..f6bc02f41c 100644 --- a/src/gp/gp_Dir.cxx +++ b/src/gp/gp_Dir.cxx @@ -142,5 +142,11 @@ gp_Dir gp_Dir::Mirrored (const gp_Ax2& A2) const void gp_Dir::DumpJson (Standard_OStream& theOStream, const Standard_Integer theDepth) const { - OCCT_DUMP_FIELD_VALUES_DUMPED (theOStream, theDepth, &coord); + OCCT_DUMP_VECTOR_CLASS (theOStream, gp_Dir, 3, coord.X(), coord.Y(), coord.Z()) +} + +Standard_Boolean gp_Dir::InitJson (const Standard_SStream& theSStream, Standard_Integer& theStreamPos) +{ + OCCT_INIT_VECTOR_CLASS (theSStream, gp_Dir, theStreamPos, 3, &coord.ChangeCoord (1), &coord.ChangeCoord (2), &coord.ChangeCoord (3)) + return Standard_True; } diff --git a/src/gp/gp_Dir.hxx b/src/gp/gp_Dir.hxx index de1944db5e..528371425d 100644 --- a/src/gp/gp_Dir.hxx +++ b/src/gp/gp_Dir.hxx @@ -266,6 +266,9 @@ public: //! Dumps the content of me into the stream Standard_EXPORT virtual void DumpJson (Standard_OStream& theOStream, const Standard_Integer theDepth = -1) const; + //! Inits the content of me into the stream + Standard_EXPORT Standard_Boolean InitJson (const Standard_SStream& theSStream, Standard_Integer& theStreamPos); + protected: diff --git a/src/gp/gp_Pnt.cxx b/src/gp/gp_Pnt.cxx index a3543dd7b1..6d0e017a3f 100644 --- a/src/gp/gp_Pnt.cxx +++ b/src/gp/gp_Pnt.cxx @@ -88,5 +88,10 @@ gp_Pnt gp_Pnt::Mirrored (const gp_Ax2& A2) const void gp_Pnt::DumpJson (Standard_OStream& theOStream, const Standard_Integer theDepth) const { - OCCT_DUMP_FIELD_VALUES_DUMPED (theOStream, theDepth, &coord); + OCCT_DUMP_VECTOR_CLASS (theOStream, gp_Pnt, 3, coord.X(), coord.Y(), coord.Z()) +} + +Standard_Boolean gp_Pnt::InitJson (const Standard_SStream& theSStream, Standard_Integer& theStreamPos) +{ + OCCT_INIT_VECTOR_CLASS (theSStream, gp_Pnt, theStreamPos, 3, &coord.ChangeCoord (1), &coord.ChangeCoord (2), &coord.ChangeCoord (3)) } diff --git a/src/gp/gp_Pnt.hxx b/src/gp/gp_Pnt.hxx index 58894f45e7..11452adf69 100644 --- a/src/gp/gp_Pnt.hxx +++ b/src/gp/gp_Pnt.hxx @@ -177,6 +177,8 @@ public: //! Dumps the content of me into the stream Standard_EXPORT virtual void DumpJson (Standard_OStream& theOStream, const Standard_Integer theDepth = -1) const; + //! Inits the content of me into the stream + Standard_EXPORT Standard_Boolean InitJson (const Standard_SStream& theSStream, Standard_Integer& theStreamPos); protected: diff --git a/src/gp/gp_XYZ.cxx b/src/gp/gp_XYZ.cxx index aaf9a3e536..9d612643c0 100644 --- a/src/gp/gp_XYZ.cxx +++ b/src/gp/gp_XYZ.cxx @@ -47,30 +47,8 @@ void gp_XYZ::DumpJson (Standard_OStream& theOStream, const Standard_Integer) con //function : InitJson //purpose : //======================================================================= -Standard_Boolean gp_XYZ::InitJson (Standard_SStream& theSStream, Standard_Integer& theStreamPos) +Standard_Boolean gp_XYZ::InitJson (const Standard_SStream& theSStream, Standard_Integer& theStreamPos) { OCCT_INIT_VECTOR_CLASS (theSStream, gp_XYZ, theStreamPos, 3, &x, &y, &z) - - //NCollection_IndexedDataMap aValues; - //if (!Standard_Dump::SplitJson (Standard_Dump::Text (theSStream), aValues) || aValues.Size() > 1) - // return Standard_False; - - //if (aValues.FindKey (1).IsEqual (OCCT_CLASS_NAME(gp_XYZ))) - // return Standard_False; - - //NCollection_IndexedMap aValuesList; - - //TCollection_AsciiString aValue = aValues.FindFromIndex (1); - //aValue.Split (Standard_Dump::JsonKeyToString (Standard_JsonKey_SeparatorValueToValue), aValuesList); - - //if (aValuesList.Size() != 3 || - // !aValuesList.FindKey(1).IsRealValue() || !aValuesList.FindKey(2).IsRealValue() || !aValuesList.FindKey(3).IsRealValue()) - // return Standard_False; - - //x = aValuesList.FindKey(1).RealValue(); - //y = aValuesList.FindKey(2).RealValue(); - //z = aValuesList.FindKey(3).RealValue(); - - return Standard_True; } diff --git a/src/gp/gp_XYZ.hxx b/src/gp/gp_XYZ.hxx index da45bc41d1..6225402b63 100644 --- a/src/gp/gp_XYZ.hxx +++ b/src/gp/gp_XYZ.hxx @@ -332,7 +332,7 @@ public: Standard_EXPORT void DumpJson (Standard_OStream& theOStream, const Standard_Integer theDepth = -1) const; //! Inits the content of me into the stream - Standard_EXPORT Standard_Boolean InitJson (Standard_SStream& theSStream, Standard_Integer& theStreamPos); + Standard_EXPORT Standard_Boolean InitJson (const Standard_SStream& theSStream, Standard_Integer& theStreamPos); protected: diff --git a/tools/Convert/Convert_Tools.cxx b/tools/Convert/Convert_Tools.cxx index e455a7cbeb..061ed017c1 100644 --- a/tools/Convert/Convert_Tools.cxx +++ b/tools/Convert/Convert_Tools.cxx @@ -14,7 +14,11 @@ // commercial license or contractual agreement. #include +#include +#include +#include +#include #include #include #include @@ -23,6 +27,62 @@ #include #include +//======================================================================= +//function : CreateShape +//purpose : +//======================================================================= +void Convert_Tools::ConvertStreamToPresentations (const Standard_SStream& theSStream, + const Standard_Integer theStartPos, + const Standard_Integer /*theLastPos*/, + NCollection_List& thePresentations) +{ + int aStartPos = theStartPos; + gp_XYZ aPoint; + if (aPoint.InitJson (theSStream, aStartPos)) + { + thePresentations.Append (new Convert_TransientShape (BRepBuilderAPI_MakeVertex (aPoint))); + return; + } + + gp_Pnt aPnt; + if (aPnt.InitJson (theSStream, aStartPos)) + { + thePresentations.Append (new Convert_TransientShape (BRepBuilderAPI_MakeVertex (aPnt))); + return; + } + + gp_Dir aDir; + if (aDir.InitJson (theSStream, aStartPos)) + { + thePresentations.Append (new Convert_TransientShape (BRepBuilderAPI_MakeEdge (gp::Origin(), aDir.XYZ()))); + return; + } + + gp_Ax3 aPln; + if (aPln.InitJson (theSStream, aStartPos)) + { + Handle(Geom_Plane) aGeomPlane = new Geom_Plane (aPln); + Handle(AIS_Plane) aPlanePrs = new AIS_Plane (aGeomPlane); + + // TODO - default fields to be defined in another place + aPlanePrs->Attributes()->SetPlaneAspect (new Prs3d_PlaneAspect()); + Handle (Prs3d_PlaneAspect) aPlaneAspect = aPlanePrs->Attributes()->PlaneAspect(); + aPlaneAspect->SetPlaneLength (100, 100); + aPlaneAspect->SetDisplayCenterArrow (Standard_True); + aPlaneAspect->SetDisplayEdgesArrows (Standard_True); + aPlaneAspect->SetArrowsSize (100); + aPlaneAspect->SetArrowsLength (100); + aPlaneAspect->SetDisplayCenterArrow (Standard_True); + aPlaneAspect->SetDisplayEdges (Standard_True); + + aPlanePrs->SetColor (Quantity_NOC_WHITE); + aPlanePrs->SetTransparency (0); + + thePresentations.Append (aPlanePrs); + return; + } +} + //======================================================================= //function : CreateShape //purpose : diff --git a/tools/Convert/Convert_Tools.hxx b/tools/Convert/Convert_Tools.hxx index ecce1fdc5f..763392f130 100644 --- a/tools/Convert/Convert_Tools.hxx +++ b/tools/Convert/Convert_Tools.hxx @@ -22,6 +22,7 @@ #include #include #include +#include #include #include #include @@ -29,6 +30,7 @@ #include #include #include +#include #include #include @@ -42,6 +44,14 @@ class Geom_Transformation; class Convert_Tools { public: + //! Creates shape presentations on the stream if possible. Tries to init some OCCT base for a new presentation + //! \param theStream source of presentation + //! \param thePresentations container to add new presentation/s + Standard_EXPORT static void ConvertStreamToPresentations (const Standard_SStream& theSStream, + const Standard_Integer theStartPos, + const Standard_Integer theLastPos, + NCollection_List& thePresentations); + //! Creates box shape //! \param theBoundingBox box shape parameters //! \return created shape diff --git a/tools/MessageModel/MessageModel_Actions.cxx b/tools/MessageModel/MessageModel_Actions.cxx index 03115c1a2f..d586f84b1a 100644 --- a/tools/MessageModel/MessageModel_Actions.cxx +++ b/tools/MessageModel/MessageModel_Actions.cxx @@ -347,6 +347,20 @@ void MessageModel_Actions::OnTestPropertyPanel() aCoords.DumpJson (aStream); MESSAGE_INFO_STREAM(aStream, "gp_XYZ", "", &aPerfMeter, NULL); } + // gp_Dir + { + gp_Dir aDir (0.3, 0.3, 0.4); + Standard_SStream aStream; + aDir.DumpJson (aStream); + MESSAGE_INFO_STREAM(aStream, "gp_Dir", "", &aPerfMeter, NULL); + } + // gp_Ax3 + { + gp_Ax3 aPln (gp_Pnt (10., 20., 15.), gp_Dir (0., 0., 1.), gp_Dir (1., 0., 0.)); + Standard_SStream aStream; + aPln.DumpJson (aStream); + MESSAGE_INFO_STREAM(aStream, "gp_Ax3", "", &aPerfMeter, NULL); + } // Bnd_Box { Bnd_Box aBox (gp_Pnt (20., 15., 10.), gp_Pnt (25., 20., 15.)); diff --git a/tools/MessageView/MessageView_Window.cxx b/tools/MessageView/MessageView_Window.cxx index 69fda29840..217dc83e93 100644 --- a/tools/MessageView/MessageView_Window.cxx +++ b/tools/MessageView/MessageView_Window.cxx @@ -25,14 +25,14 @@ #include #include -#include #include #include #include #include -#include +#include +#include #include #include #include @@ -142,6 +142,8 @@ Handle(Prs3d_Drawer) GetPreviewAttributes (const Handle(AIS_InteractiveContext)& MessageView_Window::MessageView_Window (QWidget* theParent) : QObject (theParent) { + myDisplayPreview = new View_DisplayPreview(); + myMainWindow = new QMainWindow (theParent); myTreeView = new ViewControl_TreeView (myMainWindow); @@ -363,6 +365,7 @@ void MessageView_Window::Init (NCollection_List& the if (!aContext.IsNull()) { myViewWindow->SetContext (View_ContextType_External, aContext); + myViewWindow->GetViewToolBar()->SetCurrentContextType (View_ContextType_External); } if (!aViewCamera.IsNull()) @@ -409,7 +412,7 @@ void MessageView_Window::addReport (const Handle(Message_Report)& theReport, } // ======================================================================= -// function : onTreeViewSelectionChanged +// function : onTreeViewVisibilityClicked // purpose : // ======================================================================= void MessageView_Window::onTreeViewVisibilityClicked(const QModelIndex& theIndex) @@ -444,21 +447,17 @@ void MessageView_Window::onTreeViewSelectionChanged (const QItemSelection&, cons if (!anItemBase) continue; - //Handle(TreeModel_ItemProperties) anItemProperties = anItemBase->GetProperties(); - //if (anItemProperties) - // anItemProperties->GetPresentations (-1, -1, aPresentations); - TreeModel_ItemStreamPtr aStreamParent = itemDynamicCast (anItemBase); - if (!aStreamParent) - return; - - Handle(TreeModel_ItemProperties) anItemProperties = aStreamParent->Properties (); + Handle(TreeModel_ItemProperties) anItemProperties = anItemBase->Properties (); if (anItemProperties) + { anItemProperties->GetPresentations (-1, -1, aPresentations); + } MessageModel_ItemAlertPtr anAlertItem = itemDynamicCast(anItemBase); - if (!anAlertItem) - continue; - anAlertItem->GetPresentations (aPresentations); + if (anAlertItem) + { + anAlertItem->GetPresentations (aPresentations); + } } updatePreviewPresentation (aPresentations); } @@ -729,10 +728,10 @@ void MessageView_Window::updatePropertyPanelBySelection() return; QModelIndex anIndex = TreeModel_ModelBase::SingleSelected (aModel->selectedIndexes(), 0); - TreeModel_ItemStreamPtr aStreamItem = itemDynamicCast (TreeModel_ModelBase::GetItemByIndex (anIndex)); - if (aStreamItem) + TreeModel_ItemBasePtr anItemBase = TreeModel_ModelBase::GetItemByIndex (anIndex); + if (anItemBase) { - Handle(TreeModel_ItemProperties) anItemProperties = aStreamItem->Properties (); + Handle(TreeModel_ItemProperties) anItemProperties = anItemBase->Properties (); if (!anItemProperties.IsNull()) { ViewControl_TableModelValues* aTableValues = new ViewControl_TableModelValues(); @@ -753,66 +752,6 @@ void MessageView_Window::updatePreviewPresentation (const NCollection_List::Iterator aDisplayedIt (myPreviewPresentations); aDisplayedIt.More(); aDisplayedIt.Next()) - { - Handle(AIS_InteractiveObject) aPrs = Handle(AIS_InteractiveObject)::DownCast (aDisplayedIt.Value()); - if (!aPrs.IsNull() && aPrs->GetContext() == aContext) - aContext->Remove (aPrs, Standard_True); - } - } - myPreviewPresentations.Clear(); - - myPreviewPresentations = thePresentations; - if (myPreviewPresentations.IsEmpty()) - return; - - BRep_Builder aBuilder; - TopoDS_Compound aCompound; - aBuilder.MakeCompound (aCompound); - for (NCollection_List::Iterator aDisplayedIt (myPreviewPresentations); aDisplayedIt.More(); aDisplayedIt.Next()) - { - Handle(AIS_InteractiveObject) aPrs = Handle(AIS_InteractiveObject)::DownCast (aDisplayedIt.Value()); - if (!aPrs.IsNull()) - { - if (!aPrs->GetContext().IsNull()) - continue; // not possible to display one object in several contexts - aContext->Display (aPrs, AIS_Shaded, -1/*do not participate in selection*/, Standard_True); - } - else if (!Handle(Convert_TransientShape)::DownCast (aDisplayedIt.Value()).IsNull()) - { - Handle(Convert_TransientShape) aShapeObject = Handle(Convert_TransientShape)::DownCast (aDisplayedIt.Value()); - aBuilder.Add (aCompound, aShapeObject->GetShape()); - } - } - - if (aCompound.IsNull()) - { - if (!aContext.IsNull() && myPreviewPresentation->GetContext() == aContext) - aContext->Remove (myPreviewPresentation, Standard_True); - myPreviewPresentation = NULL; - return; - - } - else - { - if (myPreviewPresentation.IsNull()) - { - myPreviewPresentation = new AIS_Shape (aCompound); - myPreviewPresentation->SetAttributes (GetPreviewAttributes(aContext)); - //myPreviewPresentation->SetAttributes (myPreviewParameters->GetDrawer()); - - //myPreviewPresentation->SetTransformPersistence(thePersistent); - if (!aContext.IsNull()) - aContext->Display (myPreviewPresentation, AIS_Shaded, -1/*do not participate in selection*/, Standard_True); - } - else - { - Handle(AIS_Shape)::DownCast (myPreviewPresentation)->Set (aCompound); - //myPreviewPresentation->SetTransformPersistence(thePersistent); - if (!aContext.IsNull() && myPreviewPresentation->GetContext() == aContext) - aContext->Redisplay (myPreviewPresentation, Standard_True); - } - } + myDisplayPreview->SetContext (aContext); + myDisplayPreview->UpdatePreview (View_DisplayActionType_DisplayId, thePresentations); } diff --git a/tools/MessageView/MessageView_Window.hxx b/tools/MessageView/MessageView_Window.hxx index 6ff19ed309..0c51aafb9d 100644 --- a/tools/MessageView/MessageView_Window.hxx +++ b/tools/MessageView/MessageView_Window.hxx @@ -40,6 +40,7 @@ class View_Window; +class View_DisplayPreview; class ViewControl_PropertyView; class MessageModel_ReportCallBack; @@ -172,6 +173,8 @@ private: QDockWidget* myPropertyPanelWidget; //!< property pane dockable widget ViewControl_PropertyView* myPropertyView; //!< property control to display model item values if exist + View_DisplayPreview* myDisplayPreview; //!< class for preview display + View_Window* myViewWindow; //!< OCC 3d view to visualize presentations QTreeView* myTreeView; //!< tree view visualized shapes MessageModel_Actions* myTreeViewActions; //!< processing history view actions @@ -180,7 +183,6 @@ private: Handle(Message_ReportCallBack) myCallBack; //! < message call back to update content of the view Handle(AIS_InteractiveObject) myPreviewPresentation; //!< presentation of preview for a selected object - NCollection_List myPreviewPresentations; }; #endif diff --git a/tools/TInspectorEXE/TInspectorEXE.cxx b/tools/TInspectorEXE/TInspectorEXE.cxx index b3f1a5ad37..1c42a38530 100644 --- a/tools/TInspectorEXE/TInspectorEXE.cxx +++ b/tools/TInspectorEXE/TInspectorEXE.cxx @@ -126,10 +126,10 @@ int main (int argc, char** argv) aPlugins.insert("TKShapeView"); aPlugins.insert("TKVInspector"); - //Handle(Message_Report) aReport = Message_Report::CurrentReport (Standard_True); - //aReport->SetLimit (100);//30); - //aReport->SetActive (Standard_True);//Standard_False); - //aPlugins.insert("TKMessageView"); + Handle(Message_Report) aReport = Message_Report::CurrentReport (Standard_True); + aReport->SetLimit (100);//30); + aReport->SetActive (Standard_True);//Standard_False); + aPlugins.insert("TKMessageView"); anActivatedPluginName = "TKVInspector"; //anActivatedPluginName = "TKMessageView"; diff --git a/tools/TKTInspectorAPI/EXTERNLIB b/tools/TKTInspectorAPI/EXTERNLIB index fd85421be9..0e517c2551 100644 --- a/tools/TKTInspectorAPI/EXTERNLIB +++ b/tools/TKTInspectorAPI/EXTERNLIB @@ -5,3 +5,4 @@ TKMath TKBRep TKTopAlgo TKPrim +TKV3d diff --git a/tools/TreeModel/TreeModel_ItemBase.cxx b/tools/TreeModel/TreeModel_ItemBase.cxx index 09c1735db0..012fe5bbae 100644 --- a/tools/TreeModel/TreeModel_ItemBase.cxx +++ b/tools/TreeModel/TreeModel_ItemBase.cxx @@ -14,6 +14,7 @@ // commercial license or contractual agreement. #include +#include #include #include @@ -47,6 +48,11 @@ void TreeModel_ItemBase::Reset() anItem->Reset(); } m_bInitialized = false; + if (!myProperties.IsNull()) + { + myProperties->Reset(); + myProperties = 0; + } myCachedValues.clear(); } @@ -131,6 +137,23 @@ void TreeModel_ItemBase::Init() Standard_Dump::SplitJson (Standard_Dump::Text (aStream), aValues); aHierarchicalValues = Standard_Dump::HierarchicalValueIndices (aValues); + if (!aValues.IsEmpty()) + { + if (!myProperties) + { + myProperties = new TreeModel_ItemProperties(); + myProperties->SetItem (currentItem()); + } + TCollection_AsciiString aKeyValue, aPropertiesValue; + aKeyValue = aValues.FindFromIndex (/*Row() +*/ 1); + if (!Standard_Dump::SplitJson (aKeyValue, aValues)) + aPropertiesValue = Standard_Dump::Text (aStream); + else + aPropertiesValue = aKeyValue; + + myProperties->Init (aPropertiesValue); + } + //if (aHierarchicalValues.Size() == 1) } m_iStreamChildren = aHierarchicalValues.Extent(); diff --git a/tools/TreeModel/TreeModel_ItemBase.hxx b/tools/TreeModel/TreeModel_ItemBase.hxx index a784548c88..fa05e205e8 100644 --- a/tools/TreeModel/TreeModel_ItemBase.hxx +++ b/tools/TreeModel/TreeModel_ItemBase.hxx @@ -36,6 +36,7 @@ #include class TreeModel_ItemBase; +class TreeModel_ItemProperties; typedef QExplicitlySharedDataPointer TreeModel_ItemBasePtr; @@ -145,6 +146,9 @@ public: //! Dumps the content of me into the stream virtual Standard_Boolean Dump (Standard_OStream& theOStream) const { (void)theOStream; return Standard_False; } + //! Returns the item properties + Handle(TreeModel_ItemProperties) Properties() const { return myProperties; } + protected: //! \param theParent the parent item @@ -179,6 +183,9 @@ protected: //! \return the value Standard_EXPORT virtual QVariant initValue (const int theItemRole) const; +protected: + Handle(TreeModel_ItemProperties) myProperties; //!< the properties + private: typedef QHash< QPair, TreeModel_ItemBasePtr > PositionToItemHash; diff --git a/tools/TreeModel/TreeModel_ItemProperties.cxx b/tools/TreeModel/TreeModel_ItemProperties.cxx index 8ccd2d6f11..40d7630896 100644 --- a/tools/TreeModel/TreeModel_ItemProperties.cxx +++ b/tools/TreeModel/TreeModel_ItemProperties.cxx @@ -14,6 +14,7 @@ // commercial license or contractual agreement. #include +#include #include #include @@ -88,6 +89,10 @@ void TreeModel_ItemProperties::GetPresentations (const int theRow, const int the if (theRow < 0) // full presentation { + Standard_SStream aStream; + Item()->GetStream (aStream); + + Convert_Tools::ConvertStreamToPresentations (aStream, 1, -1, thePresentations); return; } diff --git a/tools/TreeModel/TreeModel_ItemStream.cxx b/tools/TreeModel/TreeModel_ItemStream.cxx index 17cda16e60..a84dbde9d6 100644 --- a/tools/TreeModel/TreeModel_ItemStream.cxx +++ b/tools/TreeModel/TreeModel_ItemStream.cxx @@ -93,7 +93,6 @@ void TreeModel_ItemStream::Reset() myKey = ""; myStreamValue = ""; - myProperties->Reset(); myChildren.Clear(); TreeModel_ItemBase::Reset(); diff --git a/tools/TreeModel/TreeModel_ItemStream.hxx b/tools/TreeModel/TreeModel_ItemStream.hxx index 9581d4e747..14560f8fe7 100644 --- a/tools/TreeModel/TreeModel_ItemStream.hxx +++ b/tools/TreeModel/TreeModel_ItemStream.hxx @@ -73,9 +73,6 @@ public: const NCollection_IndexedDataMap& GetChildren() const { initItem(); return myChildren; } - //! Returns the item properties - Handle(TreeModel_ItemProperties) Properties() const { return myProperties; } - //! Returns stream value of the item to fulfill property panel. //! \return stream value or dummy virtual void GetStream (Standard_OStream& theOStream) const Standard_OVERRIDE; @@ -103,7 +100,6 @@ private: Standard_EXPORT TreeModel_ItemStream(TreeModel_ItemBasePtr theParent, const int theRow, const int theColumn); protected: - Handle(TreeModel_ItemProperties) myProperties; //!< the properties TCollection_AsciiString myKey; //!< the item key TCollection_AsciiString myStreamValue; //!< the stream value NCollection_IndexedDataMap myChildren; //!< the children diff --git a/tools/VInspector/VInspector_ItemGraphic3dCamera.cxx b/tools/VInspector/VInspector_ItemGraphic3dCamera.cxx index cd6bc3b392..fcf7dc382a 100644 --- a/tools/VInspector/VInspector_ItemGraphic3dCamera.cxx +++ b/tools/VInspector/VInspector_ItemGraphic3dCamera.cxx @@ -63,6 +63,19 @@ void VInspector_ItemGraphic3dCamera::Reset() myCamera = NULL; } +// ======================================================================= +// function : GetStream +// purpose : +// ======================================================================= +void VInspector_ItemGraphic3dCamera::GetStream (Standard_OStream& theOStream) const +{ + Handle(Graphic3d_Camera) aCamera = GetCamera(); + if (aCamera.IsNull()) + return; + + aCamera->DumpJson (theOStream); +} + // ======================================================================= // function : initItem // purpose : @@ -80,6 +93,8 @@ void VInspector_ItemGraphic3dCamera::initItem() const // ======================================================================= int VInspector_ItemGraphic3dCamera::initRowCount() const { + Handle(Graphic3d_Camera) aCamera = GetCamera(); // we need Init() call for having GetStream() filled + return 0; } diff --git a/tools/VInspector/VInspector_ItemGraphic3dCamera.hxx b/tools/VInspector/VInspector_ItemGraphic3dCamera.hxx index 5ca33c5dc0..e01b8d6af7 100644 --- a/tools/VInspector/VInspector_ItemGraphic3dCamera.hxx +++ b/tools/VInspector/VInspector_ItemGraphic3dCamera.hxx @@ -54,6 +54,10 @@ public: //! Resets cached values Standard_EXPORT virtual void Reset() Standard_OVERRIDE; + //! Returns stream value of the item to fulfill property panel. + //! \return stream value or dummy + Standard_EXPORT virtual void GetStream (Standard_OStream& theOStream) const Standard_OVERRIDE; + protected: //! Build presentation shape //! \return generated shape of the item parameters diff --git a/tools/VInspector/VInspector_ItemPrs3dDrawer.cxx b/tools/VInspector/VInspector_ItemPrs3dDrawer.cxx index f4dd35ec1a..cc049f1c13 100644 --- a/tools/VInspector/VInspector_ItemPrs3dDrawer.cxx +++ b/tools/VInspector/VInspector_ItemPrs3dDrawer.cxx @@ -157,6 +157,20 @@ void VInspector_ItemPrs3dDrawer::initItem() const const_cast(this)->Init(); } + +// ======================================================================= +// function : GetStream +// purpose : +// ======================================================================= +void VInspector_ItemPrs3dDrawer::GetStream (Standard_OStream& theOStream) const +{ + Handle(Prs3d_Drawer) aDrawer = GetDrawer(); + if (aDrawer.IsNull()) + return; + + aDrawer->DumpJson (theOStream); +} + // ======================================================================= // function : GetPrs3dAspect // purpose : diff --git a/tools/VInspector/VInspector_ItemPrs3dDrawer.hxx b/tools/VInspector/VInspector_ItemPrs3dDrawer.hxx index 943d06794c..0ffa87aee5 100644 --- a/tools/VInspector/VInspector_ItemPrs3dDrawer.hxx +++ b/tools/VInspector/VInspector_ItemPrs3dDrawer.hxx @@ -63,6 +63,10 @@ public: TCollection_AsciiString& theName, Standard_Boolean& theOwnAspect) const; + //! Returns stream value of the item to fulfill property panel. + //! \return stream value or dummy + Standard_EXPORT virtual void GetStream (Standard_OStream& theOStream) const Standard_OVERRIDE; + protected: //! Initialize the current item. It is empty because Reset() is also empty. diff --git a/tools/VInspector/VInspector_ItemV3dViewer.cxx b/tools/VInspector/VInspector_ItemV3dViewer.cxx index 005808bac8..aee1f4a86f 100644 --- a/tools/VInspector/VInspector_ItemV3dViewer.cxx +++ b/tools/VInspector/VInspector_ItemV3dViewer.cxx @@ -126,6 +126,19 @@ void VInspector_ItemV3dViewer::Reset() setViewer (NULL); } +// ======================================================================= +// function : GetStream +// purpose : +// ======================================================================= +void VInspector_ItemV3dViewer::GetStream (Standard_OStream& theOStream) const +{ + Handle(V3d_Viewer) aViewer = GetViewer(); + if (aViewer.IsNull()) + return; + + aViewer->DumpJson (theOStream); +} + // ======================================================================= // function : initItem // purpose : diff --git a/tools/VInspector/VInspector_ItemV3dViewer.hxx b/tools/VInspector/VInspector_ItemV3dViewer.hxx index 42e2f337e2..575a4f5470 100644 --- a/tools/VInspector/VInspector_ItemV3dViewer.hxx +++ b/tools/VInspector/VInspector_ItemV3dViewer.hxx @@ -59,6 +59,10 @@ public: Standard_EXPORT Handle(V3d_Viewer) GetViewer() const { return Handle(V3d_Viewer)::DownCast (GetObject()); } + //! Returns stream value of the item to fulfill property panel. + //! \return stream value or dummy + Standard_EXPORT virtual void GetStream (Standard_OStream& theOStream) const Standard_OVERRIDE; + protected: //! Initialize the current item. It is empty because Reset() is also empty. virtual void initItem() const Standard_OVERRIDE; diff --git a/tools/VInspector/VInspector_Window.cxx b/tools/VInspector/VInspector_Window.cxx index c2bd8ed934..3f2e9fd561 100644 --- a/tools/VInspector/VInspector_Window.cxx +++ b/tools/VInspector/VInspector_Window.cxx @@ -1237,7 +1237,8 @@ Handle(AIS_InteractiveContext) VInspector_Window::createView() Handle(AIS_InteractiveContext) aContext = View_Viewer::CreateStandardViewer(); Handle(AIS_Trihedron) aTrihedron = new AIS_Trihedron (new Geom_Axis2Placement (gp::XOY())); - aTrihedron->SetDatumDisplayMode (Prs3d_DM_Shaded); + aTrihedron->SetSize (0.5); + //aTrihedron->SetDatumDisplayMode (Prs3d_DM_Shaded); aContext->Display (aTrihedron, Standard_True); myViewWindow = new View_Window (0, aContext, false /*for opening several BREP files*/, true); diff --git a/tools/View/View_DisplayPreview.cxx b/tools/View/View_DisplayPreview.cxx index 7e4395a7ab..1426508137 100644 --- a/tools/View/View_DisplayPreview.cxx +++ b/tools/View/View_DisplayPreview.cxx @@ -32,8 +32,23 @@ #include #include +#include #include +void enableGlobalClipping (const Handle(AIS_InteractiveObject)& theObject, const bool theIsEnable) +{ + if (theIsEnable) + { + theObject->SetClipPlanes (Handle(Graphic3d_SequenceOfHClipPlane)()); + } + else + { + Handle(Graphic3d_SequenceOfHClipPlane) aPlanes = new Graphic3d_SequenceOfHClipPlane; + aPlanes->SetOverrideGlobal (Standard_True); + theObject->SetClipPlanes (aPlanes); + } +} + // ======================================================================= // function : Constructor // purpose : @@ -55,7 +70,8 @@ void View_DisplayPreview::SetContext (const Handle(AIS_InteractiveContext)& theC // remove all preview presentations from the previous context, display it in the new myContext = theContext; - myPreviewParameters->GetDrawer()->Link (theContext->DefaultDrawer()); + if (!theContext.IsNull()) + myPreviewParameters->GetDrawer()->Link (theContext->DefaultDrawer()); } // ======================================================================= @@ -68,38 +84,62 @@ void View_DisplayPreview::UpdatePreview (const View_DisplayActionType, if (myContext.IsNull()) return; + // clear previous previews + for (NCollection_List::Iterator anIterator (myPreviewReadyPresentations); anIterator.More(); anIterator.Next()) + { + if (!anIterator.Value()->GetContext().IsNull()) + anIterator.Value()->GetContext()->Remove (anIterator.Value(), Standard_True); + } + myPreviewReadyPresentations.Clear(); + if (thePresentations.IsEmpty()) { - myContext->Remove (myPreviewPresentation, Standard_True); + if (!myPreviewPresentation.IsNull() && !myPreviewPresentation->GetContext().IsNull()) + myPreviewPresentation->GetContext()->Remove (myPreviewPresentation, Standard_True); myPreviewPresentation = NULL; + return; } + // display parameter previews BRep_Builder aBuilder; TopoDS_Compound aCompound; aBuilder.MakeCompound (aCompound); for (NCollection_List::Iterator anIterator (thePresentations); anIterator.More(); anIterator.Next()) { Handle(Convert_TransientShape) aShapePtr = Handle(Convert_TransientShape)::DownCast (anIterator.Value()); - if (aShapePtr.IsNull()) - continue; - - aBuilder.Add (aCompound, aShapePtr->GetShape()); + if (!aShapePtr.IsNull()) + { + aBuilder.Add (aCompound, aShapePtr->GetShape()); + } + Handle(AIS_InteractiveObject) aPrs = Handle(AIS_InteractiveObject)::DownCast (anIterator.Value()); + if (!aPrs.IsNull() && aPrs->GetContext().IsNull()/*is not displayed in another context*/) + { + myContext->Display (aPrs, AIS_Shaded, -1/*do not participate in selection*/, Standard_True); + enableGlobalClipping(aPrs, false); + myPreviewReadyPresentations.Append (aPrs); + } } if (myPreviewPresentation.IsNull()) { myPreviewPresentation = new AIS_Shape (aCompound); + Quantity_Color aColor(Quantity_NOC_TOMATO); + myPreviewPresentation->Attributes()->SetPointAspect (new Prs3d_PointAspect (Aspect_TOM_O_PLUS, aColor, 3.0)); myPreviewPresentation->SetAttributes (myPreviewParameters->GetDrawer()); //myPreviewPresentation->SetTransformPersistence(thePersistent); myContext->Display (myPreviewPresentation, AIS_Shaded, -1/*do not participate in selection*/, Standard_True); + enableGlobalClipping(myPreviewPresentation, false); } else { Handle(AIS_Shape)::DownCast (myPreviewPresentation)->Set (aCompound); //myPreviewPresentation->SetTransformPersistence(thePersistent); - myContext->Redisplay (myPreviewPresentation, Standard_True); + if (!myPreviewPresentation.IsNull() && !myPreviewPresentation->GetContext().IsNull()) + { + myPreviewPresentation->GetContext()->Redisplay (myPreviewPresentation, Standard_True); + } } } diff --git a/tools/View/View_DisplayPreview.hxx b/tools/View/View_DisplayPreview.hxx index 2d2d6bbf49..2c6619d79c 100644 --- a/tools/View/View_DisplayPreview.hxx +++ b/tools/View/View_DisplayPreview.hxx @@ -80,6 +80,7 @@ private: View_PreviewParameters* myPreviewParameters; //!< drawer of preview presentation Handle(AIS_InteractiveObject) myPreviewPresentation; //!< presentation of preview for a selected object + NCollection_List myPreviewReadyPresentations; //!< presentation of preview for a selected object }; #endif diff --git a/tools/View/View_PreviewParameters.cxx b/tools/View/View_PreviewParameters.cxx index 30d0b4766a..49f1053ceb 100644 --- a/tools/View/View_PreviewParameters.cxx +++ b/tools/View/View_PreviewParameters.cxx @@ -43,9 +43,9 @@ View_PreviewParameters::View_PreviewParameters() myDrawer->ShadingAspect()->SetColor (aColor); myDrawer->ShadingAspect()->SetMaterial (aShadingMaterial); - myDrawer->ShadingAspect()->Aspect()->ChangeFrontMaterial().SetTransparency (aTransparency); - myDrawer->ShadingAspect()->Aspect()->ChangeBackMaterial() .SetTransparency (aTransparency); - myDrawer->SetTransparency (aTransparency); + //myDrawer->ShadingAspect()->Aspect()->ChangeFrontMaterial().SetTransparency (aTransparency); + //myDrawer->ShadingAspect()->Aspect()->ChangeBackMaterial() .SetTransparency (aTransparency); + //myDrawer->SetTransparency (aTransparency); // common parameters myDrawer->SetZLayer (Graphic3d_ZLayerId_Topmost); diff --git a/tools/View/View_ToolBar.cxx b/tools/View/View_ToolBar.cxx index 1ebff8d129..b9c09b767b 100644 --- a/tools/View/View_ToolBar.cxx +++ b/tools/View/View_ToolBar.cxx @@ -145,6 +145,16 @@ View_ContextType View_ToolBar::GetCurrentContextType() const return (View_ContextType)myViewSelector->currentIndex(); } +// ======================================================================= +// function : SetCurrentContext +// purpose : +// ======================================================================= +void View_ToolBar::SetCurrentContextType (View_ContextType theType) +{ + myViewSelector->setCurrentIndex ((int)theType); + emit contextChanged(); +} + // ======================================================================= // function : GetCurrentContext // purpose : diff --git a/tools/View/View_ToolBar.hxx b/tools/View/View_ToolBar.hxx index dca417ba05..a1dbf302ad 100644 --- a/tools/View/View_ToolBar.hxx +++ b/tools/View/View_ToolBar.hxx @@ -60,6 +60,10 @@ public: //! \returns type of active item of context selector Standard_EXPORT View_ContextType GetCurrentContextType() const; + //! Sets current context type + //! \param theType a context type + Standard_EXPORT void SetCurrentContextType (View_ContextType theType); + //! \returns an active context of context selector Standard_EXPORT Handle(AIS_InteractiveContext) GetCurrentContext() const; -- 2.39.5