]> OCCT Git - occt-copy.git/commitdiff
0030268: Inspectors - improvements in VInspector plugin CR0_DMUReviewer_30268
authornds <nds@opencascade.com>
Thu, 6 Jun 2019 04:41:07 +0000 (07:41 +0300)
committernds <nds@opencascade.com>
Thu, 6 Jun 2019 04:41:07 +0000 (07:41 +0300)
- display BVH information in VInspector

44 files changed:
src/BVH/BVH_Box.hxx
src/BVH/BVH_Tree.hxx
src/BVH/BVH_Types.hxx
src/Bnd/Bnd_Box.cxx
src/Bnd/Bnd_Box.hxx
src/Bnd/Bnd_OBB.cxx
src/Bnd/Bnd_OBB.hxx
src/Message/Message.cxx
src/Message/Message.hxx
src/Message/Message_Alerts.hxx
src/Message/Message_AttributeVectorOfValues.cxx
src/Quantity/Quantity_Color.cxx
src/Quantity/Quantity_Color.hxx
src/Quantity/Quantity_ColorRGBA.hxx
src/SelectBasics/SelectBasics_PickResult.hxx
src/SelectMgr/SelectMgr_RectangularFrustum.cxx
tools/MessageModel/MessageModel_ItemAlert.cxx
tools/MessageModel/MessageModel_ItemAlert.hxx
tools/MessageView/MessageView_VisibilityState.cxx
tools/MessageView/MessageView_Window.cxx
tools/MessageView/MessageView_Window.hxx
tools/TInspectorEXE/TInspectorEXE.cxx
tools/TKTreeModel/EXTERNLIB
tools/VInspector/FILES
tools/VInspector/VInspector_ItemBVHTree.cxx
tools/VInspector/VInspector_ItemBVHTree.hxx
tools/VInspector/VInspector_ItemBVHTreeNode.cxx
tools/VInspector/VInspector_ItemBVHTreeNode.hxx
tools/VInspector/VInspector_ItemSelectBasicsEntityOwner.cxx
tools/VInspector/VInspector_ItemSelectMgrSelectableObjectSet.cxx
tools/VInspector/VInspector_ItemSelectMgrSensitiveEntitySet.cxx
tools/VInspector/VInspector_ItemSelectMgrSensitiveEntitySet.hxx
tools/VInspector/VInspector_ItemSelectMgrViewerSelector.cxx
tools/VInspector/VInspector_PreviewParameters.cxx [new file with mode: 0644]
tools/VInspector/VInspector_PreviewParameters.hxx [new file with mode: 0644]
tools/VInspector/VInspector_PropertiesCreator.cxx
tools/VInspector/VInspector_Tools.hxx
tools/VInspector/VInspector_Window.cxx
tools/VInspector/VInspector_Window.hxx
tools/View/View_Viewer.cxx
tools/ViewControl/ViewControl_PropertiesStream.cxx
tools/ViewControl/ViewControl_PropertiesStream.hxx
tools/ViewControl/ViewControl_Tools.cxx
tools/ViewControl/ViewControl_Tools.hxx

index 8210aa39ba3693d1a2c3581aa63ad08fc86621ba..4e7dfc94e72d2ced669afe68a996f17047f1782d 100644 (file)
@@ -18,6 +18,7 @@
 
 #include <BVH_Constants.hxx>
 #include <BVH_Types.hxx>
+#include <Message_Alerts.hxx>
 #include <Standard_ShortReal.hxx>
 
 #include <limits>
@@ -108,6 +109,18 @@ public:
   //! Returns center of bounding box along the given axis.
   T Center (const Standard_Integer theAxis) const;
 
+  //! Dumps the content of me on the stream <OS>.
+  void Dump (Standard_OStream& OS) const
+  {
+    DUMP_VALUES (OS, "BVH_Box", 2);
+    DUMP_VALUES (OS, "IsValid", IsValid());
+
+    DUMP_VALUES (OS, "Bnd_Box", BVH::ToBndBox (CornerMin(), CornerMax()).ToString());
+
+    //DUMP_VALUES (OS, "CornerMin", BVH::ToString (CornerMin()));
+    //DUMP_VALUES (OS, "CornerMin", BVH::ToString (CornerMax()));
+  }
+
 protected:
 
   BVH_VecNt        myMinPoint; //!< Minimum point of bounding box
index a223d14b30f868bb7042a26a5e6817070e267aa3..a46f717a50b01f80ec26c3d2f6125fc1d12293e9 100644 (file)
 
 #include <BVH_Box.hxx>
 
+#include <Message_Alerts.hxx>
+
+#include <Standard_Macro.hxx>
+#include <Standard_OStream.hxx>
+
 template<class T, int N> class BVH_Builder;
 
 //! A non-template class for using as base for BVH_TreeBase
@@ -27,6 +32,13 @@ class BVH_TreeBaseTransient : public Standard_Transient
   DEFINE_STANDARD_RTTIEXT(BVH_TreeBaseTransient, Standard_Transient)
 protected:
   BVH_TreeBaseTransient() {}
+
+  //! Dumps the content of me on the stream <OS>.
+  virtual void Dump (Standard_OStream& OS) const { (void)OS; }
+
+  //! Dumps the content of the given node on the stream <OS>.
+  virtual void DumpNode (const int theNodeIndex, Standard_OStream& OS) const
+  { (void)theNodeIndex; (void)OS; }
 };
 
 //! Stores parameters of bounding volume hierarchy (BVH).
@@ -178,6 +190,35 @@ public: //! @name methods for accessing serialized tree data
     return myMaxPointBuffer;
   }
 
+  //! Dumps the content of me on the stream <OS>.
+  Standard_EXPORT virtual void Dump (Standard_OStream& OS) const Standard_OVERRIDE
+  {
+    DUMP_VALUES (OS, "BVH_Tree", 2);
+
+    DUMP_VALUES (OS, "Depth", Depth());
+    DUMP_VALUES (OS, "Length", Length());
+
+    for (Standard_Integer aNodeIdx = 0; aNodeIdx < Length(); ++aNodeIdx)
+    {
+       DumpNode (aNodeIdx, OS);
+    }
+  }
+
+  //! Dumps the content of the given node on the stream <OS>.
+  Standard_EXPORT virtual void DumpNode (const int theNodeIndex, Standard_OStream& OS) const Standard_OVERRIDE
+  {
+    DUMP_VALUES (OS, "BVH_TreeNode", 2);
+    DUMP_VALUES (OS, "NodeIndex", theNodeIndex);
+
+    DUMP_VALUES (OS, "MinPoint - MaxPoint", BVH::ToBndBox (MinPoint (theNodeIndex), MaxPoint (theNodeIndex)).ToString());
+
+    DUMP_VALUES (OS, "BegPrimitive", BegPrimitive (theNodeIndex));
+    DUMP_VALUES (OS, "EndPrimitive", EndPrimitive (theNodeIndex));
+    DUMP_VALUES (OS, "Level",        Level (theNodeIndex));
+    DUMP_VALUES (OS, "IsOuter",      IsOuter (theNodeIndex));
+  }
+
+
 public: //! @name protected fields
 
   //! Array of node data records.
index 6cbf7ae9161392911dcf42480158ad959bc06323..fcbc66bca195ab65cdba56281f01b6a83993c3a1 100644 (file)
 
 #include <vector>
 
+#include <Bnd_Box.hxx>
 #include <NCollection_Mat4.hxx>
 #include <NCollection_Vec2.hxx>
 #include <NCollection_Vec3.hxx>
 #include <NCollection_Vector.hxx>
+#include <Standard_OStream.hxx>
 #include <Standard_Type.hxx>
 
 // GCC supports shrink function only in C++11 mode
@@ -57,6 +59,32 @@ namespace BVH
     typedef NCollection_Vec3<T> Type;
   };
 
+  template<class T> Bnd_Box ToBndBox (const T& theType1, const T& theType2)
+  {
+    return Bnd_Box (theType1, 0., 0., theType2, 0., 0.);
+  }
+
+  template<class T> Bnd_Box ToBndBox (const NCollection_Vec2<T>& theType1,
+                                      const NCollection_Vec2<T>& theType2)
+  {
+    return Bnd_Box (theType1.x(), theType1.y(), 0.,
+                    theType2.x(), theType2.y(), 0.);
+  }
+
+  template<class T> Bnd_Box ToBndBox (const NCollection_Vec3<T>& theType1,
+                                      const NCollection_Vec3<T>& theType2)
+  {
+    return Bnd_Box (theType1.x(), theType1.y(), theType1.z(),
+                    theType2.x(), theType2.y(), theType2.z());
+  }
+
+  template<class T> Bnd_Box ToBndBox (const NCollection_Vec4<T>& theType1,
+                                      const NCollection_Vec4<T>& theType2)
+  {
+    return Bnd_Box (theType1.x(), theType1.y(), theType1.z(),
+                    theType2.x(), theType2.y(), theType2.z());
+  }
+
   template<class T> struct VectorType<T, 4>
   {
     typedef NCollection_Vec4<T> Type;
index 3f9ea999ffbd32bc8d797e002328b740c5a35a99..d7e67d141ac86308f657d8217eb54235ea8feb99 100644 (file)
@@ -43,6 +43,19 @@ Bnd_Box::Bnd_Box()
   SetVoid();
 }
 
+//=======================================================================
+//function : Bnd_Box
+//purpose  : 
+//=======================================================================
+
+Bnd_Box::Bnd_Box (const Standard_Real theXmin, const Standard_Real theYmin, const Standard_Real theZmin,
+                  const Standard_Real theXmax, const Standard_Real theYmax, const Standard_Real theZmax)
+: Gap (0.0)
+{
+  SetVoid();
+  Update (theXmin, theYmin, theZmin, theXmax, theYmax, theZmax);
+}
+
 //=======================================================================
 //function : Set
 //purpose  : 
@@ -957,3 +970,49 @@ void Bnd_Box::Dump () const
   cout << "\n Gap : " << Gap;
   cout << "\n";
 }
+
+//=======================================================================
+//function : PointsSeparator
+//purpose  : 
+//=======================================================================
+TCollection_AsciiString PointsSeparator()
+{
+  return " - ";
+}
+
+//=======================================================================
+//function : ToString
+//purpose  : 
+//=======================================================================
+
+TCollection_AsciiString Bnd_Box::ToString() const
+{
+  return gp_XYZ (Xmin, Ymin, Zmin).ToString()
+        + PointsSeparator()
+        + gp_XYZ (Xmax, Ymax, Zmax).ToString();
+}
+
+//=======================================================================
+//function : FromString
+//purpose  : 
+//=======================================================================
+
+Standard_Boolean Bnd_Box::FromString (const TCollection_AsciiString& theValue)
+{
+  TCollection_AsciiString aCurrentString = theValue;
+  Standard_Integer aPosition = aCurrentString.Search (PointsSeparator());
+  if (aPosition < 0)
+    return Standard_False;
+
+  TCollection_AsciiString aLeftString = aCurrentString;
+  TCollection_AsciiString aRightString = aLeftString.Split (aPosition - 1);
+  aCurrentString = aRightString;
+  aRightString = aCurrentString.Split (PointsSeparator().Length());
+
+  gp_XYZ aMinPoint, aMaxPoint;
+  if (!aMinPoint.FromString (aLeftString) || !aMaxPoint.FromString (aRightString))
+    return Standard_False;
+
+  Update (aMinPoint.X(), aMinPoint.Y(), aMinPoint.Z(), aMaxPoint.X(), aMaxPoint.Y(), aMaxPoint.Z());
+  return Standard_True;
+}
index 301d9ad72cafe2cccac7e02388838aae000fa8bc..268db71f36e07a86bba674b40a0643136048b026 100644 (file)
 #include <Standard_Real.hxx>
 #include <Standard_Integer.hxx>
 #include <Standard_Boolean.hxx>
+
+#include <TCollection_AsciiString.hxx>
+#include <gp_XYZ.hxx>
+
 class Standard_ConstructionError;
 class gp_Pnt;
 class gp_Dir;
@@ -69,6 +73,14 @@ public:
   //! The constructed box is qualified Void. Its gap is null.
   Standard_EXPORT Bnd_Box();
 
+  //! Creates a bounding box, it contains:
+  //! -   interval [ aXmin,aXmax ] in the "X Direction",
+  //! -   interval [ aYmin,aYmax ] in the "Y Direction",
+  //! -   interval [ aZmin,aZmax ] in the "Z Direction";
+  //! The constructed box is qualified Void. Its gap is null.
+  Standard_EXPORT Bnd_Box (const Standard_Real aXmin, const Standard_Real aYmin, const Standard_Real aZmin,
+                           const Standard_Real aXmax, const Standard_Real aYmax, const Standard_Real aZmax);
+
   //! Sets this bounding box so that it  covers the whole of 3D space.
   //! It is infinitely  long in all directions.
   void SetWhole() { Flags = WholeMask; }
@@ -296,6 +308,14 @@ public:
          && Xmax >= Xmin;
   }
 
