From: nds Date: Fri, 27 Dec 2019 16:12:29 +0000 (+0300) Subject: 0030268: Inspectors - improvements in VInspector plugin X-Git-Url: http://git.dev.opencascade.org/gitweb/?a=commitdiff_plain;h=31e1c545af65bbaa5b1594164546facf21fd9b54;p=occt-copy.git 0030268: Inspectors - improvements in VInspector plugin (cherry picked from commit 69db74767e3af40c5284cf350aa7501f4a59d06d) --- diff --git a/adm/templates/OpenCASCADEConfig.cmake.in b/adm/templates/OpenCASCADEConfig.cmake.in index 4937103b9c..f07d0de90a 100644 --- a/adm/templates/OpenCASCADEConfig.cmake.in +++ b/adm/templates/OpenCASCADEConfig.cmake.in @@ -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@ diff --git a/src/Standard/Standard_Dump.cxx b/src/Standard/Standard_Dump.cxx index 3157ba5581..e6831d98e5 100644 --- a/src/Standard/Standard_Dump.cxx +++ b/src/Standard/Standard_Dump.cxx @@ -19,10 +19,11 @@ // 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); } diff --git a/src/ViewerTest/ViewerTest.cxx b/src/ViewerTest/ViewerTest.cxx index 37df16d484..81a8f41dfe 100644 --- a/src/ViewerTest/ViewerTest.cxx +++ b/src/ViewerTest/ViewerTest.cxx @@ -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, diff --git a/src/ViewerTest/ViewerTest.hxx b/src/ViewerTest/ViewerTest.hxx index b9665cfc7d..925554b0cd 100644 --- a/src/ViewerTest/ViewerTest.hxx +++ b/src/ViewerTest/ViewerTest.hxx @@ -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 is picked in the AIS Viewer and returns it. //! if == TopAbs_Shape, any shape can be picked... //! MaxPick is the Max number before exiting, if no pick is successful diff --git a/tools/TreeModel/TreeModel_ItemProperties.cxx b/tools/TreeModel/TreeModel_ItemProperties.cxx index d183f8d0d1..23a8929a43 100644 --- a/tools/TreeModel/TreeModel_ItemProperties.cxx +++ b/tools/TreeModel/TreeModel_ItemProperties.cxx @@ -22,6 +22,11 @@ #include #include +#include +#include +#include +#include + 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(); } diff --git a/tools/VInspector/VInspector_ItemBVHTree.cxx b/tools/VInspector/VInspector_ItemBVHTree.cxx index 92dd1f959b..8b55d9d186 100644 --- a/tools/VInspector/VInspector_ItemBVHTree.cxx +++ b/tools/VInspector/VInspector_ItemBVHTree.cxx @@ -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(); +} diff --git a/tools/View/View_Viewer.cxx b/tools/View/View_Viewer.cxx index 03e8abe691..04907e1479 100644 --- a/tools/View/View_Viewer.cxx +++ b/tools/View/View_Viewer.cxx @@ -19,7 +19,7 @@ #include #include -#define USE_CLIPPLANE +//#define USE_CLIPPLANE #ifdef USE_CLIPPLANE #include