From 021525334791fa582d2751d86ef63e901509383e Mon Sep 17 00:00:00 2001 From: nds Date: Sun, 8 Dec 2019 22:08:19 +0300 Subject: [PATCH] 0030268: Inspectors - improvements in VInspector plugin # Dump for OCCT objects --- src/AIS/AIS_InteractiveContext.hxx | 3 + src/AIS/AIS_InteractiveContext_3.cxx | 39 ++++ src/Bnd/Bnd_Box.cxx | 23 +- src/Bnd/Bnd_Box.hxx | 3 + src/Bnd/Bnd_OBB.cxx | 9 + src/Bnd/Bnd_OBB.hxx | 3 + src/Graphic3d/Graphic3d_AspectFillCapping.cxx | 24 +++ src/Graphic3d/Graphic3d_AspectFillCapping.hxx | 3 + src/Graphic3d/Graphic3d_Aspects.cxx | 27 +++ src/Graphic3d/Graphic3d_BSDF.cxx | 33 ++- src/Graphic3d/Graphic3d_BSDF.hxx | 6 + src/Graphic3d/Graphic3d_CStructure.cxx | 18 ++ src/Graphic3d/Graphic3d_Camera.cxx | 38 ++++ src/Graphic3d/Graphic3d_Camera.hxx | 3 + src/Graphic3d/Graphic3d_ClipPlane.cxx | 2 + src/Graphic3d/Graphic3d_HatchStyle.cxx | 12 ++ src/Graphic3d/Graphic3d_HatchStyle.hxx | 3 + src/Graphic3d/Graphic3d_Layer.cxx | 38 ++++ src/Graphic3d/Graphic3d_Layer.hxx | 3 + src/Graphic3d/Graphic3d_MaterialAspect.cxx | 25 +++ src/Graphic3d/Graphic3d_MaterialAspect.hxx | 3 + src/Graphic3d/Graphic3d_TransformPers.cxx | 2 + src/Graphic3d/Graphic3d_ZLayerSettings.hxx | 26 +++ src/Message/Message_AttributeStream.cxx | 2 + src/Message/Message_Report.cxx | 31 +++ src/Message/Message_Report.hxx | 6 + src/NCollection/NCollection_Buffer.hxx | 10 + src/NCollection/NCollection_Vec3.hxx | 8 + src/NCollection/NCollection_Vec4.hxx | 8 + src/OpenGl/OpenGl_CappingAlgo.cxx | 10 + src/Prs3d/Prs3d_Drawer.cxx | 105 ++++++++++ src/Quantity/Quantity_Color.cxx | 15 +- src/Quantity/Quantity_Color.hxx | 3 + src/Quantity/Quantity_ColorRGBA.cxx | 20 +- src/Quantity/Quantity_ColorRGBA.hxx | 3 + .../Select3D_InteriorSensitivePointSet.hxx | 2 +- src/Select3D/Select3D_SensitiveBox.cxx | 1 + src/Select3D/Select3D_SensitiveBox.hxx | 2 +- src/Select3D/Select3D_SensitiveFace.cxx | 1 + src/Select3D/Select3D_SensitiveFace.hxx | 2 +- src/Select3D/Select3D_SensitiveGroup.cxx | 1 - src/Select3D/Select3D_SensitiveGroup.hxx | 2 +- src/Select3D/Select3D_SensitivePoint.cxx | 1 + src/Select3D/Select3D_SensitivePoint.hxx | 2 +- src/Select3D/Select3D_SensitivePoly.cxx | 1 - src/Select3D/Select3D_SensitivePoly.hxx | 2 +- .../Select3D_SensitivePrimitiveArray.cxx | 1 - .../Select3D_SensitivePrimitiveArray.hxx | 2 +- src/Select3D/Select3D_SensitiveSegment.cxx | 1 + src/Select3D/Select3D_SensitiveSegment.hxx | 2 +- src/Select3D/Select3D_SensitiveSet.cxx | 3 +- src/Select3D/Select3D_SensitiveSet.hxx | 2 +- src/Select3D/Select3D_SensitiveTriangle.cxx | 1 + src/Select3D/Select3D_SensitiveTriangle.hxx | 2 +- .../Select3D_SensitiveTriangulation.cxx | 1 - .../Select3D_SensitiveTriangulation.hxx | 2 +- src/Select3D/Select3D_SensitiveWire.hxx | 2 +- .../SelectBasics_SelectingVolumeManager.hxx | 5 + src/SelectMgr/SelectMgr_EntityOwner.cxx | 2 + .../SelectMgr_SelectableObjectSet.cxx | 28 +++ .../SelectMgr_SelectableObjectSet.hxx | 3 + .../SelectMgr_SelectingVolumeManager.cxx | 22 ++ .../SelectMgr_SelectingVolumeManager.hxx | 3 + src/SelectMgr/SelectMgr_ViewClipRange.cxx | 2 +- src/SelectMgr/SelectMgr_ViewerSelector.cxx | 27 ++- src/Standard/Standard_Dump.cxx | 154 ++++++++++---- src/Standard/Standard_Dump.hxx | 91 ++++++-- src/StdSelect/StdSelect_Shape.cxx | 2 + src/StdSelect/StdSelect_ViewerSelector3d.cxx | 16 ++ src/StdSelect/StdSelect_ViewerSelector3d.hxx | 3 + src/TopoDS/TopoDS_TShape.cxx | 21 ++ src/V3d/V3d_Viewer.cxx | 11 + src/V3d/V3d_Viewer.hxx | 3 + src/gp/gp_Ax1.cxx | 20 +- src/gp/gp_Ax1.hxx | 2 + src/gp/gp_Ax2.cxx | 35 +++- src/gp/gp_Ax2.hxx | 2 + src/gp/gp_Ax3.cxx | 32 ++- src/gp/gp_Ax3.hxx | 2 + src/gp/gp_Dir.cxx | 12 +- src/gp/gp_Dir.hxx | 3 + src/gp/gp_Pnt.cxx | 12 +- src/gp/gp_Pnt.hxx | 2 + src/gp/gp_Trsf.cxx | 51 ++++- src/gp/gp_Trsf.hxx | 3 + src/gp/gp_XYZ.cxx | 26 +-- src/gp/gp_XYZ.hxx | 2 +- tools/Convert/Convert_Tools.cxx | 179 +++++++++++++++- tools/Convert/Convert_Tools.hxx | 37 +++- tools/MessageModel/MessageModel_Actions.cxx | 65 ++++++ tools/MessageModel/MessageModel_ItemAlert.cxx | 101 +++++---- tools/MessageModel/MessageModel_ItemAlert.hxx | 5 + .../MessageModel/MessageModel_ItemReport.cxx | 28 +++ .../MessageModel/MessageModel_ItemReport.hxx | 9 + .../MessageView_VisibilityState.cxx | 4 +- tools/MessageView/MessageView_Window.cxx | 175 +++++++--------- tools/MessageView/MessageView_Window.hxx | 13 +- tools/TInspectorEXE/TInspectorEXE.cxx | 8 +- tools/TKTInspectorAPI/EXTERNLIB | 1 + tools/TreeModel/TreeModel_ItemBase.cxx | 44 +++- tools/TreeModel/TreeModel_ItemBase.hxx | 16 +- tools/TreeModel/TreeModel_ItemProperties.cxx | 196 ++++++++++++++++-- tools/TreeModel/TreeModel_ItemProperties.hxx | 47 ++++- tools/TreeModel/TreeModel_ItemStream.cxx | 149 +++++++------ tools/TreeModel/TreeModel_ItemStream.hxx | 30 ++- tools/VInspector/VInspector_ItemBVHTree.cxx | 21 +- tools/VInspector/VInspector_ItemBVHTree.hxx | 5 +- tools/VInspector/VInspector_ItemContext.cxx | 58 +++++- tools/VInspector/VInspector_ItemContext.hxx | 12 +- .../VInspector_ItemGraphic3dCamera.cxx | 15 ++ .../VInspector_ItemGraphic3dCamera.hxx | 4 + .../VInspector_ItemGraphic3dGroup.cxx | 1 - .../VInspector_ItemPresentableObject.cxx | 14 +- .../VInspector/VInspector_ItemPrs3dDrawer.cxx | 14 ++ .../VInspector/VInspector_ItemPrs3dDrawer.hxx | 4 + .../VInspector_ItemPrs3dPresentation.cxx | 2 +- ...Inspector_ItemSelect3DSensitiveSetItem.cxx | 5 +- ...pector_ItemSelectBasicsSensitiveEntity.cxx | 15 +- .../VInspector_ItemSelectMgrBaseFrustum.cxx | 7 +- .../VInspector_ItemSelectMgrBaseFrustum.hxx | 5 +- ...ector_ItemSelectMgrSelectableObjectSet.cxx | 13 ++ ...ector_ItemSelectMgrSelectableObjectSet.hxx | 4 + ...or_ItemSelectMgrSelectingVolumeManager.cxx | 13 ++ ...or_ItemSelectMgrSelectingVolumeManager.hxx | 4 + .../VInspector_ItemSelectMgrSelection.cxx | 6 + ...Inspector_ItemSelectMgrSensitiveEntity.cxx | 42 ++-- ...Inspector_ItemSelectMgrSensitiveEntity.hxx | 4 + ...VInspector_ItemSelectMgrViewerSelector.cxx | 7 +- ...VInspector_ItemSelectMgrViewerSelector.hxx | 5 +- tools/VInspector/VInspector_ItemV3dViewer.cxx | 13 ++ tools/VInspector/VInspector_ItemV3dViewer.hxx | 4 + tools/VInspector/VInspector_Tools.cxx | 6 +- tools/VInspector/VInspector_Tools.hxx | 2 +- tools/VInspector/VInspector_Window.cxx | 110 ++++++---- tools/View/View_DisplayPreview.cxx | 67 +++++- tools/View/View_DisplayPreview.hxx | 1 + tools/View/View_PreviewParameters.cxx | 16 +- tools/View/View_PreviewParameters.hxx | 2 +- tools/View/View_ToolBar.cxx | 78 +++++++ tools/View/View_ToolBar.hxx | 23 ++ tools/View/View_Tools.cxx | 6 + tools/View/View_Viewer.cxx | 2 +- tools/View/View_Widget.cxx | 4 +- .../ViewControl/ViewControl_PropertyView.cxx | 120 ++++++----- .../ViewControl/ViewControl_PropertyView.hxx | 38 +++- tools/ViewControl/ViewControl_Table.cxx | 22 +- tools/ViewControl/ViewControl_Table.hxx | 3 + tools/ViewControl/ViewControl_TableModel.cxx | 6 +- .../ViewControl_TableModelValues.cxx | 12 +- 149 files changed, 2516 insertions(+), 606 deletions(-) diff --git a/src/AIS/AIS_InteractiveContext.hxx b/src/AIS/AIS_InteractiveContext.hxx index d45772c497..c58f2c94ab 100644 --- a/src/AIS/AIS_InteractiveContext.hxx +++ b/src/AIS/AIS_InteractiveContext.hxx @@ -1254,6 +1254,9 @@ public: //! @name sub-intensity management (deprecated) //! @param theSelection an instance of the selection void SetSelection (const Handle(AIS_Selection)& theSelection) { mySelection = theSelection; } + //! Dumps the content of me into the stream + Standard_EXPORT virtual void DumpJson (Standard_OStream& theOStream, const Standard_Integer theDepth = -1) const; + protected: //! @name internal methods Standard_EXPORT void GetDefModes (const Handle(AIS_InteractiveObject)& anIobj, Standard_Integer& Dmode, Standard_Integer& HiMod, Standard_Integer& SelMode) const; diff --git a/src/AIS/AIS_InteractiveContext_3.cxx b/src/AIS/AIS_InteractiveContext_3.cxx index 91357cdf28..cb48d3c3f4 100644 --- a/src/AIS/AIS_InteractiveContext_3.cxx +++ b/src/AIS/AIS_InteractiveContext_3.cxx @@ -86,3 +86,42 @@ void AIS_InteractiveContext::PolygonOffsets( anObj->PolygonOffsets( aMode, aFactor, aUnits ); } // OCC4895 SAN 22/03/04 High-level interface for controlling polygon offsets + +//======================================================================= +//function : DumpJson +//purpose : +//======================================================================= +void AIS_InteractiveContext::DumpJson (Standard_OStream& theOStream, const Standard_Integer) const +{ + OCCT_DUMP_CLASS_BEGIN (theOStream, AIS_InteractiveContext); + + OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, myObjects.Size()); + + OCCT_DUMP_FIELD_VALUE_POINTER (theOStream, mgrSelector.get()); + OCCT_DUMP_FIELD_VALUE_POINTER (theOStream, myMainPM.get()); + OCCT_DUMP_FIELD_VALUE_POINTER (theOStream, myMainVwr.get()); + OCCT_DUMP_FIELD_VALUE_POINTER (theOStream, myMainSel.get()); + OCCT_DUMP_FIELD_VALUE_POINTER (theOStream, myLastActiveView); + + OCCT_DUMP_FIELD_VALUE_POINTER (theOStream, myLastPicked.get()); + + OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, myToHilightSelected); + + OCCT_DUMP_FIELD_VALUE_POINTER (theOStream, mySelection.get()); + OCCT_DUMP_FIELD_VALUE_POINTER (theOStream, myFilters.get()); + OCCT_DUMP_FIELD_VALUE_POINTER (theOStream, myDefaultDrawer.get()); + + OCCT_DUMP_FIELD_VALUE_POINTER (theOStream, myStyles[Prs3d_TypeOfHighlight_Selected]); + OCCT_DUMP_FIELD_VALUE_POINTER (theOStream, myStyles[Prs3d_TypeOfHighlight_Dynamic]); + OCCT_DUMP_FIELD_VALUE_POINTER (theOStream, myStyles[Prs3d_TypeOfHighlight_LocalSelected]); + OCCT_DUMP_FIELD_VALUE_POINTER (theOStream, myStyles[Prs3d_TypeOfHighlight_LocalDynamic]); + OCCT_DUMP_FIELD_VALUE_POINTER (theOStream, myStyles[Prs3d_TypeOfHighlight_SubIntensity]); + + OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, myDetectedSeq.Size()); + + OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, myCurDetected); + OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, myCurHighlighted); + OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, myPickingStrategy); + OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, myAutoHilight); + OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, myIsAutoActivateSelMode); +} diff --git a/src/Bnd/Bnd_Box.cxx b/src/Bnd/Bnd_Box.cxx index 2942963a73..12f15e2e32 100644 --- a/src/Bnd/Bnd_Box.cxx +++ b/src/Bnd/Bnd_Box.cxx @@ -977,11 +977,30 @@ void Bnd_Box::Dump () const //======================================================================= void Bnd_Box::DumpJson (Standard_OStream& theOStream, const Standard_Integer) const { - OCCT_DUMP_CLASS_BEGIN (theOStream, Bnd_Box); - + //OCCT_DUMP_CLASS_BEGIN (theOStream, Bnd_Box); OCCT_DUMP_FIELD_VALUES_NUMERICAL (theOStream, "CornerMin", 3, Xmin, Ymin, Zmin) OCCT_DUMP_FIELD_VALUES_NUMERICAL (theOStream, "CornerMax", 3, Xmax, Ymax, Zmax) 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) +{ + Standard_Integer aPos = theStreamPos; + + OCCT_INIT_VECTOR_CLASS (theSStream, CornerMin, aPos, 3, &Xmin, &Ymin, &Zmin) + OCCT_INIT_VECTOR_CLASS (theSStream, CornerMax, aPos, 3, &Xmax, &Ymax, &Zmax) + + OCCT_INIT_FIELD_VALUE_NUMERICAL (theSStream, aPos, Gap); + Standard_Real myFlags; + OCCT_INIT_FIELD_VALUE_NUMERICAL (theSStream, aPos, myFlags); + Flags = (Standard_Integer)myFlags; + + theStreamPos = aPos; + return Standard_True; +} 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 4846ace783..d8b41888f2 100644 --- a/src/Bnd/Bnd_OBB.cxx +++ b/src/Bnd/Bnd_OBB.cxx @@ -1011,3 +1011,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_AspectFillCapping.cxx b/src/Graphic3d/Graphic3d_AspectFillCapping.cxx index 3f6bff8042..153f5e0552 100644 --- a/src/Graphic3d/Graphic3d_AspectFillCapping.cxx +++ b/src/Graphic3d/Graphic3d_AspectFillCapping.cxx @@ -108,3 +108,27 @@ void Graphic3d_AspectFillCapping::SetHatchRotationPeristent (const Standard_Bool setFlag (theToSet, Flags_HatchRotationPersistent); myHatchingState++; } + +//======================================================================= +//function : DumpJson +//purpose : +//======================================================================= +void Graphic3d_AspectFillCapping::DumpJson (Standard_OStream& theOStream, const Standard_Integer theDepth) const +{ + OCCT_DUMP_CLASS_BEGIN (theOStream, Graphic3d_AspectFillCapping); + + OCCT_DUMP_BASE_CLASS (theOStream, theDepth, Graphic3d_Aspects); + + OCCT_DUMP_FIELD_VALUES_DUMPED (theOStream, theDepth, &myMaterial); + OCCT_DUMP_FIELD_VALUES_DUMPED (theOStream, theDepth, &myMaterial); + + OCCT_DUMP_FIELD_VALUE_POINTER (theOStream, myTexture); + OCCT_DUMP_FIELD_VALUE_POINTER (theOStream, myShader); + OCCT_DUMP_FIELD_VALUE_POINTER (theOStream, myStippleHatch); + OCCT_DUMP_FIELD_VALUE_POINTER (theOStream, myTextureHatch); + + OCCT_DUMP_FIELD_VALUES_DUMPED (theOStream, theDepth, &myHatchMaterial); + + OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, myFlags); + OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, myHatchingState); +} diff --git a/src/Graphic3d/Graphic3d_AspectFillCapping.hxx b/src/Graphic3d/Graphic3d_AspectFillCapping.hxx index 7df72d60a6..d37088dfb1 100644 --- a/src/Graphic3d/Graphic3d_AspectFillCapping.hxx +++ b/src/Graphic3d/Graphic3d_AspectFillCapping.hxx @@ -121,6 +121,9 @@ public: //! Returns modification counter for hatching state. Standard_Size HatchingState() const { return myHatchingState; } + //! Dumps the content of me into the stream + Standard_EXPORT void DumpJson (Standard_OStream& theOStream, const Standard_Integer theDepth = -1) const; + private: enum Flags diff --git a/src/Graphic3d/Graphic3d_Aspects.cxx b/src/Graphic3d/Graphic3d_Aspects.cxx index 667b7732e0..00f86b95f6 100644 --- a/src/Graphic3d/Graphic3d_Aspects.cxx +++ b/src/Graphic3d/Graphic3d_Aspects.cxx @@ -70,6 +70,14 @@ void Graphic3d_Aspects::DumpJson (Standard_OStream& theOStream, const Standard_I { OCCT_DUMP_CLASS_BEGIN (theOStream, Graphic3d_Aspects); + /*Handle(Graphic3d_ShaderProgram) myProgram; + Handle(Graphic3d_TextureSet) myTextureSet; + Handle(Graphic3d_MarkerImage) myMarkerImage; + Handle(Graphic3d_HatchStyle) myHatchStyle; + Handle(TCollection_HAsciiString) myTextFont; + Graphic3d_MaterialAspect myFrontMaterial; + Graphic3d_MaterialAspect myBackMaterial;*/ + OCCT_DUMP_FIELD_VALUES_DUMPED (theOStream, theDepth, &myInteriorColor); OCCT_DUMP_FIELD_VALUES_DUMPED (theOStream, theDepth, &myBackInteriorColor); OCCT_DUMP_FIELD_VALUES_DUMPED (theOStream, theDepth, &myEdgeColor); @@ -82,4 +90,23 @@ void Graphic3d_Aspects::DumpJson (Standard_OStream& theOStream, const Standard_I OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, myToSuppressBackFaces); OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, myToMapTexture); OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, myIsTextZoomable); + + /*Aspect_InteriorStyle myInteriorStyle; + Graphic3d_TypeOfShadingModel myShadingModel; + Graphic3d_AlphaMode myAlphaMode; + Standard_ShortReal myAlphaCutoff; + + Aspect_TypeOfLine myLineType; + Standard_ShortReal myLineWidth; + + Aspect_TypeOfMarker myMarkerType; + Standard_ShortReal myMarkerScale;*/ + + if (!myTextFont.IsNull()) + OCCT_DUMP_FIELD_VALUE_STRING (theOStream, myTextFont->String()); + + OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, myTextStyle); + OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, myTextDisplayType); + OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, myTextFontAspect); + OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, myTextAngle); } diff --git a/src/Graphic3d/Graphic3d_BSDF.cxx b/src/Graphic3d/Graphic3d_BSDF.cxx index 4421e9c2d5..3958bec309 100644 --- a/src/Graphic3d/Graphic3d_BSDF.cxx +++ b/src/Graphic3d/Graphic3d_BSDF.cxx @@ -58,6 +58,18 @@ Graphic3d_Fresnel Graphic3d_Fresnel::CreateConductor (const Graphic3d_Vec3& theR return Graphic3d_Fresnel (Graphic3d_FM_SCHLICK, aFresnel); } +//======================================================================= +//function : DumpJson +//purpose : +//======================================================================= +void Graphic3d_Fresnel::DumpJson (Standard_OStream& theOStream, const Standard_Integer theDepth) const +{ + OCCT_DUMP_CLASS_BEGIN (theOStream, Graphic3d_Fresnel); + + OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, myFresnelType); + OCCT_DUMP_FIELD_VALUES_DUMPED (theOStream, theDepth, &myFresnelData); +} + // ======================================================================= // function : Graphic3d_BSDF // purpose : @@ -189,4 +201,23 @@ Graphic3d_BSDF Graphic3d_BSDF::CreateGlass (const Graphic3d_Vec3& theWeight, theAbsorptionCoeff); return aBSDF; -} \ No newline at end of file +} + +//======================================================================= +//function : DumpJson +//purpose : +//======================================================================= +void Graphic3d_BSDF::DumpJson (Standard_OStream& theOStream, const Standard_Integer theDepth) const +{ + OCCT_DUMP_CLASS_BEGIN (theOStream, Graphic3d_BSDF); + + OCCT_DUMP_FIELD_VALUES_DUMPED (theOStream, theDepth, &Kc); + OCCT_DUMP_FIELD_VALUES_DUMPED (theOStream, theDepth, &Kd); + OCCT_DUMP_FIELD_VALUES_DUMPED (theOStream, theDepth, &Ks); + OCCT_DUMP_FIELD_VALUES_DUMPED (theOStream, theDepth, &Kt); + OCCT_DUMP_FIELD_VALUES_DUMPED (theOStream, theDepth, &Le); + OCCT_DUMP_FIELD_VALUES_DUMPED (theOStream, theDepth, &Absorption); + + OCCT_DUMP_FIELD_VALUES_DUMPED (theOStream, theDepth, &FresnelCoat); + OCCT_DUMP_FIELD_VALUES_DUMPED (theOStream, theDepth, &FresnelBase); +} diff --git a/src/Graphic3d/Graphic3d_BSDF.hxx b/src/Graphic3d/Graphic3d_BSDF.hxx index 7919089dd9..6e750209ea 100644 --- a/src/Graphic3d/Graphic3d_BSDF.hxx +++ b/src/Graphic3d/Graphic3d_BSDF.hxx @@ -87,6 +87,9 @@ public: return myFresnelType; } + //! Dumps the content of me into the stream + Standard_EXPORT void DumpJson (Standard_OStream& theOStream, const Standard_Integer theDepth = -1) const; + protected: //! Creates new Fresnel reflectance factor. @@ -180,6 +183,9 @@ public: //! Performs comparison of two BSDFs. Standard_EXPORT bool operator== (const Graphic3d_BSDF& theOther) const; + //! Dumps the content of me into the stream + Standard_EXPORT void DumpJson (Standard_OStream& theOStream, const Standard_Integer theDepth = -1) const; + }; #endif // _Graphic3d_BSDF_HeaderFile 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_ClipPlane.cxx b/src/Graphic3d/Graphic3d_ClipPlane.cxx index 9edaf4d8de..117d537a79 100755 --- a/src/Graphic3d/Graphic3d_ClipPlane.cxx +++ b/src/Graphic3d/Graphic3d_ClipPlane.cxx @@ -268,6 +268,8 @@ void Graphic3d_ClipPlane::SetChainNextPlane (const Handle(Graphic3d_ClipPlane)& // ======================================================================= void Graphic3d_ClipPlane::DumpJson (Standard_OStream& theOStream, const Standard_Integer theDepth) const { + OCCT_DUMP_CLASS_BEGIN (theOStream, Graphic3d_ClipPlane); + OCCT_DUMP_FIELD_VALUES_DUMPED (theOStream, theDepth, mySectionStyle.get()); OCCT_DUMP_FIELD_VALUE_STRING (theOStream, myEntityUID); diff --git a/src/Graphic3d/Graphic3d_HatchStyle.cxx b/src/Graphic3d/Graphic3d_HatchStyle.cxx index ebf108cfe2..5990a189a1 100644 --- a/src/Graphic3d/Graphic3d_HatchStyle.cxx +++ b/src/Graphic3d/Graphic3d_HatchStyle.cxx @@ -516,3 +516,15 @@ const Standard_Byte* Graphic3d_HatchStyle::Pattern() const ? (const Standard_Byte*)myPredefinedPatterns[myHatchType] : NULL); } + +//======================================================================= +//function : DumpJson +//purpose : +//======================================================================= +void Graphic3d_HatchStyle::DumpJson (Standard_OStream& theOStream, const Standard_Integer theDepth) const +{ + OCCT_DUMP_CLASS_BEGIN (theOStream, Graphic3d_HatchStyle); + + OCCT_DUMP_FIELD_VALUES_DUMPED (theOStream, theDepth, myPattern.get()); + OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, myHatchType); +} diff --git a/src/Graphic3d/Graphic3d_HatchStyle.hxx b/src/Graphic3d/Graphic3d_HatchStyle.hxx index c29a3ab03d..b79b03e89e 100644 --- a/src/Graphic3d/Graphic3d_HatchStyle.hxx +++ b/src/Graphic3d/Graphic3d_HatchStyle.hxx @@ -49,6 +49,9 @@ public: return myHatchType; } + //! Dumps the content of me into the stream + Standard_EXPORT void DumpJson (Standard_OStream& theOStream, const Standard_Integer theDepth = -1) const; + private: Handle(NCollection_Buffer) myPattern; //!< Image bitmap with custom hatch pattern 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_MaterialAspect.cxx b/src/Graphic3d/Graphic3d_MaterialAspect.cxx index 8888c83a64..91c735dd54 100644 --- a/src/Graphic3d/Graphic3d_MaterialAspect.cxx +++ b/src/Graphic3d/Graphic3d_MaterialAspect.cxx @@ -840,3 +840,28 @@ Graphic3d_TypeOfMaterial Graphic3d_MaterialAspect::MaterialType (const Standard_ const RawMaterial& aMat = THE_MATERIALS[theRank - 1]; return aMat.MaterialType; } + +//======================================================================= +//function : DumpJson +//purpose : +//======================================================================= +void Graphic3d_MaterialAspect::DumpJson (Standard_OStream& theOStream, const Standard_Integer theDepth) const +{ + OCCT_DUMP_CLASS_BEGIN (theOStream, Graphic3d_MaterialAspect); + + OCCT_DUMP_FIELD_VALUES_DUMPED (theOStream, theDepth, &myBSDF); + OCCT_DUMP_FIELD_VALUE_STRING (theOStream, myStringName); + + OCCT_DUMP_FIELD_VALUES_DUMPED (theOStream, theDepth, &myColors[Graphic3d_TOR_AMBIENT]); + OCCT_DUMP_FIELD_VALUES_DUMPED (theOStream, theDepth, &myColors[Graphic3d_TOR_DIFFUSE]); + OCCT_DUMP_FIELD_VALUES_DUMPED (theOStream, theDepth, &myColors[Graphic3d_TOR_SPECULAR]); + OCCT_DUMP_FIELD_VALUES_DUMPED (theOStream, theDepth, &myColors[Graphic3d_TOR_EMISSION]); + + OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, myTransparencyCoef); + OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, myRefractionIndex); + OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, myShininess); + + OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, myMaterialType); + OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, myMaterialName); + OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, myRequestedMaterialName); +} diff --git a/src/Graphic3d/Graphic3d_MaterialAspect.hxx b/src/Graphic3d/Graphic3d_MaterialAspect.hxx index 9d4ee83e52..6274a371cd 100644 --- a/src/Graphic3d/Graphic3d_MaterialAspect.hxx +++ b/src/Graphic3d/Graphic3d_MaterialAspect.hxx @@ -244,6 +244,9 @@ public: //! Returns TRUE if this material is identical to specified one. Standard_Boolean operator== (const Graphic3d_MaterialAspect& theOther) const { return IsEqual (theOther); } + //! Dumps the content of me into the stream + Standard_EXPORT void DumpJson (Standard_OStream& theOStream, const Standard_Integer theDepth = -1) const; + private: //! Initialize the standard material. diff --git a/src/Graphic3d/Graphic3d_TransformPers.cxx b/src/Graphic3d/Graphic3d_TransformPers.cxx index 4fe9e7cac6..87e18d494d 100644 --- a/src/Graphic3d/Graphic3d_TransformPers.cxx +++ b/src/Graphic3d/Graphic3d_TransformPers.cxx @@ -58,6 +58,8 @@ Handle(Graphic3d_TransformPers) Graphic3d_TransformPers::FromDeprecatedParams (G // ======================================================================= void Graphic3d_TransformPers::DumpJson (Standard_OStream& theOStream, const Standard_Integer) const { + OCCT_DUMP_CLASS_BEGIN (theOStream, Graphic3d_TransformPers); + OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, myMode) OCCT_DUMP_FIELD_VALUES_NUMERICAL (theOStream, "Params3d", 3, myParams.Params3d.PntX, myParams.Params3d.PntY, myParams.Params3d.PntZ) 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/Message/Message_AttributeStream.cxx b/src/Message/Message_AttributeStream.cxx index 0e4ed5f0c0..20c38b79b1 100644 --- a/src/Message/Message_AttributeStream.cxx +++ b/src/Message/Message_AttributeStream.cxx @@ -41,6 +41,8 @@ Message_AttributeStream::Message_AttributeStream (const Standard_SStream& theStr void Message_AttributeStream::SetStream (const Standard_SStream& theStream) { + myStream.str (""); + TCollection_AsciiString aStreamStr (theStream.str().c_str()); myStream << aStreamStr; } diff --git a/src/Message/Message_Report.cxx b/src/Message/Message_Report.cxx index 344c7fbf04..b0bc794874 100644 --- a/src/Message/Message_Report.cxx +++ b/src/Message/Message_Report.cxx @@ -24,6 +24,7 @@ #include #include +#include IMPLEMENT_STANDARD_RTTIEXT(Message_Report,Standard_Transient) @@ -500,3 +501,33 @@ void Message_Report::SetActive (const Standard_Boolean theActive, const Standard "Set active report with gravity not in valid range", ); myIsActive[theGravity] = theActive; } + +//======================================================================= +//function : DumpJson +//purpose : +//======================================================================= +void Message_Report::DumpJson (Standard_OStream& theOStream, const Standard_Integer) const +{ + OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, myPerfMeterMode); + OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, myLimit); +} + +//======================================================================= +//function : InitJson +//purpose : +//======================================================================= +Standard_Boolean Message_Report::InitJson (const Standard_SStream& theSStream, Standard_Integer& theStreamPos) +{ + Standard_Integer aPos = theStreamPos; + + Standard_Real PerfMeterMode; + OCCT_INIT_FIELD_VALUE_NUMERICAL (theSStream, aPos, PerfMeterMode); + myPerfMeterMode = (Message_PerfMeterMode)((Standard_Integer)PerfMeterMode); + + Standard_Real Limit; + OCCT_INIT_FIELD_VALUE_NUMERICAL (theSStream, aPos, Limit); + myLimit = (Standard_Integer)Limit; + + theStreamPos = aPos; + return Standard_True; +} diff --git a/src/Message/Message_Report.hxx b/src/Message/Message_Report.hxx index b8c1df512b..9fc0708cf3 100644 --- a/src/Message/Message_Report.hxx +++ b/src/Message/Message_Report.hxx @@ -149,6 +149,12 @@ public: //! Returns listener of the reports events const Handle(Message_ReportCallBack)& GetCallBack() const { return myCallBack; } + //! 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); + // OCCT RTTI DEFINE_STANDARD_RTTIEXT(Message_Report,Standard_Transient) diff --git a/src/NCollection/NCollection_Buffer.hxx b/src/NCollection/NCollection_Buffer.hxx index b51e514a4e..aca2b7d1b0 100644 --- a/src/NCollection/NCollection_Buffer.hxx +++ b/src/NCollection/NCollection_Buffer.hxx @@ -17,6 +17,7 @@ #define _NCollection_Buffer_HeaderFile #include +#include #include //! Low-level buffer object. @@ -122,6 +123,15 @@ public: mySize = 0; } + //! Dumps the content of me into the stream + Standard_EXPORT void DumpJson (Standard_OStream& theOStream, const Standard_Integer theDepth = -1) const + { + (void)theDepth; + OCCT_DUMP_FIELD_VALUE_POINTER (theOStream, myData); + OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, mySize); + OCCT_DUMP_FIELD_VALUE_POINTER (theOStream, myAllocator.get()); + } + protected: Standard_Byte* myData; //!< data pointer diff --git a/src/NCollection/NCollection_Vec3.hxx b/src/NCollection/NCollection_Vec3.hxx index fc2b48155b..c9230c582e 100644 --- a/src/NCollection/NCollection_Vec3.hxx +++ b/src/NCollection/NCollection_Vec3.hxx @@ -18,6 +18,7 @@ #include #include #include +#include //! Auxiliary macros to define couple of similar access components as vector methods #define NCOLLECTION_VEC_COMPONENTS_3D(theX, theY, theZ) \ @@ -403,6 +404,13 @@ public: return NCollection_Vec3 (Element_t(0), Element_t(0), Element_t(1)); } + //! Dumps the content of me into the stream + Standard_EXPORT void DumpJson (Standard_OStream& theOStream, const Standard_Integer theDepth = -1) const + { + (void)theDepth; + OCCT_DUMP_FIELD_VALUES_NUMERICAL (theOStream, "Vec3", 3, v[0], v[1], v[2]); + } + private: Element_t v[3]; //!< define the vector as array to avoid structure alignment issues diff --git a/src/NCollection/NCollection_Vec4.hxx b/src/NCollection/NCollection_Vec4.hxx index b3c84aea9a..1be616fa31 100644 --- a/src/NCollection/NCollection_Vec4.hxx +++ b/src/NCollection/NCollection_Vec4.hxx @@ -16,6 +16,7 @@ #define _NCollection_Vec4_H__ #include +#include //! Generic 4-components vector. //! To be used as RGBA color vector or XYZW 3D-point with special W-component @@ -375,6 +376,13 @@ public: return aResult /= theRight; } + //! Dumps the content of me into the stream + Standard_EXPORT void DumpJson (Standard_OStream& theOStream, const Standard_Integer theDepth = -1) const + { + (void)theDepth; + OCCT_DUMP_FIELD_VALUES_NUMERICAL (theOStream, "Vec4", 4, v[0], v[1], v[2], v[3]); + } + private: Element_t v[4]; //!< define the vector as array to avoid structure alignment issues diff --git a/src/OpenGl/OpenGl_CappingAlgo.cxx b/src/OpenGl/OpenGl_CappingAlgo.cxx index 1d77c45ca5..377f870235 100755 --- a/src/OpenGl/OpenGl_CappingAlgo.cxx +++ b/src/OpenGl/OpenGl_CappingAlgo.cxx @@ -341,9 +341,14 @@ namespace // function : RenderCapping // purpose : // ======================================================================= +#include +#include void OpenGl_CappingAlgo::RenderCapping (const Handle(OpenGl_Workspace)& theWorkspace, const OpenGl_Structure& theStructure) { + Message_PerfMeter aPerfMeter; + MESSAGE_INFO ("RenderCapping", "", &aPerfMeter, NULL); + const Handle(OpenGl_Context)& aContext = theWorkspace->GetGlContext(); if (!aContext->Clipping().IsCappingOn()) { @@ -380,12 +385,17 @@ void OpenGl_CappingAlgo::RenderCapping (const Handle(OpenGl_Workspace)& theWorks { // get plane being rendered const Handle(Graphic3d_ClipPlane)& aClipChain = aCappingIt.Value(); + if (!aClipChain->IsCapping() || aCappingIt.IsDisabled()) { continue; } + Standard_SStream aStream; + aClipChain->DumpJson (aStream); + MESSAGE_INFO_STREAM(aStream, "ClipChain", "", &aPerfMeter, NULL); + Standard_Integer aSubPlaneIndex = 1; for (const Graphic3d_ClipPlane* aSubPlaneIter = aClipChain.get(); aSubPlaneIter != NULL; aSubPlaneIter = aSubPlaneIter->ChainNextPlane().get(), ++aSubPlaneIndex) { diff --git a/src/Prs3d/Prs3d_Drawer.cxx b/src/Prs3d/Prs3d_Drawer.cxx index a03fa3d36f..59da3959f1 100644 --- a/src/Prs3d/Prs3d_Drawer.cxx +++ b/src/Prs3d/Prs3d_Drawer.cxx @@ -1442,5 +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_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); + //OCCT_DUMP_FIELD_VALUES_DUMPED (theOStream, theDepth, myFillCappingAspect.get()); } diff --git a/src/Quantity/Quantity_Color.cxx b/src/Quantity/Quantity_Color.cxx index 69e94fdf28..1d81b262b1 100644 --- a/src/Quantity/Quantity_Color.cxx +++ b/src/Quantity/Quantity_Color.cxx @@ -3932,6 +3932,19 @@ void call_rgbhls (float r, float g, float b, float& h, float& l, float& s) //======================================================================= void Quantity_Color::DumpJson (Standard_OStream& theOStream, const Standard_Integer) const { - OCCT_DUMP_CLASS_BEGIN (theOStream, Quantity_Color); OCCT_DUMP_FIELD_VALUES_NUMERICAL (theOStream, "RGB", 3, MyRed, MyGreen, MyBlue) } + +//======================================================================= +//function : InitJson +//purpose : +//======================================================================= +Standard_Boolean Quantity_Color::InitJson (const Standard_SStream& theSStream, Standard_Integer& theStreamPos) +{ + Standard_Integer aPos = theStreamPos; + Standard_Real aRed, aGreen, aBlue; + OCCT_INIT_VECTOR_CLASS (theSStream, RGB, aPos, 3, &aRed, &aGreen, &aBlue) + + SetValues ((Standard_ShortReal)aRed, (Standard_ShortReal)aGreen, (Standard_ShortReal)aBlue, Quantity_TOC_RGB); + return Standard_True; +} diff --git a/src/Quantity/Quantity_Color.hxx b/src/Quantity/Quantity_Color.hxx index 914ef8b8e9..d6a33f157d 100644 --- a/src/Quantity/Quantity_Color.hxx +++ b/src/Quantity/Quantity_Color.hxx @@ -267,6 +267,9 @@ Standard_Boolean operator == (const Quantity_Color& Other) const //! 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); + private: //! Converts HLS components into RGB ones. diff --git a/src/Quantity/Quantity_ColorRGBA.cxx b/src/Quantity/Quantity_ColorRGBA.cxx index 3db480fa39..19beb28c7c 100644 --- a/src/Quantity/Quantity_ColorRGBA.cxx +++ b/src/Quantity/Quantity_ColorRGBA.cxx @@ -204,10 +204,22 @@ bool Quantity_ColorRGBA::ColorFromHex (const char* const theHexColorString, //function : DumpJson //purpose : //======================================================================= -void Quantity_ColorRGBA::DumpJson (Standard_OStream& theOStream, const Standard_Integer theDepth) const +void Quantity_ColorRGBA::DumpJson (Standard_OStream& theOStream, const Standard_Integer) const { - OCCT_DUMP_CLASS_BEGIN (theOStream, Quantity_ColorRGBA); + OCCT_DUMP_FIELD_VALUES_NUMERICAL (theOStream, "RGBA", 4, myRgb.Red(), myRgb.Green(), myRgb.Blue(), myAlpha) +} + +//======================================================================= +//function : InitJson +//purpose : +//======================================================================= +Standard_Boolean Quantity_ColorRGBA::InitJson (const Standard_SStream& theSStream, Standard_Integer& theStreamPos) +{ + Standard_Integer aPos = theStreamPos; + + Standard_Real aRed, aGreen, aBlue, anAlpha; + OCCT_INIT_VECTOR_CLASS (theSStream, RGBA, aPos, 4, &aRed, &aGreen, &aBlue, &anAlpha) - OCCT_DUMP_FIELD_VALUES_DUMPED (theOStream, theDepth, &myRgb); - OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, myAlpha); + SetValues ((Standard_ShortReal)aRed, (Standard_ShortReal)aGreen, (Standard_ShortReal)aBlue, (Standard_ShortReal)anAlpha); + return Standard_True; } diff --git a/src/Quantity/Quantity_ColorRGBA.hxx b/src/Quantity/Quantity_ColorRGBA.hxx index a1e0709626..a91a4b5296 100644 --- a/src/Quantity/Quantity_ColorRGBA.hxx +++ b/src/Quantity/Quantity_ColorRGBA.hxx @@ -124,6 +124,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); + private: static void myTestSize3() { Standard_STATIC_ASSERT (sizeof(float) * 3 == sizeof(Quantity_Color)); } diff --git a/src/Select3D/Select3D_InteriorSensitivePointSet.hxx b/src/Select3D/Select3D_InteriorSensitivePointSet.hxx index 0cb2fe615a..6f9d7ebd5b 100644 --- a/src/Select3D/Select3D_InteriorSensitivePointSet.hxx +++ b/src/Select3D/Select3D_InteriorSensitivePointSet.hxx @@ -71,7 +71,7 @@ public: Standard_EXPORT virtual Standard_Integer NbSubElements() Standard_OVERRIDE; //! Dumps the content of me into the stream - Standard_EXPORT virtual void DumpJson (Standard_OStream& theOStream, const Standard_Integer theDepth = -1) const; + Standard_EXPORT virtual void DumpJson (Standard_OStream& theOStream, const Standard_Integer theDepth = -1) const Standard_OVERRIDE; DEFINE_STANDARD_RTTIEXT(Select3D_InteriorSensitivePointSet,Select3D_SensitiveSet) diff --git a/src/Select3D/Select3D_SensitiveBox.cxx b/src/Select3D/Select3D_SensitiveBox.cxx index 81f0bdb085..bef2dd1b84 100644 --- a/src/Select3D/Select3D_SensitiveBox.cxx +++ b/src/Select3D/Select3D_SensitiveBox.cxx @@ -128,6 +128,7 @@ Select3D_BndBox3d Select3D_SensitiveBox::BoundingBox() void Select3D_SensitiveBox::DumpJson (Standard_OStream& theOStream, const Standard_Integer theDepth) const { OCCT_DUMP_CLASS_BEGIN (theOStream, Select3D_SensitiveBox); + OCCT_DUMP_BASE_CLASS (theOStream, theDepth, Select3D_SensitiveEntity); OCCT_DUMP_FIELD_VALUES_DUMPED (theOStream, theDepth, &myBox); OCCT_DUMP_FIELD_VALUES_DUMPED (theOStream, theDepth, &myCenter3d); diff --git a/src/Select3D/Select3D_SensitiveBox.hxx b/src/Select3D/Select3D_SensitiveBox.hxx index 36515f2b41..cb735264c2 100644 --- a/src/Select3D/Select3D_SensitiveBox.hxx +++ b/src/Select3D/Select3D_SensitiveBox.hxx @@ -71,7 +71,7 @@ public: Standard_EXPORT virtual Select3D_BndBox3d BoundingBox() Standard_OVERRIDE; //! Dumps the content of me into the stream - Standard_EXPORT virtual void DumpJson (Standard_OStream& theOStream, const Standard_Integer theDepth = -1) const; + Standard_EXPORT virtual void DumpJson (Standard_OStream& theOStream, const Standard_Integer theDepth = -1) const Standard_OVERRIDE; private: diff --git a/src/Select3D/Select3D_SensitiveFace.cxx b/src/Select3D/Select3D_SensitiveFace.cxx index 4ad62a1044..6feff18373 100644 --- a/src/Select3D/Select3D_SensitiveFace.cxx +++ b/src/Select3D/Select3D_SensitiveFace.cxx @@ -151,6 +151,7 @@ Standard_Integer Select3D_SensitiveFace::NbSubElements() void Select3D_SensitiveFace::DumpJson (Standard_OStream& theOStream, const Standard_Integer theDepth) const { OCCT_DUMP_CLASS_BEGIN (theOStream, Select3D_SensitiveFace); + OCCT_DUMP_BASE_CLASS (theOStream, theDepth, Select3D_SensitiveEntity); OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, mySensType); OCCT_DUMP_FIELD_VALUES_DUMPED (theOStream, theDepth, myFacePoints.get()); diff --git a/src/Select3D/Select3D_SensitiveFace.hxx b/src/Select3D/Select3D_SensitiveFace.hxx index 5fdf9f27b5..2a0af16113 100644 --- a/src/Select3D/Select3D_SensitiveFace.hxx +++ b/src/Select3D/Select3D_SensitiveFace.hxx @@ -74,7 +74,7 @@ public: Standard_EXPORT virtual Standard_Integer NbSubElements() Standard_OVERRIDE; //! Dumps the content of me into the stream - Standard_EXPORT virtual void DumpJson (Standard_OStream& theOStream, const Standard_Integer theDepth = -1) const; + Standard_EXPORT virtual void DumpJson (Standard_OStream& theOStream, const Standard_Integer theDepth = -1) const Standard_OVERRIDE; private: diff --git a/src/Select3D/Select3D_SensitiveGroup.cxx b/src/Select3D/Select3D_SensitiveGroup.cxx index b3571adcbf..89c5e12cbf 100644 --- a/src/Select3D/Select3D_SensitiveGroup.cxx +++ b/src/Select3D/Select3D_SensitiveGroup.cxx @@ -369,7 +369,6 @@ Standard_Real Select3D_SensitiveGroup::distanceToCOG (SelectBasics_SelectingVolu void Select3D_SensitiveGroup::DumpJson (Standard_OStream& theOStream, const Standard_Integer theDepth) const { OCCT_DUMP_CLASS_BEGIN (theOStream, Select3D_SensitiveGroup); - OCCT_DUMP_BASE_CLASS (theOStream, theDepth, Select3D_SensitiveSet); for (Select3D_IndexedMapOfEntity::Iterator anIterator (myEntities); anIterator.More(); anIterator.Next()) diff --git a/src/Select3D/Select3D_SensitiveGroup.hxx b/src/Select3D/Select3D_SensitiveGroup.hxx index 3b6f28a239..307d6a6c58 100644 --- a/src/Select3D/Select3D_SensitiveGroup.hxx +++ b/src/Select3D/Select3D_SensitiveGroup.hxx @@ -144,7 +144,7 @@ public: Standard_EXPORT virtual Standard_Integer Size() const Standard_OVERRIDE; //! Dumps the content of me into the stream - Standard_EXPORT virtual void DumpJson (Standard_OStream& theOStream, const Standard_Integer theDepth = -1) const; + Standard_EXPORT virtual void DumpJson (Standard_OStream& theOStream, const Standard_Integer theDepth = -1) const Standard_OVERRIDE; protected: diff --git a/src/Select3D/Select3D_SensitivePoint.cxx b/src/Select3D/Select3D_SensitivePoint.cxx index a995296a88..72facedce0 100644 --- a/src/Select3D/Select3D_SensitivePoint.cxx +++ b/src/Select3D/Select3D_SensitivePoint.cxx @@ -93,6 +93,7 @@ Standard_Integer Select3D_SensitivePoint::NbSubElements() void Select3D_SensitivePoint::DumpJson (Standard_OStream& theOStream, const Standard_Integer theDepth) const { OCCT_DUMP_CLASS_BEGIN (theOStream, Select3D_SensitivePoint); + OCCT_DUMP_BASE_CLASS (theOStream, theDepth, Select3D_SensitiveEntity); OCCT_DUMP_FIELD_VALUES_DUMPED (theOStream, theDepth, &myPoint); } diff --git a/src/Select3D/Select3D_SensitivePoint.hxx b/src/Select3D/Select3D_SensitivePoint.hxx index c45c129ddb..5906c5181d 100644 --- a/src/Select3D/Select3D_SensitivePoint.hxx +++ b/src/Select3D/Select3D_SensitivePoint.hxx @@ -51,7 +51,7 @@ public: Standard_EXPORT virtual Select3D_BndBox3d BoundingBox() Standard_OVERRIDE; //! Dumps the content of me into the stream - Standard_EXPORT virtual void DumpJson (Standard_OStream& theOStream, const Standard_Integer theDepth = -1) const; + Standard_EXPORT virtual void DumpJson (Standard_OStream& theOStream, const Standard_Integer theDepth = -1) const Standard_OVERRIDE; private: diff --git a/src/Select3D/Select3D_SensitivePoly.cxx b/src/Select3D/Select3D_SensitivePoly.cxx index 37c79bcde6..80d6ab4086 100644 --- a/src/Select3D/Select3D_SensitivePoly.cxx +++ b/src/Select3D/Select3D_SensitivePoly.cxx @@ -318,7 +318,6 @@ gp_Pnt Select3D_SensitivePoly::CenterOfGeometry() const void Select3D_SensitivePoly::DumpJson (Standard_OStream& theOStream, const Standard_Integer theDepth) const { OCCT_DUMP_CLASS_BEGIN (theOStream, Select3D_SensitivePoly); - OCCT_DUMP_BASE_CLASS (theOStream, theDepth, Select3D_SensitiveSet); //Select3D_PointData myPolyg; //!< Points of the poly diff --git a/src/Select3D/Select3D_SensitivePoly.hxx b/src/Select3D/Select3D_SensitivePoly.hxx index 120db6a2d2..7b71d10920 100644 --- a/src/Select3D/Select3D_SensitivePoly.hxx +++ b/src/Select3D/Select3D_SensitivePoly.hxx @@ -93,7 +93,7 @@ public: const Standard_Integer theIdx2) Standard_OVERRIDE; //! Dumps the content of me into the stream - Standard_EXPORT virtual void DumpJson (Standard_OStream& theOStream, const Standard_Integer theDepth = -1) const; + Standard_EXPORT virtual void DumpJson (Standard_OStream& theOStream, const Standard_Integer theDepth = -1) const Standard_OVERRIDE; protected: diff --git a/src/Select3D/Select3D_SensitivePrimitiveArray.cxx b/src/Select3D/Select3D_SensitivePrimitiveArray.cxx index 220c9a429f..897035ad2f 100644 --- a/src/Select3D/Select3D_SensitivePrimitiveArray.cxx +++ b/src/Select3D/Select3D_SensitivePrimitiveArray.cxx @@ -1226,7 +1226,6 @@ Standard_Boolean Select3D_SensitivePrimitiveArray::elementIsInside (SelectBasics void Select3D_SensitivePrimitiveArray::DumpJson (Standard_OStream& theOStream, const Standard_Integer theDepth) const { OCCT_DUMP_CLASS_BEGIN (theOStream, Select3D_SensitivePrimitiveArray); - OCCT_DUMP_BASE_CLASS (theOStream, theDepth, Select3D_SensitiveSet); //Handle(Select3D_PrimArraySubGroupArray) myGroups; //!< sub-groups of sensitive entities diff --git a/src/Select3D/Select3D_SensitivePrimitiveArray.hxx b/src/Select3D/Select3D_SensitivePrimitiveArray.hxx index a78ac80337..b06a1a269a 100644 --- a/src/Select3D/Select3D_SensitivePrimitiveArray.hxx +++ b/src/Select3D/Select3D_SensitivePrimitiveArray.hxx @@ -198,7 +198,7 @@ public: Standard_Integer LastDetectedEdgeNode2() const { return myDetectedEdgeNode2; } //! Dumps the content of me into the stream - Standard_EXPORT virtual void DumpJson (Standard_OStream& theOStream, const Standard_Integer theDepth = -1) const; + Standard_EXPORT virtual void DumpJson (Standard_OStream& theOStream, const Standard_Integer theDepth = -1) const Standard_OVERRIDE; public: diff --git a/src/Select3D/Select3D_SensitiveSegment.cxx b/src/Select3D/Select3D_SensitiveSegment.cxx index 24b19e4d0a..7d707139cc 100644 --- a/src/Select3D/Select3D_SensitiveSegment.cxx +++ b/src/Select3D/Select3D_SensitiveSegment.cxx @@ -110,6 +110,7 @@ Standard_Integer Select3D_SensitiveSegment::NbSubElements() void Select3D_SensitiveSegment::DumpJson (Standard_OStream& theOStream, const Standard_Integer theDepth) const { OCCT_DUMP_CLASS_BEGIN (theOStream, Select3D_SensitiveSegment); + OCCT_DUMP_BASE_CLASS (theOStream, theDepth, Select3D_SensitiveEntity); OCCT_DUMP_FIELD_VALUES_DUMPED (theOStream, theDepth, &myStart); OCCT_DUMP_FIELD_VALUES_DUMPED (theOStream, theDepth, &myEnd); diff --git a/src/Select3D/Select3D_SensitiveSegment.hxx b/src/Select3D/Select3D_SensitiveSegment.hxx index e4bf0a7990..17ff4c3b96 100644 --- a/src/Select3D/Select3D_SensitiveSegment.hxx +++ b/src/Select3D/Select3D_SensitiveSegment.hxx @@ -71,7 +71,7 @@ public: void EndPoint (const gp_Pnt& thePnt) { myEnd = thePnt; } //! Dumps the content of me into the stream - Standard_EXPORT virtual void DumpJson (Standard_OStream& theOStream, const Standard_Integer theDepth = -1) const; + Standard_EXPORT virtual void DumpJson (Standard_OStream& theOStream, const Standard_Integer theDepth = -1) const Standard_OVERRIDE; private: diff --git a/src/Select3D/Select3D_SensitiveSet.cxx b/src/Select3D/Select3D_SensitiveSet.cxx index f9ff7ff171..bb1f80ab2d 100644 --- a/src/Select3D/Select3D_SensitiveSet.cxx +++ b/src/Select3D/Select3D_SensitiveSet.cxx @@ -237,9 +237,10 @@ void Select3D_SensitiveSet::Clear() //function : DumpJson //purpose : //======================================================================= -void Select3D_SensitiveSet::DumpJson (Standard_OStream& theOStream, const Standard_Integer) const +void Select3D_SensitiveSet::DumpJson (Standard_OStream& theOStream, const Standard_Integer theDepth) const { OCCT_DUMP_CLASS_BEGIN (theOStream, Select3D_SensitiveSet); + OCCT_DUMP_BASE_CLASS (theOStream, theDepth, Select3D_SensitiveEntity); OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, myDetectedIdx); } diff --git a/src/Select3D/Select3D_SensitiveSet.hxx b/src/Select3D/Select3D_SensitiveSet.hxx index 6cf1b03ec1..261c4cb315 100644 --- a/src/Select3D/Select3D_SensitiveSet.hxx +++ b/src/Select3D/Select3D_SensitiveSet.hxx @@ -97,7 +97,7 @@ public: Standard_Integer GetLeafNodeSize() const { return myContent.Builder()->LeafNodeSize(); } //! Dumps the content of me into the stream - Standard_EXPORT virtual void DumpJson (Standard_OStream& theOStream, const Standard_Integer theDepth = -1) const; + Standard_EXPORT virtual void DumpJson (Standard_OStream& theOStream, const Standard_Integer theDepth = -1) const Standard_OVERRIDE; protected: diff --git a/src/Select3D/Select3D_SensitiveTriangle.cxx b/src/Select3D/Select3D_SensitiveTriangle.cxx index 6eaa8243b1..c3d0002e2d 100644 --- a/src/Select3D/Select3D_SensitiveTriangle.cxx +++ b/src/Select3D/Select3D_SensitiveTriangle.cxx @@ -101,6 +101,7 @@ Select3D_BndBox3d Select3D_SensitiveTriangle::BoundingBox() void Select3D_SensitiveTriangle::DumpJson (Standard_OStream& theOStream, const Standard_Integer theDepth) const { OCCT_DUMP_CLASS_BEGIN (theOStream, Select3D_SensitiveTriangle); + OCCT_DUMP_BASE_CLASS (theOStream, theDepth, Select3D_SensitiveEntity); OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, mySensType); diff --git a/src/Select3D/Select3D_SensitiveTriangle.hxx b/src/Select3D/Select3D_SensitiveTriangle.hxx index e6ad159dcf..6e0b789769 100644 --- a/src/Select3D/Select3D_SensitiveTriangle.hxx +++ b/src/Select3D/Select3D_SensitiveTriangle.hxx @@ -68,7 +68,7 @@ public: virtual gp_Pnt CenterOfGeometry() const Standard_OVERRIDE { return myCentroid; } //! Dumps the content of me into the stream - Standard_EXPORT virtual void DumpJson (Standard_OStream& theOStream, const Standard_Integer theDepth = -1) const; + Standard_EXPORT virtual void DumpJson (Standard_OStream& theOStream, const Standard_Integer theDepth = -1) const Standard_OVERRIDE; public: diff --git a/src/Select3D/Select3D_SensitiveTriangulation.cxx b/src/Select3D/Select3D_SensitiveTriangulation.cxx index 4f9ed23327..9bc774af08 100644 --- a/src/Select3D/Select3D_SensitiveTriangulation.cxx +++ b/src/Select3D/Select3D_SensitiveTriangulation.cxx @@ -451,7 +451,6 @@ gp_GTrsf Select3D_SensitiveTriangulation::InvInitLocation() const void Select3D_SensitiveTriangulation::DumpJson (Standard_OStream& theOStream, const Standard_Integer theDepth) const { OCCT_DUMP_CLASS_BEGIN (theOStream, Select3D_SensitiveTriangulation); - OCCT_DUMP_BASE_CLASS (theOStream, theDepth, Select3D_SensitiveSet); OCCT_DUMP_FIELD_VALUES_DUMPED (theOStream, theDepth, myTriangul.get()); diff --git a/src/Select3D/Select3D_SensitiveTriangulation.hxx b/src/Select3D/Select3D_SensitiveTriangulation.hxx index 752504a318..92ef699d55 100644 --- a/src/Select3D/Select3D_SensitiveTriangulation.hxx +++ b/src/Select3D/Select3D_SensitiveTriangulation.hxx @@ -94,7 +94,7 @@ public: const TopLoc_Location& GetInitLocation() const { return myInitLocation; } //! Dumps the content of me into the stream - Standard_EXPORT virtual void DumpJson (Standard_OStream& theOStream, const Standard_Integer theDepth = -1) const; + Standard_EXPORT virtual void DumpJson (Standard_OStream& theOStream, const Standard_Integer theDepth = -1) const Standard_OVERRIDE; protected: diff --git a/src/Select3D/Select3D_SensitiveWire.hxx b/src/Select3D/Select3D_SensitiveWire.hxx index 55463188ab..eca3ac58e7 100644 --- a/src/Select3D/Select3D_SensitiveWire.hxx +++ b/src/Select3D/Select3D_SensitiveWire.hxx @@ -69,7 +69,7 @@ public: const Standard_Integer theIdx2) Standard_OVERRIDE; //! Dumps the content of me into the stream - Standard_EXPORT virtual void DumpJson (Standard_OStream& theOStream, const Standard_Integer theDepth = -1) const; + Standard_EXPORT virtual void DumpJson (Standard_OStream& theOStream, const Standard_Integer theDepth = -1) const Standard_OVERRIDE; DEFINE_STANDARD_RTTIEXT(Select3D_SensitiveWire,Select3D_SensitiveSet) diff --git a/src/SelectBasics/SelectBasics_SelectingVolumeManager.hxx b/src/SelectBasics/SelectBasics_SelectingVolumeManager.hxx index eb93e1c899..043de02bb4 100644 --- a/src/SelectBasics/SelectBasics_SelectingVolumeManager.hxx +++ b/src/SelectBasics/SelectBasics_SelectingVolumeManager.hxx @@ -20,6 +20,7 @@ #include #include #include +#include class Bnd_Box; class gp_Pnt; @@ -116,6 +117,10 @@ public: //! Ax + By + Cz + D = 0) to the given vector virtual void GetPlanes (NCollection_Vector >& thePlaneEquations) const = 0; + //! Dumps the content of me into the stream + virtual void DumpJson (Standard_OStream& theOStream, const Standard_Integer theDepth = -1) const + { (void)theDepth; OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, myActiveSelectionType) } + protected: SelectionType myActiveSelectionType; //!< Active selection type: point, box or polyline }; diff --git a/src/SelectMgr/SelectMgr_EntityOwner.cxx b/src/SelectMgr/SelectMgr_EntityOwner.cxx index ed1cedb3c5..55c3b252b9 100644 --- a/src/SelectMgr/SelectMgr_EntityOwner.cxx +++ b/src/SelectMgr/SelectMgr_EntityOwner.cxx @@ -91,6 +91,8 @@ void SelectMgr_EntityOwner::DumpJson (Standard_OStream& theOStream, const Standa { OCCT_DUMP_CLASS_BEGIN (theOStream, SelectMgr_EntityOwner); + OCCT_DUMP_FIELD_VALUE_POINTER (theOStream, this); + OCCT_DUMP_FIELD_VALUE_POINTER (theOStream, mySelectable); OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, mypriority); OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, myIsSelected); diff --git a/src/SelectMgr/SelectMgr_SelectableObjectSet.cxx b/src/SelectMgr/SelectMgr_SelectableObjectSet.cxx index 68c8060da9..da1e6616ed 100644 --- a/src/SelectMgr/SelectMgr_SelectableObjectSet.cxx +++ b/src/SelectMgr/SelectMgr_SelectableObjectSet.cxx @@ -389,3 +389,31 @@ void SelectMgr_SelectableObjectSet::MarkDirty() myIsDirty[BVHSubset_3dPersistent] = Standard_True; myIsDirty[BVHSubset_2dPersistent] = Standard_True; } +//======================================================================= +//function : DumpJson +//purpose : +//======================================================================= +void SelectMgr_SelectableObjectSet::DumpJson (Standard_OStream& theOStream, const Standard_Integer) const +{ + for (Standard_Integer aSubsetIdx = 0; aSubsetIdx < BVHSubsetNb; ++aSubsetIdx) + { + OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, aSubsetIdx); + + Standard_Boolean IsDirty = myIsDirty[aSubsetIdx]; + OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, IsDirty); + + for (NCollection_IndexedMap::Iterator anObjectIt (myObjects[aSubsetIdx]); + anObjectIt.More(); anObjectIt.Next()) + { + Handle(SelectMgr_SelectableObject) SelectableObject = anObjectIt.Value(); + OCCT_DUMP_FIELD_VALUE_POINTER (theOStream, SelectableObject.get()); + } + + TCollection_AsciiString separator; + OCCT_DUMP_FIELD_VALUE_STRING (theOStream, separator); + + } + //Graphic3d_WorldViewProjState myLastViewState; //!< Last view-projection state used for construction of BVH + OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, myLastWidth); + OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, myLastHeight); +} diff --git a/src/SelectMgr/SelectMgr_SelectableObjectSet.hxx b/src/SelectMgr/SelectMgr_SelectableObjectSet.hxx index 242abdc7e3..9dc6fe569f 100644 --- a/src/SelectMgr/SelectMgr_SelectableObjectSet.hxx +++ b/src/SelectMgr/SelectMgr_SelectableObjectSet.hxx @@ -180,6 +180,9 @@ public: return myBVH[theSubset]; } + //! Dumps the content of me into the stream + Standard_EXPORT void DumpJson (Standard_OStream& theOStream, const Standard_Integer theDepth = -1) const; + private: //! Returns an appropriate subset of theObject given depending on its persistence type. diff --git a/src/SelectMgr/SelectMgr_SelectingVolumeManager.cxx b/src/SelectMgr/SelectMgr_SelectingVolumeManager.cxx index 2ef7b60606..0510b99170 100644 --- a/src/SelectMgr/SelectMgr_SelectingVolumeManager.cxx +++ b/src/SelectMgr/SelectMgr_SelectingVolumeManager.cxx @@ -14,6 +14,7 @@ // commercial license or contractual agreement. #include +#include //======================================================================= // function : SelectMgr_SelectingVolumeManager @@ -482,3 +483,24 @@ void SelectMgr_SelectingVolumeManager::SetViewClipping (const SelectMgr_Selectin myObjectClipPlanes = theOther.myObjectClipPlanes; myViewClipRange = theOther.myViewClipRange; } + +//======================================================================= +//function : DumpJson +//purpose : +//======================================================================= +void SelectMgr_SelectingVolumeManager::DumpJson (Standard_OStream& theOStream, const Standard_Integer theDepth) const +{ + OCCT_DUMP_CLASS_BEGIN (theOStream, SelectBasics_SelectingVolumeManager); + + for (Standard_Integer anIdx = 0; anIdx < VolumeTypesNb; ++anIdx) + { + const Handle(SelectMgr_BaseFrustum)& aSelectingVolume = mySelectingVolumes[anIdx]; + OCCT_DUMP_FIELD_VALUE_POINTER (theOStream, aSelectingVolume.get()); + } + + OCCT_DUMP_FIELD_VALUE_POINTER (theOStream, myViewClipPlanes.get()); + OCCT_DUMP_FIELD_VALUE_POINTER (theOStream, myObjectClipPlanes.get()); + + OCCT_DUMP_FIELD_VALUES_DUMPED (theOStream, theDepth, &myViewClipRange); + OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, myToAllowOverlap); +} diff --git a/src/SelectMgr/SelectMgr_SelectingVolumeManager.hxx b/src/SelectMgr/SelectMgr_SelectingVolumeManager.hxx index d0d0ddc673..dcdbe03ca5 100644 --- a/src/SelectMgr/SelectMgr_SelectingVolumeManager.hxx +++ b/src/SelectMgr/SelectMgr_SelectingVolumeManager.hxx @@ -236,6 +236,9 @@ public: return mySelectingVolumes[myActiveSelectionType / 2]->GetPlanes (thePlaneEquations); } + //! Dumps the content of me into the stream + Standard_EXPORT void DumpJson (Standard_OStream& theOStream, const Standard_Integer theDepth = -1) const Standard_OVERRIDE; + private: enum { Frustum, FrustumSet, VolumeTypesNb }; //!< Defines the amount of available selecting volumes diff --git a/src/SelectMgr/SelectMgr_ViewClipRange.cxx b/src/SelectMgr/SelectMgr_ViewClipRange.cxx index 57fd7680b9..bb67df0006 100644 --- a/src/SelectMgr/SelectMgr_ViewClipRange.cxx +++ b/src/SelectMgr/SelectMgr_ViewClipRange.cxx @@ -111,9 +111,9 @@ void SelectMgr_ViewClipRange::DumpJson (Standard_OStream& theOStream, const Stan { OCCT_DUMP_CLASS_BEGIN (theOStream, SelectMgr_ViewClipRange); - OCCT_DUMP_FIELD_VALUES_DUMPED (theOStream, theDepth, &myUnclipRange); for (size_t aRangeIter = 0; aRangeIter < myClipRanges.size(); ++aRangeIter) { OCCT_DUMP_FIELD_VALUES_DUMPED (theOStream, theDepth, &myClipRanges[aRangeIter]); } + OCCT_DUMP_FIELD_VALUES_DUMPED (theOStream, theDepth, &myUnclipRange); } diff --git a/src/SelectMgr/SelectMgr_ViewerSelector.cxx b/src/SelectMgr/SelectMgr_ViewerSelector.cxx index 97471d557e..6c73304dc9 100644 --- a/src/SelectMgr/SelectMgr_ViewerSelector.cxx +++ b/src/SelectMgr/SelectMgr_ViewerSelector.cxx @@ -1051,7 +1051,7 @@ void SelectMgr_ViewerSelector::AllowOverlapDetection (const Standard_Boolean the //function : DumpJson //purpose : //======================================================================= -void SelectMgr_ViewerSelector::DumpJson (Standard_OStream& theOStream, const Standard_Integer) const +void SelectMgr_ViewerSelector::DumpJson (Standard_OStream& theOStream, const Standard_Integer theDepth) const { OCCT_DUMP_CLASS_BEGIN (theOStream, SelectMgr_ViewerSelector); @@ -1059,13 +1059,30 @@ void SelectMgr_ViewerSelector::DumpJson (Standard_OStream& theOStream, const Sta OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, myToUpdateTolerance); OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, mystored.Extent()); - Standard_Integer aNbOfSelected = 0; + OCCT_DUMP_FIELD_VALUE_POINTER (theOStream, &mySelectingVolumeMgr); + OCCT_DUMP_FIELD_VALUE_POINTER (theOStream, &mySelectableObjects); + + Standard_Integer aNbOfSelectableObjects = 0; for (SelectMgr_SelectableObjectSet::Iterator aSelectableIt (mySelectableObjects); aSelectableIt.More(); aSelectableIt.Next()) { - aNbOfSelected++; + aNbOfSelectableObjects++; } - OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, aNbOfSelected); + OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, aNbOfSelectableObjects); + OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, myTolerances.Tolerance()); OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, myTolerances.CustomTolerance()); - OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, myZLayerOrderMap.Size()); + OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, myZLayerOrderMap.Extent()); + + OCCT_DUMP_FIELD_VALUE_POINTER (theOStream, myEntitySetBuilder.get()); + OCCT_DUMP_FIELD_VALUES_DUMPED (theOStream, theDepth, &myCameraEye); + OCCT_DUMP_FIELD_VALUES_DUMPED (theOStream, theDepth, &myCameraDir); + OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, myCameraScale); + + if (!myIndexes.IsNull()) + OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, myIndexes->Size()); + + OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, myCurRank); + OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, myIsLeftChildQueuedFirst); + OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, myEntityIdx); + OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, myMapOfObjectSensitives.Extent()); } diff --git a/src/Standard/Standard_Dump.cxx b/src/Standard/Standard_Dump.cxx index 4a36e19b8f..3157ba5581 100644 --- a/src/Standard/Standard_Dump.cxx +++ b/src/Standard/Standard_Dump.cxx @@ -19,10 +19,10 @@ // function : Constructor // purpose : // ======================================================================= -Standard_DumpSentry::Standard_DumpSentry (Standard_OStream& theOStream, const char* theClassName) +Standard_DumpSentry::Standard_DumpSentry (Standard_OStream& theOStream, const char*) : myOStream (&theOStream) { - (*myOStream) << "\"" << theClassName << "\": {"; + //(*myOStream) << "\"" << theClassName << "\": {"; } // ======================================================================= @@ -31,7 +31,7 @@ Standard_DumpSentry::Standard_DumpSentry (Standard_OStream& theOStream, const ch // ======================================================================= Standard_DumpSentry::~Standard_DumpSentry() { - (*myOStream) << "}"; + //(*myOStream) << "}"; } // ======================================================================= @@ -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 << ", "; } @@ -52,7 +52,7 @@ void Standard_Dump::AddValuesSeparator (Standard_OStream& theOStream) //purpose : //======================================================================= void Standard_Dump::DumpKeyToClass (Standard_OStream& theOStream, - const char* theKey, + const TCollection_AsciiString& theKey, const TCollection_AsciiString& theField) { AddValuesSeparator (theOStream); @@ -104,9 +104,52 @@ Standard_Boolean Standard_Dump::ProcessStreamName (const Standard_SStream& theSt TCollection_AsciiString aText = Text (theStream); if (aText.IsEmpty()) return Standard_False; + + if (aText.Length () < theStreamPos) + return Standard_False; + + 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(); + + return aResult; +} + +//======================================================================= +//function : ProcessFieldName +//purpose : +//======================================================================= +Standard_Boolean Standard_Dump::ProcessFieldName (const Standard_SStream& theStream, + const TCollection_AsciiString& theName, + Standard_Integer& theStreamPos) +{ + TCollection_AsciiString aText = Text (theStream); + if (aText.IsEmpty()) + return Standard_False; + 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 aName = Standard_Dump::DumpFieldToName (theName.ToCString()); + TCollection_AsciiString aKeyName = TCollection_AsciiString (JsonKeyToString (Standard_JsonKey_Quote)) + + aName + + TCollection_AsciiString (JsonKeyToString (Standard_JsonKey_Quote)) + + JsonKeyToString (Standard_JsonKey_SeparatorKeyToValue); - TCollection_AsciiString aKeyName = theName + JsonKeyToString (Standard_JsonKey_SeparatorKeyToValue); Standard_Boolean aResult = aSubText.StartsWith (aKeyName); if (aResult) theStreamPos += aKeyName.Length(); @@ -122,14 +165,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 +186,49 @@ Standard_Boolean Standard_Dump::InitRealValues (const Standard_SStream& theStrea if (!aValueText.IsRealValue()) return Standard_False; - va_arg(vl, Standard_Real) = 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; +} + +//======================================================================= +//function : InitRealValue +//purpose : +//======================================================================= +Standard_Boolean Standard_Dump::InitRealValue (const Standard_SStream& theStream, + Standard_Integer& theStreamPos, + Standard_Real& theValue) +{ + Standard_Integer aStreamPos = theStreamPos; + + TCollection_AsciiString aText = Text (theStream); + TCollection_AsciiString aSubText = aText.SubString (aStreamPos, aText.Length()); + + aStreamPos = 1; + Standard_Integer aNextPos = aSubText.Location (JsonKeyToString (Standard_JsonKey_SeparatorValueToValue), aStreamPos, aSubText.Length()); + Standard_JsonKey aNextKey = Standard_JsonKey_SeparatorValueToValue; + + Standard_Integer aCloseChildPos = aSubText.Location (JsonKeyToString (Standard_JsonKey_CloseChild), aStreamPos, aSubText.Length()); + Standard_Boolean isUseClosePos = (aNextPos > 0 && aCloseChildPos > 0 && aCloseChildPos < aNextPos) || !aNextPos; + if (isUseClosePos) + { + aNextPos = aCloseChildPos; + aNextKey = Standard_JsonKey_CloseChild; + } + + TCollection_AsciiString aValueText = aNextPos ? aSubText.SubString (aStreamPos, aNextPos - 1) : aSubText; + if (!aValueText.IsRealValue()) + return Standard_False; + theValue = aValueText.RealValue(); + theStreamPos = aNextPos ? (theStreamPos + (aNextPos - aStreamPos) + JsonKeyLength (aNextKey)) : aText.Length(); return Standard_True; } @@ -196,17 +276,26 @@ TCollection_AsciiString Standard_Dump::GetPointerInfo (const void* thePointer, c // ======================================================================= // DumpFieldToName // ======================================================================= -const char* Standard_Dump::DumpFieldToName (const char* theField) +TCollection_AsciiString Standard_Dump::DumpFieldToName (const TCollection_AsciiString theField) { - const char* aName = theField; + TCollection_AsciiString aName = theField; + if (theField.StartsWith ('&')) + { + aName.Remove (1, 1); + } - if (aName[0] == '&') + if (::LowerCase (aName.Value(1)) == 'm' && aName.Value (2) == 'y') { - aName = aName + 1; + aName.Remove (1, 2); } - if (::LowerCase (aName[0]) == 'm' && aName[1] == 'y') + + if (TCollection_AsciiString (aName).EndsWith (".get()")) { - aName = aName + 2; + aName = aName.SubString (1, aName.Length() - TCollection_AsciiString (".get()").Length()); + } + else if (TCollection_AsciiString (aName).EndsWith ("()")) + { + aName = aName.SubString (1, aName.Length() - TCollection_AsciiString ("()").Length()); } return aName; } @@ -290,7 +379,7 @@ TCollection_AsciiString Standard_Dump::FormatJson (const Standard_SStream& theSt // SplitJson // ---------------------------------------------------------------------------- Standard_Boolean Standard_Dump::SplitJson (const TCollection_AsciiString& theStreamStr, - NCollection_IndexedDataMap& theValues) + NCollection_IndexedDataMap& theKeyToValues) { Standard_Integer /*anIndex = 1, */aNextIndex = 1; while (aNextIndex < theStreamStr.Length()) @@ -305,7 +394,7 @@ Standard_Boolean Standard_Dump::SplitJson (const TCollection_AsciiString& theStr { case Standard_JsonKey_Quote: { - aProcessed = splitKeyToValue (theStreamStr, aNextIndex/*anIndex*/, aNextIndex, theValues); + aProcessed = splitKeyToValue (theStreamStr, aNextIndex/*anIndex*/, aNextIndex, theKeyToValues); //anIndex = aNextIndex; } break; @@ -319,7 +408,7 @@ Standard_Boolean Standard_Dump::SplitJson (const TCollection_AsciiString& theStr return Standard_False; TCollection_AsciiString aSubStreamStr = theStreamStr.SubString (aStartIndex + JsonKeyLength (aKey), aNextIndex - 2); - if (!SplitJson (aSubStreamStr, theValues)) + if (!SplitJson (aSubStreamStr, theKeyToValues)) return Standard_False; aNextIndex/*anIndex*/ = aClosePos + Standard_Integer (JsonKeyLength (Standard_JsonKey_CloseChild)); @@ -339,15 +428,6 @@ Standard_Boolean Standard_Dump::SplitJson (const TCollection_AsciiString& theStr return Standard_True; } -// ---------------------------------------------------------------------------- -// JoinJson -// ---------------------------------------------------------------------------- -void Standard_Dump::JoinJson (Standard_OStream& theOStream, - const NCollection_IndexedDataMap& theValues) -{ - -} - // ---------------------------------------------------------------------------- // HierarchicalValueIndices // ---------------------------------------------------------------------------- @@ -370,7 +450,7 @@ NCollection_List Standard_Dump::HierarchicalValueIndices ( Standard_Boolean Standard_Dump::splitKeyToValue (const TCollection_AsciiString& theStreamStr, Standard_Integer theStartIndex, Standard_Integer& theNextIndex, - NCollection_IndexedDataMap& theValues) + NCollection_IndexedDataMap& theValues) { // find key value: "key" Standard_Integer aStartIndex = theStartIndex; @@ -457,11 +537,13 @@ Standard_Boolean Standard_Dump::splitKeyToValue (const TCollection_AsciiString& break; case Standard_JsonKey_None: { - Standard_Integer aCloseIndex1 = nextClosePosition (theStreamStr, aStartIndex, Standard_JsonKey_None, Standard_JsonKey_CloseChild) - 1; - Standard_Integer aCloseIndex2 = nextClosePosition (theStreamStr, aStartIndex, Standard_JsonKey_None, Standard_JsonKey_SeparatorValueToValue) - 1; - aCloseIndex = aCloseIndex1 < aCloseIndex2 ? aCloseIndex1 : aCloseIndex2; - - aSplitValue = theStreamStr.SubString (aStartIndex, aCloseIndex); + //if (aCloseIndex != aStartIndex) // case if the value is numerical and need not be closed + { + Standard_Integer aCloseIndex1 = nextClosePosition (theStreamStr, aStartIndex, Standard_JsonKey_None, Standard_JsonKey_CloseChild) - 1; + Standard_Integer aCloseIndex2 = nextClosePosition (theStreamStr, aStartIndex, Standard_JsonKey_None, Standard_JsonKey_SeparatorValueToValue) - 1; + aCloseIndex = aCloseIndex1 < aCloseIndex2 ? aCloseIndex1 : aCloseIndex2; + } + aSplitValue = aStartIndex <= aCloseIndex ? theStreamStr.SubString (aStartIndex, aCloseIndex) : ""; theNextIndex = aCloseIndex + 1; } break; @@ -472,7 +554,7 @@ Standard_Boolean Standard_Dump::splitKeyToValue (const TCollection_AsciiString& //TCollection_AsciiString aSplitValue = theStreamStr.SubString (aStartIndex, aCloseIndex - 1); //theNextIndex = aCloseIndex + 1; - TCollection_AsciiString aValue; + Standard_DumpValue aValue; if (theValues.FindFromKey (aSplitKey, aValue)) { Standard_Integer anIndex = 1; @@ -486,7 +568,7 @@ Standard_Boolean Standard_Dump::splitKeyToValue (const TCollection_AsciiString& aSplitKey = aSplitKey + anIndexedSuffix; } - theValues.Add (aSplitKey, aSplitValue); + theValues.Add (aSplitKey, Standard_DumpValue (aSplitValue, aStartIndex)); return Standard_True; } diff --git a/src/Standard/Standard_Dump.hxx b/src/Standard/Standard_Dump.hxx index c4f46ef4f0..3fb31eabf3 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. @@ -59,16 +59,30 @@ class Standard_DumpSentry; //! Append into output value: "Name": Field #define OCCT_DUMP_FIELD_VALUE_NUMERICAL(theOStream, theField) \ { \ - const char* aName = Standard_Dump::DumpFieldToName (#theField); \ + TCollection_AsciiString aName = Standard_Dump::DumpFieldToName (#theField); \ Standard_Dump::AddValuesSeparator (theOStream); \ theOStream << "\"" << aName << "\": " << theField; \ } +//! @def OCCT_INIT_FIELD_VALUE_NUMERICAL +//! 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_FIELD_VALUE_NUMERICAL(theOStream, theStreamPos, theField) \ +{ \ + Standard_Integer aStreamPos = theStreamPos; \ + if (!Standard_Dump::ProcessFieldName (theOStream, #theField, aStreamPos)) \ + return Standard_False; \ + if (!Standard_Dump::InitRealValue (theOStream, aStreamPos, theField)) \ + return Standard_False; \ + theStreamPos = aStreamPos; \ +} + //! @def OCCT_DUMP_FIELD_VALUE_STRING //! Append into output value: "Name": "Field" #define OCCT_DUMP_FIELD_VALUE_STRING(theOStream, theField) \ { \ - const char* aName = Standard_Dump::DumpFieldToName (#theField); \ + TCollection_AsciiString aName = Standard_Dump::DumpFieldToName (#theField); \ Standard_Dump::AddValuesSeparator (theOStream); \ theOStream << "\"" << aName << "\": \"" << theField << "\""; \ } @@ -77,7 +91,7 @@ class Standard_DumpSentry; //! Append into output value: "Name": "address of the pointer" #define OCCT_DUMP_FIELD_VALUE_POINTER(theOStream, theField) \ { \ - const char* aName = Standard_Dump::DumpFieldToName (#theField); \ + TCollection_AsciiString aName = Standard_Dump::DumpFieldToName (#theField); \ Standard_Dump::AddValuesSeparator (theOStream); \ theOStream << "\"" << aName << "\": \"" << Standard_Dump::GetPointerInfo (theField) << "\""; \ } @@ -90,16 +104,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); \ - const char* aName = Standard_Dump::DumpFieldToName (#theField); \ + (theField)->DumpJson (aFieldStream, theDepth - 1); \ + TCollection_AsciiString 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 +168,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. @@ -190,6 +218,17 @@ enum Standard_JsonKey Standard_JsonKey_SeparatorValueToValue //!< ", " }; +//! Type for storing a dump value with the stream position +struct Standard_DumpValue +{ + Standard_DumpValue() {} + Standard_DumpValue (const TCollection_AsciiString& theValue, const Standard_Integer& theStartPos) + : myValue (theValue), myStartPosition (theStartPos) {} + + TCollection_AsciiString myValue; //!< current string value + Standard_Integer myStartPosition; //!< position of the value first char in the whole stream +}; + //! This interface has some tool methods for stream (in JSON format) processing. class Standard_Dump { @@ -219,13 +258,9 @@ public: //! The last value might be processed later using the same method. //! //! \param theStream stream value - //! \param theValues [out] container of split values + //! \param theKeyToValues [out] container of split values Standard_EXPORT static Standard_Boolean SplitJson (const TCollection_AsciiString& theStreamStr, - NCollection_IndexedDataMap& theValues); - - //! Unites container of values into Json output in form: key_1 : value_1, key_2: value_2, ... key_n: value_n - Standard_EXPORT static void JoinJson (Standard_OStream& theOStream, - const NCollection_IndexedDataMap& theValues); + NCollection_IndexedDataMap& theKeyToValues); //! Returns container of indices in values, that has hierarchical value Standard_EXPORT static NCollection_List HierarchicalValueIndices ( @@ -265,7 +300,7 @@ public: //! @param theKey a source value //! @param theField stream value Standard_EXPORT static void DumpKeyToClass (Standard_OStream& theOStream, - const char* theKey, + const TCollection_AsciiString& theKey, const TCollection_AsciiString& theField); //! Unite values in one value using template: "value_1", "value_2", ..., "value_n" @@ -286,6 +321,14 @@ public: const TCollection_AsciiString& theName, Standard_Integer& theStreamPos); + //! Check whether the field name is equal to the name in the stream at position + //! @param theSStream stream with values + //! @param theName stream key field value + //! @param theStreamPos current position in the stream + Standard_EXPORT static Standard_Boolean ProcessFieldName (const Standard_SStream& theStream, + const TCollection_AsciiString& theName, + Standard_Integer& theStreamPos); + //! Unite values in one value using template: value_1, value_2, ..., value_n //! @param theSStream stream with values //! @param theStreamPos current position in the stream @@ -294,11 +337,19 @@ public: Standard_Integer& theStreamPos, int theCount, ...); + //! Returns real value + //! @param theSStream stream with values + //! @param theStreamPos current position in the stream + //! @param theValue stream value + Standard_EXPORT static Standard_Boolean InitRealValue (const Standard_SStream& theStream, + Standard_Integer& theStreamPos, + Standard_Real& theValue); + //! Convert field name into dump text value, removes "&" and "my" prefixes //! An example, for field myValue, theName is Value, for &myCLass, the name is Class //! @param theField a source value //! @param theName [out] an updated name - Standard_EXPORT static const char* DumpFieldToName (const char* theField); + Standard_EXPORT static TCollection_AsciiString DumpFieldToName (const TCollection_AsciiString theField); private: //! Extracts from the string value a pair (key, value), add it into output container, update index value @@ -310,7 +361,7 @@ private: Standard_EXPORT static Standard_Boolean splitKeyToValue (const TCollection_AsciiString& theStreamStr, Standard_Integer theStartIndex, Standard_Integer& theNextIndex, - NCollection_IndexedDataMap& theValues); + NCollection_IndexedDataMap& theValues); //! Returns key of json in the index position. Incement the index position to the next symbol in the row 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/StdSelect/StdSelect_ViewerSelector3d.cxx b/src/StdSelect/StdSelect_ViewerSelector3d.cxx index 51a5286e32..caa75ae712 100644 --- a/src/StdSelect/StdSelect_ViewerSelector3d.cxx +++ b/src/StdSelect/StdSelect_ViewerSelector3d.cxx @@ -1086,3 +1086,19 @@ Standard_Boolean StdSelect_ViewerSelector3d::ToPixMap (Image_PixMap& aFiller->Flush(); return Standard_True; } + +//======================================================================= +//function : DumpJson +//purpose : +//======================================================================= +void StdSelect_ViewerSelector3d::DumpJson (Standard_OStream& theOStream, const Standard_Integer) const +{ + OCCT_DUMP_CLASS_BEGIN (theOStream, SelectMgr_ViewerSelector); + + OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, myStructs.Length()) + for (Graphic3d_SequenceOfStructure::Iterator aStructsIt (myStructs); aStructsIt.More(); aStructsIt.Next()) + { + const Handle(Graphic3d_Structure)& aStructure = aStructsIt.Value(); + OCCT_DUMP_FIELD_VALUE_POINTER (theOStream, aStructure) + } +} diff --git a/src/StdSelect/StdSelect_ViewerSelector3d.hxx b/src/StdSelect/StdSelect_ViewerSelector3d.hxx index 6004c9aa70..9715b8201f 100644 --- a/src/StdSelect/StdSelect_ViewerSelector3d.hxx +++ b/src/StdSelect/StdSelect_ViewerSelector3d.hxx @@ -93,6 +93,9 @@ public: const Handle(V3d_View)& theView, const Standard_Boolean theToClearOthers = Standard_True); + //! Dumps the content of me into the stream + Standard_EXPORT void DumpJson (Standard_OStream& theOStream, const Standard_Integer theDepth = -1) const; + DEFINE_STANDARD_RTTIEXT(StdSelect_ViewerSelector3d,SelectMgr_ViewerSelector) protected: diff --git a/src/TopoDS/TopoDS_TShape.cxx b/src/TopoDS/TopoDS_TShape.cxx index 3ae9e1f6b2..5451b96622 100644 --- a/src/TopoDS/TopoDS_TShape.cxx +++ b/src/TopoDS/TopoDS_TShape.cxx @@ -29,4 +29,25 @@ void TopoDS_TShape::DumpJson (Standard_OStream& theOStream, const Standard_Integ { OCCT_DUMP_CLASS_BEGIN (theOStream, TopoDS_TShape); OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, myFlags); + + OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, ShapeType()); + OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, NbChildren()); + + OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, Free()); + + OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, Free()); + OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, Locked()); + OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, Modified()); + OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, Checked()); + + OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, Orientable()); + OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, Closed()); + OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, Infinite()); + OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, Convex()); + + //for (TopoDS_ListIteratorOfListOfShape anIterator (myShapes); anIterator.More(); anIterator.Next()) + //{ + // const TopoDS_Shape& subShape = anIterator.Value(); + // OCCT_DUMP_FIELD_VALUES_DUMPED (theOStream, theDepth, &subShape); + //} } 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..3421373bef 100644 --- a/src/gp/gp_Ax1.cxx +++ b/src/gp/gp_Ax1.cxx @@ -86,8 +86,22 @@ 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) +{ + Standard_Integer aPos = theStreamPos; + + gp_XYZ& anXYZLoc = loc.ChangeCoord(); + OCCT_INIT_VECTOR_CLASS (theSStream, Location, aPos, 3, &anXYZLoc.ChangeCoord (1), &anXYZLoc.ChangeCoord (2), &anXYZLoc.ChangeCoord (3)) + gp_XYZ aDir; + OCCT_INIT_VECTOR_CLASS (theSStream, Direction, aPos, 3, &aDir.ChangeCoord (1), &aDir.ChangeCoord (2), &aDir.ChangeCoord (3)) + SetDirection (aDir); + + theStreamPos = aPos; + 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_Ax2.cxx b/src/gp/gp_Ax2.cxx index 4c1fc2a130..537c251b8a 100644 --- a/src/gp/gp_Ax2.cxx +++ b/src/gp/gp_Ax2.cxx @@ -114,11 +114,36 @@ gp_Ax2 gp_Ax2::Mirrored(const gp_Ax2& A2) const return Temp; } -void gp_Ax2::DumpJson (Standard_OStream& theOStream, const Standard_Integer theDepth) const +void gp_Ax2::DumpJson (Standard_OStream& theOStream, const Standard_Integer) const { - OCCT_DUMP_CLASS_BEGIN (theOStream, gp_Ax2); + OCCT_DUMP_VECTOR_CLASS (theOStream, Location, 3, axis.Location().X(), axis.Location().Y(), axis.Location().Z()) + OCCT_DUMP_VECTOR_CLASS (theOStream, Direction, 3, axis.Direction().X(), axis.Direction().Y(), axis.Direction().Z()) - 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, XDirection, 3, vxdir.X(), vxdir.Y(), vxdir.Z()) + OCCT_DUMP_VECTOR_CLASS (theOStream, YDirection, 3, vydir.X(), vydir.Y(), vydir.Z()) +} + +Standard_Boolean gp_Ax2::InitJson (const Standard_SStream& theSStream, Standard_Integer& theStreamPos) +{ + Standard_Integer aPos = theStreamPos; + + gp_XYZ anXYZLoc; + OCCT_INIT_VECTOR_CLASS (theSStream, Location, aPos, 3, &anXYZLoc.ChangeCoord (1), &anXYZLoc.ChangeCoord (2), &anXYZLoc.ChangeCoord (3)) + SetLocation (anXYZLoc); + + gp_XYZ aDir; + OCCT_INIT_VECTOR_CLASS (theSStream, Direction, aPos, 3, &aDir.ChangeCoord (1), &aDir.ChangeCoord (2), &aDir.ChangeCoord (3)) + gp_XYZ aXDir; + OCCT_INIT_VECTOR_CLASS (theSStream, XDirection, aPos, 3, &aXDir.ChangeCoord (1), &aXDir.ChangeCoord (2), &aXDir.ChangeCoord (3)) + gp_XYZ anYDir; + OCCT_INIT_VECTOR_CLASS (theSStream, YDirection, aPos, 3, &anYDir.ChangeCoord (1), &anYDir.ChangeCoord (2), &anYDir.ChangeCoord (3)) + + SetXDirection (aXDir); + SetYDirection (anYDir); + + if (!Direction().IsEqual (aDir, Precision::Confusion())) + return Standard_False; + + theStreamPos = aPos; + return Standard_True; } diff --git a/src/gp/gp_Ax2.hxx b/src/gp/gp_Ax2.hxx index 6984cd8252..1777bd2fd5 100644 --- a/src/gp/gp_Ax2.hxx +++ b/src/gp/gp_Ax2.hxx @@ -326,6 +326,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..e2ed05513b 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) +{ + Standard_Integer aPos = theStreamPos; + + gp_XYZ anXYZLoc; + OCCT_INIT_VECTOR_CLASS (theSStream, Location, aPos, 3, &anXYZLoc.ChangeCoord (1), &anXYZLoc.ChangeCoord (2), &anXYZLoc.ChangeCoord (3)) + SetLocation (anXYZLoc); + + gp_XYZ aDir; + OCCT_INIT_VECTOR_CLASS (theSStream, Direction, aPos, 3, &aDir.ChangeCoord (1), &aDir.ChangeCoord (2), &aDir.ChangeCoord (3)) + gp_XYZ aXDir; + OCCT_INIT_VECTOR_CLASS (theSStream, XDirection, aPos, 3, &aXDir.ChangeCoord (1), &aXDir.ChangeCoord (2), &aXDir.ChangeCoord (3)) + gp_XYZ anYDir; + OCCT_INIT_VECTOR_CLASS (theSStream, YDirection, aPos, 3, &anYDir.ChangeCoord (1), &anYDir.ChangeCoord (2), &anYDir.ChangeCoord (3)) + + SetXDirection (aXDir); + SetYDirection (anYDir); + + theStreamPos = aPos; + 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..f58d8cc5df 100644 --- a/src/gp/gp_Dir.cxx +++ b/src/gp/gp_Dir.cxx @@ -142,5 +142,15 @@ 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) +{ + Standard_Integer aPos = theStreamPos; + + OCCT_INIT_VECTOR_CLASS (theSStream, gp_Dir, aPos, 3, &coord.ChangeCoord (1), &coord.ChangeCoord (2), &coord.ChangeCoord (3)) + + theStreamPos = aPos; + 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..515267108d 100644 --- a/src/gp/gp_Pnt.cxx +++ b/src/gp/gp_Pnt.cxx @@ -88,5 +88,15 @@ 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) +{ + Standard_Integer aPos = theStreamPos; + + OCCT_INIT_VECTOR_CLASS (theSStream, gp_Pnt, aPos, 3, &coord.ChangeCoord (1), &coord.ChangeCoord (2), &coord.ChangeCoord (3)) + + theStreamPos = aPos; + return Standard_True; } 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_Trsf.cxx b/src/gp/gp_Trsf.cxx index 7c4a4c9cd9..9ad34a3a80 100644 --- a/src/gp/gp_Trsf.cxx +++ b/src/gp/gp_Trsf.cxx @@ -857,11 +857,54 @@ void gp_Trsf::Orthogonalize() //======================================================================= void gp_Trsf::DumpJson (Standard_OStream& theOStream, const Standard_Integer theDepth) const { - OCCT_DUMP_CLASS_BEGIN (theOStream, gp_Trsf); - - OCCT_DUMP_FIELD_VALUES_DUMPED (theOStream, theDepth, &loc); - OCCT_DUMP_FIELD_VALUES_DUMPED (theOStream, theDepth, &matrix); + OCCT_DUMP_VECTOR_CLASS (theOStream, Location, 3, loc.X(), loc.Y(), loc.Z()) + OCCT_DUMP_VECTOR_CLASS (theOStream, Matrix, 9, matrix.Value(1, 1), matrix.Value(1, 2), matrix.Value(1, 3), + matrix.Value(2, 1), matrix.Value(2, 2), matrix.Value(2, 3), + matrix.Value(3, 1), matrix.Value(3, 2), matrix.Value(3, 3)) OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, shape); OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, scale); } + +//======================================================================= +//function : InitJson +//purpose : +//======================================================================= +Standard_Boolean gp_Trsf::InitJson (const Standard_SStream& theSStream, Standard_Integer& theStreamPos) +{ + Standard_Integer aPos = theStreamPos; + + gp_XYZ anXYZLoc; + OCCT_INIT_VECTOR_CLASS (theSStream, Location, aPos, 3, &anXYZLoc.ChangeCoord (1), &anXYZLoc.ChangeCoord (2), &anXYZLoc.ChangeCoord (3)) + SetTranslation (anXYZLoc); + + //OCCT_INIT_VECTOR_CLASS (theSStream, Matrix, aPos, 9, matrix.ChangeValue (1, 1), matrix.ChangeValue (1, 2), matrix.ChangeValue (1, 3), + // matrix.ChangeValue (2, 1), matrix.ChangeValue (2, 2), matrix.ChangeValue (2, 3), + // matrix.ChangeValue (3, 1), matrix.ChangeValue (3, 2), matrix.ChangeValue (3, 3)) + + Standard_Real mymatrix[3][3]; + //Standard_Real M00, M01, M02, M10, M11, M12, M20, M21, M22; + //OCCT_INIT_VECTOR_CLASS (theSStream, Matrix, aPos, 9, &mymatrix[0][0], &mymatrix[0][1], &mymatrix[0][2], + // &mymatrix[1][0], &mymatrix[1][1], &mymatrix[1][2], + // &mymatrix[2][0], &mymatrix[2][1], &mymatrix[2][2]) + + OCCT_INIT_VECTOR_CLASS (theSStream, Matrix, aPos, 9, &mymatrix[0][0], &mymatrix[0][1], &mymatrix[0][2], + &mymatrix[1][0], &mymatrix[1][1], &mymatrix[1][2], + &mymatrix[2][0], &mymatrix[2][1], &mymatrix[2][2]) + for (int i = 0; i < 3; i++) + { + for (int j = 0; j < 3; j++) + { + matrix.SetValue (i + 1, j + 1, mymatrix[i][j]); + } + } + + Standard_Real myshape; + OCCT_INIT_FIELD_VALUE_NUMERICAL (theSStream, aPos, myshape); + shape = (gp_TrsfForm)((Standard_Integer)myshape); + + OCCT_INIT_FIELD_VALUE_NUMERICAL (theSStream, aPos, scale); + + theStreamPos = aPos; + return Standard_True; +} diff --git a/src/gp/gp_Trsf.hxx b/src/gp/gp_Trsf.hxx index 85e258c67f..2eb97d860e 100644 --- a/src/gp/gp_Trsf.hxx +++ b/src/gp/gp_Trsf.hxx @@ -353,6 +353,9 @@ void operator *= (const gp_Trsf& T) //! 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); + friend class gp_GTrsf; protected: diff --git a/src/gp/gp_XYZ.cxx b/src/gp/gp_XYZ.cxx index aaf9a3e536..72317f4fbe 100644 --- a/src/gp/gp_XYZ.cxx +++ b/src/gp/gp_XYZ.cxx @@ -47,30 +47,12 @@ 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(); + Standard_Integer aPos = theStreamPos; + OCCT_INIT_VECTOR_CLASS (theSStream, gp_XYZ, aPos, 3, &x, &y, &z) + theStreamPos = aPos; 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..2cf944f29e 100644 --- a/tools/Convert/Convert_Tools.cxx +++ b/tools/Convert/Convert_Tools.cxx @@ -14,7 +14,12 @@ // commercial license or contractual agreement. #include +#include +#include +#include +#include +#include #include #include #include @@ -27,10 +32,107 @@ //function : CreateShape //purpose : //======================================================================= -TopoDS_Shape Convert_Tools::CreateShape (const Bnd_Box& theBoundingBox) +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_Ax2 anAx2; + if (anAx2.InitJson (theSStream, aStartPos)) + { + Handle(Geom_Plane) aGeomPlane = new Geom_Plane (gp_Ax3 (anAx2)); + CreatePresentation (aGeomPlane, thePresentations); + return; + } + + gp_Ax3 anAx3; // should be after gp_Ax2 + if (anAx3.InitJson (theSStream, aStartPos)) + { + Handle(Geom_Plane) aGeomPlane = new Geom_Plane (anAx3); + CreatePresentation (aGeomPlane, thePresentations); + return; + } + + // should be after gp_Ax3 + gp_Ax1 anAxis; + if (anAxis.InitJson (theSStream, aStartPos)) + { + thePresentations.Append (new Convert_TransientShape (BRepBuilderAPI_MakeEdge (anAxis.Location(), anAxis.Location().Coord() + anAxis.Direction().XYZ()))); + return; + } + + gp_Trsf aTrsf; + if (aTrsf.InitJson (theSStream, aStartPos)) + { + CreatePresentation (aTrsf, thePresentations); + return; + } + + Bnd_Box aBox; + if (aBox.InitJson (theSStream, aStartPos)) + { + TopoDS_Shape aShape; + if (Convert_Tools::CreateShape (aBox, aShape)) + thePresentations.Append (new Convert_TransientShape (aShape)); + return; + } +} + +//======================================================================= +//function : ConvertStreamToColor +//purpose : +//======================================================================= +Standard_Boolean Convert_Tools::ConvertStreamToColor (const Standard_SStream& theSStream, + Quantity_Color& theColor) +{ + Standard_Integer aStartPos = 1; + Quantity_ColorRGBA aColorRGBA; + if (aColorRGBA.InitJson (theSStream, aStartPos)) + { + theColor = aColorRGBA.GetRGB(); + return Standard_True; + } + + Quantity_Color aColor; + if (aColor.InitJson (theSStream, aStartPos)) + { + theColor = aColor; + return Standard_True; + } + + return Standard_False; +} + +//======================================================================= +//function : CreateShape +//purpose : +//======================================================================= +Standard_Boolean Convert_Tools::CreateShape (const Bnd_Box& theBoundingBox, TopoDS_Shape& theShape) { if (theBoundingBox.IsVoid() || theBoundingBox.IsWhole()) - return TopoDS_Shape(); + return Standard_False; Standard_Real aXmin, anYmin, aZmin, aXmax, anYmax, aZmax; theBoundingBox.Get (aXmin, anYmin, aZmin, aXmax, anYmax, aZmax); @@ -38,17 +140,17 @@ TopoDS_Shape Convert_Tools::CreateShape (const Bnd_Box& theBoundingBox) gp_Pnt aPntMin = gp_Pnt (aXmin, anYmin, aZmin); gp_Pnt aPntMax = gp_Pnt (aXmax, anYmax, aZmax); - return CreateBoxShape (aPntMin, aPntMax); + return CreateBoxShape (aPntMin, aPntMax, theShape); } //======================================================================= //function : CreateShape //purpose : //======================================================================= -TopoDS_Shape Convert_Tools::CreateShape (const Bnd_OBB& theBoundingBox) +Standard_Boolean Convert_Tools::CreateShape (const Bnd_OBB& theBoundingBox, TopoDS_Shape& theShape) { if (theBoundingBox.IsVoid()) - return TopoDS_Shape(); + return Standard_False; TColgp_Array1OfPnt anArrPnts(0, 8); theBoundingBox.GetVertex(&anArrPnts(0)); @@ -62,14 +164,15 @@ TopoDS_Shape Convert_Tools::CreateShape (const Bnd_OBB& theBoundingBox) aBuilder.Add (aCompound, BRepBuilderAPI_MakeEdge (gp_Pnt (anArrPnts.Value(1)), gp_Pnt (anArrPnts.Value(3)))); aBuilder.Add (aCompound, BRepBuilderAPI_MakeEdge (gp_Pnt (anArrPnts.Value(2)), gp_Pnt (anArrPnts.Value(3)))); - return aCompound; + theShape = aCompound; + return Standard_True; } //======================================================================= //function : CreateBoxShape //purpose : //======================================================================= -TopoDS_Shape Convert_Tools::CreateBoxShape (const gp_Pnt& thePntMin, const gp_Pnt& thePntMax) +Standard_Boolean Convert_Tools::CreateBoxShape (const gp_Pnt& thePntMin, const gp_Pnt& thePntMax, TopoDS_Shape& theShape) { Standard_Boolean aThinOnX = fabs (thePntMin.X() - thePntMax.X()) < Precision::Confusion(); Standard_Boolean aThinOnY = fabs (thePntMin.Y() - thePntMax.Y()) < Precision::Confusion(); @@ -81,7 +184,8 @@ TopoDS_Shape Convert_Tools::CreateBoxShape (const gp_Pnt& thePntMin, const gp_Pn TopoDS_Compound aCompound; aBuilder.MakeCompound (aCompound); aBuilder.Add (aCompound, BRepBuilderAPI_MakeVertex (thePntMin)); - return aCompound; + theShape = aCompound; + return Standard_True; } if (aThinOnX || aThinOnY || aThinOnZ) @@ -116,11 +220,66 @@ TopoDS_Shape Convert_Tools::CreateBoxShape (const gp_Pnt& thePntMin, const gp_Pn aBuilder.Add (aCompound, BRepBuilderAPI_MakeEdge (aPnt3, aPnt4)); aBuilder.Add (aCompound, BRepBuilderAPI_MakeEdge (aPnt4, aPnt1)); - return aCompound; + theShape = aCompound; + return Standard_True; } else { BRepPrimAPI_MakeBox aBoxBuilder (thePntMin, thePntMax); - return aBoxBuilder.Shape(); + theShape = aBoxBuilder.Shape(); + return Standard_True; } } + +//======================================================================= +//function : CreatePresentation +//purpose : +//======================================================================= +void Convert_Tools::CreatePresentation (const Handle(Geom_Plane)& thePlane, + NCollection_List& thePresentations) +{ + Handle(AIS_Plane) aPlanePrs = new AIS_Plane (thePlane); + + // 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); +} + +//======================================================================= +//function : CreatePresentation +//purpose : +//======================================================================= +void Convert_Tools::CreatePresentation (const gp_Trsf& theTrsf, + NCollection_List& thePresentations) +{ + Bnd_Box aBox (gp_Pnt(), gp_Pnt(10., 10., 10)); + + TopoDS_Shape aBoxShape; + if (!Convert_Tools::CreateShape (aBox, aBoxShape)) + return; + + Handle(AIS_Shape) aSourcePrs = new AIS_Shape (aBoxShape); + // TODO - default fields to be defined in another place + aSourcePrs->SetColor (Quantity_NOC_WHITE); + aSourcePrs->SetTransparency (0.5); + thePresentations.Append (aSourcePrs); + + Handle(AIS_Shape) aTransformedPrs = new AIS_Shape (aBoxShape); + // TODO - default fields to be defined in another place + aTransformedPrs->SetColor (Quantity_NOC_TOMATO); + aTransformedPrs->SetTransparency (0.5); + aTransformedPrs->SetLocalTransformation (theTrsf); + thePresentations.Append (aTransformedPrs); +} diff --git a/tools/Convert/Convert_Tools.hxx b/tools/Convert/Convert_Tools.hxx index ecce1fdc5f..2d4a08a08b 100644 --- a/tools/Convert/Convert_Tools.hxx +++ b/tools/Convert/Convert_Tools.hxx @@ -22,6 +22,8 @@ #include #include #include +#include +#include #include #include #include @@ -29,12 +31,14 @@ #include #include #include +#include #include #include #include #include +class Geom_Plane; class Geom_Transformation; //! \class Convert_Tools @@ -42,21 +46,48 @@ 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 collect new presentation/s + Standard_EXPORT static void ConvertStreamToPresentations (const Standard_SStream& theSStream, + const Standard_Integer theStartPos, + const Standard_Integer theLastPos, + NCollection_List& thePresentations); + + //! Converts stream to color if possible. It processes Quantity_Color, Quantity_ColorRGBA + //! \param theStream source of presentation + //! \param theColor [out] converted color + //! \returns true if done + Standard_EXPORT static Standard_Boolean ConvertStreamToColor (const Standard_SStream& theSStream, + Quantity_Color& theColor); + //! Creates box shape //! \param theBoundingBox box shape parameters //! \return created shape - Standard_EXPORT static TopoDS_Shape CreateShape (const Bnd_Box& theBoundingBox); + Standard_EXPORT static Standard_Boolean CreateShape (const Bnd_Box& theBoundingBox, TopoDS_Shape& theShape); //! Creates box shape //! \param theBoundingBox box shape parameters //! \return created shape - Standard_EXPORT static TopoDS_Shape CreateShape (const Bnd_OBB& theBoundingBox); + Standard_EXPORT static Standard_Boolean CreateShape (const Bnd_OBB& theBoundingBox, TopoDS_Shape& theShape); //! Creates box shape //! \param thePntMin minimum point on the bounding box //! \param thePntMax maximum point on the bounding box //! \return created shape - Standard_EXPORT static TopoDS_Shape CreateBoxShape (const gp_Pnt& thePntMin, const gp_Pnt& thePntMax); + Standard_EXPORT static Standard_Boolean CreateBoxShape (const gp_Pnt& thePntMin, const gp_Pnt& thePntMax, TopoDS_Shape& theShape); + + //! Creates presentation AIS_Plane + //! \param thePlane source plane + //! \param thePresentations container to collect new presentation/s + Standard_EXPORT static void CreatePresentation (const Handle(Geom_Plane)& thePlane, + NCollection_List& thePresentations); + + //! Creates two presentations base on gp_Trsf: box in initial place and transformed box + //! \param thePlane source plane + //! \param thePresentations container to collect new presentation/s + Standard_EXPORT static void CreatePresentation (const gp_Trsf& theTrsf, + NCollection_List& thePresentations); }; diff --git a/tools/MessageModel/MessageModel_Actions.cxx b/tools/MessageModel/MessageModel_Actions.cxx index 03115c1a2f..0b56179b08 100644 --- a/tools/MessageModel/MessageModel_Actions.cxx +++ b/tools/MessageModel/MessageModel_Actions.cxx @@ -26,6 +26,9 @@ #include +#include +#include +#include #include #include @@ -347,6 +350,45 @@ 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_Ax1 + { + gp_Ax1 aCoords (gp_Pnt (1.3, 2.3, 3.4), gp_Dir (0.3, 0.3, 0.4)); + Standard_SStream aStream; + aCoords.DumpJson (aStream); + MESSAGE_INFO_STREAM(aStream, "gp_Ax1", "", &aPerfMeter, NULL); + } + // gp_Ax2 + { + gp_Ax2 aCoords (gp_Pnt (10.3, 20.3, 30.4), gp_Dir (0.3, 0.3, 0.4)); + Standard_SStream aStream; + aCoords.DumpJson (aStream); + MESSAGE_INFO_STREAM(aStream, "gp_Ax2", "", &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); + } + // gp_Trsf + { + gp_Trsf aTrsf; + aTrsf.SetRotation (gp::OZ(), 0.3); + aTrsf.SetTranslationPart (gp_Vec (15., 15., 15.)); + aTrsf.SetScaleFactor (3.); + + Standard_SStream aStream; + aTrsf.DumpJson (aStream); + MESSAGE_INFO_STREAM(aStream, "gp_Trsf", "", &aPerfMeter, NULL); + } // Bnd_Box { Bnd_Box aBox (gp_Pnt (20., 15., 10.), gp_Pnt (25., 20., 15.)); @@ -362,6 +404,29 @@ void MessageModel_Actions::OnTestPropertyPanel() anOBB.DumpJson (aStream); MESSAGE_INFO_STREAM(aStream, "Bnd_OBB", "", &aPerfMeter, NULL); } + // Quantity_ColorRGBA + { + Quantity_ColorRGBA aColor (0.2f, 0.8f, 0.8f, 0.2f); + Standard_SStream aStream; + aColor.DumpJson (aStream); + MESSAGE_INFO_STREAM(aStream, "Quantity_ColorRGBA", "", &aPerfMeter, NULL); + } + // Quantity_Color + { + Quantity_Color aColor (0.8, 0.8, 0.8, Quantity_TOC_RGB); + Standard_SStream aStream; + aColor.DumpJson (aStream); + MESSAGE_INFO_STREAM(aStream, "Quantity_Color", "", &aPerfMeter, NULL); + } + + // SHAPE messages + { + BRepBuilderAPI_MakeEdge aBuilder (gp_Pnt (0., 0., 0.), gp_Pnt (20., 10., 20.)); + TopoDS_Shape aShape = aBuilder.Shape(); + + MESSAGE_INFO_SHAPE (aShape, "Shape message edge", "", &aPerfMeter, NULL); + } + myTreeModel->UpdateTreeModel(); #endif } diff --git a/tools/MessageModel/MessageModel_ItemAlert.cxx b/tools/MessageModel/MessageModel_ItemAlert.cxx index c4882a928b..f5b2219541 100644 --- a/tools/MessageModel/MessageModel_ItemAlert.cxx +++ b/tools/MessageModel/MessageModel_ItemAlert.cxx @@ -207,26 +207,55 @@ int MessageModel_ItemAlert::initRowCount() const // ======================================================================= void MessageModel_ItemAlert::GetStream (Standard_OStream& OS) const { - //return; Handle(Message_AlertExtended) anExtendedAlert = Handle(Message_AlertExtended)::DownCast (getAlert()); - if (!anExtendedAlert.IsNull() && !anExtendedAlert->Attribute().IsNull()) - { - Handle(Message_Attribute) anAttribute = anExtendedAlert->Attribute(); - if (!anAttribute.IsNull()) - { - if (!Handle(Message_AttributeStream)::DownCast(anAttribute).IsNull()) - { - //if (GetProperties().IsNull()) - //{ - // TreeModel_ItemBasePtr anItem = Parent()->Child (Row(), Column(), false); - // SetProperties (new MessageModel_ItemPropertiesAttributeStream (anItem)); - //} - Handle(Message_AttributeStream) anAttributeStream = Handle(Message_AttributeStream)::DownCast (anExtendedAlert->Attribute()); - //Handle(MessageModel_ItemPropertiesAttributeStream) aProperties = Handle(MessageModel_ItemPropertiesAttributeStream)::DownCast (GetProperties()); - OS << anAttributeStream->GetStream().str(); - } - } - } + if (anExtendedAlert.IsNull() || anExtendedAlert->Attribute().IsNull()) + return; + + Handle(Message_Attribute) anAttribute = anExtendedAlert->Attribute(); + if (anAttribute.IsNull()) + return; + + if (Handle(Message_AttributeStream)::DownCast(anAttribute).IsNull()) + return; + + Handle(Message_AttributeStream) anAttributeStream = Handle(Message_AttributeStream)::DownCast (anExtendedAlert->Attribute()); + OS << anAttributeStream->GetStream().str(); +} + +// ======================================================================= +// function : SetStream +// purpose : +// ======================================================================= +bool MessageModel_ItemAlert::SetStream (const Standard_SStream& theSStream, Standard_Integer& theStartPos, + Standard_Integer& theLastPos) const +{ + Handle(Message_AlertExtended) anExtendedAlert = Handle(Message_AlertExtended)::DownCast (getAlert()); + if (anExtendedAlert.IsNull() || anExtendedAlert->Attribute().IsNull()) + return false; + + Handle(Message_Attribute) anAttribute = anExtendedAlert->Attribute(); + if (anAttribute.IsNull()) + return false; + + if (Handle(Message_AttributeStream)::DownCast(anAttribute).IsNull()) + return false; + + Handle(Message_AttributeStream) anAttributeStream = Handle(Message_AttributeStream)::DownCast (anExtendedAlert->Attribute()); + TCollection_AsciiString aStreamValue = Standard_Dump::Text (anAttributeStream->GetStream()); + + TCollection_AsciiString aNewValue = Standard_Dump::Text (theSStream); + + Standard_SStream aStream; + aStream << aStreamValue.SubString (1, theStartPos - 1); + aStream << aNewValue; + if (theLastPos + 1 <= aStreamValue.Length()) + aStream << aStreamValue.SubString (theLastPos + 1, aStreamValue.Length()); + + //TCollection_AsciiString aStreamValue_debug = Standard_Dump::Text (aStream); + + anAttributeStream->SetStream (aStream); + + return true; } // ======================================================================= @@ -268,33 +297,33 @@ void MessageModel_ItemAlert::Init() } } - /*Handle(Message_AlertExtended) anExtendedAlert = Handle(Message_AlertExtended)::DownCast(myAlert); + Handle(Message_AlertExtended) anExtendedAlert = Handle(Message_AlertExtended)::DownCast(myAlert); if (!anExtendedAlert.IsNull() && !anExtendedAlert->Attribute().IsNull()) { Handle(Message_Attribute) anAttribute = anExtendedAlert->Attribute(); if (!anAttribute.IsNull()) { - if (!Handle(Message_AttributeStream)::DownCast(anAttribute).IsNull()) - { - if (GetProperties().IsNull()) - { - TreeModel_ItemBasePtr anItem = Parent()->Child (Row(), Column(), false); - SetProperties (new MessageModel_ItemPropertiesAttributeStream (anItem)); - } - Handle(Message_AttributeStream) anAttributeStream = Handle(Message_AttributeStream)::DownCast (anExtendedAlert->Attribute()); - Handle(MessageModel_ItemPropertiesAttributeStream) aProperties = Handle(MessageModel_ItemPropertiesAttributeStream)::DownCast (GetProperties()); - aProperties->Init (anAttributeStream->GetStream()); - } - //if (anAttribute->IsKind (STANDARD_TYPE (Message_AttributeObject))) - // myPresentations.Append (Handle(Message_AttributeObject)::DownCast (anAttribute)->GetObject()); - //if (anAttribute->IsKind (STANDARD_TYPE (TopoDS_AlertAttribute))) - // myPresentations.Append (new Convert_TransientShape (Handle(TopoDS_AlertAttribute)::DownCast (anAttribute)->GetShape())); + //if (!Handle(Message_AttributeStream)::DownCast(anAttribute).IsNull()) + //{ + // if (GetProperties().IsNull()) + // { + // TreeModel_ItemBasePtr anItem = Parent()->Child (Row(), Column(), false); + // SetProperties (new MessageModel_ItemPropertiesAttributeStream (anItem)); + // } + // Handle(Message_AttributeStream) anAttributeStream = Handle(Message_AttributeStream)::DownCast (anExtendedAlert->Attribute()); + // Handle(MessageModel_ItemPropertiesAttributeStream) aProperties = Handle(MessageModel_ItemPropertiesAttributeStream)::DownCast (GetProperties()); + // aProperties->Init (anAttributeStream->GetStream()); + //} + ////if (anAttribute->IsKind (STANDARD_TYPE (Message_AttributeObject))) + //// myPresentations.Append (Handle(Message_AttributeObject)::DownCast (anAttribute)->GetObject()); + if (anAttribute->IsKind (STANDARD_TYPE (TopoDS_AlertAttribute))) + myPresentations.Append (new Convert_TransientShape (Handle(TopoDS_AlertAttribute)::DownCast (anAttribute)->GetShape())); } //TCollection_AsciiString aDescription = anExtendedAlert->Attribute()->GetDescription(); //Bnd_Box aBox; //if (aBox.Init (Standard_SStream (aDescription.ToCString()))) // myPresentations.Append (new Convert_TransientShape (Convert_Tools::CreateShape (aBox))); - }*/ + } MessageModel_ItemBase::Init(); } diff --git a/tools/MessageModel/MessageModel_ItemAlert.hxx b/tools/MessageModel/MessageModel_ItemAlert.hxx index 41950e8c30..6938a2f00e 100644 --- a/tools/MessageModel/MessageModel_ItemAlert.hxx +++ b/tools/MessageModel/MessageModel_ItemAlert.hxx @@ -78,6 +78,11 @@ public: //! \return stream value or dummy Standard_EXPORT virtual void GetStream (Standard_OStream& OS) const Standard_OVERRIDE; + //! Returns stream value of the item to fulfill property panel. + //! \return stream value or dummy + Standard_EXPORT virtual bool SetStream (const Standard_SStream& theSStream, Standard_Integer& theStartPos, + Standard_Integer& theLastPos) const Standard_OVERRIDE; + //! Sets some shape to present the item //! \param theShape shape instance void SetCustomShape (const TopoDS_Shape& theShape) { myCustomShape = theShape; } diff --git a/tools/MessageModel/MessageModel_ItemReport.cxx b/tools/MessageModel/MessageModel_ItemReport.cxx index 9730033557..06b3accb15 100644 --- a/tools/MessageModel/MessageModel_ItemReport.cxx +++ b/tools/MessageModel/MessageModel_ItemReport.cxx @@ -198,3 +198,31 @@ Handle(Message_Report) MessageModel_ItemReport::FindReport (const MessageModel_I } return NULL; } + +// ======================================================================= +// function : GetStream +// purpose : +// ======================================================================= +void MessageModel_ItemReport::GetStream (Standard_OStream& theOStream) const +{ + Handle(Message_Report) aReport = GetReport(); + if (aReport.IsNull()) + return; + + aReport->DumpJson (theOStream); +} + +// ======================================================================= +// function : SetStream +// purpose : +// ======================================================================= +bool MessageModel_ItemReport::SetStream (const Standard_SStream& theSStream, Standard_Integer& theStartPos, + Standard_Integer& theLastPos) const +{ + Handle(Message_Report) aReport = GetReport(); + if (aReport.IsNull()) + return false; + + Standard_Integer aStartPos = 1; + return aReport->InitJson (theSStream, aStartPos); +} diff --git a/tools/MessageModel/MessageModel_ItemReport.hxx b/tools/MessageModel/MessageModel_ItemReport.hxx index 258a58abce..e0bfa260e8 100644 --- a/tools/MessageModel/MessageModel_ItemReport.hxx +++ b/tools/MessageModel/MessageModel_ItemReport.hxx @@ -78,6 +78,15 @@ public: //! Returns report of the item static Handle(Message_Report) FindReport (const MessageModel_ItemBasePtr& thetItem); + //! 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; + + //! Returns stream value of the item to fulfill property panel. + //! \return stream value or dummy + Standard_EXPORT virtual bool SetStream (const Standard_SStream& theSStream, Standard_Integer& theStartPos, + Standard_Integer& theLastPos) const Standard_OVERRIDE; + protected: //! Initialize the current item. It is empty because Reset() is also empty. diff --git a/tools/MessageView/MessageView_VisibilityState.cxx b/tools/MessageView/MessageView_VisibilityState.cxx index 5b7e5d415f..f2a1dbac95 100644 --- a/tools/MessageView/MessageView_VisibilityState.cxx +++ b/tools/MessageView/MessageView_VisibilityState.cxx @@ -101,7 +101,7 @@ TopoDS_Shape MessageView_VisibilityState::getShape (const QModelIndex& theIndex) if (!anAlertItem) return TopoDS_Shape(); - if (!anAlertItem->GetCustomShape().IsNull()) + /*if (!anAlertItem->GetCustomShape().IsNull()) return anAlertItem->GetCustomShape(); Handle(Message_Alert) anAlert = anAlertItem->GetAlert(); @@ -115,7 +115,7 @@ TopoDS_Shape MessageView_VisibilityState::getShape (const QModelIndex& theIndex) Handle(TopoDS_AlertAttribute) aShapeAttribute = Handle(TopoDS_AlertAttribute)::DownCast (anAlertExtended->Attribute()); if (!aShapeAttribute.IsNull()) return aShapeAttribute->GetShape(); - + */ return TopoDS_Shape(); } diff --git a/tools/MessageView/MessageView_Window.cxx b/tools/MessageView/MessageView_Window.cxx index 69fda29840..59b7b5d801 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); @@ -188,11 +190,14 @@ MessageView_Window::MessageView_Window (QWidget* theParent) myPropertyPanelWidget->setWidget (myPropertyView->GetControl()); myMainWindow->addDockWidget (Qt::RightDockWidgetArea, myPropertyPanelWidget); connect (myPropertyPanelWidget->toggleViewAction(), SIGNAL(toggled(bool)), this, SLOT (onPropertyPanelShown (bool))); - connect (myPropertyView, SIGNAL (propertyViewSelectionChanged()), this, SLOT (onPropertyViewSelectionChanged ())); + connect (myPropertyView, SIGNAL (propertyViewSelectionChanged()), this, SLOT (onPropertyViewSelectionChanged())); + connect (myPropertyView, SIGNAL (propertyViewDataChanged()), this, SLOT (onPropertyViewDataChanged())); + // view myViewWindow = new View_Window (myMainWindow, false); connect (myViewWindow, SIGNAL(eraseAllPerformed()), this, SLOT(onEraseAllPerformed())); + connect (myViewWindow->GetViewToolBar(), SIGNAL (contextChanged()), this, SLOT (onContextSelected())); aVisibilityState->SetDisplayer (myViewWindow->GetDisplayer()); aVisibilityState->SetPresentationType (View_PresentationType_Main); myViewWindow->GetView()->SetPredefinedSize (MESSAGEVIEW_DEFAULT_VIEW_WIDTH, MESSAGEVIEW_DEFAULT_VIEW_HEIGHT); @@ -363,6 +368,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 +415,7 @@ void MessageView_Window::addReport (const Handle(Message_Report)& theReport, } // ======================================================================= -// function : onTreeViewSelectionChanged +// function : onTreeViewVisibilityClicked // purpose : // ======================================================================= void MessageView_Window::onTreeViewVisibilityClicked(const QModelIndex& theIndex) @@ -430,37 +436,7 @@ void MessageView_Window::onTreeViewSelectionChanged (const QItemSelection&, cons return; updatePropertyPanelBySelection(); - - NCollection_List aPresentations; - MessageModel_ItemRootPtr aRootItem; - QModelIndexList aSelectedIndices = myTreeView->selectionModel()->selectedIndexes(); - for (QModelIndexList::const_iterator aSelIt = aSelectedIndices.begin(); aSelIt != aSelectedIndices.end(); aSelIt++) - { - QModelIndex anIndex = *aSelIt; - if (anIndex.column() != 0) - continue; - - TreeModel_ItemBasePtr anItemBase = TreeModel_ModelBase::GetItemByIndex (anIndex); - 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 (); - if (anItemProperties) - anItemProperties->GetPresentations (-1, -1, aPresentations); - - MessageModel_ItemAlertPtr anAlertItem = itemDynamicCast(anItemBase); - if (!anAlertItem) - continue; - anAlertItem->GetPresentations (aPresentations); - } - updatePreviewPresentation (aPresentations); + updatePreviewPresentation(); } // ======================================================================= @@ -553,15 +529,12 @@ void MessageView_Window::onPropertyViewSelectionChanged() if (!anAlertItem) return; - QList aPropertyTables; - myPropertyView->GetActiveTables (aPropertyTables); - if (aPropertyTables.isEmpty()) + ViewControl_Table* aPropertyTable = myPropertyView->GetTable(); + if (!aPropertyTable->IsActive()) return; - ViewControl_Table* aFirstTable = aPropertyTables[0]; // TODO: implement for several tables - QMap> aSelectedIndices; - aFirstTable->GetSelectedIndices (aSelectedIndices); + aPropertyTable->GetSelectedIndices (aSelectedIndices); // clear presentation if selection is empty MessageModel_TreeModel* aTreeModel = dynamic_cast (myTreeView->model()); @@ -573,7 +546,7 @@ void MessageView_Window::onPropertyViewSelectionChanged() return; } - /*TopoDS_Shape aShapeOfSelection = MessageModel_Tools::BuildShape (anAlertItem->GetAlert(), aSelectedIndices[0], aFirstTable); + /*TopoDS_Shape aShapeOfSelection = MessageModel_Tools::BuildShape (anAlertItem->GetAlert(), aSelectedIndices[0], aPropertyTable); if (aShapeOfSelection.IsNull()) return; @@ -596,6 +569,24 @@ void MessageView_Window::onPropertyViewSelectionChanged() }*/ } +// ======================================================================= +// function : onPropertyViewDataChanged +// purpose : +// ======================================================================= +void MessageView_Window::onPropertyViewDataChanged() +{ + QItemSelectionModel* aModel = myTreeView->selectionModel(); + if (!aModel) + return; + QModelIndex anIndex = TreeModel_ModelBase::SingleSelected (aModel->selectedIndexes(), 0); + TreeModel_ItemBasePtr anItemBase = TreeModel_ModelBase::GetItemByIndex (anIndex); + if (!anItemBase) + return; + + updatePropertyPanelBySelection(); + updatePreviewPresentation(); +} + // ======================================================================= // function : onEraseAllPerformed // purpose : @@ -703,6 +694,19 @@ void MessageView_Window::onReloadReport() aTreeModel->SetReport (aReportItem->Row(), aReport, aDescription); } +// ======================================================================= +// function : onContextSelected +// purpose : +// ======================================================================= +void MessageView_Window::onContextSelected() +{ + Handle(AIS_InteractiveContext) aContext = myViewWindow->GetViewToolBar()->GetCurrentContext(); + if (aContext.IsNull()) + return; + + myDisplayPreview->SetContext (aContext); +} + // ======================================================================= // function : updatePropertyPanelBySelection // purpose : @@ -722,97 +726,62 @@ void MessageView_Window::updatePropertyPanelBySelection() MessageModel_Tools::GetPropertyTableValues (anItemBase, aTableValues); myPropertyView->Init (aTableValues);*/ - QList aTableValuesList; + ViewControl_TableModelValues* aTableValues = 0; QItemSelectionModel* aModel = myTreeView->selectionModel(); if (!aModel) 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(); + aTableValues = new ViewControl_TableModelValues(); aTableValues->SetProperties (anItemProperties); - aTableValuesList.append (aTableValues); } } - myPropertyView->Init (aTableValuesList); + myPropertyView->Init (aTableValues); } // ======================================================================= // function : updatePreviewPresentation // purpose : // ======================================================================= -void MessageView_Window::updatePreviewPresentation (const NCollection_List& thePresentations) +void MessageView_Window::updatePreviewPresentation() { Handle(AIS_InteractiveContext) aContext = myViewWindow->GetViewToolBar()->GetCurrentContext(); if (aContext.IsNull()) return; - if (!myPreviewPresentations.IsEmpty()) + NCollection_List aPresentations; + MessageModel_ItemRootPtr aRootItem; + QModelIndexList aSelectedIndices = myTreeView->selectionModel()->selectedIndexes(); + for (QModelIndexList::const_iterator aSelIt = aSelectedIndices.begin(); aSelIt != aSelectedIndices.end(); aSelIt++) { - for (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(); + QModelIndex anIndex = *aSelIt; + if (anIndex.column() != 0) + continue; - myPreviewPresentations = thePresentations; - if (myPreviewPresentations.IsEmpty()) - return; + TreeModel_ItemBasePtr anItemBase = TreeModel_ModelBase::GetItemByIndex (anIndex); + if (!anItemBase) + continue; - 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(TreeModel_ItemProperties) anItemProperties = anItemBase->Properties(); + if (anItemProperties) { - Handle(Convert_TransientShape) aShapeObject = Handle(Convert_TransientShape)::DownCast (aDisplayedIt.Value()); - aBuilder.Add (aCompound, aShapeObject->GetShape()); + anItemProperties->GetPresentations (-1, -1, aPresentations); } - } - - 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 + MessageModel_ItemAlertPtr anAlertItem = itemDynamicCast(anItemBase); + if (anAlertItem) { - Handle(AIS_Shape)::DownCast (myPreviewPresentation)->Set (aCompound); - //myPreviewPresentation->SetTransformPersistence(thePersistent); - if (!aContext.IsNull() && myPreviewPresentation->GetContext() == aContext) - aContext->Redisplay (myPreviewPresentation, Standard_True); + anAlertItem->GetPresentations (aPresentations); } } + + myDisplayPreview->SetContext (aContext); + myDisplayPreview->UpdatePreview (View_DisplayActionType_DisplayId, aPresentations); } diff --git a/tools/MessageView/MessageView_Window.hxx b/tools/MessageView/MessageView_Window.hxx index 6ff19ed309..a602fe7e47 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; @@ -139,6 +140,9 @@ protected slots: //! \param theDeselected container of selected table cells void onPropertyViewSelectionChanged(); + //! Update tree view item, preview presentation by item value change + void onPropertyViewDataChanged(); + //! Updates visibility states by erase all in context void onEraseAllPerformed(); @@ -157,13 +161,15 @@ protected slots: //! Reads if possible report of a selected item and updates this report in tree view void onReloadReport(); + //! Updates context in preview display + void onContextSelected(); + protected: //! Updates property panel content by item selected in tree view. void updatePropertyPanelBySelection(); //!< Updates presentation of preview for parameter shapes. Creates a compound of the shapes - //!< \param theShape container of shapes - void updatePreviewPresentation (const NCollection_List& thePresentations); + void updatePreviewPresentation(); private: QMainWindow* myMainWindow; //!< main control, parent for all MessageView controls @@ -172,6 +178,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 +188,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..f7ce1dccd4 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(); } @@ -122,18 +128,46 @@ void TreeModel_ItemBase::Init() { m_bInitialized = true; - NCollection_List aHierarchicalValues; + //NCollection_List aHierarchicalValues; + int aStreamChildrenCount = 0; if (Column() == 0) { - NCollection_IndexedDataMap aValues; + //NCollection_IndexedDataMap aValues; Standard_SStream aStream; GetStream (aStream); - Standard_Dump::SplitJson (Standard_Dump::Text (aStream), aValues); - aHierarchicalValues = Standard_Dump::HierarchicalValueIndices (aValues); + if (!Standard_Dump::Text (aStream).IsEmpty()) + { + if (!myProperties) + { + myProperties = new TreeModel_ItemProperties(); + myProperties->SetItem (currentItem()); + } + myProperties->Init(); + aStreamChildrenCount = myProperties->Children().Extent(); + } + //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(); + m_iStreamChildren = aStreamChildrenCount;//aHierarchicalValues.Extent(); } // ======================================================================= diff --git a/tools/TreeModel/TreeModel_ItemBase.hxx b/tools/TreeModel/TreeModel_ItemBase.hxx index a784548c88..9271e8cb5b 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; @@ -103,8 +104,11 @@ public: //! \return stream value or dummy virtual void GetStream (Standard_OStream& theOStream) const { (void)theOStream; } - //! Sets stream value into the object - virtual void SetStream (Standard_SStream& theStream) const { (void)theStream; } + //! Returns stream value of the item to fulfill property panel. + //! \return stream value or dummy + virtual bool SetStream (const Standard_SStream& theSStream, Standard_Integer& theStartPos, + Standard_Integer& theLastPos) const + { (void)theSStream; (void)theStartPos; (void)theLastPos; return false; } //! Gets the parent of the item, or TreeModel_ItemBasePtr() if it has no parent. //! \return pointer to the item @@ -145,6 +149,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 +186,10 @@ protected: //! \return the value Standard_EXPORT virtual QVariant initValue (const int theItemRole) const; +protected: + Handle(TreeModel_ItemProperties) myProperties; //!< the properties + int m_iStreamChildren; //!< the count of stream items + private: typedef QHash< QPair, TreeModel_ItemBasePtr > PositionToItemHash; @@ -188,7 +199,6 @@ private: TreeModel_ItemBasePtr m_pParent; //!< the parent item int m_iRow; //!< the item row position in the parent item int m_iColumn; //!< the item column position in the parent item - int m_iStreamChildren; //!< the count of stream items bool m_bInitialized; //!< the state whether the item content is already initialized }; diff --git a/tools/TreeModel/TreeModel_ItemProperties.cxx b/tools/TreeModel/TreeModel_ItemProperties.cxx index 8ccd2d6f11..4813754b34 100644 --- a/tools/TreeModel/TreeModel_ItemProperties.cxx +++ b/tools/TreeModel/TreeModel_ItemProperties.cxx @@ -14,6 +14,8 @@ // commercial license or contractual agreement. #include +#include +#include #include #include @@ -27,18 +29,74 @@ IMPLEMENT_STANDARD_RTTIEXT(TreeModel_ItemProperties, Standard_Transient) // purpose : // ======================================================================= -void TreeModel_ItemProperties::Init (const TCollection_AsciiString& theStreamValue) +void TreeModel_ItemProperties::Init () { - NCollection_IndexedDataMap aValues; - if (!Standard_Dump::SplitJson (theStreamValue, aValues)) - return; + Standard_SStream aStream; + Item()->GetStream (aStream); + + NCollection_IndexedDataMap aValues; + TCollection_AsciiString aStreamText = Standard_Dump::Text (aStream); + Standard_Dump::SplitJson (aStreamText, aValues); + + TreeModel_ItemStreamPtr aStreamParent = itemDynamicCast(Item()); + TCollection_AsciiString aKey; + Standard_DumpValue aKeyValue; + if (!aStreamParent) + { + Standard_SStream aStream; + Item()->GetStream (aStream); + + //aKey = aValues.FindKey (1); + //aKeyValue = aValues.FindFromIndex (1); + + //// one row value, like gp_XYZ, without additional { for type + //aValues.Clear(); + //if (!Standard_Dump::SplitJson (aKeyValue.myValue, aValues)) + //{ + // aKeyValue = Standard_DumpValue (aStreamText, 1); + //} + + Handle(Standard_Transient) anItemObject = Item()->GetObject(); + aKey = anItemObject.IsNull() ? "Dump" : anItemObject->DynamicType()->Name(); + aKeyValue = Standard_DumpValue (aStreamText, 1); + + myKey = aKey; + myStreamValue = aKeyValue; + } + else + { + TCollection_AsciiString aValue; + Handle(TreeModel_ItemProperties) aParentProperties = Item()->Parent() ? Item()->Parent()->Properties() : 0; + if (aParentProperties) + aParentProperties->GetChildStream (Item()->Row(), aKey, aKeyValue); + + myKey = aKey; + myStreamValue = aKeyValue; + + aValues.Clear(); + Standard_Dump::SplitJson (myStreamValue.myValue, aValues); + } for (Standard_Integer anIndex = 1; anIndex <= aValues.Size(); anIndex++) { - TCollection_AsciiString aValue = aValues.FindFromIndex (anIndex); - if (!Standard_Dump::HasChildKey (aValue)) + Standard_DumpValue aValue = aValues.FindFromIndex (anIndex); + if (Standard_Dump::HasChildKey (aValue.myValue)) + myChildren.Add (aValues.FindKey (anIndex), aValue); + else myValues.Add (aValues.FindKey (anIndex), aValue); } + + //aValues.Clear(); + //if (!Standard_Dump::SplitJson (myStreamValue.myValue, aValues)) + //{ + // return; + //} + //for (Standard_Integer anIndex = 1; anIndex <= aValues.Size(); anIndex++) + //{ + // Standard_DumpValue aValue = aValues.FindFromIndex (anIndex); + // if (!Standard_Dump::HasChildKey (aValue.myValue)) + // myValues.Add (aValues.FindKey (anIndex), aValue); + //} } // ======================================================================= @@ -47,6 +105,10 @@ void TreeModel_ItemProperties::Init (const TCollection_AsciiString& theStreamVal // ======================================================================= void TreeModel_ItemProperties::Reset() { + myKey = ""; + myStreamValue = Standard_DumpValue(); + + myChildren.Clear(); myValues.Clear(); } @@ -57,7 +119,7 @@ void TreeModel_ItemProperties::Reset() int TreeModel_ItemProperties::RowCount() const { - return myValues.Size(); + return Values().Size(); } // ======================================================================= @@ -67,15 +129,84 @@ int TreeModel_ItemProperties::RowCount() const QVariant TreeModel_ItemProperties::Data (const int theRow, const int theColumn, int theRole) const { + if (theColumn == 1 && theRole == Qt::BackgroundRole) + { + Quantity_Color aColor; + Standard_SStream aStream; + Item()->GetStream (aStream); + if (Convert_Tools::ConvertStreamToColor (aStream, aColor)) + { + Standard_Real aRed, aGreen, aBlue; + aColor.Values (aRed, aGreen, aBlue, Quantity_TOC_RGB); + + int aDelta = 255; + return QColor((int)(aRed * aDelta), (int)(aGreen * aDelta), (int)(aBlue * aDelta)); + } + } + if (theRole != Qt::DisplayRole && theRole != Qt::ToolTipRole) return QVariant(); - if (theColumn == 0) return myValues.FindKey (theRow + 1).ToCString(); - else if (theColumn == 1) return myValues.FindFromIndex (theRow + 1).ToCString(); + if (theColumn == 0) return Values().FindKey (theRow + 1).ToCString(); + else if (theColumn == 1) return Values().FindFromIndex (theRow + 1).myValue.ToCString(); return QVariant(); } +// ======================================================================= +// function : GetEditType +// purpose : +// ======================================================================= + +ViewControl_EditType TreeModel_ItemProperties::GetEditType (const int, const int theColumn) const +{ + if (theColumn == 0) + return ViewControl_EditType_None; + + return ViewControl_EditType_Line; +} + +// ======================================================================= +// function : SetData +// purpose : +// ======================================================================= + +bool TreeModel_ItemProperties::SetData (const int theRow, const int theColumn, const QVariant& theValue, int) +{ + if (theColumn == 0) + return false; + + TreeModel_ItemBasePtr aParent = Item()->Parent(); + while (aParent && itemDynamicCast(aParent)) + { + aParent = aParent->Parent(); + } + if (!aParent) + return false; + + Standard_SStream aStream; + Item()->GetStream (aStream); + + //TCollection_AsciiString aStreamValue = Standard_Dump::Text (aStream); + + Standard_DumpValue aValue = Values().FindFromIndex (theRow + 1); + Standard_Integer aStartPos = aValue.myStartPosition; + Standard_Integer aLastPos = aStartPos + aValue.myValue.Length() - 1; + + aStream.str (""); + //aStream << aStreamValue.SubString (1, aStartPos - 1); + aStream << theValue.toString().toStdString().c_str(); + //if (aLastPos + 1 <= aStreamValue.Length()) + // aStream << aStreamValue.SubString (aLastPos + 1, aStreamValue.Length()); + + //TCollection_AsciiString aStreamValue_debug = Standard_Dump::Text (aStream); + + Item()->SetStream (aStream, aStartPos, aLastPos); + Item()->Reset(); + + return true; +} + // ======================================================================= // function : GetPresentations // purpose : @@ -88,6 +219,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; } @@ -98,8 +233,8 @@ void TreeModel_ItemProperties::GetPresentations (const int theRow, const int the NCollection_IndexedDataMap aValues; aValues.Add (Data (theRow, 0).toString().toStdString().c_str(), Data (theRow, theColumn).toString().toStdString().c_str()); - Standard_SStream aStreamOnSelected; - Standard_Dump::JoinJson (aStreamOnSelected, aValues); + //Standard_SStream aStreamOnSelected; + //Standard_Dump::JoinJson (aStreamOnSelected, aValues); //if (theRow < 0) // full presentation //{ @@ -108,12 +243,12 @@ void TreeModel_ItemProperties::GetPresentations (const int theRow, const int the // thePresentations.Append (new Convert_TransientShape (Convert_Tools::CreateShape (aBox))); //} - gp_XYZ aPoint; - Standard_Integer aPosition = 1; - if (aPoint.InitJson (aStreamOnSelected, aPosition)) - { - thePresentations.Append (new Convert_TransientShape (BRepBuilderAPI_MakeVertex (aPoint))); - } + //gp_XYZ aPoint; + //Standard_Integer aPosition = 1; + //if (aPoint.InitJson (aStreamOnSelected, aPosition)) + //{ + // thePresentations.Append (new Convert_TransientShape (BRepBuilderAPI_MakeVertex (aPoint))); + //} //QVariant aValue = GetTableData (theRow, theColumn, Qt::DisplayRole); @@ -141,3 +276,30 @@ Qt::ItemFlags TreeModel_ItemProperties::GetTableFlags (const int, const int theC return aFlags; } +// ======================================================================= +// function : GetChildStream +// purpose : +// ======================================================================= +void TreeModel_ItemProperties::GetChildStream (const int theRowId, + TCollection_AsciiString& theKey, + Standard_DumpValue& theValue) const +{ + if (myChildren.Size() <= theRowId) + return; + + theKey = myChildren.FindKey (theRowId + 1); + theValue = myChildren.FindFromIndex (theRowId + 1); +} + +// ======================================================================= +// function : GetChildStream +// purpose : +// ======================================================================= +void TreeModel_ItemProperties::initItem() const +{ + if (!Item()) + return; + if (Item()->IsInitialized()) + return; + Item()->Init(); +} diff --git a/tools/TreeModel/TreeModel_ItemProperties.hxx b/tools/TreeModel/TreeModel_ItemProperties.hxx index 06eadb44ee..64dbe80a3e 100644 --- a/tools/TreeModel/TreeModel_ItemProperties.hxx +++ b/tools/TreeModel/TreeModel_ItemProperties.hxx @@ -17,6 +17,7 @@ #define TreeModel_ItemProperties_H #include +#include #include #include #include @@ -65,7 +66,7 @@ public: TreeModel_ItemBasePtr Item() const { return myItem; } //! Fill internal containers by stream values - void Init (const TCollection_AsciiString& theStreamValue); + Standard_EXPORT void Init (/*const Standard_SStream& theStream*/); //! If the item has internal values, there should be reseted here. Standard_EXPORT virtual void Reset(); @@ -86,6 +87,20 @@ public: //! \return value interpreted depending on the given role QVariant Data (const int theRow, const int theColumn, int theRole = Qt::DisplayRole) const; + //! Returns type of edit control for the model index. By default, it is an empty control + //! \param theRow a model index row + //! \param theColumn a model index column + //! \return edit type + ViewControl_EditType GetEditType (const int theRow, const int theColumn) const; + + //! Sets content of the model index for the given role, it is applyed to internal container of values + //! \param theRow a model index row + //! \param theColumn a model index column + //! \param theRole a view role + //! \return true if the value is changed + Standard_EXPORT virtual bool SetData (const int theRow, const int theColumn, const QVariant& theValue, + int theRole = Qt::DisplayRole); + //! Returns presentation of the attribute to be visualized in the view //! \param theRow a model index row //! \param theColumn a model index column @@ -99,12 +114,40 @@ public: //! \return flags Standard_EXPORT virtual Qt::ItemFlags GetTableFlags (const int theRow, const int theColumn) const; + //! Returns stream value of the item to fulfill property panel. + //! \return stream value or dummy + Standard_EXPORT void GetChildStream (const int theRowId, + TCollection_AsciiString& theKey, + Standard_DumpValue& theValue) const; + + //! Returns data object of the item. + //! \return object key + const TCollection_AsciiString& GetKey() const { return myKey; } + + //! Returns stream value of the item. + //! \return value + const TCollection_AsciiString& StreamValue() const { return myStreamValue.myValue; } + + //! Returns children stream values + const NCollection_IndexedDataMap& Values() const { initItem(); return myValues; } + + //! Returns children stream values + const NCollection_IndexedDataMap& Children() const { initItem(); return myChildren; } + DEFINE_STANDARD_RTTIEXT (TreeModel_ItemProperties, Standard_Transient) +protected: + //! Initialize the current item. It creates a backup of the specific item information + void initItem() const; + private: TreeModel_ItemBasePtr myItem; //!< current item - NCollection_IndexedDataMap myValues; //!< the values + TCollection_AsciiString myKey; //!< the item key + Standard_DumpValue myStreamValue; //!< the stream value + NCollection_IndexedDataMap myChildren; //!< the children + + NCollection_IndexedDataMap myValues; //!< the values }; #endif \ No newline at end of file diff --git a/tools/TreeModel/TreeModel_ItemStream.cxx b/tools/TreeModel/TreeModel_ItemStream.cxx index 17cda16e60..76296d8a11 100644 --- a/tools/TreeModel/TreeModel_ItemStream.cxx +++ b/tools/TreeModel/TreeModel_ItemStream.cxx @@ -26,7 +26,7 @@ TreeModel_ItemStream::TreeModel_ItemStream (TreeModel_ItemBasePtr theParent, const int theRow, const int theColumn) : TreeModel_ItemBase (theParent, theRow, theColumn) { - myProperties = new TreeModel_ItemProperties(); + //myProperties = new TreeModel_ItemProperties(); } // ======================================================================= @@ -35,53 +35,67 @@ TreeModel_ItemStream::TreeModel_ItemStream (TreeModel_ItemBasePtr theParent, con // ======================================================================= void TreeModel_ItemStream::Init() { - if (!myProperties->Item()) - myProperties->SetItem (currentItem()); + //if (!GetProperties()->Item()) + // myProperties->SetItem (currentItem()); + + //TCollection_AsciiString aKey, aKeyValue, aPropertiesValue; + //TreeModel_ItemStreamPtr aStreamParent = itemDynamicCast(Parent()); + //if (!aStreamParent) + //{ + // Standard_SStream aStream; + // Parent()->GetStream (aStream); + + // NCollection_IndexedDataMap aValues; + // Standard_Dump::SplitJson (Standard_Dump::Text (aStream), aValues); + + // aKey = aValues.FindKey (Row() + 1); + // aKeyValue = aValues.FindFromIndex (Row() + 1); + + // // one row value, like gp_XYZ, without additional { for type + // aValues.Clear(); + // if (!Standard_Dump::SplitJson (aKeyValue, aValues)) + // aPropertiesValue = Standard_Dump::Text (aStream); + // else + // aPropertiesValue = aKeyValue; + //} + //else + //{ + // TreeModel_ItemStreamPtr aStreamParent = itemDynamicCast(Parent()); + + // TCollection_AsciiString aValue; + // aStreamParent->GetChildStream (Row(), aKey, aKeyValue); + // aPropertiesValue = aKeyValue; + //} + + //myKey = aKey; + ////myProperties->Init (aPropertiesValue); + //myStreamValue = aKeyValue; + + //NCollection_IndexedDataMap aValues; + //Standard_Dump::SplitJson (aKeyValue, aValues); + + //for (Standard_Integer anIndex = 1; anIndex <= aValues.Size(); anIndex++) + //{ + // TCollection_AsciiString aValue = aValues.FindFromIndex (anIndex); + // if (Standard_Dump::HasChildKey (aValue)) + // myChildren.Add (aValues.FindKey (anIndex), aValue); + //} - TCollection_AsciiString aKey, aKeyValue, aPropertiesValue; - TreeModel_ItemStreamPtr aStreamParent = itemDynamicCast(Parent()); - if (!aStreamParent) - { - Standard_SStream aStream; - Parent()->GetStream (aStream); - - NCollection_IndexedDataMap aValues; - Standard_Dump::SplitJson (Standard_Dump::Text (aStream), aValues); - - aKey = aValues.FindKey (Row() + 1); - aKeyValue = aValues.FindFromIndex (Row() + 1); - - // one row value, like gp_XYZ, without additional { for type - aValues.Clear(); - if (!Standard_Dump::SplitJson (aKeyValue, aValues)) - aPropertiesValue = Standard_Dump::Text (aStream); - else - aPropertiesValue = aKeyValue; - } - else - { - TreeModel_ItemStreamPtr aStreamParent = itemDynamicCast(Parent()); - - TCollection_AsciiString aValue; - aStreamParent->GetChildStream (Row(), aKey, aKeyValue); - aPropertiesValue = aKeyValue; - } - - myKey = aKey; - myProperties->Init (aPropertiesValue); - myStreamValue = aKeyValue; - - NCollection_IndexedDataMap aValues; - Standard_Dump::SplitJson (aKeyValue, aValues); + TreeModel_ItemBase::Init(); - for (Standard_Integer anIndex = 1; anIndex <= aValues.Size(); anIndex++) + //NCollection_List aHierarchicalValues; + int aStreamChildrenCount = 0; + if (Column() == 0) { - TCollection_AsciiString aValue = aValues.FindFromIndex (anIndex); - if (Standard_Dump::HasChildKey (aValue)) - myChildren.Add (aValues.FindKey (anIndex), aValue); + if (!myProperties) + { + myProperties = new TreeModel_ItemProperties(); + myProperties->SetItem (currentItem()); + } + myProperties->Init(); + aStreamChildrenCount = myProperties->Children().Extent(); } - - TreeModel_ItemBase::Init(); + m_iStreamChildren = aStreamChildrenCount;//aHierarchicalValues.Extent(); } // ======================================================================= @@ -90,11 +104,10 @@ void TreeModel_ItemStream::Init() // ======================================================================= void TreeModel_ItemStream::Reset() { - myKey = ""; - myStreamValue = ""; + //myKey = ""; + //myStreamValue = ""; - myProperties->Reset(); - myChildren.Clear(); + //myChildren.Clear(); TreeModel_ItemBase::Reset(); } @@ -112,31 +125,34 @@ QVariant TreeModel_ItemStream::initValue (const int theItemRole) const if (Column() != 0) return QVariant(); + if (theItemRole == Qt::ForegroundRole) + return QColor (Qt::darkBlue); + if (theItemRole != Qt::DisplayRole && theItemRole != Qt::EditRole && theItemRole != Qt::ToolTipRole) return QVariant(); switch (Column()) { - case 0: return GetKey().ToCString(); + case 0: return Properties() ? Properties()->GetKey().ToCString() : ""; } return QVariant(); } -// ======================================================================= -// function : GetChildStream -// purpose : -// ======================================================================= -void TreeModel_ItemStream::GetChildStream (const int theRowId, - TCollection_AsciiString& theKey, - TCollection_AsciiString& theValue) const -{ - TreeModel_ItemBasePtr aParentItem = Parent(); - if (!aParentItem) - return; - - theKey = myChildren.FindKey (theRowId + 1); - theValue = myChildren.FindFromIndex (theRowId + 1); -} +//// ======================================================================= +//// function : GetChildStream +//// purpose : +//// ======================================================================= +//void TreeModel_ItemStream::GetChildStream (const int theRowId, +// TCollection_AsciiString& theKey, +// TCollection_AsciiString& theValue) const +//{ +// TreeModel_ItemBasePtr aParentItem = Parent(); +// if (!aParentItem) +// return; +// +// theKey = myChildren.FindKey (theRowId + 1); +// theValue = myChildren.FindFromIndex (theRowId + 1); +//} // ======================================================================= // function : GetStream @@ -144,12 +160,13 @@ void TreeModel_ItemStream::GetChildStream (const int theRowId, // ======================================================================= void TreeModel_ItemStream::GetStream (Standard_OStream& theOStream) const { + if (!Properties()) + return; //Handle(AIS_InteractiveObject) anIO = GetInteractiveObject(); //if (anIO.IsNull()) // return; - theOStream << myStreamValue; - + theOStream << Properties()->StreamValue(); //anIO->DumpJson (theOStream); } diff --git a/tools/TreeModel/TreeModel_ItemStream.hxx b/tools/TreeModel/TreeModel_ItemStream.hxx index 9581d4e747..288963011b 100644 --- a/tools/TreeModel/TreeModel_ItemStream.hxx +++ b/tools/TreeModel/TreeModel_ItemStream.hxx @@ -60,21 +60,18 @@ public: //! \return the value Standard_EXPORT virtual QVariant initValue (const int theItemRole) const Standard_OVERRIDE; - //! Returns stream value of the item to fulfill property panel. - //! \return stream value or dummy - Standard_EXPORT void GetChildStream (const int theRowId, - TCollection_AsciiString& theKey, - TCollection_AsciiString& theValue) const; - - //! Returns data object of the item. - //! \return object - const TCollection_AsciiString& GetKey() const { initItem(); return myKey; } + ////! Returns stream value of the item to fulfill property panel. + ////! \return stream value or dummy + //Standard_EXPORT void GetChildStream (const int theRowId, + // TCollection_AsciiString& theKey, + // TCollection_AsciiString& theValue) const; - const NCollection_IndexedDataMap& GetChildren() const - { initItem(); return myChildren; } + ////! Returns data object of the item. + ////! \return object + //const TCollection_AsciiString& GetKey() const { initItem(); return myKey; } - //! Returns the item properties - Handle(TreeModel_ItemProperties) Properties() const { return myProperties; } + //const NCollection_IndexedDataMap& GetChildren() const + // { initItem(); return myChildren; } //! Returns stream value of the item to fulfill property panel. //! \return stream value or dummy @@ -103,10 +100,9 @@ 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 + //TCollection_AsciiString myKey; //!< the item key + //TCollection_AsciiString myStreamValue; //!< the stream value + //NCollection_IndexedDataMap myChildren; //!< the children }; #endif diff --git a/tools/VInspector/VInspector_ItemBVHTree.cxx b/tools/VInspector/VInspector_ItemBVHTree.cxx index 31478bf9f8..7ce6f67aad 100644 --- a/tools/VInspector/VInspector_ItemBVHTree.cxx +++ b/tools/VInspector/VInspector_ItemBVHTree.cxx @@ -42,14 +42,16 @@ VInspector_ItemBVHTree::VInspector_ItemBVHTree (TreeModel_ItemBasePtr theParent, // ======================================================================= int VInspector_ItemBVHTree::initRowCount() const { - if (Column() != 0) - return 0; + return 0;// - opencascade::handle > aTree = GetTree(); - if (aTree.IsNull()) - return 0; + //if (Column() != 0) + // return 0; - return aTree->Length(); + //opencascade::handle > aTree = GetTree(); + //if (aTree.IsNull()) + // return 0; + + //return aTree->Length(); } // ======================================================================= @@ -134,17 +136,16 @@ void VInspector_ItemBVHTree::initItem() const } // ======================================================================= -// function : Dump +// function : GetStream // purpose : // ======================================================================= -Standard_Boolean VInspector_ItemBVHTree::Dump (Standard_OStream& theOStream) const +void VInspector_ItemBVHTree::GetStream (Standard_OStream& theOStream) const { opencascade::handle > aBVHTree = GetTree(); if (aBVHTree.IsNull()) - return Standard_False; + return; aBVHTree->DumpJson (theOStream); - return Standard_True; } // ======================================================================= diff --git a/tools/VInspector/VInspector_ItemBVHTree.hxx b/tools/VInspector/VInspector_ItemBVHTree.hxx index 611af1483d..ea91796cc6 100644 --- a/tools/VInspector/VInspector_ItemBVHTree.hxx +++ b/tools/VInspector/VInspector_ItemBVHTree.hxx @@ -54,8 +54,9 @@ public: opencascade::handle > GetTree() const { return opencascade::handle >::DownCast (GetObject()); } - //! Dumps the content of me into the stream - virtual Standard_Boolean Dump (Standard_OStream& theOStream) 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_ItemContext.cxx b/tools/VInspector/VInspector_ItemContext.cxx index decdc4b162..3558b84927 100644 --- a/tools/VInspector/VInspector_ItemContext.cxx +++ b/tools/VInspector/VInspector_ItemContext.cxx @@ -40,7 +40,7 @@ int VInspector_ItemContext::initRowCount() const int aNbProperties = 1; // item to visualize Filters/Drawer information of context int aNbPresentations = 0; - Handle(AIS_InteractiveContext) aContext = GetContext(); + Handle(AIS_InteractiveContext) aContext = Handle(AIS_InteractiveContext)::DownCast (GetObject()); if (aContext.IsNull()) return 0; @@ -94,25 +94,59 @@ QVariant VInspector_ItemContext::initValue (const int theItemRole) const if (theItemRole != Qt::DisplayRole && theItemRole != Qt::EditRole && theItemRole != Qt::ToolTipRole) return QVariant(); - if (GetContext().IsNull()) + Handle(AIS_InteractiveContext) aContext = Handle(AIS_InteractiveContext)::DownCast (GetObject()); + if (aContext.IsNull()) return Column() == 0 ? "Empty context" : ""; switch (Column()) { - case 0: return GetContext()->DynamicType()->Name(); + case 0: return aContext->DynamicType()->Name(); case 4: { Handle(AIS_InteractiveObject) anEmptyIO; - int aSelectedCount = VInspector_Tools::SelectedOwners (GetContext(), anEmptyIO, false); + int aSelectedCount = VInspector_Tools::SelectedOwners (aContext, anEmptyIO, false); return aSelectedCount > 0 ? QString::number (aSelectedCount) : ""; } - case 6: return GetContext()->DeviationCoefficient(); + case 6: return aContext->DeviationCoefficient(); default: break; } return QVariant(); } +// ======================================================================= +// function : Init +// purpose : +// ======================================================================= +void VInspector_ItemContext::Init() +{ + Handle(AIS_InteractiveContext) aContext = GetContext(); + if (aContext.IsNull()) + return; + + TreeModel_ItemBase::Init(); +} + +// ======================================================================= +// function : Reset +// purpose : +// ======================================================================= +void VInspector_ItemContext::Reset() +{ + VInspector_ItemBase::Reset(); +} + +// ======================================================================= +// function : initItem +// purpose : +// ======================================================================= +void VInspector_ItemContext::initItem() const +{ + if (IsInitialized()) + return; + const_cast(this)->Init(); +} + // ======================================================================= // function : createChild // purpose : @@ -124,3 +158,17 @@ TreeModel_ItemBasePtr VInspector_ItemContext::createChild (int theRow, int theCo else return VInspector_ItemPresentableObject::CreateItem (currentItem(), theRow, theColumn); } + +// ======================================================================= +// function : GetStream +// purpose : +// ======================================================================= +void VInspector_ItemContext::GetStream (Standard_OStream& theOStream) const +{ + Handle(AIS_InteractiveContext) aContext = GetContext(); + if (aContext.IsNull()) + return; + + aContext->DumpJson (theOStream); +} + diff --git a/tools/VInspector/VInspector_ItemContext.hxx b/tools/VInspector/VInspector_ItemContext.hxx index aa693d39c4..1d3fe7a264 100644 --- a/tools/VInspector/VInspector_ItemContext.hxx +++ b/tools/VInspector/VInspector_ItemContext.hxx @@ -51,11 +51,21 @@ public: //! \return the value Standard_EXPORT virtual QVariant initValue (const int theItemRole) const 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; + + //! Inits the item, fills internal containers + Standard_EXPORT virtual void Init() Standard_OVERRIDE; + + //! Resets cached values + Standard_EXPORT virtual void Reset() Standard_OVERRIDE; + protected: //! Initialize the current item. It creates a backup of the specific item information //! Do nothing as context has been already set into item - virtual void initItem() const Standard_OVERRIDE {} + virtual void initItem() const Standard_OVERRIDE; protected: 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_ItemGraphic3dGroup.cxx b/tools/VInspector/VInspector_ItemGraphic3dGroup.cxx index df0d2bc319..7f3292bafd 100644 --- a/tools/VInspector/VInspector_ItemGraphic3dGroup.cxx +++ b/tools/VInspector/VInspector_ItemGraphic3dGroup.cxx @@ -116,7 +116,6 @@ void VInspector_ItemGraphic3dGroup::GetStream (Standard_OStream& theOStream) con aGroup->DumpJson (theOStream); } - // ======================================================================= // function : createChild // purpose : diff --git a/tools/VInspector/VInspector_ItemPresentableObject.cxx b/tools/VInspector/VInspector_ItemPresentableObject.cxx index 89c0bdbc96..f5b361348c 100644 --- a/tools/VInspector/VInspector_ItemPresentableObject.cxx +++ b/tools/VInspector/VInspector_ItemPresentableObject.cxx @@ -185,19 +185,27 @@ void VInspector_ItemPresentableObject::Init() AIS_ListOfInteractive aListOfIO; GetContext()->DisplayedObjects (aListOfIO); // the presentation is in displayed objects of Context GetContext()->ErasedObjects (aListOfIO); // the presentation is in erased objects of Context + + std::vector aListOfIOSorted; + for (AIS_ListIteratorOfListOfInteractive anIOIt (aListOfIO); anIOIt.More(); anIOIt.Next()) + { + aListOfIOSorted.push_back (anIOIt.Value()); + } + std::sort (aListOfIOSorted.begin(), aListOfIOSorted.end()); + int aDeltaIndex = 1; // properties item int aCurrentIndex = 0; - for (AIS_ListIteratorOfListOfInteractive anIOIt (aListOfIO); anIOIt.More(); anIOIt.Next(), aCurrentIndex++) + for (std::vector::const_iterator anIOIt = aListOfIOSorted.begin(); anIOIt != aListOfIOSorted.end(); anIOIt++, aCurrentIndex++) { if (aCurrentIndex != aRowId - aDeltaIndex) continue; - anIO = anIOIt.Value(); + anIO = *anIOIt; break; } } setInteractiveObject (anIO); - myTransformPersistence = anIO->TransformPersistence(); + myTransformPersistence = !anIO.IsNull() ? anIO->TransformPersistence() : NULL; UpdatePresentationShape(); TreeModel_ItemBase::Init(); // to use getIO() without circling initialization } 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_ItemPrs3dPresentation.cxx b/tools/VInspector/VInspector_ItemPrs3dPresentation.cxx index afc4d7abb4..f5aa2ecd70 100644 --- a/tools/VInspector/VInspector_ItemPrs3dPresentation.cxx +++ b/tools/VInspector/VInspector_ItemPrs3dPresentation.cxx @@ -139,7 +139,7 @@ void VInspector_ItemPrs3dPresentation::setPresentation (const Handle(Prs3d_Prese TopoDS_Shape VInspector_ItemPrs3dPresentation::buildPresentationShape() { if (!myPresentation.IsNull()) - myPresentationShape = Convert_Tools::CreateShape (myPresentation->MinMaxValues()); + Convert_Tools::CreateShape (myPresentation->MinMaxValues(), myPresentationShape); return TopoDS_Shape(); } diff --git a/tools/VInspector/VInspector_ItemSelect3DSensitiveSetItem.cxx b/tools/VInspector/VInspector_ItemSelect3DSensitiveSetItem.cxx index 49378693c8..e25321dba3 100644 --- a/tools/VInspector/VInspector_ItemSelect3DSensitiveSetItem.cxx +++ b/tools/VInspector/VInspector_ItemSelect3DSensitiveSetItem.cxx @@ -162,5 +162,8 @@ TopoDS_Shape VInspector_ItemSelect3DSensitiveSetItem::buildPresentationShape() return TopoDS_Shape(); Select3D_BndBox3d aBndBox = aSensitiveSet->Box (Row()); - return VInspector_Tools::CreateShape (aBndBox); + TopoDS_Shape aShape; + VInspector_Tools::CreateShape (aBndBox, aShape); + + return aShape; } diff --git a/tools/VInspector/VInspector_ItemSelectBasicsSensitiveEntity.cxx b/tools/VInspector/VInspector_ItemSelectBasicsSensitiveEntity.cxx index 4d1bb397a7..766fff8d3d 100644 --- a/tools/VInspector/VInspector_ItemSelectBasicsSensitiveEntity.cxx +++ b/tools/VInspector/VInspector_ItemSelectBasicsSensitiveEntity.cxx @@ -235,18 +235,25 @@ TopoDS_Shape VInspector_ItemSelectBasicsSensitiveEntity::buildPresentationShape TopoDS_Compound aCompound; aBuilder.MakeCompound (aCompound); - aBuilder.Add (aCompound, BRepBuilderAPI_MakeVertex (aBaseEntity->CenterOfGeometry())); + BRepBuilderAPI_MakeVertex aVBuilder (aBaseEntity->CenterOfGeometry()); + if (aVBuilder.IsDone()) + aBuilder.Add (aCompound, aVBuilder.Shape()); Select3D_BndBox3d aBoundingBox = aBaseEntity->BoundingBox(); if (aBoundingBox.IsValid()) - aBuilder.Add (aCompound, VInspector_Tools::CreateShape (aBoundingBox)); + { + TopoDS_Shape aShape; + if (VInspector_Tools::CreateShape (aBoundingBox, aShape)) + aBuilder.Add (aCompound, aShape); + } Standard_CString aTypeName = aBaseEntity->DynamicType()->Name(); if (aTypeName == STANDARD_TYPE (Select3D_SensitiveBox)->Name()) { Handle(Select3D_SensitiveBox) anEntity = Handle(Select3D_SensitiveBox)::DownCast (aBaseEntity); - TopoDS_Shape aShape = Convert_Tools::CreateShape(anEntity->Box()); - aBuilder.Add (aCompound, aShape); + TopoDS_Shape aShape; + if (Convert_Tools::CreateShape(anEntity->Box(), aShape)) + aBuilder.Add (aCompound, aShape); } else if (aTypeName == STANDARD_TYPE (Select3D_SensitiveFace)->Name()) { diff --git a/tools/VInspector/VInspector_ItemSelectMgrBaseFrustum.cxx b/tools/VInspector/VInspector_ItemSelectMgrBaseFrustum.cxx index 699044b844..c6a6fc851f 100644 --- a/tools/VInspector/VInspector_ItemSelectMgrBaseFrustum.cxx +++ b/tools/VInspector/VInspector_ItemSelectMgrBaseFrustum.cxx @@ -104,18 +104,17 @@ void VInspector_ItemSelectMgrBaseFrustum::initItem() const } // ======================================================================= -// function : Dump +// function : GetStream // purpose : // ======================================================================= -Standard_Boolean VInspector_ItemSelectMgrBaseFrustum::Dump (Standard_OStream& theOStream) const +void VInspector_ItemSelectMgrBaseFrustum::GetStream (Standard_OStream& theOStream) const { Handle(SelectMgr_BaseFrustum) aFrustum = GetFrustum(); if (aFrustum.IsNull()) - return Standard_False; + return; aFrustum->DumpJson (theOStream); - return Standard_True; } // ======================================================================= diff --git a/tools/VInspector/VInspector_ItemSelectMgrBaseFrustum.hxx b/tools/VInspector/VInspector_ItemSelectMgrBaseFrustum.hxx index 087818e265..984490af7e 100644 --- a/tools/VInspector/VInspector_ItemSelectMgrBaseFrustum.hxx +++ b/tools/VInspector/VInspector_ItemSelectMgrBaseFrustum.hxx @@ -53,8 +53,9 @@ public: Standard_EXPORT Handle(SelectMgr_BaseFrustum) GetFrustum() const { return Handle(SelectMgr_BaseFrustum)::DownCast (GetObject()); } - //! Dumps the content of me into the stream - virtual Standard_Boolean Dump (Standard_OStream& theOStream) 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_ItemSelectMgrSelectableObjectSet.cxx b/tools/VInspector/VInspector_ItemSelectMgrSelectableObjectSet.cxx index 3c0aaae57d..4092108135 100644 --- a/tools/VInspector/VInspector_ItemSelectMgrSelectableObjectSet.cxx +++ b/tools/VInspector/VInspector_ItemSelectMgrSelectableObjectSet.cxx @@ -140,6 +140,19 @@ opencascade::handle > VInspector_ItemSelectMgrSelecta return aSet.BVH (aBVHSubset); } +// ======================================================================= +// function : GetStream +// purpose : +// ======================================================================= +void VInspector_ItemSelectMgrSelectableObjectSet::GetStream (Standard_OStream& theOStream) const +{ + SelectMgr_SelectableObjectSet aSet; + if (!GetSelectableObjectSet (aSet)) + return; + + aSet.DumpJson (theOStream); +} + // ======================================================================= // function : createChild // purpose : diff --git a/tools/VInspector/VInspector_ItemSelectMgrSelectableObjectSet.hxx b/tools/VInspector/VInspector_ItemSelectMgrSelectableObjectSet.hxx index 2fe94f6dd1..b312b99f94 100644 --- a/tools/VInspector/VInspector_ItemSelectMgrSelectableObjectSet.hxx +++ b/tools/VInspector/VInspector_ItemSelectMgrSelectableObjectSet.hxx @@ -58,6 +58,10 @@ public: //! Returns child BVH tree of the row opencascade::handle > GetBVHTree (const int theRow, TCollection_AsciiString& theName) 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. virtual void initItem() const Standard_OVERRIDE; diff --git a/tools/VInspector/VInspector_ItemSelectMgrSelectingVolumeManager.cxx b/tools/VInspector/VInspector_ItemSelectMgrSelectingVolumeManager.cxx index 26031aca73..80725372da 100644 --- a/tools/VInspector/VInspector_ItemSelectMgrSelectingVolumeManager.cxx +++ b/tools/VInspector/VInspector_ItemSelectMgrSelectingVolumeManager.cxx @@ -119,6 +119,19 @@ Standard_Boolean VInspector_ItemSelectMgrSelectingVolumeManager::GetViewerSelect return Standard_True; } +// ======================================================================= +// function : GetStream +// purpose : +// ======================================================================= +void VInspector_ItemSelectMgrSelectingVolumeManager::GetStream (Standard_OStream& theOStream) const +{ + SelectMgr_SelectingVolumeManager aVolumeManager; + if (!GetViewerSelector (aVolumeManager)) + return; + + aVolumeManager.DumpJson (theOStream); +} + // ======================================================================= // function : createChild // purpose : diff --git a/tools/VInspector/VInspector_ItemSelectMgrSelectingVolumeManager.hxx b/tools/VInspector/VInspector_ItemSelectMgrSelectingVolumeManager.hxx index d526bf829e..3c1eff6282 100644 --- a/tools/VInspector/VInspector_ItemSelectMgrSelectingVolumeManager.hxx +++ b/tools/VInspector/VInspector_ItemSelectMgrSelectingVolumeManager.hxx @@ -57,6 +57,10 @@ public: //! Returns frustum Frustum for row = 0, FrustumSet for row = 1 Handle(SelectMgr_BaseFrustum) GetFrustum (const int theRow) 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. virtual void initItem() const Standard_OVERRIDE; diff --git a/tools/VInspector/VInspector_ItemSelectMgrSelection.cxx b/tools/VInspector/VInspector_ItemSelectMgrSelection.cxx index 0836fe7417..e01c355aa0 100644 --- a/tools/VInspector/VInspector_ItemSelectMgrSelection.cxx +++ b/tools/VInspector/VInspector_ItemSelectMgrSelection.cxx @@ -38,6 +38,9 @@ int VInspector_ItemSelectMgrSelection::initRowCount() const { Handle(SelectMgr_Selection) aSelection = GetSelection(); + + if (aSelection.IsNull()) + return 0; #if OCC_VERSION_HEX < 0x070201 int aRows = 0; for (aSelection->Init(); aSelection->More(); aSelection->Next()) @@ -58,6 +61,9 @@ QVariant VInspector_ItemSelectMgrSelection::initValue (int theItemRole) const if (aParentValue.isValid()) return aParentValue; + if (GetSelection().IsNull()) + return QVariant(); + switch (theItemRole) { case Qt::DisplayRole: diff --git a/tools/VInspector/VInspector_ItemSelectMgrSensitiveEntity.cxx b/tools/VInspector/VInspector_ItemSelectMgrSensitiveEntity.cxx index 3dc5a08424..8ee5bbc9c0 100644 --- a/tools/VInspector/VInspector_ItemSelectMgrSensitiveEntity.cxx +++ b/tools/VInspector/VInspector_ItemSelectMgrSensitiveEntity.cxx @@ -123,20 +123,23 @@ void VInspector_ItemSelectMgrSensitiveEntity::Init() int aRowId = Row(); int aCurrentId = 0; -#if OCC_VERSION_HEX < 0x070201 - for (aSelection->Init(); aSelection->More(); aSelection->Next(), aCurrentId++) -#else - for (NCollection_Vector::Iterator aSelEntIter (aSelection->Entities()); aSelEntIter.More(); aSelEntIter.Next(), aCurrentId++) -#endif + if (!aSelection.IsNull()) { - if (aCurrentId != aRowId) - continue; -#if OCC_VERSION_HEX < 0x070201 - myEntity = aSelection->Sensitive(); -#else - myEntity = aSelEntIter.Value(); -#endif - break; + #if OCC_VERSION_HEX < 0x070201 + for (aSelection->Init(); aSelection->More(); aSelection->Next(), aCurrentId++) + #else + for (NCollection_Vector::Iterator aSelEntIter (aSelection->Entities()); aSelEntIter.More(); aSelEntIter.Next(), aCurrentId++) + #endif + { + if (aCurrentId != aRowId) + continue; + #if OCC_VERSION_HEX < 0x070201 + myEntity = aSelection->Sensitive(); + #else + myEntity = aSelEntIter.Value(); + #endif + break; + } } TreeModel_ItemBase::Init(); } @@ -152,6 +155,19 @@ void VInspector_ItemSelectMgrSensitiveEntity::Reset() myEntity = NULL; } +// ======================================================================= +// function : GetStream +// purpose : +// ======================================================================= +void VInspector_ItemSelectMgrSensitiveEntity::GetStream (Standard_OStream& theOStream) const +{ + Handle(SelectMgr_SensitiveEntity) anEntity = GetSensitiveEntity(); + if (anEntity.IsNull()) + return; + + anEntity->DumpJson (theOStream); +} + // ======================================================================= // function : initItem // purpose : diff --git a/tools/VInspector/VInspector_ItemSelectMgrSensitiveEntity.hxx b/tools/VInspector/VInspector_ItemSelectMgrSensitiveEntity.hxx index a8e55c0b3e..6ae54355a3 100644 --- a/tools/VInspector/VInspector_ItemSelectMgrSensitiveEntity.hxx +++ b/tools/VInspector/VInspector_ItemSelectMgrSensitiveEntity.hxx @@ -55,6 +55,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: //! Initialize the current item. It is empty because Reset() is also empty. diff --git a/tools/VInspector/VInspector_ItemSelectMgrViewerSelector.cxx b/tools/VInspector/VInspector_ItemSelectMgrViewerSelector.cxx index 964745e220..c1104b05a7 100644 --- a/tools/VInspector/VInspector_ItemSelectMgrViewerSelector.cxx +++ b/tools/VInspector/VInspector_ItemSelectMgrViewerSelector.cxx @@ -216,17 +216,16 @@ void VInspector_ItemSelectMgrViewerSelector::initItem() const } // ======================================================================= -// function : Dump +// function : GetStream // purpose : // ======================================================================= -Standard_Boolean VInspector_ItemSelectMgrViewerSelector::Dump (Standard_OStream& theOStream) const +void VInspector_ItemSelectMgrViewerSelector::GetStream (Standard_OStream& theOStream) const { Handle(SelectMgr_ViewerSelector) aViewerSelector = GetViewerSelector(); if (aViewerSelector.IsNull()) - return Standard_False; + return; aViewerSelector->DumpJson (theOStream); - return Standard_True; } // ======================================================================= diff --git a/tools/VInspector/VInspector_ItemSelectMgrViewerSelector.hxx b/tools/VInspector/VInspector_ItemSelectMgrViewerSelector.hxx index b460d8272b..f1509a7dac 100644 --- a/tools/VInspector/VInspector_ItemSelectMgrViewerSelector.hxx +++ b/tools/VInspector/VInspector_ItemSelectMgrViewerSelector.hxx @@ -95,8 +95,9 @@ protected: //! \return the value Standard_EXPORT virtual QVariant initValue (const int theItemRole) const Standard_OVERRIDE; - //! Dumps the content of me into the stream - virtual Standard_Boolean Dump (Standard_OStream& theOStream) 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: 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_Tools.cxx b/tools/VInspector/VInspector_Tools.cxx index c56f6065fd..93c4e08492 100644 --- a/tools/VInspector/VInspector_Tools.cxx +++ b/tools/VInspector/VInspector_Tools.cxx @@ -565,15 +565,15 @@ QVariant VInspector_Tools::ToVariant (const Select3D_BndBox3d& theBoundingBox) //function : CreateShape //purpose : //======================================================================= -TopoDS_Shape VInspector_Tools::CreateShape (const Select3D_BndBox3d& theBoundingBox) +Standard_Boolean VInspector_Tools::CreateShape (const Select3D_BndBox3d& theBoundingBox, TopoDS_Shape& theShape) { if (!theBoundingBox.IsValid()) - return TopoDS_Shape(); + return Standard_False; gp_Pnt aPntMin = gp_Pnt (theBoundingBox.CornerMin().x(), theBoundingBox.CornerMin().y(), theBoundingBox.CornerMin().z()); gp_Pnt aPntMax = gp_Pnt (theBoundingBox.CornerMax().x(), theBoundingBox.CornerMax().y(), theBoundingBox.CornerMax().z()); - return Convert_Tools::CreateBoxShape (aPntMin, aPntMax); + return Convert_Tools::CreateBoxShape (aPntMin, aPntMax, theShape); } //======================================================================= diff --git a/tools/VInspector/VInspector_Tools.hxx b/tools/VInspector/VInspector_Tools.hxx index a765ee2d3a..ea6ccaeca9 100644 --- a/tools/VInspector/VInspector_Tools.hxx +++ b/tools/VInspector/VInspector_Tools.hxx @@ -180,7 +180,7 @@ public: //! Creates box shape //! \param theBoundingBox box shape parameters //! \return created shape - Standard_EXPORT static TopoDS_Shape CreateShape (const Select3D_BndBox3d& theBoundingBox); + Standard_EXPORT static Standard_Boolean CreateShape (const Select3D_BndBox3d& theBoundingBox, TopoDS_Shape& theShape); //! Build string presentation of Graphic3D index buffer //! \param theIndexBuffer index buffer diff --git a/tools/VInspector/VInspector_Window.cxx b/tools/VInspector/VInspector_Window.cxx index c2bd8ed934..e57f627774 100644 --- a/tools/VInspector/VInspector_Window.cxx +++ b/tools/VInspector/VInspector_Window.cxx @@ -32,7 +32,6 @@ #include #include #include -#include #include #include @@ -255,6 +254,11 @@ void VInspector_Window::GetPreferences (TInspectorAPI_PreferencesDataMap& theIte { theItem.Bind (anItemsIt.key().toStdString().c_str(), anItemsIt.value().toStdString().c_str()); } + + anItems.clear(); + ViewControl_PropertyView::SaveState (myPropertyView, anItems, "property_view_parameters_"); + for (QMap::const_iterator anItemsIt = anItems.begin(); anItemsIt != anItems.end(); anItemsIt++) + theItem.Bind (anItemsIt.key().toStdString().c_str(), anItemsIt.value().toStdString().c_str()); } // ======================================================================= @@ -272,15 +276,20 @@ void VInspector_Window::SetPreferences (const TInspectorAPI_PreferencesDataMap& for (TInspectorAPI_IteratorOfPreferencesDataMap anItemIt (theItem); anItemIt.More(); anItemIt.Next()) { - if (anItemIt.Key().IsEqual ("geometry")) - myMainWindow->restoreState (TreeModel_Tools::ToByteArray (anItemIt.Value().ToCString())); - else if (TreeModel_Tools::RestoreState (myTreeView, anItemIt.Key().ToCString(), anItemIt.Value().ToCString())) + TCollection_AsciiString anItemKey = anItemIt.Key(); + TCollection_AsciiString anItemValue = anItemIt.Value(); + if (anItemKey.IsEqual ("geometry")) + myMainWindow->restoreState (TreeModel_Tools::ToByteArray (anItemValue.ToCString())); + else if (TreeModel_Tools::RestoreState (myTreeView, anItemKey.ToCString(), anItemValue.ToCString())) continue; - else if (TreeModel_Tools::RestoreState (myHistoryView, anItemIt.Key().ToCString(), anItemIt.Value().ToCString(), + else if (TreeModel_Tools::RestoreState (myHistoryView, anItemKey.ToCString(), anItemValue.ToCString(), "history_view_")) continue; - else if (View_PreviewParameters::RestoreState (myDisplayPreview->GetPreviewParameters(), anItemIt.Key().ToCString(), - anItemIt.Value().ToCString(), "preview_parameters_")) + else if (View_PreviewParameters::RestoreState (myDisplayPreview->GetPreviewParameters(), anItemKey.ToCString(), + anItemValue.ToCString(), "preview_parameters_")) + continue; + else if (ViewControl_PropertyView::RestoreState (myPropertyView, anItemKey.ToCString(), + anItemValue.ToCString(), "property_view_parameters_")) continue; } } @@ -425,12 +434,9 @@ NCollection_List VInspector_Window::GetSelectedShapes (const QMode // obtain selection from the property panel { - //QList aPropertyTables; - //myPropertyView->GetActiveTables (aPropertyTables); - //if (!aPropertyTables.isEmpty()) + //ViewControl_Table* aPropertyTable = myPropertyView->GetTable(); + //if (aPropertyTable->IsActive()) //{ - // ViewControl_Table* aFirstTable = aPropertyTables[0]; // TODO: implement for several tables - // Handle(Graphic3d_TransformPers) aSelectedPersistent = GetSelectedTransformPers(); QModelIndex anIndex = TreeModel_ModelBase::SingleSelected (myTreeView->selectionModel()->selectedIndexes(), 0); @@ -451,17 +457,12 @@ NCollection_List VInspector_Window::GetSelectedShapes (const QMode void VInspector_Window::GetSelectedPropertyPanelShapes (const TreeModel_ItemBasePtr& theTreeItem, NCollection_List& theShapes) { - QList aPropertyTables; - myPropertyView->GetActiveTables (aPropertyTables); - if (aPropertyTables.isEmpty()) - return; - - ViewControl_Table* aFirstTable = aPropertyTables[0]; // TODO: implement for several tables - if (!aFirstTable) + ViewControl_Table* aPropertyTable = myPropertyView->GetTable(); + if (!aPropertyTable->IsActive()) return; NCollection_List theSelPresentations; - aFirstTable->GetSelectedPresentations (theTreeItem, theSelPresentations); + aPropertyTable->GetSelectedPresentations (theTreeItem, theSelPresentations); for (NCollection_List::Iterator anIterator (theSelPresentations); anIterator.More(); anIterator.Next()) { @@ -470,7 +471,7 @@ void VInspector_Window::GetSelectedPropertyPanelShapes (const TreeModel_ItemBase theShapes.Append (aShapePrs->GetShape()); } - //QModelIndexList& thePropertyPanelIndices = aFirstTable->GetTableView()->selectionModel()->selectedIndexes(), + //QModelIndexList& thePropertyPanelIndices = aPropertyTable->GetTableView()->selectionModel()->selectedIndexes(), //QList anItems = TreeModel_ModelBase::GetSelectedItems (theTreeViewIndices); //NCollection_List aPropertyPresentations; @@ -768,26 +769,24 @@ void VInspector_Window::onPropertyViewSelectionChanged() if (!aTreeItemSelected) return; - QList aPropertyTables; - myPropertyView->GetActiveTables (aPropertyTables); - if (aPropertyTables.isEmpty()) + ViewControl_Table* aPropertyTable = myPropertyView->GetTable(); + if (!aPropertyTable->IsActive()) return; - ViewControl_Table* aFirstTable = aPropertyTables[0]; // TODO: implement for several tables NCollection_List aSelPresentations; - aFirstTable->GetSelectedPresentations (aTreeItemSelected, aSelPresentations); + aPropertyTable->GetSelectedPresentations (aTreeItemSelected, aSelPresentations); //Handle(TreeModel_ItemProperties) anItemProperties = aTreeItemSelected->GetProperties(); //QMap> aSelectedIndices; - //aFirstTable->GetSelectedIndices (aSelectedIndices); + //aPropertyTable->GetSelectedIndices (aSelectedIndices); - //ViewControl_TableModel* aTableModel = dynamic_cast(aFirstTable->GetTableView()->model()); + //ViewControl_TableModel* aTableModel = dynamic_cast(aPropertyTable->GetTableView()->model()); //ViewControl_TableModelValues* aTableValues = aTableModel->GetModelValues(); QStringList aPointers; - aFirstTable->GetSelectedPointers (aPointers); + aPropertyTable->GetSelectedPointers (aPointers); //NCollection_List aSelPresentations; /*for (QMap>::const_iterator aSelIt = aSelectedIndices.begin(); aSelIt != aSelectedIndices.end(); aSelIt++) @@ -815,7 +814,7 @@ void VInspector_Window::onPropertyViewSelectionChanged() //NCollection_List aSelectedShapes = GetSelectedShapes (aTreeViewSelected); //GetSelectedPropertyPanelShapes(aTreeViewSelected, - // aFirstTable->GetTableView()->selectionModel()->selectedIndexes(), + // aPropertyTable->GetTableView()->selectionModel()->selectedIndexes(), // aSelectedShapes); //updatePreviewPresentation(aSelectedShapes, aSelectedPersistent); @@ -845,11 +844,8 @@ void VInspector_Window::onTreeViewSelectionChanged (const QItemSelection&, return; NCollection_List aSelPresentations; - TreeModel_ItemStreamPtr aStreamParent = itemDynamicCast (aTreeItemSelected); - if (!aStreamParent) - return; - Handle(TreeModel_ItemProperties) anItemProperties = aStreamParent->Properties (); + Handle(TreeModel_ItemProperties) anItemProperties = aTreeItemSelected->Properties (); if (anItemProperties) anItemProperties->GetPresentations (-1, -1, aSelPresentations); //else @@ -1075,17 +1071,12 @@ void VInspector_Window::updatePropertyPanelBySelection() if (!anItemBase) return; - TreeModel_ItemStreamPtr aStreamItem = itemDynamicCast (anItemBase); - if (!aStreamItem) - return; - - Handle(TreeModel_ItemProperties) anItemProperties = aStreamItem->Properties (); - QList aTableValuesList; + Handle(TreeModel_ItemProperties) anItemProperties = anItemBase->Properties (); + ViewControl_TableModelValues* aTableValues = 0; if (!anItemProperties.IsNull()) { - ViewControl_TableModelValues* aTableValues = new ViewControl_TableModelValues(); + aTableValues = new ViewControl_TableModelValues(); aTableValues->SetProperties (anItemProperties); - aTableValuesList.append (aTableValues); } /*QItemSelectionModel* aModel = myTreeView->selectionModel(); @@ -1100,7 +1091,7 @@ void VInspector_Window::updatePropertyPanelBySelection() TreeModel_ItemBasePtr aSelectedItem = TreeModel_ModelBase::GetItemByIndex(aSelected.first()); VInspector_Tools::GetPropertyTableValues (aSelectedItem, myPaneCreators, aTableValues); }*/ - myPropertyView->Init (aTableValuesList); + myPropertyView->Init (aTableValues); } // ======================================================================= @@ -1231,14 +1222,43 @@ void VInspector_Window::selectTreeViewItems (const QStringList& thePointers) // function : createView // purpose : // ======================================================================= +#include Handle(AIS_InteractiveContext) VInspector_Window::createView() { // create two view windows Handle(AIS_InteractiveContext) aContext = View_Viewer::CreateStandardViewer(); Handle(AIS_Trihedron) aTrihedron = new AIS_Trihedron (new Geom_Axis2Placement (gp::XOY())); - aTrihedron->SetDatumDisplayMode (Prs3d_DM_Shaded); - aContext->Display (aTrihedron, Standard_True); + aTrihedron->SetSize (0.5); + //aTrihedron->SetDatumDisplayMode (Prs3d_DM_Shaded); + //aContext->Display (aTrihedron, Standard_True); + aContext->Display(aTrihedron, + 0 /*wireframe*/, + -1 /* selection mode */, + Standard_True /* update viewer*/, + Standard_True /* allow decomposition */, + AIS_DS_Displayed /* xdisplay status */); + aContext->Load (aTrihedron); + aContext->Activate (aTrihedron, AIS_TrihedronSelectionMode_Axes); + { + Handle(AIS_Trihedron) myTrihedron = aTrihedron; + myTrihedron->SetInfiniteState( Standard_True); + + Quantity_Color Col(193 / 255., 205 / 255., 193 / 255., Quantity_TOC_RGB); + myTrihedron->SetArrowColor(Col.Name()); + //myTrihedron->SetSize(myTrihedronSize); + Handle(Prs3d_Drawer) drawer = myTrihedron->Attributes(); + if (drawer->HasOwnDatumAspect()) { + Handle(Prs3d_DatumAspect) daspect = drawer->DatumAspect(); + daspect->FirstAxisAspect()->SetColor(Quantity_Color(1.0, 0.0, 0.0, Quantity_TOC_RGB)); + daspect->SecondAxisAspect()->SetColor(Quantity_Color(0.0, 1.0, 0.0, Quantity_TOC_RGB)); + daspect->ThirdAxisAspect()->SetColor(Quantity_Color(0.0, 0.0, 1.0, Quantity_TOC_RGB)); + + daspect->FirstAxisAspect()->SetWidth(3.0); + daspect->SecondAxisAspect()->SetWidth(3.0); + daspect->ThirdAxisAspect()->SetWidth(3.0); + } + } myViewWindow = new View_Window (0, aContext, false /*for opening several BREP files*/, true); myViewWindow->GetView()->SetPredefinedSize (VINSPECTOR_DEFAULT_VIEW_WIDTH, VINSPECTOR_DEFAULT_VIEW_HEIGHT); diff --git a/tools/View/View_DisplayPreview.cxx b/tools/View/View_DisplayPreview.cxx index 7e4395a7ab..24fc9079a5 100644 --- a/tools/View/View_DisplayPreview.cxx +++ b/tools/View/View_DisplayPreview.cxx @@ -30,10 +30,26 @@ #include #include #include +#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 +71,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 +85,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); + } } } @@ -117,9 +158,17 @@ void View_DisplayPreview::DisplayDefaultPreview() TopoDS_Compound aCompound; aBuilder.MakeCompound (aCompound); aBuilder.Add (aCompound, BRepBuilderAPI_MakeVertex (gp_Pnt(25., 10., 0.))); - aBuilder.Add (aCompound, BRepBuilderAPI_MakeEdge (gp_Pnt(20., 20., 0.), gp_Pnt(30., 20., 10.))); + BRepBuilderAPI_MakeEdge anEdgeBuilder (gp_Pnt(20., 20., 0.), gp_Pnt(30., 20., 10.)); + aBuilder.Add (aCompound, anEdgeBuilder); + + BRepBuilderAPI_MakeEdge anEdgeBuilder1 (gp_Pnt(10., 10., 0.), gp_Pnt(20., 10., 0.)); + BRepBuilderAPI_MakeEdge anEdgeBuilder2 (gp_Pnt(20., 10., 0.), gp_Pnt(20., 0., 0.)); + + aBuilder.Add (aCompound, BRepBuilderAPI_MakeWire (anEdgeBuilder1, anEdgeBuilder2)); //aBuilder.Add (aCompound, BRepBuilderAPI_MakeFace (gp_Pln (gp_Pnt (20., 30., 0.), gp_Dir (1., 0., 0.))).Face()); - aBuilder.Add (aCompound, Convert_Tools::CreateBoxShape (gp_Pnt(20., 40., 0.), gp_Pnt(30., 60., 10.))); + TopoDS_Shape aShape; + if (Convert_Tools::CreateBoxShape (gp_Pnt(20., 40., 0.), gp_Pnt(30., 60., 10.), aShape)) + aBuilder.Add (aCompound, aShape); Handle(AIS_Shape) aDefaultPreview = new AIS_Shape (aCompound); aDefaultPreview->SetAttributes (myPreviewParameters->GetDrawer()); 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..ccacc5fc64 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); @@ -94,10 +94,10 @@ bool View_PreviewParameters::RestoreState (View_PreviewParameters* theParameter const QString& theKey, const QString& theValue, const QString& thePrefix) { - //if (theKey == thePrefix + "has_point_aspect") // point parameters - //{ + if (theKey == thePrefix + "has_point_aspect") // point parameters + { // myDrawer->SetOwnPointAspect (theValue.toBool()); - //} + } //else if (theKey == thePrefix + "point_aspect") // point parameters //{ // Standard_SStream aStream; @@ -114,7 +114,7 @@ bool View_PreviewParameters::RestoreState (View_PreviewParameters* theParameter // aStream << theValue.ToString().ToStdString(); // myDrawer->ShadingAspect()->Init (aStream); //} - //else - // return false; + else + return false; return true; } diff --git a/tools/View/View_PreviewParameters.hxx b/tools/View/View_PreviewParameters.hxx index c5931bf666..78f9771f58 100644 --- a/tools/View/View_PreviewParameters.hxx +++ b/tools/View/View_PreviewParameters.hxx @@ -41,7 +41,7 @@ public: //! Returns main control const Handle(Prs3d_Drawer)& GetDrawer() const { return myDrawer; } - //! Save state of three view in a container in form: key, value. It saves: + //! Save state of three view in a container in form: key, value. It saves: //! - visibiblity of columns, //! - columns width //! \param theTreeView a view instance diff --git a/tools/View/View_ToolBar.cxx b/tools/View/View_ToolBar.cxx index 1ebff8d129..5eebbfb6e8 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 : @@ -165,6 +175,74 @@ bool View_ToolBar::IsActionChecked (const int theActionId) const return myActionsMap.contains (anActionId) ? myActionsMap[anActionId]->isChecked() : false; } +// ======================================================================= +// function : SaveState +// purpose : +// ======================================================================= +void View_ToolBar::SaveState (View_ToolBar* theParameters, + QMap& theItems, + const QString& thePrefix) +{ + //Handle(Prs3d_Drawer) aDrawer = theParameters->GetDrawer(); + + //Quantity_Color aColor = aDrawer->Color(); + //Standard_ShortReal aTransparency = aDrawer->Transparency(); + + //// point parameters + //{ + // Standard_Boolean anOwnPointAspect = aDrawer->HasOwnPointAspect(); + // Standard_SStream OS; + // if (anOwnPointAspect) + // myDrawer->PointAspect()->Dump (OS); + // TCollection_AsciiString aStream (OS.str().c_str()); + // theItems[thePrefix + "has_point_aspect"] = anOwnPointAspect; + // theItems[thePrefix + "point_aspect"] = aStream.ToCString(); + //} + //// shading parameters + //{ + // Standard_Boolean anOwnShadingAspect = aDrawer->HasOwnShadingAspect(); + // Standard_SStream OS; + // if (anOwnShadingAspect) + // myDrawer->ShadingAspect()->Dump (OS); + // TCollection_AsciiString aStream (OS.str().c_str()); + // theItems[thePrefix + "has_shading_aspect"] = anOwnShadingAspect; + // theItems[thePrefix + "shading_aspect"] = aStream.ToCString(); + //} +} + +// ======================================================================= +// function : RestoreState +// purpose : +// ======================================================================= +bool View_ToolBar::RestoreState (View_ToolBar* theParameters, + const QString& theKey, const QString& theValue, + const QString& thePrefix) +{ + //if (theKey == thePrefix + "has_point_aspect") // point parameters + //{ + // myDrawer->SetOwnPointAspect (theValue.toBool()); + //} + //else if (theKey == thePrefix + "point_aspect") // point parameters + //{ + // Standard_SStream aStream; + // aStream << theValue.ToString().ToStdString(); + // myDrawer->PointAspect()->Init (aStream); + //} + //else if (theKey == thePrefix + "has_shading_aspect") // shading parameters + //{ + // myDrawer->SetOwnShadingAspect (theValue.toBool()); + //} + //else if (theKey == thePrefix + "shading_aspect") // shading parameters + //{ + // Standard_SStream aStream; + // aStream << theValue.ToString().ToStdString(); + // myDrawer->ShadingAspect()->Init (aStream); + //} + //else + // return false; + return true; +} + // ======================================================================= // function : onActionClicked // purpose : diff --git a/tools/View/View_ToolBar.hxx b/tools/View/View_ToolBar.hxx index dca417ba05..31f3eba3ea 100644 --- a/tools/View/View_ToolBar.hxx +++ b/tools/View/View_ToolBar.hxx @@ -60,12 +60,35 @@ 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; //! \returns whether the action is checked(toggled). Acceptable only if the action is checkable. Standard_EXPORT bool IsActionChecked (const int theActionId) const; + //! Save state of three view in a container in form: key, value. It saves: + //! - visibiblity of columns, + //! - columns width + //! \param theTreeView a view instance + //! \param theItems [out] properties + //! \param thePrefix peference item prefix + Standard_EXPORT static void SaveState (View_ToolBar* theParameters, + QMap& theItems, + const QString& thePrefix = QString()); + //! Restore state of three view by a container + //! \param theTreeView a view instance + //! \param theKey property key + //! \param theValue property value + //! \param thePrefix peference item prefix + //! \return boolean value whether the property is applyed to the tree view + Standard_EXPORT static bool RestoreState (View_ToolBar* theParameters, + const QString& theKey, const QString& theValue, + const QString& thePrefix = QString()); + signals: //! Signal about click on action of View_ToolActionType enumeration diff --git a/tools/View/View_Tools.cxx b/tools/View/View_Tools.cxx index 49a5522460..69b5f710fc 100644 --- a/tools/View/View_Tools.cxx +++ b/tools/View/View_Tools.cxx @@ -18,6 +18,7 @@ #include #include #include +#include #include #include #include @@ -79,6 +80,7 @@ void View_Tools::SaveState (View_Window* theView, QMap& theIte theItems[thePrefix + "view_camera_direction"] = aCameraDirection.join (","); View_PreviewParameters::SaveState (theView->GetDisplayer()->GetDisplayPreview()->GetPreviewParameters(), theItems, "preview_parameters_"); + View_ToolBar::SaveState (theView->GetViewToolBar(), theItems, "view_toolbar_"); } // ======================================================================= @@ -106,5 +108,9 @@ bool View_Tools::RestoreState (View_Window* theView, const QString& theKey, cons { return true; } + else if (View_ToolBar::RestoreState (theView->GetViewToolBar(), theKey, theValue, "view_toolbar_")) + { + return true; + } return false; } diff --git a/tools/View/View_Viewer.cxx b/tools/View/View_Viewer.cxx index 04907e1479..03e8abe691 100644 --- a/tools/View/View_Viewer.cxx +++ b/tools/View/View_Viewer.cxx @@ -19,7 +19,7 @@ #include #include -//#define USE_CLIPPLANE +#define USE_CLIPPLANE #ifdef USE_CLIPPLANE #include diff --git a/tools/View/View_Widget.cxx b/tools/View/View_Widget.cxx index 26a4f65577..6659080eaf 100644 --- a/tools/View/View_Widget.cxx +++ b/tools/View/View_Widget.cxx @@ -523,8 +523,8 @@ void View_Widget::processLeftButtonUp (const int theFlags, const QPoint thePoint myDragMultiButtonDownX = 0; myDragMultiButtonDownY = 0; - myCurrentMode = View_CurrentAction3d_Nothing; - activateCursor (myCurrentMode); + //myCurrentMode = View_CurrentAction3d_Nothing; + //activateCursor (myCurrentMode); emit selectionChanged(); emit leftButtonUp(thePoint.x(), thePoint.y()); } diff --git a/tools/ViewControl/ViewControl_PropertyView.cxx b/tools/ViewControl/ViewControl_PropertyView.cxx index f2f20c9213..cea23c8714 100644 --- a/tools/ViewControl/ViewControl_PropertyView.cxx +++ b/tools/ViewControl/ViewControl_PropertyView.cxx @@ -21,6 +21,7 @@ #include #include +#include #include #include #include @@ -79,39 +80,38 @@ ViewControl_PropertyView::ViewControl_PropertyView (QWidget* theParent, const QS myAttributesStack->addWidget (myTableWidget); myAttributesStack->setCurrentWidget (myEmptyWidget); + + // create table + ViewControl_Table* aTable = new ViewControl_Table (myMainWidget); + ViewControl_TableModel* aModel = new ViewControl_TableModel(aTable->GetTableView()); + aTable->SetModel (aModel); + + connect (aTable->GetTableView()->selectionModel(), + SIGNAL (selectionChanged (const QItemSelection&, const QItemSelection&)), + this, SLOT(onTableSelectionChanged (const QItemSelection&, const QItemSelection&))); + + connect (aModel, SIGNAL (dataChanged(const QModelIndex&, const QModelIndex&, const QVector&)), + this, SIGNAL (propertyViewDataChanged())); + + myTableWidgetLayout->addWidget (aTable->GetControl()); + myTable = aTable; } // ======================================================================= // function : Init // purpose : // ======================================================================= -void ViewControl_PropertyView::Init (const QList& theTableValues) +void ViewControl_PropertyView::Init (ViewControl_TableModelValues* theTableValues) { - for (int aTableId = 0; aTableId < theTableValues.size(); aTableId++) + ViewControl_Table* aTable = GetTable(); + if (theTableValues) { - ViewControl_TableModelValues* aValues = theTableValues[aTableId]; - - ViewControl_Table* aTable = findTable (aTableId); - - aTable->Init (aValues); + aTable->Init (theTableValues); ViewControl_Tools::SetDefaultHeaderSections (aTable->GetTableView(), Qt::Horizontal); - - aTable->SetActive (true); - } - // hide not used tables - for (int aTableId = theTableValues.size(); aTableId < myTables.size(); aTableId++) - { - ViewControl_Table* aTable = findTable (aTableId, false); - if (!aTable) - continue; - - ViewControl_TableModel* aModel = dynamic_cast (aTable->GetTableView()->model()); - aModel->SetModelValues (0); - - aTable->SetActive (false); } + aTable->SetActive (theTableValues); - if (theTableValues.size() > 0) + if (theTableValues) myAttributesStack->setCurrentWidget (myTableWidget); else myAttributesStack->setCurrentWidget (myEmptyWidget); @@ -126,17 +126,12 @@ void ViewControl_PropertyView::Init (QWidget*) } // ======================================================================= -// function : GetActiveTables +// function : GetTable // purpose : // ======================================================================= -void ViewControl_PropertyView::GetActiveTables (QList& theTables) +ViewControl_Table* ViewControl_PropertyView::GetTable() { - for (int aTableId = 0; aTableId < myTables.size(); aTableId++) - { - ViewControl_Table* aTable = findTable (aTableId, false); - if (aTable && aTable->IsActive()) - theTables.append (aTable); - } + return myTable; } // ======================================================================= @@ -149,12 +144,10 @@ void ViewControl_PropertyView::ClearActiveTablesSelection() myOwnSelectionChangeBlocked = true; QList aTables; - for (int aTableId = 0; aTableId < myTables.size(); aTableId++) - { - ViewControl_Table* aTable = findTable (aTableId, false); - if (aTable && aTable->IsActive()) - aTable->GetTableView()->selectionModel()->clearSelection(); - } + ViewControl_Table* aTable = GetTable(); + if (aTable->IsActive()) + aTable->GetTableView()->selectionModel()->clearSelection(); + myOwnSelectionChangeBlocked = aWasBlocked; } @@ -164,12 +157,9 @@ void ViewControl_PropertyView::ClearActiveTablesSelection() // ======================================================================= void ViewControl_PropertyView::Clear() { - for (int aTableId = 0; aTableId < myTables.size(); aTableId++) + ViewControl_Table* aTable = GetTable(); + if (aTable->IsActive()) { - ViewControl_Table* aTable = findTable (aTableId, false); - if (!aTable) - continue; - ViewControl_TableModel* aModel = dynamic_cast (aTable->GetTableView()->model()); aModel->SetModelValues (0); @@ -179,31 +169,37 @@ void ViewControl_PropertyView::Clear() } // ======================================================================= -// function : findTable +// function : SaveState // purpose : // ======================================================================= -ViewControl_Table* ViewControl_PropertyView::findTable (const int theTableId, const bool isToCreate) +void ViewControl_PropertyView::SaveState (ViewControl_PropertyView* thePropertyView, + QMap& theItems, + const QString& thePrefix) { - if (!isToCreate && theTableId >= myTables.size()) - return 0; - - if (theTableId < myTables.size()) - return myTables[theTableId]; - - ViewControl_Table* aTable = new ViewControl_Table (myMainWidget); - ViewControl_TableModel* aModel = new ViewControl_TableModel(aTable->GetTableView()); - aTable->SetModel (aModel); - - - connect (aTable->GetTableView()->selectionModel(), - SIGNAL (selectionChanged (const QItemSelection&, const QItemSelection&)), - this, SLOT(onTableSelectionChanged (const QItemSelection&, const QItemSelection&))); - - myTableWidgetLayout->addWidget (aTable->GetControl()); - - myTables.insert (theTableId, aTable); + ViewControl_Table* aTable = thePropertyView->GetTable(); + int aColumnWidth = aTable->GetTableView()->columnWidth (0); + theItems[thePrefix + "column_width_0"] = QString::number (aColumnWidth); +} - return myTables[theTableId]; +// ======================================================================= +// function : RestoreState +// purpose : +// ======================================================================= +bool ViewControl_PropertyView::RestoreState (ViewControl_PropertyView* thePropertyView, + const QString& theKey, + const QString& theValue, + const QString& thePrefix) +{ + if (theKey == thePrefix + "column_width_0") + { + bool isOk; + int aWidth = theValue.toInt (&isOk); + if (isOk) + thePropertyView->GetTable()->GetTableView()->horizontalHeader()->setDefaultSectionSize (aWidth); + } + else + return false; + return true; } // ======================================================================= diff --git a/tools/ViewControl/ViewControl_PropertyView.hxx b/tools/ViewControl/ViewControl_PropertyView.hxx index 2cb6f75377..f3677b7778 100644 --- a/tools/ViewControl/ViewControl_PropertyView.hxx +++ b/tools/ViewControl/ViewControl_PropertyView.hxx @@ -49,7 +49,7 @@ public: //! Fills the view content with values. Number of visible tables is size of container, //! Each element of container is values of the corresponded table //! \param theTableValues values - Standard_EXPORT void Init (const QList& theTableValues); + Standard_EXPORT void Init (ViewControl_TableModelValues* theTableValues); //! Fills the view content with the parameter custom widget. //! \param theWidget control @@ -61,28 +61,44 @@ public: //! \return the text edit control QWidget* GetControl() const { return myMainWidget; } - //! Returns container of active tables - //! \param theTables [out] modified container - Standard_EXPORT void GetActiveTables (QList& theTables); + //! Returns container an active table or NULL + Standard_EXPORT ViewControl_Table* GetTable(); //! Clears selection in active tables Standard_EXPORT void ClearActiveTablesSelection(); + //! Save state of three view in a container in form: key, value. It saves: + //! - visibiblity of columns, + //! - columns width + //! \param theTreeView a view instance + //! \param theItems [out] properties + //! \param thePrefix peference item prefix + Standard_EXPORT static void SaveState (ViewControl_PropertyView* theParameters, + QMap& theItems, + const QString& thePrefix = QString()); + //! Restore state of three view by a container + //! \param theTreeView a view instance + //! \param theKey property key + //! \param theValue property value + //! \param thePrefix peference item prefix + //! \return boolean value whether the property is applyed to the tree view + Standard_EXPORT static bool RestoreState (ViewControl_PropertyView* theParameters, + const QString& theKey, const QString& theValue, + const QString& thePrefix = QString()); + signals: + //! Signal about selection change in property view table void propertyViewSelectionChanged(); + //! Signal about data change in property view table + void propertyViewDataChanged(); + protected slots: //! Emits signal about selection is changed //! \param theSelected container of selected table cells //! \param theDeselected container of selected table cells void onTableSelectionChanged (const QItemSelection& theSelected, const QItemSelection& theDeselected); -protected: - //! Returns table instance or create if it was not created ealier - //! \param theTableId an index in internal container of tables - //! \param isToCreate if true, the table is created if not exists - ViewControl_Table* findTable (const int theTableId, const bool isToCreate = true); - private: bool myOwnSelectionChangeBlocked; //! blocking emit of selection changed signal @@ -93,7 +109,7 @@ private: QWidget* myTableWidget; //!< widget of tables in vertical layout QVBoxLayout* myTableWidgetLayout; //! main view layout where tables or custom widgets are presented - QList myTables; //!< table view, shown only first tables filled in Init method + ViewControl_Table* myTable; //!< table view, shown only first tables filled in Init method QWidget* myCustomWidget; //!< custom view widget }; #endif diff --git a/tools/ViewControl/ViewControl_Table.cxx b/tools/ViewControl/ViewControl_Table.cxx index 1ee8f1c7e9..b3dc851561 100644 --- a/tools/ViewControl/ViewControl_Table.cxx +++ b/tools/ViewControl/ViewControl_Table.cxx @@ -55,6 +55,9 @@ ViewControl_Table::ViewControl_Table (QWidget* theParent) int aDefCellSize = aVHeader->minimumSectionSize(); aVHeader->setDefaultSectionSize (aDefCellSize); + connect (myTableView->horizontalHeader(), SIGNAL (sectionResized (int, int, int)), + this, SLOT(onHeaderResized (int, int, int))); + aLayout->addWidget (myTableView); } @@ -87,12 +90,10 @@ void ViewControl_Table::Init (ViewControl_TableModelValues* theModelValues) ViewControl_TableItemDelegate* aDelegate = dynamic_cast(myTableView->itemDelegate()); aDelegate->SetModelValues (theModelValues); - int aSectionSize; myTableView->horizontalHeader()->setVisible (theModelValues->IsHeaderVisible (Qt::Horizontal)); - if (theModelValues->GetDefaultSectionSize (Qt::Horizontal, aSectionSize) ) - myTableView->horizontalHeader()->setDefaultSectionSize (aSectionSize); myTableView->verticalHeader()->setVisible (theModelValues->IsHeaderVisible (Qt::Vertical)); + int aSectionSize; if (theModelValues->GetDefaultSectionSize (Qt::Vertical, aSectionSize) ) { myTableView->verticalHeader()->setDefaultSectionSize (aSectionSize); @@ -197,4 +198,17 @@ void ViewControl_Table::GetSelectedPointers (QStringList& thePointers) const thePointers.append (aData); } } -} \ No newline at end of file +} + +// ======================================================================= +// function : onHeaderResized +// purpose : +// ======================================================================= + +void ViewControl_Table::onHeaderResized (int theSectionId, int, int) +{ + if (theSectionId != 0) + return; + + myTableView->horizontalHeader()->setDefaultSectionSize (myTableView->columnWidth (theSectionId)); +} diff --git a/tools/ViewControl/ViewControl_Table.hxx b/tools/ViewControl/ViewControl_Table.hxx index 3c7611ea51..ce54db27ce 100644 --- a/tools/ViewControl/ViewControl_Table.hxx +++ b/tools/ViewControl/ViewControl_Table.hxx @@ -86,6 +86,9 @@ public: //! \return string value Standard_EXPORT static QString SeparatorData(); +protected slots: + void onHeaderResized (int theSectionId, int, int); + private: bool myIsActive; //!< true if the table is used in property view and visible diff --git a/tools/ViewControl/ViewControl_TableModel.cxx b/tools/ViewControl/ViewControl_TableModel.cxx index c3b43209b8..c92865da24 100644 --- a/tools/ViewControl/ViewControl_TableModel.cxx +++ b/tools/ViewControl/ViewControl_TableModel.cxx @@ -74,5 +74,9 @@ bool ViewControl_TableModel::setData (const QModelIndex& theIndex, const QVarian return false; int aRow = theIndex.row(), aColumn = theIndex.column(); - return myModelValues->SetData (aRow, aColumn, theValue, theRole); + bool aResult = myModelValues->SetData (aRow, aColumn, theValue, theRole); + + emit dataChanged (theIndex, theIndex); + + return aResult; } diff --git a/tools/ViewControl/ViewControl_TableModelValues.cxx b/tools/ViewControl/ViewControl_TableModelValues.cxx index 3d12d42db5..7f107fabf1 100644 --- a/tools/ViewControl/ViewControl_TableModelValues.cxx +++ b/tools/ViewControl/ViewControl_TableModelValues.cxx @@ -85,8 +85,8 @@ QVariant ViewControl_TableModelValues::Data (const int theRow, const int theColu bool ViewControl_TableModelValues::SetData (const int theRow, const int theColumn, const QVariant& theValue, int) { - //if (!GetProperties().IsNull()) - // return GetProperties()->SetTableData (theRow, theColumn, theValue); + if (!GetProperties().IsNull()) + return GetProperties()->SetData (theRow, theColumn, theValue); return false; } @@ -113,10 +113,10 @@ QVariant ViewControl_TableModelValues::HeaderData (int theSection, Qt::Orientati // ======================================================================= ViewControl_EditType ViewControl_TableModelValues::GetEditType (const int theRow, const int theColumn) const { - //if (!GetProperties().IsNull()) - //{ - // return GetProperties()->GetTableEditType (theRow, theColumn); - //} + if (!GetProperties().IsNull()) + { + return GetProperties()->GetEditType (theRow, theColumn); + } return ViewControl_EditType_None; } -- 2.39.5