+  //! Covers bounding box into string in format: (Xmin, Ymin, Zmin) - (Xmax, Ymax, Zmax)
+  //! \return the string value
+  Standard_EXPORT TCollection_AsciiString ToString() const;
+
+  //! Converts text value into parameters if possible, the string format is: (Xmin, Ymin, Zmin) - (Xmax, Ymax, Zmax)
+  //! \return true if conversion is done
+  Standard_EXPORT Standard_Boolean FromString (const TCollection_AsciiString& theValue);
+
 protected:
 
   //! Bit flags.
index e9b7f36ea867049ecd1f4541414aca3d905c294c..d0b4382f7411aab4a28f9ba96f8abcd567c1f5b8 100644 (file)
@@ -677,3 +677,19 @@ void Bnd_OBB::Add(const Bnd_OBB& theOther)
   ReBuild(TColgp_Array1OfPnt(aList[0], 0, 15));
 }
 
+// =======================================================================
+// function : Init
+// purpose  : 
+// =======================================================================
+Standard_Boolean Bnd_OBB::Init (const Standard_OStream& OS)
+{
+  return Standard_False;
+}
+
+// =======================================================================
+// function : Dump
+// purpose  : 
+// =======================================================================
+void Bnd_OBB::Dump (Standard_OStream& OS) const
+{
+}
index d40d22ca93b24ac75e4b3fad99bc6670c49f11cd..065e67d959f262081ff6136b827fbfdcc761d96b 100644 (file)
@@ -20,6 +20,7 @@
 #include <Standard_Handle.hxx>
 #include <Standard_Real.hxx>
 #include <Standard_Boolean.hxx>
+#include <Standard_OStream.hxx>
 
 #include <Bnd_Box.hxx>
 #include <gp_Ax3.hxx>
@@ -276,6 +277,12 @@ public:
   //! (which it was created from) and theP.
   Standard_EXPORT void Add(const gp_Pnt& theP);
 
+  //! Dumps the content of me on the stream <OS>.
+  Standard_EXPORT Standard_Boolean Init (const Standard_OStream& OS);
+
+  //! Dumps the content of me on the stream <OS>.
+  Standard_EXPORT void Dump (Standard_OStream& OS) const;
+
 protected:
 
     void ProcessOnePoint(const gp_Pnt& theP)
index fe7d02c18078e8751ff8542797a4b12fdb5be085..c04816e92c087e86085576247e04d0d1b6c55391 100644 (file)
@@ -125,3 +125,228 @@ TCollection_AsciiString Message::PointerToString (const void* thePointer, const
   }
   return aPtrStr.str().c_str();
 }
+
+// =======================================================================
+// function : StrVectorToString
+// purpose :
+// =======================================================================
+TCollection_AsciiString Message::StrVectorToString
+    (const NCollection_Vector<TCollection_AsciiString>& theValues)
+{
+  TCollection_AsciiString aValue;
+  for (NCollection_Vector<TCollection_AsciiString>::Iterator aValuesIt (theValues); aValuesIt.More(); aValuesIt.Next())
+  {
+    aValue += aValuesIt.Value();
+    if (aValuesIt.More())
+      aValue += VectorSeparator();
+  }
+  return aValue;
+}
+
+// =======================================================================
+// function : StrVectorFromString
+// purpose :
+// =======================================================================
+Standard_Boolean Message::StrVectorFromString
+    (const TCollection_AsciiString& theValue,
+     NCollection_Vector<TCollection_AsciiString>& theValues)
+{
+  TCollection_AsciiString aCurrentString = theValue, aValueString;
+
+  while (!aCurrentString.IsEmpty())
+  {
+    Standard_Integer aPosition = aCurrentString.Search (", ");
+    aValueString = aCurrentString;
+    if (aPosition > 0)
+      aCurrentString = aValueString.Split (aPosition - 1);
+    theValues.Append (aValueString.RealValue());
+    if (aPosition > 0)
+      aCurrentString = aCurrentString.Split (2);
+  }
+  return Standard_True;
+}
+
+// =======================================================================
+// function : RealVectorToString
+// purpose :
+// =======================================================================
+TCollection_AsciiString Message::RealVectorToString
+    (const NCollection_Vector<Standard_Real>& theValues)
+{
+  TCollection_AsciiString aValue = ("(");
+
+  for (NCollection_Vector<Standard_Real>::Iterator aValuesIt (theValues); aValuesIt.More(); aValuesIt.Next())
+  {
+    aValue += aValuesIt.Value();
+    if (aValuesIt.More())
+      aValue += VectorSeparator();
+  }
+  aValue += ")";
+
+  return aValue;
+}
+
+// =======================================================================
+// function : RealVectorFromString
+// purpose :
+// =======================================================================
+Standard_Boolean Message::RealVectorFromString
+    (const TCollection_AsciiString& theValue,
+     NCollection_Vector<Standard_Real>& theValues)
+{
+  TCollection_AsciiString aCurrentString = theValue, aValueString;
+
+  Standard_Integer aPosition = aCurrentString.Search ("(");
+  if (aPosition != 1)
+    return Standard_False;
+  aCurrentString = aCurrentString.Split (aPosition);
+
+  aPosition = aCurrentString.Search (")");
+  if (aPosition != 1)
+    return Standard_False;
+  aValueString = aCurrentString.Split (aPosition);
+
+
+  while (!aCurrentString.IsEmpty())
+  {
+    // x value
+    aPosition = aCurrentString.Search (", ");
+    aValueString = aCurrentString;
+    if (aPosition > 0)
+      aCurrentString = aValueString.Split (aPosition - 1);
+    theValues.Append (aValueString.RealValue());
+    if (aPosition > 0)
+      aCurrentString = aCurrentString.Split (2);
+  }
+  return Standard_True;
+}
+
+// =======================================================================
+// function : CoordVectorToString
+// purpose :
+// =======================================================================
+TCollection_AsciiString Message::CoordVectorToString
+    (const NCollection_Vector<Standard_Real>& theValues)
+{
+  TCollection_AsciiString aValue = ("(");
+  aValue += RealVectorToString (theValues);
+  aValue += ")";
+
+  return aValue;
+}
+
+// =======================================================================
+// function : CoordVectorFromString
+// purpose :
+// =======================================================================
+Standard_Boolean Message::CoordVectorFromString
+    (const TCollection_AsciiString& theValue,
+     NCollection_Vector<Standard_Real>& theValues)
+{
+  TCollection_AsciiString aCurrentString = theValue, aValueString;
+
+  Standard_Integer aPosition = aCurrentString.Search ("(");
+  if (aPosition != 1)
+    return Standard_False;
+  aCurrentString = aCurrentString.Split (aPosition);
+
+  aPosition = aCurrentString.Search (")");
+  if (aPosition != 1)
+    return Standard_False;
+  aValueString = aCurrentString.Split (aPosition);
+
+  return RealVectorFromString (aCurrentString, theValues); 
+}
+
+// =======================================================================
+// function : ColorVectorToString
+// purpose :
+// =======================================================================
+TCollection_AsciiString Message::ColorVectorToString
+    (const NCollection_Vector<Standard_Real>& theValues)
+{
+  TCollection_AsciiString aValue = ("[");
+  aValue += RealVectorToString (theValues);
+  aValue += "]";
+
+  return aValue;
+}
+
+// =======================================================================
+// function : ColorVectorFromString
+// purpose :
+// =======================================================================
+Standard_Boolean Message::ColorVectorFromString
+    (const TCollection_AsciiString& theValue,
+     NCollection_Vector<Standard_Real>& theValues)
+{
+  TCollection_AsciiString aCurrentString = theValue, aValueString;
+
+  Standard_Integer aPosition = aCurrentString.Search ("[");
+  if (aPosition != 1)
+    return Standard_False;
+  aCurrentString = aCurrentString.Split (aPosition);
+
+  aPosition = aCurrentString.Search ("]");
+  if (aPosition != 1)
+    return Standard_False;
+  aValueString = aCurrentString.Split (aPosition);
+
+  return RealVectorFromString (aCurrentString, theValues); 
+}
+
+// =======================================================================
+// function : ConvertStream
+// purpose :
+// =======================================================================
+void Message::ConvertStream (const Standard_SStream& theStream,
+  Standard_Integer& theColumnCount,
+  NCollection_Vector<TCollection_AsciiString>& theValues)
+{
+  TCollection_AsciiString aStream (theStream.str().c_str());
+  Standard_Character aSeparator = Message::DumpSeparator();
+  Standard_Integer aColumnCount = 0;
+
+  TCollection_AsciiString aCurrentString = aStream;
+  Standard_Integer aPosition = aCurrentString.Search (aSeparator);
+  if (aPosition >= 1)
+  {
+    TCollection_AsciiString aTailString = aCurrentString.Split (aPosition);
+    Standard_Boolean aClassNameFound = Standard_False;
+    while (!aCurrentString.IsEmpty())
+    {
+      TCollection_AsciiString aValueString = aCurrentString;
+      aPosition = aValueString.Search (aSeparator);
+      if (aPosition < 0 )
+        break;
+      aCurrentString = aValueString.Split (aPosition - 1);
+
+      if (!aColumnCount)
+      {
+        if (!aClassNameFound)
+          aClassNameFound = Standard_True;
+        else
+        {
+          if (!aValueString.IsIntegerValue())
+            break; // not correct Dump, in correct the first value is number of property columns
+          aColumnCount = aValueString.IntegerValue();
+        }
+      }
+      else
+        theValues.Append (aValueString);
+
+      if (aTailString.IsEmpty())
+        break;
+      aCurrentString = aTailString;
+      aPosition = aCurrentString.Search (aSeparator);
+      if (aPosition < 0 )
+      {
+        aCurrentString = aTailString;
+        aTailString = TCollection_AsciiString();
+      }
+      else
+        aTailString = aCurrentString.Split (aPosition);
+    }
+  }
+  theColumnCount = aColumnCount;
+}
index 96feb8de0d8f4d385f46fa1fa03c6fdb4ccb1e30..7f9c44a5abe15ae19b488fdec87139d439f87095 100644 (file)
@@ -18,6 +18,7 @@
 #define _Message_HeaderFile
 
 #include <Message_Gravity.hxx>
+#include <NCollection_Vector.hxx>
 
 #include <Standard.hxx>
 #include <Standard_DefineAlloc.hxx>
@@ -25,8 +26,9 @@
 
 #include <Standard_Integer.hxx>
 #include <Standard_Real.hxx>
+#include <TCollection_AsciiString.hxx>
+
 class Message_Messenger;
-class TCollection_AsciiString;
 class Message_Msg;
 class Message_MsgFile;
 class Message_Messenger;
@@ -86,6 +88,9 @@ public:
   //! Returns separator symbol of Dump information
   static Standard_Character DumpSeparator() { return '\\'; }
 
+  //! Returns separator symbol of values vector union
+  static TCollection_AsciiString VectorSeparator() { return " ,"; }
+
   //! Convert handle pointer to string value
   //! \param thePointer a pointer
   //! \param isShortInfo if true, all '0' symbols in the beginning of the pointer are skipped
@@ -99,6 +104,65 @@ public:
   //! \return the string value
   Standard_EXPORT static TCollection_AsciiString PointerToString (const void* thePointer,
                                                                   const bool isShortInfo = true);
+  //! Convert vector of real values to string, separator is vector separator
+  //! \param thePointer a container of real values
+  //! \return the string value
+  Standard_EXPORT static TCollection_AsciiString StrVectorToString
+    (const NCollection_Vector<TCollection_AsciiString>& theValues);
+
+  //! Convert string to vector of real values, separator is vector separator
+  //! \param thePointer a container of real values
+  //! \return the string value
+  Standard_EXPORT static Standard_Boolean StrVectorFromString
+    (const TCollection_AsciiString& theValue,
+     NCollection_Vector<TCollection_AsciiString>& theValues);
+
+  //! Convert vector of real values to string, separator is vector separator
+  //! \param thePointer a container of real values
+  //! \return the string value
+  Standard_EXPORT static TCollection_AsciiString RealVectorToString
+    (const NCollection_Vector<Standard_Real>& theValues);
+
+  //! Convert string to vector of real values, separator is vector separator
+  //! \param thePointer a container of real values
+  //! \return the string value
+  Standard_EXPORT static Standard_Boolean RealVectorFromString
+    (const TCollection_AsciiString& theValue,
+     NCollection_Vector<Standard_Real>& theValues);
+
+  //! Convert vector of real values to string, separator is vector separator
+  //! \param thePointer a container of real values
+  //! \return the string value
+  Standard_EXPORT static TCollection_AsciiString CoordVectorToString
+    (const NCollection_Vector<Standard_Real>& theValues);
+
+  //! Convert string to vector of real values, separator is vector separator
+  //! \param thePointer a container of real values
+  //! \return the string value
+  Standard_EXPORT static Standard_Boolean CoordVectorFromString
+    (const TCollection_AsciiString& theValue,
+     NCollection_Vector<Standard_Real>& theValues);
+
+  //! Convert vector of real values to string, separator is vector separator
+  //! \param thePointer a container of real values
+  //! \return the string value
+  Standard_EXPORT static TCollection_AsciiString ColorVectorToString
+    (const NCollection_Vector<Standard_Real>& theValues);
+
+  //! Convert string to vector of real values, separator is vector separator
+  //! \param thePointer a container of real values
+  //! \return the string value
+  Standard_EXPORT static Standard_Boolean ColorVectorFromString
+    (const TCollection_AsciiString& theValue,
+     NCollection_Vector<Standard_Real>& theValues);
+
+  //! Converts stream to vector of values and column count
+  //! \param theStream stream value
+  //! \param theColumnCount [out] number of columns
+  //! \param theValues [out] container of split values
+  static Standard_EXPORT void ConvertStream (const Standard_SStream& theStream,
+    Standard_Integer& theColumnCount,
+    NCollection_Vector<TCollection_AsciiString>& theValues);
 
 protected:
 
