Version: 6.3.1
Public Member Functions | Protected Slots | Protected Member Functions | Private Attributes

SMESHGUI_IntersectGroupsDlg Class Reference

#include <SMESHGUI_GroupOpDlg.h>

Inheritance diagram for SMESHGUI_IntersectGroupsDlg:
Inheritance graph
[legend]

Public Member Functions

 SMESHGUI_IntersectGroupsDlg (SMESHGUI *)
 Constructor.
virtual ~SMESHGUI_IntersectGroupsDlg ()
 Destructor.
void Init ()
 Init dialog fields, connect signals and slots, show dialog.

Protected Slots

virtual bool onApply ()
 SLOT called when apply button is pressed performs operation.
virtual void onSelectionDone ()
 SLOT, called when selection is changed, updates corresponding GUI controls.
virtual void setVisible (bool visible)
 Calls onSelectionDone() and setVisible() method of base class.

Protected Member Functions

virtual void reset ()
 This virtual method redefined from the base class resets state of the dialog, initializes its fields with default value, etc.
QString getName () const
 Gets name of group to be created.
void setName (const QString &theName)
 Sets name of group to be created.
QGroupBoxgetArgGrp () const
 Gets pointer on arguments group box.
void setHelpFileName (const QString &theFName)
 Sets help file name.
SMESHGUIgetSMESHGUI () const
 Gets pointer to the module instance.
bool isValid (const QList< SMESH::SMESH_GroupBase_var > &theListGrp)
 Validate list of groups used for operation.
bool getSelectedGroups (QList< SMESH::SMESH_GroupBase_var > &theOutList, QStringList &theOutNames)
 Gets list of currently selected groups from selection manager.
SMESH::ListOfGroupsconvert (const QList< SMESH::SMESH_GroupBase_var > &)
 Converts QT-list of group to the list acceptable by IDL interface.
SALOMEDS::Color getColor () const
 Get color to be assigned to group.
void setIsApplyAndClose (const bool theFlag)
 Set value of the flag indicating that the dialog is accepted by Apply & Close button.
bool isApplyAndClose () const
 Get value of the flag indicating that the dialog is accepted by Apply & Close button.

Private Attributes

QListWidget * myListWg
QList< SMESH::SMESH_GroupBase_var > myGroups

Detailed Description

Definition at line 160 of file SMESHGUI_GroupOpDlg.h.


Constructor & Destructor Documentation

SMESHGUI_IntersectGroupsDlg::SMESHGUI_IntersectGroupsDlg ( SMESHGUI theModule)

Constructor.

Parameters:
theModulemodule

Definition at line 671 of file SMESHGUI_GroupOpDlg.cxx.

References SMESHGUI_GroupOpDlg.getArgGrp(), myListWg, and SMESHGUI_GroupOpDlg.setHelpFileName().

: SMESHGUI_GroupOpDlg( theModule )
{
  setWindowTitle(tr("INTERSECTION_OF_GROUPS"));
  setHelpFileName( "using_operations_on_groups_page.html#intersection_anchor" );

  QGroupBox* anArgGrp = getArgGrp();
  myListWg = new QListWidget( anArgGrp );

  QHBoxLayout* aLay = new QHBoxLayout( anArgGrp );
  aLay->addWidget( myListWg );
}
SMESHGUI_IntersectGroupsDlg::~SMESHGUI_IntersectGroupsDlg ( ) [virtual]

Destructor.

Definition at line 687 of file SMESHGUI_GroupOpDlg.cxx.

{
}

Member Function Documentation

SMESH::ListOfGroups * SMESHGUI_GroupOpDlg::convert ( const QList< SMESH::SMESH_GroupBase_var > &  theIn) [protected, inherited]

Converts QT-list of group to the list acceptable by IDL interface.

Parameters:
theIninput list
Returns:
list acceptable by IDL interface

Definition at line 396 of file SMESHGUI_GroupOpDlg.cxx.

Referenced by SMESHGUI_DimGroupDlg.onApply(), SMESHGUI_CutGroupsDlg.onApply(), onApply(), and SMESHGUI_UnionGroupsDlg.onApply().

{
  SMESH::ListOfGroups_var aList = new SMESH::ListOfGroups();
  aList->length( theIn.count() );

  QList<SMESH::SMESH_GroupBase_var>::const_iterator anIter = theIn.begin();
  for ( int i = 0; anIter != theIn.end(); ++anIter, ++i )
    aList[ i ] = *anIter;

  return aList._retn();
}
QGroupBox * SMESHGUI_GroupOpDlg::getArgGrp ( ) const [protected, inherited]

Gets pointer on arguments group box.

Returns:
pointer on arguments group box

Definition at line 156 of file SMESHGUI_GroupOpDlg.cxx.

