X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FSMESHGUI%2FSMESHGUI.cxx;h=0daf4dd4c25bc2c30433854483a0d89cda0a020c;hb=709c3dba309ecf9dab3db36de849525cf6ca545d;hp=e3d8df78712a71c96f9a8da371ae57cde8fec782;hpb=cf0ecc3c366225cb0a83dffc5006c5f06f40700f;p=modules%2Fsmesh.git diff --git a/src/SMESHGUI/SMESHGUI.cxx b/src/SMESHGUI/SMESHGUI.cxx index e3d8df787..0daf4dd4c 100644 --- a/src/SMESHGUI/SMESHGUI.cxx +++ b/src/SMESHGUI/SMESHGUI.cxx @@ -25,9 +25,9 @@ // $Header$ #include "SMESHGUI.h" -#include "SMESHGUI_InitMeshDlg.h" -#include "SMESHGUI_AddSubMeshDlg.h" -#include "SMESHGUI_NodesDlg.h" +#include "SMESHGUI_InitMeshOp.h" +#include "SMESHGUI_AddSubMeshOp.h" +#include "SMESHGUI_NodesOp.h" #include "SMESHGUI_TransparencyDlg.h" #include "SMESHGUI_ClippingDlg.h" #include "SMESHGUI_GroupDlg.h" @@ -41,14 +41,14 @@ #include "SMESHGUI_Hypotheses.h" #include "SMESHGUI_HypothesesUtils.h" #include "SMESHGUI_MoveNodesDlg.h" -#include "SMESHGUI_AddMeshElementDlg.h" -#include "SMESHGUI_EditHypothesesDlg.h" +#include "SMESHGUI_AddMeshElementOp.h" +#include "SMESHGUI_EditHypothesesOp.h" #include "SMESHGUI_CreateHypothesesDlg.h" #include "SMESHGUI_FilterDlg.h" #include "SMESHGUI_FilterLibraryDlg.h" #include "SMESHGUI_SingleEditDlg.h" #include "SMESHGUI_MultiEditDlg.h" -#include "SMESHGUI_GroupOpDlg.h" +#include "SMESHGUI_GroupOp.h" #include "SMESHGUI_DeleteGroupDlg.h" #include "SMESHGUI_SmoothingDlg.h" #include "SMESHGUI_RenumberingDlg.h" @@ -92,13 +92,17 @@ #include "QtxPopupMgr.h" -#include "SalomeApp_Application.h" -#include "SalomeApp_NameDlg.h" -#include "SalomeApp_DataOwner.h" -#include "SalomeApp_ImportOperation.h" #include "SalomeApp_Tools.h" #include "SalomeApp_Study.h" +#include "SalomeApp_NameDlg.h" +#include "SalomeApp_DataOwner.h" +#include "SalomeApp_Application.h" +#include "SalomeApp_Preferences.h" #include "SalomeApp_VTKSelector.h" +#include "SalomeApp_Operation.h" +#include "SalomeApp_UpdateFlags.h" + +#include "SalomeApp_ImportOperation.h" #include #include @@ -240,6 +244,8 @@ namespace{ QObject::tr("SMESH_BUT_OK")); wc.resume(); } + + SMESHGUI::GetSMESHGUI()->updateObjBrowser(); } catch (const SALOME::SALOME_Exception& S_ex){ wc.suspend(); @@ -305,9 +311,26 @@ namespace{ SUIT_FileDlg* fd = new SUIT_FileDlg( SMESHGUI::desktop(), false, true, true ); fd->setCaption( aTitle ); fd->setFilters( filters ); - fd->exec(); - aFilename = fd->selectedFile(); - aFormat = aFilterMap[fd->selectedFilter()]; + bool is_ok = false; + while(!is_ok){ + fd->exec(); + aFilename = fd->selectedFile(); + aFormat = aFilterMap[fd->selectedFilter()]; + is_ok = true; + if( !aFilename.isEmpty() + && (aMesh->NbPolygons()>0 or aMesh->NbPolyhedrons()>0) + && aFormat==SMESH::MED_V2_1){ + int aRet = SUIT_MessageBox::warn2(SMESHGUI::desktop(), + QObject::tr("SMESH_WRN_WARNING"), + QObject::tr("SMESH_EXPORT_MED_V2_1").arg(anIObject->getName()), + QObject::tr("SMESH_BUT_YES"), + QObject::tr("SMESH_BUT_NO"), + 0,1,0); + if(aRet){ + is_ok = false; + } + } + } delete fd; } if ( !aFilename.isEmpty() ) { @@ -802,46 +825,10 @@ namespace{ } } -//============================================================================= -/*! - * - */ -//============================================================================= -class CustomItem : public QCustomMenuItem -{ -public: - CustomItem(const QString& s, const QFont& f) : myString(s), myFont(f) {} - ~CustomItem() {} - - void paint(QPainter* p, const QColorGroup& cg, bool act, bool /*enabled*/, int x, int y, int w, int h) - { - p->save(); - p->fillRect( x, y, w, h, act ? cg.highlight() : cg.mid() ); - p->setPen( act ? cg.highlightedText() : cg.buttonText() ); - p->setFont( myFont ); - p->drawText( x, y, w, h, AlignHCenter | AlignVCenter | ShowPrefix | DontClip | SingleLine, myString ); - p->restore(); - } - - QSize sizeHint() - { - return QFontMetrics( myFont ).size( AlignHCenter | AlignVCenter | ShowPrefix | DontClip | SingleLine, myString ); - } - - bool fullSpan() const - { - return true; - } - -private: - QString myString; - QFont myFont; -}; - extern "C" { Standard_EXPORT CAM_Module* createModule() { - return SMESHGUI::GetSMESHGUI(); + return new SMESHGUI(); } } @@ -853,7 +840,7 @@ SMESH::SMESH_Gen_var SMESHGUI::myComponentSMESH = SMESH::SMESH_Gen::_nil(); */ //============================================================================= SMESHGUI::SMESHGUI() : - SalomeApp_Module( "SMESH" ) +SalomeApp_Module( "SMESH" ) { if ( CORBA::is_nil( myComponentSMESH ) ) { @@ -896,6 +883,15 @@ SalomeApp_SelectionMgr* SMESHGUI::selectionMgr() return 0; } +bool SMESHGUI::automaticUpdate() +{ + SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr(); + if ( !resMgr ) + return false; + + return resMgr->booleanValue( "SMESH", "auto_update", false ); +} + //============================================================================= /*! * @@ -913,24 +909,32 @@ SUIT_ResourceMgr* SMESHGUI::resourceMgr() //============================================================================= SMESHGUI* SMESHGUI::GetSMESHGUI() { - static SMESHGUI* aSMESHGUI = NULL; - if( !aSMESHGUI ) - aSMESHGUI = new SMESHGUI(); - - if(_PTR(Study) aStudy = SMESH::GetActiveStudyDocument()) - GetSMESHGen()->SetCurrentStudy( _CAST(Study,aStudy)->GetStudy() ); + SMESHGUI* smeshMod = 0; + SalomeApp_Application* app = dynamic_cast(SUIT_Session::session()->activeApplication()); + if ( app ) + { + CAM_Module* module = app->module( "Mesh" ); + smeshMod = dynamic_cast( module ); + } - SUIT_ResourceMgr* mgr = resourceMgr(); - if( mgr ) - /* Automatic Update flag */ - aSMESHGUI->myAutomaticUpdate = ( mgr->stringValue( "SMESH", "AutomaticUpdate" ).compare( "true" ) == 0 ); + if ( smeshMod && smeshMod->application() && smeshMod->application()->activeStudy() ) + { + SalomeApp_Study* study = dynamic_cast( smeshMod->application()->activeStudy() ); + if ( study ) + { + _PTR(Study) aStudy = study->studyDS(); + if ( aStudy ) + GetSMESHGen()->SetCurrentStudy( _CAST(Study,aStudy)->GetStudy() ); + } + } - return aSMESHGUI; + return smeshMod; } extern "C" { - Standard_EXPORT SMESHGUI* GetComponentGUI() { + Standard_EXPORT SMESHGUI* GetComponentGUI() + { return SMESHGUI::GetSMESHGUI(); } } @@ -962,6 +966,7 @@ void SMESHGUI::ResetState() //============================================================================= void SMESHGUI::EmitSignalDeactivateDialog() { + printf( "sln: EmitSignalDeactivateDialog EmitSignalDeactivateDialog EmitSignalDeactivateDialog\n" ); emit SignalDeactivateActiveDialog(); } @@ -1097,6 +1102,13 @@ bool SMESHGUI::OnGUIEvent( int theCommandID ) if( !mgr ) return false; + SUIT_Operation* anOp = getOperation( theCommandID ); + if ( anOp != 0 ) + { + anOp->start(); + return true; + } + SUIT_ViewWindow* view = application()->desktop()->activeWindow(); SVTK_ViewWindow* vtkwnd = dynamic_cast( view ); @@ -1215,7 +1227,8 @@ bool SMESHGUI::OnGUIEvent( int theCommandID ) case 400: // NODES { if(checkLock(aStudy)) break; - + startOperation( 400 ); +/* if ( vtkwnd ) { EmitSignalDeactivateDialog(); @@ -1226,7 +1239,7 @@ bool SMESHGUI::OnGUIEvent( int theCommandID ) tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"), tr("SMESH_BUT_OK")); - } + } */ break; } @@ -1334,8 +1347,7 @@ bool SMESHGUI::OnGUIEvent( int theCommandID ) } CORBA::Long anId = aStudy->StudyId(); TVisualObjPtr aVisualObj = SMESH::GetVisualObj(anId,IObject->getEntry()); - cout<<"myAutomaticUpdate - "<Update(); SMESH_Actor* anActor = SMESH::FindActorByEntry(IObject->getEntry()); if(!anActor){ @@ -1352,13 +1364,15 @@ bool SMESHGUI::OnGUIEvent( int theCommandID ) tr("SMESH_WRN_VIEWER_VTK"), tr("SMESH_BUT_OK")); } + updateObjBrowser(); break; } case 702: // ADD SUB MESH { if(checkLock(aStudy)) break; - if( vtkwnd ) { + startOperation( 702 ); +/* if( vtkwnd ) { EmitSignalDeactivateDialog(); new SMESHGUI_AddSubMeshDlg( this ); } @@ -1366,39 +1380,35 @@ bool SMESHGUI::OnGUIEvent( int theCommandID ) SUIT_MessageBox::warn1(desktop(), tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"), tr("SMESH_BUT_OK")); - } + }*/ break; } case 703: // INIT MESH { if(checkLock(aStudy)) break; - EmitSignalDeactivateDialog(); - new SMESHGUI_InitMeshDlg( this ); + startOperation( 703 ); break; } case 704: // EDIT Hypothesis { if(checkLock(aStudy)) break; - EmitSignalDeactivateDialog(); - new SMESHGUI_EditHypothesesDlg( this ); + startOperation( 704 ); break; } case 705: // EDIT Global Hypothesis { if(checkLock(aStudy)) break; - EmitSignalDeactivateDialog(); - new SMESHGUI_EditHypothesesDlg( this ); + startOperation( 704 ); break; } case 706: // EDIT Local Hypothesis { if(checkLock(aStudy)) break; - EmitSignalDeactivateDialog(); - new SMESHGUI_EditHypothesesDlg( this ); + startOperation( 704 ); break; } @@ -1426,9 +1436,9 @@ bool SMESHGUI::OnGUIEvent( int theCommandID ) */ EmitSignalDeactivateDialog(); if ( theCommandID == 407 ) - new SMESHGUI_TrianglesInversionDlg(this); + startOperation( 407 ); else - new SMESHGUI_UnionOfTwoTrianglesDlg(this); + startOperation( 408 ); break; } case 409: // Change orientation @@ -1623,6 +1633,13 @@ bool SMESHGUI::OnGUIEvent( int theCommandID ) case 803: // EDIT GROUP { + if ( !vtkwnd ) + { + SUIT_MessageBox::warn1( desktop(), tr( "SMESH_WRN_WARNING" ), + tr( "NOT_A_VTK_VIEWER" ),tr( "SMESH_BUT_OK" ) ); + break; + } + if(checkLock(aStudy)) break; EmitSignalDeactivateDialog(); @@ -1675,22 +1692,20 @@ bool SMESHGUI::OnGUIEvent( int theCommandID ) case 811: // Intersect groups case 812: // Cut groups { - if ( checkLock( aStudy ) ) - break; - - EmitSignalDeactivateDialog(); - - int aMode; - if ( theCommandID == 810 ) aMode = SMESHGUI_GroupOpDlg::UNION; - else if ( theCommandID == 811 ) aMode = SMESHGUI_GroupOpDlg::INTERSECT; - else aMode = SMESHGUI_GroupOpDlg::CUT; - - ( new SMESHGUI_GroupOpDlg( this, aMode ) )->show(); + if( !checkLock( aStudy ) ) + startOperation( theCommandID ); break; } case 813: // Delete groups with their contents { + if ( !vtkwnd ) + { + SUIT_MessageBox::warn1( desktop(), tr( "SMESH_WRN_WARNING" ), + tr( "NOT_A_VTK_VIEWER" ),tr( "SMESH_BUT_OK" ) ); + break; + } + if ( checkLock( aStudy ) ) break; @@ -1751,14 +1766,14 @@ bool SMESHGUI::OnGUIEvent( int theCommandID ) case 1001: // AUTOMATIC UPDATE PREFERENCES { - if (act->isOn()) { - mgr->setValue( "SMESH", "AutomaticUpdate", true ); - myAutomaticUpdate = true; - } - else { - mgr->setValue( "SMESH", "AutomaticUpdate", false ); - myAutomaticUpdate = false; - } +// if (act->isOn()) { +// mgr->setValue( "SMESH", "AutomaticUpdate", true ); +// myAutomaticUpdate = true; +// } +// else { +// mgr->setValue( "SMESH", "AutomaticUpdate", false ); +// myAutomaticUpdate = false; +// } break; } @@ -1894,6 +1909,7 @@ bool SMESHGUI::OnGUIEvent( int theCommandID ) } } } + updateObjBrowser( true ); break; } @@ -1969,7 +1985,8 @@ bool SMESHGUI::OnGUIEvent( int theCommandID ) case 4032: // HEXA { if(checkLock(aStudy)) break; - if ( vtkwnd ) { + startOperation( theCommandID ); +/* if ( vtkwnd ) { EmitSignalDeactivateDialog(); SMDSAbs_ElementType type = SMDSAbs_Edge; int nbNodes = 2; @@ -1994,7 +2011,7 @@ bool SMESHGUI::OnGUIEvent( int theCommandID ) SUIT_MessageBox::warn1(desktop(), tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"), tr("SMESH_BUT_OK")); - } + }*/ break; } case 4033: // POLYHEDRON @@ -2279,7 +2296,7 @@ bool SMESHGUI::OnGUIEvent( int theCommandID ) } - updateObjBrowser(); + //updateObjBrowser(); return true; } @@ -2362,14 +2379,14 @@ bool SMESHGUI::SetSettings(SUIT_Desktop* parent) action( 10003 )->setOn( Shrink ); // Automatic Update - if ( mgr->booleanValue( "SMESH","AutomaticUpdate", false ) ) { - action( 1001 )->setOn( true ); - myAutomaticUpdate = true; - } - else { - action( 1001 )->setOn( false ); - myAutomaticUpdate = false; - } +// if ( mgr->booleanValue( "SMESH","AutomaticUpdate", false ) ) { +// action( 1001 )->setOn( true ); +// myAutomaticUpdate = true; +// } +// else { +// action( 1001 )->setOn( false ); +// myAutomaticUpdate = false; +// } if ( mgr->booleanValue( "SMESH","DispayEntity", false ) ) action( 10071 )->setOn( true ); @@ -2415,7 +2432,7 @@ void SMESHGUI::createSMESHAction( const int id, const QString& po_id, const QStr if ( icon_id.length() ) pix = resMgr->loadPixmap( "SMESH", tr( icon_id ) ); else - pix = resMgr->loadPixmap( "SMESH", tr( QString( "ICO_" )+po_id ) ); + pix = resMgr->loadPixmap( "SMESH", tr( QString( "ICO_" )+po_id ), false ); if ( !pix.isNull() ) icon = QIconSet( pix ); @@ -2440,7 +2457,7 @@ void SMESHGUI::createPopupItem( const int id, if( pId!=-1 ) parentId = popupMgr()->actionId( action( pId ) ); - if( !popupMgr()->contains( popupMgr()->actionId( action( id ) ) ) ) +// if( !popupMgr()->contains( popupMgr()->actionId( action( id ) ) ) ) popupMgr()->insert( action( id ), parentId, 0 ); QChar lc = QtxPopupMgr::Selection::defEquality(); @@ -2466,6 +2483,11 @@ void SMESHGUI::initialize( CAM_Application* app ) { SalomeApp_Module::initialize( app ); +// SUIT_ResourceMgr* mgr = app->resourceMgr(); +// if ( mgr ) + /* Automatic Update flag */ +// myAutomaticUpdate = mgr->booleanValue( "SMESH", "AutomaticUpdate", myAutomaticUpdate ); + // ----- create actions -------------- createSMESHAction( 111, "DAT", "", (CTRL+Key_B) ); @@ -2856,7 +2878,7 @@ void SMESHGUI::initialize( CAM_Application* app ) QString aSelCount = QString( "%1 = 1" ).arg( QtxPopupMgr::Selection::defSelCountParam() ); QString lc = QtxPopupMgr::Selection::defEquality(); - QString aClient = QString( "%1client in {%2}" ).arg( lc ).arg( "'VTKViewer' 'ObjectBrowser'" ); + QString aClient = QString( "%1client in {%2}" ).arg( lc ).arg( "'VTKViewer'" ); QString aType = QString( "%1type in {%2}" ).arg( QtxPopupMgr::Selection::defEquality() ).arg( mesh_group ); QString aMeshInVTK = aClient + "&&" + aType;// + "&&" + aSelCount; @@ -3024,7 +3046,8 @@ void SMESHGUI::initialize( CAM_Application* app ) // Display / Erase //------------------------------------------------- aClient = "($client in {'VTKViewer' 'ObjectBrowser'})"; - QString aRule = aClient + " and " + aType + " and " + aSelCount; + QString anActiveVTK = QString("activeView = '%1'").arg(VTKViewer_Viewer::Type()); + QString aRule = aClient + " and " + aType + " and " + aSelCount + " and " + anActiveVTK; popupMgr()->insert( action( 301 ), -1, -1 ); // DISPLAY popupMgr()->setRule( action( 301 ), aRule + "&&" + isNotEmpty + "&&" + isInvisible, true); @@ -3073,6 +3096,11 @@ void SMESHGUI::OnGUIEvent() SMESH::SMESH_Gen_var SMESHGUI::GetSMESHGen() { + if ( CORBA::is_nil( myComponentSMESH ) ) + { + SMESHGUI aGUI; //SRN BugID: IPAL9186: Create an instance of SMESHGUI to initialize myComponentSMESH + return aGUI.myComponentSMESH; + } return myComponentSMESH; } @@ -3103,6 +3131,231 @@ void SMESHGUI::viewManagers( QStringList& list ) const void SMESHGUI::onViewManagerAdded( SUIT_ViewManager* mgr ) { - if( dynamic_cast( mgr ) ) + if ( dynamic_cast( mgr ) ) SMESH::UpdateSelectionProp( this ); } + +void SMESHGUI::createPreferences() +{ + int genTab = addPreference( tr( "PREF_TAB_GENERAL" ) ); + + int qaGroup = addPreference( tr( "PREF_GROUP_QUALITY" ), genTab ); + addPreference( tr( "PREF_DISPLAY_ENTITY" ), qaGroup, SalomeApp_Preferences::Bool, "Mesh", "display_entity" ); + addPreference( tr( "PREF_AUTO_UPDATE" ), qaGroup, SalomeApp_Preferences::Bool, "Mesh", "auto_update" ); + + int precGroup = addPreference( tr( "PREF_GROUP_PRECISION" ), genTab ); + setPreferenceProperty( precGroup, "columns", 1 ); + + addPreference( tr( "PREF_PRECISION_USE" ), precGroup, SalomeApp_Preferences::Bool ); + int prec = addPreference( tr( "PREF_PRECISION_VALUE" ), precGroup, SalomeApp_Preferences::IntSpin, "SMESH", "controls_precision" ); + + setPreferenceProperty( prec, "min", 0 ); + setPreferenceProperty( prec, "max", 16 ); + + int meshTab = addPreference( tr( "PREF_TAB_MESH" ) ); + int nodeGroup = addPreference( tr( "PREF_GROUP_NODES" ), meshTab ); + + addPreference( tr( "PREF_COLOR" ), nodeGroup, SalomeApp_Preferences::Color, "SMESH", "node_color" ); + int nodeSz = addPreference( tr( "PREF_SIZE" ), nodeGroup, SalomeApp_Preferences::IntSpin, "SMESH", "node_size" ); + + setPreferenceProperty( nodeSz, "min", 1 ); + setPreferenceProperty( nodeSz, "max", 5 ); + + int elemGroup = addPreference( tr( "PREF_GROUP_ELEMENTS" ), meshTab ); + + addPreference( tr( "PREF_FILL" ), elemGroup, SalomeApp_Preferences::Color, "SMESH", "fill_color" ); + addPreference( tr( "PREF_OUTLINE" ), elemGroup, SalomeApp_Preferences::Color, "SMESH", "outline_color" ); + addPreference( tr( "PREF_BACKFACE" ), elemGroup, SalomeApp_Preferences::Color, "SMESH", "backface_color" ); + addPreference( "", elemGroup, SalomeApp_Preferences::Space ); + + int elemW = addPreference( tr( "PREF_WIDTH" ), elemGroup, SalomeApp_Preferences::IntSpin, "SMESH", "element_width" ); + int shrink = addPreference( tr( "PREF_SHRINK_COEFF" ), elemGroup, SalomeApp_Preferences::IntSpin, "SMESH", "shrink_coeff" ); + + setPreferenceProperty( elemW, "min", 1 ); + setPreferenceProperty( elemW, "max", 5 ); + + setPreferenceProperty( shrink, "min", 0 ); + setPreferenceProperty( shrink, "max", 100 ); + + int selTab = addPreference( tr( "PREF_TAB_SELECTION" ) ); + + int selGroup = addPreference( tr( "PREF_GROUP_SELECTION" ), selTab ); + + addPreference( tr( "PREF_OBJECT_COLOR" ), selGroup, SalomeApp_Preferences::Color, "SMESH", "selection_object_color" ); + addPreference( tr( "PREF_ELEMENT_COLOR" ), selGroup, SalomeApp_Preferences::Color, "SMESH", "selection_element_color" ); + int selW = addPreference( tr( "PREF_WIDTH" ), selGroup, SalomeApp_Preferences::IntSpin, "SMESH", "selection_width" ); + + setPreferenceProperty( selW, "min", 1 ); + setPreferenceProperty( selW, "max", 5 ); + + int preGroup = addPreference( tr( "PREF_GROUP_PRESELECTION" ), selTab ); + + addPreference( tr( "PREF_HIGHLIGHT_COLOR" ), preGroup, SalomeApp_Preferences::Color, "SMESH", "highlight_color" ); + int preW = addPreference( tr( "PREF_WIDTH" ), preGroup, SalomeApp_Preferences::IntSpin, "SMESH", "highlight_width" ); + + setPreferenceProperty( preW, "min", 1 ); + setPreferenceProperty( preW, "max", 5 ); + + int precSelGroup = addPreference( tr( "PREF_GROUP_PRECISION" ), selTab ); + + addPreference( tr( "PREF_NODES" ), precSelGroup, SalomeApp_Preferences::Double, "SMESH", "selection_precision_node" ); + addPreference( tr( "PREF_ELEMENTS" ), precSelGroup, SalomeApp_Preferences::Double, "SMESH", "selection_precision_element" ); +} + +void SMESHGUI::preferencesChanged( const QString&, const QString& ) +{ +} + +//======================================================================= +// function : onOperationCommited +// purpose : SLOT called when operation commited. Set default selection mode +//======================================================================= +void SMESHGUI::onOperationCommited( SUIT_Operation* ) +{ + SVTK_ViewWindow* vtkWnd = + dynamic_cast( application()->desktop()->activeWindow() ); + if ( vtkWnd ) + vtkWnd->SetSelectionMode( ActorSelection ); +} + +//======================================================================= +// function : onOperationAborted +// purpose : SLOT called when operation commited. Set default selection mode +//======================================================================= +void SMESHGUI::onOperationAborted( SUIT_Operation* ) +{ + SVTK_ViewWindow* vtkWnd = + dynamic_cast( application()->desktop()->activeWindow() ); + if ( vtkWnd ) + vtkWnd->SetSelectionMode( ActorSelection ); +} + +//======================================================================= +// function : getOperation +// purpose : Get operation corresponding to the given Id +//======================================================================= +SalomeApp_Operation* SMESHGUI::getOperation( const int theId ) +{ + if ( myOperations.contains( theId ) ) + return myOperations[ theId ]; + + // to do: + SalomeApp_Operation* anOp = 0; + /*switch( theId ) + { + case ... : + anOp = ...; + break; + }*/ + + if ( anOp != 0 ) + { + anOp->setModule( this ); + connect( anOp, SIGNAL( aborted( SUIT_Operation* ) ), + this, SLOT( onOperationAborted( SUIT_Operation* ) ) ); + connect( anOp, SIGNAL( commited( SUIT_Operation* ) ), + this, SLOT( onOperationCommited( SUIT_Operation* ) ) ); + myOperations[ theId ] = anOp; + + } + + return anOp; +} + +//======================================================================= +// function : update +// purpose : Update something +//======================================================================= +void SMESHGUI::update( const int flags ) +{ + if ( flags & UF_Viewer | flags & UF_Forced ) + SMESH::UpdateView(); + else + SalomeApp_Module::update( flags ); +} + +//======================================================================= +// function : updateControls +// purpose : Update state of controls +//======================================================================= +void SMESHGUI::updateControls() +{ + // to do +} + +//======================================================================= +// function : updateControls +// purpose : Update state of controls +//======================================================================= +SalomeApp_Operation* SMESHGUI::createOperation( const int id ) const +{ + SalomeApp_Operation* op = 0; + switch( id ) + { + case 400: + op = new SMESHGUI_NodesOp(); + break; + + case 401: + op = new SMESHGUI_AddMeshElementOp( SMDSAbs_Edge, 2 ); + break; + + case 4021: + op = new SMESHGUI_AddMeshElementOp( SMDSAbs_Face, 3 ); + break; + + case 4022: + op = new SMESHGUI_AddMeshElementOp( SMDSAbs_Face, 4 ); + break; + + case 4023: + op = new SMESHGUI_AddMeshElementOp( SMDSAbs_Face, 5 ); // 5 - identificator for POLYGON + break; + + case 4031: + op = new SMESHGUI_AddMeshElementOp( SMDSAbs_Volume, 4 ); + break; + + case 4032: + op = new SMESHGUI_AddMeshElementOp( SMDSAbs_Volume, 8 ); + break; + + case 702: + op = new SMESHGUI_AddSubMeshOp(); + break; + + case 703: + op = new SMESHGUI_InitMeshOp(); + break; + + case 704: + op = new SMESHGUI_EditHypothesesOp(); + break; + + case 810: + op = new SMESHGUI_GroupOp( SMESHGUI_GroupOp::UNION ); + break; + + case 811: + op = new SMESHGUI_GroupOp( SMESHGUI_GroupOp::INTERSECT ); + break; + + case 812: + op = new SMESHGUI_GroupOp( SMESHGUI_GroupOp::CUT ); + break; + + default: + op = SalomeApp_Module::createOperation( id ); + break; + } + return op; +} + + + + + + + + +