1
0
mirror of https://git.dev.opencascade.org/repos/occt.git synced 2025-08-24 13:50:49 +03:00

0030268: Inspectors - improvements in VInspector plugin

- Convert package creation. It is used to prepare some auxiliary presentations/methods to prepare variables for inspector based on occt classes.
- ViewControl package improvement:
  Classes for property view, table, table model are implemented to visualize view of properties.
  This view is filled by selection in tree if the selected object has implemented DumpJson functionality.
- TreeModel package improvements:
  Method InitColumn is implemented in TreeModel_TreeModel to fill default columns in base model. The default columns are:
    Name, Visibility, Rows. Additional columns should be added in successors.
  Container of root items is moved into the base class
- View package imrovements:
  Store preferences: display mode, fit all checked state and type of external context
  View_DisplayPreview is added to process preview for selected in tree view objects
  hide actions Clear, Multi, Single by default (as selection in tree view or Visibility state of item define which presentations should be displayed or erased)
- ShapeView plugin improvements:
  Property View content based on DumpJson (columns in tree view for properties are removed),
  Properties for TopoDS_Shape are displayed
  Explode shape action in tree view to see content of shape by selected shape type. Type of displayed shapes is only preview, it is not used in export action.
  Export shape into BREP. The previous implementation about BREP files in some directory and default view is removed.
- VInspector plugin imrovements:
  Property View content based on DumpJson (columns in tree view for properties are removed),
  Properties for AIS_InteractiveContext and AIS_InteractiveObject are displayed
  obsolete classes to provide properties are removed.
- DFBrowser plugin improvements:
  Property View content based on DumpJson is not used yet. But there is the USE_DUMPJSON macro. It's switch off by default.
  If switch ON, it creates a Property View filled with DumpJson. It's a way of DFBrowser moving on this property view.
  Init uses static variable CDF_Session::CurrentSession()->CurrentApplication to fill plugin if application in plugin is not set but OCAF application exists

- OCC_VERSION_HEX variable used for previous OCCT versions support (before 6.9.0 or 7.2.0) is removed
This commit is contained in:
nds
2020-01-31 13:12:45 +03:00
committed by bugmaster
parent a2803f37e7
commit 7e1c1e4869
204 changed files with 4893 additions and 3415 deletions

View File

