diff --git a/src/OBJECT/SMESH_Actor.cxx b/src/OBJECT/SMESH_Actor.cxx index 3db87dba4..7bea5e30b 100644 --- a/src/OBJECT/SMESH_Actor.cxx +++ b/src/OBJECT/SMESH_Actor.cxx @@ -33,7 +33,9 @@ #include "SMESH_ControlsDef.hxx" #include -//#include "QAD_Config.h" +#include "SUIT_Session.h" +#include "SUIT_ResourceMgr.h" + #include #include @@ -288,38 +290,38 @@ SMESH_ActorDef::SMESH_ActorDef() vtkTextProperty* aScalarBarTitleProp = vtkTextProperty::New(); -/* if ( QAD_CONFIG->hasSetting( "SMESH:ScalarBarTitleColor" ) ) { - QStringList aTColor = QStringList::split( ":", QAD_CONFIG->getSetting( "SMESH:ScalarBarTitleColor" ), false ); - aScalarBarTitleProp->SetColor( ( aTColor.count() > 0 ? aTColor[0].toInt()/255. : 1.0 ), - ( aTColor.count() > 1 ? aTColor[1].toInt()/255. : 1.0 ), - ( aTColor.count() > 2 ? aTColor[2].toInt()/255. : 1.0 ) ); - } - else*/ - aScalarBarTitleProp->SetColor( 1.0, 1.0, 1.0 ); + SUIT_ResourceMgr* mgr = SUIT_Session::session()->resourceMgr(); + if( !mgr ) + return; + + QColor aTColor = mgr->colorValue( "ScalarBarTitleColor", "SMESH", QColor( 255, 255, 255 ) ); + aScalarBarTitleProp->SetColor( aTColor.red()/255., aTColor.green()/255., aTColor.blue()/255. ); aScalarBarTitleProp->SetFontFamilyToArial(); - /*if( QAD_CONFIG->hasSetting( "SMESH:ScalarBarTitleFont" ) ){ - if ( QAD_CONFIG->getSetting( "SMESH:ScalarBarTitleFont" ) == "Arial" ) + + if( mgr->hasValue( "ScalarBarTitleFont", "SMESH" ) ){ + QString str = mgr->stringValue( "ScalarBarTitleFont", "SMESH" ); + if ( str == "Arial" ) aScalarBarTitleProp->SetFontFamilyToArial(); - else if ( QAD_CONFIG->getSetting( "SMESH:ScalarBarTitleFont" ) == "Courier" ) + else if ( str == "Courier" ) aScalarBarTitleProp->SetFontFamilyToCourier(); - else if ( QAD_CONFIG->getSetting( "SMESH:ScalarBarTitleFont" ) == "Times" ) + else if ( str == "Times" ) aScalarBarTitleProp->SetFontFamilyToTimes(); - }*/ + } - /*if ( QAD_CONFIG->getSetting( "SMESH:ScalarBarTitleBold" ) == "true" ) + if ( mgr->stringValue( "ScalarBarTitleBold", "SMESH" ) == "true" ) aScalarBarTitleProp->BoldOn(); - else*/ + else aScalarBarTitleProp->BoldOff(); - /*if ( QAD_CONFIG->getSetting( "SMESH:ScalarBarTitleItalic" ) == "true" ) + if ( mgr->stringValue( "ScalarBarTitleItalic", "SMESH" ) == "true" ) aScalarBarTitleProp->ItalicOn(); - else*/ + else aScalarBarTitleProp->ItalicOff(); - /*if ( QAD_CONFIG->getSetting( "SMESH:ScalarBarTitleShadow" ) == "true" ) + if ( mgr->stringValue( "ScalarBarTitleShadow", "SMESH" ) == "true" ) aScalarBarTitleProp->ShadowOn(); - else*/ + else aScalarBarTitleProp->ShadowOff(); myScalarBarActor->SetTitleTextProperty( aScalarBarTitleProp ); @@ -327,75 +329,71 @@ SMESH_ActorDef::SMESH_ActorDef() vtkTextProperty* aScalarBarLabelProp = vtkTextProperty::New(); - /*if ( QAD_CONFIG->hasSetting( "SMESH:ScalarBarLabelColor" ) ) { - QStringList aTColor = QStringList::split( ":", QAD_CONFIG->getSetting( "SMESH:ScalarBarLabelColor" ), false ); - aScalarBarLabelProp->SetColor( ( aTColor.count() > 0 ? aTColor[0].toInt()/255. : 1.0 ), - ( aTColor.count() > 1 ? aTColor[1].toInt()/255. : 1.0 ), - ( aTColor.count() > 2 ? aTColor[2].toInt()/255. : 1.0 ) ); - } - else*/ - aScalarBarLabelProp->SetColor( 1.0, 1.0, 1.0 ); + aTColor = mgr->colorValue( "ScalarBarLabelColor", "SMESH", QColor( 255, 255, 255 ) ); + aScalarBarLabelProp->SetColor( aTColor.red()/255., aTColor.green()/255., aTColor.blue()/255. ); aScalarBarLabelProp->SetFontFamilyToArial(); - /*if( QAD_CONFIG->hasSetting( "SMESH:ScalarBarLabelFont" ) ){ - if ( QAD_CONFIG->getSetting( "SMESH:ScalarBarLabelFont" ) == "Arial" ) + if( mgr->hasValue( "ScalarBarLabelFont", "SMESH" ) ) + { + QString str = mgr->stringValue( "ScalarBarLabelFont", "SMESH" ); + if( str == "Arial" ) aScalarBarLabelProp->SetFontFamilyToArial(); - else if ( QAD_CONFIG->getSetting( "SMESH:ScalarBarLabelFont" ) == "Courier" ) + else if( str == "Courier" ) aScalarBarLabelProp->SetFontFamilyToCourier(); - else if ( QAD_CONFIG->getSetting( "SMESH:ScalarBarLabelFont" ) == "Times" ) + else if( str == "Times" ) aScalarBarLabelProp->SetFontFamilyToTimes(); - }*/ + } - /*if ( QAD_CONFIG->getSetting( "SMESH:ScalarBarLabelBold" ) == "true" ) + if( mgr->stringValue( "ScalarBarLabelBold", "SMESH" ) == "true" ) aScalarBarLabelProp->BoldOn(); - else*/ + else aScalarBarLabelProp->BoldOff(); - /*if ( QAD_CONFIG->getSetting( "SMESH:ScalarBarLabelItalic" ) == "true" ) + if ( mgr->stringValue( "ScalarBarLabelItalic", "SMESH" ) == "true" ) aScalarBarLabelProp->ItalicOn(); - else*/ + else aScalarBarLabelProp->ItalicOff(); - /*if ( QAD_CONFIG->getSetting( "SMESH:ScalarBarLabelShadow" ) == "true" ) + if( mgr->stringValue( "ScalarBarLabelShadow", "SMESH" ) == "true" ) aScalarBarLabelProp->ShadowOn(); - else*/ + else aScalarBarLabelProp->ShadowOff(); myScalarBarActor->SetLabelTextProperty( aScalarBarLabelProp ); aScalarBarLabelProp->Delete(); - /*if ( QAD_CONFIG->getSetting("SMESH:ScalarBarOrientation") == "Horizontal" ) + if( mgr->stringValue( "ScalarBarOrientation", "SMESH" ) == "Horizontal" ) myScalarBarActor->SetOrientationToHorizontal(); - else*/ + else myScalarBarActor->SetOrientationToVertical(); - float aXVal = 0.01; //QAD_CONFIG->getSetting("SMESH:ScalarBarOrientation") == "Horizontal" ? 0.20 : 0.01; - //if ( QAD_CONFIG->hasSetting( "SMESH:ScalarBarXPosition" ) ) - // aXVal = QAD_CONFIG->getSetting( "SMESH:ScalarBarXPosition" ).toFloat(); - float aYVal = 0.1; //QAD_CONFIG->getSetting("SMESH:ScalarBarOrientation") == "Horizontal" ? 0.01 : 0.1; - //if ( QAD_CONFIG->hasSetting( "SMESH:ScalarBarYPosition" ) ) - // aYVal = QAD_CONFIG->getSetting( "SMESH:ScalarBarYPosition" ).toFloat(); + float aXVal = mgr->stringValue( "ScalarBarOrientation", "SMESH" ) == "Horizontal" ? 0.20 : 0.01; + if( mgr->hasValue( "ScalarBarXPosition", "SMESH" ) ) + aXVal = mgr->doubleValue( "ScalarBarXPosition", "SMESH", aXVal ); + float aYVal = mgr->stringValue( "ScalarBarOrientation", "SMESH" ) == "Horizontal" ? 0.01 : 0.1; + if( mgr->hasValue( "ScalarBarYPosition", "SMESH" ) ) + aYVal = mgr->doubleValue( "ScalarBarYPosition", "SMESH", aYVal ); myScalarBarActor->SetPosition( aXVal, aYVal ); - float aWVal = 0.1; //QAD_CONFIG->getSetting("SMESH:ScalarBarOrientation") == "Horizontal" ? 0.60 : 0.10; - //if ( QAD_CONFIG->hasSetting( "SMESH:ScalarBarWidth" ) ) - // aWVal = QAD_CONFIG->getSetting( "SMESH:ScalarBarWidth" ).toFloat(); + float aWVal = mgr->stringValue( "ScalarBarOrientation", "SMESH" ) == "Horizontal" ? 0.60 : 0.10; + if( mgr->hasValue( "ScalarBarWidth", "SMESH" ) ) + aWVal = mgr->doubleValue( "ScalarBarWidth", "SMESH", aWVal ); myScalarBarActor->SetWidth( aWVal ); - float aHVal = 0.8; //QAD_CONFIG->getSetting("SMESH:ScalarBarOrientation") == "Horizontal" ? 0.12 : 0.80; - //if ( QAD_CONFIG->hasSetting( "SMESH:ScalarBarHeight" ) ) - // aHVal = QAD_CONFIG->getSetting( "SMESH:ScalarBarHeight" ).toFloat(); + float aHVal = mgr->stringValue( "ScalarBarOrientation", "SMESH" ) == "Horizontal" ? 0.12 : 0.80; + if( mgr->hasValue( "ScalarBarHeight", "SMESH" ) ) + aHVal = mgr->doubleValue( "ScalarBarHeight", "SMESH", aHVal ); myScalarBarActor->SetHeight( aHVal ); int anIntVal = 5; - //if ( QAD_CONFIG->hasSetting( "SMESH:ScalarBarNbOfLabels" ) ) - // anIntVal = QAD_CONFIG->getSetting("SMESH:ScalarBarNbOfLabels").toInt(); - myScalarBarActor->SetNumberOfLabels(anIntVal == 0? 5: anIntVal); + if( mgr->hasValue( "ScalarBarNbOfLabels", "SMESH" ) ) + anIntVal = mgr->integerValue( "ScalarBarNbOfLabels", "SMESH", anIntVal ); + myScalarBarActor->SetNumberOfLabels( anIntVal == 0 ? 5: anIntVal ); anIntVal = 64; - //if ( QAD_CONFIG->hasSetting( "SMESH:ScalarBarNbOfColors" ) ) - // anIntVal = QAD_CONFIG->getSetting("SMESH:ScalarBarNbOfColors").toInt(); - myScalarBarActor->SetMaximumNumberOfColors(anIntVal == 0? 64: anIntVal); + if( mgr->hasValue( "ScalarBarNbOfColors", "SMESH" ) ) + anIntVal = mgr->integerValue( "ScalarBarNbOfColors", "SMESH", anIntVal ); + myScalarBarActor->SetMaximumNumberOfColors( anIntVal == 0 ? 64 : anIntVal ); //Definition of points numbering pipeline @@ -622,8 +620,12 @@ SMESH_ActorDef:: SetControlMode(eControl theMode, bool theCheckEntityMode) { + SUIT_ResourceMgr* mgr = SUIT_Session::session()->resourceMgr(); + if( !mgr ) + return; + myControlMode = eNone; - //theCheckEntityMode &= QAD_CONFIG->getSetting("SMESH:DispayEntity") == "true"; + theCheckEntityMode &= mgr->stringValue( "DispayEntity", "SMESH" ) == "true"; my1DActor->GetMapper()->SetScalarVisibility(false); my2DActor->GetMapper()->SetScalarVisibility(false); @@ -850,10 +852,14 @@ bool SMESH_ActorDef::Init(TVisualObjPtr theVisualObj, //SetIsShrunkable(theGrid->GetNumberOfCells() > 10); SetIsShrunkable(true); - - //QString aMode = QAD_CONFIG->getSetting("SMESH:DisplayMode"); + + SUIT_ResourceMgr* mgr = SUIT_Session::session()->resourceMgr(); + if( !mgr ) + return false; + + QString aMode = mgr->stringValue( "DisplayMode", "SMESH" ); SetRepresentation(-1); - /* + if(aMode.compare("Wireframe") == 0){ SetRepresentation(eEdge); }else if(aMode.compare("Shading") == 0){ @@ -861,11 +867,11 @@ bool SMESH_ActorDef::Init(TVisualObjPtr theVisualObj, }else if(aMode.compare("Nodes") == 0){ SetRepresentation(ePoint); } - */ - /*aMode = QAD_CONFIG->getSetting("SMESH:Shrink"); + + aMode = mgr->stringValue( "Shrink", "SMESH" ); if(aMode == "yes"){ SetShrink(); - }*/ + } myTimeStamp->Modified(); Modified(); diff --git a/src/OBJECT/SMESH_ActorUtils.cxx b/src/OBJECT/SMESH_ActorUtils.cxx index 7e71257b2..05aa47c59 100644 --- a/src/OBJECT/SMESH_ActorUtils.cxx +++ b/src/OBJECT/SMESH_ActorUtils.cxx @@ -20,7 +20,9 @@ #include "SMESH_ActorUtils.h" -//#include "QAD_Config.h" +#include "SUIT_ResourceMgr.h" +#include "SUIT_Session.h" + #include "utilities.h" #include @@ -34,12 +36,28 @@ static int MYDEBUG = 0; namespace SMESH{ - float GetFloat(const QString& theValue, float theDefault){ - if(theValue.isEmpty()) return theDefault; - //QString aValue = QAD_CONFIG->getSetting(theValue); - //if(aValue.isEmpty()) - return theDefault; - //return aValue.toFloat(); + float GetFloat( const QString& theValue, float theDefault ) + { + int pos = theValue.find( ":" ); + float val = theDefault; + if( pos>=0 ) + { + QString val = theValue.right( theValue.length()-pos-1 ), + sect = theValue.left( pos ); + if( !val.isEmpty() && !sect.isEmpty() ) + val = GetFloat( val, sect, theDefault ); + } + return val; + } + + float GetFloat( const QString& theValue, const QString& theSection, float theDefault ) + { + float val = theDefault; + SUIT_ResourceMgr* mgr = SUIT_Session::session()->resourceMgr(); + if( mgr ) + val = (float) mgr->doubleValue( theValue, theSection, theDefault ); + + return val; } void WriteUnstructuredGrid(vtkUnstructuredGrid* theGrid, const char* theFileName){ diff --git a/src/OBJECT/SMESH_ActorUtils.h b/src/OBJECT/SMESH_ActorUtils.h index b9a01e003..b4f8194c5 100644 --- a/src/OBJECT/SMESH_ActorUtils.h +++ b/src/OBJECT/SMESH_ActorUtils.h @@ -26,7 +26,8 @@ class vtkUnstructuredGrid; namespace SMESH{ - float GetFloat(const QString& theValue, float theDefault = 0); + float GetFloat( const QString& theValue, float theDefault = 0 ); + float GetFloat( const QString& theName, const QString& theSection, float theDefault = 0 ); void WriteUnstructuredGrid(vtkUnstructuredGrid* theGrid, const char* theFileName); diff --git a/src/SMESHGUI/SMESHGUI.cxx b/src/SMESHGUI/SMESHGUI.cxx index 30064c21b..0788a118f 100644 --- a/src/SMESHGUI/SMESHGUI.cxx +++ b/src/SMESHGUI/SMESHGUI.cxx @@ -395,7 +395,7 @@ namespace{ } case 1133:{ SMESHGUI::GetSMESHGUI()->EmitSignalDeactivateDialog(); - new SMESHGUI_TransparencyDlg( SMESHGUI::desktop(), "", false ); + new SMESHGUI_TransparencyDlg( SMESHGUI::GetSMESHGUI(), "", false ); return; }} SALOME_ListIteratorOfListIO It( selected ); @@ -455,7 +455,7 @@ namespace{ float Shrink = anActor->GetShrinkFactor(); SMESHGUI_Preferences_ColorDlg *aDlg = - new SMESHGUI_Preferences_ColorDlg(SMESHGUI::desktop(),""); + new SMESHGUI_Preferences_ColorDlg( SMESHGUI::GetSMESHGUI(), "" ); aDlg->SetColor(1, c); aDlg->SetColor(2, e); aDlg->SetColor(3, n); @@ -511,7 +511,7 @@ namespace{ SMESHGUI::GetSMESHGUI()->EmitSignalDeactivateDialog(); SMESHGUI_Preferences_ColorDlg *aDlg = - new SMESHGUI_Preferences_ColorDlg(SMESHGUI::desktop(), ""); + new SMESHGUI_Preferences_ColorDlg( SMESHGUI::GetSMESHGUI(), "" ); QColor color = mgr->colorValue( "SMESH", "SettingsFillColor", QColor(0, 170, 255) ); aDlg->SetColor(1, color); @@ -793,8 +793,7 @@ namespace{ aStudyBuilder->CommitCommand(); /* Clear any previous selection */ - SALOME_ListIO selected1; - aSel->setSelectedObjects( selected1 ); + aSel->setSelectedObjects( SALOME_ListIO() ); SMESHGUI::GetSMESHGUI()->updateObjBrowser(); } @@ -1149,12 +1148,7 @@ bool SMESHGUI::OnGUIEvent( int theCommandID ) } case 201: { - SalomeApp_SelectionMgr *aSel = SMESHGUI::selectionMgr(); - SALOME_ListIO selected; - if( aSel ) - aSel->selectedObjects( selected ); - - SMESHGUI_Preferences_ScalarBarDlg::ScalarBarProperties( desktop(), aSel ); + SMESHGUI_Preferences_ScalarBarDlg::ScalarBarProperties( this ); break; } @@ -1210,8 +1204,7 @@ bool SMESHGUI::OnGUIEvent( int theCommandID ) } } } - SALOME_ListIO selected1; - aSel->setSelectedObjects( selected1 ); + aSel->setSelectedObjects( SALOME_ListIO() ); break; } @@ -1674,7 +1667,7 @@ bool SMESHGUI::OnGUIEvent( int theCommandID ) else if ( theCommandID == 811 ) aMode = SMESHGUI_GroupOpDlg::INTERSECT; else aMode = SMESHGUI_GroupOpDlg::CUT; - ( new SMESHGUI_GroupOpDlg( desktop(), SMESHGUI::selectionMgr(), aMode ) )->show(); + ( new SMESHGUI_GroupOpDlg( this, aMode ) )->show(); break; } @@ -1685,7 +1678,7 @@ bool SMESHGUI::OnGUIEvent( int theCommandID ) EmitSignalDeactivateDialog(); - new SMESHGUI_DeleteGroupDlg(this); + new SMESHGUI_DeleteGroupDlg( this ); break; } @@ -1728,13 +1721,13 @@ bool SMESHGUI::OnGUIEvent( int theCommandID ) IOs.Clear(); IOs.Append( It.Value() ); aSel->setSelectedObjects( IOs ); - new SMESHGUI_StandardMeshInfosDlg(desktop(), "", false); + new SMESHGUI_StandardMeshInfosDlg( this, "", false); } // restore selection aSel->setSelectedObjects( selected ); } else - new SMESHGUI_StandardMeshInfosDlg(desktop(), "", false); + new SMESHGUI_StandardMeshInfosDlg( this, "", false); break; } @@ -1759,13 +1752,13 @@ bool SMESHGUI::OnGUIEvent( int theCommandID ) case 1005: { - SMESHGUI_Preferences_ScalarBarDlg::ScalarBarPreferences( desktop() ); + SMESHGUI_Preferences_ScalarBarDlg::ScalarBarPreferences( this ); break; } case 10070: { - ( new SMESHGUI_PrecisionDlg( desktop() ) )->exec(); + ( new SMESHGUI_PrecisionDlg( this ) )->exec(); break; } @@ -1782,7 +1775,7 @@ bool SMESHGUI::OnGUIEvent( int theCommandID ) case 1006: { SMESHGUI_Preferences_SelectionDlg* aDlg = - new SMESHGUI_Preferences_SelectionDlg(desktop()); + new SMESHGUI_Preferences_SelectionDlg( this ); QColor aColor = mgr->colorValue( "SMESH", "SettingsPreSelectColor", Qt::cyan ); aDlg->SetColor(1, aColor); @@ -1944,8 +1937,7 @@ bool SMESHGUI::OnGUIEvent( int theCommandID ) Handle(SALOME_InteractiveObject) IObject = It.Value(); SMESH::RemoveHypothesisOrAlgorithmOnMesh(IObject); } - SALOME_ListIO selected1; - aSel->setSelectedObjects( selected1 ); + aSel->setSelectedObjects( SALOME_ListIO() ); updateObjBrowser(); break; } @@ -2034,7 +2026,7 @@ bool SMESHGUI::OnGUIEvent( int theCommandID ) if(checkLock(aStudy)) break; if( vtkwnd ) { EmitSignalDeactivateDialog(); - new SMESHGUI_RenumberingDlg(desktop(), "", selectionMgr(), 0); + new SMESHGUI_RenumberingDlg( this, "", 0); } else { @@ -2049,7 +2041,7 @@ bool SMESHGUI::OnGUIEvent( int theCommandID ) if(checkLock(aStudy)) break; if ( vtkwnd ) { EmitSignalDeactivateDialog(); - new SMESHGUI_RenumberingDlg(desktop(), "", selectionMgr(), 1); + new SMESHGUI_RenumberingDlg( this, "", 1); } else { diff --git a/src/SMESHGUI/SMESHGUI_AddMeshElementDlg.cxx b/src/SMESHGUI/SMESHGUI_AddMeshElementDlg.cxx index a15542896..8226cdc6a 100644 --- a/src/SMESHGUI/SMESHGUI_AddMeshElementDlg.cxx +++ b/src/SMESHGUI/SMESHGUI_AddMeshElementDlg.cxx @@ -268,8 +268,8 @@ SMESHGUI_AddMeshElementDlg::SMESHGUI_AddMeshElementDlg( SMESHGUI* theModule, QString caption = tr(QString("SMESH_ADD_%1_TITLE").arg(elemName)); QString grBoxTitle = tr(QString("SMESH_ADD_%1").arg(elemName)); - QPixmap image0 (SMESHGUI::resourceMgr()->loadPixmap("SMESH", iconName)); - QPixmap image1 (SMESHGUI::resourceMgr()->loadPixmap("SMESH", tr("ICON_SELECT"))); + QPixmap image0 (SMESH::GetResourceMgr( mySMESHGUI )->loadPixmap("SMESH", iconName)); + QPixmap image1 (SMESH::GetResourceMgr( mySMESHGUI )->loadPixmap("SMESH", tr("ICON_SELECT"))); if (!name) setName("SMESHGUI_AddMeshElementDlg"); diff --git a/src/SMESHGUI/SMESHGUI_AddSubMeshDlg.cxx b/src/SMESHGUI/SMESHGUI_AddSubMeshDlg.cxx index b07345819..79cbb32c0 100644 --- a/src/SMESHGUI/SMESHGUI_AddSubMeshDlg.cxx +++ b/src/SMESHGUI/SMESHGUI_AddSubMeshDlg.cxx @@ -94,7 +94,7 @@ SMESHGUI_AddSubMeshDlg::SMESHGUI_AddSubMeshDlg( SMESHGUI* theModule, const char* mySMESHGUI( theModule ), mySelectionMgr( SMESH::GetSelectionMgr( theModule ) ) { - QPixmap image0 (SMESHGUI::resourceMgr()->loadPixmap("SMESH", tr("ICON_SELECT"))); + QPixmap image0 (SMESH::GetResourceMgr( mySMESHGUI )->loadPixmap("SMESH", tr("ICON_SELECT"))); if (!name) setName("SMESHGUI_AddSubMeshDlg"); setCaption(tr("SMESH_ADD_SUBMESH")); diff --git a/src/SMESHGUI/SMESHGUI_CreateHypothesesDlg.cxx b/src/SMESHGUI/SMESHGUI_CreateHypothesesDlg.cxx index 5e3e4b090..68d2f10c8 100644 --- a/src/SMESHGUI/SMESHGUI_CreateHypothesesDlg.cxx +++ b/src/SMESHGUI/SMESHGUI_CreateHypothesesDlg.cxx @@ -287,7 +287,7 @@ void SMESHGUI_CreateHypothesesDlg::InitAlgoDefinition() parentItem = new QListViewItem(ListAlgoDefinition, aHypData->PluginName); parentItem->setOpen(true); QListViewItem* aItem = new QListViewItem(parentItem, aHypData->Label, HypList[i]); - QPixmap aPixMap (SMESHGUI::resourceMgr()->loadPixmap("SMESH", tr(aHypData->IconId))); + QPixmap aPixMap (SMESH::GetResourceMgr( mySMESHGUI )->loadPixmap("SMESH", tr(aHypData->IconId))); if (!aPixMap.isNull()) aItem->setPixmap(0, aPixMap); } diff --git a/src/SMESHGUI/SMESHGUI_CreatePatternDlg.cxx b/src/SMESHGUI/SMESHGUI_CreatePatternDlg.cxx index a7990a79a..28bb9ad0c 100755 --- a/src/SMESHGUI/SMESHGUI_CreatePatternDlg.cxx +++ b/src/SMESHGUI/SMESHGUI_CreatePatternDlg.cxx @@ -1,715 +1,715 @@ -// SMESH SMESHGUI : GUI for SMESH component -// -// Copyright (C) 2003 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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org -// -// -// -// File : SMESHGUI_CreatePatternDlg.cxx -// Author : Sergey LITONIN -// Module : SMESH - -#include "SMESHGUI_CreatePatternDlg.h" - -#include "SMESHGUI.h" -#include "SMESHGUI_SpinBox.h" -#include "SMESHGUI_PatternWidget.h" -#include "SMESHGUI_Utils.h" -#include "SMESHGUI_VTKUtils.h" -#include "SMESHGUI_PatternUtils.h" -#include "SMESHGUI_GEOMGenUtils.h" - -#include "SMESH_NumberFilter.hxx" - -#include "SUIT_ResourceMgr.h" -#include "SUIT_Desktop.h" -#include "SUIT_FileDlg.h" - -#include "SalomeApp_Study.h" -#include "SalomeApp_DataOwner.h" -#include "SalomeApp_SelectionMgr.h" -#include "SalomeApp_Tools.h" - -#include "SALOMEDS_SObject.hxx" - -#include "SALOME_ListIO.hxx" -#include "SVTK_ViewModel.h" -#include "SVTK_ViewWindow.h" -#include "SVTK_Selector.h" -#include "SVTK_Selection.h" - -// OCCT Includes -#include - -// QT Includes -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#define SPACING 5 -#define MARGIN 10 - -/*! - * Class : SMESHGUI_CreatePatternDlg - * Description : Dialog to specify filters for VTK viewer - */ - -//======================================================================= -// function : SMESHGUI_CreatePatternDlg() -// purpose : Constructor -//======================================================================= -SMESHGUI_CreatePatternDlg::SMESHGUI_CreatePatternDlg( SMESHGUI* theModule, - const int theType, - const char* theName) - : QDialog( SMESH::GetDesktop( theModule ), theName, false, - WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu), - mySMESHGUI( theModule ), - mySelectionMgr( SMESH::GetSelectionMgr( theModule ) ), - myViewWindow( SMESH::GetViewWindow( theModule ) ), - mySelector( myViewWindow->GetSelector() ) -{ - setCaption(tr("CAPTION")); - - QVBoxLayout* aDlgLay = new QVBoxLayout (this, MARGIN, SPACING); - - QFrame* aMainFrame = createMainFrame (this); - QFrame* aBtnFrame = createButtonFrame(this); - - aDlgLay->addWidget(aMainFrame); - aDlgLay->addWidget(aBtnFrame); - - aDlgLay->setStretchFactor(aMainFrame, 1); - - Init(theType); -} - -//======================================================================= -// function : createMainFrame() -// purpose : Create frame containing dialog's input fields -//======================================================================= -QFrame* SMESHGUI_CreatePatternDlg::createMainFrame (QWidget* theParent) -{ - QPixmap iconSlct (SMESHGUI::resourceMgr()->loadPixmap("SMESH", tr("ICON_SELECT"))); - QPixmap icon2d (SMESHGUI::resourceMgr()->loadPixmap("SMESH", tr("ICON_PATTERN_2d"))); - QPixmap icon3d (SMESHGUI::resourceMgr()->loadPixmap("SMESH", tr("ICON_PATTERN_3d"))); - QPixmap iconSample2d (SMESHGUI::resourceMgr()->loadPixmap("SMESH", tr("ICON_PATTERN_SAMPLE_2D"))); - - QGroupBox* aMainGrp = new QGroupBox(1, Qt::Horizontal, theParent); - aMainGrp->setFrameStyle(QFrame::NoFrame); - aMainGrp->setInsideMargin(0); - - // Pattern type group - - myTypeGrp = new QButtonGroup (1, Qt::Vertical, tr("PATTERN_TYPE"), aMainGrp); - mySwitch2d = new QRadioButton (myTypeGrp); - mySwitch3d = new QRadioButton (myTypeGrp); - mySwitch2d->setPixmap(icon2d); - mySwitch3d->setPixmap(icon3d); - myTypeGrp->insert(mySwitch2d, Type_2d); - myTypeGrp->insert(mySwitch3d, Type_3d); - - QGroupBox* aPatternGrp = new QGroupBox(1, Qt::Horizontal, tr("PATTERN"), aMainGrp); - - // Mesh and pattern name group - - QGroupBox* aMeshGrp = new QGroupBox(1, Qt::Vertical, aPatternGrp); - aMeshGrp->setFrameStyle(QFrame::NoFrame); - aMeshGrp->setInsideMargin(0); - - new QLabel(tr("MESH_OR_SUBMESH"), aMeshGrp); - - QPushButton* aSelBtn = new QPushButton(aMeshGrp); - aSelBtn->setPixmap(iconSlct); - myMeshEdit = new QLineEdit(aMeshGrp); - myMeshEdit->setReadOnly(true); - - QGroupBox* aPattGrp = new QGroupBox(1, Qt::Vertical, aPatternGrp); - aPattGrp->setFrameStyle(QFrame::NoFrame); - aPattGrp->setInsideMargin(0); - - new QLabel(tr("PATTERN_NAME"), aPattGrp); - myName = new QLineEdit(aPattGrp); - - // Picture 2d - - myPicture2d = new SMESHGUI_PatternWidget(aPatternGrp), - myPicture2d->setSizePolicy(QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding)); - - // Project check box - - myProjectChk = new QCheckBox(tr("PROJECT"), aPatternGrp); - - // Connect signals and slots - - connect(myTypeGrp, SIGNAL(clicked(int) ), SLOT(onTypeChanged(int))); - connect(myProjectChk, SIGNAL(toggled(bool)), SLOT(onProject(bool) )); - connect(aSelBtn, SIGNAL(clicked() ), SLOT(onSelBtnClicked())); - - return aMainGrp; -} - -//======================================================================= -// function : createButtonFrame() -// purpose : Create frame containing buttons -//======================================================================= -QFrame* SMESHGUI_CreatePatternDlg::createButtonFrame (QWidget* theParent) -{ - QFrame* aFrame = new QFrame(theParent); - aFrame->setFrameStyle(QFrame::Box | QFrame::Sunken); - - myOkBtn = new QPushButton(tr("SMESH_BUT_OK" ), aFrame); - mySaveBtn = new QPushButton(tr("SAVE" ), aFrame); - myCloseBtn = new QPushButton(tr("SMESH_BUT_CANCEL"), aFrame); - - QSpacerItem* aSpacer = new QSpacerItem(0, 0, QSizePolicy::Expanding, QSizePolicy::Minimum); - - QHBoxLayout* aLay = new QHBoxLayout(aFrame, MARGIN, SPACING); - - aLay->addWidget(myOkBtn); - aLay->addWidget(mySaveBtn); - aLay->addItem(aSpacer); - aLay->addWidget(myCloseBtn); - - connect(myOkBtn, SIGNAL(clicked()), SLOT(onOk())); - connect(myCloseBtn, SIGNAL(clicked()), SLOT(onClose())); - connect(mySaveBtn, SIGNAL(clicked()), SLOT(onSave())); - - return aFrame; -} - -//======================================================================= -// function : ~SMESHGUI_CreatePatternDlg() -// purpose : Destructor -//======================================================================= -SMESHGUI_CreatePatternDlg::~SMESHGUI_CreatePatternDlg() -{ - // no need to delete child widgets, Qt does it all for us -} - -//======================================================================= -// function : onProject() -// purpose : SLOT. Called when state of "Project nodes on ther face" -// checkbox is changed -//======================================================================= -void SMESHGUI_CreatePatternDlg::onProject (bool) -{ - loadFromObject(false); - displayPreview(); -} - -//======================================================================= -// function : Init() -// purpose : Init dialog fields, connect signals and slots, show dialog -//======================================================================= -void SMESHGUI_CreatePatternDlg::Init( const int theType ) -{ - myIsLoaded = false; - myType = -1; - myNbPoints = -1; - mySubMesh = SMESH::SMESH_subMesh::_nil(); - myMesh = SMESH::SMESH_Mesh::_nil(); - myGeomObj = GEOM::GEOM_Object::_nil(); - myPattern = SMESH::SMESH_Pattern::_nil(); - - erasePreview(); - - mySMESHGUI->SetActiveDialogBox((QDialog*)this); - - // selection and SMESHGUI - connect(mySelectionMgr, SIGNAL(currentSelectionChanged()), SLOT(onSelectionDone())); - connect(mySMESHGUI, SIGNAL(SignalDeactivateActiveDialog()), SLOT(onDeactivate())); - connect(mySMESHGUI, SIGNAL(SignalCloseAllDialogs()), SLOT(onClose())); - - mySwitch2d->setEnabled(theType == Type_2d); - mySwitch3d->setEnabled(theType == Type_3d); - - if (theType == Type_2d) - myProjectChk->show(); - else - myProjectChk->hide(); - - myTypeGrp->setButton(theType); - onTypeChanged(theType); - - myName->setText(getDefaultName()); - myMeshEdit->setText(""); - - setSizePolicy(QSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding)); - qApp->processEvents(); - updateGeometry(); - myPicture2d->updateGeometry(); - adjustSize(); - resize(minimumSize()); - - activateSelection(); - onSelectionDone(); - - int x, y; - mySMESHGUI->DefineDlgPosition(this, x, y); - this->move(x, y); - this->show(); -} - -//======================================================================= -// function : SetMesh() -// purpose : Set mesh to dialog -//======================================================================= -void SMESHGUI_CreatePatternDlg::SetMesh (SMESH::SMESH_Mesh_ptr thePtr) -{ - myMesh = SMESH::SMESH_Mesh::_duplicate(thePtr); - mySubMesh = SMESH::SMESH_subMesh::_nil(); - - bool isValidMesh = false; - if (!myMesh->_is_nil()) - { - _PTR(SObject) aSobj = SMESH::FindSObject(myMesh.in()); - //Handle(SALOME_InteractiveObject) anIObj = - // new SALOME_InteractiveObject(aSobj->GetID().c_str(), "SMESH"); - SUIT_DataOwnerPtr anIObj (new SalomeApp_DataOwner(aSobj->GetID().c_str())); - - isValidMesh = mySelectionMgr->isOk(anIObj); - } - - if (isValidMesh) { - _PTR(SObject) aSO = SMESH::FindSObject(myMesh.in()); - myMeshEdit->setText(aSO->GetName().c_str()); - myGeomObj = SMESH::GetGeom(aSO); - } else { - myMeshEdit->setText(""); - myGeomObj = GEOM::GEOM_Object::_nil(); - } - - if (myType == Type_2d) { - loadFromObject(false); - displayPreview(); - } -} - -//======================================================================= -// function : isValid() -// purpose : Verify validity of entry data -//======================================================================= -bool SMESHGUI_CreatePatternDlg::isValid() -{ - if (myGeomObj->_is_nil()) { - QMessageBox::information(SMESH::GetDesktop( mySMESHGUI ), - tr("SMESH_INSUFFICIENT_DATA"), - tr("SMESHGUI_INVALID_PARAMETERS"), - QMessageBox::Ok); - return false; - } - else - return true; -} - -//======================================================================= -// function : getDefaultName() -// purpose : Get default pattern name -//======================================================================= -QString SMESHGUI_CreatePatternDlg::getDefaultName() const -{ - return myType == Type_2d ? tr("DEFAULT_2D") : tr("DEFAULT_3D"); -} - -//======================================================================= -// function : onSave() -// purpose : SLOT called when "Save" button pressed. Build pattern and -// save it to disk -//======================================================================= -void SMESHGUI_CreatePatternDlg::onSave() -{ - try { - if (!isValid()) - return; - - if (!myIsLoaded) - loadFromObject(true); - - // Load pattern from object - if (!myIsLoaded) - return; - - /////////////////////////////////////////////////////// - SUIT_FileDlg* aDlg = new SUIT_FileDlg (this, false); - aDlg->setCaption(tr("SAVE_PATTERN")); - aDlg->setMode(QFileDialog::AnyFile); - aDlg->setFilters(tr("PATTERN_FILT")); - if (myName->text() != "") - aDlg->setSelection(myName->text()); - - if (aDlg->exec() != Accepted) - return; - - QString fName = aDlg->selectedFile(); - if (fName.isEmpty()) - return; - - if (QFileInfo(fName).extension().isEmpty()) - fName = autoExtension(fName); - - fName = QDir::convertSeparators(fName); - - QString aData (myPattern->GetString()); - long aLen = aData.length(); - - QFile aFile (fName); - aFile.open(IO_WriteOnly); - long aWritten = aFile.writeBlock(aData, aLen); - aFile.close(); - - if (aWritten != aLen) { - QMessageBox::information(SMESH::GetDesktop( mySMESHGUI ), tr("SMESH_ERROR"), - tr("ERROR_OF_SAVING"), QMessageBox::Ok); - } else { - //SUIT_Application::getDesktop()->setSelectionModes(ActorSelection); - myViewWindow->SetSelectionMode(ActorSelection); - disconnect(mySelectionMgr, 0, this, 0); - disconnect(mySMESHGUI, 0, this, 0); - mySMESHGUI->ResetState(); - accept(); - emit NewPattern(); - } - } catch (const SALOME::SALOME_Exception& S_ex) { - SalomeApp_Tools::QtCatchCorbaException(S_ex); - } catch (...) { - } -} - -//======================================================================= -// function : GetPatternName() -// purpose : Get name of pattern -//======================================================================= -QString SMESHGUI_CreatePatternDlg::GetPatternName() const -{ - return myName->text(); -} - -//======================================================================= -// function : GetPattern() -// purpose : Get result pattern -//======================================================================= -SMESH::SMESH_Pattern_ptr SMESHGUI_CreatePatternDlg::GetPattern() -{ - return myPattern.in(); -} - -//======================================================================= -// function : onOk() -// purpose : SLOT called when "Ok" button pressed. -//======================================================================= -void SMESHGUI_CreatePatternDlg::onOk() -{ - try { - if (!isValid()) - return; - - if (!myIsLoaded) - loadFromObject(true); - - // Load pattern from object - if (!myIsLoaded) { - return; - } else { - //SUIT_Application::getDesktop()->setSelectionModes(ActorSelection); - myViewWindow->SetSelectionMode(ActorSelection); - disconnect(mySelectionMgr, 0, this, 0); - disconnect(mySMESHGUI, 0, this, 0); - mySMESHGUI->ResetState(); - accept(); - emit NewPattern(); - } - } catch (const SALOME::SALOME_Exception& S_ex) { - SalomeApp_Tools::QtCatchCorbaException(S_ex); - } catch (...) { - } -} - -//======================================================================= -// function : onClose() -// purpose : SLOT called when "Close" button pressed. Close dialog -//======================================================================= -void SMESHGUI_CreatePatternDlg::onClose() -{ - myViewWindow->SetSelectionMode(ActorSelection); - disconnect(mySelectionMgr, 0, this, 0); - disconnect(mySMESHGUI, 0, this, 0); - mySMESHGUI->ResetState(); - reject(); - emit Close(); -} - -//======================================================================= -// function : loadFromObject() -// purpose : Load pattern from geom object corresponding to the mesh/submesh -//======================================================================= -bool SMESHGUI_CreatePatternDlg::loadFromObject (const bool theMess) -{ - try { - myIsLoaded = false; - - if (myPattern->_is_nil()) - myPattern = SMESH::GetPattern(); - - if (myMesh->_is_nil() && mySubMesh->_is_nil() || myGeomObj->_is_nil()) - return false; - - SMESH::SMESH_Mesh_ptr aMesh = mySubMesh->_is_nil() ? myMesh.in() : mySubMesh->GetFather(); - - myIsLoaded = myType == Type_2d - ? myPattern->LoadFromFace(aMesh, myGeomObj, myProjectChk->isChecked()) - : myPattern->LoadFrom3DBlock(aMesh, myGeomObj); - - if (!myIsLoaded && theMess) { - QString aMess; - SMESH::SMESH_Pattern::ErrorCode aCode = myPattern->GetErrorCode(); - - if (aCode == SMESH::SMESH_Pattern::ERR_LOAD_EMPTY_SUBMESH ) aMess = tr("ERR_LOAD_EMPTY_SUBMESH"); - else if (aCode == SMESH::SMESH_Pattern::ERR_LOADF_NARROW_FACE ) aMess = tr("ERR_LOADF_NARROW_FACE"); - else if (aCode == SMESH::SMESH_Pattern::ERR_LOADF_CLOSED_FACE ) aMess = tr("ERR_LOADF_CLOSED_FACE"); - else if (aCode == SMESH::SMESH_Pattern::ERR_LOADV_BAD_SHAPE ) aMess = tr("ERR_LOADV_BAD_SHAPE"); - else if (aCode == SMESH::SMESH_Pattern::ERR_LOADV_COMPUTE_PARAMS) aMess = tr("ERR_LOADV_COMPUTE_PARAMS"); - else aMess = tr("ERROR_OF_CREATION"); - - QMessageBox::information(SMESH::GetDesktop( mySMESHGUI ), - tr("SMESH_ERROR"), aMess, QMessageBox::Ok); - } - } catch (const SALOME::SALOME_Exception& S_ex) { - SalomeApp_Tools::QtCatchCorbaException(S_ex); - } - - return myIsLoaded; -} - -//======================================================================= -// function : onSelectionDone() -// purpose : SLOT called when selection changed -//======================================================================= -void SMESHGUI_CreatePatternDlg::onSelectionDone() -{ - try { - SALOME_ListIO aList; - mySelectionMgr->selectedObjects(aList, SVTK_Viewer::Type()); - if (aList.Extent() != 1) - return; - - // Get mesh or sub-mesh from selection - Handle(SALOME_InteractiveObject) anIO = aList.First(); - SMESH::SMESH_Mesh_var aMesh = SMESH::IObjectToInterface(anIO); - SMESH::SMESH_subMesh_var aSubMesh = SMESH::IObjectToInterface(anIO); - if (aMesh->_is_nil() && aSubMesh->_is_nil()) - return; - - // Get geom object corresponding to the mesh - _PTR(SObject) aSO; - if (!aMesh->_is_nil()) - aSO = SMESH::FindSObject(aMesh.in()); - else - aSO = SMESH::FindSObject(aSubMesh.in()); - - GEOM::GEOM_Object_var aGeomObj = SMESH::GetGeom(aSO); - if (aGeomObj->_is_nil()) - return; - - myGeomObj = aGeomObj; - - // init class fields - if (!aMesh->_is_nil()) { - myMesh = aMesh; - mySubMesh = SMESH::SMESH_subMesh::_nil(); - } else { - mySubMesh = aSubMesh; - myMesh = SMESH::SMESH_Mesh::_nil(); - } - - QString aName; - SMESH::GetNameOfSelectedIObjects(mySelectionMgr, aName); - myMeshEdit->setText(aName); - - if (myType == Type_2d) { - loadFromObject(true); - displayPreview(); - } - } catch (...) { - myMesh = SMESH::SMESH_Mesh::_nil(); - mySubMesh = SMESH::SMESH_subMesh::_nil(); - myGeomObj = GEOM::GEOM_Object::_nil(); - erasePreview(); - } -} - -//======================================================================= -// function : onDeactivate() -// purpose : SLOT called when dialog must be deativated -//======================================================================= -void SMESHGUI_CreatePatternDlg::onDeactivate() -{ - disconnect(mySelectionMgr, 0, this, 0); - setEnabled(false); -} - -//======================================================================= -// function : enterEvent() -// purpose : Event filter -//======================================================================= -void SMESHGUI_CreatePatternDlg::enterEvent (QEvent*) -{ - mySMESHGUI->EmitSignalDeactivateDialog(); - setEnabled(true); - activateSelection(); - connect(mySelectionMgr, SIGNAL(currentSelectionChanged()), SLOT(onSelectionDone())); -} - -//================================================================================= -// function : closeEvent() -// purpose : Close dialog box -//================================================================================= -void SMESHGUI_CreatePatternDlg::closeEvent (QCloseEvent*) -{ - onClose(); -} - -//======================================================================= -// function : onSelBtnClicked() -// purpose : SLOT. Called when -> button clicked. -//======================================================================= -void SMESHGUI_CreatePatternDlg::onSelBtnClicked() -{ - onSelectionDone(); -} - -//================================================================ -// function : autoExtension() -// purpose : Append extension to the file name -//================================================================ -QString SMESHGUI_CreatePatternDlg::autoExtension (const QString& theFileName) const -{ - QString anExt = theFileName.section('.', -1); - return anExt != "smp" && anExt != "SMP" ? theFileName + ".smp" : theFileName; -} - -//======================================================================= -// function : displayPreview() -// purpose : Display preview -//======================================================================= -void SMESHGUI_CreatePatternDlg::displayPreview() -{ - // Redisplay preview in dialog - try { - if (!myIsLoaded) { - erasePreview(); - } else { - SMESH::point_array_var pnts = myPattern->GetPoints(); - SMESH::long_array_var keyPoints = myPattern->GetKeyPoints(); - SMESH::array_of_long_array_var elemPoints = myPattern->GetElementPoints(false); - - if (pnts->length() == 0 || - keyPoints->length() == 0 || - elemPoints->length() == 0) { - myIsLoaded = false; - erasePreview(); - return; - } - - PointVector aPoints (pnts->length()); - QValueVector aKeyPoints (keyPoints->length()); - ConnectivityVector anElemPoints (elemPoints->length()); - - for (int i = 0, n = pnts->length(); i < n; i++) - aPoints[ i ] = pnts[ i ]; - - for (int i2 = 0, n2 = keyPoints->length(); i2 < n2; i2++) - aKeyPoints[ i2 ] = keyPoints[ i2 ]; - - for (int i3 = 0, n3 = elemPoints->length(); i3 < n3; i3++) { - QValueVector aVec (elemPoints[ i3 ].length()); - for (int i4 = 0, n4 = elemPoints[ i3 ].length(); i4 < n4; i4++) - aVec[ i4 ] = elemPoints[ i3 ][ i4 ]; - - anElemPoints[ i3 ] = aVec; - } - - myPicture2d->SetPoints(aPoints, aKeyPoints, anElemPoints); - } - - return; - - } catch (const SALOME::SALOME_Exception& S_ex) { - SalomeApp_Tools::QtCatchCorbaException(S_ex); - } catch (...) { - } - erasePreview(); -} - -//======================================================================= -// function : erasePreview() -// purpose : Erase preview -//======================================================================= -void SMESHGUI_CreatePatternDlg::erasePreview() -{ - // Erase preview in 2D viewer - myPicture2d->SetPoints(PointVector(), QValueVector(), ConnectivityVector()); -} - -//======================================================================= -// function : activateSelection() -// purpose : Activate selection in accordance with current pattern type -//======================================================================= -void SMESHGUI_CreatePatternDlg::activateSelection() -{ - mySelectionMgr->clearFilters(); - //SUIT_Application::getDesktop()->setSelectionModes(ActorSelection); - myViewWindow->SetSelectionMode(ActorSelection); - - if (myType == Type_2d) { - mySelectionMgr->installFilter(new SMESH_NumberFilter - ("SMESH", TopAbs_SHAPE, -1, TopAbs_FACE)); - } else { - TColStd_MapOfInteger aTypes; - aTypes.Add(TopAbs_SHELL); - aTypes.Add(TopAbs_SOLID); - mySelectionMgr->installFilter(new SMESH_NumberFilter - ("SMESH", TopAbs_FACE, 6, aTypes, GEOM::GEOM_Object::_nil(), true)); - } -} - -//======================================================================= -// function : onTypeChanged() -// purpose : SLOT. Called when pattern type changed. -// Change dialog's look and feel -//======================================================================= -void SMESHGUI_CreatePatternDlg::onTypeChanged (int theType) -{ - if (myType == theType) - return; - - myType = theType; - - if (theType == Type_2d) - myPicture2d->show(); - else - myPicture2d->hide(); -} +// SMESH SMESHGUI : GUI for SMESH component +// +// Copyright (C) 2003 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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org +// +// +// +// File : SMESHGUI_CreatePatternDlg.cxx +// Author : Sergey LITONIN +// Module : SMESH + +#include "SMESHGUI_CreatePatternDlg.h" + +#include "SMESHGUI.h" +#include "SMESHGUI_SpinBox.h" +#include "SMESHGUI_PatternWidget.h" +#include "SMESHGUI_Utils.h" +#include "SMESHGUI_VTKUtils.h" +#include "SMESHGUI_PatternUtils.h" +#include "SMESHGUI_GEOMGenUtils.h" + +#include "SMESH_NumberFilter.hxx" + +#include "SUIT_ResourceMgr.h" +#include "SUIT_Desktop.h" +#include "SUIT_FileDlg.h" + +#include "SalomeApp_Study.h" +#include "SalomeApp_DataOwner.h" +#include "SalomeApp_SelectionMgr.h" +#include "SalomeApp_Tools.h" + +#include "SALOMEDS_SObject.hxx" + +#include "SALOME_ListIO.hxx" +#include "SVTK_ViewModel.h" +#include "SVTK_ViewWindow.h" +#include "SVTK_Selector.h" +#include "SVTK_Selection.h" + +// OCCT Includes +#include + +// QT Includes +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#define SPACING 5 +#define MARGIN 10 + +/*! + * Class : SMESHGUI_CreatePatternDlg + * Description : Dialog to specify filters for VTK viewer + */ + +//======================================================================= +// function : SMESHGUI_CreatePatternDlg() +// purpose : Constructor +//======================================================================= +SMESHGUI_CreatePatternDlg::SMESHGUI_CreatePatternDlg( SMESHGUI* theModule, + const int theType, + const char* theName) + : QDialog( SMESH::GetDesktop( theModule ), theName, false, + WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu), + mySMESHGUI( theModule ), + mySelectionMgr( SMESH::GetSelectionMgr( theModule ) ), + myViewWindow( SMESH::GetViewWindow( theModule ) ), + mySelector( myViewWindow->GetSelector() ) +{ + setCaption(tr("CAPTION")); + + QVBoxLayout* aDlgLay = new QVBoxLayout (this, MARGIN, SPACING); + + QFrame* aMainFrame = createMainFrame (this); + QFrame* aBtnFrame = createButtonFrame(this); + + aDlgLay->addWidget(aMainFrame); + aDlgLay->addWidget(aBtnFrame); + + aDlgLay->setStretchFactor(aMainFrame, 1); + + Init(theType); +} + +//======================================================================= +// function : createMainFrame() +// purpose : Create frame containing dialog's input fields +//======================================================================= +QFrame* SMESHGUI_CreatePatternDlg::createMainFrame (QWidget* theParent) +{ + QPixmap iconSlct (SMESH::GetResourceMgr( mySMESHGUI )->loadPixmap("SMESH", tr("ICON_SELECT"))); + QPixmap icon2d (SMESH::GetResourceMgr( mySMESHGUI )->loadPixmap("SMESH", tr("ICON_PATTERN_2d"))); + QPixmap icon3d (SMESH::GetResourceMgr( mySMESHGUI )->loadPixmap("SMESH", tr("ICON_PATTERN_3d"))); + QPixmap iconSample2d (SMESH::GetResourceMgr( mySMESHGUI )->loadPixmap("SMESH", tr("ICON_PATTERN_SAMPLE_2D"))); + + QGroupBox* aMainGrp = new QGroupBox(1, Qt::Horizontal, theParent); + aMainGrp->setFrameStyle(QFrame::NoFrame); + aMainGrp->setInsideMargin(0); + + // Pattern type group + + myTypeGrp = new QButtonGroup (1, Qt::Vertical, tr("PATTERN_TYPE"), aMainGrp); + mySwitch2d = new QRadioButton (myTypeGrp); + mySwitch3d = new QRadioButton (myTypeGrp); + mySwitch2d->setPixmap(icon2d); + mySwitch3d->setPixmap(icon3d); + myTypeGrp->insert(mySwitch2d, Type_2d); + myTypeGrp->insert(mySwitch3d, Type_3d); + + QGroupBox* aPatternGrp = new QGroupBox(1, Qt::Horizontal, tr("PATTERN"), aMainGrp); + + // Mesh and pattern name group + + QGroupBox* aMeshGrp = new QGroupBox(1, Qt::Vertical, aPatternGrp); + aMeshGrp->setFrameStyle(QFrame::NoFrame); + aMeshGrp->setInsideMargin(0); + + new QLabel(tr("MESH_OR_SUBMESH"), aMeshGrp); + + QPushButton* aSelBtn = new QPushButton(aMeshGrp); + aSelBtn->setPixmap(iconSlct); + myMeshEdit = new QLineEdit(aMeshGrp); + myMeshEdit->setReadOnly(true); + + QGroupBox* aPattGrp = new QGroupBox(1, Qt::Vertical, aPatternGrp); + aPattGrp->setFrameStyle(QFrame::NoFrame); + aPattGrp->setInsideMargin(0); + + new QLabel(tr("PATTERN_NAME"), aPattGrp); + myName = new QLineEdit(aPattGrp); + + // Picture 2d + + myPicture2d = new SMESHGUI_PatternWidget(aPatternGrp), + myPicture2d->setSizePolicy(QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding)); + + // Project check box + + myProjectChk = new QCheckBox(tr("PROJECT"), aPatternGrp); + + // Connect signals and slots + + connect(myTypeGrp, SIGNAL(clicked(int) ), SLOT(onTypeChanged(int))); + connect(myProjectChk, SIGNAL(toggled(bool)), SLOT(onProject(bool) )); + connect(aSelBtn, SIGNAL(clicked() ), SLOT(onSelBtnClicked())); + + return aMainGrp; +} + +//======================================================================= +// function : createButtonFrame() +// purpose : Create frame containing buttons +//======================================================================= +QFrame* SMESHGUI_CreatePatternDlg::createButtonFrame (QWidget* theParent) +{ + QFrame* aFrame = new QFrame(theParent); + aFrame->setFrameStyle(QFrame::Box | QFrame::Sunken); + + myOkBtn = new QPushButton(tr("SMESH_BUT_OK" ), aFrame); + mySaveBtn = new QPushButton(tr("SAVE" ), aFrame); + myCloseBtn = new QPushButton(tr("SMESH_BUT_CANCEL"), aFrame); + + QSpacerItem* aSpacer = new QSpacerItem(0, 0, QSizePolicy::Expanding, QSizePolicy::Minimum); + + QHBoxLayout* aLay = new QHBoxLayout(aFrame, MARGIN, SPACING); + + aLay->addWidget(myOkBtn); + aLay->addWidget(mySaveBtn); + aLay->addItem(aSpacer); + aLay->addWidget(myCloseBtn); + + connect(myOkBtn, SIGNAL(clicked()), SLOT(onOk())); + connect(myCloseBtn, SIGNAL(clicked()), SLOT(onClose())); + connect(mySaveBtn, SIGNAL(clicked()), SLOT(onSave())); + + return aFrame; +} + +//======================================================================= +// function : ~SMESHGUI_CreatePatternDlg() +// purpose : Destructor +//======================================================================= +SMESHGUI_CreatePatternDlg::~SMESHGUI_CreatePatternDlg() +{ + // no need to delete child widgets, Qt does it all for us +} + +//======================================================================= +// function : onProject() +// purpose : SLOT. Called when state of "Project nodes on ther face" +// checkbox is changed +//======================================================================= +void SMESHGUI_CreatePatternDlg::onProject (bool) +{ + loadFromObject(false); + displayPreview(); +} + +//======================================================================= +// function : Init() +// purpose : Init dialog fields, connect signals and slots, show dialog +//======================================================================= +void SMESHGUI_CreatePatternDlg::Init( const int theType ) +{ + myIsLoaded = false; + myType = -1; + myNbPoints = -1; + mySubMesh = SMESH::SMESH_subMesh::_nil(); + myMesh = SMESH::SMESH_Mesh::_nil(); + myGeomObj = GEOM::GEOM_Object::_nil(); + myPattern = SMESH::SMESH_Pattern::_nil(); + + erasePreview(); + + mySMESHGUI->SetActiveDialogBox((QDialog*)this); + + // selection and SMESHGUI + connect(mySelectionMgr, SIGNAL(currentSelectionChanged()), SLOT(onSelectionDone())); + connect(mySMESHGUI, SIGNAL(SignalDeactivateActiveDialog()), SLOT(onDeactivate())); + connect(mySMESHGUI, SIGNAL(SignalCloseAllDialogs()), SLOT(onClose())); + + mySwitch2d->setEnabled(theType == Type_2d); + mySwitch3d->setEnabled(theType == Type_3d); + + if (theType == Type_2d) + myProjectChk->show(); + else + myProjectChk->hide(); + + myTypeGrp->setButton(theType); + onTypeChanged(theType); + + myName->setText(getDefaultName()); + myMeshEdit->setText(""); + + setSizePolicy(QSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding)); + qApp->processEvents(); + updateGeometry(); + myPicture2d->updateGeometry(); + adjustSize(); + resize(minimumSize()); + + activateSelection(); + onSelectionDone(); + + int x, y; + mySMESHGUI->DefineDlgPosition(this, x, y); + this->move(x, y); + this->show(); +} + +//======================================================================= +// function : SetMesh() +// purpose : Set mesh to dialog +//======================================================================= +void SMESHGUI_CreatePatternDlg::SetMesh (SMESH::SMESH_Mesh_ptr thePtr) +{ + myMesh = SMESH::SMESH_Mesh::_duplicate(thePtr); + mySubMesh = SMESH::SMESH_subMesh::_nil(); + + bool isValidMesh = false; + if (!myMesh->_is_nil()) + { + _PTR(SObject) aSobj = SMESH::FindSObject(myMesh.in()); + //Handle(SALOME_InteractiveObject) anIObj = + // new SALOME_InteractiveObject(aSobj->GetID().c_str(), "SMESH"); + SUIT_DataOwnerPtr anIObj (new SalomeApp_DataOwner(aSobj->GetID().c_str())); + + isValidMesh = mySelectionMgr->isOk(anIObj); + } + + if (isValidMesh) { + _PTR(SObject) aSO = SMESH::FindSObject(myMesh.in()); + myMeshEdit->setText(aSO->GetName().c_str()); + myGeomObj = SMESH::GetGeom(aSO); + } else { + myMeshEdit->setText(""); + myGeomObj = GEOM::GEOM_Object::_nil(); + } + + if (myType == Type_2d) { + loadFromObject(false); + displayPreview(); + } +} + +//======================================================================= +// function : isValid() +// purpose : Verify validity of entry data +//======================================================================= +bool SMESHGUI_CreatePatternDlg::isValid() +{ + if (myGeomObj->_is_nil()) { + QMessageBox::information(SMESH::GetDesktop( mySMESHGUI ), + tr("SMESH_INSUFFICIENT_DATA"), + tr("SMESHGUI_INVALID_PARAMETERS"), + QMessageBox::Ok); + return false; + } + else + return true; +} + +//======================================================================= +// function : getDefaultName() +// purpose : Get default pattern name +//======================================================================= +QString SMESHGUI_CreatePatternDlg::getDefaultName() const +{ + return myType == Type_2d ? tr("DEFAULT_2D") : tr("DEFAULT_3D"); +} + +//======================================================================= +// function : onSave() +// purpose : SLOT called when "Save" button pressed. Build pattern and +// save it to disk +//======================================================================= +void SMESHGUI_CreatePatternDlg::onSave() +{ + try { + if (!isValid()) + return; + + if (!myIsLoaded) + loadFromObject(true); + + // Load pattern from object + if (!myIsLoaded) + return; + + /////////////////////////////////////////////////////// + SUIT_FileDlg* aDlg = new SUIT_FileDlg (this, false); + aDlg->setCaption(tr("SAVE_PATTERN")); + aDlg->setMode(QFileDialog::AnyFile); + aDlg->setFilters(tr("PATTERN_FILT")); + if (myName->text() != "") + aDlg->setSelection(myName->text()); + + if (aDlg->exec() != Accepted) + return; + + QString fName = aDlg->selectedFile(); + if (fName.isEmpty()) + return; + + if (QFileInfo(fName).extension().isEmpty()) + fName = autoExtension(fName); + + fName = QDir::convertSeparators(fName); + + QString aData (myPattern->GetString()); + long aLen = aData.length(); + + QFile aFile (fName); + aFile.open(IO_WriteOnly); + long aWritten = aFile.writeBlock(aData, aLen); + aFile.close(); + + if (aWritten != aLen) { + QMessageBox::information(SMESH::GetDesktop( mySMESHGUI ), tr("SMESH_ERROR"), + tr("ERROR_OF_SAVING"), QMessageBox::Ok); + } else { + //SUIT_Application::getDesktop()->setSelectionModes(ActorSelection); + myViewWindow->SetSelectionMode(ActorSelection); + disconnect(mySelectionMgr, 0, this, 0); + disconnect(mySMESHGUI, 0, this, 0); + mySMESHGUI->ResetState(); + accept(); + emit NewPattern(); + } + } catch (const SALOME::SALOME_Exception& S_ex) { + SalomeApp_Tools::QtCatchCorbaException(S_ex); + } catch (...) { + } +} + +//======================================================================= +// function : GetPatternName() +// purpose : Get name of pattern +//======================================================================= +QString SMESHGUI_CreatePatternDlg::GetPatternName() const +{ + return myName->text(); +} + +//======================================================================= +// function : GetPattern() +// purpose : Get result pattern +//======================================================================= +SMESH::SMESH_Pattern_ptr SMESHGUI_CreatePatternDlg::GetPattern() +{ + return myPattern.in(); +} + +//======================================================================= +// function : onOk() +// purpose : SLOT called when "Ok" button pressed. +//======================================================================= +void SMESHGUI_CreatePatternDlg::onOk() +{ + try { + if (!isValid()) + return; + + if (!myIsLoaded) + loadFromObject(true); + + // Load pattern from object + if (!myIsLoaded) { + return; + } else { + //SUIT_Application::getDesktop()->setSelectionModes(ActorSelection); + myViewWindow->SetSelectionMode(ActorSelection); + disconnect(mySelectionMgr, 0, this, 0); + disconnect(mySMESHGUI, 0, this, 0); + mySMESHGUI->ResetState(); + accept(); + emit NewPattern(); + } + } catch (const SALOME::SALOME_Exception& S_ex) { + SalomeApp_Tools::QtCatchCorbaException(S_ex); + } catch (...) { + } +} + +//======================================================================= +// function : onClose() +// purpose : SLOT called when "Close" button pressed. Close dialog +//======================================================================= +void SMESHGUI_CreatePatternDlg::onClose() +{ + myViewWindow->SetSelectionMode(ActorSelection); + disconnect(mySelectionMgr, 0, this, 0); + disconnect(mySMESHGUI, 0, this, 0); + mySMESHGUI->ResetState(); + reject(); + emit Close(); +} + +//======================================================================= +// function : loadFromObject() +// purpose : Load pattern from geom object corresponding to the mesh/submesh +//======================================================================= +bool SMESHGUI_CreatePatternDlg::loadFromObject (const bool theMess) +{ + try { + myIsLoaded = false; + + if (myPattern->_is_nil()) + myPattern = SMESH::GetPattern(); + + if (myMesh->_is_nil() && mySubMesh->_is_nil() || myGeomObj->_is_nil()) + return false; + + SMESH::SMESH_Mesh_ptr aMesh = mySubMesh->_is_nil() ? myMesh.in() : mySubMesh->GetFather(); + + myIsLoaded = myType == Type_2d + ? myPattern->LoadFromFace(aMesh, myGeomObj, myProjectChk->isChecked()) + : myPattern->LoadFrom3DBlock(aMesh, myGeomObj); + + if (!myIsLoaded && theMess) { + QString aMess; + SMESH::SMESH_Pattern::ErrorCode aCode = myPattern->GetErrorCode(); + + if (aCode == SMESH::SMESH_Pattern::ERR_LOAD_EMPTY_SUBMESH ) aMess = tr("ERR_LOAD_EMPTY_SUBMESH"); + else if (aCode == SMESH::SMESH_Pattern::ERR_LOADF_NARROW_FACE ) aMess = tr("ERR_LOADF_NARROW_FACE"); + else if (aCode == SMESH::SMESH_Pattern::ERR_LOADF_CLOSED_FACE ) aMess = tr("ERR_LOADF_CLOSED_FACE"); + else if (aCode == SMESH::SMESH_Pattern::ERR_LOADV_BAD_SHAPE ) aMess = tr("ERR_LOADV_BAD_SHAPE"); + else if (aCode == SMESH::SMESH_Pattern::ERR_LOADV_COMPUTE_PARAMS) aMess = tr("ERR_LOADV_COMPUTE_PARAMS"); + else aMess = tr("ERROR_OF_CREATION"); + + QMessageBox::information(SMESH::GetDesktop( mySMESHGUI ), + tr("SMESH_ERROR"), aMess, QMessageBox::Ok); + } + } catch (const SALOME::SALOME_Exception& S_ex) { + SalomeApp_Tools::QtCatchCorbaException(S_ex); + } + + return myIsLoaded; +} + +//======================================================================= +// function : onSelectionDone() +// purpose : SLOT called when selection changed +//======================================================================= +void SMESHGUI_CreatePatternDlg::onSelectionDone() +{ + try { + SALOME_ListIO aList; + mySelectionMgr->selectedObjects(aList, SVTK_Viewer::Type()); + if (aList.Extent() != 1) + return; + + // Get mesh or sub-mesh from selection + Handle(SALOME_InteractiveObject) anIO = aList.First(); + SMESH::SMESH_Mesh_var aMesh = SMESH::IObjectToInterface(anIO); + SMESH::SMESH_subMesh_var aSubMesh = SMESH::IObjectToInterface(anIO); + if (aMesh->_is_nil() && aSubMesh->_is_nil()) + return; + + // Get geom object corresponding to the mesh + _PTR(SObject) aSO; + if (!aMesh->_is_nil()) + aSO = SMESH::FindSObject(aMesh.in()); + else + aSO = SMESH::FindSObject(aSubMesh.in()); + + GEOM::GEOM_Object_var aGeomObj = SMESH::GetGeom(aSO); + if (aGeomObj->_is_nil()) + return; + + myGeomObj = aGeomObj; + + // init class fields + if (!aMesh->_is_nil()) { + myMesh = aMesh; + mySubMesh = SMESH::SMESH_subMesh::_nil(); + } else { + mySubMesh = aSubMesh; + myMesh = SMESH::SMESH_Mesh::_nil(); + } + + QString aName; + SMESH::GetNameOfSelectedIObjects(mySelectionMgr, aName); + myMeshEdit->setText(aName); + + if (myType == Type_2d) { + loadFromObject(true); + displayPreview(); + } + } catch (...) { + myMesh = SMESH::SMESH_Mesh::_nil(); + mySubMesh = SMESH::SMESH_subMesh::_nil(); + myGeomObj = GEOM::GEOM_Object::_nil(); + erasePreview(); + } +} + +//======================================================================= +// function : onDeactivate() +// purpose : SLOT called when dialog must be deativated +//======================================================================= +void SMESHGUI_CreatePatternDlg::onDeactivate() +{ + disconnect(mySelectionMgr, 0, this, 0); + setEnabled(false); +} + +//======================================================================= +// function : enterEvent() +// purpose : Event filter +//======================================================================= +void SMESHGUI_CreatePatternDlg::enterEvent (QEvent*) +{ + mySMESHGUI->EmitSignalDeactivateDialog(); + setEnabled(true); + activateSelection(); + connect(mySelectionMgr, SIGNAL(currentSelectionChanged()), SLOT(onSelectionDone())); +} + +//================================================================================= +// function : closeEvent() +// purpose : Close dialog box +//================================================================================= +void SMESHGUI_CreatePatternDlg::closeEvent (QCloseEvent*) +{ + onClose(); +} + +//======================================================================= +// function : onSelBtnClicked() +// purpose : SLOT. Called when -> button clicked. +//======================================================================= +void SMESHGUI_CreatePatternDlg::onSelBtnClicked() +{ + onSelectionDone(); +} + +//================================================================ +// function : autoExtension() +// purpose : Append extension to the file name +//================================================================ +QString SMESHGUI_CreatePatternDlg::autoExtension (const QString& theFileName) const +{ + QString anExt = theFileName.section('.', -1); + return anExt != "smp" && anExt != "SMP" ? theFileName + ".smp" : theFileName; +} + +//======================================================================= +// function : displayPreview() +// purpose : Display preview +//======================================================================= +void SMESHGUI_CreatePatternDlg::displayPreview() +{ + // Redisplay preview in dialog + try { + if (!myIsLoaded) { + erasePreview(); + } else { + SMESH::point_array_var pnts = myPattern->GetPoints(); + SMESH::long_array_var keyPoints = myPattern->GetKeyPoints(); + SMESH::array_of_long_array_var elemPoints = myPattern->GetElementPoints(false); + + if (pnts->length() == 0 || + keyPoints->length() == 0 || + elemPoints->length() == 0) { + myIsLoaded = false; + erasePreview(); + return; + } + + PointVector aPoints (pnts->length()); + QValueVector aKeyPoints (keyPoints->length()); + ConnectivityVector anElemPoints (elemPoints->length()); + + for (int i = 0, n = pnts->length(); i < n; i++) + aPoints[ i ] = pnts[ i ]; + + for (int i2 = 0, n2 = keyPoints->length(); i2 < n2; i2++) + aKeyPoints[ i2 ] = keyPoints[ i2 ]; + + for (int i3 = 0, n3 = elemPoints->length(); i3 < n3; i3++) { + QValueVector aVec (elemPoints[ i3 ].length()); + for (int i4 = 0, n4 = elemPoints[ i3 ].length(); i4 < n4; i4++) + aVec[ i4 ] = elemPoints[ i3 ][ i4 ]; + + anElemPoints[ i3 ] = aVec; + } + + myPicture2d->SetPoints(aPoints, aKeyPoints, anElemPoints); + } + + return; + + } catch (const SALOME::SALOME_Exception& S_ex) { + SalomeApp_Tools::QtCatchCorbaException(S_ex); + } catch (...) { + } + erasePreview(); +} + +//======================================================================= +// function : erasePreview() +// purpose : Erase preview +//======================================================================= +void SMESHGUI_CreatePatternDlg::erasePreview() +{ + // Erase preview in 2D viewer + myPicture2d->SetPoints(PointVector(), QValueVector(), ConnectivityVector()); +} + +//======================================================================= +// function : activateSelection() +// purpose : Activate selection in accordance with current pattern type +//======================================================================= +void SMESHGUI_CreatePatternDlg::activateSelection() +{ + mySelectionMgr->clearFilters(); + //SUIT_Application::getDesktop()->setSelectionModes(ActorSelection); + myViewWindow->SetSelectionMode(ActorSelection); + + if (myType == Type_2d) { + mySelectionMgr->installFilter(new SMESH_NumberFilter + ("SMESH", TopAbs_SHAPE, -1, TopAbs_FACE)); + } else { + TColStd_MapOfInteger aTypes; + aTypes.Add(TopAbs_SHELL); + aTypes.Add(TopAbs_SOLID); + mySelectionMgr->installFilter(new SMESH_NumberFilter + ("SMESH", TopAbs_FACE, 6, aTypes, GEOM::GEOM_Object::_nil(), true)); + } +} + +//======================================================================= +// function : onTypeChanged() +// purpose : SLOT. Called when pattern type changed. +// Change dialog's look and feel +//======================================================================= +void SMESHGUI_CreatePatternDlg::onTypeChanged (int theType) +{ + if (myType == theType) + return; + + myType = theType; + + if (theType == Type_2d) + myPicture2d->show(); + else + myPicture2d->hide(); +} diff --git a/src/SMESHGUI/SMESHGUI_DeleteGroupDlg.h b/src/SMESHGUI/SMESHGUI_DeleteGroupDlg.h index 01abc7e4a..b6305bd93 100644 --- a/src/SMESHGUI/SMESHGUI_DeleteGroupDlg.h +++ b/src/SMESHGUI/SMESHGUI_DeleteGroupDlg.h @@ -52,7 +52,7 @@ class SMESHGUI_DeleteGroupDlg : public QDialog Q_OBJECT public: - SMESHGUI_DeleteGroupDlg (SMESHGUI* theModule); + SMESHGUI_DeleteGroupDlg( SMESHGUI* ); virtual ~SMESHGUI_DeleteGroupDlg(); void Init (); diff --git a/src/SMESHGUI/SMESHGUI_EditHypothesesDlg.cxx b/src/SMESHGUI/SMESHGUI_EditHypothesesDlg.cxx index 16feafbc5..3e5f9242a 100644 --- a/src/SMESHGUI/SMESHGUI_EditHypothesesDlg.cxx +++ b/src/SMESHGUI/SMESHGUI_EditHypothesesDlg.cxx @@ -115,7 +115,7 @@ SMESHGUI_EditHypothesesDlg::SMESHGUI_EditHypothesesDlg (SMESHGUI* theModule, con mySMESHGUI( theModule ), mySelectionMgr( SMESH::GetSelectionMgr( theModule ) ) { - QPixmap image0 (SMESHGUI::resourceMgr()->loadPixmap("SMESH", tr("ICON_SELECT"))); + QPixmap image0 (SMESH::GetResourceMgr( mySMESHGUI )->loadPixmap("SMESH", tr("ICON_SELECT"))); if (!name) setName("SMESHGUI_EditHypothesesDlg"); setCaption(tr("SMESH_EDIT_HYPOTHESES")); diff --git a/src/SMESHGUI/SMESHGUI_ExtrusionAlongPathDlg.cxx b/src/SMESHGUI/SMESHGUI_ExtrusionAlongPathDlg.cxx index 46222594e..b4d4a70c7 100644 --- a/src/SMESHGUI/SMESHGUI_ExtrusionAlongPathDlg.cxx +++ b/src/SMESHGUI/SMESHGUI_ExtrusionAlongPathDlg.cxx @@ -101,11 +101,12 @@ SMESHGUI_ExtrusionAlongPathDlg::SMESHGUI_ExtrusionAlongPathDlg( SMESHGUI* theMod myViewWindow( SMESH::GetViewWindow( theModule ) ), mySelector( myViewWindow->GetSelector() ) { - QPixmap edgeImage (SMESHGUI::resourceMgr()->loadPixmap("SMESH", tr("ICON_DLG_EDGE"))); - QPixmap faceImage (SMESHGUI::resourceMgr()->loadPixmap("SMESH", tr("ICON_DLG_TRIANGLE"))); - QPixmap selectImage (SMESHGUI::resourceMgr()->loadPixmap("SMESH", tr("ICON_SELECT"))); - QPixmap addImage (SMESHGUI::resourceMgr()->loadPixmap("SMESH", tr("ICON_APPEND"))); - QPixmap removeImage (SMESHGUI::resourceMgr()->loadPixmap("SMESH", tr("ICON_REMOVE"))); + SUIT_ResourceMgr* mgr = SMESH::GetResourceMgr( mySMESHGUI ); + QPixmap edgeImage ( mgr->loadPixmap("SMESH", tr("ICON_DLG_EDGE"))); + QPixmap faceImage ( mgr->loadPixmap("SMESH", tr("ICON_DLG_TRIANGLE"))); + QPixmap selectImage ( mgr->loadPixmap("SMESH", tr("ICON_SELECT"))); + QPixmap addImage ( mgr->loadPixmap("SMESH", tr("ICON_APPEND"))); + QPixmap removeImage ( mgr->loadPixmap("SMESH", tr("ICON_REMOVE"))); myType = -1; diff --git a/src/SMESHGUI/SMESHGUI_ExtrusionDlg.cxx b/src/SMESHGUI/SMESHGUI_ExtrusionDlg.cxx index 1a42cceba..4860baeef 100644 --- a/src/SMESHGUI/SMESHGUI_ExtrusionDlg.cxx +++ b/src/SMESHGUI/SMESHGUI_ExtrusionDlg.cxx @@ -92,9 +92,9 @@ SMESHGUI_ExtrusionDlg::SMESHGUI_ExtrusionDlg (SMESHGUI* theModule, myViewWindow( SMESH::GetViewWindow( theModule ) ), mySelector( myViewWindow->GetSelector() ) { - QPixmap image0 (SMESHGUI::resourceMgr()->loadPixmap("SMESH", tr("ICON_DLG_EDGE"))); - QPixmap image1 (SMESHGUI::resourceMgr()->loadPixmap("SMESH", tr("ICON_DLG_TRIANGLE"))); - QPixmap image2 (SMESHGUI::resourceMgr()->loadPixmap("SMESH", tr("ICON_SELECT"))); + QPixmap image0 (SMESH::GetResourceMgr( mySMESHGUI )->loadPixmap("SMESH", tr("ICON_DLG_EDGE"))); + QPixmap image1 (SMESH::GetResourceMgr( mySMESHGUI )->loadPixmap("SMESH", tr("ICON_DLG_TRIANGLE"))); + QPixmap image2 (SMESH::GetResourceMgr( mySMESHGUI )->loadPixmap("SMESH", tr("ICON_SELECT"))); resize(303, 185); setCaption(tr("EXTRUSION_ALONG_LINE")); diff --git a/src/SMESHGUI/SMESHGUI_FilterDlg.cxx b/src/SMESHGUI/SMESHGUI_FilterDlg.cxx index bf2863b20..b2e9627b8 100755 --- a/src/SMESHGUI/SMESHGUI_FilterDlg.cxx +++ b/src/SMESHGUI/SMESHGUI_FilterDlg.cxx @@ -2190,7 +2190,7 @@ bool SMESHGUI_FilterDlg::createFilter (const int theType) aCriteria->length(n); long aPrecision = -1; - SUIT_ResourceMgr* mgr = SMESHGUI::resourceMgr(); + SUIT_ResourceMgr* mgr = SMESH::GetResourceMgr( mySMESHGUI ); if (mgr && mgr->hasValue("SMESH", "ControlsPrecision")) { QString aStr = mgr->stringValue("SMESH", "ControlsPrecision"); diff --git a/src/SMESHGUI/SMESHGUI_GroupDlg.cxx b/src/SMESHGUI/SMESHGUI_GroupDlg.cxx index 5ec1935cd..2a86d8274 100644 --- a/src/SMESHGUI/SMESHGUI_GroupDlg.cxx +++ b/src/SMESHGUI/SMESHGUI_GroupDlg.cxx @@ -149,7 +149,7 @@ void SMESHGUI_GroupDlg::initDialog(bool create) myCreate = create; myCurrentLineEdit = 0; - QPixmap image0 (SMESHGUI::resourceMgr()->loadPixmap("SMESH", tr("ICON_SELECT"))); + QPixmap image0 (SMESH::GetResourceMgr( mySMESHGUI )->loadPixmap("SMESH", tr("ICON_SELECT"))); if (create) setCaption(tr("SMESH_CREATE_GROUP_TITLE")); @@ -744,7 +744,7 @@ void SMESHGUI_GroupDlg::onObjectSelectionChanged() myElements->clear(); - if (aNbSel == 0 ) { + if (aNbSel != 1 ) { myGroup = SMESH::SMESH_Group::_nil(); myMesh = SMESH::SMESH_Mesh::_nil(); myIsBusy = false; @@ -805,7 +805,7 @@ void SMESHGUI_GroupDlg::onObjectSelectionChanged() return; } else if (myCurrentLineEdit == myGeomGroupLine) { - if (aNbSel == 0) { + if (aNbSel != 1) { myGeomGroup = GEOM::GEOM_Object::_nil(); myIsBusy = false; return; diff --git a/src/SMESHGUI/SMESHGUI_GroupOpDlg.cxx b/src/SMESHGUI/SMESHGUI_GroupOpDlg.cxx index 04a03263a..7c15603ed 100644 --- a/src/SMESHGUI/SMESHGUI_GroupOpDlg.cxx +++ b/src/SMESHGUI/SMESHGUI_GroupOpDlg.cxx @@ -29,6 +29,7 @@ #include "SMESHGUI.h" #include "SMESHGUI_Utils.h" +#include "SMESHGUI_VTKUtils.h" #include "SMESH_TypeFilter.hxx" @@ -37,6 +38,8 @@ #include "SalomeApp_SelectionMgr.h" #include "SVTK_Selection.h" +#include "SVTK_ViewWindow.h" +#include "SVTK_Selector.h" #include "SALOME_ListIO.hxx" // QT Includes @@ -61,11 +64,13 @@ // name : SMESHGUI_GroupOpDlg::SMESHGUI_GroupOpDlg // Purpose : Constructor //======================================================================= -SMESHGUI_GroupOpDlg::SMESHGUI_GroupOpDlg (QWidget* theParent, - SalomeApp_SelectionMgr* theSelection, - const int theMode) - : QDialog(theParent, "SMESHGUI_GroupOpDlg", false, - WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu) +SMESHGUI_GroupOpDlg::SMESHGUI_GroupOpDlg( SMESHGUI* theModule, const int theMode ) + : QDialog( SMESH::GetDesktop( theModule ), "SMESHGUI_GroupOpDlg", false, + WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu ), + mySMESHGUI( theModule ), + mySelectionMgr( SMESH::GetSelectionMgr( theModule ) ), + myViewWindow( SMESH::GetViewWindow( theModule ) ), + mySelector( myViewWindow->GetSelector() ) { myMode = theMode; @@ -83,7 +88,7 @@ SMESHGUI_GroupOpDlg::SMESHGUI_GroupOpDlg (QWidget* theParent, aDlgLay->setStretchFactor(aMainFrame, 1); - Init(theSelection); + Init(); } //======================================================================= @@ -115,7 +120,7 @@ QFrame* SMESHGUI_GroupOpDlg::createMainFrame (QWidget* theParent) myEdit1->setReadOnly(true); myEdit2->setReadOnly(true); - QPixmap aPix (SMESHGUI::resourceMgr()->loadPixmap("SMESH", tr("ICON_SELECT"))); + QPixmap aPix (SMESH::GetResourceMgr( mySMESHGUI )->loadPixmap("SMESH", tr("ICON_SELECT"))); myBtn1->setPixmap(aPix); myBtn2->setPixmap(aPix); @@ -164,11 +169,9 @@ SMESHGUI_GroupOpDlg::~SMESHGUI_GroupOpDlg() // name : SMESHGUI_GroupOpDlg::Init // Purpose : Init dialog fields, connect signals and slots, show dialog //======================================================================= -void SMESHGUI_GroupOpDlg::Init (SalomeApp_SelectionMgr* theSelection) +void SMESHGUI_GroupOpDlg::Init() { - mySelectionMgr = theSelection; - SMESHGUI* aSMESHGUI = SMESHGUI::GetSMESHGUI(); - aSMESHGUI->SetActiveDialogBox((QDialog*)this); + mySMESHGUI->SetActiveDialogBox((QDialog*)this); myFocusWg = myEdit1; myGroup1 = SMESH::SMESH_GroupBase::_nil(); @@ -176,23 +179,19 @@ void SMESHGUI_GroupOpDlg::Init (SalomeApp_SelectionMgr* theSelection) // selection and SMESHGUI connect(mySelectionMgr, SIGNAL(currentSelectionChanged()), SLOT(onSelectionDone())); - connect(aSMESHGUI, SIGNAL(SignalDeactivateActiveDialog()), SLOT(onDeactivate())); - connect(aSMESHGUI, SIGNAL(SignalCloseAllDialogs()), SLOT(ClickOnClose())); + connect(mySMESHGUI, SIGNAL(SignalDeactivateActiveDialog()), SLOT(onDeactivate())); + connect(mySMESHGUI, SIGNAL(SignalCloseAllDialogs()), SLOT(ClickOnClose())); connect(myBtn1, SIGNAL(clicked()), this, SLOT(onFocusChanged())); connect(myBtn2, SIGNAL(clicked()), this, SLOT(onFocusChanged())); int x, y; - aSMESHGUI->DefineDlgPosition(this, x, y); + mySMESHGUI->DefineDlgPosition(this, x, y); this->move(x, y); this->show(); // set selection mode -#ifdef NEW_GUI - mySelectionMgr->setSelectionModes(ActorSelection, true); -#else - mySelectionMgr->setSelectionModes(ActorSelection); -#endif + myViewWindow->SetSelectionMode(ActorSelection); mySelectionMgr->installFilter(new SMESH_TypeFilter (GROUP)); return; @@ -247,7 +246,7 @@ bool SMESHGUI_GroupOpDlg::isValid() //======================================================================= bool SMESHGUI_GroupOpDlg::onApply() { - if (!isValid() || SMESHGUI::GetSMESHGUI()->isActiveStudyLocked()) + if (!isValid() || mySMESHGUI->isActiveStudyLocked()) return false; SMESH::SMESH_Mesh_ptr aMesh = myGroup1->GetMesh(); @@ -259,7 +258,7 @@ bool SMESHGUI_GroupOpDlg::onApply() else aNewGrp = aMesh->CutGroups(myGroup1, myGroup2, aName.latin1()); if (!aNewGrp->_is_nil()) { - SMESHGUI::GetSMESHGUI()->updateObjBrowser(true); + mySMESHGUI->updateObjBrowser(true); reset(); return true; } else { @@ -285,10 +284,10 @@ void SMESHGUI_GroupOpDlg::onOk() //======================================================================= void SMESHGUI_GroupOpDlg::onClose() { - mySelectionMgr->setSelectionModes(ActorSelection); + myViewWindow->SetSelectionMode(ActorSelection); disconnect(mySelectionMgr, 0, this, 0); - disconnect(SMESHGUI::GetSMESHGUI(), 0, this, 0); - SMESHGUI::GetSMESHGUI()->ResetState(); + disconnect(mySMESHGUI, 0, this, 0); + mySMESHGUI->ResetState(); mySelectionMgr->clearFilters(); reject(); } @@ -342,13 +341,9 @@ void SMESHGUI_GroupOpDlg::onDeactivate() //======================================================================= void SMESHGUI_GroupOpDlg::enterEvent (QEvent*) { - SMESHGUI::GetSMESHGUI()->EmitSignalDeactivateDialog(); + mySMESHGUI->EmitSignalDeactivateDialog(); setEnabled(true); -#ifdef NEW_GUI - mySelectionMgr->setSelectionModes(ActorSelection, true); -#else - mySelectionMgr->setSelectionModes(ActorSelection); -#endif + myViewWindow->SetSelectionMode(ActorSelection); mySelectionMgr->installFilter(new SMESH_TypeFilter (GROUP)); } diff --git a/src/SMESHGUI/SMESHGUI_GroupOpDlg.h b/src/SMESHGUI/SMESHGUI_GroupOpDlg.h index d05201390..e04b02fde 100644 --- a/src/SMESHGUI/SMESHGUI_GroupOpDlg.h +++ b/src/SMESHGUI/SMESHGUI_GroupOpDlg.h @@ -38,6 +38,9 @@ class QFrame; class QPushButton; class SalomeApp_SelectionMgr; class QLineEdit; +class SMESHGUI; +class SVTK_ViewWindow; +class SVTK_Selector; /* Class : SMESHGUI_GroupOpDlg @@ -52,10 +55,10 @@ public: enum { UNION, INTERSECT, CUT }; public: - SMESHGUI_GroupOpDlg( QWidget*, SalomeApp_SelectionMgr*, const int ); + SMESHGUI_GroupOpDlg( SMESHGUI*, const int ); virtual ~SMESHGUI_GroupOpDlg(); - void Init( SalomeApp_SelectionMgr* ) ; + void Init(); private: @@ -91,8 +94,11 @@ private: QPushButton* myBtn1; QPushButton* myBtn2; + SMESHGUI* mySMESHGUI; SalomeApp_SelectionMgr* mySelectionMgr; int myMode; + SVTK_ViewWindow* myViewWindow; + SVTK_Selector* mySelector; QLineEdit* myFocusWg; diff --git a/src/SMESHGUI/SMESHGUI_InitMeshDlg.cxx b/src/SMESHGUI/SMESHGUI_InitMeshDlg.cxx index ce686c62a..388409a8c 100644 --- a/src/SMESHGUI/SMESHGUI_InitMeshDlg.cxx +++ b/src/SMESHGUI/SMESHGUI_InitMeshDlg.cxx @@ -99,7 +99,7 @@ SMESHGUI_InitMeshDlg::SMESHGUI_InitMeshDlg (SMESHGUI* theModule, const char* nam mySMESHGUI( theModule ), mySelectionMgr( SMESH::GetSelectionMgr( theModule ) ) { - QPixmap image0 (SMESHGUI::resourceMgr()->loadPixmap("SMESH", tr("ICON_SELECT"))); + QPixmap image0 (SMESH::GetResourceMgr( mySMESHGUI )->loadPixmap("SMESH", tr("ICON_SELECT"))); if (!name) setName("SMESHGUI_InitMeshDlg"); diff --git a/src/SMESHGUI/SMESHGUI_MergeNodesDlg.cxx b/src/SMESHGUI/SMESHGUI_MergeNodesDlg.cxx index 2a36a93af..7ad8ccbe4 100644 --- a/src/SMESHGUI/SMESHGUI_MergeNodesDlg.cxx +++ b/src/SMESHGUI/SMESHGUI_MergeNodesDlg.cxx @@ -83,8 +83,8 @@ SMESHGUI_MergeNodesDlg::SMESHGUI_MergeNodesDlg( SMESHGUI* theModule, const char* myViewWindow( SMESH::GetViewWindow( theModule ) ), mySelector( myViewWindow->GetSelector() ) { - QPixmap image0 (SMESHGUI::resourceMgr()->loadPixmap("SMESH", tr("ICON_SMESH_MERGE_NODES"))); - QPixmap image1 (SMESHGUI::resourceMgr()->loadPixmap("SMESH", tr("ICON_SELECT"))); + QPixmap image0 (SMESH::GetResourceMgr( mySMESHGUI )->loadPixmap("SMESH", tr("ICON_SMESH_MERGE_NODES"))); + QPixmap image1 (SMESH::GetResourceMgr( mySMESHGUI )->loadPixmap("SMESH", tr("ICON_SELECT"))); if (!name) setName("SMESHGUI_MergeNodesDlg"); @@ -247,7 +247,6 @@ SMESHGUI_MergeNodesDlg::SMESHGUI_MergeNodesDlg( SMESHGUI* theModule, const char* myActor = 0; - mySMESHGUI = SMESHGUI::GetSMESHGUI(); mySMESHGUI->SetActiveDialogBox((QDialog*)this); myMeshOrSubMeshFilter = new SMESH_TypeFilter (MESHorSUBMESH); diff --git a/src/SMESHGUI/SMESHGUI_MeshInfosDlg.cxx b/src/SMESHGUI/SMESHGUI_MeshInfosDlg.cxx index cd16d80bd..3584bae23 100644 --- a/src/SMESHGUI/SMESHGUI_MeshInfosDlg.cxx +++ b/src/SMESHGUI/SMESHGUI_MeshInfosDlg.cxx @@ -86,7 +86,7 @@ SMESHGUI_MeshInfosDlg::SMESHGUI_MeshInfosDlg (SMESHGUI* theModule, aTopLayout->setSpacing(6); aTopLayout->setMargin(11); // select button & label - QPixmap image0(SMESHGUI::resourceMgr()->loadPixmap("SMESH",tr("ICON_SELECT"))); + QPixmap image0(SMESH::GetResourceMgr( mySMESHGUI )->loadPixmap("SMESH",tr("ICON_SELECT"))); mySelectBtn = new QPushButton(this, "mySelectBtn"); mySelectBtn->setPixmap(image0); mySelectBtn->setSizePolicy(QSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed)); diff --git a/src/SMESHGUI/SMESHGUI_MeshPatternDlg.cxx b/src/SMESHGUI/SMESHGUI_MeshPatternDlg.cxx index 2093f8ae1..238f2277c 100755 --- a/src/SMESHGUI/SMESHGUI_MeshPatternDlg.cxx +++ b/src/SMESHGUI/SMESHGUI_MeshPatternDlg.cxx @@ -136,13 +136,14 @@ SMESHGUI_MeshPatternDlg::SMESHGUI_MeshPatternDlg( SMESHGUI* theModule, //======================================================================= QFrame* SMESHGUI_MeshPatternDlg::createMainFrame (QWidget* theParent) { - QPixmap iconSlct (SMESHGUI::resourceMgr()->loadPixmap("SMESH", tr("ICON_SELECT"))); - QPixmap icon2d (SMESHGUI::resourceMgr()->loadPixmap("SMESH", tr("ICON_PATTERN_2d"))); - QPixmap icon3d (SMESHGUI::resourceMgr()->loadPixmap("SMESH", tr("ICON_PATTERN_3d"))); - QPixmap iconOpen (SMESHGUI::resourceMgr()->loadPixmap("SMESH", tr("ICON_FILE_OPEN"))); + SUIT_ResourceMgr* mgr = SMESH::GetResourceMgr( mySMESHGUI ); + QPixmap iconSlct ( mgr->loadPixmap("SMESH", tr("ICON_SELECT"))); + QPixmap icon2d ( mgr->loadPixmap("SMESH", tr("ICON_PATTERN_2d"))); + QPixmap icon3d ( mgr->loadPixmap("SMESH", tr("ICON_PATTERN_3d"))); + QPixmap iconOpen ( mgr->loadPixmap("SMESH", tr("ICON_FILE_OPEN"))); - QPixmap iconSample2d (SMESHGUI::resourceMgr()->loadPixmap("SMESH", tr("ICON_PATTERN_SAMPLE_2D"))); - QPixmap iconSample3d (SMESHGUI::resourceMgr()->loadPixmap("SMESH", tr("ICON_PATTERN_SAMPLE_3D"))); + QPixmap iconSample2d ( mgr->loadPixmap("SMESH", tr("ICON_PATTERN_SAMPLE_2D"))); + QPixmap iconSample3d ( mgr->loadPixmap("SMESH", tr("ICON_PATTERN_SAMPLE_3D"))); QGroupBox* aMainGrp = new QGroupBox (1, Qt::Horizontal, theParent); aMainGrp->setFrameStyle(QFrame::NoFrame); @@ -413,7 +414,7 @@ bool SMESHGUI_MeshPatternDlg::onApply() bool toCreatePolyedrs = myCreatePolyedrsChk->isChecked(); if ( myPattern->MakeMesh( myMesh, toCreatePolygons, toCreatePolyedrs ) ) { mySelectionMgr->clearSelected(); - SUIT_ResourceMgr* mgr = SMESHGUI::resourceMgr(); + SUIT_ResourceMgr* mgr = SMESH::GetResourceMgr( mySMESHGUI ); bool autoUpdate = false; if (mgr && mgr->stringValue("SMESH", "AutomaticUpdate").compare("true") == 0) autoUpdate = true; diff --git a/src/SMESHGUI/SMESHGUI_MoveNodesDlg.cxx b/src/SMESHGUI/SMESHGUI_MoveNodesDlg.cxx index b719ffeab..12ad1b684 100644 --- a/src/SMESHGUI/SMESHGUI_MoveNodesDlg.cxx +++ b/src/SMESHGUI/SMESHGUI_MoveNodesDlg.cxx @@ -153,8 +153,8 @@ QFrame* SMESHGUI_MoveNodesDlg::createMainFrame (QWidget* theParent) { QFrame* aFrame = new QFrame(theParent); - QPixmap iconMoveNode (SMESHGUI::resourceMgr()->loadPixmap("SMESH", tr("ICON_DLG_MOVE_NODE"))); - QPixmap iconSelect (SMESHGUI::resourceMgr()->loadPixmap("SMESH", tr("ICON_SELECT"))); + QPixmap iconMoveNode (SMESH::GetResourceMgr( mySMESHGUI )->loadPixmap("SMESH", tr("ICON_DLG_MOVE_NODE"))); + QPixmap iconSelect (SMESH::GetResourceMgr( mySMESHGUI )->loadPixmap("SMESH", tr("ICON_SELECT"))); QButtonGroup* aPixGrp = new QButtonGroup(1, Qt::Vertical, tr("MESH_NODE"), aFrame); aPixGrp->setExclusive(TRUE); diff --git a/src/SMESHGUI/SMESHGUI_MultiEditDlg.cxx b/src/SMESHGUI/SMESHGUI_MultiEditDlg.cxx index f1d940061..d2fd9fefb 100755 --- a/src/SMESHGUI/SMESHGUI_MultiEditDlg.cxx +++ b/src/SMESHGUI/SMESHGUI_MultiEditDlg.cxx @@ -141,7 +141,7 @@ QFrame* SMESHGUI_MultiEditDlg::createMainFrame (QWidget* theParent, const bool t aMainGrp->setFrameStyle(QFrame::NoFrame); aMainGrp->setInsideMargin(0); - QPixmap aPix (SMESHGUI::resourceMgr()->loadPixmap("SMESH", tr("ICON_SELECT"))); + QPixmap aPix (SMESH::GetResourceMgr( mySMESHGUI )->loadPixmap("SMESH", tr("ICON_SELECT"))); // "Selected cells" group mySelGrp = new QGroupBox(1, Qt::Horizontal, aMainGrp); diff --git a/src/SMESHGUI/SMESHGUI_NodesDlg.cxx b/src/SMESHGUI/SMESHGUI_NodesDlg.cxx index 69801bb65..3237ae793 100644 --- a/src/SMESHGUI/SMESHGUI_NodesDlg.cxx +++ b/src/SMESHGUI/SMESHGUI_NodesDlg.cxx @@ -237,7 +237,7 @@ SMESHGUI_NodesDlg::SMESHGUI_NodesDlg (SMESHGUI* theModule, { mySimulation = new SMESH::TNodeSimulation(myViewWindow); - QPixmap image0 (SMESHGUI::resourceMgr()->loadPixmap("SMESH", tr("ICON_DLG_NODE"))); + QPixmap image0 (SMESH::GetResourceMgr( mySMESHGUI )->loadPixmap("SMESH", tr("ICON_DLG_NODE"))); if (!name) setName("SMESHGUI_NodesDlg"); resize(303, 185); diff --git a/src/SMESHGUI/SMESHGUI_PrecisionDlg.cxx b/src/SMESHGUI/SMESHGUI_PrecisionDlg.cxx index 5024a235e..62a15b8f4 100755 --- a/src/SMESHGUI/SMESHGUI_PrecisionDlg.cxx +++ b/src/SMESHGUI/SMESHGUI_PrecisionDlg.cxx @@ -29,7 +29,9 @@ #include "SMESHGUI.h" #include "SMESHGUI_VTKUtils.h" +#include "SMESHGUI_Utils.h" +#include "SUIT_Desktop.h" #include "SUIT_ResourceMgr.h" #include @@ -53,9 +55,10 @@ // name : SMESHGUI_PrecisionDlg::SMESHGUI_PrecisionDlg // Purpose : Constructor //======================================================================= -SMESHGUI_PrecisionDlg::SMESHGUI_PrecisionDlg (QWidget* theParent) - : QDialog(theParent, "SMESHGUI_PrecisionDlg", true, - WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu) +SMESHGUI_PrecisionDlg::SMESHGUI_PrecisionDlg ( SMESHGUI* theModule ) + : QDialog( SMESH::GetDesktop( theModule ), "SMESHGUI_PrecisionDlg", true, + WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu ), + mySMESHGUI( theModule ) { setCaption(tr("CAPTION")); @@ -129,7 +132,7 @@ void SMESHGUI_PrecisionDlg::Init() { bool isOk = false; int aVal = DEFAULT_VAL; - SUIT_ResourceMgr* mgr = SMESHGUI::resourceMgr(); + SUIT_ResourceMgr* mgr = SMESH::GetResourceMgr( mySMESHGUI ); if (mgr && mgr->hasValue("SMESH", "ControlsPrecision")) { QString aStr = mgr->stringValue("SMESH", "ControlsPrecision"); aVal = aStr.toInt(&isOk); @@ -140,9 +143,8 @@ void SMESHGUI_PrecisionDlg::Init() onNotUse(); - SMESHGUI* aSMESHGUI = SMESHGUI::GetSMESHGUI(); - aSMESHGUI->SetActiveDialogBox((QDialog*)this); - connect(aSMESHGUI, SIGNAL(SignalCloseAllDialogs()), SLOT(onClose())); + mySMESHGUI->SetActiveDialogBox((QDialog*)this); + connect(mySMESHGUI, SIGNAL(SignalCloseAllDialogs()), SLOT(onClose())); } //======================================================================= @@ -151,7 +153,7 @@ void SMESHGUI_PrecisionDlg::Init() //======================================================================= void SMESHGUI_PrecisionDlg::onOk() { - SUIT_ResourceMgr* mgr = SMESHGUI::resourceMgr(); + SUIT_ResourceMgr* mgr = SMESH::GetResourceMgr( mySMESHGUI ); if (myNotUseChk->isChecked()) { if (mgr) { mgr->remove("SMESH", "ControlsPrecision"); @@ -166,8 +168,8 @@ void SMESHGUI_PrecisionDlg::onOk() SMESH::SetControlsPrecision(aVal); } - disconnect(SMESHGUI::GetSMESHGUI(), 0, this, 0); - SMESHGUI::GetSMESHGUI()->ResetState() ; + disconnect(mySMESHGUI, 0, this, 0); + mySMESHGUI->ResetState() ; accept(); } @@ -177,7 +179,7 @@ void SMESHGUI_PrecisionDlg::onOk() //======================================================================= void SMESHGUI_PrecisionDlg::onClose() { - disconnect(SMESHGUI::GetSMESHGUI(), 0, this, 0); + disconnect( mySMESHGUI, 0, this, 0); reject(); } diff --git a/src/SMESHGUI/SMESHGUI_PrecisionDlg.h b/src/SMESHGUI/SMESHGUI_PrecisionDlg.h index c37809963..976db3091 100755 --- a/src/SMESHGUI/SMESHGUI_PrecisionDlg.h +++ b/src/SMESHGUI/SMESHGUI_PrecisionDlg.h @@ -35,6 +35,7 @@ class QSpinBox; class QPushButton; class QCheckBox; class QFrame; +class SMESHGUI; /* Class : SMESHGUI_PrecisionDlg @@ -46,7 +47,7 @@ class SMESHGUI_PrecisionDlg : public QDialog Q_OBJECT public: - SMESHGUI_PrecisionDlg( QWidget* parent ); + SMESHGUI_PrecisionDlg( SMESHGUI* ); virtual ~SMESHGUI_PrecisionDlg(); @@ -65,7 +66,7 @@ private: void closeEvent( QCloseEvent* ); private: - + SMESHGUI* mySMESHGUI; QSpinBox* mySpinBox; QPushButton* myOKBtn; QPushButton* myCancelBtn; diff --git a/src/SMESHGUI/SMESHGUI_Preferences_ColorDlg.cxx b/src/SMESHGUI/SMESHGUI_Preferences_ColorDlg.cxx index abe998f85..d51137871 100644 --- a/src/SMESHGUI/SMESHGUI_Preferences_ColorDlg.cxx +++ b/src/SMESHGUI/SMESHGUI_Preferences_ColorDlg.cxx @@ -28,6 +28,7 @@ #include "SMESHGUI_Preferences_ColorDlg.h" #include "SMESHGUI.h" +#include "SMESHGUI_Utils.h" #include "utilities.h" @@ -44,6 +45,8 @@ #include #include +#include "SUIT_Desktop.h" + using namespace std; //================================================================================= @@ -53,10 +56,10 @@ using namespace std; // The dialog will by default be modeless, unless you // set'modal' to TRUE to construct a modal dialog. //================================================================================= -SMESHGUI_Preferences_ColorDlg::SMESHGUI_Preferences_ColorDlg (QWidget* parent, - const char* name) - : QDialog(parent, name, true, WStyle_Customize | - WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu) +SMESHGUI_Preferences_ColorDlg::SMESHGUI_Preferences_ColorDlg( SMESHGUI* theModule, const char* name) + : QDialog( SMESH::GetDesktop( theModule ), name, true, WStyle_Customize | + WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu ), + mySMESHGUI( theModule ) { if (!name) setName("SMESHGUI_Preferences_ColorDlg"); @@ -182,7 +185,6 @@ SMESHGUI_Preferences_ColorDlg::~SMESHGUI_Preferences_ColorDlg() //================================================================================= void SMESHGUI_Preferences_ColorDlg::Init() { - mySMESHGUI = SMESHGUI::GetSMESHGUI(); mySMESHGUI->SetActiveDialogBox((QDialog*)this); /* signals and slots connections */ diff --git a/src/SMESHGUI/SMESHGUI_Preferences_ColorDlg.h b/src/SMESHGUI/SMESHGUI_Preferences_ColorDlg.h index 5ad2c5403..43702b2ac 100644 --- a/src/SMESHGUI/SMESHGUI_Preferences_ColorDlg.h +++ b/src/SMESHGUI/SMESHGUI_Preferences_ColorDlg.h @@ -53,7 +53,7 @@ class SMESHGUI_Preferences_ColorDlg : public QDialog Q_OBJECT public: - SMESHGUI_Preferences_ColorDlg( QWidget* parent = 0, const char* name = 0 ); + SMESHGUI_Preferences_ColorDlg( SMESHGUI*, const char* name = 0 ); ~SMESHGUI_Preferences_ColorDlg(); void SetColor(int type, QColor color); diff --git a/src/SMESHGUI/SMESHGUI_Preferences_ScalarBarDlg.cxx b/src/SMESHGUI/SMESHGUI_Preferences_ScalarBarDlg.cxx index 850194b22..2a9ad020b 100644 --- a/src/SMESHGUI/SMESHGUI_Preferences_ScalarBarDlg.cxx +++ b/src/SMESHGUI/SMESHGUI_Preferences_ScalarBarDlg.cxx @@ -30,9 +30,11 @@ #include "SMESHGUI.h" #include "SMESHGUI_VTKUtils.h" +#include "SMESHGUI_Utils.h" #include "SMESH_Actor.h" +#include "SUIT_Desktop.h" #include "SUIT_ResourceMgr.h" #include "SalomeApp_SelectionMgr.h" @@ -83,11 +85,10 @@ SMESHGUI_Preferences_ScalarBarDlg* SMESHGUI_Preferences_ScalarBarDlg::myDlg = 0; * Gets the only instance of "Scalar Bar Properties" dialog box */ //================================================================================================= -void SMESHGUI_Preferences_ScalarBarDlg::ScalarBarProperties (QWidget* parent, - SalomeApp_SelectionMgr* Sel) +void SMESHGUI_Preferences_ScalarBarDlg::ScalarBarProperties( SMESHGUI* theModule ) { if (!myDlg) { - myDlg = new SMESHGUI_Preferences_ScalarBarDlg (parent, Sel, false); + myDlg = new SMESHGUI_Preferences_ScalarBarDlg( theModule, false); myDlg->show(); } else { myDlg->show(); @@ -104,10 +105,10 @@ void SMESHGUI_Preferences_ScalarBarDlg::ScalarBarProperties (QWidget* parent, * Opens "Scalar Bar Preferences" dialog box */ //================================================================================================= -void SMESHGUI_Preferences_ScalarBarDlg::ScalarBarPreferences (QWidget* parent) +void SMESHGUI_Preferences_ScalarBarDlg::ScalarBarPreferences( SMESHGUI* theModule ) { SMESHGUI_Preferences_ScalarBarDlg* aDlg = - new SMESHGUI_Preferences_ScalarBarDlg (parent, 0, true); + new SMESHGUI_Preferences_ScalarBarDlg( theModule, true); aDlg->exec(); } @@ -118,17 +119,16 @@ void SMESHGUI_Preferences_ScalarBarDlg::ScalarBarPreferences (QWidget* parent) * Constructor */ //================================================================================================= -SMESHGUI_Preferences_ScalarBarDlg::SMESHGUI_Preferences_ScalarBarDlg (QWidget* parent, - SalomeApp_SelectionMgr* Sel, - bool modal) - : QDialog(parent, 0, modal, WStyle_Customize | WStyle_NormalBorder | - WStyle_Title | WStyle_SysMenu | WDestructiveClose) +SMESHGUI_Preferences_ScalarBarDlg::SMESHGUI_Preferences_ScalarBarDlg( SMESHGUI* theModule, bool property, bool modal ) + : QDialog( SMESH::GetDesktop( theModule ), 0, modal, WStyle_Customize | WStyle_NormalBorder | + WStyle_Title | WStyle_SysMenu | WDestructiveClose ), + mySMESHGUI( theModule ), + mySelectionMgr( property ? SMESH::GetSelectionMgr( theModule ) : 0 ) { setName("SMESHGUI_Preferences_ScalarBarDlg"); - setCaption(Sel ? tr("SMESH_PROPERTIES_SCALARBAR") : tr("SMESH_PREFERENCES_SCALARBAR")); + setCaption( property ? tr("SMESH_PROPERTIES_SCALARBAR") : tr("SMESH_PREFERENCES_SCALARBAR")); setSizeGripEnabled(TRUE); - mySelectionMgr = Sel; myActor = 0; /******************************************************************************/ @@ -326,7 +326,7 @@ SMESHGUI_Preferences_ScalarBarDlg::SMESHGUI_Preferences_ScalarBarDlg (QWidget* p /***************************************************************/ // Init // --> first init from preferences - SUIT_ResourceMgr* mgr = SMESHGUI::resourceMgr(); + SUIT_ResourceMgr* mgr = SMESH::GetResourceMgr( mySMESHGUI ); QColor titleColor (255, 255, 255); if (mgr && mgr->hasValue("SMESH", "ScalarBarTitleColor")) { @@ -429,7 +429,7 @@ SMESHGUI_Preferences_ScalarBarDlg::SMESHGUI_Preferences_ScalarBarDlg (QWidget* p connect( myApplyBtn, SIGNAL( clicked() ), this, SLOT( onApply() ) ); connect( mySelectionMgr, SIGNAL( currentSelectionChanged() ), this, SLOT( onSelectionChanged() ) ); } - connect( SMESHGUI::GetSMESHGUI(), SIGNAL( SignalCloseAllDialogs() ), this, SLOT( onCancel() ) ) ; + connect( mySMESHGUI, SIGNAL( SignalCloseAllDialogs() ), this, SLOT( onCancel() ) ) ; } //================================================================================================= @@ -517,7 +517,7 @@ bool SMESHGUI_Preferences_ScalarBarDlg::onApply() SMESH::RepaintCurrentView(); } else { // Scalar Bar preferences - SUIT_ResourceMgr* mgr = SMESHGUI::resourceMgr(); + SUIT_ResourceMgr* mgr = SMESH::GetResourceMgr( mySMESHGUI ); if (!mgr) return false; QColor titleColor = myTitleColorBtn->paletteBackgroundColor(); diff --git a/src/SMESHGUI/SMESHGUI_Preferences_ScalarBarDlg.h b/src/SMESHGUI/SMESHGUI_Preferences_ScalarBarDlg.h index f436c649c..75fb1e4e4 100644 --- a/src/SMESHGUI/SMESHGUI_Preferences_ScalarBarDlg.h +++ b/src/SMESHGUI/SMESHGUI_Preferences_ScalarBarDlg.h @@ -41,6 +41,7 @@ class QPushButton; class QToolButton; class QRadioButton; class QSpinBox; +class SMESHGUI; class QtxDblSpinBox; @@ -54,11 +55,11 @@ class SMESHGUI_Preferences_ScalarBarDlg : public QDialog public: ~SMESHGUI_Preferences_ScalarBarDlg(); - static void ScalarBarPreferences( QWidget* parent ); - static void ScalarBarProperties ( QWidget* parent, SalomeApp_SelectionMgr* Sel ); + static void ScalarBarPreferences( SMESHGUI* ); + static void ScalarBarProperties ( SMESHGUI* ); protected: - SMESHGUI_Preferences_ScalarBarDlg( QWidget* parent = 0, SalomeApp_SelectionMgr* Sel = 0, bool modal = FALSE ); + SMESHGUI_Preferences_ScalarBarDlg( SMESHGUI*, bool, bool modal = FALSE ); static SMESHGUI_Preferences_ScalarBarDlg* myDlg; void closeEvent( QCloseEvent* e ); void setOriginAndSize( const double x, const double y, const double w, const double h ); @@ -74,6 +75,7 @@ protected slots: void onOrientationChanged(); private: + SMESHGUI* mySMESHGUI; SalomeApp_SelectionMgr* mySelectionMgr; SMESH_Actor* myActor; double myIniX, myIniY, myIniW, myIniH; diff --git a/src/SMESHGUI/SMESHGUI_Preferences_SelectionDlg.cxx b/src/SMESHGUI/SMESHGUI_Preferences_SelectionDlg.cxx index 087739f47..7606ccf2b 100644 --- a/src/SMESHGUI/SMESHGUI_Preferences_SelectionDlg.cxx +++ b/src/SMESHGUI/SMESHGUI_Preferences_SelectionDlg.cxx @@ -29,6 +29,10 @@ #include "SMESHGUI_Preferences_SelectionDlg.h" #include "SMESHGUI.h" +#include "SMESHGUI_Utils.h" + +#include "SUIT_Desktop.h" + #include #include #include @@ -105,8 +109,9 @@ void SMESHGUI_DoubleValidator::fixup(QString& theText) const // class : SMESHGUI_Preferences_SelectionDlg() // purpose : //================================================================================= -SMESHGUI_Preferences_SelectionDlg::SMESHGUI_Preferences_SelectionDlg( QWidget* parent, const char* name ) - : QDialog( parent, name, true, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu ) +SMESHGUI_Preferences_SelectionDlg::SMESHGUI_Preferences_SelectionDlg( SMESHGUI* theModule, const char* name ) + : QDialog( SMESH::GetDesktop( theModule ), name, true, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu ), + mySMESHGUI( theModule ) { if ( !name ) setName( "SMESHGUI_Preferences_SelectionDlg" ); setCaption( tr( "SMESH_PREF_SELECTION" ) ); @@ -203,7 +208,7 @@ SMESHGUI_Preferences_SelectionDlg::SMESHGUI_Preferences_SelectionDlg( QWidget* p /* Move widget on the botton right corner of main widget */ int x, y ; - SMESHGUI::GetSMESHGUI()->DefineDlgPosition(this, x, y); + mySMESHGUI->DefineDlgPosition(this, x, y); this->move(x, y); } diff --git a/src/SMESHGUI/SMESHGUI_Preferences_SelectionDlg.h b/src/SMESHGUI/SMESHGUI_Preferences_SelectionDlg.h index a4edd3865..07b7a644a 100644 --- a/src/SMESHGUI/SMESHGUI_Preferences_SelectionDlg.h +++ b/src/SMESHGUI/SMESHGUI_Preferences_SelectionDlg.h @@ -38,6 +38,7 @@ class QPushButton; class QSpinBox; class QColor; +class SMESHGUI; class SMESHGUI_LineEdit : public QLineEdit { @@ -72,7 +73,7 @@ class SMESHGUI_Preferences_SelectionDlg : public QDialog Q_OBJECT public: - SMESHGUI_Preferences_SelectionDlg( QWidget* parent = 0, const char* name = 0 ); + SMESHGUI_Preferences_SelectionDlg( SMESHGUI*, const char* name = 0 ); ~SMESHGUI_Preferences_SelectionDlg(); void SetColor(int type, QColor color); @@ -89,6 +90,7 @@ private slots: void onSelectColor(); private: + SMESHGUI* mySMESHGUI; QPushButton* myColor[3]; QSpinBox* myWidth[2]; QLineEdit* myPrecision[2]; diff --git a/src/SMESHGUI/SMESHGUI_RemoveElementsDlg.cxx b/src/SMESHGUI/SMESHGUI_RemoveElementsDlg.cxx index 011402ab7..62ef4d6ad 100644 --- a/src/SMESHGUI/SMESHGUI_RemoveElementsDlg.cxx +++ b/src/SMESHGUI/SMESHGUI_RemoveElementsDlg.cxx @@ -86,8 +86,8 @@ SMESHGUI_RemoveElementsDlg mySMESHGUI(theModule), myBusy(false) { - QPixmap image0 (SMESHGUI::resourceMgr()->loadPixmap("SMESH", tr("ICON_DLG_REM_ELEMENT"))); - QPixmap image1 (SMESHGUI::resourceMgr()->loadPixmap("SMESH", tr("ICON_SELECT"))); + QPixmap image0 (SMESH::GetResourceMgr( mySMESHGUI )->loadPixmap("SMESH", tr("ICON_DLG_REM_ELEMENT"))); + QPixmap image1 (SMESH::GetResourceMgr( mySMESHGUI )->loadPixmap("SMESH", tr("ICON_SELECT"))); if (!name) setName("SMESHGUI_RemoveElementsDlg"); diff --git a/src/SMESHGUI/SMESHGUI_RemoveNodesDlg.cxx b/src/SMESHGUI/SMESHGUI_RemoveNodesDlg.cxx index 9df083576..d07fc087d 100644 --- a/src/SMESHGUI/SMESHGUI_RemoveNodesDlg.cxx +++ b/src/SMESHGUI/SMESHGUI_RemoveNodesDlg.cxx @@ -86,8 +86,8 @@ SMESHGUI_RemoveNodesDlg mySMESHGUI(theModule), myBusy(false) { - QPixmap image0 (SMESHGUI::resourceMgr()->loadPixmap("SMESH", tr("ICON_DLG_REM_NODE"))); - QPixmap image1 (SMESHGUI::resourceMgr()->loadPixmap("SMESH", tr("ICON_SELECT"))); + QPixmap image0 (SMESH::GetResourceMgr( mySMESHGUI )->loadPixmap("SMESH", tr("ICON_DLG_REM_NODE"))); + QPixmap image1 (SMESH::GetResourceMgr( mySMESHGUI )->loadPixmap("SMESH", tr("ICON_SELECT"))); if (!name) setName("SMESHGUI_RemoveNodesDlg"); diff --git a/src/SMESHGUI/SMESHGUI_RenumberingDlg.cxx b/src/SMESHGUI/SMESHGUI_RenumberingDlg.cxx index f886e45d5..be16e7ede 100644 --- a/src/SMESHGUI/SMESHGUI_RenumberingDlg.cxx +++ b/src/SMESHGUI/SMESHGUI_RenumberingDlg.cxx @@ -36,6 +36,7 @@ #include "SMESH_TypeFilter.hxx" #include "SMDS_Mesh.hxx" +#include "SUIT_Desktop.h" #include "SUIT_Session.h" #include "SALOME_ListIO.hxx" @@ -59,11 +60,12 @@ using namespace std; // class : SMESHGUI_RenumberingDlg() // purpose : //================================================================================= -SMESHGUI_RenumberingDlg::SMESHGUI_RenumberingDlg (QWidget* parent, const char* name, - SalomeApp_SelectionMgr* Sel, +SMESHGUI_RenumberingDlg::SMESHGUI_RenumberingDlg( SMESHGUI* theModule, const char* name, const int unit, bool modal, WFlags fl) - : QDialog(parent, name, modal, WStyle_Customize | WStyle_NormalBorder | - WStyle_Title | WStyle_SysMenu | Qt::WDestructiveClose) + : QDialog( SMESH::GetDesktop( theModule ), name, modal, WStyle_Customize | WStyle_NormalBorder | + WStyle_Title | WStyle_SysMenu | Qt::WDestructiveClose), + mySMESHGUI( theModule ), + mySelectionMgr( SMESH::GetSelectionMgr( theModule ) ) { myUnit = unit; @@ -170,7 +172,7 @@ SMESHGUI_RenumberingDlg::SMESHGUI_RenumberingDlg (QWidget* parent, const char* n GroupMeshLayout->addWidget(LineEditMesh, 0, 2); SMESHGUI_RenumberingDlgLayout->addWidget(GroupMesh, 1, 0); - Init(Sel); /* Initialisations */ + Init(); /* Initialisations */ } //================================================================================= @@ -186,13 +188,11 @@ SMESHGUI_RenumberingDlg::~SMESHGUI_RenumberingDlg() // function : Init() // purpose : //================================================================================= -void SMESHGUI_RenumberingDlg::Init (SalomeApp_SelectionMgr* Sel) +void SMESHGUI_RenumberingDlg::Init() { GroupMesh->show(); myConstructorId = 0; Constructor1->setChecked(TRUE); - mySelectionMgr = Sel; - mySMESHGUI = SMESHGUI::GetSMESHGUI(); mySMESHGUI->SetActiveDialogBox((QDialog*)this); myMesh = SMESH::SMESH_Mesh::_nil(); diff --git a/src/SMESHGUI/SMESHGUI_RenumberingDlg.h b/src/SMESHGUI/SMESHGUI_RenumberingDlg.h index 74f89af67..22e5fc617 100644 --- a/src/SMESHGUI/SMESHGUI_RenumberingDlg.h +++ b/src/SMESHGUI/SMESHGUI_RenumberingDlg.h @@ -60,17 +60,15 @@ class SMESHGUI_RenumberingDlg : public QDialog Q_OBJECT public: - SMESHGUI_RenumberingDlg (QWidget* parent = 0, + SMESHGUI_RenumberingDlg( SMESHGUI*, const char* name = 0, - SalomeApp_SelectionMgr* Sel = 0, const int unit = 0, bool modal = FALSE, WFlags fl = 0); ~SMESHGUI_RenumberingDlg(); private: - - void Init( SalomeApp_SelectionMgr* Sel ) ; + void Init(); void closeEvent( QCloseEvent* e ) ; void enterEvent ( QEvent * ) ; /* mouse enter the QWidget */ void hideEvent ( QHideEvent * ); /* ESC key */ diff --git a/src/SMESHGUI/SMESHGUI_RevolutionDlg.cxx b/src/SMESHGUI/SMESHGUI_RevolutionDlg.cxx index 731f9460d..05fd46693 100644 --- a/src/SMESHGUI/SMESHGUI_RevolutionDlg.cxx +++ b/src/SMESHGUI/SMESHGUI_RevolutionDlg.cxx @@ -87,9 +87,10 @@ SMESHGUI_RevolutionDlg::SMESHGUI_RevolutionDlg( SMESHGUI* theModule, const char* myViewWindow( SMESH::GetViewWindow( theModule ) ), mySelector( myViewWindow->GetSelector() ) { - QPixmap image0 (SMESHGUI::resourceMgr()->loadPixmap("SMESH", tr("ICON_DLG_EDGE"))); - QPixmap image1 (SMESHGUI::resourceMgr()->loadPixmap("SMESH", tr("ICON_DLG_TRIANGLE"))); - QPixmap image2 (SMESHGUI::resourceMgr()->loadPixmap("SMESH", tr("ICON_SELECT"))); + SUIT_ResourceMgr* mgr = SMESH::GetResourceMgr( mySMESHGUI ); + QPixmap image0 ( mgr->loadPixmap("SMESH", tr("ICON_DLG_EDGE"))); + QPixmap image1 ( mgr->loadPixmap("SMESH", tr("ICON_DLG_TRIANGLE"))); + QPixmap image2 ( mgr->loadPixmap("SMESH", tr("ICON_SELECT"))); if (!name) setName("SMESHGUI_RevolutionDlg"); diff --git a/src/SMESHGUI/SMESHGUI_RotationDlg.cxx b/src/SMESHGUI/SMESHGUI_RotationDlg.cxx index 6d603a53a..8b9b6b70d 100644 --- a/src/SMESHGUI/SMESHGUI_RotationDlg.cxx +++ b/src/SMESHGUI/SMESHGUI_RotationDlg.cxx @@ -86,8 +86,8 @@ SMESHGUI_RotationDlg::SMESHGUI_RotationDlg( SMESHGUI* theModule, const char* nam myViewWindow( SMESH::GetViewWindow( theModule ) ), mySelector( myViewWindow->GetSelector() ) { - QPixmap image0 (SMESHGUI::resourceMgr()->loadPixmap("SMESH", tr("ICON_DLG_ROTATION"))); - QPixmap image1 (SMESHGUI::resourceMgr()->loadPixmap("SMESH", tr("ICON_SELECT"))); + QPixmap image0 (SMESH::GetResourceMgr( mySMESHGUI )->loadPixmap("SMESH", tr("ICON_DLG_ROTATION"))); + QPixmap image1 (SMESH::GetResourceMgr( mySMESHGUI )->loadPixmap("SMESH", tr("ICON_SELECT"))); if (!name) setName("SMESHGUI_RotationDlg"); diff --git a/src/SMESHGUI/SMESHGUI_SewingDlg.cxx b/src/SMESHGUI/SMESHGUI_SewingDlg.cxx index a84e3834d..dab2df032 100644 --- a/src/SMESHGUI/SMESHGUI_SewingDlg.cxx +++ b/src/SMESHGUI/SMESHGUI_SewingDlg.cxx @@ -79,11 +79,12 @@ SMESHGUI_SewingDlg::SMESHGUI_SewingDlg( SMESHGUI* theModule, const char* name, myViewWindow( SMESH::GetViewWindow( theModule ) ), mySelector( myViewWindow->GetSelector() ) { - QPixmap image0 (SMESHGUI::resourceMgr()->loadPixmap("SMESH", tr("ICON_SMESH_SEWING_FREEBORDERS"))); - QPixmap image1 (SMESHGUI::resourceMgr()->loadPixmap("SMESH", tr("ICON_SMESH_SEWING_CONFORM_FREEBORDERS"))); - QPixmap image2 (SMESHGUI::resourceMgr()->loadPixmap("SMESH", tr("ICON_SMESH_SEWING_BORDERTOSIDE"))); - QPixmap image3 (SMESHGUI::resourceMgr()->loadPixmap("SMESH", tr("ICON_SMESH_SEWING_SIDEELEMENTS"))); - QPixmap image4 (SMESHGUI::resourceMgr()->loadPixmap("SMESH", tr("ICON_SELECT"))); + SUIT_ResourceMgr* mgr = SMESH::GetResourceMgr( mySMESHGUI ); + QPixmap image0 (mgr->loadPixmap("SMESH", tr("ICON_SMESH_SEWING_FREEBORDERS"))); + QPixmap image1 (mgr->loadPixmap("SMESH", tr("ICON_SMESH_SEWING_CONFORM_FREEBORDERS"))); + QPixmap image2 (mgr->loadPixmap("SMESH", tr("ICON_SMESH_SEWING_BORDERTOSIDE"))); + QPixmap image3 (mgr->loadPixmap("SMESH", tr("ICON_SMESH_SEWING_SIDEELEMENTS"))); + QPixmap image4 (mgr->loadPixmap("SMESH", tr("ICON_SELECT"))); if (!name) setName("SMESHGUI_SewingDlg"); diff --git a/src/SMESHGUI/SMESHGUI_SingleEditDlg.cxx b/src/SMESHGUI/SMESHGUI_SingleEditDlg.cxx index cf7750be8..404d6a6d8 100755 --- a/src/SMESHGUI/SMESHGUI_SingleEditDlg.cxx +++ b/src/SMESHGUI/SMESHGUI_SingleEditDlg.cxx @@ -137,7 +137,7 @@ QFrame* SMESHGUI_SingleEditDlg::createMainFrame (QWidget* theParent) { QGroupBox* aMainGrp = new QGroupBox(1, Qt::Vertical, tr("EDGE_BETWEEN"), theParent); - QPixmap aPix (SMESHGUI::resourceMgr()->loadPixmap("SMESH", tr("ICON_SELECT"))); + QPixmap aPix (SMESH::GetResourceMgr( mySMESHGUI )->loadPixmap("SMESH", tr("ICON_SELECT"))); new QLabel(tr("SMESH_EDGE"), aMainGrp); (new QPushButton(aMainGrp))->setPixmap(aPix); diff --git a/src/SMESHGUI/SMESHGUI_SmoothingDlg.cxx b/src/SMESHGUI/SMESHGUI_SmoothingDlg.cxx index 3adcb19c5..caec59a2c 100644 --- a/src/SMESHGUI/SMESHGUI_SmoothingDlg.cxx +++ b/src/SMESHGUI/SMESHGUI_SmoothingDlg.cxx @@ -93,8 +93,8 @@ SMESHGUI_SmoothingDlg::SMESHGUI_SmoothingDlg( SMESHGUI* theModule, const char* n myViewWindow( SMESH::GetViewWindow( theModule ) ), mySelector( myViewWindow->GetSelector() ) { - QPixmap image0 (SMESHGUI::resourceMgr()->loadPixmap("SMESH", tr("ICON_DLG_SMOOTHING"))); - QPixmap image1 (SMESHGUI::resourceMgr()->loadPixmap("SMESH", tr("ICON_SELECT"))); + QPixmap image0 (SMESH::GetResourceMgr( mySMESHGUI )->loadPixmap("SMESH", tr("ICON_DLG_SMOOTHING"))); + QPixmap image1 (SMESH::GetResourceMgr( mySMESHGUI )->loadPixmap("SMESH", tr("ICON_SELECT"))); if (!name) setName("SMESHGUI_SmoothingDlg"); diff --git a/src/SMESHGUI/SMESHGUI_StandardMeshInfosDlg.cxx b/src/SMESHGUI/SMESHGUI_StandardMeshInfosDlg.cxx index 3b7916938..8960524b3 100644 --- a/src/SMESHGUI/SMESHGUI_StandardMeshInfosDlg.cxx +++ b/src/SMESHGUI/SMESHGUI_StandardMeshInfosDlg.cxx @@ -38,6 +38,7 @@ #include "SALOMEDSClient_Study.hxx" #include "SALOMEDSClient_SObject.hxx" +#include "SUIT_Desktop.h" #include "SUIT_Session.h" #include "SUIT_OverrideCursor.h" @@ -71,10 +72,12 @@ using namespace std; * Constructor */ //================================================================================= -SMESHGUI_StandardMeshInfosDlg::SMESHGUI_StandardMeshInfosDlg (QWidget* parent, const char* name, +SMESHGUI_StandardMeshInfosDlg::SMESHGUI_StandardMeshInfosDlg( SMESHGUI* theModule, const char* name, bool modal, WFlags fl) - : QDialog(parent, name, modal, WStyle_Customize | WStyle_NormalBorder | - WStyle_Title | WStyle_SysMenu | WDestructiveClose) + : QDialog( SMESH::GetDesktop( theModule ), name, modal, WStyle_Customize | WStyle_NormalBorder | + WStyle_Title | WStyle_SysMenu | WDestructiveClose), + mySMESHGUI( theModule ), + mySelectionMgr( SMESH::GetSelectionMgr( theModule ) ) { if (!name) setName("SMESHGUI_StandardMeshInfosDlg"); @@ -150,20 +153,19 @@ SMESHGUI_StandardMeshInfosDlg::SMESHGUI_StandardMeshInfosDlg (QWidget* parent, c aDlgLayout->addWidget(myButtonsGroup, 2, 0); - mySelectionMgr = SMESHGUI::selectionMgr(); - SMESHGUI::GetSMESHGUI()->SetActiveDialogBox(this); + mySMESHGUI->SetActiveDialogBox(this); // connect signals - connect(myOkBtn, SIGNAL(clicked()), this, SLOT(close())); - connect(mySelectBtn, SIGNAL(clicked()), this, SLOT(onStartSelection())); - connect(SMESHGUI::GetSMESHGUI(), SIGNAL(SignalCloseAllDialogs()), this, SLOT(close())); - connect(SMESHGUI::GetSMESHGUI(), SIGNAL(SignalDeactivateActiveDialog()), this, SLOT(DeactivateActiveDialog())); - connect(mySelectionMgr, SIGNAL(currentSelectionChanged()), this, SLOT(onSelectionChanged())); + connect( myOkBtn, SIGNAL(clicked()), this, SLOT(close())); + connect( mySelectBtn, SIGNAL(clicked()), this, SLOT(onStartSelection())); + connect( mySMESHGUI, SIGNAL(SignalCloseAllDialogs()), this, SLOT(close())); + connect( mySMESHGUI, SIGNAL(SignalDeactivateActiveDialog()), this, SLOT(DeactivateActiveDialog())); + connect( mySelectionMgr, SIGNAL(currentSelectionChanged()), this, SLOT(onSelectionChanged())); // resize and move dialog, then show this->setMinimumSize(270, 428); int x, y; - SMESHGUI::GetSMESHGUI()->DefineDlgPosition(this, x, y); + mySMESHGUI->DefineDlgPosition(this, x, y); this->move(x, y); this->show(); @@ -394,7 +396,7 @@ void SMESHGUI_StandardMeshInfosDlg::onSelectionChanged() void SMESHGUI_StandardMeshInfosDlg::closeEvent (QCloseEvent* e) { mySelectionMgr->clearFilters(); - SMESHGUI::GetSMESHGUI()->ResetState(); + mySMESHGUI->ResetState(); QDialog::closeEvent(e); } @@ -426,7 +428,7 @@ void SMESHGUI_StandardMeshInfosDlg::DeactivateActiveDialog() void SMESHGUI_StandardMeshInfosDlg::ActivateThisDialog() { /* Emit a signal to deactivate any active dialog */ - SMESHGUI::GetSMESHGUI()->EmitSignalDeactivateDialog(); + mySMESHGUI->EmitSignalDeactivateDialog(); connect(mySelectionMgr, SIGNAL(currentSelectionChanged()), this, SLOT(onSelectionChanged())); } diff --git a/src/SMESHGUI/SMESHGUI_StandardMeshInfosDlg.h b/src/SMESHGUI/SMESHGUI_StandardMeshInfosDlg.h index 857be0d4d..7fcbdc239 100644 --- a/src/SMESHGUI/SMESHGUI_StandardMeshInfosDlg.h +++ b/src/SMESHGUI/SMESHGUI_StandardMeshInfosDlg.h @@ -41,13 +41,15 @@ class QPushButton; class QLineEdit; class QTextBrowser; class SalomeApp_SelectionMgr; +class SMESHGUI; + class SMESHGUI_StandardMeshInfosDlg : public QDialog { Q_OBJECT public: - SMESHGUI_StandardMeshInfosDlg( QWidget* parent = 0, const char* name = 0, bool modal = FALSE, WFlags fl = 0 ); + SMESHGUI_StandardMeshInfosDlg( SMESHGUI*, const char* name = 0, bool modal = FALSE, WFlags fl = 0 ); ~SMESHGUI_StandardMeshInfosDlg(); protected: @@ -62,6 +64,7 @@ private slots: void onStartSelection(); private: + SMESHGUI* mySMESHGUI; SalomeApp_SelectionMgr* mySelectionMgr; bool myStartSelection; bool myIsActiveWindow; diff --git a/src/SMESHGUI/SMESHGUI_SymmetryDlg.cxx b/src/SMESHGUI/SMESHGUI_SymmetryDlg.cxx index a49f6cef9..225586edd 100644 --- a/src/SMESHGUI/SMESHGUI_SymmetryDlg.cxx +++ b/src/SMESHGUI/SMESHGUI_SymmetryDlg.cxx @@ -86,10 +86,10 @@ SMESHGUI_SymmetryDlg::SMESHGUI_SymmetryDlg( SMESHGUI* theModule, const char* nam myViewWindow( SMESH::GetViewWindow( theModule ) ), mySelector( myViewWindow->GetSelector() ) { - QPixmap image0 (SMESHGUI::resourceMgr()->loadPixmap("SMESH", tr("ICON_SMESH_SYMMETRY_POINT"))); - QPixmap image1 (SMESHGUI::resourceMgr()->loadPixmap("SMESH", tr("ICON_SMESH_SYMMETRY_AXIS"))); - QPixmap image2 (SMESHGUI::resourceMgr()->loadPixmap("SMESH", tr("ICON_SMESH_SYMMETRY_PLANE"))); - QPixmap image3 (SMESHGUI::resourceMgr()->loadPixmap("SMESH", tr("ICON_SELECT"))); + QPixmap image0 (SMESH::GetResourceMgr( mySMESHGUI )->loadPixmap("SMESH", tr("ICON_SMESH_SYMMETRY_POINT"))); + QPixmap image1 (SMESH::GetResourceMgr( mySMESHGUI )->loadPixmap("SMESH", tr("ICON_SMESH_SYMMETRY_AXIS"))); + QPixmap image2 (SMESH::GetResourceMgr( mySMESHGUI )->loadPixmap("SMESH", tr("ICON_SMESH_SYMMETRY_PLANE"))); + QPixmap image3 (SMESH::GetResourceMgr( mySMESHGUI )->loadPixmap("SMESH", tr("ICON_SELECT"))); if (!name) setName("SMESHGUI_SymmetryDlg"); diff --git a/src/SMESHGUI/SMESHGUI_TranslationDlg.cxx b/src/SMESHGUI/SMESHGUI_TranslationDlg.cxx index 5ab553b22..649ae0d74 100644 --- a/src/SMESHGUI/SMESHGUI_TranslationDlg.cxx +++ b/src/SMESHGUI/SMESHGUI_TranslationDlg.cxx @@ -87,9 +87,9 @@ SMESHGUI_TranslationDlg::SMESHGUI_TranslationDlg( SMESHGUI* theModule, const cha myViewWindow( SMESH::GetViewWindow( theModule ) ), mySelector( myViewWindow->GetSelector() ) { - QPixmap image0 (SMESHGUI::resourceMgr()->loadPixmap("SMESH", tr("ICON_SMESH_TRANSLATION_POINTS"))); - QPixmap image1 (SMESHGUI::resourceMgr()->loadPixmap("SMESH", tr("ICON_SMESH_TRANSLATION_VECTOR"))); - QPixmap image2 (SMESHGUI::resourceMgr()->loadPixmap("SMESH", tr("ICON_SELECT"))); + QPixmap image0 (SMESH::GetResourceMgr( mySMESHGUI )->loadPixmap("SMESH", tr("ICON_SMESH_TRANSLATION_POINTS"))); + QPixmap image1 (SMESH::GetResourceMgr( mySMESHGUI )->loadPixmap("SMESH", tr("ICON_SMESH_TRANSLATION_VECTOR"))); + QPixmap image2 (SMESH::GetResourceMgr( mySMESHGUI )->loadPixmap("SMESH", tr("ICON_SELECT"))); if (!name) setName("SMESHGUI_TranslationDlg"); diff --git a/src/SMESHGUI/SMESHGUI_TransparencyDlg.cxx b/src/SMESHGUI/SMESHGUI_TransparencyDlg.cxx index b121d1113..283306aa4 100644 --- a/src/SMESHGUI/SMESHGUI_TransparencyDlg.cxx +++ b/src/SMESHGUI/SMESHGUI_TransparencyDlg.cxx @@ -30,9 +30,10 @@ #include "SMESHGUI.h" #include "SMESHGUI_VTKUtils.h" - +#include "SMESHGUI_Utils.h" #include "SMESH_Actor.h" +#include "SUIT_Desktop.h" #include "SUIT_OverrideCursor.h" #include "SALOME_ListIO.hxx" @@ -58,12 +59,15 @@ using namespace std; // purpose : // //================================================================================= -SMESHGUI_TransparencyDlg::SMESHGUI_TransparencyDlg (QWidget* parent, +SMESHGUI_TransparencyDlg::SMESHGUI_TransparencyDlg( SMESHGUI* theModule, const char* name, bool modal, WFlags fl) - : QDialog(parent, name, modal, WStyle_Customize | WStyle_NormalBorder | - WStyle_Title | WStyle_SysMenu | WDestructiveClose) + : QDialog( SMESH::GetDesktop( theModule ), name, modal, WStyle_Customize | WStyle_NormalBorder | + WStyle_Title | WStyle_SysMenu | WDestructiveClose ), + mySMESHGUI( theModule ), + mySelectionMgr( SMESH::GetSelectionMgr( theModule ) ), + myViewWindow( SMESH::GetViewWindow( theModule ) ) { if (!name) setName("SMESHGUI_TransparencyDlg"); @@ -132,8 +136,6 @@ SMESHGUI_TransparencyDlg::SMESHGUI_TransparencyDlg (QWidget* parent, SMESHGUI_TransparencyDlgLayout->addWidget(GroupC1, 0, 0); SMESHGUI_TransparencyDlgLayout->addWidget(GroupButtons, 1, 0); - mySelectionMgr = SMESHGUI::selectionMgr(); - // Initial state this->onSelectionChanged(); @@ -141,12 +143,12 @@ SMESHGUI_TransparencyDlg::SMESHGUI_TransparencyDlg (QWidget* parent, connect(buttonOk, SIGNAL(clicked()), this, SLOT(ClickOnOk())); connect(Slider1, SIGNAL(valueChanged(int)), this, SLOT(SetTransparency())); connect(Slider1, SIGNAL(sliderMoved(int)), this, SLOT(ValueHasChanged())); - connect(SMESHGUI::GetSMESHGUI(), SIGNAL (SignalCloseAllDialogs()), this, SLOT(ClickOnOk())); + connect(mySMESHGUI, SIGNAL (SignalCloseAllDialogs()), this, SLOT(ClickOnOk())); connect(mySelectionMgr, SIGNAL(currentSelectionChanged()), this, SLOT(onSelectionChanged())); /* Move widget on the botton right corner of main widget */ int x, y; - SMESHGUI::GetSMESHGUI()->DefineDlgPosition(this, x, y); + mySMESHGUI->DefineDlgPosition(this, x, y); this->move(x, y); this->show(); } @@ -176,7 +178,7 @@ void SMESHGUI_TransparencyDlg::ClickOnOk() //================================================================================= void SMESHGUI_TransparencyDlg::SetTransparency() { - if (SVTK_ViewWindow* aVTKViewWindow = SMESH::GetCurrentVtkView()) { + if( myViewWindow ) { SUIT_OverrideCursor wc; float opacity = this->Slider1->value() / 100.; @@ -190,7 +192,7 @@ void SMESHGUI_TransparencyDlg::SetTransparency() if (anActor) anActor->SetOpacity(opacity); } - aVTKViewWindow->Repaint(); + myViewWindow->Repaint(); } ValueHasChanged(); } @@ -210,7 +212,7 @@ void SMESHGUI_TransparencyDlg::ValueHasChanged() //================================================================================= void SMESHGUI_TransparencyDlg::onSelectionChanged() { - if (SVTK_ViewWindow* aVTKViewWindow = SMESH::GetCurrentVtkView()) { + if( myViewWindow ) { int opacity = 100; SALOME_ListIO aList; diff --git a/src/SMESHGUI/SMESHGUI_TransparencyDlg.h b/src/SMESHGUI/SMESHGUI_TransparencyDlg.h index 211f06ee5..c1cced61e 100644 --- a/src/SMESHGUI/SMESHGUI_TransparencyDlg.h +++ b/src/SMESHGUI/SMESHGUI_TransparencyDlg.h @@ -36,6 +36,9 @@ class QLabel; class QPushButton; class QSlider; class SalomeApp_SelectionMgr; +class SVTK_Selector; +class SVTK_ViewWindow; +class SMESHGUI; //================================================================================= // class : SMESHGUI_TransparencyDlg @@ -46,7 +49,7 @@ class SMESHGUI_TransparencyDlg : public QDialog Q_OBJECT public: - SMESHGUI_TransparencyDlg( QWidget* parent = 0, + SMESHGUI_TransparencyDlg( SMESHGUI*, const char* name = 0, bool modal = false, WFlags fl = 0 ); @@ -55,13 +58,15 @@ public: private : - SalomeApp_SelectionMgr* mySelectionMgr; + SMESHGUI* mySMESHGUI; + SalomeApp_SelectionMgr* mySelectionMgr; + SVTK_ViewWindow* myViewWindow; - QPushButton* buttonOk; - QLabel* TextLabelOpaque; - QLabel* ValueLab; - QLabel* TextLabelTransparent; - QSlider* Slider1; + QPushButton* buttonOk; + QLabel* TextLabelOpaque; + QLabel* ValueLab; + QLabel* TextLabelTransparent; + QSlider* Slider1; public slots: diff --git a/src/SMESHGUI/SMESHGUI_Utils.cxx b/src/SMESHGUI/SMESHGUI_Utils.cxx index 3b4976ea6..7dbc44c72 100644 --- a/src/SMESHGUI/SMESHGUI_Utils.cxx +++ b/src/SMESHGUI/SMESHGUI_Utils.cxx @@ -56,6 +56,11 @@ namespace SMESH{ return theModule->getApp()->selectionMgr(); } + SUIT_ResourceMgr* + GetResourceMgr( const SalomeApp_Module* ) + { + return SUIT_Session::session()->resourceMgr(); + } _PTR(Study) GetCStudy(const SalomeApp_Study* theStudy) diff --git a/src/SMESHGUI/SMESHGUI_Utils.h b/src/SMESHGUI/SMESHGUI_Utils.h index 15009ab95..69e1f6160 100644 --- a/src/SMESHGUI/SMESHGUI_Utils.h +++ b/src/SMESHGUI/SMESHGUI_Utils.h @@ -31,6 +31,7 @@ class QString; class SUIT_ViewWindow; class SUIT_Desktop; class SUIT_Study; +class SUIT_ResourceMgr; class CAM_Module; @@ -52,6 +53,9 @@ namespace SMESH { SalomeApp_Study* GetAppStudy(const CAM_Module* theModule); + SUIT_ResourceMgr* + GetResourceMgr( const SalomeApp_Module* ); + _PTR(Study) GetCStudy(const SalomeApp_Study* theStudy); diff --git a/src/SMESHGUI/SMESHGUI_aParameterDlg.cxx b/src/SMESHGUI/SMESHGUI_aParameterDlg.cxx index 07c1ce1f9..03145925f 100644 --- a/src/SMESHGUI/SMESHGUI_aParameterDlg.cxx +++ b/src/SMESHGUI/SMESHGUI_aParameterDlg.cxx @@ -30,6 +30,7 @@ #include "SMESHGUI_aParameter.h" #include "SMESHGUI.h" #include "SMESHGUI_SpinBox.h" +#include "SMESHGUI_Utils.h" #include "SUIT_Tools.h" #include "SUIT_Desktop.h" @@ -53,13 +54,14 @@ using namespace std; // //====================================================================================== SMESHGUI_aParameterDlg::SMESHGUI_aParameterDlg - (std::list params, - QWidget* parent, + ( SMESHGUI* theModule, + std::list params, QString title, bool modal) -: QDialog(parent, "MyParameterDialog", modal, WStyle_Customize | - WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu), - myParamList(params) +: QDialog( SMESH::GetDesktop( theModule ), "MyParameterDialog", modal, WStyle_Customize | + WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu), + myParamList(params), + mySMESHGUI(theModule) { /* creating widgets */ init(); @@ -67,7 +69,7 @@ SMESHGUI_aParameterDlg::SMESHGUI_aParameterDlg setCaption(title); /* Move widget on the botton right corner of main widget */ - SUIT_Tools::centerWidget(this, parent); + SUIT_Tools::centerWidget(this, SMESH::GetDesktop( theModule ) ); } //====================================================================================== @@ -159,9 +161,6 @@ void SMESHGUI_aParameterDlg::init() /* signals and slots connections */ connect(myButtonOk, SIGNAL(clicked()), this, SLOT(ClickOnOk())); connect(myButtonCancel, SIGNAL(clicked()), this, SLOT(reject())); - - /* Retrieve SMESHGUI */ - mySMESHGUI = SMESHGUI::GetSMESHGUI(); } //====================================================================================== @@ -194,12 +193,13 @@ void SMESHGUI_aParameterDlg::ClickOnOk() // function : Parameters() // purpose : return a list of parameters from a dialog box //======================================================================= -bool SMESHGUI_aParameterDlg::Parameters (list params, +bool SMESHGUI_aParameterDlg::Parameters( SMESHGUI* theModule, + list params, const char *aTitle) { if (!params.empty()) { SMESHGUI_aParameterDlg *Dialog = - new SMESHGUI_aParameterDlg(params, SMESHGUI::desktop(), aTitle, TRUE); + new SMESHGUI_aParameterDlg( theModule, params, aTitle, TRUE); return (Dialog->exec() == QDialog::Accepted); } return false; diff --git a/src/SMESHGUI/SMESHGUI_aParameterDlg.h b/src/SMESHGUI/SMESHGUI_aParameterDlg.h index 7c9cd19aa..0c53672b2 100644 --- a/src/SMESHGUI/SMESHGUI_aParameterDlg.h +++ b/src/SMESHGUI/SMESHGUI_aParameterDlg.h @@ -49,15 +49,15 @@ class SMESHGUI_aParameterDlg : public QDialog Q_OBJECT public: - SMESHGUI_aParameterDlg (std::list params, - QWidget* parent = 0, + SMESHGUI_aParameterDlg( SMESHGUI*, + std::list params, QString title = QString::null, bool modal = TRUE); ~SMESHGUI_aParameterDlg(); /* Parameter function */ - static bool Parameters (std::list params, const char *aTitle); + static bool Parameters( SMESHGUI*, std::list params, const char *aTitle); protected: void init(); diff --git a/src/StdMeshersGUI/StdMeshersGUI.cxx b/src/StdMeshersGUI/StdMeshersGUI.cxx index aa7bd34bd..93322c3e7 100644 --- a/src/StdMeshersGUI/StdMeshersGUI.cxx +++ b/src/StdMeshersGUI/StdMeshersGUI.cxx @@ -121,7 +121,7 @@ void StdMeshersGUI_HypothesisCreator::EditHypothesis StdMeshersGUI_Parameters::GetParameters( theHyp, paramList ); bool modified = false; - if ( SMESHGUI_aParameterDlg::Parameters( paramList, QObject::tr("SMESH_VALUE")) ) + if ( SMESHGUI_aParameterDlg::Parameters( SMESHGUI::GetSMESHGUI(), paramList, QObject::tr("SMESH_VALUE")) ) modified = StdMeshersGUI_Parameters::SetParameters( theHyp, paramList ); if ( modified ) {