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

@@ -19,8 +19,12 @@
#include <inspector/View_Widget.hxx>
#include <AIS_Trihedron.hxx>
#include <Geom_Axis2Placement.hxx>
#include <Graphic3d_GraphicDriver.hxx>
#include <Standard_Version.hxx>
#include <inspector/View_ToolButton.hxx>
#include <inspector/View_ViewActionType.hxx>
#include <inspector/View_Viewer.hxx>
@@ -59,14 +63,17 @@
// function : Constructor
// purpose :
// =======================================================================
View_Widget::View_Widget (QWidget* theParent)
View_Widget::View_Widget (QWidget* theParent, const bool isFitAllActive)
: QWidget (theParent), myCurrentMode (View_CurrentAction3d_Nothing), myFirst (true), myDefaultWidth (-1),
myDefaultHeight (-1), myViewIsEnabled (true), myXmin (0), myYmin (0), myXmax (0), myYmax (0), myDragButtonDownX (0),
myDragButtonDownY (0), myDragMultiButtonDownX (0), myDragMultiButtonDownY (0), myIsRectVisible (false), myRectBand (0)
myDragButtonDownY (0), myDragMultiButtonDownX (0), myDragMultiButtonDownY (0), myIsRectVisible (false), myRectBand (0),
myHasInitProj (Standard_False), myInitVx (0), myInitVy (0), myInitVz (0)
{
myViewer = new View_Viewer (View_Viewer::DefaultColor());
myViewer->InitStandardViewer();
myViewer->GetContext()->Display(new AIS_Trihedron (new Geom_Axis2Placement (gp::XOY())), Standard_True);
setAttribute (Qt::WA_PaintOnScreen);
setAttribute (Qt::WA_NoSystemBackground);
@@ -76,6 +83,7 @@ View_Widget::View_Widget (QWidget* theParent)
setFocusPolicy (Qt::StrongFocus);
initViewActions();
((View_ToolButton*)myFitAllAction)->SetButtonChecked (isFitAllActive);
initCursors();
}
@@ -116,6 +124,9 @@ void View_Widget::Init()
myViewer->GetView()->SetBackgroundColor (View_Viewer::DefaultColor());
myViewer->GetView()->MustBeResized();
if (myHasInitProj)
myViewer->GetView()->SetProj (myInitVx, myInitVy, myInitVz);
}
// =======================================================================
@@ -133,13 +144,14 @@ int View_Widget::GetDisplayMode() const
// =======================================================================
void View_Widget::paintEvent (QPaintEvent* /*theEvent*/)
{
#if QT_VERSION < 0x050000
#if (QT_VERSION < 0x050000 || QT_VERSION >= 0x050700)
if (myFirst)
{
Init();
myFirst = false;
}
#endif
if (myViewer->GetView())
myViewer->GetView()->Redraw();
}
@@ -150,7 +162,7 @@ void View_Widget::paintEvent (QPaintEvent* /*theEvent*/)
// =======================================================================
void View_Widget::resizeEvent (QResizeEvent* /*theEvent*/)
{
#if QT_VERSION > 0x050000
#if (QT_VERSION > 0x050000 && QT_VERSION < 0x050700)
if (myFirst)
{
Init();
@@ -184,21 +196,33 @@ void View_Widget::SetEnabledView (const bool theIsEnabled)
if (myViewer->GetView())
myViewer->GetView()->SetBackgroundColor (theIsEnabled ? View_Viewer::DefaultColor()
: View_Viewer::DisabledColor());
for (int anActionId = View_ViewActionType_FitAllId; anActionId <= View_ViewActionType_DisplayModeId; anActionId++)
for (int anActionId = View_ViewActionType_FitAreaId; anActionId <= View_ViewActionType_DisplayModeId; anActionId++)
GetViewAction ((View_ViewActionType)anActionId)->setEnabled (theIsEnabled);
}
// =======================================================================
// function : onCheckedStateChanged
// purpose :
// =======================================================================
void View_Widget::onCheckedStateChanged (bool isOn)
{
QWidget* aSentByAction = (QWidget*)sender();
if (aSentByAction == myFitAllAction)
emit checkedStateChanged(View_ViewActionType_FitAllId, isOn);
}
// =======================================================================
// function : OnUpdateToggled
// purpose :
// =======================================================================
void View_Widget::OnUpdateToggled (bool isOn)
{
QAction* sentBy = (QAction*)sender();
QAction* aSentByAction = (QAction*)sender();
if (sentBy == myViewActions[View_ViewActionType_DisplayModeId])
if (aSentByAction == myViewActions[View_ViewActionType_DisplayModeId])
{
sentBy->setIcon (isOn ? QIcon (":/icons/view_dm_wireframe.png")
aSentByAction->setIcon (isOn ? QIcon (":/icons/view_dm_wireframe.png")
: QIcon (":/icons/view_dm_shading.png"));
return;
}
@@ -206,7 +230,7 @@ void View_Widget::OnUpdateToggled (bool isOn)
if (!isOn)
return;
for (int anActionId = View_ViewActionType_FitAllId; anActionId <= View_ViewActionType_RotationId; anActionId++)
for (int anActionId = View_ViewActionType_FitAreaId; anActionId <= View_ViewActionType_RotationId; anActionId++)
{
QAction* anAction = myViewActions[(View_ViewActionType)anActionId];
if ((anAction == myViewActions[View_ViewActionType_FitAreaId]) ||
@@ -214,19 +238,19 @@ void View_Widget::OnUpdateToggled (bool isOn)
(anAction == myViewActions[View_ViewActionType_PanId]) ||
(anAction == myViewActions[View_ViewActionType_RotationId]))
{
if (anAction && (anAction != sentBy))
if (anAction && (anAction != aSentByAction))
{
anAction->setChecked (false);
}
else
{
if (sentBy == myViewActions[View_ViewActionType_FitAreaId])
if (aSentByAction == myViewActions[View_ViewActionType_FitAreaId])
setActiveCursor (View_CursorMode_HandCursor);
else if (sentBy == myViewActions[View_ViewActionType_ZoomId])
else if (aSentByAction == myViewActions[View_ViewActionType_ZoomId])
setActiveCursor (View_CursorMode_ZoomCursor);
else if (sentBy == myViewActions[View_ViewActionType_PanId])
else if (aSentByAction == myViewActions[View_ViewActionType_PanId])
setActiveCursor (View_CursorMode_PanCursor);
else if (sentBy == myViewActions[View_ViewActionType_RotationId])
else if (aSentByAction == myViewActions[View_ViewActionType_RotationId])
setActiveCursor (View_CursorMode_RotationCursor);
else
setActiveCursor (View_CursorMode_DefaultCursor);
@@ -244,7 +268,11 @@ void View_Widget::initViewActions()
if (!myViewActions.empty())
return;
myFitAllAction = new View_ToolButton (this); //!< action for automatic fit all
connect (myFitAllAction, SIGNAL (checkedStateChanged(bool)), this, SLOT (onCheckedStateChanged(bool)));
createAction (View_ViewActionType_FitAllId, ":/icons/view_fitall.png", tr ("Fit All"), SLOT (OnFitAll()));
myFitAllAction->setDefaultAction (GetViewAction (View_ViewActionType_FitAllId));
createAction (View_ViewActionType_FitAreaId, ":/icons/view_fitarea.png", tr ("Fit Area"), SLOT (OnFitArea()), true);
createAction (View_ViewActionType_ZoomId, ":/icons/view_zoom.png", tr ("Zoom"), SLOT (OnZoom()), true);
createAction (View_ViewActionType_PanId, ":/icons/view_pan.png", tr ("Pan"), SLOT (OnPan()), true);
@@ -628,7 +656,8 @@ void View_Widget::processInputEvent (const Standard_Integer/* theX*/, const Stan
// =======================================================================
void View_Widget::processMoveEvent (const Standard_Integer theX, const Standard_Integer theY)
{
myViewer->GetContext()->MoveTo (theX, theY, myViewer->GetView(), Standard_True);
if (myViewer->GetView())
myViewer->GetContext()->MoveTo (theX, theY, myViewer->GetView(), Standard_True);
}
// =======================================================================