Back to index

salome-smesh  6.5.0
Classes | Defines | Typedefs | Functions | Variables
SMESHGUI.cxx File Reference
#include <Standard_math.hxx>
#include "Python.h"
#include "SMESHGUI.h"
#include "SMESHGUI_AddMeshElementDlg.h"
#include "SMESHGUI_AddQuadraticElementDlg.h"
#include "SMESHGUI_BuildCompoundDlg.h"
#include "SMESHGUI_ClippingDlg.h"
#include "SMESHGUI_ComputeDlg.h"
#include "SMESHGUI_ConvToQuadOp.h"
#include "SMESHGUI_CreatePolyhedralVolumeDlg.h"
#include "SMESHGUI_DeleteGroupDlg.h"
#include "SMESHGUI_Displayer.h"
#include "SMESHGUI_MergeDlg.h"
#include "SMESHGUI_ExtrusionAlongPathDlg.h"
#include "SMESHGUI_ExtrusionDlg.h"
#include "SMESHGUI_FileInfoDlg.h"
#include "SMESHGUI_FileValidator.h"
#include "SMESHGUI_FilterDlg.h"
#include "SMESHGUI_FilterLibraryDlg.h"
#include "SMESHGUI_FindElemByPointDlg.h"
#include "SMESHGUI_GroupDlg.h"
#include "SMESHGUI_GroupOnShapeDlg.h"
#include "SMESHGUI_GroupOpDlg.h"
#include "SMESHGUI_Hypotheses.h"
#include "SMESHGUI_Make2DFrom3DOp.h"
#include "SMESHGUI_MakeNodeAtPointDlg.h"
#include "SMESHGUI_Measurements.h"
#include "SMESHGUI_MeshInfo.h"
#include "SMESHGUI_MeshOp.h"
#include "SMESHGUI_MeshOrderOp.h"
#include "SMESHGUI_MeshPatternDlg.h"
#include "SMESHGUI_MultiEditDlg.h"
#include "SMESHGUI_NodesDlg.h"
#include "SMESHGUI_Preferences_ColorDlg.h"
#include "SMESHGUI_Preferences_ScalarBarDlg.h"
#include "SMESHGUI_RemoveElementsDlg.h"
#include "SMESHGUI_RemoveNodesDlg.h"
#include "SMESHGUI_RenumberingDlg.h"
#include "SMESHGUI_RevolutionDlg.h"
#include "SMESHGUI_RotationDlg.h"
#include "SMESHGUI_Selection.h"
#include "SMESHGUI_SewingDlg.h"
#include "SMESHGUI_SingleEditDlg.h"
#include "SMESHGUI_SmoothingDlg.h"
#include "SMESHGUI_SymmetryDlg.h"
#include "SMESHGUI_TranslationDlg.h"
#include "SMESHGUI_ScaleDlg.h"
#include "SMESHGUI_TransparencyDlg.h"
#include "SMESHGUI_DuplicateNodesDlg.h"
#include "SMESHGUI_CopyMeshDlg.h"
#include "SMESHGUI_Utils.h"
#include "SMESHGUI_MeshUtils.h"
#include "SMESHGUI_GroupUtils.h"
#include "SMESHGUI_FilterUtils.h"
#include "SMESHGUI_PatternUtils.h"
#include "SMESHGUI_VTKUtils.h"
#include "SMESHGUI_HypothesesUtils.h"
#include <SMESH_version.h>
#include <SMESH_Client.hxx>
#include <SMESH_Actor.h>
#include <SMESH_ScalarBarActor.h>
#include <SMESH_ActorUtils.h>
#include <SMESH_TypeFilter.hxx>
#include "SMESH_ControlsDef.hxx"
#include <SalomeApp_Tools.h>
#include <SalomeApp_Study.h>
#include <SalomeApp_Application.h>
#include <SalomeApp_CheckFileDlg.h>
#include <SalomeApp_DataObject.h>
#include <LightApp_DataOwner.h>
#include <LightApp_Preferences.h>
#include <LightApp_SelectionMgr.h>
#include <LightApp_UpdateFlags.h>
#include <LightApp_NameDlg.h>
#include <SVTK_ViewWindow.h>
#include <SVTK_ViewModel.h>
#include <SVTK_ViewManager.h>
#include <VTKViewer_Algorithm.h>
#include <SUIT_MessageBox.h>
#include <SUIT_ResourceMgr.h>
#include <SUIT_FileDlg.h>
#include <SUIT_Desktop.h>
#include <SUIT_OverrideCursor.h>
#include <SUIT_Session.h>
#include <QtxPopupMgr.h>
#include <QtxFontEdit.h>
#include <SALOME_ListIO.hxx>
#include <SALOME_ListIteratorOfListIO.hxx>
#include <SPlot2d_ViewModel.h>
#include <SPlot2d_Histogram.h>
#include <SALOMEconfig.h>
#include <QApplication>
#include <QMenu>
#include <QTextStream>
#include <boost/shared_ptr.hpp>
#include <vtkCamera.h>
#include <vtkRenderer.h>
#include <vtkPlane.h>
#include <vtkCallbackCommand.h>
#include <vtkLookupTable.h>
#include <SALOMEDS_Study.hxx>
#include <SALOMEDSClient_StudyBuilder.hxx>
#include <SALOMEDSClient_SComponent.hxx>
#include <SALOMEDSClient_ClientFactory.hxx>
#include <SALOMEDSClient_IParameters.hxx>
#include <Standard_ErrorHandler.hxx>
#include <NCollection_DataMap.hxx>

Go to the source code of this file.

Classes

struct  TPlaneData
struct  TPlaneInfo

Defines

#define WITHGENERICOBJ

Typedefs

typedef std::list< TPlaneDataTPlaneDataList
typedef std::map< int,
TPlaneDataList
TPlaneDataMap
typedef std::list< vtkActor * > TActorList
typedef std::list< TPlaneInfoTPlaneInfoList
typedef std::map< int,
TPlaneInfoList
TPlaneInfoMap

Functions

void ImportMeshesFromFile (SMESH::SMESH_Gen_ptr theComponentMesh, int theCommandID)
void ExportMeshToFile (int theCommandID)
 Export selected meshes or groups into a file.
void SetDisplayMode (int theCommandID, SMESHGUI_StudyId2MarkerMap &theMarkerMap)
void SetDisplayEntity (int theCommandID)
void Control (int theCommandID)
void InverseEntityMode (unsigned int &theOutputMode, unsigned int theMode)
void AutoColor ()
QString functorToString (SMESH::Controls::FunctorPtr f)
void SaveDistribution ()
void ShowDistribution ()
void PlotDistribution ()
void DisableAutoColor ()
bool CheckOIType (const Handle(SALOME_InteractiveObject)&theIO, MeshObjectType theType, const QString theInTypeName, QString &theOutTypeName)
QString CheckTypeObject (const Handle(SALOME_InteractiveObject)&theIO)
QString CheckHomogeneousSelection ()
SMESHGUI_EXPORT CAM_Module * createModule ()
SMESHGUI_EXPORT char * getModuleVersion ()
Standard_EXPORT SMESHGUI * GetComponentGUI ()
static int isStudyLocked (_PTR(Study) theStudy)
static bool checkLock (_PTR(Study) theStudy)

Variables

const char gSeparator = '_'
const char gDigitsSep = ':'
const char gPathSep = '|'

Class Documentation

struct TPlaneData

Definition at line 5354 of file SMESHGUI.cxx.

Class Members
vtkFloatingPointType Angle
vtkFloatingPointType Distance
int Id
vtkIdType Orientation
struct TPlaneInfo

Definition at line 5364 of file SMESHGUI.cxx.

Collaboration diagram for TPlaneInfo:
Class Members
TActorList ActorList
int PlaneId
SUIT_ViewManager * ViewManager

Define Documentation

#define WITHGENERICOBJ

Definition at line 169 of file SMESHGUI.cxx.


Typedef Documentation

typedef std::list<vtkActor*> TActorList

Definition at line 5363 of file SMESHGUI.cxx.

typedef std::list<TPlaneData> TPlaneDataList

Definition at line 5360 of file SMESHGUI.cxx.

typedef std::map<int, TPlaneDataList> TPlaneDataMap

Definition at line 5361 of file SMESHGUI.cxx.

typedef std::list<TPlaneInfo> TPlaneInfoList

Definition at line 5369 of file SMESHGUI.cxx.

typedef std::map<int, TPlaneInfoList> TPlaneInfoMap

Definition at line 5370 of file SMESHGUI.cxx.


Function Documentation

void AutoColor ( )

