SET(ENABLE_QXGRAPHVIEWER ON)
ENABLE_TESTING()
-SET(VERSION "6.5.0")
+SET(VERSION "7.0.0")
SET(VERSION_DEV "1")
SET(KERNEL_ROOT_DIR $ENV{KERNEL_ROOT_DIR})
The main SALOME Desktop consists of the following sections and
toolbars:
-\image html geomview-alt.png
+\image html desktop.png
<b>Basic parts of the SALOME Desktop:</b>
<ul>
<li><b>Main menu</b> - This is a set of context-sensitive menus, which will
-be updated according the functionality of the loaded component. In
-general, these menus contain all functional options of SALOME
+be updated according to the functionality of the currently active component. In
+general, these menus contain all functional options of SALOME
platform.</li>
-<li><b>Standard Toolbar</b> - This toolbar contains icons allowing
-creating/saving studies, correcting mistakes, copying/pasting
-objects.</li>
-<li><b>Components Toolbar</b> - This toolbar is destined for uploading
+<li><b>Standard toolbar</b> - This toolbar contains standard actions
+that allow creating new or opening existing study, saving study, deleting
+objects etc.</li>
+<li><b>Components toolbar</b> - This toolbar allows activating
components in SALOME platform.</li>
-<li><b>Module Toolbar</b> - This toolbar contains icons specific to the
-loaded module.</li>
-<li><b>Viewer Toolbar</b> - This is a set of tools destined for visualization
+<li><b>Module toolbars</b> - These toolbars contain actions specific to the
+currently active module.</li>
+<li><b>Viewer toolbar</b> - This is a set of tools destined for visualization
of the presentations in the viewer.</li>
</ul>
<b>Parts of the study window:</b>
<ul>
-<li><b>Object Browser</b> - Management of objects created or imported into
+<li><b>Object browser</b> - Management of objects created or imported into
SALOME application.</li>
<li>\b Viewer - This window is destined for visualization of
presentations.</li>
-*/
\ No newline at end of file
+*/
To confirm your choice click \b Open.
-<b>Properties</b> - allows to edit the properties of the current study.
+<b>Properties</b> - allows to show/edit the properties of the current study.
\image html studyproperties.png
<ul>
<li>\b Author - allows to change the name of the study author.</li>
<li><b> Creation date</b> - gives the date and time of Study creation.</li>
-<li>\b Locked - allows to lock the study for modifications.
+<li>\b Locked - allows to lock the study for modifications.
In case if \b Locked checkbox is checked your study will be locked for any modifications
for all users. Next time you try to edit it, you will see the
following warning message:
\image html lockedstudy.png </li>
-<li><b>Modified/Not Modified</b> - allows to see if any modifications have been
+<li><b>Modified/Not Modified</b> - allows to see if any modifications have been
introduced into study since its last save. </li>
<li><b>Length units</b> - allows to change the units of the study.</li>
-<li>\b Comment - allows to change the comment of the study.</li>
+<li>\b Comment - allows to add arbitrary comment for the study.</li>
<li>\b Modifications - allows to view the list of changes made in the study.
Each record contains the date and time of the
modification and the name of the user, who has introduced it.</li>
+<li><b> Stored data </b> - Shows the versions of data currently stored
+in the study. Note, that this information does not concern current
+versions of SALOME modules, it shows the version in which the data has been
+initially created. If the study is re-saved in the version of SALOME,
+different from initial one, the version information is
+highlighted by red-colored font; this means that version information
+is not actually valid.</li>
</ul>
\b Preferences - allows \ref setting_preferences_page "setting preferences"
- etc
*/
+CAM_Application::ModuleInfoList CAM_Application::myInfoList;
+
/*!
\brief Constructor.
char* version = getVersion ? getVersion() : 0;
- if(version) {
+ if ( version ) {
for ( ModuleInfoList::iterator it = myInfoList.begin(); it != myInfoList.end(); ++it ) {
if ( (*it).title == modName ) {
if( (*it).version.isEmpty() ) {
\param title module title (user name)
\return module name or null QString if module is not found
*/
-QString CAM_Application::moduleName( const QString& title ) const
+QString CAM_Application::moduleName( const QString& title )
{
QString res;
for ( ModuleInfoList::const_iterator it = myInfoList.begin(); it != myInfoList.end() && res.isEmpty(); ++it )
\param name module name
\return module title (user name) or null QString if module is not found
*/
-QString CAM_Application::moduleTitle( const QString& name ) const
+QString CAM_Application::moduleTitle( const QString& name )
{
QString res;
for ( ModuleInfoList::const_iterator it = myInfoList.begin(); it != myInfoList.end() && res.isEmpty(); ++it )
\param name module name
\return module icon or null QString if module is not found
*/
-QString CAM_Application::moduleIcon( const QString& name ) const
+QString CAM_Application::moduleIcon( const QString& name )
{
QString res;
for ( ModuleInfoList::const_iterator it = myInfoList.begin(); it != myInfoList.end() && res.isNull(); ++it )
\param title module title (user name)
\return \c true if module is accessible (can be loaded) or \c false otherwise
*/
-bool CAM_Application::isModuleAccessible( const QString& title ) const
+bool CAM_Application::isModuleAccessible( const QString& title )
{
bool found = false;
bool blocked = false;
\param full if \c true, return full library name, otherwise return its internal name
\return module library name or null QString if module is not found
*/
-QString CAM_Application::moduleLibrary( const QString& title, const bool full ) const
+QString CAM_Application::moduleLibrary( const QString& title, const bool full )
{
QString res;
for ( ModuleInfoList::const_iterator it = myInfoList.begin(); it != myInfoList.end() && res.isEmpty(); ++it )
/*!
\brief Return information about version of the each module.
*/
-CAM_Application::ModuleShortInfoList CAM_Application::getVersionInfo() const {
-
+CAM_Application::ModuleShortInfoList CAM_Application::getVersionInfo()
+{
ModuleShortInfoList info;
ModuleShortInfo kernel;
virtual void contextMenuPopup( const QString&, QMenu*, QString& );
- QString moduleName( const QString& ) const;
- QString moduleTitle( const QString& ) const;
- QString moduleIcon( const QString& ) const;
- bool isModuleAccessible( const QString& ) const;
+ static QString moduleName( const QString& );
+ static QString moduleTitle( const QString& );
+ static QString moduleIcon( const QString& );
+ static bool isModuleAccessible( const QString& );
virtual void createEmptyStudy();
- ModuleShortInfoList getVersionInfo() const;
+ static ModuleShortInfoList getVersionInfo();
protected:
virtual SUIT_Study* createNewStudy();
virtual void setActiveStudy( SUIT_Study* );
- QString moduleLibrary( const QString&, const bool = true ) const;
+ static QString moduleLibrary( const QString&, const bool = true );
private:
void readModuleList();
typedef QList<ModuleInfo> ModuleInfoList;
private:
- CAM_Module* myModule; //!< active module
- ModuleList myModules; //!< loaded modules list
- ModuleInfoList myInfoList; //!< modules info list
- bool myAutoLoad; //!< auto loading flag
- bool myBlocked; //!< "blocked" flag, internal usage
+ CAM_Module* myModule; //!< active module
+ ModuleList myModules; //!< loaded modules list
+ static ModuleInfoList myInfoList; //!< modules info list
+ bool myAutoLoad; //!< auto loading flag
+ bool myBlocked; //!< "blocked" flag, internal usage
};
#ifdef WIN32
STD_TabDesktop* desk = new STD_TabDesktop();
desk->setFullScreenAllowed(false);
+ desk->setMinimizeAllowed(false);
setDesktop( desk );
#ifndef DISABLE_PYCONSOLE
/*!
+ This returns the python console integrated to the GUI. Depending
+ when you request the python console, this function could return
+ null. Then the optional parameter force (default to false) can be
+ set to force the creation of the python console if it is not done
+ already.
+ \param force - if true, the pythonConsole is created if it does not exist yet
\return Python Console
*/
-PyConsole_Console* LightApp_Application::pythonConsole()
+PyConsole_Console* LightApp_Application::pythonConsole(const bool force)
{
- return qobject_cast<PyConsole_Console*>( dockWindow( WT_PyConsole ) );
+ QWidget* wid = dockWindow( WT_PyConsole );
+ if ( !wid && force==true) {
+ wid = getWindow(WT_PyConsole);
+ }
+ return qobject_cast<PyConsole_Console*>( wid );
}
#endif
LogWindow* logWindow();
SUIT_DataBrowser* objectBrowser();
#ifndef DISABLE_PYCONSOLE
- PyConsole_Console* pythonConsole();
+ PyConsole_Console* pythonConsole(const bool force = false);
#endif
virtual void updateObjectBrowser( const bool = true );
QStringList::const_iterator anIt = comps.begin(), aLast = comps.end();
for( ; anIt!=aLast; anIt++ )
{
- LightApp_Displayer* disp = LightApp_Displayer::FindDisplayer( app->moduleTitle( *anIt ), true );
+ LightApp_Displayer* disp = LightApp_Displayer::FindDisplayer( app->moduleTitle( *anIt ), false );
if( disp )
disp->EraseAll( false, false, 0 );
}
</section>
<section name="viewers" >
<!-- common viewers preferences -->
- <parameter name="drop_down_buttons" value="true" />
+ <parameter name="drop_down_buttons" value="false" />
</section>
<section name="OCCViewer" >
<!-- OCC viewer preferences -->
# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
#
-# File : Makefile.in
-# Author : Vladimir Klyachin (OCN)
-# Module : OCCViewer
-# $Header$
-#
-
include $(top_srcdir)/adm_local/unix/make_common_starter.am
lib_LTLIBRARIES = libOCCViewer.la
resources/occ_view_style_switch.png \
resources/occ_view_zooming_style_switch.png \
resources/occ_view_maximized.png \
- resources/occ_view_minimized.png \
- resources/occ_view_sync.png
+ resources/occ_view_minimized.png
nodist_salomeres_DATA = \
OCCViewer_images.qm \
setCentralWidget( centralFrame );
OCCViewer_ViewWindow* view0 = theModel->createSubWindow();
+ updateWindowTitle( view0 );
view0->setParent( centralFrame );
myViews.append( view0 ); // MAIN_VIEW
{
}
+bool OCCViewer_ViewFrame::event( QEvent* e )
+{
+ if ( e->type() == QEvent::WindowTitleChange ) {
+ updateWindowTitle( getView( MAIN_VIEW ) );
+ updateWindowTitle( getView( BOTTOM_LEFT ) );
+ updateWindowTitle( getView( TOP_LEFT ) );
+ updateWindowTitle( getView( TOP_RIGHT ) );
+ }
+ return OCCViewer_ViewWindow::event( e );
+}
+
//**************************************************************************************
OCCViewer_ViewWindow* OCCViewer_ViewFrame::getView( const int i ) const
{
view->set2dMode( (Mode2dType) i );
view->setParent( centralWidget() );
view->setViewManager(myManager);
+ updateWindowTitle( view );
myViews.append( view );
aModel->initView(view);
view->setMaximized(false, false);
getView(MAIN_VIEW)->setVisualParameters( parameters );
}
}
+
+SUIT_CameraProperties OCCViewer_ViewFrame::cameraProperties()
+{
+ // view frame does not have camera properties
+ return SUIT_CameraProperties();
+}
+
+void OCCViewer_ViewFrame::updateWindowTitle(OCCViewer_ViewWindow* theView)
+{
+ if ( !theView )
+ return;
+ QString title;
+ switch ( theView->get2dMode() ) {
+ case No2dMode:
+ title = "3D"; break;
+ case XYPlane:
+ title = "YX"; break;
+ case XZPlane:
+ title = "XZ"; break;
+ case YZPlane:
+ title = "YZ"; break;
+ default:
+ break;
+ }
+ if ( !title.isEmpty() )
+ theView->setWindowTitle( windowTitle() + " - " + title );
+}
OCCViewer_ViewFrame(SUIT_Desktop* theDesktop, OCCViewer_Viewer* theModel);
virtual ~OCCViewer_ViewFrame();
+ bool event( QEvent* e );
+
OCCViewer_ViewWindow* getView( const int ) const;
virtual OCCViewer_ViewPort3d* getViewPort() { return getView(MAIN_VIEW)->getViewPort(); }
virtual void setDropDownButtons( bool );
+ virtual SUIT_CameraProperties cameraProperties();
+
public slots:
virtual void onFrontView() { getView(MAIN_VIEW)->onFrontView(); }
virtual void onViewFitAll();
void onContextMenuRequested(QContextMenuEvent*);
private:
- void connectViewSignals(OCCViewer_ViewWindow* theView);
-
+ void connectViewSignals( OCCViewer_ViewWindow* theView );
+ void updateWindowTitle( OCCViewer_ViewWindow* theView );
QList<OCCViewer_ViewWindow*> myViews;
QGridLayout* myLayout;
QtxAction* anAction = dynamic_cast<QtxAction*>( toolMgr()->action( GraduatedAxesId ) );
myCubeAxesDlg = new OCCViewer_CubeAxesDlg( anAction, this, "OCCViewer_CubeAxesDlg" );
myCubeAxesDlg->initialize();
+
+ connect( myViewPort, SIGNAL( vpTransformed( OCCViewer_ViewPort* ) ), this, SLOT( emitViewModified() ) );
}
OCCViewer_ViewWindow* OCCViewer_ViewWindow::getView( const int mode ) const
connect(aAction, SIGNAL(triggered()), this, SLOT(onMaximizedView()));
toolMgr()->registerAction( aAction, MaximizedId );
- // Synchronize view
- aAction = new QtxAction(tr("MNU_SYNCHRONIZE_VIEW"), aResMgr->loadPixmap( "OCCViewer", tr( "ICON_OCCVIEWER_SYNC" ) ),
- tr( "MNU_SYNCHRONIZE_VIEW" ), 0, this );
- aAction->setStatusTip(tr("DSC_SYNCHRONIZE_VIEW"));
- aAction->setMenu( new QMenu( this ) );
- aAction->setCheckable(true);
- connect(aAction->menu(), SIGNAL(aboutToShow()), this, SLOT(updateSyncViews()));
- connect(aAction, SIGNAL(triggered(bool)), this, SLOT(onSynchronizeView(bool)));
- toolMgr()->registerAction( aAction, SynchronizeId );
+ // Synchronize View
+ toolMgr()->registerAction( synchronizeAction(), SynchronizeId );
}
/*!
myScalingDlg = new OCCViewer_AxialScaleDlg( this );
if ( !myScalingDlg->isVisible() )
+ {
+ myScalingDlg->Update();
myScalingDlg->show();
+ }
}
/*!
myViewAspects = aViewList;
}
-void OCCViewer_ViewWindow::synchronizeView( OCCViewer_ViewWindow* viewWindow, int id )
+/*!
+ Get camera properties for the OCC view window.
+ \return shared pointer on camera properties.
+*/
+SUIT_CameraProperties OCCViewer_ViewWindow::cameraProperties()
{
- OCCViewer_ViewWindow* otherViewWindow = 0;
- QList<OCCViewer_ViewWindow*> compatibleViews;
+ SUIT_CameraProperties aProps;
- bool isSync = viewWindow->toolMgr()->action( SynchronizeId )->isChecked();
+ Handle(V3d_View) aSourceView = getViewPort()->getView();
+ if ( aSourceView.IsNull() )
+ return aProps;
- int vwid = viewWindow->getId();
-
- SUIT_Application* app = SUIT_Session::session()->activeApplication();
- if ( !app ) return;
-
- QList<SUIT_ViewManager*> wmlist;
- app->viewManagers( viewWindow->getViewManager()->getType(), wmlist );
-
- foreach( SUIT_ViewManager* wm, wmlist ) {
- QVector<SUIT_ViewWindow*> vwlist = wm->getViews();
-
- foreach( SUIT_ViewWindow* vw, vwlist ) {
- OCCViewer_ViewWindow* occVW = dynamic_cast<OCCViewer_ViewWindow*>( vw );
- if ( !occVW ) continue;
-
- // check only compatible types
- occVW = occVW->getView( viewWindow->get2dMode() );
- if ( occVW ) {
- if ( occVW->getId() == id )
- otherViewWindow = occVW;
- else if ( occVW != viewWindow )
- compatibleViews.append( occVW );
- }
- }
+ if ( get2dMode() == No2dMode ) {
+ aProps.setDimension( SUIT_CameraProperties::Dim3D );
}
-
- if ( isSync && id ) {
- // remove all possible disconnections
- foreach( OCCViewer_ViewWindow* vw, compatibleViews ) {
- // disconnect target view
- vw->getViewPort()->disconnect( SIGNAL( vpTransformed( OCCViewer_ViewPort* ) ), viewWindow->getViewPort(), SLOT( synchronize( OCCViewer_ViewPort* ) ) );
- viewWindow->getViewPort()->disconnect( SIGNAL( vpTransformed( OCCViewer_ViewPort* ) ), vw->getViewPort(), SLOT( synchronize( OCCViewer_ViewPort* ) ) );
- if ( otherViewWindow ) {
- // disconnect source view
- vw->getViewPort()->disconnect( SIGNAL( vpTransformed( OCCViewer_ViewPort* ) ), otherViewWindow->getViewPort(), SLOT( synchronize( OCCViewer_ViewPort* ) ) );
- otherViewWindow->getViewPort()->disconnect( SIGNAL( vpTransformed( OCCViewer_ViewPort* ) ), vw->getViewPort(), SLOT( synchronize( OCCViewer_ViewPort* ) ) );
- }
- QAction* a = vw->toolMgr()->action( SynchronizeId );
- if ( a ) {
- int anid = a->data().toInt();
- if ( a->isChecked() && ( anid == id || anid == vwid ) ) {
- bool blocked = a->blockSignals( true );
- a->setChecked( false );
- a->blockSignals( blocked );
- }
- }
- }
- if ( otherViewWindow ) {
- // reconnect source and target view
- otherViewWindow->getViewPort()->disconnect( SIGNAL( vpTransformed( OCCViewer_ViewPort* ) ), viewWindow->getViewPort(), SLOT( synchronize( OCCViewer_ViewPort* ) ) );
- viewWindow->getViewPort()->disconnect( SIGNAL( vpTransformed( OCCViewer_ViewPort* ) ), otherViewWindow->getViewPort(), SLOT( synchronize( OCCViewer_ViewPort* ) ) );
- otherViewWindow->getViewPort()->connect( viewWindow->getViewPort(), SIGNAL( vpTransformed( OCCViewer_ViewPort* ) ), SLOT( synchronize( OCCViewer_ViewPort* ) ) );
- viewWindow->getViewPort()->connect( otherViewWindow->getViewPort(), SIGNAL( vpTransformed( OCCViewer_ViewPort* ) ), SLOT( synchronize( OCCViewer_ViewPort* ) ) );
- // synchronize target view with source view
- viewWindow->getViewPort()->synchronize( otherViewWindow->getViewPort() );
- viewWindow->toolMgr()->action( SynchronizeId )->setData( otherViewWindow->getId() );
- QAction* anOtherAcion = otherViewWindow->toolMgr()->action( SynchronizeId );
- if (anOtherAcion) {
- anOtherAcion->setData( viewWindow->getId() );
- if ( !anOtherAcion->isChecked() ) {
- bool blocked = anOtherAcion->blockSignals( true );
- anOtherAcion->setChecked( true );
- anOtherAcion->blockSignals( blocked );
- }
- }
- }
- }
- else if ( otherViewWindow ) {
- // reconnect source and target view
- otherViewWindow->getViewPort()->disconnect( SIGNAL( vpTransformed( OCCViewer_ViewPort* ) ), viewWindow->getViewPort(), SLOT( synchronize( OCCViewer_ViewPort* ) ) );
- viewWindow->getViewPort()->disconnect( SIGNAL( vpTransformed( OCCViewer_ViewPort* ) ), otherViewWindow->getViewPort(), SLOT( synchronize( OCCViewer_ViewPort* ) ) );
- viewWindow->getViewPort()->synchronize( otherViewWindow->getViewPort() );
- viewWindow->toolMgr()->action( SynchronizeId )->setData( otherViewWindow->getId() );
- QAction* anOtherAcion = otherViewWindow->toolMgr()->action( SynchronizeId );
- if (anOtherAcion) {
- if ( anOtherAcion->data().toInt() == viewWindow->getId() && anOtherAcion->isChecked() ) {
- bool blocked = anOtherAcion->blockSignals( true );
- anOtherAcion->setChecked( false );
- anOtherAcion->blockSignals( blocked );
- }
- }
+ else {
+ aProps.setDimension( SUIT_CameraProperties::Dim2D );
+ aProps.setViewSide( (SUIT_CameraProperties::ViewSide)(int)get2dMode() );
}
+
+ // read common properites of the view
+ Standard_Real anUpDir[3];
+ Standard_Real aPrjDir[3];
+ Standard_Real aMapScale[2];
+ Standard_Real aTranslation[3];
+ Standard_Real anAxialScale[3];
+
+ aSourceView->Up(anUpDir[0], anUpDir[1], anUpDir[2]);
+ aSourceView->Proj(aPrjDir[0], aPrjDir[1], aPrjDir[2]);
+ aSourceView->At(aTranslation[0], aTranslation[1], aTranslation[2]);
+ aSourceView->Size(aMapScale[0], aMapScale[1]);
+
+ getViewPort()->getAxialScale(anAxialScale[0], anAxialScale[1], anAxialScale[2]);
+
+ // we use similar depth to the one used in perspective projection
+ // to proivde a convinience synchronization with other camera views that
+ // can switch between orthogonal & perspective projection. otherwise,
+ // the camera will get to close when switching from orthogonal to perspective.
+ Standard_Real aCameraDepth = aSourceView->Depth() + aSourceView->ZSize() * 0.5;
+
+ // store common props
+ aProps.setViewUp(anUpDir[0], anUpDir[1], anUpDir[2]);
+ aProps.setMappingScale(aMapScale[1] / 2.0);
+ aProps.setAxialScale(anAxialScale[0], anAxialScale[1], anAxialScale[2]);
+
+ // generate view orientation matrix for transforming OCC projection reference point
+ // into a camera (eye) position.
+ gp_Dir aLeftDir = gp_Dir(anUpDir[0], anUpDir[1], anUpDir[2]).Crossed(
+ gp_Dir(aPrjDir[0], aPrjDir[1], aPrjDir[2]));
+
+ gp_Trsf aTrsf;
+ aTrsf.SetValues( aLeftDir.X(), anUpDir[0], aPrjDir[0], aTranslation[0],
+ aLeftDir.Y(), anUpDir[1], aPrjDir[1], aTranslation[1],
+ aLeftDir.Z(), anUpDir[2], aPrjDir[2], aTranslation[2],
+ Precision::Confusion(),
+ Precision::Confusion() );
+
+ // get projection reference point in view coordinates
+ Graphic3d_Vertex aProjRef = aSourceView->ViewMapping().ProjectionReferencePoint();
+
+ // transform to world-space coordinate system
+ gp_Pnt aPosition = gp_Pnt(aProjRef.X(), aProjRef.Y(), aCameraDepth).Transformed(aTrsf);
+
+ // compute focal point
+ double aFocalPoint[3];
+
+ aFocalPoint[0] = aPosition.X() - aPrjDir[0] * aCameraDepth;
+ aFocalPoint[1] = aPosition.Y() - aPrjDir[1] * aCameraDepth;
+ aFocalPoint[2] = aPosition.Z() - aPrjDir[2] * aCameraDepth;
+
+ aProps.setFocalPoint(aFocalPoint[0], aFocalPoint[1], aFocalPoint[2]);
+ aProps.setPosition(aPosition.X(), aPosition.Y(), aPosition.Z());
+
+ return aProps;
}
/*!
- "Synchronize View" action slot.
+ Synchronize views.
+ This implementation synchronizes OCC view's camera propreties.
*/
-void OCCViewer_ViewWindow::onSynchronizeView(bool checked)
+void OCCViewer_ViewWindow::synchronize( SUIT_ViewWindow* theView )
{
- QAction* a = qobject_cast<QAction*>( sender() );
- if ( a ) {
- synchronizeView( this, a->data().toInt() );
- }
-}
+ bool blocked = blockSignals( true );
-/*!
- Update list of available view for the "Synchronize View" action
-*/
-void OCCViewer_ViewWindow::updateSyncViews()
-{
- QAction* anAction = toolMgr()->action( SynchronizeId );
- if ( anAction && anAction->menu() ) {
- int currentId = anAction->data().toInt();
- anAction->menu()->clear();
- SUIT_Application* app = SUIT_Session::session()->activeApplication();
- if ( app ) {
- QList<SUIT_ViewManager*> wmlist;
- app->viewManagers( getViewManager()->getType(), wmlist );
- foreach( SUIT_ViewManager* wm, wmlist ) {
- QVector<SUIT_ViewWindow*> vwlist = wm->getViews();
- foreach ( SUIT_ViewWindow* vw, vwlist ) {
- OCCViewer_ViewWindow* occVW = dynamic_cast<OCCViewer_ViewWindow*>( vw );
- if ( !occVW || occVW == this ) continue;
- // list only compatible types
- OCCViewer_ViewWindow* subWindow = occVW->getView( get2dMode() );
- if ( subWindow && subWindow != this ) {
- QAction* a = anAction->menu()->addAction( occVW->windowTitle() );
- if ( subWindow->getId() == currentId ) {
- QFont f = a->font();
- f.setBold( true );
- a->setFont( f );
- }
- a->setData( subWindow->getId() );
- connect( a, SIGNAL( triggered(bool) ), this, SLOT( onSynchronizeView(bool) ) );
- }
- }
- }
- }
- if ( anAction->menu()->actions().isEmpty() ) {
- anAction->setData( 0 );
- anAction->menu()->addAction( tr( "MNU_SYNC_NO_VIEW" ) );
- }
+ SUIT_CameraProperties aProps = theView->cameraProperties();
+ if ( !cameraProperties().isCompatible( aProps ) ) {
+ // other view, this one is being currently synchronized to, seems has become incompatible
+ // we have to break synchronization
+ updateSyncViews();
+ return;
}
+
+ Handle(V3d_View) aDestView = getViewPort()->getView();
+
+ aDestView->SetImmediateUpdate( Standard_False );
+
+ double anUpDir[3];
+ double aPosition[3];
+ double aFocalPoint[3];
+ double aMapScaling;
+ double anAxialScale[3];
+
+ // get common properties
+ aProps.getFocalPoint(aFocalPoint[0], aFocalPoint[1], aFocalPoint[2]);
+ aProps.getPosition(aPosition[0], aPosition[1], aPosition[2]);
+ aProps.getViewUp(anUpDir[0], anUpDir[1], anUpDir[2]);
+ aProps.getAxialScale(anAxialScale[0], anAxialScale[1], anAxialScale[2]);
+ aMapScaling = aProps.getMappingScale() * 2.0;
+
+ gp_Dir aProjDir(aPosition[0] - aFocalPoint[0],
+ aPosition[1] - aFocalPoint[1],
+ aPosition[2] - aFocalPoint[2]);
+
+ // get custom view translation
+ Standard_Real aTranslation[3];
+ aDestView->At(aTranslation[0], aTranslation[1], aTranslation[2]);
+
+ gp_Dir aLeftDir = gp_Dir(anUpDir[0], anUpDir[1], anUpDir[2]).Crossed(
+ gp_Dir(aProjDir.X(), aProjDir.Y(), aProjDir.Z()));
+
+ // convert camera position into a view reference point
+ gp_Trsf aTrsf;
+ aTrsf.SetValues( aLeftDir.X(), anUpDir[0], aProjDir.X(), aTranslation[0],
+ aLeftDir.Y(), anUpDir[1], aProjDir.Y(), aTranslation[1],
+ aLeftDir.Z(), anUpDir[2], aProjDir.Z(), aTranslation[2],
+ Precision::Confusion(),
+ Precision::Confusion() );
+ aTrsf.Invert();
+
+ // transform to view-space coordinate system
+ gp_Pnt aProjRef(aPosition[0], aPosition[1], aPosition[2]);
+ aProjRef.Transform(aTrsf);
+
+ // set view camera properties using low-level approach. this is done
+ // in order to avoid interference with static variables in v3d view used
+ // when rotation is in process in another view.
+ Visual3d_ViewMapping aMapping = aDestView->View()->ViewMapping();
+ Visual3d_ViewOrientation anOrientation = aDestView->View()->ViewOrientation();
+
+ Graphic3d_Vector aMappingProj(aProjDir.X(), aProjDir.Y(), aProjDir.Z());
+ Graphic3d_Vector aMappingUp(anUpDir[0], anUpDir[1], anUpDir[2]);
+
+ aMappingProj.Normalize();
+ aMappingUp.Normalize();
+
+ anOrientation.SetViewReferencePlane(aMappingProj);
+ anOrientation.SetViewReferenceUp(aMappingUp);
+
+ aDestView->SetViewMapping(aMapping);
+ aDestView->SetViewOrientation(anOrientation);
+
+ // set panning
+ aDestView->SetCenter(aProjRef.X(), aProjRef.Y());
+
+ // set mapping scale
+ Standard_Real aWidth, aHeight;
+ aDestView->Size(aWidth, aHeight);
+
+ if ( aWidth > aHeight )
+ aDestView->SetSize (aMapScaling * (aWidth / aHeight));
+ else
+ aDestView->SetSize (aMapScaling);
+
+ getViewPort()->setAxialScale(anAxialScale[0], anAxialScale[1], anAxialScale[2]);
+
+ aDestView->ZFitAll();
+ aDestView->SetImmediateUpdate( Standard_True );
+ aDestView->Redraw();
+
+ blockSignals( blocked );
}
virtual void updateViewAspects( const viewAspectList& );
virtual void clearViewAspects();
+ virtual SUIT_CameraProperties cameraProperties();
+
public slots:
virtual void onFrontView();
virtual void onViewFitAll();
void Hide( QHideEvent * );
void maximized( OCCViewer_ViewWindow*, bool );
+protected slots:
+ void synchronize( SUIT_ViewWindow* );
+
public:
virtual QImage dumpView();
virtual bool dumpViewToFormat( const QImage&, const QString& fileName, const QString& format );
double myCurScale;
-private slots:
- void onSynchronizeView(bool);
- void updateSyncViews();
-
-private:
- static void synchronizeView( OCCViewer_ViewWindow*, int );
-
private:
OCCViewer_ClippingDlg* myClippingDlg;
QtxAction* myClippingAction;
<source>ICON_OCCVIEWER_MINIMIZE</source>
<translation>occ_view_minimized.png</translation>
</message>
- <message>
- <source>ICON_OCCVIEWER_SYNC</source>
- <translation>occ_view_sync.png</translation>
- </message>
</context>
</TS>
<source>DSC_MINIMIZE_VIEW</source>
<translation>Minimize view</translation>
</message>
- <message>
- <source>DSC_SYNCHRONIZE_VIEW</source>
- <translation>Synchronize view</translation>
- </message>
<message>
<source>MNU_MAXIMIZE_VIEW</source>
<translation>Maximize</translation>
<source>MNU_MINIMIZE_VIEW</source>
<translation>Minimize</translation>
</message>
- <message>
- <source>MNU_SYNCHRONIZE_VIEW</source>
- <translation>Synchronize</translation>
- </message>
- <message>
- <source>MNU_SYNC_NO_VIEW</source>
- <translation>[ No appropriate view ]</translation>
- </message>
</context>
<context>
<name>OCCViewer_CreateRestoreViewDlg</name>
<source>DSC_MINIMIZE_VIEW</source>
<translation>Minimiser la vue</translation>
</message>
- <message>
- <source>DSC_SYNCHRONIZE_VIEW</source>
- <translation>Synchroniser la vue</translation>
- </message>
<message>
<source>MNU_MAXIMIZE_VIEW</source>
<translation>Maximiser</translation>
<source>MNU_MINIMIZE_VIEW</source>
<translation>Minimiser</translation>
</message>
- <message>
- <source>MNU_SYNCHRONIZE_VIEW</source>
- <translation>Synchroniser</translation>
- </message>
- <message>
- <source>MNU_SYNC_NO_VIEW</source>
- <translation>[ Pas de vue appropriée ]</translation>
- </message>
</context>
<context>
<name>OCCViewer_CreateRestoreViewDlg</name>
}
myIntermittentSegmentList.clear();
}
-
- // 2)- Erase all curves points markers
-
- int nbMark = myMarkerList.size();
- if (nbMark > 0)
- {
- for (int imar=0; imar < nbMark; imar++)
- {
- QwtPlotMarker *marker = myMarkerList[imar];
-
- marker->detach(); // erase in QwtPlot window
- delete marker;
- }
- myMarkerList.clear();
- }
-
- // The graphic view's picker
- Plot2d_QwtPlotPicker *picker = myPlot->getPicker();
-
- // Clear points markers list and associations (marker,tooltip)
- if ( picker ) {
- picker->pMarkers.clear(); // QList<QwtPlotMarker*>
- picker->pMarkersToolTip.clear(); // QMap<QwtPlotMarker*, QwtText>
- }
-
+
// 3)- Erase all QwtPlotCurve associated with the Plot2d_Curve
int nbCur1 = myQwtPlotCurveList.size();
double xmin, xmax, y1min, y1max, y2min, y2max;
getFitRangeByCurves(xmin, xmax, y1min, y1max, y2min, y2max);
+ getFitRangeByMarkers(xmin, xmax, y1min, y1max, y2min, y2max);
myPlot->setAxisScale( QwtPlot::xBottom, xmin, xmax );
myPlot->setAxisScale( QwtPlot::yLeft, y1min, y1max );
}
}
+/*!
+ Gets current fit ranges by Markers
+ All parameters are inout.
+*/
+void Plot2d_ViewFrame::getFitRangeByMarkers(double& xMin, double& xMax,
+ double& yMin, double& yMax,
+ double& y2Min, double& y2Max)
+{
+ Plot2d_QwtPlotPicker *picker=myPlot->getPicker();
+ if(!picker)
+ return;
+ if(picker->pMarkers.empty())
+ return;
+ foreach(QwtPlotMarker *mrker,picker->pMarkers)
+ {
+ bool isV2 = mrker->yAxis() == QwtPlot::yRight;
+ xMin = qMin( xMin, mrker->xValue() );
+ xMax = qMax( xMax, mrker->xValue() );
+ if ( isV2 ) {
+ y2Min = qMin( y2Min, mrker->yValue() );
+ y2Max = qMax( y2Max, mrker->yValue() );
+ }
+ else {
+ yMin = qMin( yMin, mrker->yValue() );
+ yMax = qMax( yMax, mrker->yValue() );
+ }
+ if ( xMin == xMax ) {
+ xMin = xMin == 0. ? -1. : xMin - xMin/10.;
+ xMax = xMax == 0. ? 1. : xMax + xMax/10.;
+ }
+ if ( yMin == yMax ) {
+ yMin = yMin == 0. ? -1. : yMin - yMin/10.;
+ yMax = yMax == 0. ? 1 : yMax + yMax/10.;
+ }
+ if ( y2Min == y2Max ) {
+ y2Min = y2Min == 0. ? -1. : y2Min - y2Min/10.;
+ y2Max = y2Max == 0. ? 1 : y2Max + y2Max/10.;
+ }
+ }
+}
+
/*!
Tests if it is necessary to start operation on mouse action
*/
*/
Plot2d_Plot2d::Plot2d_Plot2d( QWidget* parent )
: QwtPlot( parent ),
- myIsPolished( false )
+ myIsPolished( false ),
+ myPicker( 0 )
{
// Create alternative scales
setAxisScaleDraw( QwtPlot::yLeft, new Plot2d_ScaleDraw() );
*/
QwtText Plot2d_QwtPlotPicker::trackerText( const QwtDoublePoint & pos ) const
{
- for (QList<QwtPlotMarker* >::const_iterator pMarkerIt = pMarkers.begin();
- pMarkerIt != pMarkers.end();
- ++pMarkerIt )
- {
+ for (QList<QwtPlotMarker* >::const_iterator pMarkerIt = pMarkers.begin();pMarkerIt != pMarkers.end(); ++pMarkerIt )
+ {
QwtPlotMarker* pMarker = *pMarkerIt;
if ( pMarker != NULL )
- {
- QwtDoubleRect bound0 = pMarker->boundingRect();
- QwtDoublePoint center_bound0 = bound0.center();
- double left = center_bound0.x()-(BOUND_HV_SIZE/2.);
- double top = center_bound0.y()-(BOUND_HV_SIZE/2.);
-
- QwtDoubleRect bound( left, top , BOUND_HV_SIZE, BOUND_HV_SIZE);
-
- if( bound.contains(pos) )
- {
- //QString toolTip = "X=" + QString::number( pMarker->xValue() )
- // + " Y=" + QString::number( pMarker->yValue() );
- return pMarkersToolTip[pMarker];
- }
- }
+ {
+ const QwtSymbol &symb=pMarker->symbol();
+ const QSize& sz=symb.size();
+ const QwtScaleMap yMapRef=plot()->canvasMap(QwtPlot::yLeft);
+ const QwtScaleMap xMap=plot()->canvasMap(pMarker->xAxis());
+ const QwtScaleMap yMap=plot()->canvasMap(pMarker->yAxis());
+ QwtDoubleRect bound0=pMarker->boundingRect();
+ QRect bound00=pMarker->transform(xMap,yMap,bound0);
+ QPoint toto(xMap.transform(pos.x()),yMapRef.transform(pos.y()));
+ bound00.setX(bound00.x()-sz.width());
+ bound00.setY(bound00.y()-sz.height());
+ bound00.setWidth(bound00.width()+sz.width());
+ bound00.setHeight(bound00.height()+sz.height());
+ if( bound00.contains(toto) )
+ {
+ return pMarkersToolTip[pMarker];
+ }
+ }
}
-
return QwtText();
}
void getFitRangeByCurves( double&, double&, double&, double&,
double&, double& );
+ void getFitRangeByMarkers(double&, double&, double&, double&,
+ double&, double& );
+
void addAnalyticalCurve( Plot2d_AnalyticalCurve* );
void removeAnalyticalCurve( Plot2d_AnalyticalCurve* );
void updateAnalyticalCurve( Plot2d_AnalyticalCurve*, bool = false );
// List of intermittent segments to connect curves
QList<QwtPlotCurve*> myIntermittentSegmentList;
- // List of markers associated with curves points
- QList<QwtPlotMarker*> myMarkerList;
-
// List of curves Plot2d_Curve
QList<Plot2d_Curve*> myPlot2dCurveList;
};
myOpaque( true ),
myResizer( 0 ),
myMouseMove( 0 ),
- myFullScreenAllowed(true)
+ myFullScreenAllowed(true),
+ myMinimizeAllowed(true)
{
//rnv: Enables tooltips for inactive windows.
//rnv: For details see http://bugtracker.opencascade.com/show_bug.cgi?id=20893
state = QString( "max" );
break;
case Qt::WindowMinimized:
- state = QString( "min" );
+ if ( isMinimizeAllowed() ) state = QString( "min" );
break;
case Qt::WindowFullScreen:
state = isFullScreenAllowed() ? QString( "full" ) : QString( "max" );
if ( stRx.indexIn( geom ) != -1 )
{
QString stStr = stRx.cap( 1 ).trimmed().toLower();
- if ( stStr.startsWith( QString( "max" ) ) )
+ if ( stStr.startsWith( QString( "max" ) ) ) {
state = Qt::WindowMaximized;
- else if ( stStr.startsWith( QString( "min" ) ) )
- state = Qt::WindowMinimized;
- else if ( stStr.startsWith( QString( "full" ) ) )
- state = Qt::WindowFullScreen;
+ }
+ else if ( stStr.startsWith( QString( "min" ) ) ) {
+ if ( isMinimizeAllowed() )
+ state = Qt::WindowMinimized;
+ }
+ else if ( stStr.startsWith( QString( "full" ) ) ) {
+ state = isFullScreenAllowed() ? Qt::WindowFullScreen : Qt::WindowMaximized;
+ }
}
resize( rect.size() );
/*!
\brief FullScreenAllowed flag allowed dump in the main window geometry
Qt::WindowFullScreen parameter.
- \return \c fullScreenAllowed flag.
+ \return \c FullScreenAllowed flag.
*/
bool QtxMainWindow::isFullScreenAllowed() const {
return myFullScreenAllowed;
/*!
\brief Set FullScreenAllowed flag.
The default value is true.
- \param f value of the fullScreenAllowed flag.
+ \param f value of the FullScreenAllowed flag.
*/
void QtxMainWindow::setFullScreenAllowed( const bool f ) {
myFullScreenAllowed = f;
}
+
+/*!
+ \brief MinimizeAllowed flag allowed dump in the main window geometry
+ Qt::WindowMinimized parameter.
+ \return \c MinimizeAllowed flag.
+*/
+bool QtxMainWindow::isMinimizeAllowed() const {
+ return myMinimizeAllowed;
+}
+
+
+/*!
+ \brief Set MinimizeAllowed flag.
+ The default value is true.
+ \param f value of the MinimizeAllowed flag.
+*/
+void QtxMainWindow::setMinimizeAllowed( const bool f ) {
+ myMinimizeAllowed = f;
+}
bool isFullScreenAllowed() const;
void setFullScreenAllowed( const bool );
+ bool isMinimizeAllowed() const;
+ void setMinimizeAllowed( const bool );
+
protected:
virtual bool event( QEvent* );
QToolBar* myStatusBar; //!< dockable status bar
bool myFullScreenAllowed;
+ bool myMinimizeAllowed;
bool myOpaque;
Resizer* myResizer;
*/
bool QtxPopupMgr::hasRule( QAction* a, const RuleType t ) const
{
- return a ? expression( a, t, false ) : false;
+ return a ? expression( a, t, false )!=0 : false;
}
/*!
include $(top_srcdir)/adm_local/unix/make_common_starter.am
# extra source files (generated by sip)
-SIP_SRC = sipAPISalomePyQt.h \
- sipSalomePyQtSalomePyQt.cc \
+SIP_API = sipAPISalomePyQt.h
+SIP_SRC = sipSalomePyQtSalomePyQt.cc \
sipSalomePyQtSALOME_Selection.cc \
sipSalomePyQtQtxAction.cc \
sipSalomePyQtQtxActionGroup.cc \
EXTRA_DIST += $(SIP_FILES)
# extra clean files
-CLEANFILES = $(SIP_SRC)
+CLEANFILES = $(SIP_SRC) $(SIP_API)
# moc files (generated my moc)
MOC_FILES = SalomePyQt_moc.cxx
libSalomePyQt_la_LIBADD = $(COMMON_LIBS)
# custom build step: generate C++ wrapping according to $(SIP_FILES)
-$(SIP_SRC): $(SIP_FILES)
+$(SIP_SRC): $(SIP_API)
+
+$(SIP_API): $(SIP_FILES)
$(SIP) $(PYQT_SIPFLAGS) $<
# custom install step: create symbolic link
SUIT_ViewModel.h
SUIT_ViewWindow.h
SUIT_ShortcutMgr.h
+ SUIT_CameraProperties.h
)
QT4_WRAP_CPP(GUI_HEADERS_MOC ${GUI_HEADERS})
SUIT_ViewModel.cxx
SUIT_ViewWindow.cxx
SUIT_ShortcutMgr.cxx
+ SUIT_CameraProperties.cxx
)
SET(GUITS_SOURCES
resources/SUIT_msg_en.ts
# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
#
-# File : Makefile.in
-# Author : Vladimir Klyachin (OCN)
-# Module : suit
-# $Header$
-#
include $(top_srcdir)/adm_local/unix/make_common_starter.am
lib_LTLIBRARIES = libsuit.la
SUIT_ViewManager.h \
SUIT_ViewModel.h \
SUIT_ViewWindow.h \
- SUIT_ShortcutMgr.h
+ SUIT_ShortcutMgr.h \
+ SUIT_CameraProperties.h
dist_libsuit_la_SOURCES = \
SUIT_Accel.cxx \
SUIT_ViewManager.cxx \
SUIT_ViewModel.cxx \
SUIT_ViewWindow.cxx \
- SUIT_ShortcutMgr.cxx
+ SUIT_ShortcutMgr.cxx \
+ SUIT_CameraProperties.cxx
MOC_FILES = \
SUIT_Accel_moc.cxx \
SUIT_msg_en.qm \
SUIT_msg_fr.qm \
SUIT_images.qm
-
+
dist_salomeres_DATA = \
resources/icon_visibility_on.png \
- resources/icon_visibility_off.png
-
+ resources/icon_visibility_off.png \
+ resources/view_sync.png
libsuit_la_CPPFLAGS = $(QT_INCLUDES) -I$(srcdir)/../Qtx -I$(srcdir)/../ObjBrowser
--- /dev/null
+// Copyright (C) 2007-2012 CEA/DEN, EDF R&D, OPEN CASCADE
+//
+// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+
+#include "SUIT_CameraProperties.h"
+
+/*!
+ \class SUIT_CameraProperties
+ \brief Base class for Camera Properties
+
+ This class provides common properties that
+ can be used for any arbitrary camera. This
+ properties are employed by camera synchronization
+ algorithms.
+*/
+
+/*!
+ \brief Default constructor.
+
+ Creates invalid camera properties data, i.e. IsValid() returns \c false.
+*/
+SUIT_CameraProperties::SUIT_CameraProperties()
+{
+ // init with some default values
+ myUpDir[0] = 0.0;
+ myUpDir[1] = 1.0;
+ myUpDir[2] = 0.0;
+
+ myPosition[0] = 0.0;
+ myPosition[1] = 0.0;
+ myPosition[2] = 500.0;
+
+ myFocalPoint[0] = 0.0;
+ myFocalPoint[1] = 0.0;
+ myFocalPoint[2] = 0.0;
+
+ myAxialScale[0] = 1.0;
+ myAxialScale[1] = 1.0;
+ myAxialScale[2] = 1.0;
+
+ myMappingScale = 1000;
+
+ myDimension = DimNone; // none dimension by default
+ myProjection = PrjOrthogonal; // orthogonal projection by default
+ myViewSide = ViewNone; // no side view by default
+
+ myViewAngle = 45.0;
+}
+
+/*!
+ \brief Destructor
+*/
+SUIT_CameraProperties::~SUIT_CameraProperties()
+{
+}
+
+/*!
+ \brief Check if camera properties are valid.
+ \return \c true if camera properties data is valid.
+ \sa setDimension()
+*/
+bool SUIT_CameraProperties::isValid() const
+{
+ return myDimension != DimNone;
+}
+
+/*!
+ \brief Check if this camera properties data is compatible with other camera properties.
+ \param other other properties data
+ \return \c true if both camera properties sets are compatible
+*/
+bool SUIT_CameraProperties::isCompatible( const SUIT_CameraProperties& other )
+{
+ bool result = false;
+ // check only valid data and data with same dimensions
+ if ( isValid() && other.isValid() && getDimension() == other.getDimension() ) {
+ switch( getDimension() ) {
+ case SUIT_CameraProperties::Dim2D:
+ // two 2d views are compatible if their view side is the same
+ result = getViewSide() == other.getViewSide();
+ break;
+ case SUIT_CameraProperties::Dim3D:
+ // two 3d views are compatible if their projection mode is the same
+ result = getProjection() == other.getProjection();
+ break;
+ default:
+ break;
+ }
+ }
+ return result;
+}
+
+/*!
+ \brief get dimension supported by camera.
+ \return dimension mode.
+ \sa setDimension()
+*/
+SUIT_CameraProperties::Dimension SUIT_CameraProperties::getDimension() const
+{
+ return myDimension;
+}
+
+/*!
+ \brief set dimension supported by camera.
+ \param theDimension [in] dimension mode.
+ \sa getDimension()
+*/
+void SUIT_CameraProperties::setDimension( const SUIT_CameraProperties::Dimension theDimension )
+{
+ myDimension = theDimension;
+}
+
+/*!
+ \brief get side view supported by camera (for 2d viewer).
+
+ For 2d viewer, side view can be of following values:
+ - SUIT_CameraProperties::ViewNone - no side view (for instance, for true 2d viewer)
+ - SUIT_CameraProperties::ViewXY - XY side view of 3d scene
+ - SUIT_CameraProperties::ViewXZ - XZ side view of 3d scene
+ - SUIT_CameraProperties::ViewYZ - YZ side view of 3d scene
+
+ \return side view.
+ \sa setViewSide()
+*/
+SUIT_CameraProperties::ViewSide SUIT_CameraProperties::getViewSide() const
+{
+ return myViewSide;
+}
+
+/*!
+ \brief set side view supported by camera (for 2d viewer).
+
+ For 2d viewer, side view can be of following values:
+ - SUIT_CameraProperties::ViewNone - no side view (for instance, for true 2d viewer)
+ - SUIT_CameraProperties::ViewXY - XY side view of 3d scene
+ - SUIT_CameraProperties::ViewXZ - XZ side view of 3d scene
+ - SUIT_CameraProperties::ViewYZ - YZ side view of 3d scene
+
+ \param theViewSide [in] view side.
+ \sa getViewSide()
+*/
+void SUIT_CameraProperties::setViewSide( const SUIT_CameraProperties::ViewSide theViewSide )
+{
+ myViewSide = theViewSide;
+}
+
+/*!
+ \brief get projection mode supported by camera (for 3d viewer).
+
+ For 3d viewer, projection mode can be of following values:
+ - SUIT_CameraProperties::PrjOrthogonal - orthogonal projection
+ - SUIT_CameraProperties::PrjPerspective - perspective projection
+
+ \return projection mode.
+ \sa setProjection()
+*/
+SUIT_CameraProperties::Projection SUIT_CameraProperties::getProjection() const
+{
+ return myProjection;
+}
+
+/*!
+ \brief set projection mode supported by camera (for 3d viewer).
+
+ For 3d viewer, projection mode can be of following values:
+ - SUIT_CameraProperties::PrjOrthogonal - orthogonal projection
+ - SUIT_CameraProperties::PrjPerspective - perspective projection
+
+ \param theProjection [in] projection mode.
+ \sa getProjection()
+*/
+void SUIT_CameraProperties::setProjection( const SUIT_CameraProperties::Projection theProjection )
+{
+ myProjection = theProjection;
+}
+
+/*!
+ \brief get camera up direction vector.
+ \param theX [out] vector's x coordinate in world-coordinates space.
+ \param theY [out] vector's y coordinate in world-coordinates space.
+ \param theZ [out] vector's z coordinate in world-coordinates space.
+ \sa setViewUp()
+*/
+void SUIT_CameraProperties::getViewUp(double& theX, double& theY, double& theZ) const
+{
+ theX = myUpDir[0];
+ theY = myUpDir[1];
+ theZ = myUpDir[2];
+}
+
+/*!
+ \brief set camera up direction vector.
+
+ It is recommended to set normalized vector coordinates for
+ synchronization compatibility.
+
+ \param theX [in] vector's x coordinate in world-coordinates space.
+ \param theY [in] vector's y coordinate in world-coordinates space.
+ \param theZ [in] vector's z coordinate in world-coordinates space.
+ \sa getViewUp()
+*/
+void SUIT_CameraProperties::setViewUp(const double theX, const double theY, const double theZ)
+{
+ myUpDir[0] = theX;
+ myUpDir[1] = theY;
+ myUpDir[2] = theZ;
+}
+
+/*!
+ \brief get camera's position (eye).
+ \param theX [out] x coordinate in world-coordinates space.
+ \param theY [out] y coordinate in world-coordinates space.
+ \param theZ [out] z coordinate in world-coordinates space.
+ \sa setPosition()
+*/
+void SUIT_CameraProperties::getPosition(double& theX, double& theY, double& theZ) const
+{
+ theX = myPosition[0];
+ theY = myPosition[1];
+ theZ = myPosition[2];
+}
+
+/*!
+ \brief get camera's position (eye).
+ \param theX [in] x coordinate in world-coordinates space.
+ \param theY [in] y coordinate in world-coordinates space.
+ \param theZ [in] z coordinate in world-coordinates space.
+ \sa getPosition()
+*/
+void SUIT_CameraProperties::setPosition(const double theX, const double theY, const double theZ)
+{
+ myPosition[0] = theX;
+ myPosition[1] = theY;
+ myPosition[2] = theZ;
+}
+
+/*!
+ \brief get camera's focal point (look point).
+ \param theX [out] x coordinate in world-coordinates space.
+ \param theY [out] y coordinate in world-coordinates space.
+ \param theZ [out] z coordinate in world-coordinates space.
+ \sa setFocalPoint()
+*/
+void SUIT_CameraProperties::getFocalPoint(double& theX, double& theY, double& theZ) const
+{
+ theX = myFocalPoint[0];
+ theY = myFocalPoint[1];
+ theZ = myFocalPoint[2];
+}
+
+/*!
+ \brief set camera's focal point (look point).
+ \param theX [in] x coordinate in world-coordinates space.
+ \param theY [in] y coordinate in world-coordinates space.
+ \param theZ [in] z coordinate in world-coordinates space.
+ \sa getFocalPoint()
+*/
+void SUIT_CameraProperties::setFocalPoint(const double theX, const double theY, const double theZ)
+{
+ myFocalPoint[0] = theX;
+ myFocalPoint[1] = theY;
+ myFocalPoint[2] = theZ;
+}
+
+/*!
+ \brief get window mapping scale (parallel scale).
+
+ Mapping scale defines a mapping scaling factor for the height
+ of the viewport in world-coordinate distances.
+
+ \return scaling value.
+ \sa setMappingScale()
+*/
+double SUIT_CameraProperties::getMappingScale() const
+{
+ return myMappingScale;
+}
+
+/*!
+ \brief set window mapping scale (parallel scale).
+
+ Mapping scale defines a mapping scaling factor for the height
+ of the viewport in world-coordinate distances.
+
+ \param theScale [in] the scaling.
+ \sa getMappingScale()
+*/
+void SUIT_CameraProperties::setMappingScale(const double theScale)
+{
+ myMappingScale = theScale;
+}
+
+/*!
+ \brief get scaling factors for world-coordinate space axes.
+ \param theScaleX [out] scale by x coordinate.
+ \param theScaleY [out] scale by y coordinate.
+ \param theScaleZ [out] scale by z coordinate.
+ \sa setAxialScale()
+*/
+void SUIT_CameraProperties::getAxialScale(double& theScaleX, double& theScaleY, double& theScaleZ)
+{
+ theScaleX = myAxialScale[0];
+ theScaleY = myAxialScale[1];
+ theScaleZ = myAxialScale[2];
+}
+
+/*!
+ \brief set scaling factors for world-coordinate space axes.
+ \param theScaleX [in] scale by x coordinate.
+ \param theScaleY [in] scale by y coordinate.
+ \param theScaleZ [in] scale by z coordinate.
+ \sa getAxialScale()
+*/
+void SUIT_CameraProperties::setAxialScale(const double theScaleX, const double theScaleY, const double theScaleZ)
+{
+ myAxialScale[0] = theScaleX;
+ myAxialScale[1] = theScaleY;
+ myAxialScale[2] = theScaleZ;
+}
+
+/*!
+ \brief get angle (typically in degrees) of view for perpective projection mode.
+ \return the angle of view.
+ \sa setViewAngle()
+*/
+double SUIT_CameraProperties::getViewAngle() const
+{
+ return myViewAngle;
+}
+
+/*!
+ \brief set angle (typically in degrees) of view for perpective projection mode.
+ \param theViewAngle [in] the angle of view.
+ \sa getViewAngle()
+*/
+void SUIT_CameraProperties::setViewAngle(const double theViewAngle)
+{
+ myViewAngle = theViewAngle;
+}
--- /dev/null
+// Copyright (C) 2007-2012 CEA/DEN, EDF R&D, OPEN CASCADE
+//
+// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+
+#ifndef SUIT_CAMERAPROPERITES_H
+#define SUIT_CAMERAPROPERITES_H
+
+#include "SUIT.h"
+
+class SUIT_EXPORT SUIT_CameraProperties
+{
+public:
+ enum Dimension { DimNone, Dim2D, Dim3D };
+ enum ViewSide { ViewNone, ViewXY, ViewXZ, ViewYZ };
+ enum Projection { PrjOrthogonal, PrjPerspective };
+
+ SUIT_CameraProperties();
+ virtual ~SUIT_CameraProperties();
+
+ bool isValid() const;
+ bool isCompatible( const SUIT_CameraProperties& other );
+
+ Dimension getDimension() const;
+ void setDimension( const Dimension theDimension );
+
+ ViewSide getViewSide() const;
+ void setViewSide( const ViewSide theViewSide );
+
+ Projection getProjection() const;
+ void setProjection( const Projection theProjection );
+
+ void getViewUp(double& theX, double& theY, double& theZ) const;
+ void setViewUp(const double theX, const double theY, const double theZ);
+
+ void getPosition(double& theX, double& theY, double& theZ) const;
+ void setPosition(const double theX, const double theY, const double theZ);
+
+ void getFocalPoint(double& theX, double& theY, double& theZ) const;
+ void setFocalPoint(const double theX, const double theY, const double theZ);
+
+ double getMappingScale() const;
+ void setMappingScale(const double theScale);
+
+ void getAxialScale(double& theScaleX, double& theScaleY, double& theScaleZ);
+ void setAxialScale(const double theScaleX, const double theScaleY, const double theScaleZ);
+
+ double getViewAngle() const;
+ void setViewAngle(const double theViewAngle);
+
+// common properties for all viewers
+private:
+ Dimension myDimension; //!< dimension
+ ViewSide myViewSide; //!< side view (for 2d viewer)
+ Projection myProjection; //!< projection mode (for 3d viewer): orthogonal / perspective
+ double myUpDir[3]; //!< camera up vector
+ double myPosition[3]; //!< camera position (eye).
+ double myFocalPoint[3]; //!< focal point position in world-space coordinates
+ double myMappingScale; //!< window mapping scale (parallel projection scale)
+ double myAxialScale[3]; //!< scaling factors for world axes
+ double myViewAngle; //!< perspective view angle in degrees
+};
+
+#endif // SUIT_CAMERAPROPERITES_H
while ( QApplication::overrideCursor() )
QApplication::restoreOverrideCursor();
-
+
+ cleanUp();
+
SUIT_MessageBox::critical( 0, title, msg );
}
+
+CleanUpFuncList SUIT_ExceptionHandler::myCleanUpFunctions;
+
+void SUIT_ExceptionHandler::addCleanUpRoutine(CleanUpFunction p)
+{
+ myCleanUpFunctions.append(p);
+}
+
+void SUIT_ExceptionHandler::removeCleanUpRoutine(CleanUpFunction p)
+{
+ myCleanUpFunctions.removeAll(p);
+}
+
+void SUIT_ExceptionHandler::cleanUp()
+{
+ foreach( QtCleanUpFunction f, myCleanUpFunctions )
+ {
+ f();
+ }
+}
#define SUIT_EXCEPTIONHANDLER_H
#include "SUIT.h"
+#include <QList>
class QEvent;
class QObject;
class QString;
+typedef void (*CleanUpFunction)();
+typedef QList<CleanUpFunction> CleanUpFuncList;
+
class SUIT_EXPORT SUIT_ExceptionHandler
{
public:
+ static void addCleanUpRoutine(CleanUpFunction p);
+ static void removeCleanUpRoutine(CleanUpFunction p);
+
virtual bool handle( QObject*, QEvent* );
protected:
bool internalHandle( QObject*, QEvent* );
void showMessage( const QString&, const QString& );
+
+private:
+ void cleanUp();
+
+ static CleanUpFuncList myCleanUpFunctions;
};
extern "C"
#include "SUIT_ViewWindow.h"
#include "SUIT_Tools.h"
+#include "SUIT_Session.h"
#include "SUIT_Study.h"
#include "SUIT_Desktop.h"
#include "SUIT_MessageBox.h"
#include "SUIT_Application.h"
#include "SUIT_ViewManager.h"
+#include "SUIT_ResourceMgr.h"
#include "QtxActionToolMgr.h"
#include "QtxMultiAction.h"
#include <QEvent>
#include <QIcon>
+#include <QMenu>
#include <QApplication>
#include <QContextMenuEvent>
/*! Constructor.*/
SUIT_ViewWindow::SUIT_ViewWindow( SUIT_Desktop* theDesktop )
- : QMainWindow( theDesktop ), myManager( 0 ), myIsDropDown( true )
+ : QMainWindow( theDesktop ), myManager( 0 ), myIsDropDown( true ), mySyncAction( 0 )
{
myDesktop = theDesktop;
}
/*!
- \brief Set buttons mode to drop-down (\a on = \c true) or ligned (\a on = \c false)
+ \brief Set buttons mode to drop-down (\a on = \c true) or ligned (\a on = \c false)
\param on new buttons mode
\sa dropDownButtons()
*/
}
/*!
- \return window unique identifier
+ \return window unique identifier
*/
int SUIT_ViewWindow::getId() const
{
return int(long(this));
}
+
+/*!
+ Get camera properties for the view window.
+ \return shared pointer on camera properties. Base implementation
+ returns null properties.
+*/
+SUIT_CameraProperties SUIT_ViewWindow::cameraProperties()
+{
+ return SUIT_CameraProperties();
+}
+
+/*!
+ Synchronize this view window's camera properties with specified
+ view window.
+
+ This method is a part of general views synchronization mechanism.
+ It should be redefined in successors. Base imlementation does nothing.
+
+ \param otherWindow other view window
+*/
+void SUIT_ViewWindow::synchronize( SUIT_ViewWindow* /*otherWindow*/ )
+{
+ // base implementation does nothing
+}
+
+/*!
+ Get action for views syncronization.
+
+ This method is a part of general views synchronization mechanism.
+ It creates an action that can be inserted, for instance, to the toolbar.
+
+ \return action for views synchronization
+*/
+QAction* SUIT_ViewWindow::synchronizeAction()
+{
+ if ( !mySyncAction ) {
+ SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
+ mySyncAction = new QtxAction( tr( "MNU_SYNCHRONIZE_VIEW" ),
+ resMgr->loadPixmap( "SUIT", tr( "ICON_VIEW_SYNC" ) ),
+ tr( "MNU_SYNCHRONIZE_VIEW" ), 0, this );
+ mySyncAction->setStatusTip( tr( "DSC_SYNCHRONIZE_VIEW" ) );
+ mySyncAction->setMenu( new QMenu( this ) );
+ mySyncAction->setCheckable( true );
+ connect( mySyncAction->menu(), SIGNAL( aboutToShow() ), this, SLOT( updateSyncViews() ) );
+ connect( mySyncAction, SIGNAL( triggered( bool ) ), this, SLOT( onSynchronizeView( bool ) ) );
+ }
+ return mySyncAction;
+}
+
+/*!
+ Emit notification signal that the view is transformed.
+ Other views can use the signal for synchronization.
+*/
+void SUIT_ViewWindow::emitViewModified()
+{
+ emit viewModified( this );
+}
+
+/*!
+ Update list of available view for the "Synchronize View" action
+*/
+void SUIT_ViewWindow::updateSyncViews()
+{
+ SUIT_CameraProperties props = cameraProperties();
+ if ( !props.isValid() )
+ return;
+
+ QAction* anAction = synchronizeAction();
+ if ( anAction && anAction->menu() ) {
+ int currentId = anAction->data().toInt();
+ anAction->menu()->clear();
+ SUIT_Application* app = SUIT_Session::session()->activeApplication();
+ if ( app ) {
+ SUIT_Desktop* d = app->desktop();
+ QList<SUIT_ViewWindow*> allViews = qFindChildren<SUIT_ViewWindow*>( d );
+ foreach( SUIT_ViewWindow* vw, allViews ) {
+ if ( !vw || vw == this ) continue; // skip invalid views and this one
+ SUIT_CameraProperties otherProps = vw->cameraProperties();
+ if ( otherProps.isCompatible( props ) ) {
+ QAction* a = anAction->menu()->addAction( vw->windowTitle() );
+ if ( vw->getId() == currentId ) {
+ QFont f = a->font();
+ f.setBold( true );
+ a->setFont( f );
+ }
+ a->setData( vw->getId() );
+ connect( a, SIGNAL( triggered( bool ) ), this, SLOT( onSynchronizeView( bool ) ) );
+ }
+ else if ( vw->getId() == currentId ) {
+ // other view, this one is being currently synchronized to, seems has become incompatible
+ // we have to break synchronization
+ vw->disconnect( SIGNAL( viewModified( SUIT_ViewWindow* ) ), this, SLOT( synchronize( SUIT_ViewWindow* ) ) );
+ this->disconnect( SIGNAL( viewModified( SUIT_ViewWindow* ) ), vw, SLOT( synchronize( SUIT_ViewWindow* ) ) );
+ //
+ bool blocked = anAction->blockSignals( true );
+ anAction->setChecked( false );
+ anAction->blockSignals( blocked );
+ anAction->setData( 0 );
+ //
+ QAction* a = vw->synchronizeAction();
+ if ( a ) {
+ blocked = a->blockSignals( true );
+ a->setChecked( false );
+ a->blockSignals( blocked );
+ }
+ }
+ }
+ }
+ if ( anAction->menu()->actions().isEmpty() ) {
+ anAction->setData( 0 );
+ anAction->menu()->addAction( tr( "MNU_SYNC_NO_VIEW" ) );
+ }
+ }
+}
+
+/*!
+ "Synchronize View" action slot.
+*/
+void SUIT_ViewWindow::onSynchronizeView( bool checked )
+{
+ QAction* a = qobject_cast<QAction*>( sender() );
+ if ( a ) {
+ synchronizeView( this, a->data().toInt() );
+ }
+}
+
+/*!
+ Synchronize camera properties of view \a viewWindow with
+ camera properties of view specified via \a id
+*/
+void SUIT_ViewWindow::synchronizeView( SUIT_ViewWindow* viewWindow, int id )
+{
+ SUIT_ViewWindow* sourceView = 0;
+ QList<SUIT_ViewWindow*> otherViews;
+
+ bool isSync = viewWindow->synchronizeAction() && viewWindow->synchronizeAction()->isChecked();
+
+ int vwid = viewWindow->getId();
+
+ SUIT_Application* app = SUIT_Session::session()->activeApplication();
+ if ( !app ) return;
+ SUIT_Desktop* d = app->desktop();
+ if ( !d ) return;
+
+ QList<SUIT_ViewWindow*> allViews = qFindChildren<SUIT_ViewWindow*>( d );
+ foreach( SUIT_ViewWindow* vw, allViews ) {
+ if ( !vw->cameraProperties().isValid() )
+ continue; // omit views not supporting camera properties
+ if ( vw->getId() == id )
+ sourceView = vw; // remember source view
+ else if ( vw != viewWindow )
+ otherViews.append( vw ); // collect all remaining views
+ }
+
+ if ( isSync && id ) {
+ // remove all possible disconnections
+ foreach( SUIT_ViewWindow* vw, otherViews ) {
+ // disconnect target view
+ vw->disconnect( SIGNAL( viewModified( SUIT_ViewWindow* ) ), viewWindow, SLOT( synchronize( SUIT_ViewWindow* ) ) );
+ viewWindow->disconnect( SIGNAL( viewModified( SUIT_ViewWindow* ) ), vw, SLOT( synchronize( SUIT_ViewWindow* ) ) );
+ if ( sourceView ) {
+ // disconnect source view
+ vw->disconnect( SIGNAL( viewModified( SUIT_ViewWindow* ) ), sourceView, SLOT( synchronize( SUIT_ViewWindow* ) ) );
+ sourceView->disconnect( SIGNAL( viewModified( SUIT_ViewWindow* ) ), vw, SLOT( synchronize( SUIT_ViewWindow* ) ) );
+ }
+ QAction* a = vw->synchronizeAction();
+ if ( a ) {
+ int anid = a->data().toInt();
+ if ( a->isChecked() && ( anid == id || anid == vwid ) ) {
+ bool blocked = a->blockSignals( true );
+ a->setChecked( false );
+ a->blockSignals( blocked );
+ }
+ }
+ }
+ if ( sourceView ) {
+ // reconnect source and target views
+ sourceView->disconnect( SIGNAL( viewModified( SUIT_ViewWindow* ) ), viewWindow, SLOT( synchronize( SUIT_ViewWindow* ) ) );
+ viewWindow->disconnect( SIGNAL( viewModified( SUIT_ViewWindow* ) ), sourceView, SLOT( synchronize( SUIT_ViewWindow* ) ) );
+ sourceView->connect( viewWindow, SIGNAL( viewModified( SUIT_ViewWindow* ) ), SLOT( synchronize( SUIT_ViewWindow* ) ) );
+ viewWindow->connect( sourceView, SIGNAL( viewModified( SUIT_ViewWindow* ) ), SLOT( synchronize( SUIT_ViewWindow* ) ) );
+ // synchronize target view with source view
+ viewWindow->synchronize( sourceView );
+ if ( viewWindow->synchronizeAction() )
+ viewWindow->synchronizeAction()->setData( sourceView->getId() );
+ QAction* sourceAction = sourceView->synchronizeAction();
+ if ( sourceAction ) {
+ sourceAction->setData( viewWindow->getId() );
+ if ( !sourceAction->isChecked() ) {
+ bool blocked = sourceAction->blockSignals( true );
+ sourceAction->setChecked( true );
+ sourceAction->blockSignals( blocked );
+ }
+ }
+ }
+ }
+ else if ( sourceView ) {
+ // reconnect source and target view
+ sourceView->disconnect( SIGNAL( viewModified( SUIT_ViewWindow* ) ), viewWindow, SLOT( synchronize( SUIT_ViewWindow* ) ) );
+ viewWindow->disconnect( SIGNAL( viewModified( SUIT_ViewWindow* ) ), sourceView, SLOT( synchronize( SUIT_ViewWindow* ) ) );
+ viewWindow->synchronize( sourceView );
+ if ( viewWindow->synchronizeAction() )
+ viewWindow->synchronizeAction() ->setData( sourceView->getId() );
+ QAction* sourceAction = sourceView->synchronizeAction();
+ if ( sourceAction ) {
+ if ( sourceAction->data().toInt() == viewWindow->getId() && sourceAction->isChecked() ) {
+ bool blocked = sourceAction->blockSignals( true );
+ sourceAction->setChecked( false );
+ sourceAction->blockSignals( blocked );
+ }
+ }
+ }
+}
#define SUIT_VIEWWINDOW_H
#include "SUIT.h"
+#include "SUIT_CameraProperties.h"
#include <QMainWindow>
#include <QList>
virtual void setDropDownButtons( bool );
bool dropDownButtons() const;
+ virtual SUIT_CameraProperties cameraProperties();
+
public slots:
virtual void onDumpView();
void keyPressed( SUIT_ViewWindow*, QKeyEvent* );
void keyReleased( SUIT_ViewWindow*, QKeyEvent* );
void contextMenuRequested( QContextMenuEvent *e );
-
+ void viewModified( SUIT_ViewWindow* );
+
protected:
void closeEvent( QCloseEvent* );
virtual void contextMenuEvent( QContextMenuEvent* );
virtual bool action( const int );
virtual bool dumpViewToFormat( const QImage&, const QString& fileName, const QString& format );
+ virtual QAction* synchronizeAction();
+ static void synchronizeView( SUIT_ViewWindow* viewWindow, int id );
+
SUIT_Desktop* myDesktop;
SUIT_ViewManager* myManager;
+protected slots:
+ void updateSyncViews();
+ void onSynchronizeView(bool);
+ virtual void synchronize( SUIT_ViewWindow* );
+ void emitViewModified();
+
private:
typedef QMap< int, QList<QtxMultiAction*> > ActionsMap;
QtxActionToolMgr* myToolMgr;
bool myIsDropDown;
ActionsMap myMultiActions;
+ QAction* mySyncAction;
};
#endif // SUIT_VIEWWINDOW_H
<source>ICON_DATAOBJ_INVISIBLE</source>
<translation>icon_visibility_off.png</translation>
</message>
+ <message>
+ <source>ICON_VIEW_SYNC</source>
+ <translation>view_sync.png</translation>
+ </message>
</context>
</TS>
<source>NAME_COLUMN</source>
<translation>Name</translation>
</message>
+ <message>
+ <source>MNU_SYNCHRONIZE_VIEW</source>
+ <translation>Synchronize</translation>
+ </message>
+ <message>
+ <source>DSC_SYNCHRONIZE_VIEW</source>
+ <translation>Synchronize view</translation>
+ </message>
+ <message>
+ <source>MNU_SYNC_NO_VIEW</source>
+ <translation>[ No appropriate view ]</translation>
+ </message>
</context>
<context>
<name>SUIT_Study</name>
<source>NAME_COLUMN</source>
<translation>Nom</translation>
</message>
+ <message>
+ <source>MNU_SYNCHRONIZE_VIEW</source>
+ <translation>Synchroniser</translation>
+ </message>
+ <message>
+ <source>DSC_SYNCHRONIZE_VIEW</source>
+ <translation>Synchroniser la vue</translation>
+ </message>
+ <message>
+ <source>MNU_SYNC_NO_VIEW</source>
+ <translation>[ Pas de vue appropriée ]</translation>
+ </message>
</context>
<context>
<name>SUIT_Study</name>
# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
#
-# File : Makefile.in
-# Author : Alexander Solovyov(OCN)
-# Module : SVTK
-# $Header$
-#
include $(top_srcdir)/adm_local/unix/make_common_starter.am
lib_LTLIBRARIES = libSVTK.la
resources/vtk_view_recording_play.png \
resources/vtk_view_recording_pause.png \
resources/vtk_view_recording_stop.png \
- resources/vtk_view_sync.png \
resources/vtk_view_highlight.png
nodist_salomeres_DATA = \
#include "VTKViewer_Trihedron.h"
#include "SVTK_View.h"
-//#include "SVTK_MainWindow.h"
#include "SVTK_Selector.h"
#include "SVTK_Event.h"
GetInteractor()->GetInteractorStyle()->AddObserver(SVTK::OperationFinished,
myEventCallbackCommand.GetPointer(), 0.0);
+ myKeyFreeInteractorStyle->AddObserver(SVTK::OperationFinished,
+ myEventCallbackCommand.GetPointer(), 0.0);
this,SIGNAL(contextMenuRequested(QContextMenuEvent *)));
connect(theView,SIGNAL(selectionChanged()),
theModel,SLOT(onSelectionChanged()));
+
+ connect( this, SIGNAL( transformed( SVTK_ViewWindow* ) ), SLOT( emitViewModified() ) );
}
/*!
vtkCamera* aCamera = getRenderer()->GetActiveCamera();
aCamera->SetParallelProjection(anIsParallelMode);
GetInteractor()->GetDevice()->CreateTimer(VTKI_TIMER_FIRST);
+
+ emit transformed( this );
}
void SVTK_ViewWindow::SetEventDispatcher(vtkObject* theDispatcher)
mgr->registerAction( anAction, ViewParametersId );
// Synchronize View
- anAction = new QtxAction(tr("MNU_SYNCHRONIZE_VIEW"),
- theResourceMgr->loadPixmap( "VTKViewer", tr( "ICON_SVTK_SYNCHRONIZE" ) ),
- tr( "MNU_SYNCHRONIZE_VIEW" ), 0, this);
- anAction->setStatusTip(tr("DSC_SYNCHRONIZE_VIEW"));
- anAction->setMenu( new QMenu( this ) );
- anAction->setCheckable(true);
- connect(anAction->menu(), SIGNAL(aboutToShow()), this, SLOT(updateSyncViews()));
- connect(anAction, SIGNAL(triggered(bool)), this, SLOT(onSynchronizeView(bool)));
- mgr->registerAction( anAction, SynchronizeId );
+ mgr->registerAction( synchronizeAction(), SynchronizeId );
// Switch between interaction styles
anAction = new QtxAction(tr("MNU_SVTK_STYLE_SWITCH"),
emit Hide( theEvent );
}
-void SVTK_ViewWindow::synchronizeView( SVTK_ViewWindow* viewWindow, int id )
-{
- SVTK_ViewWindow* otherViewWindow = 0;
- QList<SVTK_ViewWindow*> compatibleViews;
-
- bool isSync = viewWindow->toolMgr()->action( SynchronizeId )->isChecked();
-
- int vwid = viewWindow->getId();
-
- SUIT_Application* app = SUIT_Session::session()->activeApplication();
- if ( !app ) return;
-
- QList<SUIT_ViewManager*> wmlist;
- app->viewManagers( viewWindow->getViewManager()->getType(), wmlist );
-
- foreach( SUIT_ViewManager* wm, wmlist ) {
- QVector<SUIT_ViewWindow*> vwlist = wm->getViews();
-
- foreach( SUIT_ViewWindow* vw, vwlist ) {
- SVTK_ViewWindow* vtkVW = dynamic_cast<SVTK_ViewWindow*>( vw );
- if ( !vtkVW ) continue;
- if ( vtkVW->getId() == id )
- otherViewWindow = vtkVW;
- else if ( vtkVW != viewWindow )
- compatibleViews.append( vtkVW );
- }
- }
-
- if ( isSync && id ) {
- // remove all possible disconnections
- foreach( SVTK_ViewWindow* vw, compatibleViews ) {
- // disconnect target view
- vw->disconnect( SIGNAL( transformed( SVTK_ViewPort* ) ), viewWindow, SLOT( synchronize( SVTK_ViewPort* ) ) );
- viewWindow->disconnect( SIGNAL( transformed( SVTK_ViewPort* ) ), vw, SLOT( synchronize( SVTK_ViewPort* ) ) );
- if ( otherViewWindow ) {
- // disconnect source view
- vw->disconnect( SIGNAL( transformed( SVTK_ViewPort* ) ), otherViewWindow, SLOT( synchronize( SVTK_ViewPort* ) ) );
- otherViewWindow->disconnect( SIGNAL( transformed( SVTK_ViewPort* ) ), vw, SLOT( synchronize( SVTK_ViewPort* ) ) );
- }
- QAction* a = vw->toolMgr()->action( SynchronizeId );
- if ( a ) {
- int anid = a->data().toInt();
- if ( a->isChecked() && ( anid == id || anid == vwid ) ) {
- bool blocked = a->blockSignals( true );
- a->setChecked( false );
- a->blockSignals( blocked );
- }
- }
- }
- if ( otherViewWindow ) {
- // reconnect source and target view
- otherViewWindow->disconnect( SIGNAL( transformed( SVTK_ViewWindow* ) ), viewWindow, SLOT( synchronize( SVTK_ViewWindow* ) ) );
- viewWindow->disconnect( SIGNAL( transformed( SVTK_ViewWindow* ) ), otherViewWindow, SLOT( synchronize( SVTK_ViewWindow* ) ) );
- otherViewWindow->connect( viewWindow, SIGNAL( transformed( SVTK_ViewWindow* ) ), SLOT( synchronize( SVTK_ViewWindow* ) ) );
- viewWindow->connect( otherViewWindow, SIGNAL( transformed( SVTK_ViewWindow* ) ), SLOT( synchronize( SVTK_ViewWindow* ) ) );
- // synchronize target view with source view
- viewWindow->doSetVisualParameters( otherViewWindow->getVisualParameters(), true );
- viewWindow->toolMgr()->action( SynchronizeId )->setData( otherViewWindow->getId() );
- otherViewWindow->toolMgr()->action( SynchronizeId )->setData( viewWindow->getId() );
- if ( !otherViewWindow->toolMgr()->action( SynchronizeId )->isChecked() ) {
- bool blocked = otherViewWindow->toolMgr()->action( SynchronizeId )->blockSignals( true );
- otherViewWindow->toolMgr()->action( SynchronizeId )->setChecked( true );
- otherViewWindow->toolMgr()->action( SynchronizeId )->blockSignals( blocked );
- }
- }
- }
- else if ( otherViewWindow ) {
- // reconnect source and target view
- otherViewWindow->disconnect( SIGNAL( transformed( SVTK_ViewWindow* ) ), viewWindow, SLOT( synchronize( SVTK_ViewWindow* ) ) );
- viewWindow->disconnect( SIGNAL( transformed( SVTK_ViewWindow* ) ), otherViewWindow, SLOT( synchronize( SVTK_ViewWindow* ) ) );
- viewWindow->doSetVisualParameters( otherViewWindow->getVisualParameters(), true );
- viewWindow->toolMgr()->action( SynchronizeId )->setData( otherViewWindow->getId() );
- if ( otherViewWindow->toolMgr()->action( SynchronizeId )->data().toInt() == viewWindow->getId() && otherViewWindow->toolMgr()->action( SynchronizeId )->isChecked() ) {
- bool blocked = otherViewWindow->toolMgr()->action( SynchronizeId )->blockSignals( true );
- otherViewWindow->toolMgr()->action( SynchronizeId )->setChecked( false );
- otherViewWindow->toolMgr()->action( SynchronizeId )->blockSignals( blocked );
- }
- }
-}
-
-/*!
- "Synchronize View" action slot.
-*/
-void SVTK_ViewWindow::onSynchronizeView(bool checked)
-{
- QAction* a = qobject_cast<QAction*>( sender() );
- if ( a ) {
- synchronizeView( this, a->data().toInt() );
- }
-}
-
-/*!
- Update list of available view for the "Synchronize View" action
-*/
-void SVTK_ViewWindow::updateSyncViews()
-{
- QAction* anAction = toolMgr()->action( SynchronizeId );
- if ( anAction && anAction->menu() ) {
- int currentId = anAction->data().toInt();
- anAction->menu()->clear();
- SUIT_Application* app = SUIT_Session::session()->activeApplication();
- if ( app ) {
- QList<SUIT_ViewManager*> wmlist;
- app->viewManagers( getViewManager()->getType(), wmlist );
- foreach( SUIT_ViewManager* wm, wmlist ) {
- QVector<SUIT_ViewWindow*> vwlist = wm->getViews();
- foreach ( SUIT_ViewWindow* vw, vwlist ) {
- SVTK_ViewWindow* vtkVW = dynamic_cast<SVTK_ViewWindow*>( vw );
- if ( !vtkVW || vtkVW == this ) continue;
- QAction* a = anAction->menu()->addAction( vtkVW->windowTitle() );
- if ( vtkVW->getId() == currentId ) {
- QFont f = a->font();
- f.setBold( true );
- a->setFont( f );
- }
- a->setData( vtkVW->getId() );
- connect( a, SIGNAL( triggered(bool) ), this, SLOT( onSynchronizeView(bool) ) );
- }
- }
- }
- if ( anAction->menu()->actions().isEmpty() ) {
- anAction->setData( 0 );
- anAction->menu()->addAction( tr( "MNU_SYNC_NO_VIEW" ) );
- }
- }
-}
-
-
/*!
Emit transformed signal.
*/
if(self)
self->emitTransformed();
}
+
+/*!
+ Get camera properties for the SVTK view window.
+ \return shared pointer on camera properties.
+*/
+SUIT_CameraProperties SVTK_ViewWindow::cameraProperties()
+{
+ SUIT_CameraProperties aProps;
+
+ // get vtk camera
+ vtkCamera* aCamera = getRenderer()->GetActiveCamera();
+ if ( !aCamera )
+ return aProps;
+
+ aProps.setDimension( SUIT_CameraProperties::Dim3D );
+ if ( toolMgr()->action( ParallelModeId ) ) {
+ if ( toolMgr()->action( ParallelModeId )->isChecked() )
+ aProps.setProjection( SUIT_CameraProperties::PrjOrthogonal );
+ else
+ aProps.setProjection( SUIT_CameraProperties::PrjPerspective );
+ }
+
+ double aFocalPoint[3];
+ double aPosition[3];
+ double aViewUp[3];
+ double anAxialScale[3];
+
+ aCamera->OrthogonalizeViewUp();
+ aCamera->GetFocalPoint(aFocalPoint);
+ aCamera->GetPosition(aPosition);
+ aCamera->GetViewUp(aViewUp);
+
+ aProps.setFocalPoint(aFocalPoint[0], aFocalPoint[1], aFocalPoint[2]);
+ aProps.setPosition(aPosition[0], aPosition[1], aPosition[2]);
+ aProps.setViewUp(aViewUp[0], aViewUp[1], aViewUp[2]);
+ aProps.setMappingScale(aCamera->GetParallelScale());
+
+ if (aProps.getProjection() == SUIT_CameraProperties::PrjPerspective)
+ {
+ aProps.setViewAngle(aCamera->GetViewAngle());
+ }
+
+ GetRenderer()->GetScale(anAxialScale);
+ aProps.setAxialScale(anAxialScale[0], anAxialScale[1], anAxialScale[2]);
+
+ return aProps;
+}
+
+/*!
+ Synchronize views.
+ This implementation synchronizes camera propreties.
+*/
+void SVTK_ViewWindow::synchronize( SUIT_ViewWindow* theView )
+{
+ bool blocked = blockSignals( true );
+
+ SUIT_CameraProperties aProps = theView->cameraProperties();
+ if ( !cameraProperties().isCompatible( aProps ) ) {
+ // other view, this one is being currently synchronized to, seems has become incompatible
+ // we have to break synchronization
+ updateSyncViews();
+ return;
+ }
+
+ // get camera
+ vtkCamera* aCamera = getRenderer()->GetActiveCamera();
+
+ double aFocalPoint[3];
+ double aPosition[3];
+ double aViewUp[3];
+ double anAxialScale[3];
+
+ // get common properties
+ aProps.getViewUp(aViewUp[0], aViewUp[1], aViewUp[2]);
+ aProps.getPosition(aPosition[0], aPosition[1], aPosition[2]);
+ aProps.getFocalPoint(aFocalPoint[0], aFocalPoint[1], aFocalPoint[2]);
+ aProps.getAxialScale(anAxialScale[0], anAxialScale[1], anAxialScale[2]);
+
+ // restore properties to the camera
+ aCamera->SetViewUp(aViewUp);
+ aCamera->SetPosition(aPosition);
+ aCamera->SetFocalPoint(aFocalPoint);
+ aCamera->SetParallelScale(aProps.getMappingScale());
+
+ if (aProps.getProjection() == SUIT_CameraProperties::PrjPerspective)
+ {
+ aCamera->SetViewAngle(aProps.getViewAngle());
+ }
+
+ GetRenderer()->SetScale(anAxialScale);
+
+ getRenderer()->ResetCameraClippingRange();
+ Repaint(false);
+
+ blockSignals( blocked );
+}
//! To invoke a VTK event on #SVTK_RenderWindowInteractor instance
void InvokeEvent(unsigned long theEvent, void* theCallData);
+ virtual SUIT_CameraProperties cameraProperties();
+
signals:
void Show( QShowEvent * );
void Hide( QHideEvent * );
virtual void synchronize(SVTK_ViewWindow*);
protected slots:
+ void synchronize( SUIT_ViewWindow* );
void onKeyPressed(QKeyEvent* event);
void onKeyReleased(QKeyEvent* event);
void onMousePressed(QMouseEvent* event);
vtkPVAxesWidget* myAxesWidget;
Qtx::BackgroundData myBackground;
-private slots:
- void onSynchronizeView(bool);
- void updateSyncViews();
-
-private:
- static void synchronizeView( SVTK_ViewWindow*, int );
-
private:
QImage myDumpImage;
};
<source>ICON_SVTK_RECORDING_STOP</source>
<translation>vtk_view_recording_stop.png</translation>
</message>
- <message>
- <source>ICON_SVTK_SYNCHRONIZE</source>
- <translation>vtk_view_sync.png</translation>
- </message>
<message>
<source>ICON_SVTK_DYNAMIC_PRESLECTION_SWITCH</source>
<translation>vtk_view_highlight.png</translation>
</message>
<message>
<source>MNU_FRONT_VIEW</source>
- <translation>Front</translation>
+ <translation>-OX</translation>
</message>
<message>
<source>ERROR</source>
</message>
<message>
<source>DSC_TOP_VIEW</source>
- <translation>Top View</translation>
+ <translation>-OZ View</translation>
</message>
<message>
<source>MNU_PAN_VIEW</source>
</message>
<message>
<source>MNU_TOP_VIEW</source>
- <translation>Top</translation>
+ <translation>-OZ</translation>
</message>
<message>
<source>DSC_GLOBALPAN_VIEW</source>
</message>
<message>
<source>DSC_LEFT_VIEW</source>
- <translation>Left View</translation>
+ <translation>+OY View</translation>
</message>
<message>
<source>DSC_FITALL</source>
</message>
<message>
<source>DSC_FRONT_VIEW</source>
- <translation>Front View</translation>
+ <translation>-OX View</translation>
</message>
<message>
<source>MNU_GLOBALPAN_VIEW</source>
</message>
<message>
<source>MNU_BACK_VIEW</source>
- <translation>Back</translation>
+ <translation>+OX</translation>
</message>
<message>
<source>MNU_SHOW_TRIHEDRON</source>
</message>
<message>
<source>MNU_BOTTOM_VIEW</source>
- <translation>Bottom</translation>
+ <translation>+OZ</translation>
</message>
<message>
<source>MNU_RESET_VIEW</source>
</message>
<message>
<source>MNU_LEFT_VIEW</source>
- <translation>Left</translation>
+ <translation>+OY</translation>
</message>
<message>
<source>DSC_RIGHT_VIEW</source>
- <translation>Right View</translation>
+ <translation>-OY View</translation>
</message>
<message>
<source>MNU_CHANGINGROTATIONPOINT_VIEW</source>
</message>
<message>
<source>DSC_BOTTOM_VIEW</source>
- <translation>Bottom View</translation>
+ <translation>+OZ View</translation>
</message>
<message>
<source>DSC_DUMP_VIEW</source>
</message>
<message>
<source>MNU_RIGHT_VIEW</source>
- <translation>Right</translation>
+ <translation>-OY</translation>
</message>
<message>
<source>LBL_TOOLBAR_LABEL</source>
</message>
<message>
<source>DSC_BACK_VIEW</source>
- <translation>Back View</translation>
+ <translation>+OX View</translation>
</message>
<message>
<source>SVTK_IMAGE_FILES</source>
<source>DSC_VIEWPARAMETERS_VIEW</source>
<translation>Change the parameters of the view</translation>
</message>
- <message>
- <source>MNU_SYNCHRONIZE_VIEW</source>
- <translation>Synchronize</translation>
- </message>
- <message>
- <source>DSC_SYNCHRONIZE_VIEW</source>
- <translation>Synchronize view</translation>
- </message>
- <message>
- <source>MNU_SYNC_NO_VIEW</source>
- <translation>[ No appropriate view ]</translation>
- </message>
<message>
<source>MNU_SVTK_PARALLEL_MODE</source>
<translation>Orthogonal Mode</translation>
</message>
<message>
<source>MNU_FRONT_VIEW</source>
- <translation>Avant</translation>
+ <translation>-OX</translation>
</message>
<message>
<source>ERROR</source>
</message>
<message>
<source>DSC_TOP_VIEW</source>
- <translation>Vue de dessus</translation>
+ <translation>Vue -OZ</translation>
</message>
<message>
<source>MNU_PAN_VIEW</source>
</message>
<message>
<source>MNU_TOP_VIEW</source>
- <translation>Dessus</translation>
+ <translation>-OZ</translation>
</message>
<message>
<source>DSC_GLOBALPAN_VIEW</source>
</message>
<message>
<source>DSC_LEFT_VIEW</source>
- <translation>Vue de gauche</translation>
+ <translation>Vue +OY</translation>
</message>
<message>
<source>DSC_FITALL</source>
</message>
<message>
<source>DSC_FRONT_VIEW</source>
- <translation>Vue de face</translation>
+ <translation>Vue -OX</translation>
</message>
<message>
<source>MNU_GLOBALPAN_VIEW</source>
</message>
<message>
<source>MNU_BACK_VIEW</source>
- <translation>Arrière</translation>
+ <translation>+OX</translation>
</message>
<message>
<source>MNU_SHOW_TRIHEDRON</source>
</message>
<message>
<source>MNU_BOTTOM_VIEW</source>
- <translation>Dessous</translation>
+ <translation>+OZ</translation>
</message>
<message>
<source>MNU_RESET_VIEW</source>
</message>
<message>
<source>MNU_LEFT_VIEW</source>
- <translation>Gauche</translation>
+ <translation>+OY</translation>
</message>
<message>
<source>DSC_RIGHT_VIEW</source>
- <translation>Vue de droite</translation>
+ <translation>Vue -OY</translation>
</message>
<message>
<source>MNU_CHANGINGROTATIONPOINT_VIEW</source>
</message>
<message>
<source>DSC_BOTTOM_VIEW</source>
- <translation>Vue de dessous</translation>
+ <translation>Vue +OZ</translation>
</message>
<message>
<source>DSC_DUMP_VIEW</source>
</message>
<message>
<source>MNU_RIGHT_VIEW</source>
- <translation>Droite</translation>
+ <translation>-OY</translation>
</message>
<message>
<source>LBL_TOOLBAR_LABEL</source>
</message>
<message>
<source>DSC_BACK_VIEW</source>
- <translation>Vue arrière</translation>
+ <translation>Vue +OX</translation>
</message>
<message>
<source>SVTK_IMAGE_FILES</source>
<source>DSC_VIEWPARAMETERS_VIEW</source>
<translation>Changer les paramètres de la vue</translation>
</message>
- <message>
- <source>MNU_SYNCHRONIZE_VIEW</source>
- <translation>Synchroniser</translation>
- </message>
- <message>
- <source>DSC_SYNCHRONIZE_VIEW</source>
- <translation>Synchroniser la vue</translation>
- </message>
- <message>
- <source>MNU_SYNC_NO_VIEW</source>
- <translation>[ Pas de vue appropriée ]</translation>
- </message>
<message>
<source>MNU_SVTK_PARALLEL_MODE</source>
<translation>Mode orthogonal</translation>
SalomeApp_NoteBookDlg.cxx
SalomeApp_DoubleSpinBox.cxx
SalomeApp_IntSpinBox.cxx
+ SalomeApp_Engine_i.cxx
)
SET(GUITS_SOURCES
SalomeApp_NoteBookDlg.h
SalomeApp_DoubleSpinBox.h
SalomeApp_IntSpinBox.h
+ SalomeApp_Engine_i.h
)
INSTALL(FILES ${COMMON_HEADERS_H} DESTINATION ${GUI_salomeinclude_HEADERS})
SalomeApp_ExitDlg.h \
SalomeApp_NoteBookDlg.h \
SalomeApp_DoubleSpinBox.h \
- SalomeApp_IntSpinBox.h
+ SalomeApp_IntSpinBox.h \
+ SalomeApp_Engine_i.h
dist_libSalomeApp_la_SOURCES = \
SalomeApp_Module.cxx \
SalomeApp_ExitDlg.cxx \
SalomeApp_NoteBookDlg.cxx \
SalomeApp_DoubleSpinBox.cxx \
- SalomeApp_IntSpinBox.cxx
+ SalomeApp_IntSpinBox.cxx \
+ SalomeApp_Engine_i.cxx
MOC_FILES = \
SalomeApp_Application_moc.cxx \
-I$(srcdir)/../Event -I$(srcdir)/../CASCatch -I$(srcdir)/../Prs \
@CORBA_CXXFLAGS@ @CORBA_INCLUDES@ @LIBXML_INCLUDES@
libSalomeApp_la_LDFLAGS = $(PYTHON_LIBS) $(QT_MT_LIBS)
-libSalomeApp_la_LIBADD = $(KERNEL_LDFLAGS) -lOpUtil -lSALOMELocalTrace -lSalomeLifeCycleCORBA -lSalomeDSClient \
+libSalomeApp_la_LIBADD = $(KERNEL_LDFLAGS) -lOpUtil -lSALOMELocalTrace -lSalomeLifeCycleCORBA \
+ -lSalomeDSClient -lTOOLSDS \
../SUIT/libsuit.la ../STD/libstd.la ../CAM/libCAM.la ../ObjBrowser/libObjBrowser.la \
../Prs/libSalomePrs.la ../SPlot2d/libSPlot2d.la ../GLViewer/libGLViewer.la \
../OCCViewer/libOCCViewer.la ../VTKViewer/libVTKViewer.la ../OBJECT/libSalomeObject.la \
../SVTK/libSVTK.la ../SOCC/libSOCC.la ../PyInterp/libPyInterp.la \
../PyConsole/libPyConsole.la ../LogWindow/libLogWindow.la \
- ../LightApp/libLightApp.la ../TOOLSGUI/libToolsGUI.la ../Session/libSalomeSession.la \
+ ../LightApp/libLightApp.la ../TOOLSGUI/libToolsGUI.la ../../idl/libSalomeIDLGUI.la \
../Event/libEvent.la ../CASCatch/libCASCatch.la ../Prs/libSalomePrs.la $(CAS_KERNEL)
--- /dev/null
+// Copyright (C) 2007-2012 CEA/DEN, EDF R&D, OPEN CASCADE
+//
+// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+
+// SalomeApp_Engine_i : implementation of SalomeApp_Engine.idl
+// File : SalomeApp_Engine_i.cxx
+// Author : Alexander SLADKOV
+
+#include "SalomeApp_Engine_i.h"
+#include "SalomeApp_Application.h"
+
+#include <SALOME_NamingService.hxx>
+#include <SALOMEDS_Tool.hxx>
+#include <Utils_ORB_INIT.hxx>
+#include <Utils_SINGLETON.hxx>
+#include <Utils_SALOME_Exception.hxx>
+#include <utilities.h>
+
+#include <QApplication>
+#include <QDir>
+#include <QFile>
+
+#include <iostream>
+
+/*!
+ Constructor
+*/
+SalomeApp_Engine_i::SalomeApp_Engine_i( const char* theComponentName )
+{
+ myComponentName = theComponentName;
+ MESSAGE("SalomeApp_Engine_i::SalomeApp_Engine_i(): myComponentName = " <<
+ myComponentName << ", this = " << this);
+}
+
+/*!
+ Destructor
+*/
+SalomeApp_Engine_i::~SalomeApp_Engine_i()
+{
+ MESSAGE("SalomeApp_Engine_i::~SalomeApp_Engine_i(): myComponentName = " <<
+ myComponentName << ", this = " << this);
+}
+
+SALOMEDS::TMPFile* SalomeApp_Engine_i::Save (SALOMEDS::SComponent_ptr theComponent,
+ const char* theURL,
+ bool isMultiFile)
+{
+ SALOMEDS::TMPFile_var aStreamFile = new SALOMEDS::TMPFile;
+
+ if (CORBA::is_nil(theComponent) || CORBA::is_nil(theComponent->GetStudy()))
+ return aStreamFile._retn();
+
+ const int studyId = theComponent->GetStudy()->StudyId();
+
+ // Get a temporary directory to store a file
+ //std::string aTmpDir = isMultiFile ? theURL : SALOMEDS_Tool::GetTmpDir();
+
+ if (myMap.count(studyId)) {
+ std::string componentName (theComponent->ComponentDataType());
+
+ // Error somewhere outside - Save() called with
+ // wrong SComponent instance
+ if ( myComponentName != componentName )
+ return aStreamFile._retn();
+
+ const ListOfFiles& listOfFiles = myMap[studyId];
+
+ // listOfFiles must contain temporary directory name in its first item
+ // and names of files (relatively the temporary directory) in the others
+ const int n = listOfFiles.size() - 1;
+
+ if (n > 0) { // there are some files, containing persistent data of the component
+ std::string aTmpDir = listOfFiles[0];
+
+ // Create a list to store names of created files
+ SALOMEDS::ListOfFileNames_var aSeq = new SALOMEDS::ListOfFileNames;
+ aSeq->length(n);
+ for (int i = 0; i < n; i++)
+ aSeq[i] = CORBA::string_dup(listOfFiles[i + 1].c_str());
+
+ // Convert a file to the byte stream
+ aStreamFile = SALOMEDS_Tool::PutFilesToStream(aTmpDir.c_str(), aSeq.in(), isMultiFile);
+
+ // Remove the files and tmp directory, created by the component storage procedure
+ if (!isMultiFile) SALOMEDS_Tool::RemoveTemporaryFiles(aTmpDir.c_str(), aSeq.in(), true);
+ }
+ }
+
+ return aStreamFile._retn();
+}
+
+CORBA::Boolean SalomeApp_Engine_i::Load (SALOMEDS::SComponent_ptr theComponent,
+ const SALOMEDS::TMPFile& theFile,
+ const char* theURL,
+ bool isMultiFile)
+{
+ std::cout << "SalomeApp_Engine_i::Load() isMultiFile = " << isMultiFile << std::endl;
+ if (CORBA::is_nil(theComponent) || CORBA::is_nil(theComponent->GetStudy()))
+ return false;
+
+ // Error somewhere outside - Load() called with
+ // wrong SComponent instance
+ std::string componentName (theComponent->ComponentDataType());
+ if ( myComponentName != componentName )
+ return false;
+
+ const int studyId = theComponent->GetStudy()->StudyId();
+
+ // Create a temporary directory for the component's data files
+ std::string aTmpDir = isMultiFile ? theURL : SALOMEDS_Tool::GetTmpDir();
+
+ // Convert the byte stream theStream to a files and place them in the tmp directory.
+ // The files and temporary directory must be deleted by the component loading procedure.
+ SALOMEDS::ListOfFileNames_var aSeq =
+ SALOMEDS_Tool::PutStreamToFiles(theFile, aTmpDir.c_str(), isMultiFile);
+
+ // Store list of file names to be used by the component loading procedure
+ const int n = aSeq->length() + 1;
+ ListOfFiles listOfFiles (n);
+ listOfFiles[0] = aTmpDir;
+ for (int i = 1; i < n; i++)
+ listOfFiles[i] = std::string(aSeq[i - 1]);
+
+ SetListOfFiles(listOfFiles, studyId);
+
+ return true;
+}
+
+SalomeApp_Engine_i::ListOfFiles SalomeApp_Engine_i::GetListOfFiles (const int theStudyId)
+{
+ ListOfFiles aListOfFiles;
+
+ if (myMap.find(theStudyId) != myMap.end())
+ {
+ aListOfFiles = myMap[theStudyId];
+ }
+
+ return aListOfFiles;
+}
+
+void SalomeApp_Engine_i::SetListOfFiles (const ListOfFiles& theListOfFiles,
+ const int theStudyId)
+{
+ myMap[theStudyId] = theListOfFiles;
+}
+
+/*!
+ * DumpPython implementation for light modules
+ */
+Engines::TMPFile* SalomeApp_Engine_i::DumpPython(CORBA::Object_ptr theStudy,
+ CORBA::Boolean isPublished,
+ CORBA::Boolean isMultiFile,
+ CORBA::Boolean& isValidScript)
+{
+ MESSAGE("SalomeApp_Engine_i::DumpPython(): myComponentName = "<<
+ myComponentName << ", this = " << this);
+
+ // Temporary solution: returning a non-empty sequence
+ // even if there's nothing to dump, to avoid crashes in SALOMEDS
+ // TODO: Improve SALOMEDSImpl_Study::DumpStudy() by skipping the components
+ // with isValidScript == false, and initialize isValidScript by false below.
+ Engines::TMPFile_var aStreamFile = new Engines::TMPFile(1);
+ aStreamFile->length( 1 );
+ aStreamFile[0] = '\0';
+ isValidScript = true;
+
+ if (CORBA::is_nil(theStudy))
+ return aStreamFile._retn();
+
+ SALOMEDS::Study_var studyDS = SALOMEDS::Study::_narrow( theStudy );
+ const int studyId = studyDS->StudyId();
+
+ if (!myMap.count(studyId))
+ return aStreamFile._retn();
+
+ ListOfFiles listOfFiles = myMap[studyId];
+
+ // listOfFiles must contain temporary directory name in its first item
+ // and names of files (relatively the temporary directory) in the others
+ if ( listOfFiles.size() < 2 )
+ return aStreamFile._retn();
+
+ // there are some files, containing persistent data of the component
+ QString aTmpPath( listOfFiles.front().c_str() );
+ QDir aTmpDir( aTmpPath );
+ if ( !aTmpDir.exists() )
+ return aStreamFile._retn();
+
+ // Calculate file sizes
+ QStringList aFilePaths;
+ QList<qint64> aFileSizes;
+ qint64 aBuffSize = 0;
+ ListOfFiles::const_iterator aFIt = listOfFiles.begin();
+ ListOfFiles::const_iterator aFEnd = listOfFiles.end();
+ aFIt++;
+ for (; aFIt != aFEnd; aFIt++){
+ QString aFileName( (*aFIt).c_str() );
+ if ( !aTmpDir.exists( aFileName ) ){
+ continue;
+ }
+
+ QFile aFile( aTmpDir.filePath( aFileName ) );
+ if ( !aFile.open( QIODevice::ReadOnly ) ){
+ continue;
+ }
+
+ aFilePaths.push_back( aTmpDir.filePath( aFileName ) );
+ aFileSizes.push_back( aFile.size() );
+ aBuffSize += aFileSizes.back();
+
+ aFile.close();
+ }
+
+ if ( !aFilePaths.size() || !aBuffSize )
+ return aStreamFile._retn();
+
+ char* aBuffer = new char[aBuffSize + 1];
+ if ( !aBuffer )
+ return aStreamFile._retn();
+
+ // Convert the file(s) to the byte stream, multiple files are simply
+ // concatenated
+ // TODO: imporve multi-script support if necessary...
+ qint64 aCurrPos = 0;
+ QStringList::const_iterator aFileIt = aFilePaths.begin();
+ QStringList::const_iterator aFileEnd = aFilePaths.end();
+ QList<qint64>::const_iterator aSIt = aFileSizes.begin();
+ for ( ; aFileIt != aFileEnd; aFileIt++, aSIt++ ){
+ QFile aFile( aTmpDir.filePath( *aFileIt ) );
+ if ( !aFile.open( QIODevice::ReadOnly ) ){
+ continue;
+ }
+
+ // Incorrect size of file
+ // Do not remove the bad file to have some diagnostic means
+ if ( aFile.read( aBuffer + aCurrPos, *aSIt ) != *aSIt ){
+ aFile.close();
+ return aStreamFile._retn();
+ }
+
+ aCurrPos += (*aSIt);
+ aFile.remove();
+ }
+
+ // Here we should end up with empty aTmpDir
+ // TODO: Handle QDir::rmdir() error status somehow...
+ aTmpDir.rmdir( aTmpPath );
+
+ aBuffer[aBuffSize] = '\0';
+ CORBA::Octet* anOctetBuf = (CORBA::Octet*)aBuffer;
+ aStreamFile = new Engines::TMPFile(aBuffSize + 1, aBuffSize + 1, anOctetBuf, 1);
+
+ return aStreamFile._retn();
+}
+
+/*!
+ \return Component data type string for this instance of the engine
+*/
+char* SalomeApp_Engine_i::ComponentDataType()
+{
+ return const_cast<char*>( myComponentName.c_str() );
+}
+
+/*!
+ \return Component version
+*/
+char* SalomeApp_Engine_i::getVersion()
+{
+ SalomeApp_Application::ModuleShortInfoList versions = SalomeApp_Application::getVersionInfo();
+ QString version;
+ SalomeApp_Application::ModuleShortInfo version_info;
+ foreach ( version_info, versions ) {
+ if ( SalomeApp_Application::moduleName( version_info.name ) == myComponentName.c_str() ) {
+ version = version_info.version;
+ break;
+ }
+ }
+
+ return CORBA::string_dup( version.toLatin1().constData() );
+}
+
+/*!
+ \return
+*/
+CORBA::ORB_var SalomeApp_Engine_i::orb()
+{
+ ORB_INIT& init = *SINGLETON_<ORB_INIT>::Instance();
+ // TODO: using QApplication here looks ugly, think how to
+ // obtain the ORB reference in a nicer way...
+ static CORBA::ORB_var _orb = init( qApp->argc(), qApp->argv() );
+ return _orb;
+}
+
+/*!
+ \return
+*/
+PortableServer::POA_var SalomeApp_Engine_i::poa()
+{
+ static PortableServer::POA_var _poa;
+ if ( CORBA::is_nil( _poa ) ){
+ CORBA::Object_var obj = orb()->resolve_initial_references( "RootPOA" );
+ _poa = PortableServer::POA::_narrow( obj );
+ }
+ return _poa;
+}
+
+/*!
+ \return
+*/
+SALOME_NamingService* SalomeApp_Engine_i::namingService()
+{
+ static SALOME_NamingService _ns(orb());
+ return &_ns;
+}
+
+/*!
+ Internal method, creates a CORBA engine for a light SALOME module
+ with the given "component data type" string,
+ activates it and registers in SALOME naming service with
+ /SalomeAppEngine/comp_data_type path. If the engine is already in the
+ naming service, simply returns and object reference to it.
+ \param theComponentName - synthetic "component data type" used to identify a given light module
+ \return Object reference to the CORBA engine
+*/
+CORBA::Object_ptr SalomeApp_Engine_i::engineForComponent( const char* theComponentName,
+ bool toCreate )
+{
+ CORBA::Object_var anEngine;
+ if ( !theComponentName || !strlen( theComponentName ) )
+ return anEngine._retn();
+
+ std::string aPath( "/SalomeAppEngine/" );
+ aPath += theComponentName;
+ anEngine = namingService()->Resolve( aPath.c_str() );
+
+ // Activating a new instance of the servant
+ if ( toCreate && CORBA::is_nil( anEngine ) ){
+ try {
+ SalomeApp_Engine_i* aServant = new SalomeApp_Engine_i( theComponentName );
+ PortableServer::ObjectId_var id = poa()->activate_object( aServant );
+ anEngine = aServant->_this();
+ aServant->_remove_ref();
+ namingService()->Register( anEngine.in(), aPath.c_str() );
+ }
+ catch (CORBA::SystemException&) {
+ INFOS("Caught CORBA::SystemException.");
+ }
+ catch (CORBA::Exception&) {
+ INFOS("Caught CORBA::Exception.");
+ }
+ catch (...) {
+ INFOS("Caught unknown exception.");
+ }
+ }
+
+ return anEngine._retn();
+}
+
+/*!
+ \param theComponentName - synthetic "component data type" used to identify a given light module
+ \return IOR string for the CORBA engine for a light SALOME module
+ with the given "component data type" string
+ \sa GetInstance( const char* theComponentName )
+*/
+std::string SalomeApp_Engine_i::EngineIORForComponent( const char* theComponentName,
+ bool toCreate )
+{
+ std::string anIOR( "" );
+ CORBA::Object_var anEngine = engineForComponent( theComponentName, toCreate );
+ if ( !CORBA::is_nil( anEngine ) )
+ {
+ CORBA::String_var objStr = orb()->object_to_string( anEngine.in() );
+ anIOR = std::string( objStr.in() );
+ }
+ return anIOR;
+}
+
+/*!
+ \param theComponentName - synthetic "component data type" used to identify a given light module
+ \return A pointer to corresponding C++ engine instance, null means some internal problems.
+ \sa EngineIORForComponent( const char* theComponentName )
+*/
+SalomeApp_Engine_i* SalomeApp_Engine_i::GetInstance( const char* theComponentName,
+ bool toCreate )
+{
+ SalomeApp_Engine_i* aServant = 0;
+ CORBA::Object_var anEngine = engineForComponent( theComponentName, toCreate );
+ if ( !CORBA::is_nil( anEngine ) )
+ {
+ PortableServer::Servant aServantBase = poa()->reference_to_servant( anEngine.in() );
+ aServant = dynamic_cast<SalomeApp_Engine_i*>( aServantBase );
+ }
+ MESSAGE("SalomeApp_Engine_i::GetInstance(): theComponentName = " <<
+ theComponentName << ", aServant = " << aServant);
+ return aServant;
+}
--- /dev/null
+// Copyright (C) 2007-2012 CEA/DEN, EDF R&D, OPEN CASCADE
+//
+// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+
+// SalomeApp_Engine_i : implementation of SalomeApp_Engine.idl
+// File : SalomeApp_Engine_i.hxx
+// Author : Alexander SLADKOV
+
+#ifndef _SALOMEAPP_ENGINE_I_HXX_
+#define _SALOMEAPP_ENGINE_I_HXX_
+
+#include "SalomeApp.h"
+
+#include "SALOME_Component_i.hxx"
+
+#include <vector>
+#include <map>
+
+#include <SALOMEconfig.h>
+#include CORBA_SERVER_HEADER(SalomeApp_Engine)
+
+class SALOME_NamingService;
+
+class SALOMEAPP_EXPORT SalomeApp_Engine_i: public POA_SalomeApp::Engine,
+ public Engines_Component_i
+{
+public:
+ SalomeApp_Engine_i( const char* theComponentName );
+ ~SalomeApp_Engine_i();
+
+ SALOMEDS::TMPFile* Save( SALOMEDS::SComponent_ptr theComponent,
+ const char* theURL,
+ bool isMultiFile );
+
+ CORBA::Boolean Load( SALOMEDS::SComponent_ptr theComponent,
+ const SALOMEDS::TMPFile& theFile,
+ const char* theURL,
+ bool isMultiFile );
+
+ virtual Engines::TMPFile* DumpPython(CORBA::Object_ptr theStudy,
+ CORBA::Boolean isPublished,
+ CORBA::Boolean isMultiFile,
+ CORBA::Boolean& isValidScript);
+
+public:
+ typedef std::vector<std::string> ListOfFiles;
+
+ ListOfFiles GetListOfFiles (const int theStudyId);
+ void SetListOfFiles (const ListOfFiles& theListOfFiles,
+ const int theStudyId);
+
+ static std::string EngineIORForComponent( const char* theComponentName,
+ bool toCreate );
+ static SalomeApp_Engine_i* GetInstance ( const char* theComponentName,
+ bool toCreate );
+
+public:
+ // methods from SALOMEDS::Driver without implementation. Must be redefined because
+ // there is no default implementation of SALOMEDS::Driver interface
+ SALOMEDS::TMPFile* SaveASCII( SALOMEDS::SComponent_ptr, const char*, bool ) {return 0;}
+ CORBA::Boolean LoadASCII( SALOMEDS::SComponent_ptr, const SALOMEDS::TMPFile&, const char*, bool ) {return 0;}
+ void Close( SALOMEDS::SComponent_ptr ) {}
+ char* ComponentDataType();
+ char* IORToLocalPersistentID( SALOMEDS::SObject_ptr, const char*, CORBA::Boolean, CORBA::Boolean ) {return 0;}
+ char* LocalPersistentIDToIOR( SALOMEDS::SObject_ptr, const char*, CORBA::Boolean, CORBA::Boolean ) {return 0;}
+ bool CanPublishInStudy( CORBA::Object_ptr ) {return 0;}
+ SALOMEDS::SObject_ptr PublishInStudy(SALOMEDS::Study_ptr, SALOMEDS::SObject_ptr, CORBA::Object_ptr, const char* ) throw (SALOME::SALOME_Exception) {return 0;}
+ CORBA::Boolean CanCopy( SALOMEDS::SObject_ptr ) {return 0;}
+ SALOMEDS::TMPFile* CopyFrom( SALOMEDS::SObject_ptr, CORBA::Long& ) {return 0;}
+ CORBA::Boolean CanPaste( const char*, CORBA::Long ) {return 0;}
+ SALOMEDS::SObject_ptr PasteInto( const SALOMEDS::TMPFile&, CORBA::Long, SALOMEDS::SObject_ptr ) {return 0;}
+
+ char* getVersion();
+
+private:
+ static CORBA::ORB_var orb();
+ static PortableServer::POA_var poa();
+ static SALOME_NamingService* namingService();
+ static CORBA::Object_ptr engineForComponent( const char* theComponentName,
+ bool toCreate );
+
+private:
+ typedef std::map<int, ListOfFiles> MapOfListOfFiles;
+ MapOfListOfFiles myMap;
+
+ std::string myComponentName;
+};
+
+#endif
+
#include "SalomeApp_DataObject.h"
#include "SalomeApp_DataModel.h"
#include "SalomeApp_Application.h"
-#include "SalomeApp_Engine_i.hxx"
+#include "SalomeApp_Engine_i.h"
#include "SalomeApp_VisualState.h"
// temporary commented
QStringList columnNames;
columnNames.append(tr("PRP_AUTHOR"));
columnNames.append(tr("PRP_DATE_MODIF"));
+ myModifications->setHeaderLabels( columnNames );
- QTreeWidgetItem * headerItem = new QTreeWidgetItem(columnNames);
- myModifications->setHeaderItem ( headerItem );
+ //Component versions
+ QLabel* versionsLabel = new QLabel(tr("PRP_VERSIONS"),this);
+ myVersions = new QTreeWidget(this);
+ myVersions->setRootIsDecorated(false);
+ myVersions->setUniformRowHeights(true);
+ myVersions->setAllColumnsShowFocus(true);
+ myVersions->setColumnCount(2);
+ myVersions->setMaximumHeight(80);
+ columnNames.clear();
+ columnNames.append(tr("PRP_COMPONENT"));
+ columnNames.append(tr("PRP_VERSION"));
+ myVersions->setHeaderLabels( columnNames );
QFrame* buttonFrame = new QFrame(this);
gridLayout->addWidget(myComment, 4, 1, 1, 2);
gridLayout->addWidget(modificationsLabel, 5, 0, 1, 1);
gridLayout->addWidget(myModifications, 5, 1, 1, 2);
- gridLayout->addWidget(buttonFrame, 6, 0, 1, 3);
+ gridLayout->addWidget(versionsLabel, 6, 0, 1, 1);
+ gridLayout->addWidget(myVersions, 6, 1, 1, 2);
+ gridLayout->addWidget(buttonFrame, 7, 0, 1, 3);
connect(myOkButton, SIGNAL(clicked()), this, SLOT(clickOnOk()));
connect(myCancelButton, SIGNAL(clicked()), this, SLOT(reject()));
bool isModified = false;
SalomeApp_Study* study = dynamic_cast<SalomeApp_Study*>
(SUIT_Session::session()->activeApplication()->activeStudy());
- if (study) {
- isModified = study->isModified();
- if (hasData) {
- if (propAttr->IsModified() != isModified) {
- propAttr->SetModified((int)isModified);
- }
- }
+ isModified = study->isModified();
+ if (propAttr->IsModified() != isModified) {
+ propAttr->SetModified((int)isModified);
}
-
+
QString modif = propAttr->IsModified() ? tr( "PRP_MODIFIED" ) : tr( "PRP_NOT_MODIFIED" );
myModification->setText(modif);
QTreeWidgetItem* item = new QTreeWidgetItem(aList);
myModifications->addTopLevelItem(item);
}
+
+ //Component versions
+ std::vector<std::string> aComponents = propAttr->GetStoredComponents();
+ for ( int i = 0; i < aComponents.size(); i++ ) {
+ std::vector<int> aMins, aHours, aDays, aMonths, aYears;
+ std::vector<std::string> aVersions = propAttr->GetComponentVersions(aComponents[i]);
+ QStringList aData;
+ aData.append( aComponents[i].c_str() );
+ aData.append( aVersions.empty() || aVersions[0] == "" ? "unknown" : aVersions[0].c_str() );
+ QTreeWidgetItem* item = new QTreeWidgetItem( aData );
+ if ( aVersions.size() > 1 )
+ item->setForeground( 1, Qt::red );
+ myVersions->addTopLevelItem(item);
+ }
}
adjustSize();
}
QComboBox* myUnits;
QTextEdit* myComment;
QTreeWidget* myModifications;
+ QTreeWidget* myVersions;
QPushButton* myOkButton;
QPushButton* myCancelButton;
};
global tubebuilder, xalome
global dialogWithApply, activeStudy
global previewShapeEntry, deletePreviewShape
- global DEFAULT_FOLDER_NAME,DEFAULT_SHAPE_NAME
+ global DEFAULT_FOLDER_NAME,DEFAULT_SHAPE_NAME
dialogWithApply.accept()
shape = tubebuilder.createGeometry(activeStudy, radius, length, width)
entry = xalome.addToStudy(activeStudy, shape, DEFAULT_SHAPE_NAME, DEFAULT_FOLDER_NAME)
xalome.displayShape(entry)
-
+
def rejectCallback():
"""Action to be done when click on Cancel"""
global dialogWithApply, previewShapeEntry, deletePreviewShape
version = salome_version.getVersion(full=True)
kernel_appli_dir = os.environ['KERNEL_ROOT_DIR']
command = ""
- if os.path.exists("/usr/bin/xterm"):
- command = 'xterm -T "SALOME %s - Shell session" -e %s/runSession &'%(version,kernel_appli_dir)
- elif os.path.exists("/usr/bin/gnome-terminal"):
+ if os.path.exists("/usr/bin/gnome-terminal"):
command = 'gnome-terminal -t "SALOME %s - Shell session" -e %s/runSession &'%(version,kernel_appli_dir)
+ elif os.path.exists("/usr/bin/konsole"):
+ command = 'PATH="/usr/bin:/sbin:/bin" LD_LIBRARY_PATH="" konsole -e %s/runSession &'%(kernel_appli_dir)
+ elif os.path.exists("/usr/bin/xterm"):
+ command = 'xterm -T "SALOME %s - Shell session" -e %s/runSession &'%(version,kernel_appli_dir)
else:
- print "Neither xterm nor gnome-terminal is installed."
-
+ print "Neither xterm nor gnome-terminal nor konsole is installed."
+
if command is not "":
try:
subprocess.check_call(command, shell = True)
<parameter name="killall" value="no"/>
<parameter name="pinter" value="no"/>
<parameter name="noexcepthandler" value="no"/>
- <parameter name="modules" value="GEOM,SMESH,VISU,MED,YACS,PARAVIS"/>
+ <parameter name="modules" value="GEOM,SMESH,HEXABLOCK,VISU,MED,YACS,PARAVIS"/>
<parameter name="pyModules" value=""/>
<parameter name="embedded" value="SalomeAppEngine,study,cppContainer,registry,moduleCatalog"/>
<parameter name="standalone" value="pyContainer,supervContainer"/>
<source>PRP_MODIFICATIONS</source>
<translation>Modifications</translation>
</message>
+ <message>
+ <source>PRP_COMPONENT</source>
+ <translation>Component</translation>
+ </message>
+ <message>
+ <source>PRP_VERSION</source>
+ <translation>Version</translation>
+ </message>
+ <message>
+ <source>PRP_VERSIONS</source>
+ <translation>Stored data</translation>
+ </message>
<message>
<source>PRP_DATE_MODIF</source>
<translation>Date</translation>
<source>PRP_MODIFICATIONS</source>
<translation>Modifications</translation>
</message>
+ <message>
+ <source>PRP_COMPONENT</source>
+ <translation type="unfinished">Component</translation>
+ </message>
+ <message>
+ <source>PRP_VERSION</source>
+ <translation type="unfinished">Version</translation>
+ </message>
+ <message>
+ <source>PRP_VERSIONS</source>
+ <translation type="unfinished">Stored data</translation>
+ </message>
<message>
<source>PRP_DATE_MODIF</source>
<translation>Date</translation>
Session_ServerThread.cxx
Session_ServerLauncher.cxx
Session_ServerCheck.cxx
- SalomeApp_Engine_i.cxx
)
ADD_LIBRARY(SalomeSession SHARED ${SalomeSession_SOURCES})
SET_TARGET_PROPERTIES(SalomeSession PROPERTIES COMPILE_FLAGS "${COMMON_FLAGS}")
Session_ServerLauncher.hxx
Session_ServerThread.hxx
Session_ServerCheck.hxx
- SalomeApp_Engine_i.hxx
)
INSTALL(FILES ${COMMON_HEADERS_H} DESTINATION ${GUI_salomeinclude_HEADERS})
SALOME_Session.hxx \
Session_ServerLauncher.hxx \
Session_ServerThread.hxx \
- Session_ServerCheck.hxx \
- SalomeApp_Engine_i.hxx
+ Session_ServerCheck.hxx
# Libraries targets
Session_Session_i.cxx \
Session_ServerThread.cxx \
Session_ServerLauncher.cxx \
- Session_ServerCheck.cxx \
- SalomeApp_Engine_i.cxx
+ Session_ServerCheck.cxx
libSalomeSession_la_CPPFLAGS = $(QT_MT_INCLUDES) $(PYTHON_INCLUDES) \
$(HDF5_INCLUDES) $(BOOST_CPPFLAGS) @KERNEL_CXXFLAGS@ $(CAS_CPPFLAGS) \
// unlock Session mutex
_SessionMutex.unlock();
- if ( shutdownAll )
+ if ( myServerLauncher )
+ myServerLauncher->ShutdownAll(); // shutdown embedded servers
+
+ if ( shutdownAll ) // shutdown standalone servers
shutdownServers( _NS );
if ( myServerLauncher )
- myServerLauncher->KillAll(); // kill embedded servers
+ myServerLauncher->KillAll(); // kill embedded servers
// Unregister session server
SALOME_Session_i* sessionServant = dynamic_cast<SALOME_Session_i*>( poa->reference_to_servant( session.in() ) );
+++ /dev/null
-// Copyright (C) 2007-2012 CEA/DEN, EDF R&D, OPEN CASCADE
-//
-// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
-// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
-//
-// This library is free software; you can redistribute it and/or
-// modify it under the terms of the GNU Lesser General Public
-// License as published by the Free Software Foundation; either
-// version 2.1 of the License.
-//
-// This library is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-// Lesser General Public License for more details.
-//
-// You should have received a copy of the GNU Lesser General Public
-// License along with this library; if not, write to the Free Software
-// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-//
-// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
-//
-
-// SalomeApp_Engine_i : implementation of SalomeApp_Engine.idl
-// File : SalomeApp_Engine_i.cxx
-// Author : Alexander SLADKOV
-
-#include "SalomeApp_Engine_i.hxx"
-
-#include <SALOME_NamingService.hxx>
-#include <SALOMEDS_Tool.hxx>
-#include <Utils_ORB_INIT.hxx>
-#include <Utils_SINGLETON.hxx>
-#include <Utils_SALOME_Exception.hxx>
-#include <utilities.h>
-
-#include <QApplication>
-#include <QDir>
-#include <QFile>
-
-#include <iostream>
-
-/*!
- Constructor
-*/
-SalomeApp_Engine_i::SalomeApp_Engine_i( const char* theComponentName )
-{
- myComponentName = theComponentName;
- MESSAGE("SalomeApp_Engine_i::SalomeApp_Engine_i(): myComponentName = " <<
- myComponentName << ", this = " << this);
-}
-
-/*!
- Destructor
-*/
-SalomeApp_Engine_i::~SalomeApp_Engine_i()
-{
- MESSAGE("SalomeApp_Engine_i::~SalomeApp_Engine_i(): myComponentName = " <<
- myComponentName << ", this = " << this);
-}
-
-SALOMEDS::TMPFile* SalomeApp_Engine_i::Save (SALOMEDS::SComponent_ptr theComponent,
- const char* theURL,
- bool isMultiFile)
-{
- SALOMEDS::TMPFile_var aStreamFile = new SALOMEDS::TMPFile;
-
- if (CORBA::is_nil(theComponent) || CORBA::is_nil(theComponent->GetStudy()))
- return aStreamFile._retn();
-
- const int studyId = theComponent->GetStudy()->StudyId();
-
- // Get a temporary directory to store a file
- //std::string aTmpDir = isMultiFile ? theURL : SALOMEDS_Tool::GetTmpDir();
-
- if (myMap.count(studyId)) {
- std::string componentName (theComponent->ComponentDataType());
-
- // Error somewhere outside - Save() called with
- // wrong SComponent instance
- if ( myComponentName != componentName )
- return aStreamFile._retn();
-
- const ListOfFiles& listOfFiles = myMap[studyId];
-
- // listOfFiles must contain temporary directory name in its first item
- // and names of files (relatively the temporary directory) in the others
- const int n = listOfFiles.size() - 1;
-
- if (n > 0) { // there are some files, containing persistent data of the component
- std::string aTmpDir = listOfFiles[0];
-
- // Create a list to store names of created files
- SALOMEDS::ListOfFileNames_var aSeq = new SALOMEDS::ListOfFileNames;
- aSeq->length(n);
- for (int i = 0; i < n; i++)
- aSeq[i] = CORBA::string_dup(listOfFiles[i + 1].c_str());
-
- // Convert a file to the byte stream
- aStreamFile = SALOMEDS_Tool::PutFilesToStream(aTmpDir.c_str(), aSeq.in(), isMultiFile);
-
- // Remove the files and tmp directory, created by the component storage procedure
- if (!isMultiFile) SALOMEDS_Tool::RemoveTemporaryFiles(aTmpDir.c_str(), aSeq.in(), true);
- }
- }
-
- return aStreamFile._retn();
-}
-
-CORBA::Boolean SalomeApp_Engine_i::Load (SALOMEDS::SComponent_ptr theComponent,
- const SALOMEDS::TMPFile& theFile,
- const char* theURL,
- bool isMultiFile)
-{
- std::cout << "SalomeApp_Engine_i::Load() isMultiFile = " << isMultiFile << std::endl;
- if (CORBA::is_nil(theComponent) || CORBA::is_nil(theComponent->GetStudy()))
- return false;
-
- // Error somewhere outside - Load() called with
- // wrong SComponent instance
- std::string componentName (theComponent->ComponentDataType());
- if ( myComponentName != componentName )
- return false;
-
- const int studyId = theComponent->GetStudy()->StudyId();
-
- // Create a temporary directory for the component's data files
- std::string aTmpDir = isMultiFile ? theURL : SALOMEDS_Tool::GetTmpDir();
-
- // Convert the byte stream theStream to a files and place them in the tmp directory.
- // The files and temporary directory must be deleted by the component loading procedure.
- SALOMEDS::ListOfFileNames_var aSeq =
- SALOMEDS_Tool::PutStreamToFiles(theFile, aTmpDir.c_str(), isMultiFile);
-
- // Store list of file names to be used by the component loading procedure
- const int n = aSeq->length() + 1;
- ListOfFiles listOfFiles (n);
- listOfFiles[0] = aTmpDir;
- for (int i = 1; i < n; i++)
- listOfFiles[i] = std::string(aSeq[i - 1]);
-
- SetListOfFiles(listOfFiles, studyId);
-
- return true;
-}
-
-SalomeApp_Engine_i::ListOfFiles SalomeApp_Engine_i::GetListOfFiles (const int theStudyId)
-{
- ListOfFiles aListOfFiles;
-
- if (myMap.find(theStudyId) != myMap.end())
- {
- aListOfFiles = myMap[theStudyId];
- }
-
- return aListOfFiles;
-}
-
-void SalomeApp_Engine_i::SetListOfFiles (const ListOfFiles& theListOfFiles,
- const int theStudyId)
-{
- myMap[theStudyId] = theListOfFiles;
-}
-
-/*!
- * DumpPython implementation for light modules
- */
-Engines::TMPFile* SalomeApp_Engine_i::DumpPython(CORBA::Object_ptr theStudy,
- CORBA::Boolean isPublished,
- CORBA::Boolean isMultiFile,
- CORBA::Boolean& isValidScript)
-{
- MESSAGE("SalomeApp_Engine_i::DumpPython(): myComponentName = "<<
- myComponentName << ", this = " << this);
-
- // Temporary solution: returning a non-empty sequence
- // even if there's nothing to dump, to avoid crashes in SALOMEDS
- // TODO: Improve SALOMEDSImpl_Study::DumpStudy() by skipping the components
- // with isValidScript == false, and initialize isValidScript by false below.
- Engines::TMPFile_var aStreamFile = new Engines::TMPFile(1);
- aStreamFile->length( 1 );
- aStreamFile[0] = '\0';
- isValidScript = true;
-
- if (CORBA::is_nil(theStudy))
- return aStreamFile._retn();
-
- SALOMEDS::Study_var studyDS = SALOMEDS::Study::_narrow( theStudy );
- const int studyId = studyDS->StudyId();
-
- if (!myMap.count(studyId))
- return aStreamFile._retn();
-
- ListOfFiles listOfFiles = myMap[studyId];
-
- // listOfFiles must contain temporary directory name in its first item
- // and names of files (relatively the temporary directory) in the others
- if ( listOfFiles.size() < 2 )
- return aStreamFile._retn();
-
- // there are some files, containing persistent data of the component
- QString aTmpPath( listOfFiles.front().c_str() );
- QDir aTmpDir( aTmpPath );
- if ( !aTmpDir.exists() )
- return aStreamFile._retn();
-
- // Calculate file sizes
- QStringList aFilePaths;
- QList<qint64> aFileSizes;
- qint64 aBuffSize = 0;
- ListOfFiles::const_iterator aFIt = listOfFiles.begin();
- ListOfFiles::const_iterator aFEnd = listOfFiles.end();
- aFIt++;
- for (; aFIt != aFEnd; aFIt++){
- QString aFileName( (*aFIt).c_str() );
- if ( !aTmpDir.exists( aFileName ) ){
- continue;
- }
-
- QFile aFile( aTmpDir.filePath( aFileName ) );
- if ( !aFile.open( QIODevice::ReadOnly ) ){
- continue;
- }
-
- aFilePaths.push_back( aTmpDir.filePath( aFileName ) );
- aFileSizes.push_back( aFile.size() );
- aBuffSize += aFileSizes.back();
-
- aFile.close();
- }
-
- if ( !aFilePaths.size() || !aBuffSize )
- return aStreamFile._retn();
-
- char* aBuffer = new char[aBuffSize + 1];
- if ( !aBuffer )
- return aStreamFile._retn();
-
- // Convert the file(s) to the byte stream, multiple files are simply
- // concatenated
- // TODO: imporve multi-script support if necessary...
- qint64 aCurrPos = 0;
- QStringList::const_iterator aFileIt = aFilePaths.begin();
- QStringList::const_iterator aFileEnd = aFilePaths.end();
- QList<qint64>::const_iterator aSIt = aFileSizes.begin();
- for ( ; aFileIt != aFileEnd; aFileIt++, aSIt++ ){
- QFile aFile( aTmpDir.filePath( *aFileIt ) );
- if ( !aFile.open( QIODevice::ReadOnly ) ){
- continue;
- }
-
- // Incorrect size of file
- // Do not remove the bad file to have some diagnostic means
- if ( aFile.read( aBuffer + aCurrPos, *aSIt ) != *aSIt ){
- aFile.close();
- return aStreamFile._retn();
- }
-
- aCurrPos += (*aSIt);
- aFile.remove();
- }
-
- // Here we should end up with empty aTmpDir
- // TODO: Handle QDir::rmdir() error status somehow...
- aTmpDir.rmdir( aTmpPath );
-
- aBuffer[aBuffSize] = '\0';
- CORBA::Octet* anOctetBuf = (CORBA::Octet*)aBuffer;
- aStreamFile = new Engines::TMPFile(aBuffSize + 1, aBuffSize + 1, anOctetBuf, 1);
-
- return aStreamFile._retn();
-}
-
-/*!
- \return Component data type string for this instance of the engine
-*/
-char* SalomeApp_Engine_i::ComponentDataType()
-{
- return const_cast<char*>( myComponentName.c_str() );
-}
-
-/*!
- \return
-*/
-CORBA::ORB_var SalomeApp_Engine_i::orb()
-{
- ORB_INIT& init = *SINGLETON_<ORB_INIT>::Instance();
- // TODO: using QApplication here looks ugly, think how to
- // obtain the ORB reference in a nicer way...
- static CORBA::ORB_var _orb = init( qApp->argc(), qApp->argv() );
- return _orb;
-}
-
-/*!
- \return
-*/
-PortableServer::POA_var SalomeApp_Engine_i::poa()
-{
- static PortableServer::POA_var _poa;
- if ( CORBA::is_nil( _poa ) ){
- CORBA::Object_var obj = orb()->resolve_initial_references( "RootPOA" );
- _poa = PortableServer::POA::_narrow( obj );
- }
- return _poa;
-}
-
-/*!
- \return
-*/
-SALOME_NamingService* SalomeApp_Engine_i::namingService()
-{
- static SALOME_NamingService _ns(orb());
- return &_ns;
-}
-
-/*!
- Internal method, creates a CORBA engine for a light SALOME module
- with the given "component data type" string,
- activates it and registers in SALOME naming service with
- /SalomeAppEngine/comp_data_type path. If the engine is already in the
- naming service, simply returns and object reference to it.
- \param theComponentName - synthetic "component data type" used to identify a given light module
- \return Object reference to the CORBA engine
-*/
-CORBA::Object_ptr SalomeApp_Engine_i::engineForComponent( const char* theComponentName,
- bool toCreate )
-{
- CORBA::Object_var anEngine;
- if ( !theComponentName || !strlen( theComponentName ) )
- return anEngine._retn();
-
- std::string aPath( "/SalomeAppEngine/" );
- aPath += theComponentName;
- anEngine = namingService()->Resolve( aPath.c_str() );
-
- // Activating a new instance of the servant
- if ( toCreate && CORBA::is_nil( anEngine ) ){
- try {
- SalomeApp_Engine_i* aServant = new SalomeApp_Engine_i( theComponentName );
- PortableServer::ObjectId_var id = poa()->activate_object( aServant );
- anEngine = aServant->_this();
- aServant->_remove_ref();
- namingService()->Register( anEngine.in(), aPath.c_str() );
- }
- catch (CORBA::SystemException&) {
- INFOS("Caught CORBA::SystemException.");
- }
- catch (CORBA::Exception&) {
- INFOS("Caught CORBA::Exception.");
- }
- catch (...) {
- INFOS("Caught unknown exception.");
- }
- }
-
- return anEngine._retn();
-}
-
-/*!
- \param theComponentName - synthetic "component data type" used to identify a given light module
- \return IOR string for the CORBA engine for a light SALOME module
- with the given "component data type" string
- \sa GetInstance( const char* theComponentName )
-*/
-std::string SalomeApp_Engine_i::EngineIORForComponent( const char* theComponentName,
- bool toCreate )
-{
- std::string anIOR( "" );
- CORBA::Object_var anEngine = engineForComponent( theComponentName, toCreate );
- if ( !CORBA::is_nil( anEngine ) )
- {
- CORBA::String_var objStr = orb()->object_to_string( anEngine.in() );
- anIOR = std::string( objStr.in() );
- }
- return anIOR;
-}
-
-/*!
- \param theComponentName - synthetic "component data type" used to identify a given light module
- \return A pointer to corresponding C++ engine instance, null means some internal problems.
- \sa EngineIORForComponent( const char* theComponentName )
-*/
-SalomeApp_Engine_i* SalomeApp_Engine_i::GetInstance( const char* theComponentName,
- bool toCreate )
-{
- SalomeApp_Engine_i* aServant = 0;
- CORBA::Object_var anEngine = engineForComponent( theComponentName, toCreate );
- if ( !CORBA::is_nil( anEngine ) )
- {
- PortableServer::Servant aServantBase = poa()->reference_to_servant( anEngine.in() );
- aServant = dynamic_cast<SalomeApp_Engine_i*>( aServantBase );
- }
- MESSAGE("SalomeApp_Engine_i::GetInstance(): theComponentName = " <<
- theComponentName << ", aServant = " << aServant);
- return aServant;
-}
-
+++ /dev/null
-// Copyright (C) 2007-2012 CEA/DEN, EDF R&D, OPEN CASCADE
-//
-// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
-// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
-//
-// This library is free software; you can redistribute it and/or
-// modify it under the terms of the GNU Lesser General Public
-// License as published by the Free Software Foundation; either
-// version 2.1 of the License.
-//
-// This library is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-// Lesser General Public License for more details.
-//
-// You should have received a copy of the GNU Lesser General Public
-// License along with this library; if not, write to the Free Software
-// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-//
-// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
-//
-
-// SalomeApp_Engine_i : implementation of SalomeApp_Engine.idl
-// File : SalomeApp_Engine_i.hxx
-// Author : Alexander SLADKOV
-
-#ifndef _SALOMEAPP_ENGINE_I_HXX_
-#define _SALOMEAPP_ENGINE_I_HXX_
-
-#include "SALOME_Session.hxx"
-
-#include "SALOME_Component_i.hxx"
-
-#include <vector>
-#include <map>
-
-#include <SALOMEconfig.h>
-#include CORBA_SERVER_HEADER(SalomeApp_Engine)
-
-class SALOME_NamingService;
-
-class SESSION_EXPORT SalomeApp_Engine_i: public POA_SalomeApp::Engine,
- public Engines_Component_i
-{
-public:
- SalomeApp_Engine_i( const char* theComponentName );
- ~SalomeApp_Engine_i();
-
- SALOMEDS::TMPFile* Save( SALOMEDS::SComponent_ptr theComponent,
- const char* theURL,
- bool isMultiFile );
-
- CORBA::Boolean Load( SALOMEDS::SComponent_ptr theComponent,
- const SALOMEDS::TMPFile& theFile,
- const char* theURL,
- bool isMultiFile );
-
- virtual Engines::TMPFile* DumpPython(CORBA::Object_ptr theStudy,
- CORBA::Boolean isPublished,
- CORBA::Boolean isMultiFile,
- CORBA::Boolean& isValidScript);
-
-public:
- typedef std::vector<std::string> ListOfFiles;
-
- ListOfFiles GetListOfFiles (const int theStudyId);
- void SetListOfFiles (const ListOfFiles& theListOfFiles,
- const int theStudyId);
-
- static std::string EngineIORForComponent( const char* theComponentName,
- bool toCreate );
- static SalomeApp_Engine_i* GetInstance ( const char* theComponentName,
- bool toCreate );
-
-public:
- // methods from SALOMEDS::Driver without implementation. Must be redefined because
- // there is no default implementation of SALOMEDS::Driver interface
- SALOMEDS::TMPFile* SaveASCII( SALOMEDS::SComponent_ptr, const char*, bool ) {return 0;}
- CORBA::Boolean LoadASCII( SALOMEDS::SComponent_ptr, const SALOMEDS::TMPFile&, const char*, bool ) {return 0;}
- void Close( SALOMEDS::SComponent_ptr ) {}
- char* ComponentDataType();
- char* IORToLocalPersistentID( SALOMEDS::SObject_ptr, const char*, CORBA::Boolean, CORBA::Boolean ) {return 0;}
- char* LocalPersistentIDToIOR( SALOMEDS::SObject_ptr, const char*, CORBA::Boolean, CORBA::Boolean ) {return 0;}
- bool CanPublishInStudy( CORBA::Object_ptr ) {return 0;}
- SALOMEDS::SObject_ptr PublishInStudy(SALOMEDS::Study_ptr, SALOMEDS::SObject_ptr, CORBA::Object_ptr, const char* ) throw (SALOME::SALOME_Exception) {return 0;}
- CORBA::Boolean CanCopy( SALOMEDS::SObject_ptr ) {return 0;}
- SALOMEDS::TMPFile* CopyFrom( SALOMEDS::SObject_ptr, CORBA::Long& ) {return 0;}
- CORBA::Boolean CanPaste( const char*, CORBA::Long ) {return 0;}
- SALOMEDS::SObject_ptr PasteInto( const SALOMEDS::TMPFile&, CORBA::Long, SALOMEDS::SObject_ptr ) {return 0;}
-
-private:
- static CORBA::ORB_var orb();
- static PortableServer::POA_var poa();
- static SALOME_NamingService* namingService();
- static CORBA::Object_ptr engineForComponent( const char* theComponentName,
- bool toCreate );
-
-private:
- typedef std::map<int, ListOfFiles> MapOfListOfFiles;
- MapOfListOfFiles myMap;
-
- std::string myComponentName;
-};
-
-#endif
-
delete[] argv;
}
+void Session_ServerLauncher::ShutdownAll()
+{
+ MESSAGE("Session_ServerLauncher::ShutdownAll()");
+ std::list<Session_ServerThread*>::reverse_iterator itServ;
+ for (itServ = _serverThreads.rbegin(); itServ !=_serverThreads.rend(); itServ++)
+ {
+ (*itServ)->Shutdown();
+ }
+}
+
/*!
Destruction des classes serveur dans l'ordre inverse de creation
*/
QWaitCondition *SessionStarted);
virtual ~Session_ServerLauncher();
void run();
+ void ShutdownAll();
void KillAll();
protected:
_servType =-1;
_NS = new SALOME_NamingService(_orb); // one instance per server to limit
// multi thread coherence problems
+ _container = 0; // embedded container
}
/*!
}
}
+void Session_ServerThread::Shutdown()
+{
+ if ( _container ) _container->Shutdown();
+}
+
void Session_ServerThread::ActivateModuleCatalog(int argc,
char ** argv)
{
containerName = argv[1];
}
- new Engines_Container_i(_orb, _root_poa, containerName , argc , argv , true , false);
+ _container = new Engines_Container_i(_orb, _root_poa, containerName , argc , argv , true , false);
}
catch(CORBA::SystemException&) {
INFOS("Caught CORBA::SystemException.");
void WaitForServerReadiness(std::string serverName);
class SALOME_NamingService;
+class Engines_Container_i;
class SESSION_EXPORT Session_ServerThread
{
PortableServer::POA_ptr poa);
virtual ~Session_ServerThread();
void Init();
+ void Shutdown();
protected:
void ActivateModuleCatalog ( int argc, char ** argv );
void ActivateSALOMEDS ( int argc, char ** argv );
CORBA::ORB_var _orb;
PortableServer::POA_var _root_poa;
SALOME_NamingService * _NS;
+ Engines_Container_i* _container;
};
class QMutex;
CORBA_LIBS=@OMNIORB_LIBS@
QT_CXXFLAGS=@QT_INCLUDES@ @QT_MT_INCLUDES@
-TEST_CPPFLAGS = \
+COMMON_CPP_FLAGS = \
$(QT_CXXFLAGS) \
$(CORBA_CXXFLAGS) \
$(KERNEL_CXXFLAGS) \
-I$(top_srcdir)/src/TreeData \
-I.
-TEST_LDFLAGS = \
+COMMON_LIBS = \
$(CORBA_LIBS) $(QT_LIBS) \
$(top_builddir)/src/TreeData/libSalomeTreeData.la \
$(top_builddir)/src/GuiHelpers/libSalomeGuiHelpers.la \
- $(KERNEL_LDFLAGS) -lSalomeLifeCycleCORBA -lSalomeKernelHelpers
+ $(top_builddir)/src/SUIT/libsuit.la \
+ $(top_builddir)/src/CAM/libCAM.la \
+ $(top_builddir)/src/Plot2d/libPlot2d.la \
+ $(top_builddir)/src/LightApp/libLightApp.la \
+ $(top_builddir)/src/SalomeApp/libSalomeApp.la \
+ $(KERNEL_LDFLAGS) -lSalomeLifeCycleCORBA -lSalomeKernelHelpers @LIBXML_LIBS@
# Program targets
bin_PROGRAMS = TreeData_guitester TreeData_tester
MyDataModel.cxx
TreeData_guitester_CPPFLAGS = \
- $(TEST_CPPFLAGS)
+ $(COMMON_CPP_FLAGS)
TreeData_guitester_LDFLAGS = \
- $(TEST_LDFLAGS)
+ $(COMMON_LIBS)
TreeData_tester_SOURCES = \
tester.cxx \
MyDataModel.cxx
TreeData_tester_CPPFLAGS = \
- $(TEST_CPPFLAGS)
+ $(COMMON_CPP_FLAGS)
TreeData_tester_LDFLAGS = \
- $(TEST_LDFLAGS)
+ $(COMMON_LIBS)
# test data files
testdir = $(salomeresdir)/testdata
//#define __MYDEBUG__
//#define USE_ROBUST_TRIANGULATION
+///////////////////////////////////////////////////////////////////////////////////////////////
+// VSR 26/10/2012: fix of regression (issue 21924) - increased memory consumption
+// for displaying of 3d elements, introduced by fix for issue 20314.
+// ...
+// The macro SHOW_COINCIDING_3D_PAL20314, when defined, allows correct visualization of
+// coincident 3d elements but causes substantial increasing of memory consumption, as all 3d
+// elements are always shown, even if they are totally covered by surrounding faces.
+// If this macro is not defined (commented), the behaviour is defined by another macro -
+// SHOW_COINCIDING_3D_PAL21924, as follows:
+// - If SHOW_COINCIDING_3D_PAL21924 is defined, an alternative solution for computing
+// visibility of 3d elements is used; this solution allows to fix problem with visibility
+// of coinciding 3d elements in most cases (though some cases might not work), while not
+// causing significant increasing of memory consumption.
+// - If SHOW_COINCIDING_3D_PAL21924 is not defined (commented), coinciding 3d elements are
+// not shown at all (this corresponds to the state before issue 20314 fixing).
+///////////////////////////////////////////////////////////////////////////////////////////////
+//#define SHOW_COINCIDING_3D_PAL20314
+#ifndef SHOW_COINCIDING_3D_PAL20314
+#define SHOW_COINCIDING_3D_PAL21924
+#endif
+///////////////////////////////////////////////////////////////////////////////////////////////
+
vtkCxxRevisionMacro(VTKViewer_GeometryFilter, "$Revision$");
vtkStandardNewMacro(VTKViewer_GeometryFilter);
vtkIdList *cellIds = vtkIdList::New();
vtkIdList *faceIds = vtkIdList::New();
+ vtkIdList *cellIdsTmp = vtkIdList::New();
+ vtkIdList *faceIdsTmp = vtkIdList::New();
char *cellVis;
vtkIdType newCellId;
cellId,
myShowInside,
allVisible,
- myAppendCoincident3D,
+ GetAppendCoincident3D(),
cellVis,
output,
outputCD,
cellId,
myShowInside,
allVisible,
- myAppendCoincident3D,
+ GetAppendCoincident3D(),
cellVis,
output,
outputCD,
break;
}
case VTK_TETRA: {
+#ifdef SHOW_COINCIDING_3D_PAL21924
+ faceIdsTmp->Reset();
+ for (int ai=0; ai<npts; ai++)
+ faceIdsTmp->InsertNextId(pts[ai]);
+ input->GetCellNeighbors(cellId, faceIdsTmp, cellIdsTmp);
+#endif
for (faceId = 0; faceId < 4; faceId++)
{
faceIds->Reset();
aCellType = VTK_TRIANGLE;
numFacePts = 3;
input->GetCellNeighbors(cellId, faceIds, cellIds);
- bool process = cellIds->GetNumberOfIds() <= 0 ? true : myAppendCoincident3D;
+#ifdef SHOW_COINCIDING_3D_PAL21924
+ int nbNeighbors = 0;
+ for(int ai=0;ai<cellIds->GetNumberOfIds();ai++) {
+ if (cellIdsTmp->IsId(cellIds->GetId(ai)) == -1) nbNeighbors++;
+ }
+ bool process = nbNeighbors <= 0;
+#else
+ bool process = cellIds->GetNumberOfIds() <= 0 || GetAppendCoincident3D();
+#endif
if ( process || myShowInside ||
(!allVisible && !cellVis[cellIds->GetId(0)]) )
{
break;
}
case VTK_VOXEL: {
+#ifdef SHOW_COINCIDING_3D_PAL21924
+ faceIdsTmp->Reset();
+ for (int ai=0; ai<npts; ai++)
+ faceIdsTmp->InsertNextId(pts[ai]);
+ input->GetCellNeighbors(cellId, faceIdsTmp, cellIdsTmp);
+#endif
for (faceId = 0; faceId < 6; faceId++)
{
faceIds->Reset();
aCellType = VTK_QUAD;
numFacePts = 4;
input->GetCellNeighbors(cellId, faceIds, cellIds);
- bool process = cellIds->GetNumberOfIds() <= 0 ? true : myAppendCoincident3D;
+#ifdef SHOW_COINCIDING_3D_PAL21924
+ int nbNeighbors = 0;
+ for(int ai=0;ai<cellIds->GetNumberOfIds();ai++) {
+ if (cellIdsTmp->IsId(cellIds->GetId(ai)) == -1) nbNeighbors++;
+ }
+ bool process = nbNeighbors <= 0;
+#else
+ bool process = cellIds->GetNumberOfIds() <= 0 || GetAppendCoincident3D();
+#endif
if ( process || myShowInside ||
(!allVisible && !cellVis[cellIds->GetId(0)]) )
{
break;
}
case VTK_HEXAHEDRON: {
+#ifdef SHOW_COINCIDING_3D_PAL21924
+ faceIdsTmp->Reset();
+ for (int ai=0; ai<npts; ai++)
+ faceIdsTmp->InsertNextId(pts[ai]);
+ input->GetCellNeighbors(cellId, faceIdsTmp, cellIdsTmp);
+#endif
for (faceId = 0; faceId < 6; faceId++)
{
faceIds->Reset();
aCellType = VTK_QUAD;
numFacePts = 4;
input->GetCellNeighbors(cellId, faceIds, cellIds);
- bool process = cellIds->GetNumberOfIds() <= 0 ? true : myAppendCoincident3D;
+#ifdef SHOW_COINCIDING_3D_PAL21924
+ int nbNeighbors = 0;
+ for(int ai=0;ai<cellIds->GetNumberOfIds();ai++) {
+ if (cellIdsTmp->IsId(cellIds->GetId(ai)) == -1) nbNeighbors++;
+ }
+ bool process = nbNeighbors <= 0;
+#else
+ bool process = cellIds->GetNumberOfIds() <= 0 || GetAppendCoincident3D();
+#endif
if ( process || myShowInside ||
(!allVisible && !cellVis[cellIds->GetId(0)]) )
{
break;
}
case VTK_WEDGE: {
+#ifdef SHOW_COINCIDING_3D_PAL21924
+ faceIdsTmp->Reset();
+ for (int ai=0; ai<npts; ai++)
+ faceIdsTmp->InsertNextId(pts[ai]);
+ input->GetCellNeighbors(cellId, faceIdsTmp, cellIdsTmp);
+#endif
for (faceId = 0; faceId < 5; faceId++)
{
faceIds->Reset();
}
input->GetCellNeighbors(cellId, faceIds, cellIds);
- bool process = cellIds->GetNumberOfIds() <= 0 ? true : myAppendCoincident3D;
+#ifdef SHOW_COINCIDING_3D_PAL21924
+ int nbNeighbors = 0;
+ for(int ai=0;ai<cellIds->GetNumberOfIds();ai++) {
+ if (cellIdsTmp->IsId(cellIds->GetId(ai)) == -1) nbNeighbors++;
+ }
+ bool process = nbNeighbors <= 0;
+#else
+ bool process = cellIds->GetNumberOfIds() <= 0 || GetAppendCoincident3D();
+#endif
if ( process || myShowInside ||
(!allVisible && !cellVis[cellIds->GetId(0)]) )
{
break;
}
case VTK_HEXAGONAL_PRISM: {
+#ifdef SHOW_COINCIDING_3D_PAL21924
+ faceIdsTmp->Reset();
+ for (int ai=0; ai<npts; ai++)
+ faceIdsTmp->InsertNextId(pts[ai]);
+ input->GetCellNeighbors(cellId, faceIdsTmp, cellIdsTmp);
+#endif
for (faceId = 0; faceId < 8; faceId++)
{
faceVerts = vtkHexagonalPrism::GetFaceArray(faceId);
numFacePts = 6;
}
input->GetCellNeighbors(cellId, faceIds, cellIds);
- bool process = cellIds->GetNumberOfIds() <= 0 ? true : myAppendCoincident3D;
+#ifdef SHOW_COINCIDING_3D_PAL21924
+ int nbNeighbors = 0;
+ for(int ai=0;ai<cellIds->GetNumberOfIds();ai++) {
+ if (cellIdsTmp->IsId(cellIds->GetId(ai)) == -1) nbNeighbors++;
+ }
+ bool process = nbNeighbors <= 0;
+#else
+ bool process = cellIds->GetNumberOfIds() <= 0 || GetAppendCoincident3D();
+#endif
if ( process || myShowInside ||
(!allVisible && !cellVis[cellIds->GetId(0)]) )
{
break;
}
case VTK_PYRAMID: {
+#ifdef SHOW_COINCIDING_3D_PAL21924
+ faceIdsTmp->Reset();
+ for (int ai=0; ai<npts; ai++)
+ faceIdsTmp->InsertNextId(pts[ai]);
+ input->GetCellNeighbors(cellId, faceIdsTmp, cellIdsTmp);
+#endif
for (faceId = 0; faceId < 5; faceId++)
{
faceIds->Reset();
numFacePts = 4;
}
input->GetCellNeighbors(cellId, faceIds, cellIds);
- bool process = cellIds->GetNumberOfIds() <= 0 ? true : myAppendCoincident3D;
+#ifdef SHOW_COINCIDING_3D_PAL21924
+ int nbNeighbors = 0;
+ for(int ai=0;ai<cellIds->GetNumberOfIds();ai++) {
+ if (cellIdsTmp->IsId(cellIds->GetId(ai)) == -1) nbNeighbors++;
+ }
+ bool process = nbNeighbors <= 0;
+#else
+ bool process = cellIds->GetNumberOfIds() <= 0 || GetAppendCoincident3D();
+#endif
if ( process || myShowInside ||
(!allVisible && !cellVis[cellIds->GetId(0)]) )
{
vtkIdType* ptIds = 0;
int idp = 0;
input->GetFaceStream(cellId, nFaces, ptIds);
+#ifdef SHOW_COINCIDING_3D_PAL21924
+ faceIdsTmp->Reset();
+ for (int ai=0; ai<npts; ai++)
+ faceIdsTmp->InsertNextId(pts[ai]);
+ input->GetCellNeighbors(cellId, faceIdsTmp, cellIdsTmp);
+#endif
for (faceId = 0; faceId < nFaces; faceId++)
{
faceIds->Reset();
}
// TODO understand and fix display of several polyhedrons
input->GetCellNeighbors(cellId, faceIds, cellIds);
- bool process = cellIds->GetNumberOfIds() <= 0 ? true : myAppendCoincident3D;
+#ifdef SHOW_COINCIDING_3D_PAL21924
+ int nbNeighbors = 0;
+ for(int ai=0;ai<cellIds->GetNumberOfIds();ai++) {
+ if (cellIdsTmp->IsId(cellIds->GetId(ai)) == -1) nbNeighbors++;
+ }
+ bool process = nbNeighbors <= 0;
+#else
+ bool process = cellIds->GetNumberOfIds() <= 0 || GetAppendCoincident3D();
+#endif
if (process || myShowInside
|| (!allVisible && !cellVis[cellIds->GetId(0)]))
{
}
else //3D nonlinear cell
{
+#ifdef SHOW_COINCIDING_3D_PAL21924
+ faceIdsTmp->Reset();
+ int npts1 = 0;
+ switch (aCellType ){
+ case VTK_QUADRATIC_TETRA: npts1 = 4; break;
+ case VTK_QUADRATIC_HEXAHEDRON: npts1 = 8; break;
+ case VTK_TRIQUADRATIC_HEXAHEDRON: npts1 = 8; break;
+ case VTK_QUADRATIC_WEDGE: npts1 = 6; break;
+ case VTK_QUADRATIC_PYRAMID: npts1 = 5; break;
+ }
+ if ( npts1 > 0 ) {
+ for (int ai=0; ai<npts; ai++)
+ faceIdsTmp->InsertNextId(pts[ai]);
+ input->GetCellNeighbors(cellId, faceIdsTmp, cellIdsTmp);
+ }
+#endif
aCellType = VTK_TRIANGLE;
numFacePts = 3;
for (int j=0; j < cell->GetNumberOfFaces(); j++){
vtkCell *face = cell->GetFace(j);
input->GetCellNeighbors(cellId, face->PointIds, cellIds);
- bool process = cellIds->GetNumberOfIds() <= 0 ? true : myAppendCoincident3D;
+#ifdef SHOW_COINCIDING_3D_PAL21924
+ int nbNeighbors = 0;
+ for(int ai=0;ai<cellIds->GetNumberOfIds();ai++) {
+ if (cellIdsTmp->IsId(cellIds->GetId(ai)) == -1) nbNeighbors++;
+ }
+ bool process = nbNeighbors <= 0;
+#else
+ bool process = cellIds->GetNumberOfIds() <= 0 || GetAppendCoincident3D();
+#endif
if ( process || myShowInside ) {
face->Triangulate(0,lpts,coords);
for (i=0; i < lpts->GetNumberOfIds(); i+=3) {
cellIds->Delete();
faceIds->Delete();
+ cellIdsTmp->Delete();
+ faceIdsTmp->Delete();
if ( cellVis )
{
return myMaxArcAngle;
}
-
int VTKViewer_GeometryFilter::GetAppendCoincident3D() const {
+// VSR 26/10/2012: see description of SHOW_COINCIDING_3D_PAL20314
+// in the top of this file
+#ifdef SHOW_COINCIDING_3D_PAL20314
return myAppendCoincident3D;
+#else
+ return false;
+#endif
}
void VTKViewer_GeometryFilter::SetAppendCoincident3D(int theFlag) {