index 267cc8c8e17f0b92b6965567e876a58c6094c7c3..d1789025b2f07ff7f4aba23dc334860e149ad73d 100644 (file)
@@ -23,6 +23,9 @@
 #include <Message_Gravity.hxx>
 #include <Message_Report.hxx>
 
+#include <NCollection_Vector.hxx>
+#include <TCollection_AsciiString.hxx>
+
 static Handle(Message_Alert) OCCT_Message_Alert;
 
 #define MESSAGE_INFO(Name, Description, PerfMeter, ParentAlert) \
@@ -70,5 +73,30 @@ static Handle(Message_Alert) OCCT_Message_Alert;
     OS << Value1 << Message::DumpSeparator() << Value2 << Message::DumpSeparator(); \
   }
 
+#define DUMP_VEC_COLOR(Values, Value) \
+  { \
+    Value = Message::ColorVectorToString (aValues); \
+  }
+
+#define DUMP_VEC_COLOR_SPLIT(Value, Values) \
+  { \
+    Message::ColorVectorFromString (Value, Values); \
+  }
+
+#define DUMP_VEC_COORD(Values, Value) \
+  { \
+    Value = Message::CoordVectorToString (aValues); \
+  }
+
+#define DUMP_VEC_COORD_SPLIT(Value, Values) \
+  { \
+    Message::CoordVectorFromString (Value, Values); \
+  }
+
+
+#define DUMP_VALUES_SPLIT(OS, ColumnCount, Values) \
+  { \
+    Message::ConvertStream (OS, aColumnCount, aValues); \
+  }
 
 #endif // _Message_Alerts_HeaderFile
index fcbb2fc9d223f224638d2ce9cce9c18c4e42e390..3d389a1f45fff8f4365cf53df3f740f8d38b7bce 100644 (file)
@@ -40,7 +40,6 @@ Message_AttributeVectorOfValues::Message_AttributeVectorOfValues (const Standard
   if (aPosition >= 1)
   {
     TCollection_AsciiString aTailString = aCurrentString.Split (aPosition);
-    Standard_Integer aRow = 0;
     Standard_Boolean aClassNameFound = Standard_False;
     while (!aCurrentString.IsEmpty())
     {
index 3c056ff8ebf889c653cfd42a668d8808c99a2336..cd711d7954407039aff9d8c222f9d13bcf39328b 100644 (file)
@@ -15,6 +15,8 @@
 
 #include <Quantity_Color.hxx>
 
+#include <Message_Alerts.hxx>
+#include <NCollection_Vector.hxx>
 #include <Quantity_ColorDefinitionError.hxx>
 #include <Standard_ErrorHandler.hxx>
 #include <Standard_OutOfRange.hxx>
@@ -3908,3 +3910,33 @@ void call_rgbhls (float r, float g, float b, float& h, float& l, float& s)
           if (h < 0.0) h += 360.0;
        }
 }
+
+TCollection_AsciiString Quantity_Color::ToString() const
+{
+  NCollection_Vector<Standard_Real> aValues;
+  aValues.Append (MyRed);
+  aValues.Append (MyGreen);
+  aValues.Append (MyBlue);
+
+  Standard_SStream OS;
+
+  TCollection_AsciiString aValue;
+  DUMP_VEC_COLOR(aValues, aValue)
+
+  return aValue;
+}
+
+Standard_Boolean Quantity_Color::FromString (const TCollection_AsciiString& theValue)
+{
+  NCollection_Vector<Standard_Real> aValues;
+  DUMP_VEC_COLOR_SPLIT (theValue, aValues)
+
+  if (aValues.Size() != 3)
+    return Standard_False;
+
+  MyRed = (Standard_ShortReal)aValues.Value (0);
+  MyGreen = (Standard_ShortReal)aValues.Value (1);
+  MyBlue = (Standard_ShortReal)aValues.Value (2);
+
+  return Standard_True;
+}
index a31c38da5ddc47a082ef1bb7ce63c9e94a3a89f0..a32c04a111c69fa1e990f4cde6700ffe9d09c933 100644 (file)
@@ -21,6 +21,7 @@
 #include <Standard_Handle.hxx>
 
 #include <Standard_ShortReal.hxx>
+#include <TCollection_AsciiString.hxx>
 #include <Quantity_NameOfColor.hxx>
 #include <Quantity_TypeOfColor.hxx>
 #include <Standard_Real.hxx>
@@ -240,6 +241,14 @@ Standard_Boolean operator == (const Quantity_Color& Other) const
   //! Internal test
   Standard_EXPORT static void Test();
 
+  //! Covers point into string in format: (X, Y, Z)
+  //! \return the string value
+  Standard_EXPORT TCollection_AsciiString ToString() const;
+
+  //! Converts text value into parameters if possible, the string format is: (X, Y, Z)
+  //! \return true if conversion is done
+  Standard_EXPORT Standard_Boolean FromString (const TCollection_AsciiString& theValue);
+
 private:
 
   //! Converts HLS components into RGB ones.
index 8f91d9fea37b7501fc4748fd2cd7fb8da916ddb6..dddcaa9695c6dc7355d32806421235b02b6ac3e6 100644 (file)
@@ -14,6 +14,8 @@
 #ifndef _Quantity_ColorRGBA_HeaderFile
 #define _Quantity_ColorRGBA_HeaderFile
 
+#include <Message_Alerts.hxx>
+#include <NCollection_Vector.hxx>
 #include <Quantity_Color.hxx>
 #include <Standard_Assert.hxx>
 
@@ -91,6 +93,40 @@ public:
   //! Two colors are considered to be equal if their distance is no greater than Epsilon().
   bool operator== (const Quantity_ColorRGBA& theOther) const { return IsEqual (theOther); }
 
+
+  //! Covers point into string in format: (X, Y, Z)
+  //! \return the string value
+  Standard_EXPORT TCollection_AsciiString ToString() const
+  {
+    NCollection_Vector<Standard_Real> aValues;
+    aValues.Append (myRgb.Red());
+    aValues.Append (myRgb.Green());
+    aValues.Append (myRgb.Blue());
+    aValues.Append (myAlpha);
+
+    TCollection_AsciiString aValue;
+    DUMP_VEC_COORD (aValues, aValue);
+    return aValue;
+  }
+
+
+  //! Converts text value into parameters if possible, the string format is: (X, Y, Z)
+  //! \return true if conversion is done
+  Standard_EXPORT Standard_Boolean FromString (const TCollection_AsciiString& theValue)
+  {
+    NCollection_Vector<Standard_Real> aValues;
+    DUMP_VEC_COORD_SPLIT (theValue, aValues)
+
+    if (aValues.Size() != 3)
+      return Standard_False;
+
+    myRgb = Quantity_Color (aValues.Value (0), aValues.Value (1), aValues.Value (2),
+                            Quantity_TOC_RGB);
+    myAlpha = (Standard_ShortReal)aValues.Value (3);
+
+    return Standard_True;
+  }
+
 private:
 
   static void myTestSize3() { Standard_STATIC_ASSERT (sizeof(float) * 3 == sizeof(Quantity_Color)); }
index 03bcc16a49b2469246feba34ee205536ea51fb5f..4f45c8906d6b89d9e402e59220a3cd401d13a506 100644 (file)
@@ -17,6 +17,9 @@
 #define _SelectBasics_PickResult_HeaderFile
 
 #include <Standard.hxx>
+#include <Standard_OStream.hxx>
+
+#include <Message_Alerts.hxx>
 #include <NCollection_Vec4.hxx>
 
 //! This structure provides unified access to the results of Matches() method in all sensitive entities,
@@ -80,6 +83,15 @@ public:
   //! Set distance to geometry center.
   void SetDistToGeomCenter (Standard_Real theDistToCenter) { myDistToCenter = theDistToCenter; }
 
+  //! Dumps the content of me on the stream <OS>.
+  void Dump (Standard_OStream& OS) const
+  {
+    DUMP_VALUES (OS, "SelectBasics_PickResult", 2);
+    DUMP_VALUES (OS, "myObjPickedPnt", myObjPickedPnt.XYZ().ToString());
+    DUMP_VALUES (OS, "myDepth", myDepth);
+    DUMP_VALUES (OS, "myDistToCenter", myDistToCenter);
+  }
+
 private:
   gp_Pnt        myObjPickedPnt; //!< User-picked selection point onto object
   Standard_Real myDepth;        //!< Depth to detected point
index 81f939f7c1fc86a1c48a4b4d24ec8dcdfd966500..7bcd7d835312b8ca1a4c2aa6af14db019f560d7b 100644 (file)
@@ -441,7 +441,9 @@ Standard_Boolean SelectMgr_RectangularFrustum::Overlaps (const SelectMgr_Vec3& t
                                                          Standard_Boolean*     theInside) const
 {
   Message_PerfMeter aPerfMeter; 
-  MESSAGE_INFO ("SelectMgr_RectangularFrustum::Overlaps_vvb", "", &aPerfMeter, NULL);
+  Bnd_Box aBox (theBoxMin.x(), theBoxMin.y(), theBoxMin.z(),
+                theBoxMax.x(), theBoxMax.y(), theBoxMax.z());
+  MESSAGE_INFO ("SelectMgr_RectangularFrustum::Overlaps_vvb", aBox.ToString(), &aPerfMeter, NULL);
   return hasOverlap (theBoxMin, theBoxMax, theInside);
 }
 
index c05a71b800c95ae2f8d5056c791c428c58005c60..b94e5ac006bf00ff298ec61da53516d3215bd988 100644 (file)
 #include <inspector/MessageModel_ItemRoot.hxx>
 #include <inspector/MessageModel_ItemReport.hxx>
 #include <inspector/MessageModel_Tools.hxx>
+#include <inspector/ViewControl_Tools.hxx>
+#include <inspector/ViewControl_TransientShape.hxx>
 #include <inspector/TreeModel_Tools.hxx>
 
 #include <Message_AlertExtended.hxx>
+#include <Message_AttributeObject.hxx>
 #include <Message_AttributeVectorOfValues.hxx>
 #include <Message_CompositeAlerts.hxx>
 
+#include <Bnd_Box.hxx>
 #include <TCollection_AsciiString.hxx>
 #include <TopoDS_AlertAttribute.hxx>
 
@@ -32,6 +36,7 @@
 #include <QIcon>
 #include <Standard_WarningsRestore.hxx>
 
+
 // =======================================================================
 // function : initValue
 // purpose :
@@ -208,6 +213,23 @@ void MessageModel_ItemAlert::Init()
       }
     }
   }
+
+  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 (anAttribute->IsKind (STANDARD_TYPE (Message_AttributeObject)))
+        myPresentations.Append (Handle(Message_AttributeObject)::DownCast (anAttribute)->GetObject());
+      if (anAttribute->IsKind (STANDARD_TYPE (TopoDS_AlertAttribute)))
+        myPresentations.Append (new ViewControl_TransientShape (Handle(TopoDS_AlertAttribute)::DownCast (anAttribute)->GetShape()));
+    }
+    TCollection_AsciiString aDescription = anExtendedAlert->Attribute()->GetDescription();
+    Bnd_Box aBox;
+    if (aBox.FromString (aDescription))
+      myPresentations.Append (new ViewControl_TransientShape (ViewControl_Tools::CreateShape (aBox)));
+  }
   MessageModel_ItemBase::Init();
 }
 
@@ -221,6 +243,7 @@ void MessageModel_ItemAlert::Reset()
   myAlert = Handle(Message_Alert)();
   myUnitedAlerts.Clear();
   myChildAlerts.Clear();
+  myPresentations.Clear();
 }
 
 // =======================================================================
index f32df889d781ee4da510e259b8a99d26692b479e..f139fb54c2266faec87653dcbbe4c758a35ac748 100644 (file)
@@ -29,6 +29,7 @@
 #include <QVariant>
 #include <Standard_WarningsRestore.hxx>
 
+#include <NCollection_List.hxx>
 #include <NCollection_Vector.hxx>
 
 class QAbstractTableModel;
@@ -84,6 +85,14 @@ public:
   //! \return instance of the shape
   const TopoDS_Shape& GetCustomShape() const { return myCustomShape; }
 
+  //! Returns presentation of the attribute to be visualized in the view
+  //! \param theRow a model index row
+  //! \param theColumn a model index column
+  //! \thePresentations [out] container of presentation handles to be visualized
+  void GetPresentations (NCollection_List<Handle(Standard_Transient)>& thePresentations)
+  { thePresentations.Append (myPresentations); }
+
+
   //! Returns summ of children alert elapsed times. The method is recusive.
   //! \param theAlert a message alert
   //! \return double value