Definition at line 789 of file SMESHGUI.cxx.

                  {
    SALOME_ListIO selected;
    SalomeApp_Application* app = dynamic_cast< SalomeApp_Application* >( SUIT_Session::session()->activeApplication() );
    if( !app )
      return;

    LightApp_SelectionMgr* aSel = app->selectionMgr();
    SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( app->activeStudy() );
    if( !aSel || !appStudy )
      return;

    aSel->selectedObjects( selected );
    if( selected.IsEmpty() )
      return;

    Handle(SALOME_InteractiveObject) anIObject = selected.First();

    _PTR(Study) aStudy = appStudy->studyDS();
    _PTR(SObject) aMainSObject( aStudy->FindObjectID( anIObject->getEntry() ) );
    SMESH::SMESH_Mesh_var aMainObject = SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(anIObject);
    if( aMainObject->_is_nil() )
      return;

    aMainObject->SetAutoColor( true ); // mesh groups are re-colored here

    SMESH::ListOfGroups aListOfGroups = *aMainObject->GetGroups();
    for( int i = 0, n = aListOfGroups.length(); i < n; i++ )
    {
      SMESH::SMESH_GroupBase_var aGroupObject = aListOfGroups[i];
      SALOMEDS::Color aColor = aGroupObject->GetColor();
      _PTR(SObject) aGroupSObject = SMESH::FindSObject(aGroupObject);
      if (aGroupSObject) {
        if(SMESH_Actor *anActor = SMESH::FindActorByEntry(aGroupSObject->GetID().c_str())) {
          if( aGroupObject->GetType() == SMESH::NODE )
            anActor->SetNodeColor( aColor.R, aColor.G, aColor.B );
          else if( aGroupObject->GetType() == SMESH::EDGE )
            anActor->SetEdgeColor( aColor.R, aColor.G, aColor.B );
          else if( aGroupObject->GetType() == SMESH::ELEM0D )
            anActor->Set0DColor( aColor.R, aColor.G, aColor.B );
          else {
            QColor c;
            int delta;
            SMESH::GetColor("SMESH", "fill_color", c, delta, "0,170,255|-100");
            anActor->SetSufaceColor( aColor.R, aColor.G, aColor.B, delta );
          }
        }
      }
    }

    SMESH::RepaintCurrentView();
  }

Here is the call graph for this function:

Definition at line 1500 of file SMESHGUI.cxx.

  {
    //SUIT_Study* aStudy = SMESH::GetActiveStudy();
    LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
    SALOME_ListIO selected;
    if( aSel )
      aSel->selectedObjects( selected );

    QString RefType = CheckTypeObject(selected.First());
    SALOME_ListIteratorOfListIO It(selected);
    for ( ; It.More(); It.Next())
      {
        Handle(SALOME_InteractiveObject) IObject = It.Value();
        QString Type = CheckTypeObject(IObject);
        if (Type.compare(RefType) != 0)
          return "Heterogeneous Selection";
      }

    return RefType;
  }

Here is the call graph for this function:

static bool checkLock ( _PTR(Study)  theStudy) [static]

Definition at line 2008 of file SMESHGUI.cxx.

                                            {
  if (isStudyLocked(theStudy)) {
    SUIT_MessageBox::warning( SMESHGUI::desktop(),
                              QObject::tr("WRN_WARNING"),
                              QObject::tr("WRN_STUDY_LOCKED") );
    return true;
  }
  return false;
}

Here is the call graph for this function:

bool CheckOIType ( const Handle(SALOME_InteractiveObject)&  theIO,
MeshObjectType  theType,
const QString  theInTypeName,
QString &  theOutTypeName 
)

Definition at line 1455 of file SMESHGUI.cxx.

  {
    SMESH_TypeFilter aTypeFilter( theType );
    QString entry;
    if( !theIO.IsNull() )
    {
      entry = theIO->getEntry();
      LightApp_DataOwner owner( entry );
      if ( aTypeFilter.isOk( &owner )) {
        theOutTypeName = theInTypeName;
        return true;
      }
    }
    return false;
  }

Here is the caller graph for this function:

QString CheckTypeObject ( const Handle(SALOME_InteractiveObject)&  theIO)

Definition at line 1475 of file SMESHGUI.cxx.

  {
    _PTR(Study) aStudy = SMESH::GetActiveStudyDocument();
    _PTR(SObject) aSObj = aStudy->FindObjectID(theIO->getEntry());
    if (aSObj) {
      _PTR(SComponent) aSComp = aSObj->GetFatherComponent();
      CORBA::String_var anID = aSComp->GetID().c_str();
      if (!strcmp(anID.in(),theIO->getEntry()))
        return "Component";
    }

    QString aTypeName;
    if (
        CheckOIType ( theIO, HYPOTHESIS,    "Hypothesis", aTypeName ) ||
        CheckOIType ( theIO, ALGORITHM,     "Algorithm",  aTypeName ) ||
        CheckOIType ( theIO, MESH,          "Mesh",       aTypeName ) ||
        CheckOIType ( theIO, SUBMESH,       "SubMesh",    aTypeName ) ||
        CheckOIType ( theIO, GROUP,         "Group",      aTypeName )
        )
      return aTypeName;

    return "NoType";
  }

Here is the call graph for this function:

Here is the caller graph for this function:

void Control ( int  theCommandID)

Definition at line 1342 of file SMESHGUI.cxx.

  {
    LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
    SALOME_ListIO selected;
    if( aSel )
      aSel->selectedObjects( selected );

    if( !selected.IsEmpty() ){
      Handle(SALOME_InteractiveObject) anIO = selected.First();
      if(!anIO.IsNull()){
        SMESH_Actor::eControl aControl = SMESH_Actor::eNone;
        if(SMESH_Actor *anActor = SMESH::FindActorByEntry(anIO->getEntry())) {
          switch ( theCommandID ){
          case 6001:
            aControl = SMESH_Actor::eLength;
            break;
          case 6018:
            aControl = SMESH_Actor::eLength2D;
            break;
          case 6002:
            aControl = SMESH_Actor::eFreeEdges;
            break;
          case 6003:
            aControl = SMESH_Actor::eFreeBorders;
            break;
          case 6004:
            aControl = SMESH_Actor::eMultiConnection;
            break;
          case 6005:
            aControl = SMESH_Actor::eFreeNodes;
            break;
          case 6019:
            aControl = SMESH_Actor::eMultiConnection2D;
            break;
          case 6011:
            aControl = SMESH_Actor::eArea;
            break;
          case 6012:
            aControl = SMESH_Actor::eTaper;
            break;
          case 6013:
            aControl = SMESH_Actor::eAspectRatio;
            break;
          case 6017:
            aControl = SMESH_Actor::eAspectRatio3D;
            break;
          case 6014:
            aControl = SMESH_Actor::eMinimumAngle;
            break;
          case 6015:
            aControl = SMESH_Actor::eWarping;
            break;
          case 6016:
            aControl = SMESH_Actor::eSkew;
            break;
          case 6009:
            aControl = SMESH_Actor::eVolume3D;
            break;
          case 6021:
            aControl = SMESH_Actor::eFreeFaces;
            break;
          case 6022:
            aControl = SMESH_Actor::eMaxElementLength2D;
            break;
          case 6023:
            aControl = SMESH_Actor::eMaxElementLength3D;
            break;
          case 6024:
            aControl = SMESH_Actor::eBareBorderVolume;
            break;
          case 6025:
            aControl = SMESH_Actor::eBareBorderFace;
            break;
          case 6026:
            aControl = SMESH_Actor::eOverConstrainedVolume;
            break;
          case 6027:
            aControl = SMESH_Actor::eOverConstrainedFace;
            break;
          case 6028:
            aControl = SMESH_Actor::eCoincidentNodes;
            break;
          case 6029:
            aControl = SMESH_Actor::eCoincidentElems1D;
            break;
          case 6030:
            aControl = SMESH_Actor:: eCoincidentElems2D;
            break;
          case 6031:
            aControl = SMESH_Actor::eCoincidentElems3D;
            break;
          }
            
          anActor->SetControlMode(aControl);
          anActor->GetScalarBarActor()->SetTitle( functorToString( anActor->GetFunctor() ).toLatin1().constData() );
          SMESH::RepaintCurrentView();
#ifndef DISABLE_PLOT2DVIEWER
          if(anActor->GetPlot2Histogram()) {
            SPlot2d_Histogram* aHistogram = anActor->UpdatePlot2Histogram();
            QString functorName = functorToString( anActor->GetFunctor());
            QString aHistogramName("%1 : %2");
            aHistogramName = aHistogramName.arg(anIO->getName()).arg(functorName);
            aHistogram->setName(aHistogramName);
            aHistogram->setHorTitle(functorName);
            SMESH::ProcessIn2DViewers(anActor);
          }
#endif
        }
      }
    }
  }

Here is the call graph for this function:

SMESHGUI_EXPORT CAM_Module* createModule ( )

Definition at line 1702 of file SMESHGUI.cxx.

  {
    return new SMESHGUI();
  }
