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

0029674: Improvements in Inspector tool

- preferences for dock windows geometry, tree view columns and current view projection;
- ViewControl package for common functionality between plugins;
- processing Location and Orientation for external TopoDS_Shape object
- 'F5' key to update content of each plugin
- visibility column in tree view (used now only in ShapeView)
- properties child item for context (presents tree of current Filters of context)
This commit is contained in:
nds
2018-03-23 16:08:11 +03:00
committed by bugmaster
parent 6dfdbb7ab8
commit 6822a3bef1
135 changed files with 4187 additions and 1603 deletions

View File

@@ -8,6 +8,8 @@ VInspector_ItemBase.cxx
VInspector_ItemBase.hxx
VInspector_ItemContext.cxx
VInspector_ItemContext.hxx
VInspector_ItemFolderObject.cxx
VInspector_ItemFolderObject.hxx
VInspector_ItemEntityOwner.cxx
VInspector_ItemEntityOwner.hxx
VInspector_ItemHistoryElement.cxx
@@ -21,6 +23,8 @@ VInspector_ItemPresentableObject.cxx
VInspector_ItemPresentableObject.hxx
VInspector_ItemSelection.cxx
VInspector_ItemSelection.hxx
VInspector_ItemSelectMgrFilter.cxx
VInspector_ItemSelectMgrFilter.hxx
VInspector_ItemSensitiveEntity.cxx
VInspector_ItemSensitiveEntity.hxx
VInspector_SelectionType.hxx

View File

@@ -1,5 +1,7 @@
<!DOCTYPE RCC><RCC version="1.0">
<qresource>
<file>icons/treeview_and.png</file>
<file>icons/treeview_or.png</file>
<file>icons/treeview_update.png</file>
</qresource>
</RCC>

View File

@@ -44,6 +44,20 @@ public:
virtual void SetParameters (const Handle(TInspectorAPI_PluginParameters)& theParameters) Standard_OVERRIDE
{ myWindow->SetParameters (theParameters); }
//! Provide container for actions available in inspector on general level
//! \param theMenu if Qt implementation, it is QMenu object
Standard_EXPORT virtual void FillActionsMenu(void* theMenu) Standard_OVERRIDE { myWindow->FillActionsMenu (theMenu); }
//! Returns plugin preferences, empty implementation by default
//! \param theItem container of preference elements
virtual void GetPreferences (TInspectorAPI_PreferencesDataMap& theItem) Standard_OVERRIDE
{ myWindow->GetPreferences (theItem); }
//! Stores plugin preferences, empty implementation by default
//! \param theItem container of preference elements
virtual void SetPreferences (const TInspectorAPI_PreferencesDataMap& theItem) Standard_OVERRIDE
{ myWindow->SetPreferences (theItem); }
//! Calls update of the plugin's content
virtual void UpdateContent() Standard_OVERRIDE { myWindow->UpdateContent(); }

View File

