Version: 6.3.1
Public Types | Signals | Public Member Functions | Private Slots | Private Member Functions | Private Attributes

SMESHGUI_CreatePatternDlg Class Reference

Class : SMESHGUI_CreatePatternDlg Description : Dialog to specify filters for VTK viewer. More...

#include <SMESHGUI_CreatePatternDlg.h>

Inheritance diagram for SMESHGUI_CreatePatternDlg:
Inheritance graph
[legend]

Public Types

enum  { Type_2d, Type_3d }

Signals

void NewPattern ()
void Close ()

Public Member Functions

 SMESHGUI_CreatePatternDlg (SMESHGUI *, const int)
 Class : SMESHGUI_CreatePatternDlg Description : Dialog to specify filters for VTK viewer.
virtual ~SMESHGUI_CreatePatternDlg ()
void Init (const int)
QString GetPatternName () const
SMESH::SMESH_Pattern_ptr GetPattern ()
void SetMesh (SMESH::SMESH_Mesh_ptr)

Private Slots

void onOk ()
void onSave ()
void onClose ()
void onHelp ()
void onDeactivate ()
void onSelectionDone ()
void onTypeChanged (int)
void onProject (bool)
void onSelBtnClicked ()

Private Member Functions

void closeEvent (QCloseEvent *)
void enterEvent (QEvent *)
void keyPressEvent (QKeyEvent *)
QWidgetcreateButtonFrame (QWidget *)
QWidgetcreateMainFrame (QWidget *)
void displayPreview ()
void erasePreview ()
void activateSelection ()
QString autoExtension (const QString &) const
bool isValid ()
bool loadFromObject (const bool=true)
QString getDefaultName () const
GEOM::GEOM_Object_ptr getGeom (SALOMEDSClient_SObject *) const

Private Attributes

QButtonGroup * myTypeGrp
QRadioButton * mySwitch2d
QRadioButton * mySwitch3d
QLineEdit * myMeshEdit
QLineEdit * myName
SMESHGUI_PatternWidgetmyPicture2d
QCheckBox * myProjectChk
SMESHGUImySMESHGUI
SVTK_Selector * mySelector
LightApp_SelectionMgr * mySelectionMgr
int myType
SMESH::SMESH_Mesh_var myMesh
SMESH::SMESH_subMesh_var mySubMesh
GEOM::GEOM_Object_var myGeomObj
SMESH::SMESH_Pattern_var myPattern
bool myIsLoaded
QString myHelpFileName

Detailed Description

Class : SMESHGUI_CreatePatternDlg Description : Dialog to specify filters for VTK viewer.

Definition at line 56 of file SMESHGUI_CreatePatternDlg.h.


Member Enumeration Documentation

anonymous enum
Enumerator:
Type_2d 
Type_3d 

Definition at line 61 of file SMESHGUI_CreatePatternDlg.h.


Constructor & Destructor Documentation

SMESHGUI_CreatePatternDlg::SMESHGUI_CreatePatternDlg ( SMESHGUI theModule,
const int  theType 
)

Class : SMESHGUI_CreatePatternDlg Description : Dialog to specify filters for VTK viewer.

Definition at line 87 of file SMESHGUI_CreatePatternDlg.cxx.

References createButtonFrame(), createMainFrame(), SMESH.GetViewWindow(), Init(), MARGIN, myHelpFileName, mySelector, mySMESHGUI, and SPACING.

  : QDialog( SMESH::GetDesktop( theModule ) ),
    mySMESHGUI( theModule ),
    mySelectionMgr( SMESH::GetSelectionMgr( theModule ) )
{
  setModal( false );
  setWindowTitle( tr( "CAPTION" ) );

  QVBoxLayout* aDlgLay = new QVBoxLayout( this );
  aDlgLay->setMargin( MARGIN );
  aDlgLay->setSpacing( SPACING );

  QWidget* aMainFrame = createMainFrame( this );
  QWidget* aBtnFrame  = createButtonFrame( this );

  aDlgLay->addWidget( aMainFrame );
  aDlgLay->addWidget( aBtnFrame );

  aDlgLay->setStretchFactor( aMainFrame, 1 );

  if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ) )
    mySelector = aViewWindow->GetSelector();

  myHelpFileName = "pattern_mapping_page.html";

  Init( theType );
}
SMESHGUI_CreatePatternDlg::~SMESHGUI_CreatePatternDlg ( ) [virtual]

Definition at line 244 of file SMESHGUI_CreatePatternDlg.cxx.

{
}

Member Function Documentation

void SMESHGUI_CreatePatternDlg::activateSelection ( ) [private]

Definition at line 749 of file SMESHGUI_CreatePatternDlg.cxx.

