From: nds Date: Wed, 18 Mar 2020 06:11:32 +0000 (+0300) Subject: 0031326: Foundation Classes - Init from Json for base OCCT classes X-Git-Url: http://git.dev.opencascade.org/gitweb/?a=commitdiff_plain;h=e76d46b31cd25d57f2fc65b52814946c690ea195;p=occt-copy.git 0031326: Foundation Classes - Init from Json for base OCCT classes --- diff --git a/src/BVH/BVH_Box.hxx b/src/BVH/BVH_Box.hxx index 6e9d907a80..d941a52a1e 100644 --- a/src/BVH/BVH_Box.hxx +++ b/src/BVH/BVH_Box.hxx @@ -212,9 +212,9 @@ public: { Standard_Integer aPos = theStreamPos; - Standard_Integer isInited = 0; - OCCT_INIT_FIELD_VALUE_INTEGER (theSStream, aPos, isInited); - myIsInited = isInited != 0; + Standard_Integer anIsInited = 0; + OCCT_INIT_FIELD_VALUE_INTEGER (theSStream, aPos, anIsInited); + myIsInited = anIsInited != 0; int n = Min (N, 3); if (n == 1) diff --git a/tools/Convert/Convert_Tools.cxx b/tools/Convert/Convert_Tools.cxx index efbad8b329..67803f2494 100644 --- a/tools/Convert/Convert_Tools.cxx +++ b/tools/Convert/Convert_Tools.cxx @@ -114,6 +114,18 @@ void Convert_Tools::ConvertStreamToPresentations (const Standard_SStream& theSSt thePresentations.Append (new Convert_TransientShape (aShape)); return; } + + Select3D_BndBox3d aSelectBndBox; + if (aSelectBndBox.InitFromJson (theSStream, aStartPos)) + { + TopoDS_Shape aShape; + + gp_Pnt aPntMin = gp_Pnt (aSelectBndBox.CornerMin().x(), aSelectBndBox.CornerMin().y(), aSelectBndBox.CornerMin().z()); + gp_Pnt aPntMax = gp_Pnt (aSelectBndBox.CornerMax().x(), aSelectBndBox.CornerMax().y(), aSelectBndBox.CornerMax().z()); + if (CreateBoxShape (aPntMin, aPntMax, aShape)) + thePresentations.Append (new Convert_TransientShape (aShape)); + return; + } } //======================================================================= diff --git a/tools/MessageModel/MessageModel_ItemAlert.hxx b/tools/MessageModel/MessageModel_ItemAlert.hxx index c07fbf5e58..c9b5d0b781 100644 --- a/tools/MessageModel/MessageModel_ItemAlert.hxx +++ b/tools/MessageModel/MessageModel_ItemAlert.hxx @@ -92,7 +92,7 @@ public: //! \param theColumn a model index column //! \thePresentations [out] container of presentation handles to be visualized virtual void Presentations (NCollection_List& thePresentations) Standard_OVERRIDE - { thePresentations.Append (myPresentation); } + { TreeModel_ItemBase::Presentations (thePresentations); thePresentations.Append (myPresentation); } ////! Returns summ of children alert elapsed times. The method is recusive. diff --git a/tools/MessageView/MessageView_Window.cxx b/tools/MessageView/MessageView_Window.cxx index ac6e0d063b..1dfb89beb9 100644 --- a/tools/MessageView/MessageView_Window.cxx +++ b/tools/MessageView/MessageView_Window.cxx @@ -32,7 +32,6 @@ #include #include -#include #include #include @@ -739,7 +738,7 @@ void MessageView_Window::onPreviewChildren() NCollection_List aPresentations; TreeModel_ModelBase::SubItemsPresentations (aSelectedIndices, aPresentations); - displayer()->DisplayPreview()->UpdatePreview (View_DisplayActionType_DisplayId, aPresentations, myViewWindow->ViewWidget()->DisplayMode()); + displayer()->UpdatePreview (View_DisplayActionType_DisplayId, aPresentations); } // ======================================================================= @@ -871,20 +870,10 @@ void MessageView_Window::updatePreviewPresentation() if (!anItemBase) continue; - Handle(TreeModel_ItemProperties) anItemProperties = anItemBase->Properties(); - if (anItemProperties) - { - anItemProperties->Presentations (aPresentations); - } - - MessageModel_ItemAlertPtr anAlertItem = itemDynamicCast(anItemBase); - if (anAlertItem) - { - anAlertItem->Presentations (aPresentations); - } + anItemBase->Presentations (aPresentations); } - displayer()->DisplayPreview()->UpdatePreview (View_DisplayActionType_DisplayId, aPresentations, myViewWindow->ViewWidget()->DisplayMode()); + displayer()->UpdatePreview (View_DisplayActionType_DisplayId, aPresentations); } // ======================================================================= diff --git a/tools/TreeModel/TreeModel_ItemBase.cxx b/tools/TreeModel/TreeModel_ItemBase.cxx index 38ef9b23ca..1b23b909cb 100644 --- a/tools/TreeModel/TreeModel_ItemBase.cxx +++ b/tools/TreeModel/TreeModel_ItemBase.cxx @@ -92,6 +92,22 @@ TreeModel_ItemBasePtr TreeModel_ItemBase::Child (int theRow, int theColumn, cons return anItem; } +// ======================================================================= +// function : Presentations +// purpose : +// ======================================================================= +void TreeModel_ItemBase::Presentations (NCollection_List& thePresentations) +{ + if (Column() != 0) + return; + + const Handle(TreeModel_ItemProperties)& anItemProperties = Properties(); + if (anItemProperties) + { + anItemProperties->Presentations (thePresentations); + } +} + // ======================================================================= // function : currentItem // purpose : diff --git a/tools/TreeModel/TreeModel_ItemBase.hxx b/tools/TreeModel/TreeModel_ItemBase.hxx index 66db01a157..8654b06876 100644 --- a/tools/TreeModel/TreeModel_ItemBase.hxx +++ b/tools/TreeModel/TreeModel_ItemBase.hxx @@ -152,7 +152,7 @@ public: //! Returns presentation of the attribute to be visualized in the view //! \thePresentations [out] container of presentation handles to be visualized - virtual void Presentations (NCollection_List& thePresentations) { (void)thePresentations; } + Standard_EXPORT virtual void Presentations (NCollection_List& thePresentations); protected: diff --git a/tools/TreeModel/TreeModel_ModelBase.cxx b/tools/TreeModel/TreeModel_ModelBase.cxx index 19ee5d0a6c..806684a4f1 100644 --- a/tools/TreeModel/TreeModel_ModelBase.cxx +++ b/tools/TreeModel/TreeModel_ModelBase.cxx @@ -322,11 +322,8 @@ void TreeModel_ModelBase::subItemsPresentations (const TreeModel_ItemBasePtr& th NCollection_List& thePresentations) { theItem->Presentations (thePresentations); - if (!theItem->Properties().IsNull()) - theItem->Properties()->Presentations (thePresentations); QList anItems; - for (int aRowId = 0; aRowId < theItem->rowCount(); aRowId++) { subItemsPresentations (theItem->Child (aRowId, theItem->Column()), thePresentations); diff --git a/tools/VInspector/VInspector_ItemPresentableObject.cxx b/tools/VInspector/VInspector_ItemPresentableObject.cxx index 135170ea1b..9babba37ff 100644 --- a/tools/VInspector/VInspector_ItemPresentableObject.cxx +++ b/tools/VInspector/VInspector_ItemPresentableObject.cxx @@ -156,7 +156,7 @@ void VInspector_ItemPresentableObject::Init() } std::sort (aListOfIOSorted.begin(), aListOfIOSorted.end()); - int aCurrentIndex = 0; + int aCurrentIndex = 1; /* Properties item of context*/ for (std::vector::const_iterator anIOIt = aListOfIOSorted.begin(); anIOIt != aListOfIOSorted.end(); anIOIt++, aCurrentIndex++) { if (aCurrentIndex != aRowId) @@ -228,9 +228,10 @@ QString VInspector_ItemPresentableObject::PointerInfo() const // ======================================================================= void VInspector_ItemPresentableObject::Presentations (NCollection_List& thePresentations) { + TreeModel_ItemBase::Presentations (thePresentations); + if (Column() != 0) return; - thePresentations.Append (GetInteractiveObject()); } diff --git a/tools/VInspector/VInspector_Window.cxx b/tools/VInspector/VInspector_Window.cxx index d3ee3c9822..4e76e98113 100644 --- a/tools/VInspector/VInspector_Window.cxx +++ b/tools/VInspector/VInspector_Window.cxx @@ -22,7 +22,6 @@ #include #include -#include #include #include @@ -392,7 +391,10 @@ void VInspector_Window::SelectedShapes (NCollection_List(anItem); if (!aVItem /*|| aVItem->Row() == 0*/) + { + anItem->Presentations (theSelPresentations); continue; + } TopoDS_Shape aShape = aVItem->GetPresentationShape(); if (aShape.IsNull()) @@ -595,15 +597,11 @@ void VInspector_Window::onTreeViewSelectionChanged (const QItemSelection&, if (!anItemBase) continue; - const Handle(TreeModel_ItemProperties)& anItemProperties = anItemBase->Properties(); - if (anItemProperties) - { - anItemProperties->Presentations (aSelPresentations); - } + anItemBase->Presentations (aSelPresentations); } SelectedShapes (aSelPresentations); - displayer()->DisplayPreview()->UpdatePreview (View_DisplayActionType_DisplayId, aSelPresentations, displayer()->DisplayMode()); + displayer()->UpdatePreview (View_DisplayActionType_DisplayId, aSelPresentations); } // ======================================================================= diff --git a/tools/View/View_DisplayPreview.cxx b/tools/View/View_DisplayPreview.cxx index 7e6c55123b..e129416f33 100644 --- a/tools/View/View_DisplayPreview.cxx +++ b/tools/View/View_DisplayPreview.cxx @@ -79,12 +79,13 @@ void View_DisplayPreview::SetContext (const Handle(AIS_InteractiveContext)& theC // purpose : // ======================================================================= void View_DisplayPreview::UpdatePreview (const View_DisplayActionType, - const NCollection_List& thePresentations, - int theDisplayMode) + const NCollection_List& thePresentations) { if (myContext.IsNull()) return; + int aPreviewDisplayMode = AIS_Shaded; + // clear previous previews for (NCollection_List::Iterator anIterator (myPreviewReadyPresentations); anIterator.More(); anIterator.Next()) { @@ -115,7 +116,7 @@ void View_DisplayPreview::UpdatePreview (const View_DisplayActionType, 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, theDisplayMode, -1/*does not participate in selection*/, Standard_True); + myContext->Display (aPrs, aPreviewDisplayMode, -1/*does not participate in selection*/, Standard_True); enableGlobalClipping(aPrs, false); myPreviewReadyPresentations.Append (aPrs); } @@ -128,7 +129,7 @@ void View_DisplayPreview::UpdatePreview (const View_DisplayActionType, myPreviewPresentation->Attributes()->SetPointAspect (new Prs3d_PointAspect (Aspect_TOM_O_PLUS, aColor, 3.0)); myPreviewPresentation->SetAttributes (myPreviewParameters->GetDrawer()); - myContext->Display (myPreviewPresentation, theDisplayMode, -1/*does not participate in selection*/, Standard_True); + myContext->Display (myPreviewPresentation, aPreviewDisplayMode, -1/*does not participate in selection*/, Standard_True); enableGlobalClipping(myPreviewPresentation, false); } else @@ -140,28 +141,3 @@ void View_DisplayPreview::UpdatePreview (const View_DisplayActionType, } } } - -// ======================================================================= -// function : SetDisplayMode -// purpose : -// ======================================================================= -void View_DisplayPreview::SetDisplayMode (const int theDisplayMode, const bool theToUpdateViewer) -{ - if (myContext.IsNull()) - return; - - if (!myPreviewPresentation.IsNull()) - { - if (myContext == myPreviewPresentation->GetContext()) - myContext->SetDisplayMode (myPreviewPresentation, theDisplayMode, Standard_False); - } - - for (NCollection_List::Iterator aPreviewIt (myPreviewReadyPresentations); aPreviewIt.More(); aPreviewIt.Next()) - { - if (myContext == aPreviewIt.Value()->GetContext()) - myContext->SetDisplayMode (aPreviewIt.Value(), theDisplayMode, Standard_False); - } - - if (theToUpdateViewer) - myContext->UpdateCurrentViewer(); -} diff --git a/tools/View/View_DisplayPreview.hxx b/tools/View/View_DisplayPreview.hxx index 530bfea248..550e681289 100644 --- a/tools/View/View_DisplayPreview.hxx +++ b/tools/View/View_DisplayPreview.hxx @@ -53,12 +53,7 @@ public: //! Updates visibility of the presentations for the display type Standard_EXPORT void UpdatePreview (const View_DisplayActionType theType, - const NCollection_List& thePresentations, - int theDisplayMode); - - //! Sets display mode for all displayed presentations - Standard_EXPORT void SetDisplayMode (const int theDisplayMode, - const bool theToUpdateViewer = true); + const NCollection_List& thePresentations); //! Returns true if preview presentation is shown Standard_Boolean HasPreview() const { return !myPreviewPresentation.IsNull(); } diff --git a/tools/View/View_Displayer.cxx b/tools/View/View_Displayer.cxx index 9d36606c96..72c1c28ec7 100644 --- a/tools/View/View_Displayer.cxx +++ b/tools/View/View_Displayer.cxx @@ -34,7 +34,7 @@ // purpose : // ======================================================================= View_Displayer::View_Displayer() -: myIsKeepPresentations (false), myFitAllActive (false), myDisplayMode (-1) +: myIsKeepPresentations (false), myFitAllActive (false), myDisplayMode (0) { myDisplayPreview = new View_DisplayPreview(); } @@ -79,8 +79,6 @@ void View_Displayer::SetDisplayMode (const int theDisplayMode, for (AIS_ListIteratorOfListOfInteractive aDisplayedIt (aDisplayed); aDisplayedIt.More(); aDisplayedIt.Next()) GetContext()->SetDisplayMode (aDisplayedIt.Value(), theDisplayMode, Standard_False); - myDisplayPreview->SetDisplayMode (theDisplayMode, Standard_False); - if (theToUpdateViewer) UpdateViewer(); } @@ -270,7 +268,7 @@ bool View_Displayer::IsVisible (const TopoDS_Shape& theShape, const View_Present void View_Displayer::UpdatePreview (const View_DisplayActionType theType, const NCollection_List& thePresentations) { - myDisplayPreview->UpdatePreview (theType, thePresentations, myDisplayMode); + myDisplayPreview->UpdatePreview (theType, thePresentations); if (!myIsKeepPresentations || myFitAllActive) fitAllView(); } diff --git a/tools/View/View_PreviewParameters.cxx b/tools/View/View_PreviewParameters.cxx index 8cc48d06b1..f6375e5658 100644 --- a/tools/View/View_PreviewParameters.cxx +++ b/tools/View/View_PreviewParameters.cxx @@ -28,6 +28,7 @@ View_PreviewParameters::View_PreviewParameters() myDrawer = new Prs3d_Drawer(); Quantity_Color aColor(Quantity_NOC_TOMATO); + Standard_ShortReal aTransparency = 0.8; // point parameters myDrawer->SetPointAspect (new Prs3d_PointAspect (Aspect_TOM_O_PLUS, aColor, 3.0)); @@ -41,6 +42,10 @@ View_PreviewParameters::View_PreviewParameters() myDrawer->ShadingAspect()->SetColor (aColor); myDrawer->ShadingAspect()->SetMaterial (aShadingMaterial); + myDrawer->ShadingAspect()->Aspect()->ChangeFrontMaterial().SetTransparency (aTransparency); + myDrawer->ShadingAspect()->Aspect()->ChangeBackMaterial() .SetTransparency (aTransparency); + myDrawer->SetTransparency (aTransparency); + // common parameters myDrawer->SetZLayer (Graphic3d_ZLayerId_Topmost); }