// internal includes
#include "OCCViewer_Utilities.h"
+#include "OCCViewer_ViewFrame.h"
+#include "OCCViewer_ViewModel.h"
+#include "OCCViewer_ViewPort3d.h"
+
+#include "SUIT_ViewManager.h"
+#include "QtxActionToolMgr.h"
+#include "QtxMultiAction.h"
// KERNEL includes
#include <Basics_OCCTVersion.hxx>
-// OCC Includes
-#include <Image_PixMap.hxx>
+// OCC includes
+#include <V3d_View.hxx>
// QT includes
#include <QImage>
+#include <QAction>
-/*! Concert QImage to OCCT pixmap*/
-Handle(Image_PixMap)
-imageToPixmap( const QImage& anImage )
+Handle(Image_PixMap) OCCViewer_Utilities::imageToPixmap( const QImage& anImage )
{
Handle(Image_PixMap) aPixmap = new Image_PixMap();
if ( !anImage.isNull() ) {
}
return aPixmap;
}
+
+void OCCViewer_Utilities::setViewer2DMode( OCCViewer_Viewer* theViewer,
+ const OCCViewer_ViewWindow::Mode2dType& theMode )
+{
+ OCCViewer_ViewFrame* aFrame = dynamic_cast<OCCViewer_ViewFrame*>
+ ( theViewer->getViewManager()->getActiveView() );
+ OCCViewer_ViewWindow* aView = aFrame ? aFrame->getView( OCCViewer_ViewFrame::MAIN_VIEW ) : 0;
+ if ( !aView )
+ return;
+
+ // set a view mode
+ aView->set2dMode( theMode );
+ bool is2dMode = theMode != OCCViewer_ViewWindow::No2dMode;
+
+ // enable/disable view actions
+ QList<int> aNo2dActions;
+ aNo2dActions << OCCViewer_ViewWindow::ChangeRotationPointId
+ << OCCViewer_ViewWindow::RotationId
+ << OCCViewer_ViewWindow::FrontId
+ << OCCViewer_ViewWindow::BackId
+ //<< OCCViewer_ViewWindow::TopId
+ << OCCViewer_ViewWindow::BottomId
+ << OCCViewer_ViewWindow::LeftId
+ << OCCViewer_ViewWindow::RightId
+ << OCCViewer_ViewWindow::AntiClockWiseId
+ << OCCViewer_ViewWindow::ClockWiseId
+ << OCCViewer_ViewWindow::ResetId;
+
+ QtxActionToolMgr* aToolMgr = aView->toolMgr();
+ QAction* anAction;
+ for ( int i = 0, aNb = aNo2dActions.size(); i < aNb; i++ ) {
+ anAction = aToolMgr->action( aNo2dActions[i] );
+ if ( anAction )
+ anAction->setEnabled( !is2dMode );
+ }
+ QAction* aTop = aToolMgr->action( OCCViewer_ViewWindow::TopId );
+ QtxMultiAction* aMulti = dynamic_cast<QtxMultiAction*>( aTop->parent() );
+ aMulti->setActiveAction( aTop );
+
+ // change view position
+ Handle(V3d_View) aView3d = aView->getViewPort()->getView();
+ if ( !aView3d.IsNull() ) {
+ switch ( theMode ) {
+ case OCCViewer_ViewWindow::XYPlane:
+ aView3d->SetProj (V3d_Zpos);
+ break;
+ case OCCViewer_ViewWindow::XZPlane:
+ aView3d->SetProj (V3d_Yneg);
+ break;
+ case OCCViewer_ViewWindow::YZPlane:
+ aView3d->SetProj (V3d_Xpos);
+ break;
+ }
+ }
+}