2 #include "OCCViewer_Utilities.h"
3 #include "OCCViewer_ViewFrame.h"
4 #include "OCCViewer_ViewModel.h"
5 #include "OCCViewer_ViewPort3d.h"
7 #include "SUIT_ViewManager.h"
8 #include "QtxActionToolMgr.h"
9 #include <QtxMultiAction.h>
10 #include <V3d_View.hxx>
14 void OCCViewer_Utilities::setViewer2DMode( OCCViewer_Viewer* theViewer,
15 const OCCViewer_ViewWindow::Mode2dType& theMode )
17 OCCViewer_ViewFrame* aFrame = dynamic_cast<OCCViewer_ViewFrame*>
18 ( theViewer->getViewManager()->getActiveView() );
19 OCCViewer_ViewWindow* aView = aFrame ? aFrame->getView( OCCViewer_ViewFrame::MAIN_VIEW ) : 0;
24 aView->set2dMode( theMode );
25 bool is2dMode = theMode != OCCViewer_ViewWindow::No2dMode;
27 // enable/disable view actions
28 QList<int> aNo2dActions;
29 aNo2dActions << OCCViewer_ViewWindow::ChangeRotationPointId
30 << OCCViewer_ViewWindow::RotationId
31 << OCCViewer_ViewWindow::FrontId
32 << OCCViewer_ViewWindow::BackId
33 //<< OCCViewer_ViewWindow::TopId
34 << OCCViewer_ViewWindow::BottomId
35 << OCCViewer_ViewWindow::LeftId
36 << OCCViewer_ViewWindow::RightId
37 << OCCViewer_ViewWindow::AntiClockWiseId
38 << OCCViewer_ViewWindow::ClockWiseId
39 << OCCViewer_ViewWindow::ResetId;
41 QtxActionToolMgr* aToolMgr = aView->toolMgr();
43 for ( int i = 0, aNb = aNo2dActions.size(); i < aNb; i++ ) {
44 anAction = aToolMgr->action( aNo2dActions[i] );
46 anAction->setEnabled( !is2dMode );
48 QAction* aTop = aToolMgr->action( OCCViewer_ViewWindow::TopId );
49 QtxMultiAction* aMulti = dynamic_cast<QtxMultiAction*>( aTop->parent() );
50 aMulti->setActiveAction( aTop );
52 // change view position
53 Handle(V3d_View) aView3d = aView->getViewPort()->getView();
54 if ( !aView3d.IsNull() ) {
56 case OCCViewer_ViewWindow::XYPlane:
57 aView3d->SetProj (V3d_Zpos);
59 case OCCViewer_ViewWindow::XZPlane:
60 aView3d->SetProj (V3d_Yneg);
62 case OCCViewer_ViewWindow::YZPlane:
63 aView3d->SetProj (V3d_Xpos);