References SMESH.GetViewWindow(), mySelectionMgr, mySMESHGUI, myType, and Type_2d.

Referenced by enterEvent(), and Init().

{
  mySelectionMgr->clearFilters();
  //SUIT_Application::getDesktop()->setSelectionModes(ActorSelection);
  if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ) )
    aViewWindow->SetSelectionMode( ActorSelection );

  if ( myType == Type_2d ) {
    mySelectionMgr->installFilter( new SMESH_NumberFilter( "SMESH",
                                                           TopAbs_SHAPE,
                                                           -1,
                                                           TopAbs_FACE ) );
  } 
  else {
    TColStd_MapOfInteger aTypes;
    aTypes.Add( TopAbs_SHELL );
    aTypes.Add( TopAbs_SOLID );
    mySelectionMgr->installFilter( new SMESH_NumberFilter( "SMESH",
                                                           TopAbs_FACE,
                                                           6,
                                                           aTypes,
                                                           GEOM::GEOM_Object::_nil(),
                                                           true ) );
  }
}
QString SMESHGUI_CreatePatternDlg::autoExtension ( const QString &  theFileName) const [private]

Definition at line 673 of file SMESHGUI_CreatePatternDlg.cxx.

References SMESH_Nut.theFileName.

Referenced by onSave().

{
  QString anExt = theFileName.section('.', -1);
  return anExt != "smp" && anExt != "SMP" ? theFileName + ".smp" : theFileName;
}
void SMESHGUI_CreatePatternDlg.Close ( ) [signal]

Referenced by onClose().

void SMESHGUI_CreatePatternDlg::closeEvent ( QCloseEvent *  ) [private]

Definition at line 655 of file SMESHGUI_CreatePatternDlg.cxx.

References onClose().

{
  onClose();
}
QWidget * SMESHGUI_CreatePatternDlg::createButtonFrame ( QWidget theParent) [private]

Definition at line 210 of file SMESHGUI_CreatePatternDlg.cxx.

References MARGIN, onClose(), onHelp(), onOk(), onSave(), and SPACING.

Referenced by SMESHGUI_CreatePatternDlg().

{
  QFrame* aFrame = new QFrame( theParent );
  aFrame->setFrameStyle( QFrame::Box | QFrame::Sunken );

  QPushButton* myOkBtn    = new QPushButton( tr( "SMESH_BUT_OK"    ), aFrame );
  QPushButton* mySaveBtn  = new QPushButton( tr( "SAVE"            ), aFrame );
  QPushButton* myCloseBtn = new QPushButton( tr( "SMESH_BUT_CANCEL"), aFrame );
  QPushButton* myHelpBtn  = new QPushButton( tr( "SMESH_BUT_HELP"),   aFrame );

  QHBoxLayout* aLay = new QHBoxLayout( aFrame );
  aLay->setMargin( MARGIN );
  aLay->setSpacing( SPACING );

  aLay->addWidget( myOkBtn );
  aLay->addSpacing( 10 );
  aLay->addWidget( mySaveBtn );
  aLay->addSpacing( 10 );
  aLay->addStretch();
  aLay->addWidget( myCloseBtn );
  aLay->addWidget( myHelpBtn );

  connect( myOkBtn,    SIGNAL( clicked() ), this, SLOT( onOk() ) );
  connect( myCloseBtn, SIGNAL( clicked() ), this, SLOT( onClose() ) );
  connect( mySaveBtn,  SIGNAL( clicked() ), this, SLOT( onSave() ) );
  connect( myHelpBtn,  SIGNAL( clicked() ), this, SLOT( onHelp() ) );

  return aFrame;
}
QWidget * SMESHGUI_CreatePatternDlg::createMainFrame ( QWidget theParent) [private]

Definition at line 120 of file SMESHGUI_CreatePatternDlg.cxx.

References SMESH.GetResourceMgr(), MARGIN, myMeshEdit, myName, myPicture2d, myProjectChk, mySMESHGUI, mySwitch2d, mySwitch3d, myTypeGrp, onProject(), onSelBtnClicked(), onTypeChanged(), SPACING, Type_2d, and Type_3d.

Referenced by SMESHGUI_CreatePatternDlg().

