1
0
mirror of https://git.dev.opencascade.org/repos/occt.git synced 2025-09-08 14:17:06 +03:00

0030268: Inspectors - improvements in VInspector plugin

- display BVH information in VInspector

(cherry picked from commit ca4acb9b1d)
This commit is contained in:
nds
2019-06-06 08:25:49 +03:00
parent 4ae9b4b7cd
commit 2cabcf39aa
95 changed files with 4653 additions and 81 deletions

View 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

View File

@@ -18,6 +18,11 @@
#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.

View File

@@ -21,10 +21,12 @@
#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;

View 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;
}

View File

@@ -24,6 +24,10 @@
#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.

View 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
{
}

View 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)

View File

@@ -174,4 +174,13 @@ void Bnd_Range::Split(const Standard_Real theVal,
{
theList.Append(Bnd_Range(aValPrev, myLast));
}
}
}
//=======================================================================
//function : ToString
//purpose :
//=======================================================================
TCollection_AsciiString Bnd_Range::ToString() const
{
return TCollection_AsciiString ("[") + myFirst + ", " + myLast + "]";
}

View File

@@ -18,6 +18,7 @@
#include <Standard_Real.hxx>
#include <Standard_ConstructionError.hxx>
#include <TCollection_AsciiString.hxx>
#include <NCollection_List.hxx>
@@ -256,6 +257,10 @@ public:
return ((myFirst == theOther.myFirst) && (myLast == theOther.myLast));
}
//! Covers point into string in format: [myFirst, myLast]
//! \return the string value
Standard_EXPORT TCollection_AsciiString ToString() const;
private:
Standard_Real myFirst; //!< Start of range

View 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;
}

View 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:

View 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

View 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())
{

View 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;
}

View 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.

View 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)); }

View 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

View File

@@ -21,6 +21,11 @@ namespace
{
"FIRST_ACCEPTABLE", "ONLY_TOPMOST"
};
static Standard_CString SelectMgr_Table_PrintBVHSubset[4] =
{
"3d", "3dPersistent", "2dPersistent", "Nb"
};
}
//=======================================================================
@@ -52,3 +57,33 @@ Standard_Boolean SelectMgr::PickingStrategyFromString (Standard_CString theTypeS
}
return Standard_False;
}
//=======================================================================
//function : BVHSubsetToString
//purpose :
//=======================================================================
Standard_CString SelectMgr::BVHSubsetToString (SelectMgr_SelectableObjectSet::BVHSubset theType)
{
return SelectMgr_Table_PrintBVHSubset[theType];
}
//=======================================================================
//function : BVHSubsetFromString
//purpose :
//=======================================================================
Standard_Boolean SelectMgr::BVHSubsetFromString (Standard_CString theTypeString,
SelectMgr_SelectableObjectSet::BVHSubset& theType)
{
TCollection_AsciiString aName (theTypeString);
aName.UpperCase();
for (Standard_Integer aTypeIter = 0; aTypeIter <= SelectMgr_SelectableObjectSet::BVHSubsetNb; ++aTypeIter)
{
Standard_CString aTypeName = SelectMgr_Table_PrintBVHSubset[aTypeIter];
if (aName == aTypeName)
{
theType = SelectMgr_SelectableObjectSet::BVHSubset (aTypeIter);
return Standard_True;
}
}
return Standard_False;
}

View File

@@ -15,6 +15,7 @@
#define _SelectMgr_HeaderFile
#include <SelectMgr_PickingStrategy.hxx>
#include <SelectMgr_SelectableObjectSet.hxx>
#include <SelectMgr_StateOfSelection.hxx>
#include <SelectMgr_TypeOfBVHUpdate.hxx>
#include <SelectMgr_TypeOfUpdate.hxx>
@@ -52,6 +53,30 @@ public:
Standard_EXPORT static Standard_Boolean PickingStrategyFromString (const Standard_CString theTypeString,
SelectMgr_PickingStrategy& theType);
//! Returns the string name for a given orientation type.
//! @param theType orientation type
//! @return string identifier from the list Xpos, Ypos, Zpos and others
Standard_EXPORT static Standard_CString BVHSubsetToString (SelectMgr_SelectableObjectSet::BVHSubset theType);
//! Returns the orientation type from the given string identifier (using case-insensitive comparison).
//! @param theTypeString string identifier
//! @return orientation type or BVHSubset_3d if string identifier is invalid
static SelectMgr_SelectableObjectSet::BVHSubset BVHSubsetFromString (Standard_CString theTypeString)
{
SelectMgr_SelectableObjectSet::BVHSubset aType = SelectMgr_SelectableObjectSet::BVHSubset_3d;
BVHSubsetFromString (theTypeString, aType);
return aType;
}
//! Determines the shape type from the given string identifier (using case-insensitive comparison).
//! @param theTypeString string identifier
//! @param theType detected shape type
//! @return TRUE if string identifier is known
Standard_EXPORT static Standard_Boolean BVHSubsetFromString (const Standard_CString theTypeString,
SelectMgr_SelectableObjectSet::BVHSubset& theType);
};
#endif // _SelectMgr_HeaderFile

View File

@@ -15,6 +15,9 @@
#include <SelectMgr_BaseFrustum.hxx>
#include <Message.hxx>
#include <Message_Alerts.hxx>
IMPLEMENT_STANDARD_RTTIEXT(SelectMgr_BaseFrustum,Standard_Transient)
//=======================================================================
@@ -251,3 +254,17 @@ Standard_Boolean SelectMgr_BaseFrustum::IsClipped (const Graphic3d_SequenceOfHCl
{
return Standard_True;
}
//=======================================================================
//function : Dump
//purpose :
//=======================================================================
void SelectMgr_BaseFrustum::Dump(Standard_OStream& OS)const
{
DUMP_VALUES (OS, "SelectMgr_BaseFrustum", 2);
DUMP_VALUES (OS, "myPixelTolerance", myPixelTolerance);
DUMP_VALUES (OS, "myIsOrthographic", myIsOrthographic);
DUMP_VALUES (OS, "myBuilder", Message::TransientToString (myBuilder));
DUMP_VALUES (OS, "myCamera", Message::TransientToString (myCamera));
}

View File

@@ -35,6 +35,8 @@
#include <SelectBasics_PickResult.hxx>
#include <Standard_OStream.hxx>
//! This class is an interface for different types of selecting frustums,
//! defining different selection types, like point, box or polyline
//! selection. It contains signatures of functions for detection of
@@ -186,6 +188,9 @@ public:
return;
}
//! Dumps the content of me on the stream <OS>.
Standard_EXPORT virtual void Dump (Standard_OStream& OS) const;
DEFINE_STANDARD_RTTIEXT(SelectMgr_BaseFrustum,Standard_Transient)
protected:

View File

@@ -23,6 +23,7 @@
#include <SelectMgr_BaseFrustum.hxx>
#include <TColgp_HArray1OfPnt.hxx>
#include <TColgp_Array1OfPnt2d.hxx>
#include <Standard_OStream.hxx>
//! This is an internal class containing representation of rectangular selecting frustum, created in case
//! of point and box selection, and algorithms for overlap detection between selecting
@@ -58,6 +59,9 @@ public:
SelectMgr_Frustum() : SelectMgr_BaseFrustum() {};
//! Dumps the content of me on the stream <OS>.
Standard_EXPORT virtual void Dump (Standard_OStream& OS) const Standard_OVERRIDE;
protected:
// SAT Tests for different objects

View File

@@ -14,9 +14,13 @@
// commercial license or contractual agreement.
#include <NCollection_Vector.hxx>
#include <Message_Alerts.hxx>
#include <Poly_Array1OfTriangle.hxx>
#include <Standard_Assert.hxx>
//IMPLEMENT_STANDARD_RTTIEXT(SelectMgr_Frustum, SelectMgr_BaseFrustum)
// =======================================================================
// function : isSeparated
// purpose : Checks if AABB and frustum are separated along the given axis.
@@ -461,3 +465,43 @@ Standard_Boolean SelectMgr_Frustum<N>::hasOverlap (const gp_Pnt& thePnt1,
return Standard_True;
}
//=======================================================================
//function : Dump
//purpose :
//=======================================================================
template <int N>
void SelectMgr_Frustum<N>::Dump(Standard_OStream& OS)const
{
DUMP_VALUES (OS, "SelectMgr_Frustum<N>", 2);
DUMP_VALUES (OS, "myPlanes", N + 2);
for (int anIndex = 0; anIndex < N + 2; anIndex++)
DUMP_VALUES (OS, anIndex, myPlanes[anIndex].XYZ().ToString());
DUMP_VALUES (OS, "myVertices", N * 2);
for (int anIndex = 0; anIndex < N * 2; anIndex++)
DUMP_VALUES (OS, anIndex, myVertices[anIndex].XYZ().ToString());
DUMP_VALUES (OS, "myMaxVertsProjections", N + 2);
for (int anIndex = 0; anIndex < N + 2; anIndex++)
DUMP_VALUES (OS, anIndex, myMaxVertsProjections[anIndex]);
DUMP_VALUES (OS, "myMinVertsProjections", N + 2);
for (int anIndex = 0; anIndex < N + 2; anIndex++)
DUMP_VALUES (OS, anIndex, myMinVertsProjections[anIndex]);
DUMP_VALUES (OS, "myMaxOrthoVertsProjections", 3);
for (int anIndex = 0; anIndex < 3; anIndex++)
DUMP_VALUES (OS, anIndex, myMaxOrthoVertsProjections[anIndex]);
DUMP_VALUES (OS, "myMinOrthoVertsProjections", 3);
for (int anIndex = 0; anIndex < 3; anIndex++)
DUMP_VALUES (OS, anIndex, myMinOrthoVertsProjections[anIndex]);
DUMP_VALUES (OS, "myEdgeDirs", 6);
for (int anIndex = 0; anIndex < 6; anIndex++)
DUMP_VALUES (OS, anIndex, myEdgeDirs[anIndex].XYZ().ToString());
SelectMgr_BaseFrustum::Dump (OS);
}

View File

