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

0029674: Improvements in Inspector tool

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

View File

@@ -21,13 +21,17 @@
#include <inspector/View_Displayer.hxx>
#include <inspector/View_ToolBar.hxx>
#include <inspector/View_Tools.hxx>
#include <inspector/View_Viewer.hxx>
#include <inspector/View_Widget.hxx>
#include <V3d.hxx>
#include <Standard_WarningsDisable.hxx>
#include <QComboBox>
#include <QDockWidget>
#include <QGridLayout>
#include <QMenu>
#include <QToolBar>
#include <Standard_WarningsRestore.hxx>
@@ -37,26 +41,34 @@ const int DEFAULT_SPACING = 3;
// function : Constructor
// purpose :
// =======================================================================
View_Window::View_Window (QWidget* theParent)
View_Window::View_Window (QWidget* theParent, const bool isUseKeepView, const bool isFitAllActive)
: QWidget (theParent)
{
QGridLayout* aViewLayout = new QGridLayout (this);
aViewLayout->setContentsMargins (0, 0, 0, 0);
aViewLayout->setSpacing (DEFAULT_SPACING);
myView = new View_Widget (this);
myViewToolBar = new View_ToolBar (this);
myView = new View_Widget (this, isFitAllActive);
myViewToolBar = new View_ToolBar (this, isUseKeepView);
aViewLayout->addWidget (myViewToolBar->GetControl(), 0, 0, 1, 2);
connect (myViewToolBar, SIGNAL (contextChanged()), this, SLOT (onViewSelectorActivated()));
connect (myViewToolBar, SIGNAL (actionClicked (int)),
this, SLOT (onToolBarActionClicked (int)));
connect (myView, SIGNAL (checkedStateChanged(int, bool)), this, SLOT (onCheckedStateChanged (int, bool)));
myView->setContextMenuPolicy (Qt::CustomContextMenu);
connect (myView, SIGNAL (customContextMenuRequested (const QPoint&)),
this, SLOT (onViewContextMenuRequested (const QPoint&)));
myActionsToolBar = new QToolBar (this);
myActionsToolBar->layout()->setContentsMargins (0, 0, 0, 0);
myActionsToolBar->setOrientation (Qt::Vertical);
for (int anActionId = View_ViewActionType_FitAllId; anActionId <= View_ViewActionType_DisplayModeId; anActionId++)
myActionsToolBar->addWidget (myView-> GetWidget (View_ViewActionType_FitAllId));
for (int anActionId = View_ViewActionType_FitAreaId; anActionId <= View_ViewActionType_DisplayModeId; anActionId++)
myActionsToolBar->addAction (myView->GetViewAction ((View_ViewActionType)anActionId));
aViewLayout->addWidget (myActionsToolBar, 1, 0);
aViewLayout->addWidget (myView, 1, 1);
aViewLayout->setRowStretch (1, 1);
@@ -65,6 +77,9 @@ View_Window::View_Window (QWidget* theParent)
myViewToolBar->SetContext (View_ContextType_Own, aContext);
myDisplayer = new View_Displayer();
if (!isUseKeepView)
myDisplayer->KeepPresentations (true);
myDisplayer->SetFitAllActive (isFitAllActive);
connect (myView, SIGNAL (displayModeClicked()), this, SLOT (onDisplayModeChanged()));
onViewSelectorActivated();
}
@@ -91,6 +106,8 @@ void View_Window::onViewSelectorActivated()
Handle(AIS_InteractiveContext) aContext = myViewToolBar->GetCurrentContext();
myDisplayer->EraseAllPresentations (true);
emit eraseAllPerformed();
myDisplayer->SetContext (aContext);
}
@@ -115,6 +132,7 @@ void View_Window::onToolBarActionClicked (const int theActionId)
case View_ToolActionType_ClearViewId:
{
myDisplayer->EraseAllPresentations (true);
emit eraseAllPerformed();
break;
}
default:
@@ -122,6 +140,60 @@ void View_Window::onToolBarActionClicked (const int theActionId)
}
}
// =======================================================================
// function : onCheckedStateChanged
// purpose :
// =======================================================================
void View_Window::onCheckedStateChanged (int theActionId, bool theState)
{
if (theActionId == View_ViewActionType_FitAllId)
myDisplayer->SetFitAllActive (theState);
}
// =======================================================================
// function : onViewContextMenuRequested
// purpose :
// =======================================================================
void View_Window::onViewContextMenuRequested (const QPoint& thePosition)
{
QMenu* aMenu = new QMenu (this);
QMenu* anOrientationSubMenu = aMenu->addMenu ("Set View Orientation");
for (int i = 0; i < (int)V3d_XnegYnegZneg; i++)
{
V3d_TypeOfOrientation anOrientationType = (V3d_TypeOfOrientation)i;
anOrientationSubMenu->addAction (View_Tools::CreateAction (V3d::TypeOfOrientationToString (anOrientationType),
SLOT (onSetOrientation()), this, this));
}
aMenu->addMenu (anOrientationSubMenu);
QPoint aPoint = myView->mapToGlobal (thePosition);
aMenu->exec (aPoint);
}
// =======================================================================
// function : onSetOrientation
// purpose :
// =======================================================================
void View_Window::onSetOrientation()
{
QAction* anAction = (QAction*)(sender());
TCollection_AsciiString anOrientationStr (anAction->text().toStdString().c_str());
V3d_TypeOfOrientation anOrientationType;
if (!V3d::TypeOfOrientationFromString (anOrientationStr.ToCString(), anOrientationType))
return;
Handle(V3d_View) aView = myView->GetViewer()->GetView();
if (aView.IsNull())
return;
aView->SetProj (anOrientationType);
aView->FitAll();
aView->Redraw();
}
// =======================================================================
// function : onDisplayModeChanged
// purpose :