@@ -126,6 +135,7 @@ private:
   NCollection_DataMap<Standard_Integer, Message_ListOfAlert> myChildAlerts; //!< container of child alerts
 
   TopoDS_Shape myCustomShape;
+  NCollection_List<Handle(Standard_Transient)> myPresentations;
 };
 
 #endif
index 8b4207b8fb74699b31d776b1e88db6736dedae27..cec2d932df323d9cd738955b4d647e6058e0d3a1 100644 (file)
 // =======================================================================
 bool MessageView_VisibilityState::CanBeVisible (const QModelIndex& theIndex) const
 {
+  MessageModel_ItemAlertPtr anAlertItem = getAlertItem (theIndex);
+  if (anAlertItem)
+  {
+    NCollection_List<Handle(Standard_Transient)> aPresentations;
+    anAlertItem->GetPresentations (aPresentations);
+    if (!aPresentations.IsEmpty())
+      return true;
+  }
+
   return !getShape (theIndex).IsNull();// || hasTableValues (theIndex);
 }
 
index 575ca8445d7f8889e5c6836bdfa4af19bee5e154..ad8895e831e3c72fa6124ade8e3772648922aab6 100644 (file)
@@ -30,6 +30,7 @@
 #include <inspector/ViewControl_PropertyView.hxx>
 #include <inspector/ViewControl_TableModelValues.hxx>
 #include <inspector/ViewControl_TreeView.hxx>
+#include <inspector/ViewControl_TransientShape.hxx>
 
 #include <inspector/View_Tools.hxx>
 #include <inspector/View_Viewer.hxx>
@@ -100,6 +101,39 @@ const int MESSAGEVIEW_DEFAULT_TREE_VIEW_HEIGHT = 500;
 const int MESSAGEVIEW_DEFAULT_VIEW_WIDTH = 200;// 400;
 const int MESSAGEVIEW_DEFAULT_VIEW_HEIGHT = 300;// 1000;
 
+#include <Prs3d_PointAspect.hxx>
+#include <Prs3d_ShadingAspect.hxx>
+Handle(Prs3d_Drawer) GetPreviewAttributes (const Handle(AIS_InteractiveContext)& theContext)
+{
+  Handle(Prs3d_Drawer) myDrawer = new Prs3d_Drawer();
+  myDrawer->Link (theContext->DefaultDrawer());
+
+  Quantity_Color aColor(Quantity_NOC_TOMATO);//Quantity_NOC_GREENYELLOW));//Quantity_NOC_BLUE1));
+  Standard_ShortReal aTransparency = 0.8;
+
+  // point parameters
+  myDrawer->SetPointAspect (new Prs3d_PointAspect (Aspect_TOM_O_PLUS, aColor, 3.0));
+
+  // shading parameters
+  Graphic3d_MaterialAspect aShadingMaterial;
+  aShadingMaterial.SetReflectionModeOff (Graphic3d_TOR_SPECULAR);
+  aShadingMaterial.SetMaterialType (Graphic3d_MATERIAL_ASPECT);
+
+  myDrawer->SetShadingAspect (new Prs3d_ShadingAspect());
+  myDrawer->ShadingAspect()->Aspect()->SetInteriorStyle (Aspect_IS_SOLID);
+  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);
+
+  return myDrawer;
+}
+
 // =======================================================================
 // function : Constructor
 // purpose :
@@ -326,7 +360,10 @@ void MessageView_Window::Init (NCollection_List<Handle(Standard_Transient)>& the
   aTreeModel->EmitLayoutChanged();
 
   if (!aContext.IsNull())
+  {
+    myContext = aContext;
     myViewWindow->SetContext (View_ContextType_External, aContext);
+  }
 
   if (!aViewCamera.IsNull())
     myViewWindow->GetView()->GetViewer()->GetView()->Camera()->Copy (aViewCamera);
@@ -393,6 +430,26 @@ void MessageView_Window::onTreeViewSelectionChanged (const QItemSelection&, cons
     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;
+
+    MessageModel_ItemAlertPtr anAlertItem = itemDynamicCast<MessageModel_ItemAlert>(anItemBase);
+    if (!anAlertItem)
+      continue;
+    anAlertItem->GetPresentations (aPresentations);
+  }
+  updatePreviewPresentation (aPresentations);
 }
 
 // =======================================================================
@@ -655,3 +712,76 @@ void MessageView_Window::updatePropertyPanelBySelection()
 
   myPropertyView->Init (aTableValues);
 }
+
+// =======================================================================
+// function : updatePreviewPresentation
+// purpose :
+// =======================================================================
+void MessageView_Window::updatePreviewPresentation (const NCollection_List<Handle(Standard_Transient)>& thePresentations)
+{
+  if (myContext.IsNull())
+    return;
+
+  Handle(AIS_InteractiveContext) aContext = myContext;
+
+  if (!myPreviewPresentations.IsEmpty())
+  {
+    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())
+        aContext->Remove (aPrs, Standard_True);
+    }
+  }
+  myPreviewPresentations.Clear();
+
+  myPreviewPresentations = thePresentations;
+  if (myPreviewPresentations.IsEmpty())
+    return;
+
+  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())
+    {
+      aContext->Display (aPrs, AIS_Shaded, -1/*do not participate in selection*/, Standard_True);
+    }
+    else if (!Handle(ViewControl_TransientShape)::DownCast (aDisplayedIt.Value()).IsNull())
+    {
+      Handle(ViewControl_TransientShape) aShapeObject = Handle(ViewControl_TransientShape)::DownCast (aDisplayedIt.Value());
+      aBuilder.Add (aCompound, aShapeObject->GetShape());
+    }
+  }
+
+  if (aCompound.IsNull())
+  {
+    if (!aContext.IsNull())
+      aContext->Remove (myPreviewPresentation, Standard_True);
+    myPreviewPresentation = NULL;
+    return;
+
+  }
+  else
+  {
+    if (myPreviewPresentation.IsNull())
+    {
+      myPreviewPresentation = new AIS_Shape (aCompound);
+      myPreviewPresentation->SetAttributes (GetPreviewAttributes(myContext));
+      //myPreviewPresentation->SetAttributes (myPreviewParameters->GetDrawer());
+
+      //myPreviewPresentation->SetTransformPersistence(thePersistent);
+      if (!aContext.IsNull())
+        aContext->Display (myPreviewPresentation, AIS_Shaded, -1/*do not participate in selection*/, Standard_True);
+    }
+    else
+    {
+      Handle(AIS_Shape)::DownCast (myPreviewPresentation)->Set (aCompound);
+      //myPreviewPresentation->SetTransformPersistence(thePersistent);
+      if (!aContext.IsNull())
+        aContext->Redisplay (myPreviewPresentation, Standard_True);
+    }
+  }
+}
index 31d5b4ce7b208e417d01680c03cfa19fa5e7f6c0..a4ace53694fd3795d3be77bbef56d7aa5ee49f91 100644 (file)
 #include <TCollection_AsciiString.hxx>
 
 #include <inspector/MessageModel_Actions.hxx>
-
 #include <inspector/TInspectorAPI_PluginParameters.hxx>
 
+#include <AIS_InteractiveContext.hxx>
+#include <AIS_InteractiveObject.hxx>
+#include <TopoDS_Shape.hxx>
+
 #ifdef _MSC_VER
 #pragma warning(disable : 4127) // conditional expression is constant
 #endif
@@ -158,6 +161,10 @@ 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);
+
 private:
   QMainWindow* myMainWindow; //!< main control, parent for all MessageView controls
   QDockWidget* myViewDockWidget; //!< view dock widget to hide/show
@@ -171,6 +178,10 @@ private:
 
   Handle(TInspectorAPI_PluginParameters) myParameters; //!< plugins parameters container
   Handle(Message_ReportCallBack) myCallBack; //! < message call back to update content of the view
+
+  Handle(AIS_InteractiveContext) myContext; //! current context
+  Handle(AIS_InteractiveObject) myPreviewPresentation; //!< presentation of preview for a selected object
+  NCollection_List<Handle(Standard_Transient)> myPreviewPresentations;
 };
 
 #endif
index 3d3fd453040f1cec2d233763c25dc6439cd9e2b4..5743c1e0d197cd85718f0b538a16d93e2e0559f5 100644 (file)
@@ -66,7 +66,7 @@ void setPluginSampleDirectory (const TCollection_AsciiString& theName, TInspecto
       aFileName = fileNameInDataDir ("CSF_OCCTDataPath", "occ/hammer.brep");
     else if (theName.IsEqual ("TKVInspector"))
     {
-      aFileName = fileNameInDataDir ("CSF_OCCTDataPath", "occ/face1.brep");
+      //aFileName = fileNameInDataDir ("CSF_OCCTDataPath", "occ/face1.brep");
       anAdditionalFileName = fileNameInDataDir ("CSF_OCCTDataPath", "occ/face2.brep");
     }
     aRecentlyOpenedFiles.append (aFileName.ToCString());
@@ -127,8 +127,8 @@ int main (int argc, char** argv)
     aPlugins.insert("TKVInspector");
 
     Handle(Message_Report) aReport = Message_Report::CurrentReport (Standard_True);
-    aReport->SetLimit(30);
-    aReport->SetActive (Standard_False);
+    aReport->SetLimit (100);//30);
+    aReport->SetActive (Standard_True);//Standard_False);
     aPlugins.insert("TKMessageView");
 
     anActivatedPluginName = "TKVInspector";
index 37f0830243e80ebd23c0ab72e3cad43fae80a818..faee5c912f1f7c572b7f1694ddf7b747923d89e3 100644 (file)
@@ -1,4 +1,5 @@
 TKernel
 TKMath
+TKPrim
 TKTopAlgo
 CSF_QT
\ No newline at end of file
index 0609ab6810d566761d9b2ef2ea8deb62283830d1..983606430efcaca2cc73d820911ae8b82d709c7b 100644 (file)
@@ -87,6 +87,8 @@ VInspector_ItemV3dView.cxx
 VInspector_ItemV3dView.hxx
 VInspector_ItemV3dViewer.cxx
 VInspector_ItemV3dViewer.hxx
+VInspector_PreviewParameters.cxx
+VInspector_PreviewParameters.hxx
 VInspector_PropertiesCreator.cxx
 VInspector_PropertiesCreator.hxx
 VInspector_PrsOpenGlElement.cxx
index 5a13706816dc7936f56a81e69cbc61eeb80f6666..8bcd7e328ee9785f6a371139986af39c0c6d03cf 100644 (file)
 #include <inspector/VInspector_ItemBVHTree.hxx>
 
 #include <inspector/VInspector_ItemSelectMgrSelectableObjectSet.hxx>
+#include <inspector/VInspector_ItemSelectMgrSensitiveEntitySet.hxx>
 #include <inspector/VInspector_ItemBVHTreeNode.hxx>
+#include <inspector/VInspector_Tools.hxx>
+#include <inspector/ViewControl_PropertiesStream.hxx>
+
+#include <Bnd_Box.hxx>
+#include <BRep_Builder.hxx>
+#include <TopoDS_Compound.hxx>
 
 // =======================================================================
 // function : Constructor
@@ -81,24 +88,22 @@ QVariant VInspector_ItemBVHTree::initValue (const int theItemRole) const
 
 void VInspector_ItemBVHTree::Init()
 {
-  VInspector_ItemSelectMgrSelectableObjectSetPtr aParentItem = itemDynamicCast<VInspector_ItemSelectMgrSelectableObjectSet>(Parent());
-
-  //! Returns child BVH tree of the row
-  setTree (aParentItem->GetBVHTree (Row(), myName));
+  VInspector_ItemSelectMgrSelectableObjectSetPtr anObjectParent = itemDynamicCast<VInspector_ItemSelectMgrSelectableObjectSet>(Parent());
+  opencascade::handle<BVH_Tree<Standard_Real, 3> > aBVHTree;
+  if (anObjectParent)
+  {
+    aBVHTree = anObjectParent->GetBVHTree (Row(), myName);
+  }
+  else
+  {
+    VInspector_ItemSelectMgrSensitiveEntitySetPtr anEntityParent = itemDynamicCast<VInspector_ItemSelectMgrSensitiveEntitySet>(Parent());
+    if (anEntityParent)
+      aBVHTree = anEntityParent->GetBVHTree (Row(), myName);
+  }
 
-  //Handle(SelectMgr_ViewerSelector) aViewerSelector;
-  //if (aParentItem)
-  //{
-  //  VInspector_ItemContextPtr aParentContextItem = itemDynamicCast<VInspector_ItemContext>(aParentItem->Parent());
-  //  if (aParentContextItem)
-  //  {
-  //    Handle(AIS_InteractiveContext) aContext = aParentContextItem->GetContext();
-  //    aViewerSelector = aContext->MainSelector();
-  //  }
-  //}
-  //setViewerSelector (aViewerSelector);
+  setTree (aBVHTree);
 
-  //UpdatePresentationShape();
+  UpdatePresentationShape();
   TreeModel_ItemBase::Init(); // to use getIO() without circling initialization
 }
 
@@ -128,132 +133,64 @@ void VInspector_ItemBVHTree::initItem() const
 }
 
 // =======================================================================