void DisableAutoColor ( )

Definition at line 1034 of file SMESHGUI.cxx.

                         {
    LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
    SALOME_ListIO selected;
    if( aSel )
      aSel->selectedObjects( selected );

    if(selected.Extent()){
      Handle(SALOME_InteractiveObject) anIObject = selected.First();
      SMESH::SMESH_Mesh_var aMesh = SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(anIObject);
      if ( !aMesh->_is_nil() ) {
        aMesh->SetAutoColor( false );
      }
    }
  }

Here is the call graph for this function:

void ExportMeshToFile ( int  theCommandID)

Export selected meshes or groups into a file.

Definition at line 357 of file SMESHGUI.cxx.

  {
    LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
    SALOME_ListIO selected;
    if( aSel )
      aSel->selectedObjects( selected );

    const bool isMED = ( theCommandID == 122 || theCommandID == 125 );
    const bool isDAT = ( theCommandID == 121 || theCommandID == 124 );
    const bool isUNV = ( theCommandID == 123 || theCommandID == 126 );
    const bool isSTL = ( theCommandID == 140 || theCommandID == 141 );
    const bool isCGNS= ( theCommandID == 142 || theCommandID == 143 );
    const bool isSAUV= ( theCommandID == 144 || theCommandID == 145 );

    // actually, the following condition can't be met (added for insurance)
    if( selected.Extent() == 0 ||
        ( selected.Extent() > 1 && !isMED && !isSTL ))
      return;

    // get mesh object from selection and check duplication of their names
    bool hasDuplicatedMeshNames = false;
    QList< QPair< SMESH::SMESH_IDSource_var, QString > > aMeshList;
    QList< QPair< SMESH::SMESH_IDSource_var, QString > >::iterator aMeshIter;
    SALOME_ListIteratorOfListIO It( selected );
    for( ; It.More(); It.Next() )
    {
      Handle(SALOME_InteractiveObject) anIObject = It.Value();
      SMESH::SMESH_IDSource_var aMeshItem = SMESH::IObjectToInterface<SMESH::SMESH_IDSource>(anIObject);
      if ( aMeshItem->_is_nil() ) {
        SUIT_MessageBox::warning( SMESHGUI::desktop(),
                                  QObject::tr( "SMESH_WRN_WARNING" ),
                                  QObject::tr( "SMESH_BAD_MESH_SELECTION" ));
        return;
      }

      QString aMeshName = anIObject->getName();

      // check for name duplications
      if ( !hasDuplicatedMeshNames )
        for( aMeshIter = aMeshList.begin(); aMeshIter != aMeshList.end(); aMeshIter++ ) {
          if( aMeshName == (*aMeshIter).second ) {
            hasDuplicatedMeshNames = true;
            break;
          }
        }

      aMeshList.append( QPair< SMESH::SMESH_IDSource_var, QString >( aMeshItem, aMeshName ) );
    }

    if( hasDuplicatedMeshNames && isMED ) {
      int aRet = SUIT_MessageBox::warning(SMESHGUI::desktop(),
                                          QObject::tr("SMESH_WRN_WARNING"),
                                          QObject::tr("SMESH_EXPORT_MED_DUPLICATED_MESH_NAMES"),
                                          QObject::tr("SMESH_BUT_YES"),
                                          QObject::tr("SMESH_BUT_NO"), 0, 1);
      if (aRet != 0)
        return;
    }

    aMeshIter = aMeshList.begin();
    SMESH::SMESH_IDSource_var aMeshOrGroup = (*aMeshIter).first;
    SMESH::SMESH_Mesh_var aMesh = aMeshOrGroup->GetMesh();
    QString aMeshName = (*aMeshIter).second;

    if ( isMED || isCGNS || isSAUV )
    {
      // check for equal group names within each mesh
      for( aMeshIter = aMeshList.begin(); aMeshIter != aMeshList.end(); aMeshIter++ ) {
        SMESH::SMESH_Mesh_var aMeshItem = SMESH::SMESH_Mesh::_narrow( (*aMeshIter).first );
        if ( !aMeshItem->_is_nil() && aMeshItem->HasDuplicatedGroupNamesMED()) {
          int aRet = SUIT_MessageBox::warning
            (SMESHGUI::desktop(),
             QObject::tr("SMESH_WRN_WARNING"),
             QObject::tr("SMESH_EXPORT_MED_DUPLICATED_GRP").arg((*aMeshIter).second),
             QObject::tr("SMESH_BUT_YES"),
             QObject::tr("SMESH_BUT_NO"), 0, 1);
          if (aRet != 0)
            return;
        }
      }
    }
    else if ( isUNV )
    {
      // warn the user about presence of not supported elements
      SMESH::long_array_var nbElems = aMeshOrGroup->GetMeshInfo();
      int nbNotSupported = ( nbElems[ SMESH::Entity_Pyramid ] +
                             nbElems[ SMESH::Entity_Quad_Pyramid ] +
                             nbElems[ SMESH::Entity_Hexagonal_Prism ] +
                             nbElems[ SMESH::Entity_Polygon ] +
                             nbElems[ SMESH::Entity_Polyhedra ] );
      if ( nbNotSupported > 0 ) {
        int aRet = SUIT_MessageBox::warning
          (SMESHGUI::desktop(),
           QObject::tr("SMESH_WRN_WARNING"),
           QObject::tr("SMESH_EXPORT_UNV").arg(aMeshName),
           QObject::tr("SMESH_BUT_YES"),
           QObject::tr("SMESH_BUT_NO"), 0, 1);
        if (aRet != 0)
          return;
      }
    }

    // Get parameters of export operation

    QString aFilename;
    SMESH::MED_VERSION aFormat;
    // Init the parameters with the default values
    bool aIsASCII_STL = true;
    bool toCreateGroups = false;
    SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
    if ( resMgr )
      toCreateGroups = resMgr->booleanValue( "SMESH", "auto_groups", false );
    bool toOverwrite = true;

    QString aFilter, aTitle = QObject::tr("SMESH_EXPORT_MESH");
    QString anInitialPath = "";
    if ( SUIT_FileDlg::getLastVisitedPath().isEmpty() )
      anInitialPath = QDir::currentPath();

    if ( isUNV || isDAT )
    {
      if ( isUNV )
        aFilter = QObject::tr( "IDEAS_FILES_FILTER" ) + " (*.unv)";
      else
        aFilter = QObject::tr( "DAT_FILES_FILTER" ) + " (*.dat)";
      if ( anInitialPath.isEmpty() ) anInitialPath = SUIT_FileDlg::getLastVisitedPath();
      aFilename = SUIT_FileDlg::getFileName(SMESHGUI::desktop(),
                                            anInitialPath + QString("/") + aMeshName,
                                            aFilter, aTitle, false);
    }
    else if ( isCGNS )// Export to CGNS
    {
      SUIT_FileDlg* fd = new SUIT_FileDlg( SMESHGUI::desktop(), false, true, true );
      fd->setWindowTitle( aTitle );
      fd->setNameFilter( QObject::tr( "CGNS_FILES_FILTER" ) + " (*.cgns)" );
      if ( !anInitialPath.isEmpty() )
        fd->setDirectory( anInitialPath );
      fd->selectFile(aMeshName);
      SMESHGUI_FileValidator* fv = new SMESHGUI_FileValidator( fd );
      fd->setValidator( fv );

      if ( fd->exec() )
        aFilename = fd->selectedFile();
      toOverwrite = fv->isOverwrite();

      delete fd;
    }
    else if ( isSTL ) // Export to STL
    {
      QMap<QString, int> aFilterMap;
      aFilterMap.insert( QObject::tr( "STL_ASCII_FILES_FILTER" ) + " (*.stl)", 1 );
      aFilterMap.insert( QObject::tr( "STL_BIN_FILES_FILTER" )   + " (*.stl)", 0 );

      QStringList filters;
      QMap<QString, int>::const_iterator it = aFilterMap.begin();
      for ( ; it != aFilterMap.end(); ++it )
        filters.push_back( it.key() );

      SUIT_FileDlg* fd = new SUIT_FileDlg( SMESHGUI::desktop(), false, true, true );
      fd->setWindowTitle( aTitle );
      fd->setNameFilters( filters );
      fd->selectNameFilter( QObject::tr( "STL_ASCII_FILES_FILTER" ) + " (*.stl)" );
      if ( !anInitialPath.isEmpty() )
        fd->setDirectory( anInitialPath );
      fd->selectFile(aMeshName);
      bool is_ok = false;
      while (!is_ok) {
        if ( fd->exec() )
          aFilename = fd->selectedFile();
        aIsASCII_STL = (aFilterMap[fd->selectedNameFilter()]) == 1 ? true: false;
        is_ok = true;
      }
      delete fd;
    }
    else if ( isMED || isSAUV ) // Export to MED or SAUV
    {
      QMap<QString, SMESH::MED_VERSION> aFilterMap;
      //QString v21 (aMesh->GetVersionString(SMESH::MED_V2_1, 2));
      if ( isMED ) {
        QString v22 (aMesh->GetVersionString(SMESH::MED_V2_2, 2));
        //aFilterMap.insert( QObject::tr( "MED_VX_FILES_FILTER" ).arg( v21 ) + " (*.med)", SMESH::MED_V2_1 );
        aFilterMap.insert( QObject::tr( "MED_VX_FILES_FILTER" ).arg( v22 ) + " (*.med)", SMESH::MED_V2_2 );
      }
      else { // isSAUV
        aFilterMap.insert("All files (*)", SMESH::MED_V2_1 );
        aFilterMap.insert("SAUV files (*.sauv)", SMESH::MED_V2_2 );
        aFilterMap.insert("SAUV files (*.sauve)", SMESH::MED_V2_1 );
      }

      QStringList filters;
      QString aDefaultFilter;
      QMap<QString, SMESH::MED_VERSION>::const_iterator it = aFilterMap.begin();
      for ( ; it != aFilterMap.end(); ++it ) {
        filters.push_back( it.key() );
        if (it.value() == SMESH::MED_V2_2)
          aDefaultFilter = it.key();
      }

      SalomeApp_CheckFileDlg* fd = new SalomeApp_CheckFileDlg
        ( SMESHGUI::desktop(), false, QObject::tr("SMESH_AUTO_GROUPS"), true, true );
      fd->setWindowTitle( aTitle );
      fd->setNameFilters( filters );
      fd->selectNameFilter(aDefaultFilter);
      fd->SetChecked(toCreateGroups);
      if ( !anInitialPath.isEmpty() )
        fd->setDirectory( anInitialPath );
      fd->selectFile(aMeshName);

      SMESHGUI_FileValidator* fv = new SMESHGUI_FileValidator( fd );
      fd->setValidator( fv );

      bool is_ok = false;
      while (!is_ok) {
        if ( fd->exec() )
          aFilename = fd->selectedFile();
        else {
          aFilename = QString::null;
          break;
        }
        aFormat = aFilterMap[fd->selectedNameFilter()];
        toOverwrite = fv->isOverwrite();
        is_ok = true;
        if ( !aFilename.isEmpty() ) {
          // med-2.1 does not support poly elements
          if ( aFormat==SMESH::MED_V2_1 )
            for( aMeshIter = aMeshList.begin(); aMeshIter != aMeshList.end(); aMeshIter++ ) {
              SMESH::SMESH_IDSource_var aMeshItem = (*aMeshIter).first;
              SMESH::long_array_var nbElems = aMeshItem->GetMeshInfo();
              if ( nbElems[ SMESH::Entity_Polygon   ] + nbElems[ SMESH::Entity_Quad_Polygon   ] +
                   nbElems[ SMESH::Entity_Polyhedra ] + nbElems[ SMESH::Entity_Quad_Polyhedra ])
              {
                int aRet = SUIT_MessageBox::warning(SMESHGUI::desktop(),
                                                    QObject::tr("SMESH_WRN_WARNING"),
                                                    QObject::tr("SMESH_EXPORT_MED_V2_1").arg((*aMeshIter).second),
                                                    QObject::tr("SMESH_BUT_YES"),
                                                    QObject::tr("SMESH_BUT_NO"), 0, 1);
                if (aRet != 0) {
                  is_ok = false;
                  break;
                }
              }
            }
          if( !toOverwrite ) {
            // can't append to an existing using other format
            SMESH::MED_VERSION aVersion = SMESH::MED_V2_1;
            bool isVersionOk = SMESHGUI::GetSMESHGen()->GetMEDVersion( aFilename.toLatin1().constData(), aVersion );
            if( !isVersionOk || aVersion != aFormat ) {
              int aRet = SUIT_MessageBox::warning(SMESHGUI::desktop(),
                                                  QObject::tr("SMESH_WRN_WARNING"),
                                                  QObject::tr("SMESH_EXPORT_MED_VERSION_COLLISION").arg(aFilename),
                                                  QObject::tr("SMESH_BUT_YES"),
                                                  QObject::tr("SMESH_BUT_NO"), 0, 1);
              if (aRet == 0)
                toOverwrite = true;
              else
                is_ok = false;
            }

            QStringList aMeshNamesCollisionList;
            SMESH::string_array_var aMeshNames = SMESHGUI::GetSMESHGen()->GetMeshNames( aFilename.toLatin1().constData() );
            for( int i = 0, n = aMeshNames->length(); i < n; i++ ) {
              QString anExistingMeshName( aMeshNames[ i ] );
              for( aMeshIter = aMeshList.begin(); aMeshIter != aMeshList.end(); aMeshIter++ ) {
                QString anExportMeshName = (*aMeshIter).second;
                if( anExportMeshName == anExistingMeshName ) {
                  aMeshNamesCollisionList.append( anExportMeshName );
                  break;
                }
              }
            }
            if( !aMeshNamesCollisionList.isEmpty() ) {
              QString aMeshNamesCollisionString = aMeshNamesCollisionList.join( ", " );
              int aRet = SUIT_MessageBox::warning(SMESHGUI::desktop(),
                                                  QObject::tr("SMESH_WRN_WARNING"),
                                                  QObject::tr("SMESH_EXPORT_MED_MESH_NAMES_COLLISION").arg(aMeshNamesCollisionString),
                                                  QObject::tr("SMESH_BUT_YES"),
                                                  QObject::tr("SMESH_BUT_NO"),
                                                  QObject::tr("SMESH_BUT_CANCEL"), 0, 2);
              if (aRet == 0)
                toOverwrite = true;
              else if (aRet == 2)
                is_ok = false;
            }
          }
        }
      }
      toCreateGroups = fd->IsChecked();
      delete fd;
    }
    else
    {
      return;
    }

    // Perform export

    if ( !aFilename.isEmpty() ) {
      // Check whether the file already exists and delete it if yes
      QFile aFile( aFilename );
      if ( aFile.exists() && toOverwrite )
        aFile.remove();
      SUIT_OverrideCursor wc;

      try {
        // Renumbering is not needed since SMDS redesign in V6.2.0 (Nov 2010)
//         bool Renumber = false;
//         // PAL 14172  : Check of we have to renumber or not from the preferences before export
//         if (resMgr)
//           Renumber= resMgr->booleanValue("SMESH","renumbering");
//         if (Renumber){
//           SMESH::SMESH_MeshEditor_var aMeshEditor = aMesh->GetMeshEditor();
//           aMeshEditor->RenumberNodes();
//           aMeshEditor->RenumberElements();
//           if ( SMESHGUI::automaticUpdate() )
//             SMESH::UpdateView();
//         }
        if ( isMED )
        {
          aMeshIter = aMeshList.begin();
          for( int aMeshIndex = 0; aMeshIter != aMeshList.end(); aMeshIter++, aMeshIndex++ )
          {
            SMESH::SMESH_IDSource_var aMeshOrGroup = (*aMeshIter).first;
            SMESH::SMESH_Mesh_var        aMeshItem = aMeshOrGroup->GetMesh();
            if ( aMeshOrGroup->_is_equivalent( aMeshItem ))
              aMeshItem->ExportToMEDX( aFilename.toLatin1().data(), toCreateGroups,
                                       aFormat, toOverwrite && aMeshIndex == 0 );
            else
              aMeshItem->ExportPartToMED( aMeshOrGroup, aFilename.toLatin1().data(), toCreateGroups,
                                          aFormat, toOverwrite && aMeshIndex == 0 );
          }
        }
        else if ( isSAUV )
        {
          for( aMeshIter = aMeshList.begin(); aMeshIter != aMeshList.end(); aMeshIter++ )
          {
            SMESH::SMESH_Mesh_var aMeshItem = SMESH::SMESH_Mesh::_narrow( (*aMeshIter).first );
            if( !aMeshItem->_is_nil() )
              aMeshItem->ExportSAUV( aFilename.toLatin1().data(), toCreateGroups );
          }
        }
        else if ( isDAT )
        {
          if ( aMeshOrGroup->_is_equivalent( aMesh ))
            aMesh->ExportDAT( aFilename.toLatin1().data() );
          else
            aMesh->ExportPartToDAT( aMeshOrGroup, aFilename.toLatin1().data() );
        }
        else if ( isUNV )
        {
          if ( aMeshOrGroup->_is_equivalent( aMesh ))
            aMesh->ExportUNV( aFilename.toLatin1().data() );
          else
            aMesh->ExportPartToUNV( aMeshOrGroup, aFilename.toLatin1().data() );
        }
        else if ( isSTL )
        {
          if ( aMeshOrGroup->_is_equivalent( aMesh ))
            aMesh->ExportSTL( aFilename.toLatin1().data(), aIsASCII_STL );
          else
            aMesh->ExportPartToSTL( aMeshOrGroup, aFilename.toLatin1().data(), aIsASCII_STL );
        }
        else if ( isCGNS )
        {
          aMeshIter = aMeshList.begin();
          for( int aMeshIndex = 0; aMeshIter != aMeshList.end(); aMeshIter++, aMeshIndex++ )
          {
            SMESH::SMESH_IDSource_var aMeshOrGroup = (*aMeshIter).first;
            SMESH::SMESH_Mesh_var        aMeshItem = aMeshOrGroup->GetMesh();
            aMeshItem->ExportCGNS( aMeshOrGroup,
                                   aFilename.toLatin1().data(),
                                   toOverwrite && aMeshIndex == 0 );
          }
        }
      }
      catch (const SALOME::SALOME_Exception& S_ex){
        wc.suspend();
        SUIT_MessageBox::warning(SMESHGUI::desktop(),
                                 QObject::tr("SMESH_WRN_WARNING"),
                                 QObject::tr("SMESH_EXPORT_FAILED"));
        wc.resume();
      }
    }
  }

