]> OCCT Git - occt-copy.git/commitdiff
0031326: Foundation Classes - Init from Json for base OCCT classes
authornds <nds@opencascade.com>
Wed, 18 Mar 2020 06:11:32 +0000 (09:11 +0300)
committernds <nds@opencascade.com>
Wed, 18 Mar 2020 06:11:32 +0000 (09:11 +0300)
13 files changed:
src/BVH/BVH_Box.hxx
tools/Convert/Convert_Tools.cxx
tools/MessageModel/MessageModel_ItemAlert.hxx
tools/MessageView/MessageView_Window.cxx
tools/TreeModel/TreeModel_ItemBase.cxx
tools/TreeModel/TreeModel_ItemBase.hxx
tools/TreeModel/TreeModel_ModelBase.cxx
tools/VInspector/VInspector_ItemPresentableObject.cxx
tools/VInspector/VInspector_Window.cxx
tools/View/View_DisplayPreview.cxx
tools/View/View_DisplayPreview.hxx
tools/View/View_Displayer.cxx
tools/View/View_PreviewParameters.cxx

index 6e9d907a8059c19e8499b79d7b62b51a919a6b05..d941a52a1e5abbeec803f35df62704be86223038 100644 (file)
@@ -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)
index efbad8b32925d73efde00d67837b85da15d033bf..67803f24944f68966f014a3095e72f7a0a763443 100644 (file)
@@ -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;
+  }
 }
 
 //=======================================================================
index c07fbf5e5817d680e63b4eec7c1589af719f5c99..c9b5d0b781ff8ec4538458608a1c0035d1f2690e 100644 (file)
@@ -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<Handle(Standard_Transient)>& thePresentations) Standard_OVERRIDE
-  { thePresentations.Append (myPresentation); }
+  { TreeModel_ItemBase::Presentations (thePresentations); thePresentations.Append (myPresentation); }
 
 
   ////! Returns summ of children alert elapsed times. The method is recusive.
index ac6e0d063b74e540ce6f9e985b55dbfcdce01161..1dfb89beb9cfcb9ef3477eeef30088eeb69551cb 100644 (file)
@@ -32,7 +32,6 @@
 #include <inspector/ViewControl_TreeView.hxx>
 #include <inspector/Convert_Tools.hxx>
 
-#include <inspector/View_DisplayPreview.hxx>
 #include <inspector/View_Viewer.hxx>
 #include <inspector/View_Widget.hxx>
 
@@ -739,7 +738,7 @@ void MessageView_Window::onPreviewChildren()
   NCollection_List<Handle(Standard_Transient)> 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<MessageModel_ItemAlert>(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);
 }
 
 // =======================================================================
index 38ef9b23cafe3040d988e2bba2545bc84aa7cd36..1b23b909cbc3a923cd57195c77f98898d48bc6a7 100644 (file)
@@ -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<Handle(Standard_Transient)>& thePresentations)
+{
+  if (Column() != 0)
+    return;
+
+  const Handle(TreeModel_ItemProperties)& anItemProperties = Properties();
+  if (anItemProperties)
+  {
+    anItemProperties->Presentations (thePresentations);
+  }
+}
+
 // =======================================================================
 // function :  currentItem
 // purpose :
index 66db01a1577277f51d27ef639c95933c3ca1349b..8654b068762038a3c562f98fa87bfe421afaca36 100644 (file)
@@ -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<Handle(Standard_Transient)>& thePresentations) { (void)thePresentations; }
+  Standard_EXPORT virtual void Presentations (NCollection_List<Handle(Standard_Transient)>& thePresentations);
 
 protected:
 
