X-Git-Url: http://git.salome-platform.org/gitweb/?p=modules%2Fsmesh.git;a=blobdiff_plain;f=src%2FSMESHGUI%2FSMESHGUI_AddMeshElementDlg.cxx;h=28eba22e9b073334e862ee200bc06cb13f1e2bb9;hp=8226cdc6a7470801d4f96923479c78c8ed2aedb7;hb=57b43b4d010e2d0a1529d3c131bbb9d416e63258;hpb=a2f0f70d5912ea83c868916f06eaefb58a32ec2e diff --git a/src/SMESHGUI/SMESHGUI_AddMeshElementDlg.cxx b/src/SMESHGUI/SMESHGUI_AddMeshElementDlg.cxx index 8226cdc6a..28eba22e9 100644 --- a/src/SMESHGUI/SMESHGUI_AddMeshElementDlg.cxx +++ b/src/SMESHGUI/SMESHGUI_AddMeshElementDlg.cxx @@ -39,6 +39,8 @@ #include "SMESH_Actor.h" #include "SUIT_Session.h" +#include "SUIT_MessageBox.h" +#include "LightApp_Application.h" #include "SVTK_Selection.h" #include "SVTK_Selector.h" @@ -65,6 +67,7 @@ #include #include #include +#include // QT Includes #include @@ -118,21 +121,17 @@ namespace SMESH { myPreviewActor->VisibilityOff(); myPreviewActor->SetMapper(myMapper); + vtkFloatingPointType anRGB[3]; vtkProperty* aProp = vtkProperty::New(); - float anRGB[3]; - anRGB[0] = GetFloat("SMESH:SettingsFillColorRed", 0)/255.; - anRGB[1] = GetFloat("SMESH:SettingsFillColorGreen", 170)/255.; - anRGB[2] = GetFloat("SMESH:SettingsFillColorBlue", 255)/255.; - aProp->SetColor(anRGB[0],anRGB[1],anRGB[2]); - myPreviewActor->SetProperty(aProp); + GetColor( "SMESH", "fill_color", anRGB[0], anRGB[1], anRGB[2], QColor( 0, 170, 255 ) ); + aProp->SetColor( anRGB[0], anRGB[1], anRGB[2] ); + myPreviewActor->SetProperty( aProp ); aProp->Delete(); vtkProperty* aBackProp = vtkProperty::New(); - anRGB[0] = GetFloat("SMESH:SettingsBackFaceColorRed", 0)/255.; - anRGB[1] = GetFloat("SMESH:SettingsBackFaceColorGreen", 0)/255.; - anRGB[2] = GetFloat("SMESH:SettingsBackFaceColorBlue", 255)/255.; - aBackProp->SetColor(anRGB[0],anRGB[1],anRGB[2]); - myPreviewActor->SetBackfaceProperty(aBackProp); + GetColor( "SMESH", "backface_color", anRGB[0], anRGB[1], anRGB[2], QColor( 0, 0, 255 ) ); + aBackProp->SetColor( anRGB[0], anRGB[1], anRGB[2] ); + myPreviewActor->SetBackfaceProperty( aBackProp ); aBackProp->Delete(); myVTKViewWindow->AddActor(myPreviewActor); @@ -220,14 +219,13 @@ SMESHGUI_AddMeshElementDlg::SMESHGUI_AddMeshElementDlg( SMESHGUI* theModule, : QDialog( SMESH::GetDesktop( theModule ), name, modal, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu | Qt::WDestructiveClose), mySMESHGUI( theModule ), - mySelectionMgr( SMESH::GetSelectionMgr( theModule ) ), - myViewWindow( SMESH::GetViewWindow( theModule ) ), - mySelector( myViewWindow->GetSelector() ) + mySelectionMgr( SMESH::GetSelectionMgr( theModule ) ) { SalomeApp_Application* anApp = dynamic_cast (SUIT_Session::session()->activeApplication()); myIsPoly = false; mySimulation = new SMESH::TElementSimulation (anApp); + mySelector = (SMESH::GetViewWindow( mySMESHGUI ))->GetSelector(); // verify nb nodes and type myNbNodes = nbNodes; @@ -247,20 +245,34 @@ SMESHGUI_AddMeshElementDlg::SMESHGUI_AddMeshElementDlg( SMESHGUI* theModule, } QString elemName; - if (myNbNodes == 2) + if (myNbNodes == 2) { elemName = "EDGE"; - else if (myNbNodes == 3) + myHelpFileName = "/files/adding_nodes_and_elements.htm#Adding_edges"; + } + else if (myNbNodes == 3) { elemName = "TRIANGLE"; + myHelpFileName = "/files/adding_nodes_and_elements.htm#Adding_triangles"; + } else if (myNbNodes == 4) - if (myElementType == SMDSAbs_Face) + if (myElementType == SMDSAbs_Face) { elemName = "QUADRANGLE"; - else + myHelpFileName = "/files/adding_nodes_and_elements.htm#Adding_quadrangles"; + } + else { elemName = "TETRAS"; - else if (myNbNodes == 8) + myHelpFileName = "/files/adding_nodes_and_elements.htm#Adding_tetrahedrons"; + } + else if (myNbNodes == 8) { elemName = "HEXAS"; - else if (myElementType == SMDSAbs_Face){ + myHelpFileName = "/files/adding_nodes_and_elements.htm#Adding_hexahedrons"; + } + else if (myElementType == SMDSAbs_Face) { elemName = "POLYGON"; myIsPoly = true; + myHelpFileName = "/files/adding_nodes_and_elements.htm#Adding_polygons"; + } + else if (myElementType == SMDSAbs_Volume) { + myHelpFileName = "/files/adding_nodes_and_elements.htm#Adding_polyhedrons"; } QString iconName = tr(QString("ICON_DLG_%1").arg(elemName)); @@ -330,6 +342,11 @@ SMESHGUI_AddMeshElementDlg::SMESHGUI_AddMeshElementDlg( SMESHGUI* theModule, buttonOk->setAutoDefault(TRUE); buttonOk->setDefault(TRUE); GroupButtonsLayout->addWidget(buttonOk, 0, 0); + buttonHelp = new QPushButton(GroupButtons, "buttonHelp"); + buttonHelp->setText(tr("SMESH_BUT_HELP" )); + buttonHelp->setAutoDefault(TRUE); + GroupButtonsLayout->addWidget(buttonHelp, 0, 4); + SMESHGUI_AddMeshElementDlgLayout->addWidget(GroupButtons, 2, 0); /***************************************************************/ @@ -404,6 +421,7 @@ void SMESHGUI_AddMeshElementDlg::Init() connect(buttonOk, SIGNAL(clicked()), SLOT(ClickOnOk())); connect(buttonCancel, SIGNAL(clicked()), SLOT(ClickOnCancel())); connect(buttonApply, SIGNAL(clicked()), SLOT(ClickOnApply())); + connect(buttonHelp, SIGNAL(clicked()), SLOT(ClickOnHelp())); connect(SelectButtonC1A1, SIGNAL(clicked()), SLOT(SetEditCurrentArgument())); connect(LineEditC1A1, SIGNAL(textChanged(const QString&)), SLOT(onTextChange(const QString&))); @@ -415,16 +433,13 @@ void SMESHGUI_AddMeshElementDlg::Init() if (Reverse) connect(Reverse, SIGNAL(stateChanged(int)), SLOT(CheckBox(int))); - // Move widget on the botton right corner of main widget - int x, y; - mySMESHGUI->DefineDlgPosition(this, x, y); - this->move(x, y); this->show(); // displays Dialog // set selection mode SMESH::SetPointRepresentation(true); - myViewWindow->SetSelectionMode( NodeSelection ); + if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI )) + aViewWindow->SetSelectionMode( NodeSelection ); myBusy = false; @@ -453,14 +468,21 @@ void SMESHGUI_AddMeshElementDlg::ClickOnApply() switch (myElementType) { case SMDSAbs_Edge: aMeshEditor->AddEdge(anArrayOfIdeces.inout()); break; - case SMDSAbs_Face: - aMeshEditor->AddFace(anArrayOfIdeces.inout()); break; + case SMDSAbs_Face:{ + if(myIsPoly) + aMeshEditor->AddPolygonalFace(anArrayOfIdeces.inout()); + else + aMeshEditor->AddFace(anArrayOfIdeces.inout()); + break; + + } case SMDSAbs_Volume: aMeshEditor->AddVolume(anArrayOfIdeces.inout()); break; default:; } SALOME_ListIO aList; aList.Append( myActor->getIO() ); + mySelector->ClearIndex(); mySelectionMgr->setSelectedObjects( aList, false ); SMESH::UpdateView(); @@ -492,16 +514,34 @@ void SMESHGUI_AddMeshElementDlg::ClickOnOk() //================================================================================= void SMESHGUI_AddMeshElementDlg::ClickOnCancel() { - mySelectionMgr->clearSelected(); + //mySelectionMgr->clearSelected(); mySimulation->SetVisibility(false); SMESH::SetPointRepresentation(false); - myViewWindow->SetSelectionMode( ActorSelection ); + if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI )) + aViewWindow->SetSelectionMode( ActorSelection ); disconnect(mySelectionMgr, 0, this, 0); mySMESHGUI->ResetState(); reject(); return; } +//================================================================================= +// function : ClickOnHelp() +// purpose : +//================================================================================= +void SMESHGUI_AddMeshElementDlg::ClickOnHelp() +{ + 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")); + } +} + //================================================================================= // function : onTextChange() // purpose : @@ -524,33 +564,33 @@ void SMESHGUI_AddMeshElementDlg::onTextChange (const QString& theNewText) aMesh = myActor->GetObject()->GetMesh(); if (aMesh) { - SALOME_ListIO aList; aList.Append( myActor->getIO() ); - mySelectionMgr->setSelectedObjects( aList, false ); - - TColStd_IndexedMapOfInteger selectedIndices; TColStd_MapOfInteger newIndices; - mySelector->GetIndex(myActor->getIO(), selectedIndices); - + QStringList aListId = QStringList::split(" ", theNewText, false); + bool allOk = true; for (int i = 0; i < aListId.count(); i++) { if( const SMDS_MeshNode * n = aMesh->FindNode( aListId[ i ].toInt() ) ) { - if( selectedIndices.Add( n->GetID() ) ) - newIndices.Add( n->GetID() ); + newIndices.Add( n->GetID() ); myNbOkNodes++; } + else + allOk = false; } - if( newIndices.Extent()>0 ) - { - mySelector->AddOrRemoveIndex( myActor->getIO(), newIndices, true ); - myViewWindow->highlight( myActor->getIO(), true, true ); - } - bool aNodesOK = false; - if (myIsPoly && myElementType == SMDSAbs_Face && aListId.count() >=3 ){ - myNbOkNodes = aListId.count(); - aNodesOK = true; - } + mySelector->AddOrRemoveIndex( myActor->getIO(), newIndices, false ); + if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI )) + aViewWindow->highlight( myActor->getIO(), true, true ); + + myNbOkNodes = ( allOk && myNbNodes == aListId.count() ); + + if (myIsPoly) + { + if ( !allOk || myElementType != SMDSAbs_Face || aListId.count() < 3 ) + myNbOkNodes = 0; + else + myNbOkNodes = aListId.count(); + } } if(myNbOkNodes) { @@ -656,6 +696,7 @@ void SMESHGUI_AddMeshElementDlg::displaySimulation() } mySimulation->SetPosition(myActor,aType,anIds); + SMESH::UpdateView(); } } @@ -704,7 +745,8 @@ void SMESHGUI_AddMeshElementDlg::ActivateThisDialog() SMESH::SetPointRepresentation(true); - myViewWindow->SetSelectionMode( NodeSelection ); + if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI )) + aViewWindow->SetSelectionMode( NodeSelection ); SelectionIntoArgument(); }