@@ -15,9 +15,12 @@
#include <NCollection_Vector.hxx>
#include <Poly_Array1OfTriangle.hxx>
#include <Message_Alerts.hxx>
#include <Message_PerfMeter.hxx>
#include <SelectMgr_RectangularFrustum.hxx>
IMPLEMENT_STANDARD_RTTIEXT(SelectMgr_RectangularFrustum, SelectMgr_Frustum<4> )
// =======================================================================
// function : segmentSegmentDistance
// purpose :
@@ -138,6 +141,8 @@ namespace
const Handle(SelectMgr_FrustumBuilder)& theBuilder,
gp_Pnt* theVertices, gp_Vec* theEdges)
{
Message_PerfMeter aPerfMeter;
MESSAGE_INFO ("SelectMgr_RectangularFrustum::computeFrustum", "", &aPerfMeter, NULL);
// LeftTopNear
theVertices[0] = theBuilder->ProjectPntOnViewPlane (theMinPnt.X(),
theMaxPnt.Y(),
@@ -272,6 +277,8 @@ void SelectMgr_RectangularFrustum::cacheVertexProjections (SelectMgr_Rectangular
// =======================================================================
void SelectMgr_RectangularFrustum::Build (const gp_Pnt2d &thePoint)
{
Message_PerfMeter aPerfMeter;
MESSAGE_INFO ("SelectMgr_RectangularFrustum::Build_1", "", &aPerfMeter, NULL);
myNearPickedPnt = myBuilder->ProjectPntOnViewPlane (thePoint.X(), thePoint.Y(), 0.0);
myFarPickedPnt = myBuilder->ProjectPntOnViewPlane (thePoint.X(), thePoint.Y(), 1.0);
myViewRayDir = myFarPickedPnt.XYZ() - myNearPickedPnt.XYZ();
@@ -304,6 +311,8 @@ void SelectMgr_RectangularFrustum::Build (const gp_Pnt2d &thePoint)
void SelectMgr_RectangularFrustum::Build (const gp_Pnt2d& theMinPnt,
const gp_Pnt2d& theMaxPnt)
{
Message_PerfMeter aPerfMeter;
MESSAGE_INFO ("SelectMgr_RectangularFrustum::Build_2", "", &aPerfMeter, NULL);
myNearPickedPnt = myBuilder->ProjectPntOnViewPlane ((theMinPnt.X() + theMaxPnt.X()) * 0.5,
(theMinPnt.Y() + theMaxPnt.Y()) * 0.5,
0.0);
@@ -431,6 +440,10 @@ Standard_Boolean SelectMgr_RectangularFrustum::Overlaps (const SelectMgr_Vec3& t
const SelectMgr_Vec3& theBoxMax,
Standard_Boolean* theInside) const
{
Message_PerfMeter aPerfMeter;
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);
}
@@ -443,6 +456,8 @@ Standard_Boolean SelectMgr_RectangularFrustum::Overlaps (const SelectMgr_Vec3& t
const SelectMgr_Vec3& theBoxMax,
SelectBasics_PickResult& thePickResult) const
{
Message_PerfMeter aPerfMeter;
MESSAGE_INFO ("SelectMgr_RectangularFrustum::Overlaps_vv", "", &aPerfMeter, NULL);
if (!hasOverlap (theBoxMin, theBoxMax))
return Standard_False;
@@ -463,6 +478,8 @@ Standard_Boolean SelectMgr_RectangularFrustum::Overlaps (const SelectMgr_Vec3& t
Standard_Boolean SelectMgr_RectangularFrustum::Overlaps (const gp_Pnt& thePnt,
SelectBasics_PickResult& thePickResult) const
{
Message_PerfMeter aPerfMeter;
MESSAGE_INFO ("SelectMgr_RectangularFrustum::Overlaps_1p", "", &aPerfMeter, NULL);
if (!hasOverlap (thePnt))
return Standard_False;
@@ -482,6 +499,8 @@ Standard_Boolean SelectMgr_RectangularFrustum::Overlaps (const gp_Pnt& thePnt,
// =======================================================================
Standard_Boolean SelectMgr_RectangularFrustum::Overlaps (const gp_Pnt& thePnt) const
{
Message_PerfMeter aPerfMeter;
MESSAGE_INFO ("SelectMgr_RectangularFrustum::Overlaps_1", "", &aPerfMeter, NULL);
return hasOverlap (thePnt);
}
@@ -493,6 +512,9 @@ Standard_Boolean SelectMgr_RectangularFrustum::Overlaps (const gp_Pnt& thePnt1,
const gp_Pnt& thePnt2,
SelectBasics_PickResult& thePickResult) const
{
Message_PerfMeter aPerfMeter;
MESSAGE_INFO ("SelectMgr_RectangularFrustum::Overlaps_2", "", &aPerfMeter, NULL);
if (!hasOverlap (thePnt1, thePnt2))
return Standard_False;
@@ -512,6 +534,8 @@ Standard_Boolean SelectMgr_RectangularFrustum::Overlaps (const TColgp_Array1OfPn
Select3D_TypeOfSensitivity theSensType,
SelectBasics_PickResult& thePickResult) const
{
Message_PerfMeter aPerfMeter;
MESSAGE_INFO ("SelectMgr_RectangularFrustum::Overlaps_n", "", &aPerfMeter, NULL);
if (theSensType == Select3D_TOS_BOUNDARY)
{
Standard_Integer aMatchingSegmentsNb = -1;
@@ -562,6 +586,9 @@ Standard_Boolean SelectMgr_RectangularFrustum::Overlaps (const gp_Pnt& thePnt1,
Select3D_TypeOfSensitivity theSensType,
SelectBasics_PickResult& thePickResult) const
{
Message_PerfMeter aPerfMeter;
MESSAGE_INFO ("SelectMgr_RectangularFrustum::Overlaps_3", "", &aPerfMeter, NULL);
if (theSensType == Select3D_TOS_BOUNDARY)
{
const gp_Pnt aPntsArrayBuf[4] = { thePnt1, thePnt2, thePnt3, thePnt1 };
@@ -651,6 +678,9 @@ Standard_Real SelectMgr_RectangularFrustum::DistToGeometryCenter (const gp_Pnt&
// =======================================================================
gp_Pnt SelectMgr_RectangularFrustum::DetectedPoint (const Standard_Real theDepth) const
{
Message_PerfMeter aPerfMeter;
MESSAGE_INFO ("SelectMgr_RectangularFrustum::DetectedPoint", "", &aPerfMeter, NULL);
return myNearPickedPnt.XYZ() + myViewRayDir.Normalized().XYZ() * theDepth / myScale;
}
@@ -661,6 +691,9 @@ gp_Pnt SelectMgr_RectangularFrustum::DetectedPoint (const Standard_Real theDepth
void SelectMgr_RectangularFrustum::computeClippingRange (const Graphic3d_SequenceOfHClipPlane& thePlanes,
SelectMgr_ViewClipRange& theRange) const
{
Message_PerfMeter aPerfMeter;
MESSAGE_INFO ("SelectMgr_RectangularFrustum::computeClippingRange", "", &aPerfMeter, NULL);
Standard_Real aPlaneA, aPlaneB, aPlaneC, aPlaneD;
for (Graphic3d_SequenceOfHClipPlane::Iterator aPlaneIt (thePlanes); aPlaneIt.More(); aPlaneIt.Next())
{
@@ -746,6 +779,9 @@ void SelectMgr_RectangularFrustum::computeClippingRange (const Graphic3d_Sequenc
Standard_Boolean SelectMgr_RectangularFrustum::IsClipped (const Graphic3d_SequenceOfHClipPlane& thePlanes,
const Standard_Real theDepth) const
{
Message_PerfMeter aPerfMeter;
MESSAGE_INFO ("IsClipped", "", &aPerfMeter, NULL);
SelectMgr_ViewClipRange aRange;
computeClippingRange (thePlanes, aRange);
return aRange.IsClipped (theDepth);
@@ -797,3 +833,23 @@ void SelectMgr_RectangularFrustum::GetPlanes (NCollection_Vector<SelectMgr_Vec4>
thePlaneEquations.Append (anEquation);
}
}
//=======================================================================
//function : Dump
//purpose :
//=======================================================================
void SelectMgr_RectangularFrustum::Dump(Standard_OStream& OS)const
{
DUMP_VALUES (OS, "SelectMgr_RectangularFrustum", 2);
DUMP_VALUES (OS, "myNearPickedPnt", myNearPickedPnt.XYZ().ToString());
DUMP_VALUES (OS, "myFarPickedPnt", myFarPickedPnt.XYZ().ToString());
DUMP_VALUES (OS, "myViewRayDir", myViewRayDir.XYZ().ToString());
DUMP_VALUES (OS, "myMousePos", myMousePos.XY().ToString());
DUMP_VALUES (OS, "myScale", myScale);
DUMP_VALUES (OS, "myIsViewClipEnabled", myIsViewClipEnabled);
DUMP_VALUES (OS, "myViewClipRange", "");
myViewClipRange.Dump (OS);
SelectMgr_Frustum<4>::Dump (OS);
}

View File

@@ -18,6 +18,7 @@
#include <SelectMgr_Frustum.hxx>
#include <SelectMgr_ViewClipRange.hxx>
#include <Standard_OStream.hxx>
//! This class contains representation of rectangular selecting frustum, created in case
//! of point and box selection, and algorithms for overlap detection between selecting
@@ -137,6 +138,9 @@ public:
//! Ax + By + Cz + D = 0) to the given vector
Standard_EXPORT virtual void GetPlanes (NCollection_Vector<SelectMgr_Vec4>& thePlaneEquations) const Standard_OVERRIDE;
//! Dumps the content of me on the stream <OS>.
Standard_EXPORT virtual void Dump (Standard_OStream& OS) const Standard_OVERRIDE;
protected:
Standard_EXPORT void segmentSegmentDistance (const gp_Pnt& theSegPnt1,
@@ -164,6 +168,9 @@ private:
RightTopNear, RightTopFar,
RightBottomNear, RightBottomFar };
public:
DEFINE_STANDARD_RTTIEXT(SelectMgr_RectangularFrustum, SelectMgr_Frustum<4>)
private:
gp_Pnt myNearPickedPnt; //!< 3d projection of user-picked selection point onto near view plane

View File

@@ -19,7 +19,7 @@
#include <BVH_BinnedBuilder.hxx>
#include <BVH_LinearBuilder.hxx>
//#define REPORT_SELECTION_BUILD
#define REPORT_SELECTION_BUILD
#ifdef REPORT_SELECTION_BUILD
#include <Message_Alerts.hxx>
#include <Message_PerfMeter.hxx>
@@ -360,11 +360,17 @@ void SelectMgr_SelectableObjectSet::UpdateBVH (const Handle(Graphic3d_Camera)& t
const Standard_Integer theViewportWidth,
const Standard_Integer theViewportHeight)
{
#ifdef REPORT_SELECTION_BUILD
Message_PerfMeter aPerfMeter;
MESSAGE_INFO ("UpdateBVH", "", &aPerfMeter, NULL);
#endif
// -----------------------------------------
// check and update 3D BVH tree if necessary
// -----------------------------------------
if (!IsEmpty (BVHSubset_3d) && myIsDirty[BVHSubset_3d])
{
MESSAGE_INFO ("Check and update 3D BVH", "", &aPerfMeter, NULL);
// construct adaptor over private fields to provide direct access for the BVH builder
BVHBuilderAdaptorRegular anAdaptor (myObjects[BVHSubset_3d], myDisabledZLayers);
@@ -386,6 +392,7 @@ void SelectMgr_SelectableObjectSet::UpdateBVH (const Handle(Graphic3d_Camera)& t
if (!IsEmpty (BVHSubset_3dPersistent) &&
(myIsDirty[BVHSubset_3dPersistent] || myLastViewState.IsChanged (theViewState) || isWindowSizeChanged))
{
MESSAGE_INFO ("Check and update 3D persistence BVH tree", "", &aPerfMeter, NULL);
// construct adaptor over private fields to provide direct access for the BVH builder
BVHBuilderAdaptorPersistent anAdaptor (myObjects[BVHSubset_3dPersistent], myDisabledZLayers,
theCamera, theProjectionMat, theWorldViewMat, theViewportWidth, theViewportHeight);
@@ -400,6 +407,7 @@ void SelectMgr_SelectableObjectSet::UpdateBVH (const Handle(Graphic3d_Camera)& t
if (!IsEmpty (BVHSubset_2dPersistent) &&
(myIsDirty[BVHSubset_2dPersistent] || myLastViewState.IsProjectionChanged (theViewState) || isWindowSizeChanged))
{
MESSAGE_INFO ("Check and update 2D persistence BVH tree", "", &aPerfMeter, NULL);
// construct adaptor over private fields to provide direct access for the BVH builder
BVHBuilderAdaptorPersistent anAdaptor (myObjects[BVHSubset_2dPersistent], myDisabledZLayers,
theCamera, theProjectionMat, SelectMgr_SelectableObjectSet_THE_IDENTITY_MAT, theViewportWidth, theViewportHeight);

View File

@@ -14,6 +14,8 @@
// commercial license or contractual agreement.
#include <SelectMgr_SelectingVolumeManager.hxx>
#include <Message_Alerts.hxx>
#include <Message_PerfMeter.hxx>
//=======================================================================
// function : SelectMgr_SelectingVolumeManager
@@ -396,6 +398,9 @@ gp_Pnt SelectMgr_SelectingVolumeManager::DetectedPoint (const Standard_Real theD
Standard_Boolean SelectMgr_SelectingVolumeManager::IsClipped (const Graphic3d_SequenceOfHClipPlane& thePlanes,
const Standard_Real& theDepth) const
{
Message_PerfMeter aPerfMeter;
MESSAGE_INFO ("SelectMgr_SelectingVolumeManager::IsClipped", "", &aPerfMeter, NULL);
if (myActiveSelectionType != Point)
return Standard_False;

View File

@@ -206,6 +206,19 @@ public:
return mySelectingVolumes[myActiveSelectionType / 2];
}
//! Returns active selecting volume that was built during last
//! run of OCCT selection mechanism
Handle(SelectMgr_BaseFrustum) GetVolume (const SelectionType& theType) const
{
switch (theType)
{
case Point:
case Box: return mySelectingVolumes[Frustum];
case Polyline: return mySelectingVolumes[FrustumSet];
default: return NULL;
}
}
//! Stores plane equation coefficients (in the following form:
//! Ax + By + Cz + D = 0) to the given vector
virtual void GetPlanes (NCollection_Vector<SelectMgr_Vec4>& thePlaneEquations) const Standard_OVERRIDE

View File

@@ -18,6 +18,7 @@
#include <Bnd_Range.hxx>
#include <Standard_TypeDef.hxx>
#include <Standard_OStream.hxx>
//! Class for handling depth clipping range.
//! It is used to perform checks in case if global (for the whole view)
@@ -62,6 +63,16 @@ public:
//! Adds a clipping sub-range (for clipping chains).
void AddClipSubRange (const Bnd_Range& theRange) { myClipRanges.push_back (theRange); }
//! Dumps the content of me on the stream <OS>.
Standard_EXPORT void Dump (Standard_OStream& OS) const
{
DUMP_VALUES (OS, "SelectMgr_ViewClipRange", 2);
DUMP_VALUES (OS, "myUnclipRange", myUnclipRange.ToString());
DUMP_VALUES (OS, "myClipRanges", myClipRanges.size());
for (size_t aRangeIter = 0; aRangeIter < myClipRanges.size(); ++aRangeIter)
DUMP_VALUES (OS, aRangeIter, myClipRanges[aRangeIter].ToString());
}
private:
std::vector<Bnd_Range> myClipRanges;

View File

@@ -36,7 +36,7 @@
#include <algorithm>
//#define REPORT_SELECTION_BUILD
#define REPORT_SELECTION_BUILD
#ifdef REPORT_SELECTION_BUILD
#include <Message_Alerts.hxx>
#include <Message_PerfMeter.hxx>
@@ -280,6 +280,16 @@ void SelectMgr_ViewerSelector::checkOverlap (const Handle(SelectBasics_Sensitive
return;
}
if (!mySelectingVolumeMgr.ViewClipping().IsNull())
{
Standard_Real aDepth = /*aPickResult.HasPickedPoint() ?*+/ aPickResult.Depth();// :*/ aPickResult.DistToGeomCenter();
Standard_Boolean isClipped = mySelectingVolumeMgr.IsClipped (*mySelectingVolumeMgr.ViewClipping(),
aDepth);
if (isClipped)
return;
else
int aValue = 9;
}
if (HasDepthClipping (anOwner)
&& !aSelectable.IsNull()
&& theMgr.GetActiveSelectionType() == SelectMgr_SelectingVolumeManager::Point)
@@ -618,6 +628,7 @@ void SelectMgr_ViewerSelector::TraverseSensitives()
Standard_Integer aWidth;
Standard_Integer aHeight;
mySelectingVolumeMgr.WindowSize (aWidth, aHeight);
MESSAGE_INFO ("UpdateBVH", "", &aPerfMeter, aParentAlert);
mySelectableObjects.UpdateBVH (mySelectingVolumeMgr.Camera(),
mySelectingVolumeMgr.ProjectionMatrix(),
mySelectingVolumeMgr.WorldViewMatrix(),
@@ -637,14 +648,14 @@ void SelectMgr_ViewerSelector::TraverseSensitives()
for (Standard_Integer aBVHSetIt = 0; aBVHSetIt < SelectMgr_SelectableObjectSet::BVHSubsetNb; ++aBVHSetIt)
{
#ifdef REPORT_SELECTION_BUILD
MESSAGE_INFO (TCollection_AsciiString ("aBVHSetIt") + aBVHSetIt, "", &aPerfMeter, aParentAlert);
Handle(Message_Alert) aParentAlertLevel1 = OCCT_Message_Alert;
#endif
SelectMgr_SelectableObjectSet::BVHSubset aBVHSubset =
static_cast<SelectMgr_SelectableObjectSet::BVHSubset> (aBVHSetIt);
#ifdef REPORT_SELECTION_BUILD
MESSAGE_INFO (TCollection_AsciiString ("aBVHSetIt"), SelectMgr::BVHSubsetToString (aBVHSubset), &aPerfMeter, aParentAlert);
Handle(Message_Alert) aParentAlertLevel1 = OCCT_Message_Alert;
#endif
if (mySelectableObjects.IsEmpty (aBVHSubset))
{
continue;
@@ -756,6 +767,7 @@ void SelectMgr_ViewerSelector::TraverseSensitives()
}
}
MESSAGE_INFO ("SortResult", "", &aPerfMeter, aParentAlert);
SortResult();
#ifdef REPORT_SELECTION_BUILD
Standard_SStream aStreamDone;

View File

@@ -205,6 +205,12 @@ public:
//! Returns instance of selecting volume manager of the viewer selector
SelectMgr_SelectingVolumeManager& GetManager() { return mySelectingVolumeMgr; }
//! Returns container of selectable objects
const SelectMgr_SelectableObjectSet& GetSelectableObjects() const { return mySelectableObjects; }
//! Returns container of sensitives
const SelectMgr_MapOfObjectSensitives& GetObjectSensitives() const { return myMapOfObjectSensitives; }
//! Marks all added sensitive entities of all objects as non-selectable
Standard_EXPORT void ResetSelectionActivationStatus();

View File

@@ -69,7 +69,7 @@
#include <OSD_Timer.hxx>
//#define REPORT_SELECTION_BUILD
#define REPORT_SELECTION_BUILD
#ifdef REPORT_SELECTION_BUILD
#include <Message_Alerts.hxx>
#include <Message_PerfMeter.hxx>
@@ -162,6 +162,15 @@ void StdSelect_ViewerSelector3d::Pick (const Standard_Integer theXPMin,
const Standard_Integer theYPMax,
const Handle(V3d_View)& theView)
{
#ifdef REPORT_SELECTION_BUILD
Message_PerfMeter aPerfMeter;
MESSAGE_INFO ("Pick", TCollection_AsciiString ("min/max: (") +
theXPMin + ", " + theYPMin + ") / (" +
theXPMax + ", " + theYPMax + ") "
, &aPerfMeter, NULL);
Handle(Message_Alert) aParentAlert = OCCT_Message_Alert;
#endif
updateZLayers (theView);
mySelectingVolumeMgr.SetCamera (theView->Camera());
mySelectingVolumeMgr.SetActiveSelectionType (SelectMgr_SelectingVolumeManager::Box);

View File

@@ -24,9 +24,10 @@ class TopoDS_AlertAttribute : public Message_Attribute
{
public:
//! Constructor with shape argument
Standard_EXPORT TopoDS_AlertAttribute (const TopoDS_Shape& theShape,
const TCollection_AsciiString& theName = TCollection_AsciiString(),
const TCollection_AsciiString& theDescription = TCollection_AsciiString());
TopoDS_AlertAttribute (const TopoDS_Shape& theShape,
const TCollection_AsciiString& theName = TCollection_AsciiString(),
const TCollection_AsciiString& theDescription = TCollection_AsciiString())
: Message_Attribute (theName, theDescription), myShape (theShape) {}
//! Returns contained shape
const TopoDS_Shape& GetShape() const { return myShape; }

View File

@@ -22,6 +22,9 @@
#include <Standard_Real.hxx>
#include <Standard_Integer.hxx>
#include <Standard_Boolean.hxx>
#include <TCollection_AsciiString.hxx>
class Standard_ConstructionError;
class Standard_OutOfRange;
class gp_Mat2d;
@@ -269,6 +272,15 @@ public:
}
//! Covers point into string in format: (X, Y)
//! \return the string value
Standard_EXPORT TCollection_AsciiString ToString() const;
//! Converts text value into parameters if possible, the string format is: (X, Y)
//! \return true if conversion is done
Standard_EXPORT Standard_Boolean FromString (const TCollection_AsciiString& theValue);
protected:

View File

@@ -227,3 +227,37 @@ inline gp_XY operator* (const Standard_Real Scalar,
return Coord1.Multiplied(Scalar);
}
inline TCollection_AsciiString gp_XY::ToString() const
{
return TCollection_AsciiString ("(") + x + ", " + y + ")";
}
inline Standard_Boolean gp_XY::FromString (const TCollection_AsciiString& theValue)
{
TCollection_AsciiString aCurrentString = theValue, aValueString;
Standard_Integer aPosition = aCurrentString.Search ("(");
if (aPosition != 1)
return Standard_False;
aCurrentString = aCurrentString.Split (aPosition);
Standard_Real aX, anY;
// x value
aPosition = aCurrentString.Search (", ");
if (aPosition < 0)
return Standard_False;
aCurrentString = aValueString.Split (aPosition);
aX = aValueString.RealValue();
aCurrentString = aCurrentString.Split (2);
// y value
aPosition = aCurrentString.Search (")");
if (aPosition < 0)
return Standard_False;
aCurrentString = aValueString.Split (aPosition);
anY = aValueString.RealValue();
x = aX;
y = anY;
return Standard_True;
}

View File

@@ -22,6 +22,9 @@
#include <Standard_Real.hxx>
#include <Standard_Integer.hxx>
#include <Standard_Boolean.hxx>
#include <TCollection_AsciiString.hxx>
class Standard_ConstructionError;
class Standard_OutOfRange;
class gp_Mat;
@@ -324,6 +327,14 @@ public:
void SetLinearForm (const gp_XYZ& XYZ1, const gp_XYZ& XYZ2);
//! 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);
protected:

View File

@@ -307,7 +307,50 @@ inline gp_XYZ operator* (const Standard_Real Scalar, const gp_XYZ& Coord1) {
}
inline TCollection_AsciiString gp_XYZ::ToString() const
{
return TCollection_AsciiString ("(") + x + ", " + y + ", " + z + ")";
}
inline Standard_Boolean gp_XYZ::FromString (const TCollection_AsciiString& theValue)
{
TCollection_AsciiString aCurrentString = theValue, aValueString;
Standard_Integer aPosition = aCurrentString.Search ("(");
if (aPosition != 1)
return Standard_False;
aCurrentString = aCurrentString.Split (aPosition);
Standard_Real aX, anY, aZ;
// x value
aPosition = aCurrentString.Search (", ");
if (aPosition < 0)
return Standard_False;
aValueString = aCurrentString;
aCurrentString = aValueString.Split (aPosition - 1);
aX = aValueString.RealValue();
aCurrentString = aCurrentString.Split (2);
// y value
aPosition = aCurrentString.Search (", ");
if (aPosition < 0)
return Standard_False;
aValueString = aCurrentString;
aCurrentString = aValueString.Split (aPosition - 1);
anY = aValueString.RealValue();
aCurrentString = aCurrentString.Split (2);
// z value
aPosition = aCurrentString.Search (")");
if (aPosition < 0)
return Standard_False;
aValueString = aCurrentString;
aCurrentString = aValueString.Split (aPosition);
aZ = aValueString.RealValue();
x = aX;
y = anY;
z = aZ;
return Standard_True;
}

View File

@@ -0,0 +1,41 @@
# creating three 3D objects
# cut view scene by clipping plane
# expecting two objects selected
pload ALL
vinit View1
box b 10 10 10
vdisplay b
box b1 -5 0 0 2 2 2
vdisplay b1
box b2 13 0 0 2 2 2
vdisplay b2
vsetdispmode 1
vclipplane create pln
vclipplane set pln view Driver1/Viewer1/View1
vclipplane change pln equation -1 0 0 5
vtop
vfit
vzoom 0.5
vselect 40<34>100<30>370<37>300
# expected result is 2 objects, but clipping is not applyed for selection by box
vnbselected
# check selected elements in Inspector
pload INSPECTOR
tinspector <20>plugins vinspector
tinspector <20>plugins messageview
tinspector <20>activate messageview
activateReport
tinspector -update
# see messages from selection preparing in Inspector
vselect 40<34>100<30>370<37>300

View File

@@ -121,7 +121,9 @@ void MessageModel_Actions::AddMenuActions (const QModelIndexList& theSelectedInd
#endif
}
else if (anAlertItem)
{
theMenu->addAction (myActions[MessageModel_ActionType_ExportToShapeView]);
}
theMenu->addSeparator();
}

View File

@@ -18,12 +18,16 @@
#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();
}
// =======================================================================

View 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

View File

@@ -204,3 +204,24 @@ double MessageModel_ItemReport::AmountElapsedTime (const Handle(Message_Report)&
}
return anAmountTime;
}
// =======================================================================
// function : FindReport
// purpose :
// =======================================================================
Handle(Message_Report) MessageModel_ItemReport::FindReport (const MessageModel_ItemBasePtr& theItem)
{
Handle(Message_Report) aReport;
MessageModel_ItemBasePtr anItem = theItem;
while (anItem)
{
MessageModel_ItemReportPtr aReportItem = itemDynamicCast<MessageModel_ItemReport>(anItem);
if (aReportItem)
return aReportItem->GetReport();
anItem = itemDynamicCast<MessageModel_ItemBase>(anItem->Parent());
}
return NULL;
}

View File

@@ -80,6 +80,9 @@ public:
//! \return double value
Standard_EXPORT static double AmountElapsedTime (const Handle(Message_Report)& theReport);
//! Returns report of the item
static Handle(Message_Report) FindReport (const MessageModel_ItemBasePtr& thetItem);
protected:
//! Initialize the current item. It is empty because Reset() is also empty.

View File

@@ -27,6 +27,15 @@
// =======================================================================
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);
}

View File

@@ -30,11 +30,14 @@
#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>
#include <inspector/View_Widget.hxx>
#include <AIS_Shape.hxx>
#include <Graphic3d_Camera.hxx>
#include <OSD_Environment.hxx>
#include <OSD_Directory.hxx>
@@ -98,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 :
@@ -294,6 +330,7 @@ void MessageView_Window::Init (NCollection_List<Handle(Standard_Transient)>& the
NCollection_List<Handle(Standard_Transient)> aParameters;
Handle(Message_ReportCallBack) aReportCallBack;
Handle(Graphic3d_Camera) aViewCamera;
for (NCollection_List<Handle(Standard_Transient)>::Iterator aParamsIt (theParameters);
aParamsIt.More(); aParamsIt.Next())
@@ -305,23 +342,31 @@ void MessageView_Window::Init (NCollection_List<Handle(Standard_Transient)>& the
aMessageReport->SetCallBack (myCallBack);
addReport (aMessageReport);
}
else
else if (!Handle(AIS_InteractiveContext)::DownCast (anObject).IsNull())
{
aParameters.Append (anObject);
if (aContext.IsNull())
aContext = Handle(AIS_InteractiveContext)::DownCast (anObject);
}
else if (!Handle(Graphic3d_Camera)::DownCast (anObject).IsNull())
{
aViewCamera = Handle(Graphic3d_Camera)::DownCast (anObject);
}
}
QAbstractItemModel* aModel = myTreeView->model();
if (!aModel)
return;
MessageModel_TreeModel* aTreeModel = dynamic_cast<MessageModel_TreeModel*> (aModel);
MessageModel_TreeModel* aTreeModel = dynamic_cast<MessageModel_TreeModel*> (myTreeView->model());
if (!aTreeModel)
return;
aTreeModel->EmitLayoutChanged();
if (!aContext.IsNull())
{
myContext = aContext;
myViewWindow->SetContext (View_ContextType_External, aContext);
}
if (!aViewCamera.IsNull())
myViewWindow->GetView()->GetViewer()->GetView()->Camera()->Copy (aViewCamera);
theParameters = aParameters;
}
@@ -385,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);
}
// =======================================================================
@@ -647,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);
}
}
}

View File

@@ -21,9 +21,12 @@
#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

View 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";

View File

@@ -1,3 +1,5 @@
TKernel
TKMath
TKPrim
TKTopAlgo
CSF_QT

View File

@@ -65,6 +65,9 @@ void TreeModel_ItemBase::Reset()
}
m_bInitialized = false;
myCachedValues.clear();
if (!GetProperties().IsNull())
GetProperties()->Reset();
}
// =======================================================================

View File

@@ -19,6 +19,8 @@
#include <Standard.hxx>
#include <Standard_Macro.hxx>
#include <Standard_Handle.hxx>
#include <Standard_OStream.hxx>
#include <inspector/TreeModel_ItemRole.hxx>
#include <Standard_WarningsDisable.hxx>
@@ -139,9 +141,13 @@ public:
//! Returns item table properties builder
Standard_EXPORT Handle(TreeModel_ItemProperties) GetProperties() const;
//! Dumps the content of me on the stream <OS>.
virtual Standard_Boolean Dump (Standard_OStream& OS) const { (void)OS; return Standard_False; }
//! Returns number of item rows only
static Standard_EXPORT int RowCountWithoutProperties (const TreeModel_ItemBasePtr& theItem);
protected:
//! \param theParent the parent item

View File

@@ -48,6 +48,12 @@ public:
//! Destructor
~TreeModel_ItemProperties() {}
//! If me has internal values, it should be initialized here.
virtual void Init() {}
//! If the item has internal values, there should be reseted here.
Standard_EXPORT virtual void Reset() {}
//! Returns number of item children
//! \return an integer value, ZERO by default
virtual int ChildItemCount() const { return 0; }
@@ -59,7 +65,7 @@ public:
virtual TreeModel_ItemBasePtr CreateChildItem (int theRow, int theColumn) const
{ (void)theRow; (void)theColumn; return TreeModel_ItemBasePtr(); }
//! Returns number of table rows
//! Returns number of table columns. Default value is two columns: title to value
//! \return an integer value
virtual int GetTableColumnCount() const { return 2; }

View File

@@ -9,6 +9,13 @@ VInspector_ItemAspectWindow.cxx
VInspector_ItemAspectWindow.hxx
VInspector_ItemBase.cxx
VInspector_ItemBase.hxx
VInspector_ItemBVHTree.cxx
VInspector_ItemBVHTree.hxx
VInspector_ItemBVHTreeNode.cxx
VInspector_ItemBVHTreeNode.hxx
VInspector_ItemContainer.cxx
VInspector_ItemContainer.hxx
VInspector_ItemContainerAPI.hxx
VInspector_ItemContext.cxx
VInspector_ItemContext.hxx
VInspector_ItemFolderObject.cxx
@@ -32,12 +39,16 @@ VInspector_ItemHistoryRoot.hxx
VInspector_ItemHistoryType.cxx
VInspector_ItemHistoryType.hxx
VInspector_ItemHistoryTypeInfo.hxx
VInspector_ItemOpenGlContext.cxx
VInspector_ItemOpenGlContext.hxx
VInspector_ItemOpenGlElement.cxx
VInspector_ItemOpenGlElement.hxx
VInspector_ItemOpenGlLayer.cxx
VInspector_ItemOpenGlLayer.hxx
VInspector_ItemOpenGlLayerList.cxx
VInspector_ItemOpenGlLayerList.hxx
VInspector_ItemOpenGlWindow.cxx
VInspector_ItemOpenGlWindow.hxx
VInspector_ItemPresentableObject.cxx
VInspector_ItemPresentableObject.hxx
VInspector_ItemPresentations.cxx
@@ -62,16 +73,24 @@ VInspector_ItemSelectMgrBaseFrustum.cxx
VInspector_ItemSelectMgrBaseFrustum.hxx
VInspector_ItemSelectMgrFilter.cxx
VInspector_ItemSelectMgrFilter.hxx
VInspector_ItemSelectMgrSelectableObjectSet.cxx
VInspector_ItemSelectMgrSelectableObjectSet.hxx
VInspector_ItemSelectMgrSelectingVolumeManager.cxx
VInspector_ItemSelectMgrSelectingVolumeManager.hxx
VInspector_ItemSelectMgrSelection.cxx
VInspector_ItemSelectMgrSelection.hxx
VInspector_ItemSelectMgrSensitiveEntity.cxx
VInspector_ItemSelectMgrSensitiveEntity.hxx
VInspector_ItemSelectMgrSensitiveEntitySet.cxx
VInspector_ItemSelectMgrSensitiveEntitySet.hxx
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
VInspector_PrsOpenGlElement.hxx
VInspector_SelectionType.hxx

View File

@@ -0,0 +1,196 @@
// Created on: 2019-04-29
// 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_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
// purpose :
// =======================================================================
VInspector_ItemBVHTree::VInspector_ItemBVHTree (TreeModel_ItemBasePtr theParent,
const int theRow, const int theColumn)
: VInspector_ItemBase(theParent, theRow, theColumn)
{
}
// =======================================================================
// function : initRowCount
// purpose :
// =======================================================================
int VInspector_ItemBVHTree::initRowCount() const
{
if (Column() != 0)
return 0;
opencascade::handle<BVH_Tree<Standard_Real, 3> > aTree = GetTree();
if (aTree.IsNull())
return 0;
return aTree->Length();
}
// =======================================================================
// function : initValue
// purpose :
// =======================================================================
QVariant VInspector_ItemBVHTree::initValue (const int theItemRole) const
{
QVariant aParentValue = VInspector_ItemBase::initValue (theItemRole);
if (aParentValue.isValid())
return aParentValue;
if (theItemRole != Qt::DisplayRole && theItemRole != Qt::EditRole && theItemRole != Qt::ToolTipRole)
return QVariant();
if (GetTree().IsNull())
return Column() == 0 ? "Empty BVH tree" : "";
switch (Column())
{
case 0:
{
TCollection_AsciiString aName = TCollection_AsciiString (GetTree()->DynamicType()->Name()) +
TCollection_AsciiString (" (") + myName.ToCString() + ")";
return aName.ToCString();
}
default:
break;
}
return QVariant();
}
// =======================================================================
// function : Init
// purpose :
// =======================================================================
void VInspector_ItemBVHTree::Init()
{
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);
}
setTree (aBVHTree);
UpdatePresentationShape();
TreeModel_ItemBase::Init(); // to use getIO() without circling initialization
}
// =======================================================================
// function : Reset
// purpose :
// =======================================================================
void VInspector_ItemBVHTree::Reset()
{
VInspector_ItemBase::Reset();
setTree (NULL);
myName = TCollection_AsciiString();
}
// =======================================================================
// function : initItem
// purpose :
// =======================================================================
void VInspector_ItemBVHTree::initItem() const
{
if (IsInitialized())
return;
const_cast<VInspector_ItemBVHTree*>(this)->Init();
}
// =======================================================================
// function : Dump
// purpose :
// =======================================================================
Standard_Boolean VInspector_ItemBVHTree::Dump (Standard_OStream& OS) const
{
opencascade::handle<BVH_Tree<Standard_Real, 3> > aBVHTree = GetTree();
if (aBVHTree.IsNull())
return Standard_False;
aBVHTree->Dump (OS);
return Standard_True;
}
// =======================================================================
// function : createChild
// purpose :
// =======================================================================
TreeModel_ItemBasePtr VInspector_ItemBVHTree::createChild (int theRow, int theColumn)
{
return VInspector_ItemBVHTreeNode::CreateItem (currentItem(), theRow, theColumn);
}
// =======================================================================
// function : buildPresentationShape
// purpose :
// =======================================================================
TopoDS_Shape VInspector_ItemBVHTree::buildPresentationShape()
{
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;
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;
}

View File

@@ -0,0 +1,105 @@
// Created on: 2019-04-29
// 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_ItemBVHTree_H
#define VInspector_ItemBVHTree_H
#include <Standard.hxx>
#include <inspector/VInspector_ItemBase.hxx>
#include <TopoDS_Shape.hxx>
#include <BVH_Tree.hxx>
#include <Standard_OStream.hxx>
class VInspector_ItemBVHTree;
typedef QExplicitlySharedDataPointer<VInspector_ItemBVHTree> VInspector_ItemBVHTreePtr;
//! \class VInspector_ItemBVHTree
//! Parent item, that corresponds Folder under the AIS_InteractiveContext
//! Children of the item are: none
class VInspector_ItemBVHTree : public VInspector_ItemBase
{
public:
//! Creates an item wrapped by a shared pointer
static VInspector_ItemBVHTreePtr CreateItem (TreeModel_ItemBasePtr theParent, const int theRow, const int theColumn)
{ return VInspector_ItemBVHTreePtr (new VInspector_ItemBVHTree (theParent, theRow, theColumn)); }
//! Destructor
virtual ~VInspector_ItemBVHTree() Standard_OVERRIDE {};
//! Inits the item, fills internal containers
Standard_EXPORT virtual void Init() Standard_OVERRIDE;
//! Resets cached values
Standard_EXPORT virtual void Reset() Standard_OVERRIDE;
//! Returns data object of the item.
//! \return object
virtual Handle(Standard_Transient) GetObject() const { initItem(); return myTree; }
//! Returns current drawer, initialize the drawer if it was not initialized yet
opencascade::handle<BVH_Tree<Standard_Real, 3> > GetTree() const
{ return opencascade::handle<BVH_Tree<Standard_Real, 3> >::DownCast (GetObject()); }
//! 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;
//! Returns number of displayed presentations
//! \return rows count
Standard_EXPORT virtual int initRowCount() const Standard_OVERRIDE;
//! Returns item information for the given role. Fills internal container if it was not filled yet
//! \param theItemRole a value role
//! \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.
//! \param theRow the child row position
//! \param theColumn the child column position
//! \return the created item
virtual TreeModel_ItemBasePtr createChild (int theRow, int theColumn) Standard_OVERRIDE;
private:
//! Set V3d viewer selector into the current field
//! \param theTree a viewer selector
void setTree (const opencascade::handle<BVH_Tree<Standard_Real, 3> >& theTree) { myTree = theTree; }
private:
//! Constructor
//! param theParent a parent item
//! \param theRow the item row positition in the parent item
//! \param theColumn the item column positition in the parent item
VInspector_ItemBVHTree(TreeModel_ItemBasePtr theParent, const int theRow, const int theColumn);
private:
opencascade::handle<BVH_Tree<Standard_Real, 3> > myTree; //!< the current tree
TCollection_AsciiString myName; //!< the name
};
#endif

View File

@@ -0,0 +1,162 @@
// Created on: 2019-04-29
// 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_ItemBVHTreeNode.hxx>
#include <inspector/VInspector_ItemBVHTree.hxx>
//#include <inspector/VInspector_ItemSelectMgrBaseFrustum.hxx>
//
#include <inspector/VInspector_Tools.hxx>
#include <BRep_Builder.hxx>
#include <TopoDS_Compound.hxx>
// =======================================================================
// function : initRowCount
// purpose :
// =======================================================================
int VInspector_ItemBVHTreeNode::initRowCount() const
{
return 0;
}
// =======================================================================
// function : initValue
// purpose :
// =======================================================================
QVariant VInspector_ItemBVHTreeNode::initValue (const int theItemRole) const
{
QVariant aParentValue = VInspector_ItemBase::initValue (theItemRole);
if (aParentValue.isValid())
return aParentValue;
if (theItemRole != Qt::DisplayRole && theItemRole != Qt::EditRole && theItemRole != Qt::ToolTipRole)
return QVariant();
switch (Column())
{
case 0: return QString ("TreeNode_%1").arg (Row()); break;
default:
break;
}
return QVariant();
}
// =======================================================================
// function : Init
// purpose :
// =======================================================================
void VInspector_ItemBVHTreeNode::Init()
{
UpdatePresentationShape();
TreeModel_ItemBase::Init(); // to use getIO() without circling initialization
}
// =======================================================================
// function : Reset
// purpose :
// =======================================================================
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 :
// =======================================================================
void VInspector_ItemBVHTreeNode::initItem() const
{
if (IsInitialized())
return;
const_cast<VInspector_ItemBVHTreeNode*>(this)->Init();
}
// =======================================================================
// function : createChild
// purpose :
// =======================================================================
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;
}

View File

@@ -0,0 +1,96 @@
// Created on: 2019-04-29
// 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_ItemBVHTreeNode_H
#define VInspector_ItemBVHTreeNode_H
#include <Standard.hxx>
#include <inspector/VInspector_ItemBase.hxx>
//#include <TopoDS_Shape.hxx>
//#include <SelectMgr_SelectingVolumeManager.hxx>
class SelectMgr_BaseFrustum;
class VInspector_ItemBVHTreeNode;
typedef QExplicitlySharedDataPointer<VInspector_ItemBVHTreeNode> VInspector_ItemBVHTreeNodePtr;
//! \class VInspector_ItemBVHTreeNode
//! Parent item, that corresponds Folder under the AIS_InteractiveContext
//! Children of the item are: none
class VInspector_ItemBVHTreeNode : public VInspector_ItemBase
{
public:
//! Creates an item wrapped by a shared pointer
static VInspector_ItemBVHTreeNodePtr CreateItem (TreeModel_ItemBasePtr theParent, const int theRow, const int theColumn)
{ return VInspector_ItemBVHTreeNodePtr (new VInspector_ItemBVHTreeNode (theParent, theRow, theColumn)); }
//! Destructor
virtual ~VInspector_ItemBVHTreeNode() Standard_OVERRIDE {};
//! Inits the item, fills internal containers
Standard_EXPORT virtual void Init() Standard_OVERRIDE;
//! Resets cached values
Standard_EXPORT virtual void Reset() Standard_OVERRIDE;
//! Returns data object of the item.
//! \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;
//! Returns number of displayed presentations
//! \return rows count
Standard_EXPORT virtual int initRowCount() const Standard_OVERRIDE;
//! Returns item information for the given role. Fills internal container if it was not filled yet
//! \param theItemRole a value role
//! \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.
//! \param theRow the child row position
//! \param theColumn the child column position
//! \return the created item
virtual TreeModel_ItemBasePtr createChild (int theRow, int theColumn) Standard_OVERRIDE;
private:
//! Constructor
//! param theParent a parent item
//! \param theRow the item row positition in the parent item
//! \param theColumn the item column positition in the parent item
VInspector_ItemBVHTreeNode(TreeModel_ItemBasePtr theParent, const int theRow, const int theColumn)
: VInspector_ItemBase(theParent, theRow, theColumn) {}
};
#endif

View File

@@ -0,0 +1,96 @@
// Created on: 2017-06-16
// Created by: Natalia ERMOLAEVA
// Copyright (c) 2017 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_ItemContainer.hxx>
#include <inspector/VInspector_ItemContainerAPI.hxx>
// =======================================================================
// function : initValue
// purpose :
// =======================================================================
QVariant VInspector_ItemContainer::initValue (int theItemRole) const
{
QVariant aParentValue = VInspector_ItemBase::initValue (theItemRole);
if (aParentValue.isValid())
return aParentValue;
if (Column() != 0 || (theItemRole != Qt::DisplayRole && theItemRole != Qt::ToolTipRole))
return QVariant();
VInspector_ItemContainerAPI* aContainerItem = dynamic_cast<VInspector_ItemContainerAPI*>(Parent().data());
if (!aContainerItem)
return "Empty item container";
return aContainerItem->GetContainerValue (Row(), theItemRole);
}
// =======================================================================
// function : initRowCount
// purpose :
// =======================================================================
int VInspector_ItemContainer::initRowCount() const
{
VInspector_ItemContainerAPI* aContainerItem = dynamic_cast<VInspector_ItemContainerAPI*>(Parent().data());
if (!aContainerItem)
return 0;
return aContainerItem->GetContainerRowCount (Row());
}
// =======================================================================
// function : createChild
// purpose :
// =======================================================================
TreeModel_ItemBasePtr VInspector_ItemContainer::createChild (int theRow, int theColumn)
{
VInspector_ItemContainerAPI* aContainerItem = dynamic_cast<VInspector_ItemContainerAPI*>(Parent().data());
if (!aContainerItem)
return TreeModel_ItemBasePtr();
return aContainerItem->CreateContainerChild (currentItem(), Row(), theRow, theColumn);
}
// =======================================================================
// function : Init
// purpose :
// =======================================================================
void VInspector_ItemContainer::Init()
{
TreeModel_ItemBase::Init(); // to use getIO() without circling initialization
}
// =======================================================================
// function : Reset
// purpose :
// =======================================================================
void VInspector_ItemContainer::Reset()
{
VInspector_ItemBase::Reset();
}
// =======================================================================
// function : initItem
// purpose :
// =======================================================================
void VInspector_ItemContainer::initItem() const
{
if (IsInitialized())
return;
const_cast<VInspector_ItemContainer*> (this)->Init();
}

View File

@@ -0,0 +1,87 @@
// Created on: 2017-06-16
// Created by: Natalia ERMOLAEVA
// Copyright (c) 2017 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_ItemContainer_H
#define VInspector_ItemContainer_H
#include <Standard.hxx>
#include <inspector/VInspector_ItemBase.hxx>
#include <AIS_InteractiveObject.hxx>
#include <NCollection_List.hxx>
#include <TCollection_AsciiString.hxx>
class Prs3d_Drawer;
class QItemSelectionModel;
class VInspector_ItemContainer;
typedef QExplicitlySharedDataPointer<VInspector_ItemContainer> VInspector_ItemContainerPtr;
//! \class VInspector_ItemContainer
//! Item presents additional level of information in the tree model.
//! Parent is item context, children are either folder item or Selection filter item.
class VInspector_ItemContainer : public VInspector_ItemBase
{
public:
//! Creates an item wrapped by a shared pointer
static VInspector_ItemContainerPtr CreateItem (TreeModel_ItemBasePtr theParent,
const int theRow, const int theColumn)
{ return VInspector_ItemContainerPtr (new VInspector_ItemContainer (theParent, theRow, theColumn)); }
//! Destructor
virtual ~VInspector_ItemContainer() Standard_OVERRIDE {};
//! Returns data object of the item.
//! \return object
virtual Handle(Standard_Transient) GetObject() const { return NULL; }
//! Inits the item, fills internal containers
Standard_EXPORT virtual void Init() Standard_OVERRIDE;
//! Resets cached values
Standard_EXPORT virtual void Reset() Standard_OVERRIDE;
protected:
//! Initialize the current item. It is empty because Reset() is also empty.
virtual void initItem() const Standard_OVERRIDE;
//! Returns number of item selected
//! \return rows count
virtual int initRowCount() const Standard_OVERRIDE;
//! Returns item information for the given role. Fills internal container if it was not filled yet
//! \param theItemRole a value role
//! \return the value
virtual QVariant initValue (const int theItemRole) const Standard_OVERRIDE;
//! Creates a child item in the given position.
//! \param theRow the child row position
//! \param theColumn the child column position
//! \return the created item
virtual TreeModel_ItemBasePtr createChild (int theRow, int theColumn) Standard_OVERRIDE;
private:
//! Constructor
//! param theParent a parent item
VInspector_ItemContainer (TreeModel_ItemBasePtr theParent, const int theRow, const int theColumn)
: VInspector_ItemBase (theParent, theRow, theColumn) {}
};
#endif

View File

@@ -0,0 +1,50 @@
// Created on: 2017-06-16
// Created by: Natalia ERMOLAEVA
// Copyright (c) 2017 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_ItemContainerAPI_H
#define VInspector_ItemContainerAPI_H
#include <Standard.hxx>
#include <inspector/VInspector_ItemBase.hxx>
//! \class VInspector_ItemContainerAPI
class VInspector_ItemContainerAPI
{
public:
//! Constructor
VInspector_ItemContainerAPI () {}
//! Destructor
virtual ~VInspector_ItemContainerAPI() {};
//! Returns number of item selected
//! \return rows count
virtual int GetContainerRowCount (const int theContainerRow) const = 0;
//! Returns item information for the given role. Fills internal container if it was not filled yet
//! \param theItemRole a value role
//! \return the value
virtual QVariant GetContainerValue (const int theContainerRow, const int theItemRole) const = 0;
//! Creates a child item in the given position.
//! \param theRow the child row position
//! \param theColumn the child column position
//! \return the created item
virtual TreeModel_ItemBasePtr CreateContainerChild (const TreeModel_ItemBasePtr& theParent, const int theContainerRow, int theRow, int theColumn) = 0;
};
#endif

View File

@@ -0,0 +1,216 @@
// Created on: 2019-03-15
// 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_ItemOpenGlContext.hxx>
//#include <inspector/VInspector_ItemOpenGlContextList.hxx>
#include <inspector/VInspector_Tools.hxx>
#include <inspector/ViewControl_Tools.hxx>
#include <AIS.hxx>
#include <AIS_ListOfInteractive.hxx>
#include <Aspect.hxx>
#include <Graphic3d.hxx>
#include <OpenGl_Layer.hxx>
#include <OpenGl_Group.hxx>
#include <OpenGl_PrimitiveArray.hxx>
#include <OpenGl_Text.hxx>
#include <SelectMgr.hxx>
#include <SelectMgr_EntityOwner.hxx>
#include <Standard_WarningsDisable.hxx>
#include <QStringList>
#include <Standard_WarningsRestore.hxx>
// =======================================================================
// function : Init
// purpose :
// =======================================================================
void VInspector_ItemOpenGlContext::Init()
{
//VInspector_ItemOpenGlContextListPtr aParentItem = itemDynamicCast<VInspector_ItemOpenGlContextList>(Parent());
//myLayer = aParentItem->GetLayer (Row(), myLayerId);
TreeModel_ItemBase::Init();
}
// =======================================================================
// function : Reset
// purpose :
// =======================================================================
void VInspector_ItemOpenGlContext::Reset()
{
VInspector_ItemBase::Reset();
myLayer = NULL;
}
// =======================================================================
// function : initItem
// purpose :
// =======================================================================
void VInspector_ItemOpenGlContext::initItem() const
{
if (IsInitialized())
return;
const_cast<VInspector_ItemOpenGlContext*>(this)->Init();
}
// =======================================================================
// function : initRowCount
// purpose :
// =======================================================================
int VInspector_ItemOpenGlContext::initRowCount() const
{
if (Column() != 0)
return 0;
return 0;
}
// =======================================================================
// function : initValue
// purpose :
// =======================================================================
QVariant VInspector_ItemOpenGlContext::initValue (const int theItemRole) const
{
QVariant aParentValue = VInspector_ItemBase::initValue (theItemRole);
if (aParentValue.isValid())
return aParentValue;
if (theItemRole != Qt::DisplayRole && theItemRole != Qt::EditRole && theItemRole != Qt::ToolTipRole)
return QVariant();
Handle(OpenGl_Layer) aLayer = GetLayer();
if (aLayer.IsNull())
return Column() == 0 ? "Empty element" : "";
switch (Column())
{
case 0:
{
TCollection_AsciiString aLayerId = Graphic3d::ZLayerIdToString (myLayerId);
if (aLayerId.IsEmpty())
aLayerId = TCollection_AsciiString (myLayerId);
return theItemRole == Qt::ToolTipRole ? QVariant ("")
: QVariant (QString("%1 (%2)")
.arg(aLayer->DynamicType()->Name())
.arg (aLayerId.ToCString()));
}
default:
break;
}
return QVariant();
}
// =======================================================================
// function : GetTableRowCount
// purpose :
// =======================================================================
int VInspector_ItemOpenGlContext::GetTableRowCount() const
{
return 40;
}
// =======================================================================
// function : GetTableData
// purpose :
// =======================================================================
QVariant VInspector_ItemOpenGlContext::GetTableData (const int theRow, const int theColumn, const int theRole) const
{
if (theRole != Qt::DisplayRole)
return QVariant();
Handle(OpenGl_Layer) aLayer = GetLayer();
if (aLayer.IsNull())
return QVariant();
bool isFirstColumn = theColumn == 0;
switch (theRow)
{
case 0: return isFirstColumn ? QVariant ("NbStructures") : QVariant (aLayer->NbStructures());
case 1: return isFirstColumn ? QVariant ("NbStructuresNotCulled") : QVariant (aLayer->NbStructuresNotCulled());
case 2: return isFirstColumn ? QVariant ("NbPriorities") : QVariant (aLayer->NbPriorities());
case 3: return isFirstColumn ? QVariant ("ArrayOfStructures") : QVariant (aLayer->ArrayOfStructures().Size());
case 4: return isFirstColumn ? QVariant ("IsCulled") : QVariant (aLayer->IsCulled());
case 5: return isFirstColumn ? QVariant ("NbOfTransformPersistenceObjects") : QVariant (aLayer->NbOfTransformPersistenceObjects());
case 6: return isFirstColumn ? QVariant ("CullableStructuresBVH") : QVariant (aLayer->CullableStructuresBVH().Size());
case 7: return isFirstColumn ? QVariant ("CullableTrsfPersStructuresBVH") : QVariant (aLayer->CullableTrsfPersStructuresBVH().Size());
case 8: return isFirstColumn ? QVariant ("NonCullableStructures") : QVariant (aLayer->NonCullableStructures().Size());
default:
break;
}
Standard_Integer aRow = theRow - 9;
return getLayerSettingsTableData (aRow, theColumn, theRole, aLayer->LayerSettings());
}
// =======================================================================
// function : getLayerSettingsTableData
// purpose :
// =======================================================================
QVariant VInspector_ItemOpenGlContext::getLayerSettingsTableData (const int theRow, const int theColumn, const int theRole,
const Graphic3d_ZLayerSettings& theSettings) const
{
bool isFirstColumn = theColumn == 0;
switch (theRow)
{
case 0: return isFirstColumn ? QVariant ("LayerSettings:") : QVariant();
case 1: return isFirstColumn ? QVariant ("Name") : QVariant (theSettings.Name().ToCString());
case 2: return isFirstColumn ? QVariant ("Lights") : QVariant (ViewControl_Tools::GetPointerInfo (theSettings.Lights()).ToCString());
case 3: return isFirstColumn ? QVariant ("Origin") : QVariant (ViewControl_Tools::ToString (theSettings.Origin()).ToCString());
case 4: return isFirstColumn ? QVariant ("OriginTransformation")
: QVariant (ViewControl_Tools::ToString (theSettings.OriginTransformation()).ToCString());
case 5: return isFirstColumn ? QVariant ("HasCullingDistance") : QVariant (theSettings.HasCullingDistance());
case 6: return isFirstColumn ? QVariant ("CullingDistance")
: QVariant (theSettings.HasCullingDistance() ? theSettings.CullingDistance() : 0);
case 7: return isFirstColumn ? QVariant ("HasCullingSize") : QVariant (theSettings.HasCullingSize());
case 8: return isFirstColumn ? QVariant ("CullingSize")
: QVariant (theSettings.HasCullingSize() ? theSettings.CullingSize() : 0);
case 9: return isFirstColumn ? QVariant ("IsImmediate") : QVariant (theSettings.IsImmediate());
case 10: return isFirstColumn ? QVariant ("UseEnvironmentTexture") : QVariant (theSettings.UseEnvironmentTexture());
case 11: return isFirstColumn ? QVariant ("ToEnableDepthTest") : QVariant (theSettings.ToEnableDepthTest());
case 12: return isFirstColumn ? QVariant ("ToEnableDepthWrite") : QVariant (theSettings.ToEnableDepthWrite());
case 13: return isFirstColumn ? QVariant ("ToClearDepth") : QVariant (theSettings.ToClearDepth());
case 14: return isFirstColumn ? QVariant ("ToRenderInDepthPrepass") : QVariant (theSettings.ToRenderInDepthPrepass());
case 15: return isFirstColumn ? QVariant ("PolygonOffset: Mode")
: QVariant (Aspect::PolygonOffsetModeToString (theSettings.PolygonOffset().Mode));
case 16: return isFirstColumn ? QVariant ("PolygonOffset: Factor") : QVariant (theSettings.PolygonOffset().Factor);
case 17: return isFirstColumn ? QVariant ("PolygonOffset: Units") : QVariant (theSettings.PolygonOffset().Units);
default: break;
}
return QVariant();
}
// =======================================================================
// function : createChild
// purpose :
// =======================================================================
TreeModel_ItemBasePtr VInspector_ItemOpenGlContext::createChild (int theRow, int theColumn)
{
(void)theRow;
(void)theColumn;
return TreeModel_ItemBasePtr();
}

View File

@@ -0,0 +1,110 @@
// Created on: 2019-03-15
// 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_ItemOpenGlContext_H
#define VInspector_ItemOpenGlContext_H
#include <Standard.hxx>
#include <inspector/VInspector_ItemBase.hxx>
#include <Graphic3d_ZLayerSettings.hxx>
#include <OpenGl_Layer.hxx>
class Graphic3d_Group;
class VInspector_ItemOpenGlContext;
typedef QExplicitlySharedDataPointer<VInspector_ItemOpenGlContext> VInspector_ItemOpenGlContextPtr;
//! \class VInspector_ItemOpenGlContext
//! Parent item, that corresponds to AIS_InteractiveContext
//! Children of the item are:
//! - "Property" item to show context attributes such as selection filters and drawer properties
//! - presentation items to show all interactive elements displayed/erased in the context
class VInspector_ItemOpenGlContext : public VInspector_ItemBase
{
public:
//! Creates an item wrapped by a shared pointer
static VInspector_ItemOpenGlContextPtr CreateItem (TreeModel_ItemBasePtr theParent, const int theRow, const int theColumn)
{ return VInspector_ItemOpenGlContextPtr (new VInspector_ItemOpenGlContext (theParent, theRow, theColumn)); }
//! Destructor
virtual ~VInspector_ItemOpenGlContext() Standard_OVERRIDE {};
//! Returns data object of the item.
//! \return object
virtual Handle(Standard_Transient) GetObject() const { initItem(); return myLayer; }
//! Returns the current graphic3d group, init item if it was not initialized yet
//! \return graphic group
Standard_EXPORT Handle(OpenGl_Layer) GetLayer() const
{ return Handle(OpenGl_Layer)::DownCast (GetObject());}
//! Inits the item, fills internal containers
Standard_EXPORT virtual void Init() Standard_OVERRIDE;
//! Resets cached values
Standard_EXPORT virtual void Reset() 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;
protected:
//! Initialize the current item. It creates a backup of the specific item information
//! Do nothing as context has been already set into item
virtual void initItem() const Standard_OVERRIDE;
//! Returns number of displayed presentations
//! \return rows count
Standard_EXPORT virtual int initRowCount() const Standard_OVERRIDE;
//! Returns item information for the given role. Fills internal container if it was not filled yet
//! \param theItemRole a value role
//! \return the value
Standard_EXPORT virtual QVariant initValue (const int theItemRole) const Standard_OVERRIDE;
protected:
//! Returns table presentation of layer settings
QVariant getLayerSettingsTableData (const int theRow, const int theColumn, const int theRole,
const Graphic3d_ZLayerSettings& theSettings) const;
//! Creates a child item in the given position.
//! \param theRow the child row position
//! \param theColumn the child column position
//! \return the created item
virtual TreeModel_ItemBasePtr createChild (int theRow, int theColumn) Standard_OVERRIDE;
private:
//! Constructor
//! param theParent a parent item
//! \param theRow the item row positition in the parent item
//! \param theColumn the item column positition in the parent item
VInspector_ItemOpenGlContext(TreeModel_ItemBasePtr theParent, const int theRow, const int theColumn)
: VInspector_ItemBase(theParent, theRow, theColumn) {}
private:
Handle(OpenGl_Layer) myLayer; //! current layer
Graphic3d_ZLayerId myLayerId; //! current Z layer index in OpenGl_View
};
#endif

View File

@@ -0,0 +1,216 @@
// Created on: 2019-03-15
// 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_ItemOpenGlWindow.hxx>
//#include <inspector/VInspector_ItemOpenGlWindowList.hxx>
#include <inspector/VInspector_Tools.hxx>
#include <inspector/ViewControl_Tools.hxx>
#include <AIS.hxx>
#include <AIS_ListOfInteractive.hxx>
#include <Aspect.hxx>
#include <Graphic3d.hxx>
#include <OpenGl_Layer.hxx>
#include <OpenGl_Group.hxx>
#include <OpenGl_PrimitiveArray.hxx>
#include <OpenGl_Text.hxx>
#include <SelectMgr.hxx>
#include <SelectMgr_EntityOwner.hxx>
#include <Standard_WarningsDisable.hxx>
#include <QStringList>
#include <Standard_WarningsRestore.hxx>
// =======================================================================
// function : Init
// purpose :
// =======================================================================
void VInspector_ItemOpenGlWindow::Init()
{
//VInspector_ItemOpenGlWindowListPtr aParentItem = itemDynamicCast<VInspector_ItemOpenGlWindowList>(Parent());
//myLayer = aParentItem->GetLayer (Row(), myLayerId);
TreeModel_ItemBase::Init();
}
// =======================================================================
// function : Reset
// purpose :
// =======================================================================
void VInspector_ItemOpenGlWindow::Reset()
{
VInspector_ItemBase::Reset();
myLayer = NULL;
}
// =======================================================================
// function : initItem
// purpose :
// =======================================================================
void VInspector_ItemOpenGlWindow::initItem() const
{
if (IsInitialized())
return;
const_cast<VInspector_ItemOpenGlWindow*>(this)->Init();
}
// =======================================================================
// function : initRowCount
// purpose :
// =======================================================================
int VInspector_ItemOpenGlWindow::initRowCount() const
{
if (Column() != 0)
return 0;
return 0;
}
// =======================================================================
// function : initValue
// purpose :
// =======================================================================
QVariant VInspector_ItemOpenGlWindow::initValue (const int theItemRole) const
{
QVariant aParentValue = VInspector_ItemBase::initValue (theItemRole);
if (aParentValue.isValid())
return aParentValue;
if (theItemRole != Qt::DisplayRole && theItemRole != Qt::EditRole && theItemRole != Qt::ToolTipRole)
return QVariant();
Handle(OpenGl_Layer) aLayer = GetLayer();
if (aLayer.IsNull())
return Column() == 0 ? "Empty element" : "";
switch (Column())
{
case 0:
{
TCollection_AsciiString aLayerId = Graphic3d::ZLayerIdToString (myLayerId);
if (aLayerId.IsEmpty())
aLayerId = TCollection_AsciiString (myLayerId);
return theItemRole == Qt::ToolTipRole ? QVariant ("")
: QVariant (QString("%1 (%2)")
.arg(aLayer->DynamicType()->Name())
.arg (aLayerId.ToCString()));
}
default:
break;
}
return QVariant();
}
// =======================================================================
// function : GetTableRowCount
// purpose :
// =======================================================================
int VInspector_ItemOpenGlWindow::GetTableRowCount() const
{
return 40;
}
// =======================================================================
// function : GetTableData
// purpose :
// =======================================================================
QVariant VInspector_ItemOpenGlWindow::GetTableData (const int theRow, const int theColumn, const int theRole) const
{
if (theRole != Qt::DisplayRole)
return QVariant();
Handle(OpenGl_Layer) aLayer = GetLayer();
if (aLayer.IsNull())
return QVariant();
bool isFirstColumn = theColumn == 0;
switch (theRow)
{
case 0: return isFirstColumn ? QVariant ("NbStructures") : QVariant (aLayer->NbStructures());
case 1: return isFirstColumn ? QVariant ("NbStructuresNotCulled") : QVariant (aLayer->NbStructuresNotCulled());
case 2: return isFirstColumn ? QVariant ("NbPriorities") : QVariant (aLayer->NbPriorities());
case 3: return isFirstColumn ? QVariant ("ArrayOfStructures") : QVariant (aLayer->ArrayOfStructures().Size());
case 4: return isFirstColumn ? QVariant ("IsCulled") : QVariant (aLayer->IsCulled());
case 5: return isFirstColumn ? QVariant ("NbOfTransformPersistenceObjects") : QVariant (aLayer->NbOfTransformPersistenceObjects());
case 6: return isFirstColumn ? QVariant ("CullableStructuresBVH") : QVariant (aLayer->CullableStructuresBVH().Size());
case 7: return isFirstColumn ? QVariant ("CullableTrsfPersStructuresBVH") : QVariant (aLayer->CullableTrsfPersStructuresBVH().Size());
case 8: return isFirstColumn ? QVariant ("NonCullableStructures") : QVariant (aLayer->NonCullableStructures().Size());
default:
break;
}
Standard_Integer aRow = theRow - 9;
return getLayerSettingsTableData (aRow, theColumn, theRole, aLayer->LayerSettings());
}
// =======================================================================
// function : getLayerSettingsTableData
// purpose :
// =======================================================================
QVariant VInspector_ItemOpenGlWindow::getLayerSettingsTableData (const int theRow, const int theColumn, const int theRole,
const Graphic3d_ZLayerSettings& theSettings) const
{
bool isFirstColumn = theColumn == 0;
switch (theRow)
{
case 0: return isFirstColumn ? QVariant ("LayerSettings:") : QVariant();
case 1: return isFirstColumn ? QVariant ("Name") : QVariant (theSettings.Name().ToCString());
case 2: return isFirstColumn ? QVariant ("Lights") : QVariant (ViewControl_Tools::GetPointerInfo (theSettings.Lights()).ToCString());
case 3: return isFirstColumn ? QVariant ("Origin") : QVariant (ViewControl_Tools::ToString (theSettings.Origin()).ToCString());
case 4: return isFirstColumn ? QVariant ("OriginTransformation")
: QVariant (ViewControl_Tools::ToString (theSettings.OriginTransformation()).ToCString());
case 5: return isFirstColumn ? QVariant ("HasCullingDistance") : QVariant (theSettings.HasCullingDistance());
case 6: return isFirstColumn ? QVariant ("CullingDistance")
: QVariant (theSettings.HasCullingDistance() ? theSettings.CullingDistance() : 0);
case 7: return isFirstColumn ? QVariant ("HasCullingSize") : QVariant (theSettings.HasCullingSize());
case 8: return isFirstColumn ? QVariant ("CullingSize")
: QVariant (theSettings.HasCullingSize() ? theSettings.CullingSize() : 0);
case 9: return isFirstColumn ? QVariant ("IsImmediate") : QVariant (theSettings.IsImmediate());
case 10: return isFirstColumn ? QVariant ("UseEnvironmentTexture") : QVariant (theSettings.UseEnvironmentTexture());
case 11: return isFirstColumn ? QVariant ("ToEnableDepthTest") : QVariant (theSettings.ToEnableDepthTest());
case 12: return isFirstColumn ? QVariant ("ToEnableDepthWrite") : QVariant (theSettings.ToEnableDepthWrite());
case 13: return isFirstColumn ? QVariant ("ToClearDepth") : QVariant (theSettings.ToClearDepth());
case 14: return isFirstColumn ? QVariant ("ToRenderInDepthPrepass") : QVariant (theSettings.ToRenderInDepthPrepass());
case 15: return isFirstColumn ? QVariant ("PolygonOffset: Mode")
: QVariant (Aspect::PolygonOffsetModeToString (theSettings.PolygonOffset().Mode));
case 16: return isFirstColumn ? QVariant ("PolygonOffset: Factor") : QVariant (theSettings.PolygonOffset().Factor);
case 17: return isFirstColumn ? QVariant ("PolygonOffset: Units") : QVariant (theSettings.PolygonOffset().Units);
default: break;
}
return QVariant();
}
// =======================================================================
// function : createChild
// purpose :
// =======================================================================
TreeModel_ItemBasePtr VInspector_ItemOpenGlWindow::createChild (int theRow, int theColumn)
{
(void)theRow;
(void)theColumn;
return TreeModel_ItemBasePtr();
}

View File

@@ -0,0 +1,110 @@
// Created on: 2019-03-15
// 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_ItemOpenGlWindow_H
#define VInspector_ItemOpenGlWindow_H
#include <Standard.hxx>
#include <inspector/VInspector_ItemBase.hxx>
#include <Graphic3d_ZLayerSettings.hxx>
#include <OpenGl_Layer.hxx>
class Graphic3d_Group;
class VInspector_ItemOpenGlWindow;
typedef QExplicitlySharedDataPointer<VInspector_ItemOpenGlWindow> VInspector_ItemOpenGlWindowPtr;
//! \class VInspector_ItemOpenGlWindow
//! Parent item, that corresponds to AIS_InteractiveContext
//! Children of the item are:
//! - "Property" item to show context attributes such as selection filters and drawer properties
//! - presentation items to show all interactive elements displayed/erased in the context
class VInspector_ItemOpenGlWindow : public VInspector_ItemBase
{
public:
//! Creates an item wrapped by a shared pointer
static VInspector_ItemOpenGlWindowPtr CreateItem (TreeModel_ItemBasePtr theParent, const int theRow, const int theColumn)
{ return VInspector_ItemOpenGlWindowPtr (new VInspector_ItemOpenGlWindow (theParent, theRow, theColumn)); }
//! Destructor
virtual ~VInspector_ItemOpenGlWindow() Standard_OVERRIDE {};
//! Returns data object of the item.
//! \return object
virtual Handle(Standard_Transient) GetObject() const { initItem(); return myLayer; }
//! Returns the current graphic3d group, init item if it was not initialized yet
//! \return graphic group
Standard_EXPORT Handle(OpenGl_Layer) GetLayer() const
{ return Handle(OpenGl_Layer)::DownCast (GetObject());}
//! Inits the item, fills internal containers
Standard_EXPORT virtual void Init() Standard_OVERRIDE;
//! Resets cached values
Standard_EXPORT virtual void Reset() 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;
protected:
//! Initialize the current item. It creates a backup of the specific item information
//! Do nothing as context has been already set into item
virtual void initItem() const Standard_OVERRIDE;
//! Returns number of displayed presentations
//! \return rows count
Standard_EXPORT virtual int initRowCount() const Standard_OVERRIDE;
//! Returns item information for the given role. Fills internal container if it was not filled yet
//! \param theItemRole a value role
//! \return the value
Standard_EXPORT virtual QVariant initValue (const int theItemRole) const Standard_OVERRIDE;
protected:
//! Returns table presentation of layer settings
QVariant getLayerSettingsTableData (const int theRow, const int theColumn, const int theRole,
const Graphic3d_ZLayerSettings& theSettings) const;
//! Creates a child item in the given position.
//! \param theRow the child row position
//! \param theColumn the child column position
//! \return the created item
virtual TreeModel_ItemBasePtr createChild (int theRow, int theColumn) Standard_OVERRIDE;
private:
//! Constructor
//! param theParent a parent item
//! \param theRow the item row positition in the parent item
//! \param theColumn the item column positition in the parent item
VInspector_ItemOpenGlWindow(TreeModel_ItemBasePtr theParent, const int theRow, const int theColumn)
: VInspector_ItemBase(theParent, theRow, theColumn) {}
private:
Handle(OpenGl_Layer) myLayer; //! current layer
Graphic3d_ZLayerId myLayerId; //! current Z layer index in OpenGl_View
};
#endif

View 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();

View File

@@ -103,6 +103,21 @@ void VInspector_ItemSelectMgrBaseFrustum::initItem() const
const_cast<VInspector_ItemSelectMgrBaseFrustum*>(this)->Init();
}
// =======================================================================
// function : Dump
// purpose :
// =======================================================================
Standard_Boolean VInspector_ItemSelectMgrBaseFrustum::Dump (Standard_OStream& OS) const
{
Handle(SelectMgr_BaseFrustum) aFrustum = GetFrustum();
if (aFrustum.IsNull())
return Standard_False;
aFrustum->Dump (OS);
return Standard_True;
}
// =======================================================================
// function : GetTableRowCount
// purpose :

View File

@@ -53,6 +53,9 @@ public:
Standard_EXPORT Handle(SelectMgr_BaseFrustum) GetFrustum() const
{ return Handle(SelectMgr_BaseFrustum)::DownCast (GetObject()); }
//! 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;

View File

@@ -0,0 +1,188 @@
// Created on: 2019-04-29
// 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_ItemSelectMgrSelectableObjectSet.hxx>
#include <inspector/VInspector_ItemBVHTree.hxx>
#include <inspector/VInspector_ItemSelectMgrViewerSelector.hxx>
#include <inspector/VInspector_ItemSelectMgrBaseFrustum.hxx>
#include <inspector/ViewControl_Tools.hxx>
#include <SelectMgr.hxx>
// =======================================================================
// function : initRowCount
// purpose :
// =======================================================================
int VInspector_ItemSelectMgrSelectableObjectSet::initRowCount() const
{
if (Column() != 0)
return 0;
return SelectMgr_SelectableObjectSet::BVHSubsetNb; // VInspector_ItemBVHTree items
}
// =======================================================================
// function : initValue
// purpose :
// =======================================================================
QVariant VInspector_ItemSelectMgrSelectableObjectSet::initValue (const int theItemRole) const
{
QVariant aParentValue = VInspector_ItemBase::initValue (theItemRole);
if (aParentValue.isValid())
return aParentValue;
if (theItemRole != Qt::DisplayRole && theItemRole != Qt::EditRole && theItemRole != Qt::ToolTipRole)
return QVariant();
SelectMgr_SelectableObjectSet aSet;
if (!GetSelectableObjectSet (aSet))
return Column() == 0 ? "Empty selectable object set" : "";
switch (Column())
{
case 0: return "SelectMgr_SelectableObjectSet";
default:
break;
}
return QVariant();
}
// =======================================================================
// function : Init
// purpose :
// =======================================================================
void VInspector_ItemSelectMgrSelectableObjectSet::Init()
{
//VInspector_ItemFolderObjectPtr aParentItem = itemDynamicCast<VInspector_ItemFolderObject>(Parent());
//Handle(SelectMgr_SelectingVolumeManager) aVolumeMgr;
//if (aParentItem)
//{
// VInspector_ItemContextPtr aParentContextItem = itemDynamicCast<VInspector_ItemContext>(aParentItem->Parent());
// if (aParentContextItem)
// {
// Handle(AIS_InteractiveContext) aContext = aParentContextItem->GetContext();
// aVolumeMgr = aContext->MainSelector();
// }
//}
//setViewerSelector (aVolumeMgr);
//UpdatePresentationShape();
TreeModel_ItemBase::Init(); // to use getIO() without circling initialization
}
// =======================================================================
// function : Reset
// purpose :
// =======================================================================
void VInspector_ItemSelectMgrSelectableObjectSet::Reset()
{
VInspector_ItemBase::Reset();
}
// =======================================================================
// function : initItem
// purpose :
// =======================================================================
void VInspector_ItemSelectMgrSelectableObjectSet::initItem() const
{
if (IsInitialized())
return;
const_cast<VInspector_ItemSelectMgrSelectableObjectSet*>(this)->Init();
}
// =======================================================================
// function : GetSelectableObjectSet
// purpose :
// =======================================================================
Standard_Boolean VInspector_ItemSelectMgrSelectableObjectSet::GetSelectableObjectSet (SelectMgr_SelectableObjectSet& theSet) const
{
VInspector_ItemSelectMgrViewerSelectorPtr aParentItem = itemDynamicCast<VInspector_ItemSelectMgrViewerSelector>(Parent());
if (!aParentItem || aParentItem->GetViewerSelector().IsNull())
return Standard_False;
theSet = aParentItem->GetViewerSelector()->GetSelectableObjects();
return Standard_True;
}
// =======================================================================
// function : GetBVHTree
// purpose :
// =======================================================================
opencascade::handle<BVH_Tree<Standard_Real, 3> > VInspector_ItemSelectMgrSelectableObjectSet::GetBVHTree (const int theRow,
TCollection_AsciiString& theName) const
{
SelectMgr_SelectableObjectSet aSet;
if (!GetSelectableObjectSet (aSet))
return NULL;
if (theRow >= SelectMgr_SelectableObjectSet::BVHSubsetNb)
return NULL;
SelectMgr_SelectableObjectSet::BVHSubset aBVHSubset = (SelectMgr_SelectableObjectSet::BVHSubset)theRow;
theName = TCollection_AsciiString ("BVH_Tree_") + SelectMgr::BVHSubsetToString (aBVHSubset);
return aSet.BVH (aBVHSubset);
}
// =======================================================================
// function : GetTableRowCount
// purpose :
// =======================================================================
int VInspector_ItemSelectMgrSelectableObjectSet::GetTableRowCount() const
{
return 60;
}
// =======================================================================
// function : GetTableData
// purpose :
// =======================================================================
QVariant VInspector_ItemSelectMgrSelectableObjectSet::GetTableData (const int theRow, const int theColumn, const int theRole) const
{
if (theRole != Qt::DisplayRole)
return QVariant();
//SelectMgr_SelectingVolumeManager aVolumeMgr;
//if (!GetViewerSelector (aVolumeMgr))
// return QVariant();
//bool isFirstColumn = theColumn == 0;
//switch (theRow)
//{
// case 0: return isFirstColumn ? QVariant ("GetActiveSelectionType") : QVariant (aVolumeMgr.GetActiveSelectionType());
// case 1: return isFirstColumn ? QVariant ("IsOverlapAllowed()") : QVariant (aVolumeMgr.IsOverlapAllowed());
// case 2: return isFirstColumn ? "GetNearPickedPnt" : ViewControl_Tools::ToString (aVolumeMgr.GetNearPickedPnt()).ToCString();
// case 3: return isFirstColumn ? "GetFarPickedPnt" : ViewControl_Tools::ToString (aVolumeMgr.GetFarPickedPnt()).ToCString();
// default: break;
//}
return QVariant();
}
// =======================================================================
// function : createChild
// purpose :
// =======================================================================
TreeModel_ItemBasePtr VInspector_ItemSelectMgrSelectableObjectSet::createChild (int theRow, int theColumn)
{
if (theRow == 0 || theRow == 1 || theRow == 2)
return VInspector_ItemBVHTree::CreateItem (currentItem(), theRow, theColumn);
return TreeModel_ItemBasePtr();
}

View File

@@ -0,0 +1,102 @@
// Created on: 2019-04-29
// 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_ItemSelectMgrSelectableObjectSet_H
#define VInspector_ItemSelectMgrSelectableObjectSet_H
#include <inspector/VInspector_ItemBase.hxx>
#include <BVH_Tree.hxx>
#include <Standard.hxx>
#include <SelectMgr_SelectableObjectSet.hxx>
#include <TCollection_AsciiString.hxx>
class SelectMgr_BaseFrustum;
class VInspector_ItemSelectMgrSelectableObjectSet;
typedef QExplicitlySharedDataPointer<VInspector_ItemSelectMgrSelectableObjectSet> VInspector_ItemSelectMgrSelectableObjectSetPtr;
//! \class VInspector_ItemSelectMgrSelectableObjectSet
//! Parent item, that corresponds Folder under the AIS_InteractiveContext
//! Children of the item are: none
class VInspector_ItemSelectMgrSelectableObjectSet : public VInspector_ItemBase
{
public:
//! Creates an item wrapped by a shared pointer
static VInspector_ItemSelectMgrSelectableObjectSetPtr CreateItem (TreeModel_ItemBasePtr theParent, const int theRow, const int theColumn)
{ return VInspector_ItemSelectMgrSelectableObjectSetPtr (new VInspector_ItemSelectMgrSelectableObjectSet (theParent, theRow, theColumn)); }
//! Destructor
virtual ~VInspector_ItemSelectMgrSelectableObjectSet() Standard_OVERRIDE {};
//! Inits the item, fills internal containers
Standard_EXPORT virtual void Init() Standard_OVERRIDE;
//! Resets cached values
Standard_EXPORT virtual void Reset() Standard_OVERRIDE;
//! Returns data object of the item.
//! \return object
virtual Handle(Standard_Transient) GetObject() const { initItem(); return NULL; }
//! Returns current drawer, initialize the drawer if it was not initialized yet
Standard_EXPORT Standard_Boolean GetSelectableObjectSet (SelectMgr_SelectableObjectSet& theSet) const;
//! 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.
virtual void initItem() const Standard_OVERRIDE;
//! Returns number of displayed presentations
//! \return rows count
Standard_EXPORT virtual int initRowCount() const Standard_OVERRIDE;
//! Returns item information for the given role. Fills internal container if it was not filled yet
//! \param theItemRole a value role
//! \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;
protected:
//! Creates a child item in the given position.
//! \param theRow the child row position
//! \param theColumn the child column position
//! \return the created item
virtual TreeModel_ItemBasePtr createChild (int theRow, int theColumn) Standard_OVERRIDE;
private:
//! Constructor
//! param theParent a parent item
//! \param theRow the item row positition in the parent item
//! \param theColumn the item column positition in the parent item
VInspector_ItemSelectMgrSelectableObjectSet(TreeModel_ItemBasePtr theParent, const int theRow, const int theColumn)
: VInspector_ItemBase(theParent, theRow, theColumn) {}
};
#endif

View File

@@ -29,7 +29,7 @@ int VInspector_ItemSelectMgrSelectingVolumeManager::initRowCount() const
if (Column() != 0)
return 0;
return 1;
return 2;
}
// =======================================================================
@@ -119,6 +119,24 @@ Standard_Boolean VInspector_ItemSelectMgrSelectingVolumeManager::GetViewerSelect
return Standard_True;
}
// =======================================================================
// function : GetTableRowCount
// purpose :
// =======================================================================
Handle(SelectMgr_BaseFrustum) VInspector_ItemSelectMgrSelectingVolumeManager::GetFrustum (const int theRow) const
{
SelectMgr_SelectingVolumeManager aVolumeManager;
if (!GetViewerSelector (aVolumeManager))
return NULL;
if (theRow == 0)
return aVolumeManager.GetVolume (SelectBasics_SelectingVolumeManager::Box);
else if (theRow == 1)
return aVolumeManager.GetVolume (SelectBasics_SelectingVolumeManager::Polyline);
return NULL;
}
// =======================================================================
// function : GetTableRowCount
// purpose :
@@ -159,7 +177,7 @@ QVariant VInspector_ItemSelectMgrSelectingVolumeManager::GetTableData (const int
// =======================================================================
TreeModel_ItemBasePtr VInspector_ItemSelectMgrSelectingVolumeManager::createChild (int theRow, int theColumn)
{
if (theRow == 0)
if (theRow == 0 || theRow == 1)
return VInspector_ItemSelectMgrBaseFrustum::CreateItem (currentItem(), theRow, theColumn);
//else if (theRow == 1)
// return VInspector_ItemAspectWindow::CreateItem (currentItem(), theRow, theColumn);

View File

@@ -22,6 +22,8 @@
#include <TopoDS_Shape.hxx>
#include <SelectMgr_SelectingVolumeManager.hxx>
class SelectMgr_BaseFrustum;
class VInspector_ItemSelectMgrSelectingVolumeManager;
typedef QExplicitlySharedDataPointer<VInspector_ItemSelectMgrSelectingVolumeManager> VInspector_ItemSelectMgrSelectingVolumeManagerPtr;
@@ -52,6 +54,9 @@ public:
//! Returns current drawer, initialize the drawer if it was not initialized yet
Standard_EXPORT Standard_Boolean GetViewerSelector (SelectMgr_SelectingVolumeManager& theVolumeManager) const;
//! Returns frustum Frustum for row = 0, FrustumSet for row = 1
Handle(SelectMgr_BaseFrustum) GetFrustum (const int theRow) const;
protected:
//! Initialize the current item. It is empty because Reset() is also empty.
virtual void initItem() const Standard_OVERRIDE;

View File

@@ -0,0 +1,157 @@
// Created on: 2017-06-16
// Created by: Natalia ERMOLAEVA
// Copyright (c) 2017 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_ItemSelectMgrSensitiveEntitySet.hxx>
#include <inspector/VInspector_ItemSelectMgrViewerSelector.hxx>
#include <inspector/VInspector_ItemBVHTree.hxx>
#include <inspector/ViewControl_Tools.hxx>
#include <AIS_ListOfInteractive.hxx>
#include <SelectMgr_SensitiveEntitySet.hxx>
// =======================================================================
// function : initValue
// purpose :
// =======================================================================
int VInspector_ItemSelectMgrSensitiveEntitySet::initRowCount() const
{
//Handle(SelectMgr_SensitiveEntitySet) aSensitiveSet = Handle(SelectMgr_SensitiveEntitySet)::DownCast (GetSensitiveEntitySet());
//if (!aSensitiveSet.IsNull())
// return aSensitiveSet->Size();
return 1; // for BVH_Tree
}
// =======================================================================
// function : initValue
// purpose :
// =======================================================================
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;
if (theItemRole != Qt::DisplayRole && theItemRole != Qt::EditRole && theItemRole != Qt::ToolTipRole)
return QVariant();
Handle(SelectMgr_SensitiveEntitySet) anEntitySet = GetSensitiveEntitySet();
const Handle(SelectMgr_SelectableObject)& aSelectableObject = GetSelectableObject();
if (anEntitySet.IsNull())
return Column() == 0 ? "Empty sensitive entity set" : "";
if (aSelectableObject.IsNull())
return Column() == 0 ? "Empty selectable object for sensitive entity set" : "";
switch (theItemRole)
{
case Qt::DisplayRole:
case Qt::EditRole:
case Qt::ToolTipRole:
{
switch (Column())
{
case 0: return aSelectableObject->DynamicType()->Name();
default:
break;
}
break;
}
default:
break;
}
return QVariant();
}
// =======================================================================
// function : createChild
// purpose :
// =======================================================================
TreeModel_ItemBasePtr VInspector_ItemSelectMgrSensitiveEntitySet::createChild (int theRow, int theColumn)
{
return VInspector_ItemBVHTree::CreateItem (currentItem(), theRow, theColumn);
}
// =======================================================================
// function : Init
// purpose :
// =======================================================================
void VInspector_ItemSelectMgrSensitiveEntitySet::Init()
{
VInspector_ItemSelectMgrViewerSelectorPtr aParentItem = itemDynamicCast<VInspector_ItemSelectMgrViewerSelector>(Parent()->Parent());
Handle(SelectMgr_SelectableObject) anObject;
Handle(SelectMgr_SensitiveEntitySet) anEntitySet = aParentItem->GetSensitiveEntitySet (Row(), anObject);
myEntitySet = anEntitySet;
mySelectableObject = anObject;
UpdatePresentationShape();
TreeModel_ItemBase::Init();
}
// =======================================================================
// function : Reset
// purpose :
// =======================================================================
void VInspector_ItemSelectMgrSensitiveEntitySet::Reset()
{
// an empty method to don't clear the main label, otherwise the model will be empty
TreeModel_ItemBase::Reset();
myEntitySet = NULL;
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 :
// =======================================================================
void VInspector_ItemSelectMgrSensitiveEntitySet::initItem() const
{
if (IsInitialized())
return;
const_cast<VInspector_ItemSelectMgrSensitiveEntitySet*>(this)->Init();
}
// =======================================================================
// function : buildPresentationShape
// purpose :
// =======================================================================
TopoDS_Shape VInspector_ItemSelectMgrSensitiveEntitySet::buildPresentationShape()
{
//mySelectableObject
return TopoDS_Shape();
}

View File

@@ -0,0 +1,112 @@
// Created on: 2017-06-16
// Created by: Natalia ERMOLAEVA
// Copyright (c) 2017 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_ItemSelectMgrSensitiveEntitySet_H
#define VInspector_ItemSelectMgrSensitiveEntitySet_H
#include <AIS_InteractiveObject.hxx>
#include <BVH_Tree.hxx>
#include <SelectMgr_SensitiveEntitySet.hxx>
#include <Standard.hxx>
#include <inspector/VInspector_ItemBase.hxx>
class SelectMgr_SelectableObject;
class QItemSelectionModel;
class VInspector_ItemSelectMgrSensitiveEntitySet;
typedef QExplicitlySharedDataPointer<VInspector_ItemSelectMgrSensitiveEntitySet> VInspector_ItemSelectMgrSensitiveEntitySetPtr;
//! \class VInspector_ItemSelectMgrSensitiveEntitySet
class VInspector_ItemSelectMgrSensitiveEntitySet : public VInspector_ItemBase
{
public:
//! Creates an item wrapped by a shared pointer
static VInspector_ItemSelectMgrSensitiveEntitySetPtr CreateItem (TreeModel_ItemBasePtr theParent, const int theRow, const int theColumn)
{ return VInspector_ItemSelectMgrSensitiveEntitySetPtr (new VInspector_ItemSelectMgrSensitiveEntitySet (theParent, theRow, theColumn)); }
//! Destructor
virtual ~VInspector_ItemSelectMgrSensitiveEntitySet() Standard_OVERRIDE {};
//! Returns data object of the item.
//! \return object
virtual Handle(Standard_Transient) GetObject() const { initItem(); return myEntitySet; }
//! \return the current sensitive entity
Standard_EXPORT Handle(SelectMgr_SensitiveEntitySet) GetSensitiveEntitySet() const
{ return Handle(SelectMgr_SensitiveEntitySet)::DownCast (GetObject()); }
//! \return the current sensitive entity
Standard_EXPORT const Handle(SelectMgr_SelectableObject)& GetSelectableObject() const
{ GetObject(); return mySelectableObject; }
//! Inits the item, fills internal containers
Standard_EXPORT virtual void Init() Standard_OVERRIDE;
//! 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.
virtual void initItem() const Standard_OVERRIDE;
//! \return number of children.
virtual int initRowCount() const Standard_OVERRIDE;
//! Returns item information for the given role. Fills internal container if it was not filled yet
//! \param theItemRole a value role
//! \return the value
virtual QVariant initValue (const int theItemRole) const Standard_OVERRIDE;
protected:
//! Creates a child item in the given position.
//! \param theRow the child row position
//! \param theColumn the child column position
//! \return the created item
virtual TreeModel_ItemBasePtr createChild (int theRow, int theColumn) Standard_OVERRIDE;
//! Returns table value for the row in form: <function name> <function value> depending on the aspect kind
//! \param theRow a model index row
//! \param theColumn a model index column
//! \param theEntityKind kind or kind of entity
QVariant getTableData (const int theRow,
const int theColumn,
const int theRole,
const TCollection_AsciiString& theEntityKind) const;
protected:
//! Build presentation shape
//! \return generated shape of the item parameters
virtual TopoDS_Shape buildPresentationShape() Standard_OVERRIDE;
//! Constructor
//! param theParent a parent item
VInspector_ItemSelectMgrSensitiveEntitySet(TreeModel_ItemBasePtr theParent, const int theRow, const int theColumn)
: VInspector_ItemBase(theParent, theRow, theColumn) {}
private:
Handle(SelectMgr_SensitiveEntitySet) myEntitySet; //!< the current sensitive entity
Handle(SelectMgr_SelectableObject) mySelectableObject; //!< the current presentation
};
#endif

View File

@@ -15,7 +15,10 @@
#include <inspector/VInspector_ItemSelectMgrViewerSelector.hxx>
#include <inspector/VInspector_ItemContainer.hxx>
#include <inspector/VInspector_ItemSelectMgrSelectableObjectSet.hxx>
#include <inspector/VInspector_ItemSelectMgrSelectingVolumeManager.hxx>
#include <inspector/VInspector_ItemSelectMgrSensitiveEntitySet.hxx>
#include <inspector/VInspector_ItemSelectMgrViewerSelectorPicked.hxx>
#include <inspector/VInspector_ItemFolderObject.hxx>
@@ -50,7 +53,8 @@ int VInspector_ItemSelectMgrViewerSelector::initRowCount() const
if (Column() != 0)
return 0;
Standard_Integer aNbRows = GetFirstChildOfPicked(); // SelectMgr_SelectingVolumeManager
// SelectMgr_SelectingVolumeManager, VInspector_ItemSelectMgrSelectableObjectSet, VInspector_ItemContainer
Standard_Integer aNbRows = GetFirstChildOfPicked();
Handle(SelectMgr_ViewerSelector) aViewSelector = GetViewerSelector();
if (!aViewSelector.IsNull())
@@ -125,6 +129,80 @@ void VInspector_ItemSelectMgrViewerSelector::Reset()
setViewerSelector (NULL);
}
// =======================================================================
// function : GetSensitiveEntitySet
// purpose :
// =======================================================================
Handle(SelectMgr_SensitiveEntitySet) VInspector_ItemSelectMgrViewerSelector::GetSensitiveEntitySet (const int theRow,
Handle(SelectMgr_SelectableObject)& theObject)
{
Standard_Integer anIndex = 0;
Handle(SelectMgr_ViewerSelector) aViewSelector = GetViewerSelector();
if (aViewSelector.IsNull())
return NULL;
for (SelectMgr_MapOfObjectSensitivesIterator anIterator (aViewSelector->GetObjectSensitives()); anIterator.More(); anIterator.Next(), anIndex++)
{
if (anIndex != theRow)
continue;
theObject = anIterator.Key();
return anIterator.Value();
}
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 :
// =======================================================================
QVariant VInspector_ItemSelectMgrViewerSelector::GetContainerValue (const int theContainerRow, const int theItemRole) const
{
if (theContainerRow != 2)
return 0;
if (theItemRole != Qt::DisplayRole)
return QVariant();
Handle(SelectMgr_ViewerSelector) aViewSelector = GetViewerSelector();
if (aViewSelector.IsNull())
return QVariant();
return "SelectMgr_MapOfObjectSensitives";
}
// =======================================================================
// function : CreateContainerChild
// purpose :
// =======================================================================
TreeModel_ItemBasePtr VInspector_ItemSelectMgrViewerSelector::CreateContainerChild (const TreeModel_ItemBasePtr& theParent, const int theContainerRow, int theRow, int theColumn)
{
if (theContainerRow != 2)
return TreeModel_ItemBasePtr();
return VInspector_ItemSelectMgrSensitiveEntitySet::CreateItem (theParent, theRow, theColumn);
}
// =======================================================================
// function : initItem
// purpose :
@@ -245,6 +323,20 @@ bool VInspector_ItemSelectMgrViewerSelector::SetTableData (const int theRow, con
return Standard_True;
}
// =======================================================================
// function : Dump
// purpose :
// =======================================================================
Standard_Boolean VInspector_ItemSelectMgrViewerSelector::Dump (Standard_OStream& OS) const
{
Handle(SelectMgr_ViewerSelector) aViewerSelector = GetViewerSelector();
if (aViewerSelector.IsNull())
return Standard_False;
aViewerSelector->Dump (OS);
return Standard_True;
}
// =======================================================================
// function : buildPresentationShape
// purpose :
@@ -272,12 +364,10 @@ TreeModel_ItemBasePtr VInspector_ItemSelectMgrViewerSelector::createChild (int t
{
if (theRow == 0)
return VInspector_ItemSelectMgrSelectingVolumeManager::CreateItem (currentItem(), theRow, theColumn);
else if (theRow == 1)
return VInspector_ItemSelectMgrSelectableObjectSet::CreateItem (currentItem(), theRow, theColumn);
else if (theRow == 2)
return VInspector_ItemContainer::CreateItem (currentItem(), theRow, theColumn);
else
return VInspector_ItemSelectMgrViewerSelectorPicked::CreateItem (currentItem(), theRow, theColumn);
//else if (theRow == 1)
// return VInspector_ItemAspectWindow::CreateItem (currentItem(), theRow, theColumn);
//else if (theRow == 2)
// return VInspector_ItemGraphic3dCView::CreateItem (currentItem(), theRow, theColumn);
//
return TreeModel_ItemBasePtr();
}

View File

@@ -18,9 +18,11 @@
#include <Standard.hxx>
#include <inspector/VInspector_ItemBase.hxx>
#include <inspector/VInspector_ItemContainerAPI.hxx>
#include <TopoDS_Shape.hxx>
#include <SelectMgr_ViewerSelector.hxx>
#include <Standard_OStream.hxx>
class VInspector_ItemSelectMgrViewerSelector;
typedef QExplicitlySharedDataPointer<VInspector_ItemSelectMgrViewerSelector> VInspector_ItemSelectMgrViewerSelectorPtr;
@@ -28,7 +30,7 @@ typedef QExplicitlySharedDataPointer<VInspector_ItemSelectMgrViewerSelector> VIn
//! \class VInspector_ItemSelectMgrViewerSelector
//! Parent item, that corresponds Folder under the AIS_InteractiveContext
//! Children of the item are: none
class VInspector_ItemSelectMgrViewerSelector : public VInspector_ItemBase
class VInspector_ItemSelectMgrViewerSelector : public VInspector_ItemBase, public VInspector_ItemContainerAPI
{
public:
@@ -55,7 +57,31 @@ public:
//! 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; }
//! the 1 item is VInspector_ItemSelectMgrSelectableObjectSet
//! the 2 item is VInspector_ItemContainer for SelectMgr_MapOfObjectSensitives
Standard_Integer GetFirstChildOfPicked() const { return 3; }
//! Returns entity set if possible from SelectMgr_MapOfObjectSensitives
//! \param theRow row index
//! \param theObject [out] object connected to the sensitive entity set
Standard_EXPORT Handle(SelectMgr_SensitiveEntitySet) GetSensitiveEntitySet (const int theRow,
Handle(SelectMgr_SelectableObject)& theObject);
//! Returns number of item selected
//! \return rows count
virtual int GetContainerRowCount (const int theContainerRow) const Standard_OVERRIDE;
//! Returns item information for the given role. Fills internal container if it was not filled yet
//! \param theItemRole a value role
//! \return the value
virtual QVariant GetContainerValue (const int theContainerRow, const int theItemRole) const Standard_OVERRIDE;
//! Creates a child item in the given position.
//! \param theRow the child row position
//! \param theColumn the child column position
//! \return the created item
virtual TreeModel_ItemBasePtr CreateContainerChild (const TreeModel_ItemBasePtr& theParent, const int theContainerRow, int theRow, int theColumn) Standard_OVERRIDE;
protected:
//! Initialize the current item. It is empty because Reset() is also empty.
virtual void initItem() const Standard_OVERRIDE;
@@ -90,6 +116,9 @@ protected:
//! \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;
protected:
//! Build presentation shape

View File

@@ -24,6 +24,7 @@
#include <V3d_ListOfLight.hxx>
#include <inspector/ViewControl_Tools.hxx>
#include <inspector/ViewControl_TableDoubleVector.hxx>
#include <inspector/VInspector_ItemAspectWindow.hxx>
#include <inspector/VInspector_ItemContext.hxx>
#include <inspector/VInspector_ItemGraphic3dCamera.hxx>
@@ -130,8 +131,13 @@ int VInspector_ItemV3dView::GetTableRowCount() const
// function : GetTableEditType
// purpose :
// =======================================================================
ViewControl_EditType VInspector_ItemV3dView::GetTableEditType (const int, const int) const
ViewControl_EditType VInspector_ItemV3dView::GetTableEditType (const int theRow, const int) const
{
switch (theRow)
{
case 2: return ViewControl_EditType_DoubleVector;
}
return ViewControl_EditType_None;
}
@@ -217,8 +223,36 @@ QVariant VInspector_ItemV3dView::GetTableData (const int theRow, const int theCo
// function : SetTableData
// purpose :
// =======================================================================
bool VInspector_ItemV3dView::SetTableData (const int, const int, const QVariant&)
bool VInspector_ItemV3dView::SetTableData (const int theRow, const int theColumn, const QVariant& theValue)
{
Handle(V3d_View) aView = GetView();
if (aView.IsNull())
return false;
if (theColumn == 0)
return false;
switch (theRow)
{
case 2:
{
QString aValue = theValue.toString();
Standard_Real aX, anY, aZ, aVx, aVy, aVz;
QList<QVariant> aValues = ViewControl_TableDoubleVector::GetListVector(aValue);
if (aValues.size() == 3)
{
aX = aValues[0].toFloat();
anY = aValues[1].toFloat();
aZ = aValues[2].toFloat();
Standard_Real aTmpX, aTmpY, aTmpZ;
aView->Axis(aTmpX, aTmpY, aTmpZ, aVx, aVy, aVz);
aView->SetAxis(aX, anY, aZ, aVx, aVy, aVz);
}
}
}
return true;
}

View File

@@ -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;
}

View File

@@ -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

View File

@@ -0,0 +1,36 @@
// Created on: 2019-04-28
// 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_PropertiesCreator.hxx>
#include <inspector/VInspectorPaneAIS_ColoredShape.hxx>
#include <inspector/ViewControl_PropertiesStream.hxx>
#include <Standard_OStream.hxx>
IMPLEMENT_STANDARD_RTTIEXT(VInspector_PropertiesCreator, TreeModel_ItemPropertiesCreator)
// =======================================================================
// function : GetProperties
// purpose :
// =======================================================================
TreeModel_ItemProperties* VInspector_PropertiesCreator::GetProperties (const TreeModel_ItemBasePtr& theItem)
{
Standard_SStream aSStream;
if (theItem->Dump (aSStream))
return new ViewControl_PropertiesStream (theItem);
return NULL;
}

View File

@@ -0,0 +1,47 @@
// Created on: 2019-04-28
// 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_PropertiesCreator_H
#define VInspector_PropertiesCreator_H
#include <Standard.hxx>
#include <Standard_Macro.hxx>
#include <inspector/TreeModel_ItemPropertiesCreator.hxx>
DEFINE_STANDARD_HANDLE (VInspector_PropertiesCreator, TreeModel_ItemPropertiesCreator)
//! \class VInspector_PropertiesCreator
//! \brief An interface to create custom panes by transient object name.
class VInspector_PropertiesCreator : public TreeModel_ItemPropertiesCreator
{
public:
//! Constructor
VInspector_PropertiesCreator() {}
//! Destructor
virtual ~VInspector_PropertiesCreator() {}
//! Returns pane for the name, creates a new pane if it does not exist and possible to create
//! \param theName type of the pane
//! \return a pane instance or NULL
virtual TreeModel_ItemProperties* GetProperties (const TreeModel_ItemBasePtr& theItem) Standard_OVERRIDE;
DEFINE_STANDARD_RTTIEXT(VInspector_PropertiesCreator, TreeModel_ItemPropertiesCreator)
};
#endif

View File

@@ -600,6 +600,30 @@ TopoDS_Shape VInspector_Tools::CreateShape (const Bnd_Box& theBoundingBox)
return CreateBoxShape (aPntMin, aPntMax);
}
//=======================================================================
//function : CreateShape
//purpose :
//=======================================================================
TopoDS_Shape VInspector_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 : CreateShape
//purpose :

View File

@@ -18,6 +18,7 @@
#include <AIS_InteractiveContext.hxx>
#include <Bnd_Box.hxx>
#include <Bnd_OBB.hxx>
#include <Graphic3d_Buffer.hxx>
#include <Graphic3d_Mat4.hxx>
#include <Graphic3d_Mat4d.hxx>
@@ -191,7 +192,7 @@ public:
//! Creates box shape
//! \param theBoundingBox box shape parameters
//! \return created shape
Standard_EXPORT static TopoDS_Shape CreateShape (const Select3D_BndBox3d& theBoundingBox);
Standard_EXPORT static TopoDS_Shape CreateShape (const Bnd_OBB& theBoundingBox);
//! Creates box shape
//! \param thePntMin minimum point on the bounding box
@@ -199,6 +200,11 @@ public:
//! \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

View File

@@ -19,8 +19,10 @@
#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,8 @@
#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>
#include <inspector/VInspector_ToolBar.hxx>
@@ -106,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);
@@ -127,6 +133,7 @@ VInspector_Window::VInspector_Window()
//((ViewControl_TreeView*)myTreeView)->SetPredefinedSize (QSize (VINSPECTOR_DEFAULT_TREE_VIEW_WIDTH,
// VINSPECTOR_DEFAULT_TREE_VIEW_HEIGHT));
VInspector_ViewModel* aTreeModel = new VInspector_ViewModel (myTreeView);
aTreeModel-> AddPropertiesCreator(new VInspector_PropertiesCreator());
myTreeView->setModel (aTreeModel);
// hide Visibility column
TreeModel_HeaderSection anItem = aTreeModel->GetHeaderItem ((int)TreeModel_ColumnType_Visibility);
@@ -247,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());
}
}
// =======================================================================
@@ -274,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;
}
}
@@ -380,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();
@@ -535,8 +552,13 @@ Handle(Graphic3d_TransformPers) VInspector_Window::GetSelectedTransformPers()
// =======================================================================
bool VInspector_Window::Init (const NCollection_List<Handle(Standard_Transient)>& theParameters)
{
VInspector_ViewModel* aViewModel = dynamic_cast<VInspector_ViewModel*> (myTreeView->model());
if (!aViewModel)
return Standard_False;
Handle(AIS_InteractiveContext) aContext;
Handle(VInspector_CallBack) aCallBack;
Standard_Boolean isModelUpdated = Standard_False;
for (NCollection_List<Handle(Standard_Transient)>::Iterator aParamsIt (theParameters); aParamsIt.More(); aParamsIt.Next())
{
@@ -552,21 +574,20 @@ bool VInspector_Window::Init (const NCollection_List<Handle(Standard_Transient)>
Handle(ViewControl_PaneCreator) aPaneCreator = Handle(ViewControl_PaneCreator)::DownCast (anObject);
if (!myPaneCreators.Contains (aPaneCreator))
myPaneCreators.Append (aPaneCreator);
isModelUpdated = Standard_True;
}
if (!Handle(TreeModel_ItemPropertiesCreator)::DownCast (anObject).IsNull())
{
Handle(TreeModel_ItemPropertiesCreator) aPropCreator = Handle(TreeModel_ItemPropertiesCreator)::DownCast (anObject);
VInspector_ViewModel* aViewModel = dynamic_cast<VInspector_ViewModel*>(myTreeView->model());
aViewModel->AddPropertiesCreator (aPropCreator);
Handle(TreeModel_ItemPropertiesCreator) aPropCreator = Handle(TreeModel_ItemPropertiesCreator)::DownCast (anObject);
VInspector_ViewModel* aViewModel = dynamic_cast<VInspector_ViewModel*>(myTreeView->model());
aViewModel->AddPropertiesCreator (aPropCreator);
isModelUpdated = Standard_True;
}
}
if (aContext.IsNull())
return false;
VInspector_ViewModel* aViewModel = dynamic_cast<VInspector_ViewModel*> (myTreeView->model());
if (aViewModel && aViewModel->GetContext() == aContext)
UpdateTreeModel();
if (aViewModel->GetContext() != aContext)
SetContext(aContext);
else
SetContext (aContext);
isModelUpdated = Standard_True;
if (!aCallBack.IsNull() && aCallBack != myCallBack)
{
@@ -576,6 +597,10 @@ bool VInspector_Window::Init (const NCollection_List<Handle(Standard_Transient)>
myCallBack->SetContext(aContext);
myCallBack->SetHistoryModel(aHistoryModel);
}
if (isModelUpdated)
UpdateTreeModel();
return true;
}
@@ -585,12 +610,22 @@ bool VInspector_Window::Init (const NCollection_List<Handle(Standard_Transient)>
// =======================================================================
void VInspector_Window::SetContext (const Handle(AIS_InteractiveContext)& theContext)
{
if (theContext.IsNull())
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();
}
// =======================================================================
@@ -647,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++)
@@ -811,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 :
@@ -819,8 +891,6 @@ void VInspector_Window::onExportToShapeView()
{
const QModelIndexList anIndices;
NCollection_List<TopoDS_Shape> aSelectedShapes = GetSelectedShapes (myTreeView->selectionModel()->selectedIndexes());
if (aSelectedShapes.Extent() <= 0)
return;
TCollection_AsciiString aPluginName ("TKShapeView");
NCollection_List<Handle(Standard_Transient)> aParameters;
@@ -832,20 +902,42 @@ void VInspector_Window::onExportToShapeView()
anItemNames = myParameters->GetSelectedNames (aPluginName);
QStringList anExportedPointers;
for (NCollection_List<TopoDS_Shape>::Iterator anIOIt (aSelectedShapes); anIOIt.More(); anIOIt.Next())
if (aSelectedShapes.Extent() > 0)
{
const TopoDS_Shape& aShape = anIOIt.Value();
if (aShape.IsNull())
continue;
aParameters.Append (aShape.TShape());
anItemNames.Append (TInspectorAPI_PluginParameters::ParametersToString(aShape));
anExportedPointers.append (VInspector_Tools::GetPointerInfo (aShape.TShape(), true).ToCString());
for (NCollection_List<TopoDS_Shape>::Iterator anIOIt (aSelectedShapes); anIOIt.More(); anIOIt.Next())
{
const TopoDS_Shape& aShape = anIOIt.Value();
if (aShape.IsNull())
continue;
aParameters.Append (aShape.TShape());
anItemNames.Append (TInspectorAPI_PluginParameters::ParametersToString(aShape));
anExportedPointers.append (VInspector_Tools::GetPointerInfo (aShape.TShape(), true).ToCString());
}
}
if (anExportedPointers.empty())
// seach for objects to be exported
QList<TreeModel_ItemBasePtr> anItems = TreeModel_ModelBase::GetSelectedItems (myTreeView->selectionModel()->selectedIndexes());
for (QList<TreeModel_ItemBasePtr>::const_iterator anItemIt = anItems.begin(); anItemIt != anItems.end(); anItemIt++)
{
TreeModel_ItemBasePtr anItem = *anItemIt;
VInspector_ItemBasePtr aVItem = itemDynamicCast<VInspector_ItemBase>(anItem);
if (!aVItem)
continue;
Handle(Standard_Transient) anObject = aVItem->GetObject();
if (anObject.IsNull())
continue;
aParameters.Append (anObject);
anItemNames.Append (anObject->DynamicType()->Name());
anExportedPointers.append (VInspector_Tools::GetPointerInfo (anObject, true).ToCString());
}
if (anExportedPointers.isEmpty())
return;
TCollection_AsciiString aPluginShortName = aPluginName.SubString (3, aPluginName.Length());
QString aMessage = QString ("TShape %1 is sent to %2.")
QString aMessage = QString ("Objects %1 are sent to %2.")
.arg (anExportedPointers.join(", "))
.arg (aPluginShortName.ToCString());
QString aQuestion = QString ("Would you like to activate %1 immediately?\n")
@@ -860,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 :
@@ -1128,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();
@@ -1186,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())
@@ -1229,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);

View File

@@ -35,12 +35,14 @@
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

View File

@@ -20,10 +20,6 @@
#include <Standard_Macro.hxx>
#include <inspector/TreeModel_ItemPropertiesCreator.hxx>
#include <inspector/ViewControl_Pane.hxx>
#include <NCollection_DataMap.hxx>
#include <TCollection_AsciiString.hxx>
DEFINE_STANDARD_HANDLE (VInspectorPaneAIS_PropertiesCreator, TreeModel_ItemPropertiesCreator)
@@ -46,8 +42,6 @@ public:
DEFINE_STANDARD_RTTIEXT(VInspectorPaneAIS_PropertiesCreator, TreeModel_ItemPropertiesCreator)
private:
NCollection_DataMap<TCollection_AsciiString, ViewControl_Pane*> myPanes; //!< created panes
};
#endif

View File

@@ -313,7 +313,7 @@ Handle(Standard_Transient) View_Displayer::CreatePresentation (const TopoDS_Shap
{
Handle(AIS_Shape) aShape = new AIS_Shape (theShape);
aShape->Attributes()->SetPointAspect (new Prs3d_PointAspect (Aspect_TOM_POINT, Quantity_NOC_WHITE, 1.0));
//aShape->Attributes()->SetPointAspect (new Prs3d_PointAspect (Aspect_TOM_POINT, Quantity_NOC_WHITE, 1.0));
return aShape;
}

View File

@@ -19,6 +19,13 @@
#include <Standard_ExtString.hxx>
#include <Standard_Version.hxx>
//#define USE_CLIPPLANE
#ifdef USE_CLIPPLANE
#include <Graphic3d_ClipPlane.hxx>
#include <gp_Pln.hxx>
#endif
// =======================================================================
// function : CreateView
// purpose :
@@ -26,7 +33,15 @@
void View_Viewer::CreateView()
{
if (myView.IsNull())
{
myView = myContext->CurrentViewer()->CreateView();
#ifdef USE_CLIPPLANE
gp_Pln aPln (gp_Pnt (50, 0, 0), gp_Dir (-1., 0., 0.));
Handle(Graphic3d_ClipPlane) aClipPlane = new Graphic3d_ClipPlane(aPln);
myView->AddClipPlane (aClipPlane);
#endif
}
}
// =======================================================================

View File

@@ -8,10 +8,14 @@ ViewControl_Pane.hxx
ViewControl_PaneCreator.cxx
ViewControl_PaneCreator.hxx
ViewControl_PaneItem.hxx
ViewControl_PropertiesStream.cxx
ViewControl_PropertiesStream.hxx
ViewControl_PropertyView.cxx
ViewControl_PropertyView.hxx
ViewControl_Table.cxx
ViewControl_Table.hxx
ViewControl_TableDoubleVector.cxx
ViewControl_TableDoubleVector.hxx
ViewControl_TableItemDelegate.cxx
ViewControl_TableItemDelegate.hxx
ViewControl_TableModel.cxx

View File

@@ -26,7 +26,7 @@ enum ViewControl_EditType
ViewControl_EditType_Double, //!< line edit widget used double validator
ViewControl_EditType_Line, //!< line edit widget
ViewControl_EditType_Spin, //!< spin box widget
ViewControl_EditType_DoubleVec3, //!< control to enter three double values
ViewControl_EditType_DoubleVector, //!< control to enter three double values
ViewControl_EditType_DoAction //!< control to perform the row action
};

View File

@@ -0,0 +1,115 @@
// Created on: 2019-04-28
// 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/ViewControl_PropertiesStream.hxx>
#include <inspector/ViewControl_TransientShape.hxx>
#include <BRepBuilderAPI_MakeVertex.hxx>
#include <Message.hxx>
IMPLEMENT_STANDARD_RTTIEXT(ViewControl_PropertiesStream, TreeModel_ItemProperties)
// =======================================================================
// function : Init
// purpose :
// =======================================================================
void ViewControl_PropertiesStream::Init()
{
if (!getItem() || !myValues.IsEmpty())
return;
Standard_SStream aSStream;
getItem()->Dump (aSStream);
Message::ConvertStream (aSStream, myColumnCount, myValues);
}
// =======================================================================
// function : Reset
// purpose :
// =======================================================================
void ViewControl_PropertiesStream::Reset()
{
if (!getItem())
return;
myValues.Clear();
myColumnCount = 0;
}
// =======================================================================
// function : initItem
// purpose :
// =======================================================================
void ViewControl_PropertiesStream::initItem() const
{
const_cast<ViewControl_PropertiesStream*>(this)->Init();
}
// =======================================================================
// function : GetTableRowCount
// purpose :
// =======================================================================
int ViewControl_PropertiesStream::GetTableRowCount() const
{
initItem();
return getValues().Length() / myColumnCount;
}
// =======================================================================
// function : GetTableData
// purpose :
// =======================================================================
QVariant ViewControl_PropertiesStream::GetTableData (const int theRow, const int theColumn, int theRole) const
{
if (theRole != Qt::DisplayRole)
return QVariant();
initItem();
int anIndex = theRow * myColumnCount + theColumn;
if (theRole == Qt::DisplayRole && anIndex < getValues().Length())
return getValues().Value(anIndex).ToCString();
return QVariant();
}
// =======================================================================
// function : GetPresentations
// purpose :
// =======================================================================
void ViewControl_PropertiesStream::GetPresentations (const int theRow,
const int theColumn,
NCollection_List<Handle(Standard_Transient)>& thePresentations)
{
if (theColumn == 0)
return;
QVariant aValue = GetTableData (theRow, theColumn, Qt::DisplayRole);
TCollection_AsciiString aStrValue = aValue.toString().toStdString().c_str();
gp_XYZ aPoint;
if (!aPoint.FromString (aStrValue))
return;
thePresentations.Append (new ViewControl_TransientShape (BRepBuilderAPI_MakeVertex (aPoint)));
}

View File

@@ -0,0 +1,91 @@
// Created on: 2019-04-28
// 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 ViewControl_PropertiesStream_H
#define ViewControl_PropertiesStream_H
#include <Standard.hxx>
#include <Standard_SStream.hxx>
#include <NCollection_Vector.hxx>
#include <TCollection_AsciiString.hxx>
#include <inspector/TreeModel_ItemProperties.hxx>
#include <inspector/TreeModel_ItemBase.hxx>
DEFINE_STANDARD_HANDLE (ViewControl_PropertiesStream, TreeModel_ItemProperties)
//! \class ViewControl_PropertiesStream
//! \brief This is an interace for ViewControl_TableModel to give real values of the model
//! It should be filled or redefined.
class ViewControl_PropertiesStream : public TreeModel_ItemProperties
{
public:
//! Constructor
Standard_EXPORT ViewControl_PropertiesStream (const TreeModel_ItemBasePtr& theItem)
: TreeModel_ItemProperties (theItem) {}
//! Destructor
virtual ~ViewControl_PropertiesStream() {}
//! If me has internal values, it should be initialized here.
Standard_EXPORT virtual void Init() Standard_OVERRIDE;
//! If the item has internal values, there should be reseted here.
Standard_EXPORT virtual void Reset() Standard_OVERRIDE;
//! Returns number of table columns
//! \return an integer value
virtual int GetTableColumnCount() const { initItem(); return myColumnCount; }
//! Returns number of rows, depending on orientation: myColumnCount or size of values container
//! \param theParent an index of the parent item
//! \return an integer value
Standard_EXPORT virtual int GetTableRowCount() const Standard_OVERRIDE;
//! Returns content of the model index for the given role, it is obtained from internal container of values
//! It returns value only for DisplayRole.
//! \param theRow a model index row
//! \param theColumn a model index column
//! \param theRole a view role
//! \return value intepreted depending on the given role
Standard_EXPORT virtual QVariant GetTableData (const int theRow, const int theColumn, const int theRole = Qt::DisplayRole) const Standard_OVERRIDE;
//! 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
Standard_EXPORT virtual void GetPresentations (const int theRow, const int theColumn,
NCollection_List<Handle(Standard_Transient)>& thePresentations) Standard_OVERRIDE;
protected:
//! Returns values
//! @return values
const NCollection_Vector<TCollection_AsciiString>& getValues() const { return myValues; }
protected:
//! Initialize me.
Standard_EXPORT void initItem() const;
public:
DEFINE_STANDARD_RTTIEXT (ViewControl_PropertiesStream, TreeModel_ItemProperties)
protected:
NCollection_Vector<TCollection_AsciiString> myValues; //!< container of values
Standard_Integer myColumnCount; //!< value to present container of values into table
};
#endif

View File

@@ -0,0 +1,264 @@
//-----------------------------------------------------------------------------
// Created on: 2019-03-28
// Created by: Vadim LEONTIEV
// Copyright (c) 2019 OPEN CASCADE SAS
//
// This file is part of commercial software by OPEN CASCADE SAS.
//
// This software is furnished in accordance with the terms and conditions
// of the contract and with the inclusion of this copyright notice.
// This software or any other copy thereof may not be provided or otherwise
// be made available to any third party.
// No ownership title to the software is transferred hereby.
//
// OPEN CASCADE SAS makes no representation or warranties with respect to the
// performance of this software, and specifically disclaims any responsibility
// for any damages, special or consequential, connected with its use.
//-----------------------------------------------------------------------------
#include <inspector/ViewControl_TableDoubleVector.hxx>
#include <inspector/ViewControl_TableItemDelegate.hxx>
#include <inspector/ViewControl_TableModel.hxx>
#include <inspector/ViewControl_TableModelValues.hxx>
#include <inspector/TreeModel_Tools.hxx>
#include <Standard_WarningsDisable.hxx>
#include <QDialogButtonBox>
#include <QHeaderView>
#include <QGridLayout>
#include <QItemSelectionModel>
#include <QTableView>
#include <QWidget>
#include <Standard_WarningsRestore.hxx>
//! Model for a table of parameters: Values: X, Y, Z
class ViewControl_ParametersModelVector : public ViewControl_TableModelValues
{
public:
ViewControl_ParametersModelVector(ViewControl_TableDoubleVector* theDoubleVector)
: ViewControl_TableModelValues(), myDoubleVector(theDoubleVector) {}
virtual ~ViewControl_ParametersModelVector() {}
//! Inits model by the parameters vector
//! \param theVector model the vector
void SetVector(const QList<QVariant>& theVector)
{
if (myVector.isEmpty())
{ myVector.clear(); }
for (int aNumberVector = 0; aNumberVector < theVector.size(); ++aNumberVector)
{
myVector.append(theVector[aNumberVector]);
}
}
//! Returns current vector
//! \return vector value to string
QList<QVariant> GetVector() const { return myVector; }
//! Returns current vector
//! \return vector value to QList
QList<QVariant> GetListFromString(const QString& theVector) const
{
QList<QVariant> aDoubleList;
QStringList aList = theVector.split(QString(","), QString::SkipEmptyParts);
if (aList.isEmpty())
return aDoubleList;
for (int aNumberValue = 0; aNumberValue < aList.size(); ++aNumberValue)
{
aDoubleList.append(QVariant(aList[aNumberValue]));
}
return aDoubleList;
}
//! Returns item information(short) for display role.
//! \param theIndex a model index
//! \param theRole a view role
//! \return value intepreted depending on the given role
Standard_EXPORT virtual QVariant Data(const int theRow, const int theColumn,
int theRole = Qt::DisplayRole) const Standard_OVERRIDE
{
if (theRole != Qt::DisplayRole)
return QVariant();
bool isFirstColumn = theColumn == 0;
switch (theRow)
{
case 0: return isFirstColumn ? QVariant("X") : myVector[theRow];
case 1: return isFirstColumn ? QVariant("Y") : myVector[theRow];
case 2: return isFirstColumn ? QVariant("Z") : myVector[theRow];
}
return QVariant();
}
//! Sets content of the model index for the given role, it is applyed to internal container of values
//! \param theRow a model index row
//! \param theColumn a model index column
//! \param theRole a view role
//! \return true if the value is changed
virtual bool SetData(const int theRow, const int theColumn, const QVariant& theValue, int)
{
if (theColumn != 1 || theRow < 0 || theRow > 2)
return false;
switch (theRow)
{
case 0: myVector[theRow] = theValue; break;
case 1: myVector[theRow] = theValue; break;
case 2: myVector[theRow] = theValue; break;
}
return true;
}
//! Returns number of tree level line items = colums in table view
virtual int ColumnCount(const QModelIndex& theParent = QModelIndex()) const Standard_OVERRIDE
{ (void)theParent; return 2; }
//! Returns onlly one row in table view
virtual int RowCount(const QModelIndex& theParent = QModelIndex()) const Standard_OVERRIDE
{ (void)theParent; return 3; }
//! Returns editable flag for DoubleVector
//! \return flags
Qt::ItemFlags Flags(const QModelIndex& theIndex) const
{
Qt::ItemFlags aFlags = ViewControl_TableModelValues::Flags(theIndex);
if (theIndex.column() == 1 && theIndex.row() >= 0 && theIndex.row() <= 2)
aFlags = aFlags | Qt::ItemIsEditable;
return aFlags;
}
//! 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 GetEditType(const int theRow, const int theColumn) const
{
if (theColumn == 1 && theRow >= 0 && theRow <= 2)
return ViewControl_EditType_Double;
return ViewControl_EditType_None;
}
private:
QList<QVariant> myVector;
ViewControl_TableDoubleVector* myDoubleVector;
};
// =======================================================================
// function : Constructor
// purpose :
// =======================================================================
ViewControl_TableDoubleVector::ViewControl_TableDoubleVector(QWidget* theParent)
: QDialog(theParent)
{
QGridLayout* aLayout = new QGridLayout(this);
aLayout->setContentsMargins(0, 0, 0, 0);
myParameters = new QTableView(this);
ViewControl_TableModel* aTableModel = new ViewControl_TableModel(myParameters);
aTableModel->SetModelValues(new ViewControl_ParametersModelVector(this));
myParameters->setModel(aTableModel);
ViewControl_TableItemDelegate* anItemDelegate = new ViewControl_TableItemDelegate();
anItemDelegate->SetModelValues(aTableModel->GetModelValues());
myParameters->setItemDelegate(anItemDelegate);
myParameters->verticalHeader()->setDefaultSectionSize(myParameters->verticalHeader()->minimumSectionSize());
myParameters->verticalHeader()->setVisible(false);
myParameters->horizontalHeader()->setVisible(false);
myParameters->setMinimumHeight(myParameters->verticalHeader()->minimumSectionSize() * aTableModel->rowCount() +
TreeModel_Tools::HeaderSectionMargin());
myParameters->setMinimumWidth(myParameters->horizontalHeader()->defaultSectionSize() * aTableModel->columnCount() +
TreeModel_Tools::HeaderSectionMargin());
QItemSelectionModel* aSelectionModel = new QItemSelectionModel(myParameters->model());
myParameters->setSelectionMode(QAbstractItemView::SingleSelection);
myParameters->setSelectionModel(aSelectionModel);
aLayout->addWidget(myParameters, 0, 0);
myDialogButtons = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel, this);
connect(myDialogButtons, &QDialogButtonBox::accepted, this, &QDialog::accept);
connect(myDialogButtons, &QDialogButtonBox::rejected, this, &QDialog::reject);
aLayout->addWidget(myDialogButtons, 1, 0, 1, 2);
}
// =======================================================================
// function : SetVectorValue
// purpose :
// =======================================================================
void ViewControl_TableDoubleVector::SetVectorValue(const QString& theVector)
{
QList<QVariant> aVector = GetListVector(theVector);
// parameters model
ViewControl_TableModel* aTableModel = dynamic_cast<ViewControl_TableModel*> (myParameters->model());
ViewControl_ParametersModelVector* aParametersModel = dynamic_cast<ViewControl_ParametersModelVector*> (aTableModel->GetModelValues());
aParametersModel->SetVector(aVector);
}
// =======================================================================
// function : GetListVector
// purpose :
// =======================================================================
QList<QVariant> ViewControl_TableDoubleVector::GetListVector(const QString& theVector)
{
QList<QVariant> aDoubleList;
QStringList aList = theVector.split(ViewControl_TableDoubleVector::DoubleSeparator(), QString::SkipEmptyParts);
if (aList.isEmpty())
return aDoubleList;
for (int aNumberValue = 0; aNumberValue < aList.size(); ++aNumberValue)
{
aDoubleList.append(QVariant(aList[aNumberValue]));
}
return aDoubleList;
}
// =======================================================================
// function : GetVector
// purpose :
// =======================================================================
QString ViewControl_TableDoubleVector::GetVector() const
{
ViewControl_TableModel* aTableModel = dynamic_cast<ViewControl_TableModel*> (myParameters->model());
ViewControl_ParametersModelVector* aParametersModel = dynamic_cast<ViewControl_ParametersModelVector*> (aTableModel->GetModelValues());
return VectorToString(aParametersModel->GetVector());
}
// =======================================================================
// function : VectorToString
// purpose :
// =======================================================================
QString ViewControl_TableDoubleVector::VectorToString(const QList<QVariant>& theVector) const
{
QString aVectorToString;
for (int aNumberValue = 0; aNumberValue < theVector.size(); ++aNumberValue)
{
aVectorToString += theVector[aNumberValue].toString() + DoubleSeparator();
}
aVectorToString.remove(aVectorToString.length() - 1, 1);
return aVectorToString;
}

View File

@@ -0,0 +1,76 @@
//-----------------------------------------------------------------------------
// Created on: 2019-03-28
// Created by: Vadim LEONTIEV
// Copyright (c) 2019 OPEN CASCADE SAS
//
// This file is part of commercial software by OPEN CASCADE SAS.
//
// This software is furnished in accordance with the terms and conditions
// of the contract and with the inclusion of this copyright notice.
// This software or any other copy thereof may not be provided or otherwise
// be made available to any third party.
// No ownership title to the software is transferred hereby.
//
// OPEN CASCADE SAS makes no representation or warranties with respect to the
// performance of this software, and specifically disclaims any responsibility
// for any damages, special or consequential, connected with its use.
//-----------------------------------------------------------------------------
#ifndef ViewControl_TableDoubleVector_H
#define ViewControl_TableDoubleVector_H
#include <inspector/ViewControl.hxx>
#include <inspector/ViewControl_Tools.hxx>
#include <Standard_WarningsDisable.hxx>
#include <Standard_Macro.hxx>
#include <QDialog>
#include <QString>
#include <QWidget>
#include <Standard_WarningsRestore.hxx>
class QDialogButtonBox;
class QTableView;
//! \class ViewControl_PointCoordinates
//! \dialog of change the point coordinates
class VIEWCONTROL_EXPORT ViewControl_TableDoubleVector : public QDialog
{
Q_OBJECT
public:
//! Constructor
ViewControl_TableDoubleVector(QWidget* theParent);
//! Destructor
virtual ~ViewControl_TableDoubleVector() Standard_OVERRIDE{}
//! Inits control by the vector value
//! \param theVector text vector value
void SetVectorValue(const QString& theVector);
//! Returns vector value
//! \return QList<QVariant> vector value
static QList<QVariant> ViewControl_TableDoubleVector::GetListVector(const QString& theVector);
//! Returns vector value
//! \return text vector value
QString GetVector() const;
//! Converts vector to string value in form
//! \param theVector vector value
//! \return text value
QString VectorToString(const QList<QVariant>& theVector) const;
private:
//! Returns symbol used as a separtor of vector components in string conversion
//! \return symbol value
static QString DoubleSeparator() { return ","; }
private:
QTableView* myParameters; //! current vector parameters
QDialogButtonBox* myDialogButtons; //! OK/Cancel buttons
};
#endif // ViewControl_TableDoubleVector_H

View File

@@ -17,6 +17,7 @@
#include <inspector/ViewControl_ColorSelector.hxx>
#include <inspector/ViewControl_TableModelValues.hxx>
#include <inspector/ViewControl_EditType.hxx>
#include <inspector/ViewControl_TableDoubleVector.hxx>
#include <Standard_WarningsDisable.hxx>
#include <QFont>
@@ -121,6 +122,7 @@ QWidget* ViewControl_TableItemDelegate::createEditorControl (QWidget* theParent,
return aSpinBox;
}
case ViewControl_EditType_DoAction: return new QPushButton (theParent);
case ViewControl_EditType_DoubleVector: return new ViewControl_TableDoubleVector(theParent);
default: return 0;
}
@@ -185,6 +187,7 @@ void ViewControl_TableItemDelegate::setEditorValue (QWidget* theEditor, const Vi
case ViewControl_EditType_Line: (qobject_cast<QLineEdit*>(theEditor))->setText (theValue.toString()); break;
case ViewControl_EditType_Spin: (qobject_cast<QSpinBox*>(theEditor))->setValue (theValue.toInt()); break;
case ViewControl_EditType_DoAction: (qobject_cast<QPushButton*>(theEditor))->setText ("UnSelect"); break;
case ViewControl_EditType_DoubleVector: (qobject_cast<ViewControl_TableDoubleVector*>(theEditor))->SetVectorValue(theValue.toString()); break;
default: break;
}
@@ -207,6 +210,7 @@ QVariant ViewControl_TableItemDelegate::getEditorValue (QWidget* theEditor, cons
case ViewControl_EditType_Line: return (qobject_cast<QLineEdit*>(theEditor))->text();
case ViewControl_EditType_Spin: return (qobject_cast<QSpinBox*>(theEditor))->value();
case ViewControl_EditType_DoAction: return QVariant ("Clicked");
case ViewControl_EditType_DoubleVector: return (qobject_cast<ViewControl_TableDoubleVector*>(theEditor))->GetVector();
default: return QVariant();
}

View File

@@ -18,6 +18,13 @@
#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();
}
}

View File

@@ -21,11 +21,13 @@
#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