mirror of
https://git.dev.opencascade.org/repos/occt.git
synced 2025-09-13 14:27:08 +03:00
0030268: Inspectors - improvements in VInspector plugin
- transform persistent apply to preview of presentations - Graphic3d_Camera matrices values in property panel - SelectMgr_Selection values in property panel.
This commit is contained in:
@@ -24,6 +24,8 @@
|
||||
#include <inspector/TreeModel_ItemBase.hxx>
|
||||
#include <inspector/ViewControl_EditType.hxx>
|
||||
|
||||
class Graphic3d_TransformPers;
|
||||
|
||||
class VInspector_ItemBase;
|
||||
typedef QExplicitlySharedDataPointer<VInspector_ItemBase> VInspector_ItemBasePtr;
|
||||
|
||||
@@ -56,6 +58,9 @@ public:
|
||||
virtual void GetPresentations (NCollection_List<Handle(Standard_Transient)>& thePresentations)
|
||||
{ (void)thePresentations; }
|
||||
|
||||
//! Returns transform persistent of the item or NULL
|
||||
Handle(Graphic3d_TransformPers) TransformPersistence() const { return myTransformPersistence; }
|
||||
|
||||
//! Returns shape of the item parameters
|
||||
//! \return generated shape of the item parameters
|
||||
Standard_EXPORT virtual TopoDS_Shape GetPresentationShape() const;
|
||||
@@ -117,6 +122,7 @@ protected:
|
||||
|
||||
Handle(AIS_InteractiveContext) myContext; //!< the current context
|
||||
TopoDS_Shape myPresentationShape; //!< item presentation shape
|
||||
Handle(Graphic3d_TransformPers) myTransformPersistence; //!< item cached persistent
|
||||
};
|
||||
|
||||
#endif
|
@@ -60,6 +60,8 @@ void VInspector_ItemGraphic3dCStructure::Init()
|
||||
|
||||
Handle(Prs3d_Presentation) aPresentation = aParentItem->GetPresentation();
|
||||
myCStructure = aPresentation->CStructure();
|
||||
if (!myCStructure.IsNull())
|
||||
myTransformPersistence = myCStructure->TransformPersistence();
|
||||
|
||||
TreeModel_ItemBase::Init();
|
||||
}
|
||||
@@ -72,6 +74,7 @@ void VInspector_ItemGraphic3dCStructure::Reset()
|
||||
{
|
||||
VInspector_ItemBase::Reset();
|
||||
myCStructure = NULL;
|
||||
myTransformPersistence = NULL;
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
|
@@ -241,6 +241,24 @@ QVariant VInspector_ItemGraphic3dCamera::GetTableData (const int theRow, const i
|
||||
: QVariant (ViewControl_Tools::ToString (aCamera->Direction()).ToCString());
|
||||
case 19: return isFirstColumn ? (!isToolTip ? QVariant ("ViewDimensions") : QVariant ("View plane size at center (target) point and distance between ZFar and ZNear planes"))
|
||||
: ViewControl_Tools::ToString (aCamera->ViewDimensions()).ToCString();
|
||||
|
||||
case 20: return ViewControl_Table::SeparatorData();
|
||||
case 21: return isFirstColumn ? QVariant ("TransformMatrices (D):") : QVariant();
|
||||
case 22: return ViewControl_Table::SeparatorData();
|
||||
|
||||
case 23: return isFirstColumn ? QVariant ("OrientationMatrix") : VInspector_Tools::ToVariant (aCamera->OrientationMatrix());
|
||||
case 24: return isFirstColumn ? QVariant ("ProjectionMatrix") : VInspector_Tools::ToVariant (aCamera->ProjectionMatrix());
|
||||
case 25: return isFirstColumn ? QVariant ("ProjectionStereoLeft") : VInspector_Tools::ToVariant (aCamera->ProjectionStereoLeft());
|
||||
case 26: return isFirstColumn ? QVariant ("ProjectionStereoRight") : VInspector_Tools::ToVariant (aCamera->ProjectionStereoRight());
|
||||
|
||||
case 27: return ViewControl_Table::SeparatorData();
|
||||
case 28: return isFirstColumn ? QVariant ("TransformMatrices (F):") : QVariant();
|
||||
case 29: return ViewControl_Table::SeparatorData();
|
||||
|
||||
case 30: return isFirstColumn ? QVariant ("OrientationMatrixF") : VInspector_Tools::ToVariant (aCamera->OrientationMatrixF());
|
||||
case 31: return isFirstColumn ? QVariant ("ProjectionMatrixF") : VInspector_Tools::ToVariant (aCamera->ProjectionMatrixF());
|
||||
case 32: return isFirstColumn ? QVariant ("ProjectionStereoLeftF") : VInspector_Tools::ToVariant (aCamera->ProjectionStereoLeftF());
|
||||
case 33: return isFirstColumn ? QVariant ("ProjectionStereoRightF") : VInspector_Tools::ToVariant (aCamera->ProjectionStereoRightF());
|
||||
}
|
||||
return QVariant();
|
||||
}
|
||||
|
@@ -204,6 +204,7 @@ void VInspector_ItemPresentableObject::Init()
|
||||
}
|
||||
|
||||
setInteractiveObject (anIO);
|
||||
myTransformPersistence = anIO->TransformPersistence();
|
||||
UpdatePresentationShape();
|
||||
TreeModel_ItemBase::Init(); // to use getIO() without circling initialization
|
||||
}
|
||||
@@ -218,6 +219,7 @@ void VInspector_ItemPresentableObject::Reset()
|
||||
|
||||
SetContext (NULL);
|
||||
setInteractiveObject (NULL);
|
||||
myTransformPersistence = NULL;
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
|
@@ -176,7 +176,7 @@ QVariant VInspector_ItemPrs3dPresentation::GetTableData (const int theRow, const
|
||||
switch (theRow)
|
||||
{
|
||||
case 0: return ViewControl_Table::SeparatorData();
|
||||
case 1: return isFirstColumn ? QVariant (STANDARD_TYPE (Graphic3d_Structure)->Name())
|
||||
case 1: return isFirstColumn ? QVariant (STANDARD_TYPE (Prs3d_Presentation)->Name())
|
||||
: ViewControl_Tools::GetPointerInfo (aPrs).ToCString();
|
||||
case 2: return ViewControl_Table::SeparatorData();
|
||||
case 3: return isFirstColumn ? QVariant ("DisplayPriority") : QVariant (aPrs->DisplayPriority());
|
||||
|
@@ -189,3 +189,40 @@ void VInspector_ItemSelectMgrSelection::initItem() const
|
||||
const_cast<VInspector_ItemSelectMgrSelection*>(this)->Init();
|
||||
// an empty method to don't initialize the main label, as it was not cleared in Reset()
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : GetTableRowCount
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
int VInspector_ItemSelectMgrSelection::GetTableRowCount() const
|
||||
{
|
||||
return 10;
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : GetTableData
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
QVariant VInspector_ItemSelectMgrSelection::GetTableData (const int theRow, const int theColumn, const int theRole) const
|
||||
{
|
||||
if (theRole != Qt::DisplayRole)
|
||||
return QVariant();
|
||||
|
||||
bool isFirstColumn = theColumn == 0;
|
||||
|
||||
Handle(SelectMgr_Selection) aSelection = GetSelection();
|
||||
switch (theRow)
|
||||
{
|
||||
case 0: return isFirstColumn ? QVariant ("Mode") : QVariant (aSelection->Mode());
|
||||
case 1: return isFirstColumn ? QVariant ("Sensitivity") : QVariant (aSelection->Sensitivity());
|
||||
case 2: return isFirstColumn ? QVariant ("UpdateStatus")
|
||||
: QVariant ((int)aSelection->UpdateStatus()); // TODO! SelectMgr_TypeOfUpdate
|
||||
case 3: return isFirstColumn ? QVariant ("BVHUpdateStatus")
|
||||
: QVariant ((int)aSelection->BVHUpdateStatus()); // TODO! SelectMgr_TypeOfBVHUpdate
|
||||
case 4: return isFirstColumn ? QVariant ("GetSelectionState")
|
||||
: QVariant ((int)aSelection->GetSelectionState()); // TODO! SelectMgr_StateOfSelection
|
||||
|
||||
default: return QVariant();
|
||||
}
|
||||
return QVariant();
|
||||
}
|
||||
|
@@ -52,6 +52,15 @@ public:
|
||||
//! 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:
|
||||
|
||||
//! Initializes the current item. It is empty because Reset() is also empty.
|
||||
|
@@ -589,7 +589,7 @@ TopoDS_Shape VInspector_Tools::CreateShape (const Bnd_Box& theBoundingBox)
|
||||
theBoundingBox.IsXThin (Precision::Confusion()) ||
|
||||
theBoundingBox.IsYThin (Precision::Confusion()) ||
|
||||
theBoundingBox.IsZThin (Precision::Confusion()))
|
||||
return TopoDS_Shape();
|
||||
return TopoDS_Shape(); // TODO: display shape for thin box, like in the same method for Select3D_BndBox3d
|
||||
|
||||
BRepPrimAPI_MakeBox aBoxBuilder(theBoundingBox.CornerMin(), theBoundingBox.CornerMax());
|
||||
return aBoxBuilder.Shape();
|
||||
@@ -610,6 +610,16 @@ TopoDS_Shape VInspector_Tools::CreateShape (const Select3D_BndBox3d& theBounding
|
||||
Standard_Boolean aThinOnX = fabs (aPntMin.X() - aPntMax.X()) < Precision::Confusion();
|
||||
Standard_Boolean aThinOnY = fabs (aPntMin.Y() - aPntMax.Y()) < Precision::Confusion();
|
||||
Standard_Boolean aThinOnZ = fabs (aPntMin.Z() - aPntMax.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 (aPntMin));
|
||||
return aCompound;
|
||||
}
|
||||
|
||||
if (aThinOnX || aThinOnY || aThinOnZ)
|
||||
{
|
||||
gp_Pnt aPnt1, aPnt2, aPnt3, aPnt4 ;
|
||||
@@ -620,14 +630,14 @@ TopoDS_Shape VInspector_Tools::CreateShape (const Select3D_BndBox3d& theBounding
|
||||
aPnt3 = gp_Pnt(aPntMin.X(), aPntMax.Y(), aPntMax.Z());
|
||||
aPnt4 = gp_Pnt(aPntMin.X(), aPntMin.Y(), aPntMax.Z());
|
||||
}
|
||||
if (aThinOnY)
|
||||
else if (aThinOnY)
|
||||
{
|
||||
aPnt1 = gp_Pnt(aPntMin.X(), aPntMin.Y(), aPntMin.Z());
|
||||
aPnt2 = gp_Pnt(aPntMax.X(), aPntMin.Y(), aPntMin.Z());
|
||||
aPnt3 = gp_Pnt(aPntMax.X(), aPntMin.Y(), aPntMax.Z());
|
||||
aPnt4 = gp_Pnt(aPntMin.X(), aPntMin.Y(), aPntMax.Z());
|
||||
}
|
||||
if (aThinOnZ)
|
||||
else if (aThinOnZ)
|
||||
{
|
||||
aPnt1 = gp_Pnt(aPntMin.X(), aPntMin.Y(), aPntMin.Z());
|
||||
aPnt2 = gp_Pnt(aPntMax.X(), aPntMin.Y(), aPntMin.Z());
|
||||
@@ -698,6 +708,50 @@ QVariant VInspector_Tools::ToVariant (const Handle(Graphic3d_BoundBuffer)& theBo
|
||||
return QVariant();
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : ToVariant
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
QVariant VInspector_Tools::ToVariant (const Graphic3d_Mat4d& theMatrix)
|
||||
{
|
||||
TCollection_AsciiString aValues;
|
||||
for (int aRowId = 1; aRowId <= theMatrix.Rows(); aRowId++)
|
||||
{
|
||||
for (int aColId = 1; aColId <= theMatrix.Cols(); aColId++)
|
||||
{
|
||||
aValues += TCollection_AsciiString (theMatrix.GetValue (aRowId, aColId));
|
||||
if (aColId != theMatrix.Rows())
|
||||
aValues += ",";
|
||||
}
|
||||
if (aRowId != theMatrix.Rows())
|
||||
aValues += " ";
|
||||
}
|
||||
|
||||
return aValues.ToCString();
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : ToVariant
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
QVariant VInspector_Tools::ToVariant (const Graphic3d_Mat4& theMatrix)
|
||||
{
|
||||
TCollection_AsciiString aValues;
|
||||
for (int aRowId = 1; aRowId <= theMatrix.Rows(); aRowId++)
|
||||
{
|
||||
for (int aColId = 1; aColId <= theMatrix.Cols(); aColId++)
|
||||
{
|
||||
aValues += TCollection_AsciiString (theMatrix.GetValue (aRowId, aColId));
|
||||
if (aColId != theMatrix.Rows())
|
||||
aValues += ",";
|
||||
}
|
||||
if (aRowId != theMatrix.Rows())
|
||||
aValues += " ";
|
||||
}
|
||||
|
||||
return aValues.ToCString();
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : ToString
|
||||
//purpose :
|
||||
|
@@ -19,6 +19,8 @@
|
||||
#include <AIS_InteractiveContext.hxx>
|
||||
#include <Bnd_Box.hxx>
|
||||
#include <Graphic3d_Buffer.hxx>
|
||||
#include <Graphic3d_Mat4.hxx>
|
||||
#include <Graphic3d_Mat4d.hxx>
|
||||
#include <Select3D_BndBox3d.hxx>
|
||||
#include <SelectMgr_EntityOwner.hxx>
|
||||
#include <Standard.hxx>
|
||||
@@ -206,6 +208,16 @@ public:
|
||||
//! \return string presentation
|
||||
Standard_EXPORT static QVariant ToVariant (const Handle(Graphic3d_BoundBuffer)& theBoundBuffer);
|
||||
|
||||
//! Convert matrix values into a text presentation
|
||||
//! \param theMatrix a matrix of elements
|
||||
//! \return string presentation
|
||||
Standard_EXPORT static QVariant ToVariant (const Graphic3d_Mat4d& theMatrix);
|
||||
|
||||
//! Convert matrix values into a text presentation
|
||||
//! \param theMatrix a matrix of elements
|
||||
//! \return string presentation
|
||||
Standard_EXPORT static QVariant ToVariant (const Graphic3d_Mat4& theMatrix);
|
||||
|
||||
Standard_EXPORT static QString ToString (const Graphic3d_Attribute& theAttribute);
|
||||
|
||||
};
|
||||
|
@@ -434,18 +434,14 @@ Handle(Graphic3d_TransformPers) VInspector_Window::GetSelectedTransformPers()
|
||||
if (!aVItem)
|
||||
continue;
|
||||
|
||||
Handle(AIS_InteractiveObject) anIO;
|
||||
while (aVItem && anIO.IsNull())
|
||||
while (aVItem)
|
||||
{
|
||||
VInspector_ItemPresentableObjectPtr aPrsObjectItem = itemDynamicCast<VInspector_ItemPresentableObject>(aVItem);
|
||||
if (aPrsObjectItem)
|
||||
{
|
||||
anIO = aPrsObjectItem->GetInteractiveObject();
|
||||
}
|
||||
Handle(Graphic3d_TransformPers) aPers = aVItem->TransformPersistence();
|
||||
if (!aPers.IsNull())
|
||||
return aPers;
|
||||
|
||||
aVItem = itemDynamicCast<VInspector_ItemBase>(aVItem->Parent());
|
||||
}
|
||||
if (!anIO.IsNull() && !anIO->TransformPersistence().IsNull())
|
||||
return anIO->TransformPersistence();
|
||||
}
|
||||
return Handle(Graphic3d_TransformPers)();
|
||||
}
|
||||
|
Reference in New Issue
Block a user