From: nds Date: Fri, 29 Nov 2013 13:23:01 +0000 (+0000) Subject: Profile object creation. X-Git-Tag: BR_hydro_v_0_4~129 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=f62b83d0f33b4533252d7fc426d6666e8603b411;p=modules%2Fhydro.git Profile object creation. --- diff --git a/src/HYDROCurveCreator/CurveCreator_Widget.cxx b/src/HYDROCurveCreator/CurveCreator_Widget.cxx index 1897434c..fd66a6b6 100644 --- a/src/HYDROCurveCreator/CurveCreator_Widget.cxx +++ b/src/HYDROCurveCreator/CurveCreator_Widget.cxx @@ -36,6 +36,7 @@ #include #include #include "OCCViewer_Utilities.h" +#include "OCCViewer_ViewWidget.h" #include #include @@ -82,7 +83,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 ) + myOCCViewer( 0 ), myOCCViewWidget( 0 ) { myNewSectionEditor = new CurveCreator_NewSectionDlg( this ); myNewSectionEditor->hide(); @@ -257,7 +258,7 @@ void CurveCreator_Widget::setOCCViewer( OCCViewer_Viewer* theViewer ) this, SLOT( onMouseMove( SUIT_ViewWindow*, QMouseEvent* ) ) ); connect( aViewManager, SIGNAL( lastViewClosed( SUIT_ViewManager* ) ), this, SLOT( onLastViewClosed( SUIT_ViewManager* ) ) ); - OCCViewer_Utilities::setViewer2DMode( theViewer, OCCViewer_ViewWindow::XYPlane ); + OCCViewer_Utilities::setViewer2DMode( myOCCViewer, OCCViewer_ViewWindow::XYPlane ); } } @@ -269,13 +270,65 @@ 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 */ Handle(AIS_InteractiveContext) CurveCreator_Widget::getAISContext() { + Handle(AIS_InteractiveContext) aContext; OCCViewer_Viewer* aViewer = getOCCViewer(); - return aViewer ? aViewer->getAISContext() : 0; + if ( aViewer ) + aContext = aViewer->getAISContext(); + else if ( myOCCViewWidget ) + aContext = myOCCViewWidget->getAISContext(); + + return aContext; } /** @@ -287,7 +340,9 @@ 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; } @@ -318,6 +373,14 @@ 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(); + } } //======================================================================= @@ -1023,6 +1086,21 @@ void CurveCreator_Widget::onLastViewClosed( SUIT_ViewManager* theManager ) myOCCViewer = 0; } +void CurveCreator_Widget::onMousePress( QMouseEvent* theEvent ) +{ + onMousePress( 0, theEvent ); +} + +void CurveCreator_Widget::onMouseRelease( QMouseEvent* theEvent ) +{ + onMouseRelease( 0, theEvent ); +} + +void CurveCreator_Widget::onMouseMove( QMouseEvent* theEvent ) +{ + onMouseMove( 0, theEvent ); +} + void CurveCreator_Widget::onCellChanged( int theRow, int theColumn ) { int aCurrSect = getSectionId( theRow ); diff --git a/src/HYDROCurveCreator/CurveCreator_Widget.h b/src/HYDROCurveCreator/CurveCreator_Widget.h index ea41a275..f07dde23 100644 --- a/src/HYDROCurveCreator/CurveCreator_Widget.h +++ b/src/HYDROCurveCreator/CurveCreator_Widget.h @@ -37,6 +37,7 @@ class OCCViewer_Viewer; class OCCViewer_ViewPort3d; +class OCCViewer_ViewWidget; class AIS_ListOfInteractive; @@ -58,7 +59,7 @@ public: // OCC viewer manipulation void setOCCViewer( OCCViewer_Viewer* theViewer ); - OCCViewer_Viewer* getOCCViewer(); + void setOCCViewWidget( OCCViewer_ViewWidget* theViewWidget ); Handle(AIS_InteractiveContext) getAISContext(); OCCViewer_ViewPort3d* getViewPort(); @@ -114,6 +115,10 @@ protected slots: void onMouseMove( SUIT_ViewWindow*, QMouseEvent* theEvent ); void onLastViewClosed( SUIT_ViewManager* theManager ); + void onMousePress( QMouseEvent* theEvent ); + void onMouseRelease( QMouseEvent* theEvent ); + void onMouseMove( QMouseEvent* theEvent ); + void onCellChanged( int theRow, int theColumn ); protected: @@ -146,6 +151,9 @@ protected: typedef std::deque< SectionToPoint > SectionToPointList; private: + OCCViewer_Viewer* getOCCViewer(); + OCCViewer_ViewWidget* getOCCViewWidget(); + QAction* createAction( ActionId theId, const QString& theName, const QPixmap& theImage, const QString& theToolTip, const QKeySequence& theShortcut ); QAction* getAction(ActionId theId); @@ -199,6 +207,7 @@ private: QTableWidget* myLocalPointView; CurveCreator_NewSectionDlg* myNewSectionEditor; OCCViewer_Viewer* myOCCViewer; + OCCViewer_ViewWidget* myOCCViewWidget; int mySection; int myPointNum; bool myDragStarted; diff --git a/src/HYDROCurveCreator/OCCViewer_ViewWidget.cxx b/src/HYDROCurveCreator/OCCViewer_ViewWidget.cxx index ad86a6cf..ac9fd07c 100644 --- a/src/HYDROCurveCreator/OCCViewer_ViewWidget.cxx +++ b/src/HYDROCurveCreator/OCCViewer_ViewWidget.cxx @@ -674,6 +674,7 @@ void OCCViewer_ViewWidget::vpMousePressEvent(QMouseEvent* theEvent) //myViewPort->startRotation(myStartX, myStartY);//, 0, mySelectedPoint); break; default: + emit mousePressed(theEvent); break; } } @@ -699,6 +700,7 @@ void OCCViewer_ViewWidget::vpMouseReleaseEvent(QMouseEvent* theEvent) { switch (myOperation) { case NOTHING: + emit mouseReleased(theEvent); break; case ROTATE: myViewPort->endRotation(); @@ -776,7 +778,9 @@ void OCCViewer_ViewWidget::vpMouseMoveEvent(QMouseEvent* theEvent) setCursor(handCursor); } } - } + } + else + emit mouseMoving( theEvent ); } } } diff --git a/src/HYDROCurveCreator/OCCViewer_ViewWidget.h b/src/HYDROCurveCreator/OCCViewer_ViewWidget.h index 455a1294..cbfe37e7 100644 --- a/src/HYDROCurveCreator/OCCViewer_ViewWidget.h +++ b/src/HYDROCurveCreator/OCCViewer_ViewWidget.h @@ -22,6 +22,7 @@ class QPushButton; class QToolBar; class Handle(V3d_Viewer); +class Handle(AIS_InteractiveContext); #ifdef WIN32 #pragma warning ( disable:4251 ) @@ -40,6 +41,7 @@ public: ~OCCViewer_ViewWidget(); OCCViewer_ViewPort3d* getViewPort(); + Handle(AIS_InteractiveContext) getAISContext() { return myAISContext; } bool eventFilter(QObject* watched, QEvent* e); @@ -64,6 +66,11 @@ public slots: 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 };