{
  QPixmap iconSlct    ( SMESH::GetResourceMgr( mySMESHGUI )->loadPixmap( "SMESH", tr( "ICON_SELECT" ) ) );
  QPixmap icon2d      ( SMESH::GetResourceMgr( mySMESHGUI )->loadPixmap( "SMESH", tr( "ICON_PATTERN_2d" ) ) );
  QPixmap icon3d      ( SMESH::GetResourceMgr( mySMESHGUI )->loadPixmap( "SMESH", tr( "ICON_PATTERN_3d" ) ) );
  QPixmap iconSample2d( SMESH::GetResourceMgr( mySMESHGUI )->loadPixmap( "SMESH", tr( "ICON_PATTERN_SAMPLE_2D" ) ) );

  QWidget* aMainGrp = new QWidget( theParent );
  QVBoxLayout* aMainGrpLayout = new QVBoxLayout( aMainGrp );
  aMainGrpLayout->setMargin( 0 );
  aMainGrpLayout->setSpacing( SPACING );

  // Pattern type group

  QGroupBox* aTypeGrp = new QGroupBox( tr( "PATTERN_TYPE" ), aMainGrp );
  QHBoxLayout* aTypeGrpLayout = new QHBoxLayout( aTypeGrp );
  aTypeGrpLayout->setMargin( MARGIN );
  aTypeGrpLayout->setSpacing( SPACING );

  mySwitch2d = new QRadioButton( aTypeGrp );
  mySwitch3d = new QRadioButton( aTypeGrp );
  mySwitch2d->setIcon( icon2d );
  mySwitch3d->setIcon( icon3d );

  myTypeGrp = new QButtonGroup( aMainGrp );
  myTypeGrp->addButton( mySwitch2d, Type_2d );
  myTypeGrp->addButton( mySwitch3d, Type_3d );

  // ... layout widgets

  aTypeGrpLayout->addWidget( mySwitch2d );
  aTypeGrpLayout->addWidget( mySwitch3d );

  // Mesh and pattern name group

  QGroupBox* aPatternGrp = new QGroupBox( tr( "PATTERN" ), aMainGrp );
  QGridLayout* aPatternGrpLayout = new QGridLayout( aPatternGrp );
  aPatternGrpLayout->setMargin( MARGIN );
  aPatternGrpLayout->setSpacing( SPACING );

  QLabel* aMeshLab = new QLabel( tr( "MESH_OR_SUBMESH" ), aPatternGrp );

  QPushButton* aSelBtn = new QPushButton( aPatternGrp );
  aSelBtn->setIcon( iconSlct );
  myMeshEdit = new QLineEdit( aPatternGrp );
  myMeshEdit->setReadOnly( true );

  QLabel* aNameLab = new QLabel( tr( "PATTERN_NAME" ), aPatternGrp );
  myName = new QLineEdit( aPatternGrp );

  // Picture 2d

  myPicture2d = new SMESHGUI_PatternWidget( aPatternGrp ),
  myPicture2d->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Expanding ) );

  // Project check box

  myProjectChk = new QCheckBox( tr( "PROJECT" ), aPatternGrp );

  // ... layout widgets

  aPatternGrpLayout->addWidget( aMeshLab,     0, 0 );
  aPatternGrpLayout->addWidget( aSelBtn,      0, 1 );
  aPatternGrpLayout->addWidget( myMeshEdit,   0, 2 );
  aPatternGrpLayout->addWidget( aNameLab,     1, 0 );
  aPatternGrpLayout->addWidget( myName,       1, 2 );
  aPatternGrpLayout->addWidget( myPicture2d,  2, 0, 1, 3 );
  aPatternGrpLayout->addWidget( myProjectChk, 3, 0, 1, 3 );

  // main layout

  aMainGrpLayout->addWidget( aTypeGrp );
  aMainGrpLayout->addWidget( aPatternGrp );

  // Connect signals and slots

  connect( myTypeGrp,    SIGNAL( buttonClicked( int )  ),
           this,         SLOT( onTypeChanged( int ) ) );
  connect( myProjectChk, SIGNAL( toggled( bool ) ),
           this,         SLOT( onProject( bool ) ) );
  connect( aSelBtn,      SIGNAL( clicked() ),
           this,         SLOT( onSelBtnClicked() ) );

  return aMainGrp;
}
void SMESHGUI_CreatePatternDlg::displayPreview ( ) [private]

Definition at line 683 of file SMESHGUI_CreatePatternDlg.cxx.

References erasePreview(), SMESH_test.i2, SMESH_test.i3, myIsLoaded, myPattern, myPicture2d, SMESH_AdvancedEditor.n2, SMESH_AdvancedEditor.n3, SMESH_AdvancedEditor.n4, and SMESHGUI_PatternWidget.SetPoints().

Referenced by onProject(), onSelectionDone(), and SetMesh().