@@ -15,21 +15,17 @@
#include <inspector/ShapeView_ItemShape.hxx>
#include <Adaptor3d_Curve.hxx>
#include <BRep_Tool.hxx>
#include <BRepAdaptor_Curve.hxx>
#include <GCPnts_AbscissaPoint.hxx>
#include <Geom_Curve.hxx>
#include <GeomAdaptor_Curve.hxx>
#include <inspector/ShapeView_ItemRoot.hxx>
#include <inspector/ShapeView_ItemShape.hxx>
#include <inspector/ViewControl_Tools.hxx>
#include <TopAbs.hxx>
#include <TCollection_AsciiString.hxx>
#include <TopoDS.hxx>
#include <TopoDS_Edge.hxx>
#include <TopoDS_Iterator.hxx>
#include <TopoDS_Vertex.hxx>
#include <TopExp.hxx>
#include <TopTools_IndexedMapOfShape.hxx>
#include <Standard_WarningsDisable.hxx>
#include <QObject>
@@ -37,166 +33,32 @@
#include <Standard_WarningsRestore.hxx>
// =======================================================================
// function : ToString
// function : Shape
// purpose :
// =======================================================================
QString ToString (const Standard_Boolean& theValue)
TopoDS_Shape ShapeView_ItemShape::Shape (const int theRowId) const
{
return theValue ? "1" : "0";
}
// =======================================================================
// function : ToString
// purpose :
// =======================================================================
QString ToString (const gp_Pnt& thePoint)
{
return QString ("(%1, %2, %3)").arg (thePoint.X()).arg (thePoint.Y()).arg (thePoint.Z());
}
// =======================================================================
// function : ToName
// purpose :
// =======================================================================
QString ToName (const TopAbs_ShapeEnum& theShapeType)
{
Standard_SStream aSStream;
TopAbs::Print (theShapeType, aSStream);
return QString (aSStream.str().c_str());
}
// =======================================================================
// function : ToName
// purpose :
// =======================================================================
QString ToName (const TopAbs_Orientation& theOrientation)
{
Standard_SStream aSStream;
TopAbs::Print(theOrientation, aSStream);
return QString (aSStream.str().c_str());
}
// =======================================================================
// function : ToName
// purpose :
// =======================================================================
QString ToName (const GeomAbs_Shape& theType)
{
switch (theType)
if (myChildShapes.IsEmpty())
{
case GeomAbs_C0: return "GeomAbs_C0";
case GeomAbs_G1: return "GeomAbs_G1";
case GeomAbs_C1: return "GeomAbs_C1";
case GeomAbs_G2: return "GeomAbs_G2";
case GeomAbs_C2: return "GeomAbs_C2";
case GeomAbs_C3: return "GeomAbs_C3";
case GeomAbs_CN: return "GeomAbs_CN";
default: break;
}
return QString();
}
ShapeView_ItemShape* aThis = (ShapeView_ItemShape*)this;
// =======================================================================
// function : ToOtherInfo
// purpose :
// =======================================================================
void ToOtherInfo (const TopoDS_Shape& theShape, QVariant& theValue, QVariant& theInfo)
{
switch (theShape.ShapeType())
{
case TopAbs_COMPOUND:
case TopAbs_COMPSOLID:
case TopAbs_SOLID:
case TopAbs_SHELL:
case TopAbs_FACE:
case TopAbs_WIRE:
break;
case TopAbs_EDGE:
if (myExplodeType != TopAbs_SHAPE)
{
TopoDS_Edge anEdge = TopoDS::Edge(theShape);
double aFirst, aLast;
Handle(Geom_Curve) aCurve = BRep_Tool::Curve(anEdge, aFirst, aLast);
GeomAdaptor_Curve aAdaptor(aCurve, aFirst, aLast);
gp_Pnt aFirstPnt = aAdaptor.Value(aFirst);
gp_Pnt aLastPnt = aAdaptor.Value(aLast);
BRepAdaptor_Curve aBRepAdaptor = BRepAdaptor_Curve(anEdge);
Adaptor3d_Curve* anAdaptor3d = &aBRepAdaptor;
QStringList aValues, anInfo;
aValues.append (QString::number (GCPnts_AbscissaPoint::Length(*anAdaptor3d)));
anInfo.append ("Length");
aValues.append (aCurve->DynamicType()->Name());
anInfo.append ("DynamicType");
aValues.append (ToString (aFirstPnt));
anInfo.append (QString ("First" + QString::number (aFirst)));
aValues.append (ToString (aLastPnt));
anInfo.append (QString ("Last" + QString::number (aLast)));
aValues.append (ToName (aCurve->Continuity()));
anInfo.append ("Continuity");
aValues.append (ToString (aCurve->IsClosed()));
anInfo.append ("IsClosed");
if (aCurve->IsPeriodic()) {
aValues.append (QString::number (aCurve->Period()));
anInfo.append ("IsPeriodic");
}
else
{
aValues.append (ToString (aCurve->IsPeriodic()));
anInfo.append ("IsPeriodic");
}
theValue = aValues.join (" / ");
theInfo = QString ("%1:\n%2").arg (anInfo.join (" / ")).arg (aValues.join ("\n"));
break;
TopExp::MapShapes(myShape, myExplodeType, aThis->myChildShapes);
}
else
{
TopoDS_Iterator aSubShapeIt (myShape);
for (int aCurrentIndex = 0; aSubShapeIt.More(); aSubShapeIt.Next(), aCurrentIndex++)
{
aThis->myChildShapes.Add (aSubShapeIt.Value());
}
}
case TopAbs_SHAPE:
default:
break;
}
}
if (myChildShapes.Extent() >= theRowId + 1)
return myChildShapes(theRowId + 1);
// =======================================================================
// function : locationInfo
// purpose :
// =======================================================================
QString locationInfo (const TopLoc_Location& theLocation)
{
QString anInfo;
gp_Trsf aTrsf = theLocation.Transformation();
QStringList aValues, aRowValues;
for (int aRowId = 1; aRowId <= 3; aRowId++)
{
aRowValues.clear();
for (int aColumnId = 1; aColumnId <= 4; aColumnId++)
aRowValues.append (QString::number (aTrsf.Value(aRowId, aColumnId)));
aValues.append (aRowValues.join (","));
}
anInfo.append (aValues.join (" "));
return anInfo;
}
// =======================================================================
// function : GetShape
// purpose :
// =======================================================================
TopoDS_Shape ShapeView_ItemShape::GetShape (const int theRowId) const
{
TopoDS_Iterator aSubShapeIt (myShape);
for (int aCurrentIndex = 0; aSubShapeIt.More(); aSubShapeIt.Next(), aCurrentIndex++)
{
if (aCurrentIndex != theRowId)
continue;
break;
}
return aSubShapeIt.Value();
return TopoDS_Shape();
}
// =======================================================================
@@ -205,6 +67,10 @@ TopoDS_Shape ShapeView_ItemShape::GetShape (const int theRowId) const
// =======================================================================
QVariant ShapeView_ItemShape::initValue(const int theRole) const
{
QVariant aParentValue = TreeModel_ItemBase::initValue (theRole);
if (aParentValue.isValid())
return aParentValue;
TopoDS_Shape aShape = getShape();
if (aShape.IsNull())
return QVariant();
@@ -214,58 +80,7 @@ QVariant ShapeView_ItemShape::initValue(const int theRole) const
switch (Column())
{
case 0: return ToName (aShape.ShapeType());
case 2: return rowCount() > 0 ? QVariant (rowCount()) : QVariant();
case 3: return TShapePointer().ToCString();
case 4: return ToName(aShape.Orientation());
case 5: return locationInfo(aShape.Location());
case 6: return ToString (aShape.Checked());
case 7: return ToString (aShape.Closed());
case 8: return ToString (aShape.Infinite());
case 9: return ToString (aShape.Locked());
case 10: return ToString (aShape.Modified());
case 11: return ToString (aShape.Orientable());
case 12:
{
if (aShape.ShapeType() != TopAbs_VERTEX)
return QVariant();
TopoDS_Vertex aVertex = TopoDS::Vertex (aShape);
gp_Pnt aPoint = BRep_Tool::Pnt (aVertex);
return ToString (aPoint);
}
case 13:
case 14:
case 15:
case 16:
case 17:
case 18:
case 19:
{
if (aShape.ShapeType() != TopAbs_EDGE)
return QVariant();
TopoDS_Edge anEdge = TopoDS::Edge(aShape);
double aFirst, aLast;
Handle(Geom_Curve) aCurve = BRep_Tool::Curve(anEdge, aFirst, aLast);
GeomAdaptor_Curve aAdaptor(aCurve, aFirst, aLast);
gp_Pnt aFirstPnt = aAdaptor.Value(aFirst);
gp_Pnt aLastPnt = aAdaptor.Value(aLast);
BRepAdaptor_Curve aBRepAdaptor = BRepAdaptor_Curve(anEdge);
Adaptor3d_Curve* anAdaptor3d = &aBRepAdaptor;
switch (Column())
{
case 13: return QString::number (GCPnts_AbscissaPoint::Length(*anAdaptor3d));
case 14: return aCurve->DynamicType()->Name();
case 15: return ToString (aFirstPnt);
case 16: return ToString (aLastPnt);
case 17: return ToName (aCurve->Continuity());
case 18: return ToString (aCurve->IsClosed());
case 19: return aCurve->IsPeriodic() ? QString::number (aCurve->Period()) : ToString (aCurve->IsPeriodic());
}
}
case 0: return TopAbs::ShapeTypeToString (aShape.ShapeType());
default: break;
}
return QVariant();
@@ -282,11 +97,33 @@ int ShapeView_ItemShape::initRowCount() const
return 0;
int aRowsCount = 0;
for (TopoDS_Iterator aSubShapeIt(aShape); aSubShapeIt.More(); aSubShapeIt.Next())
aRowsCount++;
if (myExplodeType != TopAbs_SHAPE)
{
TopTools_IndexedMapOfShape aSubShapes;
TopExp::MapShapes(aShape, myExplodeType, aSubShapes);
aRowsCount = aSubShapes.Extent();
}
else
{
for (TopoDS_Iterator aSubShapeIt(aShape); aSubShapeIt.More(); aSubShapeIt.Next())
aRowsCount++;
}
return aRowsCount;
}
// =======================================================================
// function : initStream
// purpose :
// =======================================================================
void ShapeView_ItemShape::initStream (Standard_OStream& theOStream) const
{
TopoDS_Shape aShape = getShape();
if (aShape.IsNull())
return;
aShape.DumpJson (theOStream);
}
// =======================================================================
// function : createChild
// purpose :
@@ -304,7 +141,9 @@ void ShapeView_ItemShape::Init()
{
ShapeView_ItemRootPtr aRootItem = itemDynamicCast<ShapeView_ItemRoot> (Parent());
ShapeView_ItemShapePtr aShapeItem = itemDynamicCast<ShapeView_ItemShape> (Parent());
myShape = aRootItem ? aRootItem->GetShape (Row()) : aShapeItem->GetShape (Row());
myShape = aRootItem ? aRootItem->Shape (Row()) : aShapeItem->Shape (Row());
TreeModel_ItemBase::Init();
}
// =======================================================================
@@ -317,30 +156,6 @@ TopoDS_Shape ShapeView_ItemShape::getShape() const
return myShape;
}
// =======================================================================
// function : getPointerInfo
// purpose :
// =======================================================================
TCollection_AsciiString ShapeView_ItemShape::getPointerInfo (const Handle(Standard_Transient)& thePointer, const bool isShortInfo)
{
std::ostringstream aPtrStr;
aPtrStr << thePointer.operator->();
if (!isShortInfo)
return aPtrStr.str().c_str();
TCollection_AsciiString anInfoPtr (aPtrStr.str().c_str());
for (int aSymbolId = 1; aSymbolId < anInfoPtr.Length(); aSymbolId++)
{
if (anInfoPtr.Value(aSymbolId) != '0')
{
anInfoPtr = anInfoPtr.SubString(aSymbolId, anInfoPtr.Length());
anInfoPtr.Prepend("0x");
return anInfoPtr;
}
}
return aPtrStr.str().c_str();
}
// =======================================================================
// function : Reset
// purpose :
@@ -348,8 +163,10 @@ TCollection_AsciiString ShapeView_ItemShape::getPointerInfo (const Handle(Standa
void ShapeView_ItemShape::Reset()
{
myFileName = QString();
myChildShapes.Clear();
myShape = TopoDS_Shape();
ShapeView_ItemBase::Reset();
TreeModel_ItemBase::Reset();
}
// =======================================================================
@@ -362,4 +179,3 @@ void ShapeView_ItemShape::initItem() const
return;
const_cast<ShapeView_ItemShape*>(this)->Init();
}