//! @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;
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);
+}
//=======================================================================
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;
+}
//! 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.
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;
+}
//! 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)
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);
+}
//! 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
{
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);
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);
}
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 :
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);
+}
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.
//! 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
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());
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<Standard_Real> myMatricesD;
+ mutable TransformMatrices<Standard_ShortReal> myMatricesF;
+
+ mutable Graphic3d_WorldViewProjState myWorldViewProjState;*/
+}
//! 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:
// =======================================================================
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);
? (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);
+}
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
}
}
}
+
+// =======================================================================
+// 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<const Graphic3d_CStructure*> 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]);
+}
//! Returns indexed map of always rendered structures.
const NCollection_IndexedMap<const Graphic3d_CStructure*>& 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.
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);
+}
//! 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.
// =======================================================================
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)
#include <Graphic3d_LightSet.hxx>
#include <Graphic3d_PolygonOffset.hxx>
#include <Precision.hxx>
+#include <Standard_Dump.hxx>
#include <TCollection_AsciiString.hxx>
enum Graphic3d_ZLayerSetting
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
void Message_AttributeStream::SetStream (const Standard_SStream& theStream)
{
+ myStream.str ("");
+
TCollection_AsciiString aStreamStr (theStream.str().c_str());
myStream << aStreamStr;
}
#include <NCollection_Map.hxx>
#include <Precision.hxx>
+#include <Standard_Dump.hxx>
IMPLEMENT_STANDARD_RTTIEXT(Message_Report,Standard_Transient)
"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;
+}
//! 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)
#define _NCollection_Buffer_HeaderFile
#include <NCollection_BaseAllocator.hxx>
+#include <Standard_Dump.hxx>
#include <Standard_Transient.hxx>
//! Low-level buffer object.
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
#include <cstring>
#include <cmath>
#include <NCollection_Vec2.hxx>
+#include <Standard_Dump.hxx>
//! Auxiliary macros to define couple of similar access components as vector methods
#define NCOLLECTION_VEC_COMPONENTS_3D(theX, theY, theZ) \
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
#define _NCollection_Vec4_H__
#include <NCollection_Vec3.hxx>
+#include <Standard_Dump.hxx>
//! Generic 4-components vector.
//! To be used as RGBA color vector or XYZW 3D-point with special W-component
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
// function : RenderCapping
// purpose :
// =======================================================================
+#include <Message_Alerts.hxx>
+#include <Message_PerfMeter.hxx>
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())
{
{
// 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)
{
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());
}
//=======================================================================
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;
+}
//! 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.
//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;
}
//! 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)); }
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)
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);
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:
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());
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:
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())
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:
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);
}
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:
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
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:
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
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:
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);
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:
//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);
}
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:
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);
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:
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());
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:
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)
#include <gp_Pnt.hxx>
#include <TColgp_HArray1OfPnt.hxx>
#include <SelectBasics_PickResult.hxx>
+#include <Standard_Dump.hxx>
class Bnd_Box;
class gp_Pnt;
//! Ax + By + Cz + D = 0) to the given vector
virtual void GetPlanes (NCollection_Vector<NCollection_Vec4<Standard_Real> >& 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
};
{
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);
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<Handle(SelectMgr_SelectableObject)>::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);
+}
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.
// commercial license or contractual agreement.
#include <SelectMgr_SelectingVolumeManager.hxx>
+#include <Standard_Dump.hxx>
//=======================================================================
// function : SelectMgr_SelectingVolumeManager
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);
+}
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
{
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);
}
//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);
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());
}
// 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 << "\": {";
}
// =======================================================================
// =======================================================================
Standard_DumpSentry::~Standard_DumpSentry()
{
- (*myOStream) << "}";
+ //(*myOStream) << "}";
}
// =======================================================================
Standard_SStream aStream;
aStream << theOStream.rdbuf();
TCollection_AsciiString aStreamStr = Standard_Dump::Text (aStream);
- if (!aStreamStr.EndsWith ("{"))
+ if (!aStreamStr.IsEmpty() && !aStreamStr.EndsWith ("{"))
theOStream << ", ";
}
//purpose :
//=======================================================================
void Standard_Dump::DumpKeyToClass (Standard_OStream& theOStream,
- const char* theKey,
+ const TCollection_AsciiString& theKey,
const TCollection_AsciiString& theField)
{
AddValuesSeparator (theOStream);
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();
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)
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;
}
// =======================================================================
// 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;
}
// SplitJson
// ----------------------------------------------------------------------------
Standard_Boolean Standard_Dump::SplitJson (const TCollection_AsciiString& theStreamStr,
- NCollection_IndexedDataMap<TCollection_AsciiString, TCollection_AsciiString>& theValues)
+ NCollection_IndexedDataMap<TCollection_AsciiString, Standard_DumpValue>& theKeyToValues)
{
Standard_Integer /*anIndex = 1, */aNextIndex = 1;
while (aNextIndex < theStreamStr.Length())
{
case Standard_JsonKey_Quote:
{
- aProcessed = splitKeyToValue (theStreamStr, aNextIndex/*anIndex*/, aNextIndex, theValues);
+ aProcessed = splitKeyToValue (theStreamStr, aNextIndex/*anIndex*/, aNextIndex, theKeyToValues);
//anIndex = aNextIndex;
}
break;
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));
return Standard_True;
}
-// ----------------------------------------------------------------------------
-// JoinJson
-// ----------------------------------------------------------------------------
-void Standard_Dump::JoinJson (Standard_OStream& theOStream,
- const NCollection_IndexedDataMap<TCollection_AsciiString, TCollection_AsciiString>& theValues)
-{
-
-}
-
// ----------------------------------------------------------------------------
// HierarchicalValueIndices
// ----------------------------------------------------------------------------
Standard_Boolean Standard_Dump::splitKeyToValue (const TCollection_AsciiString& theStreamStr,
Standard_Integer theStartIndex,
Standard_Integer& theNextIndex,
- NCollection_IndexedDataMap<TCollection_AsciiString, TCollection_AsciiString>& theValues)
+ NCollection_IndexedDataMap<TCollection_AsciiString, Standard_DumpValue>& theValues)
{
// find key value: "key"
Standard_Integer aStartIndex = theStartIndex;
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;
//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;
aSplitKey = aSplitKey + anIndexedSuffix;
}
- theValues.Add (aSplitKey, aSplitValue);
+ theValues.Add (aSplitKey, Standard_DumpValue (aSplitValue, aStartIndex));
return Standard_True;
}
//! 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.
//! 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 << "\""; \
}
//! 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) << "\""; \
}
//! 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.
//! 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.
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
{
//! 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<TCollection_AsciiString, TCollection_AsciiString>& 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<TCollection_AsciiString, TCollection_AsciiString>& theValues);
+ NCollection_IndexedDataMap<TCollection_AsciiString, Standard_DumpValue>& theKeyToValues);
//! Returns container of indices in values, that has hierarchical value
Standard_EXPORT static NCollection_List<Standard_Integer> HierarchicalValueIndices (
//! @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"
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
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
Standard_EXPORT static Standard_Boolean splitKeyToValue (const TCollection_AsciiString& theStreamStr,
Standard_Integer theStartIndex,
Standard_Integer& theNextIndex,
- NCollection_IndexedDataMap<TCollection_AsciiString, TCollection_AsciiString>& theValues);
+ NCollection_IndexedDataMap<TCollection_AsciiString, Standard_DumpValue>& theValues);
//! Returns key of json in the index position. Incement the index position to the next symbol in the row
{
OCCT_DUMP_CLASS_BEGIN (theOStream, StdSelect_Shape);
+ OCCT_DUMP_BASE_CLASS (theOStream, theDepth, PrsMgr_PresentableObject);
+
OCCT_DUMP_FIELD_VALUES_DUMPED (theOStream, theDepth, &mysh);
}
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)
+ }
+}
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:
{
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);
+ //}
}
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);
+}
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.
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;
}
//! 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:
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;
}
//! 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:
}
-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;
}
//! 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:
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;
}
//! 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:
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;
}
//! 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:
//=======================================================================
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;
+}
//! 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:
//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<TCollection_AsciiString, TCollection_AsciiString> 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<TCollection_AsciiString> 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;
}
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:
// commercial license or contractual agreement.
#include <inspector/Convert_Tools.hxx>
+#include <inspector/Convert_TransientShape.hxx>
+#include <AIS_Plane.hxx>
+#include <AIS_Shape.hxx>
+#include <Geom_Plane.hxx>
+#include <Prs3d_PlaneAspect.hxx>
#include <TColgp_Array1OfPnt.hxx>
#include <Standard_Dump.hxx>
#include <BRep_Builder.hxx>
//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<Handle(Standard_Transient)>& 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);
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));
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();
TopoDS_Compound aCompound;
aBuilder.MakeCompound (aCompound);
aBuilder.Add (aCompound, BRepBuilderAPI_MakeVertex (thePntMin));
- return aCompound;
+ theShape = aCompound;
+ return Standard_True;
}
if (aThinOnX || aThinOnY || aThinOnZ)
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<Handle(Standard_Transient)>& 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<Handle(Standard_Transient)>& 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);
+}
#include <gp_XYZ.hxx>
#include <Bnd_Box.hxx>
#include <Bnd_OBB.hxx>
+#include <NCollection_List.hxx>
+#include <Quantity_Color.hxx>
#include <Standard.hxx>
#include <Standard_Macro.hxx>
#include <TColgp_HArray1OfPnt.hxx>
#include <TCollection_AsciiString.hxx>
#include <TopLoc_Location.hxx>
#include <TopoDS_Shape.hxx>
+#include <Standard_SStream.hxx>
#include <Standard_WarningsDisable.hxx>
#include <QString>
#include <QVariant>
#include <Standard_WarningsRestore.hxx>
+class Geom_Plane;
class Geom_Transformation;
//! \class Convert_Tools
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<Handle(Standard_Transient)>& 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<Handle(Standard_Transient)>& 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<Handle(Standard_Transient)>& thePresentations);
};
#include <Message_AlertExtended.hxx>
+#include <BRepBuilderAPI_MakeEdge.hxx>
+#include <Quantity_Color.hxx>
+#include <Quantity_ColorRGBA.hxx>
#include <TCollection_AsciiString.hxx>
#include <TopoDS_AlertAttribute.hxx>
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.));
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
}
// =======================================================================
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;
}
// =======================================================================
}
}
- /*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();
}
//! \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; }
}
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);
+}
//! 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.
if (!anAlertItem)
return TopoDS_Shape();
- if (!anAlertItem->GetCustomShape().IsNull())
+ /*if (!anAlertItem->GetCustomShape().IsNull())
return anAlertItem->GetCustomShape();
Handle(Message_Alert) anAlert = anAlertItem->GetAlert();
Handle(TopoDS_AlertAttribute) aShapeAttribute = Handle(TopoDS_AlertAttribute)::DownCast (anAlertExtended->Attribute());
if (!aShapeAttribute.IsNull())
return aShapeAttribute->GetShape();
-
+ */
return TopoDS_Shape();
}
#include <inspector/MessageModel_TreeModel.hxx>
#include <inspector/TreeModel_ContextMenu.hxx>
-#include <inspector/TreeModel_ItemStream.hxx>
#include <inspector/TreeModel_Tools.hxx>
#include <inspector/ViewControl_PropertyView.hxx>
#include <inspector/ViewControl_TableModelValues.hxx>
#include <inspector/ViewControl_TreeView.hxx>
-#include <inspector/Convert_TransientShape.hxx>
+#include <inspector/Convert_Tools.hxx>
+#include <inspector/View_DisplayPreview.hxx >
#include <inspector/View_Tools.hxx>
#include <inspector/View_Viewer.hxx>
#include <inspector/View_Widget.hxx>
MessageView_Window::MessageView_Window (QWidget* theParent)
: QObject (theParent)
{
+ myDisplayPreview = new View_DisplayPreview();
+
myMainWindow = new QMainWindow (theParent);
myTreeView = new ViewControl_TreeView (myMainWindow);
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);
if (!aContext.IsNull())
{
myViewWindow->SetContext (View_ContextType_External, aContext);
+ myViewWindow->GetViewToolBar()->SetCurrentContextType (View_ContextType_External);
}
if (!aViewCamera.IsNull())
}
// =======================================================================
-// function : onTreeViewSelectionChanged
+// function : onTreeViewVisibilityClicked
// purpose :
// =======================================================================
void MessageView_Window::onTreeViewVisibilityClicked(const QModelIndex& theIndex)
return;
updatePropertyPanelBySelection();
-
- NCollection_List<Handle(Standard_Transient)> 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<TreeModel_ItemStream> (anItemBase);
- if (!aStreamParent)
- return;
-
- Handle(TreeModel_ItemProperties) anItemProperties = aStreamParent->Properties ();
- if (anItemProperties)
- anItemProperties->GetPresentations (-1, -1, aPresentations);
-
- MessageModel_ItemAlertPtr anAlertItem = itemDynamicCast<MessageModel_ItemAlert>(anItemBase);
- if (!anAlertItem)
- continue;
- anAlertItem->GetPresentations (aPresentations);
- }
- updatePreviewPresentation (aPresentations);
+ updatePreviewPresentation();
}
// =======================================================================
if (!anAlertItem)
return;
- QList<ViewControl_Table*> 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<int, QList<int>> aSelectedIndices;
- aFirstTable->GetSelectedIndices (aSelectedIndices);
+ aPropertyTable->GetSelectedIndices (aSelectedIndices);
// clear presentation if selection is empty
MessageModel_TreeModel* aTreeModel = dynamic_cast<MessageModel_TreeModel*> (myTreeView->model());
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;
}*/
}
+// =======================================================================
+// 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 :
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 :
MessageModel_Tools::GetPropertyTableValues (anItemBase, aTableValues);
myPropertyView->Init (aTableValues);*/
- QList<ViewControl_TableModelValues*> 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_ItemStream> (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<Handle(Standard_Transient)>& thePresentations)
+void MessageView_Window::updatePreviewPresentation()
{
Handle(AIS_InteractiveContext) aContext = myViewWindow->GetViewToolBar()->GetCurrentContext();
if (aContext.IsNull())
return;
- if (!myPreviewPresentations.IsEmpty())
+ NCollection_List<Handle(Standard_Transient)> aPresentations;
+ MessageModel_ItemRootPtr aRootItem;
+ QModelIndexList aSelectedIndices = myTreeView->selectionModel()->selectedIndexes();
+ for (QModelIndexList::const_iterator aSelIt = aSelectedIndices.begin(); aSelIt != aSelectedIndices.end(); aSelIt++)
{
- for (NCollection_List<Handle(Standard_Transient)>::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<Handle(Standard_Transient)>::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<MessageModel_ItemAlert>(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);
}
class View_Window;
+class View_DisplayPreview;
class ViewControl_PropertyView;
class MessageModel_ReportCallBack;
//! \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();
//! 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<Handle(Standard_Transient)>& thePresentations);
+ void updatePreviewPresentation();
private:
QMainWindow* myMainWindow; //!< main control, parent for all MessageView controls
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
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<Handle(Standard_Transient)> myPreviewPresentations;
};
#endif
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";
TKBRep
TKTopAlgo
TKPrim
+TKV3d
// commercial license or contractual agreement.
#include <inspector/TreeModel_ItemBase.hxx>
+#include <inspector/TreeModel_ItemProperties.hxx>
#include <inspector/TreeModel_ItemRole.hxx>
#include <inspector/TreeModel_ItemStream.hxx>
anItem->Reset();
}
m_bInitialized = false;
+ if (!myProperties.IsNull())
+ {
+ myProperties->Reset();
+ //myProperties = 0;
+ }
myCachedValues.clear();
}
{
m_bInitialized = true;
- NCollection_List<Standard_Integer> aHierarchicalValues;
+ //NCollection_List<Standard_Integer> aHierarchicalValues;
+ int aStreamChildrenCount = 0;
if (Column() == 0)
{
- NCollection_IndexedDataMap<TCollection_AsciiString, TCollection_AsciiString> aValues;
+ //NCollection_IndexedDataMap<TCollection_AsciiString, TCollection_AsciiString> 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();
}
// =======================================================================
#include <Standard_WarningsRestore.hxx>
class TreeModel_ItemBase;
+class TreeModel_ItemProperties;
typedef QExplicitlySharedDataPointer<TreeModel_ItemBase> TreeModel_ItemBasePtr;
//! \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
//! 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
//! \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<int, int>, TreeModel_ItemBasePtr > PositionToItemHash;
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
};
// commercial license or contractual agreement.
#include <inspector/TreeModel_ItemProperties.hxx>
+#include <inspector/TreeModel_ItemStream.hxx>
+#include <inspector/Convert_Tools.hxx>
#include <inspector/Convert_TransientShape.hxx>
#include <BRepBuilderAPI_MakeVertex.hxx>
// purpose :
// =======================================================================
-void TreeModel_ItemProperties::Init (const TCollection_AsciiString& theStreamValue)
+void TreeModel_ItemProperties::Init ()
{
- NCollection_IndexedDataMap<TCollection_AsciiString, TCollection_AsciiString> aValues;
- if (!Standard_Dump::SplitJson (theStreamValue, aValues))
- return;
+ Standard_SStream aStream;
+ Item()->GetStream (aStream);
+
+ NCollection_IndexedDataMap<TCollection_AsciiString, Standard_DumpValue> aValues;
+ TCollection_AsciiString aStreamText = Standard_Dump::Text (aStream);
+ Standard_Dump::SplitJson (aStreamText, aValues);
+
+ TreeModel_ItemStreamPtr aStreamParent = itemDynamicCast<TreeModel_ItemStream>(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);
+ //}
}
// =======================================================================
// =======================================================================
void TreeModel_ItemProperties::Reset()
{
+ myKey = "";
+ myStreamValue = Standard_DumpValue();
+
+ myChildren.Clear();
myValues.Clear();
}
int TreeModel_ItemProperties::RowCount() const
{
- return myValues.Size();
+ return Values().Size();
}
// =======================================================================
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<TreeModel_ItemStream>(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 :
if (theRow < 0) // full presentation
{
+ Standard_SStream aStream;
+ Item()->GetStream (aStream);
+
+ Convert_Tools::ConvertStreamToPresentations (aStream, 1, -1, thePresentations);
return;
}
NCollection_IndexedDataMap<TCollection_AsciiString, TCollection_AsciiString> 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
//{
// 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);
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();
+}
#define TreeModel_ItemProperties_H
#include <Standard.hxx>
+#include <Standard_Dump.hxx>
#include <Standard_Handle.hxx>
#include <Standard_Macro.hxx>
#include <Standard_Type.hxx>
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();
//! \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
//! \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<TCollection_AsciiString, Standard_DumpValue>& Values() const { initItem(); return myValues; }
+
+ //! Returns children stream values
+ const NCollection_IndexedDataMap<TCollection_AsciiString, Standard_DumpValue>& 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<TCollection_AsciiString, TCollection_AsciiString> myValues; //!< the values
+ TCollection_AsciiString myKey; //!< the item key
+ Standard_DumpValue myStreamValue; //!< the stream value
+ NCollection_IndexedDataMap<TCollection_AsciiString, Standard_DumpValue> myChildren; //!< the children
+
+ NCollection_IndexedDataMap<TCollection_AsciiString, Standard_DumpValue> myValues; //!< the values
};
#endif
\ No newline at end of file
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();
}
// =======================================================================
// =======================================================================
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<TreeModel_ItemStream>(Parent());
+ //if (!aStreamParent)
+ //{
+ // Standard_SStream aStream;
+ // Parent()->GetStream (aStream);
+
+ // NCollection_IndexedDataMap<TCollection_AsciiString, TCollection_AsciiString> 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<TreeModel_ItemStream>(Parent());
+
+ // TCollection_AsciiString aValue;
+ // aStreamParent->GetChildStream (Row(), aKey, aKeyValue);
+ // aPropertiesValue = aKeyValue;
+ //}
+
+ //myKey = aKey;
+ ////myProperties->Init (aPropertiesValue);
+ //myStreamValue = aKeyValue;
+
+ //NCollection_IndexedDataMap<TCollection_AsciiString, TCollection_AsciiString> 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<TreeModel_ItemStream>(Parent());
- if (!aStreamParent)
- {
- Standard_SStream aStream;
- Parent()->GetStream (aStream);
-
- NCollection_IndexedDataMap<TCollection_AsciiString, TCollection_AsciiString> 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<TreeModel_ItemStream>(Parent());
-
- TCollection_AsciiString aValue;
- aStreamParent->GetChildStream (Row(), aKey, aKeyValue);
- aPropertiesValue = aKeyValue;
- }
-
- myKey = aKey;
- myProperties->Init (aPropertiesValue);
- myStreamValue = aKeyValue;
-
- NCollection_IndexedDataMap<TCollection_AsciiString, TCollection_AsciiString> aValues;
- Standard_Dump::SplitJson (aKeyValue, aValues);
+ TreeModel_ItemBase::Init();
- for (Standard_Integer anIndex = 1; anIndex <= aValues.Size(); anIndex++)
+ //NCollection_List<Standard_Integer> 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();
}
// =======================================================================
// =======================================================================
void TreeModel_ItemStream::Reset()
{
- myKey = "";
- myStreamValue = "";
+ //myKey = "";
+ //myStreamValue = "";
- myProperties->Reset();
- myChildren.Clear();
+ //myChildren.Clear();
TreeModel_ItemBase::Reset();
}
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
// =======================================================================
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);
}
//! \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<TCollection_AsciiString, TCollection_AsciiString>& 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<TCollection_AsciiString, TCollection_AsciiString>& GetChildren() const
+ // { initItem(); return myChildren; }
//! Returns stream value of the item to fulfill property panel.
//! \return stream value or dummy
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<TCollection_AsciiString, TCollection_AsciiString> myChildren; //!< the children
+ //TCollection_AsciiString myKey; //!< the item key
+ //TCollection_AsciiString myStreamValue; //!< the stream value
+ //NCollection_IndexedDataMap<TCollection_AsciiString, TCollection_AsciiString> myChildren; //!< the children
};
#endif
// =======================================================================
int VInspector_ItemBVHTree::initRowCount() const
{
- if (Column() != 0)
- return 0;
+ return 0;//
- opencascade::handle<BVH_Tree<Standard_Real, 3> > aTree = GetTree();
- if (aTree.IsNull())
- return 0;
+ //if (Column() != 0)
+ // return 0;
- return aTree->Length();
+ //opencascade::handle<BVH_Tree<Standard_Real, 3> > aTree = GetTree();
+ //if (aTree.IsNull())
+ // return 0;
+
+ //return aTree->Length();
}
// =======================================================================
}
// =======================================================================
-// function : Dump
+// function : GetStream
// purpose :
// =======================================================================
-Standard_Boolean VInspector_ItemBVHTree::Dump (Standard_OStream& theOStream) const
+void VInspector_ItemBVHTree::GetStream (Standard_OStream& theOStream) const
{
opencascade::handle<BVH_Tree<Standard_Real, 3> > aBVHTree = GetTree();
if (aBVHTree.IsNull())
- return Standard_False;
+ return;
aBVHTree->DumpJson (theOStream);
- return Standard_True;
}
// =======================================================================
opencascade::handle<BVH_Tree<Standard_Real, 3> > GetTree() const
{ return opencascade::handle<BVH_Tree<Standard_Real, 3> >::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.
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;
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<VInspector_ItemContext*>(this)->Init();
+}
+
// =======================================================================
// function : createChild
// purpose :
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);
+}
+
//! \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:
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 :
// =======================================================================
int VInspector_ItemGraphic3dCamera::initRowCount() const
{
+ Handle(Graphic3d_Camera) aCamera = GetCamera(); // we need Init() call for having GetStream() filled
+
return 0;
}
//! 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
aGroup->DumpJson (theOStream);
}
-
// =======================================================================
// function : createChild
// purpose :
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<Handle(AIS_InteractiveObject)> 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<Handle(AIS_InteractiveObject)>::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
}
const_cast<VInspector_ItemPrs3dDrawer*>(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 :
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.
TopoDS_Shape VInspector_ItemPrs3dPresentation::buildPresentationShape()
{
if (!myPresentation.IsNull())
- myPresentationShape = Convert_Tools::CreateShape (myPresentation->MinMaxValues());
+ Convert_Tools::CreateShape (myPresentation->MinMaxValues(), myPresentationShape);
return TopoDS_Shape();
}
return TopoDS_Shape();
Select3D_BndBox3d aBndBox = aSensitiveSet->Box (Row());
- return VInspector_Tools::CreateShape (aBndBox);
+ TopoDS_Shape aShape;
+ VInspector_Tools::CreateShape (aBndBox, aShape);
+
+ return aShape;
}
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())
{
}
// =======================================================================
-// 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;
}
// =======================================================================
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.
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 :
//! Returns child BVH tree of the row
opencascade::handle<BVH_Tree<Standard_Real, 3> > 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;
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 :
//! 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;
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())
if (aParentValue.isValid())
return aParentValue;
+ if (GetSelection().IsNull())
+ return QVariant();
+
switch (theItemRole)
{
case Qt::DisplayRole:
int aRowId = Row();
int aCurrentId = 0;
-#if OCC_VERSION_HEX < 0x070201
- for (aSelection->Init(); aSelection->More(); aSelection->Next(), aCurrentId++)
-#else
- for (NCollection_Vector<Handle(SelectMgr_SensitiveEntity)>::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<Handle(SelectMgr_SensitiveEntity)>::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();
}
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 :
//! 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.
}
// =======================================================================
-// 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;
}
// =======================================================================
//! \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:
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 :
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;
//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);
}
//=======================================================================
//! 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
#include <inspector/TreeModel_ColumnType.hxx>
#include <inspector/TreeModel_ContextMenu.hxx>
#include <inspector/TreeModel_ItemProperties.hxx>
-#include <inspector/TreeModel_ItemStream.hxx>
#include <inspector/TreeModel_Tools.hxx>
#include <inspector/ViewControl_MessageDialog.hxx>
{
theItem.Bind (anItemsIt.key().toStdString().c_str(), anItemsIt.value().toStdString().c_str());
}
+
+ anItems.clear();
+ ViewControl_PropertyView::SaveState (myPropertyView, anItems, "property_view_parameters_");
+ for (QMap<QString, QString>::const_iterator anItemsIt = anItems.begin(); anItemsIt != anItems.end(); anItemsIt++)
+ theItem.Bind (anItemsIt.key().toStdString().c_str(), anItemsIt.value().toStdString().c_str());
}
// =======================================================================
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;
}
}
// obtain selection from the property panel
{
- //QList<ViewControl_Table*> 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);
void VInspector_Window::GetSelectedPropertyPanelShapes (const TreeModel_ItemBasePtr& theTreeItem,
NCollection_List<TopoDS_Shape>& theShapes)
{
- QList<ViewControl_Table*> 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<Handle(Standard_Transient)> theSelPresentations;
- aFirstTable->GetSelectedPresentations (theTreeItem, theSelPresentations);
+ aPropertyTable->GetSelectedPresentations (theTreeItem, theSelPresentations);
for (NCollection_List<Handle(Standard_Transient)>::Iterator anIterator (theSelPresentations); anIterator.More(); anIterator.Next())
{
theShapes.Append (aShapePrs->GetShape());
}
- //QModelIndexList& thePropertyPanelIndices = aFirstTable->GetTableView()->selectionModel()->selectedIndexes(),
+ //QModelIndexList& thePropertyPanelIndices = aPropertyTable->GetTableView()->selectionModel()->selectedIndexes(),
//QList<TreeModel_ItemBasePtr> anItems = TreeModel_ModelBase::GetSelectedItems (theTreeViewIndices);
//NCollection_List<Handle(Standard_Transient)> aPropertyPresentations;
if (!aTreeItemSelected)
return;
- QList<ViewControl_Table*> 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<Handle(Standard_Transient)> aSelPresentations;
- aFirstTable->GetSelectedPresentations (aTreeItemSelected, aSelPresentations);
+ aPropertyTable->GetSelectedPresentations (aTreeItemSelected, aSelPresentations);
//Handle(TreeModel_ItemProperties) anItemProperties = aTreeItemSelected->GetProperties();
//QMap<int, QList<int>> aSelectedIndices;
- //aFirstTable->GetSelectedIndices (aSelectedIndices);
+ //aPropertyTable->GetSelectedIndices (aSelectedIndices);
- //ViewControl_TableModel* aTableModel = dynamic_cast<ViewControl_TableModel*>(aFirstTable->GetTableView()->model());
+ //ViewControl_TableModel* aTableModel = dynamic_cast<ViewControl_TableModel*>(aPropertyTable->GetTableView()->model());
//ViewControl_TableModelValues* aTableValues = aTableModel->GetModelValues();
QStringList aPointers;
- aFirstTable->GetSelectedPointers (aPointers);
+ aPropertyTable->GetSelectedPointers (aPointers);
//NCollection_List<Handle(Standard_Transient)> aSelPresentations;
/*for (QMap<int, QList<int>>::const_iterator aSelIt = aSelectedIndices.begin(); aSelIt != aSelectedIndices.end(); aSelIt++)
//NCollection_List<TopoDS_Shape> aSelectedShapes = GetSelectedShapes (aTreeViewSelected);
//GetSelectedPropertyPanelShapes(aTreeViewSelected,
- // aFirstTable->GetTableView()->selectionModel()->selectedIndexes(),
+ // aPropertyTable->GetTableView()->selectionModel()->selectedIndexes(),
// aSelectedShapes);
//updatePreviewPresentation(aSelectedShapes, aSelectedPersistent);
return;
NCollection_List<Handle(Standard_Transient)> aSelPresentations;
- TreeModel_ItemStreamPtr aStreamParent = itemDynamicCast<TreeModel_ItemStream> (aTreeItemSelected);
- if (!aStreamParent)
- return;
- Handle(TreeModel_ItemProperties) anItemProperties = aStreamParent->Properties ();
+ Handle(TreeModel_ItemProperties) anItemProperties = aTreeItemSelected->Properties ();
if (anItemProperties)
anItemProperties->GetPresentations (-1, -1, aSelPresentations);
//else
if (!anItemBase)
return;
- TreeModel_ItemStreamPtr aStreamItem = itemDynamicCast<TreeModel_ItemStream> (anItemBase);
- if (!aStreamItem)
- return;
-
- Handle(TreeModel_ItemProperties) anItemProperties = aStreamItem->Properties ();
- QList<ViewControl_TableModelValues*> 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();
TreeModel_ItemBasePtr aSelectedItem = TreeModel_ModelBase::GetItemByIndex(aSelected.first());
VInspector_Tools::GetPropertyTableValues (aSelectedItem, myPaneCreators, aTableValues);
}*/
- myPropertyView->Init (aTableValuesList);
+ myPropertyView->Init (aTableValues);
}
// =======================================================================
// function : createView
// purpose :
// =======================================================================
+#include <Prs3d_DatumAspect.hxx>
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);
#include <BRepBuilderAPI_MakeVertex.hxx>
#include <BRepBuilderAPI_MakeEdge.hxx>
#include <BRepBuilderAPI_MakeFace.hxx>
+#include <BRepBuilderAPI_MakeWire.hxx>
#include <Geom_Axis2Placement.hxx>
+#include <Prs3d_PointAspect.hxx>
#include <TopoDS_Compound.hxx>
+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 :
// 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());
}
// =======================================================================
if (myContext.IsNull())
return;
+ // clear previous previews
+ for (NCollection_List<Handle(AIS_InteractiveObject)>::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<Handle(Standard_Transient)>::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);
+ }
}
}
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());
View_PreviewParameters* myPreviewParameters; //!< drawer of preview presentation
Handle(AIS_InteractiveObject) myPreviewPresentation; //!< presentation of preview for a selected object
+ NCollection_List<Handle(AIS_InteractiveObject)> myPreviewReadyPresentations; //!< presentation of preview for a selected object
};
#endif
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);
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;
// aStream << theValue.ToString().ToStdString();
// myDrawer->ShadingAspect()->Init (aStream);
//}
- //else
- // return false;
+ else
+ return false;
return true;
}
//! 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
return (View_ContextType)myViewSelector->currentIndex();
}
+// =======================================================================
+// function : SetCurrentContext
+// purpose :
+// =======================================================================
+void View_ToolBar::SetCurrentContextType (View_ContextType theType)
+{
+ myViewSelector->setCurrentIndex ((int)theType);
+ emit contextChanged();
+}
+
// =======================================================================
// function : GetCurrentContext
// purpose :
return myActionsMap.contains (anActionId) ? myActionsMap[anActionId]->isChecked() : false;
}
+// =======================================================================
+// function : SaveState
+// purpose :
+// =======================================================================
+void View_ToolBar::SaveState (View_ToolBar* theParameters,
+ QMap<QString, QString>& 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 :
//! \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<QString, QString>& 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
#include <inspector/View_Displayer.hxx>
#include <inspector/View_DisplayPreview.hxx>
#include <inspector/View_PreviewParameters.hxx>
+#include <inspector/View_ToolBar.hxx>
#include <inspector/View_Viewer.hxx>
#include <inspector/View_Widget.hxx>
#include <inspector/View_Window.hxx>
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_");
}
// =======================================================================
{
return true;
}
+ else if (View_ToolBar::RestoreState (theView->GetViewToolBar(), theKey, theValue, "view_toolbar_"))
+ {
+ return true;
+ }
return false;
}
#include <Standard_ExtString.hxx>
#include <Standard_Version.hxx>
-//#define USE_CLIPPLANE
+#define USE_CLIPPLANE
#ifdef USE_CLIPPLANE
#include <Graphic3d_ClipPlane.hxx>
myDragMultiButtonDownX = 0;
myDragMultiButtonDownY = 0;
- myCurrentMode = View_CurrentAction3d_Nothing;
- activateCursor (myCurrentMode);
+ //myCurrentMode = View_CurrentAction3d_Nothing;
+ //activateCursor (myCurrentMode);
emit selectionChanged();
emit leftButtonUp(thePoint.x(), thePoint.y());
}
#include <Standard_WarningsDisable.hxx>
#include <QAbstractTableModel>
+#include <QHeaderView>
#include <QStackedWidget>
#include <QScrollArea>
#include <QTableView>
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<int>&)),
+ this, SIGNAL (propertyViewDataChanged()));
+
+ myTableWidgetLayout->addWidget (aTable->GetControl());
+ myTable = aTable;
}
// =======================================================================
// function : Init
// purpose :
// =======================================================================
-void ViewControl_PropertyView::Init (const QList<ViewControl_TableModelValues*>& 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<ViewControl_TableModel*> (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);
}
// =======================================================================
-// function : GetActiveTables
+// function : GetTable
// purpose :
// =======================================================================
-void ViewControl_PropertyView::GetActiveTables (QList<ViewControl_Table*>& 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;
}
// =======================================================================
myOwnSelectionChangeBlocked = true;
QList<ViewControl_Table*> 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;
}
// =======================================================================
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<ViewControl_TableModel*> (aTable->GetTableView()->model());
aModel->SetModelValues (0);
}
// =======================================================================
-// function : findTable
+// function : SaveState
// purpose :
// =======================================================================
-ViewControl_Table* ViewControl_PropertyView::findTable (const int theTableId, const bool isToCreate)
+void ViewControl_PropertyView::SaveState (ViewControl_PropertyView* thePropertyView,
+ QMap<QString, QString>& 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;
}
// =======================================================================
//! 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<ViewControl_TableModelValues*>& theTableValues);
+ Standard_EXPORT void Init (ViewControl_TableModelValues* theTableValues);
//! Fills the view content with the parameter custom widget.
//! \param theWidget control
//! \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<ViewControl_Table*>& 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<QString, QString>& 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
QWidget* myTableWidget; //!< widget of tables in vertical layout
QVBoxLayout* myTableWidgetLayout; //! main view layout where tables or custom widgets are presented
- QList<ViewControl_Table*> 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
int aDefCellSize = aVHeader->minimumSectionSize();
aVHeader->setDefaultSectionSize (aDefCellSize);
+ connect (myTableView->horizontalHeader(), SIGNAL (sectionResized (int, int, int)),
+ this, SLOT(onHeaderResized (int, int, int)));
+
aLayout->addWidget (myTableView);
}
ViewControl_TableItemDelegate* aDelegate = dynamic_cast<ViewControl_TableItemDelegate*>(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);
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));
+}
//! \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
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;
}
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;
}
// =======================================================================
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;
}