{
  // Redisplay preview in dialog
  try {
    if ( !myIsLoaded ) {
      erasePreview();
    }
    else {
      SMESH::point_array_var pnts = myPattern->GetPoints();
      SMESH::long_array_var keyPoints = myPattern->GetKeyPoints();
      SMESH::array_of_long_array_var elemPoints = myPattern->GetElementPoints( false );

      if ( pnts->length()       == 0 ||
           keyPoints->length()  == 0 ||
           elemPoints->length() == 0 ) {
        myIsLoaded = false;
        erasePreview();
        return;
      }

      PointVector aPoints( pnts->length() );
      QVector<int> aKeyPoints( keyPoints->length() );
      ConnectivityVector anElemPoints( elemPoints->length() );

      for ( int i = 0, n = pnts->length(); i < n; i++ )
        aPoints[ i ] = pnts[ i ];

      for ( int i2 = 0, n2 = keyPoints->length(); i2 < n2; i2++ )
        aKeyPoints[ i2 ] = keyPoints[ i2 ];

      for (int i3 = 0, n3 = elemPoints->length(); i3 < n3; i3++) {
        QVector<int> aVec (elemPoints[ i3 ].length());
        for (int i4 = 0, n4 = elemPoints[ i3 ].length(); i4 < n4; i4++)
          aVec[ i4 ] = elemPoints[ i3 ][ i4 ];

        anElemPoints[ i3 ] = aVec;
      }

      myPicture2d->SetPoints( aPoints, aKeyPoints, anElemPoints );
    }

    return;

  } 
  catch ( const SALOME::SALOME_Exception& S_ex ) {
    SalomeApp_Tools::QtCatchCorbaException( S_ex );
  }
  catch (...) {
  }
  erasePreview();
}
void SMESHGUI_CreatePatternDlg::enterEvent ( QEvent *  ) [private]

Definition at line 640 of file SMESHGUI_CreatePatternDlg.cxx.

References activateSelection(), SMESHGUI.EmitSignalDeactivateDialog(), mySelectionMgr, mySMESHGUI, and onSelectionDone().

{
  // there is a stange problem that enterEvent() comes after onSave()
  if ( isVisible () ) {
    mySMESHGUI->EmitSignalDeactivateDialog();
    setEnabled( true );
    activateSelection();
    connect( mySelectionMgr, SIGNAL( currentSelectionChanged() ), SLOT( onSelectionDone() ) );
  }
}
void SMESHGUI_CreatePatternDlg::erasePreview ( ) [private]

Definition at line 739 of file SMESHGUI_CreatePatternDlg.cxx.

References myPicture2d, and SMESHGUI_PatternWidget.SetPoints().

Referenced by displayPreview(), Init(), and onSelectionDone().

{
  // Erase preview in 2D viewer
  myPicture2d->SetPoints( PointVector(), QVector<int>(), ConnectivityVector() );
}
QString SMESHGUI_CreatePatternDlg::getDefaultName ( ) const [private]

Definition at line 357 of file SMESHGUI_CreatePatternDlg.cxx.

References myType, and Type_2d.

Referenced by Init().

{
  return myType == Type_2d ? tr( "DEFAULT_2D" ) : tr( "DEFAULT_3D" );
}
GEOM::GEOM_Object_ptr SMESHGUI_CreatePatternDlg.getGeom ( SALOMEDSClient_SObject *  ) const [private]
SMESH::SMESH_Pattern_ptr SMESHGUI_CreatePatternDlg::GetPattern ( )

Definition at line 444 of file SMESHGUI_CreatePatternDlg.cxx.

References myPattern.

Referenced by SMESHGUI_MeshPatternDlg.onOkCreationDlg().

{
  return myPattern.in();
}
QString SMESHGUI_CreatePatternDlg::GetPatternName ( ) const

Definition at line 435 of file SMESHGUI_CreatePatternDlg.cxx.

References myName.

Referenced by SMESHGUI_MeshPatternDlg.onOkCreationDlg().

{
  return myName->text();
}
void SMESHGUI_CreatePatternDlg::Init ( const int  theType)

Definition at line 263 of file SMESHGUI_CreatePatternDlg.cxx.

References activateSelection(), erasePreview(), getDefaultName(), myGeomObj, myIsLoaded, myMesh, myMeshEdit, myName, myPattern, mySelectionMgr, mySMESHGUI, mySubMesh, mySwitch2d, mySwitch3d, myType, myTypeGrp, onClose(), onDeactivate(), onSelectionDone(), onTypeChanged(), SMESHGUI.SetActiveDialogBox(), Type_2d, and Type_3d.

Referenced by SMESHGUI_MeshPatternDlg.onNew(), and SMESHGUI_CreatePatternDlg().

