X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;ds=sidebyside;f=src%2FSMESHGUI%2FSMESHGUI_MeshPatternDlg.cxx;h=9184f68b509f4b231cec2ca5ca8de29da323b372;hb=refs%2Ftags%2FV3_2_5pre1;hp=cab4a47a2fd8cb10b48d7477b0be97abd2c3950c;hpb=a90ef6efde9b07cd44333af32c174fdca08d8057;p=modules%2Fsmesh.git diff --git a/src/SMESHGUI/SMESHGUI_MeshPatternDlg.cxx b/src/SMESHGUI/SMESHGUI_MeshPatternDlg.cxx index cab4a47a2..9184f68b5 100755 --- a/src/SMESHGUI/SMESHGUI_MeshPatternDlg.cxx +++ b/src/SMESHGUI/SMESHGUI_MeshPatternDlg.cxx @@ -17,7 +17,7 @@ // 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 +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // // // @@ -46,10 +46,13 @@ #include "SUIT_ResourceMgr.h" #include "SUIT_Desktop.h" #include "SUIT_FileDlg.h" +#include "SUIT_Session.h" +#include "SUIT_MessageBox.h" -#include "SalomeApp_SelectionMgr.h" +#include "LightApp_SelectionMgr.h" #include "SalomeApp_Tools.h" #include "SalomeApp_Study.h" +#include "LightApp_Application.h" #include "SALOMEDS_SObject.hxx" @@ -59,6 +62,7 @@ #include "SVTK_ViewModel.h" #include "SVTK_Selector.h" #include "SVTK_ViewWindow.h" +#include "VTKViewer_CellLocationsArray.h" // OCCT Includes #include @@ -86,11 +90,11 @@ // VTK Includes #include #include -#include #include #include #include #include +#include #define SPACING 5 #define MARGIN 10 @@ -110,9 +114,7 @@ SMESHGUI_MeshPatternDlg::SMESHGUI_MeshPatternDlg( SMESHGUI* theModule, WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu), myBusy(false), mySMESHGUI( theModule ), - mySelectionMgr( SMESH::GetSelectionMgr( theModule ) ), - myViewWindow( SMESH::GetViewWindow( theModule ) ), - mySelector( myViewWindow->GetSelector() ) + mySelectionMgr( SMESH::GetSelectionMgr( theModule ) ) { setCaption(tr("CAPTION")); @@ -127,6 +129,11 @@ SMESHGUI_MeshPatternDlg::SMESHGUI_MeshPatternDlg( SMESHGUI* theModule, aDlgLay->setStretchFactor(aMainFrame, 1); myCreationDlg = 0; + + mySelector = (SMESH::GetViewWindow( mySMESHGUI ))->GetSelector(); + + myHelpFileName = "pattern_mapping.htm"; + Init(); } @@ -288,6 +295,7 @@ QFrame* SMESHGUI_MeshPatternDlg::createButtonFrame (QWidget* theParent) myOkBtn = new QPushButton(tr("SMESH_BUT_OK" ), aFrame); myApplyBtn = new QPushButton(tr("SMESH_BUT_APPLY"), aFrame); myCloseBtn = new QPushButton(tr("SMESH_BUT_CLOSE"), aFrame); + myHelpBtn = new QPushButton(tr("SMESH_BUT_HELP"), aFrame); QSpacerItem* aSpacer = new QSpacerItem(0, 0, QSizePolicy::Expanding, QSizePolicy::Minimum); @@ -297,10 +305,12 @@ QFrame* SMESHGUI_MeshPatternDlg::createButtonFrame (QWidget* theParent) aLay->addWidget(myApplyBtn); aLay->addItem(aSpacer); aLay->addWidget(myCloseBtn); + aLay->addWidget(myHelpBtn); connect(myOkBtn, SIGNAL(clicked()), SLOT(onOk())); connect(myCloseBtn, SIGNAL(clicked()), SLOT(onClose())); connect(myApplyBtn, SIGNAL(clicked()), SLOT(onApply())); + connect(myHelpBtn, SIGNAL(clicked()), SLOT(onHelp())); return aFrame; } @@ -349,9 +359,6 @@ void SMESHGUI_MeshPatternDlg::Init() activateSelection(); onSelectionDone(); - int x, y; - mySMESHGUI->DefineDlgPosition(this, x, y); - this->move(x, y); this->show(); } @@ -376,6 +383,13 @@ bool SMESHGUI_MeshPatternDlg::isValid (const bool theMess) return false; } + if ( myName->text()=="" ) { + if (theMess) + QMessageBox::information(SMESHGUI::desktop(), tr("SMESH_INSUFFICIENT_DATA"), + tr("SMESHGUI_INVALID_PARAMETERS"), QMessageBox::Ok); + return false; + } + return true; } @@ -413,11 +427,8 @@ bool SMESHGUI_MeshPatternDlg::onApply() bool toCreatePolygons = myCreatePolygonsChk->isChecked(); bool toCreatePolyedrs = myCreatePolyedrsChk->isChecked(); if ( myPattern->MakeMesh( myMesh, toCreatePolygons, toCreatePolyedrs ) ) { - mySelectionMgr->clearSelected(); - SUIT_ResourceMgr* mgr = SMESH::GetResourceMgr( mySMESHGUI ); - bool autoUpdate = false; - if (mgr && mgr->stringValue("SMESH", "AutomaticUpdate").compare("true") == 0) - autoUpdate = true; + //mySelectionMgr->clearSelected(); + bool autoUpdate = SMESHGUI::automaticUpdate(); if (!isRefine() && autoUpdate) { _PTR(SObject) aSO = SMESH::FindSObject(myMesh.in()); SMESH_Actor* anActor = SMESH::FindActorByEntry(aSO->GetID().c_str()); @@ -429,9 +440,13 @@ bool SMESHGUI_MeshPatternDlg::onApply() } } } + mySelectionMgr->clearSelected(); SMESH::UpdateView(); - + mySMESHGUI->updateObjBrowser(true); + + mySelEdit[ Ids ]->setText(""); + return true; } else { QMessageBox::information(SMESHGUI::desktop(), tr("SMESH_ERROR"), @@ -464,7 +479,8 @@ void SMESHGUI_MeshPatternDlg::onClose() { mySelectionMgr->clearFilters(); SMESH::SetPickable(); - myViewWindow->SetSelectionMode(ActorSelection); + if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI )) + aViewWindow->SetSelectionMode(ActorSelection); disconnect(mySelectionMgr, 0, this, 0); disconnect(mySMESHGUI, 0, this, 0); mySMESHGUI->ResetState(); @@ -472,6 +488,23 @@ void SMESHGUI_MeshPatternDlg::onClose() reject(); } +//================================================================================= +// function : onHelp() +// purpose : +//================================================================================= +void SMESHGUI_MeshPatternDlg::onHelp() +{ + LightApp_Application* app = (LightApp_Application*)(SUIT_Session::session()->activeApplication()); + if (app) + app->onHelpContextModule(mySMESHGUI ? app->moduleName(mySMESHGUI->moduleName()) : QString(""), myHelpFileName); + else { + SUIT_MessageBox::warn1(0, QObject::tr("WRN_WARNING"), + QObject::tr("EXTERNAL_BROWSER_CANNOT_SHOW_PAGE"). + arg(app->resourceMgr()->stringValue("ExternalBrowser", "application")).arg(myHelpFileName), + QObject::tr("BUT_OK")); + } +} + //======================================================================= // name : SMESHGUI_MeshPatternDlg::onSelectionDone // Purpose : SLOT called when selection changed @@ -516,6 +549,8 @@ void SMESHGUI_MeshPatternDlg::onSelectionDone() } else if (mySelInput == Ids) { SALOME_ListIO aList; mySelectionMgr->selectedObjects(aList,SVTK_Viewer::Type()); + if (aList.Extent() != 1) + return; QString anIds; if (!SMESH::GetNameOfSelectedElements(mySelector, aList.First(), anIds)) @@ -738,7 +773,10 @@ void SMESHGUI_MeshPatternDlg::onOkCreationDlg() { myPattern = SMESH::SMESH_Pattern::_duplicate(myCreationDlg->GetPattern()); myName->setText(myCreationDlg->GetPatternName()); + + updateWgState(); displayPreview(); + setEnabled(true); myIsCreateDlgOpen = false; } @@ -853,7 +891,7 @@ void SMESHGUI_MeshPatternDlg::displayPreview() aProp->SetRepresentationToWireframe(); aProp->SetColor(250, 0, 250); if (SMESH::FindActorByObject(myMesh)) - aProp->SetLineWidth(SMESH::GetFloat("SMESH:SettingsWidth", 1) +1); + aProp->SetLineWidth( SMESH::GetFloat( "SMESH:element_width", 1 ) + 1 ); else aProp->SetLineWidth(1); myPreviewActor->SetProperty(aProp); @@ -932,7 +970,7 @@ void SMESHGUI_MeshPatternDlg::updateWgState() } QValueList ids; - if (!CORBA::is_nil(myPattern) && getIds(ids)) { + if (!CORBA::is_nil(myPattern)/* && getIds(ids)*/) { SMESH::long_array_var keyPoints = myPattern->GetKeyPoints(); if (keyPoints->length()) { myNode1->setEnabled(true); @@ -963,14 +1001,21 @@ void SMESHGUI_MeshPatternDlg::activateSelection() SMESH::SetPickable(anActor); if (myType == Type_2d) - myViewWindow->SetSelectionMode(FaceSelection); + { + if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI )) + aViewWindow->SetSelectionMode(FaceSelection); + } else - myViewWindow->SetSelectionMode(CellSelection); + { + if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI )) + aViewWindow->SetSelectionMode(CellSelection); + } } else { SMESH::SetPickable(); //mySelectionMgr->setSelectionModes(ActorSelection); - myViewWindow->SetSelectionMode(ActorSelection); + if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI )) + aViewWindow->SetSelectionMode(ActorSelection); } if (mySelInput == Object && !myMeshShape->_is_nil()) { @@ -1188,7 +1233,7 @@ vtkUnstructuredGrid* SMESHGUI_MeshPatternDlg::getGrid() else aCellTypesArray->InsertNextValue(VTK_EMPTY_CELL); } - vtkIntArray* aCellLocationsArray = vtkIntArray::New(); + VTKViewer_CellLocationsArray* aCellLocationsArray = VTKViewer_CellLocationsArray::New(); aCellLocationsArray->SetNumberOfComponents(1); aCellLocationsArray->SetNumberOfTuples(aNbCells); @@ -1257,30 +1302,21 @@ void SMESHGUI_MeshPatternDlg::onTextChanged (const QString& theNewText) if (aMesh) { QStringList aListId = QStringList::split(" ", theNewText, false); - SALOME_ListIO aList; - aList.Append(anActor->getIO()); - mySelectionMgr->setSelectedObjects(aList, false); - - TColStd_IndexedMapOfInteger selectedIndices; TColStd_MapOfInteger newIndices; - mySelector->GetIndex(anActor->getIO(), selectedIndices); for (int i = 0; i < aListId.count(); i++) { const SMDS_MeshElement * e = aMesh->FindElement(aListId[ i ].toInt()); - if (e && e->GetType() == (myType == Type_2d ? SMDSAbs_Face : SMDSAbs_Volume)) { - if (selectedIndices.Add(e->GetID())) { - newIndices.Add(e->GetID()); - } - } - } - if (newIndices.Extent() > 0) - { - mySelector->AddOrRemoveIndex( anActor->getIO(), newIndices, true); - myViewWindow->highlight( anActor->getIO(), true, true ); + if (e && e->GetType() == (myType == Type_2d ? SMDSAbs_Face : SMDSAbs_Volume)) + newIndices.Add(e->GetID()); } + mySelector->AddOrRemoveIndex( anActor->getIO(), newIndices, false); + if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI )) + aViewWindow->highlight( anActor->getIO(), true, true ); } myBusy = false; + + displayPreview(); } //======================================================================= @@ -1332,3 +1368,20 @@ int SMESHGUI_MeshPatternDlg::getNode (bool second) const { return second ? myNode2->value() - 1 : myNode1->value() - 1; } + +//================================================================================= +// function : keyPressEvent() +// purpose : +//================================================================================= +void SMESHGUI_MeshPatternDlg::keyPressEvent( QKeyEvent* e ) +{ + QDialog::keyPressEvent( e ); + if ( e->isAccepted() ) + return; + + if ( e->key() == Key_F1 ) + { + e->accept(); + onHelp(); + } +}