improvements in VInspector, based on CR40491 branch.
#include <algorithm>
+//#define REPORT_SELECTION_BUILD
+#ifdef REPORT_SELECTION_BUILD
+#include <Message_Alerts.hxx>
+#include <Message_PerfMeter.hxx>
+#endif
+
IMPLEMENT_STANDARD_RTTIEXT(SelectMgr_ViewerSelector, Standard_Transient)
namespace {
const gp_GTrsf& theInversedTrsf,
SelectMgr_SelectingVolumeManager& theMgr)
{
+ #ifdef REPORT_SELECTION_BUILD
+ Message_PerfMeter aPerfMeter;
+ MESSAGE_INFO_OBJECT (theEntity, "checkOverlap", "", &aPerfMeter, NULL);
+ Handle(Message_Alert) aParentAlert = OCCT_Message_Alert;
+ #endif
+
Handle(SelectMgr_EntityOwner) anOwner (Handle(SelectMgr_EntityOwner)::DownCast (theEntity->OwnerId()));
Handle(SelectMgr_SelectableObject) aSelectable;
Standard_Boolean toRestoresViewClipEnabled = Standard_False;
}
SelectBasics_PickResult aPickResult;
+ #ifdef REPORT_SELECTION_BUILD
+ MESSAGE_INFO (TCollection_AsciiString ("Matches - start"), "", &aPerfMeter, aParentAlert);
+ #endif
const Standard_Boolean isMatched = theEntity->Matches(theMgr, aPickResult);
+ #ifdef REPORT_SELECTION_BUILD
+ MESSAGE_INFO (TCollection_AsciiString ("Matches - end"), "", &aPerfMeter, aParentAlert);
+ #endif
if (toRestoresViewClipEnabled)
{
theMgr.SetViewClippingEnabled (Standard_True);
return;
}
+ #ifdef REPORT_SELECTION_BUILD
+ Message_PerfMeter aPerfMeter;
+ MESSAGE_INFO_OBJECT (theObject, "traverseObject", "", &aPerfMeter, NULL);
+ Handle(Message_Alert) aParentAlert = OCCT_Message_Alert;
+ #endif
+
const opencascade::handle<BVH_Tree<Standard_Real, 3> >& aSensitivesTree = anEntitySet->BVH();
gp_GTrsf aInversedTrsf;
if (theObject->HasTransformation() || !theObject->TransformPersistence().IsNull())
Standard_Integer aHead = -1;
for (;;)
{
+ #ifdef REPORT_SELECTION_BUILD
+ MESSAGE_INFO (TCollection_AsciiString ("aNode") + aNode, "", &aPerfMeter, aParentAlert);
+ #endif
+
if (!aSensitivesTree->IsOuter (aNode))
{
const Standard_Integer aLeftChildIdx = aSensitivesTree->Child<0> (aNode);
//=======================================================================
void SelectMgr_ViewerSelector::TraverseSensitives()
{
+#ifdef REPORT_SELECTION_BUILD
+ Message_PerfMeter aPerfMeter;
+ MESSAGE_INFO ("TraverseSensitives", "", &aPerfMeter, NULL);
+ Handle(Message_Alert) aParentAlert = OCCT_Message_Alert;
+#endif
+
mystored.Clear();
Standard_Integer aWidth;
for (Standard_Integer aBVHSetIt = 0; aBVHSetIt < SelectMgr_SelectableObjectSet::BVHSubsetNb; ++aBVHSetIt)
{
+ #ifdef REPORT_SELECTION_BUILD
+ MESSAGE_INFO (TCollection_AsciiString ("aBVHSetIt") + aBVHSetIt, "", &aPerfMeter, aParentAlert);
+ Handle(Message_Alert) aParentAlertLevel1 = OCCT_Message_Alert;
+ #endif
+
SelectMgr_SelectableObjectSet::BVHSubset aBVHSubset =
static_cast<SelectMgr_SelectableObjectSet::BVHSubset> (aBVHSetIt);
Standard_Integer aHead = -1;
for (;;)
{
+ #ifdef REPORT_SELECTION_BUILD
+ MESSAGE_INFO (TCollection_AsciiString ("aNode - ") + aNode, "", &aPerfMeter, aParentAlertLevel1);
+ #endif
if (!aBVHTree->IsOuter (aNode))
{
const Standard_Integer aLeftChildIdx = aBVHTree->Child<0> (aNode);
//=======================================================================
void SelectMgr_ViewerSelector::SortResult()
{
+#ifdef REPORT_SELECTION_BUILD
+ Message_PerfMeter aPerfMeter;
+ MESSAGE_INFO ("SortResult", "", &aPerfMeter, NULL);
+ Handle(Message_Alert) aParentAlert = OCCT_Message_Alert;
+#endif
+
if(mystored.IsEmpty()) return;
const Standard_Integer anExtent = mystored.Extent();
//! depth which is used to choose among objects of the same priority.
void SetPickClosest (const Standard_Boolean theToPreferClosest) { preferclosest = theToPreferClosest; }
+ //! Return preference of selecting one object for OnePicked() method
+ Standard_Boolean IsPickClosest() const { return preferclosest; }
+
//! Returns the number of detected owners.
Standard_Integer NbPicked() const { return mystored.Extent(); }
#include <OSD_Timer.hxx>
+//#define REPORT_SELECTION_BUILD
+#ifdef REPORT_SELECTION_BUILD
+#include <Message_Alerts.hxx>
+#include <Message_PerfMeter.hxx>
+#endif
IMPLEMENT_STANDARD_RTTIEXT(StdSelect_ViewerSelector3d,SelectMgr_ViewerSelector)
const Standard_Integer theYPix,
const Handle(V3d_View)& theView)
{
+#ifdef REPORT_SELECTION_BUILD
+ Message_PerfMeter aPerfMeter;
+ MESSAGE_INFO ("Pick", TCollection_AsciiString ("theXPix = ") + theXPix + ", theYPix = " + theYPix, &aPerfMeter, NULL);
+ Handle(Message_Alert) aParentAlert = OCCT_Message_Alert;
+#endif
updateZLayers (theView);
if(myToUpdateTolerance)
{
mySelectingVolumeMgr.SetWindowSize (aWidth, aHeight);
gp_Pnt2d aMousePos (static_cast<Standard_Real> (theXPix),
static_cast<Standard_Real> (theYPix));
+
+#ifdef REPORT_SELECTION_BUILD
+ MESSAGE_INFO ("Pick", TCollection_AsciiString ("aMousePos - X = ") + aMousePos.X() + ", Y = " + aMousePos.Y(), &aPerfMeter, aParentAlert);
+#endif
+
mySelectingVolumeMgr.BuildSelectingVolume (aMousePos);
mySelectingVolumeMgr.SetViewClipping (theView->ClipPlanes());
for (int aSelectedId = 0, aSize = aSelectedIndices.size(); aSelectedId < aSize; aSelectedId++)
{
int aLevels = 2;
- setExpanded (myTreeView, aSelectedIndices[aSelectedId], true, aLevels);
+ TreeModel_Tools::SetExpanded (myTreeView, aSelectedIndices[aSelectedId], true, aLevels);
}
QApplication::restoreOverrideCursor();
}
for (int aSelectedId = 0, aSize = aSelectedIndices.size(); aSelectedId < aSize; aSelectedId++)
{
int aLevels = -1;
- setExpanded (myTreeView, aSelectedIndices[aSelectedId], true, aLevels);
+ TreeModel_Tools::SetExpanded (myTreeView, aSelectedIndices[aSelectedId], true, aLevels);
}
QApplication::restoreOverrideCursor();
}
QModelIndexList aSelectedIndices = aSelectionModel->selectedIndexes();
for (int aSelectedId = 0, aSize = aSelectedIndices.size(); aSelectedId < aSize; aSelectedId++) {
int aLevels = -1;
- setExpanded (myTreeView, aSelectedIndices[aSelectedId], false, aLevels);
+ TreeModel_Tools::SetExpanded (myTreeView, aSelectedIndices[aSelectedId], false, aLevels);
}
}
thePresentations.Append (aPresentation);
}
}
-
-// =======================================================================
-// function : setExpanded
-// purpose :
-// =======================================================================
-void DFBrowser_Window::setExpanded (QTreeView* theTreeView, const QModelIndex& theIndex, const bool isExpanded,
- int& theLevels)
-{
- bool isToExpand = theLevels == -1 || theLevels > 0;
- if (!isToExpand)
- return;
-
- theTreeView->setExpanded (theIndex, isExpanded);
- if (theLevels != -1)
- theLevels--;
-
- QAbstractItemModel* aModel = theTreeView->model();
- for (int aRowId = 0, aRows = aModel->rowCount (theIndex); aRowId < aRows; aRowId++)
- {
- int aLevels = theLevels;
- setExpanded (theTreeView, aModel->index (aRowId, 0, theIndex), isExpanded, aLevels);
- }
-}
//! \return container of presentations or NULL
void findPresentations (const QModelIndexList& theIndices, AIS_ListOfInteractive& thePresentations);
- //! Recursive items expanding in tree view staring from the index
- //! \param theTreeView an OCAF tree view
- //! \param theParentIndex an index which children should be expanded
- //! \param isExpanded a boolean state if the item should be expanded or collapsed
- //! \param theLevels a number of levels to be expanded, or -1 for all levels
- static void setExpanded (QTreeView* theTreeView, const QModelIndex& theParentIndex, const bool isExpanded, int& theLevels);
-
private:
DFBrowser_Module* myModule; //!< current module
VInspector_ItemSelectBasicsEntityOwner.hxx
VInspector_ItemSelectBasicsSensitiveEntity.cxx
VInspector_ItemSelectBasicsSensitiveEntity.hxx
+VInspector_ItemSelectMgrViewerSelector.cxx
+VInspector_ItemSelectMgrViewerSelector.hxx
+VInspector_ItemSelectMgrViewerSelectorPicked.cxx
+VInspector_ItemSelectMgrViewerSelectorPicked.hxx
+VInspector_ItemSelectMgrBaseFrustum.cxx
+VInspector_ItemSelectMgrBaseFrustum.hxx
VInspector_ItemSelectMgrFilter.cxx
VInspector_ItemSelectMgrFilter.hxx
+VInspector_ItemSelectMgrSelectingVolumeManager.cxx
+VInspector_ItemSelectMgrSelectingVolumeManager.hxx
VInspector_ItemSelectMgrSelection.cxx
VInspector_ItemSelectMgrSelection.hxx
VInspector_ItemSelectMgrSensitiveEntity.cxx
// =======================================================================
void VInspector_CallBack::Activate (Handle(AIS_InteractiveObject) thePrs, const Standard_Integer theMode)
{
+ if (!myHistoryModel)
+ return;
+
QList<QVariant> anInfo;
if (!thePrs.IsNull())
anInfo = VInspector_Tools::GetInfo (thePrs);
// =======================================================================
void VInspector_CallBack::AddOrRemoveSelected (const TopoDS_Shape& theShape)
{
+ if (!myHistoryModel)
+ return;
QList<QVariant> aValues;
aValues.append (""); // Name
aValues.append (""); // Pointer
// =======================================================================
void VInspector_CallBack::AddOrRemoveSelected (Handle(AIS_InteractiveObject) thePrs)
{
+ if (!myHistoryModel)
+ return;
QList<QVariant> aValues = VInspector_Tools::GetInfo (thePrs);
aValues.append (VInspector_Tools::GetSelectedInfoPointers (myContext)); // SelectionInfo
myHistoryModel->AddElement (VInspector_CallBackMode_AddOrRemoveSelected, aValues);
// =======================================================================
void VInspector_CallBack::AddOrRemoveSelected (Handle(SelectMgr_EntityOwner) theOwner)
{
+ if (!myHistoryModel)
+ return;
QList<QVariant> aValues;
aValues.append (""); // Name
aValues.append (VInspector_Tools::GetPointerInfo (theOwner, true).ToCString()); // Pointer
// =======================================================================
void VInspector_CallBack::ClearSelected()
{
+ if (!myHistoryModel)
+ return;
QList<QVariant> aValues;
myHistoryModel->AddElement (VInspector_CallBackMode_ClearSelected, aValues);
}
// =======================================================================
void VInspector_CallBack::MoveTo (const Standard_Integer/* theXPix*/, const Standard_Integer/* theYPix*/)
{
+ if (!myHistoryModel)
+ return;
QList<QVariant> aValues;
aValues = VInspector_Tools::GetHighlightInfo (myContext);
myHistoryModel->AddElement (VInspector_CallBackMode_MoveTo, aValues);
// =======================================================================
void VInspector_CallBack::Select()
{
+ if (!myHistoryModel)
+ return;
QList<QVariant> aValues;
aValues = VInspector_Tools::GetSelectedInfo (myContext);
myHistoryModel->AddElement (VInspector_CallBackMode_Select, aValues);
// =======================================================================
void VInspector_CallBack::ShiftSelect()
{
+ if (!myHistoryModel)
+ return;
QList<QVariant> aValues;
aValues = VInspector_Tools::GetSelectedInfo (myContext);
myHistoryModel->AddElement (VInspector_CallBackMode_ShiftSelect, aValues);
//! Appends displayed presentation into history model
//! \param thePrs the presentation
virtual void Display (Handle(AIS_InteractiveObject) thePrs) Standard_OVERRIDE
- { myHistoryModel->AddElement (VInspector_CallBackMode_Display, VInspector_Tools::GetInfo (thePrs)); }
+ { if (myHistoryModel != 0) myHistoryModel->AddElement (VInspector_CallBackMode_Display, VInspector_Tools::GetInfo (thePrs)); }
//! Appends redisplayed presentation into history model
//! \param thePrs the presentation
virtual void Redisplay (Handle(AIS_InteractiveObject) thePrs) Standard_OVERRIDE
- { myHistoryModel->AddElement (VInspector_CallBackMode_Redisplay, VInspector_Tools::GetInfo (thePrs)); }
+ { if (myHistoryModel != 0) myHistoryModel->AddElement (VInspector_CallBackMode_Redisplay, VInspector_Tools::GetInfo (thePrs)); }
//! Appends removed presentation into history model
//! \param thePrs the presentation
virtual void Remove (Handle(AIS_InteractiveObject) thePrs) Standard_OVERRIDE
- { myHistoryModel->AddElement (VInspector_CallBackMode_Remove, VInspector_Tools::GetInfo (thePrs)); }
+ { if (myHistoryModel != 0) myHistoryModel->AddElement (VInspector_CallBackMode_Remove, VInspector_Tools::GetInfo (thePrs)); }
//! Appends loaded presentation into history model
//! \param thePrs the presentation
virtual void Load (Handle(AIS_InteractiveObject) thePrs) Standard_OVERRIDE
- { myHistoryModel->AddElement (VInspector_CallBackMode_Load, VInspector_Tools::GetInfo (thePrs)); }
+ { if (myHistoryModel != 0) myHistoryModel->AddElement (VInspector_CallBackMode_Load, VInspector_Tools::GetInfo (thePrs)); }
//! Appends information about modes activation
//! \param thePrs the presentation
//! Appends information about modes deactivation
//! \param thePrs the presentation
virtual void Deactivate (Handle(AIS_InteractiveObject) thePrs) Standard_OVERRIDE
- { myHistoryModel->AddElement (VInspector_CallBackMode_Deactivate, VInspector_Tools::GetInfo (thePrs)); }
+ { if (myHistoryModel != 0) myHistoryModel->AddElement (VInspector_CallBackMode_Deactivate, VInspector_Tools::GetInfo (thePrs)); }
//! Appends information about modes deactivation
//! \param thePrs the presentation
//! \param theMode the selection mode
virtual void Deactivate (Handle(AIS_InteractiveObject) thePrs, const Standard_Integer theMode) Standard_OVERRIDE
- { (void)theMode; myHistoryModel->AddElement (VInspector_CallBackMode_Deactivate, VInspector_Tools::GetInfo (thePrs)); }
+ { (void)theMode;
+ if (myHistoryModel != 0) myHistoryModel->AddElement (VInspector_CallBackMode_Deactivate, VInspector_Tools::GetInfo (thePrs)); }
//! Appends information about selection change
//! \param theShape the selected shape
//! Appends information about selection clear
//! \param thePrs the selected presentation
virtual void ClearSelected (Handle(AIS_InteractiveObject) thePrs) Standard_OVERRIDE
- { myHistoryModel->AddElement (VInspector_CallBackMode_ClearSelected, VInspector_Tools::GetInfo (thePrs)); }
+ { if (myHistoryModel != 0) myHistoryModel->AddElement (VInspector_CallBackMode_ClearSelected, VInspector_Tools::GetInfo (thePrs)); }
//! Appends information about moving to point
//! \param theXPix a pixels on horizontal
//! Appends information about setting selection
//! \param thePrs the selected presentation
virtual void SetSelected (Handle(AIS_InteractiveObject) thePrs) Standard_OVERRIDE
- { myHistoryModel->AddElement (VInspector_CallBackMode_SetSelected, VInspector_Tools::GetInfo (thePrs)); }
+ { if (myHistoryModel != 0) myHistoryModel->AddElement (VInspector_CallBackMode_SetSelected, VInspector_Tools::GetInfo (thePrs)); }
//! Appends information about select
Standard_EXPORT virtual void Select() Standard_OVERRIDE;
// =======================================================================
QVariant VInspector_ItemAspectWindow::initValue (int theItemRole) const
{
+ QVariant aParentValue = VInspector_ItemBase::initValue (theItemRole);
+ if (aParentValue.isValid())
+ return aParentValue;
+
if (theItemRole != Qt::DisplayRole && theItemRole != Qt::EditRole && theItemRole != Qt::ToolTipRole)
return QVariant();
{
case 0: return theItemRole == Qt::DisplayRole ? aWindow->DynamicType()->Name()
: STANDARD_TYPE (Aspect_Window)->Name();
- case 1:
- return rowCount();
- case 2:
- return ViewControl_Tools::GetPointerInfo (aWindow, true).ToCString();
default:
break;
}
#include <inspector/VInspector_ItemBase.hxx>
#include <inspector/VInspector_ItemContext.hxx>
+#include <inspector/ViewControl_Tools.hxx>
+
// =======================================================================
// function : Reset
// purpose :
TreeModel_ItemBase::Reset();
}
+// =======================================================================
+// function : initValue
+// purpose :
+// =======================================================================
+QVariant VInspector_ItemBase::initValue (const int theItemRole) const
+{
+ if (theItemRole != Qt::DisplayRole && theItemRole != Qt::ToolTipRole)
+ return QVariant();
+
+ switch (Column())
+ {
+ case 1: { return rowCount(); }
+ case 2: return ViewControl_Tools::GetPointerInfo (GetObject(), true).ToCString();
+ case 3: { return Row(); }
+ }
+
+ return QVariant();
+}
+
// =======================================================================
// function : GetContext
// purpose :
//! \return object
virtual Handle(Standard_Transient) GetObject() const { return NULL; }
+ //! Returns item information for the given role. Fills internal container if it was not filled yet
+ //! \param theItemRole a value role
+ //! \return the value
+ Standard_EXPORT virtual QVariant initValue (const int theItemRole) const Standard_OVERRIDE;
+
//! Returns presentation of the attribute to be visualized in the view
//! \thePresentations [out] container of presentation handles to be visualized
virtual void GetPresentations (NCollection_List<Handle(Standard_Transient)>& thePresentations)
// =======================================================================
QVariant VInspector_ItemContext::initValue (const int theItemRole) const
{
+ QVariant aParentValue = VInspector_ItemBase::initValue (theItemRole);
+ if (aParentValue.isValid())
+ return aParentValue;
+
if (theItemRole != Qt::DisplayRole && theItemRole != Qt::EditRole && theItemRole != Qt::ToolTipRole)
return QVariant();
switch (Column())
{
case 0: return GetContext()->DynamicType()->Name();
- case 1: return rowCount();
case 4:
{
Handle(AIS_InteractiveObject) anEmptyIO;
#include <inspector/VInspector_ItemPresentableObject.hxx>
#include <inspector/VInspector_ItemPrs3dDrawer.hxx>
#include <inspector/VInspector_ItemSelectMgrFilter.hxx>
+#include <inspector/VInspector_ItemSelectMgrViewerSelector.hxx>
#include <inspector/VInspector_ItemV3dViewer.hxx>
#include <AIS_InteractiveObject.hxx>
// =======================================================================
QVariant VInspector_ItemFolderObject::initValue (int theItemRole) const
{
+ QVariant aParentValue = VInspector_ItemBase::initValue (theItemRole);
+ if (aParentValue.isValid())
+ return aParentValue;
+
if (Column() != 0 || (theItemRole != Qt::DisplayRole && theItemRole != Qt::ToolTipRole))
return QVariant();
{
case ParentKind_ContextItem:
{
- int aNbChildren = 2; // Filters, Viewer
+ int aNbChildren = 3; // Filters, Viewer, MainSelector
aNbChildren++; // DefaultDrawer
for (int aTypeId = 0; aTypeId < Prs3d_TypeOfHighlight_NB; aTypeId++)
{
return VInspector_ItemFolderObject::CreateItem (currentItem(), theRow, theColumn);
else if (theRow == 1)
return VInspector_ItemV3dViewer::CreateItem (currentItem(), theRow, theColumn);
+ else if (theRow == 2)
+ return VInspector_ItemSelectMgrViewerSelector::CreateItem (currentItem(), theRow, theColumn);
else
return VInspector_ItemPrs3dDrawer::CreateItem (currentItem(), theRow, theColumn);
}
{
case ParentKind_ContextItem:
{
- if (theRow == 0 || theRow == 1) // "Filters", "Viewer"
+ if (theRow == 0 || theRow == 1 || theRow == 2) // "Filters", "Viewer", "Viewer Selector"
return 0;
- if (theRow == 2)
+ if (theRow == 3)
{
theName = "DefaultDrawer";
return GetContext()->DefaultDrawer();
const Handle(Prs3d_Drawer)& aDrawer = GetContext()->HighlightStyle (aType);
if (aDrawer.IsNull())
continue;
- if (aCurId == theRow - 3)
+ if (aCurId == theRow - 4)
{
theName = TCollection_AsciiString ("HighlightStyle: ") + Prs3d::TypeOfHighlightToString (aType);
return aDrawer;
// =======================================================================
QVariant VInspector_ItemGraphic3dCStructure::initValue (const int theItemRole) const
{
+ QVariant aParentValue = VInspector_ItemBase::initValue (theItemRole);
+ if (aParentValue.isValid())
+ return aParentValue;
+
if (theItemRole != Qt::DisplayRole && theItemRole != Qt::EditRole && theItemRole != Qt::ToolTipRole)
return QVariant();
{
case 0: return theItemRole == Qt::DisplayRole ? aCStructure->DynamicType()->Name()
: STANDARD_TYPE (Graphic3d_CStructure)->Name();
- case 1: return rowCount();
default:
break;
}
// =======================================================================
QVariant VInspector_ItemGraphic3dCView::initValue (const int theItemRole) const
{
+ QVariant aParentValue = VInspector_ItemBase::initValue (theItemRole);
+ if (aParentValue.isValid())
+ return aParentValue;
+
if (theItemRole != Qt::DisplayRole && theItemRole != Qt::EditRole && theItemRole != Qt::ToolTipRole)
return QVariant();
{
case 0: return theItemRole == Qt::DisplayRole ? aCView->DynamicType()->Name()
: STANDARD_TYPE (Graphic3d_CView)->Name();
- case 1:
- return rowCount();
- case 2:
- return ViewControl_Tools::GetPointerInfo (aCView, true).ToCString();
default:
break;
}
// =======================================================================
QVariant VInspector_ItemGraphic3dCamera::initValue (const int theItemRole) const
{
+ QVariant aParentValue = VInspector_ItemBase::initValue (theItemRole);
+ if (aParentValue.isValid())
+ return aParentValue;
+
if (theItemRole != Qt::DisplayRole && theItemRole != Qt::EditRole && theItemRole != Qt::ToolTipRole)
return QVariant();
{
case 0: return theItemRole == Qt::DisplayRole ? aCamera->DynamicType()->Name()
: STANDARD_TYPE (Graphic3d_Camera)->Name();
- case 1:
- return rowCount();
- case 2:
- return ViewControl_Tools::GetPointerInfo (aCamera, true).ToCString();
default:
break;
}
// =======================================================================
QVariant VInspector_ItemGraphic3dClipPlane::initValue (const int theItemRole) const
{
+ QVariant aParentValue = VInspector_ItemBase::initValue (theItemRole);
+ if (aParentValue.isValid())
+ return aParentValue;
+
if (theItemRole != Qt::DisplayRole && theItemRole != Qt::EditRole && theItemRole != Qt::ToolTipRole)
return QVariant();
switch (Column())
{
case 0: return GetClipPlane()->DynamicType()->Name();
- case 1: return rowCount();
default:
break;
}
// =======================================================================
QVariant VInspector_ItemGraphic3dGroup::initValue (const int theItemRole) const
{
+ QVariant aParentValue = VInspector_ItemBase::initValue (theItemRole);
+ if (aParentValue.isValid())
+ return aParentValue;
+
if (theItemRole != Qt::DisplayRole && theItemRole != Qt::EditRole && theItemRole != Qt::ToolTipRole)
return QVariant();
// =======================================================================
QVariant VInspector_ItemGraphic3dTransformPers::initValue (const int theItemRole) const
{
+ QVariant aParentValue = VInspector_ItemBase::initValue (theItemRole);
+ if (aParentValue.isValid())
+ return aParentValue;
+
if (theItemRole != Qt::DisplayRole && theItemRole != Qt::EditRole && theItemRole != Qt::ToolTipRole)
return QVariant();
switch (Column())
{
case 0: return aTransformPers->DynamicType()->Name();
- case 1: return rowCount();
default:
break;
}
// =======================================================================
QVariant VInspector_ItemHistoryElement::initValue(const int theRole) const
{
+ QVariant aParentValue = VInspector_ItemBase::initValue (theRole);
+ if (aParentValue.isValid())
+ return aParentValue;
+
if (theRole != Qt::DisplayRole && theRole != Qt::EditRole && theRole != Qt::ToolTipRole)
return QVariant();
// =======================================================================
QVariant VInspector_ItemHistoryRoot::initValue (const int theRole) const
{
+ QVariant aParentValue = VInspector_ItemBase::initValue (theRole);
+ if (aParentValue.isValid())
+ return aParentValue;
+
if (theRole != Qt::DisplayRole && theRole != Qt::EditRole && theRole != Qt::ToolTipRole)
return QVariant();
VInspector_ItemHistoryRootPtr aParentItem = itemDynamicCast<VInspector_ItemHistoryRoot>(Parent());
const VInspector_ItemHistoryTypeInfo& aTypeInfo = aParentItem->GetTypeInfo(Row());
+ if (aTypeInfo.myElements.size() < rowCount())
+ return QString();
QList<QVariant> anElements = aTypeInfo.myElements[rowCount() - 1]; // the last item
return anElements.size() > 1 ? anElements[1].toString() : QString();
}
VInspector_ItemHistoryRootPtr aParentItem = itemDynamicCast<VInspector_ItemHistoryRoot>(Parent());
const VInspector_ItemHistoryTypeInfo& aTypeInfo = aParentItem->GetTypeInfo(Row());
+ if ( aTypeInfo.myElements.size() < rowCount())
+ return QString();
QList<QVariant> anElements = aTypeInfo.myElements[rowCount() - 1]; // the last item
return anElements.size() > 3 ? anElements[3].toString() : QString();
}
// =======================================================================
QVariant VInspector_ItemHistoryType::initValue(const int theRole) const
{
+ QVariant aParentValue = VInspector_ItemBase::initValue (theRole);
+ if (aParentValue.isValid())
+ return aParentValue;
+
if (theRole != Qt::DisplayRole && theRole != Qt::EditRole && theRole != Qt::ToolTipRole)
return QVariant();
VInspector_ItemHistoryRootPtr aParentItem = itemDynamicCast<VInspector_ItemHistoryRoot>(Parent());
const VInspector_ItemHistoryTypeInfo& aTypeInfo = aParentItem->GetTypeInfo(Row());
int aRowCount = rowCount();
+ if (aRowCount <= 0 || aTypeInfo.myElements.size() < aRowCount)
+ return QVariant();
+
QList<QVariant> anElements = rowCount() > 0 ? aTypeInfo.myElements[rowCount() - 1] : QList<QVariant>(); // the last item
int anInfoSize = anElements.size();
switch (Column())
// =======================================================================
QVariant VInspector_ItemOpenGlElement::initValue (const int theItemRole) const
{
+ QVariant aParentValue = VInspector_ItemBase::initValue (theItemRole);
+ if (aParentValue.isValid())
+ return aParentValue;
+
if (theItemRole != Qt::DisplayRole && theItemRole != Qt::EditRole && theItemRole != Qt::ToolTipRole)
return QVariant();
//! Returns the current graphic3d group, init item if it was not initialized yet
//! \return graphic group
- Handle(OpenGl_Element) GetElement() const { return Handle(OpenGl_Element)::DownCast (GetObject());}
+ Standard_EXPORT Handle(OpenGl_Element) GetElement() const
+ { return Handle(OpenGl_Element)::DownCast (GetObject());}
//! Inits the item, fills internal containers
Standard_EXPORT virtual void Init() Standard_OVERRIDE;
// =======================================================================
QVariant VInspector_ItemPresentableObject::initValue (int theItemRole) const
{
+ QVariant aParentValue = VInspector_ItemBase::initValue (theItemRole);
+ if (aParentValue.isValid())
+ return aParentValue;
+
if (theItemRole == Qt::DisplayRole || theItemRole == Qt::ToolTipRole)
{
Handle(AIS_InteractiveObject) anIO = GetInteractiveObject();
return theItemRole == Qt::ToolTipRole ? QVariant ("")
: QVariant (anIO->DynamicType()->Name());
}
- case 1:
- return rowCount();
- case 2:
- {
- if (!aNullIO)
- return VInspector_Tools::GetPointerInfo (anIO, true).ToCString();
- break;
- }
case 4:
{
int aNbSelected = VInspector_Tools::SelectedOwners (GetContext(), anIO, false);
// =======================================================================
QVariant VInspector_ItemPresentations::initValue (int theItemRole) const
{
+ QVariant aParentValue = VInspector_ItemBase::initValue (theItemRole);
+ if (aParentValue.isValid())
+ return aParentValue;
+
if (Column() != 0 || (theItemRole != Qt::DisplayRole && theItemRole != Qt::ToolTipRole))
return QVariant();
QVariant VInspector_ItemPrs3dAspect::initValue (int theItemRole) const
{
+ QVariant aParentValue = VInspector_ItemBase::initValue (theItemRole);
+ if (aParentValue.isValid())
+ return aParentValue;
+
if (theItemRole == Qt::DisplayRole || theItemRole == Qt::ToolTipRole)
{
Handle(Prs3d_BasicAspect) anAspect = GetAspect();
? (aNullAspect ? QVariant("Prs3d_BasicAspect is empty") : QVariant (anAspect->DynamicType()->Name()))
: QVariant (myName.ToCString());
}
- case 1:
- return rowCount();
- case 2:
- {
- if (!aNullAspect)
- return VInspector_Tools::GetPointerInfo (anAspect, true).ToCString();
- break;
- }
default: break;
}
}
QVariant VInspector_ItemPrs3dDrawer::initValue (int theItemRole) const
{
+ QVariant aParentValue = VInspector_ItemBase::initValue (theItemRole);
+ if (aParentValue.isValid())
+ return aParentValue;
+
Handle(Prs3d_Drawer) aDrawer = GetDrawer();
bool aNullDrawer = aDrawer.IsNull();
if (theItemRole == Qt::DisplayRole || theItemRole == Qt::ToolTipRole)
? (aNullDrawer ? QVariant("Prs3d_Drawer is empty") : QVariant (aDrawer->DynamicType()->Name()))
: QVariant (myName.ToCString());
}
- case 1:
- return rowCount();
- case 2:
- {
- if (!aNullDrawer)
- return VInspector_Tools::GetPointerInfo (aDrawer, true).ToCString();
- break;
- }
default: break;
}
}
// =======================================================================
QVariant VInspector_ItemPrs3dPresentation::initValue (int theItemRole) const
{
+ QVariant aParentValue = VInspector_ItemBase::initValue (theItemRole);
+ if (aParentValue.isValid())
+ return aParentValue;
+
if (Column() != 0 || (theItemRole != Qt::DisplayRole && theItemRole != Qt::ToolTipRole))
return QVariant();
// =======================================================================
QVariant VInspector_ItemSelect3DSensitiveSetItem::initValue (int theItemRole) const
{
+ QVariant aParentValue = VInspector_ItemBase::initValue (theItemRole);
+ if (aParentValue.isValid())
+ return aParentValue;
+
Handle(SelectBasics_SensitiveEntity) anEntity = GetSensitiveEntity();
if (anEntity.IsNull())
return QVariant();
// =======================================================================
QVariant VInspector_ItemSelectBasicsEntityOwner::initValue(int theItemRole) const
{
+ QVariant aParentValue = VInspector_ItemBase::initValue (theItemRole);
+ if (aParentValue.isValid())
+ return aParentValue;
+
switch (theItemRole)
{
case Qt::DisplayRole:
switch (Column())
{
case 0: return anOwner->DynamicType()->Name();
- case 2: return VInspector_Tools::GetPointerInfo (anOwner, true).ToCString();
- //case 3:
- //{
- // 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 17:
- //case 18:
- //case 19:
- // {
- // 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*/ ViewControl_Tools::ToString (aShape.Location()).ToCString();
- //}
- //case 21:
- // {
- // 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 ViewControl_Tools::ToString (BROwnr->Location()).ToCString();
- //}
- //default: break;
+ default: break;
}
break;
}
// =======================================================================
QVariant VInspector_ItemSelectBasicsSensitiveEntity::initValue (int theItemRole) const
{
+ QVariant aParentValue = VInspector_ItemBase::initValue (theItemRole);
+ if (aParentValue.isValid())
+ return aParentValue;
+
Handle(SelectBasics_SensitiveEntity) anEntity = GetSensitiveEntity();
if (anEntity.IsNull())
return QVariant();
--- /dev/null
+// Created on: 2019-02-04
+// Created by: Natalia ERMOLAEVA
+// Copyright (c) 2019 OPEN CASCADE SAS
+//
+// This file is part of Open CASCADE Technology software library.
+//
+// This library is free software; you can redistribute it and/or modify it under
+// the terms of the GNU Lesser General Public License version 2.1 as published
+// by the Free Software Foundation, with special exception defined in the file
+// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
+// distribution for complete text of the license and disclaimer of any warranty.
+//
+// Alternatively, this file may be used under the terms of Open CASCADE
+// commercial license or contractual agreement.
+
+#include <inspector/VInspector_ItemSelectMgrBaseFrustum.hxx>
+
+#include <inspector/VInspector_ItemSelectMgrSelectingVolumeManager.hxx>
+
+// =======================================================================
+// function : initRowCount
+// purpose :
+// =======================================================================
+int VInspector_ItemSelectMgrBaseFrustum::initRowCount() const
+{
+ if (Column() != 0)
+ return 0;
+
+ return 0;
+}
+
+// =======================================================================
+// function : initValue
+// purpose :
+// =======================================================================
+QVariant VInspector_ItemSelectMgrBaseFrustum::initValue (const int theItemRole) const
+{
+ QVariant aParentValue = VInspector_ItemBase::initValue (theItemRole);
+ if (aParentValue.isValid())
+ return aParentValue;
+
+ if (theItemRole != Qt::DisplayRole && theItemRole != Qt::EditRole && theItemRole != Qt::ToolTipRole)
+ return QVariant();
+
+ Handle (SelectMgr_BaseFrustum) aFrustum = GetFrustum();
+ if (aFrustum.IsNull())
+ return Column() == 0 ? "Empty frustum" : "";
+
+ switch (Column())
+ {
+ case 0: return aFrustum->DynamicType()->Name();
+ default:
+ break;
+ }
+ return QVariant();
+}
+
+// =======================================================================
+// function : Init
+// purpose :
+// =======================================================================
+
+void VInspector_ItemSelectMgrBaseFrustum::Init()
+{
+ VInspector_ItemSelectMgrSelectingVolumeManagerPtr aParentItem = itemDynamicCast<VInspector_ItemSelectMgrSelectingVolumeManager>(Parent());
+
+ Handle(SelectMgr_BaseFrustum) aFrustum;
+ if (aParentItem)
+ {
+ SelectMgr_SelectingVolumeManager aVolumeManager;
+ if (aParentItem->GetViewerSelector (aVolumeManager))
+ {
+ aFrustum = aVolumeManager.ActiveVolume();
+ }
+ }
+ setFrustum (aFrustum);
+
+ UpdatePresentationShape();
+ TreeModel_ItemBase::Init(); // to use getIO() without circling initialization
+}
+
+// =======================================================================
+// function : Reset
+// purpose :
+// =======================================================================
+
+void VInspector_ItemSelectMgrBaseFrustum::Reset()
+{
+ VInspector_ItemBase::Reset();
+
+ setFrustum (NULL);
+}
+
+// =======================================================================
+// function : initItem
+// purpose :
+// =======================================================================
+
+void VInspector_ItemSelectMgrBaseFrustum::initItem() const
+{
+ if (IsInitialized())
+ return;
+ const_cast<VInspector_ItemSelectMgrBaseFrustum*>(this)->Init();
+}
+
+// =======================================================================
+// function : GetTableRowCount
+// purpose :
+// =======================================================================
+int VInspector_ItemSelectMgrBaseFrustum::GetTableRowCount() const
+{
+ return 60;
+}
+
+// =======================================================================
+// function : GetTableData
+// purpose :
+// =======================================================================
+QVariant VInspector_ItemSelectMgrBaseFrustum::GetTableData (const int theRow, const int theColumn, const int theRole) const
+{
+ if (theRole != Qt::DisplayRole)
+ return QVariant();
+
+ Handle(SelectMgr_BaseFrustum) aView = GetFrustum();
+ if (aView.IsNull())
+ return QVariant();
+
+ //bool isFirstColumn = theColumn == 0;
+ //switch (theRow)
+ //{
+ // case 0:
+ // {
+ // if (isFirstColumn)
+ // return QVariant ("ImmediateUpdate");
+
+ // Standard_Boolean aCurState = aView->SetImmediateUpdate (Standard_False);
+ // aView->SetImmediateUpdate (aCurState);
+
+ // return aCurState;
+ // }
+ // break;
+ // case 1:
+ // {
+ // if (isFirstColumn)
+ // return QVariant ("ActiveLights");
+
+ // V3d_ListOfLightIterator aLightsIt = aView->ActiveLightIterator();
+ // Standard_Integer aNbOfLights = 0;
+ // while (aLightsIt.More())
+ // {
+ // aNbOfLights++;
+ // aLightsIt.Next();
+ // }
+ // return aNbOfLights;
+ // }
+ // case 2:
+ // {
+ // if (isFirstColumn)
+ // return QVariant ("Axis: origin");
+
+ // Standard_Real aX, anY, aZ, aVx, aVy, aVz;
+ // aView->Axis (aX, anY, aZ, aVx, aVy, aVz);
+
+ // return ViewControl_Tools::ToString (gp_Pnt (aX, anY, aZ)).ToCString();
+ // }
+ // case 3:
+ // {
+ // if (isFirstColumn)
+ // return QVariant ("Axis: direction");
+
+ // Standard_Real aX, anY, aZ, aVx, aVy, aVz;
+ // aView->Axis (aX, anY, aZ, aVx, aVy, aVz);
+
+ // return ViewControl_Tools::ToString (gp_Dir (aVx, aVy, aVz)).ToCString();
+ // }
+ // case 4: return isFirstColumn ? QVariant ("ComputedMode") : QVariant (aView->ComputedMode());
+ // case 5: return isFirstColumn ? QVariant ("AutoZFitMode") : QVariant (aView->AutoZFitMode());
+ // case 6: return isFirstColumn ? QVariant ("AutoZFitScaleFactor") : QVariant (aView->AutoZFitScaleFactor());
+ //}
+ return QVariant();
+}
+
+// =======================================================================
+// function : createChild
+// purpose :
+// =======================================================================
+TreeModel_ItemBasePtr VInspector_ItemSelectMgrBaseFrustum::createChild (int theRow, int theColumn)
+{
+ //if (theRow == 0)
+ // return VInspector_ItemGraphic3dCamera::CreateItem (currentItem(), theRow, theColumn);
+ //else if (theRow == 1)
+ // return VInspector_ItemAspectWindow::CreateItem (currentItem(), theRow, theColumn);
+ //else if (theRow == 2)
+ // return VInspector_ItemGraphic3dCView::CreateItem (currentItem(), theRow, theColumn);
+ //
+ return TreeModel_ItemBasePtr();
+}
--- /dev/null
+// Created on: 2019-02-04
+// Created by: Natalia ERMOLAEVA
+// Copyright (c) 2019 OPEN CASCADE SAS
+//
+// This file is part of Open CASCADE Technology software library.
+//
+// This library is free software; you can redistribute it and/or modify it under
+// the terms of the GNU Lesser General Public License version 2.1 as published
+// by the Free Software Foundation, with special exception defined in the file
+// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
+// distribution for complete text of the license and disclaimer of any warranty.
+//
+// Alternatively, this file may be used under the terms of Open CASCADE
+// commercial license or contractual agreement.
+
+#ifndef VInspector_ItemSelectMgrBaseFrustum_H
+#define VInspector_ItemSelectMgrBaseFrustum_H
+
+#include <Standard.hxx>
+#include <inspector/VInspector_ItemBase.hxx>
+
+#include <TopoDS_Shape.hxx>
+#include <SelectMgr_BaseFrustum.hxx>
+
+class VInspector_ItemSelectMgrBaseFrustum;
+typedef QExplicitlySharedDataPointer<VInspector_ItemSelectMgrBaseFrustum> VInspector_ItemSelectMgrBaseFrustumPtr;
+
+//! \class VInspector_ItemSelectMgrBaseFrustum
+//! Parent item, that corresponds Folder under the AIS_InteractiveContext
+//! Children of the item are: none
+class VInspector_ItemSelectMgrBaseFrustum : public VInspector_ItemBase
+{
+public:
+
+ //! Creates an item wrapped by a shared pointer
+ static VInspector_ItemSelectMgrBaseFrustumPtr CreateItem (TreeModel_ItemBasePtr theParent, const int theRow, const int theColumn)
+ { return VInspector_ItemSelectMgrBaseFrustumPtr (new VInspector_ItemSelectMgrBaseFrustum (theParent, theRow, theColumn)); }
+
+ //! Destructor
+ virtual ~VInspector_ItemSelectMgrBaseFrustum() Standard_OVERRIDE {};
+
+ //! Inits the item, fills internal containers
+ Standard_EXPORT virtual void Init() Standard_OVERRIDE;
+
+ //! Resets cached values
+ Standard_EXPORT virtual void Reset() Standard_OVERRIDE;
+
+ //! Returns data object of the item.
+ //! \return object
+ virtual Handle(Standard_Transient) GetObject() const { initItem(); return myFrustum; }
+
+ //! Returns current drawer, initialize the drawer if it was not initialized yet
+ Standard_EXPORT Handle(SelectMgr_BaseFrustum) GetFrustum() const
+ { return Handle(SelectMgr_BaseFrustum)::DownCast (GetObject()); }
+
+protected:
+ //! Initialize the current item. It is empty because Reset() is also empty.
+ virtual void initItem() const Standard_OVERRIDE;
+
+ //! Returns number of displayed presentations
+ //! \return rows count
+ Standard_EXPORT virtual int initRowCount() const Standard_OVERRIDE;
+
+ //! Returns item information for the given role. Fills internal container if it was not filled yet
+ //! \param theItemRole a value role
+ //! \return the value
+ Standard_EXPORT virtual QVariant initValue (const int theItemRole) const Standard_OVERRIDE;
+
+ //! Returns number of table rows
+ //! \return an integer value
+ virtual int GetTableRowCount() const Standard_OVERRIDE;
+
+ //! Returns table value for the row in form: <function name> <function value>
+ //! \param theRow a model index row
+ //! \param theColumn a model index column
+ virtual QVariant GetTableData (const int theRow, const int theColumn, const int theRole) const Standard_OVERRIDE;
+
+protected:
+
+ //! Creates a child item in the given position.
+ //! \param theRow the child row position
+ //! \param theColumn the child column position
+ //! \return the created item
+ virtual TreeModel_ItemBasePtr createChild (int theRow, int theColumn) Standard_OVERRIDE;
+
+private:
+
+ //! Set V3d viewer selector into the current field
+ //! \param theFrustum a viewer selector
+ void setFrustum (const Handle(SelectMgr_BaseFrustum)& theFrustum) { myFrustum = theFrustum; }
+
+private:
+
+ //! Constructor
+ //! param theParent a parent item
+ //! \param theRow the item row positition in the parent item
+ //! \param theColumn the item column positition in the parent item
+ VInspector_ItemSelectMgrBaseFrustum(TreeModel_ItemBasePtr theParent, const int theRow, const int theColumn)
+ : VInspector_ItemBase(theParent, theRow, theColumn) {}
+
+protected:
+
+ Handle(SelectMgr_BaseFrustum) myFrustum; //!< the current viewer selector
+};
+
+#endif
// =======================================================================
QVariant VInspector_ItemSelectMgrFilter::initValue (int theItemRole) const
{
+ QVariant aParentValue = VInspector_ItemBase::initValue (theItemRole);
+ if (aParentValue.isValid())
+ return aParentValue;
+
if (theItemRole == Qt::DisplayRole || theItemRole == Qt::ToolTipRole)
{
Handle(SelectMgr_Filter) aFilter = GetFilter();
{
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;
}
}
--- /dev/null
+// Created on: 2019-02-04
+// Created by: Natalia ERMOLAEVA
+// Copyright (c) 2019 OPEN CASCADE SAS
+//
+// This file is part of Open CASCADE Technology software library.
+//
+// This library is free software; you can redistribute it and/or modify it under
+// the terms of the GNU Lesser General Public License version 2.1 as published
+// by the Free Software Foundation, with special exception defined in the file
+// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
+// distribution for complete text of the license and disclaimer of any warranty.
+//
+// Alternatively, this file may be used under the terms of Open CASCADE
+// commercial license or contractual agreement.
+
+#include <inspector/VInspector_ItemSelectMgrSelectingVolumeManager.hxx>
+
+#include <inspector/VInspector_ItemSelectMgrViewerSelector.hxx>
+#include <inspector/VInspector_ItemSelectMgrBaseFrustum.hxx>
+
+#include <inspector/ViewControl_Tools.hxx>
+
+// =======================================================================
+// function : initRowCount
+// purpose :
+// =======================================================================
+int VInspector_ItemSelectMgrSelectingVolumeManager::initRowCount() const
+{
+ if (Column() != 0)
+ return 0;
+
+ return 1;
+}
+
+// =======================================================================
+// function : initValue
+// purpose :
+// =======================================================================
+QVariant VInspector_ItemSelectMgrSelectingVolumeManager::initValue (const int theItemRole) const
+{
+ QVariant aParentValue = VInspector_ItemBase::initValue (theItemRole);
+ if (aParentValue.isValid())
+ return aParentValue;
+
+ if (theItemRole != Qt::DisplayRole && theItemRole != Qt::EditRole && theItemRole != Qt::ToolTipRole)
+ return QVariant();
+
+ SelectMgr_SelectingVolumeManager aVolumeManager;
+ if (!GetViewerSelector (aVolumeManager))
+ return Column() == 0 ? "Empty volume manager" : "";
+
+ switch (Column())
+ {
+ case 0: return "SelectMgr_SelectingVolumeManager";
+ default:
+ break;
+ }
+ return QVariant();
+}
+
+// =======================================================================
+// function : Init
+// purpose :
+// =======================================================================
+
+void VInspector_ItemSelectMgrSelectingVolumeManager::Init()
+{
+ //VInspector_ItemFolderObjectPtr aParentItem = itemDynamicCast<VInspector_ItemFolderObject>(Parent());
+ //Handle(SelectMgr_SelectingVolumeManager) aVolumeMgr;
+ //if (aParentItem)
+ //{
+ // VInspector_ItemContextPtr aParentContextItem = itemDynamicCast<VInspector_ItemContext>(aParentItem->Parent());
+ // if (aParentContextItem)
+ // {
+ // Handle(AIS_InteractiveContext) aContext = aParentContextItem->GetContext();
+ // aVolumeMgr = aContext->MainSelector();
+ // }
+ //}
+ //setViewerSelector (aVolumeMgr);
+
+ //UpdatePresentationShape();
+ TreeModel_ItemBase::Init(); // to use getIO() without circling initialization
+}
+
+// =======================================================================
+// function : Reset
+// purpose :
+// =======================================================================
+
+void VInspector_ItemSelectMgrSelectingVolumeManager::Reset()
+{
+ VInspector_ItemBase::Reset();
+}
+
+// =======================================================================
+// function : initItem
+// purpose :
+// =======================================================================
+
+void VInspector_ItemSelectMgrSelectingVolumeManager::initItem() const
+{
+ if (IsInitialized())
+ return;
+ const_cast<VInspector_ItemSelectMgrSelectingVolumeManager*>(this)->Init();
+}
+
+// =======================================================================
+// function : GetTableRowCount
+// purpose :
+// =======================================================================
+Standard_Boolean VInspector_ItemSelectMgrSelectingVolumeManager::GetViewerSelector (SelectMgr_SelectingVolumeManager& theVolumeManager) const
+{
+ VInspector_ItemSelectMgrViewerSelectorPtr aParentItem = itemDynamicCast<VInspector_ItemSelectMgrViewerSelector>(Parent());
+
+ if (!aParentItem || aParentItem->GetViewerSelector().IsNull())
+ return Standard_False;
+
+ theVolumeManager = aParentItem->GetViewerSelector()->GetManager();
+ return Standard_True;
+}
+
+// =======================================================================
+// function : GetTableRowCount
+// purpose :
+// =======================================================================
+int VInspector_ItemSelectMgrSelectingVolumeManager::GetTableRowCount() const
+{
+ return 60;
+}
+
+// =======================================================================
+// function : GetTableData
+// purpose :
+// =======================================================================
+QVariant VInspector_ItemSelectMgrSelectingVolumeManager::GetTableData (const int theRow, const int theColumn, const int theRole) const
+{
+ if (theRole != Qt::DisplayRole)
+ return QVariant();
+
+ SelectMgr_SelectingVolumeManager aVolumeMgr;
+ if (!GetViewerSelector (aVolumeMgr))
+ return QVariant();
+
+ bool isFirstColumn = theColumn == 0;
+ switch (theRow)
+ {
+ case 0: return isFirstColumn ? QVariant ("GetActiveSelectionType") : QVariant (aVolumeMgr.GetActiveSelectionType());
+ case 1: return isFirstColumn ? QVariant ("IsOverlapAllowed()") : QVariant (aVolumeMgr.IsOverlapAllowed());
+ case 2: return isFirstColumn ? "GetNearPickedPnt" : ViewControl_Tools::ToString (aVolumeMgr.GetNearPickedPnt()).ToCString();
+ case 3: return isFirstColumn ? "GetFarPickedPnt" : ViewControl_Tools::ToString (aVolumeMgr.GetFarPickedPnt()).ToCString();
+ default: break;
+ }
+ return QVariant();
+}
+
+// =======================================================================
+// function : createChild
+// purpose :
+// =======================================================================
+TreeModel_ItemBasePtr VInspector_ItemSelectMgrSelectingVolumeManager::createChild (int theRow, int theColumn)
+{
+ if (theRow == 0)
+ return VInspector_ItemSelectMgrBaseFrustum::CreateItem (currentItem(), theRow, theColumn);
+ //else if (theRow == 1)
+ // return VInspector_ItemAspectWindow::CreateItem (currentItem(), theRow, theColumn);
+ //else if (theRow == 2)
+ // return VInspector_ItemGraphic3dCView::CreateItem (currentItem(), theRow, theColumn);
+ //
+ return TreeModel_ItemBasePtr();
+}
--- /dev/null
+// Created on: 2019-02-04
+// Created by: Natalia ERMOLAEVA
+// Copyright (c) 2019 OPEN CASCADE SAS
+//
+// This file is part of Open CASCADE Technology software library.
+//
+// This library is free software; you can redistribute it and/or modify it under
+// the terms of the GNU Lesser General Public License version 2.1 as published
+// by the Free Software Foundation, with special exception defined in the file
+// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
+// distribution for complete text of the license and disclaimer of any warranty.
+//
+// Alternatively, this file may be used under the terms of Open CASCADE
+// commercial license or contractual agreement.
+
+#ifndef VInspector_ItemSelectMgrSelectingVolumeManager_H
+#define VInspector_ItemSelectMgrSelectingVolumeManager_H
+
+#include <Standard.hxx>
+#include <inspector/VInspector_ItemBase.hxx>
+
+#include <TopoDS_Shape.hxx>
+#include <SelectMgr_SelectingVolumeManager.hxx>
+
+class VInspector_ItemSelectMgrSelectingVolumeManager;
+typedef QExplicitlySharedDataPointer<VInspector_ItemSelectMgrSelectingVolumeManager> VInspector_ItemSelectMgrSelectingVolumeManagerPtr;
+
+//! \class VInspector_ItemSelectMgrSelectingVolumeManager
+//! Parent item, that corresponds Folder under the AIS_InteractiveContext
+//! Children of the item are: none
+class VInspector_ItemSelectMgrSelectingVolumeManager : public VInspector_ItemBase
+{
+public:
+
+ //! Creates an item wrapped by a shared pointer
+ static VInspector_ItemSelectMgrSelectingVolumeManagerPtr CreateItem (TreeModel_ItemBasePtr theParent, const int theRow, const int theColumn)
+ { return VInspector_ItemSelectMgrSelectingVolumeManagerPtr (new VInspector_ItemSelectMgrSelectingVolumeManager (theParent, theRow, theColumn)); }
+
+ //! Destructor
+ virtual ~VInspector_ItemSelectMgrSelectingVolumeManager() Standard_OVERRIDE {};
+
+ //! Inits the item, fills internal containers
+ Standard_EXPORT virtual void Init() Standard_OVERRIDE;
+
+ //! Resets cached values
+ Standard_EXPORT virtual void Reset() Standard_OVERRIDE;
+
+ //! Returns data object of the item.
+ //! \return object
+ virtual Handle(Standard_Transient) GetObject() const { initItem(); return NULL; }
+
+ //! Returns current drawer, initialize the drawer if it was not initialized yet
+ Standard_EXPORT Standard_Boolean GetViewerSelector (SelectMgr_SelectingVolumeManager& theVolumeManager) const;
+
+protected:
+ //! Initialize the current item. It is empty because Reset() is also empty.
+ virtual void initItem() const Standard_OVERRIDE;
+
+ //! Returns number of displayed presentations
+ //! \return rows count
+ Standard_EXPORT virtual int initRowCount() const Standard_OVERRIDE;
+
+ //! Returns item information for the given role. Fills internal container if it was not filled yet
+ //! \param theItemRole a value role
+ //! \return the value
+ Standard_EXPORT virtual QVariant initValue (const int theItemRole) const Standard_OVERRIDE;
+
+ //! Returns number of table rows
+ //! \return an integer value
+ virtual int GetTableRowCount() const Standard_OVERRIDE;
+
+ //! Returns table value for the row in form: <function name> <function value>
+ //! \param theRow a model index row
+ //! \param theColumn a model index column
+ virtual QVariant GetTableData (const int theRow, const int theColumn, const int theRole) const Standard_OVERRIDE;
+
+protected:
+
+ //! Creates a child item in the given position.
+ //! \param theRow the child row position
+ //! \param theColumn the child column position
+ //! \return the created item
+ virtual TreeModel_ItemBasePtr createChild (int theRow, int theColumn) Standard_OVERRIDE;
+
+private:
+
+ //! Constructor
+ //! param theParent a parent item
+ //! \param theRow the item row positition in the parent item
+ //! \param theColumn the item column positition in the parent item
+ VInspector_ItemSelectMgrSelectingVolumeManager(TreeModel_ItemBasePtr theParent, const int theRow, const int theColumn)
+ : VInspector_ItemBase(theParent, theRow, theColumn) {}
+
+};
+
+#endif
// =======================================================================
QVariant VInspector_ItemSelectMgrSelection::initValue (int theItemRole) const
{
+ QVariant aParentValue = VInspector_ItemBase::initValue (theItemRole);
+ if (aParentValue.isValid())
+ return aParentValue;
+
switch (theItemRole)
{
case Qt::DisplayRole:
switch (Column())
{
case 0: return GetSelection()->DynamicType()->Name();
- case 1: return rowCount();
case 3:
{
if (theItemRole == Qt::ToolTipRole)
// =======================================================================
QVariant VInspector_ItemSelectMgrSensitiveEntity::initValue (int theItemRole) const
{
+ QVariant aParentValue = VInspector_ItemBase::initValue (theItemRole);
+ if (aParentValue.isValid())
+ return aParentValue;
+
Handle(SelectMgr_SensitiveEntity) anEntity = GetSensitiveEntity();
switch (theItemRole)
{
--- /dev/null
+// Created on: 2019-02-04
+// Created by: Natalia ERMOLAEVA
+// Copyright (c) 2019 OPEN CASCADE SAS
+//
+// This file is part of Open CASCADE Technology software library.
+//
+// This library is free software; you can redistribute it and/or modify it under
+// the terms of the GNU Lesser General Public License version 2.1 as published
+// by the Free Software Foundation, with special exception defined in the file
+// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
+// distribution for complete text of the license and disclaimer of any warranty.
+//
+// Alternatively, this file may be used under the terms of Open CASCADE
+// commercial license or contractual agreement.
+
+#include <inspector/VInspector_ItemSelectMgrViewerSelector.hxx>
+
+#include <inspector/VInspector_ItemSelectMgrSelectingVolumeManager.hxx>
+#include <inspector/VInspector_ItemSelectMgrViewerSelectorPicked.hxx>
+
+#include <inspector/VInspector_ItemFolderObject.hxx>
+#include <inspector/VInspector_ItemContext.hxx>
+
+#include <inspector/ViewControl_Table.hxx>
+#include <inspector/View_Tools.hxx>
+
+#include <BRep_Builder.hxx>
+#include <BRepBuilderAPI_MakeVertex.hxx>
+#include <TopoDS_Compound.hxx>
+
+#include <StdSelect_ViewerSelector3d.hxx>
+
+// =======================================================================
+// function : Constructor
+// purpose :
+// =======================================================================
+VInspector_ItemSelectMgrViewerSelector::VInspector_ItemSelectMgrViewerSelector (TreeModel_ItemBasePtr theParent,
+ const int theRow, const int theColumn)
+: VInspector_ItemBase(theParent, theRow, theColumn),
+ myXPix (150), myYPix (350), myXMinPix (150), myYMinPix (350), myXMaxPix (200), myYMaxPix (400)
+{
+}
+
+// =======================================================================
+// function : initRowCount
+// purpose :
+// =======================================================================
+int VInspector_ItemSelectMgrViewerSelector::initRowCount() const
+{
+ if (Column() != 0)
+ return 0;
+
+ Standard_Integer aNbRows = GetFirstChildOfPicked(); // SelectMgr_SelectingVolumeManager
+
+ Handle(SelectMgr_ViewerSelector) aViewSelector = GetViewerSelector();
+ if (!aViewSelector.IsNull())
+ {
+ for (Standard_Integer aDetIter = 1; aDetIter <= aViewSelector->NbPicked(); ++aDetIter)
+ {
+ aNbRows++;
+ //Handle(SelectMgr_EntityOwner) anOwner = aViewSelector->->Picked (aDetIter);
+ }
+ }
+ return aNbRows;
+}
+
+// =======================================================================
+// function : initValue
+// purpose :
+// =======================================================================
+QVariant VInspector_ItemSelectMgrViewerSelector::initValue (const int theItemRole) const
+{
+ QVariant aParentValue = VInspector_ItemBase::initValue (theItemRole);
+ if (aParentValue.isValid())
+ return aParentValue;
+
+ if (theItemRole != Qt::DisplayRole && theItemRole != Qt::EditRole && theItemRole != Qt::ToolTipRole)
+ return QVariant();
+
+ if (GetViewerSelector().IsNull())
+ return Column() == 0 ? "Empty viewer selector" : "";
+
+ switch (Column())
+ {
+ case 0: return GetViewerSelector()->DynamicType()->Name();
+ default:
+ break;
+ }
+ return QVariant();
+}
+
+// =======================================================================
+// function : Init
+// purpose :
+// =======================================================================
+
+void VInspector_ItemSelectMgrViewerSelector::Init()
+{
+ VInspector_ItemFolderObjectPtr aParentItem = itemDynamicCast<VInspector_ItemFolderObject>(Parent());
+ Handle(SelectMgr_ViewerSelector) aViewerSelector;
+ if (aParentItem)
+ {
+ VInspector_ItemContextPtr aParentContextItem = itemDynamicCast<VInspector_ItemContext>(aParentItem->Parent());
+ if (aParentContextItem)
+ {
+ Handle(AIS_InteractiveContext) aContext = aParentContextItem->GetContext();
+ aViewerSelector = aContext->MainSelector();
+ }
+ }
+ setViewerSelector (aViewerSelector);
+
+ UpdatePresentationShape();
+ TreeModel_ItemBase::Init(); // to use getIO() without circling initialization
+}
+
+// =======================================================================
+// function : Reset
+// purpose :
+// =======================================================================
+
+void VInspector_ItemSelectMgrViewerSelector::Reset()
+{
+ VInspector_ItemBase::Reset();
+
+ setViewerSelector (NULL);
+}
+
+// =======================================================================
+// function : initItem
+// purpose :
+// =======================================================================
+
+void VInspector_ItemSelectMgrViewerSelector::initItem() const
+{
+ if (IsInitialized())
+ return;
+ const_cast<VInspector_ItemSelectMgrViewerSelector*>(this)->Init();
+}
+
+// =======================================================================
+// function : GetTableRowCount
+// purpose :
+// =======================================================================
+int VInspector_ItemSelectMgrViewerSelector::GetTableRowCount() const
+{
+ return 60;
+}
+
+// =======================================================================
+// function : GetTableData
+// purpose :
+// =======================================================================
+QVariant VInspector_ItemSelectMgrViewerSelector::GetTableData (const int theRow, const int theColumn, const int theRole) const
+{
+ if (theRole != Qt::DisplayRole)
+ return QVariant();
+
+ Handle(SelectMgr_ViewerSelector) aViewerSelector = GetViewerSelector();
+ if (aViewerSelector.IsNull())
+ return QVariant();
+
+ bool isFirstColumn = theColumn == 0;
+ switch (theRow)
+ {
+ case 0: return isFirstColumn ? QVariant ("Sensitivity") : QVariant (aViewerSelector->Sensitivity());
+ case 1: return isFirstColumn ? QVariant ("IsPickClosest") : QVariant (aViewerSelector->IsPickClosest());
+ case 2: return isFirstColumn ? QVariant ("NbPicked") : QVariant (aViewerSelector->NbPicked());
+
+ case 3: return ViewControl_Table::SeparatorData();
+ case 4: return isFirstColumn ? QVariant ("ClearPicked") : QVariant ("DO");
+
+ case 5: return ViewControl_Table::SeparatorData();
+ case 6: return isFirstColumn ? QVariant ("X (pixel)") : QVariant (myXPix);
+ case 7: return isFirstColumn ? QVariant ("Y (pixel)") : QVariant (myYPix);
+ case 8: return isFirstColumn ? QVariant ("Pick") : QVariant ("DO");
+
+ case 9: return ViewControl_Table::SeparatorData();
+ case 10: return isFirstColumn ? QVariant ("X Min (pixel)") : QVariant (myXMinPix);
+ case 11: return isFirstColumn ? QVariant ("Y Min (pixel)") : QVariant (myXMinPix);
+ case 12: return isFirstColumn ? QVariant ("X Max (pixel)") : QVariant (myXMaxPix);
+ case 13: return isFirstColumn ? QVariant ("Y Max (pixel)") : QVariant (myYMaxPix);
+ case 14: return isFirstColumn ? QVariant ("Pick") : QVariant ("DO");
+
+ default: break;
+ }
+ return QVariant();
+}
+
+// =======================================================================
+// function : GetTableEditType
+// purpose :
+// =======================================================================
+ViewControl_EditType VInspector_ItemSelectMgrViewerSelector::GetTableEditType (const int theRow, const int) const
+{
+ switch (theRow)
+ {
+ case 4: return ViewControl_EditType_DoAction;
+ case 6: return ViewControl_EditType_Spin;
+ case 7: return ViewControl_EditType_Spin;
+ case 8: return ViewControl_EditType_DoAction;
+ case 10: return ViewControl_EditType_Spin;
+ case 11: return ViewControl_EditType_Spin;
+ case 12: return ViewControl_EditType_Spin;
+ case 13: return ViewControl_EditType_Spin;
+ case 14: return ViewControl_EditType_DoAction;
+ default: return ViewControl_EditType_None;
+ }
+}
+
+// =======================================================================
+// function : SetTableData
+// purpose :
+// =======================================================================
+bool VInspector_ItemSelectMgrViewerSelector::SetTableData (const int theRow, const int, const QVariant& theValue)
+{
+ Handle(SelectMgr_ViewerSelector) aViewerSelector = GetViewerSelector();
+ if (aViewerSelector.IsNull())
+ return Standard_False;
+
+ switch (theRow)
+ {
+ case 4: aViewerSelector->ClearPicked(); break;
+ case 6: myXPix = theValue.toInt();
+ case 7: myYPix = theValue.toInt();
+ case 8:
+ {
+ Handle(StdSelect_ViewerSelector3d) aSelector3d = Handle(StdSelect_ViewerSelector3d)::DownCast(aViewerSelector);
+ if (!aSelector3d.IsNull())
+ aSelector3d->Pick (myXPix, myYPix, View_Tools::FindActiveView (GetContext()));
+ break;
+ }
+ case 10: myXMinPix = theValue.toInt();
+ case 11: myXMinPix = theValue.toInt();
+ case 12: myXMaxPix = theValue.toInt();
+ case 13: myYMaxPix = theValue.toInt();
+ case 14:
+ {
+ Handle(StdSelect_ViewerSelector3d) aSelector3d = Handle(StdSelect_ViewerSelector3d)::DownCast(aViewerSelector);
+ if (!aSelector3d.IsNull())
+ aSelector3d->Pick (myXMinPix, myYMinPix, myXMaxPix, myYMaxPix, View_Tools::FindActiveView (GetContext()));
+ break;
+ }
+ default: break;
+ }
+ return Standard_True;
+}
+
+// =======================================================================
+// function : buildPresentationShape
+// purpose :
+// =======================================================================
+TopoDS_Shape VInspector_ItemSelectMgrViewerSelector::buildPresentationShape (const Handle(SelectMgr_ViewerSelector)& theViewSelector)
+{
+ if (theViewSelector.IsNull() || theViewSelector->NbPicked() == 0)
+ return TopoDS_Shape();
+
+ BRep_Builder aBuilder;
+ TopoDS_Compound aCompound;
+ aBuilder.MakeCompound (aCompound);
+
+ for (Standard_Integer aRankId = 1; aRankId <= theViewSelector->NbPicked(); ++aRankId)
+ aBuilder.Add (aCompound, BRepBuilderAPI_MakeVertex (theViewSelector->PickedPoint (aRankId)));
+
+ return aCompound;
+}
+
+// =======================================================================
+// function : createChild
+// purpose :
+// =======================================================================
+TreeModel_ItemBasePtr VInspector_ItemSelectMgrViewerSelector::createChild (int theRow, int theColumn)
+{
+ if (theRow == 0)
+ return VInspector_ItemSelectMgrSelectingVolumeManager::CreateItem (currentItem(), theRow, theColumn);
+ else
+ return VInspector_ItemSelectMgrViewerSelectorPicked::CreateItem (currentItem(), theRow, theColumn);
+ //else if (theRow == 1)
+ // return VInspector_ItemAspectWindow::CreateItem (currentItem(), theRow, theColumn);
+ //else if (theRow == 2)
+ // return VInspector_ItemGraphic3dCView::CreateItem (currentItem(), theRow, theColumn);
+ //
+ return TreeModel_ItemBasePtr();
+}
--- /dev/null
+// Created on: 2019-02-04
+// Created by: Natalia ERMOLAEVA
+// Copyright (c) 2019 OPEN CASCADE SAS
+//
+// This file is part of Open CASCADE Technology software library.
+//
+// This library is free software; you can redistribute it and/or modify it under
+// the terms of the GNU Lesser General Public License version 2.1 as published
+// by the Free Software Foundation, with special exception defined in the file
+// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
+// distribution for complete text of the license and disclaimer of any warranty.
+//
+// Alternatively, this file may be used under the terms of Open CASCADE
+// commercial license or contractual agreement.
+
+#ifndef VInspector_ItemSelectMgrViewerSelector_H
+#define VInspector_ItemSelectMgrViewerSelector_H
+
+#include <Standard.hxx>
+#include <inspector/VInspector_ItemBase.hxx>
+
+#include <TopoDS_Shape.hxx>
+#include <SelectMgr_ViewerSelector.hxx>
+
+class VInspector_ItemSelectMgrViewerSelector;
+typedef QExplicitlySharedDataPointer<VInspector_ItemSelectMgrViewerSelector> VInspector_ItemSelectMgrViewerSelectorPtr;
+
+//! \class VInspector_ItemSelectMgrViewerSelector
+//! Parent item, that corresponds Folder under the AIS_InteractiveContext
+//! Children of the item are: none
+class VInspector_ItemSelectMgrViewerSelector : public VInspector_ItemBase
+{
+public:
+
+ //! Creates an item wrapped by a shared pointer
+ static VInspector_ItemSelectMgrViewerSelectorPtr CreateItem (TreeModel_ItemBasePtr theParent, const int theRow, const int theColumn)
+ { return VInspector_ItemSelectMgrViewerSelectorPtr (new VInspector_ItemSelectMgrViewerSelector (theParent, theRow, theColumn)); }
+
+ //! Destructor
+ virtual ~VInspector_ItemSelectMgrViewerSelector() Standard_OVERRIDE {};
+
+ //! Inits the item, fills internal containers
+ Standard_EXPORT virtual void Init() Standard_OVERRIDE;
+
+ //! Resets cached values
+ Standard_EXPORT virtual void Reset() Standard_OVERRIDE;
+
+ //! Returns data object of the item.
+ //! \return object
+ virtual Handle(Standard_Transient) GetObject() const { initItem(); return myViewerSelector; }
+
+ //! Returns current drawer, initialize the drawer if it was not initialized yet
+ Standard_EXPORT Handle(SelectMgr_ViewerSelector) GetViewerSelector() const
+ { return Handle(SelectMgr_ViewerSelector)::DownCast (GetObject()); }
+
+ //! Returns the span from the 0 row to the first item corresponded to the picked item
+ //! the 0 item is SelectMgr_SelectingVolumeManager
+ Standard_Integer GetFirstChildOfPicked() const { return 1; }
+protected:
+ //! Initialize the current item. It is empty because Reset() is also empty.
+ virtual void initItem() const Standard_OVERRIDE;
+
+ //! Returns number of displayed presentations
+ //! \return rows count
+ Standard_EXPORT virtual int initRowCount() const Standard_OVERRIDE;
+
+ //! Returns item information for the given role. Fills internal container if it was not filled yet
+ //! \param theItemRole a value role
+ //! \return the value
+ Standard_EXPORT virtual QVariant initValue (const int theItemRole) const Standard_OVERRIDE;
+
+ //! Returns number of table rows
+ //! \return an integer value
+ virtual int GetTableRowCount() const Standard_OVERRIDE;
+
+ //! Returns table value for the row in form: <function name> <function value>
+ //! \param theRow a model index row
+ //! \param theColumn a model index column
+ virtual QVariant GetTableData (const int theRow, const int theColumn, const int theRole) const Standard_OVERRIDE;
+
+ //! Returns type of edit control for the model index. By default, it is an empty control
+ //! \param theRow a model index row
+ //! \param theColumn a model index column
+ //! \return edit type
+ virtual ViewControl_EditType GetTableEditType (const int theRow, const int theColumn) const Standard_OVERRIDE;
+
+ //! Sets the value into the table cell. Only 1st column value might be modified.
+ //! \param theRow a model index row
+ //! \param theColumn a model index column
+ //! \param theValue a new cell value
+ virtual bool SetTableData (const int theRow, const int theColumn, const QVariant& theValue) Standard_OVERRIDE;
+
+protected:
+
+ //! Build presentation shape
+ //! \return generated shape of the item parameters
+ virtual TopoDS_Shape buildPresentationShape() Standard_OVERRIDE { return buildPresentationShape (myViewerSelector); }
+
+ //! Creates shape for the 3d viewer selector parameters
+ //! \param theViewerSelector current viewer selector
+ //! \return shape or NULL
+ static TopoDS_Shape buildPresentationShape (const Handle(SelectMgr_ViewerSelector)& theViewerSelector);
+
+protected:
+
+ //! Creates a child item in the given position.
+ //! \param theRow the child row position
+ //! \param theColumn the child column position
+ //! \return the created item
+ virtual TreeModel_ItemBasePtr createChild (int theRow, int theColumn) Standard_OVERRIDE;
+
+private:
+
+ //! Set V3d viewer selector into the current field
+ //! \param theViewerSelector a viewer selector
+ void setViewerSelector (const Handle(SelectMgr_ViewerSelector)& theViewerSelector) { myViewerSelector = theViewerSelector; }
+
+private:
+
+ //! Constructor
+ //! param theParent a parent item
+ //! \param theRow the item row positition in the parent item
+ //! \param theColumn the item column positition in the parent item
+ VInspector_ItemSelectMgrViewerSelector(TreeModel_ItemBasePtr theParent, const int theRow, const int theColumn);
+
+private:
+
+ Handle(SelectMgr_ViewerSelector) myViewerSelector; //!< the current viewer selector
+
+ Standard_Integer myXPix; //!< cached value for picked X
+ Standard_Integer myYPix; //!< cached value for picked Y
+
+ Standard_Integer myXMinPix; //!< cached value for min value of picked X
+ Standard_Integer myYMinPix; //!< cached value for min value of picked Y
+
+ Standard_Integer myXMaxPix; //!< cached value for max value of picked X
+ Standard_Integer myYMaxPix; //!< cached value for max value of picked Y
+};
+
+#endif
--- /dev/null
+// Created on: 2019-02-04
+// Created by: Natalia ERMOLAEVA
+// Copyright (c) 2019 OPEN CASCADE SAS
+//
+// This file is part of Open CASCADE Technology software library.
+//
+// This library is free software; you can redistribute it and/or modify it under
+// the terms of the GNU Lesser General Public License version 2.1 as published
+// by the Free Software Foundation, with special exception defined in the file
+// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
+// distribution for complete text of the license and disclaimer of any warranty.
+//
+// Alternatively, this file may be used under the terms of Open CASCADE
+// commercial license or contractual agreement.
+
+#include <inspector/VInspector_ItemSelectMgrViewerSelectorPicked.hxx>
+
+#include <inspector/VInspector_ItemSelectMgrViewerSelector.hxx>
+#include <inspector/VInspector_Tools.hxx>
+#include <inspector/ViewControl_Tools.hxx>
+
+#include <BRepBuilderAPI_MakeVertex.hxx>
+#include <BRep_Builder.hxx>
+#include <TopoDS_Compound.hxx>
+
+// =======================================================================
+// function : initRowCount
+// purpose :
+// =======================================================================
+int VInspector_ItemSelectMgrViewerSelectorPicked::initRowCount() const
+{
+ if (Column() != 0)
+ return 0;
+
+ return 0;
+}
+
+// =======================================================================
+// function : initValue
+// purpose :
+// =======================================================================
+QVariant VInspector_ItemSelectMgrViewerSelectorPicked::initValue (const int theItemRole) const
+{
+ QVariant aParentValue = VInspector_ItemBase::initValue (theItemRole);
+ if (aParentValue.isValid())
+ return aParentValue;
+
+ if (theItemRole != Qt::DisplayRole && theItemRole != Qt::EditRole && theItemRole != Qt::ToolTipRole)
+ return QVariant();
+
+ Standard_Integer aRankId;
+ Handle(SelectMgr_ViewerSelector) aViewerSelector = GetViewerSelector (aRankId);
+ if (aViewerSelector.IsNull())
+ return Column() == 0 ? "Empty viewer selector" : "";
+
+ switch (Column())
+ {
+ case 0:
+ {
+ TCollection_AsciiString aValue = TCollection_AsciiString (aRankId) + " - " +
+ VInspector_Tools::GetPointerInfo (aViewerSelector->Picked (aRankId));
+ return aValue.ToCString();
+ }
+ default:
+ break;
+ }
+ return QVariant();
+}
+
+// =======================================================================
+// function : Init
+// purpose :
+// =======================================================================
+
+void VInspector_ItemSelectMgrViewerSelectorPicked::Init()
+{
+ UpdatePresentationShape();
+ TreeModel_ItemBase::Init(); // to use getIO() without circling initialization
+}
+
+// =======================================================================
+// function : Reset
+// purpose :
+// =======================================================================
+
+void VInspector_ItemSelectMgrViewerSelectorPicked::Reset()
+{
+ VInspector_ItemBase::Reset();
+}
+
+// =======================================================================
+// function : initItem
+// purpose :
+// =======================================================================
+
+void VInspector_ItemSelectMgrViewerSelectorPicked::initItem() const
+{
+ if (IsInitialized())
+ return;
+ const_cast<VInspector_ItemSelectMgrViewerSelectorPicked*>(this)->Init();
+}
+
+// =======================================================================
+// function : GetTableRowCount
+// purpose :
+// =======================================================================
+Handle(SelectMgr_ViewerSelector) VInspector_ItemSelectMgrViewerSelectorPicked::GetViewerSelector (Standard_Integer& theRankId) const
+{
+ VInspector_ItemSelectMgrViewerSelectorPtr aParentItem = itemDynamicCast<VInspector_ItemSelectMgrViewerSelector>(Parent());
+ if (!aParentItem)
+ return NULL;
+
+ Handle(SelectMgr_ViewerSelector) aViewerSelector = aParentItem->GetViewerSelector();
+ theRankId = Row() + 1 - aParentItem->GetFirstChildOfPicked();
+ if (theRankId > aViewerSelector->NbPicked())
+ return NULL;
+
+ return aViewerSelector;
+}
+
+// =======================================================================
+// function : GetTableRowCount
+// purpose :
+// =======================================================================
+int VInspector_ItemSelectMgrViewerSelectorPicked::GetTableRowCount() const
+{
+ return 60;
+}
+
+// =======================================================================
+// function : GetTableData
+// purpose :
+// =======================================================================
+QVariant VInspector_ItemSelectMgrViewerSelectorPicked::GetTableData (const int theRow, const int theColumn, const int theRole) const
+{
+ if (theRole != Qt::DisplayRole && theRole != Qt::ToolTipRole)
+ return QVariant();
+
+ Standard_Integer aRankId;
+ Handle(SelectMgr_ViewerSelector) aViewerSelector = GetViewerSelector (aRankId);
+ if (aViewerSelector.IsNull())
+ return QVariant();
+
+ bool isFirstColumn = theColumn == 0;
+ switch (theRow)
+ {
+ case 0: return isFirstColumn ? "Picked" :
+ (theRole == Qt::DisplayRole ? VInspector_Tools::GetPointerInfo (aViewerSelector->Picked (aRankId)).ToCString()
+ : aViewerSelector->Picked (aRankId)->DynamicType()->Name());
+ case 1: return isFirstColumn ? "PickedEntity" :
+ (theRole == Qt::DisplayRole ? VInspector_Tools::GetPointerInfo (aViewerSelector->PickedEntity (aRankId)).ToCString()
+ : aViewerSelector->PickedEntity (aRankId)->DynamicType()->Name());
+ case 2: return isFirstColumn ? "PickedPoint" : ViewControl_Tools::ToString (aViewerSelector->PickedPoint (aRankId)).ToCString();
+
+ default: break;
+ }
+ Standard_Integer aLastIndex = 2;
+
+ if (theRow > aLastIndex)
+ return getTableSortCriterionData (theRow - (aLastIndex + 1), theColumn, theRole);
+
+ return QVariant();
+}
+
+// =======================================================================
+// function : getTableSortCriterionData
+// purpose :
+// =======================================================================
+QVariant VInspector_ItemSelectMgrViewerSelectorPicked::getTableSortCriterionData (const Standard_Integer theIndex,
+ const int theColumn, const int theRole) const
+{
+ Standard_Integer aRankId;
+ Handle(SelectMgr_ViewerSelector) aViewerSelector = GetViewerSelector (aRankId);
+ if (aViewerSelector.IsNull())
+ return QVariant();
+
+ const SelectMgr_SortCriterion& aCriterion = aViewerSelector->PickedData (aRankId);
+ bool isFirstColumn = theColumn == 0;
+ switch (theIndex)
+ {
+ case 0: return isFirstColumn ? QVariant ("Depth") : QVariant (aCriterion.Depth);
+ case 1: return isFirstColumn ? QVariant ("MinDist") : QVariant (aCriterion.MinDist);
+ case 2: return isFirstColumn ? QVariant ("Tolerance") : QVariant (aCriterion.Tolerance);
+ case 3: return isFirstColumn ? QVariant ("Priority") : QVariant (aCriterion.Priority);
+ case 4: return isFirstColumn ? QVariant ("ZLayerPosition") : QVariant (aCriterion.ZLayerPosition);
+ case 5: return isFirstColumn ? QVariant ("NbOwnerMatches") : QVariant (aCriterion.NbOwnerMatches);
+ case 6: return isFirstColumn ? QVariant ("ToPreferClosest") : QVariant (aCriterion.ToPreferClosest);
+ default: break;
+ }
+ return QVariant();
+}
+
+// =======================================================================
+// function : buildPresentationShape
+// purpose :
+// =======================================================================
+TopoDS_Shape VInspector_ItemSelectMgrViewerSelectorPicked::buildPresentationShape()
+{
+ Standard_Integer aRankId;
+ Handle(SelectMgr_ViewerSelector) aViewerSelector = GetViewerSelector (aRankId);
+ return buildPresentationShape (aViewerSelector, aRankId);
+}
+
+// =======================================================================
+// function : buildPresentationShape
+// purpose :
+// =======================================================================
+TopoDS_Shape VInspector_ItemSelectMgrViewerSelectorPicked::buildPresentationShape (const Handle(SelectMgr_ViewerSelector)& theViewSelector,
+ const Standard_Integer theRowId)
+{
+ if (theViewSelector.IsNull() || theRowId + 1 > theViewSelector->NbPicked())
+ return TopoDS_Shape();
+
+ BRep_Builder aBuilder;
+ TopoDS_Compound aCompound;
+ aBuilder.MakeCompound (aCompound);
+
+ Standard_Integer aRankId = theRowId + 1;
+ aBuilder.Add (aCompound, BRepBuilderAPI_MakeVertex (theViewSelector->PickedPoint (aRankId)));
+
+ return aCompound;
+}
+
+// =======================================================================
+// function : createChild
+// purpose :
+// =======================================================================
+TreeModel_ItemBasePtr VInspector_ItemSelectMgrViewerSelectorPicked::createChild (int, int)
+{
+ //if (theRow == 0)
+ // return VInspector_ItemGraphic3dCamera::CreateItem (currentItem(), theRow, theColumn);
+ //else if (theRow == 1)
+ // return VInspector_ItemAspectWindow::CreateItem (currentItem(), theRow, theColumn);
+ //else if (theRow == 2)
+ // return VInspector_ItemGraphic3dCView::CreateItem (currentItem(), theRow, theColumn);
+ //
+ return TreeModel_ItemBasePtr();
+}
--- /dev/null
+// Created on: 2019-02-04
+// Created by: Natalia ERMOLAEVA
+// Copyright (c) 2019 OPEN CASCADE SAS
+//
+// This file is part of Open CASCADE Technology software library.
+//
+// This library is free software; you can redistribute it and/or modify it under
+// the terms of the GNU Lesser General Public License version 2.1 as published
+// by the Free Software Foundation, with special exception defined in the file
+// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
+// distribution for complete text of the license and disclaimer of any warranty.
+//
+// Alternatively, this file may be used under the terms of Open CASCADE
+// commercial license or contractual agreement.
+
+#ifndef VInspector_ItemSelectMgrViewerSelectorPicked_H
+#define VInspector_ItemSelectMgrViewerSelectorPicked_H
+
+#include <Standard.hxx>
+#include <inspector/VInspector_ItemBase.hxx>
+
+#include <TopoDS_Shape.hxx>
+#include <SelectMgr_ViewerSelector.hxx>
+
+class VInspector_ItemSelectMgrViewerSelectorPicked;
+typedef QExplicitlySharedDataPointer<VInspector_ItemSelectMgrViewerSelectorPicked> VInspector_ItemSelectMgrViewerSelectorPickedPtr;
+
+//! \class VInspector_ItemSelectMgrViewerSelectorPicked
+//! Parent item, that corresponds Folder under the AIS_InteractiveContext
+//! Children of the item are: none
+class VInspector_ItemSelectMgrViewerSelectorPicked : public VInspector_ItemBase
+{
+public:
+
+ //! Creates an item wrapped by a shared pointer
+ static VInspector_ItemSelectMgrViewerSelectorPickedPtr CreateItem (TreeModel_ItemBasePtr theParent, const int theRow, const int theColumn)
+ { return VInspector_ItemSelectMgrViewerSelectorPickedPtr (new VInspector_ItemSelectMgrViewerSelectorPicked (theParent, theRow, theColumn)); }
+
+ //! Destructor
+ virtual ~VInspector_ItemSelectMgrViewerSelectorPicked() Standard_OVERRIDE {};
+
+ //! Inits the item, fills internal containers
+ Standard_EXPORT virtual void Init() Standard_OVERRIDE;
+
+ //! Resets cached values
+ Standard_EXPORT virtual void Reset() Standard_OVERRIDE;
+
+ //! Returns data object of the item.
+ //! \return object
+ virtual Handle(Standard_Transient) GetObject() const { initItem(); return NULL; }
+
+ //! Returns viewer selector of the parent and index of rank inside the parent
+ //! \param theRankId rank of the item inside viewer selector
+ Standard_EXPORT Handle(SelectMgr_ViewerSelector) GetViewerSelector (Standard_Integer& theRankId) const;
+
+protected:
+ //! Initialize the current item. It is empty because Reset() is also empty.
+ virtual void initItem() const Standard_OVERRIDE;
+
+ //! Returns number of displayed presentations
+ //! \return rows count
+ Standard_EXPORT virtual int initRowCount() const Standard_OVERRIDE;
+
+ //! Returns item information for the given role. Fills internal container if it was not filled yet
+ //! \param theItemRole a value role
+ //! \return the value
+ Standard_EXPORT virtual QVariant initValue (const int theItemRole) const Standard_OVERRIDE;
+
+ //! Returns number of table rows
+ //! \return an integer value
+ virtual int GetTableRowCount() const Standard_OVERRIDE;
+
+ //! Returns table value for the row in form: <function name> <function value>
+ //! \param theRow a model index row
+ //! \param theColumn a model index column
+ virtual QVariant GetTableData (const int theRow, const int theColumn, const int theRole) const Standard_OVERRIDE;
+
+protected:
+ //! Returns table value of SelectMgr_SortCriterion
+ QVariant getTableSortCriterionData (const Standard_Integer theIndex, const int theColumn, const int theRole) const;
+
+ //! Build presentation shape
+ //! \return generated shape of the item parameters
+ virtual TopoDS_Shape buildPresentationShape() Standard_OVERRIDE;
+
+ //! Creates shape for the 3d viewer selector parameters
+ //! \param theViewerSelector current viewer selector
+ //! \param theRowId index of the item row, theRank - 1 value inside viewer selector
+ //! \return shape or NULL
+ static TopoDS_Shape buildPresentationShape (const Handle(SelectMgr_ViewerSelector)& theViewerSelector,
+ const Standard_Integer theRowId);
+
+protected:
+
+ //! Creates a child item in the given position.
+ //! \param theRow the child row position
+ //! \param theColumn the child column position
+ //! \return the created item
+ virtual TreeModel_ItemBasePtr createChild (int theRow, int theColumn) Standard_OVERRIDE;
+
+private:
+
+private:
+
+ //! Constructor
+ //! param theParent a parent item
+ //! \param theRow the item row positition in the parent item
+ //! \param theColumn the item column positition in the parent item
+ VInspector_ItemSelectMgrViewerSelectorPicked(TreeModel_ItemBasePtr theParent, const int theRow, const int theColumn)
+ : VInspector_ItemBase(theParent, theRow, theColumn) {}
+};
+
+#endif
// =======================================================================
QVariant VInspector_ItemV3dView::initValue (const int theItemRole) const
{
+ QVariant aParentValue = VInspector_ItemBase::initValue (theItemRole);
+ if (aParentValue.isValid())
+ return aParentValue;
+
if (theItemRole != Qt::DisplayRole && theItemRole != Qt::EditRole && theItemRole != Qt::ToolTipRole)
return QVariant();
switch (Column())
{
case 0: return GetView()->DynamicType()->Name();
- case 1: return rowCount();
default:
break;
}
// =======================================================================
QVariant VInspector_ItemV3dViewer::initValue (const int theItemRole) const
{
+ QVariant aParentValue = VInspector_ItemBase::initValue (theItemRole);
+ if (aParentValue.isValid())
+ return aParentValue;
+
if (theItemRole != Qt::DisplayRole && theItemRole != Qt::EditRole && theItemRole != Qt::ToolTipRole)
return QVariant();
switch (Column())
{
case 0: return GetViewer()->DynamicType()->Name();
- case 1: return rowCount();
default:
break;
}
#include <inspector/VInspector_TableModelValues.hxx>
#include <inspector/ViewControl_Pane.hxx>
+#include <inspector/ViewControl_PaneItem.hxx>
#include <inspector/ViewControl_TableModel.hxx>
#include <inspector/VInspector_Tools.hxx>
return aFlags;
}
+// =======================================================================
+// function : RowCount
+// purpose :
+// =======================================================================
+
+int VInspector_TableModelValues::RowCount (const QModelIndex& theParent) const
+{
+ VInspector_ItemBasePtr anItem = GetItem();
+
+ int aRowCount = anItem->GetTableRowCount();
+ Handle(Standard_Transient) anObject = anItem->GetObject();
+ if (anObject.IsNull())
+ return aRowCount;
+
+ for (NCollection_List<Handle(ViewControl_PaneCreator)>::Iterator anIterator (myCreators); anIterator.More(); anIterator.Next())
+ {
+ Handle(ViewControl_PaneCreator) aCreator = anIterator.Value();
+ ViewControl_Pane* aPane = aCreator->GetPane (anObject->DynamicType()->Name());
+ if (!aPane)
+ continue;
+ aRowCount += aPane->GetTableRowCount (anObject);
+ }
+ return aRowCount;
+}
+
// =======================================================================
// function : GetEditType
// purpose :
return anItem->GetTableEnumValues (aCurrentRow, theColumn);
}
+// =======================================================================
+// function : GetPaneShapes
+// purpose :
+// =======================================================================
+
+void VInspector_TableModelValues::GetPaneShapes (const int theRow, const int theColumn, NCollection_List<TopoDS_Shape>& theShapes)
+{
+ VInspector_ItemBasePtr anItem = GetItem();
+ Handle(Standard_Transient) anObject = anItem->GetObject();
+ if (anObject.IsNull())
+ return;
+
+ for (NCollection_List<Handle(ViewControl_PaneCreator)>::Iterator anIterator (myCreators); anIterator.More(); anIterator.Next())
+ {
+ Handle(ViewControl_PaneCreator) aCreator = anIterator.Value();
+ ViewControl_Pane* aPane = aCreator->GetPane (anObject->DynamicType()->Name());
+ if (!aPane)
+ continue;
+
+ ViewControl_PaneItem* anItem = aPane->GetSelected (anObject, theRow, theColumn);
+ if (anItem && !anItem->GetShape().IsNull())
+ theShapes.Append (anItem->GetShape());
+ }
+}
+
// =======================================================================
// function : GetItem
// purpose :
//! Returns number of columns. It has two columns: <funciton name> <function value>
//! \param theParent an index of the parent item
//! \return an integer value
- Standard_EXPORT virtual int ColumnCount (const QModelIndex& theParent = QModelIndex()) const
+ Standard_EXPORT virtual int ColumnCount (const QModelIndex& theParent = QModelIndex()) const Standard_OVERRIDE
{ (void)theParent; return 2; }
+ //! Returns number of rows, depending on orientation: myColumnCount or size of values container
+ //! \param theParent an index of the parent item
+ //! \return an integer value
+ Standard_EXPORT virtual int RowCount (const QModelIndex& theParent = QModelIndex()) const Standard_OVERRIDE;
+
//! Returns content of the model index for the given role, it is obtained from internal container of values
//! It returns value only for DisplayRole.
//! \param theRow a model index row
//! \param theColumn a model index column
//! \param theRole a view role
//! \return value intepreted depending on the given role
- Standard_EXPORT virtual QVariant Data (const int theRow, const int theColumn, int theRole = Qt::DisplayRole) const;
+ Standard_EXPORT virtual QVariant Data (const int theRow, const int theColumn, int theRole = Qt::DisplayRole) const Standard_OVERRIDE;
//! Sets content of the model index for the given role, it is applyed to internal container of values
//! \param theRow a model index row
//! \param theRole a view role
//! \return true if the value is changed
Standard_EXPORT virtual bool SetData (const int theRow, const int theColumn, const QVariant& theValue,
- int theRole = Qt::DisplayRole);
+ int theRole = Qt::DisplayRole) Standard_OVERRIDE;
//! Returns flags for the item: ItemIsEnabled | Qt::ItemIsSelectable.
//! Additional flag for the column 1 is Qt::ItemIsEditable.
//! \return string values for the enumeration presented in the row or an empty container
virtual QList<QVariant> GetEnumValues (const int theRow, const int theColumn) const Standard_OVERRIDE;
+ //! Returns container of pane shapes
+ //! \param theRow table model row index
+ //! \param theColumn a model index column
+ //! \param [out] output container of shapes to add pane new shapes if found
+ Standard_EXPORT void GetPaneShapes (const int theRow, const int theColumn, NCollection_List<TopoDS_Shape>& theShapes);
+
private:
//!< Returns source item base
// =======================================================================
TCollection_AsciiString VInspector_Tools::GetPointerInfo (const Handle(Standard_Transient)& thePointer, const bool isShortInfo)
{
+ if (!thePointer.operator->())
+ return "";
+
std::ostringstream aPtrStr;
aPtrStr << thePointer.operator->();
if (!isShortInfo)
//=======================================================================
TopoDS_Shape VInspector_Tools::CreateShape (const Bnd_Box& theBoundingBox)
{
- if (theBoundingBox.IsVoid() || theBoundingBox.IsWhole() ||
- theBoundingBox.IsXThin (Precision::Confusion()) ||
- theBoundingBox.IsYThin (Precision::Confusion()) ||
- theBoundingBox.IsZThin (Precision::Confusion()))
- 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();
+ if (theBoundingBox.IsVoid() || theBoundingBox.IsWhole())
+ return TopoDS_Shape();
+
+ Standard_Real aXmin, anYmin, aZmin, aXmax, anYmax, aZmax;
+ theBoundingBox.Get (aXmin, anYmin, aZmin, aXmax, anYmax, aZmax);
+
+ gp_Pnt aPntMin = gp_Pnt (aXmin, anYmin, aZmin);
+ gp_Pnt aPntMax = gp_Pnt (aXmax, anYmax, aZmax);
+
+ return CreateBoxShape (aPntMin, aPntMax);
}
//=======================================================================
gp_Pnt aPntMin = gp_Pnt (theBoundingBox.CornerMin().x(), theBoundingBox.CornerMin().y(), theBoundingBox.CornerMin().z());
gp_Pnt aPntMax = gp_Pnt (theBoundingBox.CornerMax().x(), theBoundingBox.CornerMax().y(), theBoundingBox.CornerMax().z());
- 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();
+ return CreateBoxShape (aPntMin, aPntMax);
+}
+
+//=======================================================================
+//function : CreateBoxShape
+//purpose :
+//=======================================================================
+TopoDS_Shape VInspector_Tools::CreateBoxShape (const gp_Pnt& thePntMin, const gp_Pnt& thePntMax)
+{
+ Standard_Boolean aThinOnX = fabs (thePntMin.X() - thePntMax.X()) < Precision::Confusion();
+ Standard_Boolean aThinOnY = fabs (thePntMin.Y() - thePntMax.Y()) < Precision::Confusion();
+ Standard_Boolean aThinOnZ = fabs (thePntMin.Z() - thePntMax.Z()) < Precision::Confusion();
if (((int)aThinOnX + (int)aThinOnY + (int)aThinOnZ) > 1) // thin box in several directions is a point
{
BRep_Builder aBuilder;
TopoDS_Compound aCompound;
aBuilder.MakeCompound (aCompound);
- aBuilder.Add (aCompound, BRepBuilderAPI_MakeVertex (aPntMin));
+ aBuilder.Add (aCompound, BRepBuilderAPI_MakeVertex (thePntMin));
return aCompound;
}
gp_Pnt aPnt1, aPnt2, aPnt3, aPnt4 ;
if (aThinOnX)
{
- aPnt1 = gp_Pnt(aPntMin.X(), aPntMin.Y(), aPntMin.Z());
- aPnt2 = gp_Pnt(aPntMin.X(), aPntMax.Y(), aPntMin.Z());
- aPnt3 = gp_Pnt(aPntMin.X(), aPntMax.Y(), aPntMax.Z());
- aPnt4 = gp_Pnt(aPntMin.X(), aPntMin.Y(), aPntMax.Z());
+ aPnt1 = gp_Pnt(thePntMin.X(), thePntMin.Y(), thePntMin.Z());
+ aPnt2 = gp_Pnt(thePntMin.X(), thePntMax.Y(), thePntMin.Z());
+ aPnt3 = gp_Pnt(thePntMin.X(), thePntMax.Y(), thePntMax.Z());
+ aPnt4 = gp_Pnt(thePntMin.X(), thePntMin.Y(), thePntMax.Z());
}
else if (aThinOnY)
{
- aPnt1 = gp_Pnt(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());
+ aPnt1 = gp_Pnt(thePntMin.X(), thePntMin.Y(), thePntMin.Z());
+ aPnt2 = gp_Pnt(thePntMax.X(), thePntMin.Y(), thePntMin.Z());
+ aPnt3 = gp_Pnt(thePntMax.X(), thePntMin.Y(), thePntMax.Z());
+ aPnt4 = gp_Pnt(thePntMin.X(), thePntMin.Y(), thePntMax.Z());
}
else if (aThinOnZ)
{
- aPnt1 = gp_Pnt(aPntMin.X(), aPntMin.Y(), aPntMin.Z());
- aPnt2 = gp_Pnt(aPntMax.X(), aPntMin.Y(), aPntMin.Z());
- aPnt3 = gp_Pnt(aPntMax.X(), aPntMax.Y(), aPntMin.Z());
- aPnt4 = gp_Pnt(aPntMin.X(), aPntMax.Y(), aPntMin.Z());
+ aPnt1 = gp_Pnt(thePntMin.X(), thePntMin.Y(), thePntMin.Z());
+ aPnt2 = gp_Pnt(thePntMax.X(), thePntMin.Y(), thePntMin.Z());
+ aPnt3 = gp_Pnt(thePntMax.X(), thePntMax.Y(), thePntMin.Z());
+ aPnt4 = gp_Pnt(thePntMin.X(), thePntMax.Y(), thePntMin.Z());
}
BRep_Builder aBuilder;
TopoDS_Compound aCompound;
}
else
{
- BRepPrimAPI_MakeBox aBoxBuilder (
- gp_Pnt (theBoundingBox.CornerMin().x(), theBoundingBox.CornerMin().y(), theBoundingBox.CornerMin().z()),
- gp_Pnt (theBoundingBox.CornerMax().x(), theBoundingBox.CornerMax().y(), theBoundingBox.CornerMax().z()));
+ BRepPrimAPI_MakeBox aBoxBuilder (thePntMin, thePntMax);
return aBoxBuilder.Shape();
}
}
//! \return created shape
Standard_EXPORT static TopoDS_Shape CreateShape (const Select3D_BndBox3d& theBoundingBox);
+ //! Creates box shape
+ //! \param thePntMin minimum point on the bounding box
+ //! \param thePntMax maximum point on the bounding box
+ //! \return created shape
+ Standard_EXPORT static TopoDS_Shape CreateBoxShape (const gp_Pnt& thePntMin, const gp_Pnt& thePntMax);
+
//! Build string presentation of Graphic3D index buffer
//! \param theIndexBuffer index buffer
//! \return string presentation
#include <inspector/VInspector_ItemSelectBasicsEntityOwner.hxx>
#include <inspector/VInspector_ItemPresentableObject.hxx>
#include <inspector/VInspector_ItemSelectMgrSensitiveEntity.hxx>
+
+#include <inspector/ViewControl_Tools.hxx>
+
#include <SelectBasics_EntityOwner.hxx>
#include <Standard_WarningsDisable.hxx>
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 (3, TreeModel_HeaderSection ("Row", COLUMN_SIZE_WIDTH));
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
+ //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
- 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 (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 (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 (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
+ //SetHeaderItem (20, TreeModel_HeaderSection ("Color", -1)); // ItemPresentableObject
- SetHeaderItem (21, TreeModel_HeaderSection ("Owner Location", -1, true)); // ItemEntityOwner
+ //SetHeaderItem (21, TreeModel_HeaderSection ("Owner Location", -1, true)); // ItemEntityOwner
}
// =======================================================================
// function : FindPointers
// purpose :
// =======================================================================
-QModelIndexList VInspector_ViewModel::FindPointers (const QStringList& thePointers)
+void VInspector_ViewModel::FindPointers (const QStringList& thePointers,
+ const QModelIndex& theParent,
+ QModelIndexList& theFoundIndices)
{
- QModelIndexList anIndices;
- QModelIndex aParentIndex = index (0, 0);
+ if (thePointers.isEmpty())
+ return;
+
+ QModelIndex aParentIndex = theParent.isValid() ? theParent : index (0, 0);
TreeModel_ItemBasePtr aParentItem = TreeModel_ModelBase::GetItemByIndex (aParentIndex); // context item
for (int aRowId = 0, aCount = aParentItem->rowCount(); aRowId < aCount; aRowId++)
{
QModelIndex anIndex = index (aRowId, 0, aParentIndex);
TreeModel_ItemBasePtr anItemBase = TreeModel_ModelBase::GetItemByIndex (anIndex);
- VInspector_ItemPresentableObjectPtr anItemPrs = itemDynamicCast<VInspector_ItemPresentableObject>(anItemBase);
- if (!anItemPrs)
+ VInspector_ItemBasePtr aVItem = itemDynamicCast<VInspector_ItemBase>(anItemBase);
+ if (!aVItem)
continue;
- if (thePointers.contains (anItemPrs->PointerInfo()))
- anIndices.append (anIndex);
+ Handle(Standard_Transient) anObject = aVItem->GetObject();
+ TCollection_AsciiString aPointerInfo = ViewControl_Tools::GetPointerInfo (anObject);
+ if (thePointers.contains (aPointerInfo.ToCString()))
+ theFoundIndices.append (anIndex);
+
+ FindPointers (thePointers, anIndex, theFoundIndices);
}
- return anIndices;
}
// =======================================================================
//! Returns tree view indices for the given pointers of presentable object
//! \param thePointers a list of presentation pointers
- //! \return container of indices
- Standard_EXPORT QModelIndexList FindPointers (const QStringList& thePointers);
+ //! \param theParent an index of the parent item
+ //! \param [out] container of indices
+ Standard_EXPORT void FindPointers (const QStringList& thePointers,
+ const QModelIndex& theParent,
+ QModelIndexList& theFoundIndices);
//! Returns tree model index of the presentation item in the tree view.
//! \param thePresentation a presentation
#include <inspector/TreeModel_Tools.hxx>
#include <inspector/ViewControl_MessageDialog.hxx>
+#include <inspector/ViewControl_TableModel.hxx>
#include <inspector/ViewControl_Tools.hxx>
#include <inspector/VInspector_ToolBar.hxx>
#include <inspector/VInspector_ItemOpenGlElement.hxx>
#include <inspector/VInspector_ItemPresentableObject.hxx>
#include <inspector/VInspector_PrsOpenGlElement.hxx>
+#include <inspector/VInspector_TableModelValues.hxx>
#include <inspector/VInspector_ToolBar.hxx>
#include <inspector/VInspector_Tools.hxx>
#include <inspector/VInspector_ViewModel.hxx>
{
TreeModel_ItemBasePtr anItem = *anItemIt;
VInspector_ItemBasePtr aVItem = itemDynamicCast<VInspector_ItemBase>(anItem);
- if (!aVItem)
+ if (!aVItem && aVItem->Row() == 0)
continue;
TopoDS_Shape aShape = aVItem->GetPresentationShape();
aSelectedShapes.Append (aShape);
}
+
+ // obtain selection from the property panel
+ {
+ QList<ViewControl_Table*> aPropertyTables;
+ myPropertyView->GetActiveTables (aPropertyTables);
+ if (!aPropertyTables.isEmpty())
+ {
+ ViewControl_Table* aFirstTable = aPropertyTables[0]; // TODO: implement for several tables
+
+ Handle(Graphic3d_TransformPers) aSelectedPersistent = GetSelectedTransformPers();
+ QModelIndexList aTreeViewSelected = myTreeView->selectionModel()->selectedIndexes();
+ GetSelectedPropertyPanelShapes(aTreeViewSelected,
+ aFirstTable->GetTableView()->selectionModel()->selectedIndexes(),
+ aSelectedShapes);
+ }
+ }
+
return aSelectedShapes;
}
+// =======================================================================
+// function : GetSelectedPropertyPanelShapes
+// purpose :
+// =======================================================================
+void VInspector_Window::GetSelectedPropertyPanelShapes (const QModelIndexList& theTreeViewIndices,
+ const QModelIndexList& thePropertyPanelIndices,
+ NCollection_List<TopoDS_Shape>& theShapes)
+{
+ QList<TreeModel_ItemBasePtr> anItems = TreeModel_ModelBase::GetSelectedItems (theTreeViewIndices);
+ for (QList<TreeModel_ItemBasePtr>::const_iterator anItemIt = anItems.begin(); anItemIt != anItems.end(); anItemIt++)
+ {
+ TreeModel_ItemBasePtr anItem = *anItemIt;
+ VInspector_ItemBasePtr aVItem = itemDynamicCast<VInspector_ItemBase>(anItem);
+ if (!aVItem || aVItem->Column() != 0)
+ continue;
+
+ QList<ViewControl_TableModelValues*> aTableValues;
+ VInspector_Tools::GetPropertyTableValues (aVItem, myPaneCreators, aTableValues);
+ if (aTableValues.isEmpty())
+ continue;
+
+ for (int aTableIt = 0; aTableIt < aTableValues.size(); aTableIt++)
+ {
+ VInspector_TableModelValues* aTableVals = dynamic_cast<VInspector_TableModelValues*>(aTableValues[aTableIt]);
+ if (!aTableVals)
+ continue;
+
+ // default shape by NULL selection
+ aTableVals->GetPaneShapes (-1, -1, theShapes);
+
+ for (QModelIndexList::const_iterator anIndicesIt = thePropertyPanelIndices.begin(); anIndicesIt != thePropertyPanelIndices.end(); anIndicesIt++)
+ {
+ QModelIndex anIndex = *anIndicesIt;
+ aTableVals->GetPaneShapes (anIndex.row(), anIndex.column(), theShapes);
+ }
+ }
+ }
+}
+
// =======================================================================
// function : GetSelectedElements
// purpose :
if (aCallBack.IsNull())
aCallBack = Handle(VInspector_CallBack)::DownCast (anObject);
+
+ if (!Handle(ViewControl_PaneCreator)::DownCast (anObject).IsNull())
+ {
+ Handle(ViewControl_PaneCreator) aPaneCreator = Handle(ViewControl_PaneCreator)::DownCast (anObject);
+ if (!myPaneCreators.Contains (aPaneCreator))
+ myPaneCreators.Append (aPaneCreator);
+ }
}
if (aContext.IsNull())
return false;
aMenu->addAction (ViewControl_Tools::CreateAction (VInspector_Tools::DisplayActionTypeToString ((VInspector_DisplayActionType) aTypeId),
SLOT (onDisplayActionTypeClicked()), GetMainWindow(), this));
aMenu->addSeparator();
+
+ aMenu->addAction (ViewControl_Tools::CreateAction (tr ("Expand"), SLOT (onExpand()), GetMainWindow(), this));
+ aMenu->addAction (ViewControl_Tools::CreateAction (tr ("Expand All"), SLOT (onExpandAll()), GetMainWindow(), this));
+ aMenu->addAction (ViewControl_Tools::CreateAction (tr ("Collapse All"), SLOT (onCollapseAll()), GetMainWindow(), this));
+
QPoint aPoint = myTreeView->mapToGlobal (thePosition);
aMenu->exec(aPoint);
}
// =======================================================================
void VInspector_Window::onPropertyViewSelectionChanged()
{
- /*QItemSelectionModel* aModel = myTreeView->selectionModel();
- if (!aModel)
- return;
- QModelIndex aSelectedIndex = TreeModel_ModelBase::SingleSelected (aModel->selectedIndexes(), 0);
- QModelIndex anIndex = myTreeView->model()->index (aSelectedIndex.row(), TreeModel_ColumnType_Visibility, aSelectedIndex.parent());
-
- TreeModel_ItemBasePtr anItemBase = TreeModel_ModelBase::GetItemByIndex (anIndex);
- if (!anItemBase)
- return;
- MessageModel_ItemAlertPtr anAlertItem = itemDynamicCast<MessageModel_ItemAlert>(anItemBase);
- if (!anAlertItem)
- return;
-
QList<ViewControl_Table*> aPropertyTables;
myPropertyView->GetActiveTables (aPropertyTables);
if (aPropertyTables.isEmpty())
QMap<int, QList<int>> aSelectedIndices;
aFirstTable->GetSelectedIndices (aSelectedIndices);
- // clear presentation if selection is empty
- MessageModel_TreeModel* aTreeModel = dynamic_cast<MessageModel_TreeModel*> (myTreeView->model());
- TreeModel_VisibilityState* aVisibilityState = aTreeModel->GetVisibilityState();
- if (aSelectedIndices.isEmpty() && aVisibilityState->IsVisible (anIndex))
- {
- aVisibilityState->SetVisible (anIndex, false, true);
- anAlertItem->SetCustomShape (TopoDS_Shape());
- return;
- }
-
- TopoDS_Shape aShapeOfSelection = MessageModel_Tools::BuildShape (anAlertItem->GetAlert(), aSelectedIndices[0], aFirstTable);
- if (aShapeOfSelection.IsNull())
- return;
+ ViewControl_TableModel* aTableModel = dynamic_cast<ViewControl_TableModel*>(aFirstTable->GetTableView()->model());
+ ViewControl_TableModelValues* aTableValues = aTableModel->GetModelValues();
- if (aVisibilityState->IsVisible (anIndex))
+ QStringList aPointers;
+ for (QMap<int, QList<int>>::const_iterator aSelIt = aSelectedIndices.begin(); aSelIt != aSelectedIndices.end(); aSelIt++)
{
- View_Displayer* aDisplayer = myViewWindow->GetDisplayer();
+ int aRowId = aSelIt.key();
+ QList<int> aColIds = aSelIt.value();
+ for (int aColId = 0; aColId < aColIds.size(); aColId++)
+ {
+ int aSelectedColId = aColIds[aColId];
+ if (aSelectedColId != 1)
+ continue;
- Handle(AIS_InteractiveObject) aPresentation = myViewWindow->GetDisplayer()->FindPresentation (anAlertItem->GetCustomShape());
+ QString aData = aTableValues->Data (aRowId, aSelectedColId, Qt::DisplayRole).toString();
+ if (aData.contains (ViewControl_Tools::GetPointerPrefix().ToCString()))
+ aPointers.append (aData);
+ }
+ }
+ highlightTreeViewItems (aPointers);
- Handle(AIS_Shape) aShapePresentation = Handle(AIS_Shape)::DownCast (aPresentation);
- aShapePresentation->Set (aShapeOfSelection);
+ Handle(Graphic3d_TransformPers) aSelectedPersistent = GetSelectedTransformPers();
+ QModelIndexList aTreeViewSelected = myTreeView->selectionModel()->selectedIndexes();
+ NCollection_List<TopoDS_Shape> aSelectedShapes = GetSelectedShapes (aTreeViewSelected);
- aDisplayer->RedisplayPresentation (aPresentation);
- anAlertItem->SetCustomShape (aShapeOfSelection);
- }
- else
- {
- anAlertItem->SetCustomShape (aShapeOfSelection);
- aVisibilityState->SetVisible (anIndex, true);
- }*/
+ GetSelectedPropertyPanelShapes(aTreeViewSelected,
+ aFirstTable->GetTableView()->selectionModel()->selectedIndexes(),
+ aSelectedShapes);
+
+ updatePreviewPresentation(aSelectedShapes, aSelectedPersistent);
}
// =======================================================================
updatePropertyPanelBySelection();
Handle(Graphic3d_TransformPers) aSelectedPersistent = GetSelectedTransformPers();
+
NCollection_List<TopoDS_Shape> aSelectedShapes = GetSelectedShapes (myTreeView->selectionModel()->selectedIndexes());
updatePreviewPresentation(aSelectedShapes, aSelectedPersistent);
QModelIndexList aSelectedIndices = theSelected.indexes();
QStringList aPointers = aHistoryModel->GetSelectedPointers(aSelectedIndices.first());
-
- VInspector_ViewModel* aTreeModel = dynamic_cast<VInspector_ViewModel*> (myTreeView->model());
- if (!aTreeModel)
- return;
-
- QModelIndexList anIndices = aTreeModel->FindPointers (aPointers);
- QItemSelectionModel* aSelectionModel = myTreeView->selectionModel();
- aSelectionModel->clear();
- for (int anIndicesId = 0, aSize = anIndices.size(); anIndicesId < aSize; anIndicesId++)
- {
- QModelIndex anIndex = anIndices[anIndicesId];
- myTreeView->setExpanded (aTreeModel->parent (anIndex), true);
- aSelectionModel->select (anIndex, QItemSelectionModel::Select);
- }
+ selectTreeViewItems (aPointers);
}
// =======================================================================
displaySelectedPresentations (VInspector_Tools::DisplayActionTypeFromString (anAction->text().toStdString().c_str()));
}
+// =======================================================================
+// function : onExpand
+// purpose :
+// =======================================================================
+void VInspector_Window::onExpand()
+{
+ QApplication::setOverrideCursor (Qt::WaitCursor);
+
+ QItemSelectionModel* aSelectionModel = myTreeView->selectionModel();
+ QModelIndexList aSelectedIndices = aSelectionModel->selectedIndexes();
+ for (int aSelectedId = 0, aSize = aSelectedIndices.size(); aSelectedId < aSize; aSelectedId++)
+ {
+ int aLevels = 2;
+ TreeModel_Tools::SetExpanded (myTreeView, aSelectedIndices[aSelectedId], true, aLevels);
+ }
+ QApplication::restoreOverrideCursor();
+}
+
+// =======================================================================
+// function : onExpandAll
+// purpose :
+// =======================================================================
+void VInspector_Window::onExpandAll()
+{
+ QApplication::setOverrideCursor (Qt::WaitCursor);
+
+ QItemSelectionModel* aSelectionModel = myTreeView->selectionModel();
+ QModelIndexList aSelectedIndices = aSelectionModel->selectedIndexes();
+ for (int aSelectedId = 0, aSize = aSelectedIndices.size(); aSelectedId < aSize; aSelectedId++)
+ {
+ int aLevels = -1;
+ TreeModel_Tools::SetExpanded (myTreeView, aSelectedIndices[aSelectedId], true, aLevels);
+ }
+ QApplication::restoreOverrideCursor();
+}
+
+// =======================================================================
+// function : onCollapseAll
+// purpose :
+// =======================================================================
+void VInspector_Window::onCollapseAll()
+{
+ QItemSelectionModel* aSelectionModel = myTreeView->selectionModel();
+ QModelIndexList aSelectedIndices = aSelectionModel->selectedIndexes();
+ for (int aSelectedId = 0, aSize = aSelectedIndices.size(); aSelectedId < aSize; aSelectedId++)
+ {
+ int aLevels = -1;
+ TreeModel_Tools::SetExpanded (myTreeView, aSelectedIndices[aSelectedId], false, aLevels);
+ }
+}
+
#ifdef DEBUG_TWO_VIEWS
// =======================================================================
// function : onViewLeftButtonDown
UpdateTreeModel();
}
+// =======================================================================
+// function : highlightTreeViewItems
+// purpose :
+// =======================================================================
+void VInspector_Window::highlightTreeViewItems (const QStringList& thePointers)
+{
+ VInspector_ViewModel* aTreeModel = dynamic_cast<VInspector_ViewModel*> (myTreeView->model());
+ if (!aTreeModel)
+ return;
+
+ QModelIndexList anIndices;
+ aTreeModel->FindPointers (thePointers, QModelIndex(), anIndices);
+ for (int anIndicesId = 0, aSize = anIndices.size(); anIndicesId < aSize; anIndicesId++)
+ {
+ QModelIndex anIndex = anIndices[anIndicesId];
+ TreeModel_Tools::SetExpandedTo (myTreeView, anIndex);
+ }
+ aTreeModel->SetHighlighted (anIndices);
+
+ if (!anIndices.isEmpty())
+ myTreeView->scrollTo (anIndices.last());
+}
+
+// =======================================================================
+// function : selectTreeViewItems
+// purpose :
+// =======================================================================
+void VInspector_Window::selectTreeViewItems (const QStringList& thePointers)
+{
+ VInspector_ViewModel* aTreeModel = dynamic_cast<VInspector_ViewModel*> (myTreeView->model());
+ if (!aTreeModel)
+ return;
+
+ QModelIndexList anIndices;
+ aTreeModel->FindPointers (thePointers, QModelIndex(), anIndices);
+ QItemSelectionModel* aSelectionModel = myTreeView->selectionModel();
+ aSelectionModel->clear();
+ for (int anIndicesId = 0, aSize = anIndices.size(); anIndicesId < aSize; anIndicesId++)
+ {
+ QModelIndex anIndex = anIndices[anIndicesId];
+ TreeModel_Tools::SetExpandedTo (myTreeView, anIndex);
+ aSelectionModel->select (anIndex, QItemSelectionModel::Select);
+ }
+}
+
// =======================================================================
// function : createView
// purpose :
if (myPreviewPresentation.IsNull())
{
myPreviewPresentation = new AIS_Shape (aCompound);
- myPreviewPresentation->SetColor (Quantity_Color (Quantity_NOC_BLUE1));
+ myPreviewPresentation->SetColor (Quantity_Color (Quantity_NOC_TOMATO));//Quantity_NOC_GREENYELLOW));//Quantity_NOC_BLUE1));
myPreviewPresentation->SetZLayer (Graphic3d_ZLayerId_Topmost);
myPreviewPresentation->SetTransformPersistence(thePersistent);
if (!aContext.IsNull())
- aContext->Display (myPreviewPresentation, Standard_True);
+ aContext->Display (myPreviewPresentation, AIS_Shaded, -1/*do not participate in selection*/, Standard_True);
}
else
{
//! \return container of shapes
NCollection_List<TopoDS_Shape> GetSelectedShapes (const QModelIndexList& theIndices);
+ //! Returns selected shapes
+ //! \param theModel selection model
+ //! \return container of shapes
+ void GetSelectedPropertyPanelShapes (const QModelIndexList& theTreeViewIndices,
+ const QModelIndexList& thePropertyPanelIndices,
+ NCollection_List<TopoDS_Shape>& theShapes);
+
//! Returns selected elements
//! \param theModel selection model
//! \return container of OpenGl elements
//! Apply activated display action
void onDisplayActionTypeClicked();
+ //! Expand two next levels for all selected item
+ void onExpand();
+
+ //! Expand all levels for all selected items
+ void onExpandAll();
+
+ //! Collapse all levels for all selected items
+ void onCollapseAll();
+
#ifdef DEBUG_TWO_VIEWS
//! Processing mouse down in the view
//! \param theX X mouse position in pixels
//! \param theType display action type
void displaySelectedPresentations (const VInspector_DisplayActionType theType);
+ //! Set items of the pointers highlighted in tree view
+ //! \param theType display action type
+ void highlightTreeViewItems (const QStringList& thePointers);
+
+ //! Set items of the pointers selected in tree view
+ //! \param theType display action type
+ void selectTreeViewItems (const QStringList& thePointers);
+
//! Creates an istance of 3D view to initialize context.
//! \return a context of created view.
Handle(AIS_InteractiveContext) createView();
VInspectorPaneAIS_PaneCreator.cxx
VInspectorPaneAIS_PaneCreator.hxx
VInspectorPaneAIS_Shape.cxx
-VInspectorPaneAIS_Shape.hxx
-VInspectorPaneAIS_Trihedron.cxx
-VInspectorPaneAIS_Trihedron.hxx
\ No newline at end of file
+VInspectorPaneAIS_Shape.hxx
\ No newline at end of file
#include <inspector/VInspectorPaneAIS_PaneCreator.hxx>
#include <inspector/VInspectorPaneAIS_Shape.hxx>
-#include <inspector/VInspectorPaneAIS_Trihedron.hxx>
#include <AIS_Shape.hxx>
-#include <AIS_Trihedron.hxx>
-IMPLEMENT_STANDARD_RTTIEXT(VInspectorPaneAIS_PaneCreator, VInspectorAPI_CallBack)
+IMPLEMENT_STANDARD_RTTIEXT(VInspectorPaneAIS_PaneCreator, ViewControl_PaneCreator)
// =======================================================================
// function : createPane
{
if (theName == STANDARD_TYPE (AIS_Shape)->Name())
return new VInspectorPaneAIS_Shape();
- //else if (theName == STANDARD_TYPE (AIS_Trihedron)->Name())
- // return new VInspectorPaneAIS_Trihedron();
return NULL;
}
#include <inspector/VInspectorPaneAIS_Shape.hxx>
-//#include <AIS_Shape.hxx>
-//#include <AIS_ListOfInteractive.hxx>
-//#include <AIS_ListIteratorOfListOfInteractive.hxx>
-//#include <Aspect.hxx>
-//
-//#include <inspector/VInspector_ItemContext.hxx>
-//#include <inspector/VInspector_ItemSelectBasicsEntityOwner.hxx>
-//#include <inspector/VInspector_ItemFolderObject.hxx>
-//#include <inspector/VInspector_ItemPresentations.hxx>
-//#include <inspector/VInspector_ItemSelectMgrSelection.hxx>
#include <inspector/ViewControl_Table.hxx>
#include <inspector/ViewControl_Tools.hxx>
#include <inspector/VInspector_Tools.hxx>
-//#include <inspector/VInspector_ViewModel.hxx>
#include <inspector/ViewControl_PaneItem.hxx>
#include <Prs3d.hxx>
#include <TopAbs.hxx>
-//
-//#include <Graphic3d.hxx>
-//#include <NCollection_List.hxx>
-//#include <Prs3d.hxx>
-//#include <Prs3d_Drawer.hxx>
-//#include <PrsMgr.hxx>
-//#include <SelectBasics_EntityOwner.hxx>
-//#include <StdSelect_BRepOwner.hxx>
-//#include <Standard_Version.hxx>
-//
-//#include <Standard_WarningsDisable.hxx>
-//#include <QColor>
-//#include <QItemSelectionModel>
-//#include <Standard_WarningsRestore.hxx>
// =======================================================================
// function : GetTableRowCount
return QVariant();
}
-// =======================================================================
-// function : GetTableEditType
-// purpose :
-// =======================================================================
-ViewControl_EditType VInspectorPaneAIS_Shape::GetTableEditType (const Handle(Standard_Transient)& theObject,
- const int theRow, const int) const
-{
- Handle(AIS_Shape) aPrs = GetPresentation (theObject);
- if (aPrs.IsNull())
- return ViewControl_EditType_None;
-
- switch (theRow)
- {
- //case 4: return ViewControl_EditType_Line;
- //case 5: return ViewControl_EditType_Combo;
- //case 6: return ViewControl_EditType_Bool;
- //case 12: return ViewControl_EditType_Bool;
- //case 17: return ViewControl_EditType_Combo;
- //case 18: return ViewControl_EditType_Bool;
- //case 20: return ViewControl_EditType_Combo;
- //case 23: return ViewControl_EditType_Bool;
- default: return ViewControl_EditType_None;
- }
-}
-
-// =======================================================================
-// function : GetTableEnumValues
-// purpose :
-// =======================================================================
-QList<QVariant> VInspectorPaneAIS_Shape::GetTableEnumValues (const Handle(Standard_Transient)& theObject,
- const int theRow, const int) const
-{
- Handle(AIS_Shape) aPrs = GetPresentation (theObject);
- if (aPrs.IsNull())
- return QList<QVariant>();
-
- QList<QVariant> aValues;
- switch (theRow)
- {
- //case 5:
- //{
- // for (int i = 0; i <= Aspect_TOFM_FRONT_SIDE; i++)
- // aValues.append (Aspect::TypeOfFacingModelToString((Aspect_TypeOfFacingModel)i));
- //}
- //break;
- //case 17:
- //{
- // for (int i = 0; i <= PrsMgr_TOP_ProjectorDependant; i++)
- // aValues.append (PrsMgr::TypeOfPresentation3dToString ((PrsMgr_TypeOfPresentation3d)i));
- //}
- //break;
- //case 20:
- //{
- // aValues.append (Graphic3d::ZLayerIdToString (Graphic3d_ZLayerId_UNKNOWN));
- // aValues.append (Graphic3d::ZLayerIdToString (Graphic3d_ZLayerId_Default));
- // aValues.append (Graphic3d::ZLayerIdToString (Graphic3d_ZLayerId_Top));
- // aValues.append (Graphic3d::ZLayerIdToString (Graphic3d_ZLayerId_Topmost));
- // aValues.append (Graphic3d::ZLayerIdToString (Graphic3d_ZLayerId_TopOSD));
- // aValues.append (Graphic3d::ZLayerIdToString (Graphic3d_ZLayerId_BotOSD));
- //}
- //break;
- default: break;
- }
- return aValues;
-}
-
-// =======================================================================
-// function : SetTableData
-// purpose :
-// =======================================================================
-bool VInspectorPaneAIS_Shape::SetTableData (const Handle(Standard_Transient)& theObject,
- const int theRow, const int, const QVariant& theValue)
-{
- Handle(AIS_Shape) aPrs = GetPresentation (theObject);
- if (aPrs.IsNull())
- return false;
-
- //Handle(AIS_InteractiveObject) aPrs = GetInteractiveObject();
- switch (theRow)
- {
- //case 4:
- //{
- // double aValue = theValue.toDouble();
- // if (aValue > 0) aPrs->SetWidth (aValue);
- // else aPrs->UnsetWidth();
- //}
- //break;
- //case 5: aPrs->SetCurrentFacingModel (Aspect::TypeOfFacingModelFromString (theValue.toString().toStdString().c_str()));
- //case 6: aPrs->SetInfiniteState (theValue.toBool());
- //case 12: aPrs->SetAutoHilight(theValue.toBool());
- //case 17: aPrs->SetTypeOfPresentation (PrsMgr::TypeOfPresentation3dFromString (theValue.toString().toStdString().c_str()));
- //case 18: aPrs->SetMutable (theValue.toBool());
- //case 20: aPrs->SetZLayer (Graphic3d::ZLayerIdFromString (theValue.toString().toStdString().c_str()));
- //case 23: if (!theValue.toBool()) aPrs->ResetTransformation();
- default: return false;
- }
- return true;
-}
-
// =======================================================================
// function : GetSelected
// purpose :
//! \param theRow a model index row
//! \param theColumn a model index column
Standard_EXPORT virtual QVariant GetTableData (const Handle(Standard_Transient)& theObject,
- const int theRow, const int theColumn, const int theRole) const Standard_OVERRIDE;
-
- //! Returns type of edit control for the model index. By default, it is an empty control
- //! \param theRow a model index row
- //! \param theColumn a model index column
- //! \return edit type
- Standard_EXPORT virtual ViewControl_EditType GetTableEditType (const Handle(Standard_Transient)& theObject,
- const int theRow, const int theColumn) const Standard_OVERRIDE;
-
- //! Returns container of string values for enumeration in the model row
- //! \param theRow table model row index
- //! \param theColumn a model index column
- //! \return string values for the enumeration presented in the row or an empty container
- Standard_EXPORT virtual QList<QVariant> GetTableEnumValues (const Handle(Standard_Transient)& theObject,
- const int theRow, const int theColumn) const Standard_OVERRIDE;
-
- //! Sets the value into the table cell. Only 1st column value might be modified.
- //! \param theRow a model index row
- //! \param theColumn a model index column
- //! \param theValue a new cell value
- Standard_EXPORT virtual bool SetTableData (const Handle(Standard_Transient)& theObject,
- const int theRow, const int theColumn, const QVariant& theValue) Standard_OVERRIDE;
+ const int theRow,
+ const int theColumn,
+ const int theRole) const Standard_OVERRIDE;
//! Return selected element in the pane cell
//! \param theObject current pane object
//! \param theRow a model index row
//! \param theColumn a model index column
Standard_EXPORT virtual ViewControl_PaneItem* GetSelected (const Handle(Standard_Transient)& theObject,
- const int theRow, const int theColumn) Standard_OVERRIDE;
+ const int theRow,
+ const int theColumn) Standard_OVERRIDE;
protected:
//! Converts transient object to custom presentation type
+++ /dev/null
-// Created on: 2018-12-08
-// 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/VInspectorPaneAIS_Trihedron.hxx>
-
+++ /dev/null
-// Created on: 2018-12-08
-// 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 VInspectorPaneAIS_Trihedron_H
-#define VInspectorPaneAIS_Trihedron_H
-
-#include <Standard.hxx>
-#include <inspector/ViewControl_Pane.hxx>
-
-//! \class VInspectorPaneAIS_Trihedron
-//! Item presents information about AIS_InteractiveObject.
-//! Parent is item context, children are item selections.
-class VInspectorPaneAIS_Trihedron : public ViewControl_Pane
-{
-};
-
-#endif
#include <Prs3d_PointAspect.hxx>
#include <V3d_View.hxx>
#include <V3d_Viewer.hxx>
+
#include <inspector/View_Viewer.hxx>
#include <inspector/View_Widget.hxx>
+#include <inspector/View_Tools.hxx>
// =======================================================================
// function : Constructor
// =======================================================================
Handle(V3d_View) View_Displayer::GetView() const
{
- Handle(V3d_View) aView;
- if (GetContext().IsNull())
- return aView;
-
- const Handle(V3d_Viewer)& aViewer = GetContext()->CurrentViewer();
- if (!aViewer.IsNull())
- {
- aViewer->InitActiveViews();
- if (aViewer->MoreActiveViews())
- aView = aViewer->ActiveView();
- }
- return aView;
+ return View_Tools::FindActiveView (GetContext());
}
// =======================================================================
return anAction;
}
+// =======================================================================
+// function : GetView
+// purpose :
+// =======================================================================
+Handle(V3d_View) View_Tools::FindActiveView (const Handle(AIS_InteractiveContext)& theContext)
+{
+ if (theContext.IsNull())
+ return NULL;
+
+ const Handle(V3d_Viewer)& aViewer = theContext->CurrentViewer();
+ if (aViewer.IsNull())
+ return NULL;
+
+ aViewer->InitActiveViews();
+ if (!aViewer->MoreActiveViews())
+ return NULL;
+
+ return aViewer->ActiveView();
+}
+
// =======================================================================
// function : SaveState
// purpose :
#include <QString>
#include <Standard_WarningsRestore.hxx>
+#include <V3d_View.hxx>
+#include <AIS_InteractiveContext.hxx>
+
class View_Window;
class QAction;
Standard_EXPORT static QAction* CreateAction (const QString& theText, const char* theSlot,
QObject* theParent, QObject* theContext);
+
+ //! Gets current viewer from the context and returns active view of the viewer
+ //! \return view or NULL
+ Standard_EXPORT static Handle(V3d_View) FindActiveView (const Handle(AIS_InteractiveContext)& theContext);
+
//! Save state of three view in a container in form: key, value. It saves:
//! - visibiblity of columns,
//! - columns width
#include <inspector/ViewControl_Tools.hxx>
#include <inspector/TreeModel_Tools.hxx>
-//#include <Quantity.hxx>
+#include <Quantity.hxx>
#include <Standard_WarningsDisable.hxx>
#include <QAbstractTableModel>
return QVariant ("Name");
Quantity_NameOfColor aColorName;
if (ViewControl_ColorSelector::IsExactColorName(myColor, aColorName))
- return "";//Quantity::NameOfColorToString (aColorName);
+ return Quantity::NameOfColorToString (aColorName);
}
break;
case 2: return isFirstColumn ? QVariant ("Red") : ViewControl_Tools::ToVariant (myColor.GetRGB().Red());
case 4: return isFirstColumn ? QVariant ("Blue") : ViewControl_Tools::ToVariant (myColor.GetRGB().Blue());
case 5: return isFirstColumn ? QVariant ("Alpha") : ViewControl_Tools::ToVariant (myColor.Alpha());
case 6: return isFirstColumn ? QVariant ("Near Name")
- : "";//Quantity::NameOfColorToString (myColor.GetRGB().Name());
+ : Quantity::NameOfColorToString (myColor.GetRGB().Name());
}
return QVariant();
}
return QVariant();
if (theRole == Qt::ToolTipRole)
- return "";//QString("%1 (%2)").arg(Quantity::NameOfColorToString (aNameOfColor))
- // .arg (ViewControl_ColorSelector::ColorToString (Quantity_Color (aNameOfColor)));
+ return QString("%1 (%2)").arg(Quantity::NameOfColorToString (aNameOfColor))
+ .arg (ViewControl_ColorSelector::ColorToString (Quantity_Color (aNameOfColor)));
return QVariant();
}
void ViewControl_Table::GetSelectedIndices (QMap<int, QList<int>>& theSelectedIndices)
{
QModelIndexList aSelected = myTableView->selectionModel()->selectedIndexes();
- ViewControl_TableModel* aModel = dynamic_cast<ViewControl_TableModel*> (myTableView->model());
int aRow, aColumn;
for (QModelIndexList::const_iterator anIt = aSelected.begin(); anIt != aSelected.end(); anIt++)
{
+ QModelIndex anIndex = *anIt;
+ aRow = anIndex.row();
+ aColumn = anIndex.column();
if (!theSelectedIndices.contains (aRow))
theSelectedIndices.insert (aRow, QList<int>());
theSelectedIndices[aRow].append (aColumn);