-// function : GetTableRowCount
-// purpose :
-// =======================================================================
-int VInspector_ItemBVHTree::GetTableRowCount() const
-{
-  return 60;
-}
-
-// =======================================================================
-// function : GetTableData
+// function : Dump
 // purpose :
 // =======================================================================
-QVariant VInspector_ItemBVHTree::GetTableData (const int theRow, const int theColumn, const int theRole) const
+Standard_Boolean VInspector_ItemBVHTree::Dump (Standard_OStream& OS) const
 {
-  //if (theRole != Qt::DisplayRole)
-  //  return QVariant();
-
-  //Handle(SelectMgr_ViewerSelector) aViewerSelector = GetViewerSelector();
-  //if (aViewerSelector.IsNull())
-  //  return QVariant();
-
-  //bool isFirstColumn = theColumn == 0;
-  //switch (theRow)
-  //{
-  //  case 0: return isFirstColumn ? QVariant ("Sensitivity") : QVariant (aViewerSelector->Sensitivity());
-  //  case 1: return isFirstColumn ? QVariant ("IsPickClosest") : QVariant (aViewerSelector->IsPickClosest());
-  //  case 2: return isFirstColumn ? QVariant ("NbPicked") : QVariant (aViewerSelector->NbPicked());
-
-  //  case 3: return ViewControl_Table::SeparatorData();
-  //  case 4: return isFirstColumn ? QVariant ("ClearPicked") : QVariant ("DO");
-
-  //  case 5: return ViewControl_Table::SeparatorData();
-  //  case 6: return isFirstColumn ? QVariant ("X (pixel)") : QVariant (myXPix);
-  //  case 7: return isFirstColumn ? QVariant ("Y (pixel)") : QVariant (myYPix);
-  //  case 8: return isFirstColumn ? QVariant ("Pick") : QVariant ("DO");
-
-  //  case 9: return ViewControl_Table::SeparatorData();
-  //  case 10: return isFirstColumn ? QVariant ("X Min (pixel)") : QVariant (myXMinPix);
-  //  case 11: return isFirstColumn ? QVariant ("Y Min (pixel)") : QVariant (myXMinPix);
-  //  case 12: return isFirstColumn ? QVariant ("X Max (pixel)") : QVariant (myXMaxPix);
-  //  case 13: return isFirstColumn ? QVariant ("Y Max (pixel)") : QVariant (myYMaxPix);
-  //  case 14: return isFirstColumn ? QVariant ("Pick") : QVariant ("DO");
+  opencascade::handle<BVH_Tree<Standard_Real, 3> > aBVHTree = GetTree();
+  if (aBVHTree.IsNull())
+    return Standard_False;
 
-  //  default: break;
-  //}
-  return QVariant();
-}
-
-// =======================================================================
-// function : GetTableEditType
-// purpose :
-// =======================================================================
-ViewControl_EditType VInspector_ItemBVHTree::GetTableEditType (const int theRow, const int) const
-{
-  switch (theRow)
-  {
-    //case 4: return ViewControl_EditType_DoAction;
-    //case 6: return ViewControl_EditType_Spin;
-    //case 7: return ViewControl_EditType_Spin;
-    //case 8: return ViewControl_EditType_DoAction;
-    //case 10: return ViewControl_EditType_Spin;
-    //case 11: return ViewControl_EditType_Spin;
-    //case 12: return ViewControl_EditType_Spin;
-    //case 13: return ViewControl_EditType_Spin;
-    //case 14: return ViewControl_EditType_DoAction;
-    default: return ViewControl_EditType_None;
-  }
+  aBVHTree->Dump (OS);
+  return Standard_True;
 }
 
 // =======================================================================
-// function : SetTableData
+// function : createChild
 // purpose :
 // =======================================================================
-bool VInspector_ItemBVHTree::SetTableData (const int theRow, const int, const QVariant& theValue)
+TreeModel_ItemBasePtr VInspector_ItemBVHTree::createChild (int theRow, int theColumn)
 {
-  //Handle(SelectMgr_ViewerSelector) aViewerSelector = GetViewerSelector();
-  //if (aViewerSelector.IsNull())
-  //  return Standard_False;
-
-  //switch (theRow)
-  //{
-  //  case 4: aViewerSelector->ClearPicked(); break;
-  //  case 6: myXPix = theValue.toInt();
-  //  case 7: myYPix = theValue.toInt();
-  //  case 8:
-  //  {
-  //    Handle(StdSelect_ViewerSelector3d) aSelector3d = Handle(StdSelect_ViewerSelector3d)::DownCast(aViewerSelector);
-  //    if (!aSelector3d.IsNull())
-  //      aSelector3d->Pick (myXPix, myYPix, View_Tools::FindActiveView (GetContext()));
-  //    break;
-  //  }
-  //  case 10: myXMinPix = theValue.toInt();
-  //  case 11: myXMinPix = theValue.toInt();
-  //  case 12: myXMaxPix = theValue.toInt();
-  //  case 13: myYMaxPix = theValue.toInt();
-  //  case 14:
-  //  {
-  //    Handle(StdSelect_ViewerSelector3d) aSelector3d = Handle(StdSelect_ViewerSelector3d)::DownCast(aViewerSelector);
-  //    if (!aSelector3d.IsNull())
-  //      aSelector3d->Pick (myXMinPix, myYMinPix, myXMaxPix, myYMaxPix, View_Tools::FindActiveView (GetContext()));
-  //    break;
-  //  }
-  //  default: break;
-  //}
-  return Standard_True;
+  return VInspector_ItemBVHTreeNode::CreateItem (currentItem(), theRow, theColumn);
 }
 
 // =======================================================================
-// function : Dump
+// function : buildPresentationShape
 // purpose :
 // =======================================================================
-Standard_Boolean VInspector_ItemBVHTree::Dump (Standard_OStream& OS) const
+TopoDS_Shape VInspector_ItemBVHTree::buildPresentationShape()
 {
-  //Handle(SelectMgr_ViewerSelector) aViewerSelector = GetViewerSelector();
-  //if (aViewerSelector.IsNull())
-  //  return Standard_False;
+  opencascade::handle<BVH_Tree<Standard_Real, 3> > aBVHTree = myTree;
+  if (aBVHTree.IsNull())
+    return TopoDS_Shape();
+
+  Standard_SStream OS;
+  //aBVHTree->DumpNode (Row(), OS);
+  aBVHTree->Dump (OS);
+
+  Standard_Integer aColumnCount;
+  NCollection_Vector<TCollection_AsciiString> aValues;
+  Message::ConvertStream (OS, aColumnCount, aValues);
+
+  BRep_Builder aBuilder;
+  TopoDS_Compound aCompound;
+  aBuilder.MakeCompound (aCompound);
+  for (int aValueId = 0; aValueId < aValues.Size(); )
+  {
+    for (int aColumnId = 0; aColumnId < aColumnCount; aColumnId++, aValueId++)
+    {
+      if (aColumnId != 1)
+        continue;
 
-  //aViewerSelector->Dump (OS);
-  return Standard_True;
-}
+      TCollection_AsciiString aValue = aValues.Value (aValueId);
+      Bnd_Box aBox;
+      if (!aBox.FromString (aValue))
+        continue;
 
-// =======================================================================
-// function : createChild
-// purpose :
-// =======================================================================
-TreeModel_ItemBasePtr VInspector_ItemBVHTree::createChild (int theRow, int theColumn)
-{
-  return VInspector_ItemBVHTreeNode::CreateItem (currentItem(), theRow, theColumn);
+      TopoDS_Shape aShape = VInspector_Tools::CreateShape (aBox);
+      aBuilder.Add (aCompound, aShape);
+    }
+  }
+  return aCompound;
 }
index 651145ee2b3ccbd9993f77213fad19b0edc47f46..a72ca7e2e76324953c50d6b7b0c429550665a8ad 100644 (file)
@@ -51,12 +51,12 @@ public:
   virtual Handle(Standard_Transient) GetObject() const { initItem(); return myTree; }
 
   //! Returns current drawer, initialize the drawer if it was not initialized yet
-  Standard_EXPORT opencascade::handle<BVH_Tree<Standard_Real, 3> > GetTree() const
+  opencascade::handle<BVH_Tree<Standard_Real, 3> > GetTree() const
   { return opencascade::handle<BVH_Tree<Standard_Real, 3> >::DownCast (GetObject()); }
 
-  //! Returns the span from the 0 row to the first item corresponded to the picked item
-  //! the 0 item is SelectMgr_SelectingVolumeManager
-  Standard_Integer GetFirstChildOfPicked() const { return 1; }
+  //! Dumps the content of me on the stream <OS>.
+  virtual Standard_Boolean Dump (Standard_OStream& OS) const;
+
 protected:
   //! Initialize the current item. It is empty because Reset() is also empty.
   virtual void initItem() const Standard_OVERRIDE;
@@ -70,29 +70,9 @@ protected:
   //! \return the value
   Standard_EXPORT virtual QVariant initValue (const int theItemRole) const Standard_OVERRIDE;
 
-  //! Returns number of table rows
-  //! \return an integer value
-  virtual int GetTableRowCount() const Standard_OVERRIDE;
-
-  //! Returns table value for the row in form: <function name> <function value>
-  //! \param theRow a model index row
-  //! \param theColumn a model index column
-  virtual QVariant GetTableData (const int theRow, const int theColumn, const int theRole) const Standard_OVERRIDE;
-
-  //! 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
-  virtual ViewControl_EditType GetTableEditType (const int theRow, const int theColumn) const Standard_OVERRIDE;
-
-  //! Sets the value into the table cell. Only 1st column value might be modified.
-  //! \param theRow a model index row
-  //! \param theColumn a model index column
-  //! \param theValue a new cell value
-  virtual bool SetTableData (const int theRow, const int theColumn, const QVariant& theValue) Standard_OVERRIDE;
-
-  //! Dumps the content of me on the stream <OS>.
-  virtual Standard_Boolean Dump (Standard_OStream& OS) const;
+  //! Build presentation shape
+  //! \return generated shape of the item parameters
+  virtual TopoDS_Shape buildPresentationShape() Standard_OVERRIDE;
 
 protected:
 
index 99a45f590c10502cc5c74ef577257ac9c74bc4f6..061539e303742a1a0ed43728b2dff34f3dd2fa1e 100644 (file)
 
 #include <inspector/VInspector_ItemBVHTreeNode.hxx>
 
-//#include <inspector/VInspector_ItemSelectMgrViewerSelector.hxx>
+#include <inspector/VInspector_ItemBVHTree.hxx>
 //#include <inspector/VInspector_ItemSelectMgrBaseFrustum.hxx>
 //
-//#include <inspector/ViewControl_Tools.hxx>
+#include <inspector/VInspector_Tools.hxx>
+
+#include <BRep_Builder.hxx>
+#include <TopoDS_Compound.hxx>
 
 // =======================================================================
 // function : initRowCount
 // =======================================================================
 int VInspector_ItemBVHTreeNode::initRowCount() const
 {
-  if (Column() != 0)
-    return 0;
-
-  return 2;
+  return 0;
 }
 
 // =======================================================================
@@ -47,7 +47,7 @@ QVariant VInspector_ItemBVHTreeNode::initValue (const int theItemRole) const
 
   switch (Column())
   {
-    case 0: return QString ("TreeNode_" + Row()); break;
+    case 0: return QString ("TreeNode_%1").arg (Row()); break;
     default:
       break;
   }
@@ -61,6 +61,7 @@ QVariant VInspector_ItemBVHTreeNode::initValue (const int theItemRole) const
 
 void VInspector_ItemBVHTreeNode::Init()
 {
+  UpdatePresentationShape();
   TreeModel_ItemBase::Init(); // to use getIO() without circling initialization
 }
 
@@ -74,6 +75,18 @@ void VInspector_ItemBVHTreeNode::Reset()
   VInspector_ItemBase::Reset();
 }
 
+// =======================================================================
+// function : GetTree
+// purpose :
+// =======================================================================
+
+opencascade::handle<BVH_Tree<Standard_Real, 3> > VInspector_ItemBVHTreeNode::GetTree() const
+{
+  VInspector_ItemBVHTreePtr anObjectParent = itemDynamicCast<VInspector_ItemBVHTree>(Parent());
+
+  return anObjectParent->GetTree();
+}
+
 // =======================================================================
 // function : initItem
 // purpose :
@@ -90,7 +103,60 @@ void VInspector_ItemBVHTreeNode::initItem() const
 // function : createChild
 // purpose :
 // =======================================================================
-TreeModel_ItemBasePtr VInspector_ItemBVHTreeNode::createChild (int theRow, int theColumn)
+TreeModel_ItemBasePtr VInspector_ItemBVHTreeNode::createChild (int, int)
 {
   return TreeModel_ItemBasePtr();
 }
