]> SALOME platform Git repositories - modules/hydro.git/commitdiff
Salome HOME
Profile object creation.
authornds <nds@opencascade.com>
Fri, 29 Nov 2013 13:23:01 +0000 (13:23 +0000)
committernds <nds@opencascade.com>
Fri, 29 Nov 2013 13:23:01 +0000 (13:23 +0000)
src/HYDROCurveCreator/CurveCreator_Widget.cxx
src/HYDROCurveCreator/CurveCreator_Widget.h
src/HYDROCurveCreator/OCCViewer_ViewWidget.cxx
src/HYDROCurveCreator/OCCViewer_ViewWidget.h

index 1897434ccea30b3e0c5c6df8fd778988b47b2197..fd66a6b69052c075b0af2665025cfb53dd4f31de 100644 (file)
@@ -36,6 +36,7 @@
 #include <OCCViewer_ViewManager.h>
 #include <OCCViewer_ViewPort3d.h>
 #include "OCCViewer_Utilities.h"
+#include "OCCViewer_ViewWidget.h"
 
 #include <BRep_Tool.hxx>
 #include <TopoDS.hxx>
@@ -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 );
index ea41a275c1e7638faa8e87af9864b48a14eb28dd..f07dde23113eb1147d60378b8b804b7cfc5db37e 100644 (file)
@@ -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;
index ad86a6cf050d7cb382f7bb8db4d1022780b94f51..ac9fd07c51abe19ce6774c75fcab83aed881f1bc 100644 (file)
@@ -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 );
     }
   }
 }
index 455a12942760cce806306b8cb979c96b09992ec2..cbfe37e7f5cb80e0694e3c2019f5c6193bbfea79 100644 (file)
@@ -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 };