Here is the call graph for this function:

Definition at line 841 of file SMESHGUI.cxx.

  {
    QString type = QObject::tr( "UNKNOWN_CONTROL" );
    if ( dynamic_cast< SMESH::Controls::Volume* >( f.get() ) )
      type = QObject::tr( "VOLUME_3D_ELEMENTS" );
    else if ( dynamic_cast< SMESH::Controls::MaxElementLength2D* >( f.get() ) )
      type = QObject::tr( "MAX_ELEMENT_LENGTH_2D" );
    else if ( dynamic_cast< SMESH::Controls::MaxElementLength3D* >( f.get() ) )
      type = QObject::tr( "MAX_ELEMENT_LENGTH_3D" );
    else if ( dynamic_cast< SMESH::Controls::MinimumAngle* >( f.get() ) )
      type = QObject::tr( "MINIMUMANGLE_ELEMENTS" );
    else if ( dynamic_cast< SMESH::Controls::AspectRatio* >( f.get() ) )
      type = QObject::tr( "ASPECTRATIO_ELEMENTS" );
    else if ( dynamic_cast< SMESH::Controls::AspectRatio3D* >( f.get() ) )
      type = QObject::tr( "ASPECTRATIO_3D_ELEMENTS" );
    else if ( dynamic_cast< SMESH::Controls::Warping* >( f.get() ) )
      type = QObject::tr( "WARP_ELEMENTS" );
    else if ( dynamic_cast< SMESH::Controls::Taper* >( f.get() ) )
      type = QObject::tr( "TAPER_ELEMENTS" );
    else if ( dynamic_cast< SMESH::Controls::Skew* >( f.get() ) )
      type = QObject::tr( "SKEW_ELEMENTS" );
    else if ( dynamic_cast< SMESH::Controls::Area* >( f.get() ) )
      type = QObject::tr( "AREA_ELEMENTS" );
    else if ( dynamic_cast< SMESH::Controls::Length* >( f.get() ) )
      type = QObject::tr( "LENGTH_EDGES" );
    else if ( dynamic_cast< SMESH::Controls::Length2D* >( f.get() ) )
      type = QObject::tr( "LENGTH2D_EDGES" );
    else if ( dynamic_cast< SMESH::Controls::MultiConnection* >( f.get() ) )
      type = QObject::tr( "MULTI_BORDERS" );
    else if ( dynamic_cast< SMESH::Controls::MultiConnection2D* >( f.get() ) )
      type = QObject::tr( "MULTI2D_BORDERS" );
    else if ( dynamic_cast< SMESH::Controls::FreeNodes* >( f.get() ) )
      type = QObject::tr( "FREE_NODES" );
    else if ( dynamic_cast< SMESH::Controls::FreeEdges* >( f.get() ) )
      type = QObject::tr( "FREE_EDGES" );
    else if ( dynamic_cast< SMESH::Controls::FreeBorders* >( f.get() ) )
      type = QObject::tr( "FREE_BORDERS" );
    else if ( dynamic_cast< SMESH::Controls::FreeFaces* >( f.get() ) )
      type = QObject::tr( "FREE_FACES" );
    else if ( dynamic_cast< SMESH::Controls::BareBorderVolume* >( f.get() ) )
      type = QObject::tr( "BARE_BORDER_VOLUME" );
    else if ( dynamic_cast< SMESH::Controls::BareBorderFace* >( f.get() ) )
      type = QObject::tr( "BARE_BORDER_FACE" );
    else if ( dynamic_cast< SMESH::Controls::OverConstrainedVolume* >( f.get() ) )
      type = QObject::tr( "OVER_CONSTRAINED_VOLUME" );
    else if ( dynamic_cast< SMESH::Controls::OverConstrainedFace* >( f.get() ) )
      type = QObject::tr( "OVER_CONSTRAINED_FACE" );
    else if ( dynamic_cast< SMESH::Controls::CoincidentNodes* >( f.get() ) )
      type = QObject::tr( "EQUAL_NODE" );
    else if ( dynamic_cast< SMESH::Controls::CoincidentElements1D* >( f.get() ) )
      type = QObject::tr( "EQUAL_EDGE" );
    else if ( dynamic_cast< SMESH::Controls::CoincidentElements2D* >( f.get() ) )
      type = QObject::tr( "EQUAL_FACE" );
    else if ( dynamic_cast< SMESH::Controls::CoincidentElements3D* >( f.get() ) )
      type = QObject::tr( "EQUAL_VOLUME" );
    return type;
  }