References SMESHGUI_GroupOpDlg.myArgGrp.

Referenced by SMESHGUI_CutGroupsDlg.SMESHGUI_CutGroupsDlg(), SMESHGUI_DimGroupDlg.SMESHGUI_DimGroupDlg(), SMESHGUI_IntersectGroupsDlg(), and SMESHGUI_UnionGroupsDlg.SMESHGUI_UnionGroupsDlg().

{
  return myArgGrp;
}
SALOMEDS::Color SMESHGUI_GroupOpDlg::getColor ( ) const [protected, inherited]

Get color to be assigned to group.

Returns:
color to be assigned to group

Definition at line 413 of file SMESHGUI_GroupOpDlg.cxx.

References SMESHGUI_GroupOpDlg.myColorBtn.

Referenced by SMESHGUI_DimGroupDlg.onApply(), SMESHGUI_CutGroupsDlg.onApply(), onApply(), and SMESHGUI_UnionGroupsDlg.onApply().

{
  QColor aQColor = myColorBtn->color();

  SALOMEDS::Color aColor;
  aColor.R = (float)aQColor.red() / 255.0;
  aColor.G = (float)aQColor.green() / 255.0;
  aColor.B = (float)aQColor.blue() / 255.0;

  return aColor;
}
QString SMESHGUI_GroupOpDlg::getName ( ) const [protected, inherited]

Gets name of group to be created.

Returns:
name of group to be created
See also:
setName()

Definition at line 494 of file SMESHGUI_GroupOpDlg.cxx.

References SMESHGUI_GroupOpDlg.myNameEdit.

Referenced by SMESHGUI_DimGroupDlg.onApply(), SMESHGUI_CutGroupsDlg.onApply(), onApply(), and SMESHGUI_UnionGroupsDlg.onApply().

{
  return myNameEdit->text();
}
bool SMESHGUI_GroupOpDlg::getSelectedGroups ( QList< SMESH::SMESH_GroupBase_var > &  theOutList,
QStringList &  theOutNames 
) [protected, inherited]

Gets list of currently selected groups from selection manager.

Parameters:
theOutListout list of groups
theOutNamesout list of group of group names
Returns:
TRUE if operation theOutList is not empty, FALSE otherwise

Definition at line 366 of file SMESHGUI_GroupOpDlg.cxx.

References SMESH_controls.aGroup, and SMESHGUI_GroupOpDlg.mySelectionMgr.

Referenced by SMESHGUI_DimGroupDlg.onSelectionDone(), SMESHGUI_CutGroupsDlg.onSelectionDone(), onSelectionDone(), and SMESHGUI_UnionGroupsDlg.onSelectionDone().

{
  theOutList.clear();

  theOutList.clear();
  theOutNames.clear();

  SALOME_ListIO aListIO;
  mySelectionMgr->selectedObjects( aListIO );
  SALOME_ListIteratorOfListIO anIter ( aListIO );
  for ( ; anIter.More(); anIter.Next()) 
  {
    SMESH::SMESH_GroupBase_var aGroup =
      SMESH::IObjectToInterface<SMESH::SMESH_GroupBase>(anIter.Value());
    if ( !aGroup->_is_nil()) 
    {
      theOutList.append( aGroup );
      theOutNames.append( aGroup->GetName() );
    }
  }

  return theOutList.count() > 0;
}
SMESHGUI * SMESHGUI_GroupOpDlg::getSMESHGUI ( ) const [protected, inherited]

Gets pointer to the module instance.

Returns:
pointer to the module instance

Definition at line 174 of file SMESHGUI_GroupOpDlg.cxx.

References SMESHGUI_GroupOpDlg.mySMESHGUI.

Referenced by SMESHGUI_DimGroupDlg.onApply(), SMESHGUI_CutGroupsDlg.onApply(), onApply(), SMESHGUI_UnionGroupsDlg.onApply(), and SMESHGUI_CutGroupsDlg.SMESHGUI_CutGroupsDlg().

{
  return mySMESHGUI;
}
void SMESHGUI_GroupOpDlg::Init ( ) [inherited]

Init dialog fields, connect signals and slots, show dialog.

Definition at line 224 of file SMESHGUI_GroupOpDlg.cxx.

References SMESH.GetViewWindow(), GROUP, SMESHGUI_GroupOpDlg.mySelectionMgr, SMESHGUI_GroupOpDlg.mySMESHGUI, SMESHGUI_GroupOpDlg.onDeactivate(), SMESHGUI_GroupOpDlg.onSelectionDone(), and SMESHGUI.SetActiveDialogBox().

Referenced by SMESHGUI_GroupOpDlg.SMESHGUI_GroupOpDlg().

