From: vsv Date: Fri, 10 Sep 2010 13:16:27 +0000 (+0000) Subject: *** empty log message *** X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=9151b88db5087bf133bd2536f5e4aeb383a0ce72;p=modules%2Fgui.git *** empty log message *** --- diff --git a/src/OCCViewer/Makefile.am b/src/OCCViewer/Makefile.am index 65d59fc7e..1a5e49497 100755 --- a/src/OCCViewer/Makefile.am +++ b/src/OCCViewer/Makefile.am @@ -44,7 +44,8 @@ salomeinclude_HEADERS = \ OCCViewer_AxialScaleDlg.h \ OCCViewer_SetRotationPointDlg.h \ OCCViewer_Trihedron.h \ - OCCViewer_ToolTip.h + OCCViewer_ToolTip.h \ + OCCViewer_ViewFrame.h dist_libOCCViewer_la_SOURCES = \ OCCViewer_AISSelector.cxx \ @@ -60,7 +61,8 @@ dist_libOCCViewer_la_SOURCES = \ OCCViewer_ClippingDlg.cxx \ OCCViewer_AxialScaleDlg.cxx \ OCCViewer_Trihedron.cxx \ - OCCViewer_ToolTip.cxx + OCCViewer_ToolTip.cxx \ + OCCViewer_ViewFrame.cxx MOC_FILES = \ OCCViewer_AISSelector_moc.cxx \ @@ -74,8 +76,9 @@ MOC_FILES = \ OCCViewer_SetRotationPointDlg_moc.cxx \ OCCViewer_ClippingDlg_moc.cxx \ OCCViewer_AxialScaleDlg_moc.cxx \ - OCCViewer_ToolTip_moc.cxx - + OCCViewer_ToolTip_moc.cxx \ + OCCViewer_ViewFrame_moc.cxx + nodist_libOCCViewer_la_SOURCES = $(MOC_FILES) dist_salomeres_DATA = \ @@ -101,7 +104,9 @@ dist_salomeres_DATA = \ resources/occ_view_top.png \ resources/occ_view_triedre.png \ resources/occ_view_zoom.png \ - resources/occ_view_rotation_point.png + resources/occ_view_rotation_point.png \ + resources/occ_view_maximized.png \ + resources/occ_view_minimized.png nodist_salomeres_DATA = \ OCCViewer_images.qm \ diff --git a/src/OCCViewer/OCCViewer_ViewModel.cxx b/src/OCCViewer/OCCViewer_ViewModel.cxx index caea77326..e84dd4fb0 100755 --- a/src/OCCViewer/OCCViewer_ViewModel.cxx +++ b/src/OCCViewer/OCCViewer_ViewModel.cxx @@ -22,6 +22,7 @@ #include "OCCViewer_ViewModel.h" #include "OCCViewer_ViewWindow.h" +#include "OCCViewer_ViewFrame.h" #include "OCCViewer_VService.h" #include "OCCViewer_ViewPort3d.h" @@ -114,7 +115,7 @@ OCCViewer_Viewer::OCCViewer_Viewer( bool DisplayTrihedron, bool DisplayStaticTri myAISContext->Display(myTrihedron); myAISContext->Deactivate(myTrihedron); - } + } // set interaction style to standard myInteractionStyle = 0; @@ -172,8 +173,9 @@ void OCCViewer_Viewer::initView( OCCViewer_ViewWindow* view ) */ SUIT_ViewWindow* OCCViewer_Viewer::createView( SUIT_Desktop* theDesktop ) { - OCCViewer_ViewWindow* view = new OCCViewer_ViewWindow(theDesktop, this); - initView( view ); + //OCCViewer_ViewWindow* view = new OCCViewer_ViewWindow(theDesktop, this); + OCCViewer_ViewFrame* view = new OCCViewer_ViewFrame(theDesktop, this); + initView( view->getView(OCCViewer_ViewFrame::MAIN_VIEW) ); return view; } @@ -218,12 +220,16 @@ void OCCViewer_Viewer::onMouseMove(SUIT_ViewWindow* theWindow, QMouseEvent* theE OCCViewer_ViewWindow* aView = (OCCViewer_ViewWindow*) theWindow; if ( isSelectionEnabled() ) { - if (aView->getViewPort()->isBusy()) return; // Check that the ViewPort initialization completed + if (aView->getViewPort()->isBusy()) { + QCoreApplication::processEvents(); + return; // Check that the ViewPort initialization completed // To Prevent call move event if the View port is not initialized // IPAL 20883 + } Handle(V3d_View) aView3d = aView->getViewPort()->getView(); - if ( !aView3d.IsNull() ) + if ( !aView3d.IsNull() ) { myAISContext->MoveTo(theEvent->x(), theEvent->y(), aView3d); + } } } @@ -405,14 +411,10 @@ void OCCViewer_Viewer::onChangeBgColor() OCCViewer_ViewWindow* aView = (OCCViewer_ViewWindow*)(myViewManager->getActiveView()); if( !aView ) return; - OCCViewer_ViewPort3d* aViewPort3d = aView->getViewPort(); - if( !aViewPort3d ) - return; - QColor aColorActive = aViewPort3d->backgroundColor(); - + QColor aColorActive = aView->backgroundColor(); QColor selColor = QColorDialog::getColor( aColorActive, aView); if ( selColor.isValid() ) - aViewPort3d->setBackgroundColor(selColor); + aView->setBackgroundColor(selColor); } /*! @@ -708,3 +710,11 @@ void OCCViewer_Viewer::isos( int& u, int& v ) const v = ic->IsoNumber( AIS_TOI_IsoV ); } } + +/* + * Returns a new OCCViewer_ViewWindow instance which will be placed as a sub window in ViewFrame + */ +OCCViewer_ViewWindow* OCCViewer_Viewer::createSubWindow() +{ + return new OCCViewer_ViewWindow( 0, this); +} diff --git a/src/OCCViewer/OCCViewer_ViewModel.h b/src/OCCViewer/OCCViewer_ViewModel.h index 925b2dc05..251095a65 100755 --- a/src/OCCViewer/OCCViewer_ViewModel.h +++ b/src/OCCViewer/OCCViewer_ViewModel.h @@ -117,6 +117,8 @@ public: double trihedronSize() const; virtual void setTrihedronSize( const double ); + virtual OCCViewer_ViewWindow* createSubWindow(); + public slots: void onClearViewAspects(); @@ -150,12 +152,13 @@ public: void setIsos( const int u, const int v ); // number of isolines void isos( int& u, int& v ) const; + void initView( OCCViewer_ViewWindow* view ); + signals: void selectionChanged(); void deselection(); protected: - void initView( OCCViewer_ViewWindow* view ); protected slots: void onMousePress(SUIT_ViewWindow*, QMouseEvent*); diff --git a/src/OCCViewer/OCCViewer_ViewPort3d.cxx b/src/OCCViewer/OCCViewer_ViewPort3d.cxx index 4b2ebd62c..f0cbe3d13 100755 --- a/src/OCCViewer/OCCViewer_ViewPort3d.cxx +++ b/src/OCCViewer/OCCViewer_ViewPort3d.cxx @@ -119,7 +119,7 @@ bool OCCViewer_ViewPort3d::mapView( const Handle(V3d_View)& view ) } /* create static trihedron (16551: EDF PAL 501) */ - OCCViewer_ViewWindow* aVW = dynamic_cast( parentWidget() ); + OCCViewer_ViewWindow* aVW = dynamic_cast( parentWidget()->parentWidget()->parentWidget() ); if ( aVW ) { OCCViewer_Viewer* aViewModel = dynamic_cast( aVW->getViewManager()->getViewModel() ); if ( aViewModel && aViewModel->isStaticTrihedronDisplayed() ){ diff --git a/src/OCCViewer/OCCViewer_ViewWindow.cxx b/src/OCCViewer/OCCViewer_ViewWindow.cxx index ee2ba5cb8..aa79b3254 100755 --- a/src/OCCViewer/OCCViewer_ViewWindow.cxx +++ b/src/OCCViewer/OCCViewer_ViewWindow.cxx @@ -216,6 +216,7 @@ OCCViewer_ViewWindow::OCCViewer_ViewWindow( SUIT_Desktop* theDesktop, mypSketcher = 0; myCurSketch = -1; + my2dMode = No2dMode; myInteractionStyle = SUIT_ViewModel::STANDARD; } @@ -250,6 +251,17 @@ void OCCViewer_ViewWindow::initLayout() createActions(); createToolBar(); + switch (my2dMode) { + case XYPlane: + onTopView(); + break; + case XZPlane: + onLeftView(); + break; + case YZPlane: + onFrontView(); + break; + } } /*! @@ -270,7 +282,8 @@ OCCViewer_ViewWindow::getButtonState( QMouseEvent* theEvent, int theInteractionS (theEvent->buttons() == SUIT_ViewModel::myButtonMap[aStyle][SUIT_ViewModel::PAN]) ) aOp = PANVIEW; else if( (theEvent->modifiers() == SUIT_ViewModel::myStateMap[aStyle][SUIT_ViewModel::ROTATE]) && - (theEvent->buttons() == SUIT_ViewModel::myButtonMap[aStyle][SUIT_ViewModel::ROTATE]) ) + (theEvent->buttons() == SUIT_ViewModel::myButtonMap[aStyle][SUIT_ViewModel::ROTATE]) && + (my2dMode == No2dMode)) aOp = ROTATE; return aOp; @@ -1137,6 +1150,13 @@ void OCCViewer_ViewWindow::createActions() aAction->setCheckable(true); connect(aAction, SIGNAL(toggled(bool)), this, SLOT(onSwitchInteractionStyle(bool))); toolMgr()->registerAction( aAction, SwitchInteractionStyleId ); + + // Maximized view + aAction = new QtxAction(tr("MNU_MINIMIZE_VIEW"), aResMgr->loadPixmap( "OCCViewer", tr( "ICON_OCCVIEWER_MINIMIZE" ) ), + tr( "MNU_MINIMIZE_VIEW" ), 0, this ); + aAction->setStatusTip(tr("DSC_MINIMIZE_VIEW")); + connect(aAction, SIGNAL(triggered()), this, SLOT(onMaximizedView())); + toolMgr()->registerAction( aAction, MaximizedId ); } /*! @@ -1162,32 +1182,35 @@ void OCCViewer_ViewWindow::createToolBar() aPanningAction->insertAction( toolMgr()->action( GlobalPanId ) ); toolMgr()->append( aPanningAction, tid ); - toolMgr()->append( ChangeRotationPointId, tid ); - toolMgr()->append( RotationId, tid ); - - QtxMultiAction* aViewsAction = new QtxMultiAction( this ); - aViewsAction->insertAction( toolMgr()->action( FrontId ) ); - aViewsAction->insertAction( toolMgr()->action( BackId ) ); - aViewsAction->insertAction( toolMgr()->action( TopId ) ); - aViewsAction->insertAction( toolMgr()->action( BottomId ) ); - aViewsAction->insertAction( toolMgr()->action( LeftId ) ); - aViewsAction->insertAction( toolMgr()->action( RightId ) ); - toolMgr()->append( aViewsAction, tid ); - - toolMgr()->append( ResetId, tid ); + if (my2dMode == No2dMode) { + toolMgr()->append( ChangeRotationPointId, tid ); + toolMgr()->append( RotationId, tid ); + + QtxMultiAction* aViewsAction = new QtxMultiAction( this ); + aViewsAction->insertAction( toolMgr()->action( FrontId ) ); + aViewsAction->insertAction( toolMgr()->action( BackId ) ); + aViewsAction->insertAction( toolMgr()->action( TopId ) ); + aViewsAction->insertAction( toolMgr()->action( BottomId ) ); + aViewsAction->insertAction( toolMgr()->action( LeftId ) ); + aViewsAction->insertAction( toolMgr()->action( RightId ) ); + toolMgr()->append( aViewsAction, tid ); + + toolMgr()->append( ResetId, tid ); - QtxMultiAction* aMemAction = new QtxMultiAction( this ); - aMemAction->insertAction( toolMgr()->action( MemId ) ); - aMemAction->insertAction( toolMgr()->action( RestoreId ) ); - toolMgr()->append( aMemAction, tid ); + QtxMultiAction* aMemAction = new QtxMultiAction( this ); + aMemAction->insertAction( toolMgr()->action( MemId ) ); + aMemAction->insertAction( toolMgr()->action( RestoreId ) ); + toolMgr()->append( aMemAction, tid ); - toolMgr()->append( toolMgr()->separator(), tid ); - toolMgr()->append( CloneId, tid ); + toolMgr()->append( toolMgr()->separator(), tid ); + toolMgr()->append( CloneId, tid ); - toolMgr()->append( toolMgr()->separator(), tid ); - toolMgr()->append( ClippingId, tid ); - toolMgr()->append( AxialScaleId, tid ); + toolMgr()->append( toolMgr()->separator(), tid ); + toolMgr()->append( ClippingId, tid ); + toolMgr()->append( AxialScaleId, tid ); + } toolMgr()->append( AmbientId, tid ); + toolMgr()->append( MaximizedId, tid); } /*! @@ -1616,6 +1639,14 @@ void OCCViewer_ViewWindow::setCuttingPlane( bool on, const double x, const doub view->Redraw(); } +void OCCViewer_ViewWindow::setCuttingPlane( bool on, const gp_Pln pln ) +{ + gp_Dir aDir = pln.Axis().Direction(); + gp_Pnt aPnt = pln.Location(); + setCuttingPlane(on, aPnt.X(), aPnt.Y(), aPnt.Z(), aDir.X(), aDir.Y(), aDir.Z()); +} + + /*! \brief Check if any cutting plane is enabled \return \c true if at least one cutting plane is enabled @@ -1927,3 +1958,59 @@ bool OCCViewer_ViewWindow::transformEnabled( const OperationType id ) const { return myStatus.contains( id ) ? myStatus[ id ] : true; } + +void OCCViewer_ViewWindow::onMaximizedView() +{ + setMaximized(!isMaximized()); +} + + +void OCCViewer_ViewWindow::setMaximized(bool toMaximize, bool toSendSignal) +{ + QAction* anAction = toolMgr()->action( MaximizedId ); + SUIT_ResourceMgr* aResMgr = SUIT_Session::session()->resourceMgr(); + if ( toMaximize ) { + anAction->setText( tr( "MNU_MINIMIZE_VIEW" ) ); + anAction->setIcon( aResMgr->loadPixmap( "OCCViewer", tr( "ICON_OCCVIEWER_MINIMIZE" ) ) ); + anAction->setStatusTip( tr( "DSC_MINIMIZE_VIEW" ) ); + if (toSendSignal) { + printf("### OCCViewer_ViewWindow::emitMaximised\n"); + emit maximized( this, true ); + } + } + else { + anAction->setText( tr( "MNU_MAXIMIZE_VIEW" ) ); + anAction->setIcon( aResMgr->loadPixmap( "OCCViewer", tr( "ICON_OCCVIEWER_MAXIMIZE" ) ) ); + anAction->setStatusTip( tr( "DSC_MAXIMIZE_VIEW" ) ); + if (toSendSignal) { + printf("### OCCViewer_ViewWindow::emitMinimised\n"); + emit maximized( this, false ); + } + } +} + + +bool OCCViewer_ViewWindow::isMaximized() const +{ + return !(toolMgr()->action( MaximizedId )->text() == tr( "MNU_MAXIMIZE_VIEW" )); +} + + +void OCCViewer_ViewWindow::set2dMode(Mode2dType theType) +{ + my2dMode = theType; +} + +QColor OCCViewer_ViewWindow::backgroundColor() const +{ + if( !myViewPort ) + return Qt::black; + return myViewPort->backgroundColor(); +} + +void OCCViewer_ViewWindow::setBackgroundColor( const QColor& theColor) +{ + if( !myViewPort ) + return; + myViewPort->setBackgroundColor(theColor); +} diff --git a/src/OCCViewer/OCCViewer_ViewWindow.h b/src/OCCViewer/OCCViewer_ViewWindow.h index 56558b5b7..1a8fb886d 100755 --- a/src/OCCViewer/OCCViewer_ViewWindow.h +++ b/src/OCCViewer/OCCViewer_ViewWindow.h @@ -50,7 +50,7 @@ public: enum { DumpId, FitAllId, FitRectId, ZoomId, PanId, GlobalPanId, ChangeRotationPointId, RotationId, FrontId, BackId, TopId, BottomId, LeftId, RightId, ResetId, CloneId, ClippingId, MemId, RestoreId, - TrihedronShowId, AxialScaleId, AmbientId, SwitchInteractionStyleId }; + TrihedronShowId, AxialScaleId, AmbientId, SwitchInteractionStyleId, MaximizedId, UserId }; enum OperationType{ NOTHING, PANVIEW, ZOOMVIEW, ROTATE, PANGLOBAL, WINDOWFIT, FITALLVIEW, RESETVIEW, @@ -60,72 +60,89 @@ public: enum SketchingType { NoSketching, Rect, Polygon }; + enum Mode2dType { No2dMode, XYPlane, XZPlane, YZPlane}; + + OCCViewer_ViewWindow(SUIT_Desktop* theDesktop, OCCViewer_Viewer* theModel); virtual ~OCCViewer_ViewWindow(); - OCCViewer_ViewPort3d* getViewPort(); + virtual OCCViewer_ViewPort3d* getViewPort(); - bool eventFilter(QObject* watched, QEvent* e); + virtual bool eventFilter(QObject* watched, QEvent* e); - void performRestoring( const viewAspect& ); + virtual void performRestoring( const viewAspect& ); virtual void initLayout(); - void updateEnabledDrawMode(); + virtual void updateEnabledDrawMode(); - void setCuttingPlane( bool on, const double x = 0 , const double y = 0 , const double z = 0, + virtual void setCuttingPlane( bool on, const double x = 0 , const double y = 0 , const double z = 0, const double dx = 0, const double dy = 0, const double dz = 1); - bool isCuttingPlane(); + virtual void setCuttingPlane( bool on, const gp_Pln thePln ); + + virtual bool isCuttingPlane(); virtual QString getVisualParameters(); virtual void setVisualParameters( const QString& parameters ); virtual void initSketchers(); - OCCViewer_ViewSketcher* getSketcher( const int ); + virtual OCCViewer_ViewSketcher* getSketcher( const int ); - void activateSketching( int ); + virtual void activateSketching( int ); - int interactionStyle() const; - void setInteractionStyle( const int ); + virtual int interactionStyle() const; + virtual void setInteractionStyle( const int ); void setTransformEnabled( const OperationType, const bool ); bool transformEnabled( const OperationType ) const; + + void set2dMode(Mode2dType theType); + Mode2dType get2dMode() const {return my2dMode; } + + void setMaximized(bool toMaximize, bool toSendSignal = true); + bool isMaximized() const; + + virtual QColor backgroundColor() const; + virtual void setBackgroundColor( const QColor& ); + public slots: - void onFrontView(); - void onViewFitAll(); - void onBackView(); - void onTopView(); - void onBottomView(); - void onLeftView(); - void onRightView(); - void onResetView(); - void onFitAll(); - void activateZoom(); - void activateWindowFit(); - void activateRotation(); - void activatePanning(); - void activateGlobalPanning(); - void onSetRotationPoint( bool on ); - void onCloneView(); - void onClipping( bool on ); - void onAxialScale(); - void onAmbientToogle(); - void onMemorizeView(); - void onRestoreView(); - void onTrihedronShow(); - void setRestoreFlag(); - void onSwitchInteractionStyle( bool on ); - - void activateSetRotationGravity(); - void activateSetRotationSelected( double theX, double theY, double theZ ); - void activateStartPointSelection(); - void updateGravityCoords(); + virtual void onFrontView(); + virtual void onViewFitAll(); + virtual void onBackView(); + virtual void onTopView(); + virtual void onBottomView(); + virtual void onLeftView(); + virtual void onRightView(); + virtual void onResetView(); + virtual void onFitAll(); + virtual void activateZoom(); + virtual void activateWindowFit(); + virtual void activateRotation(); + virtual void activatePanning(); + virtual void activateGlobalPanning(); + virtual void onSetRotationPoint( bool on ); + virtual void onCloneView(); + virtual void onClipping( bool on ); + virtual void onAxialScale(); + virtual void onAmbientToogle(); + virtual void onMemorizeView(); + virtual void onRestoreView(); + virtual void onTrihedronShow(); + virtual void setRestoreFlag(); + virtual void onSwitchInteractionStyle( bool on ); + + virtual void activateSetRotationGravity(); + virtual void activateSetRotationSelected( double theX, double theY, double theZ ); + virtual void activateStartPointSelection(); + virtual void updateGravityCoords(); virtual void showEvent( QShowEvent * ); virtual void hideEvent( QHideEvent * ); + void onMaximizedView(); + signals: void vpTransformationStarted(OCCViewer_ViewWindow::OperationType type); @@ -134,6 +151,7 @@ signals: void Show( QShowEvent * ); void Hide( QHideEvent * ); + void maximized( OCCViewer_ViewWindow*, bool ); protected: virtual QImage dumpView(); @@ -216,6 +234,8 @@ private: typedef QMap MapOfTransformStatus; MapOfTransformStatus myStatus; + + Mode2dType my2dMode; }; #ifdef WIN32