From 69bf3301f1500f86bcd93ad1ef1a3a0c05c374bc Mon Sep 17 00:00:00 2001 From: nds Date: Mon, 25 Feb 2019 16:25:13 +0300 Subject: [PATCH] 30268: Inspectors - improvements in VInspector plugin improvements in VInspector, based on CR40491 branch. --- src/SelectMgr/SelectMgr_ViewerSelector.cxx | 48 +++ src/SelectMgr/SelectMgr_ViewerSelector.hxx | 3 + src/StdSelect/StdSelect_ViewerSelector3d.cxx | 15 + tools/DFBrowser/DFBrowser_Window.cxx | 29 +- tools/DFBrowser/DFBrowser_Window.hxx | 7 - tools/VInspector/FILES | 8 + tools/VInspector/VInspector_CallBack.cxx | 17 ++ tools/VInspector/VInspector_CallBack.hxx | 17 +- .../VInspector_ItemAspectWindow.cxx | 8 +- tools/VInspector/VInspector_ItemBase.cxx | 21 ++ tools/VInspector/VInspector_ItemBase.hxx | 5 + tools/VInspector/VInspector_ItemContext.cxx | 5 +- .../VInspector_ItemFolderObject.cxx | 15 +- .../VInspector_ItemGraphic3dCStructure.cxx | 5 +- .../VInspector_ItemGraphic3dCView.cxx | 8 +- .../VInspector_ItemGraphic3dCamera.cxx | 8 +- .../VInspector_ItemGraphic3dClipPlane.cxx | 5 +- .../VInspector_ItemGraphic3dGroup.cxx | 4 + .../VInspector_ItemGraphic3dTransformPers.cxx | 5 +- .../VInspector_ItemHistoryElement.cxx | 4 + .../VInspector/VInspector_ItemHistoryRoot.cxx | 4 + .../VInspector/VInspector_ItemHistoryType.cxx | 11 + .../VInspector_ItemOpenGlElement.cxx | 4 + .../VInspector_ItemOpenGlElement.hxx | 3 +- .../VInspector_ItemPresentableObject.cxx | 12 +- .../VInspector_ItemPresentations.cxx | 4 + .../VInspector/VInspector_ItemPrs3dAspect.cxx | 12 +- .../VInspector/VInspector_ItemPrs3dDrawer.cxx | 12 +- .../VInspector_ItemPrs3dPresentation.cxx | 4 + ...Inspector_ItemSelect3DSensitiveSetItem.cxx | 4 + ...VInspector_ItemSelectBasicsEntityOwner.cxx | 47 +-- ...pector_ItemSelectBasicsSensitiveEntity.cxx | 4 + .../VInspector_ItemSelectMgrBaseFrustum.cxx | 197 ++++++++++++ .../VInspector_ItemSelectMgrBaseFrustum.hxx | 106 +++++++ .../VInspector_ItemSelectMgrFilter.cxx | 6 +- ...or_ItemSelectMgrSelectingVolumeManager.cxx | 170 +++++++++++ ...or_ItemSelectMgrSelectingVolumeManager.hxx | 96 ++++++ .../VInspector_ItemSelectMgrSelection.cxx | 5 +- ...Inspector_ItemSelectMgrSensitiveEntity.cxx | 4 + ...VInspector_ItemSelectMgrViewerSelector.cxx | 283 ++++++++++++++++++ ...VInspector_ItemSelectMgrViewerSelector.hxx | 140 +++++++++ ...ctor_ItemSelectMgrViewerSelectorPicked.cxx | 238 +++++++++++++++ ...ctor_ItemSelectMgrViewerSelectorPicked.hxx | 113 +++++++ tools/VInspector/VInspector_ItemV3dView.cxx | 5 +- tools/VInspector/VInspector_ItemV3dViewer.cxx | 5 +- .../VInspector_TableModelValues.cxx | 51 ++++ .../VInspector_TableModelValues.hxx | 17 +- tools/VInspector/VInspector_Tools.cxx | 66 ++-- tools/VInspector/VInspector_Tools.hxx | 6 + tools/VInspector/VInspector_ViewModel.cxx | 62 ++-- tools/VInspector/VInspector_ViewModel.hxx | 7 +- tools/VInspector/VInspector_Window.cxx | 252 ++++++++++++---- tools/VInspector/VInspector_Window.hxx | 24 ++ tools/VInspectorPaneAIS/FILES | 4 +- .../VInspectorPaneAIS_PaneCreator.cxx | 6 +- .../VInspectorPaneAIS_Shape.cxx | 124 -------- .../VInspectorPaneAIS_Shape.hxx | 28 +- .../VInspectorPaneAIS_Trihedron.cxx | 17 -- .../VInspectorPaneAIS_Trihedron.hxx | 29 -- tools/View/View_Displayer.cxx | 15 +- tools/View/View_Tools.cxx | 20 ++ tools/View/View_Tools.hxx | 8 + .../ViewControl/ViewControl_ColorSelector.cxx | 10 +- tools/ViewControl/ViewControl_Table.cxx | 4 +- 64 files changed, 2010 insertions(+), 466 deletions(-) create mode 100644 tools/VInspector/VInspector_ItemSelectMgrBaseFrustum.cxx create mode 100644 tools/VInspector/VInspector_ItemSelectMgrBaseFrustum.hxx create mode 100644 tools/VInspector/VInspector_ItemSelectMgrSelectingVolumeManager.cxx create mode 100644 tools/VInspector/VInspector_ItemSelectMgrSelectingVolumeManager.hxx create mode 100644 tools/VInspector/VInspector_ItemSelectMgrViewerSelector.cxx create mode 100644 tools/VInspector/VInspector_ItemSelectMgrViewerSelector.hxx create mode 100644 tools/VInspector/VInspector_ItemSelectMgrViewerSelectorPicked.cxx create mode 100644 tools/VInspector/VInspector_ItemSelectMgrViewerSelectorPicked.hxx delete mode 100644 tools/VInspectorPaneAIS/VInspectorPaneAIS_Trihedron.cxx delete mode 100644 tools/VInspectorPaneAIS/VInspectorPaneAIS_Trihedron.hxx diff --git a/src/SelectMgr/SelectMgr_ViewerSelector.cxx b/src/SelectMgr/SelectMgr_ViewerSelector.cxx index b0dfab611c..0476e7fd6b 100644 --- a/src/SelectMgr/SelectMgr_ViewerSelector.cxx +++ b/src/SelectMgr/SelectMgr_ViewerSelector.cxx @@ -34,6 +34,12 @@ #include +//#define REPORT_SELECTION_BUILD +#ifdef REPORT_SELECTION_BUILD +#include +#include +#endif + IMPLEMENT_STANDARD_RTTIEXT(SelectMgr_ViewerSelector, Standard_Transient) namespace { @@ -199,6 +205,12 @@ void SelectMgr_ViewerSelector::checkOverlap (const Handle(SelectBasics_Sensitive 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; @@ -248,7 +260,13 @@ void SelectMgr_ViewerSelector::checkOverlap (const Handle(SelectBasics_Sensitive } 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); @@ -356,6 +374,12 @@ void SelectMgr_ViewerSelector::traverseObject (const Handle(SelectMgr_Selectable 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 >& aSensitivesTree = anEntitySet->BVH(); gp_GTrsf aInversedTrsf; if (theObject->HasTransformation() || !theObject->TransformPersistence().IsNull()) @@ -403,6 +427,10 @@ void SelectMgr_ViewerSelector::traverseObject (const Handle(SelectMgr_Selectable 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); @@ -496,6 +524,12 @@ void SelectMgr_ViewerSelector::traverseObject (const Handle(SelectMgr_Selectable //======================================================================= 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; @@ -520,6 +554,11 @@ void SelectMgr_ViewerSelector::TraverseSensitives() for (Standard_Integer aBVHSetIt = 0; aBVHSetIt < SelectMgr_SelectableObjectSet::BVHSubsetNb; ++aBVHSetIt) { + #ifdef REPORT_SELECTION_BUILD + MESSAGE_INFO (TCollection_AsciiString ("aBVHSetIt") + aBVHSetIt, "", &aPerfMeter, aParentAlert); + Handle(Message_Alert) aParentAlertLevel1 = OCCT_Message_Alert; + #endif + SelectMgr_SelectableObjectSet::BVHSubset aBVHSubset = static_cast (aBVHSetIt); @@ -578,6 +617,9 @@ void SelectMgr_ViewerSelector::TraverseSensitives() 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); @@ -815,6 +857,12 @@ TCollection_AsciiString SelectMgr_ViewerSelector::Status (const Handle(SelectMgr //======================================================================= 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(); diff --git a/src/SelectMgr/SelectMgr_ViewerSelector.hxx b/src/SelectMgr/SelectMgr_ViewerSelector.hxx index 78691625f8..953665ec8f 100644 --- a/src/SelectMgr/SelectMgr_ViewerSelector.hxx +++ b/src/SelectMgr/SelectMgr_ViewerSelector.hxx @@ -109,6 +109,9 @@ public: //! 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(); } diff --git a/src/StdSelect/StdSelect_ViewerSelector3d.cxx b/src/StdSelect/StdSelect_ViewerSelector3d.cxx index 3e6c6106d5..19fc15a01d 100644 --- a/src/StdSelect/StdSelect_ViewerSelector3d.cxx +++ b/src/StdSelect/StdSelect_ViewerSelector3d.cxx @@ -69,6 +69,11 @@ #include +//#define REPORT_SELECTION_BUILD +#ifdef REPORT_SELECTION_BUILD +#include +#include +#endif IMPLEMENT_STANDARD_RTTIEXT(StdSelect_ViewerSelector3d,SelectMgr_ViewerSelector) @@ -117,6 +122,11 @@ void StdSelect_ViewerSelector3d::Pick (const Standard_Integer theXPix, 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) { @@ -131,6 +141,11 @@ void StdSelect_ViewerSelector3d::Pick (const Standard_Integer theXPix, mySelectingVolumeMgr.SetWindowSize (aWidth, aHeight); gp_Pnt2d aMousePos (static_cast (theXPix), static_cast (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()); diff --git a/tools/DFBrowser/DFBrowser_Window.cxx b/tools/DFBrowser/DFBrowser_Window.cxx index 5801326f84..a34cd16f43 100644 --- a/tools/DFBrowser/DFBrowser_Window.cxx +++ b/tools/DFBrowser/DFBrowser_Window.cxx @@ -659,7 +659,7 @@ void DFBrowser_Window::onExpand() 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(); } @@ -677,7 +677,7 @@ void DFBrowser_Window::onExpandAll() 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(); } @@ -692,7 +692,7 @@ void DFBrowser_Window::onCollapseAll() 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); } } @@ -988,26 +988,3 @@ void DFBrowser_Window::findPresentations (const QModelIndexList& theIndices, AIS 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); - } -} diff --git a/tools/DFBrowser/DFBrowser_Window.hxx b/tools/DFBrowser/DFBrowser_Window.hxx index 93fb3d7e0c..66f3479735 100644 --- a/tools/DFBrowser/DFBrowser_Window.hxx +++ b/tools/DFBrowser/DFBrowser_Window.hxx @@ -206,13 +206,6 @@ protected: //! \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 diff --git a/tools/VInspector/FILES b/tools/VInspector/FILES index 764cf39cdd..bc4ca4a8c3 100644 --- a/tools/VInspector/FILES +++ b/tools/VInspector/FILES @@ -50,8 +50,16 @@ VInspector_ItemSelectBasicsEntityOwner.cxx 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 diff --git a/tools/VInspector/VInspector_CallBack.cxx b/tools/VInspector/VInspector_CallBack.cxx index 4fec137ba2..a42ff3b208 100644 --- a/tools/VInspector/VInspector_CallBack.cxx +++ b/tools/VInspector/VInspector_CallBack.cxx @@ -38,6 +38,9 @@ IMPLEMENT_STANDARD_RTTIEXT(VInspector_CallBack, VInspectorAPI_CallBack) // ======================================================================= void VInspector_CallBack::Activate (Handle(AIS_InteractiveObject) thePrs, const Standard_Integer theMode) { + if (!myHistoryModel) + return; + QList anInfo; if (!thePrs.IsNull()) anInfo = VInspector_Tools::GetInfo (thePrs); @@ -57,6 +60,8 @@ void VInspector_CallBack::Activate (Handle(AIS_InteractiveObject) thePrs, const // ======================================================================= void VInspector_CallBack::AddOrRemoveSelected (const TopoDS_Shape& theShape) { + if (!myHistoryModel) + return; QList aValues; aValues.append (""); // Name aValues.append (""); // Pointer @@ -71,6 +76,8 @@ void VInspector_CallBack::AddOrRemoveSelected (const TopoDS_Shape& theShape) // ======================================================================= void VInspector_CallBack::AddOrRemoveSelected (Handle(AIS_InteractiveObject) thePrs) { + if (!myHistoryModel) + return; QList aValues = VInspector_Tools::GetInfo (thePrs); aValues.append (VInspector_Tools::GetSelectedInfoPointers (myContext)); // SelectionInfo myHistoryModel->AddElement (VInspector_CallBackMode_AddOrRemoveSelected, aValues); @@ -82,6 +89,8 @@ void VInspector_CallBack::AddOrRemoveSelected (Handle(AIS_InteractiveObject) the // ======================================================================= void VInspector_CallBack::AddOrRemoveSelected (Handle(SelectMgr_EntityOwner) theOwner) { + if (!myHistoryModel) + return; QList aValues; aValues.append (""); // Name aValues.append (VInspector_Tools::GetPointerInfo (theOwner, true).ToCString()); // Pointer @@ -97,6 +106,8 @@ void VInspector_CallBack::AddOrRemoveSelected (Handle(SelectMgr_EntityOwner) the // ======================================================================= void VInspector_CallBack::ClearSelected() { + if (!myHistoryModel) + return; QList aValues; myHistoryModel->AddElement (VInspector_CallBackMode_ClearSelected, aValues); } @@ -107,6 +118,8 @@ void VInspector_CallBack::ClearSelected() // ======================================================================= void VInspector_CallBack::MoveTo (const Standard_Integer/* theXPix*/, const Standard_Integer/* theYPix*/) { + if (!myHistoryModel) + return; QList aValues; aValues = VInspector_Tools::GetHighlightInfo (myContext); myHistoryModel->AddElement (VInspector_CallBackMode_MoveTo, aValues); @@ -118,6 +131,8 @@ void VInspector_CallBack::MoveTo (const Standard_Integer/* theXPix*/, const Stan // ======================================================================= void VInspector_CallBack::Select() { + if (!myHistoryModel) + return; QList aValues; aValues = VInspector_Tools::GetSelectedInfo (myContext); myHistoryModel->AddElement (VInspector_CallBackMode_Select, aValues); @@ -129,6 +144,8 @@ void VInspector_CallBack::Select() // ======================================================================= void VInspector_CallBack::ShiftSelect() { + if (!myHistoryModel) + return; QList aValues; aValues = VInspector_Tools::GetSelectedInfo (myContext); myHistoryModel->AddElement (VInspector_CallBackMode_ShiftSelect, aValues); diff --git a/tools/VInspector/VInspector_CallBack.hxx b/tools/VInspector/VInspector_CallBack.hxx index 57bdeae4ff..00290c73b5 100644 --- a/tools/VInspector/VInspector_CallBack.hxx +++ b/tools/VInspector/VInspector_CallBack.hxx @@ -43,22 +43,22 @@ public: //! 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 @@ -75,13 +75,14 @@ public: //! 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 @@ -101,7 +102,7 @@ public: //! 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 @@ -111,7 +112,7 @@ public: //! 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; diff --git a/tools/VInspector/VInspector_ItemAspectWindow.cxx b/tools/VInspector/VInspector_ItemAspectWindow.cxx index 27e4ae28fa..9a8a41a4de 100644 --- a/tools/VInspector/VInspector_ItemAspectWindow.cxx +++ b/tools/VInspector/VInspector_ItemAspectWindow.cxx @@ -34,6 +34,10 @@ // ======================================================================= 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(); @@ -45,10 +49,6 @@ QVariant VInspector_ItemAspectWindow::initValue (int theItemRole) const { 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; } diff --git a/tools/VInspector/VInspector_ItemBase.cxx b/tools/VInspector/VInspector_ItemBase.cxx index 2a29012bd7..56158a4018 100644 --- a/tools/VInspector/VInspector_ItemBase.cxx +++ b/tools/VInspector/VInspector_ItemBase.cxx @@ -17,6 +17,8 @@ #include #include +#include + // ======================================================================= // function : Reset // purpose : @@ -27,6 +29,25 @@ void VInspector_ItemBase::Reset() 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 : diff --git a/tools/VInspector/VInspector_ItemBase.hxx b/tools/VInspector/VInspector_ItemBase.hxx index 48b9922ba6..b5447aa3ec 100644 --- a/tools/VInspector/VInspector_ItemBase.hxx +++ b/tools/VInspector/VInspector_ItemBase.hxx @@ -53,6 +53,11 @@ public: //! \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& thePresentations) diff --git a/tools/VInspector/VInspector_ItemContext.cxx b/tools/VInspector/VInspector_ItemContext.cxx index 57bf423e6d..bb6dfbe9db 100644 --- a/tools/VInspector/VInspector_ItemContext.cxx +++ b/tools/VInspector/VInspector_ItemContext.cxx @@ -88,6 +88,10 @@ int VInspector_ItemContext::initRowCount() const // ======================================================================= 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(); @@ -97,7 +101,6 @@ QVariant VInspector_ItemContext::initValue (const int theItemRole) const switch (Column()) { case 0: return GetContext()->DynamicType()->Name(); - case 1: return rowCount(); case 4: { Handle(AIS_InteractiveObject) anEmptyIO; diff --git a/tools/VInspector/VInspector_ItemFolderObject.cxx b/tools/VInspector/VInspector_ItemFolderObject.cxx index 2ec8394f8c..5e6c394258 100644 --- a/tools/VInspector/VInspector_ItemFolderObject.cxx +++ b/tools/VInspector/VInspector_ItemFolderObject.cxx @@ -20,6 +20,7 @@ #include #include #include +#include #include #include @@ -31,6 +32,10 @@ // ======================================================================= 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(); @@ -55,7 +60,7 @@ int VInspector_ItemFolderObject::initRowCount() const { 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++) { @@ -91,6 +96,8 @@ TreeModel_ItemBasePtr VInspector_ItemFolderObject::createChild (int theRow, int 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); } @@ -137,10 +144,10 @@ Handle(Prs3d_Drawer) VInspector_ItemFolderObject::GetPrs3dDrawer (const int theR { 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(); @@ -152,7 +159,7 @@ Handle(Prs3d_Drawer) VInspector_ItemFolderObject::GetPrs3dDrawer (const int theR 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; diff --git a/tools/VInspector/VInspector_ItemGraphic3dCStructure.cxx b/tools/VInspector/VInspector_ItemGraphic3dCStructure.cxx index 447917b89e..a50f2d8ab9 100644 --- a/tools/VInspector/VInspector_ItemGraphic3dCStructure.cxx +++ b/tools/VInspector/VInspector_ItemGraphic3dCStructure.cxx @@ -107,6 +107,10 @@ int VInspector_ItemGraphic3dCStructure::initRowCount() const // ======================================================================= 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(); @@ -118,7 +122,6 @@ QVariant VInspector_ItemGraphic3dCStructure::initValue (const int theItemRole) c { case 0: return theItemRole == Qt::DisplayRole ? aCStructure->DynamicType()->Name() : STANDARD_TYPE (Graphic3d_CStructure)->Name(); - case 1: return rowCount(); default: break; } diff --git a/tools/VInspector/VInspector_ItemGraphic3dCView.cxx b/tools/VInspector/VInspector_ItemGraphic3dCView.cxx index 8799206529..5adef08ccc 100644 --- a/tools/VInspector/VInspector_ItemGraphic3dCView.cxx +++ b/tools/VInspector/VInspector_ItemGraphic3dCView.cxx @@ -106,6 +106,10 @@ int VInspector_ItemGraphic3dCView::initRowCount() const // ======================================================================= 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(); @@ -117,10 +121,6 @@ QVariant VInspector_ItemGraphic3dCView::initValue (const int theItemRole) const { 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; } diff --git a/tools/VInspector/VInspector_ItemGraphic3dCamera.cxx b/tools/VInspector/VInspector_ItemGraphic3dCamera.cxx index e8ec58a51e..3467a2b309 100644 --- a/tools/VInspector/VInspector_ItemGraphic3dCamera.cxx +++ b/tools/VInspector/VInspector_ItemGraphic3dCamera.cxx @@ -90,6 +90,10 @@ int VInspector_ItemGraphic3dCamera::initRowCount() const // ======================================================================= 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(); @@ -101,10 +105,6 @@ QVariant VInspector_ItemGraphic3dCamera::initValue (const int theItemRole) const { 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; } diff --git a/tools/VInspector/VInspector_ItemGraphic3dClipPlane.cxx b/tools/VInspector/VInspector_ItemGraphic3dClipPlane.cxx index ab5a882ac0..aa0af62ba0 100644 --- a/tools/VInspector/VInspector_ItemGraphic3dClipPlane.cxx +++ b/tools/VInspector/VInspector_ItemGraphic3dClipPlane.cxx @@ -48,6 +48,10 @@ int VInspector_ItemGraphic3dClipPlane::initRowCount() const // ======================================================================= 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(); @@ -57,7 +61,6 @@ QVariant VInspector_ItemGraphic3dClipPlane::initValue (const int theItemRole) co switch (Column()) { case 0: return GetClipPlane()->DynamicType()->Name(); - case 1: return rowCount(); default: break; } diff --git a/tools/VInspector/VInspector_ItemGraphic3dGroup.cxx b/tools/VInspector/VInspector_ItemGraphic3dGroup.cxx index b841b224ba..979cf4214e 100644 --- a/tools/VInspector/VInspector_ItemGraphic3dGroup.cxx +++ b/tools/VInspector/VInspector_ItemGraphic3dGroup.cxx @@ -88,6 +88,10 @@ int VInspector_ItemGraphic3dGroup::initRowCount() const // ======================================================================= 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(); diff --git a/tools/VInspector/VInspector_ItemGraphic3dTransformPers.cxx b/tools/VInspector/VInspector_ItemGraphic3dTransformPers.cxx index f66c620f05..b4549b1cfb 100644 --- a/tools/VInspector/VInspector_ItemGraphic3dTransformPers.cxx +++ b/tools/VInspector/VInspector_ItemGraphic3dTransformPers.cxx @@ -86,6 +86,10 @@ int VInspector_ItemGraphic3dTransformPers::initRowCount() const // ======================================================================= 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(); @@ -96,7 +100,6 @@ QVariant VInspector_ItemGraphic3dTransformPers::initValue (const int theItemRole switch (Column()) { case 0: return aTransformPers->DynamicType()->Name(); - case 1: return rowCount(); default: break; } diff --git a/tools/VInspector/VInspector_ItemHistoryElement.cxx b/tools/VInspector/VInspector_ItemHistoryElement.cxx index c7a4379ec6..ef57992759 100644 --- a/tools/VInspector/VInspector_ItemHistoryElement.cxx +++ b/tools/VInspector/VInspector_ItemHistoryElement.cxx @@ -26,6 +26,10 @@ // ======================================================================= 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(); diff --git a/tools/VInspector/VInspector_ItemHistoryRoot.cxx b/tools/VInspector/VInspector_ItemHistoryRoot.cxx index a39a4342ab..77f9512140 100644 --- a/tools/VInspector/VInspector_ItemHistoryRoot.cxx +++ b/tools/VInspector/VInspector_ItemHistoryRoot.cxx @@ -78,6 +78,10 @@ const VInspector_ItemHistoryTypeInfo& VInspector_ItemHistoryRoot::GetTypeInfo (c // ======================================================================= 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(); diff --git a/tools/VInspector/VInspector_ItemHistoryType.cxx b/tools/VInspector/VInspector_ItemHistoryType.cxx index 9e68c960ea..70ab2c9049 100644 --- a/tools/VInspector/VInspector_ItemHistoryType.cxx +++ b/tools/VInspector/VInspector_ItemHistoryType.cxx @@ -31,6 +31,8 @@ QString VInspector_ItemHistoryType::PointerInfo() const VInspector_ItemHistoryRootPtr aParentItem = itemDynamicCast(Parent()); const VInspector_ItemHistoryTypeInfo& aTypeInfo = aParentItem->GetTypeInfo(Row()); + if (aTypeInfo.myElements.size() < rowCount()) + return QString(); QList anElements = aTypeInfo.myElements[rowCount() - 1]; // the last item return anElements.size() > 1 ? anElements[1].toString() : QString(); } @@ -46,6 +48,8 @@ QString VInspector_ItemHistoryType::OwnerInfo() const VInspector_ItemHistoryRootPtr aParentItem = itemDynamicCast(Parent()); const VInspector_ItemHistoryTypeInfo& aTypeInfo = aParentItem->GetTypeInfo(Row()); + if ( aTypeInfo.myElements.size() < rowCount()) + return QString(); QList anElements = aTypeInfo.myElements[rowCount() - 1]; // the last item return anElements.size() > 3 ? anElements[3].toString() : QString(); } @@ -56,12 +60,19 @@ QString VInspector_ItemHistoryType::OwnerInfo() const // ======================================================================= 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(Parent()); const VInspector_ItemHistoryTypeInfo& aTypeInfo = aParentItem->GetTypeInfo(Row()); int aRowCount = rowCount(); + if (aRowCount <= 0 || aTypeInfo.myElements.size() < aRowCount) + return QVariant(); + QList anElements = rowCount() > 0 ? aTypeInfo.myElements[rowCount() - 1] : QList(); // the last item int anInfoSize = anElements.size(); switch (Column()) diff --git a/tools/VInspector/VInspector_ItemOpenGlElement.cxx b/tools/VInspector/VInspector_ItemOpenGlElement.cxx index 0ed0e648d4..bdaa9418b3 100644 --- a/tools/VInspector/VInspector_ItemOpenGlElement.cxx +++ b/tools/VInspector/VInspector_ItemOpenGlElement.cxx @@ -83,6 +83,10 @@ int VInspector_ItemOpenGlElement::initRowCount() const // ======================================================================= 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(); diff --git a/tools/VInspector/VInspector_ItemOpenGlElement.hxx b/tools/VInspector/VInspector_ItemOpenGlElement.hxx index 09476d2a1e..f41cbfbb59 100644 --- a/tools/VInspector/VInspector_ItemOpenGlElement.hxx +++ b/tools/VInspector/VInspector_ItemOpenGlElement.hxx @@ -48,7 +48,8 @@ public: //! 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; diff --git a/tools/VInspector/VInspector_ItemPresentableObject.cxx b/tools/VInspector/VInspector_ItemPresentableObject.cxx index 33fd3c7915..22083e4bdd 100644 --- a/tools/VInspector/VInspector_ItemPresentableObject.cxx +++ b/tools/VInspector/VInspector_ItemPresentableObject.cxx @@ -53,6 +53,10 @@ // ======================================================================= 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(); @@ -68,14 +72,6 @@ QVariant VInspector_ItemPresentableObject::initValue (int theItemRole) const 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); diff --git a/tools/VInspector/VInspector_ItemPresentations.cxx b/tools/VInspector/VInspector_ItemPresentations.cxx index 043f64c0df..28567f24c0 100644 --- a/tools/VInspector/VInspector_ItemPresentations.cxx +++ b/tools/VInspector/VInspector_ItemPresentations.cxx @@ -27,6 +27,10 @@ // ======================================================================= 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(); diff --git a/tools/VInspector/VInspector_ItemPrs3dAspect.cxx b/tools/VInspector/VInspector_ItemPrs3dAspect.cxx index 5fdb42f695..2efedca57c 100644 --- a/tools/VInspector/VInspector_ItemPrs3dAspect.cxx +++ b/tools/VInspector/VInspector_ItemPrs3dAspect.cxx @@ -47,6 +47,10 @@ 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(); @@ -59,14 +63,6 @@ QVariant VInspector_ItemPrs3dAspect::initValue (int theItemRole) const ? (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; } } diff --git a/tools/VInspector/VInspector_ItemPrs3dDrawer.cxx b/tools/VInspector/VInspector_ItemPrs3dDrawer.cxx index 8e9f6379c0..eb341d941f 100644 --- a/tools/VInspector/VInspector_ItemPrs3dDrawer.cxx +++ b/tools/VInspector/VInspector_ItemPrs3dDrawer.cxx @@ -48,6 +48,10 @@ 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) @@ -60,14 +64,6 @@ QVariant VInspector_ItemPrs3dDrawer::initValue (int theItemRole) const ? (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; } } diff --git a/tools/VInspector/VInspector_ItemPrs3dPresentation.cxx b/tools/VInspector/VInspector_ItemPrs3dPresentation.cxx index a66c4a4e2a..0fbeac1940 100644 --- a/tools/VInspector/VInspector_ItemPrs3dPresentation.cxx +++ b/tools/VInspector/VInspector_ItemPrs3dPresentation.cxx @@ -29,6 +29,10 @@ // ======================================================================= 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(); diff --git a/tools/VInspector/VInspector_ItemSelect3DSensitiveSetItem.cxx b/tools/VInspector/VInspector_ItemSelect3DSensitiveSetItem.cxx index d6a0790487..c865b83c04 100644 --- a/tools/VInspector/VInspector_ItemSelect3DSensitiveSetItem.cxx +++ b/tools/VInspector/VInspector_ItemSelect3DSensitiveSetItem.cxx @@ -78,6 +78,10 @@ Handle(Standard_Transient) VInspector_ItemSelect3DSensitiveSetItem::GetObject() // ======================================================================= 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(); diff --git a/tools/VInspector/VInspector_ItemSelectBasicsEntityOwner.cxx b/tools/VInspector/VInspector_ItemSelectBasicsEntityOwner.cxx index c8bc17cadc..312a658c8a 100644 --- a/tools/VInspector/VInspector_ItemSelectBasicsEntityOwner.cxx +++ b/tools/VInspector/VInspector_ItemSelectBasicsEntityOwner.cxx @@ -36,6 +36,10 @@ // ======================================================================= QVariant VInspector_ItemSelectBasicsEntityOwner::initValue(int theItemRole) const { + QVariant aParentValue = VInspector_ItemBase::initValue (theItemRole); + if (aParentValue.isValid()) + return aParentValue; + switch (theItemRole) { case Qt::DisplayRole: @@ -49,48 +53,7 @@ QVariant VInspector_ItemSelectBasicsEntityOwner::initValue(int theItemRole) cons 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; } diff --git a/tools/VInspector/VInspector_ItemSelectBasicsSensitiveEntity.cxx b/tools/VInspector/VInspector_ItemSelectBasicsSensitiveEntity.cxx index c316c3a5f5..af955e3a98 100644 --- a/tools/VInspector/VInspector_ItemSelectBasicsSensitiveEntity.cxx +++ b/tools/VInspector/VInspector_ItemSelectBasicsSensitiveEntity.cxx @@ -79,6 +79,10 @@ int VInspector_ItemSelectBasicsSensitiveEntity::initRowCount() const // ======================================================================= 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(); diff --git a/tools/VInspector/VInspector_ItemSelectMgrBaseFrustum.cxx b/tools/VInspector/VInspector_ItemSelectMgrBaseFrustum.cxx new file mode 100644 index 0000000000..e602f2b733 --- /dev/null +++ b/tools/VInspector/VInspector_ItemSelectMgrBaseFrustum.cxx @@ -0,0 +1,197 @@ +// 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 + +#include + +// ======================================================================= +// 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(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(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(); +} diff --git a/tools/VInspector/VInspector_ItemSelectMgrBaseFrustum.hxx b/tools/VInspector/VInspector_ItemSelectMgrBaseFrustum.hxx new file mode 100644 index 0000000000..39079ddccf --- /dev/null +++ b/tools/VInspector/VInspector_ItemSelectMgrBaseFrustum.hxx @@ -0,0 +1,106 @@ +// 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 +#include + +#include +#include + +class VInspector_ItemSelectMgrBaseFrustum; +typedef QExplicitlySharedDataPointer 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: + //! \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 diff --git a/tools/VInspector/VInspector_ItemSelectMgrFilter.cxx b/tools/VInspector/VInspector_ItemSelectMgrFilter.cxx index f8a09377c5..70bf35e55d 100644 --- a/tools/VInspector/VInspector_ItemSelectMgrFilter.cxx +++ b/tools/VInspector/VInspector_ItemSelectMgrFilter.cxx @@ -30,6 +30,10 @@ // ======================================================================= 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(); @@ -37,8 +41,6 @@ QVariant VInspector_ItemSelectMgrFilter::initValue (int theItemRole) const { 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; } } diff --git a/tools/VInspector/VInspector_ItemSelectMgrSelectingVolumeManager.cxx b/tools/VInspector/VInspector_ItemSelectMgrSelectingVolumeManager.cxx new file mode 100644 index 0000000000..8a08b48878 --- /dev/null +++ b/tools/VInspector/VInspector_ItemSelectMgrSelectingVolumeManager.cxx @@ -0,0 +1,170 @@ +// 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 + +#include +#include + +#include + +// ======================================================================= +// 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(Parent()); + //Handle(SelectMgr_SelectingVolumeManager) aVolumeMgr; + //if (aParentItem) + //{ + // VInspector_ItemContextPtr aParentContextItem = itemDynamicCast(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(this)->Init(); +} + +// ======================================================================= +// function : GetTableRowCount +// purpose : +// ======================================================================= +Standard_Boolean VInspector_ItemSelectMgrSelectingVolumeManager::GetViewerSelector (SelectMgr_SelectingVolumeManager& theVolumeManager) const +{ + VInspector_ItemSelectMgrViewerSelectorPtr aParentItem = itemDynamicCast(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(); +} diff --git a/tools/VInspector/VInspector_ItemSelectMgrSelectingVolumeManager.hxx b/tools/VInspector/VInspector_ItemSelectMgrSelectingVolumeManager.hxx new file mode 100644 index 0000000000..b08765e477 --- /dev/null +++ b/tools/VInspector/VInspector_ItemSelectMgrSelectingVolumeManager.hxx @@ -0,0 +1,96 @@ +// 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 +#include + +#include +#include + +class VInspector_ItemSelectMgrSelectingVolumeManager; +typedef QExplicitlySharedDataPointer 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: + //! \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 diff --git a/tools/VInspector/VInspector_ItemSelectMgrSelection.cxx b/tools/VInspector/VInspector_ItemSelectMgrSelection.cxx index 529de360d6..c09ece65cd 100644 --- a/tools/VInspector/VInspector_ItemSelectMgrSelection.cxx +++ b/tools/VInspector/VInspector_ItemSelectMgrSelection.cxx @@ -54,6 +54,10 @@ int VInspector_ItemSelectMgrSelection::initRowCount() const // ======================================================================= QVariant VInspector_ItemSelectMgrSelection::initValue (int theItemRole) const { + QVariant aParentValue = VInspector_ItemBase::initValue (theItemRole); + if (aParentValue.isValid()) + return aParentValue; + switch (theItemRole) { case Qt::DisplayRole: @@ -63,7 +67,6 @@ QVariant VInspector_ItemSelectMgrSelection::initValue (int theItemRole) const switch (Column()) { case 0: return GetSelection()->DynamicType()->Name(); - case 1: return rowCount(); case 3: { if (theItemRole == Qt::ToolTipRole) diff --git a/tools/VInspector/VInspector_ItemSelectMgrSensitiveEntity.cxx b/tools/VInspector/VInspector_ItemSelectMgrSensitiveEntity.cxx index 6a99f4a95d..181ff57b6c 100644 --- a/tools/VInspector/VInspector_ItemSelectMgrSensitiveEntity.cxx +++ b/tools/VInspector/VInspector_ItemSelectMgrSensitiveEntity.cxx @@ -55,6 +55,10 @@ int VInspector_ItemSelectMgrSensitiveEntity::initRowCount() const // ======================================================================= 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) { diff --git a/tools/VInspector/VInspector_ItemSelectMgrViewerSelector.cxx b/tools/VInspector/VInspector_ItemSelectMgrViewerSelector.cxx new file mode 100644 index 0000000000..1f15cf506a --- /dev/null +++ b/tools/VInspector/VInspector_ItemSelectMgrViewerSelector.cxx @@ -0,0 +1,283 @@ +// 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 + +#include +#include + +#include +#include + +#include +#include + +#include +#include +#include + +#include + +// ======================================================================= +// 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(Parent()); + Handle(SelectMgr_ViewerSelector) aViewerSelector; + if (aParentItem) + { + VInspector_ItemContextPtr aParentContextItem = itemDynamicCast(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(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(); +} diff --git a/tools/VInspector/VInspector_ItemSelectMgrViewerSelector.hxx b/tools/VInspector/VInspector_ItemSelectMgrViewerSelector.hxx new file mode 100644 index 0000000000..978a70b34b --- /dev/null +++ b/tools/VInspector/VInspector_ItemSelectMgrViewerSelector.hxx @@ -0,0 +1,140 @@ +// 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 +#include + +#include +#include + +class VInspector_ItemSelectMgrViewerSelector; +typedef QExplicitlySharedDataPointer 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: + //! \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 diff --git a/tools/VInspector/VInspector_ItemSelectMgrViewerSelectorPicked.cxx b/tools/VInspector/VInspector_ItemSelectMgrViewerSelectorPicked.cxx new file mode 100644 index 0000000000..d0fbe4c21c --- /dev/null +++ b/tools/VInspector/VInspector_ItemSelectMgrViewerSelectorPicked.cxx @@ -0,0 +1,238 @@ +// 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 + +#include +#include +#include + +#include +#include +#include + +// ======================================================================= +// 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(this)->Init(); +} + +// ======================================================================= +// function : GetTableRowCount +// purpose : +// ======================================================================= +Handle(SelectMgr_ViewerSelector) VInspector_ItemSelectMgrViewerSelectorPicked::GetViewerSelector (Standard_Integer& theRankId) const +{ + VInspector_ItemSelectMgrViewerSelectorPtr aParentItem = itemDynamicCast(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(); +} diff --git a/tools/VInspector/VInspector_ItemSelectMgrViewerSelectorPicked.hxx b/tools/VInspector/VInspector_ItemSelectMgrViewerSelectorPicked.hxx new file mode 100644 index 0000000000..5262394694 --- /dev/null +++ b/tools/VInspector/VInspector_ItemSelectMgrViewerSelectorPicked.hxx @@ -0,0 +1,113 @@ +// 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 +#include + +#include +#include + +class VInspector_ItemSelectMgrViewerSelectorPicked; +typedef QExplicitlySharedDataPointer 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: + //! \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 diff --git a/tools/VInspector/VInspector_ItemV3dView.cxx b/tools/VInspector/VInspector_ItemV3dView.cxx index 3583e74a8b..beb64c9555 100644 --- a/tools/VInspector/VInspector_ItemV3dView.cxx +++ b/tools/VInspector/VInspector_ItemV3dView.cxx @@ -55,6 +55,10 @@ int VInspector_ItemV3dView::initRowCount() const // ======================================================================= 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(); @@ -64,7 +68,6 @@ QVariant VInspector_ItemV3dView::initValue (const int theItemRole) const switch (Column()) { case 0: return GetView()->DynamicType()->Name(); - case 1: return rowCount(); default: break; } diff --git a/tools/VInspector/VInspector_ItemV3dViewer.cxx b/tools/VInspector/VInspector_ItemV3dViewer.cxx index 114eda6cd9..0cfc80edc5 100644 --- a/tools/VInspector/VInspector_ItemV3dViewer.cxx +++ b/tools/VInspector/VInspector_ItemV3dViewer.cxx @@ -73,6 +73,10 @@ int VInspector_ItemV3dViewer::initRowCount() const // ======================================================================= 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(); @@ -82,7 +86,6 @@ QVariant VInspector_ItemV3dViewer::initValue (const int theItemRole) const switch (Column()) { case 0: return GetViewer()->DynamicType()->Name(); - case 1: return rowCount(); default: break; } diff --git a/tools/VInspector/VInspector_TableModelValues.cxx b/tools/VInspector/VInspector_TableModelValues.cxx index bac85b01e8..a94b4d5e17 100644 --- a/tools/VInspector/VInspector_TableModelValues.cxx +++ b/tools/VInspector/VInspector_TableModelValues.cxx @@ -16,6 +16,7 @@ #include #include +#include #include #include @@ -137,6 +138,31 @@ Qt::ItemFlags VInspector_TableModelValues::Flags (const QModelIndex& theIndex) c 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::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 : @@ -197,6 +223,31 @@ QList VInspector_TableModelValues::GetEnumValues (const int theRow, co return anItem->GetTableEnumValues (aCurrentRow, theColumn); } +// ======================================================================= +// function : GetPaneShapes +// purpose : +// ======================================================================= + +void VInspector_TableModelValues::GetPaneShapes (const int theRow, const int theColumn, NCollection_List& theShapes) +{ + VInspector_ItemBasePtr anItem = GetItem(); + Handle(Standard_Transient) anObject = anItem->GetObject(); + if (anObject.IsNull()) + return; + + for (NCollection_List::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 : diff --git a/tools/VInspector/VInspector_TableModelValues.hxx b/tools/VInspector/VInspector_TableModelValues.hxx index fcc68c3cf4..fb917187ec 100644 --- a/tools/VInspector/VInspector_TableModelValues.hxx +++ b/tools/VInspector/VInspector_TableModelValues.hxx @@ -40,16 +40,21 @@ public: //! Returns number of columns. It has two columns: //! \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 @@ -57,7 +62,7 @@ public: //! \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. @@ -77,6 +82,12 @@ public: //! \return string values for the enumeration presented in the row or an empty container virtual QList 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& theShapes); + private: //!< Returns source item base diff --git a/tools/VInspector/VInspector_Tools.cxx b/tools/VInspector/VInspector_Tools.cxx index 1d1f575c5b..a44046decd 100644 --- a/tools/VInspector/VInspector_Tools.cxx +++ b/tools/VInspector/VInspector_Tools.cxx @@ -69,6 +69,9 @@ TCollection_AsciiString VInspector_Tools::GetShapeTypeInfo (const TopAbs_ShapeEn // ======================================================================= 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) @@ -585,14 +588,16 @@ QVariant VInspector_Tools::ToVariant (const Select3D_BndBox3d& theBoundingBox) //======================================================================= 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); } //======================================================================= @@ -607,16 +612,25 @@ TopoDS_Shape VInspector_Tools::CreateShape (const Select3D_BndBox3d& theBounding 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; } @@ -625,24 +639,24 @@ TopoDS_Shape VInspector_Tools::CreateShape (const Select3D_BndBox3d& theBounding 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; @@ -656,9 +670,7 @@ TopoDS_Shape VInspector_Tools::CreateShape (const Select3D_BndBox3d& theBounding } 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(); } } diff --git a/tools/VInspector/VInspector_Tools.hxx b/tools/VInspector/VInspector_Tools.hxx index fc8790bd2c..add7d38fdc 100644 --- a/tools/VInspector/VInspector_Tools.hxx +++ b/tools/VInspector/VInspector_Tools.hxx @@ -193,6 +193,12 @@ public: //! \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 diff --git a/tools/VInspector/VInspector_ViewModel.cxx b/tools/VInspector/VInspector_ViewModel.cxx index b008f60663..ea7fac8a5f 100644 --- a/tools/VInspector/VInspector_ViewModel.cxx +++ b/tools/VInspector/VInspector_ViewModel.cxx @@ -20,6 +20,9 @@ #include #include #include + +#include + #include #include @@ -42,30 +45,30 @@ VInspector_ViewModel::VInspector_ViewModel (QObject* theParent) SetHeaderItem (0, TreeModel_HeaderSection ("Name", COLUMN_NAME_WIDTH)); SetHeaderItem (1, TreeModel_HeaderSection ("Size", COLUMN_SIZE_WIDTH)); SetHeaderItem (2, TreeModel_HeaderSection ("Pointer", COLUMN_POINTER_WIDTH)); - SetHeaderItem (3, TreeModel_HeaderSection ("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 } // ======================================================================= @@ -105,22 +108,29 @@ void VInspector_ViewModel::SetContext (const Handle(AIS_InteractiveContext)& the // 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(anItemBase); - if (!anItemPrs) + VInspector_ItemBasePtr aVItem = itemDynamicCast(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; } // ======================================================================= diff --git a/tools/VInspector/VInspector_ViewModel.hxx b/tools/VInspector/VInspector_ViewModel.hxx index 2f58f57a1c..55bbecf996 100644 --- a/tools/VInspector/VInspector_ViewModel.hxx +++ b/tools/VInspector/VInspector_ViewModel.hxx @@ -59,8 +59,11 @@ public: //! 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 diff --git a/tools/VInspector/VInspector_Window.cxx b/tools/VInspector/VInspector_Window.cxx index 4814fa251f..4e709c015a 100644 --- a/tools/VInspector/VInspector_Window.cxx +++ b/tools/VInspector/VInspector_Window.cxx @@ -26,6 +26,7 @@ #include #include +#include #include #include @@ -39,6 +40,7 @@ #include #include #include +#include #include #include #include @@ -369,7 +371,7 @@ NCollection_List VInspector_Window::GetSelectedShapes (const QMode { TreeModel_ItemBasePtr anItem = *anItemIt; VInspector_ItemBasePtr aVItem = itemDynamicCast(anItem); - if (!aVItem) + if (!aVItem && aVItem->Row() == 0) continue; TopoDS_Shape aShape = aVItem->GetPresentationShape(); @@ -378,9 +380,65 @@ NCollection_List VInspector_Window::GetSelectedShapes (const QMode aSelectedShapes.Append (aShape); } + + // obtain selection from the property panel + { + QList 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& theShapes) +{ + QList anItems = TreeModel_ModelBase::GetSelectedItems (theTreeViewIndices); + for (QList::const_iterator anItemIt = anItems.begin(); anItemIt != anItems.end(); anItemIt++) + { + TreeModel_ItemBasePtr anItem = *anItemIt; + VInspector_ItemBasePtr aVItem = itemDynamicCast(anItem); + if (!aVItem || aVItem->Column() != 0) + continue; + + QList aTableValues; + VInspector_Tools::GetPropertyTableValues (aVItem, myPaneCreators, aTableValues); + if (aTableValues.isEmpty()) + continue; + + for (int aTableIt = 0; aTableIt < aTableValues.size(); aTableIt++) + { + VInspector_TableModelValues* aTableVals = dynamic_cast(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 : @@ -463,6 +521,13 @@ bool VInspector_Window::Init (const NCollection_List 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; @@ -544,6 +609,11 @@ void VInspector_Window::onTreeViewContextMenuRequested(const QPoint& thePosition 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); } @@ -608,19 +678,6 @@ void VInspector_Window::onPropertyPanelShown (bool isToggled) // ======================================================================= 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(anItemBase); - if (!anAlertItem) - return; - QList aPropertyTables; myPropertyView->GetActiveTables (aPropertyTables); if (aPropertyTables.isEmpty()) @@ -631,37 +688,36 @@ void VInspector_Window::onPropertyViewSelectionChanged() QMap> aSelectedIndices; aFirstTable->GetSelectedIndices (aSelectedIndices); - // clear presentation if selection is empty - MessageModel_TreeModel* aTreeModel = dynamic_cast (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(aFirstTable->GetTableView()->model()); + ViewControl_TableModelValues* aTableValues = aTableModel->GetModelValues(); - if (aVisibilityState->IsVisible (anIndex)) + QStringList aPointers; + for (QMap>::const_iterator aSelIt = aSelectedIndices.begin(); aSelIt != aSelectedIndices.end(); aSelIt++) { - View_Displayer* aDisplayer = myViewWindow->GetDisplayer(); + int aRowId = aSelIt.key(); + QList 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 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); } // ======================================================================= @@ -682,6 +738,7 @@ void VInspector_Window::onTreeViewSelectionChanged (const QItemSelection&, updatePropertyPanelBySelection(); Handle(Graphic3d_TransformPers) aSelectedPersistent = GetSelectedTransformPers(); + NCollection_List aSelectedShapes = GetSelectedShapes (myTreeView->selectionModel()->selectedIndexes()); updatePreviewPresentation(aSelectedShapes, aSelectedPersistent); @@ -707,20 +764,7 @@ void VInspector_Window::onHistoryViewSelectionChanged (const QItemSelection& the QModelIndexList aSelectedIndices = theSelected.indexes(); QStringList aPointers = aHistoryModel->GetSelectedPointers(aSelectedIndices.first()); - - VInspector_ViewModel* aTreeModel = dynamic_cast (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); } // ======================================================================= @@ -783,6 +827,57 @@ void VInspector_Window::onDisplayActionTypeClicked() 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 @@ -931,6 +1026,51 @@ void VInspector_Window::displaySelectedPresentations (const VInspector_DisplayAc UpdateTreeModel(); } +// ======================================================================= +// function : highlightTreeViewItems +// purpose : +// ======================================================================= +void VInspector_Window::highlightTreeViewItems (const QStringList& thePointers) +{ + VInspector_ViewModel* aTreeModel = dynamic_cast (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 (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 : @@ -1003,12 +1143,12 @@ void VInspector_Window::updatePreviewPresentation (const NCollection_ListSetColor (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 { diff --git a/tools/VInspector/VInspector_Window.hxx b/tools/VInspector/VInspector_Window.hxx index f82d2f9eb5..b806e92518 100644 --- a/tools/VInspector/VInspector_Window.hxx +++ b/tools/VInspector/VInspector_Window.hxx @@ -107,6 +107,13 @@ public: //! \return container of shapes NCollection_List 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& theShapes); + //! Returns selected elements //! \param theModel selection model //! \return container of OpenGl elements @@ -163,6 +170,15 @@ private slots: //! 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 @@ -200,6 +216,14 @@ private: //! \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(); diff --git a/tools/VInspectorPaneAIS/FILES b/tools/VInspectorPaneAIS/FILES index c1faaa5dfa..310e98b5ae 100644 --- a/tools/VInspectorPaneAIS/FILES +++ b/tools/VInspectorPaneAIS/FILES @@ -1,6 +1,4 @@ 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 diff --git a/tools/VInspectorPaneAIS/VInspectorPaneAIS_PaneCreator.cxx b/tools/VInspectorPaneAIS/VInspectorPaneAIS_PaneCreator.cxx index c19e361fd0..7bde9e2398 100644 --- a/tools/VInspectorPaneAIS/VInspectorPaneAIS_PaneCreator.cxx +++ b/tools/VInspectorPaneAIS/VInspectorPaneAIS_PaneCreator.cxx @@ -15,12 +15,10 @@ #include #include -#include #include -#include -IMPLEMENT_STANDARD_RTTIEXT(VInspectorPaneAIS_PaneCreator, VInspectorAPI_CallBack) +IMPLEMENT_STANDARD_RTTIEXT(VInspectorPaneAIS_PaneCreator, ViewControl_PaneCreator) // ======================================================================= // function : createPane @@ -30,8 +28,6 @@ ViewControl_Pane* VInspectorPaneAIS_PaneCreator::createPane (const Standard_CStr { 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; } diff --git a/tools/VInspectorPaneAIS/VInspectorPaneAIS_Shape.cxx b/tools/VInspectorPaneAIS/VInspectorPaneAIS_Shape.cxx index f57d355660..f4378b68d8 100644 --- a/tools/VInspectorPaneAIS/VInspectorPaneAIS_Shape.cxx +++ b/tools/VInspectorPaneAIS/VInspectorPaneAIS_Shape.cxx @@ -15,39 +15,14 @@ #include -//#include -//#include -//#include -//#include -// -//#include -//#include -//#include -//#include -//#include #include #include #include -//#include #include #include #include -// -//#include -//#include -//#include -//#include -//#include -//#include -//#include -//#include -// -//#include -//#include -//#include -//#include // ======================================================================= // function : GetTableRowCount @@ -99,105 +74,6 @@ QVariant VInspectorPaneAIS_Shape::GetTableData (const Handle(Standard_Transient) 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 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(); - - QList 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 : diff --git a/tools/VInspectorPaneAIS/VInspectorPaneAIS_Shape.hxx b/tools/VInspectorPaneAIS/VInspectorPaneAIS_Shape.hxx index 9fad94bb12..eb8ceeca08 100644 --- a/tools/VInspectorPaneAIS/VInspectorPaneAIS_Shape.hxx +++ b/tools/VInspectorPaneAIS/VInspectorPaneAIS_Shape.hxx @@ -42,35 +42,17 @@ public: //! \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 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 diff --git a/tools/VInspectorPaneAIS/VInspectorPaneAIS_Trihedron.cxx b/tools/VInspectorPaneAIS/VInspectorPaneAIS_Trihedron.cxx deleted file mode 100644 index 35c0169d99..0000000000 --- a/tools/VInspectorPaneAIS/VInspectorPaneAIS_Trihedron.cxx +++ /dev/null @@ -1,17 +0,0 @@ -// 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 - diff --git a/tools/VInspectorPaneAIS/VInspectorPaneAIS_Trihedron.hxx b/tools/VInspectorPaneAIS/VInspectorPaneAIS_Trihedron.hxx deleted file mode 100644 index 33ea153834..0000000000 --- a/tools/VInspectorPaneAIS/VInspectorPaneAIS_Trihedron.hxx +++ /dev/null @@ -1,29 +0,0 @@ -// 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 -#include - -//! \class VInspectorPaneAIS_Trihedron -//! Item presents information about AIS_InteractiveObject. -//! Parent is item context, children are item selections. -class VInspectorPaneAIS_Trihedron : public ViewControl_Pane -{ -}; - -#endif diff --git a/tools/View/View_Displayer.cxx b/tools/View/View_Displayer.cxx index e218cae80e..49fa790828 100644 --- a/tools/View/View_Displayer.cxx +++ b/tools/View/View_Displayer.cxx @@ -23,8 +23,10 @@ #include #include #include + #include #include +#include // ======================================================================= // function : Constructor @@ -277,18 +279,7 @@ void View_Displayer::DisplayedPresentations (NCollection_SharedCurrentViewer(); - if (!aViewer.IsNull()) - { - aViewer->InitActiveViews(); - if (aViewer->MoreActiveViews()) - aView = aViewer->ActiveView(); - } - return aView; + return View_Tools::FindActiveView (GetContext()); } // ======================================================================= diff --git a/tools/View/View_Tools.cxx b/tools/View/View_Tools.cxx index 3ecb175c22..3ed8a92f5e 100644 --- a/tools/View/View_Tools.cxx +++ b/tools/View/View_Tools.cxx @@ -36,6 +36,26 @@ QAction* View_Tools::CreateAction (const QString& theText, const char* theSlot, 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 : diff --git a/tools/View/View_Tools.hxx b/tools/View/View_Tools.hxx index 2c105f7ed6..b3c49a76e0 100644 --- a/tools/View/View_Tools.hxx +++ b/tools/View/View_Tools.hxx @@ -24,6 +24,9 @@ #include #include +#include +#include + class View_Window; class QAction; @@ -44,6 +47,11 @@ public: 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 diff --git a/tools/ViewControl/ViewControl_ColorSelector.cxx b/tools/ViewControl/ViewControl_ColorSelector.cxx index efaf568794..5129c89d96 100644 --- a/tools/ViewControl/ViewControl_ColorSelector.cxx +++ b/tools/ViewControl/ViewControl_ColorSelector.cxx @@ -20,7 +20,7 @@ #include #include -//#include +#include #include #include @@ -85,7 +85,7 @@ public: 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()); @@ -93,7 +93,7 @@ public: 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(); } @@ -236,8 +236,8 @@ public: 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(); } diff --git a/tools/ViewControl/ViewControl_Table.cxx b/tools/ViewControl/ViewControl_Table.cxx index 19f866acfc..fee84d2c06 100644 --- a/tools/ViewControl/ViewControl_Table.cxx +++ b/tools/ViewControl/ViewControl_Table.cxx @@ -109,11 +109,13 @@ void ViewControl_Table::Init (ViewControl_TableModelValues* theModelValues) void ViewControl_Table::GetSelectedIndices (QMap>& theSelectedIndices) { QModelIndexList aSelected = myTableView->selectionModel()->selectedIndexes(); - ViewControl_TableModel* aModel = dynamic_cast (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()); theSelectedIndices[aRow].append (aColumn); -- 2.39.5