mirror of
https://git.dev.opencascade.org/repos/occt.git
synced 2025-08-04 13:13:25 +03:00
0029674: Improvements in Inspector tool
- preferences for dock windows geometry, tree view columns and current view projection; - ViewControl package for common functionality between plugins; - processing Location and Orientation for external TopoDS_Shape object - 'F5' key to update content of each plugin - visibility column in tree view (used now only in ShapeView) - properties child item for context (presents tree of current Filters of context)
This commit is contained in:
@@ -25,6 +25,8 @@
|
||||
#include <inspector/DFBrowser_SearchView.hxx>
|
||||
#include <inspector/DFBrowser_Window.hxx>
|
||||
|
||||
#include <inspector/ViewControl_Tools.hxx>
|
||||
|
||||
#include <TDF_Attribute.hxx>
|
||||
|
||||
#include <Standard_WarningsDisable.hxx>
|
||||
@@ -51,9 +53,9 @@ DFBrowser_AttributePaneStack::DFBrowser_AttributePaneStack (QObject* theParent)
|
||||
void DFBrowser_AttributePaneStack::CreateWidget (QWidget* theParent)
|
||||
{
|
||||
myAttributesStack = new QStackedWidget (theParent);
|
||||
DFBrowser_Window::SetWhiteBackground (myAttributesStack);
|
||||
ViewControl_Tools::SetWhiteBackground (myAttributesStack);
|
||||
myEmptyWidget = new QWidget (theParent);
|
||||
DFBrowser_Window::SetWhiteBackground (myEmptyWidget);
|
||||
ViewControl_Tools::SetWhiteBackground (myEmptyWidget);
|
||||
|
||||
myAttributesStack->addWidget (myEmptyWidget);
|
||||
|
||||
@@ -87,7 +89,7 @@ void DFBrowser_AttributePaneStack::SetPaneMode (const DFBrowser_AttributePaneTyp
|
||||
else
|
||||
{
|
||||
QItemSelectionModel* aSelectionModel = myModule->GetOCAFViewSelectionModel();
|
||||
QModelIndex anIndex = DFBrowser_Window::SingleSelected (aSelectionModel->selectedIndexes(), 0);
|
||||
QModelIndex anIndex = TreeModel_ModelBase::SingleSelected (aSelectionModel->selectedIndexes(), 0);
|
||||
SetCurrentItem (anIndex);
|
||||
}
|
||||
}
|
||||
|
@@ -49,6 +49,20 @@ public:
|
||||
//! \param theParameters a parameters container
|
||||
Standard_EXPORT virtual void SetParameters (const Handle(TInspectorAPI_PluginParameters)& theParameters) Standard_OVERRIDE;
|
||||
|
||||
//! Provide container for actions available in inspector on general level
|
||||
//! \param theMenu if Qt implementation, it is QMenu object
|
||||
Standard_EXPORT virtual void FillActionsMenu (void* theMenu) Standard_OVERRIDE { myWindow->FillActionsMenu (theMenu); }
|
||||
|
||||
//! Returns plugin preferences, empty implementation by default
|
||||
//! \param theItem container of preference elements
|
||||
virtual void GetPreferences (TInspectorAPI_PreferencesDataMap& theItem) Standard_OVERRIDE
|
||||
{ myWindow->GetPreferences (theItem); }
|
||||
|
||||
//! Stores plugin preferences, empty implementation by default
|
||||
//! \param theItem container of preference elements
|
||||
virtual void SetPreferences (const TInspectorAPI_PreferencesDataMap& theItem) Standard_OVERRIDE
|
||||
{ myWindow->SetPreferences (theItem); }
|
||||
|
||||
//! Updates content of the current window
|
||||
virtual void UpdateContent() Standard_OVERRIDE { myWindow->UpdateContent(); }
|
||||
|
||||
|
@@ -31,8 +31,6 @@
|
||||
#include <QObject>
|
||||
#include <Standard_WarningsRestore.hxx>
|
||||
|
||||
const int INFO_LENGHT = 60;
|
||||
|
||||
// =======================================================================
|
||||
// function : hasAttribute
|
||||
// purpose :
|
||||
@@ -136,8 +134,8 @@ QVariant DFBrowser_Item::initValue (const int theItemRole) const
|
||||
DFBrowser_ItemRole_AdditionalInfo, Column()).toString();
|
||||
if (!anAdditionalInfo.isEmpty())
|
||||
{
|
||||
if (theItemRole == DFBrowserPane_ItemRole_DisplayExtended && anAdditionalInfo.length() > INFO_LENGHT)
|
||||
anAdditionalInfo = anAdditionalInfo.mid (0, INFO_LENGHT - 3) + "...";
|
||||
if (theItemRole == DFBrowserPane_ItemRole_DisplayExtended)
|
||||
anAdditionalInfo = TreeModel_Tools::CutString (anAdditionalInfo);
|
||||
if (!anAdditionalInfo.isEmpty())
|
||||
aValue = QVariant (aValue.toString() + QString (" [%1]").arg (anAdditionalInfo));
|
||||
//if (aRole == Qt::ToolTipRole)
|
||||
|
@@ -21,6 +21,10 @@
|
||||
#include <inspector/DFBrowser_Window.hxx>
|
||||
#include <inspector/DFBrowser_TreeLevelView.hxx>
|
||||
|
||||
#include <inspector/TreeModel_ModelBase.hxx>
|
||||
|
||||
#include <inspector/ViewControl_Tools.hxx>
|
||||
|
||||
#include <Standard_WarningsDisable.hxx>
|
||||
#include <QAbstractItemModel>
|
||||
#include <QGridLayout>
|
||||
@@ -36,7 +40,7 @@ DFBrowser_PropertyPanel::DFBrowser_PropertyPanel (QWidget* theParent)
|
||||
: QObject (theParent), myAttributesStack (0)
|
||||
{
|
||||
myMainWindow = new QWidget (theParent);
|
||||
DFBrowser_Window::SetWhiteBackground (myMainWindow);
|
||||
ViewControl_Tools::SetWhiteBackground (myMainWindow);
|
||||
|
||||
QGridLayout* aLayout = new QGridLayout (myMainWindow);
|
||||
aLayout->setContentsMargins (0, 0, 0, 0);
|
||||
@@ -55,6 +59,6 @@ void DFBrowser_PropertyPanel::UpdateBySelectionChanged (const QItemSelection& th
|
||||
{
|
||||
GetAttributesStack()->GetSearchView()->Reset();
|
||||
|
||||
QModelIndex anIndex = DFBrowser_Window::SingleSelected (theSelected.indexes(), 0);
|
||||
QModelIndex anIndex = TreeModel_ModelBase::SingleSelected (theSelected.indexes(), 0);
|
||||
myAttributesStack->SetCurrentItem (anIndex);
|
||||
}
|
||||
|
@@ -20,6 +20,8 @@
|
||||
#include <inspector/DFBrowserPane_Tools.hxx>
|
||||
#include <inspector/DFBrowser_Module.hxx>
|
||||
|
||||
#include <inspector/ViewControl_Tools.hxx>
|
||||
|
||||
#include <TDocStd_Application.hxx>
|
||||
#include <TDocStd_Document.hxx>
|
||||
#include <TDF_AttributeIterator.hxx>
|
||||
@@ -108,7 +110,7 @@ DFBrowser_SearchLine::DFBrowser_SearchLine (QWidget* theParent)
|
||||
connect (myLineControl, SIGNAL (returnPressed()), this, SLOT (onReturnPressed()));
|
||||
connect (mySearchButton, SIGNAL (clicked()), this, SLOT (onSearchButtonClicked()));
|
||||
|
||||
DFBrowser_Window::SetWhiteBackground (this);
|
||||
ViewControl_Tools::SetWhiteBackground (this);
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
|
@@ -22,6 +22,11 @@
|
||||
|
||||
#include <inspector/DFBrowserPane_Tools.hxx>
|
||||
|
||||
#include <inspector/TreeModel_ModelBase.hxx>
|
||||
#include <inspector/TreeModel_Tools.hxx>
|
||||
|
||||
#include <inspector/ViewControl_Tools.hxx>
|
||||
|
||||
#include <Standard_WarningsDisable.hxx>
|
||||
#include <QAbstractProxyModel>
|
||||
#include <QGridLayout>
|
||||
@@ -46,7 +51,7 @@ DFBrowser_SearchView::DFBrowser_SearchView (QWidget* theParent)
|
||||
|
||||
myTableView = new QTableView (myMainWindow);
|
||||
myTableView->verticalHeader()->setVisible (false);
|
||||
myTableView->verticalHeader()->setDefaultSectionSize (DEFAULT_ICON_SIZE + DFBrowserPane_Tools::HeaderSectionMargin());
|
||||
myTableView->verticalHeader()->setDefaultSectionSize (DEFAULT_ICON_SIZE + TreeModel_Tools::HeaderSectionMargin());
|
||||
myTableView->setIconSize (QSize (DEFAULT_ICON_SIZE, DEFAULT_ICON_SIZE));
|
||||
myTableView->horizontalHeader()->setVisible (false);
|
||||
myTableView->horizontalHeader()->setStretchLastSection (true);
|
||||
@@ -56,7 +61,7 @@ DFBrowser_SearchView::DFBrowser_SearchView (QWidget* theParent)
|
||||
|
||||
aLayout->addWidget (myTableView);
|
||||
|
||||
DFBrowser_Window::SetWhiteBackground (myTableView);
|
||||
ViewControl_Tools::SetWhiteBackground (myTableView);
|
||||
myTableView->setGridStyle (Qt::NoPen);
|
||||
}
|
||||
|
||||
@@ -69,7 +74,7 @@ void DFBrowser_SearchView::InitModels()
|
||||
QAbstractItemModel* aModel = mySearchLine->GetCompletionModel();
|
||||
myTableView->setModel (aModel);
|
||||
myTableView->setColumnWidth (0, 0); // to hide column
|
||||
myTableView->setColumnWidth (1, DEFAULT_ICON_SIZE + DFBrowserPane_Tools::HeaderSectionMargin());
|
||||
myTableView->setColumnWidth (1, DEFAULT_ICON_SIZE + TreeModel_Tools::HeaderSectionMargin());
|
||||
|
||||
QItemSelectionModel* aSelectionModel = new QItemSelectionModel (aModel);
|
||||
myTableView->setSelectionMode (QAbstractItemView::SingleSelection);
|
||||
@@ -89,7 +94,7 @@ void DFBrowser_SearchView::onTableSelectionChanged (const QItemSelection&,
|
||||
{
|
||||
QItemSelectionModel* aSelectionModel = myTableView->selectionModel();
|
||||
QModelIndexList aSelectedIndices = aSelectionModel->selectedIndexes();
|
||||
QModelIndex aSelectedIndex = DFBrowser_Window::SingleSelected (aSelectedIndices, 2);
|
||||
QModelIndex aSelectedIndex = TreeModel_ModelBase::SingleSelected (aSelectedIndices, 2);
|
||||
if (!aSelectedIndex.isValid())
|
||||
return;
|
||||
QAbstractProxyModel* aTableModel = dynamic_cast<QAbstractProxyModel*> (myTableView->model());
|
||||
|
@@ -1,55 +0,0 @@
|
||||
// Created on: 2017-06-16
|
||||
// Created by: Natalia ERMOLAEVA
|
||||
// Copyright (c) 2017 OPEN CASCADE SAS
|
||||
//
|
||||
// This file is part of Open CASCADE Technology software library.
|
||||
//
|
||||
// This library is free software; you can redistribute it and/or modify it under
|
||||
// the terms of the GNU Lesser General Public License version 2.1 as published
|
||||
// by the Free Software Foundation, with special exception defined in the file
|
||||
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
|
||||
// distribution for complete text of the license and disclaimer of any warranty.
|
||||
//
|
||||
// Alternatively, this file may be used under the terms of Open CASCADE
|
||||
// commercial license or contractual agreement.
|
||||
|
||||
#include <inspector/DFBrowser_Shortcut.hxx>
|
||||
|
||||
#include <inspector/DFBrowser_Module.hxx>
|
||||
|
||||
#include <Standard_WarningsDisable.hxx>
|
||||
#include <QApplication>
|
||||
#include <QKeyEvent>
|
||||
#include <Standard_WarningsRestore.hxx>
|
||||
|
||||
// =======================================================================
|
||||
// function : Constructor
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
DFBrowser_Shortcut::DFBrowser_Shortcut (QObject* theParent)
|
||||
: QObject (theParent), myModule (0)
|
||||
{
|
||||
qApp->installEventFilter (this);
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : eventFilter
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
bool DFBrowser_Shortcut::eventFilter (QObject* theObject, QEvent* theEvent)
|
||||
{
|
||||
if (!myModule || theEvent->type() != QEvent::KeyRelease)
|
||||
return QObject::eventFilter (theObject, theEvent);
|
||||
|
||||
QKeyEvent* aKeyEvent = dynamic_cast<QKeyEvent*> (theEvent);
|
||||
switch (aKeyEvent->key())
|
||||
{
|
||||
case Qt::Key_F5:
|
||||
{
|
||||
myModule->UpdateTreeModel();
|
||||
return true;
|
||||
}
|
||||
default: break;
|
||||
}
|
||||
return QObject::eventFilter (theObject, theEvent);
|
||||
}
|
@@ -1,54 +0,0 @@
|
||||
// Created on: 2017-06-16
|
||||
// Created by: Natalia ERMOLAEVA
|
||||
// Copyright (c) 2017 OPEN CASCADE SAS
|
||||
//
|
||||
// This file is part of Open CASCADE Technology software library.
|
||||
//
|
||||
// This library is free software; you can redistribute it and/or modify it under
|
||||
// the terms of the GNU Lesser General Public License version 2.1 as published
|
||||
// by the Free Software Foundation, with special exception defined in the file
|
||||
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
|
||||
// distribution for complete text of the license and disclaimer of any warranty.
|
||||
//
|
||||
// Alternatively, this file may be used under the terms of Open CASCADE
|
||||
// commercial license or contractual agreement.
|
||||
|
||||
#ifndef DFBrowser_Shortcut_H
|
||||
#define DFBrowser_Shortcut_H
|
||||
|
||||
#include <Standard.hxx>
|
||||
#include <Standard_Macro.hxx>
|
||||
|
||||
#include <Standard_WarningsDisable.hxx>
|
||||
#include <QObject>
|
||||
#include <Standard_WarningsRestore.hxx>
|
||||
|
||||
class DFBrowser_Module;
|
||||
class QEvent;
|
||||
|
||||
//! \class DFBrowser_Shortcut
|
||||
//! Listens application KeyRelease event. Processes key event:
|
||||
//! - <Key_F5>: updates tree view model
|
||||
class DFBrowser_Shortcut : public QObject
|
||||
{
|
||||
public:
|
||||
|
||||
//! Constructor
|
||||
Standard_EXPORT DFBrowser_Shortcut (QObject* theParent);
|
||||
|
||||
//! Destructor
|
||||
virtual ~DFBrowser_Shortcut() {}
|
||||
|
||||
//! Sets the current module
|
||||
//! \param theModule a module
|
||||
void SetModule (DFBrowser_Module* theModule) { myModule = theModule; }
|
||||
|
||||
//! Processes key release event to update view model, otherwise do usual QObject functionality
|
||||
Standard_EXPORT virtual bool eventFilter (QObject *theObject, QEvent* theEvent) Standard_OVERRIDE;
|
||||
|
||||
private:
|
||||
DFBrowser_Module* myModule; //!< the current module
|
||||
};
|
||||
|
||||
|
||||
#endif
|
@@ -15,7 +15,6 @@
|
||||
|
||||
#include <inspector/DFBrowser_Thread.hxx>
|
||||
#include <inspector/DFBrowser_ThreadItemSearch.hxx>
|
||||
#include <inspector/DFBrowser_ThreadItemUsedShapesMap.hxx>
|
||||
#include <inspector/DFBrowser_TreeLevelLine.hxx>
|
||||
#include <inspector/DFBrowser_SearchLine.hxx>
|
||||
|
||||
@@ -67,21 +66,6 @@ DFBrowser_Thread::DFBrowser_Thread (DFBrowser_Window* theWindow)
|
||||
{
|
||||
DFBrowser_SearchLine* aSearchLine = theWindow->GetTreeLevelLine()->GetSearchLine();
|
||||
myItems.append (new DFBrowser_ThreadItemSearch(aSearchLine));
|
||||
myItems.append (new DFBrowser_ThreadItemUsedShapesMap());
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : SetModule
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
void DFBrowser_Thread::SetModule (DFBrowser_Module* theModule)
|
||||
{
|
||||
for (int anItemId = 0, aSize = myItems.size(); anItemId < aSize; anItemId++)
|
||||
{
|
||||
DFBrowser_ThreadItemUsedShapesMap* aShapesItem = dynamic_cast<DFBrowser_ThreadItemUsedShapesMap*> (myItems[anItemId]);
|
||||
if (aShapesItem)
|
||||
aShapesItem->SetModule (theModule);
|
||||
}
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
|
@@ -42,10 +42,6 @@ public:
|
||||
//! Destructor
|
||||
virtual ~DFBrowser_Thread() {}
|
||||
|
||||
//! Sets module to the started thread items
|
||||
//! \param theModule a current module
|
||||
Standard_EXPORT void SetModule (DFBrowser_Module* theModule);
|
||||
|
||||
//! Starts all candidate thread items
|
||||
Standard_EXPORT void ProcessApplication();
|
||||
|
||||
|
@@ -1,223 +0,0 @@
|
||||
// Created on: 2017-06-16
|
||||
// Created by: Natalia ERMOLAEVA
|
||||
// Copyright (c) 2017 OPEN CASCADE SAS
|
||||
//
|
||||
// This file is part of Open CASCADE Technology software library.
|
||||
//
|
||||
// This library is free software; you can redistribute it and/or modify it under
|
||||
// the terms of the GNU Lesser General Public License version 2.1 as published
|
||||
// by the Free Software Foundation, with special exception defined in the file
|
||||
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
|
||||
// distribution for complete text of the license and disclaimer of any warranty.
|
||||
//
|
||||
// Alternatively, this file may be used under the terms of Open CASCADE
|
||||
// commercial license or contractual agreement.
|
||||
|
||||
#include <inspector/DFBrowser_ThreadItemUsedShapesMap.hxx>
|
||||
|
||||
#include <inspector/DFBrowser_Module.hxx>
|
||||
#include <inspector/DFBrowser_Tools.hxx>
|
||||
#include <inspector/DFBrowser_TreeModel.hxx>
|
||||
|
||||
#include <inspector/DFBrowserPane_TNamingUsedShapes.hxx>
|
||||
#include <inspector/DFBrowserPane_Tools.hxx>
|
||||
|
||||
#include <TNaming_DataMapIteratorOfDataMapOfShapePtrRefShape.hxx>
|
||||
#include <TNaming_PtrRefShape.hxx>
|
||||
#include <TNaming_RefShape.hxx>
|
||||
#include <TNaming_UsedShapes.hxx>
|
||||
|
||||
#include <Standard_Type.hxx>
|
||||
#include <TDocStd_Document.hxx>
|
||||
|
||||
// =======================================================================
|
||||
// function : Run
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
void DFBrowser_ThreadItemUsedShapesMap::Run()
|
||||
{
|
||||
if (!myModule)
|
||||
return;
|
||||
DFBrowser_TreeModel* aDFBrowserModel = dynamic_cast<DFBrowser_TreeModel*> (myModule->GetOCAFViewModel());
|
||||
if (!aDFBrowserModel)
|
||||
return;
|
||||
|
||||
Handle(TDocStd_Application) anApplication = aDFBrowserModel->GetTDocStdApplication();
|
||||
if (anApplication.IsNull())
|
||||
return;
|
||||
|
||||
for (Standard_Integer aDocId = 1, aNbDocuments = anApplication->NbDocuments(); aDocId <= aNbDocuments; aDocId++)
|
||||
{
|
||||
Handle(TDocStd_Document) aDocument;
|
||||
anApplication->GetDocument (aDocId, aDocument);
|
||||
if (aDocument.IsNull())
|
||||
continue;
|
||||
|
||||
TDF_Label aLabel = aDocument->Main().Root();
|
||||
|
||||
Handle(TNaming_UsedShapes) anAttribute;
|
||||
if (!aLabel.FindAttribute (TNaming_UsedShapes::GetID(), anAttribute))
|
||||
continue;
|
||||
|
||||
std::list<TCollection_AsciiString> aReferences;
|
||||
findReferences (anAttribute, aReferences);
|
||||
if (!aReferences.empty())
|
||||
myAttributeRefs.Bind (anAttribute, aReferences);
|
||||
}
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : ApplyValues
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
void DFBrowser_ThreadItemUsedShapesMap::ApplyValues()
|
||||
{
|
||||
if (myAttributeRefs.IsEmpty())
|
||||
return;
|
||||
|
||||
DFBrowserPane_AttributePaneAPI* aPane = myModule->GetAttributePane (STANDARD_TYPE (TNaming_UsedShapes)->Name());
|
||||
if (aPane)
|
||||
{
|
||||
DFBrowserPane_TNamingUsedShapes* aUsedShapesPane = dynamic_cast<DFBrowserPane_TNamingUsedShapes*> (aPane);
|
||||
aUsedShapesPane->SetSortedReferences (myAttributeRefs);
|
||||
}
|
||||
// update
|
||||
DFBrowser_TreeModel* aDFBrowserModel = dynamic_cast<DFBrowser_TreeModel*> (myModule->GetOCAFViewModel());
|
||||
for (NCollection_DataMap<Handle(TDF_Attribute), std::list<TCollection_AsciiString> >::Iterator aRefIt (myAttributeRefs);
|
||||
aRefIt.More(); aRefIt.Next())
|
||||
{
|
||||
TreeModel_ItemBasePtr anItemBase = TreeModel_ModelBase::GetItemByIndex
|
||||
(aDFBrowserModel->FindIndexByAttribute (aRefIt.Key()));
|
||||
if (anItemBase)
|
||||
{
|
||||
anItemBase->Reset();
|
||||
anItemBase->Init();
|
||||
}
|
||||
}
|
||||
// clear cache
|
||||
myAttributeRefs.Clear();
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : ClearSortedReferences
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
void DFBrowser_ThreadItemUsedShapesMap::ClearSortedReferences (DFBrowser_Module* theModule)
|
||||
{
|
||||
DFBrowserPane_AttributePaneAPI* aPane = theModule->GetAttributePane (STANDARD_TYPE (TNaming_UsedShapes)->Name());
|
||||
if (!aPane)
|
||||
return;
|
||||
|
||||
DFBrowserPane_TNamingUsedShapes* aUsedShapesPane = dynamic_cast<DFBrowserPane_TNamingUsedShapes*> (aPane);
|
||||
aUsedShapesPane->ClearSortedReferences();
|
||||
|
||||
// update tree item state
|
||||
DFBrowser_TreeModel* aDFBrowserModel = dynamic_cast<DFBrowser_TreeModel*> (theModule->GetOCAFViewModel());
|
||||
if (!aDFBrowserModel)
|
||||
return;
|
||||
Handle(TDocStd_Application) anApplication = aDFBrowserModel->GetTDocStdApplication();
|
||||
if (anApplication.IsNull())
|
||||
return;
|
||||
|
||||
for (Standard_Integer aDocId = 1, aNbDocuments = anApplication->NbDocuments(); aDocId <= aNbDocuments; aDocId++)
|
||||
{
|
||||
Handle(TDocStd_Document) aDocument;
|
||||
anApplication->GetDocument (aDocId, aDocument);
|
||||
if (aDocument.IsNull())
|
||||
continue;
|
||||
TDF_Label aLabel = aDocument->Main().Root();
|
||||
Handle(TNaming_UsedShapes) anAttribute;
|
||||
if (aLabel.FindAttribute (TNaming_UsedShapes::GetID(), anAttribute))
|
||||
{
|
||||
TreeModel_ItemBasePtr anItemBase = TreeModel_ModelBase::GetItemByIndex(
|
||||
aDFBrowserModel->FindIndexByAttribute (anAttribute));
|
||||
if (anItemBase)
|
||||
anItemBase->Init();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : isLessThan
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
bool DFBrowser_ThreadItemUsedShapesMap::isLessThan (const QStringList& theLeft, const QStringList& theRight)
|
||||
{
|
||||
int aState = 1; //! where 0 - less, 1 - equal, 2 - larger
|
||||
int aLeftSize = theLeft.size();
|
||||
int aRightSize = theRight.size();
|
||||
|
||||
for (int anItemId = 0; anItemId < aRightSize && anItemId < aLeftSize && aState == 1; anItemId++)
|
||||
{
|
||||
int aRightId = theRight[anItemId].toInt();
|
||||
int aLeftId = theLeft[anItemId].toInt();
|
||||
if (aLeftId == aRightId)
|
||||
continue;
|
||||
else if (aLeftId < aRightId)
|
||||
aState = 0; // less
|
||||
else if (aLeftId > aRightId)
|
||||
aState = 2; // less
|
||||
}
|
||||
if (aState == 1)
|
||||
{ // equal in similar parts
|
||||
if (aLeftSize < aRightSize)
|
||||
aState = 0;
|
||||
else if (aLeftSize > aRightSize)
|
||||
aState = 2;
|
||||
}
|
||||
return aState == 0;
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : addValue
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
void DFBrowser_ThreadItemUsedShapesMap::addValue (const TCollection_AsciiString& theEntry,
|
||||
QList<QPair<TCollection_AsciiString, QStringList > >& theEntries)
|
||||
{
|
||||
QStringList aSplit = QString (theEntry.ToCString()).split (":");
|
||||
|
||||
int aLessIndex = -1;
|
||||
bool isInserted = false;
|
||||
// looking for nearest smaller value from the end of the list
|
||||
for (int anEntryId = theEntries.size() - 1; anEntryId >= 0 && !isInserted; anEntryId--)
|
||||
{
|
||||
if (isLessThan(aSplit, theEntries[anEntryId].second))
|
||||
aLessIndex = anEntryId;
|
||||
else
|
||||
{
|
||||
// if less than was found and now, the entry is greater than current entry
|
||||
if (aLessIndex != -1)
|
||||
{
|
||||
theEntries.insert (aLessIndex, qMakePair (theEntry, aSplit));
|
||||
isInserted = true;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!isInserted)
|
||||
{
|
||||
if (aLessIndex != -1) // less than all, insert at this position
|
||||
theEntries.insert (aLessIndex, qMakePair (theEntry, aSplit));
|
||||
else
|
||||
theEntries.append (qMakePair (theEntry, aSplit));
|
||||
}
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : findReferences
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
void DFBrowser_ThreadItemUsedShapesMap::findReferences (Handle(TDF_Attribute) theAttribute,
|
||||
std::list<TCollection_AsciiString>& theReferences)
|
||||
{
|
||||
Handle(TNaming_UsedShapes) anAttribute = Handle(TNaming_UsedShapes)::DownCast (theAttribute);
|
||||
|
||||
QList<QPair<TCollection_AsciiString, QStringList> > anEntries;
|
||||
for (TNaming_DataMapIteratorOfDataMapOfShapePtrRefShape aDataIt(anAttribute->Map()); aDataIt.More(); aDataIt.Next())
|
||||
addValue(DFBrowserPane_Tools::GetEntry (aDataIt.Value()->Label()), anEntries);
|
||||
|
||||
for (QList<QPair<TCollection_AsciiString, QStringList> >::const_iterator anEntryIt = anEntries.begin();
|
||||
anEntryIt != anEntries.end(); anEntryIt++)
|
||||
theReferences.push_back (anEntryIt->first);
|
||||
}
|
@@ -1,81 +0,0 @@
|
||||
// Created on: 2017-06-16
|
||||
// Created by: Natalia ERMOLAEVA
|
||||
// Copyright (c) 2017 OPEN CASCADE SAS
|
||||
//
|
||||
// This file is part of Open CASCADE Technology software library.
|
||||
//
|
||||
// This library is free software; you can redistribute it and/or modify it under
|
||||
// the terms of the GNU Lesser General Public License version 2.1 as published
|
||||
// by the Free Software Foundation, with special exception defined in the file
|
||||
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
|
||||
// distribution for complete text of the license and disclaimer of any warranty.
|
||||
//
|
||||
// Alternatively, this file may be used under the terms of Open CASCADE
|
||||
// commercial license or contractual agreement.
|
||||
|
||||
#ifndef DFBROWSER_ThreadItemUsedShapesMap_H
|
||||
#define DFBROWSER_ThreadItemUsedShapesMap_H
|
||||
|
||||
#include <inspector/DFBrowser_ThreadItem.hxx>
|
||||
|
||||
#include <NCollection_DataMap.hxx>
|
||||
#include <Standard.hxx>
|
||||
#include <TCollection_AsciiString.hxx>
|
||||
#include <TDF_Attribute.hxx>
|
||||
|
||||
#include <Standard_WarningsDisable.hxx>
|
||||
#include <QStringList>
|
||||
#include <QPair>
|
||||
#include <Standard_WarningsRestore.hxx>
|
||||
|
||||
class DFBrowser_Module;
|
||||
|
||||
//! \class DFBrowser_ThreadItemUsedShapesMap
|
||||
//! Collects and sorts map values of TNaming_UsedShape attributes. Applies values to the OCAF tree view model
|
||||
class DFBrowser_ThreadItemUsedShapesMap : public DFBrowser_ThreadItem
|
||||
{
|
||||
public:
|
||||
|
||||
//! Constructor
|
||||
DFBrowser_ThreadItemUsedShapesMap() : myModule (0) {}
|
||||
|
||||
//! Destructor
|
||||
virtual ~DFBrowser_ThreadItemUsedShapesMap() {}
|
||||
|
||||
//! Sets the current module
|
||||
void SetModule (DFBrowser_Module* theModule) { myModule = theModule; }
|
||||
|
||||
//! Iterates by application documents and for TNaming_UsedShape attribute collects container of sorted values.
|
||||
Standard_EXPORT virtual void Run() Standard_OVERRIDE;
|
||||
|
||||
//! Initialize tree view model of OCAF by internal container of sorted values.
|
||||
Standard_EXPORT virtual void ApplyValues() Standard_OVERRIDE;
|
||||
|
||||
//! Set empty cache into tree view model of OCAF. Calls Init of these item by usual values (not sorted)
|
||||
Standard_EXPORT static void ClearSortedReferences (DFBrowser_Module* theModule);
|
||||
|
||||
private:
|
||||
|
||||
//! Collects sorted values of the attribute if the attribute has TNaming_UsedShape type
|
||||
//! \param theAttribute a processed attribute
|
||||
//! \param theReferences a output container of sorted references
|
||||
void findReferences (Handle(TDF_Attribute) theAttribute, std::list<TCollection_AsciiString>& theReferences);
|
||||
|
||||
//! Checks whether the left path is less than the right path
|
||||
//! \param theLeft path to label
|
||||
//! \param theRight path to label
|
||||
//! \returns true if the left path is less(not equal) than right path
|
||||
static bool isLessThan (const QStringList& theLeft, const QStringList& theRight);
|
||||
|
||||
//! Insert entry into container of entries using sorting. It is split by ":" separator to perform soring
|
||||
//! \param theEntry a label entry
|
||||
//! \param theEntries a result container
|
||||
void addValue (const TCollection_AsciiString& theEntry, QList<QPair<TCollection_AsciiString, QStringList > >& theEntries);
|
||||
|
||||
private:
|
||||
|
||||
DFBrowser_Module* myModule; //!< the current module
|
||||
NCollection_DataMap<Handle(TDF_Attribute), std::list<TCollection_AsciiString> > myAttributeRefs; //!< sorted references
|
||||
};
|
||||
|
||||
#endif
|
@@ -22,6 +22,9 @@
|
||||
|
||||
#include <inspector/DFBrowserPane_Tools.hxx>
|
||||
|
||||
#include <inspector/TreeModel_ModelBase.hxx>
|
||||
#include <inspector/TreeModel_Tools.hxx>
|
||||
|
||||
#include <Standard_WarningsDisable.hxx>
|
||||
#include <QAbstractItemModel>
|
||||
#include <QFrame>
|
||||
@@ -65,7 +68,7 @@ DFBrowser_TreeLevelLine::DFBrowser_TreeLevelLine (QWidget* theParent)
|
||||
myTableView->horizontalHeader()->setVisible (false);
|
||||
QHeaderView* aVHeader = myTableView->verticalHeader();
|
||||
aVHeader->setVisible (false);
|
||||
int aDefCellSize = aVHeader->minimumSectionSize() + DFBrowserPane_Tools::HeaderSectionMargin();
|
||||
int aDefCellSize = aVHeader->minimumSectionSize() + TreeModel_Tools::HeaderSectionMargin();
|
||||
aVHeader->setDefaultSectionSize (aDefCellSize);
|
||||
aLayout->addWidget (myTableView, 0, 2);
|
||||
|
||||
@@ -120,7 +123,7 @@ void DFBrowser_TreeLevelLine::OnTreeViewSelectionChanged (const QItemSelection&
|
||||
const QItemSelection&)
|
||||
{
|
||||
QModelIndexList aSelectedIndices = theSelected.indexes();
|
||||
QModelIndex aSelectedIndex = DFBrowser_Window::SingleSelected (aSelectedIndices, 0);
|
||||
QModelIndex aSelectedIndex = TreeModel_ModelBase::SingleSelected (aSelectedIndices, 0);
|
||||
|
||||
if (!mySelectionProcessingBlocked) // we're processing action click
|
||||
setForwardIndex (aSelectedIndex);
|
||||
@@ -152,7 +155,7 @@ void DFBrowser_TreeLevelLine::onTableSelectionChanged (const QItemSelection& the
|
||||
if (!aTableModel)
|
||||
return;
|
||||
|
||||
QModelIndex aSelectedIndex = DFBrowser_Window::SingleSelected (theSelected.indexes(), 0, Qt::Vertical);
|
||||
QModelIndex aSelectedIndex = TreeModel_ModelBase::SingleSelected (theSelected.indexes(), 0, Qt::Vertical);
|
||||
emit indexSelected (aTableModel->GetTreeViewIndex (aSelectedIndex));
|
||||
}
|
||||
|
||||
|
@@ -21,6 +21,7 @@
|
||||
#include <inspector/DFBrowserPane_Tools.hxx>
|
||||
#include <inspector/TreeModel_ModelBase.hxx>
|
||||
|
||||
#include <inspector/ViewControl_Tools.hxx>
|
||||
#include <Standard_WarningsDisable.hxx>
|
||||
#include <QItemSelectionModel>
|
||||
#include <QGridLayout>
|
||||
@@ -62,7 +63,7 @@ DFBrowser_TreeLevelView::DFBrowser_TreeLevelView (QWidget* theParent)
|
||||
connect (myTableView, SIGNAL (doubleClicked (const QModelIndex&)),
|
||||
this, SLOT (onTableDoubleClicked (const QModelIndex&)));
|
||||
|
||||
DFBrowser_Window::SetWhiteBackground (myTableView);
|
||||
ViewControl_Tools::SetWhiteBackground (myTableView);
|
||||
myTableView->setGridStyle (Qt::NoPen);
|
||||
}
|
||||
|
||||
@@ -129,7 +130,7 @@ void DFBrowser_TreeLevelView::onTableSelectionChanged (const QItemSelection& the
|
||||
const QItemSelection&)
|
||||
{
|
||||
QModelIndexList aSelectedIndices = theSelected.indexes();
|
||||
QModelIndex aSelectedIndex = DFBrowser_Window::SingleSelected (aSelectedIndices, 0);
|
||||
QModelIndex aSelectedIndex = TreeModel_ModelBase::SingleSelected (aSelectedIndices, 0);
|
||||
|
||||
DFBrowser_TreeLevelViewModel* aTableModel = dynamic_cast<DFBrowser_TreeLevelViewModel*> (myTableView->model());
|
||||
if (aTableModel && aTableModel->IsInitialized())
|
||||
|
@@ -32,6 +32,8 @@
|
||||
#include <QAbstractItemModel>
|
||||
#include <Standard_WarningsRestore.hxx>
|
||||
|
||||
const int COLUMN_NAME_WIDTH = 300;
|
||||
|
||||
// =======================================================================
|
||||
// function : Constructor
|
||||
// purpose :
|
||||
@@ -39,11 +41,21 @@
|
||||
DFBrowser_TreeModel::DFBrowser_TreeModel (QObject* theParent, DFBrowser_Module* theModule)
|
||||
: TreeModel_ModelBase (theParent)
|
||||
{
|
||||
m_pRootItem = DFBrowser_ItemApplication::CreateItem (TreeModel_ItemBasePtr());
|
||||
SetHeaderItem (0, TreeModel_HeaderSection ("Name", COLUMN_NAME_WIDTH));
|
||||
|
||||
DFBrowser_ItemApplicationPtr aRootItem = itemDynamicCast<DFBrowser_ItemApplication> (m_pRootItem);
|
||||
aRootItem->SetModule (theModule);
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : createRootItem
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
void DFBrowser_TreeModel::createRootItem (const int)
|
||||
{
|
||||
m_pRootItem = DFBrowser_ItemApplication::CreateItem (TreeModel_ItemBasePtr());
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : Init
|
||||
// purpose :
|
||||
|
@@ -95,11 +95,10 @@ public:
|
||||
Standard_EXPORT virtual QVariant data (const QModelIndex& theIndex,
|
||||
int theRole = Qt::DisplayRole) const Standard_OVERRIDE;
|
||||
|
||||
//! Returns count of columns in the model
|
||||
//! \param theParent an index of the parent item
|
||||
//! \return integer value
|
||||
virtual int columnCount (const QModelIndex& theParent = QModelIndex()) const Standard_OVERRIDE
|
||||
{ (void)theParent; return 1; }
|
||||
protected:
|
||||
//! Creates root item
|
||||
//! \param theColumnId index of a column
|
||||
virtual void createRootItem (const int theColumnId);
|
||||
|
||||
private:
|
||||
|
||||
|
@@ -1,37 +0,0 @@
|
||||
// Created on: 2017-06-16
|
||||
// Created by: Natalia ERMOLAEVA
|
||||
// Copyright (c) 2017 OPEN CASCADE SAS
|
||||
//
|
||||
// This file is part of Open CASCADE Technology software library.
|
||||
//
|
||||
// This library is free software; you can redistribute it and/or modify it under
|
||||
// the terms of the GNU Lesser General Public License version 2.1 as published
|
||||
// by the Free Software Foundation, with special exception defined in the file
|
||||
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
|
||||
// distribution for complete text of the license and disclaimer of any warranty.
|
||||
//
|
||||
// Alternatively, this file may be used under the terms of Open CASCADE
|
||||
// commercial license or contractual agreement.
|
||||
|
||||
#include <inspector/DFBrowser_TreeView.hxx>
|
||||
|
||||
// =======================================================================
|
||||
// function : SetPredefinedSize
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
void DFBrowser_TreeView::SetPredefinedSize (int theDefaultWidth, int theDefaultHeight)
|
||||
{
|
||||
myDefaultWidth = theDefaultWidth;
|
||||
myDefaultHeight = theDefaultHeight;
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : sizeHint
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
QSize DFBrowser_TreeView::sizeHint() const
|
||||
{
|
||||
if (myDefaultWidth > 0 && myDefaultHeight > 0)
|
||||
return QSize (myDefaultWidth, myDefaultHeight);
|
||||
return QTreeView::sizeHint();
|
||||
}
|
@@ -1,53 +0,0 @@
|
||||
// Created on: 2017-06-16
|
||||
// Created by: Natalia ERMOLAEVA
|
||||
// Copyright (c) 2017 OPEN CASCADE SAS
|
||||
//
|
||||
// This file is part of Open CASCADE Technology software library.
|
||||
//
|
||||
// This library is free software; you can redistribute it and/or modify it under
|
||||
// the terms of the GNU Lesser General Public License version 2.1 as published
|
||||
// by the Free Software Foundation, with special exception defined in the file
|
||||
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
|
||||
// distribution for complete text of the license and disclaimer of any warranty.
|
||||
//
|
||||
// Alternatively, this file may be used under the terms of Open CASCADE
|
||||
// commercial license or contractual agreement.
|
||||
|
||||
#ifndef DFBrowser_TreeView_H
|
||||
#define DFBrowser_TreeView_H
|
||||
|
||||
#include <Standard.hxx>
|
||||
#include <Standard_Macro.hxx>
|
||||
|
||||
#include <Standard_WarningsDisable.hxx>
|
||||
#include <QTreeView>
|
||||
#include <Standard_WarningsRestore.hxx>
|
||||
|
||||
//! \class DFBrowser_TreeView
|
||||
//! Extended tree view control with possibility to set predefined size.
|
||||
class DFBrowser_TreeView : public QTreeView
|
||||
{
|
||||
public:
|
||||
|
||||
//! Constructor
|
||||
Standard_EXPORT DFBrowser_TreeView (QWidget* theParent)
|
||||
: QTreeView (theParent), myDefaultWidth (-1), myDefaultHeight (-1) {}
|
||||
|
||||
//! Destructor
|
||||
virtual ~DFBrowser_TreeView() {}
|
||||
|
||||
//! Sets default size of control, that is used by the first control show
|
||||
//! \param theDefaultWidth the width value
|
||||
//! \param theDefaultHeight the height value
|
||||
Standard_EXPORT void SetPredefinedSize(int theDefaultWidth, int theDefaultHeight);
|
||||
|
||||
//! Returns predefined size if both values are positive, otherwise parent size hint
|
||||
Standard_EXPORT virtual QSize sizeHint() const Standard_OVERRIDE;
|
||||
|
||||
private:
|
||||
|
||||
int myDefaultWidth; //!< default width, -1 if it should not be used
|
||||
int myDefaultHeight; //!< default height, -1 if it should not be used
|
||||
};
|
||||
|
||||
#endif
|
@@ -33,20 +33,24 @@
|
||||
#include <inspector/DFBrowser_PropertyPanel.hxx>
|
||||
#include <inspector/DFBrowser_SearchLine.hxx>
|
||||
#include <inspector/DFBrowser_SearchView.hxx>
|
||||
#include <inspector/DFBrowser_Shortcut.hxx>
|
||||
#include <inspector/DFBrowser_Thread.hxx>
|
||||
#include <inspector/DFBrowser_ThreadItemSearch.hxx>
|
||||
#include <inspector/DFBrowser_ThreadItemUsedShapesMap.hxx>
|
||||
#include <inspector/DFBrowser_Tools.hxx>
|
||||
#include <inspector/DFBrowser_TreeLevelLine.hxx>
|
||||
#include <inspector/DFBrowser_TreeLevelView.hxx>
|
||||
#include <inspector/DFBrowser_TreeModel.hxx>
|
||||
#include <inspector/DFBrowser_TreeView.hxx>
|
||||
|
||||
#include <inspector/DFBrowserPane_AttributePaneSelector.hxx>
|
||||
#include <inspector/DFBrowserPane_SelectionKind.hxx>
|
||||
#include <inspector/DFBrowserPane_Tools.hxx>
|
||||
|
||||
#include <inspector/TreeModel_ContextMenu.hxx>
|
||||
#include <inspector/TreeModel_Tools.hxx>
|
||||
|
||||
#include <inspector/ViewControl_TreeView.hxx>
|
||||
|
||||
#include <inspector/View_Tools.hxx>
|
||||
|
||||
#include <OSD_Directory.hxx>
|
||||
#include <OSD_Environment.hxx>
|
||||
#include <OSD_Protection.hxx>
|
||||
@@ -58,7 +62,8 @@
|
||||
#include <inspector/View_Window.hxx>
|
||||
|
||||
#include <TDF_Tool.hxx>
|
||||
#include <inspector/TreeModel_MessageDialog.hxx>
|
||||
#include <inspector/ViewControl_MessageDialog.hxx>
|
||||
#include <inspector/ViewControl_Tools.hxx>
|
||||
|
||||
#include <Standard_WarningsDisable.hxx>
|
||||
#include <QAction>
|
||||
@@ -94,7 +99,6 @@ const int DFBROWSER_DEFAULT_VIEW_HEIGHT = 300;
|
||||
const int DFBROWSER_DEFAULT_POSITION_X = 200;
|
||||
const int DFBROWSER_DEFAULT_POSITION_Y = 60;
|
||||
|
||||
const int OCAF_BROWSER_COLUMN_WIDTH_0 = 300;
|
||||
const int DEFAULT_PROPERTY_PANEL_HEIGHT = 200;
|
||||
const int DEFAULT_BROWSER_HEIGHT = 800;
|
||||
|
||||
@@ -108,21 +112,16 @@ DFBrowser_Window::DFBrowser_Window()
|
||||
myMainWindow = new QMainWindow (0);
|
||||
|
||||
// tree view
|
||||
myTreeView = new DFBrowser_TreeView (myMainWindow);
|
||||
myTreeView = new ViewControl_TreeView (myMainWindow);
|
||||
myTreeView->setContextMenuPolicy (Qt::CustomContextMenu);
|
||||
connect (myTreeView, SIGNAL (customContextMenuRequested (const QPoint&)),
|
||||
this, SLOT (onTreeViewContextMenuRequested (const QPoint&)));
|
||||
((DFBrowser_TreeView*)myTreeView)->SetPredefinedSize (DFBROWSER_DEFAULT_TREE_VIEW_WIDTH,
|
||||
DFBROWSER_DEFAULT_TREE_VIEW_HEIGHT);
|
||||
new TreeModel_ContextMenu (myTreeView);
|
||||
((ViewControl_TreeView*)myTreeView)->SetPredefinedSize (QSize (DFBROWSER_DEFAULT_TREE_VIEW_WIDTH,
|
||||
DFBROWSER_DEFAULT_TREE_VIEW_HEIGHT));
|
||||
myTreeView->setHeaderHidden (true);
|
||||
myTreeView->setSortingEnabled (Standard_False);
|
||||
|
||||
QDockWidget* aTreeViewWidget = new QDockWidget (tr ("TreeView"), myMainWindow);
|
||||
aTreeViewWidget->setTitleBarWidget (new QWidget(myMainWindow));
|
||||
aTreeViewWidget->setFeatures (QDockWidget::NoDockWidgetFeatures);
|
||||
aTreeViewWidget->setWidget (myTreeView);
|
||||
myMainWindow->addDockWidget (Qt::LeftDockWidgetArea, aTreeViewWidget);
|
||||
myMainWindow->setCorner (Qt::BottomLeftCorner, Qt::LeftDockWidgetArea);
|
||||
myMainWindow->setCentralWidget (myTreeView);
|
||||
|
||||
#if QT_VERSION < 0x050000
|
||||
myTreeView->setStyle (new QWindowsStyle);
|
||||
@@ -137,22 +136,11 @@ DFBrowser_Window::DFBrowser_Window()
|
||||
connect (myTreeLevelLine, SIGNAL (updateClicked()), this, SLOT (onUpdateClicked()));
|
||||
|
||||
QDockWidget* aTreeLineDockWidget = new QDockWidget (tr ("Tree Level Line"), myMainWindow);
|
||||
aTreeLineDockWidget->setObjectName (aTreeLineDockWidget->windowTitle());
|
||||
aTreeLineDockWidget->setTitleBarWidget (new QWidget(myMainWindow));
|
||||
aTreeLineDockWidget->setFeatures (QDockWidget::NoDockWidgetFeatures);
|
||||
aTreeLineDockWidget->setWidget (myTreeLevelLine->GetControl());
|
||||
myMainWindow->addDockWidget (Qt::TopDockWidgetArea, aTreeLineDockWidget);
|
||||
|
||||
// dump view window
|
||||
QWidget* aDumpWidget = new QWidget (myMainWindow);
|
||||
QVBoxLayout* aDumpLay = new QVBoxLayout (aDumpWidget);
|
||||
aDumpLay->setMargin (0);
|
||||
myDumpView = new DFBrowser_DumpView (aDumpWidget);
|
||||
aDumpLay->addWidget (myDumpView->GetControl());
|
||||
QDockWidget* aDumpDockWidget = new QDockWidget (tr ("Dump"), myMainWindow);
|
||||
|
||||
aDumpDockWidget->setWidget (aDumpWidget);
|
||||
myMainWindow->addDockWidget (Qt::BottomDockWidgetArea, aDumpDockWidget);
|
||||
|
||||
// property panel
|
||||
myPropertyPanel = new DFBrowser_PropertyPanel (myMainWindow);
|
||||
DFBrowser_AttributePaneStack* anAttributePaneStack = myPropertyPanel->GetAttributesStack();
|
||||
@@ -173,27 +161,44 @@ DFBrowser_Window::DFBrowser_Window()
|
||||
connect (aLevelView, SIGNAL (indexDoubleClicked (const QModelIndex&)),
|
||||
this, SLOT (onLevelDoubleClicked (const QModelIndex&)));
|
||||
|
||||
myMainWindow->setCentralWidget (myPropertyPanel->GetControl());
|
||||
QDockWidget* aPropertyPanelWidget = new QDockWidget (tr ("PropertyPanel"), myMainWindow);
|
||||
aPropertyPanelWidget->setObjectName (aPropertyPanelWidget->windowTitle());
|
||||
aPropertyPanelWidget->setTitleBarWidget (new QWidget(myMainWindow));
|
||||
aPropertyPanelWidget->setWidget (myPropertyPanel->GetControl());
|
||||
myMainWindow->addDockWidget (Qt::RightDockWidgetArea, aPropertyPanelWidget);
|
||||
|
||||
// dump view window
|
||||
QWidget* aDumpWidget = new QWidget(myMainWindow);
|
||||
QVBoxLayout* aDumpLay = new QVBoxLayout(aDumpWidget);
|
||||
aDumpLay->setMargin(0);
|
||||
myDumpView = new DFBrowser_DumpView(aDumpWidget);
|
||||
aDumpLay->addWidget(myDumpView->GetControl());
|
||||
QDockWidget* aDumpDockWidget = new QDockWidget(tr("Dump"), myMainWindow);
|
||||
aDumpDockWidget->setObjectName(aDumpDockWidget->windowTitle());
|
||||
|
||||
aDumpDockWidget->setWidget(aDumpWidget);
|
||||
myMainWindow->addDockWidget(Qt::RightDockWidgetArea, aDumpDockWidget);
|
||||
|
||||
// view
|
||||
myViewWindow = new View_Window (myMainWindow);
|
||||
myViewWindow->GetView()->SetPredefinedSize (DFBROWSER_DEFAULT_VIEW_WIDTH, DFBROWSER_DEFAULT_VIEW_HEIGHT);
|
||||
|
||||
QDockWidget* aViewDockWidget = new QDockWidget (tr ("View"), myMainWindow);
|
||||
aViewDockWidget->setObjectName (aViewDockWidget->windowTitle());
|
||||
aViewDockWidget->setTitleBarWidget (myViewWindow->GetViewToolBar()->GetControl());
|
||||
aViewDockWidget->setWidget (myViewWindow);
|
||||
myMainWindow->addDockWidget (Qt::BottomDockWidgetArea, aViewDockWidget);
|
||||
myMainWindow->addDockWidget (Qt::RightDockWidgetArea, aViewDockWidget);
|
||||
|
||||
QColor aHColor (229, 243, 255);
|
||||
myViewWindow->GetDisplayer()->SetAttributeColor (Quantity_Color(aHColor.red() / 255., aHColor.green() / 255.,
|
||||
aHColor.blue() / 255., Quantity_TOC_RGB), View_PresentationType_Additional);
|
||||
|
||||
myMainWindow->splitDockWidget(aPropertyPanelWidget, aViewDockWidget, Qt::Vertical);
|
||||
myMainWindow->tabifyDockWidget (aDumpDockWidget, aViewDockWidget);
|
||||
|
||||
aTreeViewWidget->resize (DFBROWSER_DEFAULT_TREE_VIEW_WIDTH, DFBROWSER_DEFAULT_TREE_VIEW_HEIGHT);
|
||||
myTreeView->resize (DFBROWSER_DEFAULT_TREE_VIEW_WIDTH, DFBROWSER_DEFAULT_TREE_VIEW_HEIGHT);
|
||||
|
||||
myThread = new DFBrowser_Thread (this);
|
||||
|
||||
myShortcut = new DFBrowser_Shortcut (myMainWindow);
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
@@ -220,6 +225,62 @@ void DFBrowser_Window::SetParent (void* theParent)
|
||||
}
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : FillActionsMenu
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
void DFBrowser_Window::FillActionsMenu (void* theMenu)
|
||||
{
|
||||
QMenu* aMenu = (QMenu*)theMenu;
|
||||
QList<QDockWidget*> aDockwidgets = myMainWindow->findChildren<QDockWidget*>();
|
||||
for (QList<QDockWidget*>::iterator it = aDockwidgets.begin(); it != aDockwidgets.end(); ++it)
|
||||
{
|
||||
QDockWidget* aDockWidget = *it;
|
||||
if (aDockWidget->parentWidget() == myMainWindow)
|
||||
aMenu->addAction (aDockWidget->toggleViewAction());
|
||||
}
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : GetPreferences
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
void DFBrowser_Window::GetPreferences (TInspectorAPI_PreferencesDataMap& theItem)
|
||||
{
|
||||
theItem.Clear();
|
||||
theItem.Bind ("geometry", TreeModel_Tools::ToString (myMainWindow->saveState()).toStdString().c_str());
|
||||
|
||||
QMap<QString, QString> anItems;
|
||||
TreeModel_Tools::SaveState (myTreeView, anItems);
|
||||
View_Tools::SaveState(myViewWindow, anItems);
|
||||
|
||||
for (QMap<QString, QString>::const_iterator anItemsIt = anItems.begin(); anItemsIt != anItems.end(); anItemsIt++)
|
||||
theItem.Bind (anItemsIt.key().toStdString().c_str(), anItemsIt.value().toStdString().c_str());
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : SetPreferences
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
void DFBrowser_Window::SetPreferences (const TInspectorAPI_PreferencesDataMap& theItem)
|
||||
{
|
||||
if (theItem.IsEmpty())
|
||||
{
|
||||
TreeModel_Tools::SetDefaultHeaderSections (myTreeView);
|
||||
return;
|
||||
}
|
||||
|
||||
for (TInspectorAPI_IteratorOfPreferencesDataMap anItemIt (theItem); anItemIt.More(); anItemIt.Next())
|
||||
{
|
||||
if (anItemIt.Key().IsEqual ("geometry"))
|
||||
myMainWindow->restoreState (TreeModel_Tools::ToByteArray (anItemIt.Value().ToCString()));
|
||||
else if (TreeModel_Tools::RestoreState (myTreeView, anItemIt.Key().ToCString(), anItemIt.Value().ToCString()))
|
||||
continue;
|
||||
else if (View_Tools::RestoreState(myViewWindow, anItemIt.Key().ToCString(), anItemIt.Value().ToCString()))
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : UpdateContent
|
||||
// purpose :
|
||||
@@ -370,9 +431,6 @@ void DFBrowser_Window::Init (const NCollection_List<Handle(Standard_Transient)>&
|
||||
myTreeLevelLine->GetSearchLine()->SetModule (myModule);
|
||||
myPropertyPanel->GetAttributesStack()->GetSearchView()->InitModels();
|
||||
|
||||
myShortcut->SetModule (myModule);
|
||||
myThread->SetModule (myModule);
|
||||
|
||||
connect (myModule, SIGNAL (beforeUpdateTreeModel()), this, SLOT (onBeforeUpdateTreeModel()));
|
||||
|
||||
if (!aContext.IsNull())
|
||||
@@ -506,7 +564,6 @@ void DFBrowser_Window::setExpandedLevels (QTreeView* theTreeView, const QModelIn
|
||||
void DFBrowser_Window::setOCAFModel (QAbstractItemModel* theModel)
|
||||
{
|
||||
myTreeView->setModel (theModel);
|
||||
myTreeView->setColumnWidth (0, OCAF_BROWSER_COLUMN_WIDTH_0);
|
||||
|
||||
QItemSelectionModel* aSelectionModel = new QItemSelectionModel (theModel);
|
||||
myTreeView->setSelectionModel (aSelectionModel);
|
||||
@@ -536,21 +593,9 @@ void DFBrowser_Window::onBeforeUpdateTreeModel()
|
||||
// =======================================================================
|
||||
void DFBrowser_Window::ClearThreadCache()
|
||||
{
|
||||
DFBrowser_ThreadItemUsedShapesMap::ClearSortedReferences (myModule);
|
||||
DFBrowser_ThreadItemSearch::ClearValues (GetTreeLevelLine()->GetSearchLine());
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : SetWhiteBackground
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
void DFBrowser_Window::SetWhiteBackground (QWidget* theControl)
|
||||
{
|
||||
QPalette aPalette = theControl->palette();
|
||||
aPalette.setColor (QPalette::All, QPalette::Foreground, Qt::white);
|
||||
theControl->setPalette (aPalette);
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : TmpDirectory
|
||||
// purpose :
|
||||
@@ -582,25 +627,6 @@ TCollection_AsciiString DFBrowser_Window::TmpDirectory()
|
||||
return aTmpDir;
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : SingleSelected
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
QModelIndex DFBrowser_Window::SingleSelected (const QModelIndexList& theIndices, const int theCellId,
|
||||
const Qt::Orientation theOrientation)
|
||||
{
|
||||
QModelIndexList aFirstColumnSelectedIndices;
|
||||
for (QModelIndexList::const_iterator anIndicesIt = theIndices.begin(), aLast = theIndices.end();
|
||||
anIndicesIt != aLast; anIndicesIt++)
|
||||
{
|
||||
QModelIndex anIndex = *anIndicesIt;
|
||||
if ((theOrientation == Qt::Horizontal && anIndex.column() == theCellId) ||
|
||||
(theOrientation == Qt::Vertical && anIndex.row() == theCellId))
|
||||
aFirstColumnSelectedIndices.append (anIndex);
|
||||
}
|
||||
return aFirstColumnSelectedIndices.size() == 1 ? aFirstColumnSelectedIndices.first() : QModelIndex();
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : onTreeViewContextMenuRequested
|
||||
// purpose :
|
||||
@@ -608,25 +634,14 @@ QModelIndex DFBrowser_Window::SingleSelected (const QModelIndexList& theIndices,
|
||||
void DFBrowser_Window::onTreeViewContextMenuRequested (const QPoint& thePosition)
|
||||
{
|
||||
QMenu* aMenu = new QMenu(GetMainWindow());
|
||||
aMenu->addAction (createAction (tr ("Expand"), SLOT (onExpand())));
|
||||
aMenu->addAction (createAction (tr ("Expand All"), SLOT (onExpandAll())));
|
||||
aMenu->addAction (createAction (tr ("Collapse All"), SLOT (onCollapseAll())));
|
||||
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);
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : createAction
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
QAction* DFBrowser_Window::createAction (const QString& theText, const char* theSlot)
|
||||
{
|
||||
QAction* anAction = new QAction (theText, GetMainWindow());
|
||||
connect (anAction, SIGNAL (triggered(bool)), this, theSlot);
|
||||
return anAction;
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : onExpand
|
||||
// purpose :
|
||||
@@ -694,7 +709,7 @@ void DFBrowser_Window::onTreeViewSelectionChanged (const QItemSelection& theSele
|
||||
anAttributePaneStack->GetTreeLevelView()->UpdateByTreeSelectionChanged (theSelected, theDeselected);
|
||||
|
||||
QModelIndexList aSelectedIndices = theSelected.indexes();
|
||||
QModelIndex aSelectedIndex = DFBrowser_Window::SingleSelected (aSelectedIndices, 0);
|
||||
QModelIndex aSelectedIndex = TreeModel_ModelBase::SingleSelected (aSelectedIndices, 0);
|
||||
|
||||
myTreeView->scrollTo (aSelectedIndex);
|
||||
View_Displayer* aDisplayer = myViewWindow->GetDisplayer();
|
||||
@@ -736,8 +751,12 @@ void DFBrowser_Window::onPaneSelectionChanged (const QItemSelection&,
|
||||
if (myParameters->FindParameters (aPluginName))
|
||||
aParameters = myParameters->Parameters (aPluginName);
|
||||
|
||||
NCollection_List<TCollection_AsciiString> anItemNames;
|
||||
if (myParameters->FindSelectedNames (aPluginName))
|
||||
anItemNames = myParameters->GetSelectedNames (aPluginName);
|
||||
|
||||
int aParametersCount = aParameters.Extent();
|
||||
anAttributePane->GetSelectionParameters (aSelectionModel, aParameters);
|
||||
anAttributePane->GetSelectionParameters (aSelectionModel, aParameters, anItemNames);
|
||||
if (aParametersCount != aParameters.Extent()) // some TShapes are added
|
||||
{
|
||||
TCollection_AsciiString aPluginShortName = aPluginName.SubString (3, aPluginName.Length());
|
||||
@@ -747,11 +766,12 @@ void DFBrowser_Window::onPaneSelectionChanged (const QItemSelection&,
|
||||
QString aQuestion = QString ("Would you like to activate %1 immediately?\n")
|
||||
.arg (aPluginShortName.ToCString()).toStdString().c_str();
|
||||
if (!myExportToShapeViewDialog)
|
||||
myExportToShapeViewDialog = new TreeModel_MessageDialog (myParent, aMessage, aQuestion);
|
||||
myExportToShapeViewDialog = new ViewControl_MessageDialog (myParent, aMessage, aQuestion);
|
||||
else
|
||||
myExportToShapeViewDialog->SetInformation (aMessage);
|
||||
myExportToShapeViewDialog->Start();
|
||||
|
||||
myParameters->SetSelectedNames (aPluginName, anItemNames);
|
||||
myParameters->SetParameters (aPluginName, aParameters, myExportToShapeViewDialog->IsAccepted());
|
||||
}
|
||||
return;
|
||||
|
@@ -35,11 +35,10 @@
|
||||
class DFBrowser_DumpView;
|
||||
class DFBrowser_Module;
|
||||
class DFBrowser_PropertyPanel;
|
||||
class DFBrowser_Shortcut;
|
||||
class DFBrowser_Thread;
|
||||
class DFBrowser_TreeLevelLine;
|
||||
|
||||
class TreeModel_MessageDialog;
|
||||
class ViewControl_MessageDialog;
|
||||
|
||||
class View_ToolBar;
|
||||
class View_Window;
|
||||
@@ -73,6 +72,18 @@ public:
|
||||
//! \param theParameters a parameters container
|
||||
void SetParameters (const Handle(TInspectorAPI_PluginParameters)& theParameters) { myParameters = theParameters; }
|
||||
|
||||
//! Provide container for actions available in inspector on general level
|
||||
//! \param theMenu if Qt implementation, it is QMenu object
|
||||
Standard_EXPORT virtual void FillActionsMenu (void* theMenu);
|
||||
|
||||
//! Returns plugin preferences: dock widgets state, tree view columns.
|
||||
//! \param theItem container of preference elements
|
||||
Standard_EXPORT void GetPreferences (TInspectorAPI_PreferencesDataMap& theItem);
|
||||
|
||||
//! Applies plugin preferences
|
||||
//! \param theItem container of preference elements
|
||||
Standard_EXPORT void SetPreferences (const TInspectorAPI_PreferencesDataMap& theItem);
|
||||
|
||||
//! Applyes parameters to Init controls, opens files if there are in parameters, updates OCAF tree view model
|
||||
Standard_EXPORT void UpdateContent();
|
||||
|
||||
@@ -101,22 +112,10 @@ public:
|
||||
//! Returns tree level line control
|
||||
DFBrowser_TreeLevelLine* GetTreeLevelLine() const { return myTreeLevelLine; }
|
||||
|
||||
//! Change palette of the widget to have white foreground
|
||||
//! \param theControl a widget to be modified
|
||||
Standard_EXPORT static void SetWhiteBackground (QWidget* theControl);
|
||||
|
||||
//! Returns temporary directory defined by environment variables TEMP or TMP
|
||||
//! \return string value
|
||||
Standard_EXPORT static TCollection_AsciiString TmpDirectory();
|
||||
|
||||
//! Returns single selected item in the cell of given orientation. If the orientation is Horizontal,
|
||||
//! in the cell id colum, one row should be selected.
|
||||
//! \param theIndices a container of selected indices
|
||||
//! \param theCellId column index if orientation is horizontal, row index otherwise
|
||||
//! \param theOrientation an orientation to apply the cell index
|
||||
//! \return model index from the list
|
||||
Standard_EXPORT static QModelIndex SingleSelected (const QModelIndexList& theIndices, const int theCellId,
|
||||
const Qt::Orientation theOrientation = Qt::Horizontal);
|
||||
private slots:
|
||||
|
||||
//! Cleans history in tree level line, clears cache of thread processing, starts threads for application
|
||||
@@ -191,12 +190,6 @@ private:
|
||||
//! \param theIndices a container of OCAF tree view model indices
|
||||
void highlightIndices (const QModelIndexList& theIndices);
|
||||
|
||||
//! Creates an action with the given text connected to the slot
|
||||
//! \param theText an action text value
|
||||
//! \param theSlot a listener of triggered signal of the new action
|
||||
//! \return a new action
|
||||
QAction* createAction (const QString& theText, const char* theSlot);
|
||||
|
||||
//! Returns candidate to be the window title. It is either name of opened STEP file or the application path
|
||||
//! \return string value
|
||||
QString getWindowTitle() const;
|
||||
@@ -231,8 +224,7 @@ private:
|
||||
View_Window* myViewWindow; //!< V3d view to visualize presentations/references if it can be build for a selected item
|
||||
DFBrowser_DumpView* myDumpView; //!< Text editor where "Dump" method output is shown
|
||||
DFBrowser_Thread* myThread; //!< Threads manipulator, starting thread items, listens finalizing
|
||||
DFBrowser_Shortcut* myShortcut; //!< Short cut processor, F5 - updates OCAF view model content
|
||||
TreeModel_MessageDialog* myExportToShapeViewDialog; //!< dialog about exporting TopoDS_Shape to ShapeView plugin
|
||||
ViewControl_MessageDialog* myExportToShapeViewDialog; //!< dialog about exporting TopoDS_Shape to ShapeView plugin
|
||||
Handle(TInspectorAPI_PluginParameters) myParameters; //!< contains application, context, files that should be opened
|
||||
};
|
||||
|
||||
|
@@ -30,15 +30,11 @@ DFBrowser_SearchLineModel.cxx
|
||||
DFBrowser_SearchLineModel.hxx
|
||||
DFBrowser_SearchView.cxx
|
||||
DFBrowser_SearchView.hxx
|
||||
DFBrowser_Shortcut.cxx
|
||||
DFBrowser_Shortcut.hxx
|
||||
DFBrowser_Thread.cxx
|
||||
DFBrowser_Thread.hxx
|
||||
DFBrowser_ThreadItem.hxx
|
||||
DFBrowser_ThreadItemSearch.cxx
|
||||
DFBrowser_ThreadItemSearch.hxx
|
||||
DFBrowser_ThreadItemUsedShapesMap.cxx
|
||||
DFBrowser_ThreadItemUsedShapesMap.hxx
|
||||
DFBrowser_Tools.cxx
|
||||
DFBrowser_Tools.hxx
|
||||
DFBrowser_TreeLevelLine.cxx
|
||||
@@ -53,7 +49,5 @@ DFBrowser_TreeLevelViewModel.cxx
|
||||
DFBrowser_TreeLevelViewModel.hxx
|
||||
DFBrowser_TreeModel.cxx
|
||||
DFBrowser_TreeModel.hxx
|
||||
DFBrowser_TreeView.cxx
|
||||
DFBrowser_TreeView.hxx
|
||||
DFBrowser_Window.cxx
|
||||
DFBrowser_Window.hxx
|
||||
|
Reference in New Issue
Block a user