X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;ds=sidebyside;f=src%2FSMESH_SWIG_WITHIHM%2FlibSMESH_Swig.cxx;h=3d9a9a157b4478cdb8695912fc9c310292c3d5f3;hb=58ca79c858e1151163fef7def2ae32334b6ce7f8;hp=e33be0832b5da788eca00d87adb5f6801fea479f;hpb=560f8b2d0c2a7fdb4047f981cfac56ed3629bc1a;p=modules%2Fsmesh.git diff --git a/src/SMESH_SWIG_WITHIHM/libSMESH_Swig.cxx b/src/SMESH_SWIG_WITHIHM/libSMESH_Swig.cxx index e33be0832..3d9a9a157 100644 --- a/src/SMESH_SWIG_WITHIHM/libSMESH_Swig.cxx +++ b/src/SMESH_SWIG_WITHIHM/libSMESH_Swig.cxx @@ -1,4 +1,4 @@ -// Copyright (C) 2007-2016 CEA/DEN, EDF R&D, OPEN CADE +// Copyright (C) 2007-2020 CEA/DEN, EDF R&D, OPEN CASCADE // // This library is free software; you can redistribute it and/or // modify it under the terms of the GNU Lesser General Public @@ -37,7 +37,7 @@ /// may only be needed to be called in case if mesh objects are /// created when no active study is set to %SMESH component. /// In this case, mentioned functions can be used to forcibly -/// publish existing objects in the currrently active study. +/// publish existing objects in the currently active study. /// /// Note that if there are no open study, these methods will do /// nothing. @@ -144,9 +144,9 @@ namespace _PTR(Study) study = SMESH::getStudy(); if ( study ) { - sobject = study->FindObjectID( uid ); - if ( !sobject ) - sobject = study->FindObjectIOR( uid ); + sobject = study->FindObjectID( uid ); + if ( !sobject ) + sobject = study->FindObjectIOR( uid ); } } return sobject; @@ -168,26 +168,26 @@ namespace { if ( uid ) { - ViewManagerList vms = app->viewManagers(); - for ( int i = 0; i < vms.count() && !window; i++ ) - { - SUIT_ViewManager* vm = vms[i]; - QVector vws = vm->getViews(); - for ( int j = 0; j < vws.count() && !window; j++) - { - SUIT_ViewWindow* vw = vws[0]; - if ( uid == vw->getId() ) - window = dynamic_cast( vm->getViewModel() ); - } - } + ViewManagerList vms = app->viewManagers(); + for ( int i = 0; i < vms.count() && !window; i++ ) + { + SUIT_ViewManager* vm = vms[i]; + QVector vws = vm->getViews(); + for ( int j = 0; j < vws.count() && !window; j++) + { + SUIT_ViewWindow* vw = vws[0]; + if ( uid == vw->getId() ) + window = dynamic_cast( vm->getViewModel() ); + } + } } else { - SUIT_ViewManager* vm = app->getViewManager( SVTK_Viewer::Type(), create ); - if ( vm ) - { - window = dynamic_cast( vm->getViewModel() ); - } + SUIT_ViewManager* vm = app->getViewManager( SVTK_Viewer::Type(), create ); + if ( vm ) + { + window = dynamic_cast( vm->getViewModel() ); + } } } return window; @@ -209,11 +209,11 @@ namespace foreach( SUIT_ViewManager* vm, vms ) { if ( vm && vm->getType() == SVTK_Viewer::Type() ) - { + { SALOME_View* view = dynamic_cast( vm->getViewModel() ); if ( view ) - views << view; - } + views << view; + } } } return views; @@ -255,49 +255,49 @@ namespace if ( actor ) { actor->GetNodeColor( props.nodeColor.r, - props.nodeColor.g, - props.nodeColor.b ); + props.nodeColor.g, + props.nodeColor.b ); props.markerType = actor->GetMarkerType(); props.markerScale = actor->GetMarkerScale(); - + actor->GetEdgeColor( props.edgeColor.r, - props.edgeColor.g, - props.edgeColor.b ); + props.edgeColor.g, + props.edgeColor.b ); props.edgeWidth = qMax( (int)actor->GetLineWidth(), 1 ); - + actor->GetSufaceColor( props.surfaceColor.r, - props.surfaceColor.g, - props.surfaceColor.b, - props.surfaceColor.delta ); - + props.surfaceColor.g, + props.surfaceColor.b, + props.surfaceColor.delta ); + actor->GetVolumeColor( props.volumeColor.r, - props.volumeColor.g, - props.volumeColor.b, - props.volumeColor.delta ); - + props.volumeColor.g, + props.volumeColor.b, + props.volumeColor.delta ); + actor->Get0DColor( props.elem0dColor.r, - props.elem0dColor.g, - props.elem0dColor.b ); + props.elem0dColor.g, + props.elem0dColor.b ); props.elem0dSize = qMax( (int)actor->Get0DSize(), 1 ); - + actor->GetBallColor( props.ballColor.r, - props.ballColor.g, - props.ballColor.b ); + props.ballColor.g, + props.ballColor.b ); props.ballScale = qMax( actor->GetBallScale(), 1e-2 ); - + actor->GetOutlineColor( props.outlineColor.r, - props.outlineColor.g, - props.outlineColor.b ); + props.outlineColor.g, + props.outlineColor.b ); props.outlineWidth = qMax( (int)actor->GetOutlineWidth(), 1 ); - + actor->GetFacesOrientationColor( props.orientationColor.r, - props.orientationColor.g, - props.orientationColor.b ); + props.orientationColor.g, + props.orientationColor.b ); props.orientationScale = actor->GetFacesOrientationScale(); props.orientation3d = actor->GetFacesOrientation3DVectors(); - + props.shrinkFactor = actor->GetShrinkFactor(); - + props.opacity = actor->GetOpacity(); } return props; @@ -316,51 +316,51 @@ namespace if ( actor ) { actor->SetNodeColor( props.nodeColor.r, - props.nodeColor.g, - props.nodeColor.b ); + props.nodeColor.g, + props.nodeColor.b ); if ( props.markerType != VTK::MT_USER ) - actor->SetMarkerStd( props.markerType, props.markerScale ); - + actor->SetMarkerStd( props.markerType, props.markerScale ); + actor->SetEdgeColor( props.edgeColor.r, - props.edgeColor.g, - props.edgeColor.b ); + props.edgeColor.g, + props.edgeColor.b ); actor->SetLineWidth( qMax( (double)props.edgeWidth, 1. ) ); - + actor->SetSufaceColor( props.surfaceColor.r, - props.surfaceColor.g, - props.surfaceColor.b, - props.surfaceColor.delta ); - + props.surfaceColor.g, + props.surfaceColor.b, + props.surfaceColor.delta ); + actor->SetVolumeColor( props.volumeColor.r, - props.volumeColor.g, - props.volumeColor.b, - props.volumeColor.delta ); - + props.volumeColor.g, + props.volumeColor.b, + props.volumeColor.delta ); + actor->Set0DColor( props.elem0dColor.r, - props.elem0dColor.g, - props.elem0dColor.b ); + props.elem0dColor.g, + props.elem0dColor.b ); actor->Set0DSize( qMax( (double)props.elem0dSize, 1. ) ); - + actor->SetBallColor( props.ballColor.r, - props.ballColor.g, - props.ballColor.b ); + props.ballColor.g, + props.ballColor.b ); actor->SetBallScale( qMax( props.ballScale, 1e-2 ) ); - + actor->SetOutlineColor( props.outlineColor.r, - props.outlineColor.g, - props.outlineColor.b ); + props.outlineColor.g, + props.outlineColor.b ); actor->SetOutlineWidth( qMax( (double)props.outlineWidth, 1. ) ); - + actor->SetFacesOrientationColor( props.orientationColor.r, - props.orientationColor.g, - props.orientationColor.b ); + props.orientationColor.g, + props.orientationColor.b ); actor->SetFacesOrientationScale( props.orientationScale ); actor->SetFacesOrientation3DVectors( props.orientation3d ); - + actor->SetShrinkFactor( props.shrinkFactor ); - + actor->SetOpacity( props.opacity ); - + view->Repaint(); } } @@ -559,13 +559,16 @@ void SMESH_Swig::init() SalomeApp_Application* app = dynamic_cast( session->activeApplication() ); if ( !SMESHGUI::GetSMESHGUI() ) - app->loadModule( "Mesh" ); + app->loadModule( "Mesh" ); } }; // load SMESH GUI if it's not yet loaded - ProcessVoidEvent( new TInitEvent() ); - SMESHGUI::GetSMESHGen()->UpdateStudy(); + if ( SUIT_Session::session() ) + { + ProcessVoidEvent( new TInitEvent() ); + SMESHGUI::GetSMESHGen()->UpdateStudy(); + } } ///////////////////////////////////////////////////////////////// @@ -584,13 +587,13 @@ const char* SMESH_Swig::publish(const char* ior, const char* name) if ( !CORBA::is_nil( object ) ) { SALOMEDS::SObject_var sobject = - SMESHGUI::GetSMESHGen()->PublishInStudy( SALOMEDS::SObject::_nil(), - object.in(), - name ); + SMESHGUI::GetSMESHGen()->PublishInStudy( SALOMEDS::SObject::_nil(), + object.in(), + name ); if ( !CORBA::is_nil( sobject ) ) - { - uid = sobject->GetID(); - } + { + uid = sobject->GetID(); + } sobject->UnRegister(); } @@ -634,7 +637,7 @@ void SMESH_Swig::display(const char* uid, int viewUid, bool updateViewer) { SALOME_View* view = uid2wnd( myViewUid, true ); // create view if it's not present if ( view ) - LightApp_Displayer::FindDisplayer( "Mesh", true )->Display( myUid, myIsUpdate, view ); + LightApp_Displayer::FindDisplayer( "Mesh", true )->Display( myUid, myIsUpdate, view ); } }; @@ -668,15 +671,15 @@ void SMESH_Swig::erase(const char* uid, int viewUid, bool updateViewer) { if ( myViewUid == -1 ) { - QList views = windows(); - foreach( SALOME_View* view, views ) - LightApp_Displayer::FindDisplayer( "Mesh", true )->Erase( myUid, true, myIsUpdate, view ); + QList views = windows(); + foreach( SALOME_View* view, views ) + LightApp_Displayer::FindDisplayer( "Mesh", true )->Erase( myUid, true, myIsUpdate, view ); } else { - SALOME_View* view = uid2wnd( myViewUid ); - if ( view ) - LightApp_Displayer::FindDisplayer( "Mesh", true )->Erase( myUid, true, myIsUpdate, view ); + SALOME_View* view = uid2wnd( myViewUid ); + if ( view ) + LightApp_Displayer::FindDisplayer( "Mesh", true )->Erase( myUid, true, myIsUpdate, view ); } } }; @@ -702,8 +705,8 @@ void SMESH_Swig::update(const char* uid) TUpdateEvent( const char* uid ) : myUid( uid ) {} virtual void Execute() { - Handle(SALOME_InteractiveObject) io = - new SALOME_InteractiveObject( myUid, "SMESH", "" ); + Handle(SALOME_InteractiveObject) io = + new SALOME_InteractiveObject( myUid, "SMESH", "" ); SMESH::Update( io, true ); } }; @@ -775,7 +778,7 @@ public: QList views = windows(); foreach( SALOME_View* view, views ) { - setProperties( view, myUid, myProps ); + setProperties( view, myUid, myProps ); } } else @@ -867,7 +870,7 @@ public: { actor->SetPointsLabeled( myNumbering ); if ( view ) - view->Repaint(); + view->Repaint(); } } }; @@ -954,7 +957,7 @@ public: { actor->SetCellsLabeled( myNumbering ); if ( view ) - view->Repaint(); + view->Repaint(); } } }; @@ -1040,7 +1043,7 @@ public: { actor->SetRepresentation( myMode ); if ( view ) - view->Repaint(); + view->Repaint(); } } }; @@ -1125,11 +1128,11 @@ public: if ( actor ) { if ( myShrink ) - actor->SetShrink(); + actor->SetShrink(); else - actor->UnShrink(); + actor->UnShrink(); if ( view ) - view->Repaint(); + view->Repaint(); } } }; @@ -1215,7 +1218,7 @@ public: { actor->SetOpacity( myOpacity ); if ( view ) - view->Repaint(); + view->Repaint(); } } }; @@ -1301,7 +1304,7 @@ public: { actor->SetFacesOriented( myShown ); if ( view ) - view->Repaint(); + view->Repaint(); } } }; @@ -1387,7 +1390,7 @@ public: { actor->SetEntityMode( myEntities ); if ( view ) - view->Repaint(); + view->Repaint(); } } }; @@ -1507,7 +1510,7 @@ const char* SMESH_Swig::AddNewAlgorithm(const char* ior, const char* name) ///////////////////////////////////////////////////////////////// /// \deprecated Publishing is done automatically. -/// \deprecated Synonim of AddNewAlgorithm(). +/// \deprecated Synonym of AddNewAlgorithm(). /// \param ior IOR of the algorithm. /// \param name Name of the algorithm (optional). /// \return UID of the data object. @@ -1577,7 +1580,7 @@ void SMESH_Swig::UnSetHypothesis(const char* /*uid*/) const char* SMESH_Swig::AddSubMesh(const char* /*meshUid*/, const char* ior, int /*shapeType*/, - const char* name) + const char* name) { deprecated("SMESH_Swig::AddSubMesh", "SMESH_Swig::publish"); return publish( ior, name ); @@ -1597,7 +1600,7 @@ const char* SMESH_Swig::AddSubMeshOnShape(const char* /*meshUid*/, const char* /*shapeUid*/, const char* ior, int /*shapeType*/, - const char* name) + const char* name) { deprecated("SMESH_Swig::AddSubMeshOnShape", "SMESH_Swig::publish"); return publish( ior, name ); @@ -1716,7 +1719,7 @@ public: if ( !selMgr ) return; - + selMgr->clearFilters(); SVTK_ViewWindow* vw = SMESH::GetViewWindow(); @@ -1724,10 +1727,10 @@ public: return; SMESH_Actor* actor = SMESH::FindActorByEntry( myUid ); - + if ( !actor || !actor->hasIO() ) return; - + Handle(SALOME_InteractiveObject) io = actor->getIO(); SALOME_ListIO ios; ios.Append( io ); @@ -1735,7 +1738,7 @@ public: if ( vw->SelectionMode() == ActorSelection ) return; - + TColStd_MapOfInteger idMap; std::vector::const_iterator it; for ( it = myIds.begin(); it != myIds.end(); ++it ) @@ -1767,7 +1770,7 @@ void SMESH_Swig::select(const char* uid, std::vector ids, bool append) if ( sobject ) ProcessVoidEvent( new TSelectListEvent( sobject->GetID().c_str(), ids, append ) ); } - + ///////////////////////////////////////////////////////////////// /// \brief Select element of the mesh, sub-mesh or group. /// \param uid Mesh object's study UID or IOR. @@ -1811,7 +1814,7 @@ public: if ( !selMgr ) return; - + selMgr->clearFilters(); SVTK_ViewWindow* vw = SMESH::GetViewWindow(); @@ -1819,10 +1822,10 @@ public: return; SMESH_Actor* actor = SMESH::FindActorByEntry( myUid ); - + if ( !actor || !actor->hasIO() ) return; - + Handle(SALOME_InteractiveObject) io = actor->getIO(); SALOME_ListIO ios; ios.Append( io ); @@ -1830,7 +1833,7 @@ public: if ( vw->SelectionMode() != EdgeOfCellSelection ) return; - + SVTK_IndexedMapOfIds idMap; std::vector >::const_iterator it; for ( it = myIds.begin(); it != myIds.end(); ++it ) @@ -1887,7 +1890,7 @@ public: { SVTK_ViewWindow* vw = dynamic_cast( model->getViewManager()->getActiveView() ); if ( vw ) - myResult = (SelectionMode)vw->SelectionMode(); + myResult = (SelectionMode)vw->SelectionMode(); } } }; @@ -1925,25 +1928,25 @@ public: SVTK_ViewWindow* vw = dynamic_cast( model->getViewManager()->getActiveView() ); if ( vw ) { - SelectionMode previousMode = (SelectionMode)vw->SelectionMode(); - bool switchPointMode = ( previousMode == Node && mySelectionMode != Node ) || - ( previousMode != Node && mySelectionMode == Node ); - if ( switchPointMode ) - { - vtkRenderer* renderer = vw->getRenderer(); - VTK::ActorCollectionCopy actors( renderer->GetActors() ); - vtkActorCollection* collection = actors.GetActors(); - collection->InitTraversal(); - while ( vtkActor* vtkActor = collection->GetNextActor() ) - { - if ( SMESH_Actor* actor = dynamic_cast( vtkActor ) ) - { - if ( actor->GetVisibility() ) - actor->SetPointRepresentation( mySelectionMode == Node ); - } - } - } - vw->SetSelectionMode( mySelectionMode ); + SelectionMode previousMode = (SelectionMode)vw->SelectionMode(); + bool switchPointMode = ( previousMode == Node && mySelectionMode != Node ) || + ( previousMode != Node && mySelectionMode == Node ); + if ( switchPointMode ) + { + vtkRenderer* renderer = vw->getRenderer(); + VTK::ActorCollectionCopy actors( renderer->GetActors() ); + vtkActorCollection* collection = actors.GetActors(); + collection->InitTraversal(); + while ( vtkActor* vtkActor = collection->GetNextActor() ) + { + if ( SMESH_Actor* actor = dynamic_cast( vtkActor ) ) + { + if ( actor->GetVisibility() ) + actor->SetPointRepresentation( mySelectionMode == Node ); + } + } + } + vw->SetSelectionMode( mySelectionMode ); } } } @@ -1958,7 +1961,7 @@ public: void SMESH_Swig::setSelectionMode(SelectionMode mode, int viewUid) { init(); - ProcessVoidEvent( new TSetSelectionModeEvent( mode, viewUid ) ); + ProcessVoidEvent( new TSetSelectionModeEvent( mode, viewUid ) ); } ///////////////////////////////////////////////////////////////// @@ -1970,17 +1973,17 @@ public: typedef std::vector TResult; TResult myResult; const char* myUid; - + TGetSelectedEvent( const char* uid ) : myUid( uid ) {} - + virtual void Execute() { SVTK_ViewWindow* vw = SMESH::GetViewWindow(); if ( !vw ) return; - SVTK_Selector* selector = vw->GetSelector(); + SVTK_Selector* selector = vw->GetSelector(); if ( !selector ) return; @@ -2023,10 +2026,10 @@ public: typedef std::vector > TResult; TResult myResult; const char* myUid; - + TGetSelectedPairEvent( const char* uid ) : myUid( uid ) {} - + virtual void Execute() { SVTK_ViewWindow* vw = SMESH::GetViewWindow(); @@ -2036,7 +2039,7 @@ public: if ( vw->SelectionMode() != EdgeOfCellSelection ) return; - SVTK_Selector* selector = vw->GetSelector(); + SVTK_Selector* selector = vw->GetSelector(); if ( !selector ) return; @@ -2047,8 +2050,9 @@ public: SVTK_IndexedMapOfIds idMap; selector->GetCompositeIndex( actor->getIO(), idMap ); - for ( int i = 1; i <= idMap.Extent(); i++ ) - myResult.push_back( std::make_pair( (int)idMap( i )[0], (int)idMap( i )[1]) ); + for ( int i = 1; i <= idMap.Extent(); i++ ) { + myResult.push_back( std::make_pair( (int)idMap(i)[0], (int)idMap(i)[1]) ); + } } };