mirror of
https://git.dev.opencascade.org/repos/occt.git
synced 2025-08-29 14:00:49 +03:00
0030268: Inspectors - improvements in VInspector plugin
- Convert package creation. It is used to prepare some auxiliary presentations/methods to prepare variables for inspector based on occt classes. - ViewControl package improvement: Classes for property view, table, table model are implemented to visualize view of properties. This view is filled by selection in tree if the selected object has implemented DumpJson functionality. - TreeModel package improvements: Method InitColumn is implemented in TreeModel_TreeModel to fill default columns in base model. The default columns are: Name, Visibility, Rows. Additional columns should be added in successors. Container of root items is moved into the base class - View package imrovements: Store preferences: display mode, fit all checked state and type of external context View_DisplayPreview is added to process preview for selected in tree view objects hide actions Clear, Multi, Single by default (as selection in tree view or Visibility state of item define which presentations should be displayed or erased) - ShapeView plugin improvements: Property View content based on DumpJson (columns in tree view for properties are removed), Properties for TopoDS_Shape are displayed Explode shape action in tree view to see content of shape by selected shape type. Type of displayed shapes is only preview, it is not used in export action. Export shape into BREP. The previous implementation about BREP files in some directory and default view is removed. - VInspector plugin imrovements: Property View content based on DumpJson (columns in tree view for properties are removed), Properties for AIS_InteractiveContext and AIS_InteractiveObject are displayed obsolete classes to provide properties are removed. - DFBrowser plugin improvements: Property View content based on DumpJson is not used yet. But there is the USE_DUMPJSON macro. It's switch off by default. If switch ON, it creates a Property View filled with DumpJson. It's a way of DFBrowser moving on this property view. Init uses static variable CDF_Session::CurrentSession()->CurrentApplication to fill plugin if application in plugin is not set but OCAF application exists - OCC_VERSION_HEX variable used for previous OCCT versions support (before 6.9.0 or 7.2.0) is removed
This commit is contained in:
@@ -47,10 +47,9 @@
|
||||
#include <inspector/TreeModel_ContextMenu.hxx>
|
||||
#include <inspector/TreeModel_Tools.hxx>
|
||||
|
||||
#include <inspector/ViewControl_PropertyView.hxx>
|
||||
#include <inspector/ViewControl_TreeView.hxx>
|
||||
|
||||
#include <inspector/View_Tools.hxx>
|
||||
|
||||
#include <OSD_Directory.hxx>
|
||||
#include <OSD_Environment.hxx>
|
||||
#include <OSD_Protection.hxx>
|
||||
@@ -102,6 +101,8 @@ const int DFBROWSER_DEFAULT_POSITION_Y = 60;
|
||||
const int DEFAULT_PROPERTY_PANEL_HEIGHT = 200;
|
||||
const int DEFAULT_BROWSER_HEIGHT = 800;
|
||||
|
||||
//#define USE_DUMPJSON
|
||||
|
||||
// =======================================================================
|
||||
// function : Constructor
|
||||
// purpose :
|
||||
@@ -161,12 +162,24 @@ DFBrowser_Window::DFBrowser_Window()
|
||||
connect (aLevelView, SIGNAL (indexDoubleClicked (const QModelIndex&)),
|
||||
this, SLOT (onLevelDoubleClicked (const QModelIndex&)));
|
||||
|
||||
// property widget
|
||||
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);
|
||||
|
||||
// property view
|
||||
#ifdef USE_DUMPJSON
|
||||
myPropertyPanelWidget = new QDockWidget (tr ("PropertyPanel (DumpJson)"), myMainWindow);
|
||||
myPropertyView = new ViewControl_PropertyView (myMainWindow,
|
||||
QSize(DFBROWSER_DEFAULT_VIEW_WIDTH, DFBROWSER_DEFAULT_VIEW_HEIGHT));
|
||||
myPropertyPanelWidget->setObjectName (myPropertyPanelWidget->windowTitle());
|
||||
myPropertyPanelWidget->setTitleBarWidget (new QWidget(myMainWindow));
|
||||
myPropertyPanelWidget->setWidget (myPropertyView->GetControl());
|
||||
myMainWindow->addDockWidget (Qt::RightDockWidgetArea, myPropertyPanelWidget);
|
||||
#endif
|
||||
|
||||
// dump view window
|
||||
QWidget* aDumpWidget = new QWidget(myMainWindow);
|
||||
QVBoxLayout* aDumpLay = new QVBoxLayout(aDumpWidget);
|
||||
@@ -181,20 +194,26 @@ DFBrowser_Window::DFBrowser_Window()
|
||||
|
||||
// view
|
||||
myViewWindow = new View_Window (myMainWindow);
|
||||
myViewWindow->GetView()->SetPredefinedSize (DFBROWSER_DEFAULT_VIEW_WIDTH, DFBROWSER_DEFAULT_VIEW_HEIGHT);
|
||||
myViewWindow->ViewWidget()->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->setTitleBarWidget (myViewWindow->ViewToolBar()->GetControl());
|
||||
aViewDockWidget->setWidget (myViewWindow);
|
||||
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);
|
||||
myViewWindow->Displayer()->SetAttributeColor (Quantity_Color(aHColor.red() / 255., aHColor.green() / 255.,
|
||||
aHColor.blue() / 255., Quantity_TOC_sRGB), View_PresentationType_Additional);
|
||||
|
||||
myMainWindow->splitDockWidget(aPropertyPanelWidget, aViewDockWidget, Qt::Vertical);
|
||||
myMainWindow->splitDockWidget (aPropertyPanelWidget, aViewDockWidget, Qt::Vertical);
|
||||
|
||||
#ifdef USE_DUMPJSON
|
||||
myMainWindow->tabifyDockWidget (aDumpDockWidget, myPropertyPanelWidget);
|
||||
myMainWindow->tabifyDockWidget (myPropertyPanelWidget, aViewDockWidget);
|
||||
#else
|
||||
myMainWindow->tabifyDockWidget (aDumpDockWidget, aViewDockWidget);
|
||||
#endif
|
||||
|
||||
myTreeView->resize (DFBROWSER_DEFAULT_TREE_VIEW_WIDTH, DFBROWSER_DEFAULT_TREE_VIEW_HEIGHT);
|
||||
|
||||
@@ -254,7 +273,7 @@ void DFBrowser_Window::GetPreferences (TInspectorAPI_PreferencesDataMap& theItem
|
||||
|
||||
QMap<QString, QString> anItems;
|
||||
TreeModel_Tools::SaveState (myTreeView, anItems);
|
||||
View_Tools::SaveState(myViewWindow, anItems);
|
||||
View_Window::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());
|
||||
@@ -278,7 +297,7 @@ void DFBrowser_Window::SetPreferences (const TInspectorAPI_PreferencesDataMap& t
|
||||
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()))
|
||||
else if (View_Window::RestoreState(myViewWindow, anItemIt.Key().ToCString(), anItemIt.Value().ToCString()))
|
||||
continue;
|
||||
}
|
||||
}
|
||||
@@ -420,6 +439,11 @@ void DFBrowser_Window::Init (const NCollection_List<Handle(Standard_Transient)>&
|
||||
}
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (anApplication.IsNull() && CDF_Session::Exists())
|
||||
anApplication = Handle(TDocStd_Application)::DownCast (CDF_Session::CurrentSession()->CurrentApplication());
|
||||
}
|
||||
|
||||
myModule = new DFBrowser_Module();
|
||||
myModule->CreateViewModel (myMainWindow);
|
||||
@@ -659,7 +683,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 +701,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 +716,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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -705,6 +729,12 @@ void DFBrowser_Window::onTreeViewSelectionChanged (const QItemSelection& theSele
|
||||
{
|
||||
if (!myModule)
|
||||
return;
|
||||
|
||||
#ifdef USE_DUMPJSON
|
||||
if (myPropertyPanelWidget->toggleViewAction()->isChecked())
|
||||
myPropertyView->Init (ViewControl_Tools::CreateTableModelValues (myTreeView->selectionModel()));
|
||||
#endif
|
||||
|
||||
// previuos selection should be cleared in the panel selectors
|
||||
DFBrowser_AttributePaneStack* anAttributePaneStack = myPropertyPanel->GetAttributesStack();
|
||||
anAttributePaneStack->GetPaneSelector()->ClearSelected();
|
||||
@@ -716,7 +746,7 @@ void DFBrowser_Window::onTreeViewSelectionChanged (const QItemSelection& theSele
|
||||
QModelIndex aSelectedIndex = TreeModel_ModelBase::SingleSelected (aSelectedIndices, 0);
|
||||
|
||||
myTreeView->scrollTo (aSelectedIndex);
|
||||
View_Displayer* aDisplayer = myViewWindow->GetDisplayer();
|
||||
View_Displayer* aDisplayer = myViewWindow->Displayer();
|
||||
|
||||
aDisplayer->ErasePresentations (View_PresentationType_Additional, false);
|
||||
aDisplayer->DisplayPresentation (findPresentation (aSelectedIndex), View_PresentationType_Main);
|
||||
@@ -765,7 +795,7 @@ void DFBrowser_Window::onPaneSelectionChanged (const QItemSelection&,
|
||||
{
|
||||
TCollection_AsciiString aPluginShortName = aPluginName.SubString (3, aPluginName.Length());
|
||||
QString aMessage = QString ("TShape %1 is sent to %2.")
|
||||
.arg (DFBrowserPane_Tools::GetPointerInfo (aParameters.Last()).ToCString())
|
||||
.arg (Standard_Dump::GetPointerInfo (aParameters.Last()).ToCString())
|
||||
.arg (aPluginShortName.ToCString());
|
||||
QString aQuestion = QString ("Would you like to activate %1 immediately?\n")
|
||||
.arg (aPluginShortName.ToCString()).toStdString().c_str();
|
||||
@@ -793,7 +823,7 @@ void DFBrowser_Window::onPaneSelectionChanged (const QItemSelection&,
|
||||
|
||||
// make the shape visualized
|
||||
QModelIndex aSelectedIndex = aSelectedIndices.first();
|
||||
View_Displayer* aDisplayer = myViewWindow->GetDisplayer();
|
||||
View_Displayer* aDisplayer = myViewWindow->Displayer();
|
||||
aDisplayer->DisplayPresentation (findPresentation (aSelectedIndex), View_PresentationType_Main);
|
||||
|
||||
// highlight and scroll to the referenced item if it exists
|
||||
@@ -894,7 +924,7 @@ void DFBrowser_Window::onLevelSelected (const QModelIndex& theIndex)
|
||||
QModelIndexList anIndices;
|
||||
anIndices.append (theIndex);
|
||||
highlightIndices (anIndices);
|
||||
View_Displayer* aDisplayer = myViewWindow->GetDisplayer();
|
||||
View_Displayer* aDisplayer = myViewWindow->Displayer();
|
||||
aDisplayer->ErasePresentations (View_PresentationType_Additional, false);
|
||||
aDisplayer->DisplayPresentation (findPresentation (theIndex), View_PresentationType_Main);
|
||||
}
|
||||
@@ -988,26 +1018,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);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user