#include <BVH_Constants.hxx>
#include <BVH_Types.hxx>
+#include <Message_Alerts.hxx>
#include <Standard_ShortReal.hxx>
#include <limits>
//! 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
#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
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).
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.
#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
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;
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 :
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;
+}
#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;
//! 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; }
&& 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.
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
+{
+}
#include <Standard_Handle.hxx>
#include <Standard_Real.hxx>
#include <Standard_Boolean.hxx>
+#include <Standard_OStream.hxx>
#include <Bnd_Box.hxx>
#include <gp_Ax3.hxx>
//! (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)
}
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;
+}
#define _Message_HeaderFile
#include <Message_Gravity.hxx>
+#include <NCollection_Vector.hxx>
#include <Standard.hxx>
#include <Standard_DefineAlloc.hxx>
#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;
//! 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
//! \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:
#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) \
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
if (aPosition >= 1)
{
TCollection_AsciiString aTailString = aCurrentString.Split (aPosition);
- Standard_Integer aRow = 0;
Standard_Boolean aClassNameFound = Standard_False;
while (!aCurrentString.IsEmpty())
{
#include <Quantity_Color.hxx>
+#include <Message_Alerts.hxx>
+#include <NCollection_Vector.hxx>
#include <Quantity_ColorDefinitionError.hxx>
#include <Standard_ErrorHandler.hxx>
#include <Standard_OutOfRange.hxx>
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;
+}
#include <Standard_Handle.hxx>
#include <Standard_ShortReal.hxx>
+#include <TCollection_AsciiString.hxx>
#include <Quantity_NameOfColor.hxx>
#include <Quantity_TypeOfColor.hxx>
#include <Standard_Real.hxx>
//! 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.
#ifndef _Quantity_ColorRGBA_HeaderFile
#define _Quantity_ColorRGBA_HeaderFile
+#include <Message_Alerts.hxx>
+#include <NCollection_Vector.hxx>
#include <Quantity_Color.hxx>
#include <Standard_Assert.hxx>
//! 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)); }
#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,
//! 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
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);
}
#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>
#include <QIcon>
#include <Standard_WarningsRestore.hxx>
+
// =======================================================================
// function : initValue
// purpose :
}
}
}
+
+ 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();
}
myAlert = Handle(Message_Alert)();
myUnitedAlerts.Clear();
myChildAlerts.Clear();
+ myPresentations.Clear();
}
// =======================================================================
#include <QVariant>
#include <Standard_WarningsRestore.hxx>
+#include <NCollection_List.hxx>
#include <NCollection_Vector.hxx>
class QAbstractTableModel;
//! \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
NCollection_DataMap<Standard_Integer, Message_ListOfAlert> myChildAlerts; //!< container of child alerts
TopoDS_Shape myCustomShape;
+ NCollection_List<Handle(Standard_Transient)> myPresentations;
};
#endif
// =======================================================================
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);
}
#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>
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 :
aTreeModel->EmitLayoutChanged();
if (!aContext.IsNull())
+ {
+ myContext = aContext;
myViewWindow->SetContext (View_ContextType_External, aContext);
+ }
if (!aViewCamera.IsNull())
myViewWindow->GetView()->GetViewer()->GetView()->Camera()->Copy (aViewCamera);
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);
}
// =======================================================================
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);
+ }
+ }
+}
#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
//! 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
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
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());
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";
TKernel
TKMath
+TKPrim
TKTopAlgo
CSF_QT
\ No newline at end of file
VInspector_ItemV3dView.hxx
VInspector_ItemV3dViewer.cxx
VInspector_ItemV3dViewer.hxx
+VInspector_PreviewParameters.cxx
+VInspector_PreviewParameters.hxx
VInspector_PropertiesCreator.cxx
VInspector_PropertiesCreator.hxx
VInspector_PrsOpenGlElement.cxx
#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
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
}
}
// =======================================================================
-// 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;
}
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;
//! \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:
#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;
}
// =======================================================================
switch (Column())
{
- case 0: return QString ("TreeNode_" + Row()); break;
+ case 0: return QString ("TreeNode_%1").arg (Row()); break;
default:
break;
}
void VInspector_ItemBVHTreeNode::Init()
{
+ UpdatePresentationShape();
TreeModel_ItemBase::Init(); // to use getIO() without circling initialization
}
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 :
// 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;
+}
//! \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;
//! \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.
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();
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);
}
// =======================================================================
#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
}
// =======================================================================
// =======================================================================
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;
// =======================================================================
TreeModel_ItemBasePtr VInspector_ItemSelectMgrSensitiveEntitySet::createChild (int theRow, int theColumn)
{
- return VInspector_ItemSelect3DSensitiveSetItem::CreateItem (currentItem(), theRow, theColumn);
+ return VInspector_ItemBVHTree::CreateItem (currentItem(), theRow, theColumn);
}
// =======================================================================
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 :
{
if (IsInitialized())
return;
+
const_cast<VInspector_ItemSelectMgrSensitiveEntitySet*>(this)->Init();
}
#define VInspector_ItemSelectMgrSensitiveEntitySet_H
#include <AIS_InteractiveObject.hxx>
+#include <BVH_Tree.hxx>
#include <SelectMgr_SensitiveEntitySet.hxx>
#include <Standard.hxx>
#include <inspector/VInspector_ItemBase.hxx>
//! 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.
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 :
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++)
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 :
--- /dev/null
+// 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;
+}
--- /dev/null
+// 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
// =======================================================================
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);
//! \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
#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>
#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>
VInspector_Window::VInspector_Window()
: myParent (0), myExportToShapeViewDialog (0), myViewWindow (0)
{
+ myPreviewParameters = new VInspector_PreviewParameters();
+
myMainWindow = new QMainWindow (0);
QWidget* aCentralWidget = new QWidget (myMainWindow);
}
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());
+ }
}
// =======================================================================
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;
}
}
{
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();
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();
}
// =======================================================================
{
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++)
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 :
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 :
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();
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())
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);
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;
//! \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();
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
#include <Standard_ExtString.hxx>
#include <Standard_Version.hxx>
-#define USE_CLIPPLANE
+//#define USE_CLIPPLANE
#ifdef USE_CLIPPLANE
#include <Graphic3d_ClipPlane.hxx>
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);
}
// =======================================================================
#define ViewControl_PropertiesStream_H
#include <Standard.hxx>
+#include <Standard_SStream.hxx>
#include <NCollection_Vector.hxx>
#include <TCollection_AsciiString.hxx>
#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>
{
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();
+ }
+}
#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>
//! \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