{
  mySMESHGUI->SetActiveDialogBox((QDialog*)this);
  
  // selection and SMESHGUI
  connect(mySelectionMgr, SIGNAL(currentSelectionChanged()), SLOT(onSelectionDone()));
  connect(mySMESHGUI, SIGNAL(SignalDeactivateActiveDialog()), SLOT(onDeactivate()));
  connect(mySMESHGUI, SIGNAL(SignalCloseAllDialogs()), SLOT(ClickOnClose()));

  // set selection mode
  if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
    aViewWindow->SetSelectionMode(ActorSelection);
  mySelectionMgr->installFilter(new SMESH_TypeFilter (GROUP));
}
bool SMESHGUI_GroupOpDlg::isApplyAndClose ( ) const [protected, inherited]

Get value of the flag indicating that the dialog is accepted by Apply & Close button.

Returns:
value of the flag
See also:
setApplyAndClose()

Definition at line 551 of file SMESHGUI_GroupOpDlg.cxx.

References SMESHGUI_GroupOpDlg.myIsApplyAndClose.

Referenced by SMESHGUI_DimGroupDlg.onApply(), SMESHGUI_CutGroupsDlg.onApply(), onApply(), and SMESHGUI_UnionGroupsDlg.onApply().

{
  return myIsApplyAndClose;
}
bool SMESHGUI_GroupOpDlg::isValid ( const QList< SMESH::SMESH_GroupBase_var > &  theListGrp) [protected, inherited]

Validate list of groups used for operation.

Checks whether they corresponds to the same face and have one type

Parameters:
theListGrpinput list of groups
Returns:
TRUE if groups are valid, FALSE otherwise

Definition at line 245 of file SMESHGUI_GroupOpDlg.cxx.

Referenced by SMESHGUI_DimGroupDlg.onApply(), SMESHGUI_CutGroupsDlg.onApply(), onApply(), and SMESHGUI_UnionGroupsDlg.onApply().

{
  if ( theListGrp.isEmpty() )
  {
    SUIT_MessageBox::information( this, tr("SMESH_INSUFFICIENT_DATA"),
                                  tr("INCORRECT_ARGUMENTS") );
    return false;
  }

  int aMeshId = -1, aGrpType = -1;
  QList<SMESH::SMESH_GroupBase_var>::const_iterator anIter;
  for ( anIter = theListGrp.begin(); anIter != theListGrp.end(); ++anIter )
  {
    SMESH::SMESH_GroupBase_var aGrp = *anIter;
    if ( CORBA::is_nil( aGrp ) )
      continue; // nonsence

    SMESH::SMESH_Mesh_var aMesh = aGrp->GetMesh();
    if ( CORBA::is_nil( aMesh ) )
      continue;

    // mesh id
    int aCurrId = aMesh->GetId();
    if ( aMeshId == -1 )
      aMeshId = aCurrId;
    else 
    {
      if ( aMeshId != aCurrId )
      {
        aMeshId = -1; // different meshes
        break;
      }
    }

    // group type
    int aCurrType = aGrp->GetType();
    if ( aGrpType == -1 )
      aGrpType = aCurrType;
    else 
    {
      if ( aGrpType != aCurrType )
      {
        aGrpType = -1; // different types
        break;
      }
    }

  }

  if ( aMeshId == -1 )
  {
    SUIT_MessageBox::information(this, tr("SMESH_INSUFFICIENT_DATA"),
                                 tr("DIFF_MESHES"));
    return false;
  }

  if ( aGrpType == -1 ) 
  {
    SUIT_MessageBox::information(this, tr("SMESH_INSUFFICIENT_DATA"),
                                 tr("DIFF_TYPES"));
    return false;
  }

  return true;
}
bool SMESHGUI_IntersectGroupsDlg::onApply ( ) [protected, virtual, slot]

SLOT called when apply button is pressed performs operation.

Returns:
TRUE if operation has been completed successfully, FALSE otherwise

Reimplemented from SMESHGUI_GroupOpDlg.

Definition at line 706 of file SMESHGUI_GroupOpDlg.cxx.

References _PTR(), SMESHGUI_GroupOpDlg.convert(), SMESHGUI_GroupOpDlg.getColor(), SMESHGUI_GroupOpDlg.getName(), SMESHGUI_GroupOpDlg.getSMESHGUI(), SMESHGUI_GroupOpDlg.isApplyAndClose(), SMESHGUI_GroupOpDlg.isValid(), SMESHGUI.Modified(), myGroups, and reset().

{
  if ( getSMESHGUI()->isActiveStudyLocked())
    return false;

  // Verify validity of group name
  if ( getName() == "" ) 
  {
    SUIT_MessageBox::information(this, tr("SMESH_INSUFFICIENT_DATA"),
                                 SMESHGUI_GroupOpDlg::tr("EMPTY_NAME"));
    return false;
  }

  if ( !isValid( myGroups ) )
    return false;

  SMESH::SMESH_Mesh_var aMesh = myGroups.first()->GetMesh();
  QString aName = getName();
  
  bool aRes = false;
  QStringList anEntryList;
  try
  {
    SMESH::ListOfGroups_var aList = convert( myGroups );
    SMESH::SMESH_Group_var aNewGrp = 
      aMesh->IntersectListOfGroups( aList, aName.toLatin1().constData() );
    if ( !CORBA::is_nil( aNewGrp ) )
    {
      aNewGrp->SetColor(  getColor() );
      if( _PTR(SObject) aSObject = SMESH::ObjectToSObject( aNewGrp ) )
        anEntryList.append( aSObject->GetID().c_str() );
      aRes = true;
    }
  }
  catch( ... )
  {
    aRes = false;
  }

  if ( aRes ) 
  {
    SMESHGUI::Modified();
    getSMESHGUI()->updateObjBrowser(true);
    reset();
    if( LightApp_Application* anApp =
        dynamic_cast<LightApp_Application*>( SUIT_Session::session()->activeApplication() ) )
      anApp->browseObjects( anEntryList, isApplyAndClose() );
    return true;
  } 
  else 
  {
    SUIT_MessageBox::critical(this, tr("SMESH_ERROR"),
                              tr("SMESH_OPERATION_FAILED"));
    return false;
  }
}
void SMESHGUI_IntersectGroupsDlg::onSelectionDone ( ) [protected, virtual, slot]

SLOT, called when selection is changed, updates corresponding GUI controls.

Reimplemented from SMESHGUI_GroupOpDlg.

Definition at line 766 of file SMESHGUI_GroupOpDlg.cxx.

References SMESHGUI_GroupOpDlg.getSelectedGroups(), myGroups, and myListWg.

{
  QStringList aNames;
  getSelectedGroups( myGroups, aNames );
  myListWg->clear();
  myListWg->addItems( aNames );
}
void SMESHGUI_IntersectGroupsDlg::reset ( ) [protected, virtual]

This virtual method redefined from the base class resets state of the dialog, initializes its fields with default value, etc.

Reimplemented from SMESHGUI_GroupOpDlg.

Definition at line 695 of file SMESHGUI_GroupOpDlg.cxx.

References myGroups, and myListWg.

Referenced by onApply().

{
  SMESHGUI_GroupOpDlg::reset();
  myListWg->clear();
  myGroups.clear();
}
void SMESHGUI_GroupOpDlg::setHelpFileName ( const QString &  theFName) [protected, inherited]
void SMESHGUI_GroupOpDlg::setIsApplyAndClose ( const bool  theFlag) [protected, inherited]

Set value of the flag indicating that the dialog is accepted by Apply & Close button.

Parameters:
theFlagvalue of the flag
See also:
isApplyAndClose()

Definition at line 540 of file SMESHGUI_GroupOpDlg.cxx.

References SMESHGUI_GroupOpDlg.myIsApplyAndClose.

Referenced by SMESHGUI_GroupOpDlg.onOk().

{
  myIsApplyAndClose = theFlag;
}
void SMESHGUI_GroupOpDlg::setName ( const QString &  theName) [protected, inherited]

Sets name of group to be created.

Parameters:
theNamename of group to be created
See also:
getName()

Definition at line 504 of file SMESHGUI_GroupOpDlg.cxx.

References SMESHGUI_GroupOpDlg.myNameEdit.

{
  myNameEdit->setText( theName );
}
void SMESHGUI_GroupOpDlg::setVisible ( bool  visible) [protected, virtual, slot, inherited]

Calls onSelectionDone() and setVisible() method of base class.

Parameters:
visiblethe visible state of the dialog

Definition at line 438 of file SMESHGUI_GroupOpDlg.cxx.

References ex21_lamp.height, and SMESHGUI_GroupOpDlg.onSelectionDone().

{
  if ( visible )
  {
    onSelectionDone();
    resize( minimumSizeHint().width(), sizeHint().height() );
  }
  QDialog::setVisible( visible );
}

Field Documentation

QList<SMESH::SMESH_GroupBase_var> SMESHGUI_IntersectGroupsDlg.myGroups [private]

Definition at line 178 of file SMESHGUI_GroupOpDlg.h.

Referenced by onApply(), onSelectionDone(), and reset().

QListWidget* SMESHGUI_IntersectGroupsDlg.myListWg [private]

Definition at line 177 of file SMESHGUI_GroupOpDlg.h.

Referenced by onSelectionDone(), reset(), and SMESHGUI_IntersectGroupsDlg().

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