From: nds Date: Tue, 3 Dec 2013 06:39:24 +0000 (+0000) Subject: Remove OCCViewer_ViewWidget X-Git-Tag: BR_hydro_v_0_4~94 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=b6e2e1d6c59c665f28b5584d32779c694a7ba233;p=modules%2Fhydro.git Remove OCCViewer_ViewWidget --- diff --git a/src/HYDROCurveCreator/CMakeLists.txt b/src/HYDROCurveCreator/CMakeLists.txt index 1ef4282b..29ef282f 100644 --- a/src/HYDROCurveCreator/CMakeLists.txt +++ b/src/HYDROCurveCreator/CMakeLists.txt @@ -63,7 +63,6 @@ IF(SALOME_BUILD_GUI) # CurveCreator_UndoOptsDlg.h CurveCreator_Widget.h OCCViewer_Utilities.h - OCCViewer_ViewWidget.h ) ENDIF(SALOME_BUILD_GUI) @@ -111,7 +110,6 @@ IF(SALOME_BUILD_GUI) # CurveCreator_UndoOptsDlg.cxx CurveCreator_Widget.cxx OCCViewer_Utilities.cxx - OCCViewer_ViewWidget.cxx ) ENDIF(SALOME_BUILD_GUI) diff --git a/src/HYDROCurveCreator/CurveCreator_Widget.cxx b/src/HYDROCurveCreator/CurveCreator_Widget.cxx index 08a78d86..37169ef5 100644 --- a/src/HYDROCurveCreator/CurveCreator_Widget.cxx +++ b/src/HYDROCurveCreator/CurveCreator_Widget.cxx @@ -36,7 +36,6 @@ #include #include #include "OCCViewer_Utilities.h" -#include "OCCViewer_ViewWidget.h" #include #include @@ -83,7 +82,7 @@ CurveCreator_Widget::CurveCreator_Widget(QWidget* parent, Qt::WindowFlags fl) : QWidget(parent), myNewSectionEditor(NULL), myCurve(theCurve), mySection(0), myDragStarted( false ), myDragInteractionStyle( SUIT_ViewModel::STANDARD ), - myOCCViewer( 0 ), myOCCViewWidget( 0 ) + myOCCViewer( 0 ) { myNewSectionEditor = new CurveCreator_NewSectionDlg( this ); myNewSectionEditor->hide(); @@ -270,52 +269,6 @@ OCCViewer_Viewer* CurveCreator_Widget::getOCCViewer() return myOCCViewer; } -/** - * Set an OCC viewer - */ -void CurveCreator_Widget::setOCCViewWidget( OCCViewer_ViewWidget* theViewWidget ) -{ - if ( myOCCViewWidget == theViewWidget ) - return; - - if ( myOCCViewWidget ) { - disconnect( myOCCViewWidget, SIGNAL( mousePressed( QMouseEvent* ) ), - this, SLOT( onMousePress( QMouseEvent* ) ) ); - disconnect( myOCCViewWidget, SIGNAL( mouseReleased( QMouseEvent* ) ), - this, SLOT( onMouseRelease( QMouseEvent* ) ) ); - disconnect( myOCCViewWidget, SIGNAL( mouseMoving( QMouseEvent* ) ), - this, SLOT( onMouseMove( QMouseEvent* ) ) ); - //disconnect( myOCCViewWidget, SIGNAL( lastViewClosed( SUIT_ViewManager* ) ), - // this, SLOT( onLastViewClosed( SUIT_ViewManager* ) ) ); - - // restore normal mode in the viewer - OCCViewer_Utilities::setViewWidget2DMode( myOCCViewWidget, OCCViewer_ViewWidget::No2dMode ); - // all local contexts should be closed if the viewer is not more used - setLocalPointContext( false, true ); - } - - myOCCViewWidget = theViewWidget; - if ( myOCCViewWidget ) { - connect( myOCCViewWidget, SIGNAL( mousePressed( QMouseEvent* ) ), - this, SLOT( onMousePress( QMouseEvent* ) ) ); - connect( myOCCViewWidget, SIGNAL( mouseReleased( QMouseEvent* ) ), - this, SLOT( onMouseRelease( QMouseEvent* ) ) ); - connect( myOCCViewWidget, SIGNAL( mouseMoving( QMouseEvent* ) ), - this, SLOT( onMouseMove( QMouseEvent* ) ) ); - //connect( aViewManager, SIGNAL( lastViewClosed( SUIT_ViewManager* ) ), - // this, SLOT( onLastViewClosed( SUIT_ViewManager* ) ) ); - OCCViewer_Utilities::setViewWidget2DMode( myOCCViewWidget, OCCViewer_ViewWidget::XYPlane ); - } -} - -/** - * Returns current OCC viewer - */ -OCCViewer_ViewWidget* CurveCreator_Widget::getOCCViewWidget() -{ - return myOCCViewWidget; -} - /** * Returns OCC viewer context */ @@ -325,8 +278,6 @@ Handle(AIS_InteractiveContext) CurveCreator_Widget::getAISContext() OCCViewer_Viewer* aViewer = getOCCViewer(); if ( aViewer ) aContext = aViewer->getAISContext(); - else if ( myOCCViewWidget ) - aContext = myOCCViewWidget->getAISContext(); return aContext; } @@ -340,8 +291,6 @@ OCCViewer_ViewPort3d* CurveCreator_Widget::getViewPort() OCCViewer_Viewer* aViewer = getOCCViewer(); if ( aViewer ) aViewPort = ((OCCViewer_ViewWindow*)aViewer->getViewManager()->getActiveView())->getViewPort(); - else if ( myOCCViewWidget ) - aViewPort = myOCCViewWidget->getViewPort(); return aViewPort; } @@ -373,14 +322,6 @@ void CurveCreator_Widget::setObjectsSelected(const AIS_ListOfInteractive& theLis OCCViewer_Viewer* aViewer = getOCCViewer(); if ( aViewer ) aViewer->setObjectsSelected(theList); - else if ( myOCCViewWidget ) { - Handle(AIS_InteractiveContext) aContext = myOCCViewWidget->getAISContext(); - - AIS_ListIteratorOfListOfInteractive aIt; - for (aIt.Initialize(theList); aIt.More(); aIt.Next()) - aContext->AddOrRemoveSelected(aIt.Value(), false); - aContext->UpdateCurrentViewer(); - } } //======================================================================= diff --git a/src/HYDROCurveCreator/CurveCreator_Widget.h b/src/HYDROCurveCreator/CurveCreator_Widget.h index 7d8d1ee4..0e6e51e8 100644 --- a/src/HYDROCurveCreator/CurveCreator_Widget.h +++ b/src/HYDROCurveCreator/CurveCreator_Widget.h @@ -37,7 +37,6 @@ class OCCViewer_Viewer; class OCCViewer_ViewPort3d; -class OCCViewer_ViewWidget; class AIS_ListOfInteractive; @@ -59,7 +58,6 @@ public: // OCC viewer manipulation void setOCCViewer( OCCViewer_Viewer* theViewer ); - void setOCCViewWidget( OCCViewer_ViewWidget* theViewWidget ); Handle(AIS_InteractiveContext) getAISContext(); OCCViewer_ViewPort3d* getViewPort(); @@ -154,7 +152,6 @@ protected: private: OCCViewer_Viewer* getOCCViewer(); - OCCViewer_ViewWidget* getOCCViewWidget(); QAction* createAction( ActionId theId, const QString& theName, const QPixmap& theImage, const QString& theToolTip, const QKeySequence& theShortcut ); @@ -209,7 +206,6 @@ private: QTableWidget* myLocalPointView; CurveCreator_NewSectionDlg* myNewSectionEditor; OCCViewer_Viewer* myOCCViewer; - OCCViewer_ViewWidget* myOCCViewWidget; int mySection; int myPointNum; bool myDragStarted; diff --git a/src/HYDROCurveCreator/OCCViewer_Utilities.cxx b/src/HYDROCurveCreator/OCCViewer_Utilities.cxx index c683c014..425179f9 100644 --- a/src/HYDROCurveCreator/OCCViewer_Utilities.cxx +++ b/src/HYDROCurveCreator/OCCViewer_Utilities.cxx @@ -1,6 +1,5 @@ #include "OCCViewer_Utilities.h" -#include "OCCViewer_ViewWidget.h" #include #include @@ -58,44 +57,3 @@ void OCCViewer_Utilities::setViewer2DMode( OCCViewer_Viewer* theViewer, break; } } - -void OCCViewer_Utilities::setViewWidget2DMode( OCCViewer_ViewWidget* theViewWidget, - const OCCViewer_ViewWidget::Mode2dType& theMode ) -{ - if ( !theViewWidget ) - return; - - // set a view mode - theViewWidget->set2dMode( theMode ); - bool is2dMode = theMode != OCCViewer_ViewWindow::No2dMode; - - // enable/disable view actions - QList aNo2dActions; - aNo2dActions << OCCViewer_ViewWidget::RotationId - << OCCViewer_ViewWidget::FrontId - << OCCViewer_ViewWidget::BackId - << OCCViewer_ViewWidget::TopId - << OCCViewer_ViewWidget::BottomId - << OCCViewer_ViewWidget::LeftId - << OCCViewer_ViewWidget::RightId; - - QAction* anAction; - for ( int i = 0, aNb = aNo2dActions.size(); i < aNb; i++ ) { - anAction = theViewWidget->action( aNo2dActions[i] ); - if ( anAction ) - anAction->setVisible( !is2dMode ); - } - - // change view position - switch ( theMode ) { - case OCCViewer_ViewWindow::XYPlane: - theViewWidget->onTopView(); - break; - case OCCViewer_ViewWindow::XZPlane: - theViewWidget->onLeftView(); - break; - case OCCViewer_ViewWindow::YZPlane: - theViewWidget->onFrontView(); - break; - } -} diff --git a/src/HYDROCurveCreator/OCCViewer_Utilities.h b/src/HYDROCurveCreator/OCCViewer_Utilities.h index ce83e2a3..c89eb45f 100644 --- a/src/HYDROCurveCreator/OCCViewer_Utilities.h +++ b/src/HYDROCurveCreator/OCCViewer_Utilities.h @@ -4,7 +4,6 @@ #include "CurveCreator_Macro.hxx" #include -#include "OCCViewer_ViewWidget.h" class OCCViewer_Viewer; @@ -24,14 +23,6 @@ public: static void setViewer2DMode( OCCViewer_Viewer* theViewer, const OCCViewer_ViewWindow::Mode2dType& theMode ); - - /*! - * Set 2D mode for the view widget. Hide or show 3D actions. - * \param theViewWidget an OCC view widget - * \param theMode OCC view window mode - */ - static void setViewWidget2DMode( OCCViewer_ViewWidget* theViewWidget, - const OCCViewer_ViewWidget::Mode2dType& theMode ); }; #endif diff --git a/src/HYDROCurveCreator/OCCViewer_ViewWidget.cxx b/src/HYDROCurveCreator/OCCViewer_ViewWidget.cxx deleted file mode 100644 index ac9fd07c..00000000 --- a/src/HYDROCurveCreator/OCCViewer_ViewWidget.cxx +++ /dev/null @@ -1,853 +0,0 @@ - -#include "OCCViewer_ViewWidget.h" - -#include -#include -#include -#include -#include -#include -#include -#include - -#include - -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include - -const int SPACING_SIZE = 5; -const int Z_FIT_ALL_SIZE = 1000; - -const char* imageZoomCursor[] = { -"32 32 3 1", -". c None", -"a c #000000", -"# c #ffffff", -"................................", -"................................", -".#######........................", -"..aaaaaaa.......................", -"................................", -".............#####..............", -"...........##.aaaa##............", -"..........#.aa.....a#...........", -".........#.a.........#..........", -".........#a..........#a.........", -"........#.a...........#.........", -"........#a............#a........", -"........#a............#a........", -"........#a............#a........", -"........#a............#a........", -".........#...........#.a........", -".........#a..........#a.........", -".........##.........#.a.........", -"........#####.....##.a..........", -".......###aaa#####.aa...........", -"......###aa...aaaaa.......#.....", -".....###aa................#a....", -"....###aa.................#a....", -"...###aa...............#######..", -"....#aa.................aa#aaaa.", -".....a....................#a....", -"..........................#a....", -"...........................a....", -"................................", -"................................", -"................................", -"................................"}; - -const char* imageRotateCursor[] = { -"32 32 3 1", -". c None", -"a c #000000", -"# c #ffffff", -"................................", -"................................", -"................................", -"................................", -"........#.......................", -".......#.a......................", -"......#######...................", -".......#aaaaa#####..............", -"........#..##.a#aa##........##..", -".........a#.aa..#..a#.....##.aa.", -".........#.a.....#...#..##.aa...", -".........#a.......#..###.aa.....", -"........#.a.......#a..#aa.......", -"........#a.........#..#a........", -"........#a.........#a.#a........", -"........#a.........#a.#a........", -"........#a.........#a.#a........", -".........#.........#a#.a........", -"........##a........#a#a.........", -"......##.a#.......#.#.a.........", -"....##.aa..##.....##.a..........", -"..##.aa.....a#####.aa...........", -"...aa.........aaa#a.............", -"................#.a.............", -"...............#.a..............", -"..............#.a...............", -"...............a................", -"................................", -"................................", -"................................", -"................................", -"................................"}; - -const char* imageCrossCursor[] = { - "32 32 3 1", - ". c None", - "a c #000000", - "# c #ffffff", - "................................", - "................................", - "................................", - "................................", - "................................", - "................................", - "................................", - "...............#................", - "...............#a...............", - "...............#a...............", - "...............#a...............", - "...............#a...............", - "...............#a...............", - "...............#a...............", - "...............#a...............", - ".......#################........", - "........aaaaaaa#aaaaaaaaa.......", - "...............#a...............", - "...............#a...............", - "...............#a...............", - "...............#a...............", - "...............#a...............", - "...............#a...............", - "...............#a...............", - "................a...............", - "................................", - "................................", - "................................", - "................................", - "................................", - "................................", - "................................"}; - -// ---------------- OCC view widget -------- -OCCViewer_ViewWidget::OCCViewer_ViewWidget(QWidget* parent, const bool isUseMultiAction) - : QFrame(parent), myShowTrihedron(true), myUseMultiAction(isUseMultiAction) -{ - setObjectName("OCC_view_widget"); - mySelectedPoint = gp_Pnt(0.,0.,0.); - setFrameStyle(QFrame::NoFrame); - - QGridLayout* anAnalLay = new QGridLayout(this); - anAnalLay->setMargin(0); - anAnalLay->setSpacing(SPACING_SIZE); - - QWidget* aBtnBox = new QWidget(this); - QHBoxLayout* aBtnLay = new QHBoxLayout(aBtnBox); - aBtnLay->setMargin(0); - aBtnLay->setSpacing(SPACING_SIZE); - - myToolBar = new QToolBar(aBtnBox); - aBtnLay->addWidget(myToolBar); - if (myUseMultiAction) { - myZoomBtns = new QtxMultiAction(aBtnBox); - myZoomBtns->setObjectName("zoomBtn"); - myToolBar->addAction(myZoomBtns); - myPanBtns = new QtxMultiAction(aBtnBox); - myPanBtns->setObjectName("panBtn"); - myToolBar->addAction(myPanBtns); - myProjBtns = new QtxMultiAction(aBtnBox); - myProjBtns->setObjectName("projectionBtn"); - myToolBar->addAction(myProjBtns); - } - // Rotation - aBtnLay->addStretch(1); - anAnalLay->addWidget(aBtnBox, 0, 0, 1, 2); - - myV3dViewer = OCCViewer_VService::CreateViewer((short*) "Viewer3d", "", "", 1000., V3d_XposYnegZpos, true, true); - //myV3dViewer->Init(); // to avoid creation of the useless perspective view (see OCCT issue 0024267) - -#if OCC_VERSION_LARGE <= 0x06060000 // Porting to OCCT higher 6.6.0 version - myV3dCollector = OCCViewer_VService::CreateViewer((short*) "Collector3d", "", "", 1000., V3d_XposYnegZpos, true, true); - myV3dCollector->Init(); -#endif - - // init selector -#if OCC_VERSION_LARGE <= 0x06060000 - myAISContext = new AIS_InteractiveContext( myV3dViewer, myV3dCollector ); -#else - myAISContext = new AIS_InteractiveContext( myV3dViewer ); -#endif - myAISContext->SelectionColor(Quantity_NOC_WHITE); - myAISContext->IsoOnPlane(true); - - myViewPort = new OCCViewer_ViewPort3d(this, myV3dViewer, V3d_ORTHOGRAPHIC); - myViewPort->setBackgroundColor(Qt::black); - myViewPort->setMinimumHeight(300); - myViewPort->installEventFilter(this); - anAnalLay->addWidget(myViewPort, 1, 0, 1, 2); - - Handle(Geom_Axis2Placement) anAxis = new Geom_Axis2Placement(gp::XOY()); - myTrihedron = new AIS_Trihedron(anAxis); - myTrihedron->SetInfiniteState(Standard_True); - - Quantity_Color Col(193/255., 205/255., 193/255., Quantity_TOC_RGB); - myTrihedron->SetArrowColor(Col.Name()); - myTrihedron->SetSize(100); - Handle(AIS_Drawer) drawer = myTrihedron->Attributes(); - if (drawer->HasDatumAspect()) { - Handle(Prs3d_DatumAspect) daspect = drawer->DatumAspect(); - daspect->FirstAxisAspect()->SetColor(Quantity_Color(1.0, 0.0, 0.0, Quantity_TOC_RGB)); - daspect->SecondAxisAspect()->SetColor(Quantity_Color(0.0, 1.0, 0.0, Quantity_TOC_RGB)); - daspect->ThirdAxisAspect()->SetColor(Quantity_Color(0.0, 0.0, 1.0, Quantity_TOC_RGB)); - } - myAISContext->Display(myTrihedron); - myAISContext->Deactivate(myTrihedron); - - myTrihedron->SetTransformPersistence(Graphic3d_TMF_TriedronPers, gp_Pnt(-1, -1, 200)); - myTrihedron->SetSize(100); - - createActions(); - myButsMap[TrihId]->setChecked(false); - onTrihChanged(); - - my2dMode = No2dMode; -} - -OCCViewer_ViewWidget::~OCCViewer_ViewWidget() -{ - delete myViewPort; - - myAISContext.Nullify(); - myV3dViewer.Nullify(); - #if OCC_VERSION_LARGE <= 0x06060000 - myV3dCollector.Nullify(); - #endif -} - -OCCViewer_ViewPort3d* OCCViewer_ViewWidget::getViewPort() -{ - return myViewPort; -} - -void OCCViewer_ViewWidget::reset() -{ - clearViewer(); - myOperation = NOTHING; - myCurrPointType = OCCViewer_ViewWindow::GRAVITY; -} - -void OCCViewer_ViewWidget::Display(const TopoDS_Shape shape, const bool theShaded, - const QColor& shapeColor) -{ - clearViewer(false); - if (shape.IsNull()) { - myAISContext->UpdateCurrentViewer(); - return; - } - - Handle(AIS_InteractiveObject) io = new AIS_Shape(shape); - io->UnsetSelectionMode(); - io->UnsetHilightMode(); - - Quantity_Color aColor(shapeColor.red()/255., shapeColor.green()/255., - shapeColor.blue()/255., Quantity_TOC_RGB); - io->SetColor(aColor); - - myAISContext->Display(io, false); - if (theShaded) { - myAISContext->SetDisplayMode(io, AIS_Shaded, false); - myAISContext->SetMaterial(io, Graphic3d_NOM_PLASTIC, false); - } - else - myAISContext->SetDisplayMode(io, AIS_WireFrame, false); - viewerFitAll(false); - myAISContext->UpdateCurrentViewer(); -} - -void OCCViewer_ViewWidget::createActions() -{ - SUIT_ResourceMgr* aResMgr = SUIT_Session::session()->resourceMgr(); - QtxAction* aAction; - - // FitAll - aAction = new QtxAction(tr("MNU_FITALL"), aResMgr->loadPixmap("OCCViewer", tr("ICON_OCCVIEWER_VIEW_FITALL")), - tr("MNU_FITALL"), 0, this); - aAction->setStatusTip(tr("DSC_FITALL")); - connect(aAction, SIGNAL(activated()), this, SLOT(onActivated())); - myButsMap[ FitAllId ] = aAction; - - // FitRect - aAction = new QtxAction(tr("MNU_FITRECT"), aResMgr->loadPixmap("OCCViewer", tr("ICON_OCCVIEWER_VIEW_FITAREA")), - tr("MNU_FITRECT"), 0, this); - aAction->setStatusTip(tr("DSC_FITRECT")); - connect(aAction, SIGNAL(activated()), this, SLOT(onActivated())); - myButsMap[ FitRectId ] = aAction; - - // Zoom - aAction = new QtxAction(tr("MNU_ZOOM_VIEW"), aResMgr->loadPixmap("OCCViewer", tr("ICON_OCCVIEWER_VIEW_ZOOM")), - tr("MNU_ZOOM_VIEW"), 0, this); - aAction->setStatusTip(tr("DSC_ZOOM_VIEW")); - connect(aAction, SIGNAL(activated()), this, SLOT(onActivated())); - myButsMap[ ZoomId ] = aAction; - - // Panning - aAction = new QtxAction(tr("MNU_PAN_VIEW"), aResMgr->loadPixmap("OCCViewer", tr("ICON_OCCVIEWER_VIEW_PAN")), - tr("MNU_PAN_VIEW"), 0, this); - aAction->setStatusTip(tr("DSC_PAN_VIEW")); - connect(aAction, SIGNAL(activated()), this, SLOT(onActivated())); - myButsMap[ PanId ] = aAction; - - // Global Panning - aAction = new QtxAction(tr("MNU_GLOBALPAN_VIEW"), aResMgr->loadPixmap("OCCViewer", tr("ICON_OCCVIEWER_VIEW_GLOBALPAN")), - tr("MNU_GLOBALPAN_VIEW"), 0, this); - aAction->setStatusTip(tr("DSC_GLOBALPAN_VIEW")); - connect(aAction, SIGNAL(activated()), this, SLOT(onActivated())); - myButsMap[ GlobalPanId ] = aAction; - - // Projections - aAction = new QtxAction(tr("MNU_FRONT_VIEW"), aResMgr->loadPixmap("OCCViewer", tr("ICON_OCCVIEWER_VIEW_FRONT")), - tr("MNU_FRONT_VIEW"), 0, this); - aAction->setStatusTip(tr("DSC_FRONT_VIEW")); - connect(aAction, SIGNAL(activated()), this, SLOT(onFrontView())); - myButsMap[ FrontId ] = aAction; - - aAction = new QtxAction(tr("MNU_BACK_VIEW"), aResMgr->loadPixmap("OCCViewer", tr("ICON_OCCVIEWER_VIEW_BACK")), - tr("MNU_BACK_VIEW"), 0, this); - aAction->setStatusTip(tr("DSC_BACK_VIEW")); - connect(aAction, SIGNAL(activated()), this, SLOT(onBackView())); - myButsMap[ BackId ] = aAction; - - aAction = new QtxAction(tr("MNU_TOP_VIEW"), aResMgr->loadPixmap("OCCViewer", tr("ICON_OCCVIEWER_VIEW_TOP")), - tr("MNU_TOP_VIEW"), 0, this); - aAction->setStatusTip(tr("DSC_TOP_VIEW")); - connect(aAction, SIGNAL(activated()), this, SLOT(onTopView())); - myButsMap[ TopId ] = aAction; - - aAction = new QtxAction(tr("MNU_BOTTOM_VIEW"), aResMgr->loadPixmap("OCCViewer", tr("ICON_OCCVIEWER_VIEW_BOTTOM")), - tr("MNU_BOTTOM_VIEW"), 0, this); - aAction->setStatusTip(tr("DSC_BOTTOM_VIEW")); - connect(aAction, SIGNAL(activated()), this, SLOT(onBottomView())); - myButsMap[ BottomId ] = aAction; - - aAction = new QtxAction(tr("MNU_LEFT_VIEW"), aResMgr->loadPixmap("OCCViewer", tr("ICON_OCCVIEWER_VIEW_LEFT")), - tr("MNU_LEFT_VIEW"), 0, this); - aAction->setStatusTip(tr("DSC_LEFT_VIEW")); - connect(aAction, SIGNAL(activated()), this, SLOT(onLeftView())); - myButsMap[ LeftId ] = aAction; - - aAction = new QtxAction(tr("MNU_RIGHT_VIEW"), aResMgr->loadPixmap("OCCViewer", tr("ICON_OCCVIEWER_VIEW_RIGHT")), - tr("MNU_RIGHT_VIEW"), 0, this); - aAction->setStatusTip(tr("DSC_RIGHT_VIEW")); - connect(aAction, SIGNAL(activated()), this, SLOT(onRightView())); - myButsMap[ RightId ] = aAction; - - aAction = new QtxAction(tr("MNU_ROTATE_VIEW"), aResMgr->loadPixmap("OCCViewer", tr("ICON_OCCVIEWER_VIEW_ROTATE")), - tr("MNU_ROTATE_VIEW"), 0, this); - aAction->setStatusTip(tr("DSC_ROTATE_VIEW")); - connect(aAction, SIGNAL(triggered()), this, SLOT(onActivated())); - myToolBar->addAction(aAction); - myButsMap[ RotationId ] = aAction; - - aAction = new QtxAction(tr("MNU_SHOW_TRIHEDRE"), aResMgr->loadPixmap("OCCViewer", tr("ICON_OCCVIEWER_VIEW_TRIHEDRON")), - tr("MNU_SHOW_TRIHEDRE"), 0, this); - aAction->setStatusTip(tr("DSC_SHOW_TRIHEDRE")); - aAction->setCheckable(true); - connect(aAction, SIGNAL(triggered()), this, SLOT(onTrihChanged())); - myToolBar->addAction(aAction); - myButsMap[ TrihId ] = aAction; - - if (myUseMultiAction) { - myZoomBtns->insertAction(myButsMap[ FitAllId ]); - myZoomBtns->insertAction(myButsMap[ FitRectId ]); - myZoomBtns->insertAction(myButsMap[ ZoomId ]); - - myPanBtns->insertAction(myButsMap[ PanId ]); - myPanBtns->insertAction(myButsMap[ GlobalPanId ]); - - myProjBtns->insertAction(myButsMap[ FrontId ]); - myProjBtns->insertAction(myButsMap[ BackId ]); - myProjBtns->insertAction(myButsMap[ TopId ]); - myProjBtns->insertAction(myButsMap[ BottomId ]); - myProjBtns->insertAction(myButsMap[ LeftId ]); - myProjBtns->insertAction(myButsMap[ RightId ]); - } - else { - myToolBar->addAction(myButsMap[ FitAllId ]); - myToolBar->addAction(myButsMap[ FitRectId ]); - myToolBar->addAction(myButsMap[ ZoomId ]); - - myToolBar->addAction(myButsMap[ PanId ]); - myToolBar->addAction(myButsMap[ GlobalPanId ]); - - myToolBar->addAction(myButsMap[ FrontId ]); - myToolBar->addAction(myButsMap[ BackId ]); - myToolBar->addAction(myButsMap[ TopId ]); - myToolBar->addAction(myButsMap[ BottomId ]); - myToolBar->addAction(myButsMap[ LeftId ]); - myToolBar->addAction(myButsMap[ RightId ]); - } -} - -/*! - Custom event handler -*/ -bool OCCViewer_ViewWidget::eventFilter(QObject* watched, QEvent* e) -{ - if (e->type() == QEvent::ContextMenu) - return true; - - bool aRes = false; - int aReturn = -1; - if (watched == myViewPort) { - int aType = e->type(); - switch(aType) { - case QEvent::MouseButtonPress: - vpMousePressEvent((QMouseEvent*) e); - aRes = true; - aReturn = 1; - break; - case QEvent::MouseButtonRelease: - vpMouseReleaseEvent((QMouseEvent*) e); - aRes = true; - aReturn = 1; - break; - case QEvent::MouseMove: - vpMouseMoveEvent((QMouseEvent*) e); - aRes = true; - aReturn = 1; - break; - case QEvent::Wheel: - { - QWheelEvent* aEvent = (QWheelEvent*) e; - double aDelta = aEvent->delta(); - double aScale = (aDelta < 0) ? 100./(-aDelta) : aDelta/100.; - myViewPort->getView()->SetZoom(aScale); - } - aRes = true; - aReturn = 1; - break; - default: - break; - } - } - if (aReturn == -1) - aRes = QFrame::eventFilter(watched, e); - - if (watched == myViewPort && !myViewPort->getView().IsNull()) { - if (e->type() == QEvent::MouseButtonRelease) - viewZFitAll(); - } - - return aRes; -} - -void OCCViewer_ViewWidget::set2dMode(OCCViewer_ViewWidget::Mode2dType theType) -{ - my2dMode = theType; -} - -QAction* OCCViewer_ViewWidget::action( const ButtonsType& theId ) -{ - return myButsMap.contains( theId ) ? myButsMap[theId] : 0; -} - -void OCCViewer_ViewWidget::onActivated() -{ - if(!sender() || !sender()->inherits("QtxAction")) - return; - QtxAction* anAction = (QtxAction*)sender(); - ActionsMap::const_iterator anIt = myButsMap.begin(), last = myButsMap.end(); - int aCurAction = -1; - for (; anIt != last && aCurAction == -1; anIt++) { - if (anIt.value() != anAction) - continue; - aCurAction = anIt.key(); - } - switch(aCurAction) { - case RotationId: activateRotation(); return; - case FitAllId: viewerFitAll(); break; - case FitRectId: activateWindowFit(); break; - case ZoomId: activateZoom(); break; - case PanId: activatePanning(); break; - case GlobalPanId: activateGlPanning(); break; - } - viewZFitAll(); -} - -void OCCViewer_ViewWidget::viewerFitAll(const bool theUpdate) -{ - myViewPort->fitAll(false, true, theUpdate); - viewZFitAll(); -} - -void OCCViewer_ViewWidget::onTrihChanged() -{ - QtxAction* anAction = myButsMap[TrihId]; - myShowTrihedron = anAction->isChecked(); - if (myShowTrihedron) { - myAISContext->Display(myTrihedron); - myAISContext->Deactivate(myTrihedron); - } - else - myAISContext->Erase(myTrihedron); -} -/*! - Processes transformation "front view" -*/ -void OCCViewer_ViewWidget::onFrontView() -{ - Handle(V3d_View) aView3d = myViewPort->getView(); - if (!aView3d.IsNull()) aView3d->SetProj (V3d_Xpos); - viewerFitAll(); -} - -/*! - Processes transformation "back view" -*/ -void OCCViewer_ViewWidget::onBackView() -{ - Handle(V3d_View) aView3d = myViewPort->getView(); - if (!aView3d.IsNull()) aView3d->SetProj (V3d_Xneg); - viewerFitAll(); -} - -/*! - Processes transformation "top view" -*/ -void OCCViewer_ViewWidget::onTopView() -{ - Handle(V3d_View) aView3d = myViewPort->getView(); - if (!aView3d.IsNull()) aView3d->SetProj (V3d_Zpos); - viewerFitAll(); -} - -/*! - Processes transformation "bottom view" -*/ -void OCCViewer_ViewWidget::onBottomView() -{ - Handle(V3d_View) aView3d = myViewPort->getView(); - if (!aView3d.IsNull()) aView3d->SetProj (V3d_Zneg); - viewerFitAll(); -} - -/*! - Processes transformation "left view" -*/ -void OCCViewer_ViewWidget::onLeftView() -{ - Handle(V3d_View) aView3d = myViewPort->getView(); - if (!aView3d.IsNull()) aView3d->SetProj (V3d_Yneg); - viewerFitAll(); -} - -/*! - Processes transformation "right view" -*/ -void OCCViewer_ViewWidget::onRightView() -{ - Handle(V3d_View) aView3d = myViewPort->getView(); - if (!aView3d.IsNull()) aView3d->SetProj (V3d_Ypos); - viewerFitAll(); -} - - -void OCCViewer_ViewWidget::viewZFitAll() -{ - myViewPort->getView()->ZFitAll(Z_FIT_ALL_SIZE); -} - -void OCCViewer_ViewWidget::activateZoom() -{ - if (!transformRequested() && !myCursorIsHand) - myCursor = cursor(); /* save old cursor */ - - if (myOperation != ZOOMVIEW) { - QPixmap zoomPixmap (imageZoomCursor); - QCursor zoomCursor (zoomPixmap); - if(setTransformRequested (ZOOMVIEW)) - setCursor(zoomCursor); - } -} - -void OCCViewer_ViewWidget::activateWindowFit() -{ - if (!transformRequested() && !myCursorIsHand) - myCursor = cursor(); /* save old cursor */ - - if (myOperation != WINDOWFIT) { - QCursor handCursor (Qt::PointingHandCursor); - if(setTransformRequested (WINDOWFIT)) - setCursor (handCursor); - myCursorIsHand = true; - } -} - -void OCCViewer_ViewWidget::activateRotation() -{ - if (!transformRequested() && !myCursorIsHand) - myCursor = cursor(); // save old cursor - - if (myOperation != ROTATE) { - QPixmap rotatePixmap (imageRotateCursor); - QCursor rotCursor (rotatePixmap); - if(setTransformRequested (ROTATE)) - setCursor(rotCursor); - } -} - -void OCCViewer_ViewWidget::activatePanning() -{ - if (!transformRequested() && !myCursorIsHand) - myCursor = cursor(); // save old cursor - - if (myOperation != PANVIEW) { - QCursor panCursor (Qt::SizeAllCursor); - if(setTransformRequested (PANVIEW)) - setCursor(panCursor); - } -} - -void OCCViewer_ViewWidget::activateGlPanning() -{ - Handle(V3d_View) aView3d = myViewPort->getView(); - if (!aView3d.IsNull()) { - QPixmap globalPanPixmap (imageCrossCursor); - QCursor glPanCursor (globalPanPixmap); - myCurScale = aView3d->Scale(); - aView3d->FitAll(0.01, false); - myCursor = cursor(); // save old cursor - myViewPort->fitAll(); // fits view before selecting a new scene center - if(setTransformRequested(PANGLOBAL)) - setCursor(glPanCursor); - } -} - -void OCCViewer_ViewWidget::vpMousePressEvent(QMouseEvent* theEvent) -{ - myStartX = theEvent->x(); - myStartY = theEvent->y(); - switch (myOperation) { - case WINDOWFIT: - case PANGLOBAL: - case ZOOMVIEW: - case PANVIEW: - break; - case ROTATE: - if (theEvent->button() == Qt::LeftButton) { - myViewPort->startRotation(myStartX, myStartY, myCurrPointType, mySelectedPoint); - } - break; - default: - /* Try to activate a transformation */ - switch (getButtonState(theEvent)) { - case ZOOMVIEW: - activateZoom(); - break; - case PANVIEW: - activatePanning(); - break; - case ROTATE: - activateRotation(); - //myViewPort->startRotation(myStartX, myStartY);//, 0, mySelectedPoint); - break; - default: - emit mousePressed(theEvent); - break; - } - } -} -OCCViewer_ViewWidget::OperationType OCCViewer_ViewWidget::getButtonState(QMouseEvent* theEvent) -{ - OperationType aOp = NOTHING; - if((theEvent->modifiers() == SUIT_ViewModel::myStateMap[SUIT_ViewModel::STANDARD][SUIT_ViewModel::ZOOM]) && - (theEvent->button() == SUIT_ViewModel::myButtonMap[SUIT_ViewModel::STANDARD][SUIT_ViewModel::ZOOM])) - aOp = ZOOMVIEW; - else if((theEvent->modifiers() == SUIT_ViewModel::myStateMap[SUIT_ViewModel::STANDARD][SUIT_ViewModel::PAN]) && - (theEvent->button() == SUIT_ViewModel::myButtonMap[SUIT_ViewModel::STANDARD][SUIT_ViewModel::PAN])) - aOp = PANVIEW; - else if((theEvent->modifiers() == SUIT_ViewModel::myStateMap[SUIT_ViewModel::STANDARD][SUIT_ViewModel::ROTATE]) && - (theEvent->button() == SUIT_ViewModel::myButtonMap[SUIT_ViewModel::STANDARD][SUIT_ViewModel::ROTATE]) && - (my2dMode == No2dMode)) - aOp = ROTATE; - - return aOp; -} - -void OCCViewer_ViewWidget::vpMouseReleaseEvent(QMouseEvent* theEvent) -{ - switch (myOperation) { - case NOTHING: - emit mouseReleased(theEvent); - break; - case ROTATE: - myViewPort->endRotation(); - resetState(); - break; - case PANVIEW: - case ZOOMVIEW: - resetState(); - break; - - case PANGLOBAL: - if (theEvent->button() == Qt::LeftButton) { - myViewPort->setCenter(theEvent->x(), theEvent->y()); - myViewPort->getView()->SetScale(myCurScale); - resetState(); - } - break; - - case WINDOWFIT: - if (theEvent->modifiers() == Qt::LeftButton) { - myCurrX = theEvent->x(); - myCurrY = theEvent->y(); - QRect rect = SUIT_Tools::makeRect(myStartX, myStartY, myCurrX, myCurrY); - if (!rect.isEmpty()) myViewPort->fitRect(rect); - resetState(); - } - break; - } - - // NOTE: viewer 3D detects a rectangle of selection using this event - // so we must emit it BEFORE resetting the selection rectangle - - if (theEvent->button() == Qt::LeftButton && myDrawRect) { - myDrawRect = false; - drawRect(); - resetState(); - myViewPort->update(); - } -} - -void OCCViewer_ViewWidget::vpMouseMoveEvent(QMouseEvent* theEvent) -{ - myCurrX = theEvent->x(); - myCurrY = theEvent->y(); - switch (myOperation) { - case ROTATE: - myViewPort->rotate(myCurrX, myCurrY, myCurrPointType, mySelectedPoint); - break; - case ZOOMVIEW: - myViewPort->zoom(myStartX, myStartY, myCurrX, myCurrY); - myStartX = myCurrX; - myStartY = myCurrY; - break; - - case PANVIEW: - myViewPort->pan(myCurrX - myStartX, myStartY - myCurrY); - myStartX = myCurrX; - myStartY = myCurrY; - break; - - case PANGLOBAL: - break; - - default: { - int aState = theEvent->modifiers(); - if (aState == Qt::LeftButton || - aState == ((int) Qt::LeftButton | (int) Qt::ShiftModifier)) { - myDrawRect = true; - if (myDrawRect) { - drawRect(); - if (!myCursorIsHand) { // we are going to sketch a rectangle - QCursor handCursor (Qt::PointingHandCursor); - myCursorIsHand = true; - myCursor = cursor(); - setCursor(handCursor); - } - } - } - else - emit mouseMoving( theEvent ); - } - } -} - -/*! - Sets the viewport to its initial state - (no transformations in process etc.) -*/ -void OCCViewer_ViewWidget::resetState() -{ - myDrawRect = false; - myRect.setLeft(2); - myRect.setRight(0); - - /* make rectangle empty (left > right) */ - if (transformRequested() || myCursorIsHand) - setCursor(myCursor); - myCursorIsHand = false; - - setTransformRequested(NOTHING); -} - -void OCCViewer_ViewWidget::drawRect() -{ - QPainter aPainter(myViewPort); - aPainter.setCompositionMode(QPainter::CompositionMode_Xor); - aPainter.setPen(Qt::white); - QRect aRect = SUIT_Tools::makeRect(myStartX, myStartY, myCurrX, myCurrY); - if (!myRect.isEmpty()) - aPainter.drawRect(myRect); - aPainter.drawRect(aRect); - myRect = aRect; -} - -bool OCCViewer_ViewWidget::setTransformRequested (OperationType op) -{ - myOperation = op; - myViewPort->setMouseTracking(myOperation == NOTHING); - return true; -} - -void OCCViewer_ViewWidget::clearViewer(const bool theUpdate) -{ - // check if trihedron is displayed - Standard_Boolean isTrihedronDisplayed = myAISContext->IsDisplayed(myTrihedron); - - // get objects to be erased (all currently displayed objects) - AIS_ListOfInteractive aList; - myAISContext->DisplayedObjects(aList); - AIS_ListIteratorOfListOfInteractive anIter(aList); - for (; anIter.More(); anIter.Next()) { - if (isTrihedronDisplayed && anIter.Value()->DynamicType() == STANDARD_TYPE(AIS_Trihedron)) - continue; - // erase an object - Handle(AIS_InteractiveObject) anIO = anIter.Value(); -#if OCC_VERSION_LARGE <= 0x06060000 - myAISContext->Erase(anIO, false, false); -#else - myAISContext->Erase(anIO, false); -#endif - } - - // display trihedron if necessary - if (isTrihedronDisplayed) - myAISContext->Display(myTrihedron, theUpdate); - else if (theUpdate) - myV3dViewer->Update(); - if (theUpdate) - myAISContext->UpdateCurrentViewer(); -} diff --git a/src/HYDROCurveCreator/OCCViewer_ViewWidget.h b/src/HYDROCurveCreator/OCCViewer_ViewWidget.h deleted file mode 100644 index cbfe37e7..00000000 --- a/src/HYDROCurveCreator/OCCViewer_ViewWidget.h +++ /dev/null @@ -1,132 +0,0 @@ -#ifndef OCCVIEWER_VIEWWIDGET_H -#define OCCVIEWER_VIEWWIDGET_H - -#include "CurveCreator_Macro.hxx" -#include - -#include -#include -#include - -#include -#include -#include -#include - -#include -#include -#include - -class OCCViewer_ViewPort3d; -class QPushButton; -class QToolBar; - -class Handle(V3d_Viewer); -class Handle(AIS_InteractiveContext); - -#ifdef WIN32 -#pragma warning ( disable:4251 ) -#endif - -// ---------------- OCC view widget -------- -class CURVECREATOR_EXPORT OCCViewer_ViewWidget : public QFrame -{ - Q_OBJECT - -public: - typedef enum { FitAllId, FitRectId, ZoomId, PanId, GlobalPanId, RotationId, TrihId, - FrontId, BackId, TopId, BottomId, LeftId, RightId, None } ButtonsType; - - OCCViewer_ViewWidget(QWidget* parent, const bool isUseMultiAction = true); - ~OCCViewer_ViewWidget(); - - OCCViewer_ViewPort3d* getViewPort(); - Handle(AIS_InteractiveContext) getAISContext() { return myAISContext; } - - bool eventFilter(QObject* watched, QEvent* e); - - void reset(); - void Display(const TopoDS_Shape shape, const bool theShaded, - const QColor& shapeColor); - - enum Mode2dType { No2dMode, XYPlane, XZPlane, YZPlane}; - - void set2dMode( Mode2dType ); - Mode2dType get2dMode() const { return my2dMode; } - - QAction* action( const ButtonsType& theId ); - -public slots: - void onActivated(); - void onTrihChanged(); - void onFrontView(); - void onBackView(); - void onTopView(); - void onBottomView(); - void onLeftView(); - void onRightView(); - -signals: - void mouseMoving( QMouseEvent* theEvent ); - void mousePressed( QMouseEvent* theEvent ); - void mouseReleased( QMouseEvent* theEvent ); - -private: - enum OperationType{ NOTHING, FITALLVIEW, WINDOWFIT, ZOOMVIEW, PANVIEW, PANGLOBAL, - ROTATE }; - - void createActions(); - void viewZFitAll(); - void activateZoom(); - void activateWindowFit(); - void activateRotation(); - void activatePanning(); - void activateGlPanning(); - OperationType getButtonState(QMouseEvent* theEvent); - void viewerFitAll(const bool theUpdate = true); - - void vpMousePressEvent (QMouseEvent* theEvent); - void vpMouseReleaseEvent(QMouseEvent* theEvent); - void vpMouseMoveEvent (QMouseEvent* theEvent); - - void drawRect(); - void resetState(); - bool transformRequested() { return myOperation != NOTHING; } - bool setTransformRequested (OperationType op); - void clearViewer(const bool theUpdate = true); - - typedef QMap ActionsMap; - -private: - OCCViewer_ViewPort3d* myViewPort; - Handle(V3d_Viewer) myV3dViewer; -#if OCC_VERSION_LARGE <= 0x06060000 - Handle(V3d_Viewer) myV3dCollector; -#endif - Handle(AIS_InteractiveContext) myAISContext; - Handle(AIS_Trihedron) myTrihedron; - - QtxMultiAction *myZoomBtns, *myPanBtns, *myProjBtns; - QToolBar* myToolBar; - OperationType myOperation; - - ActionsMap myButsMap; - QCursor myCursor; - QRect myRect; - - double myCurScale; - bool myCursorIsHand; - bool myDrawRect; - int myStartX; - int myStartY; - int myCurrX; - int myCurrY; - OCCViewer_ViewWindow::RotationPointType myCurrPointType; - gp_Pnt mySelectedPoint; - bool myShowTrihedron; - - Mode2dType my2dMode; - bool myUseMultiAction; -}; - -#endif