X-Git-Url: http://git.salome-platform.org/gitweb/?p=modules%2Fsmesh.git;a=blobdiff_plain;f=src%2FSMESHGUI%2FSMESHGUI.cxx;h=493b734bb144759ea436447652610fc438a5af65;hp=2d1419586f89558f082662db13de6c593e1ad3ef;hb=8f57b2cfd33d6d41539b00f3665f184266c297be;hpb=b0a908c0d20341651771d0249fb10882f54b2aad diff --git a/src/SMESHGUI/SMESHGUI.cxx b/src/SMESHGUI/SMESHGUI.cxx index 2d1419586..493b734bb 100644 --- a/src/SMESHGUI/SMESHGUI.cxx +++ b/src/SMESHGUI/SMESHGUI.cxx @@ -44,6 +44,7 @@ #include "SMESHGUI_DuplicateNodesDlg.h" #include "SMESHGUI_ExtrusionAlongPathDlg.h" #include "SMESHGUI_ExtrusionDlg.h" +#include "SMESHGUI_FieldSelectorWdg.h" #include "SMESHGUI_FileInfoDlg.h" #include "SMESHGUI_FileValidator.h" #include "SMESHGUI_FilterDlg.h" @@ -181,21 +182,6 @@ // of auto-color picking up #define SIMPLE_AUTOCOLOR -// REMOVE the code about MPLMathText_Disabler if it does not complite at porting to ParaView-4.1 -#include -namespace -{ - // Creation of this class disables vtkMatplotlibMathTextUtilities - struct MPLMathText_Disabler : protected vtkMatplotlibMathTextUtilities - { - MPLMathText_Disabler() - { - vtkMatplotlibMathTextUtilities::MPLMathTextAvailable = - vtkMatplotlibMathTextUtilities::UNAVAILABLE; - } - }; -} - namespace { // Declarations @@ -212,7 +198,12 @@ namespace void Control( int theCommandID ); // Definitions - //============================================================= + //================================================================================ + /*! + * \brief Reads meshes from file + */ + //================================================================================ + void ImportMeshesFromFile( SMESH::SMESH_Gen_ptr theComponentMesh, int theCommandID ) { @@ -611,6 +602,8 @@ namespace if ( SUIT_FileDlg::getLastVisitedPath().isEmpty() ) anInitialPath = QDir::currentPath(); + QList< QPair< GEOM::ListOfFields_var, QString > > aFieldList; + // Get a file name to write in and additional otions if ( isUNV || isDAT || isGMF ) // Export w/o options { @@ -696,8 +689,13 @@ namespace QStringList checkBoxes; checkBoxes << QObject::tr("SMESH_AUTO_GROUPS") << QObject::tr("SMESH_AUTO_DIM"); + SMESHGUI_FieldSelectorWdg* fieldSelWdg = new SMESHGUI_FieldSelectorWdg(); + QList< QWidget* > wdgList; + if ( fieldSelWdg->GetAllFeilds( aMeshList, aFieldList )) + wdgList.append( fieldSelWdg ); + SalomeApp_CheckFileDlg* fd = - new SalomeApp_CheckFileDlg ( SMESHGUI::desktop(), false, checkBoxes, true, true ); + new SalomeApp_CheckFileDlg ( SMESHGUI::desktop(), false, checkBoxes, true, true, wdgList ); fd->setWindowTitle( aTitle ); fd->setNameFilters( filters ); fd->selectNameFilter( aDefaultFilter ); @@ -787,6 +785,9 @@ namespace } toCreateGroups = fd->IsChecked(0); toFindOutDim = fd->IsChecked(1); + fieldSelWdg->GetSelectedFeilds(); + if ( !fieldSelWdg->parent() ) + delete fieldSelWdg; delete fd; } else @@ -823,12 +824,16 @@ namespace { SMESH::SMESH_IDSource_var aMeshOrGroup = (*aMeshIter).first; SMESH::SMESH_Mesh_var aMeshItem = aMeshOrGroup->GetMesh(); - if ( aMeshOrGroup->_is_equivalent( aMeshItem )) + const GEOM::ListOfFields& fields = aFieldList[ aMeshIndex ].first.in(); + const QString& geoAssFields = aFieldList[ aMeshIndex ].second; + const bool hasFields = ( fields.length() || !geoAssFields.isEmpty() ); + if ( !hasFields && aMeshOrGroup->_is_equivalent( aMeshItem )) aMeshItem->ExportToMEDX( aFilename.toUtf8().data(), toCreateGroups, aFormat, toOverwrite && aMeshIndex == 0, toFindOutDim ); else aMeshItem->ExportPartToMED( aMeshOrGroup, aFilename.toUtf8().data(), toCreateGroups, - aFormat, toOverwrite && aMeshIndex == 0, toFindOutDim ); + aFormat, toOverwrite && aMeshIndex == 0, toFindOutDim, + fields, geoAssFields.toLatin1().data() ); } } else if ( isSAUV ) @@ -1296,6 +1301,7 @@ namespace int deltaF = 0, deltaV = 0; int elem0dSize = 1; int ballSize = 1; + double ballScale = 1.0; int edgeWidth = 1; int outlineWidth = 1; double shrinkCoef = 0.0; @@ -1340,6 +1346,7 @@ namespace anActor->GetBallColor( color[0], color[1], color[2] ); ballColor.setRgbF( color[0], color[1], color[2] ); ballSize = qMax( (int)anActor->GetBallSize(), 1 ); // minimum allowed size is 1 + ballScale = qMax( (double)anActor->GetBallScale(), 1e-2 ); // minimum allowed scale is 1e-2 // outlines: color anActor->GetOutlineColor( color[0], color[1], color[2] ); outlineColor.setRgbF( color[0], color[1], color[2] ); @@ -1396,6 +1403,7 @@ namespace // balls: color, size dlg.setBallColor( ballColor ); dlg.setBallSize( ballSize ); + dlg.setBallScale( ballScale ); // orientation: color, scale, 3d flag dlg.setOrientationColor( orientationColor ); dlg.setOrientationSize( int( orientationScale * 100. ) ); @@ -1422,6 +1430,7 @@ namespace elem0dSize = dlg.elem0dSize(); ballColor = dlg.ballColor(); ballSize = dlg.ballSize(); + ballScale = dlg.ballScale(); orientationColor = dlg.orientationColor(); orientationScale = dlg.orientationSize() / 100.; orientation3d = dlg.orientation3d(); @@ -1465,6 +1474,7 @@ namespace // balls: color, size anActor->SetBallColor( ballColor.redF(), ballColor.greenF(), ballColor.blueF() ); anActor->SetBallSize( ballSize ); + anActor->SetBallScale( ballScale ); // orientation: color, scale, 3d flag anActor->SetFacesOrientationColor( orientationColor.redF(), orientationColor.greenF(), orientationColor.blueF() ); anActor->SetFacesOrientationScale( orientationScale ); @@ -1954,8 +1964,6 @@ SalomeApp_Module( "SMESH" ) /* load resources for all available meshers */ SMESH::InitAvailableHypotheses(); - - MPLMathText_Disabler d; // disable vtkMatplotlibMathTextUtilities } //============================================================================= @@ -2004,8 +2012,8 @@ bool SMESHGUI::automaticUpdate(unsigned int requestedSize, bool* limitExceeded) * */ //============================================================================= -bool SMESHGUI::automaticUpdate( SMESH::SMESH_Mesh_ptr theMesh, - int* entities, bool* limitExceeded, int* hidden ) +bool SMESHGUI::automaticUpdate( SMESH::SMESH_IDSource_ptr theMesh, + int* entities, bool* limitExceeded, int* hidden, long* nbElements ) { SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr(); if ( !resMgr ) @@ -2015,8 +2023,23 @@ bool SMESHGUI::automaticUpdate( SMESH::SMESH_Mesh_ptr theMesh, long updateLimit = resMgr->integerValue( "SMESH", "update_limit", 500000 ); bool incrementalLimit = resMgr->booleanValue( "SMESH", "incremental_limit", false ); - long requestedSize = theMesh->NbElements(); - + SMESH::long_array_var info = theMesh->GetMeshInfo(); + long nbOdElems = info[SMDSEntity_0D]; + long nbEdges = info[SMDSEntity_Edge] + info[SMDSEntity_Quad_Edge]; + long nbFaces = info[SMDSEntity_Triangle] + info[SMDSEntity_Quad_Triangle] + info[SMDSEntity_BiQuad_Triangle] + + info[SMDSEntity_Quadrangle] + info[SMDSEntity_Quad_Quadrangle] + info[SMDSEntity_BiQuad_Quadrangle] + + info[SMDSEntity_Polygon]; + long nbVolumes = info[SMDSEntity_Tetra] + info[SMDSEntity_Quad_Tetra] + + info[SMDSEntity_Hexa] + info[SMDSEntity_Quad_Hexa] + info[SMDSEntity_TriQuad_Hexa] + + info[SMDSEntity_Pyramid] + info[SMDSEntity_Quad_Pyramid] + + info[SMDSEntity_Penta] + info[SMDSEntity_Quad_Penta] + + info[SMDSEntity_Polyhedra] + + info[SMDSEntity_Hexagonal_Prism]; + long nbBalls = info[SMDSEntity_Ball]; + + long requestedSize = nbOdElems + nbBalls + nbEdges + nbFaces + nbVolumes; + *nbElements = requestedSize; + *entities = SMESH_Actor::eAllEntity; *hidden = 0; @@ -2025,11 +2048,6 @@ bool SMESHGUI::automaticUpdate( SMESH::SMESH_Mesh_ptr theMesh, if ( limitExceeded ) *limitExceeded = autoUpdate && exceeded; if ( incrementalLimit ) { - long nbOdElems = theMesh->Nb0DElements(); - long nbEdges = theMesh->NbEdges(); - long nbFaces = theMesh->NbFaces(); - long nbVolumes = theMesh->NbVolumes(); - long nbBalls = theMesh->NbBalls(); long total = 0; if ( nbOdElems > 0 ) { @@ -4737,7 +4755,7 @@ void SMESHGUI::contextMenuPopup( const QString& client, QMenu* menu, QString& ti _PTR(Study) study = appStudy->studyDS(); _PTR(SObject) obj = study->FindObjectID( io->getEntry() ); if ( obj ) { - QString aName = QString( obj->GetName().c_str() ); + QString aName = QString( QString::fromUtf8(obj->GetName().c_str()) ); while ( aName.at( aName.length() - 1 ) == ' ' ) // Remove extraspaces in Name of Popup aName.remove( (aName.length() - 1), 1 ); title = aName; @@ -4753,6 +4771,7 @@ LightApp_Selection* SMESHGUI::createSelection() const void SMESHGUI::windows( QMap& aMap ) const { aMap.insert( SalomeApp_Application::WT_ObjectBrowser, Qt::LeftDockWidgetArea ); + aMap.insert( SalomeApp_Application::WT_NoteBook, Qt::LeftDockWidgetArea ); aMap.insert( SalomeApp_Application::WT_PyConsole, Qt::BottomDockWidgetArea ); } @@ -5033,6 +5052,8 @@ void SMESHGUI::createPreferences() LightApp_Preferences::IntSpin, "SMESH", "elem0d_size"); int ballSize = addPreference(tr("PREF_BALL_SIZE"), elemGroup, LightApp_Preferences::IntSpin, "SMESH", "ball_elem_size"); + double ballScale = addPreference(tr("PREF_BALL_SCALE"), elemGroup, + LightApp_Preferences::DblSpin, "SMESH", "ball_elem_scale"); int elemW = addPreference(tr("PREF_WIDTH"), elemGroup, LightApp_Preferences::IntSpin, "SMESH", "element_width"); int outW = addPreference(tr("PREF_OUTLINE_WIDTH"), elemGroup, @@ -5046,6 +5067,10 @@ void SMESHGUI::createPreferences() setPreferenceProperty( ballSize, "min", 1 ); setPreferenceProperty( ballSize, "max", 10 ); + setPreferenceProperty( ballScale, "min", 1e-2 ); + setPreferenceProperty( ballScale, "max", 1e7 ); + setPreferenceProperty( ballScale, "step", 0.5 ); + setPreferenceProperty( elemW, "min", 1 ); setPreferenceProperty( elemW, "max", 5 ); @@ -5718,6 +5743,7 @@ void SMESHGUI::storeVisualParameters (int savePoint) sizeStr << QString::number((int)aSmeshActor->Get0DSize()); sizeStr << "ball"; sizeStr << QString::number((int)aSmeshActor->GetBallSize()); + sizeStr << QString::number((double)aSmeshActor->GetBallScale()); sizeStr << "shrink"; sizeStr << QString::number(aSmeshActor->GetShrinkFactor()); sizeStr << "orientation"; @@ -6302,6 +6328,7 @@ void SMESHGUI::restoreVisualParameters (int savePoint) int outlineWidth = -1; int elem0dSize = -1; int ballSize = -1; + double ballScale = -1.0; double shrinkSize = -1; double orientationSize = -1; bool orientation3d = false; @@ -6329,11 +6356,16 @@ void SMESHGUI::restoreVisualParameters (int savePoint) i++; } else if ( type == "ball" ) { - // ball size is given as single integer value - if ( i+1 >= sizes.count() ) break; // format error - int v = sizes[i+1].toInt( &bOk ); if ( !bOk ) break; // format error - ballSize = v; - i++; + // balls are specified by two values: size:scale, where + // - size - is a integer value specifying size + // - scale - is a double value specifying scale factor + if ( i+1 >= sizes.count() ) break; // format error + int v1 = sizes[i+1].toInt( &bOk ); if ( !bOk ) break; // format error + if ( i+2 >= sizes.count() ) break; // format error + double v2 = sizes[i+2].toDouble( &bOk ); if ( !bOk ) break; // format error + ballSize = v1; + ballScale = v2; + i += 2; } else if ( type == "shrink" ) { // shrink factor is given as single floating point value @@ -6369,6 +6401,9 @@ void SMESHGUI::restoreVisualParameters (int savePoint) // ball size if ( ballSize > 0 ) aSmeshActor->SetBallSize( ballSize ); + // ball scale + if ( ballScale > 0.0 ) + aSmeshActor->SetBallScale( ballScale ); // shrink factor if ( shrinkSize > 0 ) aSmeshActor->SetShrinkFactor( shrinkSize ); @@ -6700,7 +6735,7 @@ void SMESHGUI::message( const QString& msg ) _PTR(SObject) obj = study->FindObjectID( entry.toLatin1().constData() ); QString name; if ( obj ) - name = obj->GetName().c_str(); + name = QString::fromUtf8(obj->GetName().c_str()); if ( name.isEmpty() ) return;