{
  myIsLoaded     = false;
  myType         = -1;
  mySubMesh      = SMESH::SMESH_subMesh::_nil();
  myMesh         = SMESH::SMESH_Mesh::_nil();
  myGeomObj      = GEOM::GEOM_Object::_nil();
  myPattern      = SMESH::SMESH_Pattern::_nil();

  erasePreview();

  mySMESHGUI->SetActiveDialogBox((QDialog*)this);

  // selection and SMESHGUI
  connect( mySelectionMgr, SIGNAL( currentSelectionChanged() ),
           this,           SLOT( onSelectionDone() ) );
  connect( mySMESHGUI,     SIGNAL( SignalDeactivateActiveDialog() ),
           this,           SLOT( onDeactivate() ) );
  connect( mySMESHGUI,     SIGNAL( SignalCloseAllDialogs() ),
           this,           SLOT( onClose() ) );

  mySwitch2d->setEnabled( theType == Type_2d );
  mySwitch3d->setEnabled( theType == Type_3d );

  myTypeGrp->button( theType )->setChecked( true );
  onTypeChanged( theType );

  myName->setText( getDefaultName() );
  myMeshEdit->setText( "" );

  QApplication::instance()->processEvents();
  updateGeometry();
  resize(100,100);

  activateSelection();
  onSelectionDone();

  //show();
}
bool SMESHGUI_CreatePatternDlg::isValid ( ) [private]

Definition at line 342 of file SMESHGUI_CreatePatternDlg.cxx.

References myGeomObj.

Referenced by onOk(), and onSave().

{
  if ( myGeomObj->_is_nil() ) {
    SUIT_MessageBox::information( this,
                                  tr( "SMESH_INSUFFICIENT_DATA" ),
                                  tr( "SMESHGUI_INVALID_PARAMETERS" ) );
    return false;
  }
  return true;
}
void SMESHGUI_CreatePatternDlg::keyPressEvent ( QKeyEvent *  e) [private]

Definition at line 795 of file SMESHGUI_CreatePatternDlg.cxx.

References onHelp().

{
  QDialog::keyPressEvent( e );
  if ( e->isAccepted() )
    return;

  if ( e->key() == Qt::Key_F1 ){
    e->accept();
    onHelp();
  }
}
bool SMESHGUI_CreatePatternDlg::loadFromObject ( const bool  theMess = true) [private]

Definition at line 528 of file SMESHGUI_CreatePatternDlg.cxx.

References SMESH.SMESH_Pattern.ERR_LOAD_EMPTY_SUBMESH, SMESH.SMESH_Pattern.ERR_LOADF_CANT_PROJECT, SMESH.SMESH_Pattern.ERR_LOADF_CLOSED_FACE, SMESH.SMESH_Pattern.ERR_LOADF_NARROW_FACE, SMESH.SMESH_Pattern.ERR_LOADV_BAD_SHAPE, SMESH.SMESH_Pattern.ERR_LOADV_COMPUTE_PARAMS, SMESH.GetPattern(), myGeomObj, myIsLoaded, myMesh, myPattern, myProjectChk, mySubMesh, myType, and Type_2d.

Referenced by onOk(), onProject(), onSave(), onSelectionDone(), and SetMesh().

{
  try {
    myIsLoaded = false;

    if ( myPattern->_is_nil() )
      myPattern = SMESH::GetPattern();

    if ( (myMesh->_is_nil() && mySubMesh->_is_nil()) || myGeomObj->_is_nil() )
      return false;

    SMESH::SMESH_Mesh_ptr aMesh = mySubMesh->_is_nil() ? myMesh.in() : mySubMesh->GetFather();

    myIsLoaded = myType == Type_2d
      ? myPattern->LoadFromFace( aMesh, myGeomObj, myProjectChk->isChecked() )
      : myPattern->LoadFrom3DBlock( aMesh, myGeomObj );

    if ( !myIsLoaded && theMess ) {
      QString aMess;
      SMESH::SMESH_Pattern::ErrorCode aCode = myPattern->GetErrorCode();

      if      ( aCode == SMESH::SMESH_Pattern::ERR_LOAD_EMPTY_SUBMESH )   aMess = tr( "ERR_LOAD_EMPTY_SUBMESH" );
      else if ( aCode == SMESH::SMESH_Pattern::ERR_LOADF_NARROW_FACE )    aMess = tr( "ERR_LOADF_NARROW_FACE" );
      else if ( aCode == SMESH::SMESH_Pattern::ERR_LOADF_CLOSED_FACE )    aMess = tr( "ERR_LOADF_CLOSED_FACE" );
      else if ( aCode == SMESH::SMESH_Pattern::ERR_LOADF_CANT_PROJECT )   aMess = tr( "ERR_LOADF_CANT_PROJECT" );
      else if ( aCode == SMESH::SMESH_Pattern::ERR_LOADV_BAD_SHAPE )      aMess = tr( "ERR_LOADV_BAD_SHAPE" );
      else if ( aCode == SMESH::SMESH_Pattern::ERR_LOADV_COMPUTE_PARAMS ) aMess = tr( "ERR_LOADV_COMPUTE_PARAMS" );
      else                                                                aMess = tr( "ERROR_OF_CREATION" );

      SUIT_MessageBox::information( this, tr( "SMESH_ERROR" ), aMess );
    }
  } 
  catch ( const SALOME::SALOME_Exception& S_ex ) {
    SalomeApp_Tools::QtCatchCorbaException( S_ex );
  }

  return myIsLoaded;
}
void SMESHGUI_CreatePatternDlg.NewPattern ( ) [signal]