@@ -21,15 +21,15 @@
// function : GetContext
// purpose :
// =======================================================================
const Handle(AIS_InteractiveContext)& VInspector_ItemBase::GetContext() const
Handle(AIS_InteractiveContext) VInspector_ItemBase::GetContext() const
{
if (!myContext.IsNull())
return myContext;
Handle(AIS_InteractiveContext) aContext;
if (const VInspector_ItemContext* aThisContextItem = dynamic_cast<const VInspector_ItemContext*> (this))
if (dynamic_cast<const VInspector_ItemContext*> (this))
{
aContext = aThisContextItem->GetContext();
return Handle(AIS_InteractiveContext)(); // context has not be set yet
}
else
{

View File

@@ -41,12 +41,12 @@ public:
//! Returns the current contex. It iterates up by list of parents to found context item and return context
//! \return a context
Standard_EXPORT const Handle(AIS_InteractiveContext)& GetContext() const;
Standard_EXPORT Handle(AIS_InteractiveContext) GetContext() const;
protected:
//! Initialize the current item. It creates a backup of the specific item information
virtual void initItem() const {};// = 0;
virtual void initItem() const {}
protected:

View File

@@ -17,9 +17,14 @@
#include <AIS_ListOfInteractive.hxx>
#include <SelectMgr_EntityOwner.hxx>
#include <inspector/VInspector_ItemFolderObject.hxx>
#include <inspector/VInspector_ItemPresentableObject.hxx>
#include <inspector/VInspector_Tools.hxx>
#include <Standard_WarningsDisable.hxx>
#include <QStringList>
#include <Standard_WarningsRestore.hxx>
//#define DEBUG_FREE_OWNERS
// =======================================================================
@@ -31,53 +36,48 @@ int VInspector_ItemContext::initRowCount() const
if (Column() != 0)
return 0;
int aNbProperties = 1; // item to visualize Filters/Drawer information of context
int aNbPresentations = 0;
if (!GetContext().IsNull())
{
AIS_ListOfInteractive aListOfIO;
GetContext()->DisplayedObjects (aListOfIO);
GetContext()->ErasedObjects(aListOfIO);
aNbPresentations = aListOfIO.Extent();
}
Handle(AIS_InteractiveContext) aContext = GetContext();
if (aContext.IsNull())
return 0;
AIS_ListOfInteractive aListOfIO;
aContext->DisplayedObjects (aListOfIO);
aContext->ErasedObjects(aListOfIO);
aNbPresentations = aListOfIO.Extent();
// owners without Presentation
#ifdef DEBUG_FREE_OWNERS
int aRows = 0;
// only local context is processed: TODO for global context
Handle(AIS_InteractiveContext) aContext = GetContext();
if (!aContext.IsNull()) {
NCollection_List<Handle(SelectBasics_EntityOwner)> anActiveOwners;
aContext->MainSelector()->ActiveOwners(anActiveOwners);
NCollection_List<Handle(SelectBasics_EntityOwner)> anActiveOwners;
aContext->MainSelector()->ActiveOwners(anActiveOwners);
Handle(SelectMgr_EntityOwner) anOwner;
for (NCollection_List<Handle(SelectBasics_EntityOwner)>::Iterator anOwnersIt(anActiveOwners);
anOwnersIt.More(); anOwnersIt.Next())
{
anOwner = Handle(SelectMgr_EntityOwner)::DownCast(anOwnersIt.Value());
if (anOwner.IsNull())
continue;
Handle(AIS_InteractiveObject) anAISObj = Handle(AIS_InteractiveObject)::DownCast(anOwner->Selectable());
if (anAISObj.IsNull())
aRows++;
}
}
// owners in Global Context
if (!aContext.IsNull())
Handle(SelectMgr_EntityOwner) anOwner;
for (NCollection_List<Handle(SelectBasics_EntityOwner)>::Iterator anOwnersIt(anActiveOwners);
anOwnersIt.More(); anOwnersIt.Next())
{
NCollection_List<Handle(SelectBasics_EntityOwner)> anActiveOwners;
aContext->MainSelector()->ActiveOwners(anActiveOwners);
anOwner = Handle(SelectMgr_EntityOwner)::DownCast(anOwnersIt.Value());
if (anOwner.IsNull())
continue;
Handle(AIS_InteractiveObject) anAISObj = Handle(AIS_InteractiveObject)::DownCast(anOwner->Selectable());
if (anAISObj.IsNull())
aRows++;
}
// owners in Global Context
NCollection_List<Handle(SelectBasics_EntityOwner)> anActiveOwners;
aContext->MainSelector()->ActiveOwners(anActiveOwners);
if (aRows > 0)
aNbPresentations += aRows;
#endif
#ifdef DEBUG_FREE_OWNERS
NCollection_List<Handle(SelectBasics_EntityOwner)> anEmptySelectableOwners;
NCollection_List<Handle(SelectBasics_EntityOwner)> anOwners =
VInspector_Tools::ActiveOwners (GetContext(), anEmptySelectableOwners);
VInspector_Tools::ActiveOwners (aContext, anEmptySelectableOwners);
if (anEmptySelectableOwners.Size() > 0)
aNbPresentations += 1;
#endif
return aNbPresentations;
return aNbProperties + aNbPresentations;
}
// =======================================================================
@@ -89,42 +89,20 @@ QVariant VInspector_ItemContext::initValue (const int theItemRole) const
if (theItemRole != Qt::DisplayRole && theItemRole != Qt::EditRole && theItemRole != Qt::ToolTipRole)
return QVariant();
if (GetContext().IsNull())
return Column() == 0 ? "Empty context" : "";
switch (Column())
{
case 0: return GetContext()->DynamicType()->Name();
case 1: return rowCount();
case 4:
{
if (theItemRole == Qt::ToolTipRole)
return "Selected Owners";
else
{
Handle(AIS_InteractiveObject) anEmptyIO;
int aSelectedCount = VInspector_Tools::SelectedOwners (GetContext(), anEmptyIO, false);
return aSelectedCount > 0 ? QString::number (aSelectedCount) : "";
}
}
case 7:
{
if (theItemRole == Qt::ToolTipRole)
return QString ("All Owners/Active Owners");
else
{
NCollection_List<Handle(SelectBasics_EntityOwner)> anEmptySelectableOwners;
NCollection_List<Handle(SelectBasics_EntityOwner)> anOwners =
VInspector_Tools::ActiveOwners (GetContext(), anEmptySelectableOwners);
int anActiveOwners = anOwners.Size();
anOwners = VInspector_Tools::ContextOwners (GetContext());
return QString ("%1 / %2").arg (anOwners.Size()).arg (anActiveOwners);
}
}
case 8:
{
if (theItemRole == Qt::ToolTipRole)
return QString ("DeviationCoefficient");
else
return GetContext()->DeviationCoefficient();
Handle(AIS_InteractiveObject) anEmptyIO;
int aSelectedCount = VInspector_Tools::SelectedOwners (GetContext(), anEmptyIO, false);
return aSelectedCount > 0 ? QString::number (aSelectedCount) : "";
}
case 6: return GetContext()->DeviationCoefficient();
default:
break;
}
@@ -137,5 +115,8 @@ QVariant VInspector_ItemContext::initValue (const int theItemRole) const
// =======================================================================
TreeModel_ItemBasePtr VInspector_ItemContext::createChild (int theRow, int theColumn)
{
return VInspector_ItemPresentableObject::CreateItem (currentItem(), theRow, theColumn);
if (theRow == 0)
return VInspector_ItemFolderObject::CreateItem (currentItem(), theRow, theColumn);
else
return VInspector_ItemPresentableObject::CreateItem (currentItem(), theRow, theColumn);
}

View File

@@ -24,6 +24,9 @@ typedef QExplicitlySharedDataPointer<VInspector_ItemContext> VInspector_ItemCont
//! \class VInspector_ItemContext
//! 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_ItemContext : public VInspector_ItemBase
{
public:

View File

@@ -47,58 +47,34 @@ QVariant VInspector_ItemEntityOwner::initValue(int theItemRole) const
switch (Column())
{
case 0: return anOwner->DynamicType()->Name();
case 2: return theItemRole == Qt::ToolTipRole ? "Owner pointer"
: VInspector_Tools::GetPointerInfo (anOwner, true).ToCString();
case 2: return VInspector_Tools::GetPointerInfo (anOwner, true).ToCString();
case 3:
{
if (theItemRole == Qt::ToolTipRole)
return "Owner Shape type";
else
{
Handle(StdSelect_BRepOwner) BROwnr = Handle(StdSelect_BRepOwner)::DownCast (anOwner);
if (!BROwnr.IsNull())
{
const TopoDS_Shape& aShape = BROwnr->Shape();
if (!aShape.IsNull())
return VInspector_Tools::GetShapeTypeInfo (aShape.ShapeType()).ToCString();
}
}
break;
Handle(StdSelect_BRepOwner) BROwnr = Handle(StdSelect_BRepOwner)::DownCast (anOwner);
if (BROwnr.IsNull())
return QVariant();
const TopoDS_Shape& aShape = BROwnr->Shape();
if (aShape.IsNull())
return QVariant();
return VInspector_Tools::GetShapeTypeInfo (aShape.ShapeType()).ToCString();
}
case 5:
{
if (theItemRole == Qt::ToolTipRole)
return "TShape pointer";
else
case 17:
case 18:
case 19:
{
Handle(StdSelect_BRepOwner) BROwnr = Handle(StdSelect_BRepOwner)::DownCast (anOwner);
if (!BROwnr.IsNull())
{
const TopoDS_Shape& aShape = BROwnr->Shape();
if (!aShape.IsNull())
return VInspector_Tools::GetPointerInfo (aShape.TShape(), true).ToCString();
}
}
break;
}
case 8:
{
if (theItemRole == Qt::ToolTipRole)
return "Shape Location : Shape Orientation";
else
{
Handle(StdSelect_BRepOwner) aBROwnr = Handle(StdSelect_BRepOwner)::DownCast (anOwner);
if (!aBROwnr.IsNull())
{
const TopoDS_Shape& aShape = aBROwnr->Shape();
if (!aShape.IsNull())
return QString ("%1 : %2")
.arg (VInspector_Tools::LocationToName(aShape.Location()).ToCString())
.arg (VInspector_Tools::OrientationToName(aShape.Orientation()).ToCString());
return VInspector_Tools::GetShapeTypeInfo (aShape.ShapeType()).ToCString();
}
}
break;
Handle(StdSelect_BRepOwner) BROwnr = Handle(StdSelect_BRepOwner)::DownCast (anOwner);
if (BROwnr.IsNull())
return QVariant();
const TopoDS_Shape& aShape = BROwnr->Shape();
if (aShape.IsNull())
return QVariant();
return Column() == 17 ? VInspector_Tools::GetPointerInfo (aShape.TShape(), true).ToCString()
: Column() == 18 ? VInspector_Tools::OrientationToName (aShape.Orientation()).ToCString()
: /*19*/ VInspector_Tools::LocationToName (aShape.Location()).ToCString();
}
default: break;
}
@@ -148,12 +124,21 @@ void VInspector_ItemEntityOwner::Init()
int aRowId = Row();
int aCurrentIndex = 0;
#if OCC_VERSION_HEX < 0x070201
for (anIO->Init(); anIO->More() && anOwner.IsNull(); anIO->Next())
{
const Handle(SelectMgr_Selection)& aSelection = anIO->CurrentSelection();
for (aSelection->Init(); aSelection->More() && anOwner.IsNull(); aSelection->Next())
{
Handle(SelectMgr_SensitiveEntity) anEntity = aSelection->Sensitive();
#else
for (SelectMgr_SequenceOfSelection::Iterator aSelIter (anIO->Selections()); aSelIter.More() && anOwner.IsNull(); aSelIter.Next())
{
const Handle(SelectMgr_Selection)& aSelection = aSelIter.Value();
for (NCollection_Vector<Handle(SelectMgr_SensitiveEntity)>::Iterator aSelEntIter (aSelection->Entities()); aSelEntIter.More() && anOwner.IsNull(); aSelEntIter.Next())
{
Handle(SelectMgr_SensitiveEntity) anEntity = aSelEntIter.Value();
#endif
const Handle(SelectBasics_SensitiveEntity)& aBase = anEntity->BaseSensitive();
if (!aBase.IsNull())
{

View File

@@ -0,0 +1,93 @@
// 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_ItemFolderObject.hxx>
#include <inspector/VInspector_ItemContext.hxx>
#include <inspector/VInspector_ItemSelectMgrFilter.hxx>
// =======================================================================
// function : initValue
// purpose :
// =======================================================================
QVariant VInspector_ItemFolderObject::initValue (int theItemRole) const
{
if (Column() == 0 && (theItemRole == Qt::DisplayRole || theItemRole == Qt::ToolTipRole))
{
if (parentItemIsContext()) return "Properties";
else if (Row() == 0) return "Filters";
else return QVariant();
}
return QVariant();
}
// =======================================================================
// function : initRowCount
// purpose :
// =======================================================================
int VInspector_ItemFolderObject::initRowCount() const
{
return parentItemIsContext() ? 1 : (GetContext().IsNull() ? 0 : GetContext()->Filters().Extent());
}
// =======================================================================
// function : createChild
// purpose :
// =======================================================================
TreeModel_ItemBasePtr VInspector_ItemFolderObject::createChild (int theRow, int theColumn)
{
if (parentItemIsContext())
return VInspector_ItemFolderObject::CreateItem (currentItem(), theRow, theColumn);
else
return VInspector_ItemSelectMgrFilter::CreateItem (currentItem(), theRow, theColumn);
}
// =======================================================================
// function : Init
// purpose :
// =======================================================================
void VInspector_ItemFolderObject::Init()
{
TreeModel_ItemBase::Init(); // to use getIO() without circling initialization
}
// =======================================================================
// function : Reset
// purpose :
// =======================================================================
void VInspector_ItemFolderObject::Reset()
{
VInspector_ItemBase::Reset();
}
// =======================================================================
// function : initItem
// purpose :
// =======================================================================
void VInspector_ItemFolderObject::initItem() const
{
if (IsInitialized())
return;
const_cast<VInspector_ItemFolderObject*> (this)->Init();
}
// =======================================================================
// function : parentItemIsContext
// purpose :
// =======================================================================
bool VInspector_ItemFolderObject::parentItemIsContext() const
{
return itemDynamicCast<VInspector_ItemContext> (Parent());
}

View File

@@ -0,0 +1,86 @@
// 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_ItemFolderObject_H
#define VInspector_ItemFolderObject_H
#include <Standard.hxx>
#include <inspector/VInspector_ItemBase.hxx>
#include <AIS_InteractiveObject.hxx>
#include <NCollection_List.hxx>
#include <TCollection_AsciiString.hxx>
class QItemSelectionModel;
class VInspector_ItemFolderObject;
typedef QExplicitlySharedDataPointer<VInspector_ItemFolderObject> VInspector_ItemFolderObjectPtr;
//! \class VInspector_ItemFolderObject
//! 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_ItemFolderObject : public VInspector_ItemBase
{
public:
//! Creates an item wrapped by a shared pointer
static VInspector_ItemFolderObjectPtr CreateItem (TreeModel_ItemBasePtr theParent,
const int theRow, const int theColumn)
{ return VInspector_ItemFolderObjectPtr (new VInspector_ItemFolderObject (theParent, theRow, theColumn)); }
//! Destructor
virtual ~VInspector_ItemFolderObject() 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;
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:
//! Returns whether the parent item is context item
//! \returns bolean value
bool parentItemIsContext() const;
private:
//! Constructor
//! param theParent a parent item
VInspector_ItemFolderObject (TreeModel_ItemBasePtr theParent, const int theRow, const int theColumn)
: VInspector_ItemBase (theParent, theRow, theColumn) {}
};
#endif

View File

@@ -32,7 +32,7 @@ struct VInspector_ItemHistoryTypeInfo
//! Append new element
//! \param theInfo an information element
void AddElement (const QList<QVariant>& theInfo) { myElements.append(theInfo); }
void AddElement (const QList<QVariant>& theInfo) { myElements.append (theInfo); }
VInspector_CallBackMode myMode; //!< history element mode
QList<QList<QVariant>> myElements; //!< container of elements information

View File

@@ -42,6 +42,16 @@
// =======================================================================
QVariant VInspector_ItemPresentableObject::initValue (int theItemRole) const
{
if (Column() == 20 && theItemRole == Qt::BackgroundRole) {
Handle(AIS_InteractiveObject) anIO = GetInteractiveObject();
if (!anIO.IsNull() && anIO->HasColor())
{
Quantity_Color aColor;
anIO->Color(aColor);
return QColor ((int)(aColor.Red()*255.), (int)(aColor.Green()*255.), (int)(aColor.Blue()*255.));
}
}
if (theItemRole == Qt::DisplayRole || theItemRole == Qt::ToolTipRole)
{
Handle(AIS_InteractiveObject) anIO = GetInteractiveObject();
@@ -78,46 +88,74 @@ QVariant VInspector_ItemPresentableObject::initValue (int theItemRole) const
}
case 4:
{
if (theItemRole == Qt::ToolTipRole)
return "SelectedOwners";
else
int aNbSelected = VInspector_Tools::SelectedOwners (GetContext(), anIO, false);
return aNbSelected > 0 ? QString::number (aNbSelected) : "";
}
case 5:
{
TColStd_ListOfInteger aModes;
Handle(AIS_InteractiveContext) aContext = GetContext();
aContext->ActivatedModes(anIO, aModes);
TCollection_AsciiString aModesInfo;
for (TColStd_ListIteratorOfListOfInteger itr (aModes); itr.More(); itr.Next())
{
Handle(AIS_InteractiveContext) aContext = GetContext();
int aCount = VInspector_Tools::SelectedOwners (aContext, anIO, false);
if (aCount > 0)
return aCount;
if (!aModesInfo.IsEmpty())
aModesInfo += ", ";
aModesInfo += VInspector_Tools::GetShapeTypeInfo (AIS_Shape::SelectionType(itr.Value()));
}
break;
return aModesInfo.ToCString();
}
break;
case 6:
{
double aDeviationCoefficient = 0;
Handle(AIS_Shape) anAISShape = Handle(AIS_Shape)::DownCast (anIO);
if (!anAISShape.IsNull())
{
Standard_Real aPreviousCoefficient;
anAISShape->OwnDeviationCoefficient(aDeviationCoefficient, aPreviousCoefficient);
}
return QString::number(aDeviationCoefficient);
}
case 7:
{
double aShapeDeflection = 0;
Handle(AIS_Shape) aShapeIO = Handle(AIS_Shape)::DownCast (anIO);
if (!aShapeIO.IsNull())
{
const TopoDS_Shape& aShape = aShapeIO->Shape();
if (!aShape.IsNull())
aShapeDeflection = Prs3d::GetDeflection(aShape, anIO->Attributes());
}
return QString::number (aShapeDeflection);
}
case 8:
{
if (theItemRole == Qt::ToolTipRole)
return QString ("%1 / %2 / %3").arg ("OwnDeviationCoefficient")
.arg ("ShapeDeflection")
.arg ("IsAutoTriangulation");
else
double aDeviationCoefficient = 0;
Handle(AIS_Shape) anAISShape = Handle(AIS_Shape)::DownCast (anIO);
if (!anAISShape.IsNull())
{
double aDeviationCoefficient = 0;
Handle(AIS_Shape) anAISShape = Handle(AIS_Shape)::DownCast (anIO);
if (!anAISShape.IsNull())
{
Standard_Real aPreviousCoefficient;
anAISShape->OwnDeviationCoefficient(aDeviationCoefficient, aPreviousCoefficient);
}
double aShapeDeflection = 0;
Handle(AIS_Shape) aShapeIO = Handle(AIS_Shape)::DownCast (anIO);
if (!aShapeIO.IsNull())
{
const TopoDS_Shape& aShape = aShapeIO->Shape();
if (!aShape.IsNull())
aShapeDeflection = Prs3d::GetDeflection(aShape, anIO->Attributes());
}
bool anIsAutoTriangulation = anIO->Attributes()->IsAutoTriangulation();
return QString ("%1 / %2 / %3").arg (aDeviationCoefficient)
.arg (aShapeDeflection)
.arg (anIsAutoTriangulation);
Standard_Real aPreviousCoefficient;
anAISShape->OwnDeviationCoefficient(aDeviationCoefficient, aPreviousCoefficient);
}
break;
Handle(AIS_Shape) aShapeIO = Handle(AIS_Shape)::DownCast (anIO);
bool anIsAutoTriangulation = aNullIO ? false : anIO->Attributes()->IsAutoTriangulation();
return anIsAutoTriangulation ? QString ("true") : QString ("false");
}
case 17:
case 18:
case 19:
{
Handle(AIS_Shape) aShapeIO = Handle(AIS_Shape)::DownCast (anIO);
if (aShapeIO.IsNull())
return QVariant();
const TopoDS_Shape& aShape = aShapeIO->Shape();
if (aShape.IsNull())
return QVariant();
return Column() == 17 ? VInspector_Tools::GetPointerInfo (aShape.TShape(), true).ToCString()
: Column() == 18 ? VInspector_Tools::OrientationToName (aShape.Orientation()).ToCString()
: /*19*/ VInspector_Tools::LocationToName (aShape.Location()).ToCString();
}
default: break;
}
@@ -155,9 +193,19 @@ QVariant VInspector_ItemPresentableObject::initValue (int theItemRole) const
int VInspector_ItemPresentableObject::initRowCount() const
{
Handle(AIS_InteractiveObject) anIO = GetInteractiveObject();
#if OCC_VERSION_HEX < 0x070201
int aRows = 0;
if (anIO.IsNull())
return aRows;
// iteration through sensitive privitives
for (anIO->Init(); anIO->More(); anIO->Next())
aRows++;
return aRows;
#else
return !anIO.IsNull()
? anIO->Selections().Size()
: 0;
#endif
}
// =======================================================================
@@ -186,10 +234,11 @@ void VInspector_ItemPresentableObject::Init()
AIS_ListOfInteractive aListOfIO;
GetContext()->DisplayedObjects (aListOfIO); // the presentation is in displayed objects of Context
GetContext()->ErasedObjects (aListOfIO); // the presentation is in erased objects of Context
int aDeltaIndex = 1; // properties item
int aCurrentIndex = 0;
for (AIS_ListIteratorOfListOfInteractive anIOIt (aListOfIO); anIOIt.More(); anIOIt.Next(), aCurrentIndex++)
{
if (aCurrentIndex != aRowId)
if (aCurrentIndex != aRowId - aDeltaIndex)
continue;
anIO = anIOIt.Value();
break;

View File

@@ -0,0 +1,138 @@
// 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_ItemSelectMgrFilter.hxx>
#include <inspector/VInspector_ItemFolderObject.hxx>
#include <inspector/VInspector_Tools.hxx>
#include <SelectMgr_AndFilter.hxx>
#include <SelectMgr_OrFilter.hxx>
#include <Standard_WarningsDisable.hxx>
#include <QIcon>
#include <Standard_WarningsRestore.hxx>
// =======================================================================
// function : initValue
// purpose :
// =======================================================================
QVariant VInspector_ItemSelectMgrFilter::initValue (int theItemRole) const
{
if (theItemRole == Qt::DisplayRole || theItemRole == Qt::ToolTipRole)
{
Handle(SelectMgr_Filter) aFilter = GetFilter();
switch (Column())
{
case 0: return theItemRole == Qt::ToolTipRole ? QVariant ("")
: QVariant (aFilter->DynamicType()->Name());
case 1: return rowCount() > 0 ? QVariant (rowCount()) : QVariant();
case 2: return VInspector_Tools::GetPointerInfo (aFilter, true).ToCString();
default: break;
}
}
if (Column() == 0 && theItemRole == Qt::DecorationRole)
{
Handle(SelectMgr_Filter) aFilter = GetFilter();
if (aFilter->IsKind (STANDARD_TYPE (SelectMgr_AndFilter))) return QIcon (":/icons/treeview_and.png");
if (aFilter->IsKind (STANDARD_TYPE (SelectMgr_OrFilter))) return QIcon (":/icons/treeview_or.png");
}
return QVariant();
}
// =======================================================================
// function : initRowCount
// purpose :
// =======================================================================
int VInspector_ItemSelectMgrFilter::initRowCount() const
{
Handle(SelectMgr_Filter) aFilter = GetFilter();
if (aFilter->IsKind (STANDARD_TYPE (SelectMgr_CompositionFilter)))
{
Handle(SelectMgr_CompositionFilter) aCompositionFilter = Handle(SelectMgr_CompositionFilter)::DownCast (aFilter);
return aCompositionFilter->StoredFilters().Size();
}
return 0;
}
// =======================================================================
// function : createChild
// purpose :
// =======================================================================
TreeModel_ItemBasePtr VInspector_ItemSelectMgrFilter::createChild (int theRow, int theColumn)
{
return VInspector_ItemSelectMgrFilter::CreateItem(currentItem(), theRow, theColumn);
}
// =======================================================================
// function : Init
// purpose :
// =======================================================================
void VInspector_ItemSelectMgrFilter::Init()
{
Handle(AIS_InteractiveContext) aContext = GetContext();
Handle(SelectMgr_Filter) aFilter;
Handle(SelectMgr_CompositionFilter) aParentCompositeFilter;
VInspector_ItemSelectMgrFilterPtr aParentSelectMgrItem = itemDynamicCast<VInspector_ItemSelectMgrFilter> (Parent());
if (aParentSelectMgrItem)
aParentCompositeFilter = Handle(SelectMgr_CompositionFilter)::DownCast (aParentSelectMgrItem->GetFilter());
int aRowId = Row();
const SelectMgr_ListOfFilter& aFilters = !aParentCompositeFilter.IsNull() ? aParentCompositeFilter->StoredFilters()
: aContext->Filters();
int aCurrentIndex = 0;
for (SelectMgr_ListOfFilter::Iterator aFiltersIt (aFilters); aFiltersIt.More(); aFiltersIt.Next(), aCurrentIndex++)
{
if (aCurrentIndex != aRowId)
continue;
aFilter = aFiltersIt.Value();
break;
}
setFilter (aFilter);
TreeModel_ItemBase::Init(); // to use getFilter() without circling initialization
}
// =======================================================================
// function : Reset
// purpose :
// =======================================================================
void VInspector_ItemSelectMgrFilter::Reset()
{
VInspector_ItemBase::Reset();
setFilter (NULL);
}
// =======================================================================
// function : initItem
// purpose :
// =======================================================================
void VInspector_ItemSelectMgrFilter::initItem() const
{
if (IsInitialized())
return;
const_cast<VInspector_ItemSelectMgrFilter*>(this)->Init();
}
// =======================================================================
// function : GetInteractiveObject
// purpose :
// =======================================================================
Handle(SelectMgr_Filter) VInspector_ItemSelectMgrFilter::GetFilter() const
{
initItem();
return myFilter;
}

View File

@@ -0,0 +1,91 @@
// 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_ItemSelectMgrFilter_H
#define VInspector_ItemSelectMgrFilter_H
#include <Standard.hxx>
#include <inspector/VInspector_ItemBase.hxx>
#include <SelectMgr_Filter.hxx>
class QItemSelectionModel;
class VInspector_ItemSelectMgrFilter;
typedef QExplicitlySharedDataPointer<VInspector_ItemSelectMgrFilter> VInspector_ItemSelectMgrFilterPtr;
//! \class VInspector_ItemSelectMgrFilter
//! Item presents information about SelectMgr_Filter.
//! Parent is item folder, children are sub filter if the filter is a composition filter.
class VInspector_ItemSelectMgrFilter : public VInspector_ItemBase
{
public:
//! Creates an item wrapped by a shared pointer
static VInspector_ItemSelectMgrFilterPtr CreateItem (TreeModel_ItemBasePtr theParent, const int theRow, const int theColumn)
{ return VInspector_ItemSelectMgrFilterPtr (new VInspector_ItemSelectMgrFilter (theParent, theRow, theColumn)); }
//! Destructor
virtual ~VInspector_ItemSelectMgrFilter() Standard_OVERRIDE {};
//! Returns the current filter, init item if it was not initialized yet
//! \return filter object
Standard_EXPORT Handle(SelectMgr_Filter) GetFilter() const;
//! 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:
//! Set filter into the current item
//! \param theFilter a filter
void setFilter (Handle(SelectMgr_Filter) theFilter) { myFilter = theFilter; }
private:
//! Constructor
//! param theParent a parent item
VInspector_ItemSelectMgrFilter (TreeModel_ItemBasePtr theParent, const int theRow, const int theColumn)
: VInspector_ItemBase (theParent, theRow, theColumn) {}
protected:
Handle(SelectMgr_Filter) myFilter; //!< the current filter
};
#endif

View File

@@ -19,14 +19,16 @@
#include <SelectMgr_EntityOwner.hxx>
#include <SelectMgr_Selection.hxx>
#include <SelectMgr_SensitiveEntity.hxx>
#include <Standard_Version.hxx>
#include <inspector/VInspector_ItemContext.hxx>
#include <inspector/VInspector_ItemPresentableObject.hxx>
#include <inspector/VInspector_ItemSensitiveEntity.hxx>
#include <inspector/VInspector_Tools.hxx>
#include <Standard_WarningsDisable.hxx>
#include <QColor>
#include <QStringList>
#include <QColor>
#include <Standard_WarningsRestore.hxx>
// =======================================================================
@@ -46,7 +48,14 @@ Handle(SelectMgr_Selection) VInspector_ItemSelection::getSelection() const
int VInspector_ItemSelection::initRowCount() const
{
Handle(SelectMgr_Selection) aSelection = getSelection();
#if OCC_VERSION_HEX < 0x070201
int aRows = 0;
for (aSelection->Init(); aSelection->More(); aSelection->Next())
aRows++;
return aRows;
#else
return aSelection->Entities().Size();
#endif
}
// =======================================================================
@@ -85,28 +94,34 @@ QVariant VInspector_ItemSelection::initValue (int theItemRole) const
if (aState == SelectMgr_SOS_Activated || aState == SelectMgr_SOS_Any)
{
Handle(AIS_InteractiveContext) aContext = GetContext();
#if OCC_VERSION_HEX < 0x070201
for (mySelection->Init(); mySelection->More(); mySelection->Next())
{
const Handle(SelectBasics_EntityOwner)& anOwner = mySelection->Sensitive()->BaseSensitive()->OwnerId();
#else
for (NCollection_Vector<Handle(SelectMgr_SensitiveEntity)>::Iterator aSelEntIter (mySelection->Entities()); aSelEntIter.More(); aSelEntIter.Next())
{
const Handle(SelectBasics_EntityOwner)& anOwner = aSelEntIter.Value()->BaseSensitive()->OwnerId();
#endif
if (VInspector_Tools::IsOwnerSelected(aContext, anOwner))
aNbSelected++;
}
}
QString aStateValue = VInspector_Tools::ToName (VInspector_SelectionType_StateOfSelection, aState).ToCString();
return QVariant (aNbSelected > 0 ? QString ("%1 : %2").arg (aStateValue).arg (aNbSelected) : aStateValue);
return aNbSelected > 0 ? QString::number (aNbSelected) : "";
}
}
case 6: return theItemRole == Qt::ToolTipRole ? "Sensitivity" : QString::number (getSelection()->Sensitivity());
case 8:
case 9:
{
if (theItemRole == Qt::ToolTipRole)
return QString ("%1 / %2").arg ("SelectMgr_TypeOfUpdate").arg ("SelectMgr_TypeOfBVHUpdate");
else
return QString ("%1 / %2").arg (VInspector_Tools::ToName (VInspector_SelectionType_TypeOfUpdate,
getSelection()->UpdateStatus()).ToCString())
.arg (VInspector_Tools::ToName (VInspector_SelectionType_TypeOfBVHUpdate,
getSelection()->BVHUpdateStatus()).ToCString());
SelectMgr_StateOfSelection aState = getSelection()->GetSelectionState();
return VInspector_Tools::ToName (VInspector_SelectionType_StateOfSelection, aState).ToCString();
}
case 10: return QString::number (getSelection()->Sensitivity());
case 11:
return VInspector_Tools::ToName (VInspector_SelectionType_TypeOfUpdate,
getSelection()->UpdateStatus()).ToCString();
case 12:
return VInspector_Tools::ToName (VInspector_SelectionType_TypeOfBVHUpdate,
getSelection()->BVHUpdateStatus()).ToCString();
default:
break;
}
@@ -142,11 +157,19 @@ void VInspector_ItemSelection::Init()
int aRowId = Row();
int aCurrentId = 0;
#if OCC_VERSION_HEX < 0x070201
for (anIO->Init(); anIO->More(); anIO->Next(), aCurrentId++)
#else
for (SelectMgr_SequenceOfSelection::Iterator aSelIter (anIO->Selections()); aSelIter.More(); aSelIter.Next(), aCurrentId++)
#endif
{
if (aCurrentId != aRowId)
continue;
#if OCC_VERSION_HEX < 0x070201
mySelection = anIO->CurrentSelection();
#else
mySelection = aSelIter.Value();
#endif
break;
}
TreeModel_ItemBase::Init();

View File

@@ -61,52 +61,34 @@ QVariant VInspector_ItemSensitiveEntity::initValue (int theItemRole) const
{
switch (Column())
{
case 0:
return myEntity->DynamicType()->Name();
case 2:
{
return theItemRole == Qt::ToolTipRole ? "Owner pointer" : VInspector_Tools::GetPointerInfo (
GetSensitiveEntity()->BaseSensitive()->OwnerId(), true).ToCString();
}
case 0: return myEntity->DynamicType()->Name();
case 2: return VInspector_Tools::GetPointerInfo (GetSensitiveEntity()->BaseSensitive()->OwnerId(), true).ToCString();
case 3:
{
if (theItemRole == Qt::ToolTipRole)
return "Owner Shape type";
else
{
Handle(StdSelect_BRepOwner) BROwnr = Handle(StdSelect_BRepOwner)::DownCast (anOwner);
if (!BROwnr.IsNull())
{
const TopoDS_Shape& aShape = BROwnr->Shape();
if (!aShape.IsNull())
return VInspector_Tools::GetShapeTypeInfo (aShape.ShapeType()).ToCString();
}
}
break;
Handle(StdSelect_BRepOwner) BROwnr = Handle(StdSelect_BRepOwner)::DownCast (anOwner);
if (BROwnr.IsNull())
return QVariant();
const TopoDS_Shape& aShape = BROwnr->Shape();
if (aShape.IsNull())
return QVariant();
return VInspector_Tools::GetShapeTypeInfo (aShape.ShapeType()).ToCString();
}
case 4: return theItemRole == Qt::ToolTipRole ? "IsActiveForSelection"
case 13: return
#if OCC_VERSION_HEX <= 0x060901
: ("none");
("none");
#else
: myEntity->IsActiveForSelection() ? QString ("true") : QString ("false");
myEntity->IsActiveForSelection() ? QString ("true") : QString ("false");
#endif
case 5: return theItemRole == Qt::ToolTipRole ? "SelectBasics_SensitiveEntity"
: getEntityOwner()->DynamicType()->Name();
case 6: return theItemRole == Qt::ToolTipRole ? "SensitivityFactor"
: QString::number (GetSensitiveEntity()->BaseSensitive()->SensitivityFactor());
case 7: return theItemRole == Qt::ToolTipRole ? "NbSubElements"
: QString::number (GetSensitiveEntity()->BaseSensitive()->NbSubElements());
case 8:
case 14: return QString::number (GetSensitiveEntity()->BaseSensitive()->SensitivityFactor());
case 15: return QString::number (GetSensitiveEntity()->BaseSensitive()->NbSubElements());
case 16:
{
if (theItemRole == Qt::ToolTipRole)
return "Owner priority";
else
{
Handle(StdSelect_BRepOwner) BROwnr = Handle(StdSelect_BRepOwner)::DownCast (anOwner);
if (!BROwnr.IsNull())
return anOwner->Priority();
}
break;
Handle(StdSelect_BRepOwner) BROwnr = Handle(StdSelect_BRepOwner)::DownCast (anOwner);
if (BROwnr.IsNull())
return QVariant();
return anOwner->Priority();
}
default:
break;
@@ -157,11 +139,19 @@ void VInspector_ItemSensitiveEntity::Init()
int aRowId = Row();
int aCurrentId = 0;
#if OCC_VERSION_HEX < 0x070201
for (aSelection->Init(); aSelection->More(); aSelection->Next(), aCurrentId++)
#else
for (NCollection_Vector<Handle(SelectMgr_SensitiveEntity)>::Iterator aSelEntIter (aSelection->Entities()); aSelEntIter.More(); aSelEntIter.Next(), aCurrentId++)
#endif
{
if (aCurrentId != aRowId)
continue;
#if OCC_VERSION_HEX < 0x070201
myEntity = aSelection->Sensitive();
#else
myEntity = aSelEntIter.Value();
#endif
break;
}
TreeModel_ItemBase::Init();

View File

@@ -17,6 +17,9 @@
#include <AIS_ListIteratorOfListOfInteractive.hxx>
#include <AIS_ListOfInteractive.hxx>
#if OCC_VERSION_HEX < 0x060901
#include <AIS_LocalContext.hxx>
#endif
#include <AIS_Selection.hxx>
#include <AIS_Shape.hxx>
#include <AIS_Trihedron.hxx>
@@ -143,6 +146,16 @@ NCollection_List<Handle(SelectBasics_EntityOwner)> VInspector_Tools::ContextOwne
Handle(AIS_InteractiveObject) anIO = aIt.Value();
if (anIO.IsNull())
continue;
#if OCC_VERSION_HEX < 0x070201
for (anIO->Init(); anIO->More(); anIO->Next())
{
Handle(SelectMgr_Selection) aSelection = anIO->CurrentSelection();
if (aSelection.IsNull())
continue;
for (aSelection->Init(); aSelection->More(); aSelection->Next())
{
Handle(SelectMgr_SensitiveEntity) anEntity = aSelection->Sensitive();
#else
for (SelectMgr_SequenceOfSelection::Iterator aSelIter (anIO->Selections()); aSelIter.More(); aSelIter.Next())
{
Handle(SelectMgr_Selection) aSelection = aSelIter.Value();
@@ -151,6 +164,7 @@ NCollection_List<Handle(SelectBasics_EntityOwner)> VInspector_Tools::ContextOwne
for (NCollection_Vector<Handle(SelectMgr_SensitiveEntity)>::Iterator aSelEntIter (aSelection->Entities()); aSelEntIter.More(); aSelEntIter.Next())
{
Handle(SelectMgr_SensitiveEntity) anEntity = aSelEntIter.Value();
#endif
if (anEntity.IsNull())
continue;
const Handle(SelectBasics_SensitiveEntity)& aBase = anEntity->BaseSensitive();
@@ -223,11 +237,23 @@ void VInspector_Tools::AddOrRemoveSelectedShapes (const Handle(AIS_InteractiveCo
theContext->UnhilightSelected(Standard_False);
//TODO: processing in local context only
#if OCC_VERSION_HEX < 0x060901
Handle(AIS_LocalContext) aLContext = theContext->LocalContext();
TCollection_AsciiString aSelectionName = aLContext->SelectionName();
aLContext->UnhilightPicked(Standard_False);
#endif
for (NCollection_List<Handle(SelectBasics_EntityOwner)>::Iterator anOwnersIt(theOwners);
anOwnersIt.More(); anOwnersIt.Next())
{
Handle(SelectMgr_EntityOwner) anOwner = Handle(SelectMgr_EntityOwner)::DownCast (anOwnersIt.Value());
#if OCC_VERSION_HEX > 0x060901
theContext->AddOrRemoveSelected (anOwner, Standard_False);
#else
AIS_Selection::Selection(aSelectionName.ToCString())->Select(anOwner);
anOwner->SetSelected(Standard_True);
#endif
}
theContext->UpdateCurrentViewer();
}

View File

@@ -15,6 +15,7 @@
#include <inspector/VInspector_ViewModel.hxx>
#include <inspector/TreeModel_Tools.hxx>
#include <inspector/VInspector_ItemContext.hxx>
#include <inspector/VInspector_ItemEntityOwner.hxx>
#include <inspector/VInspector_ItemPresentableObject.hxx>
@@ -26,6 +27,11 @@
#include <QStringList>
#include <Standard_WarningsRestore.hxx>
const int COLUMN_NAME_WIDTH = 260;
const int COLUMN_SIZE_WIDTH = 30;
const int COLUMN_POINTER_WIDTH = 70;
const int COLUMN_SHAPE_TYPE_WIDTH = 75;
// =======================================================================
// function : Constructor
// purpose :
@@ -33,19 +39,51 @@
VInspector_ViewModel::VInspector_ViewModel (QObject* theParent)
: TreeModel_ModelBase (theParent)
{
for (int aColumnId = 0, aNbColumns = columnCount(); aColumnId < aNbColumns; aColumnId++)
myRootItems.insert (aColumnId, VInspector_ItemContext::CreateItem (TreeModel_ItemBasePtr(), 0, aColumnId));
SetHeaderItem (0, TreeModel_HeaderSection ("Name", COLUMN_NAME_WIDTH));
SetHeaderItem (1, TreeModel_HeaderSection ("Size", COLUMN_SIZE_WIDTH));
SetHeaderItem (2, TreeModel_HeaderSection ("Pointer", COLUMN_POINTER_WIDTH));
SetHeaderItem (3, TreeModel_HeaderSection ("ShapeType", COLUMN_SHAPE_TYPE_WIDTH)); // ItemPresentableObject, ItemSelection
SetHeaderItem (4, TreeModel_HeaderSection ("SelectedOwners", -1)); // ItemContext, ItemPresentableObject, ItemSelection
SetHeaderItem (5, TreeModel_HeaderSection ("ActivatedModes", -1)); // ItemPresentableObject
SetHeaderItem (6, TreeModel_HeaderSection ("DeviationCoefficient", -1, true)); // ItemContext, ItemPresentableObject
SetHeaderItem (7, TreeModel_HeaderSection ("Deflection", -1, true)); // ItemPresentableObject
SetHeaderItem (8, TreeModel_HeaderSection ("IsAutoTriangulation", -1, true)); // ItemPresentableObject
m_pRootItem = myRootItems[0];
SetHeaderItem (9, TreeModel_HeaderSection ("SelectionState", -1)); // ItemSelection
SetHeaderItem (10, TreeModel_HeaderSection ("Sensitivity", -1, true)); // ItemSelection
SetHeaderItem (11, TreeModel_HeaderSection ("UpdateStatus", -1, true)); // ItemSelection
SetHeaderItem (12, TreeModel_HeaderSection ("BVHUpdateStatus", -1, true)); // ItemSelection
SetHeaderItem (13, TreeModel_HeaderSection ("IsActiveForSelection", -1, true)); // ItemSensitiveEntity
SetHeaderItem (14, TreeModel_HeaderSection ("SensitivityFactor", -1, true)); // ItemSensitiveEntity
SetHeaderItem (15, TreeModel_HeaderSection ("NbSubElements", -1, true)); // ItemSensitiveEntity
SetHeaderItem (16, TreeModel_HeaderSection ("Priority", -1, true)); // ItemSensitiveEntity
SetHeaderItem (17, TreeModel_HeaderSection ("TShape", COLUMN_POINTER_WIDTH, true)); // ItemEntityOwner
SetHeaderItem (18, TreeModel_HeaderSection ("Orientation", -1, true)); // ItemEntityOwner
SetHeaderItem (19, TreeModel_HeaderSection ("Location", -1, true)); // ItemEntityOwner
SetHeaderItem (20, TreeModel_HeaderSection ("Color", -1)); // ItemPresentableObject
}
// =======================================================================
// function : createRootItem
// purpose :
// =======================================================================
void VInspector_ViewModel::createRootItem (const int theColumnId)
{
myRootItems.insert (theColumnId, VInspector_ItemContext::CreateItem (TreeModel_ItemBasePtr(), 0, theColumnId));
if (theColumnId == 0)
m_pRootItem = myRootItems[0];
}
// =======================================================================
// function : GetContext
// purpose :
// =======================================================================
const Handle(AIS_InteractiveContext)& VInspector_ViewModel::GetContext() const
Handle(AIS_InteractiveContext) VInspector_ViewModel::GetContext() const
{
return itemDynamicCast<VInspector_ItemContext>(RootItem (0))->GetContext();
return itemDynamicCast<VInspector_ItemContext> (RootItem (0))->GetContext();
}
// =======================================================================
@@ -103,32 +141,6 @@ QModelIndex VInspector_ViewModel::FindIndex (const Handle(AIS_InteractiveObject)
return QModelIndex();
}
// =======================================================================
// function : headerData
// purpose :
// =======================================================================
QVariant VInspector_ViewModel::headerData (int theSection, Qt::Orientation theOrientation, int theRole) const
{
if (theOrientation != Qt::Horizontal || theRole != Qt::DisplayRole)
return QVariant();
switch (theSection)
{
case 0: return "Name";
case 1: return "Size";
case 2: return "Pointer";
case 3: return "Shape type";
case 4: return "Selection";
case 5: return "Base Sensitive";
case 6: return "Sensitivity";
case 7: return "SubElements";
case 8: return "Deviation/Deflectiton/Update/Priority";
//Auto Triangulation
default: break;
}
return QVariant();
}
// =======================================================================
// function : GetSelectedOwners
// purpose :
@@ -171,3 +183,13 @@ void VInspector_ViewModel::GetSelectedOwners (QItemSelectionModel* theSelectionM
theOwners.Append (anEntityOwner);
}
}
// =======================================================================
// function : UpdateTreeModel
// purpose :
// =======================================================================
void VInspector_ViewModel::UpdateTreeModel()
{
Reset();
EmitLayoutChanged();
}

View File

@@ -51,8 +51,8 @@ public:
//! Initialize the model by the given context
//! \param theContext viewer context
Standard_EXPORT const Handle(AIS_InteractiveContext)& GetContext() const;
Standard_EXPORT Handle(AIS_InteractiveContext) GetContext() const;
//! Initialize the model by the given context
//! \param theContext viewer context
Standard_EXPORT void SetContext (const Handle(AIS_InteractiveContext)& theContext);
@@ -70,29 +70,24 @@ public:
//! Returns root item by column
//! \param theColumn an index of the column
//! \return root item instance
Standard_EXPORT virtual TreeModel_ItemBasePtr RootItem (const int theColumn) const Standard_OVERRIDE
virtual TreeModel_ItemBasePtr RootItem (const int theColumn) const Standard_OVERRIDE
{ return myRootItems[theColumn]; }
//! Returns count of columns in the model
//! \param theParent an index of the parent item
//! \return integer value
Standard_EXPORT virtual int columnCount (const QModelIndex& theParent = QModelIndex()) const Standard_OVERRIDE
{ (void)theParent; return 9; }
//! Returns the header data for the given role and section in the header with the specified orientation.
//! \param theSection the header section. For horizontal headers - column number, for vertical headers - row number.
//! \param theOrientation a header orientation
//! \param theRole a data role
//! \return the header data
Standard_EXPORT virtual QVariant headerData (int theSection, Qt::Orientation theOrientation,
int theRole = Qt::DisplayRole ) const Standard_OVERRIDE;
//! Returns select owners for tree view selected items
//! \param theSelectionModel a selection model
//! \param theOwners an output list of owners
Standard_EXPORT static void GetSelectedOwners (QItemSelectionModel* theSelectionModel,
NCollection_List<Handle(SelectBasics_EntityOwner)>& theOwners);
//! Updates tree model
Standard_EXPORT void UpdateTreeModel();
protected:
//! Creates root item
//! \param theColumnId index of a column
virtual void createRootItem (const int theColumnId) Standard_OVERRIDE;
private:
QMap<int, TreeModel_ItemBasePtr> myRootItems; //!< container of root items, for each column own root item

View File

@@ -23,6 +23,20 @@
#include <QStringList>
#include <Standard_WarningsRestore.hxx>
const int COLUMN_NAME_WIDTH = 230;
const int COLUMN_SIZE_WIDTH = 30;
const int COLUMN_POINTER_WIDTH = 70;
const int COLUMN_SHAPE_TYPE_WIDTH = 75;
const int COLUMN_AIS_NAME_WIDTH = 75;
const int COLUMN_SELECTED_WIDTH = 75;
const int COLUMN_5_WIDTH = 120;
const int COLUMN_6_WIDTH = 65;
const int COLUMN_7_WIDTH = 70;
const int HISTORY_AIS_NAME_COLUMN_WIDTH = 140;
// =======================================================================
// function : Constructor
// purpose :
@@ -30,13 +44,30 @@
VInspector_ViewModelHistory::VInspector_ViewModelHistory (QObject* theParent, const int theHistoryTypesMaxAmount)
: TreeModel_ModelBase (theParent)
{
SetHeaderItem (0, TreeModel_HeaderSection ("Name", COLUMN_NAME_WIDTH));
SetHeaderItem (1, TreeModel_HeaderSection ("Size", COLUMN_SIZE_WIDTH));
SetHeaderItem (2, TreeModel_HeaderSection ("Pointer", COLUMN_POINTER_WIDTH));
SetHeaderItem (3, TreeModel_HeaderSection ("Shape type", COLUMN_SHAPE_TYPE_WIDTH));
SetHeaderItem (4, TreeModel_HeaderSection ("AIS Name", COLUMN_AIS_NAME_WIDTH));
SetHeaderItem (5, TreeModel_HeaderSection ("Selected/Highlighted", -1));
for (int aColumnId = 0, aNbColumns = columnCount(); aColumnId < aNbColumns; aColumnId++)
{
myRootItems.insert(aColumnId, VInspector_ItemHistoryRoot::CreateItem(TreeModel_ItemBasePtr(), 0, aColumnId));
VInspector_ItemHistoryRootPtr aRootItem = itemDynamicCast<VInspector_ItemHistoryRoot>(myRootItems[aColumnId]);
aRootItem->SetHistoryTypesMaxAmount(theHistoryTypesMaxAmount);
VInspector_ItemHistoryRootPtr aRootItem = itemDynamicCast<VInspector_ItemHistoryRoot> (myRootItems[aColumnId]);
aRootItem->SetHistoryTypesMaxAmount (theHistoryTypesMaxAmount);
}
m_pRootItem = myRootItems[0];
}
// =======================================================================
// function : createRootItem
// purpose :
// =======================================================================
void VInspector_ViewModelHistory::createRootItem (const int theColumnId)
{
myRootItems.insert (theColumnId, VInspector_ItemHistoryRoot::CreateItem (TreeModel_ItemBasePtr(), 0, theColumnId));
if (theColumnId == 0)
m_pRootItem = myRootItems[0];
}
// =======================================================================
@@ -89,25 +120,3 @@ QStringList VInspector_ViewModelHistory::GetSelectedPointers (const QModelIndex&
}
return aPointers;
}
// =======================================================================
// function : headerData
// purpose :
// =======================================================================
QVariant VInspector_ViewModelHistory::headerData (int theSection, Qt::Orientation theOrientation, int theRole) const
{
if (theOrientation != Qt::Horizontal || theRole != Qt::DisplayRole)
return QVariant();
switch (theSection)
{
case 0: return "Name";
case 1: return "Size";
case 2: return "Pointer";
case 3: return "Shape type";
case 4: return "AIS Name";
case 5: return "Selected/Highlighted";
default: break;
}
return QVariant();
}

View File

@@ -56,19 +56,11 @@ public:
//! \return root item instance
virtual TreeModel_ItemBasePtr RootItem(const int theColumn) const Standard_OVERRIDE { return myRootItems[theColumn]; }
//! Returns count of columns in the model
//! \param theParent an index of the parent item
//! \return integer value
virtual int columnCount (const QModelIndex& theParent = QModelIndex()) const Standard_OVERRIDE
{ (void)theParent; return 6; }
protected:
//! Returns the header data for the given role and section in the header with the specified orientation.
//! \param theSection the header section. For horizontal headers - column number, for vertical headers - row number.
//! \param theOrientation a header orientation
//! \param theRole a data role
//! \return the header data
Standard_EXPORT virtual QVariant headerData (int theSection, Qt::Orientation theOrientation,
int theRole = Qt::DisplayRole ) const Standard_OVERRIDE;
//! Creates root item
//! \param theColumnId index of a column
virtual void createRootItem (const int theColumnId) Standard_OVERRIDE;
private:

View File

@@ -17,13 +17,17 @@
#include <AIS_Shape.hxx>
#include <inspector/TreeModel_MessageDialog.hxx>
#include <inspector/TreeModel_ColumnType.hxx>
#include <inspector/TreeModel_ContextMenu.hxx>
#include <inspector/TreeModel_Tools.hxx>
#include <inspector/ViewControl_MessageDialog.hxx>
#include <inspector/ViewControl_Tools.hxx>
#include <inspector/VInspector_ItemPresentableObject.hxx>
#include <inspector/VInspector_ToolBar.hxx>
#include <inspector/VInspector_Tools.hxx>
#include <inspector/VInspector_ViewModel.hxx>
#include <inspector/VInspector_ViewModelHistory.hxx>
#include <inspector/VInspector_CallBack.hxx>
#include <inspector/VInspector_Communicator.hxx>
#include <inspector/VInspector_ItemEntityOwner.hxx>
@@ -33,6 +37,8 @@
#include <inspector/VInspector_ViewModel.hxx>
#include <inspector/VInspector_ViewModelHistory.hxx>
#include <inspector/ViewControl_TreeView.hxx>
#include <inspector/View_Widget.hxx>
#include <inspector/View_Window.hxx>
@@ -50,18 +56,6 @@
#include <QWidget>
#include <Standard_WarningsRestore.hxx>
const int FIRST_COLUMN_WIDTH = 230;
const int COLUMN_1_WIDTH = 30;
const int COLUMN_2_WIDTH = 70;
const int COLUMN_3_WIDTH = 70;
const int COLUMN_4_WIDTH = 75;
const int COLUMN_5_WIDTH = 120;
const int COLUMN_6_WIDTH = 65;
const int COLUMN_7_WIDTH = 70;
const int HISTORY_AIS_NAME_COLUMN_WIDTH = 140;
const int VINSPECTOR_DEFAULT_WIDTH = 1250;
const int VINSPECTOR_DEFAULT_HEIGHT = 800;
@@ -77,52 +71,6 @@ const int VINSPECTOR_DEFAULT_HISTORY_VIEW_HEIGHT = 50;
const int VINSPECTOR_DEFAULT_VIEW_POSITION_X = 200 + 900 + 100; // TINSPECTOR_DEFAULT_POSITION_X + TINSPECTOR_DEFAULT_WIDTH + 100
const int VINSPECTOR_DEFAULT_VIEW_POSITION_Y = 60; // TINSPECTOR_DEFAULT_POSITION_Y + 50
//! \class Vinspector_TreeView
//! Extended tree view control with possibility to set predefined size.
class Vinspector_TreeView : public QTreeView
{
public:
//! Constructor
Vinspector_TreeView (QWidget* theParent) : QTreeView (theParent), myDefaultWidth (-1), myDefaultHeight (-1) {}
//! Destructor
virtual ~Vinspector_TreeView() {}
//! Sets default size of control, that is used by the first control show
//! \param theDefaultWidth the width value
//! \param theDefaultHeight the height value
void SetPredefinedSize (int theDefaultWidth, int theDefaultHeight);
//! Returns predefined size if both values are positive, otherwise parent size hint
virtual QSize sizeHint() const Standard_OVERRIDE;
private:
int myDefaultWidth; //!< default width, -1 if it should not be used
int myDefaultHeight; //!< default height, -1 if it should not be used
};
// =======================================================================
// function : SetPredefinedSize
// purpose :
// =======================================================================
void Vinspector_TreeView::SetPredefinedSize (int theDefaultWidth, int theDefaultHeight)
{
myDefaultWidth = theDefaultWidth;
myDefaultHeight = theDefaultHeight;
}
// =======================================================================
// function : sizeHint
// purpose :
// =======================================================================
QSize Vinspector_TreeView::sizeHint() const
{
if (myDefaultWidth > 0 && myDefaultHeight > 0)
return QSize (myDefaultWidth, myDefaultHeight);
return QTreeView::sizeHint();
}
// =======================================================================
// function : Constructor
// purpose :
@@ -137,7 +85,7 @@ VInspector_Window::VInspector_Window()
aParentLay->setContentsMargins (0, 0, 0, 0);
aParentLay->setSpacing(0);
// tool bar: on the bottom of the window
// restore state of tool bar: on the bottom of the window
myToolBar = new VInspector_ToolBar(aCentralWidget);
connect (myToolBar, SIGNAL (actionClicked (int)), this, SLOT (onToolBarActionClicked (int)));
aParentLay->addWidget (myToolBar->GetControl(), 0, 0);
@@ -148,34 +96,55 @@ VInspector_Window::VInspector_Window()
myTreeView->setSelectionMode (QAbstractItemView::ExtendedSelection);
myTreeView->header()->setStretchLastSection (true);
myTreeView->setContextMenuPolicy(Qt::CustomContextMenu);
VInspector_ViewModel* aTreeModel = new VInspector_ViewModel (myTreeView);
myTreeView->setModel (aTreeModel);
// hide Visibility column
TreeModel_HeaderSection anItem = aTreeModel->GetHeaderItem ((int)TreeModel_ColumnType_Visibility);
anItem.SetIsHidden (true);
aTreeModel->SetHeaderItem ((int)TreeModel_ColumnType_Visibility, anItem);
connect (myTreeView, SIGNAL(customContextMenuRequested(const QPoint&)),
this, SLOT (onTreeViewContextMenuRequested(const QPoint&)));
new TreeModel_ContextMenu (myTreeView);
QItemSelectionModel* aSelModel = new QItemSelectionModel (myTreeView->model(), myTreeView);
myTreeView->setSelectionModel (aSelModel);
connect (aSelModel, SIGNAL (selectionChanged (const QItemSelection&, const QItemSelection&)),
this, SLOT (onSelectionChanged (const QItemSelection&, const QItemSelection&)));
aParentLay->addWidget(myTreeView, 1, 0);
aParentLay->setRowStretch (1, 1);
myMainWindow->setCentralWidget (aCentralWidget);
// history view in bottom dock widget
myHistoryView = new Vinspector_TreeView (aCentralWidget);
myHistoryView = new ViewControl_TreeView (myMainWindow);
myHistoryView->setSelectionBehavior (QAbstractItemView::SelectRows);
((Vinspector_TreeView*)myHistoryView)->SetPredefinedSize (VINSPECTOR_DEFAULT_HISTORY_VIEW_WIDTH,
VINSPECTOR_DEFAULT_HISTORY_VIEW_HEIGHT);
((ViewControl_TreeView*)myHistoryView)->SetPredefinedSize (QSize (VINSPECTOR_DEFAULT_HISTORY_VIEW_WIDTH,
VINSPECTOR_DEFAULT_HISTORY_VIEW_HEIGHT));
myHistoryView->setContextMenuPolicy (Qt::CustomContextMenu);
myHistoryView->header()->setStretchLastSection (true);
new TreeModel_ContextMenu (myHistoryView);
myHistoryView->setSelectionMode (QAbstractItemView::ExtendedSelection);
VInspector_ViewModelHistory* aHistoryModel = new VInspector_ViewModelHistory (myHistoryView);
myHistoryView->setModel (aHistoryModel);
QItemSelectionModel* aSelectionModel = new QItemSelectionModel (myHistoryView->model());
QItemSelectionModel* aSelectionModel = new QItemSelectionModel (aHistoryModel);
myHistoryView->setSelectionModel (aSelectionModel);
connect (aSelectionModel, SIGNAL (selectionChanged (const QItemSelection&, const QItemSelection&)),
this, SLOT (onHistoryViewSelectionChanged (const QItemSelection&, const QItemSelection&)));
this, SLOT (onHistoryViewSelectionChanged (const QItemSelection&, const QItemSelection&)));
myHistoryView->setColumnWidth (0, FIRST_COLUMN_WIDTH);
myHistoryView->setColumnWidth (1, COLUMN_1_WIDTH);
myHistoryView->setColumnWidth (2, COLUMN_2_WIDTH);
myHistoryView->setColumnWidth (3, COLUMN_3_WIDTH);
myHistoryView->setColumnWidth (4, HISTORY_AIS_NAME_COLUMN_WIDTH);
anItem = aHistoryModel->GetHeaderItem (0);
TreeModel_Tools::UseVisibilityColumn (myHistoryView, false);
// hide Visibility column
anItem = aHistoryModel->GetHeaderItem ((int)TreeModel_ColumnType_Visibility);
anItem.SetIsHidden (true);
aHistoryModel->SetHeaderItem ((int)TreeModel_ColumnType_Visibility, anItem);
QModelIndex aParentIndex = myHistoryView->model()->index (0, 0);
myHistoryView->setExpanded (aParentIndex, true);
QDockWidget* aHistoryDockWidget = new QDockWidget (tr ("HistoryView"), myMainWindow);
aHistoryDockWidget->setObjectName (aHistoryDockWidget->windowTitle());
aHistoryDockWidget->setTitleBarWidget (new QWidget(myMainWindow));
aHistoryDockWidget->setWidget (myHistoryView);
myMainWindow->addDockWidget (Qt::BottomDockWidgetArea, aHistoryDockWidget);
@@ -202,6 +171,69 @@ void VInspector_Window::SetParent (void* theParent)
aLayout->addWidget (GetMainWindow());
}
// =======================================================================
// function : FillActionsMenu
// purpose :
// =======================================================================
void VInspector_Window::FillActionsMenu (void* theMenu)
{
QMenu* aMenu = (QMenu*)theMenu;
QList<QDockWidget*> aDockwidgets = myMainWindow->findChildren<QDockWidget*>();
for (QList<QDockWidget*>::iterator it = aDockwidgets.begin(); it != aDockwidgets.end(); ++it)
{
QDockWidget* aDockWidget = *it;
if (aDockWidget->parentWidget() == myMainWindow)
aMenu->addAction (aDockWidget->toggleViewAction());
}
}
// =======================================================================
// function : GetPreferences
// purpose :
// =======================================================================
void VInspector_Window::GetPreferences (TInspectorAPI_PreferencesDataMap& theItem)
{
theItem.Clear();
theItem.Bind ("geometry", TreeModel_Tools::ToString (myMainWindow->saveState()).toStdString().c_str());
QMap<QString, QString> anItems;
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());
}
anItems.clear();
TreeModel_Tools::SaveState (myHistoryView, anItems, "history_view_");
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());
}
// =======================================================================
// function : SetPreferences
// purpose :
// =======================================================================
void VInspector_Window::SetPreferences (const TInspectorAPI_PreferencesDataMap& theItem)
{
if (theItem.IsEmpty())
{
TreeModel_Tools::SetDefaultHeaderSections (myTreeView);
TreeModel_Tools::SetDefaultHeaderSections (myHistoryView);
return;
}
for (TInspectorAPI_IteratorOfPreferencesDataMap anItemIt (theItem); anItemIt.More(); anItemIt.Next())
{
if (anItemIt.Key().IsEqual ("geometry"))
myMainWindow->restoreState (TreeModel_Tools::ToByteArray (anItemIt.Value().ToCString()));
else if (TreeModel_Tools::RestoreState (myTreeView, anItemIt.Key().ToCString(), anItemIt.Value().ToCString()))
continue;
else if (TreeModel_Tools::RestoreState (myHistoryView, anItemIt.Key().ToCString(), anItemIt.Value().ToCString(),
"history_view_"))
continue;
}
}
// =======================================================================
// function : UpdateContent
// purpose :
@@ -210,17 +242,20 @@ void VInspector_Window::UpdateContent()
{
TCollection_AsciiString aName = "TKVInspector";
bool isModelUpdated = false;
if (myParameters->FindParameters (aName))
Init(myParameters->Parameters (aName));
if (myParameters->FindFileNames(aName))
isModelUpdated = Init (myParameters->Parameters (aName));
if (myParameters->FindFileNames (aName))
{
for (NCollection_List<TCollection_AsciiString>::Iterator aFileNamesIt(myParameters->FileNames(aName));
for (NCollection_List<TCollection_AsciiString>::Iterator aFileNamesIt (myParameters->FileNames (aName));
aFileNamesIt.More(); aFileNamesIt.Next())
OpenFile (aFileNamesIt.Value());
isModelUpdated = OpenFile (aFileNamesIt.Value()) || isModelUpdated;
NCollection_List<TCollection_AsciiString> aNames;
myParameters->SetFileNames(aName, aNames);
myParameters->SetFileNames (aName, aNames);
}
if (!isModelUpdated)
UpdateTreeModel();
// make AIS_InteractiveObject selected selected if exist in select parameters
NCollection_List<Handle(Standard_Transient)> anObjects;
@@ -250,7 +285,7 @@ void VInspector_Window::UpdateContent()
// function : Init
// purpose :
// =======================================================================
void VInspector_Window::Init (const NCollection_List<Handle(Standard_Transient)>& theParameters)
bool VInspector_Window::Init (const NCollection_List<Handle(Standard_Transient)>& theParameters)
{
Handle(AIS_InteractiveContext) aContext;
Handle(VInspector_CallBack) aCallBack;
@@ -265,17 +300,18 @@ void VInspector_Window::Init (const NCollection_List<Handle(Standard_Transient)>
aCallBack = Handle(VInspector_CallBack)::DownCast (anObject);
}
if (aContext.IsNull())
return;
SetContext (aContext);
return false;
VInspector_ViewModel* aViewModel = dynamic_cast<VInspector_ViewModel*> (myTreeView->model());
if (aViewModel && aViewModel->GetContext() == aContext)
UpdateTreeModel();
else
SetContext (aContext);
if (!aCallBack.IsNull())
if (!aCallBack.IsNull() && aCallBack != myCallBack)
{
myCallBack = aCallBack;
VInspector_ViewModelHistory* aHistoryModel = dynamic_cast<VInspector_ViewModelHistory*>
(myHistoryView->model());
myCallBack->SetContext (aContext);
myCallBack->SetHistoryModel(aHistoryModel);
}
return true;
}
// =======================================================================
@@ -284,53 +320,36 @@ void VInspector_Window::Init (const NCollection_List<Handle(Standard_Transient)>
// =======================================================================
void VInspector_Window::SetContext (const Handle(AIS_InteractiveContext)& theContext)
{
VInspector_ViewModel* aViewModel = new VInspector_ViewModel (myTreeView);
VInspector_ViewModel* aViewModel = dynamic_cast<VInspector_ViewModel*> (myTreeView->model());
aViewModel->SetContext (theContext);
myTreeView->setModel (aViewModel);
myTreeView->setExpanded (aViewModel->index (0, 0), true);
myTreeView->setColumnWidth (0, FIRST_COLUMN_WIDTH);
if (!myCallBack.IsNull())
myCallBack->SetContext (theContext);
QItemSelectionModel* aSelModel = new QItemSelectionModel (aViewModel, myTreeView);
myTreeView->setSelectionModel (aSelModel);
connect (aSelModel, SIGNAL (selectionChanged (const QItemSelection&, const QItemSelection&)),
this, SLOT (onSelectionChanged (const QItemSelection&, const QItemSelection&)));
myTreeView->setColumnWidth (1, COLUMN_1_WIDTH);
myTreeView->setColumnWidth (2, COLUMN_2_WIDTH);
myTreeView->setColumnWidth (3, COLUMN_3_WIDTH);
myTreeView->setColumnWidth (4, COLUMN_4_WIDTH);
myTreeView->setColumnWidth (5, COLUMN_5_WIDTH);
myTreeView->setColumnWidth (6, COLUMN_6_WIDTH);
myTreeView->setColumnWidth (7, COLUMN_7_WIDTH);
}
// =======================================================================
// function : OpenFile
// purpose :
// =======================================================================
void VInspector_Window::OpenFile(const TCollection_AsciiString& theFileName)
bool VInspector_Window::OpenFile(const TCollection_AsciiString& theFileName)
{
VInspector_ViewModel* aViewModel = dynamic_cast<VInspector_ViewModel*> (myTreeView->model());
if (!aViewModel)
{
Handle(AIS_InteractiveContext) aContext = createView();
SetContext (aContext);
aViewModel = dynamic_cast<VInspector_ViewModel*> (myTreeView->model());
}
if (!aViewModel)
return;
return false;
Handle(AIS_InteractiveContext) aContext = aViewModel->GetContext();
if (!aContext)
return;
bool isModelUpdated = false;
if (aContext.IsNull())
{
aContext = createView();
SetContext (aContext);
isModelUpdated = true;
}
TopoDS_Shape aShape = VInspector_Tools::ReadShape (theFileName);
if (aShape.IsNull())
return;
return isModelUpdated;
Handle(AIS_Shape) aPresentation = new AIS_Shape (aShape);
aContext->Display (aPresentation, false);
@@ -339,6 +358,7 @@ void VInspector_Window::OpenFile(const TCollection_AsciiString& theFileName)
UpdateTreeModel();
myTreeView->setExpanded (aViewModel->index (0, 0), true);
return true;
}
// =======================================================================
@@ -348,9 +368,9 @@ void VInspector_Window::OpenFile(const TCollection_AsciiString& theFileName)
void VInspector_Window::onTreeViewContextMenuRequested(const QPoint& thePosition)
{
QMenu* aMenu = new QMenu (GetMainWindow());
aMenu->addAction (createAction (tr ("Export to ShapeView"), SLOT(onExportToShapeView())));
aMenu->addAction (createAction (tr ("Show"), SLOT(onShow())));
aMenu->addAction (createAction (tr ("Hide"), SLOT(onHide())));
aMenu->addAction (ViewControl_Tools::CreateAction (tr ("Export to ShapeView"), SLOT (onExportToShapeView()), GetMainWindow(), this));
aMenu->addAction (ViewControl_Tools::CreateAction (tr ("Show"), SLOT (onShow()), GetMainWindow(), this));
aMenu->addAction (ViewControl_Tools::CreateAction (tr ("Hide"), SLOT (onHide()), GetMainWindow(), this));
QPoint aPoint = myTreeView->mapToGlobal (thePosition);
aMenu->exec(aPoint);
}
@@ -462,6 +482,10 @@ void VInspector_Window::onExportToShapeView()
if (myParameters->FindParameters (aPluginName))
aParameters = myParameters->Parameters (aPluginName);
NCollection_List<TCollection_AsciiString> anItemNames;
if (myParameters->FindSelectedNames (aPluginName))
anItemNames = myParameters->GetSelectedNames (aPluginName);
QStringList anExportedPointers;
for (NCollection_List<Handle(AIS_InteractiveObject)>::Iterator anIOIt (aSelectedPresentations); anIOIt.More(); anIOIt.Next())
{
@@ -473,6 +497,7 @@ void VInspector_Window::onExportToShapeView()
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())
@@ -485,11 +510,12 @@ void VInspector_Window::onExportToShapeView()
QString aQuestion = QString ("Would you like to activate %1 immediately?\n")
.arg (aPluginShortName.ToCString()).toStdString().c_str();
if (!myExportToShapeViewDialog)
myExportToShapeViewDialog = new TreeModel_MessageDialog (myParent, aMessage, aQuestion);
myExportToShapeViewDialog = new ViewControl_MessageDialog (myParent, aMessage, aQuestion);
else
myExportToShapeViewDialog->SetInformation (aMessage);
myExportToShapeViewDialog->Start();
myParameters->SetSelectedNames (aPluginName, anItemNames);
myParameters->SetParameters (aPluginName, aParameters, myExportToShapeViewDialog->IsAccepted());
}
@@ -518,21 +544,8 @@ void VInspector_Window::onHide()
void VInspector_Window::UpdateTreeModel()
{
VInspector_ViewModel* aViewModel = dynamic_cast<VInspector_ViewModel*> (myTreeView->model());
if (!aViewModel)
return;
aViewModel->Reset();
aViewModel->EmitLayoutChanged();
}
// =======================================================================
// function : createAction
// purpose :
// =======================================================================
QAction* VInspector_Window::createAction(const QString& theText, const char* theSlot)
{
QAction* anAction = new QAction(theText, GetMainWindow());
connect(anAction, SIGNAL(triggered(bool)), this, theSlot);
return anAction;
if (aViewModel)
aViewModel->UpdateTreeModel();
}
// =======================================================================

View File

@@ -20,6 +20,7 @@
#include <NCollection_List.hxx>
#include <SelectBasics_EntityOwner.hxx>
#include <Standard.hxx>
#include <inspector/TInspectorAPI_PluginParameters.hxx>
#include <inspector/VInspector_CallBack.hxx>
@@ -29,7 +30,7 @@
#include <QMainWindow>
#include <Standard_WarningsRestore.hxx>
class TreeModel_MessageDialog;
class ViewControl_MessageDialog;
class VInspector_ToolBar;
class View_Window;
@@ -63,6 +64,18 @@ public:
//! \param theParameters a parameters container
void SetParameters (const Handle(TInspectorAPI_PluginParameters)& theParameters) { myParameters = theParameters; }
//! Provide container for actions available in inspector on general level
//! \param theMenu if Qt implementation, it is QMenu object
Standard_EXPORT void FillActionsMenu (void* theMenu);
//! Returns plugin preferences: dock widgets state, tree view columns.
//! \param theItem container of preference elements
Standard_EXPORT void GetPreferences (TInspectorAPI_PreferencesDataMap& theItem);
//! Applies plugin preferences
//! \param theItem container of preference elements
Standard_EXPORT void SetPreferences (const TInspectorAPI_PreferencesDataMap& theItem);
//! Applyes parameters to Init controls, opens files if there are in parameters, updates OCAF tree view model
Standard_EXPORT void UpdateContent();
@@ -74,11 +87,11 @@ private:
//! Fills controls of the plugin by parameters:
//! - Fine AIS_InteractiveObject and fills View if it if it differs from the current context
//! \param theParameters a parameters container
void Init (const NCollection_List<Handle(Standard_Transient)>& theParameters);
bool Init (const NCollection_List<Handle(Standard_Transient)>& theParameters);
//! Read BREP file, creates AIS presentation for the shape and visualize it in the current context
//! \param theFileName a name of BREP file
void OpenFile (const TCollection_AsciiString& theFileName);
bool OpenFile (const TCollection_AsciiString& theFileName);
private slots:
@@ -120,12 +133,6 @@ private:
//! Updates tree model
void UpdateTreeModel();
//! Creates an action with the given text connected to the slot
//! \param theText an action text value
//! \param theSlot a listener of triggered signal of the new action
//! \return a new action
QAction* createAction(const QString& theText, const char* theSlot);
//! Set selected in tree view presentations displayed or erased in the current context. Note that erased presentations
//! still belongs to the current context until Remove is called.
//! \param theToDisplay if true, presentation is displayed otherwise erased
@@ -145,7 +152,7 @@ private:
QTreeView* myHistoryView; //!< history of AIS context calls
Handle(VInspector_CallBack) myCallBack; //!< AIS context call back, if set
TreeModel_MessageDialog* myExportToShapeViewDialog; //!< dialog about exporting TopoDS_Shape to ShapeView plugin
ViewControl_MessageDialog* myExportToShapeViewDialog; //!< dialog about exporting TopoDS_Shape to ShapeView plugin
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

Binary file not shown.

After

Width:  |  Height:  |  Size: 604 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 231 B