]> OCCT Git - occt-copy.git/commitdiff
0030268: Inspectors - improvements in VInspector plugin
authornds <nds@opencascade.com>
Fri, 27 Dec 2019 16:12:29 +0000 (19:12 +0300)
committernds <nds@opencascade.com>
Fri, 27 Dec 2019 16:13:04 +0000 (19:13 +0300)
(cherry picked from commit 69db74767e3af40c5284cf350aa7501f4a59d06d)

adm/templates/OpenCASCADEConfig.cmake.in
src/Standard/Standard_Dump.cxx
src/ViewerTest/ViewerTest.cxx
src/ViewerTest/ViewerTest.hxx
tools/TreeModel/TreeModel_ItemProperties.cxx
tools/VInspector/VInspector_ItemBVHTree.cxx
tools/View/View_Viewer.cxx

index 4937103b9c34e590797dcfe7757478d5be7ca1b0..f07d0de90aa91bbd91e504024b6b3eb5664dcaf6 100644 (file)
@@ -62,6 +62,7 @@ set (OpenCASCADE_WITH_TBB       @USE_TBB@)
 set (OpenCASCADE_WITH_VTK       @USE_VTK@)
 set (OpenCASCADE_WITH_FFMPEG    @USE_FFMPEG@)
 set (OpenCASCADE_WITH_GLES2     @USE_GLES2@)
+set (OpenCASCADE_WITH_INSPECTOR @BUILD_Inspector@)
 @SET_OpenCASCADE_WITH_D3D@
 @SET_OpenCASCADE_WITH_GLX@
 
index 3157ba55810b6a79da4c12f8f88a477e6a44565e..e6831d98e57b6722ee591757fad46b9df3c57c8b 100644 (file)
 // function : Constructor
 // purpose :
 // =======================================================================
-Standard_DumpSentry::Standard_DumpSentry (Standard_OStream& theOStream, const char*)
+Standard_DumpSentry::Standard_DumpSentry (Standard_OStream& theOStream, const char* className)
 : myOStream (&theOStream)
 {
-  //(*myOStream) << "\"" << theClassName << "\": {";
+  OCCT_DUMP_FIELD_VALUE_STRING (theOStream, className)
+//(*myOStream) << "\"" << theClassName << "\": {";
 }
 
 // =======================================================================
@@ -284,7 +285,15 @@ TCollection_AsciiString Standard_Dump::DumpFieldToName (const TCollection_AsciiS
     aName.Remove (1, 1);
   }
 
-  if (::LowerCase (aName.Value(1)) == 'm' && aName.Value (2) == 'y')
+  if (::LowerCase (aName.Value(1)) == 'a' && aName.Value (2) == 'n')
+  {
+    aName.Remove (1, 2);
+  }
+  else if (::LowerCase (aName.Value(1)) == 'a')
+  {
+    aName.Remove (1, 1);
+  }
+  else if (::LowerCase (aName.Value(1)) == 'm' && aName.Value (2) == 'y')
   {
     aName.Remove (1, 2);
   }
index 37df16d484c5947b7fd0f27e20e0f5b01da998e0..81a8f41dfea26e9223838b81a20876cc6c2505e5 100644 (file)
@@ -758,6 +758,56 @@ Standard_Boolean ViewerTest::Display (const TCollection_AsciiString&       theNa
   return Standard_True;
 }
 
+//=======================================================================
+//function : Display
+//purpose  :
+//=======================================================================
+Standard_Boolean ViewerTest::Display (const TCollection_AsciiString&       theName,
+                                      const Handle(AIS_InteractiveObject)& theObject,
+                                      const Standard_Integer               theDispMode,
+                                      const Standard_Integer               theSelectionMode,
+                                      const Standard_Boolean               theToUpdate,
+                                      const Standard_Boolean               theReplaceIfExists)
+{
+  ViewerTest_DoubleMapOfInteractiveAndName& aMap = GetMapOfAIS();
+  Handle(AIS_InteractiveContext) aCtx = ViewerTest::GetAISContext();
+  if (aCtx.IsNull())
+  {
+    std::cout << "Error: AIS context is not available.\n";
+    return Standard_False;
+  }
+
+  if (aMap.IsBound2 (theName))
+  {
+    if (!theReplaceIfExists)
+    {
+      std::cout << "Error: other interactive object has been already registered with name: " << theName << ".\n"
+                << "Please use another name.\n";
+      return Standard_False;
+    }
+
+    if (Handle(AIS_InteractiveObject) anOldObj = aMap.Find2 (theName))
+    {
+      aCtx->Remove (anOldObj, theObject.IsNull() && theToUpdate);
+    }
+    aMap.UnBind2 (theName);
+  }
+
+  if (theObject.IsNull())
+  {
+    // object with specified name has been already unbound
+    return Standard_True;
+  }
+
+  // unbind AIS object if it was bound with another name
+  aMap.UnBind1 (theObject);
+
+  // can be registered without rebinding
+  aMap.Bind (theObject, theName);
+  aCtx->Display (theObject, theDispMode, theSelectionMode, theToUpdate);
+  return Standard_True;
+}
+
 //! Alias for ViewerTest::Display(), compatibility with old code.
 Standard_EXPORT Standard_Boolean VDisplayAISObject (const TCollection_AsciiString&       theName,
                                                     const Handle(AIS_InteractiveObject)& theObject,
index b9665cfc7dda3365dd3e315664f08531497d37b7..925554b0cd04406a795adbb6ff507b7ca4ea4b5d 100644 (file)
@@ -90,6 +90,22 @@ public:
                                                    const Standard_Boolean               theToUpdate = Standard_True,
                                                    const Standard_Boolean               theReplaceIfExists = Standard_True);
 