Referenced by onOk(), and onSave().

void SMESHGUI_CreatePatternDlg::onClose ( ) [private, slot]

Definition at line 488 of file SMESHGUI_CreatePatternDlg.cxx.

References Close(), SMESH.GetViewWindow(), mySelectionMgr, mySMESHGUI, and SMESHGUI.ResetState().

Referenced by closeEvent(), createButtonFrame(), and Init().

{
  if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ) )
    aViewWindow->SetSelectionMode( ActorSelection );
  disconnect( mySelectionMgr, 0, this, 0 );
  disconnect( mySMESHGUI, 0, this, 0 );
  mySMESHGUI->ResetState();
  reject();
  emit Close();
}
void SMESHGUI_CreatePatternDlg::onDeactivate ( ) [private, slot]

Definition at line 630 of file SMESHGUI_CreatePatternDlg.cxx.

References mySelectionMgr.

Referenced by Init().

{
  disconnect( mySelectionMgr, 0, this, 0 );
  setEnabled( false );
}
void SMESHGUI_CreatePatternDlg::onHelp ( ) [private, slot]

Definition at line 503 of file SMESHGUI_CreatePatternDlg.cxx.

References myHelpFileName, and mySMESHGUI.

Referenced by createButtonFrame(), and keyPressEvent().

{
  LightApp_Application* app = (LightApp_Application*)( SUIT_Session::session()->activeApplication() );
  if ( app ) 
    app->onHelpContextModule( mySMESHGUI ? app->moduleName( mySMESHGUI->moduleName() ) : QString( "" ), myHelpFileName );
  else {
    QString platform;
#ifdef WIN32
    platform = "winapplication";
#else
    platform = "application";
#endif
    SUIT_MessageBox::warning( this, 
                              tr( "WRN_WARNING" ),
                              tr( "EXTERNAL_BROWSER_CANNOT_SHOW_PAGE" ).
                              arg( app->resourceMgr()->stringValue( "ExternalBrowser", 
                                                                    platform ) ).
                              arg( myHelpFileName ) );
  }
}
void SMESHGUI_CreatePatternDlg::onOk ( ) [private, slot]

Definition at line 453 of file SMESHGUI_CreatePatternDlg.cxx.

References SMESH.GetViewWindow(), isValid(), loadFromObject(), myIsLoaded, mySelectionMgr, mySMESHGUI, NewPattern(), and SMESHGUI.ResetState().

Referenced by createButtonFrame().

{
  try {
    if ( !isValid() )
      return;

    if ( !myIsLoaded )
      loadFromObject( true );

    // Load pattern from object
    if ( !myIsLoaded ) {
      return;
    }
    else {
      //SUIT_Application::getDesktop()->setSelectionModes(ActorSelection);
      if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ) )
        aViewWindow->SetSelectionMode( ActorSelection );
      disconnect( mySelectionMgr, 0, this, 0 );
      disconnect( mySMESHGUI, 0, this, 0 );
      mySMESHGUI->ResetState();
      accept();
      emit NewPattern();
    }
  } 
  catch ( const SALOME::SALOME_Exception& S_ex ) {
    SalomeApp_Tools::QtCatchCorbaException( S_ex );
  } 
  catch (...) {
  }
}
void SMESHGUI_CreatePatternDlg::onProject ( bool  ) [private, slot]

Definition at line 253 of file SMESHGUI_CreatePatternDlg.cxx.

References displayPreview(), and loadFromObject().

Referenced by createMainFrame().

{
  loadFromObject( false );
  displayPreview();
}
void SMESHGUI_CreatePatternDlg::onSave ( ) [private, slot]

Definition at line 367 of file SMESHGUI_CreatePatternDlg.cxx.

References autoExtension(), SMESH.GetViewWindow(), isValid(), loadFromObject(), myIsLoaded, myName, myPattern, mySelectionMgr, mySMESHGUI, NewPattern(), and SMESHGUI.ResetState().

Referenced by createButtonFrame().