+
+// =======================================================================
+// function : buildPresentationShape
+// purpose :
+// =======================================================================
+TopoDS_Shape VInspector_ItemBVHTreeNode::buildPresentationShape()
+{
+  opencascade::handle<BVH_Tree<Standard_Real, 3> > aBVHTree = GetTree();
+  if (aBVHTree.IsNull())
+    return TopoDS_Shape();
+
+  Standard_SStream OS;
+  aBVHTree->DumpNode (Row(), OS);
+
+  Standard_Integer aColumnCount;
+  NCollection_Vector<TCollection_AsciiString> aValues;
+  Message::ConvertStream (OS, aColumnCount, aValues);
+
+  BRep_Builder aBuilder;
+  TopoDS_Compound aCompound;
+  aBuilder.MakeCompound (aCompound);
+  for (int aValueId = 0; aValueId < aValues.Size(); )
+  {
+    for (int aColumnId = 0; aColumnId < aColumnCount; aColumnId++, aValueId++)
+    {
+      if (aColumnId != 1)
+        continue;
+
+      TCollection_AsciiString aValue = aValues.Value (aValueId);
+      Bnd_Box aBox;
+      if (!aBox.FromString (aValue))
+        continue;
+
+      TopoDS_Shape aShape = VInspector_Tools::CreateShape (aBox);
+      aBuilder.Add (aCompound, aShape);
+    }
+  }
+  return aCompound;
+}
+
+// =======================================================================
+// function : Dump
+// purpose :
+// =======================================================================
+Standard_Boolean VInspector_ItemBVHTreeNode::Dump (Standard_OStream& OS) const
+{
+  opencascade::handle<BVH_Tree<Standard_Real, 3> > aBVHTree = GetTree();
+  if (aBVHTree.IsNull())
+    return Standard_False;
+
+  aBVHTree->DumpNode (Row(), OS);
+  return Standard_True;
+}
index ea09d078334931afde44c834df871347db2e01d8..d5aef7b4b938740f9efc4f4dfd806e0a920e4c38 100644 (file)
@@ -51,6 +51,12 @@ public:
   //! \return object
   virtual Handle(Standard_Transient) GetObject() const { initItem(); return NULL; }
 
+  //! Returns parent tree, the node information is obtained from the tree by the given index
+  Standard_EXPORT opencascade::handle<BVH_Tree<Standard_Real, 3> > GetTree() const;
+
+  //! Dumps the content of me on the stream <OS>.
+  virtual Standard_Boolean Dump (Standard_OStream& OS) const;
+
 protected:
   //! Initialize the current item. It is empty because Reset() is also empty.
   virtual void initItem() const Standard_OVERRIDE;
@@ -64,6 +70,10 @@ protected:
   //! \return the value
   Standard_EXPORT virtual QVariant initValue (const int theItemRole) const Standard_OVERRIDE;
 
+  //! Build presentation shape
+  //! \return generated shape of the item parameters
+  virtual TopoDS_Shape buildPresentationShape() Standard_OVERRIDE;
+
 protected:
 
   //! Creates a child item in the given position.
index 312a658c8aebd6d8fa60b6c6918555be531f014e..edcde81111c69563eeb054dde5da7d15c323d56d 100644 (file)
@@ -215,20 +215,23 @@ QVariant VInspector_ItemSelectBasicsEntityOwner::GetTableData(const int theRow,
   bool isFirstColumn = theColumn == 0;
 
   Handle(SelectBasics_EntityOwner) anOwner = getEntityOwner();
+  Handle(SelectMgr_EntityOwner) anEntityOwner = Handle(SelectMgr_EntityOwner)::DownCast (anOwner);
   switch (theRow)
   {
     case 0: return isFirstColumn ? QVariant ("Priority") : QVariant (anOwner->Priority());
     case 1: return isFirstColumn ? QVariant ("HasLocation") : QVariant (anOwner->HasLocation());
     case 2: return isFirstColumn ? QVariant ("Location") :
       (anOwner->HasLocation() ? QVariant (ViewControl_Tools::ToString (anOwner->Location()).ToCString()) : QVariant());
+    case 3: return isFirstColumn ? QVariant ("IsSelected") : QVariant (!anEntityOwner.IsNull() ? anEntityOwner->IsSelected() : "");
     default: break;
   }
 
+
   Handle(StdSelect_BRepOwner) aBROwner = Handle(StdSelect_BRepOwner)::DownCast (anOwner);
   if (aBROwner.IsNull())
     return QVariant();
 
-  int aBRepOwnerRow = theRow - 3;
+  int aBRepOwnerRow = theRow - 4;
   switch (aBRepOwnerRow)
   {
     case 0: return ViewControl_Table::SeparatorData();
index b2f61e37a48ee6efc3ddd85c9d1a658606df8ea5..8f2051acb5d667e690441d665fdd7c1de68a6336 100644 (file)
@@ -139,7 +139,7 @@ opencascade::handle<BVH_Tree<Standard_Real, 3> > VInspector_ItemSelectMgrSelecta
   SelectMgr_SelectableObjectSet::BVHSubset aBVHSubset = (SelectMgr_SelectableObjectSet::BVHSubset)theRow;
   theName = TCollection_AsciiString ("BVH_Tree_") + SelectMgr::BVHSubsetToString (aBVHSubset);
 
-  return aSet.BVH (SelectMgr_SelectableObjectSet::BVHSubset_2dPersistent);
+  return aSet.BVH (aBVHSubset);
 }
 
 // =======================================================================
index e0b538927d162985c49c8f3bf32a835e4a03b772..672a946a53d1e742a5e2b1e3a0769d7d4437dfa5 100644 (file)
@@ -16,7 +16,8 @@
 
 #include <inspector/VInspector_ItemSelectMgrSensitiveEntitySet.hxx>
 #include <inspector/VInspector_ItemSelectMgrViewerSelector.hxx>
-#include <inspector/VInspector_ItemSelect3DSensitiveSetItem.hxx>
+#include <inspector/VInspector_ItemBVHTree.hxx>
+#include <inspector/ViewControl_Tools.hxx>
 
 #include <AIS_ListOfInteractive.hxx>
 #include <SelectMgr_SensitiveEntitySet.hxx>
 // =======================================================================
 int VInspector_ItemSelectMgrSensitiveEntitySet::initRowCount() const
 {
-  Handle(SelectMgr_SensitiveEntitySet) aSensitiveSet = Handle(SelectMgr_SensitiveEntitySet)::DownCast (GetSensitiveEntitySet());
-  if (!aSensitiveSet.IsNull())
-    return aSensitiveSet->Size();
+  //Handle(SelectMgr_SensitiveEntitySet) aSensitiveSet = Handle(SelectMgr_SensitiveEntitySet)::DownCast (GetSensitiveEntitySet());
+  //if (!aSensitiveSet.IsNull())
+  //  return aSensitiveSet->Size();
 
-  return 2;
+  return 1; // for BVH_Tree
 }
 
 // =======================================================================
@@ -40,6 +41,9 @@ int VInspector_ItemSelectMgrSensitiveEntitySet::initRowCount() const
 // =======================================================================
 QVariant VInspector_ItemSelectMgrSensitiveEntitySet::initValue (int theItemRole) const
 {
+  if (theItemRole == Qt::DisplayRole && theItemRole == Qt::ToolTipRole && Column() == 2)
+    return ViewControl_Tools::GetPointerInfo (GetSelectableObject(), true).ToCString();
+
   QVariant aParentValue = VInspector_ItemBase::initValue (theItemRole);
   if (aParentValue.isValid())
     return aParentValue;
@@ -82,7 +86,7 @@ QVariant VInspector_ItemSelectMgrSensitiveEntitySet::initValue (int theItemRole)
 // =======================================================================
 TreeModel_ItemBasePtr VInspector_ItemSelectMgrSensitiveEntitySet::createChild (int theRow, int theColumn)
 {
-  return VInspector_ItemSelect3DSensitiveSetItem::CreateItem (currentItem(), theRow, theColumn);
+  return VInspector_ItemBVHTree::CreateItem (currentItem(), theRow, theColumn);
 }
 
 // =======================================================================
@@ -115,6 +119,21 @@ void VInspector_ItemSelectMgrSensitiveEntitySet::Reset()
   mySelectableObject = NULL;
 }
 
+// =======================================================================
+// function : GetBVHTree
+// purpose :
+// =======================================================================
+opencascade::handle<BVH_Tree<Standard_Real, 3> > VInspector_ItemSelectMgrSensitiveEntitySet::GetBVHTree (const int theRow,
+  TCollection_AsciiString& theName) const
+{
+  Handle(SelectMgr_SensitiveEntitySet) anEntitySet = GetSensitiveEntitySet();
+
+  if (anEntitySet.IsNull())
+    return NULL;
+
+  return anEntitySet->BVH();
+}
+
 // =======================================================================
 // function : initItem
 // purpose :
@@ -123,6 +142,7 @@ void VInspector_ItemSelectMgrSensitiveEntitySet::initItem() const
 {
   if (IsInitialized())
     return;
+
   const_cast<VInspector_ItemSelectMgrSensitiveEntitySet*>(this)->Init();
 }
 
index 85ee1cdc08c8a674dc961cbacd62b55415406dfc..305417778baacd69de4c1c41f8a3b05b2164a5c0 100644 (file)
@@ -17,6 +17,7 @@
 #define VInspector_ItemSelectMgrSensitiveEntitySet_H
 
 #include <AIS_InteractiveObject.hxx>
+#include <BVH_Tree.hxx>
 #include <SelectMgr_SensitiveEntitySet.hxx>
 #include <Standard.hxx>
 #include <inspector/VInspector_ItemBase.hxx>
@@ -59,6 +60,9 @@ public:
   //! Resets cached values
   Standard_EXPORT virtual void Reset() Standard_OVERRIDE;
 
+  //! Returns child BVH tree of the row
+  opencascade::handle<BVH_Tree<Standard_Real, 3> > GetBVHTree (const int theRow, TCollection_AsciiString& theName) const;
+
 protected:
 
   //! Initialize the current item. It is empty because Reset() is also empty.
index 8c9687f55522eca24b124085ff8ef09edda86002..bd590e5c4188d9d7ab4492dcfb0698cc9d76fcfa 100644 (file)
@@ -129,23 +129,6 @@ void VInspector_ItemSelectMgrViewerSelector::Reset()
   setViewerSelector (NULL);
 }
 
-// =======================================================================
-// function : GetContainerRowCount
-// purpose :
-// =======================================================================
-
-int VInspector_ItemSelectMgrViewerSelector::GetContainerRowCount (const int theContainerRow) const
-{
-  if (theContainerRow != 2)
-    return 0;
-
-  Handle(SelectMgr_ViewerSelector) aViewSelector = GetViewerSelector();
-  if (aViewSelector.IsNull())
-    return 0;
-
-  return aViewSelector->GetObjectSensitives().Extent();
-}
-
 // =======================================================================
 // function : GetSensitiveEntitySet
 // purpose :
@@ -156,7 +139,7 @@ Handle(SelectMgr_SensitiveEntitySet) VInspector_ItemSelectMgrViewerSelector::Get
   Standard_Integer anIndex = 0;
 
   Handle(SelectMgr_ViewerSelector) aViewSelector = GetViewerSelector();
-  if (!aViewSelector.IsNull())
+  if (aViewSelector.IsNull())
     return NULL;
 
   for (SelectMgr_MapOfObjectSensitivesIterator anIterator (aViewSelector->GetObjectSensitives()); anIterator.More(); anIterator.Next(), anIndex++)
@@ -170,6 +153,23 @@ Handle(SelectMgr_SensitiveEntitySet) VInspector_ItemSelectMgrViewerSelector::Get
   return NULL;
 }
 
+// =======================================================================
+// function : GetContainerRowCount
+// purpose :
+// =======================================================================
+
+int VInspector_ItemSelectMgrViewerSelector::GetContainerRowCount (const int theContainerRow) const
+{
+  if (theContainerRow != 2)
+    return 0;
+
+  Handle(SelectMgr_ViewerSelector) aViewSelector = GetViewerSelector();
+  if (aViewSelector.IsNull())
+    return 0;
+
+  return aViewSelector->GetObjectSensitives().Extent();
+}
+
 // =======================================================================
 // function : GetContainerValue
 // purpose :