Here is the caller graph for this function:

Standard_EXPORT SMESHGUI* GetComponentGUI ( )

Definition at line 1852 of file SMESHGUI.cxx.

  {
    return SMESHGUI::GetSMESHGUI();
  }

Definition at line 1707 of file SMESHGUI.cxx.

                                            {
    return (char*)SMESH_VERSION_STR;
  }
void ImportMeshesFromFile ( SMESH::SMESH_Gen_ptr  theComponentMesh,
int  theCommandID 
)

Definition at line 188 of file SMESHGUI.cxx.

  {
    QStringList filter;
    std::string myExtension;

    if ( theCommandID == 113 ) {
      filter.append( QObject::tr( "MED_FILES_FILTER" ) + " (*.med)" );
      filter.append( QObject::tr( "ALL_FILES_FILTER" ) + " (*)" );
    }
    else if ( theCommandID == 112 ) {
      filter.append( QObject::tr( "IDEAS_FILES_FILTER" ) + " (*.unv)" );
    }
    else if ( theCommandID == 111 ) {
      filter.append( QObject::tr( "DAT_FILES_FILTER" ) + " (*.dat)" );
    }
    else if ( theCommandID == 115 ) {
      filter.append( QObject::tr( "STL_ASCII_FILES_FILTER" ) + " (*.stl)" );
    }
    else if ( theCommandID == 116 ) {
      filter.append( QObject::tr( "CGNS_FILES_FILTER" ) + " (*.cgns)" );
    }
    else if ( theCommandID == 117 ) {
      filter.append( QObject::tr( "SAUV files (*.sauv*)" ) );
      filter.append( QObject::tr( "All files (*)" ) );
    }

    QString anInitialPath = "";
    if ( SUIT_FileDlg::getLastVisitedPath().isEmpty() )
      anInitialPath = QDir::currentPath();

    QStringList filenames = SUIT_FileDlg::getOpenFileNames( SMESHGUI::desktop(),
                                                            anInitialPath,
                                                            filter,
                                                            QObject::tr( "SMESH_IMPORT_MESH" ) );
    if ( filenames.count() > 0 ) {
      SUIT_OverrideCursor wc;
      _PTR(Study) aStudy = SMESH::GetActiveStudyDocument();

      QStringList errors;
      QStringList anEntryList;
      bool isEmpty = false;
      for ( QStringList::ConstIterator it = filenames.begin(); it != filenames.end(); ++it ) {
        QString filename = *it;
        SMESH::mesh_array_var aMeshes = new SMESH::mesh_array;
        try {
          switch ( theCommandID ) {
          case 111:
            {
              // DAT format (currently unsupported)
              errors.append( QString( "%1 :\n\t%2" ).arg( filename ).
                             arg( QObject::tr( "SMESH_ERR_NOT_SUPPORTED_FORMAT" ) ) );
              break;
            }
          case 112:
            {
              // UNV format
              aMeshes->length( 1 );
              aMeshes[0] = theComponentMesh->CreateMeshesFromUNV( filename.toLatin1().constData() );
              if ( aMeshes[0]->_is_nil() )
                errors.append( QString( "%1 :\n\t%2" ).arg( filename ).
                               arg( QObject::tr( "SMESH_ERR_UNKNOWN_IMPORT_ERROR" ) ) );
              break;
            }
          case 113:
            {
              // MED format
              SMESH::DriverMED_ReadStatus res;
              aMeshes = theComponentMesh->CreateMeshesFromMED( filename.toLatin1().constData(), res );
              if ( res != SMESH::DRS_OK ) {
                errors.append( QString( "%1 :\n\t%2" ).arg( filename ).
                               arg( QObject::tr( QString( "SMESH_DRS_%1" ).arg( res ).toLatin1().data() ) ) );
              }
              break;
            }
          case 115:
            {
              // STL format
              aMeshes->length( 1 );
              aMeshes[0] = theComponentMesh->CreateMeshesFromSTL( filename.toLatin1().constData() );
              if ( aMeshes[0]->_is_nil() ) {
                errors.append( QString( "%1 :\n\t%2" ).arg( filename ).
                               arg( QObject::tr( "SMESH_ERR_UNKNOWN_IMPORT_ERROR" ) ) );
              }
              break;
            }
          case 116:
            {
              // CGNS format
              SMESH::DriverMED_ReadStatus res;
              aMeshes = theComponentMesh->CreateMeshesFromCGNS( filename.toLatin1().constData(), res );
              if ( res != SMESH::DRS_OK ) {
                errors.append( QString( "%1 :\n\t%2" ).arg( filename ).
                               arg( QObject::tr( QString( "SMESH_DRS_%1" ).arg( res ).toLatin1().data() ) ) );
              }
              break;
            }
          case 117:
            {
              // SAUV format
              SMESH::DriverMED_ReadStatus res;
              aMeshes = theComponentMesh->CreateMeshesFromSAUV( filename.toLatin1().constData(), res );
              if ( res != SMESH::DRS_OK ) {
                errors.append( QString( "%1 :\n\t%2" ).arg( filename ).
                               arg( QObject::tr( QString( "SMESH_DRS_%1" ).arg( res ).toLatin1().data() ) ) );
              }
              break;
            }
          }
        }
        catch ( const SALOME::SALOME_Exception& S_ex ) {
          errors.append( QString( "%1 :\n\t%2" ).arg( filename ).
                         arg( QObject::tr( "SMESH_ERR_UNKNOWN_IMPORT_ERROR" ) ) );
        }

        for ( int i = 0, iEnd = aMeshes->length(); i < iEnd; i++ ) {
          _PTR(SObject) aMeshSO = SMESH::FindSObject( aMeshes[i] );
          if ( aMeshSO ) {
            _PTR(StudyBuilder) aBuilder = aStudy->NewBuilder();
            _PTR(AttributePixMap) aPixmap = aBuilder->FindOrCreateAttribute( aMeshSO, "AttributePixMap" );
            aPixmap->SetPixMap( "ICON_SMESH_TREE_MESH_IMPORTED" );
            if ( theCommandID == 112 ) // mesh names aren't taken from the file for UNV import
              SMESH::SetName( aMeshSO, QFileInfo(filename).fileName() );

            anEntryList.append( aMeshSO->GetID().c_str() );

#ifdef WITHGENERICOBJ
            // obj has been published in study. Its refcount has been incremented.
            // It is safe to decrement its refcount
            // so that it will be destroyed when the entry in study will be removed
            aMeshes[i]->UnRegister();
#endif
          }
          else {
            isEmpty = true;
          }
        }
      }

      // update Object browser
      SMESHGUI::GetSMESHGUI()->updateObjBrowser();

      // browse to the published meshes
      if( LightApp_Application* anApp =
          dynamic_cast<LightApp_Application*>( SUIT_Session::session()->activeApplication() ) )
        anApp->browseObjects( anEntryList );

      // show Error message box if there were errors
      if ( errors.count() > 0 ) {
        SUIT_MessageBox::critical( SMESHGUI::desktop(),
                                   QObject::tr( "SMESH_ERROR" ),
                                   QObject::tr( "SMESH_IMPORT_ERRORS" ) + "\n" + errors.join( "\n" ) );
      }

      // show warning message box, if some imported mesh is empty
      if ( isEmpty ) {
          SUIT_MessageBox::warning( SMESHGUI::desktop(),
                                    QObject::tr( "SMESH_WRN_WARNING" ),
                                    QObject::tr( "SMESH_DRS_SOME_EMPTY" ) );
      }
    }
  }