{
  try {
    if ( !isValid() )
      return;

    if ( !myIsLoaded )
      loadFromObject( true );

    // Load pattern from object
    if ( !myIsLoaded )
      return;

    SUIT_FileDlg* aDlg = new SUIT_FileDlg( this, false );
    aDlg->setWindowTitle( tr( "SAVE_PATTERN" ) );
    aDlg->setFileMode( QFileDialog::AnyFile );
    aDlg->setFilter( tr( "PATTERN_FILT" ) );
    if ( myName->text() != "" )
      aDlg->selectFile( myName->text() );

    if ( aDlg->exec() != Accepted )
      return;

    QString fName = aDlg->selectedFile();
    if ( fName.isEmpty() )
      return;

    if ( QFileInfo( fName ).suffix().isEmpty() )
      fName = autoExtension( fName );

    fName = QDir::convertSeparators( fName );

    QString aData( myPattern->GetString() );
    long aLen = aData.length();

    QFile aFile( fName );
    aFile.open( QIODevice::WriteOnly );
    long aWritten = aFile.write( aData.toLatin1(), aLen );
    aFile.close();

    if ( aWritten != aLen ) {
      SUIT_MessageBox::information( this,
                                    tr( "SMESH_ERROR" ),
                                    tr( "ERROR_OF_SAVING" ) );
    } 
    else {
      //SUIT_Application::getDesktop()->setSelectionModes(ActorSelection);
      if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ) )
        aViewWindow->SetSelectionMode( ActorSelection );
      disconnect( mySelectionMgr, 0, this, 0 );
      disconnect( mySMESHGUI, 0, this, 0 );
      mySMESHGUI->ResetState();
      accept();
      emit NewPattern();
    }
  } 
  catch ( const SALOME::SALOME_Exception& S_ex ) {
    SalomeApp_Tools::QtCatchCorbaException( S_ex );
  } 
  catch (...) {
  }
}
void SMESHGUI_CreatePatternDlg::onSelBtnClicked ( ) [private, slot]

Definition at line 664 of file SMESHGUI_CreatePatternDlg.cxx.

References onSelectionDone().

Referenced by createMainFrame().

void SMESHGUI_CreatePatternDlg::onSelectionDone ( ) [private, slot]

Definition at line 571 of file SMESHGUI_CreatePatternDlg.cxx.

References _PTR(), displayPreview(), erasePreview(), SMESH.GetGeom(), SMESH.GetNameOfSelectedIObjects(), Handle(), loadFromObject(), myGeomObj, myMesh, myMeshEdit, mySelectionMgr, mySubMesh, myType, and Type_2d.

Referenced by enterEvent(), Init(), and onSelBtnClicked().

{
  try {
    SALOME_ListIO aList;
    mySelectionMgr->selectedObjects( aList, SVTK_Viewer::Type() );
    if ( aList.Extent() != 1 )
      return;

    // Get mesh or sub-mesh from selection
    Handle(SALOME_InteractiveObject) anIO = aList.First();
    SMESH::SMESH_Mesh_var aMesh = SMESH::IObjectToInterface<SMESH::SMESH_Mesh>( anIO );
    SMESH::SMESH_subMesh_var aSubMesh = SMESH::IObjectToInterface<SMESH::SMESH_subMesh>( anIO );
    if ( aMesh->_is_nil() && aSubMesh->_is_nil() )
      return;

    // Get geom object corresponding to the mesh
    _PTR(SObject) aSO;
    if ( !aMesh->_is_nil() )
      aSO = SMESH::FindSObject( aMesh.in() );
    else
      aSO = SMESH::FindSObject( aSubMesh.in() );

    GEOM::GEOM_Object_var aGeomObj = SMESH::GetGeom( aSO );
    if ( aGeomObj->_is_nil() )
      return;

    myGeomObj = aGeomObj;

    // init class fields
    if ( !aMesh->_is_nil() ) {
      myMesh = aMesh;
      mySubMesh = SMESH::SMESH_subMesh::_nil();
    } 
    else {
      mySubMesh = aSubMesh;
      myMesh = SMESH::SMESH_Mesh::_nil();
    }

    QString aName;
    SMESH::GetNameOfSelectedIObjects( mySelectionMgr, aName );
    myMeshEdit->setText( aName );

    if ( myType == Type_2d ) {
      loadFromObject( true );
      displayPreview();
    }
  } 
  catch (...) {
    myMesh = SMESH::SMESH_Mesh::_nil();
    mySubMesh = SMESH::SMESH_subMesh::_nil();
    myGeomObj = GEOM::GEOM_Object::_nil();
    erasePreview();
  }
}
void SMESHGUI_CreatePatternDlg::onTypeChanged ( int  theType) [private, slot]

Definition at line 780 of file SMESHGUI_CreatePatternDlg.cxx.

References myPicture2d, myProjectChk, myType, and Type_2d.

Referenced by createMainFrame(), and Init().

{
  if ( myType == theType )
    return;

  myType = theType;

  myPicture2d->setVisible( theType == Type_2d );
  myProjectChk->setVisible( theType == Type_2d );
}
void SMESHGUI_CreatePatternDlg::SetMesh ( SMESH::SMESH_Mesh_ptr  thePtr)

