CurveCreator_TreeView.h
# CurveCreator_UndoOptsDlg.h
CurveCreator_Widget.h
+ OCCViewer_Utilities.h
OCCViewer_ViewWidget.h
)
ENDIF(SALOME_BUILD_GUI)
CurveCreator_TreeView.cxx
# CurveCreator_UndoOptsDlg.cxx
CurveCreator_Widget.cxx
+ OCCViewer_Utilities.cxx
OCCViewer_ViewWidget.cxx
)
ENDIF(SALOME_BUILD_GUI)
#include <OCCViewer_ViewWindow.h>
#include <OCCViewer_ViewManager.h>
#include <OCCViewer_ViewPort3d.h>
+#include "OCCViewer_Utilities.h"
#include <BRep_Tool.hxx>
#include <TopoDS.hxx>
this, SLOT( onMouseRelease( SUIT_ViewWindow*, QMouseEvent* ) ) );
disconnect( aViewManager, SIGNAL( mouseMove( SUIT_ViewWindow*, QMouseEvent* ) ),
this, SLOT( onMouseMove( SUIT_ViewWindow*, QMouseEvent* ) ) );
+ // restore normal mode in the viewer
+ OCCViewer_Utilities::setViewer2DMode( myOCCViewer, OCCViewer_ViewWindow::No2dMode );
// all local contexts should be closed if the viewer is not more used
setLocalPointContext( false, true );
}
this, SLOT( onMouseRelease( SUIT_ViewWindow*, QMouseEvent* ) ) );
connect( aViewManager, SIGNAL( mouseMove( SUIT_ViewWindow*, QMouseEvent* ) ),
this, SLOT( onMouseMove( SUIT_ViewWindow*, QMouseEvent* ) ) );
+ OCCViewer_Utilities::setViewer2DMode( theViewer, OCCViewer_ViewWindow::XYPlane );
}
}
--- /dev/null
+
+#include "OCCViewer_Utilities.h"
+
+#include <OCCViewer_ViewFrame.h>
+#include <OCCViewer_ViewModel.h>
+#include <SUIT_ViewManager.h>
+
+#include <QtxActionToolMgr.h>
+
+#include <QAction>
+
+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 );
+ }
+
+ // change view position
+ switch ( theMode ) {
+ case OCCViewer_ViewWindow::XYPlane:
+ aView->onTopView();
+ break;
+ case OCCViewer_ViewWindow::XZPlane:
+ aView->onLeftView();
+ break;
+ case OCCViewer_ViewWindow::YZPlane:
+ aView->onFrontView();
+ break;
+ }
+}
--- /dev/null
+#ifndef OCCVIEWER_UTILITIES_H
+#define OCCVIEWER_UTILITIES_H
+
+#include "CurveCreator_Macro.hxx"
+
+#include <OCCViewer_ViewWindow.h>
+
+class OCCViewer_Viewer;
+
+#ifdef WIN32
+#pragma warning ( disable:4251 )
+#endif
+
+class CURVECREATOR_EXPORT OCCViewer_Utilities
+{
+public:
+
+ /*!
+ * Set 2D mode for the viewer. Hide or show 3D actions.
+ * \param theViewer an OCC viewer
+ * \param theMode OCC view window mode
+ */
+ static void setViewer2DMode( OCCViewer_Viewer* theViewer,
+ const OCCViewer_ViewWindow::Mode2dType& theMode );
+
+};
+
+#endif
connect( anApp, SIGNAL( operationFinished( const QString&, const QString&, const QStringList& ) ),
this, SLOT( onExternalOperationFinished( const QString&, const QString&, const QStringList& ) ) );
+ HYDROGUI_Tool::setOCCActionShown( this, OCCViewer_ViewWindow::MaximizedId, false );
+
return aRes;
}
disconnect( getApp(), SIGNAL( operationFinished( const QString&, const QString&, const QStringList& ) ),
this, SLOT( onExternalOperationFinished( const QString&, const QString&, const QStringList& ) ) );
+ HYDROGUI_Tool::setOCCActionShown( this, OCCViewer_ViewWindow::MaximizedId, true );
+
return LightApp_Module::deactivateModule( theStudy );
}
if( OCCViewer_ViewFrame* aViewFrame = dynamic_cast<OCCViewer_ViewFrame*>( theViewWindow ) )
{
aViewFrame->onTopView();
+
+ HYDROGUI_Tool::setOCCActionShown( aViewFrame, OCCViewer_ViewWindow::MaximizedId, false );
}
}
}
#include <LightApp_SelectionMgr.h>
#include <OCCViewer_ViewModel.h>
+#include <OCCViewer_ViewFrame.h>
#include <QtxWorkstack.h>
+#include <QtxActionToolMgr.h>
#include <STD_TabDesktop.h>
return getViewIdList( theModule, OCCViewer_Viewer::Type() );
}
+void HYDROGUI_Tool::setOCCActionShown( OCCViewer_ViewFrame* theViewFrame,
+ const int theActionId,
+ const bool isShown )
+{
+ if ( !theViewFrame )
+ return;
+
+ OCCViewer_ViewWindow* aView = theViewFrame->getView( OCCViewer_ViewFrame::MAIN_VIEW );
+ if ( aView ) {
+ aView->toolMgr()->setShown( theActionId, isShown );
+ if ( theActionId == OCCViewer_ViewWindow::MaximizedId )
+ theViewFrame->onMaximizedView( aView, true );
+ }
+}
+
+void HYDROGUI_Tool::setOCCActionShown( HYDROGUI_Module* theModule,
+ const int theActionId,
+ const bool isShown )
+{
+ QList<size_t> aList;
+ ViewManagerList aViewMgrs;
+ theModule->getApp()->viewManagers( OCCViewer_Viewer::Type(), aViewMgrs );
+ QListIterator<SUIT_ViewManager*> anIter( aViewMgrs );
+ while( anIter.hasNext() )
+ {
+ if( SUIT_ViewManager* aViewMgr = anIter.next() )
+ {
+ OCCViewer_ViewFrame* aViewFrame = dynamic_cast<OCCViewer_ViewFrame*>
+ ( aViewMgr->getActiveView() );
+ if ( aViewFrame )
+ setOCCActionShown( aViewFrame, theActionId, isShown );
+ }
+ }
+}
+
void HYDROGUI_Tool::GetObjectReferences( const Handle(HYDROData_Image)& theImage,
HYDROData_SequenceOfObjects& theRefObjects,
QStringList& theRefNames )
#include <TCollection_HExtendedString.hxx>
class SUIT_ViewManager;
+class OCCViewer_ViewFrame;
class HYDROGUI_DataModel;
class HYDROGUI_Module;
*/
static QList<size_t> GetOCCViewIdList( HYDROGUI_Module* theModule );
+
+ /**
+ * \brief Change OCC viewer action visibility.
+ * \param theViewFrame OCC viewer frame
+ * \param theActionId an action index, which state should be changed
+ * \param isShown the action visibility state
+ */
+ static void setOCCActionShown( OCCViewer_ViewFrame* theViewFrame,
+ const int theActionId,
+ const bool isShown );
+
+ /**
+ * \brief Change OCC viewer action visibility for all opened views.
+ * \param theActionId an action index, which state should be changed
+ * \param isShown the action visibility state
+ */
+ static void setOCCActionShown( HYDROGUI_Module* theModule,
+ const int theActionId,
+ const bool isShown );
+
/**
* \brief Get the list of references (recursively) for the specified image object
* \param theImage image data object