diff --git a/tools/VInspector/VInspector_PreviewParameters.cxx b/tools/VInspector/VInspector_PreviewParameters.cxx
new file mode 100644 (file)
index 0000000..7b3f80c
--- /dev/null
@@ -0,0 +1,120 @@
+// Created on: 2019-05-03
+// Created by: Natalia ERMOLAEVA
+// Copyright (c) 2019 OPEN CASCADE SAS
+//
+// This file is part of Open CASCADE Technology software library.
+//
+// This library is free software; you can redistribute it and/or modify it under
+// the terms of the GNU Lesser General Public License version 2.1 as published
+// by the Free Software Foundation, with special exception defined in the file
+// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
+// distribution for complete text of the license and disclaimer of any warranty.
+//
+// Alternatively, this file may be used under the terms of Open CASCADE
+// commercial license or contractual agreement. 
+
+#include <inspector/VInspector_PreviewParameters.hxx>
+
+#include <Prs3d_Drawer.hxx>
+#include <Prs3d_PointAspect.hxx>
+#include <Prs3d_ShadingAspect.hxx>
+
+// =======================================================================
+// function : Constructor
+// purpose :
+// =======================================================================
+VInspector_PreviewParameters::VInspector_PreviewParameters()
+{
+  myDrawer = new Prs3d_Drawer();
+
+  Quantity_Color aColor(Quantity_NOC_TOMATO);//Quantity_NOC_GREENYELLOW));//Quantity_NOC_BLUE1));
+  Standard_ShortReal aTransparency = 0.8;
+
+  // point parameters
+  myDrawer->SetPointAspect (new Prs3d_PointAspect (Aspect_TOM_O_PLUS, aColor, 3.0));
+
+  // shading parameters
+  Graphic3d_MaterialAspect aShadingMaterial;
+  aShadingMaterial.SetReflectionModeOff (Graphic3d_TOR_SPECULAR);
+  aShadingMaterial.SetMaterialType (Graphic3d_MATERIAL_ASPECT);
+
+  myDrawer->SetShadingAspect (new Prs3d_ShadingAspect());
+  myDrawer->ShadingAspect()->Aspect()->SetInteriorStyle (Aspect_IS_SOLID);
+  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);
+}
+
+// =======================================================================
+// function : SaveState
+// purpose :
+// =======================================================================
+void VInspector_PreviewParameters::SaveState (VInspector_PreviewParameters* 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  VInspector_PreviewParameters::RestoreState (VInspector_PreviewParameters* 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;
+}
diff --git a/tools/VInspector/VInspector_PreviewParameters.hxx b/tools/VInspector/VInspector_PreviewParameters.hxx
new file mode 100644 (file)
index 0000000..e98bea6
--- /dev/null
@@ -0,0 +1,68 @@
+// Created on: 2019-05-03
+// Created by: Natalia ERMOLAEVA
+// Copyright (c) 2019 OPEN CASCADE SAS
+//
+// This file is part of Open CASCADE Technology software library.
+//
+// This library is free software; you can redistribute it and/or modify it under
+// the terms of the GNU Lesser General Public License version 2.1 as published
+// by the Free Software Foundation, with special exception defined in the file
+// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
+// distribution for complete text of the license and disclaimer of any warranty.
+//
+// Alternatively, this file may be used under the terms of Open CASCADE
+// commercial license or contractual agreement. 
+
+#ifndef VInspector_PreviewParameters_H
+#define VInspector_PreviewParameters_H
+
+#include <Standard.hxx>
+#include <Standard_Macro.hxx>
+
+#include <Prs3d_Drawer.hxx>
+
+#include <Standard_WarningsDisable.hxx>
+#include <QMap>
+#include <QString>
+#include <Standard_WarningsRestore.hxx>
+
+//! \class VInspector_PreviewParameters
+//! Container of View tool bar actions
+class VInspector_PreviewParameters
+{
+public:
+
+  //! Constructor
+  Standard_EXPORT VInspector_PreviewParameters ();
+
+  //! Destructor
+  virtual ~VInspector_PreviewParameters() {}
+
+  //! 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:
+  //! - visibiblity of columns,
+  //! - columns width
+  //! \param theTreeView a view instance
+  //! \param theItems [out] properties
+  //! \param thePrefix peference item prefix
+  Standard_EXPORT static void SaveState (VInspector_PreviewParameters* 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 (VInspector_PreviewParameters* theParameters,
+                                            const QString& theKey, const QString& theValue,
+                                            const QString& thePrefix = QString());
+
+private:
+
+  Handle(Prs3d_Drawer) myDrawer;
+};
+
+#endif
index eb70a404eea27e23cad225eaf79d99a6540a71cf..7d376c977eb347e0351ae05a64b4eaa9bda77940 100644 (file)
@@ -27,10 +27,6 @@ IMPLEMENT_STANDARD_RTTIEXT(VInspector_PropertiesCreator, TreeModel_ItemPropertie
 // =======================================================================
 TreeModel_ItemProperties* VInspector_PropertiesCreator::GetProperties (const TreeModel_ItemBasePtr& theItem)
 {
-  Handle(Standard_Transient) anObject = theItem->GetObject();
-  if (anObject.IsNull())
-    return NULL;
-
   Standard_SStream aSStream;
   if (theItem->Dump (aSStream))
     return new ViewControl_PropertiesStream (theItem);
index 7b02cd9532fe911e9136b9623de92137d1211f2f..4ca765d51736e6ec06f8b8bb008d4a010dab52a7 100644 (file)
@@ -194,17 +194,17 @@ public:
   //! \return created shape
   Standard_EXPORT static TopoDS_Shape CreateShape (const Bnd_OBB& theBoundingBox);
 
-  //! Creates box shape
-  //! \param theBoundingBox box shape parameters
-  //! \return created shape
-  Standard_EXPORT static TopoDS_Shape CreateShape (const Select3D_BndBox3d& theBoundingBox);
-
   //! 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);
 
+  //! Creates box shape
+  //! \param theBoundingBox box shape parameters
+  //! \return created shape
+  Standard_EXPORT static TopoDS_Shape CreateShape (const Select3D_BndBox3d& theBoundingBox);
+
   //! Build string presentation of Graphic3D index buffer
   //! \param theIndexBuffer index buffer
   //! \return string presentation
index 7fe674d6a5f0846522e3cf4ceb86f33e192a5521..f1f2e0a86d67e4a8757ad9367892321c6318cec3 100644 (file)
 #include <AIS_Shape.hxx>
 #include <AIS_Trihedron.hxx>
 #include <BRep_Builder.hxx>
+#include <BRepBuilderAPI_MakeVertex.hxx>
+#include <BRepBuilderAPI_MakeEdge.hxx>
+#include <BRepBuilderAPI_MakeFace.hxx>
 #include <Geom_Axis2Placement.hxx>
-#include <Prs3d_PointAspect.hxx>
 #include <TopoDS_Compound.hxx>
 
 #include <TopExp_Explorer.hxx>
@@ -45,6 +47,7 @@
 #include <inspector/VInspector_ItemFolderObject.hxx>
 #include <inspector/VInspector_ItemOpenGlElement.hxx>
 #include <inspector/VInspector_ItemPresentableObject.hxx>
+#include <inspector/VInspector_PreviewParameters.hxx>
 #include <inspector/VInspector_PropertiesCreator.hxx>
 #include <inspector/VInspector_PrsOpenGlElement.hxx>
 #include <inspector/VInspector_TableModelValues.hxx>
@@ -107,6 +110,8 @@ const int VINSPECTOR_DEFAULT_VIEW_POSITION_Y = 60; // TINSPECTOR_DEFAULT_POSITIO
 VInspector_Window::VInspector_Window()
 : myParent (0), myExportToShapeViewDialog (0), myViewWindow (0)
 {
+  myPreviewParameters = new VInspector_PreviewParameters();
+
   myMainWindow = new QMainWindow (0);
 
   QWidget* aCentralWidget = new QWidget (myMainWindow);
@@ -249,9 +254,16 @@ void VInspector_Window::GetPreferences (TInspectorAPI_PreferencesDataMap& theIte
   }
 
   anItems.clear();
-  TreeModel_Tools::SaveState (myHistoryView, anItems, "history_view_");
+  VInspector_PreviewParameters::SaveState (myPreviewParameters, anItems, "preview_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());
+
+  anItems.clear();
+  TreeModel_Tools::SaveState (myTreeView, anItems);
   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());
+  }
 }
 
 // =======================================================================
@@ -276,6 +288,9 @@ void VInspector_Window::SetPreferences (const TInspectorAPI_PreferencesDataMap&
     else if (TreeModel_Tools::RestoreState (myHistoryView, anItemIt.Key().ToCString(), anItemIt.Value().ToCString(),
                                             "history_view_"))
       continue;
+    else if (VInspector_PreviewParameters::RestoreState (myPreviewParameters, anItemIt.Key().ToCString(), anItemIt.Value().ToCString(),
+                                            "preview_parameters_"))
+      continue;
   }
 }
 
@@ -382,7 +397,7 @@ NCollection_List<TopoDS_Shape> VInspector_Window::GetSelectedShapes (const QMode
   {
     TreeModel_ItemBasePtr anItem = *anItemIt;
     VInspector_ItemBasePtr aVItem = itemDynamicCast<VInspector_ItemBase>(anItem);
-    if (!aVItem || aVItem->Row() == 0)
+    if (!aVItem /*|| aVItem->Row() == 0*/)
       continue;
 
     TopoDS_Shape aShape = aVItem->GetPresentationShape();
@@ -599,11 +614,18 @@ void VInspector_Window::SetContext (const Handle(AIS_InteractiveContext)& theCon
     return;
 
   VInspector_ViewModel* aViewModel = dynamic_cast<VInspector_ViewModel*> (myTreeView->model());
+  bool isFirst = aViewModel->GetContext().IsNull();
+
   aViewModel->SetContext (theContext);
   myTreeView->setExpanded (aViewModel->index (0, 0), true);
 
   if (!myCallBack.IsNull())
     myCallBack->SetContext (theContext);
+
+  myPreviewParameters->GetDrawer()->Link (theContext->DefaultDrawer());
+
+  if (isFirst)
+    onExportToMessageView();
 }
 
 // =======================================================================
@@ -660,6 +682,20 @@ void VInspector_Window::onTreeViewContextMenuRequested(const QPoint& thePosition
 {
   QMenu* aMenu = new QMenu (GetMainWindow());
   aMenu->addAction (ViewControl_Tools::CreateAction (tr ("Export to ShapeView"), SLOT (onExportToShapeView()), GetMainWindow(), this));
+  aMenu->addSeparator();
+
+  QModelIndex anIndex = TreeModel_ModelBase::SingleSelected (myTreeView->selectionModel()->selectedIndexes(), 0);
+  TreeModel_ItemBasePtr anItemBase = TreeModel_ModelBase::GetItemByIndex (anIndex);
+  if (anItemBase)
+  {
+    if (itemDynamicCast<VInspector_ItemContext> (anItemBase))
+    {
+      aMenu->addAction (ViewControl_Tools::CreateAction (tr ("Export to MessageView"), SLOT (onExportToMessageView()), GetMainWindow(), this));
+      aMenu->addSeparator();
+
+      aMenu->addAction (ViewControl_Tools::CreateAction (tr ("Default preview"), SLOT (onDefaultPreview()), GetMainWindow(), this));
+    }
+  }
 
   aMenu->addSeparator();
   for (int aTypeId = (int)VInspector_DisplayActionType_DisplayId; aTypeId <= (int)VInspector_DisplayActionType_RemoveId; aTypeId++)
@@ -824,6 +860,29 @@ void VInspector_Window::onHistoryViewSelectionChanged (const QItemSelection& the
   selectTreeViewItems (aPointers);
 }
 
+// =======================================================================
+// function : onExportToShapeView
+// purpose :
+// =======================================================================
+void VInspector_Window::onExportToMessageView()
+{
+  VInspector_ViewModel* aViewModel = dynamic_cast<VInspector_ViewModel*> (myTreeView->model());
+  if (!aViewModel)
+    return;
+  Handle(AIS_InteractiveContext) aContext = aViewModel->GetContext();
+
+  TCollection_AsciiString aPluginName ("TKMessageView");
+  NCollection_List<Handle(Standard_Transient)> aParameters;
+  if (myParameters->FindParameters (aPluginName))
+    aParameters = myParameters->Parameters (aPluginName);
+
+  QStringList anExportedPointers;
+  anExportedPointers.append (VInspector_Tools::GetPointerInfo (aContext, true).ToCString());
+  aParameters.Append (aContext);
+
+  myParameters->SetParameters (aPluginName, aParameters, false);//myExportToShapeViewDialog->IsAccepted());
+}
+
 // =======================================================================
 // function : onExportToShapeView
 // purpose :
@@ -893,6 +952,36 @@ void VInspector_Window::onExportToShapeView()
   myParameters->SetParameters (aPluginName, aParameters, myExportToShapeViewDialog->IsAccepted());
 }
 
+// =======================================================================
+// function : onDefaultPreview
+// purpose :
+// =======================================================================
+void VInspector_Window::onDefaultPreview()
+{
+  VInspector_ViewModel* aViewModel = dynamic_cast<VInspector_ViewModel*> (myTreeView->model());
+  if (!aViewModel)
+    return;
+
+  Handle(AIS_InteractiveContext) aContext = aViewModel->GetContext();
+  if (aContext.IsNull())
+    return;
+
+  BRep_Builder aBuilder;
+  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.)));
+  //aBuilder.Add (aCompound, BRepBuilderAPI_MakeFace (gp_Pln (gp_Pnt (20., 30., 0.), gp_Dir (1., 0., 0.))).Face());
+  aBuilder.Add (aCompound, VInspector_Tools::CreateBoxShape (gp_Pnt(20., 40., 0.), gp_Pnt(30., 60., 10.)));
+
+  Handle(AIS_Shape) aDefaultPreview = new AIS_Shape (aCompound);
+  aDefaultPreview->SetAttributes (myPreviewParameters->GetDrawer());
+  if (!aContext.IsNull())
+    aContext->Display (aDefaultPreview, AIS_Shaded, -1/*do not participate in selection*/, Standard_True);
+
+  UpdateTreeModel();
+}
+
 // =======================================================================
 // function : onDisplayActionTypeClicked
 // purpose :
@@ -1161,7 +1250,7 @@ Handle(AIS_InteractiveContext) VInspector_Window::createView()
   aTrihedron->SetDatumDisplayMode (Prs3d_DM_Shaded);
   aContext->Display (aTrihedron, Standard_True);
 
-  myViewWindow = new View_Window (0, aContext);
+  myViewWindow = new View_Window (0, aContext, false /*for opening several BREP files*/, true);
   myViewWindow->GetView()->SetPredefinedSize (VINSPECTOR_DEFAULT_VIEW_WIDTH, VINSPECTOR_DEFAULT_VIEW_HEIGHT);
   myViewWindow->move (VINSPECTOR_DEFAULT_VIEW_POSITION_X, VINSPECTOR_DEFAULT_VIEW_POSITION_Y);
   myViewWindow->show();
@@ -1219,12 +1308,8 @@ void VInspector_Window::updatePreviewPresentation (const NCollection_List<TopoDS
 
   if (myPreviewPresentation.IsNull())
   {
-    Quantity_Color aColor(Quantity_NOC_TOMATO);//Quantity_NOC_GREENYELLOW));//Quantity_NOC_BLUE1));
-
     myPreviewPresentation = new AIS_Shape (aCompound);
-    myPreviewPresentation->Attributes()->SetPointAspect (new Prs3d_PointAspect (Aspect_TOM_O_PLUS, aColor, 3.0));
-    myPreviewPresentation->SetColor (aColor);
-    myPreviewPresentation->SetZLayer (Graphic3d_ZLayerId_Topmost);
+    myPreviewPresentation->SetAttributes (myPreviewParameters->GetDrawer());
 
     myPreviewPresentation->SetTransformPersistence(thePersistent);
     if (!aContext.IsNull())
@@ -1262,10 +1347,9 @@ void VInspector_Window::updatePreviewPresentation (const NCollection_List<Handle
   if (myOpenGlPreviewPresentation.IsNull())
   {
     myOpenGlPreviewPresentation = new VInspector_PrsOpenGlElement();
+    myOpenGlPreviewPresentation->SetAttributes (myPreviewParameters->GetDrawer());
     myOpenGlPreviewPresentation->Set (theElements);
 
-    myOpenGlPreviewPresentation->SetColor (Quantity_Color (Quantity_NOC_BLUE1));
-    myOpenGlPreviewPresentation->SetZLayer (Graphic3d_ZLayerId_Topmost);
     myOpenGlPreviewPresentation->SetTransformPersistence(thePersistent);
     if (!aContext.IsNull())
       aContext->Display (myOpenGlPreviewPresentation, Standard_True);
index b806e925183039b9e3c10ac89cf1f94e9180eae8..0c774f8bb08926b419c77cc10d430a4f9a42a068 100644 (file)
 
 class OpenGl_Element;
 
-class VInspector_PrsOpenGlElement;
+class VInspector_PreviewParameters;
 
 class ViewControl_MessageDialog;
 class ViewControl_PropertyView;
 
+class VInspector_PrsOpenGlElement;
 class VInspector_ToolBar;
+
 class View_Window;
 
 class QAbstractItemModel;
@@ -164,9 +166,15 @@ private slots:
   //! \param theDeselected a deselected items
   void onTreeViewSelectionChanged (const QItemSelection& theSelected, const QItemSelection& theDeselected);
 
+  //! Exports the selected context into MessageView for have preview in the context.
+  void onExportToMessageView();
+
   //! Exports the first selected shape into ShapeViewer plugin.
   void onExportToShapeView();
 
+  //! Displays default preview presentation
+  void onDefaultPreview();
+
   //! Apply activated display action
   void onDisplayActionTypeClicked();
 
@@ -259,6 +267,7 @@ private:
   View_Window* myViewWindow; //!< temporary view window, it is created if Open is called but context is still NULL
 
   Handle(TInspectorAPI_PluginParameters) myParameters; //!< plugins parameters container
+  VInspector_PreviewParameters* myPreviewParameters; //!< drawer of preview presentation
   Handle(AIS_InteractiveObject) myPreviewPresentation; //!< presentation of preview for a selected object
   Handle(VInspector_PrsOpenGlElement) myOpenGlPreviewPresentation; //!< presentation of preview for OpenGl elements
 
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>
index c37ee4260e8c0e639050724eb825d4278c55e235..fd5ac5a3f0eebc5522eaef94c0d8323102b08113 100644 (file)
@@ -35,52 +35,7 @@ void ViewControl_PropertiesStream::Init()
   Standard_SStream aSStream;
   getItem()->Dump (aSStream);
 
-  TCollection_AsciiString aStream (aSStream.str().c_str());
-  Standard_Character aSeparator = Message::DumpSeparator();
-  Standard_Integer aColumnCount = 0;
-
-  TCollection_AsciiString aCurrentString = aStream;
-  Standard_Integer aPosition = aCurrentString.Search (aSeparator);
-  if (aPosition >= 1)
-  {
-    TCollection_AsciiString aTailString = aCurrentString.Split (aPosition);
-    Standard_Boolean aClassNameFound = Standard_False;
-    while (!aCurrentString.IsEmpty())
-    {
-      TCollection_AsciiString aValueString = aCurrentString;
-      aPosition = aValueString.Search (aSeparator);
-      if (aPosition < 0 )
-        break;
-      aCurrentString = aValueString.Split (aPosition - 1);
-
-      if (!aColumnCount)
-      {
-        if (!aClassNameFound)
-          aClassNameFound = Standard_True;
-        else
-        {
-          if (!aValueString.IsIntegerValue())
-            break; // not correct Dump, in correct the first value is number of property columns
-          aColumnCount = aValueString.IntegerValue();
-        }
-      }
-      else
-        myValues.Append (aValueString);
-
-      if (aTailString.IsEmpty())
-        break;
-      aCurrentString = aTailString;
-      aPosition = aCurrentString.Search (aSeparator);
-      if (aPosition < 0 )
-      {
-        aCurrentString = aTailString;
-        aTailString = TCollection_AsciiString();
-      }
-      else
-        aTailString = aCurrentString.Split (aPosition);
-    }
-  }
-  myColumnCount = aColumnCount;
+  Message::ConvertStream (aSStream, myColumnCount, myValues); 
 }
 
 // =======================================================================
index 91730e86170ad25f58415dbcdaf0b1a4bffb9ea5..c1317d41907d7d3d98d1678505dd3ab073b56cf0 100644 (file)
@@ -17,6 +17,7 @@
 #define ViewControl_PropertiesStream_H
 
 #include <Standard.hxx>
+#include <Standard_SStream.hxx>
 #include <NCollection_Vector.hxx>
 #include <TCollection_AsciiString.hxx>
 
index 1bcf999a3729fbd51f1b0003155b4bc40597822a..273f805a5c0de9fbbf77996b6024123069ed8631 100644 (file)
 
 #include <Geom_Transformation.hxx>
 
+#include <TColgp_Array1OfPnt.hxx>
+#include <BRep_Builder.hxx>
+#include <TopoDS_Compound.hxx>
+#include <BRepPrimAPI_MakeBox.hxx>
+#include <BRepBuilderAPI_MakeEdge.hxx>
+#include <BRepBuilderAPI_MakeVertex.hxx>
+
 #include <Standard_WarningsDisable.hxx>
 #include <QAction>
 #include <QHeaderView>
@@ -260,3 +267,105 @@ TCollection_AsciiString ViewControl_Tools::ToString (const TopLoc_Location& theL
 {
   return ToString (theLocation.Transformation());
 }
+
+//=======================================================================
+//function : CreateShape
+//purpose  :
+//=======================================================================
+TopoDS_Shape ViewControl_Tools::CreateShape (const Bnd_Box& theBoundingBox)
+{
+  if (theBoundingBox.IsVoid() || theBoundingBox.IsWhole())
+    return TopoDS_Shape();
+
+  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);
+}
+
+//=======================================================================
+//function : CreateShape
+//purpose  :
+//=======================================================================
+TopoDS_Shape ViewControl_Tools::CreateShape (const Bnd_OBB& theBoundingBox)
+{
+  if (theBoundingBox.IsVoid())
+    return TopoDS_Shape();
+
+  TColgp_Array1OfPnt anArrPnts(0, 8);
+  theBoundingBox.GetVertex(&anArrPnts(0));
+
+  BRep_Builder aBuilder;
+  TopoDS_Compound aCompound;
+  aBuilder.MakeCompound (aCompound);
+
+  aBuilder.Add (aCompound, BRepBuilderAPI_MakeEdge (gp_Pnt (anArrPnts.Value(0)), gp_Pnt (anArrPnts.Value(1))));
+  aBuilder.Add (aCompound, BRepBuilderAPI_MakeEdge (gp_Pnt (anArrPnts.Value(0)), gp_Pnt (anArrPnts.Value(2))));
+  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;
+}
+
+//=======================================================================
+//function : CreateBoxShape
+//purpose  :
+//=======================================================================
+TopoDS_Shape ViewControl_Tools::CreateBoxShape (const gp_Pnt& thePntMin, const gp_Pnt& thePntMax)
+{
+  Standard_Boolean aThinOnX = fabs (thePntMin.X() - thePntMax.X()) < Precision::Confusion();
+  Standard_Boolean aThinOnY = fabs (thePntMin.Y() - thePntMax.Y()) < Precision::Confusion();
+  Standard_Boolean aThinOnZ = fabs (thePntMin.Z() - thePntMax.Z()) < Precision::Confusion();
+
+  if (((int)aThinOnX + (int)aThinOnY + (int)aThinOnZ) > 1) // thin box in several directions is a point
+  {
+    BRep_Builder aBuilder;
+    TopoDS_Compound aCompound;
+    aBuilder.MakeCompound (aCompound);
+    aBuilder.Add (aCompound, BRepBuilderAPI_MakeVertex (thePntMin));
+    return aCompound;
+  }
+
+  if (aThinOnX || aThinOnY || aThinOnZ)
+  {
+    gp_Pnt aPnt1, aPnt2, aPnt3, aPnt4 ;
+    if (aThinOnX)
+    {
+      aPnt1 = gp_Pnt(thePntMin.X(), thePntMin.Y(), thePntMin.Z());
+      aPnt2 = gp_Pnt(thePntMin.X(), thePntMax.Y(), thePntMin.Z());
+      aPnt3 = gp_Pnt(thePntMin.X(), thePntMax.Y(), thePntMax.Z());
+      aPnt4 = gp_Pnt(thePntMin.X(), thePntMin.Y(), thePntMax.Z());
+    }
+    else if (aThinOnY)
+    {
+      aPnt1 = gp_Pnt(thePntMin.X(), thePntMin.Y(), thePntMin.Z());
+      aPnt2 = gp_Pnt(thePntMax.X(), thePntMin.Y(), thePntMin.Z());
+      aPnt3 = gp_Pnt(thePntMax.X(), thePntMin.Y(), thePntMax.Z());
+      aPnt4 = gp_Pnt(thePntMin.X(), thePntMin.Y(), thePntMax.Z());
+    }
+    else if (aThinOnZ)
+    {
+      aPnt1 = gp_Pnt(thePntMin.X(), thePntMin.Y(), thePntMin.Z());
+      aPnt2 = gp_Pnt(thePntMax.X(), thePntMin.Y(), thePntMin.Z());
+      aPnt3 = gp_Pnt(thePntMax.X(), thePntMax.Y(), thePntMin.Z());
+      aPnt4 = gp_Pnt(thePntMin.X(), thePntMax.Y(), thePntMin.Z());
+    }
+    BRep_Builder aBuilder;
+    TopoDS_Compound aCompound;
+    aBuilder.MakeCompound (aCompound);
+    aBuilder.Add (aCompound, BRepBuilderAPI_MakeEdge (aPnt1, aPnt2));
+    aBuilder.Add (aCompound, BRepBuilderAPI_MakeEdge (aPnt2, aPnt3));
+    aBuilder.Add (aCompound, BRepBuilderAPI_MakeEdge (aPnt3, aPnt4));
+    aBuilder.Add (aCompound, BRepBuilderAPI_MakeEdge (aPnt4, aPnt1));
+
+    return aCompound;
+  }
+  else
+  {
+    BRepPrimAPI_MakeBox aBoxBuilder (thePntMin, thePntMax);
+    return aBoxBuilder.Shape();
+  }
+}
index 7a9b90a3a4565acd9d89538f261dff3b72b1f9ac..a701d4df0aec93d87a031137a9d7927a149ae8d1 100644 (file)
 #include <gp_Trsf.hxx>
 #include <gp_XYZ.hxx>
 #include <Bnd_Box.hxx>
+#include <Bnd_OBB.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_WarningsDisable.hxx>
 #include <QString>
@@ -143,6 +145,22 @@ public:
   //! \return text value
   Standard_EXPORT static TCollection_AsciiString ToString (const TopLoc_Location& theLocation);
 
+  //! Creates box shape
+  //! \param theBoundingBox box shape parameters
+  //! \return created shape
+  Standard_EXPORT static TopoDS_Shape CreateShape (const Bnd_Box& theBoundingBox);
+
+  //! Creates box shape
+  //! \param theBoundingBox box shape parameters
+  //! \return created shape
+  Standard_EXPORT static TopoDS_Shape CreateShape (const Bnd_OBB& theBoundingBox);
+
+  //! 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);
+
 };
 
 #endif