Here is the call graph for this function:

void InverseEntityMode ( unsigned int &  theOutputMode,
unsigned int  theMode 
) [inline]

Definition at line 741 of file SMESHGUI.cxx.

  {
    bool anIsNotPresent = ~theOutputMode & theMode;
    if(anIsNotPresent)
      theOutputMode |= theMode;
    else
      theOutputMode &= ~theMode;
  }

Here is the caller graph for this function:

static int isStudyLocked ( _PTR(Study)  theStudy) [static]

Definition at line 2004 of file SMESHGUI.cxx.

                                              {
  return theStudy->GetProperties()->IsLocked();
}

Here is the caller graph for this function:

void PlotDistribution ( )

Definition at line 989 of file SMESHGUI.cxx.

                         {
   SalomeApp_Application* app = dynamic_cast< SalomeApp_Application* >( SUIT_Session::session()->activeApplication() );
   if( !app )
     return;

   LightApp_SelectionMgr* aSel = SMESHGUI::selectionMgr();
   SALOME_ListIO selected;
   if ( aSel )
     aSel->selectedObjects( selected );
    
   if ( selected.Extent() == 1 ) {
     Handle(SALOME_InteractiveObject) anIO = selected.First();
     if ( anIO->hasEntry() ) {
       //Find Actor by entry before getting Plot2d viewer,
       //because after call getViewManager( Plot2d_Viewer::Type(), true ) active window is Plot2d Viewer
       SMESH_Actor* anActor = SMESH::FindActorByEntry( anIO->getEntry() );

       SUIT_ViewManager* aViewManager = app->getViewManager( Plot2d_Viewer::Type(), true ); // create if necessary

       if( !aViewManager )
         return;
       
       SPlot2d_Viewer* aView = dynamic_cast<SPlot2d_Viewer*>(aViewManager->getViewModel());
       if ( !aView )
         return;

       Plot2d_ViewFrame* aPlot = aView->getActiveViewFrame();
       if ( !aPlot )
         return;

       if ( anActor && anActor->GetControlMode() != SMESH_Actor::eNone ) {
         SPlot2d_Histogram* aHistogram = anActor->UpdatePlot2Histogram();
         QString functorName = functorToString( anActor->GetFunctor());
         QString aHistogramName("%1 : %2");
         aHistogramName = aHistogramName.arg(anIO->getName()).arg(functorName);
         aHistogram->setName(aHistogramName);
         aHistogram->setHorTitle(functorName);
         aHistogram->setVerTitle(QObject::tr("DISTRIBUTION_NB_ENT"));
         aPlot->displayObject(aHistogram, true);
       }
     }
   }
 }

Here is the call graph for this function:

void SaveDistribution ( )

Definition at line 899 of file SMESHGUI.cxx.

  {
    LightApp_SelectionMgr* aSel = SMESHGUI::selectionMgr();
    SALOME_ListIO selected;
    if ( aSel )
      aSel->selectedObjects( selected );

    if ( selected.Extent() == 1 ) {
      Handle(SALOME_InteractiveObject) anIO = selected.First();
      if ( anIO->hasEntry() ) {
        SMESH_Actor* anActor = SMESH::FindActorByEntry( anIO->getEntry() );
        if ( anActor && anActor->GetScalarBarActor() && anActor->GetControlMode() != SMESH_Actor::eNone ) {
          SMESH_ScalarBarActor* aScalarBarActor = anActor->GetScalarBarActor();
          SMESH::Controls::FunctorPtr aFunctor = anActor->GetFunctor();
          if ( aScalarBarActor && aFunctor ) {
            SMESH::Controls::NumericalFunctor* aNumFun = dynamic_cast<SMESH::Controls::NumericalFunctor*>( aFunctor.get() );
            if ( aNumFun ) {
              std::vector<int> elements;
              SMESH::SMESH_Mesh_var mesh = SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(anIO);
              if ( mesh->_is_nil() ) {
                SMESH::SMESH_IDSource_var idSource =
                  SMESH::IObjectToInterface<SMESH::SMESH_IDSource>(anIO);
                if ( !idSource->_is_nil() )
                {
                  SMESH::long_array_var ids = idSource->GetIDs();
                  elements.resize( ids->length() );
                  for ( unsigned i = 0; i < elements.size(); ++i )
                    elements[i] = ids[i];
                }
              }
              int nbIntervals = aScalarBarActor->GetMaximumNumberOfColors();
              vtkLookupTable* lookupTable =
                static_cast<vtkLookupTable*>(aScalarBarActor->GetLookupTable());
              double * minmax = lookupTable->GetRange();
              std::vector<int>    nbEvents;
              std::vector<double> funValues;
              aNumFun->GetHistogram( nbIntervals, nbEvents, funValues, elements, minmax );
              QString anInitialPath = "";
              if ( SUIT_FileDlg::getLastVisitedPath().isEmpty() )
                anInitialPath = QDir::currentPath();
              QString aMeshName = anIO->getName();
              QStringList filter;
              filter.append( QObject::tr( "TEXT_FILES_FILTER" ) + " (*.txt)" );
              filter.append( QObject::tr( "ALL_FILES_FILTER" ) + " (*)" );
              QString aFilename = anInitialPath + "/" + aMeshName + "_" + 
                functorToString( aFunctor ).toLower().simplified().replace( QRegExp( " |-" ), "_" ) + ".txt";
              aFilename = SUIT_FileDlg::getFileName( SMESHGUI::desktop(),
                                                     aFilename,
                                                     filter,
                                                     QObject::tr( "SMESH_SAVE_DISTRIBUTION" ),
                                                     false );
              if ( !aFilename.isEmpty() ) {
                QFile f( aFilename );
                if ( f.open( QFile::WriteOnly | QFile::Truncate ) ) {
                  QTextStream out( &f );
                  out << "# Mesh: " << aMeshName << endl;
                  out << "# Control: " << functorToString( aFunctor ) << endl;
                  out << "#" << endl;
                  out.setFieldWidth( 10 );
                  for ( int i = 0; i < qMin( nbEvents.size(), funValues.size()-1 ); i++ )
                    out << funValues[i] << "\t" << funValues[i+1] << "\t" << nbEvents[i] << endl;
                  f.close();
                }
              }
            }
          }
        }
      }
    }
  }

Here is the call graph for this function:

void SetDisplayEntity ( int  theCommandID)

Definition at line 751 of file SMESHGUI.cxx.

                                         {
    LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
    SALOME_ListIO selected;
    if( aSel )
      aSel->selectedObjects( selected );

    if(selected.Extent() >= 1){
      SALOME_ListIteratorOfListIO It( selected );
      for( ; It.More(); It.Next()){
        Handle(SALOME_InteractiveObject) IObject = It.Value();
        if(IObject->hasEntry()){
          if(SMESH_Actor *anActor = SMESH::FindActorByEntry(IObject->getEntry())){
            unsigned int aMode = anActor->GetEntityMode();
            switch(theCommandID){
            case 216:
              InverseEntityMode(aMode,SMESH_Actor::e0DElements);
              break;
            case 217:
              InverseEntityMode(aMode,SMESH_Actor::eEdges);
              break;
            case 218:
              InverseEntityMode(aMode,SMESH_Actor::eFaces);
              break;
            case 219:
              InverseEntityMode(aMode,SMESH_Actor::eVolumes);
              break;
            case 220:
              aMode = SMESH_Actor::eAllEntity;
              break;
            }
            if(aMode)
              anActor->SetEntityMode(aMode);
          }
        }
      }
    }
  }

Here is the call graph for this function:

void SetDisplayMode ( int  theCommandID,
SMESHGUI_StudyId2MarkerMap theMarkerMap 
)