index 19ee5d0a6c15aadf5581129271600425b5b34837..806684a4f119c277fb28b460f36c2cdc4f557aef 100644 (file)
@@ -322,11 +322,8 @@ void TreeModel_ModelBase::subItemsPresentations (const TreeModel_ItemBasePtr& th
                                                  NCollection_List<Handle(Standard_Transient)>& thePresentations)
 {
   theItem->Presentations (thePresentations);
-  if (!theItem->Properties().IsNull())
-    theItem->Properties()->Presentations (thePresentations);
 
   QList<TreeModel_ItemBasePtr> anItems;
-
   for (int aRowId = 0; aRowId < theItem->rowCount(); aRowId++)
   {
     subItemsPresentations (theItem->Child (aRowId, theItem->Column()), thePresentations);
index 135170ea1b674b303003cb39e74c5c139df3d255..9babba37ff720d2acfa48d9f3616c88cb695ca81 100644 (file)
@@ -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<Handle(AIS_InteractiveObject)>::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<Handle(Standard_Transient)>& thePresentations)
 {
+  TreeModel_ItemBase::Presentations (thePresentations); 
+
   if (Column() != 0)
     return;
-
   thePresentations.Append (GetInteractiveObject());
 }
 
index d3ee3c98227abf08b574f9d86f79008b477c4289..4e76e981135a6031ed7e12d28a1af54d23cfe5eb 100644 (file)
@@ -22,7 +22,6 @@
 
 #include <inspector/TreeModel_ColumnType.hxx>
 #include <inspector/TreeModel_ContextMenu.hxx>
-#include <inspector/TreeModel_ItemProperties.hxx>
 #include <inspector/TreeModel_Tools.hxx>
 
 #include <inspector/ViewControl_MessageDialog.hxx>
@@ -392,7 +391,10 @@ void VInspector_Window::SelectedShapes (NCollection_List<Handle(Standard_Transie
     TreeModel_ItemBasePtr anItem = *anItemIt;
     VInspector_ItemBasePtr aVItem = itemDynamicCast<VInspector_ItemBase>(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);
 }
 
 // =======================================================================
index 7e6c55123b0e14b41dfce2f91821c18c33393287..e129416f33ba0e9c1845de546d8985c5f3b1e57e 100644 (file)
@@ -79,12 +79,13 @@ void View_DisplayPreview::SetContext (const Handle(AIS_InteractiveContext)& theC
 // purpose :
 // =======================================================================
 void View_DisplayPreview::UpdatePreview (const View_DisplayActionType,
-                                         const NCollection_List<Handle(Standard_Transient)>& thePresentations,
-                                         int theDisplayMode)
+                                         const NCollection_List<Handle(Standard_Transient)>& thePresentations)
 {
   if (myContext.IsNull())
     return;
 
+  int aPreviewDisplayMode = AIS_Shaded;
+
   // clear previous previews
   for (NCollection_List<Handle(AIS_InteractiveObject)>::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<Handle(AIS_InteractiveObject)>::Iterator aPreviewIt (myPreviewReadyPresentations); aPreviewIt.More(); aPreviewIt.Next())
-  {
-     if (myContext == aPreviewIt.Value()->GetContext())
-       myContext->SetDisplayMode (aPreviewIt.Value(), theDisplayMode, Standard_False);
-  }
-
-  if (theToUpdateViewer)
-    myContext->UpdateCurrentViewer();
-}
index 530bfea2480aace7089051cf4de154fc51f76d47..550e681289a059c3aef94efd6ee7e0e9557eb35e 100644 (file)
@@ -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<Handle(Standard_Transient)>& thePresentations,
-                                      int theDisplayMode);
-
-  //! Sets display mode for all displayed presentations
-  Standard_EXPORT void SetDisplayMode (const int theDisplayMode,
-                                       const bool theToUpdateViewer = true);
+                                      const NCollection_List<Handle(Standard_Transient)>& thePresentations);
 
   //! Returns true if preview presentation is shown
   Standard_Boolean HasPreview() const { return !myPreviewPresentation.IsNull(); }
index 9d36606c96b83d9dac7045d87de66508b60145d5..72c1c28ec738a30821a818d0bddb5a6d597d00e4 100644 (file)
@@ -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<Handle(Standard_Transient)>& thePresentations)
 {
-  myDisplayPreview->UpdatePreview (theType, thePresentations, myDisplayMode);
+  myDisplayPreview->UpdatePreview (theType, thePresentations);
   if (!myIsKeepPresentations || myFitAllActive)
     fitAllView();
 }
index 8cc48d06b1f4885f7192323cea3c2eb705d0f003..f6375e5658fd6c4b060076fb908eb82a92e0de3b 100644 (file)
@@ -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);
 }