+  //! Display AIS object in active Viewer and register it in the map of Interactive Objects with specified name.
+  //! Sets status, display mode and selection mode for the Object
+  //! @param theName            key to be associated to displayed interactive object
+  //! @param theObject          object to display
+  //! @param theDispMode        display mode how the object should be displayed
+  //! @param theSelectionMode   if theSelectionMode equals -1, theIObj will not be activated
+  //! @param theToUpdate        redraw viewer after displaying object
+  //! @param theReplaceIfExists replace the object assigned to specified key
+  //! @return true if new object has been displayed
+  Standard_EXPORT static Standard_Boolean Display (const TCollection_AsciiString&       theName,
+                                                   const Handle(AIS_InteractiveObject)& theObject,
+                                                   const Standard_Integer               theDispMode,
+                                                   const Standard_Integer               theSelectionMode,
+                                                   const Standard_Boolean               theToUpdate = Standard_True,
+                                                   const Standard_Boolean               theReplaceIfExists = Standard_True);
+
   //! waits until a shape of type <aType> is picked in the AIS Viewer and returns it.
   //! if <aType> == TopAbs_Shape, any shape can be picked...
   //! MaxPick  is the Max number before exiting, if no pick is successful
index d183f8d0d1fa36908214546d91f4e9eb03d8a8b7..23a8929a43bc4654f62969306b4659380e5a1368 100644 (file)
 #include <gp_XYZ.hxx>
 #include <Standard_Dump.hxx>
 
+#include <Standard_WarningsDisable.hxx>
+#include <QApplication>
+#include <QFont>
+#include <Standard_WarningsRestore.hxx>
+
 IMPLEMENT_STANDARD_RTTIEXT(TreeModel_ItemProperties, Standard_Transient)
 
 // =======================================================================
@@ -128,11 +133,26 @@ QVariant TreeModel_ItemProperties::Data (const int theRow, const int theColumn,
       return aCachedValues[(int)theRole];
   }
 
-  if (theRole != Qt::DisplayRole && theRole != Qt::ToolTipRole)
-    return QVariant();
+  if (theRole == Qt::FontRole) // method name is in italic
+  {
+    if (Data(theRow, 0, Qt::DisplayRole).toString().contains("className"))
+    {
+      QFont aFont = qApp->font();
+      aFont.setItalic (true);
+      return aFont;
+    }
+  }
+  if (theRole == Qt::ForegroundRole)
+  {
+    if (Data(theRow, 0, Qt::DisplayRole).toString().contains("className"))
+      return QColor (Qt::darkGray).darker(150);
+  }
 
-  if (theColumn == 0) return RowValues().FindFromIndex (theRow + 1).myKey;
-  else if (theColumn == 1) return RowValues().FindFromIndex (theRow + 1).myValue;
+  if (theRole == Qt::DisplayRole || theRole == Qt::ToolTipRole)
+  {
+    if (theColumn == 0) return RowValues().FindFromIndex (theRow + 1).myKey;
+    else if (theColumn == 1) return RowValues().FindFromIndex (theRow + 1).myValue;
+  }
 
   return QVariant();
 }
index 92dd1f959b8c91450b91f359c6bb1ddf27035b3d..8b55d9d186cff17f65f9bb2f574544591ddd75f8 100644 (file)
@@ -148,15 +148,6 @@ void VInspector_ItemBVHTree::initStream (Standard_OStream& theOStream) const
   aBVHTree->DumpJson (theOStream);
 }
 
-// =======================================================================
-// function : createChild
-// purpose :
-// =======================================================================
-TreeModel_ItemBasePtr VInspector_ItemBVHTree::createChild (int theRow, int theColumn)
-{
-  return VInspector_ItemBVHTreeNode::CreateItem (currentItem(), theRow, theColumn);
-}
-
 // =======================================================================
 // function : buildPresentationShape
 // purpose :
@@ -197,3 +188,12 @@ TopoDS_Shape VInspector_ItemBVHTree::buildPresentationShape()
   }
   return aCompound;*/
 }
+
+// =======================================================================
+// function : createChild
+// purpose :
+// =======================================================================
+TreeModel_ItemBasePtr VInspector_ItemBVHTree::createChild (int theRow, int theColumn)
+{
+  return TreeModel_ItemBasePtr();
+}
index 03e8abe6912185e77635e6256e23519e9f0ff6e4..04907e14794d0170bd6e080442cdbea4dd357f17 100644 (file)
@@ -19,7 +19,7 @@
 #include <Standard_ExtString.hxx>
 #include <Standard_Version.hxx>
 
-#define USE_CLIPPLANE
+//#define USE_CLIPPLANE
 
 #ifdef USE_CLIPPLANE
 #include <Graphic3d_ClipPlane.hxx>