1
0
mirror of https://git.dev.opencascade.org/repos/occt.git synced 2025-08-19 13:40: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:
nds
2020-01-31 13:12:45 +03:00
committed by bugmaster
parent a2803f37e7
commit 7e1c1e4869
204 changed files with 4893 additions and 3415 deletions

View File

@@ -19,11 +19,10 @@
#include <inspector/View_Window.hxx>
#include <inspector/TInspectorAPI_Version.hxx>
#include <inspector/View_Displayer.hxx>
#include <inspector/View_DisplayPreview.hxx>
#include <inspector/View_PreviewParameters.hxx>
#include <inspector/View_ToolBar.hxx>
#include <inspector/View_Tools.hxx>
#include <inspector/View_Viewer.hxx>
#include <inspector/View_Widget.hxx>
@@ -43,14 +42,16 @@ const int DEFAULT_SPACING = 3;
// function : Constructor
// purpose :
// =======================================================================
View_Window::View_Window (QWidget* theParent, const bool isUseKeepView, const bool isFitAllActive)
View_Window::View_Window (QWidget* theParent,
const Handle(AIS_InteractiveContext)& theContext,
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, isFitAllActive);
myView = new View_Widget (this, theContext, isFitAllActive);
myViewToolBar = new View_ToolBar (this, isUseKeepView);
aViewLayout->addWidget (myViewToolBar->GetControl(), 0, 0, 1, 2);
connect (myViewToolBar, SIGNAL (contextChanged()), this, SLOT (onViewSelectorActivated()));
@@ -69,7 +70,7 @@ View_Window::View_Window (QWidget* theParent, const bool isUseKeepView, const bo
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));
myActionsToolBar->addAction (myView->ViewAction ((View_ViewActionType)anActionId));
aViewLayout->addWidget (myActionsToolBar, 1, 0);
aViewLayout->addWidget (myView, 1, 1);
@@ -92,7 +93,76 @@ View_Window::View_Window (QWidget* theParent, const bool isUseKeepView, const bo
// =======================================================================
void View_Window::SetContext (View_ContextType /*theType*/, const Handle(AIS_InteractiveContext)& theContext)
{
GetViewToolBar()->SetContext (View_ContextType_External, theContext);
ViewToolBar()->SetContext (View_ContextType_External, theContext);
}
// =======================================================================
// function : SaveState
// purpose :
// =======================================================================
void View_Window::SaveState (View_Window* theView, QMap<QString, QString>& theItems,
const QString& thePrefix)
{
QStringList aCameraDirection;
Standard_Real aVX, aVY, aVZ;
Handle(V3d_View) aView = theView->ViewWidget()->GetViewer()->GetView();
if (aView.IsNull())
return;
aView->Proj (aVX, aVY, aVZ);
aCameraDirection << QString::number (aVX) << QString::number (aVY) << QString::number (aVZ);
theItems[thePrefix + "view_camera_direction"] = aCameraDirection.join (",");
View_PreviewParameters::SaveState (theView->Displayer()->DisplayPreview()->GetPreviewParameters(), theItems, "preview_parameters_");
View_ToolBar::SaveState (theView->ViewToolBar(), theItems, "view_toolbar_");
View_Widget::SaveState (theView->ViewWidget(), theItems, "view_widget_");
}
// =======================================================================
// function : RestoreState
// purpose :
// =======================================================================
bool View_Window::RestoreState (View_Window* theView, const QString& theKey, const QString& theValue,
const QString& thePrefix)
{
if (theKey == thePrefix + "view_camera_direction")
{
QStringList aValues = theValue.split (",");
if (aValues.size() == 3)
{
Standard_Real aVX = aValues.at (0).toDouble();
Standard_Real aVY = aValues.at (1).toDouble();
Standard_Real aVZ = aValues.at (2).toDouble();
theView->ViewWidget()->SetInitProj (aVX, aVY, aVZ);
}
return true;
}
else if (View_PreviewParameters::RestoreState (theView->Displayer()->DisplayPreview()->GetPreviewParameters(),
theKey, theValue, "preview_parameters_"))
{
return true;
}
else if (View_ToolBar::RestoreState (theView->ViewToolBar(), theKey, theValue, "view_toolbar_"))
{
return true;
}
else if (View_Widget::RestoreState (theView->ViewWidget(), theKey, theValue, "view_widget_"))
{
// display mode is restored
View_Displayer* aDisplayer = theView->Displayer();
if (theView->ViewWidget()->DisplayMode() != aDisplayer->DisplayMode())
aDisplayer->SetDisplayMode (theView->ViewWidget()->DisplayMode());
bool toFitAll = theView->ViewWidget()->IsActionChecked (View_ViewActionType_FitAllId);
if (toFitAll != aDisplayer->IsFitAllActive())
aDisplayer->SetFitAllActive (toFitAll);
return true;
}
return false;
}
// =======================================================================
@@ -101,12 +171,12 @@ void View_Window::SetContext (View_ContextType /*theType*/, const Handle(AIS_Int
// =======================================================================
void View_Window::onViewSelectorActivated()
{
View_ContextType aType = myViewToolBar->GetCurrentContextType();
View_ContextType aType = myViewToolBar->CurrentContextType();
bool isViewEnabled = aType == View_ContextType_Own;
myView->SetEnabledView (isViewEnabled);
Handle(AIS_InteractiveContext) aContext = myViewToolBar->GetCurrentContext();
Handle(AIS_InteractiveContext) aContext = myViewToolBar->CurrentContext();
myDisplayer->EraseAllPresentations (true);
emit eraseAllPerformed();
@@ -121,6 +191,11 @@ void View_Window::onToolBarActionClicked (const int theActionId)
{
switch (theActionId)
{
case View_ToolActionType_Trihedron:
{
myDisplayer->DisplayDefaultTrihedron (myViewToolBar->IsActionChecked (theActionId), Standard_True);
break;
}
case View_ToolActionType_KeepViewId:
{
myDisplayer->KeepPresentations (myViewToolBar->IsActionChecked (theActionId));
@@ -158,23 +233,22 @@ void View_Window::onCheckedStateChanged (int theActionId, bool theState)
// =======================================================================
void View_Window::onViewContextMenuRequested (const QPoint& thePosition)
{
#if TINSPECTORAPI_VERSION_HEX > 0x070200
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));
QAction* anAction = new QAction (V3d::TypeOfOrientationToString (anOrientationType), this);
QObject::connect (anAction, SIGNAL (triggered (bool)), this, SLOT (onSetOrientation()));
anOrientationSubMenu->addAction (anAction);
}
aMenu->addMenu (anOrientationSubMenu);
QPoint aPoint = myView->mapToGlobal (thePosition);
aMenu->exec (aPoint);
#else
(void)thePosition;
#endif
}
// =======================================================================
@@ -183,7 +257,6 @@ void View_Window::onViewContextMenuRequested (const QPoint& thePosition)
// =======================================================================
void View_Window::onSetOrientation()
{
#if TINSPECTORAPI_VERSION_HEX > 0x070200
QAction* anAction = (QAction*)(sender());
TCollection_AsciiString anOrientationStr (anAction->text().toStdString().c_str());
@@ -199,7 +272,6 @@ void View_Window::onSetOrientation()
aView->SetProj (anOrientationType);
aView->FitAll();
aView->Redraw();
#endif
}
// =======================================================================
@@ -208,7 +280,7 @@ void View_Window::onSetOrientation()
// =======================================================================
void View_Window::onDisplayModeChanged()
{
int aDisplayMode = myView->GetDisplayMode();
int aDisplayMode = myView->DisplayMode();
for (NCollection_DataMap<View_PresentationType, NCollection_Shared<AIS_ListOfInteractive> >::Iterator
anIterator(myDisplayer->GetDisplayed()); anIterator.More(); anIterator.Next())
myDisplayer->SetDisplayMode (aDisplayMode, anIterator.Key(), false);