X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FOCCViewer%2FOCCViewer_ViewWindow.cxx;h=683f0499e3a94eaf33f7a437be1ebf0506ef57c2;hb=e232236eb57c37a9daef7d114d940fb60d9f659f;hp=2b2d6d866b4f9d28e58667cb31635c2739676dad;hpb=bb8609caf7881d966fbb88dec0a7822736da93f5;p=modules%2Fgui.git diff --git a/src/OCCViewer/OCCViewer_ViewWindow.cxx b/src/OCCViewer/OCCViewer_ViewWindow.cxx index 2b2d6d866..683f0499e 100755 --- a/src/OCCViewer/OCCViewer_ViewWindow.cxx +++ b/src/OCCViewer/OCCViewer_ViewWindow.cxx @@ -29,10 +29,11 @@ #include "OCCViewer_ViewManager.h" #include "OCCViewer_ViewSketcher.h" #include "OCCViewer_CreateRestoreViewDlg.h" -#include "OCCViewer_ClippingDlg.h" +#include "OCCViewer_ClipPlane.h" #include "OCCViewer_SetRotationPointDlg.h" #include "OCCViewer_AxialScaleDlg.h" #include "OCCViewer_CubeAxesDlg.h" +#include "OCCViewer_ClippingDlg.h" #include @@ -79,6 +80,12 @@ #include #include +#if OCC_VERSION_LARGE > 0x06060000 +#include +#include + +#endif + #include #include "utilities.h" @@ -224,18 +231,21 @@ OCCViewer_ViewWindow::OCCViewer_ViewWindow( SUIT_Desktop* theDesktop, myEnableDrawMode = false; myDrawRect=false; updateEnabledDrawMode(); - myClippingDlg = 0; myScalingDlg = 0; mySetRotationPointDlg = 0; myRectBand = 0; IsSketcherStyle = false; + myIsKeyFree = false; mypSketcher = 0; myCurSketch = -1; my2dMode = No2dMode; myInteractionStyle = SUIT_ViewModel::STANDARD; + myPreselectionEnabled = true; + mySelectionEnabled = true; + clearViewAspects(); @@ -351,13 +361,13 @@ bool OCCViewer_ViewWindow::eventFilter( QObject* watched, QEvent* e ) case QEvent::Wheel: { QWheelEvent* aEvent = (QWheelEvent*) e; - myViewPort->startZoomAtPoint( aEvent->x(), aEvent->y() ); - double delta = (double)( aEvent->delta() ) / ( 15 * 8 ); - int x = aEvent->x(); - int y = aEvent->y(); - int x1 = (int)( aEvent->x() + width()*delta/100 ); - int y1 = (int)( aEvent->y() + height()*delta/100 ); - myViewPort->zoom( x, y, x1, y1 ); + myViewPort->startZoomAtPoint( aEvent->x(), aEvent->y() ); + double delta = (double)( aEvent->delta() ) / ( 15 * 8 ); + int x = aEvent->x(); + int y = aEvent->y(); + int x1 = (int)( aEvent->x() + width()*delta/100 ); + int y1 = (int)( aEvent->y() + height()*delta/100 ); + myViewPort->zoom( x, y, x1, y1 ); } return true; @@ -448,17 +458,24 @@ void OCCViewer_ViewWindow::vpMousePressEvent( QMouseEvent* theEvent ) default: /* Try to activate a transformation */ - switch ( getButtonState(theEvent, anInteractionStyle) ) { + OperationType aState; + if ( interactionStyle() == SUIT_ViewModel::STANDARD ) + aState = getButtonState(theEvent, anInteractionStyle); + else { + aState = OCCViewer_ViewWindow::NOTHING; + myIsKeyFree = true; + } + switch ( aState ) { case ZOOMVIEW: myViewPort->startZoomAtPoint( myStartX, myStartY ); activateZoom(); break; case PANVIEW: - activatePanning(); + activatePanning(); break; case ROTATE: - activateRotation(); - myViewPort->startRotation(myStartX, myStartY, myCurrPointType, mySelectedPoint); + activateRotation(); + myViewPort->startRotation(myStartX, myStartY, myCurrPointType, mySelectedPoint); break; default: if ( myRotationPointSelection ) @@ -792,6 +809,25 @@ bool OCCViewer_ViewWindow::setTransformRequested( OperationType op ) */ void OCCViewer_ViewWindow::vpMouseMoveEvent( QMouseEvent* theEvent ) { + if ( myIsKeyFree && interactionStyle() == SUIT_ViewModel::KEY_FREE ) { + myIsKeyFree = false; + switch ( getButtonState( theEvent, interactionStyle() ) ) { + case ZOOMVIEW: + myViewPort->startZoomAtPoint( myStartX, myStartY ); + activateZoom(); + break; + case PANVIEW: + activatePanning(); + break; + case ROTATE: + activateRotation(); + myViewPort->startRotation(myStartX, myStartY, myCurrPointType, mySelectedPoint); + break; + default: + break; + } + } + myCurrX = theEvent->x(); myCurrY = theEvent->y(); switch (myOperation) { @@ -829,8 +865,10 @@ void OCCViewer_ViewWindow::vpMouseMoveEvent( QMouseEvent* theEvent ) int aState = theEvent->modifiers(); int aButton = theEvent->buttons(); int anInteractionStyle = interactionStyle(); - if ( anInteractionStyle == SUIT_ViewModel::STANDARD && - aButton == Qt::LeftButton && ( aState == Qt::NoModifier || Qt::ShiftModifier ) ) { + if ( ( anInteractionStyle == SUIT_ViewModel::STANDARD && + aButton == Qt::LeftButton && ( aState == Qt::NoModifier || Qt::ShiftModifier ) ) || + ( anInteractionStyle == SUIT_ViewModel::KEY_FREE && + aButton == Qt::LeftButton && ( aState == Qt::ControlModifier || aState == ( Qt::ControlModifier|Qt::ShiftModifier ) ) ) ) { myDrawRect = myEnableDrawMode; if ( myDrawRect ) { drawRect(); @@ -843,8 +881,10 @@ void OCCViewer_ViewWindow::vpMouseMoveEvent( QMouseEvent* theEvent ) } emit mouseMoving( this, theEvent ); } - else if ( anInteractionStyle == SUIT_ViewModel::STANDARD && - aButton == Qt::RightButton && ( aState == Qt::NoModifier || Qt::ShiftModifier ) ) { + else if ( ( anInteractionStyle == SUIT_ViewModel::STANDARD && + aButton == Qt::RightButton && ( aState == Qt::NoModifier || Qt::ShiftModifier ) ) || + ( anInteractionStyle == SUIT_ViewModel::KEY_FREE && + aButton == Qt::RightButton && ( aState == Qt::ControlModifier || aState == ( Qt::ControlModifier|Qt::ShiftModifier ) ) ) ) { OCCViewer_ViewSketcher* sketcher = 0; QList::Iterator it; for ( it = mySketchers.begin(); it != mySketchers.end() && !sketcher; ++it ) @@ -1171,12 +1211,12 @@ void OCCViewer_ViewWindow::createActions() connect(aAction, SIGNAL(triggered()), this, SLOT(onCloneView())); toolMgr()->registerAction( aAction, CloneId ); - myClippingAction = new QtxAction(tr("MNU_CLIPPING"), aResMgr->loadPixmap( "OCCViewer", tr( "ICON_OCCVIEWER_CLIPPING" ) ), - tr( "MNU_CLIPPING" ), 0, this); - myClippingAction->setStatusTip(tr("DSC_CLIPPING")); - myClippingAction->setCheckable( true ); - connect(myClippingAction, SIGNAL(toggled( bool )), this, SLOT(onClipping( bool ))); - toolMgr()->registerAction( myClippingAction, ClippingId ); + aAction = new QtxAction (tr ("MNU_CLIPPING"), aResMgr->loadPixmap ("OCCViewer", tr ("ICON_OCCVIEWER_CLIPPING")), + tr ("MNU_CLIPPING"), 0, this); + aAction->setStatusTip (tr ("DSC_CLIPPING")); + aAction->setCheckable (true); + connect (aAction, SIGNAL (toggled (bool)), this, SLOT (onClipping (bool))); + toolMgr()->registerAction (aAction, ClippingId); aAction = new QtxAction(tr("MNU_SHOOT_VIEW"), aResMgr->loadPixmap( "OCCViewer", tr( "ICON_OCCVIEWER_SHOOT_VIEW" ) ), tr( "MNU_SHOOT_VIEW" ), 0, this); @@ -1205,6 +1245,22 @@ void OCCViewer_ViewWindow::createActions() connect(aAction, SIGNAL(triggered()), this, SLOT(onAxialScale())); toolMgr()->registerAction( aAction, AxialScaleId ); + // Enable/disable preselection + aAction = new QtxAction(tr("MNU_ENABLE_PRESELECTION"), aResMgr->loadPixmap( "OCCViewer", tr( "ICON_OCCVIEWER_PRESELECTION" ) ), + tr( "MNU_ENABLE_PRESELECTION" ), 0, this); + aAction->setStatusTip(tr("DSC_ENABLE_PRESELECTION")); + aAction->setCheckable(true); + connect(aAction, SIGNAL(toggled(bool)), this, SLOT(onSwitchPreselection(bool))); + toolMgr()->registerAction( aAction, SwitchPreselectionId ); + + // Enable/disable selection + aAction = new QtxAction(tr("MNU_ENABLE_SELECTION"), aResMgr->loadPixmap( "OCCViewer", tr( "ICON_OCCVIEWER_SELECTION" ) ), + tr( "MNU_ENABLE_SELECTION" ), 0, this); + aAction->setStatusTip(tr("DSC_ENABLE_SELECTION")); + aAction->setCheckable(true); + connect(aAction, SIGNAL(toggled(bool)), this, SLOT(onSwitchSelection(bool))); + toolMgr()->registerAction( aAction, SwitchSelectionId ); + // Graduated axes aAction = new QtxAction(tr("MNU_GRADUATED_AXES"), aResMgr->loadPixmap( "OCCViewer", tr( "ICON_OCCVIEWER_GRADUATED_AXES" ) ), tr( "MNU_GRADUATED_AXES" ), 0, this); @@ -1242,6 +1298,15 @@ void OCCViewer_ViewWindow::createActions() connect(aAction, SIGNAL(triggered()), this, SLOT(onMaximizedView())); toolMgr()->registerAction( aAction, MaximizedId ); + // Return to 3d view + if (my2dMode!=No2dMode){ + aAction = new QtxAction(tr("MNU_RETURN_3D_VIEW"), aResMgr->loadPixmap( "OCCViewer", tr( "ICON_OCCVIEWER_RETURN_3D_VIEW" ) ), + tr( "MNU_RETURN_3D_VIEW" ), 0, this ); + aAction->setStatusTip(tr("DSC_RETURN_3D_VIEW")); + connect(aAction, SIGNAL(triggered()), this, SLOT(returnTo3dView())); + toolMgr()->registerAction( aAction, ReturnTo3dViewId ); + } + // Synchronize View toolMgr()->registerAction( synchronizeAction(), SynchronizeId ); } @@ -1267,12 +1332,17 @@ void OCCViewer_ViewWindow::createToolBar() } int tid = toolMgr()->createToolBar( aToolbarName, false ); - + if ( my2dMode != No2dMode ){ + toolMgr()->append( ReturnTo3dViewId, tid ); + toolMgr()->append( toolMgr()->separator(), tid ); + } toolMgr()->append( DumpId, tid ); toolMgr()->append( SwitchInteractionStyleId, tid ); #if OCC_VERSION_LARGE > 0x0603000A // available only with OCC-6.3-sp11 and higher version toolMgr()->append( SwitchZoomingStyleId, tid ); #endif + toolMgr()->append( SwitchPreselectionId, tid ); + toolMgr()->append( SwitchSelectionId, tid ); if( myModel->trihedronActivated() ) toolMgr()->append( TrihedronShowId, tid ); @@ -1495,44 +1565,6 @@ void OCCViewer_ViewWindow::onCloneView() emit viewCloned( vw ); } -/*! - \brief called if clipping operation is activated. - - Enables/disables clipping plane displaying. - - \parma on action state -*/ -void OCCViewer_ViewWindow::onClipping( bool on ) -{ - /* - SUIT_ResourceMgr* aResMgr = SUIT_Session::session()->resourceMgr(); - if ( on ) - myActionsMap[ ClippingId ]->setIcon(aResMgr->loadPixmap( "OCCViewer", tr( "ICON_OCCVIEWER_CLIPPING_PRESSED" ))); - else - myActionsMap[ ClippingId ]->setIcon(aResMgr->loadPixmap( "OCCViewer", tr( "ICON_OCCVIEWER_CLIPPING" ))); - */ - OCCViewer_ViewWindow* aParent = dynamic_cast(parent()->parent()); - if (!aParent) - aParent = this; - if ( on ) - { - if ( !myClippingDlg ) - { - myClippingDlg = new OCCViewer_ClippingDlg( aParent ); - myClippingDlg->SetAction( myClippingAction ); - } - - if ( !myClippingDlg->isVisible() ) - myClippingDlg->show(); - } - else - { - if ( myClippingDlg->isVisible() ) - myClippingDlg->hide(); - aParent->setCuttingPlane(false); - } -} - /*! Creates one more window with same content */ @@ -1630,14 +1662,14 @@ void OCCViewer_ViewWindow::performRestoring( const viewAspect& anItem, bool base anAxisData[1].Name = anItem.gtNameZ; anAxisData[2].Name = anItem.gtNameZ; anAxisData[0].NameColor = QColor( anItem.gtNameColorRX, - anItem.gtNameColorGX, - anItem.gtNameColorBX ); + anItem.gtNameColorGX, + anItem.gtNameColorBX ); anAxisData[1].NameColor = QColor( anItem.gtNameColorRY, - anItem.gtNameColorGY, - anItem.gtNameColorBY ); + anItem.gtNameColorGY, + anItem.gtNameColorBY ); anAxisData[2].NameColor = QColor( anItem.gtNameColorRZ, - anItem.gtNameColorGZ, - anItem.gtNameColorBZ ); + anItem.gtNameColorGZ, + anItem.gtNameColorBZ ); anAxisData[0].DrawValues = anItem.gtDrawValuesX; anAxisData[1].DrawValues = anItem.gtDrawValuesY; anAxisData[2].DrawValues = anItem.gtDrawValuesZ; @@ -1648,14 +1680,14 @@ void OCCViewer_ViewWindow::performRestoring( const viewAspect& anItem, bool base anAxisData[1].Offset = anItem.gtOffsetY; anAxisData[2].Offset = anItem.gtOffsetZ; anAxisData[0].Color = QColor( anItem.gtColorRX, - anItem.gtColorGX, - anItem.gtColorBX ); + anItem.gtColorGX, + anItem.gtColorBX ); anAxisData[1].Color = QColor( anItem.gtColorRY, - anItem.gtColorGY, - anItem.gtColorBY ); + anItem.gtColorGY, + anItem.gtColorBY ); anAxisData[2].Color = QColor( anItem.gtColorRZ, - anItem.gtColorGZ, - anItem.gtColorBZ ); + anItem.gtColorGZ, + anItem.gtColorBZ ); anAxisData[0].DrawTickmarks = anItem.gtDrawTickmarksX; anAxisData[1].DrawTickmarks = anItem.gtDrawTickmarksY; anAxisData[2].DrawTickmarks = anItem.gtDrawTickmarksZ; @@ -1688,6 +1720,49 @@ void OCCViewer_ViewWindow::onTrihedronShow() myModel->toggleTrihedron(); } +/*! + \brief Toggles preselection (highlighting) on/off +*/ +void OCCViewer_ViewWindow::onSwitchPreselection( bool on ) +{ + myPreselectionEnabled = on; + myModel->setSelectionOptions( isPreselectionEnabled(), myModel->isSelectionEnabled() ); + + // unhighlight all highlighted objects + /*if ( !on ) { + myModel->unHighlightAll( true, false ); + }*/ + + // update action state if method is called outside + QtxAction* a = dynamic_cast( toolMgr()->action( SwitchPreselectionId ) ); + if ( a && a->isChecked() != on ) { + a->setChecked( on ); + } +} + +/*! + \brief Toggles selection on/off +*/ +void OCCViewer_ViewWindow::onSwitchSelection( bool on ) +{ + mySelectionEnabled = on; + myModel->setSelectionOptions( myModel->isPreselectionEnabled(), isSelectionEnabled() ); + + // update action state if method is called outside + + // preselection + QtxAction* a = dynamic_cast( toolMgr()->action( SwitchPreselectionId ) ); + if ( a ) { + a->setEnabled( on ); + } + + // selection + a = dynamic_cast( toolMgr()->action( SwitchSelectionId ) ); + if ( a && a->isChecked() != on ) { + a->setChecked( on ); + } +} + /*! \brief Switches "keyboard free" interaction style on/off */ @@ -1851,33 +1926,33 @@ void OCCViewer_ViewWindow::setCuttingPlane( bool on, const double x, const doub // try to use already existing plane or create a new one Handle(V3d_Plane) clipPlane; - view->InitActivePlanes(); // calculate new a,b,c,d values for the plane gp_Pln pln (gp_Pnt(x, y, z), gp_Dir(dx, dy, dz)); double a, b, c, d; pln.Coefficients(a, b, c, d); - -#if OCC_VERSION_LARGE > 0x06040000 // Porting to OCCT6.5.1 - if (view->MoreActivePlanes()) { - clipPlane = view->ActivePlane(); - clipPlane->SetPlane(a, b, c, d); + + Graphic3d_SequenceOfHClipPlane aPlanes = view->GetClipPlanes(); + Handle(Graphic3d_ClipPlane) aClipPlane; + if(aPlanes.Size() > 0 ) { + Graphic3d_SequenceOfHClipPlane::Iterator anIter (aPlanes); + aClipPlane = anIter.Value(); + aClipPlane->SetEquation(pln); + aClipPlane->SetOn(Standard_True); + } else { + aClipPlane = new Graphic3d_ClipPlane(pln); + view->AddClipPlane(aClipPlane); + aClipPlane->SetOn(Standard_True); + } + } + else { + Graphic3d_SequenceOfHClipPlane aPlanes = view->GetClipPlanes(); + Graphic3d_SequenceOfHClipPlane::Iterator anIter (aPlanes); + for( ;anIter.More();anIter.Next() ){ + Handle(Graphic3d_ClipPlane) aClipPlane = anIter.Value(); + aClipPlane->SetOn(Standard_False); } - else - clipPlane = new V3d_Plane (a, b, c, d); -#else - if (view->MoreActivePlanes()) - clipPlane = view->ActivePlane(); - else - clipPlane = new V3d_Plane (viewer); - - clipPlane->SetPlane(a, b, c, d); -#endif - - view->SetPlaneOn(clipPlane); } - else - view->SetPlaneOff(); view->Update(); view->Redraw(); @@ -1898,8 +1973,17 @@ void OCCViewer_ViewWindow::setCuttingPlane( bool on, const gp_Pln pln ) bool OCCViewer_ViewWindow::isCuttingPlane() { Handle(V3d_View) view = myViewPort->getView(); - view->InitActivePlanes(); - return (view->MoreActivePlanes()); + bool res = false; + Graphic3d_SequenceOfHClipPlane aPlanes = view->GetClipPlanes(); + Graphic3d_SequenceOfHClipPlane::Iterator anIter (aPlanes); + for( ;anIter.More();anIter.Next() ) { + Handle(Graphic3d_ClipPlane) aClipPlane = anIter.Value(); + if(aClipPlane->IsOn()) { + res = true; + break; + } + } + return res; } /*! @@ -1999,7 +2083,6 @@ viewAspect OCCViewer_ViewWindow::getViewParams() const return params; } - /*! \brief Get visual parameters of this view window. \return visual parameters of view window @@ -2029,6 +2112,28 @@ QString OCCViewer_ViewWindow::getVisualParameters() data << QString( "isVisible=%1" ).arg( params.isVisible ); data << QString( "size=%1" ) .arg( params.size, 0, 'f', 2 ); + ClipPlanesList aPlanes = myModel->getClipPlanes(); + for ( int i=0; i < aPlanes.size(); i++ ) { + OCCViewer_ClipPlane& aPlane = aPlanes[i]; + QString ClippingPlane = QString( "ClippingPlane%1=").arg( i+1 ); + ClippingPlane += QString( "Mode~%1;").arg( (int)aPlane.PlaneMode ); + ClippingPlane += QString( "IsActive~%1;").arg( aPlane.IsOn ); + ClippingPlane += QString( "AbsoluteOrientation~%1;" ).arg( aPlane.Orientation ); + ClippingPlane += QString( "IsInvert~%1;" ).arg( aPlane.IsInvert ); + ClippingPlane += QString( "X~%1;" ).arg( aPlane.X ); + ClippingPlane += QString( "Y~%1;" ).arg( aPlane.Y ); + ClippingPlane += QString( "Z~%1;" ).arg( aPlane.Z ); + ClippingPlane += QString( "Dx~%1;" ).arg( aPlane.Dx ); + ClippingPlane += QString( "Dy~%1;" ).arg( aPlane.Dy );; + ClippingPlane += QString( "Dz~%1;" ).arg( aPlane.Dz ); + ClippingPlane += QString( "RelativeOrientation~%1;" ).arg( aPlane.RelativeMode.Orientation ); + ClippingPlane += QString( "Distance~%1;" ).arg( aPlane.RelativeMode.Distance ); + ClippingPlane += QString( "Rotation1~%1;" ).arg( aPlane.RelativeMode.Rotation1 ); + ClippingPlane += QString( "Rotation2~%1" ).arg( aPlane.RelativeMode.Rotation2 ); + data << ClippingPlane; + } + + #if OCC_VERSION_LARGE > 0x06030009 // available only with OCC-6.3-sp10 or newer version // graduated trihedron data << QString( "gtIsVisible=%1" ) .arg( params.gtIsVisible ); @@ -2085,7 +2190,7 @@ QString OCCViewer_ViewWindow::getVisualParameters() void OCCViewer_ViewWindow::setVisualParameters( const QString& parameters ) { viewAspect params; - + ClipPlanesList aClipPlanes; QStringList data = parameters.split( '*' ); Qtx::BackgroundData bgData; if ( parameters.contains( '=' ) ) // new format - "scale=1.000e+00*centerX=0.000e+00..." @@ -2111,6 +2216,29 @@ void OCCViewer_ViewWindow::setVisualParameters( const QString& parameters ) else if ( paramName == "scaleZ" ) params.scaleZ = paramValue.toDouble(); else if ( paramName == "isVisible" ) params.isVisible = paramValue.toInt(); else if ( paramName == "size" ) params.size = paramValue.toDouble(); + else if ( paramName.contains( "ClippingPlane" ) ) { + QStringList ClipPlaneData = paramValue.split( ';' ); + OCCViewer_ClipPlane aPlane; + foreach( QString ClipPlaneParam, ClipPlaneData ) { + QString ClipPlane_paramName = ClipPlaneParam.section( '~', 0, 0 ).trimmed(); + QString ClipPlane_paramValue = ClipPlaneParam.section( '~', 1, 1 ).trimmed(); + if ( ClipPlane_paramName == "Mode" ) aPlane.PlaneMode = ( ClipPlaneMode )ClipPlane_paramValue.toInt(); + else if ( ClipPlane_paramName == "IsActive" ) aPlane.IsOn = ClipPlane_paramValue.toInt(); + else if ( ClipPlane_paramName == "AbsoluteOrientation" ) aPlane.Orientation = ClipPlane_paramValue.toInt(); + else if ( ClipPlane_paramName == "IsInvert" ) aPlane.IsInvert = ClipPlane_paramValue.toInt(); + else if ( ClipPlane_paramName == "X" ) aPlane.X = ClipPlane_paramValue.toDouble(); + else if ( ClipPlane_paramName == "Y" ) aPlane.Y = ClipPlane_paramValue.toDouble(); + else if ( ClipPlane_paramName == "Z" ) aPlane.Z = ClipPlane_paramValue.toDouble(); + else if ( ClipPlane_paramName == "Dx" ) aPlane.Dx = ClipPlane_paramValue.toDouble(); + else if ( ClipPlane_paramName == "Dy" ) aPlane.Dy = ClipPlane_paramValue.toDouble(); + else if ( ClipPlane_paramName == "Dz" ) aPlane.Dz = ClipPlane_paramValue.toDouble(); + else if ( ClipPlane_paramName == "RelativeOrientation" ) aPlane.RelativeMode.Orientation = ClipPlane_paramValue.toInt(); + else if ( ClipPlane_paramName == "Distance" ) aPlane.RelativeMode.Distance = ClipPlane_paramValue.toDouble(); + else if ( ClipPlane_paramName == "Rotation1" ) aPlane.RelativeMode.Rotation1 = ClipPlane_paramValue.toDouble(); + else if ( ClipPlane_paramName == "Rotation2" ) aPlane.RelativeMode.Rotation2 = ClipPlane_paramValue.toDouble(); + } + aClipPlanes.push_back(aPlane); + } // graduated trihedron else if ( paramName == "gtIsVisible" ) params.gtIsVisible = paramValue.toInt(); else if ( paramName == "gtDrawNameX" ) params.gtDrawNameX = paramValue.toInt(); @@ -2153,8 +2281,8 @@ void OCCViewer_ViewWindow::setVisualParameters( const QString& parameters ) else if ( paramName == "gtTickmarkLengthY" ) params.gtTickmarkLengthY = paramValue.toInt(); else if ( paramName == "gtTickmarkLengthZ" ) params.gtTickmarkLengthZ = paramValue.toInt(); else if ( paramName == "background" ) { - QString bg = paramValue.replace( "$", "=" ); - bgData = Qtx::stringToBackground( bg ); + QString bg = paramValue.replace( "$", "=" ); + bgData = Qtx::stringToBackground( bg ); } } } @@ -2180,8 +2308,9 @@ void OCCViewer_ViewWindow::setVisualParameters( const QString& parameters ) params.isVisible = data.count() > idx ? data[idx++].toInt() : 1; params.size = data.count() > idx ? data[idx++].toDouble() : 100.0; } - performRestoring( params ); + performRestoring( params ); setBackground( bgData ); + myModel->setClipPlanes(aClipPlanes); } /*! @@ -2294,7 +2423,7 @@ void OCCViewer_ViewWindow::onSketchingFinished() if ( mypSketcher && mypSketcher->result() == OCCViewer_ViewSketcher::Accept ) { Handle(AIS_InteractiveContext) ic = myModel->getAISContext(); - bool append = bool( mypSketcher->buttonState() & Qt::ShiftModifier ); + bool append = bool( mypSketcher->buttonState() && mypSketcher->isHasShift() ); switch( mypSketcher->type() ) { case Rect: @@ -2388,16 +2517,34 @@ void OCCViewer_ViewWindow::onMaximizedView() setMaximized(!isMaximized()); } +void OCCViewer_ViewWindow::returnTo3dView() +{ + setReturnedTo3dView( true ); +} + +void OCCViewer_ViewWindow::setReturnedTo3dView(bool isVisible3dView) +{ + if ( !toolMgr()->action( ReturnTo3dViewId ) || + toolMgr()->isShown(ReturnTo3dViewId) != isVisible3dView ) return; + if ( !isVisible3dView ) + toolMgr()->show( ReturnTo3dViewId ); + else + toolMgr()->hide( ReturnTo3dViewId ); + if ( isVisible3dView ) emit returnedTo3d( ); +} + void OCCViewer_ViewWindow::setMaximized(bool toMaximize, bool toSendSignal) { QAction* anAction = toolMgr()->action( MaximizedId ); + QAction* anAction2 = toolMgr()->action( ReturnTo3dViewId ); SUIT_ResourceMgr* aResMgr = SUIT_Session::session()->resourceMgr(); if ( toMaximize ) { anAction->setText( tr( "MNU_MINIMIZE_VIEW" ) ); anAction->setToolTip( tr( "MNU_MINIMIZE_VIEW" ) ); anAction->setIcon( aResMgr->loadPixmap( "OCCViewer", tr( "ICON_OCCVIEWER_MINIMIZE" ) ) ); anAction->setStatusTip( tr( "DSC_MINIMIZE_VIEW" ) ); + if ( anAction2 && my2dMode != No2dMode ) toolMgr()->show( ReturnTo3dViewId ); if (toSendSignal) { emit maximized( this, true ); } @@ -2407,13 +2554,13 @@ void OCCViewer_ViewWindow::setMaximized(bool toMaximize, bool toSendSignal) anAction->setToolTip( tr( "MNU_MAXIMIZE_VIEW" ) ); anAction->setIcon( aResMgr->loadPixmap( "OCCViewer", tr( "ICON_OCCVIEWER_MAXIMIZE" ) ) ); anAction->setStatusTip( tr( "DSC_MAXIMIZE_VIEW" ) ); + if ( anAction2 && my2dMode != No2dMode ) toolMgr()->hide( ReturnTo3dViewId ); if (toSendSignal) { emit maximized( this, false ); } } } - bool OCCViewer_ViewWindow::isMaximized() const { return !(toolMgr()->action( MaximizedId )->text() == tr( "MNU_MAXIMIZE_VIEW" )); @@ -2662,3 +2809,85 @@ void OCCViewer_ViewWindow::synchronize( SUIT_ViewWindow* theView ) blockSignals( blocked ); } + +/*! + \brief Indicates whether preselection is enabled + \return true if preselection is enabled +*/ +bool OCCViewer_ViewWindow::isPreselectionEnabled() const +{ + return myPreselectionEnabled; +} + +/*! + \brief Enables/disables preselection + \param theIsToEnable if true - preselection will be enabled +*/ +void OCCViewer_ViewWindow::enablePreselection( bool theIsToEnable ) +{ + onSwitchPreselection( theIsToEnable ); +} + +/*! + \brief Indicates whether selection is enabled + \return true if selection is enabled +*/ +bool OCCViewer_ViewWindow::isSelectionEnabled() const +{ + return mySelectionEnabled; +} + +/*! + \brief Enables/disables selection + \param theIsToEnable if true - selection will be enabled +*/ +void OCCViewer_ViewWindow::enableSelection( bool theIsToEnable ) +{ + onSwitchSelection( theIsToEnable ); +} + + +/*! + \brief called if clipping operation is activated / deactivated. + + Enables/disables clipping plane displaying. + + \parma on action state +*/ +void OCCViewer_ViewWindow::onClipping (bool theIsOn) +{ + if(!myModel) return; + OCCViewer_ClippingDlg* aClippingDlg = myModel->getClippingDlg(); + + if (theIsOn) { + if (!aClippingDlg) { + aClippingDlg = new OCCViewer_ClippingDlg (this, myModel); + myModel->setClippingDlg(aClippingDlg); + } + if (!aClippingDlg->isVisible()) + aClippingDlg->show(); + } else { + if ( aClippingDlg ) { + aClippingDlg->close(); + myModel->setClippingDlg(0); + } + } + + SUIT_ViewManager* mgr = getViewManager(); + if( mgr ) { + QVector aViews = mgr->getViews(); + for(int i = 0, iEnd = aViews.size(); i < iEnd; i++) { + if(SUIT_ViewWindow* aViewWindow = aViews.at(i)) { + QtxActionToolMgr* mgr = aViewWindow->toolMgr(); + if(!mgr) continue; + QAction* a = toolMgr()->action( ClippingId ); + if(!a) continue; + if(theIsOn != a->isChecked()){ + disconnect (a, SIGNAL (toggled (bool)), aViewWindow, SLOT (onClipping (bool))); + a->setChecked(theIsOn); + connect (a, SIGNAL (toggled (bool)), aViewWindow, SLOT (onClipping (bool))); + } + } + } + } +}