Definition at line 1049 of file SMESHGUI.cxx.

                                                                                 {
    SALOME_ListIO selected;
    SalomeApp_Application* app = dynamic_cast< SalomeApp_Application* >( SUIT_Session::session()->activeApplication() );
    if( !app )
      return;

    LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
    SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( app->activeStudy() );
    if( !aSel || !appStudy )
      return;

    if( theCommandID == 1134 ) { // Clipping dialog can be activated without selection
      if( SMESHGUI* aModule = SMESHGUI::GetSMESHGUI() ) {
        aModule->EmitSignalDeactivateDialog();
        if( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( aModule ) )
          (new SMESHGUI_ClippingDlg( aModule, aViewWindow ))->show();
      }
      return;
    }

    _PTR(Study) aStudy = appStudy->studyDS();

    aSel->selectedObjects( selected );

    if(selected.Extent() >= 1){
      switch(theCommandID){
      case 1133:{
        SMESHGUI::GetSMESHGUI()->EmitSignalDeactivateDialog();
        (new SMESHGUI_TransparencyDlg( SMESHGUI::GetSMESHGUI() ))->show();
        return;
      }
      case 1132:{
        QColor c, e, b, n, c0D, o, outl, selection, preselection;
        int delta;
        int size0D = 0;
        int Edgewidth = 0;
        vtkFloatingPointType Shrink = 0.0;
        vtkFloatingPointType faces_orientation_scale = 0.0;
        bool faces_orientation_3dvectors = false;

        VTK::MarkerType aMarkerTypeCurrent = VTK::MT_NONE;
        VTK::MarkerScale aMarkerScaleCurrent = VTK::MS_NONE;
        int aMarkerTextureCurrent = 0;

        SALOME_ListIteratorOfListIO It( selected );
        for( ; It.More(); It.Next()){
          Handle(SALOME_InteractiveObject) IObject = It.Value();
          if(IObject->hasEntry()){
            if(SMESH_Actor *anActor = SMESH::FindActorByEntry(IObject->getEntry())){
              vtkFloatingPointType color[3];
              anActor->GetSufaceColor(color[0], color[1], color[2],delta);
              int c0 = int (color[0] * 255);
              int c1 = int (color[1] * 255);
              int c2 = int (color[2] * 255);
              c.setRgb(c0, c1, c2);

              vtkFloatingPointType edgecolor[3];
              anActor->GetEdgeColor(edgecolor[0], edgecolor[1], edgecolor[2]);
              c0 = int (edgecolor[0] * 255);
              c1 = int (edgecolor[1] * 255);
              c2 = int (edgecolor[2] * 255);
              e.setRgb(c0, c1, c2);

              vtkFloatingPointType nodecolor[3];
              anActor->GetNodeColor(nodecolor[0], nodecolor[1], nodecolor[2]);
              c0 = int (nodecolor[0] * 255);
              c1 = int (nodecolor[1] * 255);
              c2 = int (nodecolor[2] * 255);
              n.setRgb(c0, c1, c2);

              vtkFloatingPointType color0D[3];
              anActor->Get0DColor(color0D[0], color0D[1], color0D[2]);
              c0 = int (color0D[0] * 255);
              c1 = int (color0D[1] * 255);
              c2 = int (color0D[2] * 255);
              c0D.setRgb(c0, c1, c2);

              vtkFloatingPointType outlineColor[3];
              anActor->GetOutlineColor(outlineColor[0], outlineColor[1], outlineColor[2]);
              c0 = int (outlineColor[0] * 255);
              c1 = int (outlineColor[1] * 255);
              c2 = int (outlineColor[2] * 255);
              outl.setRgb(c0, c1, c2);

              vtkFloatingPointType hColor[3];
              anActor->GetHighlightColor(hColor[0], hColor[1], hColor[2]);
              c0 = int (hColor[0] * 255);
              c1 = int (hColor[1] * 255);
              c2 = int (hColor[2] * 255);
              selection.setRgb(c0, c1, c2);

              vtkFloatingPointType phColor[3];
              anActor->GetPreHighlightColor(phColor[0], phColor[1], phColor[2]);
              c0 = int (phColor[0] * 255);
              c1 = int (phColor[1] * 255);
              c2 = int (phColor[2] * 255);
              preselection.setRgb(c0, c1, c2);

              size0D = (int)anActor->Get0DSize();
              if(size0D == 0)
                size0D = 1;
              Edgewidth = (int)anActor->GetLineWidth();
              if(Edgewidth == 0)
                Edgewidth = 1;
              Shrink = anActor->GetShrinkFactor();

              vtkFloatingPointType faces_orientation_color[3];
              anActor->GetFacesOrientationColor(faces_orientation_color);
              c0 = int (faces_orientation_color[0] * 255);
              c1 = int (faces_orientation_color[1] * 255);
              c2 = int (faces_orientation_color[2] * 255);
              o.setRgb(c0, c1, c2);

              faces_orientation_scale = anActor->GetFacesOrientationScale();
              faces_orientation_3dvectors = anActor->GetFacesOrientation3DVectors();

              aMarkerTypeCurrent = anActor->GetMarkerType();
              aMarkerScaleCurrent = anActor->GetMarkerScale();
              aMarkerTextureCurrent = anActor->GetMarkerTexture();

              // even if there are multiple objects in the selection,
              // we need only the first one to get values for the dialog
              break;
            }
          }
        }

        SMESHGUI_Preferences_ColorDlg *aDlg =
          new SMESHGUI_Preferences_ColorDlg( SMESHGUI::GetSMESHGUI() );
        aDlg->SetColor(1, c);
        aDlg->SetColor(2, e);
        aDlg->SetColor(3, n);
        aDlg->SetColor(4, outl);
        aDlg->SetDeltaBrightness(delta);
        aDlg->SetColor(5, c0D);
        aDlg->SetColor(6, o);
        aDlg->SetIntValue(1, Edgewidth);
        aDlg->SetIntValue(2, int(Shrink*100.));
        aDlg->SetIntValue(3, size0D);
        aDlg->SetDoubleValue(1, faces_orientation_scale);
        aDlg->SetBooleanValue(1, faces_orientation_3dvectors);
        aDlg->SetColor(7, selection);
        aDlg->SetColor(8, preselection);
 
        aDlg->setCustomMarkerMap( theMarkerMap[ aStudy->StudyId() ] );

        if( aMarkerTypeCurrent != VTK::MT_USER )
          aDlg->setStandardMarker( aMarkerTypeCurrent, aMarkerScaleCurrent );
        else
          aDlg->setCustomMarker( aMarkerTextureCurrent );

        if(aDlg->exec()){
          QColor color = aDlg->GetColor(1);
          QColor edgecolor = aDlg->GetColor(2);
          QColor nodecolor = aDlg->GetColor(3);
          QColor outlinecolor = aDlg->GetColor(4);
          QColor color0D = aDlg->GetColor(5);
          QColor faces_orientation_color = aDlg->GetColor(6);
          QColor selectioncolor = aDlg->GetColor(7);
          QColor preSelectioncolor = aDlg->GetColor(8);
          int delta = aDlg->GetDeltaBrightness();

          /* Point marker */
          theMarkerMap[ aStudy->StudyId() ] = aDlg->getCustomMarkerMap();

          SALOME_ListIteratorOfListIO It( selected );
          for( ; It.More(); It.Next()){
            Handle(SALOME_InteractiveObject) IObject = It.Value();
            if(IObject->hasEntry()){
              if(SMESH_Actor *anActor = SMESH::FindActorByEntry(IObject->getEntry())){
                /* actor color and backface color */
                anActor->SetSufaceColor(vtkFloatingPointType (color.red()) / 255.,
                                        vtkFloatingPointType (color.green()) / 255.,
                                        vtkFloatingPointType (color.blue()) / 255.,
                                        delta);
                /* edge color */
                anActor->SetEdgeColor(vtkFloatingPointType (edgecolor.red()) / 255.,
                                      vtkFloatingPointType (edgecolor.green()) / 255.,
                                      vtkFloatingPointType (edgecolor.blue()) / 255.);
                /* edge outline */
                anActor->SetOutlineColor(vtkFloatingPointType (outlinecolor.red()) / 255.,
                                         vtkFloatingPointType (outlinecolor.green()) / 255.,
                                         vtkFloatingPointType (outlinecolor.blue()) / 255.);

                /* selection */
                anActor->SetHighlightColor(vtkFloatingPointType (selectioncolor.red()) / 255.,
                                           vtkFloatingPointType (selectioncolor.green()) / 255.,
                                           vtkFloatingPointType (selectioncolor.blue()) / 255.);
                /* pre-selection */
                anActor->SetPreHighlightColor(vtkFloatingPointType (preSelectioncolor.red()) / 255.,
                                              vtkFloatingPointType (preSelectioncolor.green()) / 255.,
                                              vtkFloatingPointType (preSelectioncolor.blue()) / 255.);
                

                /* Shrink factor and size edges */
                anActor->SetShrinkFactor(aDlg->GetIntValue(2) / 100.);
                anActor->SetLineWidth(aDlg->GetIntValue(1));

                /* Nodes color and size */
                anActor->SetNodeColor(vtkFloatingPointType (nodecolor.red()) / 255.,
                                      vtkFloatingPointType (nodecolor.green()) / 255.,
                                      vtkFloatingPointType (nodecolor.blue()) / 255.);

                /* 0D elements */
                anActor->Set0DColor(vtkFloatingPointType (color0D.red()) / 255.,
                                    vtkFloatingPointType (color0D.green()) / 255.,
                                    vtkFloatingPointType (color0D.blue()) / 255.);
                anActor->Set0DSize(aDlg->GetIntValue(3));

                /* Faces orientation */
                vtkFloatingPointType c[3] = {vtkFloatingPointType(faces_orientation_color.redF()),
                                             vtkFloatingPointType(faces_orientation_color.greenF()),
                                             vtkFloatingPointType(faces_orientation_color.blueF())};
                anActor->SetFacesOrientationColor(c);
                anActor->SetFacesOrientationScale(aDlg->GetDoubleValue(1));
                anActor->SetFacesOrientation3DVectors(aDlg->GetBooleanValue(1));

                VTK::MarkerType aMarkerTypeNew = aDlg->getMarkerType();
                VTK::MarkerScale aMarkerScaleNew = aDlg->getStandardMarkerScale();
                int aMarkerTextureNew = aDlg->getCustomMarkerID();
                if( aMarkerTypeNew != VTK::MT_USER )
                  anActor->SetMarkerStd( aMarkerTypeNew, aMarkerScaleNew );
                else {
                  const VTK::MarkerMap& aMarkerMap = theMarkerMap[ aStudy->StudyId() ];
                  VTK::MarkerMap::const_iterator anIter = aMarkerMap.find( aMarkerTextureNew );
                  if( anIter != aMarkerMap.end() )
                    anActor->SetMarkerTexture( aMarkerTextureNew, anIter->second.second );
                }

                SMESH::SMESH_GroupBase_var aGroupObject = SMESH::IObjectToInterface<SMESH::SMESH_GroupBase>(IObject);
                if( !aGroupObject->_is_nil() )
                {
                  SMESH::ElementType anElementType = aGroupObject->GetType();
                  QColor aColor;
                  switch( anElementType )
                  {
                    case SMESH::NODE: aColor = nodecolor; break;
                    case SMESH::EDGE: aColor = edgecolor; break;
                    default: aColor = color; break;
                  }

                  SALOMEDS::Color aGroupColor;
                  aGroupColor.R = (float)aColor.red() / 255.0;
                  aGroupColor.G = (float)aColor.green() / 255.0;
                  aGroupColor.B = (float)aColor.blue() / 255.0;
                  aGroupObject->SetColor( aGroupColor );
                }
              }
            }
          }
          SMESH::RepaintCurrentView();
        }
        delete aDlg;
        return;
      }
      }
      SALOME_ListIteratorOfListIO It( selected );
      for( ; It.More(); It.Next()){
        Handle(SALOME_InteractiveObject) IObject = It.Value();
        if(IObject->hasEntry()){
          if(SMESH_Actor *anActor = SMESH::FindActorByEntry(IObject->getEntry())){
            switch(theCommandID){
            case 211:
              anActor->SetRepresentation(SMESH_Actor::eEdge);
              break;
            case 212:
              anActor->SetRepresentation(SMESH_Actor::eSurface);
              break;
            case 213:
              if(anActor->IsShrunk())
                anActor->UnShrink();
              else
                anActor->SetShrink();
              break;
            case 215:
              anActor->SetRepresentation(SMESH_Actor::ePoint);
              break;
            case 231:
              if(anActor->GetQuadratic2DRepresentation() != SMESH_Actor::eLines)
                anActor->SetQuadratic2DRepresentation(SMESH_Actor::eLines);
              break;
            case 232:
              if(anActor->GetQuadratic2DRepresentation() != SMESH_Actor::eArcs)
                anActor->SetQuadratic2DRepresentation(SMESH_Actor::eArcs);
              break;
            }
          }
        }
      }
      SMESH::RepaintCurrentView();
    }
  }

Here is the call graph for this function:

void ShowDistribution ( )

Definition at line 970 of file SMESHGUI.cxx.

                          {
    LightApp_SelectionMgr* aSel = SMESHGUI::selectionMgr();
    SALOME_ListIO selected;
    if ( aSel )
      aSel->selectedObjects( selected );
    
    if ( selected.Extent() == 1 ) {
      Handle(SALOME_InteractiveObject) anIO = selected.First();
      if ( anIO->hasEntry() ) {
        SMESH_Actor* anActor = SMESH::FindActorByEntry( anIO->getEntry() );
        if ( anActor && anActor->GetScalarBarActor() && anActor->GetControlMode() != SMESH_Actor::eNone ) {
          SMESH_ScalarBarActor *aScalarBarActor = anActor->GetScalarBarActor();
          aScalarBarActor->SetDistributionVisibility(!aScalarBarActor->GetDistributionVisibility());
        }
      }
    }
  }

Here is the call graph for this function:


Variable Documentation

const char gDigitsSep = ':'

Definition at line 5087 of file SMESHGUI.cxx.

const char gPathSep = '|'

Definition at line 5088 of file SMESHGUI.cxx.

const char gSeparator = '_'

Definition at line 5086 of file SMESHGUI.cxx.