Definition at line 307 of file SMESHGUI_CreatePatternDlg.cxx.

References _PTR(), displayPreview(), SMESH.GetGeom(), loadFromObject(), myGeomObj, myMesh, myMeshEdit, mySelectionMgr, mySubMesh, myType, and Type_2d.

Referenced by SMESHGUI_MeshPatternDlg.onNew().

{
  myMesh = SMESH::SMESH_Mesh::_duplicate( thePtr );
  mySubMesh = SMESH::SMESH_subMesh::_nil();

  bool isValidMesh = false;
  if ( !myMesh->_is_nil() ) {
    _PTR(SObject) aSobj = SMESH::FindSObject( myMesh.in() );
    //Handle(SALOME_InteractiveObject) anIObj =
    //  new SALOME_InteractiveObject(aSobj->GetID().c_str(), "SMESH");
    SUIT_DataOwnerPtr anIObj( new LightApp_DataOwner( aSobj->GetID().c_str() ) );

    isValidMesh = mySelectionMgr->isOk( anIObj );
  }

  if ( isValidMesh ) {
    _PTR(SObject) aSO = SMESH::FindSObject( myMesh.in() );
    myMeshEdit->setText( aSO->GetName().c_str() );
    myGeomObj = SMESH::GetGeom( aSO );
  } 
  else {
    myMeshEdit->setText( "" );
    myGeomObj = GEOM::GEOM_Object::_nil();
  }

  if ( myType == Type_2d ) {
    loadFromObject( false );
    displayPreview();
  }
}

Field Documentation

GEOM::GEOM_Object_var SMESHGUI_CreatePatternDlg.myGeomObj [private]

Definition at line 125 of file SMESHGUI_CreatePatternDlg.h.

Referenced by Init(), isValid(), loadFromObject(), onSelectionDone(), and SetMesh().

Definition at line 130 of file SMESHGUI_CreatePatternDlg.h.

Referenced by onHelp(), and SMESHGUI_CreatePatternDlg().

Definition at line 128 of file SMESHGUI_CreatePatternDlg.h.

Referenced by displayPreview(), Init(), loadFromObject(), onOk(), and onSave().

SMESH::SMESH_Mesh_var SMESHGUI_CreatePatternDlg.myMesh [private]

Definition at line 123 of file SMESHGUI_CreatePatternDlg.h.

Referenced by Init(), loadFromObject(), onSelectionDone(), and SetMesh().

Definition at line 111 of file SMESHGUI_CreatePatternDlg.h.

Referenced by createMainFrame(), Init(), onSelectionDone(), and SetMesh().

QLineEdit* SMESHGUI_CreatePatternDlg.myName [private]

Definition at line 112 of file SMESHGUI_CreatePatternDlg.h.

Referenced by createMainFrame(), GetPatternName(), Init(), and onSave().

SMESH::SMESH_Pattern_var SMESHGUI_CreatePatternDlg.myPattern [private]

Definition at line 127 of file SMESHGUI_CreatePatternDlg.h.

Referenced by displayPreview(), GetPattern(), Init(), loadFromObject(), and onSave().

Definition at line 116 of file SMESHGUI_CreatePatternDlg.h.

Referenced by createMainFrame(), loadFromObject(), and onTypeChanged().

LightApp_SelectionMgr* SMESHGUI_CreatePatternDlg.mySelectionMgr [private]
SVTK_Selector* SMESHGUI_CreatePatternDlg.mySelector [private]

Definition at line 119 of file SMESHGUI_CreatePatternDlg.h.

Referenced by SMESHGUI_CreatePatternDlg().

SMESH::SMESH_subMesh_var SMESHGUI_CreatePatternDlg.mySubMesh [private]

Definition at line 124 of file SMESHGUI_CreatePatternDlg.h.

Referenced by Init(), loadFromObject(), onSelectionDone(), and SetMesh().

QRadioButton* SMESHGUI_CreatePatternDlg.mySwitch2d [private]

Definition at line 108 of file SMESHGUI_CreatePatternDlg.h.

Referenced by createMainFrame(), and Init().

QRadioButton* SMESHGUI_CreatePatternDlg.mySwitch3d [private]

Definition at line 109 of file SMESHGUI_CreatePatternDlg.h.

Referenced by createMainFrame(), and Init().

QButtonGroup* SMESHGUI_CreatePatternDlg.myTypeGrp [private]

Definition at line 107 of file SMESHGUI_CreatePatternDlg.h.

Referenced by createMainFrame(), and Init().

Copyright © 2007-2011 CEA/DEN, EDF R&D, OPEN CASCADE
Copyright © 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS