mirror of
https://git.dev.opencascade.org/repos/occt.git
synced 2025-08-04 13:13:25 +03:00
0031658: Inspector - using AIS_ViewController in View package
- View: using AIS_ViewController, AIS_ViewCube.
This commit is contained in:
@@ -19,6 +19,7 @@
|
||||
|
||||
#include <inspector/View_Widget.hxx>
|
||||
|
||||
#include <AIS_ViewController.hxx>
|
||||
#include <Geom_Axis2Placement.hxx>
|
||||
#include <Graphic3d_GraphicDriver.hxx>
|
||||
|
||||
@@ -50,13 +51,6 @@
|
||||
#include <Xw_Window.hxx>
|
||||
#endif
|
||||
|
||||
// the key for multi selection :
|
||||
#define MULTISELECTIONKEY Qt::ShiftModifier
|
||||
// the key for shortcut (use to activate dynamic onRotate, panning)
|
||||
#define CASCADESHORTCUTKEY Qt::ControlModifier
|
||||
// for elastic bean selection
|
||||
#define ValZWMin 1
|
||||
|
||||
// =======================================================================
|
||||
// function : Constructor
|
||||
// purpose :
|
||||
@@ -64,18 +58,20 @@
|
||||
View_Widget::View_Widget (QWidget* theParent,
|
||||
const Handle(AIS_InteractiveContext)& theContext,
|
||||
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),
|
||||
: QWidget (theParent), myFirst (true), myDefaultWidth (-1),
|
||||
myDefaultHeight (-1), myViewIsEnabled (true),
|
||||
myHasInitProj (Standard_False), myInitVx (0), myInitVy (0), myInitVz (0)
|
||||
{
|
||||
myViewer = new View_Viewer (View_Viewer::DefaultColor());
|
||||
if (!theContext.IsNull())
|
||||
{
|
||||
myViewer->InitViewer (theContext);
|
||||
}
|
||||
else
|
||||
{
|
||||
myViewer->InitViewer (myViewer->CreateStandardViewer());
|
||||
}
|
||||
myController = new AIS_ViewController();
|
||||
|
||||
setAttribute (Qt::WA_PaintOnScreen);
|
||||
setAttribute (Qt::WA_NoSystemBackground);
|
||||
@@ -87,7 +83,6 @@ View_Widget::View_Widget (QWidget* theParent,
|
||||
|
||||
initViewActions();
|
||||
((View_ToolButton*)myFitAllAction)->SetButtonChecked (isFitAllActive);
|
||||
initCursors();
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
@@ -204,8 +199,7 @@ 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_FitAreaId; anActionId <= View_ViewActionType_DisplayModeId; anActionId++)
|
||||
ViewAction ((View_ViewActionType)anActionId)->setEnabled (theIsEnabled);
|
||||
ViewAction (View_ViewActionType_DisplayModeId)->setEnabled (theIsEnabled);
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
@@ -254,53 +248,6 @@ void View_Widget::onCheckedStateChanged (bool isOn)
|
||||
emit checkedStateChanged(View_ViewActionType_FitAllId, isOn);
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : OnUpdateToggled
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
void View_Widget::OnUpdateToggled (bool isOn)
|
||||
{
|
||||
QAction* aSentByAction = (QAction*)sender();
|
||||
|
||||
if (aSentByAction == myViewActions[View_ViewActionType_DisplayModeId])
|
||||
{
|
||||
aSentByAction->setIcon (isOn ? QIcon (":/icons/view_dm_wireframe.png")
|
||||
: QIcon (":/icons/view_dm_shading.png"));
|
||||
return;
|
||||
}
|
||||
|
||||
if (!isOn)
|
||||
return;
|
||||
|
||||
for (int anActionId = View_ViewActionType_FitAreaId; anActionId <= View_ViewActionType_RotationId; anActionId++)
|
||||
{
|
||||
QAction* anAction = myViewActions[(View_ViewActionType)anActionId];
|
||||
if ((anAction == myViewActions[View_ViewActionType_FitAreaId]) ||
|
||||
(anAction == myViewActions[View_ViewActionType_ZoomId]) ||
|
||||
(anAction == myViewActions[View_ViewActionType_PanId]) ||
|
||||
(anAction == myViewActions[View_ViewActionType_RotationId]))
|
||||
{
|
||||
if (anAction && (anAction != aSentByAction))
|
||||
{
|
||||
anAction->setChecked (false);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (aSentByAction == myViewActions[View_ViewActionType_FitAreaId])
|
||||
setActiveCursor (View_CursorMode_HandCursor);
|
||||
else if (aSentByAction == myViewActions[View_ViewActionType_ZoomId])
|
||||
setActiveCursor (View_CursorMode_ZoomCursor);
|
||||
else if (aSentByAction == myViewActions[View_ViewActionType_PanId])
|
||||
setActiveCursor (View_CursorMode_PanCursor);
|
||||
else if (aSentByAction == myViewActions[View_ViewActionType_RotationId])
|
||||
setActiveCursor (View_CursorMode_RotationCursor);
|
||||
else
|
||||
setActiveCursor (View_CursorMode_DefaultCursor);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : initViewActions
|
||||
// purpose :
|
||||
@@ -315,31 +262,8 @@ void View_Widget::initViewActions()
|
||||
createAction (View_ViewActionType_FitAllId, ":/icons/view_fitall.png", tr ("Fit All"), SLOT (OnFitAll()));
|
||||
myFitAllAction->setDefaultAction (ViewAction (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);
|
||||
createAction (View_ViewActionType_RotationId, ":/icons/view_rotate.png", tr ("Rotation"), SLOT (OnRotate()), true);
|
||||
createAction (View_ViewActionType_DisplayModeId, ":/icons/view_dm_shading.png", tr ("Display Mode"),
|
||||
SIGNAL (displayModeClicked()), true);
|
||||
|
||||
for (int anActionId = View_ViewActionType_FitAreaId; anActionId <= View_ViewActionType_RotationId; anActionId++)
|
||||
connect (myViewActions[(View_ViewActionType)anActionId], SIGNAL (toggled(bool)), this, SLOT (OnUpdateToggled(bool)));
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : initCursors
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
void View_Widget::initCursors()
|
||||
{
|
||||
if (!myCursors.empty())
|
||||
return;
|
||||
|
||||
myCursors[View_CursorMode_DefaultCursor] = QCursor (Qt::ArrowCursor);
|
||||
myCursors[View_CursorMode_HandCursor] = QCursor (Qt::PointingHandCursor);
|
||||
myCursors[View_CursorMode_PanCursor] = QCursor (Qt::SizeAllCursor);
|
||||
myCursors[View_CursorMode_ZoomCursor] = QCursor(QIcon (":/icons/cursor_zoom.png").pixmap (20, 20));
|
||||
myCursors[View_CursorMode_RotationCursor] = QCursor(QIcon (":/icons/cursor_rotate.png").pixmap (20, 20));
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
@@ -348,12 +272,13 @@ void View_Widget::initCursors()
|
||||
// =======================================================================
|
||||
void View_Widget::mousePressEvent (QMouseEvent* theEvent)
|
||||
{
|
||||
if (theEvent->button() == Qt::LeftButton)
|
||||
processLeftButtonDown (theEvent->buttons() | theEvent->modifiers(), theEvent->pos());
|
||||
else if (theEvent->button() == Qt::MidButton)
|
||||
processMiddleButtonDown (theEvent->buttons() | theEvent->modifiers(), theEvent->pos());
|
||||
else if (theEvent->button() == Qt::RightButton)
|
||||
processRightButtonDown (theEvent->buttons() | theEvent->modifiers(), theEvent->pos());
|
||||
if (myController->PressMouseButton (Graphic3d_Vec2i (theEvent->x(), theEvent->y()),
|
||||
keyMouse (theEvent->button()),
|
||||
keyFlag (theEvent->modifiers()),
|
||||
Standard_False))
|
||||
{
|
||||
myController->FlushViewEvents (myViewer->GetContext(), myViewer->GetView(), Standard_True);
|
||||
}
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
@@ -362,12 +287,13 @@ void View_Widget::mousePressEvent (QMouseEvent* theEvent)
|
||||
// =======================================================================
|
||||
void View_Widget::mouseReleaseEvent (QMouseEvent* theEvent)
|
||||
{
|
||||
if (theEvent->button() == Qt::LeftButton)
|
||||
processLeftButtonUp (theEvent->buttons() | theEvent->modifiers(), theEvent->pos());
|
||||
else if (theEvent->button() == Qt::MidButton)
|
||||
processMiddleButtonUp (theEvent->buttons() | theEvent->modifiers(), theEvent->pos());
|
||||
else if (theEvent->button() == Qt::RightButton)
|
||||
processRightButtonUp (theEvent->buttons() | theEvent->modifiers(), theEvent->pos());
|
||||
if (myController->ReleaseMouseButton (Graphic3d_Vec2i (theEvent->x(), theEvent->y()),
|
||||
keyMouse (theEvent->button()),
|
||||
keyFlag (theEvent->modifiers()),
|
||||
Standard_False))
|
||||
{
|
||||
myController->FlushViewEvents (myViewer->GetContext(), myViewer->GetView(), Standard_True);
|
||||
}
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
@@ -376,411 +302,11 @@ void View_Widget::mouseReleaseEvent (QMouseEvent* theEvent)
|
||||
// =======================================================================
|
||||
void View_Widget::mouseMoveEvent (QMouseEvent* theEvent)
|
||||
{
|
||||
processMouseMove (theEvent->buttons() | theEvent->modifiers(), theEvent->pos());
|
||||
}
|
||||
myController->UpdateMousePosition (Graphic3d_Vec2i (theEvent->x(), theEvent->y()),
|
||||
keyMouse (theEvent->button()),
|
||||
keyFlag (theEvent->modifiers()), Standard_False);
|
||||
|
||||
// =======================================================================
|
||||
// function : activateCursor
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
void View_Widget::activateCursor (const View_CurrentAction3d theMode)
|
||||
{
|
||||
switch (theMode)
|
||||
{
|
||||
case View_CurrentAction3d_DynamicPanning:
|
||||
{
|
||||
setActiveCursor (View_CursorMode_PanCursor);
|
||||
break;
|
||||
}
|
||||
case View_CurrentAction3d_DynamicZooming:
|
||||
{
|
||||
setActiveCursor (View_CursorMode_ZoomCursor);
|
||||
break;
|
||||
}
|
||||
case View_CurrentAction3d_DynamicRotation:
|
||||
{
|
||||
setActiveCursor (View_CursorMode_RotationCursor);
|
||||
break;
|
||||
}
|
||||
case View_CurrentAction3d_WindowZooming:
|
||||
{
|
||||
setActiveCursor (View_CursorMode_HandCursor);
|
||||
break;
|
||||
}
|
||||
case View_CurrentAction3d_Nothing:
|
||||
default:
|
||||
{
|
||||
setActiveCursor (View_CursorMode_DefaultCursor);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : processLeftButtonDown
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
void View_Widget::processLeftButtonDown (const int theFlags, const QPoint thePoint)
|
||||
{
|
||||
// save the current mouse coordinate in min
|
||||
myXmin = thePoint.x();
|
||||
myYmin = thePoint.y();
|
||||
myXmax = thePoint.x();
|
||||
myYmax = thePoint.y();
|
||||
|
||||
if (theFlags & CASCADESHORTCUTKEY)
|
||||
{
|
||||
myCurrentMode = View_CurrentAction3d_DynamicZooming;
|
||||
OnUpdateToggled(true);
|
||||
}
|
||||
else
|
||||
{
|
||||
switch (myCurrentMode)
|
||||
{
|
||||
case View_CurrentAction3d_Nothing:
|
||||
{
|
||||
if (theFlags & MULTISELECTIONKEY)
|
||||
processDragMultiEvent (myXmax, myYmax, View_DragMode_ButtonDown);
|
||||
else
|
||||
processDragEvent (myXmax, myYmax, View_DragMode_ButtonDown);
|
||||
break;
|
||||
}
|
||||
case View_CurrentAction3d_DynamicZooming:
|
||||
case View_CurrentAction3d_WindowZooming:
|
||||
case View_CurrentAction3d_DynamicPanning:
|
||||
break;
|
||||
case View_CurrentAction3d_DynamicRotation:
|
||||
{
|
||||
myViewer->GetView()->StartRotation (thePoint.x(), thePoint.y());
|
||||
break;
|
||||
}
|
||||
default:
|
||||
{
|
||||
throw Standard_ProgramError ("View_Widget::processLeftButtonDown : Incompatible Current Mode");
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
activateCursor (myCurrentMode);
|
||||
emit leftButtonDown(thePoint.x(), thePoint.y());
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : processMiddleButtonDown
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
void View_Widget::processMiddleButtonDown (const int theFlags, const QPoint /*thePoint*/)
|
||||
{
|
||||
if (theFlags & CASCADESHORTCUTKEY) {
|
||||
myCurrentMode = View_CurrentAction3d_DynamicPanning;
|
||||
OnUpdateToggled(true);
|
||||
}
|
||||
activateCursor (myCurrentMode);
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : processRightButtonDown
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
void View_Widget::processRightButtonDown (const int theFlags, const QPoint thePoint)
|
||||
{
|
||||
if (theFlags & CASCADESHORTCUTKEY)
|
||||
{
|
||||
myCurrentMode = View_CurrentAction3d_DynamicRotation;
|
||||
myViewer->GetView()->StartRotation (thePoint.x(), thePoint.y());
|
||||
OnUpdateToggled(true);
|
||||
}
|
||||
else
|
||||
{
|
||||
popup (thePoint.x(), thePoint.y());
|
||||
}
|
||||
activateCursor (myCurrentMode);
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : processLeftButtonUp
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
void View_Widget::processLeftButtonUp (const int theFlags, const QPoint thePoint)
|
||||
{
|
||||
switch (myCurrentMode)
|
||||
{
|
||||
case View_CurrentAction3d_Nothing:
|
||||
{
|
||||
if (thePoint.x() == myXmin && thePoint.y() == myYmin)
|
||||
{
|
||||
// no offset between down and up --> selectEvent
|
||||
myXmax = thePoint.x();
|
||||
myYmax = thePoint.y();
|
||||
if (theFlags & MULTISELECTIONKEY)
|
||||
processInputMultiEvent (thePoint.x(), thePoint.y());
|
||||
else
|
||||
processInputEvent (thePoint.x(), thePoint.y());
|
||||
}
|
||||
else
|
||||
{
|
||||
drawRectangle (myXmin, myYmin, myXmax, myYmax, Standard_False);
|
||||
myXmax = thePoint.x();
|
||||
myYmax = thePoint.y();
|
||||
if (theFlags & MULTISELECTIONKEY)
|
||||
processDragMultiEvent (thePoint.x(), thePoint.y(), View_DragMode_ButtonUp);
|
||||
else
|
||||
processDragEvent (thePoint.x(), thePoint.y(), View_DragMode_ButtonUp);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case View_CurrentAction3d_DynamicZooming:
|
||||
break;
|
||||
case View_CurrentAction3d_WindowZooming:
|
||||
{
|
||||
drawRectangle (myXmin, myYmin, myXmax, myYmax, Standard_False);
|
||||
myXmax = thePoint.x();
|
||||
myYmax = thePoint.y();
|
||||
if ((abs(myXmin - myXmax) > ValZWMin) ||
|
||||
(abs(myYmin - myYmax) > ValZWMin))
|
||||
myViewer->GetView()->WindowFitAll (myXmin, myYmin, myXmax, myYmax);
|
||||
break;
|
||||
}
|
||||
case View_CurrentAction3d_DynamicPanning:
|
||||
break;
|
||||
case View_CurrentAction3d_DynamicRotation:
|
||||
break;
|
||||
default:
|
||||
{
|
||||
throw Standard_ProgramError("View_Widget::processLeftButtonUp : Incompatible Current Mode");
|
||||
break;
|
||||
}
|
||||
}
|
||||
myDragButtonDownX = 0;
|
||||
myDragButtonDownY = 0;
|
||||
myDragMultiButtonDownX = 0;
|
||||
myDragMultiButtonDownY = 0;
|
||||
|
||||
emit selectionChanged();
|
||||
emit leftButtonUp(thePoint.x(), thePoint.y());
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : processMiddleButtonUp
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
void View_Widget::processMiddleButtonUp (const int /*theFlags*/, const QPoint /*thePoint*/)
|
||||
{
|
||||
myCurrentMode = View_CurrentAction3d_Nothing;
|
||||
activateCursor (myCurrentMode);
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : processRightButtonUp
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
void View_Widget::processRightButtonUp (const int /*theFlags*/, const QPoint thePoint)
|
||||
{
|
||||
if (myCurrentMode == View_CurrentAction3d_Nothing)
|
||||
{
|
||||
popup (thePoint.x(), thePoint.y());
|
||||
}
|
||||
else
|
||||
myCurrentMode = View_CurrentAction3d_Nothing;
|
||||
activateCursor (myCurrentMode);
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : processMouseMove
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
void View_Widget::processMouseMove (const int theFlags, const QPoint thePoint)
|
||||
{
|
||||
if (theFlags & Qt::LeftButton || theFlags & Qt::RightButton || theFlags & Qt::MidButton)
|
||||
{
|
||||
switch (myCurrentMode)
|
||||
{
|
||||
case View_CurrentAction3d_Nothing:
|
||||
{
|
||||
myXmax = thePoint.x();
|
||||
myYmax = thePoint.y();
|
||||
drawRectangle (myXmin, myYmin, myXmax, myYmax, Standard_False);
|
||||
if (theFlags & MULTISELECTIONKEY)
|
||||
processDragMultiEvent (myXmax, myYmax, View_DragMode_ButtonMove);
|
||||
else
|
||||
processDragEvent (myXmax, myYmax, View_DragMode_ButtonMove);
|
||||
drawRectangle (myXmin, myYmin, myXmax, myYmax, Standard_True);
|
||||
break;
|
||||
}
|
||||
case View_CurrentAction3d_DynamicZooming:
|
||||
{
|
||||
myViewer->GetView()->Zoom (myXmax, myYmax, thePoint.x(), thePoint.y());
|
||||
myXmax = thePoint.x();
|
||||
myYmax = thePoint.y();
|
||||
break;
|
||||
}
|
||||
case View_CurrentAction3d_WindowZooming:
|
||||
{
|
||||
myXmax = thePoint.x();
|
||||
myYmax = thePoint.y();
|
||||
drawRectangle (myXmin, myYmin, myXmax, myYmax, Standard_False);
|
||||
drawRectangle (myXmin, myYmin, myXmax, myYmax, Standard_True);
|
||||
break;
|
||||
}
|
||||
case View_CurrentAction3d_DynamicPanning:
|
||||
{
|
||||
myViewer->GetView()->Pan (thePoint.x() - myXmax, myYmax - thePoint.y());
|
||||
myXmax = thePoint.x();
|
||||
myYmax = thePoint.y();
|
||||
break;
|
||||
}
|
||||
case View_CurrentAction3d_DynamicRotation:
|
||||
{
|
||||
myViewer->GetView()->Rotation (thePoint.x(), thePoint.y());
|
||||
myViewer->GetView()->Redraw();
|
||||
break;
|
||||
}
|
||||
default:
|
||||
{
|
||||
throw Standard_ProgramError("View_Widget::processMouseMove : Incompatible Current Mode");
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
myXmax = thePoint.x();
|
||||
myYmax = thePoint.y();
|
||||
if (theFlags & MULTISELECTIONKEY)
|
||||
processMoveMultiEvent (thePoint.x(), thePoint.y());
|
||||
else
|
||||
processMoveEvent (thePoint.x(), thePoint.y());
|
||||
}
|
||||
emit moveTo (thePoint.x(), thePoint.y());
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : processDragEvent
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
void View_Widget::processDragEvent (const Standard_Integer theX, const Standard_Integer theY, const View_DragMode& theState)
|
||||
{
|
||||
//myDragButtonDownX = 0;
|
||||
//myDragButtonDownY = 0;
|
||||
|
||||
switch (theState)
|
||||
{
|
||||
case View_DragMode_ButtonDown:
|
||||
{
|
||||
myDragButtonDownX = theX;
|
||||
myDragButtonDownY = theY;
|
||||
break;
|
||||
}
|
||||
case View_DragMode_ButtonMove:
|
||||
break;
|
||||
case View_DragMode_ButtonUp:
|
||||
{
|
||||
myViewer->GetContext()->Select (myDragButtonDownX, myDragButtonDownY, theX, theY, myViewer->GetView(), Standard_True);
|
||||
emit selectionChanged();
|
||||
break;
|
||||
}
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : processInputEvent
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
void View_Widget::processInputEvent (const Standard_Integer/* theX*/, const Standard_Integer/* theY*/)
|
||||
{
|
||||
myViewer->GetContext()->Select (Standard_True);
|
||||
emit selectionChanged();
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : processMoveEvent
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
void View_Widget::processMoveEvent (const Standard_Integer theX, const Standard_Integer theY)
|
||||
{
|
||||
if (myViewer->GetView())
|
||||
myViewer->GetContext()->MoveTo (theX, theY, myViewer->GetView(), Standard_True);
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : processDragMultiEvent
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
void View_Widget::processDragMultiEvent (const Standard_Integer theX, const Standard_Integer theY,
|
||||
const View_DragMode& theState)
|
||||
{
|
||||
switch (theState)
|
||||
{
|
||||
case View_DragMode_ButtonDown:
|
||||
{
|
||||
myDragMultiButtonDownX = theX;
|
||||
myDragMultiButtonDownY = theY;
|
||||
break;
|
||||
}
|
||||
case View_DragMode_ButtonMove:
|
||||
{
|
||||
myViewer->GetContext()->ShiftSelect (myDragMultiButtonDownX, myDragMultiButtonDownY, theX, theY,
|
||||
myViewer->GetView(), Standard_True);
|
||||
emit selectionChanged();
|
||||
break;
|
||||
}
|
||||
case View_DragMode_ButtonUp:
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : processInputMultiEvent
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
void View_Widget::processInputMultiEvent (const Standard_Integer /*theX*/, const Standard_Integer /*theY*/)
|
||||
{
|
||||
myViewer->GetContext()->ShiftSelect (Standard_True);
|
||||
emit selectionChanged();
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : drawRectangle
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
void View_Widget::drawRectangle (const Standard_Integer theMinX, const Standard_Integer MinY,
|
||||
const Standard_Integer MaxX, const Standard_Integer MaxY,
|
||||
const Standard_Boolean theToDraw)
|
||||
{
|
||||
Standard_Integer StoredMinX, StoredMaxX, StoredMinY, StoredMaxY;
|
||||
|
||||
StoredMinX = (theMinX < MaxX) ? theMinX : MaxX;
|
||||
StoredMinY = (MinY < MaxY) ? MinY : MaxY;
|
||||
StoredMaxX = (theMinX > MaxX) ? theMinX : MaxX;
|
||||
StoredMaxY = (MinY > MaxY) ? MinY : MaxY;
|
||||
|
||||
QRect aRect;
|
||||
aRect.setRect(StoredMinX, StoredMinY, abs (StoredMaxX-StoredMinX), abs (StoredMaxY-StoredMinY));
|
||||
|
||||
if (!myRectBand)
|
||||
{
|
||||
myRectBand = new QRubberBand (QRubberBand::Rectangle, this);
|
||||
myRectBand->setStyle (QStyleFactory::create ("windows"));
|
||||
myRectBand->setGeometry (aRect);
|
||||
myRectBand->show();
|
||||
}
|
||||
|
||||
if (myIsRectVisible && !theToDraw) // move or up : erase at the old position
|
||||
{
|
||||
myRectBand->hide();
|
||||
delete myRectBand;
|
||||
myRectBand = 0;
|
||||
myIsRectVisible = false;
|
||||
}
|
||||
|
||||
if (theToDraw) // move : draw
|
||||
{
|
||||
myIsRectVisible = true;
|
||||
myRectBand->setGeometry (aRect);
|
||||
}
|
||||
myController->FlushViewEvents (myViewer->GetContext(), myViewer->GetView(), Standard_True);
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
@@ -801,11 +327,34 @@ void View_Widget::createAction (const View_ViewActionType theActionId, const QSt
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : setActiveCursor
|
||||
// function : keyFlag
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
void View_Widget::setActiveCursor (const View_CursorMode& theMode)
|
||||
Aspect_VKeyFlags View_Widget::keyFlag (const int theModifierId)
|
||||
{
|
||||
QCursor aCursor = myCursors[theMode];
|
||||
setCursor (myCursors[theMode]);
|
||||
switch (theModifierId)
|
||||
{
|
||||
case Qt::NoModifier: return Aspect_VKeyFlags_NONE;
|
||||
case Qt::ShiftModifier: return Aspect_VKeyFlags_SHIFT;
|
||||
case Qt::ControlModifier: return Aspect_VKeyFlags_CTRL;
|
||||
default: break;
|
||||
}
|
||||
return Aspect_VKeyFlags_NONE;
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : keyMouse
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
Aspect_VKeyMouse View_Widget::keyMouse (const int theButtonId)
|
||||
{
|
||||
switch (theButtonId)
|
||||
{
|
||||
case Qt::NoButton: return Aspect_VKeyMouse_NONE;
|
||||
case Qt::LeftButton: return Aspect_VKeyMouse_LeftButton;
|
||||
case Qt::RightButton: return Aspect_VKeyMouse_RightButton;
|
||||
case Qt::MidButton: return Aspect_VKeyMouse_MiddleButton;
|
||||
default: break;
|
||||
}
|
||||
return Aspect_VKeyMouse_NONE;
|
||||
}
|
||||
|
Reference in New Issue
Block a user